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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/README.md +287 -0
  2. package/dist/agent.d.ts +2 -0
  3. package/dist/angular/index.d.ts +8 -0
  4. package/dist/angular/index.js +1112 -44
  5. package/dist/angular/voice-app-kit-status.service.d.ts +12 -0
  6. package/dist/angular/voice-ops-status.component.d.ts +15 -0
  7. package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
  8. package/dist/angular/voice-provider-status.service.d.ts +12 -0
  9. package/dist/angular/voice-routing-status.service.d.ts +11 -0
  10. package/dist/angular/voice-stream.service.d.ts +2 -0
  11. package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
  12. package/dist/angular/voice-turn-latency.service.d.ts +13 -0
  13. package/dist/angular/voice-turn-quality.service.d.ts +12 -0
  14. package/dist/angular/voice-workflow-status.service.d.ts +12 -0
  15. package/dist/appKit.d.ts +100 -0
  16. package/dist/assistant.d.ts +143 -0
  17. package/dist/assistantHealth.d.ts +81 -0
  18. package/dist/assistantMemory.d.ts +63 -0
  19. package/dist/bargeInRoutes.d.ts +56 -0
  20. package/dist/client/actions.d.ts +22 -0
  21. package/dist/client/appKitStatus.d.ts +19 -0
  22. package/dist/client/bargeInMonitor.d.ts +7 -0
  23. package/dist/client/connection.d.ts +3 -0
  24. package/dist/client/duplex.d.ts +1 -1
  25. package/dist/client/htmxBootstrap.js +587 -13
  26. package/dist/client/index.d.ts +38 -0
  27. package/dist/client/index.js +1890 -8
  28. package/dist/client/liveTurnLatency.d.ts +38 -0
  29. package/dist/client/opsStatusWidget.d.ts +40 -0
  30. package/dist/client/providerCapabilities.d.ts +19 -0
  31. package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
  32. package/dist/client/providerSimulationControls.d.ts +33 -0
  33. package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
  34. package/dist/client/providerStatus.d.ts +19 -0
  35. package/dist/client/providerStatusWidget.d.ts +32 -0
  36. package/dist/client/routingStatus.d.ts +19 -0
  37. package/dist/client/routingStatusWidget.d.ts +28 -0
  38. package/dist/client/traceTimeline.d.ts +19 -0
  39. package/dist/client/traceTimelineWidget.d.ts +32 -0
  40. package/dist/client/turnLatency.d.ts +22 -0
  41. package/dist/client/turnLatencyWidget.d.ts +33 -0
  42. package/dist/client/turnQuality.d.ts +19 -0
  43. package/dist/client/turnQualityWidget.d.ts +32 -0
  44. package/dist/client/workflowStatus.d.ts +19 -0
  45. package/dist/diagnosticsRoutes.d.ts +44 -0
  46. package/dist/evalRoutes.d.ts +213 -0
  47. package/dist/fileStore.d.ts +5 -2
  48. package/dist/handoff.d.ts +54 -0
  49. package/dist/handoffHealth.d.ts +94 -0
  50. package/dist/index.d.ts +71 -6
  51. package/dist/index.js +11044 -1800
  52. package/dist/modelAdapters.d.ts +114 -0
  53. package/dist/openaiTTS.d.ts +18 -0
  54. package/dist/opsConsoleRoutes.d.ts +77 -0
  55. package/dist/opsWebhook.d.ts +126 -0
  56. package/dist/outcomeContract.d.ts +112 -0
  57. package/dist/postgresStore.d.ts +2 -0
  58. package/dist/productionReadiness.d.ts +111 -0
  59. package/dist/providerAdapters.d.ts +48 -0
  60. package/dist/providerCapabilities.d.ts +92 -0
  61. package/dist/providerHealth.d.ts +79 -0
  62. package/dist/qualityRoutes.d.ts +76 -0
  63. package/dist/queue.d.ts +61 -0
  64. package/dist/react/VoiceOpsStatus.d.ts +6 -0
  65. package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
  66. package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
  67. package/dist/react/VoiceProviderStatus.d.ts +6 -0
  68. package/dist/react/VoiceRoutingStatus.d.ts +6 -0
  69. package/dist/react/VoiceTraceTimeline.d.ts +6 -0
  70. package/dist/react/VoiceTurnLatency.d.ts +6 -0
  71. package/dist/react/VoiceTurnQuality.d.ts +6 -0
  72. package/dist/react/index.d.ts +17 -0
  73. package/dist/react/index.js +2467 -12
  74. package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
  75. package/dist/react/useVoiceController.d.ts +2 -0
  76. package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
  77. package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
  78. package/dist/react/useVoiceProviderStatus.d.ts +8 -0
  79. package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
  80. package/dist/react/useVoiceStream.d.ts +2 -0
  81. package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
  82. package/dist/react/useVoiceTurnLatency.d.ts +9 -0
  83. package/dist/react/useVoiceTurnQuality.d.ts +8 -0
  84. package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
  85. package/dist/resilienceRoutes.d.ts +142 -0
  86. package/dist/sessionReplay.d.ts +175 -0
  87. package/dist/sqliteStore.d.ts +2 -0
  88. package/dist/svelte/createVoiceAppKitStatus.d.ts +8 -0
  89. package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
  90. package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
  91. package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
  92. package/dist/svelte/createVoiceProviderStatus.d.ts +10 -0
  93. package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
  94. package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
  95. package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
  96. package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
  97. package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
  98. package/dist/svelte/index.d.ts +10 -0
  99. package/dist/svelte/index.js +1728 -4
  100. package/dist/telephony/contract.d.ts +61 -0
  101. package/dist/telephony/matrix.d.ts +97 -0
  102. package/dist/telephony/plivo.d.ts +254 -0
  103. package/dist/telephony/telnyx.d.ts +247 -0
  104. package/dist/telephony/twilio.d.ts +132 -0
  105. package/dist/telephonyOutcome.d.ts +201 -0
  106. package/dist/testing/index.d.ts +2 -0
  107. package/dist/testing/index.js +2637 -21
  108. package/dist/testing/ioProviderSimulator.d.ts +41 -0
  109. package/dist/testing/providerSimulator.d.ts +44 -0
  110. package/dist/toolContract.d.ts +130 -0
  111. package/dist/toolRuntime.d.ts +50 -0
  112. package/dist/trace.d.ts +1 -1
  113. package/dist/traceTimeline.d.ts +93 -0
  114. package/dist/turnLatency.d.ts +95 -0
  115. package/dist/turnQuality.d.ts +94 -0
  116. package/dist/types.d.ts +125 -2
  117. package/dist/vue/VoiceOpsStatus.d.ts +30 -0
  118. package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
  119. package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
  120. package/dist/vue/VoiceProviderStatus.d.ts +51 -0
  121. package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
  122. package/dist/vue/VoiceTurnLatency.d.ts +69 -0
  123. package/dist/vue/VoiceTurnQuality.d.ts +51 -0
  124. package/dist/vue/index.d.ts +16 -0
  125. package/dist/vue/index.js +2360 -26
  126. package/dist/vue/useVoiceAppKitStatus.d.ts +9 -0
  127. package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
  128. package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
  129. package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
  130. package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
  131. package/dist/vue/useVoiceStream.d.ts +2 -0
  132. package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
  133. package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
  134. package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
  135. package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
  136. package/dist/workflowContract.d.ts +91 -0
  137. package/package.json +1 -1
package/dist/vue/index.js CHANGED
@@ -69,8 +69,2049 @@ 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
+ var 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
+ var 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
+ var 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
+ var 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
+ var 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
+ var 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
+ var 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
+ });
72
2113
  // src/vue/useVoiceStream.ts
73
- import { onUnmounted, ref, shallowRef } from "vue";
2114
+ import { onUnmounted as onUnmounted8, ref as ref5, shallowRef as shallowRef7 } from "vue";
74
2115
 
75
2116
  // src/client/actions.ts
76
2117
  var normalizeErrorMessage = (value) => {
@@ -120,6 +2161,12 @@ var serverMessageToAction = (message) => {
120
2161
  sessionId: message.sessionId,
121
2162
  type: "complete"
122
2163
  };
2164
+ case "call_lifecycle":
2165
+ return {
2166
+ event: message.event,
2167
+ sessionId: message.sessionId,
2168
+ type: "call_lifecycle"
2169
+ };
123
2170
  case "error":
124
2171
  return {
125
2172
  message: normalizeErrorMessage(message.message),
@@ -163,7 +2210,7 @@ var DEFAULT_SCENARIO_QUERY_PARAM = "scenarioId";
163
2210
  var noop = () => {};
164
2211
  var noopUnsubscribe = () => noop;
165
2212
  var NOOP_CONNECTION = {
166
- start: () => {},
2213
+ callControl: noop,
167
2214
  close: noop,
168
2215
  endTurn: noop,
169
2216
  getReadyState: () => WS_CLOSED,
@@ -171,6 +2218,7 @@ var NOOP_CONNECTION = {
171
2218
  getSessionId: () => "",
172
2219
  send: noop,
173
2220
  sendAudio: noop,
2221
+ start: () => {},
174
2222
  subscribe: noopUnsubscribe
175
2223
  };
176
2224
  var createSessionId = () => crypto.randomUUID();
@@ -192,6 +2240,7 @@ var isVoiceServerMessage = (value) => {
192
2240
  switch (value.type) {
193
2241
  case "audio":
194
2242
  case "assistant":
2243
+ case "call_lifecycle":
195
2244
  case "complete":
196
2245
  case "error":
197
2246
  case "final":
@@ -332,6 +2381,12 @@ var createVoiceConnection = (path, options = {}) => {
332
2381
  const endTurn = () => {
333
2382
  send({ type: "end_turn" });
334
2383
  };
2384
+ const callControl = (message) => {
2385
+ send({
2386
+ ...message,
2387
+ type: "call_control"
2388
+ });
2389
+ };
335
2390
  const close = () => {
336
2391
  clearTimers();
337
2392
  if (state.ws) {
@@ -349,7 +2404,7 @@ var createVoiceConnection = (path, options = {}) => {
349
2404
  };
350
2405
  connect();
351
2406
  return {
352
- start,
2407
+ callControl,
353
2408
  close,
354
2409
  endTurn,
355
2410
  getReadyState: () => state.ws?.readyState ?? WS_CLOSED,
@@ -357,6 +2412,7 @@ var createVoiceConnection = (path, options = {}) => {
357
2412
  getSessionId: () => state.sessionId,
358
2413
  send,
359
2414
  sendAudio,
2415
+ start,
360
2416
  subscribe
361
2417
  };
362
2418
  };
@@ -365,6 +2421,7 @@ var createVoiceConnection = (path, options = {}) => {
365
2421
  var createInitialState = () => ({
366
2422
  assistantAudio: [],
367
2423
  assistantTexts: [],
2424
+ call: null,
368
2425
  error: null,
369
2426
  isConnected: false,
370
2427
  scenarioId: null,
@@ -408,6 +2465,20 @@ var createVoiceStreamStore = () => {
408
2465
  status: "completed"
409
2466
  };
410
2467
  break;
2468
+ case "call_lifecycle":
2469
+ state = {
2470
+ ...state,
2471
+ call: {
2472
+ ...state.call,
2473
+ disposition: action.event.type === "end" ? action.event.disposition : state.call?.disposition,
2474
+ endedAt: action.event.type === "end" ? action.event.at : state.call?.endedAt,
2475
+ events: [...state.call?.events ?? [], action.event],
2476
+ lastEventAt: action.event.at,
2477
+ startedAt: state.call?.startedAt ?? action.event.at
2478
+ },
2479
+ sessionId: action.sessionId
2480
+ };
2481
+ break;
411
2482
  case "connected":
412
2483
  state = {
413
2484
  ...state,
@@ -494,6 +2565,9 @@ var createVoiceStream = (path, options = {}) => {
494
2565
  }
495
2566
  });
496
2567
  return {
2568
+ callControl(message) {
2569
+ connection.callControl(message);
2570
+ },
497
2571
  close() {
498
2572
  unsubscribeConnection();
499
2573
  connection.close();
@@ -537,6 +2611,9 @@ var createVoiceStream = (path, options = {}) => {
537
2611
  get assistantAudio() {
538
2612
  return store.getSnapshot().assistantAudio;
539
2613
  },
2614
+ get call() {
2615
+ return store.getSnapshot().call;
2616
+ },
540
2617
  sendAudio(audio) {
541
2618
  connection.sendAudio(audio);
542
2619
  },
@@ -552,17 +2629,19 @@ var createVoiceStream = (path, options = {}) => {
552
2629
  // src/vue/useVoiceStream.ts
553
2630
  var useVoiceStream = (path, options = {}) => {
554
2631
  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([]);
2632
+ const assistantAudio = shallowRef7([]);
2633
+ const assistantTexts = shallowRef7([]);
2634
+ const call = shallowRef7(null);
2635
+ const error = ref5(null);
2636
+ const isConnected = ref5(false);
2637
+ const partial = ref5("");
2638
+ const sessionId = ref5(stream.sessionId);
2639
+ const status = ref5(stream.status);
2640
+ const turns = shallowRef7([]);
563
2641
  const sync = () => {
564
2642
  assistantAudio.value = [...stream.assistantAudio];
565
2643
  assistantTexts.value = [...stream.assistantTexts];
2644
+ call.value = stream.call;
566
2645
  error.value = stream.error;
567
2646
  isConnected.value = stream.isConnected;
568
2647
  partial.value = stream.partial;
@@ -576,10 +2655,12 @@ var useVoiceStream = (path, options = {}) => {
576
2655
  unsubscribe();
577
2656
  stream.close();
578
2657
  };
579
- onUnmounted(destroy);
2658
+ onUnmounted8(destroy);
580
2659
  return {
581
2660
  assistantAudio,
582
2661
  assistantTexts,
2662
+ call,
2663
+ callControl: (message) => stream.callControl(message),
583
2664
  close: () => destroy(),
584
2665
  endTurn: () => stream.endTurn(),
585
2666
  error,
@@ -592,7 +2673,7 @@ var useVoiceStream = (path, options = {}) => {
592
2673
  };
593
2674
  };
594
2675
  // src/vue/useVoiceController.ts
595
- import { onUnmounted as onUnmounted2, ref as ref2, shallowRef as shallowRef2 } from "vue";
2676
+ import { onUnmounted as onUnmounted9, ref as ref6, shallowRef as shallowRef8 } from "vue";
596
2677
 
597
2678
  // src/client/htmx.ts
598
2679
  var DEFAULT_EVENT_NAME = "voice-refresh";
@@ -1056,6 +3137,7 @@ var resolveVoiceRuntimePreset = (name = "default") => {
1056
3137
  var createInitialState2 = (stream) => ({
1057
3138
  assistantAudio: [...stream.assistantAudio],
1058
3139
  assistantTexts: [...stream.assistantTexts],
3140
+ call: stream.call,
1059
3141
  error: stream.error,
1060
3142
  isConnected: stream.isConnected,
1061
3143
  isRecording: false,
@@ -1085,6 +3167,7 @@ var createVoiceController = (path, options = {}) => {
1085
3167
  ...state,
1086
3168
  assistantAudio: [...stream.assistantAudio],
1087
3169
  assistantTexts: [...stream.assistantTexts],
3170
+ call: stream.call,
1088
3171
  error: stream.error,
1089
3172
  isConnected: stream.isConnected,
1090
3173
  partial: stream.partial,
@@ -1112,7 +3195,13 @@ var createVoiceController = (path, options = {}) => {
1112
3195
  capture = createMicrophoneCapture({
1113
3196
  channelCount: options.capture?.channelCount ?? preset.capture.channelCount,
1114
3197
  onLevel: options.capture?.onLevel,
1115
- onAudio: (audio) => stream.sendAudio(audio),
3198
+ onAudio: (audio) => {
3199
+ if (options.capture?.onAudio) {
3200
+ options.capture.onAudio(audio, stream.sendAudio);
3201
+ return;
3202
+ }
3203
+ stream.sendAudio(audio);
3204
+ },
1116
3205
  sampleRateHz: options.capture?.sampleRateHz ?? preset.capture.sampleRateHz
1117
3206
  });
1118
3207
  return capture;
@@ -1162,6 +3251,7 @@ var createVoiceController = (path, options = {}) => {
1162
3251
  bindHTMX(bindingOptions) {
1163
3252
  return bindVoiceHTMX(stream, bindingOptions);
1164
3253
  },
3254
+ callControl: (message) => stream.callControl(message),
1165
3255
  close,
1166
3256
  endTurn: () => stream.endTurn(),
1167
3257
  get error() {
@@ -1214,6 +3304,9 @@ var createVoiceController = (path, options = {}) => {
1214
3304
  },
1215
3305
  get assistantAudio() {
1216
3306
  return state.assistantAudio;
3307
+ },
3308
+ get call() {
3309
+ return state.call;
1217
3310
  }
1218
3311
  };
1219
3312
  };
@@ -1221,16 +3314,16 @@ var createVoiceController = (path, options = {}) => {
1221
3314
  // src/vue/useVoiceController.ts
1222
3315
  var useVoiceController = (path, options = {}) => {
1223
3316
  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([]);
3317
+ const assistantAudio = shallowRef8([]);
3318
+ const assistantTexts = shallowRef8([]);
3319
+ const error = ref6(null);
3320
+ const isConnected = ref6(false);
3321
+ const isRecording = ref6(false);
3322
+ const partial = ref6("");
3323
+ const recordingError = ref6(null);
3324
+ const sessionId = ref6(controller.sessionId);
3325
+ const status = ref6(controller.status);
3326
+ const turns = shallowRef8([]);
1234
3327
  const sync = () => {
1235
3328
  assistantAudio.value = [...controller.assistantAudio];
1236
3329
  assistantTexts.value = [...controller.assistantTexts];
@@ -1249,7 +3342,7 @@ var useVoiceController = (path, options = {}) => {
1249
3342
  unsubscribe();
1250
3343
  controller.close();
1251
3344
  };
1252
- onUnmounted2(destroy);
3345
+ onUnmounted9(destroy);
1253
3346
  return {
1254
3347
  assistantAudio,
1255
3348
  assistantTexts,
@@ -1270,7 +3363,248 @@ var useVoiceController = (path, options = {}) => {
1270
3363
  turns
1271
3364
  };
1272
3365
  };
3366
+ // src/vue/useVoiceTraceTimeline.ts
3367
+ import { onUnmounted as onUnmounted10, ref as ref7, shallowRef as shallowRef9 } from "vue";
3368
+
3369
+ // src/client/traceTimeline.ts
3370
+ var fetchVoiceTraceTimeline = async (path = "/api/voice-traces", options = {}) => {
3371
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3372
+ const response = await fetchImpl(path);
3373
+ if (!response.ok) {
3374
+ throw new Error(`Voice trace timeline failed: HTTP ${response.status}`);
3375
+ }
3376
+ return await response.json();
3377
+ };
3378
+ var createVoiceTraceTimelineStore = (path = "/api/voice-traces", options = {}) => {
3379
+ const listeners = new Set;
3380
+ let closed = false;
3381
+ let timer;
3382
+ let snapshot = {
3383
+ error: null,
3384
+ isLoading: false,
3385
+ report: null
3386
+ };
3387
+ const emit = () => {
3388
+ for (const listener of listeners) {
3389
+ listener();
3390
+ }
3391
+ };
3392
+ const refresh = async () => {
3393
+ if (closed) {
3394
+ return snapshot.report;
3395
+ }
3396
+ snapshot = {
3397
+ ...snapshot,
3398
+ error: null,
3399
+ isLoading: true
3400
+ };
3401
+ emit();
3402
+ try {
3403
+ const report = await fetchVoiceTraceTimeline(path, options);
3404
+ snapshot = {
3405
+ error: null,
3406
+ isLoading: false,
3407
+ report,
3408
+ updatedAt: Date.now()
3409
+ };
3410
+ emit();
3411
+ return report;
3412
+ } catch (error) {
3413
+ snapshot = {
3414
+ ...snapshot,
3415
+ error: error instanceof Error ? error.message : String(error),
3416
+ isLoading: false
3417
+ };
3418
+ emit();
3419
+ throw error;
3420
+ }
3421
+ };
3422
+ const close = () => {
3423
+ closed = true;
3424
+ if (timer) {
3425
+ clearInterval(timer);
3426
+ timer = undefined;
3427
+ }
3428
+ listeners.clear();
3429
+ };
3430
+ if (options.intervalMs && options.intervalMs > 0) {
3431
+ timer = setInterval(() => {
3432
+ refresh().catch(() => {});
3433
+ }, options.intervalMs);
3434
+ }
3435
+ return {
3436
+ close,
3437
+ getServerSnapshot: () => snapshot,
3438
+ getSnapshot: () => snapshot,
3439
+ refresh,
3440
+ subscribe: (listener) => {
3441
+ listeners.add(listener);
3442
+ return () => {
3443
+ listeners.delete(listener);
3444
+ };
3445
+ }
3446
+ };
3447
+ };
3448
+
3449
+ // src/vue/useVoiceTraceTimeline.ts
3450
+ var useVoiceTraceTimeline = (path = "/api/voice-traces", options = {}) => {
3451
+ const store = createVoiceTraceTimelineStore(path, options);
3452
+ const error = ref7(null);
3453
+ const isLoading = ref7(false);
3454
+ const report = shallowRef9(null);
3455
+ const updatedAt = ref7(undefined);
3456
+ const sync = () => {
3457
+ const snapshot = store.getSnapshot();
3458
+ error.value = snapshot.error;
3459
+ isLoading.value = snapshot.isLoading;
3460
+ report.value = snapshot.report;
3461
+ updatedAt.value = snapshot.updatedAt;
3462
+ };
3463
+ const unsubscribe = store.subscribe(sync);
3464
+ sync();
3465
+ store.refresh().catch(() => {});
3466
+ onUnmounted10(() => {
3467
+ unsubscribe();
3468
+ store.close();
3469
+ });
3470
+ return {
3471
+ error,
3472
+ isLoading,
3473
+ refresh: store.refresh,
3474
+ report,
3475
+ updatedAt
3476
+ };
3477
+ };
3478
+ // src/vue/useVoiceWorkflowStatus.ts
3479
+ import { onUnmounted as onUnmounted11, ref as ref8, shallowRef as shallowRef10 } from "vue";
3480
+
3481
+ // src/client/workflowStatus.ts
3482
+ var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
3483
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3484
+ const response = await fetchImpl(path);
3485
+ if (!response.ok) {
3486
+ throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
3487
+ }
3488
+ return await response.json();
3489
+ };
3490
+ var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
3491
+ const listeners = new Set;
3492
+ let closed = false;
3493
+ let timer;
3494
+ let snapshot = {
3495
+ error: null,
3496
+ isLoading: false
3497
+ };
3498
+ const emit = () => {
3499
+ for (const listener of listeners) {
3500
+ listener();
3501
+ }
3502
+ };
3503
+ const refresh = async () => {
3504
+ if (closed) {
3505
+ return snapshot.report;
3506
+ }
3507
+ snapshot = {
3508
+ ...snapshot,
3509
+ error: null,
3510
+ isLoading: true
3511
+ };
3512
+ emit();
3513
+ try {
3514
+ const report = await fetchVoiceWorkflowStatus(path, options);
3515
+ snapshot = {
3516
+ error: null,
3517
+ isLoading: false,
3518
+ report,
3519
+ updatedAt: Date.now()
3520
+ };
3521
+ emit();
3522
+ return report;
3523
+ } catch (error) {
3524
+ snapshot = {
3525
+ ...snapshot,
3526
+ error: error instanceof Error ? error.message : String(error),
3527
+ isLoading: false
3528
+ };
3529
+ emit();
3530
+ throw error;
3531
+ }
3532
+ };
3533
+ const close = () => {
3534
+ closed = true;
3535
+ if (timer) {
3536
+ clearInterval(timer);
3537
+ timer = undefined;
3538
+ }
3539
+ listeners.clear();
3540
+ };
3541
+ if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
3542
+ timer = setInterval(() => {
3543
+ refresh().catch(() => {});
3544
+ }, options.intervalMs);
3545
+ }
3546
+ return {
3547
+ close,
3548
+ getServerSnapshot: () => snapshot,
3549
+ getSnapshot: () => snapshot,
3550
+ refresh,
3551
+ subscribe: (listener) => {
3552
+ listeners.add(listener);
3553
+ return () => {
3554
+ listeners.delete(listener);
3555
+ };
3556
+ }
3557
+ };
3558
+ };
3559
+
3560
+ // src/vue/useVoiceWorkflowStatus.ts
3561
+ var useVoiceWorkflowStatus = (path = "/evals/scenarios/json", options = {}) => {
3562
+ const store = createVoiceWorkflowStatusStore(path, options);
3563
+ const error = ref8(null);
3564
+ const isLoading = ref8(false);
3565
+ const report = shallowRef10(undefined);
3566
+ const updatedAt = ref8(undefined);
3567
+ const sync = () => {
3568
+ const snapshot = store.getSnapshot();
3569
+ error.value = snapshot.error;
3570
+ isLoading.value = snapshot.isLoading;
3571
+ report.value = snapshot.report;
3572
+ updatedAt.value = snapshot.updatedAt;
3573
+ };
3574
+ const unsubscribe = store.subscribe(sync);
3575
+ sync();
3576
+ if (typeof window !== "undefined") {
3577
+ store.refresh().catch(() => {});
3578
+ }
3579
+ onUnmounted11(() => {
3580
+ unsubscribe();
3581
+ store.close();
3582
+ });
3583
+ return {
3584
+ error,
3585
+ isLoading,
3586
+ refresh: store.refresh,
3587
+ report,
3588
+ updatedAt
3589
+ };
3590
+ };
1273
3591
  export {
3592
+ useVoiceWorkflowStatus,
3593
+ useVoiceTurnQuality,
3594
+ useVoiceTurnLatency,
3595
+ useVoiceTraceTimeline,
1274
3596
  useVoiceStream,
1275
- useVoiceController
3597
+ useVoiceRoutingStatus,
3598
+ useVoiceProviderStatus,
3599
+ useVoiceProviderSimulationControls,
3600
+ useVoiceProviderCapabilities,
3601
+ useVoiceController,
3602
+ useVoiceAppKitStatus,
3603
+ VoiceTurnQuality,
3604
+ VoiceTurnLatency,
3605
+ VoiceRoutingStatus,
3606
+ VoiceProviderStatus,
3607
+ VoiceProviderSimulationControls,
3608
+ VoiceProviderCapabilities,
3609
+ VoiceOpsStatus
1276
3610
  };