@salesforce/agents
Version:
Client side APIs for working with Salesforce agents
84 lines (83 loc) • 3.21 kB
TypeScript
import { Connection, SfProject } from '@salesforce/core';
import { type AgentJson, type PublishAgent } from './types.js';
/**
* Service class responsible for publishing agents to Salesforce orgs
*/
export declare class AgentPublisher {
private readonly maybeMock;
private connection;
private project;
private agentJson;
private developerName;
private bundleMetaPath;
private bundleDir;
private API_URL;
private readonly API_HEADERS;
/**
* Creates a new AgentPublisher instance
*
* @param connection The connection to the Salesforce org
* @param project The Salesforce project
*/
constructor(connection: Connection, project: SfProject, agentJson: AgentJson);
/**
* Publish an AgentJson representation to the org
*
* @returns Promise<PublishAgent> The publish response
*/
publishAgentJson(): Promise<PublishAgent>;
/**
* Validates and extracts the developer name from the agent configuration,
* and locates the corresponding authoring bundle directory and metadata file.
*
* @returns An object containing:
* - developerName: The cleaned developer name without version suffixes
* - bundleDir: The path to the authoring bundle directory
* - bundleMetaPath: The full path to the bundle-meta.xml file
*
* @throws SfError if the authoring bundle directory or metadata file cannot be found
*/
private validateDeveloperName;
/**
* Retrieve the agent metadata from the org after publishing
*
* @param developerName The developer name of the agent
* @param originalConnection The original connection to use for retrieval
*/
private retrieveAgentMetadata;
/**
* Synchronizes the authoring bundle by deploying it twice due to server-side validation requirements.
*
* Due to a server side validation constraint, the authoring bundle (AAB) must be deployed twice:
* 1. First deployment without target attribute creates the AAB as a draft version
* 2. Second deployment with target attribute commits the AAB as the published version
*
* @param botVersionName The bot version name to use as the target for the final published deployment
* @private
*/
private syncAuthoringBundle;
/**
* Deploys the authoring bundle to the Salesforce org after setting the correct target attribute if provided.
* The target attribute is required for deployment but should not remain in the
* local source files after deployment.
*
* @param botVersionId The bot version ID used to construct the target attribute
*
* @throws SfError if the deployment fails or if there are component deployment errors
*/
private deployAuthoringBundle;
/**
* Returns the ID for the published bot.
*
* @param agentApiName The agent API name
* @returns The ID for the published bot
*/
private getPublishedBotId;
/**
* Returns the developerName of the given bot version ID.
*
* @param botVersionId The Id of the bot version
* @returns The developer name of the bot version
*/
private getVersionDeveloperName;
}