@salesforce/agents
Advanced tools
Comparing version 0.1.6 to 0.2.0
import { Connection, SfProject } from '@salesforce/core'; | ||
import { type SfAgent, type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig } from './types.js'; | ||
export declare class Agent implements SfAgent { | ||
private connection; | ||
private project; | ||
private logger; | ||
private mockDir?; | ||
private maybeMock; | ||
constructor(connection: Connection, project: SfProject); | ||
@@ -9,0 +8,0 @@ create(config: AgentCreateConfig): Promise<AgentCreateResponse>; |
@@ -10,18 +10,14 @@ "use strict"; | ||
exports.Agent = void 0; | ||
const node_path_1 = require("node:path"); | ||
const node_fs_1 = require("node:fs"); | ||
const node_util_1 = require("node:util"); | ||
const core_1 = require("@salesforce/core"); | ||
const kit_1 = require("@salesforce/kit"); | ||
const mockDir_1 = require("./mockDir"); | ||
const maybe_mock_1 = require("./maybe-mock"); | ||
class Agent { | ||
connection; | ||
project; | ||
logger; | ||
mockDir; | ||
maybeMock; | ||
constructor(connection, project) { | ||
this.connection = connection; | ||
this.project = project; | ||
this.logger = core_1.Logger.childFromRoot(this.constructor.name); | ||
this.mockDir = (0, mockDir_1.getMockDir)(); | ||
this.maybeMock = new maybe_mock_1.MaybeMock(connection); | ||
} | ||
@@ -44,47 +40,11 @@ async create(config) { | ||
let agentSpec; | ||
if (this.mockDir) { | ||
const specFileName = `${config.name}.json`; | ||
const specFilePath = (0, node_path_1.join)(this.mockDir, `${specFileName}`); | ||
try { | ||
this.logger.debug(`Using mock directory: ${this.mockDir} for agent job spec creation`); | ||
(0, node_fs_1.statSync)(specFilePath); | ||
} | ||
catch (err) { | ||
throw core_1.SfError.create({ | ||
name: 'MissingMockFile', | ||
message: `SF_MOCK_DIR [${this.mockDir}] must contain a spec file with name ${specFileName}`, | ||
cause: err, | ||
}); | ||
} | ||
try { | ||
this.logger.debug(`Returning mock agent spec file: ${specFilePath}`); | ||
agentSpec = JSON.parse((0, node_fs_1.readFileSync)(specFilePath, 'utf8')); | ||
} | ||
catch (err) { | ||
throw core_1.SfError.create({ | ||
name: 'InvalidMockFile', | ||
message: `SF_MOCK_DIR [${this.mockDir}] must contain a valid spec file with name ${specFileName}`, | ||
cause: err, | ||
actions: [ | ||
'Check that the file is readable', | ||
'Check that the file is a valid JSON array of jobTitle and jobDescription objects', | ||
], | ||
}); | ||
} | ||
const response = await this.maybeMock.request('GET', this.buildAgentJobSpecUrl(config)); | ||
if (response.isSuccess && response.jobSpecs) { | ||
agentSpec = response.jobSpecs; | ||
} | ||
else { | ||
// TODO: We'll probably want to wrap this for better error handling but let's see | ||
// what it looks like first. | ||
const response = await this.connection.requestGet(this.buildAgentJobSpecUrl(config), { | ||
retry: { maxRetries: 3 }, | ||
throw core_1.SfError.create({ | ||
name: 'AgentJobSpecCreateError', | ||
message: response.errorMessage ?? 'unknown', | ||
}); | ||
if (response.isSuccess) { | ||
agentSpec = response?.jobSpecs; | ||
} | ||
else { | ||
throw core_1.SfError.create({ | ||
name: 'AgentJobSpecCreateError', | ||
message: response.errorMessage ?? 'unknown', | ||
}); | ||
} | ||
} | ||
@@ -91,0 +51,0 @@ return agentSpec; |
export { AgentCreateConfig, AgentCreateResponse, AgentJobSpec, AgentJobSpecCreateConfig, AgentJobSpecCreateResponse, SfAgent, } from './types'; | ||
export { Agent } from './agent'; | ||
export { AgentTester } from './agentTester'; |
@@ -9,5 +9,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Agent = void 0; | ||
exports.AgentTester = exports.Agent = void 0; | ||
var agent_1 = require("./agent"); | ||
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return agent_1.Agent; } }); | ||
var agentTester_1 = require("./agentTester"); | ||
Object.defineProperty(exports, "AgentTester", { enumerable: true, get: function () { return agentTester_1.AgentTester; } }); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@salesforce/agents", | ||
"description": "Client side APIs for working with Salesforce agents", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"license": "BSD-3-Clause", | ||
@@ -14,7 +14,10 @@ "author": "Salesforce", | ||
"dependencies": { | ||
"@oclif/table": "^0.3.3", | ||
"@salesforce/core": "^8.8.0", | ||
"@salesforce/kit": "^3.2.3" | ||
"@salesforce/kit": "^3.2.3", | ||
"@salesforce/sf-plugins-core": "^12.1.0", | ||
"nock": "^13.5.6" | ||
}, | ||
"devDependencies": { | ||
"@salesforce/cli-plugins-testkit": "^5.3.20", | ||
"@salesforce/cli-plugins-testkit": "^5.3.38", | ||
"@salesforce/dev-scripts": "^10.2.10", | ||
@@ -21,0 +24,0 @@ "ts-node": "^10.9.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36725
19
509
5
1
+ Added@oclif/table@^0.3.3
+ Addednock@^13.5.6
+ Added@alcalzone/ansi-tokenize@0.1.3(transitive)
+ Added@inquirer/confirm@3.2.0(transitive)
+ Added@inquirer/core@9.2.1(transitive)
+ Added@inquirer/figures@1.0.9(transitive)
+ Added@inquirer/password@2.2.0(transitive)
+ Added@inquirer/type@1.5.52.0.0(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@oclif/core@4.2.0(transitive)
+ Added@oclif/table@0.3.9(transitive)
+ Added@salesforce/sf-plugins-core@12.1.1(transitive)
+ Added@types/mute-stream@0.0.4(transitive)
+ Added@types/node@22.10.2(transitive)
+ Added@types/prop-types@15.7.14(transitive)
+ Added@types/react@18.3.18(transitive)
+ Added@types/wrap-ansi@3.0.0(transitive)
+ Addedansi-escapes@4.3.25.0.07.0.0(transitive)
+ Addedansi-regex@5.0.16.1.0(transitive)
+ Addedansi-styles@4.3.06.2.1(transitive)
+ Addedansis@3.5.2(transitive)
+ Addedarray-union@2.1.0(transitive)
+ Addedasync@3.2.6(transitive)
+ Addedauto-bind@5.0.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.112.0.1(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchalk@4.1.25.4.1(transitive)
+ Addedchange-case@5.4.4(transitive)
+ Addedclean-stack@3.0.1(transitive)
+ Addedcli-boxes@3.0.0(transitive)
+ Addedcli-cursor@4.0.0(transitive)
+ Addedcli-progress@3.12.0(transitive)
+ Addedcli-spinners@2.9.2(transitive)
+ Addedcli-truncate@4.0.0(transitive)
+ Addedcli-width@4.1.0(transitive)
+ Addedcode-excerpt@4.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconvert-to-spaces@2.0.1(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addeddir-glob@3.0.1(transitive)
+ Addedejs@3.1.10(transitive)
+ Addedemoji-regex@10.4.08.0.0(transitive)
+ Addedenvironment@1.1.0(transitive)
+ Addedes-toolkit@1.31.0(transitive)
+ Addedescape-string-regexp@2.0.04.0.0(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfastq@1.18.0(transitive)
+ Addedfilelist@1.0.4(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedget-east-asian-width@1.3.0(transitive)
+ Addedget-package-type@0.1.0(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedglobby@11.1.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedindent-string@4.0.05.0.0(transitive)
+ Addedink@5.1.0(transitive)
+ Addedis-docker@2.2.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-fullwidth-code-point@3.0.04.0.05.0.0(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-in-ci@1.0.0(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-wsl@2.2.0(transitive)
+ Addedjake@10.9.2(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedlilconfig@3.1.3(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedminimatch@3.1.25.1.69.0.5(transitive)
+ Addedmute-stream@1.0.0(transitive)
+ Addednatural-orderby@3.0.2(transitive)
+ Addednock@13.5.6(transitive)
+ Addedobject-hash@3.0.0(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedpatch-console@2.0.0(transitive)
+ Addedpath-type@4.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedpropagate@2.0.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreact@18.3.1(transitive)
+ Addedreact-reconciler@0.29.2(transitive)
+ Addedrestore-cursor@4.0.0(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedscheduler@0.23.2(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedslash@3.0.0(transitive)
+ Addedslice-ansi@5.0.07.1.0(transitive)
+ Addedstack-utils@2.0.6(transitive)
+ Addedstring-width@4.2.37.2.0(transitive)
+ Addedstrip-ansi@6.0.17.1.0(transitive)
+ Addedsupports-color@7.2.08.1.1(transitive)
+ Addedsupports-hyperlinks@2.3.0(transitive)
+ Addedterminal-link@3.0.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedtype-fest@0.21.31.4.04.31.0(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedwidest-line@3.1.05.0.0(transitive)
+ Addedwordwrap@1.0.0(transitive)
+ Addedwrap-ansi@6.2.07.0.09.0.0(transitive)
+ Addedws@8.18.0(transitive)
+ Addedyoctocolors-cjs@2.1.2(transitive)
+ Addedyoga-wasm-web@0.3.3(transitive)