Skip to content

Commit 8b271a4

Browse files
committed
fix: api changes
1 parent 4c5fc31 commit 8b271a4

File tree

9 files changed

+70
-99
lines changed

9 files changed

+70
-99
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@inquirer/prompts": "^7.2.0",
1010
"@oclif/core": "^4",
1111
"@oclif/multi-stage-output": "^0.7.12",
12-
"@salesforce/agents": "^0.5.9",
12+
"@salesforce/agents": "0.5.10-dev.0",
1313
"@salesforce/core": "^8.8.0",
1414
"@salesforce/kit": "^3.2.1",
1515
"@salesforce/sf-plugins-core": "^12.1.0",

schemas/agent-test-results.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"$ref": "#/definitions/AgentTestResultsResult",
44
"definitions": {
55
"AgentTestResultsResult": {
6-
"$ref": "#/definitions/AgentTestDetailsResponse"
6+
"$ref": "#/definitions/AgentTestResultsResponse"
77
},
8-
"AgentTestDetailsResponse": {
8+
"AgentTestResultsResponse": {
99
"type": "object",
1010
"properties": {
1111
"status": {

src/commands/agent/generate/test-cases.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,18 @@ export function constructTestSetXML(testCases: TestSetInputs[]): string {
134134
<inputs>
135135
<utterance>${testCase.utterance}</utterance>
136136
</inputs>
137-
<expectations>
138-
<expectation>
139-
<name>topic_sequence_match</name>
140-
<expectedValue>${testCase.topicSequenceExpectedValue}</expectedValue>
141-
</expectation>
142-
<expectation>
143-
<name>action_sequence_match</name>
144-
<expectedValue>${`[${testCase.actionSequenceExpectedValue.map((v) => `"${v}"`).join(',')}]`}</expectedValue>
145-
</expectation>
146-
<expectation>
147-
<name>bot_response_rating</name>
148-
<expectedValue>${testCase.botRatingExpectedValue}</expectedValue>
149-
</expectation>
150-
</expectations>
137+
<expectation>
138+
<name>topic_sequence_match</name>
139+
<expectedValue>${testCase.topicSequenceExpectedValue}</expectedValue>
140+
</expectation>
141+
<expectation>
142+
<name>action_sequence_match</name>
143+
<expectedValue>${`[${testCase.actionSequenceExpectedValue.map((v) => `"${v}"`).join(',')}]`}</expectedValue>
144+
</expectation>
145+
<expectation>
146+
<name>bot_response_rating</name>
147+
<expectedValue>${testCase.botRatingExpectedValue}</expectedValue>
148+
</expectation>
151149
</testCase>\n`;
152150
});
153151
xml += '</AiEvaluationTestSet>';

src/commands/agent/test/results.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
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, AgentTestResultsResponse } from '@salesforce/agents';
1111
import { resultFormatFlag, testOutputDirFlag } from '../../../flags.js';
1212
import { handleTestResults } from '../../../handleTestResults.js';
1313

1414
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
1515
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.results');
1616

17-
export type AgentTestResultsResult = AgentTestDetailsResponse;
17+
export type AgentTestResultsResult = AgentTestResultsResponse;
1818

1919
export default class AgentTestResults extends SfCommand<AgentTestResultsResult> {
2020
public static readonly summary = messages.getMessage('summary');
@@ -38,7 +38,7 @@ export default class AgentTestResults extends SfCommand<AgentTestResultsResult>
3838
const { flags } = await this.parse(AgentTestResults);
3939

4040
const agentTester = new AgentTester(flags['target-org'].getConnection(flags['api-version']));
41-
const response = await agentTester.details(flags['job-id']);
41+
const response = await agentTester.results(flags['job-id']);
4242
await handleTestResults({
4343
id: flags['job-id'],
4444
format: flags['result-format'],

src/handleTestResults.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
import { join } from 'node:path';
88
import { writeFile, mkdir } from 'node:fs/promises';
9-
import { AgentTestDetailsResponse, jsonFormat, humanFormat, junitFormat, tapFormat } from '@salesforce/agents';
9+
import { AgentTestResultsResponse, jsonFormat, humanFormat, junitFormat, tapFormat } from '@salesforce/agents';
1010
import { Ux } from '@salesforce/sf-plugins-core/Ux';
1111

1212
async function writeFileToDir(outputDir: string, fileName: string, content: string): Promise<void> {
@@ -25,7 +25,7 @@ export async function handleTestResults({
2525
}: {
2626
id: string;
2727
format: 'human' | 'json' | 'junit' | 'tap';
28-
results: AgentTestDetailsResponse | undefined;
28+
results: AgentTestResultsResponse | undefined;
2929
jsonEnabled: boolean;
3030
outputDir?: string;
3131
}): Promise<void> {

src/read-dir.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
*/
77
import { readdir } from 'node:fs/promises';
88
export async function readDir(path: string): Promise<string[]> {
9-
return (await readdir(path)).filter((bot) => !bot.startsWith('.'));
9+
try {
10+
return (await readdir(path)).filter((bot) => !bot.startsWith('.'));
11+
} catch {
12+
return [];
13+
}
1014
}

src/testStages.ts

Lines changed: 2 additions & 2 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 { AgentTestDetailsResponse, AgentTester } from '@salesforce/agents';
10+
import { AgentTestResultsResponse, AgentTester } from '@salesforce/agents';
1111
import { Lifecycle } from '@salesforce/core';
1212
import { Duration } from '@salesforce/kit';
1313
import { Ux } from '@salesforce/sf-plugins-core';
@@ -80,7 +80,7 @@ export class TestStages {
8080
agentTester: AgentTester,
8181
id: string,
8282
wait: Duration
83-
): Promise<{ completed: boolean; response?: AgentTestDetailsResponse }> {
83+
): Promise<{ completed: boolean; response?: AgentTestResultsResponse }> {
8484
this.mso.skipTo('Polling for Test Results');
8585
const lifecycle = Lifecycle.getInstance();
8686
lifecycle.on(

test/commands/agent/generate/test-cases.test.ts

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -40,60 +40,54 @@ describe('constructTestSetXML', () => {
4040
<inputs>
4141
<utterance>hello</utterance>
4242
</inputs>
43-
<expectations>
44-
<expectation>
45-
<name>topic_sequence_match</name>
46-
<expectedValue>qux</expectedValue>
47-
</expectation>
48-
<expectation>
49-
<name>action_sequence_match</name>
50-
<expectedValue>["foo","bar"]</expectedValue>
51-
</expectation>
52-
<expectation>
53-
<name>bot_response_rating</name>
54-
<expectedValue>baz</expectedValue>
55-
</expectation>
56-
</expectations>
43+
<expectation>
44+
<name>topic_sequence_match</name>
45+
<expectedValue>qux</expectedValue>
46+
</expectation>
47+
<expectation>
48+
<name>action_sequence_match</name>
49+
<expectedValue>["foo","bar"]</expectedValue>
50+
</expectation>
51+
<expectation>
52+
<name>bot_response_rating</name>
53+
<expectedValue>baz</expectedValue>
54+
</expectation>
5755
</testCase>
5856
<testCase>
5957
<number>2</number>
6058
<inputs>
6159
<utterance>goodbye</utterance>
6260
</inputs>
63-
<expectations>
64-
<expectation>
65-
<name>topic_sequence_match</name>
66-
<expectedValue>qux</expectedValue>
67-
</expectation>
68-
<expectation>
69-
<name>action_sequence_match</name>
70-
<expectedValue>["foo","bar"]</expectedValue>
71-
</expectation>
72-
<expectation>
73-
<name>bot_response_rating</name>
74-
<expectedValue>baz</expectedValue>
75-
</expectation>
76-
</expectations>
61+
<expectation>
62+
<name>topic_sequence_match</name>
63+
<expectedValue>qux</expectedValue>
64+
</expectation>
65+
<expectation>
66+
<name>action_sequence_match</name>
67+
<expectedValue>["foo","bar"]</expectedValue>
68+
</expectation>
69+
<expectation>
70+
<name>bot_response_rating</name>
71+
<expectedValue>baz</expectedValue>
72+
</expectation>
7773
</testCase>
7874
<testCase>
7975
<number>3</number>
8076
<inputs>
8177
<utterance>how are you</utterance>
8278
</inputs>
83-
<expectations>
84-
<expectation>
85-
<name>topic_sequence_match</name>
86-
<expectedValue>qux</expectedValue>
87-
</expectation>
88-
<expectation>
89-
<name>action_sequence_match</name>
90-
<expectedValue>["foo","bar"]</expectedValue>
91-
</expectation>
92-
<expectation>
93-
<name>bot_response_rating</name>
94-
<expectedValue>baz</expectedValue>
95-
</expectation>
96-
</expectations>
79+
<expectation>
80+
<name>topic_sequence_match</name>
81+
<expectedValue>qux</expectedValue>
82+
</expectation>
83+
<expectation>
84+
<name>action_sequence_match</name>
85+
<expectedValue>["foo","bar"]</expectedValue>
86+
</expectation>
87+
<expectation>
88+
<name>bot_response_rating</name>
89+
<expectedValue>baz</expectedValue>
90+
</expectation>
9791
</testCase>
9892
</AiEvaluationTestSet>`);
9993
});

yarn.lock

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,10 +1507,10 @@
15071507
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
15081508
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==
15091509

1510-
"@salesforce/agents@^0.5.9":
1511-
version "0.5.9"
1512-
resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.5.9.tgz#1e79c894b8cbfaab32379a5bbab653faca631aac"
1513-
integrity sha512-6GF5rX356sjGURsOCok1mIzj6u79m/TqpQ9IXlSxxPbtfGXBxddNN32+LOgKwrmszLNwI5kmKRDYbZgWK3G6Lw==
1510+
"@salesforce/agents@0.5.10-dev.0":
1511+
version "0.5.10-dev.0"
1512+
resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.5.10-dev.0.tgz#733a3d66d9a56acef3a731f3b879a05180fa17ce"
1513+
integrity sha512-7u6x7Ufb/P406wswpJVBzpZBMWK6DE4Ib0WAwlIfL86QpQg555jJatyov1ekKQLizhr/+hKszF7lqv/cXdk4qw==
15141514
dependencies:
15151515
"@salesforce/core" "^8.8.0"
15161516
"@salesforce/kit" "^3.2.3"
@@ -7930,16 +7930,7 @@ stack-utils@^2.0.6:
79307930
dependencies:
79317931
escape-string-regexp "^2.0.0"
79327932

7933-
"string-width-cjs@npm:string-width@^4.2.0":
7934-
version "4.2.3"
7935-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
7936-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
7937-
dependencies:
7938-
emoji-regex "^8.0.0"
7939-
is-fullwidth-code-point "^3.0.0"
7940-
strip-ansi "^6.0.1"
7941-
7942-
string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
7933+
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
79437934
version "4.2.3"
79447935
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
79457936
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -8061,14 +8052,7 @@ string_decoder@~1.1.1:
80618052
dependencies:
80628053
safe-buffer "~5.1.0"
80638054

8064-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
8065-
version "6.0.1"
8066-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
8067-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
8068-
dependencies:
8069-
ansi-regex "^5.0.1"
8070-
8071-
strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1:
8055+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1:
80728056
version "6.0.1"
80738057
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
80748058
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -8742,7 +8726,7 @@ workerpool@^6.5.1:
87428726
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544"
87438727
integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==
87448728

8745-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
8729+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
87468730
version "7.0.0"
87478731
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
87488732
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -8760,15 +8744,6 @@ wrap-ansi@^6.2.0:
87608744
string-width "^4.1.0"
87618745
strip-ansi "^6.0.0"
87628746

8763-
wrap-ansi@^7.0.0:
8764-
version "7.0.0"
8765-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
8766-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
8767-
dependencies:
8768-
ansi-styles "^4.0.0"
8769-
string-width "^4.1.0"
8770-
strip-ansi "^6.0.0"
8771-
87728747
wrap-ansi@^8.1.0:
87738748
version "8.1.0"
87748749
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)