@absolutejs/voice 0.0.22-beta.14 → 0.0.22-beta.140
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.
- package/README.md +781 -5
- package/dist/agent.d.ts +24 -0
- package/dist/agentSquadContract.d.ts +64 -0
- package/dist/angular/index.d.ts +9 -0
- package/dist/angular/index.js +1418 -46
- package/dist/angular/voice-campaign-dialer-proof.service.d.ts +14 -0
- package/dist/angular/voice-controller.service.d.ts +1 -0
- package/dist/angular/voice-ops-status.component.d.ts +15 -0
- package/dist/angular/voice-ops-status.service.d.ts +12 -0
- package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
- package/dist/angular/voice-provider-status.service.d.ts +12 -0
- package/dist/angular/voice-routing-status.service.d.ts +11 -0
- package/dist/angular/voice-stream.service.d.ts +3 -0
- package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
- package/dist/angular/voice-turn-latency.service.d.ts +13 -0
- package/dist/angular/voice-turn-quality.service.d.ts +12 -0
- package/dist/angular/voice-workflow-status.service.d.ts +12 -0
- package/dist/assistantHealth.d.ts +81 -0
- package/dist/audit.d.ts +128 -0
- package/dist/auditDeliveryRoutes.d.ts +85 -0
- package/dist/auditExport.d.ts +34 -0
- package/dist/auditRoutes.d.ts +66 -0
- package/dist/auditSinks.d.ts +133 -0
- package/dist/bargeInRoutes.d.ts +56 -0
- package/dist/campaign.d.ts +610 -0
- package/dist/campaignDialers.d.ts +90 -0
- package/dist/client/actions.d.ts +105 -0
- package/dist/client/bargeInMonitor.d.ts +7 -0
- package/dist/client/campaignDialerProof.d.ts +23 -0
- package/dist/client/connection.d.ts +3 -0
- package/dist/client/duplex.d.ts +1 -1
- package/dist/client/htmxBootstrap.js +747 -15
- package/dist/client/index.d.ts +40 -0
- package/dist/client/index.js +2162 -10
- package/dist/client/liveTurnLatency.d.ts +41 -0
- package/dist/client/opsStatus.d.ts +19 -0
- package/dist/client/opsStatusWidget.d.ts +40 -0
- package/dist/client/providerCapabilities.d.ts +19 -0
- package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
- package/dist/client/providerSimulationControls.d.ts +33 -0
- package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
- package/dist/client/providerStatus.d.ts +19 -0
- package/dist/client/providerStatusWidget.d.ts +32 -0
- package/dist/client/routingStatus.d.ts +19 -0
- package/dist/client/routingStatusWidget.d.ts +28 -0
- package/dist/client/traceTimeline.d.ts +19 -0
- package/dist/client/traceTimelineWidget.d.ts +32 -0
- package/dist/client/turnLatency.d.ts +22 -0
- package/dist/client/turnLatencyWidget.d.ts +33 -0
- package/dist/client/turnQuality.d.ts +19 -0
- package/dist/client/turnQualityWidget.d.ts +32 -0
- package/dist/client/workflowStatus.d.ts +19 -0
- package/dist/dataControl.d.ts +47 -0
- package/dist/demoReadyRoutes.d.ts +98 -0
- package/dist/diagnosticsRoutes.d.ts +44 -0
- package/dist/evalRoutes.d.ts +213 -0
- package/dist/fileStore.d.ts +11 -2
- package/dist/handoff.d.ts +54 -0
- package/dist/handoffHealth.d.ts +94 -0
- package/dist/index.d.ts +104 -9
- package/dist/index.js +17435 -4717
- package/dist/liveLatency.d.ts +78 -0
- package/dist/modelAdapters.d.ts +23 -2
- package/dist/openaiRealtime.d.ts +27 -0
- package/dist/openaiTTS.d.ts +18 -0
- package/dist/opsConsoleRoutes.d.ts +77 -0
- package/dist/opsStatus.d.ts +68 -0
- package/dist/opsStatusRoutes.d.ts +33 -0
- package/dist/opsWebhook.d.ts +126 -0
- package/dist/outcomeContract.d.ts +112 -0
- package/dist/phoneAgent.d.ts +62 -0
- package/dist/phoneAgentProductionSmoke.d.ts +115 -0
- package/dist/postgresStore.d.ts +13 -2
- package/dist/productionReadiness.d.ts +267 -0
- package/dist/providerAdapters.d.ts +48 -0
- package/dist/providerCapabilities.d.ts +92 -0
- package/dist/providerHealth.d.ts +79 -0
- package/dist/providerRoutingContract.d.ts +38 -0
- package/dist/qualityRoutes.d.ts +76 -0
- package/dist/queue.d.ts +61 -0
- package/dist/react/VoiceOpsStatus.d.ts +6 -0
- package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
- package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
- package/dist/react/VoiceProviderStatus.d.ts +6 -0
- package/dist/react/VoiceRoutingStatus.d.ts +6 -0
- package/dist/react/VoiceTraceTimeline.d.ts +6 -0
- package/dist/react/VoiceTurnLatency.d.ts +6 -0
- package/dist/react/VoiceTurnQuality.d.ts +6 -0
- package/dist/react/index.d.ts +18 -0
- package/dist/react/index.js +2750 -14
- package/dist/react/useVoiceCampaignDialerProof.d.ts +10 -0
- package/dist/react/useVoiceController.d.ts +3 -0
- package/dist/react/useVoiceOpsStatus.d.ts +8 -0
- package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
- package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
- package/dist/react/useVoiceProviderStatus.d.ts +8 -0
- package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/react/useVoiceStream.d.ts +3 -0
- package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
- package/dist/react/useVoiceTurnLatency.d.ts +9 -0
- package/dist/react/useVoiceTurnQuality.d.ts +8 -0
- package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
- package/dist/reconnectContract.d.ts +87 -0
- package/dist/resilienceRoutes.d.ts +142 -0
- package/dist/sessionReplay.d.ts +185 -0
- package/dist/simulationSuite.d.ts +120 -0
- package/dist/sqliteStore.d.ts +13 -2
- package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
- package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
- package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
- package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
- package/dist/svelte/createVoiceProviderStatus.d.ts +10 -0
- package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
- package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
- package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
- package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
- package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
- package/dist/svelte/index.d.ts +10 -0
- package/dist/svelte/index.js +2176 -202
- package/dist/telephony/contract.d.ts +61 -0
- package/dist/telephony/matrix.d.ts +97 -0
- package/dist/telephony/plivo.d.ts +254 -0
- package/dist/telephony/telnyx.d.ts +247 -0
- package/dist/telephony/twilio.d.ts +135 -2
- package/dist/telephonyOutcome.d.ts +201 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +2973 -156
- package/dist/testing/ioProviderSimulator.d.ts +41 -0
- package/dist/testing/providerSimulator.d.ts +44 -0
- package/dist/toolContract.d.ts +130 -0
- package/dist/toolRuntime.d.ts +50 -0
- package/dist/trace.d.ts +1 -1
- package/dist/traceDeliveryRoutes.d.ts +86 -0
- package/dist/traceTimeline.d.ts +93 -0
- package/dist/turnLatency.d.ts +95 -0
- package/dist/turnQuality.d.ts +94 -0
- package/dist/types.d.ts +170 -4
- package/dist/vue/VoiceOpsStatus.d.ts +30 -0
- package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
- package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
- package/dist/vue/VoiceProviderStatus.d.ts +51 -0
- package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
- package/dist/vue/VoiceTurnLatency.d.ts +69 -0
- package/dist/vue/VoiceTurnQuality.d.ts +51 -0
- package/dist/vue/index.d.ts +17 -0
- package/dist/vue/index.js +2660 -31
- package/dist/vue/useVoiceCampaignDialerProof.d.ts +11 -0
- package/dist/vue/useVoiceController.d.ts +2 -1
- package/dist/vue/useVoiceOpsStatus.d.ts +9 -0
- package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
- package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
- package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
- package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/vue/useVoiceStream.d.ts +4 -1
- package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
- package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
- package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
- package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
- package/dist/workflowContract.d.ts +91 -0
- 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
|
|
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
|
-
|
|
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,409 @@ 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
|
+
## Simulation Suite Path
|
|
218
|
+
|
|
219
|
+
Use `createVoiceSimulationSuiteRoutes(...)` when you want one pre-production proof surface for the things that usually live in separate dashboards or scripts:
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
import {
|
|
223
|
+
createVoiceSimulationSuiteRoutes,
|
|
224
|
+
createVoiceFileRuntimeStorage
|
|
225
|
+
} from '@absolutejs/voice';
|
|
226
|
+
|
|
227
|
+
const runtime = createVoiceFileRuntimeStorage({
|
|
228
|
+
directory: '.voice-runtime/support'
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
app.use(
|
|
232
|
+
createVoiceSimulationSuiteRoutes({
|
|
233
|
+
htmlPath: '/voice/simulations',
|
|
234
|
+
path: '/api/voice/simulations',
|
|
235
|
+
store: runtime.traces,
|
|
236
|
+
scenarios: workflowScenarios,
|
|
237
|
+
fixtureStore: scenarioFixtureStore,
|
|
238
|
+
tools: toolContracts,
|
|
239
|
+
outcomes: {
|
|
240
|
+
contracts: outcomeContracts,
|
|
241
|
+
events: runtime.events,
|
|
242
|
+
reviews: runtime.reviews,
|
|
243
|
+
sessions: runtime.session,
|
|
244
|
+
tasks: runtime.tasks
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
);
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
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.
|
|
251
|
+
|
|
252
|
+
## Phone Voice Agent In 20 Minutes
|
|
253
|
+
|
|
254
|
+
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.
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
import {
|
|
258
|
+
createVoicePhoneAgent,
|
|
259
|
+
createVoiceTelephonyOutcomePolicy,
|
|
260
|
+
runVoicePhoneAgentProductionSmokeContract
|
|
261
|
+
} from '@absolutejs/voice';
|
|
262
|
+
import { deepgram } from '@absolutejs/voice-deepgram';
|
|
263
|
+
|
|
264
|
+
const outcomePolicy = createVoiceTelephonyOutcomePolicy({
|
|
265
|
+
transferTarget: '+15551234567'
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
app
|
|
269
|
+
.use(
|
|
270
|
+
createVoicePhoneAgent({
|
|
271
|
+
setup: {
|
|
272
|
+
path: '/api/voice/phone/setup',
|
|
273
|
+
title: 'Support Phone Agent'
|
|
274
|
+
},
|
|
275
|
+
matrix: {
|
|
276
|
+
path: '/api/carriers',
|
|
277
|
+
title: 'AbsoluteJS Voice Carrier Matrix'
|
|
278
|
+
},
|
|
279
|
+
productionSmoke: {
|
|
280
|
+
maxAgeMs: 24 * 60 * 60 * 1000,
|
|
281
|
+
required: [
|
|
282
|
+
'carrier-contract',
|
|
283
|
+
'media-started',
|
|
284
|
+
'transcript',
|
|
285
|
+
'assistant-response',
|
|
286
|
+
'lifecycle-outcome',
|
|
287
|
+
'no-session-error',
|
|
288
|
+
'fresh-trace'
|
|
289
|
+
],
|
|
290
|
+
store: runtime.traces
|
|
291
|
+
},
|
|
292
|
+
carriers: [
|
|
293
|
+
{
|
|
294
|
+
provider: 'twilio',
|
|
295
|
+
options: {
|
|
296
|
+
context: {},
|
|
297
|
+
outcomePolicy,
|
|
298
|
+
session: runtime.session,
|
|
299
|
+
stt: deepgram({ apiKey: process.env.DEEPGRAM_API_KEY! }),
|
|
300
|
+
streamPath: '/api/voice/twilio/stream',
|
|
301
|
+
twiml: {
|
|
302
|
+
path: '/api/voice/twilio',
|
|
303
|
+
streamUrl: process.env.TWILIO_STREAM_URL
|
|
304
|
+
},
|
|
305
|
+
webhook: {
|
|
306
|
+
path: '/api/voice/twilio/webhook',
|
|
307
|
+
signingSecret: process.env.TWILIO_AUTH_TOKEN
|
|
308
|
+
},
|
|
309
|
+
async onTurn({ turn }) {
|
|
310
|
+
return { assistantText: `I heard: ${turn.text}` };
|
|
311
|
+
},
|
|
312
|
+
onComplete: async () => {}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
]
|
|
316
|
+
}).routes
|
|
317
|
+
);
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
The wrapper mounts selected carrier routes plus two proof surfaces:
|
|
321
|
+
|
|
322
|
+
- `/api/voice/phone/setup`: one setup report with carrier URLs, smoke links, lifecycle stages, and readiness.
|
|
323
|
+
- `/api/voice/phone/setup?format=html`: copy/paste setup page for carrier dashboards.
|
|
324
|
+
- `/api/carriers`: carrier matrix JSON for Twilio, Telnyx, and Plivo.
|
|
325
|
+
- `/api/carriers?format=html`: side-by-side carrier readiness matrix.
|
|
326
|
+
- `/api/voice/phone/smoke-contract?sessionId=...`: trace-backed production smoke contract.
|
|
327
|
+
- `/voice/phone/smoke-contract?sessionId=...`: HTML production smoke contract.
|
|
328
|
+
|
|
329
|
+
The setup page tells you exactly what to copy into the carrier dashboard:
|
|
330
|
+
|
|
331
|
+
- 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.
|
|
332
|
+
- 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.
|
|
333
|
+
- 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.
|
|
334
|
+
|
|
335
|
+
Each configured carrier can also expose its own setup and smoke pages, for example:
|
|
336
|
+
|
|
337
|
+
- `/api/voice/twilio/setup?format=html`
|
|
338
|
+
- `/api/voice/twilio/smoke?format=html`
|
|
339
|
+
- `/api/voice/telnyx/setup?format=html`
|
|
340
|
+
- `/api/voice/telnyx/smoke?format=html`
|
|
341
|
+
- `/api/voice/plivo/setup?format=html`
|
|
342
|
+
- `/api/voice/plivo/smoke?format=html`
|
|
343
|
+
|
|
344
|
+
The phone-agent report normalizes the lifecycle schema across carriers:
|
|
345
|
+
|
|
346
|
+
- `ringing`
|
|
347
|
+
- `answered`
|
|
348
|
+
- `media-started`
|
|
349
|
+
- `transcript`
|
|
350
|
+
- `assistant-response`
|
|
351
|
+
- `transfer`
|
|
352
|
+
- `voicemail`
|
|
353
|
+
- `no-answer`
|
|
354
|
+
- `completed`
|
|
355
|
+
- `failed`
|
|
356
|
+
|
|
357
|
+
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.
|
|
358
|
+
|
|
359
|
+
After running a real smoke call, certify the phone-agent path from traces:
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
const smoke = await runVoicePhoneAgentProductionSmokeContract({
|
|
363
|
+
maxAgeMs: 24 * 60 * 60 * 1000,
|
|
364
|
+
required: [
|
|
365
|
+
'media-started',
|
|
366
|
+
'transcript',
|
|
367
|
+
'assistant-response',
|
|
368
|
+
'lifecycle-outcome',
|
|
369
|
+
'no-session-error',
|
|
370
|
+
'fresh-trace'
|
|
371
|
+
],
|
|
372
|
+
sessionId: 'phone-smoke-session',
|
|
373
|
+
store: runtime.traces
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
if (!smoke.pass) {
|
|
377
|
+
throw new Error(smoke.issues.map((issue) => issue.message).join('\n'));
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
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.
|
|
382
|
+
|
|
383
|
+
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`.
|
|
384
|
+
|
|
385
|
+
## Ops Status Hooks And Widgets
|
|
386
|
+
|
|
387
|
+
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.
|
|
388
|
+
|
|
389
|
+
```ts
|
|
390
|
+
import {
|
|
391
|
+
createVoiceDemoReadyRoutes,
|
|
392
|
+
createVoiceFileRuntimeStorage,
|
|
393
|
+
createVoiceOpsStatusRoutes,
|
|
394
|
+
summarizeVoiceOpsStatus
|
|
395
|
+
} from '@absolutejs/voice';
|
|
396
|
+
|
|
397
|
+
const runtime = createVoiceFileRuntimeStorage({ directory: '.voice-runtime/support' });
|
|
398
|
+
|
|
399
|
+
app.use(
|
|
400
|
+
createVoiceOpsStatusRoutes({
|
|
401
|
+
store: runtime.traces,
|
|
402
|
+
llmProviders: ['openai', 'anthropic', 'gemini'],
|
|
403
|
+
sttProviders: ['deepgram', 'assemblyai']
|
|
404
|
+
})
|
|
405
|
+
);
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
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.
|
|
409
|
+
|
|
410
|
+
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:
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
app.use(
|
|
414
|
+
createVoiceDemoReadyRoutes({
|
|
415
|
+
opsStatus: {
|
|
416
|
+
href: '/api/voice/ops-status',
|
|
417
|
+
load: () => summarizeVoiceOpsStatus(opsStatusOptions)
|
|
418
|
+
},
|
|
419
|
+
phoneSetup: {
|
|
420
|
+
href: '/api/voice/phone/setup?format=html',
|
|
421
|
+
load: () => phoneAgentSetupReport
|
|
422
|
+
},
|
|
423
|
+
phoneSmoke: {
|
|
424
|
+
href: '/voice/phone/smoke-contract',
|
|
425
|
+
load: () => phoneSmokeReport
|
|
426
|
+
},
|
|
427
|
+
productionReadiness: {
|
|
428
|
+
href: '/production-readiness',
|
|
429
|
+
load: () => productionReadinessReport
|
|
430
|
+
}
|
|
431
|
+
})
|
|
432
|
+
);
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
```ts
|
|
436
|
+
app.use(
|
|
437
|
+
createVoiceOpsStatusRoutes({
|
|
438
|
+
include: { quality: false, sessions: false },
|
|
439
|
+
preferFixtureWorkflows: true,
|
|
440
|
+
store: runtime.traces
|
|
441
|
+
})
|
|
442
|
+
);
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### React Status Widget
|
|
446
|
+
|
|
447
|
+
```tsx
|
|
448
|
+
import { VoiceOpsStatus } from '@absolutejs/voice/react';
|
|
449
|
+
|
|
450
|
+
export function OpsBadge() {
|
|
451
|
+
return <VoiceOpsStatus intervalMs={5000} />;
|
|
452
|
+
}
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### Vue Status Widget
|
|
456
|
+
|
|
457
|
+
```vue
|
|
458
|
+
<script setup lang="ts">
|
|
459
|
+
import { VoiceOpsStatus } from '@absolutejs/voice/vue';
|
|
460
|
+
</script>
|
|
461
|
+
|
|
462
|
+
<template>
|
|
463
|
+
<VoiceOpsStatus :interval-ms="5000" />
|
|
464
|
+
</template>
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### Svelte Status Widget
|
|
468
|
+
|
|
469
|
+
```svelte
|
|
470
|
+
<script lang="ts">
|
|
471
|
+
import { onDestroy, onMount } from 'svelte';
|
|
472
|
+
import { createVoiceOpsStatus } from '@absolutejs/voice/svelte';
|
|
473
|
+
|
|
474
|
+
const status = createVoiceOpsStatus('/api/voice/ops-status', { intervalMs: 5000 });
|
|
475
|
+
let html = '';
|
|
476
|
+
onMount(() => status.subscribe(() => (html = status.getHTML())));
|
|
477
|
+
onDestroy(() => status.close());
|
|
478
|
+
</script>
|
|
479
|
+
|
|
480
|
+
{@html html}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Angular Status Widget
|
|
484
|
+
|
|
485
|
+
```ts
|
|
486
|
+
import { VoiceOpsStatusService } from '@absolutejs/voice/angular';
|
|
487
|
+
|
|
488
|
+
status = inject(VoiceOpsStatusService).connect('/api/voice/ops-status', {
|
|
489
|
+
intervalMs: 5000
|
|
490
|
+
});
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
```html
|
|
494
|
+
<h2>{{ status.report()?.status === 'pass' ? 'Passing' : 'Needs attention' }}</h2>
|
|
495
|
+
<p>{{ status.report()?.passed ?? 0 }} passing checks</p>
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### HTML Or HTMX Status Widget
|
|
499
|
+
|
|
500
|
+
```html
|
|
501
|
+
<div id="voice-ops-status"></div>
|
|
502
|
+
<script type="module">
|
|
503
|
+
import { mountVoiceOpsStatus } from '@absolutejs/voice/client';
|
|
504
|
+
|
|
505
|
+
mountVoiceOpsStatus(document.querySelector('#voice-ops-status'), '/api/voice/ops-status', {
|
|
506
|
+
intervalMs: 5000
|
|
507
|
+
});
|
|
508
|
+
</script>
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
For custom elements:
|
|
512
|
+
|
|
513
|
+
```html
|
|
514
|
+
<absolute-voice-ops-status interval-ms="5000"></absolute-voice-ops-status>
|
|
515
|
+
<script type="module">
|
|
516
|
+
import { defineVoiceOpsStatusElement } from '@absolutejs/voice/client';
|
|
517
|
+
defineVoiceOpsStatusElement();
|
|
518
|
+
</script>
|
|
519
|
+
```
|
|
520
|
+
|
|
76
521
|
## Voice Assistants
|
|
77
522
|
|
|
78
523
|
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 +657,21 @@ const billingAgent = createVoiceAgent({
|
|
|
212
657
|
const frontDesk = createVoiceAgentSquad({
|
|
213
658
|
id: 'front-desk',
|
|
214
659
|
defaultAgentId: 'support',
|
|
215
|
-
agents: [supportAgent, billingAgent]
|
|
660
|
+
agents: [supportAgent, billingAgent],
|
|
661
|
+
handoffPolicy: ({ handoff }) => {
|
|
662
|
+
if (handoff.targetAgentId === 'billing') {
|
|
663
|
+
return {
|
|
664
|
+
summary: 'Route verified billing requests to the billing specialist.',
|
|
665
|
+
metadata: { queue: 'billing' }
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
return {
|
|
670
|
+
allow: false,
|
|
671
|
+
reason: `No approved route for ${handoff.targetAgentId}.`,
|
|
672
|
+
escalate: { reason: 'unsupported-specialist' }
|
|
673
|
+
};
|
|
674
|
+
}
|
|
216
675
|
});
|
|
217
676
|
|
|
218
677
|
voice({
|
|
@@ -226,6 +685,56 @@ voice({
|
|
|
226
685
|
|
|
227
686
|
`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
687
|
|
|
688
|
+
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.
|
|
689
|
+
|
|
690
|
+
Use `runVoiceAgentSquadContract(...)` in tests or readiness checks when you need proof that a specialist graph still routes correctly:
|
|
691
|
+
|
|
692
|
+
```ts
|
|
693
|
+
import {
|
|
694
|
+
createVoiceMemoryTraceEventStore,
|
|
695
|
+
runVoiceAgentSquadContract
|
|
696
|
+
} from '@absolutejs/voice';
|
|
697
|
+
|
|
698
|
+
const trace = createVoiceMemoryTraceEventStore();
|
|
699
|
+
const frontDesk = createVoiceAgentSquad({
|
|
700
|
+
id: 'front-desk',
|
|
701
|
+
defaultAgentId: 'support',
|
|
702
|
+
agents: [supportAgent, billingAgent],
|
|
703
|
+
trace
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
const report = await runVoiceAgentSquadContract({
|
|
707
|
+
context: {},
|
|
708
|
+
squad: frontDesk,
|
|
709
|
+
trace,
|
|
710
|
+
contract: {
|
|
711
|
+
id: 'billing-route',
|
|
712
|
+
scenarioId: 'billing-route',
|
|
713
|
+
turns: [
|
|
714
|
+
{
|
|
715
|
+
text: 'I have a billing question.',
|
|
716
|
+
expect: {
|
|
717
|
+
finalAgentId: 'billing',
|
|
718
|
+
outcome: 'assistant',
|
|
719
|
+
assistantIncludes: ['billing'],
|
|
720
|
+
handoffs: [
|
|
721
|
+
{
|
|
722
|
+
fromAgentId: 'support',
|
|
723
|
+
targetAgentId: 'billing',
|
|
724
|
+
status: 'allowed'
|
|
725
|
+
}
|
|
726
|
+
]
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
]
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
if (!report.pass) {
|
|
734
|
+
throw new Error(report.issues.map((issue) => issue.message).join('\n'));
|
|
735
|
+
}
|
|
736
|
+
```
|
|
737
|
+
|
|
229
738
|
## Traces And Replay
|
|
230
739
|
|
|
231
740
|
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 +742,22 @@ Use trace stores when you want every call to be inspectable outside a hosted pla
|
|
|
233
742
|
```ts
|
|
234
743
|
import {
|
|
235
744
|
buildVoiceTraceReplay,
|
|
745
|
+
buildVoiceAuditExport,
|
|
746
|
+
createVoiceAuditHTTPSink,
|
|
747
|
+
createVoiceAuditLogger,
|
|
748
|
+
createVoiceAuditSinkDeliveryWorker,
|
|
749
|
+
createVoiceAuditSinkStore,
|
|
750
|
+
createVoiceAuditTrailRoutes,
|
|
236
751
|
createVoiceAgent,
|
|
237
752
|
createVoiceFileRuntimeStorage,
|
|
238
753
|
createVoiceRedisTaskLeaseCoordinator,
|
|
754
|
+
createVoiceTraceDeliveryRoutes,
|
|
239
755
|
createVoiceTraceHTTPSink,
|
|
240
756
|
createVoiceTraceSinkStore,
|
|
241
757
|
createVoiceTraceSinkDeliveryWorker,
|
|
758
|
+
buildVoiceDataRetentionPlan,
|
|
242
759
|
exportVoiceTrace,
|
|
760
|
+
applyVoiceDataRetentionPolicy,
|
|
243
761
|
pruneVoiceTraceEvents,
|
|
244
762
|
voice
|
|
245
763
|
} from '@absolutejs/voice';
|
|
@@ -251,6 +769,30 @@ const runtimeStorage = createVoiceFileRuntimeStorage({
|
|
|
251
769
|
const redisLeases = createVoiceRedisTaskLeaseCoordinator({
|
|
252
770
|
url: process.env.REDIS_URL
|
|
253
771
|
});
|
|
772
|
+
const auditStore = createVoiceAuditSinkStore({
|
|
773
|
+
store: runtimeStorage.audit,
|
|
774
|
+
deliveryQueue: runtimeStorage.auditDeliveries,
|
|
775
|
+
sinks: [
|
|
776
|
+
createVoiceAuditHTTPSink({
|
|
777
|
+
id: 'security-warehouse',
|
|
778
|
+
signingSecret: process.env.VOICE_AUDIT_SINK_SECRET,
|
|
779
|
+
url: process.env.VOICE_AUDIT_SINK_URL!
|
|
780
|
+
})
|
|
781
|
+
]
|
|
782
|
+
});
|
|
783
|
+
const audit = createVoiceAuditLogger(auditStore);
|
|
784
|
+
const auditSinkWorker = createVoiceAuditSinkDeliveryWorker({
|
|
785
|
+
deliveries: runtimeStorage.auditDeliveries,
|
|
786
|
+
leases: redisLeases,
|
|
787
|
+
sinks: [
|
|
788
|
+
createVoiceAuditHTTPSink({
|
|
789
|
+
id: 'security-warehouse',
|
|
790
|
+
signingSecret: process.env.VOICE_AUDIT_SINK_SECRET,
|
|
791
|
+
url: process.env.VOICE_AUDIT_SINK_URL!
|
|
792
|
+
})
|
|
793
|
+
],
|
|
794
|
+
workerId: 'audit-sink-worker'
|
|
795
|
+
});
|
|
254
796
|
const trace = createVoiceTraceSinkStore({
|
|
255
797
|
store: runtimeStorage.traces,
|
|
256
798
|
deliveryQueue: runtimeStorage.traceDeliveries,
|
|
@@ -277,6 +819,9 @@ const traceSinkWorker = createVoiceTraceSinkDeliveryWorker({
|
|
|
277
819
|
|
|
278
820
|
const supportAgent = createVoiceAgent({
|
|
279
821
|
id: 'support',
|
|
822
|
+
audit,
|
|
823
|
+
auditProvider: 'openai',
|
|
824
|
+
auditModel: 'gpt-4.1',
|
|
280
825
|
trace,
|
|
281
826
|
model: {
|
|
282
827
|
async generate() {
|
|
@@ -293,6 +838,17 @@ voice({
|
|
|
293
838
|
onTurn: supportAgent.onTurn,
|
|
294
839
|
onComplete: async () => {}
|
|
295
840
|
});
|
|
841
|
+
app.use(
|
|
842
|
+
createVoiceAuditTrailRoutes({
|
|
843
|
+
store: runtimeStorage.audit
|
|
844
|
+
})
|
|
845
|
+
);
|
|
846
|
+
app.use(
|
|
847
|
+
createVoiceTraceDeliveryRoutes({
|
|
848
|
+
store: runtimeStorage.traceDeliveries,
|
|
849
|
+
worker: traceSinkWorker
|
|
850
|
+
})
|
|
851
|
+
);
|
|
296
852
|
|
|
297
853
|
const replay = await exportVoiceTrace({
|
|
298
854
|
store: runtimeStorage.traces,
|
|
@@ -314,18 +870,53 @@ await pruneVoiceTraceEvents({
|
|
|
314
870
|
store: runtimeStorage.traces,
|
|
315
871
|
before: Date.now() - 30 * 24 * 60 * 60 * 1000
|
|
316
872
|
});
|
|
873
|
+
|
|
874
|
+
await audit.operatorAction({
|
|
875
|
+
action: 'review.approve',
|
|
876
|
+
actor: { id: 'operator-123', kind: 'operator' },
|
|
877
|
+
resource: { id: 'review-123', type: 'review' }
|
|
878
|
+
});
|
|
317
879
|
```
|
|
318
880
|
|
|
319
881
|
`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
882
|
|
|
321
883
|
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
884
|
|
|
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.
|
|
885
|
+
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
886
|
|
|
325
887
|
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
888
|
|
|
327
889
|
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
890
|
|
|
891
|
+
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.
|
|
892
|
+
|
|
893
|
+
```ts
|
|
894
|
+
const plan = await buildVoiceDataRetentionPlan({
|
|
895
|
+
before: Date.now() - 30 * 24 * 60 * 60 * 1000,
|
|
896
|
+
...runtimeStorage
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
console.log(plan.scopes);
|
|
900
|
+
|
|
901
|
+
await applyVoiceDataRetentionPolicy({
|
|
902
|
+
audit: runtimeStorage.audit,
|
|
903
|
+
before: Date.now() - 30 * 24 * 60 * 60 * 1000,
|
|
904
|
+
...runtimeStorage
|
|
905
|
+
});
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
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.
|
|
909
|
+
|
|
910
|
+
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.
|
|
911
|
+
|
|
912
|
+
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.
|
|
913
|
+
|
|
914
|
+
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.
|
|
915
|
+
|
|
916
|
+
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.
|
|
917
|
+
|
|
918
|
+
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.
|
|
919
|
+
|
|
329
920
|
## Production Voice Ops
|
|
330
921
|
|
|
331
922
|
The recommended production pattern is:
|
|
@@ -733,6 +1324,59 @@ app.use(
|
|
|
733
1324
|
|
|
734
1325
|
Client state now exposes `assistantAudio` on the stream/controller helpers, so apps can buffer or play synthesized chunks without inventing a second transport.
|
|
735
1326
|
|
|
1327
|
+
## OpenAI Realtime
|
|
1328
|
+
|
|
1329
|
+
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.
|
|
1330
|
+
|
|
1331
|
+
```ts
|
|
1332
|
+
import { createOpenAIRealtimeAdapter } from '@absolutejs/voice';
|
|
1333
|
+
import { runTTSAdapterFixture } from '@absolutejs/voice/testing';
|
|
1334
|
+
|
|
1335
|
+
const realtime = createOpenAIRealtimeAdapter({
|
|
1336
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
1337
|
+
instructions: 'Answer in one concise sentence.',
|
|
1338
|
+
model: 'gpt-realtime',
|
|
1339
|
+
voice: 'marin'
|
|
1340
|
+
});
|
|
1341
|
+
|
|
1342
|
+
app.use(
|
|
1343
|
+
voice({
|
|
1344
|
+
path: '/voice',
|
|
1345
|
+
realtime,
|
|
1346
|
+
realtimeInputFormat: {
|
|
1347
|
+
channels: 1,
|
|
1348
|
+
container: 'raw',
|
|
1349
|
+
encoding: 'pcm_s16le',
|
|
1350
|
+
sampleRateHz: 24000
|
|
1351
|
+
},
|
|
1352
|
+
session,
|
|
1353
|
+
onTurn: async ({ turn }) => ({
|
|
1354
|
+
assistantText: `You said: ${turn.text}`
|
|
1355
|
+
}),
|
|
1356
|
+
onComplete: async () => {}
|
|
1357
|
+
})
|
|
1358
|
+
);
|
|
1359
|
+
|
|
1360
|
+
const report = await runTTSAdapterFixture(
|
|
1361
|
+
realtime,
|
|
1362
|
+
{
|
|
1363
|
+
id: 'openai-realtime-smoke',
|
|
1364
|
+
text: 'Say exactly: AbsoluteJS realtime is online.',
|
|
1365
|
+
title: 'OpenAI Realtime smoke'
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
realtimeFormat: {
|
|
1369
|
+
channels: 1,
|
|
1370
|
+
container: 'raw',
|
|
1371
|
+
encoding: 'pcm_s16le',
|
|
1372
|
+
sampleRateHz: 24000
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
);
|
|
1376
|
+
```
|
|
1377
|
+
|
|
1378
|
+
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.
|
|
1379
|
+
|
|
736
1380
|
If you want a minimal browser playback path, use the client audio player:
|
|
737
1381
|
|
|
738
1382
|
```ts
|
|
@@ -1069,6 +1713,136 @@ app.use(
|
|
|
1069
1713
|
- `benchmark-results/sessions-cheap-stt-runs-3.json`
|
|
1070
1714
|
- `benchmark-results/stt-routing-run-manifest.json`
|
|
1071
1715
|
|
|
1716
|
+
## LLM Provider Routing
|
|
1717
|
+
|
|
1718
|
+
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.
|
|
1719
|
+
|
|
1720
|
+
```ts
|
|
1721
|
+
import {
|
|
1722
|
+
createAnthropicVoiceAssistantModel,
|
|
1723
|
+
createGeminiVoiceAssistantModel,
|
|
1724
|
+
createOpenAIVoiceAssistantModel,
|
|
1725
|
+
createVoiceProviderRouter,
|
|
1726
|
+
resolveVoiceProviderRoutingPolicyPreset
|
|
1727
|
+
} from '@absolutejs/voice';
|
|
1728
|
+
|
|
1729
|
+
const model = createVoiceProviderRouter({
|
|
1730
|
+
providers: {
|
|
1731
|
+
openai: createOpenAIVoiceAssistantModel({ apiKey: process.env.OPENAI_API_KEY! }),
|
|
1732
|
+
anthropic: createAnthropicVoiceAssistantModel({ apiKey: process.env.ANTHROPIC_API_KEY! }),
|
|
1733
|
+
gemini: createGeminiVoiceAssistantModel({ apiKey: process.env.GEMINI_API_KEY! })
|
|
1734
|
+
},
|
|
1735
|
+
providerHealth: {
|
|
1736
|
+
failureThreshold: 1,
|
|
1737
|
+
cooldownMs: 30_000,
|
|
1738
|
+
rateLimitCooldownMs: 120_000
|
|
1739
|
+
},
|
|
1740
|
+
providerProfiles: {
|
|
1741
|
+
openai: { cost: 6, latencyMs: 650, quality: 0.92, timeoutMs: 3500 },
|
|
1742
|
+
anthropic: { cost: 7, latencyMs: 850, quality: 0.95, timeoutMs: 4500 },
|
|
1743
|
+
gemini: { cost: 2, latencyMs: 700, quality: 0.86, timeoutMs: 3500 }
|
|
1744
|
+
},
|
|
1745
|
+
policy: resolveVoiceProviderRoutingPolicyPreset('balanced')
|
|
1746
|
+
});
|
|
1747
|
+
```
|
|
1748
|
+
|
|
1749
|
+
Built-in policy presets:
|
|
1750
|
+
|
|
1751
|
+
- `quality-first`: rank by `providerProfiles[provider].quality`, then priority, latency, and cost.
|
|
1752
|
+
- `latency-first`: rank by expected latency.
|
|
1753
|
+
- `cost-first`: rank by expected cost.
|
|
1754
|
+
- `cost-cap`: rank by cost and reject providers above `maxCost`.
|
|
1755
|
+
- `balanced`: weighted score using cost, latency, quality, and priority.
|
|
1756
|
+
|
|
1757
|
+
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.
|
|
1758
|
+
|
|
1759
|
+
```ts
|
|
1760
|
+
const policy = resolveVoiceProviderRoutingPolicyPreset('cost-cap', {
|
|
1761
|
+
maxCost: 3,
|
|
1762
|
+
minQuality: 0.82
|
|
1763
|
+
});
|
|
1764
|
+
```
|
|
1765
|
+
|
|
1766
|
+
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.
|
|
1767
|
+
|
|
1768
|
+
```ts
|
|
1769
|
+
import { runVoiceProviderRoutingContract } from '@absolutejs/voice';
|
|
1770
|
+
|
|
1771
|
+
const report = await runVoiceProviderRoutingContract({
|
|
1772
|
+
store: runtime.traces,
|
|
1773
|
+
contract: {
|
|
1774
|
+
id: 'openai-to-anthropic-fallback',
|
|
1775
|
+
expect: [
|
|
1776
|
+
{
|
|
1777
|
+
kind: 'llm',
|
|
1778
|
+
provider: 'openai',
|
|
1779
|
+
selectedProvider: 'openai',
|
|
1780
|
+
fallbackProvider: 'anthropic',
|
|
1781
|
+
status: 'error'
|
|
1782
|
+
},
|
|
1783
|
+
{
|
|
1784
|
+
kind: 'llm',
|
|
1785
|
+
provider: 'anthropic',
|
|
1786
|
+
selectedProvider: 'openai',
|
|
1787
|
+
status: 'fallback'
|
|
1788
|
+
}
|
|
1789
|
+
]
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
|
|
1793
|
+
if (!report.pass) {
|
|
1794
|
+
throw new Error(report.issues.map((issue) => issue.message).join('\n'));
|
|
1795
|
+
}
|
|
1796
|
+
```
|
|
1797
|
+
|
|
1798
|
+
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.
|
|
1799
|
+
|
|
1800
|
+
For full control, pass an object policy:
|
|
1801
|
+
|
|
1802
|
+
```ts
|
|
1803
|
+
const model = createVoiceProviderRouter({
|
|
1804
|
+
providers,
|
|
1805
|
+
providerProfiles,
|
|
1806
|
+
policy: {
|
|
1807
|
+
strategy: 'balanced',
|
|
1808
|
+
maxLatencyMs: 1000,
|
|
1809
|
+
weights: { cost: 1, latencyMs: 0.004, quality: 12 }
|
|
1810
|
+
}
|
|
1811
|
+
});
|
|
1812
|
+
```
|
|
1813
|
+
|
|
1814
|
+
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.
|
|
1815
|
+
|
|
1816
|
+
```ts
|
|
1817
|
+
const stt = createVoiceSTTProviderRouter({
|
|
1818
|
+
adapters: {
|
|
1819
|
+
deepgram,
|
|
1820
|
+
assemblyai
|
|
1821
|
+
},
|
|
1822
|
+
providerHealth: { cooldownMs: 30_000 },
|
|
1823
|
+
providerProfiles: {
|
|
1824
|
+
deepgram: { cost: 4, latencyMs: 180, quality: 0.93, timeoutMs: 1500 },
|
|
1825
|
+
assemblyai: { cost: 2, latencyMs: 650, quality: 0.88, timeoutMs: 3000 }
|
|
1826
|
+
},
|
|
1827
|
+
policy: resolveVoiceProviderRoutingPolicyPreset('latency-first')
|
|
1828
|
+
});
|
|
1829
|
+
|
|
1830
|
+
const tts = createVoiceTTSProviderRouter({
|
|
1831
|
+
adapters: {
|
|
1832
|
+
elevenlabs,
|
|
1833
|
+
openai
|
|
1834
|
+
},
|
|
1835
|
+
providerProfiles: {
|
|
1836
|
+
elevenlabs: { cost: 5, latencyMs: 220, quality: 0.94 },
|
|
1837
|
+
openai: { cost: 2, latencyMs: 320, quality: 0.87 }
|
|
1838
|
+
},
|
|
1839
|
+
policy: resolveVoiceProviderRoutingPolicyPreset('cost-cap', {
|
|
1840
|
+
maxCost: 3,
|
|
1841
|
+
minQuality: 0.85
|
|
1842
|
+
})
|
|
1843
|
+
});
|
|
1844
|
+
```
|
|
1845
|
+
|
|
1072
1846
|
## Presets
|
|
1073
1847
|
|
|
1074
1848
|
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 +2340,8 @@ Default reconnect strategy is `resume-last-turn`.
|
|
|
1566
2340
|
|
|
1567
2341
|
If an adapter does not emit native end-of-turn events, core falls back to silence detection with a default `700ms` threshold.
|
|
1568
2342
|
|
|
2343
|
+
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.
|
|
2344
|
+
|
|
1569
2345
|
## STT Fallback
|
|
1570
2346
|
|
|
1571
2347
|
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.
|