@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/agentTestResults.js
CHANGED
package/lib/agentTester.js
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
import { AgentPreviewInterface, type AgentPreviewSendResponse, type PlannerResponse, PreviewMetadata } from '../types';
|
|
3
|
+
import { TranscriptEntry } from '../utils';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class for agent preview functionality.
|
|
6
|
+
* Contains shared properties and methods between ScriptAgent and ProductionAgent.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class AgentBase {
|
|
9
|
+
protected readonly connection: Connection;
|
|
10
|
+
/**
|
|
11
|
+
* The display name of the agent (user-friendly name, not API name)
|
|
12
|
+
*/
|
|
13
|
+
name: string | undefined;
|
|
14
|
+
protected sessionId: string | undefined;
|
|
15
|
+
protected historyDir: string | undefined;
|
|
16
|
+
protected apexDebugging: boolean | undefined;
|
|
17
|
+
protected planIds: Set<string>;
|
|
18
|
+
abstract preview: AgentPreviewInterface;
|
|
19
|
+
protected constructor(connection: Connection);
|
|
20
|
+
restoreConnection(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Get all traces from the current session
|
|
23
|
+
* Reads traces from the session directory if available, otherwise fetches from API
|
|
24
|
+
*/
|
|
25
|
+
protected getAllTracesFromDisc(): Promise<PlannerResponse[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Save the complete session data to disk by copying the session directory.
|
|
28
|
+
* The session directory is already populated during the session with:
|
|
29
|
+
* - Transcript entries (transcript.jsonl)
|
|
30
|
+
* - Traces (traces/*.json)
|
|
31
|
+
* - Session metadata (metadata.json)
|
|
32
|
+
*
|
|
33
|
+
* Session directory structure:
|
|
34
|
+
* .sfdx/agents/<agentId>/sessions/<sessionId>/
|
|
35
|
+
* ├── transcript.jsonl # All transcript entries (one per line)
|
|
36
|
+
* ├── traces/ # Individual trace files
|
|
37
|
+
* │ ├── <planId1>.json
|
|
38
|
+
* │ └── <planId2>.json
|
|
39
|
+
* └── metadata.json # Session metadata (start time, end time, planIds, etc.)
|
|
40
|
+
*
|
|
41
|
+
* @param outputDir Optional output directory. If not provided, uses default location.
|
|
42
|
+
* @returns The path to the copied session directory
|
|
43
|
+
*/
|
|
44
|
+
protected saveSessionTo(outputDir: string): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Set the Apex debugging mode for the agent preview.
|
|
47
|
+
* This can be called before starting a session.
|
|
48
|
+
*
|
|
49
|
+
* @param apexDebugging true to enable Apex debugging, false to disable
|
|
50
|
+
*/
|
|
51
|
+
protected setApexDebugging(apexDebugging: boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Send a message to the agent using the session ID obtained by calling `start()`.
|
|
54
|
+
*
|
|
55
|
+
* @param message A message to send to the agent.
|
|
56
|
+
* @returns `AgentPreviewSendResponse`
|
|
57
|
+
*/
|
|
58
|
+
protected abstract sendMessage(message: string): Promise<AgentPreviewSendResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Get the agent ID to use for storage/transcript purposes
|
|
61
|
+
*/
|
|
62
|
+
protected abstract getAgentIdForStorage(): string | Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Check if Apex debugging should be enabled for this agent type
|
|
65
|
+
*/
|
|
66
|
+
protected abstract canApexDebug(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Handle Apex debugging setup before sending a message
|
|
69
|
+
*/
|
|
70
|
+
protected abstract handleApexDebuggingSetup(): Promise<void>;
|
|
71
|
+
protected abstract getTrace(planId: string): Promise<PlannerResponse | undefined>;
|
|
72
|
+
protected abstract getHistoryFromDisc(): Promise<{
|
|
73
|
+
metadata: PreviewMetadata | null;
|
|
74
|
+
transcript: TranscriptEntry[];
|
|
75
|
+
traces: PlannerResponse[];
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentBase = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2026, Salesforce, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
const promises_1 = require("node:fs/promises");
|
|
20
|
+
const node_path_1 = require("node:path");
|
|
21
|
+
const core_1 = require("@salesforce/core");
|
|
22
|
+
/**
|
|
23
|
+
* Abstract base class for agent preview functionality.
|
|
24
|
+
* Contains shared properties and methods between ScriptAgent and ProductionAgent.
|
|
25
|
+
*/
|
|
26
|
+
class AgentBase {
|
|
27
|
+
connection;
|
|
28
|
+
/**
|
|
29
|
+
* The display name of the agent (user-friendly name, not API name)
|
|
30
|
+
*/
|
|
31
|
+
name;
|
|
32
|
+
sessionId;
|
|
33
|
+
historyDir;
|
|
34
|
+
apexDebugging;
|
|
35
|
+
planIds = new Set();
|
|
36
|
+
constructor(connection) {
|
|
37
|
+
this.connection = connection;
|
|
38
|
+
}
|
|
39
|
+
async restoreConnection() {
|
|
40
|
+
delete this.connection.accessToken;
|
|
41
|
+
await this.connection.refreshAuth();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get all traces from the current session
|
|
45
|
+
* Reads traces from the session directory if available, otherwise fetches from API
|
|
46
|
+
*/
|
|
47
|
+
async getAllTracesFromDisc() {
|
|
48
|
+
if (!this.historyDir) {
|
|
49
|
+
throw core_1.SfError.create({ message: 'history never created' });
|
|
50
|
+
}
|
|
51
|
+
const traces = [];
|
|
52
|
+
// If we have a session directory, try reading traces from disk first
|
|
53
|
+
const tracesDir = (0, node_path_1.join)(this.historyDir, 'traces');
|
|
54
|
+
const files = await (0, promises_1.readdir)(tracesDir);
|
|
55
|
+
const tracePromises = files
|
|
56
|
+
.filter((file) => file.endsWith('.json'))
|
|
57
|
+
.map(async (file) => {
|
|
58
|
+
const traceData = await (0, promises_1.readFile)((0, node_path_1.join)(tracesDir, file), 'utf-8');
|
|
59
|
+
return JSON.parse(traceData);
|
|
60
|
+
});
|
|
61
|
+
traces.push(...(await Promise.all(tracePromises)));
|
|
62
|
+
return traces;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Save the complete session data to disk by copying the session directory.
|
|
66
|
+
* The session directory is already populated during the session with:
|
|
67
|
+
* - Transcript entries (transcript.jsonl)
|
|
68
|
+
* - Traces (traces/*.json)
|
|
69
|
+
* - Session metadata (metadata.json)
|
|
70
|
+
*
|
|
71
|
+
* Session directory structure:
|
|
72
|
+
* .sfdx/agents/<agentId>/sessions/<sessionId>/
|
|
73
|
+
* ├── transcript.jsonl # All transcript entries (one per line)
|
|
74
|
+
* ├── traces/ # Individual trace files
|
|
75
|
+
* │ ├── <planId1>.json
|
|
76
|
+
* │ └── <planId2>.json
|
|
77
|
+
* └── metadata.json # Session metadata (start time, end time, planIds, etc.)
|
|
78
|
+
*
|
|
79
|
+
* @param outputDir Optional output directory. If not provided, uses default location.
|
|
80
|
+
* @returns The path to the copied session directory
|
|
81
|
+
*/
|
|
82
|
+
async saveSessionTo(outputDir) {
|
|
83
|
+
if (!this.sessionId || !this.historyDir) {
|
|
84
|
+
throw core_1.SfError.create({ name: 'noSessionId', message: 'No active session. Call .start() first.' });
|
|
85
|
+
}
|
|
86
|
+
const agentId = await this.getAgentIdForStorage();
|
|
87
|
+
// Determine output directory
|
|
88
|
+
const destDir = (0, node_path_1.join)(outputDir, agentId, `session_${this.sessionId}`);
|
|
89
|
+
// Copy the entire session directory from .sfdx to the output directory
|
|
90
|
+
// This includes transcript.jsonl, traces/, and metadata.json
|
|
91
|
+
await (0, promises_1.mkdir)(destDir, { recursive: true });
|
|
92
|
+
await (0, promises_1.cp)(this.historyDir, destDir, { recursive: true });
|
|
93
|
+
return destDir;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Set the Apex debugging mode for the agent preview.
|
|
97
|
+
* This can be called before starting a session.
|
|
98
|
+
*
|
|
99
|
+
* @param apexDebugging true to enable Apex debugging, false to disable
|
|
100
|
+
*/
|
|
101
|
+
setApexDebugging(apexDebugging) {
|
|
102
|
+
this.apexDebugging = apexDebugging;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.AgentBase = AgentBase;
|
|
106
|
+
//# sourceMappingURL=agentBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentBase.js","sourceRoot":"","sources":["../../src/agents/agentBase.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,+CAAgE;AAChE,yCAAiC;AACjC,2CAAuD;AAIvD;;;GAGG;AACH,MAAsB,SAAS;IAWY;IAVzC;;OAEG;IACI,IAAI,CAAqB;IACtB,SAAS,CAAqB;IAC9B,UAAU,CAAqB;IAC/B,aAAa,CAAsB;IACnC,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAGtC,YAAyC,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAE5D,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QACnC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,oBAAoB;QAClC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,M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,CAAC,CAAC;QAEtE,uEAAuE;QACvE,6DAA6D;QAC7D,MAAM,IAAA,gBAAK,EAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,MAAM,IAAA,aAAE,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAExD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACO,gBAAgB,CAAC,aAAsB;QAC/C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CA+BF;AApHD,8BAoHC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AgentPreviewInterface, type AgentPreviewSendResponse, type BotMetadata, type BotVersionMetadata, PlannerResponse, PreviewMetadata, ProductionAgentOptions } from '../types';
|
|
2
|
+
import { TranscriptEntry } from '../utils';
|
|
3
|
+
import { AgentBase } from './agentBase';
|
|
4
|
+
export declare class ProductionAgent extends AgentBase {
|
|
5
|
+
private options;
|
|
6
|
+
preview: AgentPreviewInterface;
|
|
7
|
+
private botMetadata;
|
|
8
|
+
private id;
|
|
9
|
+
private apiName;
|
|
10
|
+
private apiBase;
|
|
11
|
+
constructor(options: ProductionAgentOptions);
|
|
12
|
+
getBotMetadata(): Promise<BotMetadata>;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the latest bot version metadata.
|
|
15
|
+
*
|
|
16
|
+
* @returns the latest bot version metadata
|
|
17
|
+
*/
|
|
18
|
+
getLatestBotVersionMetadata(): Promise<BotVersionMetadata>;
|
|
19
|
+
getTrace(planId: string): Promise<PlannerResponse | undefined>;
|
|
20
|
+
getHistoryFromDisc(sessionId?: string): Promise<{
|
|
21
|
+
metadata: PreviewMetadata | null;
|
|
22
|
+
transcript: TranscriptEntry[];
|
|
23
|
+
traces: PlannerResponse[];
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the ID for this agent.
|
|
27
|
+
*
|
|
28
|
+
* @returns The ID of the agent (The `Bot` ID).
|
|
29
|
+
*/
|
|
30
|
+
getId(): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Activates the agent.
|
|
33
|
+
*
|
|
34
|
+
* @returns void
|
|
35
|
+
*/
|
|
36
|
+
activate(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Deactivates the agent.
|
|
39
|
+
*
|
|
40
|
+
* @returns void
|
|
41
|
+
*/
|
|
42
|
+
deactivate(): Promise<void>;
|
|
43
|
+
getAgentIdForStorage(): string;
|
|
44
|
+
protected canApexDebug(): boolean;
|
|
45
|
+
protected handleApexDebuggingSetup(): Promise<void>;
|
|
46
|
+
protected sendMessage(message: string): Promise<AgentPreviewSendResponse>;
|
|
47
|
+
private setAgentStatus;
|
|
48
|
+
private startPreview;
|
|
49
|
+
/**
|
|
50
|
+
* Ends an interactive session with the agent.
|
|
51
|
+
*
|
|
52
|
+
* @param sessionId A session ID provided by first calling `agentPreview.start()`.
|
|
53
|
+
* @param reason A reason why the interactive session was ended.
|
|
54
|
+
* @returns `AgentPreviewEndResponse`
|
|
55
|
+
*/
|
|
56
|
+
private endSession;
|
|
57
|
+
}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductionAgent = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2026, Salesforce, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
const node_crypto_1 = require("node:crypto");
|
|
20
|
+
const core_1 = require("@salesforce/core");
|
|
21
|
+
const kit_1 = require("@salesforce/kit");
|
|
22
|
+
const maybe_mock_1 = require("../maybe-mock");
|
|
23
|
+
const utils_1 = require("../utils");
|
|
24
|
+
const apexUtils_1 = require("../apexUtils");
|
|
25
|
+
const agentBase_1 = require("./agentBase");
|
|
26
|
+
;
|
|
27
|
+
const messages = new core_1.Messages('@salesforce/agents', 'agents', new Map([["invalidAgentSpecConfig", "Missing one or more of the required agent spec arguments: type, role, companyName, companyDescription"], ["missingAgentName", "The \"agentName\" configuration property is required when saving an agent."], ["agentRetrievalError", "Unable to retrieve newly created Agent metadata. Due to: %s"], ["agentRetrievalErrorActions", "Retrieve the agent metadata using the \"project retrieve start\" command."], ["missingAgentNameOrId", "The \"nameOrId\" agent option is required when creating an Agent instance."], ["agentIsDeleted", "The %s agent has been deleted and its activation state can't be changed."], ["agentActivationError", "Changing the agent's activation status was unsuccessful due to %s."]]));
|
|
28
|
+
class ProductionAgent extends agentBase_1.AgentBase {
|
|
29
|
+
options;
|
|
30
|
+
preview;
|
|
31
|
+
botMetadata;
|
|
32
|
+
id;
|
|
33
|
+
apiName;
|
|
34
|
+
apiBase = `https://${(0, utils_1.getEndpoint)()}api.salesforce.com/einstein/ai-agent/v1`;
|
|
35
|
+
constructor(options) {
|
|
36
|
+
super(options.connection);
|
|
37
|
+
this.options = options;
|
|
38
|
+
if (!options.apiNameOrId) {
|
|
39
|
+
throw messages.createError('missingAgentNameOrId');
|
|
40
|
+
}
|
|
41
|
+
this.preview = {
|
|
42
|
+
start: (apexDebugging) => this.startPreview(apexDebugging),
|
|
43
|
+
send: (message) => this.sendMessage(message),
|
|
44
|
+
getAllTraces: () => this.getAllTracesFromDisc(),
|
|
45
|
+
end: (reason) => this.endSession(reason),
|
|
46
|
+
saveSession: (outputDir) => this.saveSessionTo(outputDir),
|
|
47
|
+
setApexDebugging: (apexDebugging) => this.setApexDebugging(apexDebugging),
|
|
48
|
+
};
|
|
49
|
+
if (options.apiNameOrId.startsWith('0Xx') && [15, 18].includes(options.apiNameOrId.length)) {
|
|
50
|
+
this.id = options.apiNameOrId;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.apiName = options.apiNameOrId;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async getBotMetadata() {
|
|
57
|
+
if (!this.botMetadata) {
|
|
58
|
+
const whereClause = this.id ? `Id = '${this.id}'` : `DeveloperName = '${this.apiName}'`;
|
|
59
|
+
this.botMetadata = await this.connection.singleRecordQuery(`SELECT FIELDS(ALL), (SELECT FIELDS(ALL) FROM BotVersions LIMIT 10) FROM BotDefinition WHERE ${whereClause} LIMIT 1`);
|
|
60
|
+
this.id = this.botMetadata.Id;
|
|
61
|
+
this.apiName = this.botMetadata.DeveloperName;
|
|
62
|
+
// Set the display name from MasterLabel
|
|
63
|
+
this.name = this.botMetadata.MasterLabel;
|
|
64
|
+
}
|
|
65
|
+
return this.botMetadata;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns the latest bot version metadata.
|
|
69
|
+
*
|
|
70
|
+
* @returns the latest bot version metadata
|
|
71
|
+
*/
|
|
72
|
+
async getLatestBotVersionMetadata() {
|
|
73
|
+
if (!this.botMetadata) {
|
|
74
|
+
this.botMetadata = await this.getBotMetadata();
|
|
75
|
+
}
|
|
76
|
+
const botVersions = this.botMetadata.BotVersions.records;
|
|
77
|
+
return botVersions[botVersions.length - 1];
|
|
78
|
+
}
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/require-await,class-methods-use-this,@typescript-eslint/no-unused-vars
|
|
80
|
+
async getTrace(planId) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
getHistoryFromDisc(sessionId) {
|
|
84
|
+
// Use provided sessionId, or fall back to this.sessionId, or let getAllHistory find the most recent
|
|
85
|
+
const actualSessionId = sessionId ?? this.sessionId;
|
|
86
|
+
return (0, utils_1.getAllHistory)(this.getAgentIdForStorage(), actualSessionId);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns the ID for this agent.
|
|
90
|
+
*
|
|
91
|
+
* @returns The ID of the agent (The `Bot` ID).
|
|
92
|
+
*/
|
|
93
|
+
async getId() {
|
|
94
|
+
if (!this.id) {
|
|
95
|
+
await this.getBotMetadata();
|
|
96
|
+
}
|
|
97
|
+
return this.id; // getBotMetadata() ensures this.id is not undefined
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Activates the agent.
|
|
101
|
+
*
|
|
102
|
+
* @returns void
|
|
103
|
+
*/
|
|
104
|
+
async activate() {
|
|
105
|
+
return this.setAgentStatus('Active');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Deactivates the agent.
|
|
109
|
+
*
|
|
110
|
+
* @returns void
|
|
111
|
+
*/
|
|
112
|
+
async deactivate() {
|
|
113
|
+
return this.setAgentStatus('Inactive');
|
|
114
|
+
}
|
|
115
|
+
getAgentIdForStorage() {
|
|
116
|
+
if (!this.id) {
|
|
117
|
+
throw core_1.SfError.create({ name: 'noId', message: 'Agent ID not found. Call .getBotMetadata() first.' });
|
|
118
|
+
}
|
|
119
|
+
return this.id;
|
|
120
|
+
}
|
|
121
|
+
// eslint-disable-next-line class-methods-use-this
|
|
122
|
+
canApexDebug() {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
async handleApexDebuggingSetup() {
|
|
126
|
+
const botMetadata = await this.getBotMetadata();
|
|
127
|
+
if (botMetadata.BotUserId) {
|
|
128
|
+
const traceFlag = await (0, apexUtils_1.findTraceFlag)(this.connection, botMetadata.BotUserId);
|
|
129
|
+
if (!traceFlag) {
|
|
130
|
+
await (0, apexUtils_1.createTraceFlag)(this.connection, botMetadata.BotUserId);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async sendMessage(message) {
|
|
135
|
+
if (!this.sessionId) {
|
|
136
|
+
throw core_1.SfError.create({ name: 'noSessionId', message: 'Agent not started, please call .start() first' });
|
|
137
|
+
}
|
|
138
|
+
const url = `${this.apiBase}/sessions/${this.sessionId}/messages`;
|
|
139
|
+
const body = {
|
|
140
|
+
message: {
|
|
141
|
+
sequenceId: Date.now(),
|
|
142
|
+
type: 'Text',
|
|
143
|
+
text: message,
|
|
144
|
+
},
|
|
145
|
+
variables: [],
|
|
146
|
+
};
|
|
147
|
+
try {
|
|
148
|
+
const start = Date.now();
|
|
149
|
+
// Handle Apex debugging setup if needed
|
|
150
|
+
if (this.apexDebugging && this.canApexDebug()) {
|
|
151
|
+
await this.handleApexDebuggingSetup();
|
|
152
|
+
}
|
|
153
|
+
const agentId = this.getAgentIdForStorage();
|
|
154
|
+
// Ensure session directory exists
|
|
155
|
+
if (!this.historyDir) {
|
|
156
|
+
this.historyDir = await (0, utils_1.getHistoryDir)(agentId, this.sessionId);
|
|
157
|
+
}
|
|
158
|
+
void (0, utils_1.appendTranscriptToHistory)({
|
|
159
|
+
timestamp: new Date().toISOString(),
|
|
160
|
+
agentId,
|
|
161
|
+
sessionId: this.sessionId,
|
|
162
|
+
role: 'user',
|
|
163
|
+
text: message,
|
|
164
|
+
}, this.historyDir);
|
|
165
|
+
let response;
|
|
166
|
+
try {
|
|
167
|
+
response = await this.connection.request({
|
|
168
|
+
method: 'POST',
|
|
169
|
+
url,
|
|
170
|
+
body: JSON.stringify(body),
|
|
171
|
+
headers: {
|
|
172
|
+
'x-client-name': 'afdx',
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
const errorName = error?.name ?? '';
|
|
178
|
+
if (errorName.includes('404')) {
|
|
179
|
+
throw core_1.SfError.create({
|
|
180
|
+
name: 'AgentApiNotFound',
|
|
181
|
+
message: `Preview Send API returned 404. SF_TEST_API=${kit_1.env.getBoolean('SF_TEST_API') ? 'true' : 'false'} If targeting a test.api environment, set SF_TEST_API=true, otherwise it's false.`,
|
|
182
|
+
cause: error,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
throw core_1.SfError.wrap(error);
|
|
186
|
+
}
|
|
187
|
+
const planId = response.messages.at(0).planId;
|
|
188
|
+
this.planIds.add(planId);
|
|
189
|
+
await (0, utils_1.appendTranscriptToHistory)({
|
|
190
|
+
timestamp: new Date().toISOString(),
|
|
191
|
+
agentId,
|
|
192
|
+
sessionId: this.sessionId,
|
|
193
|
+
role: 'agent',
|
|
194
|
+
text: response.messages.at(0)?.message,
|
|
195
|
+
raw: response.messages,
|
|
196
|
+
}, this.historyDir);
|
|
197
|
+
// Fetch and write trace immediately if available
|
|
198
|
+
if (planId) {
|
|
199
|
+
try {
|
|
200
|
+
const trace = await this.getTrace(planId);
|
|
201
|
+
await (0, utils_1.writeTraceToHistory)(planId, trace, this.historyDir);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
throw core_1.SfError.wrap(error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (this.apexDebugging && this.canApexDebug()) {
|
|
208
|
+
const apexLog = await (0, apexUtils_1.getDebugLog)(this.connection, start, Date.now());
|
|
209
|
+
if (apexLog) {
|
|
210
|
+
response.apexDebugLog = apexLog;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return response;
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
throw core_1.SfError.wrap(err);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
async setAgentStatus(desiredState) {
|
|
220
|
+
const botMetadata = await this.getBotMetadata();
|
|
221
|
+
const botVersionMetadata = await this.getLatestBotVersionMetadata();
|
|
222
|
+
if (botMetadata.IsDeleted) {
|
|
223
|
+
throw messages.createError('agentIsDeleted', [botMetadata.DeveloperName]);
|
|
224
|
+
}
|
|
225
|
+
if (botVersionMetadata.Status === desiredState) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const url = `/connect/bot-versions/${botVersionMetadata.Id}/activation`;
|
|
229
|
+
const maybeMock = new maybe_mock_1.MaybeMock(this.connection);
|
|
230
|
+
const response = await maybeMock.request('POST', url, { status: desiredState });
|
|
231
|
+
if (response.success) {
|
|
232
|
+
this.botMetadata.BotVersions.records[0].Status = response.isActivated ? 'Active' : 'Inactive';
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
throw messages.createError('agentActivationError', [response.messages?.toString() ?? 'unknown']);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
async startPreview(apexDebugging) {
|
|
239
|
+
if (!this.id) {
|
|
240
|
+
await this.getId();
|
|
241
|
+
}
|
|
242
|
+
const url = `${this.apiBase}/agents/${this.id}/sessions`;
|
|
243
|
+
// Use the provided apexDebugging parameter if given, otherwise keep the previously set one
|
|
244
|
+
if (apexDebugging !== undefined) {
|
|
245
|
+
this.apexDebugging = apexDebugging;
|
|
246
|
+
}
|
|
247
|
+
const body = {
|
|
248
|
+
externalSessionKey: (0, node_crypto_1.randomUUID)(),
|
|
249
|
+
instanceConfig: {
|
|
250
|
+
endpoint: this.options.connection.instanceUrl,
|
|
251
|
+
},
|
|
252
|
+
streamingCapabilities: {
|
|
253
|
+
chunkTypes: ['Text'],
|
|
254
|
+
},
|
|
255
|
+
bypassUser: true,
|
|
256
|
+
};
|
|
257
|
+
try {
|
|
258
|
+
let response;
|
|
259
|
+
try {
|
|
260
|
+
response = await this.connection.request({
|
|
261
|
+
method: 'POST',
|
|
262
|
+
url,
|
|
263
|
+
body: JSON.stringify(body),
|
|
264
|
+
headers: {
|
|
265
|
+
'x-client-name': 'afdx',
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
const errorName = error?.name ?? '';
|
|
271
|
+
if (errorName.includes('404')) {
|
|
272
|
+
throw core_1.SfError.create({
|
|
273
|
+
name: 'AgentApiNotFound',
|
|
274
|
+
message: `Preview Start API returned 404. SF_TEST_API=${kit_1.env.getBoolean('SF_TEST_API') ? 'true' : 'false'} If targeting a test.api environment, set SF_TEST_API=true, otherwise it's false.`,
|
|
275
|
+
cause: error,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
throw core_1.SfError.wrap(error);
|
|
279
|
+
}
|
|
280
|
+
this.sessionId = response.sessionId;
|
|
281
|
+
const agentId = this.id;
|
|
282
|
+
this.historyDir = await (0, utils_1.getHistoryDir)(agentId, response.sessionId);
|
|
283
|
+
await (0, utils_1.appendTranscriptToHistory)({
|
|
284
|
+
timestamp: new Date().toISOString(),
|
|
285
|
+
agentId,
|
|
286
|
+
sessionId: response.sessionId,
|
|
287
|
+
role: 'agent',
|
|
288
|
+
text: response.messages.map((m) => m.message).join('\n'),
|
|
289
|
+
raw: response.messages,
|
|
290
|
+
}, this.historyDir);
|
|
291
|
+
// Write initial metadata
|
|
292
|
+
await (0, utils_1.writeMetaFileToHistory)(this.historyDir, {
|
|
293
|
+
sessionId: response.sessionId,
|
|
294
|
+
agentId,
|
|
295
|
+
startTime: new Date().toISOString(),
|
|
296
|
+
apexDebugging: this.apexDebugging,
|
|
297
|
+
planIds: [],
|
|
298
|
+
});
|
|
299
|
+
return response;
|
|
300
|
+
}
|
|
301
|
+
catch (err) {
|
|
302
|
+
throw core_1.SfError.wrap(err);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Ends an interactive session with the agent.
|
|
307
|
+
*
|
|
308
|
+
* @param sessionId A session ID provided by first calling `agentPreview.start()`.
|
|
309
|
+
* @param reason A reason why the interactive session was ended.
|
|
310
|
+
* @returns `AgentPreviewEndResponse`
|
|
311
|
+
*/
|
|
312
|
+
async endSession(reason) {
|
|
313
|
+
if (!this.sessionId) {
|
|
314
|
+
throw core_1.SfError.create({ name: 'noSessionId', message: 'please call .start() first' });
|
|
315
|
+
}
|
|
316
|
+
if (!this.id) {
|
|
317
|
+
throw core_1.SfError.create({ name: 'noId', message: 'please call .getId() first' });
|
|
318
|
+
}
|
|
319
|
+
const url = `${this.apiBase}/v1.1/sessions/${this.sessionId}`;
|
|
320
|
+
try {
|
|
321
|
+
// https://developer.salesforce.com/docs/einstein/genai/guide/agent-api-examples.html#end-session
|
|
322
|
+
let response;
|
|
323
|
+
try {
|
|
324
|
+
response = await this.connection.request({
|
|
325
|
+
method: 'DELETE',
|
|
326
|
+
url,
|
|
327
|
+
headers: {
|
|
328
|
+
'x-session-end-reason': reason,
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
const errorName = error?.name ?? '';
|
|
334
|
+
if (errorName.includes('404')) {
|
|
335
|
+
throw core_1.SfError.create({
|
|
336
|
+
name: 'AgentApiNotFound',
|
|
337
|
+
message: `Preview End API returned 404. SF_TEST_API=${kit_1.env.getBoolean('SF_TEST_API') ? 'true' : 'false'} If targeting a test.api environment, set SF_TEST_API=true, otherwise it's false.`,
|
|
338
|
+
cause: error,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
throw core_1.SfError.wrap(error);
|
|
342
|
+
}
|
|
343
|
+
// Write end entry immediately
|
|
344
|
+
if (this.historyDir) {
|
|
345
|
+
await (0, utils_1.appendTranscriptToHistory)({
|
|
346
|
+
timestamp: new Date().toISOString(),
|
|
347
|
+
agentId: this.id,
|
|
348
|
+
sessionId: this.sessionId,
|
|
349
|
+
role: 'agent',
|
|
350
|
+
reason,
|
|
351
|
+
raw: response.messages,
|
|
352
|
+
}, this.historyDir);
|
|
353
|
+
// Update metadata with end time
|
|
354
|
+
await (0, utils_1.updateMetadataEndTime)(this.historyDir, new Date().toISOString(), this.planIds);
|
|
355
|
+
}
|
|
356
|
+
// Clear session data for next session
|
|
357
|
+
this.sessionId = undefined;
|
|
358
|
+
this.historyDir = undefined;
|
|
359
|
+
this.planIds = new Set();
|
|
360
|
+
return response;
|
|
361
|
+
}
|
|
362
|
+
catch (err) {
|
|
363
|
+
throw core_1.SfError.wrap(err);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
exports.ProductionAgent = ProductionAgent;
|
|
368
|
+
//# sourceMappingURL=productionAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productionAgent.js","sourceRoot":"","sources":["../../src/agents/productionAgent.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,6CAAyC;AACzC,2CAAqD;AACrD,yCAAsC;AActC,8CAA0C;AAC1C,oCASkB;AAClB,4CAA2E;AAC3E,2CAAwC;;AAExC,MAAM,QAAQ,OAAG,eAAQ,CAAc,oBAAoB,EAAE,QAAQ,kuBAAC,CAAC;AAEvE,MAAa,eAAgB,SAAQ,qBAAS;IAOjB;IANpB,OAAO,CAAwB;IAC9B,WAAW,CAA0B;IACrC,EAAE,CAAqB;IACvB,OAAO,CAAqB;IAC5B,OAAO,GAAG,WAAW,IAAA,mBAAW,GAAE,yCAAyC,CAAC;IAEpF,YAA2B,OAA+B;QACxD,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QADD,YAAO,GAAP,OAAO,CAAwB;QAExD,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YACzB,MAAM,QAAQ,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,OAAO,GAAG;YACb,KAAK,EAAE,CAAC,aAAuB,EAAsC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC;YACxG,IAAI,EAAE,CAAC,OAAe,EAAqC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;YACvF,YAAY,EAAE,GAA+B,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC3E,GAAG,EAAE,CAAC,MAAiB,EAAoC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACrF,WA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