import type { AgentConfig, HarnessConfig } from '../types/index.js'; import type { RealtimeAudioClient } from './RealtimeAudioClient.js'; import type { OrchestrationAuthority } from '../orchestration/OrchestrationAuthority.js'; /** * Returns a harness config with `voiceMode: true` so `normalizeHarnessConfig` applies * the voice context budget and default auto-compaction (20 messages, truncate). */ export declare function withVoiceHarnessDefaults(config: HarnessConfig): HarnessConfig; /** * Transport session abstraction for audio I/O between the end-user * and the realtime runtime. This is the user-facing transport * (WebSocket, SIP, WebRTC), NOT the model client. */ export interface RealtimeTransportSession { /** Send audio frames to the end-user client. */ sendAudio(data: Uint8Array): void; /** Receive audio frames from the end-user client. */ onAudio(handler: (data: Uint8Array) => void): void; /** Called when the end-user transport closes. */ onClose(handler: () => void): void; /** Close the transport. */ close(): void; /** * Optional: called when the user interrupts (barge-in). * The transport should clear any buffered outgoing audio and * signal the client to stop playback immediately. */ onInterrupted?(handler: () => void): void; /** * Optional: clear any buffered outgoing audio. * Called by RealtimeRuntime when an interruption is detected. */ clearAudioBuffer?(): void; } /** * Configuration for constructing a RealtimeRuntime. */ export interface RealtimeRuntimeConfig { /** All agent configurations — same shape as text Runtime. */ agents: AgentConfig[]; /** Default agent to activate for new sessions. */ defaultAgentId: string; /** The orchestration authority (or config to build one). */ authority: OrchestrationAuthority; } /** * Parameters for starting a realtime session. */ export interface StartRealtimeSessionParams { /** The provider model client (Gemini, OpenAI, etc.). */ modelClient: RealtimeAudioClient; /** The end-user transport (WebSocket, SIP, etc.). */ transport: RealtimeTransportSession; /** Existing session ID, or undefined to create a new one. */ sessionId?: string; /** User ID for session scoping. */ userId?: string; /** Override the default agent. */ agentId?: string; } /** * Opaque handle for a running realtime session. * Used to stop or query a session externally. */ export interface RealtimeSessionHandle { /** The session ID. */ readonly sessionId: string; /** The call/worker ID. */ readonly callId: string; /** Stop the session. */ stop(): Promise; } /** * Core-owned realtime execution facade. * * Accepts the same AgentConfig[] as the text Runtime, composes the * OrchestrationAuthority for transport-agnostic semantics, and runs * an event-driven loop over a RealtimeAudioClient. * * This facade is provider-agnostic — it works with any RealtimeAudioClient * (Gemini, OpenAI, fake test client). Provider-specific concerns * (wire format, reconnect, audio encoding) stay in the client adapter. * * @see RFC-REALTIME-RUNTIME-AUTHORITY.md §4.3 */ export declare class RealtimeRuntime { private readonly authority; private readonly activeSessions; constructor(config: RealtimeRuntimeConfig); /** * Start a realtime session. * * This is the canonical entry point for persistent realtime execution. * It: * 1. Opens a session through the authority * 2. Prepares initial model config (prompt + tools) * 3. Connects the model client * 4. Wires the event loop (audio, transcripts, tool calls, turns) * 5. Returns a handle for external control */ startSession(params: StartRealtimeSessionParams): Promise; /** * Stop a running session by call ID. */ stopSession(callId: string): Promise; /** * Stop all active sessions. */ shutdown(): Promise; /** * Get an active session by call ID. */ getSession(callId: string): RealtimeSessionHandle | undefined; /** * Wire the event loop between transport, model client, and authority. * * This is the heart of the realtime runtime. It maps provider events * to authority operations and authority outcomes to transport/model actions. * * The event loop matches the pseudocode in RFC-REALTIME-RUNTIME-AUTHORITY.md §5. */ private wireEventLoop; /** * Handle a tool call from the model: * 1. Execute through authority (enforcement, hooks, capability routing) * 2. Send tool response back to model * 3. Act on the outcome (reconfigure, handoff, end) */ private handleToolCall; /** * Wait for the model to emit turn-complete after a tool response. * This gives the model time to generate a verbal acknowledgment * before the session reconfigures (disconnect + reconnect). * * Times out if the model doesn't complete within the budget — * this prevents hanging if the model enters a tool-call loop * or the connection drops before turn-complete fires. */ private waitForTurnComplete; }