@absolutejs/voice 0.0.22-beta.24 → 0.0.22-beta.240

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 (216) hide show
  1. package/README.md +3112 -236
  2. package/dist/agent.d.ts +62 -0
  3. package/dist/agentSquadContract.d.ts +69 -0
  4. package/dist/angular/index.d.ts +14 -0
  5. package/dist/angular/index.js +3266 -1097
  6. package/dist/angular/voice-agent-squad-status.service.d.ts +12 -0
  7. package/dist/angular/voice-campaign-dialer-proof.service.d.ts +14 -0
  8. package/dist/angular/voice-controller.service.d.ts +1 -0
  9. package/dist/angular/voice-delivery-runtime.component.d.ts +17 -0
  10. package/dist/angular/voice-delivery-runtime.service.d.ts +16 -0
  11. package/dist/angular/voice-live-ops.service.d.ts +11 -0
  12. package/dist/angular/voice-ops-action-center.service.d.ts +13 -0
  13. package/dist/angular/voice-ops-status.component.d.ts +15 -0
  14. package/dist/angular/voice-ops-status.service.d.ts +12 -0
  15. package/dist/angular/voice-platform-coverage.service.d.ts +12 -0
  16. package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
  17. package/dist/angular/voice-provider-contracts.service.d.ts +12 -0
  18. package/dist/angular/voice-routing-status.service.d.ts +11 -0
  19. package/dist/angular/voice-stream.service.d.ts +3 -0
  20. package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
  21. package/dist/angular/voice-turn-latency.service.d.ts +13 -0
  22. package/dist/angular/voice-turn-quality.service.d.ts +12 -0
  23. package/dist/angular/voice-workflow-status.service.d.ts +12 -0
  24. package/dist/audit.d.ts +128 -0
  25. package/dist/auditDeliveryRoutes.d.ts +85 -0
  26. package/dist/auditExport.d.ts +34 -0
  27. package/dist/auditRoutes.d.ts +66 -0
  28. package/dist/auditSinks.d.ts +151 -0
  29. package/dist/bargeInRoutes.d.ts +56 -0
  30. package/dist/campaign.d.ts +746 -0
  31. package/dist/campaignDialers.d.ts +90 -0
  32. package/dist/client/actions.d.ts +105 -0
  33. package/dist/client/agentSquadStatus.d.ts +37 -0
  34. package/dist/client/agentSquadStatusWidget.d.ts +24 -0
  35. package/dist/client/bargeInMonitor.d.ts +7 -0
  36. package/dist/client/campaignDialerProof.d.ts +23 -0
  37. package/dist/client/connection.d.ts +3 -0
  38. package/dist/client/deliveryRuntime.d.ts +34 -0
  39. package/dist/client/deliveryRuntimeWidget.d.ts +37 -0
  40. package/dist/client/duplex.d.ts +1 -1
  41. package/dist/client/htmxBootstrap.js +747 -15
  42. package/dist/client/index.d.ts +64 -0
  43. package/dist/client/index.js +4594 -21
  44. package/dist/client/liveOps.d.ts +22 -0
  45. package/dist/client/liveOpsWidget.d.ts +23 -0
  46. package/dist/client/liveTurnLatency.d.ts +41 -0
  47. package/dist/client/opsActionCenter.d.ts +54 -0
  48. package/dist/client/opsActionCenterWidget.d.ts +29 -0
  49. package/dist/client/opsActionHistory.d.ts +19 -0
  50. package/dist/client/opsActionHistoryWidget.d.ts +11 -0
  51. package/dist/client/opsStatus.d.ts +19 -0
  52. package/dist/client/opsStatusWidget.d.ts +40 -0
  53. package/dist/client/platformCoverage.d.ts +19 -0
  54. package/dist/client/platformCoverageWidget.d.ts +37 -0
  55. package/dist/client/providerCapabilities.d.ts +19 -0
  56. package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
  57. package/dist/client/providerContracts.d.ts +19 -0
  58. package/dist/client/providerContractsWidget.d.ts +37 -0
  59. package/dist/client/providerSimulationControls.d.ts +33 -0
  60. package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
  61. package/dist/client/providerStatusWidget.d.ts +32 -0
  62. package/dist/client/routingStatus.d.ts +19 -0
  63. package/dist/client/routingStatusWidget.d.ts +28 -0
  64. package/dist/client/traceTimeline.d.ts +19 -0
  65. package/dist/client/traceTimelineWidget.d.ts +36 -0
  66. package/dist/client/turnLatency.d.ts +22 -0
  67. package/dist/client/turnLatencyWidget.d.ts +33 -0
  68. package/dist/client/turnQuality.d.ts +19 -0
  69. package/dist/client/turnQualityWidget.d.ts +32 -0
  70. package/dist/client/workflowStatus.d.ts +19 -0
  71. package/dist/dataControl.d.ts +140 -0
  72. package/dist/deliveryRuntime.d.ts +158 -0
  73. package/dist/deliverySinkRoutes.d.ts +117 -0
  74. package/dist/demoReadyRoutes.d.ts +98 -0
  75. package/dist/diagnosticsRoutes.d.ts +44 -0
  76. package/dist/evalRoutes.d.ts +219 -0
  77. package/dist/fileStore.d.ts +14 -2
  78. package/dist/handoff.d.ts +54 -0
  79. package/dist/handoffHealth.d.ts +94 -0
  80. package/dist/incidentBundle.d.ts +116 -0
  81. package/dist/index.d.ts +128 -13
  82. package/dist/index.js +23685 -5200
  83. package/dist/latencySlo.d.ts +56 -0
  84. package/dist/liveLatency.d.ts +78 -0
  85. package/dist/liveOps.d.ts +122 -0
  86. package/dist/modelAdapters.d.ts +23 -2
  87. package/dist/observabilityExport.d.ts +428 -0
  88. package/dist/openaiRealtime.d.ts +27 -0
  89. package/dist/openaiTTS.d.ts +18 -0
  90. package/dist/operationsRecord.d.ts +158 -0
  91. package/dist/opsActionAuditRoutes.d.ts +99 -0
  92. package/dist/opsConsoleRoutes.d.ts +80 -0
  93. package/dist/opsRecovery.d.ts +137 -0
  94. package/dist/opsStatus.d.ts +76 -0
  95. package/dist/opsStatusRoutes.d.ts +33 -0
  96. package/dist/opsWebhook.d.ts +126 -0
  97. package/dist/outcomeContract.d.ts +115 -0
  98. package/dist/phoneAgent.d.ts +76 -0
  99. package/dist/phoneAgentProductionSmoke.d.ts +115 -0
  100. package/dist/platformCoverage.d.ts +73 -0
  101. package/dist/postgresStore.d.ts +13 -2
  102. package/dist/productionReadiness.d.ts +466 -0
  103. package/dist/providerAdapters.d.ts +48 -0
  104. package/dist/providerCapabilities.d.ts +92 -0
  105. package/dist/providerHealth.d.ts +1 -0
  106. package/dist/providerRoutingContract.d.ts +38 -0
  107. package/dist/providerSlo.d.ts +114 -0
  108. package/dist/providerStackRecommendations.d.ts +145 -0
  109. package/dist/qualityRoutes.d.ts +76 -0
  110. package/dist/queue.d.ts +61 -0
  111. package/dist/react/VoiceAgentSquadStatus.d.ts +5 -0
  112. package/dist/react/VoiceDeliveryRuntime.d.ts +7 -0
  113. package/dist/react/VoiceOpsActionCenter.d.ts +5 -0
  114. package/dist/react/VoiceOpsStatus.d.ts +6 -0
  115. package/dist/react/VoicePlatformCoverage.d.ts +6 -0
  116. package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
  117. package/dist/react/VoiceProviderContracts.d.ts +6 -0
  118. package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
  119. package/dist/react/VoiceProviderStatus.d.ts +6 -0
  120. package/dist/react/VoiceRoutingStatus.d.ts +6 -0
  121. package/dist/react/VoiceTraceTimeline.d.ts +6 -0
  122. package/dist/react/VoiceTurnLatency.d.ts +6 -0
  123. package/dist/react/VoiceTurnQuality.d.ts +6 -0
  124. package/dist/react/index.d.ts +28 -0
  125. package/dist/react/index.js +4359 -33
  126. package/dist/react/useVoiceAgentSquadStatus.d.ts +8 -0
  127. package/dist/react/useVoiceCampaignDialerProof.d.ts +10 -0
  128. package/dist/react/useVoiceController.d.ts +3 -0
  129. package/dist/react/useVoiceDeliveryRuntime.d.ts +13 -0
  130. package/dist/react/useVoiceLiveOps.d.ts +9 -0
  131. package/dist/react/useVoiceOpsActionCenter.d.ts +11 -0
  132. package/dist/react/useVoiceOpsStatus.d.ts +8 -0
  133. package/dist/react/useVoicePlatformCoverage.d.ts +8 -0
  134. package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
  135. package/dist/react/useVoiceProviderContracts.d.ts +8 -0
  136. package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
  137. package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
  138. package/dist/react/useVoiceStream.d.ts +3 -0
  139. package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
  140. package/dist/react/useVoiceTurnLatency.d.ts +9 -0
  141. package/dist/react/useVoiceTurnQuality.d.ts +8 -0
  142. package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
  143. package/dist/readinessProfiles.d.ts +37 -0
  144. package/dist/reconnectContract.d.ts +87 -0
  145. package/dist/resilienceRoutes.d.ts +143 -0
  146. package/dist/sessionReplay.d.ts +12 -0
  147. package/dist/simulationSuite.d.ts +121 -0
  148. package/dist/sqliteStore.d.ts +13 -2
  149. package/dist/svelte/createVoiceAgentSquadStatus.d.ts +9 -0
  150. package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
  151. package/dist/svelte/createVoiceDeliveryRuntime.d.ts +11 -0
  152. package/dist/svelte/createVoiceLiveOps.d.ts +13 -0
  153. package/dist/svelte/createVoiceOpsActionCenter.d.ts +10 -0
  154. package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
  155. package/dist/svelte/createVoicePlatformCoverage.d.ts +7 -0
  156. package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
  157. package/dist/svelte/createVoiceProviderContracts.d.ts +10 -0
  158. package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
  159. package/dist/svelte/createVoiceProviderStatus.d.ts +4 -2
  160. package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
  161. package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
  162. package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
  163. package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
  164. package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
  165. package/dist/svelte/index.d.ts +15 -0
  166. package/dist/svelte/index.js +4664 -439
  167. package/dist/telephony/contract.d.ts +61 -0
  168. package/dist/telephony/matrix.d.ts +97 -0
  169. package/dist/telephony/plivo.d.ts +254 -0
  170. package/dist/telephony/telnyx.d.ts +247 -0
  171. package/dist/telephony/twilio.d.ts +135 -2
  172. package/dist/telephonyOutcome.d.ts +201 -0
  173. package/dist/testing/index.d.ts +1 -0
  174. package/dist/testing/index.js +2024 -69
  175. package/dist/testing/ioProviderSimulator.d.ts +41 -0
  176. package/dist/toolContract.d.ts +133 -0
  177. package/dist/toolRuntime.d.ts +50 -0
  178. package/dist/trace.d.ts +19 -1
  179. package/dist/traceDeliveryRoutes.d.ts +86 -0
  180. package/dist/traceTimeline.d.ts +97 -0
  181. package/dist/turnLatency.d.ts +95 -0
  182. package/dist/turnQuality.d.ts +94 -0
  183. package/dist/types.d.ts +180 -4
  184. package/dist/vue/VoiceDeliveryRuntime.d.ts +30 -0
  185. package/dist/vue/VoiceOpsActionCenter.d.ts +13 -0
  186. package/dist/vue/VoiceOpsStatus.d.ts +30 -0
  187. package/dist/vue/VoicePlatformCoverage.d.ts +23 -0
  188. package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
  189. package/dist/vue/VoiceProviderContracts.d.ts +21 -0
  190. package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
  191. package/dist/vue/VoiceProviderStatus.d.ts +51 -0
  192. package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
  193. package/dist/vue/VoiceTurnLatency.d.ts +69 -0
  194. package/dist/vue/VoiceTurnQuality.d.ts +51 -0
  195. package/dist/vue/index.d.ts +26 -0
  196. package/dist/vue/index.js +4136 -57
  197. package/dist/vue/useVoiceAgentSquadStatus.d.ts +9 -0
  198. package/dist/vue/useVoiceCampaignDialerProof.d.ts +11 -0
  199. package/dist/vue/useVoiceController.d.ts +2 -1
  200. package/dist/vue/useVoiceDeliveryRuntime.d.ts +13 -0
  201. package/dist/vue/useVoiceLiveOps.d.ts +9 -0
  202. package/dist/vue/useVoiceOpsActionCenter.d.ts +11 -0
  203. package/dist/vue/useVoiceOpsStatus.d.ts +9 -0
  204. package/dist/vue/useVoicePlatformCoverage.d.ts +9 -0
  205. package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
  206. package/dist/vue/useVoiceProviderContracts.d.ts +9 -0
  207. package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
  208. package/dist/vue/useVoiceProviderStatus.d.ts +1 -1
  209. package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
  210. package/dist/vue/useVoiceStream.d.ts +4 -1
  211. package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
  212. package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
  213. package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
  214. package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
  215. package/dist/workflowContract.d.ts +91 -0
  216. package/package.json +1 -1
package/dist/vue/index.js CHANGED
@@ -69,8 +69,3840 @@ 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/VoiceOpsActionCenter.ts
378
+ import { defineComponent as defineComponent2, h as h2 } from "vue";
379
+
380
+ // src/client/opsActionCenter.ts
381
+ var recordVoiceOpsActionResult = async (result, options = {}) => {
382
+ if (options.auditPath === false) {
383
+ return;
384
+ }
385
+ const path = options.auditPath ?? "/api/voice/ops-actions/audit";
386
+ const fetchImpl = options.fetch ?? globalThis.fetch;
387
+ const response = await fetchImpl(path, {
388
+ body: JSON.stringify(result),
389
+ headers: {
390
+ "Content-Type": "application/json"
391
+ },
392
+ method: "POST"
393
+ });
394
+ if (!response.ok) {
395
+ throw new Error(`Voice ops action audit failed: HTTP ${response.status}`);
396
+ }
397
+ };
398
+ var createVoiceOpsActionCenterActions = (options = {}) => {
399
+ const deliveryRuntimePath = options.deliveryRuntimePath ?? "/api/voice-delivery-runtime";
400
+ const actions = [];
401
+ if (options.includeProductionReadiness !== false) {
402
+ actions.push({
403
+ description: "Refresh the production readiness report.",
404
+ id: "production-readiness",
405
+ label: "Refresh readiness",
406
+ method: "GET",
407
+ path: options.productionReadinessPath ?? "/api/production-readiness"
408
+ });
409
+ }
410
+ if (options.includeDeliveryRuntime !== false) {
411
+ actions.push({
412
+ description: "Drain pending and failed audit/trace deliveries.",
413
+ id: "delivery-runtime.tick",
414
+ label: "Tick delivery workers",
415
+ method: "POST",
416
+ path: `${deliveryRuntimePath.replace(/\/$/, "")}/tick`
417
+ }, {
418
+ description: "Move reviewed dead letters back to live delivery queues.",
419
+ id: "delivery-runtime.requeue-dead-letters",
420
+ label: "Requeue dead letters",
421
+ method: "POST",
422
+ path: `${deliveryRuntimePath.replace(/\/$/, "")}/requeue-dead-letters`
423
+ });
424
+ }
425
+ if (options.includeTurnLatencyProof !== false) {
426
+ actions.push({
427
+ description: "Run the synthetic turn latency proof.",
428
+ id: "turn-latency.proof",
429
+ label: "Run latency proof",
430
+ method: "POST",
431
+ path: options.turnLatencyProofPath ?? "/api/turn-latency/proof"
432
+ });
433
+ }
434
+ if (options.includeProviderSimulation !== false) {
435
+ const pathPrefix = options.providerSimulationPathPrefix ?? "/api/stt-simulate";
436
+ for (const provider of options.providers ?? []) {
437
+ actions.push({
438
+ description: `Simulate ${provider} provider failure.`,
439
+ id: `provider.${provider}.failure`,
440
+ label: `Simulate ${provider} failure`,
441
+ method: "POST",
442
+ path: `${pathPrefix}/failure?provider=${encodeURIComponent(provider)}`
443
+ }, {
444
+ description: `Mark ${provider} provider recovered.`,
445
+ id: `provider.${provider}.recovery`,
446
+ label: `Recover ${provider}`,
447
+ method: "POST",
448
+ path: `${pathPrefix}/recovery?provider=${encodeURIComponent(provider)}`
449
+ });
450
+ }
451
+ }
452
+ return actions;
453
+ };
454
+ var runVoiceOpsAction = async (action, options = {}) => {
455
+ const fetchImpl = options.fetch ?? globalThis.fetch;
456
+ const response = await fetchImpl(action.path, {
457
+ method: action.method ?? "POST"
458
+ });
459
+ const body = await response.json().catch(() => null);
460
+ if (!response.ok) {
461
+ const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice ops action "${action.id}" failed: HTTP ${response.status}`;
462
+ throw new Error(message);
463
+ }
464
+ return {
465
+ actionId: action.id,
466
+ body,
467
+ ok: response.ok,
468
+ ranAt: Date.now(),
469
+ status: response.status
470
+ };
471
+ };
472
+ var createVoiceOpsActionCenterStore = (options = {}) => {
473
+ const listeners = new Set;
474
+ let closed = false;
475
+ let timer;
476
+ let snapshot = {
477
+ actions: options.actions ?? createVoiceOpsActionCenterActions(),
478
+ error: null,
479
+ isRunning: false
480
+ };
481
+ const emit = () => {
482
+ for (const listener of listeners) {
483
+ listener();
484
+ }
485
+ };
486
+ const setActions = (actions) => {
487
+ snapshot = { ...snapshot, actions, updatedAt: Date.now() };
488
+ emit();
489
+ };
490
+ const run = async (actionId) => {
491
+ if (closed) {
492
+ return snapshot.lastResult;
493
+ }
494
+ const action = snapshot.actions.find((item) => item.id === actionId);
495
+ if (!action) {
496
+ throw new Error(`Voice ops action "${actionId}" is not configured.`);
497
+ }
498
+ if (action.disabled) {
499
+ throw new Error(`Voice ops action "${actionId}" is disabled.`);
500
+ }
501
+ snapshot = {
502
+ ...snapshot,
503
+ error: null,
504
+ isRunning: true,
505
+ runningActionId: action.id
506
+ };
507
+ emit();
508
+ try {
509
+ const result = await runVoiceOpsAction(action, options);
510
+ await options.onActionResult?.(result);
511
+ await recordVoiceOpsActionResult(result, options);
512
+ snapshot = {
513
+ ...snapshot,
514
+ error: null,
515
+ isRunning: false,
516
+ lastResult: result,
517
+ runningActionId: undefined,
518
+ updatedAt: Date.now()
519
+ };
520
+ emit();
521
+ return result;
522
+ } catch (error) {
523
+ const result = {
524
+ actionId: action.id,
525
+ body: null,
526
+ error: error instanceof Error ? error.message : String(error),
527
+ ok: false,
528
+ ranAt: Date.now(),
529
+ status: 0
530
+ };
531
+ await options.onActionResult?.(result);
532
+ await recordVoiceOpsActionResult(result, options).catch(() => {});
533
+ snapshot = {
534
+ ...snapshot,
535
+ error: error instanceof Error ? error.message : String(error),
536
+ isRunning: false,
537
+ runningActionId: undefined
538
+ };
539
+ emit();
540
+ throw error;
541
+ }
542
+ };
543
+ const close = () => {
544
+ closed = true;
545
+ if (timer) {
546
+ clearInterval(timer);
547
+ timer = undefined;
548
+ }
549
+ listeners.clear();
550
+ };
551
+ if (options.intervalMs && options.intervalMs > 0) {
552
+ timer = setInterval(() => {
553
+ emit();
554
+ }, options.intervalMs);
555
+ }
556
+ return {
557
+ close,
558
+ getServerSnapshot: () => snapshot,
559
+ getSnapshot: () => snapshot,
560
+ run,
561
+ setActions,
562
+ subscribe: (listener) => {
563
+ listeners.add(listener);
564
+ return () => {
565
+ listeners.delete(listener);
566
+ };
567
+ }
568
+ };
569
+ };
570
+
571
+ // src/client/opsActionCenterWidget.ts
572
+ var DEFAULT_TITLE2 = "Voice Ops Action Center";
573
+ var DEFAULT_DESCRIPTION2 = "Run production voice proofs and operator actions from one primitive panel.";
574
+ var escapeHtml2 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
575
+ var createVoiceOpsActionCenterViewModel = (snapshot, options = {}) => {
576
+ const status = snapshot.error ? "error" : snapshot.isRunning ? "running" : snapshot.lastResult ? "completed" : "ready";
577
+ return {
578
+ actions: snapshot.actions.map((action) => ({
579
+ description: action.description ?? "",
580
+ disabled: Boolean(action.disabled || snapshot.isRunning),
581
+ id: action.id,
582
+ isRunning: snapshot.runningActionId === action.id,
583
+ label: action.label
584
+ })),
585
+ description: options.description ?? DEFAULT_DESCRIPTION2,
586
+ error: snapshot.error,
587
+ isRunning: snapshot.isRunning,
588
+ label: status === "error" ? "Needs attention" : status === "running" ? "Running" : status === "completed" ? "Action completed" : "Ready",
589
+ lastResultLabel: snapshot.lastResult ? `${snapshot.lastResult.actionId} returned HTTP ${snapshot.lastResult.status}` : "No action has run yet.",
590
+ status,
591
+ title: options.title ?? DEFAULT_TITLE2
592
+ };
593
+ };
594
+ var renderVoiceOpsActionCenterHTML = (snapshot, options = {}) => {
595
+ const model = createVoiceOpsActionCenterViewModel(snapshot, options);
596
+ const actions = model.actions.map((action) => `<button type="button" data-absolute-voice-ops-action="${escapeHtml2(action.id)}"${action.disabled ? " disabled" : ""}>
597
+ ${escapeHtml2(action.isRunning ? "Working..." : action.label)}
598
+ </button>`).join("");
599
+ return `<section class="absolute-voice-ops-action-center absolute-voice-ops-action-center--${escapeHtml2(model.status)}">
600
+ <header class="absolute-voice-ops-action-center__header">
601
+ <span class="absolute-voice-ops-action-center__eyebrow">${escapeHtml2(model.title)}</span>
602
+ <strong class="absolute-voice-ops-action-center__label">${escapeHtml2(model.label)}</strong>
603
+ </header>
604
+ <p class="absolute-voice-ops-action-center__description">${escapeHtml2(model.description)}</p>
605
+ <div class="absolute-voice-ops-action-center__actions">${actions}</div>
606
+ <p class="absolute-voice-ops-action-center__result">${escapeHtml2(model.lastResultLabel)}</p>
607
+ ${model.error ? `<p class="absolute-voice-ops-action-center__error">${escapeHtml2(model.error)}</p>` : ""}
608
+ </section>`;
609
+ };
610
+ var getVoiceOpsActionCenterCSS = () => `.absolute-voice-ops-action-center{border:1px solid #d5cbb8;border-radius:20px;background:#fffaf1;color:#17130b;padding:18px;box-shadow:0 18px 40px rgba(58,42,16,.12);font-family:inherit}.absolute-voice-ops-action-center--error{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-ops-action-center__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-ops-action-center__eyebrow{color:#725d37;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-ops-action-center__label{font-size:28px;line-height:1}.absolute-voice-ops-action-center__description,.absolute-voice-ops-action-center__result{color:#5b4b2f;margin:12px 0 0}.absolute-voice-ops-action-center__actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.absolute-voice-ops-action-center__actions button{background:#7c4a03;border:0;border-radius:999px;color:#fff8e8;cursor:pointer;font:inherit;font-weight:800;padding:8px 12px}.absolute-voice-ops-action-center__actions button:disabled{cursor:not-allowed;opacity:.5}.absolute-voice-ops-action-center__error{color:#9f1239;font-weight:700}`;
611
+ var mountVoiceOpsActionCenter = (element, options = {}) => {
612
+ const store = createVoiceOpsActionCenterStore(options);
613
+ const render = () => {
614
+ element.innerHTML = renderVoiceOpsActionCenterHTML(store.getSnapshot(), options);
615
+ };
616
+ const unsubscribe = store.subscribe(render);
617
+ const handleClick = (event) => {
618
+ const target = event.target;
619
+ if (!(target instanceof Element)) {
620
+ return;
621
+ }
622
+ const action = target.closest("[data-absolute-voice-ops-action]");
623
+ const actionId = action?.getAttribute("data-absolute-voice-ops-action");
624
+ if (actionId) {
625
+ store.run(actionId).catch(() => {});
626
+ }
627
+ };
628
+ element.addEventListener?.("click", handleClick);
629
+ render();
630
+ return {
631
+ close: () => {
632
+ element.removeEventListener?.("click", handleClick);
633
+ unsubscribe();
634
+ store.close();
635
+ },
636
+ run: store.run
637
+ };
638
+ };
639
+ var defineVoiceOpsActionCenterElement = (tagName = "absolute-voice-ops-action-center", options = {}) => {
640
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
641
+ return;
642
+ }
643
+ customElements.define(tagName, class AbsoluteVoiceOpsActionCenterElement extends HTMLElement {
644
+ mounted;
645
+ connectedCallback() {
646
+ this.mounted = mountVoiceOpsActionCenter(this, {
647
+ ...options,
648
+ description: this.getAttribute("description") ?? options.description,
649
+ title: this.getAttribute("title") ?? options.title
650
+ });
651
+ }
652
+ disconnectedCallback() {
653
+ this.mounted?.close();
654
+ this.mounted = undefined;
655
+ }
656
+ });
657
+ };
658
+
659
+ // src/vue/useVoiceOpsActionCenter.ts
660
+ import { onUnmounted as onUnmounted2, ref as ref2, shallowRef as shallowRef2 } from "vue";
661
+ function useVoiceOpsActionCenter(options = {}) {
662
+ const store = createVoiceOpsActionCenterStore(options);
663
+ const actions = shallowRef2([]);
664
+ const error = ref2(null);
665
+ const isRunning = ref2(false);
666
+ const lastResult = shallowRef2(undefined);
667
+ const runningActionId = ref2(undefined);
668
+ const updatedAt = ref2(undefined);
669
+ const sync = () => {
670
+ const snapshot = store.getSnapshot();
671
+ actions.value = snapshot.actions;
672
+ error.value = snapshot.error;
673
+ isRunning.value = snapshot.isRunning;
674
+ lastResult.value = snapshot.lastResult;
675
+ runningActionId.value = snapshot.runningActionId;
676
+ updatedAt.value = snapshot.updatedAt;
677
+ };
678
+ const unsubscribe = store.subscribe(sync);
679
+ sync();
680
+ onUnmounted2(() => {
681
+ unsubscribe();
682
+ store.close();
683
+ });
684
+ return {
685
+ actions,
686
+ error,
687
+ isRunning,
688
+ lastResult,
689
+ run: store.run,
690
+ runningActionId,
691
+ setActions: store.setActions,
692
+ updatedAt
693
+ };
694
+ }
695
+
696
+ // src/vue/VoiceOpsActionCenter.ts
697
+ var VoiceOpsActionCenter = defineComponent2({
698
+ name: "VoiceOpsActionCenter",
699
+ props: {
700
+ actions: Array,
701
+ description: String,
702
+ title: String
703
+ },
704
+ setup(props) {
705
+ const options = {
706
+ actions: props.actions,
707
+ description: props.description,
708
+ title: props.title
709
+ };
710
+ const center = useVoiceOpsActionCenter(options);
711
+ return () => {
712
+ const model = createVoiceOpsActionCenterViewModel({
713
+ actions: center.actions.value,
714
+ error: center.error.value,
715
+ isRunning: center.isRunning.value,
716
+ lastResult: center.lastResult.value,
717
+ runningActionId: center.runningActionId.value,
718
+ updatedAt: center.updatedAt.value
719
+ }, options);
720
+ return h2("section", {
721
+ class: [
722
+ "absolute-voice-ops-action-center",
723
+ `absolute-voice-ops-action-center--${model.status}`
724
+ ]
725
+ }, [
726
+ h2("header", { class: "absolute-voice-ops-action-center__header" }, [
727
+ h2("span", { class: "absolute-voice-ops-action-center__eyebrow" }, model.title),
728
+ h2("strong", { class: "absolute-voice-ops-action-center__label" }, model.label)
729
+ ]),
730
+ h2("p", { class: "absolute-voice-ops-action-center__description" }, model.description),
731
+ h2("div", { class: "absolute-voice-ops-action-center__actions" }, model.actions.map((action) => h2("button", {
732
+ disabled: action.disabled,
733
+ key: action.id,
734
+ onClick: () => {
735
+ center.run(action.id).catch(() => {});
736
+ },
737
+ type: "button"
738
+ }, action.isRunning ? "Working..." : action.label))),
739
+ h2("p", { class: "absolute-voice-ops-action-center__result" }, model.lastResultLabel),
740
+ model.error ? h2("p", { class: "absolute-voice-ops-action-center__error" }, model.error) : null
741
+ ]);
742
+ };
743
+ }
744
+ });
745
+ // src/vue/VoiceDeliveryRuntime.ts
746
+ import { defineComponent as defineComponent3, h as h3 } from "vue";
747
+
748
+ // src/client/deliveryRuntime.ts
749
+ var getDefaultActionPath = (path, action, options) => {
750
+ if (action === "tick") {
751
+ return options.tickPath ?? `${path.replace(/\/$/, "")}/tick`;
752
+ }
753
+ return options.requeueDeadLettersPath ?? `${path.replace(/\/$/, "")}/requeue-dead-letters`;
754
+ };
755
+ var fetchVoiceDeliveryRuntime = async (path = "/api/voice-delivery-runtime", options = {}) => {
756
+ const fetchImpl = options.fetch ?? globalThis.fetch;
757
+ const response = await fetchImpl(path);
758
+ if (!response.ok) {
759
+ throw new Error(`Voice delivery runtime failed: HTTP ${response.status}`);
760
+ }
761
+ return await response.json();
762
+ };
763
+ var runVoiceDeliveryRuntimeAction = async (action, path = "/api/voice-delivery-runtime", options = {}) => {
764
+ const fetchImpl = options.fetch ?? globalThis.fetch;
765
+ const response = await fetchImpl(getDefaultActionPath(path, action, options), {
766
+ method: "POST"
767
+ });
768
+ if (!response.ok) {
769
+ throw new Error(`Voice delivery runtime ${action} failed: HTTP ${response.status}`);
770
+ }
771
+ const body = await response.json();
772
+ return {
773
+ action,
774
+ result: body.result,
775
+ summary: body.summary,
776
+ updatedAt: Date.now()
777
+ };
778
+ };
779
+ var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", options = {}) => {
780
+ const listeners = new Set;
781
+ let closed = false;
782
+ let timer;
783
+ let snapshot = {
784
+ actionError: null,
785
+ actionStatus: "idle",
786
+ error: null,
787
+ isLoading: false
788
+ };
789
+ const emit = () => {
790
+ for (const listener of listeners) {
791
+ listener();
792
+ }
793
+ };
794
+ const refresh = async () => {
795
+ if (closed) {
796
+ return snapshot.report;
797
+ }
798
+ snapshot = {
799
+ ...snapshot,
800
+ error: null,
801
+ isLoading: true
802
+ };
803
+ emit();
804
+ try {
805
+ const report = await fetchVoiceDeliveryRuntime(path, options);
806
+ snapshot = {
807
+ ...snapshot,
808
+ error: null,
809
+ isLoading: false,
810
+ report,
811
+ updatedAt: Date.now()
812
+ };
813
+ emit();
814
+ return report;
815
+ } catch (error) {
816
+ snapshot = {
817
+ ...snapshot,
818
+ error: error instanceof Error ? error.message : String(error),
819
+ isLoading: false
820
+ };
821
+ emit();
822
+ throw error;
823
+ }
824
+ };
825
+ const runAction = async (action) => {
826
+ if (closed) {
827
+ return snapshot.lastAction;
828
+ }
829
+ snapshot = {
830
+ ...snapshot,
831
+ actionError: null,
832
+ actionStatus: "running"
833
+ };
834
+ emit();
835
+ try {
836
+ const result = await runVoiceDeliveryRuntimeAction(action, path, options);
837
+ snapshot = {
838
+ ...snapshot,
839
+ actionError: null,
840
+ actionStatus: "completed",
841
+ lastAction: result
842
+ };
843
+ emit();
844
+ await refresh();
845
+ return result;
846
+ } catch (error) {
847
+ snapshot = {
848
+ ...snapshot,
849
+ actionError: error instanceof Error ? error.message : String(error),
850
+ actionStatus: "failed"
851
+ };
852
+ emit();
853
+ throw error;
854
+ }
855
+ };
856
+ const close = () => {
857
+ closed = true;
858
+ if (timer) {
859
+ clearInterval(timer);
860
+ timer = undefined;
861
+ }
862
+ listeners.clear();
863
+ };
864
+ if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
865
+ timer = setInterval(() => {
866
+ refresh().catch(() => {});
867
+ }, options.intervalMs);
868
+ }
869
+ return {
870
+ close,
871
+ getServerSnapshot: () => snapshot,
872
+ getSnapshot: () => snapshot,
873
+ requeueDeadLetters: () => runAction("requeue-dead-letters"),
874
+ refresh,
875
+ tick: () => runAction("tick"),
876
+ subscribe: (listener) => {
877
+ listeners.add(listener);
878
+ return () => {
879
+ listeners.delete(listener);
880
+ };
881
+ }
882
+ };
883
+ };
884
+
885
+ // src/client/deliveryRuntimeWidget.ts
886
+ var DEFAULT_TITLE3 = "Voice Delivery Runtime";
887
+ var DEFAULT_DESCRIPTION3 = "Audit and trace delivery worker health from your AbsoluteJS voice app.";
888
+ var escapeHtml3 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
889
+ var createSurface = (id, summary) => {
890
+ if (!summary) {
891
+ return {
892
+ deadLettered: 0,
893
+ detail: "Worker disabled",
894
+ failed: 0,
895
+ id,
896
+ label: id === "audit" ? "Audit delivery" : "Trace delivery",
897
+ pending: 0,
898
+ status: "disabled",
899
+ total: 0
900
+ };
901
+ }
902
+ const blocked = summary.failed + summary.deadLettered;
903
+ return {
904
+ deadLettered: summary.deadLettered,
905
+ detail: `${summary.delivered}/${summary.total} delivered, ${summary.pending} pending`,
906
+ failed: summary.failed,
907
+ id,
908
+ label: id === "audit" ? "Audit delivery" : "Trace delivery",
909
+ pending: summary.pending,
910
+ status: blocked > 0 ? "warn" : "pass",
911
+ total: summary.total
912
+ };
913
+ };
914
+ var createVoiceDeliveryRuntimeViewModel = (snapshot, options = {}) => {
915
+ const report = snapshot.report;
916
+ const surfaces = [
917
+ createSurface("audit", report?.summary.audit),
918
+ createSurface("trace", report?.summary.trace)
919
+ ];
920
+ const hasWarnings = surfaces.some((surface) => surface.status === "warn");
921
+ return {
922
+ description: options.description ?? DEFAULT_DESCRIPTION3,
923
+ error: snapshot.error,
924
+ actionError: snapshot.actionError,
925
+ actionStatus: snapshot.actionStatus,
926
+ isLoading: snapshot.isLoading,
927
+ isRunning: Boolean(report?.isRunning),
928
+ label: snapshot.error ? "Unavailable" : report ? report.isRunning ? "Running" : "Stopped" : "Checking",
929
+ status: snapshot.error ? "error" : report ? hasWarnings ? "warn" : "pass" : "loading",
930
+ surfaces,
931
+ title: options.title ?? DEFAULT_TITLE3,
932
+ updatedAt: snapshot.updatedAt
933
+ };
934
+ };
935
+ var renderVoiceDeliveryRuntimeHTML = (snapshot, options = {}) => {
936
+ const model = createVoiceDeliveryRuntimeViewModel(snapshot, options);
937
+ const surfaces = model.surfaces.map((surface) => `<li class="absolute-voice-delivery-runtime__surface absolute-voice-delivery-runtime__surface--${escapeHtml3(surface.status)}">
938
+ <span>${escapeHtml3(surface.label)}</span>
939
+ <strong>${escapeHtml3(surface.detail)}</strong>
940
+ <small>${String(surface.failed)} failed &middot; ${String(surface.deadLettered)} dead-lettered</small>
941
+ </li>`).join("");
942
+ const actions = options.includeActions === false ? "" : `<div class="absolute-voice-delivery-runtime__actions">
943
+ <button type="button" data-absolute-voice-delivery-runtime-action="tick">${model.actionStatus === "running" ? "Working..." : "Tick workers"}</button>
944
+ <button type="button" data-absolute-voice-delivery-runtime-action="requeue-dead-letters"${model.surfaces.some((surface) => surface.deadLettered > 0) ? "" : " disabled"}>Requeue dead letters</button>
945
+ </div>`;
946
+ const actionError = model.actionError ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml3(model.actionError)}</p>` : "";
947
+ return `<section class="absolute-voice-delivery-runtime absolute-voice-delivery-runtime--${escapeHtml3(model.status)}">
948
+ <header class="absolute-voice-delivery-runtime__header">
949
+ <span class="absolute-voice-delivery-runtime__eyebrow">${escapeHtml3(model.title)}</span>
950
+ <strong class="absolute-voice-delivery-runtime__label">${escapeHtml3(model.label)}</strong>
951
+ </header>
952
+ <p class="absolute-voice-delivery-runtime__description">${escapeHtml3(model.description)}</p>
953
+ <ul class="absolute-voice-delivery-runtime__surfaces">${surfaces}</ul>
954
+ ${actions}
955
+ ${actionError}
956
+ ${model.error ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml3(model.error)}</p>` : ""}
957
+ </section>`;
958
+ };
959
+ var getVoiceDeliveryRuntimeCSS = () => `.absolute-voice-delivery-runtime{border:1px solid #c9d8cf;border-radius:20px;background:#f6fff9;color:#0d1b12;padding:18px;box-shadow:0 18px 40px rgba(19,55,35,.12);font-family:inherit}.absolute-voice-delivery-runtime--warn,.absolute-voice-delivery-runtime--error{border-color:#f2b56b;background:#fff9ed}.absolute-voice-delivery-runtime__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-delivery-runtime__eyebrow{color:#4e6b59;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-delivery-runtime__label{font-size:28px;line-height:1}.absolute-voice-delivery-runtime__description{color:#33483b;margin:12px 0 0}.absolute-voice-delivery-runtime__surfaces{display:grid;gap:8px;list-style:none;margin:16px 0 0;padding:0}.absolute-voice-delivery-runtime__surface{background:#fff;border:1px solid #d9eadf;border-radius:14px;display:grid;gap:4px;padding:10px 12px}.absolute-voice-delivery-runtime__surface--warn{border-color:#f2b56b}.absolute-voice-delivery-runtime__surface--disabled{opacity:.72}.absolute-voice-delivery-runtime__surface span,.absolute-voice-delivery-runtime__surface small{color:#587063}.absolute-voice-delivery-runtime__actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.absolute-voice-delivery-runtime__actions button{background:#134e2d;border:0;border-radius:999px;color:#f6fff9;cursor:pointer;font:inherit;font-weight:800;padding:8px 12px}.absolute-voice-delivery-runtime__actions button:disabled{cursor:not-allowed;opacity:.48}.absolute-voice-delivery-runtime__error{color:#9f1239;font-weight:700}`;
960
+ var mountVoiceDeliveryRuntime = (element, path = "/api/voice-delivery-runtime", options = {}) => {
961
+ const store = createVoiceDeliveryRuntimeStore(path, options);
962
+ const render = () => {
963
+ element.innerHTML = renderVoiceDeliveryRuntimeHTML(store.getSnapshot(), options);
964
+ };
965
+ const unsubscribe = store.subscribe(render);
966
+ const handleClick = (event) => {
967
+ const target = event.target;
968
+ if (!(target instanceof Element)) {
969
+ return;
970
+ }
971
+ const action = target.closest("[data-absolute-voice-delivery-runtime-action]");
972
+ const actionName = action?.getAttribute("data-absolute-voice-delivery-runtime-action");
973
+ if (actionName === "tick") {
974
+ store.tick().catch(() => {});
975
+ }
976
+ if (actionName === "requeue-dead-letters") {
977
+ store.requeueDeadLetters().catch(() => {});
978
+ }
979
+ };
980
+ element.addEventListener?.("click", handleClick);
981
+ render();
982
+ store.refresh().catch(() => {});
983
+ return {
984
+ close: () => {
985
+ element.removeEventListener?.("click", handleClick);
986
+ unsubscribe();
987
+ store.close();
988
+ },
989
+ refresh: store.refresh
990
+ };
991
+ };
992
+ var defineVoiceDeliveryRuntimeElement = (tagName = "absolute-voice-delivery-runtime") => {
993
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
994
+ return;
995
+ }
996
+ customElements.define(tagName, class AbsoluteVoiceDeliveryRuntimeElement extends HTMLElement {
997
+ mounted;
998
+ connectedCallback() {
999
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
1000
+ this.mounted = mountVoiceDeliveryRuntime(this, this.getAttribute("path") ?? "/api/voice-delivery-runtime", {
1001
+ description: this.getAttribute("description") ?? undefined,
1002
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
1003
+ title: this.getAttribute("title") ?? undefined
1004
+ });
1005
+ }
1006
+ disconnectedCallback() {
1007
+ this.mounted?.close();
1008
+ this.mounted = undefined;
1009
+ }
1010
+ });
1011
+ };
1012
+
1013
+ // src/vue/useVoiceDeliveryRuntime.ts
1014
+ import { onUnmounted as onUnmounted3, ref as ref3, shallowRef as shallowRef3 } from "vue";
1015
+ function useVoiceDeliveryRuntime(path = "/api/voice-delivery-runtime", options = {}) {
1016
+ const store = createVoiceDeliveryRuntimeStore(path, options);
1017
+ const actionError = ref3(null);
1018
+ const actionStatus = ref3("idle");
1019
+ const error = ref3(null);
1020
+ const isLoading = ref3(false);
1021
+ const report = shallowRef3(undefined);
1022
+ const updatedAt = ref3(undefined);
1023
+ const sync = () => {
1024
+ const snapshot = store.getSnapshot();
1025
+ actionError.value = snapshot.actionError;
1026
+ actionStatus.value = snapshot.actionStatus;
1027
+ error.value = snapshot.error;
1028
+ isLoading.value = snapshot.isLoading;
1029
+ report.value = snapshot.report;
1030
+ updatedAt.value = snapshot.updatedAt;
1031
+ };
1032
+ const unsubscribe = store.subscribe(sync);
1033
+ sync();
1034
+ if (typeof window !== "undefined") {
1035
+ store.refresh().catch(() => {});
1036
+ }
1037
+ onUnmounted3(() => {
1038
+ unsubscribe();
1039
+ store.close();
1040
+ });
1041
+ return {
1042
+ actionError,
1043
+ actionStatus,
1044
+ error,
1045
+ isLoading,
1046
+ requeueDeadLetters: store.requeueDeadLetters,
1047
+ refresh: store.refresh,
1048
+ report,
1049
+ tick: store.tick,
1050
+ updatedAt
1051
+ };
1052
+ }
1053
+
1054
+ // src/vue/VoiceDeliveryRuntime.ts
1055
+ var VoiceDeliveryRuntime = defineComponent3({
1056
+ name: "VoiceDeliveryRuntime",
1057
+ props: {
1058
+ description: String,
1059
+ includeActions: {
1060
+ default: true,
1061
+ type: Boolean
1062
+ },
1063
+ intervalMs: Number,
1064
+ path: {
1065
+ default: "/api/voice-delivery-runtime",
1066
+ type: String
1067
+ },
1068
+ title: String
1069
+ },
1070
+ setup(props) {
1071
+ const options = {
1072
+ description: props.description,
1073
+ intervalMs: props.intervalMs,
1074
+ title: props.title
1075
+ };
1076
+ const runtime = useVoiceDeliveryRuntime(props.path, options);
1077
+ return () => {
1078
+ const model = createVoiceDeliveryRuntimeViewModel({
1079
+ error: runtime.error.value,
1080
+ actionError: runtime.actionError.value,
1081
+ actionStatus: runtime.actionStatus.value,
1082
+ isLoading: runtime.isLoading.value,
1083
+ report: runtime.report.value,
1084
+ updatedAt: runtime.updatedAt.value
1085
+ }, options);
1086
+ const hasDeadLetters = model.surfaces.some((surface) => surface.deadLettered > 0);
1087
+ return h3("section", {
1088
+ class: [
1089
+ "absolute-voice-delivery-runtime",
1090
+ `absolute-voice-delivery-runtime--${model.status}`
1091
+ ]
1092
+ }, [
1093
+ h3("header", { class: "absolute-voice-delivery-runtime__header" }, [
1094
+ h3("span", { class: "absolute-voice-delivery-runtime__eyebrow" }, model.title),
1095
+ h3("strong", { class: "absolute-voice-delivery-runtime__label" }, model.label)
1096
+ ]),
1097
+ h3("p", { class: "absolute-voice-delivery-runtime__description" }, model.description),
1098
+ h3("ul", { class: "absolute-voice-delivery-runtime__surfaces" }, model.surfaces.map((surface) => h3("li", {
1099
+ class: [
1100
+ "absolute-voice-delivery-runtime__surface",
1101
+ `absolute-voice-delivery-runtime__surface--${surface.status}`
1102
+ ],
1103
+ key: surface.id
1104
+ }, [
1105
+ h3("span", surface.label),
1106
+ h3("strong", surface.detail),
1107
+ h3("small", `${surface.failed} failed / ${surface.deadLettered} dead-lettered`)
1108
+ ]))),
1109
+ props.includeActions ? h3("div", { class: "absolute-voice-delivery-runtime__actions" }, [
1110
+ h3("button", {
1111
+ disabled: model.actionStatus === "running",
1112
+ onClick: () => {
1113
+ runtime.tick().catch(() => {});
1114
+ },
1115
+ type: "button"
1116
+ }, model.actionStatus === "running" ? "Working..." : "Tick workers"),
1117
+ h3("button", {
1118
+ disabled: model.actionStatus === "running" || !hasDeadLetters,
1119
+ onClick: () => {
1120
+ runtime.requeueDeadLetters().catch(() => {});
1121
+ },
1122
+ type: "button"
1123
+ }, "Requeue dead letters")
1124
+ ]) : null,
1125
+ model.actionError ? h3("p", { class: "absolute-voice-delivery-runtime__error" }, model.actionError) : null,
1126
+ model.error ? h3("p", { class: "absolute-voice-delivery-runtime__error" }, model.error) : null
1127
+ ]);
1128
+ };
1129
+ }
1130
+ });
1131
+ // src/vue/VoicePlatformCoverage.ts
1132
+ import { defineComponent as defineComponent4, h as h4 } from "vue";
1133
+
1134
+ // src/vue/useVoicePlatformCoverage.ts
1135
+ import { onUnmounted as onUnmounted4, ref as ref4, shallowRef as shallowRef4 } from "vue";
1136
+
1137
+ // src/client/platformCoverage.ts
1138
+ var fetchVoicePlatformCoverage = async (path = "/api/voice/platform-coverage", options = {}) => {
1139
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1140
+ const response = await fetchImpl(path);
1141
+ if (!response.ok) {
1142
+ throw new Error(`Voice platform coverage failed: HTTP ${response.status}`);
1143
+ }
1144
+ return await response.json();
1145
+ };
1146
+ var createVoicePlatformCoverageStore = (path = "/api/voice/platform-coverage", options = {}) => {
1147
+ const listeners = new Set;
1148
+ let closed = false;
1149
+ let timer;
1150
+ let snapshot = {
1151
+ error: null,
1152
+ isLoading: false
1153
+ };
1154
+ const emit = () => {
1155
+ for (const listener of listeners) {
1156
+ listener();
1157
+ }
1158
+ };
1159
+ const refresh = async () => {
1160
+ if (closed) {
1161
+ return snapshot.report;
1162
+ }
1163
+ snapshot = {
1164
+ ...snapshot,
1165
+ error: null,
1166
+ isLoading: true
1167
+ };
1168
+ emit();
1169
+ try {
1170
+ const report = await fetchVoicePlatformCoverage(path, options);
1171
+ snapshot = {
1172
+ error: null,
1173
+ isLoading: false,
1174
+ report,
1175
+ updatedAt: Date.now()
1176
+ };
1177
+ emit();
1178
+ return report;
1179
+ } catch (error) {
1180
+ snapshot = {
1181
+ ...snapshot,
1182
+ error: error instanceof Error ? error.message : String(error),
1183
+ isLoading: false
1184
+ };
1185
+ emit();
1186
+ throw error;
1187
+ }
1188
+ };
1189
+ const close = () => {
1190
+ closed = true;
1191
+ if (timer) {
1192
+ clearInterval(timer);
1193
+ timer = undefined;
1194
+ }
1195
+ listeners.clear();
1196
+ };
1197
+ if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
1198
+ timer = setInterval(() => {
1199
+ refresh().catch(() => {});
1200
+ }, options.intervalMs);
1201
+ }
1202
+ return {
1203
+ close,
1204
+ getServerSnapshot: () => snapshot,
1205
+ getSnapshot: () => snapshot,
1206
+ refresh,
1207
+ subscribe: (listener) => {
1208
+ listeners.add(listener);
1209
+ return () => {
1210
+ listeners.delete(listener);
1211
+ };
1212
+ }
1213
+ };
1214
+ };
1215
+
1216
+ // src/vue/useVoicePlatformCoverage.ts
1217
+ function useVoicePlatformCoverage(path = "/api/voice/platform-coverage", options = {}) {
1218
+ const store = createVoicePlatformCoverageStore(path, options);
1219
+ const error = ref4(null);
1220
+ const isLoading = ref4(false);
1221
+ const report = shallowRef4(undefined);
1222
+ const updatedAt = ref4(undefined);
1223
+ const sync = () => {
1224
+ const snapshot = store.getSnapshot();
1225
+ error.value = snapshot.error;
1226
+ isLoading.value = snapshot.isLoading;
1227
+ report.value = snapshot.report;
1228
+ updatedAt.value = snapshot.updatedAt;
1229
+ };
1230
+ const unsubscribe = store.subscribe(sync);
1231
+ sync();
1232
+ if (typeof window !== "undefined") {
1233
+ store.refresh().catch(() => {});
1234
+ }
1235
+ onUnmounted4(() => {
1236
+ unsubscribe();
1237
+ store.close();
1238
+ });
1239
+ return {
1240
+ error,
1241
+ isLoading,
1242
+ refresh: store.refresh,
1243
+ report,
1244
+ updatedAt
1245
+ };
1246
+ }
1247
+
1248
+ // src/client/platformCoverageWidget.ts
1249
+ var DEFAULT_TITLE4 = "Platform Replacement Coverage";
1250
+ var DEFAULT_DESCRIPTION4 = "Code-owned coverage for hosted voice-platform surfaces, backed by the same proof routes used by release evidence.";
1251
+ var DEFAULT_LINKS = [
1252
+ { href: "/switching-from-vapi", label: "Switching guide" },
1253
+ { href: "/api/voice/vapi-coverage", label: "Coverage JSON" }
1254
+ ];
1255
+ var escapeHtml4 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1256
+ var formatStatus = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
1257
+ var surfaceDetail2 = (surface) => {
1258
+ if (surface.status === "pass") {
1259
+ return surface.replacement;
1260
+ }
1261
+ if (surface.gap) {
1262
+ return surface.gap;
1263
+ }
1264
+ if (surface.missingEvidence?.length) {
1265
+ return `Missing evidence: ${surface.missingEvidence.join(", ")}`;
1266
+ }
1267
+ return surface.replacement;
1268
+ };
1269
+ var createVoicePlatformCoverageViewModel = (snapshot, options = {}) => {
1270
+ const allSurfaces = snapshot.report?.coverage ?? [];
1271
+ const failing = allSurfaces.filter((surface) => surface.status !== "pass");
1272
+ const limit = options.limit ?? 6;
1273
+ const surfaces = allSurfaces.slice(0, limit).map((surface) => ({
1274
+ ...surface,
1275
+ detail: surfaceDetail2(surface),
1276
+ label: surface.surface
1277
+ }));
1278
+ return {
1279
+ description: options.description ?? DEFAULT_DESCRIPTION4,
1280
+ error: snapshot.error,
1281
+ isLoading: snapshot.isLoading,
1282
+ label: snapshot.error ? "Unavailable" : snapshot.report ? failing.length ? `${failing.length} gaps` : `${snapshot.report.total} surfaces passing` : snapshot.isLoading ? "Checking" : "No coverage report",
1283
+ links: options.links ?? DEFAULT_LINKS,
1284
+ status: snapshot.error ? "error" : snapshot.report ? failing.length ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
1285
+ surfaces,
1286
+ title: options.title ?? DEFAULT_TITLE4,
1287
+ updatedAt: snapshot.updatedAt
1288
+ };
1289
+ };
1290
+ var renderVoicePlatformCoverageHTML = (snapshot, options = {}) => {
1291
+ const model = createVoicePlatformCoverageViewModel(snapshot, options);
1292
+ const surfaces = model.surfaces.length ? `<div class="absolute-voice-platform-coverage__surfaces">${model.surfaces.map((surface) => `<article class="absolute-voice-platform-coverage__surface absolute-voice-platform-coverage__surface--${escapeHtml4(surface.status)}">
1293
+ <header>
1294
+ <strong>${escapeHtml4(surface.label)}</strong>
1295
+ <span>${escapeHtml4(formatStatus(surface.status))}</span>
1296
+ </header>
1297
+ <p>${escapeHtml4(surface.detail)}</p>
1298
+ <small>${surface.evidence.filter((item) => item.ok).length}/${surface.evidence.length} evidence checks passing</small>
1299
+ </article>`).join("")}</div>` : `<p class="absolute-voice-platform-coverage__empty">${model.error ? escapeHtml4(model.error) : "Run the proof pack to populate platform coverage evidence."}</p>`;
1300
+ const links = model.links.length ? `<p class="absolute-voice-platform-coverage__links">${model.links.map((link) => `<a href="${escapeHtml4(link.href)}">${escapeHtml4(link.label)}</a>`).join("")}</p>` : "";
1301
+ return `<section class="absolute-voice-platform-coverage absolute-voice-platform-coverage--${escapeHtml4(model.status)}">
1302
+ <header class="absolute-voice-platform-coverage__header">
1303
+ <span class="absolute-voice-platform-coverage__eyebrow">${escapeHtml4(model.title)}</span>
1304
+ <strong class="absolute-voice-platform-coverage__label">${escapeHtml4(model.label)}</strong>
1305
+ </header>
1306
+ <p class="absolute-voice-platform-coverage__description">${escapeHtml4(model.description)}</p>
1307
+ ${surfaces}
1308
+ ${links}
1309
+ ${model.error ? `<p class="absolute-voice-platform-coverage__error">${escapeHtml4(model.error)}</p>` : ""}
1310
+ </section>`;
1311
+ };
1312
+ var getVoicePlatformCoverageCSS = () => `.absolute-voice-platform-coverage{border:1px solid #c7d2fe;border-radius:20px;background:#f8fbff;color:#111827;padding:18px;box-shadow:0 18px 40px rgba(30,64,175,.12);font-family:inherit}.absolute-voice-platform-coverage--warning,.absolute-voice-platform-coverage--error{border-color:#f2a7a7;background:#fff7f4}.absolute-voice-platform-coverage__header,.absolute-voice-platform-coverage__surface header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-platform-coverage__eyebrow{color:#1d4ed8;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-platform-coverage__label{font-size:24px;line-height:1}.absolute-voice-platform-coverage__description,.absolute-voice-platform-coverage__surface p,.absolute-voice-platform-coverage__surface small,.absolute-voice-platform-coverage__empty{color:#475569}.absolute-voice-platform-coverage__surfaces{display:grid;gap:10px;margin-top:14px}.absolute-voice-platform-coverage__surface{background:#fff;border:1px solid #dbeafe;border-radius:16px;padding:12px}.absolute-voice-platform-coverage__surface--pass{border-color:#86efac}.absolute-voice-platform-coverage__surface--fail,.absolute-voice-platform-coverage__surface--missing,.absolute-voice-platform-coverage__surface--stale{border-color:#f2a7a7}.absolute-voice-platform-coverage__surface p{margin:8px 0}.absolute-voice-platform-coverage__surface span{text-transform:capitalize}.absolute-voice-platform-coverage__links{display:flex;flex-wrap:wrap;gap:8px;margin:14px 0 0}.absolute-voice-platform-coverage__links a{border:1px solid #bfdbfe;border-radius:999px;color:#1d4ed8;font-weight:800;padding:6px 10px;text-decoration:none}.absolute-voice-platform-coverage__error{color:#9f1239;font-weight:700}`;
1313
+ var mountVoicePlatformCoverage = (element, path = "/api/voice/platform-coverage", options = {}) => {
1314
+ const store = createVoicePlatformCoverageStore(path, options);
1315
+ const render = () => {
1316
+ element.innerHTML = renderVoicePlatformCoverageHTML(store.getSnapshot(), options);
1317
+ };
1318
+ const unsubscribe = store.subscribe(render);
1319
+ render();
1320
+ store.refresh().catch(() => {});
1321
+ return {
1322
+ close: () => {
1323
+ unsubscribe();
1324
+ store.close();
1325
+ },
1326
+ refresh: store.refresh
1327
+ };
1328
+ };
1329
+ var defineVoicePlatformCoverageElement = (tagName = "absolute-voice-platform-coverage") => {
1330
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
1331
+ return;
1332
+ }
1333
+ customElements.define(tagName, class AbsoluteVoicePlatformCoverageElement extends HTMLElement {
1334
+ mounted;
1335
+ connectedCallback() {
1336
+ this.mounted = mountVoicePlatformCoverage(this, this.getAttribute("path") ?? "/api/voice/platform-coverage", {
1337
+ description: this.getAttribute("description") ?? undefined,
1338
+ intervalMs: Number(this.getAttribute("interval-ms") ?? 0) || undefined,
1339
+ limit: Number(this.getAttribute("limit") ?? 0) || undefined,
1340
+ title: this.getAttribute("title") ?? undefined
1341
+ });
1342
+ }
1343
+ disconnectedCallback() {
1344
+ this.mounted?.close();
1345
+ this.mounted = undefined;
1346
+ }
1347
+ });
1348
+ };
1349
+
1350
+ // src/vue/VoicePlatformCoverage.ts
1351
+ var VoicePlatformCoverage = defineComponent4({
1352
+ name: "VoicePlatformCoverage",
1353
+ props: {
1354
+ description: String,
1355
+ intervalMs: Number,
1356
+ limit: Number,
1357
+ path: {
1358
+ default: "/api/voice/platform-coverage",
1359
+ type: String
1360
+ },
1361
+ title: String
1362
+ },
1363
+ setup(props) {
1364
+ const state = useVoicePlatformCoverage(props.path, {
1365
+ description: props.description,
1366
+ intervalMs: props.intervalMs,
1367
+ limit: props.limit,
1368
+ title: props.title
1369
+ });
1370
+ return () => {
1371
+ const model = createVoicePlatformCoverageViewModel({
1372
+ error: state.error.value,
1373
+ isLoading: state.isLoading.value,
1374
+ report: state.report.value,
1375
+ updatedAt: state.updatedAt.value
1376
+ }, {
1377
+ description: props.description,
1378
+ intervalMs: props.intervalMs,
1379
+ limit: props.limit,
1380
+ title: props.title
1381
+ });
1382
+ return h4("section", {
1383
+ class: [
1384
+ "absolute-voice-platform-coverage",
1385
+ `absolute-voice-platform-coverage--${model.status}`
1386
+ ]
1387
+ }, [
1388
+ h4("header", { class: "absolute-voice-platform-coverage__header" }, [
1389
+ h4("span", { class: "absolute-voice-platform-coverage__eyebrow" }, model.title),
1390
+ h4("strong", { class: "absolute-voice-platform-coverage__label" }, model.label)
1391
+ ]),
1392
+ h4("p", { class: "absolute-voice-platform-coverage__description" }, model.description),
1393
+ model.surfaces.length ? h4("div", { class: "absolute-voice-platform-coverage__surfaces" }, model.surfaces.map((surface) => h4("article", {
1394
+ class: [
1395
+ "absolute-voice-platform-coverage__surface",
1396
+ `absolute-voice-platform-coverage__surface--${surface.status}`
1397
+ ],
1398
+ key: surface.surface
1399
+ }, [
1400
+ h4("header", [
1401
+ h4("strong", surface.label),
1402
+ h4("span", surface.status)
1403
+ ]),
1404
+ h4("p", surface.detail),
1405
+ h4("small", `${surface.evidence.filter((item) => item.ok).length}/${surface.evidence.length} evidence checks passing`)
1406
+ ]))) : h4("p", { class: "absolute-voice-platform-coverage__empty" }, model.error ?? "Run the proof pack to populate platform coverage evidence."),
1407
+ model.links.length ? h4("p", { class: "absolute-voice-platform-coverage__links" }, model.links.map((link) => h4("a", { href: link.href, key: link.href }, link.label))) : null,
1408
+ model.error ? h4("p", { class: "absolute-voice-platform-coverage__error" }, model.error) : null
1409
+ ]);
1410
+ };
1411
+ }
1412
+ });
1413
+ // src/vue/VoiceProviderSimulationControls.ts
1414
+ import { computed, defineComponent as defineComponent5, h as h5 } from "vue";
1415
+
1416
+ // src/client/providerSimulationControls.ts
1417
+ var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
1418
+ const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
1419
+ const body = await response.json().catch(() => null);
1420
+ if (!response.ok) {
1421
+ const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice provider simulation failed: HTTP ${response.status}`;
1422
+ throw new Error(message);
1423
+ }
1424
+ return body;
1425
+ };
1426
+ var createVoiceProviderSimulationControlsStore = (options) => {
1427
+ const listeners = new Set;
1428
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1429
+ const pathPrefix = options.pathPrefix ?? `/api/${options.kind ?? "stt"}-simulate`;
1430
+ let closed = false;
1431
+ let snapshot = {
1432
+ error: null,
1433
+ isRunning: false,
1434
+ lastResult: null,
1435
+ mode: null,
1436
+ provider: null
1437
+ };
1438
+ const emit = () => {
1439
+ for (const listener of listeners) {
1440
+ listener();
1441
+ }
1442
+ };
1443
+ const run = async (provider, mode) => {
1444
+ if (closed) {
1445
+ return snapshot.lastResult;
1446
+ }
1447
+ snapshot = {
1448
+ ...snapshot,
1449
+ error: null,
1450
+ isRunning: true,
1451
+ mode,
1452
+ provider
1453
+ };
1454
+ emit();
1455
+ try {
1456
+ const result = await postSimulation(pathPrefix, mode, provider, fetchImpl);
1457
+ snapshot = {
1458
+ error: null,
1459
+ isRunning: false,
1460
+ lastResult: result,
1461
+ mode,
1462
+ provider,
1463
+ updatedAt: Date.now()
1464
+ };
1465
+ emit();
1466
+ return result;
1467
+ } catch (error) {
1468
+ snapshot = {
1469
+ ...snapshot,
1470
+ error: error instanceof Error ? error.message : String(error),
1471
+ isRunning: false
1472
+ };
1473
+ emit();
1474
+ throw error;
1475
+ }
1476
+ };
1477
+ const close = () => {
1478
+ closed = true;
1479
+ listeners.clear();
1480
+ };
1481
+ return {
1482
+ close,
1483
+ getServerSnapshot: () => snapshot,
1484
+ getSnapshot: () => snapshot,
1485
+ run,
1486
+ subscribe: (listener) => {
1487
+ listeners.add(listener);
1488
+ return () => {
1489
+ listeners.delete(listener);
1490
+ };
1491
+ }
1492
+ };
1493
+ };
1494
+
1495
+ // src/client/providerSimulationControlsWidget.ts
1496
+ var escapeHtml5 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1497
+ var formatKind = (kind) => (kind ?? "stt").toUpperCase();
1498
+ var createVoiceProviderSimulationControlsViewModel = (snapshot, options) => {
1499
+ const configuredProviders = options.providers.filter((provider) => provider.configured !== false);
1500
+ const fallbackReady = !options.fallbackRequiredProvider || configuredProviders.some((entry) => entry.provider === options.fallbackRequiredProvider);
1501
+ const failureProviders = (options.failureProviders ? options.failureProviders.map((provider) => ({ provider })) : configuredProviders).filter((provider) => configuredProviders.some((entry) => entry.provider === provider.provider));
1502
+ return {
1503
+ canSimulateFailure: configuredProviders.length > 0 && fallbackReady,
1504
+ description: options.failureMessage ?? `Simulate ${formatKind(options.kind)} provider failure and recovery without changing credentials.`,
1505
+ error: snapshot.error,
1506
+ failureProviders,
1507
+ isRunning: snapshot.isRunning,
1508
+ label: snapshot.isRunning ? `Running ${snapshot.mode ?? "simulation"}` : snapshot.lastResult ? `${snapshot.lastResult.provider} ${snapshot.lastResult.mode} simulated` : configuredProviders.length ? `${configuredProviders.length} configured` : "No configured providers",
1509
+ providers: configuredProviders,
1510
+ resultText: snapshot.lastResult ? JSON.stringify(snapshot.lastResult, null, 2) : null,
1511
+ title: options.title ?? `${formatKind(options.kind)} Failure Simulation`
1512
+ };
1513
+ };
1514
+ var renderVoiceProviderSimulationControlsHTML = (snapshot, options) => {
1515
+ const model = createVoiceProviderSimulationControlsViewModel(snapshot, options);
1516
+ const failureButtons = model.failureProviders.map((provider) => `<button type="button" data-voice-provider-fail="${escapeHtml5(provider.provider)}"${!model.canSimulateFailure || snapshot.isRunning ? " disabled" : ""}>Simulate ${escapeHtml5(provider.provider)} ${escapeHtml5(formatKind(options.kind))} failure</button>`).join("");
1517
+ const recoveryButtons = model.providers.map((provider) => `<button type="button" data-voice-provider-recover="${escapeHtml5(provider.provider)}"${snapshot.isRunning ? " disabled" : ""}>Mark ${escapeHtml5(provider.provider)} recovered</button>`).join("");
1518
+ return `<section class="absolute-voice-provider-simulation absolute-voice-provider-simulation--${snapshot.error ? "error" : snapshot.isRunning ? "running" : "ready"}">
1519
+ <header class="absolute-voice-provider-simulation__header">
1520
+ <span class="absolute-voice-provider-simulation__eyebrow">${escapeHtml5(model.title)}</span>
1521
+ <strong class="absolute-voice-provider-simulation__label">${escapeHtml5(model.label)}</strong>
1522
+ </header>
1523
+ <p class="absolute-voice-provider-simulation__description">${escapeHtml5(model.description)}</p>
1524
+ ${model.canSimulateFailure ? "" : `<p class="absolute-voice-provider-simulation__empty">${escapeHtml5(options.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure.")}</p>`}
1525
+ <div class="absolute-voice-provider-simulation__actions">${failureButtons}${recoveryButtons}</div>
1526
+ ${snapshot.error ? `<p class="absolute-voice-provider-simulation__error">${escapeHtml5(snapshot.error)}</p>` : ""}
1527
+ ${model.resultText ? `<pre class="absolute-voice-provider-simulation__result">${escapeHtml5(model.resultText)}</pre>` : ""}
1528
+ </section>`;
1529
+ };
1530
+ var bindVoiceProviderSimulationControls = (element, store) => {
1531
+ const onClick = (event) => {
1532
+ const target = event.target;
1533
+ if (!(target instanceof HTMLElement)) {
1534
+ return;
1535
+ }
1536
+ const failProvider = target.getAttribute("data-voice-provider-fail");
1537
+ const recoverProvider = target.getAttribute("data-voice-provider-recover");
1538
+ if (failProvider) {
1539
+ store.run(failProvider, "failure").catch(() => {});
1540
+ }
1541
+ if (recoverProvider) {
1542
+ store.run(recoverProvider, "recovery").catch(() => {});
1543
+ }
1544
+ };
1545
+ element.addEventListener("click", onClick);
1546
+ return () => element.removeEventListener("click", onClick);
1547
+ };
1548
+ var mountVoiceProviderSimulationControls = (element, options) => {
1549
+ const store = createVoiceProviderSimulationControlsStore(options);
1550
+ const render = () => {
1551
+ element.innerHTML = renderVoiceProviderSimulationControlsHTML(store.getSnapshot(), options);
1552
+ };
1553
+ const unsubscribeStore = store.subscribe(render);
1554
+ const unsubscribeDom = bindVoiceProviderSimulationControls(element, store);
1555
+ render();
1556
+ return {
1557
+ close: () => {
1558
+ unsubscribeDom();
1559
+ unsubscribeStore();
1560
+ store.close();
1561
+ },
1562
+ run: store.run
1563
+ };
1564
+ };
1565
+ var defineVoiceProviderSimulationControlsElement = (tagName = "absolute-voice-provider-simulation") => {
1566
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
1567
+ return;
1568
+ }
1569
+ customElements.define(tagName, class AbsoluteVoiceProviderSimulationElement extends HTMLElement {
1570
+ mounted;
1571
+ connectedCallback() {
1572
+ const providers = (this.getAttribute("providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean).map((provider) => ({ provider }));
1573
+ const failureProviders = (this.getAttribute("failure-providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean);
1574
+ this.mounted = mountVoiceProviderSimulationControls(this, {
1575
+ failureProviders: failureProviders.length ? failureProviders : undefined,
1576
+ fallbackRequiredMessage: this.getAttribute("fallback-required-message") ?? undefined,
1577
+ fallbackRequiredProvider: this.getAttribute("fallback-required-provider") ?? undefined,
1578
+ failureMessage: this.getAttribute("failure-message") ?? undefined,
1579
+ kind: this.getAttribute("kind") ?? "stt",
1580
+ pathPrefix: this.getAttribute("path-prefix") ?? undefined,
1581
+ providers,
1582
+ title: this.getAttribute("title") ?? undefined
1583
+ });
1584
+ }
1585
+ disconnectedCallback() {
1586
+ this.mounted?.close();
1587
+ this.mounted = undefined;
1588
+ }
1589
+ });
1590
+ };
1591
+
1592
+ // src/vue/useVoiceProviderSimulationControls.ts
1593
+ import { onUnmounted as onUnmounted5, ref as ref5 } from "vue";
1594
+ function useVoiceProviderSimulationControls(options) {
1595
+ const store = createVoiceProviderSimulationControlsStore(options);
1596
+ const error = ref5(null);
1597
+ const isRunning = ref5(false);
1598
+ const lastResult = ref5(null);
1599
+ const mode = ref5(null);
1600
+ const provider = ref5(null);
1601
+ const updatedAt = ref5(undefined);
1602
+ const sync = () => {
1603
+ const snapshot = store.getSnapshot();
1604
+ error.value = snapshot.error;
1605
+ isRunning.value = snapshot.isRunning;
1606
+ lastResult.value = snapshot.lastResult;
1607
+ mode.value = snapshot.mode;
1608
+ provider.value = snapshot.provider;
1609
+ updatedAt.value = snapshot.updatedAt;
1610
+ };
1611
+ const unsubscribe = store.subscribe(sync);
1612
+ sync();
1613
+ onUnmounted5(() => {
1614
+ unsubscribe();
1615
+ store.close();
1616
+ });
1617
+ return {
1618
+ error,
1619
+ isRunning,
1620
+ lastResult,
1621
+ mode,
1622
+ provider,
1623
+ run: store.run,
1624
+ updatedAt
1625
+ };
1626
+ }
1627
+
1628
+ // src/vue/VoiceProviderSimulationControls.ts
1629
+ var VoiceProviderSimulationControls = defineComponent5({
1630
+ name: "VoiceProviderSimulationControls",
1631
+ props: {
1632
+ class: { default: "", type: String },
1633
+ fallbackRequiredMessage: { default: undefined, type: String },
1634
+ fallbackRequiredProvider: { default: undefined, type: String },
1635
+ failureMessage: { default: undefined, type: String },
1636
+ failureProviders: {
1637
+ default: undefined,
1638
+ type: Array
1639
+ },
1640
+ kind: { default: "stt", type: String },
1641
+ pathPrefix: { default: undefined, type: String },
1642
+ providers: {
1643
+ required: true,
1644
+ type: Array
1645
+ },
1646
+ title: { default: undefined, type: String }
1647
+ },
1648
+ setup(props) {
1649
+ const options = {
1650
+ fallbackRequiredMessage: props.fallbackRequiredMessage,
1651
+ fallbackRequiredProvider: props.fallbackRequiredProvider,
1652
+ failureMessage: props.failureMessage,
1653
+ failureProviders: props.failureProviders,
1654
+ kind: props.kind,
1655
+ pathPrefix: props.pathPrefix,
1656
+ providers: props.providers,
1657
+ title: props.title
1658
+ };
1659
+ const controls = useVoiceProviderSimulationControls(options);
1660
+ const model = computed(() => createVoiceProviderSimulationControlsViewModel({
1661
+ error: controls.error.value,
1662
+ isRunning: controls.isRunning.value,
1663
+ lastResult: controls.lastResult.value,
1664
+ mode: controls.mode.value,
1665
+ provider: controls.provider.value,
1666
+ updatedAt: controls.updatedAt.value
1667
+ }, options));
1668
+ const run = (provider, mode) => {
1669
+ controls.run(provider, mode).catch(() => {});
1670
+ };
1671
+ return () => h5("section", {
1672
+ class: [
1673
+ "absolute-voice-provider-simulation",
1674
+ `absolute-voice-provider-simulation--${controls.error.value ? "error" : controls.isRunning.value ? "running" : "ready"}`,
1675
+ props.class
1676
+ ]
1677
+ }, [
1678
+ h5("header", { class: "absolute-voice-provider-simulation__header" }, [
1679
+ h5("span", { class: "absolute-voice-provider-simulation__eyebrow" }, model.value.title),
1680
+ h5("strong", { class: "absolute-voice-provider-simulation__label" }, model.value.label)
1681
+ ]),
1682
+ h5("p", { class: "absolute-voice-provider-simulation__description" }, model.value.description),
1683
+ model.value.canSimulateFailure ? null : h5("p", { class: "absolute-voice-provider-simulation__empty" }, props.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure."),
1684
+ h5("div", { class: "absolute-voice-provider-simulation__actions" }, [
1685
+ ...model.value.failureProviders.map((provider) => h5("button", {
1686
+ disabled: !model.value.canSimulateFailure || controls.isRunning.value,
1687
+ key: `fail-${provider.provider}`,
1688
+ onClick: () => run(provider.provider, "failure"),
1689
+ type: "button"
1690
+ }, `Simulate ${provider.provider} ${props.kind.toUpperCase()} failure`)),
1691
+ ...model.value.providers.map((provider) => h5("button", {
1692
+ disabled: controls.isRunning.value,
1693
+ key: `recover-${provider.provider}`,
1694
+ onClick: () => run(provider.provider, "recovery"),
1695
+ type: "button"
1696
+ }, `Mark ${provider.provider} recovered`))
1697
+ ]),
1698
+ controls.error.value ? h5("p", { class: "absolute-voice-provider-simulation__error" }, controls.error.value) : null,
1699
+ model.value.resultText ? h5("pre", { class: "absolute-voice-provider-simulation__result" }, model.value.resultText) : null
1700
+ ]);
1701
+ }
1702
+ });
1703
+ // src/vue/VoiceProviderCapabilities.ts
1704
+ import { computed as computed2, defineComponent as defineComponent6, h as h6 } from "vue";
1705
+
1706
+ // src/client/providerCapabilities.ts
1707
+ var fetchVoiceProviderCapabilities = async (path = "/api/provider-capabilities", options = {}) => {
1708
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1709
+ const response = await fetchImpl(path);
1710
+ if (!response.ok) {
1711
+ throw new Error(`Voice provider capabilities failed: HTTP ${response.status}`);
1712
+ }
1713
+ return await response.json();
1714
+ };
1715
+ var createVoiceProviderCapabilitiesStore = (path = "/api/provider-capabilities", options = {}) => {
1716
+ const listeners = new Set;
1717
+ let closed = false;
1718
+ let timer;
1719
+ let snapshot = {
1720
+ error: null,
1721
+ isLoading: false
1722
+ };
1723
+ const emit = () => {
1724
+ for (const listener of listeners) {
1725
+ listener();
1726
+ }
1727
+ };
1728
+ const refresh = async () => {
1729
+ if (closed) {
1730
+ return snapshot.report;
1731
+ }
1732
+ snapshot = {
1733
+ ...snapshot,
1734
+ error: null,
1735
+ isLoading: true
1736
+ };
1737
+ emit();
1738
+ try {
1739
+ const report = await fetchVoiceProviderCapabilities(path, options);
1740
+ snapshot = {
1741
+ error: null,
1742
+ isLoading: false,
1743
+ report,
1744
+ updatedAt: Date.now()
1745
+ };
1746
+ emit();
1747
+ return report;
1748
+ } catch (error) {
1749
+ snapshot = {
1750
+ ...snapshot,
1751
+ error: error instanceof Error ? error.message : String(error),
1752
+ isLoading: false
1753
+ };
1754
+ emit();
1755
+ throw error;
1756
+ }
1757
+ };
1758
+ const close = () => {
1759
+ closed = true;
1760
+ if (timer) {
1761
+ clearInterval(timer);
1762
+ timer = undefined;
1763
+ }
1764
+ listeners.clear();
1765
+ };
1766
+ if (options.intervalMs && options.intervalMs > 0) {
1767
+ timer = setInterval(() => {
1768
+ refresh().catch(() => {});
1769
+ }, options.intervalMs);
1770
+ }
1771
+ return {
1772
+ close,
1773
+ getServerSnapshot: () => snapshot,
1774
+ getSnapshot: () => snapshot,
1775
+ refresh,
1776
+ subscribe: (listener) => {
1777
+ listeners.add(listener);
1778
+ return () => {
1779
+ listeners.delete(listener);
1780
+ };
1781
+ }
1782
+ };
1783
+ };
1784
+
1785
+ // src/client/providerCapabilitiesWidget.ts
1786
+ var DEFAULT_TITLE5 = "Provider Capabilities";
1787
+ var DEFAULT_DESCRIPTION5 = "Configured, selected, and healthy voice providers for this deployment.";
1788
+ var escapeHtml6 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1789
+ var formatProvider = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
1790
+ var formatKind2 = (kind) => kind.toUpperCase();
1791
+ var formatStatus2 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
1792
+ var getCapabilityDetail = (capability) => {
1793
+ if (!capability.configured) {
1794
+ return "Not configured in this deployment.";
1795
+ }
1796
+ if (capability.selected) {
1797
+ return `Selected ${capability.kind.toUpperCase()} provider for new sessions.`;
1798
+ }
1799
+ if (capability.health?.status === "healthy") {
1800
+ return "Configured and healthy fallback candidate.";
1801
+ }
1802
+ if (capability.health?.status === "idle") {
1803
+ return "Configured; no traffic observed yet.";
1804
+ }
1805
+ if (capability.health?.lastError) {
1806
+ return capability.health.lastError;
1807
+ }
1808
+ return "Configured and available.";
1809
+ };
1810
+ var isWarningStatus = (status) => status === "degraded" || status === "rate-limited" || status === "suppressed" || status === "unconfigured";
1811
+ var createVoiceProviderCapabilitiesViewModel = (snapshot, options = {}) => {
1812
+ const capabilities = (snapshot.report?.capabilities ?? []).map((capability) => ({
1813
+ ...capability,
1814
+ detail: getCapabilityDetail(capability),
1815
+ label: `${formatProvider(capability.provider)} ${formatKind2(capability.kind)}`,
1816
+ rows: [
1817
+ { label: "Status", value: formatStatus2(capability.status) },
1818
+ { label: "Selected", value: capability.selected ? "Yes" : "No" },
1819
+ { label: "Model", value: capability.model ?? "Default" },
1820
+ {
1821
+ label: "Features",
1822
+ value: capability.features?.join(", ") || "Not specified"
1823
+ },
1824
+ { label: "Runs", value: String(capability.health?.runCount ?? 0) },
1825
+ { label: "Errors", value: String(capability.health?.errorCount ?? 0) }
1826
+ ]
1827
+ }));
1828
+ const warningCount = capabilities.filter((capability) => isWarningStatus(capability.status)).length;
1829
+ const selectedCount = snapshot.report?.selected ?? capabilities.filter((capability) => capability.selected).length;
1830
+ return {
1831
+ capabilities,
1832
+ description: options.description ?? DEFAULT_DESCRIPTION5,
1833
+ error: snapshot.error,
1834
+ isLoading: snapshot.isLoading,
1835
+ label: snapshot.error ? "Unavailable" : capabilities.length ? warningCount > 0 ? `${warningCount} needs attention` : `${selectedCount} selected` : snapshot.isLoading ? "Checking" : "No capabilities",
1836
+ status: snapshot.error ? "error" : capabilities.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
1837
+ title: options.title ?? DEFAULT_TITLE5,
1838
+ updatedAt: snapshot.updatedAt
1839
+ };
1840
+ };
1841
+ var renderVoiceProviderCapabilitiesHTML = (snapshot, options = {}) => {
1842
+ const model = createVoiceProviderCapabilitiesViewModel(snapshot, options);
1843
+ 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--${escapeHtml6(capability.status)}">
1844
+ <header>
1845
+ <strong>${escapeHtml6(capability.label)}</strong>
1846
+ <span>${escapeHtml6(formatStatus2(capability.status))}</span>
1847
+ </header>
1848
+ <p>${escapeHtml6(capability.detail)}</p>
1849
+ <dl>${capability.rows.map((row) => `<div>
1850
+ <dt>${escapeHtml6(row.label)}</dt>
1851
+ <dd>${escapeHtml6(row.value)}</dd>
1852
+ </div>`).join("")}</dl>
1853
+ </article>`).join("")}</div>` : '<p class="absolute-voice-provider-capabilities__empty">Configure provider capabilities to see deployment coverage.</p>';
1854
+ return `<section class="absolute-voice-provider-capabilities absolute-voice-provider-capabilities--${escapeHtml6(model.status)}">
1855
+ <header class="absolute-voice-provider-capabilities__header">
1856
+ <span class="absolute-voice-provider-capabilities__eyebrow">${escapeHtml6(model.title)}</span>
1857
+ <strong class="absolute-voice-provider-capabilities__label">${escapeHtml6(model.label)}</strong>
1858
+ </header>
1859
+ <p class="absolute-voice-provider-capabilities__description">${escapeHtml6(model.description)}</p>
1860
+ ${capabilities}
1861
+ ${model.error ? `<p class="absolute-voice-provider-capabilities__error">${escapeHtml6(model.error)}</p>` : ""}
1862
+ </section>`;
1863
+ };
1864
+ 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}`;
1865
+ var mountVoiceProviderCapabilities = (element, path = "/api/provider-capabilities", options = {}) => {
1866
+ const store = createVoiceProviderCapabilitiesStore(path, options);
1867
+ const render = () => {
1868
+ element.innerHTML = renderVoiceProviderCapabilitiesHTML(store.getSnapshot(), options);
1869
+ };
1870
+ const unsubscribe = store.subscribe(render);
1871
+ render();
1872
+ store.refresh().catch(() => {});
1873
+ return {
1874
+ close: () => {
1875
+ unsubscribe();
1876
+ store.close();
1877
+ },
1878
+ refresh: store.refresh
1879
+ };
1880
+ };
1881
+ var defineVoiceProviderCapabilitiesElement = (tagName = "absolute-voice-provider-capabilities") => {
1882
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
1883
+ return;
1884
+ }
1885
+ customElements.define(tagName, class AbsoluteVoiceProviderCapabilitiesElement extends HTMLElement {
1886
+ mounted;
1887
+ connectedCallback() {
1888
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
1889
+ this.mounted = mountVoiceProviderCapabilities(this, this.getAttribute("path") ?? "/api/provider-capabilities", {
1890
+ description: this.getAttribute("description") ?? undefined,
1891
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
1892
+ title: this.getAttribute("title") ?? undefined
1893
+ });
1894
+ }
1895
+ disconnectedCallback() {
1896
+ this.mounted?.close();
1897
+ this.mounted = undefined;
1898
+ }
1899
+ });
1900
+ };
1901
+
1902
+ // src/vue/useVoiceProviderCapabilities.ts
1903
+ import { onUnmounted as onUnmounted6, shallowRef as shallowRef5 } from "vue";
1904
+ function useVoiceProviderCapabilities(path = "/api/provider-capabilities", options = {}) {
1905
+ const store = createVoiceProviderCapabilitiesStore(path, options);
1906
+ const error = shallowRef5(null);
1907
+ const isLoading = shallowRef5(false);
1908
+ const report = shallowRef5();
1909
+ const updatedAt = shallowRef5(undefined);
1910
+ const sync = () => {
1911
+ const snapshot = store.getSnapshot();
1912
+ error.value = snapshot.error;
1913
+ isLoading.value = snapshot.isLoading;
1914
+ report.value = snapshot.report;
1915
+ updatedAt.value = snapshot.updatedAt;
1916
+ };
1917
+ const unsubscribe = store.subscribe(sync);
1918
+ sync();
1919
+ store.refresh().catch(() => {});
1920
+ onUnmounted6(() => {
1921
+ unsubscribe();
1922
+ store.close();
1923
+ });
1924
+ return {
1925
+ error,
1926
+ isLoading,
1927
+ refresh: store.refresh,
1928
+ report,
1929
+ updatedAt
1930
+ };
1931
+ }
1932
+
1933
+ // src/vue/VoiceProviderCapabilities.ts
1934
+ var VoiceProviderCapabilities = defineComponent6({
1935
+ name: "VoiceProviderCapabilities",
1936
+ props: {
1937
+ class: {
1938
+ default: "",
1939
+ type: String
1940
+ },
1941
+ description: {
1942
+ default: undefined,
1943
+ type: String
1944
+ },
1945
+ intervalMs: {
1946
+ default: 5000,
1947
+ type: Number
1948
+ },
1949
+ path: {
1950
+ default: "/api/provider-capabilities",
1951
+ type: String
1952
+ },
1953
+ title: {
1954
+ default: undefined,
1955
+ type: String
1956
+ }
1957
+ },
1958
+ setup(props) {
1959
+ const options = {
1960
+ description: props.description,
1961
+ intervalMs: props.intervalMs,
1962
+ title: props.title
1963
+ };
1964
+ const capabilities = useVoiceProviderCapabilities(props.path, options);
1965
+ const model = computed2(() => createVoiceProviderCapabilitiesViewModel({
1966
+ error: capabilities.error.value,
1967
+ isLoading: capabilities.isLoading.value,
1968
+ report: capabilities.report.value,
1969
+ updatedAt: capabilities.updatedAt.value
1970
+ }, options));
1971
+ return () => h6("section", {
1972
+ class: [
1973
+ "absolute-voice-provider-capabilities",
1974
+ `absolute-voice-provider-capabilities--${model.value.status}`,
1975
+ props.class
1976
+ ]
1977
+ }, [
1978
+ h6("header", { class: "absolute-voice-provider-capabilities__header" }, [
1979
+ h6("span", { class: "absolute-voice-provider-capabilities__eyebrow" }, model.value.title),
1980
+ h6("strong", { class: "absolute-voice-provider-capabilities__label" }, model.value.label)
1981
+ ]),
1982
+ h6("p", { class: "absolute-voice-provider-capabilities__description" }, model.value.description),
1983
+ model.value.capabilities.length ? h6("div", { class: "absolute-voice-provider-capabilities__providers" }, model.value.capabilities.map((capability) => h6("article", {
1984
+ class: [
1985
+ "absolute-voice-provider-capabilities__provider",
1986
+ `absolute-voice-provider-capabilities__provider--${capability.status}`
1987
+ ],
1988
+ key: `${capability.kind}:${capability.provider}`
1989
+ }, [
1990
+ h6("header", [
1991
+ h6("strong", capability.label),
1992
+ h6("span", capability.status)
1993
+ ]),
1994
+ h6("p", capability.detail),
1995
+ h6("dl", capability.rows.map((row) => h6("div", { key: row.label }, [
1996
+ h6("dt", row.label),
1997
+ h6("dd", row.value)
1998
+ ])))
1999
+ ]))) : h6("p", { class: "absolute-voice-provider-capabilities__empty" }, "Configure provider capabilities to see deployment coverage."),
2000
+ model.value.error ? h6("p", { class: "absolute-voice-provider-capabilities__error" }, model.value.error) : null
2001
+ ]);
2002
+ }
2003
+ });
2004
+ // src/vue/VoiceProviderContracts.ts
2005
+ import { defineComponent as defineComponent7, h as h7 } from "vue";
2006
+
2007
+ // src/vue/useVoiceProviderContracts.ts
2008
+ import { onUnmounted as onUnmounted7, shallowRef as shallowRef6 } from "vue";
2009
+
2010
+ // src/client/providerContracts.ts
2011
+ var fetchVoiceProviderContracts = async (path = "/api/provider-contracts", options = {}) => {
2012
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2013
+ const response = await fetchImpl(path);
2014
+ if (!response.ok) {
2015
+ throw new Error(`Voice provider contracts failed: HTTP ${response.status}`);
2016
+ }
2017
+ return await response.json();
2018
+ };
2019
+ var createVoiceProviderContractsStore = (path = "/api/provider-contracts", options = {}) => {
2020
+ const listeners = new Set;
2021
+ let closed = false;
2022
+ let timer;
2023
+ let snapshot = {
2024
+ error: null,
2025
+ isLoading: false
2026
+ };
2027
+ const emit = () => {
2028
+ for (const listener of listeners) {
2029
+ listener();
2030
+ }
2031
+ };
2032
+ const refresh = async () => {
2033
+ if (closed) {
2034
+ return snapshot.report;
2035
+ }
2036
+ snapshot = { ...snapshot, error: null, isLoading: true };
2037
+ emit();
2038
+ try {
2039
+ const report = await fetchVoiceProviderContracts(path, options);
2040
+ snapshot = {
2041
+ error: null,
2042
+ isLoading: false,
2043
+ report,
2044
+ updatedAt: Date.now()
2045
+ };
2046
+ emit();
2047
+ return report;
2048
+ } catch (error) {
2049
+ snapshot = {
2050
+ ...snapshot,
2051
+ error: error instanceof Error ? error.message : String(error),
2052
+ isLoading: false
2053
+ };
2054
+ emit();
2055
+ throw error;
2056
+ }
2057
+ };
2058
+ const close = () => {
2059
+ closed = true;
2060
+ if (timer) {
2061
+ clearInterval(timer);
2062
+ timer = undefined;
2063
+ }
2064
+ listeners.clear();
2065
+ };
2066
+ if (options.intervalMs && options.intervalMs > 0) {
2067
+ timer = setInterval(() => {
2068
+ refresh().catch(() => {});
2069
+ }, options.intervalMs);
2070
+ }
2071
+ return {
2072
+ close,
2073
+ getServerSnapshot: () => snapshot,
2074
+ getSnapshot: () => snapshot,
2075
+ refresh,
2076
+ subscribe: (listener) => {
2077
+ listeners.add(listener);
2078
+ return () => {
2079
+ listeners.delete(listener);
2080
+ };
2081
+ }
2082
+ };
2083
+ };
2084
+
2085
+ // src/vue/useVoiceProviderContracts.ts
2086
+ function useVoiceProviderContracts(path = "/api/provider-contracts", options = {}) {
2087
+ const store = createVoiceProviderContractsStore(path, options);
2088
+ const error = shallowRef6(null);
2089
+ const isLoading = shallowRef6(false);
2090
+ const report = shallowRef6();
2091
+ const updatedAt = shallowRef6(undefined);
2092
+ const sync = () => {
2093
+ const snapshot = store.getSnapshot();
2094
+ error.value = snapshot.error;
2095
+ isLoading.value = snapshot.isLoading;
2096
+ report.value = snapshot.report;
2097
+ updatedAt.value = snapshot.updatedAt;
2098
+ };
2099
+ const unsubscribe = store.subscribe(sync);
2100
+ sync();
2101
+ store.refresh().catch(() => {});
2102
+ onUnmounted7(() => {
2103
+ unsubscribe();
2104
+ store.close();
2105
+ });
2106
+ return {
2107
+ error,
2108
+ isLoading,
2109
+ refresh: store.refresh,
2110
+ report,
2111
+ updatedAt
2112
+ };
2113
+ }
2114
+
2115
+ // src/client/providerContractsWidget.ts
2116
+ var DEFAULT_TITLE6 = "Provider Contracts";
2117
+ var DEFAULT_DESCRIPTION6 = "Production contract coverage for provider env, latency, fallback, streaming, and capabilities.";
2118
+ var escapeHtml7 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
2119
+ var formatProvider2 = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
2120
+ var formatStatus3 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
2121
+ var contractDetail = (row) => {
2122
+ const failing = row.checks.filter((check) => check.status !== "pass");
2123
+ if (failing.length === 0) {
2124
+ return "Provider contract is production-ready.";
2125
+ }
2126
+ return failing.map((check) => `${check.label}: ${check.detail ?? check.status}`).join(" ");
2127
+ };
2128
+ var createVoiceProviderContractsViewModel = (snapshot, options = {}) => {
2129
+ const rows = (snapshot.report?.rows ?? []).map((row) => ({
2130
+ ...row,
2131
+ detail: contractDetail(row),
2132
+ label: `${formatProvider2(row.provider)} ${row.kind.toUpperCase()}`,
2133
+ remediations: row.checks.filter((check) => check.status !== "pass" && check.remediation).map((check) => ({
2134
+ detail: check.remediation?.detail ?? "",
2135
+ href: check.remediation?.href,
2136
+ label: check.remediation?.label ?? check.label
2137
+ })),
2138
+ rows: [
2139
+ { label: "Status", value: formatStatus3(row.status) },
2140
+ { label: "Selected", value: row.selected ? "Yes" : "No" },
2141
+ { label: "Configured", value: row.configured ? "Yes" : "No" },
2142
+ {
2143
+ label: "Checks",
2144
+ value: row.checks.map((check) => `${check.label}: ${formatStatus3(check.status)}`).join(", ")
2145
+ }
2146
+ ]
2147
+ }));
2148
+ const warningCount = snapshot.report ? snapshot.report.failed + snapshot.report.warned : rows.filter((row) => row.status !== "pass").length;
2149
+ return {
2150
+ description: options.description ?? DEFAULT_DESCRIPTION6,
2151
+ error: snapshot.error,
2152
+ isLoading: snapshot.isLoading,
2153
+ label: snapshot.error ? "Unavailable" : rows.length ? warningCount > 0 ? `${warningCount} needs attention` : `${rows.length} passing` : snapshot.isLoading ? "Checking" : "No contracts",
2154
+ rows,
2155
+ status: snapshot.error ? "error" : rows.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
2156
+ title: options.title ?? DEFAULT_TITLE6,
2157
+ updatedAt: snapshot.updatedAt
2158
+ };
2159
+ };
2160
+ var renderVoiceProviderContractsHTML = (snapshot, options = {}) => {
2161
+ const model = createVoiceProviderContractsViewModel(snapshot, options);
2162
+ const rows = model.rows.length ? `<div class="absolute-voice-provider-contracts__rows">${model.rows.map((row) => `<article class="absolute-voice-provider-contracts__row absolute-voice-provider-contracts__row--${escapeHtml7(row.status)}">
2163
+ <header>
2164
+ <strong>${escapeHtml7(row.label)}</strong>
2165
+ <span>${escapeHtml7(formatStatus3(row.status))}</span>
2166
+ </header>
2167
+ <p>${escapeHtml7(row.detail)}</p>
2168
+ ${row.remediations.length ? `<ul class="absolute-voice-provider-contracts__remediations">${row.remediations.map((remediation) => `<li>${remediation.href ? `<a href="${escapeHtml7(remediation.href)}">${escapeHtml7(remediation.label)}</a>` : `<strong>${escapeHtml7(remediation.label)}</strong>`}<span>${escapeHtml7(remediation.detail)}</span></li>`).join("")}</ul>` : ""}
2169
+ <dl>${row.rows.map((item) => `<div>
2170
+ <dt>${escapeHtml7(item.label)}</dt>
2171
+ <dd>${escapeHtml7(item.value)}</dd>
2172
+ </div>`).join("")}</dl>
2173
+ </article>`).join("")}</div>` : '<p class="absolute-voice-provider-contracts__empty">Configure provider contracts to see production coverage.</p>';
2174
+ return `<section class="absolute-voice-provider-contracts absolute-voice-provider-contracts--${escapeHtml7(model.status)}">
2175
+ <header class="absolute-voice-provider-contracts__header">
2176
+ <span class="absolute-voice-provider-contracts__eyebrow">${escapeHtml7(model.title)}</span>
2177
+ <strong class="absolute-voice-provider-contracts__label">${escapeHtml7(model.label)}</strong>
2178
+ </header>
2179
+ <p class="absolute-voice-provider-contracts__description">${escapeHtml7(model.description)}</p>
2180
+ ${rows}
2181
+ ${model.error ? `<p class="absolute-voice-provider-contracts__error">${escapeHtml7(model.error)}</p>` : ""}
2182
+ </section>`;
2183
+ };
2184
+ var getVoiceProviderContractsCSS = () => `.absolute-voice-provider-contracts{border:1px solid #b8dcc7;border-radius:20px;background:#f7fff9;color:#09140d;padding:18px;box-shadow:0 18px 40px rgba(21,83,45,.12);font-family:inherit}.absolute-voice-provider-contracts--error,.absolute-voice-provider-contracts--warning{border-color:#f2a7a7;background:#fff7f4}.absolute-voice-provider-contracts__header,.absolute-voice-provider-contracts__row header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-provider-contracts__eyebrow{color:#166534;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-provider-contracts__label{font-size:24px;line-height:1}.absolute-voice-provider-contracts__description,.absolute-voice-provider-contracts__row p,.absolute-voice-provider-contracts__row dt,.absolute-voice-provider-contracts__empty{color:#405448}.absolute-voice-provider-contracts__rows{display:grid;gap:12px;margin-top:14px}.absolute-voice-provider-contracts__row{background:#fff;border:1px solid #d6eadb;border-radius:16px;padding:14px}.absolute-voice-provider-contracts__row--pass{border-color:#86efac}.absolute-voice-provider-contracts__row--warn,.absolute-voice-provider-contracts__row--fail{border-color:#f2a7a7}.absolute-voice-provider-contracts__row p{margin:10px 0}.absolute-voice-provider-contracts__remediations{display:grid;gap:8px;list-style:none;margin:0 0 10px;padding:0}.absolute-voice-provider-contracts__remediations li{background:#fff7ed;border:1px solid #fed7aa;border-radius:12px;display:grid;gap:3px;padding:8px}.absolute-voice-provider-contracts__remediations a,.absolute-voice-provider-contracts__remediations strong{color:#9a3412}.absolute-voice-provider-contracts__remediations span{color:#7c2d12}.absolute-voice-provider-contracts__row dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-provider-contracts__row div{background:#f7fff9;border:1px solid #d6eadb;border-radius:12px;padding:8px}.absolute-voice-provider-contracts__row dt{font-size:12px}.absolute-voice-provider-contracts__row dd{font-weight:800;margin:4px 0 0}.absolute-voice-provider-contracts__error{color:#9f1239;font-weight:700}`;
2185
+ var mountVoiceProviderContracts = (element, path = "/api/provider-contracts", options = {}) => {
2186
+ const store = createVoiceProviderContractsStore(path, options);
2187
+ const render = () => {
2188
+ element.innerHTML = renderVoiceProviderContractsHTML(store.getSnapshot(), options);
2189
+ };
2190
+ const unsubscribe = store.subscribe(render);
2191
+ render();
2192
+ store.refresh().catch(() => {});
2193
+ return {
2194
+ close: () => {
2195
+ unsubscribe();
2196
+ store.close();
2197
+ },
2198
+ refresh: store.refresh
2199
+ };
2200
+ };
2201
+ var defineVoiceProviderContractsElement = (tagName = "absolute-voice-provider-contracts") => {
2202
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
2203
+ return;
2204
+ }
2205
+ customElements.define(tagName, class AbsoluteVoiceProviderContractsElement extends HTMLElement {
2206
+ mounted;
2207
+ connectedCallback() {
2208
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
2209
+ this.mounted = mountVoiceProviderContracts(this, this.getAttribute("path") ?? "/api/provider-contracts", {
2210
+ description: this.getAttribute("description") ?? undefined,
2211
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
2212
+ title: this.getAttribute("title") ?? undefined
2213
+ });
2214
+ }
2215
+ disconnectedCallback() {
2216
+ this.mounted?.close();
2217
+ this.mounted = undefined;
2218
+ }
2219
+ });
2220
+ };
2221
+
2222
+ // src/vue/VoiceProviderContracts.ts
2223
+ var VoiceProviderContracts = defineComponent7({
2224
+ name: "VoiceProviderContracts",
2225
+ props: {
2226
+ description: String,
2227
+ intervalMs: Number,
2228
+ path: {
2229
+ default: "/api/provider-contracts",
2230
+ type: String
2231
+ },
2232
+ title: String
2233
+ },
2234
+ setup(props) {
2235
+ const state = useVoiceProviderContracts(props.path, {
2236
+ description: props.description,
2237
+ intervalMs: props.intervalMs,
2238
+ title: props.title
2239
+ });
2240
+ return () => {
2241
+ const model = createVoiceProviderContractsViewModel({
2242
+ error: state.error.value,
2243
+ isLoading: state.isLoading.value,
2244
+ report: state.report.value,
2245
+ updatedAt: state.updatedAt.value
2246
+ }, {
2247
+ description: props.description,
2248
+ intervalMs: props.intervalMs,
2249
+ title: props.title
2250
+ });
2251
+ return h7("section", {
2252
+ class: [
2253
+ "absolute-voice-provider-contracts",
2254
+ `absolute-voice-provider-contracts--${model.status}`
2255
+ ]
2256
+ }, [
2257
+ h7("header", { class: "absolute-voice-provider-contracts__header" }, [
2258
+ h7("span", { class: "absolute-voice-provider-contracts__eyebrow" }, model.title),
2259
+ h7("strong", { class: "absolute-voice-provider-contracts__label" }, model.label)
2260
+ ]),
2261
+ h7("p", { class: "absolute-voice-provider-contracts__description" }, model.description),
2262
+ model.rows.length ? h7("div", { class: "absolute-voice-provider-contracts__rows" }, model.rows.map((row) => h7("article", {
2263
+ class: [
2264
+ "absolute-voice-provider-contracts__row",
2265
+ `absolute-voice-provider-contracts__row--${row.status}`
2266
+ ],
2267
+ key: `${row.kind}:${row.provider}`
2268
+ }, [
2269
+ h7("header", [
2270
+ h7("strong", row.label),
2271
+ h7("span", row.status)
2272
+ ]),
2273
+ h7("p", row.detail),
2274
+ row.remediations.length ? h7("ul", {
2275
+ class: "absolute-voice-provider-contracts__remediations"
2276
+ }, row.remediations.map((remediation) => h7("li", {
2277
+ key: `${row.kind}:${row.provider}:${remediation.label}`
2278
+ }, [
2279
+ remediation.href ? h7("a", { href: remediation.href }, remediation.label) : h7("strong", remediation.label),
2280
+ h7("span", remediation.detail)
2281
+ ]))) : null,
2282
+ h7("dl", row.rows.map((item) => h7("div", { key: item.label }, [
2283
+ h7("dt", item.label),
2284
+ h7("dd", item.value)
2285
+ ])))
2286
+ ]))) : h7("p", { class: "absolute-voice-provider-contracts__empty" }, "Configure provider contracts to see production coverage."),
2287
+ model.error ? h7("p", { class: "absolute-voice-provider-contracts__error" }, model.error) : null
2288
+ ]);
2289
+ };
2290
+ }
2291
+ });
2292
+ // src/vue/VoiceProviderStatus.ts
2293
+ import { computed as computed3, defineComponent as defineComponent8, h as h8 } from "vue";
2294
+
2295
+ // src/client/providerStatus.ts
2296
+ var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
2297
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2298
+ const response = await fetchImpl(path);
2299
+ if (!response.ok) {
2300
+ throw new Error(`Voice provider status failed: HTTP ${response.status}`);
2301
+ }
2302
+ return await response.json();
2303
+ };
2304
+ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
2305
+ const listeners = new Set;
2306
+ let closed = false;
2307
+ let timer;
2308
+ let snapshot = {
2309
+ error: null,
2310
+ isLoading: false,
2311
+ providers: []
2312
+ };
2313
+ const emit = () => {
2314
+ for (const listener of listeners) {
2315
+ listener();
2316
+ }
2317
+ };
2318
+ const refresh = async () => {
2319
+ if (closed) {
2320
+ return snapshot.providers;
2321
+ }
2322
+ snapshot = {
2323
+ ...snapshot,
2324
+ error: null,
2325
+ isLoading: true
2326
+ };
2327
+ emit();
2328
+ try {
2329
+ const providers = await fetchVoiceProviderStatus(path, options);
2330
+ snapshot = {
2331
+ error: null,
2332
+ isLoading: false,
2333
+ providers,
2334
+ updatedAt: Date.now()
2335
+ };
2336
+ emit();
2337
+ return providers;
2338
+ } catch (error) {
2339
+ snapshot = {
2340
+ ...snapshot,
2341
+ error: error instanceof Error ? error.message : String(error),
2342
+ isLoading: false
2343
+ };
2344
+ emit();
2345
+ throw error;
2346
+ }
2347
+ };
2348
+ const close = () => {
2349
+ closed = true;
2350
+ if (timer) {
2351
+ clearInterval(timer);
2352
+ timer = undefined;
2353
+ }
2354
+ listeners.clear();
2355
+ };
2356
+ if (options.intervalMs && options.intervalMs > 0) {
2357
+ timer = setInterval(() => {
2358
+ refresh().catch(() => {});
2359
+ }, options.intervalMs);
2360
+ }
2361
+ return {
2362
+ close,
2363
+ getServerSnapshot: () => snapshot,
2364
+ getSnapshot: () => snapshot,
2365
+ refresh,
2366
+ subscribe: (listener) => {
2367
+ listeners.add(listener);
2368
+ return () => {
2369
+ listeners.delete(listener);
2370
+ };
2371
+ }
2372
+ };
2373
+ };
2374
+
2375
+ // src/client/providerStatusWidget.ts
2376
+ var DEFAULT_TITLE7 = "Voice Providers";
2377
+ var DEFAULT_DESCRIPTION7 = "Live provider health, fallback counts, latency, and suppression state from your self-hosted trace store.";
2378
+ var escapeHtml8 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
2379
+ var formatProvider3 = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
2380
+ var formatStatus4 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
2381
+ var formatLatency = (value) => typeof value === "number" ? `${value}ms` : "No samples";
2382
+ var formatSuppression = (value) => typeof value === "number" ? `${Math.ceil(value / 1000)}s` : "None";
2383
+ var getProviderDetail = (provider) => {
2384
+ if (provider.status === "suppressed") {
2385
+ return provider.lastError ? `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)} after ${provider.lastError}.` : `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)}.`;
2386
+ }
2387
+ if (provider.status === "recoverable") {
2388
+ return "Cooldown expired; ready for recovery traffic.";
2389
+ }
2390
+ if (provider.status === "rate-limited") {
2391
+ return "Rate limit detected; router should avoid this provider.";
2392
+ }
2393
+ if (provider.status === "degraded") {
2394
+ return provider.lastError ?? "Recent provider errors detected.";
2395
+ }
2396
+ if (provider.status === "healthy") {
2397
+ return provider.recommended ? "Healthy and currently recommended." : "Healthy and available for routing.";
2398
+ }
2399
+ return "No provider traffic observed yet.";
2400
+ };
2401
+ var isWarningStatus2 = (status) => status === "degraded" || status === "rate-limited" || status === "recoverable" || status === "suppressed";
2402
+ var createVoiceProviderStatusViewModel = (snapshot, options = {}) => {
2403
+ const providers = snapshot.providers.map((provider) => ({
2404
+ ...provider,
2405
+ detail: getProviderDetail(provider),
2406
+ label: `${formatProvider3(provider.provider)}${provider.recommended ? " recommended" : ""}`,
2407
+ rows: [
2408
+ { label: "Runs", value: String(provider.runCount) },
2409
+ { label: "Avg latency", value: formatLatency(provider.averageElapsedMs) },
2410
+ { label: "Errors", value: String(provider.errorCount) },
2411
+ { label: "Timeouts", value: String(provider.timeoutCount) },
2412
+ { label: "Fallbacks", value: String(provider.fallbackCount) },
2413
+ {
2414
+ label: "Suppression",
2415
+ value: formatSuppression(provider.suppressionRemainingMs)
2416
+ }
2417
+ ]
2418
+ }));
2419
+ const warningCount = providers.filter((provider) => isWarningStatus2(provider.status)).length;
2420
+ const healthyCount = providers.filter((provider) => provider.status === "healthy").length;
2421
+ return {
2422
+ description: options.description ?? DEFAULT_DESCRIPTION7,
2423
+ error: snapshot.error,
2424
+ isLoading: snapshot.isLoading,
2425
+ label: snapshot.error ? "Unavailable" : providers.length ? warningCount > 0 ? `${warningCount} needs attention` : `${healthyCount} healthy` : snapshot.isLoading ? "Checking" : "No provider traffic",
2426
+ providers,
2427
+ status: snapshot.error ? "error" : providers.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
2428
+ title: options.title ?? DEFAULT_TITLE7,
2429
+ updatedAt: snapshot.updatedAt
2430
+ };
2431
+ };
2432
+ var renderVoiceProviderStatusHTML = (snapshot, options = {}) => {
2433
+ const model = createVoiceProviderStatusViewModel(snapshot, options);
2434
+ 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--${escapeHtml8(provider.status)}">
2435
+ <header>
2436
+ <strong>${escapeHtml8(provider.label)}</strong>
2437
+ <span>${escapeHtml8(formatStatus4(provider.status))}</span>
2438
+ </header>
2439
+ <p>${escapeHtml8(provider.detail)}</p>
2440
+ <dl>${provider.rows.map((row) => `<div>
2441
+ <dt>${escapeHtml8(row.label)}</dt>
2442
+ <dd>${escapeHtml8(row.value)}</dd>
2443
+ </div>`).join("")}</dl>
2444
+ </article>`).join("")}</div>` : '<p class="absolute-voice-provider-status__empty">Run voice traffic to see provider health.</p>';
2445
+ return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${escapeHtml8(model.status)}">
2446
+ <header class="absolute-voice-provider-status__header">
2447
+ <span class="absolute-voice-provider-status__eyebrow">${escapeHtml8(model.title)}</span>
2448
+ <strong class="absolute-voice-provider-status__label">${escapeHtml8(model.label)}</strong>
2449
+ </header>
2450
+ <p class="absolute-voice-provider-status__description">${escapeHtml8(model.description)}</p>
2451
+ ${providers}
2452
+ ${model.error ? `<p class="absolute-voice-provider-status__error">${escapeHtml8(model.error)}</p>` : ""}
2453
+ </section>`;
2454
+ };
2455
+ 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}`;
2456
+ var mountVoiceProviderStatus = (element, path = "/api/provider-status", options = {}) => {
2457
+ const store = createVoiceProviderStatusStore(path, options);
2458
+ const render = () => {
2459
+ element.innerHTML = renderVoiceProviderStatusHTML(store.getSnapshot(), options);
2460
+ };
2461
+ const unsubscribe = store.subscribe(render);
2462
+ render();
2463
+ store.refresh().catch(() => {});
2464
+ return {
2465
+ close: () => {
2466
+ unsubscribe();
2467
+ store.close();
2468
+ },
2469
+ refresh: store.refresh
2470
+ };
2471
+ };
2472
+ var defineVoiceProviderStatusElement = (tagName = "absolute-voice-provider-status") => {
2473
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
2474
+ return;
2475
+ }
2476
+ customElements.define(tagName, class AbsoluteVoiceProviderStatusElement extends HTMLElement {
2477
+ mounted;
2478
+ connectedCallback() {
2479
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
2480
+ this.mounted = mountVoiceProviderStatus(this, this.getAttribute("path") ?? "/api/provider-status", {
2481
+ description: this.getAttribute("description") ?? undefined,
2482
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
2483
+ title: this.getAttribute("title") ?? undefined
2484
+ });
2485
+ }
2486
+ disconnectedCallback() {
2487
+ this.mounted?.close();
2488
+ this.mounted = undefined;
2489
+ }
2490
+ });
2491
+ };
2492
+
2493
+ // src/vue/useVoiceProviderStatus.ts
2494
+ import { onUnmounted as onUnmounted8, ref as ref6, shallowRef as shallowRef7 } from "vue";
2495
+ function useVoiceProviderStatus(path = "/api/provider-status", options = {}) {
2496
+ const store = createVoiceProviderStatusStore(path, options);
2497
+ const error = ref6(null);
2498
+ const isLoading = ref6(false);
2499
+ const providers = shallowRef7([]);
2500
+ const updatedAt = ref6(undefined);
2501
+ const sync = () => {
2502
+ const snapshot = store.getSnapshot();
2503
+ error.value = snapshot.error;
2504
+ isLoading.value = snapshot.isLoading;
2505
+ providers.value = [...snapshot.providers];
2506
+ updatedAt.value = snapshot.updatedAt;
2507
+ };
2508
+ const unsubscribe = store.subscribe(sync);
2509
+ sync();
2510
+ store.refresh().catch(() => {});
2511
+ onUnmounted8(() => {
2512
+ unsubscribe();
2513
+ store.close();
2514
+ });
2515
+ return {
2516
+ error,
2517
+ isLoading,
2518
+ providers,
2519
+ refresh: store.refresh,
2520
+ updatedAt
2521
+ };
2522
+ }
2523
+
2524
+ // src/vue/VoiceProviderStatus.ts
2525
+ var VoiceProviderStatus = defineComponent8({
2526
+ name: "VoiceProviderStatus",
2527
+ props: {
2528
+ class: {
2529
+ default: "",
2530
+ type: String
2531
+ },
2532
+ description: {
2533
+ default: undefined,
2534
+ type: String
2535
+ },
2536
+ intervalMs: {
2537
+ default: 5000,
2538
+ type: Number
2539
+ },
2540
+ path: {
2541
+ default: "/api/provider-status",
2542
+ type: String
2543
+ },
2544
+ title: {
2545
+ default: undefined,
2546
+ type: String
2547
+ }
2548
+ },
2549
+ setup(props) {
2550
+ const options = {
2551
+ description: props.description,
2552
+ intervalMs: props.intervalMs,
2553
+ title: props.title
2554
+ };
2555
+ const status = useVoiceProviderStatus(props.path, options);
2556
+ const model = computed3(() => createVoiceProviderStatusViewModel({
2557
+ error: status.error.value,
2558
+ isLoading: status.isLoading.value,
2559
+ providers: status.providers.value,
2560
+ updatedAt: status.updatedAt.value
2561
+ }, options));
2562
+ return () => h8("section", {
2563
+ class: [
2564
+ "absolute-voice-provider-status",
2565
+ `absolute-voice-provider-status--${model.value.status}`,
2566
+ props.class
2567
+ ]
2568
+ }, [
2569
+ h8("header", { class: "absolute-voice-provider-status__header" }, [
2570
+ h8("span", { class: "absolute-voice-provider-status__eyebrow" }, model.value.title),
2571
+ h8("strong", { class: "absolute-voice-provider-status__label" }, model.value.label)
2572
+ ]),
2573
+ h8("p", { class: "absolute-voice-provider-status__description" }, model.value.description),
2574
+ model.value.providers.length ? h8("div", { class: "absolute-voice-provider-status__providers" }, model.value.providers.map((provider) => h8("article", {
2575
+ class: [
2576
+ "absolute-voice-provider-status__provider",
2577
+ `absolute-voice-provider-status__provider--${provider.status}`
2578
+ ],
2579
+ key: provider.provider
2580
+ }, [
2581
+ h8("header", [
2582
+ h8("strong", provider.label),
2583
+ h8("span", provider.status)
2584
+ ]),
2585
+ h8("p", provider.detail),
2586
+ h8("dl", provider.rows.map((row) => h8("div", { key: row.label }, [
2587
+ h8("dt", row.label),
2588
+ h8("dd", row.value)
2589
+ ])))
2590
+ ]))) : h8("p", { class: "absolute-voice-provider-status__empty" }, "Run voice traffic to see provider health."),
2591
+ model.value.error ? h8("p", { class: "absolute-voice-provider-status__error" }, model.value.error) : null
2592
+ ]);
2593
+ }
2594
+ });
2595
+ // src/vue/VoiceRoutingStatus.ts
2596
+ import { computed as computed4, defineComponent as defineComponent9, h as h9 } from "vue";
2597
+
2598
+ // src/client/routingStatus.ts
2599
+ var fetchVoiceRoutingStatus = async (path = "/api/routing/latest", options = {}) => {
2600
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2601
+ const response = await fetchImpl(path);
2602
+ if (!response.ok) {
2603
+ throw new Error(`Voice routing status failed: HTTP ${response.status}`);
2604
+ }
2605
+ return await response.json();
2606
+ };
2607
+ var createVoiceRoutingStatusStore = (path = "/api/routing/latest", options = {}) => {
2608
+ const listeners = new Set;
2609
+ let closed = false;
2610
+ let timer;
2611
+ let snapshot = {
2612
+ decision: null,
2613
+ error: null,
2614
+ isLoading: false
2615
+ };
2616
+ const emit = () => {
2617
+ for (const listener of listeners) {
2618
+ listener();
2619
+ }
2620
+ };
2621
+ const refresh = async () => {
2622
+ if (closed) {
2623
+ return snapshot.decision;
2624
+ }
2625
+ snapshot = {
2626
+ ...snapshot,
2627
+ error: null,
2628
+ isLoading: true
2629
+ };
2630
+ emit();
2631
+ try {
2632
+ const decision = await fetchVoiceRoutingStatus(path, options);
2633
+ snapshot = {
2634
+ decision,
2635
+ error: null,
2636
+ isLoading: false,
2637
+ updatedAt: Date.now()
2638
+ };
2639
+ emit();
2640
+ return decision;
2641
+ } catch (error) {
2642
+ snapshot = {
2643
+ ...snapshot,
2644
+ error: error instanceof Error ? error.message : String(error),
2645
+ isLoading: false
2646
+ };
2647
+ emit();
2648
+ throw error;
2649
+ }
2650
+ };
2651
+ const close = () => {
2652
+ closed = true;
2653
+ if (timer) {
2654
+ clearInterval(timer);
2655
+ timer = undefined;
2656
+ }
2657
+ listeners.clear();
2658
+ };
2659
+ if (options.intervalMs && options.intervalMs > 0) {
2660
+ timer = setInterval(() => {
2661
+ refresh().catch(() => {});
2662
+ }, options.intervalMs);
2663
+ }
2664
+ return {
2665
+ close,
2666
+ getServerSnapshot: () => snapshot,
2667
+ getSnapshot: () => snapshot,
2668
+ refresh,
2669
+ subscribe: (listener) => {
2670
+ listeners.add(listener);
2671
+ return () => {
2672
+ listeners.delete(listener);
2673
+ };
2674
+ }
2675
+ };
2676
+ };
2677
+
2678
+ // src/client/routingStatusWidget.ts
2679
+ var DEFAULT_TITLE8 = "Voice Routing";
2680
+ var DEFAULT_DESCRIPTION8 = "Latest provider routing decision from the self-hosted trace store.";
2681
+ var escapeHtml9 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
2682
+ var formatValue = (value, fallback = "None") => typeof value === "string" && value.trim() ? value : typeof value === "number" && Number.isFinite(value) ? String(value) : fallback;
2683
+ var createVoiceRoutingStatusViewModel = (snapshot, options = {}) => {
2684
+ const decision = snapshot.decision;
2685
+ const rows = decision ? [
2686
+ { label: "Kind", value: decision.kind.toUpperCase() },
2687
+ { label: "Policy", value: formatValue(decision.routing, "Unknown") },
2688
+ { label: "Provider", value: formatValue(decision.provider, "Unknown") },
2689
+ {
2690
+ label: "Selected",
2691
+ value: formatValue(decision.selectedProvider, "Unknown")
2692
+ },
2693
+ {
2694
+ label: "Fallback",
2695
+ value: formatValue(decision.fallbackProvider)
2696
+ },
2697
+ { label: "Status", value: formatValue(decision.status, "unknown") },
2698
+ {
2699
+ label: "Latency budget",
2700
+ value: typeof decision.latencyBudgetMs === "number" ? `${decision.latencyBudgetMs}ms` : "None"
2701
+ }
2702
+ ] : [];
2703
+ return {
2704
+ decision,
2705
+ description: options.description ?? DEFAULT_DESCRIPTION8,
2706
+ error: snapshot.error,
2707
+ isLoading: snapshot.isLoading,
2708
+ label: snapshot.error ? "Unavailable" : decision ? `${formatValue(decision.kind).toUpperCase()} ${formatValue(decision.status, "unknown")}` : snapshot.isLoading ? "Checking" : "No routing yet",
2709
+ rows,
2710
+ status: snapshot.error ? "error" : decision ? "ready" : snapshot.isLoading ? "loading" : "empty",
2711
+ title: options.title ?? DEFAULT_TITLE8,
2712
+ updatedAt: snapshot.updatedAt
2713
+ };
2714
+ };
2715
+ var renderVoiceRoutingStatusHTML = (snapshot, options = {}) => {
2716
+ const model = createVoiceRoutingStatusViewModel(snapshot, options);
2717
+ const rows = model.rows.length ? `<div class="absolute-voice-routing-status__grid">${model.rows.map((row) => `<div>
2718
+ <span>${escapeHtml9(row.label)}</span>
2719
+ <strong>${escapeHtml9(row.value)}</strong>
2720
+ </div>`).join("")}</div>` : '<p class="absolute-voice-routing-status__empty">Start a voice session to see the selected provider.</p>';
2721
+ return `<section class="absolute-voice-routing-status absolute-voice-routing-status--${escapeHtml9(model.status)}">
2722
+ <header class="absolute-voice-routing-status__header">
2723
+ <span class="absolute-voice-routing-status__eyebrow">${escapeHtml9(model.title)}</span>
2724
+ <strong class="absolute-voice-routing-status__label">${escapeHtml9(model.label)}</strong>
2725
+ </header>
2726
+ <p class="absolute-voice-routing-status__description">${escapeHtml9(model.description)}</p>
2727
+ ${rows}
2728
+ ${model.error ? `<p class="absolute-voice-routing-status__error">${escapeHtml9(model.error)}</p>` : ""}
2729
+ </section>`;
2730
+ };
2731
+ 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}`;
2732
+ var mountVoiceRoutingStatus = (element, path = "/api/routing/latest", options = {}) => {
2733
+ const store = createVoiceRoutingStatusStore(path, options);
2734
+ const render = () => {
2735
+ element.innerHTML = renderVoiceRoutingStatusHTML(store.getSnapshot(), options);
2736
+ };
2737
+ const unsubscribe = store.subscribe(render);
2738
+ render();
2739
+ store.refresh().catch(() => {});
2740
+ return {
2741
+ close: () => {
2742
+ unsubscribe();
2743
+ store.close();
2744
+ },
2745
+ refresh: store.refresh
2746
+ };
2747
+ };
2748
+ var defineVoiceRoutingStatusElement = (tagName = "absolute-voice-routing-status") => {
2749
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
2750
+ return;
2751
+ }
2752
+ customElements.define(tagName, class AbsoluteVoiceRoutingStatusElement extends HTMLElement {
2753
+ mounted;
2754
+ connectedCallback() {
2755
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
2756
+ this.mounted = mountVoiceRoutingStatus(this, this.getAttribute("path") ?? "/api/routing/latest", {
2757
+ description: this.getAttribute("description") ?? undefined,
2758
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
2759
+ title: this.getAttribute("title") ?? undefined
2760
+ });
2761
+ }
2762
+ disconnectedCallback() {
2763
+ this.mounted?.close();
2764
+ this.mounted = undefined;
2765
+ }
2766
+ });
2767
+ };
2768
+
2769
+ // src/vue/useVoiceRoutingStatus.ts
2770
+ import { onUnmounted as onUnmounted9, ref as ref7, shallowRef as shallowRef8 } from "vue";
2771
+ function useVoiceRoutingStatus(path = "/api/routing/latest", options = {}) {
2772
+ const store = createVoiceRoutingStatusStore(path, options);
2773
+ const decision = shallowRef8(null);
2774
+ const error = ref7(null);
2775
+ const isLoading = ref7(false);
2776
+ const updatedAt = ref7(undefined);
2777
+ const sync = () => {
2778
+ const snapshot = store.getSnapshot();
2779
+ decision.value = snapshot.decision;
2780
+ error.value = snapshot.error;
2781
+ isLoading.value = snapshot.isLoading;
2782
+ updatedAt.value = snapshot.updatedAt;
2783
+ };
2784
+ const unsubscribe = store.subscribe(sync);
2785
+ sync();
2786
+ store.refresh().catch(() => {});
2787
+ onUnmounted9(() => {
2788
+ unsubscribe();
2789
+ store.close();
2790
+ });
2791
+ return {
2792
+ decision,
2793
+ error,
2794
+ isLoading,
2795
+ refresh: store.refresh,
2796
+ updatedAt
2797
+ };
2798
+ }
2799
+
2800
+ // src/vue/VoiceRoutingStatus.ts
2801
+ var VoiceRoutingStatus = defineComponent9({
2802
+ name: "VoiceRoutingStatus",
2803
+ props: {
2804
+ class: {
2805
+ default: "",
2806
+ type: String
2807
+ },
2808
+ description: {
2809
+ default: undefined,
2810
+ type: String
2811
+ },
2812
+ intervalMs: {
2813
+ default: 5000,
2814
+ type: Number
2815
+ },
2816
+ path: {
2817
+ default: "/api/routing/latest",
2818
+ type: String
2819
+ },
2820
+ title: {
2821
+ default: undefined,
2822
+ type: String
2823
+ }
2824
+ },
2825
+ setup(props) {
2826
+ const options = {
2827
+ description: props.description,
2828
+ intervalMs: props.intervalMs,
2829
+ title: props.title
2830
+ };
2831
+ const status = useVoiceRoutingStatus(props.path, options);
2832
+ const model = computed4(() => createVoiceRoutingStatusViewModel({
2833
+ decision: status.decision.value,
2834
+ error: status.error.value,
2835
+ isLoading: status.isLoading.value,
2836
+ updatedAt: status.updatedAt.value
2837
+ }, options));
2838
+ return () => h9("section", {
2839
+ class: [
2840
+ "absolute-voice-routing-status",
2841
+ `absolute-voice-routing-status--${model.value.status}`,
2842
+ props.class
2843
+ ]
2844
+ }, [
2845
+ h9("header", { class: "absolute-voice-routing-status__header" }, [
2846
+ h9("span", { class: "absolute-voice-routing-status__eyebrow" }, model.value.title),
2847
+ h9("strong", { class: "absolute-voice-routing-status__label" }, model.value.label)
2848
+ ]),
2849
+ h9("p", { class: "absolute-voice-routing-status__description" }, model.value.description),
2850
+ model.value.rows.length ? h9("div", { class: "absolute-voice-routing-status__grid" }, model.value.rows.map((row) => h9("div", { key: row.label }, [
2851
+ h9("span", row.label),
2852
+ h9("strong", row.value)
2853
+ ]))) : h9("p", { class: "absolute-voice-routing-status__empty" }, "Start a voice session to see the selected provider."),
2854
+ model.value.error ? h9("p", { class: "absolute-voice-routing-status__error" }, model.value.error) : null
2855
+ ]);
2856
+ }
2857
+ });
2858
+ // src/vue/useVoiceAgentSquadStatus.ts
2859
+ import { onUnmounted as onUnmounted10, ref as ref8, shallowRef as shallowRef9 } from "vue";
2860
+
2861
+ // src/client/traceTimeline.ts
2862
+ var fetchVoiceTraceTimeline = async (path = "/api/voice-traces", options = {}) => {
2863
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2864
+ const response = await fetchImpl(path);
2865
+ if (!response.ok) {
2866
+ throw new Error(`Voice trace timeline failed: HTTP ${response.status}`);
2867
+ }
2868
+ return await response.json();
2869
+ };
2870
+ var createVoiceTraceTimelineStore = (path = "/api/voice-traces", options = {}) => {
2871
+ const listeners = new Set;
2872
+ let closed = false;
2873
+ let timer;
2874
+ let snapshot = {
2875
+ error: null,
2876
+ isLoading: false,
2877
+ report: null
2878
+ };
2879
+ const emit = () => {
2880
+ for (const listener of listeners) {
2881
+ listener();
2882
+ }
2883
+ };
2884
+ const refresh = async () => {
2885
+ if (closed) {
2886
+ return snapshot.report;
2887
+ }
2888
+ snapshot = {
2889
+ ...snapshot,
2890
+ error: null,
2891
+ isLoading: true
2892
+ };
2893
+ emit();
2894
+ try {
2895
+ const report = await fetchVoiceTraceTimeline(path, options);
2896
+ snapshot = {
2897
+ error: null,
2898
+ isLoading: false,
2899
+ report,
2900
+ updatedAt: Date.now()
2901
+ };
2902
+ emit();
2903
+ return report;
2904
+ } catch (error) {
2905
+ snapshot = {
2906
+ ...snapshot,
2907
+ error: error instanceof Error ? error.message : String(error),
2908
+ isLoading: false
2909
+ };
2910
+ emit();
2911
+ throw error;
2912
+ }
2913
+ };
2914
+ const close = () => {
2915
+ closed = true;
2916
+ if (timer) {
2917
+ clearInterval(timer);
2918
+ timer = undefined;
2919
+ }
2920
+ listeners.clear();
2921
+ };
2922
+ if (options.intervalMs && options.intervalMs > 0) {
2923
+ timer = setInterval(() => {
2924
+ refresh().catch(() => {});
2925
+ }, options.intervalMs);
2926
+ }
2927
+ return {
2928
+ close,
2929
+ getServerSnapshot: () => snapshot,
2930
+ getSnapshot: () => snapshot,
2931
+ refresh,
2932
+ subscribe: (listener) => {
2933
+ listeners.add(listener);
2934
+ return () => {
2935
+ listeners.delete(listener);
2936
+ };
2937
+ }
2938
+ };
2939
+ };
2940
+
2941
+ // src/client/agentSquadStatus.ts
2942
+ var getString = (value) => typeof value === "string" && value.trim() ? value.trim() : undefined;
2943
+ var getPayloadString = (event, key) => getString(event.payload?.[key]);
2944
+ var eventStatus = (event) => {
2945
+ const status = getPayloadString(event, "status");
2946
+ if (status === "blocked")
2947
+ return "blocked";
2948
+ if (status === "unknown-target")
2949
+ return "unknown-target";
2950
+ if (status === "allowed")
2951
+ return "handoff";
2952
+ return event.type === "agent.result" ? "active" : "handoff";
2953
+ };
2954
+ var deriveSessionSpecialist = (session) => {
2955
+ const events = [...session.events].sort((left, right) => left.at - right.at);
2956
+ const agentEvents = events.filter((event) => event.type === "agent.handoff" || event.type === "agent.context" || event.type === "agent.result" || event.type === "agent.model");
2957
+ const latest = agentEvents.at(-1);
2958
+ if (!latest) {
2959
+ return {
2960
+ lastEventAt: session.lastEventAt,
2961
+ sessionId: session.sessionId,
2962
+ status: "idle"
2963
+ };
2964
+ }
2965
+ const handoffEvents = events.filter((event) => event.type === "agent.handoff");
2966
+ const lastHandoff = handoffEvents.at(-1);
2967
+ const latestAgentId = getPayloadString(latest, "agentId");
2968
+ const handoffStatus = lastHandoff ? eventStatus(lastHandoff) : undefined;
2969
+ const currentTarget = handoffStatus === "blocked" || handoffStatus === "unknown-target" ? getPayloadString(lastHandoff, "fromAgentId") ?? latestAgentId : getPayloadString(lastHandoff ?? latest, "targetAgentId") ?? latestAgentId;
2970
+ return {
2971
+ fromAgentId: getPayloadString(lastHandoff ?? latest, "fromAgentId"),
2972
+ lastEventAt: latest.at,
2973
+ reason: getPayloadString(lastHandoff ?? latest, "reason") ?? getPayloadString(latest, "handoffTarget"),
2974
+ sessionId: session.sessionId,
2975
+ status: lastHandoff ? eventStatus(lastHandoff) : "active",
2976
+ summary: getPayloadString(lastHandoff ?? latest, "summary"),
2977
+ targetAgentId: currentTarget,
2978
+ turnId: latest.turnId
2979
+ };
2980
+ };
2981
+ var buildVoiceAgentSquadStatusReport = (timeline, options = {}) => {
2982
+ const sessions = (timeline?.sessions ?? []).filter((session) => !options.sessionId || session.sessionId === options.sessionId).map(deriveSessionSpecialist).sort((left, right) => (right.lastEventAt ?? 0) - (left.lastEventAt ?? 0));
2983
+ const active = sessions.filter((session) => session.status !== "idle");
2984
+ return {
2985
+ active,
2986
+ checkedAt: timeline?.checkedAt,
2987
+ current: active[0] ?? sessions[0],
2988
+ sessionCount: sessions.length,
2989
+ sessions
2990
+ };
2991
+ };
2992
+ var createVoiceAgentSquadStatusStore = (path = "/api/voice-traces", options = {}) => {
2993
+ const timelineStore = createVoiceTraceTimelineStore(path, options);
2994
+ const getReport = () => buildVoiceAgentSquadStatusReport(timelineStore.getSnapshot().report, {
2995
+ sessionId: options.sessionId
2996
+ });
2997
+ const getSnapshot = () => {
2998
+ const snapshot = timelineStore.getSnapshot();
2999
+ return {
3000
+ error: snapshot.error,
3001
+ isLoading: snapshot.isLoading,
3002
+ report: getReport(),
3003
+ updatedAt: snapshot.updatedAt
3004
+ };
3005
+ };
3006
+ return {
3007
+ close: timelineStore.close,
3008
+ getServerSnapshot: getSnapshot,
3009
+ getSnapshot,
3010
+ refresh: timelineStore.refresh,
3011
+ subscribe: timelineStore.subscribe
3012
+ };
3013
+ };
3014
+
3015
+ // src/vue/useVoiceAgentSquadStatus.ts
3016
+ function useVoiceAgentSquadStatus(path = "/api/voice-traces", options = {}) {
3017
+ const store = createVoiceAgentSquadStatusStore(path, options);
3018
+ const current = shallowRef9(undefined);
3019
+ const error = ref8(null);
3020
+ const isLoading = ref8(false);
3021
+ const report = shallowRef9(undefined);
3022
+ const updatedAt = ref8(undefined);
3023
+ const sync = () => {
3024
+ const snapshot = store.getSnapshot();
3025
+ current.value = snapshot.report.current;
3026
+ error.value = snapshot.error;
3027
+ isLoading.value = snapshot.isLoading;
3028
+ report.value = snapshot.report;
3029
+ updatedAt.value = snapshot.updatedAt;
3030
+ };
3031
+ const unsubscribe = store.subscribe(sync);
3032
+ sync();
3033
+ if (typeof window !== "undefined") {
3034
+ store.refresh().catch(() => {});
3035
+ }
3036
+ onUnmounted10(() => {
3037
+ unsubscribe();
3038
+ store.close();
3039
+ });
3040
+ return {
3041
+ current,
3042
+ error,
3043
+ isLoading,
3044
+ refresh: store.refresh,
3045
+ report,
3046
+ updatedAt
3047
+ };
3048
+ }
3049
+ // src/vue/VoiceTurnLatency.ts
3050
+ import { computed as computed5, defineComponent as defineComponent10, h as h10 } from "vue";
3051
+
3052
+ // src/client/turnLatency.ts
3053
+ var fetchVoiceTurnLatency = async (path = "/api/turn-latency", options = {}) => {
3054
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3055
+ const response = await fetchImpl(path);
3056
+ if (!response.ok) {
3057
+ throw new Error(`Voice turn latency failed: HTTP ${response.status}`);
3058
+ }
3059
+ return await response.json();
3060
+ };
3061
+ var runVoiceTurnLatencyProof = async (path, options = {}) => {
3062
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3063
+ const response = await fetchImpl(path, { method: "POST" });
3064
+ if (!response.ok) {
3065
+ throw new Error(`Voice turn latency proof failed: HTTP ${response.status}`);
3066
+ }
3067
+ return response.json();
3068
+ };
3069
+ var createVoiceTurnLatencyStore = (path = "/api/turn-latency", options = {}) => {
3070
+ const listeners = new Set;
3071
+ let closed = false;
3072
+ let timer;
3073
+ let snapshot = {
3074
+ error: null,
3075
+ isLoading: false
3076
+ };
3077
+ const emit = () => {
3078
+ for (const listener of listeners) {
3079
+ listener();
3080
+ }
3081
+ };
3082
+ const refresh = async () => {
3083
+ if (closed) {
3084
+ return snapshot.report;
3085
+ }
3086
+ snapshot = { ...snapshot, error: null, isLoading: true };
3087
+ emit();
3088
+ try {
3089
+ const report = await fetchVoiceTurnLatency(path, options);
3090
+ snapshot = {
3091
+ error: null,
3092
+ isLoading: false,
3093
+ report,
3094
+ updatedAt: Date.now()
3095
+ };
3096
+ emit();
3097
+ return report;
3098
+ } catch (error) {
3099
+ snapshot = {
3100
+ ...snapshot,
3101
+ error: error instanceof Error ? error.message : String(error),
3102
+ isLoading: false
3103
+ };
3104
+ emit();
3105
+ throw error;
3106
+ }
3107
+ };
3108
+ const runProof = async () => {
3109
+ if (!options.proofPath) {
3110
+ throw new Error("Voice turn latency proof path is not configured.");
3111
+ }
3112
+ snapshot = { ...snapshot, error: null, isLoading: true };
3113
+ emit();
3114
+ try {
3115
+ await runVoiceTurnLatencyProof(options.proofPath, options);
3116
+ return await refresh();
3117
+ } catch (error) {
3118
+ snapshot = {
3119
+ ...snapshot,
3120
+ error: error instanceof Error ? error.message : String(error),
3121
+ isLoading: false
3122
+ };
3123
+ emit();
3124
+ throw error;
3125
+ }
3126
+ };
3127
+ const close = () => {
3128
+ closed = true;
3129
+ if (timer) {
3130
+ clearInterval(timer);
3131
+ timer = undefined;
3132
+ }
3133
+ listeners.clear();
3134
+ };
3135
+ if (options.intervalMs && options.intervalMs > 0) {
3136
+ timer = setInterval(() => {
3137
+ refresh().catch(() => {});
3138
+ }, options.intervalMs);
3139
+ }
3140
+ return {
3141
+ close,
3142
+ getServerSnapshot: () => snapshot,
3143
+ getSnapshot: () => snapshot,
3144
+ refresh,
3145
+ runProof,
3146
+ subscribe: (listener) => {
3147
+ listeners.add(listener);
3148
+ return () => {
3149
+ listeners.delete(listener);
3150
+ };
3151
+ }
3152
+ };
3153
+ };
3154
+
3155
+ // src/client/turnLatencyWidget.ts
3156
+ var DEFAULT_TITLE9 = "Turn Latency";
3157
+ var DEFAULT_DESCRIPTION9 = "Per-turn timing from first transcript to commit and assistant response start.";
3158
+ var DEFAULT_PROOF_LABEL = "Run latency proof";
3159
+ var escapeHtml10 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
3160
+ var formatMs = (value) => typeof value === "number" ? `${Math.round(value)}ms` : "n/a";
3161
+ var createVoiceTurnLatencyViewModel = (snapshot, options = {}) => {
3162
+ const turns = (snapshot.report?.turns ?? []).map((turn) => ({
3163
+ ...turn,
3164
+ label: turn.text || "Empty turn",
3165
+ rows: turn.stages.map((stage) => ({
3166
+ label: stage.label,
3167
+ value: formatMs(stage.valueMs)
3168
+ }))
3169
+ }));
3170
+ const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
3171
+ const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
3172
+ return {
3173
+ description: options.description ?? DEFAULT_DESCRIPTION9,
3174
+ error: snapshot.error,
3175
+ isLoading: snapshot.isLoading,
3176
+ label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} slow` : warningCount > 0 ? `${warningCount} warnings` : `avg ${formatMs(snapshot.report?.averageTotalMs)}` : snapshot.isLoading ? "Checking" : "No turns",
3177
+ proofLabel: options.proofPath ? options.proofLabel ?? DEFAULT_PROOF_LABEL : undefined,
3178
+ showProofAction: Boolean(options.proofPath),
3179
+ status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
3180
+ title: options.title ?? DEFAULT_TITLE9,
3181
+ turns,
3182
+ updatedAt: snapshot.updatedAt
3183
+ };
3184
+ };
3185
+ var renderVoiceTurnLatencyHTML = (snapshot, options = {}) => {
3186
+ const model = createVoiceTurnLatencyViewModel(snapshot, options);
3187
+ 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--${escapeHtml10(turn.status)}">
3188
+ <header>
3189
+ <strong>${escapeHtml10(turn.label)}</strong>
3190
+ <span>${escapeHtml10(turn.status)}</span>
3191
+ </header>
3192
+ <dl>${turn.rows.map((row) => `<div>
3193
+ <dt>${escapeHtml10(row.label)}</dt>
3194
+ <dd>${escapeHtml10(row.value)}</dd>
3195
+ </div>`).join("")}</dl>
3196
+ </article>`).join("")}</div>` : '<p class="absolute-voice-turn-latency__empty">Complete a voice turn to see latency diagnostics.</p>';
3197
+ return `<section class="absolute-voice-turn-latency absolute-voice-turn-latency--${escapeHtml10(model.status)}">
3198
+ <header class="absolute-voice-turn-latency__header">
3199
+ <span class="absolute-voice-turn-latency__eyebrow">${escapeHtml10(model.title)}</span>
3200
+ <strong class="absolute-voice-turn-latency__label">${escapeHtml10(model.label)}</strong>
3201
+ </header>
3202
+ <p class="absolute-voice-turn-latency__description">${escapeHtml10(model.description)}</p>
3203
+ ${model.showProofAction ? `<button class="absolute-voice-turn-latency__proof" data-absolute-voice-turn-latency-proof type="button">${escapeHtml10(model.proofLabel ?? DEFAULT_PROOF_LABEL)}</button>` : ""}
3204
+ ${turns}
3205
+ ${model.error ? `<p class="absolute-voice-turn-latency__error">${escapeHtml10(model.error)}</p>` : ""}
3206
+ </section>`;
3207
+ };
3208
+ var mountVoiceTurnLatency = (element, path = "/api/turn-latency", options = {}) => {
3209
+ const store = createVoiceTurnLatencyStore(path, options);
3210
+ const render = () => {
3211
+ element.innerHTML = renderVoiceTurnLatencyHTML(store.getSnapshot(), options);
3212
+ };
3213
+ const handleClick = (event) => {
3214
+ const target = event.target;
3215
+ if (target instanceof Element && target.closest("[data-absolute-voice-turn-latency-proof]")) {
3216
+ store.runProof().catch(() => {});
3217
+ }
3218
+ };
3219
+ const unsubscribe = store.subscribe(render);
3220
+ element.addEventListener("click", handleClick);
3221
+ render();
3222
+ store.refresh().catch(() => {});
3223
+ return {
3224
+ close: () => {
3225
+ element.removeEventListener("click", handleClick);
3226
+ unsubscribe();
3227
+ store.close();
3228
+ },
3229
+ refresh: store.refresh
3230
+ };
3231
+ };
3232
+ var defineVoiceTurnLatencyElement = (tagName = "absolute-voice-turn-latency") => {
3233
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
3234
+ return;
3235
+ }
3236
+ customElements.define(tagName, class AbsoluteVoiceTurnLatencyElement extends HTMLElement {
3237
+ mounted;
3238
+ connectedCallback() {
3239
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
3240
+ this.mounted = mountVoiceTurnLatency(this, this.getAttribute("path") ?? "/api/turn-latency", {
3241
+ description: this.getAttribute("description") ?? undefined,
3242
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
3243
+ proofLabel: this.getAttribute("proof-label") ?? undefined,
3244
+ proofPath: this.getAttribute("proof-path") ?? undefined,
3245
+ title: this.getAttribute("title") ?? undefined
3246
+ });
3247
+ }
3248
+ disconnectedCallback() {
3249
+ this.mounted?.close();
3250
+ this.mounted = undefined;
3251
+ }
3252
+ });
3253
+ };
3254
+
3255
+ // src/vue/useVoiceTurnLatency.ts
3256
+ import { onUnmounted as onUnmounted11, shallowRef as shallowRef10 } from "vue";
3257
+ function useVoiceTurnLatency(path = "/api/turn-latency", options = {}) {
3258
+ const store = createVoiceTurnLatencyStore(path, options);
3259
+ const error = shallowRef10(null);
3260
+ const isLoading = shallowRef10(false);
3261
+ const report = shallowRef10();
3262
+ const updatedAt = shallowRef10(undefined);
3263
+ const sync = () => {
3264
+ const snapshot = store.getSnapshot();
3265
+ error.value = snapshot.error;
3266
+ isLoading.value = snapshot.isLoading;
3267
+ report.value = snapshot.report;
3268
+ updatedAt.value = snapshot.updatedAt;
3269
+ };
3270
+ const unsubscribe = store.subscribe(sync);
3271
+ sync();
3272
+ store.refresh().catch(() => {});
3273
+ onUnmounted11(() => {
3274
+ unsubscribe();
3275
+ store.close();
3276
+ });
3277
+ return {
3278
+ error,
3279
+ isLoading,
3280
+ refresh: store.refresh,
3281
+ report,
3282
+ runProof: store.runProof,
3283
+ updatedAt
3284
+ };
3285
+ }
3286
+
3287
+ // src/vue/VoiceTurnLatency.ts
3288
+ var VoiceTurnLatency = defineComponent10({
3289
+ name: "VoiceTurnLatency",
3290
+ props: {
3291
+ class: { default: "", type: String },
3292
+ description: { default: undefined, type: String },
3293
+ intervalMs: { default: 5000, type: Number },
3294
+ path: { default: "/api/turn-latency", type: String },
3295
+ proofLabel: { default: undefined, type: String },
3296
+ proofPath: { default: undefined, type: String },
3297
+ title: { default: undefined, type: String }
3298
+ },
3299
+ setup(props) {
3300
+ const options = {
3301
+ description: props.description,
3302
+ intervalMs: props.intervalMs,
3303
+ proofLabel: props.proofLabel,
3304
+ proofPath: props.proofPath,
3305
+ title: props.title
3306
+ };
3307
+ const latency = useVoiceTurnLatency(props.path, options);
3308
+ const model = computed5(() => createVoiceTurnLatencyViewModel({
3309
+ error: latency.error.value,
3310
+ isLoading: latency.isLoading.value,
3311
+ report: latency.report.value,
3312
+ updatedAt: latency.updatedAt.value
3313
+ }, options));
3314
+ return () => h10("section", {
3315
+ class: [
3316
+ "absolute-voice-turn-latency",
3317
+ `absolute-voice-turn-latency--${model.value.status}`,
3318
+ props.class
3319
+ ]
3320
+ }, [
3321
+ h10("header", { class: "absolute-voice-turn-latency__header" }, [
3322
+ h10("span", { class: "absolute-voice-turn-latency__eyebrow" }, model.value.title),
3323
+ h10("strong", { class: "absolute-voice-turn-latency__label" }, model.value.label)
3324
+ ]),
3325
+ h10("p", { class: "absolute-voice-turn-latency__description" }, model.value.description),
3326
+ model.value.showProofAction ? h10("button", {
3327
+ class: "absolute-voice-turn-latency__proof",
3328
+ onClick: () => {
3329
+ latency.runProof().catch(() => {});
3330
+ },
3331
+ type: "button"
3332
+ }, model.value.proofLabel) : null,
3333
+ model.value.turns.length ? h10("div", { class: "absolute-voice-turn-latency__turns" }, model.value.turns.map((turn) => h10("article", {
3334
+ class: [
3335
+ "absolute-voice-turn-latency__turn",
3336
+ `absolute-voice-turn-latency__turn--${turn.status}`
3337
+ ],
3338
+ key: `${turn.sessionId}:${turn.turnId}`
3339
+ }, [
3340
+ h10("header", [
3341
+ h10("strong", turn.label),
3342
+ h10("span", turn.status)
3343
+ ]),
3344
+ h10("dl", turn.rows.map((row) => h10("div", { key: row.label }, [
3345
+ h10("dt", row.label),
3346
+ h10("dd", row.value)
3347
+ ])))
3348
+ ]))) : h10("p", { class: "absolute-voice-turn-latency__empty" }, "Complete a voice turn to see latency diagnostics."),
3349
+ model.value.error ? h10("p", { class: "absolute-voice-turn-latency__error" }, model.value.error) : null
3350
+ ]);
3351
+ }
3352
+ });
3353
+ // src/vue/VoiceTurnQuality.ts
3354
+ import { computed as computed6, defineComponent as defineComponent11, h as h11 } from "vue";
3355
+
3356
+ // src/client/turnQuality.ts
3357
+ var fetchVoiceTurnQuality = async (path = "/api/turn-quality", options = {}) => {
3358
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3359
+ const response = await fetchImpl(path);
3360
+ if (!response.ok) {
3361
+ throw new Error(`Voice turn quality failed: HTTP ${response.status}`);
3362
+ }
3363
+ return await response.json();
3364
+ };
3365
+ var createVoiceTurnQualityStore = (path = "/api/turn-quality", options = {}) => {
3366
+ const listeners = new Set;
3367
+ let closed = false;
3368
+ let timer;
3369
+ let snapshot = {
3370
+ error: null,
3371
+ isLoading: false
3372
+ };
3373
+ const emit = () => {
3374
+ for (const listener of listeners) {
3375
+ listener();
3376
+ }
3377
+ };
3378
+ const refresh = async () => {
3379
+ if (closed) {
3380
+ return snapshot.report;
3381
+ }
3382
+ snapshot = {
3383
+ ...snapshot,
3384
+ error: null,
3385
+ isLoading: true
3386
+ };
3387
+ emit();
3388
+ try {
3389
+ const report = await fetchVoiceTurnQuality(path, options);
3390
+ snapshot = {
3391
+ error: null,
3392
+ isLoading: false,
3393
+ report,
3394
+ updatedAt: Date.now()
3395
+ };
3396
+ emit();
3397
+ return report;
3398
+ } catch (error) {
3399
+ snapshot = {
3400
+ ...snapshot,
3401
+ error: error instanceof Error ? error.message : String(error),
3402
+ isLoading: false
3403
+ };
3404
+ emit();
3405
+ throw error;
3406
+ }
3407
+ };
3408
+ const close = () => {
3409
+ closed = true;
3410
+ if (timer) {
3411
+ clearInterval(timer);
3412
+ timer = undefined;
3413
+ }
3414
+ listeners.clear();
3415
+ };
3416
+ if (options.intervalMs && options.intervalMs > 0) {
3417
+ timer = setInterval(() => {
3418
+ refresh().catch(() => {});
3419
+ }, options.intervalMs);
3420
+ }
3421
+ return {
3422
+ close,
3423
+ getServerSnapshot: () => snapshot,
3424
+ getSnapshot: () => snapshot,
3425
+ refresh,
3426
+ subscribe: (listener) => {
3427
+ listeners.add(listener);
3428
+ return () => {
3429
+ listeners.delete(listener);
3430
+ };
3431
+ }
3432
+ };
3433
+ };
3434
+
3435
+ // src/client/turnQualityWidget.ts
3436
+ var DEFAULT_TITLE10 = "Turn Quality";
3437
+ var DEFAULT_DESCRIPTION10 = "Per-turn STT confidence, fallback selection, corrections, and transcript coverage.";
3438
+ var escapeHtml11 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
3439
+ var formatConfidence = (value) => typeof value === "number" ? `${Math.round(value * 100)}%` : "n/a";
3440
+ var formatMaybe = (value) => value === undefined || value === "" ? "n/a" : String(value);
3441
+ var getTurnDetail = (turn) => {
3442
+ if (turn.status === "fail") {
3443
+ return "Empty or unusable committed turn; inspect transcripts and adapter events.";
3444
+ }
3445
+ if (turn.fallbackUsed) {
3446
+ return `Fallback STT selected${turn.fallbackSelectionReason ? ` by ${turn.fallbackSelectionReason}` : ""}.`;
3447
+ }
3448
+ if (turn.correctionChanged) {
3449
+ return `Correction changed the turn${turn.correctionProvider ? ` via ${turn.correctionProvider}` : ""}.`;
3450
+ }
3451
+ if (turn.status === "warn") {
3452
+ return "Turn completed with quality warnings.";
3453
+ }
3454
+ if (turn.status === "unknown") {
3455
+ return "No quality diagnostics were recorded for this turn.";
3456
+ }
3457
+ return "Turn quality looks healthy.";
3458
+ };
3459
+ var createVoiceTurnQualityViewModel = (snapshot, options = {}) => {
3460
+ const turns = (snapshot.report?.turns ?? []).map((turn) => ({
3461
+ ...turn,
3462
+ detail: getTurnDetail(turn),
3463
+ label: turn.text || "Empty turn",
3464
+ rows: [
3465
+ { label: "Source", value: turn.source ?? "unknown" },
3466
+ { label: "Confidence", value: formatConfidence(turn.averageConfidence) },
3467
+ { label: "Fallback", value: turn.fallbackUsed ? "Yes" : "No" },
3468
+ { label: "Correction", value: turn.correctionChanged ? "Changed" : "None" },
3469
+ { label: "Transcripts", value: `${turn.selectedTranscriptCount} selected` },
3470
+ { label: "Cost", value: formatMaybe(turn.costUnits) }
3471
+ ]
3472
+ }));
3473
+ const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
3474
+ const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
3475
+ return {
3476
+ description: options.description ?? DEFAULT_DESCRIPTION10,
3477
+ error: snapshot.error,
3478
+ isLoading: snapshot.isLoading,
3479
+ label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} failed` : warningCount > 0 ? `${warningCount} warnings` : `${turns.length} healthy` : snapshot.isLoading ? "Checking" : "No turns",
3480
+ status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
3481
+ title: options.title ?? DEFAULT_TITLE10,
3482
+ turns,
3483
+ updatedAt: snapshot.updatedAt
3484
+ };
3485
+ };
3486
+ var renderVoiceTurnQualityHTML = (snapshot, options = {}) => {
3487
+ const model = createVoiceTurnQualityViewModel(snapshot, options);
3488
+ 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--${escapeHtml11(turn.status)}">
3489
+ <header>
3490
+ <strong>${escapeHtml11(turn.label)}</strong>
3491
+ <span>${escapeHtml11(turn.status)}</span>
3492
+ </header>
3493
+ <p>${escapeHtml11(turn.detail)}</p>
3494
+ <dl>${turn.rows.map((row) => `<div>
3495
+ <dt>${escapeHtml11(row.label)}</dt>
3496
+ <dd>${escapeHtml11(row.value)}</dd>
3497
+ </div>`).join("")}</dl>
3498
+ </article>`).join("")}</div>` : '<p class="absolute-voice-turn-quality__empty">Complete a voice turn to see STT quality diagnostics.</p>';
3499
+ return `<section class="absolute-voice-turn-quality absolute-voice-turn-quality--${escapeHtml11(model.status)}">
3500
+ <header class="absolute-voice-turn-quality__header">
3501
+ <span class="absolute-voice-turn-quality__eyebrow">${escapeHtml11(model.title)}</span>
3502
+ <strong class="absolute-voice-turn-quality__label">${escapeHtml11(model.label)}</strong>
3503
+ </header>
3504
+ <p class="absolute-voice-turn-quality__description">${escapeHtml11(model.description)}</p>
3505
+ ${turns}
3506
+ ${model.error ? `<p class="absolute-voice-turn-quality__error">${escapeHtml11(model.error)}</p>` : ""}
3507
+ </section>`;
3508
+ };
3509
+ 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}`;
3510
+ var mountVoiceTurnQuality = (element, path = "/api/turn-quality", options = {}) => {
3511
+ const store = createVoiceTurnQualityStore(path, options);
3512
+ const render = () => {
3513
+ element.innerHTML = renderVoiceTurnQualityHTML(store.getSnapshot(), options);
3514
+ };
3515
+ const unsubscribe = store.subscribe(render);
3516
+ render();
3517
+ store.refresh().catch(() => {});
3518
+ return {
3519
+ close: () => {
3520
+ unsubscribe();
3521
+ store.close();
3522
+ },
3523
+ refresh: store.refresh
3524
+ };
3525
+ };
3526
+ var defineVoiceTurnQualityElement = (tagName = "absolute-voice-turn-quality") => {
3527
+ if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
3528
+ return;
3529
+ }
3530
+ customElements.define(tagName, class AbsoluteVoiceTurnQualityElement extends HTMLElement {
3531
+ mounted;
3532
+ connectedCallback() {
3533
+ const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
3534
+ this.mounted = mountVoiceTurnQuality(this, this.getAttribute("path") ?? "/api/turn-quality", {
3535
+ description: this.getAttribute("description") ?? undefined,
3536
+ intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
3537
+ title: this.getAttribute("title") ?? undefined
3538
+ });
3539
+ }
3540
+ disconnectedCallback() {
3541
+ this.mounted?.close();
3542
+ this.mounted = undefined;
3543
+ }
3544
+ });
3545
+ };
3546
+
3547
+ // src/vue/useVoiceTurnQuality.ts
3548
+ import { onUnmounted as onUnmounted12, shallowRef as shallowRef11 } from "vue";
3549
+ function useVoiceTurnQuality(path = "/api/turn-quality", options = {}) {
3550
+ const store = createVoiceTurnQualityStore(path, options);
3551
+ const error = shallowRef11(null);
3552
+ const isLoading = shallowRef11(false);
3553
+ const report = shallowRef11();
3554
+ const updatedAt = shallowRef11(undefined);
3555
+ const sync = () => {
3556
+ const snapshot = store.getSnapshot();
3557
+ error.value = snapshot.error;
3558
+ isLoading.value = snapshot.isLoading;
3559
+ report.value = snapshot.report;
3560
+ updatedAt.value = snapshot.updatedAt;
3561
+ };
3562
+ const unsubscribe = store.subscribe(sync);
3563
+ sync();
3564
+ store.refresh().catch(() => {});
3565
+ onUnmounted12(() => {
3566
+ unsubscribe();
3567
+ store.close();
3568
+ });
3569
+ return { error, isLoading, refresh: store.refresh, report, updatedAt };
3570
+ }
3571
+
3572
+ // src/vue/VoiceTurnQuality.ts
3573
+ var VoiceTurnQuality = defineComponent11({
3574
+ name: "VoiceTurnQuality",
3575
+ props: {
3576
+ class: { default: "", type: String },
3577
+ description: { default: undefined, type: String },
3578
+ intervalMs: { default: 5000, type: Number },
3579
+ path: { default: "/api/turn-quality", type: String },
3580
+ title: { default: undefined, type: String }
3581
+ },
3582
+ setup(props) {
3583
+ const options = {
3584
+ description: props.description,
3585
+ intervalMs: props.intervalMs,
3586
+ title: props.title
3587
+ };
3588
+ const quality = useVoiceTurnQuality(props.path, options);
3589
+ const model = computed6(() => createVoiceTurnQualityViewModel({
3590
+ error: quality.error.value,
3591
+ isLoading: quality.isLoading.value,
3592
+ report: quality.report.value,
3593
+ updatedAt: quality.updatedAt.value
3594
+ }, options));
3595
+ return () => h11("section", {
3596
+ class: [
3597
+ "absolute-voice-turn-quality",
3598
+ `absolute-voice-turn-quality--${model.value.status}`,
3599
+ props.class
3600
+ ]
3601
+ }, [
3602
+ h11("header", { class: "absolute-voice-turn-quality__header" }, [
3603
+ h11("span", { class: "absolute-voice-turn-quality__eyebrow" }, model.value.title),
3604
+ h11("strong", { class: "absolute-voice-turn-quality__label" }, model.value.label)
3605
+ ]),
3606
+ h11("p", { class: "absolute-voice-turn-quality__description" }, model.value.description),
3607
+ model.value.turns.length ? h11("div", { class: "absolute-voice-turn-quality__turns" }, model.value.turns.map((turn) => h11("article", {
3608
+ class: [
3609
+ "absolute-voice-turn-quality__turn",
3610
+ `absolute-voice-turn-quality__turn--${turn.status}`
3611
+ ],
3612
+ key: `${turn.sessionId}:${turn.turnId}`
3613
+ }, [
3614
+ h11("header", [
3615
+ h11("strong", turn.label),
3616
+ h11("span", turn.status)
3617
+ ]),
3618
+ h11("p", turn.detail),
3619
+ h11("dl", turn.rows.map((row) => h11("div", { key: row.label }, [
3620
+ h11("dt", row.label),
3621
+ h11("dd", row.value)
3622
+ ])))
3623
+ ]))) : h11("p", { class: "absolute-voice-turn-quality__empty" }, "Complete a voice turn to see STT quality diagnostics."),
3624
+ model.value.error ? h11("p", { class: "absolute-voice-turn-quality__error" }, model.value.error) : null
3625
+ ]);
3626
+ }
3627
+ });
3628
+ // src/vue/useVoiceLiveOps.ts
3629
+ import { onUnmounted as onUnmounted13, ref as ref9, shallowRef as shallowRef12 } from "vue";
3630
+
3631
+ // src/client/liveOps.ts
3632
+ var postVoiceLiveOpsAction = async (input, options = {}) => {
3633
+ if (!input.sessionId) {
3634
+ throw new Error("Start a voice session before running live ops actions.");
3635
+ }
3636
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3637
+ const response = await fetchImpl(options.actionPath ?? "/api/voice/live-ops/action", {
3638
+ body: JSON.stringify(input),
3639
+ headers: {
3640
+ "Content-Type": "application/json"
3641
+ },
3642
+ method: "POST"
3643
+ });
3644
+ const payload = await response.json().catch(() => null);
3645
+ if (!response.ok || !payload?.ok) {
3646
+ const message = payload && typeof payload === "object" && "error" in payload ? String(payload.error) : `Voice live ops action failed: HTTP ${response.status}`;
3647
+ throw new Error(message);
3648
+ }
3649
+ return payload;
3650
+ };
3651
+ var createVoiceLiveOpsStore = (options = {}) => {
3652
+ const listeners = new Set;
3653
+ let closed = false;
3654
+ let snapshot = {
3655
+ error: null,
3656
+ isRunning: false
3657
+ };
3658
+ const emit = () => {
3659
+ for (const listener of listeners) {
3660
+ listener();
3661
+ }
3662
+ };
3663
+ const run = async (input) => {
3664
+ if (closed) {
3665
+ return snapshot.lastResult;
3666
+ }
3667
+ snapshot = {
3668
+ ...snapshot,
3669
+ error: null,
3670
+ isRunning: true,
3671
+ runningAction: input.action
3672
+ };
3673
+ emit();
3674
+ try {
3675
+ const result = await postVoiceLiveOpsAction(input, options);
3676
+ await options.onControl?.(result);
3677
+ snapshot = {
3678
+ ...snapshot,
3679
+ error: null,
3680
+ isRunning: false,
3681
+ lastResult: result,
3682
+ runningAction: undefined,
3683
+ updatedAt: Date.now()
3684
+ };
3685
+ emit();
3686
+ return result;
3687
+ } catch (error) {
3688
+ snapshot = {
3689
+ ...snapshot,
3690
+ error: error instanceof Error ? error.message : String(error),
3691
+ isRunning: false,
3692
+ runningAction: undefined,
3693
+ updatedAt: Date.now()
3694
+ };
3695
+ emit();
3696
+ throw error;
3697
+ }
3698
+ };
3699
+ const close = () => {
3700
+ closed = true;
3701
+ listeners.clear();
3702
+ };
3703
+ return {
3704
+ close,
3705
+ getServerSnapshot: () => snapshot,
3706
+ getSnapshot: () => snapshot,
3707
+ run,
3708
+ subscribe: (listener) => {
3709
+ listeners.add(listener);
3710
+ return () => {
3711
+ listeners.delete(listener);
3712
+ };
3713
+ }
3714
+ };
3715
+ };
3716
+
3717
+ // src/vue/useVoiceLiveOps.ts
3718
+ function useVoiceLiveOps(options = {}) {
3719
+ const store = createVoiceLiveOpsStore(options);
3720
+ const error = ref9(null);
3721
+ const isRunning = ref9(false);
3722
+ const lastResult = shallowRef12(undefined);
3723
+ const runningAction = ref9(undefined);
3724
+ const updatedAt = ref9(undefined);
3725
+ const sync = () => {
3726
+ const snapshot = store.getSnapshot();
3727
+ error.value = snapshot.error;
3728
+ isRunning.value = snapshot.isRunning;
3729
+ lastResult.value = snapshot.lastResult;
3730
+ runningAction.value = snapshot.runningAction;
3731
+ updatedAt.value = snapshot.updatedAt;
3732
+ };
3733
+ const unsubscribe = store.subscribe(sync);
3734
+ sync();
3735
+ onUnmounted13(() => {
3736
+ unsubscribe();
3737
+ store.close();
3738
+ });
3739
+ return {
3740
+ error,
3741
+ isRunning,
3742
+ lastResult,
3743
+ run: store.run,
3744
+ runningAction,
3745
+ updatedAt
3746
+ };
3747
+ }
3748
+ // src/vue/useVoiceCampaignDialerProof.ts
3749
+ import { onUnmounted as onUnmounted14, shallowRef as shallowRef13 } from "vue";
3750
+
3751
+ // src/client/campaignDialerProof.ts
3752
+ var fetchVoiceCampaignDialerProofStatus = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
3753
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3754
+ const response = await fetchImpl(path);
3755
+ if (!response.ok) {
3756
+ throw new Error(`Voice campaign dialer proof status failed: HTTP ${response.status}`);
3757
+ }
3758
+ return await response.json();
3759
+ };
3760
+ var runVoiceCampaignDialerProofAction = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
3761
+ const fetchImpl = options.fetch ?? globalThis.fetch;
3762
+ const response = await fetchImpl(path, { method: "POST" });
3763
+ if (!response.ok) {
3764
+ throw new Error(`Voice campaign dialer proof failed: HTTP ${response.status}`);
3765
+ }
3766
+ return await response.json();
3767
+ };
3768
+ var createVoiceCampaignDialerProofStore = (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
3769
+ const listeners = new Set;
3770
+ let closed = false;
3771
+ let timer;
3772
+ let snapshot = {
3773
+ error: null,
3774
+ isLoading: false
3775
+ };
3776
+ const emit = () => {
3777
+ for (const listener of listeners) {
3778
+ listener();
3779
+ }
3780
+ };
3781
+ const refresh = async () => {
3782
+ if (closed) {
3783
+ return snapshot.status;
3784
+ }
3785
+ snapshot = { ...snapshot, error: null, isLoading: true };
3786
+ emit();
3787
+ try {
3788
+ const status = await fetchVoiceCampaignDialerProofStatus(path, options);
3789
+ snapshot = {
3790
+ ...snapshot,
3791
+ error: null,
3792
+ isLoading: false,
3793
+ status,
3794
+ updatedAt: Date.now()
3795
+ };
3796
+ emit();
3797
+ return status;
3798
+ } catch (error) {
3799
+ snapshot = {
3800
+ ...snapshot,
3801
+ error: error instanceof Error ? error.message : String(error),
3802
+ isLoading: false
3803
+ };
3804
+ emit();
3805
+ throw error;
3806
+ }
3807
+ };
3808
+ const runProof = async () => {
3809
+ const runPath = options.runPath ?? snapshot.status?.runPath ?? path;
3810
+ snapshot = { ...snapshot, error: null, isLoading: true };
3811
+ emit();
3812
+ try {
3813
+ const report = await runVoiceCampaignDialerProofAction(runPath, options);
3814
+ snapshot = {
3815
+ ...snapshot,
3816
+ error: null,
3817
+ isLoading: false,
3818
+ report,
3819
+ status: {
3820
+ generatedAt: Date.now(),
3821
+ mode: report.mode,
3822
+ ok: report.ok,
3823
+ providers: report.providers.map((provider) => provider.provider),
3824
+ runPath,
3825
+ safe: true
3826
+ },
3827
+ updatedAt: Date.now()
3828
+ };
3829
+ emit();
3830
+ return report;
3831
+ } catch (error) {
3832
+ snapshot = {
3833
+ ...snapshot,
3834
+ error: error instanceof Error ? error.message : String(error),
3835
+ isLoading: false
3836
+ };
3837
+ emit();
3838
+ throw error;
3839
+ }
3840
+ };
3841
+ const close = () => {
3842
+ closed = true;
3843
+ if (timer) {
3844
+ clearInterval(timer);
3845
+ timer = undefined;
3846
+ }
3847
+ listeners.clear();
3848
+ };
3849
+ if (options.intervalMs && options.intervalMs > 0) {
3850
+ timer = setInterval(() => {
3851
+ refresh().catch(() => {});
3852
+ }, options.intervalMs);
3853
+ }
3854
+ return {
3855
+ close,
3856
+ getServerSnapshot: () => snapshot,
3857
+ getSnapshot: () => snapshot,
3858
+ refresh,
3859
+ runProof,
3860
+ subscribe: (listener) => {
3861
+ listeners.add(listener);
3862
+ return () => {
3863
+ listeners.delete(listener);
3864
+ };
3865
+ }
3866
+ };
3867
+ };
3868
+
3869
+ // src/vue/useVoiceCampaignDialerProof.ts
3870
+ function useVoiceCampaignDialerProof(path = "/api/voice/campaigns/dialer-proof", options = {}) {
3871
+ const store = createVoiceCampaignDialerProofStore(path, options);
3872
+ const error = shallowRef13(null);
3873
+ const isLoading = shallowRef13(false);
3874
+ const report = shallowRef13();
3875
+ const status = shallowRef13();
3876
+ const updatedAt = shallowRef13(undefined);
3877
+ const sync = () => {
3878
+ const snapshot = store.getSnapshot();
3879
+ error.value = snapshot.error;
3880
+ isLoading.value = snapshot.isLoading;
3881
+ report.value = snapshot.report;
3882
+ status.value = snapshot.status;
3883
+ updatedAt.value = snapshot.updatedAt;
3884
+ };
3885
+ const unsubscribe = store.subscribe(sync);
3886
+ sync();
3887
+ if (typeof window !== "undefined") {
3888
+ store.refresh().catch(() => {});
3889
+ }
3890
+ onUnmounted14(() => {
3891
+ unsubscribe();
3892
+ store.close();
3893
+ });
3894
+ return {
3895
+ error,
3896
+ isLoading,
3897
+ refresh: store.refresh,
3898
+ report,
3899
+ runProof: store.runProof,
3900
+ status,
3901
+ updatedAt
3902
+ };
3903
+ }
72
3904
  // src/vue/useVoiceStream.ts
73
- import { onUnmounted, ref, shallowRef } from "vue";
3905
+ import { onUnmounted as onUnmounted15, ref as ref10, shallowRef as shallowRef14 } from "vue";
74
3906
 
75
3907
  // src/client/actions.ts
76
3908
  var normalizeErrorMessage = (value) => {
@@ -120,6 +3952,17 @@ var serverMessageToAction = (message) => {
120
3952
  sessionId: message.sessionId,
121
3953
  type: "complete"
122
3954
  };
3955
+ case "connection":
3956
+ return {
3957
+ reconnect: message.reconnect,
3958
+ type: "connection"
3959
+ };
3960
+ case "call_lifecycle":
3961
+ return {
3962
+ event: message.event,
3963
+ sessionId: message.sessionId,
3964
+ type: "call_lifecycle"
3965
+ };
123
3966
  case "error":
124
3967
  return {
125
3968
  message: normalizeErrorMessage(message.message),
@@ -135,6 +3978,17 @@ var serverMessageToAction = (message) => {
135
3978
  transcript: message.transcript,
136
3979
  type: "partial"
137
3980
  };
3981
+ case "replay":
3982
+ return {
3983
+ assistantTexts: message.assistantTexts,
3984
+ call: message.call,
3985
+ partial: message.partial,
3986
+ scenarioId: message.scenarioId,
3987
+ sessionId: message.sessionId,
3988
+ status: message.status,
3989
+ turns: message.turns,
3990
+ type: "replay"
3991
+ };
138
3992
  case "session":
139
3993
  return {
140
3994
  sessionId: message.sessionId,
@@ -163,7 +4017,7 @@ var DEFAULT_SCENARIO_QUERY_PARAM = "scenarioId";
163
4017
  var noop = () => {};
164
4018
  var noopUnsubscribe = () => noop;
165
4019
  var NOOP_CONNECTION = {
166
- start: () => {},
4020
+ callControl: noop,
167
4021
  close: noop,
168
4022
  endTurn: noop,
169
4023
  getReadyState: () => WS_CLOSED,
@@ -171,6 +4025,7 @@ var NOOP_CONNECTION = {
171
4025
  getSessionId: () => "",
172
4026
  send: noop,
173
4027
  sendAudio: noop,
4028
+ start: () => {},
174
4029
  subscribe: noopUnsubscribe
175
4030
  };
176
4031
  var createSessionId = () => crypto.randomUUID();
@@ -192,11 +4047,14 @@ var isVoiceServerMessage = (value) => {
192
4047
  switch (value.type) {
193
4048
  case "audio":
194
4049
  case "assistant":
4050
+ case "call_lifecycle":
195
4051
  case "complete":
4052
+ case "connection":
196
4053
  case "error":
197
4054
  case "final":
198
4055
  case "partial":
199
4056
  case "pong":
4057
+ case "replay":
200
4058
  case "session":
201
4059
  case "turn":
202
4060
  return true;
@@ -233,6 +4091,9 @@ var createVoiceConnection = (path, options = {}) => {
233
4091
  sessionId: options.sessionId ?? createSessionId(),
234
4092
  ws: null
235
4093
  };
4094
+ const emitConnection = (reconnect) => {
4095
+ listeners.forEach((listener) => listener(reconnect));
4096
+ };
236
4097
  const clearTimers = () => {
237
4098
  if (state.pingInterval) {
238
4099
  clearInterval(state.pingInterval);
@@ -255,9 +4116,28 @@ var createVoiceConnection = (path, options = {}) => {
255
4116
  }
256
4117
  };
257
4118
  const scheduleReconnect = () => {
4119
+ const nextAttemptAt = Date.now() + RECONNECT_DELAY_MS;
258
4120
  state.reconnectAttempts += 1;
4121
+ emitConnection({
4122
+ reconnect: {
4123
+ attempts: state.reconnectAttempts,
4124
+ lastDisconnectAt: Date.now(),
4125
+ maxAttempts: maxReconnectAttempts,
4126
+ nextAttemptAt,
4127
+ status: "reconnecting"
4128
+ },
4129
+ type: "connection"
4130
+ });
259
4131
  state.reconnectTimeout = setTimeout(() => {
260
4132
  if (state.reconnectAttempts > maxReconnectAttempts) {
4133
+ emitConnection({
4134
+ reconnect: {
4135
+ attempts: state.reconnectAttempts,
4136
+ maxAttempts: maxReconnectAttempts,
4137
+ status: "exhausted"
4138
+ },
4139
+ type: "connection"
4140
+ });
261
4141
  return;
262
4142
  }
263
4143
  connect();
@@ -267,9 +4147,21 @@ var createVoiceConnection = (path, options = {}) => {
267
4147
  const ws = new WebSocket(buildWsUrl(path, state.sessionId, state.scenarioId));
268
4148
  ws.binaryType = "arraybuffer";
269
4149
  ws.onopen = () => {
4150
+ const wasReconnecting = state.reconnectAttempts > 0;
270
4151
  state.isConnected = true;
271
- state.reconnectAttempts = 0;
272
4152
  flushPendingMessages();
4153
+ if (wasReconnecting) {
4154
+ emitConnection({
4155
+ reconnect: {
4156
+ attempts: state.reconnectAttempts,
4157
+ lastResumedAt: Date.now(),
4158
+ maxAttempts: maxReconnectAttempts,
4159
+ status: "resumed"
4160
+ },
4161
+ type: "connection"
4162
+ });
4163
+ state.reconnectAttempts = 0;
4164
+ }
273
4165
  listeners.forEach((listener) => listener({
274
4166
  scenarioId: state.scenarioId ?? undefined,
275
4167
  sessionId: state.sessionId,
@@ -299,6 +4191,16 @@ var createVoiceConnection = (path, options = {}) => {
299
4191
  const reconnectable = shouldReconnect && event.code !== WS_NORMAL_CLOSURE && state.reconnectAttempts < maxReconnectAttempts;
300
4192
  if (reconnectable) {
301
4193
  scheduleReconnect();
4194
+ } else if (shouldReconnect && event.code !== WS_NORMAL_CLOSURE) {
4195
+ emitConnection({
4196
+ reconnect: {
4197
+ attempts: state.reconnectAttempts,
4198
+ lastDisconnectAt: Date.now(),
4199
+ maxAttempts: maxReconnectAttempts,
4200
+ status: "exhausted"
4201
+ },
4202
+ type: "connection"
4203
+ });
302
4204
  }
303
4205
  };
304
4206
  state.ws = ws;
@@ -332,6 +4234,12 @@ var createVoiceConnection = (path, options = {}) => {
332
4234
  const endTurn = () => {
333
4235
  send({ type: "end_turn" });
334
4236
  };
4237
+ const callControl = (message) => {
4238
+ send({
4239
+ ...message,
4240
+ type: "call_control"
4241
+ });
4242
+ };
335
4243
  const close = () => {
336
4244
  clearTimers();
337
4245
  if (state.ws) {
@@ -349,7 +4257,7 @@ var createVoiceConnection = (path, options = {}) => {
349
4257
  };
350
4258
  connect();
351
4259
  return {
352
- start,
4260
+ callControl,
353
4261
  close,
354
4262
  endTurn,
355
4263
  getReadyState: () => state.ws?.readyState ?? WS_CLOSED,
@@ -357,18 +4265,26 @@ var createVoiceConnection = (path, options = {}) => {
357
4265
  getSessionId: () => state.sessionId,
358
4266
  send,
359
4267
  sendAudio,
4268
+ start,
360
4269
  subscribe
361
4270
  };
362
4271
  };
363
4272
 
364
4273
  // src/client/store.ts
4274
+ var createInitialReconnectState = () => ({
4275
+ attempts: 0,
4276
+ maxAttempts: 0,
4277
+ status: "idle"
4278
+ });
365
4279
  var createInitialState = () => ({
366
4280
  assistantAudio: [],
367
4281
  assistantTexts: [],
4282
+ call: null,
368
4283
  error: null,
369
4284
  isConnected: false,
370
4285
  scenarioId: null,
371
4286
  partial: "",
4287
+ reconnect: createInitialReconnectState(),
372
4288
  sessionId: null,
373
4289
  status: "idle",
374
4290
  turns: []
@@ -408,10 +4324,36 @@ var createVoiceStreamStore = () => {
408
4324
  status: "completed"
409
4325
  };
410
4326
  break;
4327
+ case "call_lifecycle":
4328
+ state = {
4329
+ ...state,
4330
+ call: {
4331
+ ...state.call,
4332
+ disposition: action.event.type === "end" ? action.event.disposition : state.call?.disposition,
4333
+ endedAt: action.event.type === "end" ? action.event.at : state.call?.endedAt,
4334
+ events: [...state.call?.events ?? [], action.event],
4335
+ lastEventAt: action.event.at,
4336
+ startedAt: state.call?.startedAt ?? action.event.at
4337
+ },
4338
+ sessionId: action.sessionId
4339
+ };
4340
+ break;
411
4341
  case "connected":
412
4342
  state = {
413
4343
  ...state,
414
- isConnected: true
4344
+ isConnected: true,
4345
+ reconnect: state.reconnect.status === "reconnecting" ? {
4346
+ ...state.reconnect,
4347
+ lastResumedAt: Date.now(),
4348
+ nextAttemptAt: undefined,
4349
+ status: "resumed"
4350
+ } : state.reconnect
4351
+ };
4352
+ break;
4353
+ case "connection":
4354
+ state = {
4355
+ ...state,
4356
+ reconnect: action.reconnect
415
4357
  };
416
4358
  break;
417
4359
  case "disconnected":
@@ -439,6 +4381,26 @@ var createVoiceStreamStore = () => {
439
4381
  partial: action.transcript.text
440
4382
  };
441
4383
  break;
4384
+ case "replay":
4385
+ state = {
4386
+ ...state,
4387
+ assistantTexts: [...action.assistantTexts],
4388
+ call: action.call ?? null,
4389
+ error: null,
4390
+ isConnected: action.status === "active",
4391
+ partial: action.partial,
4392
+ reconnect: state.reconnect.status === "reconnecting" ? {
4393
+ ...state.reconnect,
4394
+ lastResumedAt: Date.now(),
4395
+ nextAttemptAt: undefined,
4396
+ status: "resumed"
4397
+ } : state.reconnect,
4398
+ scenarioId: action.scenarioId ?? state.scenarioId,
4399
+ sessionId: action.sessionId,
4400
+ status: action.status,
4401
+ turns: [...action.turns]
4402
+ };
4403
+ break;
442
4404
  case "session":
443
4405
  state = {
444
4406
  ...state,
@@ -486,14 +4448,41 @@ var createVoiceStream = (path, options = {}) => {
486
4448
  const notify = () => {
487
4449
  subscribers.forEach((subscriber) => subscriber());
488
4450
  };
4451
+ const reportReconnect = () => {
4452
+ if (!options.reconnectReportPath || typeof fetch === "undefined") {
4453
+ return;
4454
+ }
4455
+ const snapshot = store.getSnapshot();
4456
+ const body = JSON.stringify({
4457
+ at: Date.now(),
4458
+ reconnect: snapshot.reconnect,
4459
+ scenarioId: snapshot.scenarioId,
4460
+ sessionId: connection.getSessionId(),
4461
+ turnIds: snapshot.turns.map((turn) => turn.id)
4462
+ });
4463
+ fetch(options.reconnectReportPath, {
4464
+ body,
4465
+ headers: {
4466
+ "Content-Type": "application/json"
4467
+ },
4468
+ keepalive: true,
4469
+ method: "POST"
4470
+ }).catch(() => {});
4471
+ };
489
4472
  const unsubscribeConnection = connection.subscribe((message) => {
490
4473
  const action = serverMessageToAction(message);
491
4474
  if (action) {
492
4475
  store.dispatch(action);
4476
+ if (message.type === "connection") {
4477
+ reportReconnect();
4478
+ }
493
4479
  notify();
494
4480
  }
495
4481
  });
496
4482
  return {
4483
+ callControl(message) {
4484
+ connection.callControl(message);
4485
+ },
497
4486
  close() {
498
4487
  unsubscribeConnection();
499
4488
  connection.close();
@@ -522,6 +4511,9 @@ var createVoiceStream = (path, options = {}) => {
522
4511
  get partial() {
523
4512
  return store.getSnapshot().partial;
524
4513
  },
4514
+ get reconnect() {
4515
+ return store.getSnapshot().reconnect;
4516
+ },
525
4517
  get sessionId() {
526
4518
  return connection.getSessionId();
527
4519
  },
@@ -537,6 +4529,9 @@ var createVoiceStream = (path, options = {}) => {
537
4529
  get assistantAudio() {
538
4530
  return store.getSnapshot().assistantAudio;
539
4531
  },
4532
+ get call() {
4533
+ return store.getSnapshot().call;
4534
+ },
540
4535
  sendAudio(audio) {
541
4536
  connection.sendAudio(audio);
542
4537
  },
@@ -550,22 +4545,26 @@ var createVoiceStream = (path, options = {}) => {
550
4545
  };
551
4546
 
552
4547
  // src/vue/useVoiceStream.ts
553
- var useVoiceStream = (path, options = {}) => {
4548
+ function useVoiceStream(path, options = {}) {
554
4549
  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([]);
4550
+ const assistantAudio = shallowRef14([]);
4551
+ const assistantTexts = shallowRef14([]);
4552
+ const call = shallowRef14(null);
4553
+ const error = ref10(null);
4554
+ const isConnected = ref10(false);
4555
+ const partial = ref10("");
4556
+ const reconnect = shallowRef14(stream.reconnect);
4557
+ const sessionId = ref10(stream.sessionId);
4558
+ const status = ref10(stream.status);
4559
+ const turns = shallowRef14([]);
563
4560
  const sync = () => {
564
4561
  assistantAudio.value = [...stream.assistantAudio];
565
4562
  assistantTexts.value = [...stream.assistantTexts];
4563
+ call.value = stream.call;
566
4564
  error.value = stream.error;
567
4565
  isConnected.value = stream.isConnected;
568
4566
  partial.value = stream.partial;
4567
+ reconnect.value = stream.reconnect;
569
4568
  sessionId.value = stream.sessionId;
570
4569
  status.value = stream.status;
571
4570
  turns.value = [...stream.turns];
@@ -576,23 +4575,26 @@ var useVoiceStream = (path, options = {}) => {
576
4575
  unsubscribe();
577
4576
  stream.close();
578
4577
  };
579
- onUnmounted(destroy);
4578
+ onUnmounted15(destroy);
580
4579
  return {
581
4580
  assistantAudio,
582
4581
  assistantTexts,
4582
+ call,
4583
+ callControl: (message) => stream.callControl(message),
583
4584
  close: () => destroy(),
584
4585
  endTurn: () => stream.endTurn(),
585
4586
  error,
586
4587
  isConnected,
587
4588
  partial,
4589
+ reconnect,
588
4590
  sendAudio: (audio) => stream.sendAudio(audio),
589
4591
  sessionId,
590
4592
  status,
591
4593
  turns
592
4594
  };
593
- };
4595
+ }
594
4596
  // src/vue/useVoiceController.ts
595
- import { onUnmounted as onUnmounted2, ref as ref2, shallowRef as shallowRef2 } from "vue";
4597
+ import { onUnmounted as onUnmounted16, ref as ref11, shallowRef as shallowRef15 } from "vue";
596
4598
 
597
4599
  // src/client/htmx.ts
598
4600
  var DEFAULT_EVENT_NAME = "voice-refresh";
@@ -1056,10 +5058,12 @@ var resolveVoiceRuntimePreset = (name = "default") => {
1056
5058
  var createInitialState2 = (stream) => ({
1057
5059
  assistantAudio: [...stream.assistantAudio],
1058
5060
  assistantTexts: [...stream.assistantTexts],
5061
+ call: stream.call,
1059
5062
  error: stream.error,
1060
5063
  isConnected: stream.isConnected,
1061
5064
  isRecording: false,
1062
5065
  partial: stream.partial,
5066
+ reconnect: stream.reconnect,
1063
5067
  recordingError: null,
1064
5068
  sessionId: stream.sessionId,
1065
5069
  scenarioId: stream.scenarioId,
@@ -1085,9 +5089,11 @@ var createVoiceController = (path, options = {}) => {
1085
5089
  ...state,
1086
5090
  assistantAudio: [...stream.assistantAudio],
1087
5091
  assistantTexts: [...stream.assistantTexts],
5092
+ call: stream.call,
1088
5093
  error: stream.error,
1089
5094
  isConnected: stream.isConnected,
1090
5095
  partial: stream.partial,
5096
+ reconnect: stream.reconnect,
1091
5097
  sessionId: stream.sessionId,
1092
5098
  scenarioId: stream.scenarioId,
1093
5099
  status: stream.status,
@@ -1112,7 +5118,13 @@ var createVoiceController = (path, options = {}) => {
1112
5118
  capture = createMicrophoneCapture({
1113
5119
  channelCount: options.capture?.channelCount ?? preset.capture.channelCount,
1114
5120
  onLevel: options.capture?.onLevel,
1115
- onAudio: (audio) => stream.sendAudio(audio),
5121
+ onAudio: (audio) => {
5122
+ if (options.capture?.onAudio) {
5123
+ options.capture.onAudio(audio, stream.sendAudio);
5124
+ return;
5125
+ }
5126
+ stream.sendAudio(audio);
5127
+ },
1116
5128
  sampleRateHz: options.capture?.sampleRateHz ?? preset.capture.sampleRateHz
1117
5129
  });
1118
5130
  return capture;
@@ -1162,6 +5174,7 @@ var createVoiceController = (path, options = {}) => {
1162
5174
  bindHTMX(bindingOptions) {
1163
5175
  return bindVoiceHTMX(stream, bindingOptions);
1164
5176
  },
5177
+ callControl: (message) => stream.callControl(message),
1165
5178
  close,
1166
5179
  endTurn: () => stream.endTurn(),
1167
5180
  get error() {
@@ -1181,6 +5194,9 @@ var createVoiceController = (path, options = {}) => {
1181
5194
  get recordingError() {
1182
5195
  return state.recordingError;
1183
5196
  },
5197
+ get reconnect() {
5198
+ return state.reconnect;
5199
+ },
1184
5200
  sendAudio: (audio) => stream.sendAudio(audio),
1185
5201
  get sessionId() {
1186
5202
  return state.sessionId;
@@ -1214,23 +5230,27 @@ var createVoiceController = (path, options = {}) => {
1214
5230
  },
1215
5231
  get assistantAudio() {
1216
5232
  return state.assistantAudio;
5233
+ },
5234
+ get call() {
5235
+ return state.call;
1217
5236
  }
1218
5237
  };
1219
5238
  };
1220
5239
 
1221
5240
  // src/vue/useVoiceController.ts
1222
- var useVoiceController = (path, options = {}) => {
5241
+ function useVoiceController(path, options = {}) {
1223
5242
  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([]);
5243
+ const assistantAudio = shallowRef15([]);
5244
+ const assistantTexts = shallowRef15([]);
5245
+ const error = ref11(null);
5246
+ const isConnected = ref11(false);
5247
+ const isRecording = ref11(false);
5248
+ const partial = ref11("");
5249
+ const reconnect = shallowRef15(controller.reconnect);
5250
+ const recordingError = ref11(null);
5251
+ const sessionId = ref11(controller.sessionId);
5252
+ const status = ref11(controller.status);
5253
+ const turns = shallowRef15([]);
1234
5254
  const sync = () => {
1235
5255
  assistantAudio.value = [...controller.assistantAudio];
1236
5256
  assistantTexts.value = [...controller.assistantTexts];
@@ -1238,6 +5258,7 @@ var useVoiceController = (path, options = {}) => {
1238
5258
  isConnected.value = controller.isConnected;
1239
5259
  isRecording.value = controller.isRecording;
1240
5260
  partial.value = controller.partial;
5261
+ reconnect.value = controller.reconnect;
1241
5262
  recordingError.value = controller.recordingError;
1242
5263
  sessionId.value = controller.sessionId;
1243
5264
  status.value = controller.status;
@@ -1249,7 +5270,7 @@ var useVoiceController = (path, options = {}) => {
1249
5270
  unsubscribe();
1250
5271
  controller.close();
1251
5272
  };
1252
- onUnmounted2(destroy);
5273
+ onUnmounted16(destroy);
1253
5274
  return {
1254
5275
  assistantAudio,
1255
5276
  assistantTexts,
@@ -1260,6 +5281,7 @@ var useVoiceController = (path, options = {}) => {
1260
5281
  isConnected,
1261
5282
  isRecording,
1262
5283
  partial,
5284
+ reconnect,
1263
5285
  recordingError,
1264
5286
  sendAudio: (audio) => controller.sendAudio(audio),
1265
5287
  sessionId,
@@ -1269,27 +5291,56 @@ var useVoiceController = (path, options = {}) => {
1269
5291
  toggleRecording: () => controller.toggleRecording(),
1270
5292
  turns
1271
5293
  };
1272
- };
1273
- // src/vue/useVoiceProviderStatus.ts
1274
- import { onUnmounted as onUnmounted3, ref as ref3, shallowRef as shallowRef3 } from "vue";
5294
+ }
5295
+ // src/vue/useVoiceTraceTimeline.ts
5296
+ import { onUnmounted as onUnmounted17, ref as ref12, shallowRef as shallowRef16 } from "vue";
5297
+ function useVoiceTraceTimeline(path = "/api/voice-traces", options = {}) {
5298
+ const store = createVoiceTraceTimelineStore(path, options);
5299
+ const error = ref12(null);
5300
+ const isLoading = ref12(false);
5301
+ const report = shallowRef16(null);
5302
+ const updatedAt = ref12(undefined);
5303
+ const sync = () => {
5304
+ const snapshot = store.getSnapshot();
5305
+ error.value = snapshot.error;
5306
+ isLoading.value = snapshot.isLoading;
5307
+ report.value = snapshot.report;
5308
+ updatedAt.value = snapshot.updatedAt;
5309
+ };
5310
+ const unsubscribe = store.subscribe(sync);
5311
+ sync();
5312
+ store.refresh().catch(() => {});
5313
+ onUnmounted17(() => {
5314
+ unsubscribe();
5315
+ store.close();
5316
+ });
5317
+ return {
5318
+ error,
5319
+ isLoading,
5320
+ refresh: store.refresh,
5321
+ report,
5322
+ updatedAt
5323
+ };
5324
+ }
5325
+ // src/vue/useVoiceWorkflowStatus.ts
5326
+ import { onUnmounted as onUnmounted18, ref as ref13, shallowRef as shallowRef17 } from "vue";
1275
5327
 
1276
- // src/client/providerStatus.ts
1277
- var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
5328
+ // src/client/workflowStatus.ts
5329
+ var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
1278
5330
  const fetchImpl = options.fetch ?? globalThis.fetch;
1279
5331
  const response = await fetchImpl(path);
1280
5332
  if (!response.ok) {
1281
- throw new Error(`Voice provider status failed: HTTP ${response.status}`);
5333
+ throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
1282
5334
  }
1283
5335
  return await response.json();
1284
5336
  };
1285
- var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
5337
+ var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
1286
5338
  const listeners = new Set;
1287
5339
  let closed = false;
1288
5340
  let timer;
1289
5341
  let snapshot = {
1290
5342
  error: null,
1291
- isLoading: false,
1292
- providers: []
5343
+ isLoading: false
1293
5344
  };
1294
5345
  const emit = () => {
1295
5346
  for (const listener of listeners) {
@@ -1298,7 +5349,7 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
1298
5349
  };
1299
5350
  const refresh = async () => {
1300
5351
  if (closed) {
1301
- return snapshot.providers;
5352
+ return snapshot.report;
1302
5353
  }
1303
5354
  snapshot = {
1304
5355
  ...snapshot,
@@ -1307,15 +5358,15 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
1307
5358
  };
1308
5359
  emit();
1309
5360
  try {
1310
- const providers = await fetchVoiceProviderStatus(path, options);
5361
+ const report = await fetchVoiceWorkflowStatus(path, options);
1311
5362
  snapshot = {
1312
5363
  error: null,
1313
5364
  isLoading: false,
1314
- providers,
5365
+ report,
1315
5366
  updatedAt: Date.now()
1316
5367
  };
1317
5368
  emit();
1318
- return providers;
5369
+ return report;
1319
5370
  } catch (error) {
1320
5371
  snapshot = {
1321
5372
  ...snapshot,
@@ -1334,7 +5385,7 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
1334
5385
  }
1335
5386
  listeners.clear();
1336
5387
  };
1337
- if (options.intervalMs && options.intervalMs > 0) {
5388
+ if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
1338
5389
  timer = setInterval(() => {
1339
5390
  refresh().catch(() => {});
1340
5391
  }, options.intervalMs);
@@ -1353,37 +5404,65 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
1353
5404
  };
1354
5405
  };
1355
5406
 
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);
5407
+ // src/vue/useVoiceWorkflowStatus.ts
5408
+ function useVoiceWorkflowStatus(path = "/evals/scenarios/json", options = {}) {
5409
+ const store = createVoiceWorkflowStatusStore(path, options);
5410
+ const error = ref13(null);
5411
+ const isLoading = ref13(false);
5412
+ const report = shallowRef17(undefined);
5413
+ const updatedAt = ref13(undefined);
1363
5414
  const sync = () => {
1364
5415
  const snapshot = store.getSnapshot();
1365
5416
  error.value = snapshot.error;
1366
5417
  isLoading.value = snapshot.isLoading;
1367
- providers.value = [...snapshot.providers];
5418
+ report.value = snapshot.report;
1368
5419
  updatedAt.value = snapshot.updatedAt;
1369
5420
  };
1370
5421
  const unsubscribe = store.subscribe(sync);
1371
5422
  sync();
1372
- store.refresh().catch(() => {});
1373
- onUnmounted3(() => {
5423
+ if (typeof window !== "undefined") {
5424
+ store.refresh().catch(() => {});
5425
+ }
5426
+ onUnmounted18(() => {
1374
5427
  unsubscribe();
1375
5428
  store.close();
1376
5429
  });
1377
5430
  return {
1378
5431
  error,
1379
5432
  isLoading,
1380
- providers,
1381
5433
  refresh: store.refresh,
5434
+ report,
1382
5435
  updatedAt
1383
5436
  };
1384
- };
5437
+ }
1385
5438
  export {
5439
+ useVoiceWorkflowStatus,
5440
+ useVoiceTurnQuality,
5441
+ useVoiceTurnLatency,
5442
+ useVoiceTraceTimeline,
1386
5443
  useVoiceStream,
5444
+ useVoiceRoutingStatus,
1387
5445
  useVoiceProviderStatus,
1388
- useVoiceController
5446
+ useVoiceProviderSimulationControls,
5447
+ useVoiceProviderContracts,
5448
+ useVoiceProviderCapabilities,
5449
+ useVoicePlatformCoverage,
5450
+ useVoiceOpsStatus,
5451
+ useVoiceOpsActionCenter,
5452
+ useVoiceLiveOps,
5453
+ useVoiceDeliveryRuntime,
5454
+ useVoiceController,
5455
+ useVoiceCampaignDialerProof,
5456
+ useVoiceAgentSquadStatus,
5457
+ VoiceTurnQuality,
5458
+ VoiceTurnLatency,
5459
+ VoiceRoutingStatus,
5460
+ VoiceProviderStatus,
5461
+ VoiceProviderSimulationControls,
5462
+ VoiceProviderContracts,
5463
+ VoiceProviderCapabilities,
5464
+ VoicePlatformCoverage,
5465
+ VoiceOpsStatus,
5466
+ VoiceOpsActionCenter,
5467
+ VoiceDeliveryRuntime
1389
5468
  };