@salesforce/agents 0.20.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/agent.d.ts +25 -86
- package/lib/agent.js +90 -310
- package/lib/agent.js.map +1 -1
- package/lib/agentTest.js +1 -1
- package/lib/agentTestResults.js +1 -1
- package/lib/agentTester.js +1 -1
- package/lib/agents/agentBase.d.ts +77 -0
- package/lib/agents/agentBase.js +106 -0
- package/lib/agents/agentBase.js.map +1 -0
- package/lib/agents/productionAgent.d.ts +57 -0
- package/lib/agents/productionAgent.js +368 -0
- package/lib/agents/productionAgent.js.map +1 -0
- package/lib/agents/scriptAgent.d.ts +69 -0
- package/lib/agents/scriptAgent.js +463 -0
- package/lib/agents/scriptAgent.js.map +1 -0
- package/lib/{agentPublisher.d.ts → agents/scriptAgentPublisher.d.ts} +23 -10
- package/lib/{agentPublisher.js → agents/scriptAgentPublisher.js} +42 -17
- package/lib/agents/scriptAgentPublisher.js.map +1 -0
- package/lib/apexUtils.js +1 -1
- package/lib/index.d.ts +4 -5
- package/lib/index.js +8 -10
- package/lib/index.js.map +1 -1
- package/lib/maybe-mock.js +1 -1
- package/lib/templates/agentScriptTemplate.d.ts +9 -0
- package/lib/templates/agentScriptTemplate.js +149 -0
- package/lib/templates/agentScriptTemplate.js.map +1 -0
- package/lib/types.d.ts +44 -13
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils.d.ts +68 -7
- package/lib/utils.js +215 -20
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/lib/agentPreview.d.ts +0 -78
- package/lib/agentPreview.js +0 -258
- package/lib/agentPreview.js.map +0 -1
- package/lib/agentPreviewBase.d.ts +0 -59
- package/lib/agentPreviewBase.js +0 -55
- package/lib/agentPreviewBase.js.map +0 -1
- package/lib/agentPublisher.js.map +0 -1
- package/lib/agentSimulate.d.ts +0 -79
- package/lib/agentSimulate.js +0 -297
- package/lib/agentSimulate.js.map +0 -1
- package/lib/agentTrace.d.ts +0 -23
- package/lib/agentTrace.js +0 -47
- package/lib/agentTrace.js.map +0 -1
package/lib/agentPreview.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agentPreview.js","sourceRoot":"","sources":["../src/agentPreview.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,6CAAyC;AACzC,2CAAiE;AACjE,yCAAsC;AACtC,mCAAgC;AAChC,yDAAsD;AAStD,mCAAgD;AAChD,2CAA0E;;AAG1E,MAAM,QAAQ,OAAG,eAAQ,CAAc,oBAAoB,EAAE,cAAc,qNAAC,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,YAAa,SAAQ,mCAAgB;IAC7B,OAAO,GAAG,WAC3B,SAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAC5C,yCAAyC,CAAC;IACzB,KAAK,CAAS;IAE/B;;;;;OAKG;IACH,YAAmB,UAAsB,EAAE,KAAa;QACtD,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACjE,MAAM,QAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,KAAK;QAChB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,WAAW,IAAI,CAAC,KAAK,WAAW,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6CAA6C,IAAI,CAAC,KAAK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MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAClD,IAAI,OAAO,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;gBAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qDAAqD,OAAO,EAAE,CAAC,CAAC;gBAClF,OAAO;YACT,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,QAAQ,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,MAAM,IAAA,yBAAa,EAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,IAAA,2BAAe,EAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;CACF;AA1ND,oCA0NC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Connection, Logger } from '@salesforce/core';
|
|
2
|
-
import { MaybeMock } from './maybe-mock';
|
|
3
|
-
import { type AgentPreviewEndResponse, type AgentPreviewStartResponse, type AgentPreviewSendResponse, type EndReason, type BaseAgentConfig, type AgentInteractionBase, PlannerResponse } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Abstract base class for agent runners that provides common functionality
|
|
6
|
-
* for interacting with agents through the Einstein AI Agent API.
|
|
7
|
-
*/
|
|
8
|
-
export declare abstract class AgentPreviewBase implements AgentInteractionBase {
|
|
9
|
-
protected connection: Connection;
|
|
10
|
-
protected apexTraceFlag?: {
|
|
11
|
-
Id?: string;
|
|
12
|
-
ExpirationDate?: string;
|
|
13
|
-
};
|
|
14
|
-
protected readonly logger: Logger;
|
|
15
|
-
protected readonly maybeMock: MaybeMock;
|
|
16
|
-
protected apexDebugMode?: boolean;
|
|
17
|
-
protected constructor(config: BaseAgentConfig);
|
|
18
|
-
/**
|
|
19
|
-
* Get the base API URL for the agent service.
|
|
20
|
-
* This is overridden by child classes to provide their specific API base.
|
|
21
|
-
*/
|
|
22
|
-
protected abstract get apiBase(): string;
|
|
23
|
-
/**
|
|
24
|
-
* Enable or disable Apex Debug Mode, which will enable trace flags for the Bot user
|
|
25
|
-
* and create apex debug logs for use within VS Code's Apex Replay Debugger.
|
|
26
|
-
*
|
|
27
|
-
* @param enable Whether to enable or disable Apex Debug Mode.
|
|
28
|
-
*/
|
|
29
|
-
setApexDebugMode(enable: boolean): void;
|
|
30
|
-
/**
|
|
31
|
-
* Start an interactive session with the agent.
|
|
32
|
-
* This is implemented by child classes to provide their specific start logic.
|
|
33
|
-
*/
|
|
34
|
-
abstract start(): Promise<AgentPreviewStartResponse>;
|
|
35
|
-
/**
|
|
36
|
-
* Send a message to the agent using the session ID obtained by calling `start()`.
|
|
37
|
-
*
|
|
38
|
-
* @param sessionId A session ID provided by first calling `start()`.
|
|
39
|
-
* @param message A message to send to the agent.
|
|
40
|
-
* @returns `AgentPreviewSendResponse`
|
|
41
|
-
*/
|
|
42
|
-
abstract send(sessionId: string, message: string): Promise<AgentPreviewSendResponse>;
|
|
43
|
-
/**
|
|
44
|
-
* Ends an interactive session with the agent.
|
|
45
|
-
*
|
|
46
|
-
* @param sessionId A session ID provided by first calling `start()`.
|
|
47
|
-
* @param reason A reason why the interactive session was ended.
|
|
48
|
-
* @returns `AgentPreviewEndResponse`
|
|
49
|
-
*/
|
|
50
|
-
abstract end(sessionId: string, reason: EndReason): Promise<AgentPreviewEndResponse>;
|
|
51
|
-
/**
|
|
52
|
-
* Get the traces for a given session and message IDs.
|
|
53
|
-
*
|
|
54
|
-
* @param sessionId A session ID provided by first calling `start()`.
|
|
55
|
-
* @param messageIds An array of message IDs to get the traces for.
|
|
56
|
-
* @returns `PlannerResponse[]`
|
|
57
|
-
*/
|
|
58
|
-
abstract traces(sessionId: string, messageIds: string[]): Promise<PlannerResponse[]>;
|
|
59
|
-
}
|
package/lib/agentPreviewBase.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2025, Salesforce, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.AgentPreviewBase = void 0;
|
|
19
|
-
const core_1 = require("@salesforce/core");
|
|
20
|
-
const maybe_mock_1 = require("./maybe-mock");
|
|
21
|
-
/**
|
|
22
|
-
* Abstract base class for agent runners that provides common functionality
|
|
23
|
-
* for interacting with agents through the Einstein AI Agent API.
|
|
24
|
-
*/
|
|
25
|
-
class AgentPreviewBase {
|
|
26
|
-
connection;
|
|
27
|
-
apexTraceFlag;
|
|
28
|
-
logger;
|
|
29
|
-
maybeMock;
|
|
30
|
-
apexDebugMode;
|
|
31
|
-
constructor(config) {
|
|
32
|
-
if (!config.connection) {
|
|
33
|
-
throw new Error('Connection is required');
|
|
34
|
-
}
|
|
35
|
-
// Protected properties
|
|
36
|
-
const connection = config.connection;
|
|
37
|
-
const logger = config.logger ?? core_1.Logger.childFromRoot(this.constructor.name);
|
|
38
|
-
// Initialize protected properties
|
|
39
|
-
this.connection = connection;
|
|
40
|
-
this.logger = logger;
|
|
41
|
-
this.maybeMock = new maybe_mock_1.MaybeMock(connection);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Enable or disable Apex Debug Mode, which will enable trace flags for the Bot user
|
|
45
|
-
* and create apex debug logs for use within VS Code's Apex Replay Debugger.
|
|
46
|
-
*
|
|
47
|
-
* @param enable Whether to enable or disable Apex Debug Mode.
|
|
48
|
-
*/
|
|
49
|
-
setApexDebugMode(enable) {
|
|
50
|
-
this.apexDebugMode = enable;
|
|
51
|
-
this.logger.debug(`Apex Debug Mode is now ${enable ? 'enabled' : 'disabled'}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.AgentPreviewBase = AgentPreviewBase;
|
|
55
|
-
//# sourceMappingURL=agentPreviewBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agentPreviewBase.js","sourceRoot":"","sources":["../src/agentPreviewBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2CAAsD;AACtD,6CAAyC;AAWzC;;;GAGG;AACH,MAAsB,gBAAgB;IAC1B,UAAU,CAAa;IACvB,aAAa,CAA4C;IAChD,MAAM,CAAS;IACf,SAAS,CAAY;IAC9B,aAAa,CAAW;IAElC,YAAsB,MAAuB;QAC3C,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,uBAAuB;QACvB,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,aAAM,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE5E,kCAAkC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IA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C;YAC7E,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAxQD,wCAwQC"}
|
package/lib/agentSimulate.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { AgentPreviewBase } from './agentPreviewBase';
|
|
3
|
-
import { type AgentPreviewEndResponse, type AgentPreviewSendResponse, type AgentPreviewStartResponse, PlannerResponse } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* A service to simulate interactions with an agent using a local .agent file.
|
|
6
|
-
* The file will be compiled using Agent.compileAgent before being used
|
|
7
|
-
* with the simulation endpoints.
|
|
8
|
-
*
|
|
9
|
-
* **Examples**
|
|
10
|
-
*
|
|
11
|
-
* Create an instance of the service:
|
|
12
|
-
*
|
|
13
|
-
* `const agentSimulate = new AgentSimulate(connection, './path/to/agent.agent');`
|
|
14
|
-
*
|
|
15
|
-
* Start an interactive session:
|
|
16
|
-
*
|
|
17
|
-
* `const { sessionId } = await agentSimulate.start();`
|
|
18
|
-
*
|
|
19
|
-
* Send a message to the agent using the session ID from the startResponse:
|
|
20
|
-
*
|
|
21
|
-
* `const sendResponse = await agentSimulate.send(sessionId, message);`
|
|
22
|
-
*
|
|
23
|
-
* End an interactive session:
|
|
24
|
-
*
|
|
25
|
-
* `await agentSimulate.end(sessionId, 'UserRequest');`
|
|
26
|
-
*
|
|
27
|
-
* Enable Apex Debug Mode:
|
|
28
|
-
*
|
|
29
|
-
* `agentSimulate.toggleApexDebugMode(true);`
|
|
30
|
-
*/
|
|
31
|
-
export declare class AgentSimulate extends AgentPreviewBase {
|
|
32
|
-
/**
|
|
33
|
-
* The client can specify whether the actions will run in a simulated mode ("mock actions", no side effects, mockActions=true) or a non-simulated mode ("real actions", actions with side effects, mockActions=false)
|
|
34
|
-
*/
|
|
35
|
-
mockActions: boolean;
|
|
36
|
-
protected readonly apiBase: string;
|
|
37
|
-
private readonly agentFilePath;
|
|
38
|
-
private compiledAgent?;
|
|
39
|
-
/**
|
|
40
|
-
* Create an instance of the service.
|
|
41
|
-
*
|
|
42
|
-
* @param connection The connection to use to make requests.
|
|
43
|
-
* @param agentFilePath Path to the .agent file to simulate.
|
|
44
|
-
* @param mockActions whether or not to mock the actions of the simulated agent
|
|
45
|
-
*/
|
|
46
|
-
constructor(connection: Connection, agentFilePath: string, mockActions: boolean);
|
|
47
|
-
/**
|
|
48
|
-
* Start an interactive simulation session with the agent.
|
|
49
|
-
* This will first compile the agent script if it hasn't been compiled yet.
|
|
50
|
-
*
|
|
51
|
-
* @returns `AgentPreviewStartResponse`, which includes a session ID needed for other actions.
|
|
52
|
-
*/
|
|
53
|
-
start(): Promise<AgentPreviewStartResponse>;
|
|
54
|
-
/**
|
|
55
|
-
* Send a message to the agent using the session ID obtained by calling `start()`.
|
|
56
|
-
*
|
|
57
|
-
* @param sessionId A session ID provided by first calling `agentSimulate.start()`.
|
|
58
|
-
* @param message A message to send to the agent.
|
|
59
|
-
* @returns `AgentPreviewSendResponse`
|
|
60
|
-
*/
|
|
61
|
-
send(sessionId: string, message: string): Promise<AgentPreviewSendResponse>;
|
|
62
|
-
/**
|
|
63
|
-
* Ending is not required, or supported, for AgentSimulation
|
|
64
|
-
* this is a noop method to support easier consumer typings
|
|
65
|
-
*
|
|
66
|
-
* @returns `AgentPreviewEndResponse`
|
|
67
|
-
*/
|
|
68
|
-
end(): Promise<AgentPreviewEndResponse>;
|
|
69
|
-
/**
|
|
70
|
-
* Enable or disable Apex Debug Mode, which will enable trace flags for the Bot user
|
|
71
|
-
* and create apex debug logs for use within VS Code's Apex Replay Debugger.
|
|
72
|
-
*
|
|
73
|
-
* @param enable Whether to enable or disable Apex Debug Mode.
|
|
74
|
-
*/
|
|
75
|
-
toggleApexDebugMode(enable: boolean): void;
|
|
76
|
-
trace(sessionId: string, messageId: string): Promise<PlannerResponse | null>;
|
|
77
|
-
traces(sessionId: string, messageIds: string[]): Promise<PlannerResponse[]>;
|
|
78
|
-
private ensureTraceFlag;
|
|
79
|
-
}
|
package/lib/agentSimulate.js
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2025, Salesforce, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.AgentSimulate = void 0;
|
|
19
|
-
const promises_1 = require("node:fs/promises");
|
|
20
|
-
const node_path_1 = require("node:path");
|
|
21
|
-
const node_crypto_1 = require("node:crypto");
|
|
22
|
-
const core_1 = require("@salesforce/core");
|
|
23
|
-
const kit_1 = require("@salesforce/kit");
|
|
24
|
-
const agent_1 = require("./agent");
|
|
25
|
-
const agentPreviewBase_1 = require("./agentPreviewBase");
|
|
26
|
-
const apexUtils_1 = require("./apexUtils");
|
|
27
|
-
const utils_1 = require("./utils");
|
|
28
|
-
/**
|
|
29
|
-
* A service to simulate interactions with an agent using a local .agent file.
|
|
30
|
-
* The file will be compiled using Agent.compileAgent before being used
|
|
31
|
-
* with the simulation endpoints.
|
|
32
|
-
*
|
|
33
|
-
* **Examples**
|
|
34
|
-
*
|
|
35
|
-
* Create an instance of the service:
|
|
36
|
-
*
|
|
37
|
-
* `const agentSimulate = new AgentSimulate(connection, './path/to/agent.agent');`
|
|
38
|
-
*
|
|
39
|
-
* Start an interactive session:
|
|
40
|
-
*
|
|
41
|
-
* `const { sessionId } = await agentSimulate.start();`
|
|
42
|
-
*
|
|
43
|
-
* Send a message to the agent using the session ID from the startResponse:
|
|
44
|
-
*
|
|
45
|
-
* `const sendResponse = await agentSimulate.send(sessionId, message);`
|
|
46
|
-
*
|
|
47
|
-
* End an interactive session:
|
|
48
|
-
*
|
|
49
|
-
* `await agentSimulate.end(sessionId, 'UserRequest');`
|
|
50
|
-
*
|
|
51
|
-
* Enable Apex Debug Mode:
|
|
52
|
-
*
|
|
53
|
-
* `agentSimulate.toggleApexDebugMode(true);`
|
|
54
|
-
*/
|
|
55
|
-
class AgentSimulate extends agentPreviewBase_1.AgentPreviewBase {
|
|
56
|
-
/**
|
|
57
|
-
* The client can specify whether the actions will run in a simulated mode ("mock actions", no side effects, mockActions=true) or a non-simulated mode ("real actions", actions with side effects, mockActions=false)
|
|
58
|
-
*/
|
|
59
|
-
mockActions;
|
|
60
|
-
apiBase = `https://${kit_1.env.getBoolean('SF_TEST_API') ? 'test.' : ''}api.salesforce.com/einstein/ai-agent`;
|
|
61
|
-
agentFilePath;
|
|
62
|
-
compiledAgent;
|
|
63
|
-
/**
|
|
64
|
-
* Create an instance of the service.
|
|
65
|
-
*
|
|
66
|
-
* @param connection The connection to use to make requests.
|
|
67
|
-
* @param agentFilePath Path to the .agent file to simulate.
|
|
68
|
-
* @param mockActions whether or not to mock the actions of the simulated agent
|
|
69
|
-
*/
|
|
70
|
-
constructor(connection, agentFilePath, mockActions) {
|
|
71
|
-
super({ connection });
|
|
72
|
-
this.agentFilePath = agentFilePath;
|
|
73
|
-
this.mockActions = mockActions;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Start an interactive simulation session with the agent.
|
|
77
|
-
* This will first compile the agent script if it hasn't been compiled yet.
|
|
78
|
-
*
|
|
79
|
-
* @returns `AgentPreviewStartResponse`, which includes a session ID needed for other actions.
|
|
80
|
-
*/
|
|
81
|
-
async start() {
|
|
82
|
-
if (!this.compiledAgent) {
|
|
83
|
-
void core_1.Lifecycle.getInstance().emit('agents:compiling', {});
|
|
84
|
-
this.logger.debug(`Compiling agent script from ${this.agentFilePath}`);
|
|
85
|
-
const agentString = await (0, promises_1.readFile)(this.agentFilePath, 'utf-8');
|
|
86
|
-
const compiledAgent = await agent_1.Agent.compileAgentScript(this.connection, agentString);
|
|
87
|
-
if (compiledAgent.status === 'success' && compiledAgent.compiledArtifact) {
|
|
88
|
-
this.compiledAgent = compiledAgent.compiledArtifact;
|
|
89
|
-
// we must set the compiledAgent.agentVersion.developerName, we'll get this from the -meta <target> field
|
|
90
|
-
const metaContent = await (0, promises_1.readFile)(`${this.agentFilePath.replace('.agent', '.bundle-meta.xml')}`, 'utf-8');
|
|
91
|
-
this.compiledAgent.agentVersion.developerName = metaContent.match(/<target>.*(v\d+)<\/target>/)?.at(1) ?? 'v0';
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
const formattedError = compiledAgent.errors
|
|
95
|
-
.map((e) => `- ${e.errorType} ${e.description}: ${e.lineStart}:${e.colStart} / ${e.lineEnd}:${e.colEnd}`)
|
|
96
|
-
.join('\n');
|
|
97
|
-
throw new core_1.SfError('Failed to compile agent script', formattedError);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
this.logger.debug('Starting agent simulation session');
|
|
101
|
-
// send bypassUser=false when the compiledAgent.globalConfiguration.defaultAgentUser is INVALID
|
|
102
|
-
let bypassUser = (await this.connection.query(`SELECT Id FROM USER WHERE username='${this.compiledAgent.globalConfiguration.defaultAgentUser}'`)).totalSize === 1;
|
|
103
|
-
if (bypassUser && this.compiledAgent.globalConfiguration.agentType === 'AgentforceEmployeeAgent') {
|
|
104
|
-
// another situation which bypassUser = false, is when previewing an agent script, with a valid default_agent_user, and it's an AgentforceEmployeeAgent type
|
|
105
|
-
bypassUser = false;
|
|
106
|
-
}
|
|
107
|
-
const body = {
|
|
108
|
-
agentDefinition: this.compiledAgent,
|
|
109
|
-
enableSimulationMode: this.mockActions,
|
|
110
|
-
externalSessionKey: (0, node_crypto_1.randomUUID)(),
|
|
111
|
-
instanceConfig: {
|
|
112
|
-
endpoint: this.connection.instanceUrl,
|
|
113
|
-
},
|
|
114
|
-
variables: [],
|
|
115
|
-
parameters: {},
|
|
116
|
-
streamingCapabilities: {
|
|
117
|
-
chunkTypes: ['Text', 'LightningChunk'],
|
|
118
|
-
},
|
|
119
|
-
richContentCapabilities: {},
|
|
120
|
-
bypassUser,
|
|
121
|
-
executionHistory: [],
|
|
122
|
-
conversationContext: [],
|
|
123
|
-
};
|
|
124
|
-
try {
|
|
125
|
-
void core_1.Lifecycle.getInstance().emit('agents:simulation-starting', {});
|
|
126
|
-
this.connection = await (0, utils_1.useNamedUserJwt)(this.connection);
|
|
127
|
-
const response = await this.connection.request({
|
|
128
|
-
method: 'POST',
|
|
129
|
-
url: `${this.apiBase}/v1.1/preview/sessions`,
|
|
130
|
-
headers: {
|
|
131
|
-
'x-attributed-client': 'no-builder', // <- removes markdown from responses
|
|
132
|
-
'x-client-name': 'afdx',
|
|
133
|
-
},
|
|
134
|
-
body: JSON.stringify(body),
|
|
135
|
-
}, { retry: { maxRetries: 3 } });
|
|
136
|
-
const agentIdForStorage = (0, node_path_1.basename)(this.agentFilePath);
|
|
137
|
-
await (0, utils_1.appendTranscriptEntry)({
|
|
138
|
-
timestamp: new Date().toISOString(),
|
|
139
|
-
agentId: agentIdForStorage,
|
|
140
|
-
sessionId: response.sessionId,
|
|
141
|
-
role: 'agent',
|
|
142
|
-
text: response.messages.map((m) => m.message).join('\n'),
|
|
143
|
-
raw: response.messages,
|
|
144
|
-
}, true);
|
|
145
|
-
return response;
|
|
146
|
-
}
|
|
147
|
-
catch (err) {
|
|
148
|
-
throw core_1.SfError.wrap(err);
|
|
149
|
-
}
|
|
150
|
-
finally {
|
|
151
|
-
// Always restore the original connection, even if an error occurred
|
|
152
|
-
delete this.connection.accessToken;
|
|
153
|
-
await this.connection.refreshAuth();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Send a message to the agent using the session ID obtained by calling `start()`.
|
|
158
|
-
*
|
|
159
|
-
* @param sessionId A session ID provided by first calling `agentSimulate.start()`.
|
|
160
|
-
* @param message A message to send to the agent.
|
|
161
|
-
* @returns `AgentPreviewSendResponse`
|
|
162
|
-
*/
|
|
163
|
-
async send(sessionId, message) {
|
|
164
|
-
if (!this.compiledAgent) {
|
|
165
|
-
throw new core_1.SfError('Agent not compiled, please call .start() first');
|
|
166
|
-
}
|
|
167
|
-
const url = `${this.apiBase}/v1.1/preview/sessions/${sessionId}/messages`;
|
|
168
|
-
const body = {
|
|
169
|
-
message: {
|
|
170
|
-
sequenceId: Date.now(),
|
|
171
|
-
type: 'Text',
|
|
172
|
-
text: message,
|
|
173
|
-
},
|
|
174
|
-
variables: [],
|
|
175
|
-
};
|
|
176
|
-
this.logger.debug(`Sending message with apexDebugMode ${this.apexDebugMode ? 'enabled' : 'disabled'}`);
|
|
177
|
-
const agentIdForStorage = (0, node_path_1.basename)(this.agentFilePath);
|
|
178
|
-
try {
|
|
179
|
-
const start = Date.now();
|
|
180
|
-
if (this.apexDebugMode && !this.mockActions) {
|
|
181
|
-
await this.ensureTraceFlag();
|
|
182
|
-
}
|
|
183
|
-
await (0, utils_1.appendTranscriptEntry)({
|
|
184
|
-
timestamp: new Date().toISOString(),
|
|
185
|
-
agentId: agentIdForStorage,
|
|
186
|
-
sessionId,
|
|
187
|
-
role: 'user',
|
|
188
|
-
text: message,
|
|
189
|
-
});
|
|
190
|
-
this.connection = await (0, utils_1.useNamedUserJwt)(this.connection);
|
|
191
|
-
const response = await this.connection.request({
|
|
192
|
-
method: 'POST',
|
|
193
|
-
url,
|
|
194
|
-
body: JSON.stringify(body),
|
|
195
|
-
headers: {
|
|
196
|
-
'x-client-name': 'afdx',
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
await (0, utils_1.appendTranscriptEntry)({
|
|
200
|
-
timestamp: new Date().toISOString(),
|
|
201
|
-
agentId: agentIdForStorage,
|
|
202
|
-
sessionId,
|
|
203
|
-
role: 'agent',
|
|
204
|
-
text: response.messages.map((m) => m.message).join('\n'),
|
|
205
|
-
raw: response.messages,
|
|
206
|
-
});
|
|
207
|
-
if (this.apexDebugMode && !this.mockActions) {
|
|
208
|
-
const apexLog = await (0, apexUtils_1.getDebugLog)(this.connection, start, Date.now());
|
|
209
|
-
if (apexLog) {
|
|
210
|
-
if (apexLog.Id)
|
|
211
|
-
this.logger.debug(`Apex debug log ID for message is ${apexLog.Id}`);
|
|
212
|
-
response.apexDebugLog = apexLog;
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
this.logger.debug('No apex debug log found for this message');
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return response;
|
|
219
|
-
}
|
|
220
|
-
catch (err) {
|
|
221
|
-
throw core_1.SfError.wrap(err);
|
|
222
|
-
}
|
|
223
|
-
finally {
|
|
224
|
-
// Always restore the original connection, even if an error occurred
|
|
225
|
-
delete this.connection.accessToken;
|
|
226
|
-
await this.connection.refreshAuth();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Ending is not required, or supported, for AgentSimulation
|
|
231
|
-
* this is a noop method to support easier consumer typings
|
|
232
|
-
*
|
|
233
|
-
* @returns `AgentPreviewEndResponse`
|
|
234
|
-
*/
|
|
235
|
-
// eslint-disable-next-line class-methods-use-this
|
|
236
|
-
async end() {
|
|
237
|
-
return Promise.resolve({ messages: [], _links: [] });
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Enable or disable Apex Debug Mode, which will enable trace flags for the Bot user
|
|
241
|
-
* and create apex debug logs for use within VS Code's Apex Replay Debugger.
|
|
242
|
-
*
|
|
243
|
-
* @param enable Whether to enable or disable Apex Debug Mode.
|
|
244
|
-
*/
|
|
245
|
-
toggleApexDebugMode(enable) {
|
|
246
|
-
this.setApexDebugMode(enable);
|
|
247
|
-
}
|
|
248
|
-
async trace(sessionId, messageId) {
|
|
249
|
-
const traces = await this.traces(sessionId, [messageId]);
|
|
250
|
-
return traces.length ? traces[0] : null;
|
|
251
|
-
}
|
|
252
|
-
async traces(sessionId, messageIds) {
|
|
253
|
-
try {
|
|
254
|
-
this.connection = await (0, utils_1.useNamedUserJwt)(this.connection);
|
|
255
|
-
const traces = [];
|
|
256
|
-
const tracePromises = messageIds.map((messageId) => this.connection.request({
|
|
257
|
-
method: 'GET',
|
|
258
|
-
url: `${this.apiBase}/v1.1/preview/sessions/${sessionId}/plans/${messageId}`,
|
|
259
|
-
headers: {
|
|
260
|
-
'x-client-name': 'afdx',
|
|
261
|
-
},
|
|
262
|
-
}));
|
|
263
|
-
const traceResults = await Promise.all(tracePromises);
|
|
264
|
-
traces.push(...traceResults);
|
|
265
|
-
return traces;
|
|
266
|
-
}
|
|
267
|
-
catch (err) {
|
|
268
|
-
throw core_1.SfError.wrap(err);
|
|
269
|
-
}
|
|
270
|
-
finally {
|
|
271
|
-
// Always restore the original connection, even if an error occurred
|
|
272
|
-
delete this.connection.accessToken;
|
|
273
|
-
await this.connection.refreshAuth();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
// once we're previewing agents in the org, with mockActions = false, we'll have to figure out how to get the correct user that was simulated for apex invocattion
|
|
277
|
-
async ensureTraceFlag() {
|
|
278
|
-
if (this.apexTraceFlag) {
|
|
279
|
-
const expDate = this.apexTraceFlag.ExpirationDate;
|
|
280
|
-
if (expDate && new Date(expDate) > new Date()) {
|
|
281
|
-
this.logger.debug(`Using cached apexTraceFlag with ExpirationDate of ${expDate}`);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
this.logger.debug('Cached apex trace flag is expired');
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
const user = this.compiledAgent?.globalConfiguration.defaultAgentUser ?? this.connection.getUsername();
|
|
289
|
-
const userId = (await this.connection.singleRecordQuery(`SELECT Id FROM User WHERE Username = '${user}'`)).Id;
|
|
290
|
-
this.apexTraceFlag = await (0, apexUtils_1.findTraceFlag)(this.connection, userId);
|
|
291
|
-
if (!this.apexTraceFlag) {
|
|
292
|
-
await (0, apexUtils_1.createTraceFlag)(this.connection, userId);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
exports.AgentSimulate = AgentSimulate;
|
|
297
|
-
//# sourceMappingURL=agentSimulate.js.map
|
package/lib/agentSimulate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agentSimulate.js","sourceRoot":"","sources":["../src/agentSimulate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,+CAA4C;AAC5C,yCAAqC;AACrC,6CAAyC;AACzC,2CAAkE;AAClE,yCAAsC;AACtC,mCAAgC;AAChC,yDAAsD;AAQtD,2CAA0E;AAC1E,mCAAiE;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,aAAc,SAAQ,mCAAgB;IACjD;;OAEG;IACI,WAAW,CAAU;IACT,OAAO,GAAG,WAC3B,SAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAC5C,sCAAsC,CAAC;IACtB,aAAa,CAAS;IAC/B,aAAa,CAAa;IAElC;;;;;;OAMG;IACH,YAAmB,UAAsB,EAAE,aAAqB,EAAE,WAAoB;QACpF,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,KAAK,gBAAS,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;YAC1D,IAAI,CAAC,MAAM,CAAC,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C9C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qDAAqD,OAAO,EAAE,CAAC,CAAC;gBAClF,OAAO;YACT,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC,gBAAgB,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,EAAG,CAAC;QAExG,MAAM,MAAM,GAAG,CACb,MAAM,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAiB,yCAAyC,IAAI,GAAG,CAAC,CAC1G,CAAC,EAAE,CAAC;QAEL,IAAI,CAAC,aAAa,GAAG,MAAM,IAAA,yBAAa,EAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,IAAA,2BAAe,EAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;CACF;AA9QD,sCA8QC"}
|
package/lib/agentTrace.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { type AgentTraceResponse } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* A service for retrieving agent execution traces. Provides detailed information
|
|
5
|
-
* about agent plan execution including steps, timing, and safety scores.
|
|
6
|
-
*
|
|
7
|
-
* **Examples**
|
|
8
|
-
*
|
|
9
|
-
* Get trace data for a specific trace ID:
|
|
10
|
-
*
|
|
11
|
-
* `const traceData = await AgentTrace.getTrace(connection, '12-23-34');`
|
|
12
|
-
*/
|
|
13
|
-
export declare class AgentTrace {
|
|
14
|
-
/**
|
|
15
|
-
* Get the trace data for a given trace ID.
|
|
16
|
-
*
|
|
17
|
-
* @param connection The connection to use for making the API request
|
|
18
|
-
* @param traceId The trace ID to retrieve trace data for
|
|
19
|
-
* @returns Promise that resolves with the trace data response containing actions and their execution details
|
|
20
|
-
* @beta
|
|
21
|
-
*/
|
|
22
|
-
static getTrace(connection: Connection, traceId: string): Promise<AgentTraceResponse>;
|
|
23
|
-
}
|
package/lib/agentTrace.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2025, Salesforce, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.AgentTrace = void 0;
|
|
19
|
-
const maybe_mock_1 = require("./maybe-mock");
|
|
20
|
-
/**
|
|
21
|
-
* A service for retrieving agent execution traces. Provides detailed information
|
|
22
|
-
* about agent plan execution including steps, timing, and safety scores.
|
|
23
|
-
*
|
|
24
|
-
* **Examples**
|
|
25
|
-
*
|
|
26
|
-
* Get trace data for a specific trace ID:
|
|
27
|
-
*
|
|
28
|
-
* `const traceData = await AgentTrace.getTrace(connection, '12-23-34');`
|
|
29
|
-
*/
|
|
30
|
-
class AgentTrace {
|
|
31
|
-
/**
|
|
32
|
-
* Get the trace data for a given trace ID.
|
|
33
|
-
*
|
|
34
|
-
* @param connection The connection to use for making the API request
|
|
35
|
-
* @param traceId The trace ID to retrieve trace data for
|
|
36
|
-
* @returns Promise that resolves with the trace data response containing actions and their execution details
|
|
37
|
-
* @beta
|
|
38
|
-
*/
|
|
39
|
-
static async getTrace(connection, traceId) {
|
|
40
|
-
const maybeMock = new maybe_mock_1.MaybeMock(connection);
|
|
41
|
-
// TODO: who knows what the real endpoint will be, or if the return type is 100% accurate
|
|
42
|
-
const url = `/api/trace/${traceId}`;
|
|
43
|
-
return maybeMock.request('GET', url);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.AgentTrace = AgentTrace;
|
|
47
|
-
//# sourceMappingURL=agentTrace.js.map
|
package/lib/agentTrace.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agentTrace.js","sourceRoot":"","sources":["../src/agentTrace.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,6CAAyC;AAGzC;;;;;;;;;GASG;AACH,MAAa,UAAU;IACrB;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAsB,EAAE,OAAe;QAClE,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,UAAU,CAAC,CAAC;QAC5C,yFAAyF;QACzF,MAAM,GAAG,GAAG,cAAc,OAAO,EAAE,CAAC;QAEpC,OAAO,SAAS,CAAC,OAAO,CAAqB,KAAK,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;CACF;AAhBD,gCAgBC"}
|