@salesforce/plugin-agent 1.38.0 → 1.39.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.
package/README.md CHANGED
@@ -130,7 +130,7 @@ EXAMPLES
130
130
  $ sf agent activate --api-name Resort_Manager --version 2 --target-org my-org
131
131
  ```
132
132
 
133
- _See code: [src/commands/agent/activate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/activate.ts)_
133
+ _See code: [src/commands/agent/activate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/activate.ts)_
134
134
 
135
135
  ## `sf agent create`
136
136
 
@@ -197,7 +197,7 @@ EXAMPLES
197
197
  $ sf agent create --name "Resort Manager" --spec specs/resortManagerAgent.yaml --preview
198
198
  ```
199
199
 
200
- _See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/create.ts)_
200
+ _See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/create.ts)_
201
201
 
202
202
  ## `sf agent deactivate`
203
203
 
@@ -238,7 +238,7 @@ EXAMPLES
238
238
  $ sf agent deactivate --api-name Resort_Manager --target-org my-org
239
239
  ```
240
240
 
241
- _See code: [src/commands/agent/deactivate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/deactivate.ts)_
241
+ _See code: [src/commands/agent/deactivate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/deactivate.ts)_
242
242
 
243
243
  ## `sf agent generate agent-spec`
244
244
 
@@ -345,7 +345,7 @@ EXAMPLES
345
345
  $ sf agent generate agent-spec --tone formal --agent-user resortmanager@myorg.com
346
346
  ```
347
347
 
348
- _See code: [src/commands/agent/generate/agent-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/generate/agent-spec.ts)_
348
+ _See code: [src/commands/agent/generate/agent-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/generate/agent-spec.ts)_
349
349
 
350
350
  ## `sf agent generate authoring-bundle`
351
351
 
@@ -422,7 +422,7 @@ EXAMPLES
422
422
  other-package-dir/main/default --target-org my-dev-org
423
423
  ```
424
424
 
425
- _See code: [src/commands/agent/generate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/generate/authoring-bundle.ts)_
425
+ _See code: [src/commands/agent/generate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/generate/authoring-bundle.ts)_
426
426
 
427
427
  ## `sf agent generate template`
428
428
 
@@ -484,7 +484,7 @@ EXAMPLES
484
484
  my-package --source-org my-scratch-org
485
485
  ```
486
486
 
487
- _See code: [src/commands/agent/generate/template.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/generate/template.ts)_
487
+ _See code: [src/commands/agent/generate/template.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/generate/template.ts)_
488
488
 
489
489
  ## `sf agent generate test-spec`
490
490
 
@@ -549,7 +549,7 @@ EXAMPLES
549
549
  force-app//main/default/aiEvaluationDefinitions/Resort_Manager_Tests.aiEvaluationDefinition-meta.xml
550
550
  ```
551
551
 
552
- _See code: [src/commands/agent/generate/test-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/generate/test-spec.ts)_
552
+ _See code: [src/commands/agent/generate/test-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/generate/test-spec.ts)_
553
553
 
554
554
  ## `sf agent preview`
555
555
 
@@ -622,7 +622,7 @@ EXAMPLES
622
622
  $ sf agent preview --use-live-actions --apex-debug --output-dir transcripts/my-preview
623
623
  ```
624
624
 
625
- _See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/preview.ts)_
625
+ _See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/preview.ts)_
626
626
 
627
627
  ## `sf agent preview end`
628
628
 
@@ -630,13 +630,18 @@ End an existing programmatic agent preview session and get trace location.
630
630
 
631
631
  ```
632
632
  USAGE
633
- $ sf agent preview end -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [--session-id <value>] [-n
634
- <value>] [--authoring-bundle <value>]
633
+ $ sf agent preview end -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [--session-id <value> |
634
+ --all] [-n <value> | --authoring-bundle <value>] [-p]
635
635
 
636
636
  FLAGS
637
637
  -n, --api-name=<value> API name of the activated published agent you want to preview.
638
638
  -o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
639
639
  configuration variable is already set.
640
+ -p, --no-prompt Don't prompt for confirmation before ending sessions. Has an effect only when used
641
+ with --all.
642
+ --all End all active preview sessions. Combine with --api-name or --authoring-bundle to
643
+ limit to a specific agent, or use with only --target-org to end sessions for all
644
+ agents found in the local session cache. Requires --target-org.
640
645
  --api-version=<value> Override the api version used for api requests made by this command
641
646
  --authoring-bundle=<value> API name of the authoring bundle metadata component that contains the agent's Agent
642
647
  Script file.
@@ -656,13 +661,17 @@ DESCRIPTION
656
661
  The original "agent preview start" command outputs a session ID which you then use with the --session-id flag of this
657
662
  command to end the session. You don't have to specify the --session-id flag if an agent has only one active preview
658
663
  session. You must also use either the --authoring-bundle or --api-name flag to specify the API name of the authoring
659
- bundle or the published agent, respecitvely. To find either API name, navigate to your package directory in your DX
664
+ bundle or the published agent, respectively. To find either API name, navigate to your package directory in your DX
660
665
  project. The API name of an authoring bundle is the same as its directory name under the "aiAuthoringBundles" metadata
661
666
  directory. Similarly, the published agent's API name is the same as its directory name under the "Bots" metadata
662
667
  directory.
663
668
 
669
+ Use the --all flag to end all active preview sessions at once. You can combine --all with --api-name or
670
+ --authoring-bundle to end only sessions for a specific agent, or use --all on its own to end every session across all
671
+ agents in the project.
672
+
664
673
  EXAMPLES
665
- End a preview session of a published agent by specifying its session ID and API name ; use the default org:
674
+ End a preview session of a published agent by specifying its session ID and API name; use the default org:
666
675
 
667
676
  $ sf agent preview end --session-id <SESSION_ID> --api-name My_Published_Agent
668
677
 
@@ -675,9 +684,17 @@ EXAMPLES
675
684
  one active session.
676
685
 
677
686
  $ sf agent preview end --authoring-bundle My_Local_Agent
687
+
688
+ End all active preview sessions for a specific agent without prompting:
689
+
690
+ $ sf agent preview end --all --authoring-bundle My_Local_Agent --target-org <target_org> --no-prompt
691
+
692
+ End all active preview sessions across every agent in the local session cache for an org:
693
+
694
+ $ sf agent preview end --all --target-org <target_org>
678
695
  ```
679
696
 
680
- _See code: [src/commands/agent/preview/end.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/preview/end.ts)_
697
+ _See code: [src/commands/agent/preview/end.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/preview/end.ts)_
681
698
 
682
699
  ## `sf agent preview send`
683
700
 
@@ -735,7 +752,7 @@ EXAMPLES
735
752
  $ sf agent preview send --utterance "what can you help me with?" --authoring-bundle My_Local_Agent
736
753
  ```
737
754
 
738
- _See code: [src/commands/agent/preview/send.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/preview/send.ts)_
755
+ _See code: [src/commands/agent/preview/send.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/preview/send.ts)_
739
756
 
740
757
  ## `sf agent preview sessions`
741
758
 
@@ -768,7 +785,7 @@ EXAMPLES
768
785
  $ sf agent preview sessions
769
786
  ```
770
787
 
771
- _See code: [src/commands/agent/preview/sessions.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/preview/sessions.ts)_
788
+ _See code: [src/commands/agent/preview/sessions.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/preview/sessions.ts)_
772
789
 
773
790
  ## `sf agent preview start`
774
791
 
@@ -833,7 +850,7 @@ EXAMPLES
833
850
  $ sf agent preview start --api-name My_Published_Agent
834
851
  ```
835
852
 
836
- _See code: [src/commands/agent/preview/start.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/preview/start.ts)_
853
+ _See code: [src/commands/agent/preview/start.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/preview/start.ts)_
837
854
 
838
855
  ## `sf agent publish authoring-bundle`
839
856
 
@@ -893,7 +910,7 @@ EXAMPLES
893
910
  $ sf agent publish authoring-bundle --api-name MyAuthoringbundle --concise
894
911
  ```
895
912
 
896
- _See code: [src/commands/agent/publish/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/publish/authoring-bundle.ts)_
913
+ _See code: [src/commands/agent/publish/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/publish/authoring-bundle.ts)_
897
914
 
898
915
  ## `sf agent test create`
899
916
 
@@ -948,7 +965,7 @@ EXAMPLES
948
965
  $ sf agent test create --spec specs/Resort_Manager-testSpec.yaml --api-name Resort_Manager_Test --preview
949
966
  ```
950
967
 
951
- _See code: [src/commands/agent/test/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/test/create.ts)_
968
+ _See code: [src/commands/agent/test/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/test/create.ts)_
952
969
 
953
970
  ## `sf agent test list`
954
971
 
@@ -983,7 +1000,7 @@ EXAMPLES
983
1000
  $ sf agent test list --target-org my-org
984
1001
  ```
985
1002
 
986
- _See code: [src/commands/agent/test/list.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/test/list.ts)_
1003
+ _See code: [src/commands/agent/test/list.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/test/list.ts)_
987
1004
 
988
1005
  ## `sf agent test results`
989
1006
 
@@ -1059,7 +1076,7 @@ FLAG DESCRIPTIONS
1059
1076
  expression when using custom evaluations.
1060
1077
  ```
1061
1078
 
1062
- _See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/test/results.ts)_
1079
+ _See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/test/results.ts)_
1063
1080
 
1064
1081
  ## `sf agent test resume`
1065
1082
 
@@ -1143,7 +1160,7 @@ FLAG DESCRIPTIONS
1143
1160
  expression when using custom evaluations.
1144
1161
  ```
1145
1162
 
1146
- _See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/test/resume.ts)_
1163
+ _See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/test/resume.ts)_
1147
1164
 
1148
1165
  ## `sf agent test run`
1149
1166
 
@@ -1227,7 +1244,7 @@ FLAG DESCRIPTIONS
1227
1244
  expression when using custom evaluations.
1228
1245
  ```
1229
1246
 
1230
- _See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/test/run.ts)_
1247
+ _See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/test/run.ts)_
1231
1248
 
1232
1249
  ## `sf agent test run-eval`
1233
1250
 
@@ -1300,7 +1317,7 @@ EXAMPLES
1300
1317
  $ echo '{"tests":[...]}' | sf agent test run-eval --spec --target-org my-org
1301
1318
  ```
1302
1319
 
1303
- _See code: [src/commands/agent/test/run-eval.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/test/run-eval.ts)_
1320
+ _See code: [src/commands/agent/test/run-eval.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/test/run-eval.ts)_
1304
1321
 
1305
1322
  ## `sf agent trace delete`
1306
1323
 
@@ -1358,7 +1375,7 @@ EXAMPLES
1358
1375
  $ sf agent trace delete --no-prompt
1359
1376
  ```
1360
1377
 
1361
- _See code: [src/commands/agent/trace/delete.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/trace/delete.ts)_
1378
+ _See code: [src/commands/agent/trace/delete.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/trace/delete.ts)_
1362
1379
 
1363
1380
  ## `sf agent trace list`
1364
1381
 
@@ -1425,7 +1442,7 @@ FLAG DESCRIPTIONS
1425
1442
  (2026-04-20T14:00:00.000Z). The "Recorded At" values shown in the table output are valid inputs.
1426
1443
  ```
1427
1444
 
1428
- _See code: [src/commands/agent/trace/list.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/trace/list.ts)_
1445
+ _See code: [src/commands/agent/trace/list.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/trace/list.ts)_
1429
1446
 
1430
1447
  ## `sf agent trace read`
1431
1448
 
@@ -1498,7 +1515,7 @@ EXAMPLES
1498
1515
  $ sf agent trace read --session-id <SESSION_ID> --json
1499
1516
  ```
1500
1517
 
1501
- _See code: [src/commands/agent/trace/read.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/trace/read.ts)_
1518
+ _See code: [src/commands/agent/trace/read.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/trace/read.ts)_
1502
1519
 
1503
1520
  ## `sf agent validate authoring-bundle`
1504
1521
 
@@ -1545,6 +1562,6 @@ EXAMPLES
1545
1562
  $ sf agent validate authoring-bundle --api-name MyAuthoringBundle --target-org my-dev-org
1546
1563
  ```
1547
1564
 
1548
- _See code: [src/commands/agent/validate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/validate/authoring-bundle.ts)_
1565
+ _See code: [src/commands/agent/validate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.39.0/src/commands/agent/validate/authoring-bundle.ts)_
1549
1566
 
1550
1567
  <!-- commandsstop -->
@@ -1,8 +1,12 @@
1
1
  import { SfCommand } from '@salesforce/sf-plugins-core';
2
- export type AgentPreviewEndResult = {
2
+ import type { Interfaces } from '@oclif/core';
3
+ export type EndedSession = {
3
4
  sessionId: string;
4
5
  tracesPath: string;
5
6
  };
7
+ export type AgentPreviewEndResult = {
8
+ ended: EndedSession[];
9
+ } | EndedSession;
6
10
  export default class AgentPreviewEnd extends SfCommand<AgentPreviewEndResult> {
7
11
  static readonly summary: string;
8
12
  static readonly description: string;
@@ -11,11 +15,33 @@ export default class AgentPreviewEnd extends SfCommand<AgentPreviewEndResult> {
11
15
  static readonly envVariablesSection: import("@oclif/core").HelpSection;
12
16
  static readonly errorCodes: import("@oclif/core").HelpSection;
13
17
  static readonly flags: {
14
- 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
15
- 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
- 'session-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
- 'api-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
- 'authoring-bundle': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'target-org': Interfaces.OptionFlag<import("@salesforce/core").Org, Interfaces.CustomOptions>;
19
+ 'api-version': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
20
+ 'session-id': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
21
+ 'api-name': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
22
+ 'authoring-bundle': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
23
+ all: Interfaces.BooleanFlag<boolean>;
24
+ 'no-prompt': Interfaces.BooleanFlag<boolean>;
19
25
  };
20
26
  run(): Promise<AgentPreviewEndResult>;
27
+ private initAgent;
28
+ private endAll;
29
+ /**
30
+ * Path 1: --all + --api-name or --authoring-bundle
31
+ * Ends all sessions for a single specified agent. This is the original behaviour.
32
+ */
33
+ private endAllForAgent;
34
+ /**
35
+ * Path 2: --all alone (no agent identifier).
36
+ * Reads all agents from the local cache via listCachedSessions and ends every session.
37
+ * sessionType 'published' → ProductionAgent (server-side DELETE). 'simulated'/'live' → ScriptAgent (local only).
38
+ * session-meta.json is always present for entries returned by listCachedSessions, so sessionType is always defined.
39
+ */
40
+ private endAllAgents;
41
+ /**
42
+ * Called by endAllForAgent (single specified agent) and endAllAgents (all agents from cache)
43
+ * once ended/failed arrays have been fully aggregated.
44
+ * Throws a partial-failure error if needed; logs success otherwise.
45
+ */
46
+ private finishEndAll;
21
47
  }
@@ -13,12 +13,20 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Flags, SfCommand, toHelpSection } from '@salesforce/sf-plugins-core';
17
- import { Messages, SfError, Lifecycle, EnvironmentVariable } from '@salesforce/core';
16
+ import { Flags, SfCommand, toHelpSection, prompts } from '@salesforce/sf-plugins-core';
17
+ import { Messages, SfError, EnvironmentVariable } from '@salesforce/core';
18
18
  import { Agent, ProductionAgent, ScriptAgent } from '@salesforce/agents';
19
- import { getCachedSessionIds, removeCache, validatePreviewSession } from '../../../previewSessionStore.js';
19
+ import { getCachedSessionIds, listCachedSessions, removeCache, validatePreviewSession, } from '../../../previewSessionStore.js';
20
20
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
21
21
  const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.preview.end');
22
+ async function callPreviewEnd(agent) {
23
+ if (agent instanceof ScriptAgent) {
24
+ await agent.preview.end();
25
+ }
26
+ else if (agent instanceof ProductionAgent) {
27
+ await agent.preview.end('UserRequest');
28
+ }
29
+ }
22
30
  export default class AgentPreviewEnd extends SfCommand {
23
31
  static summary = messages.getMessage('summary');
24
32
  static description = messages.getMessage('description');
@@ -27,8 +35,10 @@ export default class AgentPreviewEnd extends SfCommand {
27
35
  static envVariablesSection = toHelpSection('ENVIRONMENT VARIABLES', EnvironmentVariable.SF_TARGET_ORG);
28
36
  static errorCodes = toHelpSection('ERROR CODES', {
29
37
  'Succeeded (0)': 'Preview session ended successfully and traces saved.',
38
+ 'ExactlyOneRequired (2)': 'Neither --api-name nor --authoring-bundle was provided (required when --all is not set).',
30
39
  'NotFound (2)': 'Agent not found, or no preview session exists for this agent.',
31
40
  'PreviewEndFailed (4)': 'Failed to end the preview session.',
41
+ 'PreviewEndPartialFailure (68)': 'With --all, one or more sessions failed to end while others succeeded.',
32
42
  'SessionAmbiguous (5)': 'Multiple preview sessions found; specify --session-id to choose one.',
33
43
  });
34
44
  static flags = {
@@ -37,77 +47,230 @@ export default class AgentPreviewEnd extends SfCommand {
37
47
  'session-id': Flags.string({
38
48
  summary: messages.getMessage('flags.session-id.summary'),
39
49
  required: false,
50
+ exclusive: ['all'],
40
51
  }),
41
52
  'api-name': Flags.string({
42
53
  summary: messages.getMessage('flags.api-name.summary'),
43
54
  char: 'n',
44
- exactlyOne: ['api-name', 'authoring-bundle'],
55
+ exclusive: ['authoring-bundle'],
45
56
  }),
46
57
  'authoring-bundle': Flags.string({
47
58
  summary: messages.getMessage('flags.authoring-bundle.summary'),
48
- exactlyOne: ['api-name', 'authoring-bundle'],
59
+ exclusive: ['api-name'],
60
+ }),
61
+ all: Flags.boolean({
62
+ summary: messages.getMessage('flags.all.summary'),
63
+ exclusive: ['session-id'],
64
+ }),
65
+ 'no-prompt': Flags.boolean({
66
+ summary: messages.getMessage('flags.no-prompt.summary'),
67
+ char: 'p',
49
68
  }),
50
69
  };
51
70
  async run() {
52
71
  const { flags } = await this.parse(AgentPreviewEnd);
53
72
  const conn = flags['target-org'].getConnection(flags['api-version']);
54
- const agentIdentifier = flags['authoring-bundle'] ?? flags['api-name'];
55
- // Initialize agent with error tracking
56
- let agent;
57
- try {
58
- agent = flags['authoring-bundle']
59
- ? await Agent.init({ connection: conn, project: this.project, aabName: flags['authoring-bundle'] })
60
- : await Agent.init({ connection: conn, project: this.project, apiNameOrId: flags['api-name'] });
73
+ if (flags['all']) {
74
+ return this.endAll(flags, conn);
61
75
  }
62
- catch (error) {
63
- const wrapped = SfError.wrap(error);
64
- await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_agent_not_found' });
65
- throw new SfError(messages.getMessage('error.agentNotFound', [agentIdentifier]), 'AgentNotFound', [], 2, wrapped);
76
+ // Without --all, exactly one of --api-name or --authoring-bundle is required.
77
+ if (!flags['api-name'] && !flags['authoring-bundle']) {
78
+ throw new SfError(messages.getMessage('error.exactlyOneRequired'), 'ExactlyOneRequired', [], 2);
66
79
  }
67
- // Get or validate session ID
80
+ const agent = await this.initAgent(flags, conn);
68
81
  let sessionId = flags['session-id'];
69
82
  if (sessionId === undefined) {
70
83
  const cached = await getCachedSessionIds(this.project, agent);
71
84
  if (cached.length === 0) {
72
- await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_no_session' });
73
85
  throw new SfError(messages.getMessage('error.noSession'), 'PreviewSessionNotFound', [], 2);
74
86
  }
75
87
  if (cached.length > 1) {
76
- await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_multiple_sessions' });
77
88
  throw new SfError(messages.getMessage('error.multipleSessions', [cached.join(', ')]), 'PreviewSessionAmbiguous', [], 5);
78
89
  }
79
90
  sessionId = cached[0];
80
91
  }
81
92
  agent.setSessionId(sessionId);
82
- // Validate session
83
93
  try {
84
94
  await validatePreviewSession(agent);
85
95
  }
86
96
  catch (error) {
87
97
  const wrapped = SfError.wrap(error);
88
- await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_session_invalid' });
89
98
  throw new SfError(messages.getMessage('error.sessionInvalid', [sessionId]), 'PreviewSessionInvalid', [], 2, wrapped);
90
99
  }
91
100
  const tracesPath = await agent.getHistoryDir();
92
- await removeCache(agent);
93
- // End preview with error tracking
94
101
  try {
95
- if (agent instanceof ScriptAgent) {
96
- await agent.preview.end();
97
- }
98
- else if (agent instanceof ProductionAgent) {
99
- await agent.preview.end('UserRequest');
100
- }
102
+ await callPreviewEnd(agent);
101
103
  }
102
104
  catch (error) {
103
105
  const wrapped = SfError.wrap(error);
104
- await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_failed' });
105
106
  throw new SfError(messages.getMessage('error.endFailed', [wrapped.message]), 'PreviewEndFailed', [wrapped.message], 4, wrapped);
106
107
  }
107
- await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_success' });
108
+ // ProductionAgent.endSession() clears this.sessionId after the server call; re-set it so
109
+ // removeCache can call getHistoryDir() without throwing "No sessionId set on agent".
110
+ agent.setSessionId(sessionId);
111
+ await removeCache(agent);
108
112
  const result = { sessionId, tracesPath };
109
113
  this.log(messages.getMessage('output.tracesPath', [tracesPath]));
110
114
  return result;
111
115
  }
116
+ async initAgent(flags, conn) {
117
+ const agentIdentifier = flags['authoring-bundle'] ?? flags['api-name'];
118
+ try {
119
+ return flags['authoring-bundle']
120
+ ? await Agent.init({
121
+ connection: conn,
122
+ project: this.project,
123
+ aabName: flags['authoring-bundle'],
124
+ })
125
+ : await Agent.init({ connection: conn, project: this.project, apiNameOrId: flags['api-name'] });
126
+ }
127
+ catch (error) {
128
+ const wrapped = SfError.wrap(error);
129
+ throw new SfError(messages.getMessage('error.agentNotFound', [agentIdentifier]), 'AgentNotFound', [], 2, wrapped);
130
+ }
131
+ }
132
+ async endAll(flags, conn) {
133
+ const hasAgentIdentifier = flags['api-name'] !== undefined || flags['authoring-bundle'] !== undefined;
134
+ if (hasAgentIdentifier) {
135
+ return this.endAllForAgent(flags, conn);
136
+ }
137
+ return this.endAllAgents(conn, flags['no-prompt'] ?? false);
138
+ }
139
+ /**
140
+ * Path 1: --all + --api-name or --authoring-bundle
141
+ * Ends all sessions for a single specified agent. This is the original behaviour.
142
+ */
143
+ async endAllForAgent(flags, conn) {
144
+ const agent = await this.initAgent(flags, conn);
145
+ const agentLabel = flags['api-name'] ?? flags['authoring-bundle'];
146
+ const sessionIds = await getCachedSessionIds(this.project, agent);
147
+ const sessionsToEnd = sessionIds.map((sessionId) => ({ sessionId }));
148
+ if (sessionsToEnd.length === 0) {
149
+ this.log(messages.getMessage('output.noSessionsFound'));
150
+ return { ended: [] };
151
+ }
152
+ if (!flags['no-prompt']) {
153
+ const confirmed = await prompts.confirm({
154
+ message: messages.getMessage('prompt.confirmAll', [sessionsToEnd.length, agentLabel]),
155
+ });
156
+ if (!confirmed) {
157
+ return { ended: [] };
158
+ }
159
+ }
160
+ const { ended, failed } = await endSessionsForAgent(agent, sessionsToEnd);
161
+ return this.finishEndAll(ended, failed);
162
+ }
163
+ /**
164
+ * Path 2: --all alone (no agent identifier).
165
+ * Reads all agents from the local cache via listCachedSessions and ends every session.
166
+ * sessionType 'published' → ProductionAgent (server-side DELETE). 'simulated'/'live' → ScriptAgent (local only).
167
+ * session-meta.json is always present for entries returned by listCachedSessions, so sessionType is always defined.
168
+ */
169
+ async endAllAgents(conn, noPrompt) {
170
+ const entries = await listCachedSessions(this.project);
171
+ const totalSessions = entries.reduce((sum, e) => sum + e.sessions.length, 0);
172
+ if (totalSessions === 0) {
173
+ this.log(messages.getMessage('output.noSessionsFound'));
174
+ return { ended: [] };
175
+ }
176
+ if (!noPrompt) {
177
+ const agentBreakdown = entries
178
+ .map((e) => {
179
+ const label = e.displayName ?? e.agentId;
180
+ const type = e.sessions[0]?.sessionType === 'published' ? 'bot' : 'bundle'; // 'bot'/'bundle' labels confirmed by PM — intentional deviation from raw sessionType value
181
+ return ` - ${label} (${type}): ${e.sessions.length} session(s)`;
182
+ })
183
+ .join('\n');
184
+ const confirmed = await prompts.confirm({
185
+ message: `${messages.getMessage('prompt.confirmAllAgents', [
186
+ totalSessions,
187
+ entries.length,
188
+ ])}\n${agentBreakdown}`,
189
+ });
190
+ if (!confirmed) {
191
+ return { ended: [] };
192
+ }
193
+ }
194
+ const ended = [];
195
+ const failed = [];
196
+ for (const entry of entries) {
197
+ const { agentId, sessions } = entry;
198
+ let agent;
199
+ try {
200
+ const isProduction = sessions[0]?.sessionType === 'published';
201
+ if (isProduction) {
202
+ // eslint-disable-next-line no-await-in-loop
203
+ agent = await Agent.init({ connection: conn, project: this.project, apiNameOrId: agentId });
204
+ }
205
+ else {
206
+ // eslint-disable-next-line no-await-in-loop
207
+ agent = await Agent.init({ connection: conn, project: this.project, aabName: agentId });
208
+ }
209
+ }
210
+ catch (error) {
211
+ // If we can't init the agent, mark all its sessions as failed.
212
+ const errMsg = SfError.wrap(error).message;
213
+ for (const s of sessions) {
214
+ failed.push({ task: { sessionId: s.sessionId }, error: errMsg });
215
+ }
216
+ continue;
217
+ }
218
+ // eslint-disable-next-line no-await-in-loop
219
+ const { ended: agentEnded, failed: agentFailed } = await endSessionsForAgent(agent, sessions.map((s) => ({ sessionId: s.sessionId })));
220
+ ended.push(...agentEnded);
221
+ failed.push(...agentFailed);
222
+ }
223
+ return this.finishEndAll(ended, failed);
224
+ }
225
+ /**
226
+ * Called by endAllForAgent (single specified agent) and endAllAgents (all agents from cache)
227
+ * once ended/failed arrays have been fully aggregated.
228
+ * Throws a partial-failure error if needed; logs success otherwise.
229
+ */
230
+ finishEndAll(ended, failed) {
231
+ if (failed.length > 0) {
232
+ const failedList = failed.map((f) => `${f.task.sessionId}: ${f.error}`).join(', ');
233
+ const endedIds = ended.map((e) => e.sessionId).join(', ');
234
+ const msg = `Failed to end ${failed.length} session(s): [${failedList}]. Successfully ended ${ended.length} session(s)${ended.length > 0 ? `: [${endedIds}]` : ''}.`;
235
+ throw new SfError(msg, 'PreviewEndPartialFailure', [], 68);
236
+ }
237
+ this.log(messages.getMessage('output.endedAll', [ended.length]));
238
+ return { ended };
239
+ }
240
+ }
241
+ /**
242
+ * Ends a list of sessions on the given agent object serially.
243
+ * Returns { ended, failed } so callers can aggregate results.
244
+ * Does NOT throw on partial failure — callers decide what to do.
245
+ * On failure, the local cache entry is NOT removed (consistent with single-session path behaviour).
246
+ */
247
+ async function endSessionsForAgent(agent, sessionsToEnd) {
248
+ const ended = [];
249
+ const failed = [];
250
+ // Sessions are ended serially because setSessionId mutates shared state on the agent object.
251
+ // Parallelising would introduce a race condition where concurrent calls overwrite each other's sessionId.
252
+ for (const task of sessionsToEnd) {
253
+ const { sessionId } = task;
254
+ try {
255
+ agent.setSessionId(sessionId);
256
+ // eslint-disable-next-line no-await-in-loop
257
+ await validatePreviewSession(agent);
258
+ // eslint-disable-next-line no-await-in-loop
259
+ const tracesPath = await agent.getHistoryDir();
260
+ // ScriptAgent flushes traces to disk; ProductionAgent issues the server-side end request.
261
+ // eslint-disable-next-line no-await-in-loop
262
+ await callPreviewEnd(agent);
263
+ // ProductionAgent.endSession() clears this.sessionId after the server call; re-set it so
264
+ // removeCache can call getHistoryDir() without throwing "No sessionId set on agent".
265
+ agent.setSessionId(sessionId);
266
+ // eslint-disable-next-line no-await-in-loop
267
+ await removeCache(agent);
268
+ ended.push({ sessionId, tracesPath });
269
+ }
270
+ catch (error) {
271
+ failed.push({ task, error: SfError.wrap(error).message });
272
+ }
273
+ }
274
+ return { ended, failed };
112
275
  }
113
276
  //# sourceMappingURL=end.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"end.js","sourceRoot":"","sources":["../../../../src/commands/agent/preview/end.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE3G,QAAQ,CAAC,kCAAkC,CAAC,MAAM,C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