@rimelabs/sdk 0.1.0-alpha.2 → 0.1.0-alpha.21

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 (85) hide show
  1. package/CHANGELOG.md +155 -0
  2. package/LICENSE-PRISM +201 -0
  3. package/NOTICE-PRISM +9 -0
  4. package/README.md +279 -114
  5. package/dist/auth.d.ts +9 -3
  6. package/dist/auth.js +12 -4
  7. package/dist/cancellation.d.ts +6 -0
  8. package/dist/cancellation.js +54 -0
  9. package/dist/client.d.ts +24 -23
  10. package/dist/client.js +41 -92
  11. package/dist/grpc.d.ts +27 -0
  12. package/dist/grpc.js +175 -0
  13. package/dist/index.d.ts +10 -2
  14. package/dist/index.js +6 -2
  15. package/dist/pcm.d.ts +21 -0
  16. package/dist/pcm.js +52 -0
  17. package/dist/realtime/async.d.ts +23 -0
  18. package/dist/realtime/async.js +87 -0
  19. package/dist/realtime/audio.d.ts +2 -0
  20. package/dist/realtime/audio.js +11 -0
  21. package/dist/realtime/client.d.ts +12 -0
  22. package/dist/realtime/client.js +139 -0
  23. package/dist/realtime/conversation.d.ts +47 -0
  24. package/dist/realtime/conversation.js +321 -0
  25. package/dist/realtime/faults.d.ts +2 -0
  26. package/dist/realtime/faults.js +25 -0
  27. package/dist/realtime/protocol.d.ts +99 -0
  28. package/dist/realtime/protocol.js +432 -0
  29. package/dist/realtime/session.d.ts +79 -0
  30. package/dist/realtime/session.js +808 -0
  31. package/dist/realtime/settings.d.ts +11 -0
  32. package/dist/realtime/settings.js +142 -0
  33. package/dist/realtime/transport.d.ts +16 -0
  34. package/dist/realtime/transport.js +86 -0
  35. package/dist/realtime/types.d.ts +292 -0
  36. package/dist/realtime/types.js +12 -0
  37. package/dist/stt/audio.d.ts +15 -0
  38. package/dist/stt/audio.js +46 -0
  39. package/dist/stt/client.d.ts +17 -0
  40. package/dist/stt/client.js +121 -0
  41. package/dist/stt/policy.d.ts +11 -0
  42. package/dist/stt/policy.js +11 -0
  43. package/dist/stt/protocol.d.ts +14 -0
  44. package/dist/stt/protocol.js +76 -0
  45. package/dist/stt/queue.d.ts +16 -0
  46. package/dist/stt/queue.js +45 -0
  47. package/dist/stt/stream.d.ts +48 -0
  48. package/dist/stt/stream.js +224 -0
  49. package/dist/stt/transport.d.ts +15 -0
  50. package/dist/stt/transport.js +94 -0
  51. package/dist/stt/types.d.ts +51 -0
  52. package/dist/stt/types.js +1 -0
  53. package/dist/{audio.d.ts → tts/audio.d.ts} +9 -0
  54. package/dist/{audio.js → tts/audio.js} +44 -4
  55. package/dist/tts/buffer.d.ts +3 -0
  56. package/dist/tts/buffer.js +53 -0
  57. package/dist/tts/client.d.ts +53 -0
  58. package/dist/tts/client.js +151 -0
  59. package/dist/tts/lexicon.d.ts +7 -0
  60. package/dist/tts/lexicon.js +23 -0
  61. package/dist/{policy.d.ts → tts/policy.d.ts} +2 -3
  62. package/dist/tts/policy.js +41 -0
  63. package/dist/{stream.d.ts → tts/stream.d.ts} +15 -2
  64. package/dist/{stream.js → tts/stream.js} +54 -30
  65. package/dist/tts/timestamps.d.ts +24 -0
  66. package/dist/tts/timestamps.js +46 -0
  67. package/dist/{transport.d.ts → tts/transport.d.ts} +10 -13
  68. package/dist/tts/transport.js +133 -0
  69. package/dist/validation.d.ts +5 -0
  70. package/dist/validation.js +28 -0
  71. package/docs/realtime.md +537 -0
  72. package/docs/stt.md +186 -0
  73. package/docs/tts.md +284 -0
  74. package/package.json +14 -12
  75. package/dist/policy.js +0 -82
  76. package/dist/sentences.d.ts +0 -21
  77. package/dist/sentences.js +0 -142
  78. package/dist/transport.js +0 -223
  79. package/vendor/LICENSE.blingfire +0 -21
  80. package/vendor/README.md +0 -11
  81. package/vendor/blingfire.cjs +0 -4
  82. package/vendor/blingfire.upstream.cjs +0 -1
  83. package/vendor/blingfire.wasm +0 -0
  84. /package/dist/{queue.d.ts → tts/queue.d.ts} +0 -0
  85. /package/dist/{queue.js → tts/queue.js} +0 -0
@@ -0,0 +1,432 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /** Decode only the protocol fields the SDK uses. Unknown events and fields stay open. */
3
+ import { RimeInputError, RimeStreamError } from "../errors.js";
4
+ import { normalizeFault } from "./faults.js";
5
+ /** A copy of the client's labels for every reply: keys to strings. */
6
+ export function responseMetadata(value) {
7
+ if (!value ||
8
+ typeof value !== "object" ||
9
+ ![Object.prototype, null].includes(Object.getPrototypeOf(value)) ||
10
+ Object.values(value).some((label) => typeof label !== "string"))
11
+ throw new RimeInputError("responseMetadata must map keys to strings");
12
+ return Object.freeze({ ...value });
13
+ }
14
+ /** A request carries its result type and checks it before exposing the result. */
15
+ export class Request {
16
+ kind;
17
+ accepts;
18
+ allowsItemCreated;
19
+ constructor(kind, accepts, allowsItemCreated = false) {
20
+ this.kind = kind;
21
+ this.accepts = accepts;
22
+ this.allowsItemCreated = allowsItemCreated;
23
+ }
24
+ result(event) {
25
+ if (!this.accepts(event))
26
+ throw new RimeStreamError(`Unexpected ${event.kind} acknowledgment for ${this.kind}`);
27
+ return event;
28
+ }
29
+ check(event) {
30
+ this.result(event);
31
+ }
32
+ }
33
+ export const requests = {
34
+ update: new Request("session.update", (e) => e.kind === "session.updated"),
35
+ item: new Request("conversation.item.create", (e) => e.kind === "item.created"),
36
+ toolResult: new Request("conversation.item.create", (e) => e.kind === "tool.result.created"),
37
+ create: new Request("response.create", (e) => e.kind === "response.started"),
38
+ text: new Request("response.create", (e) => e.kind === "response.started", true),
39
+ cancel: new Request("response.cancel", (e) => e.kind === "response.ended"),
40
+ clear: new Request("input_audio_buffer.clear", (e) => e.kind === "audio.cleared"),
41
+ truncate: new Request("conversation.item.truncate", (e) => e.kind === "item.truncated"),
42
+ };
43
+ function invalid(field) {
44
+ throw new RimeStreamError(`Invalid realtime field: ${field}`);
45
+ }
46
+ function object(value, field) {
47
+ if (!value || typeof value !== "object" || Array.isArray(value))
48
+ return invalid(field);
49
+ return value;
50
+ }
51
+ function string(value, field) {
52
+ if (typeof value !== "string")
53
+ return invalid(field);
54
+ return value;
55
+ }
56
+ function id(value, field) {
57
+ const result = string(value, field);
58
+ if (!result)
59
+ return invalid(field);
60
+ return result;
61
+ }
62
+ function optionalString(value, field) {
63
+ return value == null ? null : string(value, field);
64
+ }
65
+ function integer(value, field) {
66
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
67
+ return invalid(field);
68
+ return value;
69
+ }
70
+ function revision(value) {
71
+ return value.prism_settings_revision === undefined
72
+ ? null
73
+ : integer(value.prism_settings_revision, "prism_settings_revision");
74
+ }
75
+ function duration(value, field) {
76
+ if (value == null)
77
+ return null;
78
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0)
79
+ return invalid(field);
80
+ return value;
81
+ }
82
+ function session(value) {
83
+ const view = object(value, "session");
84
+ const detection = view.turn_detection === undefined
85
+ ? {}
86
+ : object(view.turn_detection, "session.turn_detection");
87
+ let eagerness = null;
88
+ if (detection.eagerness !== undefined) {
89
+ const value = string(detection.eagerness, "session.turn_detection.eagerness");
90
+ eagerness =
91
+ value === "low" ||
92
+ value === "medium" ||
93
+ value === "high" ||
94
+ value === "auto"
95
+ ? value
96
+ : "unknown";
97
+ }
98
+ let endOfTurnTimeoutMs = null;
99
+ if (detection.prism_end_of_turn_timeout_ms !== undefined) {
100
+ const value = detection.prism_end_of_turn_timeout_ms;
101
+ if (typeof value !== "number" ||
102
+ !Number.isInteger(value) ||
103
+ value < 1000 ||
104
+ value > 10000)
105
+ invalid("session.turn_detection.prism_end_of_turn_timeout_ms");
106
+ endOfTurnTimeoutMs = value;
107
+ }
108
+ const waits = view.prism_tool_waits === undefined
109
+ ? {}
110
+ : object(view.prism_tool_waits, "session.prism_tool_waits");
111
+ if (view.prism_tool_waits !== undefined &&
112
+ (!("result_timeout_s" in waits) || !("continuation_timeout_s" in waits)))
113
+ invalid("session.prism_tool_waits");
114
+ const interrupt = view.prism_effective_interrupt_response;
115
+ if (interrupt !== undefined && typeof interrupt !== "boolean")
116
+ invalid("session.prism_effective_interrupt_response");
117
+ return {
118
+ settingsRevision: revision(view),
119
+ id: id(view.id, "session.id"),
120
+ requestId: optionalString(view.request_id, "session.request_id"),
121
+ responseMetadata: view.prism_response_metadata === undefined
122
+ ? null
123
+ : clientMetadata(object(view.prism_response_metadata, "session.prism_response_metadata")),
124
+ voice: view.voice === undefined ? "" : string(view.voice, "session.voice"),
125
+ interruptOnSpeech: interrupt ?? null,
126
+ turnDetection: Object.freeze({ eagerness, endOfTurnTimeoutMs }),
127
+ toolResultTimeoutS: duration(waits.result_timeout_s, "result_timeout_s"),
128
+ toolContinuationTimeoutS: duration(waits.continuation_timeout_s, "continuation_timeout_s"),
129
+ };
130
+ }
131
+ /** The client's labels in `metadata`: its string values under keys that are
132
+ * not Prism's `prism_` ones. */
133
+ function clientMetadata(metadata) {
134
+ return Object.freeze(Object.fromEntries(Object.entries(metadata).filter((entry) => !entry[0].startsWith("prism_") && typeof entry[1] === "string")));
135
+ }
136
+ function fault(value) {
137
+ const error = object(value, "error");
138
+ const owner = error.owner == null ? {} : object(error.owner, "error.owner");
139
+ const scope = error.scope === undefined ? "unknown" : string(error.scope, "error.scope");
140
+ const calls = owner.call_ids ?? [];
141
+ if (!Array.isArray(calls))
142
+ return invalid("error.owner.call_ids");
143
+ const code = error.code === undefined ? "unknown" : string(error.code, "error.code");
144
+ return normalizeFault({
145
+ code,
146
+ message: error.message === undefined ? "" : string(error.message, "error.message"),
147
+ scope: scope === "event" ||
148
+ scope === "utterance" ||
149
+ scope === "response" ||
150
+ scope === "tool_roundtrip" ||
151
+ scope === "session"
152
+ ? scope
153
+ : "unknown",
154
+ requestId: optionalString(owner.event_id, "error.owner.event_id"),
155
+ responseId: optionalString(owner.response_id, "error.owner.response_id"),
156
+ itemId: optionalString(owner.item_id, "error.owner.item_id"),
157
+ callIds: calls.map((value) => id(value, "error.owner.call_ids")),
158
+ correlationId: optionalString(error.correlation_id, "error.correlation_id"),
159
+ parameter: optionalString(error.param, "error.param"),
160
+ });
161
+ }
162
+ function json(value) {
163
+ if (value === null || typeof value === "string" || typeof value === "boolean")
164
+ return value;
165
+ if (typeof value === "number" && Number.isFinite(value))
166
+ return value;
167
+ if (Array.isArray(value))
168
+ return value.map(json);
169
+ const entries = object(value, "arguments");
170
+ return Object.fromEntries(Object.entries(entries).map(([key, value]) => [key, json(value)]));
171
+ }
172
+ function argumentsObject(value) {
173
+ const result = json(JSON.parse(string(value, "arguments")));
174
+ if (!result || typeof result !== "object" || Array.isArray(result))
175
+ return invalid("arguments");
176
+ return result;
177
+ }
178
+ function audio(value) {
179
+ const encoded = string(value, "delta");
180
+ if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(encoded))
181
+ return invalid("audio.delta");
182
+ const data = Buffer.from(encoded, "base64");
183
+ if (data.length % 2)
184
+ return invalid("audio.delta");
185
+ return Object.freeze({
186
+ data,
187
+ format: Object.freeze({
188
+ sampleRate: 24000,
189
+ channels: 1,
190
+ encoding: "pcm_s16le",
191
+ }),
192
+ });
193
+ }
194
+ export function decode(raw, sessionId) {
195
+ try {
196
+ return decodeValue(JSON.parse(raw), sessionId);
197
+ }
198
+ catch (error) {
199
+ if (error instanceof RimeStreamError)
200
+ throw error;
201
+ throw new RimeStreamError("Invalid realtime event");
202
+ }
203
+ }
204
+ function decodeValue(value, sessionId) {
205
+ const event = object(value, "event"), kind = string(event.type, "type");
206
+ const ref = (value) => {
207
+ if (sessionId === null)
208
+ throw new RimeStreamError("Event arrived before session.created");
209
+ return Object.freeze({ sessionId, responseId: id(value, "response.id") });
210
+ };
211
+ let payload;
212
+ switch (kind) {
213
+ case "session.created":
214
+ payload = { kind: "session.created", session: session(event.session) };
215
+ break;
216
+ case "session.updated":
217
+ payload = { kind: "session.updated", session: session(event.session) };
218
+ break;
219
+ case "conversation.item.created": {
220
+ const item = object(event.item, "item");
221
+ if (item.type === "function_call_output")
222
+ payload = {
223
+ kind: "tool.result.created",
224
+ callId: id(item.call_id, "item.call_id"),
225
+ };
226
+ else {
227
+ if (item.type !== undefined && item.type !== "message")
228
+ invalid("item.type");
229
+ payload = { kind: "item.created", itemId: id(item.id, "item.id") };
230
+ }
231
+ break;
232
+ }
233
+ case "input_audio_buffer.cleared":
234
+ payload = { kind: "audio.cleared" };
235
+ break;
236
+ case "conversation.item.truncated":
237
+ payload = {
238
+ kind: "item.truncated",
239
+ itemId: id(event.item_id, "item_id"),
240
+ contentIndex: integer(event.content_index, "content_index"),
241
+ };
242
+ break;
243
+ case "prism.typed_input.ready":
244
+ payload = { kind: "input.ready" };
245
+ break;
246
+ case "prism.input_audio_buffer.speech_hint":
247
+ payload = {
248
+ kind: "speech.hint",
249
+ audioStartMs: integer(event.audio_start_ms, "audio_start_ms"),
250
+ };
251
+ break;
252
+ case "input_audio_buffer.speech_started":
253
+ payload = {
254
+ kind: "speech.started",
255
+ itemId: id(event.item_id, "item_id"),
256
+ audioStartMs: integer(event.audio_start_ms, "audio_start_ms"),
257
+ };
258
+ break;
259
+ case "input_audio_buffer.speech_stopped": {
260
+ const reason = event.prism_end_reason === undefined
261
+ ? null
262
+ : string(event.prism_end_reason, "prism_end_reason");
263
+ payload = {
264
+ kind: "speech.stopped",
265
+ itemId: id(event.item_id, "item_id"),
266
+ audioEndMs: integer(event.audio_end_ms, "audio_end_ms"),
267
+ endReason: reason === null ||
268
+ reason === "semantic" ||
269
+ reason === "timeout" ||
270
+ reason === "silence" ||
271
+ reason === "max_duration" ||
272
+ reason === "detector_changed"
273
+ ? reason
274
+ : "unknown",
275
+ };
276
+ break;
277
+ }
278
+ case "input_audio_buffer.committed":
279
+ payload = {
280
+ kind: "input.committed",
281
+ itemId: id(event.item_id, "item_id"),
282
+ };
283
+ break;
284
+ case "conversation.item.input_audio_transcription.delta":
285
+ payload = {
286
+ kind: "transcript.delta",
287
+ itemId: id(event.item_id, "item_id"),
288
+ delta: string(event.delta, "delta"),
289
+ };
290
+ break;
291
+ case "conversation.item.input_audio_transcription.completed":
292
+ payload = {
293
+ kind: "transcript.final",
294
+ itemId: id(event.item_id, "item_id"),
295
+ text: string(event.transcript, "transcript"),
296
+ };
297
+ break;
298
+ case "conversation.item.input_audio_transcription.failed": {
299
+ const error = object(event.error, "error"), itemId = id(event.item_id, "item_id");
300
+ payload = {
301
+ kind: "transcript.failed",
302
+ itemId,
303
+ error: fault({
304
+ code: string(error.code, "error.code"),
305
+ message: string(error.message, "error.message"),
306
+ scope: "utterance",
307
+ owner: { item_id: itemId },
308
+ }),
309
+ };
310
+ break;
311
+ }
312
+ case "response.created": {
313
+ const response = object(event.response, "response"), metadata = response.metadata == null
314
+ ? {}
315
+ : object(response.metadata, "metadata");
316
+ const cause = metadata.prism_cause === undefined
317
+ ? undefined
318
+ : string(metadata.prism_cause, "prism_cause");
319
+ const parent = optionalString(metadata.prism_parent_response_id, "prism_parent_response_id");
320
+ const inputItemId = optionalString(metadata.prism_input_item_id, "prism_input_item_id");
321
+ const inputItemIds = response.prism_input_item_ids ??
322
+ (inputItemId === null ? [] : [inputItemId]);
323
+ if (!Array.isArray(inputItemIds))
324
+ return invalid("prism_input_item_ids");
325
+ payload = {
326
+ kind: "response.started",
327
+ settingsRevision: revision(response),
328
+ response: ref(response.id),
329
+ cause: cause === undefined
330
+ ? "speech"
331
+ : cause === "user_text"
332
+ ? "text"
333
+ : cause === "tool_continuation"
334
+ ? "tools"
335
+ : cause === "proactive"
336
+ ? "proactive"
337
+ : "unknown",
338
+ parent: parent === null ? null : ref(parent),
339
+ inputItemId,
340
+ metadata: clientMetadata(metadata),
341
+ inputItemIds: Object.freeze(inputItemIds.map((value) => id(value, "prism_input_item_ids"))),
342
+ };
343
+ break;
344
+ }
345
+ case "response.done": {
346
+ const response = object(event.response, "response"), metadata = response.metadata == null
347
+ ? {}
348
+ : object(response.metadata, "metadata");
349
+ const details = response.status_details == null
350
+ ? {}
351
+ : object(response.status_details, "status_details");
352
+ const status = string(response.status, "response.status");
353
+ payload = {
354
+ kind: "response.ended",
355
+ settingsRevision: revision(response),
356
+ response: ref(response.id),
357
+ status: status === "completed" ||
358
+ status === "cancelled" ||
359
+ status === "failed"
360
+ ? status
361
+ : "unknown",
362
+ reason: optionalString(details.reason, "reason"),
363
+ drainToken: optionalString(metadata.prism_drain_token, "prism_drain_token"),
364
+ };
365
+ break;
366
+ }
367
+ case "response.function_call_arguments.done":
368
+ payload = {
369
+ kind: "tool.call",
370
+ call: Object.freeze({
371
+ ...ref(event.response_id),
372
+ callId: id(event.call_id, "call_id"),
373
+ }),
374
+ itemId: id(event.item_id, "item_id"),
375
+ name: string(event.name, "name"),
376
+ arguments: argumentsObject(event.arguments),
377
+ };
378
+ break;
379
+ case "response.output_item.added":
380
+ case "response.text.delta":
381
+ case "response.text.done":
382
+ case "response.audio.delta":
383
+ case "response.audio.done": {
384
+ const item = kind === "response.output_item.added"
385
+ ? object(event.item, "item")
386
+ : null;
387
+ if (item && string(item.type, "item.type") !== "message")
388
+ return null;
389
+ const contentIndex = kind === "response.output_item.added" &&
390
+ event.content_index === undefined
391
+ ? 0
392
+ : integer(event.content_index, "content_index");
393
+ if (contentIndex !== 0)
394
+ throw new RimeStreamError("Unsupported Prism contract: content_index must be zero");
395
+ const output = Object.freeze({
396
+ response: ref(event.response_id),
397
+ itemId: id(item ? item.id : event.item_id, "item_id"),
398
+ outputIndex: integer(event.output_index, "output_index"),
399
+ contentIndex,
400
+ });
401
+ if (kind === "response.output_item.added")
402
+ payload = { kind: "message.started", output };
403
+ else if (kind === "response.text.delta")
404
+ payload = {
405
+ kind: "text.delta",
406
+ output,
407
+ delta: string(event.delta, "delta"),
408
+ };
409
+ else if (kind === "response.text.done")
410
+ payload = {
411
+ kind: "text.done",
412
+ output,
413
+ text: string(event.text, "text"),
414
+ };
415
+ else if (kind === "response.audio.delta")
416
+ payload = { kind: "audio.delta", output, audio: audio(event.delta) };
417
+ else
418
+ payload = { kind: "audio.done", output };
419
+ break;
420
+ }
421
+ case "error":
422
+ payload = { kind: "error", error: fault(event.error) };
423
+ break;
424
+ default:
425
+ return null;
426
+ }
427
+ return {
428
+ eventId: event.event_id === undefined ? "" : string(event.event_id, "event_id"),
429
+ requestId: optionalString(event.prism_request_event_id, "prism_request_event_id"),
430
+ payload,
431
+ };
432
+ }
@@ -0,0 +1,79 @@
1
+ import { RealtimeConnection } from "./transport.js";
2
+ import * as t from "./types.js";
3
+ import * as p from "./protocol.js";
4
+ /** @internal Read the policy captured before queuing the response event. */
5
+ export declare function responseInterruptsSpeech(session: RealtimeSession, response: t.ResponseRef): boolean;
6
+ /** @internal Recognize only failures created by intentional session closure. */
7
+ export declare function isSessionCloseError(error: unknown): boolean;
8
+ /** One conversation. Consume events concurrently with session operations. */
9
+ export declare class RealtimeSession {
10
+ private readonly socket;
11
+ private readonly timeouts;
12
+ private readonly forget;
13
+ private readonly created;
14
+ private sessionId;
15
+ private sessionInfo;
16
+ private readonly lifetime;
17
+ private failure;
18
+ private closed;
19
+ private closing;
20
+ private consuming;
21
+ private readonly queue;
22
+ private readonly queued;
23
+ private readonly ready;
24
+ private readyEpoch;
25
+ private readonly admission;
26
+ private readonly writeLock;
27
+ private readonly audioLock;
28
+ private readonly truncateLock;
29
+ private readonly toolLock;
30
+ private readonly pending;
31
+ private readonly responses;
32
+ private readonly interruptionPolicies;
33
+ private latest;
34
+ private readonly tasks;
35
+ private converter;
36
+ /** @internal Use client.realtime.connect(). */
37
+ constructor(socket: RealtimeConnection, timeouts: Required<t.RealtimeTimeouts>, forget: () => void);
38
+ /** @internal */
39
+ initialize(settings: p.SessionSettings, signal: AbortSignal): Promise<void>;
40
+ get info(): t.SessionInfo;
41
+ get events(): AsyncIterableIterator<t.SessionEvent<t.NormalizedRealtimeFault>>;
42
+ private readEvents;
43
+ private id;
44
+ private check;
45
+ private response;
46
+ private track;
47
+ private capacity;
48
+ private operation;
49
+ private locked;
50
+ private send;
51
+ private request;
52
+ private runRequest;
53
+ private abandon;
54
+ private create;
55
+ /** Apply supplied settings and wait for acknowledgment. Tools replace the
56
+ * complete list. Replies already started keep their original settings.
57
+ * Cancellation after submission does not undo an accepted update. */
58
+ update(options?: t.RealtimeUpdateOptions): Promise<t.SessionInfo>;
59
+ sendText(value: string, options?: t.RealtimeOperationOptions): Promise<t.ResponseRef>;
60
+ requestReply(options?: t.ReplyOptions): Promise<t.ResponseRef>;
61
+ addMessage(role: "user" | "assistant", value: string, options?: t.RealtimeOperationOptions): Promise<t.ItemRef>;
62
+ submitToolResult(call: t.ToolCallRef, output: string, options?: t.RealtimeOperationOptions): Promise<void>;
63
+ continueReply(parent: t.ResponseRef, options?: t.RealtimeOperationOptions): Promise<t.ResponseRef>;
64
+ cancel(response: t.ResponseRef, options?: t.RealtimeOperationOptions): Promise<void>;
65
+ /** Replaces the labels later replies carry; a reply already started keeps
66
+ * its own. Resolves once Prism confirms the change. */
67
+ setResponseMetadata(metadata: t.Labels, options?: t.RealtimeOperationOptions): Promise<void>;
68
+ clearAudio(options?: t.RealtimeOperationOptions): Promise<void>;
69
+ sendAudio(chunk: t.AudioChunk, options?: t.RealtimeOperationOptions): Promise<void>;
70
+ reportPlayback(report: t.PlaybackReport, options?: t.RealtimeOperationOptions): Promise<void>;
71
+ private settle;
72
+ private reject;
73
+ private fail;
74
+ private dispatch;
75
+ private wireResponse;
76
+ private publish;
77
+ close(): Promise<void>;
78
+ [Symbol.asyncDispose](): Promise<void>;
79
+ }