import { type ReactNode } from "react"; import { type RealtimeVoiceAudioLevelStore } from "./realtime-voice-audio-level.js"; import { type RealtimeVoiceModeCopy, type RealtimeVoiceModeState } from "./RealtimeVoiceMode.js"; export declare const REALTIME_VOICE_LANGUAGES: readonly ["auto", "en", "es", "fr", "de", "it", "pt", "ja", "ko", "zh"]; export declare const REALTIME_VOICE_INTELLIGENCE_LEVELS: readonly ["instant", "balanced", "deep"]; export declare const REALTIME_VOICES: readonly ["marin", "cedar", "coral", "sage", "verse", "alloy", "ash", "ballad", "echo", "shimmer"]; export type RealtimeVoiceLanguage = (typeof REALTIME_VOICE_LANGUAGES)[number]; export type RealtimeVoiceIntelligence = (typeof REALTIME_VOICE_INTELLIGENCE_LEVELS)[number]; export type RealtimeVoice = (typeof REALTIME_VOICES)[number]; export interface RealtimeVoicePreferences { language: RealtimeVoiceLanguage; intelligence: RealtimeVoiceIntelligence; voice: RealtimeVoice; } export declare const DEFAULT_REALTIME_VOICE_PREFERENCES: RealtimeVoicePreferences; export declare const REALTIME_VOICE_AUDIO_CONSTRAINTS: MediaTrackConstraints; type RealtimeServerEvent = Record & { type?: string; }; export interface RealtimeVoiceToolResult { callId: string; status: "completed" | "failed" | "approval_required"; output: string; approvalKey?: string; expandedTools?: RealtimeVoiceFunctionTool[]; /** Re-issued when discovery widens the manifest. Calls to the new names 404 * until this replaces the session's capability. */ capability?: string; } export interface RealtimeVoiceSessionAnswer { sdp: string; capability?: string; } export interface RealtimeVoiceFunctionTool { type: "function"; name: string; description?: string; parameters?: Record; } export interface RealtimeVoiceModeApi { state: "idle" | RealtimeVoiceModeState; active: boolean; errorMessage: string | null; chatVisible: boolean; audioLevels: RealtimeVoiceAudioLevelStore; preferences: RealtimeVoicePreferences; microphones: readonly RealtimeVoiceMicrophone[]; microphoneDeviceId: string; microphoneSwitching: boolean; microphoneError: string | null; voiceChangePending: boolean; setLanguage: (language: RealtimeVoiceLanguage) => void; setIntelligence: (intelligence: RealtimeVoiceIntelligence) => void; setVoice: (voice: RealtimeVoice) => void; setMicrophone: (deviceId: string) => Promise; start: () => Promise; end: () => void; toggleChat: () => void; } export interface RealtimeVoiceMicrophone { deviceId: string; label: string; } export declare function createRealtimeVoiceAudioConstraints(deviceId?: string, exact?: boolean): MediaTrackConstraints; export declare function replaceRealtimeVoiceMicrophone(options: { mediaDevices: Pick; peer: Pick; currentStream: MediaStream | null; deviceId: string; }): Promise; export declare function normalizeRealtimeVoicePreferences(value: unknown): RealtimeVoicePreferences; export declare function resolveRealtimeVoiceLanguage(language: RealtimeVoiceLanguage, browserLanguages?: readonly string[]): Exclude; export declare function realtimeVoiceReasoningEffort(intelligence: RealtimeVoiceIntelligence): "minimal" | "low" | "medium"; export declare function createRealtimeVoicePreferenceUpdate(preferences: RealtimeVoicePreferences, options?: { browserLanguages?: readonly string[]; includeVoice?: boolean; }): Record; export interface CompletedRealtimeVoiceTranscript { role: "user" | "assistant"; text: string; providerId?: string; } export interface RealtimeVoiceTranscriptSequencer { handle: (event: RealtimeServerEvent) => void; reset: () => void; } /** * Input transcription is produced by a separate ASR model and can finish after * the assistant response. Reserve each message's position when OpenAI adds it * to the conversation, then publish only the contiguous completed prefix. */ export declare function createRealtimeVoiceTranscriptSequencer(publish: (transcript: CompletedRealtimeVoiceTranscript) => void): RealtimeVoiceTranscriptSequencer; export declare function createRealtimeVoiceGreetingEvent(): Record; export declare function createRealtimeVoiceGreetingStarter(send: (event: Record) => void): { start: () => boolean; reset: () => void; }; export interface RealtimeVoiceResponseCoordinator { request: (event?: Record) => void; handleEvent: (event: RealtimeServerEvent) => void; handleError: (message?: string) => boolean; reset: () => void; } export declare function createRealtimeVoiceResponseCoordinator(send: (event: Record) => void): RealtimeVoiceResponseCoordinator; /** * Voice mode owns the chat only temporarily. Restore the captured transcript * when it is still the user's active thread (or the chat has no active thread) * but never pull them back after they deliberately selected another thread. */ export declare function shouldRestoreRealtimeVoiceTranscriptThread(transcriptThreadId: string | undefined, activeThreadId: string | undefined): transcriptThreadId is string; export declare function extractCompletedRealtimeVoiceTranscript(event: RealtimeServerEvent): CompletedRealtimeVoiceTranscript | null; export interface RealtimeVoiceModeProviderProps { children: ReactNode; browserTabId?: string; } export declare function isRealtimeVoiceAbortError(error: unknown): boolean; export declare function isRealtimeVoiceSetupRequiredError(error: unknown): boolean; export declare function createRealtimeVoiceConnectionTimeout(onTimeout: () => void, timeoutMs?: number): () => void; export declare function createRealtimeVoiceConnectionGate(onTimeout: () => void, timeoutMs?: number): { markTransportReady: () => void; markSessionCreated: () => void; cancel: () => void; }; interface RealtimeVoiceSessionOptions { browserTabId?: string; signal?: AbortSignal; preferences?: RealtimeVoicePreferences; browserLanguages?: readonly string[]; } export declare function createRealtimeVoiceSessionWithCapability(offerSdp: string, options?: RealtimeVoiceSessionOptions): Promise; /** Backwards-compatible SDP-only session helper for existing client callers. */ export declare function createRealtimeVoiceSession(offerSdp: string, options?: RealtimeVoiceSessionOptions): Promise; export declare function executeRealtimeVoiceTool(input: { name: string; args: Record; callId: string; sessionId?: string; browserTabId?: string; capability?: string; signal?: AbortSignal; }): Promise; export declare function extractRealtimeVoiceSessionTools(event: RealtimeServerEvent): RealtimeVoiceFunctionTool[] | null; /** * Merge search-discovered schemas into the live manifest. Pinned navigation * and discovery tools stay available, then the newest discoveries take the * remaining slots ahead of lower-priority tools from the original manifest. */ export declare function mergeRealtimeVoiceToolManifest(currentTools: readonly RealtimeVoiceFunctionTool[], expandedTools: readonly RealtimeVoiceFunctionTool[]): RealtimeVoiceFunctionTool[]; export interface RealtimeVoiceToolManifestCoordinator { enqueue: (result: RealtimeVoiceToolResult) => void; setSessionTools: (tools: readonly RealtimeVoiceFunctionTool[]) => void; handleError: (eventId: string | undefined, message?: string) => boolean; reset: () => void; getTools: () => readonly RealtimeVoiceFunctionTool[]; } /** * Realtime treats `session.update.tools` as a full replacement. Serialize * discovery updates and wait for a confirming `session.updated` manifest * before returning the search result and allowing the next model response. */ export declare function createRealtimeVoiceToolManifestCoordinator(send: (event: Record) => void, timeoutMs?: number): RealtimeVoiceToolManifestCoordinator; export declare function extractRealtimeVoiceFunctionCalls(event: RealtimeServerEvent): Array<{ name: string; callId: string; argumentsText: string; }>; export declare function listenForRealtimeVoicePageHide(cleanup: () => void): () => void; export declare function useRealtimeVoiceModeCopy(): RealtimeVoiceModeCopy; export declare function RealtimeVoiceModeProvider({ children, browserTabId, }: RealtimeVoiceModeProviderProps): import("react").JSX.Element; /** * Ensure standalone/full-page composers get realtime voice without nesting a * second session owner inside the persistent AgentSidebar provider. */ export declare function RealtimeVoiceModeBoundary({ children, browserTabId, }: RealtimeVoiceModeProviderProps): import("react").JSX.Element; export declare function useRealtimeVoiceMode(): RealtimeVoiceModeApi; export declare function useRealtimeVoiceModeOptional(): RealtimeVoiceModeApi | null; export declare function readRealtimeVoiceContext(): Promise<{ navigation: unknown; url: unknown; }>; export declare function readRealtimeVoiceContextWith(options: { readAppState?: (key: string) => Promise | unknown; resolvePath?: (path: string) => string; }): Promise<{ navigation: unknown; url: unknown; }>; export {}; //# sourceMappingURL=useRealtimeVoiceMode.d.ts.map