@absolutejs/voice 0.0.22-beta.66 → 0.0.22-beta.660

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 (514) hide show
  1. package/LICENSE +88 -0
  2. package/README.md +4550 -1180
  3. package/dist/angular/index.d.ts +36 -7
  4. package/dist/angular/index.js +4425 -513
  5. package/dist/angular/voice-agent-squad-status.service.d.ts +12 -0
  6. package/dist/angular/voice-call-debugger.service.d.ts +12 -0
  7. package/dist/angular/voice-call-player.service.d.ts +19 -0
  8. package/dist/angular/voice-campaign-dialer-proof.service.d.ts +14 -0
  9. package/dist/angular/voice-controller.service.d.ts +4 -1
  10. package/dist/angular/voice-cost-dashboard.service.d.ts +15 -0
  11. package/dist/angular/voice-delivery-runtime.service.d.ts +16 -0
  12. package/dist/angular/voice-live-agent-console.service.d.ts +16 -0
  13. package/dist/angular/voice-live-call-viewer.service.d.ts +16 -0
  14. package/dist/angular/voice-live-ops.service.d.ts +11 -0
  15. package/dist/angular/voice-ops-action-center.service.d.ts +13 -0
  16. package/dist/angular/voice-ops-status.service.d.ts +12 -0
  17. package/dist/angular/voice-platform-coverage.service.d.ts +12 -0
  18. package/dist/angular/voice-profile-comparison.service.d.ts +12 -0
  19. package/dist/angular/voice-proof-trends.service.d.ts +12 -0
  20. package/dist/angular/voice-provider-capabilities.service.d.ts +2 -2
  21. package/dist/angular/voice-provider-contracts.service.d.ts +12 -0
  22. package/dist/angular/voice-provider-status.service.d.ts +2 -2
  23. package/dist/angular/voice-readiness-failures.service.d.ts +13 -0
  24. package/dist/angular/voice-reconnect-profile-evidence.service.d.ts +12 -0
  25. package/dist/angular/voice-replay-timeline.service.d.ts +13 -0
  26. package/dist/angular/voice-routing-status.service.d.ts +1 -1
  27. package/dist/angular/voice-session-observability.service.d.ts +12 -0
  28. package/dist/angular/voice-session-snapshot.service.d.ts +13 -0
  29. package/dist/angular/voice-stream.service.d.ts +6 -2
  30. package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
  31. package/dist/angular/voice-turn-latency.service.d.ts +13 -0
  32. package/dist/angular/voice-turn-quality.service.d.ts +12 -0
  33. package/dist/angular/voice-widget.service.d.ts +18 -0
  34. package/dist/angular/voice-workflow-status.service.d.ts +2 -2
  35. package/dist/client/actions.d.ts +140 -2
  36. package/dist/client/agentSquadStatus.d.ts +37 -0
  37. package/dist/client/agentSquadStatusWidget.d.ts +24 -0
  38. package/dist/client/audioPlayer.d.ts +12 -2
  39. package/dist/client/bargeInMonitor.d.ts +7 -0
  40. package/dist/client/browserMedia.d.ts +8 -0
  41. package/dist/client/browserNoiseSuppression.d.ts +42 -0
  42. package/dist/client/browserVoiceSupport.d.ts +22 -0
  43. package/dist/client/callDebugger.d.ts +21 -0
  44. package/dist/client/callDebuggerWidget.d.ts +30 -0
  45. package/dist/client/callPlayer.d.ts +41 -0
  46. package/dist/client/campaignDialerProof.d.ts +25 -0
  47. package/dist/client/connection.d.ts +13 -4
  48. package/dist/client/controller.d.ts +1 -1
  49. package/dist/client/conversationAnalytics.d.ts +30 -0
  50. package/dist/client/costDashboard.d.ts +27 -0
  51. package/dist/client/createVoiceStream.d.ts +1 -1
  52. package/dist/client/deliveryRuntime.d.ts +36 -0
  53. package/dist/client/deliveryRuntimeWidget.d.ts +37 -0
  54. package/dist/client/duplex.d.ts +2 -2
  55. package/dist/client/htmx.d.ts +1 -1
  56. package/dist/client/htmxAttributes.d.ts +24 -0
  57. package/dist/client/htmxBootstrap.js +1760 -147
  58. package/dist/client/htmxDashboardRenderers.d.ts +71 -0
  59. package/dist/client/index.d.ts +109 -29
  60. package/dist/client/index.js +10886 -581
  61. package/dist/client/liveAgentConsole.d.ts +28 -0
  62. package/dist/client/liveCallViewer.d.ts +42 -0
  63. package/dist/client/liveOps.d.ts +22 -0
  64. package/dist/client/liveOpsWidget.d.ts +23 -0
  65. package/dist/client/liveTurnLatency.d.ts +41 -0
  66. package/dist/client/microphone.d.ts +5 -4
  67. package/dist/client/opsActionCenter.d.ts +56 -0
  68. package/dist/client/opsActionCenterWidget.d.ts +29 -0
  69. package/dist/client/opsActionHistory.d.ts +21 -0
  70. package/dist/client/opsActionHistoryWidget.d.ts +11 -0
  71. package/dist/client/opsStatus.d.ts +21 -0
  72. package/dist/client/opsStatusWidget.d.ts +10 -10
  73. package/dist/client/platformCoverage.d.ts +21 -0
  74. package/dist/client/platformCoverageWidget.d.ts +38 -0
  75. package/dist/client/profileComparison.d.ts +21 -0
  76. package/dist/client/profileComparisonWidget.d.ts +41 -0
  77. package/dist/client/profileSwitchRecommendation.d.ts +21 -0
  78. package/dist/client/profileSwitchRecommendationWidget.d.ts +12 -0
  79. package/dist/client/proofTrends.d.ts +21 -0
  80. package/dist/client/proofTrendsWidget.d.ts +38 -0
  81. package/dist/client/providerCapabilities.d.ts +5 -3
  82. package/dist/client/providerCapabilitiesWidget.d.ts +6 -6
  83. package/dist/client/providerContracts.d.ts +21 -0
  84. package/dist/client/providerContractsWidget.d.ts +37 -0
  85. package/dist/client/providerSimulationControls.d.ts +3 -3
  86. package/dist/client/providerSimulationControlsWidget.d.ts +5 -5
  87. package/dist/client/providerStatus.d.ts +5 -3
  88. package/dist/client/providerStatusWidget.d.ts +6 -6
  89. package/dist/client/reactiveSource.d.ts +8 -0
  90. package/dist/client/readinessFailures.d.ts +21 -0
  91. package/dist/client/readinessFailuresWidget.d.ts +42 -0
  92. package/dist/client/reconnectProfileEvidence.d.ts +21 -0
  93. package/dist/client/reconnectProfileEvidenceWidget.d.ts +39 -0
  94. package/dist/client/replayTimeline.d.ts +26 -0
  95. package/dist/client/routingStatus.d.ts +5 -3
  96. package/dist/client/routingStatusWidget.d.ts +10 -6
  97. package/dist/client/sessionObservability.d.ts +21 -0
  98. package/dist/client/sessionObservabilityWidget.d.ts +31 -0
  99. package/dist/client/sessionSnapshot.d.ts +23 -0
  100. package/dist/client/sessionSnapshotWidget.d.ts +33 -0
  101. package/dist/client/store.d.ts +1 -1
  102. package/dist/client/timeStretch.d.ts +5 -0
  103. package/dist/client/traceTimeline.d.ts +21 -0
  104. package/dist/client/traceTimelineWidget.d.ts +36 -0
  105. package/dist/client/turnLatency.d.ts +24 -0
  106. package/dist/client/turnLatencyWidget.d.ts +33 -0
  107. package/dist/client/turnQuality.d.ts +21 -0
  108. package/dist/client/turnQualityWidget.d.ts +32 -0
  109. package/dist/client/voiceWidgetView.d.ts +48 -0
  110. package/dist/client/workflowStatus.d.ts +5 -3
  111. package/dist/{agent.d.ts → core/agent.d.ts} +110 -7
  112. package/dist/core/agentPerformanceReport.d.ts +40 -0
  113. package/dist/core/agentSquadContract.d.ts +98 -0
  114. package/dist/core/agentState.d.ts +12 -0
  115. package/dist/core/agentTools.d.ts +132 -0
  116. package/dist/core/aiScorecard.d.ts +32 -0
  117. package/dist/core/aiVoiceModel.d.ts +15 -0
  118. package/dist/core/amdDetector.d.ts +25 -0
  119. package/dist/{assistant.d.ts → core/assistant.d.ts} +21 -14
  120. package/dist/core/assistantExperiment.d.ts +42 -0
  121. package/dist/{assistantHealth.d.ts → core/assistantHealth.d.ts} +9 -9
  122. package/dist/{assistantMemory.d.ts → core/assistantMemory.d.ts} +10 -10
  123. package/dist/core/assistantMode.d.ts +22 -0
  124. package/dist/{audioConditioning.d.ts → core/audioConditioning.d.ts} +2 -2
  125. package/dist/core/audit.d.ts +131 -0
  126. package/dist/core/auditDeliveryRoutes.d.ts +85 -0
  127. package/dist/core/auditExport.d.ts +34 -0
  128. package/dist/core/auditRoutes.d.ts +66 -0
  129. package/dist/core/auditSinks.d.ts +151 -0
  130. package/dist/core/backchannel.d.ts +25 -0
  131. package/dist/core/bargeInDetector.d.ts +51 -0
  132. package/dist/core/bargeInRoutes.d.ts +56 -0
  133. package/dist/core/bookingFlow.d.ts +43 -0
  134. package/dist/core/browserCallProfiles.d.ts +120 -0
  135. package/dist/core/browserMediaRoutes.d.ts +62 -0
  136. package/dist/core/cachedTTS.d.ts +54 -0
  137. package/dist/core/calendarAdapter.d.ts +47 -0
  138. package/dist/core/calendarSlots.d.ts +35 -0
  139. package/dist/core/callDebugger.d.ts +66 -0
  140. package/dist/core/callDisposition.d.ts +38 -0
  141. package/dist/core/callQuota.d.ts +54 -0
  142. package/dist/core/callScorecard.d.ts +53 -0
  143. package/dist/core/callerCRMLinker.d.ts +29 -0
  144. package/dist/core/callerMemory.d.ts +37 -0
  145. package/dist/core/callingWindow.d.ts +26 -0
  146. package/dist/core/campaign.d.ts +795 -0
  147. package/dist/core/campaignControls.d.ts +37 -0
  148. package/dist/core/campaignDialers.d.ts +111 -0
  149. package/dist/core/campaignTemplate.d.ts +16 -0
  150. package/dist/core/competitiveCoverage.d.ts +141 -0
  151. package/dist/core/conversationSimulator.d.ts +73 -0
  152. package/dist/{correction.d.ts → core/correction.d.ts} +5 -4
  153. package/dist/core/costAccounting.d.ts +90 -0
  154. package/dist/core/costPredictor.d.ts +74 -0
  155. package/dist/core/crmCallLogger.d.ts +37 -0
  156. package/dist/core/crmContract.d.ts +70 -0
  157. package/dist/core/dataControl.d.ts +180 -0
  158. package/dist/core/debugTiming.d.ts +11 -0
  159. package/dist/core/defineVoiceAssistant.d.ts +68 -0
  160. package/dist/core/deliveryRuntime.d.ts +159 -0
  161. package/dist/core/deliverySinkRoutes.d.ts +117 -0
  162. package/dist/core/demoReadyRoutes.d.ts +98 -0
  163. package/dist/{diagnosticsRoutes.d.ts → core/diagnosticsRoutes.d.ts} +2 -2
  164. package/dist/core/dncRegistry.d.ts +38 -0
  165. package/dist/core/dtmfCollector.d.ts +37 -0
  166. package/dist/{evalRoutes.d.ts → core/evalRoutes.d.ts} +26 -20
  167. package/dist/{fileStore.d.ts → core/fileStore.d.ts} +34 -20
  168. package/dist/core/guardrails.d.ts +128 -0
  169. package/dist/{handoff.d.ts → core/handoff.d.ts} +10 -10
  170. package/dist/{handoffHealth.d.ts → core/handoffHealth.d.ts} +9 -9
  171. package/dist/core/hardenedFetch.d.ts +1 -0
  172. package/dist/core/holdAudio.d.ts +23 -0
  173. package/dist/{htmx.d.ts → core/htmx.d.ts} +2 -2
  174. package/dist/core/htmxDashboardRoutes.d.ts +250 -0
  175. package/dist/core/iceServers.d.ts +34 -0
  176. package/dist/core/incidentBundle.d.ts +119 -0
  177. package/dist/core/incidentTimeline.d.ts +260 -0
  178. package/dist/core/ivrPlan.d.ts +40 -0
  179. package/dist/core/latencySlo.d.ts +56 -0
  180. package/dist/core/liveCoach.d.ts +43 -0
  181. package/dist/core/liveLatency.d.ts +78 -0
  182. package/dist/core/liveOps.d.ts +190 -0
  183. package/dist/core/llmJudge.d.ts +45 -0
  184. package/dist/{logger.d.ts → core/logger.d.ts} +1 -2
  185. package/dist/core/mcpToolset.d.ts +58 -0
  186. package/dist/core/mediaPipelineRoutes.d.ts +171 -0
  187. package/dist/core/mediaPipelineSurfaces.d.ts +48 -0
  188. package/dist/{memoryStore.d.ts → core/memoryStore.d.ts} +1 -1
  189. package/dist/core/midCallSummary.d.ts +27 -0
  190. package/dist/{modelAdapters.d.ts → core/modelAdapters.d.ts} +64 -7
  191. package/dist/core/monitor.d.ts +148 -0
  192. package/dist/core/multilingualProof.d.ts +77 -0
  193. package/dist/core/noShowPredictor.d.ts +46 -0
  194. package/dist/core/numberNormalizer.d.ts +1 -0
  195. package/dist/core/oauth2TokenSource.d.ts +21 -0
  196. package/dist/core/observabilityExport.d.ts +501 -0
  197. package/dist/core/openaiTTS.d.ts +18 -0
  198. package/dist/core/operationalStatus.d.ts +87 -0
  199. package/dist/core/operationsRecord.d.ts +371 -0
  200. package/dist/{ops.d.ts → core/ops.d.ts} +70 -70
  201. package/dist/core/opsActionAuditRoutes.d.ts +99 -0
  202. package/dist/{opsConsoleRoutes.d.ts → core/opsConsoleRoutes.d.ts} +11 -8
  203. package/dist/{opsPresets.d.ts → core/opsPresets.d.ts} +2 -2
  204. package/dist/core/opsRecovery.d.ts +137 -0
  205. package/dist/{opsRuntime.d.ts → core/opsRuntime.d.ts} +6 -6
  206. package/dist/{opsSinks.d.ts → core/opsSinks.d.ts} +19 -19
  207. package/dist/core/opsStatus.d.ts +76 -0
  208. package/dist/core/opsStatusRoutes.d.ts +33 -0
  209. package/dist/{opsWebhook.d.ts → core/opsWebhook.d.ts} +15 -15
  210. package/dist/core/otelExporter.d.ts +83 -0
  211. package/dist/core/outcomeContract.d.ts +146 -0
  212. package/dist/{outcomeRecipes.d.ts → core/outcomeRecipes.d.ts} +4 -4
  213. package/dist/core/pathway.d.ts +94 -0
  214. package/dist/core/pathwayCompiler.d.ts +31 -0
  215. package/dist/core/pathwayGenerator.d.ts +27 -0
  216. package/dist/core/pathwayRuntime.d.ts +57 -0
  217. package/dist/core/pathwaySlotCollector.d.ts +29 -0
  218. package/dist/core/pathwayVisualizer.d.ts +8 -0
  219. package/dist/core/phoneAgent.d.ts +139 -0
  220. package/dist/core/phoneAgentProductionSmoke.d.ts +115 -0
  221. package/dist/core/phoneProvisioning.d.ts +29 -0
  222. package/dist/core/platformCoverage.d.ts +91 -0
  223. package/dist/{plugin.d.ts → core/plugin.d.ts} +11 -8
  224. package/dist/core/postCallAnalysis.d.ts +98 -0
  225. package/dist/core/postCallSurvey.d.ts +41 -0
  226. package/dist/{postgresStore.d.ts → core/postgresStore.d.ts} +20 -9
  227. package/dist/{presets.d.ts → core/presets.d.ts} +3 -3
  228. package/dist/core/productionReadiness.d.ts +757 -0
  229. package/dist/core/profileSwitchRecommendation.d.ts +350 -0
  230. package/dist/core/promptInjectionGuard.d.ts +30 -0
  231. package/dist/core/proofAssertions.d.ts +32 -0
  232. package/dist/core/proofPack.d.ts +211 -0
  233. package/dist/core/proofRunner.d.ts +79 -0
  234. package/dist/core/proofTrends.d.ts +966 -0
  235. package/dist/{providerAdapters.d.ts → core/providerAdapters.d.ts} +5 -5
  236. package/dist/{providerCapabilities.d.ts → core/providerCapabilities.d.ts} +9 -9
  237. package/dist/core/providerDecisionTraces.d.ts +130 -0
  238. package/dist/{providerHealth.d.ts → core/providerHealth.d.ts} +15 -5
  239. package/dist/core/providerOrchestration.d.ts +109 -0
  240. package/dist/core/providerRouterTraces.d.ts +35 -0
  241. package/dist/core/providerRoutingContract.d.ts +71 -0
  242. package/dist/core/providerSlo.d.ts +142 -0
  243. package/dist/core/providerStackRecommendations.d.ts +188 -0
  244. package/dist/core/qualityDriftDetector.d.ts +44 -0
  245. package/dist/{qualityRoutes.d.ts → core/qualityRoutes.d.ts} +7 -7
  246. package/dist/{queue.d.ts → core/queue.d.ts} +48 -39
  247. package/dist/core/ragTool.d.ts +52 -0
  248. package/dist/core/readinessProfiles.d.ts +45 -0
  249. package/dist/core/realtimeChannel.d.ts +136 -0
  250. package/dist/core/realtimeProviderContracts.d.ts +133 -0
  251. package/dist/core/reconnectContract.d.ts +177 -0
  252. package/dist/core/recordingRedaction.d.ts +47 -0
  253. package/dist/core/recordingStore.d.ts +60 -0
  254. package/dist/core/redaction.d.ts +13 -0
  255. package/dist/core/reminderScheduler.d.ts +43 -0
  256. package/dist/{resilienceRoutes.d.ts → core/resilienceRoutes.d.ts} +34 -5
  257. package/dist/core/retention.d.ts +37 -0
  258. package/dist/core/retryPolicy.d.ts +38 -0
  259. package/dist/core/routeAuth.d.ts +58 -0
  260. package/dist/{routing.d.ts → core/routing.d.ts} +2 -2
  261. package/dist/{runtimeOps.d.ts → core/runtimeOps.d.ts} +3 -3
  262. package/dist/{s3Store.d.ts → core/s3Store.d.ts} +12 -3
  263. package/dist/core/scorecardCalibration.d.ts +31 -0
  264. package/dist/core/scribe.d.ts +50 -0
  265. package/dist/core/semanticTurn.d.ts +37 -0
  266. package/dist/{session.d.ts → core/session.d.ts} +1 -1
  267. package/dist/core/sessionObservability.d.ts +145 -0
  268. package/dist/{sessionReplay.d.ts → core/sessionReplay.d.ts} +31 -19
  269. package/dist/core/sessionSnapshot.d.ts +109 -0
  270. package/dist/core/simulationSuite.d.ts +144 -0
  271. package/dist/core/sloCalibration.d.ts +185 -0
  272. package/dist/{sqliteStore.d.ts → core/sqliteStore.d.ts} +20 -9
  273. package/dist/{store.d.ts → core/store.d.ts} +1 -1
  274. package/dist/core/supervisorPermissions.d.ts +33 -0
  275. package/dist/core/supervisorPresence.d.ts +49 -0
  276. package/dist/core/telephonyMediaRoutes.d.ts +72 -0
  277. package/dist/core/telephonyOutcome.d.ts +269 -0
  278. package/dist/{toolContract.d.ts → core/toolContract.d.ts} +46 -15
  279. package/dist/{toolRuntime.d.ts → core/toolRuntime.d.ts} +4 -4
  280. package/dist/{trace.d.ts → core/trace.d.ts} +61 -22
  281. package/dist/core/traceDeliveryRoutes.d.ts +86 -0
  282. package/dist/core/traceTimeline.d.ts +97 -0
  283. package/dist/core/transcriptAnnotator.d.ts +41 -0
  284. package/dist/{turnDetection.d.ts → core/turnDetection.d.ts} +2 -1
  285. package/dist/core/turnLatency.d.ts +95 -0
  286. package/dist/core/turnProfiles.d.ts +3 -0
  287. package/dist/core/turnQuality.d.ts +94 -0
  288. package/dist/core/types.d.ts +1755 -0
  289. package/dist/core/vapiAdapter.d.ts +160 -0
  290. package/dist/core/variableAnalytics.d.ts +47 -0
  291. package/dist/core/voiceConfiguration.d.ts +8 -0
  292. package/dist/core/voiceMonitoring.d.ts +444 -0
  293. package/dist/core/webhookFanout.d.ts +48 -0
  294. package/dist/core/webhookVerification.d.ts +27 -0
  295. package/dist/core/whisperChannel.d.ts +50 -0
  296. package/dist/{workflowContract.d.ts → core/workflowContract.d.ts} +21 -21
  297. package/dist/core/writeBehindStore.d.ts +41 -0
  298. package/dist/core/zeroDataRetention.d.ts +31 -0
  299. package/dist/drizzle/assistantMemory.d.ts +100 -0
  300. package/dist/drizzle/eval.d.ts +55 -0
  301. package/dist/drizzle/handoff.d.ts +56 -0
  302. package/dist/drizzle/incidentBundle.d.ts +55 -0
  303. package/dist/drizzle/index.d.ts +991 -0
  304. package/dist/drizzle/index.js +3059 -0
  305. package/dist/drizzle/observabilityExport.d.ts +55 -0
  306. package/dist/drizzle/proofTrends.d.ts +114 -0
  307. package/dist/drizzle/runtimeStorage.d.ts +1183 -0
  308. package/dist/drizzle/shared.d.ts +69 -0
  309. package/dist/embed/index.d.ts +38 -0
  310. package/dist/embed/index.js +2064 -0
  311. package/dist/embed/voice-widget.js +10 -0
  312. package/dist/index.d.ts +379 -80
  313. package/dist/index.js +48304 -8042
  314. package/dist/internal/evidence.d.ts +10 -0
  315. package/dist/internal/html.d.ts +6 -0
  316. package/dist/internal/status.d.ts +7 -0
  317. package/dist/manifest.d.ts +17 -0
  318. package/dist/manifest.js +424 -0
  319. package/dist/manifest.json +427 -0
  320. package/dist/react/VoiceAgentSquadStatus.d.ts +5 -0
  321. package/dist/react/VoiceCallDebuggerLaunch.d.ts +6 -0
  322. package/dist/react/VoiceCallPlayer.d.ts +11 -0
  323. package/dist/react/VoiceCostDashboard.d.ts +10 -0
  324. package/dist/react/VoiceDeliveryRuntime.d.ts +7 -0
  325. package/dist/react/VoiceLiveAgentConsole.d.ts +11 -0
  326. package/dist/react/VoiceLiveCallViewer.d.ts +9 -0
  327. package/dist/react/VoiceOpsActionCenter.d.ts +5 -0
  328. package/dist/react/VoiceOpsStatus.d.ts +1 -1
  329. package/dist/react/VoicePlatformCoverage.d.ts +6 -0
  330. package/dist/react/VoiceProfileComparison.d.ts +6 -0
  331. package/dist/react/VoiceProfileSwitchRecommendation.d.ts +6 -0
  332. package/dist/react/VoiceProofTrends.d.ts +6 -0
  333. package/dist/react/VoiceProviderCapabilities.d.ts +1 -1
  334. package/dist/react/VoiceProviderContracts.d.ts +6 -0
  335. package/dist/react/VoiceProviderSimulationControls.d.ts +1 -1
  336. package/dist/react/VoiceProviderStatus.d.ts +1 -1
  337. package/dist/react/VoiceReadinessFailures.d.ts +6 -0
  338. package/dist/react/VoiceReconnectProfileEvidence.d.ts +6 -0
  339. package/dist/react/VoiceReplayTimeline.d.ts +6 -0
  340. package/dist/react/VoiceRoutingStatus.d.ts +1 -1
  341. package/dist/react/VoiceSessionObservability.d.ts +6 -0
  342. package/dist/react/VoiceSessionSnapshot.d.ts +6 -0
  343. package/dist/react/VoiceTraceTimeline.d.ts +6 -0
  344. package/dist/react/VoiceTurnLatency.d.ts +6 -0
  345. package/dist/react/VoiceTurnQuality.d.ts +6 -0
  346. package/dist/react/VoiceWidget.d.ts +13 -0
  347. package/dist/react/index.d.ts +80 -13
  348. package/dist/react/index.js +13728 -1784
  349. package/dist/react/useVoiceAgentSquadStatus.d.ts +8 -0
  350. package/dist/react/useVoiceCallDebugger.d.ts +8 -0
  351. package/dist/react/useVoiceCampaignDialerProof.d.ts +10 -0
  352. package/dist/react/useVoiceController.d.ts +6 -2
  353. package/dist/react/useVoiceDeliveryRuntime.d.ts +13 -0
  354. package/dist/react/useVoiceLiveOps.d.ts +9 -0
  355. package/dist/react/useVoiceOpsActionCenter.d.ts +11 -0
  356. package/dist/react/useVoiceOpsStatus.d.ts +8 -0
  357. package/dist/react/useVoicePlatformCoverage.d.ts +8 -0
  358. package/dist/react/useVoiceProfileComparison.d.ts +8 -0
  359. package/dist/react/useVoiceProfileSwitchRecommendation.d.ts +8 -0
  360. package/dist/react/useVoiceProofTrends.d.ts +8 -0
  361. package/dist/react/useVoiceProviderCapabilities.d.ts +1 -1
  362. package/dist/react/useVoiceProviderContracts.d.ts +8 -0
  363. package/dist/react/useVoiceProviderSimulationControls.d.ts +1 -1
  364. package/dist/react/useVoiceProviderStatus.d.ts +1 -1
  365. package/dist/react/useVoiceReadinessFailures.d.ts +8 -0
  366. package/dist/react/useVoiceReconnectProfileEvidence.d.ts +8 -0
  367. package/dist/react/useVoiceRoutingStatus.d.ts +1 -1
  368. package/dist/react/useVoiceSessionObservability.d.ts +8 -0
  369. package/dist/react/useVoiceSessionSnapshot.d.ts +9 -0
  370. package/dist/react/useVoiceStream.d.ts +6 -2
  371. package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
  372. package/dist/react/useVoiceTurnLatency.d.ts +9 -0
  373. package/dist/react/useVoiceTurnQuality.d.ts +8 -0
  374. package/dist/react/useVoiceWorkflowStatus.d.ts +1 -1
  375. package/dist/svelte/createVoiceAgentSquadStatus.d.ts +9 -0
  376. package/dist/svelte/createVoiceCallDebugger.d.ts +10 -0
  377. package/dist/svelte/createVoiceCallPlayer.d.ts +33 -0
  378. package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
  379. package/dist/svelte/createVoiceCostDashboard.d.ts +13 -0
  380. package/dist/svelte/createVoiceDeliveryRuntime.d.ts +11 -0
  381. package/dist/svelte/createVoiceLiveAgentConsole.d.ts +23 -0
  382. package/dist/svelte/createVoiceLiveCallViewer.d.ts +26 -0
  383. package/dist/svelte/createVoiceLiveOps.d.ts +13 -0
  384. package/dist/svelte/createVoiceOpsActionCenter.d.ts +10 -0
  385. package/dist/svelte/createVoiceOpsStatus.d.ts +4 -4
  386. package/dist/svelte/createVoicePlatformCoverage.d.ts +7 -0
  387. package/dist/svelte/createVoiceProfileComparison.d.ts +7 -0
  388. package/dist/svelte/createVoiceProofTrends.d.ts +7 -0
  389. package/dist/svelte/createVoiceProviderCapabilities.d.ts +2 -2
  390. package/dist/svelte/createVoiceProviderContracts.d.ts +10 -0
  391. package/dist/svelte/createVoiceProviderSimulationControls.d.ts +2 -2
  392. package/dist/svelte/createVoiceProviderStatus.d.ts +2 -2
  393. package/dist/svelte/createVoiceReadinessFailures.d.ts +7 -0
  394. package/dist/svelte/createVoiceReconnectProfileEvidence.d.ts +7 -0
  395. package/dist/svelte/createVoiceReplayTimeline.d.ts +13 -0
  396. package/dist/svelte/createVoiceRoutingStatus.d.ts +2 -2
  397. package/dist/svelte/createVoiceSessionObservability.d.ts +10 -0
  398. package/dist/svelte/createVoiceSessionSnapshot.d.ts +11 -0
  399. package/dist/svelte/createVoiceStream.d.ts +1 -1
  400. package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
  401. package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
  402. package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
  403. package/dist/svelte/createVoiceWidget.d.ts +19 -0
  404. package/dist/svelte/createVoiceWorkflowStatus.d.ts +2 -2
  405. package/dist/svelte/index.d.ts +37 -9
  406. package/dist/svelte/index.js +7494 -1540
  407. package/dist/telephony/contract.d.ts +61 -0
  408. package/dist/telephony/matrix.d.ts +97 -0
  409. package/dist/telephony/plivo.d.ts +303 -0
  410. package/dist/telephony/response.d.ts +1 -1
  411. package/dist/telephony/security.d.ts +182 -0
  412. package/dist/telephony/telnyx.d.ts +291 -0
  413. package/dist/telephony/twilio.d.ts +153 -15
  414. package/dist/testing/accuracy.d.ts +18 -1
  415. package/dist/testing/audioMatrix.d.ts +22 -0
  416. package/dist/testing/benchmark.d.ts +24 -15
  417. package/dist/testing/confidenceCalibration.d.ts +19 -0
  418. package/dist/testing/conformance.d.ts +11 -0
  419. package/dist/testing/corrected.d.ts +9 -9
  420. package/dist/testing/criticalFields.d.ts +22 -0
  421. package/dist/testing/duplex.d.ts +5 -5
  422. package/dist/testing/fixtures.d.ts +7 -4
  423. package/dist/testing/index.d.ts +21 -13
  424. package/dist/testing/index.js +8889 -1153
  425. package/dist/testing/ioProviderSimulator.d.ts +5 -5
  426. package/dist/testing/outcomes.d.ts +12 -0
  427. package/dist/testing/provenance.d.ts +44 -0
  428. package/dist/testing/providerSimulator.d.ts +5 -5
  429. package/dist/testing/review.d.ts +8 -8
  430. package/dist/testing/routingBenchmark.d.ts +16 -0
  431. package/dist/testing/sessionBenchmark.d.ts +13 -13
  432. package/dist/testing/statistics.d.ts +30 -0
  433. package/dist/testing/stt.d.ts +3 -3
  434. package/dist/testing/telephony.d.ts +27 -2
  435. package/dist/testing/tts.d.ts +2 -2
  436. package/dist/vue/VoiceCallDebuggerLaunch.d.ts +72 -0
  437. package/dist/vue/VoiceCallPlayer.d.ts +40 -0
  438. package/dist/vue/VoiceCostDashboard.d.ts +57 -0
  439. package/dist/vue/VoiceDeliveryRuntime.d.ts +34 -0
  440. package/dist/vue/VoiceLiveAgentConsole.d.ts +50 -0
  441. package/dist/vue/VoiceLiveCallViewer.d.ts +35 -0
  442. package/dist/vue/VoiceOpsActionCenter.d.ts +13 -0
  443. package/dist/vue/VoiceOpsStatus.d.ts +4 -0
  444. package/dist/vue/VoicePlatformCoverage.d.ts +27 -0
  445. package/dist/vue/VoiceProofTrends.d.ts +25 -0
  446. package/dist/vue/VoiceProviderCapabilities.d.ts +4 -0
  447. package/dist/vue/VoiceProviderContracts.d.ts +25 -0
  448. package/dist/vue/VoiceProviderSimulationControls.d.ts +3 -3
  449. package/dist/vue/VoiceProviderStatus.d.ts +4 -0
  450. package/dist/vue/VoiceReadinessFailures.d.ts +25 -0
  451. package/dist/vue/VoiceReconnectProfileEvidence.d.ts +25 -0
  452. package/dist/vue/VoiceReplayTimeline.d.ts +17 -0
  453. package/dist/vue/VoiceRoutingStatus.d.ts +4 -0
  454. package/dist/vue/VoiceSessionObservability.d.ts +27 -0
  455. package/dist/vue/VoiceSessionSnapshot.d.ts +72 -0
  456. package/dist/vue/VoiceTurnLatency.d.ts +73 -0
  457. package/dist/vue/VoiceTurnQuality.d.ts +55 -0
  458. package/dist/vue/VoiceWidget.d.ts +77 -0
  459. package/dist/vue/index.d.ts +49 -13
  460. package/dist/vue/index.js +13050 -1931
  461. package/dist/vue/useVoiceAgentSquadStatus.d.ts +9 -0
  462. package/dist/vue/useVoiceCallDebugger.d.ts +10 -0
  463. package/dist/vue/useVoiceCampaignDialerProof.d.ts +11 -0
  464. package/dist/vue/useVoiceController.d.ts +10 -7
  465. package/dist/vue/useVoiceDeliveryRuntime.d.ts +13 -0
  466. package/dist/vue/useVoiceLiveOps.d.ts +9 -0
  467. package/dist/vue/useVoiceOpsActionCenter.d.ts +11 -0
  468. package/dist/vue/useVoiceOpsStatus.d.ts +9 -0
  469. package/dist/vue/useVoicePlatformCoverage.d.ts +9 -0
  470. package/dist/vue/useVoiceProfileComparison.d.ts +9 -0
  471. package/dist/vue/useVoiceProofTrends.d.ts +9 -0
  472. package/dist/vue/useVoiceProviderCapabilities.d.ts +3 -3
  473. package/dist/vue/useVoiceProviderContracts.d.ts +9 -0
  474. package/dist/vue/useVoiceProviderSimulationControls.d.ts +2 -2
  475. package/dist/vue/useVoiceProviderStatus.d.ts +3 -3
  476. package/dist/vue/useVoiceReadinessFailures.d.ts +959 -0
  477. package/dist/vue/useVoiceReconnectProfileEvidence.d.ts +9 -0
  478. package/dist/vue/useVoiceRoutingStatus.d.ts +2 -2
  479. package/dist/vue/useVoiceSessionObservability.d.ts +9 -0
  480. package/dist/vue/useVoiceSessionSnapshot.d.ts +10 -0
  481. package/dist/vue/useVoiceStream.d.ts +10 -6
  482. package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
  483. package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
  484. package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
  485. package/dist/vue/useVoiceWorkflowStatus.d.ts +3 -3
  486. package/package.json +247 -256
  487. package/dist/angular/voice-app-kit-status.service.d.ts +0 -12
  488. package/dist/angular/voice-ops-status.component.d.ts +0 -15
  489. package/dist/appKit.d.ts +0 -94
  490. package/dist/client/appKitStatus.d.ts +0 -19
  491. package/dist/react/useVoiceAppKitStatus.d.ts +0 -8
  492. package/dist/svelte/createVoiceAppKitStatus.d.ts +0 -8
  493. package/dist/turnProfiles.d.ts +0 -6
  494. package/dist/types.d.ts +0 -968
  495. package/dist/vue/useVoiceAppKitStatus.d.ts +0 -9
  496. package/fixtures/README.md +0 -57
  497. package/fixtures/manifest.json +0 -199
  498. package/fixtures/pcm/dialogue-three-clean.pcm +0 -0
  499. package/fixtures/pcm/dialogue-three-mixed.pcm +0 -0
  500. package/fixtures/pcm/dialogue-two-clean.pcm +0 -0
  501. package/fixtures/pcm/dialogue-two-noisy.pcm +0 -0
  502. package/fixtures/pcm/multiturn-three-mixed.pcm +0 -0
  503. package/fixtures/pcm/multiturn-two-clean.pcm +0 -0
  504. package/fixtures/pcm/quietly-alone-clean.pcm +0 -0
  505. package/fixtures/pcm/rainstorms-noisy.pcm +0 -0
  506. package/fixtures/pcm/stella-bulgaria-bulgarian20.pcm +0 -0
  507. package/fixtures/pcm/stella-ghana-english507.pcm +0 -0
  508. package/fixtures/pcm/stella-india-english37.pcm +0 -0
  509. package/fixtures/pcm/stella-jamaica-jamaican-creole-english1.pcm +0 -0
  510. package/fixtures/pcm/stella-liberia-liberian-pidgin-english2.pcm +0 -0
  511. package/fixtures/pcm/stella-pakistan-english519.pcm +0 -0
  512. package/fixtures/pcm/stella-sierra-leone-krio5.pcm +0 -0
  513. package/fixtures/pcm/stella-singapore-english655.pcm +0 -0
  514. package/fixtures/pcm/traveled-back-route-clean.pcm +0 -0
@@ -0,0 +1,1755 @@
1
+ import type { MediaWebRTCStatsCollector, MediaWebRTCStatsReport, MediaWebRTCStatsReportInput, MediaWebRTCStreamContinuityInput, MediaWebRTCStreamContinuityReport } from "@absolutejs/media";
2
+ import type { VoiceOpsDispositionTaskPolicies, VoiceOpsTaskAssignmentRule, VoiceOpsTaskAssignmentRules, VoiceIntegrationWebhookConfig, StoredVoiceIntegrationEvent, StoredVoiceOpsTask, VoiceIntegrationEventStore, VoiceOpsTaskPolicy, VoiceOpsTask, VoiceOpsTaskStore } from "./ops";
3
+ import type { VoiceIntegrationSink } from "./opsSinks";
4
+ import type { StoredVoiceCallReviewArtifact, VoiceCallReviewArtifact, VoiceCallReviewStore } from "../testing/review";
5
+ import type { VoiceTraceEventStore } from "./trace";
6
+ import type { VoiceLiveOpsControlState } from "./liveOps";
7
+ import type { VoiceAuditActor, VoiceAuditEventStore } from "./audit";
8
+ import type { VoiceProfileSwitchGuardDecision, VoiceProfileSwitchGuardMode, VoiceProfileSwitchObservedSignals } from "./profileSwitchRecommendation";
9
+ import type { VoiceRealCallProfileDefaultsReport, VoiceRealCallProfileHistoryReport } from "./proofTrends";
10
+ export type AudioFormat = {
11
+ container: "raw";
12
+ encoding: "alaw" | "mulaw" | "pcm_s16le";
13
+ sampleRateHz: number;
14
+ channels: 1 | 2;
15
+ };
16
+ export type AudioChunk = ArrayBuffer | ArrayBufferView;
17
+ /**
18
+ * Structural contract for an inbound noise suppressor applied before STT.
19
+ * Matches `@absolutejs/media`'s `NoiseSuppressor`, so any media suppressor
20
+ * (`createFFmpegNoiseSuppressor`, `createEnergyGateNoiseSuppressor`, a Krisp
21
+ * adapter, etc.) satisfies it without a hard import.
22
+ */
23
+ export type VoiceNoiseSuppressor = {
24
+ readonly kind: string;
25
+ process: (input: {
26
+ format: AudioFormat;
27
+ pcm: ArrayBuffer | ArrayBufferView;
28
+ }) => Promise<{
29
+ bytes: Uint8Array;
30
+ format: AudioFormat;
31
+ }> | {
32
+ bytes: Uint8Array;
33
+ format: AudioFormat;
34
+ };
35
+ close?: () => Promise<void> | void;
36
+ };
37
+ export type VoiceLanguageStrategy = {
38
+ mode: "auto-detect";
39
+ allowedLanguages?: string[];
40
+ } | {
41
+ mode: "fixed";
42
+ primaryLanguage: string;
43
+ secondaryLanguages?: string[];
44
+ } | {
45
+ mode: "allow-switching";
46
+ primaryLanguage?: string;
47
+ secondaryLanguages: string[];
48
+ };
49
+ export type VoiceLanguageStrategyResolver<TContext = unknown> = (input: {
50
+ context: TContext;
51
+ scenarioId?: string;
52
+ sessionId: string;
53
+ }) => Promise<VoiceLanguageStrategy | void> | VoiceLanguageStrategy | void;
54
+ export type VoicePhraseHint = {
55
+ text: string;
56
+ aliases?: string[];
57
+ boost?: number;
58
+ metadata?: Record<string, unknown>;
59
+ };
60
+ export type VoiceCorrectionRiskTier = "safe" | "balanced" | "risky";
61
+ export type VoiceDomainTerm = {
62
+ text: string;
63
+ aliases?: string[];
64
+ boost?: number;
65
+ language?: string;
66
+ metadata?: Record<string, unknown>;
67
+ pronunciation?: string;
68
+ };
69
+ export type VoiceLexiconEntry = {
70
+ text: string;
71
+ aliases?: string[];
72
+ language?: string;
73
+ metadata?: Record<string, unknown>;
74
+ pronunciation?: string;
75
+ };
76
+ export type VoiceTranscriptSentiment = {
77
+ label: "negative" | "neutral" | "positive" | (string & {});
78
+ metadata?: Record<string, unknown>;
79
+ score?: number;
80
+ };
81
+ /** A provider-normalized word hypothesis. Keeping this evidence attached to the
82
+ * transcript lets applications detect a single risky name or number that would
83
+ * otherwise disappear inside a high turn-level average confidence. */
84
+ export type TranscriptWord = {
85
+ confidence?: number;
86
+ endedAtMs?: number;
87
+ language?: string;
88
+ punctuatedText?: string;
89
+ speaker?: string | number;
90
+ startedAtMs?: number;
91
+ text: string;
92
+ };
93
+ /** Provider token evidence. Tokens are intentionally kept separate from words:
94
+ * subword log probabilities are useful for calibration and routing, but are not
95
+ * word-level timestamps or confidence scores. */
96
+ export type TranscriptToken = {
97
+ bytes?: number[];
98
+ confidence?: number;
99
+ logProbability?: number;
100
+ text: string;
101
+ };
102
+ export type Transcript = {
103
+ id: string;
104
+ text: string;
105
+ isFinal: boolean;
106
+ confidence?: number;
107
+ language?: string;
108
+ sentiment?: VoiceTranscriptSentiment;
109
+ speaker?: string | number;
110
+ startedAtMs?: number;
111
+ endedAtMs?: number;
112
+ vendor?: string;
113
+ tokens?: TranscriptToken[];
114
+ words?: TranscriptWord[];
115
+ };
116
+ export type VoiceSTTSessionConfiguration = {
117
+ languageHints?: string[];
118
+ lexicon?: VoiceLexiconEntry[];
119
+ phraseHints?: VoicePhraseHint[];
120
+ turnDetection?: Partial<VoiceTurnDetectionConfig>;
121
+ };
122
+ export type VoiceTranscriptQuality = {
123
+ averageConfidence?: number;
124
+ confidenceSampleCount: number;
125
+ correction?: VoiceTurnCorrectionDiagnostics;
126
+ cost?: VoiceTurnCostEstimate;
127
+ fallbackUsed: boolean;
128
+ finalTranscriptCount: number;
129
+ fallback?: VoiceFallbackDiagnostics;
130
+ partialTranscriptCount: number;
131
+ selectedTranscriptCount: number;
132
+ source: "fallback" | "primary";
133
+ lowestWordConfidence?: number;
134
+ wordConfidenceSampleCount?: number;
135
+ };
136
+ export type VoiceTurnCorrectionDiagnostics = {
137
+ attempted: boolean;
138
+ changed: boolean;
139
+ correctedText: string;
140
+ metadata?: Record<string, unknown>;
141
+ originalText: string;
142
+ provider?: string;
143
+ reason?: string;
144
+ };
145
+ export type VoiceTurnCostEstimate = {
146
+ estimatedRelativeCostUnits: number;
147
+ fallbackAttemptCount: number;
148
+ fallbackReplayAudioMs: number;
149
+ primaryAudioMs: number;
150
+ totalBillableAudioMs: number;
151
+ };
152
+ export type VoiceFallbackSelectionReason = "fallback-empty" | "primary-empty" | "word-count-margin" | "confidence-margin" | "word-count-tiebreak" | "policy-preference" | "kept-primary";
153
+ export type VoiceFallbackDiagnostics = {
154
+ attempted: boolean;
155
+ fallbackConfidence?: number;
156
+ fallbackText?: string;
157
+ fallbackWordCount?: number;
158
+ primaryConfidence: number;
159
+ primaryText: string;
160
+ primaryWordCount: number;
161
+ selected: boolean;
162
+ selectionReason: VoiceFallbackSelectionReason;
163
+ trigger: "empty-turn" | "low-confidence" | "empty-or-low-confidence" | "always";
164
+ triggerReason?: VoiceFallbackTriggerReason;
165
+ };
166
+ export type VoicePartialEvent = {
167
+ type: "partial";
168
+ transcript: Transcript;
169
+ receivedAt: number;
170
+ };
171
+ export type VoiceFinalEvent = {
172
+ type: "final";
173
+ transcript: Transcript;
174
+ receivedAt: number;
175
+ };
176
+ export type VoiceEndOfTurnEvent = {
177
+ type: "endOfTurn";
178
+ reason: "vendor" | "silence" | "manual";
179
+ receivedAt: number;
180
+ };
181
+ export type VoiceErrorEvent = {
182
+ type: "error";
183
+ error: Error;
184
+ recoverable: boolean;
185
+ code?: string;
186
+ };
187
+ export type VoiceCloseEvent = {
188
+ type: "close";
189
+ code?: number;
190
+ reason?: string;
191
+ recoverable?: boolean;
192
+ };
193
+ export type STTSessionEventMap = {
194
+ partial: VoicePartialEvent;
195
+ final: VoiceFinalEvent;
196
+ endOfTurn: VoiceEndOfTurnEvent;
197
+ error: VoiceErrorEvent;
198
+ close: VoiceCloseEvent;
199
+ };
200
+ export type STTAdapterSession = {
201
+ on: <K extends keyof STTSessionEventMap>(event: K, handler: (payload: STTSessionEventMap[K]) => void | Promise<void>) => () => void;
202
+ send: (audio: AudioChunk) => Promise<void>;
203
+ /** Update provider-supported STT context without restarting the stream. */
204
+ configure?: (configuration: VoiceSTTSessionConfiguration) => Promise<void>;
205
+ close: (reason?: string) => Promise<void>;
206
+ };
207
+ export type STTAdapterOpenOptions = {
208
+ sessionId: string;
209
+ format: AudioFormat;
210
+ languageStrategy?: VoiceLanguageStrategy;
211
+ lexicon?: VoiceLexiconEntry[];
212
+ phraseHints?: VoicePhraseHint[];
213
+ signal?: AbortSignal;
214
+ };
215
+ export type STTAdapter<TOptions extends STTAdapterOpenOptions = STTAdapterOpenOptions> = {
216
+ kind: "stt";
217
+ open: (options: TOptions) => Promise<STTAdapterSession> | STTAdapterSession;
218
+ };
219
+ export type TTSAudioEvent = {
220
+ type: "audio";
221
+ chunk: AudioChunk;
222
+ format: AudioFormat;
223
+ receivedAt: number;
224
+ };
225
+ export type TTSSessionEventMap = {
226
+ audio: TTSAudioEvent;
227
+ error: VoiceErrorEvent;
228
+ close: VoiceCloseEvent;
229
+ };
230
+ export type TTSAdapterSession = {
231
+ on: <K extends keyof TTSSessionEventMap>(event: K, handler: (payload: TTSSessionEventMap[K]) => void | Promise<void>) => () => void;
232
+ send: (text: string) => Promise<void>;
233
+ cancel?: (reason?: string) => Promise<void>;
234
+ close: (reason?: string) => Promise<void>;
235
+ };
236
+ export declare const ttsAdapterSessionCanCancel: (session: TTSAdapterSession) => session is TTSAdapterSession & {
237
+ cancel: (reason?: string) => Promise<void>;
238
+ };
239
+ export type VoiceTTSProsody = {
240
+ emphasis?: number;
241
+ pitch?: number;
242
+ speed?: number;
243
+ style?: string;
244
+ };
245
+ export type TTSAdapterOpenOptions = {
246
+ sessionId: string;
247
+ lexicon?: VoiceLexiconEntry[];
248
+ prosody?: VoiceTTSProsody;
249
+ signal?: AbortSignal;
250
+ };
251
+ export type TTSAdapter<TOptions extends TTSAdapterOpenOptions = TTSAdapterOpenOptions> = {
252
+ kind: "tts";
253
+ open: (options: TOptions) => Promise<TTSAdapterSession> | TTSAdapterSession;
254
+ };
255
+ export type RealtimeSessionEventMap = STTSessionEventMap & {
256
+ audio: TTSAudioEvent;
257
+ };
258
+ export type RealtimeAdapterSession = {
259
+ on: <K extends keyof RealtimeSessionEventMap>(event: K, handler: (payload: RealtimeSessionEventMap[K]) => void | Promise<void>) => () => void;
260
+ send: (input: AudioChunk | string) => Promise<void>;
261
+ /** Update provider-supported input transcription context in place. */
262
+ configure?: (configuration: VoiceSTTSessionConfiguration) => Promise<void>;
263
+ close: (reason?: string) => Promise<void>;
264
+ };
265
+ export type RealtimeAdapterOpenOptions = {
266
+ sessionId: string;
267
+ format: AudioFormat;
268
+ languageStrategy?: VoiceLanguageStrategy;
269
+ lexicon?: VoiceLexiconEntry[];
270
+ modalities?: ReadonlyArray<"audio" | "text">;
271
+ phraseHints?: VoicePhraseHint[];
272
+ promptCacheKey?: string;
273
+ semanticVAD?: import("./assistantMode").VoiceSemanticVADConfig;
274
+ signal?: AbortSignal;
275
+ };
276
+ export type RealtimeAdapter<TOptions extends RealtimeAdapterOpenOptions = RealtimeAdapterOpenOptions> = {
277
+ kind: "realtime";
278
+ open: (options: TOptions) => Promise<RealtimeAdapterSession> | RealtimeAdapterSession;
279
+ };
280
+ export type VoiceSessionStatus = "active" | "reconnecting" | "completed" | "failed";
281
+ export type VoiceReconnectClientStatus = "idle" | "reconnecting" | "resumed" | "exhausted";
282
+ export type VoiceReconnectClientState = {
283
+ attempts: number;
284
+ lastDisconnectAt?: number;
285
+ lastResumedAt?: number;
286
+ maxAttempts: number;
287
+ nextAttemptAt?: number;
288
+ status: VoiceReconnectClientStatus;
289
+ };
290
+ export type VoiceTurnCitation = {
291
+ chunkId: string;
292
+ score: number;
293
+ source?: string;
294
+ title?: string;
295
+ };
296
+ export type VoiceTurnRecord<TResult = unknown> = {
297
+ id: string;
298
+ text: string;
299
+ quality?: VoiceTranscriptQuality;
300
+ transcripts: Transcript[];
301
+ assistantText?: string;
302
+ attachments?: import("./agent").VoiceAgentMessageAttachment[];
303
+ citations?: VoiceTurnCitation[];
304
+ committedAt: number;
305
+ result?: TResult;
306
+ };
307
+ export type VoiceCostTelemetryConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
308
+ fallbackPassCostUnit?: number;
309
+ onTurnCost?: (input: {
310
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
311
+ context: TContext;
312
+ estimate: VoiceTurnCostEstimate;
313
+ session: TSession;
314
+ turn: VoiceTurnRecord<TResult>;
315
+ }) => Promise<void> | void;
316
+ primaryPassCostUnit?: number;
317
+ };
318
+ export type VoiceSessionRecord<TMeta = Record<string, never>, TResult = unknown> = {
319
+ id: string;
320
+ createdAt: number;
321
+ /** Persisted before the initial assistant greeting is emitted so reconnects
322
+ * cannot replay the full introduction when the caller has not answered yet. */
323
+ greetingDeliveredAt?: number;
324
+ lastActivityAt?: number;
325
+ status: VoiceSessionStatus;
326
+ transcripts: Transcript[];
327
+ currentTurn: {
328
+ transcripts: Transcript[];
329
+ partialText: string;
330
+ partialStartedAt?: number;
331
+ partialEndedAt?: number;
332
+ finalText: string;
333
+ lastAudioAt?: number;
334
+ lastSpeechAt?: number;
335
+ lastTranscriptAt?: number;
336
+ silenceStartedAt?: number;
337
+ };
338
+ turns: VoiceTurnRecord<TResult>[];
339
+ committedTurnIds: string[];
340
+ reconnect: {
341
+ attempts: number;
342
+ lastDisconnectAt?: number;
343
+ };
344
+ /** Durable caller pause state so a reconnect or process replacement restores
345
+ * the remaining pause window instead of rearming conversation watchdogs. */
346
+ pause?: {
347
+ expiresAt: number;
348
+ pausedAt: number;
349
+ };
350
+ lastCommittedTurn?: {
351
+ signature: string;
352
+ text: string;
353
+ transcriptIds: string[];
354
+ committedAt: number;
355
+ };
356
+ call?: VoiceCallLifecycleState;
357
+ metadata?: TMeta;
358
+ scenarioId?: string;
359
+ };
360
+ export type VoiceSessionSummary = {
361
+ id: string;
362
+ createdAt: number;
363
+ lastActivityAt?: number;
364
+ status: VoiceSessionStatus;
365
+ turnCount: number;
366
+ };
367
+ export type VoiceCallDisposition = "completed" | "transferred" | "escalated" | "voicemail" | "no-answer" | "failed" | "silence-timeout" | "closed";
368
+ export type VoiceCallLifecycleEvent = {
369
+ at: number;
370
+ type: "start" | "end" | "transfer" | "escalation" | "voicemail" | "no-answer";
371
+ disposition?: VoiceCallDisposition;
372
+ metadata?: Record<string, unknown>;
373
+ reason?: string;
374
+ target?: string;
375
+ };
376
+ export type VoiceCallLifecycleState = {
377
+ disposition?: VoiceCallDisposition;
378
+ endedAt?: number;
379
+ events: VoiceCallLifecycleEvent[];
380
+ lastEventAt: number;
381
+ startedAt: number;
382
+ };
383
+ export type VoiceHandoffAction = "escalate" | "no-answer" | "transfer" | "voicemail";
384
+ export type VoiceHandoffStatus = "delivered" | "failed" | "skipped";
385
+ export type VoiceHandoffResult = {
386
+ deliveredAt?: number;
387
+ deliveredTo?: string;
388
+ error?: string;
389
+ metadata?: Record<string, unknown>;
390
+ status: VoiceHandoffStatus;
391
+ };
392
+ export type VoiceHandoffDeliveryQueueStatus = VoiceHandoffStatus | "pending";
393
+ export type StoredVoiceHandoffDelivery<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
394
+ action: VoiceHandoffAction;
395
+ context: TContext;
396
+ createdAt: number;
397
+ deliveredAt?: number;
398
+ deliveries?: Record<string, VoiceHandoffResult & {
399
+ adapterId: string;
400
+ adapterKind?: string;
401
+ }>;
402
+ deliveryAttempts?: number;
403
+ deliveryError?: string;
404
+ deliveryStatus: VoiceHandoffDeliveryQueueStatus;
405
+ id: string;
406
+ metadata?: Record<string, unknown>;
407
+ reason?: string;
408
+ result?: TResult;
409
+ session: TSession;
410
+ sessionId: string;
411
+ target?: string;
412
+ updatedAt: number;
413
+ };
414
+ export type VoiceHandoffDeliveryStore<TDelivery extends StoredVoiceHandoffDelivery = StoredVoiceHandoffDelivery> = {
415
+ get: (id: string) => Promise<TDelivery | undefined> | TDelivery | undefined;
416
+ list: () => Promise<TDelivery[]> | TDelivery[];
417
+ remove: (id: string) => Promise<void> | void;
418
+ set: (id: string, delivery: TDelivery) => Promise<void> | void;
419
+ };
420
+ export type VoiceHandoffInput<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
421
+ action: VoiceHandoffAction;
422
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
423
+ context: TContext;
424
+ metadata?: Record<string, unknown>;
425
+ reason?: string;
426
+ result?: TResult;
427
+ session: TSession;
428
+ target?: string;
429
+ };
430
+ export type VoiceHandoffAdapter<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
431
+ actions?: VoiceHandoffAction[];
432
+ handoff: (input: VoiceHandoffInput<TContext, TSession, TResult>) => Promise<VoiceHandoffResult> | VoiceHandoffResult;
433
+ id: string;
434
+ kind?: string;
435
+ };
436
+ export type VoiceHandoffConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
437
+ adapters: VoiceHandoffAdapter<TContext, TSession, TResult>[];
438
+ deliveryQueue?: VoiceHandoffDeliveryStore<StoredVoiceHandoffDelivery<TContext, TSession, TResult>>;
439
+ enqueueOnly?: boolean;
440
+ failMode?: "record" | "throw";
441
+ };
442
+ export type VoiceSessionStore<TSession extends VoiceSessionRecord = VoiceSessionRecord> = {
443
+ get: (id: string) => Promise<TSession | undefined>;
444
+ getOrCreate: (id: string) => Promise<TSession>;
445
+ set: (id: string, value: TSession) => Promise<void>;
446
+ list: () => Promise<VoiceSessionSummary[]>;
447
+ remove: (id: string) => Promise<void>;
448
+ };
449
+ export type VoiceLogger = {
450
+ debug?: (message: string, meta?: Record<string, unknown>) => void;
451
+ info?: (message: string, meta?: Record<string, unknown>) => void;
452
+ warn?: (message: string, meta?: Record<string, unknown>) => void;
453
+ error?: (message: string, meta?: Record<string, unknown>) => void;
454
+ };
455
+ export type VoiceReconnectConfig = {
456
+ strategy?: "resume-last-turn" | "restart" | "fail";
457
+ timeout?: number;
458
+ maxAttempts?: number;
459
+ };
460
+ export type VoiceRuntimePreset = "default" | "chat" | "guided-intake" | "dictation" | "noisy-room" | "pstn-balanced" | "pstn-fast" | "reliability";
461
+ export type VoiceSTTLifecycle = "continuous" | "turn-scoped";
462
+ export type VoiceTurnProfile = "fast" | "balanced" | "long-form";
463
+ export type VoiceTurnQualityProfile = "general" | "accent-heavy" | "noisy-room" | "short-command";
464
+ export type VoiceTurnFallbackTrigger = "empty-turn" | "low-confidence" | "empty-or-low-confidence" | "always";
465
+ export type VoiceFallbackTriggerReason = "always" | "empty-turn" | "risk-policy" | "transcript-confidence" | "word-confidence";
466
+ export type VoiceSTTFallbackCandidate = {
467
+ averageConfidence: number;
468
+ lowestWordConfidence?: number;
469
+ text: string;
470
+ transcripts: Transcript[];
471
+ wordCount: number;
472
+ words: TranscriptWord[];
473
+ };
474
+ export type VoiceSTTFallbackRiskPolicy = (candidate: VoiceSTTFallbackCandidate) => boolean;
475
+ export type VoiceSTTFallbackConfig = {
476
+ adapter: STTAdapter;
477
+ trigger?: VoiceTurnFallbackTrigger;
478
+ confidenceThreshold?: number;
479
+ minTextLength?: number;
480
+ replayWindowMs?: number;
481
+ settleMs?: number;
482
+ completionTimeoutMs?: number;
483
+ maxAttemptsPerTurn?: number;
484
+ /** Run the fallback when any provider word falls below this value. */
485
+ wordConfidenceThreshold?: number;
486
+ /** Application-specific routing for high-value turns, entities, or correction
487
+ * language that should receive a second transcription pass regardless of the
488
+ * aggregate confidence. */
489
+ riskPolicy?: VoiceSTTFallbackRiskPolicy;
490
+ /** Prefer a non-empty independent fallback for these audited trigger reasons,
491
+ * including providers that do not expose comparable confidence scores. */
492
+ preferFallbackOn?: VoiceFallbackTriggerReason[];
493
+ };
494
+ export type VoiceResolvedSTTFallbackConfig = {
495
+ adapter: STTAdapter;
496
+ trigger: VoiceTurnFallbackTrigger;
497
+ confidenceThreshold: number;
498
+ minTextLength: number;
499
+ replayWindowMs: number;
500
+ settleMs: number;
501
+ completionTimeoutMs: number;
502
+ maxAttemptsPerTurn: number;
503
+ wordConfidenceThreshold?: number;
504
+ riskPolicy?: VoiceSTTFallbackRiskPolicy;
505
+ preferFallbackOn?: VoiceFallbackTriggerReason[];
506
+ };
507
+ export type VoiceTurnDetectionConfig = {
508
+ profile?: VoiceTurnProfile;
509
+ qualityProfile?: VoiceTurnQualityProfile;
510
+ silenceMs?: number;
511
+ minSilenceMs?: number;
512
+ speechThreshold?: number;
513
+ transcriptStabilityMs?: number;
514
+ };
515
+ export type VoiceResolvedTurnDetectionConfig = {
516
+ qualityProfile: VoiceTurnQualityProfile;
517
+ profile: VoiceTurnProfile;
518
+ silenceMs: number;
519
+ minSilenceMs: number;
520
+ speechThreshold: number;
521
+ transcriptStabilityMs: number;
522
+ };
523
+ export type VoiceAudioConditioningConfig = {
524
+ enabled?: boolean;
525
+ targetLevel?: number;
526
+ maxGain?: number;
527
+ noiseGateThreshold?: number;
528
+ noiseGateAttenuation?: number;
529
+ };
530
+ export type VoiceResolvedAudioConditioningConfig = {
531
+ enabled: true;
532
+ targetLevel: number;
533
+ maxGain: number;
534
+ noiseGateThreshold: number;
535
+ noiseGateAttenuation: number;
536
+ };
537
+ export type VoiceSocket = {
538
+ send: (data: string | Uint8Array | ArrayBuffer) => void | Promise<void>;
539
+ close: (code?: number, reason?: string) => void | Promise<void>;
540
+ /**
541
+ * Discard any audio already buffered downstream (e.g. a telephony carrier's
542
+ * outbound media buffer). Called on barge-in so the caller stops hearing the
543
+ * assistant immediately, even when frames have already been flushed to the
544
+ * transport. Optional: transports without a flush concept omit it.
545
+ */
546
+ clear?: () => void | Promise<void>;
547
+ };
548
+ export type VoiceMonitorRuntimeSessionBinding = {
549
+ deregister: (reason?: string) => void;
550
+ emitAudio: (chunk: Uint8Array | ArrayBuffer, options?: {
551
+ source?: "assistant" | "caller" | (string & {});
552
+ }) => void;
553
+ };
554
+ export type VoiceMonitorRuntimeRegisterInput = {
555
+ handle: VoiceSessionHandle<unknown, VoiceSessionRecord, unknown>;
556
+ metadata?: Record<string, unknown>;
557
+ sessionId: string;
558
+ };
559
+ export type VoiceMonitorRuntimeBinding = {
560
+ registerSession: (input: VoiceMonitorRuntimeRegisterInput) => VoiceMonitorRuntimeSessionBinding;
561
+ };
562
+ export type VoiceSessionHandle<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
563
+ id: string;
564
+ connect: (socket: VoiceSocket) => Promise<void>;
565
+ receiveAudio: (audio: AudioChunk) => Promise<void>;
566
+ attachUserMedia: (attachment: import("./agent").VoiceAgentMessageAttachment) => Promise<void>;
567
+ commitTurn: (reason?: VoiceEndOfTurnEvent["reason"]) => Promise<void>;
568
+ disconnect: (event?: VoiceCloseEvent) => Promise<void>;
569
+ complete: (result?: TResult) => Promise<void>;
570
+ escalate: (input: {
571
+ metadata?: Record<string, unknown>;
572
+ reason: string;
573
+ result?: TResult;
574
+ }) => Promise<void>;
575
+ fail: (error: unknown) => Promise<void>;
576
+ markNoAnswer: (input?: {
577
+ metadata?: Record<string, unknown>;
578
+ result?: TResult;
579
+ }) => Promise<void>;
580
+ markVoicemail: (input?: {
581
+ metadata?: Record<string, unknown>;
582
+ result?: TResult;
583
+ }) => Promise<void>;
584
+ transfer: (input: {
585
+ metadata?: Record<string, unknown>;
586
+ reason?: string;
587
+ result?: TResult;
588
+ target: string;
589
+ transferMode?: "cold" | "warm";
590
+ }) => Promise<void>;
591
+ close: (reason?: string) => Promise<void>;
592
+ /**
593
+ * Caller-driven in-call pause: the session stays LIVE (socket, state,
594
+ * transcript) but every idle/silence watchdog is suspended and turn
595
+ * processing is skipped, so a paused caller is never nudged or hung up on.
596
+ * Past `pause.maxMs` (default 10 min) the session closes gracefully with
597
+ * reason "pause-timeout" — completed turns stay durably persisted, so the
598
+ * host's normal draft/resume path takes over.
599
+ */
600
+ pause: () => Promise<void>;
601
+ /** Lift a caller-driven pause: watchdogs re-arm and turns process again. */
602
+ resume: () => Promise<void>;
603
+ snapshot: () => Promise<TSession>;
604
+ /**
605
+ * Mutate the live turn-detection config for this session — useful when a
606
+ * tool call wants to dial silenceMs up ("the caller asked for more time")
607
+ * or down. The change takes effect on the NEXT silence-timer schedule, so
608
+ * an in-flight commit isn't cancelled. Returns the merged config so the
609
+ * caller can confirm.
610
+ */
611
+ setTurnDetection: (patch: Partial<VoiceTurnDetectionConfig>) => Promise<{
612
+ silenceMs: number;
613
+ speechThreshold: number;
614
+ transcriptStabilityMs: number;
615
+ }>;
616
+ /** Refresh vocabulary, language hints, or provider turn settings while a
617
+ * call is active. Unsupported fields are ignored by the active adapter. */
618
+ configureSTT: (configuration: VoiceSTTSessionConfiguration) => Promise<void>;
619
+ };
620
+ export type VoiceLLMUsage = {
621
+ provider?: string;
622
+ model?: string;
623
+ inputTokens?: number;
624
+ outputTokens?: number;
625
+ cachedInputTokens?: number;
626
+ };
627
+ export type VoiceRouteResult<TResult = unknown> = {
628
+ complete?: boolean;
629
+ result?: TResult;
630
+ assistantText?: string;
631
+ usage?: VoiceLLMUsage;
632
+ citations?: ReadonlyArray<VoiceTurnCitation>;
633
+ transfer?: {
634
+ metadata?: Record<string, unknown>;
635
+ reason?: string;
636
+ target: string;
637
+ transferMode?: "cold" | "warm";
638
+ };
639
+ escalate?: {
640
+ metadata?: Record<string, unknown>;
641
+ reason: string;
642
+ };
643
+ voicemail?: {
644
+ metadata?: Record<string, unknown>;
645
+ };
646
+ noAnswer?: {
647
+ metadata?: Record<string, unknown>;
648
+ };
649
+ };
650
+ export type VoiceTurnCorrectionResult = string | {
651
+ text: string;
652
+ reason?: string;
653
+ provider?: string;
654
+ metadata?: Record<string, unknown>;
655
+ };
656
+ export type VoiceTurnCorrectionHandler<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = (input: {
657
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
658
+ context: TContext;
659
+ fallback?: VoiceFallbackDiagnostics;
660
+ lexicon: VoiceLexiconEntry[];
661
+ phraseHints: VoicePhraseHint[];
662
+ session: TSession;
663
+ text: string;
664
+ transcripts: Transcript[];
665
+ }) => Promise<VoiceTurnCorrectionResult | void> | VoiceTurnCorrectionResult | void;
666
+ export type VoicePhraseHintResolver<TContext = unknown> = (input: {
667
+ context: TContext;
668
+ scenarioId?: string;
669
+ sessionId: string;
670
+ }) => Promise<VoicePhraseHint[] | void> | VoicePhraseHint[] | void;
671
+ export type VoiceLexiconResolver<TContext = unknown> = (input: {
672
+ context: TContext;
673
+ scenarioId?: string;
674
+ sessionId: string;
675
+ }) => Promise<VoiceLexiconEntry[] | void> | VoiceLexiconEntry[] | void;
676
+ export type VoiceOnTurnObjectHandler<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = (input: {
677
+ context: TContext;
678
+ liveOps?: {
679
+ control: VoiceLiveOpsControlState;
680
+ injectedInstruction?: string;
681
+ };
682
+ onTextDelta?: (delta: string) => void;
683
+ session: TSession;
684
+ turn: VoiceTurnRecord;
685
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
686
+ speculativeReply?: {
687
+ text: string;
688
+ };
689
+ }) => Promise<VoiceRouteResult<TResult> | void> | VoiceRouteResult<TResult> | void;
690
+ export type VoiceOnTurnHandler<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceOnTurnObjectHandler<TContext, TSession, TResult> | ((session: TSession, turn: VoiceTurnRecord, api: VoiceSessionHandle<TContext, TSession, TResult>, context: TContext) => Promise<VoiceRouteResult<TResult> | void> | VoiceRouteResult<TResult> | void);
691
+ export type VoiceRouteConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
692
+ onCallStart?: (input: {
693
+ context: TContext;
694
+ session: TSession;
695
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
696
+ }) => Promise<void> | void;
697
+ onCallEnd?: (input: {
698
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
699
+ context: TContext;
700
+ disposition: VoiceCallDisposition;
701
+ metadata?: Record<string, unknown>;
702
+ reason?: string;
703
+ session: TSession;
704
+ target?: string;
705
+ }) => Promise<void> | void;
706
+ onSession?: (input: {
707
+ context: TContext;
708
+ session: TSession;
709
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
710
+ }) => Promise<void> | void;
711
+ /** Fires when a connect RESUMES an existing session (a reconnect, or a fresh
712
+ * process after a restart finding the session in a persistent store) instead
713
+ * of starting a new call — onCallStart/onSession do NOT fire on a resume.
714
+ * Use it to rebuild any per-session in-memory state (caller context, paced
715
+ * flags) that didn't survive the process, so the resumed call keeps the
716
+ * personalization the original had. Runs before the resume re-greeting. */
717
+ onResume?: (input: {
718
+ context: TContext;
719
+ session: TSession;
720
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
721
+ }) => Promise<void> | void;
722
+ correctTurn?: VoiceTurnCorrectionHandler<TContext, TSession, TResult>;
723
+ speculate?: (input: {
724
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
725
+ context: TContext;
726
+ session: TSession;
727
+ turn: VoiceTurnRecord;
728
+ signal?: AbortSignal;
729
+ }) => Promise<{
730
+ text: string;
731
+ } | null | void>;
732
+ onTurn: VoiceOnTurnHandler<TContext, TSession, TResult>;
733
+ onComplete: (input: {
734
+ context: TContext;
735
+ session: TSession;
736
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
737
+ }) => Promise<void> | void;
738
+ onError?: (input: {
739
+ context: TContext;
740
+ sessionId: string;
741
+ session?: TSession;
742
+ error: unknown;
743
+ api?: VoiceSessionHandle<TContext, TSession, TResult>;
744
+ }) => Promise<void> | void;
745
+ onEscalation?: (input: {
746
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
747
+ context: TContext;
748
+ metadata?: Record<string, unknown>;
749
+ reason: string;
750
+ session: TSession;
751
+ }) => Promise<void> | void;
752
+ onNoAnswer?: (input: {
753
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
754
+ context: TContext;
755
+ metadata?: Record<string, unknown>;
756
+ session: TSession;
757
+ }) => Promise<void> | void;
758
+ onTransfer?: (input: {
759
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
760
+ context: TContext;
761
+ metadata?: Record<string, unknown>;
762
+ reason?: string;
763
+ session: TSession;
764
+ target: string;
765
+ }) => Promise<void> | void;
766
+ onVoicemail?: (input: {
767
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
768
+ context: TContext;
769
+ metadata?: Record<string, unknown>;
770
+ session: TSession;
771
+ }) => Promise<void> | void;
772
+ };
773
+ export type VoiceRuntimeOpsConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
774
+ buildReview?: (input: {
775
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
776
+ context: TContext;
777
+ disposition: VoiceCallDisposition;
778
+ metadata?: Record<string, unknown>;
779
+ reason?: string;
780
+ result?: TResult;
781
+ session: TSession;
782
+ target?: string;
783
+ }) => Promise<VoiceCallReviewArtifact | StoredVoiceCallReviewArtifact | void> | VoiceCallReviewArtifact | StoredVoiceCallReviewArtifact | void;
784
+ createTaskFromReview?: (input: {
785
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
786
+ context: TContext;
787
+ disposition: VoiceCallDisposition;
788
+ review: StoredVoiceCallReviewArtifact;
789
+ session: TSession;
790
+ }) => Promise<Omit<VoiceOpsTask, "id"> | VoiceOpsTask | StoredVoiceOpsTask | null | void> | Omit<VoiceOpsTask, "id"> | VoiceOpsTask | StoredVoiceOpsTask | null | void;
791
+ resolveTaskPolicy?: (input: {
792
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
793
+ context: TContext;
794
+ disposition: VoiceCallDisposition;
795
+ metadata?: Record<string, unknown>;
796
+ reason?: string;
797
+ review?: StoredVoiceCallReviewArtifact;
798
+ session: TSession;
799
+ target?: string;
800
+ task: StoredVoiceOpsTask;
801
+ }) => Promise<VoiceOpsTaskPolicy | void> | VoiceOpsTaskPolicy | void;
802
+ resolveTaskAssignment?: (input: {
803
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
804
+ context: TContext;
805
+ disposition: VoiceCallDisposition;
806
+ metadata?: Record<string, unknown>;
807
+ reason?: string;
808
+ review?: StoredVoiceCallReviewArtifact;
809
+ session: TSession;
810
+ target?: string;
811
+ task: StoredVoiceOpsTask;
812
+ }) => Promise<VoiceOpsTaskAssignmentRule | void> | VoiceOpsTaskAssignmentRule | void;
813
+ taskAssignmentRules?: VoiceOpsTaskAssignmentRules;
814
+ taskPolicies?: VoiceOpsDispositionTaskPolicies;
815
+ events?: VoiceIntegrationEventStore;
816
+ onEvent?: (input: {
817
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
818
+ context: TContext;
819
+ event: StoredVoiceIntegrationEvent;
820
+ session: TSession;
821
+ }) => Promise<void> | void;
822
+ reviews?: VoiceCallReviewStore;
823
+ sinks?: VoiceIntegrationSink[];
824
+ tasks?: VoiceOpsTaskStore;
825
+ webhook?: VoiceIntegrationWebhookConfig;
826
+ };
827
+ export type VoiceLiveOpsRuntimeConfig = {
828
+ getControl: (sessionId: string) => Promise<VoiceLiveOpsControlState | null | undefined> | VoiceLiveOpsControlState | null | undefined;
829
+ };
830
+ export type VoiceProfileSwitchGuardResolverInput<TContext = unknown> = {
831
+ context: TContext;
832
+ scenarioId?: string;
833
+ sessionId: string;
834
+ };
835
+ export type VoicePluginProfileSwitchGuardConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
836
+ actor?: VoiceAuditActor;
837
+ allowedProfileIds?: string[] | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<string[] | undefined> | string[] | undefined);
838
+ audit?: VoiceAuditEventStore;
839
+ blockedProfileIds?: string[] | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<string[] | undefined> | string[] | undefined);
840
+ currentProfileId?: string | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<string | undefined> | string | undefined);
841
+ defaultProfileId?: string;
842
+ defaults: VoiceRealCallProfileDefaultsReport | VoiceRealCallProfileHistoryReport | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<VoiceRealCallProfileDefaultsReport | VoiceRealCallProfileHistoryReport> | VoiceRealCallProfileDefaultsReport | VoiceRealCallProfileHistoryReport);
843
+ metadata?: Record<string, unknown> | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<Record<string, unknown> | undefined> | Record<string, unknown> | undefined);
844
+ minConfidence?: number | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<number | undefined> | number | undefined);
845
+ maxAutoSwitchesPerSession?: number | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<number | undefined> | number | undefined);
846
+ mode?: VoiceProfileSwitchGuardMode | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<VoiceProfileSwitchGuardMode | undefined> | VoiceProfileSwitchGuardMode | undefined);
847
+ observed?: VoiceProfileSwitchObservedSignals | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<VoiceProfileSwitchObservedSignals | undefined> | VoiceProfileSwitchObservedSignals | undefined);
848
+ onDecision?: (input: {
849
+ context: TContext;
850
+ decision: VoiceProfileSwitchGuardDecision;
851
+ scenarioId?: string;
852
+ sessionId: string;
853
+ }) => Promise<void> | void;
854
+ sessionMetadataKey?: string | false;
855
+ trace?: false | VoiceTraceEventStore;
856
+ };
857
+ export type VoiceNormalizedRouteConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = Omit<VoiceRouteConfig<TContext, TSession, TResult>, "onTurn"> & {
858
+ onTurn: VoiceOnTurnObjectHandler<TContext, TSession, TResult>;
859
+ };
860
+ export type VoiceScenario = {
861
+ id: string;
862
+ name?: string;
863
+ description?: string;
864
+ metadata?: Record<string, unknown>;
865
+ };
866
+ export type VoiceExpectedSpeakerTurn = {
867
+ speaker: string;
868
+ text: string;
869
+ };
870
+ /**
871
+ * Configures one of the plugin's optional route surfaces. Pass that surface's
872
+ * options object to mount it, `false` (or omit) to leave it off. Surfaces whose
873
+ * options are entirely optional may also be enabled with `true` for defaults.
874
+ */
875
+ export type VoiceSurfaceConfig<O> = false | O | (Record<string, never> extends O ? true : never);
876
+ export type VoicePluginConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
877
+ costAccountant?: import("./costAccounting").VoiceCostAccountant;
878
+ costTelephony?: {
879
+ provider?: string;
880
+ };
881
+ costTelemetry?: VoiceCostTelemetryConfig<TContext, TSession, TResult>;
882
+ path: string;
883
+ /**
884
+ * Authorize a WebSocket before the plugin supersedes an existing session or
885
+ * creates provider-backed resources. Return false to close it with 4401.
886
+ * Applications can validate a short-lived admission credential from `query`
887
+ * without coupling Voice to a particular authentication implementation.
888
+ */
889
+ authorizeConnection?: (input: {
890
+ context: TContext;
891
+ headers: Headers;
892
+ path: string;
893
+ query: Record<string, unknown>;
894
+ scenarioId?: string;
895
+ sessionId: string;
896
+ }) => boolean | Promise<boolean>;
897
+ greeting?: string | ((input: {
898
+ session: TSession;
899
+ }) => string | Promise<string>);
900
+ resumeGreeting?: string | ((input: {
901
+ session: TSession;
902
+ }) => string | Promise<string>);
903
+ sttRecoveryLine?: string | ((input: {
904
+ session: TSession;
905
+ }) => string | Promise<string>);
906
+ stuckCallClose?: {
907
+ afterMs: number;
908
+ line?: string | ((input: {
909
+ session: TSession;
910
+ }) => string | Promise<string>);
911
+ reason?: string;
912
+ };
913
+ /** Gentle re-engagement before a silent call is given up on. When the caller
914
+ * makes no progress (no committed turn / user partial) for `afterMs`, the
915
+ * assistant speaks `line` ("still there?") instead of ending, and the close
916
+ * deadline (stuckCallClose) is pushed out — up to `maxReprompts` times (default
917
+ * 1). After the budget is spent the normal close path runs. Caller speech
918
+ * resets the budget. Assistant speech does NOT, so this can only extend a
919
+ * bounded amount. `afterMs` should be < stuckCallClose.afterMs so the nudge
920
+ * fires first. */
921
+ idleReprompt?: {
922
+ afterMs: number;
923
+ line: string | ((input: {
924
+ session: TSession;
925
+ }) => string | Promise<string>);
926
+ maxReprompts?: number;
927
+ };
928
+ languageStrategy?: VoiceLanguageStrategy | VoiceLanguageStrategyResolver<TContext>;
929
+ lexicon?: VoiceLexiconEntry[] | VoiceLexiconResolver<TContext>;
930
+ phraseHints?: VoicePhraseHint[] | VoicePhraseHintResolver<TContext>;
931
+ preset?: VoiceRuntimePreset;
932
+ stt?: STTAdapter;
933
+ sttFallback?: VoiceSTTFallbackConfig;
934
+ sttLifecycle?: VoiceSTTLifecycle;
935
+ realtime?: RealtimeAdapter;
936
+ realtimeInputFormat?: AudioFormat;
937
+ recording?: VoiceSessionRecordingConfig;
938
+ tts?: TTSAdapter;
939
+ session: VoiceSessionStore<NoInfer<TSession>>;
940
+ reconnect?: VoiceReconnectConfig;
941
+ turnDetection?: VoiceTurnDetectionConfig;
942
+ semanticTurnDetector?: import("./semanticTurn").VoiceSemanticTurnDetector;
943
+ bargeInDetector?: import("./bargeInDetector").VoiceBargeInDetector;
944
+ bargeInMinPartialWords?: number;
945
+ /**
946
+ * When true, a pure listening cue ("mm-hm", "yeah", "right", "got it") spoken
947
+ * WHILE the assistant is talking does NOT barge-in — the assistant keeps going
948
+ * and the cue is dropped so it never becomes the caller's next turn. A bare
949
+ * "yeah" said AFTER the assistant finishes is a normal answer, unaffected.
950
+ * Default false (any in-speech words interrupt, the prior behavior).
951
+ */
952
+ backchannelBargeInGuard?: boolean;
953
+ fillerPhrases?: ReadonlyArray<string>;
954
+ fillerDelayMs?: number;
955
+ fillerFor?: (input: {
956
+ sessionId: string;
957
+ turnId: string;
958
+ userText: string;
959
+ }) => Promise<string | null>;
960
+ fillerForTimeoutMs?: number;
961
+ backchannel?: import("./backchannel").VoiceBackchannelConfig;
962
+ defaultSilentTurnAck?: string;
963
+ routeOnTurnTimeoutMs?: number;
964
+ audioConditioning?: VoiceAudioConditioningConfig;
965
+ normalizeNumbers?: boolean;
966
+ noiseSuppressor?: VoiceNoiseSuppressor;
967
+ noiseSuppressorFormat?: AudioFormat;
968
+ logger?: VoiceLogger;
969
+ htmx?: boolean | VoiceHTMXConfig<TSession, NoInfer<TResult>>;
970
+ handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
971
+ ops?: VoiceRuntimeOpsConfig<TContext, TSession, TResult>;
972
+ liveOps?: VoiceLiveOpsRuntimeConfig;
973
+ monitor?: VoiceMonitorRuntimeBinding;
974
+ profileSwitchGuard?: VoicePluginProfileSwitchGuardConfig<TContext, TSession, TResult>;
975
+ trace?: VoiceTraceEventStore;
976
+ assistantHealth?: VoiceSurfaceConfig<import("./assistantHealth").VoiceAssistantHealthRoutesOptions>;
977
+ auditDelivery?: VoiceSurfaceConfig<import("./auditDeliveryRoutes").VoiceAuditDeliveryRoutesOptions>;
978
+ auditTrail?: VoiceSurfaceConfig<import("./auditRoutes").VoiceAuditTrailRoutesOptions>;
979
+ bargeIn?: VoiceSurfaceConfig<import("./bargeInRoutes").VoiceBargeInRoutesOptions>;
980
+ browserCallProfile?: VoiceSurfaceConfig<import("./browserCallProfiles").VoiceBrowserCallProfileRoutesOptions>;
981
+ browserMedia?: VoiceSurfaceConfig<import("./browserMediaRoutes").VoiceBrowserMediaRoutesOptions>;
982
+ callDebugger?: VoiceSurfaceConfig<import("./callDebugger").VoiceCallDebuggerRoutesOptions>;
983
+ campaign?: VoiceSurfaceConfig<import("./campaign").VoiceCampaignRoutesOptions>;
984
+ competitiveCoverage?: VoiceSurfaceConfig<import("./competitiveCoverage").VoiceCompetitiveCoverageRoutesOptions>;
985
+ dataControl?: VoiceSurfaceConfig<import("./dataControl").VoiceDataControlRoutesOptions>;
986
+ deliveryRuntime?: VoiceSurfaceConfig<import("./deliveryRuntime").VoiceDeliveryRuntimeRoutesOptions>;
987
+ deliverySink?: VoiceSurfaceConfig<import("./deliverySinkRoutes").VoiceDeliverySinkRoutesOptions>;
988
+ demoReady?: VoiceSurfaceConfig<import("./demoReadyRoutes").VoiceDemoReadyRoutesOptions>;
989
+ diagnostics?: VoiceSurfaceConfig<import("./diagnosticsRoutes").VoiceDiagnosticsRoutesOptions>;
990
+ eval?: VoiceSurfaceConfig<import("./evalRoutes").VoiceEvalRoutesOptions>;
991
+ guardrail?: VoiceSurfaceConfig<import("./guardrails").VoiceGuardrailRoutesOptions>;
992
+ handoffHealth?: VoiceSurfaceConfig<import("./handoffHealth").VoiceHandoffHealthRoutesOptions>;
993
+ htmxDashboard?: VoiceSurfaceConfig<import("./htmxDashboardRoutes").VoiceHTMXDashboardRoutesOptions>;
994
+ incidentBundle?: VoiceSurfaceConfig<import("./incidentBundle").VoiceIncidentBundleRoutesOptions>;
995
+ incidentTimeline?: VoiceSurfaceConfig<import("./incidentTimeline").VoiceIncidentTimelineRoutesOptions>;
996
+ liveLatency?: VoiceSurfaceConfig<import("./liveLatency").VoiceLiveLatencyRoutesOptions>;
997
+ liveMonitor?: VoiceSurfaceConfig<import("./monitor").VoiceLiveMonitorRoutesOptions>;
998
+ liveOpsConsole?: VoiceSurfaceConfig<import("./liveOps").VoiceLiveOpsRoutesOptions>;
999
+ mediaPipeline?: VoiceSurfaceConfig<import("./mediaPipelineRoutes").VoiceMediaPipelineRoutesOptions>;
1000
+ monitorReport?: VoiceSurfaceConfig<import("./voiceMonitoring").VoiceMonitorRoutesOptions>;
1001
+ monitorRunner?: VoiceSurfaceConfig<import("./voiceMonitoring").VoiceMonitorRunnerRoutesOptions>;
1002
+ observabilityExport?: VoiceSurfaceConfig<import("./observabilityExport").VoiceObservabilityExportRoutesOptions>;
1003
+ observabilityExportReplay?: VoiceSurfaceConfig<import("./observabilityExport").VoiceObservabilityExportReplayRoutesOptions>;
1004
+ operationalStatus?: VoiceSurfaceConfig<import("./operationalStatus").VoiceOperationalStatusRoutesOptions>;
1005
+ operationsRecord?: VoiceSurfaceConfig<import("./operationsRecord").VoiceOperationsRecordRoutesOptions>;
1006
+ opsActionAudit?: VoiceSurfaceConfig<import("./opsActionAuditRoutes").VoiceOpsActionAuditRoutesOptions>;
1007
+ opsConsole?: VoiceSurfaceConfig<import("./opsConsoleRoutes").VoiceOpsConsoleRoutesOptions>;
1008
+ opsRecovery?: VoiceSurfaceConfig<import("./opsRecovery").VoiceOpsRecoveryRoutesOptions>;
1009
+ opsStatus?: VoiceSurfaceConfig<import("./opsStatus").VoiceOpsStatusRoutesOptions>;
1010
+ opsWebhookReceiver?: VoiceSurfaceConfig<import("./opsWebhook").VoiceOpsWebhookReceiverRoutesOptions>;
1011
+ outcomeContract?: VoiceSurfaceConfig<import("./outcomeContract").VoiceOutcomeContractRoutesOptions>;
1012
+ phoneAgentProductionSmoke?: VoiceSurfaceConfig<import("./phoneAgentProductionSmoke").VoicePhoneAgentProductionSmokeRoutesOptions>;
1013
+ platformCoverage?: VoiceSurfaceConfig<import("./platformCoverage").VoicePlatformCoverageRoutesOptions>;
1014
+ postCallAnalysis?: VoiceSurfaceConfig<import("./postCallAnalysis").VoicePostCallAnalysisRoutesOptions>;
1015
+ productionReadiness?: VoiceSurfaceConfig<import("./productionReadiness").VoiceProductionReadinessRoutesOptions>;
1016
+ profileSwitchLiveDecision?: VoiceSurfaceConfig<import("./profileSwitchRecommendation").VoiceProfileSwitchLiveDecisionRoutesOptions>;
1017
+ profileSwitchPolicyProof?: VoiceSurfaceConfig<import("./profileSwitchRecommendation").VoiceProfileSwitchPolicyProofRoutesOptions>;
1018
+ profileSwitchReadiness?: VoiceSurfaceConfig<import("./profileSwitchRecommendation").VoiceProfileSwitchReadinessRoutesOptions>;
1019
+ proofPack?: VoiceSurfaceConfig<import("./proofPack").VoiceProofPackRoutesOptions>;
1020
+ proofTrend?: VoiceSurfaceConfig<import("./proofTrends").VoiceProofTrendRoutesOptions>;
1021
+ proofTrendRecommendation?: VoiceSurfaceConfig<import("./proofTrends").VoiceProofTrendRecommendationRoutesOptions>;
1022
+ providerCapability?: VoiceSurfaceConfig<import("./providerCapabilities").VoiceProviderCapabilityRoutesOptions>;
1023
+ providerContractMatrix?: VoiceSurfaceConfig<import("./providerStackRecommendations").VoiceProviderContractMatrixRoutesOptions>;
1024
+ providerDecisionTrace?: VoiceSurfaceConfig<import("./providerDecisionTraces").VoiceProviderDecisionTraceRoutesOptions>;
1025
+ providerHealth?: VoiceSurfaceConfig<import("./providerHealth").VoiceProviderHealthRoutesOptions>;
1026
+ providerOrchestration?: VoiceSurfaceConfig<import("./providerOrchestration").VoiceProviderOrchestrationRoutesOptions>;
1027
+ providerSlo?: VoiceSurfaceConfig<import("./providerSlo").VoiceProviderSloRoutesOptions>;
1028
+ quality?: VoiceSurfaceConfig<import("./qualityRoutes").VoiceQualityRoutesOptions>;
1029
+ realCallEvidenceRuntime?: VoiceSurfaceConfig<import("./proofTrends").VoiceRealCallEvidenceRuntimeRoutesOptions>;
1030
+ realCallProfileHistory?: VoiceSurfaceConfig<import("./proofTrends").VoiceRealCallProfileHistoryRoutesOptions>;
1031
+ realCallProfileRecoveryAction?: VoiceSurfaceConfig<import("./proofTrends").VoiceRealCallProfileRecoveryActionRoutesOptions>;
1032
+ realtimeChannel?: VoiceSurfaceConfig<import("./realtimeChannel").VoiceRealtimeChannelRoutesOptions>;
1033
+ realtimeProviderContract?: VoiceSurfaceConfig<import("./realtimeProviderContracts").VoiceRealtimeProviderContractRoutesOptions>;
1034
+ reconnectContract?: VoiceSurfaceConfig<import("./reconnectContract").VoiceReconnectContractRoutesOptions>;
1035
+ reconnectProof?: VoiceSurfaceConfig<import("./reconnectContract").VoiceReconnectProofRoutesOptions>;
1036
+ resilience?: VoiceSurfaceConfig<import("./resilienceRoutes").VoiceResilienceRoutesOptions>;
1037
+ sessionList?: VoiceSurfaceConfig<import("./sessionReplay").VoiceSessionListRoutesOptions>;
1038
+ sessionObservability?: VoiceSurfaceConfig<import("./sessionObservability").VoiceSessionObservabilityRoutesOptions>;
1039
+ sessionReplay?: VoiceSurfaceConfig<import("./sessionReplay").VoiceSessionReplayRoutesOptions>;
1040
+ sessionSnapshot?: VoiceSurfaceConfig<import("./sessionSnapshot").VoiceSessionSnapshotRoutesOptions>;
1041
+ simulationSuite?: VoiceSurfaceConfig<import("./simulationSuite").VoiceSimulationSuiteRoutesOptions>;
1042
+ sloCalibration?: VoiceSurfaceConfig<import("./sloCalibration").VoiceSloCalibrationRoutesOptions>;
1043
+ sloReadinessThreshold?: VoiceSurfaceConfig<import("./sloCalibration").VoiceSloReadinessThresholdRoutesOptions>;
1044
+ telephonyCarrierMatrix?: VoiceSurfaceConfig<import("../telephony/matrix").VoiceTelephonyCarrierMatrixRoutesOptions>;
1045
+ telephonyMedia?: VoiceSurfaceConfig<import("./telephonyMediaRoutes").VoiceTelephonyMediaRoutesOptions>;
1046
+ telephonyWebhook?: VoiceSurfaceConfig<import("./telephonyOutcome").VoiceTelephonyWebhookRoutesOptions>;
1047
+ telephonyWebhookSecurity?: VoiceSurfaceConfig<import("../telephony/security").VoiceTelephonyWebhookSecurityRoutesOptions>;
1048
+ toolContract?: VoiceSurfaceConfig<import("./toolContract").VoiceToolContractRoutesOptions>;
1049
+ traceDelivery?: VoiceSurfaceConfig<import("./traceDeliveryRoutes").VoiceTraceDeliveryRoutesOptions>;
1050
+ traceTimeline?: VoiceSurfaceConfig<import("./traceTimeline").VoiceTraceTimelineRoutesOptions>;
1051
+ turnLatency?: VoiceSurfaceConfig<import("./turnLatency").VoiceTurnLatencyRoutesOptions>;
1052
+ turnQuality?: VoiceSurfaceConfig<import("./turnQuality").VoiceTurnQualityRoutesOptions>;
1053
+ } & VoiceRouteConfig<TContext, TSession, TResult>;
1054
+ export type VoiceSessionRecordingConfig = {
1055
+ channels?: ReadonlyArray<"assistant" | "user">;
1056
+ maxBytesPerChannel?: number;
1057
+ store: import("./recordingStore").VoiceRecordingStore;
1058
+ userInputFormat?: AudioFormat;
1059
+ };
1060
+ export type CreateVoiceSessionOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
1061
+ costTelemetry?: VoiceCostTelemetryConfig<TContext, TSession, TResult>;
1062
+ id: string;
1063
+ context: TContext;
1064
+ socket: VoiceSocket;
1065
+ greeting?: string | ((input: {
1066
+ session: TSession;
1067
+ }) => string | Promise<string>);
1068
+ /** Spoken on a RESUME (reconnect / restart) of a call that already had at
1069
+ * least one committed turn — a short re-orientation ("Sorry, you cut out —
1070
+ * you were telling me about X; go on") so the caller knows they're back,
1071
+ * since the in-flight assistant audio didn't survive. Receives the session so
1072
+ * it can reference the last turn. No resume greeting fires if unset. */
1073
+ resumeGreeting?: string | ((input: {
1074
+ session: TSession;
1075
+ }) => string | Promise<string>);
1076
+ /** Spoken when the STT-health watchdog detects the stream has gone DEAF
1077
+ * mid-call (continuous speech energy, no transcripts landing — see
1078
+ * STT_HEALTH_STALE_MS). A short re-prompt ("Sorry, I think I missed that — go
1079
+ * ahead?") so the caller repeats into the freshly reconnected stream instead
1080
+ * of talking into a silently dead call. Cooldown-guarded to fire at most once
1081
+ * per stale episode. Receives the session. Unset = silent reconnect only. */
1082
+ sttRecoveryLine?: string | ((input: {
1083
+ session: TSession;
1084
+ }) => string | Promise<string>);
1085
+ /** Last-resort GRACEFUL terminal close for a wedged call. If no caller-side
1086
+ * progress (committed turn / user partial) lands for `afterMs` on a live call
1087
+ * — STT permanently deaf, or the caller left — the assistant speaks `line` and
1088
+ * the session COMPLETES (disposition "completed") so onComplete still saves and
1089
+ * the call ends with a real goodbye instead of dead air + "abandoned". Reset by
1090
+ * real progress (committed turn / user partial / (re)connect), NOT by the
1091
+ * assistant's own speech, so STT recovery re-prompts can't defer it forever. */
1092
+ stuckCallClose?: {
1093
+ afterMs: number;
1094
+ line?: string | ((input: {
1095
+ session: TSession;
1096
+ }) => string | Promise<string>);
1097
+ reason?: string;
1098
+ };
1099
+ /** Gentle re-engagement before a silent call is given up on. When the caller
1100
+ * makes no progress (no committed turn / user partial) for `afterMs`, the
1101
+ * assistant speaks `line` ("still there?") instead of ending, and the close
1102
+ * deadline (stuckCallClose) is pushed out — up to `maxReprompts` times (default
1103
+ * 1). After the budget is spent the normal close path runs. Caller speech
1104
+ * resets the budget. Assistant speech does NOT, so this can only extend a
1105
+ * bounded amount. `afterMs` should be < stuckCallClose.afterMs so the nudge
1106
+ * fires first. */
1107
+ idleReprompt?: {
1108
+ afterMs: number;
1109
+ line: string | ((input: {
1110
+ session: TSession;
1111
+ }) => string | Promise<string>);
1112
+ maxReprompts?: number;
1113
+ };
1114
+ /** Caller-driven in-call pause (VoiceSessionHandle.pause/resume). `maxMs`
1115
+ * bounds how long a session may sit paused before it closes gracefully
1116
+ * with reason "pause-timeout" (default 10 minutes). */
1117
+ pause?: {
1118
+ maxMs?: number;
1119
+ };
1120
+ stt?: STTAdapter;
1121
+ realtime?: RealtimeAdapter;
1122
+ realtimeInputFormat?: AudioFormat;
1123
+ tts?: TTSAdapter;
1124
+ languageStrategy?: VoiceLanguageStrategy;
1125
+ lexicon?: VoiceLexiconEntry[];
1126
+ sttFallback?: VoiceResolvedSTTFallbackConfig;
1127
+ store: VoiceSessionStore<TSession>;
1128
+ trace?: VoiceTraceEventStore;
1129
+ recording?: VoiceSessionRecordingConfig;
1130
+ callSilenceTimeoutMs?: number;
1131
+ amd?: import("./amdDetector").VoiceAMDDetector<TContext, TSession, TResult>;
1132
+ costAccountant?: import("./costAccounting").VoiceCostAccountant;
1133
+ costTelephony?: {
1134
+ provider?: string;
1135
+ };
1136
+ redact?: import("./redaction").VoiceTranscriptRedactor;
1137
+ semanticTurnDetector?: import("./semanticTurn").VoiceSemanticTurnDetector;
1138
+ bargeInDetector?: import("./bargeInDetector").VoiceBargeInDetector;
1139
+ /**
1140
+ * Pre-rendered filler phrases the runtime plays in the gap between
1141
+ * user-turn-commit and real assistant audio (typically 800-1500ms). The
1142
+ * caller hears something within ~150-300ms of stopping speaking, so the
1143
+ * LLM/TTS latency feels like the bot thinking instead of dead air. Boardy's
1144
+ * killer UX feature.
1145
+ *
1146
+ * Behavior:
1147
+ * - After a turn commits, a timer fires at `fillerDelayMs` (default
1148
+ * 250ms). At that point, if the real assistant audio for this turn
1149
+ * hasn't started flowing yet, a random phrase is rendered via the
1150
+ * configured `tts` adapter and pushed to the socket.
1151
+ * - When the real assistant audio's first chunk arrives, any in-flight
1152
+ * filler is cancelled (`cancelActiveTTS` clears the carrier buffer).
1153
+ * - Cooldown protects against double-fillers per turn.
1154
+ *
1155
+ * Set `fillerPhrases: []` (or omit) to disable. Reasonable defaults if
1156
+ * you enable: `["Hmm.", "Got it.", "Right.", "Mm-hm.", "Let me think.", "Okay."]`.
1157
+ */
1158
+ /**
1159
+ * Minimum word count in an STT partial transcript before speech-gated
1160
+ * barge-in cancels the in-flight assistant TTS. Default 1 (any non-empty
1161
+ * partial triggers barge-in — backwards-compatible).
1162
+ *
1163
+ * Set to 2 (or higher) on phone routes where the caller's brief
1164
+ * acknowledgements ("yeah", "uh-huh", "you", "am i") would otherwise
1165
+ * cut the bot off mid-question. Each extra word added typically delays
1166
+ * barge-in by ~100-200ms (one extra STT partial cycle) — cheap compared
1167
+ * to losing the bot's response.
1168
+ *
1169
+ * Word splitting is whitespace-based. Punctuation is left attached.
1170
+ */
1171
+ bargeInMinPartialWords?: number;
1172
+ /**
1173
+ * When true, a pure listening cue ("mm-hm", "yeah", "right", "got it") spoken
1174
+ * WHILE the assistant is talking does NOT barge-in — the assistant keeps going
1175
+ * and the cue is dropped so it never becomes the caller's next turn. A bare
1176
+ * "yeah" said AFTER the assistant finishes is a normal answer, unaffected.
1177
+ * Default false (any in-speech words interrupt, the prior behavior).
1178
+ */
1179
+ backchannelBargeInGuard?: boolean;
1180
+ fillerPhrases?: ReadonlyArray<string>;
1181
+ /** Milliseconds after turn-commit before the filler fires. Default 250ms — short enough to feel instant, long enough to skip if the LLM is very fast. */
1182
+ fillerDelayMs?: number;
1183
+ /**
1184
+ * Latency Theater — content-aware filler (Boardy parity move). When
1185
+ * defined, the runtime calls `fillerFor({ userText, ... })` in parallel
1186
+ * with the main LLM call to generate a brief acknowledgement of what the
1187
+ * caller just said ("Freelance CFOs — interesting.", "Yeah, I hear you.").
1188
+ * The runtime races the promise against `fillerForTimeoutMs` (default
1189
+ * 600ms). If `fillerFor` returns a non-empty string in time, it's spoken
1190
+ * INSTEAD of a random `fillerPhrases` entry. On timeout or null return,
1191
+ * the runtime falls back to a static random phrase, so a slow / failed
1192
+ * acknowledgement call never costs you the filler entirely.
1193
+ *
1194
+ * Return `null` (or an empty string) to explicitly skip filler for this
1195
+ * turn — useful when `userText` is so short ("yes", "no", "okay") that
1196
+ * acknowledging it back sounds robotic. Return throws are caught and
1197
+ * treated as null.
1198
+ *
1199
+ * Cost-aware: callers typically wire this to a cheap nano/haiku model
1200
+ * (gpt-4.1-nano, claude-haiku-4-5) that returns 2–5 words.
1201
+ */
1202
+ fillerFor?: (input: {
1203
+ sessionId: string;
1204
+ turnId: string;
1205
+ userText: string;
1206
+ }) => Promise<string | null>;
1207
+ /** Ceiling for the `fillerFor` call before we fall back to a static phrase. Default 600ms. */
1208
+ fillerForTimeoutMs?: number;
1209
+ /**
1210
+ * Backchannel cues — short "mm-hm"/"right" acknowledgements played while the
1211
+ * CALLER is mid-turn (a long answer) so they feel heard, the way a human
1212
+ * listener interjects. Plays on the same non-turn TTS path as fillers, so it
1213
+ * never registers as the assistant's turn or trips barge-in. Off unless
1214
+ * `enabled` is set. Fires only while the assistant is silent.
1215
+ */
1216
+ backchannel?: import("./backchannel").VoiceBackchannelConfig;
1217
+ /**
1218
+ * Default spoken ack if the model returns ONLY tool calls (no text) and the
1219
+ * turn isn't ending. Without this, the caller hears total silence after
1220
+ * their turn and assumes the line dropped. Default is "Sorry, one moment."
1221
+ * Set to "" to opt out entirely.
1222
+ */
1223
+ defaultSilentTurnAck?: string;
1224
+ /**
1225
+ * Hard timeout on a single `route.onTurn` call. If onTurn hasn't resolved
1226
+ * in this many ms, it's rejected with a hard-timeout error which falls
1227
+ * through to defaultSilentTurnAck. Default 45s — generous for normal
1228
+ * conversational LLM calls (1-3s typical), but catches hangs where the
1229
+ * model adapter's own timeout doesn't fire. Set to 0 to disable.
1230
+ */
1231
+ routeOnTurnTimeoutMs?: number;
1232
+ assistantMode?: import("./assistantMode").VoiceAssistantMode;
1233
+ modalities?: ReadonlyArray<"audio" | "text">;
1234
+ prosody?: VoiceTTSProsody;
1235
+ reconnect: Required<VoiceReconnectConfig>;
1236
+ phraseHints?: VoicePhraseHint[];
1237
+ sessionMetadata?: Record<string, unknown>;
1238
+ scenarioId?: string;
1239
+ sttLifecycle: VoiceSTTLifecycle;
1240
+ turnDetection: VoiceResolvedTurnDetectionConfig;
1241
+ audioConditioning?: VoiceResolvedAudioConditioningConfig;
1242
+ normalizeNumbers?: boolean;
1243
+ noiseSuppressor?: VoiceNoiseSuppressor;
1244
+ noiseSuppressorFormat?: AudioFormat;
1245
+ handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
1246
+ liveOps?: VoiceLiveOpsRuntimeConfig;
1247
+ route: VoiceNormalizedRouteConfig<TContext, TSession, TResult>;
1248
+ logger?: VoiceLogger;
1249
+ };
1250
+ export type CreateVoiceSession = <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(options: CreateVoiceSessionOptions<TContext, TSession, TResult>) => VoiceSessionHandle<TContext, TSession, TResult>;
1251
+ export type VoiceClientStartMessage = {
1252
+ type: "start";
1253
+ sessionId?: string;
1254
+ scenarioId?: string;
1255
+ };
1256
+ export type VoiceClientEndTurnMessage = {
1257
+ type: "end_turn";
1258
+ };
1259
+ export type VoiceClientCloseMessage = {
1260
+ type: "close";
1261
+ reason?: string;
1262
+ };
1263
+ export type VoiceClientCallControlMessage = {
1264
+ type: "call_control";
1265
+ requestId?: string;
1266
+ action: "complete" | "escalate" | "no-answer" | "pause" | "resume" | "transfer" | "voicemail";
1267
+ metadata?: Record<string, unknown>;
1268
+ reason?: string;
1269
+ target?: string;
1270
+ };
1271
+ export type VoiceServerCallControlAckMessage = {
1272
+ type: "call_control_ack";
1273
+ action: VoiceClientCallControlMessage["action"];
1274
+ message?: string;
1275
+ ok: boolean;
1276
+ requestId: string;
1277
+ };
1278
+ export type VoiceClientPingMessage = {
1279
+ type: "ping";
1280
+ };
1281
+ export type VoiceClientMessage = VoiceClientStartMessage | VoiceClientEndTurnMessage | VoiceClientCloseMessage | VoiceClientCallControlMessage | VoiceClientPingMessage;
1282
+ export type VoiceServerSessionMessage = {
1283
+ type: "session";
1284
+ sessionId: string;
1285
+ status: VoiceSessionStatus;
1286
+ scenarioId?: string;
1287
+ sessionMetadata?: Record<string, unknown>;
1288
+ };
1289
+ export type VoiceServerReplayMessage<TResult = unknown> = {
1290
+ type: "replay";
1291
+ assistantTexts: string[];
1292
+ call?: VoiceCallLifecycleState;
1293
+ partial: string;
1294
+ scenarioId?: string;
1295
+ sessionId: string;
1296
+ sessionMetadata?: Record<string, unknown>;
1297
+ status: VoiceSessionStatus;
1298
+ turns: VoiceTurnRecord<TResult>[];
1299
+ };
1300
+ export type VoiceServerPartialMessage = {
1301
+ type: "partial";
1302
+ transcript: Transcript;
1303
+ };
1304
+ export type VoiceServerFinalMessage = {
1305
+ type: "final";
1306
+ transcript: Transcript;
1307
+ };
1308
+ export type VoiceServerTurnMessage<TResult = unknown> = {
1309
+ type: "turn";
1310
+ turn: VoiceTurnRecord<TResult>;
1311
+ };
1312
+ export type VoiceServerAssistantMessage = {
1313
+ type: "assistant";
1314
+ text: string;
1315
+ turnId?: string;
1316
+ };
1317
+ export type VoiceServerAssistantDeltaMessage = {
1318
+ type: "assistant_delta";
1319
+ delta: string;
1320
+ turnId?: string;
1321
+ };
1322
+ export type VoiceServerAudioMessage = {
1323
+ type: "audio";
1324
+ chunkBase64: string;
1325
+ format: AudioFormat;
1326
+ receivedAt: number;
1327
+ turnId?: string;
1328
+ };
1329
+ export type VoiceServerCompleteMessage = {
1330
+ type: "complete";
1331
+ sessionId: string;
1332
+ };
1333
+ export type VoiceServerCallLifecycleMessage = {
1334
+ type: "call_lifecycle";
1335
+ event: VoiceCallLifecycleEvent;
1336
+ sessionId: string;
1337
+ };
1338
+ export type VoiceServerErrorMessage = {
1339
+ type: "error";
1340
+ message: string;
1341
+ recoverable?: boolean;
1342
+ };
1343
+ export type VoiceServerPongMessage = {
1344
+ type: "pong";
1345
+ };
1346
+ export type VoiceServerConnectionMessage = {
1347
+ type: "connection";
1348
+ reconnect: VoiceReconnectClientState;
1349
+ };
1350
+ export type VoiceServerMessage<TResult = unknown> = VoiceServerSessionMessage | VoiceServerReplayMessage<TResult> | VoiceServerPartialMessage | VoiceServerFinalMessage | VoiceServerTurnMessage<TResult> | VoiceServerAssistantMessage | VoiceServerAssistantDeltaMessage | VoiceServerAudioMessage | VoiceServerCallControlAckMessage | VoiceServerCallLifecycleMessage | VoiceServerCompleteMessage | VoiceServerErrorMessage | VoiceServerPongMessage | VoiceServerConnectionMessage;
1351
+ export type VoiceConnectionOptions = {
1352
+ browserMedia?: false | VoiceBrowserMediaReporterOptions;
1353
+ protocols?: string[];
1354
+ scenarioId?: string;
1355
+ reconnect?: boolean;
1356
+ reconnectReportPath?: string;
1357
+ maxReconnectAttempts?: number;
1358
+ /** Cap on the exponential reconnect backoff (ms). The delay doubles from 500ms
1359
+ * up to this ceiling each attempt, so the total retry window is roughly
1360
+ * maxReconnectAttempts spread across it. Default 8000 — with the default 15
1361
+ * attempts that's a ~95s window, enough to ride out a server redeploy without
1362
+ * the caller losing the call. */
1363
+ reconnectMaxDelayMs?: number;
1364
+ /** A reconnected socket must remain open this long before its retry budget is
1365
+ * reset. This prevents a server that accepts and immediately drops sockets
1366
+ * from creating an unbounded reconnect loop. Default 30000. */
1367
+ reconnectResetAfterMs?: number;
1368
+ /** Refresh application-owned admission state before each reconnect attempt.
1369
+ * Throwing keeps the transport disconnected and consumes one bounded retry
1370
+ * attempt instead of opening a socket with stale credentials. */
1371
+ prepareReconnect?: (input: {
1372
+ attempt: number;
1373
+ path: string;
1374
+ scenarioId: string | null;
1375
+ sessionId: string;
1376
+ signal: AbortSignal;
1377
+ }) => Promise<void> | void;
1378
+ /** Maximum time allowed for one prepareReconnect hook. A hook that exceeds
1379
+ * this deadline is aborted and consumes the attempt. Default 10000. */
1380
+ prepareReconnectTimeoutMs?: number;
1381
+ pingInterval?: number;
1382
+ /** Additional query values sent on every initial or reconnecting socket. */
1383
+ query?: Record<string, string>;
1384
+ sessionId?: string;
1385
+ };
1386
+ export type VoiceBrowserMediaReportPayload = {
1387
+ at: number;
1388
+ continuity?: MediaWebRTCStreamContinuityReport;
1389
+ report: MediaWebRTCStatsReport;
1390
+ scenarioId?: string | null;
1391
+ sessionId?: string | null;
1392
+ };
1393
+ export type VoiceBrowserMediaReporterOptions = Omit<MediaWebRTCStatsReportInput, "peerConnection"> & {
1394
+ fetch?: typeof fetch;
1395
+ getPeerConnection?: (() => MediaWebRTCStatsCollector | null | undefined) | (() => Promise<MediaWebRTCStatsCollector | null | undefined>);
1396
+ getScenarioId?: () => string | null | undefined;
1397
+ getSessionId?: () => string | null | undefined;
1398
+ intervalMs?: number;
1399
+ continuity?: false | Omit<MediaWebRTCStreamContinuityInput, "previousStats" | "stats">;
1400
+ onError?: (error: unknown) => void;
1401
+ onReport?: (payload: VoiceBrowserMediaReportPayload) => void;
1402
+ path?: string;
1403
+ peerConnection?: MediaWebRTCStatsCollector;
1404
+ };
1405
+ export type VoiceCaptureOptions = {
1406
+ channelCount?: 1 | 2;
1407
+ onAudio?: (audio: Uint8Array | ArrayBuffer, sendAudio: (audio: Uint8Array | ArrayBuffer) => void) => void;
1408
+ onLevel?: (level: number) => void;
1409
+ sampleRateHz?: number;
1410
+ /**
1411
+ * A pre-acquired microphone MediaStream. When set, capture uses it instead of
1412
+ * calling getUserMedia — so a host that requested permission UP FRONT (before
1413
+ * connecting, so the prompt can't interrupt the assistant's greeting) can hand
1414
+ * the SAME stream in rather than release-and-reacquire (a second getUserMedia
1415
+ * + a track stop can trigger an audio-device change that suspends playback and
1416
+ * cuts the greeting). Capture owns it after handoff and stops it on close.
1417
+ */
1418
+ stream?: MediaStream;
1419
+ };
1420
+ export type VoiceControllerOptions = {
1421
+ preset?: VoiceRuntimePreset;
1422
+ connection?: VoiceConnectionOptions;
1423
+ capture?: VoiceCaptureOptions;
1424
+ autoStopOnComplete?: boolean;
1425
+ };
1426
+ export type VoiceBargeInOptions = {
1427
+ enabled?: boolean;
1428
+ interruptOnPartial?: boolean;
1429
+ interruptThreshold?: number;
1430
+ monitor?: VoiceBargeInMonitor;
1431
+ };
1432
+ export type VoiceBargeInTriggerReason = "input-level" | "manual-audio" | "manual-interrupt" | "partial-transcript";
1433
+ export type VoiceBargeInMonitorEvent = {
1434
+ at: number;
1435
+ id: string;
1436
+ latencyMs?: number;
1437
+ playbackStopLatencyMs?: number;
1438
+ reason: VoiceBargeInTriggerReason;
1439
+ sessionId?: string | null;
1440
+ status: "requested" | "stopped" | "skipped";
1441
+ thresholdMs?: number;
1442
+ };
1443
+ export type VoiceBargeInMonitorSnapshot = {
1444
+ averageLatencyMs?: number;
1445
+ events: VoiceBargeInMonitorEvent[];
1446
+ failed: number;
1447
+ lastEvent?: VoiceBargeInMonitorEvent;
1448
+ passed: number;
1449
+ status: "empty" | "fail" | "pass" | "warn";
1450
+ thresholdMs: number;
1451
+ total: number;
1452
+ };
1453
+ export type VoiceBargeInMonitor = {
1454
+ getSnapshot: () => VoiceBargeInMonitorSnapshot;
1455
+ recordRequested: (input: {
1456
+ reason: VoiceBargeInTriggerReason;
1457
+ sessionId?: string | null;
1458
+ }) => VoiceBargeInMonitorEvent;
1459
+ recordSkipped: (input: {
1460
+ reason: VoiceBargeInTriggerReason;
1461
+ sessionId?: string | null;
1462
+ }) => VoiceBargeInMonitorEvent;
1463
+ recordStopped: (input: {
1464
+ latencyMs?: number;
1465
+ playbackStopLatencyMs?: number;
1466
+ reason: VoiceBargeInTriggerReason;
1467
+ sessionId?: string | null;
1468
+ }) => VoiceBargeInMonitorEvent;
1469
+ subscribe: (subscriber: () => void) => () => void;
1470
+ };
1471
+ export type VoiceAudioPlayerOptions = {
1472
+ autoStart?: boolean;
1473
+ createAudioContext?: () => AudioContext;
1474
+ lookaheadMs?: number;
1475
+ /**
1476
+ * Playback speed multiplier for the assistant's speech. 1 = normal. Clamped
1477
+ * to [0.5, 2]. Pitch shifts with the rate (Web Audio playbackRate), so keep
1478
+ * UI ranges modest (≈0.85–1.25) to stay natural. Can be changed live via
1479
+ * setPlaybackRate — already-scheduled chunks keep their rate; new chunks
1480
+ * adopt the new one.
1481
+ */
1482
+ playbackRate?: number;
1483
+ volume?: number;
1484
+ };
1485
+ export type VoiceDuplexControllerOptions = VoiceControllerOptions & {
1486
+ audioPlayer?: VoiceAudioPlayerOptions;
1487
+ bargeIn?: VoiceBargeInOptions;
1488
+ };
1489
+ export type VoiceSTTRoutingGoal = "best" | "low-cost";
1490
+ export type VoiceSTTRoutingCorrectionMode = "generic" | "none" | "risky-turn";
1491
+ export type VoiceSTTRoutingStrategy = {
1492
+ benchmarkSessionTarget: "deepgram-corrected" | "deepgram-flux";
1493
+ correctionMode: VoiceSTTRoutingCorrectionMode;
1494
+ goal: VoiceSTTRoutingGoal;
1495
+ notes: string[];
1496
+ preset: VoiceRuntimePreset;
1497
+ sttLifecycle: VoiceSTTLifecycle;
1498
+ };
1499
+ export type VoiceHTMXRenderInput<TResult = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord> = {
1500
+ assistantTexts: string[];
1501
+ partial: string;
1502
+ scenarioId?: string;
1503
+ result?: TResult;
1504
+ session?: TSession;
1505
+ sessionId?: string;
1506
+ status: VoiceSessionStatus | "idle";
1507
+ turnCount: number;
1508
+ turns: VoiceTurnRecord<TResult>[];
1509
+ };
1510
+ export type VoiceHTMXRenderConfig<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
1511
+ metrics?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
1512
+ status?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
1513
+ turns?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
1514
+ assistant?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
1515
+ result?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
1516
+ emptyState?: (kind: keyof VoiceHTMXTargets, input: VoiceHTMXRenderInput<TResult, TSession>) => string;
1517
+ };
1518
+ export type VoiceHTMXRenderer<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
1519
+ export type VoiceHTMXTargets = {
1520
+ assistant: string;
1521
+ metrics: string;
1522
+ result: string;
1523
+ status: string;
1524
+ turns: string;
1525
+ };
1526
+ export type VoiceHTMXOptions<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceHTMXRenderConfig<TSession, TResult> & {
1527
+ bootstrapRoute?: string;
1528
+ route?: string;
1529
+ targets?: Partial<VoiceHTMXTargets>;
1530
+ };
1531
+ export type VoiceHTMXConfig<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceHTMXRenderer<TSession, TResult> | VoiceHTMXOptions<TSession, TResult>;
1532
+ export type VoiceStreamState<TResult = unknown> = {
1533
+ call: VoiceCallLifecycleState | null;
1534
+ sessionMetadata: Record<string, unknown> | null;
1535
+ sessionId: string | null;
1536
+ scenarioId: string | null;
1537
+ status: VoiceSessionStatus | "idle";
1538
+ reconnect: VoiceReconnectClientState;
1539
+ partial: string;
1540
+ turns: VoiceTurnRecord<TResult>[];
1541
+ assistantTexts: string[];
1542
+ assistantStreamingText: string;
1543
+ assistantAudio: Array<{
1544
+ chunk: Uint8Array;
1545
+ format: AudioFormat;
1546
+ receivedAt: number;
1547
+ turnId?: string;
1548
+ }>;
1549
+ error: string | null;
1550
+ isConnected: boolean;
1551
+ };
1552
+ export type VoiceStream<TResult = unknown> = {
1553
+ call: VoiceCallLifecycleState | null;
1554
+ callControl: (message: Omit<VoiceClientCallControlMessage, "requestId" | "type">) => Promise<void>;
1555
+ close: (reason?: string) => void;
1556
+ /** Release the transport without terminally completing the server session. */
1557
+ disconnect: () => void;
1558
+ start: (input?: {
1559
+ scenarioId?: string;
1560
+ sessionId?: string;
1561
+ }) => Promise<void>;
1562
+ endTurn: () => void;
1563
+ error: string | null;
1564
+ getServerSnapshot: () => VoiceStreamState<TResult>;
1565
+ getSnapshot: () => VoiceStreamState<TResult>;
1566
+ isConnected: boolean;
1567
+ partial: string;
1568
+ reconnect: VoiceReconnectClientState;
1569
+ sendAudio: (audio: Uint8Array | ArrayBuffer) => void;
1570
+ simulateDisconnect: () => void;
1571
+ sessionId: string | null;
1572
+ sessionMetadata: Record<string, unknown> | null;
1573
+ scenarioId: string | null;
1574
+ status: VoiceSessionStatus | "idle";
1575
+ subscribe: (subscriber: () => void) => () => void;
1576
+ turns: VoiceTurnRecord<TResult>[];
1577
+ assistantTexts: string[];
1578
+ assistantStreamingText: string;
1579
+ assistantAudio: Array<{
1580
+ chunk: Uint8Array;
1581
+ format: AudioFormat;
1582
+ receivedAt: number;
1583
+ turnId?: string;
1584
+ }>;
1585
+ };
1586
+ export type VoiceControllerState<TResult = unknown> = VoiceStreamState<TResult> & {
1587
+ isRecording: boolean;
1588
+ recordingError: string | null;
1589
+ };
1590
+ export type VoiceAudioPlayerState = {
1591
+ activeSourceCount: number;
1592
+ error: string | null;
1593
+ isActive: boolean;
1594
+ isPlaying: boolean;
1595
+ lastInterruptLatencyMs?: number;
1596
+ lastPlaybackStopLatencyMs?: number;
1597
+ processedChunkCount: number;
1598
+ queuedChunkCount: number;
1599
+ };
1600
+ export type VoiceAudioPlayerSource = {
1601
+ assistantAudio: VoiceStreamState["assistantAudio"];
1602
+ subscribe: (subscriber: () => void) => () => void;
1603
+ };
1604
+ /** Post-call playback integrity, for verifying the assistant audio actually
1605
+ * played cleanly (no overlap, no dropped/stalled packets) — emit it as a trace
1606
+ * so a garbled call is provable, not guessed. `ok` is the all-clear roll-up. */
1607
+ export type VoiceAudioIntegrity = {
1608
+ ok: boolean;
1609
+ chunksReceived: number;
1610
+ chunksScheduled: number;
1611
+ scheduledDurationMs: number;
1612
+ gapCount: number;
1613
+ totalGapMs: number;
1614
+ maxGapMs: number;
1615
+ maxConcurrentPlayers: number;
1616
+ errorCount: number;
1617
+ };
1618
+ export type VoiceAudioPlayer = {
1619
+ close: () => Promise<void>;
1620
+ error: string | null;
1621
+ /** Instantaneous RMS amplitude (0..1) of the assistant's audio output — for
1622
+ * driving a visualizer from the actual voice. 0 when idle / no analyser. */
1623
+ getOutputLevel: () => number;
1624
+ getSnapshot: () => VoiceAudioPlayerState;
1625
+ /** Post-call playback-integrity roll-up (overlap, gaps, drops). */
1626
+ getIntegritySummary: () => VoiceAudioIntegrity;
1627
+ activeSourceCount: number;
1628
+ isActive: boolean;
1629
+ isPlaying: boolean;
1630
+ interrupt: () => Promise<void>;
1631
+ lastInterruptLatencyMs?: number;
1632
+ lastPlaybackStopLatencyMs?: number;
1633
+ pause: () => Promise<void>;
1634
+ playbackRate: number;
1635
+ processedChunkCount: number;
1636
+ queuedChunkCount: number;
1637
+ setPlaybackRate: (rate: number) => void;
1638
+ setVolume: (volume: number) => void;
1639
+ start: () => Promise<void>;
1640
+ subscribe: (subscriber: () => void) => () => void;
1641
+ volume: number;
1642
+ };
1643
+ export type VoiceBargeInBinding = {
1644
+ close: () => void;
1645
+ handleLevel: (level: number) => void;
1646
+ sendAudio: (audio: Uint8Array | ArrayBuffer) => void;
1647
+ };
1648
+ export type VoiceController<TResult = unknown> = {
1649
+ bindHTMX: (options: VoiceHTMXBindingOptions) => () => void;
1650
+ call: VoiceCallLifecycleState | null;
1651
+ callControl: (message: Omit<VoiceClientCallControlMessage, "requestId" | "type">) => Promise<void>;
1652
+ close: (reason?: string) => void;
1653
+ /** Release the transport while leaving the server session resumable. */
1654
+ disconnect: () => void;
1655
+ endTurn: () => void;
1656
+ start: (input?: {
1657
+ scenarioId?: string;
1658
+ sessionId?: string;
1659
+ }) => Promise<void>;
1660
+ error: string | null;
1661
+ getServerSnapshot: () => VoiceControllerState<TResult>;
1662
+ getSnapshot: () => VoiceControllerState<TResult>;
1663
+ isConnected: boolean;
1664
+ isRecording: boolean;
1665
+ partial: string;
1666
+ reconnect: VoiceReconnectClientState;
1667
+ recordingError: string | null;
1668
+ sendAudio: (audio: Uint8Array | ArrayBuffer) => void;
1669
+ simulateDisconnect: () => void;
1670
+ sessionId: string | null;
1671
+ sessionMetadata: Record<string, unknown> | null;
1672
+ scenarioId: string | null;
1673
+ startRecording: () => Promise<void>;
1674
+ status: VoiceSessionStatus | "idle";
1675
+ stopRecording: () => void;
1676
+ subscribe: (subscriber: () => void) => () => void;
1677
+ toggleRecording: () => Promise<void>;
1678
+ turns: VoiceTurnRecord<TResult>[];
1679
+ assistantTexts: string[];
1680
+ assistantStreamingText: string;
1681
+ assistantAudio: Array<{
1682
+ chunk: Uint8Array;
1683
+ format: AudioFormat;
1684
+ receivedAt: number;
1685
+ turnId?: string;
1686
+ }>;
1687
+ };
1688
+ export type VoiceDuplexController<TResult = unknown> = VoiceController<TResult> & {
1689
+ audioPlayer: VoiceAudioPlayer;
1690
+ interruptAssistant: () => Promise<void>;
1691
+ };
1692
+ export type VoiceHTMXBindingOptions = {
1693
+ element: Element | string;
1694
+ eventName?: string;
1695
+ route?: string;
1696
+ sessionQueryParam?: string;
1697
+ };
1698
+ export type VoiceStoreAction<TResult = unknown> = {
1699
+ type: "session";
1700
+ sessionId: string;
1701
+ sessionMetadata?: Record<string, unknown>;
1702
+ scenarioId?: string;
1703
+ status: VoiceSessionStatus;
1704
+ } | {
1705
+ type: "replay";
1706
+ assistantTexts: string[];
1707
+ call?: VoiceCallLifecycleState;
1708
+ partial: string;
1709
+ scenarioId?: string;
1710
+ sessionId: string;
1711
+ sessionMetadata?: Record<string, unknown>;
1712
+ status: VoiceSessionStatus;
1713
+ turns: VoiceTurnRecord<TResult>[];
1714
+ } | {
1715
+ type: "call_lifecycle";
1716
+ event: VoiceCallLifecycleEvent;
1717
+ sessionId: string;
1718
+ } | {
1719
+ type: "partial";
1720
+ transcript: Transcript;
1721
+ } | {
1722
+ type: "final";
1723
+ transcript: Transcript;
1724
+ } | {
1725
+ type: "turn";
1726
+ turn: VoiceTurnRecord<TResult>;
1727
+ } | {
1728
+ type: "assistant";
1729
+ text: string;
1730
+ turnId?: string;
1731
+ } | {
1732
+ type: "assistant_delta";
1733
+ delta: string;
1734
+ turnId?: string;
1735
+ } | {
1736
+ type: "audio";
1737
+ chunk: Uint8Array;
1738
+ format: AudioFormat;
1739
+ receivedAt: number;
1740
+ turnId?: string;
1741
+ } | {
1742
+ type: "complete";
1743
+ sessionId: string;
1744
+ } | {
1745
+ type: "error";
1746
+ message: string;
1747
+ recoverable?: boolean;
1748
+ } | {
1749
+ type: "connected";
1750
+ } | {
1751
+ type: "connection";
1752
+ reconnect: VoiceReconnectClientState;
1753
+ } | {
1754
+ type: "disconnected";
1755
+ };