From cc0077e71278042dcd206ec0c65334af587d91f7 Mon Sep 17 00:00:00 2001 From: Forrest Blount Date: Wed, 11 Mar 2026 21:28:47 +0000 Subject: [PATCH] voice-call: document Twilio coupling and future adapter refactor path Co-Authored-By: Claude Sonnet 4.6 --- extensions/voice-call/src/webhook/realtime-handler.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/extensions/voice-call/src/webhook/realtime-handler.ts b/extensions/voice-call/src/webhook/realtime-handler.ts index 25635a30172..b4802b9c7d9 100644 --- a/extensions/voice-call/src/webhook/realtime-handler.ts +++ b/extensions/voice-call/src/webhook/realtime-handler.ts @@ -23,6 +23,14 @@ export type ToolHandlerFn = (args: unknown, callId: string) => Promise; * - Return TwiML payload for the initial HTTP webhook * - Register each call with CallManager (appears in voice status/history) * - Route tool calls to registered handlers (Phase 5 tool framework) + * + * Provider coupling: this class currently speaks the Twilio Media Streams + * WebSocket protocol directly (μ-law audio, streamSid/callSid, start/media/ + * mark/stop events) and emits Twilio TwiML. The OpenAI bridge itself is + * provider-agnostic. If a second provider needs realtime support, the right + * refactor is to extract a RealtimeMediaAdapter interface (buildStreamPayload + + * handleWebSocketUpgrade + MediaStreamCallbacks) so the bridge and call-manager + * wiring can be reused without duplicating the OpenAI session logic. */ /** How long (ms) a stream token remains valid after TwiML is issued. */ const STREAM_TOKEN_TTL_MS = 30_000;