@absolutejs/voice 0.0.22-beta.1 → 0.0.22-beta.100

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 (137) hide show
  1. package/README.md +287 -0
  2. package/dist/agent.d.ts +2 -0
  3. package/dist/angular/index.d.ts +8 -0
  4. package/dist/angular/index.js +1112 -44
  5. package/dist/angular/voice-app-kit-status.service.d.ts +12 -0
  6. package/dist/angular/voice-ops-status.component.d.ts +15 -0
  7. package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
  8. package/dist/angular/voice-provider-status.service.d.ts +12 -0
  9. package/dist/angular/voice-routing-status.service.d.ts +11 -0
  10. package/dist/angular/voice-stream.service.d.ts +2 -0
  11. package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
  12. package/dist/angular/voice-turn-latency.service.d.ts +13 -0
  13. package/dist/angular/voice-turn-quality.service.d.ts +12 -0
  14. package/dist/angular/voice-workflow-status.service.d.ts +12 -0
  15. package/dist/appKit.d.ts +100 -0
  16. package/dist/assistant.d.ts +143 -0
  17. package/dist/assistantHealth.d.ts +81 -0
  18. package/dist/assistantMemory.d.ts +63 -0
  19. package/dist/bargeInRoutes.d.ts +56 -0
  20. package/dist/client/actions.d.ts +22 -0
  21. package/dist/client/appKitStatus.d.ts +19 -0
  22. package/dist/client/bargeInMonitor.d.ts +7 -0
  23. package/dist/client/connection.d.ts +3 -0
  24. package/dist/client/duplex.d.ts +1 -1
  25. package/dist/client/htmxBootstrap.js +587 -13
  26. package/dist/client/index.d.ts +38 -0
  27. package/dist/client/index.js +1890 -8
  28. package/dist/client/liveTurnLatency.d.ts +38 -0
  29. package/dist/client/opsStatusWidget.d.ts +40 -0
  30. package/dist/client/providerCapabilities.d.ts +19 -0
  31. package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
  32. package/dist/client/providerSimulationControls.d.ts +33 -0
  33. package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
  34. package/dist/client/providerStatus.d.ts +19 -0
  35. package/dist/client/providerStatusWidget.d.ts +32 -0
  36. package/dist/client/routingStatus.d.ts +19 -0
  37. package/dist/client/routingStatusWidget.d.ts +28 -0
  38. package/dist/client/traceTimeline.d.ts +19 -0
  39. package/dist/client/traceTimelineWidget.d.ts +32 -0
  40. package/dist/client/turnLatency.d.ts +22 -0
  41. package/dist/client/turnLatencyWidget.d.ts +33 -0
  42. package/dist/client/turnQuality.d.ts +19 -0
  43. package/dist/client/turnQualityWidget.d.ts +32 -0
  44. package/dist/client/workflowStatus.d.ts +19 -0
  45. package/dist/diagnosticsRoutes.d.ts +44 -0
  46. package/dist/evalRoutes.d.ts +213 -0
  47. package/dist/fileStore.d.ts +5 -2
  48. package/dist/handoff.d.ts +54 -0
  49. package/dist/handoffHealth.d.ts +94 -0
  50. package/dist/index.d.ts +71 -6
  51. package/dist/index.js +11044 -1800
  52. package/dist/modelAdapters.d.ts +114 -0
  53. package/dist/openaiTTS.d.ts +18 -0
  54. package/dist/opsConsoleRoutes.d.ts +77 -0
  55. package/dist/opsWebhook.d.ts +126 -0
  56. package/dist/outcomeContract.d.ts +112 -0
  57. package/dist/postgresStore.d.ts +2 -0
  58. package/dist/productionReadiness.d.ts +111 -0
  59. package/dist/providerAdapters.d.ts +48 -0
  60. package/dist/providerCapabilities.d.ts +92 -0
  61. package/dist/providerHealth.d.ts +79 -0
  62. package/dist/qualityRoutes.d.ts +76 -0
  63. package/dist/queue.d.ts +61 -0
  64. package/dist/react/VoiceOpsStatus.d.ts +6 -0
  65. package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
  66. package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
  67. package/dist/react/VoiceProviderStatus.d.ts +6 -0
  68. package/dist/react/VoiceRoutingStatus.d.ts +6 -0
  69. package/dist/react/VoiceTraceTimeline.d.ts +6 -0
  70. package/dist/react/VoiceTurnLatency.d.ts +6 -0
  71. package/dist/react/VoiceTurnQuality.d.ts +6 -0
  72. package/dist/react/index.d.ts +17 -0
  73. package/dist/react/index.js +2467 -12
  74. package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
  75. package/dist/react/useVoiceController.d.ts +2 -0
  76. package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
  77. package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
  78. package/dist/react/useVoiceProviderStatus.d.ts +8 -0
  79. package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
  80. package/dist/react/useVoiceStream.d.ts +2 -0
  81. package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
  82. package/dist/react/useVoiceTurnLatency.d.ts +9 -0
  83. package/dist/react/useVoiceTurnQuality.d.ts +8 -0
  84. package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
  85. package/dist/resilienceRoutes.d.ts +142 -0
  86. package/dist/sessionReplay.d.ts +175 -0
  87. package/dist/sqliteStore.d.ts +2 -0
  88. package/dist/svelte/createVoiceAppKitStatus.d.ts +8 -0
  89. package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
  90. package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
  91. package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
  92. package/dist/svelte/createVoiceProviderStatus.d.ts +10 -0
  93. package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
  94. package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
  95. package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
  96. package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
  97. package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
  98. package/dist/svelte/index.d.ts +10 -0
  99. package/dist/svelte/index.js +1728 -4
  100. package/dist/telephony/contract.d.ts +61 -0
  101. package/dist/telephony/matrix.d.ts +97 -0
  102. package/dist/telephony/plivo.d.ts +254 -0
  103. package/dist/telephony/telnyx.d.ts +247 -0
  104. package/dist/telephony/twilio.d.ts +132 -0
  105. package/dist/telephonyOutcome.d.ts +201 -0
  106. package/dist/testing/index.d.ts +2 -0
  107. package/dist/testing/index.js +2637 -21
  108. package/dist/testing/ioProviderSimulator.d.ts +41 -0
  109. package/dist/testing/providerSimulator.d.ts +44 -0
  110. package/dist/toolContract.d.ts +130 -0
  111. package/dist/toolRuntime.d.ts +50 -0
  112. package/dist/trace.d.ts +1 -1
  113. package/dist/traceTimeline.d.ts +93 -0
  114. package/dist/turnLatency.d.ts +95 -0
  115. package/dist/turnQuality.d.ts +94 -0
  116. package/dist/types.d.ts +125 -2
  117. package/dist/vue/VoiceOpsStatus.d.ts +30 -0
  118. package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
  119. package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
  120. package/dist/vue/VoiceProviderStatus.d.ts +51 -0
  121. package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
  122. package/dist/vue/VoiceTurnLatency.d.ts +69 -0
  123. package/dist/vue/VoiceTurnQuality.d.ts +51 -0
  124. package/dist/vue/index.d.ts +16 -0
  125. package/dist/vue/index.js +2360 -26
  126. package/dist/vue/useVoiceAppKitStatus.d.ts +9 -0
  127. package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
  128. package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
  129. package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
  130. package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
  131. package/dist/vue/useVoiceStream.d.ts +2 -0
  132. package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
  133. package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
  134. package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
  135. package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
  136. package/dist/workflowContract.d.ts +91 -0
  137. package/package.json +1 -1
package/README.md CHANGED
@@ -73,6 +73,197 @@ const app = new Elysia()
73
73
 
74
74
  `createVoiceMemoryStore()` is dev-only. Real deployments should provide a shared store backed by Redis, Postgres, or equivalent.
75
75
 
76
+ ## App Kit And Status Widgets
77
+
78
+ Use `createVoiceAppKitRoutes(...)` when you want a self-hosted operations surface without hand-wiring every dashboard route. It adds the ops console, quality gates, eval routes, provider health, session replay, handoff health, diagnostics, and `GET /app-kit/status`.
79
+
80
+ ```ts
81
+ import { createVoiceAppKitRoutes, createVoiceFileRuntimeStorage } from '@absolutejs/voice';
82
+
83
+ const runtime = createVoiceFileRuntimeStorage({ directory: '.voice-runtime/support' });
84
+
85
+ app.use(
86
+ createVoiceAppKitRoutes({
87
+ store: runtime.traces,
88
+ llmProviders: ['openai', 'anthropic', 'gemini'],
89
+ sttProviders: ['deepgram', 'assemblyai']
90
+ }).routes
91
+ );
92
+ ```
93
+
94
+ 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 ops pages.
95
+
96
+ ```ts
97
+ app.use(
98
+ createVoiceAppKitRoutes({
99
+ appStatus: {
100
+ include: { quality: false, sessions: false },
101
+ preferFixtureWorkflows: true
102
+ },
103
+ evals: { fixtures: certificationFixtures, scenarios: workflowScenarios },
104
+ store: runtime.traces
105
+ }).routes
106
+ );
107
+ ```
108
+
109
+ ### React Status Widget
110
+
111
+ ```tsx
112
+ import { VoiceOpsStatus } from '@absolutejs/voice/react';
113
+
114
+ export function OpsBadge() {
115
+ return <VoiceOpsStatus intervalMs={5000} />;
116
+ }
117
+ ```
118
+
119
+ ### Vue Status Widget
120
+
121
+ ```vue
122
+ <script setup lang="ts">
123
+ import { VoiceOpsStatus } from '@absolutejs/voice/vue';
124
+ </script>
125
+
126
+ <template>
127
+ <VoiceOpsStatus :interval-ms="5000" />
128
+ </template>
129
+ ```
130
+
131
+ ### Svelte Status Widget
132
+
133
+ ```svelte
134
+ <script lang="ts">
135
+ import { onDestroy, onMount } from 'svelte';
136
+ import { createVoiceOpsStatus } from '@absolutejs/voice/svelte';
137
+
138
+ const status = createVoiceOpsStatus('/app-kit/status', { intervalMs: 5000 });
139
+ let html = '';
140
+ onMount(() => status.subscribe(() => (html = status.getHTML())));
141
+ onDestroy(() => status.close());
142
+ </script>
143
+
144
+ {@html html}
145
+ ```
146
+
147
+ ### Angular Status Widget
148
+
149
+ ```ts
150
+ import { VoiceAppKitStatusService } from '@absolutejs/voice/angular';
151
+
152
+ status = inject(VoiceAppKitStatusService).connect('/app-kit/status', {
153
+ intervalMs: 5000
154
+ });
155
+ ```
156
+
157
+ ```html
158
+ <h2>{{ status.report()?.status === 'pass' ? 'Passing' : 'Needs attention' }}</h2>
159
+ <p>{{ status.report()?.passed ?? 0 }} passing checks</p>
160
+ ```
161
+
162
+ ### HTML Or HTMX Status Widget
163
+
164
+ ```html
165
+ <div id="voice-ops-status"></div>
166
+ <script type="module">
167
+ import { mountVoiceOpsStatus } from '@absolutejs/voice/client';
168
+
169
+ mountVoiceOpsStatus(document.querySelector('#voice-ops-status'), '/app-kit/status', {
170
+ intervalMs: 5000
171
+ });
172
+ </script>
173
+ ```
174
+
175
+ For custom elements:
176
+
177
+ ```html
178
+ <absolute-voice-ops-status interval-ms="5000"></absolute-voice-ops-status>
179
+ <script type="module">
180
+ import { defineVoiceOpsStatusElement } from '@absolutejs/voice/client';
181
+ defineVoiceOpsStatusElement();
182
+ </script>
183
+ ```
184
+
185
+ ## Voice Assistants
186
+
187
+ 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(...)`.
188
+
189
+ ```ts
190
+ import {
191
+ createVoiceAssistant,
192
+ createVoiceExperiment,
193
+ createVoiceFileRuntimeStorage,
194
+ createVoiceMemoryStore,
195
+ createVoiceAgentTool,
196
+ voice
197
+ } from '@absolutejs/voice';
198
+ import { deepgram } from '@absolutejs/voice-deepgram';
199
+
200
+ const runtimeStorage = createVoiceFileRuntimeStorage({
201
+ directory: '.voice-runtime/support'
202
+ });
203
+
204
+ const lookupOrder = createVoiceAgentTool({
205
+ name: 'lookup_order',
206
+ description: 'Look up an order by id.',
207
+ execute: async ({ args }) => ({ orderId: args.orderId, status: 'shipped' })
208
+ });
209
+
210
+ const assistant = createVoiceAssistant({
211
+ id: 'support',
212
+ artifactPlan: {
213
+ ops: {
214
+ events: runtimeStorage.events,
215
+ reviews: runtimeStorage.reviews,
216
+ tasks: runtimeStorage.tasks
217
+ },
218
+ preset: {
219
+ name: 'support-triage',
220
+ options: {
221
+ queue: 'support-triage'
222
+ }
223
+ }
224
+ },
225
+ experiment: createVoiceExperiment({
226
+ id: 'support-prompt',
227
+ variants: [
228
+ { id: 'baseline', weight: 1 },
229
+ {
230
+ id: 'direct',
231
+ weight: 1,
232
+ system: 'You are concise, practical, and resolve the caller quickly.'
233
+ }
234
+ ]
235
+ }),
236
+ guardrails: {
237
+ beforeTurn: ({ turn }) =>
238
+ turn.text.toLowerCase().includes('human')
239
+ ? { escalate: { reason: 'caller requested a human' } }
240
+ : undefined
241
+ },
242
+ model: {
243
+ async generate({ messages, tools }) {
244
+ return {
245
+ assistantText: `I can help. Available tools: ${tools.map((tool) => tool.name).join(', ')}`
246
+ };
247
+ }
248
+ },
249
+ system: 'You are a support voice assistant.',
250
+ tools: [lookupOrder],
251
+ trace: runtimeStorage.traces
252
+ });
253
+
254
+ voice({
255
+ path: '/voice',
256
+ session: createVoiceMemoryStore(),
257
+ stt: deepgram({ apiKey: process.env.DEEPGRAM_API_KEY! }),
258
+ trace: runtimeStorage.traces,
259
+ ops: assistant.ops,
260
+ onTurn: assistant.onTurn,
261
+ onComplete: async () => {}
262
+ });
263
+ ```
264
+
265
+ Assistant experiments are deterministic by session id, so a caller stays on the same variant for a call. Variants can change the model, system prompt, tools, and tool-round budget; guardrails can block a turn before model execution or rewrite the returned `VoiceRouteResult`.
266
+
76
267
  ## Agent Tools And Squads
77
268
 
78
269
  For assistant-style products, use `createVoiceAgent(...)` as the `onTurn` handler. The agent layer is provider-neutral: plug in any model adapter, register server-side tools, and return normal voice route results like `assistantText`, `transfer`, `escalate`, or `complete`.
@@ -987,6 +1178,102 @@ app.use(
987
1178
  - `benchmark-results/sessions-cheap-stt-runs-3.json`
988
1179
  - `benchmark-results/stt-routing-run-manifest.json`
989
1180
 
1181
+ ## LLM Provider Routing
1182
+
1183
+ 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.
1184
+
1185
+ ```ts
1186
+ import {
1187
+ createAnthropicVoiceAssistantModel,
1188
+ createGeminiVoiceAssistantModel,
1189
+ createOpenAIVoiceAssistantModel,
1190
+ createVoiceProviderRouter,
1191
+ resolveVoiceProviderRoutingPolicyPreset
1192
+ } from '@absolutejs/voice';
1193
+
1194
+ const model = createVoiceProviderRouter({
1195
+ providers: {
1196
+ openai: createOpenAIVoiceAssistantModel({ apiKey: process.env.OPENAI_API_KEY! }),
1197
+ anthropic: createAnthropicVoiceAssistantModel({ apiKey: process.env.ANTHROPIC_API_KEY! }),
1198
+ gemini: createGeminiVoiceAssistantModel({ apiKey: process.env.GEMINI_API_KEY! })
1199
+ },
1200
+ providerHealth: {
1201
+ failureThreshold: 1,
1202
+ cooldownMs: 30_000,
1203
+ rateLimitCooldownMs: 120_000
1204
+ },
1205
+ providerProfiles: {
1206
+ openai: { cost: 6, latencyMs: 650, quality: 0.92, timeoutMs: 3500 },
1207
+ anthropic: { cost: 7, latencyMs: 850, quality: 0.95, timeoutMs: 4500 },
1208
+ gemini: { cost: 2, latencyMs: 700, quality: 0.86, timeoutMs: 3500 }
1209
+ },
1210
+ policy: resolveVoiceProviderRoutingPolicyPreset('balanced')
1211
+ });
1212
+ ```
1213
+
1214
+ Built-in policy presets:
1215
+
1216
+ - `quality-first`: rank by `providerProfiles[provider].quality`, then priority, latency, and cost.
1217
+ - `latency-first`: rank by expected latency.
1218
+ - `cost-first`: rank by expected cost.
1219
+ - `cost-cap`: rank by cost and reject providers above `maxCost`.
1220
+ - `balanced`: weighted score using cost, latency, quality, and priority.
1221
+
1222
+ 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.
1223
+
1224
+ ```ts
1225
+ const policy = resolveVoiceProviderRoutingPolicyPreset('cost-cap', {
1226
+ maxCost: 3,
1227
+ minQuality: 0.82
1228
+ });
1229
+ ```
1230
+
1231
+ For full control, pass an object policy:
1232
+
1233
+ ```ts
1234
+ const model = createVoiceProviderRouter({
1235
+ providers,
1236
+ providerProfiles,
1237
+ policy: {
1238
+ strategy: 'balanced',
1239
+ maxLatencyMs: 1000,
1240
+ weights: { cost: 1, latencyMs: 0.004, quality: 12 }
1241
+ }
1242
+ });
1243
+ ```
1244
+
1245
+ 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.
1246
+
1247
+ ```ts
1248
+ const stt = createVoiceSTTProviderRouter({
1249
+ adapters: {
1250
+ deepgram,
1251
+ assemblyai
1252
+ },
1253
+ providerHealth: { cooldownMs: 30_000 },
1254
+ providerProfiles: {
1255
+ deepgram: { cost: 4, latencyMs: 180, quality: 0.93, timeoutMs: 1500 },
1256
+ assemblyai: { cost: 2, latencyMs: 650, quality: 0.88, timeoutMs: 3000 }
1257
+ },
1258
+ policy: resolveVoiceProviderRoutingPolicyPreset('latency-first')
1259
+ });
1260
+
1261
+ const tts = createVoiceTTSProviderRouter({
1262
+ adapters: {
1263
+ elevenlabs,
1264
+ openai
1265
+ },
1266
+ providerProfiles: {
1267
+ elevenlabs: { cost: 5, latencyMs: 220, quality: 0.94 },
1268
+ openai: { cost: 2, latencyMs: 320, quality: 0.87 }
1269
+ },
1270
+ policy: resolveVoiceProviderRoutingPolicyPreset('cost-cap', {
1271
+ maxCost: 3,
1272
+ minQuality: 0.85
1273
+ })
1274
+ });
1275
+ ```
1276
+
990
1277
  ## Presets
991
1278
 
992
1279
  Voice now ships named runtime presets so apps can start from a useful baseline instead of hand-tuning silence and capture settings every time.
package/dist/agent.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { VoiceOnTurnObjectHandler, VoiceRouteResult, VoiceSessionHandle, VoiceSessionRecord, VoiceTurnRecord } from './types';
2
2
  import type { VoiceTraceEventStore } from './trace';
3
+ import type { VoiceToolRuntime } from './toolRuntime';
3
4
  export type VoiceAgentMessageRole = 'assistant' | 'system' | 'tool' | 'user';
4
5
  export type VoiceAgentMessage = {
5
6
  content: string;
@@ -86,6 +87,7 @@ export type VoiceAgentOptions<TContext = unknown, TSession extends VoiceSessionR
86
87
  turn: VoiceTurnRecord;
87
88
  }) => Promise<string | undefined> | string | undefined);
88
89
  trace?: VoiceTraceEventStore;
90
+ toolRuntime?: VoiceToolRuntime<TContext, TSession, TResult>;
89
91
  tools?: Array<VoiceAgentTool<TContext, TSession, Record<string, unknown>, unknown, TResult>>;
90
92
  };
91
93
  export type VoiceAgentSquadOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
@@ -1,2 +1,10 @@
1
+ export { VoiceAppKitStatusService } from './voice-app-kit-status.service';
1
2
  export { VoiceStreamService } from './voice-stream.service';
2
3
  export { VoiceControllerService } from './voice-controller.service';
4
+ export { VoiceProviderCapabilitiesService } from './voice-provider-capabilities.service';
5
+ export { VoiceProviderStatusService } from './voice-provider-status.service';
6
+ export { VoiceRoutingStatusService } from './voice-routing-status.service';
7
+ export { VoiceTraceTimelineService } from './voice-trace-timeline.service';
8
+ export { VoiceTurnLatencyService } from './voice-turn-latency.service';
9
+ export { VoiceTurnQualityService } from './voice-turn-quality.service';
10
+ export { VoiceWorkflowStatusService } from './voice-workflow-status.service';