@salesforce/agents
Version:
Client side APIs for working with Salesforce agents
72 lines (71 loc) • 2.4 kB
TypeScript
import { Connection } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { type AgentTestStartResponse, type AgentTestStatusResponse, type AgentTestResultsResponse } from './types.js';
/**
* A service for testing agents using `AiEvaluationDefinition` metadata. Start asynchronous
* test runs, get or poll for test status, and get detailed test results.
*
* **Examples**
*
* Create an instance of the service:
*
* `const agentTester = new AgentTester(connection);`
*
* Start a test run:
*
* `const startResponse = await agentTester.start(aiEvalDef);`
*
* Get the status for a test run:
*
* `const status = await agentTester.status(startResponse.runId);`
*
* Get detailed results for a test run:
*
* `const results = await agentTester.results(startResponse.runId);`
*/
export declare class AgentTester {
private maybeMock;
constructor(connection: Connection);
/**
* Initiates a test run (i.e., AI evaluation).
*
* @param aiEvalDefName - The name of the AI evaluation definition to run.
* @returns Promise that resolves with the response from starting the test.
*/
start(aiEvalDefName: string): Promise<AgentTestStartResponse>;
/**
* Get the status of a test run.
*
* @param {string} jobId
* @returns {Promise<AgentTestStatusResponse>}
*/
status(jobId: string): Promise<AgentTestStatusResponse>;
/**
* Poll the status of a test run until the tests are complete or the timeout is reached.
*
* @param {string} jobId
* @param {Duration} timeout
* @returns {Promise<AgentTestResultsResponse>}
*/
poll(jobId: string, { timeout }?: {
timeout?: Duration;
}): Promise<AgentTestResultsResponse>;
/**
* Get detailed test run results.
*
* @param {string} jobId
* @returns {Promise<AgentTestResultsResponse>}
*/
results(jobId: string): Promise<AgentTestResultsResponse>;
/**
* Cancel an in-progress test run.
*
* @param {string} jobId
* @returns {Promise<{success: boolean}>}
*/
cancel(jobId: string): Promise<{
success: boolean;
}>;
}
/** Decodes HTML entities in test result fields (utterance, actionsSequence, actualValue, expectedValue, metricExplainability). */
export declare function normalizeResults(results: AgentTestResultsResponse): AgentTestResultsResponse;