Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
07838d9
feat: add --all flag to agent preview end (W-22203669)
franciscoperezsammartino Apr 28, 2026
c0f8d35
fix: address review findings for --all flag on agent preview end
franciscoperezsammartino Apr 28, 2026
cd0f110
chore: regenerate schemas and fix NUT type assertions for EndedSessio…
franciscoperezsammartino Apr 28, 2026
2b06552
fix: restore SessionType named import in start.ts
franciscoperezsammartino Apr 28, 2026
1c51088
refactor: restore pre-shim inline session store; scope to W-22203669 …
franciscoperezsammartino Apr 28, 2026
2aa93f1
fix: remove agentId from EndedSession public result type
franciscoperezsammartino Apr 28, 2026
0336fb9
refactor: enforce --target-org dependency on --api-name at flag level
franciscoperezsammartino Apr 28, 2026
3ea4c26
refactor: extract callPreviewEnd to remove instanceof duplication
franciscoperezsammartino Apr 28, 2026
f54e906
chore: restore atomic-write comment on updateSessionIndex
franciscoperezsammartino Apr 28, 2026
6f64ff5
refactor: eliminate getSessionDir/removeCacheById in favor of duck-ty…
franciscoperezsammartino Apr 28, 2026
26666d1
chore: restore previewSessionStore.ts to main shim and upgrade @sales…
franciscoperezsammartino Apr 28, 2026
4c9f795
chore: restore yarn.lock to main state
franciscoperezsammartino Apr 28, 2026
6716566
Apply suggestion from @jshackell-sfdc
franciscoperezsammartino Apr 28, 2026
10fe754
Apply suggestion from @jshackell-sfdc
franciscoperezsammartino Apr 28, 2026
b9a6a13
refactor: use Interfaces.InferredFlags for private method flag types
franciscoperezsammartino Apr 28, 2026
15b796d
refactor: require --api-name or --authoring-bundle when using --all
franciscoperezsammartino Apr 29, 2026
9553aca
refactor: enforce --all agent identifier requirement at flag definiti…
franciscoperezsammartino Apr 29, 2026
95a25a9
refactor: use exactlyOne instead of exclusive+atLeastOne for agent id…
franciscoperezsammartino Apr 29, 2026
6b5d6b7
feat: allow --all alone to end sessions across all cached agents
franciscoperezsammartino Apr 30, 2026
1b1c52d
fix: address PR review feedback and improve --all end-all-agents path
franciscoperezsammartino May 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,16 @@ End an existing programmatic agent preview session and get trace location.

```
USAGE
$ sf agent preview end -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [--session-id <value>] [-n
<value>] [--authoring-bundle <value>]
$ sf agent preview end [--json] [--flags-dir <value>] [--api-version <value>] [--session-id <value>] [-n <value>]
[--authoring-bundle <value>] [--all] [-p] [-o <value>]

FLAGS
-n, --api-name=<value> API name of the activated published agent you want to preview.
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
-o, --target-org=<value> Username or alias of the target org. Required with --api-name. Not required if the
`target-org` configuration variable is already set.
-p, --no-prompt Skip confirmation when using --all (no effect otherwise).
--all End every cached preview session for the agent given by --api-name or
--authoring-bundle.
--api-version=<value> Override the api version used for api requests made by this command
--authoring-bundle=<value> API name of the authoring bundle metadata component that contains the agent's Agent
Script file.
Expand All @@ -652,7 +655,7 @@ DESCRIPTION
The original "agent preview start" command outputs a session ID which you then use with the --session-id flag of this
command to end the session. You don't have to specify the --session-id flag if an agent has only one active preview
session. You must also use either the --authoring-bundle or --api-name flag to specify the API name of the authoring
bundle or the published agent, respecitvely. To find either API name, navigate to your package directory in your DX
bundle or the published agent, respectively. To find either API name, navigate to your package directory in your DX
project. The API name of an authoring bundle is the same as its directory name under the "aiAuthoringBundles" metadata
directory. Similarly, the published agent's API name is the same as its directory name under the "Bots" metadata
directory.
Expand All @@ -671,6 +674,10 @@ EXAMPLES
one active session.

$ sf agent preview end --authoring-bundle My_Local_Agent

End every cached preview session for that authoring bundle without a confirmation prompt:

$ sf agent preview end --all --authoring-bundle My_Local_Agent --no-prompt
```

_See code: [src/commands/agent/preview/end.ts](https://github.com/salesforcecli/plugin-agent/blob/1.34.0/src/commands/agent/preview/end.ts)_
Expand Down
14 changes: 12 additions & 2 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,18 @@
"alias": [],
"command": "agent:preview:end",
"flagAliases": [],
"flagChars": ["n", "o"],
"flags": ["api-name", "api-version", "authoring-bundle", "flags-dir", "json", "session-id", "target-org"],
"flagChars": ["n", "o", "p"],
"flags": [
"all",
"api-name",
"api-version",
"authoring-bundle",
"flags-dir",
"json",
"no-prompt",
"session-id",
"target-org"
],
"plugin": "@salesforce/plugin-agent"
},
{
Expand Down
38 changes: 36 additions & 2 deletions messages/agent.preview.end.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ End an existing programmatic agent preview session and get trace location.

You must have previously started a programmatic agent preview session with the "agent preview start" command to then use this command to end it. This command also displays the local directory where the session trace files are stored.

The original "agent preview start" command outputs a session ID which you then use with the --session-id flag of this command to end the session. You don't have to specify the --session-id flag if an agent has only one active preview session. You must also use either the --authoring-bundle or --api-name flag to specify the API name of the authoring bundle or the published agent, respecitvely. To find either API name, navigate to your package directory in your DX project. The API name of an authoring bundle is the same as its directory name under the "aiAuthoringBundles" metadata directory. Similarly, the published agent's API name is the same as its directory name under the "Bots" metadata directory.
The original "agent preview start" command outputs a session ID which you then use with the --session-id flag of this command to end the session. You don't have to specify the --session-id flag if an agent has only one active preview session. You must also use either the --authoring-bundle or --api-name flag to specify the API name of the authoring bundle or the published agent, respectively. To find either API name, navigate to your package directory in your DX project. The API name of an authoring bundle is the same as its directory name under the "aiAuthoringBundles" metadata directory. Similarly, the published agent's API name is the same as its directory name under the "Bots" metadata directory.

Use the --all flag to end all active preview sessions at once. You can combine --all with --api-name or --authoring-bundle to end only sessions for a specific agent, or use --all on its own to end every session across all agents in the project.

# flags.session-id.summary

Expand All @@ -20,6 +22,14 @@ API name of the activated published agent you want to preview.

API name of the authoring bundle metadata component that contains the agent's Agent Script file.

# flags.all.summary

End all active preview sessions. Combine with --api-name or --authoring-bundle to limit to a specific agent, or use with only --target-org to end sessions for all agents found in the local session cache. Requires --target-org.

# flags.no-prompt.summary

Don't prompt for confirmation before ending sessions. Has an effect only when used with --all.

# error.noSession

No agent preview session found. Run "sf agent preview start" to start a new agent preview session.
Expand All @@ -44,9 +54,25 @@ Failed to end preview session: %s

Session traces: %s

# output.noSessionsFound

No active preview sessions found.

# output.endedAll

Ended %s preview session(s).

# prompt.confirmAll

About to end %s preview session(s) for agent '%s'. Continue?

# prompt.confirmAllAgents

About to end %s preview session(s) across %s agent(s). Continue?

# examples

- End a preview session of a published agent by specifying its session ID and API name ; use the default org:
- End a preview session of a published agent by specifying its session ID and API name; use the default org:

<%= config.bin %> <%= command.id %> --session-id <SESSION_ID> --api-name My_Published_Agent

Expand All @@ -57,3 +83,11 @@ Session traces: %s
- End a preview session of an agent using its authoring bundle API name; you get an error if the agent has more than one active session.

<%= config.bin %> <%= command.id %> --authoring-bundle My_Local_Agent

- End all active preview sessions for a specific agent without prompting:

<%= config.bin %> <%= command.id %> --all --authoring-bundle My_Local_Agent --target-org <target_org> --no-prompt

- End all active preview sessions across every agent in the local session cache for an org:

<%= config.bin %> <%= command.id %> --all --target-org <target_org>
20 changes: 20 additions & 0 deletions schemas/agent-preview-end.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
"$ref": "#/definitions/AgentPreviewEndResult",
"definitions": {
"AgentPreviewEndResult": {
"anyOf": [
{
"type": "object",
"properties": {
"ended": {
"type": "array",
"items": {
"$ref": "#/definitions/EndedSession"
}
}
},
"required": ["ended"],
"additionalProperties": false
},
{
"$ref": "#/definitions/EndedSession"
}
]
},
"EndedSession": {
"type": "object",
"properties": {
"sessionId": {
Expand Down
Loading
Loading