@salesforce/agents
Version:
Client side APIs for working with Salesforce agents
58 lines (57 loc) • 2.65 kB
TypeScript
import { Connection } from '@salesforce/core';
export declare const metric: readonly ["completeness", "coherence", "conciseness", "output_latency_milliseconds"];
/**
* Sanitize a filename by removing or replacing illegal characters.
* This ensures the filename is valid across different operating systems.
*
* @param filename - The filename to sanitize
* @returns A sanitized filename safe for use across operating systems
*/
export declare const sanitizeFilename: (filename: string) => string;
/**
* Clean a string by replacing HTML entities with their respective characters.
*
* @param str - The string to clean.
* @returns The cleaned string with all HTML entities replaced with their respective characters.
*/
export declare const decodeHtmlEntities: (str?: string) => string;
/**
* Find the authoring bundle directory for a given bot name by recursively searching from a starting directory or directories.
*
* @param dirOrDirs - The directory or array of directories to start searching from
* @param botName - The name of the bot to find the authoring bundle directory for
* @returns The path to the authoring bundle directory if found, undefined otherwise
*/
export declare const findAuthoringBundle: (dirOrDirs: string | string[], botName: string) => string | undefined;
/**
* Find all local agent files in a directory by recursively searching for files ending with '.agent'
*
* @param dir - The directory to start searching from
* @returns Array of paths to agent files
*/
export declare const findLocalAgents: (dir: string) => string[];
export declare const useNamedUserJwt: (connection: Connection) => Promise<Connection>;
export type TranscriptRole = 'user' | 'agent';
export type TranscriptEntry = {
timestamp: string;
agentId: string;
sessionId: string;
role: TranscriptRole;
text?: string;
raw?: any;
reason?: string;
};
/**
* Append a transcript entry to the last conversation JSON file under the project local .sfdx folder.
* If the entry has event: 'start', this will clear the previous conversation and start fresh.
* Path: <project>/.sfdx/agents/conversations/<agentId>/history.json
*/
export declare const appendTranscriptEntry: (entry: TranscriptEntry, newSession?: boolean) => Promise<void>;
/**
* Read and parse the last conversation's transcript entries from JSON.
* Path: <project>/.sfdx/agents/conversations/<agentId>/history.json
*
* @param agentId The agent's API name (developerName)
* @returns Array of TranscriptEntry in file order (chronological append order).
*/
export declare const readTranscriptEntries: (agentId: string) => Promise<TranscriptEntry[]>;