diff --git a/messages/agent.test.start.md b/messages/agent.test.start.md new file mode 100644 index 0000000..4b73b25 --- /dev/null +++ b/messages/agent.test.start.md @@ -0,0 +1,33 @@ +# summary + +Start a test for an Agent. + +# description + +Start a test for an Agent, providing the AiEvalDefinitionVersion ID. Returns the job ID. + +# flags.id.summary + +The AiEvalDefinitionVersion ID. + +# flags.id.description + +The AiEvalDefinitionVersion ID. + +# flags.wait.summary + +Number of minutes to wait for the command to complete and display results to the terminal window. + +# flags.wait.description + +If the command continues to run after the wait period, the CLI returns control of the terminal window to you. + +# flags.output-dir.summary + +Directory in which to store test run files. + +# examples + +- Start a test for an Agent: + + <%= config.bin %> <%= command.id %> --id AiEvalDefVerId diff --git a/messages/hello.world.md b/messages/hello.world.md deleted file mode 100644 index 804f848..0000000 --- a/messages/hello.world.md +++ /dev/null @@ -1,29 +0,0 @@ -# summary - -Say hello. - -# description - -Say hello either to the world or someone you know. - -# flags.name.summary - -The name of the person you'd like to say hello to. - -# flags.name.description - -This person can be anyone in the world! - -# examples - -- Say hello to the world: - - <%= config.bin %> <%= command.id %> - -- Say hello to someone you know: - - <%= config.bin %> <%= command.id %> --name Astro - -# info.hello - -Hello %s at %s. diff --git a/src/commands/agent/run/test.ts b/src/commands/agent/run/test.ts new file mode 100644 index 0000000..ee5c1af --- /dev/null +++ b/src/commands/agent/run/test.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; +import { Messages } from '@salesforce/core'; + +Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); +const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.start'); + +export type AgentRunTestResult = { + buildVersion: number; + jobId: string; + errorRepresentation?: string; +}; + +export default class AgentRunTest extends SfCommand { + public static readonly summary = messages.getMessage('summary'); + public static readonly description = messages.getMessage('description'); + public static readonly examples = messages.getMessages('examples'); + + public static readonly flags = { + 'target-org': Flags.requiredOrg(), + // AiEvalDefinitionVersion.Id -- This should really be "test-name" + id: Flags.string({ + char: 'i', + required: true, + summary: messages.getMessage('flags.id.summary'), + description: messages.getMessage('flags.id.description'), + }), + wait: Flags.duration({ + char: 'w', + unit: 'minutes', + min: 1, + summary: messages.getMessage('flags.wait.summary'), + description: messages.getMessage('flags.wait.description'), + }), + 'output-dir': Flags.directory({ + char: 'd', + summary: messages.getMessage('flags.output-dir.summary'), + }), + // + // Future flags: + // result-format [csv, json, table, junit, TAP] + // suites [array of suite names] + // verbose [boolean] + // ??? api-version or build-version ??? + }; + + public async run(): Promise { + const { flags } = await this.parse(AgentRunTest); + + this.log(`Starting tests for AiEvalDefinitionVersion: ${flags.id}`); + + // Call SF Eval Connect API passing AiEvalDefinitionVersion.Id + + return { + buildVersion: 62.0, // looks like API version + jobId: '4KBSM000000003F4AQ', // evaluationJobId; needed for getting status and stopping + }; + } +} diff --git a/src/commands/hello/world.ts b/src/commands/hello/world.ts deleted file mode 100644 index 5b46ef5..0000000 --- a/src/commands/hello/world.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021, salesforce.com, inc. - * All rights reserved. - * Licensed under the BSD 3-Clause license. - * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause - */ - -import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; -import { Messages } from '@salesforce/core'; - -Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); -const messages = Messages.loadMessages('@salesforce/plugin-agent', 'hello.world'); - -export type HelloWorldResult = { - name: string; - time: string; -}; - -export default class World extends SfCommand { - public static readonly summary = messages.getMessage('summary'); - public static readonly description = messages.getMessage('description'); - public static readonly examples = messages.getMessages('examples'); - - public static readonly flags = { - name: Flags.string({ - char: 'n', - summary: messages.getMessage('flags.name.summary'), - description: messages.getMessage('flags.name.description'), - default: 'World', - }), - }; - - public async run(): Promise { - const { flags } = await this.parse(World); - const time = new Date().toDateString(); - this.log(messages.getMessage('info.hello', [flags.name, time])); - return { - name: flags.name, - time, - }; - } -}