import type { IncomingSocketEvent, OutgoingSocketEvent } from "./events.js"; import type { Mode } from "../BaseConversation.js"; import type { ConversationConfigOverrideAgentPrompt, ConversationConfigOverrideAgentLanguage as Language } from "@elevenlabs/types"; import type { DisconnectionDetails } from "../types.js"; export type { ConversationConfigOverrideAgentPrompt, ConversationConfigOverrideAgentLanguage as Language, } from "@elevenlabs/types"; export type { DisconnectionContext, DisconnectionDetails } from "../types.js"; export type DelayConfig = { default: number; android?: number; ios?: number; }; export type FormatConfig = { format: "pcm" | "ulaw"; sampleRate: number; }; export type OnDisconnectCallback = (details: DisconnectionDetails) => void; export type OnMessageCallback = (event: IncomingSocketEvent) => void; export type OnOutgoingMessageCallback = (event: any) => void; export type BaseSessionConfig = { origin?: string; authorization?: string; livekitUrl?: string; webRtc?: { /** * ICE transport policy for the WebRTC connection. Set to "relay" to only * use TURN relay candidates, e.g. on networks that drop direct UDP flows. * Defaults to "all". */ iceTransportPolicy?: "all" | "relay"; /** * Whether to negotiate over a single peer connection (LiveKit's v1 join * protocol, which bundles the publisher offer in the JoinRequest). Set to * false to force the dual peer connection path, e.g. on platforms that * reject the microphone request at the point v1 issues it. Defaults to * livekit-client's own default, currently true. */ singlePeerConnection?: boolean; }; overrides?: { agent?: { prompt?: ConversationConfigOverrideAgentPrompt; firstMessage?: string; language?: Language; }; tts?: { voiceId?: string; speed?: number; stability?: number; similarityBoost?: number; }; asr?: { /** Keywords to boost ASR prediction probability for this conversation. */ keywords?: string[]; }; conversation?: { textOnly?: boolean; }; }; customLlmExtraBody?: unknown; dynamicVariables?: Record; toolMockConfig?: { /** Which tools to mock. Defaults to 'none'. */ mockingStrategy?: "none" | "all" | "selected"; /** Tool names to mock when mockingStrategy is 'selected'. */ mockedToolNames?: string[]; /** Behavior when mocked tool has no mock response. Defaults to 'raise_error'. */ fallbackStrategy?: "raise_error" | "call_real_tool"; }; useWakeLock?: boolean; connectionDelay?: DelayConfig; textOnly?: boolean; userId?: string; environment?: string; }; export type ConnectionType = "websocket" | "webrtc"; /** * @experimental */ export type PostCallWebhookConfig = { url: string; /** * Secret the orchestrator uses to sign deliveries. The orchestrator * rejects secrets shorter than 16 characters. Anything set here is visible * to the end user running the page, like the rest of the orchestrator * session config; intended for testing against trusted deployments, not * production use. */ hmacSecret?: string; }; /** * @experimental */ export type OrchestratorConfig = { /** WebSocket URL of the orchestrator, e.g. "wss:///sagemaker/convai/conversation". */ url: string; /** Full agent definition, as exported from the ElevenLabs platform. */ agentConfig?: Record; /** Partial configs applied as overrides on top of the base agent config. */ agentConfigOverrides?: Record[]; /** * Tool definitions for the agent, in the platform's tool export format * (the `tools_config_list` entries produced by the agent export tooling, * matching the Python SDK field of the same name). The orchestrator * validates each entry server-side and rejects the session on mismatch. */ tools?: Record[]; /** * Replaces the knowledge-base section of the system prompt. Independent of * `overrides.agent.prompt`, which sets the prompt text; the orchestrator * composes the two, so both may be provided together. */ promptKnowledgeBase?: string[]; /** Bedrock cross-region inference profile, e.g. "global". The orchestrator defaults to "us". */ bedrockInferenceProfile?: string; /** Called with the conversation transcript once the session ends. */ postCallTranscriptionWebhook?: PostCallWebhookConfig; /** Called with the conversation audio once the session ends. */ postCallAudioWebhook?: PostCallWebhookConfig; }; export type PublicSessionConfig = BaseSessionConfig & { agentId: string; connectionType?: ConnectionType; signedUrl?: never; conversationToken?: never; orchestrator?: never; }; export type PrivateWebSocketSessionConfig = BaseSessionConfig & { signedUrl: string; connectionType?: "websocket"; agentId?: never; conversationToken?: never; orchestrator?: never; }; export type PrivateWebRTCSessionConfig = BaseSessionConfig & { conversationToken: string; connectionType?: "webrtc"; agentId?: never; signedUrl?: never; orchestrator?: never; }; /** * @experimental */ export type OrchestratorSessionConfig = BaseSessionConfig & { /** * Routes the session to a self-hosted orchestrator instead of the ElevenLabs cloud. * @experimental */ orchestrator: OrchestratorConfig; connectionType?: "websocket"; agentId?: never; signedUrl?: never; conversationToken?: never; authorization?: never; origin?: never; environment?: never; }; export type SessionConfig = PublicSessionConfig | PrivateWebSocketSessionConfig | PrivateWebRTCSessionConfig | OrchestratorSessionConfig; export declare abstract class BaseConnection { abstract readonly conversationId: string; abstract readonly inputFormat: FormatConfig; abstract readonly outputFormat: FormatConfig; protected queue: IncomingSocketEvent[]; protected outgoingQueue: OutgoingSocketEvent[]; protected disconnectionDetails: DisconnectionDetails | null; protected onDisconnectCallback: OnDisconnectCallback | null; protected onMessageCallback: OnMessageCallback | null; protected onModeChangeCallback: ((mode: Mode) => void) | null; protected onDebug?: (info: unknown) => void; protected onOutgoingMessageCallback: OnOutgoingMessageCallback | null; constructor(config?: { onDebug?: (info: unknown) => void; }); protected debug(info: unknown): void; abstract close(): void; abstract sendMessage(message: OutgoingSocketEvent): void; onMessage(callback: OnMessageCallback): void; onDisconnect(callback: OnDisconnectCallback): void; onModeChange(callback: (mode: Mode) => void): void; onOutgoingMessage(callback: OnOutgoingMessageCallback): void; protected updateMode(mode: Mode): void; protected disconnect(details: DisconnectionDetails): void; protected handleMessage(parsedEvent: IncomingSocketEvent): void; protected handleOutgoingMessage(event: any): void; } export declare function parseFormat(format: string): FormatConfig; //# sourceMappingURL=BaseConnection.d.ts.map