@wildix/wilma-voice-client 0.0.50 → 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;
@@ -562,569 +899,168 @@ export declare namespace VoiceCallEvent {
562
899
  agentTranscription: (value: VoiceCallAgentTranscriptionEvent) => T;
563
900
  reply: (value: VoiceCallReplyEvent) => T;
564
901
  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
- * Agent to run on this session.
611
- * @public
612
- */
613
- agentId: string;
614
- /**
615
- * 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.
616
- * @public
617
- */
618
- agentVersion?: number | undefined;
619
- /**
620
- * Run the agent's current draft (for testing). Mutually exclusive with agentVersion.
621
- * @public
622
- */
623
- agentDraft?: boolean | undefined;
624
- /**
625
- * PBX call id, when the session is bridged to a call.
626
- * @public
627
- */
628
- callId?: string | undefined;
629
- /**
630
- * 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.
631
- * @public
632
- */
633
- flowIndex?: number | undefined;
634
- /**
635
- * The number the caller dialled to reach the agent. Kept on the session as metadata beside `callId` and `flowIndex`.
636
- * @public
637
- */
638
- dialedNumber?: string | undefined;
639
- /**
640
- * BCP-47 language of the conversation, e.g. 'en-US'.
641
- * @public
642
- */
643
- language?: string | undefined;
644
- callerName?: string | undefined;
645
- callerNumber?: string | undefined;
646
- callerEmail?: string | undefined;
647
- callerCompany?: string | undefined;
648
- /**
649
- * Override the TTS voice for this session, as a voice URI, e.g. 'elevenlabs://<voiceId>?apiKey=...'. Defaults to the agent's configured voice.
650
- * @public
651
- */
652
- voice?: string | undefined;
653
- /**
654
- * First message spoken to the caller. Overrides the agent's configured greeting.
655
- * @public
656
- */
657
- initialMessage?: string | undefined;
658
- /**
659
- * Base64-encoded JSON object of agent variables for this session, e.g. base64('\{"orderId":"123"\}').
660
- * @public
661
- */
662
- variables?: string | undefined;
663
- /**
664
- * How caller speech reaches the service. Defaults to TRANSCRIPTION (PBX). Web/app clients use AUDIO.
665
- * @public
666
- */
667
- inputMode?: VoiceInputMode | undefined;
668
- /**
669
- * Format of client `audio` chunks in AUDIO mode.
670
- * @public
671
- */
672
- inputAudio?: VoiceAudioFormat | undefined;
673
- /**
674
- * Preferred format for server-synthesized `play` frames.
675
- * @public
676
- */
677
- outputAudio?: VoiceAudioFormat | undefined;
678
- }
679
- /**
680
- * An error surfaced on the connection. Non-terminal unless followed by a SessionEndedEvent.
681
- * @public
682
- */
683
- export interface VoiceErrorEvent {
684
- /**
685
- * Discriminator for the inner payload of an `event` frame.
686
- * @public
687
- */
688
- type: VoiceEventType;
689
- /**
690
- * Stable machine-readable error code.
691
- * @public
692
- */
693
- code: string;
694
- message: string;
695
- time: number;
696
- }
697
- /**
698
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
699
- * @public
700
- */
701
- export interface ErrorWebsocketEvent {
702
- type: string;
703
- /**
704
- * An error surfaced on the connection. Non-terminal unless followed by a SessionEndedEvent.
705
- * @public
706
- */
707
- event: VoiceErrorEvent;
708
- }
709
- /**
710
- * Terminate the session and hang up the call.
711
- * @public
712
- */
713
- export interface HangupCommandData {
714
- reason?: string | undefined;
715
- /**
716
- * Discriminator for the inner payload of a `command` frame.
717
- * @public
718
- */
719
- type: VoiceCommandType;
720
- }
721
- /**
722
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
723
- * @public
724
- */
725
- export interface HangupWebsocketCommand {
726
- type: string;
727
- /**
728
- * Terminate the session and hang up the call.
729
- * @public
730
- */
731
- command: HangupCommandData;
732
- }
733
- /**
734
- * The caller interrupted (barged in over) a reply that was being played.
735
- * @public
736
- */
737
- export interface InterruptionEvent {
738
- /**
739
- * Discriminator for the inner payload of an `event` frame.
740
- * @public
741
- */
742
- type: VoiceEventType;
743
- /**
744
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
745
- * @public
746
- */
747
- replyId: string;
748
- /**
749
- * Portion of the reply that had been played before the interruption.
750
- * @public
751
- */
752
- playedText: string;
753
- /**
754
- * The full reply text that was being played.
755
- * @public
756
- */
757
- originalText: string;
758
- time: number;
759
- }
760
- /**
761
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
762
- * @public
763
- */
764
- export interface InterruptionWebsocketEvent {
765
- type: string;
766
- /**
767
- * The caller interrupted (barged in over) a reply that was being played.
768
- * @public
769
- */
770
- event: InterruptionEvent;
771
- }
772
- /**
773
- * Opens an agent audio stream. `MediaCloudAudio` messages of the stream follow until `audio.end`. Streams do not interleave.
774
- * @public
775
- */
776
- export interface MediaAudioBeginFrame {
777
- type: MediaAudioBeginFrameType;
778
- /**
779
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
780
- * @public
781
- */
782
- replyId: string;
783
- /**
784
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
785
- * @public
786
- */
787
- streamId: string;
788
- /**
789
- * Sample rate of the stream's `pcm_s16le` mono audio in Hz: 8000, 16000, 22050 or 24000.
790
- * @public
791
- */
792
- sampleRate: number;
793
- }
794
- /**
795
- * Closes an agent audio stream.
796
- * @public
797
- */
798
- export interface MediaAudioEndFrame {
799
- type: MediaAudioEndFrameType;
800
- /**
801
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
802
- * @public
803
- */
804
- streamId: string;
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
+ }
805
909
  }
806
910
  /**
807
- * 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.
808
912
  * @public
809
913
  */
810
- export interface MediaDuckFrame {
811
- type: MediaDuckFrameType;
914
+ export interface VoiceCallAudioBeginFrame {
812
915
  /**
813
- * 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).
814
917
  * @public
815
918
  */
919
+ type: VoiceCallServerFrameType;
816
920
  replyId: string;
921
+ streamId: string;
817
922
  /**
818
- * Target gain in dB.
819
- * @public
820
- */
821
- volumeDb: number;
822
- /**
823
- * 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.
824
924
  * @public
825
925
  */
826
- rampMs: number;
926
+ sampleRate: number;
827
927
  }
828
928
  /**
829
- * An error on the run. When `retryable` is false, the socket closes after it.
929
+ * Closes an agent audio stream.
830
930
  * @public
831
931
  */
832
- export interface MediaErrorFrame {
833
- type: MediaErrorFrameType;
932
+ export interface VoiceCallAudioEndFrame {
834
933
  /**
835
- * 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).
836
935
  * @public
837
936
  */
838
- code: string;
839
- retryable: boolean;
840
- message: string;
841
- }
842
- /**
843
- * Answer to `finish`: the cloud processed all audio. The socket closes with 1000 after it.
844
- * @public
845
- */
846
- export interface MediaFinishedFrame {
847
- type: MediaFinishedFrameType;
848
- }
849
- /**
850
- * Hang up the call after the queued agent audio plays. Terminal: the PBX answers with `finish`.
851
- * @public
852
- */
853
- export interface MediaHangupFrame {
854
- type: MediaHangupFrameType;
937
+ type: VoiceCallServerFrameType;
938
+ streamId: string;
855
939
  }
856
940
  /**
857
- * The call continues in another language.
941
+ * DTMF input that the PBX collected. The cloud takes `digits` as the caller's reply.
858
942
  * @public
859
943
  */
860
- export interface MediaLanguageFrame {
861
- type: MediaLanguageFrameType;
944
+ export interface VoiceCallDtmfFrame {
862
945
  /**
863
- * Language that the call continues in.
946
+ * Value of `type` in a text frame from the client (the PBX).
864
947
  * @public
865
948
  */
866
- language: string;
949
+ type: VoiceCallClientFrameType;
950
+ id: string;
951
+ digits: string;
867
952
  }
868
953
  /**
869
- * Return a reply to full volume.
954
+ * Change the volume of a playing reply. `volumeDb` 0 returns it to full volume.
870
955
  * @public
871
956
  */
872
- export interface MediaRestoreFrame {
873
- type: MediaRestoreFrameType;
957
+ export interface VoiceCallDuckFrame {
874
958
  /**
875
- * 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).
876
960
  * @public
877
961
  */
962
+ type: VoiceCallServerFrameType;
878
963
  replyId: string;
879
964
  /**
880
- * Ramp duration in ms.
881
- * @public
882
- */
883
- rampMs: number;
884
- }
885
- /**
886
- * The agent that answers the run.
887
- * @public
888
- */
889
- export interface MediaStartedAgent {
890
- name: string;
891
- }
892
- /**
893
- * Caller voice detection of a run, with every value resolved.
894
- * @public
895
- */
896
- export interface MediaVoiceDetection {
897
- /**
898
- * Silence in ms that ends the caller speech.
899
- * @public
900
- */
901
- silenceMs: number;
902
- /**
903
- * Mean frame level in dBFS below which caller audio is silence.
965
+ * Target gain in dB.
904
966
  * @public
905
967
  */
906
- silenceLevelDb: number;
968
+ volumeDb: number;
907
969
  /**
908
- * Mean frame level in dBFS from which caller audio is speech.
970
+ * Ramp duration in ms.
909
971
  * @public
910
972
  */
911
- speechLevelDb: number;
973
+ rampMs: number;
912
974
  }
913
975
  /**
914
- * 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`.
915
977
  * @public
916
978
  */
917
- export interface MediaStartedFrame {
918
- type: MediaStartedFrameType;
919
- /**
920
- * Id of the cloud stream of this run. Cloud logs carry it; use it to match PBX and cloud logs.
921
- * @public
922
- */
923
- streamId: string;
924
- /**
925
- * Present when the run purpose is `agent`.
926
- * @public
927
- */
928
- agent?: MediaStartedAgent | undefined;
929
- /**
930
- * Group of the agent. Absent when the agent has none.
931
- * @public
932
- */
933
- groupId?: string | undefined;
979
+ export interface VoiceCallEndFrame {
934
980
  /**
935
- * 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).
936
982
  * @public
937
983
  */
938
- backgroundSound?: string | undefined;
984
+ type: VoiceCallClientFrameType;
939
985
  /**
940
- * 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`.
941
987
  * @public
942
988
  */
943
- voiceDetection?: MediaVoiceDetection | undefined;
989
+ reason: VoiceCallClientEndReason;
944
990
  }
945
991
  /**
946
- * Stop every agent audio stream of the run: the one that plays and the ones that wait.
947
- * @public
948
- */
949
- export interface MediaStopFrame {
950
- type: MediaStopFrameType;
951
- }
952
- /**
953
- * 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.
954
993
  * @public
955
994
  */
956
- export interface MediaTranscriptionFrame {
957
- type: MediaTranscriptionFrameType;
958
- /**
959
- * Party that spoke. The agent's own words are `callee`.
960
- * @public
961
- */
962
- party: MediaParty;
963
- /**
964
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
965
- * @public
966
- */
967
- id: string;
968
- final: boolean;
969
- text: string;
970
- /**
971
- * Run-clock time or duration in ms of PBX audio since the run started. It continues across reconnects.
972
- * @public
973
- */
974
- startMs: number;
975
- /**
976
- * Run-clock time or duration in ms of PBX audio since the run started. It continues across reconnects.
977
- * @public
978
- */
979
- endMs: number;
980
- /**
981
- * BCP-47 language tag, optionally with a region subtag: 'en', 'en-US', 'pt-BR'. Deliberately a
982
- * constrained string rather than an enum: the offerable set is a property of the selected
983
- * recogniser and changes with it, so an enumeration here would cap the set at whatever was known
984
- * when the model was released.
985
- * @public
986
- */
987
- language: string;
995
+ export interface VoiceCallEndedFrame {
988
996
  /**
989
- * 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).
990
998
  * @public
991
999
  */
992
- confidence?: number | undefined;
1000
+ type: VoiceCallServerFrameType;
993
1001
  }
994
1002
  /**
995
- * 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.
996
1004
  * @public
997
1005
  */
998
- export interface MediaTransferFrame {
999
- type: MediaTransferFrameType;
1006
+ export interface VoiceCallErrorFrame {
1000
1007
  /**
1001
- * Dialplan context of the target.
1008
+ * Value of `type` in a text frame from the server (the cloud).
1002
1009
  * @public
1003
1010
  */
1004
- context: string;
1011
+ type: VoiceCallServerFrameType;
1005
1012
  /**
1006
- * Extension of the target.
1013
+ * Stable error code, for example `START_TIMEOUT`, `PROTOCOL_ERROR` or `STT_FAILED`.
1007
1014
  * @public
1008
1015
  */
1009
- extension: string;
1016
+ code: string;
1017
+ retryable: boolean;
1018
+ message: string;
1010
1019
  }
1011
1020
  /**
1012
- * 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`.
1013
1022
  * @public
1014
1023
  */
1015
- export interface MediaCloudFrames {
1016
- /**
1017
- * The cloud accepted `start`. Sent once per connection.
1018
- * @public
1019
- */
1020
- started?: MediaStartedFrame | undefined;
1021
- /**
1022
- * Words of one party. Partials and the final of one utterance share `id`. For the agent, the words that played.
1023
- * @public
1024
- */
1025
- transcription?: MediaTranscriptionFrame | undefined;
1026
- /**
1027
- * Opens an agent audio stream. `MediaCloudAudio` messages of the stream follow until `audio.end`. Streams do not interleave.
1028
- * @public
1029
- */
1030
- audioBegin?: MediaAudioBeginFrame | undefined;
1031
- /**
1032
- * One binary audio message. In the describe answer it is base64; on the socket it is raw bytes.
1033
- * @public
1034
- */
1035
- audio?: Uint8Array | undefined;
1024
+ export interface VoiceCallHangupFrame {
1036
1025
  /**
1037
- * Closes an agent audio stream.
1038
- * @public
1039
- */
1040
- audioEnd?: MediaAudioEndFrame | undefined;
1041
- /**
1042
- * Stop every agent audio stream of the run: the one that plays and the ones that wait.
1043
- * @public
1044
- */
1045
- stop?: MediaStopFrame | undefined;
1046
- /**
1047
- * Lower the volume of a playing reply.
1048
- * @public
1049
- */
1050
- duck?: MediaDuckFrame | undefined;
1051
- /**
1052
- * Return a reply to full volume.
1053
- * @public
1054
- */
1055
- restore?: MediaRestoreFrame | undefined;
1056
- /**
1057
- * The call continues in another language.
1058
- * @public
1059
- */
1060
- language?: MediaLanguageFrame | undefined;
1061
- /**
1062
- * Transfer the call after the queued agent audio plays. Terminal: the PBX answers with `finish`.
1063
- * @public
1064
- */
1065
- transfer?: MediaTransferFrame | undefined;
1066
- /**
1067
- * Hang up the call after the queued agent audio plays. Terminal: the PBX answers with `finish`.
1068
- * @public
1069
- */
1070
- hangup?: MediaHangupFrame | undefined;
1071
- /**
1072
- * An error on the run. When `retryable` is false, the socket closes after it.
1073
- * @public
1074
- */
1075
- error?: MediaErrorFrame | undefined;
1076
- /**
1077
- * 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).
1078
1027
  * @public
1079
1028
  */
1080
- finished?: MediaFinishedFrame | undefined;
1029
+ type: VoiceCallServerFrameType;
1081
1030
  }
1082
1031
  /**
1083
- * DTMF input that the PBX collected. The cloud takes `digits` as the caller's reply.
1032
+ * The call continues in another language.
1084
1033
  * @public
1085
1034
  */
1086
- export interface MediaDtmfFrame {
1087
- type: MediaDtmfFrameType;
1035
+ export interface VoiceCallLanguageFrame {
1088
1036
  /**
1089
- * 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).
1090
1038
  * @public
1091
1039
  */
1092
- id: string;
1093
- digits: string;
1094
- }
1095
- /**
1096
- * The run ended on the PBX. The PBX sends no audio after it and waits up to 3 s for `finished`.
1097
- * @public
1098
- */
1099
- export interface MediaFinishFrame {
1100
- type: MediaFinishFrameType;
1040
+ type: VoiceCallServerFrameType;
1101
1041
  /**
1102
- * Who ended the run on the PBX.
1042
+ * Language that the call continues in.
1103
1043
  * @public
1104
1044
  */
1105
- reason: MediaFinishReason;
1045
+ language: string;
1106
1046
  }
1107
1047
  /**
1108
1048
  * An agent audio stream changed state on the PBX.
1109
1049
  * @public
1110
1050
  */
1111
- export interface MediaPlaybackFrame {
1112
- type: MediaPlaybackFrameType;
1051
+ export interface VoiceCallPlaybackFrame {
1113
1052
  /**
1114
- * 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).
1115
1054
  * @public
1116
1055
  */
1056
+ type: VoiceCallClientFrameType;
1117
1057
  replyId: string;
1118
- /**
1119
- * Id of a reply, a stream, an utterance or a DTMF input, unique in the run.
1120
- * @public
1121
- */
1122
1058
  streamId: string;
1123
1059
  /**
1124
1060
  * Event of an agent audio stream.
1125
1061
  * @public
1126
1062
  */
1127
- event: MediaPlaybackEvent;
1063
+ event: VoiceCallPlaybackPhase;
1128
1064
  /**
1129
1065
  * Run-clock time or duration in ms of PBX audio since the run started. It continues across reconnects.
1130
1066
  * @public
@@ -1136,16 +1072,16 @@ export interface MediaPlaybackFrame {
1136
1072
  */
1137
1073
  playedMs?: number | undefined;
1138
1074
  /**
1139
- * Present with `stopped`.
1075
+ * True when the PBX dropped the stream, for example at its queue limit. Only with `stopped`. Absent: false.
1140
1076
  * @public
1141
1077
  */
1142
- cause?: MediaPlaybackStopCause | undefined;
1078
+ dropped?: boolean | undefined;
1143
1079
  }
1144
1080
  /**
1145
- * 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.
1146
1082
  * @public
1147
1083
  */
1148
- export interface MediaStartAgent {
1084
+ export interface VoiceCallStartAgent {
1149
1085
  /**
1150
1086
  * Agent id.
1151
1087
  * @public
@@ -1163,31 +1099,10 @@ export interface MediaStartAgent {
1163
1099
  version?: number | undefined;
1164
1100
  }
1165
1101
  /**
1166
- * 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.
1167
- * @public
1168
- */
1169
- export interface MediaAudioFormat {
1170
- /**
1171
- * Sample encoding of PBX audio.
1172
- * @public
1173
- */
1174
- encoding: MediaAudioEncoding;
1175
- /**
1176
- * Sample rate in Hz.
1177
- * @public
1178
- */
1179
- sampleRate: number;
1180
- /**
1181
- * Number of channels.
1182
- * @public
1183
- */
1184
- channels: number;
1185
- }
1186
- /**
1187
- * 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.
1188
1103
  * @public
1189
1104
  */
1190
- export interface MediaStartCaller {
1105
+ export interface VoiceCallStartCaller {
1191
1106
  name?: string | undefined;
1192
1107
  number?: string | undefined;
1193
1108
  email?: string | undefined;
@@ -1197,572 +1112,374 @@ export interface MediaStartCaller {
1197
1112
  * First text frame of a socket, sent within 10 s of the upgrade. Opens a run, or attaches a reconnect to it.
1198
1113
  * @public
1199
1114
  */
1200
- export interface MediaStartFrame {
1201
- type: MediaStartFrameType;
1115
+ export interface VoiceCallStartFrame {
1202
1116
  /**
1203
- * Purpose of a media run.
1117
+ * Value of `type` in a text frame from the client (the PBX).
1204
1118
  * @public
1205
1119
  */
1206
- purpose: MediaRunPurpose;
1120
+ type: VoiceCallClientFrameType;
1207
1121
  /**
1208
1122
  * Id of the PBX call. Use it to correlate the call events of the run.
1209
1123
  * @public
1210
1124
  */
1211
1125
  callId: string;
1212
1126
  /**
1213
- * Index of this run on the call, from 0.
1214
- * @public
1215
- */
1216
- flowIndex: number;
1217
- /**
1218
- * Id of this run. The same on every connection of the run; the cloud attaches a reconnect and settles a takeover by it.
1219
- * @public
1220
- */
1221
- sessionId: string;
1222
- /**
1223
- * True when an earlier connection of this run got agent audio (`audio.begin`): the cloud continues that session without a new greeting.
1224
- * @public
1225
- */
1226
- resume: boolean;
1227
- /**
1228
- * Run-clock time of the first audio byte of this connection: 0 on the first connection.
1229
- * @public
1230
- */
1231
- resumeAtMs: number;
1232
- /**
1233
- * 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.
1234
- * @public
1235
- */
1236
- audio: MediaAudioFormat;
1237
- /**
1238
- * Present when `purpose` is `agent`.
1239
- * @public
1240
- */
1241
- agent?: MediaStartAgent | undefined;
1242
- /**
1243
- * 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.
1244
- * @public
1245
- */
1246
- languages?: string[] | undefined;
1247
- /**
1248
- * 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`.
1249
- * @public
1250
- */
1251
- preferredLanguage?: string | undefined;
1252
- /**
1253
- * True to identify the caller's language among `languages` when `purpose` is `transcription`. Absent: false. Ignored when `purpose` is `agent`.
1254
- * @public
1255
- */
1256
- autoDetect?: boolean | undefined;
1257
- /**
1258
- * Caller identity. Each member is absent, null or empty when unknown.
1259
- * @public
1260
- */
1261
- caller: MediaStartCaller;
1262
- /**
1263
- * Number that the caller dialled. Absent, null or empty when unknown.
1264
- * @public
1265
- */
1266
- dialedNumber?: string | undefined;
1267
- /**
1268
- * Base64 of a JSON object of the `VOICEBOT_*` channel variables. Absent, null or empty when there are none.
1269
- * @public
1270
- */
1271
- variables?: string | undefined;
1272
- }
1273
- /**
1274
- * Voice activity of a party as the PBX detects it. Sent when the state changes, and every 100 ms while agent audio plays.
1275
- * @public
1276
- */
1277
- export interface MediaVadFrame {
1278
- type: MediaVadFrameType;
1279
- /**
1280
- * Party whose audio the report describes.
1281
- * @public
1282
- */
1283
- party: MediaParty;
1284
- /**
1285
- * True while the party speaks.
1286
- * @public
1287
- */
1288
- speaking: boolean;
1289
- /**
1290
- * Energy of the audio frame that produced the report, in dBFS.
1291
- * @public
1292
- */
1293
- energyDb: number;
1294
- /**
1295
- * Run-clock time or duration in ms of PBX audio since the run started. It continues across reconnects.
1296
- * @public
1297
- */
1298
- atMs: number;
1299
- }
1300
- /**
1301
- * One example of each message that the PBX sends.
1302
- * @public
1303
- */
1304
- export interface MediaPbxFrames {
1305
- /**
1306
- * First text frame of a socket, sent within 10 s of the upgrade. Opens a run, or attaches a reconnect to it.
1127
+ * Index of this run on the call, from 0.
1307
1128
  * @public
1308
1129
  */
1309
- start?: MediaStartFrame | undefined;
1130
+ flowIndex: number;
1310
1131
  /**
1311
- * One binary audio message. In the describe answer it is base64; on the socket it is raw bytes.
1132
+ * Id of this run. The same on every connection of the run; the cloud attaches a reconnect and settles a takeover by it.
1312
1133
  * @public
1313
1134
  */
1314
- audio?: Uint8Array | undefined;
1135
+ sessionId: string;
1315
1136
  /**
1316
- * Voice activity of a party as the PBX detects it. Sent when the state changes, and every 100 ms while agent audio plays.
1137
+ * True when an earlier connection of this run got agent audio (`audio.begin`): the cloud continues that session without a new greeting.
1317
1138
  * @public
1318
1139
  */
1319
- vad?: MediaVadFrame | undefined;
1140
+ resume: boolean;
1320
1141
  /**
1321
- * DTMF input that the PBX collected. The cloud takes `digits` as the caller's reply.
1142
+ * Run-clock time of the first audio byte of this connection: 0 on the first connection.
1322
1143
  * @public
1323
1144
  */
1324
- dtmf?: MediaDtmfFrame | undefined;
1145
+ resumeAtMs: number;
1325
1146
  /**
1326
- * An agent audio stream changed state on the PBX.
1147
+ * The agent of the run. At most one of `draft` and `version` is set.
1327
1148
  * @public
1328
1149
  */
1329
- playback?: MediaPlaybackFrame | undefined;
1150
+ agent: VoiceCallStartAgent;
1330
1151
  /**
1331
- * The run ended on the PBX. The PBX sends no audio after it and waits up to 3 s for `finished`.
1152
+ * Language of the call, for example `en-US`. The agent starts in its configured language that matches it.
1332
1153
  * @public
1333
1154
  */
1334
- finish?: MediaFinishFrame | undefined;
1335
- }
1336
- /**
1337
- * One example of each message of the PBX media socket.
1338
- * @public
1339
- */
1340
- export interface MediaProtocolFrames {
1155
+ language: string;
1341
1156
  /**
1342
- * Messages that the PBX sends.
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.
1343
1158
  * @public
1344
1159
  */
1345
- pbx?: MediaPbxFrames | undefined;
1160
+ caller: VoiceCallStartCaller;
1346
1161
  /**
1347
- * Messages that the cloud sends.
1162
+ * Number that the caller dialled. Absent, null or empty when unknown.
1163
+ * @public
1164
+ */
1165
+ dialedNumber?: string | undefined;
1166
+ /**
1167
+ * Base64 of a JSON object of the `VOICEBOT_*` channel variables. Absent, null or empty when there are none.
1348
1168
  * @public
1349
1169
  */
1350
- cloud?: MediaCloudFrames | undefined;
1170
+ variables?: string | undefined;
1351
1171
  }
1352
1172
  /**
1353
- * 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"\}\}`.
1354
1174
  * @public
1355
1175
  */
1356
- export interface PlaybackEvent {
1176
+ export interface VoiceCallStartedFrame {
1357
1177
  /**
1358
- * Discriminator for the inner payload of an `event` frame.
1178
+ * Value of `type` in a text frame from the server (the cloud).
1359
1179
  * @public
1360
1180
  */
1361
- type: VoiceEventType;
1181
+ type: VoiceCallServerFrameType;
1362
1182
  /**
1363
- * 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.
1364
1184
  * @public
1365
1185
  */
1366
- replyId: string;
1367
- text: string;
1368
- complete: boolean;
1369
- startTime: number;
1370
- endTime?: number | undefined;
1371
- }
1372
- /**
1373
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1374
- * @public
1375
- */
1376
- export interface PlaybackWebsocketEvent {
1377
- type: string;
1186
+ connectionId: string;
1378
1187
  /**
1379
- * Client-reported progress of an in-flight reply playback.
1188
+ * Display name of the agent.
1380
1189
  * @public
1381
1190
  */
1382
- event: PlaybackEvent;
1383
- }
1384
- /**
1385
- * 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.
1386
- * @public
1387
- */
1388
- export interface PlayCommandData {
1191
+ agentName: string;
1389
1192
  /**
1390
- * 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.
1391
1194
  * @public
1392
1195
  */
1393
- replyId: string;
1196
+ groupId?: string | undefined;
1394
1197
  /**
1395
- * 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.
1396
1199
  * @public
1397
1200
  */
1398
- streamId: string;
1399
- data: string;
1201
+ backgroundSound?: string | undefined;
1400
1202
  /**
1401
- * 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.
1402
1204
  * @public
1403
1205
  */
1404
- type: VoiceCommandType;
1206
+ voiceDetection?: VoiceDetectionSettings | undefined;
1405
1207
  }
1406
1208
  /**
1407
- * 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.
1408
1210
  * @public
1409
1211
  */
1410
- export interface PlayWebsocketCommand {
1411
- type: string;
1212
+ export interface VoiceCallStopFrame {
1412
1213
  /**
1413
- * 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).
1414
1215
  * @public
1415
1216
  */
1416
- command: PlayCommandData;
1217
+ type: VoiceCallServerFrameType;
1417
1218
  }
1418
1219
  /**
1419
- * 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.
1420
1221
  * @public
1421
1222
  */
1422
- export interface ReplyEvent {
1223
+ export interface VoiceCallTranscriptionFrame {
1423
1224
  /**
1424
- * Discriminator for the inner payload of an `event` frame.
1225
+ * Value of `type` in a text frame from the server (the cloud).
1425
1226
  * @public
1426
1227
  */
1427
- type: VoiceEventType;
1228
+ type: VoiceCallServerFrameType;
1428
1229
  /**
1429
- * 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`.
1430
1231
  * @public
1431
1232
  */
1233
+ party: VoiceCallParty;
1432
1234
  id: string;
1235
+ final: boolean;
1433
1236
  text: string;
1434
1237
  /**
1435
- * 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.
1436
1239
  * @public
1437
1240
  */
1438
- language?: string | undefined;
1439
- startTime: number;
1440
- endTime: number;
1441
- }
1442
- /**
1443
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1444
- * @public
1445
- */
1446
- export interface ReplyWebsocketEvent {
1447
- type: string;
1241
+ startMs: number;
1448
1242
  /**
1449
- * 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.
1450
1244
  * @public
1451
1245
  */
1452
- event: ReplyEvent;
1453
- }
1454
- /**
1455
- * 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.
1456
- * @public
1457
- */
1458
- export interface SayCommandAudioOptions {
1246
+ endMs: number;
1459
1247
  /**
1460
- * 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.
1461
1252
  * @public
1462
1253
  */
1463
- streamId: string;
1464
- 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;
1465
1260
  }
1466
1261
  /**
1467
- * 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`.
1468
1263
  * @public
1469
1264
  */
1470
- export interface SayCommandData {
1471
- text: string;
1472
- /**
1473
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
1474
- * @public
1475
- */
1476
- replyId: string;
1477
- /**
1478
- * Whether the caller may barge in over this reply.
1479
- * @public
1480
- */
1481
- interruptible?: boolean | undefined;
1265
+ export interface VoiceCallTransferFrame {
1482
1266
  /**
1483
- * Bare Amazon Polly voice id, e.g. 'Joanna' — NOT a URI. The PBX consumes this verbatim as the
1484
- * AMI `Voice=` action parameter, so it takes exactly what Polly names the voice, with the
1485
- * `amazon_polly://` scheme and any query parameters already stripped by whoever builds this
1486
- * command out of the agent's stored `VoiceUri`.
1487
- *
1488
- * Set only for a provider whose synthesis runs ON THE PBX (Amazon Polly); ElevenLabs and Google
1489
- * are synthesized in the cloud and streamed as PCM through `play` instead, and leave this
1490
- * absent.
1267
+ * Dialplan context of the destination.
1491
1268
  * @public
1492
1269
  */
1493
- voice?: string | undefined;
1270
+ context: string;
1494
1271
  /**
1495
- * 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.
1496
1273
  * @public
1497
1274
  */
1498
- audio?: SayCommandAudioOptions | undefined;
1275
+ extension: string;
1499
1276
  /**
1500
- * Discriminator for the inner payload of a `command` frame.
1277
+ * Value of `type` in a text frame from the server (the cloud).
1501
1278
  * @public
1502
1279
  */
1503
- type: VoiceCommandType;
1280
+ type: VoiceCallServerFrameType;
1504
1281
  }
1505
1282
  /**
1506
- * 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.
1507
1284
  * @public
1508
1285
  */
1509
- export interface SayWebsocketCommand {
1510
- type: string;
1286
+ export interface VoiceCallVadFrame {
1511
1287
  /**
1512
- * 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).
1513
1289
  * @public
1514
1290
  */
1515
- command: SayCommandData;
1516
- }
1517
- /**
1518
- * Terminal server event: the session ended, optionally with an error.
1519
- * @public
1520
- */
1521
- export interface SessionEndedEvent {
1291
+ type: VoiceCallClientFrameType;
1522
1292
  /**
1523
- * Discriminator for the inner payload of an `event` frame.
1293
+ * True while the caller speaks.
1524
1294
  * @public
1525
1295
  */
1526
- type: VoiceEventType;
1527
- reason?: string | undefined;
1296
+ speaking: boolean;
1528
1297
  /**
1529
- * Present when the session ended because of an error.
1298
+ * Energy of the audio frame that produced the report, in dBFS.
1530
1299
  * @public
1531
1300
  */
1532
- error?: string | undefined;
1533
- time: number;
1534
- }
1535
- /**
1536
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1537
- * @public
1538
- */
1539
- export interface SessionEndedWebsocketEvent {
1540
- type: string;
1301
+ energyDb: number;
1541
1302
  /**
1542
- * 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.
1543
1304
  * @public
1544
1305
  */
1545
- event: SessionEndedEvent;
1306
+ atMs: number;
1546
1307
  }
1547
1308
  /**
1548
- * Recognition intent for the call, sent on `started` at protocolVersion >= 2. NOT recogniser
1549
- * parameters: the PBX translates it into its provider's API. Against Amazon Transcribe with
1550
- * autoDetect true that is identify-multiple-languages plus language-options and
1551
- * preferred-language; with autoDetect false, a single-language stream on preferredLanguage.
1552
- *
1553
- * Both members the server can get wrong are RESOLVED here rather than forwarded: `engine` is
1554
- * always concrete (an absent one would let the PBX apply a different default than the console
1555
- * built its language list for), and `autoDetect` is clamped to false whenever the language count
1556
- * is below the recogniser's minimum or the recogniser cannot identify languages at all
1557
- * (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.
1558
1310
  * @public
1559
1311
  */
1560
- export interface VoiceSpeechPayload {
1312
+ export interface VoiceCallProtocolFrames {
1561
1313
  /**
1562
- * 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.
1563
1315
  * @public
1564
1316
  */
1565
- engine: string;
1317
+ start?: VoiceCallStartFrame | undefined;
1566
1318
  /**
1567
- * 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.
1568
1320
  * @public
1569
1321
  */
1570
- languages: string[];
1322
+ vad?: VoiceCallVadFrame | undefined;
1571
1323
  /**
1572
- * 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.
1573
1325
  * @public
1574
1326
  */
1575
- preferredLanguage: string;
1327
+ dtmf?: VoiceCallDtmfFrame | undefined;
1576
1328
  /**
1577
- * 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.
1578
1330
  * @public
1579
1331
  */
1580
- autoDetect: boolean;
1581
- }
1582
- /**
1583
- * 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.
1584
- * @public
1585
- */
1586
- export interface SessionStartedEvent {
1332
+ playback?: VoiceCallPlaybackFrame | undefined;
1587
1333
  /**
1588
- * 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`.
1589
1335
  * @public
1590
1336
  */
1591
- type: VoiceEventType;
1592
- time: number;
1337
+ end?: VoiceCallEndFrame | undefined;
1593
1338
  /**
1594
- * 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"\}\}`.
1595
1340
  * @public
1596
1341
  */
1597
- sessionId: string;
1342
+ started?: VoiceCallStartedFrame | undefined;
1598
1343
  /**
1599
- * 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.
1600
1345
  * @public
1601
1346
  */
1602
- agentId: string;
1347
+ transcription?: VoiceCallTranscriptionFrame | undefined;
1603
1348
  /**
1604
- * 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.
1605
1350
  * @public
1606
1351
  */
1607
- agentVersion?: number | undefined;
1352
+ audioBegin?: VoiceCallAudioBeginFrame | undefined;
1608
1353
  /**
1609
- * Trace recording this voice session in wilma-traces — the caller's transcribed phrases, the
1610
- * model calls they drove and the tools the agent ran. Read it with the wilma-traces GetTrace
1611
- * operation, or tail it live with StreamTrace to follow a call while it is in progress.
1612
- *
1613
- * Sent once at handshake and stable for the connection: a call is one trace. A caller who
1614
- * redials gets a new session and therefore a new trace, since the trace is keyed on the session
1615
- * id supplied at connect.
1354
+ * Closes an agent audio stream.
1616
1355
  * @public
1617
1356
  */
1618
- traceId?: string | undefined;
1357
+ audioEnd?: VoiceCallAudioEndFrame | undefined;
1619
1358
  /**
1620
- * Agent display name.
1359
+ * Stop every agent audio stream of the run: the one that plays and the ones that wait.
1621
1360
  * @public
1622
1361
  */
1623
- agentName?: string | undefined;
1362
+ stop?: VoiceCallStopFrame | undefined;
1624
1363
  /**
1625
- * Agent category.
1364
+ * Change the volume of a playing reply. `volumeDb` 0 returns it to full volume.
1626
1365
  * @public
1627
1366
  */
1628
- category?: string | undefined;
1367
+ duck?: VoiceCallDuckFrame | undefined;
1629
1368
  /**
1630
- * PBX group used for data ACL; empty when the agent is not assigned to a group.
1369
+ * The call continues in another language.
1631
1370
  * @public
1632
1371
  */
1633
- groupId?: string | undefined;
1372
+ language?: VoiceCallLanguageFrame | undefined;
1634
1373
  /**
1635
- * 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`.
1636
1375
  * @public
1637
1376
  */
1638
- speech?: VoiceSpeechPayload | undefined;
1377
+ transfer?: VoiceCallTransferFrame | undefined;
1639
1378
  /**
1640
- * Music-on-hold class the PBX should play under the call as ambient background.
1641
- *
1642
- * A BARE NAME, not the configuration object `VoiceBackgroundSoundSettings`: this is the RESOLVED
1643
- * outcome. The server has already applied `enabled` and the class default, so the PBX gets a name
1644
- * to play or nothing at all and needs no resolution rule of its own.
1645
- *
1646
- * TOP LEVEL, NOT INSIDE `speech`, because it is not recognition intent and must not inherit
1647
- * `speech`'s conditions: a call with no configured languages carries no `speech` payload and can
1648
- * still have background audio.
1649
- *
1650
- * ABSENT MEANS OFF, and absence is the only way to say it — there is no value for 'none'. A bot
1651
- * whose administrator never touched the setting sends nothing here, which is exactly what every
1652
- * 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`.
1653
1380
  * @public
1654
1381
  */
1655
- backgroundSound?: string | undefined;
1382
+ hangup?: VoiceCallHangupFrame | undefined;
1656
1383
  /**
1657
- * 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.
1658
1385
  * @public
1659
1386
  */
1660
- inputAudio?: VoiceAudioFormat | undefined;
1387
+ error?: VoiceCallErrorFrame | undefined;
1661
1388
  /**
1662
- * 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.
1663
1390
  * @public
1664
1391
  */
1665
- outputAudio?: VoiceAudioFormat | undefined;
1392
+ ended?: VoiceCallEndedFrame | undefined;
1666
1393
  }
1667
1394
  /**
1668
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1395
+ * Parameters supplied on the WebSocket connect (upgrade) request, as query-string parameters.
1669
1396
  * @public
1670
1397
  */
1671
- export interface SessionStartedWebsocketEvent {
1672
- type: string;
1398
+ export interface VoiceConnectParams {
1673
1399
  /**
1674
- * 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.
1675
1401
  * @public
1676
1402
  */
1677
- event: SessionStartedEvent;
1678
- }
1679
- /**
1680
- * @public
1681
- */
1682
- export interface StopCommandData {
1403
+ protocolVersion?: number | undefined;
1683
1404
  /**
1684
- * Discriminator for the inner payload of a `command` frame.
1405
+ * Caller-supplied session id, unique per connection.
1685
1406
  * @public
1686
1407
  */
1687
- type: VoiceCommandType;
1688
- }
1689
- /**
1690
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1691
- * @public
1692
- */
1693
- export interface StopWebsocketCommand {
1694
- type: string;
1695
- command: StopCommandData;
1696
- }
1697
- /**
1698
- * 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.
1699
- * @public
1700
- */
1701
- export interface TranscriptionEvent {
1408
+ sessionId: string;
1702
1409
  /**
1703
- * 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.
1704
1411
  * @public
1705
1412
  */
1706
- type: VoiceEventType;
1413
+ resume?: boolean | undefined;
1707
1414
  /**
1708
- * Identifier of a transcription chunk within a session.
1415
+ * Agent to run on this session.
1709
1416
  * @public
1710
1417
  */
1711
- id: string;
1712
- text: string;
1418
+ agentId: string;
1713
1419
  /**
1714
- * 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.
1715
1421
  * @public
1716
1422
  */
1717
- confidence?: number | undefined;
1423
+ agentVersion?: number | undefined;
1718
1424
  /**
1719
- * 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.
1720
1426
  * @public
1721
1427
  */
1722
- 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;
1723
1444
  /**
1724
- * 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'.
1725
1446
  * @public
1726
1447
  */
1727
1448
  language?: string | undefined;
1728
- time: number;
1729
- }
1730
- /**
1731
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1732
- * @public
1733
- */
1734
- export interface TranscriptionWebsocketEvent {
1735
- type: string;
1449
+ callerName?: string | undefined;
1450
+ callerNumber?: string | undefined;
1451
+ callerEmail?: string | undefined;
1452
+ callerCompany?: string | undefined;
1736
1453
  /**
1737
- * 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.
1738
1455
  * @public
1739
1456
  */
1740
- event: TranscriptionEvent;
1741
- }
1742
- /**
1743
- * Transfer the call to a PBX destination and terminate the session. Honoured on PBX clients.
1744
- * @public
1745
- */
1746
- export interface TransferCommandData {
1747
- context: string;
1748
- extension: string;
1457
+ voice?: string | undefined;
1749
1458
  /**
1750
- * Discriminator for the inner payload of a `command` frame.
1459
+ * First message spoken to the caller. Overrides the agent's configured greeting.
1751
1460
  * @public
1752
1461
  */
1753
- type: VoiceCommandType;
1754
- }
1755
- /**
1756
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1757
- * @public
1758
- */
1759
- export interface TransferWebsocketCommand {
1760
- 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;
1761
1478
  /**
1762
- * 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.
1763
1480
  * @public
1764
1481
  */
1765
- command: TransferCommandData;
1482
+ company?: string | undefined;
1766
1483
  }
1767
1484
  /**
1768
1485
  * @public
@@ -1774,95 +1491,90 @@ export interface DescribeVoiceProtocolOutput {
1774
1491
  */
1775
1492
  connectParams?: VoiceConnectParams | undefined;
1776
1493
  /**
1777
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1778
- * @public
1779
- */
1780
- audioWebsocketEvent?: AudioWebsocketEvent | undefined;
1781
- /**
1782
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1494
+ * Keepalive frame from the client: `\{"type": "healthcheck"\}`. The service sends no answer.
1783
1495
  * @public
1784
1496
  */
1785
- transcriptionWebsocketEvent?: TranscriptionWebsocketEvent | undefined;
1497
+ healthcheckWebsocketFrame?: VoiceHealthcheckWebsocketFrame | undefined;
1786
1498
  /**
1787
- * 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.
1788
1500
  * @public
1789
1501
  */
1790
- agentTranscriptionWebsocketEvent?: AgentTranscriptionWebsocketEvent | undefined;
1502
+ transcriptionEvent?: VoiceTranscriptionEvent | undefined;
1791
1503
  /**
1792
- * 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.
1793
1505
  * @public
1794
1506
  */
1795
- replyWebsocketEvent?: ReplyWebsocketEvent | undefined;
1507
+ agentTranscriptionEvent?: VoiceAgentTranscriptionEvent | undefined;
1796
1508
  /**
1797
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1509
+ * A final caller utterance. It starts an agent turn.
1798
1510
  * @public
1799
1511
  */
1800
- playbackWebsocketEvent?: PlaybackWebsocketEvent | undefined;
1512
+ replyEvent?: VoiceReplyEvent | undefined;
1801
1513
  /**
1802
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1514
+ * Progress of the playback of a reply on the client.
1803
1515
  * @public
1804
1516
  */
1805
- interruptionWebsocketEvent?: InterruptionWebsocketEvent | undefined;
1517
+ playbackEvent?: VoicePlaybackEvent | undefined;
1806
1518
  /**
1807
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1519
+ * The caller spoke over a reply while the client played it.
1808
1520
  * @public
1809
1521
  */
1810
- completeWebsocketEvent?: CompleteWebsocketEvent | undefined;
1522
+ interruptionEvent?: VoiceInterruptionEvent | undefined;
1811
1523
  /**
1812
- * 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.
1813
1525
  * @public
1814
1526
  */
1815
- controlWebsocketEvent?: ControlWebsocketEvent | undefined;
1527
+ completeEvent?: VoiceCompleteEvent | undefined;
1816
1528
  /**
1817
- * 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.
1818
1530
  * @public
1819
1531
  */
1820
- sessionStartedWebsocketEvent?: SessionStartedWebsocketEvent | undefined;
1532
+ sessionStartedEvent?: VoiceSessionStartedEvent | undefined;
1821
1533
  /**
1822
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1534
+ * The session ended. This is the last event of the session.
1823
1535
  * @public
1824
1536
  */
1825
- sessionEndedWebsocketEvent?: SessionEndedWebsocketEvent | undefined;
1537
+ sessionEndedEvent?: VoiceSessionEndedEvent | undefined;
1826
1538
  /**
1827
- * Envelope of a WebSocket event frame: `\{ "type": "event", "event": \{ ... \} \}`.
1539
+ * An error on the connection. The session continues, unless a `ended` event follows.
1828
1540
  * @public
1829
1541
  */
1830
- errorWebsocketEvent?: ErrorWebsocketEvent | undefined;
1542
+ errorEvent?: VoiceErrorEvent | undefined;
1831
1543
  /**
1832
- * 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.
1833
1545
  * @public
1834
1546
  */
1835
- sayWebsocketCommand?: SayWebsocketCommand | undefined;
1547
+ sayCommand?: VoiceSayCommandData | undefined;
1836
1548
  /**
1837
- * 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.
1838
1550
  * @public
1839
1551
  */
1840
- playWebsocketCommand?: PlayWebsocketCommand | undefined;
1552
+ playCommand?: VoicePlayCommandData | undefined;
1841
1553
  /**
1842
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1554
+ * Stop the audio of the agent.
1843
1555
  * @public
1844
1556
  */
1845
- stopWebsocketCommand?: StopWebsocketCommand | undefined;
1557
+ stopCommand?: VoiceStopCommandData | undefined;
1846
1558
  /**
1847
- * Envelope of a WebSocket command frame: `\{ "type": "command", "command": \{ ... \} \}`.
1559
+ * End the session and hang up the call.
1848
1560
  * @public
1849
1561
  */
1850
- hangupWebsocketCommand?: HangupWebsocketCommand | undefined;
1562
+ hangupCommand?: VoiceHangupCommandData | undefined;
1851
1563
  /**
1852
- * 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.
1853
1565
  * @public
1854
1566
  */
1855
- transferWebsocketCommand?: TransferWebsocketCommand | undefined;
1567
+ transferCommand?: VoiceTransferCommandData | undefined;
1856
1568
  /**
1857
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.
1858
1570
  * @public
1859
1571
  */
1860
1572
  callEvent?: VoiceCallEvent | undefined;
1861
1573
  /**
1862
- * 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.
1863
1575
  * @public
1864
1576
  */
1865
- media?: MediaProtocolFrames | undefined;
1577
+ callSocket?: VoiceCallProtocolFrames | undefined;
1866
1578
  }
1867
1579
  /**
1868
1580
  * @public
@@ -1926,13 +1638,17 @@ export interface ListVoicesOutput {
1926
1638
  voices: Voice[];
1927
1639
  }
1928
1640
  /**
1929
- * Terminate the session and hang up the call.
1641
+ * End the session and hang up the call.
1930
1642
  * @public
1931
1643
  */
1932
1644
  export interface SendHangupInput {
1645
+ /**
1646
+ * Why the session ended.
1647
+ * @public
1648
+ */
1933
1649
  reason?: string | undefined;
1934
1650
  /**
1935
- * 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.
1936
1652
  * @public
1937
1653
  */
1938
1654
  sessionId: string;
@@ -1943,23 +1659,15 @@ export interface SendHangupInput {
1943
1659
  export interface SendHangupOutput {
1944
1660
  }
1945
1661
  /**
1946
- * 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.
1947
1663
  * @public
1948
1664
  */
1949
1665
  export interface SendPlayInput {
1950
- /**
1951
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
1952
- * @public
1953
- */
1954
1666
  replyId: string;
1955
- /**
1956
- * Identifies one synthesized audio stream within a session; carried by a `say` command and the `play` frames that render it.
1957
- * @public
1958
- */
1959
1667
  streamId: string;
1960
1668
  data: string;
1961
1669
  /**
1962
- * 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.
1963
1671
  * @public
1964
1672
  */
1965
1673
  sessionId: string;
@@ -1970,40 +1678,32 @@ export interface SendPlayInput {
1970
1678
  export interface SendPlayOutput {
1971
1679
  }
1972
1680
  /**
1973
- * 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.
1974
1682
  * @public
1975
1683
  */
1976
1684
  export interface SendSayInput {
1977
- text: string;
1978
1685
  /**
1979
- * Correlates a caller phrase, the agent reply it produced, and the playback/interruption of that reply.
1686
+ * Text of the reply.
1980
1687
  * @public
1981
1688
  */
1982
- replyId: string;
1689
+ text: string;
1983
1690
  /**
1984
- * Whether the caller may barge in over this reply.
1691
+ * Id of the reply.
1985
1692
  * @public
1986
1693
  */
1987
- interruptible?: boolean | undefined;
1694
+ replyId: string;
1988
1695
  /**
1989
- * Bare Amazon Polly voice id, e.g. 'Joanna' — NOT a URI. The PBX consumes this verbatim as the
1990
- * AMI `Voice=` action parameter, so it takes exactly what Polly names the voice, with the
1991
- * `amazon_polly://` scheme and any query parameters already stripped by whoever builds this
1992
- * command out of the agent's stored `VoiceUri`.
1993
- *
1994
- * Set only for a provider whose synthesis runs ON THE PBX (Amazon Polly); ElevenLabs and Google
1995
- * are synthesized in the cloud and streamed as PCM through `play` instead, and leave this
1996
- * absent.
1696
+ * True when the caller can interrupt the reply.
1997
1697
  * @public
1998
1698
  */
1999
- voice?: string | undefined;
1699
+ interruptible?: boolean | undefined;
2000
1700
  /**
2001
- * 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.
2002
1702
  * @public
2003
1703
  */
2004
- audio?: SayCommandAudioOptions | undefined;
1704
+ audio?: VoiceSayCommandAudioOptions | undefined;
2005
1705
  /**
2006
- * 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.
2007
1707
  * @public
2008
1708
  */
2009
1709
  sessionId: string;
@@ -2018,7 +1718,7 @@ export interface SendSayOutput {
2018
1718
  */
2019
1719
  export interface SendStopInput {
2020
1720
  /**
2021
- * 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.
2022
1722
  * @public
2023
1723
  */
2024
1724
  sessionId: string;
@@ -2029,14 +1729,22 @@ export interface SendStopInput {
2029
1729
  export interface SendStopOutput {
2030
1730
  }
2031
1731
  /**
2032
- * 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.
2033
1733
  * @public
2034
1734
  */
2035
1735
  export interface SendTransferInput {
1736
+ /**
1737
+ * Dialplan context of the destination.
1738
+ * @public
1739
+ */
2036
1740
  context: string;
1741
+ /**
1742
+ * Extension of the destination.
1743
+ * @public
1744
+ */
2037
1745
  extension: string;
2038
1746
  /**
2039
- * 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.
2040
1748
  * @public
2041
1749
  */
2042
1750
  sessionId: string;