@salesforce/agents
Version:
Client side APIs for working with Salesforce agents
107 lines (106 loc) • 3.43 kB
TypeScript
import { Connection, SfProject } from '@salesforce/core';
import { type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig, type AgentOptions, type BotMetadata, type BotVersionMetadata } from './types.js';
/**
* Events emitted during Agent.create() for consumers to listen to and keep track of progress
*
* @type {{Creating: string, Previewing: string, Retrieving: string}}
*/
export declare const AgentCreateLifecycleStages: {
Creating: string;
Previewing: string;
Retrieving: string;
};
/**
* A client side representation of an agent within an org. Also provides utilities
* such as creating agents, listing agents, and creating agent specs.
*
* **Examples**
*
* Create a new instance and get the ID (uses the `Bot` ID):
*
* `const id = new Agent({connection, name}).getId();`
*
* Create a new agent in the org:
*
* `const myAgent = await Agent.create(connection, project, options);`
*
* List all agents in the local project:
*
* `const agentList = await Agent.list(project);`
*/
export declare class Agent {
private options;
private id?;
private name?;
private botMetadata?;
/**
* Create an instance of an agent in an org. Must provide a connection to an org
* and the agent (Bot) API name or ID as part of `AgentOptions`.
*
* @param {options} AgentOptions
*/
constructor(options: AgentOptions);
/**
* List all agents in the current project.
*
* @param project a `SfProject` for a local DX project.
*/
static list(project: SfProject): Promise<string[]>;
/**
* Lists all agents in the org.
*
* @param connection a `Connection` to an org.
* @returns the list of agents
*/
static listRemote(connection: Connection): Promise<BotMetadata[]>;
/**
* Creates an agent from a configuration, optionally saving the agent in an org.
*
* @param connection a `Connection` to an org.
* @param project a `SfProject` for a local DX project.
* @param config a configuration for creating or previewing an agent.
* @returns the agent definition
*/
static create(connection: Connection, project: SfProject, config: AgentCreateConfig): Promise<AgentCreateResponse>;
/**
* Create an agent spec from provided data.
*
* @param connection a `Connection` to an org.
* @param config The configuration used to generate an agent spec.
* @returns the agent job spec
*/
static createSpec(connection: Connection, config: AgentJobSpecCreateConfig): Promise<AgentJobSpec>;
/**
* Returns the ID for this agent.
*
* @returns The ID of the agent (The `Bot` ID).
*/
getId(): Promise<string>;
/**
* Queries BotDefinition and BotVersions (limited to 10) for the bot metadata and assigns:
* 1. this.id
* 2. this.name
* 3. this.botMetadata
* 4. this.botVersionMetadata
*/
getBotMetadata(): Promise<BotMetadata>;
/**
* Returns the latest bot version metadata.
*
* @returns the latest bot version metadata
*/
getLatestBotVersionMetadata(): Promise<BotVersionMetadata>;
/**
* Activates the agent.
*
* @returns void
*/
activate(): Promise<void>;
/**
* Deactivates the agent.
*
* @returns void
*/
deactivate(): Promise<void>;
private setAgentStatus;
}