@absolutejs/voice 0.0.22-beta.15 → 0.0.22-beta.150

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 (159) hide show
  1. package/README.md +781 -5
  2. package/dist/agent.d.ts +24 -0
  3. package/dist/agentSquadContract.d.ts +64 -0
  4. package/dist/angular/index.d.ts +8 -0
  5. package/dist/angular/index.js +1306 -58
  6. package/dist/angular/voice-campaign-dialer-proof.service.d.ts +14 -0
  7. package/dist/angular/voice-controller.service.d.ts +1 -0
  8. package/dist/angular/voice-ops-status.component.d.ts +15 -0
  9. package/dist/angular/voice-ops-status.service.d.ts +12 -0
  10. package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
  11. package/dist/angular/voice-routing-status.service.d.ts +11 -0
  12. package/dist/angular/voice-stream.service.d.ts +3 -0
  13. package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
  14. package/dist/angular/voice-turn-latency.service.d.ts +13 -0
  15. package/dist/angular/voice-turn-quality.service.d.ts +12 -0
  16. package/dist/angular/voice-workflow-status.service.d.ts +12 -0
  17. package/dist/assistantHealth.d.ts +81 -0
  18. package/dist/audit.d.ts +128 -0
  19. package/dist/auditDeliveryRoutes.d.ts +85 -0
  20. package/dist/auditExport.d.ts +34 -0
  21. package/dist/auditRoutes.d.ts +66 -0
  22. package/dist/auditSinks.d.ts +151 -0
  23. package/dist/bargeInRoutes.d.ts +56 -0
  24. package/dist/campaign.d.ts +610 -0
  25. package/dist/campaignDialers.d.ts +90 -0
  26. package/dist/client/actions.d.ts +105 -0
  27. package/dist/client/bargeInMonitor.d.ts +7 -0
  28. package/dist/client/campaignDialerProof.d.ts +23 -0
  29. package/dist/client/connection.d.ts +3 -0
  30. package/dist/client/duplex.d.ts +1 -1
  31. package/dist/client/htmxBootstrap.js +747 -15
  32. package/dist/client/index.d.ts +38 -0
  33. package/dist/client/index.js +2091 -20
  34. package/dist/client/liveTurnLatency.d.ts +41 -0
  35. package/dist/client/opsStatus.d.ts +19 -0
  36. package/dist/client/opsStatusWidget.d.ts +40 -0
  37. package/dist/client/providerCapabilities.d.ts +19 -0
  38. package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
  39. package/dist/client/providerSimulationControls.d.ts +33 -0
  40. package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
  41. package/dist/client/providerStatusWidget.d.ts +32 -0
  42. package/dist/client/routingStatus.d.ts +19 -0
  43. package/dist/client/routingStatusWidget.d.ts +28 -0
  44. package/dist/client/traceTimeline.d.ts +19 -0
  45. package/dist/client/traceTimelineWidget.d.ts +32 -0
  46. package/dist/client/turnLatency.d.ts +22 -0
  47. package/dist/client/turnLatencyWidget.d.ts +33 -0
  48. package/dist/client/turnQuality.d.ts +19 -0
  49. package/dist/client/turnQualityWidget.d.ts +32 -0
  50. package/dist/client/workflowStatus.d.ts +19 -0
  51. package/dist/dataControl.d.ts +47 -0
  52. package/dist/deliveryRuntime.d.ts +146 -0
  53. package/dist/deliverySinkRoutes.d.ts +117 -0
  54. package/dist/demoReadyRoutes.d.ts +98 -0
  55. package/dist/diagnosticsRoutes.d.ts +44 -0
  56. package/dist/evalRoutes.d.ts +213 -0
  57. package/dist/fileStore.d.ts +11 -2
  58. package/dist/handoff.d.ts +54 -0
  59. package/dist/handoffHealth.d.ts +94 -0
  60. package/dist/index.d.ts +109 -12
  61. package/dist/index.js +18016 -4870
  62. package/dist/liveLatency.d.ts +78 -0
  63. package/dist/modelAdapters.d.ts +23 -2
  64. package/dist/openaiRealtime.d.ts +27 -0
  65. package/dist/openaiTTS.d.ts +18 -0
  66. package/dist/opsConsoleRoutes.d.ts +80 -0
  67. package/dist/opsStatus.d.ts +76 -0
  68. package/dist/opsStatusRoutes.d.ts +33 -0
  69. package/dist/opsWebhook.d.ts +126 -0
  70. package/dist/outcomeContract.d.ts +112 -0
  71. package/dist/phoneAgent.d.ts +62 -0
  72. package/dist/phoneAgentProductionSmoke.d.ts +115 -0
  73. package/dist/postgresStore.d.ts +13 -2
  74. package/dist/productionReadiness.d.ts +295 -0
  75. package/dist/providerAdapters.d.ts +48 -0
  76. package/dist/providerCapabilities.d.ts +92 -0
  77. package/dist/providerHealth.d.ts +54 -0
  78. package/dist/providerRoutingContract.d.ts +38 -0
  79. package/dist/qualityRoutes.d.ts +76 -0
  80. package/dist/queue.d.ts +61 -0
  81. package/dist/react/VoiceOpsStatus.d.ts +6 -0
  82. package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
  83. package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
  84. package/dist/react/VoiceProviderStatus.d.ts +6 -0
  85. package/dist/react/VoiceRoutingStatus.d.ts +6 -0
  86. package/dist/react/VoiceTraceTimeline.d.ts +6 -0
  87. package/dist/react/VoiceTurnLatency.d.ts +6 -0
  88. package/dist/react/VoiceTurnQuality.d.ts +6 -0
  89. package/dist/react/index.d.ts +17 -0
  90. package/dist/react/index.js +2669 -33
  91. package/dist/react/useVoiceCampaignDialerProof.d.ts +10 -0
  92. package/dist/react/useVoiceController.d.ts +3 -0
  93. package/dist/react/useVoiceOpsStatus.d.ts +8 -0
  94. package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
  95. package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
  96. package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
  97. package/dist/react/useVoiceStream.d.ts +3 -0
  98. package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
  99. package/dist/react/useVoiceTurnLatency.d.ts +9 -0
  100. package/dist/react/useVoiceTurnQuality.d.ts +8 -0
  101. package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
  102. package/dist/reconnectContract.d.ts +87 -0
  103. package/dist/resilienceRoutes.d.ts +142 -0
  104. package/dist/sessionReplay.d.ts +185 -0
  105. package/dist/simulationSuite.d.ts +120 -0
  106. package/dist/sqliteStore.d.ts +13 -2
  107. package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
  108. package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
  109. package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
  110. package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
  111. package/dist/svelte/createVoiceProviderStatus.d.ts +4 -2
  112. package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
  113. package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
  114. package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
  115. package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
  116. package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
  117. package/dist/svelte/index.d.ts +9 -0
  118. package/dist/svelte/index.js +2321 -430
  119. package/dist/telephony/contract.d.ts +61 -0
  120. package/dist/telephony/matrix.d.ts +97 -0
  121. package/dist/telephony/plivo.d.ts +254 -0
  122. package/dist/telephony/telnyx.d.ts +247 -0
  123. package/dist/telephony/twilio.d.ts +135 -2
  124. package/dist/telephonyOutcome.d.ts +201 -0
  125. package/dist/testing/index.d.ts +2 -0
  126. package/dist/testing/index.js +2973 -156
  127. package/dist/testing/ioProviderSimulator.d.ts +41 -0
  128. package/dist/testing/providerSimulator.d.ts +44 -0
  129. package/dist/toolContract.d.ts +130 -0
  130. package/dist/toolRuntime.d.ts +50 -0
  131. package/dist/trace.d.ts +19 -1
  132. package/dist/traceDeliveryRoutes.d.ts +86 -0
  133. package/dist/traceTimeline.d.ts +93 -0
  134. package/dist/turnLatency.d.ts +95 -0
  135. package/dist/turnQuality.d.ts +94 -0
  136. package/dist/types.d.ts +170 -4
  137. package/dist/vue/VoiceOpsStatus.d.ts +30 -0
  138. package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
  139. package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
  140. package/dist/vue/VoiceProviderStatus.d.ts +51 -0
  141. package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
  142. package/dist/vue/VoiceTurnLatency.d.ts +69 -0
  143. package/dist/vue/VoiceTurnQuality.d.ts +51 -0
  144. package/dist/vue/index.d.ts +16 -0
  145. package/dist/vue/index.js +2569 -53
  146. package/dist/vue/useVoiceCampaignDialerProof.d.ts +11 -0
  147. package/dist/vue/useVoiceController.d.ts +2 -1
  148. package/dist/vue/useVoiceOpsStatus.d.ts +9 -0
  149. package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
  150. package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
  151. package/dist/vue/useVoiceProviderStatus.d.ts +1 -1
  152. package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
  153. package/dist/vue/useVoiceStream.d.ts +4 -1
  154. package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
  155. package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
  156. package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
  157. package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
  158. package/dist/workflowContract.d.ts +91 -0
  159. package/package.json +1 -1
package/dist/vue/index.js CHANGED
@@ -69,8 +69,2205 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => {
69
69
  return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
70
70
  };
71
71
 
72
+ // src/vue/VoiceOpsStatus.ts
73
+ import { defineComponent, h } from "vue";
74
+
75
+ // src/client/opsStatus.ts
76
+ var fetchVoiceOpsStatus = async (path = "/api/voice/ops-status", options = {}) => {
77
+ const fetchImpl = options.fetch ?? globalThis.fetch;
78
+ const response = await fetchImpl(path);
79
+ if (!response.ok) {
80
+ throw new Error(`Voice ops status failed: HTTP ${response.status}`);
81
+ }
82
+ return await response.json();
83
+ };
84
+ var createVoiceOpsStatusStore = (path = "/api/voice/ops-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 fetchVoiceOpsStatus(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 your AbsoluteJS voice app.";
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 = "/api/voice/ops-status", options = {}) => {
242
+ const store = createVoiceOpsStatusStore(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") ?? "/api/voice/ops-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/useVoiceOpsStatus.ts
280
+ import { onUnmounted, ref, shallowRef } from "vue";
281
+ function useVoiceOpsStatus(path = "/api/voice/ops-status", options = {}) {
282
+ const store = createVoiceOpsStatusStore(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: "/api/voice/ops-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 = useVoiceOpsStatus(props.path, options);
336
+ return () => {
337
+ const model = createVoiceOpsStatusViewModel({
338
+ error: status.error.value,
339
+ isLoading: status.isLoading.value,
340
+ report: status.report.value,
341
+ updatedAt: status.updatedAt.value
342
+ }, options);
343
+ return h("section", {
344
+ class: [
345
+ "absolute-voice-ops-status",
346
+ `absolute-voice-ops-status--${model.status}`
347
+ ]
348
+ }, [
349
+ h("header", { class: "absolute-voice-ops-status__header" }, [
350
+ h("span", { class: "absolute-voice-ops-status__eyebrow" }, model.title),
351
+ h("strong", { class: "absolute-voice-ops-status__label" }, model.label)
352
+ ]),
353
+ h("p", { class: "absolute-voice-ops-status__description" }, model.description),
354
+ h("div", { class: "absolute-voice-ops-status__summary" }, [
355
+ h("span", `${model.passed} passing`),
356
+ h("span", `${Math.max(model.total - model.passed, 0)} failing`),
357
+ h("span", `${model.total} checks`)
358
+ ]),
359
+ h("ul", { class: "absolute-voice-ops-status__surfaces" }, model.surfaces.length > 0 ? model.surfaces.map((surface) => h("li", {
360
+ class: [
361
+ "absolute-voice-ops-status__surface",
362
+ `absolute-voice-ops-status__surface--${surface.status}`
363
+ ],
364
+ key: surface.id
365
+ }, [h("span", surface.label), h("strong", surface.detail)])) : [
366
+ h("li", { class: "absolute-voice-ops-status__surface" }, [
367
+ h("span", "Status"),
368
+ h("strong", "Waiting for first check")
369
+ ])
370
+ ]),
371
+ model.error ? h("p", { class: "absolute-voice-ops-status__error" }, model.error) : null,
372
+ model.links.length > 0 ? h("nav", { class: "absolute-voice-ops-status__links" }, model.links.slice(0, 4).map((link) => h("a", { href: link.href, key: link.href }, link.label))) : null
373
+ ]);
374
+ };
375
+ }
376
+ });
377
+ // src/vue/VoiceProviderSimulationControls.ts
378
+ import { computed, defineComponent as defineComponent2, h as h2 } from "vue";
379
+
380
+ // src/client/providerSimulationControls.ts
381
+ var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
382
+ const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
383
+ const body = await response.json().catch(() => null);
384
+ if (!response.ok) {
385
+ const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice provider simulation failed: HTTP ${response.status}`;
386
+ throw new Error(message);
387
+ }
388
+ return body;
389
+ };
390
+ var createVoiceProviderSimulationControlsStore = (options) => {
391
+ const listeners = new Set;
392
+ const fetchImpl = options.fetch ?? globalThis.fetch;
393
+ const pathPrefix = options.pathPrefix ?? `/api/${options.kind ?? "stt"}-simulate`;
394
+ let closed = false;
395
+ let snapshot = {
396
+ error: null,
397
+ isRunning: false,
398
+ lastResult: null,
399
+ mode: null,
400
+ provider: null
401
+ };
402
+ const emit = () => {
403
+ for (const listener of listeners) {
404
+ listener();
405
+ }
406
+ };
407
+ const run = async (provider, mode) => {
408
+ if (closed) {
409
+ return snapshot.lastResult;
410
+ }
411
+ snapshot = {
412
+ ...snapshot,
413
+ error: null,
414
+ isRunning: true,
415
+ mode,
416
+ provider
417
+ };
418
+ emit();
419
+ try {
420
+ const result = await postSimulation(pathPrefix, mode, provider, fetchImpl);
421
+ snapshot = {
422
+ error: null,
423
+ isRunning: false,
424
+ lastResult: result,
425
+ mode,
426
+ provider,
427
+ updatedAt: Date.now()
428
+ };
429
+ emit();
430
+ return result;
431
+ } catch (error) {
432
+ snapshot = {
433
+ ...snapshot,
434
+ error: error instanceof Error ? error.message : String(error),
435
+ isRunning: false
436
+ };
437
+ emit();
438
+ throw error;
439
+ }
440
+ };
441
+ const close = () => {
442
+ closed = true;
443
+ listeners.clear();
444
+ };
445
+ return {
446
+ close,
447
+ getServerSnapshot: () => snapshot,
448
+ getSnapshot: () => snapshot,
449
+ run,
450
+ subscribe: (listener) => {
451
+ listeners.add(listener);
452
+ return () => {
453
+ listeners.delete(listener);
454
+ };
455
+ }
456
+ };
457
+ };
458
+
459
+ // src/client/providerSimulationControlsWidget.ts
460
+ var escapeHtml2 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
461
+ var formatKind = (kind) => (kind ?? "stt").toUpperCase();
462
+ var createVoiceProviderSimulationControlsViewModel = (snapshot, options) => {
463
+ const configuredProviders = options.providers.filter((provider) => provider.configured !== false);
464
+ const fallbackReady = !options.fallbackRequiredProvider || configuredProviders.some((entry) => entry.provider === options.fallbackRequiredProvider);
465
+ const failureProviders = (options.failureProviders ? options.failureProviders.map((provider) => ({ provider })) : configuredProviders).filter((provider) => configuredProviders.some((entry) => entry.provider === provider.provider));
466
+ return {
467
+ canSimulateFailure: configuredProviders.length > 0 && fallbackReady,
468
+ description: options.failureMessage ?? `Simulate ${formatKind(options.kind)} provider failure and recovery without changing credentials.`,
469
+ error: snapshot.error,
470
+ failureProviders,
471
+ isRunning: snapshot.isRunning,
472
+ label: snapshot.isRunning ? `Running ${snapshot.mode ?? "simulation"}` : snapshot.lastResult ? `${snapshot.lastResult.provider} ${snapshot.lastResult.mode} simulated` : configuredProviders.length ? `${configuredProviders.length} configured` : "No configured providers",
473
+ providers: configuredProviders,
474
+ resultText: snapshot.lastResult ? JSON.stringify(snapshot.lastResult, null, 2) : null,
475
+ title: options.title ?? `${formatKind(options.kind)} Failure Simulation`
476
+ };
477
+ };
478
+ var renderVoiceProviderSimulationControlsHTML = (snapshot, options) => {
479
+ const model = createVoiceProviderSimulationControlsViewModel(snapshot, options);
480
+ const failureButtons = model.failureProviders.map((provider) => `<button type="button" data-voice-provider-fail="${escapeHtml2(provider.provider)}"${!model.canSimulateFailure || snapshot.isRunning ? " disabled" : ""}>Simulate ${escapeHtml2(provider.provider)} ${escapeHtml2(formatKind(options.kind))} failure</button>`).join("");
481
+ const recoveryButtons = model.providers.map((provider) => `<button type="button" data-voice-provider-recover="${escapeHtml2(provider.provider)}"${snapshot.isRunning ? " disabled" : ""}>Mark ${escapeHtml2(provider.provider)} recovered</button>`).join("");
482
+ return `<section class="absolute-voice-provider-simulation absolute-voice-provider-simulation--${snapshot.error ? "error" : snapshot.isRunning ? "running" : "ready"}">
483
+ <header class="absolute-voice-provider-simulation__header">
484
+ <span class="absolute-voice-provider-simulation__eyebrow">${escapeHtml2(model.title)}</span>
485
+ <strong class="absolute-voice-provider-simulation__label">${escapeHtml2(model.label)}</strong>
486
+ </header>
487
+ <p class="absolute-voice-provider-simulation__description">${escapeHtml2(model.description)}</p>
488
+ ${model.canSimulateFailure ? "" : `<p class="absolute-voice-provider-simulation__empty">${escapeHtml2(options.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure.")}</p>`}
489
+ <div class="absolute-voice-provider-simulation__actions">${failureButtons}${recoveryButtons}</div>
490
+ ${snapshot.error ? `<p class="absolute-voice-provider-simulation__error">${escapeHtml2(snapshot.error)}</p>` : ""}
491
+ ${model.resultText ? `<pre class="absolute-voice-provider-simulation__result">${escapeHtml2(model.resultText)}</pre>` : ""}
492
+ </section>`;
493
+ };
494
+ var bindVoiceProviderSimulationControls = (element, store) => {
495
+ const onClick = (event) => {
496
+ const target = event.target;
497
+ if (!(target instanceof HTMLElement)) {
498
+ return;
499
+ }
500
+ const failProvider = target.getAttribute("data-voice-provider-fail");
501
+ const recoverProvider = target.getAttribute("data-voice-provider-recover");
502
+ if (failProvider) {
503
+ store.run(failProvider, "failure").catch(() => {});
504
+ }
505
+ if (recoverProvider) {
506
+ store.run(recoverProvider, "recovery").catch(() => {});
507
+ }
508
+ };
509
+ element.addEventListener("click", onClick);
510
+ return () => element.removeEventListener("click", onClick);
511
+ };
512
+ var mountVoiceProviderSimulationControls = (element, options) => {
513
+ const store = createVoiceProviderSimulationControlsStore(options);
514
+ const render = () => {
515
+ element.innerHTML = renderVoiceProviderSimulationControlsHTML(store.getSnapshot(), options);
516
+ };
517
+ const unsubscribeStore = store.subscribe(render);
518
+ const unsubscribeDom = bindVoiceProviderSimulationControls(element, store);
519
+ render();
520
+ return {
521
+ close: () => {
522
+ unsubscribeDom();
523
+ unsubscribeStore();
524
+ store.close();
525
+ },
526
+ run: store.run
527
+ };
528
+ };
529
+ var defineVoiceProviderSimulationControlsElement = (tagName = "absolute-voice-provider-simulation") => {
530
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
531
+ return;
532
+ }
533
+ customElements.define(tagName, class AbsoluteVoiceProviderSimulationElement extends HTMLElement {
534
+ mounted;
535
+ connectedCallback() {
536
+ const providers = (this.getAttribute("providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean).map((provider) => ({ provider }));
537
+ const failureProviders = (this.getAttribute("failure-providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean);
538
+ this.mounted = mountVoiceProviderSimulationControls(this, {
539
+ failureProviders: failureProviders.length ? failureProviders : undefined,
540
+ fallbackRequiredMessage: this.getAttribute("fallback-required-message") ?? undefined,
541
+ fallbackRequiredProvider: this.getAttribute("fallback-required-provider") ?? undefined,
542
+ failureMessage: this.getAttribute("failure-message") ?? undefined,
543
+ kind: this.getAttribute("kind") ?? "stt",
544
+ pathPrefix: this.getAttribute("path-prefix") ?? undefined,
545
+ providers,
546
+ title: this.getAttribute("title") ?? undefined
547
+ });
548
+ }
549
+ disconnectedCallback() {
550
+ this.mounted?.close();
551
+ this.mounted = undefined;
552
+ }
553
+ });
554
+ };
555
+
556
+ // src/vue/useVoiceProviderSimulationControls.ts
557
+ import { onUnmounted as onUnmounted2, ref as ref2 } from "vue";
558
+ function useVoiceProviderSimulationControls(options) {
559
+ const store = createVoiceProviderSimulationControlsStore(options);
560
+ const error = ref2(null);
561
+ const isRunning = ref2(false);
562
+ const lastResult = ref2(null);
563
+ const mode = ref2(null);
564
+ const provider = ref2(null);
565
+ const updatedAt = ref2(undefined);
566
+ const sync = () => {
567
+ const snapshot = store.getSnapshot();
568
+ error.value = snapshot.error;
569
+ isRunning.value = snapshot.isRunning;
570
+ lastResult.value = snapshot.lastResult;
571
+ mode.value = snapshot.mode;
572
+ provider.value = snapshot.provider;
573
+ updatedAt.value = snapshot.updatedAt;
574
+ };
575
+ const unsubscribe = store.subscribe(sync);
576
+ sync();
577
+ onUnmounted2(() => {
578
+ unsubscribe();
579
+ store.close();
580
+ });
581
+ return {
582
+ error,
583
+ isRunning,
584
+ lastResult,
585
+ mode,
586
+ provider,
587
+ run: store.run,
588
+ updatedAt
589
+ };
590
+ }
591
+
592
+ // src/vue/VoiceProviderSimulationControls.ts
593
+ var VoiceProviderSimulationControls = defineComponent2({
594
+ name: "VoiceProviderSimulationControls",
595
+ props: {
596
+ class: { default: "", type: String },
597
+ fallbackRequiredMessage: { default: undefined, type: String },
598
+ fallbackRequiredProvider: { default: undefined, type: String },
599
+ failureMessage: { default: undefined, type: String },
600
+ failureProviders: {
601
+ default: undefined,
602
+ type: Array
603
+ },
604
+ kind: { default: "stt", type: String },
605
+ pathPrefix: { default: undefined, type: String },
606
+ providers: {
607
+ required: true,
608
+ type: Array
609
+ },
610
+ title: { default: undefined, type: String }
611
+ },
612
+ setup(props) {
613
+ const options = {
614
+ fallbackRequiredMessage: props.fallbackRequiredMessage,
615
+ fallbackRequiredProvider: props.fallbackRequiredProvider,
616
+ failureMessage: props.failureMessage,
617
+ failureProviders: props.failureProviders,
618
+ kind: props.kind,
619
+ pathPrefix: props.pathPrefix,
620
+ providers: props.providers,
621
+ title: props.title
622
+ };
623
+ const controls = useVoiceProviderSimulationControls(options);
624
+ const model = computed(() => createVoiceProviderSimulationControlsViewModel({
625
+ error: controls.error.value,
626
+ isRunning: controls.isRunning.value,
627
+ lastResult: controls.lastResult.value,
628
+ mode: controls.mode.value,
629
+ provider: controls.provider.value,
630
+ updatedAt: controls.updatedAt.value
631
+ }, options));
632
+ const run = (provider, mode) => {
633
+ controls.run(provider, mode).catch(() => {});
634
+ };
635
+ return () => h2("section", {
636
+ class: [
637
+ "absolute-voice-provider-simulation",
638
+ `absolute-voice-provider-simulation--${controls.error.value ? "error" : controls.isRunning.value ? "running" : "ready"}`,
639
+ props.class
640
+ ]
641
+ }, [
642
+ h2("header", { class: "absolute-voice-provider-simulation__header" }, [
643
+ h2("span", { class: "absolute-voice-provider-simulation__eyebrow" }, model.value.title),
644
+ h2("strong", { class: "absolute-voice-provider-simulation__label" }, model.value.label)
645
+ ]),
646
+ h2("p", { class: "absolute-voice-provider-simulation__description" }, model.value.description),
647
+ model.value.canSimulateFailure ? null : h2("p", { class: "absolute-voice-provider-simulation__empty" }, props.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure."),
648
+ h2("div", { class: "absolute-voice-provider-simulation__actions" }, [
649
+ ...model.value.failureProviders.map((provider) => h2("button", {
650
+ disabled: !model.value.canSimulateFailure || controls.isRunning.value,
651
+ key: `fail-${provider.provider}`,
652
+ onClick: () => run(provider.provider, "failure"),
653
+ type: "button"
654
+ }, `Simulate ${provider.provider} ${props.kind.toUpperCase()} failure`)),
655
+ ...model.value.providers.map((provider) => h2("button", {
656
+ disabled: controls.isRunning.value,
657
+ key: `recover-${provider.provider}`,
658
+ onClick: () => run(provider.provider, "recovery"),
659
+ type: "button"
660
+ }, `Mark ${provider.provider} recovered`))
661
+ ]),
662
+ controls.error.value ? h2("p", { class: "absolute-voice-provider-simulation__error" }, controls.error.value) : null,
663
+ model.value.resultText ? h2("pre", { class: "absolute-voice-provider-simulation__result" }, model.value.resultText) : null
664
+ ]);
665
+ }
666
+ });
667
+ // src/vue/VoiceProviderCapabilities.ts
668
+ import { computed as computed2, defineComponent as defineComponent3, h as h3 } from "vue";
669
+
670
+ // src/client/providerCapabilities.ts
671
+ var fetchVoiceProviderCapabilities = async (path = "/api/provider-capabilities", options = {}) => {
672
+ const fetchImpl = options.fetch ?? globalThis.fetch;
673
+ const response = await fetchImpl(path);
674
+ if (!response.ok) {
675
+ throw new Error(`Voice provider capabilities failed: HTTP ${response.status}`);
676
+ }
677
+ return await response.json();
678
+ };
679
+ var createVoiceProviderCapabilitiesStore = (path = "/api/provider-capabilities", options = {}) => {
680
+ const listeners = new Set;
681
+ let closed = false;
682
+ let timer;
683
+ let snapshot = {
684
+ error: null,
685
+ isLoading: false
686
+ };
687
+ const emit = () => {
688
+ for (const listener of listeners) {
689
+ listener();
690
+ }
691
+ };
692
+ const refresh = async () => {
693
+ if (closed) {
694
+ return snapshot.report;
695
+ }
696
+ snapshot = {
697
+ ...snapshot,
698
+ error: null,
699
+ isLoading: true
700
+ };
701
+ emit();
702
+ try {
703
+ const report = await fetchVoiceProviderCapabilities(path, options);
704
+ snapshot = {
705
+ error: null,
706
+ isLoading: false,
707
+ report,
708
+ updatedAt: Date.now()
709
+ };
710
+ emit();
711
+ return report;
712
+ } catch (error) {
713
+ snapshot = {
714
+ ...snapshot,
715
+ error: error instanceof Error ? error.message : String(error),
716
+ isLoading: false
717
+ };
718
+ emit();
719
+ throw error;
720
+ }
721
+ };
722
+ const close = () => {
723
+ closed = true;
724
+ if (timer) {
725
+ clearInterval(timer);
726
+ timer = undefined;
727
+ }
728
+ listeners.clear();
729
+ };
730
+ if (options.intervalMs && options.intervalMs > 0) {
731
+ timer = setInterval(() => {
732
+ refresh().catch(() => {});
733
+ }, options.intervalMs);
734
+ }
735
+ return {
736
+ close,
737
+ getServerSnapshot: () => snapshot,
738
+ getSnapshot: () => snapshot,
739
+ refresh,
740
+ subscribe: (listener) => {
741
+ listeners.add(listener);
742
+ return () => {
743
+ listeners.delete(listener);
744
+ };
745
+ }
746
+ };
747
+ };
748
+
749
+ // src/client/providerCapabilitiesWidget.ts
750
+ var DEFAULT_TITLE2 = "Provider Capabilities";
751
+ var DEFAULT_DESCRIPTION2 = "Configured, selected, and healthy voice providers for this deployment.";
752
+ var escapeHtml3 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
753
+ var formatProvider = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
754
+ var formatKind2 = (kind) => kind.toUpperCase();
755
+ var formatStatus = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
756
+ var getCapabilityDetail = (capability) => {
757
+ if (!capability.configured) {
758
+ return "Not configured in this deployment.";
759
+ }
760
+ if (capability.selected) {
761
+ return `Selected ${capability.kind.toUpperCase()} provider for new sessions.`;
762
+ }
763
+ if (capability.health?.status === "healthy") {
764
+ return "Configured and healthy fallback candidate.";
765
+ }
766
+ if (capability.health?.status === "idle") {
767
+ return "Configured; no traffic observed yet.";
768
+ }
769
+ if (capability.health?.lastError) {
770
+ return capability.health.lastError;
771
+ }
772
+ return "Configured and available.";
773
+ };
774
+ var isWarningStatus = (status) => status === "degraded" || status === "rate-limited" || status === "suppressed" || status === "unconfigured";
775
+ var createVoiceProviderCapabilitiesViewModel = (snapshot, options = {}) => {
776
+ const capabilities = (snapshot.report?.capabilities ?? []).map((capability) => ({
777
+ ...capability,
778
+ detail: getCapabilityDetail(capability),
779
+ label: `${formatProvider(capability.provider)} ${formatKind2(capability.kind)}`,
780
+ rows: [
781
+ { label: "Status", value: formatStatus(capability.status) },
782
+ { label: "Selected", value: capability.selected ? "Yes" : "No" },
783
+ { label: "Model", value: capability.model ?? "Default" },
784
+ {
785
+ label: "Features",
786
+ value: capability.features?.join(", ") || "Not specified"
787
+ },
788
+ { label: "Runs", value: String(capability.health?.runCount ?? 0) },
789
+ { label: "Errors", value: String(capability.health?.errorCount ?? 0) }
790
+ ]
791
+ }));
792
+ const warningCount = capabilities.filter((capability) => isWarningStatus(capability.status)).length;
793
+ const selectedCount = snapshot.report?.selected ?? capabilities.filter((capability) => capability.selected).length;
794
+ return {
795
+ capabilities,
796
+ description: options.description ?? DEFAULT_DESCRIPTION2,
797
+ error: snapshot.error,
798
+ isLoading: snapshot.isLoading,
799
+ label: snapshot.error ? "Unavailable" : capabilities.length ? warningCount > 0 ? `${warningCount} needs attention` : `${selectedCount} selected` : snapshot.isLoading ? "Checking" : "No capabilities",
800
+ status: snapshot.error ? "error" : capabilities.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
801
+ title: options.title ?? DEFAULT_TITLE2,
802
+ updatedAt: snapshot.updatedAt
803
+ };
804
+ };
805
+ var renderVoiceProviderCapabilitiesHTML = (snapshot, options = {}) => {
806
+ const model = createVoiceProviderCapabilitiesViewModel(snapshot, options);
807
+ const capabilities = model.capabilities.length ? `<div class="absolute-voice-provider-capabilities__providers">${model.capabilities.map((capability) => `<article class="absolute-voice-provider-capabilities__provider absolute-voice-provider-capabilities__provider--${escapeHtml3(capability.status)}">
808
+ <header>
809
+ <strong>${escapeHtml3(capability.label)}</strong>
810
+ <span>${escapeHtml3(formatStatus(capability.status))}</span>
811
+ </header>
812
+ <p>${escapeHtml3(capability.detail)}</p>
813
+ <dl>${capability.rows.map((row) => `<div>
814
+ <dt>${escapeHtml3(row.label)}</dt>
815
+ <dd>${escapeHtml3(row.value)}</dd>
816
+ </div>`).join("")}</dl>
817
+ </article>`).join("")}</div>` : '<p class="absolute-voice-provider-capabilities__empty">Configure provider capabilities to see deployment coverage.</p>';
818
+ return `<section class="absolute-voice-provider-capabilities absolute-voice-provider-capabilities--${escapeHtml3(model.status)}">
819
+ <header class="absolute-voice-provider-capabilities__header">
820
+ <span class="absolute-voice-provider-capabilities__eyebrow">${escapeHtml3(model.title)}</span>
821
+ <strong class="absolute-voice-provider-capabilities__label">${escapeHtml3(model.label)}</strong>
822
+ </header>
823
+ <p class="absolute-voice-provider-capabilities__description">${escapeHtml3(model.description)}</p>
824
+ ${capabilities}
825
+ ${model.error ? `<p class="absolute-voice-provider-capabilities__error">${escapeHtml3(model.error)}</p>` : ""}
826
+ </section>`;
827
+ };
828
+ var getVoiceProviderCapabilitiesCSS = () => `.absolute-voice-provider-capabilities{border:1px solid #bfd7ea;border-radius:20px;background:#f6fbff;color:#08131f;padding:18px;box-shadow:0 18px 40px rgba(14,51,78,.12);font-family:inherit}.absolute-voice-provider-capabilities--error,.absolute-voice-provider-capabilities--warning{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-provider-capabilities__header,.absolute-voice-provider-capabilities__provider header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-provider-capabilities__eyebrow{color:#255f85;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-provider-capabilities__label{font-size:24px;line-height:1}.absolute-voice-provider-capabilities__description,.absolute-voice-provider-capabilities__provider p,.absolute-voice-provider-capabilities__provider dt,.absolute-voice-provider-capabilities__empty{color:#405467}.absolute-voice-provider-capabilities__providers{display:grid;gap:12px;margin-top:14px}.absolute-voice-provider-capabilities__provider{background:#fff;border:1px solid #d7e7f3;border-radius:16px;padding:14px}.absolute-voice-provider-capabilities__provider--selected,.absolute-voice-provider-capabilities__provider--healthy{border-color:#86efac}.absolute-voice-provider-capabilities__provider--degraded,.absolute-voice-provider-capabilities__provider--rate-limited,.absolute-voice-provider-capabilities__provider--suppressed,.absolute-voice-provider-capabilities__provider--unconfigured{border-color:#f2a7a7}.absolute-voice-provider-capabilities__provider p{margin:10px 0}.absolute-voice-provider-capabilities__provider dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-provider-capabilities__provider div{background:#f6fbff;border:1px solid #d7e7f3;border-radius:12px;padding:8px}.absolute-voice-provider-capabilities__provider dt{font-size:12px}.absolute-voice-provider-capabilities__provider dd{font-weight:800;margin:4px 0 0}.absolute-voice-provider-capabilities__empty{margin:14px 0 0}.absolute-voice-provider-capabilities__error{color:#9f1239;font-weight:700}`;
829
+ var mountVoiceProviderCapabilities = (element, path = "/api/provider-capabilities", options = {}) => {
830
+ const store = createVoiceProviderCapabilitiesStore(path, options);
831
+ const render = () => {
832
+ element.innerHTML = renderVoiceProviderCapabilitiesHTML(store.getSnapshot(), options);
833
+ };
834
+ const unsubscribe = store.subscribe(render);
835
+ render();
836
+ store.refresh().catch(() => {});
837
+ return {
838
+ close: () => {
839
+ unsubscribe();
840
+ store.close();
841
+ },
842
+ refresh: store.refresh
843
+ };
844
+ };
845
+ var defineVoiceProviderCapabilitiesElement = (tagName = "absolute-voice-provider-capabilities") => {
846
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
847
+ return;
848
+ }
849
+ customElements.define(tagName, class AbsoluteVoiceProviderCapabilitiesElement extends HTMLElement {
850
+ mounted;
851
+ connectedCallback() {
852
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
853
+ this.mounted = mountVoiceProviderCapabilities(this, this.getAttribute("path") ?? "/api/provider-capabilities", {
854
+ description: this.getAttribute("description") ?? undefined,
855
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
856
+ title: this.getAttribute("title") ?? undefined
857
+ });
858
+ }
859
+ disconnectedCallback() {
860
+ this.mounted?.close();
861
+ this.mounted = undefined;
862
+ }
863
+ });
864
+ };
865
+
866
+ // src/vue/useVoiceProviderCapabilities.ts
867
+ import { onUnmounted as onUnmounted3, shallowRef as shallowRef2 } from "vue";
868
+ function useVoiceProviderCapabilities(path = "/api/provider-capabilities", options = {}) {
869
+ const store = createVoiceProviderCapabilitiesStore(path, options);
870
+ const error = shallowRef2(null);
871
+ const isLoading = shallowRef2(false);
872
+ const report = shallowRef2();
873
+ const updatedAt = shallowRef2(undefined);
874
+ const sync = () => {
875
+ const snapshot = store.getSnapshot();
876
+ error.value = snapshot.error;
877
+ isLoading.value = snapshot.isLoading;
878
+ report.value = snapshot.report;
879
+ updatedAt.value = snapshot.updatedAt;
880
+ };
881
+ const unsubscribe = store.subscribe(sync);
882
+ sync();
883
+ store.refresh().catch(() => {});
884
+ onUnmounted3(() => {
885
+ unsubscribe();
886
+ store.close();
887
+ });
888
+ return {
889
+ error,
890
+ isLoading,
891
+ refresh: store.refresh,
892
+ report,
893
+ updatedAt
894
+ };
895
+ }
896
+
897
+ // src/vue/VoiceProviderCapabilities.ts
898
+ var VoiceProviderCapabilities = defineComponent3({
899
+ name: "VoiceProviderCapabilities",
900
+ props: {
901
+ class: {
902
+ default: "",
903
+ type: String
904
+ },
905
+ description: {
906
+ default: undefined,
907
+ type: String
908
+ },
909
+ intervalMs: {
910
+ default: 5000,
911
+ type: Number
912
+ },
913
+ path: {
914
+ default: "/api/provider-capabilities",
915
+ type: String
916
+ },
917
+ title: {
918
+ default: undefined,
919
+ type: String
920
+ }
921
+ },
922
+ setup(props) {
923
+ const options = {
924
+ description: props.description,
925
+ intervalMs: props.intervalMs,
926
+ title: props.title
927
+ };
928
+ const capabilities = useVoiceProviderCapabilities(props.path, options);
929
+ const model = computed2(() => createVoiceProviderCapabilitiesViewModel({
930
+ error: capabilities.error.value,
931
+ isLoading: capabilities.isLoading.value,
932
+ report: capabilities.report.value,
933
+ updatedAt: capabilities.updatedAt.value
934
+ }, options));
935
+ return () => h3("section", {
936
+ class: [
937
+ "absolute-voice-provider-capabilities",
938
+ `absolute-voice-provider-capabilities--${model.value.status}`,
939
+ props.class
940
+ ]
941
+ }, [
942
+ h3("header", { class: "absolute-voice-provider-capabilities__header" }, [
943
+ h3("span", { class: "absolute-voice-provider-capabilities__eyebrow" }, model.value.title),
944
+ h3("strong", { class: "absolute-voice-provider-capabilities__label" }, model.value.label)
945
+ ]),
946
+ h3("p", { class: "absolute-voice-provider-capabilities__description" }, model.value.description),
947
+ model.value.capabilities.length ? h3("div", { class: "absolute-voice-provider-capabilities__providers" }, model.value.capabilities.map((capability) => h3("article", {
948
+ class: [
949
+ "absolute-voice-provider-capabilities__provider",
950
+ `absolute-voice-provider-capabilities__provider--${capability.status}`
951
+ ],
952
+ key: `${capability.kind}:${capability.provider}`
953
+ }, [
954
+ h3("header", [
955
+ h3("strong", capability.label),
956
+ h3("span", capability.status)
957
+ ]),
958
+ h3("p", capability.detail),
959
+ h3("dl", capability.rows.map((row) => h3("div", { key: row.label }, [
960
+ h3("dt", row.label),
961
+ h3("dd", row.value)
962
+ ])))
963
+ ]))) : h3("p", { class: "absolute-voice-provider-capabilities__empty" }, "Configure provider capabilities to see deployment coverage."),
964
+ model.value.error ? h3("p", { class: "absolute-voice-provider-capabilities__error" }, model.value.error) : null
965
+ ]);
966
+ }
967
+ });
968
+ // src/vue/VoiceProviderStatus.ts
969
+ import { computed as computed3, defineComponent as defineComponent4, h as h4 } from "vue";
970
+
971
+ // src/client/providerStatus.ts
972
+ var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
973
+ const fetchImpl = options.fetch ?? globalThis.fetch;
974
+ const response = await fetchImpl(path);
975
+ if (!response.ok) {
976
+ throw new Error(`Voice provider status failed: HTTP ${response.status}`);
977
+ }
978
+ return await response.json();
979
+ };
980
+ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
981
+ const listeners = new Set;
982
+ let closed = false;
983
+ let timer;
984
+ let snapshot = {
985
+ error: null,
986
+ isLoading: false,
987
+ providers: []
988
+ };
989
+ const emit = () => {
990
+ for (const listener of listeners) {
991
+ listener();
992
+ }
993
+ };
994
+ const refresh = async () => {
995
+ if (closed) {
996
+ return snapshot.providers;
997
+ }
998
+ snapshot = {
999
+ ...snapshot,
1000
+ error: null,
1001
+ isLoading: true
1002
+ };
1003
+ emit();
1004
+ try {
1005
+ const providers = await fetchVoiceProviderStatus(path, options);
1006
+ snapshot = {
1007
+ error: null,
1008
+ isLoading: false,
1009
+ providers,
1010
+ updatedAt: Date.now()
1011
+ };
1012
+ emit();
1013
+ return providers;
1014
+ } catch (error) {
1015
+ snapshot = {
1016
+ ...snapshot,
1017
+ error: error instanceof Error ? error.message : String(error),
1018
+ isLoading: false
1019
+ };
1020
+ emit();
1021
+ throw error;
1022
+ }
1023
+ };
1024
+ const close = () => {
1025
+ closed = true;
1026
+ if (timer) {
1027
+ clearInterval(timer);
1028
+ timer = undefined;
1029
+ }
1030
+ listeners.clear();
1031
+ };
1032
+ if (options.intervalMs && options.intervalMs > 0) {
1033
+ timer = setInterval(() => {
1034
+ refresh().catch(() => {});
1035
+ }, options.intervalMs);
1036
+ }
1037
+ return {
1038
+ close,
1039
+ getServerSnapshot: () => snapshot,
1040
+ getSnapshot: () => snapshot,
1041
+ refresh,
1042
+ subscribe: (listener) => {
1043
+ listeners.add(listener);
1044
+ return () => {
1045
+ listeners.delete(listener);
1046
+ };
1047
+ }
1048
+ };
1049
+ };
1050
+
1051
+ // src/client/providerStatusWidget.ts
1052
+ var DEFAULT_TITLE3 = "Voice Providers";
1053
+ var DEFAULT_DESCRIPTION3 = "Live provider health, fallback counts, latency, and suppression state from your self-hosted trace store.";
1054
+ var escapeHtml4 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1055
+ var formatProvider2 = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
1056
+ var formatStatus2 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
1057
+ var formatLatency = (value) => typeof value === "number" ? `${value}ms` : "No samples";
1058
+ var formatSuppression = (value) => typeof value === "number" ? `${Math.ceil(value / 1000)}s` : "None";
1059
+ var getProviderDetail = (provider) => {
1060
+ if (provider.status === "suppressed") {
1061
+ return provider.lastError ? `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)} after ${provider.lastError}.` : `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)}.`;
1062
+ }
1063
+ if (provider.status === "recoverable") {
1064
+ return "Cooldown expired; ready for recovery traffic.";
1065
+ }
1066
+ if (provider.status === "rate-limited") {
1067
+ return "Rate limit detected; router should avoid this provider.";
1068
+ }
1069
+ if (provider.status === "degraded") {
1070
+ return provider.lastError ?? "Recent provider errors detected.";
1071
+ }
1072
+ if (provider.status === "healthy") {
1073
+ return provider.recommended ? "Healthy and currently recommended." : "Healthy and available for routing.";
1074
+ }
1075
+ return "No provider traffic observed yet.";
1076
+ };
1077
+ var isWarningStatus2 = (status) => status === "degraded" || status === "rate-limited" || status === "recoverable" || status === "suppressed";
1078
+ var createVoiceProviderStatusViewModel = (snapshot, options = {}) => {
1079
+ const providers = snapshot.providers.map((provider) => ({
1080
+ ...provider,
1081
+ detail: getProviderDetail(provider),
1082
+ label: `${formatProvider2(provider.provider)}${provider.recommended ? " recommended" : ""}`,
1083
+ rows: [
1084
+ { label: "Runs", value: String(provider.runCount) },
1085
+ { label: "Avg latency", value: formatLatency(provider.averageElapsedMs) },
1086
+ { label: "Errors", value: String(provider.errorCount) },
1087
+ { label: "Timeouts", value: String(provider.timeoutCount) },
1088
+ { label: "Fallbacks", value: String(provider.fallbackCount) },
1089
+ {
1090
+ label: "Suppression",
1091
+ value: formatSuppression(provider.suppressionRemainingMs)
1092
+ }
1093
+ ]
1094
+ }));
1095
+ const warningCount = providers.filter((provider) => isWarningStatus2(provider.status)).length;
1096
+ const healthyCount = providers.filter((provider) => provider.status === "healthy").length;
1097
+ return {
1098
+ description: options.description ?? DEFAULT_DESCRIPTION3,
1099
+ error: snapshot.error,
1100
+ isLoading: snapshot.isLoading,
1101
+ label: snapshot.error ? "Unavailable" : providers.length ? warningCount > 0 ? `${warningCount} needs attention` : `${healthyCount} healthy` : snapshot.isLoading ? "Checking" : "No provider traffic",
1102
+ providers,
1103
+ status: snapshot.error ? "error" : providers.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
1104
+ title: options.title ?? DEFAULT_TITLE3,
1105
+ updatedAt: snapshot.updatedAt
1106
+ };
1107
+ };
1108
+ var renderVoiceProviderStatusHTML = (snapshot, options = {}) => {
1109
+ const model = createVoiceProviderStatusViewModel(snapshot, options);
1110
+ const providers = model.providers.length ? `<div class="absolute-voice-provider-status__providers">${model.providers.map((provider) => `<article class="absolute-voice-provider-status__provider absolute-voice-provider-status__provider--${escapeHtml4(provider.status)}">
1111
+ <header>
1112
+ <strong>${escapeHtml4(provider.label)}</strong>
1113
+ <span>${escapeHtml4(formatStatus2(provider.status))}</span>
1114
+ </header>
1115
+ <p>${escapeHtml4(provider.detail)}</p>
1116
+ <dl>${provider.rows.map((row) => `<div>
1117
+ <dt>${escapeHtml4(row.label)}</dt>
1118
+ <dd>${escapeHtml4(row.value)}</dd>
1119
+ </div>`).join("")}</dl>
1120
+ </article>`).join("")}</div>` : '<p class="absolute-voice-provider-status__empty">Run voice traffic to see provider health.</p>';
1121
+ return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${escapeHtml4(model.status)}">
1122
+ <header class="absolute-voice-provider-status__header">
1123
+ <span class="absolute-voice-provider-status__eyebrow">${escapeHtml4(model.title)}</span>
1124
+ <strong class="absolute-voice-provider-status__label">${escapeHtml4(model.label)}</strong>
1125
+ </header>
1126
+ <p class="absolute-voice-provider-status__description">${escapeHtml4(model.description)}</p>
1127
+ ${providers}
1128
+ ${model.error ? `<p class="absolute-voice-provider-status__error">${escapeHtml4(model.error)}</p>` : ""}
1129
+ </section>`;
1130
+ };
1131
+ var getVoiceProviderStatusCSS = () => `.absolute-voice-provider-status{border:1px solid #d8d2c4;border-radius:20px;background:#fffaf0;color:#16130d;padding:18px;box-shadow:0 18px 40px rgba(47,37,18,.12);font-family:inherit}.absolute-voice-provider-status--error,.absolute-voice-provider-status--warning{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-provider-status__header,.absolute-voice-provider-status__provider header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-provider-status__eyebrow{color:#73664f;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-provider-status__label{font-size:24px;line-height:1}.absolute-voice-provider-status__description,.absolute-voice-provider-status__provider p,.absolute-voice-provider-status__provider dt,.absolute-voice-provider-status__empty{color:#514733}.absolute-voice-provider-status__providers{display:grid;gap:12px;margin-top:14px}.absolute-voice-provider-status__provider{background:#fff;border:1px solid #eee4d2;border-radius:16px;padding:14px}.absolute-voice-provider-status__provider--degraded,.absolute-voice-provider-status__provider--rate-limited,.absolute-voice-provider-status__provider--suppressed{border-color:#f2a7a7}.absolute-voice-provider-status__provider--recoverable{border-color:#fbbf24}.absolute-voice-provider-status__provider p{margin:10px 0}.absolute-voice-provider-status__provider dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-provider-status__provider div{background:#fffaf0;border:1px solid #eee4d2;border-radius:12px;padding:8px}.absolute-voice-provider-status__provider dt{font-size:12px}.absolute-voice-provider-status__provider dd{font-weight:800;margin:4px 0 0}.absolute-voice-provider-status__empty{margin:14px 0 0}.absolute-voice-provider-status__error{color:#9f1239;font-weight:700}`;
1132
+ var mountVoiceProviderStatus = (element, path = "/api/provider-status", options = {}) => {
1133
+ const store = createVoiceProviderStatusStore(path, options);
1134
+ const render = () => {
1135
+ element.innerHTML = renderVoiceProviderStatusHTML(store.getSnapshot(), options);
1136
+ };
1137
+ const unsubscribe = store.subscribe(render);
1138
+ render();
1139
+ store.refresh().catch(() => {});
1140
+ return {
1141
+ close: () => {
1142
+ unsubscribe();
1143
+ store.close();
1144
+ },
1145
+ refresh: store.refresh
1146
+ };
1147
+ };
1148
+ var defineVoiceProviderStatusElement = (tagName = "absolute-voice-provider-status") => {
1149
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
1150
+ return;
1151
+ }
1152
+ customElements.define(tagName, class AbsoluteVoiceProviderStatusElement extends HTMLElement {
1153
+ mounted;
1154
+ connectedCallback() {
1155
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
1156
+ this.mounted = mountVoiceProviderStatus(this, this.getAttribute("path") ?? "/api/provider-status", {
1157
+ description: this.getAttribute("description") ?? undefined,
1158
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
1159
+ title: this.getAttribute("title") ?? undefined
1160
+ });
1161
+ }
1162
+ disconnectedCallback() {
1163
+ this.mounted?.close();
1164
+ this.mounted = undefined;
1165
+ }
1166
+ });
1167
+ };
1168
+
1169
+ // src/vue/useVoiceProviderStatus.ts
1170
+ import { onUnmounted as onUnmounted4, ref as ref3, shallowRef as shallowRef3 } from "vue";
1171
+ function useVoiceProviderStatus(path = "/api/provider-status", options = {}) {
1172
+ const store = createVoiceProviderStatusStore(path, options);
1173
+ const error = ref3(null);
1174
+ const isLoading = ref3(false);
1175
+ const providers = shallowRef3([]);
1176
+ const updatedAt = ref3(undefined);
1177
+ const sync = () => {
1178
+ const snapshot = store.getSnapshot();
1179
+ error.value = snapshot.error;
1180
+ isLoading.value = snapshot.isLoading;
1181
+ providers.value = [...snapshot.providers];
1182
+ updatedAt.value = snapshot.updatedAt;
1183
+ };
1184
+ const unsubscribe = store.subscribe(sync);
1185
+ sync();
1186
+ store.refresh().catch(() => {});
1187
+ onUnmounted4(() => {
1188
+ unsubscribe();
1189
+ store.close();
1190
+ });
1191
+ return {
1192
+ error,
1193
+ isLoading,
1194
+ providers,
1195
+ refresh: store.refresh,
1196
+ updatedAt
1197
+ };
1198
+ }
1199
+
1200
+ // src/vue/VoiceProviderStatus.ts
1201
+ var VoiceProviderStatus = defineComponent4({
1202
+ name: "VoiceProviderStatus",
1203
+ props: {
1204
+ class: {
1205
+ default: "",
1206
+ type: String
1207
+ },
1208
+ description: {
1209
+ default: undefined,
1210
+ type: String
1211
+ },
1212
+ intervalMs: {
1213
+ default: 5000,
1214
+ type: Number
1215
+ },
1216
+ path: {
1217
+ default: "/api/provider-status",
1218
+ type: String
1219
+ },
1220
+ title: {
1221
+ default: undefined,
1222
+ type: String
1223
+ }
1224
+ },
1225
+ setup(props) {
1226
+ const options = {
1227
+ description: props.description,
1228
+ intervalMs: props.intervalMs,
1229
+ title: props.title
1230
+ };
1231
+ const status = useVoiceProviderStatus(props.path, options);
1232
+ const model = computed3(() => createVoiceProviderStatusViewModel({
1233
+ error: status.error.value,
1234
+ isLoading: status.isLoading.value,
1235
+ providers: status.providers.value,
1236
+ updatedAt: status.updatedAt.value
1237
+ }, options));
1238
+ return () => h4("section", {
1239
+ class: [
1240
+ "absolute-voice-provider-status",
1241
+ `absolute-voice-provider-status--${model.value.status}`,
1242
+ props.class
1243
+ ]
1244
+ }, [
1245
+ h4("header", { class: "absolute-voice-provider-status__header" }, [
1246
+ h4("span", { class: "absolute-voice-provider-status__eyebrow" }, model.value.title),
1247
+ h4("strong", { class: "absolute-voice-provider-status__label" }, model.value.label)
1248
+ ]),
1249
+ h4("p", { class: "absolute-voice-provider-status__description" }, model.value.description),
1250
+ model.value.providers.length ? h4("div", { class: "absolute-voice-provider-status__providers" }, model.value.providers.map((provider) => h4("article", {
1251
+ class: [
1252
+ "absolute-voice-provider-status__provider",
1253
+ `absolute-voice-provider-status__provider--${provider.status}`
1254
+ ],
1255
+ key: provider.provider
1256
+ }, [
1257
+ h4("header", [
1258
+ h4("strong", provider.label),
1259
+ h4("span", provider.status)
1260
+ ]),
1261
+ h4("p", provider.detail),
1262
+ h4("dl", provider.rows.map((row) => h4("div", { key: row.label }, [
1263
+ h4("dt", row.label),
1264
+ h4("dd", row.value)
1265
+ ])))
1266
+ ]))) : h4("p", { class: "absolute-voice-provider-status__empty" }, "Run voice traffic to see provider health."),
1267
+ model.value.error ? h4("p", { class: "absolute-voice-provider-status__error" }, model.value.error) : null
1268
+ ]);
1269
+ }
1270
+ });
1271
+ // src/vue/VoiceRoutingStatus.ts
1272
+ import { computed as computed4, defineComponent as defineComponent5, h as h5 } from "vue";
1273
+
1274
+ // src/client/routingStatus.ts
1275
+ var fetchVoiceRoutingStatus = async (path = "/api/routing/latest", options = {}) => {
1276
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1277
+ const response = await fetchImpl(path);
1278
+ if (!response.ok) {
1279
+ throw new Error(`Voice routing status failed: HTTP ${response.status}`);
1280
+ }
1281
+ return await response.json();
1282
+ };
1283
+ var createVoiceRoutingStatusStore = (path = "/api/routing/latest", options = {}) => {
1284
+ const listeners = new Set;
1285
+ let closed = false;
1286
+ let timer;
1287
+ let snapshot = {
1288
+ decision: null,
1289
+ error: null,
1290
+ isLoading: false
1291
+ };
1292
+ const emit = () => {
1293
+ for (const listener of listeners) {
1294
+ listener();
1295
+ }
1296
+ };
1297
+ const refresh = async () => {
1298
+ if (closed) {
1299
+ return snapshot.decision;
1300
+ }
1301
+ snapshot = {
1302
+ ...snapshot,
1303
+ error: null,
1304
+ isLoading: true
1305
+ };
1306
+ emit();
1307
+ try {
1308
+ const decision = await fetchVoiceRoutingStatus(path, options);
1309
+ snapshot = {
1310
+ decision,
1311
+ error: null,
1312
+ isLoading: false,
1313
+ updatedAt: Date.now()
1314
+ };
1315
+ emit();
1316
+ return decision;
1317
+ } catch (error) {
1318
+ snapshot = {
1319
+ ...snapshot,
1320
+ error: error instanceof Error ? error.message : String(error),
1321
+ isLoading: false
1322
+ };
1323
+ emit();
1324
+ throw error;
1325
+ }
1326
+ };
1327
+ const close = () => {
1328
+ closed = true;
1329
+ if (timer) {
1330
+ clearInterval(timer);
1331
+ timer = undefined;
1332
+ }
1333
+ listeners.clear();
1334
+ };
1335
+ if (options.intervalMs && options.intervalMs > 0) {
1336
+ timer = setInterval(() => {
1337
+ refresh().catch(() => {});
1338
+ }, options.intervalMs);
1339
+ }
1340
+ return {
1341
+ close,
1342
+ getServerSnapshot: () => snapshot,
1343
+ getSnapshot: () => snapshot,
1344
+ refresh,
1345
+ subscribe: (listener) => {
1346
+ listeners.add(listener);
1347
+ return () => {
1348
+ listeners.delete(listener);
1349
+ };
1350
+ }
1351
+ };
1352
+ };
1353
+
1354
+ // src/client/routingStatusWidget.ts
1355
+ var DEFAULT_TITLE4 = "Voice Routing";
1356
+ var DEFAULT_DESCRIPTION4 = "Latest provider routing decision from the self-hosted trace store.";
1357
+ var escapeHtml5 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1358
+ var formatValue = (value, fallback = "None") => typeof value === "string" && value.trim() ? value : typeof value === "number" && Number.isFinite(value) ? String(value) : fallback;
1359
+ var createVoiceRoutingStatusViewModel = (snapshot, options = {}) => {
1360
+ const decision = snapshot.decision;
1361
+ const rows = decision ? [
1362
+ { label: "Kind", value: decision.kind.toUpperCase() },
1363
+ { label: "Policy", value: formatValue(decision.routing, "Unknown") },
1364
+ { label: "Provider", value: formatValue(decision.provider, "Unknown") },
1365
+ {
1366
+ label: "Selected",
1367
+ value: formatValue(decision.selectedProvider, "Unknown")
1368
+ },
1369
+ {
1370
+ label: "Fallback",
1371
+ value: formatValue(decision.fallbackProvider)
1372
+ },
1373
+ { label: "Status", value: formatValue(decision.status, "unknown") },
1374
+ {
1375
+ label: "Latency budget",
1376
+ value: typeof decision.latencyBudgetMs === "number" ? `${decision.latencyBudgetMs}ms` : "None"
1377
+ }
1378
+ ] : [];
1379
+ return {
1380
+ decision,
1381
+ description: options.description ?? DEFAULT_DESCRIPTION4,
1382
+ error: snapshot.error,
1383
+ isLoading: snapshot.isLoading,
1384
+ label: snapshot.error ? "Unavailable" : decision ? `${formatValue(decision.kind).toUpperCase()} ${formatValue(decision.status, "unknown")}` : snapshot.isLoading ? "Checking" : "No routing yet",
1385
+ rows,
1386
+ status: snapshot.error ? "error" : decision ? "ready" : snapshot.isLoading ? "loading" : "empty",
1387
+ title: options.title ?? DEFAULT_TITLE4,
1388
+ updatedAt: snapshot.updatedAt
1389
+ };
1390
+ };
1391
+ var renderVoiceRoutingStatusHTML = (snapshot, options = {}) => {
1392
+ const model = createVoiceRoutingStatusViewModel(snapshot, options);
1393
+ const rows = model.rows.length ? `<div class="absolute-voice-routing-status__grid">${model.rows.map((row) => `<div>
1394
+ <span>${escapeHtml5(row.label)}</span>
1395
+ <strong>${escapeHtml5(row.value)}</strong>
1396
+ </div>`).join("")}</div>` : '<p class="absolute-voice-routing-status__empty">Start a voice session to see the selected provider.</p>';
1397
+ return `<section class="absolute-voice-routing-status absolute-voice-routing-status--${escapeHtml5(model.status)}">
1398
+ <header class="absolute-voice-routing-status__header">
1399
+ <span class="absolute-voice-routing-status__eyebrow">${escapeHtml5(model.title)}</span>
1400
+ <strong class="absolute-voice-routing-status__label">${escapeHtml5(model.label)}</strong>
1401
+ </header>
1402
+ <p class="absolute-voice-routing-status__description">${escapeHtml5(model.description)}</p>
1403
+ ${rows}
1404
+ ${model.error ? `<p class="absolute-voice-routing-status__error">${escapeHtml5(model.error)}</p>` : ""}
1405
+ </section>`;
1406
+ };
1407
+ var getVoiceRoutingStatusCSS = () => `.absolute-voice-routing-status{border:1px solid #d8d2c4;border-radius:20px;background:#fffaf0;color:#16130d;padding:18px;box-shadow:0 18px 40px rgba(47,37,18,.12);font-family:inherit}.absolute-voice-routing-status--error{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-routing-status__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-routing-status__eyebrow{color:#73664f;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-routing-status__label{font-size:24px;line-height:1}.absolute-voice-routing-status__description{color:#514733;margin:12px 0 0}.absolute-voice-routing-status__grid{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin-top:14px}.absolute-voice-routing-status__grid div{background:#fff;border:1px solid #eee4d2;border-radius:14px;padding:10px 12px}.absolute-voice-routing-status__grid span{color:#655944;display:block;font-size:12px;margin-bottom:4px}.absolute-voice-routing-status__grid strong{overflow-wrap:anywhere}.absolute-voice-routing-status__empty{color:#655944;margin:14px 0 0}.absolute-voice-routing-status__error{color:#9f1239;font-weight:700}`;
1408
+ var mountVoiceRoutingStatus = (element, path = "/api/routing/latest", options = {}) => {
1409
+ const store = createVoiceRoutingStatusStore(path, options);
1410
+ const render = () => {
1411
+ element.innerHTML = renderVoiceRoutingStatusHTML(store.getSnapshot(), options);
1412
+ };
1413
+ const unsubscribe = store.subscribe(render);
1414
+ render();
1415
+ store.refresh().catch(() => {});
1416
+ return {
1417
+ close: () => {
1418
+ unsubscribe();
1419
+ store.close();
1420
+ },
1421
+ refresh: store.refresh
1422
+ };
1423
+ };
1424
+ var defineVoiceRoutingStatusElement = (tagName = "absolute-voice-routing-status") => {
1425
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
1426
+ return;
1427
+ }
1428
+ customElements.define(tagName, class AbsoluteVoiceRoutingStatusElement extends HTMLElement {
1429
+ mounted;
1430
+ connectedCallback() {
1431
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
1432
+ this.mounted = mountVoiceRoutingStatus(this, this.getAttribute("path") ?? "/api/routing/latest", {
1433
+ description: this.getAttribute("description") ?? undefined,
1434
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
1435
+ title: this.getAttribute("title") ?? undefined
1436
+ });
1437
+ }
1438
+ disconnectedCallback() {
1439
+ this.mounted?.close();
1440
+ this.mounted = undefined;
1441
+ }
1442
+ });
1443
+ };
1444
+
1445
+ // src/vue/useVoiceRoutingStatus.ts
1446
+ import { onUnmounted as onUnmounted5, ref as ref4, shallowRef as shallowRef4 } from "vue";
1447
+ function useVoiceRoutingStatus(path = "/api/routing/latest", options = {}) {
1448
+ const store = createVoiceRoutingStatusStore(path, options);
1449
+ const decision = shallowRef4(null);
1450
+ const error = ref4(null);
1451
+ const isLoading = ref4(false);
1452
+ const updatedAt = ref4(undefined);
1453
+ const sync = () => {
1454
+ const snapshot = store.getSnapshot();
1455
+ decision.value = snapshot.decision;
1456
+ error.value = snapshot.error;
1457
+ isLoading.value = snapshot.isLoading;
1458
+ updatedAt.value = snapshot.updatedAt;
1459
+ };
1460
+ const unsubscribe = store.subscribe(sync);
1461
+ sync();
1462
+ store.refresh().catch(() => {});
1463
+ onUnmounted5(() => {
1464
+ unsubscribe();
1465
+ store.close();
1466
+ });
1467
+ return {
1468
+ decision,
1469
+ error,
1470
+ isLoading,
1471
+ refresh: store.refresh,
1472
+ updatedAt
1473
+ };
1474
+ }
1475
+
1476
+ // src/vue/VoiceRoutingStatus.ts
1477
+ var VoiceRoutingStatus = defineComponent5({
1478
+ name: "VoiceRoutingStatus",
1479
+ props: {
1480
+ class: {
1481
+ default: "",
1482
+ type: String
1483
+ },
1484
+ description: {
1485
+ default: undefined,
1486
+ type: String
1487
+ },
1488
+ intervalMs: {
1489
+ default: 5000,
1490
+ type: Number
1491
+ },
1492
+ path: {
1493
+ default: "/api/routing/latest",
1494
+ type: String
1495
+ },
1496
+ title: {
1497
+ default: undefined,
1498
+ type: String
1499
+ }
1500
+ },
1501
+ setup(props) {
1502
+ const options = {
1503
+ description: props.description,
1504
+ intervalMs: props.intervalMs,
1505
+ title: props.title
1506
+ };
1507
+ const status = useVoiceRoutingStatus(props.path, options);
1508
+ const model = computed4(() => createVoiceRoutingStatusViewModel({
1509
+ decision: status.decision.value,
1510
+ error: status.error.value,
1511
+ isLoading: status.isLoading.value,
1512
+ updatedAt: status.updatedAt.value
1513
+ }, options));
1514
+ return () => h5("section", {
1515
+ class: [
1516
+ "absolute-voice-routing-status",
1517
+ `absolute-voice-routing-status--${model.value.status}`,
1518
+ props.class
1519
+ ]
1520
+ }, [
1521
+ h5("header", { class: "absolute-voice-routing-status__header" }, [
1522
+ h5("span", { class: "absolute-voice-routing-status__eyebrow" }, model.value.title),
1523
+ h5("strong", { class: "absolute-voice-routing-status__label" }, model.value.label)
1524
+ ]),
1525
+ h5("p", { class: "absolute-voice-routing-status__description" }, model.value.description),
1526
+ model.value.rows.length ? h5("div", { class: "absolute-voice-routing-status__grid" }, model.value.rows.map((row) => h5("div", { key: row.label }, [
1527
+ h5("span", row.label),
1528
+ h5("strong", row.value)
1529
+ ]))) : h5("p", { class: "absolute-voice-routing-status__empty" }, "Start a voice session to see the selected provider."),
1530
+ model.value.error ? h5("p", { class: "absolute-voice-routing-status__error" }, model.value.error) : null
1531
+ ]);
1532
+ }
1533
+ });
1534
+ // src/vue/VoiceTurnLatency.ts
1535
+ import { computed as computed5, defineComponent as defineComponent6, h as h6 } from "vue";
1536
+
1537
+ // src/client/turnLatency.ts
1538
+ var fetchVoiceTurnLatency = async (path = "/api/turn-latency", options = {}) => {
1539
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1540
+ const response = await fetchImpl(path);
1541
+ if (!response.ok) {
1542
+ throw new Error(`Voice turn latency failed: HTTP ${response.status}`);
1543
+ }
1544
+ return await response.json();
1545
+ };
1546
+ var runVoiceTurnLatencyProof = async (path, options = {}) => {
1547
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1548
+ const response = await fetchImpl(path, { method: "POST" });
1549
+ if (!response.ok) {
1550
+ throw new Error(`Voice turn latency proof failed: HTTP ${response.status}`);
1551
+ }
1552
+ return response.json();
1553
+ };
1554
+ var createVoiceTurnLatencyStore = (path = "/api/turn-latency", options = {}) => {
1555
+ const listeners = new Set;
1556
+ let closed = false;
1557
+ let timer;
1558
+ let snapshot = {
1559
+ error: null,
1560
+ isLoading: false
1561
+ };
1562
+ const emit = () => {
1563
+ for (const listener of listeners) {
1564
+ listener();
1565
+ }
1566
+ };
1567
+ const refresh = async () => {
1568
+ if (closed) {
1569
+ return snapshot.report;
1570
+ }
1571
+ snapshot = { ...snapshot, error: null, isLoading: true };
1572
+ emit();
1573
+ try {
1574
+ const report = await fetchVoiceTurnLatency(path, options);
1575
+ snapshot = {
1576
+ error: null,
1577
+ isLoading: false,
1578
+ report,
1579
+ updatedAt: Date.now()
1580
+ };
1581
+ emit();
1582
+ return report;
1583
+ } catch (error) {
1584
+ snapshot = {
1585
+ ...snapshot,
1586
+ error: error instanceof Error ? error.message : String(error),
1587
+ isLoading: false
1588
+ };
1589
+ emit();
1590
+ throw error;
1591
+ }
1592
+ };
1593
+ const runProof = async () => {
1594
+ if (!options.proofPath) {
1595
+ throw new Error("Voice turn latency proof path is not configured.");
1596
+ }
1597
+ snapshot = { ...snapshot, error: null, isLoading: true };
1598
+ emit();
1599
+ try {
1600
+ await runVoiceTurnLatencyProof(options.proofPath, options);
1601
+ return await refresh();
1602
+ } catch (error) {
1603
+ snapshot = {
1604
+ ...snapshot,
1605
+ error: error instanceof Error ? error.message : String(error),
1606
+ isLoading: false
1607
+ };
1608
+ emit();
1609
+ throw error;
1610
+ }
1611
+ };
1612
+ const close = () => {
1613
+ closed = true;
1614
+ if (timer) {
1615
+ clearInterval(timer);
1616
+ timer = undefined;
1617
+ }
1618
+ listeners.clear();
1619
+ };
1620
+ if (options.intervalMs && options.intervalMs > 0) {
1621
+ timer = setInterval(() => {
1622
+ refresh().catch(() => {});
1623
+ }, options.intervalMs);
1624
+ }
1625
+ return {
1626
+ close,
1627
+ getServerSnapshot: () => snapshot,
1628
+ getSnapshot: () => snapshot,
1629
+ refresh,
1630
+ runProof,
1631
+ subscribe: (listener) => {
1632
+ listeners.add(listener);
1633
+ return () => {
1634
+ listeners.delete(listener);
1635
+ };
1636
+ }
1637
+ };
1638
+ };
1639
+
1640
+ // src/client/turnLatencyWidget.ts
1641
+ var DEFAULT_TITLE5 = "Turn Latency";
1642
+ var DEFAULT_DESCRIPTION5 = "Per-turn timing from first transcript to commit and assistant response start.";
1643
+ var DEFAULT_PROOF_LABEL = "Run latency proof";
1644
+ var escapeHtml6 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1645
+ var formatMs = (value) => typeof value === "number" ? `${Math.round(value)}ms` : "n/a";
1646
+ var createVoiceTurnLatencyViewModel = (snapshot, options = {}) => {
1647
+ const turns = (snapshot.report?.turns ?? []).map((turn) => ({
1648
+ ...turn,
1649
+ label: turn.text || "Empty turn",
1650
+ rows: turn.stages.map((stage) => ({
1651
+ label: stage.label,
1652
+ value: formatMs(stage.valueMs)
1653
+ }))
1654
+ }));
1655
+ const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
1656
+ const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
1657
+ return {
1658
+ description: options.description ?? DEFAULT_DESCRIPTION5,
1659
+ error: snapshot.error,
1660
+ isLoading: snapshot.isLoading,
1661
+ label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} slow` : warningCount > 0 ? `${warningCount} warnings` : `avg ${formatMs(snapshot.report?.averageTotalMs)}` : snapshot.isLoading ? "Checking" : "No turns",
1662
+ proofLabel: options.proofPath ? options.proofLabel ?? DEFAULT_PROOF_LABEL : undefined,
1663
+ showProofAction: Boolean(options.proofPath),
1664
+ status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
1665
+ title: options.title ?? DEFAULT_TITLE5,
1666
+ turns,
1667
+ updatedAt: snapshot.updatedAt
1668
+ };
1669
+ };
1670
+ var renderVoiceTurnLatencyHTML = (snapshot, options = {}) => {
1671
+ const model = createVoiceTurnLatencyViewModel(snapshot, options);
1672
+ const turns = model.turns.length ? `<div class="absolute-voice-turn-latency__turns">${model.turns.map((turn) => `<article class="absolute-voice-turn-latency__turn absolute-voice-turn-latency__turn--${escapeHtml6(turn.status)}">
1673
+ <header>
1674
+ <strong>${escapeHtml6(turn.label)}</strong>
1675
+ <span>${escapeHtml6(turn.status)}</span>
1676
+ </header>
1677
+ <dl>${turn.rows.map((row) => `<div>
1678
+ <dt>${escapeHtml6(row.label)}</dt>
1679
+ <dd>${escapeHtml6(row.value)}</dd>
1680
+ </div>`).join("")}</dl>
1681
+ </article>`).join("")}</div>` : '<p class="absolute-voice-turn-latency__empty">Complete a voice turn to see latency diagnostics.</p>';
1682
+ return `<section class="absolute-voice-turn-latency absolute-voice-turn-latency--${escapeHtml6(model.status)}">
1683
+ <header class="absolute-voice-turn-latency__header">
1684
+ <span class="absolute-voice-turn-latency__eyebrow">${escapeHtml6(model.title)}</span>
1685
+ <strong class="absolute-voice-turn-latency__label">${escapeHtml6(model.label)}</strong>
1686
+ </header>
1687
+ <p class="absolute-voice-turn-latency__description">${escapeHtml6(model.description)}</p>
1688
+ ${model.showProofAction ? `<button class="absolute-voice-turn-latency__proof" data-absolute-voice-turn-latency-proof type="button">${escapeHtml6(model.proofLabel ?? DEFAULT_PROOF_LABEL)}</button>` : ""}
1689
+ ${turns}
1690
+ ${model.error ? `<p class="absolute-voice-turn-latency__error">${escapeHtml6(model.error)}</p>` : ""}
1691
+ </section>`;
1692
+ };
1693
+ var mountVoiceTurnLatency = (element, path = "/api/turn-latency", options = {}) => {
1694
+ const store = createVoiceTurnLatencyStore(path, options);
1695
+ const render = () => {
1696
+ element.innerHTML = renderVoiceTurnLatencyHTML(store.getSnapshot(), options);
1697
+ };
1698
+ const handleClick = (event) => {
1699
+ const target = event.target;
1700
+ if (target instanceof Element && target.closest("[data-absolute-voice-turn-latency-proof]")) {
1701
+ store.runProof().catch(() => {});
1702
+ }
1703
+ };
1704
+ const unsubscribe = store.subscribe(render);
1705
+ element.addEventListener("click", handleClick);
1706
+ render();
1707
+ store.refresh().catch(() => {});
1708
+ return {
1709
+ close: () => {
1710
+ element.removeEventListener("click", handleClick);
1711
+ unsubscribe();
1712
+ store.close();
1713
+ },
1714
+ refresh: store.refresh
1715
+ };
1716
+ };
1717
+ var defineVoiceTurnLatencyElement = (tagName = "absolute-voice-turn-latency") => {
1718
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
1719
+ return;
1720
+ }
1721
+ customElements.define(tagName, class AbsoluteVoiceTurnLatencyElement extends HTMLElement {
1722
+ mounted;
1723
+ connectedCallback() {
1724
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
1725
+ this.mounted = mountVoiceTurnLatency(this, this.getAttribute("path") ?? "/api/turn-latency", {
1726
+ description: this.getAttribute("description") ?? undefined,
1727
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
1728
+ proofLabel: this.getAttribute("proof-label") ?? undefined,
1729
+ proofPath: this.getAttribute("proof-path") ?? undefined,
1730
+ title: this.getAttribute("title") ?? undefined
1731
+ });
1732
+ }
1733
+ disconnectedCallback() {
1734
+ this.mounted?.close();
1735
+ this.mounted = undefined;
1736
+ }
1737
+ });
1738
+ };
1739
+
1740
+ // src/vue/useVoiceTurnLatency.ts
1741
+ import { onUnmounted as onUnmounted6, shallowRef as shallowRef5 } from "vue";
1742
+ function useVoiceTurnLatency(path = "/api/turn-latency", options = {}) {
1743
+ const store = createVoiceTurnLatencyStore(path, options);
1744
+ const error = shallowRef5(null);
1745
+ const isLoading = shallowRef5(false);
1746
+ const report = shallowRef5();
1747
+ const updatedAt = shallowRef5(undefined);
1748
+ const sync = () => {
1749
+ const snapshot = store.getSnapshot();
1750
+ error.value = snapshot.error;
1751
+ isLoading.value = snapshot.isLoading;
1752
+ report.value = snapshot.report;
1753
+ updatedAt.value = snapshot.updatedAt;
1754
+ };
1755
+ const unsubscribe = store.subscribe(sync);
1756
+ sync();
1757
+ store.refresh().catch(() => {});
1758
+ onUnmounted6(() => {
1759
+ unsubscribe();
1760
+ store.close();
1761
+ });
1762
+ return {
1763
+ error,
1764
+ isLoading,
1765
+ refresh: store.refresh,
1766
+ report,
1767
+ runProof: store.runProof,
1768
+ updatedAt
1769
+ };
1770
+ }
1771
+
1772
+ // src/vue/VoiceTurnLatency.ts
1773
+ var VoiceTurnLatency = defineComponent6({
1774
+ name: "VoiceTurnLatency",
1775
+ props: {
1776
+ class: { default: "", type: String },
1777
+ description: { default: undefined, type: String },
1778
+ intervalMs: { default: 5000, type: Number },
1779
+ path: { default: "/api/turn-latency", type: String },
1780
+ proofLabel: { default: undefined, type: String },
1781
+ proofPath: { default: undefined, type: String },
1782
+ title: { default: undefined, type: String }
1783
+ },
1784
+ setup(props) {
1785
+ const options = {
1786
+ description: props.description,
1787
+ intervalMs: props.intervalMs,
1788
+ proofLabel: props.proofLabel,
1789
+ proofPath: props.proofPath,
1790
+ title: props.title
1791
+ };
1792
+ const latency = useVoiceTurnLatency(props.path, options);
1793
+ const model = computed5(() => createVoiceTurnLatencyViewModel({
1794
+ error: latency.error.value,
1795
+ isLoading: latency.isLoading.value,
1796
+ report: latency.report.value,
1797
+ updatedAt: latency.updatedAt.value
1798
+ }, options));
1799
+ return () => h6("section", {
1800
+ class: [
1801
+ "absolute-voice-turn-latency",
1802
+ `absolute-voice-turn-latency--${model.value.status}`,
1803
+ props.class
1804
+ ]
1805
+ }, [
1806
+ h6("header", { class: "absolute-voice-turn-latency__header" }, [
1807
+ h6("span", { class: "absolute-voice-turn-latency__eyebrow" }, model.value.title),
1808
+ h6("strong", { class: "absolute-voice-turn-latency__label" }, model.value.label)
1809
+ ]),
1810
+ h6("p", { class: "absolute-voice-turn-latency__description" }, model.value.description),
1811
+ model.value.showProofAction ? h6("button", {
1812
+ class: "absolute-voice-turn-latency__proof",
1813
+ onClick: () => {
1814
+ latency.runProof().catch(() => {});
1815
+ },
1816
+ type: "button"
1817
+ }, model.value.proofLabel) : null,
1818
+ model.value.turns.length ? h6("div", { class: "absolute-voice-turn-latency__turns" }, model.value.turns.map((turn) => h6("article", {
1819
+ class: [
1820
+ "absolute-voice-turn-latency__turn",
1821
+ `absolute-voice-turn-latency__turn--${turn.status}`
1822
+ ],
1823
+ key: `${turn.sessionId}:${turn.turnId}`
1824
+ }, [
1825
+ h6("header", [
1826
+ h6("strong", turn.label),
1827
+ h6("span", turn.status)
1828
+ ]),
1829
+ h6("dl", turn.rows.map((row) => h6("div", { key: row.label }, [
1830
+ h6("dt", row.label),
1831
+ h6("dd", row.value)
1832
+ ])))
1833
+ ]))) : h6("p", { class: "absolute-voice-turn-latency__empty" }, "Complete a voice turn to see latency diagnostics."),
1834
+ model.value.error ? h6("p", { class: "absolute-voice-turn-latency__error" }, model.value.error) : null
1835
+ ]);
1836
+ }
1837
+ });
1838
+ // src/vue/VoiceTurnQuality.ts
1839
+ import { computed as computed6, defineComponent as defineComponent7, h as h7 } from "vue";
1840
+
1841
+ // src/client/turnQuality.ts
1842
+ var fetchVoiceTurnQuality = async (path = "/api/turn-quality", options = {}) => {
1843
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1844
+ const response = await fetchImpl(path);
1845
+ if (!response.ok) {
1846
+ throw new Error(`Voice turn quality failed: HTTP ${response.status}`);
1847
+ }
1848
+ return await response.json();
1849
+ };
1850
+ var createVoiceTurnQualityStore = (path = "/api/turn-quality", options = {}) => {
1851
+ const listeners = new Set;
1852
+ let closed = false;
1853
+ let timer;
1854
+ let snapshot = {
1855
+ error: null,
1856
+ isLoading: false
1857
+ };
1858
+ const emit = () => {
1859
+ for (const listener of listeners) {
1860
+ listener();
1861
+ }
1862
+ };
1863
+ const refresh = async () => {
1864
+ if (closed) {
1865
+ return snapshot.report;
1866
+ }
1867
+ snapshot = {
1868
+ ...snapshot,
1869
+ error: null,
1870
+ isLoading: true
1871
+ };
1872
+ emit();
1873
+ try {
1874
+ const report = await fetchVoiceTurnQuality(path, options);
1875
+ snapshot = {
1876
+ error: null,
1877
+ isLoading: false,
1878
+ report,
1879
+ updatedAt: Date.now()
1880
+ };
1881
+ emit();
1882
+ return report;
1883
+ } catch (error) {
1884
+ snapshot = {
1885
+ ...snapshot,
1886
+ error: error instanceof Error ? error.message : String(error),
1887
+ isLoading: false
1888
+ };
1889
+ emit();
1890
+ throw error;
1891
+ }
1892
+ };
1893
+ const close = () => {
1894
+ closed = true;
1895
+ if (timer) {
1896
+ clearInterval(timer);
1897
+ timer = undefined;
1898
+ }
1899
+ listeners.clear();
1900
+ };
1901
+ if (options.intervalMs && options.intervalMs > 0) {
1902
+ timer = setInterval(() => {
1903
+ refresh().catch(() => {});
1904
+ }, options.intervalMs);
1905
+ }
1906
+ return {
1907
+ close,
1908
+ getServerSnapshot: () => snapshot,
1909
+ getSnapshot: () => snapshot,
1910
+ refresh,
1911
+ subscribe: (listener) => {
1912
+ listeners.add(listener);
1913
+ return () => {
1914
+ listeners.delete(listener);
1915
+ };
1916
+ }
1917
+ };
1918
+ };
1919
+
1920
+ // src/client/turnQualityWidget.ts
1921
+ var DEFAULT_TITLE6 = "Turn Quality";
1922
+ var DEFAULT_DESCRIPTION6 = "Per-turn STT confidence, fallback selection, corrections, and transcript coverage.";
1923
+ var escapeHtml7 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1924
+ var formatConfidence = (value) => typeof value === "number" ? `${Math.round(value * 100)}%` : "n/a";
1925
+ var formatMaybe = (value) => value === undefined || value === "" ? "n/a" : String(value);
1926
+ var getTurnDetail = (turn) => {
1927
+ if (turn.status === "fail") {
1928
+ return "Empty or unusable committed turn; inspect transcripts and adapter events.";
1929
+ }
1930
+ if (turn.fallbackUsed) {
1931
+ return `Fallback STT selected${turn.fallbackSelectionReason ? ` by ${turn.fallbackSelectionReason}` : ""}.`;
1932
+ }
1933
+ if (turn.correctionChanged) {
1934
+ return `Correction changed the turn${turn.correctionProvider ? ` via ${turn.correctionProvider}` : ""}.`;
1935
+ }
1936
+ if (turn.status === "warn") {
1937
+ return "Turn completed with quality warnings.";
1938
+ }
1939
+ if (turn.status === "unknown") {
1940
+ return "No quality diagnostics were recorded for this turn.";
1941
+ }
1942
+ return "Turn quality looks healthy.";
1943
+ };
1944
+ var createVoiceTurnQualityViewModel = (snapshot, options = {}) => {
1945
+ const turns = (snapshot.report?.turns ?? []).map((turn) => ({
1946
+ ...turn,
1947
+ detail: getTurnDetail(turn),
1948
+ label: turn.text || "Empty turn",
1949
+ rows: [
1950
+ { label: "Source", value: turn.source ?? "unknown" },
1951
+ { label: "Confidence", value: formatConfidence(turn.averageConfidence) },
1952
+ { label: "Fallback", value: turn.fallbackUsed ? "Yes" : "No" },
1953
+ { label: "Correction", value: turn.correctionChanged ? "Changed" : "None" },
1954
+ { label: "Transcripts", value: `${turn.selectedTranscriptCount} selected` },
1955
+ { label: "Cost", value: formatMaybe(turn.costUnits) }
1956
+ ]
1957
+ }));
1958
+ const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
1959
+ const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
1960
+ return {
1961
+ description: options.description ?? DEFAULT_DESCRIPTION6,
1962
+ error: snapshot.error,
1963
+ isLoading: snapshot.isLoading,
1964
+ label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} failed` : warningCount > 0 ? `${warningCount} warnings` : `${turns.length} healthy` : snapshot.isLoading ? "Checking" : "No turns",
1965
+ status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
1966
+ title: options.title ?? DEFAULT_TITLE6,
1967
+ turns,
1968
+ updatedAt: snapshot.updatedAt
1969
+ };
1970
+ };
1971
+ var renderVoiceTurnQualityHTML = (snapshot, options = {}) => {
1972
+ const model = createVoiceTurnQualityViewModel(snapshot, options);
1973
+ const turns = model.turns.length ? `<div class="absolute-voice-turn-quality__turns">${model.turns.map((turn) => `<article class="absolute-voice-turn-quality__turn absolute-voice-turn-quality__turn--${escapeHtml7(turn.status)}">
1974
+ <header>
1975
+ <strong>${escapeHtml7(turn.label)}</strong>
1976
+ <span>${escapeHtml7(turn.status)}</span>
1977
+ </header>
1978
+ <p>${escapeHtml7(turn.detail)}</p>
1979
+ <dl>${turn.rows.map((row) => `<div>
1980
+ <dt>${escapeHtml7(row.label)}</dt>
1981
+ <dd>${escapeHtml7(row.value)}</dd>
1982
+ </div>`).join("")}</dl>
1983
+ </article>`).join("")}</div>` : '<p class="absolute-voice-turn-quality__empty">Complete a voice turn to see STT quality diagnostics.</p>';
1984
+ return `<section class="absolute-voice-turn-quality absolute-voice-turn-quality--${escapeHtml7(model.status)}">
1985
+ <header class="absolute-voice-turn-quality__header">
1986
+ <span class="absolute-voice-turn-quality__eyebrow">${escapeHtml7(model.title)}</span>
1987
+ <strong class="absolute-voice-turn-quality__label">${escapeHtml7(model.label)}</strong>
1988
+ </header>
1989
+ <p class="absolute-voice-turn-quality__description">${escapeHtml7(model.description)}</p>
1990
+ ${turns}
1991
+ ${model.error ? `<p class="absolute-voice-turn-quality__error">${escapeHtml7(model.error)}</p>` : ""}
1992
+ </section>`;
1993
+ };
1994
+ var getVoiceTurnQualityCSS = () => `.absolute-voice-turn-quality{border:1px solid #e4d1a3;border-radius:20px;background:#fff9eb;color:#17120a;padding:18px;box-shadow:0 18px 40px rgba(73,48,14,.12);font-family:inherit}.absolute-voice-turn-quality--error,.absolute-voice-turn-quality--warning{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-turn-quality__header,.absolute-voice-turn-quality__turn header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-turn-quality__eyebrow{color:#8a5a0a;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-turn-quality__label{font-size:24px;line-height:1}.absolute-voice-turn-quality__description,.absolute-voice-turn-quality__turn p,.absolute-voice-turn-quality__turn dt,.absolute-voice-turn-quality__empty{color:#5a4930}.absolute-voice-turn-quality__turns{display:grid;gap:12px;margin-top:14px}.absolute-voice-turn-quality__turn{background:#fff;border:1px solid #f0dfba;border-radius:16px;padding:14px}.absolute-voice-turn-quality__turn--pass{border-color:#86efac}.absolute-voice-turn-quality__turn--warn,.absolute-voice-turn-quality__turn--unknown{border-color:#fbbf24}.absolute-voice-turn-quality__turn--fail{border-color:#f2a7a7}.absolute-voice-turn-quality__turn p{margin:10px 0}.absolute-voice-turn-quality__turn dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-turn-quality__turn div{background:#fff9eb;border:1px solid #f0dfba;border-radius:12px;padding:8px}.absolute-voice-turn-quality__turn dt{font-size:12px}.absolute-voice-turn-quality__turn dd{font-weight:800;margin:4px 0 0}.absolute-voice-turn-quality__empty{margin:14px 0 0}.absolute-voice-turn-quality__error{color:#9f1239;font-weight:700}`;
1995
+ var mountVoiceTurnQuality = (element, path = "/api/turn-quality", options = {}) => {
1996
+ const store = createVoiceTurnQualityStore(path, options);
1997
+ const render = () => {
1998
+ element.innerHTML = renderVoiceTurnQualityHTML(store.getSnapshot(), options);
1999
+ };
2000
+ const unsubscribe = store.subscribe(render);
2001
+ render();
2002
+ store.refresh().catch(() => {});
2003
+ return {
2004
+ close: () => {
2005
+ unsubscribe();
2006
+ store.close();
2007
+ },
2008
+ refresh: store.refresh
2009
+ };
2010
+ };
2011
+ var defineVoiceTurnQualityElement = (tagName = "absolute-voice-turn-quality") => {
2012
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
2013
+ return;
2014
+ }
2015
+ customElements.define(tagName, class AbsoluteVoiceTurnQualityElement extends HTMLElement {
2016
+ mounted;
2017
+ connectedCallback() {
2018
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
2019
+ this.mounted = mountVoiceTurnQuality(this, this.getAttribute("path") ?? "/api/turn-quality", {
2020
+ description: this.getAttribute("description") ?? undefined,
2021
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
2022
+ title: this.getAttribute("title") ?? undefined
2023
+ });
2024
+ }
2025
+ disconnectedCallback() {
2026
+ this.mounted?.close();
2027
+ this.mounted = undefined;
2028
+ }
2029
+ });
2030
+ };
2031
+
2032
+ // src/vue/useVoiceTurnQuality.ts
2033
+ import { onUnmounted as onUnmounted7, shallowRef as shallowRef6 } from "vue";
2034
+ function useVoiceTurnQuality(path = "/api/turn-quality", options = {}) {
2035
+ const store = createVoiceTurnQualityStore(path, options);
2036
+ const error = shallowRef6(null);
2037
+ const isLoading = shallowRef6(false);
2038
+ const report = shallowRef6();
2039
+ const updatedAt = shallowRef6(undefined);
2040
+ const sync = () => {
2041
+ const snapshot = store.getSnapshot();
2042
+ error.value = snapshot.error;
2043
+ isLoading.value = snapshot.isLoading;
2044
+ report.value = snapshot.report;
2045
+ updatedAt.value = snapshot.updatedAt;
2046
+ };
2047
+ const unsubscribe = store.subscribe(sync);
2048
+ sync();
2049
+ store.refresh().catch(() => {});
2050
+ onUnmounted7(() => {
2051
+ unsubscribe();
2052
+ store.close();
2053
+ });
2054
+ return { error, isLoading, refresh: store.refresh, report, updatedAt };
2055
+ }
2056
+
2057
+ // src/vue/VoiceTurnQuality.ts
2058
+ var VoiceTurnQuality = defineComponent7({
2059
+ name: "VoiceTurnQuality",
2060
+ props: {
2061
+ class: { default: "", type: String },
2062
+ description: { default: undefined, type: String },
2063
+ intervalMs: { default: 5000, type: Number },
2064
+ path: { default: "/api/turn-quality", type: String },
2065
+ title: { default: undefined, type: String }
2066
+ },
2067
+ setup(props) {
2068
+ const options = {
2069
+ description: props.description,
2070
+ intervalMs: props.intervalMs,
2071
+ title: props.title
2072
+ };
2073
+ const quality = useVoiceTurnQuality(props.path, options);
2074
+ const model = computed6(() => createVoiceTurnQualityViewModel({
2075
+ error: quality.error.value,
2076
+ isLoading: quality.isLoading.value,
2077
+ report: quality.report.value,
2078
+ updatedAt: quality.updatedAt.value
2079
+ }, options));
2080
+ return () => h7("section", {
2081
+ class: [
2082
+ "absolute-voice-turn-quality",
2083
+ `absolute-voice-turn-quality--${model.value.status}`,
2084
+ props.class
2085
+ ]
2086
+ }, [
2087
+ h7("header", { class: "absolute-voice-turn-quality__header" }, [
2088
+ h7("span", { class: "absolute-voice-turn-quality__eyebrow" }, model.value.title),
2089
+ h7("strong", { class: "absolute-voice-turn-quality__label" }, model.value.label)
2090
+ ]),
2091
+ h7("p", { class: "absolute-voice-turn-quality__description" }, model.value.description),
2092
+ model.value.turns.length ? h7("div", { class: "absolute-voice-turn-quality__turns" }, model.value.turns.map((turn) => h7("article", {
2093
+ class: [
2094
+ "absolute-voice-turn-quality__turn",
2095
+ `absolute-voice-turn-quality__turn--${turn.status}`
2096
+ ],
2097
+ key: `${turn.sessionId}:${turn.turnId}`
2098
+ }, [
2099
+ h7("header", [
2100
+ h7("strong", turn.label),
2101
+ h7("span", turn.status)
2102
+ ]),
2103
+ h7("p", turn.detail),
2104
+ h7("dl", turn.rows.map((row) => h7("div", { key: row.label }, [
2105
+ h7("dt", row.label),
2106
+ h7("dd", row.value)
2107
+ ])))
2108
+ ]))) : h7("p", { class: "absolute-voice-turn-quality__empty" }, "Complete a voice turn to see STT quality diagnostics."),
2109
+ model.value.error ? h7("p", { class: "absolute-voice-turn-quality__error" }, model.value.error) : null
2110
+ ]);
2111
+ }
2112
+ });
2113
+ // src/vue/useVoiceCampaignDialerProof.ts
2114
+ import { onUnmounted as onUnmounted8, shallowRef as shallowRef7 } from "vue";
2115
+
2116
+ // src/client/campaignDialerProof.ts
2117
+ var fetchVoiceCampaignDialerProofStatus = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
2118
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2119
+ const response = await fetchImpl(path);
2120
+ if (!response.ok) {
2121
+ throw new Error(`Voice campaign dialer proof status failed: HTTP ${response.status}`);
2122
+ }
2123
+ return await response.json();
2124
+ };
2125
+ var runVoiceCampaignDialerProofAction = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
2126
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2127
+ const response = await fetchImpl(path, { method: "POST" });
2128
+ if (!response.ok) {
2129
+ throw new Error(`Voice campaign dialer proof failed: HTTP ${response.status}`);
2130
+ }
2131
+ return await response.json();
2132
+ };
2133
+ var createVoiceCampaignDialerProofStore = (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
2134
+ const listeners = new Set;
2135
+ let closed = false;
2136
+ let timer;
2137
+ let snapshot = {
2138
+ error: null,
2139
+ isLoading: false
2140
+ };
2141
+ const emit = () => {
2142
+ for (const listener of listeners) {
2143
+ listener();
2144
+ }
2145
+ };
2146
+ const refresh = async () => {
2147
+ if (closed) {
2148
+ return snapshot.status;
2149
+ }
2150
+ snapshot = { ...snapshot, error: null, isLoading: true };
2151
+ emit();
2152
+ try {
2153
+ const status = await fetchVoiceCampaignDialerProofStatus(path, options);
2154
+ snapshot = {
2155
+ ...snapshot,
2156
+ error: null,
2157
+ isLoading: false,
2158
+ status,
2159
+ updatedAt: Date.now()
2160
+ };
2161
+ emit();
2162
+ return status;
2163
+ } catch (error) {
2164
+ snapshot = {
2165
+ ...snapshot,
2166
+ error: error instanceof Error ? error.message : String(error),
2167
+ isLoading: false
2168
+ };
2169
+ emit();
2170
+ throw error;
2171
+ }
2172
+ };
2173
+ const runProof = async () => {
2174
+ const runPath = options.runPath ?? snapshot.status?.runPath ?? path;
2175
+ snapshot = { ...snapshot, error: null, isLoading: true };
2176
+ emit();
2177
+ try {
2178
+ const report = await runVoiceCampaignDialerProofAction(runPath, options);
2179
+ snapshot = {
2180
+ ...snapshot,
2181
+ error: null,
2182
+ isLoading: false,
2183
+ report,
2184
+ status: {
2185
+ generatedAt: Date.now(),
2186
+ mode: report.mode,
2187
+ ok: report.ok,
2188
+ providers: report.providers.map((provider) => provider.provider),
2189
+ runPath,
2190
+ safe: true
2191
+ },
2192
+ updatedAt: Date.now()
2193
+ };
2194
+ emit();
2195
+ return report;
2196
+ } catch (error) {
2197
+ snapshot = {
2198
+ ...snapshot,
2199
+ error: error instanceof Error ? error.message : String(error),
2200
+ isLoading: false
2201
+ };
2202
+ emit();
2203
+ throw error;
2204
+ }
2205
+ };
2206
+ const close = () => {
2207
+ closed = true;
2208
+ if (timer) {
2209
+ clearInterval(timer);
2210
+ timer = undefined;
2211
+ }
2212
+ listeners.clear();
2213
+ };
2214
+ if (options.intervalMs && options.intervalMs > 0) {
2215
+ timer = setInterval(() => {
2216
+ refresh().catch(() => {});
2217
+ }, options.intervalMs);
2218
+ }
2219
+ return {
2220
+ close,
2221
+ getServerSnapshot: () => snapshot,
2222
+ getSnapshot: () => snapshot,
2223
+ refresh,
2224
+ runProof,
2225
+ subscribe: (listener) => {
2226
+ listeners.add(listener);
2227
+ return () => {
2228
+ listeners.delete(listener);
2229
+ };
2230
+ }
2231
+ };
2232
+ };
2233
+
2234
+ // src/vue/useVoiceCampaignDialerProof.ts
2235
+ function useVoiceCampaignDialerProof(path = "/api/voice/campaigns/dialer-proof", options = {}) {
2236
+ const store = createVoiceCampaignDialerProofStore(path, options);
2237
+ const error = shallowRef7(null);
2238
+ const isLoading = shallowRef7(false);
2239
+ const report = shallowRef7();
2240
+ const status = shallowRef7();
2241
+ const updatedAt = shallowRef7(undefined);
2242
+ const sync = () => {
2243
+ const snapshot = store.getSnapshot();
2244
+ error.value = snapshot.error;
2245
+ isLoading.value = snapshot.isLoading;
2246
+ report.value = snapshot.report;
2247
+ status.value = snapshot.status;
2248
+ updatedAt.value = snapshot.updatedAt;
2249
+ };
2250
+ const unsubscribe = store.subscribe(sync);
2251
+ sync();
2252
+ if (typeof window !== "undefined") {
2253
+ store.refresh().catch(() => {});
2254
+ }
2255
+ onUnmounted8(() => {
2256
+ unsubscribe();
2257
+ store.close();
2258
+ });
2259
+ return {
2260
+ error,
2261
+ isLoading,
2262
+ refresh: store.refresh,
2263
+ report,
2264
+ runProof: store.runProof,
2265
+ status,
2266
+ updatedAt
2267
+ };
2268
+ }
72
2269
  // src/vue/useVoiceStream.ts
73
- import { onUnmounted, ref, shallowRef } from "vue";
2270
+ import { onUnmounted as onUnmounted9, ref as ref5, shallowRef as shallowRef8 } from "vue";
74
2271
 
75
2272
  // src/client/actions.ts
76
2273
  var normalizeErrorMessage = (value) => {
@@ -120,6 +2317,17 @@ var serverMessageToAction = (message) => {
120
2317
  sessionId: message.sessionId,
121
2318
  type: "complete"
122
2319
  };
2320
+ case "connection":
2321
+ return {
2322
+ reconnect: message.reconnect,
2323
+ type: "connection"
2324
+ };
2325
+ case "call_lifecycle":
2326
+ return {
2327
+ event: message.event,
2328
+ sessionId: message.sessionId,
2329
+ type: "call_lifecycle"
2330
+ };
123
2331
  case "error":
124
2332
  return {
125
2333
  message: normalizeErrorMessage(message.message),
@@ -135,6 +2343,17 @@ var serverMessageToAction = (message) => {
135
2343
  transcript: message.transcript,
136
2344
  type: "partial"
137
2345
  };
2346
+ case "replay":
2347
+ return {
2348
+ assistantTexts: message.assistantTexts,
2349
+ call: message.call,
2350
+ partial: message.partial,
2351
+ scenarioId: message.scenarioId,
2352
+ sessionId: message.sessionId,
2353
+ status: message.status,
2354
+ turns: message.turns,
2355
+ type: "replay"
2356
+ };
138
2357
  case "session":
139
2358
  return {
140
2359
  sessionId: message.sessionId,
@@ -163,7 +2382,7 @@ var DEFAULT_SCENARIO_QUERY_PARAM = "scenarioId";
163
2382
  var noop = () => {};
164
2383
  var noopUnsubscribe = () => noop;
165
2384
  var NOOP_CONNECTION = {
166
- start: () => {},
2385
+ callControl: noop,
167
2386
  close: noop,
168
2387
  endTurn: noop,
169
2388
  getReadyState: () => WS_CLOSED,
@@ -171,6 +2390,7 @@ var NOOP_CONNECTION = {
171
2390
  getSessionId: () => "",
172
2391
  send: noop,
173
2392
  sendAudio: noop,
2393
+ start: () => {},
174
2394
  subscribe: noopUnsubscribe
175
2395
  };
176
2396
  var createSessionId = () => crypto.randomUUID();
@@ -192,11 +2412,14 @@ var isVoiceServerMessage = (value) => {
192
2412
  switch (value.type) {
193
2413
  case "audio":
194
2414
  case "assistant":
2415
+ case "call_lifecycle":
195
2416
  case "complete":
2417
+ case "connection":
196
2418
  case "error":
197
2419
  case "final":
198
2420
  case "partial":
199
2421
  case "pong":
2422
+ case "replay":
200
2423
  case "session":
201
2424
  case "turn":
202
2425
  return true;
@@ -233,6 +2456,9 @@ var createVoiceConnection = (path, options = {}) => {
233
2456
  sessionId: options.sessionId ?? createSessionId(),
234
2457
  ws: null
235
2458
  };
2459
+ const emitConnection = (reconnect) => {
2460
+ listeners.forEach((listener) => listener(reconnect));
2461
+ };
236
2462
  const clearTimers = () => {
237
2463
  if (state.pingInterval) {
238
2464
  clearInterval(state.pingInterval);
@@ -255,9 +2481,28 @@ var createVoiceConnection = (path, options = {}) => {
255
2481
  }
256
2482
  };
257
2483
  const scheduleReconnect = () => {
2484
+ const nextAttemptAt = Date.now() + RECONNECT_DELAY_MS;
258
2485
  state.reconnectAttempts += 1;
2486
+ emitConnection({
2487
+ reconnect: {
2488
+ attempts: state.reconnectAttempts,
2489
+ lastDisconnectAt: Date.now(),
2490
+ maxAttempts: maxReconnectAttempts,
2491
+ nextAttemptAt,
2492
+ status: "reconnecting"
2493
+ },
2494
+ type: "connection"
2495
+ });
259
2496
  state.reconnectTimeout = setTimeout(() => {
260
2497
  if (state.reconnectAttempts > maxReconnectAttempts) {
2498
+ emitConnection({
2499
+ reconnect: {
2500
+ attempts: state.reconnectAttempts,
2501
+ maxAttempts: maxReconnectAttempts,
2502
+ status: "exhausted"
2503
+ },
2504
+ type: "connection"
2505
+ });
261
2506
  return;
262
2507
  }
263
2508
  connect();
@@ -267,9 +2512,21 @@ var createVoiceConnection = (path, options = {}) => {
267
2512
  const ws = new WebSocket(buildWsUrl(path, state.sessionId, state.scenarioId));
268
2513
  ws.binaryType = "arraybuffer";
269
2514
  ws.onopen = () => {
2515
+ const wasReconnecting = state.reconnectAttempts > 0;
270
2516
  state.isConnected = true;
271
- state.reconnectAttempts = 0;
272
2517
  flushPendingMessages();
2518
+ if (wasReconnecting) {
2519
+ emitConnection({
2520
+ reconnect: {
2521
+ attempts: state.reconnectAttempts,
2522
+ lastResumedAt: Date.now(),
2523
+ maxAttempts: maxReconnectAttempts,
2524
+ status: "resumed"
2525
+ },
2526
+ type: "connection"
2527
+ });
2528
+ state.reconnectAttempts = 0;
2529
+ }
273
2530
  listeners.forEach((listener) => listener({
274
2531
  scenarioId: state.scenarioId ?? undefined,
275
2532
  sessionId: state.sessionId,
@@ -299,6 +2556,16 @@ var createVoiceConnection = (path, options = {}) => {
299
2556
  const reconnectable = shouldReconnect && event.code !== WS_NORMAL_CLOSURE && state.reconnectAttempts < maxReconnectAttempts;
300
2557
  if (reconnectable) {
301
2558
  scheduleReconnect();
2559
+ } else if (shouldReconnect && event.code !== WS_NORMAL_CLOSURE) {
2560
+ emitConnection({
2561
+ reconnect: {
2562
+ attempts: state.reconnectAttempts,
2563
+ lastDisconnectAt: Date.now(),
2564
+ maxAttempts: maxReconnectAttempts,
2565
+ status: "exhausted"
2566
+ },
2567
+ type: "connection"
2568
+ });
302
2569
  }
303
2570
  };
304
2571
  state.ws = ws;
@@ -332,6 +2599,12 @@ var createVoiceConnection = (path, options = {}) => {
332
2599
  const endTurn = () => {
333
2600
  send({ type: "end_turn" });
334
2601
  };
2602
+ const callControl = (message) => {
2603
+ send({
2604
+ ...message,
2605
+ type: "call_control"
2606
+ });
2607
+ };
335
2608
  const close = () => {
336
2609
  clearTimers();
337
2610
  if (state.ws) {
@@ -349,7 +2622,7 @@ var createVoiceConnection = (path, options = {}) => {
349
2622
  };
350
2623
  connect();
351
2624
  return {
352
- start,
2625
+ callControl,
353
2626
  close,
354
2627
  endTurn,
355
2628
  getReadyState: () => state.ws?.readyState ?? WS_CLOSED,
@@ -357,18 +2630,26 @@ var createVoiceConnection = (path, options = {}) => {
357
2630
  getSessionId: () => state.sessionId,
358
2631
  send,
359
2632
  sendAudio,
2633
+ start,
360
2634
  subscribe
361
2635
  };
362
2636
  };
363
2637
 
364
2638
  // src/client/store.ts
2639
+ var createInitialReconnectState = () => ({
2640
+ attempts: 0,
2641
+ maxAttempts: 0,
2642
+ status: "idle"
2643
+ });
365
2644
  var createInitialState = () => ({
366
2645
  assistantAudio: [],
367
2646
  assistantTexts: [],
2647
+ call: null,
368
2648
  error: null,
369
2649
  isConnected: false,
370
2650
  scenarioId: null,
371
2651
  partial: "",
2652
+ reconnect: createInitialReconnectState(),
372
2653
  sessionId: null,
373
2654
  status: "idle",
374
2655
  turns: []
@@ -408,10 +2689,36 @@ var createVoiceStreamStore = () => {
408
2689
  status: "completed"
409
2690
  };
410
2691
  break;
2692
+ case "call_lifecycle":
2693
+ state = {
2694
+ ...state,
2695
+ call: {
2696
+ ...state.call,
2697
+ disposition: action.event.type === "end" ? action.event.disposition : state.call?.disposition,
2698
+ endedAt: action.event.type === "end" ? action.event.at : state.call?.endedAt,
2699
+ events: [...state.call?.events ?? [], action.event],
2700
+ lastEventAt: action.event.at,
2701
+ startedAt: state.call?.startedAt ?? action.event.at
2702
+ },
2703
+ sessionId: action.sessionId
2704
+ };
2705
+ break;
411
2706
  case "connected":
412
2707
  state = {
413
2708
  ...state,
414
- isConnected: true
2709
+ isConnected: true,
2710
+ reconnect: state.reconnect.status === "reconnecting" ? {
2711
+ ...state.reconnect,
2712
+ lastResumedAt: Date.now(),
2713
+ nextAttemptAt: undefined,
2714
+ status: "resumed"
2715
+ } : state.reconnect
2716
+ };
2717
+ break;
2718
+ case "connection":
2719
+ state = {
2720
+ ...state,
2721
+ reconnect: action.reconnect
415
2722
  };
416
2723
  break;
417
2724
  case "disconnected":
@@ -439,6 +2746,26 @@ var createVoiceStreamStore = () => {
439
2746
  partial: action.transcript.text
440
2747
  };
441
2748
  break;
2749
+ case "replay":
2750
+ state = {
2751
+ ...state,
2752
+ assistantTexts: [...action.assistantTexts],
2753
+ call: action.call ?? null,
2754
+ error: null,
2755
+ isConnected: action.status === "active",
2756
+ partial: action.partial,
2757
+ reconnect: state.reconnect.status === "reconnecting" ? {
2758
+ ...state.reconnect,
2759
+ lastResumedAt: Date.now(),
2760
+ nextAttemptAt: undefined,
2761
+ status: "resumed"
2762
+ } : state.reconnect,
2763
+ scenarioId: action.scenarioId ?? state.scenarioId,
2764
+ sessionId: action.sessionId,
2765
+ status: action.status,
2766
+ turns: [...action.turns]
2767
+ };
2768
+ break;
442
2769
  case "session":
443
2770
  state = {
444
2771
  ...state,
@@ -486,14 +2813,41 @@ var createVoiceStream = (path, options = {}) => {
486
2813
  const notify = () => {
487
2814
  subscribers.forEach((subscriber) => subscriber());
488
2815
  };
2816
+ const reportReconnect = () => {
2817
+ if (!options.reconnectReportPath || typeof fetch === "undefined") {
2818
+ return;
2819
+ }
2820
+ const snapshot = store.getSnapshot();
2821
+ const body = JSON.stringify({
2822
+ at: Date.now(),
2823
+ reconnect: snapshot.reconnect,
2824
+ scenarioId: snapshot.scenarioId,
2825
+ sessionId: connection.getSessionId(),
2826
+ turnIds: snapshot.turns.map((turn) => turn.id)
2827
+ });
2828
+ fetch(options.reconnectReportPath, {
2829
+ body,
2830
+ headers: {
2831
+ "Content-Type": "application/json"
2832
+ },
2833
+ keepalive: true,
2834
+ method: "POST"
2835
+ }).catch(() => {});
2836
+ };
489
2837
  const unsubscribeConnection = connection.subscribe((message) => {
490
2838
  const action = serverMessageToAction(message);
491
2839
  if (action) {
492
2840
  store.dispatch(action);
2841
+ if (message.type === "connection") {
2842
+ reportReconnect();
2843
+ }
493
2844
  notify();
494
2845
  }
495
2846
  });
496
2847
  return {
2848
+ callControl(message) {
2849
+ connection.callControl(message);
2850
+ },
497
2851
  close() {
498
2852
  unsubscribeConnection();
499
2853
  connection.close();
@@ -522,6 +2876,9 @@ var createVoiceStream = (path, options = {}) => {
522
2876
  get partial() {
523
2877
  return store.getSnapshot().partial;
524
2878
  },
2879
+ get reconnect() {
2880
+ return store.getSnapshot().reconnect;
2881
+ },
525
2882
  get sessionId() {
526
2883
  return connection.getSessionId();
527
2884
  },
@@ -537,6 +2894,9 @@ var createVoiceStream = (path, options = {}) => {
537
2894
  get assistantAudio() {
538
2895
  return store.getSnapshot().assistantAudio;
539
2896
  },
2897
+ get call() {
2898
+ return store.getSnapshot().call;
2899
+ },
540
2900
  sendAudio(audio) {
541
2901
  connection.sendAudio(audio);
542
2902
  },
@@ -550,22 +2910,26 @@ var createVoiceStream = (path, options = {}) => {
550
2910
  };
551
2911
 
552
2912
  // src/vue/useVoiceStream.ts
553
- var useVoiceStream = (path, options = {}) => {
2913
+ function useVoiceStream(path, options = {}) {
554
2914
  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([]);
2915
+ const assistantAudio = shallowRef8([]);
2916
+ const assistantTexts = shallowRef8([]);
2917
+ const call = shallowRef8(null);
2918
+ const error = ref5(null);
2919
+ const isConnected = ref5(false);
2920
+ const partial = ref5("");
2921
+ const reconnect = shallowRef8(stream.reconnect);
2922
+ const sessionId = ref5(stream.sessionId);
2923
+ const status = ref5(stream.status);
2924
+ const turns = shallowRef8([]);
563
2925
  const sync = () => {
564
2926
  assistantAudio.value = [...stream.assistantAudio];
565
2927
  assistantTexts.value = [...stream.assistantTexts];
2928
+ call.value = stream.call;
566
2929
  error.value = stream.error;
567
2930
  isConnected.value = stream.isConnected;
568
2931
  partial.value = stream.partial;
2932
+ reconnect.value = stream.reconnect;
569
2933
  sessionId.value = stream.sessionId;
570
2934
  status.value = stream.status;
571
2935
  turns.value = [...stream.turns];
@@ -576,23 +2940,26 @@ var useVoiceStream = (path, options = {}) => {
576
2940
  unsubscribe();
577
2941
  stream.close();
578
2942
  };
579
- onUnmounted(destroy);
2943
+ onUnmounted9(destroy);
580
2944
  return {
581
2945
  assistantAudio,
582
2946
  assistantTexts,
2947
+ call,
2948
+ callControl: (message) => stream.callControl(message),
583
2949
  close: () => destroy(),
584
2950
  endTurn: () => stream.endTurn(),
585
2951
  error,
586
2952
  isConnected,
587
2953
  partial,
2954
+ reconnect,
588
2955
  sendAudio: (audio) => stream.sendAudio(audio),
589
2956
  sessionId,
590
2957
  status,
591
2958
  turns
592
2959
  };
593
- };
2960
+ }
594
2961
  // src/vue/useVoiceController.ts
595
- import { onUnmounted as onUnmounted2, ref as ref2, shallowRef as shallowRef2 } from "vue";
2962
+ import { onUnmounted as onUnmounted10, ref as ref6, shallowRef as shallowRef9 } from "vue";
596
2963
 
597
2964
  // src/client/htmx.ts
598
2965
  var DEFAULT_EVENT_NAME = "voice-refresh";
@@ -1056,10 +3423,12 @@ var resolveVoiceRuntimePreset = (name = "default") => {
1056
3423
  var createInitialState2 = (stream) => ({
1057
3424
  assistantAudio: [...stream.assistantAudio],
1058
3425
  assistantTexts: [...stream.assistantTexts],
3426
+ call: stream.call,
1059
3427
  error: stream.error,
1060
3428
  isConnected: stream.isConnected,
1061
3429
  isRecording: false,
1062
3430
  partial: stream.partial,
3431
+ reconnect: stream.reconnect,
1063
3432
  recordingError: null,
1064
3433
  sessionId: stream.sessionId,
1065
3434
  scenarioId: stream.scenarioId,
@@ -1085,9 +3454,11 @@ var createVoiceController = (path, options = {}) => {
1085
3454
  ...state,
1086
3455
  assistantAudio: [...stream.assistantAudio],
1087
3456
  assistantTexts: [...stream.assistantTexts],
3457
+ call: stream.call,
1088
3458
  error: stream.error,
1089
3459
  isConnected: stream.isConnected,
1090
3460
  partial: stream.partial,
3461
+ reconnect: stream.reconnect,
1091
3462
  sessionId: stream.sessionId,
1092
3463
  scenarioId: stream.scenarioId,
1093
3464
  status: stream.status,
@@ -1112,7 +3483,13 @@ var createVoiceController = (path, options = {}) => {
1112
3483
  capture = createMicrophoneCapture({
1113
3484
  channelCount: options.capture?.channelCount ?? preset.capture.channelCount,
1114
3485
  onLevel: options.capture?.onLevel,
1115
- onAudio: (audio) => stream.sendAudio(audio),
3486
+ onAudio: (audio) => {
3487
+ if (options.capture?.onAudio) {
3488
+ options.capture.onAudio(audio, stream.sendAudio);
3489
+ return;
3490
+ }
3491
+ stream.sendAudio(audio);
3492
+ },
1116
3493
  sampleRateHz: options.capture?.sampleRateHz ?? preset.capture.sampleRateHz
1117
3494
  });
1118
3495
  return capture;
@@ -1162,6 +3539,7 @@ var createVoiceController = (path, options = {}) => {
1162
3539
  bindHTMX(bindingOptions) {
1163
3540
  return bindVoiceHTMX(stream, bindingOptions);
1164
3541
  },
3542
+ callControl: (message) => stream.callControl(message),
1165
3543
  close,
1166
3544
  endTurn: () => stream.endTurn(),
1167
3545
  get error() {
@@ -1181,6 +3559,9 @@ var createVoiceController = (path, options = {}) => {
1181
3559
  get recordingError() {
1182
3560
  return state.recordingError;
1183
3561
  },
3562
+ get reconnect() {
3563
+ return state.reconnect;
3564
+ },
1184
3565
  sendAudio: (audio) => stream.sendAudio(audio),
1185
3566
  get sessionId() {
1186
3567
  return state.sessionId;
@@ -1214,23 +3595,27 @@ var createVoiceController = (path, options = {}) => {
1214
3595
  },
1215
3596
  get assistantAudio() {
1216
3597
  return state.assistantAudio;
3598
+ },
3599
+ get call() {
3600
+ return state.call;
1217
3601
  }
1218
3602
  };
1219
3603
  };
1220
3604
 
1221
3605
  // src/vue/useVoiceController.ts
1222
- var useVoiceController = (path, options = {}) => {
3606
+ function useVoiceController(path, options = {}) {
1223
3607
  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([]);
3608
+ const assistantAudio = shallowRef9([]);
3609
+ const assistantTexts = shallowRef9([]);
3610
+ const error = ref6(null);
3611
+ const isConnected = ref6(false);
3612
+ const isRecording = ref6(false);
3613
+ const partial = ref6("");
3614
+ const reconnect = shallowRef9(controller.reconnect);
3615
+ const recordingError = ref6(null);
3616
+ const sessionId = ref6(controller.sessionId);
3617
+ const status = ref6(controller.status);
3618
+ const turns = shallowRef9([]);
1234
3619
  const sync = () => {
1235
3620
  assistantAudio.value = [...controller.assistantAudio];
1236
3621
  assistantTexts.value = [...controller.assistantTexts];
@@ -1238,6 +3623,7 @@ var useVoiceController = (path, options = {}) => {
1238
3623
  isConnected.value = controller.isConnected;
1239
3624
  isRecording.value = controller.isRecording;
1240
3625
  partial.value = controller.partial;
3626
+ reconnect.value = controller.reconnect;
1241
3627
  recordingError.value = controller.recordingError;
1242
3628
  sessionId.value = controller.sessionId;
1243
3629
  status.value = controller.status;
@@ -1249,7 +3635,7 @@ var useVoiceController = (path, options = {}) => {
1249
3635
  unsubscribe();
1250
3636
  controller.close();
1251
3637
  };
1252
- onUnmounted2(destroy);
3638
+ onUnmounted10(destroy);
1253
3639
  return {
1254
3640
  assistantAudio,
1255
3641
  assistantTexts,
@@ -1260,6 +3646,7 @@ var useVoiceController = (path, options = {}) => {
1260
3646
  isConnected,
1261
3647
  isRecording,
1262
3648
  partial,
3649
+ reconnect,
1263
3650
  recordingError,
1264
3651
  sendAudio: (audio) => controller.sendAudio(audio),
1265
3652
  sessionId,
@@ -1269,27 +3656,27 @@ var useVoiceController = (path, options = {}) => {
1269
3656
  toggleRecording: () => controller.toggleRecording(),
1270
3657
  turns
1271
3658
  };
1272
- };
1273
- // src/vue/useVoiceProviderStatus.ts
1274
- import { onUnmounted as onUnmounted3, ref as ref3, shallowRef as shallowRef3 } from "vue";
3659
+ }
3660
+ // src/vue/useVoiceTraceTimeline.ts
3661
+ import { onUnmounted as onUnmounted11, ref as ref7, shallowRef as shallowRef10 } from "vue";
1275
3662
 
1276
- // src/client/providerStatus.ts
1277
- var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
3663
+ // src/client/traceTimeline.ts
3664
+ var fetchVoiceTraceTimeline = async (path = "/api/voice-traces", options = {}) => {
1278
3665
  const fetchImpl = options.fetch ?? globalThis.fetch;
1279
3666
  const response = await fetchImpl(path);
1280
3667
  if (!response.ok) {
1281
- throw new Error(`Voice provider status failed: HTTP ${response.status}`);
3668
+ throw new Error(`Voice trace timeline failed: HTTP ${response.status}`);
1282
3669
  }
1283
3670
  return await response.json();
1284
3671
  };
1285
- var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
3672
+ var createVoiceTraceTimelineStore = (path = "/api/voice-traces", options = {}) => {
1286
3673
  const listeners = new Set;
1287
3674
  let closed = false;
1288
3675
  let timer;
1289
3676
  let snapshot = {
1290
3677
  error: null,
1291
3678
  isLoading: false,
1292
- providers: []
3679
+ report: null
1293
3680
  };
1294
3681
  const emit = () => {
1295
3682
  for (const listener of listeners) {
@@ -1298,7 +3685,7 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
1298
3685
  };
1299
3686
  const refresh = async () => {
1300
3687
  if (closed) {
1301
- return snapshot.providers;
3688
+ return snapshot.report;
1302
3689
  }
1303
3690
  snapshot = {
1304
3691
  ...snapshot,
@@ -1307,15 +3694,15 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
1307
3694
  };
1308
3695
  emit();
1309
3696
  try {
1310
- const providers = await fetchVoiceProviderStatus(path, options);
3697
+ const report = await fetchVoiceTraceTimeline(path, options);
1311
3698
  snapshot = {
1312
3699
  error: null,
1313
3700
  isLoading: false,
1314
- providers,
3701
+ report,
1315
3702
  updatedAt: Date.now()
1316
3703
  };
1317
3704
  emit();
1318
- return providers;
3705
+ return report;
1319
3706
  } catch (error) {
1320
3707
  snapshot = {
1321
3708
  ...snapshot,
@@ -1353,37 +3740,166 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
1353
3740
  };
1354
3741
  };
1355
3742
 
1356
- // src/vue/useVoiceProviderStatus.ts
1357
- var useVoiceProviderStatus = (path = "/api/provider-status", options = {}) => {
1358
- const store = createVoiceProviderStatusStore(path, options);
1359
- const error = ref3(null);
1360
- const isLoading = ref3(false);
1361
- const providers = shallowRef3([]);
1362
- const updatedAt = ref3(undefined);
3743
+ // src/vue/useVoiceTraceTimeline.ts
3744
+ function useVoiceTraceTimeline(path = "/api/voice-traces", options = {}) {
3745
+ const store = createVoiceTraceTimelineStore(path, options);
3746
+ const error = ref7(null);
3747
+ const isLoading = ref7(false);
3748
+ const report = shallowRef10(null);
3749
+ const updatedAt = ref7(undefined);
1363
3750
  const sync = () => {
1364
3751
  const snapshot = store.getSnapshot();
1365
3752
  error.value = snapshot.error;
1366
3753
  isLoading.value = snapshot.isLoading;
1367
- providers.value = [...snapshot.providers];
3754
+ report.value = snapshot.report;
1368
3755
  updatedAt.value = snapshot.updatedAt;
1369
3756
  };
1370
3757
  const unsubscribe = store.subscribe(sync);
1371
3758
  sync();
1372
3759
  store.refresh().catch(() => {});
1373
- onUnmounted3(() => {
3760
+ onUnmounted11(() => {
1374
3761
  unsubscribe();
1375
3762
  store.close();
1376
3763
  });
1377
3764
  return {
1378
3765
  error,
1379
3766
  isLoading,
1380
- providers,
1381
3767
  refresh: store.refresh,
3768
+ report,
1382
3769
  updatedAt
1383
3770
  };
3771
+ }
3772
+ // src/vue/useVoiceWorkflowStatus.ts
3773
+ import { onUnmounted as onUnmounted12, ref as ref8, shallowRef as shallowRef11 } from "vue";
3774
+
3775
+ // src/client/workflowStatus.ts
3776
+ var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
3777
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3778
+ const response = await fetchImpl(path);
3779
+ if (!response.ok) {
3780
+ throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
3781
+ }
3782
+ return await response.json();
3783
+ };
3784
+ var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
3785
+ const listeners = new Set;
3786
+ let closed = false;
3787
+ let timer;
3788
+ let snapshot = {
3789
+ error: null,
3790
+ isLoading: false
3791
+ };
3792
+ const emit = () => {
3793
+ for (const listener of listeners) {
3794
+ listener();
3795
+ }
3796
+ };
3797
+ const refresh = async () => {
3798
+ if (closed) {
3799
+ return snapshot.report;
3800
+ }
3801
+ snapshot = {
3802
+ ...snapshot,
3803
+ error: null,
3804
+ isLoading: true
3805
+ };
3806
+ emit();
3807
+ try {
3808
+ const report = await fetchVoiceWorkflowStatus(path, options);
3809
+ snapshot = {
3810
+ error: null,
3811
+ isLoading: false,
3812
+ report,
3813
+ updatedAt: Date.now()
3814
+ };
3815
+ emit();
3816
+ return report;
3817
+ } catch (error) {
3818
+ snapshot = {
3819
+ ...snapshot,
3820
+ error: error instanceof Error ? error.message : String(error),
3821
+ isLoading: false
3822
+ };
3823
+ emit();
3824
+ throw error;
3825
+ }
3826
+ };
3827
+ const close = () => {
3828
+ closed = true;
3829
+ if (timer) {
3830
+ clearInterval(timer);
3831
+ timer = undefined;
3832
+ }
3833
+ listeners.clear();
3834
+ };
3835
+ if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
3836
+ timer = setInterval(() => {
3837
+ refresh().catch(() => {});
3838
+ }, options.intervalMs);
3839
+ }
3840
+ return {
3841
+ close,
3842
+ getServerSnapshot: () => snapshot,
3843
+ getSnapshot: () => snapshot,
3844
+ refresh,
3845
+ subscribe: (listener) => {
3846
+ listeners.add(listener);
3847
+ return () => {
3848
+ listeners.delete(listener);
3849
+ };
3850
+ }
3851
+ };
1384
3852
  };
3853
+
3854
+ // src/vue/useVoiceWorkflowStatus.ts
3855
+ function useVoiceWorkflowStatus(path = "/evals/scenarios/json", options = {}) {
3856
+ const store = createVoiceWorkflowStatusStore(path, options);
3857
+ const error = ref8(null);
3858
+ const isLoading = ref8(false);
3859
+ const report = shallowRef11(undefined);
3860
+ const updatedAt = ref8(undefined);
3861
+ const sync = () => {
3862
+ const snapshot = store.getSnapshot();
3863
+ error.value = snapshot.error;
3864
+ isLoading.value = snapshot.isLoading;
3865
+ report.value = snapshot.report;
3866
+ updatedAt.value = snapshot.updatedAt;
3867
+ };
3868
+ const unsubscribe = store.subscribe(sync);
3869
+ sync();
3870
+ if (typeof window !== "undefined") {
3871
+ store.refresh().catch(() => {});
3872
+ }
3873
+ onUnmounted12(() => {
3874
+ unsubscribe();
3875
+ store.close();
3876
+ });
3877
+ return {
3878
+ error,
3879
+ isLoading,
3880
+ refresh: store.refresh,
3881
+ report,
3882
+ updatedAt
3883
+ };
3884
+ }
1385
3885
  export {
3886
+ useVoiceWorkflowStatus,
3887
+ useVoiceTurnQuality,
3888
+ useVoiceTurnLatency,
3889
+ useVoiceTraceTimeline,
1386
3890
  useVoiceStream,
3891
+ useVoiceRoutingStatus,
1387
3892
  useVoiceProviderStatus,
1388
- useVoiceController
3893
+ useVoiceProviderSimulationControls,
3894
+ useVoiceProviderCapabilities,
3895
+ useVoiceOpsStatus,
3896
+ useVoiceController,
3897
+ useVoiceCampaignDialerProof,
3898
+ VoiceTurnQuality,
3899
+ VoiceTurnLatency,
3900
+ VoiceRoutingStatus,
3901
+ VoiceProviderStatus,
3902
+ VoiceProviderSimulationControls,
3903
+ VoiceProviderCapabilities,
3904
+ VoiceOpsStatus
1389
3905
  };