UNPKG

@salesforce/agents

Version:

Client side APIs for working with Salesforce agents

75 lines (74 loc) 2.6 kB
import { Connection, SfProject } from '@salesforce/core'; import { type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig, type AgentOptions } 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?; /** * Create an instance of an agent in an org. Must provide a connection to an org * and the agent (Bot) API name 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[]>; /** * 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>; } /** * Generate an API name from an agent name. Matches what the UI does. */ export declare const generateAgentApiName: (agentName: string) => string;