@memberjunction/ai-realtime-client 0.0.1 → 5.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +148 -28
  2. package/dist/audio/audioMeter.d.ts +101 -0
  3. package/dist/audio/audioMeter.d.ts.map +1 -0
  4. package/dist/audio/audioMeter.js +193 -0
  5. package/dist/audio/audioMeter.js.map +1 -0
  6. package/dist/audio/micCapture.d.ts +26 -0
  7. package/dist/audio/micCapture.d.ts.map +1 -0
  8. package/dist/audio/micCapture.js +69 -0
  9. package/dist/audio/micCapture.js.map +1 -0
  10. package/dist/audio/pcmPlayback.d.ts +73 -0
  11. package/dist/audio/pcmPlayback.d.ts.map +1 -0
  12. package/dist/audio/pcmPlayback.js +78 -0
  13. package/dist/audio/pcmPlayback.js.map +1 -0
  14. package/dist/audio/pcmUtils.d.ts +17 -0
  15. package/dist/audio/pcmUtils.d.ts.map +1 -0
  16. package/dist/audio/pcmUtils.js +46 -0
  17. package/dist/audio/pcmUtils.js.map +1 -0
  18. package/dist/drivers/assemblyAIRealtimeClient.d.ts +384 -0
  19. package/dist/drivers/assemblyAIRealtimeClient.d.ts.map +1 -0
  20. package/dist/drivers/assemblyAIRealtimeClient.js +732 -0
  21. package/dist/drivers/assemblyAIRealtimeClient.js.map +1 -0
  22. package/dist/drivers/elevenLabsRealtimeClient.d.ts +362 -0
  23. package/dist/drivers/elevenLabsRealtimeClient.d.ts.map +1 -0
  24. package/dist/drivers/elevenLabsRealtimeClient.js +686 -0
  25. package/dist/drivers/elevenLabsRealtimeClient.js.map +1 -0
  26. package/dist/drivers/geminiRealtimeClient.d.ts +406 -0
  27. package/dist/drivers/geminiRealtimeClient.d.ts.map +1 -0
  28. package/dist/drivers/geminiRealtimeClient.js +675 -0
  29. package/dist/drivers/geminiRealtimeClient.js.map +1 -0
  30. package/dist/drivers/openAIRealtimeClient.d.ts +381 -0
  31. package/dist/drivers/openAIRealtimeClient.d.ts.map +1 -0
  32. package/dist/drivers/openAIRealtimeClient.js +602 -0
  33. package/dist/drivers/openAIRealtimeClient.js.map +1 -0
  34. package/dist/drivers/xaiRealtimeClient.d.ts +430 -0
  35. package/dist/drivers/xaiRealtimeClient.d.ts.map +1 -0
  36. package/dist/drivers/xaiRealtimeClient.js +676 -0
  37. package/dist/drivers/xaiRealtimeClient.js.map +1 -0
  38. package/dist/generic/baseRealtimeClient.d.ts +401 -0
  39. package/dist/generic/baseRealtimeClient.d.ts.map +1 -0
  40. package/dist/generic/baseRealtimeClient.js +226 -0
  41. package/dist/generic/baseRealtimeClient.js.map +1 -0
  42. package/dist/index.d.ts +11 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +11 -0
  45. package/dist/index.js.map +1 -0
  46. package/package.json +28 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assemblyAIRealtimeClient.js","sourceRoot":"","sources":["../../src/drivers/assemblyAIRealtimeClient.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAuB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAwB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAkB,MAAM,qBAAqB,CAAC;AAE1E,kFAAkF;AAElF,6FAA6F;AAC7F,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AA4EhD,kFAAkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,S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,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/G,CAAC;IAED,kFAAkF;IAC1E,SAAS,CAAC,KAAiB;QAC/B,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,0EAA0E;IAClE,kBAAkB;QACtB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;QAChC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IAC3B,CAAC;IAED,4EAA4E;IACpE,QAAQ,CAAC,KAA0B;QACvC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACJ,CAAA;AAvrBY,wBAAwB;IADpC,aAAa,CAAC,kBAAkB,EAAE,YAAY,CAAC;GACnC,wBAAwB,CAurBpC;;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B;IACxC,oEAAoE;AACxE,CAAC"}
@@ -0,0 +1,362 @@
1
+ import { ClientRealtimeSessionConfig, JSONObject, JSONValue } from '@memberjunction/ai';
2
+ import { BaseRealtimeClient } from '../generic/baseRealtimeClient.js';
3
+ import { IRealtimePcmPlayback } from '../audio/pcmPlayback.js';
4
+ import { IPcmMicCapture } from '../audio/micCapture.js';
5
+ /** A parsed inbound websocket frame. The Agents protocol multiplexes on `type`. */
6
+ export interface ElevenLabsServerEvent {
7
+ type?: string;
8
+ conversation_initiation_metadata_event?: {
9
+ conversation_id?: string;
10
+ agent_output_audio_format?: string;
11
+ user_input_audio_format?: string;
12
+ };
13
+ audio_event?: {
14
+ audio_base_64?: string;
15
+ event_id?: number;
16
+ };
17
+ user_transcription_event?: {
18
+ user_transcript?: string;
19
+ };
20
+ agent_response_event?: {
21
+ agent_response?: string;
22
+ };
23
+ agent_response_correction_event?: {
24
+ original_agent_response?: string;
25
+ corrected_agent_response?: string;
26
+ };
27
+ client_tool_call?: {
28
+ tool_name?: string;
29
+ tool_call_id?: string;
30
+ parameters?: JSONObject;
31
+ };
32
+ interruption_event?: {
33
+ event_id?: number;
34
+ };
35
+ ping_event?: {
36
+ event_id?: number;
37
+ ping_ms?: number;
38
+ };
39
+ vad_score_event?: {
40
+ vad_score?: number;
41
+ };
42
+ }
43
+ /**
44
+ * The minimal websocket surface this client depends on: assignable lifecycle handlers plus
45
+ * `send`/`close`. Declaring the seam as an interface (rather than the platform `WebSocket`)
46
+ * lets unit tests inject a fully in-memory fake that captures outbound frames and drives the
47
+ * handlers with ElevenLabs-shaped events — no websocket, no network.
48
+ */
49
+ export interface IElevenLabsClientSocket {
50
+ /** Invoked once the socket is open. */
51
+ onopen: (() => void) | null;
52
+ /** Invoked with each inbound frame's raw string payload. */
53
+ onmessage: ((data: string) => void) | null;
54
+ /** Invoked on a socket-level error (fatal). */
55
+ onerror: ((message: string) => void) | null;
56
+ /** Invoked when the socket closes (any reason). */
57
+ onclose: (() => void) | null;
58
+ /** Sends one JSON-serialized client frame. */
59
+ send(data: string): void;
60
+ /** Terminates the underlying connection. */
61
+ close(): void;
62
+ }
63
+ /**
64
+ * ElevenLabs Agents implementation of {@link BaseRealtimeClient}: a **browser-direct**
65
+ * conversation websocket authenticated with the server-minted SIGNED URL (the
66
+ * `EphemeralToken` IS the `wss://…&token=…` URL — no API key ever reaches the browser).
67
+ *
68
+ * Registered with the ClassFactory under the key `'elevenlabs'` — the `Provider` string the
69
+ * server's `ElevenLabsRealtime` driver stamps on its `ClientRealtimeSessionConfig`.
70
+ *
71
+ * Owns ALL ElevenLabs wire concerns (the behavioral twin of the Gemini client driver — the
72
+ * audio plane is client-owned over a websocket, no WebRTC):
73
+ * - **Connect handshake**: open the signed-URL socket → send
74
+ * `conversation_initiation_client_data` carrying the server-authored prompt override (from
75
+ * the `SessionConfig` pact) → wait for `conversation_initiation_metadata` → negotiate the
76
+ * PCM rates from `user_input_audio_format` / `agent_output_audio_format` → build the audio
77
+ * plane → `'listening'`. The state is gated on the metadata (driver obligation #7): only
78
+ * then has the platform confirmed the session — including the per-session system prompt —
79
+ * is applied.
80
+ * - **Audio in**: mic PCM16 at the negotiated input rate via the shared
81
+ * {@link createPcmMicCapture} worklet pipeline, streamed as base64 `user_audio_chunk`
82
+ * frames (note: a bare-key frame, not a `type`d one — that is the wire contract).
83
+ * - **Audio out**: `audio` events decoded into the shared {@link RealtimePcmPlayback} at the
84
+ * negotiated output rate; {@link IsAudioPlaying} comes from its playout clock.
85
+ * - **Transcripts are FINAL-only**: the Agents socket emits whole-utterance
86
+ * `user_transcript` / `agent_response` events (no interim deltas), so every transcript this
87
+ * driver emits has `IsFinal: true`. `agent_response_correction` (post-barge-in truncation)
88
+ * re-finalizes the assistant turn with the text that was ACTUALLY spoken — hosts persisting
89
+ * transcripts should treat a final assistant transcript arriving right after an
90
+ * interruption as the authoritative replacement of the previous one.
91
+ * - **Busy mapping**: `IsBusy` is set on the first `audio` / `agent_response` of a turn (and
92
+ * eagerly when this client triggers a response) and cleared on `agent_response_complete`,
93
+ * on `interruption`, and on a `client_tool_call` frame (the agent has yielded the floor
94
+ * pending the result — deadlock guard, obligation #2).
95
+ * - **Narration**: ElevenLabs has no per-response-instructions channel, so
96
+ * {@link RequestSpokenUpdate} is EMULATED Gemini-style — the instructions ride as a
97
+ * `user_message` and the response kind is stamped `'narration'` AT SEND TIME (sends are the
98
+ * turn triggers; there is no `response.created`-style confirmation frame to stamp on), then
99
+ * reset on the response boundary. Fidelity caveat: the instruction enters the conversation
100
+ * as a user turn, so the agent may occasionally reference it; hosts should phrase narration
101
+ * instructions accordingly.
102
+ * - **Cancel**: the protocol has no server-side cancel frame. {@link CancelActiveResponse}
103
+ * flushes the locally-owned playout queue (speech stops immediately) and marks the response
104
+ * inactive; residual server-side generation for a cancelled turn is simply not played.
105
+ * Spoken barge-in is handled by the platform's own VAD (which emits `interruption`), and a
106
+ * typed {@link SendText} takes the floor server-side as a fresh user turn.
107
+ * - **No usage telemetry**: the Conversational AI socket exposes no token-usage events, so
108
+ * this driver NEVER emits {@link OnUsage} (registering a handler is safe; it just never
109
+ * fires — usage accounting for ElevenLabs sessions happens platform-side).
110
+ */
111
+ export declare class ElevenLabsRealtimeClient extends BaseRealtimeClient {
112
+ private socket;
113
+ private micStream;
114
+ private micCapture;
115
+ private playback;
116
+ /** True while an agent response is in flight; gates (queues) client-triggered sends. */
117
+ private responseActive;
118
+ /** The kind of the response currently in flight; stamped at send time, reset on boundary. */
119
+ private activeResponseKind;
120
+ /** Sends deferred while a response is in flight; drained in order at the next boundary. */
121
+ private queuedSends;
122
+ /**
123
+ * Nudge guard for tool results delivered AFTER the platform closed the turn (a long
124
+ * delegation outlasting the agent's last utterance): {@link sendToolResultFrame}
125
+ * optimistically marks a response active, but if NO model output actually arrives within
126
+ * this window, the platform has silently absorbed the result — the timer fires a
127
+ * user_message nudge so the outcome is always voiced (live finding).
128
+ */
129
+ private toolResultNudgeTimer;
130
+ /**
131
+ * Tool calls awaiting their result — used to make {@link SendToolResult} EXACTLY-ONCE:
132
+ * the id is consumed when the result is accepted (queued or sent), so a duplicate send
133
+ * for the same call is dropped with a warning instead of confusing the conversation.
134
+ */
135
+ private pendingToolCallIds;
136
+ /** True once Disconnect ran — an expected socket close must not surface as fatal. */
137
+ private closedByConsumer;
138
+ /**
139
+ * The client's own view of the session state — mirrors what was last emitted, EXCEPT after
140
+ * a tool call: the host typically shows its own busy indicator then, so the client silently
141
+ * leaves `'speaking'` (no emission) until the result reply's first output re-asserts it.
142
+ */
143
+ private currentState;
144
+ /**
145
+ * Opens the client-direct conversation: socket to the signed URL, the initiation frame
146
+ * carrying the server-authored prompt override, then — once the metadata confirms the
147
+ * session config is applied — the audio plane at the NEGOTIATED sample rates. Reports
148
+ * `'listening'` only after all of that (obligation #7).
149
+ */
150
+ Connect(config: ClientRealtimeSessionConfig, micStream: MediaStream): Promise<void>;
151
+ /**
152
+ * Tears down the socket, mic capture, mic tracks, and playout engine, resets the response
153
+ * state machine, and emits a final `'closed'` (unless already `'error'`). Safe to call
154
+ * more than once.
155
+ */
156
+ Disconnect(): Promise<void>;
157
+ /**
158
+ * Injects typed text as a `user_message` (the platform's "respond to this" trigger).
159
+ * No-op when the session is not open.
160
+ *
161
+ * **SendText implies barge-in** (base-contract rule): an active spoken response is
162
+ * cancelled via {@link CancelActiveResponse} first — playback flushed, response marked
163
+ * inactive, queued sends drained — so the typed turn takes the floor immediately. If a
164
+ * drained queued send (e.g. a pending tool result) starts a new response, the text queues
165
+ * behind it, preserving the tool-result delivery invariant. Server-side the fresh user
166
+ * turn takes the floor on its own; no explicit cancel frame exists or is needed.
167
+ */
168
+ SendText(text: string): void;
169
+ /**
170
+ * @inheritdoc
171
+ *
172
+ * ElevenLabs has no cancel frame — the client OWNS the audio plane, so cancelling means:
173
+ * flush the local playout queue (speech stops immediately), mark the in-flight response
174
+ * inactive, and drain queued sends (a queued tool result takes the floor next — delivery
175
+ * is never dropped by a cancel). Residual server-side generation for the cancelled turn is
176
+ * simply never played; the platform's own VAD handles SPOKEN barge-in (emitting
177
+ * `interruption`). No-op when nothing is active.
178
+ */
179
+ CancelActiveResponse(): void;
180
+ /**
181
+ * Injects background context via `contextual_update` — NATIVE on this provider: the
182
+ * platform's purpose-built non-interrupting context channel. Sent immediately even while
183
+ * a response is in flight (the platform guarantees it never triggers or disturbs
184
+ * generation), so unlike the Gemini driver no queueing applies.
185
+ */
186
+ SendContextNote(text: string): void;
187
+ /**
188
+ * Triggers ONE short spoken update. EMULATED as a `user_message` carrying the
189
+ * instructions, with the resulting response stamped `Kind: 'narration'` at send time
190
+ * (reset on the response boundary) — see the class-level fidelity caveat. Queued behind
191
+ * any in-flight response (a `user_message` sent mid-response would barge in on it), per
192
+ * the base contract's collision rule.
193
+ */
194
+ RequestSpokenUpdate(instructions: string): void;
195
+ /**
196
+ * Feeds an executed tool's result back via `client_tool_result`, correlated by the
197
+ * platform's `tool_call_id`. EXACTLY-ONCE: the pending id is consumed when the result is
198
+ * accepted, and a duplicate (or unknown) callID is dropped with a warning. Sent
199
+ * immediately when idle — the platform speaks the result as the turn's continuation —
200
+ * otherwise queued behind the in-flight response (e.g. a progress narration) so the
201
+ * trigger is never lost.
202
+ */
203
+ SendToolResult(callID: string, outputJson: string): void;
204
+ /**
205
+ * Mutes / unmutes by toggling the mic tracks' `enabled` flag: the capture pipeline stays
206
+ * up and streams SILENCE while muted (the provider's VAD sees a continuous stream and the
207
+ * un-mute is glitch-free — same policy as the OpenAI and Gemini client drivers).
208
+ */
209
+ SetMuted(muted: boolean): void;
210
+ /** @inheritdoc */
211
+ get IsBusy(): boolean;
212
+ /**
213
+ * @inheritdoc
214
+ *
215
+ * Computed directly from the playout engine's playhead clock — this client OWNS the
216
+ * output buffer, so "audibly playing" is precisely "scheduled audio extends beyond the
217
+ * audio context's current time".
218
+ */
219
+ get IsAudioPlaying(): boolean;
220
+ /**
221
+ * Creation seam for the conversation websocket. Production wraps the platform-global
222
+ * `WebSocket` opened against the signed URL; unit tests override this to return an
223
+ * in-memory fake. Handlers are attached by {@link Connect} AFTER this returns, so the
224
+ * implementation must not require them at construction time.
225
+ */
226
+ protected createSocket(signedUrl: string): IElevenLabsClientSocket;
227
+ /**
228
+ * Creation seam for the mic-capture pipeline at the NEGOTIATED input rate. Production
229
+ * delegates to the shared {@link createPcmMicCapture}; unit tests override this with a
230
+ * no-op fake (and may capture `onPcmChunk` to simulate mic frames).
231
+ */
232
+ protected createMicCapture(micStream: MediaStream, sampleRate: number, onPcmChunk: (base64Pcm16: string) => void): Promise<IPcmMicCapture>;
233
+ /**
234
+ * Creation seam for the playout engine at the NEGOTIATED output rate. Production returns
235
+ * the shared {@link RealtimePcmPlayback}.
236
+ */
237
+ protected createPlayback(sampleRate: number): IRealtimePcmPlayback;
238
+ /** Resolver for the in-flight Connect's metadata wait (null outside Connect). */
239
+ private onInitiationMetadata;
240
+ /**
241
+ * Extracts the wire-shaped `conversation_config_override` from the server-minted
242
+ * `SessionConfig` pact (`{ agentId, overrides, config }` — authored by the server's
243
+ * `ElevenLabsRealtime.CreateClientSession`). Falls back to an empty override when absent
244
+ * (the managed agent then runs on its stored base prompt).
245
+ */
246
+ private parseOverrides;
247
+ /**
248
+ * Parses a `pcm_<rate>` audio-format tag from the initiation metadata. Non-PCM formats
249
+ * (e.g. `ulaw_8000` — a telephony-only configuration) are not playable/encodable by the
250
+ * shared PCM pipeline; the driver warns and falls back to the platform default so the
251
+ * session degrades loudly rather than throwing.
252
+ */
253
+ static ParsePcmRate(format: string | undefined, direction: 'input' | 'output'): number;
254
+ /** Streams one base64 PCM16 mic chunk as a bare-key `user_audio_chunk` frame. */
255
+ private sendMicChunk;
256
+ /** Surfaces a fatal socket error and marks the session unusable (obligation #6). */
257
+ private handleSocketError;
258
+ /**
259
+ * A socket close the CONSUMER didn't ask for is fatal: ElevenLabs hard-closes at signed-URL
260
+ * expiry and when the agent itself ends the conversation, so an unexpected close is how
261
+ * credential / conversation death reaches the host (obligation #6).
262
+ */
263
+ private handleSocketClose;
264
+ /** Parses one raw socket payload; non-JSON frames are ignored. */
265
+ private handleSocketMessage;
266
+ /** Multiplexes one inbound frame to the focused per-concern handlers. */
267
+ private handleServerEvent;
268
+ /** Decodes one base64 model-audio frame into the playout queue and marks generation live. */
269
+ private handleAudio;
270
+ /** User transcript: whole-utterance FINAL (this provider emits no interim deltas). */
271
+ private handleUserTranscript;
272
+ /**
273
+ * Agent response: the turn's complete text, emitted FINAL with the ACTIVE response kind so
274
+ * narration turns are tagged correctly (stamp-at-send — see the class doc).
275
+ */
276
+ private handleAgentResponse;
277
+ /**
278
+ * Post-barge-in correction: re-finalizes the assistant turn with the text that was
279
+ * ACTUALLY spoken before the interruption cut it off. Emitted as a fresh FINAL assistant
280
+ * transcript, `Kind: 'normal'` (the interruption already reset the response kind; a
281
+ * truncated narration's correction is still just what was audibly said) — stamped
282
+ * {@link RealtimeClientTranscript.ReplacesPrevious} so hosts UPDATE the superseded turn
283
+ * in place instead of persisting both (closes the §10 "Transcript `Replaces` marker" gap).
284
+ */
285
+ private handleAgentResponseCorrection;
286
+ /**
287
+ * Response boundary: release the busy lock, reset the response kind, drain queued sends
288
+ * (stopping at the first one that starts a new response), and return the floor.
289
+ */
290
+ private handleResponseComplete;
291
+ /**
292
+ * Surfaces the agent's tool call to the host. Two deliberate behaviors mirror the other
293
+ * drivers: (1) the client silently leaves `'speaking'` (no emission) so a host-rendered
294
+ * busy indicator isn't clobbered by the turn's trailing frames (obligation #1); (2)
295
+ * `responseActive` is CLEARED — the agent has yielded the floor pending the result, so a
296
+ * queued send can never deadlock (obligation #2). The queue is NOT drained here: a queued
297
+ * narration must not inject a user turn between the tool call and its result.
298
+ */
299
+ private handleClientToolCall;
300
+ /**
301
+ * True barge-in: the platform's VAD detected the user cutting off active agent output
302
+ * (ElevenLabs only emits `interruption` for actual barge-ins, but the emission is still
303
+ * gated on something genuinely being active — a spurious frame while idle is NOT an
304
+ * interruption per the base contract). Flush playout, surface it, reset the response
305
+ * machine, give the floor back. The queue is NOT drained — the user has the floor; queued
306
+ * sends flush at the next response boundary.
307
+ */
308
+ private handleInterruption;
309
+ /**
310
+ * First model output of a response (audio or the response text): the agent is busy and
311
+ * the client is audibly / imminently `'speaking'`.
312
+ */
313
+ private markGenerationStarted;
314
+ /**
315
+ * Runs a send immediately when no response is in flight; otherwise queues it for the next
316
+ * boundary (`agent_response_complete`). A `user_message` sent mid-response barges in on
317
+ * it, so deferral is the safe default — mirroring the Gemini driver's rule.
318
+ */
319
+ private enqueueOrRun;
320
+ /**
321
+ * Drains queued sends in order at a response boundary, stopping as soon as one starts a
322
+ * new response (sets {@link responseActive}) — the rest wait for that response to finish.
323
+ */
324
+ private flushQueuedSends;
325
+ /**
326
+ * Sends a `user_message` that triggers a response, stamping the upcoming response's kind
327
+ * at send time and eagerly marking the agent busy. `emitSpeaking` mirrors the other
328
+ * drivers: typed text reflects `'speaking'` immediately; narration waits for the first
329
+ * model output.
330
+ */
331
+ private sendUserMessage;
332
+ /**
333
+ * Sends the `client_tool_result` frame (the platform speaks the result as the turn's
334
+ * continuation — no explicit generation trigger exists or is needed) and eagerly marks
335
+ * the agent busy so a queued narration can't slip in before the spoken result.
336
+ */
337
+ private sendToolResultFrame;
338
+ /** How long to wait for real model output after a tool result before nudging. */
339
+ private static readonly ToolResultNudgeMs;
340
+ /** Arms the absorbed-tool-result nudge (see {@link toolResultNudgeTimer}). */
341
+ private armToolResultNudge;
342
+ /** Cancels the nudge — real model output arrived (or the session is resetting). */
343
+ private cancelToolResultNudge;
344
+ /**
345
+ * Parses a JSON-stringified tool result into a structured value for the `result` slot,
346
+ * falling back to the raw string so a free-text result still round-trips.
347
+ */
348
+ static ParseToolOutput(output: string): JSONValue;
349
+ /** JSON-serializes and sends one client frame (no-op once the socket is gone). */
350
+ private sendFrame;
351
+ /** Resets the per-session response state machine (used on Disconnect). */
352
+ private resetResponseState;
353
+ /** Updates the client's own state view and emits the change to the host. */
354
+ private setState;
355
+ }
356
+ /**
357
+ * Tree-shaking prevention: bundlers cannot see that {@link ElevenLabsRealtimeClient} is
358
+ * instantiated dynamically through the ClassFactory, so a consumer must call this no-op
359
+ * to create a static code path that keeps the `@RegisterClass` side effect alive.
360
+ */
361
+ export declare function LoadElevenLabsRealtimeClient(): void;
362
+ //# sourceMappingURL=elevenLabsRealtimeClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elevenLabsRealtimeClient.d.ts","sourceRoot":"","sources":["../../src/drivers/elevenLabsRealtimeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,UAAU,EAAE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