@absolutejs/voice 0.0.22-beta.12 → 0.0.22-beta.121

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 (146) hide show
  1. package/README.md +411 -3
  2. package/dist/agent.d.ts +2 -0
  3. package/dist/angular/index.d.ts +9 -0
  4. package/dist/angular/index.js +1278 -44
  5. package/dist/angular/voice-app-kit-status.service.d.ts +12 -0
  6. package/dist/angular/voice-campaign-dialer-proof.service.d.ts +14 -0
  7. package/dist/angular/voice-ops-status.component.d.ts +15 -0
  8. package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
  9. package/dist/angular/voice-provider-status.service.d.ts +12 -0
  10. package/dist/angular/voice-routing-status.service.d.ts +11 -0
  11. package/dist/angular/voice-stream.service.d.ts +2 -0
  12. package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
  13. package/dist/angular/voice-turn-latency.service.d.ts +13 -0
  14. package/dist/angular/voice-turn-quality.service.d.ts +12 -0
  15. package/dist/angular/voice-workflow-status.service.d.ts +12 -0
  16. package/dist/appKit.d.ts +100 -0
  17. package/dist/assistantHealth.d.ts +81 -0
  18. package/dist/bargeInRoutes.d.ts +56 -0
  19. package/dist/campaign.d.ts +610 -0
  20. package/dist/campaignDialers.d.ts +90 -0
  21. package/dist/client/actions.d.ts +22 -0
  22. package/dist/client/appKitStatus.d.ts +19 -0
  23. package/dist/client/bargeInMonitor.d.ts +7 -0
  24. package/dist/client/campaignDialerProof.d.ts +23 -0
  25. package/dist/client/connection.d.ts +3 -0
  26. package/dist/client/duplex.d.ts +1 -1
  27. package/dist/client/htmxBootstrap.js +587 -13
  28. package/dist/client/index.d.ts +40 -0
  29. package/dist/client/index.js +2028 -8
  30. package/dist/client/liveTurnLatency.d.ts +41 -0
  31. package/dist/client/opsStatusWidget.d.ts +40 -0
  32. package/dist/client/providerCapabilities.d.ts +19 -0
  33. package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
  34. package/dist/client/providerSimulationControls.d.ts +33 -0
  35. package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
  36. package/dist/client/providerStatus.d.ts +19 -0
  37. package/dist/client/providerStatusWidget.d.ts +32 -0
  38. package/dist/client/routingStatus.d.ts +19 -0
  39. package/dist/client/routingStatusWidget.d.ts +28 -0
  40. package/dist/client/traceTimeline.d.ts +19 -0
  41. package/dist/client/traceTimelineWidget.d.ts +32 -0
  42. package/dist/client/turnLatency.d.ts +22 -0
  43. package/dist/client/turnLatencyWidget.d.ts +33 -0
  44. package/dist/client/turnQuality.d.ts +19 -0
  45. package/dist/client/turnQualityWidget.d.ts +32 -0
  46. package/dist/client/workflowStatus.d.ts +19 -0
  47. package/dist/diagnosticsRoutes.d.ts +44 -0
  48. package/dist/evalRoutes.d.ts +213 -0
  49. package/dist/fileStore.d.ts +3 -0
  50. package/dist/handoff.d.ts +54 -0
  51. package/dist/handoffHealth.d.ts +94 -0
  52. package/dist/index.d.ts +77 -8
  53. package/dist/index.js +12658 -3061
  54. package/dist/liveLatency.d.ts +78 -0
  55. package/dist/modelAdapters.d.ts +41 -2
  56. package/dist/openaiTTS.d.ts +18 -0
  57. package/dist/opsConsoleRoutes.d.ts +77 -0
  58. package/dist/opsWebhook.d.ts +126 -0
  59. package/dist/outcomeContract.d.ts +112 -0
  60. package/dist/phoneAgent.d.ts +58 -0
  61. package/dist/postgresStore.d.ts +5 -0
  62. package/dist/productionReadiness.d.ts +121 -0
  63. package/dist/providerAdapters.d.ts +48 -0
  64. package/dist/providerCapabilities.d.ts +92 -0
  65. package/dist/providerHealth.d.ts +79 -0
  66. package/dist/qualityRoutes.d.ts +76 -0
  67. package/dist/queue.d.ts +61 -0
  68. package/dist/react/VoiceOpsStatus.d.ts +6 -0
  69. package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
  70. package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
  71. package/dist/react/VoiceProviderStatus.d.ts +6 -0
  72. package/dist/react/VoiceRoutingStatus.d.ts +6 -0
  73. package/dist/react/VoiceTraceTimeline.d.ts +6 -0
  74. package/dist/react/VoiceTurnLatency.d.ts +6 -0
  75. package/dist/react/VoiceTurnQuality.d.ts +6 -0
  76. package/dist/react/index.d.ts +18 -0
  77. package/dist/react/index.js +2606 -12
  78. package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
  79. package/dist/react/useVoiceCampaignDialerProof.d.ts +10 -0
  80. package/dist/react/useVoiceController.d.ts +2 -0
  81. package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
  82. package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
  83. package/dist/react/useVoiceProviderStatus.d.ts +8 -0
  84. package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
  85. package/dist/react/useVoiceStream.d.ts +2 -0
  86. package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
  87. package/dist/react/useVoiceTurnLatency.d.ts +9 -0
  88. package/dist/react/useVoiceTurnQuality.d.ts +8 -0
  89. package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
  90. package/dist/resilienceRoutes.d.ts +142 -0
  91. package/dist/sessionReplay.d.ts +175 -0
  92. package/dist/simulationSuite.d.ts +120 -0
  93. package/dist/sqliteStore.d.ts +5 -0
  94. package/dist/svelte/createVoiceAppKitStatus.d.ts +8 -0
  95. package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
  96. package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
  97. package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
  98. package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
  99. package/dist/svelte/createVoiceProviderStatus.d.ts +10 -0
  100. package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
  101. package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
  102. package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
  103. package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
  104. package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
  105. package/dist/svelte/index.d.ts +11 -0
  106. package/dist/svelte/index.js +1849 -4
  107. package/dist/telephony/contract.d.ts +61 -0
  108. package/dist/telephony/matrix.d.ts +97 -0
  109. package/dist/telephony/plivo.d.ts +254 -0
  110. package/dist/telephony/telnyx.d.ts +247 -0
  111. package/dist/telephony/twilio.d.ts +132 -0
  112. package/dist/telephonyOutcome.d.ts +201 -0
  113. package/dist/testing/index.d.ts +2 -0
  114. package/dist/testing/index.js +2640 -21
  115. package/dist/testing/ioProviderSimulator.d.ts +41 -0
  116. package/dist/testing/providerSimulator.d.ts +44 -0
  117. package/dist/toolContract.d.ts +130 -0
  118. package/dist/toolRuntime.d.ts +50 -0
  119. package/dist/trace.d.ts +1 -1
  120. package/dist/traceTimeline.d.ts +93 -0
  121. package/dist/turnLatency.d.ts +95 -0
  122. package/dist/turnQuality.d.ts +94 -0
  123. package/dist/types.d.ts +125 -2
  124. package/dist/vue/VoiceOpsStatus.d.ts +30 -0
  125. package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
  126. package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
  127. package/dist/vue/VoiceProviderStatus.d.ts +51 -0
  128. package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
  129. package/dist/vue/VoiceTurnLatency.d.ts +69 -0
  130. package/dist/vue/VoiceTurnQuality.d.ts +51 -0
  131. package/dist/vue/index.d.ts +17 -0
  132. package/dist/vue/index.js +2520 -29
  133. package/dist/vue/useVoiceAppKitStatus.d.ts +9 -0
  134. package/dist/vue/useVoiceCampaignDialerProof.d.ts +11 -0
  135. package/dist/vue/useVoiceController.d.ts +1 -1
  136. package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
  137. package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
  138. package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
  139. package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
  140. package/dist/vue/useVoiceStream.d.ts +3 -1
  141. package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
  142. package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
  143. package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
  144. package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
  145. package/dist/workflowContract.d.ts +91 -0
  146. package/package.json +1 -1
package/dist/vue/index.js CHANGED
@@ -69,8 +69,2205 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => {
69
69
  return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
70
70
  };
71
71
 
72
+ // src/vue/VoiceOpsStatus.ts
73
+ import { defineComponent, h } from "vue";
74
+
75
+ // src/client/appKitStatus.ts
76
+ var fetchVoiceAppKitStatus = async (path = "/app-kit/status", options = {}) => {
77
+ const fetchImpl = options.fetch ?? globalThis.fetch;
78
+ const response = await fetchImpl(path);
79
+ if (!response.ok) {
80
+ throw new Error(`Voice app kit status failed: HTTP ${response.status}`);
81
+ }
82
+ return await response.json();
83
+ };
84
+ var createVoiceAppKitStatusStore = (path = "/app-kit/status", options = {}) => {
85
+ const listeners = new Set;
86
+ let closed = false;
87
+ let timer;
88
+ let snapshot = {
89
+ error: null,
90
+ isLoading: false
91
+ };
92
+ const emit = () => {
93
+ for (const listener of listeners) {
94
+ listener();
95
+ }
96
+ };
97
+ const refresh = async () => {
98
+ if (closed) {
99
+ return snapshot.report;
100
+ }
101
+ snapshot = {
102
+ ...snapshot,
103
+ error: null,
104
+ isLoading: true
105
+ };
106
+ emit();
107
+ try {
108
+ const report = await fetchVoiceAppKitStatus(path, options);
109
+ snapshot = {
110
+ error: null,
111
+ isLoading: false,
112
+ report,
113
+ updatedAt: Date.now()
114
+ };
115
+ emit();
116
+ return report;
117
+ } catch (error) {
118
+ snapshot = {
119
+ ...snapshot,
120
+ error: error instanceof Error ? error.message : String(error),
121
+ isLoading: false
122
+ };
123
+ emit();
124
+ throw error;
125
+ }
126
+ };
127
+ const close = () => {
128
+ closed = true;
129
+ if (timer) {
130
+ clearInterval(timer);
131
+ timer = undefined;
132
+ }
133
+ listeners.clear();
134
+ };
135
+ if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
136
+ timer = setInterval(() => {
137
+ refresh().catch(() => {});
138
+ }, options.intervalMs);
139
+ }
140
+ return {
141
+ close,
142
+ getServerSnapshot: () => snapshot,
143
+ getSnapshot: () => snapshot,
144
+ refresh,
145
+ subscribe: (listener) => {
146
+ listeners.add(listener);
147
+ return () => {
148
+ listeners.delete(listener);
149
+ };
150
+ }
151
+ };
152
+ };
153
+
154
+ // src/client/opsStatusWidget.ts
155
+ var DEFAULT_TITLE = "Voice Ops Status";
156
+ var DEFAULT_DESCRIPTION = "Certified workflow, provider, and handoff readiness from the AbsoluteJS voice app kit.";
157
+ var SURFACE_LABELS = {
158
+ handoffs: "Handoffs",
159
+ providers: "Providers",
160
+ quality: "Quality",
161
+ sessions: "Sessions",
162
+ workflows: "Workflows"
163
+ };
164
+ var escapeHtml = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
165
+ var readNumber = (value, key) => value && typeof value === "object" && (key in value) ? Number(value[key] ?? 0) : 0;
166
+ var surfaceDetail = (surface) => {
167
+ const total = readNumber(surface, "total");
168
+ const failed = readNumber(surface, "failed");
169
+ const degraded = readNumber(surface, "degraded");
170
+ const source = surface && typeof surface === "object" && "source" in surface && typeof surface.source === "string" ? ` from ${surface.source}` : "";
171
+ if (degraded > 0) {
172
+ return `${degraded} degraded of ${total}`;
173
+ }
174
+ if (failed > 0) {
175
+ return `${failed} failing of ${total}${source}`;
176
+ }
177
+ return total > 0 ? `${total} passing${source}` : `No failures${source}`;
178
+ };
179
+ var getVoiceOpsStatusLabel = (report, error) => {
180
+ if (error) {
181
+ return "Unavailable";
182
+ }
183
+ if (!report) {
184
+ return "Checking";
185
+ }
186
+ return report.status === "pass" ? "Passing" : "Needs attention";
187
+ };
188
+ var createVoiceOpsStatusViewModel = (snapshot, options = {}) => {
189
+ const report = snapshot.report;
190
+ const surfaces = Object.entries(report?.surfaces ?? {}).map(([id, surface]) => {
191
+ const failed = readNumber(surface, "failed") || readNumber(surface, "degraded");
192
+ const total = readNumber(surface, "total");
193
+ const status = surface && typeof surface === "object" && "status" in surface ? surface.status ?? "pass" : "pass";
194
+ return {
195
+ detail: surfaceDetail(surface),
196
+ failed,
197
+ id,
198
+ label: SURFACE_LABELS[id] ?? id,
199
+ status,
200
+ total
201
+ };
202
+ });
203
+ return {
204
+ description: options.description ?? DEFAULT_DESCRIPTION,
205
+ error: snapshot.error,
206
+ isLoading: snapshot.isLoading,
207
+ label: getVoiceOpsStatusLabel(report, snapshot.error),
208
+ links: options.includeLinks === false ? [] : report?.links ?? [],
209
+ passed: report?.passed ?? 0,
210
+ status: snapshot.error ? "error" : report ? report.status : snapshot.isLoading ? "loading" : "loading",
211
+ surfaces,
212
+ title: options.title ?? DEFAULT_TITLE,
213
+ total: report?.total ?? 0,
214
+ updatedAt: snapshot.updatedAt
215
+ };
216
+ };
217
+ var renderVoiceOpsStatusHTML = (snapshot, options = {}) => {
218
+ const model = createVoiceOpsStatusViewModel(snapshot, options);
219
+ const surfaces = model.surfaces.length ? model.surfaces.map((surface) => `<li class="absolute-voice-ops-status__surface absolute-voice-ops-status__surface--${escapeHtml(surface.status)}">
220
+ <span>${escapeHtml(surface.label)}</span>
221
+ <strong>${escapeHtml(surface.detail)}</strong>
222
+ </li>`).join("") : '<li class="absolute-voice-ops-status__surface"><span>Status</span><strong>Waiting for first check</strong></li>';
223
+ const links = model.links.length ? `<nav class="absolute-voice-ops-status__links">${model.links.slice(0, 4).map((link) => `<a href="${escapeHtml(link.href)}">${escapeHtml(link.label)}</a>`).join("")}</nav>` : "";
224
+ return `<section class="absolute-voice-ops-status absolute-voice-ops-status--${escapeHtml(model.status)}">
225
+ <header class="absolute-voice-ops-status__header">
226
+ <span class="absolute-voice-ops-status__eyebrow">${escapeHtml(model.title)}</span>
227
+ <strong class="absolute-voice-ops-status__label">${escapeHtml(model.label)}</strong>
228
+ </header>
229
+ <p class="absolute-voice-ops-status__description">${escapeHtml(model.description)}</p>
230
+ <div class="absolute-voice-ops-status__summary">
231
+ <span>${model.passed} passing</span>
232
+ <span>${Math.max(model.total - model.passed, 0)} failing</span>
233
+ <span>${model.total} checks</span>
234
+ </div>
235
+ <ul class="absolute-voice-ops-status__surfaces">${surfaces}</ul>
236
+ ${model.error ? `<p class="absolute-voice-ops-status__error">${escapeHtml(model.error)}</p>` : ""}
237
+ ${links}
238
+ </section>`;
239
+ };
240
+ var getVoiceOpsStatusCSS = () => `.absolute-voice-ops-status{border:1px solid #d8d2c4;border-radius:20px;background:#fffaf0;color:#16130d;padding:18px;box-shadow:0 18px 40px rgba(47,37,18,.12);font-family:inherit}.absolute-voice-ops-status--fail,.absolute-voice-ops-status--error{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-ops-status__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-ops-status__eyebrow{color:#73664f;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-ops-status__label{font-size:28px;line-height:1}.absolute-voice-ops-status__description{color:#514733;margin:12px 0 0}.absolute-voice-ops-status__summary,.absolute-voice-ops-status__links{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.absolute-voice-ops-status__summary span,.absolute-voice-ops-status__links a{border:1px solid #e6ddca;border-radius:999px;color:inherit;padding:6px 10px;text-decoration:none}.absolute-voice-ops-status__surfaces{display:grid;gap:8px;list-style:none;margin:16px 0 0;padding:0}.absolute-voice-ops-status__surface{align-items:center;background:#fff;border:1px solid #eee4d2;border-radius:14px;display:flex;gap:12px;justify-content:space-between;padding:10px 12px}.absolute-voice-ops-status__surface--fail{border-color:#f2a7a7}.absolute-voice-ops-status__surface span{color:#655944}.absolute-voice-ops-status__error{color:#9f1239;font-weight:700}`;
241
+ var mountVoiceOpsStatus = (element, path = "/app-kit/status", options = {}) => {
242
+ const store = createVoiceAppKitStatusStore(path, options);
243
+ const render = () => {
244
+ element.innerHTML = renderVoiceOpsStatusHTML(store.getSnapshot(), options);
245
+ };
246
+ const unsubscribe = store.subscribe(render);
247
+ render();
248
+ store.refresh().catch(() => {});
249
+ return {
250
+ close: () => {
251
+ unsubscribe();
252
+ store.close();
253
+ },
254
+ refresh: store.refresh
255
+ };
256
+ };
257
+ var defineVoiceOpsStatusElement = (tagName = "absolute-voice-ops-status") => {
258
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
259
+ return;
260
+ }
261
+ customElements.define(tagName, class AbsoluteVoiceOpsStatusElement extends HTMLElement {
262
+ mounted;
263
+ connectedCallback() {
264
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
265
+ this.mounted = mountVoiceOpsStatus(this, this.getAttribute("path") ?? "/app-kit/status", {
266
+ description: this.getAttribute("description") ?? undefined,
267
+ includeLinks: this.getAttribute("include-links") !== "false",
268
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
269
+ title: this.getAttribute("title") ?? undefined
270
+ });
271
+ }
272
+ disconnectedCallback() {
273
+ this.mounted?.close();
274
+ this.mounted = undefined;
275
+ }
276
+ });
277
+ };
278
+
279
+ // src/vue/useVoiceAppKitStatus.ts
280
+ import { onUnmounted, ref, shallowRef } from "vue";
281
+ function useVoiceAppKitStatus(path = "/app-kit/status", options = {}) {
282
+ const store = createVoiceAppKitStatusStore(path, options);
283
+ const error = ref(null);
284
+ const isLoading = ref(false);
285
+ const report = shallowRef(undefined);
286
+ const updatedAt = ref(undefined);
287
+ const sync = () => {
288
+ const snapshot = store.getSnapshot();
289
+ error.value = snapshot.error;
290
+ isLoading.value = snapshot.isLoading;
291
+ report.value = snapshot.report;
292
+ updatedAt.value = snapshot.updatedAt;
293
+ };
294
+ const unsubscribe = store.subscribe(sync);
295
+ sync();
296
+ if (typeof window !== "undefined") {
297
+ store.refresh().catch(() => {});
298
+ }
299
+ onUnmounted(() => {
300
+ unsubscribe();
301
+ store.close();
302
+ });
303
+ return {
304
+ error,
305
+ isLoading,
306
+ refresh: store.refresh,
307
+ report,
308
+ updatedAt
309
+ };
310
+ }
311
+
312
+ // src/vue/VoiceOpsStatus.ts
313
+ var VoiceOpsStatus = defineComponent({
314
+ name: "VoiceOpsStatus",
315
+ props: {
316
+ description: String,
317
+ includeLinks: {
318
+ default: true,
319
+ type: Boolean
320
+ },
321
+ intervalMs: Number,
322
+ path: {
323
+ default: "/app-kit/status",
324
+ type: String
325
+ },
326
+ title: String
327
+ },
328
+ setup(props) {
329
+ const options = {
330
+ description: props.description,
331
+ includeLinks: props.includeLinks,
332
+ intervalMs: props.intervalMs,
333
+ title: props.title
334
+ };
335
+ const status = useVoiceAppKitStatus(props.path, options);
336
+ return () => {
337
+ const model = createVoiceOpsStatusViewModel({
338
+ error: status.error.value,
339
+ isLoading: status.isLoading.value,
340
+ report: status.report.value,
341
+ updatedAt: status.updatedAt.value
342
+ }, options);
343
+ return h("section", {
344
+ class: [
345
+ "absolute-voice-ops-status",
346
+ `absolute-voice-ops-status--${model.status}`
347
+ ]
348
+ }, [
349
+ h("header", { class: "absolute-voice-ops-status__header" }, [
350
+ h("span", { class: "absolute-voice-ops-status__eyebrow" }, model.title),
351
+ h("strong", { class: "absolute-voice-ops-status__label" }, model.label)
352
+ ]),
353
+ h("p", { class: "absolute-voice-ops-status__description" }, model.description),
354
+ h("div", { class: "absolute-voice-ops-status__summary" }, [
355
+ h("span", `${model.passed} passing`),
356
+ h("span", `${Math.max(model.total - model.passed, 0)} failing`),
357
+ h("span", `${model.total} checks`)
358
+ ]),
359
+ h("ul", { class: "absolute-voice-ops-status__surfaces" }, model.surfaces.length > 0 ? model.surfaces.map((surface) => h("li", {
360
+ class: [
361
+ "absolute-voice-ops-status__surface",
362
+ `absolute-voice-ops-status__surface--${surface.status}`
363
+ ],
364
+ key: surface.id
365
+ }, [h("span", surface.label), h("strong", surface.detail)])) : [
366
+ h("li", { class: "absolute-voice-ops-status__surface" }, [
367
+ h("span", "Status"),
368
+ h("strong", "Waiting for first check")
369
+ ])
370
+ ]),
371
+ model.error ? h("p", { class: "absolute-voice-ops-status__error" }, model.error) : null,
372
+ model.links.length > 0 ? h("nav", { class: "absolute-voice-ops-status__links" }, model.links.slice(0, 4).map((link) => h("a", { href: link.href, key: link.href }, link.label))) : null
373
+ ]);
374
+ };
375
+ }
376
+ });
377
+ // src/vue/VoiceProviderSimulationControls.ts
378
+ import { computed, defineComponent as defineComponent2, h as h2 } from "vue";
379
+
380
+ // src/client/providerSimulationControls.ts
381
+ var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
382
+ const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
383
+ const body = await response.json().catch(() => null);
384
+ if (!response.ok) {
385
+ const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice provider simulation failed: HTTP ${response.status}`;
386
+ throw new Error(message);
387
+ }
388
+ return body;
389
+ };
390
+ var createVoiceProviderSimulationControlsStore = (options) => {
391
+ const listeners = new Set;
392
+ const fetchImpl = options.fetch ?? globalThis.fetch;
393
+ const pathPrefix = options.pathPrefix ?? `/api/${options.kind ?? "stt"}-simulate`;
394
+ let closed = false;
395
+ let snapshot = {
396
+ error: null,
397
+ isRunning: false,
398
+ lastResult: null,
399
+ mode: null,
400
+ provider: null
401
+ };
402
+ const emit = () => {
403
+ for (const listener of listeners) {
404
+ listener();
405
+ }
406
+ };
407
+ const run = async (provider, mode) => {
408
+ if (closed) {
409
+ return snapshot.lastResult;
410
+ }
411
+ snapshot = {
412
+ ...snapshot,
413
+ error: null,
414
+ isRunning: true,
415
+ mode,
416
+ provider
417
+ };
418
+ emit();
419
+ try {
420
+ const result = await postSimulation(pathPrefix, mode, provider, fetchImpl);
421
+ snapshot = {
422
+ error: null,
423
+ isRunning: false,
424
+ lastResult: result,
425
+ mode,
426
+ provider,
427
+ updatedAt: Date.now()
428
+ };
429
+ emit();
430
+ return result;
431
+ } catch (error) {
432
+ snapshot = {
433
+ ...snapshot,
434
+ error: error instanceof Error ? error.message : String(error),
435
+ isRunning: false
436
+ };
437
+ emit();
438
+ throw error;
439
+ }
440
+ };
441
+ const close = () => {
442
+ closed = true;
443
+ listeners.clear();
444
+ };
445
+ return {
446
+ close,
447
+ getServerSnapshot: () => snapshot,
448
+ getSnapshot: () => snapshot,
449
+ run,
450
+ subscribe: (listener) => {
451
+ listeners.add(listener);
452
+ return () => {
453
+ listeners.delete(listener);
454
+ };
455
+ }
456
+ };
457
+ };
458
+
459
+ // src/client/providerSimulationControlsWidget.ts
460
+ var escapeHtml2 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
461
+ var formatKind = (kind) => (kind ?? "stt").toUpperCase();
462
+ var createVoiceProviderSimulationControlsViewModel = (snapshot, options) => {
463
+ const configuredProviders = options.providers.filter((provider) => provider.configured !== false);
464
+ const fallbackReady = !options.fallbackRequiredProvider || configuredProviders.some((entry) => entry.provider === options.fallbackRequiredProvider);
465
+ const failureProviders = (options.failureProviders ? options.failureProviders.map((provider) => ({ provider })) : configuredProviders).filter((provider) => configuredProviders.some((entry) => entry.provider === provider.provider));
466
+ return {
467
+ canSimulateFailure: configuredProviders.length > 0 && fallbackReady,
468
+ description: options.failureMessage ?? `Simulate ${formatKind(options.kind)} provider failure and recovery without changing credentials.`,
469
+ error: snapshot.error,
470
+ failureProviders,
471
+ isRunning: snapshot.isRunning,
472
+ label: snapshot.isRunning ? `Running ${snapshot.mode ?? "simulation"}` : snapshot.lastResult ? `${snapshot.lastResult.provider} ${snapshot.lastResult.mode} simulated` : configuredProviders.length ? `${configuredProviders.length} configured` : "No configured providers",
473
+ providers: configuredProviders,
474
+ resultText: snapshot.lastResult ? JSON.stringify(snapshot.lastResult, null, 2) : null,
475
+ title: options.title ?? `${formatKind(options.kind)} Failure Simulation`
476
+ };
477
+ };
478
+ var renderVoiceProviderSimulationControlsHTML = (snapshot, options) => {
479
+ const model = createVoiceProviderSimulationControlsViewModel(snapshot, options);
480
+ const failureButtons = model.failureProviders.map((provider) => `<button type="button" data-voice-provider-fail="${escapeHtml2(provider.provider)}"${!model.canSimulateFailure || snapshot.isRunning ? " disabled" : ""}>Simulate ${escapeHtml2(provider.provider)} ${escapeHtml2(formatKind(options.kind))} failure</button>`).join("");
481
+ const recoveryButtons = model.providers.map((provider) => `<button type="button" data-voice-provider-recover="${escapeHtml2(provider.provider)}"${snapshot.isRunning ? " disabled" : ""}>Mark ${escapeHtml2(provider.provider)} recovered</button>`).join("");
482
+ return `<section class="absolute-voice-provider-simulation absolute-voice-provider-simulation--${snapshot.error ? "error" : snapshot.isRunning ? "running" : "ready"}">
483
+ <header class="absolute-voice-provider-simulation__header">
484
+ <span class="absolute-voice-provider-simulation__eyebrow">${escapeHtml2(model.title)}</span>
485
+ <strong class="absolute-voice-provider-simulation__label">${escapeHtml2(model.label)}</strong>
486
+ </header>
487
+ <p class="absolute-voice-provider-simulation__description">${escapeHtml2(model.description)}</p>
488
+ ${model.canSimulateFailure ? "" : `<p class="absolute-voice-provider-simulation__empty">${escapeHtml2(options.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure.")}</p>`}
489
+ <div class="absolute-voice-provider-simulation__actions">${failureButtons}${recoveryButtons}</div>
490
+ ${snapshot.error ? `<p class="absolute-voice-provider-simulation__error">${escapeHtml2(snapshot.error)}</p>` : ""}
491
+ ${model.resultText ? `<pre class="absolute-voice-provider-simulation__result">${escapeHtml2(model.resultText)}</pre>` : ""}
492
+ </section>`;
493
+ };
494
+ var bindVoiceProviderSimulationControls = (element, store) => {
495
+ const onClick = (event) => {
496
+ const target = event.target;
497
+ if (!(target instanceof HTMLElement)) {
498
+ return;
499
+ }
500
+ const failProvider = target.getAttribute("data-voice-provider-fail");
501
+ const recoverProvider = target.getAttribute("data-voice-provider-recover");
502
+ if (failProvider) {
503
+ store.run(failProvider, "failure").catch(() => {});
504
+ }
505
+ if (recoverProvider) {
506
+ store.run(recoverProvider, "recovery").catch(() => {});
507
+ }
508
+ };
509
+ element.addEventListener("click", onClick);
510
+ return () => element.removeEventListener("click", onClick);
511
+ };
512
+ var mountVoiceProviderSimulationControls = (element, options) => {
513
+ const store = createVoiceProviderSimulationControlsStore(options);
514
+ const render = () => {
515
+ element.innerHTML = renderVoiceProviderSimulationControlsHTML(store.getSnapshot(), options);
516
+ };
517
+ const unsubscribeStore = store.subscribe(render);
518
+ const unsubscribeDom = bindVoiceProviderSimulationControls(element, store);
519
+ render();
520
+ return {
521
+ close: () => {
522
+ unsubscribeDom();
523
+ unsubscribeStore();
524
+ store.close();
525
+ },
526
+ run: store.run
527
+ };
528
+ };
529
+ var defineVoiceProviderSimulationControlsElement = (tagName = "absolute-voice-provider-simulation") => {
530
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
531
+ return;
532
+ }
533
+ customElements.define(tagName, class AbsoluteVoiceProviderSimulationElement extends HTMLElement {
534
+ mounted;
535
+ connectedCallback() {
536
+ const providers = (this.getAttribute("providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean).map((provider) => ({ provider }));
537
+ const failureProviders = (this.getAttribute("failure-providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean);
538
+ this.mounted = mountVoiceProviderSimulationControls(this, {
539
+ failureProviders: failureProviders.length ? failureProviders : undefined,
540
+ fallbackRequiredMessage: this.getAttribute("fallback-required-message") ?? undefined,
541
+ fallbackRequiredProvider: this.getAttribute("fallback-required-provider") ?? undefined,
542
+ failureMessage: this.getAttribute("failure-message") ?? undefined,
543
+ kind: this.getAttribute("kind") ?? "stt",
544
+ pathPrefix: this.getAttribute("path-prefix") ?? undefined,
545
+ providers,
546
+ title: this.getAttribute("title") ?? undefined
547
+ });
548
+ }
549
+ disconnectedCallback() {
550
+ this.mounted?.close();
551
+ this.mounted = undefined;
552
+ }
553
+ });
554
+ };
555
+
556
+ // src/vue/useVoiceProviderSimulationControls.ts
557
+ import { onUnmounted as onUnmounted2, ref as ref2 } from "vue";
558
+ function useVoiceProviderSimulationControls(options) {
559
+ const store = createVoiceProviderSimulationControlsStore(options);
560
+ const error = ref2(null);
561
+ const isRunning = ref2(false);
562
+ const lastResult = ref2(null);
563
+ const mode = ref2(null);
564
+ const provider = ref2(null);
565
+ const updatedAt = ref2(undefined);
566
+ const sync = () => {
567
+ const snapshot = store.getSnapshot();
568
+ error.value = snapshot.error;
569
+ isRunning.value = snapshot.isRunning;
570
+ lastResult.value = snapshot.lastResult;
571
+ mode.value = snapshot.mode;
572
+ provider.value = snapshot.provider;
573
+ updatedAt.value = snapshot.updatedAt;
574
+ };
575
+ const unsubscribe = store.subscribe(sync);
576
+ sync();
577
+ onUnmounted2(() => {
578
+ unsubscribe();
579
+ store.close();
580
+ });
581
+ return {
582
+ error,
583
+ isRunning,
584
+ lastResult,
585
+ mode,
586
+ provider,
587
+ run: store.run,
588
+ updatedAt
589
+ };
590
+ }
591
+
592
+ // src/vue/VoiceProviderSimulationControls.ts
593
+ var VoiceProviderSimulationControls = defineComponent2({
594
+ name: "VoiceProviderSimulationControls",
595
+ props: {
596
+ class: { default: "", type: String },
597
+ fallbackRequiredMessage: { default: undefined, type: String },
598
+ fallbackRequiredProvider: { default: undefined, type: String },
599
+ failureMessage: { default: undefined, type: String },
600
+ failureProviders: {
601
+ default: undefined,
602
+ type: Array
603
+ },
604
+ kind: { default: "stt", type: String },
605
+ pathPrefix: { default: undefined, type: String },
606
+ providers: {
607
+ required: true,
608
+ type: Array
609
+ },
610
+ title: { default: undefined, type: String }
611
+ },
612
+ setup(props) {
613
+ const options = {
614
+ fallbackRequiredMessage: props.fallbackRequiredMessage,
615
+ fallbackRequiredProvider: props.fallbackRequiredProvider,
616
+ failureMessage: props.failureMessage,
617
+ failureProviders: props.failureProviders,
618
+ kind: props.kind,
619
+ pathPrefix: props.pathPrefix,
620
+ providers: props.providers,
621
+ title: props.title
622
+ };
623
+ const controls = useVoiceProviderSimulationControls(options);
624
+ const model = computed(() => createVoiceProviderSimulationControlsViewModel({
625
+ error: controls.error.value,
626
+ isRunning: controls.isRunning.value,
627
+ lastResult: controls.lastResult.value,
628
+ mode: controls.mode.value,
629
+ provider: controls.provider.value,
630
+ updatedAt: controls.updatedAt.value
631
+ }, options));
632
+ const run = (provider, mode) => {
633
+ controls.run(provider, mode).catch(() => {});
634
+ };
635
+ return () => h2("section", {
636
+ class: [
637
+ "absolute-voice-provider-simulation",
638
+ `absolute-voice-provider-simulation--${controls.error.value ? "error" : controls.isRunning.value ? "running" : "ready"}`,
639
+ props.class
640
+ ]
641
+ }, [
642
+ h2("header", { class: "absolute-voice-provider-simulation__header" }, [
643
+ h2("span", { class: "absolute-voice-provider-simulation__eyebrow" }, model.value.title),
644
+ h2("strong", { class: "absolute-voice-provider-simulation__label" }, model.value.label)
645
+ ]),
646
+ h2("p", { class: "absolute-voice-provider-simulation__description" }, model.value.description),
647
+ model.value.canSimulateFailure ? null : h2("p", { class: "absolute-voice-provider-simulation__empty" }, props.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure."),
648
+ h2("div", { class: "absolute-voice-provider-simulation__actions" }, [
649
+ ...model.value.failureProviders.map((provider) => h2("button", {
650
+ disabled: !model.value.canSimulateFailure || controls.isRunning.value,
651
+ key: `fail-${provider.provider}`,
652
+ onClick: () => run(provider.provider, "failure"),
653
+ type: "button"
654
+ }, `Simulate ${provider.provider} ${props.kind.toUpperCase()} failure`)),
655
+ ...model.value.providers.map((provider) => h2("button", {
656
+ disabled: controls.isRunning.value,
657
+ key: `recover-${provider.provider}`,
658
+ onClick: () => run(provider.provider, "recovery"),
659
+ type: "button"
660
+ }, `Mark ${provider.provider} recovered`))
661
+ ]),
662
+ controls.error.value ? h2("p", { class: "absolute-voice-provider-simulation__error" }, controls.error.value) : null,
663
+ model.value.resultText ? h2("pre", { class: "absolute-voice-provider-simulation__result" }, model.value.resultText) : null
664
+ ]);
665
+ }
666
+ });
667
+ // src/vue/VoiceProviderCapabilities.ts
668
+ import { computed as computed2, defineComponent as defineComponent3, h as h3 } from "vue";
669
+
670
+ // src/client/providerCapabilities.ts
671
+ var fetchVoiceProviderCapabilities = async (path = "/api/provider-capabilities", options = {}) => {
672
+ const fetchImpl = options.fetch ?? globalThis.fetch;
673
+ const response = await fetchImpl(path);
674
+ if (!response.ok) {
675
+ throw new Error(`Voice provider capabilities failed: HTTP ${response.status}`);
676
+ }
677
+ return await response.json();
678
+ };
679
+ var createVoiceProviderCapabilitiesStore = (path = "/api/provider-capabilities", options = {}) => {
680
+ const listeners = new Set;
681
+ let closed = false;
682
+ let timer;
683
+ let snapshot = {
684
+ error: null,
685
+ isLoading: false
686
+ };
687
+ const emit = () => {
688
+ for (const listener of listeners) {
689
+ listener();
690
+ }
691
+ };
692
+ const refresh = async () => {
693
+ if (closed) {
694
+ return snapshot.report;
695
+ }
696
+ snapshot = {
697
+ ...snapshot,
698
+ error: null,
699
+ isLoading: true
700
+ };
701
+ emit();
702
+ try {
703
+ const report = await fetchVoiceProviderCapabilities(path, options);
704
+ snapshot = {
705
+ error: null,
706
+ isLoading: false,
707
+ report,
708
+ updatedAt: Date.now()
709
+ };
710
+ emit();
711
+ return report;
712
+ } catch (error) {
713
+ snapshot = {
714
+ ...snapshot,
715
+ error: error instanceof Error ? error.message : String(error),
716
+ isLoading: false
717
+ };
718
+ emit();
719
+ throw error;
720
+ }
721
+ };
722
+ const close = () => {
723
+ closed = true;
724
+ if (timer) {
725
+ clearInterval(timer);
726
+ timer = undefined;
727
+ }
728
+ listeners.clear();
729
+ };
730
+ if (options.intervalMs && options.intervalMs > 0) {
731
+ timer = setInterval(() => {
732
+ refresh().catch(() => {});
733
+ }, options.intervalMs);
734
+ }
735
+ return {
736
+ close,
737
+ getServerSnapshot: () => snapshot,
738
+ getSnapshot: () => snapshot,
739
+ refresh,
740
+ subscribe: (listener) => {
741
+ listeners.add(listener);
742
+ return () => {
743
+ listeners.delete(listener);
744
+ };
745
+ }
746
+ };
747
+ };
748
+
749
+ // src/client/providerCapabilitiesWidget.ts
750
+ var DEFAULT_TITLE2 = "Provider Capabilities";
751
+ var DEFAULT_DESCRIPTION2 = "Configured, selected, and healthy voice providers for this deployment.";
752
+ var escapeHtml3 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
753
+ var formatProvider = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
754
+ var formatKind2 = (kind) => kind.toUpperCase();
755
+ var formatStatus = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
756
+ var getCapabilityDetail = (capability) => {
757
+ if (!capability.configured) {
758
+ return "Not configured in this deployment.";
759
+ }
760
+ if (capability.selected) {
761
+ return `Selected ${capability.kind.toUpperCase()} provider for new sessions.`;
762
+ }
763
+ if (capability.health?.status === "healthy") {
764
+ return "Configured and healthy fallback candidate.";
765
+ }
766
+ if (capability.health?.status === "idle") {
767
+ return "Configured; no traffic observed yet.";
768
+ }
769
+ if (capability.health?.lastError) {
770
+ return capability.health.lastError;
771
+ }
772
+ return "Configured and available.";
773
+ };
774
+ var isWarningStatus = (status) => status === "degraded" || status === "rate-limited" || status === "suppressed" || status === "unconfigured";
775
+ var createVoiceProviderCapabilitiesViewModel = (snapshot, options = {}) => {
776
+ const capabilities = (snapshot.report?.capabilities ?? []).map((capability) => ({
777
+ ...capability,
778
+ detail: getCapabilityDetail(capability),
779
+ label: `${formatProvider(capability.provider)} ${formatKind2(capability.kind)}`,
780
+ rows: [
781
+ { label: "Status", value: formatStatus(capability.status) },
782
+ { label: "Selected", value: capability.selected ? "Yes" : "No" },
783
+ { label: "Model", value: capability.model ?? "Default" },
784
+ {
785
+ label: "Features",
786
+ value: capability.features?.join(", ") || "Not specified"
787
+ },
788
+ { label: "Runs", value: String(capability.health?.runCount ?? 0) },
789
+ { label: "Errors", value: String(capability.health?.errorCount ?? 0) }
790
+ ]
791
+ }));
792
+ const warningCount = capabilities.filter((capability) => isWarningStatus(capability.status)).length;
793
+ const selectedCount = snapshot.report?.selected ?? capabilities.filter((capability) => capability.selected).length;
794
+ return {
795
+ capabilities,
796
+ description: options.description ?? DEFAULT_DESCRIPTION2,
797
+ error: snapshot.error,
798
+ isLoading: snapshot.isLoading,
799
+ label: snapshot.error ? "Unavailable" : capabilities.length ? warningCount > 0 ? `${warningCount} needs attention` : `${selectedCount} selected` : snapshot.isLoading ? "Checking" : "No capabilities",
800
+ status: snapshot.error ? "error" : capabilities.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
801
+ title: options.title ?? DEFAULT_TITLE2,
802
+ updatedAt: snapshot.updatedAt
803
+ };
804
+ };
805
+ var renderVoiceProviderCapabilitiesHTML = (snapshot, options = {}) => {
806
+ const model = createVoiceProviderCapabilitiesViewModel(snapshot, options);
807
+ const capabilities = model.capabilities.length ? `<div class="absolute-voice-provider-capabilities__providers">${model.capabilities.map((capability) => `<article class="absolute-voice-provider-capabilities__provider absolute-voice-provider-capabilities__provider--${escapeHtml3(capability.status)}">
808
+ <header>
809
+ <strong>${escapeHtml3(capability.label)}</strong>
810
+ <span>${escapeHtml3(formatStatus(capability.status))}</span>
811
+ </header>
812
+ <p>${escapeHtml3(capability.detail)}</p>
813
+ <dl>${capability.rows.map((row) => `<div>
814
+ <dt>${escapeHtml3(row.label)}</dt>
815
+ <dd>${escapeHtml3(row.value)}</dd>
816
+ </div>`).join("")}</dl>
817
+ </article>`).join("")}</div>` : '<p class="absolute-voice-provider-capabilities__empty">Configure provider capabilities to see deployment coverage.</p>';
818
+ return `<section class="absolute-voice-provider-capabilities absolute-voice-provider-capabilities--${escapeHtml3(model.status)}">
819
+ <header class="absolute-voice-provider-capabilities__header">
820
+ <span class="absolute-voice-provider-capabilities__eyebrow">${escapeHtml3(model.title)}</span>
821
+ <strong class="absolute-voice-provider-capabilities__label">${escapeHtml3(model.label)}</strong>
822
+ </header>
823
+ <p class="absolute-voice-provider-capabilities__description">${escapeHtml3(model.description)}</p>
824
+ ${capabilities}
825
+ ${model.error ? `<p class="absolute-voice-provider-capabilities__error">${escapeHtml3(model.error)}</p>` : ""}
826
+ </section>`;
827
+ };
828
+ var getVoiceProviderCapabilitiesCSS = () => `.absolute-voice-provider-capabilities{border:1px solid #bfd7ea;border-radius:20px;background:#f6fbff;color:#08131f;padding:18px;box-shadow:0 18px 40px rgba(14,51,78,.12);font-family:inherit}.absolute-voice-provider-capabilities--error,.absolute-voice-provider-capabilities--warning{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-provider-capabilities__header,.absolute-voice-provider-capabilities__provider header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-provider-capabilities__eyebrow{color:#255f85;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-provider-capabilities__label{font-size:24px;line-height:1}.absolute-voice-provider-capabilities__description,.absolute-voice-provider-capabilities__provider p,.absolute-voice-provider-capabilities__provider dt,.absolute-voice-provider-capabilities__empty{color:#405467}.absolute-voice-provider-capabilities__providers{display:grid;gap:12px;margin-top:14px}.absolute-voice-provider-capabilities__provider{background:#fff;border:1px solid #d7e7f3;border-radius:16px;padding:14px}.absolute-voice-provider-capabilities__provider--selected,.absolute-voice-provider-capabilities__provider--healthy{border-color:#86efac}.absolute-voice-provider-capabilities__provider--degraded,.absolute-voice-provider-capabilities__provider--rate-limited,.absolute-voice-provider-capabilities__provider--suppressed,.absolute-voice-provider-capabilities__provider--unconfigured{border-color:#f2a7a7}.absolute-voice-provider-capabilities__provider p{margin:10px 0}.absolute-voice-provider-capabilities__provider dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-provider-capabilities__provider div{background:#f6fbff;border:1px solid #d7e7f3;border-radius:12px;padding:8px}.absolute-voice-provider-capabilities__provider dt{font-size:12px}.absolute-voice-provider-capabilities__provider dd{font-weight:800;margin:4px 0 0}.absolute-voice-provider-capabilities__empty{margin:14px 0 0}.absolute-voice-provider-capabilities__error{color:#9f1239;font-weight:700}`;
829
+ var mountVoiceProviderCapabilities = (element, path = "/api/provider-capabilities", options = {}) => {
830
+ const store = createVoiceProviderCapabilitiesStore(path, options);
831
+ const render = () => {
832
+ element.innerHTML = renderVoiceProviderCapabilitiesHTML(store.getSnapshot(), options);
833
+ };
834
+ const unsubscribe = store.subscribe(render);
835
+ render();
836
+ store.refresh().catch(() => {});
837
+ return {
838
+ close: () => {
839
+ unsubscribe();
840
+ store.close();
841
+ },
842
+ refresh: store.refresh
843
+ };
844
+ };
845
+ var defineVoiceProviderCapabilitiesElement = (tagName = "absolute-voice-provider-capabilities") => {
846
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
847
+ return;
848
+ }
849
+ customElements.define(tagName, class AbsoluteVoiceProviderCapabilitiesElement extends HTMLElement {
850
+ mounted;
851
+ connectedCallback() {
852
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
853
+ this.mounted = mountVoiceProviderCapabilities(this, this.getAttribute("path") ?? "/api/provider-capabilities", {
854
+ description: this.getAttribute("description") ?? undefined,
855
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
856
+ title: this.getAttribute("title") ?? undefined
857
+ });
858
+ }
859
+ disconnectedCallback() {
860
+ this.mounted?.close();
861
+ this.mounted = undefined;
862
+ }
863
+ });
864
+ };
865
+
866
+ // src/vue/useVoiceProviderCapabilities.ts
867
+ import { onUnmounted as onUnmounted3, shallowRef as shallowRef2 } from "vue";
868
+ function useVoiceProviderCapabilities(path = "/api/provider-capabilities", options = {}) {
869
+ const store = createVoiceProviderCapabilitiesStore(path, options);
870
+ const error = shallowRef2(null);
871
+ const isLoading = shallowRef2(false);
872
+ const report = shallowRef2();
873
+ const updatedAt = shallowRef2(undefined);
874
+ const sync = () => {
875
+ const snapshot = store.getSnapshot();
876
+ error.value = snapshot.error;
877
+ isLoading.value = snapshot.isLoading;
878
+ report.value = snapshot.report;
879
+ updatedAt.value = snapshot.updatedAt;
880
+ };
881
+ const unsubscribe = store.subscribe(sync);
882
+ sync();
883
+ store.refresh().catch(() => {});
884
+ onUnmounted3(() => {
885
+ unsubscribe();
886
+ store.close();
887
+ });
888
+ return {
889
+ error,
890
+ isLoading,
891
+ refresh: store.refresh,
892
+ report,
893
+ updatedAt
894
+ };
895
+ }
896
+
897
+ // src/vue/VoiceProviderCapabilities.ts
898
+ var VoiceProviderCapabilities = defineComponent3({
899
+ name: "VoiceProviderCapabilities",
900
+ props: {
901
+ class: {
902
+ default: "",
903
+ type: String
904
+ },
905
+ description: {
906
+ default: undefined,
907
+ type: String
908
+ },
909
+ intervalMs: {
910
+ default: 5000,
911
+ type: Number
912
+ },
913
+ path: {
914
+ default: "/api/provider-capabilities",
915
+ type: String
916
+ },
917
+ title: {
918
+ default: undefined,
919
+ type: String
920
+ }
921
+ },
922
+ setup(props) {
923
+ const options = {
924
+ description: props.description,
925
+ intervalMs: props.intervalMs,
926
+ title: props.title
927
+ };
928
+ const capabilities = useVoiceProviderCapabilities(props.path, options);
929
+ const model = computed2(() => createVoiceProviderCapabilitiesViewModel({
930
+ error: capabilities.error.value,
931
+ isLoading: capabilities.isLoading.value,
932
+ report: capabilities.report.value,
933
+ updatedAt: capabilities.updatedAt.value
934
+ }, options));
935
+ return () => h3("section", {
936
+ class: [
937
+ "absolute-voice-provider-capabilities",
938
+ `absolute-voice-provider-capabilities--${model.value.status}`,
939
+ props.class
940
+ ]
941
+ }, [
942
+ h3("header", { class: "absolute-voice-provider-capabilities__header" }, [
943
+ h3("span", { class: "absolute-voice-provider-capabilities__eyebrow" }, model.value.title),
944
+ h3("strong", { class: "absolute-voice-provider-capabilities__label" }, model.value.label)
945
+ ]),
946
+ h3("p", { class: "absolute-voice-provider-capabilities__description" }, model.value.description),
947
+ model.value.capabilities.length ? h3("div", { class: "absolute-voice-provider-capabilities__providers" }, model.value.capabilities.map((capability) => h3("article", {
948
+ class: [
949
+ "absolute-voice-provider-capabilities__provider",
950
+ `absolute-voice-provider-capabilities__provider--${capability.status}`
951
+ ],
952
+ key: `${capability.kind}:${capability.provider}`
953
+ }, [
954
+ h3("header", [
955
+ h3("strong", capability.label),
956
+ h3("span", capability.status)
957
+ ]),
958
+ h3("p", capability.detail),
959
+ h3("dl", capability.rows.map((row) => h3("div", { key: row.label }, [
960
+ h3("dt", row.label),
961
+ h3("dd", row.value)
962
+ ])))
963
+ ]))) : h3("p", { class: "absolute-voice-provider-capabilities__empty" }, "Configure provider capabilities to see deployment coverage."),
964
+ model.value.error ? h3("p", { class: "absolute-voice-provider-capabilities__error" }, model.value.error) : null
965
+ ]);
966
+ }
967
+ });
968
+ // src/vue/VoiceProviderStatus.ts
969
+ import { computed as computed3, defineComponent as defineComponent4, h as h4 } from "vue";
970
+
971
+ // src/client/providerStatus.ts
972
+ var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
973
+ const fetchImpl = options.fetch ?? globalThis.fetch;
974
+ const response = await fetchImpl(path);
975
+ if (!response.ok) {
976
+ throw new Error(`Voice provider status failed: HTTP ${response.status}`);
977
+ }
978
+ return await response.json();
979
+ };
980
+ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
981
+ const listeners = new Set;
982
+ let closed = false;
983
+ let timer;
984
+ let snapshot = {
985
+ error: null,
986
+ isLoading: false,
987
+ providers: []
988
+ };
989
+ const emit = () => {
990
+ for (const listener of listeners) {
991
+ listener();
992
+ }
993
+ };
994
+ const refresh = async () => {
995
+ if (closed) {
996
+ return snapshot.providers;
997
+ }
998
+ snapshot = {
999
+ ...snapshot,
1000
+ error: null,
1001
+ isLoading: true
1002
+ };
1003
+ emit();
1004
+ try {
1005
+ const providers = await fetchVoiceProviderStatus(path, options);
1006
+ snapshot = {
1007
+ error: null,
1008
+ isLoading: false,
1009
+ providers,
1010
+ updatedAt: Date.now()
1011
+ };
1012
+ emit();
1013
+ return providers;
1014
+ } catch (error) {
1015
+ snapshot = {
1016
+ ...snapshot,
1017
+ error: error instanceof Error ? error.message : String(error),
1018
+ isLoading: false
1019
+ };
1020
+ emit();
1021
+ throw error;
1022
+ }
1023
+ };
1024
+ const close = () => {
1025
+ closed = true;
1026
+ if (timer) {
1027
+ clearInterval(timer);
1028
+ timer = undefined;
1029
+ }
1030
+ listeners.clear();
1031
+ };
1032
+ if (options.intervalMs && options.intervalMs > 0) {
1033
+ timer = setInterval(() => {
1034
+ refresh().catch(() => {});
1035
+ }, options.intervalMs);
1036
+ }
1037
+ return {
1038
+ close,
1039
+ getServerSnapshot: () => snapshot,
1040
+ getSnapshot: () => snapshot,
1041
+ refresh,
1042
+ subscribe: (listener) => {
1043
+ listeners.add(listener);
1044
+ return () => {
1045
+ listeners.delete(listener);
1046
+ };
1047
+ }
1048
+ };
1049
+ };
1050
+
1051
+ // src/client/providerStatusWidget.ts
1052
+ var DEFAULT_TITLE3 = "Voice Providers";
1053
+ var DEFAULT_DESCRIPTION3 = "Live provider health, fallback counts, latency, and suppression state from your self-hosted trace store.";
1054
+ var escapeHtml4 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1055
+ var formatProvider2 = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
1056
+ var formatStatus2 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
1057
+ var formatLatency = (value) => typeof value === "number" ? `${value}ms` : "No samples";
1058
+ var formatSuppression = (value) => typeof value === "number" ? `${Math.ceil(value / 1000)}s` : "None";
1059
+ var getProviderDetail = (provider) => {
1060
+ if (provider.status === "suppressed") {
1061
+ return provider.lastError ? `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)} after ${provider.lastError}.` : `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)}.`;
1062
+ }
1063
+ if (provider.status === "recoverable") {
1064
+ return "Cooldown expired; ready for recovery traffic.";
1065
+ }
1066
+ if (provider.status === "rate-limited") {
1067
+ return "Rate limit detected; router should avoid this provider.";
1068
+ }
1069
+ if (provider.status === "degraded") {
1070
+ return provider.lastError ?? "Recent provider errors detected.";
1071
+ }
1072
+ if (provider.status === "healthy") {
1073
+ return provider.recommended ? "Healthy and currently recommended." : "Healthy and available for routing.";
1074
+ }
1075
+ return "No provider traffic observed yet.";
1076
+ };
1077
+ var isWarningStatus2 = (status) => status === "degraded" || status === "rate-limited" || status === "recoverable" || status === "suppressed";
1078
+ var createVoiceProviderStatusViewModel = (snapshot, options = {}) => {
1079
+ const providers = snapshot.providers.map((provider) => ({
1080
+ ...provider,
1081
+ detail: getProviderDetail(provider),
1082
+ label: `${formatProvider2(provider.provider)}${provider.recommended ? " recommended" : ""}`,
1083
+ rows: [
1084
+ { label: "Runs", value: String(provider.runCount) },
1085
+ { label: "Avg latency", value: formatLatency(provider.averageElapsedMs) },
1086
+ { label: "Errors", value: String(provider.errorCount) },
1087
+ { label: "Timeouts", value: String(provider.timeoutCount) },
1088
+ { label: "Fallbacks", value: String(provider.fallbackCount) },
1089
+ {
1090
+ label: "Suppression",
1091
+ value: formatSuppression(provider.suppressionRemainingMs)
1092
+ }
1093
+ ]
1094
+ }));
1095
+ const warningCount = providers.filter((provider) => isWarningStatus2(provider.status)).length;
1096
+ const healthyCount = providers.filter((provider) => provider.status === "healthy").length;
1097
+ return {
1098
+ description: options.description ?? DEFAULT_DESCRIPTION3,
1099
+ error: snapshot.error,
1100
+ isLoading: snapshot.isLoading,
1101
+ label: snapshot.error ? "Unavailable" : providers.length ? warningCount > 0 ? `${warningCount} needs attention` : `${healthyCount} healthy` : snapshot.isLoading ? "Checking" : "No provider traffic",
1102
+ providers,
1103
+ status: snapshot.error ? "error" : providers.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
1104
+ title: options.title ?? DEFAULT_TITLE3,
1105
+ updatedAt: snapshot.updatedAt
1106
+ };
1107
+ };
1108
+ var renderVoiceProviderStatusHTML = (snapshot, options = {}) => {
1109
+ const model = createVoiceProviderStatusViewModel(snapshot, options);
1110
+ const providers = model.providers.length ? `<div class="absolute-voice-provider-status__providers">${model.providers.map((provider) => `<article class="absolute-voice-provider-status__provider absolute-voice-provider-status__provider--${escapeHtml4(provider.status)}">
1111
+ <header>
1112
+ <strong>${escapeHtml4(provider.label)}</strong>
1113
+ <span>${escapeHtml4(formatStatus2(provider.status))}</span>
1114
+ </header>
1115
+ <p>${escapeHtml4(provider.detail)}</p>
1116
+ <dl>${provider.rows.map((row) => `<div>
1117
+ <dt>${escapeHtml4(row.label)}</dt>
1118
+ <dd>${escapeHtml4(row.value)}</dd>
1119
+ </div>`).join("")}</dl>
1120
+ </article>`).join("")}</div>` : '<p class="absolute-voice-provider-status__empty">Run voice traffic to see provider health.</p>';
1121
+ return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${escapeHtml4(model.status)}">
1122
+ <header class="absolute-voice-provider-status__header">
1123
+ <span class="absolute-voice-provider-status__eyebrow">${escapeHtml4(model.title)}</span>
1124
+ <strong class="absolute-voice-provider-status__label">${escapeHtml4(model.label)}</strong>
1125
+ </header>
1126
+ <p class="absolute-voice-provider-status__description">${escapeHtml4(model.description)}</p>
1127
+ ${providers}
1128
+ ${model.error ? `<p class="absolute-voice-provider-status__error">${escapeHtml4(model.error)}</p>` : ""}
1129
+ </section>`;
1130
+ };
1131
+ var getVoiceProviderStatusCSS = () => `.absolute-voice-provider-status{border:1px solid #d8d2c4;border-radius:20px;background:#fffaf0;color:#16130d;padding:18px;box-shadow:0 18px 40px rgba(47,37,18,.12);font-family:inherit}.absolute-voice-provider-status--error,.absolute-voice-provider-status--warning{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-provider-status__header,.absolute-voice-provider-status__provider header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-provider-status__eyebrow{color:#73664f;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-provider-status__label{font-size:24px;line-height:1}.absolute-voice-provider-status__description,.absolute-voice-provider-status__provider p,.absolute-voice-provider-status__provider dt,.absolute-voice-provider-status__empty{color:#514733}.absolute-voice-provider-status__providers{display:grid;gap:12px;margin-top:14px}.absolute-voice-provider-status__provider{background:#fff;border:1px solid #eee4d2;border-radius:16px;padding:14px}.absolute-voice-provider-status__provider--degraded,.absolute-voice-provider-status__provider--rate-limited,.absolute-voice-provider-status__provider--suppressed{border-color:#f2a7a7}.absolute-voice-provider-status__provider--recoverable{border-color:#fbbf24}.absolute-voice-provider-status__provider p{margin:10px 0}.absolute-voice-provider-status__provider dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-provider-status__provider div{background:#fffaf0;border:1px solid #eee4d2;border-radius:12px;padding:8px}.absolute-voice-provider-status__provider dt{font-size:12px}.absolute-voice-provider-status__provider dd{font-weight:800;margin:4px 0 0}.absolute-voice-provider-status__empty{margin:14px 0 0}.absolute-voice-provider-status__error{color:#9f1239;font-weight:700}`;
1132
+ var mountVoiceProviderStatus = (element, path = "/api/provider-status", options = {}) => {
1133
+ const store = createVoiceProviderStatusStore(path, options);
1134
+ const render = () => {
1135
+ element.innerHTML = renderVoiceProviderStatusHTML(store.getSnapshot(), options);
1136
+ };
1137
+ const unsubscribe = store.subscribe(render);
1138
+ render();
1139
+ store.refresh().catch(() => {});
1140
+ return {
1141
+ close: () => {
1142
+ unsubscribe();
1143
+ store.close();
1144
+ },
1145
+ refresh: store.refresh
1146
+ };
1147
+ };
1148
+ var defineVoiceProviderStatusElement = (tagName = "absolute-voice-provider-status") => {
1149
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
1150
+ return;
1151
+ }
1152
+ customElements.define(tagName, class AbsoluteVoiceProviderStatusElement extends HTMLElement {
1153
+ mounted;
1154
+ connectedCallback() {
1155
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
1156
+ this.mounted = mountVoiceProviderStatus(this, this.getAttribute("path") ?? "/api/provider-status", {
1157
+ description: this.getAttribute("description") ?? undefined,
1158
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
1159
+ title: this.getAttribute("title") ?? undefined
1160
+ });
1161
+ }
1162
+ disconnectedCallback() {
1163
+ this.mounted?.close();
1164
+ this.mounted = undefined;
1165
+ }
1166
+ });
1167
+ };
1168
+
1169
+ // src/vue/useVoiceProviderStatus.ts
1170
+ import { onUnmounted as onUnmounted4, ref as ref3, shallowRef as shallowRef3 } from "vue";
1171
+ function useVoiceProviderStatus(path = "/api/provider-status", options = {}) {
1172
+ const store = createVoiceProviderStatusStore(path, options);
1173
+ const error = ref3(null);
1174
+ const isLoading = ref3(false);
1175
+ const providers = shallowRef3([]);
1176
+ const updatedAt = ref3(undefined);
1177
+ const sync = () => {
1178
+ const snapshot = store.getSnapshot();
1179
+ error.value = snapshot.error;
1180
+ isLoading.value = snapshot.isLoading;
1181
+ providers.value = [...snapshot.providers];
1182
+ updatedAt.value = snapshot.updatedAt;
1183
+ };
1184
+ const unsubscribe = store.subscribe(sync);
1185
+ sync();
1186
+ store.refresh().catch(() => {});
1187
+ onUnmounted4(() => {
1188
+ unsubscribe();
1189
+ store.close();
1190
+ });
1191
+ return {
1192
+ error,
1193
+ isLoading,
1194
+ providers,
1195
+ refresh: store.refresh,
1196
+ updatedAt
1197
+ };
1198
+ }
1199
+
1200
+ // src/vue/VoiceProviderStatus.ts
1201
+ var VoiceProviderStatus = defineComponent4({
1202
+ name: "VoiceProviderStatus",
1203
+ props: {
1204
+ class: {
1205
+ default: "",
1206
+ type: String
1207
+ },
1208
+ description: {
1209
+ default: undefined,
1210
+ type: String
1211
+ },
1212
+ intervalMs: {
1213
+ default: 5000,
1214
+ type: Number
1215
+ },
1216
+ path: {
1217
+ default: "/api/provider-status",
1218
+ type: String
1219
+ },
1220
+ title: {
1221
+ default: undefined,
1222
+ type: String
1223
+ }
1224
+ },
1225
+ setup(props) {
1226
+ const options = {
1227
+ description: props.description,
1228
+ intervalMs: props.intervalMs,
1229
+ title: props.title
1230
+ };
1231
+ const status = useVoiceProviderStatus(props.path, options);
1232
+ const model = computed3(() => createVoiceProviderStatusViewModel({
1233
+ error: status.error.value,
1234
+ isLoading: status.isLoading.value,
1235
+ providers: status.providers.value,
1236
+ updatedAt: status.updatedAt.value
1237
+ }, options));
1238
+ return () => h4("section", {
1239
+ class: [
1240
+ "absolute-voice-provider-status",
1241
+ `absolute-voice-provider-status--${model.value.status}`,
1242
+ props.class
1243
+ ]
1244
+ }, [
1245
+ h4("header", { class: "absolute-voice-provider-status__header" }, [
1246
+ h4("span", { class: "absolute-voice-provider-status__eyebrow" }, model.value.title),
1247
+ h4("strong", { class: "absolute-voice-provider-status__label" }, model.value.label)
1248
+ ]),
1249
+ h4("p", { class: "absolute-voice-provider-status__description" }, model.value.description),
1250
+ model.value.providers.length ? h4("div", { class: "absolute-voice-provider-status__providers" }, model.value.providers.map((provider) => h4("article", {
1251
+ class: [
1252
+ "absolute-voice-provider-status__provider",
1253
+ `absolute-voice-provider-status__provider--${provider.status}`
1254
+ ],
1255
+ key: provider.provider
1256
+ }, [
1257
+ h4("header", [
1258
+ h4("strong", provider.label),
1259
+ h4("span", provider.status)
1260
+ ]),
1261
+ h4("p", provider.detail),
1262
+ h4("dl", provider.rows.map((row) => h4("div", { key: row.label }, [
1263
+ h4("dt", row.label),
1264
+ h4("dd", row.value)
1265
+ ])))
1266
+ ]))) : h4("p", { class: "absolute-voice-provider-status__empty" }, "Run voice traffic to see provider health."),
1267
+ model.value.error ? h4("p", { class: "absolute-voice-provider-status__error" }, model.value.error) : null
1268
+ ]);
1269
+ }
1270
+ });
1271
+ // src/vue/VoiceRoutingStatus.ts
1272
+ import { computed as computed4, defineComponent as defineComponent5, h as h5 } from "vue";
1273
+
1274
+ // src/client/routingStatus.ts
1275
+ var fetchVoiceRoutingStatus = async (path = "/api/routing/latest", options = {}) => {
1276
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1277
+ const response = await fetchImpl(path);
1278
+ if (!response.ok) {
1279
+ throw new Error(`Voice routing status failed: HTTP ${response.status}`);
1280
+ }
1281
+ return await response.json();
1282
+ };
1283
+ var createVoiceRoutingStatusStore = (path = "/api/routing/latest", options = {}) => {
1284
+ const listeners = new Set;
1285
+ let closed = false;
1286
+ let timer;
1287
+ let snapshot = {
1288
+ decision: null,
1289
+ error: null,
1290
+ isLoading: false
1291
+ };
1292
+ const emit = () => {
1293
+ for (const listener of listeners) {
1294
+ listener();
1295
+ }
1296
+ };
1297
+ const refresh = async () => {
1298
+ if (closed) {
1299
+ return snapshot.decision;
1300
+ }
1301
+ snapshot = {
1302
+ ...snapshot,
1303
+ error: null,
1304
+ isLoading: true
1305
+ };
1306
+ emit();
1307
+ try {
1308
+ const decision = await fetchVoiceRoutingStatus(path, options);
1309
+ snapshot = {
1310
+ decision,
1311
+ error: null,
1312
+ isLoading: false,
1313
+ updatedAt: Date.now()
1314
+ };
1315
+ emit();
1316
+ return decision;
1317
+ } catch (error) {
1318
+ snapshot = {
1319
+ ...snapshot,
1320
+ error: error instanceof Error ? error.message : String(error),
1321
+ isLoading: false
1322
+ };
1323
+ emit();
1324
+ throw error;
1325
+ }
1326
+ };
1327
+ const close = () => {
1328
+ closed = true;
1329
+ if (timer) {
1330
+ clearInterval(timer);
1331
+ timer = undefined;
1332
+ }
1333
+ listeners.clear();
1334
+ };
1335
+ if (options.intervalMs && options.intervalMs > 0) {
1336
+ timer = setInterval(() => {
1337
+ refresh().catch(() => {});
1338
+ }, options.intervalMs);
1339
+ }
1340
+ return {
1341
+ close,
1342
+ getServerSnapshot: () => snapshot,
1343
+ getSnapshot: () => snapshot,
1344
+ refresh,
1345
+ subscribe: (listener) => {
1346
+ listeners.add(listener);
1347
+ return () => {
1348
+ listeners.delete(listener);
1349
+ };
1350
+ }
1351
+ };
1352
+ };
1353
+
1354
+ // src/client/routingStatusWidget.ts
1355
+ var DEFAULT_TITLE4 = "Voice Routing";
1356
+ var DEFAULT_DESCRIPTION4 = "Latest provider routing decision from the self-hosted trace store.";
1357
+ var escapeHtml5 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1358
+ var formatValue = (value, fallback = "None") => typeof value === "string" && value.trim() ? value : typeof value === "number" && Number.isFinite(value) ? String(value) : fallback;
1359
+ var createVoiceRoutingStatusViewModel = (snapshot, options = {}) => {
1360
+ const decision = snapshot.decision;
1361
+ const rows = decision ? [
1362
+ { label: "Kind", value: decision.kind.toUpperCase() },
1363
+ { label: "Policy", value: formatValue(decision.routing, "Unknown") },
1364
+ { label: "Provider", value: formatValue(decision.provider, "Unknown") },
1365
+ {
1366
+ label: "Selected",
1367
+ value: formatValue(decision.selectedProvider, "Unknown")
1368
+ },
1369
+ {
1370
+ label: "Fallback",
1371
+ value: formatValue(decision.fallbackProvider)
1372
+ },
1373
+ { label: "Status", value: formatValue(decision.status, "unknown") },
1374
+ {
1375
+ label: "Latency budget",
1376
+ value: typeof decision.latencyBudgetMs === "number" ? `${decision.latencyBudgetMs}ms` : "None"
1377
+ }
1378
+ ] : [];
1379
+ return {
1380
+ decision,
1381
+ description: options.description ?? DEFAULT_DESCRIPTION4,
1382
+ error: snapshot.error,
1383
+ isLoading: snapshot.isLoading,
1384
+ label: snapshot.error ? "Unavailable" : decision ? `${formatValue(decision.kind).toUpperCase()} ${formatValue(decision.status, "unknown")}` : snapshot.isLoading ? "Checking" : "No routing yet",
1385
+ rows,
1386
+ status: snapshot.error ? "error" : decision ? "ready" : snapshot.isLoading ? "loading" : "empty",
1387
+ title: options.title ?? DEFAULT_TITLE4,
1388
+ updatedAt: snapshot.updatedAt
1389
+ };
1390
+ };
1391
+ var renderVoiceRoutingStatusHTML = (snapshot, options = {}) => {
1392
+ const model = createVoiceRoutingStatusViewModel(snapshot, options);
1393
+ const rows = model.rows.length ? `<div class="absolute-voice-routing-status__grid">${model.rows.map((row) => `<div>
1394
+ <span>${escapeHtml5(row.label)}</span>
1395
+ <strong>${escapeHtml5(row.value)}</strong>
1396
+ </div>`).join("")}</div>` : '<p class="absolute-voice-routing-status__empty">Start a voice session to see the selected provider.</p>';
1397
+ return `<section class="absolute-voice-routing-status absolute-voice-routing-status--${escapeHtml5(model.status)}">
1398
+ <header class="absolute-voice-routing-status__header">
1399
+ <span class="absolute-voice-routing-status__eyebrow">${escapeHtml5(model.title)}</span>
1400
+ <strong class="absolute-voice-routing-status__label">${escapeHtml5(model.label)}</strong>
1401
+ </header>
1402
+ <p class="absolute-voice-routing-status__description">${escapeHtml5(model.description)}</p>
1403
+ ${rows}
1404
+ ${model.error ? `<p class="absolute-voice-routing-status__error">${escapeHtml5(model.error)}</p>` : ""}
1405
+ </section>`;
1406
+ };
1407
+ var getVoiceRoutingStatusCSS = () => `.absolute-voice-routing-status{border:1px solid #d8d2c4;border-radius:20px;background:#fffaf0;color:#16130d;padding:18px;box-shadow:0 18px 40px rgba(47,37,18,.12);font-family:inherit}.absolute-voice-routing-status--error{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-routing-status__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-routing-status__eyebrow{color:#73664f;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-routing-status__label{font-size:24px;line-height:1}.absolute-voice-routing-status__description{color:#514733;margin:12px 0 0}.absolute-voice-routing-status__grid{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin-top:14px}.absolute-voice-routing-status__grid div{background:#fff;border:1px solid #eee4d2;border-radius:14px;padding:10px 12px}.absolute-voice-routing-status__grid span{color:#655944;display:block;font-size:12px;margin-bottom:4px}.absolute-voice-routing-status__grid strong{overflow-wrap:anywhere}.absolute-voice-routing-status__empty{color:#655944;margin:14px 0 0}.absolute-voice-routing-status__error{color:#9f1239;font-weight:700}`;
1408
+ var mountVoiceRoutingStatus = (element, path = "/api/routing/latest", options = {}) => {
1409
+ const store = createVoiceRoutingStatusStore(path, options);
1410
+ const render = () => {
1411
+ element.innerHTML = renderVoiceRoutingStatusHTML(store.getSnapshot(), options);
1412
+ };
1413
+ const unsubscribe = store.subscribe(render);
1414
+ render();
1415
+ store.refresh().catch(() => {});
1416
+ return {
1417
+ close: () => {
1418
+ unsubscribe();
1419
+ store.close();
1420
+ },
1421
+ refresh: store.refresh
1422
+ };
1423
+ };
1424
+ var defineVoiceRoutingStatusElement = (tagName = "absolute-voice-routing-status") => {
1425
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
1426
+ return;
1427
+ }
1428
+ customElements.define(tagName, class AbsoluteVoiceRoutingStatusElement extends HTMLElement {
1429
+ mounted;
1430
+ connectedCallback() {
1431
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
1432
+ this.mounted = mountVoiceRoutingStatus(this, this.getAttribute("path") ?? "/api/routing/latest", {
1433
+ description: this.getAttribute("description") ?? undefined,
1434
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
1435
+ title: this.getAttribute("title") ?? undefined
1436
+ });
1437
+ }
1438
+ disconnectedCallback() {
1439
+ this.mounted?.close();
1440
+ this.mounted = undefined;
1441
+ }
1442
+ });
1443
+ };
1444
+
1445
+ // src/vue/useVoiceRoutingStatus.ts
1446
+ import { onUnmounted as onUnmounted5, ref as ref4, shallowRef as shallowRef4 } from "vue";
1447
+ function useVoiceRoutingStatus(path = "/api/routing/latest", options = {}) {
1448
+ const store = createVoiceRoutingStatusStore(path, options);
1449
+ const decision = shallowRef4(null);
1450
+ const error = ref4(null);
1451
+ const isLoading = ref4(false);
1452
+ const updatedAt = ref4(undefined);
1453
+ const sync = () => {
1454
+ const snapshot = store.getSnapshot();
1455
+ decision.value = snapshot.decision;
1456
+ error.value = snapshot.error;
1457
+ isLoading.value = snapshot.isLoading;
1458
+ updatedAt.value = snapshot.updatedAt;
1459
+ };
1460
+ const unsubscribe = store.subscribe(sync);
1461
+ sync();
1462
+ store.refresh().catch(() => {});
1463
+ onUnmounted5(() => {
1464
+ unsubscribe();
1465
+ store.close();
1466
+ });
1467
+ return {
1468
+ decision,
1469
+ error,
1470
+ isLoading,
1471
+ refresh: store.refresh,
1472
+ updatedAt
1473
+ };
1474
+ }
1475
+
1476
+ // src/vue/VoiceRoutingStatus.ts
1477
+ var VoiceRoutingStatus = defineComponent5({
1478
+ name: "VoiceRoutingStatus",
1479
+ props: {
1480
+ class: {
1481
+ default: "",
1482
+ type: String
1483
+ },
1484
+ description: {
1485
+ default: undefined,
1486
+ type: String
1487
+ },
1488
+ intervalMs: {
1489
+ default: 5000,
1490
+ type: Number
1491
+ },
1492
+ path: {
1493
+ default: "/api/routing/latest",
1494
+ type: String
1495
+ },
1496
+ title: {
1497
+ default: undefined,
1498
+ type: String
1499
+ }
1500
+ },
1501
+ setup(props) {
1502
+ const options = {
1503
+ description: props.description,
1504
+ intervalMs: props.intervalMs,
1505
+ title: props.title
1506
+ };
1507
+ const status = useVoiceRoutingStatus(props.path, options);
1508
+ const model = computed4(() => createVoiceRoutingStatusViewModel({
1509
+ decision: status.decision.value,
1510
+ error: status.error.value,
1511
+ isLoading: status.isLoading.value,
1512
+ updatedAt: status.updatedAt.value
1513
+ }, options));
1514
+ return () => h5("section", {
1515
+ class: [
1516
+ "absolute-voice-routing-status",
1517
+ `absolute-voice-routing-status--${model.value.status}`,
1518
+ props.class
1519
+ ]
1520
+ }, [
1521
+ h5("header", { class: "absolute-voice-routing-status__header" }, [
1522
+ h5("span", { class: "absolute-voice-routing-status__eyebrow" }, model.value.title),
1523
+ h5("strong", { class: "absolute-voice-routing-status__label" }, model.value.label)
1524
+ ]),
1525
+ h5("p", { class: "absolute-voice-routing-status__description" }, model.value.description),
1526
+ model.value.rows.length ? h5("div", { class: "absolute-voice-routing-status__grid" }, model.value.rows.map((row) => h5("div", { key: row.label }, [
1527
+ h5("span", row.label),
1528
+ h5("strong", row.value)
1529
+ ]))) : h5("p", { class: "absolute-voice-routing-status__empty" }, "Start a voice session to see the selected provider."),
1530
+ model.value.error ? h5("p", { class: "absolute-voice-routing-status__error" }, model.value.error) : null
1531
+ ]);
1532
+ }
1533
+ });
1534
+ // src/vue/VoiceTurnLatency.ts
1535
+ import { computed as computed5, defineComponent as defineComponent6, h as h6 } from "vue";
1536
+
1537
+ // src/client/turnLatency.ts
1538
+ var fetchVoiceTurnLatency = async (path = "/api/turn-latency", options = {}) => {
1539
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1540
+ const response = await fetchImpl(path);
1541
+ if (!response.ok) {
1542
+ throw new Error(`Voice turn latency failed: HTTP ${response.status}`);
1543
+ }
1544
+ return await response.json();
1545
+ };
1546
+ var runVoiceTurnLatencyProof = async (path, options = {}) => {
1547
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1548
+ const response = await fetchImpl(path, { method: "POST" });
1549
+ if (!response.ok) {
1550
+ throw new Error(`Voice turn latency proof failed: HTTP ${response.status}`);
1551
+ }
1552
+ return response.json();
1553
+ };
1554
+ var createVoiceTurnLatencyStore = (path = "/api/turn-latency", options = {}) => {
1555
+ const listeners = new Set;
1556
+ let closed = false;
1557
+ let timer;
1558
+ let snapshot = {
1559
+ error: null,
1560
+ isLoading: false
1561
+ };
1562
+ const emit = () => {
1563
+ for (const listener of listeners) {
1564
+ listener();
1565
+ }
1566
+ };
1567
+ const refresh = async () => {
1568
+ if (closed) {
1569
+ return snapshot.report;
1570
+ }
1571
+ snapshot = { ...snapshot, error: null, isLoading: true };
1572
+ emit();
1573
+ try {
1574
+ const report = await fetchVoiceTurnLatency(path, options);
1575
+ snapshot = {
1576
+ error: null,
1577
+ isLoading: false,
1578
+ report,
1579
+ updatedAt: Date.now()
1580
+ };
1581
+ emit();
1582
+ return report;
1583
+ } catch (error) {
1584
+ snapshot = {
1585
+ ...snapshot,
1586
+ error: error instanceof Error ? error.message : String(error),
1587
+ isLoading: false
1588
+ };
1589
+ emit();
1590
+ throw error;
1591
+ }
1592
+ };
1593
+ const runProof = async () => {
1594
+ if (!options.proofPath) {
1595
+ throw new Error("Voice turn latency proof path is not configured.");
1596
+ }
1597
+ snapshot = { ...snapshot, error: null, isLoading: true };
1598
+ emit();
1599
+ try {
1600
+ await runVoiceTurnLatencyProof(options.proofPath, options);
1601
+ return await refresh();
1602
+ } catch (error) {
1603
+ snapshot = {
1604
+ ...snapshot,
1605
+ error: error instanceof Error ? error.message : String(error),
1606
+ isLoading: false
1607
+ };
1608
+ emit();
1609
+ throw error;
1610
+ }
1611
+ };
1612
+ const close = () => {
1613
+ closed = true;
1614
+ if (timer) {
1615
+ clearInterval(timer);
1616
+ timer = undefined;
1617
+ }
1618
+ listeners.clear();
1619
+ };
1620
+ if (options.intervalMs && options.intervalMs > 0) {
1621
+ timer = setInterval(() => {
1622
+ refresh().catch(() => {});
1623
+ }, options.intervalMs);
1624
+ }
1625
+ return {
1626
+ close,
1627
+ getServerSnapshot: () => snapshot,
1628
+ getSnapshot: () => snapshot,
1629
+ refresh,
1630
+ runProof,
1631
+ subscribe: (listener) => {
1632
+ listeners.add(listener);
1633
+ return () => {
1634
+ listeners.delete(listener);
1635
+ };
1636
+ }
1637
+ };
1638
+ };
1639
+
1640
+ // src/client/turnLatencyWidget.ts
1641
+ var DEFAULT_TITLE5 = "Turn Latency";
1642
+ var DEFAULT_DESCRIPTION5 = "Per-turn timing from first transcript to commit and assistant response start.";
1643
+ var DEFAULT_PROOF_LABEL = "Run latency proof";
1644
+ var escapeHtml6 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1645
+ var formatMs = (value) => typeof value === "number" ? `${Math.round(value)}ms` : "n/a";
1646
+ var createVoiceTurnLatencyViewModel = (snapshot, options = {}) => {
1647
+ const turns = (snapshot.report?.turns ?? []).map((turn) => ({
1648
+ ...turn,
1649
+ label: turn.text || "Empty turn",
1650
+ rows: turn.stages.map((stage) => ({
1651
+ label: stage.label,
1652
+ value: formatMs(stage.valueMs)
1653
+ }))
1654
+ }));
1655
+ const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
1656
+ const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
1657
+ return {
1658
+ description: options.description ?? DEFAULT_DESCRIPTION5,
1659
+ error: snapshot.error,
1660
+ isLoading: snapshot.isLoading,
1661
+ label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} slow` : warningCount > 0 ? `${warningCount} warnings` : `avg ${formatMs(snapshot.report?.averageTotalMs)}` : snapshot.isLoading ? "Checking" : "No turns",
1662
+ proofLabel: options.proofPath ? options.proofLabel ?? DEFAULT_PROOF_LABEL : undefined,
1663
+ showProofAction: Boolean(options.proofPath),
1664
+ status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
1665
+ title: options.title ?? DEFAULT_TITLE5,
1666
+ turns,
1667
+ updatedAt: snapshot.updatedAt
1668
+ };
1669
+ };
1670
+ var renderVoiceTurnLatencyHTML = (snapshot, options = {}) => {
1671
+ const model = createVoiceTurnLatencyViewModel(snapshot, options);
1672
+ const turns = model.turns.length ? `<div class="absolute-voice-turn-latency__turns">${model.turns.map((turn) => `<article class="absolute-voice-turn-latency__turn absolute-voice-turn-latency__turn--${escapeHtml6(turn.status)}">
1673
+ <header>
1674
+ <strong>${escapeHtml6(turn.label)}</strong>
1675
+ <span>${escapeHtml6(turn.status)}</span>
1676
+ </header>
1677
+ <dl>${turn.rows.map((row) => `<div>
1678
+ <dt>${escapeHtml6(row.label)}</dt>
1679
+ <dd>${escapeHtml6(row.value)}</dd>
1680
+ </div>`).join("")}</dl>
1681
+ </article>`).join("")}</div>` : '<p class="absolute-voice-turn-latency__empty">Complete a voice turn to see latency diagnostics.</p>';
1682
+ return `<section class="absolute-voice-turn-latency absolute-voice-turn-latency--${escapeHtml6(model.status)}">
1683
+ <header class="absolute-voice-turn-latency__header">
1684
+ <span class="absolute-voice-turn-latency__eyebrow">${escapeHtml6(model.title)}</span>
1685
+ <strong class="absolute-voice-turn-latency__label">${escapeHtml6(model.label)}</strong>
1686
+ </header>
1687
+ <p class="absolute-voice-turn-latency__description">${escapeHtml6(model.description)}</p>
1688
+ ${model.showProofAction ? `<button class="absolute-voice-turn-latency__proof" data-absolute-voice-turn-latency-proof type="button">${escapeHtml6(model.proofLabel ?? DEFAULT_PROOF_LABEL)}</button>` : ""}
1689
+ ${turns}
1690
+ ${model.error ? `<p class="absolute-voice-turn-latency__error">${escapeHtml6(model.error)}</p>` : ""}
1691
+ </section>`;
1692
+ };
1693
+ var mountVoiceTurnLatency = (element, path = "/api/turn-latency", options = {}) => {
1694
+ const store = createVoiceTurnLatencyStore(path, options);
1695
+ const render = () => {
1696
+ element.innerHTML = renderVoiceTurnLatencyHTML(store.getSnapshot(), options);
1697
+ };
1698
+ const handleClick = (event) => {
1699
+ const target = event.target;
1700
+ if (target instanceof Element && target.closest("[data-absolute-voice-turn-latency-proof]")) {
1701
+ store.runProof().catch(() => {});
1702
+ }
1703
+ };
1704
+ const unsubscribe = store.subscribe(render);
1705
+ element.addEventListener("click", handleClick);
1706
+ render();
1707
+ store.refresh().catch(() => {});
1708
+ return {
1709
+ close: () => {
1710
+ element.removeEventListener("click", handleClick);
1711
+ unsubscribe();
1712
+ store.close();
1713
+ },
1714
+ refresh: store.refresh
1715
+ };
1716
+ };
1717
+ var defineVoiceTurnLatencyElement = (tagName = "absolute-voice-turn-latency") => {
1718
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
1719
+ return;
1720
+ }
1721
+ customElements.define(tagName, class AbsoluteVoiceTurnLatencyElement extends HTMLElement {
1722
+ mounted;
1723
+ connectedCallback() {
1724
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
1725
+ this.mounted = mountVoiceTurnLatency(this, this.getAttribute("path") ?? "/api/turn-latency", {
1726
+ description: this.getAttribute("description") ?? undefined,
1727
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
1728
+ proofLabel: this.getAttribute("proof-label") ?? undefined,
1729
+ proofPath: this.getAttribute("proof-path") ?? undefined,
1730
+ title: this.getAttribute("title") ?? undefined
1731
+ });
1732
+ }
1733
+ disconnectedCallback() {
1734
+ this.mounted?.close();
1735
+ this.mounted = undefined;
1736
+ }
1737
+ });
1738
+ };
1739
+
1740
+ // src/vue/useVoiceTurnLatency.ts
1741
+ import { onUnmounted as onUnmounted6, shallowRef as shallowRef5 } from "vue";
1742
+ function useVoiceTurnLatency(path = "/api/turn-latency", options = {}) {
1743
+ const store = createVoiceTurnLatencyStore(path, options);
1744
+ const error = shallowRef5(null);
1745
+ const isLoading = shallowRef5(false);
1746
+ const report = shallowRef5();
1747
+ const updatedAt = shallowRef5(undefined);
1748
+ const sync = () => {
1749
+ const snapshot = store.getSnapshot();
1750
+ error.value = snapshot.error;
1751
+ isLoading.value = snapshot.isLoading;
1752
+ report.value = snapshot.report;
1753
+ updatedAt.value = snapshot.updatedAt;
1754
+ };
1755
+ const unsubscribe = store.subscribe(sync);
1756
+ sync();
1757
+ store.refresh().catch(() => {});
1758
+ onUnmounted6(() => {
1759
+ unsubscribe();
1760
+ store.close();
1761
+ });
1762
+ return {
1763
+ error,
1764
+ isLoading,
1765
+ refresh: store.refresh,
1766
+ report,
1767
+ runProof: store.runProof,
1768
+ updatedAt
1769
+ };
1770
+ }
1771
+
1772
+ // src/vue/VoiceTurnLatency.ts
1773
+ var VoiceTurnLatency = defineComponent6({
1774
+ name: "VoiceTurnLatency",
1775
+ props: {
1776
+ class: { default: "", type: String },
1777
+ description: { default: undefined, type: String },
1778
+ intervalMs: { default: 5000, type: Number },
1779
+ path: { default: "/api/turn-latency", type: String },
1780
+ proofLabel: { default: undefined, type: String },
1781
+ proofPath: { default: undefined, type: String },
1782
+ title: { default: undefined, type: String }
1783
+ },
1784
+ setup(props) {
1785
+ const options = {
1786
+ description: props.description,
1787
+ intervalMs: props.intervalMs,
1788
+ proofLabel: props.proofLabel,
1789
+ proofPath: props.proofPath,
1790
+ title: props.title
1791
+ };
1792
+ const latency = useVoiceTurnLatency(props.path, options);
1793
+ const model = computed5(() => createVoiceTurnLatencyViewModel({
1794
+ error: latency.error.value,
1795
+ isLoading: latency.isLoading.value,
1796
+ report: latency.report.value,
1797
+ updatedAt: latency.updatedAt.value
1798
+ }, options));
1799
+ return () => h6("section", {
1800
+ class: [
1801
+ "absolute-voice-turn-latency",
1802
+ `absolute-voice-turn-latency--${model.value.status}`,
1803
+ props.class
1804
+ ]
1805
+ }, [
1806
+ h6("header", { class: "absolute-voice-turn-latency__header" }, [
1807
+ h6("span", { class: "absolute-voice-turn-latency__eyebrow" }, model.value.title),
1808
+ h6("strong", { class: "absolute-voice-turn-latency__label" }, model.value.label)
1809
+ ]),
1810
+ h6("p", { class: "absolute-voice-turn-latency__description" }, model.value.description),
1811
+ model.value.showProofAction ? h6("button", {
1812
+ class: "absolute-voice-turn-latency__proof",
1813
+ onClick: () => {
1814
+ latency.runProof().catch(() => {});
1815
+ },
1816
+ type: "button"
1817
+ }, model.value.proofLabel) : null,
1818
+ model.value.turns.length ? h6("div", { class: "absolute-voice-turn-latency__turns" }, model.value.turns.map((turn) => h6("article", {
1819
+ class: [
1820
+ "absolute-voice-turn-latency__turn",
1821
+ `absolute-voice-turn-latency__turn--${turn.status}`
1822
+ ],
1823
+ key: `${turn.sessionId}:${turn.turnId}`
1824
+ }, [
1825
+ h6("header", [
1826
+ h6("strong", turn.label),
1827
+ h6("span", turn.status)
1828
+ ]),
1829
+ h6("dl", turn.rows.map((row) => h6("div", { key: row.label }, [
1830
+ h6("dt", row.label),
1831
+ h6("dd", row.value)
1832
+ ])))
1833
+ ]))) : h6("p", { class: "absolute-voice-turn-latency__empty" }, "Complete a voice turn to see latency diagnostics."),
1834
+ model.value.error ? h6("p", { class: "absolute-voice-turn-latency__error" }, model.value.error) : null
1835
+ ]);
1836
+ }
1837
+ });
1838
+ // src/vue/VoiceTurnQuality.ts
1839
+ import { computed as computed6, defineComponent as defineComponent7, h as h7 } from "vue";
1840
+
1841
+ // src/client/turnQuality.ts
1842
+ var fetchVoiceTurnQuality = async (path = "/api/turn-quality", options = {}) => {
1843
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1844
+ const response = await fetchImpl(path);
1845
+ if (!response.ok) {
1846
+ throw new Error(`Voice turn quality failed: HTTP ${response.status}`);
1847
+ }
1848
+ return await response.json();
1849
+ };
1850
+ var createVoiceTurnQualityStore = (path = "/api/turn-quality", options = {}) => {
1851
+ const listeners = new Set;
1852
+ let closed = false;
1853
+ let timer;
1854
+ let snapshot = {
1855
+ error: null,
1856
+ isLoading: false
1857
+ };
1858
+ const emit = () => {
1859
+ for (const listener of listeners) {
1860
+ listener();
1861
+ }
1862
+ };
1863
+ const refresh = async () => {
1864
+ if (closed) {
1865
+ return snapshot.report;
1866
+ }
1867
+ snapshot = {
1868
+ ...snapshot,
1869
+ error: null,
1870
+ isLoading: true
1871
+ };
1872
+ emit();
1873
+ try {
1874
+ const report = await fetchVoiceTurnQuality(path, options);
1875
+ snapshot = {
1876
+ error: null,
1877
+ isLoading: false,
1878
+ report,
1879
+ updatedAt: Date.now()
1880
+ };
1881
+ emit();
1882
+ return report;
1883
+ } catch (error) {
1884
+ snapshot = {
1885
+ ...snapshot,
1886
+ error: error instanceof Error ? error.message : String(error),
1887
+ isLoading: false
1888
+ };
1889
+ emit();
1890
+ throw error;
1891
+ }
1892
+ };
1893
+ const close = () => {
1894
+ closed = true;
1895
+ if (timer) {
1896
+ clearInterval(timer);
1897
+ timer = undefined;
1898
+ }
1899
+ listeners.clear();
1900
+ };
1901
+ if (options.intervalMs && options.intervalMs > 0) {
1902
+ timer = setInterval(() => {
1903
+ refresh().catch(() => {});
1904
+ }, options.intervalMs);
1905
+ }
1906
+ return {
1907
+ close,
1908
+ getServerSnapshot: () => snapshot,
1909
+ getSnapshot: () => snapshot,
1910
+ refresh,
1911
+ subscribe: (listener) => {
1912
+ listeners.add(listener);
1913
+ return () => {
1914
+ listeners.delete(listener);
1915
+ };
1916
+ }
1917
+ };
1918
+ };
1919
+
1920
+ // src/client/turnQualityWidget.ts
1921
+ var DEFAULT_TITLE6 = "Turn Quality";
1922
+ var DEFAULT_DESCRIPTION6 = "Per-turn STT confidence, fallback selection, corrections, and transcript coverage.";
1923
+ var escapeHtml7 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1924
+ var formatConfidence = (value) => typeof value === "number" ? `${Math.round(value * 100)}%` : "n/a";
1925
+ var formatMaybe = (value) => value === undefined || value === "" ? "n/a" : String(value);
1926
+ var getTurnDetail = (turn) => {
1927
+ if (turn.status === "fail") {
1928
+ return "Empty or unusable committed turn; inspect transcripts and adapter events.";
1929
+ }
1930
+ if (turn.fallbackUsed) {
1931
+ return `Fallback STT selected${turn.fallbackSelectionReason ? ` by ${turn.fallbackSelectionReason}` : ""}.`;
1932
+ }
1933
+ if (turn.correctionChanged) {
1934
+ return `Correction changed the turn${turn.correctionProvider ? ` via ${turn.correctionProvider}` : ""}.`;
1935
+ }
1936
+ if (turn.status === "warn") {
1937
+ return "Turn completed with quality warnings.";
1938
+ }
1939
+ if (turn.status === "unknown") {
1940
+ return "No quality diagnostics were recorded for this turn.";
1941
+ }
1942
+ return "Turn quality looks healthy.";
1943
+ };
1944
+ var createVoiceTurnQualityViewModel = (snapshot, options = {}) => {
1945
+ const turns = (snapshot.report?.turns ?? []).map((turn) => ({
1946
+ ...turn,
1947
+ detail: getTurnDetail(turn),
1948
+ label: turn.text || "Empty turn",
1949
+ rows: [
1950
+ { label: "Source", value: turn.source ?? "unknown" },
1951
+ { label: "Confidence", value: formatConfidence(turn.averageConfidence) },
1952
+ { label: "Fallback", value: turn.fallbackUsed ? "Yes" : "No" },
1953
+ { label: "Correction", value: turn.correctionChanged ? "Changed" : "None" },
1954
+ { label: "Transcripts", value: `${turn.selectedTranscriptCount} selected` },
1955
+ { label: "Cost", value: formatMaybe(turn.costUnits) }
1956
+ ]
1957
+ }));
1958
+ const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
1959
+ const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
1960
+ return {
1961
+ description: options.description ?? DEFAULT_DESCRIPTION6,
1962
+ error: snapshot.error,
1963
+ isLoading: snapshot.isLoading,
1964
+ label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} failed` : warningCount > 0 ? `${warningCount} warnings` : `${turns.length} healthy` : snapshot.isLoading ? "Checking" : "No turns",
1965
+ status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
1966
+ title: options.title ?? DEFAULT_TITLE6,
1967
+ turns,
1968
+ updatedAt: snapshot.updatedAt
1969
+ };
1970
+ };
1971
+ var renderVoiceTurnQualityHTML = (snapshot, options = {}) => {
1972
+ const model = createVoiceTurnQualityViewModel(snapshot, options);
1973
+ const turns = model.turns.length ? `<div class="absolute-voice-turn-quality__turns">${model.turns.map((turn) => `<article class="absolute-voice-turn-quality__turn absolute-voice-turn-quality__turn--${escapeHtml7(turn.status)}">
1974
+ <header>
1975
+ <strong>${escapeHtml7(turn.label)}</strong>
1976
+ <span>${escapeHtml7(turn.status)}</span>
1977
+ </header>
1978
+ <p>${escapeHtml7(turn.detail)}</p>
1979
+ <dl>${turn.rows.map((row) => `<div>
1980
+ <dt>${escapeHtml7(row.label)}</dt>
1981
+ <dd>${escapeHtml7(row.value)}</dd>
1982
+ </div>`).join("")}</dl>
1983
+ </article>`).join("")}</div>` : '<p class="absolute-voice-turn-quality__empty">Complete a voice turn to see STT quality diagnostics.</p>';
1984
+ return `<section class="absolute-voice-turn-quality absolute-voice-turn-quality--${escapeHtml7(model.status)}">
1985
+ <header class="absolute-voice-turn-quality__header">
1986
+ <span class="absolute-voice-turn-quality__eyebrow">${escapeHtml7(model.title)}</span>
1987
+ <strong class="absolute-voice-turn-quality__label">${escapeHtml7(model.label)}</strong>
1988
+ </header>
1989
+ <p class="absolute-voice-turn-quality__description">${escapeHtml7(model.description)}</p>
1990
+ ${turns}
1991
+ ${model.error ? `<p class="absolute-voice-turn-quality__error">${escapeHtml7(model.error)}</p>` : ""}
1992
+ </section>`;
1993
+ };
1994
+ var getVoiceTurnQualityCSS = () => `.absolute-voice-turn-quality{border:1px solid #e4d1a3;border-radius:20px;background:#fff9eb;color:#17120a;padding:18px;box-shadow:0 18px 40px rgba(73,48,14,.12);font-family:inherit}.absolute-voice-turn-quality--error,.absolute-voice-turn-quality--warning{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-turn-quality__header,.absolute-voice-turn-quality__turn header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-turn-quality__eyebrow{color:#8a5a0a;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-turn-quality__label{font-size:24px;line-height:1}.absolute-voice-turn-quality__description,.absolute-voice-turn-quality__turn p,.absolute-voice-turn-quality__turn dt,.absolute-voice-turn-quality__empty{color:#5a4930}.absolute-voice-turn-quality__turns{display:grid;gap:12px;margin-top:14px}.absolute-voice-turn-quality__turn{background:#fff;border:1px solid #f0dfba;border-radius:16px;padding:14px}.absolute-voice-turn-quality__turn--pass{border-color:#86efac}.absolute-voice-turn-quality__turn--warn,.absolute-voice-turn-quality__turn--unknown{border-color:#fbbf24}.absolute-voice-turn-quality__turn--fail{border-color:#f2a7a7}.absolute-voice-turn-quality__turn p{margin:10px 0}.absolute-voice-turn-quality__turn dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-turn-quality__turn div{background:#fff9eb;border:1px solid #f0dfba;border-radius:12px;padding:8px}.absolute-voice-turn-quality__turn dt{font-size:12px}.absolute-voice-turn-quality__turn dd{font-weight:800;margin:4px 0 0}.absolute-voice-turn-quality__empty{margin:14px 0 0}.absolute-voice-turn-quality__error{color:#9f1239;font-weight:700}`;
1995
+ var mountVoiceTurnQuality = (element, path = "/api/turn-quality", options = {}) => {
1996
+ const store = createVoiceTurnQualityStore(path, options);
1997
+ const render = () => {
1998
+ element.innerHTML = renderVoiceTurnQualityHTML(store.getSnapshot(), options);
1999
+ };
2000
+ const unsubscribe = store.subscribe(render);
2001
+ render();
2002
+ store.refresh().catch(() => {});
2003
+ return {
2004
+ close: () => {
2005
+ unsubscribe();
2006
+ store.close();
2007
+ },
2008
+ refresh: store.refresh
2009
+ };
2010
+ };
2011
+ var defineVoiceTurnQualityElement = (tagName = "absolute-voice-turn-quality") => {
2012
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
2013
+ return;
2014
+ }
2015
+ customElements.define(tagName, class AbsoluteVoiceTurnQualityElement extends HTMLElement {
2016
+ mounted;
2017
+ connectedCallback() {
2018
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
2019
+ this.mounted = mountVoiceTurnQuality(this, this.getAttribute("path") ?? "/api/turn-quality", {
2020
+ description: this.getAttribute("description") ?? undefined,
2021
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
2022
+ title: this.getAttribute("title") ?? undefined
2023
+ });
2024
+ }
2025
+ disconnectedCallback() {
2026
+ this.mounted?.close();
2027
+ this.mounted = undefined;
2028
+ }
2029
+ });
2030
+ };
2031
+
2032
+ // src/vue/useVoiceTurnQuality.ts
2033
+ import { onUnmounted as onUnmounted7, shallowRef as shallowRef6 } from "vue";
2034
+ function useVoiceTurnQuality(path = "/api/turn-quality", options = {}) {
2035
+ const store = createVoiceTurnQualityStore(path, options);
2036
+ const error = shallowRef6(null);
2037
+ const isLoading = shallowRef6(false);
2038
+ const report = shallowRef6();
2039
+ const updatedAt = shallowRef6(undefined);
2040
+ const sync = () => {
2041
+ const snapshot = store.getSnapshot();
2042
+ error.value = snapshot.error;
2043
+ isLoading.value = snapshot.isLoading;
2044
+ report.value = snapshot.report;
2045
+ updatedAt.value = snapshot.updatedAt;
2046
+ };
2047
+ const unsubscribe = store.subscribe(sync);
2048
+ sync();
2049
+ store.refresh().catch(() => {});
2050
+ onUnmounted7(() => {
2051
+ unsubscribe();
2052
+ store.close();
2053
+ });
2054
+ return { error, isLoading, refresh: store.refresh, report, updatedAt };
2055
+ }
2056
+
2057
+ // src/vue/VoiceTurnQuality.ts
2058
+ var VoiceTurnQuality = defineComponent7({
2059
+ name: "VoiceTurnQuality",
2060
+ props: {
2061
+ class: { default: "", type: String },
2062
+ description: { default: undefined, type: String },
2063
+ intervalMs: { default: 5000, type: Number },
2064
+ path: { default: "/api/turn-quality", type: String },
2065
+ title: { default: undefined, type: String }
2066
+ },
2067
+ setup(props) {
2068
+ const options = {
2069
+ description: props.description,
2070
+ intervalMs: props.intervalMs,
2071
+ title: props.title
2072
+ };
2073
+ const quality = useVoiceTurnQuality(props.path, options);
2074
+ const model = computed6(() => createVoiceTurnQualityViewModel({
2075
+ error: quality.error.value,
2076
+ isLoading: quality.isLoading.value,
2077
+ report: quality.report.value,
2078
+ updatedAt: quality.updatedAt.value
2079
+ }, options));
2080
+ return () => h7("section", {
2081
+ class: [
2082
+ "absolute-voice-turn-quality",
2083
+ `absolute-voice-turn-quality--${model.value.status}`,
2084
+ props.class
2085
+ ]
2086
+ }, [
2087
+ h7("header", { class: "absolute-voice-turn-quality__header" }, [
2088
+ h7("span", { class: "absolute-voice-turn-quality__eyebrow" }, model.value.title),
2089
+ h7("strong", { class: "absolute-voice-turn-quality__label" }, model.value.label)
2090
+ ]),
2091
+ h7("p", { class: "absolute-voice-turn-quality__description" }, model.value.description),
2092
+ model.value.turns.length ? h7("div", { class: "absolute-voice-turn-quality__turns" }, model.value.turns.map((turn) => h7("article", {
2093
+ class: [
2094
+ "absolute-voice-turn-quality__turn",
2095
+ `absolute-voice-turn-quality__turn--${turn.status}`
2096
+ ],
2097
+ key: `${turn.sessionId}:${turn.turnId}`
2098
+ }, [
2099
+ h7("header", [
2100
+ h7("strong", turn.label),
2101
+ h7("span", turn.status)
2102
+ ]),
2103
+ h7("p", turn.detail),
2104
+ h7("dl", turn.rows.map((row) => h7("div", { key: row.label }, [
2105
+ h7("dt", row.label),
2106
+ h7("dd", row.value)
2107
+ ])))
2108
+ ]))) : h7("p", { class: "absolute-voice-turn-quality__empty" }, "Complete a voice turn to see STT quality diagnostics."),
2109
+ model.value.error ? h7("p", { class: "absolute-voice-turn-quality__error" }, model.value.error) : null
2110
+ ]);
2111
+ }
2112
+ });
2113
+ // src/vue/useVoiceCampaignDialerProof.ts
2114
+ import { onUnmounted as onUnmounted8, shallowRef as shallowRef7 } from "vue";
2115
+
2116
+ // src/client/campaignDialerProof.ts
2117
+ var fetchVoiceCampaignDialerProofStatus = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
2118
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2119
+ const response = await fetchImpl(path);
2120
+ if (!response.ok) {
2121
+ throw new Error(`Voice campaign dialer proof status failed: HTTP ${response.status}`);
2122
+ }
2123
+ return await response.json();
2124
+ };
2125
+ var runVoiceCampaignDialerProofAction = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
2126
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2127
+ const response = await fetchImpl(path, { method: "POST" });
2128
+ if (!response.ok) {
2129
+ throw new Error(`Voice campaign dialer proof failed: HTTP ${response.status}`);
2130
+ }
2131
+ return await response.json();
2132
+ };
2133
+ var createVoiceCampaignDialerProofStore = (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
2134
+ const listeners = new Set;
2135
+ let closed = false;
2136
+ let timer;
2137
+ let snapshot = {
2138
+ error: null,
2139
+ isLoading: false
2140
+ };
2141
+ const emit = () => {
2142
+ for (const listener of listeners) {
2143
+ listener();
2144
+ }
2145
+ };
2146
+ const refresh = async () => {
2147
+ if (closed) {
2148
+ return snapshot.status;
2149
+ }
2150
+ snapshot = { ...snapshot, error: null, isLoading: true };
2151
+ emit();
2152
+ try {
2153
+ const status = await fetchVoiceCampaignDialerProofStatus(path, options);
2154
+ snapshot = {
2155
+ ...snapshot,
2156
+ error: null,
2157
+ isLoading: false,
2158
+ status,
2159
+ updatedAt: Date.now()
2160
+ };
2161
+ emit();
2162
+ return status;
2163
+ } catch (error) {
2164
+ snapshot = {
2165
+ ...snapshot,
2166
+ error: error instanceof Error ? error.message : String(error),
2167
+ isLoading: false
2168
+ };
2169
+ emit();
2170
+ throw error;
2171
+ }
2172
+ };
2173
+ const runProof = async () => {
2174
+ const runPath = options.runPath ?? snapshot.status?.runPath ?? path;
2175
+ snapshot = { ...snapshot, error: null, isLoading: true };
2176
+ emit();
2177
+ try {
2178
+ const report = await runVoiceCampaignDialerProofAction(runPath, options);
2179
+ snapshot = {
2180
+ ...snapshot,
2181
+ error: null,
2182
+ isLoading: false,
2183
+ report,
2184
+ status: {
2185
+ generatedAt: Date.now(),
2186
+ mode: report.mode,
2187
+ ok: report.ok,
2188
+ providers: report.providers.map((provider) => provider.provider),
2189
+ runPath,
2190
+ safe: true
2191
+ },
2192
+ updatedAt: Date.now()
2193
+ };
2194
+ emit();
2195
+ return report;
2196
+ } catch (error) {
2197
+ snapshot = {
2198
+ ...snapshot,
2199
+ error: error instanceof Error ? error.message : String(error),
2200
+ isLoading: false
2201
+ };
2202
+ emit();
2203
+ throw error;
2204
+ }
2205
+ };
2206
+ const close = () => {
2207
+ closed = true;
2208
+ if (timer) {
2209
+ clearInterval(timer);
2210
+ timer = undefined;
2211
+ }
2212
+ listeners.clear();
2213
+ };
2214
+ if (options.intervalMs && options.intervalMs > 0) {
2215
+ timer = setInterval(() => {
2216
+ refresh().catch(() => {});
2217
+ }, options.intervalMs);
2218
+ }
2219
+ return {
2220
+ close,
2221
+ getServerSnapshot: () => snapshot,
2222
+ getSnapshot: () => snapshot,
2223
+ refresh,
2224
+ runProof,
2225
+ subscribe: (listener) => {
2226
+ listeners.add(listener);
2227
+ return () => {
2228
+ listeners.delete(listener);
2229
+ };
2230
+ }
2231
+ };
2232
+ };
2233
+
2234
+ // src/vue/useVoiceCampaignDialerProof.ts
2235
+ function useVoiceCampaignDialerProof(path = "/api/voice/campaigns/dialer-proof", options = {}) {
2236
+ const store = createVoiceCampaignDialerProofStore(path, options);
2237
+ const error = shallowRef7(null);
2238
+ const isLoading = shallowRef7(false);
2239
+ const report = shallowRef7();
2240
+ const status = shallowRef7();
2241
+ const updatedAt = shallowRef7(undefined);
2242
+ const sync = () => {
2243
+ const snapshot = store.getSnapshot();
2244
+ error.value = snapshot.error;
2245
+ isLoading.value = snapshot.isLoading;
2246
+ report.value = snapshot.report;
2247
+ status.value = snapshot.status;
2248
+ updatedAt.value = snapshot.updatedAt;
2249
+ };
2250
+ const unsubscribe = store.subscribe(sync);
2251
+ sync();
2252
+ if (typeof window !== "undefined") {
2253
+ store.refresh().catch(() => {});
2254
+ }
2255
+ onUnmounted8(() => {
2256
+ unsubscribe();
2257
+ store.close();
2258
+ });
2259
+ return {
2260
+ error,
2261
+ isLoading,
2262
+ refresh: store.refresh,
2263
+ report,
2264
+ runProof: store.runProof,
2265
+ status,
2266
+ updatedAt
2267
+ };
2268
+ }
72
2269
  // src/vue/useVoiceStream.ts
73
- import { onUnmounted, ref, shallowRef } from "vue";
2270
+ import { onUnmounted as onUnmounted9, ref as ref5, shallowRef as shallowRef8 } from "vue";
74
2271
 
75
2272
  // src/client/actions.ts
76
2273
  var normalizeErrorMessage = (value) => {
@@ -120,6 +2317,12 @@ var serverMessageToAction = (message) => {
120
2317
  sessionId: message.sessionId,
121
2318
  type: "complete"
122
2319
  };
2320
+ case "call_lifecycle":
2321
+ return {
2322
+ event: message.event,
2323
+ sessionId: message.sessionId,
2324
+ type: "call_lifecycle"
2325
+ };
123
2326
  case "error":
124
2327
  return {
125
2328
  message: normalizeErrorMessage(message.message),
@@ -163,7 +2366,7 @@ var DEFAULT_SCENARIO_QUERY_PARAM = "scenarioId";
163
2366
  var noop = () => {};
164
2367
  var noopUnsubscribe = () => noop;
165
2368
  var NOOP_CONNECTION = {
166
- start: () => {},
2369
+ callControl: noop,
167
2370
  close: noop,
168
2371
  endTurn: noop,
169
2372
  getReadyState: () => WS_CLOSED,
@@ -171,6 +2374,7 @@ var NOOP_CONNECTION = {
171
2374
  getSessionId: () => "",
172
2375
  send: noop,
173
2376
  sendAudio: noop,
2377
+ start: () => {},
174
2378
  subscribe: noopUnsubscribe
175
2379
  };
176
2380
  var createSessionId = () => crypto.randomUUID();
@@ -192,6 +2396,7 @@ var isVoiceServerMessage = (value) => {
192
2396
  switch (value.type) {
193
2397
  case "audio":
194
2398
  case "assistant":
2399
+ case "call_lifecycle":
195
2400
  case "complete":
196
2401
  case "error":
197
2402
  case "final":
@@ -332,6 +2537,12 @@ var createVoiceConnection = (path, options = {}) => {
332
2537
  const endTurn = () => {
333
2538
  send({ type: "end_turn" });
334
2539
  };
2540
+ const callControl = (message) => {
2541
+ send({
2542
+ ...message,
2543
+ type: "call_control"
2544
+ });
2545
+ };
335
2546
  const close = () => {
336
2547
  clearTimers();
337
2548
  if (state.ws) {
@@ -349,7 +2560,7 @@ var createVoiceConnection = (path, options = {}) => {
349
2560
  };
350
2561
  connect();
351
2562
  return {
352
- start,
2563
+ callControl,
353
2564
  close,
354
2565
  endTurn,
355
2566
  getReadyState: () => state.ws?.readyState ?? WS_CLOSED,
@@ -357,6 +2568,7 @@ var createVoiceConnection = (path, options = {}) => {
357
2568
  getSessionId: () => state.sessionId,
358
2569
  send,
359
2570
  sendAudio,
2571
+ start,
360
2572
  subscribe
361
2573
  };
362
2574
  };
@@ -365,6 +2577,7 @@ var createVoiceConnection = (path, options = {}) => {
365
2577
  var createInitialState = () => ({
366
2578
  assistantAudio: [],
367
2579
  assistantTexts: [],
2580
+ call: null,
368
2581
  error: null,
369
2582
  isConnected: false,
370
2583
  scenarioId: null,
@@ -408,6 +2621,20 @@ var createVoiceStreamStore = () => {
408
2621
  status: "completed"
409
2622
  };
410
2623
  break;
2624
+ case "call_lifecycle":
2625
+ state = {
2626
+ ...state,
2627
+ call: {
2628
+ ...state.call,
2629
+ disposition: action.event.type === "end" ? action.event.disposition : state.call?.disposition,
2630
+ endedAt: action.event.type === "end" ? action.event.at : state.call?.endedAt,
2631
+ events: [...state.call?.events ?? [], action.event],
2632
+ lastEventAt: action.event.at,
2633
+ startedAt: state.call?.startedAt ?? action.event.at
2634
+ },
2635
+ sessionId: action.sessionId
2636
+ };
2637
+ break;
411
2638
  case "connected":
412
2639
  state = {
413
2640
  ...state,
@@ -494,6 +2721,9 @@ var createVoiceStream = (path, options = {}) => {
494
2721
  }
495
2722
  });
496
2723
  return {
2724
+ callControl(message) {
2725
+ connection.callControl(message);
2726
+ },
497
2727
  close() {
498
2728
  unsubscribeConnection();
499
2729
  connection.close();
@@ -537,6 +2767,9 @@ var createVoiceStream = (path, options = {}) => {
537
2767
  get assistantAudio() {
538
2768
  return store.getSnapshot().assistantAudio;
539
2769
  },
2770
+ get call() {
2771
+ return store.getSnapshot().call;
2772
+ },
540
2773
  sendAudio(audio) {
541
2774
  connection.sendAudio(audio);
542
2775
  },
@@ -550,19 +2783,21 @@ var createVoiceStream = (path, options = {}) => {
550
2783
  };
551
2784
 
552
2785
  // src/vue/useVoiceStream.ts
553
- var useVoiceStream = (path, options = {}) => {
2786
+ function useVoiceStream(path, options = {}) {
554
2787
  const stream = createVoiceStream(path, options);
555
- const assistantAudio = shallowRef([]);
556
- const assistantTexts = shallowRef([]);
557
- const error = ref(null);
558
- const isConnected = ref(false);
559
- const partial = ref("");
560
- const sessionId = ref(stream.sessionId);
561
- const status = ref(stream.status);
562
- const turns = shallowRef([]);
2788
+ const assistantAudio = shallowRef8([]);
2789
+ const assistantTexts = shallowRef8([]);
2790
+ const call = shallowRef8(null);
2791
+ const error = ref5(null);
2792
+ const isConnected = ref5(false);
2793
+ const partial = ref5("");
2794
+ const sessionId = ref5(stream.sessionId);
2795
+ const status = ref5(stream.status);
2796
+ const turns = shallowRef8([]);
563
2797
  const sync = () => {
564
2798
  assistantAudio.value = [...stream.assistantAudio];
565
2799
  assistantTexts.value = [...stream.assistantTexts];
2800
+ call.value = stream.call;
566
2801
  error.value = stream.error;
567
2802
  isConnected.value = stream.isConnected;
568
2803
  partial.value = stream.partial;
@@ -576,10 +2811,12 @@ var useVoiceStream = (path, options = {}) => {
576
2811
  unsubscribe();
577
2812
  stream.close();
578
2813
  };
579
- onUnmounted(destroy);
2814
+ onUnmounted9(destroy);
580
2815
  return {
581
2816
  assistantAudio,
582
2817
  assistantTexts,
2818
+ call,
2819
+ callControl: (message) => stream.callControl(message),
583
2820
  close: () => destroy(),
584
2821
  endTurn: () => stream.endTurn(),
585
2822
  error,
@@ -590,9 +2827,9 @@ var useVoiceStream = (path, options = {}) => {
590
2827
  status,
591
2828
  turns
592
2829
  };
593
- };
2830
+ }
594
2831
  // src/vue/useVoiceController.ts
595
- import { onUnmounted as onUnmounted2, ref as ref2, shallowRef as shallowRef2 } from "vue";
2832
+ import { onUnmounted as onUnmounted10, ref as ref6, shallowRef as shallowRef9 } from "vue";
596
2833
 
597
2834
  // src/client/htmx.ts
598
2835
  var DEFAULT_EVENT_NAME = "voice-refresh";
@@ -1056,6 +3293,7 @@ var resolveVoiceRuntimePreset = (name = "default") => {
1056
3293
  var createInitialState2 = (stream) => ({
1057
3294
  assistantAudio: [...stream.assistantAudio],
1058
3295
  assistantTexts: [...stream.assistantTexts],
3296
+ call: stream.call,
1059
3297
  error: stream.error,
1060
3298
  isConnected: stream.isConnected,
1061
3299
  isRecording: false,
@@ -1085,6 +3323,7 @@ var createVoiceController = (path, options = {}) => {
1085
3323
  ...state,
1086
3324
  assistantAudio: [...stream.assistantAudio],
1087
3325
  assistantTexts: [...stream.assistantTexts],
3326
+ call: stream.call,
1088
3327
  error: stream.error,
1089
3328
  isConnected: stream.isConnected,
1090
3329
  partial: stream.partial,
@@ -1112,7 +3351,13 @@ var createVoiceController = (path, options = {}) => {
1112
3351
  capture = createMicrophoneCapture({
1113
3352
  channelCount: options.capture?.channelCount ?? preset.capture.channelCount,
1114
3353
  onLevel: options.capture?.onLevel,
1115
- onAudio: (audio) => stream.sendAudio(audio),
3354
+ onAudio: (audio) => {
3355
+ if (options.capture?.onAudio) {
3356
+ options.capture.onAudio(audio, stream.sendAudio);
3357
+ return;
3358
+ }
3359
+ stream.sendAudio(audio);
3360
+ },
1116
3361
  sampleRateHz: options.capture?.sampleRateHz ?? preset.capture.sampleRateHz
1117
3362
  });
1118
3363
  return capture;
@@ -1162,6 +3407,7 @@ var createVoiceController = (path, options = {}) => {
1162
3407
  bindHTMX(bindingOptions) {
1163
3408
  return bindVoiceHTMX(stream, bindingOptions);
1164
3409
  },
3410
+ callControl: (message) => stream.callControl(message),
1165
3411
  close,
1166
3412
  endTurn: () => stream.endTurn(),
1167
3413
  get error() {
@@ -1214,23 +3460,26 @@ var createVoiceController = (path, options = {}) => {
1214
3460
  },
1215
3461
  get assistantAudio() {
1216
3462
  return state.assistantAudio;
3463
+ },
3464
+ get call() {
3465
+ return state.call;
1217
3466
  }
1218
3467
  };
1219
3468
  };
1220
3469
 
1221
3470
  // src/vue/useVoiceController.ts
1222
- var useVoiceController = (path, options = {}) => {
3471
+ function useVoiceController(path, options = {}) {
1223
3472
  const controller = createVoiceController(path, options);
1224
- const assistantAudio = shallowRef2([]);
1225
- const assistantTexts = shallowRef2([]);
1226
- const error = ref2(null);
1227
- const isConnected = ref2(false);
1228
- const isRecording = ref2(false);
1229
- const partial = ref2("");
1230
- const recordingError = ref2(null);
1231
- const sessionId = ref2(controller.sessionId);
1232
- const status = ref2(controller.status);
1233
- const turns = shallowRef2([]);
3473
+ const assistantAudio = shallowRef9([]);
3474
+ const assistantTexts = shallowRef9([]);
3475
+ const error = ref6(null);
3476
+ const isConnected = ref6(false);
3477
+ const isRecording = ref6(false);
3478
+ const partial = ref6("");
3479
+ const recordingError = ref6(null);
3480
+ const sessionId = ref6(controller.sessionId);
3481
+ const status = ref6(controller.status);
3482
+ const turns = shallowRef9([]);
1234
3483
  const sync = () => {
1235
3484
  assistantAudio.value = [...controller.assistantAudio];
1236
3485
  assistantTexts.value = [...controller.assistantTexts];
@@ -1249,7 +3498,7 @@ var useVoiceController = (path, options = {}) => {
1249
3498
  unsubscribe();
1250
3499
  controller.close();
1251
3500
  };
1252
- onUnmounted2(destroy);
3501
+ onUnmounted10(destroy);
1253
3502
  return {
1254
3503
  assistantAudio,
1255
3504
  assistantTexts,
@@ -1269,8 +3518,250 @@ var useVoiceController = (path, options = {}) => {
1269
3518
  toggleRecording: () => controller.toggleRecording(),
1270
3519
  turns
1271
3520
  };
3521
+ }
3522
+ // src/vue/useVoiceTraceTimeline.ts
3523
+ import { onUnmounted as onUnmounted11, ref as ref7, shallowRef as shallowRef10 } from "vue";
3524
+
3525
+ // src/client/traceTimeline.ts
3526
+ var fetchVoiceTraceTimeline = async (path = "/api/voice-traces", options = {}) => {
3527
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3528
+ const response = await fetchImpl(path);
3529
+ if (!response.ok) {
3530
+ throw new Error(`Voice trace timeline failed: HTTP ${response.status}`);
3531
+ }
3532
+ return await response.json();
3533
+ };
3534
+ var createVoiceTraceTimelineStore = (path = "/api/voice-traces", options = {}) => {
3535
+ const listeners = new Set;
3536
+ let closed = false;
3537
+ let timer;
3538
+ let snapshot = {
3539
+ error: null,
3540
+ isLoading: false,
3541
+ report: null
3542
+ };
3543
+ const emit = () => {
3544
+ for (const listener of listeners) {
3545
+ listener();
3546
+ }
3547
+ };
3548
+ const refresh = async () => {
3549
+ if (closed) {
3550
+ return snapshot.report;
3551
+ }
3552
+ snapshot = {
3553
+ ...snapshot,
3554
+ error: null,
3555
+ isLoading: true
3556
+ };
3557
+ emit();
3558
+ try {
3559
+ const report = await fetchVoiceTraceTimeline(path, options);
3560
+ snapshot = {
3561
+ error: null,
3562
+ isLoading: false,
3563
+ report,
3564
+ updatedAt: Date.now()
3565
+ };
3566
+ emit();
3567
+ return report;
3568
+ } catch (error) {
3569
+ snapshot = {
3570
+ ...snapshot,
3571
+ error: error instanceof Error ? error.message : String(error),
3572
+ isLoading: false
3573
+ };
3574
+ emit();
3575
+ throw error;
3576
+ }
3577
+ };
3578
+ const close = () => {
3579
+ closed = true;
3580
+ if (timer) {
3581
+ clearInterval(timer);
3582
+ timer = undefined;
3583
+ }
3584
+ listeners.clear();
3585
+ };
3586
+ if (options.intervalMs && options.intervalMs > 0) {
3587
+ timer = setInterval(() => {
3588
+ refresh().catch(() => {});
3589
+ }, options.intervalMs);
3590
+ }
3591
+ return {
3592
+ close,
3593
+ getServerSnapshot: () => snapshot,
3594
+ getSnapshot: () => snapshot,
3595
+ refresh,
3596
+ subscribe: (listener) => {
3597
+ listeners.add(listener);
3598
+ return () => {
3599
+ listeners.delete(listener);
3600
+ };
3601
+ }
3602
+ };
3603
+ };
3604
+
3605
+ // src/vue/useVoiceTraceTimeline.ts
3606
+ function useVoiceTraceTimeline(path = "/api/voice-traces", options = {}) {
3607
+ const store = createVoiceTraceTimelineStore(path, options);
3608
+ const error = ref7(null);
3609
+ const isLoading = ref7(false);
3610
+ const report = shallowRef10(null);
3611
+ const updatedAt = ref7(undefined);
3612
+ const sync = () => {
3613
+ const snapshot = store.getSnapshot();
3614
+ error.value = snapshot.error;
3615
+ isLoading.value = snapshot.isLoading;
3616
+ report.value = snapshot.report;
3617
+ updatedAt.value = snapshot.updatedAt;
3618
+ };
3619
+ const unsubscribe = store.subscribe(sync);
3620
+ sync();
3621
+ store.refresh().catch(() => {});
3622
+ onUnmounted11(() => {
3623
+ unsubscribe();
3624
+ store.close();
3625
+ });
3626
+ return {
3627
+ error,
3628
+ isLoading,
3629
+ refresh: store.refresh,
3630
+ report,
3631
+ updatedAt
3632
+ };
3633
+ }
3634
+ // src/vue/useVoiceWorkflowStatus.ts
3635
+ import { onUnmounted as onUnmounted12, ref as ref8, shallowRef as shallowRef11 } from "vue";
3636
+
3637
+ // src/client/workflowStatus.ts
3638
+ var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
3639
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3640
+ const response = await fetchImpl(path);
3641
+ if (!response.ok) {
3642
+ throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
3643
+ }
3644
+ return await response.json();
3645
+ };
3646
+ var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
3647
+ const listeners = new Set;
3648
+ let closed = false;
3649
+ let timer;
3650
+ let snapshot = {
3651
+ error: null,
3652
+ isLoading: false
3653
+ };
3654
+ const emit = () => {
3655
+ for (const listener of listeners) {
3656
+ listener();
3657
+ }
3658
+ };
3659
+ const refresh = async () => {
3660
+ if (closed) {
3661
+ return snapshot.report;
3662
+ }
3663
+ snapshot = {
3664
+ ...snapshot,
3665
+ error: null,
3666
+ isLoading: true
3667
+ };
3668
+ emit();
3669
+ try {
3670
+ const report = await fetchVoiceWorkflowStatus(path, options);
3671
+ snapshot = {
3672
+ error: null,
3673
+ isLoading: false,
3674
+ report,
3675
+ updatedAt: Date.now()
3676
+ };
3677
+ emit();
3678
+ return report;
3679
+ } catch (error) {
3680
+ snapshot = {
3681
+ ...snapshot,
3682
+ error: error instanceof Error ? error.message : String(error),
3683
+ isLoading: false
3684
+ };
3685
+ emit();
3686
+ throw error;
3687
+ }
3688
+ };
3689
+ const close = () => {
3690
+ closed = true;
3691
+ if (timer) {
3692
+ clearInterval(timer);
3693
+ timer = undefined;
3694
+ }
3695
+ listeners.clear();
3696
+ };
3697
+ if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
3698
+ timer = setInterval(() => {
3699
+ refresh().catch(() => {});
3700
+ }, options.intervalMs);
3701
+ }
3702
+ return {
3703
+ close,
3704
+ getServerSnapshot: () => snapshot,
3705
+ getSnapshot: () => snapshot,
3706
+ refresh,
3707
+ subscribe: (listener) => {
3708
+ listeners.add(listener);
3709
+ return () => {
3710
+ listeners.delete(listener);
3711
+ };
3712
+ }
3713
+ };
1272
3714
  };
3715
+
3716
+ // src/vue/useVoiceWorkflowStatus.ts
3717
+ function useVoiceWorkflowStatus(path = "/evals/scenarios/json", options = {}) {
3718
+ const store = createVoiceWorkflowStatusStore(path, options);
3719
+ const error = ref8(null);
3720
+ const isLoading = ref8(false);
3721
+ const report = shallowRef11(undefined);
3722
+ const updatedAt = ref8(undefined);
3723
+ const sync = () => {
3724
+ const snapshot = store.getSnapshot();
3725
+ error.value = snapshot.error;
3726
+ isLoading.value = snapshot.isLoading;
3727
+ report.value = snapshot.report;
3728
+ updatedAt.value = snapshot.updatedAt;
3729
+ };
3730
+ const unsubscribe = store.subscribe(sync);
3731
+ sync();
3732
+ if (typeof window !== "undefined") {
3733
+ store.refresh().catch(() => {});
3734
+ }
3735
+ onUnmounted12(() => {
3736
+ unsubscribe();
3737
+ store.close();
3738
+ });
3739
+ return {
3740
+ error,
3741
+ isLoading,
3742
+ refresh: store.refresh,
3743
+ report,
3744
+ updatedAt
3745
+ };
3746
+ }
1273
3747
  export {
3748
+ useVoiceWorkflowStatus,
3749
+ useVoiceTurnQuality,
3750
+ useVoiceTurnLatency,
3751
+ useVoiceTraceTimeline,
1274
3752
  useVoiceStream,
1275
- useVoiceController
3753
+ useVoiceRoutingStatus,
3754
+ useVoiceProviderStatus,
3755
+ useVoiceProviderSimulationControls,
3756
+ useVoiceProviderCapabilities,
3757
+ useVoiceController,
3758
+ useVoiceCampaignDialerProof,
3759
+ useVoiceAppKitStatus,
3760
+ VoiceTurnQuality,
3761
+ VoiceTurnLatency,
3762
+ VoiceRoutingStatus,
3763
+ VoiceProviderStatus,
3764
+ VoiceProviderSimulationControls,
3765
+ VoiceProviderCapabilities,
3766
+ VoiceOpsStatus
1276
3767
  };