@wildix/wilma-voice-client 0.0.51 → 0.0.52

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