@salesforce/plugin-agent 1.5.1 → 1.6.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 +105 -33
- package/lib/commands/agent/create.js +0 -1
- package/lib/commands/agent/create.js.map +1 -1
- package/lib/commands/agent/generate/definition.d.ts +9 -0
- package/lib/commands/agent/generate/definition.js +76 -0
- package/lib/commands/agent/generate/definition.js.map +1 -0
- package/lib/commands/agent/generate/spec.js +3 -6
- package/lib/commands/agent/generate/spec.js.map +1 -1
- package/lib/commands/agent/generate/testset.d.ts +17 -0
- package/lib/commands/agent/generate/testset.js +101 -0
- package/lib/commands/agent/generate/testset.js.map +1 -0
- package/lib/inquirer-theme.d.ts +5 -0
- package/lib/inquirer-theme.js +11 -0
- package/lib/inquirer-theme.js.map +1 -0
- package/messages/agent.create.md +9 -9
- package/messages/agent.generate.definition.md +13 -0
- package/messages/agent.generate.spec.md +19 -11
- package/messages/agent.generate.testset.md +11 -0
- package/npm-shrinkwrap.json +157 -7
- package/oclif.lock +36 -28
- package/oclif.manifest.json +107 -17
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -62,7 +62,9 @@ sf plugins
|
|
|
62
62
|
<!-- commands -->
|
|
63
63
|
|
|
64
64
|
- [`sf agent create`](#sf-agent-create)
|
|
65
|
+
- [`sf agent generate definition`](#sf-agent-generate-definition)
|
|
65
66
|
- [`sf agent generate spec`](#sf-agent-generate-spec)
|
|
67
|
+
- [`sf agent generate testset`](#sf-agent-generate-testset)
|
|
66
68
|
- [`sf agent preview`](#sf-agent-preview)
|
|
67
69
|
- [`sf agent test cancel`](#sf-agent-test-cancel)
|
|
68
70
|
- [`sf agent test results`](#sf-agent-test-results)
|
|
@@ -71,15 +73,15 @@ sf plugins
|
|
|
71
73
|
|
|
72
74
|
## `sf agent create`
|
|
73
75
|
|
|
74
|
-
Create an
|
|
76
|
+
Create an agent in your org from a local agent spec file.
|
|
75
77
|
|
|
76
78
|
```
|
|
77
79
|
USAGE
|
|
78
80
|
$ sf agent create -o <value> -f <value> -n <value> [--json] [--flags-dir <value>] [--api-version <value>]
|
|
79
81
|
|
|
80
82
|
FLAGS
|
|
81
|
-
-f, --job-spec=<value> (required)
|
|
82
|
-
-n, --name=<value> (required)
|
|
83
|
+
-f, --job-spec=<value> (required) Path to an agent spec file.
|
|
84
|
+
-n, --name=<value> (required) API name of the new agent.
|
|
83
85
|
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
84
86
|
configuration variable is already set.
|
|
85
87
|
--api-version=<value> Override the api version used for api requests made by this command
|
|
@@ -89,27 +91,56 @@ GLOBAL FLAGS
|
|
|
89
91
|
--json Format output as json.
|
|
90
92
|
|
|
91
93
|
DESCRIPTION
|
|
92
|
-
Create an
|
|
94
|
+
Create an agent in your org from a local agent spec file.
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
To generate an agent spec file, run the "agent generate spec" CLI command, which outputs a JSON file with the list of
|
|
97
|
+
jobs and descriptions that the new agent can perform. Then specify this generated spec file to the --job-spec flag of
|
|
98
|
+
this command, along with the name of the new agent.
|
|
99
|
+
|
|
100
|
+
When this command finishes, your org contains the new agent, which you can then edit in the Agent Builder UI. The new
|
|
101
|
+
agent already has a list of topics and actions that were automatically created from the list of jobs in the provided
|
|
102
|
+
agent spec file. This command also retrieves all the metadata files associated with the new agent to your local DX
|
|
103
|
+
project.
|
|
104
|
+
|
|
105
|
+
To open the new agent in your org's Agent Builder UI, run this command: "sf org open agent --name
|
|
106
|
+
<api-name-of-your-agent>".
|
|
95
107
|
|
|
96
108
|
EXAMPLES
|
|
97
|
-
Create an
|
|
109
|
+
Create an agent called "CustomerSupportAgent" in an org with alias "my-org" using the specified agent spec file:
|
|
98
110
|
|
|
99
|
-
$ sf agent create --spec ./
|
|
111
|
+
$ sf agent create --name CustomerSupportAgent --job-spec ./config/agentSpec.json --target-org my-org
|
|
112
|
+
```
|
|
100
113
|
|
|
101
|
-
|
|
102
|
-
|
|
114
|
+
_See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.6.0/src/commands/agent/create.ts)_
|
|
115
|
+
|
|
116
|
+
## `sf agent generate definition`
|
|
117
|
+
|
|
118
|
+
Interactively generate a new AiEvaluationDefinition.
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
USAGE
|
|
122
|
+
$ sf agent generate definition [--flags-dir <value>]
|
|
103
123
|
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
GLOBAL FLAGS
|
|
125
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
126
|
+
|
|
127
|
+
DESCRIPTION
|
|
128
|
+
Interactively generate a new AiEvaluationDefinition.
|
|
129
|
+
|
|
130
|
+
This command will prompt you for the necessary information to create a new AiEvaluationDefinition. The definition will
|
|
131
|
+
be saved to the `aiEvaluationDefinitions` directory in the project.
|
|
132
|
+
|
|
133
|
+
You must have the `Bots` and `AiEvaluationTestSets` metadata types present in your project to use this command.
|
|
134
|
+
|
|
135
|
+
EXAMPLES
|
|
136
|
+
$ sf agent generate definition
|
|
106
137
|
```
|
|
107
138
|
|
|
108
|
-
_See code: [src/commands/agent/
|
|
139
|
+
_See code: [src/commands/agent/generate/definition.ts](https://github.com/salesforcecli/plugin-agent/blob/1.6.0/src/commands/agent/generate/definition.ts)_
|
|
109
140
|
|
|
110
141
|
## `sf agent generate spec`
|
|
111
142
|
|
|
112
|
-
|
|
143
|
+
Generate an agent spec, which is the list of jobs that the agent performs.
|
|
113
144
|
|
|
114
145
|
```
|
|
115
146
|
USAGE
|
|
@@ -118,37 +149,78 @@ USAGE
|
|
|
118
149
|
[-f <value>]
|
|
119
150
|
|
|
120
151
|
FLAGS
|
|
121
|
-
-d, --output-dir=<value> [default: config]
|
|
122
|
-
|
|
123
|
-
-f, --file-name=<value> [default: agentSpec.json]
|
|
152
|
+
-d, --output-dir=<value> [default: config] Directory where the agent spec file is written; can be an
|
|
153
|
+
absolute or relative path.
|
|
154
|
+
-f, --file-name=<value> [default: agentSpec.json] Name of the generated agent spec file.
|
|
124
155
|
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
125
156
|
configuration variable is already set.
|
|
126
|
-
-t, --type=<option>
|
|
157
|
+
-t, --type=<option> Type of agent to create.
|
|
127
158
|
<options: customer|internal>
|
|
128
159
|
--api-version=<value> Override the api version used for api requests made by this command
|
|
129
|
-
--company-description=<value>
|
|
130
|
-
|
|
131
|
-
--company-
|
|
132
|
-
--
|
|
133
|
-
--role=<value> The role of the agent.
|
|
160
|
+
--company-description=<value> Description of your company.
|
|
161
|
+
--company-name=<value> Name of your company.
|
|
162
|
+
--company-website=<value> Website URL of your company.
|
|
163
|
+
--role=<value> Role of the agent.
|
|
134
164
|
|
|
135
165
|
GLOBAL FLAGS
|
|
136
166
|
--flags-dir=<value> Import flag values from a directory.
|
|
137
167
|
--json Format output as json.
|
|
138
168
|
|
|
139
169
|
DESCRIPTION
|
|
140
|
-
|
|
170
|
+
Generate an agent spec, which is the list of jobs that the agent performs.
|
|
171
|
+
|
|
172
|
+
When using Salesforce CLI to create an agent in your org, the first step is to generate the local JSON-formatted agent
|
|
173
|
+
spec file with this command.
|
|
141
174
|
|
|
142
|
-
|
|
175
|
+
An agent spec is a list of jobs and descriptions that capture what the agent can do. Use flags such as --role and
|
|
176
|
+
--company-description to provide details about your company and the role that the agent plays in your company; you can
|
|
177
|
+
also enter the information interactively if you prefer. When you then execute this command, the large language model
|
|
178
|
+
(LLM) associated with your org uses the information to generate the list of jobs that the agent most likely performs.
|
|
179
|
+
We recommend that you provide good details for --role, --company-description, etc, so that the LLM can generate the
|
|
180
|
+
best and most relevant list of jobs and descriptions. Once generated, you can edit the spec file; for example, you can
|
|
181
|
+
remove jobs that don't apply to your agent.
|
|
182
|
+
|
|
183
|
+
When your agent spec is ready, you then create the agent in your org by specifying the agent spec file to the
|
|
184
|
+
--job-spec flag of the "agent create" CLI command.
|
|
143
185
|
|
|
144
186
|
EXAMPLES
|
|
145
|
-
Create an
|
|
187
|
+
Create an agent spec for your default org in the default location and use flags to specify the agent's role and your
|
|
188
|
+
company details:
|
|
189
|
+
|
|
190
|
+
$ sf agent generate spec --type customer --role "Assist users in navigating and managing bookings" \
|
|
191
|
+
--company-name "Coral Cloud" --company-description "Resort that manages guests and their reservations and \
|
|
192
|
+
experiences"
|
|
193
|
+
|
|
194
|
+
Create an agent spec by being prompted for role and company details interactively; write the generated file to the
|
|
195
|
+
"specs" directory and use the org with alias "my-org":
|
|
196
|
+
|
|
197
|
+
$ sf agent generate spec --output-dir specs --target-org my-org
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
_See code: [src/commands/agent/generate/spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.6.0/src/commands/agent/generate/spec.ts)_
|
|
201
|
+
|
|
202
|
+
## `sf agent generate testset`
|
|
203
|
+
|
|
204
|
+
Interactively generate an AiEvaluationTestSet.
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
USAGE
|
|
208
|
+
$ sf agent generate testset [--flags-dir <value>]
|
|
209
|
+
|
|
210
|
+
GLOBAL FLAGS
|
|
211
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
146
212
|
|
|
147
|
-
|
|
148
|
-
|
|
213
|
+
DESCRIPTION
|
|
214
|
+
Interactively generate an AiEvaluationTestSet.
|
|
215
|
+
|
|
216
|
+
Answer the prompts to generate an AiEvaluationTestSet that will be written to a file. You can then run "sf agent
|
|
217
|
+
generate definition" to generate the AiEvaluationDefinition that can be used to evaluate the test set.
|
|
218
|
+
|
|
219
|
+
EXAMPLES
|
|
220
|
+
$ sf agent generate testset
|
|
149
221
|
```
|
|
150
222
|
|
|
151
|
-
_See code: [src/commands/agent/generate/
|
|
223
|
+
_See code: [src/commands/agent/generate/testset.ts](https://github.com/salesforcecli/plugin-agent/blob/1.6.0/src/commands/agent/generate/testset.ts)_
|
|
152
224
|
|
|
153
225
|
## `sf agent preview`
|
|
154
226
|
|
|
@@ -183,7 +255,7 @@ FLAG DESCRIPTIONS
|
|
|
183
255
|
the API name of the agent? (TBD based on agents library)
|
|
184
256
|
```
|
|
185
257
|
|
|
186
|
-
_See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.
|
|
258
|
+
_See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.6.0/src/commands/agent/preview.ts)_
|
|
187
259
|
|
|
188
260
|
## `sf agent test cancel`
|
|
189
261
|
|
|
@@ -215,7 +287,7 @@ EXAMPLES
|
|
|
215
287
|
$ sf agent test cancel --job-id AiEvalId
|
|
216
288
|
```
|
|
217
289
|
|
|
218
|
-
_See code: [src/commands/agent/test/cancel.ts](https://github.com/salesforcecli/plugin-agent/blob/1.
|
|
290
|
+
_See code: [src/commands/agent/test/cancel.ts](https://github.com/salesforcecli/plugin-agent/blob/1.6.0/src/commands/agent/test/cancel.ts)_
|
|
219
291
|
|
|
220
292
|
## `sf agent test results`
|
|
221
293
|
|
|
@@ -254,7 +326,7 @@ FLAG DESCRIPTIONS
|
|
|
254
326
|
results will not be written.
|
|
255
327
|
```
|
|
256
328
|
|
|
257
|
-
_See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.
|
|
329
|
+
_See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.6.0/src/commands/agent/test/results.ts)_
|
|
258
330
|
|
|
259
331
|
## `sf agent test resume`
|
|
260
332
|
|
|
@@ -302,7 +374,7 @@ FLAG DESCRIPTIONS
|
|
|
302
374
|
If the command continues to run after the wait period, the CLI returns control of the terminal window to you.
|
|
303
375
|
```
|
|
304
376
|
|
|
305
|
-
_See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.
|
|
377
|
+
_See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.6.0/src/commands/agent/test/resume.ts)_
|
|
306
378
|
|
|
307
379
|
## `sf agent test run`
|
|
308
380
|
|
|
@@ -353,6 +425,6 @@ FLAG DESCRIPTIONS
|
|
|
353
425
|
If the command continues to run after the wait period, the CLI returns control of the terminal window to you.
|
|
354
426
|
```
|
|
355
427
|
|
|
356
|
-
_See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.
|
|
428
|
+
_See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.6.0/src/commands/agent/test/run.ts)_
|
|
357
429
|
|
|
358
430
|
<!-- commandsstop -->
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/agent/create.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAqB,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAE1F,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,cAAc,CAAC,CAAC;AAOnF,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAA4B;IAC5D,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,CAAU,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CAAC,IAAI,EAAE,CAAC,oCAAoC,CAAC,CAAC;QAE/G,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;IAC1C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export default class AgentGenerateDefinition extends SfCommand<void> {
|
|
3
|
+
static readonly summary: string;
|
|
4
|
+
static readonly description: string;
|
|
5
|
+
static readonly examples: string[];
|
|
6
|
+
static readonly enableJsonFlag = false;
|
|
7
|
+
static readonly state = "beta";
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
import { mkdir, readdir, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
10
|
+
import { Messages, SfError } from '@salesforce/core';
|
|
11
|
+
import select from '@inquirer/select';
|
|
12
|
+
import input from '@inquirer/input';
|
|
13
|
+
import { theme } from '../../../inquirer-theme.js';
|
|
14
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
15
|
+
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.generate.definition');
|
|
16
|
+
export default class AgentGenerateDefinition extends SfCommand {
|
|
17
|
+
static summary = messages.getMessage('summary');
|
|
18
|
+
static description = messages.getMessage('description');
|
|
19
|
+
static examples = messages.getMessages('examples');
|
|
20
|
+
static enableJsonFlag = false;
|
|
21
|
+
static state = 'beta';
|
|
22
|
+
async run() {
|
|
23
|
+
const testSetDir = join('force-app', 'main', 'default', 'aiEvaluationTestSets');
|
|
24
|
+
const testSets = (await readdir(testSetDir)).map((testSet) => testSet.replace('.xml', ''));
|
|
25
|
+
if (testSets.length === 0) {
|
|
26
|
+
throw new SfError(`No test sets found in ${testSetDir}`, 'NoTestSetsFoundError', [
|
|
27
|
+
'Run the "sf agent generate testset" command to create a test set',
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
const botsDir = join('force-app', 'main', 'default', 'bots');
|
|
31
|
+
const bots = await readdir(botsDir);
|
|
32
|
+
if (bots.length === 0) {
|
|
33
|
+
throw new SfError(`No bots found in ${botsDir}`, 'NoBotsFoundError');
|
|
34
|
+
}
|
|
35
|
+
const testSet = await select({
|
|
36
|
+
message: 'Select the AiEvaluationTestSet to use',
|
|
37
|
+
choices: testSets,
|
|
38
|
+
theme,
|
|
39
|
+
});
|
|
40
|
+
const bot = await select({
|
|
41
|
+
message: 'Select the Bot to run the tests against',
|
|
42
|
+
choices: bots,
|
|
43
|
+
theme,
|
|
44
|
+
});
|
|
45
|
+
const name = await input({
|
|
46
|
+
message: 'Enter a name for the AiEvaluationDefinition',
|
|
47
|
+
validate: (i) => (i.length > 0 ? true : 'Name cannot be empty'),
|
|
48
|
+
theme,
|
|
49
|
+
});
|
|
50
|
+
const description = await input({
|
|
51
|
+
message: 'Enter a description for the AiEvaluationDefinition',
|
|
52
|
+
theme,
|
|
53
|
+
});
|
|
54
|
+
const subjectType = await select({
|
|
55
|
+
message: 'Select the type for the AiEvaluationDefinition',
|
|
56
|
+
choices: ['AGENT'],
|
|
57
|
+
theme,
|
|
58
|
+
});
|
|
59
|
+
this.log(`Generating AiEvaluationDefinition for ${bot} using ${testSet} AiEvaluationTestSet`);
|
|
60
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
61
|
+
<AiEvaluationDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
62
|
+
${description ? `<description>${description}</description>` : ''}
|
|
63
|
+
<name>${name}</name>
|
|
64
|
+
<subjectType>${subjectType}</subjectType>
|
|
65
|
+
<subjectName>${bot}</subjectName>
|
|
66
|
+
<testSetName>${testSet}</testSetName>
|
|
67
|
+
</AiEvaluationDefinition>`;
|
|
68
|
+
// remove all empty lines
|
|
69
|
+
const cleanedXml = xml.replace(/^\s*[\r\n]/gm, '');
|
|
70
|
+
const definitionPath = join('force-app', 'main', 'default', 'aiEvaluationDefinitions', `${name}.xml`);
|
|
71
|
+
await mkdir(dirname(definitionPath), { recursive: true });
|
|
72
|
+
this.log(`Writing AiEvaluationDefinition to ${definitionPath}`);
|
|
73
|
+
await writeFile(definitionPath, cleanedXml);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../../src/commands/agent/generate/definition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,2BAA2B,CAAC,CAAC;AAEhG,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,SAAe;IAC3D,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,M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|
14
14
|
import figures from '@inquirer/figures';
|
|
15
15
|
import { Agent } from '@salesforce/agents';
|
|
16
|
+
import { theme } from '../../../inquirer-theme.js';
|
|
16
17
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
17
18
|
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.generate.spec');
|
|
18
19
|
const FLAGGABLE_PROMPTS = {
|
|
@@ -154,17 +155,13 @@ export default class AgentCreateSpec extends SfCommand {
|
|
|
154
155
|
return select({
|
|
155
156
|
choices: flagDef.options.map((o) => ({ name: o, value: o })),
|
|
156
157
|
message,
|
|
157
|
-
theme
|
|
158
|
-
prefix: { idle: ansis.blueBright('?') },
|
|
159
|
-
},
|
|
158
|
+
theme,
|
|
160
159
|
});
|
|
161
160
|
}
|
|
162
161
|
return inquirerInput({
|
|
163
162
|
message,
|
|
164
163
|
validate: flagDef.validate,
|
|
165
|
-
theme
|
|
166
|
-
prefix: { idle: ansis.blueBright('?') },
|
|
167
|
-
},
|
|
164
|
+
theme,
|
|
168
165
|
});
|
|
169
166
|
}
|
|
170
167
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../src/commands/agent/generate/spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAa,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,KAAK,EAA8B,MAAM,oBAAoB,CAAC;
|
|
1
|
+
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Aa,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAE7F,OAAO,aAAa,CAAC;QACvB,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,MAAM,CAAC;gBACZ,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC5D,OAAO;gBACP,KAAK;aACN,CAAC,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC;YACnB,OAAO;YACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK;SACN,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
type ExpectationType = 'topic_sequence_match' | 'action_sequence_match' | 'bot_response_rating';
|
|
3
|
+
export type TestSetInputs = {
|
|
4
|
+
utterance: string;
|
|
5
|
+
expectationType: ExpectationType;
|
|
6
|
+
expectedValue: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function constructTestSetXML(testCases: TestSetInputs[]): string;
|
|
9
|
+
export default class AgentGenerateTestset extends SfCommand<void> {
|
|
10
|
+
static readonly summary: string;
|
|
11
|
+
static readonly description: string;
|
|
12
|
+
static readonly examples: string[];
|
|
13
|
+
static readonly enableJsonFlag = false;
|
|
14
|
+
static readonly state = "beta";
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
10
|
+
import { Messages } from '@salesforce/core';
|
|
11
|
+
import input from '@inquirer/input';
|
|
12
|
+
import select from '@inquirer/select';
|
|
13
|
+
import confirm from '@inquirer/confirm';
|
|
14
|
+
import { theme } from '../../../inquirer-theme.js';
|
|
15
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
16
|
+
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.generate.testset');
|
|
17
|
+
async function promptForTestCase() {
|
|
18
|
+
const utterance = await input({
|
|
19
|
+
message: 'What utterance would you like to test?',
|
|
20
|
+
validate: (d) => d.length > 0 || 'utterance cannot be empty',
|
|
21
|
+
theme,
|
|
22
|
+
});
|
|
23
|
+
const expectationType = await select({
|
|
24
|
+
message: 'What type of expectation would you like to test for the utterance?',
|
|
25
|
+
choices: ['topic_sequence_match', 'action_sequence_match', 'bot_response_rating'],
|
|
26
|
+
theme,
|
|
27
|
+
});
|
|
28
|
+
const expectedValue = await input({
|
|
29
|
+
message: 'What is the expected value for the expectation?',
|
|
30
|
+
validate: (d) => {
|
|
31
|
+
if (!d.length) {
|
|
32
|
+
return 'expected value cannot be empty';
|
|
33
|
+
}
|
|
34
|
+
if (expectationType === 'action_sequence_match') {
|
|
35
|
+
return d.split(',').length > 1 || 'expected value must be a comma-separated list of actions';
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
},
|
|
39
|
+
theme,
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
utterance,
|
|
43
|
+
expectationType,
|
|
44
|
+
expectedValue,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function constructTestSetXML(testCases) {
|
|
48
|
+
const tab = ' ';
|
|
49
|
+
let xml = `<?xml version="1.0" encoding="UTF-8"?>\n<AiEvaluationTestSet>\n${tab}<subjectType>AGENT</subjectType>\n`;
|
|
50
|
+
testCases.forEach((testCase, i) => {
|
|
51
|
+
const expectedValue = testCase.expectationType === 'action_sequence_match'
|
|
52
|
+
? `[${testCase.expectedValue
|
|
53
|
+
.split(',')
|
|
54
|
+
.map((v) => `"${v}"`)
|
|
55
|
+
.join(',')}]`
|
|
56
|
+
: testCase.expectedValue;
|
|
57
|
+
xml += ` <testCase>
|
|
58
|
+
<number>${i + 1}</number>
|
|
59
|
+
<inputs>
|
|
60
|
+
<utterance>${testCase.utterance}</utterance>
|
|
61
|
+
</inputs>
|
|
62
|
+
<expectations>
|
|
63
|
+
<expectation>
|
|
64
|
+
<name>${testCase.expectationType}</name>
|
|
65
|
+
<expectedValue>${expectedValue}</expectedValue>
|
|
66
|
+
</expectation>
|
|
67
|
+
</expectations>
|
|
68
|
+
</testCase>\n`;
|
|
69
|
+
});
|
|
70
|
+
xml += '</AiEvaluationTestSet>';
|
|
71
|
+
return xml;
|
|
72
|
+
}
|
|
73
|
+
export default class AgentGenerateTestset extends SfCommand {
|
|
74
|
+
static summary = messages.getMessage('summary');
|
|
75
|
+
static description = messages.getMessage('description');
|
|
76
|
+
static examples = messages.getMessages('examples');
|
|
77
|
+
static enableJsonFlag = false;
|
|
78
|
+
static state = 'beta';
|
|
79
|
+
async run() {
|
|
80
|
+
const testSetName = await input({
|
|
81
|
+
message: 'What is the name of the test set?',
|
|
82
|
+
});
|
|
83
|
+
const testCases = [];
|
|
84
|
+
do {
|
|
85
|
+
this.log();
|
|
86
|
+
this.styledHeader(`Adding test case #${testCases.length + 1}`);
|
|
87
|
+
// eslint-disable-next-line no-await-in-loop
|
|
88
|
+
testCases.push(await promptForTestCase());
|
|
89
|
+
} while ( // eslint-disable-next-line no-await-in-loop
|
|
90
|
+
await confirm({
|
|
91
|
+
message: 'Would you like to add another test case?',
|
|
92
|
+
default: true,
|
|
93
|
+
}));
|
|
94
|
+
const testSetPath = join('force-app', 'main', 'default', 'aiEvaluationTestsets', `${testSetName}.xml`);
|
|
95
|
+
await mkdir(dirname(testSetPath), { recursive: true });
|
|
96
|
+
this.log();
|
|
97
|
+
this.log(`Writing new AiEvaluationTestSet to ${testSetPath}`);
|
|
98
|
+
await writeFile(testSetPath, constructTestSetXML(testCases));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=testset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testset.js","sourceRoot":"","sources":["../../../../src/commands/agent/generate/testset.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,wBAAwB,CAAC,CAAC;AAU7F,KAAK,UAAU,iBAAiB;IAC9B,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC;QAC5B,OAAO,EAAE,wCAAwC;QACjD,QAAQ,EAAE,CAAC,CAAS,EAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,2BAA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,CAAC;QACX,IAAI,CAAC,GAAG,CAAC,sCAAsC,WAAW,EAAE,CAAC,CAAC;QAC9D,MAAM,SAAS,CAAC,WAAW,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import ansis from 'ansis';
|
|
8
|
+
export const theme = {
|
|
9
|
+
prefix: { idle: ansis.blueBright('?') },
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=inquirer-theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inquirer-theme.js","sourceRoot":"","sources":["../src/inquirer-theme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;CACxC,CAAC"}
|
package/messages/agent.create.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
# summary
|
|
2
2
|
|
|
3
|
-
Create an
|
|
3
|
+
Create an agent in your org from a local agent spec file.
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
To generate an agent spec file, run the "agent generate spec" CLI command, which outputs a JSON file with the list of jobs and descriptions that the new agent can perform. Then specify this generated spec file to the --job-spec flag of this command, along with the name of the new agent.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
When this command finishes, your org contains the new agent, which you can then edit in the Agent Builder UI. The new agent already has a list of topics and actions that were automatically created from the list of jobs in the provided agent spec file. This command also retrieves all the metadata files associated with the new agent to your local DX project.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
To open the new agent in your org's Agent Builder UI, run this command: "sf org open agent --name <api-name-of-your-agent>".
|
|
12
12
|
|
|
13
|
-
# flags.job-spec.
|
|
13
|
+
# flags.job-spec.summary
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Path to an agent spec file.
|
|
16
16
|
|
|
17
17
|
# flags.name.summary
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
API name of the new agent.
|
|
20
20
|
|
|
21
21
|
# examples
|
|
22
22
|
|
|
23
|
-
- Create an
|
|
23
|
+
- Create an agent called "CustomerSupportAgent" in an org with alias "my-org" using the specified agent spec file:
|
|
24
24
|
|
|
25
|
-
<%= config.bin %> <%= command.id %> --spec ./
|
|
25
|
+
<%= config.bin %> <%= command.id %> --name CustomerSupportAgent --job-spec ./config/agentSpec.json --target-org my-org
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Interactively generate a new AiEvaluationDefinition.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
This command will prompt you for the necessary information to create a new AiEvaluationDefinition. The definition will be saved to the `aiEvaluationDefinitions` directory in the project.
|
|
8
|
+
|
|
9
|
+
You must have the `Bots` and `AiEvaluationTestSets` metadata types present in your project to use this command.
|
|
10
|
+
|
|
11
|
+
# examples
|
|
12
|
+
|
|
13
|
+
- <%= config.bin %> <%= command.id %>
|