import type { ModelUsage } from './model.js'; import type { VoiceAudioFormat } from './voice.js'; /** * Lightweight WebSocket client for the Node server's `WS /sessions/:id/voice` * endpoint. Server-side bridge owns the provider connection and API keys; * this client just streams audio + control messages over WS. * * Works in browsers and on Node 22+ (uses the global `WebSocket`). */ export interface VoiceWsClientOptions { /** WS URL — e.g. `ws://localhost:9111/sessions/abc/voice`. */ url: string; /** Bearer token, sent as `?token=` query param. */ authToken?: string; /** Tenant id, sent as `?tenant=` query param. */ tenantId?: string; /** Realtime voice timbre id (alloy, nova, verse, ...). */ voice?: string; /** Initial instructions / persona. */ instructions?: string; /** Audio format hint. Default `pcm16` (server-side default). */ audioFormat?: VoiceAudioFormat; /** Realtime model id — overrides server default. */ model?: string; /** Called for every event from the server. */ onEvent?: (event: VoiceWsClientEvent) => void; /** Called once when the bridge confirms the session. */ onSessionOpen?: (sessionId: string) => void; /** Called on errors (transport or server-side). */ onError?: (error: Error) => void; /** Called when the socket closes. */ onClose?: () => void; } export type VoiceWsClientEvent = { type: 'session_open'; sessionId: string; } | { type: 'audio'; audio: Uint8Array; } | { type: 'text_delta'; delta: string; role: 'assistant' | 'user'; } | { type: 'transcript'; text: string; role: 'assistant' | 'user'; } | { type: 'tool_call'; id: string; name: string; input: unknown; } | { type: 'response_done'; usage?: ModelUsage; } | { type: 'cost_limit'; scope: string; observedUsd: number; limitUsd: number; scopeKey?: string; } | { type: 'error'; message: string; }; export interface VoiceWsClientHandle { sendAudio(frame: Uint8Array): void; sendText(text: string): void; submitToolResult(input: { id: string; output: unknown; }): void; cancel(): void; close(): void; } export declare function connectFabricVoice(options: VoiceWsClientOptions): VoiceWsClientHandle; //# sourceMappingURL=voice-ws-client.d.ts.map