/** * Type definitions for Voice.ai Web SDK * * This file contains all TypeScript types for the SDK including: * - Agent Connection types (real-time voice) * - Agent Management types * - Analytics types * - Knowledge Base types * - Phone Number types * - Common types (pagination, errors) */ export interface ConnectionDetails { serverUrl: string; participantToken: string; callId: string; /** Token scoped to ending this specific call. Used by disconnect() * to immediately free the concurrency slot without needing an API key. */ endToken?: string; } export interface ConnectionOptions { /** API base URL (default: auto-detect or provided) */ apiUrl?: string; /** API key for authentication */ apiKey?: string; /** Generic bearer auth token for authentication */ authToken?: string; /** Agent ID to connect to. */ agentId?: string; /** Runtime prompt variables */ dynamicVariables?: DynamicVariables; /** Runtime config overrides for the current call. * Uses the same nested shape as agent config for the allowlisted subset. */ agentOverrides?: RuntimeAgentOverrides; /** Enable automatic microphone publishing (default: true) */ autoPublishMic?: boolean; /** Audio capture options */ audioOptions?: AudioCaptureOptions; /** Enable pre-connect audio buffering (default: true) - improves mobile timing */ preConnectBuffer?: boolean; /** Enable test mode to preview/test agents without deploying (default: false). * When true, uses test-connection-details endpoint which allows testing paused agents. */ testMode?: boolean; /** Pre-fetched LiveKit server URL (from your backend). * When provided along with participantToken, the SDK connects directly * without calling the Voice.AI API, so no API key is needed in the browser. */ serverUrl?: string; /** Pre-fetched LiveKit participant token (from your backend) */ participantToken?: string; /** Pre-fetched call ID (from your backend) */ callId?: string; /** Pre-fetched end token (from your backend, for ending the call without API key) */ endToken?: string; [key: string]: any; } export interface TranscriptionSegment { /** Unique ID for this transcription segment/stream */ id: string; text: string; role: 'user' | 'assistant'; timestamp: number; isFinal: boolean; } export interface ConnectionStatus { connected: boolean; connecting: boolean; error?: string; callId?: string; } export type AgentState = 'disconnected' | 'connecting' | 'initializing' | 'listening' | 'thinking' | 'speaking'; export interface AgentStateInfo { state: AgentState; agentParticipantId?: string; } export interface AudioLevelInfo { level: number; isSpeaking: boolean; } export interface MicrophoneState { enabled: boolean; muted: boolean; } export type TranscriptionHandler = (segment: TranscriptionSegment) => void; export type ConnectionStatusHandler = (status: ConnectionStatus) => void; export type ErrorHandler = (error: Error) => void; export type AgentStateHandler = (state: AgentStateInfo) => void; export type AudioLevelHandler = (level: AudioLevelInfo) => void; export type MicrophoneStateHandler = (state: MicrophoneState) => void; export interface AudioCaptureOptions { echoCancellation?: boolean; noiseSuppression?: boolean; autoGainControl?: boolean; sampleRate?: number; channelCount?: number; voiceIsolation?: boolean; [key: string]: any; } /** Pagination metadata returned by list endpoints */ export interface PaginationMeta { current_page: number; total_pages: number; total_items: number; limit: number; has_next: boolean; has_previous: boolean; } /** Pagination options for list requests */ export interface PaginationOptions { /** Page number (1-based) */ page?: number; /** Items per page (max 100) */ limit?: number; } /** Standard error response from API */ export interface ErrorResponse { error: string; detail?: string; code?: string; } /** Validation error detail */ export interface ValidationErrorDetail { loc: (string | number)[]; msg: string; type: string; } /** HTTP Validation Error response */ export interface HTTPValidationError { detail: ValidationErrorDetail[]; } /** TTS parameters for agent voice configuration */ export interface TTSParams { /** Voice ID to use for text-to-speech generation */ voice_id?: string | null; /** TTS model to use. If not provided, automatically selected based on language. * Examples: 'voiceai-tts-v1-latest', 'voiceai-tts-multilingual-v1-latest' */ model?: string | null; /** Language code (ISO 639-1 format, e.g., 'en', 'es', 'fr'). * Use 'auto' for ASR-detected language at runtime (requires multilingual model). * Defaults to 'en' if not set. */ language?: string | null; /** Sampling temperature (0.0-2.0). Higher values make output more random. */ temperature?: number | null; /** Nucleus sampling parameter (0.0-1.0). Controls diversity of output. */ top_p?: number | null; /** Managed pronunciation dictionary ID stored in the Voice.ai API. */ dictionary_id?: string | null; /** Optional managed pronunciation dictionary version. Defaults to the latest active version. */ dictionary_version?: number | null; [key: string]: any; } /** A supported dynamic variable value passed at call start */ export type DynamicVariableValue = string | number | boolean; /** Runtime prompt variables passed at call start */ export type DynamicVariables = Record; /** Runtime config overrides passed at call start */ export interface RuntimeAgentOverrides { /** Call-scoped TTS overrides */ tts_params?: Partial>; } /** MCP Server configuration */ export interface MCPServerConfig { /** Human-readable name for the server (required) */ name: string; /** Description of the server's purpose or tools */ description?: string | null; /** MCP server endpoint URL (required). URLs ending with '/mcp' use streamable HTTP transport. */ url: string; /** Authentication type (default: 'none') */ auth_type?: 'none' | 'bearer_token' | 'api_key' | 'custom_headers' | null; /** Token for 'bearer_token' or 'api_key' authentication */ auth_token?: string | null; /** HTTP headers for authentication or custom configuration */ headers?: Record | null; [key: string]: any; } export interface ManagedToolsConfig { google_calendar?: { enabled?: boolean | null; default_calendar_id?: string | null; timezone?: string | null; selected_operations?: string[] | null; } | null; google_sheets?: { enabled?: boolean | null; spreadsheet_id?: string | null; sheet_name?: string | null; selected_operations?: string[] | null; } | null; google_gmail?: { enabled?: boolean | null; selected_operations?: string[] | null; } | null; } export type GoogleCalendarOperation = 'google_calendar_check_availability' | 'google_calendar_list_upcoming_events' | 'google_calendar_create_event' | 'google_calendar_update_event' | 'google_calendar_cancel_event'; export type GoogleSheetsOperation = 'google_sheets_append_row' | 'google_sheets_list_sheets' | 'google_sheets_read_rows'; export type GoogleGmailOperation = 'google_gmail_search_messages' | 'google_gmail_get_message' | 'google_gmail_send_email'; export type GoogleManagedToolOperation = GoogleCalendarOperation | GoogleSheetsOperation | GoogleGmailOperation; export interface GoogleManagedToolOperationOption { value: T; label: string; description: string; } export interface GoogleOAuthStartOptions { returnUrl?: string; managedTools?: ManagedToolsConfig | null; } export interface GoogleOAuthStartResponse { auth_url: string; requested_scopes: string[]; } export interface GoogleConnectionStatus { connected: boolean; agent_id: string; error?: string; email?: string | null; expires_at?: string | null; granted_scopes: string[]; scopes: string[]; required_scopes: string[]; missing_scopes: string[]; reconnect_required: boolean; } /** Webhook event types */ export type WebhookEventType = 'call.started' | 'call.completed'; /** * Webhook event notification configuration exposed by the public API. * * `secret` is write-only (accepted in create/update payloads). * `has_secret` is read-only (returned in API responses). */ export interface WebhookEventsConfig { /** Webhook endpoint URL (required) */ url: string; /** HMAC-SHA256 signing secret for payload verification (write-only on create/update; URL-matched when preserving secrets across full-array replacement) */ secret?: string | null; /** Whether a signing secret is configured (returned by API) */ has_secret?: boolean; /** Event types to receive. Empty array = all events. Options: 'call.started', 'call.completed' */ events?: WebhookEventType[]; /** Request timeout in seconds (default: 5, range: 1-30) */ timeout?: number; /** Whether webhook notifications are active (default: true) */ enabled?: boolean; [key: string]: any; } /** * Inbound call webhook configuration exposed by the public API. * * `secret` is write-only (accepted in create/update payloads). * `has_secret` is read-only (returned in API responses). */ export interface WebhookInboundCallConfig { /** Webhook endpoint URL (required) */ url: string; /** HMAC-SHA256 signing secret for payload verification (set when configuring) */ secret?: string | null; /** Whether a signing secret is configured (returned by API) */ has_secret?: boolean; /** Request timeout in seconds (default: 5, range: 1-30) */ timeout?: number; /** Whether inbound call personalization is active (default: true) */ enabled?: boolean; [key: string]: any; } /** * Webhook tool configuration exposed by the public API. * * Webhook tools are outbound API-call definitions. */ export interface WebhookToolConfig { /** Tool name (required) */ name: string; /** Human-readable tool description (required) */ description: string; /** Tool input schema or shorthand map */ parameters: Record; /** Tool response schema or shorthand map */ response?: Record | null; /** Webhook endpoint URL for this tool (required) */ url: string; /** Outbound HTTP method */ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; /** Tool execution mode */ execution_mode: 'sync' | 'async'; /** Authentication mode */ auth_type: 'none' | 'bearer_token' | 'api_key' | 'custom_headers'; /** Token for bearer_token or api_key auth */ auth_token?: string | null; /** Additional headers (also used for custom_headers auth). For POST/PUT/PATCH, Content-Type is agent-managed and any configured Content-Type is ignored. */ headers?: Record | null; /** Request timeout in seconds */ timeout?: number | null; [key: string]: any; } /** Webhooks configuration exposed by the public API */ export interface WebhooksConfig { /** Event notification webhook endpoint configurations. On update, omit to preserve, set null to clear, or replace the entire array. */ events?: WebhookEventsConfig[] | null; /** Inbound call webhook configuration */ inbound_call?: WebhookInboundCallConfig | null; /** Tool webhook configurations */ tools?: WebhookToolConfig[] | null; [key: string]: any; } /** Webhook event payload (received at your webhook URL) */ export interface WebhookEvent { /** Event type */ event: WebhookEventType | 'test'; /** ISO 8601 timestamp of when the event occurred */ timestamp: string; /** Unique identifier for the call (may be null for test events) */ call_id?: string | null; /** Agent ID that generated the event */ agent_id: string; /** Event-specific additional data */ data: Record; } /** Response from testing webhook configuration */ export interface WebhookTestResponse { /** Test result status */ status: 'success' | 'failed'; /** Human-readable result description */ message: string; /** Aggregate per-endpoint delivery results */ results?: Array<{ url: string; success: boolean; status_code?: number | null; attempts: number; error?: string | null; }>; } /** Agent configuration */ export interface AgentConfig { /** Agent system prompt */ prompt?: string | null; /** Initial greeting message */ greeting?: string | null; /** LLM temperature (default: 0.7) */ llm_temperature?: number | null; /** LLM model (default: gemini-3.1-flash-lite-preview) */ llm_model?: string | null; /** Minimum TTS sentence length (default: 20) */ tts_min_sentence_len?: number | null; /** TTS parameters */ tts_params?: TTSParams | null; /** Minimum silence duration (default: 0.55) */ min_silence_duration?: number | null; /** Minimum speech duration (default: 0.1) */ min_speech_duration?: number | null; /** User silence timeout (default: 10.0) */ user_silence_timeout?: number | null; /** Maximum call duration in seconds (default: 900) */ max_call_duration_seconds?: number | null; /** Allow interruptions (default: true) */ allow_interruptions?: boolean | null; /** Allow interruptions on greeting (default: false) */ allow_interruptions_on_greeting?: boolean | null; /** Minimum words required for interruption (default: 1) */ min_interruption_words?: number | null; /** Enable automatic noise reduction (default: true) */ auto_noise_reduction?: boolean | null; /** Whether agent can end calls via tool or timeout (default: false) */ allow_agent_to_end_call?: boolean | null; /** Whether agent can skip turns and yield conversation control (default: false) */ allow_agent_to_skip_turn?: boolean | null; /** Minimum endpointing delay (default: 0.5) */ min_endpointing_delay?: number | null; /** Maximum endpointing delay (default: 3.0) */ max_endpointing_delay?: number | null; /** VAD activation threshold (default: 0.6) */ vad_activation_threshold?: number | null; /** Phone number in E.164 format */ phone_number?: string | null; /** Whether call recording is enabled */ recording_enabled?: boolean | null; /** Whether agent can make outbound calls */ allow_outbound_calling?: boolean | null; /** Webhook configuration for event notifications */ webhooks?: WebhooksConfig | null; /** MCP servers configuration */ mcp_servers?: MCPServerConfig[] | null; /** First-party managed tools configuration */ managed_tools?: ManagedToolsConfig | null; [key: string]: any; } /** Agent object */ export interface Agent { /** Unique agent identifier */ agent_id: string; /** Agent name */ name: string; /** Agent configuration */ config: AgentConfig; /** Agent status (default: paused) */ status: string; /** Status code (default: 1) */ status_code: number; /** Associated knowledge base ID */ kb_id?: number | null; /** Creation timestamp */ created_at: string; /** Last update timestamp */ updated_at: string; [key: string]: any; } /** Request to create a new agent */ export interface CreateAgentRequest { /** Agent name (cannot be empty) */ name: string; /** Agent configuration */ config: AgentConfig; /** Knowledge base ID to assign (optional) */ kb_id?: number | null; [key: string]: any; } /** Request to update an agent */ export interface UpdateAgentRequest { /** New agent name */ name?: string | null; /** Updated configuration */ config?: AgentConfig | null; /** Knowledge base ID (set to null to remove) */ kb_id?: number | null; [key: string]: any; } /** Response from deploying an agent */ export interface AgentDeployResponse { agent: Agent; message: string; sip_status?: string | null; sip_details?: Record | null; [key: string]: any; } /** Response from pausing an agent */ export interface AgentPauseResponse { agent: Agent; [key: string]: any; } /** Response from deleting an agent */ export interface AgentDeleteResponse { agent: Agent; message?: string | null; [key: string]: any; } /** Agent connection status response */ export interface AgentConnectionStatusResponse { agent_id: string; name: string; voice_id: string; status: string; status_code: number; call_allowed: boolean; call_validation_details?: Record | null; [key: string]: any; } /** Request body for creating an outbound call */ export interface CreateOutboundCallRequest { /** Agent ID to make the outbound call */ agent_id: string; /** Phone number to dial */ target_phone_number: string; /** Optional runtime prompt variables */ dynamic_variables?: DynamicVariables | null; /** Optional runtime config overrides */ agent_overrides?: RuntimeAgentOverrides | null; } /** Response body for outbound call creation */ export interface CreateOutboundCallResponse { call_id: string; room_name: string; agent_id: string; target_phone_number: string; status: string; initiated_at: string; [key: string]: any; } /** Agent status summary */ export interface AgentStatusSummary { deployed: number; paused: number; disabled: number; } /** Agent stats summary response */ export interface AgentStatsSummaryResponse { total_agents: number; status_summary: AgentStatusSummary; } /** Request to initialize agent from template */ export interface InitAgentRequest { agent_template?: string | null; name?: string | null; [key: string]: any; } /** Response from initializing agent from template */ export interface InitAgentResponse { agent_template: AgentConfig; available_types: string[]; description: string; } /** Paginated agent response */ export interface PaginatedAgentResponse { items: Agent[]; pagination: PaginationMeta; } /** List agents options */ export interface ListAgentsOptions extends PaginationOptions { /** List of statuses to show (default: deployed and paused) */ show_statuses?: string[]; } /** Call history item */ export interface CallHistoryItem { id: number; call_id?: string | null; agent_id?: string | null; agent_name?: string | null; call_timestamp: string; call_duration_seconds: number; credits_used: number; has_transcript: boolean; call_type?: string | null; from_number?: string | null; to_number?: string | null; transcription_summary?: string | null; transcription_stats?: Record | null; [key: string]: any; } /** Paginated call history response */ export interface PaginatedCallHistoryResponse { items: CallHistoryItem[]; pagination: PaginationMeta; } export type CallHistorySortBy = 'timestamp' | 'agent' | 'call' | 'duration' | 'credits' | 'summary' | 'transcript' | 'recording'; export type CallHistorySortDirection = 'asc' | 'desc'; /** Options for getting call history */ export interface GetCallHistoryOptions extends PaginationOptions { /** Filter calls after this date (ISO format UTC) */ start_date?: string; /** Filter calls before this date (ISO format UTC) */ end_date?: string; /** Filter calls by agent ID(s) */ agent_ids?: string[]; /** Filter calls by partial agent name match */ agent_name?: string; /** Sort field */ sort_by?: CallHistorySortBy; /** Sort direction */ sort_dir?: CallHistorySortDirection; } /** Transcript URL response */ export interface TranscriptResponse { url: string; } /** Recording availability status */ export type RecordingStatus = 'ready' | 'processing' | 'not_recorded'; /** Recording status response */ export interface RecordingResponse { status: RecordingStatus; url?: string | null; } /** Document for knowledge base */ export interface KnowledgeBaseDocument { /** Document text content (required) */ content: string; /** Optional metadata dictionary */ metadata?: Record | null; [key: string]: any; } /** Request to create a knowledge base */ export interface CreateKnowledgeBaseRequest { /** Knowledge base name */ name?: string | null; /** Knowledge base description */ description?: string | null; /** List of documents (at least one required) */ documents: KnowledgeBaseDocument[]; [key: string]: any; } /** Request to update a knowledge base */ export interface UpdateKnowledgeBaseRequest { /** New name */ name?: string | null; /** New description */ description?: string | null; /** Documents to replace all existing (if provided) */ documents?: KnowledgeBaseDocument[] | null; [key: string]: any; } /** Knowledge base response (without documents) */ export interface KnowledgeBaseResponse { kb_id: number; name?: string | null; description?: string | null; document_count: number; created_at: string; updated_at: string; message?: string | null; [key: string]: any; } /** Knowledge base with documents */ export interface KnowledgeBaseWithDocuments extends KnowledgeBaseResponse { documents: Record[]; } /** Paginated knowledge base response */ export interface PaginatedKnowledgeBaseResponse { items: KnowledgeBaseResponse[]; pagination: PaginationMeta; } /** Request to assign knowledge base to agent */ export interface AssignKnowledgeBaseRequest { kb_id: number; } /** Phone number information */ export interface PhoneNumberInfo { phone_number: string; status: string; assigned_to_agent_id?: string | null; assigned_to_agent_name?: string | null; } /** Available phone number from search */ export interface AvailablePhoneNumber { phone_number: string; locality?: string | null; region?: string | null; country_code: string; } /** Request to search phone numbers */ export interface SearchPhoneNumbersRequest { /** Country code (e.g., 'US', 'CA', default: 'US') */ country_code?: string; /** 3-digit area code (e.g., '415') */ area_code?: string | null; /** Provider: 'twilio' or 'telnyx' (default: 'twilio') */ provider?: string; [key: string]: any; } /** Response from searching phone numbers */ export interface SearchPhoneNumbersResponse { results: AvailablePhoneNumber[]; total_results: number; } /** Request to select/purchase or release a phone number */ export interface PurchasePhoneNumberRequest { /** Exact phone number (e.g., '+15551234567') */ phone_number: string; /** Provider: 'twilio' or 'telnyx' (default: 'twilio') */ provider?: string; [key: string]: any; } /** Response from selecting or releasing a phone number */ export interface PurchasePhoneNumberResponse { phone_number: string; status: string; } /** All phone numbers response (non-paginated) */ export interface AllPhoneNumbersResponse { phone_numbers: PhoneNumberInfo[]; total_numbers: number; total_available: number; total_assigned: number; } /** Paginated phone numbers response */ export interface PaginatedPhoneNumberResponse { items: AvailablePhoneNumber[]; pagination: PaginationMeta; } /** Paginated all phone numbers response */ export interface PaginatedAllPhoneNumbersResponse { items: PhoneNumberInfo[]; pagination: PaginationMeta; } /** Audio format for TTS output */ export type TTSAudioFormat = 'mp3' | 'wav' | 'pcm' | 'alaw_8000' | 'mp3_22050_32' | 'mp3_24000_48' | 'mp3_44100_32' | 'mp3_44100_64' | 'mp3_44100_96' | 'mp3_44100_128' | 'mp3_44100_192' | 'opus_48000_32' | 'opus_48000_64' | 'opus_48000_96' | 'opus_48000_128' | 'opus_48000_192' | 'pcm_8000' | 'pcm_16000' | 'pcm_22050' | 'pcm_24000' | 'pcm_32000' | 'pcm_44100' | 'pcm_48000' | 'ulaw_8000' | 'wav_16000' | 'wav_22050' | 'wav_24000'; /** Voice visibility setting */ export type VoiceVisibility = 'PUBLIC' | 'PRIVATE'; /** Voice processing status */ export type VoiceStatus = 'PENDING' | 'PROCESSING' | 'AVAILABLE' | 'FAILED'; /** Request to generate speech from text */ export interface SynthesizeRequest { /** Text to generate speech for (required) */ text: string; /** Voice ID to use. If omitted, the default built-in voice is used. */ voice_id?: string | null; /** Audio output format (default: 'mp3') */ audio_format?: TTSAudioFormat; /** Generation temperature 0.0-2.0 (default: 1.0) */ temperature?: number; /** Top-p sampling parameter 0.0-1.0 (default: 0.8) */ top_p?: number; /** TTS model to use. If not provided, automatically selected based on language. */ model?: string | null; /** Language code in ISO 639-1 format, e.g. 'en', 'es', 'fr' (default: 'en') */ language?: string; /** Managed pronunciation dictionary ID stored in the Voice.ai API. */ dictionary_id?: string | null; /** Optional managed pronunciation dictionary version. Defaults to the latest active version. */ dictionary_version?: number | null; [key: string]: any; } /** Options for cloning a voice from audio */ export interface CloneVoiceOptions { /** Audio file (MP3, WAV, or M4A format, max 7.5MB) */ file: Blob | File; /** Name for the voice (optional) */ name?: string; /** Voice visibility: PUBLIC or PRIVATE (default: PUBLIC) */ voice_visibility?: VoiceVisibility; /** Language code in ISO 639-1 format (default: 'en') */ language?: string; } /** Response from cloning a voice */ export interface CloneVoiceResponse { /** The created voice ID */ voice_id: string; /** Voice processing status: PENDING, PROCESSING, AVAILABLE, or FAILED */ status: VoiceStatus; } /** Voice status/details response */ export interface VoiceResponse { /** The voice ID */ voice_id: string; /** Voice processing status */ status: VoiceStatus; /** User-provided voice name */ name?: string | null; /** Voice visibility: PUBLIC or PRIVATE */ voice_visibility?: VoiceVisibility | null; } /** Request to update voice metadata */ export interface UpdateVoiceOptions { /** New voice name */ name?: string | null; /** New visibility: PUBLIC or PRIVATE */ voice_visibility?: VoiceVisibility | null; } /** Response from deleting a voice */ export interface DeleteVoiceResponse { status: string; voice_id: string; } export interface PronunciationRuleInput { id?: string | null; word: string; replacement: string; ipa?: string | null; case_sensitive?: boolean; } export interface PronunciationRule { id: string; word: string; replacement: string; ipa: string | null; case_sensitive: boolean; } export interface PronunciationDictionaryVersionSummary { version: number; created_at_unix: number; } export interface PronunciationDictionarySummary { id: string; name: string; language: string; current_version: number; created_at_unix: number; updated_at_unix: number; } export interface PronunciationDictionaryDetail extends PronunciationDictionarySummary { rules: PronunciationRule[]; versions: PronunciationDictionaryVersionSummary[]; } export interface DeletePronunciationDictionaryResponse { id: string; deleted: boolean; } /** Request for connection details */ export interface ConnectionDetailsRequest { agent_id?: string | null; dynamic_variables?: DynamicVariables | null; agent_overrides?: RuntimeAgentOverrides | null; [key: string]: any; } /** Response with connection details */ export interface ConnectionDetailsResponse { server_url: string; participant_token: string; call_id: string; [key: string]: any; } /** End call response */ export interface EndCallResponse { call_id: string; status: string; ended_at: string; actual_duration_seconds: number; credits_used: number; [key: string]: any; } export type AuthTokenProvider = () => Promise | string | null | undefined; /** Configuration for VoiceAI SDK */ export interface VoiceAIConfig { /** API key for authentication. * Required for API operations (agents, tts, analytics, etc.) and `getConnectionDetails()`. * Not needed when using `connectRoom()` with pre-fetched connection details. */ apiKey?: string; /** Generic bearer auth token for REST API operations. */ authToken?: string; /** Lazy auth token provider for browser apps with rotating auth. */ getAuthToken?: AuthTokenProvider; /** API base URL (optional, defaults to production) */ apiUrl?: string; } //# sourceMappingURL=types.d.ts.map