import type * as ElevenLabs from "../../../api/index"; import { Tool } from "../tools/Tool"; import { Workflow } from "../workflow/Workflow"; import { type AgentIssue } from "./errors"; import { type WireObject } from "./wire"; type AgentFields = NonNullable; type PromptFields = NonNullable; type TtsFields = NonNullable; /** The settings an agent can be given in code. Every field is optional, so `update()` takes the same shape. */ export interface AgentOptions { /** The agent's instructions: `conversation_config.agent.prompt.prompt`. */ prompt?: PromptFields["prompt"]; /** What the agent says first: `conversation_config.agent.first_message`. */ firstMessage?: AgentFields["firstMessage"]; /** `conversation_config.agent.language`, e.g. `"en"`. */ language?: AgentFields["language"]; /** `conversation_config.agent.prompt.llm`. */ llm?: PromptFields["llm"]; /** `conversation_config.agent.prompt.temperature`. */ temperature?: PromptFields["temperature"]; /** `conversation_config.tts.voice_id`. */ voiceId?: TtsFields["voiceId"]; /** `conversation_config.tts.model_id`. */ ttsModel?: TtsFields["modelId"]; tags?: string[]; /** * Tools the agent can use anywhere. Webhook and client tools are created or updated by `agents.push()` and * attached by id; system tools go into `prompt.built_in_tools`. Replaces the agent's tools on `update()`. */ tools?: Tool[]; /** Ids of existing tools to attach as they are. `agents.push()` doesn't create or change them. */ toolIds?: string[]; /** The agent's workflow. Its tool nodes can take `Tool` objects, which `agents.push()` manages too. */ workflow?: Workflow; /** * Any other conversation settings, merged under the typed options above. Setting a field here that a typed option * also sets is reported by `validate()`. */ conversationConfig?: ElevenLabs.ConversationalConfig; /** Platform settings (privacy, evaluation, widget...), merged the same way. */ platformSettings?: ElevenLabs.AgentPlatformSettingsRequestModel; } export interface AgentValidateOptions { /** Called for each non-fatal problem, such as an agent without a prompt. */ onWarning?: (issue: AgentIssue) => void; } export interface AgentBuildOptions extends AgentValidateOptions { /** * The id of each webhook and client tool the agent uses, by tool name. `agents.push()` passes these after creating * or updating the tools. Every such tool needs one. */ toolIds?: Record; } export interface AgentLoadOptions { /** * Tools the config refers to, by id. Each matching webhook or client tool becomes a `Tool` the agent manages; the * other ids, including tools of other kinds such as `mcp`, stay as `toolIds`. */ toolsById?: Record | Map; } /** * An agent, written as code: its settings, its tools and its workflow in one definition. Push it with * `client.conversationalAi.agents.push(agent)`, which creates or updates the tools and the agent together. * * @example * const agent = new Agent("Support line", { * prompt: "You are a support agent for Acme.", * firstMessage: "Hi, how can I help?", * tools: [Tool.endCall(), getOrder], * workflow: wf, * }); * const { agentId } = await client.conversationalAi.agents.push(agent); */ export declare class Agent { private _name; private readonly _typed; private _tags; private _tools; private _toolIds; private _workflow; /** A loaded workflow nobody has edited yet, kept in API format so it round-trips exactly. */ private _rawWorkflow; private _toolsById; /** The loaded `tool_ids`, so a loaded agent keeps its tool order. */ private _loadedToolIds; /** Whether `tools` or `toolIds` was given (even empty), so the agent sets `tool_ids` rather than leaving it alone. */ private _toolListGiven; /** Loaded system tools with their config as loaded, sent as-is while the tool is unchanged. */ private readonly _loadedSystem; /** Settings loaded from a config, in API format. Typed options and raw options are applied on top. */ private _base; private _rawConversationConfig; private _rawPlatformSettings; constructor(name: string, options?: AgentOptions); /** * Loads an agent config in API format (snake_case): a CLI `agent_configs/*.json` file, or the `toJSON()` of an * agent. Webhook and client tools found in `toolsById` become `Tool` objects the agent manages; the other ids, * including tools of other kinds such as `mcp`, stay as `toolIds`. Fields this SDK doesn't model are kept, so an * unedited agent round-trips exactly. */ static fromJSON(json: string | object, options?: AgentLoadOptions): Agent; /** The agent's name. */ get name(): string; /** * The agent's workflow, or `undefined` if it has none. A loaded workflow is turned into a `Workflow` the first time * it's read here, with its tool ids swapped for the `Tool` objects the agent knows, so it can be edited. */ get workflow(): Workflow | undefined; /** Changes the agent. Typed options replace what was there; `conversationConfig` and `platformSettings` merge. */ update(options: AgentOptions & { name?: string; }): this; /** Adds a tool the agent can use anywhere. */ addTool(tool: Tool): this; /** * Every webhook and client tool the agent and its workflow use, each once: the tools `agents.push()` creates or * updates. System tools aren't included; they live inside the agent's config. Nor are tools of other kinds (such * as `mcp`): they stay attached by the id the agent was loaded with, as pull leaves them. */ tools(): Tool[]; /** * The id the agent was loaded with for `tool` (`toolsById`; a project passes its `tools.json` ids this way). Tools * of kinds push doesn't manage stay attached by it. */ private _knownId; private _workflowTools; /** The ids of existing tools attached as they are, which `agents.push()` doesn't manage. */ get toolIds(): string[]; /** * Checks everything that doesn't need tool ids: the tools, the workflow, the settings, and that no two tools share * a name. CI can run this without an API key. * * @throws {AgentValidationError} listing every problem, if the agent is invalid */ validate(options?: AgentValidateOptions): void; /** * Validates the agent and returns it in the shape `agents.create()` accepts (`agents.update()` takes the same * fields). Fields this SDK doesn't model are dropped by the generated client; `agents.push()` sends them too. * * @throws {AgentValidationError} listing every problem, if the agent is invalid or a tool has no id */ build(options?: AgentBuildOptions): ElevenLabs.conversationalAi.BodyCreateAgentV1ConvaiAgentsCreatePost; /** * The agent config in API format (snake_case keys, sorted at every level): the shape of a CLI * `agent_configs/*.json` file. Validates like `build()`, and also needs every tool's id. */ toJSON(options?: AgentBuildOptions): Record; /** * Builds the API-format config. Without `toolIds` (validation only), tools stand under placeholder ids and missing * ids aren't reported. */ private _assemble; } /** Replaces the tool ids in an API-format workflow's tool nodes and subagents, in place. */ export declare function mapRawWorkflowToolIds(workflow: WireObject, map: (id: string) => string): WireObject; /** The tool ids an API-format workflow's nodes use. */ export declare function rawWorkflowToolIds(workflow: WireObject | undefined): string[]; export {};