@wildix/wilma-voice-client 0.0.51 → 0.0.53

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.
@@ -1,5 +1,5 @@
1
1
  import type { DocumentType as __DocumentType, StreamingBlobTypes } from "@smithy/types";
2
- import type { MediaAudioBeginFrameType, MediaAudioEncoding, MediaAudioEndFrameType, MediaDtmfFrameType, MediaDuckFrameType, MediaErrorFrameType, MediaFinishedFrameType, MediaFinishFrameType, MediaFinishReason, MediaHangupFrameType, MediaLanguageFrameType, MediaParty, MediaPlaybackEvent, MediaPlaybackFrameType, MediaPlaybackStopCause, MediaRestoreFrameType, MediaRunPurpose, MediaStartedFrameType, MediaStartFrameType, MediaStopFrameType, MediaTranscriptionFrameType, MediaTransferFrameType, MediaVadFrameType, VoiceAudioEncoding, VoiceCallEndReason, VoiceCallToolPhase, VoiceCommandType, VoiceControlAction, VoiceEventType, VoiceInputMode, VoicePronunciationEncoding, VoiceTranscriptionDropReason } from "./enums";
2
+ import type { VoiceCallClientEndReason, VoiceCallClientFrameType, VoiceCallEndReason, VoiceCallParty, VoiceCallPlaybackPhase, VoiceCallServerFrameType, VoiceCommandType, VoiceEventType, VoiceInputMode, VoicePronunciationEncoding, VoiceToolPhase, VoiceTranscriptionDropReason } from "./enums";
3
3
  /**
4
4
  * A pronunciation rule for one phrase. Belongs to a LANGUAGE, not to the agent: 'Wildix' is
5
5
  * respelled differently for an Italian and a German voice, so one list shared ACROSS languages
@@ -25,968 +25,656 @@ export interface VoicePronunciation {
25
25
  encoding?: VoicePronunciationEncoding | undefined;
26
26
  }
27
27
  /**
28
- * A recogniser result for the agent's own leg — what the caller hears. Sent by the PBX for new-stack agents only, from the same dual-channel stream that transcribes the caller. Never starts a turn.
28
+ * Caller voice detection on the PBX.
29
29
  * @public
30
30
  */
31
- export interface AgentTranscriptionEvent {
31
+ export interface VoiceDetectionSettings {
32
32
  /**
33
- * Discriminator for the inner payload of an `event` frame.
33
+ * Silence in ms that ends the caller speech. Absent: 500.
34
34
  * @public
35
35
  */
36
- type: VoiceEventType;
37
- /**
38
- * Identifier of a transcription chunk within a session.
39
- * @public
40
- */
41
- id: string;
42
- text: string;
36
+ silenceMs?: number | undefined;
43
37
  /**
44
- * Transcription confidence score (accuracy level) in range from 0.0 to 1.0. Value -1.0 indicates confidence is unavailable.
38
+ * Mean frame level in dBFS below which caller audio is silence. Absent: -36.
45
39
  * @public
46
40
  */
47
- confidence?: number | undefined;
41
+ silenceLevelDb?: number | undefined;
48
42
  /**
49
- * True when this is the final transcript for the utterance rather than an interim hypothesis. An absent value is read as final, as on `TranscriptionEvent`.
43
+ * Mean frame level in dBFS from which caller audio is speech. Absent: -30.
50
44
  * @public
51
45
  */
52
- final?: boolean | undefined;
53
- /**
54
- * Language the recogniser identified for this chunk. Recorded in the trace only — it drives no behavior.
55
- * @public
56
- */
57
- language?: string | undefined;
58
- time: number;
46
+ speechLevelDb?: number | undefined;
59
47
  }
60
48
  /**
61
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
49
+ * A transcription chunk of the agent speech, as the caller hears it. It does not start a turn.
62
50
  * @public
63
51
  */
64
- export interface AgentTranscriptionWebsocketEvent {
65
- type: string;
52
+ export interface VoiceAgentTranscriptionEvent {
66
53
  /**
67
- * A recogniser result for the agent's own leg — what the caller hears. Sent by the PBX for new-stack agents only, from the same dual-channel stream that transcribes the caller. Never starts a turn.
68
- * @public
69
- */
70
- event: AgentTranscriptionEvent;
71
- }
72
- /**
73
- * A chunk of raw caller audio, base64-encoded in the session's negotiated input format
74
- * (inputAudio from the connect handshake). Used by web/app clients in AUDIO input mode; the
75
- * service buffers and transcribes it server-side. Not used in TRANSCRIPTION mode.
76
- * @public
77
- */
78
- export interface AudioEvent {
79
- /**
80
- * Discriminator for the inner payload of an `event` frame.
54
+ * Value of `type` in the `event` of an event frame.
81
55
  * @public
82
56
  */
83
57
  type: VoiceEventType;
84
- data: string;
85
58
  /**
86
- * Optional monotonic chunk sequence number, for gap detection.
59
+ * Id of the utterance. Absent: the service makes a new id.
87
60
  * @public
88
61
  */
89
- seq?: number | undefined;
90
- }
91
- /**
92
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
93
- * @public
94
- */
95
- export interface AudioWebsocketEvent {
96
- type: string;
62
+ id?: string | undefined;
97
63
  /**
98
- * A chunk of raw caller audio, base64-encoded in the session's negotiated input format
99
- * (inputAudio from the connect handshake). Used by web/app clients in AUDIO input mode; the
100
- * service buffers and transcribes it server-side. Not used in TRANSCRIPTION mode.
64
+ * Text of the chunk. Must not be empty.
101
65
  * @public
102
66
  */
103
- event: AudioEvent;
104
- }
105
- /**
106
- * The call/conversation completed (e.g. the caller hung up or the call was transferred away).
107
- * @public
108
- */
109
- export interface CompleteEvent {
110
- /**
111
- * Discriminator for the inner payload of an `event` frame.
112
- * @public
113
- */
114
- type: VoiceEventType;
115
- reason: string;
116
- time: number;
117
- }
118
- /**
119
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
120
- * @public
121
- */
122
- export interface CompleteWebsocketEvent {
123
- type: string;
124
- /**
125
- * The call/conversation completed (e.g. the caller hung up or the call was transferred away).
126
- * @public
127
- */
128
- event: CompleteEvent;
129
- }
130
- /**
131
- * A lightweight control frame from the client (AUDIO mode).
132
- * @public
133
- */
134
- export interface ControlEvent {
135
- /**
136
- * Discriminator for the inner payload of an `event` frame.
137
- * @public
138
- */
139
- type: VoiceEventType;
140
- /**
141
- * A client control action on the audio input (AUDIO mode).
142
- * @public
143
- */
144
- action: VoiceControlAction;
145
- }
146
- /**
147
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
148
- * @public
149
- */
150
- export interface ControlWebsocketEvent {
151
- type: string;
67
+ text: string;
152
68
  /**
153
- * A lightweight control frame from the client (AUDIO mode).
69
+ * Confidence of the recogniser. The service does not record it.
154
70
  * @public
155
71
  */
156
- event: ControlEvent;
157
- }
158
- /**
159
- * @public
160
- */
161
- export interface DescribeVoiceProtocolInput {
162
- }
163
- /**
164
- * A recogniser result for the AGENT's own leg — what the caller actually heard. Same semantics as VoiceCallTranscriptionEvent; an interrupted reply simply stops.
165
- * @public
166
- */
167
- export interface VoiceCallAgentTranscriptionEvent {
72
+ confidence?: number | undefined;
168
73
  /**
169
- * Identifier of a transcription chunk within a session.
74
+ * True when the chunk is the final transcript of the utterance. False for an interim result. Absent: true.
170
75
  * @public
171
76
  */
172
- id: string;
173
- text: string;
174
- final: boolean;
77
+ final?: boolean | undefined;
175
78
  /**
176
- * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
177
- * constrained string rather than an enum: the offerable set is a property of the selected
178
- * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
179
- * when the model was released.
79
+ * Language that the recogniser identified for the chunk. The service records it and does not change the conversation language.
180
80
  * @public
181
81
  */
182
82
  language?: string | undefined;
183
- time?: number | undefined;
184
- }
185
- /**
186
- * The session ended. After `transfer` another session of the same call may follow with its own `started`.
187
- * @public
188
- */
189
- export interface VoiceCallEndedEvent {
190
- /**
191
- * Caller-facing voice session identifier, unique per connection. Supplied by the client at connect (the PBX call/session id, or a client-generated id for web sessions).
192
- * @public
193
- */
194
- sessionId: string;
195
- reason: VoiceCallEndReason;
196
- }
197
- /**
198
- * The caller talked over the agent. `playedText` is what they heard before the cut.
199
- * @public
200
- */
201
- export interface VoiceCallInterruptionEvent {
202
83
  /**
203
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
84
+ * Time of the chunk, in epoch ms. Absent: the time when the service received it.
204
85
  * @public
205
86
  */
206
- replyId?: string | undefined;
207
- playedText?: string | undefined;
208
- originalText?: string | undefined;
87
+ time?: number | undefined;
209
88
  }
210
89
  /**
211
- * The conversation language changed on a recognised utterance.
90
+ * The call or the conversation is complete, for example because the caller hung up. The service ends the session. The service also accepts `type` `ended` with the same meaning.
212
91
  * @public
213
92
  */
214
- export interface VoiceCallLanguageEvent {
93
+ export interface VoiceCompleteEvent {
215
94
  /**
216
- * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
217
- * constrained string rather than an enum: the offerable set is a property of the selected
218
- * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
219
- * when the model was released.
95
+ * Value of `type` in the `event` of an event frame.
220
96
  * @public
221
97
  */
222
- from?: string | undefined;
98
+ type: VoiceEventType;
223
99
  /**
224
- * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
225
- * constrained string rather than an enum: the offerable set is a property of the selected
226
- * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
227
- * when the model was released.
100
+ * Why the call is complete. Absent: the value of `type`.
228
101
  * @public
229
102
  */
230
- to: string;
231
- reason: string;
232
- }
233
- /**
234
- * The PBX finished (or abandoned) playing a reply.
235
- * @public
236
- */
237
- export interface VoiceCallPlaybackEvent {
103
+ reason?: string | undefined;
238
104
  /**
239
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
105
+ * Time of the completion, in epoch ms. The service ignores it.
240
106
  * @public
241
107
  */
242
- replyId: string;
243
- complete: boolean;
108
+ time?: number | undefined;
244
109
  }
245
110
  /**
246
- * The caller's completed utterance that started a turn — after the runtime's filler and duplicate filter.
111
+ * End the session and hang up the call.
247
112
  * @public
248
113
  */
249
- export interface VoiceCallReplyEvent {
114
+ export interface VoiceHangupCommand {
250
115
  /**
251
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
116
+ * Why the session ended.
252
117
  * @public
253
118
  */
254
- id: string;
255
- text: string;
119
+ reason?: string | undefined;
256
120
  /**
257
- * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
258
- * constrained string rather than an enum: the offerable set is a property of the selected
259
- * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
260
- * when the model was released.
121
+ * Value of `type` in the `command` of a command frame.
261
122
  * @public
262
123
  */
263
- language?: string | undefined;
124
+ type: VoiceCommandType;
264
125
  }
265
126
  /**
266
- * One sentence the agent speaks, as it is handed to the PBX (after playback sanitizing). Sentences of one reply share `replyId`.
127
+ * Liveness check of the service by the client: `\{"type": "healthcheck"\}`, with no envelope. The service sends no answer.
267
128
  * @public
268
129
  */
269
- export interface VoiceCallSayEvent {
270
- /**
271
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
272
- * @public
273
- */
274
- replyId: string;
275
- text: string;
276
- interruptible: boolean;
130
+ export interface VoiceHealthcheckCommand {
131
+ type: string;
277
132
  }
278
133
  /**
279
- * The session that answered the call, sent once per session of the call (a transfer starts another).
134
+ * The caller spoke over a reply while the client played it.
280
135
  * @public
281
136
  */
282
- export interface VoiceCallStartedEvent {
137
+ export interface VoiceInterruptionEvent {
283
138
  /**
284
- * Caller-facing voice session identifier, unique per connection. Supplied by the client at connect (the PBX call/session id, or a client-generated id for web sessions).
139
+ * Value of `type` in the `event` of an event frame.
285
140
  * @public
286
141
  */
287
- sessionId: string;
142
+ type: VoiceEventType;
288
143
  /**
289
- * The session's trace, for the LLM-level detail this stream deliberately omits. Absent for a built-in agent, whose trace is not the tenant's to read.
144
+ * Reply that the caller interrupted.
290
145
  * @public
291
146
  */
292
- traceId?: string | undefined;
293
- agentId: string;
294
- agentName?: string | undefined;
147
+ replyId?: string | undefined;
295
148
  /**
296
- * Published agent version number. Monotonic within an agent's version history, starting at 1.
149
+ * Part of the reply that the client played before the interruption.
297
150
  * @public
298
151
  */
299
- agentVersion?: number | undefined;
152
+ playedText?: string | undefined;
300
153
  /**
301
- * True when the session runs the agent's draft.
154
+ * Full text of the reply.
302
155
  * @public
303
156
  */
304
- agentDraft?: boolean | undefined;
157
+ originalText?: string | undefined;
305
158
  /**
306
- * BCP-47 language the call started in.
159
+ * Time of the interruption, in epoch ms on the client clock. The service ignores 0.
307
160
  * @public
308
161
  */
309
- language?: string | undefined;
162
+ time?: number | undefined;
310
163
  }
311
164
  /**
312
- * A tool call the agent made during a turn. Name and phase only — arguments and results live in the trace. Sent to a caller signed in to the system; never to a guest.
165
+ * Progress of the playback of a reply on the client.
313
166
  * @public
314
167
  */
315
- export interface VoiceCallToolEvent {
168
+ export interface VoicePlaybackEvent {
316
169
  /**
317
- * Identifies the tool call inside the turn — the model's own call id, not the PBX call this stream follows.
170
+ * Value of `type` in the `event` of an event frame.
318
171
  * @public
319
172
  */
320
- toolCallId: string;
321
- toolName: string;
322
- phase: VoiceCallToolPhase;
173
+ type: VoiceEventType;
323
174
  /**
324
- * The phrase spoken while the tool runs, when the capability configures one.
175
+ * Reply that the client plays.
325
176
  * @public
326
177
  */
327
- startMessage?: string | undefined;
328
- }
329
- /**
330
- * A recogniser result for the caller's speech. Interim results (`final: false`) are replaced by the final one with the same `id`.
331
- * @public
332
- */
333
- export interface VoiceCallTranscriptionEvent {
178
+ replyId?: string | undefined;
334
179
  /**
335
- * Identifier of a transcription chunk within a session.
180
+ * Text of the reply that the client played.
336
181
  * @public
337
182
  */
338
- id: string;
339
- text: string;
340
- final: boolean;
183
+ text?: string | undefined;
341
184
  /**
342
- * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
343
- * constrained string rather than an enum: the offerable set is a property of the selected
344
- * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
345
- * when the model was released.
185
+ * True when the client played the reply to its end.
346
186
  * @public
347
187
  */
348
- language?: string | undefined;
188
+ complete: boolean;
349
189
  /**
350
- * Milliseconds since the call started, as the PBX stamps it.
190
+ * Start of the playback, in epoch ms on the client clock. The service ignores 0.
351
191
  * @public
352
192
  */
353
- time?: number | undefined;
193
+ startTime?: number | undefined;
354
194
  /**
355
- * Present on a final that did not go to the agent as a caller turn. It came while the agent spoke, and its recognition confidence was below the minimum of the call or the recogniser labelled it with another speaker.
195
+ * End of the playback, in epoch ms on the client clock. The service ignores 0.
356
196
  * @public
357
197
  */
358
- dropped?: VoiceTranscriptionDropReason | undefined;
198
+ endTime?: number | undefined;
359
199
  }
360
200
  /**
361
- * One event on a live call. The SSE frame's `event:` is the member name and `data:` this whole union document, so a frame reads `data: \{"say": \{...\}\}` — never the member's payload on its own.
362
- * @public
363
- */
364
- export type VoiceCallEvent = VoiceCallEvent.AgentTranscriptionMember | VoiceCallEvent.EndedMember | VoiceCallEvent.InterruptionMember | VoiceCallEvent.LanguageMember | VoiceCallEvent.PlaybackMember | VoiceCallEvent.ReplyMember | VoiceCallEvent.SayMember | VoiceCallEvent.StartedMember | VoiceCallEvent.ToolMember | VoiceCallEvent.TranscriptionMember | VoiceCallEvent.$UnknownMember;
365
- /**
201
+ * A final caller utterance. It starts an agent turn.
366
202
  * @public
367
203
  */
368
- export declare namespace VoiceCallEvent {
369
- /**
370
- * The session that answered the call, sent once per session of the call (a transfer starts another).
371
- * @public
372
- */
373
- interface StartedMember {
374
- started: VoiceCallStartedEvent;
375
- transcription?: never;
376
- agentTranscription?: never;
377
- reply?: never;
378
- say?: never;
379
- playback?: never;
380
- interruption?: never;
381
- language?: never;
382
- tool?: never;
383
- ended?: never;
384
- $unknown?: never;
385
- }
204
+ export interface VoiceReplyEvent {
386
205
  /**
387
- * A recogniser result for the caller's speech. Interim results (`final: false`) are replaced by the final one with the same `id`.
206
+ * Value of `type` in the `event` of an event frame.
388
207
  * @public
389
208
  */
390
- interface TranscriptionMember {
391
- started?: never;
392
- transcription: VoiceCallTranscriptionEvent;
393
- agentTranscription?: never;
394
- reply?: never;
395
- say?: never;
396
- playback?: never;
397
- interruption?: never;
398
- language?: never;
399
- tool?: never;
400
- ended?: never;
401
- $unknown?: never;
402
- }
403
- /**
404
- * A recogniser result for the AGENT's own leg — what the caller actually heard. Same semantics as VoiceCallTranscriptionEvent; an interrupted reply simply stops.
405
- * @public
406
- */
407
- interface AgentTranscriptionMember {
408
- started?: never;
409
- transcription?: never;
410
- agentTranscription: VoiceCallAgentTranscriptionEvent;
411
- reply?: never;
412
- say?: never;
413
- playback?: never;
414
- interruption?: never;
415
- language?: never;
416
- tool?: never;
417
- ended?: never;
418
- $unknown?: never;
419
- }
420
- /**
421
- * The caller's completed utterance that started a turn — after the runtime's filler and duplicate filter.
422
- * @public
423
- */
424
- interface ReplyMember {
425
- started?: never;
426
- transcription?: never;
427
- agentTranscription?: never;
428
- reply: VoiceCallReplyEvent;
429
- say?: never;
430
- playback?: never;
431
- interruption?: never;
432
- language?: never;
433
- tool?: never;
434
- ended?: never;
435
- $unknown?: never;
436
- }
437
- /**
438
- * One sentence the agent speaks, as it is handed to the PBX (after playback sanitizing). Sentences of one reply share `replyId`.
439
- * @public
440
- */
441
- interface SayMember {
442
- started?: never;
443
- transcription?: never;
444
- agentTranscription?: never;
445
- reply?: never;
446
- say: VoiceCallSayEvent;
447
- playback?: never;
448
- interruption?: never;
449
- language?: never;
450
- tool?: never;
451
- ended?: never;
452
- $unknown?: never;
453
- }
454
- /**
455
- * The PBX finished (or abandoned) playing a reply.
456
- * @public
457
- */
458
- interface PlaybackMember {
459
- started?: never;
460
- transcription?: never;
461
- agentTranscription?: never;
462
- reply?: never;
463
- say?: never;
464
- playback: VoiceCallPlaybackEvent;
465
- interruption?: never;
466
- language?: never;
467
- tool?: never;
468
- ended?: never;
469
- $unknown?: never;
470
- }
471
- /**
472
- * The caller talked over the agent. `playedText` is what they heard before the cut.
473
- * @public
474
- */
475
- interface InterruptionMember {
476
- started?: never;
477
- transcription?: never;
478
- agentTranscription?: never;
479
- reply?: never;
480
- say?: never;
481
- playback?: never;
482
- interruption: VoiceCallInterruptionEvent;
483
- language?: never;
484
- tool?: never;
485
- ended?: never;
486
- $unknown?: never;
487
- }
209
+ type: VoiceEventType;
488
210
  /**
489
- * The conversation language changed on a recognised utterance.
211
+ * Id of the utterance. Absent: the service makes a new id.
490
212
  * @public
491
213
  */
492
- interface LanguageMember {
493
- started?: never;
494
- transcription?: never;
495
- agentTranscription?: never;
496
- reply?: never;
497
- say?: never;
498
- playback?: never;
499
- interruption?: never;
500
- language: VoiceCallLanguageEvent;
501
- tool?: never;
502
- ended?: never;
503
- $unknown?: never;
504
- }
214
+ id?: string | undefined;
505
215
  /**
506
- * A tool call the agent made during a turn. Name and phase only — arguments and results live in the trace. Sent to a caller signed in to the system; never to a guest.
216
+ * Text of the utterance. Must not be empty.
507
217
  * @public
508
218
  */
509
- interface ToolMember {
510
- started?: never;
511
- transcription?: never;
512
- agentTranscription?: never;
513
- reply?: never;
514
- say?: never;
515
- playback?: never;
516
- interruption?: never;
517
- language?: never;
518
- tool: VoiceCallToolEvent;
519
- ended?: never;
520
- $unknown?: never;
521
- }
219
+ text: string;
522
220
  /**
523
- * The session ended. After `transfer` another session of the same call may follow with its own `started`.
221
+ * Time of the utterance, in epoch ms. Absent: the time when the service received it.
524
222
  * @public
525
223
  */
526
- interface EndedMember {
527
- started?: never;
528
- transcription?: never;
529
- agentTranscription?: never;
530
- reply?: never;
531
- say?: never;
532
- playback?: never;
533
- interruption?: never;
534
- language?: never;
535
- tool?: never;
536
- ended: VoiceCallEndedEvent;
537
- $unknown?: never;
538
- }
224
+ time?: number | undefined;
539
225
  /**
226
+ * Language that the recogniser identified for the utterance. A value that is different from the conversation language changes the conversation language. When the utterance has segments in more than one language, send the language of the last segment.
540
227
  * @public
541
228
  */
542
- interface $UnknownMember {
543
- started?: never;
544
- transcription?: never;
545
- agentTranscription?: never;
546
- reply?: never;
547
- say?: never;
548
- playback?: never;
549
- interruption?: never;
550
- language?: never;
551
- tool?: never;
552
- ended?: never;
553
- $unknown: [string, any];
554
- }
555
- /**
556
- * @deprecated unused in schema-serde mode.
557
- *
558
- */
559
- interface Visitor<T> {
560
- started: (value: VoiceCallStartedEvent) => T;
561
- transcription: (value: VoiceCallTranscriptionEvent) => T;
562
- agentTranscription: (value: VoiceCallAgentTranscriptionEvent) => T;
563
- reply: (value: VoiceCallReplyEvent) => T;
564
- say: (value: VoiceCallSayEvent) => T;
565
- playback: (value: VoiceCallPlaybackEvent) => T;
566
- interruption: (value: VoiceCallInterruptionEvent) => T;
567
- language: (value: VoiceCallLanguageEvent) => T;
568
- tool: (value: VoiceCallToolEvent) => T;
569
- ended: (value: VoiceCallEndedEvent) => T;
570
- _: (name: string, value: any) => T;
571
- }
572
- }
573
- /**
574
- * A PCM/compressed audio format description.
575
- * @public
576
- */
577
- export interface VoiceAudioFormat {
229
+ language?: string | undefined;
578
230
  /**
579
- * Encoding of raw audio carried over the connection (client `audio` chunks and server `play` frames).
231
+ * Confidence of the recogniser for the utterance. The service ignores a value outside 0 to 1.
580
232
  * @public
581
233
  */
582
- encoding: VoiceAudioEncoding;
234
+ confidence?: number | undefined;
583
235
  /**
584
- * Samples per second, e.g. 8000, 16000 or 24000.
236
+ * Start of the speech, in epoch ms on the client clock. The service ignores 0.
585
237
  * @public
586
238
  */
587
- sampleRate: number;
239
+ startTime?: number | undefined;
588
240
  /**
589
- * Channel count. Defaults to 1 (mono).
241
+ * End of the speech, in epoch ms on the client clock. The service ignores 0.
590
242
  * @public
591
243
  */
592
- channels?: number | undefined;
244
+ endTime?: number | undefined;
593
245
  }
594
246
  /**
595
- * Parameters supplied on the WebSocket connect (upgrade) request, as query-string parameters.
247
+ * A transcription chunk of caller speech. A client that does its own speech-to-text sends it. When the service does the speech-to-text, the service sends it to the client.
596
248
  * @public
597
249
  */
598
- export interface VoiceConnectParams {
599
- /**
600
- * Protocol version advertised by the client (query parameter `v`). 0 (or absent) is the legacy PBX protocol; >= 1 enables the sessionStarted event; >= 2 additionally means the client WAITS for `started` before opening its recognition stream and honours the `speech` payload on it.
601
- * @public
602
- */
603
- protocolVersion?: number | undefined;
604
- /**
605
- * Caller-supplied session id, unique per connection.
606
- * @public
607
- */
608
- sessionId: string;
609
- /**
610
- * Attach the running session `sessionId` again after a close with code `1001` or a lost connection. The session keeps its history and does not play the greeting again.
611
- * @public
612
- */
613
- resume?: boolean | undefined;
614
- /**
615
- * The client connects again with `resume` after a close with code `1001`. Only then can the service move a PBX text-socket call to another server while the call runs; without it the socket stays open until the call ends or the server stops.
616
- * @public
617
- */
618
- reconnect?: boolean | undefined;
250
+ export interface VoiceTranscriptionEvent {
619
251
  /**
620
- * Agent to run on this session.
621
- * @public
622
- */
623
- agentId: string;
624
- /**
625
- * Published agent version to run. Mutually exclusive with agentDraft. When neither is set, the agent's deployment configuration selects the version. The PBX sends it only for a preview number (`<agentId>-vN`, WMS-27502); a customer call never carries it.
252
+ * Value of `type` in the `event` of an event frame.
626
253
  * @public
627
254
  */
628
- agentVersion?: number | undefined;
255
+ type: VoiceEventType;
629
256
  /**
630
- * Run the agent's current draft (for testing). Mutually exclusive with agentVersion.
257
+ * Id of the utterance. The interim chunks and the final chunk of one utterance have the same id. Absent: the service makes a new id.
631
258
  * @public
632
259
  */
633
- agentDraft?: boolean | undefined;
260
+ id?: string | undefined;
634
261
  /**
635
- * PBX call id, when the session is bridged to a call.
262
+ * Text of the chunk. Must not be empty.
636
263
  * @public
637
264
  */
638
- callId?: string | undefined;
265
+ text: string;
639
266
  /**
640
- * Leg of the PBX call inside `callId` (pbx-data-engine's flow index). Kept on the session as metadata beside `callId` and `dialedNumber`; never interpreted by the runtime.
267
+ * Confidence of the recogniser. The service ignores a value outside 0 to 1.
641
268
  * @public
642
269
  */
643
- flowIndex?: number | undefined;
270
+ confidence?: number | undefined;
644
271
  /**
645
- * The number the caller dialled to reach the agent. Kept on the session as metadata beside `callId` and `flowIndex`.
272
+ * True when the chunk is the final transcript of the utterance. False for an interim result. Absent: true.
646
273
  * @public
647
274
  */
648
- dialedNumber?: string | undefined;
275
+ final?: boolean | undefined;
649
276
  /**
650
- * BCP-47 language of the conversation, e.g. 'en-US'.
277
+ * Language that the recogniser identified for the chunk. The service records it and does not change the conversation language.
651
278
  * @public
652
279
  */
653
280
  language?: string | undefined;
654
- callerName?: string | undefined;
655
- callerNumber?: string | undefined;
656
- callerEmail?: string | undefined;
657
- callerCompany?: string | undefined;
658
- /**
659
- * Override the TTS voice for this session, as a voice URI, e.g. 'elevenlabs://<voiceId>?apiKey=...'. Defaults to the agent's configured voice.
660
- * @public
661
- */
662
- voice?: string | undefined;
663
281
  /**
664
- * First message spoken to the caller. Overrides the agent's configured greeting.
282
+ * Time of the chunk, in epoch ms. Absent: the time when the service received it.
665
283
  * @public
666
284
  */
667
- initialMessage?: string | undefined;
285
+ time?: number | undefined;
286
+ }
287
+ /**
288
+ * The session ended. This is the last event of the session.
289
+ * @public
290
+ */
291
+ export interface VoiceSessionEndedEvent {
668
292
  /**
669
- * Base64-encoded JSON object of agent variables for this session, e.g. base64('\{"orderId":"123"\}').
293
+ * Value of `type` in the `event` of an event frame.
670
294
  * @public
671
295
  */
672
- variables?: string | undefined;
296
+ type: VoiceEventType;
673
297
  /**
674
- * How caller speech reaches the service. Defaults to TRANSCRIPTION (PBX). Web/app clients use AUDIO.
298
+ * Why the session ended.
675
299
  * @public
676
300
  */
677
- inputMode?: VoiceInputMode | undefined;
301
+ reason?: string | undefined;
678
302
  /**
679
- * Format of client `audio` chunks in AUDIO mode.
303
+ * Present when the session ended because of an error.
680
304
  * @public
681
305
  */
682
- inputAudio?: VoiceAudioFormat | undefined;
306
+ error?: string | undefined;
683
307
  /**
684
- * Preferred format for server-synthesized `play` frames.
308
+ * Time of the event, in epoch ms.
685
309
  * @public
686
310
  */
687
- outputAudio?: VoiceAudioFormat | undefined;
311
+ time: number;
688
312
  }
689
313
  /**
690
- * An error surfaced on the connection. Non-terminal unless followed by a SessionEndedEvent.
314
+ * An error on the connection. The session continues, unless a `ended` event follows.
691
315
  * @public
692
316
  */
693
317
  export interface VoiceErrorEvent {
694
318
  /**
695
- * Discriminator for the inner payload of an `event` frame.
319
+ * Value of `type` in the `event` of an event frame.
696
320
  * @public
697
321
  */
698
322
  type: VoiceEventType;
699
323
  /**
700
- * Stable machine-readable error code.
324
+ * Error code. The value is stable.
701
325
  * @public
702
326
  */
703
327
  code: string;
328
+ /**
329
+ * Description of the error.
330
+ * @public
331
+ */
704
332
  message: string;
705
- time: number;
706
- }
707
- /**
708
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
709
- * @public
710
- */
711
- export interface ErrorWebsocketEvent {
712
- type: string;
713
333
  /**
714
- * An error surfaced on the connection. Non-terminal unless followed by a SessionEndedEvent.
334
+ * Time of the event, in epoch ms.
715
335
  * @public
716
336
  */
717
- event: VoiceErrorEvent;
337
+ time: number;
718
338
  }
719
339
  /**
720
- * Terminate the session and hang up the call.
340
+ * A chunk of synthesized audio of a reply. `data` is base64 of PCM audio at the sample rate of the `say` command. An empty `data` marks the end of the stream.
721
341
  * @public
722
342
  */
723
- export interface HangupCommandData {
724
- reason?: string | undefined;
343
+ export interface VoicePlayCommand {
344
+ replyId: string;
345
+ streamId: string;
346
+ data: string;
725
347
  /**
726
- * Discriminator for the inner payload of a `command` frame.
348
+ * Value of `type` in the `command` of a command frame.
727
349
  * @public
728
350
  */
729
351
  type: VoiceCommandType;
730
352
  }
731
353
  /**
732
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
354
+ * Audio of a reply that the service synthesizes. `play` commands with this stream id follow the `say` command.
733
355
  * @public
734
356
  */
735
- export interface HangupWebsocketCommand {
736
- type: string;
357
+ export interface VoiceSayCommandAudioOptions {
358
+ streamId: string;
737
359
  /**
738
- * Terminate the session and hang up the call.
360
+ * Sample rate of the `pcm_s16le` mono audio of the `play` commands, in Hz: 8000, 12000, 16000, 24000, 32000, 44100 or 48000.
739
361
  * @public
740
362
  */
741
- command: HangupCommandData;
363
+ sampleRate: number;
742
364
  }
743
365
  /**
744
- * The caller interrupted (barged in over) a reply that was being played.
366
+ * Play a reply to the caller. When `audio` is present, the service sends the audio of the reply in `play` commands. When `audio` is absent, the client shows `text` or synthesizes it itself.
745
367
  * @public
746
368
  */
747
- export interface InterruptionEvent {
369
+ export interface VoiceSayCommand {
748
370
  /**
749
- * Discriminator for the inner payload of an `event` frame.
371
+ * Text of the reply.
750
372
  * @public
751
373
  */
752
- type: VoiceEventType;
374
+ text: string;
753
375
  /**
754
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
376
+ * Id of the reply.
755
377
  * @public
756
378
  */
757
379
  replyId: string;
758
380
  /**
759
- * Portion of the reply that had been played before the interruption.
381
+ * True when the caller can interrupt the reply.
760
382
  * @public
761
383
  */
762
- playedText: string;
384
+ interruptible?: boolean | undefined;
763
385
  /**
764
- * The full reply text that was being played.
386
+ * Audio of a reply that the service synthesizes. `play` commands with this stream id follow the `say` command.
765
387
  * @public
766
388
  */
767
- originalText: string;
768
- time: number;
769
- }
770
- /**
771
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
772
- * @public
773
- */
774
- export interface InterruptionWebsocketEvent {
775
- type: string;
389
+ audio?: VoiceSayCommandAudioOptions | undefined;
776
390
  /**
777
- * The caller interrupted (barged in over) a reply that was being played.
391
+ * Value of `type` in the `command` of a command frame.
778
392
  * @public
779
393
  */
780
- event: InterruptionEvent;
394
+ type: VoiceCommandType;
781
395
  }
782
396
  /**
783
- * Opens an agent audio stream. `MediaCloudAudio` messages of the stream follow until `audio.end`. Streams do not interleave.
397
+ * Speech recognition settings of the call. The client applies them to its recogniser.
784
398
  * @public
785
399
  */
786
- export interface MediaAudioBeginFrame {
787
- type: MediaAudioBeginFrameType;
400
+ export interface VoiceSpeechPayload {
788
401
  /**
789
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
402
+ * Recogniser URI. Always present.
790
403
  * @public
791
404
  */
792
- replyId: string;
405
+ engine: string;
793
406
  /**
794
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
407
+ * All configured languages. These are the candidates for language identification.
795
408
  * @public
796
409
  */
797
- streamId: string;
410
+ languages: string[];
798
411
  /**
799
- * Sample rate of the stream's `pcm_s16le` mono audio in Hz: 8000, 16000, 22050 or 24000.
412
+ * Language at the start of the call. Always a member of `languages`.
800
413
  * @public
801
414
  */
802
- sampleRate: number;
803
- }
804
- /**
805
- * Closes an agent audio stream.
806
- * @public
807
- */
808
- export interface MediaAudioEndFrame {
809
- type: MediaAudioEndFrameType;
415
+ preferredLanguage: string;
810
416
  /**
811
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
417
+ * True to identify the spoken language of each utterance. False when `languages` has fewer languages than the recogniser needs, or when the recogniser cannot identify languages.
812
418
  * @public
813
419
  */
814
- streamId: string;
420
+ autoDetect: boolean;
815
421
  }
816
422
  /**
817
- * Lower the volume of a playing reply.
423
+ * The session is ready. Sent once after the handshake, on the PBX voice socket only when the client sends protocol version 1 or more.
818
424
  * @public
819
425
  */
820
- export interface MediaDuckFrame {
821
- type: MediaDuckFrameType;
426
+ export interface VoiceSessionStartedEvent {
822
427
  /**
823
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
428
+ * Value of `type` in the `event` of an event frame.
824
429
  * @public
825
430
  */
826
- replyId: string;
431
+ type: VoiceEventType;
827
432
  /**
828
- * Target gain in dB.
433
+ * Time of the event, in epoch ms.
829
434
  * @public
830
435
  */
831
- volumeDb: number;
436
+ time: number;
832
437
  /**
833
- * Ramp duration in ms.
438
+ * Id of the session.
834
439
  * @public
835
440
  */
836
- rampMs: number;
441
+ sessionId: string;
442
+ /**
443
+ * Agent of the session.
444
+ * @public
445
+ */
446
+ agentId: string;
447
+ /**
448
+ * Published agent version of the session. Absent when the session runs the agent draft.
449
+ * @public
450
+ */
451
+ agentVersion?: number | undefined;
452
+ /**
453
+ * Trace of the session. It does not change during the session.
454
+ * @public
455
+ */
456
+ traceId?: string | undefined;
457
+ /**
458
+ * Display name of the agent.
459
+ * @public
460
+ */
461
+ agentName?: string | undefined;
462
+ /**
463
+ * Category of the agent.
464
+ * @public
465
+ */
466
+ category?: string | undefined;
467
+ /**
468
+ * PBX group of the agent, for data access control. Empty when the agent has no group.
469
+ * @public
470
+ */
471
+ groupId?: string | undefined;
472
+ /**
473
+ * Speech recognition settings of the call. Present only at `protocolVersion` 2 or more and only when the agent has speech settings. Absent: use a single-language recogniser on the language of the channel.
474
+ * @public
475
+ */
476
+ speech?: VoiceSpeechPayload | undefined;
477
+ /**
478
+ * Music-on-hold class to play as background sound of the call. Absent: no background sound.
479
+ * @public
480
+ */
481
+ backgroundSound?: string | undefined;
837
482
  }
838
483
  /**
839
- * An error on the run. When `retryable` is false, the socket closes after it.
484
+ * Stop the audio of the agent.
840
485
  * @public
841
486
  */
842
- export interface MediaErrorFrame {
843
- type: MediaErrorFrameType;
487
+ export interface VoiceStopCommand {
844
488
  /**
845
- * Stable error code, for example `START_TIMEOUT`, `PROTOCOL_ERROR` or `STT_FAILED`.
489
+ * Value of `type` in the `command` of a command frame.
846
490
  * @public
847
491
  */
848
- code: string;
849
- retryable: boolean;
850
- message: string;
492
+ type: VoiceCommandType;
851
493
  }
852
494
  /**
853
- * Answer to `finish`: the cloud processed all audio. The socket closes with 1000 after it.
495
+ * Transfer the call to a PBX destination and end the session. Only a PBX client does the transfer.
854
496
  * @public
855
497
  */
856
- export interface MediaFinishedFrame {
857
- type: MediaFinishedFrameType;
498
+ export interface VoiceTransferCommand {
499
+ /**
500
+ * Dialplan context of the destination.
501
+ * @public
502
+ */
503
+ context: string;
504
+ /**
505
+ * Extension of the destination.
506
+ * @public
507
+ */
508
+ extension: string;
509
+ /**
510
+ * Value of `type` in the `command` of a command frame.
511
+ * @public
512
+ */
513
+ type: VoiceCommandType;
858
514
  }
859
515
  /**
860
- * Hang up the call after the queued agent audio plays. Terminal: the PBX answers with `finish`.
861
516
  * @public
862
517
  */
863
- export interface MediaHangupFrame {
864
- type: MediaHangupFrameType;
518
+ export interface DescribeVoiceProtocolInput {
865
519
  }
866
520
  /**
867
- * The call continues in another language.
521
+ * A recogniser result for the AGENT's own leg — what the caller actually heard. Same semantics as VoiceCallTranscriptionEvent; an interrupted reply simply stops.
868
522
  * @public
869
523
  */
870
- export interface MediaLanguageFrame {
871
- type: MediaLanguageFrameType;
524
+ export interface VoiceCallAgentTranscriptionEvent {
525
+ id: string;
526
+ text: string;
527
+ final: boolean;
872
528
  /**
873
- * Language that the call continues in.
529
+ * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
530
+ * constrained string rather than an enum: the offerable set is a property of the selected
531
+ * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
532
+ * when the model was released.
874
533
  * @public
875
534
  */
876
- language: string;
535
+ language?: string | undefined;
536
+ time?: number | undefined;
877
537
  }
878
538
  /**
879
- * Return a reply to full volume.
539
+ * The session ended. After `transfer` another session of the same call may follow with its own `started`.
880
540
  * @public
881
541
  */
882
- export interface MediaRestoreFrame {
883
- type: MediaRestoreFrameType;
884
- /**
885
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
886
- * @public
887
- */
888
- replyId: string;
542
+ export interface VoiceCallEndedEvent {
889
543
  /**
890
- * Ramp duration in ms.
544
+ * Id of the voice session.
891
545
  * @public
892
546
  */
893
- rampMs: number;
547
+ sessionId: string;
548
+ reason: VoiceCallEndReason;
894
549
  }
895
550
  /**
896
- * The agent that answers the run.
551
+ * The caller talked over the agent. `playedText` is what they heard before the cut.
897
552
  * @public
898
553
  */
899
- export interface MediaStartedAgent {
900
- name: string;
554
+ export interface VoiceCallInterruptionEvent {
555
+ replyId?: string | undefined;
556
+ playedText?: string | undefined;
557
+ originalText?: string | undefined;
901
558
  }
902
559
  /**
903
- * Caller voice detection of a run, with every value resolved.
560
+ * The conversation language changed on a recognised utterance.
904
561
  * @public
905
562
  */
906
- export interface MediaVoiceDetection {
563
+ export interface VoiceCallLanguageEvent {
907
564
  /**
908
- * Silence in ms that ends the caller speech.
565
+ * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
566
+ * constrained string rather than an enum: the offerable set is a property of the selected
567
+ * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
568
+ * when the model was released.
909
569
  * @public
910
570
  */
911
- silenceMs: number;
571
+ from?: string | undefined;
912
572
  /**
913
- * Mean frame level in dBFS below which caller audio is silence.
573
+ * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
574
+ * constrained string rather than an enum: the offerable set is a property of the selected
575
+ * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
576
+ * when the model was released.
914
577
  * @public
915
578
  */
916
- silenceLevelDb: number;
579
+ to: string;
580
+ reason: string;
581
+ }
582
+ /**
583
+ * The PBX finished (or abandoned) playing a reply.
584
+ * @public
585
+ */
586
+ export interface VoiceCallPlaybackEvent {
587
+ replyId: string;
588
+ complete: boolean;
589
+ }
590
+ /**
591
+ * The caller's completed utterance that started a turn — after the runtime's filler and duplicate filter.
592
+ * @public
593
+ */
594
+ export interface VoiceCallReplyEvent {
595
+ id: string;
596
+ text: string;
917
597
  /**
918
- * Mean frame level in dBFS from which caller audio is speech.
598
+ * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
599
+ * constrained string rather than an enum: the offerable set is a property of the selected
600
+ * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
601
+ * when the model was released.
919
602
  * @public
920
603
  */
921
- speechLevelDb: number;
604
+ language?: string | undefined;
605
+ }
606
+ /**
607
+ * One sentence the agent speaks, as it is handed to the PBX (after playback sanitizing). Sentences of one reply share `replyId`.
608
+ * @public
609
+ */
610
+ export interface VoiceCallSayEvent {
611
+ replyId: string;
612
+ text: string;
613
+ interruptible: boolean;
922
614
  }
923
615
  /**
924
- * The cloud accepted `start`. Sent once per connection.
616
+ * The session that answered the call, sent once per session of the call (a transfer starts another).
925
617
  * @public
926
618
  */
927
- export interface MediaStartedFrame {
928
- type: MediaStartedFrameType;
619
+ export interface VoiceCallStartedEvent {
929
620
  /**
930
- * Id of the cloud stream of this run. Cloud logs carry it; use it to match PBX and cloud logs.
621
+ * Id of the voice session.
931
622
  * @public
932
623
  */
933
- streamId: string;
624
+ sessionId: string;
934
625
  /**
935
- * Present when the run purpose is `agent`.
626
+ * The session's trace, for the LLM-level detail this stream deliberately omits. Absent for a built-in agent, whose trace is not the tenant's to read.
936
627
  * @public
937
628
  */
938
- agent?: MediaStartedAgent | undefined;
629
+ traceId?: string | undefined;
630
+ agentId: string;
631
+ agentName?: string | undefined;
939
632
  /**
940
- * Group of the agent. Absent when the agent has none.
633
+ * Published agent version number. Monotonic within an agent's version history, starting at 1.
941
634
  * @public
942
635
  */
943
- groupId?: string | undefined;
636
+ agentVersion?: number | undefined;
944
637
  /**
945
- * Music-on-hold class that the PBX plays after each caller turn until agent audio starts. Absent: none.
638
+ * True when the session runs the agent's draft.
946
639
  * @public
947
640
  */
948
- backgroundSound?: string | undefined;
641
+ agentDraft?: boolean | undefined;
949
642
  /**
950
- * Caller voice detection that the PBX uses for the `vad` frames of this run. Absent: the PBX keeps its defaults.
643
+ * BCP-47 language the call started in.
951
644
  * @public
952
645
  */
953
- voiceDetection?: MediaVoiceDetection | undefined;
954
- }
955
- /**
956
- * Stop every agent audio stream of the run: the one that plays and the ones that wait.
957
- * @public
958
- */
959
- export interface MediaStopFrame {
960
- type: MediaStopFrameType;
646
+ language?: string | undefined;
961
647
  }
962
648
  /**
963
- * Words of one party. Partials and the final of one utterance share `id`. For the agent, the words that played.
649
+ * A tool call the agent made during a turn. Name and phase only — arguments and results live in the trace. Sent to a caller signed in to the system; never to a guest.
964
650
  * @public
965
651
  */
966
- export interface MediaTranscriptionFrame {
967
- type: MediaTranscriptionFrameType;
968
- /**
969
- * Party that spoke. The agent's own words are `callee`.
970
- * @public
971
- */
972
- party: MediaParty;
652
+ export interface VoiceCallToolEvent {
973
653
  /**
974
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
654
+ * Identifies the tool call inside the turn — the model's own call id, not the PBX call this stream follows.
975
655
  * @public
976
656
  */
977
- id: string;
978
- final: boolean;
979
- text: string;
657
+ toolCallId: string;
658
+ toolName: string;
980
659
  /**
981
- * Run-clock time or duration in ms of PBX audio since the run started. It continues across reconnects.
660
+ * Phase of a tool call of the agent.
982
661
  * @public
983
662
  */
984
- startMs: number;
663
+ phase: VoiceToolPhase;
985
664
  /**
986
- * Run-clock time or duration in ms of PBX audio since the run started. It continues across reconnects.
665
+ * The phrase spoken while the tool runs, when the capability configures one.
987
666
  * @public
988
667
  */
989
- endMs: number;
668
+ startMessage?: string | undefined;
669
+ }
670
+ /**
671
+ * A recogniser result for the caller's speech. Interim results (`final: false`) are replaced by the final one with the same `id`.
672
+ * @public
673
+ */
674
+ export interface VoiceCallTranscriptionEvent {
675
+ id: string;
676
+ text: string;
677
+ final: boolean;
990
678
  /**
991
679
  * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
992
680
  * constrained string rather than an enum: the offerable set is a property of the selected
@@ -994,147 +682,277 @@ export interface MediaTranscriptionFrame {
994
682
  * when the model was released.
995
683
  * @public
996
684
  */
997
- language: string;
998
- /**
999
- * Recogniser confidence from 0 to 1. Absent when the text is not from a recogniser, or the engine gives none.
1000
- * @public
1001
- */
1002
- confidence?: number | undefined;
1003
- }
1004
- /**
1005
- * Transfer the call after the queued agent audio plays. Terminal: the PBX answers with `finish`.
1006
- * @public
1007
- */
1008
- export interface MediaTransferFrame {
1009
- type: MediaTransferFrameType;
685
+ language?: string | undefined;
1010
686
  /**
1011
- * Dialplan context of the target.
687
+ * Milliseconds since the call started, as the PBX stamps it.
1012
688
  * @public
1013
689
  */
1014
- context: string;
690
+ time?: number | undefined;
1015
691
  /**
1016
- * Extension of the target.
692
+ * Present on a final that did not go to the agent as a caller turn. It came while the agent spoke, and its recognition confidence was below the minimum of the call or the recogniser labelled it with another speaker.
1017
693
  * @public
1018
694
  */
1019
- extension: string;
695
+ finalDropReason?: VoiceTranscriptionDropReason | undefined;
1020
696
  }
1021
697
  /**
1022
- * One example of each message that the cloud sends.
698
+ * One event on a live call. The SSE frame's `event:` is the member name and `data:` this whole union document, so a frame reads `data: \{"say": \{...\}\}` — never the member's payload on its own.
699
+ * @public
700
+ */
701
+ export type VoiceCallEvent = VoiceCallEvent.AgentTranscriptionMember | VoiceCallEvent.EndedMember | VoiceCallEvent.InterruptionMember | VoiceCallEvent.LanguageMember | VoiceCallEvent.PlaybackMember | VoiceCallEvent.ReplyMember | VoiceCallEvent.SayMember | VoiceCallEvent.StartedMember | VoiceCallEvent.ToolMember | VoiceCallEvent.TranscriptionMember | VoiceCallEvent.$UnknownMember;
702
+ /**
1023
703
  * @public
1024
704
  */
1025
- export interface MediaCloudFrames {
1026
- /**
1027
- * The cloud accepted `start`. Sent once per connection.
1028
- * @public
1029
- */
1030
- started?: MediaStartedFrame | undefined;
705
+ export declare namespace VoiceCallEvent {
1031
706
  /**
1032
- * Words of one party. Partials and the final of one utterance share `id`. For the agent, the words that played.
707
+ * The session that answered the call, sent once per session of the call (a transfer starts another).
1033
708
  * @public
1034
709
  */
1035
- transcription?: MediaTranscriptionFrame | undefined;
710
+ interface StartedMember {
711
+ started: VoiceCallStartedEvent;
712
+ transcription?: never;
713
+ agentTranscription?: never;
714
+ reply?: never;
715
+ say?: never;
716
+ playback?: never;
717
+ interruption?: never;
718
+ language?: never;
719
+ tool?: never;
720
+ ended?: never;
721
+ $unknown?: never;
722
+ }
1036
723
  /**
1037
- * Opens an agent audio stream. `MediaCloudAudio` messages of the stream follow until `audio.end`. Streams do not interleave.
724
+ * A recogniser result for the caller's speech. Interim results (`final: false`) are replaced by the final one with the same `id`.
1038
725
  * @public
1039
726
  */
1040
- audioBegin?: MediaAudioBeginFrame | undefined;
727
+ interface TranscriptionMember {
728
+ started?: never;
729
+ transcription: VoiceCallTranscriptionEvent;
730
+ agentTranscription?: never;
731
+ reply?: never;
732
+ say?: never;
733
+ playback?: never;
734
+ interruption?: never;
735
+ language?: never;
736
+ tool?: never;
737
+ ended?: never;
738
+ $unknown?: never;
739
+ }
1041
740
  /**
1042
- * One binary audio message. In the describe answer it is base64; on the socket it is raw bytes.
741
+ * A recogniser result for the AGENT's own leg — what the caller actually heard. Same semantics as VoiceCallTranscriptionEvent; an interrupted reply simply stops.
1043
742
  * @public
1044
743
  */
1045
- audio?: Uint8Array | undefined;
744
+ interface AgentTranscriptionMember {
745
+ started?: never;
746
+ transcription?: never;
747
+ agentTranscription: VoiceCallAgentTranscriptionEvent;
748
+ reply?: never;
749
+ say?: never;
750
+ playback?: never;
751
+ interruption?: never;
752
+ language?: never;
753
+ tool?: never;
754
+ ended?: never;
755
+ $unknown?: never;
756
+ }
1046
757
  /**
1047
- * Closes an agent audio stream.
758
+ * The caller's completed utterance that started a turn — after the runtime's filler and duplicate filter.
1048
759
  * @public
1049
760
  */
1050
- audioEnd?: MediaAudioEndFrame | undefined;
761
+ interface ReplyMember {
762
+ started?: never;
763
+ transcription?: never;
764
+ agentTranscription?: never;
765
+ reply: VoiceCallReplyEvent;
766
+ say?: never;
767
+ playback?: never;
768
+ interruption?: never;
769
+ language?: never;
770
+ tool?: never;
771
+ ended?: never;
772
+ $unknown?: never;
773
+ }
1051
774
  /**
1052
- * Stop every agent audio stream of the run: the one that plays and the ones that wait.
775
+ * One sentence the agent speaks, as it is handed to the PBX (after playback sanitizing). Sentences of one reply share `replyId`.
1053
776
  * @public
1054
777
  */
1055
- stop?: MediaStopFrame | undefined;
778
+ interface SayMember {
779
+ started?: never;
780
+ transcription?: never;
781
+ agentTranscription?: never;
782
+ reply?: never;
783
+ say: VoiceCallSayEvent;
784
+ playback?: never;
785
+ interruption?: never;
786
+ language?: never;
787
+ tool?: never;
788
+ ended?: never;
789
+ $unknown?: never;
790
+ }
1056
791
  /**
1057
- * Lower the volume of a playing reply.
792
+ * The PBX finished (or abandoned) playing a reply.
1058
793
  * @public
1059
794
  */
1060
- duck?: MediaDuckFrame | undefined;
795
+ interface PlaybackMember {
796
+ started?: never;
797
+ transcription?: never;
798
+ agentTranscription?: never;
799
+ reply?: never;
800
+ say?: never;
801
+ playback: VoiceCallPlaybackEvent;
802
+ interruption?: never;
803
+ language?: never;
804
+ tool?: never;
805
+ ended?: never;
806
+ $unknown?: never;
807
+ }
1061
808
  /**
1062
- * Return a reply to full volume.
809
+ * The caller talked over the agent. `playedText` is what they heard before the cut.
1063
810
  * @public
1064
811
  */
1065
- restore?: MediaRestoreFrame | undefined;
812
+ interface InterruptionMember {
813
+ started?: never;
814
+ transcription?: never;
815
+ agentTranscription?: never;
816
+ reply?: never;
817
+ say?: never;
818
+ playback?: never;
819
+ interruption: VoiceCallInterruptionEvent;
820
+ language?: never;
821
+ tool?: never;
822
+ ended?: never;
823
+ $unknown?: never;
824
+ }
1066
825
  /**
1067
- * The call continues in another language.
826
+ * The conversation language changed on a recognised utterance.
1068
827
  * @public
1069
828
  */
1070
- language?: MediaLanguageFrame | undefined;
829
+ interface LanguageMember {
830
+ started?: never;
831
+ transcription?: never;
832
+ agentTranscription?: never;
833
+ reply?: never;
834
+ say?: never;
835
+ playback?: never;
836
+ interruption?: never;
837
+ language: VoiceCallLanguageEvent;
838
+ tool?: never;
839
+ ended?: never;
840
+ $unknown?: never;
841
+ }
1071
842
  /**
1072
- * Transfer the call after the queued agent audio plays. Terminal: the PBX answers with `finish`.
843
+ * A tool call the agent made during a turn. Name and phase only — arguments and results live in the trace. Sent to a caller signed in to the system; never to a guest.
1073
844
  * @public
1074
845
  */
1075
- transfer?: MediaTransferFrame | undefined;
846
+ interface ToolMember {
847
+ started?: never;
848
+ transcription?: never;
849
+ agentTranscription?: never;
850
+ reply?: never;
851
+ say?: never;
852
+ playback?: never;
853
+ interruption?: never;
854
+ language?: never;
855
+ tool: VoiceCallToolEvent;
856
+ ended?: never;
857
+ $unknown?: never;
858
+ }
1076
859
  /**
1077
- * Hang up the call after the queued agent audio plays. Terminal: the PBX answers with `finish`.
860
+ * The session ended. After `transfer` another session of the same call may follow with its own `started`.
1078
861
  * @public
1079
862
  */
1080
- hangup?: MediaHangupFrame | undefined;
863
+ interface EndedMember {
864
+ started?: never;
865
+ transcription?: never;
866
+ agentTranscription?: never;
867
+ reply?: never;
868
+ say?: never;
869
+ playback?: never;
870
+ interruption?: never;
871
+ language?: never;
872
+ tool?: never;
873
+ ended: VoiceCallEndedEvent;
874
+ $unknown?: never;
875
+ }
1081
876
  /**
1082
- * An error on the run. When `retryable` is false, the socket closes after it.
1083
877
  * @public
1084
878
  */
1085
- error?: MediaErrorFrame | undefined;
879
+ interface $UnknownMember {
880
+ started?: never;
881
+ transcription?: never;
882
+ agentTranscription?: never;
883
+ reply?: never;
884
+ say?: never;
885
+ playback?: never;
886
+ interruption?: never;
887
+ language?: never;
888
+ tool?: never;
889
+ ended?: never;
890
+ $unknown: [string, any];
891
+ }
1086
892
  /**
1087
- * Answer to `finish`: the cloud processed all audio. The socket closes with 1000 after it.
1088
- * @public
893
+ * @deprecated unused in schema-serde mode.
894
+ *
1089
895
  */
1090
- finished?: MediaFinishedFrame | undefined;
896
+ interface Visitor<T> {
897
+ started: (value: VoiceCallStartedEvent) => T;
898
+ transcription: (value: VoiceCallTranscriptionEvent) => T;
899
+ agentTranscription: (value: VoiceCallAgentTranscriptionEvent) => T;
900
+ reply: (value: VoiceCallReplyEvent) => T;
901
+ say: (value: VoiceCallSayEvent) => T;
902
+ playback: (value: VoiceCallPlaybackEvent) => T;
903
+ interruption: (value: VoiceCallInterruptionEvent) => T;
904
+ language: (value: VoiceCallLanguageEvent) => T;
905
+ tool: (value: VoiceCallToolEvent) => T;
906
+ ended: (value: VoiceCallEndedEvent) => T;
907
+ _: (name: string, value: any) => T;
908
+ }
1091
909
  }
1092
910
  /**
1093
911
  * DTMF input that the PBX collected. The cloud takes `digits` as the caller's reply.
1094
912
  * @public
1095
913
  */
1096
- export interface MediaDtmfFrame {
1097
- type: MediaDtmfFrameType;
914
+ export interface VoiceCallDtmfFrame {
1098
915
  /**
1099
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
916
+ * Value of `type` in a text frame from the client (the PBX).
1100
917
  * @public
1101
918
  */
919
+ type: VoiceCallClientFrameType;
1102
920
  id: string;
1103
921
  digits: string;
1104
922
  }
1105
923
  /**
1106
- * The run ended on the PBX. The PBX sends no audio after it and waits up to 3 s for `finished`.
924
+ * The run ended on the PBX. The PBX sends no audio after it and waits up to 3 s for `ended`.
1107
925
  * @public
1108
926
  */
1109
- export interface MediaFinishFrame {
1110
- type: MediaFinishFrameType;
927
+ export interface VoiceCallEndFrame {
928
+ /**
929
+ * Value of `type` in a text frame from the client (the PBX).
930
+ * @public
931
+ */
932
+ type: VoiceCallClientFrameType;
1111
933
  /**
1112
- * Who ended the run on the PBX.
934
+ * Who ended the run on the PBX. The live events of the call report it as `VoiceCallEndReason`: `caller-hangup` as `hangup`, `agent-hangup` as `complete`, `agent-transfer` as `transfer`, `timeout` as `timeout`.
1113
935
  * @public
1114
936
  */
1115
- reason: MediaFinishReason;
937
+ reason: VoiceCallClientEndReason;
1116
938
  }
1117
939
  /**
1118
940
  * An agent audio stream changed state on the PBX.
1119
941
  * @public
1120
942
  */
1121
- export interface MediaPlaybackFrame {
1122
- type: MediaPlaybackFrameType;
943
+ export interface VoiceCallPlaybackFrame {
1123
944
  /**
1124
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
945
+ * Value of `type` in a text frame from the client (the PBX).
1125
946
  * @public
1126
947
  */
948
+ type: VoiceCallClientFrameType;
1127
949
  replyId: string;
1128
- /**
1129
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
1130
- * @public
1131
- */
1132
950
  streamId: string;
1133
951
  /**
1134
952
  * Event of an agent audio stream.
1135
953
  * @public
1136
954
  */
1137
- event: MediaPlaybackEvent;
955
+ event: VoiceCallPlaybackPhase;
1138
956
  /**
1139
957
  * Run-clock time or duration in ms of PBX audio since the run started. It continues across reconnects.
1140
958
  * @public
@@ -1146,16 +964,16 @@ export interface MediaPlaybackFrame {
1146
964
  */
1147
965
  playedMs?: number | undefined;
1148
966
  /**
1149
- * Present with `stopped`.
967
+ * True when the PBX dropped the stream, for example at its queue limit. Only with `stopped`. Absent: false.
1150
968
  * @public
1151
969
  */
1152
- cause?: MediaPlaybackStopCause | undefined;
970
+ dropped?: boolean | undefined;
1153
971
  }
1154
972
  /**
1155
- * The agent of a media run. At most one of `draft` and `version` is set.
973
+ * The agent of the run. At most one of `draft` and `version` is set.
1156
974
  * @public
1157
975
  */
1158
- export interface MediaStartAgent {
976
+ export interface VoiceCallStartAgent {
1159
977
  /**
1160
978
  * Agent id.
1161
979
  * @public
@@ -1173,31 +991,10 @@ export interface MediaStartAgent {
1173
991
  version?: number | undefined;
1174
992
  }
1175
993
  /**
1176
- * Format of the binary PBX audio (`MediaPbxAudio`). Channel 0 is the caller; channel 1, when present, is the callee. Samples interleave. The cloud accepts only 8000 Hz and one channel at this time; another format closes the socket with 4400.
1177
- * @public
1178
- */
1179
- export interface MediaAudioFormat {
1180
- /**
1181
- * Sample encoding of PBX audio.
1182
- * @public
1183
- */
1184
- encoding: MediaAudioEncoding;
1185
- /**
1186
- * Sample rate in Hz.
1187
- * @public
1188
- */
1189
- sampleRate: number;
1190
- /**
1191
- * Number of channels.
1192
- * @public
1193
- */
1194
- channels: number;
1195
- }
1196
- /**
1197
- * Caller identity. Each member is absent, null or empty when unknown.
994
+ * Caller identity from the lookup application of the PBX: an external lookup or the local phonebook. Each member is absent, null or empty when unknown.
1198
995
  * @public
1199
996
  */
1200
- export interface MediaStartCaller {
997
+ export interface VoiceCallStartCaller {
1201
998
  name?: string | undefined;
1202
999
  number?: string | undefined;
1203
1000
  email?: string | undefined;
@@ -1207,13 +1004,12 @@ export interface MediaStartCaller {
1207
1004
  * First text frame of a socket, sent within 10 s of the upgrade. Opens a run, or attaches a reconnect to it.
1208
1005
  * @public
1209
1006
  */
1210
- export interface MediaStartFrame {
1211
- type: MediaStartFrameType;
1007
+ export interface VoiceCallStartFrame {
1212
1008
  /**
1213
- * Purpose of a media run.
1009
+ * Value of `type` in a text frame from the client (the PBX).
1214
1010
  * @public
1215
1011
  */
1216
- purpose: MediaRunPurpose;
1012
+ type: VoiceCallClientFrameType;
1217
1013
  /**
1218
1014
  * Id of the PBX call. Use it to correlate the call events of the run.
1219
1015
  * @public
@@ -1240,35 +1036,20 @@ export interface MediaStartFrame {
1240
1036
  */
1241
1037
  resumeAtMs: number;
1242
1038
  /**
1243
- * Format of the binary PBX audio (`MediaPbxAudio`). Channel 0 is the caller; channel 1, when present, is the callee. Samples interleave. The cloud accepts only 8000 Hz and one channel at this time; another format closes the socket with 4400.
1244
- * @public
1245
- */
1246
- audio: MediaAudioFormat;
1247
- /**
1248
- * Present when `purpose` is `agent`.
1249
- * @public
1250
- */
1251
- agent?: MediaStartAgent | undefined;
1252
- /**
1253
- * Languages to recognise when `purpose` is `transcription`. May be empty only when `autoDetect` is true. Ignored when `purpose` is `agent`: the agent settings give the languages.
1039
+ * The agent of the run. At most one of `draft` and `version` is set.
1254
1040
  * @public
1255
1041
  */
1256
- languages?: string[] | undefined;
1042
+ agent: VoiceCallStartAgent;
1257
1043
  /**
1258
- * Language of the call. Required when `purpose` is `agent`: the agent starts in its configured language that matches it. With `transcription`, absent or null means the first of `languages`.
1044
+ * Language of the call, for example `en-US`. The agent starts in its configured language that matches it.
1259
1045
  * @public
1260
1046
  */
1261
- preferredLanguage?: string | undefined;
1262
- /**
1263
- * True to identify the caller's language among `languages` when `purpose` is `transcription`. Absent: false. Ignored when `purpose` is `agent`.
1264
- * @public
1265
- */
1266
- autoDetect?: boolean | undefined;
1047
+ language: string;
1267
1048
  /**
1268
- * Caller identity. Each member is absent, null or empty when unknown.
1049
+ * Caller identity from the lookup application of the PBX: an external lookup or the local phonebook. Each member is absent, null or empty when unknown.
1269
1050
  * @public
1270
1051
  */
1271
- caller: MediaStartCaller;
1052
+ caller: VoiceCallStartCaller;
1272
1053
  /**
1273
1054
  * Number that the caller dialled. Absent, null or empty when unknown.
1274
1055
  * @public
@@ -1281,18 +1062,17 @@ export interface MediaStartFrame {
1281
1062
  variables?: string | undefined;
1282
1063
  }
1283
1064
  /**
1284
- * Voice activity of a party as the PBX detects it. Sent when the state changes, and every 100 ms while agent audio plays.
1065
+ * Voice activity of the caller as the PBX detects it. Sent when the state changes, and every 100 ms while agent audio plays.
1285
1066
  * @public
1286
1067
  */
1287
- export interface MediaVadFrame {
1288
- type: MediaVadFrameType;
1068
+ export interface VoiceCallVadFrame {
1289
1069
  /**
1290
- * Party whose audio the report describes.
1070
+ * Value of `type` in a text frame from the client (the PBX).
1291
1071
  * @public
1292
1072
  */
1293
- party: MediaParty;
1073
+ type: VoiceCallClientFrameType;
1294
1074
  /**
1295
- * True while the party speaks.
1075
+ * True while the caller speaks.
1296
1076
  * @public
1297
1077
  */
1298
1078
  speaking: boolean;
@@ -1308,571 +1088,564 @@ export interface MediaVadFrame {
1308
1088
  atMs: number;
1309
1089
  }
1310
1090
  /**
1311
- * One example of each message that the PBX sends.
1091
+ * One example of each text message that the client (the PBX) sends on the call socket.
1312
1092
  * @public
1313
1093
  */
1314
- export interface MediaPbxFrames {
1094
+ export interface VoiceCallClientFrames {
1315
1095
  /**
1316
1096
  * First text frame of a socket, sent within 10 s of the upgrade. Opens a run, or attaches a reconnect to it.
1317
1097
  * @public
1318
1098
  */
1319
- start?: MediaStartFrame | undefined;
1099
+ start?: VoiceCallStartFrame | undefined;
1320
1100
  /**
1321
- * One binary audio message. In the describe answer it is base64; on the socket it is raw bytes.
1101
+ * Voice activity of the caller as the PBX detects it. Sent when the state changes, and every 100 ms while agent audio plays.
1322
1102
  * @public
1323
1103
  */
1324
- audio?: Uint8Array | undefined;
1104
+ vad?: VoiceCallVadFrame | undefined;
1325
1105
  /**
1326
- * Voice activity of a party as the PBX detects it. Sent when the state changes, and every 100 ms while agent audio plays.
1106
+ * DTMF input that the PBX collected. The cloud takes `digits` as the caller's reply.
1327
1107
  * @public
1328
1108
  */
1329
- vad?: MediaVadFrame | undefined;
1109
+ dtmf?: VoiceCallDtmfFrame | undefined;
1330
1110
  /**
1331
- * DTMF input that the PBX collected. The cloud takes `digits` as the caller's reply.
1111
+ * An agent audio stream changed state on the PBX.
1332
1112
  * @public
1333
1113
  */
1334
- dtmf?: MediaDtmfFrame | undefined;
1114
+ playback?: VoiceCallPlaybackFrame | undefined;
1335
1115
  /**
1336
- * An agent audio stream changed state on the PBX.
1116
+ * The run ended on the PBX. The PBX sends no audio after it and waits up to 3 s for `ended`.
1117
+ * @public
1118
+ */
1119
+ end?: VoiceCallEndFrame | undefined;
1120
+ }
1121
+ /**
1122
+ * Opens an agent audio stream. Binary audio messages of the stream follow until `audio.end`. Streams do not interleave.
1123
+ * @public
1124
+ */
1125
+ export interface VoiceCallAudioBeginFrame {
1126
+ /**
1127
+ * Value of `type` in a text frame from the server (the cloud).
1128
+ * @public
1129
+ */
1130
+ type: VoiceCallServerFrameType;
1131
+ replyId: string;
1132
+ streamId: string;
1133
+ /**
1134
+ * Sample rate of the stream's `pcm_s16le` mono audio in Hz: 8000, 12000, 16000, 24000, 32000, 44100 or 48000.
1337
1135
  * @public
1338
1136
  */
1339
- playback?: MediaPlaybackFrame | undefined;
1137
+ sampleRate: number;
1138
+ }
1139
+ /**
1140
+ * Closes an agent audio stream.
1141
+ * @public
1142
+ */
1143
+ export interface VoiceCallAudioEndFrame {
1144
+ /**
1145
+ * Value of `type` in a text frame from the server (the cloud).
1146
+ * @public
1147
+ */
1148
+ type: VoiceCallServerFrameType;
1149
+ streamId: string;
1150
+ }
1151
+ /**
1152
+ * Change the volume of a playing reply. `volumeDb` 0 returns it to full volume.
1153
+ * @public
1154
+ */
1155
+ export interface VoiceCallDuckFrame {
1156
+ /**
1157
+ * Value of `type` in a text frame from the server (the cloud).
1158
+ * @public
1159
+ */
1160
+ type: VoiceCallServerFrameType;
1161
+ replyId: string;
1162
+ /**
1163
+ * Target gain in dB.
1164
+ * @public
1165
+ */
1166
+ volumeDb: number;
1167
+ /**
1168
+ * Ramp duration in ms.
1169
+ * @public
1170
+ */
1171
+ rampMs: number;
1172
+ }
1173
+ /**
1174
+ * Answer to `end`: the cloud processed all audio. The socket closes with close code 1000 after it.
1175
+ * @public
1176
+ */
1177
+ export interface VoiceCallEndedFrame {
1340
1178
  /**
1341
- * The run ended on the PBX. The PBX sends no audio after it and waits up to 3 s for `finished`.
1179
+ * Value of `type` in a text frame from the server (the cloud).
1342
1180
  * @public
1343
1181
  */
1344
- finish?: MediaFinishFrame | undefined;
1182
+ type: VoiceCallServerFrameType;
1345
1183
  }
1346
1184
  /**
1347
- * One example of each message of the PBX media socket.
1185
+ * An error on the run. When `retryable` is false, the socket closes after it.
1348
1186
  * @public
1349
1187
  */
1350
- export interface MediaProtocolFrames {
1188
+ export interface VoiceCallErrorFrame {
1351
1189
  /**
1352
- * Messages that the PBX sends.
1190
+ * Value of `type` in a text frame from the server (the cloud).
1353
1191
  * @public
1354
1192
  */
1355
- pbx?: MediaPbxFrames | undefined;
1193
+ type: VoiceCallServerFrameType;
1356
1194
  /**
1357
- * Messages that the cloud sends.
1195
+ * Stable error code, for example `START_TIMEOUT`, `PROTOCOL_ERROR` or `STT_FAILED`.
1358
1196
  * @public
1359
1197
  */
1360
- cloud?: MediaCloudFrames | undefined;
1198
+ code: string;
1199
+ retryable: boolean;
1200
+ message: string;
1361
1201
  }
1362
1202
  /**
1363
- * Client-reported progress of an in-flight reply playback.
1203
+ * Hang up the call after the queued agent audio plays. Terminal: the PBX answers with `end`.
1364
1204
  * @public
1365
1205
  */
1366
- export interface PlaybackEvent {
1367
- /**
1368
- * Discriminator for the inner payload of an `event` frame.
1369
- * @public
1370
- */
1371
- type: VoiceEventType;
1206
+ export interface VoiceCallHangupFrame {
1372
1207
  /**
1373
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
1208
+ * Value of `type` in a text frame from the server (the cloud).
1374
1209
  * @public
1375
1210
  */
1376
- replyId: string;
1377
- text: string;
1378
- complete: boolean;
1379
- startTime: number;
1380
- endTime?: number | undefined;
1211
+ type: VoiceCallServerFrameType;
1381
1212
  }
1382
1213
  /**
1383
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1214
+ * The call continues in another language.
1384
1215
  * @public
1385
1216
  */
1386
- export interface PlaybackWebsocketEvent {
1387
- type: string;
1217
+ export interface VoiceCallLanguageFrame {
1218
+ /**
1219
+ * Value of `type` in a text frame from the server (the cloud).
1220
+ * @public
1221
+ */
1222
+ type: VoiceCallServerFrameType;
1388
1223
  /**
1389
- * Client-reported progress of an in-flight reply playback.
1224
+ * Language that the call continues in.
1390
1225
  * @public
1391
1226
  */
1392
- event: PlaybackEvent;
1227
+ language: string;
1393
1228
  }
1394
1229
  /**
1395
- * A chunk of synthesized reply audio to play. `data` is base64, PCM-encoded at the sample rate declared in the matching `say` command; an empty `data` marks the end of the stream.
1230
+ * The agent that answers the run.
1396
1231
  * @public
1397
1232
  */
1398
- export interface PlayCommandData {
1233
+ export interface VoiceCallStartedAgent {
1399
1234
  /**
1400
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
1235
+ * Agent id, as in `start.agent.id`.
1401
1236
  * @public
1402
1237
  */
1403
- replyId: string;
1238
+ id: string;
1404
1239
  /**
1405
- * Identifies one synthesized audio stream within a session; carried by a `say` command and the `play` frames that render it.
1240
+ * Display name of the agent.
1406
1241
  * @public
1407
1242
  */
1408
- streamId: string;
1409
- data: string;
1243
+ name: string;
1410
1244
  /**
1411
- * Discriminator for the inner payload of a `command` frame.
1245
+ * Group of the agent. Absent when the agent has none.
1412
1246
  * @public
1413
1247
  */
1414
- type: VoiceCommandType;
1248
+ groupId?: string | undefined;
1415
1249
  }
1416
1250
  /**
1417
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1251
+ * Answer to `start`: the session of the run is ready on this connection. Sent once per connection, also after a reconnect. Example: `\{"type":"started","connectionId":"0f6d…","agent":\{"id":"a_qqyHI7xWBH","name":"Support"\}\}`.
1418
1252
  * @public
1419
1253
  */
1420
- export interface PlayWebsocketCommand {
1421
- type: string;
1254
+ export interface VoiceCallStartedFrame {
1422
1255
  /**
1423
- * A chunk of synthesized reply audio to play. `data` is base64, PCM-encoded at the sample rate declared in the matching `say` command; an empty `data` marks the end of the stream.
1256
+ * Value of `type` in a text frame from the server (the cloud).
1424
1257
  * @public
1425
1258
  */
1426
- command: PlayCommandData;
1427
- }
1428
- /**
1429
- * A final caller phrase that should trigger an agent turn (PBX / TRANSCRIPTION mode).
1430
- * @public
1431
- */
1432
- export interface ReplyEvent {
1259
+ type: VoiceCallServerFrameType;
1433
1260
  /**
1434
- * Discriminator for the inner payload of an `event` frame.
1261
+ * Id of this connection. Each connection of the run has its own.
1435
1262
  * @public
1436
1263
  */
1437
- type: VoiceEventType;
1264
+ connectionId: string;
1438
1265
  /**
1439
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
1266
+ * The agent that answers the run.
1440
1267
  * @public
1441
1268
  */
1442
- id: string;
1443
- text: string;
1269
+ agent: VoiceCallStartedAgent;
1444
1270
  /**
1445
- * Language the recogniser identified for this completed utterance. THIS is the one that drives the language switch. When the recogniser reports several languages inside one utterance, the PBX sends the LAST labelled segment's language — it is the one the caller is speaking now.
1271
+ * Music-on-hold class that the PBX plays after each caller turn until agent audio starts. Absent: none.
1446
1272
  * @public
1447
1273
  */
1448
- language?: string | undefined;
1449
- startTime: number;
1450
- endTime: number;
1451
- }
1452
- /**
1453
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1454
- * @public
1455
- */
1456
- export interface ReplyWebsocketEvent {
1457
- type: string;
1274
+ backgroundSound?: string | undefined;
1458
1275
  /**
1459
- * A final caller phrase that should trigger an agent turn (PBX / TRANSCRIPTION mode).
1276
+ * Caller voice detection that the PBX uses for the `vad` frames of this run. The cloud sends every member. Absent: the PBX keeps its defaults.
1460
1277
  * @public
1461
1278
  */
1462
- event: ReplyEvent;
1279
+ voiceDetection?: VoiceDetectionSettings | undefined;
1463
1280
  }
1464
1281
  /**
1465
- * Audio-stream parameters when the server synthesizes the reply itself (TTS provider configured on the agent): the `say` is followed by a stream of `play` frames on this stream id.
1282
+ * Stop every agent audio stream of the run: the one that plays and the ones that wait.
1466
1283
  * @public
1467
1284
  */
1468
- export interface SayCommandAudioOptions {
1285
+ export interface VoiceCallStopFrame {
1469
1286
  /**
1470
- * Identifies one synthesized audio stream within a session; carried by a `say` command and the `play` frames that render it.
1287
+ * Value of `type` in a text frame from the server (the cloud).
1471
1288
  * @public
1472
1289
  */
1473
- streamId: string;
1474
- sampleRate: number;
1290
+ type: VoiceCallServerFrameType;
1475
1291
  }
1476
1292
  /**
1477
- * Play a reply to the caller. When `audio` is absent the client performs text-to-speech from `text`; when present the server streams synthesized `play` frames for this reply.
1293
+ * Words of one party. Partials and the final of one utterance share `id`. For the agent, the words that played.
1478
1294
  * @public
1479
1295
  */
1480
- export interface SayCommandData {
1481
- text: string;
1296
+ export interface VoiceCallTranscriptionFrame {
1482
1297
  /**
1483
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
1298
+ * Value of `type` in a text frame from the server (the cloud).
1484
1299
  * @public
1485
1300
  */
1486
- replyId: string;
1301
+ type: VoiceCallServerFrameType;
1487
1302
  /**
1488
- * Whether the caller may barge in over this reply.
1303
+ * Party that spoke. The agent's own words are `callee`.
1489
1304
  * @public
1490
1305
  */
1491
- interruptible?: boolean | undefined;
1306
+ party: VoiceCallParty;
1307
+ id: string;
1308
+ final: boolean;
1309
+ text: string;
1492
1310
  /**
1493
- * Bare Amazon Polly voice id, e.g. 'Joanna' — NOT a URI. The PBX consumes this verbatim as the
1494
- * AMI `Voice=` action parameter, so it takes exactly what Polly names the voice, with the
1495
- * `amazon_polly://` scheme and any query parameters already stripped by whoever builds this
1496
- * command out of the agent's stored `VoiceUri`.
1497
- *
1498
- * Set only for a provider whose synthesis runs ON THE PBX (Amazon Polly); ElevenLabs and Google
1499
- * are synthesized in the cloud and streamed as PCM through `play` instead, and leave this
1500
- * absent.
1311
+ * Run-clock time or duration in ms of PBX audio since the run started. It continues across reconnects.
1501
1312
  * @public
1502
1313
  */
1503
- voice?: string | undefined;
1314
+ startMs: number;
1504
1315
  /**
1505
- * Audio-stream parameters when the server synthesizes the reply itself (TTS provider configured on the agent): the `say` is followed by a stream of `play` frames on this stream id.
1316
+ * Run-clock time or duration in ms of PBX audio since the run started. It continues across reconnects.
1506
1317
  * @public
1507
1318
  */
1508
- audio?: SayCommandAudioOptions | undefined;
1319
+ endMs: number;
1509
1320
  /**
1510
- * Discriminator for the inner payload of a `command` frame.
1321
+ * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
1322
+ * constrained string rather than an enum: the offerable set is a property of the selected
1323
+ * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
1324
+ * when the model was released.
1511
1325
  * @public
1512
1326
  */
1513
- type: VoiceCommandType;
1514
- }
1515
- /**
1516
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1517
- * @public
1518
- */
1519
- export interface SayWebsocketCommand {
1520
- type: string;
1327
+ language: string;
1521
1328
  /**
1522
- * Play a reply to the caller. When `audio` is absent the client performs text-to-speech from `text`; when present the server streams synthesized `play` frames for this reply.
1329
+ * Recogniser confidence from 0 to 1. Absent when the text is not from a recogniser, or the engine gives none.
1523
1330
  * @public
1524
1331
  */
1525
- command: SayCommandData;
1332
+ confidence?: number | undefined;
1526
1333
  }
1527
1334
  /**
1528
- * Terminal server event: the session ended, optionally with an error.
1335
+ * Transfer the call after the queued agent audio plays. Terminal: the PBX answers with `end`.
1529
1336
  * @public
1530
1337
  */
1531
- export interface SessionEndedEvent {
1338
+ export interface VoiceCallTransferFrame {
1532
1339
  /**
1533
- * Discriminator for the inner payload of an `event` frame.
1340
+ * Dialplan context of the destination.
1534
1341
  * @public
1535
1342
  */
1536
- type: VoiceEventType;
1537
- reason?: string | undefined;
1343
+ context: string;
1538
1344
  /**
1539
- * Present when the session ended because of an error.
1345
+ * Extension of the destination.
1540
1346
  * @public
1541
1347
  */
1542
- error?: string | undefined;
1543
- time: number;
1544
- }
1545
- /**
1546
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1547
- * @public
1548
- */
1549
- export interface SessionEndedWebsocketEvent {
1550
- type: string;
1348
+ extension: string;
1551
1349
  /**
1552
- * Terminal server event: the session ended, optionally with an error.
1350
+ * Value of `type` in a text frame from the server (the cloud).
1553
1351
  * @public
1554
1352
  */
1555
- event: SessionEndedEvent;
1353
+ type: VoiceCallServerFrameType;
1556
1354
  }
1557
1355
  /**
1558
- * Recognition intent for the call, sent on `started` at protocolVersion >= 2. NOT recogniser
1559
- * parameters: the PBX translates it into its provider's API. Against Amazon Transcribe with
1560
- * autoDetect true that is identify-multiple-languages plus language-options and
1561
- * preferred-language; with autoDetect false, a single-language stream on preferredLanguage.
1562
- *
1563
- * Both members the server can get wrong are RESOLVED here rather than forwarded: `engine` is
1564
- * always concrete (an absent one would let the PBX apply a different default than the console
1565
- * built its language list for), and `autoDetect` is clamped to false whenever the language count
1566
- * is below the recogniser's minimum or the recogniser cannot identify languages at all
1567
- * (forwarding true with one candidate makes Amazon reject the stream outright — a dead call).
1356
+ * One example of each text message that the server (the cloud) sends on the call socket.
1568
1357
  * @public
1569
1358
  */
1570
- export interface VoiceSpeechPayload {
1359
+ export interface VoiceCallServerFrames {
1571
1360
  /**
1572
- * Concrete recogniser URI, resolved from the agent or from the platform default; never absent. See TranscriptionUri.
1361
+ * Answer to `start`: the session of the run is ready on this connection. Sent once per connection, also after a reconnect. Example: `\{"type":"started","connectionId":"0f6d…","agent":\{"id":"a_qqyHI7xWBH","name":"Support"\}\}`.
1573
1362
  * @public
1574
1363
  */
1575
- engine: string;
1364
+ started?: VoiceCallStartedFrame | undefined;
1576
1365
  /**
1577
- * Every configured language, as candidates for identification.
1366
+ * Words of one party. Partials and the final of one utterance share `id`. For the agent, the words that played.
1578
1367
  * @public
1579
1368
  */
1580
- languages: string[];
1369
+ transcription?: VoiceCallTranscriptionFrame | undefined;
1581
1370
  /**
1582
- * The language the call starts in, resolved from the channel. Always a member of `languages`.
1371
+ * Opens an agent audio stream. Binary audio messages of the stream follow until `audio.end`. Streams do not interleave.
1583
1372
  * @public
1584
1373
  */
1585
- preferredLanguage: string;
1374
+ audioBegin?: VoiceCallAudioBeginFrame | undefined;
1586
1375
  /**
1587
- * Whether to identify the spoken language per utterance. Already clamped by the server — see the shape's documentation.
1376
+ * Closes an agent audio stream.
1588
1377
  * @public
1589
1378
  */
1590
- autoDetect: boolean;
1591
- }
1592
- /**
1593
- * Emitted once right after the handshake to confirm the session and the agent it is bound to. Sent only when the client advertises protocol version >= 1.
1594
- * @public
1595
- */
1596
- export interface SessionStartedEvent {
1379
+ audioEnd?: VoiceCallAudioEndFrame | undefined;
1597
1380
  /**
1598
- * Discriminator for the inner payload of an `event` frame.
1381
+ * Stop every agent audio stream of the run: the one that plays and the ones that wait.
1599
1382
  * @public
1600
1383
  */
1601
- type: VoiceEventType;
1602
- time: number;
1384
+ stop?: VoiceCallStopFrame | undefined;
1603
1385
  /**
1604
- * Caller-facing voice session identifier, unique per connection. Supplied by the client at connect (the PBX call/session id, or a client-generated id for web sessions).
1386
+ * Change the volume of a playing reply. `volumeDb` 0 returns it to full volume.
1605
1387
  * @public
1606
1388
  */
1607
- sessionId: string;
1389
+ duck?: VoiceCallDuckFrame | undefined;
1608
1390
  /**
1609
- * Agent bound to the session.
1391
+ * The call continues in another language.
1610
1392
  * @public
1611
1393
  */
1612
- agentId: string;
1394
+ language?: VoiceCallLanguageFrame | undefined;
1613
1395
  /**
1614
- * Published agent version resolved at connect; absent when running the agent draft.
1396
+ * Transfer the call after the queued agent audio plays. Terminal: the PBX answers with `end`.
1615
1397
  * @public
1616
1398
  */
1617
- agentVersion?: number | undefined;
1399
+ transfer?: VoiceCallTransferFrame | undefined;
1618
1400
  /**
1619
- * Trace recording this voice session in wilma-traces — the caller's transcribed phrases, the
1620
- * model calls they drove and the tools the agent ran. Read it with the wilma-traces GetTrace
1621
- * operation, or tail it live with StreamTrace to follow a call while it is in progress.
1622
- *
1623
- * Sent once at handshake and stable for the connection: a call is one trace. A caller who
1624
- * redials gets a new session and therefore a new trace, since the trace is keyed on the session
1625
- * id supplied at connect.
1401
+ * Hang up the call after the queued agent audio plays. Terminal: the PBX answers with `end`.
1626
1402
  * @public
1627
1403
  */
1628
- traceId?: string | undefined;
1404
+ hangup?: VoiceCallHangupFrame | undefined;
1629
1405
  /**
1630
- * Agent display name.
1406
+ * An error on the run. When `retryable` is false, the socket closes after it.
1631
1407
  * @public
1632
1408
  */
1633
- agentName?: string | undefined;
1409
+ error?: VoiceCallErrorFrame | undefined;
1634
1410
  /**
1635
- * Agent category.
1411
+ * Answer to `end`: the cloud processed all audio. The socket closes with close code 1000 after it.
1636
1412
  * @public
1637
1413
  */
1638
- category?: string | undefined;
1414
+ ended?: VoiceCallEndedFrame | undefined;
1415
+ }
1416
+ /**
1417
+ * The text messages of the call socket `/v2/voice/calls/ws`. The socket has no connect parameters: the first text frame is `start`.
1418
+ * @public
1419
+ */
1420
+ export interface VoiceCallProtocolFrames {
1639
1421
  /**
1640
- * PBX group used for data ACL; empty when the agent is not assigned to a group.
1422
+ * One example of each text message that the client (the PBX) sends on the call socket.
1641
1423
  * @public
1642
1424
  */
1643
- groupId?: string | undefined;
1425
+ client?: VoiceCallClientFrames | undefined;
1644
1426
  /**
1645
- * Recognition intent for the call. Sent only at protocolVersion >= 2 and only when the agent has `speech` configured. A v2 client that receives `started` WITHOUT this member falls back to exactly its pre-v2 behavior: a single-language stream on the channel's own `language`.
1427
+ * One example of each text message that the server (the cloud) sends on the call socket.
1646
1428
  * @public
1647
1429
  */
1648
- speech?: VoiceSpeechPayload | undefined;
1430
+ server?: VoiceCallServerFrames | undefined;
1431
+ }
1432
+ /**
1433
+ * One example of each message that the client sends on the text socket. An event goes in `\{"type": "event", "event": \{...\}\}`; `healthcheck` has no envelope.
1434
+ * @public
1435
+ */
1436
+ export interface VoiceTextClientFrames {
1649
1437
  /**
1650
- * Music-on-hold class the PBX should play under the call as ambient background.
1651
- *
1652
- * A BARE NAME, not the configuration object `VoiceBackgroundSoundSettings`: this is the RESOLVED
1653
- * outcome. The server has already applied `enabled` and the class default, so the PBX gets a name
1654
- * to play or nothing at all and needs no resolution rule of its own.
1655
- *
1656
- * TOP LEVEL, NOT INSIDE `speech`, because it is not recognition intent and must not inherit
1657
- * `speech`'s conditions: a call with no configured languages carries no `speech` payload and can
1658
- * still have background audio.
1659
- *
1660
- * ABSENT MEANS OFF, and absence is the only way to say it — there is no value for 'none'. A bot
1661
- * whose administrator never touched the setting sends nothing here, which is exactly what every
1662
- * call sent before it existed, so the PBX needs no new case.
1438
+ * Liveness check of the service by the client: `\{"type": "healthcheck"\}`, with no envelope. The service sends no answer.
1663
1439
  * @public
1664
1440
  */
1665
- backgroundSound?: string | undefined;
1441
+ healthcheck?: VoiceHealthcheckCommand | undefined;
1666
1442
  /**
1667
- * Negotiated format of caller `audio` chunks the client should send (AUDIO mode).
1443
+ * A transcription chunk of caller speech. A client that does its own speech-to-text sends it. When the service does the speech-to-text, the service sends it to the client.
1668
1444
  * @public
1669
1445
  */
1670
- inputAudio?: VoiceAudioFormat | undefined;
1446
+ transcription?: VoiceTranscriptionEvent | undefined;
1671
1447
  /**
1672
- * Format of the synthesized `play` frames the server will send when it performs TTS.
1448
+ * A transcription chunk of the agent speech, as the caller hears it. It does not start a turn.
1673
1449
  * @public
1674
1450
  */
1675
- outputAudio?: VoiceAudioFormat | undefined;
1676
- }
1677
- /**
1678
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1679
- * @public
1680
- */
1681
- export interface SessionStartedWebsocketEvent {
1682
- type: string;
1451
+ agentTranscription?: VoiceAgentTranscriptionEvent | undefined;
1683
1452
  /**
1684
- * Emitted once right after the handshake to confirm the session and the agent it is bound to. Sent only when the client advertises protocol version >= 1.
1453
+ * A final caller utterance. It starts an agent turn.
1685
1454
  * @public
1686
1455
  */
1687
- event: SessionStartedEvent;
1688
- }
1689
- /**
1690
- * @public
1691
- */
1692
- export interface StopCommandData {
1456
+ reply?: VoiceReplyEvent | undefined;
1693
1457
  /**
1694
- * Discriminator for the inner payload of a `command` frame.
1458
+ * Progress of the playback of a reply on the client.
1695
1459
  * @public
1696
1460
  */
1697
- type: VoiceCommandType;
1698
- }
1699
- /**
1700
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1701
- * @public
1702
- */
1703
- export interface StopWebsocketCommand {
1704
- type: string;
1705
- command: StopCommandData;
1461
+ playback?: VoicePlaybackEvent | undefined;
1462
+ /**
1463
+ * The caller spoke over a reply while the client played it.
1464
+ * @public
1465
+ */
1466
+ interruption?: VoiceInterruptionEvent | undefined;
1467
+ /**
1468
+ * The call or the conversation is complete, for example because the caller hung up. The service ends the session. The service also accepts `type` `ended` with the same meaning.
1469
+ * @public
1470
+ */
1471
+ complete?: VoiceCompleteEvent | undefined;
1706
1472
  }
1707
1473
  /**
1708
- * A transcription chunk of caller speech, provided by a client that does its own speech-to-text (PBX / TRANSCRIPTION mode), or emitted by the service (AUDIO mode) and echoed to the client.
1474
+ * Parameters supplied on the WebSocket connect (upgrade) request, as query-string parameters.
1709
1475
  * @public
1710
1476
  */
1711
- export interface TranscriptionEvent {
1477
+ export interface VoiceConnectParams {
1712
1478
  /**
1713
- * Discriminator for the inner payload of an `event` frame.
1479
+ * Protocol version advertised by the client (query parameter `v`). 0 (or absent) is the legacy PBX protocol; >= 1 enables the sessionStarted event; >= 2 additionally means the client WAITS for `started` before opening its recognition stream and honours the `speech` payload on it; >= 3 additionally means the client connects again with `resume` after close code `1001`, so the service can move the call to another server while it runs.
1714
1480
  * @public
1715
1481
  */
1716
- type: VoiceEventType;
1482
+ protocolVersion?: number | undefined;
1717
1483
  /**
1718
- * Identifier of a transcription chunk within a session.
1484
+ * Caller-supplied session id, unique per connection.
1719
1485
  * @public
1720
1486
  */
1721
- id: string;
1722
- text: string;
1487
+ sessionId: string;
1723
1488
  /**
1724
- * Transcription confidence score (accuracy level) in range from 0.0 to 1.0. Value -1.0 indicates confidence is unavailable.
1489
+ * True when this connection attaches the running session `sessionId` again, after a close with close code `1001` or a lost connection. The session keeps its history and does not play the greeting again.
1725
1490
  * @public
1726
1491
  */
1727
- confidence?: number | undefined;
1492
+ resume?: boolean | undefined;
1728
1493
  /**
1729
- * True when this is the final transcript for the utterance rather than an interim hypothesis. An absent value is read as final: a client that does not distinguish interim results sends none.
1494
+ * Agent to run on this session.
1730
1495
  * @public
1731
1496
  */
1732
- final?: boolean | undefined;
1497
+ agentId: string;
1733
1498
  /**
1734
- * Language the recogniser identified for this chunk. Recorded in the trace only — it drives no behavior, so an operator can see what the recogniser thought during an utterance that never became a turn.
1499
+ * Published agent version to run. Mutually exclusive with agentDraft. When neither is set, the agent's deployment configuration selects the version. The PBX sends it only for a preview number (`<agentId>-vN`, WMS-27502); a customer call never carries it.
1735
1500
  * @public
1736
1501
  */
1737
- language?: string | undefined;
1738
- time: number;
1739
- }
1740
- /**
1741
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1742
- * @public
1743
- */
1744
- export interface TranscriptionWebsocketEvent {
1745
- type: string;
1502
+ agentVersion?: number | undefined;
1746
1503
  /**
1747
- * A transcription chunk of caller speech, provided by a client that does its own speech-to-text (PBX / TRANSCRIPTION mode), or emitted by the service (AUDIO mode) and echoed to the client.
1504
+ * Run the agent's current draft (for testing). Mutually exclusive with agentVersion.
1748
1505
  * @public
1749
1506
  */
1750
- event: TranscriptionEvent;
1751
- }
1752
- /**
1753
- * Transfer the call to a PBX destination and terminate the session. Honoured on PBX clients.
1754
- * @public
1755
- */
1756
- export interface TransferCommandData {
1757
- context: string;
1758
- extension: string;
1507
+ agentDraft?: boolean | undefined;
1759
1508
  /**
1760
- * Discriminator for the inner payload of a `command` frame.
1509
+ * PBX call id, when the session is bridged to a call.
1761
1510
  * @public
1762
1511
  */
1763
- type: VoiceCommandType;
1764
- }
1765
- /**
1766
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1767
- * @public
1768
- */
1769
- export interface TransferWebsocketCommand {
1770
- type: string;
1512
+ callId?: string | undefined;
1771
1513
  /**
1772
- * Transfer the call to a PBX destination and terminate the session. Honoured on PBX clients.
1514
+ * Leg of the PBX call inside `callId` (pbx-data-engine's flow index). Kept on the session as metadata beside `callId` and `dialedNumber`; never interpreted by the runtime.
1773
1515
  * @public
1774
1516
  */
1775
- command: TransferCommandData;
1776
- }
1777
- /**
1778
- * @public
1779
- */
1780
- export interface DescribeVoiceProtocolOutput {
1517
+ flowIndex?: number | undefined;
1518
+ /**
1519
+ * The number the caller dialled to reach the agent. Kept on the session as metadata beside `callId` and `flowIndex`.
1520
+ * @public
1521
+ */
1522
+ dialedNumber?: string | undefined;
1781
1523
  /**
1782
- * Parameters supplied on the WebSocket connect (upgrade) request, as query-string parameters.
1524
+ * BCP-47 language of the conversation, e.g. 'en-US'.
1783
1525
  * @public
1784
1526
  */
1785
- connectParams?: VoiceConnectParams | undefined;
1527
+ language?: string | undefined;
1528
+ callerName?: string | undefined;
1529
+ callerNumber?: string | undefined;
1530
+ callerEmail?: string | undefined;
1531
+ callerCompany?: string | undefined;
1786
1532
  /**
1787
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1533
+ * Override the TTS voice for this session, as a voice URI, e.g. 'elevenlabs://<voiceId>?apiKey=...'. Defaults to the agent's configured voice.
1788
1534
  * @public
1789
1535
  */
1790
- audioWebsocketEvent?: AudioWebsocketEvent | undefined;
1536
+ voice?: string | undefined;
1791
1537
  /**
1792
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1538
+ * First message spoken to the caller. Overrides the agent's configured greeting.
1793
1539
  * @public
1794
1540
  */
1795
- transcriptionWebsocketEvent?: TranscriptionWebsocketEvent | undefined;
1541
+ initialMessage?: string | undefined;
1796
1542
  /**
1797
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1543
+ * Base64-encoded JSON object of agent variables for this session, e.g. base64('\{"orderId":"123"\}').
1798
1544
  * @public
1799
1545
  */
1800
- agentTranscriptionWebsocketEvent?: AgentTranscriptionWebsocketEvent | undefined;
1546
+ variables?: string | undefined;
1801
1547
  /**
1802
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1548
+ * How caller speech reaches the service. Absent: `transcription`. The service refuses another value with HTTP 400.
1803
1549
  * @public
1804
1550
  */
1805
- replyWebsocketEvent?: ReplyWebsocketEvent | undefined;
1551
+ inputMode?: VoiceInputMode | undefined;
1806
1552
  /**
1807
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1553
+ * Owner user of the session. Absent: no user. The service ignores it for a PBX token with `callId`.
1808
1554
  * @public
1809
1555
  */
1810
- playbackWebsocketEvent?: PlaybackWebsocketEvent | undefined;
1556
+ user?: string | undefined;
1811
1557
  /**
1812
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1558
+ * Tenant of the session. Required for a service token, which carries no tenant. For another token a value different from the token tenant gets HTTP 401.
1813
1559
  * @public
1814
1560
  */
1815
- interruptionWebsocketEvent?: InterruptionWebsocketEvent | undefined;
1561
+ company?: string | undefined;
1562
+ }
1563
+ /**
1564
+ * One example of each message that the server sends on the text socket. An event goes in `\{"type": "event", "event": \{...\}\}`, a command in `\{"type": "command", "command": \{...\}\}`.
1565
+ * @public
1566
+ */
1567
+ export interface VoiceTextServerFrames {
1816
1568
  /**
1817
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1569
+ * The session is ready. Sent once after the handshake, on the PBX voice socket only when the client sends protocol version 1 or more.
1818
1570
  * @public
1819
1571
  */
1820
- completeWebsocketEvent?: CompleteWebsocketEvent | undefined;
1572
+ started?: VoiceSessionStartedEvent | undefined;
1821
1573
  /**
1822
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1574
+ * The session ended. This is the last event of the session.
1823
1575
  * @public
1824
1576
  */
1825
- controlWebsocketEvent?: ControlWebsocketEvent | undefined;
1577
+ ended?: VoiceSessionEndedEvent | undefined;
1826
1578
  /**
1827
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1579
+ * An error on the connection. The session continues, unless a `ended` event follows.
1828
1580
  * @public
1829
1581
  */
1830
- sessionStartedWebsocketEvent?: SessionStartedWebsocketEvent | undefined;
1582
+ error?: VoiceErrorEvent | undefined;
1831
1583
  /**
1832
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1584
+ * Play a reply to the caller. When `audio` is present, the service sends the audio of the reply in `play` commands. When `audio` is absent, the client shows `text` or synthesizes it itself.
1833
1585
  * @public
1834
1586
  */
1835
- sessionEndedWebsocketEvent?: SessionEndedWebsocketEvent | undefined;
1587
+ say?: VoiceSayCommand | undefined;
1836
1588
  /**
1837
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1589
+ * A chunk of synthesized audio of a reply. `data` is base64 of PCM audio at the sample rate of the `say` command. An empty `data` marks the end of the stream.
1838
1590
  * @public
1839
1591
  */
1840
- errorWebsocketEvent?: ErrorWebsocketEvent | undefined;
1592
+ play?: VoicePlayCommand | undefined;
1841
1593
  /**
1842
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1594
+ * Stop the audio of the agent.
1843
1595
  * @public
1844
1596
  */
1845
- sayWebsocketCommand?: SayWebsocketCommand | undefined;
1597
+ stop?: VoiceStopCommand | undefined;
1846
1598
  /**
1847
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1599
+ * End the session and hang up the call.
1848
1600
  * @public
1849
1601
  */
1850
- playWebsocketCommand?: PlayWebsocketCommand | undefined;
1602
+ hangup?: VoiceHangupCommand | undefined;
1851
1603
  /**
1852
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1604
+ * Transfer the call to a PBX destination and end the session. Only a PBX client does the transfer.
1853
1605
  * @public
1854
1606
  */
1855
- stopWebsocketCommand?: StopWebsocketCommand | undefined;
1607
+ transfer?: VoiceTransferCommand | undefined;
1608
+ }
1609
+ /**
1610
+ * The connect parameters and the messages of the text socket `/v2/voice/ws`.
1611
+ * @public
1612
+ */
1613
+ export interface VoiceTextProtocolFrames {
1856
1614
  /**
1857
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1615
+ * Query parameters of the upgrade request.
1858
1616
  * @public
1859
1617
  */
1860
- hangupWebsocketCommand?: HangupWebsocketCommand | undefined;
1618
+ connectParams?: VoiceConnectParams | undefined;
1861
1619
  /**
1862
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1620
+ * Messages that the client sends.
1863
1621
  * @public
1864
1622
  */
1865
- transferWebsocketCommand?: TransferWebsocketCommand | undefined;
1623
+ client?: VoiceTextClientFrames | undefined;
1866
1624
  /**
1867
- * One event of the StreamCallEvents SSE stream (`event:` is the member name, `data:` its JSON). Listed here so the generated SDKs carry the union; the stream body itself is an opaque byte stream.
1625
+ * Messages that the server sends.
1868
1626
  * @public
1869
1627
  */
1870
- callEvent?: VoiceCallEvent | undefined;
1628
+ server?: VoiceTextServerFrames | undefined;
1629
+ }
1630
+ /**
1631
+ * @public
1632
+ */
1633
+ export interface DescribeVoiceProtocolOutput {
1634
+ /**
1635
+ * Text socket `/v2/voice/ws`.
1636
+ * @public
1637
+ */
1638
+ textSocket?: VoiceTextProtocolFrames | undefined;
1639
+ /**
1640
+ * Call socket `/v2/voice/calls/ws`.
1641
+ * @public
1642
+ */
1643
+ callSocket?: VoiceCallProtocolFrames | undefined;
1871
1644
  /**
1872
- * Messages of the PBX media socket `/v2/voice/media/ws` (subprotocol `wilma-media-v2`): one example of each. The binary audio messages are base64 here and raw bytes on the socket.
1645
+ * One event of the StreamCallEvents SSE stream (`event:` is the member name, `data:` its JSON). The stream body itself is an opaque byte stream.
1873
1646
  * @public
1874
1647
  */
1875
- media?: MediaProtocolFrames | undefined;
1648
+ callEvent?: VoiceCallEvent | undefined;
1876
1649
  }
1877
1650
  /**
1878
1651
  * @public
@@ -1936,13 +1709,17 @@ export interface ListVoicesOutput {
1936
1709
  voices: Voice[];
1937
1710
  }
1938
1711
  /**
1939
- * Terminate the session and hang up the call.
1712
+ * End the session and hang up the call.
1940
1713
  * @public
1941
1714
  */
1942
1715
  export interface SendHangupInput {
1716
+ /**
1717
+ * Why the session ended.
1718
+ * @public
1719
+ */
1943
1720
  reason?: string | undefined;
1944
1721
  /**
1945
- * Caller-facing voice session identifier, unique per connection. Supplied by the client at connect (the PBX call/session id, or a client-generated id for web sessions).
1722
+ * Id of the voice session.
1946
1723
  * @public
1947
1724
  */
1948
1725
  sessionId: string;
@@ -1953,23 +1730,15 @@ export interface SendHangupInput {
1953
1730
  export interface SendHangupOutput {
1954
1731
  }
1955
1732
  /**
1956
- * A chunk of synthesized reply audio to play. `data` is base64, PCM-encoded at the sample rate declared in the matching `say` command; an empty `data` marks the end of the stream.
1733
+ * A chunk of synthesized audio of a reply. `data` is base64 of PCM audio at the sample rate of the `say` command. An empty `data` marks the end of the stream.
1957
1734
  * @public
1958
1735
  */
1959
1736
  export interface SendPlayInput {
1960
- /**
1961
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
1962
- * @public
1963
- */
1964
1737
  replyId: string;
1965
- /**
1966
- * Identifies one synthesized audio stream within a session; carried by a `say` command and the `play` frames that render it.
1967
- * @public
1968
- */
1969
1738
  streamId: string;
1970
1739
  data: string;
1971
1740
  /**
1972
- * Caller-facing voice session identifier, unique per connection. Supplied by the client at connect (the PBX call/session id, or a client-generated id for web sessions).
1741
+ * Id of the voice session.
1973
1742
  * @public
1974
1743
  */
1975
1744
  sessionId: string;
@@ -1980,40 +1749,32 @@ export interface SendPlayInput {
1980
1749
  export interface SendPlayOutput {
1981
1750
  }
1982
1751
  /**
1983
- * Play a reply to the caller. When `audio` is absent the client performs text-to-speech from `text`; when present the server streams synthesized `play` frames for this reply.
1752
+ * Play a reply to the caller. When `audio` is present, the service sends the audio of the reply in `play` commands. When `audio` is absent, the client shows `text` or synthesizes it itself.
1984
1753
  * @public
1985
1754
  */
1986
1755
  export interface SendSayInput {
1987
- text: string;
1988
1756
  /**
1989
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
1757
+ * Text of the reply.
1990
1758
  * @public
1991
1759
  */
1992
- replyId: string;
1760
+ text: string;
1993
1761
  /**
1994
- * Whether the caller may barge in over this reply.
1762
+ * Id of the reply.
1995
1763
  * @public
1996
1764
  */
1997
- interruptible?: boolean | undefined;
1765
+ replyId: string;
1998
1766
  /**
1999
- * Bare Amazon Polly voice id, e.g. 'Joanna' — NOT a URI. The PBX consumes this verbatim as the
2000
- * AMI `Voice=` action parameter, so it takes exactly what Polly names the voice, with the
2001
- * `amazon_polly://` scheme and any query parameters already stripped by whoever builds this
2002
- * command out of the agent's stored `VoiceUri`.
2003
- *
2004
- * Set only for a provider whose synthesis runs ON THE PBX (Amazon Polly); ElevenLabs and Google
2005
- * are synthesized in the cloud and streamed as PCM through `play` instead, and leave this
2006
- * absent.
1767
+ * True when the caller can interrupt the reply.
2007
1768
  * @public
2008
1769
  */
2009
- voice?: string | undefined;
1770
+ interruptible?: boolean | undefined;
2010
1771
  /**
2011
- * Audio-stream parameters when the server synthesizes the reply itself (TTS provider configured on the agent): the `say` is followed by a stream of `play` frames on this stream id.
1772
+ * Audio of a reply that the service synthesizes. `play` commands with this stream id follow the `say` command.
2012
1773
  * @public
2013
1774
  */
2014
- audio?: SayCommandAudioOptions | undefined;
1775
+ audio?: VoiceSayCommandAudioOptions | undefined;
2015
1776
  /**
2016
- * Caller-facing voice session identifier, unique per connection. Supplied by the client at connect (the PBX call/session id, or a client-generated id for web sessions).
1777
+ * Id of the voice session.
2017
1778
  * @public
2018
1779
  */
2019
1780
  sessionId: string;
@@ -2028,7 +1789,7 @@ export interface SendSayOutput {
2028
1789
  */
2029
1790
  export interface SendStopInput {
2030
1791
  /**
2031
- * Caller-facing voice session identifier, unique per connection. Supplied by the client at connect (the PBX call/session id, or a client-generated id for web sessions).
1792
+ * Id of the voice session.
2032
1793
  * @public
2033
1794
  */
2034
1795
  sessionId: string;
@@ -2039,14 +1800,22 @@ export interface SendStopInput {
2039
1800
  export interface SendStopOutput {
2040
1801
  }
2041
1802
  /**
2042
- * Transfer the call to a PBX destination and terminate the session. Honoured on PBX clients.
1803
+ * Transfer the call to a PBX destination and end the session. Only a PBX client does the transfer.
2043
1804
  * @public
2044
1805
  */
2045
1806
  export interface SendTransferInput {
1807
+ /**
1808
+ * Dialplan context of the destination.
1809
+ * @public
1810
+ */
2046
1811
  context: string;
1812
+ /**
1813
+ * Extension of the destination.
1814
+ * @public
1815
+ */
2047
1816
  extension: string;
2048
1817
  /**
2049
- * Caller-facing voice session identifier, unique per connection. Supplied by the client at connect (the PBX call/session id, or a client-generated id for web sessions).
1818
+ * Id of the voice session.
2050
1819
  * @public
2051
1820
  */
2052
1821
  sessionId: string;