Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@salesforce/agents

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/agents - npm Package Compare versions

Comparing version 0.1.6 to 0.2.0

lib/agentTester.d.ts

3

lib/agent.d.ts
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc