Skip to content
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,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 @@ -656,7 +659,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 @@ -675,6 +678,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.38.1/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 @@ -108,8 +108,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
42 changes: 40 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,18 @@ 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.exactlyOneRequired

Exactly one of the following must be provided: --api-name, --authoring-bundle

# error.noSession

No agent preview session found. Run "sf agent preview start" to start a new agent preview session.
Expand All @@ -44,9 +58,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 +87,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