@salesforce/plugin-agent 1.3.4 → 1.4.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 +100 -20
- package/lib/agentTestCache.d.ts +17 -0
- package/lib/agentTestCache.js +53 -0
- package/lib/agentTestCache.js.map +1 -0
- package/lib/commands/agent/test/cancel.d.ts +4 -3
- package/lib/commands/agent/test/cancel.js +15 -11
- package/lib/commands/agent/test/cancel.js.map +1 -1
- package/lib/commands/agent/test/results.d.ts +16 -0
- package/lib/commands/agent/test/results.js +38 -0
- package/lib/commands/agent/test/results.js.map +1 -0
- package/lib/commands/agent/test/resume.d.ts +20 -0
- package/lib/commands/agent/test/resume.js +66 -0
- package/lib/commands/agent/test/resume.js.map +1 -0
- package/lib/commands/agent/test/run.d.ts +6 -7
- package/lib/commands/agent/test/run.js +38 -23
- package/lib/commands/agent/test/run.js.map +1 -1
- package/lib/flags.d.ts +4 -0
- package/lib/flags.js +21 -0
- package/lib/flags.js.map +1 -0
- package/lib/testStages.d.ts +27 -0
- package/lib/testStages.js +96 -0
- package/lib/testStages.js.map +1 -0
- package/messages/agent.test.cancel.md +2 -2
- package/messages/agent.test.results.md +19 -0
- package/messages/agent.test.resume.md +29 -0
- package/messages/agent.test.run.md +5 -9
- package/messages/shared.md +3 -0
- package/npm-shrinkwrap.json +26 -8
- package/oclif.lock +18 -35
- package/oclif.manifest.json +226 -13
- package/package.json +17 -7
- package/schemas/agent-create.json +2 -4
- package/schemas/agent-generate-spec.json +2 -4
- package/schemas/agent-test-cancel.json +3 -6
- package/schemas/agent-test-results.json +145 -0
- package/schemas/agent-test-resume.json +19 -0
- package/schemas/agent-test-run.json +4 -13
package/README.md
CHANGED
|
@@ -64,6 +64,8 @@ sf plugins
|
|
|
64
64
|
- [`sf agent create`](#sf-agent-create)
|
|
65
65
|
- [`sf agent generate spec`](#sf-agent-generate-spec)
|
|
66
66
|
- [`sf agent test cancel`](#sf-agent-test-cancel)
|
|
67
|
+
- [`sf agent test results`](#sf-agent-test-results)
|
|
68
|
+
- [`sf agent test resume`](#sf-agent-test-resume)
|
|
67
69
|
- [`sf agent test run`](#sf-agent-test-run)
|
|
68
70
|
|
|
69
71
|
## `sf agent create`
|
|
@@ -102,7 +104,7 @@ FLAG DESCRIPTIONS
|
|
|
102
104
|
spec` command.
|
|
103
105
|
```
|
|
104
106
|
|
|
105
|
-
_See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.
|
|
107
|
+
_See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.4.0/src/commands/agent/create.ts)_
|
|
106
108
|
|
|
107
109
|
## `sf agent generate spec`
|
|
108
110
|
|
|
@@ -145,7 +147,7 @@ EXAMPLES
|
|
|
145
147
|
--company-description "A meaningful description"
|
|
146
148
|
```
|
|
147
149
|
|
|
148
|
-
_See code: [src/commands/agent/generate/spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.
|
|
150
|
+
_See code: [src/commands/agent/generate/spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.4.0/src/commands/agent/generate/spec.ts)_
|
|
149
151
|
|
|
150
152
|
## `sf agent test cancel`
|
|
151
153
|
|
|
@@ -153,13 +155,14 @@ Cancel a running test for an Agent.
|
|
|
153
155
|
|
|
154
156
|
```
|
|
155
157
|
USAGE
|
|
156
|
-
$ sf agent test cancel -o <value> -
|
|
158
|
+
$ sf agent test cancel -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-i <value>] [-r]
|
|
157
159
|
|
|
158
160
|
FLAGS
|
|
159
|
-
-i, --job-id=<value>
|
|
160
|
-
-o, --target-org=<value>
|
|
161
|
-
|
|
162
|
-
-r, --use-most-recent
|
|
161
|
+
-i, --job-id=<value> The AiEvaluation ID.
|
|
162
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
163
|
+
configuration variable is already set.
|
|
164
|
+
-r, --use-most-recent Use the job ID of the most recent test evaluation.
|
|
165
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
163
166
|
|
|
164
167
|
GLOBAL FLAGS
|
|
165
168
|
--flags-dir=<value> Import flag values from a directory.
|
|
@@ -173,10 +176,84 @@ DESCRIPTION
|
|
|
173
176
|
EXAMPLES
|
|
174
177
|
Cancel a test for an Agent:
|
|
175
178
|
|
|
176
|
-
$ sf agent test cancel --id AiEvalId
|
|
179
|
+
$ sf agent test cancel --job-id AiEvalId
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
_See code: [src/commands/agent/test/cancel.ts](https://github.com/salesforcecli/plugin-agent/blob/1.4.0/src/commands/agent/test/cancel.ts)_
|
|
183
|
+
|
|
184
|
+
## `sf agent test results`
|
|
185
|
+
|
|
186
|
+
Get the results of a test evaluation.
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
USAGE
|
|
190
|
+
$ sf agent test results -o <value> -i <value> [--json] [--flags-dir <value>] [--api-version <value>] [--result-format
|
|
191
|
+
json|human]
|
|
192
|
+
|
|
193
|
+
FLAGS
|
|
194
|
+
-i, --job-id=<value> (required) The AiEvaluation ID.
|
|
195
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
196
|
+
configuration variable is already set.
|
|
197
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
198
|
+
--result-format=<option> [default: human] Format of the test run results.
|
|
199
|
+
<options: json|human>
|
|
200
|
+
|
|
201
|
+
GLOBAL FLAGS
|
|
202
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
203
|
+
--json Format output as json.
|
|
204
|
+
|
|
205
|
+
DESCRIPTION
|
|
206
|
+
Get the results of a test evaluation.
|
|
207
|
+
|
|
208
|
+
Provide the AiEvaluation ID to get the results of a test evaluation.
|
|
209
|
+
|
|
210
|
+
EXAMPLES
|
|
211
|
+
$ sf agent test results --job-id AiEvalId
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
_See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.4.0/src/commands/agent/test/results.ts)_
|
|
215
|
+
|
|
216
|
+
## `sf agent test resume`
|
|
217
|
+
|
|
218
|
+
Resume a running test for an Agent.
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
USAGE
|
|
222
|
+
$ sf agent test resume -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-i <value>] [-r] [-w
|
|
223
|
+
<value>] [--result-format json|human]
|
|
224
|
+
|
|
225
|
+
FLAGS
|
|
226
|
+
-i, --job-id=<value> The AiEvaluation ID.
|
|
227
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
228
|
+
configuration variable is already set.
|
|
229
|
+
-r, --use-most-recent Use the job ID of the most recent test evaluation.
|
|
230
|
+
-w, --wait=<value> [default: 5 minutes] Number of minutes to wait for the command to complete and display
|
|
231
|
+
results to the terminal window.
|
|
232
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
233
|
+
--result-format=<option> [default: human] Format of the test run results.
|
|
234
|
+
<options: json|human>
|
|
235
|
+
|
|
236
|
+
GLOBAL FLAGS
|
|
237
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
238
|
+
--json Format output as json.
|
|
239
|
+
|
|
240
|
+
DESCRIPTION
|
|
241
|
+
Resume a running test for an Agent.
|
|
242
|
+
|
|
243
|
+
Resume a running test for an Agent, providing the AiEvaluation ID.
|
|
244
|
+
|
|
245
|
+
EXAMPLES
|
|
246
|
+
Resume a test for an Agent:
|
|
247
|
+
|
|
248
|
+
$ sf agent test resume --job-id AiEvalId
|
|
249
|
+
|
|
250
|
+
FLAG DESCRIPTIONS
|
|
251
|
+
-w, --wait=<value> Number of minutes to wait for the command to complete and display results to the terminal window.
|
|
252
|
+
|
|
253
|
+
If the command continues to run after the wait period, the CLI returns control of the terminal window to you.
|
|
177
254
|
```
|
|
178
255
|
|
|
179
|
-
_See code: [src/commands/agent/test/
|
|
256
|
+
_See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.4.0/src/commands/agent/test/resume.ts)_
|
|
180
257
|
|
|
181
258
|
## `sf agent test run`
|
|
182
259
|
|
|
@@ -184,15 +261,18 @@ Start a test for an Agent.
|
|
|
184
261
|
|
|
185
262
|
```
|
|
186
263
|
USAGE
|
|
187
|
-
$ sf agent test run -o <value> -
|
|
264
|
+
$ sf agent test run -o <value> -n <value> [--json] [--flags-dir <value>] [--api-version <value>] [-w <value>]
|
|
265
|
+
[--result-format json|human]
|
|
188
266
|
|
|
189
267
|
FLAGS
|
|
190
|
-
-
|
|
191
|
-
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
268
|
+
-n, --name=<value> (required) The name of the AiEvaluationDefinition to start.
|
|
269
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
270
|
+
configuration variable is already set.
|
|
271
|
+
-w, --wait=<value> Number of minutes to wait for the command to complete and display results to the
|
|
272
|
+
terminal window.
|
|
273
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
274
|
+
--result-format=<option> [default: human] Format of the test run results.
|
|
275
|
+
<options: json|human>
|
|
196
276
|
|
|
197
277
|
GLOBAL FLAGS
|
|
198
278
|
--flags-dir=<value> Import flag values from a directory.
|
|
@@ -206,18 +286,18 @@ DESCRIPTION
|
|
|
206
286
|
EXAMPLES
|
|
207
287
|
Start a test for an Agent:
|
|
208
288
|
|
|
209
|
-
$ sf agent test run --
|
|
289
|
+
$ sf agent test run --name AiEvalDefVerId
|
|
210
290
|
|
|
211
291
|
FLAG DESCRIPTIONS
|
|
212
|
-
-
|
|
292
|
+
-n, --name=<value> The name of the AiEvaluationDefinition to start.
|
|
213
293
|
|
|
214
|
-
The
|
|
294
|
+
The name of the AiEvaluationDefinition to start.
|
|
215
295
|
|
|
216
296
|
-w, --wait=<value> Number of minutes to wait for the command to complete and display results to the terminal window.
|
|
217
297
|
|
|
218
298
|
If the command continues to run after the wait period, the CLI returns control of the terminal window to you.
|
|
219
299
|
```
|
|
220
300
|
|
|
221
|
-
_See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.
|
|
301
|
+
_See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.4.0/src/commands/agent/test/run.ts)_
|
|
222
302
|
|
|
223
303
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TTLConfig } from '@salesforce/core';
|
|
2
|
+
type CacheContents = {
|
|
3
|
+
aiEvaluationId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class AgentTestCache extends TTLConfig<TTLConfig.Options, CacheContents> {
|
|
7
|
+
static getFileName(): string;
|
|
8
|
+
static getDefaultOptions(): TTLConfig.Options;
|
|
9
|
+
createCacheEntry(aiEvaluationId: string, name: string): Promise<void>;
|
|
10
|
+
removeCacheEntry(aiEvaluationId: string): Promise<void>;
|
|
11
|
+
resolveFromCache(): CacheContents;
|
|
12
|
+
useIdOrMostRecent(aiEvaluationId: string | undefined, useMostRecent: boolean): {
|
|
13
|
+
aiEvaluationId: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { Global, SfError, TTLConfig } from '@salesforce/core';
|
|
8
|
+
import { Duration } from '@salesforce/kit';
|
|
9
|
+
export class AgentTestCache extends TTLConfig {
|
|
10
|
+
static getFileName() {
|
|
11
|
+
return 'agent-test-cache.json';
|
|
12
|
+
}
|
|
13
|
+
static getDefaultOptions() {
|
|
14
|
+
return {
|
|
15
|
+
isGlobal: true,
|
|
16
|
+
isState: true,
|
|
17
|
+
filename: AgentTestCache.getFileName(),
|
|
18
|
+
stateFolder: Global.SF_STATE_FOLDER,
|
|
19
|
+
ttl: Duration.days(7),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async createCacheEntry(aiEvaluationId, name) {
|
|
23
|
+
if (!aiEvaluationId)
|
|
24
|
+
throw new SfError('aiEvaluationId is required to create a cache entry');
|
|
25
|
+
this.set(aiEvaluationId, { aiEvaluationId, name });
|
|
26
|
+
await this.write();
|
|
27
|
+
}
|
|
28
|
+
async removeCacheEntry(aiEvaluationId) {
|
|
29
|
+
if (!aiEvaluationId)
|
|
30
|
+
throw new SfError('aiEvaluationId is required to remove a cache entry');
|
|
31
|
+
this.unset(aiEvaluationId);
|
|
32
|
+
await this.write();
|
|
33
|
+
}
|
|
34
|
+
resolveFromCache() {
|
|
35
|
+
const key = this.getLatestKey();
|
|
36
|
+
if (!key)
|
|
37
|
+
throw new SfError('Could not find an aiEvaluationId to resume');
|
|
38
|
+
return this.get(key);
|
|
39
|
+
}
|
|
40
|
+
useIdOrMostRecent(aiEvaluationId, useMostRecent) {
|
|
41
|
+
if (aiEvaluationId && useMostRecent) {
|
|
42
|
+
throw new SfError('Cannot specify both an aiEvaluationId and use most recent flag');
|
|
43
|
+
}
|
|
44
|
+
if (!aiEvaluationId && !useMostRecent) {
|
|
45
|
+
throw new SfError('Must specify either an aiEvaluationId or use most recent flag');
|
|
46
|
+
}
|
|
47
|
+
if (aiEvaluationId) {
|
|
48
|
+
return { aiEvaluationId };
|
|
49
|
+
}
|
|
50
|
+
return this.resolveFromCache();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=agentTestCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentTestCache.js","sourceRoot":"","sources":["../src/agentTestCache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,S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O,CAAC,gEAAgE,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,CAAC,cAAc,IAAI,CAAC,aAAa,EAAE,CAAC;YACtC,MAAM,IAAI,OAAO,CAAC,+DAA+D,CAAC,CAAC;QACrF,CAAC;QAED,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,CAAC;QAED,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
2
|
export type AgentTestCancelResult = {
|
|
3
|
-
|
|
3
|
+
aiEvaluationId: string;
|
|
4
4
|
success: boolean;
|
|
5
5
|
errorCode?: string;
|
|
6
6
|
message?: string;
|
|
@@ -9,10 +9,11 @@ export default class AgentTestCancel extends SfCommand<AgentTestCancelResult> {
|
|
|
9
9
|
static readonly summary: string;
|
|
10
10
|
static readonly description: string;
|
|
11
11
|
static readonly examples: string[];
|
|
12
|
-
static state
|
|
12
|
+
static readonly state = "beta";
|
|
13
13
|
static readonly flags: {
|
|
14
14
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
-
'
|
|
15
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'job-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
17
|
'use-most-recent': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
18
|
};
|
|
18
19
|
run(): Promise<AgentTestCancelResult>;
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
8
|
import { Messages } from '@salesforce/core';
|
|
9
|
+
import { AgentTester } from '@salesforce/agents';
|
|
10
|
+
import { AgentTestCache } from '../../../agentTestCache.js';
|
|
9
11
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
10
12
|
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.cancel');
|
|
11
13
|
export default class AgentTestCancel extends SfCommand {
|
|
@@ -15,29 +17,31 @@ export default class AgentTestCancel extends SfCommand {
|
|
|
15
17
|
static state = 'beta';
|
|
16
18
|
static flags = {
|
|
17
19
|
'target-org': Flags.requiredOrg(),
|
|
20
|
+
'api-version': Flags.orgApiVersion(),
|
|
18
21
|
'job-id': Flags.string({
|
|
19
22
|
char: 'i',
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
summary: messages.getMessage('flags.job-id.summary'),
|
|
24
|
+
exactlyOne: ['use-most-recent', 'job-id'],
|
|
22
25
|
}),
|
|
23
26
|
'use-most-recent': Flags.boolean({
|
|
24
27
|
char: 'r',
|
|
25
28
|
summary: messages.getMessage('flags.use-most-recent.summary'),
|
|
26
29
|
exactlyOne: ['use-most-recent', 'job-id'],
|
|
27
30
|
}),
|
|
28
|
-
//
|
|
29
|
-
// Future flags:
|
|
30
|
-
// ??? api-version ???
|
|
31
31
|
};
|
|
32
32
|
async run() {
|
|
33
33
|
const { flags } = await this.parse(AgentTestCancel);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const agentTestCache = await AgentTestCache.create();
|
|
35
|
+
const { aiEvaluationId } = agentTestCache.useIdOrMostRecent(flags['job-id'], flags['use-most-recent']);
|
|
36
|
+
this.log(`Canceling tests for AiEvaluation Job: ${aiEvaluationId}`);
|
|
37
|
+
const agentTester = new AgentTester(flags['target-org'].getConnection(flags['api-version']));
|
|
38
|
+
const result = await agentTester.cancel(aiEvaluationId);
|
|
39
|
+
if (result.success) {
|
|
40
|
+
await agentTestCache.removeCacheEntry(aiEvaluationId);
|
|
41
|
+
}
|
|
38
42
|
return {
|
|
39
|
-
success:
|
|
40
|
-
|
|
43
|
+
success: result.success,
|
|
44
|
+
aiEvaluationId,
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/cancel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/cancel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;AASxF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,SAAgC;IACpE,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,KAAK,GAAG,MAAM,CAAC;IAE/B,MAAM,CAAU,KAAK,GAAG;QAC7B,YAAY,EAAE,KAAK,CAAC,WAAW,EAAE;QACjC,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE;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import { AgentTestDetailsResponse } from '@salesforce/agents';
|
|
3
|
+
export type AgentTestResultsResult = AgentTestDetailsResponse;
|
|
4
|
+
export default class AgentTestResults extends SfCommand<AgentTestResultsResult> {
|
|
5
|
+
static readonly summary: string;
|
|
6
|
+
static readonly description: string;
|
|
7
|
+
static readonly examples: string[];
|
|
8
|
+
static readonly state = "beta";
|
|
9
|
+
static readonly flags: {
|
|
10
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'job-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'result-format': import("@oclif/core/interfaces").OptionFlag<"json" | "human", import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<AgentTestResultsResult>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { Messages } from '@salesforce/core';
|
|
9
|
+
import { AgentTester, humanFormat } from '@salesforce/agents';
|
|
10
|
+
import { resultFormatFlag } from '../../../flags.js';
|
|
11
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
12
|
+
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.results');
|
|
13
|
+
export default class AgentTestResults extends SfCommand {
|
|
14
|
+
static summary = messages.getMessage('summary');
|
|
15
|
+
static description = messages.getMessage('description');
|
|
16
|
+
static examples = messages.getMessages('examples');
|
|
17
|
+
static state = 'beta';
|
|
18
|
+
static flags = {
|
|
19
|
+
'target-org': Flags.requiredOrg(),
|
|
20
|
+
'api-version': Flags.orgApiVersion(),
|
|
21
|
+
'job-id': Flags.string({
|
|
22
|
+
summary: messages.getMessage('flags.job-id.summary'),
|
|
23
|
+
char: 'i',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
'result-format': resultFormatFlag(),
|
|
27
|
+
};
|
|
28
|
+
async run() {
|
|
29
|
+
const { flags } = await this.parse(AgentTestResults);
|
|
30
|
+
const agentTester = new AgentTester(flags['target-org'].getConnection(flags['api-version']));
|
|
31
|
+
const response = await agentTester.details(flags['job-id']);
|
|
32
|
+
if (flags['result-format'] === 'human') {
|
|
33
|
+
this.log(await humanFormat(flags['job-id'], response));
|
|
34
|
+
}
|
|
35
|
+
return response;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/results.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAA4B,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,oBAAoB,CAAC,CAAC;AAIzF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,SAAiC;IACtE,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,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
6
|
+
export default class AgentTestResume extends SfCommand<AgentTestResumeResult> {
|
|
7
|
+
static readonly summary: string;
|
|
8
|
+
static readonly description: string;
|
|
9
|
+
static readonly examples: string[];
|
|
10
|
+
static readonly state = "beta";
|
|
11
|
+
static readonly flags: {
|
|
12
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'job-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'use-most-recent': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
wait: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/kit").Duration, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'result-format': import("@oclif/core/interfaces").OptionFlag<"json" | "human", import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<AgentTestResumeResult>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, 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 { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { Messages } from '@salesforce/core';
|
|
9
|
+
import { AgentTester, humanFormat } from '@salesforce/agents';
|
|
10
|
+
import { AgentTestCache } from '../../../agentTestCache.js';
|
|
11
|
+
import { TestStages } from '../../../testStages.js';
|
|
12
|
+
import { resultFormatFlag } from '../../../flags.js';
|
|
13
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
14
|
+
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.resume');
|
|
15
|
+
export default class AgentTestResume extends SfCommand {
|
|
16
|
+
static summary = messages.getMessage('summary');
|
|
17
|
+
static description = messages.getMessage('description');
|
|
18
|
+
static examples = messages.getMessages('examples');
|
|
19
|
+
static state = 'beta';
|
|
20
|
+
static flags = {
|
|
21
|
+
'target-org': Flags.requiredOrg(),
|
|
22
|
+
'api-version': Flags.orgApiVersion(),
|
|
23
|
+
'job-id': Flags.string({
|
|
24
|
+
char: 'i',
|
|
25
|
+
summary: messages.getMessage('flags.job-id.summary'),
|
|
26
|
+
exactlyOne: ['use-most-recent', 'job-id'],
|
|
27
|
+
}),
|
|
28
|
+
'use-most-recent': Flags.boolean({
|
|
29
|
+
char: 'r',
|
|
30
|
+
summary: messages.getMessage('flags.use-most-recent.summary'),
|
|
31
|
+
exactlyOne: ['use-most-recent', 'job-id'],
|
|
32
|
+
}),
|
|
33
|
+
wait: Flags.duration({
|
|
34
|
+
char: 'w',
|
|
35
|
+
unit: 'minutes',
|
|
36
|
+
min: 1,
|
|
37
|
+
defaultValue: 5,
|
|
38
|
+
summary: messages.getMessage('flags.wait.summary'),
|
|
39
|
+
description: messages.getMessage('flags.wait.description'),
|
|
40
|
+
}),
|
|
41
|
+
'result-format': resultFormatFlag(),
|
|
42
|
+
};
|
|
43
|
+
async run() {
|
|
44
|
+
const { flags } = await this.parse(AgentTestResume);
|
|
45
|
+
const agentTestCache = await AgentTestCache.create();
|
|
46
|
+
const { name, aiEvaluationId } = agentTestCache.useIdOrMostRecent(flags['job-id'], flags['use-most-recent']);
|
|
47
|
+
const mso = new TestStages({
|
|
48
|
+
title: `Agent Test Run: ${name ?? aiEvaluationId}`,
|
|
49
|
+
jsonEnabled: this.jsonEnabled(),
|
|
50
|
+
});
|
|
51
|
+
mso.start({ id: aiEvaluationId });
|
|
52
|
+
const agentTester = new AgentTester(flags['target-org'].getConnection(flags['api-version']));
|
|
53
|
+
const { completed, response } = await mso.poll(agentTester, aiEvaluationId, flags.wait);
|
|
54
|
+
if (completed)
|
|
55
|
+
await agentTestCache.removeCacheEntry(aiEvaluationId);
|
|
56
|
+
mso.stop();
|
|
57
|
+
if (response && flags['result-format'] === 'human') {
|
|
58
|
+
this.log(await humanFormat(name ?? aiEvaluationId, response));
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
status: 'COMPLETED',
|
|
62
|
+
aiEvaluationId,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/resume.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;AAOxF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,SAAgC;IACpE,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;I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,IAAI,cAAc,EAAE;YAClD,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;SAChC,CAAC,CAAC;QACH,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QAClC,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAE7F,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACxF,IAAI,SAAS;YAAE,MAAM,cAAc,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAErE,GAAG,CAAC,IAAI,EAAE,CAAC;QAEX,IAAI,QAAQ,IAAI,KAAK,CAAC,eAAe,CAAC,KAAK,OAAO,EAAE,CAAC;YACnD,IAAI,CAAC,GAAG,CAAC,MAAM,WAAW,CAAC,IAAI,IAAI,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC;QAChE,CAAC;QAED,OAAO;YACL,MAAM,EAAE,WAAW;YACnB,cAAc;SACf,CAAC;IACJ,CAAC"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
2
|
export type AgentTestRunResult = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
errorCode?: string;
|
|
6
|
-
message?: string;
|
|
3
|
+
aiEvaluationId: string;
|
|
4
|
+
status: string;
|
|
7
5
|
};
|
|
8
6
|
export default class AgentTestRun extends SfCommand<AgentTestRunResult> {
|
|
9
7
|
static readonly summary: string;
|
|
10
8
|
static readonly description: string;
|
|
11
9
|
static readonly examples: string[];
|
|
12
|
-
static state
|
|
10
|
+
static readonly state = "beta";
|
|
13
11
|
static readonly flags: {
|
|
14
12
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
-
|
|
13
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
15
|
wait: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/kit").Duration, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
-
'
|
|
16
|
+
'result-format': import("@oclif/core/interfaces").OptionFlag<"json" | "human", import("@oclif/core/interfaces").CustomOptions>;
|
|
18
17
|
};
|
|
19
18
|
run(): Promise<AgentTestRunResult>;
|
|
20
19
|
}
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
8
|
import { Messages } from '@salesforce/core';
|
|
9
|
+
import { AgentTester, humanFormat } from '@salesforce/agents';
|
|
10
|
+
import { colorize } from '@oclif/core/ux';
|
|
11
|
+
import { resultFormatFlag } from '../../../flags.js';
|
|
12
|
+
import { AgentTestCache } from '../../../agentTestCache.js';
|
|
13
|
+
import { TestStages } from '../../../testStages.js';
|
|
9
14
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
10
15
|
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.run');
|
|
11
16
|
export default class AgentTestRun extends SfCommand {
|
|
@@ -15,13 +20,15 @@ export default class AgentTestRun extends SfCommand {
|
|
|
15
20
|
static state = 'beta';
|
|
16
21
|
static flags = {
|
|
17
22
|
'target-org': Flags.requiredOrg(),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
char: '
|
|
23
|
+
'api-version': Flags.orgApiVersion(),
|
|
24
|
+
name: Flags.string({
|
|
25
|
+
char: 'n',
|
|
21
26
|
required: true,
|
|
22
|
-
summary: messages.getMessage('flags.
|
|
23
|
-
description: messages.getMessage('flags.
|
|
27
|
+
summary: messages.getMessage('flags.name.summary'),
|
|
28
|
+
description: messages.getMessage('flags.name.description'),
|
|
24
29
|
}),
|
|
30
|
+
// we want to pass `undefined` to the API
|
|
31
|
+
// eslint-disable-next-line sf-plugin/flag-min-max-default
|
|
25
32
|
wait: Flags.duration({
|
|
26
33
|
char: 'w',
|
|
27
34
|
unit: 'minutes',
|
|
@@ -29,27 +36,35 @@ export default class AgentTestRun extends SfCommand {
|
|
|
29
36
|
summary: messages.getMessage('flags.wait.summary'),
|
|
30
37
|
description: messages.getMessage('flags.wait.description'),
|
|
31
38
|
}),
|
|
32
|
-
'
|
|
33
|
-
char: 'd',
|
|
34
|
-
summary: messages.getMessage('flags.output-dir.summary'),
|
|
35
|
-
}),
|
|
36
|
-
//
|
|
37
|
-
// Future flags:
|
|
38
|
-
// result-format [csv, json, table, junit, TAP]
|
|
39
|
-
// suites [array of suite names]
|
|
40
|
-
// verbose [boolean]
|
|
41
|
-
// ??? api-version or build-version ???
|
|
39
|
+
'result-format': resultFormatFlag(),
|
|
42
40
|
};
|
|
43
41
|
async run() {
|
|
44
42
|
const { flags } = await this.parse(AgentTestRun);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
const mso = new TestStages({ title: `Agent Test Run: ${flags.name}`, jsonEnabled: this.jsonEnabled() });
|
|
44
|
+
mso.start();
|
|
45
|
+
const agentTester = new AgentTester(flags['target-org'].getConnection(flags['api-version']));
|
|
46
|
+
const response = await agentTester.start(flags.name);
|
|
47
|
+
mso.update({ id: response.aiEvaluationId });
|
|
48
|
+
const agentTestCache = await AgentTestCache.create();
|
|
49
|
+
await agentTestCache.createCacheEntry(response.aiEvaluationId, flags.name);
|
|
50
|
+
if (flags.wait?.minutes) {
|
|
51
|
+
const { completed, response: detailsResponse } = await mso.poll(agentTester, response.aiEvaluationId, flags.wait);
|
|
52
|
+
if (completed)
|
|
53
|
+
await agentTestCache.removeCacheEntry(response.aiEvaluationId);
|
|
54
|
+
mso.stop();
|
|
55
|
+
if (detailsResponse && flags['result-format'] === 'human') {
|
|
56
|
+
this.log(await humanFormat(flags.name, detailsResponse));
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
status: 'COMPLETED',
|
|
60
|
+
aiEvaluationId: response.aiEvaluationId,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
mso.stop();
|
|
65
|
+
this.log(`Run ${colorize('dim', `sf agent test resume --job-id ${response.aiEvaluationId}`)} to resuming watching this test.`);
|
|
66
|
+
}
|
|
67
|
+
return response;
|
|
53
68
|
}
|
|
54
69
|
}
|
|
55
70
|
//# sourceMappingURL=run.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/run.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/run.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,C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