@superpanel-sdk/runtime 0.0.1-internal.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +35 -0
  2. package/bin/superpanel-sdk-runtime.mjs +22 -0
  3. package/dist/builder/codegen/emit.d.ts +17 -0
  4. package/dist/builder/codegen/emit.js +143 -0
  5. package/dist/builder/codegen/generate.d.ts +21 -0
  6. package/dist/builder/codegen/generate.js +90 -0
  7. package/dist/builder/compile/compile-agenda.d.ts +15 -0
  8. package/dist/builder/compile/compile-agenda.js +59 -0
  9. package/dist/builder/compile/compile-sequence.d.ts +24 -0
  10. package/dist/builder/compile/compile-sequence.js +121 -0
  11. package/dist/builder/compile/function-code.d.ts +6 -0
  12. package/dist/builder/compile/function-code.js +30 -0
  13. package/dist/builder/compile/registry.d.ts +13 -0
  14. package/dist/builder/compile/registry.js +42 -0
  15. package/dist/builder/load.d.ts +22 -0
  16. package/dist/builder/load.js +169 -0
  17. package/dist/builder/merge.d.ts +4 -0
  18. package/dist/builder/merge.js +19 -0
  19. package/dist/builder/paths.d.ts +10 -0
  20. package/dist/builder/paths.js +22 -0
  21. package/dist/builder/types.d.ts +31 -0
  22. package/dist/builder/types.js +2 -0
  23. package/dist/cli/compile/index.d.ts +4 -0
  24. package/dist/cli/compile/index.js +11 -0
  25. package/dist/cli/index.d.ts +3 -0
  26. package/dist/cli/index.js +64 -0
  27. package/dist/cli/serve/index.d.ts +9 -0
  28. package/dist/cli/serve/index.js +340 -0
  29. package/dist/cli/type-gen/index.d.ts +5 -0
  30. package/dist/cli/type-gen/index.js +90 -0
  31. package/dist/compute-host/compute-host.d.ts +38 -0
  32. package/dist/compute-host/compute-host.js +45 -0
  33. package/dist/compute-host/index.d.ts +5 -0
  34. package/dist/compute-host/index.js +3 -0
  35. package/dist/compute-host/source-compute-host.d.ts +29 -0
  36. package/dist/compute-host/source-compute-host.js +72 -0
  37. package/dist/core/context/account-fields.d.ts +12 -0
  38. package/dist/core/context/account-fields.js +2 -0
  39. package/dist/core/context/contact.d.ts +60 -0
  40. package/dist/core/context/contact.js +34 -0
  41. package/dist/core/context/db.d.ts +69 -0
  42. package/dist/core/context/db.js +44 -0
  43. package/dist/core/context/docusign.d.ts +134 -0
  44. package/dist/core/context/docusign.js +108 -0
  45. package/dist/core/context/env.d.ts +9 -0
  46. package/dist/core/context/env.js +19 -0
  47. package/dist/core/context/filevine.d.ts +323 -0
  48. package/dist/core/context/filevine.js +254 -0
  49. package/dist/core/context/http.d.ts +9 -0
  50. package/dist/core/context/http.js +4 -0
  51. package/dist/core/context/hubspot.d.ts +250 -0
  52. package/dist/core/context/hubspot.js +191 -0
  53. package/dist/core/context/platform-registry.d.ts +67 -0
  54. package/dist/core/context/platform-registry.js +11 -0
  55. package/dist/core/context/platform.d.ts +33 -0
  56. package/dist/core/context/platform.js +2 -0
  57. package/dist/core/context/twilio.d.ts +50 -0
  58. package/dist/core/context/twilio.js +42 -0
  59. package/dist/core/context/types.d.ts +87 -0
  60. package/dist/core/context/types.js +9 -0
  61. package/dist/core/functions/define/case-context.d.ts +14 -0
  62. package/dist/core/functions/define/case-context.js +15 -0
  63. package/dist/core/functions/define/compute.d.ts +7 -0
  64. package/dist/core/functions/define/compute.js +17 -0
  65. package/dist/core/functions/define/custom.d.ts +4 -0
  66. package/dist/core/functions/define/custom.js +8 -0
  67. package/dist/core/functions/define/system.d.ts +7 -0
  68. package/dist/core/functions/define/system.js +12 -0
  69. package/dist/core/functions/func-ref.d.ts +16 -0
  70. package/dist/core/functions/func-ref.js +20 -0
  71. package/dist/core/functions/types.d.ts +78 -0
  72. package/dist/core/functions/types.js +5 -0
  73. package/dist/core/slot/compile-schema.d.ts +24 -0
  74. package/dist/core/slot/compile-schema.js +336 -0
  75. package/dist/core/slot/deps.d.ts +15 -0
  76. package/dist/core/slot/deps.js +88 -0
  77. package/dist/core/slot/derived.d.ts +32 -0
  78. package/dist/core/slot/derived.js +115 -0
  79. package/dist/core/slot/field.d.ts +36 -0
  80. package/dist/core/slot/field.js +97 -0
  81. package/dist/core/slot/id-ref.d.ts +4 -0
  82. package/dist/core/slot/id-ref.js +15 -0
  83. package/dist/core/slot/index.d.ts +15 -0
  84. package/dist/core/slot/index.js +14 -0
  85. package/dist/core/slot/path.d.ts +18 -0
  86. package/dist/core/slot/path.js +22 -0
  87. package/dist/core/slot/row.d.ts +22 -0
  88. package/dist/core/slot/row.js +54 -0
  89. package/dist/core/slot/schema.d.ts +102 -0
  90. package/dist/core/slot/schema.js +17 -0
  91. package/dist/core/slot/sf-schema.d.ts +23 -0
  92. package/dist/core/slot/sf-schema.js +125 -0
  93. package/dist/core/slot/sf-validate.d.ts +14 -0
  94. package/dist/core/slot/sf-validate.js +132 -0
  95. package/dist/core/slot/snapshot.d.ts +18 -0
  96. package/dist/core/slot/snapshot.js +138 -0
  97. package/dist/core/slot/types.d.ts +144 -0
  98. package/dist/core/slot/types.js +2 -0
  99. package/dist/core/slot/value.d.ts +9 -0
  100. package/dist/core/slot/value.js +97 -0
  101. package/dist/core/slot/write.d.ts +41 -0
  102. package/dist/core/slot/write.js +319 -0
  103. package/dist/core/stage/builders.d.ts +36 -0
  104. package/dist/core/stage/builders.js +28 -0
  105. package/dist/core/stage/condition.d.ts +17 -0
  106. package/dist/core/stage/condition.js +198 -0
  107. package/dist/core/stage/drive.d.ts +43 -0
  108. package/dist/core/stage/drive.js +77 -0
  109. package/dist/core/stage/finish-when.d.ts +20 -0
  110. package/dist/core/stage/finish-when.js +82 -0
  111. package/dist/core/stage/flatten.d.ts +27 -0
  112. package/dist/core/stage/flatten.js +464 -0
  113. package/dist/core/stage/index.d.ts +11 -0
  114. package/dist/core/stage/index.js +10 -0
  115. package/dist/core/stage/simulate.d.ts +24 -0
  116. package/dist/core/stage/simulate.js +33 -0
  117. package/dist/core/stage/transfer-fields.d.ts +14 -0
  118. package/dist/core/stage/transfer-fields.js +88 -0
  119. package/dist/core/stage/types.d.ts +177 -0
  120. package/dist/core/stage/types.js +2 -0
  121. package/dist/core/stage/validate.d.ts +11 -0
  122. package/dist/core/stage/validate.js +226 -0
  123. package/dist/core/stage/walk.d.ts +34 -0
  124. package/dist/core/stage/walk.js +96 -0
  125. package/dist/dev-overlay/protocol.d.ts +53 -0
  126. package/dist/dev-overlay/protocol.js +21 -0
  127. package/dist/fn-context/build-context.d.ts +11 -0
  128. package/dist/fn-context/build-context.js +21 -0
  129. package/dist/fn-context/fake/empty-api.d.ts +9 -0
  130. package/dist/fn-context/fake/empty-api.js +50 -0
  131. package/dist/fn-context/fake/index.d.ts +12 -0
  132. package/dist/fn-context/fake/index.js +22 -0
  133. package/dist/fn-context/index.d.ts +9 -0
  134. package/dist/fn-context/index.js +8 -0
  135. package/dist/fn-context/log.d.ts +8 -0
  136. package/dist/fn-context/log.js +29 -0
  137. package/dist/fn-context/make-ctx.d.ts +9 -0
  138. package/dist/fn-context/make-ctx.js +51 -0
  139. package/dist/fn-context/rpc/errors.d.ts +25 -0
  140. package/dist/fn-context/rpc/errors.js +23 -0
  141. package/dist/fn-context/rpc/index.d.ts +10 -0
  142. package/dist/fn-context/rpc/index.js +9 -0
  143. package/dist/fn-context/rpc/integration/index.d.ts +51 -0
  144. package/dist/fn-context/rpc/integration/index.js +19 -0
  145. package/dist/fn-context/rpc/integration/list-bindings.d.ts +21 -0
  146. package/dist/fn-context/rpc/integration/list-bindings.js +18 -0
  147. package/dist/fn-context/rpc/log.d.ts +36 -0
  148. package/dist/fn-context/rpc/log.js +16 -0
  149. package/dist/fn-context/rpc/platform.d.ts +28 -0
  150. package/dist/fn-context/rpc/platform.js +15 -0
  151. package/dist/fn-context/rpc/request-id.d.ts +5 -0
  152. package/dist/fn-context/rpc/request-id.js +13 -0
  153. package/dist/fn-context/rpc/trpc-client.d.ts +7 -0
  154. package/dist/fn-context/rpc/trpc-client.js +109 -0
  155. package/dist/fn-context/rpc/trpc-init.d.ts +17 -0
  156. package/dist/fn-context/rpc/trpc-init.js +17 -0
  157. package/dist/fn-context/rpc/trpc-router-factory.d.ts +84 -0
  158. package/dist/fn-context/rpc/trpc-router-factory.js +9 -0
  159. package/dist/fn-context/types.d.ts +17 -0
  160. package/dist/fn-context/types.js +2 -0
  161. package/dist/index.d.ts +47 -0
  162. package/dist/index.js +34 -0
  163. package/dist/voice-service/actions.d.ts +20 -0
  164. package/dist/voice-service/actions.js +2 -0
  165. package/dist/voice-service/index.d.ts +3 -0
  166. package/dist/voice-service/index.js +3 -0
  167. package/dist/voice-service/types.d.ts +1010 -0
  168. package/dist/voice-service/types.js +16 -0
  169. package/package.json +55 -0
@@ -0,0 +1,1010 @@
1
+ export interface IMessage {
2
+ role: IRole;
3
+ content: string;
4
+ }
5
+ export type STTProvider = 'deepgram-flux' | 'deepgram' | 'aws-transcribe' | 'elevenlabs-stt';
6
+ export type TTSProvider = 'cartesia' | 'elevenlabs' | 'elevenlabs-http' | 'inworld' | 'fish';
7
+ export interface DeepgramFluxSttConfig {
8
+ apiKey: string;
9
+ /**
10
+ * - `flux-general-en`: English-only model.
11
+ * - `flux-general-multi`: Multilingual model. Required when using `languageHints`.
12
+ */
13
+ model: 'flux-general-en' | 'flux-general-multi';
14
+ encoding?: 'linear16' | 'linear32' | 'mulaw' | 'alaw' | 'opus' | 'ogg-opus';
15
+ sampleRate?: number;
16
+ eagerEotThreshold?: number;
17
+ eotThreshold?: number;
18
+ eotTimeoutMs?: number;
19
+ keyterms?: string[];
20
+ mipOptOut?: boolean;
21
+ tag?: string;
22
+ /**
23
+ * BCP-47 language codes biasing the multilingual model toward specific languages.
24
+ *
25
+ * Only valid with `model: 'flux-general-multi'` — sending hints with `flux-general-en`
26
+ * returns HTTP 400 from Deepgram.
27
+ *
28
+ * Behavior:
29
+ * - Omit / empty: auto-detect (model picks language per turn).
30
+ * - Single code: locks to that language (accuracy on par with a dedicated monolingual model).
31
+ * - Multiple codes: biases toward this candidate set (best for known multi-language calls).
32
+ *
33
+ * Supported languages (10):
34
+ * en (English), es (Spanish), fr (French), de (German), hi (Hindi),
35
+ * ru (Russian), pt (Portuguese), ja (Japanese), it (Italian), nl (Dutch).
36
+ *
37
+ * Locale subtags like `en-GB` or `pt-BR` are accepted and fall back to the base code.
38
+ */
39
+ languageHints?: string[];
40
+ reconnectAttempts?: number;
41
+ reconnectDelay?: number;
42
+ minBufferDurationMs?: number;
43
+ }
44
+ export interface DeepgramApiConfig {
45
+ model?: 'nova-3' | 'nova-3-general' | 'nova-3-medical' | 'nova-2' | 'nova-2-general' | 'nova-2-automotive' | 'nova' | 'nova-general' | 'nova-phonecall' | 'nova-medical' | 'enhanced' | 'enhanced-general' | 'enhanced-meeting' | 'enhanced-phonecall' | 'enhanced-finance' | 'base' | 'meeting' | 'phonecall' | 'finance' | 'conversationalai' | 'voicemail' | 'video' | 'custom';
46
+ encoding?: 'linear16' | 'linear32' | 'flac' | 'alaw' | 'mulaw' | 'amr-nb' | 'amr-wb' | 'opus' | 'ogg-opus' | 'speex' | 'g729';
47
+ sample_rate?: any;
48
+ channels?: any;
49
+ language?: any;
50
+ version?: any;
51
+ interim_results?: 'true' | 'false';
52
+ punctuate?: 'true' | 'false';
53
+ profanity_filter?: 'true' | 'false';
54
+ redact?: 'true' | 'false' | 'pci' | 'numbers' | 'aggressive_numbers' | 'ssn';
55
+ diarize?: 'true' | 'false';
56
+ multichannel?: 'true' | 'false';
57
+ smart_format?: 'true' | 'false';
58
+ numerals?: 'true' | 'false';
59
+ dictation?: 'true' | 'false';
60
+ utterance_end_ms?: any;
61
+ vad_events?: 'true' | 'false';
62
+ endpointing?: any;
63
+ keywords?: any;
64
+ keyterm?: any;
65
+ search?: any;
66
+ replace?: any;
67
+ callback?: any;
68
+ callback_method?: 'POST' | 'GET' | 'PUT' | 'DELETE';
69
+ tag?: any;
70
+ extra?: any;
71
+ mip_opt_out?: any;
72
+ }
73
+ export interface DeepgramSttConfig extends DeepgramApiConfig {
74
+ reconnectAttempts?: number;
75
+ reconnectDelay?: number;
76
+ apiKey: string;
77
+ }
78
+ export interface AwsTranscribeSttConfig {
79
+ region: string;
80
+ accessKeyId?: string;
81
+ secretAccessKey?: string;
82
+ languageCode?: 'en-US' | 'en-GB' | 'en-AU' | 'es-US' | 'es-ES' | 'fr-FR' | 'fr-CA' | 'de-DE' | 'it-IT' | 'ja-JP' | 'ko-KR' | 'pt-BR' | 'zh-CN' | 'th-TH' | 'ar-SA' | 'pt-PT' | 'ca-ES' | 'ar-AE' | 'hi-IN' | 'zh-HK' | 'nl-NL' | 'no-NO' | 'sv-SE' | 'pl-PL' | 'fi-FI' | 'zh-TW' | 'en-IN' | 'en-IE' | 'en-NZ' | 'en-AB' | 'en-ZA' | 'en-WL' | 'de-CH' | 'af-ZA' | 'eu-ES' | 'hr-HR' | 'cs-CZ' | 'da-DK' | 'fa-IR' | 'gl-ES' | 'el-GR' | 'he-IL' | 'id-ID' | 'lv-LV' | 'ms-MY' | 'ro-RO' | 'ru-RU' | 'sr-RS' | 'sk-SK' | 'so-SO' | 'tl-PH' | 'uk-UA' | 'vi-VN' | 'zu-ZA';
83
+ mediaSampleRateHertz?: number;
84
+ vocabularyName?: string;
85
+ vocabularyNames?: string;
86
+ vocabularyFilterName?: string;
87
+ vocabularyFilterNames?: string;
88
+ vocabularyFilterMethod?: 'remove' | 'mask' | 'tag';
89
+ showSpeakerLabel?: boolean;
90
+ enableChannelIdentification?: boolean;
91
+ numberOfChannels?: number;
92
+ enablePartialResultsStabilization?: boolean;
93
+ partialResultsStability?: 'high' | 'medium' | 'low';
94
+ sessionId?: string;
95
+ languageModelName?: string;
96
+ identifyLanguage?: boolean;
97
+ identifyMultipleLanguages?: boolean;
98
+ languageOptions?: string;
99
+ preferredLanguage?: string;
100
+ contentIdentificationType?: 'PII';
101
+ contentRedactionType?: 'PII';
102
+ piiEntityTypes?: string;
103
+ reconnectAttempts?: number;
104
+ reconnectDelay?: number;
105
+ }
106
+ export type ElevenLabsSttAudioFormat = 'pcm_8000' | 'pcm_16000' | 'pcm_22050' | 'pcm_24000' | 'pcm_44100' | 'pcm_48000' | 'ulaw_8000';
107
+ export type ElevenLabsSttCommitStrategy = 'manual' | 'vad';
108
+ export interface ElevenLabsSttConfig {
109
+ apiKey: string;
110
+ modelId?: string;
111
+ audioFormat?: ElevenLabsSttAudioFormat;
112
+ languageCode?: string;
113
+ commitStrategy?: ElevenLabsSttCommitStrategy;
114
+ vadSilenceThresholdSecs?: number;
115
+ vadThreshold?: number;
116
+ minSpeechDurationMs?: number;
117
+ minSilenceDurationMs?: number;
118
+ enableLogging?: boolean;
119
+ includeTimestamps?: boolean;
120
+ includeLanguageDetection?: boolean;
121
+ reconnectAttempts?: number;
122
+ reconnectDelay?: number;
123
+ }
124
+ export interface GoogleLLMConfig {
125
+ model?: 'gemini-2.5-flash' | 'gemini-2.5-flash-lite';
126
+ maxTokens?: number;
127
+ temperature?: number;
128
+ systemPrompt?: string;
129
+ }
130
+ export interface CartesiaTTSConfig {
131
+ apiKey: string;
132
+ cartesiaVersion: '2024-06-10' | '2024-11-13' | '2025-04-16';
133
+ reconnectAttempts: number;
134
+ reconnectDelay: number;
135
+ model_id: string;
136
+ voice: {
137
+ mode: string;
138
+ id: string;
139
+ };
140
+ generation_config?: {
141
+ volume?: number;
142
+ speed?: number;
143
+ emotion?: string;
144
+ };
145
+ output_format: {
146
+ container: 'raw' | 'wav' | 'mp3' | 'flac';
147
+ encoding: 'pcm_s16le' | 'pcm_f32le' | 'pcm_mulaw' | 'pcm_alaw';
148
+ sample_rate: number;
149
+ };
150
+ language?: string;
151
+ max_buffer_delay_ms?: number;
152
+ add_timestamps?: boolean;
153
+ add_phoneme_timestamps?: boolean;
154
+ use_normalized_timestamps?: boolean;
155
+ pronunciation_dict_id?: string;
156
+ emotion?: string;
157
+ }
158
+ export interface ElevenLabsHttpTTSConfig {
159
+ apiKey: string;
160
+ voice_id: string;
161
+ /**
162
+ * When false, request runs in zero-retention mode (no history features).
163
+ * Enterprise-only when set to false. Defaults to ElevenLabs default (true).
164
+ */
165
+ enable_logging?: boolean;
166
+ /**
167
+ * 0 = default mode (no latency optimizations)
168
+ * 1 = normal latency optimizations
169
+ * 2 = strong latency optimizations
170
+ * 3 = max latency optimizations
171
+ * 4 = max latency optimizations + text normalizer disabled
172
+ */
173
+ optimize_streaming_latency?: 0 | 1 | 2 | 3 | 4;
174
+ /**
175
+ * Output audio container/codec/sample_rate/bitrate.
176
+ * Defaults to mp3_44100_128 on the server side.
177
+ */
178
+ output_format?: 'mp3_22050_32' | 'mp3_24000_48' | 'mp3_44100_32' | 'mp3_44100_64' | 'mp3_44100_96' | 'mp3_44100_128' | 'mp3_44100_192' | 'pcm_8000' | 'pcm_16000' | 'pcm_22050' | 'pcm_24000' | 'pcm_32000' | 'pcm_44100' | 'pcm_48000' | 'ulaw_8000' | 'alaw_8000' | 'opus_48000_32' | 'opus_48000_64' | 'opus_48000_96' | 'opus_48000_128' | 'opus_48000_192';
179
+ /** Defaults to 'eleven_multilingual_v2' on the server side. */
180
+ model_id?: string;
181
+ /** ISO 639-1 language code; errors if the model does not support it. */
182
+ language_code?: string;
183
+ voice_settings?: {
184
+ /** [0,1] - lower = more emotional range, higher = more monotonous (default 0.5) */
185
+ stability?: number;
186
+ /** [0,1] - how closely to adhere to the original voice (default 0.75) */
187
+ similarity_boost?: number;
188
+ /** [0,1] - style exaggeration; non-zero adds latency (default 0) */
189
+ style?: number;
190
+ /** Slightly higher latency when true (default true) */
191
+ use_speaker_boost?: boolean;
192
+ /** Speech speed multiplier (default 1) */
193
+ speed?: number;
194
+ };
195
+ pronunciation_dictionary_locators?: Array<{
196
+ pronunciation_dictionary_id: string;
197
+ version_id: string;
198
+ }>;
199
+ /** Best-effort deterministic sampling. Integer in [0, 4294967295]. */
200
+ seed?: number;
201
+ /** Improves continuity when concatenating with prior generation. */
202
+ previous_text?: string;
203
+ /** Improves continuity when concatenating with next generation. */
204
+ next_text?: string;
205
+ /** Up to 3 previous request_ids. Takes precedence over `previous_text`. */
206
+ previous_request_ids?: string[];
207
+ /** Up to 3 next request_ids. Takes precedence over `next_text`. */
208
+ next_request_ids?: string[];
209
+ /** Force IVC voice instead of PVC version (default false). */
210
+ use_pvc_as_ivc?: boolean;
211
+ /** Text normalization mode (default 'auto'). */
212
+ apply_text_normalization?: 'auto' | 'on' | 'off';
213
+ /**
214
+ * Language-specific text normalization (e.g. Japanese).
215
+ * Heavy latency cost. Default false.
216
+ */
217
+ apply_language_text_normalization?: boolean;
218
+ /**
219
+ * HTTP request timeout in milliseconds. 0 / undefined disables it.
220
+ */
221
+ requestTimeoutMs?: number;
222
+ }
223
+ export interface ElevenLabsTTSConfig {
224
+ apiKey: string;
225
+ reconnectAttempts: number;
226
+ reconnectDelay: number;
227
+ voice_id: string;
228
+ model_id?: string;
229
+ voice_settings?: {
230
+ stability?: number;
231
+ similarity_boost?: number;
232
+ style?: number;
233
+ use_speaker_boost?: boolean;
234
+ speed?: number;
235
+ };
236
+ generation_config?: {
237
+ chunk_length_schedule?: number[];
238
+ };
239
+ pronunciation_dictionary_locators?: Array<{
240
+ pronunciation_dictionary_id: string;
241
+ version_id: string;
242
+ }>;
243
+ language_code?: string;
244
+ output_format?: 'mp3_22050_32' | 'mp3_44100_32' | 'mp3_44100_64' | 'mp3_44100_96' | 'mp3_44100_128' | 'mp3_44100_192' | 'pcm_8000' | 'pcm_16000' | 'pcm_22050' | 'pcm_24000' | 'pcm_44100' | 'ulaw_8000' | 'alaw_8000' | 'opus_48000_32' | 'opus_48000_64' | 'opus_48000_96' | 'opus_48000_128' | 'opus_48000_192';
245
+ enable_logging?: boolean;
246
+ enable_ssml_parsing?: boolean;
247
+ optimize_streaming_latency?: number;
248
+ apply_text_normalization?: 'auto' | 'on' | 'off';
249
+ sync_alignment?: boolean;
250
+ auto_mode?: boolean;
251
+ inactivity_timeout?: number;
252
+ seed?: number;
253
+ }
254
+ export interface InworldTTSConfig {
255
+ apiKey: string;
256
+ voiceId: string;
257
+ modelId: string;
258
+ reconnectAttempts?: number;
259
+ reconnectDelay?: number;
260
+ audioConfig?: {
261
+ audioEncoding?: 'LINEAR16' | 'MP3' | 'OGG_OPUS' | 'ALAW' | 'MULAW';
262
+ sampleRateHertz?: number;
263
+ bitRate?: number;
264
+ speakingRate?: number;
265
+ };
266
+ temperature?: number;
267
+ bufferCharThreshold?: number;
268
+ maxBufferDelayMs?: number;
269
+ autoMode?: boolean;
270
+ applyTextNormalization?: 'APPLY_TEXT_NORMALIZATION_UNSPECIFIED' | 'ON' | 'OFF';
271
+ timestampType?: 'TIMESTAMP_TYPE_UNSPECIFIED' | 'WORD' | 'CHARACTER';
272
+ timestampTransportStrategy?: 'TIMESTAMP_TRANSPORT_STRATEGY_UNSPECIFIED' | 'SYNC' | 'ASYNC';
273
+ }
274
+ export interface FishTTSConfig {
275
+ apiKey: string;
276
+ model: 's1' | 's2-pro';
277
+ format: 'pcm';
278
+ sample_rate: 8000;
279
+ latency: 'low' | 'normal' | 'balanced';
280
+ reference_id?: string | string[] | null;
281
+ references?: unknown;
282
+ prosody?: {
283
+ speed?: number;
284
+ volume?: number;
285
+ normalize_loudness?: boolean;
286
+ } | null;
287
+ temperature?: number;
288
+ top_p?: number;
289
+ max_new_tokens?: number;
290
+ repetition_penalty?: number;
291
+ min_chunk_length?: number;
292
+ chunk_length?: number;
293
+ condition_on_previous_chunks?: boolean;
294
+ normalize?: boolean;
295
+ early_stop_threshold?: number;
296
+ mp3_bitrate?: 64 | 128 | 192;
297
+ opus_bitrate?: -1000 | 24 | 32 | 48 | 64;
298
+ }
299
+ export interface AssistantConfig {
300
+ minNumberOfWordsToInterrupt: number;
301
+ interruptProtectionMs: number;
302
+ endSpeakTimeoutMs: number;
303
+ sttProvider: STTProvider;
304
+ ttsProvider: TTSProvider;
305
+ goodbyePatterns: string[];
306
+ defaultTransferingMessage: string;
307
+ defaultTransferFailedMessage: string;
308
+ shuttingDownMessage: string;
309
+ warmTransferPrompt: string;
310
+ endOfTurnPrompt: string;
311
+ endOfTurnLlmEnable: boolean;
312
+ llmFastResponseEnable: boolean;
313
+ outboundCallFirstSayDelayMs: number;
314
+ }
315
+ export interface VoiceMailConfig {
316
+ ignoreInFirstTimeMs: number;
317
+ maxRegexAnalysisRounds: number;
318
+ regexPatterns: string[];
319
+ reply?: string;
320
+ voiceMailSpeakTimeoutMs: number;
321
+ voiceMailAutoHangupDelayMs: number;
322
+ voiceMailPrompt?: string;
323
+ }
324
+ export interface UserSilenceConfig {
325
+ silenceTimeoutMs: number[];
326
+ maxSilenceCount: number;
327
+ responseMessages: string[];
328
+ sendSilenceSignalInMs: number;
329
+ silenceSignalResponseTimeoutMs: number;
330
+ maxContinueSilenceSignalCount: number;
331
+ }
332
+ export interface ConversationConfig {
333
+ enabled?: boolean;
334
+ autoSave?: boolean;
335
+ }
336
+ export interface SoundEffectConfig {
337
+ enabled: boolean;
338
+ volume: number;
339
+ }
340
+ export interface SoundConfig {
341
+ mainBackground: SoundEffectConfig;
342
+ mainBackgroundMusicURL?: string;
343
+ thinkSound: SoundEffectConfig;
344
+ }
345
+ export interface AudioStreamConfig {
346
+ pushIntervalMs?: number;
347
+ }
348
+ export type TransferType = 'cold' | 'warm' | 'async-warm';
349
+ export type FallbackAction = 'end-call' | 'restore-normal-call-state';
350
+ export interface AsyncWarmTransferBridgeConfig {
351
+ targetSayTemplate?: string;
352
+ customerSayTemplate?: string;
353
+ }
354
+ export interface LoopConfirmConfig {
355
+ confirmTimeoutMs: number;
356
+ pauseAfterSayMs: number;
357
+ loopSayText: string;
358
+ fallbackAction: FallbackAction;
359
+ }
360
+ export interface TransferConfig extends LoopConfirmConfig {
361
+ confirmLlmPrompt: string;
362
+ withoutBriefing: boolean;
363
+ warmTransferWaitingMusicURL?: string;
364
+ warmTransferWaitingMusicVolume?: number;
365
+ }
366
+ export interface FieldCollectConfig extends LoopConfirmConfig {
367
+ enterModeSayText: string | null;
368
+ succeedSayText: string | null;
369
+ unsuccessSayText: string | null;
370
+ validateDigits: DtmfDigit[];
371
+ digitsValueMap: Record<string, string>;
372
+ }
373
+ export interface WarmTransferSession {
374
+ conferenceName: string;
375
+ customerCallSid: string;
376
+ newCallSid: string;
377
+ briefing: string;
378
+ loopSayText: string;
379
+ confirmLlmPrompt: string;
380
+ newCallStatus: 'calling' | 'connected' | 'bridging' | 'in-conference' | 'failed';
381
+ failedMessage: string;
382
+ transferType?: TransferType;
383
+ fallbackAction?: FallbackAction;
384
+ requestor?: Requestor;
385
+ targetBridgeSay?: string;
386
+ customerBridgeSay?: string;
387
+ targetCompleted?: boolean;
388
+ customerCompleted?: boolean;
389
+ confirmTimeoutMs: number;
390
+ pauseAfterSayMs: number;
391
+ createdAt: number;
392
+ confirmMode: WarmTransferConfirmMethod[];
393
+ confirmKeypad: DtmfDigit;
394
+ }
395
+ /**
396
+ * - `connected` target outbound leg has been answered
397
+ * - `confirmed` rep ack'd via DTMF or LLM (still before any briefing/bridge say)
398
+ * - `target-completed` target side finished its briefing / targetBridgeSay
399
+ * - `customer-completed` customer side finished its customerBridgeSay
400
+ * - `failed` any failure: confirm timeout, target hangup, customer-bridge error, or conference join error
401
+ */
402
+ export type WarmTransferStatus = 'connected' | 'confirmed' | 'target-completed' | 'customer-completed' | 'failed';
403
+ export type WarmTransferStatusMessage = {
404
+ newCallSid: string;
405
+ status: WarmTransferStatus;
406
+ reason?: CallEndReason;
407
+ };
408
+ export interface TTSCacheConfig {
409
+ enabled: boolean;
410
+ cacheExpireMs?: number;
411
+ }
412
+ export interface AntiBotMonitorConfig {
413
+ enabled: boolean;
414
+ startDelayMs: number;
415
+ checkIntervalMs: number;
416
+ maxBotCount: number;
417
+ maxRunCount: number;
418
+ prompt: string;
419
+ }
420
+ export interface VoiceAssistantConfig {
421
+ deepgramFluxStt?: DeepgramFluxSttConfig;
422
+ deepgramStt?: DeepgramSttConfig;
423
+ awsTranscribeStt?: AwsTranscribeSttConfig;
424
+ elevenlabsStt?: ElevenLabsSttConfig;
425
+ cartesia?: CartesiaTTSConfig;
426
+ elevenlabs?: ElevenLabsTTSConfig;
427
+ elevenlabsHttp?: ElevenLabsHttpTTSConfig;
428
+ inworld?: InworldTTSConfig;
429
+ fish?: FishTTSConfig;
430
+ llm: GoogleLLMConfig;
431
+ antiBotMonitor: AntiBotMonitorConfig;
432
+ voiceMail: VoiceMailConfig;
433
+ userSilence: UserSilenceConfig;
434
+ conversation: ConversationConfig;
435
+ sound: SoundConfig;
436
+ audioStream: AudioStreamConfig;
437
+ transfer: TransferConfig;
438
+ ttsCache: TTSCacheConfig;
439
+ assistant: AssistantConfig;
440
+ /** Per-app baseline for OpenAI Realtime sessions. Per-call `configOverride` shallow-merges on top. */
441
+ openaiRealtime: OpenAIRealtimeConfig;
442
+ twilio: {
443
+ accountSid: string;
444
+ authToken: string;
445
+ };
446
+ language: string;
447
+ }
448
+ type DeepPartial<T> = {
449
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
450
+ };
451
+ export type OptionalVoiceAssistantConfig = Omit<DeepPartial<VoiceAssistantConfig>, 'deepgramStt' | 'cartesia' | 'elevenlabs' | 'elevenlabsHttp' | 'inworld' | 'fish' | 'deepgramFluxStt' | 'awsTranscribeStt' | 'elevenlabsStt' | 'openaiRealtime'> & {
452
+ deepgramFluxStt?: Partial<DeepgramFluxSttConfig>;
453
+ deepgramStt?: Partial<DeepgramSttConfig>;
454
+ awsTranscribeStt?: Partial<AwsTranscribeSttConfig>;
455
+ elevenlabsStt?: Partial<ElevenLabsSttConfig>;
456
+ cartesia?: Partial<CartesiaTTSConfig>;
457
+ elevenlabs?: Partial<ElevenLabsTTSConfig>;
458
+ elevenlabsHttp?: Partial<ElevenLabsHttpTTSConfig>;
459
+ inworld?: Partial<InworldTTSConfig>;
460
+ fish?: Partial<FishTTSConfig>;
461
+ openaiRealtime?: Partial<OpenAIRealtimeConfig>;
462
+ };
463
+ export type TwilioCredentials = VoiceAssistantConfig['twilio'];
464
+ export interface AppAction {
465
+ callSid: string;
466
+ }
467
+ export interface IncomingOutgoingCall extends AppAction {
468
+ fromNumber: string;
469
+ toNumber: string;
470
+ direction: 'inbound' | 'outbound';
471
+ serviceNumber: string;
472
+ appId: string;
473
+ startTs: Date;
474
+ status?: TwilioCallStatus;
475
+ }
476
+ export interface ChatWebsocketStartMessage extends IncomingOutgoingCall {
477
+ voiceServiceUrl: string;
478
+ }
479
+ export type CallFailedReason = any;
480
+ export type FirstAction = {
481
+ type: 'speak-first-say';
482
+ } | {
483
+ type: 'transfer';
484
+ req: TransferEvt;
485
+ } | {
486
+ type: 'field-collect';
487
+ req: FieldCollectRequest;
488
+ };
489
+ export type ApplicationConfig = {
490
+ firstSay: string;
491
+ succeed: boolean;
492
+ firstActions: FirstAction[];
493
+ language: string;
494
+ reason?: CallFailedReason;
495
+ cfg: VoiceAssistantConfig;
496
+ };
497
+ export type ApplicationConfigResponse = Omit<Partial<ApplicationConfig>, 'cfg'> & {
498
+ cfg?: OptionalVoiceAssistantConfig;
499
+ };
500
+ export type TwilioCallStatus = 'queued' | 'initiated' | 'ringing' | 'in-progress' | 'completed' | 'busy' | 'failed' | 'no-answer' | 'canceled';
501
+ export interface TwilioCallStatusCallback {
502
+ CallSid: string;
503
+ AccountSid: string;
504
+ From: string;
505
+ To: string;
506
+ CallStatus: TwilioCallStatus;
507
+ ApiVersion: string;
508
+ Direction: 'inbound' | 'outbound-api' | 'outbound-dial';
509
+ ForwardedFrom?: string;
510
+ CallerName?: string;
511
+ ParentCallSid?: string;
512
+ CallDuration?: string;
513
+ SipResponseCode?: string;
514
+ RecordingUrl?: string;
515
+ RecordingSid?: string;
516
+ RecordingDuration?: string;
517
+ Timestamp: string;
518
+ }
519
+ export interface TwilioAMDStatusCallback {
520
+ CallSid: string;
521
+ AccountSid: string;
522
+ AnsweredBy: 'human' | 'machine_start' | 'machine_end_beep' | 'machine_end_silence' | 'machine_end_other' | 'fax' | 'unknown';
523
+ MachineDetectionDuration?: string;
524
+ Confidence?: string;
525
+ }
526
+ export interface TwilioStartEvent {
527
+ event: 'start';
528
+ sequenceNumber: string;
529
+ start: {
530
+ accountSid: string;
531
+ streamSid: string;
532
+ callSid: string;
533
+ tracks: string[];
534
+ mediaFormat: {
535
+ encoding: string;
536
+ sampleRate: number;
537
+ channels: number;
538
+ };
539
+ customParameters: Record<string, string>;
540
+ };
541
+ streamSid: string;
542
+ }
543
+ export interface TwilioDialActionCallback {
544
+ CallSid: string;
545
+ AccountSid: string;
546
+ ApiVersion: string;
547
+ From: string;
548
+ To: string;
549
+ CallStatus: 'queued' | 'ringing' | 'in-progress' | 'completed' | 'busy' | 'failed' | 'no-answer' | 'canceled';
550
+ Direction: 'inbound' | 'outbound-api' | 'outbound-dial';
551
+ DialCallStatus?: 'queued' | 'ringing' | 'in-progress' | 'completed' | 'busy' | 'failed' | 'no-answer' | 'canceled';
552
+ DialCallSid?: string;
553
+ DialCallDuration?: string;
554
+ DialBridged?: string;
555
+ ParentCallSid?: string;
556
+ Called?: string;
557
+ CalledCountry?: string;
558
+ CalledState?: string;
559
+ CalledCity?: string;
560
+ CalledZip?: string;
561
+ CalledVia?: string;
562
+ Caller?: string;
563
+ CallerCountry?: string;
564
+ CallerState?: string;
565
+ CallerCity?: string;
566
+ CallerZip?: string;
567
+ ToState?: string;
568
+ ToCity?: string;
569
+ ToZip?: string;
570
+ ToCountry?: string;
571
+ FromCountry?: string;
572
+ FromState?: string;
573
+ FromCity?: string;
574
+ FromZip?: string;
575
+ ForwardedFrom?: string;
576
+ }
577
+ export interface TwilioRecordingStatusCallback {
578
+ CallSid: string;
579
+ RecordingSid: string;
580
+ RecordingUrl: string;
581
+ RecordingStatus: 'completed' | 'in-progress' | 'absent' | 'failed';
582
+ RecordingDuration?: string;
583
+ RecordingChannels?: string;
584
+ RecordingSource?: string;
585
+ AccountSid: string;
586
+ }
587
+ export type IRole = 'assistant' | 'user' | 'system';
588
+ export interface ChatItem {
589
+ timestamp: number;
590
+ content: string;
591
+ role: IRole;
592
+ type: 'chat' | 'transfer' | 'end-call' | 'silence-signal' | 'field-collect';
593
+ params?: {
594
+ silenceSignalId?: string;
595
+ };
596
+ }
597
+ export interface ChatItemWithCallSid extends AppAction {
598
+ item: ChatItem;
599
+ }
600
+ export interface AssistantFastRsp {
601
+ text: string;
602
+ }
603
+ export type AssistantLLMType = 'chat' | 'fast-response' | 'voice-mail' | 'anti-bot-detection' | 'transfer-briefing' | 'user-silence-llm-response';
604
+ export interface AssistantLLMStartReq {
605
+ requestId: string;
606
+ messages: ChatItem[];
607
+ type: AssistantLLMType;
608
+ }
609
+ export interface AssistantLLMStopReq {
610
+ requestId: string;
611
+ }
612
+ export interface AssistantLLMResponse {
613
+ text: string;
614
+ requestId: string;
615
+ done: boolean;
616
+ error?: string;
617
+ }
618
+ export type WarmTransferConfirmMethod = 'keypad' | 'llm';
619
+ export type DtmfDigit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '*' | '#';
620
+ export type Requestor = 'step' | 'first-action';
621
+ export interface TransferEvt extends AppAction {
622
+ type: 'transfer';
623
+ toNumber: string;
624
+ say: string;
625
+ unsuccessfulSay: string;
626
+ arguments: string;
627
+ interruptSay: boolean;
628
+ requestor: Requestor;
629
+ warmBriefingPrompt: string;
630
+ transferType?: TransferType;
631
+ warmTransferConfirmMode?: WarmTransferConfirmMethod[];
632
+ warmTransferConfirmKeypad?: DtmfDigit;
633
+ warmTransferConfig?: Partial<TransferConfig>;
634
+ asyncWarmTransferBridge?: AsyncWarmTransferBridgeConfig;
635
+ }
636
+ export interface MakeCallOptions {
637
+ withAMD?: boolean;
638
+ prviderNumber?: string;
639
+ }
640
+ export interface MakeCallRequest extends MakeCallOptions {
641
+ type: 'make-call';
642
+ fromNumber: string;
643
+ toNumber: string;
644
+ options: MakeCallOptions;
645
+ }
646
+ export interface GlobalInterruptibleRequest extends AppAction {
647
+ type: 'global-interruption';
648
+ disableInterrupt: boolean;
649
+ }
650
+ export interface FieldCollectRequest extends AppAction {
651
+ type: 'field-collect';
652
+ userdata?: string;
653
+ requestor: Requestor;
654
+ fieldName: string;
655
+ config: FieldCollectConfig;
656
+ }
657
+ export interface FieldCollectResponse extends AppAction {
658
+ succeed: boolean;
659
+ fieldName: string;
660
+ requestor: Requestor;
661
+ result: DtmfDigit[];
662
+ value: string;
663
+ userdata?: string;
664
+ }
665
+ export type ReloadAppConfigReason = 'switch-language';
666
+ export interface ReloadAppConfigRequest extends AppAction {
667
+ type: 'reload-app-config';
668
+ reason: ReloadAppConfigReason;
669
+ config: ApplicationConfigResponse;
670
+ }
671
+ export interface ReloadAppConfigResponse extends AppAction {
672
+ type: 'reload-app-config-response';
673
+ }
674
+ export interface VoiceServiceResponse {
675
+ success: boolean;
676
+ callSid?: string;
677
+ failedReason?: 'max-outbound-calls-reached' | 'twilio-api-error' | 'voice-service-internal-error' | 'on-outbound-request-error' | 'network-error' | 'fetch-twilio-config-error';
678
+ message?: string;
679
+ errorCode?: number;
680
+ statusCode?: number;
681
+ }
682
+ export declare class VoiceServiceError extends Error {
683
+ readonly response: VoiceServiceResponse;
684
+ constructor(message: string, response: VoiceServiceResponse);
685
+ }
686
+ export interface MakeFastReponseRequest extends AppAction {
687
+ type: 'make-fast-response';
688
+ text: string;
689
+ }
690
+ export interface ColdTransferMessage {
691
+ introductionBriefing: string;
692
+ unsuccessfulSay: string;
693
+ }
694
+ export declare enum AppState {
695
+ STARTING = "starting",
696
+ WSS_CHECK_FAILED = "wss_check_failed",
697
+ READY = "ready",
698
+ SHUTTING_DOWN = "shutting_down",
699
+ SHUTDOWN = "shutdown"
700
+ }
701
+ export interface InstanceState {
702
+ instanceId: string;
703
+ startTs: number;
704
+ state: AppState;
705
+ timestamp: number;
706
+ activeCalls: number;
707
+ calls: IncomingOutgoingCall[];
708
+ }
709
+ export interface DispatchRule {
710
+ id: string;
711
+ phoneNumber: string;
712
+ agentServiceUrl: string;
713
+ }
714
+ export type CallEndReason = 'stt-error-exit' | 'voicemail-detected-with-reply' | 'voicemail-detected-no-reply' | 'user-silence-max-reached' | 'user-silence-signal-max-continue-reached' | 'assistant-said-goodbye' | 'instance-shutting-down' | 'customer-ended-call' | 'call-busy' | 'call-no-answer' | 'call-failed' | 'call-canceled' | 'cold-transfer-call-success' | 'cold-transfer-call-success-by-first-action' | 'warm-transfer-call-success' | 'warm-transfer-call-success-by-first-action' | 'warm-transfer-failed-execute-error' | 'warm-transfer-failed-confirm-timeout' | 'warm-transfer-failed-join-conference' | 'warm-transfer-failed-target-no-answer' | 'warm-transfer-failed-target-busy' | 'warm-transfer-failed-target-canceled' | 'warm-transfer-failed-target-hangup' | 'warm-transfer-failed-target-error' | 'warm-transfer-failed-customer-hangup' | 'cold-transfer-failed-no-answer' | 'cold-transfer-failed-busy' | 'cold-transfer-failed-canceled' | 'cold-transfer-failed-error' | 'cold-transfer-failed-customer-hangup' | 'field-collect-failed' | 'field-collect-customer-hangup' | 'user-is-bot' | 'unknown';
715
+ export interface CallStatusChangeEvent extends AppAction {
716
+ ctx: IncomingOutgoingCall;
717
+ status: TwilioCallStatusCallback;
718
+ end?: CallEndReason;
719
+ }
720
+ export interface CallEndEvent extends AppAction {
721
+ ctx: IncomingOutgoingCall;
722
+ end: CallEndReason;
723
+ }
724
+ export type CallRecordedEvent = TwilioRecordingStatusCallback & AppAction;
725
+ export type SilenceSignalResponse = AppAction & {
726
+ type: 'silence-signal-response';
727
+ signalId: string;
728
+ result: 'ignore' | 'accept';
729
+ message?: string;
730
+ };
731
+ export type TransferEvent = AppAction & {
732
+ type: 'transfer-event';
733
+ transferType: TransferType;
734
+ fallbackAction: FallbackAction;
735
+ requestor: Requestor;
736
+ result: 'start-transfer' | 'transfer-failed' | 'transfer-completed' | 'async-warm-transfer-bridging';
737
+ };
738
+ /** Built-in voice options for `gpt-realtime` / `gpt-realtime-2`. */
739
+ export type RealtimeBuiltinVoice = 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse' | 'marin' | 'cedar';
740
+ /** Built-in voice name or a custom voice reference (`{ id: "voice_1234" }`). */
741
+ export type RealtimeVoiceConfig = RealtimeBuiltinVoice | {
742
+ id: string;
743
+ };
744
+ /** @deprecated Use `RealtimeBuiltinVoice` or `RealtimeVoiceConfig`. */
745
+ export type RealtimeVoice = RealtimeBuiltinVoice;
746
+ /** Realtime model identifier. */
747
+ export type RealtimeModel = 'gpt-realtime-2';
748
+ /** PCM 16-bit 24 kHz mono — the only audio format this service uses today. */
749
+ export type RealtimeAudioFormat = {
750
+ type: 'audio/pcm';
751
+ rate?: 24000;
752
+ };
753
+ export type RealtimeOutputModality = 'text' | 'audio';
754
+ /** The API accepts a single modality per session: `['audio']` or `['text']`. */
755
+ export type RealtimeOutputModalities = ['audio'] | ['text'];
756
+ /**
757
+ * Noise reduction. `null` (or omitted) disables. Use `near_field` for handset/headset
758
+ * mics and `far_field` for room/conference mics.
759
+ */
760
+ export type RealtimeNoiseReduction = {
761
+ type: 'near_field' | 'far_field';
762
+ } | null;
763
+ export interface RealtimeServerVadConfig {
764
+ type: 'server_vad';
765
+ /**
766
+ * Energy-based speech-activation threshold, 0.0–1.0. Default 0.5. Higher = more
767
+ * conservative (needs louder audio to count as speech → resists line noise/echo but may
768
+ * miss soft speech); lower = more sensitive (catches quiet speech but noise can false-trigger).
769
+ * Telephony usually wants slightly above the default.
770
+ */
771
+ threshold?: number;
772
+ /**
773
+ * Audio retained *before* the VAD-detected speech onset, in ms. Default 300. VAD always
774
+ * lags the true onset, so this prefix keeps the first consonants/syllables from being clipped.
775
+ */
776
+ prefix_padding_ms?: number;
777
+ /**
778
+ * Continuous silence after speech required to mark end-of-speech (EOT) and commit the
779
+ * input buffer, in ms. Default 500. Lower = snappier turns but mid-sentence pauses can
780
+ * cut the user off; higher = tolerates thinking pauses at the cost of reply latency.
781
+ */
782
+ silence_duration_ms?: number;
783
+ /**
784
+ * Idle re-engagement (NOT EOT detection): if the user stays silent for this long *after the
785
+ * model's last response*, the server auto-fires a new `response.create` to re-prompt them.
786
+ * Omit/null to never auto-re-prompt. Min 5000ms. Distinct from the session-level
787
+ * `exit.onSilenceMs`, which tears down the realtime sub-flow instead.
788
+ */
789
+ idle_timeout_ms?: number;
790
+ /**
791
+ * Auto-create a model response when EOT is detected. Default true. (The very first response
792
+ * can still be deferred client-side — see `autoCreateInitialResponse` in `RealtimeSession`.)
793
+ */
794
+ create_response?: boolean;
795
+ /**
796
+ * Auto-cancel an in-flight model response when new user speech is detected
797
+ * (server-side barge-in). Default true. With this enabled, clients MUST NOT
798
+ * issue `response.cancel` themselves — the two race and the manual cancel
799
+ * routinely fails with `response_cancel_not_active`.
800
+ */
801
+ interrupt_response?: boolean;
802
+ }
803
+ export interface RealtimeSemanticVadConfig {
804
+ type: 'semantic_vad';
805
+ /**
806
+ * How eagerly the semantic classifier calls end-of-turn. Default 'auto'. `high` = ends turns
807
+ * fast (snappy, but more likely to cut off a thinking pause); `low` = waits longer for the
808
+ * user to continue. Unlike `server_vad`, EOT is judged from content/prosody, not raw silence.
809
+ */
810
+ eagerness?: 'low' | 'medium' | 'high' | 'auto';
811
+ /** Auto-create a model response when EOT is detected. Default true. */
812
+ create_response?: boolean;
813
+ /** Server-side barge-in: auto-cancel the in-flight response on new user speech. Default true. */
814
+ interrupt_response?: boolean;
815
+ }
816
+ /** Turn detection. `null` disables VAD entirely (push-to-talk style). */
817
+ export type RealtimeTurnDetection = RealtimeServerVadConfig | RealtimeSemanticVadConfig | null;
818
+ /** Transcription delay. Only supported with `gpt-realtime-whisper` in GA Realtime sessions. */
819
+ export type RealtimeTranscriptionDelay = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
820
+ export type RealtimeTranscriptionModel = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-mini-transcribe-2025-12-15' | 'gpt-4o-transcribe' | 'gpt-4o-transcribe-diarize' | 'gpt-realtime-whisper' | (string & {});
821
+ /** Input audio transcription (`audio.input.transcription`). */
822
+ export interface RealtimeTranscriptionConfig {
823
+ model?: RealtimeTranscriptionModel;
824
+ delay?: RealtimeTranscriptionDelay;
825
+ language?: string;
826
+ prompt?: string;
827
+ }
828
+ export type RealtimeToolChoiceMode = 'auto' | 'none' | 'required';
829
+ export interface RealtimeToolChoiceFunction {
830
+ type: 'function';
831
+ name: string;
832
+ }
833
+ export interface RealtimeToolChoiceMcp {
834
+ type: 'mcp';
835
+ server_label: string;
836
+ name?: string;
837
+ }
838
+ export type RealtimeToolChoice = RealtimeToolChoiceMode | RealtimeToolChoiceFunction | RealtimeToolChoiceMcp;
839
+ export type RealtimeReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
840
+ export interface RealtimeReasoningConfig {
841
+ effort?: RealtimeReasoningEffort;
842
+ }
843
+ export type RealtimeInclude = 'item.input_audio_transcription.logprobs';
844
+ export type RealtimeMaxOutputTokens = number | 'inf';
845
+ export interface RealtimePromptInputText {
846
+ type: 'input_text';
847
+ text: string;
848
+ }
849
+ export type RealtimePromptInputImageDetail = 'low' | 'high' | 'auto' | 'original';
850
+ export interface RealtimePromptInputImage {
851
+ type: 'input_image';
852
+ detail?: RealtimePromptInputImageDetail;
853
+ file_id?: string;
854
+ image_url?: string;
855
+ }
856
+ export type RealtimePromptInputFileDetail = 'low' | 'high';
857
+ export interface RealtimePromptInputFile {
858
+ type: 'input_file';
859
+ detail?: RealtimePromptInputFileDetail;
860
+ file_data?: string;
861
+ file_id?: string;
862
+ file_url?: string;
863
+ filename?: string;
864
+ }
865
+ export type RealtimePromptVariableValue = string | RealtimePromptInputText | RealtimePromptInputImage | RealtimePromptInputFile;
866
+ export interface RealtimePromptConfig {
867
+ id: string;
868
+ version?: string;
869
+ variables?: Record<string, RealtimePromptVariableValue>;
870
+ }
871
+ export type RealtimeTracingConfig = 'auto' | {
872
+ group_id?: string;
873
+ metadata?: unknown;
874
+ workflow_name?: string;
875
+ } | null;
876
+ export type RealtimeTruncationConfig = 'auto' | 'disabled' | {
877
+ type: 'retention_ratio';
878
+ retention_ratio: number;
879
+ token_limits?: {
880
+ post_instructions?: number;
881
+ };
882
+ };
883
+ export interface RealtimeFunctionToolDefinition {
884
+ type: 'function';
885
+ name: string;
886
+ description?: string;
887
+ parameters?: unknown;
888
+ }
889
+ export type RealtimeMcpConnectorId = 'connector_dropbox' | 'connector_gmail' | 'connector_googlecalendar' | 'connector_googledrive' | 'connector_microsoftteams' | 'connector_outlookcalendar' | 'connector_outlookemail' | 'connector_sharepoint';
890
+ export interface RealtimeMcpToolFilter {
891
+ read_only?: boolean;
892
+ tool_names?: string[];
893
+ }
894
+ export type RealtimeMcpAllowedTools = string[] | RealtimeMcpToolFilter;
895
+ export interface RealtimeMcpToolApprovalFilter {
896
+ always?: RealtimeMcpToolFilter;
897
+ never?: RealtimeMcpToolFilter;
898
+ }
899
+ export type RealtimeMcpToolApproval = 'always' | 'never' | RealtimeMcpToolApprovalFilter;
900
+ export interface RealtimeMcpToolDefinition {
901
+ type: 'mcp';
902
+ server_label: string;
903
+ allowed_tools?: RealtimeMcpAllowedTools;
904
+ authorization?: string;
905
+ connector_id?: RealtimeMcpConnectorId;
906
+ defer_loading?: boolean;
907
+ headers?: Record<string, string>;
908
+ require_approval?: RealtimeMcpToolApproval;
909
+ server_description?: string;
910
+ server_url?: string;
911
+ }
912
+ export type RealtimeToolDefinition = RealtimeFunctionToolDefinition | RealtimeMcpToolDefinition;
913
+ /**
914
+ * Client-side barge-in handling for the realtime audio output.
915
+ *
916
+ * The server owns turn-level barge-in (`turn_detection.interrupt_response`), but it streams
917
+ * audio faster than real-time, so several seconds of already-generated audio can sit in the
918
+ * local playback buffer. Without intervention that tail keeps playing after the caller starts
919
+ * talking, making the interruption feel like it "didn't work". These knobs let us drop that
920
+ * residual tail (and optionally reconcile the server's transcript) the instant a barge-in is
921
+ * flagged.
922
+ */
923
+ export interface RealtimeBargeInConfig {
924
+ /**
925
+ * Drop the locally buffered (not-yet-played) output audio the moment the server flags user
926
+ * speech while the model is talking. Stops the multi-second tail so the interruption is
927
+ * immediate. Default `true`.
928
+ */
929
+ clearBufferedTailOnBargeIn?: boolean;
930
+ /**
931
+ * Only clear when at least this much un-played audio is still buffered (ms). Guards against
932
+ * chopping the model on a near-empty tail or a `speech_started` that lands right as playback
933
+ * finishes. Default `40` (~2 Twilio frames).
934
+ */
935
+ minBufferedMsToClear?: number;
936
+ /**
937
+ * After clearing, send `conversation.item.truncate` so the server's stored assistant turn
938
+ * reflects only what the caller actually heard (computed from bytes pulled by the mixer, so
939
+ * `audio_end_ms` is always ≤ generated audio and won't be rejected). Keeps history honest and
940
+ * avoids the model believing it finished a sentence it was cut off mid-way. Default `true`.
941
+ */
942
+ truncateOnBargeIn?: boolean;
943
+ }
944
+ /**
945
+ * Full per-session OpenAI Realtime configuration.
946
+ */
947
+ export interface OpenAIRealtimeConfig {
948
+ apiKey: string;
949
+ model: RealtimeModel;
950
+ voice: RealtimeVoiceConfig;
951
+ /** Defaults to `['audio']`. The API does not support `['text', 'audio']` together. */
952
+ outputModalities?: RealtimeOutputModalities;
953
+ inputAudioFormat: RealtimeAudioFormat;
954
+ outputAudioFormat: RealtimeAudioFormat;
955
+ outputAudioSpeed?: number;
956
+ /**
957
+ * Linear makeup gain applied to the model's output audio before μ-law encoding.
958
+ * `1.0` = no change. Values > 1 amplify (with hard-clip protection at ±32767).
959
+ * Use to compensate for gpt-realtime's relatively low native output level.
960
+ */
961
+ outputGain?: number;
962
+ include?: RealtimeInclude[];
963
+ /** `null` disables noise reduction. */
964
+ noiseReduction: RealtimeNoiseReduction;
965
+ /** `null` disables VAD entirely. With `interrupt_response: true` the server owns barge-in. */
966
+ turnDetection: RealtimeTurnDetection;
967
+ /** Client-side barge-in tail handling. Omit to use defaults (clear + truncate enabled). */
968
+ bargeIn?: RealtimeBargeInConfig;
969
+ transcription: RealtimeTranscriptionConfig | null;
970
+ maxOutputTokens?: RealtimeMaxOutputTokens;
971
+ parallelToolCalls?: boolean;
972
+ prompt?: RealtimePromptConfig;
973
+ tools?: RealtimeToolDefinition[];
974
+ toolChoice?: RealtimeToolChoice;
975
+ /** Reasoning effort for reasoning-capable Realtime models such as `gpt-realtime-2`. */
976
+ reasoning?: RealtimeReasoningConfig;
977
+ tracing?: RealtimeTracingConfig;
978
+ truncation?: RealtimeTruncationConfig;
979
+ }
980
+ export type OptionalOpenAIRealtimeConfig = Partial<OpenAIRealtimeConfig>;
981
+ /** `none`: cold start. `last-n`: replay last `historyContextLastN` items (default 100). `full`: all. */
982
+ export type RealtimeHistoryContext = 'none' | 'last-n' | 'full';
983
+ export type RealtimeExitTrigger = 'tool' | 'silence';
984
+ export interface RealtimeExitConfig {
985
+ /** Tool names that exit the sub-flow when called by the model. */
986
+ onTool?: string[];
987
+ /** Idle silence (ms) after which the sub-flow auto-exits. */
988
+ onSilenceMs?: number;
989
+ }
990
+ /** Payload for the `RealtimeChat` mid-call action. */
991
+ export interface RealtimeChatActionPayload {
992
+ callSid: string;
993
+ instructions: string;
994
+ voice?: RealtimeVoiceConfig;
995
+ tools?: RealtimeToolDefinition[];
996
+ historyContext?: RealtimeHistoryContext;
997
+ /** Trailing items to inject when `historyContext === 'last-n'`. Default 100 (`DEFAULT_HISTORY_LAST_N`). */
998
+ historyContextLastN?: number;
999
+ /** Top-level shortcut for `configOverride.noiseReduction`. `null` disables. */
1000
+ noiseReduction?: RealtimeNoiseReduction;
1001
+ exit?: RealtimeExitConfig;
1002
+ configOverride?: OptionalOpenAIRealtimeConfig;
1003
+ }
1004
+ /** `/twilio/thirdparty-event` body to trigger a mid-call realtime sub-flow. */
1005
+ export interface RealtimeChatRequest extends AppAction {
1006
+ type: 'realtime-chat';
1007
+ payload: Omit<RealtimeChatActionPayload, 'callSid'>;
1008
+ }
1009
+ export {};
1010
+ //# sourceMappingURL=types.d.ts.map