Skip to content

Commit b89c252

Browse files
Merge pull request #320 from salesforcecli/wr/programmaticPreviewII
Wr/programmatic preview ii @W-21191157@
2 parents 56d829f + b2e9ef6 commit b89c252

20 files changed

Lines changed: 1424 additions & 362 deletions

command-snapshot.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,47 @@
9292
],
9393
"plugin": "@salesforce/plugin-agent"
9494
},
95+
{
96+
"alias": [],
97+
"command": "agent:preview:end",
98+
"flagAliases": [],
99+
"flagChars": ["n", "o"],
100+
"flags": ["api-name", "api-version", "authoring-bundle", "flags-dir", "json", "session-id", "target-org"],
101+
"plugin": "@salesforce/plugin-agent"
102+
},
103+
{
104+
"alias": [],
105+
"command": "agent:preview:send",
106+
"flagAliases": [],
107+
"flagChars": ["n", "o", "u"],
108+
"flags": [
109+
"api-name",
110+
"api-version",
111+
"authoring-bundle",
112+
"flags-dir",
113+
"json",
114+
"session-id",
115+
"target-org",
116+
"utterance"
117+
],
118+
"plugin": "@salesforce/plugin-agent"
119+
},
120+
{
121+
"alias": [],
122+
"command": "agent:preview:sessions",
123+
"flagAliases": [],
124+
"flagChars": [],
125+
"flags": ["flags-dir", "json"],
126+
"plugin": "@salesforce/plugin-agent"
127+
},
128+
{
129+
"alias": [],
130+
"command": "agent:preview:start",
131+
"flagAliases": [],
132+
"flagChars": ["n", "o"],
133+
"flags": ["api-name", "api-version", "authoring-bundle", "flags-dir", "json", "target-org", "use-live-actions"],
134+
"plugin": "@salesforce/plugin-agent"
135+
},
95136
{
96137
"alias": [],
97138
"command": "agent:publish:authoring-bundle",

messages/agent.preview.end.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# summary
2+
3+
End an existing programmatic agent preview session and get trace location.
4+
5+
# description
6+
7+
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.
8+
9+
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.
10+
11+
# flags.session-id.summary
12+
13+
Session ID outputted by "agent preview start". Not required when the agent has exactly one active session. Run "agent preview sessions" to see the list of all sessions.
14+
15+
# flags.api-name.summary
16+
17+
API name of the activated published agent you want to preview.
18+
19+
# flags.authoring-bundle.summary
20+
21+
API name of the authoring bundle metadata component that contains the agent's Agent Script file.
22+
23+
# error.noSession
24+
25+
No agent preview session found. Run "sf agent preview start" to start a new agent preview session.
26+
27+
# error.multipleSessions
28+
29+
Multiple preview sessions found for this agent. Use the --session-id flag to identify a specific session. Sessions: %s
30+
31+
# output.tracesPath
32+
33+
Session traces: %s
34+
35+
# examples
36+
37+
- End a preview session of a published agent by specifying its session ID and API name ; use the default org:
38+
39+
<%= config.bin %> <%= command.id %> --session-id <SESSION_ID> --api-name My_Published_Agent
40+
41+
- Similar to previous example, but don't specify a session ID; you get an error if the published agent has more than one active session. Use the org with alias "my-dev-org":
42+
43+
<%= config.bin %> <%= command.id %> --api-name My_Published_Agent --target-org my-dev-org
44+
45+
- 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.
46+
47+
<%= config.bin %> <%= command.id %> --authoring-bundle My_Local_Agent

messages/agent.preview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ When the session concludes, the command asks if you want to save the API respons
2121

2222
# flags.api-name.summary
2323

24-
API name of the published and active agent you want to interact with.
24+
API name of the activated published agent you want to interact with.
2525

2626
# flags.authoring-bundle.summary
2727

messages/agent.preview.send.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# summary
2+
3+
Send a message to an existing agent preview session.
4+
5+
# description
6+
7+
You must have previously started a programmatic agent preview session with the "agent preview start" command to then use this command to send the agent a message (utterance). This command then displays the agent's response.
8+
9+
The original "agent preview start" command outputs a session ID which you then use with the --session-id flag of this command to send a message. 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.
10+
11+
# flags.session-id.summary
12+
13+
Session ID outputted by "agent preview start". Not required when the agent has exactly one active session. Run "agent preview sessions" to see list of all sessions.
14+
15+
# flags.utterance.summary
16+
17+
Utterance to send to the agent, enclosed in double quotes.
18+
19+
# flags.api-name.summary
20+
21+
API name of the activated published agent you want to preview.
22+
23+
# flags.authoring-bundle.summary
24+
25+
API name of the authoring bundle metadata component that contains the agent's Agent Script file.
26+
27+
# error.noSession
28+
29+
No agent preview session found. Run "sf agent preview start" to start a new agent preview session.
30+
31+
# error.multipleSessions
32+
33+
Multiple preview sessions found for this agent. Use the --session-id flag to identify a specific session. Sessions: %s
34+
35+
# examples
36+
37+
- Send a message to an activated published agent using its API name and session ID; use the default org:
38+
39+
<%= config.bin %> <%= command.id %> --utterance "What can you help me with?" --api-name My_Published_Agent --session-id <SESSION_ID>
40+
41+
- Similar to previous example, but don't specify a session ID; you get an error if the agent has more than one active session. Use the org with alias "my-dev-org":
42+
43+
<%= config.bin %> <%= command.id %> --utterance "What can you help me with?" --api-name My_Published_Agent --target-org my-dev-org
44+
45+
- Send a message to an agent using its authoring bundle API name; you get an error if the agent has more than one active session:
46+
47+
<%= config.bin %> <%= command.id %> --utterance "what can you help me with?" --authoring-bundle My_Local_Agent

messages/agent.preview.sessions.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# summary
2+
3+
List all known programmatic agent preview sessions.
4+
5+
# description
6+
7+
This command lists the agent preview sessions that were started with the "agent preview start" command and are still in the local cache. Use this command to discover specific session IDs that you can pass to the "agent preview send" or "agent preview end" commands with the --session-id flag.
8+
9+
Programmatic agent preview sessions can be started for both published activated agents and by using an agent's local authoring bundle, which contains its Agent Script file. In this command's output table, the Agent column contains either the API name of the authoring bundle or the published agent, whichever was used when starting the session. In the table, if the same API name has multiple rows with different session IDs, then it means that you previously started multiple preview sessions with the associated agent.
10+
11+
# output.empty
12+
13+
No cached agent preview sessions found.
14+
15+
# output.tableHeader.agent
16+
17+
Agent (authoring bundle or API name)
18+
19+
# output.tableHeader.sessionId
20+
21+
Session ID
22+
23+
# examples
24+
25+
- List all cached agent preview sessions:
26+
27+
<%= config.bin %> <%= command.id %>

messages/agent.preview.start.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# summary
2+
3+
Start a programmatic agent preview session.
4+
5+
# description
6+
7+
This command outputs a session ID that you then use with the "agent preview send" command to send an utterance to the agent. Use the "agent preview sessions" command to list all active sessions and the "agent preview end" command to end a specific session.
8+
9+
Identify the agent you want to start previewing with either the --authoring-bundle flag to specify a local authoring bundle's API name or --api-name to specify an activated published agent's API name. 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.
10+
11+
When starting a preview session using the authoring bundle, which contains the agent's Agent Script file, the preview uses mocked actions by default. Specify --use-live-actions for live mode, which uses the real Apex classes, flows, etc, in the org for the actions.
12+
13+
# flags.api-name.summary
14+
15+
API name of the activated published agent you want to preview.
16+
17+
# flags.authoring-bundle.summary
18+
19+
API name of the authoring bundle metadata component that contains the agent's Agent Script file.
20+
21+
# flags.use-live-actions.summary
22+
23+
Use real actions in the org; if not specified, preview uses AI to simulate (mock) actions.
24+
25+
# output.sessionId
26+
27+
Session ID: %s
28+
29+
# examples
30+
31+
- Start a programmatic agent preview session by specifying an authoring bundle; uses mocked actions by default. Use the org with alias "my-dev-org":
32+
33+
<%= config.bin %> <%= command.id %> --authoring-bundle My_Agent_Bundle --target-org my-dev-org
34+
35+
- Similar to previous example but use live actions and the default org:
36+
37+
<%= config.bin %> <%= command.id %> --authoring-bundle My_Agent_Bundle --use-live-actions
38+
39+
- Start a preview session with an activated published agent:
40+
41+
<%= config.bin %> <%= command.id %> --api-name My_Published_Agent

schemas/agent-preview-end.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/AgentPreviewEndResult",
4+
"definitions": {
5+
"AgentPreviewEndResult": {
6+
"type": "object",
7+
"properties": {
8+
"sessionId": {
9+
"type": "string"
10+
},
11+
"tracesPath": {
12+
"type": "string"
13+
}
14+
},
15+
"required": ["sessionId", "tracesPath"],
16+
"additionalProperties": false
17+
}
18+
}
19+
}

schemas/agent-preview-send.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/AgentPreviewSendResult",
4+
"definitions": {
5+
"AgentPreviewSendResult": {
6+
"type": "object",
7+
"properties": {
8+
"messages": {
9+
"type": "array",
10+
"items": {
11+
"type": "object",
12+
"properties": {
13+
"message": {
14+
"type": "string"
15+
},
16+
"role": {
17+
"type": "string"
18+
}
19+
},
20+
"additionalProperties": false
21+
}
22+
}
23+
},
24+
"required": ["messages"],
25+
"additionalProperties": false
26+
}
27+
}
28+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/AgentPreviewSessionsResult",
4+
"definitions": {
5+
"AgentPreviewSessionsResult": {
6+
"type": "array",
7+
"items": {
8+
"type": "object",
9+
"properties": {
10+
"agentId": {
11+
"type": "string"
12+
},
13+
"displayName": {
14+
"type": "string"
15+
},
16+
"sessionId": {
17+
"type": "string"
18+
}
19+
},
20+
"required": ["agentId", "sessionId"],
21+
"additionalProperties": false
22+
}
23+
}
24+
}
25+
}

schemas/agent-preview-start.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/AgentPreviewStartResult",
4+
"definitions": {
5+
"AgentPreviewStartResult": {
6+
"type": "object",
7+
"properties": {
8+
"sessionId": {
9+
"type": "string"
10+
}
11+
},
12+
"required": ["sessionId"],
13+
"additionalProperties": false
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)