@salesforce/agents 0.20.1-beta.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 +14 -11
- package/lib/agent.js +22 -14
- package/lib/agent.js.map +1 -1
- package/lib/{agentInteractionBase.d.ts → agents/agentBase.d.ts} +17 -26
- package/lib/{agentInteractionBase.js → agents/agentBase.js} +11 -89
- package/lib/agents/agentBase.js.map +1 -0
- package/lib/{productionAgent.d.ts → agents/productionAgent.d.ts} +11 -5
- package/lib/{productionAgent.js → agents/productionAgent.js} +146 -50
- package/lib/agents/productionAgent.js.map +1 -0
- package/lib/{scriptAgent.d.ts → agents/scriptAgent.d.ts} +13 -7
- package/lib/{scriptAgent.js → agents/scriptAgent.js} +194 -176
- package/lib/agents/scriptAgent.js.map +1 -0
- package/lib/{agentPublisher.d.ts → agents/scriptAgentPublisher.d.ts} +7 -8
- package/lib/{agentPublisher.js → agents/scriptAgentPublisher.js} +14 -25
- package/lib/agents/scriptAgentPublisher.js.map +1 -0
- package/lib/apexUtils.d.ts +0 -1
- package/lib/apexUtils.js +0 -10
- package/lib/apexUtils.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +5 -5
- package/lib/index.js.map +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 +24 -7
- package/lib/types.js.map +1 -1
- package/lib/utils.d.ts +56 -26
- package/lib/utils.js +182 -38
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/lib/agentInteractionBase.js.map +0 -1
- package/lib/agentPublisher.js.map +0 -1
- package/lib/productionAgent.js.map +0 -1
- package/lib/scriptAgent.js.map +0 -1
|
@@ -19,19 +19,19 @@ exports.ProductionAgent = void 0;
|
|
|
19
19
|
const node_crypto_1 = require("node:crypto");
|
|
20
20
|
const core_1 = require("@salesforce/core");
|
|
21
21
|
const kit_1 = require("@salesforce/kit");
|
|
22
|
-
const maybe_mock_1 = require("
|
|
23
|
-
const utils_1 = require("
|
|
24
|
-
const apexUtils_1 = require("
|
|
25
|
-
const
|
|
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
26
|
;
|
|
27
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
|
|
28
|
+
class ProductionAgent extends agentBase_1.AgentBase {
|
|
29
29
|
options;
|
|
30
30
|
preview;
|
|
31
31
|
botMetadata;
|
|
32
32
|
id;
|
|
33
33
|
apiName;
|
|
34
|
-
apiBase = `https://${
|
|
34
|
+
apiBase = `https://${(0, utils_1.getEndpoint)()}api.salesforce.com/einstein/ai-agent/v1`;
|
|
35
35
|
constructor(options) {
|
|
36
36
|
super(options.connection);
|
|
37
37
|
this.options = options;
|
|
@@ -43,7 +43,7 @@ class ProductionAgent extends agentInteractionBase_1.AgentInteractionBase {
|
|
|
43
43
|
send: (message) => this.sendMessage(message),
|
|
44
44
|
getAllTraces: () => this.getAllTracesFromDisc(),
|
|
45
45
|
end: (reason) => this.endSession(reason),
|
|
46
|
-
saveSession: (outputDir) => this.
|
|
46
|
+
saveSession: (outputDir) => this.saveSessionTo(outputDir),
|
|
47
47
|
setApexDebugging: (apexDebugging) => this.setApexDebugging(apexDebugging),
|
|
48
48
|
};
|
|
49
49
|
if (options.apiNameOrId.startsWith('0Xx') && [15, 18].includes(options.apiNameOrId.length)) {
|
|
@@ -78,16 +78,13 @@ class ProductionAgent extends agentInteractionBase_1.AgentInteractionBase {
|
|
|
78
78
|
}
|
|
79
79
|
// eslint-disable-next-line @typescript-eslint/require-await,class-methods-use-this,@typescript-eslint/no-unused-vars
|
|
80
80
|
async getTrace(planId) {
|
|
81
|
-
// return this.connection.request<PlannerResponse>({
|
|
82
|
-
// method: 'GET',
|
|
83
|
-
// url: `${this.connection.getConnectionOptions().instanceUrl!}:9443/proxy/worker/internal/sessions/${this
|
|
84
|
-
// .sessionId!}/plans/${planId}`,
|
|
85
|
-
// headers: {
|
|
86
|
-
// 'x-client-name': 'afdx',
|
|
87
|
-
// },
|
|
88
|
-
// });
|
|
89
81
|
return undefined;
|
|
90
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
|
+
}
|
|
91
88
|
/**
|
|
92
89
|
* Returns the ID for this agent.
|
|
93
90
|
*
|
|
@@ -134,11 +131,90 @@ class ProductionAgent extends agentInteractionBase_1.AgentInteractionBase {
|
|
|
134
131
|
}
|
|
135
132
|
}
|
|
136
133
|
}
|
|
137
|
-
|
|
134
|
+
async sendMessage(message) {
|
|
138
135
|
if (!this.sessionId) {
|
|
139
|
-
throw core_1.SfError.create({ name: 'noSessionId', message: '
|
|
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);
|
|
140
217
|
}
|
|
141
|
-
return `${this.apiBase}/sessions/${this.sessionId}/messages`;
|
|
142
218
|
}
|
|
143
219
|
async setAgentStatus(desiredState) {
|
|
144
220
|
const botMetadata = await this.getBotMetadata();
|
|
@@ -179,35 +255,41 @@ class ProductionAgent extends agentInteractionBase_1.AgentInteractionBase {
|
|
|
179
255
|
bypassUser: true,
|
|
180
256
|
};
|
|
181
257
|
try {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
+
}
|
|
190
280
|
this.sessionId = response.sessionId;
|
|
191
|
-
// Initialize session directory and write initial data
|
|
192
|
-
// Session directory structure:
|
|
193
|
-
// .sfdx/agents/<agentId>/sessions/<sessionId>/
|
|
194
|
-
// ├── transcript.jsonl # All transcript entries (one per line)
|
|
195
|
-
// ├── traces/ # Individual trace files
|
|
196
|
-
// │ ├── <planId1>.json
|
|
197
|
-
// │ └── <planId2>.json
|
|
198
|
-
// └── metadata.json # Session metadata (start time, end time, planIds, etc.)
|
|
199
281
|
const agentId = this.id;
|
|
200
|
-
this.
|
|
201
|
-
await (0, utils_1.
|
|
282
|
+
this.historyDir = await (0, utils_1.getHistoryDir)(agentId, response.sessionId);
|
|
283
|
+
await (0, utils_1.appendTranscriptToHistory)({
|
|
202
284
|
timestamp: new Date().toISOString(),
|
|
203
285
|
agentId,
|
|
204
286
|
sessionId: response.sessionId,
|
|
205
287
|
role: 'agent',
|
|
206
288
|
text: response.messages.map((m) => m.message).join('\n'),
|
|
207
289
|
raw: response.messages,
|
|
208
|
-
}, this.
|
|
290
|
+
}, this.historyDir);
|
|
209
291
|
// Write initial metadata
|
|
210
|
-
await (0, utils_1.
|
|
292
|
+
await (0, utils_1.writeMetaFileToHistory)(this.historyDir, {
|
|
211
293
|
sessionId: response.sessionId,
|
|
212
294
|
agentId,
|
|
213
295
|
startTime: new Date().toISOString(),
|
|
@@ -237,29 +319,43 @@ class ProductionAgent extends agentInteractionBase_1.AgentInteractionBase {
|
|
|
237
319
|
const url = `${this.apiBase}/v1.1/sessions/${this.sessionId}`;
|
|
238
320
|
try {
|
|
239
321
|
// https://developer.salesforce.com/docs/einstein/genai/guide/agent-api-examples.html#end-session
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
+
}
|
|
247
343
|
// Write end entry immediately
|
|
248
|
-
if (this.
|
|
249
|
-
await (0, utils_1.
|
|
344
|
+
if (this.historyDir) {
|
|
345
|
+
await (0, utils_1.appendTranscriptToHistory)({
|
|
250
346
|
timestamp: new Date().toISOString(),
|
|
251
347
|
agentId: this.id,
|
|
252
348
|
sessionId: this.sessionId,
|
|
253
349
|
role: 'agent',
|
|
254
350
|
reason,
|
|
255
351
|
raw: response.messages,
|
|
256
|
-
}, this.
|
|
352
|
+
}, this.historyDir);
|
|
257
353
|
// Update metadata with end time
|
|
258
|
-
await (0, utils_1.updateMetadataEndTime)(this.
|
|
354
|
+
await (0, utils_1.updateMetadataEndTime)(this.historyDir, new Date().toISOString(), this.planIds);
|
|
259
355
|
}
|
|
260
356
|
// Clear session data for next session
|
|
261
357
|
this.sessionId = undefined;
|
|
262
|
-
this.
|
|
358
|
+
this.historyDir = undefined;
|
|
263
359
|
this.planIds = new Set();
|
|
264
360
|
return response;
|
|
265
361
|
}
|
|
@@ -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,MAA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CAAC;YAC3B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;YAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;YAEjC,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,cAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF;AAxYD,0CAwYC"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { SfProject } from '@salesforce/core';
|
|
2
|
-
import { type AgentPreviewEndResponse, type AgentPreviewSendResponse, type CompileAgentScriptResponse, ExtendedAgentJobSpec, PlannerResponse, PublishAgent, ScriptAgentOptions } from '
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { type AgentPreviewEndResponse, AgentPreviewInterface, type AgentPreviewSendResponse, type CompileAgentScriptResponse, ExtendedAgentJobSpec, PlannerResponse, PreviewMetadata, PublishAgent, ScriptAgentOptions } from '../types';
|
|
3
|
+
import { TranscriptEntry } from '../utils';
|
|
4
|
+
import { AgentBase } from './agentBase';
|
|
5
|
+
export declare class ScriptAgent extends AgentBase {
|
|
5
6
|
private options;
|
|
6
7
|
preview: AgentPreviewInterface & {
|
|
7
8
|
setMockMode: (mockMode: 'Mock' | 'Live Test') => void;
|
|
8
9
|
};
|
|
9
10
|
private mockMode;
|
|
10
11
|
private agentScriptContent;
|
|
11
|
-
private metaContent;
|
|
12
12
|
private agentJson;
|
|
13
13
|
private apiBase;
|
|
14
|
+
private readonly aabDirectory;
|
|
15
|
+
private readonly metaContent;
|
|
14
16
|
constructor(options: ScriptAgentOptions);
|
|
15
17
|
/**
|
|
16
18
|
* Creates an AiAuthoringBundle directory, .script file, and -meta.xml file
|
|
@@ -46,16 +48,20 @@ export declare class ScriptAgent extends AgentInteractionBase {
|
|
|
46
48
|
* @returns {Promise<PublishAgentJsonResponse>} The publish response
|
|
47
49
|
*/
|
|
48
50
|
publish(): Promise<PublishAgent>;
|
|
51
|
+
getHistoryFromDisc(sessionId?: string): Promise<{
|
|
52
|
+
metadata: PreviewMetadata | null;
|
|
53
|
+
transcript: TranscriptEntry[];
|
|
54
|
+
traces: PlannerResponse[];
|
|
55
|
+
}>;
|
|
49
56
|
/**
|
|
50
57
|
* Ending is not required
|
|
51
|
-
* this will save all
|
|
58
|
+
* this will save all the transcripts to disc
|
|
52
59
|
*
|
|
53
60
|
* @returns `AgentPreviewEndResponse`
|
|
54
61
|
*/
|
|
55
62
|
endSession(): Promise<AgentPreviewEndResponse>;
|
|
56
|
-
|
|
63
|
+
getAgentIdForStorage(): string;
|
|
57
64
|
protected canApexDebug(): boolean;
|
|
58
|
-
protected getSendMessageUrl(): string;
|
|
59
65
|
protected handleApexDebuggingSetup(): Promise<void>;
|
|
60
66
|
protected sendMessage(message: string): Promise<AgentPreviewSendResponse>;
|
|
61
67
|
private setMockMode;
|