@salesforce/agents
Version:
Client side APIs for working with Salesforce agents
115 lines (114 loc) • 4.65 kB
TypeScript
import { Connection } from '@salesforce/core';
import { DeployResult } from '@salesforce/source-deploy-retrieve';
import { AvailableDefinition, AgentTestConfig, AiEvaluationDefinition, TestSpec } from './types.js';
/**
* Events emitted during agent test creation for consumers to listen to and keep track of progress.
*/
export declare const AgentTestCreateLifecycleStages: {
CreatingLocalMetadata: string;
Waiting: string;
DeployingMetadata: string;
Done: string;
};
/**
* A client side representation of an agent test (AiEvaluationDefinition) within an org.
* Also provides utilities such as creating and listing agent tests, and converting between
* agent test spec and AiEvaluationDefinition.
*
* **Examples**
*
* Create a new instance from an agent test spec:
*
* `const agentTest = new AgentTest({ specPath: path/to/specfile });`
*
* Get the metadata content of an agent test:
*
* `const metadataContent = await agentTest.getMetadata();`
*
* Write the metadata content to a file:
*
* `await agentTest.writeMetadata('path/to/metadataFile');`
*/
export declare class AgentTest {
private config;
private specData?;
private data?;
/**
* Create an AgentTest based on one of:
*
* 1. AiEvaluationDefinition API name.
* 2. Path to a local AiEvaluationDefinition metadata file.
* 3. Path to a local agent test spec file.
* 4. Agent test spec data.
*
* @param config AgentTestConfig
*/
constructor(config: AgentTestConfig);
/**
* List the AiEvaluationDefinitions available in the org.
*/
static list(connection: Connection): Promise<AvailableDefinition[]>;
/**
* Creates and deploys an AiEvaluationDefinition from a specification file.
*
* @param connection - Connection to the org where the agent test will be created.
* @param apiName - The API name of the AiEvaluationDefinition to create
* @param specFilePath - The path to the specification file to create the definition from
* @param options - Configuration options for creating the definition
* @param options.outputDir - The directory where the AiEvaluationDefinition file will be written
* @param options.preview - If true, writes the AiEvaluationDefinition file to <api-name>-preview-<timestamp>.xml in the current working directory and does not deploy it
*
* @returns Promise containing:
* - path: The filesystem path to the created AiEvaluationDefinition file
* - contents: The AiEvaluationDefinition contents as a string
* - deployResult: The deployment result (if not in preview mode)
*
* @throws {SfError} When deployment fails
*/
static create(connection: Connection, apiName: string, specFilePath: string, options: {
outputDir: string;
preview?: boolean;
}): Promise<{
path: string;
contents: string;
deployResult?: DeployResult;
}>;
/**
* Get the specification for this agent test.
*
* Returns the test spec data if already generated. Otherwise it will generate the spec by:
*
* 1. Read from an existing local spec file.
* 2. Read from an existing local AiEvaluationDefinition metadata file and convert it.
* 3. Use the provided org connection to read the remote AiEvaluationDefinition metadata.
*
* @param connection Org connection to use if this AgentTest only has an AiEvaluationDefinition API name.
* @returns Promise<TestSpec>
*/
getTestSpec(connection?: Connection): Promise<TestSpec>;
/**
* Get the metadata content for this agent test.
*
* Returns the AiEvaluationDefinition metadata if already generated. Otherwise it will get it by:
*
* 1. Read from an existing local AiEvaluationDefinition metadata file.
* 2. Read from an existing local spec file and convert it.
* 3. Use the provided org connection to read the remote AiEvaluationDefinition metadata.
*
* @param connection Org connection to use if this AgentTest only has an AiEvaluationDefinition API name.
* @returns Promise<TestSpec>
*/
getMetadata(connection?: Connection): Promise<AiEvaluationDefinition>;
/**
* Write a test specification file in YAML format.
*
* @param outputFile The file path where the YAML test spec should be written.
*/
writeTestSpec(outputFile: string): Promise<void>;
/**
* Write AiEvaluationDefinition metadata file.
*
* @param outputFile The file path where the metadata file should be written.
*/
writeMetadata(outputFile: string): Promise<void>;
}