@salesforce/plugin-agent 1.10.0 → 1.11.1
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 +136 -93
- package/lib/commands/agent/create-v2.d.ts +3 -7
- package/lib/commands/agent/create-v2.js +31 -75
- package/lib/commands/agent/create-v2.js.map +1 -1
- package/lib/commands/agent/generate/spec-v2.d.ts +64 -1
- package/lib/commands/agent/generate/spec-v2.js +170 -19
- package/lib/commands/agent/generate/spec-v2.js.map +1 -1
- package/lib/commands/agent/generate/{test-definition.d.ts → test-spec.d.ts} +1 -1
- package/lib/commands/agent/generate/{test-cases.js → test-spec.js} +50 -51
- package/lib/commands/agent/generate/test-spec.js.map +1 -0
- package/lib/commands/agent/test/create.d.ts +23 -0
- package/lib/commands/agent/test/create.js +95 -0
- package/lib/commands/agent/test/create.js.map +1 -0
- package/lib/flags.d.ts +1 -28
- package/lib/flags.js +3 -41
- package/lib/flags.js.map +1 -1
- package/messages/agent.create-v2.md +19 -25
- package/messages/agent.generate.spec-v2.md +89 -13
- package/messages/agent.generate.test-spec.md +11 -0
- package/messages/agent.test.create.md +27 -0
- package/messages/shared.md +0 -20
- package/npm-shrinkwrap.json +280 -266
- package/oclif.lock +64 -17
- package/oclif.manifest.json +164 -115
- package/package.json +8 -4
- package/schemas/agent-create__v2.json +129 -5
- package/schemas/agent-test-create.json +19 -0
- package/schemas/agent-test-results.json +14 -17
- package/lib/commands/agent/generate/test-cases.d.ts +0 -16
- package/lib/commands/agent/generate/test-cases.js.map +0 -1
- package/lib/commands/agent/generate/test-definition.js +0 -76
- package/lib/commands/agent/generate/test-definition.js.map +0 -1
- package/messages/agent.generate.test-cases.md +0 -11
- package/messages/agent.generate.test-definition.md +0 -13
|
@@ -5,6 +5,64 @@ export type AgentCreateSpecResult = {
|
|
|
5
5
|
errorMessage?: string;
|
|
6
6
|
specPath?: string;
|
|
7
7
|
} & AgentJobSpecV2;
|
|
8
|
+
export type AgentSpecFileContents = AgentJobSpecV2 & {
|
|
9
|
+
agentUser?: string;
|
|
10
|
+
enrichLogs?: boolean;
|
|
11
|
+
tone?: 'casual' | 'formal' | 'neutral';
|
|
12
|
+
primaryLanguage?: 'en_US';
|
|
13
|
+
};
|
|
14
|
+
export declare const FLAGGABLE_PROMPTS: {
|
|
15
|
+
type: {
|
|
16
|
+
message: string;
|
|
17
|
+
validate: (d: string) => boolean | string;
|
|
18
|
+
char: "t";
|
|
19
|
+
options: string[];
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
role: {
|
|
23
|
+
message: string;
|
|
24
|
+
validate: (d: string) => boolean | string;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
'company-name': {
|
|
28
|
+
message: string;
|
|
29
|
+
validate: (d: string) => boolean | string;
|
|
30
|
+
required: true;
|
|
31
|
+
};
|
|
32
|
+
'company-description': {
|
|
33
|
+
message: string;
|
|
34
|
+
validate: (d: string) => boolean | string;
|
|
35
|
+
required: true;
|
|
36
|
+
};
|
|
37
|
+
'company-website': {
|
|
38
|
+
message: string;
|
|
39
|
+
validate: (d: string) => boolean | string;
|
|
40
|
+
};
|
|
41
|
+
'max-topics': {
|
|
42
|
+
message: string;
|
|
43
|
+
promptMessage: string;
|
|
44
|
+
validate: () => boolean | string;
|
|
45
|
+
};
|
|
46
|
+
'agent-user': {
|
|
47
|
+
message: string;
|
|
48
|
+
promptMessage: string;
|
|
49
|
+
validate: () => boolean | string;
|
|
50
|
+
};
|
|
51
|
+
'enrich-logs': {
|
|
52
|
+
message: string;
|
|
53
|
+
promptMessage: string;
|
|
54
|
+
validate: () => boolean | string;
|
|
55
|
+
options: string[];
|
|
56
|
+
default: string;
|
|
57
|
+
};
|
|
58
|
+
tone: {
|
|
59
|
+
message: string;
|
|
60
|
+
promptMessage: string;
|
|
61
|
+
validate: () => boolean | string;
|
|
62
|
+
options: string[];
|
|
63
|
+
default: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
8
66
|
export default class AgentCreateSpecV2 extends SfCommand<AgentCreateSpecResult> {
|
|
9
67
|
static readonly summary: string;
|
|
10
68
|
static readonly description: string;
|
|
@@ -14,14 +72,19 @@ export default class AgentCreateSpecV2 extends SfCommand<AgentCreateSpecResult>
|
|
|
14
72
|
static readonly flags: {
|
|
15
73
|
spec: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
74
|
'output-file': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
-
'
|
|
75
|
+
'full-interview': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
76
|
'prompt-template': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
77
|
'grounding-context': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
78
|
+
'no-prompt': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
79
|
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
80
|
role: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
81
|
"company-name": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
82
|
"company-description": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
83
|
"company-website": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
84
|
+
"max-topics": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
85
|
+
"agent-user": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
86
|
+
"enrich-logs": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
87
|
+
tone: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
88
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
89
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
90
|
};
|
|
@@ -5,14 +5,88 @@
|
|
|
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
7
|
import { join, resolve, dirname } from 'node:path';
|
|
8
|
-
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
9
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
9
|
+
import { SfCommand, Flags, prompts } from '@salesforce/sf-plugins-core';
|
|
10
10
|
import { Messages } from '@salesforce/core';
|
|
11
11
|
import YAML from 'yaml';
|
|
12
12
|
import { Agent } from '@salesforce/agents';
|
|
13
|
-
import {
|
|
13
|
+
import { makeFlags, promptForFlag, validateAgentType, validateMaxTopics } from '../../../flags.js';
|
|
14
14
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
15
15
|
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.generate.spec-v2');
|
|
16
|
+
export const FLAGGABLE_PROMPTS = {
|
|
17
|
+
type: {
|
|
18
|
+
message: messages.getMessage('flags.type.summary'),
|
|
19
|
+
validate: (d) => d.length > 0 || 'Type cannot be empty',
|
|
20
|
+
char: 't',
|
|
21
|
+
options: ['customer', 'internal'],
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
role: {
|
|
25
|
+
message: messages.getMessage('flags.role.summary'),
|
|
26
|
+
validate: (d) => d.length > 0 || 'Role cannot be empty',
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
'company-name': {
|
|
30
|
+
message: messages.getMessage('flags.company-name.summary'),
|
|
31
|
+
validate: (d) => d.length > 0 || 'Company name cannot be empty',
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
'company-description': {
|
|
35
|
+
message: messages.getMessage('flags.company-description.summary'),
|
|
36
|
+
validate: (d) => d.length > 0 || 'Company description cannot be empty',
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
'company-website': {
|
|
40
|
+
message: messages.getMessage('flags.company-website.summary'),
|
|
41
|
+
validate: (d) => {
|
|
42
|
+
// Allow empty string
|
|
43
|
+
if (d.length === 0)
|
|
44
|
+
return true;
|
|
45
|
+
try {
|
|
46
|
+
const regExp = new RegExp('^(http|https)://', 'i');
|
|
47
|
+
const companySite = regExp.test(d) ? d : `https://${d}`;
|
|
48
|
+
new URL(companySite);
|
|
49
|
+
d = companySite;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
return 'Please enter a valid URL';
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
'max-topics': {
|
|
58
|
+
message: messages.getMessage('flags.max-topics.summary'),
|
|
59
|
+
promptMessage: messages.getMessage('flags.max-topics.prompt'),
|
|
60
|
+
validate: () => true,
|
|
61
|
+
// min: 1,
|
|
62
|
+
// max: 30,
|
|
63
|
+
},
|
|
64
|
+
'agent-user': {
|
|
65
|
+
message: messages.getMessage('flags.agent-user.summary'),
|
|
66
|
+
promptMessage: messages.getMessage('flags.agent-user.prompt'),
|
|
67
|
+
validate: () => true,
|
|
68
|
+
},
|
|
69
|
+
'enrich-logs': {
|
|
70
|
+
message: messages.getMessage('flags.enrich-logs.summary'),
|
|
71
|
+
promptMessage: messages.getMessage('flags.enrich-logs.prompt'),
|
|
72
|
+
validate: () => true,
|
|
73
|
+
options: ['true', 'false'],
|
|
74
|
+
default: 'false',
|
|
75
|
+
},
|
|
76
|
+
tone: {
|
|
77
|
+
message: messages.getMessage('flags.tone.summary'),
|
|
78
|
+
promptMessage: messages.getMessage('flags.tone.prompt'),
|
|
79
|
+
validate: () => true,
|
|
80
|
+
options: ['formal', 'casual', 'neutral'],
|
|
81
|
+
default: 'casual',
|
|
82
|
+
},
|
|
83
|
+
// 'primary-language': {
|
|
84
|
+
// message: messages.getMessage('flags.primary-language.summary'),
|
|
85
|
+
// validate: (): boolean | string => true,
|
|
86
|
+
// options: ['en_US'],
|
|
87
|
+
// default: 'en_US',
|
|
88
|
+
// },
|
|
89
|
+
};
|
|
16
90
|
export default class AgentCreateSpecV2 extends SfCommand {
|
|
17
91
|
static summary = messages.getMessage('summary');
|
|
18
92
|
static description = messages.getMessage('description');
|
|
@@ -22,7 +96,8 @@ export default class AgentCreateSpecV2 extends SfCommand {
|
|
|
22
96
|
static flags = {
|
|
23
97
|
'target-org': Flags.requiredOrg(),
|
|
24
98
|
'api-version': Flags.orgApiVersion(),
|
|
25
|
-
...makeFlags(
|
|
99
|
+
...makeFlags(FLAGGABLE_PROMPTS),
|
|
100
|
+
// a spec file can be used as input. Allows iterative spec development.
|
|
26
101
|
spec: Flags.file({
|
|
27
102
|
summary: messages.getMessage('flags.spec.summary'),
|
|
28
103
|
exists: true,
|
|
@@ -31,9 +106,8 @@ export default class AgentCreateSpecV2 extends SfCommand {
|
|
|
31
106
|
summary: messages.getMessage('flags.output-file.summary'),
|
|
32
107
|
default: join('config', 'agentSpec.yaml'),
|
|
33
108
|
}),
|
|
34
|
-
'
|
|
35
|
-
summary: messages.getMessage('flags.
|
|
36
|
-
min: 1,
|
|
109
|
+
'full-interview': Flags.boolean({
|
|
110
|
+
summary: messages.getMessage('flags.full-interview.summary'),
|
|
37
111
|
}),
|
|
38
112
|
'prompt-template': Flags.string({
|
|
39
113
|
summary: messages.getMessage('flags.prompt-template.summary'),
|
|
@@ -42,13 +116,25 @@ export default class AgentCreateSpecV2 extends SfCommand {
|
|
|
42
116
|
summary: messages.getMessage('flags.grounding-context.summary'),
|
|
43
117
|
dependsOn: ['prompt-template'],
|
|
44
118
|
}),
|
|
119
|
+
'no-prompt': Flags.boolean({
|
|
120
|
+
summary: messages.getMessage('flags.no-prompt.summary'),
|
|
121
|
+
}),
|
|
45
122
|
};
|
|
46
123
|
// eslint-disable-next-line complexity
|
|
47
124
|
async run() {
|
|
48
125
|
const { flags } = await this.parse(AgentCreateSpecV2);
|
|
126
|
+
let outputFile;
|
|
127
|
+
try {
|
|
128
|
+
outputFile = await resolveOutputFile(flags['output-file'], flags['no-prompt']);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
this.log(messages.getMessage('commandCanceled'));
|
|
132
|
+
// @ts-expect-error expected due to command cancelation.
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
49
135
|
// throw error if --json is used and not all required flags are provided
|
|
50
136
|
if (this.jsonEnabled()) {
|
|
51
|
-
const missingFlags = Object.entries(
|
|
137
|
+
const missingFlags = Object.entries(FLAGGABLE_PROMPTS)
|
|
52
138
|
.filter(([key, prompt]) => 'required' in prompt && prompt.required && !(key in flags))
|
|
53
139
|
.map(([key]) => key);
|
|
54
140
|
if (missingFlags.length) {
|
|
@@ -63,24 +149,42 @@ export default class AgentCreateSpecV2 extends SfCommand {
|
|
|
63
149
|
inputSpec = YAML.parse(readFileSync(resolve(flags.spec), 'utf8'));
|
|
64
150
|
}
|
|
65
151
|
// Flags override inputSpec values. Prompt if neither is set.
|
|
66
|
-
const type = flags.type ?? validateAgentType(inputSpec?.agentType) ?? (await promptForFlag(
|
|
67
|
-
const
|
|
68
|
-
const companyName = flags['company-name'] ?? inputSpec?.companyName ?? (await promptForFlag(FLAGGABLE_SPEC_PROMPTS['company-name']));
|
|
152
|
+
const type = flags.type ?? validateAgentType(inputSpec?.agentType) ?? (await promptForFlag(FLAGGABLE_PROMPTS.type));
|
|
153
|
+
const companyName = flags['company-name'] ?? inputSpec?.companyName ?? (await promptForFlag(FLAGGABLE_PROMPTS['company-name']));
|
|
69
154
|
const companyDescription = flags['company-description'] ??
|
|
70
155
|
inputSpec?.companyDescription ??
|
|
71
|
-
(await promptForFlag(
|
|
156
|
+
(await promptForFlag(FLAGGABLE_PROMPTS['company-description']));
|
|
157
|
+
const role = flags.role ?? inputSpec?.role ?? (await promptForFlag(FLAGGABLE_PROMPTS.role));
|
|
158
|
+
// full interview prompts
|
|
72
159
|
const companyWebsite = flags['company-website'] ??
|
|
73
160
|
inputSpec?.companyWebsite ??
|
|
74
|
-
(await promptForFlag(
|
|
161
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['company-website']) : undefined);
|
|
162
|
+
const maxNumOfTopics = flags['max-topics'] ??
|
|
163
|
+
validateMaxTopics(inputSpec?.maxNumOfTopics) ??
|
|
164
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['max-topics']) : 10);
|
|
165
|
+
const agentUser = flags['agent-user'] ??
|
|
166
|
+
inputSpec?.agentUser ??
|
|
167
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['agent-user']) : undefined);
|
|
168
|
+
let enrichLogs = flags['enrich-logs'] ??
|
|
169
|
+
inputSpec?.enrichLogs ??
|
|
170
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['enrich-logs']) : undefined);
|
|
171
|
+
enrichLogs = Boolean(enrichLogs === 'true' || enrichLogs === true);
|
|
172
|
+
const tone = flags.tone ??
|
|
173
|
+
inputSpec?.tone ??
|
|
174
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS.tone) : undefined);
|
|
175
|
+
// const primaryLanguage =
|
|
176
|
+
// flags['primary-language'] ??
|
|
177
|
+
// inputSpec?.primaryLanguage ??
|
|
178
|
+
// (flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['primary-language']) : undefined);
|
|
75
179
|
this.log();
|
|
76
180
|
this.spinner.start('Creating agent spec');
|
|
77
181
|
const connection = flags['target-org'].getConnection(flags['api-version']);
|
|
78
182
|
const agent = new Agent(connection, this.project);
|
|
79
183
|
const specConfig = {
|
|
80
184
|
agentType: type,
|
|
81
|
-
role,
|
|
82
185
|
companyName,
|
|
83
186
|
companyDescription,
|
|
187
|
+
role,
|
|
84
188
|
};
|
|
85
189
|
if (companyWebsite) {
|
|
86
190
|
specConfig.companyWebsite = companyWebsite;
|
|
@@ -93,19 +197,51 @@ export default class AgentCreateSpecV2 extends SfCommand {
|
|
|
93
197
|
specConfig.groundingContext = groundingContext;
|
|
94
198
|
}
|
|
95
199
|
}
|
|
96
|
-
const maxNumOfTopics = flags['max-topics'] ?? validateMaxTopics(inputSpec?.maxNumOfTopics);
|
|
97
200
|
if (maxNumOfTopics) {
|
|
98
|
-
specConfig.maxNumOfTopics = maxNumOfTopics;
|
|
201
|
+
specConfig.maxNumOfTopics = Number(maxNumOfTopics);
|
|
99
202
|
}
|
|
100
203
|
// Should we log the specConfig being used? It's returned in the JSON and the generated spec.
|
|
101
204
|
// this.log(`${ansis.green(figures.tick)} ${ansis.bold(message)} ${ansis.cyan(valueFromFlag)}`);
|
|
102
|
-
const
|
|
103
|
-
|
|
205
|
+
const specResponse = await agent.createSpecV2(specConfig);
|
|
206
|
+
// @ts-expect-error Need better typing
|
|
207
|
+
const specFileContents = buildSpecFile(specResponse, { agentUser, enrichLogs, tone });
|
|
208
|
+
const outputFilePath = writeSpecFile(outputFile, specFileContents);
|
|
104
209
|
this.spinner.stop();
|
|
105
210
|
this.log(`\nSaved agent spec: ${outputFilePath}`);
|
|
106
|
-
return { ...{ isSuccess: true, specPath: outputFilePath }, ...
|
|
211
|
+
return { ...{ isSuccess: true, specPath: outputFilePath }, ...specResponse, ...specFileContents };
|
|
107
212
|
}
|
|
108
213
|
}
|
|
214
|
+
// Builds spec file contents from the spec response and any additional flags
|
|
215
|
+
// in a specific order.
|
|
216
|
+
const buildSpecFile = (specResponse, extraProps) => {
|
|
217
|
+
const propertyOrder = [
|
|
218
|
+
'agentType',
|
|
219
|
+
'companyName',
|
|
220
|
+
'companyDescription',
|
|
221
|
+
'companyWebsite',
|
|
222
|
+
'role',
|
|
223
|
+
'maxNumOfTopics',
|
|
224
|
+
'agentUser',
|
|
225
|
+
'enrichLogs',
|
|
226
|
+
'tone',
|
|
227
|
+
// 'primaryLanguage',
|
|
228
|
+
'promptTemplateName',
|
|
229
|
+
'groundingContext',
|
|
230
|
+
'topics',
|
|
231
|
+
];
|
|
232
|
+
const specFileContents = {};
|
|
233
|
+
propertyOrder.map((prop) => {
|
|
234
|
+
// @ts-expect-error need better typing of the array.
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
236
|
+
const val = specResponse[prop] ?? extraProps[prop];
|
|
237
|
+
if (val != null || (typeof val === 'string' && val.length > 0)) {
|
|
238
|
+
// @ts-expect-error need better typing of the array.
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
240
|
+
specFileContents[prop] = val;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return specFileContents;
|
|
244
|
+
};
|
|
109
245
|
const writeSpecFile = (outputFile, agentSpec) => {
|
|
110
246
|
// create the directory if not already created
|
|
111
247
|
const outputFilePath = resolve(outputFile);
|
|
@@ -114,4 +250,19 @@ const writeSpecFile = (outputFile, agentSpec) => {
|
|
|
114
250
|
writeFileSync(outputFilePath, YAML.stringify(agentSpec));
|
|
115
251
|
return outputFilePath;
|
|
116
252
|
};
|
|
253
|
+
const resolveOutputFile = async (outputFile, noPrompt = false) => {
|
|
254
|
+
let resolvedOutputFile = resolve(outputFile);
|
|
255
|
+
if (!noPrompt) {
|
|
256
|
+
if (existsSync(resolvedOutputFile)) {
|
|
257
|
+
const message = messages.getMessage('confirmSpecOverwrite', [resolvedOutputFile]);
|
|
258
|
+
if (!(await prompts.confirm({ message }))) {
|
|
259
|
+
throw Error('NoOverwrite');
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (!resolvedOutputFile.endsWith('.yaml')) {
|
|
264
|
+
resolvedOutputFile = `${resolvedOutputFile}.yaml`;
|
|
265
|
+
}
|
|
266
|
+
return resolvedOutputFile;
|
|
267
|
+
};
|
|
117
268
|
//# sourceMappingURL=spec-v2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-v2.js","sourceRoot":"","sources":["../../../../src/commands/agent/generate/spec-v2.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"spec-v2.js","sourceRoot":"","sources":["../../../../src/commands/agent/generate/spec-v2.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAA8C,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAmB,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEpH,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,wBAAwB,CAAC,CAAC;AAiB7F,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAA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,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAClF,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC;gBAC1C,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1C,kBAAkB,GAAG,GAAG,kBAAkB,OAAO,CAAC;IACpD,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
export default class
|
|
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 {
|
|
8
|
-
import {
|
|
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-
|
|
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
|
|
51
|
+
const expectedTopic = await select({
|
|
51
52
|
message: 'Expected topic',
|
|
52
53
|
choices: [...topics, customKey],
|
|
53
54
|
theme,
|
|
54
55
|
});
|
|
55
|
-
if (
|
|
56
|
+
if (expectedTopic === customKey) {
|
|
56
57
|
return {
|
|
57
58
|
utterance,
|
|
58
|
-
|
|
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
|
-
|
|
70
|
-
|
|
70
|
+
expectedActions: await askForOtherActions(),
|
|
71
|
+
expectedOutcome: await askForBotRating(),
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
|
-
const genAiPluginXml = await readFile(genAiPlugins[
|
|
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
|
|
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 (
|
|
84
|
+
if (expectedActions.includes(customKey)) {
|
|
84
85
|
const additional = await askForOtherActions();
|
|
85
|
-
|
|
86
|
+
expectedActions = [...expectedActions.filter((a) => a !== customKey), ...additional];
|
|
86
87
|
}
|
|
87
|
-
const
|
|
88
|
+
const expectedOutcome = await askForBotRating();
|
|
88
89
|
return {
|
|
89
90
|
utterance,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
expectedActions,
|
|
92
|
+
expectedOutcome,
|
|
93
|
+
expectedTopic,
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
|
-
export
|
|
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
|
|
129
|
-
|
|
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
|
-
|
|
164
|
-
|
|
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-
|
|
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;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,0BAA0B,CAAC,CAAC;AAe/F,SAAS,SAAS,CAAI,KAAc;IAClC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC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C,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
|
+
}
|