Skip to content

Commit 75d6403

Browse files
committed
fix: keep up with agents lib
1 parent b0d78a1 commit 75d6403

File tree

9 files changed

+40
-42
lines changed

9 files changed

+40
-42
lines changed

command-snapshot.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"alias": [],
4848
"command": "agent:test:results",
4949
"flagAliases": [],
50-
"flagChars": ["i", "o", "r"],
50+
"flagChars": ["i", "o"],
5151
"flags": ["api-version", "flags-dir", "job-id", "json", "result-format", "target-org"],
5252
"plugin": "@salesforce/plugin-agent"
5353
},
@@ -56,14 +56,14 @@
5656
"command": "agent:test:resume",
5757
"flagAliases": [],
5858
"flagChars": ["i", "o", "r", "w"],
59-
"flags": ["api-version", "flags-dir", "job-id", "json", "target-org", "use-most-recent", "wait"],
59+
"flags": ["api-version", "flags-dir", "job-id", "json", "result-format", "target-org", "use-most-recent", "wait"],
6060
"plugin": "@salesforce/plugin-agent"
6161
},
6262
{
6363
"alias": [],
6464
"command": "agent:test:run",
6565
"flagAliases": [],
66-
"flagChars": ["n", "o", "r", "w"],
66+
"flagChars": ["n", "o", "w"],
6767
"flags": ["api-version", "flags-dir", "json", "name", "result-format", "target-org", "wait"],
6868
"plugin": "@salesforce/plugin-agent"
6969
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"@inquirer/select": "^4.0.1",
1111
"@oclif/core": "^4",
1212
"@oclif/multi-stage-output": "^0.7.12",
13-
"@salesforce/agents": "^0.2.2",
13+
"@salesforce/agents": "^0.3.0",
1414
"@salesforce/core": "^8.8.0",
1515
"@salesforce/kit": "^3.2.1",
1616
"@salesforce/sf-plugins-core": "^12.1.0",

src/commands/agent/generate/spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ export default class AgentCreateSpec extends SfCommand<AgentCreateSpecResult> {
142142

143143
this.log();
144144
this.styledHeader('Agent Details');
145-
const type = (await this.getFlagOrPrompt(flags.type, FLAGGABLE_PROMPTS.type)) as
146-
| 'customer_facing'
147-
| 'employee_facing';
145+
const type = (await this.getFlagOrPrompt(flags.type, FLAGGABLE_PROMPTS.type)) as 'customer' | 'internal';
148146
const role = await this.getFlagOrPrompt(flags.role, FLAGGABLE_PROMPTS.role);
149147
const companyName = await this.getFlagOrPrompt(flags['company-name'], FLAGGABLE_PROMPTS['company-name']);
150148
const companyDescription = await this.getFlagOrPrompt(

src/commands/agent/test/results.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
99
import { Messages } from '@salesforce/core';
10-
import { AgentTester, AgentTestDetailsResponse } from '@salesforce/agents';
10+
import { AgentTester, AgentTestDetailsResponse, humanFormat } from '@salesforce/agents';
1111
import { resultFormatFlag } from '../../../flags.js';
1212

1313
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
@@ -37,8 +37,10 @@ export default class AgentTestResults extends SfCommand<AgentTestResultsResult>
3737
const { flags } = await this.parse(AgentTestResults);
3838

3939
const agentTester = new AgentTester(flags['target-org'].getConnection(flags['api-version']));
40-
const { response, formatted } = await agentTester.details(flags['job-id'], flags['result-format']);
41-
this.log(formatted);
40+
const response = await agentTester.details(flags['job-id']);
41+
if (flags['result-format'] === 'human') {
42+
this.log(await humanFormat(flags['job-id'], response));
43+
}
4244
return response;
4345
}
4446
}

src/commands/agent/test/resume.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
99
import { Messages } from '@salesforce/core';
10-
import { AgentTester } from '@salesforce/agents';
10+
import { AgentTester, humanFormat } from '@salesforce/agents';
1111
import { AgentTestCache } from '../../../agentTestCache.js';
1212
import { TestStages } from '../../../testStages.js';
13+
import { resultFormatFlag } from '../../../flags.js';
1314

1415
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
1516
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.resume');
@@ -46,6 +47,7 @@ export default class AgentTestResume extends SfCommand<AgentTestResumeResult> {
4647
summary: messages.getMessage('flags.wait.summary'),
4748
description: messages.getMessage('flags.wait.description'),
4849
}),
50+
'result-format': resultFormatFlag(),
4951
};
5052

5153
public async run(): Promise<AgentTestResumeResult> {
@@ -61,10 +63,15 @@ export default class AgentTestResume extends SfCommand<AgentTestResumeResult> {
6163
mso.start({ id: aiEvaluationId });
6264
const agentTester = new AgentTester(flags['target-org'].getConnection(flags['api-version']));
6365

64-
const completed = await mso.poll(agentTester, aiEvaluationId, flags.wait);
66+
const { completed, response } = await mso.poll(agentTester, aiEvaluationId, flags.wait);
6567
if (completed) await agentTestCache.removeCacheEntry(aiEvaluationId);
6668

6769
mso.stop();
70+
71+
if (response && flags['result-format'] === 'human') {
72+
this.log(await humanFormat(name ?? aiEvaluationId, response));
73+
}
74+
6875
return {
6976
status: 'COMPLETED',
7077
aiEvaluationId,

src/commands/agent/test/run.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
99
import { Messages } from '@salesforce/core';
10-
import { AgentTester } from '@salesforce/agents';
10+
import { AgentTester, humanFormat } from '@salesforce/agents';
1111
import { colorize } from '@oclif/core/ux';
1212
import { resultFormatFlag } from '../../../flags.js';
1313
import { AgentTestCache } from '../../../agentTestCache.js';
@@ -64,9 +64,14 @@ export default class AgentTestRun extends SfCommand<AgentTestRunResult> {
6464
await agentTestCache.createCacheEntry(response.aiEvaluationId, flags.name);
6565

6666
if (flags.wait?.minutes) {
67-
const completed = await mso.poll(agentTester, response.aiEvaluationId, flags.wait);
67+
const { completed, response: detailsResponse } = await mso.poll(agentTester, response.aiEvaluationId, flags.wait);
6868
if (completed) await agentTestCache.removeCacheEntry(response.aiEvaluationId);
69+
6970
mso.stop();
71+
72+
if (detailsResponse && flags['result-format'] === 'human') {
73+
this.log(await humanFormat(flags.name, detailsResponse));
74+
}
7075
return {
7176
status: 'COMPLETED',
7277
aiEvaluationId: response.aiEvaluationId,

src/flags.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ export const resultFormatFlag = Flags.option({
1818
// 'junit'
1919
] as const,
2020
default: 'human',
21-
char: 'r',
2221
summary: messages.getMessage('flags.result-format.summary'),
2322
});

src/testStages.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { colorize } from '@oclif/core/ux';
99
import { MultiStageOutput } from '@oclif/multi-stage-output';
10-
import { AgentTester } from '@salesforce/agents';
10+
import { AgentTestDetailsResponse, AgentTester } from '@salesforce/agents';
1111
import { Lifecycle } from '@salesforce/core';
1212
import { Duration } from '@salesforce/kit';
1313
import { Ux } from '@salesforce/sf-plugins-core';
@@ -76,7 +76,11 @@ export class TestStages {
7676
this.mso.skipTo('Starting Tests', data);
7777
}
7878

79-
public async poll(agentTester: AgentTester, id: string, wait: Duration): Promise<boolean> {
79+
public async poll(
80+
agentTester: AgentTester,
81+
id: string,
82+
wait: Duration
83+
): Promise<{ completed: boolean; response?: AgentTestDetailsResponse }> {
8084
this.mso.skipTo('Polling for Test Results');
8185
const lifecycle = Lifecycle.getInstance();
8286
lifecycle.on(
@@ -91,16 +95,15 @@ export class TestStages {
9195
);
9296

9397
try {
94-
const { formatted } = await agentTester.poll(id, { timeout: wait });
98+
const response = await agentTester.poll(id, { timeout: wait });
9599
this.stop();
96-
this.ux.log(formatted);
97-
return true;
100+
return { completed: true, response };
98101
} catch (e) {
99102
if (isTimeoutError(e)) {
100103
this.stop('async');
101104
this.ux.log(`Client timed out after ${wait.minutes} minutes.`);
102105
this.ux.log(`Run ${colorize('dim', `sf agent test resume --job-id ${id}`)} to resuming watching this test.`);
103-
return true;
106+
return { completed: true };
104107
} else {
105108
this.error();
106109
throw e;

yarn.lock

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,23 +1344,7 @@
13441344
http-call "^5.2.2"
13451345
lodash "^4.17.21"
13461346

1347-
"@oclif/table@^0.3.2":
1348-
version "0.3.3"
1349-
resolved "https://registry.yarnpkg.com/@oclif/table/-/table-0.3.3.tgz#5dc1c98cfa5415b131d77c85048df187fc241d12"
1350-
integrity sha512-sz6gGT1JAPP743vxl1491hxboIu0ZFHaP3gyvhz5Prgsuljp2NGyyu7JPEMeVImCnZ9N3K9cy3VXxRFEwRH/ig==
1351-
dependencies:
1352-
"@oclif/core" "^4"
1353-
"@types/react" "^18.3.12"
1354-
change-case "^5.4.4"
1355-
cli-truncate "^4.0.0"
1356-
ink "^5.0.1"
1357-
natural-orderby "^3.0.2"
1358-
object-hash "^3.0.0"
1359-
react "^18.3.1"
1360-
strip-ansi "^7.1.0"
1361-
wrap-ansi "^9.0.0"
1362-
1363-
"@oclif/table@^0.3.3":
1347+
"@oclif/table@^0.3.2", "@oclif/table@^0.3.3":
13641348
version "0.3.5"
13651349
resolved "https://registry.yarnpkg.com/@oclif/table/-/table-0.3.5.tgz#118149eab364f3485eab5c9fd0d717c56082bacb"
13661350
integrity sha512-1IjoVz7WAdUdBW5vYIRc6wt9N7Ezwll6AtdmeqLQ8lUmB9gQJVyeb7dqXtUaUvIG7bZMvryfPe6Xibeo5FTCWA==
@@ -1389,10 +1373,10 @@
13891373
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
13901374
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==
13911375

1392-
"@salesforce/agents@^0.2.2":
1393-
version "0.2.2"
1394-
resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.2.2.tgz#c32e35e043f60ae6b4192448984342541bb0fc81"
1395-
integrity sha512-X5HGMHLFqK8rpXrNF4r/dYEdseu//0PnI6oGuWoVwnNPgJ4D0b3iIqTYeznpVEYqOa8wVZdceG2pZXd0GiO+9w==
1376+
"@salesforce/agents@^0.3.0":
1377+
version "0.3.0"
1378+
resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.3.0.tgz#5f58d69eca1dde07daaf88bc2226b1a09e579666"
1379+
integrity sha512-BV/Fa+WN8IT5n+bsdDI8wga5dxjY9Rhu6eAvU3OCyRQ7F0nFd5uqLe2Ybo+0gLbGCvGCrV9gt8eJ5z4fsgLoDQ==
13961380
dependencies:
13971381
"@oclif/table" "^0.3.3"
13981382
"@salesforce/core" "^8.8.0"

0 commit comments

Comments
 (0)