UNPKG

phonic

Version:

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPhonic-Co%2Fphonic-node) [![npm shield](htt

193 lines (192 loc) 10.2 kB
import type * as Phonic from "../index.mjs"; /** * Configuration fields for the initial `config` message. */ export interface ConfigOptions { /** Agent name to use for conversation */ agent?: string | undefined; /** Project name */ project?: string | undefined; /** STS model to use */ model?: "merritt" | undefined; /** System prompt for AI assistant */ system_prompt?: string | undefined; /** Audio playback speed */ audio_speed?: number | undefined; /** Background noise level for the conversation */ background_noise_level?: number | undefined; /** Background noise type for the conversation */ background_noise?: (ConfigOptions.BackgroundNoise | null) | undefined; /** When `true`, the welcome message will be automatically generated and the `welcome_message` field will be ignored. */ generate_welcome_message?: boolean | undefined; /** When `false`, the welcome message will not be interruptible by the user. */ is_welcome_message_interruptible?: boolean | undefined; /** Number of seconds of inactivity before the conversation WebSocket is closed. */ websocket_timeout_sec?: number | undefined; /** Message to play when conversation starts. Ignored when `generate_welcome_message` is `true`. */ welcome_message?: (string | null) | undefined; /** Voice ID to use for speech synthesis */ voice_id?: string | undefined; /** Audio input format */ input_format?: ConfigOptions.InputFormat | undefined; /** Audio output format */ output_format?: ConfigOptions.OutputFormat | undefined; /** Voice activity detection prebuffer duration */ vad_prebuffer_duration_ms?: number | undefined; /** Minimum speech duration for VAD */ vad_min_speech_duration_ms?: number | undefined; /** Minimum silence duration for VAD */ vad_min_silence_duration_ms?: number | undefined; /** Voice activity detection threshold */ vad_threshold?: number | undefined; /** Minimum number of words required to interrupt the assistant. */ min_words_to_interrupt?: number | undefined; /** Whether to have the no-input poke text be generated by AI */ generate_no_input_poke_text?: boolean | undefined; /** Seconds of silence before poke message */ no_input_poke_sec?: (number | null) | undefined; /** Poke message text. Ignored when generate_no_input_poke_text is true. */ no_input_poke_text?: string | undefined; /** Seconds of silence before ending conversation */ no_input_end_conversation_sec?: number | undefined; /** ISO 639-1 language code that sets the agent's default language to recognize and speak. Welcome message and no input poke text should be in this language. */ default_language?: string | undefined; /** Array of additional ISO 639-1 language codes that the agent should be able to recognize and speak. Should not include `default_language`. When `multilingual_mode` is `"auto"`, a maximum of 2 additional languages is allowed. */ additional_languages?: string[] | undefined; /** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). If `"initial"` the first turn user audio determines the language for the rest of the conversation. */ multilingual_mode?: ConfigOptions.MultilingualMode | undefined; /** Push to talk mode. User must send mute/unmute messages to turn on/off listening to audio. Defaults to false. */ push_to_talk?: boolean | undefined; /** When `true`, assistant audio is streamed to the client as fast as it is generated, rather than paced to real time. Defaults to false. */ stream_ahead_of_real_time?: boolean | undefined; /** The intelligence level of the agent. `high` uses a more capable model for more complex reasoning, while `standard` is optimized for lower latency. */ intelligence_level?: ConfigOptions.IntelligenceLevel | undefined; /** Keywords to boost in speech recognition */ boosted_keywords?: string[] | undefined; /** Array of `{ word, pronunciation }` entries. Words must be unique. */ pronunciation_dictionary?: ConfigOptions.PronunciationDictionary.Item[] | undefined; /** Tools available to the assistant. Use a string to reference a pre-defined tool by name, or define an inline WebSocket tool for this conversation. */ tools?: Phonic.ToolDefinition[] | undefined; /** Template variables for system prompt and welcome message */ template_variables?: Record<string, string> | undefined; /** When `true`, PII and PHI are redacted from text transcripts (e.g. replaced with tags like `[PHONE NUMBER]`) and bleeped from audio recordings after the conversation ends. */ enable_redaction?: boolean | undefined; /** Names of pre-configured MCP servers to make available to the assistant. Names must be unique. */ mcp_servers?: string[] | undefined; /** Names of observability integrations to enable for the conversation. Each must be one of the supported providers. */ observability_integrations?: "braintrust"[] | undefined; /** Tasks the assistant should accomplish during the conversation. */ tasks?: ConfigOptions.Tasks.Item[] | undefined; /** Pool of phone numbers to use as the caller ID for outbound calls. */ outbound_number_pool?: (ConfigOptions.OutboundNumberPool | null) | undefined; /** When `true`, the assistant will produce backchannel responses (e.g. "mm-hmm", "yeah") while the user is speaking. */ enable_assistant_backchannel?: boolean | undefined; /** How aggressively the assistant produces backchannel responses. Only applies when `enable_assistant_backchannel` is `true`. */ assistant_backchannel_aggressiveness?: number | undefined; /** When not `null`, the agent will call this endpoint to get configuration options for the conversation. */ configuration_endpoint?: (ConfigOptions.ConfigurationEndpoint | null) | undefined; /** Additional runtime parameters. */ additional_params?: Record<string, unknown> | undefined; /** * Policy controlling how long transcripts and audio recordings are retained before being deleted. * When `zero_data_retention` is `true`, nothing is retained and `transcripts`/`audio_recordings` are omitted. */ data_retention_policy?: ConfigOptions.DataRetentionPolicy | undefined; } export declare namespace ConfigOptions { /** Background noise type for the conversation */ const BackgroundNoise: { readonly Office: "office"; readonly CallCenter: "call-center"; readonly CoffeeShop: "coffee-shop"; }; type BackgroundNoise = (typeof BackgroundNoise)[keyof typeof BackgroundNoise]; /** Audio input format */ const InputFormat: { readonly Pcm44100: "pcm_44100"; readonly Pcm24000: "pcm_24000"; readonly Pcm16000: "pcm_16000"; readonly Pcm8000: "pcm_8000"; readonly Mulaw8000: "mulaw_8000"; }; type InputFormat = (typeof InputFormat)[keyof typeof InputFormat]; /** Audio output format */ const OutputFormat: { readonly Pcm44100: "pcm_44100"; readonly Pcm24000: "pcm_24000"; readonly Pcm16000: "pcm_16000"; readonly Pcm8000: "pcm_8000"; readonly Mulaw8000: "mulaw_8000"; }; type OutputFormat = (typeof OutputFormat)[keyof typeof OutputFormat]; /** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). If `"initial"` the first turn user audio determines the language for the rest of the conversation. */ const MultilingualMode: { readonly Auto: "auto"; readonly Request: "request"; readonly Initial: "initial"; }; type MultilingualMode = (typeof MultilingualMode)[keyof typeof MultilingualMode]; /** The intelligence level of the agent. `high` uses a more capable model for more complex reasoning, while `standard` is optimized for lower latency. */ const IntelligenceLevel: { readonly Standard: "standard"; readonly High: "high"; }; type IntelligenceLevel = (typeof IntelligenceLevel)[keyof typeof IntelligenceLevel]; type PronunciationDictionary = PronunciationDictionary.Item[]; namespace PronunciationDictionary { interface Item { word: string; pronunciation: string; } } type Tasks = Tasks.Item[]; namespace Tasks { interface Item { /** Name of the task. */ name: string; /** Description of the task. */ description: string; } } /** * Pool of phone numbers to use as the caller ID for outbound calls. */ interface OutboundNumberPool { /** Active E.164 phone numbers to use for outbound calls. Numbers must be unique. */ active: string[]; /** Blocked E.164 phone numbers that should not be used for outbound calls. */ blocked: string[]; } /** * When not `null`, the agent will call this endpoint to get configuration options for the conversation. */ interface ConfigurationEndpoint { /** URL to call. */ url: string; /** Object of key-value pairs sent as headers when calling the endpoint. */ headers?: Record<string, string> | undefined; /** Timeout in milliseconds for the endpoint call. */ timeout_ms?: number | undefined; } /** * Policy controlling how long transcripts and audio recordings are retained before being deleted. * When `zero_data_retention` is `true`, nothing is retained and `transcripts`/`audio_recordings` are omitted. */ type DataRetentionPolicy = /** * Zero data retention mode. No transcripts or audio recordings are retained. */ { zero_data_retention: true; } /** * Standard data retention with configurable deletion windows. */ | { zero_data_retention: false; transcripts: { delete_after_hours: number | null; }; audio_recordings: { delete_after_hours: number | null; }; }; }