@salesforce/plugin-agent 1.37.0 → 1.38.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
@@ -78,6 +78,9 @@ sf plugins
78
78
  - [`sf agent test resume`](#sf-agent-test-resume)
79
79
  - [`sf agent test run`](#sf-agent-test-run)
80
80
  - [`sf agent test run-eval`](#sf-agent-test-run-eval)
81
+ - [`sf agent trace delete`](#sf-agent-trace-delete)
82
+ - [`sf agent trace list`](#sf-agent-trace-list)
83
+ - [`sf agent trace read`](#sf-agent-trace-read)
81
84
  - [`sf agent validate authoring-bundle`](#sf-agent-validate-authoring-bundle)
82
85
 
83
86
  ## `sf agent activate`
@@ -127,7 +130,7 @@ EXAMPLES
127
130
  $ sf agent activate --api-name Resort_Manager --version 2 --target-org my-org
128
131
  ```
129
132
 
130
- _See code: [src/commands/agent/activate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/activate.ts)_
133
+ _See code: [src/commands/agent/activate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/activate.ts)_
131
134
 
132
135
  ## `sf agent create`
133
136
 
@@ -194,7 +197,7 @@ EXAMPLES
194
197
  $ sf agent create --name "Resort Manager" --spec specs/resortManagerAgent.yaml --preview
195
198
  ```
196
199
 
197
- _See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/create.ts)_
200
+ _See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/create.ts)_
198
201
 
199
202
  ## `sf agent deactivate`
200
203
 
@@ -235,7 +238,7 @@ EXAMPLES
235
238
  $ sf agent deactivate --api-name Resort_Manager --target-org my-org
236
239
  ```
237
240
 
238
- _See code: [src/commands/agent/deactivate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/deactivate.ts)_
241
+ _See code: [src/commands/agent/deactivate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/deactivate.ts)_
239
242
 
240
243
  ## `sf agent generate agent-spec`
241
244
 
@@ -342,7 +345,7 @@ EXAMPLES
342
345
  $ sf agent generate agent-spec --tone formal --agent-user resortmanager@myorg.com
343
346
  ```
344
347
 
345
- _See code: [src/commands/agent/generate/agent-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.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.38.0/src/commands/agent/generate/agent-spec.ts)_
346
349
 
347
350
  ## `sf agent generate authoring-bundle`
348
351
 
@@ -419,7 +422,7 @@ EXAMPLES
419
422
  other-package-dir/main/default --target-org my-dev-org
420
423
  ```
421
424
 
422
- _See code: [src/commands/agent/generate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.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.38.0/src/commands/agent/generate/authoring-bundle.ts)_
423
426
 
424
427
  ## `sf agent generate template`
425
428
 
@@ -481,7 +484,7 @@ EXAMPLES
481
484
  my-package --source-org my-scratch-org
482
485
  ```
483
486
 
484
- _See code: [src/commands/agent/generate/template.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/generate/template.ts)_
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)_
485
488
 
486
489
  ## `sf agent generate test-spec`
487
490
 
@@ -546,7 +549,7 @@ EXAMPLES
546
549
  force-app//main/default/aiEvaluationDefinitions/Resort_Manager_Tests.aiEvaluationDefinition-meta.xml
547
550
  ```
548
551
 
549
- _See code: [src/commands/agent/generate/test-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.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.38.0/src/commands/agent/generate/test-spec.ts)_
550
553
 
551
554
  ## `sf agent preview`
552
555
 
@@ -619,7 +622,7 @@ EXAMPLES
619
622
  $ sf agent preview --use-live-actions --apex-debug --output-dir transcripts/my-preview
620
623
  ```
621
624
 
622
- _See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/preview.ts)_
625
+ _See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.38.0/src/commands/agent/preview.ts)_
623
626
 
624
627
  ## `sf agent preview end`
625
628
 
@@ -674,7 +677,7 @@ EXAMPLES
674
677
  $ sf agent preview end --authoring-bundle My_Local_Agent
675
678
  ```
676
679
 
677
- _See code: [src/commands/agent/preview/end.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/preview/end.ts)_
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)_
678
681
 
679
682
  ## `sf agent preview send`
680
683
 
@@ -732,7 +735,7 @@ EXAMPLES
732
735
  $ sf agent preview send --utterance "what can you help me with?" --authoring-bundle My_Local_Agent
733
736
  ```
734
737
 
735
- _See code: [src/commands/agent/preview/send.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/preview/send.ts)_
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)_
736
739
 
737
740
  ## `sf agent preview sessions`
738
741
 
@@ -765,7 +768,7 @@ EXAMPLES
765
768
  $ sf agent preview sessions
766
769
  ```
767
770
 
768
- _See code: [src/commands/agent/preview/sessions.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/preview/sessions.ts)_
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)_
769
772
 
770
773
  ## `sf agent preview start`
771
774
 
@@ -830,7 +833,7 @@ EXAMPLES
830
833
  $ sf agent preview start --api-name My_Published_Agent
831
834
  ```
832
835
 
833
- _See code: [src/commands/agent/preview/start.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/preview/start.ts)_
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)_
834
837
 
835
838
  ## `sf agent publish authoring-bundle`
836
839
 
@@ -890,7 +893,7 @@ EXAMPLES
890
893
  $ sf agent publish authoring-bundle --api-name MyAuthoringbundle --concise
891
894
  ```
892
895
 
893
- _See code: [src/commands/agent/publish/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/publish/authoring-bundle.ts)_
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)_
894
897
 
895
898
  ## `sf agent test create`
896
899
 
@@ -945,7 +948,7 @@ EXAMPLES
945
948
  $ sf agent test create --spec specs/Resort_Manager-testSpec.yaml --api-name Resort_Manager_Test --preview
946
949
  ```
947
950
 
948
- _See code: [src/commands/agent/test/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/test/create.ts)_
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)_
949
952
 
950
953
  ## `sf agent test list`
951
954
 
@@ -980,7 +983,7 @@ EXAMPLES
980
983
  $ sf agent test list --target-org my-org
981
984
  ```
982
985
 
983
- _See code: [src/commands/agent/test/list.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/test/list.ts)_
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)_
984
987
 
985
988
  ## `sf agent test results`
986
989
 
@@ -1056,7 +1059,7 @@ FLAG DESCRIPTIONS
1056
1059
  expression when using custom evaluations.
1057
1060
  ```
1058
1061
 
1059
- _See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/test/results.ts)_
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)_
1060
1063
 
1061
1064
  ## `sf agent test resume`
1062
1065
 
@@ -1140,7 +1143,7 @@ FLAG DESCRIPTIONS
1140
1143
  expression when using custom evaluations.
1141
1144
  ```
1142
1145
 
1143
- _See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/test/resume.ts)_
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)_
1144
1147
 
1145
1148
  ## `sf agent test run`
1146
1149
 
@@ -1224,7 +1227,7 @@ FLAG DESCRIPTIONS
1224
1227
  expression when using custom evaluations.
1225
1228
  ```
1226
1229
 
1227
- _See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/test/run.ts)_
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)_
1228
1231
 
1229
1232
  ## `sf agent test run-eval`
1230
1233
 
@@ -1297,7 +1300,205 @@ EXAMPLES
1297
1300
  $ echo '{"tests":[...]}' | sf agent test run-eval --spec --target-org my-org
1298
1301
  ```
1299
1302
 
1300
- _See code: [src/commands/agent/test/run-eval.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/test/run-eval.ts)_
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)_
1304
+
1305
+ ## `sf agent trace delete`
1306
+
1307
+ Delete agent preview trace files.
1308
+
1309
+ ```
1310
+ USAGE
1311
+ $ sf agent trace delete [--json] [--flags-dir <value>] [-a <value>] [--session-id <value>] [--older-than <value>]
1312
+ [--no-prompt]
1313
+
1314
+ FLAGS
1315
+ -a, --agent=<value> Only delete traces for this agent name (substring match). Matches against the name used when
1316
+ starting the session, whether that's an authoring bundle or a published agent API name.
1317
+ --no-prompt Skip the confirmation prompt and delete immediately.
1318
+ --older-than=<value> Only delete traces older than this duration. Accepts a number followed by a unit: m/minutes,
1319
+ h/hours, d/days, w/weeks (e.g. 7d, 24h, 2w).
1320
+ --session-id=<value> Only delete traces from this session ID.
1321
+
1322
+ GLOBAL FLAGS
1323
+ --flags-dir=<value> Import flag values from a directory.
1324
+ --json Format output as json.
1325
+
1326
+ DESCRIPTION
1327
+ Delete agent preview trace files.
1328
+
1329
+ Deletes trace files recorded during agent preview sessions. By default, shows a preview of what will be deleted and
1330
+ prompts for confirmation. Use --no-prompt to skip confirmation.
1331
+
1332
+ Without filters, deletes all traces for all agents and sessions. Use flags to narrow the scope: filter by agent name
1333
+ (--agent), by session (--session-id), or by age (--older-than).
1334
+
1335
+ EXAMPLES
1336
+ Delete all traces for all agents and sessions (with confirmation prompt):
1337
+
1338
+ $ sf agent trace delete
1339
+
1340
+ Delete all traces for a specific agent:
1341
+
1342
+ $ sf agent trace delete --agent My_Agent
1343
+
1344
+ Delete traces from a specific session:
1345
+
1346
+ $ sf agent trace delete --session-id <SESSION_ID>
1347
+
1348
+ Delete traces older than 7 days:
1349
+
1350
+ $ sf agent trace delete --older-than 7d
1351
+
1352
+ Delete traces older than 24 hours for a specific agent, no prompt:
1353
+
1354
+ $ sf agent trace delete --agent My_Agent --older-than 24h --no-prompt
1355
+
1356
+ Delete all traces without confirmation:
1357
+
1358
+ $ sf agent trace delete --no-prompt
1359
+ ```
1360
+
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)_
1362
+
1363
+ ## `sf agent trace list`
1364
+
1365
+ List the trace files that were recorded during all agent preview sessions.
1366
+
1367
+ ```
1368
+ USAGE
1369
+ $ sf agent trace list [--json] [--flags-dir <value>] [--session-id <value>] [-a <value>] [--since <value>]
1370
+
1371
+ FLAGS
1372
+ -a, --agent=<value> Only show traces for this agent name (substring match). Matches against the name used when
1373
+ starting the session, whether that's an authoring bundle or a published agent API name.
1374
+ --session-id=<value> Session ID used to filter the list of trace files.
1375
+ --since=<value> Date used to filter the list of trace files; only those recorded on or after the date are
1376
+ listed.
1377
+
1378
+ GLOBAL FLAGS
1379
+ --flags-dir=<value> Import flag values from a directory.
1380
+ --json Format output as json.
1381
+
1382
+ DESCRIPTION
1383
+ List the trace files that were recorded during all agent preview sessions.
1384
+
1385
+ Lists trace files recorded during agent preview sessions. By default, lists all traces for all agents and all of their
1386
+ sessions. Use flags to narrow results: filter by agent name (--agent), by session (--session-id), or by date
1387
+ (--since).
1388
+
1389
+ Each row in the output corresponds to one trace file, which in turn corresponds to one agent session. The Agent column
1390
+ shows the authoring bundle or API name used when starting the session.
1391
+
1392
+ EXAMPLES
1393
+ List all traces for all agents and sessions:
1394
+
1395
+ $ sf agent trace list
1396
+
1397
+ List all traces for a specific agent:
1398
+
1399
+ $ sf agent trace list --agent My_Agent
1400
+
1401
+ List traces for a specific session:
1402
+
1403
+ $ sf agent trace list --session-id <SESSION_ID>
1404
+
1405
+ List traces recorded on or after April 20, 2026 (date-only, interpreted as UTC midnight):
1406
+
1407
+ $ sf agent trace list --since 2026-04-20
1408
+
1409
+ List traces recorded on or after a specific UTC time:
1410
+
1411
+ $ sf agent trace list --since 2026-04-20T14:00:00Z
1412
+
1413
+ Filter by agent and date together:
1414
+
1415
+ $ sf agent trace list --agent My_Agent --since 2026-04-20
1416
+
1417
+ Return results as JSON:
1418
+
1419
+ $ sf agent trace list --json
1420
+
1421
+ FLAG DESCRIPTIONS
1422
+ --since=<value> Date used to filter the list of trace files; only those recorded on or after the date are listed.
1423
+
1424
+ Accepts ISO 8601 format: date-only (2026-04-20), date-time (2026-04-20T14:00:00Z), or date-time with milliseconds
1425
+ (2026-04-20T14:00:00.000Z). The "Recorded At" values shown in the table output are valid inputs.
1426
+ ```
1427
+
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)_
1429
+
1430
+ ## `sf agent trace read`
1431
+
1432
+ Read and analyze trace files from an agent preview session.
1433
+
1434
+ ```
1435
+ USAGE
1436
+ $ sf agent trace read -s <value> [--json] [--flags-dir <value>] [-f summary|detail|raw] [-d
1437
+ actions|grounding|routing|errors] [-t <value>]
1438
+
1439
+ FLAGS
1440
+ -d, --dimension=<option> Dimension to drill into when using --format detail. One of: actions, grounding, routing,
1441
+ errors. Required when --format is detail.
1442
+ <options: actions|grounding|routing|errors>
1443
+ -f, --format=<option> [default: summary] Output format: summary (default), detail, or raw. Use detail with
1444
+ --dimension to drill into a specific aspect of the trace.
1445
+ <options: summary|detail|raw>
1446
+ -s, --session-id=<value> (required) Session ID to read traces for.
1447
+ -t, --turn=<value> Scope output to this conversation turn number.
1448
+
1449
+ GLOBAL FLAGS
1450
+ --flags-dir=<value> Import flag values from a directory.
1451
+ --json Format output as json.
1452
+
1453
+ DESCRIPTION
1454
+ Read and analyze trace files from an agent preview session.
1455
+
1456
+ Reads trace files recorded during an agent preview session and outputs them in one of three formats.
1457
+
1458
+ **--format summary** (default): A per-turn narrative showing topic routing, actions executed, and the agent's
1459
+ response. Use this to quickly understand what happened in a session.
1460
+
1461
+ **--format detail**: Diagnostic drill-down into a specific dimension (--dimension required). Filters output to only
1462
+ the trace steps relevant to that dimension, minimizing noise.
1463
+
1464
+ **--format raw**: Unprocessed trace JSON. Use this as a fallback when the trace schema has changed or you need to
1465
+ perform custom analysis.
1466
+
1467
+ Available dimensions for --format detail: actions, grounding, routing, errors.
1468
+
1469
+ Use --turn N to scope output to a single conversation turn.
1470
+
1471
+ EXAMPLES
1472
+ Show a session summary (all turns):
1473
+
1474
+ $ sf agent trace read --session-id <SESSION_ID>
1475
+
1476
+ Show summary for a single turn:
1477
+
1478
+ $ sf agent trace read --session-id <SESSION_ID> --turn 2
1479
+
1480
+ Drill into action execution across all turns:
1481
+
1482
+ $ sf agent trace read --session-id <SESSION_ID> --format detail --dimension actions
1483
+
1484
+ Drill into routing decisions for a specific turn:
1485
+
1486
+ $ sf agent trace read --session-id <SESSION_ID> --format detail --dimension routing --turn 1
1487
+
1488
+ Show all errors across the session:
1489
+
1490
+ $ sf agent trace read --session-id <SESSION_ID> --format detail --dimension errors
1491
+
1492
+ Output raw trace JSON for custom parsing:
1493
+
1494
+ $ sf agent trace read --session-id <SESSION_ID> --format raw
1495
+
1496
+ Return results as JSON:
1497
+
1498
+ $ sf agent trace read --session-id <SESSION_ID> --json
1499
+ ```
1500
+
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)_
1301
1502
 
1302
1503
  ## `sf agent validate authoring-bundle`
1303
1504
 
@@ -1344,6 +1545,6 @@ EXAMPLES
1344
1545
  $ sf agent validate authoring-bundle --api-name MyAuthoringBundle --target-org my-dev-org
1345
1546
  ```
1346
1547
 
1347
- _See code: [src/commands/agent/validate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.37.0/src/commands/agent/validate/authoring-bundle.ts)_
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)_
1348
1549
 
1349
1550
  <!-- commandsstop -->
@@ -0,0 +1,12 @@
1
+ import { type SfProject } from '@salesforce/core';
2
+ export type AgentSession = {
3
+ agentId: string;
4
+ displayName: string;
5
+ sessionId: string;
6
+ };
7
+ /**
8
+ * Returns all sessions that have trace data on disk — both active sessions (still in the
9
+ * cache index) and ended sessions (removed from the index by `agent preview end` but whose
10
+ * trace directories remain under .sfdx/agents/<agentId>/sessions/<sessionId>/).
11
+ */
12
+ export declare function listAllAgentSessions(project: SfProject): Promise<AgentSession[]>;
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { readdir } from 'node:fs/promises';
17
+ import { join } from 'node:path';
18
+ import { listCachedPreviewSessions } from '@salesforce/agents';
19
+ /**
20
+ * Returns all sessions that have trace data on disk — both active sessions (still in the
21
+ * cache index) and ended sessions (removed from the index by `agent preview end` but whose
22
+ * trace directories remain under .sfdx/agents/<agentId>/sessions/<sessionId>/).
23
+ */
24
+ export async function listAllAgentSessions(project) {
25
+ const cached = await listCachedPreviewSessions(project);
26
+ const active = cached.flatMap(({ agentId, displayName, sessions }) => sessions.map(({ sessionId }) => ({ agentId, displayName: displayName ?? agentId, sessionId })));
27
+ const seen = new Set(active.map((s) => s.sessionId));
28
+ const agentsDir = join(project.getPath(), '.sfdx', 'agents');
29
+ const ended = [];
30
+ try {
31
+ const agentDirs = await readdir(agentsDir, { withFileTypes: true });
32
+ for (const agentEnt of agentDirs) {
33
+ if (!agentEnt.isDirectory())
34
+ continue;
35
+ const sessionsDir = join(agentsDir, agentEnt.name, 'sessions');
36
+ try {
37
+ // eslint-disable-next-line no-await-in-loop
38
+ const sessionDirs = await readdir(sessionsDir, { withFileTypes: true });
39
+ for (const sessEnt of sessionDirs) {
40
+ if (!sessEnt.isDirectory() || seen.has(sessEnt.name))
41
+ continue;
42
+ ended.push({ agentId: agentEnt.name, displayName: agentEnt.name, sessionId: sessEnt.name });
43
+ seen.add(sessEnt.name);
44
+ }
45
+ }
46
+ catch {
47
+ // no sessions dir for this agent
48
+ }
49
+ }
50
+ }
51
+ catch {
52
+ // no .sfdx/agents dir yet
53
+ }
54
+ return [...active, ...ended];
55
+ }
56
+ //# sourceMappingURL=agentSessionScanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentSessionScanner.js","sourceRoot":"","sources":["../src/agentSessionScanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAI/D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAkB;IAC3D,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACxD,MAAM,MAAM,GAAmB,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE,CACnF,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,IAAI,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAC/F,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAErD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QACpE,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;gBAAE,SAAS;YACtC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAC/D,IAAI,CAAC;gBACH,4CAA4C;gBAC5C,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;gBACxE,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE,CAAC;oBAClC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;wBAAE,SAAS;oBAC/D,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;oBAC5F,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,iCAAiC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,0BAA0B;IAC5B,CAAC;IAED,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type AgentTraceDeleteResult = Array<{
3
+ agent: string;
4
+ sessionId: string;
5
+ planId: string;
6
+ path: string;
7
+ }>;
8
+ export default class AgentTraceDelete extends SfCommand<AgentTraceDeleteResult> {
9
+ static readonly summary: string;
10
+ static readonly description: string;
11
+ static readonly examples: string[];
12
+ static readonly requiresProject = true;
13
+ static readonly errorCodes: import("@oclif/core").HelpSection;
14
+ static readonly flags: {
15
+ agent: 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
+ 'older-than': import("@oclif/core/interfaces").OptionFlag<Date | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'no-prompt': import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
+ };
20
+ run(): Promise<AgentTraceDeleteResult>;
21
+ }
@@ -0,0 +1,118 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { unlink } from 'node:fs/promises';
17
+ import { Flags, SfCommand, toHelpSection } from '@salesforce/sf-plugins-core';
18
+ import { Messages, SfError } from '@salesforce/core';
19
+ import { listSessionTraces } from '@salesforce/agents';
20
+ import yesNoOrCancel from '../../../yes-no-cancel.js';
21
+ import { listAllAgentSessions } from '../../../agentSessionScanner.js';
22
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
23
+ const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.trace.delete');
24
+ const DURATION_RE = /^(\d+)(d|h|m|w|days?|hours?|minutes?|weeks?)$/i;
25
+ const UNIT_MS = {
26
+ m: 60_000,
27
+ minute: 60_000,
28
+ minutes: 60_000,
29
+ h: 3_600_000,
30
+ hour: 3_600_000,
31
+ hours: 3_600_000,
32
+ d: 86_400_000,
33
+ day: 86_400_000,
34
+ days: 86_400_000,
35
+ w: 604_800_000,
36
+ week: 604_800_000,
37
+ weeks: 604_800_000,
38
+ };
39
+ export default class AgentTraceDelete extends SfCommand {
40
+ static summary = messages.getMessage('summary');
41
+ static description = messages.getMessage('description');
42
+ static examples = messages.getMessages('examples');
43
+ static requiresProject = true;
44
+ static errorCodes = toHelpSection('ERROR CODES', {
45
+ 'Succeeded (0)': 'Traces deleted successfully (or no traces matched).',
46
+ });
47
+ static flags = {
48
+ agent: Flags.string({
49
+ summary: messages.getMessage('flags.agent.summary'),
50
+ char: 'a',
51
+ }),
52
+ 'session-id': Flags.string({
53
+ summary: messages.getMessage('flags.session-id.summary'),
54
+ }),
55
+ 'older-than': Flags.custom({
56
+ summary: messages.getMessage('flags.older-than.summary'),
57
+ // eslint-disable-next-line @typescript-eslint/require-await
58
+ parse: async (raw) => {
59
+ const match = DURATION_RE.exec(raw);
60
+ if (!match) {
61
+ throw new SfError(messages.getMessage('error.invalidOlderThan', [raw]), 'InvalidDuration');
62
+ }
63
+ const ms = parseInt(match[1], 10) * UNIT_MS[match[2].toLowerCase()];
64
+ return new Date(Date.now() - ms);
65
+ },
66
+ })(),
67
+ 'no-prompt': Flags.boolean({
68
+ summary: messages.getMessage('flags.no-prompt.summary'),
69
+ }),
70
+ };
71
+ async run() {
72
+ const { flags } = await this.parse(AgentTraceDelete);
73
+ const agentFilter = flags.agent?.toLowerCase();
74
+ const allSessions = await listAllAgentSessions(this.project);
75
+ const candidates = [];
76
+ for (const { agentId, displayName, sessionId } of allSessions) {
77
+ if (agentFilter && !displayName.toLowerCase().includes(agentFilter))
78
+ continue;
79
+ if (flags['session-id'] && sessionId !== flags['session-id'])
80
+ continue;
81
+ // eslint-disable-next-line no-await-in-loop
82
+ let traces = await listSessionTraces(agentId, sessionId);
83
+ if (flags['older-than']) {
84
+ traces = traces.filter((t) => t.mtime < flags['older-than']);
85
+ }
86
+ for (const t of traces) {
87
+ candidates.push({ agent: displayName, sessionId, planId: t.planId, path: t.path });
88
+ }
89
+ }
90
+ if (candidates.length === 0) {
91
+ this.log(messages.getMessage('output.noneFound'));
92
+ return [];
93
+ }
94
+ if (!flags['no-prompt']) {
95
+ this.log(messages.getMessage('output.preview', [candidates.length]));
96
+ this.table({
97
+ data: candidates.map((c) => ({ agent: c.agent, sessionId: c.sessionId, planId: c.planId })),
98
+ columns: [
99
+ { key: 'agent', name: messages.getMessage('output.tableHeader.agent') },
100
+ { key: 'sessionId', name: messages.getMessage('output.tableHeader.sessionId') },
101
+ { key: 'planId', name: messages.getMessage('output.tableHeader.planId') },
102
+ ],
103
+ });
104
+ const confirmed = await yesNoOrCancel({
105
+ message: messages.getMessage('prompt.confirm', [candidates.length]),
106
+ default: false,
107
+ });
108
+ if (confirmed === 'cancel' || confirmed === false) {
109
+ this.log(messages.getMessage('output.cancelled'));
110
+ return [];
111
+ }
112
+ }
113
+ await Promise.all(candidates.map((c) => unlink(c.path)));
114
+ this.log(messages.getMessage('output.deleted', [candidates.length]));
115
+ return candidates;
116
+ }
117
+ }
118
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../src/commands/agent/trace/delete.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAsB,MAAM,oBAAoB,CAAC;AAC3E,OAAO,aAAa,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC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;oBACvE,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC,EAAE;oBAC/E,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC,EAAE;iBAC1E;aACF,CAAC,CAAC;YAEH,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC;gBACpC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACnE,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;YAEH,IAAI,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;gBAClD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;gBAClD,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrE,OAAO,UAAU,CAAC;IACpB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type AgentTraceListResult = Array<{
3
+ agent: string;
4
+ sessionId: string;
5
+ planId: string;
6
+ path: string;
7
+ size: number;
8
+ mtime: string;
9
+ }>;
10
+ export default class AgentTraceList extends SfCommand<AgentTraceListResult> {
11
+ static readonly summary: string;
12
+ static readonly description: string;
13
+ static readonly examples: string[];
14
+ static readonly requiresProject = true;
15
+ static readonly errorCodes: import("@oclif/core").HelpSection;
16
+ static readonly flags: {
17
+ 'session-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ since: import("@oclif/core/interfaces").OptionFlag<Date | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ };
21
+ run(): Promise<AgentTraceListResult>;
22
+ }