@salesforce/agents 0.20.0 → 0.20.1-beta.0

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.
Files changed (44) hide show
  1. package/lib/agent.d.ts +14 -78
  2. package/lib/agent.js +74 -302
  3. package/lib/agent.js.map +1 -1
  4. package/lib/agentInteractionBase.d.ts +86 -0
  5. package/lib/agentInteractionBase.js +184 -0
  6. package/lib/agentInteractionBase.js.map +1 -0
  7. package/lib/agentPublisher.d.ts +16 -2
  8. package/lib/agentPublisher.js +42 -6
  9. package/lib/agentPublisher.js.map +1 -1
  10. package/lib/agentTest.js +1 -1
  11. package/lib/agentTestResults.js +1 -1
  12. package/lib/agentTester.js +1 -1
  13. package/lib/apexUtils.d.ts +1 -0
  14. package/lib/apexUtils.js +11 -1
  15. package/lib/apexUtils.js.map +1 -1
  16. package/lib/index.d.ts +4 -5
  17. package/lib/index.js +8 -10
  18. package/lib/index.js.map +1 -1
  19. package/lib/maybe-mock.js +1 -1
  20. package/lib/productionAgent.d.ts +51 -0
  21. package/lib/productionAgent.js +272 -0
  22. package/lib/productionAgent.js.map +1 -0
  23. package/lib/scriptAgent.d.ts +63 -0
  24. package/lib/scriptAgent.js +445 -0
  25. package/lib/scriptAgent.js.map +1 -0
  26. package/lib/types.d.ts +22 -8
  27. package/lib/types.js +1 -1
  28. package/lib/types.js.map +1 -1
  29. package/lib/utils.d.ts +35 -4
  30. package/lib/utils.js +64 -13
  31. package/lib/utils.js.map +1 -1
  32. package/package.json +1 -1
  33. package/lib/agentPreview.d.ts +0 -78
  34. package/lib/agentPreview.js +0 -258
  35. package/lib/agentPreview.js.map +0 -1
  36. package/lib/agentPreviewBase.d.ts +0 -59
  37. package/lib/agentPreviewBase.js +0 -55
  38. package/lib/agentPreviewBase.js.map +0 -1
  39. package/lib/agentSimulate.d.ts +0 -79
  40. package/lib/agentSimulate.js +0 -297
  41. package/lib/agentSimulate.js.map +0 -1
  42. package/lib/agentTrace.d.ts +0 -23
  43. package/lib/agentTrace.js +0 -47
  44. package/lib/agentTrace.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ import { Connection } from '@salesforce/core';
2
+ import { type AgentPreviewEndResponse, type AgentPreviewSendResponse, type AgentPreviewStartResponse, type PlannerResponse } from './types';
3
+ /**
4
+ * Common preview interface that both ScriptAgent and ProductionAgent implement
5
+ */
6
+ export type AgentPreviewInterface = {
7
+ start: (...args: unknown[]) => Promise<AgentPreviewStartResponse>;
8
+ send: (message: string) => Promise<AgentPreviewSendResponse>;
9
+ getAllTraces: () => Promise<PlannerResponse[]>;
10
+ end: (...args: unknown[]) => Promise<AgentPreviewEndResponse>;
11
+ saveSession: (outputDir?: string) => Promise<string>;
12
+ setApexDebugging: (apexDebugging: boolean) => void;
13
+ };
14
+ /**
15
+ * Abstract base class for agent preview functionality.
16
+ * Contains shared properties and methods between ScriptAgent and ProductionAgent.
17
+ */
18
+ export declare abstract class AgentInteractionBase {
19
+ protected readonly connection: Connection;
20
+ /**
21
+ * The display name of the agent (user-friendly name, not API name)
22
+ */
23
+ name: string | undefined;
24
+ protected sessionId: string | undefined;
25
+ protected sessionDir: string | undefined;
26
+ protected apexDebugging: boolean | undefined;
27
+ protected planIds: Set<string>;
28
+ abstract preview: AgentPreviewInterface;
29
+ protected constructor(connection: Connection);
30
+ restoreConnection(): Promise<void>;
31
+ /**
32
+ * Send a message to the agent using the session ID obtained by calling `start()`.
33
+ *
34
+ * @param message A message to send to the agent.
35
+ * @returns `AgentPreviewSendResponse`
36
+ */
37
+ protected sendMessage(message: string): Promise<AgentPreviewSendResponse>;
38
+ /**
39
+ * Get all traces from the current session
40
+ * Reads traces from the session directory if available, otherwise fetches from API
41
+ */
42
+ protected getAllTracesFromDisc(): Promise<PlannerResponse[]>;
43
+ /**
44
+ * Save the complete session data to disk by copying the session directory.
45
+ * The session directory is already populated during the session with:
46
+ * - Transcript entries (transcript.jsonl)
47
+ * - Traces (traces/*.json)
48
+ * - Session metadata (metadata.json)
49
+ *
50
+ * Session directory structure:
51
+ * .sfdx/agents/<agentId>/sessions/<sessionId>/
52
+ * ├── transcript.jsonl # All transcript entries (one per line)
53
+ * ├── traces/ # Individual trace files
54
+ * │ ├── <planId1>.json
55
+ * │ └── <planId2>.json
56
+ * └── metadata.json # Session metadata (start time, end time, planIds, etc.)
57
+ *
58
+ * @param outputDir Optional output directory. If not provided, uses default location.
59
+ * @returns The path to the copied session directory
60
+ */
61
+ protected saveSessionToDisc(outputDir: string): Promise<string>;
62
+ /**
63
+ * Set the Apex debugging mode for the agent preview.
64
+ * This can be called before starting a session.
65
+ *
66
+ * @param apexDebugging true to enable Apex debugging, false to disable
67
+ */
68
+ protected setApexDebugging(apexDebugging: boolean): void;
69
+ /**
70
+ * Get the agent ID to use for storage/transcript purposes
71
+ */
72
+ protected abstract getAgentIdForStorage(): string | Promise<string>;
73
+ /**
74
+ * Check if Apex debugging should be enabled for this agent type
75
+ */
76
+ protected abstract canApexDebug(): boolean;
77
+ /**
78
+ * Handle Apex debugging setup before sending a message
79
+ */
80
+ protected abstract handleApexDebuggingSetup(): Promise<void>;
81
+ protected abstract getTrace(planId: string): Promise<PlannerResponse | undefined>;
82
+ /**
83
+ * Get the URL for sending messages
84
+ */
85
+ protected abstract getSendMessageUrl(): string;
86
+ }
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentInteractionBase = 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
+ const utils_1 = require("./utils");
23
+ const apexUtils_1 = require("./apexUtils");
24
+ /**
25
+ * Abstract base class for agent preview functionality.
26
+ * Contains shared properties and methods between ScriptAgent and ProductionAgent.
27
+ */
28
+ class AgentInteractionBase {
29
+ connection;
30
+ /**
31
+ * The display name of the agent (user-friendly name, not API name)
32
+ */
33
+ name;
34
+ sessionId;
35
+ sessionDir;
36
+ apexDebugging;
37
+ planIds = new Set();
38
+ constructor(connection) {
39
+ this.connection = connection;
40
+ }
41
+ async restoreConnection() {
42
+ delete this.connection.accessToken;
43
+ await this.connection.refreshAuth();
44
+ }
45
+ /**
46
+ * Send a message to the agent using the session ID obtained by calling `start()`.
47
+ *
48
+ * @param message A message to send to the agent.
49
+ * @returns `AgentPreviewSendResponse`
50
+ */
51
+ async sendMessage(message) {
52
+ if (!this.sessionId) {
53
+ throw core_1.SfError.create({ name: 'noSessionId', message: 'Agent not started, please call .start() first' });
54
+ }
55
+ const url = this.getSendMessageUrl();
56
+ const body = {
57
+ message: {
58
+ sequenceId: Date.now(),
59
+ type: 'Text',
60
+ text: message,
61
+ },
62
+ variables: [],
63
+ };
64
+ try {
65
+ const start = Date.now();
66
+ // Handle Apex debugging setup if needed
67
+ if (this.apexDebugging && this.canApexDebug()) {
68
+ await this.handleApexDebuggingSetup();
69
+ }
70
+ const agentId = await this.getAgentIdForStorage();
71
+ // Ensure session directory exists
72
+ if (!this.sessionDir) {
73
+ this.sessionDir = await (0, utils_1.getSessionDir)(agentId, this.sessionId);
74
+ }
75
+ void (0, utils_1.appendTranscriptEntryToSession)({
76
+ timestamp: new Date().toISOString(),
77
+ agentId,
78
+ sessionId: this.sessionId,
79
+ role: 'user',
80
+ text: message,
81
+ }, this.sessionDir);
82
+ const response = await this.connection.request({
83
+ method: 'POST',
84
+ url,
85
+ body: JSON.stringify(body),
86
+ headers: {
87
+ 'x-client-name': 'afdx',
88
+ },
89
+ });
90
+ const planId = response.messages.at(0).planId;
91
+ this.planIds.add(planId);
92
+ await (0, utils_1.appendTranscriptEntryToSession)({
93
+ timestamp: new Date().toISOString(),
94
+ agentId,
95
+ sessionId: this.sessionId,
96
+ role: 'agent',
97
+ text: response.messages.at(0)?.message,
98
+ raw: response.messages,
99
+ }, this.sessionDir);
100
+ // Fetch and write trace immediately if available
101
+ if (planId) {
102
+ try {
103
+ const trace = await this.getTrace(planId);
104
+ await (0, utils_1.writeTraceToSession)(planId, trace, this.sessionDir);
105
+ }
106
+ catch (error) {
107
+ throw core_1.SfError.wrap(error);
108
+ }
109
+ }
110
+ if (this.apexDebugging && this.canApexDebug()) {
111
+ const apexLog = await (0, apexUtils_1.getDebugLog)(this.connection, start, Date.now());
112
+ if (apexLog) {
113
+ response.apexDebugLog = apexLog;
114
+ }
115
+ }
116
+ return response;
117
+ }
118
+ catch (err) {
119
+ throw core_1.SfError.wrap(err);
120
+ }
121
+ }
122
+ /**
123
+ * Get all traces from the current session
124
+ * Reads traces from the session directory if available, otherwise fetches from API
125
+ */
126
+ async getAllTracesFromDisc() {
127
+ if (!this.sessionDir) {
128
+ throw core_1.SfError.create({ message: 'history never created' });
129
+ }
130
+ const traces = [];
131
+ // If we have a session directory, try reading traces from disk first
132
+ const tracesDir = (0, node_path_1.join)(this.sessionDir, 'traces');
133
+ const files = await (0, promises_1.readdir)(tracesDir);
134
+ const tracePromises = files
135
+ .filter((file) => file.endsWith('.json'))
136
+ .map(async (file) => {
137
+ const traceData = await (0, promises_1.readFile)((0, node_path_1.join)(tracesDir, file), 'utf-8');
138
+ return JSON.parse(traceData);
139
+ });
140
+ traces.push(...(await Promise.all(tracePromises)));
141
+ return traces;
142
+ }
143
+ /**
144
+ * Save the complete session data to disk by copying the session directory.
145
+ * The session directory is already populated during the session with:
146
+ * - Transcript entries (transcript.jsonl)
147
+ * - Traces (traces/*.json)
148
+ * - Session metadata (metadata.json)
149
+ *
150
+ * Session directory structure:
151
+ * .sfdx/agents/<agentId>/sessions/<sessionId>/
152
+ * ├── transcript.jsonl # All transcript entries (one per line)
153
+ * ├── traces/ # Individual trace files
154
+ * │ ├── <planId1>.json
155
+ * │ └── <planId2>.json
156
+ * └── metadata.json # Session metadata (start time, end time, planIds, etc.)
157
+ *
158
+ * @param outputDir Optional output directory. If not provided, uses default location.
159
+ * @returns The path to the copied session directory
160
+ */
161
+ async saveSessionToDisc(outputDir) {
162
+ if (!this.sessionId || !this.sessionDir) {
163
+ throw core_1.SfError.create({ name: 'noSessionId', message: 'No active session. Call .start() first.' });
164
+ }
165
+ const agentId = await this.getAgentIdForStorage();
166
+ // Determine output directory
167
+ const destDir = (0, node_path_1.join)(outputDir, agentId, `session_${this.sessionId}`);
168
+ // Copy the entire session directory from .sfdx to the output directory
169
+ // This includes transcript.jsonl, traces/, and metadata.json
170
+ await (0, utils_1.copyDirectory)(this.sessionDir, destDir);
171
+ return destDir;
172
+ }
173
+ /**
174
+ * Set the Apex debugging mode for the agent preview.
175
+ * This can be called before starting a session.
176
+ *
177
+ * @param apexDebugging true to enable Apex debugging, false to disable
178
+ */
179
+ setApexDebugging(apexDebugging) {
180
+ this.apexDebugging = apexDebugging;
181
+ }
182
+ }
183
+ exports.AgentInteractionBase = AgentInteractionBase;
184
+ //# sourceMappingURL=agentInteractionBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentInteractionBase.js","sourceRoot":"","sources":["../src/agentInteractionBase.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,+CAAqD;AACrD,yCAAiC;AACjC,2CAAuD;AAOvD,mCAA4G;AAC5G,2CAA0C;AAc1C;;;GAGG;AACH,MAAsB,oBAAoB;IAWC;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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;;;;;;;;;;;OAiBG;IACO,KAAK,CAAC,iBAAiB,CAAC,SAAiB;QACjD,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,MAAM,cAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC,CAAC;QACpG,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAElD,6BAA6B;QAC7B,MAAM,OAAO,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,OAAO,EAAE,WAAW,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAEtE,uEAAuE;QACvE,6DAA6D;QAC7D,MAAM,IAAA,qBAAa,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAE9C,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACO,gBAAgB,CAAC,aAAsB;QAC/C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CAuBF;AAzMD,oDAyMC"}
@@ -11,6 +11,12 @@ export declare class AgentPublisher {
11
11
  private developerName;
12
12
  private bundleMetaPath;
13
13
  private bundleDir;
14
+ /**
15
+ * Original connection username, stored to create fresh connections for metadata operations.
16
+ * This ensures metadata operations (retrieve/deploy) use a standard connection that hasn't
17
+ * been upgraded with JWT, which is required for SOAP API operations.
18
+ */
19
+ private readonly originalUsername;
14
20
  private API_URL;
15
21
  private readonly API_HEADERS;
16
22
  /**
@@ -18,6 +24,7 @@ export declare class AgentPublisher {
18
24
  *
19
25
  * @param connection The connection to the Salesforce org
20
26
  * @param project The Salesforce project
27
+ * @param agentJson
21
28
  */
22
29
  constructor(connection: Connection, project: SfProject, agentJson: AgentJson);
23
30
  /**
@@ -26,6 +33,14 @@ export declare class AgentPublisher {
26
33
  * @returns Promise<PublishAgent> The publish response
27
34
  */
28
35
  publishAgentJson(): Promise<PublishAgent>;
36
+ /**
37
+ * Creates a fresh standard connection for metadata operations (retrieve/deploy).
38
+ * This ensures metadata operations use a connection that hasn't been upgraded with JWT,
39
+ * which is required for SOAP API operations.
40
+ *
41
+ * @returns A fresh Connection instance with standard authentication
42
+ */
43
+ private createStandardConnection;
29
44
  /**
30
45
  * Validates and extracts the developer name from the agent configuration,
31
46
  * and locates the corresponding authoring bundle directory and metadata file.
@@ -41,8 +56,7 @@ export declare class AgentPublisher {
41
56
  /**
42
57
  * Retrieve the agent metadata from the org after publishing
43
58
  *
44
- * @param developerName The developer name of the agent
45
- * @param originalConnection The original connection to use for retrieval
59
+ * @param botVersionName The bot version name
46
60
  */
47
61
  private retrieveAgentMetadata;
48
62
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright 2025, Salesforce, Inc.
3
+ * Copyright 2026, Salesforce, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -78,6 +78,12 @@ class AgentPublisher {
78
78
  developerName;
79
79
  bundleMetaPath;
80
80
  bundleDir;
81
+ /**
82
+ * Original connection username, stored to create fresh connections for metadata operations.
83
+ * This ensures metadata operations (retrieve/deploy) use a standard connection that hasn't
84
+ * been upgraded with JWT, which is required for SOAP API operations.
85
+ */
86
+ originalUsername;
81
87
  API_URL = `https://${kit_1.env.getBoolean('SF_TEST_API') ? 'test.' : ''}api.salesforce.com/einstein/ai-agent/v1.1/authoring/agents`;
82
88
  API_HEADERS = {
83
89
  'x-client-name': 'afdx',
@@ -88,12 +94,22 @@ class AgentPublisher {
88
94
  *
89
95
  * @param connection The connection to the Salesforce org
90
96
  * @param project The Salesforce project
97
+ * @param agentJson
91
98
  */
92
99
  constructor(connection, project, agentJson) {
93
100
  this.maybeMock = new maybe_mock_1.MaybeMock(connection);
94
101
  this.connection = connection;
95
102
  this.project = project;
96
103
  this.agentJson = agentJson;
104
+ // Store the original username to create fresh connections for metadata operations
105
+ const username = connection.getUsername();
106
+ if (!username) {
107
+ throw core_1.SfError.create({
108
+ name: 'ConnectionError',
109
+ message: 'Connection must have a username',
110
+ });
111
+ }
112
+ this.originalUsername = username;
97
113
  // Validate and get developer name and bundle directory
98
114
  const validationResult = this.validateDeveloperName();
99
115
  this.developerName = validationResult.developerName;
@@ -144,6 +160,21 @@ class AgentPublisher {
144
160
  });
145
161
  }
146
162
  }
163
+ /**
164
+ * Creates a fresh standard connection for metadata operations (retrieve/deploy).
165
+ * This ensures metadata operations use a connection that hasn't been upgraded with JWT,
166
+ * which is required for SOAP API operations.
167
+ *
168
+ * @returns A fresh Connection instance with standard authentication
169
+ */
170
+ async createStandardConnection() {
171
+ const authInfo = await core_1.AuthInfo.create({
172
+ username: this.originalUsername,
173
+ });
174
+ return core_1.Connection.create({
175
+ authInfo,
176
+ });
177
+ }
147
178
  /**
148
179
  * Validates and extracts the developer name from the agent configuration,
149
180
  * and locates the corresponding authoring bundle directory and metadata file.
@@ -178,23 +209,25 @@ class AgentPublisher {
178
209
  /**
179
210
  * Retrieve the agent metadata from the org after publishing
180
211
  *
181
- * @param developerName The developer name of the agent
182
- * @param originalConnection The original connection to use for retrieval
212
+ * @param botVersionName The bot version name
183
213
  */
184
214
  async retrieveAgentMetadata(botVersionName) {
185
215
  const defaultPackagePath = path.resolve(this.project.getDefaultPackage().path);
216
+ // Create a fresh standard connection for metadata operations
217
+ // This ensures SOAP API operations work correctly (JWT tokens don't work with SOAP)
218
+ const standardConnection = await this.createStandardConnection();
186
219
  const cs = await source_deploy_retrieve_1.ComponentSetBuilder.build({
187
220
  metadata: {
188
221
  metadataEntries: [`Bot:${this.developerName}`, `Agent:${this.developerName}_${botVersionName}`],
189
222
  directoryPaths: [defaultPackagePath],
190
223
  },
191
224
  org: {
192
- username: this.connection.getUsername(),
225
+ username: this.originalUsername,
193
226
  exclude: [],
194
227
  },
195
228
  });
196
229
  const retrieve = await cs.retrieve({
197
- usernameOrConnection: this.connection,
230
+ usernameOrConnection: standardConnection,
198
231
  merge: true,
199
232
  format: 'source',
200
233
  output: path.resolve(this.project.getPath(), defaultPackagePath),
@@ -250,8 +283,11 @@ class AgentPublisher {
250
283
  });
251
284
  await (0, promises_1.writeFile)(this.bundleMetaPath, xmlBuilder.build(authoringBundle));
252
285
  // 2. attempt to deploy the authoring bundle to the org
286
+ // Create a fresh standard connection for metadata operations
287
+ // This ensures SOAP API operations work correctly (JWT tokens don't work with SOAP)
288
+ const standardConnection = await this.createStandardConnection();
253
289
  const deploy = await source_deploy_retrieve_1.ComponentSet.fromSource(this.bundleDir).deploy({
254
- usernameOrConnection: this.connection.getUsername(),
290
+ usernameOrConnection: standardConnection,
255
291
  });
256
292
  const deployResult = await deploy.pollStatus();
257
293
  // 3.remove the target from the local authoring bundle meta.xml file
@@ -1 +1 @@
1
- {"version":3,"file":"agentPublisher.js","sourceRoot":"","sources":["../src/agentPublisher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAkC;AAClC,+CAAuD;AACvD,qCAAqC;AACrC,yCAAsC;AACtC,qDAAwD;AACxD,2CAAoF;AACpF,+EAAuF;AACvF,6CAAyC;AAEzC,mCAA+D;;AAG/D,MAAM,QAAQ,OAAG,eAAQ,CAAc,oBAAoB,EAAE,gBAAgB,ifAAC,CAAC;AAE/E,IAAI,MAAc,CAAC;AACnB,MAAM,SAAS,GAAG,GAAW,EAAE;IAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,aAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAa,cAAc;IACR,SAAS,CAAY;IAC9B,UAAU,CAAa;IACvB,OAAO,CAAY;IACnB,SAAS,CAAY;IACrB,aAAa,CAAS;IACtB,cAAc,CAAS;IACvB,SAAS,CA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C,uBAAuB,CAAC,YAAoB;QACxD,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,iBAAiB,CACzD,kDAAkD,YAAY,GAAG,CAClE,CAAC;YACF,SAAS,EAAE,CAAC,KAAK,CAAC,uBAAuB,YAAY,OAAO,WAAW,CAAC,aAAa,GAAG,CAAC,CAAC;YAC1F,OAAO,WAAW,CAAC,aAAa,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,qBAAqB,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;YACxE,GAAG,CAAC,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,uCAAuC,CAAC,CAAC,CAAC;YAC7E,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AA5SD,wCA4SC"}
package/lib/agentTest.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright 2025, Salesforce, Inc.
3
+ * Copyright 2026, Salesforce, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright 2025, Salesforce, Inc.
3
+ * Copyright 2026, Salesforce, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright 2025, Salesforce, Inc.
3
+ * Copyright 2026, Salesforce, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ export declare const getDebugLevelId: (connection: Connection) => Promise<string
29
29
  * @param userId The user id to create the trace flag for.
30
30
  */
31
31
  export declare const createTraceFlag: (connection: Connection, userId: string) => Promise<void>;
32
+ export declare function ensureTraceFlag(username: string, connection: Connection): Promise<ApexTraceFlag | undefined>;
32
33
  /**
33
34
  * Find a trace flag for the given user id.
34
35
  *
package/lib/apexUtils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright 2025, Salesforce, Inc.
3
+ * Copyright 2026, Salesforce, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.findTraceFlag = exports.createTraceFlag = exports.getDebugLevelId = exports.writeDebugLog = exports.getDebugLog = void 0;
19
+ exports.ensureTraceFlag = ensureTraceFlag;
19
20
  const node_path_1 = require("node:path");
20
21
  const promises_1 = require("node:fs/promises");
21
22
  const core_1 = require("@salesforce/core");
@@ -103,6 +104,15 @@ const createTraceFlag = async (connection, userId) => {
103
104
  }
104
105
  };
105
106
  exports.createTraceFlag = createTraceFlag;
107
+ // 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
108
+ async function ensureTraceFlag(username, connection) {
109
+ const userId = (await connection.singleRecordQuery(`SELECT Id FROM User WHERE Username = '${username}'`)).Id;
110
+ const apexTraceFlag = await (0, exports.findTraceFlag)(connection, userId);
111
+ if (!apexTraceFlag) {
112
+ await (0, exports.createTraceFlag)(connection, userId);
113
+ }
114
+ return apexTraceFlag;
115
+ }
106
116
  /**
107
117
  * Find a trace flag for the given user id.
108
118
  *
@@ -1 +1 @@
1
- {"version":3,"file":"apexUtils.js","sourceRoot":"","sources":["../src/apexUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,yCAAiC;AACjC,+CAA6C;AAC7C,2CAAgE;AAEhE,mCAA2C;;AAG3C,MAAM,QAAQ,OAAG,eAAQ,CAAc,oBAAoB,EAAE,WAAW,8IAAC,CAAC;AAE1E,IAAI,MAAc,CAA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AM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,CAA6B,CAAC;QACzE,IAAI,SAAS,CAAC,cAAc,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;YAChF,SAAS,EAAE,CAAC,KAAK,CAAC,yDAAyD,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC;YACvG,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAhBW,QAAA,aAAa,iBAgBxB"}
package/lib/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
- export { type AgentInteractionBase, type BaseAgentConfig, type AgentPreviewStartResponse, type AgentPreviewSendResponse, type AgentPreviewEndResponse, type EndReason, type ApiStatus, type AgentJson, type AgentCompilationSuccess, type AgentScriptContent, type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig, type AgentOptions, type AgentTone, type AgentType, type BotMetadata, type BotVersionMetadata, type CompilationError, type DraftAgentTopics, type DraftAgentTopicsBody, type DraftAgentTopicsResponse, type AvailableDefinition, type AgentPreviewMessageLinks, type AgentPreviewMessage, type AgentPreviewError, AgentSource, type ScriptAgent, type PublishedAgent, type AgentTestResultsResponse, type AgentTestStartResponse, type AgentTestStatusResponse, type TestCaseResult, type TestStatus, type AgentTestConfig, type TestCase, type TestSpec, type MetadataMetric, type MetadataExpectation, type MetadataCustomEvaluation, type AiEvaluationDefinition, type AgentTraceResponse, type AgentTraceStep, type UserInputStep, type LLMExecutionStep, type UpdateTopicStep, type EventStep, type ReasoningStep, type PlannerResponseStep, } from './types';
1
+ export { type BaseAgentConfig, type AgentPreviewStartResponse, type AgentPreviewSendResponse, type AgentPreviewEndResponse, type EndReason, type ApiStatus, type AgentJson, type AgentCompilationSuccess, type AgentScriptContent, type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig, type AgentOptions, type AgentTone, type AgentType, type BotMetadata, type BotVersionMetadata, type PreviewableAgent, type CompilationError, type DraftAgentTopics, type DraftAgentTopicsBody, type DraftAgentTopicsResponse, type AvailableDefinition, type AgentPreviewMessageLinks, type AgentPreviewMessage, type AgentPreviewError, AgentSource, type ScriptAgentType, type ProductionAgentType, type AgentTestResultsResponse, type AgentTestStartResponse, type AgentTestStatusResponse, type TestCaseResult, type TestStatus, type AgentTestConfig, type TestCase, type TestSpec, type MetadataMetric, type MetadataExpectation, type MetadataCustomEvaluation, type AiEvaluationDefinition, type AgentTraceResponse, type AgentTraceStep, type UserInputStep, type LLMExecutionStep, type UpdateTopicStep, type EventStep, type ReasoningStep, type PlannerResponseStep, } from './types';
2
2
  export { metric, findAuthoringBundle, readTranscriptEntries } from './utils';
3
3
  export { Agent, AgentCreateLifecycleStages } from './agent';
4
4
  export { AgentTester } from './agentTester';
5
5
  export { AgentTest, AgentTestCreateLifecycleStages } from './agentTest';
6
- export { AgentTrace } from './agentTrace';
6
+ export { ProductionAgent } from './productionAgent';
7
+ export { ScriptAgent } from './scriptAgent';
8
+ export { AgentInteractionBase, type AgentPreviewInterface } from './agentInteractionBase';
7
9
  export { convertTestResultsToFormat, humanFriendlyName } from './agentTestResults';
8
- export { AgentPreview } from './agentPreview';
9
- export { AgentSimulate } from './agentSimulate';
10
10
  export { writeDebugLog } from './apexUtils';
11
- export { AgentPreviewBase } from './agentPreviewBase';
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright 2025, Salesforce, Inc.
3
+ * Copyright 2026, Salesforce, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.AgentPreviewBase = exports.writeDebugLog = exports.AgentSimulate = exports.AgentPreview = exports.humanFriendlyName = exports.convertTestResultsToFormat = exports.AgentTrace = exports.AgentTestCreateLifecycleStages = exports.AgentTest = exports.AgentTester = exports.AgentCreateLifecycleStages = exports.Agent = exports.readTranscriptEntries = exports.findAuthoringBundle = exports.metric = exports.AgentSource = void 0;
18
+ exports.writeDebugLog = exports.humanFriendlyName = exports.convertTestResultsToFormat = exports.AgentInteractionBase = exports.ScriptAgent = exports.ProductionAgent = exports.AgentTestCreateLifecycleStages = exports.AgentTest = exports.AgentTester = exports.AgentCreateLifecycleStages = exports.Agent = exports.readTranscriptEntries = exports.findAuthoringBundle = exports.metric = exports.AgentSource = void 0;
19
19
  var types_1 = require("./types");
20
20
  Object.defineProperty(exports, "AgentSource", { enumerable: true, get: function () { return types_1.AgentSource; } });
21
21
  var utils_1 = require("./utils");
@@ -30,17 +30,15 @@ Object.defineProperty(exports, "AgentTester", { enumerable: true, get: function
30
30
  var agentTest_1 = require("./agentTest");
31
31
  Object.defineProperty(exports, "AgentTest", { enumerable: true, get: function () { return agentTest_1.AgentTest; } });
32
32
  Object.defineProperty(exports, "AgentTestCreateLifecycleStages", { enumerable: true, get: function () { return agentTest_1.AgentTestCreateLifecycleStages; } });
33
- var agentTrace_1 = require("./agentTrace");
34
- Object.defineProperty(exports, "AgentTrace", { enumerable: true, get: function () { return agentTrace_1.AgentTrace; } });
33
+ var productionAgent_1 = require("./productionAgent");
34
+ Object.defineProperty(exports, "ProductionAgent", { enumerable: true, get: function () { return productionAgent_1.ProductionAgent; } });
35
+ var scriptAgent_1 = require("./scriptAgent");
36
+ Object.defineProperty(exports, "ScriptAgent", { enumerable: true, get: function () { return scriptAgent_1.ScriptAgent; } });
37
+ var agentInteractionBase_1 = require("./agentInteractionBase");
38
+ Object.defineProperty(exports, "AgentInteractionBase", { enumerable: true, get: function () { return agentInteractionBase_1.AgentInteractionBase; } });
35
39
  var agentTestResults_1 = require("./agentTestResults");
36
40
  Object.defineProperty(exports, "convertTestResultsToFormat", { enumerable: true, get: function () { return agentTestResults_1.convertTestResultsToFormat; } });
37
41
  Object.defineProperty(exports, "humanFriendlyName", { enumerable: true, get: function () { return agentTestResults_1.humanFriendlyName; } });
38
- var agentPreview_1 = require("./agentPreview");
39
- Object.defineProperty(exports, "AgentPreview", { enumerable: true, get: function () { return agentPreview_1.AgentPreview; } });
40
- var agentSimulate_1 = require("./agentSimulate");
41
- Object.defineProperty(exports, "AgentSimulate", { enumerable: true, get: function () { return agentSimulate_1.AgentSimulate; } });
42
42
  var apexUtils_1 = require("./apexUtils");
43
43
  Object.defineProperty(exports, "writeDebugLog", { enumerable: true, get: function () { return apexUtils_1.writeDebugLog; } });
44
- var agentPreviewBase_1 = require("./agentPreviewBase");
45
- Object.defineProperty(exports, "AgentPreviewBase", { enumerable: true, get: function () { return agentPreviewBase_1.AgentPreviewBase; } });
46
44
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iCA4DiB;AA3Bf,oGAAA,WAAW,OAAA;AA6Bb,iCAA6E;AAApE,+FAAA,MAAM,OAAA;AAAE,4GAAA,mBAAmB,OAAA;AAAE,8GAAA,qBAAqB,OAAA;AAC3D,iCAA4D;AAAnD,8FAAA,KAAK,OAAA;AAAE,mHAAA,0BAA0B,OAAA;AAC1C,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,yCAAwE;AAA/D,sGAAA,SAAS,OAAA;AAAE,2HAAA,8BAA8B,OAAA;AAClD,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,uDAAmF;AAA1E,8HAAA,0BAA0B,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AACtD,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AACtB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iCA4DiB;AA3Bf,oGAAA,WAAW,OAAA;AA6Bb,iCAA6E;AAApE,+FAAA,MAAM,OAAA;AAAE,4GAAA,mBAAmB,OAAA;AAAE,8GAAA,qBAAqB,OAAA;AAC3D,iCAA4D;AAAnD,8FAAA,KAAK,OAAA;AAAE,mHAAA,0BAA0B,OAAA;AAC1C,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,yCAAwE;AAA/D,sGAAA,SAAS,OAAA;AAAE,2HAAA,8BAA8B,OAAA;AAClD,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,+DAA0F;AAAjF,4HAAA,oBAAoB,OAAA;AAC7B,uDAAmF;AAA1E,8HAAA,0BAA0B,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AACtD,yCAA4C;AAAnC,0GAAA,aAAa,OAAA"}
package/lib/maybe-mock.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright 2025, Salesforce, Inc.
3
+ * Copyright 2026, Salesforce, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.