import type * as ElevenLabs from "../../../api/index"; import type { Destination } from "../workflow/Destination"; import { type ToolIssue } from "./errors"; import type { AuthConnection, Header } from "./Header"; import { type ObjectSchema, Schema } from "./Schema"; export type ToolKind = "webhook" | "client" | "system" | "other"; /** Options every kind of tool accepts. */ export interface CommonToolOptions { /** What the LLM calls the tool by. */ name?: string; /** When the tool should be used and what it does. */ description?: string; /** Seconds to wait for the tool to finish. */ responseTimeoutSecs?: number; interruptionMode?: ElevenLabs.ToolInterruptionMode; preToolSpeech?: ElevenLabs.PreToolSpeechMode; toolCallSound?: ElevenLabs.ToolCallSoundType; toolCallSoundBehavior?: ElevenLabs.ToolCallSoundBehavior; toolErrorHandlingMode?: ElevenLabs.ToolErrorHandlingMode; } export interface WebhookToolOptions extends CommonToolOptions { /** Placeholder values for the dynamic variables the tool uses. */ dynamicVariablePlaceholders?: Record; executionMode?: ElevenLabs.ToolExecutionMode; contentType?: ElevenLabs.WebhookToolApiSchemaConfigInputContentType; responseFilter?: ElevenLabs.ResponseFilter; followRedirects?: boolean; followRedirectsAllowedDomains?: string[]; } export interface ClientToolOptions extends CommonToolOptions { /** Placeholder values for the dynamic variables the tool uses. */ dynamicVariablePlaceholders?: Record; executionMode?: ElevenLabs.ToolExecutionMode; /** Wait for the client to respond, and pass its response to the LLM. */ expectsResponse?: boolean; } export type SystemToolOptions = CommonToolOptions; export interface AssignOptions { /** Remove the value from the tool response before the LLM and the transcript see it. */ sanitize?: boolean; /** Store lists and objects as they are instead of as JSON strings. */ preserveNativeType?: boolean; } /** Options for one entry of a transfer system tool. The first group applies to phone/SIP, the second to agents. */ export interface SystemTransferOptions { transferType?: ElevenLabs.TransferTypeEnum; customSipHeaders?: ElevenLabs.PhoneNumberTransferCustomSipHeadersItem[]; sipReferPlayDialtone?: boolean; uui?: ElevenLabs.UuiTransferConfig; postDialDigits?: ElevenLabs.PhoneNumberTransferPostDialDigits; delayMs?: number; transferMessage?: string; enableTransferredAgentFirstMessage?: boolean; preserveClientTtsOverrides?: boolean; preserveVoiceSettings?: boolean; } export interface ToolBuildOptions { /** Called for each non-fatal problem, such as a param with no description. */ onWarning?: (issue: ToolIssue) => void; } type ToolConfig = ElevenLabs.ToolRequestModelToolConfig; type Model = Record; /** * An agent tool, written as code. Create one with `Tool.webhook()`, `Tool.client()` or a `SystemTool` constructor, * or load one with `Tool.fromJSON()` / `Tool.fromResponse()`. */ export declare abstract class Tool { /** `"webhook"`, `"client"`, `"system"`, or `"other"` for a loaded tool of a type this SDK can't edit. */ abstract readonly kind: ToolKind; /** @internal The tool config, except the parts subclasses keep in their own fields. */ protected _config: Model; /** @internal Problems found while building, reported by `build()`. */ protected readonly _issues: ToolIssue[]; /** @internal */ protected constructor(config: Model); /** A tool the server runs by calling an HTTP endpoint. Set the method and URL with `get()`, `post()`... */ static webhook(name: string, description: string): WebhookTool; /** A tool that sends an event to the user's client. */ static client(name: string, description: string): ClientTool; /** * Loads a tool stored in API format (snake_case), for example from `toJSONString()` or a CLI * `tool_configs/*.json` file. Accepts a JSON string or a parsed object: a tool config, or a request or response * with a `tool_config` key. */ static fromJSON(json: string | object): Tool; /** Loads the result of `tools.get()`. */ static fromResponse(response: ElevenLabs.ToolResponseModel): Tool; /** The tool's name, as the LLM sees it. */ get name(): string; /** Merges options for this kind of tool. A key that doesn't apply is reported by `build()`. */ options(options: CommonToolOptions): this; /** This tool as a `WebhookTool`, or `undefined` if it's another kind. */ asWebhook(): WebhookTool | undefined; /** This tool as a `ClientTool`, or `undefined` if it's another kind. */ asClient(): ClientTool | undefined; /** This tool as a `SystemTool`, or `undefined` if it's another kind. */ asSystem(): SystemTool | undefined; /** * Validates the tool and returns it in the shape `tools.create()` and `tools.update()` accept. * * @throws {ToolValidationError} listing every problem, if the tool is invalid */ build(options?: ToolBuildOptions): ElevenLabs.ToolRequestModel; /** * Validates the tool and returns only its config: for a system tool, its entry in `prompt.builtInTools`. * Create webhook and client tools with `tools.create(tool.build())` and attach them by id in `prompt.toolIds`; * the inline `prompt.tools` field is deprecated, and replaces `builtInTools` with the system tools it contains. * * @throws {ToolValidationError} listing every problem, if the tool is invalid */ buildConfig(options?: ToolBuildOptions): ToolConfig; /** * The tool config in API format (snake_case keys, sorted at every level), the shape of a CLI * `tool_configs/*.json` file. Validates like `build()`. Also what `JSON.stringify(tool)` uses. */ toJSON(): Record; /** `toJSON()` as a string with 2-space indentation and a trailing newline: the canonical file format. */ toJSONString(): string; /** @internal */ protected abstract _allowedOptions(): string[]; /** @internal */ protected _setOption(key: string, value: unknown): void; /** @internal Problems that need the finished tool. */ protected abstract _validate(): ToolIssue[]; /** @internal */ protected abstract _toModel(): ToolConfig; } /** A tool the server runs by calling an HTTP endpoint. */ export declare class WebhookTool extends Tool { readonly kind: "webhook"; /** The `api_schema` fields not kept below: url, method, auth, content type and so on. */ private _api; private readonly _pathParams; private _query; private _body; private _response; private readonly _headers; /** @internal */ constructor(config: Model, api: Model); /** @internal */ static load(config: Model, apiSchema?: Model): WebhookTool; /** Sends a `GET` to `url`. `{name}` placeholders in the URL are filled from path params. */ get(url: string): this; /** Sends a `POST` to `url`. */ post(url: string): this; /** Sends a `PUT` to `url`. */ put(url: string): this; /** Sends a `PATCH` to `url`. */ patch(url: string): this; /** Sends a `DELETE` to `url`. */ delete(url: string): this; /** Sets the path param `name`, filling the `{name}` placeholder in the URL. Literal schemas only. */ pathParam(name: string, schema: Schema): this; /** Sets the query param `name`. Required unless the schema is `optional()`. Literal schemas only. */ queryParam(name: string, schema: Schema): this; /** Sets the request body schema. Must be an object. */ body(schema: Schema): this; /** Sets the response body schema. Must be an object. */ response(schema: Schema): this; /** Sets the request header `name`. */ header(name: string, value: Header): this; /** Authenticates requests with an auth connection. */ auth(connection: AuthConnection): this; /** Stores the value at `valuePath` in the response (dot notation, e.g. `"order.status"`) in `variable`. */ assign(variable: string, valuePath: string, options?: AssignOptions): this; /** Removes the path param `name`. */ removePathParam(name: string): this; /** Removes the query param `name`. */ removeQueryParam(name: string): this; /** Removes the request header `name`. */ removeHeader(name: string): this; /** Removes every assignment to `variable`. */ removeAssignment(variable: string): this; /** The request body schema, for editing with `body()`. */ get bodySchema(): Schema | undefined; /** The response body schema, for editing with `response()`. */ get responseSchema(): Schema | undefined; /** Merges options for webhook tools. A key that doesn't apply is reported by `build()`. */ options(options: WebhookToolOptions): this; /** @internal */ protected _allowedOptions(): string[]; /** @internal */ protected _setOption(key: string, value: unknown): void; /** @internal */ protected _validate(): ToolIssue[]; /** @internal */ protected _toModel(): ToolConfig; private _request; } /** A tool that sends an event to the user's client. */ export declare class ClientTool extends Tool { readonly kind: "client"; private _parameters; /** @internal */ constructor(config: Model, parameters: ObjectSchema | undefined); /** Sets the param `name`. Required unless the schema is `optional()`. */ param(name: string, schema: Schema): this; /** Removes the param `name`. */ removeParam(name: string): this; /** The params schema. */ get parametersSchema(): ObjectSchema | undefined; /** Merges options for client tools. A key that doesn't apply is reported by `build()`. */ options(options: ClientToolOptions): this; /** @internal */ protected _allowedOptions(): string[]; /** @internal */ protected _validate(): ToolIssue[]; /** @internal */ protected _toModel(): ToolConfig; } export interface SkipTurnOptions { /** Seconds to wait before the agent checks in. -1 waits for the user. */ waitTimeoutSecs?: number; } export interface LanguageDetectionOptions { /** Only switch language during the first two user turns. */ onlyAtConversationStart?: boolean; } export interface PlayKeypadTouchToneOptions { /** Send tones as RTP events instead of in-band audio. SIP trunk numbers only. */ useOutOfBandDtmf?: boolean; /** Don't speak after playing tones, so speech doesn't confuse an IVR. */ suppressTurnAfterDtmf?: boolean; } export interface VoicemailDetectionOptions { /** Message to leave on voicemail. Without one, the call ends. */ voicemailMessage?: string; } export interface KnowledgeBaseToolOptions { enabledStrategies?: ElevenLabs.SearchStrategy[]; } export interface TransferToNumberOptions { /** Play a message to the caller while they wait for the transfer. */ enableClientMessage?: boolean; } /** A built-in tool the agent runs itself, such as ending the call or transferring it. */ export declare class SystemTool extends Tool { readonly kind: "system"; /** The API's `system_tool_type`, e.g. `"end_call"`. */ readonly systemToolType: string; private readonly _params; /** @internal */ constructor(systemToolType: string, config: Model, params: Model); /** Lets the agent end the call. */ static endCall(): SystemTool; /** Lets the agent stay quiet when the user asks for a moment. */ static skipTurn(options?: SkipTurnOptions): SystemTool; /** Lets the agent switch language. */ static languageDetection(options?: LanguageDetectionOptions): SystemTool; /** Lets the agent play keypad tones, for phone menus. */ static playKeypadTouchTone(options?: PlayKeypadTouchToneOptions): SystemTool; /** Lets the agent detect voicemail and leave a message or hang up. */ static voicemailDetection(options?: VoicemailDetectionOptions): SystemTool; /** Lets the agent search its knowledge base. */ static knowledgeBase(options?: KnowledgeBaseToolOptions): SystemTool; /** Lets the agent transfer the call to a phone number or SIP URI. Add destinations with `transfer()`. */ static transferToNumber(options?: TransferToNumberOptions): SystemTool; /** Lets the agent hand the conversation to another agent. Add destinations with `transfer()`. */ static transferToAgent(): SystemTool; private static _create; /** * Adds a destination to a transfer tool. `condition` is plain text telling the LLM when to transfer there. * `transferToNumber` takes phone and SIP destinations, `transferToAgent` agent destinations. */ transfer(condition: string, destination: Destination, options?: SystemTransferOptions): this; /** * Validates the tool and returns its entry for the agent's `prompt.builtInTools`. * * @throws {ToolValidationError} listing every problem, if the tool is invalid */ buildConfig(options?: ToolBuildOptions): ElevenLabs.ToolRequestModelToolConfig.System; /** @internal */ protected _allowedOptions(): string[]; /** @internal */ protected _validate(): ToolIssue[]; /** @internal */ protected _toModel(): ToolConfig; } export {};