Skip to content

Commit

Permalink
feat: add command stub for agent run test
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Oct 29, 2024
1 parent 80985ac commit 934ee67
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 71 deletions.
33 changes: 33 additions & 0 deletions messages/agent.test.start.md
Original file line number Diff line number Diff line change
@@ -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
29 changes: 0 additions & 29 deletions messages/hello.world.md

This file was deleted.

65 changes: 65 additions & 0 deletions src/commands/agent/run/test.ts
Original file line number Diff line number Diff line change
@@ -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<AgentRunTestResult> {
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<AgentRunTestResult> {
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
};
}
}
42 changes: 0 additions & 42 deletions src/commands/hello/world.ts

This file was deleted.

0 comments on commit 934ee67

Please sign in to comment.