@salesforce/plugin-agent 1.10.0 → 1.11.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
@@ -65,10 +65,10 @@ sf plugins
65
65
  - [`sf agent create-v2`](#sf-agent-create-v2)
66
66
  - [`sf agent generate spec`](#sf-agent-generate-spec)
67
67
  - [`sf agent generate spec-v2`](#sf-agent-generate-spec-v2)
68
- - [`sf agent generate test-cases`](#sf-agent-generate-test-cases)
69
- - [`sf agent generate test-definition`](#sf-agent-generate-test-definition)
68
+ - [`sf agent generate test-spec`](#sf-agent-generate-test-spec)
70
69
  - [`sf agent preview`](#sf-agent-preview)
71
70
  - [`sf agent test cancel`](#sf-agent-test-cancel)
71
+ - [`sf agent test create`](#sf-agent-test-create)
72
72
  - [`sf agent test list`](#sf-agent-test-list)
73
73
  - [`sf agent test results`](#sf-agent-test-results)
74
74
  - [`sf agent test resume`](#sf-agent-test-resume)
@@ -114,11 +114,11 @@ EXAMPLES
114
114
  $ sf agent create --name CustomerSupportAgent --spec ./config/agentSpec.json --target-org my-org
115
115
  ```
116
116
 
117
- _See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/create.ts)_
117
+ _See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/create.ts)_
118
118
 
119
119
  ## `sf agent create-v2`
120
120
 
121
- Create an agent in your org from a local agent spec file.
121
+ Create an agent in your org using a local agent spec file.
122
122
 
123
123
  ```
124
124
  USAGE
@@ -129,43 +129,54 @@ USAGE
129
129
  FLAGS
130
130
  -o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
131
131
  configuration variable is already set.
132
- --agent-name=<value> Name for the new agent.
132
+ --agent-name=<value> Name (label) of the new agent.
133
133
  --api-version=<value> Override the api version used for api requests made by this command
134
- --enrich-logs=<option> Adds agent conversation data to event logs.
134
+ --enrich-logs=<option> Adds agent conversation data to event logs so you can view all agent session activity in
135
+ one place.
135
136
  <options: true|false>
136
137
  --planner-id=<value> The GenAiPlanner ID to associate with the agent.
137
- --preview Preview the agent without saving in your org.
138
+ --preview Preview the agent without saving it in your org.
138
139
  --spec=<value> (required) Path to an agent spec file.
139
- --tone=<option> Conversational style of agent responses.
140
+ --tone=<option> Conversational style of the agent, such as how it expresses your brand personality in its
141
+ messages through word choice, punctuation, and sentence structure.
140
142
  <options: formal|casual|neutral>
141
- --user-id=<value> Custom user ID for the agent.
143
+ --user-id=<value> ID of a user in your org that is assigned to your agent; determines what your agent can
144
+ access and do.
142
145
 
143
146
  GLOBAL FLAGS
144
147
  --flags-dir=<value> Import flag values from a directory.
145
148
  --json Format output as json.
146
149
 
147
150
  DESCRIPTION
148
- Create an agent in your org from a local agent spec file.
151
+ Create an agent in your org using a local agent spec file.
149
152
 
150
- To generate an agent spec file, run the "agent generate spec" CLI command, which outputs a YAML file with the list of
151
- jobs and descriptions that the new agent can perform. Then specify this generated spec file to the --spec flag of this
152
- command, along with the name of the new agent.
153
+ Before you run this command, you must first generate an agent spec file by running the "agent generate spec" CLI
154
+ command, which outputs a YAML file with the agent properties and list of AI-generated topics. Topics define the range
155
+ of jobs the agent can handle. Then specify the generated agent spec file to this command using the --spec flag, along
156
+ with the name (label) of the new agent using the --agent-name flag.
153
157
 
154
158
  When this command finishes, your org contains the new agent, which you can then edit in the Agent Builder UI. The new
155
- agent already has a list of topics and actions that were automatically created from the list of jobs in the provided
156
- agent spec file. This command also retrieves all the metadata files associated with the new agent to your local DX
159
+ agent's topics are the same as the ones listed in the agent spec file. The agent might also have some AI-generated
160
+ actions. This command also retrieves all the metadata files associated with the new agent to your local Salesforce DX
157
161
  project.
158
162
 
163
+ Use the --preview flag to review what the agent looks like without actually saving it in your org. Rather, the command
164
+ creates a JSON file with all the agent details in the current directory.
165
+
159
166
  To open the new agent in your org's Agent Builder UI, run this command: "sf org open agent --name
160
167
  <api-name-of-your-agent>".
161
168
 
162
169
  EXAMPLES
163
- Create an agent called "CustomerSupportAgent" in an org with alias "my-org" using the specified agent spec file:
170
+ Create an agent called "ResortManager" in an org with alias "my-org" using the specified agent spec file:
171
+
172
+ $ sf agent create-v2 --agent-name ResortManager --spec specs/resortManagerAgent.yaml --target-org my-org
164
173
 
165
- $ sf agent create-v2 --name CustomerSupportAgent --spec ./config/agentSpec.json --target-org my-org
174
+ Preview the creation of an agent called "ResortManager" and use your default org:
175
+
176
+ $ sf agent create-v2 --agent-name ResortManager --spec specs/resortManagerAgent.yaml --preview
166
177
  ```
167
178
 
168
- _See code: [src/commands/agent/create-v2.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/create-v2.ts)_
179
+ _See code: [src/commands/agent/create-v2.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/create-v2.ts)_
169
180
 
170
181
  ## `sf agent generate spec`
171
182
 
@@ -226,11 +237,11 @@ EXAMPLES
226
237
  $ sf agent generate spec --output-dir specs --target-org my-org
227
238
  ```
228
239
 
229
- _See code: [src/commands/agent/generate/spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/generate/spec.ts)_
240
+ _See code: [src/commands/agent/generate/spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/generate/spec.ts)_
230
241
 
231
242
  ## `sf agent generate spec-v2`
232
243
 
233
- Generate an agent spec, which is the list of jobs that the agent performs.
244
+ Generate an agent spec, which is a YAML file that captures what an agent can do.
234
245
 
235
246
  ```
236
247
  USAGE
@@ -247,98 +258,91 @@ FLAGS
247
258
  --company-description=<value> Description of your company.
248
259
  --company-name=<value> Name of your company.
249
260
  --company-website=<value> Website URL of your company.
250
- --grounding-context=<value> Context information to be used with the customized prompt template.
251
- --max-topics=<value> Maximum number of agent job topics to generate in the spec; default is 10.
252
- --output-file=<value> [default: config/agentSpec.yaml] Path for the generated agent spec file (yaml); can
261
+ --grounding-context=<value> Context information and personalization that's added to your prompts when using a
262
+ custom prompt template.
263
+ --max-topics=<value> Maximum number of topics to generate in the agent spec; default is 10.
264
+ --output-file=<value> [default: config/agentSpec.yaml] Path for the generated YAML agent spec file; can
253
265
  be an absolute or relative path.
254
- --prompt-template=<value> Developer name of a customized prompt template to use instead of the default.
266
+ --prompt-template=<value> API name of a customized prompt template to use instead of the default prompt
267
+ template.
255
268
  --role=<value> Role of the agent.
256
- --spec=<value> Spec file (yaml) to use as input to the command.
269
+ --spec=<value> Agent spec file, in YAML format, to use as input to the command.
257
270
 
258
271
  GLOBAL FLAGS
259
272
  --flags-dir=<value> Import flag values from a directory.
260
273
  --json Format output as json.
261
274
 
262
275
  DESCRIPTION
263
- Generate an agent spec, which is the list of jobs that the agent performs.
276
+ Generate an agent spec, which is a YAML file that captures what an agent can do.
264
277
 
265
- When using Salesforce CLI to create an agent in your org, you can choose to generate a YAML-formatted agent spec file
266
- with this command as a first step.
278
+ Before you use Salesforce CLI to create an agent in your org, you must first generate an agent spec with this command.
279
+ An agent spec is a YAML-formatted file that contains information about the agent, such as its role and company
280
+ description, and then an AI-generated list of topics based on this information. Topics define the range of jobs your
281
+ agent can handle.
267
282
 
268
- An agent spec is a list of jobs and descriptions that capture what the agent can do. Use flags such as --role and
269
- --company-description to provide details about your company and the role that the agent plays in your company; you can
270
- also enter the information interactively if you prefer. When you then execute this command, the large language model
271
- (LLM) associated with your org uses the information to generate the list of jobs that the agent most likely performs.
272
- We recommend that you provide good details for --role, --company-description, etc, so that the LLM can generate the
273
- best and most relevant list of jobs and descriptions. Once generated, you can edit the spec file; for example, you can
274
- remove jobs that don't apply to your agent.
275
-
276
- When your agent spec is ready, you then create the agent in your org by specifying the agent spec file to the
277
- --job-spec flag of the "agent create" CLI command.
278
-
279
- EXAMPLES
280
- Create an agent spec for your default org in the default location and use flags to specify the agent's role and your
281
- company details:
282
-
283
- $ sf agent generate spec-v2 --type customer --role "Assist users in navigating and managing bookings" \
284
- --company-name "Coral Cloud" --company-description "Resort that manages guests and their reservations and \
285
- experiences"
283
+ Use flags, such as --role and --company-description, to provide details about your company and the role that the agent
284
+ plays in your company. If you prefer, you can also be prompted for the information. Upon command execution, the large
285
+ language model (LLM) associated with your org uses the information you provided to generate a list of topics for the
286
+ agent. Because the LLM uses the company and role information to generate the topics, we recommend that you provide
287
+ accurate and specific details so the LLM generates the best and most relevant topics. Once generated, you can edit the
288
+ spec file; for example, you can remove topics that don't apply to your agent or change the description of a particular
289
+ topic.
286
290
 
287
- Create an agent spec by being prompted for role and company details interactively; write the generated file to the
288
- "specs" directory and use the org with alias "my-org":
289
-
290
- $ sf agent generate spec-v2 --output-dir specs --target-org my-org
291
- ```
291
+ You can iterate the spec generation process by using the --spec flag to pass an existing agent spec file to this
292
+ command, and then using the --role, --company-description, etc, flags to refine your agent properties. Iteratively
293
+ improving the description of your agent allows the LLM to generate progressively better topics.
292
294
 
293
- _See code: [src/commands/agent/generate/spec-v2.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/generate/spec-v2.ts)_
295
+ You can also specify a custom prompt template that the agent uses, and ground the prompt template to add context and
296
+ personalization to the agent's prompts.
294
297
 
295
- ## `sf agent generate test-cases`
298
+ When your agent spec is ready, you then create the agent in your org by running the "agent create" CLI command and
299
+ specifying the spec with the --spec flag.
296
300
 
297
- Interactively generate a new Set of AI Evaluation test cases.
301
+ EXAMPLES
302
+ Generate an agent spec in the default location and use flags to specify the agent properties, such as its role and
303
+ your company details; use your default org:
298
304
 
299
- ```
300
- USAGE
301
- $ sf agent generate test-cases [--flags-dir <value>]
305
+ $ sf agent generate spec-v2 --type customer --role "Field customer complaints and manage employee schedules." \
306
+ --company-name "Coral Cloud Resorts" --company-description "Provide customers with exceptional destination \
307
+ activities, unforgettable experiences, and reservation services."
302
308
 
303
- GLOBAL FLAGS
304
- --flags-dir=<value> Import flag values from a directory.
309
+ Generate an agent spec by being prompted for the required agent properties and generate a maxiumum of 5 topics;
310
+ write the generated file to the "specs/resortManagerSpec.yaml" file and use the org with alias "my-org":
305
311
 
306
- DESCRIPTION
307
- Interactively generate a new Set of AI Evaluation test cases.
312
+ $ sf agent generate spec-v2 --max-topics 5 --output-file specs/resortManagerAgent.yaml --target-org my-org
308
313
 
309
- Answer the prompts to generate an AiEvaluationTestSet that will be written to a file. You can then run "sf agent
310
- generate definition" to generate the AiEvaluationDefinition that can be used to evaluate the test set.
314
+ Specify an existing agent spec file called "specs/resortManagerAgent.yaml", and then overwrite it with a new version
315
+ that contains newly AI-generated topics based on the updated role information passed in with the --role flag:
311
316
 
312
- EXAMPLES
313
- $ sf agent generate test-cases
317
+ $ sf agent generate spec-v2 --spec specs/resortManagerAgent.yaml --output-file specs/resortManagerAgent.yaml \
318
+ --role "Field customer complaints, manage employee schedules, and ensure all resort operations are running \
319
+ smoothly" --target-org my-org
314
320
  ```
315
321
 
316
- _See code: [src/commands/agent/generate/test-cases.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/generate/test-cases.ts)_
322
+ _See code: [src/commands/agent/generate/spec-v2.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/generate/spec-v2.ts)_
317
323
 
318
- ## `sf agent generate test-definition`
324
+ ## `sf agent generate test-spec`
319
325
 
320
- Interactively generate a new AI Evaluation Test Definition.
326
+ Interactively generate a specification file for a AI evaluation test.
321
327
 
322
328
  ```
323
329
  USAGE
324
- $ sf agent generate test-definition [--flags-dir <value>]
330
+ $ sf agent generate test-spec [--flags-dir <value>]
325
331
 
326
332
  GLOBAL FLAGS
327
333
  --flags-dir=<value> Import flag values from a directory.
328
334
 
329
335
  DESCRIPTION
330
- Interactively generate a new AI Evaluation Test Definition.
331
-
332
- This command will prompt you for the necessary information to create a new AiEvaluationDefinition. The definition will
333
- be saved to the `aiEvaluationDefinitions` directory in the project.
336
+ Interactively generate a specification file for a AI evaluation test.
334
337
 
335
- You must have the `Bots` and `AiEvaluationTestSets` metadata types present in your project to use this command.
338
+ This command will prompt you for the necessary information to create a new spec file (in yaml format). You can then
339
+ create a new AI evaluation using "sf agent test create --spec <spec-file>".
336
340
 
337
341
  EXAMPLES
338
- $ sf agent generate test-definition
342
+ $ sf agent generate test-spec
339
343
  ```
340
344
 
341
- _See code: [src/commands/agent/generate/test-definition.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/generate/test-definition.ts)_
345
+ _See code: [src/commands/agent/generate/test-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/generate/test-spec.ts)_
342
346
 
343
347
  ## `sf agent preview`
344
348
 
@@ -373,7 +377,7 @@ FLAG DESCRIPTIONS
373
377
  the API name of the agent? (TBD based on agents library)
374
378
  ```
375
379
 
376
- _See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/preview.ts)_
380
+ _See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/preview.ts)_
377
381
 
378
382
  ## `sf agent test cancel`
379
383
 
@@ -410,7 +414,43 @@ EXAMPLES
410
414
  $ sf agent test cancel --job-id 4KBfake0000003F4AQ --target-org my-org
411
415
  ```
412
416
 
413
- _See code: [src/commands/agent/test/cancel.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/test/cancel.ts)_
417
+ _See code: [src/commands/agent/test/cancel.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/test/cancel.ts)_
418
+
419
+ ## `sf agent test create`
420
+
421
+ Summary of a command.
422
+
423
+ ```
424
+ USAGE
425
+ $ sf agent test create -s <value> -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [--preview] [-p]
426
+
427
+ FLAGS
428
+ -o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
429
+ configuration variable is already set.
430
+ -p, --no-prompt Don't prompt for confirmation when overwriting an existing test.
431
+ -s, --spec=<value> (required) Description of a flag.
432
+ --api-version=<value> Override the api version used for api requests made by this command
433
+ --preview Preview the test metadata without deploying to your org.
434
+
435
+ GLOBAL FLAGS
436
+ --flags-dir=<value> Import flag values from a directory.
437
+ --json Format output as json.
438
+
439
+ DESCRIPTION
440
+ Summary of a command.
441
+
442
+ More information about a command. Don't repeat the summary.
443
+
444
+ EXAMPLES
445
+ $ sf agent test create
446
+
447
+ FLAG DESCRIPTIONS
448
+ -s, --spec=<value> Description of a flag.
449
+
450
+ More information about a flag. Don't repeat the summary.
451
+ ```
452
+
453
+ _See code: [src/commands/agent/test/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/test/create.ts)_
414
454
 
415
455
  ## `sf agent test list`
416
456
 
@@ -439,7 +479,7 @@ EXAMPLES
439
479
  $ sf agent test list
440
480
  ```
441
481
 
442
- _See code: [src/commands/agent/test/list.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/test/list.ts)_
482
+ _See code: [src/commands/agent/test/list.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/test/list.ts)_
443
483
 
444
484
  ## `sf agent test results`
445
485
 
@@ -495,7 +535,7 @@ FLAG DESCRIPTIONS
495
535
  test results aren't written.
496
536
  ```
497
537
 
498
- _See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/test/results.ts)_
538
+ _See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/test/results.ts)_
499
539
 
500
540
  ## `sf agent test resume`
501
541
 
@@ -558,7 +598,7 @@ FLAG DESCRIPTIONS
558
598
  test results aren't written.
559
599
  ```
560
600
 
561
- _See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/test/resume.ts)_
601
+ _See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/test/resume.ts)_
562
602
 
563
603
  ## `sf agent test run`
564
604
 
@@ -621,6 +661,6 @@ FLAG DESCRIPTIONS
621
661
  test results aren't written.
622
662
  ```
623
663
 
624
- _See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.10.0/src/commands/agent/test/run.ts)_
664
+ _See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.11.0/src/commands/agent/test/run.ts)_
625
665
 
626
666
  <!-- commandsstop -->
@@ -1,5 +1,5 @@
1
1
  import { SfCommand } from '@salesforce/sf-plugins-core';
2
- export default class AgentGenerateTestDefinition extends SfCommand<void> {
2
+ export default class AgentGenerateTestSpec extends SfCommand<void> {
3
3
  static readonly summary: string;
4
4
  static readonly description: string;
5
5
  static readonly examples: string[];
@@ -4,16 +4,17 @@
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
  */
7
- import { dirname, join } from 'node:path';
8
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
7
+ import { join } from 'node:path';
8
+ import { readFile } from 'node:fs/promises';
9
9
  import { SfCommand } from '@salesforce/sf-plugins-core';
10
- import { Messages } from '@salesforce/core';
10
+ import { Messages, SfError } from '@salesforce/core';
11
+ import { generateTestSpec } from '@salesforce/agents';
11
12
  import { select, input, confirm, checkbox } from '@inquirer/prompts';
12
13
  import { XMLParser } from 'fast-xml-parser';
13
14
  import { theme } from '../../../inquirer-theme.js';
14
15
  import { readDir } from '../../../read-dir.js';
15
16
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
16
- const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.generate.test-cases');
17
+ const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.generate.test-spec');
17
18
  function castArray(value) {
18
19
  return Array.isArray(value) ? value : [value];
19
20
  }
@@ -47,15 +48,15 @@ async function promptForTestCase(genAiPlugins) {
47
48
  },
48
49
  theme,
49
50
  });
50
- const topicSequenceExpectedValue = await select({
51
+ const expectedTopic = await select({
51
52
  message: 'Expected topic',
52
53
  choices: [...topics, customKey],
53
54
  theme,
54
55
  });
55
- if (topicSequenceExpectedValue === customKey) {
56
+ if (expectedTopic === customKey) {
56
57
  return {
57
58
  utterance,
58
- topicSequenceExpectedValue: await input({
59
+ expectedTopic: await input({
59
60
  message: 'Expected topic',
60
61
  validate: (d) => {
61
62
  if (!d.length) {
@@ -66,67 +67,56 @@ async function promptForTestCase(genAiPlugins) {
66
67
  theme,
67
68
  }),
68
69
  // If the user selects OTHER for the topic, then we don't have a genAiPlugin to get actions from so we ask for them for custom input
69
- actionSequenceExpectedValue: await askForOtherActions(),
70
- botRatingExpectedValue: await askForBotRating(),
70
+ expectedActions: await askForOtherActions(),
71
+ expectedOutcome: await askForBotRating(),
71
72
  };
72
73
  }
73
- const genAiPluginXml = await readFile(genAiPlugins[topicSequenceExpectedValue], 'utf-8');
74
+ const genAiPluginXml = await readFile(genAiPlugins[expectedTopic], 'utf-8');
74
75
  const parser = new XMLParser();
75
76
  const parsed = parser.parse(genAiPluginXml);
76
77
  const actions = castArray(parsed.GenAiPlugin.genAiFunctions).map((f) => f.functionName);
77
- let actionSequenceExpectedValue = await checkbox({
78
+ let expectedActions = await checkbox({
78
79
  message: 'Expected action(s)',
79
80
  choices: [...actions, customKey],
80
81
  theme,
81
82
  required: true,
82
83
  });
83
- if (actionSequenceExpectedValue.includes(customKey)) {
84
+ if (expectedActions.includes(customKey)) {
84
85
  const additional = await askForOtherActions();
85
- actionSequenceExpectedValue = [...actionSequenceExpectedValue.filter((a) => a !== customKey), ...additional];
86
+ expectedActions = [...expectedActions.filter((a) => a !== customKey), ...additional];
86
87
  }
87
- const botRatingExpectedValue = await askForBotRating();
88
+ const expectedOutcome = await askForBotRating();
88
89
  return {
89
90
  utterance,
90
- actionSequenceExpectedValue,
91
- botRatingExpectedValue,
92
- topicSequenceExpectedValue,
91
+ expectedActions,
92
+ expectedOutcome,
93
+ expectedTopic,
93
94
  };
94
95
  }
95
- export function constructTestSetXML(testCases) {
96
- const tab = ' ';
97
- let xml = `<?xml version="1.0" encoding="UTF-8"?>\n<AiEvaluationTestSet>\n${tab}<subjectType>AGENT</subjectType>\n`;
98
- testCases.forEach((testCase, i) => {
99
- xml += ` <testCase>
100
- <number>${i + 1}</number>
101
- <inputs>
102
- <utterance>${testCase.utterance}</utterance>
103
- </inputs>
104
- <expectation>
105
- <name>topic_sequence_match</name>
106
- <expectedValue>${testCase.topicSequenceExpectedValue}</expectedValue>
107
- </expectation>
108
- <expectation>
109
- <name>action_sequence_match</name>
110
- <expectedValue>${`[${testCase.actionSequenceExpectedValue.map((v) => `"${v}"`).join(',')}]`}</expectedValue>
111
- </expectation>
112
- <expectation>
113
- <name>bot_response_rating</name>
114
- <expectedValue>${testCase.botRatingExpectedValue}</expectedValue>
115
- </expectation>
116
- </testCase>\n`;
117
- });
118
- xml += '</AiEvaluationTestSet>';
119
- return xml;
120
- }
121
- export default class AgentGenerateTestCases extends SfCommand {
96
+ export default class AgentGenerateTestSpec extends SfCommand {
122
97
  static summary = messages.getMessage('summary');
123
98
  static description = messages.getMessage('description');
124
99
  static examples = messages.getMessages('examples');
125
100
  static enableJsonFlag = false;
126
101
  static state = 'beta';
127
102
  async run() {
128
- const testSetName = await input({
129
- message: 'What is the name of this set of test cases',
103
+ const botsDir = join('force-app', 'main', 'default', 'bots');
104
+ const bots = await readDir(botsDir);
105
+ if (bots.length === 0) {
106
+ throw new SfError(`No agents found in ${botsDir}`, 'NoAgentsFoundError');
107
+ }
108
+ const subjectType = await select({
109
+ message: 'What are you testing',
110
+ choices: ['AGENT'],
111
+ theme,
112
+ });
113
+ const subjectName = await select({
114
+ message: 'Select the Agent to test',
115
+ choices: bots,
116
+ theme,
117
+ });
118
+ const name = await input({
119
+ message: 'Enter a name for the test definition',
130
120
  validate(d) {
131
121
  // ensure that it's not empty
132
122
  if (!d.length) {
@@ -140,6 +130,11 @@ export default class AgentGenerateTestCases extends SfCommand {
140
130
  // }
141
131
  // return true;
142
132
  },
133
+ theme,
134
+ });
135
+ const description = await input({
136
+ message: 'Enter a description for test definition (optional)',
137
+ theme,
143
138
  });
144
139
  const genAiPluginDir = join('force-app', 'main', 'default', 'genAiPlugins');
145
140
  const genAiPlugins = Object.fromEntries((await readDir(genAiPluginDir)).map((genAiPlugin) => [
@@ -157,11 +152,15 @@ export default class AgentGenerateTestCases extends SfCommand {
157
152
  message: 'Would you like to add another test case',
158
153
  default: true,
159
154
  }));
160
- const testSetPath = join('force-app', 'main', 'default', 'aiEvaluationTestSets', `${testSetName}.aiEvaluationTestSet-meta.xml`);
161
- await mkdir(dirname(testSetPath), { recursive: true });
162
155
  this.log();
163
- this.log(`Created ${testSetPath}`);
164
- await writeFile(testSetPath, constructTestSetXML(testCases));
156
+ await generateTestSpec({
157
+ name,
158
+ description,
159
+ subjectType,
160
+ subjectName,
161
+ testCases,
162
+ }, `${name}-test-spec.yaml`);
163
+ this.log(`Created ${name}-test-spec.yaml`);
165
164
  }
166
165
  }
167
- //# sourceMappingURL=test-cases.js.map
166
+ //# sourceMappingURL=test-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-spec.js","sourceRoot":"","sources":["../../../../src/commands/agent/generate/test-spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC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C,SAAS,4CAA4C;QACpD,MAAM,OAAO,CAAC;YACZ,OAAO,EAAE,yCAAyC;YAClD,OAAO,EAAE,IAAI;SACd,CAAC,EACF;QAEF,IAAI,CAAC,GAAG,EAAE,CAAC;QAEX,MAAM,gBAAgB,CACpB;YACE,IAAI;YACJ,WAAW;YACX,WAAW;YACX,WAAW;YACX,SAAS;SACV,EACD,GAAG,IAAI,iBAAiB,CACzB,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,WAAW,IAAI,iBAAiB,CAAC,CAAC;IAC7C,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ import { SfError } from '@salesforce/core';
3
+ import { CLIError } from '@oclif/core/errors';
4
+ export type AgentTestCreateResult = {
5
+ path: string;
6
+ contents: string;
7
+ };
8
+ export default class AgentTestCreate extends SfCommand<AgentTestCreateResult> {
9
+ static readonly summary: string;
10
+ static readonly description: string;
11
+ static readonly examples: string[];
12
+ static readonly state = "beta";
13
+ static readonly flags: {
14
+ spec: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
+ 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ preview: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ 'no-prompt': import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
+ };
20
+ private mso?;
21
+ run(): Promise<AgentTestCreateResult>;
22
+ protected catch(error: Error | SfError | CLIError): Promise<never>;
23
+ }