@absolutejs/voice 0.0.22-beta.17 → 0.0.22-beta.170

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 (189) hide show
  1. package/README.md +1057 -5
  2. package/dist/agent.d.ts +24 -0
  3. package/dist/agentSquadContract.d.ts +64 -0
  4. package/dist/angular/index.d.ts +12 -0
  5. package/dist/angular/index.js +3196 -1111
  6. package/dist/angular/voice-campaign-dialer-proof.service.d.ts +14 -0
  7. package/dist/angular/voice-controller.service.d.ts +1 -0
  8. package/dist/angular/voice-delivery-runtime.component.d.ts +17 -0
  9. package/dist/angular/voice-delivery-runtime.service.d.ts +16 -0
  10. package/dist/angular/voice-ops-action-center.service.d.ts +13 -0
  11. package/dist/angular/voice-ops-status.component.d.ts +15 -0
  12. package/dist/angular/voice-ops-status.service.d.ts +12 -0
  13. package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
  14. package/dist/angular/voice-provider-contracts.service.d.ts +12 -0
  15. package/dist/angular/voice-routing-status.service.d.ts +11 -0
  16. package/dist/angular/voice-stream.service.d.ts +3 -0
  17. package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
  18. package/dist/angular/voice-turn-latency.service.d.ts +13 -0
  19. package/dist/angular/voice-turn-quality.service.d.ts +12 -0
  20. package/dist/angular/voice-workflow-status.service.d.ts +12 -0
  21. package/dist/assistantHealth.d.ts +81 -0
  22. package/dist/audit.d.ts +128 -0
  23. package/dist/auditDeliveryRoutes.d.ts +85 -0
  24. package/dist/auditExport.d.ts +34 -0
  25. package/dist/auditRoutes.d.ts +66 -0
  26. package/dist/auditSinks.d.ts +151 -0
  27. package/dist/bargeInRoutes.d.ts +56 -0
  28. package/dist/campaign.d.ts +610 -0
  29. package/dist/campaignDialers.d.ts +90 -0
  30. package/dist/client/actions.d.ts +105 -0
  31. package/dist/client/bargeInMonitor.d.ts +7 -0
  32. package/dist/client/campaignDialerProof.d.ts +23 -0
  33. package/dist/client/connection.d.ts +3 -0
  34. package/dist/client/deliveryRuntime.d.ts +34 -0
  35. package/dist/client/deliveryRuntimeWidget.d.ts +37 -0
  36. package/dist/client/duplex.d.ts +1 -1
  37. package/dist/client/htmxBootstrap.js +747 -15
  38. package/dist/client/index.d.ts +54 -0
  39. package/dist/client/index.js +2944 -20
  40. package/dist/client/liveTurnLatency.d.ts +41 -0
  41. package/dist/client/opsActionCenter.d.ts +54 -0
  42. package/dist/client/opsActionCenterWidget.d.ts +29 -0
  43. package/dist/client/opsActionHistory.d.ts +19 -0
  44. package/dist/client/opsActionHistoryWidget.d.ts +11 -0
  45. package/dist/client/opsStatus.d.ts +19 -0
  46. package/dist/client/opsStatusWidget.d.ts +40 -0
  47. package/dist/client/providerCapabilities.d.ts +19 -0
  48. package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
  49. package/dist/client/providerContracts.d.ts +19 -0
  50. package/dist/client/providerContractsWidget.d.ts +37 -0
  51. package/dist/client/providerSimulationControls.d.ts +33 -0
  52. package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
  53. package/dist/client/providerStatusWidget.d.ts +32 -0
  54. package/dist/client/routingStatus.d.ts +19 -0
  55. package/dist/client/routingStatusWidget.d.ts +28 -0
  56. package/dist/client/traceTimeline.d.ts +19 -0
  57. package/dist/client/traceTimelineWidget.d.ts +32 -0
  58. package/dist/client/turnLatency.d.ts +22 -0
  59. package/dist/client/turnLatencyWidget.d.ts +33 -0
  60. package/dist/client/turnQuality.d.ts +19 -0
  61. package/dist/client/turnQualityWidget.d.ts +32 -0
  62. package/dist/client/workflowStatus.d.ts +19 -0
  63. package/dist/dataControl.d.ts +47 -0
  64. package/dist/deliveryRuntime.d.ts +158 -0
  65. package/dist/deliverySinkRoutes.d.ts +117 -0
  66. package/dist/demoReadyRoutes.d.ts +98 -0
  67. package/dist/diagnosticsRoutes.d.ts +44 -0
  68. package/dist/evalRoutes.d.ts +213 -0
  69. package/dist/fileStore.d.ts +11 -2
  70. package/dist/handoff.d.ts +54 -0
  71. package/dist/handoffHealth.d.ts +94 -0
  72. package/dist/index.d.ts +114 -11
  73. package/dist/index.js +18454 -4316
  74. package/dist/liveLatency.d.ts +78 -0
  75. package/dist/modelAdapters.d.ts +23 -2
  76. package/dist/openaiRealtime.d.ts +27 -0
  77. package/dist/openaiTTS.d.ts +18 -0
  78. package/dist/opsActionAuditRoutes.d.ts +99 -0
  79. package/dist/opsConsoleRoutes.d.ts +80 -0
  80. package/dist/opsStatus.d.ts +76 -0
  81. package/dist/opsStatusRoutes.d.ts +33 -0
  82. package/dist/opsWebhook.d.ts +126 -0
  83. package/dist/outcomeContract.d.ts +112 -0
  84. package/dist/phoneAgent.d.ts +62 -0
  85. package/dist/phoneAgentProductionSmoke.d.ts +115 -0
  86. package/dist/postgresStore.d.ts +13 -2
  87. package/dist/productionReadiness.d.ts +368 -0
  88. package/dist/providerAdapters.d.ts +48 -0
  89. package/dist/providerCapabilities.d.ts +92 -0
  90. package/dist/providerHealth.d.ts +1 -0
  91. package/dist/providerRoutingContract.d.ts +38 -0
  92. package/dist/providerStackRecommendations.d.ts +145 -0
  93. package/dist/qualityRoutes.d.ts +76 -0
  94. package/dist/queue.d.ts +61 -0
  95. package/dist/react/VoiceDeliveryRuntime.d.ts +7 -0
  96. package/dist/react/VoiceOpsActionCenter.d.ts +5 -0
  97. package/dist/react/VoiceOpsStatus.d.ts +6 -0
  98. package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
  99. package/dist/react/VoiceProviderContracts.d.ts +6 -0
  100. package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
  101. package/dist/react/VoiceProviderStatus.d.ts +6 -0
  102. package/dist/react/VoiceRoutingStatus.d.ts +6 -0
  103. package/dist/react/VoiceTraceTimeline.d.ts +6 -0
  104. package/dist/react/VoiceTurnLatency.d.ts +6 -0
  105. package/dist/react/VoiceTurnQuality.d.ts +6 -0
  106. package/dist/react/index.d.ts +23 -0
  107. package/dist/react/index.js +3695 -33
  108. package/dist/react/useVoiceCampaignDialerProof.d.ts +10 -0
  109. package/dist/react/useVoiceController.d.ts +3 -0
  110. package/dist/react/useVoiceDeliveryRuntime.d.ts +13 -0
  111. package/dist/react/useVoiceOpsActionCenter.d.ts +11 -0
  112. package/dist/react/useVoiceOpsStatus.d.ts +8 -0
  113. package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
  114. package/dist/react/useVoiceProviderContracts.d.ts +8 -0
  115. package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
  116. package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
  117. package/dist/react/useVoiceStream.d.ts +3 -0
  118. package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
  119. package/dist/react/useVoiceTurnLatency.d.ts +9 -0
  120. package/dist/react/useVoiceTurnQuality.d.ts +8 -0
  121. package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
  122. package/dist/readinessProfiles.d.ts +35 -0
  123. package/dist/reconnectContract.d.ts +87 -0
  124. package/dist/resilienceRoutes.d.ts +142 -0
  125. package/dist/sessionReplay.d.ts +185 -0
  126. package/dist/simulationSuite.d.ts +120 -0
  127. package/dist/sqliteStore.d.ts +13 -2
  128. package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
  129. package/dist/svelte/createVoiceDeliveryRuntime.d.ts +11 -0
  130. package/dist/svelte/createVoiceOpsActionCenter.d.ts +10 -0
  131. package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
  132. package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
  133. package/dist/svelte/createVoiceProviderContracts.d.ts +10 -0
  134. package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
  135. package/dist/svelte/createVoiceProviderStatus.d.ts +4 -2
  136. package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
  137. package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
  138. package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
  139. package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
  140. package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
  141. package/dist/svelte/index.d.ts +12 -0
  142. package/dist/svelte/index.js +3095 -439
  143. package/dist/telephony/contract.d.ts +61 -0
  144. package/dist/telephony/matrix.d.ts +97 -0
  145. package/dist/telephony/plivo.d.ts +254 -0
  146. package/dist/telephony/telnyx.d.ts +247 -0
  147. package/dist/telephony/twilio.d.ts +135 -2
  148. package/dist/telephonyOutcome.d.ts +201 -0
  149. package/dist/testing/index.d.ts +1 -0
  150. package/dist/testing/index.js +2008 -69
  151. package/dist/testing/ioProviderSimulator.d.ts +41 -0
  152. package/dist/testing/providerSimulator.d.ts +8 -0
  153. package/dist/toolContract.d.ts +130 -0
  154. package/dist/toolRuntime.d.ts +50 -0
  155. package/dist/trace.d.ts +19 -1
  156. package/dist/traceDeliveryRoutes.d.ts +86 -0
  157. package/dist/traceTimeline.d.ts +93 -0
  158. package/dist/turnLatency.d.ts +95 -0
  159. package/dist/turnQuality.d.ts +94 -0
  160. package/dist/types.d.ts +170 -4
  161. package/dist/vue/VoiceDeliveryRuntime.d.ts +30 -0
  162. package/dist/vue/VoiceOpsActionCenter.d.ts +13 -0
  163. package/dist/vue/VoiceOpsStatus.d.ts +30 -0
  164. package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
  165. package/dist/vue/VoiceProviderContracts.d.ts +21 -0
  166. package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
  167. package/dist/vue/VoiceProviderStatus.d.ts +51 -0
  168. package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
  169. package/dist/vue/VoiceTurnLatency.d.ts +69 -0
  170. package/dist/vue/VoiceTurnQuality.d.ts +51 -0
  171. package/dist/vue/index.d.ts +22 -0
  172. package/dist/vue/index.js +3617 -53
  173. package/dist/vue/useVoiceCampaignDialerProof.d.ts +11 -0
  174. package/dist/vue/useVoiceController.d.ts +2 -1
  175. package/dist/vue/useVoiceDeliveryRuntime.d.ts +13 -0
  176. package/dist/vue/useVoiceOpsActionCenter.d.ts +11 -0
  177. package/dist/vue/useVoiceOpsStatus.d.ts +9 -0
  178. package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
  179. package/dist/vue/useVoiceProviderContracts.d.ts +9 -0
  180. package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
  181. package/dist/vue/useVoiceProviderStatus.d.ts +1 -1
  182. package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
  183. package/dist/vue/useVoiceStream.d.ts +4 -1
  184. package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
  185. package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
  186. package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
  187. package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
  188. package/dist/workflowContract.d.ts +91 -0
  189. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,48 @@
1
1
  # `@absolutejs/voice`
2
2
 
3
- `@absolutejs/voice` is the voice session layer for AbsoluteJS. It owns the duplex WebSocket lifecycle, transcript buffering, turn commits, reconnect behavior, and client primitives, while keeping speech vendors and session storage pluggable.
3
+ `@absolutejs/voice` is the self-hosted voice operations layer for AbsoluteJS.
4
+
5
+ It gives your app the primitives hosted voice platforms usually keep behind their dashboards: browser voice sessions, phone-call routes, provider routing, assistant tools, handoffs, traces, evals, production-readiness checks, latency proof, storage adapters, and framework-native UI helpers.
6
+
7
+ Use it when you want Vapi/Retell/Bland-style voice-agent capability, but you want the orchestration, data, traces, storage, and UI to live inside the AbsoluteJS server you already operate.
8
+
9
+ ## Why AbsoluteJS Voice
10
+
11
+ - Self-hosted by default: your app owns sessions, traces, reviews, tasks, handoffs, retention, and provider keys.
12
+ - Provider-neutral: use Deepgram, AssemblyAI, OpenAI, Anthropic, Gemini, ElevenLabs-style TTS, or your own adapters without rewriting app workflow code.
13
+ - Browser and phone surfaces: mount browser WebSocket voice routes plus Twilio, Telnyx, and Plivo telephony routes from the same package.
14
+ - Production proof: ops status, production readiness, turn quality, turn latency, live browser p50/p95 latency, trace timelines, evals, fixtures, and contracts are package primitives.
15
+ - Framework parity: React, Vue, Svelte, Angular, HTML, HTMX, and plain client entrypoints share the same core behavior.
16
+ - No hosted platform tax: AbsoluteJS Voice does not add a mandatory per-minute orchestration fee between your app and your providers.
17
+
18
+ ## Start Here
19
+
20
+ Pick the path that matches what you are building:
21
+
22
+ - Browser voice agent: mount `voice(...)`, choose an STT adapter, and use the React/Vue/Svelte/Angular/HTML/HTMX client helpers for mic, transcript, reconnect, and status UI.
23
+ - Phone voice agent: mount Twilio, Telnyx, or Plivo routes, normalize carrier outcomes, inspect carrier readiness, and persist call lifecycle traces.
24
+ - Production readiness: mount the status and proof primitives you need, such as `createVoiceOpsStatusRoutes(...)`, `createVoiceProductionReadinessRoutes(...)`, quality routes, trace routes, eval routes, and smoke contracts.
25
+ - Provider routing and fallback: use LLM/STT/TTS provider routers, provider health, provider simulation controls, and cost/latency-aware routing policies.
26
+ - Evals and simulation: mount `createVoiceSimulationSuiteRoutes(...)` to run scenario fixtures, workflow contracts, tool contracts, outcome contracts, baseline comparisons, and saved benchmark artifacts before live traffic.
27
+
28
+ ## How This Differs From Hosted Voice Platforms
29
+
30
+ Hosted voice-agent platforms are strongest when you want a managed dashboard, phone-number provisioning, hosted orchestration, and campaign tooling out of the box.
31
+
32
+ AbsoluteJS Voice is strongest when voice is part of your own product and you need code-owned primitives:
33
+
34
+ - Your app stores the call data instead of a vendor dashboard being the source of truth.
35
+ - Your app controls provider routing, fallback, retries, handoffs, and retention.
36
+ - Your team can inspect and extend every primitive.
37
+ - Your framework UI can render first-class voice state without iframe/dashboard handoffs.
38
+ - Your production checks and evals can run in CI, smoke tests, or your own admin UI.
39
+
40
+ The goal is not to clone a hosted platform. The goal is to make AbsoluteJS the best place to build and operate self-hosted voice products.
4
41
 
5
42
  ## Install
6
43
 
7
44
  ```bash
8
- bun add @absolutejs/voice
45
+ bun add @absolutejs/voice @absolutejs/voice-deepgram
9
46
  ```
10
47
 
11
48
  Peer dependencies:
@@ -21,7 +58,12 @@ Optional framework entrypoints:
21
58
  - `@absolutejs/voice/angular`
22
59
  - `@absolutejs/voice/client`
23
60
 
24
- ## Route Setup
61
+ Common optional adapters:
62
+
63
+ - `@absolutejs/voice-deepgram`
64
+ - `@absolutejs/voice-assemblyai`
65
+
66
+ ## Browser Voice Agent
25
67
 
26
68
  ```ts
27
69
  import { Elysia } from 'elysia';
@@ -73,6 +115,685 @@ const app = new Elysia()
73
115
 
74
116
  `createVoiceMemoryStore()` is dev-only. Real deployments should provide a shared store backed by Redis, Postgres, or equivalent.
75
117
 
118
+ ## Production Readiness Path
119
+
120
+ Once the basic route works, mount the proof routes you need. These give you the self-hosted operational surfaces that hosted platforms usually make mandatory, without forcing a bundled app kit:
121
+
122
+ ```ts
123
+ import {
124
+ createVoiceAuditDeliveryRoutes,
125
+ createVoiceDemoReadyRoutes,
126
+ createVoiceFileRuntimeStorage,
127
+ createVoiceLiveLatencyRoutes,
128
+ createVoiceOpsStatusRoutes,
129
+ createVoiceProductionReadinessRoutes,
130
+ createVoiceTraceDeliveryRoutes,
131
+ createVoiceTraceTimelineRoutes,
132
+ createVoiceTurnLatencyRoutes,
133
+ createVoiceTurnQualityRoutes
134
+ } from '@absolutejs/voice';
135
+
136
+ const runtime = createVoiceFileRuntimeStorage({
137
+ directory: '.voice-runtime/support'
138
+ });
139
+
140
+ app
141
+ .use(
142
+ createVoiceOpsStatusRoutes({
143
+ store: runtime.traces,
144
+ llmProviders: ['openai', 'anthropic', 'gemini'],
145
+ sttProviders: ['deepgram', 'assemblyai']
146
+ })
147
+ )
148
+ .use(
149
+ createVoiceTurnLatencyRoutes({
150
+ htmlPath: '/turn-latency',
151
+ path: '/api/turn-latency',
152
+ store: runtime.session,
153
+ traceStore: runtime.traces
154
+ })
155
+ )
156
+ .use(
157
+ createVoiceLiveLatencyRoutes({
158
+ htmlPath: '/live-latency',
159
+ path: '/api/live-latency',
160
+ store: runtime.traces
161
+ })
162
+ )
163
+ .use(
164
+ createVoiceTurnQualityRoutes({
165
+ htmlPath: '/turn-quality',
166
+ path: '/api/turn-quality',
167
+ store: runtime.session
168
+ })
169
+ )
170
+ .use(
171
+ createVoiceTraceTimelineRoutes({
172
+ htmlPath: '/traces',
173
+ path: '/api/voice-traces',
174
+ store: runtime.traces
175
+ })
176
+ )
177
+ .use(
178
+ createVoiceProductionReadinessRoutes({
179
+ audit: runtime.audit,
180
+ auditDeliveries: runtime.auditDeliveries,
181
+ htmlPath: '/production-readiness',
182
+ path: '/api/production-readiness',
183
+ store: runtime.traces,
184
+ traceDeliveries: runtime.traceDeliveries
185
+ })
186
+ )
187
+ .use(
188
+ createVoiceAuditDeliveryRoutes({
189
+ htmlPath: '/audit/deliveries',
190
+ path: '/api/voice-audit-deliveries',
191
+ store: runtime.auditDeliveries
192
+ })
193
+ )
194
+ .use(
195
+ createVoiceTraceDeliveryRoutes({
196
+ htmlPath: '/traces/deliveries',
197
+ path: '/api/voice-trace-deliveries',
198
+ store: runtime.traceDeliveries
199
+ })
200
+ );
201
+ ```
202
+
203
+ Recommended proof routes:
204
+
205
+ - `/api/voice/ops-status`: compact status for hooks, widgets, and customer-facing demos.
206
+ - `/api/voice/ops-status/html`: HTML status card for quick internal review.
207
+ - `/demo-ready`: customer-facing demo readiness checklist.
208
+ - `/production-readiness`: production gate summary.
209
+ - `/audit/deliveries`: audit sink export queue and failed delivery details.
210
+ - `/voice/phone/smoke-contract`: trace-backed phone-agent production smoke proof.
211
+ - `/traces`: per-session trace timelines.
212
+ - `/traces/deliveries`: trace sink export queue and failed delivery details.
213
+ - `/turn-latency`: server-side turn-stage latency.
214
+ - `/live-latency`: browser-measured speech-to-assistant p50/p95 latency.
215
+ - `/turn-quality`: STT confidence, correction, fallback, and transcript diagnostics.
216
+
217
+ ### Readiness Profiles
218
+
219
+ Use `createVoiceReadinessProfile(...)` when you want production-shaped defaults without adopting an app kit. Profiles are just spreadable route-option bundles for `createVoiceProductionReadinessRoutes(...)`; every option remains explicit and overrideable.
220
+
221
+ ```ts
222
+ import {
223
+ createVoiceProductionReadinessRoutes,
224
+ createVoiceReadinessProfile
225
+ } from '@absolutejs/voice';
226
+
227
+ app.use(
228
+ createVoiceProductionReadinessRoutes({
229
+ ...createVoiceReadinessProfile('meeting-recorder', {
230
+ bargeInReports: async () => [await buildBargeInReport()],
231
+ explain: true,
232
+ providerRoutingContracts: async () => [await runProviderRoutingContract()],
233
+ reconnectContracts: async () => [await runReconnectContract()]
234
+ }),
235
+ store: runtime.traces
236
+ })
237
+ );
238
+ ```
239
+
240
+ Built-in profiles:
241
+
242
+ - `meeting-recorder`: live latency, session health, provider fallback, routing contracts, reconnect proof, and barge-in interruption proof.
243
+ - `phone-agent`: carrier readiness, phone-agent smoke proof, handoffs, provider routing contracts, audit/trace delivery health, and delivery runtime proof.
244
+ - `ops-heavy`: audit evidence, operator action history, audit/trace delivery health, delivery runtime proof, and deploy-gate support.
245
+
246
+ Phone-agent fast path:
247
+
248
+ ```ts
249
+ app.use(
250
+ createVoiceProductionReadinessRoutes({
251
+ ...createVoiceReadinessProfile('phone-agent', {
252
+ auditDeliveries: runtime.auditDeliveries,
253
+ carriers: loadCarrierMatrixInputs,
254
+ deliveryRuntime,
255
+ explain: true,
256
+ phoneAgentSmokes: async () => [await runPhoneSmoke()],
257
+ providerRoutingContracts: async () => [await runProviderRoutingContract()],
258
+ traceDeliveries: runtime.traceDeliveries
259
+ }),
260
+ store: runtime.traces
261
+ })
262
+ );
263
+ ```
264
+
265
+ Ops-heavy fast path:
266
+
267
+ ```ts
268
+ app.use(
269
+ createVoiceProductionReadinessRoutes({
270
+ ...createVoiceReadinessProfile('ops-heavy', {
271
+ audit: runtime.audit,
272
+ auditDeliveries: runtime.auditDeliveries,
273
+ deliveryRuntime,
274
+ traceDeliveries: runtime.traceDeliveries
275
+ }),
276
+ gate: {
277
+ failOnWarnings: true
278
+ },
279
+ store: runtime.traces
280
+ })
281
+ );
282
+ ```
283
+
284
+ The profile helper intentionally does not mount routes, create storage, start workers, or prescribe a deploy workflow. It only returns readiness options so teams can standardize defaults while keeping control over proof sources and route mounting.
285
+
286
+ Pass `explain: true` when the readiness JSON and HTML should describe the selected profile, its purpose, and which expected proof surfaces are configured or still missing. This is useful for customer demos and internal release reviews where the readiness URL needs to explain what it certifies without sending people to docs.
287
+
288
+ ## Delivery Runtime Presets
289
+
290
+ Use `createVoiceDeliveryRuntimePresetConfig(...)` when you want one primitive to create paired audit and trace delivery workers for the same target. The preset returns a normal `VoiceDeliveryRuntimeConfig`, so you can still inspect or override worker options before passing it to `createVoiceDeliveryRuntime(...)`.
291
+
292
+ ### File Delivery
293
+
294
+ Use file delivery for local demos, dev environments, or self-hosted deployments that collect exports from disk.
295
+
296
+ ```ts
297
+ import {
298
+ createVoiceDeliveryRuntime,
299
+ createVoiceDeliveryRuntimePresetConfig,
300
+ createVoiceDeliveryRuntimeRoutes,
301
+ createVoiceFileRuntimeStorage
302
+ } from '@absolutejs/voice';
303
+
304
+ const runtimeStorage = createVoiceFileRuntimeStorage({
305
+ directory: '.voice-runtime/support'
306
+ });
307
+
308
+ const deliveryRuntime = createVoiceDeliveryRuntime(
309
+ createVoiceDeliveryRuntimePresetConfig({
310
+ auditDeliveries: runtimeStorage.auditDeliveries,
311
+ directory: '.voice-runtime/support/delivery-exports',
312
+ leases: createLeaseCoordinator(),
313
+ mode: 'file',
314
+ traceDeliveries: runtimeStorage.traceDeliveries
315
+ })
316
+ );
317
+
318
+ app.use(
319
+ createVoiceDeliveryRuntimeRoutes({
320
+ runtime: deliveryRuntime
321
+ })
322
+ );
323
+ ```
324
+
325
+ ### Webhook Delivery
326
+
327
+ Use webhook delivery when audit and trace exports should go to your own ingestion service, SIEM bridge, warehouse collector, or internal ops backend. The built-in HTTP sinks support retries, optional HMAC signing, custom headers, timeouts, and custom envelope bodies.
328
+
329
+ ```ts
330
+ const deliveryRuntime = createVoiceDeliveryRuntime(
331
+ createVoiceDeliveryRuntimePresetConfig({
332
+ auditDeliveries: runtimeStorage.auditDeliveries,
333
+ auditSinkId: 'support-audit-webhook',
334
+ body: {
335
+ audit: ({ events }) => ({
336
+ eventCount: events.length,
337
+ events,
338
+ source: 'support-app',
339
+ surface: 'audit-deliveries'
340
+ }),
341
+ trace: ({ events }) => ({
342
+ eventCount: events.length,
343
+ events,
344
+ source: 'support-app',
345
+ surface: 'trace-deliveries'
346
+ })
347
+ },
348
+ failures: {
349
+ maxFailures: 3
350
+ },
351
+ leases: {
352
+ audit: createLeaseCoordinator(),
353
+ trace: createLeaseCoordinator()
354
+ },
355
+ mode: 'webhook',
356
+ signingSecret: process.env.VOICE_DELIVERY_WEBHOOK_SECRET,
357
+ traceDeliveries: runtimeStorage.traceDeliveries,
358
+ traceSinkId: 'support-trace-webhook',
359
+ url: process.env.VOICE_DELIVERY_WEBHOOK_URL!
360
+ })
361
+ );
362
+ ```
363
+
364
+ ### S3 Delivery
365
+
366
+ Use S3 delivery when exports should land directly in object storage through Bun's native S3 client. Set `bucket` and `keyPrefix`; the preset writes audit and trace exports under separate prefixes.
367
+
368
+ ```ts
369
+ const deliveryRuntime = createVoiceDeliveryRuntime(
370
+ createVoiceDeliveryRuntimePresetConfig({
371
+ auditDeliveries: runtimeStorage.auditDeliveries,
372
+ auditSinkId: 'support-audit-s3',
373
+ bucket: process.env.VOICE_DELIVERY_S3_BUCKET,
374
+ failures: {
375
+ maxFailures: 3
376
+ },
377
+ keyPrefix: 'support/voice-deliveries',
378
+ leases: {
379
+ audit: createLeaseCoordinator(),
380
+ trace: createLeaseCoordinator()
381
+ },
382
+ mode: 's3',
383
+ traceDeliveries: runtimeStorage.traceDeliveries,
384
+ traceSinkId: 'support-trace-s3'
385
+ })
386
+ );
387
+ ```
388
+
389
+ Mount `createVoiceDeliveryRuntimeRoutes({ runtime: deliveryRuntime })` to expose:
390
+
391
+ - `/api/voice-delivery-runtime`: combined audit and trace worker summary.
392
+ - `/api/voice-delivery-runtime/tick`: manual tick for both workers.
393
+ - `/delivery-runtime`: HTML worker control plane.
394
+
395
+ Pass the same runtime to production readiness so failed, dead-lettered, or pending export queues become deploy-blocking evidence:
396
+
397
+ ```ts
398
+ app.use(
399
+ createVoiceProductionReadinessRoutes({
400
+ auditDeliveries: runtimeStorage.auditDeliveries,
401
+ deliveryRuntime,
402
+ links: {
403
+ deliveryRuntime: '/delivery-runtime'
404
+ },
405
+ store: runtimeStorage.traces,
406
+ traceDeliveries: runtimeStorage.traceDeliveries
407
+ })
408
+ );
409
+ ```
410
+
411
+ ## Simulation Suite Path
412
+
413
+ Use `createVoiceSimulationSuiteRoutes(...)` when you want one pre-production proof surface for the things that usually live in separate dashboards or scripts:
414
+
415
+ ```ts
416
+ import {
417
+ createVoiceSimulationSuiteRoutes,
418
+ createVoiceFileRuntimeStorage
419
+ } from '@absolutejs/voice';
420
+
421
+ const runtime = createVoiceFileRuntimeStorage({
422
+ directory: '.voice-runtime/support'
423
+ });
424
+
425
+ app.use(
426
+ createVoiceSimulationSuiteRoutes({
427
+ htmlPath: '/voice/simulations',
428
+ path: '/api/voice/simulations',
429
+ store: runtime.traces,
430
+ scenarios: workflowScenarios,
431
+ fixtureStore: scenarioFixtureStore,
432
+ tools: toolContracts,
433
+ outcomes: {
434
+ contracts: outcomeContracts,
435
+ events: runtime.events,
436
+ reviews: runtime.reviews,
437
+ sessions: runtime.session,
438
+ tasks: runtime.tasks
439
+ }
440
+ })
441
+ );
442
+ ```
443
+
444
+ The suite rolls up session quality, scenario evals, fixture simulations, tool contracts, and outcome contracts into one pass/fail report. It is the code-owned equivalent of "test this voice flow before production" without requiring a hosted voice-agent dashboard.
445
+
446
+ ## Phone Voice Agent In 20 Minutes
447
+
448
+ Use `createVoicePhoneAgent(...)` when the agent needs to answer or place calls through your own Twilio, Telnyx, or Plivo account. This is the self-hosted alternative to a hosted phone-agent dashboard: your app owns the carrier routes, stream URLs, webhooks, traces, readiness checks, and lifecycle outcomes.
449
+
450
+ ```ts
451
+ import {
452
+ createVoicePhoneAgent,
453
+ createVoiceTelephonyOutcomePolicy,
454
+ runVoicePhoneAgentProductionSmokeContract
455
+ } from '@absolutejs/voice';
456
+ import { deepgram } from '@absolutejs/voice-deepgram';
457
+
458
+ const outcomePolicy = createVoiceTelephonyOutcomePolicy({
459
+ transferTarget: '+15551234567'
460
+ });
461
+
462
+ app
463
+ .use(
464
+ createVoicePhoneAgent({
465
+ setup: {
466
+ path: '/api/voice/phone/setup',
467
+ title: 'Support Phone Agent'
468
+ },
469
+ matrix: {
470
+ path: '/api/carriers',
471
+ title: 'AbsoluteJS Voice Carrier Matrix'
472
+ },
473
+ productionSmoke: {
474
+ maxAgeMs: 24 * 60 * 60 * 1000,
475
+ required: [
476
+ 'carrier-contract',
477
+ 'media-started',
478
+ 'transcript',
479
+ 'assistant-response',
480
+ 'lifecycle-outcome',
481
+ 'no-session-error',
482
+ 'fresh-trace'
483
+ ],
484
+ store: runtime.traces
485
+ },
486
+ carriers: [
487
+ {
488
+ provider: 'twilio',
489
+ options: {
490
+ context: {},
491
+ outcomePolicy,
492
+ session: runtime.session,
493
+ stt: deepgram({ apiKey: process.env.DEEPGRAM_API_KEY! }),
494
+ streamPath: '/api/voice/twilio/stream',
495
+ twiml: {
496
+ path: '/api/voice/twilio',
497
+ streamUrl: process.env.TWILIO_STREAM_URL
498
+ },
499
+ webhook: {
500
+ path: '/api/voice/twilio/webhook',
501
+ signingSecret: process.env.TWILIO_AUTH_TOKEN
502
+ },
503
+ async onTurn({ turn }) {
504
+ return { assistantText: `I heard: ${turn.text}` };
505
+ },
506
+ onComplete: async () => {}
507
+ }
508
+ }
509
+ ]
510
+ }).routes
511
+ );
512
+ ```
513
+
514
+ The wrapper mounts selected carrier routes plus two proof surfaces:
515
+
516
+ - `/api/voice/phone/setup`: one setup report with carrier URLs, smoke links, lifecycle stages, and readiness.
517
+ - `/api/voice/phone/setup?format=html`: copy/paste setup page for carrier dashboards.
518
+ - `/api/carriers`: carrier matrix JSON for Twilio, Telnyx, and Plivo.
519
+ - `/api/carriers?format=html`: side-by-side carrier readiness matrix.
520
+ - `/api/voice/phone/smoke-contract?sessionId=...`: trace-backed production smoke contract.
521
+ - `/voice/phone/smoke-contract?sessionId=...`: HTML production smoke contract.
522
+
523
+ The setup page tells you exactly what to copy into the carrier dashboard:
524
+
525
+ - Twilio: set the phone number voice webhook/TwiML URL to the reported TwiML URL, set the status callback to the reported webhook URL, and allow the reported `wss://` media stream.
526
+ - Telnyx: set the connection TeXML URL to the reported TeXML URL, set the status webhook to the reported webhook URL, and allow the reported `wss://` media stream.
527
+ - Plivo: set the answer URL to the reported answer URL, set the status callback to the reported webhook URL, and allow the reported `wss://` media stream.
528
+
529
+ Each configured carrier can also expose its own setup and smoke pages, for example:
530
+
531
+ - `/api/voice/twilio/setup?format=html`
532
+ - `/api/voice/twilio/smoke?format=html`
533
+ - `/api/voice/telnyx/setup?format=html`
534
+ - `/api/voice/telnyx/smoke?format=html`
535
+ - `/api/voice/plivo/setup?format=html`
536
+ - `/api/voice/plivo/smoke?format=html`
537
+
538
+ The phone-agent report normalizes the lifecycle schema across carriers:
539
+
540
+ - `ringing`
541
+ - `answered`
542
+ - `media-started`
543
+ - `transcript`
544
+ - `assistant-response`
545
+ - `transfer`
546
+ - `voicemail`
547
+ - `no-answer`
548
+ - `completed`
549
+ - `failed`
550
+
551
+ That is the important Vapi/Retell/Bland gap this primitive closes: a team can mount one phone-agent entrypoint, bring its own carrier account, verify readiness before live calls, and keep call traces and lifecycle outcomes inside its own AbsoluteJS app. Telnyx and Plivo use the same wrapper with `{ provider: 'telnyx', options: ... }` or `{ provider: 'plivo', options: ... }`. The lower-level `createTwilioVoiceRoutes(...)`, `createTelnyxVoiceRoutes(...)`, and `createPlivoVoiceRoutes(...)` helpers remain available when you need carrier-specific control.
552
+
553
+ After running a real smoke call, certify the phone-agent path from traces:
554
+
555
+ ```ts
556
+ const smoke = await runVoicePhoneAgentProductionSmokeContract({
557
+ maxAgeMs: 24 * 60 * 60 * 1000,
558
+ required: [
559
+ 'media-started',
560
+ 'transcript',
561
+ 'assistant-response',
562
+ 'lifecycle-outcome',
563
+ 'no-session-error',
564
+ 'fresh-trace'
565
+ ],
566
+ sessionId: 'phone-smoke-session',
567
+ store: runtime.traces
568
+ });
569
+
570
+ if (!smoke.pass) {
571
+ throw new Error(smoke.issues.map((issue) => issue.message).join('\n'));
572
+ }
573
+ ```
574
+
575
+ Pass those reports into production readiness through `phoneAgentSmokes`. This makes deployment fail when the carrier setup exists but the actual phone-agent call path did not produce media start, transcript, assistant response, terminal lifecycle outcome, and clean trace evidence.
576
+
577
+ When `productionSmoke` is enabled on `createVoicePhoneAgent(...)`, the wrapper mounts `/api/voice/phone/smoke-contract?sessionId=...` for JSON and `/voice/phone/smoke-contract?sessionId=...` for HTML. It also derives carrier contract evidence from the existing carrier matrix unless you provide a custom `getContract`.
578
+
579
+ ## Ops Status Hooks And Widgets
580
+
581
+ Use `createVoiceOpsStatusRoutes(...)` when you want a small status endpoint for demos, admin pages, and framework widgets. It is intentionally not a route bundle: mount quality gates, eval routes, provider health, session replay, phone-agent smoke proof, handoff health, and diagnostics explicitly when your app needs them.
582
+
583
+ ```ts
584
+ import {
585
+ createVoiceDemoReadyRoutes,
586
+ createVoiceFileRuntimeStorage,
587
+ createVoiceOpsStatusRoutes,
588
+ summarizeVoiceOpsStatus
589
+ } from '@absolutejs/voice';
590
+
591
+ const runtime = createVoiceFileRuntimeStorage({ directory: '.voice-runtime/support' });
592
+
593
+ app.use(
594
+ createVoiceOpsStatusRoutes({
595
+ store: runtime.traces,
596
+ llmProviders: ['openai', 'anthropic', 'gemini'],
597
+ sttProviders: ['deepgram', 'assemblyai']
598
+ })
599
+ );
600
+ ```
601
+
602
+ The status endpoint is intentionally small enough for customer-facing demos. It can report fixture-backed workflow readiness while leaving deeper live quality/session failures visible on the proof routes you mount separately.
603
+
604
+ For a single demo page that rolls up ops status, production readiness, phone setup, and phone smoke proof, mount `createVoiceDemoReadyRoutes(...)` with the same reports you already expose elsewhere:
605
+
606
+ ```ts
607
+ app.use(
608
+ createVoiceDemoReadyRoutes({
609
+ opsStatus: {
610
+ href: '/api/voice/ops-status',
611
+ load: () => summarizeVoiceOpsStatus(opsStatusOptions)
612
+ },
613
+ phoneSetup: {
614
+ href: '/api/voice/phone/setup?format=html',
615
+ load: () => phoneAgentSetupReport
616
+ },
617
+ phoneSmoke: {
618
+ href: '/voice/phone/smoke-contract',
619
+ load: () => phoneSmokeReport
620
+ },
621
+ productionReadiness: {
622
+ href: '/production-readiness',
623
+ load: () => productionReadinessReport
624
+ }
625
+ })
626
+ );
627
+ ```
628
+
629
+ ```ts
630
+ app.use(
631
+ createVoiceOpsStatusRoutes({
632
+ include: { quality: false, sessions: false },
633
+ preferFixtureWorkflows: true,
634
+ store: runtime.traces
635
+ })
636
+ );
637
+ ```
638
+
639
+ ### React Status Widget
640
+
641
+ ```tsx
642
+ import { VoiceOpsStatus } from '@absolutejs/voice/react';
643
+
644
+ export function OpsBadge() {
645
+ return <VoiceOpsStatus intervalMs={5000} />;
646
+ }
647
+ ```
648
+
649
+ ### Vue Status Widget
650
+
651
+ ```vue
652
+ <script setup lang="ts">
653
+ import { VoiceOpsStatus } from '@absolutejs/voice/vue';
654
+ </script>
655
+
656
+ <template>
657
+ <VoiceOpsStatus :interval-ms="5000" />
658
+ </template>
659
+ ```
660
+
661
+ ### Svelte Status Widget
662
+
663
+ ```svelte
664
+ <script lang="ts">
665
+ import { onDestroy, onMount } from 'svelte';
666
+ import { createVoiceOpsStatus } from '@absolutejs/voice/svelte';
667
+
668
+ const status = createVoiceOpsStatus('/api/voice/ops-status', { intervalMs: 5000 });
669
+ let html = '';
670
+ onMount(() => status.subscribe(() => (html = status.getHTML())));
671
+ onDestroy(() => status.close());
672
+ </script>
673
+
674
+ {@html html}
675
+ ```
676
+
677
+ ### Angular Status Widget
678
+
679
+ ```ts
680
+ import { VoiceOpsStatusService } from '@absolutejs/voice/angular';
681
+
682
+ status = inject(VoiceOpsStatusService).connect('/api/voice/ops-status', {
683
+ intervalMs: 5000
684
+ });
685
+ ```
686
+
687
+ ```html
688
+ <h2>{{ status.report()?.status === 'pass' ? 'Passing' : 'Needs attention' }}</h2>
689
+ <p>{{ status.report()?.passed ?? 0 }} passing checks</p>
690
+ ```
691
+
692
+ ### HTML Or HTMX Status Widget
693
+
694
+ ```html
695
+ <div id="voice-ops-status"></div>
696
+ <script type="module">
697
+ import { mountVoiceOpsStatus } from '@absolutejs/voice/client';
698
+
699
+ mountVoiceOpsStatus(document.querySelector('#voice-ops-status'), '/api/voice/ops-status', {
700
+ intervalMs: 5000
701
+ });
702
+ </script>
703
+ ```
704
+
705
+ For custom elements:
706
+
707
+ ```html
708
+ <absolute-voice-ops-status interval-ms="5000"></absolute-voice-ops-status>
709
+ <script type="module">
710
+ import { defineVoiceOpsStatusElement } from '@absolutejs/voice/client';
711
+ defineVoiceOpsStatusElement();
712
+ </script>
713
+ ```
714
+
715
+ ## Delivery Runtime Widgets
716
+
717
+ After mounting `createVoiceDeliveryRuntimeRoutes(...)`, apps can expose audit and trace worker health through the same framework-native primitives:
718
+
719
+ ```tsx
720
+ import { VoiceDeliveryRuntime } from '@absolutejs/voice/react';
721
+
722
+ export function DeliveryWorkers() {
723
+ return <VoiceDeliveryRuntime intervalMs={5000} />;
724
+ }
725
+ ```
726
+
727
+ The widget includes operator actions by default: `Tick workers` drains pending/failed deliveries, and `Requeue dead letters` moves reviewed dead-lettered audit/trace deliveries back into the live queues. Pass `includeActions={false}` when you only want a read-only status card.
728
+
729
+ ```ts
730
+ import { VoiceDeliveryRuntime } from '@absolutejs/voice/vue';
731
+ import { createVoiceDeliveryRuntime } from '@absolutejs/voice/svelte';
732
+ import { VoiceDeliveryRuntimeService } from '@absolutejs/voice/angular';
733
+ ```
734
+
735
+ For HTML or HTMX pages:
736
+
737
+ ```html
738
+ <absolute-voice-delivery-runtime interval-ms="5000"></absolute-voice-delivery-runtime>
739
+ <script type="module">
740
+ import { defineVoiceDeliveryRuntimeElement } from '@absolutejs/voice/client';
741
+ defineVoiceDeliveryRuntimeElement();
742
+ </script>
743
+ ```
744
+
745
+ ## Voice Ops Action Center
746
+
747
+ Use `VoiceOpsActionCenter` when you want one primitive operator panel for production proofs and recovery actions without building a dashboard. The default action builder can include production readiness refresh, delivery worker ticks, dead-letter requeue, turn-latency proof, and provider failover simulation.
748
+
749
+ ```tsx
750
+ import { VoiceOpsActionCenter } from '@absolutejs/voice/react';
751
+ import { createVoiceOpsActionCenterActions } from '@absolutejs/voice/client';
752
+
753
+ export function OperatorPanel() {
754
+ return (
755
+ <VoiceOpsActionCenter
756
+ actions={createVoiceOpsActionCenterActions({
757
+ providers: ['deepgram', 'assemblyai']
758
+ })}
759
+ />
760
+ );
761
+ }
762
+ ```
763
+
764
+ Mount `createVoiceOpsActionAuditRoutes(...)` to make every action-center click auditable. The client posts successful and failed action results to `/api/voice/ops-actions/audit` by default, and the route records both `operator.action` audit events and `operator.action` trace events.
765
+
766
+ ```ts
767
+ import { createVoiceOpsActionAuditRoutes } from '@absolutejs/voice';
768
+
769
+ app.use(
770
+ createVoiceOpsActionAuditRoutes({
771
+ audit: runtimeStorage.audit,
772
+ trace: runtimeStorage.traces
773
+ })
774
+ );
775
+ ```
776
+
777
+ The same route exposes `GET /api/voice/ops-actions/history` and `/voice/ops-actions` so apps can show recent operator actions beside the action center. For HTML or HTMX pages, use `mountVoiceOpsActionHistory(...)` from `@absolutejs/voice/client`.
778
+
779
+ For HTML or HTMX pages:
780
+
781
+ ```html
782
+ <div id="voice-ops-actions"></div>
783
+ <script type="module">
784
+ import {
785
+ createVoiceOpsActionCenterActions,
786
+ mountVoiceOpsActionCenter
787
+ } from '@absolutejs/voice/client';
788
+
789
+ mountVoiceOpsActionCenter(document.querySelector('#voice-ops-actions'), {
790
+ actions: createVoiceOpsActionCenterActions({
791
+ providers: ['deepgram']
792
+ })
793
+ });
794
+ </script>
795
+ ```
796
+
76
797
  ## Voice Assistants
77
798
 
78
799
  Use `createVoiceAssistant(...)` when you want one product-level surface for a voice agent instead of wiring tools, guardrails, experiments, traces, and ops recipes separately. It returns a standard `onTurn` handler, plus an `ops` object you can pass to `voice(...)`.
@@ -212,7 +933,21 @@ const billingAgent = createVoiceAgent({
212
933
  const frontDesk = createVoiceAgentSquad({
213
934
  id: 'front-desk',
214
935
  defaultAgentId: 'support',
215
- agents: [supportAgent, billingAgent]
936
+ agents: [supportAgent, billingAgent],
937
+ handoffPolicy: ({ handoff }) => {
938
+ if (handoff.targetAgentId === 'billing') {
939
+ return {
940
+ summary: 'Route verified billing requests to the billing specialist.',
941
+ metadata: { queue: 'billing' }
942
+ };
943
+ }
944
+
945
+ return {
946
+ allow: false,
947
+ reason: `No approved route for ${handoff.targetAgentId}.`,
948
+ escalate: { reason: 'unsupported-specialist' }
949
+ };
950
+ }
216
951
  });
217
952
 
218
953
  voice({
@@ -226,6 +961,56 @@ voice({
226
961
 
227
962
  `createVoiceAgentSquad(...)` gives you squad-style specialization without locking your app into a hosted voice platform. An agent can return `handoff: { targetAgentId: 'billing' }`; the squad records the handoff, runs the target agent on the same turn, and still returns a standard `VoiceRouteResult`.
228
963
 
964
+ For production call centers, pass `handoffPolicy` to keep routing code-owned instead of dashboard-owned. The policy can allow a handoff, reroute it to a different specialist, merge handoff metadata, summarize the reason for the target agent, or block the handoff and return an escalation. Squad traces mark each handoff as `allowed`, `blocked`, `unknown-target`, or `max-exceeded`, so support teams can audit why a caller moved between specialists.
965
+
966
+ Use `runVoiceAgentSquadContract(...)` in tests or readiness checks when you need proof that a specialist graph still routes correctly:
967
+
968
+ ```ts
969
+ import {
970
+ createVoiceMemoryTraceEventStore,
971
+ runVoiceAgentSquadContract
972
+ } from '@absolutejs/voice';
973
+
974
+ const trace = createVoiceMemoryTraceEventStore();
975
+ const frontDesk = createVoiceAgentSquad({
976
+ id: 'front-desk',
977
+ defaultAgentId: 'support',
978
+ agents: [supportAgent, billingAgent],
979
+ trace
980
+ });
981
+
982
+ const report = await runVoiceAgentSquadContract({
983
+ context: {},
984
+ squad: frontDesk,
985
+ trace,
986
+ contract: {
987
+ id: 'billing-route',
988
+ scenarioId: 'billing-route',
989
+ turns: [
990
+ {
991
+ text: 'I have a billing question.',
992
+ expect: {
993
+ finalAgentId: 'billing',
994
+ outcome: 'assistant',
995
+ assistantIncludes: ['billing'],
996
+ handoffs: [
997
+ {
998
+ fromAgentId: 'support',
999
+ targetAgentId: 'billing',
1000
+ status: 'allowed'
1001
+ }
1002
+ ]
1003
+ }
1004
+ }
1005
+ ]
1006
+ }
1007
+ });
1008
+
1009
+ if (!report.pass) {
1010
+ throw new Error(report.issues.map((issue) => issue.message).join('\n'));
1011
+ }
1012
+ ```
1013
+
229
1014
  ## Traces And Replay
230
1015
 
231
1016
  Use trace stores when you want every call to be inspectable outside a hosted platform. Trace events are append-only records for model passes, tool calls, handoffs, agent results, call lifecycle, turn timing, errors, and cost telemetry.
@@ -233,13 +1018,22 @@ Use trace stores when you want every call to be inspectable outside a hosted pla
233
1018
  ```ts
234
1019
  import {
235
1020
  buildVoiceTraceReplay,
1021
+ buildVoiceAuditExport,
1022
+ createVoiceAuditHTTPSink,
1023
+ createVoiceAuditLogger,
1024
+ createVoiceAuditSinkDeliveryWorker,
1025
+ createVoiceAuditSinkStore,
1026
+ createVoiceAuditTrailRoutes,
236
1027
  createVoiceAgent,
237
1028
  createVoiceFileRuntimeStorage,
238
1029
  createVoiceRedisTaskLeaseCoordinator,
1030
+ createVoiceTraceDeliveryRoutes,
239
1031
  createVoiceTraceHTTPSink,
240
1032
  createVoiceTraceSinkStore,
241
1033
  createVoiceTraceSinkDeliveryWorker,
1034
+ buildVoiceDataRetentionPlan,
242
1035
  exportVoiceTrace,
1036
+ applyVoiceDataRetentionPolicy,
243
1037
  pruneVoiceTraceEvents,
244
1038
  voice
245
1039
  } from '@absolutejs/voice';
@@ -251,6 +1045,30 @@ const runtimeStorage = createVoiceFileRuntimeStorage({
251
1045
  const redisLeases = createVoiceRedisTaskLeaseCoordinator({
252
1046
  url: process.env.REDIS_URL
253
1047
  });
1048
+ const auditStore = createVoiceAuditSinkStore({
1049
+ store: runtimeStorage.audit,
1050
+ deliveryQueue: runtimeStorage.auditDeliveries,
1051
+ sinks: [
1052
+ createVoiceAuditHTTPSink({
1053
+ id: 'security-warehouse',
1054
+ signingSecret: process.env.VOICE_AUDIT_SINK_SECRET,
1055
+ url: process.env.VOICE_AUDIT_SINK_URL!
1056
+ })
1057
+ ]
1058
+ });
1059
+ const audit = createVoiceAuditLogger(auditStore);
1060
+ const auditSinkWorker = createVoiceAuditSinkDeliveryWorker({
1061
+ deliveries: runtimeStorage.auditDeliveries,
1062
+ leases: redisLeases,
1063
+ sinks: [
1064
+ createVoiceAuditHTTPSink({
1065
+ id: 'security-warehouse',
1066
+ signingSecret: process.env.VOICE_AUDIT_SINK_SECRET,
1067
+ url: process.env.VOICE_AUDIT_SINK_URL!
1068
+ })
1069
+ ],
1070
+ workerId: 'audit-sink-worker'
1071
+ });
254
1072
  const trace = createVoiceTraceSinkStore({
255
1073
  store: runtimeStorage.traces,
256
1074
  deliveryQueue: runtimeStorage.traceDeliveries,
@@ -277,6 +1095,9 @@ const traceSinkWorker = createVoiceTraceSinkDeliveryWorker({
277
1095
 
278
1096
  const supportAgent = createVoiceAgent({
279
1097
  id: 'support',
1098
+ audit,
1099
+ auditProvider: 'openai',
1100
+ auditModel: 'gpt-4.1',
280
1101
  trace,
281
1102
  model: {
282
1103
  async generate() {
@@ -293,6 +1114,17 @@ voice({
293
1114
  onTurn: supportAgent.onTurn,
294
1115
  onComplete: async () => {}
295
1116
  });
1117
+ app.use(
1118
+ createVoiceAuditTrailRoutes({
1119
+ store: runtimeStorage.audit
1120
+ })
1121
+ );
1122
+ app.use(
1123
+ createVoiceTraceDeliveryRoutes({
1124
+ store: runtimeStorage.traceDeliveries,
1125
+ worker: traceSinkWorker
1126
+ })
1127
+ );
296
1128
 
297
1129
  const replay = await exportVoiceTrace({
298
1130
  store: runtimeStorage.traces,
@@ -314,18 +1146,53 @@ await pruneVoiceTraceEvents({
314
1146
  store: runtimeStorage.traces,
315
1147
  before: Date.now() - 30 * 24 * 60 * 60 * 1000
316
1148
  });
1149
+
1150
+ await audit.operatorAction({
1151
+ action: 'review.approve',
1152
+ actor: { id: 'operator-123', kind: 'operator' },
1153
+ resource: { id: 'review-123', type: 'review' }
1154
+ });
317
1155
  ```
318
1156
 
319
1157
  `createVoiceMemoryTraceEventStore(...)`, `createVoiceFileTraceEventStore(...)`, `createVoiceSQLiteTraceEventStore(...)`, and `createVoicePostgresTraceEventStore(...)` all implement the same `VoiceTraceEventStore` contract. File, SQLite, and Postgres runtime storage expose `runtimeStorage.traces` and `runtimeStorage.traceDeliveries` alongside sessions, reviews, tasks, events, and external object mappings. Passing `trace` to `voice(...)` records session lifecycle, transcript, committed-turn, assistant, cost, and error events; passing it to agents records model passes, tools, results, and handoffs.
320
1158
 
321
1159
  For self-hosted QA and support workflows, use `summarizeVoiceTrace(...)`, `evaluateVoiceTrace(...)`, `renderVoiceTraceMarkdown(...)`, `renderVoiceTraceHTML(...)`, or `buildVoiceTraceReplay(...)`. They turn raw trace events into portable artifacts you can attach to tickets, inspect locally, or fail in CI when a call has missing transcripts, missing turns, tool errors, session errors, or excessive handoffs.
322
1160
 
323
- For observability pipelines, wrap any trace store with `createVoiceTraceSinkStore(...)` and pass sinks such as `createVoiceTraceHTTPSink(...)`. The wrapper still writes to your normal file, SQLite, or Postgres store, then fans out appended events to your warehouse, logs, S3 bridge, or analytics endpoint. Use `awaitDelivery: true` only when you want trace delivery to block append completion. For durable delivery, pass `deliveryQueue` and run `createVoiceTraceSinkDeliveryWorker(...)` or `createVoiceTraceSinkDeliveryWorkerLoop(...)`; the worker uses the same Redis lease/idempotency primitives as ops workers and supports retries plus dead-letter stores.
1161
+ For observability pipelines, wrap any trace store with `createVoiceTraceSinkStore(...)` and pass sinks such as `createVoiceTraceHTTPSink(...)`. The wrapper still writes to your normal file, SQLite, or Postgres store, then fans out appended events to your warehouse, logs, S3 bridge, or analytics endpoint. Use `awaitDelivery: true` only when you want trace delivery to block append completion. For durable delivery, pass `deliveryQueue` and run `createVoiceTraceSinkDeliveryWorker(...)` or `createVoiceTraceSinkDeliveryWorkerLoop(...)`; the worker uses the same Redis lease/idempotency primitives as ops workers and supports retries plus dead-letter stores. Mount `createVoiceTraceDeliveryRoutes({ store: runtimeStorage.traceDeliveries, worker })` to expose `/traces/deliveries`, `/api/voice-trace-deliveries`, and an explicit `POST /api/voice-trace-deliveries/drain` retry path.
324
1162
 
325
1163
  When traces may leave your private runtime, pass `redact: true` or a redaction config to `exportVoiceTrace(...)`, `renderVoiceTraceMarkdown(...)`, `renderVoiceTraceHTML(...)`, or `buildVoiceTraceReplay(...)`. The built-in redactor scrubs common email addresses, phone numbers, and sensitive keys like `token`, `secret`, `password`, `apiKey`, `authorization`, `phone`, and `email`; you can pass custom keys or replacement text for stricter policies.
326
1164
 
327
1165
  For retention jobs, `pruneVoiceTraceEvents(...)` works against any trace store. Use `dryRun: true` before deleting, filter by session, trace, scenario, turn, or event type, cap each run with `limit`, or keep only the newest N matching events with `keepNewest`.
328
1166
 
1167
+ For whole-runtime data control, use `buildVoiceDataRetentionPlan(...)` first and then `applyVoiceDataRetentionPolicy(...)` when the deletion set is correct. The policy works across stores exposed by file, SQLite, or Postgres runtime storage, including sessions, traces, trace deliveries, audit deliveries, reviews, ops tasks, integration events, and campaigns. A cutoff or per-scope `keepNewest` selector is required before anything is deleted, so an empty policy reports skipped scopes instead of wiping data.
1168
+
1169
+ ```ts
1170
+ const plan = await buildVoiceDataRetentionPlan({
1171
+ before: Date.now() - 30 * 24 * 60 * 60 * 1000,
1172
+ ...runtimeStorage
1173
+ });
1174
+
1175
+ console.log(plan.scopes);
1176
+
1177
+ await applyVoiceDataRetentionPolicy({
1178
+ audit: runtimeStorage.audit,
1179
+ before: Date.now() - 30 * 24 * 60 * 60 * 1000,
1180
+ ...runtimeStorage
1181
+ });
1182
+ ```
1183
+
1184
+ Use `createVoiceAuditLogger(...)` when you need append-only compliance evidence outside call traces. The logger records provider calls, tool calls, handoffs, retention runs, and operator actions into `runtimeStorage.audit`, so self-hosted teams can prove who changed what, which provider ran, which tool fired, and what data-control policy deleted.
1185
+
1186
+ Pass `audit` directly to `createVoiceAgent(...)` to record model calls as provider-call audit events and tool executions as tool-call audit events. Pass it to `createVoiceAgentSquad(...)` to record squad handoffs automatically. Use `auditProvider` and `auditModel` on agents when you want readiness and compliance reports to show the actual model provider instead of the agent id.
1187
+
1188
+ For compliance pipelines, wrap any audit store with `createVoiceAuditSinkStore(...)` and pass sinks such as `createVoiceAuditHTTPSink(...)`. Audit sinks redact by default, support HMAC signing, retries, event-type filters, optional blocking delivery, durable delivery queues through `runtimeStorage.auditDeliveries`, and background workers through `createVoiceAuditSinkDeliveryWorker(...)` or `createVoiceAuditSinkDeliveryWorkerLoop(...)`. File, SQLite, and Postgres runtime storage all expose `auditDeliveries`, so teams can ship evidence to a SIEM, warehouse, or internal security service without a hosted dashboard. Mount `createVoiceAuditDeliveryRoutes({ store: runtimeStorage.auditDeliveries, worker })` to expose `/audit/deliveries`, `/api/voice-audit-deliveries`, and an explicit `POST /api/voice-audit-deliveries/drain` retry path.
1189
+
1190
+ Pass `audit: runtimeStorage.audit` into production readiness when audit coverage should block deploys. By default readiness requires provider-call, retention-policy, and operator-action audit evidence; retention-policy evidence must be from the last 7 days so a stale one-time audit event does not certify an active retention job. Override required event types or freshness with `audit: { store: runtimeStorage.audit, require: [{ type: 'retention.policy', maxAgeMs: ... }] }` when a deployment has different compliance gates. Pass `auditDeliveries: runtimeStorage.auditDeliveries` and `traceDeliveries: runtimeStorage.traceDeliveries` when sink export health should also block deploys; failed or dead-lettered deliveries fail readiness, pending deliveries warn, and pending deliveries older than the configured fail window fail readiness.
1191
+
1192
+ Mount `createVoiceAuditTrailRoutes(...)` to expose `/api/voice-audit` and `/audit` over the same store. File, SQLite, and Postgres runtime storage all expose `runtimeStorage.audit`. The JSON and HTML surfaces support filters like `type`, `outcome`, `actorId`, `resourceType`, `resourceId`, `sessionId`, `traceId`, and `limit`, so operators can search audit evidence without writing a custom viewer first.
1193
+
1194
+ Use `exportVoiceAuditTrail(...)` or `buildVoiceAuditExport(...)` when audit evidence needs to leave the app. Pass `redact: true` to scrub sensitive keys plus common email and phone patterns from payloads and metadata before generating JSON, Markdown, or HTML. Audit trail routes also expose redacted exports at `/api/voice-audit/export`, `/api/voice-audit/export?format=markdown`, `/api/voice-audit/export?format=html`, and `/audit/export`; export routes redact by default unless `redact=false` is passed.
1195
+
329
1196
  ## Production Voice Ops
330
1197
 
331
1198
  The recommended production pattern is:
@@ -733,6 +1600,59 @@ app.use(
733
1600
 
734
1601
  Client state now exposes `assistantAudio` on the stream/controller helpers, so apps can buffer or play synthesized chunks without inventing a second transport.
735
1602
 
1603
+ ## OpenAI Realtime
1604
+
1605
+ Use `createOpenAIRealtimeAdapter(...)` when you want a direct OpenAI Realtime speech-to-speech output path for live smoke tests, duplex benchmarks, or custom realtime orchestration. It implements the same `RealtimeAdapter` contract used by the benchmark harness, so the provider can stream `response.output_audio.delta` audio chunks into AbsoluteJS voice events while still emitting normalized transcript, error, and close events.
1606
+
1607
+ ```ts
1608
+ import { createOpenAIRealtimeAdapter } from '@absolutejs/voice';
1609
+ import { runTTSAdapterFixture } from '@absolutejs/voice/testing';
1610
+
1611
+ const realtime = createOpenAIRealtimeAdapter({
1612
+ apiKey: process.env.OPENAI_API_KEY!,
1613
+ instructions: 'Answer in one concise sentence.',
1614
+ model: 'gpt-realtime',
1615
+ voice: 'marin'
1616
+ });
1617
+
1618
+ app.use(
1619
+ voice({
1620
+ path: '/voice',
1621
+ realtime,
1622
+ realtimeInputFormat: {
1623
+ channels: 1,
1624
+ container: 'raw',
1625
+ encoding: 'pcm_s16le',
1626
+ sampleRateHz: 24000
1627
+ },
1628
+ session,
1629
+ onTurn: async ({ turn }) => ({
1630
+ assistantText: `You said: ${turn.text}`
1631
+ }),
1632
+ onComplete: async () => {}
1633
+ })
1634
+ );
1635
+
1636
+ const report = await runTTSAdapterFixture(
1637
+ realtime,
1638
+ {
1639
+ id: 'openai-realtime-smoke',
1640
+ text: 'Say exactly: AbsoluteJS realtime is online.',
1641
+ title: 'OpenAI Realtime smoke'
1642
+ },
1643
+ {
1644
+ realtimeFormat: {
1645
+ channels: 1,
1646
+ container: 'raw',
1647
+ encoding: 'pcm_s16le',
1648
+ sampleRateHz: 24000
1649
+ }
1650
+ }
1651
+ );
1652
+ ```
1653
+
1654
+ For server-to-server use, the adapter opens a WebSocket to OpenAI, sends `session.update`, streams text or base64 PCM input, and emits raw 24kHz mono `pcm_s16le` assistant audio. It requires raw 24kHz mono PCM input because that is the OpenAI Realtime PCM format. The main `voice(...)` route can now run in cascaded mode with `stt` plus optional `tts`, or direct realtime mode with `realtime`. Browser demos should make sure the captured PCM format matches `realtimeInputFormat` or resample before sending audio.
1655
+
736
1656
  If you want a minimal browser playback path, use the client audio player:
737
1657
 
738
1658
  ```ts
@@ -1069,6 +1989,136 @@ app.use(
1069
1989
  - `benchmark-results/sessions-cheap-stt-runs-3.json`
1070
1990
  - `benchmark-results/stt-routing-run-manifest.json`
1071
1991
 
1992
+ ## LLM Provider Routing
1993
+
1994
+ Use `createVoiceProviderRouter(...)` when your assistant can run on more than one LLM provider. The router keeps provider choice inside your app: you define the available model adapters, profile each provider, and choose a policy.
1995
+
1996
+ ```ts
1997
+ import {
1998
+ createAnthropicVoiceAssistantModel,
1999
+ createGeminiVoiceAssistantModel,
2000
+ createOpenAIVoiceAssistantModel,
2001
+ createVoiceProviderRouter,
2002
+ resolveVoiceProviderRoutingPolicyPreset
2003
+ } from '@absolutejs/voice';
2004
+
2005
+ const model = createVoiceProviderRouter({
2006
+ providers: {
2007
+ openai: createOpenAIVoiceAssistantModel({ apiKey: process.env.OPENAI_API_KEY! }),
2008
+ anthropic: createAnthropicVoiceAssistantModel({ apiKey: process.env.ANTHROPIC_API_KEY! }),
2009
+ gemini: createGeminiVoiceAssistantModel({ apiKey: process.env.GEMINI_API_KEY! })
2010
+ },
2011
+ providerHealth: {
2012
+ failureThreshold: 1,
2013
+ cooldownMs: 30_000,
2014
+ rateLimitCooldownMs: 120_000
2015
+ },
2016
+ providerProfiles: {
2017
+ openai: { cost: 6, latencyMs: 650, quality: 0.92, timeoutMs: 3500 },
2018
+ anthropic: { cost: 7, latencyMs: 850, quality: 0.95, timeoutMs: 4500 },
2019
+ gemini: { cost: 2, latencyMs: 700, quality: 0.86, timeoutMs: 3500 }
2020
+ },
2021
+ policy: resolveVoiceProviderRoutingPolicyPreset('balanced')
2022
+ });
2023
+ ```
2024
+
2025
+ Built-in policy presets:
2026
+
2027
+ - `quality-first`: rank by `providerProfiles[provider].quality`, then priority, latency, and cost.
2028
+ - `latency-first`: rank by expected latency.
2029
+ - `cost-first`: rank by expected cost.
2030
+ - `cost-cap`: rank by cost and reject providers above `maxCost`.
2031
+ - `balanced`: weighted score using cost, latency, quality, and priority.
2032
+
2033
+ Budget filters are strict. If you pass `maxCost`, `maxLatencyMs`, or `minQuality`, providers outside those limits are removed before ranking, even if they were selected by the request.
2034
+
2035
+ ```ts
2036
+ const policy = resolveVoiceProviderRoutingPolicyPreset('cost-cap', {
2037
+ maxCost: 3,
2038
+ minQuality: 0.82
2039
+ });
2040
+ ```
2041
+
2042
+ Use `runVoiceProviderRoutingContract(...)` when provider fallback needs to be certified before production. The contract reads provider routing trace events and verifies the expected selected provider, fallback provider, status, and kind in order.
2043
+
2044
+ ```ts
2045
+ import { runVoiceProviderRoutingContract } from '@absolutejs/voice';
2046
+
2047
+ const report = await runVoiceProviderRoutingContract({
2048
+ store: runtime.traces,
2049
+ contract: {
2050
+ id: 'openai-to-anthropic-fallback',
2051
+ expect: [
2052
+ {
2053
+ kind: 'llm',
2054
+ provider: 'openai',
2055
+ selectedProvider: 'openai',
2056
+ fallbackProvider: 'anthropic',
2057
+ status: 'error'
2058
+ },
2059
+ {
2060
+ kind: 'llm',
2061
+ provider: 'anthropic',
2062
+ selectedProvider: 'openai',
2063
+ status: 'fallback'
2064
+ }
2065
+ ]
2066
+ }
2067
+ });
2068
+
2069
+ if (!report.pass) {
2070
+ throw new Error(report.issues.map((issue) => issue.message).join('\n'));
2071
+ }
2072
+ ```
2073
+
2074
+ Pass provider routing contract reports into production readiness through `providerRoutingContracts`. Readiness fails when a fallback contract fails, so model-routing regressions become deploy blockers instead of dashboard-only surprises.
2075
+
2076
+ For full control, pass an object policy:
2077
+
2078
+ ```ts
2079
+ const model = createVoiceProviderRouter({
2080
+ providers,
2081
+ providerProfiles,
2082
+ policy: {
2083
+ strategy: 'balanced',
2084
+ maxLatencyMs: 1000,
2085
+ weights: { cost: 1, latencyMs: 0.004, quality: 12 }
2086
+ }
2087
+ });
2088
+ ```
2089
+
2090
+ The same profile and policy shape also works for STT and TTS provider routers, so a self-hosted app can choose the fastest provider for live calls, cap cost for background work, or require a minimum quality score without hard-coding provider branches.
2091
+
2092
+ ```ts
2093
+ const stt = createVoiceSTTProviderRouter({
2094
+ adapters: {
2095
+ deepgram,
2096
+ assemblyai
2097
+ },
2098
+ providerHealth: { cooldownMs: 30_000 },
2099
+ providerProfiles: {
2100
+ deepgram: { cost: 4, latencyMs: 180, quality: 0.93, timeoutMs: 1500 },
2101
+ assemblyai: { cost: 2, latencyMs: 650, quality: 0.88, timeoutMs: 3000 }
2102
+ },
2103
+ policy: resolveVoiceProviderRoutingPolicyPreset('latency-first')
2104
+ });
2105
+
2106
+ const tts = createVoiceTTSProviderRouter({
2107
+ adapters: {
2108
+ elevenlabs,
2109
+ openai
2110
+ },
2111
+ providerProfiles: {
2112
+ elevenlabs: { cost: 5, latencyMs: 220, quality: 0.94 },
2113
+ openai: { cost: 2, latencyMs: 320, quality: 0.87 }
2114
+ },
2115
+ policy: resolveVoiceProviderRoutingPolicyPreset('cost-cap', {
2116
+ maxCost: 3,
2117
+ minQuality: 0.85
2118
+ })
2119
+ });
2120
+ ```
2121
+
1072
2122
  ## Presets
1073
2123
 
1074
2124
  Voice now ships named runtime presets so apps can start from a useful baseline instead of hand-tuning silence and capture settings every time.
@@ -1566,6 +2616,8 @@ Default reconnect strategy is `resume-last-turn`.
1566
2616
 
1567
2617
  If an adapter does not emit native end-of-turn events, core falls back to silence detection with a default `700ms` threshold.
1568
2618
 
2619
+ For browser/client proof, use `runVoiceReconnectContract(...)` or mount `createVoiceReconnectContractRoutes(...)` with captured reconnect snapshots. The contract verifies that a reconnect was observed, the stream resumed before exhaustion, and replayed state did not duplicate committed turn IDs.
2620
+
1569
2621
  ## STT Fallback
1570
2622
 
1571
2623
  You can pair a primary vendor with an optional fallback vendor per route when you need extra reliability for accents, edge environments, or short commands.