@absolutejs/voice 0.0.22-beta.9 → 0.0.22-beta.91
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.
- package/README.md +205 -0
- package/dist/agent.d.ts +2 -0
- package/dist/angular/index.d.ts +7 -0
- package/dist/angular/index.js +957 -43
- package/dist/angular/voice-app-kit-status.service.d.ts +12 -0
- package/dist/angular/voice-ops-status.component.d.ts +15 -0
- package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
- package/dist/angular/voice-provider-status.service.d.ts +12 -0
- package/dist/angular/voice-routing-status.service.d.ts +11 -0
- package/dist/angular/voice-stream.service.d.ts +2 -0
- package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
- package/dist/angular/voice-turn-quality.service.d.ts +12 -0
- package/dist/angular/voice-workflow-status.service.d.ts +12 -0
- package/dist/appKit.d.ts +98 -0
- package/dist/assistantHealth.d.ts +81 -0
- package/dist/client/actions.d.ts +22 -0
- package/dist/client/appKitStatus.d.ts +19 -0
- package/dist/client/connection.d.ts +3 -0
- package/dist/client/htmxBootstrap.js +44 -2
- package/dist/client/index.d.ts +30 -0
- package/dist/client/index.js +1463 -2
- package/dist/client/opsStatusWidget.d.ts +40 -0
- package/dist/client/providerCapabilities.d.ts +19 -0
- package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
- package/dist/client/providerSimulationControls.d.ts +33 -0
- package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
- package/dist/client/providerStatus.d.ts +19 -0
- package/dist/client/providerStatusWidget.d.ts +32 -0
- package/dist/client/routingStatus.d.ts +19 -0
- package/dist/client/routingStatusWidget.d.ts +28 -0
- package/dist/client/traceTimeline.d.ts +19 -0
- package/dist/client/traceTimelineWidget.d.ts +32 -0
- package/dist/client/turnQuality.d.ts +19 -0
- package/dist/client/turnQualityWidget.d.ts +32 -0
- package/dist/client/workflowStatus.d.ts +19 -0
- package/dist/diagnosticsRoutes.d.ts +44 -0
- package/dist/evalRoutes.d.ts +213 -0
- package/dist/handoff.d.ts +54 -0
- package/dist/handoffHealth.d.ts +94 -0
- package/dist/index.d.ts +62 -7
- package/dist/index.js +10382 -2574
- package/dist/modelAdapters.d.ts +75 -0
- package/dist/openaiTTS.d.ts +18 -0
- package/dist/opsConsoleRoutes.d.ts +77 -0
- package/dist/opsWebhook.d.ts +126 -0
- package/dist/outcomeContract.d.ts +112 -0
- package/dist/postgresStore.d.ts +2 -0
- package/dist/productionReadiness.d.ts +111 -0
- package/dist/providerAdapters.d.ts +48 -0
- package/dist/providerCapabilities.d.ts +92 -0
- package/dist/providerHealth.d.ts +79 -0
- package/dist/qualityRoutes.d.ts +76 -0
- package/dist/queue.d.ts +61 -0
- package/dist/react/VoiceOpsStatus.d.ts +6 -0
- package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
- package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
- package/dist/react/VoiceProviderStatus.d.ts +6 -0
- package/dist/react/VoiceRoutingStatus.d.ts +6 -0
- package/dist/react/VoiceTraceTimeline.d.ts +6 -0
- package/dist/react/VoiceTurnQuality.d.ts +6 -0
- package/dist/react/index.d.ts +15 -0
- package/dist/react/index.js +2150 -11
- package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
- package/dist/react/useVoiceController.d.ts +2 -0
- package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
- package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
- package/dist/react/useVoiceProviderStatus.d.ts +8 -0
- package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/react/useVoiceStream.d.ts +2 -0
- package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
- package/dist/react/useVoiceTurnQuality.d.ts +8 -0
- package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
- package/dist/resilienceRoutes.d.ts +142 -0
- package/dist/sessionReplay.d.ts +175 -0
- package/dist/sqliteStore.d.ts +2 -0
- package/dist/svelte/createVoiceAppKitStatus.d.ts +8 -0
- package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
- package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
- package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
- package/dist/svelte/createVoiceProviderStatus.d.ts +10 -0
- package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
- package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
- package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
- package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
- package/dist/svelte/index.d.ts +9 -0
- package/dist/svelte/index.js +1508 -3
- package/dist/telephony/contract.d.ts +61 -0
- package/dist/telephony/matrix.d.ts +97 -0
- package/dist/telephony/plivo.d.ts +254 -0
- package/dist/telephony/telnyx.d.ts +247 -0
- package/dist/telephony/twilio.d.ts +132 -0
- package/dist/telephonyOutcome.d.ts +201 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +2543 -14
- package/dist/testing/ioProviderSimulator.d.ts +41 -0
- package/dist/testing/providerSimulator.d.ts +44 -0
- package/dist/toolContract.d.ts +130 -0
- package/dist/toolRuntime.d.ts +50 -0
- package/dist/trace.d.ts +1 -1
- package/dist/traceTimeline.d.ts +93 -0
- package/dist/turnQuality.d.ts +94 -0
- package/dist/types.d.ts +84 -2
- package/dist/vue/VoiceOpsStatus.d.ts +30 -0
- package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
- package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
- package/dist/vue/VoiceProviderStatus.d.ts +51 -0
- package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
- package/dist/vue/VoiceTurnQuality.d.ts +51 -0
- package/dist/vue/index.d.ts +14 -0
- package/dist/vue/index.js +2047 -25
- package/dist/vue/useVoiceAppKitStatus.d.ts +9 -0
- package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
- package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
- package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
- package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/vue/useVoiceStream.d.ts +2 -0
- package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
- package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
- package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
- package/dist/workflowContract.d.ts +91 -0
- package/package.json +1 -1
package/dist/vue/index.js
CHANGED
|
@@ -69,8 +69,1745 @@ 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/
|
|
72
|
+
// src/vue/VoiceOpsStatus.ts
|
|
73
|
+
import { defineComponent, h } from "vue";
|
|
74
|
+
|
|
75
|
+
// src/client/appKitStatus.ts
|
|
76
|
+
var fetchVoiceAppKitStatus = async (path = "/app-kit/status", options = {}) => {
|
|
77
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
78
|
+
const response = await fetchImpl(path);
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
throw new Error(`Voice app kit status failed: HTTP ${response.status}`);
|
|
81
|
+
}
|
|
82
|
+
return await response.json();
|
|
83
|
+
};
|
|
84
|
+
var createVoiceAppKitStatusStore = (path = "/app-kit/status", options = {}) => {
|
|
85
|
+
const listeners = new Set;
|
|
86
|
+
let closed = false;
|
|
87
|
+
let timer;
|
|
88
|
+
let snapshot = {
|
|
89
|
+
error: null,
|
|
90
|
+
isLoading: false
|
|
91
|
+
};
|
|
92
|
+
const emit = () => {
|
|
93
|
+
for (const listener of listeners) {
|
|
94
|
+
listener();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const refresh = async () => {
|
|
98
|
+
if (closed) {
|
|
99
|
+
return snapshot.report;
|
|
100
|
+
}
|
|
101
|
+
snapshot = {
|
|
102
|
+
...snapshot,
|
|
103
|
+
error: null,
|
|
104
|
+
isLoading: true
|
|
105
|
+
};
|
|
106
|
+
emit();
|
|
107
|
+
try {
|
|
108
|
+
const report = await fetchVoiceAppKitStatus(path, options);
|
|
109
|
+
snapshot = {
|
|
110
|
+
error: null,
|
|
111
|
+
isLoading: false,
|
|
112
|
+
report,
|
|
113
|
+
updatedAt: Date.now()
|
|
114
|
+
};
|
|
115
|
+
emit();
|
|
116
|
+
return report;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
snapshot = {
|
|
119
|
+
...snapshot,
|
|
120
|
+
error: error instanceof Error ? error.message : String(error),
|
|
121
|
+
isLoading: false
|
|
122
|
+
};
|
|
123
|
+
emit();
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const close = () => {
|
|
128
|
+
closed = true;
|
|
129
|
+
if (timer) {
|
|
130
|
+
clearInterval(timer);
|
|
131
|
+
timer = undefined;
|
|
132
|
+
}
|
|
133
|
+
listeners.clear();
|
|
134
|
+
};
|
|
135
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
136
|
+
timer = setInterval(() => {
|
|
137
|
+
refresh().catch(() => {});
|
|
138
|
+
}, options.intervalMs);
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
close,
|
|
142
|
+
getServerSnapshot: () => snapshot,
|
|
143
|
+
getSnapshot: () => snapshot,
|
|
144
|
+
refresh,
|
|
145
|
+
subscribe: (listener) => {
|
|
146
|
+
listeners.add(listener);
|
|
147
|
+
return () => {
|
|
148
|
+
listeners.delete(listener);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/client/opsStatusWidget.ts
|
|
155
|
+
var DEFAULT_TITLE = "Voice Ops Status";
|
|
156
|
+
var DEFAULT_DESCRIPTION = "Certified workflow, provider, and handoff readiness from the AbsoluteJS voice app kit.";
|
|
157
|
+
var SURFACE_LABELS = {
|
|
158
|
+
handoffs: "Handoffs",
|
|
159
|
+
providers: "Providers",
|
|
160
|
+
quality: "Quality",
|
|
161
|
+
sessions: "Sessions",
|
|
162
|
+
workflows: "Workflows"
|
|
163
|
+
};
|
|
164
|
+
var escapeHtml = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
165
|
+
var readNumber = (value, key) => value && typeof value === "object" && (key in value) ? Number(value[key] ?? 0) : 0;
|
|
166
|
+
var surfaceDetail = (surface) => {
|
|
167
|
+
const total = readNumber(surface, "total");
|
|
168
|
+
const failed = readNumber(surface, "failed");
|
|
169
|
+
const degraded = readNumber(surface, "degraded");
|
|
170
|
+
const source = surface && typeof surface === "object" && "source" in surface && typeof surface.source === "string" ? ` from ${surface.source}` : "";
|
|
171
|
+
if (degraded > 0) {
|
|
172
|
+
return `${degraded} degraded of ${total}`;
|
|
173
|
+
}
|
|
174
|
+
if (failed > 0) {
|
|
175
|
+
return `${failed} failing of ${total}${source}`;
|
|
176
|
+
}
|
|
177
|
+
return total > 0 ? `${total} passing${source}` : `No failures${source}`;
|
|
178
|
+
};
|
|
179
|
+
var getVoiceOpsStatusLabel = (report, error) => {
|
|
180
|
+
if (error) {
|
|
181
|
+
return "Unavailable";
|
|
182
|
+
}
|
|
183
|
+
if (!report) {
|
|
184
|
+
return "Checking";
|
|
185
|
+
}
|
|
186
|
+
return report.status === "pass" ? "Passing" : "Needs attention";
|
|
187
|
+
};
|
|
188
|
+
var createVoiceOpsStatusViewModel = (snapshot, options = {}) => {
|
|
189
|
+
const report = snapshot.report;
|
|
190
|
+
const surfaces = Object.entries(report?.surfaces ?? {}).map(([id, surface]) => {
|
|
191
|
+
const failed = readNumber(surface, "failed") || readNumber(surface, "degraded");
|
|
192
|
+
const total = readNumber(surface, "total");
|
|
193
|
+
const status = surface && typeof surface === "object" && "status" in surface ? surface.status ?? "pass" : "pass";
|
|
194
|
+
return {
|
|
195
|
+
detail: surfaceDetail(surface),
|
|
196
|
+
failed,
|
|
197
|
+
id,
|
|
198
|
+
label: SURFACE_LABELS[id] ?? id,
|
|
199
|
+
status,
|
|
200
|
+
total
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
return {
|
|
204
|
+
description: options.description ?? DEFAULT_DESCRIPTION,
|
|
205
|
+
error: snapshot.error,
|
|
206
|
+
isLoading: snapshot.isLoading,
|
|
207
|
+
label: getVoiceOpsStatusLabel(report, snapshot.error),
|
|
208
|
+
links: options.includeLinks === false ? [] : report?.links ?? [],
|
|
209
|
+
passed: report?.passed ?? 0,
|
|
210
|
+
status: snapshot.error ? "error" : report ? report.status : snapshot.isLoading ? "loading" : "loading",
|
|
211
|
+
surfaces,
|
|
212
|
+
title: options.title ?? DEFAULT_TITLE,
|
|
213
|
+
total: report?.total ?? 0,
|
|
214
|
+
updatedAt: snapshot.updatedAt
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
var renderVoiceOpsStatusHTML = (snapshot, options = {}) => {
|
|
218
|
+
const model = createVoiceOpsStatusViewModel(snapshot, options);
|
|
219
|
+
const surfaces = model.surfaces.length ? model.surfaces.map((surface) => `<li class="absolute-voice-ops-status__surface absolute-voice-ops-status__surface--${escapeHtml(surface.status)}">
|
|
220
|
+
<span>${escapeHtml(surface.label)}</span>
|
|
221
|
+
<strong>${escapeHtml(surface.detail)}</strong>
|
|
222
|
+
</li>`).join("") : '<li class="absolute-voice-ops-status__surface"><span>Status</span><strong>Waiting for first check</strong></li>';
|
|
223
|
+
const links = model.links.length ? `<nav class="absolute-voice-ops-status__links">${model.links.slice(0, 4).map((link) => `<a href="${escapeHtml(link.href)}">${escapeHtml(link.label)}</a>`).join("")}</nav>` : "";
|
|
224
|
+
return `<section class="absolute-voice-ops-status absolute-voice-ops-status--${escapeHtml(model.status)}">
|
|
225
|
+
<header class="absolute-voice-ops-status__header">
|
|
226
|
+
<span class="absolute-voice-ops-status__eyebrow">${escapeHtml(model.title)}</span>
|
|
227
|
+
<strong class="absolute-voice-ops-status__label">${escapeHtml(model.label)}</strong>
|
|
228
|
+
</header>
|
|
229
|
+
<p class="absolute-voice-ops-status__description">${escapeHtml(model.description)}</p>
|
|
230
|
+
<div class="absolute-voice-ops-status__summary">
|
|
231
|
+
<span>${model.passed} passing</span>
|
|
232
|
+
<span>${Math.max(model.total - model.passed, 0)} failing</span>
|
|
233
|
+
<span>${model.total} checks</span>
|
|
234
|
+
</div>
|
|
235
|
+
<ul class="absolute-voice-ops-status__surfaces">${surfaces}</ul>
|
|
236
|
+
${model.error ? `<p class="absolute-voice-ops-status__error">${escapeHtml(model.error)}</p>` : ""}
|
|
237
|
+
${links}
|
|
238
|
+
</section>`;
|
|
239
|
+
};
|
|
240
|
+
var getVoiceOpsStatusCSS = () => `.absolute-voice-ops-status{border:1px solid #d8d2c4;border-radius:20px;background:#fffaf0;color:#16130d;padding:18px;box-shadow:0 18px 40px rgba(47,37,18,.12);font-family:inherit}.absolute-voice-ops-status--fail,.absolute-voice-ops-status--error{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-ops-status__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-ops-status__eyebrow{color:#73664f;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-ops-status__label{font-size:28px;line-height:1}.absolute-voice-ops-status__description{color:#514733;margin:12px 0 0}.absolute-voice-ops-status__summary,.absolute-voice-ops-status__links{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.absolute-voice-ops-status__summary span,.absolute-voice-ops-status__links a{border:1px solid #e6ddca;border-radius:999px;color:inherit;padding:6px 10px;text-decoration:none}.absolute-voice-ops-status__surfaces{display:grid;gap:8px;list-style:none;margin:16px 0 0;padding:0}.absolute-voice-ops-status__surface{align-items:center;background:#fff;border:1px solid #eee4d2;border-radius:14px;display:flex;gap:12px;justify-content:space-between;padding:10px 12px}.absolute-voice-ops-status__surface--fail{border-color:#f2a7a7}.absolute-voice-ops-status__surface span{color:#655944}.absolute-voice-ops-status__error{color:#9f1239;font-weight:700}`;
|
|
241
|
+
var mountVoiceOpsStatus = (element, path = "/app-kit/status", options = {}) => {
|
|
242
|
+
const store = createVoiceAppKitStatusStore(path, options);
|
|
243
|
+
const render = () => {
|
|
244
|
+
element.innerHTML = renderVoiceOpsStatusHTML(store.getSnapshot(), options);
|
|
245
|
+
};
|
|
246
|
+
const unsubscribe = store.subscribe(render);
|
|
247
|
+
render();
|
|
248
|
+
store.refresh().catch(() => {});
|
|
249
|
+
return {
|
|
250
|
+
close: () => {
|
|
251
|
+
unsubscribe();
|
|
252
|
+
store.close();
|
|
253
|
+
},
|
|
254
|
+
refresh: store.refresh
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
var defineVoiceOpsStatusElement = (tagName = "absolute-voice-ops-status") => {
|
|
258
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
customElements.define(tagName, class AbsoluteVoiceOpsStatusElement extends HTMLElement {
|
|
262
|
+
mounted;
|
|
263
|
+
connectedCallback() {
|
|
264
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
265
|
+
this.mounted = mountVoiceOpsStatus(this, this.getAttribute("path") ?? "/app-kit/status", {
|
|
266
|
+
description: this.getAttribute("description") ?? undefined,
|
|
267
|
+
includeLinks: this.getAttribute("include-links") !== "false",
|
|
268
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
269
|
+
title: this.getAttribute("title") ?? undefined
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
disconnectedCallback() {
|
|
273
|
+
this.mounted?.close();
|
|
274
|
+
this.mounted = undefined;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// src/vue/useVoiceAppKitStatus.ts
|
|
73
280
|
import { onUnmounted, ref, shallowRef } from "vue";
|
|
281
|
+
var useVoiceAppKitStatus = (path = "/app-kit/status", options = {}) => {
|
|
282
|
+
const store = createVoiceAppKitStatusStore(path, options);
|
|
283
|
+
const error = ref(null);
|
|
284
|
+
const isLoading = ref(false);
|
|
285
|
+
const report = shallowRef(undefined);
|
|
286
|
+
const updatedAt = ref(undefined);
|
|
287
|
+
const sync = () => {
|
|
288
|
+
const snapshot = store.getSnapshot();
|
|
289
|
+
error.value = snapshot.error;
|
|
290
|
+
isLoading.value = snapshot.isLoading;
|
|
291
|
+
report.value = snapshot.report;
|
|
292
|
+
updatedAt.value = snapshot.updatedAt;
|
|
293
|
+
};
|
|
294
|
+
const unsubscribe = store.subscribe(sync);
|
|
295
|
+
sync();
|
|
296
|
+
if (typeof window !== "undefined") {
|
|
297
|
+
store.refresh().catch(() => {});
|
|
298
|
+
}
|
|
299
|
+
onUnmounted(() => {
|
|
300
|
+
unsubscribe();
|
|
301
|
+
store.close();
|
|
302
|
+
});
|
|
303
|
+
return {
|
|
304
|
+
error,
|
|
305
|
+
isLoading,
|
|
306
|
+
refresh: store.refresh,
|
|
307
|
+
report,
|
|
308
|
+
updatedAt
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// src/vue/VoiceOpsStatus.ts
|
|
313
|
+
var VoiceOpsStatus = defineComponent({
|
|
314
|
+
name: "VoiceOpsStatus",
|
|
315
|
+
props: {
|
|
316
|
+
description: String,
|
|
317
|
+
includeLinks: {
|
|
318
|
+
default: true,
|
|
319
|
+
type: Boolean
|
|
320
|
+
},
|
|
321
|
+
intervalMs: Number,
|
|
322
|
+
path: {
|
|
323
|
+
default: "/app-kit/status",
|
|
324
|
+
type: String
|
|
325
|
+
},
|
|
326
|
+
title: String
|
|
327
|
+
},
|
|
328
|
+
setup(props) {
|
|
329
|
+
const options = {
|
|
330
|
+
description: props.description,
|
|
331
|
+
includeLinks: props.includeLinks,
|
|
332
|
+
intervalMs: props.intervalMs,
|
|
333
|
+
title: props.title
|
|
334
|
+
};
|
|
335
|
+
const status = useVoiceAppKitStatus(props.path, options);
|
|
336
|
+
return () => {
|
|
337
|
+
const model = createVoiceOpsStatusViewModel({
|
|
338
|
+
error: status.error.value,
|
|
339
|
+
isLoading: status.isLoading.value,
|
|
340
|
+
report: status.report.value,
|
|
341
|
+
updatedAt: status.updatedAt.value
|
|
342
|
+
}, options);
|
|
343
|
+
return h("section", {
|
|
344
|
+
class: [
|
|
345
|
+
"absolute-voice-ops-status",
|
|
346
|
+
`absolute-voice-ops-status--${model.status}`
|
|
347
|
+
]
|
|
348
|
+
}, [
|
|
349
|
+
h("header", { class: "absolute-voice-ops-status__header" }, [
|
|
350
|
+
h("span", { class: "absolute-voice-ops-status__eyebrow" }, model.title),
|
|
351
|
+
h("strong", { class: "absolute-voice-ops-status__label" }, model.label)
|
|
352
|
+
]),
|
|
353
|
+
h("p", { class: "absolute-voice-ops-status__description" }, model.description),
|
|
354
|
+
h("div", { class: "absolute-voice-ops-status__summary" }, [
|
|
355
|
+
h("span", `${model.passed} passing`),
|
|
356
|
+
h("span", `${Math.max(model.total - model.passed, 0)} failing`),
|
|
357
|
+
h("span", `${model.total} checks`)
|
|
358
|
+
]),
|
|
359
|
+
h("ul", { class: "absolute-voice-ops-status__surfaces" }, model.surfaces.length > 0 ? model.surfaces.map((surface) => h("li", {
|
|
360
|
+
class: [
|
|
361
|
+
"absolute-voice-ops-status__surface",
|
|
362
|
+
`absolute-voice-ops-status__surface--${surface.status}`
|
|
363
|
+
],
|
|
364
|
+
key: surface.id
|
|
365
|
+
}, [h("span", surface.label), h("strong", surface.detail)])) : [
|
|
366
|
+
h("li", { class: "absolute-voice-ops-status__surface" }, [
|
|
367
|
+
h("span", "Status"),
|
|
368
|
+
h("strong", "Waiting for first check")
|
|
369
|
+
])
|
|
370
|
+
]),
|
|
371
|
+
model.error ? h("p", { class: "absolute-voice-ops-status__error" }, model.error) : null,
|
|
372
|
+
model.links.length > 0 ? h("nav", { class: "absolute-voice-ops-status__links" }, model.links.slice(0, 4).map((link) => h("a", { href: link.href, key: link.href }, link.label))) : null
|
|
373
|
+
]);
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
// src/vue/VoiceProviderSimulationControls.ts
|
|
378
|
+
import { computed, defineComponent as defineComponent2, h as h2 } from "vue";
|
|
379
|
+
|
|
380
|
+
// src/client/providerSimulationControls.ts
|
|
381
|
+
var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
|
|
382
|
+
const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
|
|
383
|
+
const body = await response.json().catch(() => null);
|
|
384
|
+
if (!response.ok) {
|
|
385
|
+
const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice provider simulation failed: HTTP ${response.status}`;
|
|
386
|
+
throw new Error(message);
|
|
387
|
+
}
|
|
388
|
+
return body;
|
|
389
|
+
};
|
|
390
|
+
var createVoiceProviderSimulationControlsStore = (options) => {
|
|
391
|
+
const listeners = new Set;
|
|
392
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
393
|
+
const pathPrefix = options.pathPrefix ?? `/api/${options.kind ?? "stt"}-simulate`;
|
|
394
|
+
let closed = false;
|
|
395
|
+
let snapshot = {
|
|
396
|
+
error: null,
|
|
397
|
+
isRunning: false,
|
|
398
|
+
lastResult: null,
|
|
399
|
+
mode: null,
|
|
400
|
+
provider: null
|
|
401
|
+
};
|
|
402
|
+
const emit = () => {
|
|
403
|
+
for (const listener of listeners) {
|
|
404
|
+
listener();
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
const run = async (provider, mode) => {
|
|
408
|
+
if (closed) {
|
|
409
|
+
return snapshot.lastResult;
|
|
410
|
+
}
|
|
411
|
+
snapshot = {
|
|
412
|
+
...snapshot,
|
|
413
|
+
error: null,
|
|
414
|
+
isRunning: true,
|
|
415
|
+
mode,
|
|
416
|
+
provider
|
|
417
|
+
};
|
|
418
|
+
emit();
|
|
419
|
+
try {
|
|
420
|
+
const result = await postSimulation(pathPrefix, mode, provider, fetchImpl);
|
|
421
|
+
snapshot = {
|
|
422
|
+
error: null,
|
|
423
|
+
isRunning: false,
|
|
424
|
+
lastResult: result,
|
|
425
|
+
mode,
|
|
426
|
+
provider,
|
|
427
|
+
updatedAt: Date.now()
|
|
428
|
+
};
|
|
429
|
+
emit();
|
|
430
|
+
return result;
|
|
431
|
+
} catch (error) {
|
|
432
|
+
snapshot = {
|
|
433
|
+
...snapshot,
|
|
434
|
+
error: error instanceof Error ? error.message : String(error),
|
|
435
|
+
isRunning: false
|
|
436
|
+
};
|
|
437
|
+
emit();
|
|
438
|
+
throw error;
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
const close = () => {
|
|
442
|
+
closed = true;
|
|
443
|
+
listeners.clear();
|
|
444
|
+
};
|
|
445
|
+
return {
|
|
446
|
+
close,
|
|
447
|
+
getServerSnapshot: () => snapshot,
|
|
448
|
+
getSnapshot: () => snapshot,
|
|
449
|
+
run,
|
|
450
|
+
subscribe: (listener) => {
|
|
451
|
+
listeners.add(listener);
|
|
452
|
+
return () => {
|
|
453
|
+
listeners.delete(listener);
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// src/client/providerSimulationControlsWidget.ts
|
|
460
|
+
var escapeHtml2 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
461
|
+
var formatKind = (kind) => (kind ?? "stt").toUpperCase();
|
|
462
|
+
var createVoiceProviderSimulationControlsViewModel = (snapshot, options) => {
|
|
463
|
+
const configuredProviders = options.providers.filter((provider) => provider.configured !== false);
|
|
464
|
+
const fallbackReady = !options.fallbackRequiredProvider || configuredProviders.some((entry) => entry.provider === options.fallbackRequiredProvider);
|
|
465
|
+
const failureProviders = (options.failureProviders ? options.failureProviders.map((provider) => ({ provider })) : configuredProviders).filter((provider) => configuredProviders.some((entry) => entry.provider === provider.provider));
|
|
466
|
+
return {
|
|
467
|
+
canSimulateFailure: configuredProviders.length > 0 && fallbackReady,
|
|
468
|
+
description: options.failureMessage ?? `Simulate ${formatKind(options.kind)} provider failure and recovery without changing credentials.`,
|
|
469
|
+
error: snapshot.error,
|
|
470
|
+
failureProviders,
|
|
471
|
+
isRunning: snapshot.isRunning,
|
|
472
|
+
label: snapshot.isRunning ? `Running ${snapshot.mode ?? "simulation"}` : snapshot.lastResult ? `${snapshot.lastResult.provider} ${snapshot.lastResult.mode} simulated` : configuredProviders.length ? `${configuredProviders.length} configured` : "No configured providers",
|
|
473
|
+
providers: configuredProviders,
|
|
474
|
+
resultText: snapshot.lastResult ? JSON.stringify(snapshot.lastResult, null, 2) : null,
|
|
475
|
+
title: options.title ?? `${formatKind(options.kind)} Failure Simulation`
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
var renderVoiceProviderSimulationControlsHTML = (snapshot, options) => {
|
|
479
|
+
const model = createVoiceProviderSimulationControlsViewModel(snapshot, options);
|
|
480
|
+
const failureButtons = model.failureProviders.map((provider) => `<button type="button" data-voice-provider-fail="${escapeHtml2(provider.provider)}"${!model.canSimulateFailure || snapshot.isRunning ? " disabled" : ""}>Simulate ${escapeHtml2(provider.provider)} ${escapeHtml2(formatKind(options.kind))} failure</button>`).join("");
|
|
481
|
+
const recoveryButtons = model.providers.map((provider) => `<button type="button" data-voice-provider-recover="${escapeHtml2(provider.provider)}"${snapshot.isRunning ? " disabled" : ""}>Mark ${escapeHtml2(provider.provider)} recovered</button>`).join("");
|
|
482
|
+
return `<section class="absolute-voice-provider-simulation absolute-voice-provider-simulation--${snapshot.error ? "error" : snapshot.isRunning ? "running" : "ready"}">
|
|
483
|
+
<header class="absolute-voice-provider-simulation__header">
|
|
484
|
+
<span class="absolute-voice-provider-simulation__eyebrow">${escapeHtml2(model.title)}</span>
|
|
485
|
+
<strong class="absolute-voice-provider-simulation__label">${escapeHtml2(model.label)}</strong>
|
|
486
|
+
</header>
|
|
487
|
+
<p class="absolute-voice-provider-simulation__description">${escapeHtml2(model.description)}</p>
|
|
488
|
+
${model.canSimulateFailure ? "" : `<p class="absolute-voice-provider-simulation__empty">${escapeHtml2(options.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure.")}</p>`}
|
|
489
|
+
<div class="absolute-voice-provider-simulation__actions">${failureButtons}${recoveryButtons}</div>
|
|
490
|
+
${snapshot.error ? `<p class="absolute-voice-provider-simulation__error">${escapeHtml2(snapshot.error)}</p>` : ""}
|
|
491
|
+
${model.resultText ? `<pre class="absolute-voice-provider-simulation__result">${escapeHtml2(model.resultText)}</pre>` : ""}
|
|
492
|
+
</section>`;
|
|
493
|
+
};
|
|
494
|
+
var bindVoiceProviderSimulationControls = (element, store) => {
|
|
495
|
+
const onClick = (event) => {
|
|
496
|
+
const target = event.target;
|
|
497
|
+
if (!(target instanceof HTMLElement)) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const failProvider = target.getAttribute("data-voice-provider-fail");
|
|
501
|
+
const recoverProvider = target.getAttribute("data-voice-provider-recover");
|
|
502
|
+
if (failProvider) {
|
|
503
|
+
store.run(failProvider, "failure").catch(() => {});
|
|
504
|
+
}
|
|
505
|
+
if (recoverProvider) {
|
|
506
|
+
store.run(recoverProvider, "recovery").catch(() => {});
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
element.addEventListener("click", onClick);
|
|
510
|
+
return () => element.removeEventListener("click", onClick);
|
|
511
|
+
};
|
|
512
|
+
var mountVoiceProviderSimulationControls = (element, options) => {
|
|
513
|
+
const store = createVoiceProviderSimulationControlsStore(options);
|
|
514
|
+
const render = () => {
|
|
515
|
+
element.innerHTML = renderVoiceProviderSimulationControlsHTML(store.getSnapshot(), options);
|
|
516
|
+
};
|
|
517
|
+
const unsubscribeStore = store.subscribe(render);
|
|
518
|
+
const unsubscribeDom = bindVoiceProviderSimulationControls(element, store);
|
|
519
|
+
render();
|
|
520
|
+
return {
|
|
521
|
+
close: () => {
|
|
522
|
+
unsubscribeDom();
|
|
523
|
+
unsubscribeStore();
|
|
524
|
+
store.close();
|
|
525
|
+
},
|
|
526
|
+
run: store.run
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
var defineVoiceProviderSimulationControlsElement = (tagName = "absolute-voice-provider-simulation") => {
|
|
530
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
customElements.define(tagName, class AbsoluteVoiceProviderSimulationElement extends HTMLElement {
|
|
534
|
+
mounted;
|
|
535
|
+
connectedCallback() {
|
|
536
|
+
const providers = (this.getAttribute("providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean).map((provider) => ({ provider }));
|
|
537
|
+
const failureProviders = (this.getAttribute("failure-providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean);
|
|
538
|
+
this.mounted = mountVoiceProviderSimulationControls(this, {
|
|
539
|
+
failureProviders: failureProviders.length ? failureProviders : undefined,
|
|
540
|
+
fallbackRequiredMessage: this.getAttribute("fallback-required-message") ?? undefined,
|
|
541
|
+
fallbackRequiredProvider: this.getAttribute("fallback-required-provider") ?? undefined,
|
|
542
|
+
failureMessage: this.getAttribute("failure-message") ?? undefined,
|
|
543
|
+
kind: this.getAttribute("kind") ?? "stt",
|
|
544
|
+
pathPrefix: this.getAttribute("path-prefix") ?? undefined,
|
|
545
|
+
providers,
|
|
546
|
+
title: this.getAttribute("title") ?? undefined
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
disconnectedCallback() {
|
|
550
|
+
this.mounted?.close();
|
|
551
|
+
this.mounted = undefined;
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
// src/vue/useVoiceProviderSimulationControls.ts
|
|
557
|
+
import { onUnmounted as onUnmounted2, ref as ref2 } from "vue";
|
|
558
|
+
var useVoiceProviderSimulationControls = (options) => {
|
|
559
|
+
const store = createVoiceProviderSimulationControlsStore(options);
|
|
560
|
+
const error = ref2(null);
|
|
561
|
+
const isRunning = ref2(false);
|
|
562
|
+
const lastResult = ref2(null);
|
|
563
|
+
const mode = ref2(null);
|
|
564
|
+
const provider = ref2(null);
|
|
565
|
+
const updatedAt = ref2(undefined);
|
|
566
|
+
const sync = () => {
|
|
567
|
+
const snapshot = store.getSnapshot();
|
|
568
|
+
error.value = snapshot.error;
|
|
569
|
+
isRunning.value = snapshot.isRunning;
|
|
570
|
+
lastResult.value = snapshot.lastResult;
|
|
571
|
+
mode.value = snapshot.mode;
|
|
572
|
+
provider.value = snapshot.provider;
|
|
573
|
+
updatedAt.value = snapshot.updatedAt;
|
|
574
|
+
};
|
|
575
|
+
const unsubscribe = store.subscribe(sync);
|
|
576
|
+
sync();
|
|
577
|
+
onUnmounted2(() => {
|
|
578
|
+
unsubscribe();
|
|
579
|
+
store.close();
|
|
580
|
+
});
|
|
581
|
+
return {
|
|
582
|
+
error,
|
|
583
|
+
isRunning,
|
|
584
|
+
lastResult,
|
|
585
|
+
mode,
|
|
586
|
+
provider,
|
|
587
|
+
run: store.run,
|
|
588
|
+
updatedAt
|
|
589
|
+
};
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
// src/vue/VoiceProviderSimulationControls.ts
|
|
593
|
+
var VoiceProviderSimulationControls = defineComponent2({
|
|
594
|
+
name: "VoiceProviderSimulationControls",
|
|
595
|
+
props: {
|
|
596
|
+
class: { default: "", type: String },
|
|
597
|
+
fallbackRequiredMessage: { default: undefined, type: String },
|
|
598
|
+
fallbackRequiredProvider: { default: undefined, type: String },
|
|
599
|
+
failureMessage: { default: undefined, type: String },
|
|
600
|
+
failureProviders: {
|
|
601
|
+
default: undefined,
|
|
602
|
+
type: Array
|
|
603
|
+
},
|
|
604
|
+
kind: { default: "stt", type: String },
|
|
605
|
+
pathPrefix: { default: undefined, type: String },
|
|
606
|
+
providers: {
|
|
607
|
+
required: true,
|
|
608
|
+
type: Array
|
|
609
|
+
},
|
|
610
|
+
title: { default: undefined, type: String }
|
|
611
|
+
},
|
|
612
|
+
setup(props) {
|
|
613
|
+
const options = {
|
|
614
|
+
fallbackRequiredMessage: props.fallbackRequiredMessage,
|
|
615
|
+
fallbackRequiredProvider: props.fallbackRequiredProvider,
|
|
616
|
+
failureMessage: props.failureMessage,
|
|
617
|
+
failureProviders: props.failureProviders,
|
|
618
|
+
kind: props.kind,
|
|
619
|
+
pathPrefix: props.pathPrefix,
|
|
620
|
+
providers: props.providers,
|
|
621
|
+
title: props.title
|
|
622
|
+
};
|
|
623
|
+
const controls = useVoiceProviderSimulationControls(options);
|
|
624
|
+
const model = computed(() => createVoiceProviderSimulationControlsViewModel({
|
|
625
|
+
error: controls.error.value,
|
|
626
|
+
isRunning: controls.isRunning.value,
|
|
627
|
+
lastResult: controls.lastResult.value,
|
|
628
|
+
mode: controls.mode.value,
|
|
629
|
+
provider: controls.provider.value,
|
|
630
|
+
updatedAt: controls.updatedAt.value
|
|
631
|
+
}, options));
|
|
632
|
+
const run = (provider, mode) => {
|
|
633
|
+
controls.run(provider, mode).catch(() => {});
|
|
634
|
+
};
|
|
635
|
+
return () => h2("section", {
|
|
636
|
+
class: [
|
|
637
|
+
"absolute-voice-provider-simulation",
|
|
638
|
+
`absolute-voice-provider-simulation--${controls.error.value ? "error" : controls.isRunning.value ? "running" : "ready"}`,
|
|
639
|
+
props.class
|
|
640
|
+
]
|
|
641
|
+
}, [
|
|
642
|
+
h2("header", { class: "absolute-voice-provider-simulation__header" }, [
|
|
643
|
+
h2("span", { class: "absolute-voice-provider-simulation__eyebrow" }, model.value.title),
|
|
644
|
+
h2("strong", { class: "absolute-voice-provider-simulation__label" }, model.value.label)
|
|
645
|
+
]),
|
|
646
|
+
h2("p", { class: "absolute-voice-provider-simulation__description" }, model.value.description),
|
|
647
|
+
model.value.canSimulateFailure ? null : h2("p", { class: "absolute-voice-provider-simulation__empty" }, props.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure."),
|
|
648
|
+
h2("div", { class: "absolute-voice-provider-simulation__actions" }, [
|
|
649
|
+
...model.value.failureProviders.map((provider) => h2("button", {
|
|
650
|
+
disabled: !model.value.canSimulateFailure || controls.isRunning.value,
|
|
651
|
+
key: `fail-${provider.provider}`,
|
|
652
|
+
onClick: () => run(provider.provider, "failure"),
|
|
653
|
+
type: "button"
|
|
654
|
+
}, `Simulate ${provider.provider} ${props.kind.toUpperCase()} failure`)),
|
|
655
|
+
...model.value.providers.map((provider) => h2("button", {
|
|
656
|
+
disabled: controls.isRunning.value,
|
|
657
|
+
key: `recover-${provider.provider}`,
|
|
658
|
+
onClick: () => run(provider.provider, "recovery"),
|
|
659
|
+
type: "button"
|
|
660
|
+
}, `Mark ${provider.provider} recovered`))
|
|
661
|
+
]),
|
|
662
|
+
controls.error.value ? h2("p", { class: "absolute-voice-provider-simulation__error" }, controls.error.value) : null,
|
|
663
|
+
model.value.resultText ? h2("pre", { class: "absolute-voice-provider-simulation__result" }, model.value.resultText) : null
|
|
664
|
+
]);
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
// src/vue/VoiceProviderCapabilities.ts
|
|
668
|
+
import { computed as computed2, defineComponent as defineComponent3, h as h3 } from "vue";
|
|
669
|
+
|
|
670
|
+
// src/client/providerCapabilities.ts
|
|
671
|
+
var fetchVoiceProviderCapabilities = async (path = "/api/provider-capabilities", options = {}) => {
|
|
672
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
673
|
+
const response = await fetchImpl(path);
|
|
674
|
+
if (!response.ok) {
|
|
675
|
+
throw new Error(`Voice provider capabilities failed: HTTP ${response.status}`);
|
|
676
|
+
}
|
|
677
|
+
return await response.json();
|
|
678
|
+
};
|
|
679
|
+
var createVoiceProviderCapabilitiesStore = (path = "/api/provider-capabilities", options = {}) => {
|
|
680
|
+
const listeners = new Set;
|
|
681
|
+
let closed = false;
|
|
682
|
+
let timer;
|
|
683
|
+
let snapshot = {
|
|
684
|
+
error: null,
|
|
685
|
+
isLoading: false
|
|
686
|
+
};
|
|
687
|
+
const emit = () => {
|
|
688
|
+
for (const listener of listeners) {
|
|
689
|
+
listener();
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
const refresh = async () => {
|
|
693
|
+
if (closed) {
|
|
694
|
+
return snapshot.report;
|
|
695
|
+
}
|
|
696
|
+
snapshot = {
|
|
697
|
+
...snapshot,
|
|
698
|
+
error: null,
|
|
699
|
+
isLoading: true
|
|
700
|
+
};
|
|
701
|
+
emit();
|
|
702
|
+
try {
|
|
703
|
+
const report = await fetchVoiceProviderCapabilities(path, options);
|
|
704
|
+
snapshot = {
|
|
705
|
+
error: null,
|
|
706
|
+
isLoading: false,
|
|
707
|
+
report,
|
|
708
|
+
updatedAt: Date.now()
|
|
709
|
+
};
|
|
710
|
+
emit();
|
|
711
|
+
return report;
|
|
712
|
+
} catch (error) {
|
|
713
|
+
snapshot = {
|
|
714
|
+
...snapshot,
|
|
715
|
+
error: error instanceof Error ? error.message : String(error),
|
|
716
|
+
isLoading: false
|
|
717
|
+
};
|
|
718
|
+
emit();
|
|
719
|
+
throw error;
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
const close = () => {
|
|
723
|
+
closed = true;
|
|
724
|
+
if (timer) {
|
|
725
|
+
clearInterval(timer);
|
|
726
|
+
timer = undefined;
|
|
727
|
+
}
|
|
728
|
+
listeners.clear();
|
|
729
|
+
};
|
|
730
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
731
|
+
timer = setInterval(() => {
|
|
732
|
+
refresh().catch(() => {});
|
|
733
|
+
}, options.intervalMs);
|
|
734
|
+
}
|
|
735
|
+
return {
|
|
736
|
+
close,
|
|
737
|
+
getServerSnapshot: () => snapshot,
|
|
738
|
+
getSnapshot: () => snapshot,
|
|
739
|
+
refresh,
|
|
740
|
+
subscribe: (listener) => {
|
|
741
|
+
listeners.add(listener);
|
|
742
|
+
return () => {
|
|
743
|
+
listeners.delete(listener);
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
// src/client/providerCapabilitiesWidget.ts
|
|
750
|
+
var DEFAULT_TITLE2 = "Provider Capabilities";
|
|
751
|
+
var DEFAULT_DESCRIPTION2 = "Configured, selected, and healthy voice providers for this deployment.";
|
|
752
|
+
var escapeHtml3 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
753
|
+
var formatProvider = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
754
|
+
var formatKind2 = (kind) => kind.toUpperCase();
|
|
755
|
+
var formatStatus = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
756
|
+
var getCapabilityDetail = (capability) => {
|
|
757
|
+
if (!capability.configured) {
|
|
758
|
+
return "Not configured in this deployment.";
|
|
759
|
+
}
|
|
760
|
+
if (capability.selected) {
|
|
761
|
+
return `Selected ${capability.kind.toUpperCase()} provider for new sessions.`;
|
|
762
|
+
}
|
|
763
|
+
if (capability.health?.status === "healthy") {
|
|
764
|
+
return "Configured and healthy fallback candidate.";
|
|
765
|
+
}
|
|
766
|
+
if (capability.health?.status === "idle") {
|
|
767
|
+
return "Configured; no traffic observed yet.";
|
|
768
|
+
}
|
|
769
|
+
if (capability.health?.lastError) {
|
|
770
|
+
return capability.health.lastError;
|
|
771
|
+
}
|
|
772
|
+
return "Configured and available.";
|
|
773
|
+
};
|
|
774
|
+
var isWarningStatus = (status) => status === "degraded" || status === "rate-limited" || status === "suppressed" || status === "unconfigured";
|
|
775
|
+
var createVoiceProviderCapabilitiesViewModel = (snapshot, options = {}) => {
|
|
776
|
+
const capabilities = (snapshot.report?.capabilities ?? []).map((capability) => ({
|
|
777
|
+
...capability,
|
|
778
|
+
detail: getCapabilityDetail(capability),
|
|
779
|
+
label: `${formatProvider(capability.provider)} ${formatKind2(capability.kind)}`,
|
|
780
|
+
rows: [
|
|
781
|
+
{ label: "Status", value: formatStatus(capability.status) },
|
|
782
|
+
{ label: "Selected", value: capability.selected ? "Yes" : "No" },
|
|
783
|
+
{ label: "Model", value: capability.model ?? "Default" },
|
|
784
|
+
{
|
|
785
|
+
label: "Features",
|
|
786
|
+
value: capability.features?.join(", ") || "Not specified"
|
|
787
|
+
},
|
|
788
|
+
{ label: "Runs", value: String(capability.health?.runCount ?? 0) },
|
|
789
|
+
{ label: "Errors", value: String(capability.health?.errorCount ?? 0) }
|
|
790
|
+
]
|
|
791
|
+
}));
|
|
792
|
+
const warningCount = capabilities.filter((capability) => isWarningStatus(capability.status)).length;
|
|
793
|
+
const selectedCount = snapshot.report?.selected ?? capabilities.filter((capability) => capability.selected).length;
|
|
794
|
+
return {
|
|
795
|
+
capabilities,
|
|
796
|
+
description: options.description ?? DEFAULT_DESCRIPTION2,
|
|
797
|
+
error: snapshot.error,
|
|
798
|
+
isLoading: snapshot.isLoading,
|
|
799
|
+
label: snapshot.error ? "Unavailable" : capabilities.length ? warningCount > 0 ? `${warningCount} needs attention` : `${selectedCount} selected` : snapshot.isLoading ? "Checking" : "No capabilities",
|
|
800
|
+
status: snapshot.error ? "error" : capabilities.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
801
|
+
title: options.title ?? DEFAULT_TITLE2,
|
|
802
|
+
updatedAt: snapshot.updatedAt
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
var renderVoiceProviderCapabilitiesHTML = (snapshot, options = {}) => {
|
|
806
|
+
const model = createVoiceProviderCapabilitiesViewModel(snapshot, options);
|
|
807
|
+
const capabilities = model.capabilities.length ? `<div class="absolute-voice-provider-capabilities__providers">${model.capabilities.map((capability) => `<article class="absolute-voice-provider-capabilities__provider absolute-voice-provider-capabilities__provider--${escapeHtml3(capability.status)}">
|
|
808
|
+
<header>
|
|
809
|
+
<strong>${escapeHtml3(capability.label)}</strong>
|
|
810
|
+
<span>${escapeHtml3(formatStatus(capability.status))}</span>
|
|
811
|
+
</header>
|
|
812
|
+
<p>${escapeHtml3(capability.detail)}</p>
|
|
813
|
+
<dl>${capability.rows.map((row) => `<div>
|
|
814
|
+
<dt>${escapeHtml3(row.label)}</dt>
|
|
815
|
+
<dd>${escapeHtml3(row.value)}</dd>
|
|
816
|
+
</div>`).join("")}</dl>
|
|
817
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-capabilities__empty">Configure provider capabilities to see deployment coverage.</p>';
|
|
818
|
+
return `<section class="absolute-voice-provider-capabilities absolute-voice-provider-capabilities--${escapeHtml3(model.status)}">
|
|
819
|
+
<header class="absolute-voice-provider-capabilities__header">
|
|
820
|
+
<span class="absolute-voice-provider-capabilities__eyebrow">${escapeHtml3(model.title)}</span>
|
|
821
|
+
<strong class="absolute-voice-provider-capabilities__label">${escapeHtml3(model.label)}</strong>
|
|
822
|
+
</header>
|
|
823
|
+
<p class="absolute-voice-provider-capabilities__description">${escapeHtml3(model.description)}</p>
|
|
824
|
+
${capabilities}
|
|
825
|
+
${model.error ? `<p class="absolute-voice-provider-capabilities__error">${escapeHtml3(model.error)}</p>` : ""}
|
|
826
|
+
</section>`;
|
|
827
|
+
};
|
|
828
|
+
var getVoiceProviderCapabilitiesCSS = () => `.absolute-voice-provider-capabilities{border:1px solid #bfd7ea;border-radius:20px;background:#f6fbff;color:#08131f;padding:18px;box-shadow:0 18px 40px rgba(14,51,78,.12);font-family:inherit}.absolute-voice-provider-capabilities--error,.absolute-voice-provider-capabilities--warning{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-provider-capabilities__header,.absolute-voice-provider-capabilities__provider header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-provider-capabilities__eyebrow{color:#255f85;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-provider-capabilities__label{font-size:24px;line-height:1}.absolute-voice-provider-capabilities__description,.absolute-voice-provider-capabilities__provider p,.absolute-voice-provider-capabilities__provider dt,.absolute-voice-provider-capabilities__empty{color:#405467}.absolute-voice-provider-capabilities__providers{display:grid;gap:12px;margin-top:14px}.absolute-voice-provider-capabilities__provider{background:#fff;border:1px solid #d7e7f3;border-radius:16px;padding:14px}.absolute-voice-provider-capabilities__provider--selected,.absolute-voice-provider-capabilities__provider--healthy{border-color:#86efac}.absolute-voice-provider-capabilities__provider--degraded,.absolute-voice-provider-capabilities__provider--rate-limited,.absolute-voice-provider-capabilities__provider--suppressed,.absolute-voice-provider-capabilities__provider--unconfigured{border-color:#f2a7a7}.absolute-voice-provider-capabilities__provider p{margin:10px 0}.absolute-voice-provider-capabilities__provider dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-provider-capabilities__provider div{background:#f6fbff;border:1px solid #d7e7f3;border-radius:12px;padding:8px}.absolute-voice-provider-capabilities__provider dt{font-size:12px}.absolute-voice-provider-capabilities__provider dd{font-weight:800;margin:4px 0 0}.absolute-voice-provider-capabilities__empty{margin:14px 0 0}.absolute-voice-provider-capabilities__error{color:#9f1239;font-weight:700}`;
|
|
829
|
+
var mountVoiceProviderCapabilities = (element, path = "/api/provider-capabilities", options = {}) => {
|
|
830
|
+
const store = createVoiceProviderCapabilitiesStore(path, options);
|
|
831
|
+
const render = () => {
|
|
832
|
+
element.innerHTML = renderVoiceProviderCapabilitiesHTML(store.getSnapshot(), options);
|
|
833
|
+
};
|
|
834
|
+
const unsubscribe = store.subscribe(render);
|
|
835
|
+
render();
|
|
836
|
+
store.refresh().catch(() => {});
|
|
837
|
+
return {
|
|
838
|
+
close: () => {
|
|
839
|
+
unsubscribe();
|
|
840
|
+
store.close();
|
|
841
|
+
},
|
|
842
|
+
refresh: store.refresh
|
|
843
|
+
};
|
|
844
|
+
};
|
|
845
|
+
var defineVoiceProviderCapabilitiesElement = (tagName = "absolute-voice-provider-capabilities") => {
|
|
846
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
customElements.define(tagName, class AbsoluteVoiceProviderCapabilitiesElement extends HTMLElement {
|
|
850
|
+
mounted;
|
|
851
|
+
connectedCallback() {
|
|
852
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
853
|
+
this.mounted = mountVoiceProviderCapabilities(this, this.getAttribute("path") ?? "/api/provider-capabilities", {
|
|
854
|
+
description: this.getAttribute("description") ?? undefined,
|
|
855
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
856
|
+
title: this.getAttribute("title") ?? undefined
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
disconnectedCallback() {
|
|
860
|
+
this.mounted?.close();
|
|
861
|
+
this.mounted = undefined;
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
// src/vue/useVoiceProviderCapabilities.ts
|
|
867
|
+
import { onUnmounted as onUnmounted3, shallowRef as shallowRef2 } from "vue";
|
|
868
|
+
var useVoiceProviderCapabilities = (path = "/api/provider-capabilities", options = {}) => {
|
|
869
|
+
const store = createVoiceProviderCapabilitiesStore(path, options);
|
|
870
|
+
const error = shallowRef2(null);
|
|
871
|
+
const isLoading = shallowRef2(false);
|
|
872
|
+
const report = shallowRef2();
|
|
873
|
+
const updatedAt = shallowRef2(undefined);
|
|
874
|
+
const sync = () => {
|
|
875
|
+
const snapshot = store.getSnapshot();
|
|
876
|
+
error.value = snapshot.error;
|
|
877
|
+
isLoading.value = snapshot.isLoading;
|
|
878
|
+
report.value = snapshot.report;
|
|
879
|
+
updatedAt.value = snapshot.updatedAt;
|
|
880
|
+
};
|
|
881
|
+
const unsubscribe = store.subscribe(sync);
|
|
882
|
+
sync();
|
|
883
|
+
store.refresh().catch(() => {});
|
|
884
|
+
onUnmounted3(() => {
|
|
885
|
+
unsubscribe();
|
|
886
|
+
store.close();
|
|
887
|
+
});
|
|
888
|
+
return {
|
|
889
|
+
error,
|
|
890
|
+
isLoading,
|
|
891
|
+
refresh: store.refresh,
|
|
892
|
+
report,
|
|
893
|
+
updatedAt
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
// src/vue/VoiceProviderCapabilities.ts
|
|
898
|
+
var VoiceProviderCapabilities = defineComponent3({
|
|
899
|
+
name: "VoiceProviderCapabilities",
|
|
900
|
+
props: {
|
|
901
|
+
class: {
|
|
902
|
+
default: "",
|
|
903
|
+
type: String
|
|
904
|
+
},
|
|
905
|
+
description: {
|
|
906
|
+
default: undefined,
|
|
907
|
+
type: String
|
|
908
|
+
},
|
|
909
|
+
intervalMs: {
|
|
910
|
+
default: 5000,
|
|
911
|
+
type: Number
|
|
912
|
+
},
|
|
913
|
+
path: {
|
|
914
|
+
default: "/api/provider-capabilities",
|
|
915
|
+
type: String
|
|
916
|
+
},
|
|
917
|
+
title: {
|
|
918
|
+
default: undefined,
|
|
919
|
+
type: String
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
setup(props) {
|
|
923
|
+
const options = {
|
|
924
|
+
description: props.description,
|
|
925
|
+
intervalMs: props.intervalMs,
|
|
926
|
+
title: props.title
|
|
927
|
+
};
|
|
928
|
+
const capabilities = useVoiceProviderCapabilities(props.path, options);
|
|
929
|
+
const model = computed2(() => createVoiceProviderCapabilitiesViewModel({
|
|
930
|
+
error: capabilities.error.value,
|
|
931
|
+
isLoading: capabilities.isLoading.value,
|
|
932
|
+
report: capabilities.report.value,
|
|
933
|
+
updatedAt: capabilities.updatedAt.value
|
|
934
|
+
}, options));
|
|
935
|
+
return () => h3("section", {
|
|
936
|
+
class: [
|
|
937
|
+
"absolute-voice-provider-capabilities",
|
|
938
|
+
`absolute-voice-provider-capabilities--${model.value.status}`,
|
|
939
|
+
props.class
|
|
940
|
+
]
|
|
941
|
+
}, [
|
|
942
|
+
h3("header", { class: "absolute-voice-provider-capabilities__header" }, [
|
|
943
|
+
h3("span", { class: "absolute-voice-provider-capabilities__eyebrow" }, model.value.title),
|
|
944
|
+
h3("strong", { class: "absolute-voice-provider-capabilities__label" }, model.value.label)
|
|
945
|
+
]),
|
|
946
|
+
h3("p", { class: "absolute-voice-provider-capabilities__description" }, model.value.description),
|
|
947
|
+
model.value.capabilities.length ? h3("div", { class: "absolute-voice-provider-capabilities__providers" }, model.value.capabilities.map((capability) => h3("article", {
|
|
948
|
+
class: [
|
|
949
|
+
"absolute-voice-provider-capabilities__provider",
|
|
950
|
+
`absolute-voice-provider-capabilities__provider--${capability.status}`
|
|
951
|
+
],
|
|
952
|
+
key: `${capability.kind}:${capability.provider}`
|
|
953
|
+
}, [
|
|
954
|
+
h3("header", [
|
|
955
|
+
h3("strong", capability.label),
|
|
956
|
+
h3("span", capability.status)
|
|
957
|
+
]),
|
|
958
|
+
h3("p", capability.detail),
|
|
959
|
+
h3("dl", capability.rows.map((row) => h3("div", { key: row.label }, [
|
|
960
|
+
h3("dt", row.label),
|
|
961
|
+
h3("dd", row.value)
|
|
962
|
+
])))
|
|
963
|
+
]))) : h3("p", { class: "absolute-voice-provider-capabilities__empty" }, "Configure provider capabilities to see deployment coverage."),
|
|
964
|
+
model.value.error ? h3("p", { class: "absolute-voice-provider-capabilities__error" }, model.value.error) : null
|
|
965
|
+
]);
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
// src/vue/VoiceProviderStatus.ts
|
|
969
|
+
import { computed as computed3, defineComponent as defineComponent4, h as h4 } from "vue";
|
|
970
|
+
|
|
971
|
+
// src/client/providerStatus.ts
|
|
972
|
+
var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
|
|
973
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
974
|
+
const response = await fetchImpl(path);
|
|
975
|
+
if (!response.ok) {
|
|
976
|
+
throw new Error(`Voice provider status failed: HTTP ${response.status}`);
|
|
977
|
+
}
|
|
978
|
+
return await response.json();
|
|
979
|
+
};
|
|
980
|
+
var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
|
|
981
|
+
const listeners = new Set;
|
|
982
|
+
let closed = false;
|
|
983
|
+
let timer;
|
|
984
|
+
let snapshot = {
|
|
985
|
+
error: null,
|
|
986
|
+
isLoading: false,
|
|
987
|
+
providers: []
|
|
988
|
+
};
|
|
989
|
+
const emit = () => {
|
|
990
|
+
for (const listener of listeners) {
|
|
991
|
+
listener();
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
const refresh = async () => {
|
|
995
|
+
if (closed) {
|
|
996
|
+
return snapshot.providers;
|
|
997
|
+
}
|
|
998
|
+
snapshot = {
|
|
999
|
+
...snapshot,
|
|
1000
|
+
error: null,
|
|
1001
|
+
isLoading: true
|
|
1002
|
+
};
|
|
1003
|
+
emit();
|
|
1004
|
+
try {
|
|
1005
|
+
const providers = await fetchVoiceProviderStatus(path, options);
|
|
1006
|
+
snapshot = {
|
|
1007
|
+
error: null,
|
|
1008
|
+
isLoading: false,
|
|
1009
|
+
providers,
|
|
1010
|
+
updatedAt: Date.now()
|
|
1011
|
+
};
|
|
1012
|
+
emit();
|
|
1013
|
+
return providers;
|
|
1014
|
+
} catch (error) {
|
|
1015
|
+
snapshot = {
|
|
1016
|
+
...snapshot,
|
|
1017
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1018
|
+
isLoading: false
|
|
1019
|
+
};
|
|
1020
|
+
emit();
|
|
1021
|
+
throw error;
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
const close = () => {
|
|
1025
|
+
closed = true;
|
|
1026
|
+
if (timer) {
|
|
1027
|
+
clearInterval(timer);
|
|
1028
|
+
timer = undefined;
|
|
1029
|
+
}
|
|
1030
|
+
listeners.clear();
|
|
1031
|
+
};
|
|
1032
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
1033
|
+
timer = setInterval(() => {
|
|
1034
|
+
refresh().catch(() => {});
|
|
1035
|
+
}, options.intervalMs);
|
|
1036
|
+
}
|
|
1037
|
+
return {
|
|
1038
|
+
close,
|
|
1039
|
+
getServerSnapshot: () => snapshot,
|
|
1040
|
+
getSnapshot: () => snapshot,
|
|
1041
|
+
refresh,
|
|
1042
|
+
subscribe: (listener) => {
|
|
1043
|
+
listeners.add(listener);
|
|
1044
|
+
return () => {
|
|
1045
|
+
listeners.delete(listener);
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
// src/client/providerStatusWidget.ts
|
|
1052
|
+
var DEFAULT_TITLE3 = "Voice Providers";
|
|
1053
|
+
var DEFAULT_DESCRIPTION3 = "Live provider health, fallback counts, latency, and suppression state from your self-hosted trace store.";
|
|
1054
|
+
var escapeHtml4 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1055
|
+
var formatProvider2 = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
1056
|
+
var formatStatus2 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
1057
|
+
var formatLatency = (value) => typeof value === "number" ? `${value}ms` : "No samples";
|
|
1058
|
+
var formatSuppression = (value) => typeof value === "number" ? `${Math.ceil(value / 1000)}s` : "None";
|
|
1059
|
+
var getProviderDetail = (provider) => {
|
|
1060
|
+
if (provider.status === "suppressed") {
|
|
1061
|
+
return provider.lastError ? `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)} after ${provider.lastError}.` : `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)}.`;
|
|
1062
|
+
}
|
|
1063
|
+
if (provider.status === "recoverable") {
|
|
1064
|
+
return "Cooldown expired; ready for recovery traffic.";
|
|
1065
|
+
}
|
|
1066
|
+
if (provider.status === "rate-limited") {
|
|
1067
|
+
return "Rate limit detected; router should avoid this provider.";
|
|
1068
|
+
}
|
|
1069
|
+
if (provider.status === "degraded") {
|
|
1070
|
+
return provider.lastError ?? "Recent provider errors detected.";
|
|
1071
|
+
}
|
|
1072
|
+
if (provider.status === "healthy") {
|
|
1073
|
+
return provider.recommended ? "Healthy and currently recommended." : "Healthy and available for routing.";
|
|
1074
|
+
}
|
|
1075
|
+
return "No provider traffic observed yet.";
|
|
1076
|
+
};
|
|
1077
|
+
var isWarningStatus2 = (status) => status === "degraded" || status === "rate-limited" || status === "recoverable" || status === "suppressed";
|
|
1078
|
+
var createVoiceProviderStatusViewModel = (snapshot, options = {}) => {
|
|
1079
|
+
const providers = snapshot.providers.map((provider) => ({
|
|
1080
|
+
...provider,
|
|
1081
|
+
detail: getProviderDetail(provider),
|
|
1082
|
+
label: `${formatProvider2(provider.provider)}${provider.recommended ? " recommended" : ""}`,
|
|
1083
|
+
rows: [
|
|
1084
|
+
{ label: "Runs", value: String(provider.runCount) },
|
|
1085
|
+
{ label: "Avg latency", value: formatLatency(provider.averageElapsedMs) },
|
|
1086
|
+
{ label: "Errors", value: String(provider.errorCount) },
|
|
1087
|
+
{ label: "Timeouts", value: String(provider.timeoutCount) },
|
|
1088
|
+
{ label: "Fallbacks", value: String(provider.fallbackCount) },
|
|
1089
|
+
{
|
|
1090
|
+
label: "Suppression",
|
|
1091
|
+
value: formatSuppression(provider.suppressionRemainingMs)
|
|
1092
|
+
}
|
|
1093
|
+
]
|
|
1094
|
+
}));
|
|
1095
|
+
const warningCount = providers.filter((provider) => isWarningStatus2(provider.status)).length;
|
|
1096
|
+
const healthyCount = providers.filter((provider) => provider.status === "healthy").length;
|
|
1097
|
+
return {
|
|
1098
|
+
description: options.description ?? DEFAULT_DESCRIPTION3,
|
|
1099
|
+
error: snapshot.error,
|
|
1100
|
+
isLoading: snapshot.isLoading,
|
|
1101
|
+
label: snapshot.error ? "Unavailable" : providers.length ? warningCount > 0 ? `${warningCount} needs attention` : `${healthyCount} healthy` : snapshot.isLoading ? "Checking" : "No provider traffic",
|
|
1102
|
+
providers,
|
|
1103
|
+
status: snapshot.error ? "error" : providers.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
1104
|
+
title: options.title ?? DEFAULT_TITLE3,
|
|
1105
|
+
updatedAt: snapshot.updatedAt
|
|
1106
|
+
};
|
|
1107
|
+
};
|
|
1108
|
+
var renderVoiceProviderStatusHTML = (snapshot, options = {}) => {
|
|
1109
|
+
const model = createVoiceProviderStatusViewModel(snapshot, options);
|
|
1110
|
+
const providers = model.providers.length ? `<div class="absolute-voice-provider-status__providers">${model.providers.map((provider) => `<article class="absolute-voice-provider-status__provider absolute-voice-provider-status__provider--${escapeHtml4(provider.status)}">
|
|
1111
|
+
<header>
|
|
1112
|
+
<strong>${escapeHtml4(provider.label)}</strong>
|
|
1113
|
+
<span>${escapeHtml4(formatStatus2(provider.status))}</span>
|
|
1114
|
+
</header>
|
|
1115
|
+
<p>${escapeHtml4(provider.detail)}</p>
|
|
1116
|
+
<dl>${provider.rows.map((row) => `<div>
|
|
1117
|
+
<dt>${escapeHtml4(row.label)}</dt>
|
|
1118
|
+
<dd>${escapeHtml4(row.value)}</dd>
|
|
1119
|
+
</div>`).join("")}</dl>
|
|
1120
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-status__empty">Run voice traffic to see provider health.</p>';
|
|
1121
|
+
return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${escapeHtml4(model.status)}">
|
|
1122
|
+
<header class="absolute-voice-provider-status__header">
|
|
1123
|
+
<span class="absolute-voice-provider-status__eyebrow">${escapeHtml4(model.title)}</span>
|
|
1124
|
+
<strong class="absolute-voice-provider-status__label">${escapeHtml4(model.label)}</strong>
|
|
1125
|
+
</header>
|
|
1126
|
+
<p class="absolute-voice-provider-status__description">${escapeHtml4(model.description)}</p>
|
|
1127
|
+
${providers}
|
|
1128
|
+
${model.error ? `<p class="absolute-voice-provider-status__error">${escapeHtml4(model.error)}</p>` : ""}
|
|
1129
|
+
</section>`;
|
|
1130
|
+
};
|
|
1131
|
+
var getVoiceProviderStatusCSS = () => `.absolute-voice-provider-status{border:1px solid #d8d2c4;border-radius:20px;background:#fffaf0;color:#16130d;padding:18px;box-shadow:0 18px 40px rgba(47,37,18,.12);font-family:inherit}.absolute-voice-provider-status--error,.absolute-voice-provider-status--warning{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-provider-status__header,.absolute-voice-provider-status__provider header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-provider-status__eyebrow{color:#73664f;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-provider-status__label{font-size:24px;line-height:1}.absolute-voice-provider-status__description,.absolute-voice-provider-status__provider p,.absolute-voice-provider-status__provider dt,.absolute-voice-provider-status__empty{color:#514733}.absolute-voice-provider-status__providers{display:grid;gap:12px;margin-top:14px}.absolute-voice-provider-status__provider{background:#fff;border:1px solid #eee4d2;border-radius:16px;padding:14px}.absolute-voice-provider-status__provider--degraded,.absolute-voice-provider-status__provider--rate-limited,.absolute-voice-provider-status__provider--suppressed{border-color:#f2a7a7}.absolute-voice-provider-status__provider--recoverable{border-color:#fbbf24}.absolute-voice-provider-status__provider p{margin:10px 0}.absolute-voice-provider-status__provider dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-provider-status__provider div{background:#fffaf0;border:1px solid #eee4d2;border-radius:12px;padding:8px}.absolute-voice-provider-status__provider dt{font-size:12px}.absolute-voice-provider-status__provider dd{font-weight:800;margin:4px 0 0}.absolute-voice-provider-status__empty{margin:14px 0 0}.absolute-voice-provider-status__error{color:#9f1239;font-weight:700}`;
|
|
1132
|
+
var mountVoiceProviderStatus = (element, path = "/api/provider-status", options = {}) => {
|
|
1133
|
+
const store = createVoiceProviderStatusStore(path, options);
|
|
1134
|
+
const render = () => {
|
|
1135
|
+
element.innerHTML = renderVoiceProviderStatusHTML(store.getSnapshot(), options);
|
|
1136
|
+
};
|
|
1137
|
+
const unsubscribe = store.subscribe(render);
|
|
1138
|
+
render();
|
|
1139
|
+
store.refresh().catch(() => {});
|
|
1140
|
+
return {
|
|
1141
|
+
close: () => {
|
|
1142
|
+
unsubscribe();
|
|
1143
|
+
store.close();
|
|
1144
|
+
},
|
|
1145
|
+
refresh: store.refresh
|
|
1146
|
+
};
|
|
1147
|
+
};
|
|
1148
|
+
var defineVoiceProviderStatusElement = (tagName = "absolute-voice-provider-status") => {
|
|
1149
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1150
|
+
return;
|
|
1151
|
+
}
|
|
1152
|
+
customElements.define(tagName, class AbsoluteVoiceProviderStatusElement extends HTMLElement {
|
|
1153
|
+
mounted;
|
|
1154
|
+
connectedCallback() {
|
|
1155
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
1156
|
+
this.mounted = mountVoiceProviderStatus(this, this.getAttribute("path") ?? "/api/provider-status", {
|
|
1157
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1158
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
1159
|
+
title: this.getAttribute("title") ?? undefined
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
disconnectedCallback() {
|
|
1163
|
+
this.mounted?.close();
|
|
1164
|
+
this.mounted = undefined;
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
// src/vue/useVoiceProviderStatus.ts
|
|
1170
|
+
import { onUnmounted as onUnmounted4, ref as ref3, shallowRef as shallowRef3 } from "vue";
|
|
1171
|
+
var useVoiceProviderStatus = (path = "/api/provider-status", options = {}) => {
|
|
1172
|
+
const store = createVoiceProviderStatusStore(path, options);
|
|
1173
|
+
const error = ref3(null);
|
|
1174
|
+
const isLoading = ref3(false);
|
|
1175
|
+
const providers = shallowRef3([]);
|
|
1176
|
+
const updatedAt = ref3(undefined);
|
|
1177
|
+
const sync = () => {
|
|
1178
|
+
const snapshot = store.getSnapshot();
|
|
1179
|
+
error.value = snapshot.error;
|
|
1180
|
+
isLoading.value = snapshot.isLoading;
|
|
1181
|
+
providers.value = [...snapshot.providers];
|
|
1182
|
+
updatedAt.value = snapshot.updatedAt;
|
|
1183
|
+
};
|
|
1184
|
+
const unsubscribe = store.subscribe(sync);
|
|
1185
|
+
sync();
|
|
1186
|
+
store.refresh().catch(() => {});
|
|
1187
|
+
onUnmounted4(() => {
|
|
1188
|
+
unsubscribe();
|
|
1189
|
+
store.close();
|
|
1190
|
+
});
|
|
1191
|
+
return {
|
|
1192
|
+
error,
|
|
1193
|
+
isLoading,
|
|
1194
|
+
providers,
|
|
1195
|
+
refresh: store.refresh,
|
|
1196
|
+
updatedAt
|
|
1197
|
+
};
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1200
|
+
// src/vue/VoiceProviderStatus.ts
|
|
1201
|
+
var VoiceProviderStatus = defineComponent4({
|
|
1202
|
+
name: "VoiceProviderStatus",
|
|
1203
|
+
props: {
|
|
1204
|
+
class: {
|
|
1205
|
+
default: "",
|
|
1206
|
+
type: String
|
|
1207
|
+
},
|
|
1208
|
+
description: {
|
|
1209
|
+
default: undefined,
|
|
1210
|
+
type: String
|
|
1211
|
+
},
|
|
1212
|
+
intervalMs: {
|
|
1213
|
+
default: 5000,
|
|
1214
|
+
type: Number
|
|
1215
|
+
},
|
|
1216
|
+
path: {
|
|
1217
|
+
default: "/api/provider-status",
|
|
1218
|
+
type: String
|
|
1219
|
+
},
|
|
1220
|
+
title: {
|
|
1221
|
+
default: undefined,
|
|
1222
|
+
type: String
|
|
1223
|
+
}
|
|
1224
|
+
},
|
|
1225
|
+
setup(props) {
|
|
1226
|
+
const options = {
|
|
1227
|
+
description: props.description,
|
|
1228
|
+
intervalMs: props.intervalMs,
|
|
1229
|
+
title: props.title
|
|
1230
|
+
};
|
|
1231
|
+
const status = useVoiceProviderStatus(props.path, options);
|
|
1232
|
+
const model = computed3(() => createVoiceProviderStatusViewModel({
|
|
1233
|
+
error: status.error.value,
|
|
1234
|
+
isLoading: status.isLoading.value,
|
|
1235
|
+
providers: status.providers.value,
|
|
1236
|
+
updatedAt: status.updatedAt.value
|
|
1237
|
+
}, options));
|
|
1238
|
+
return () => h4("section", {
|
|
1239
|
+
class: [
|
|
1240
|
+
"absolute-voice-provider-status",
|
|
1241
|
+
`absolute-voice-provider-status--${model.value.status}`,
|
|
1242
|
+
props.class
|
|
1243
|
+
]
|
|
1244
|
+
}, [
|
|
1245
|
+
h4("header", { class: "absolute-voice-provider-status__header" }, [
|
|
1246
|
+
h4("span", { class: "absolute-voice-provider-status__eyebrow" }, model.value.title),
|
|
1247
|
+
h4("strong", { class: "absolute-voice-provider-status__label" }, model.value.label)
|
|
1248
|
+
]),
|
|
1249
|
+
h4("p", { class: "absolute-voice-provider-status__description" }, model.value.description),
|
|
1250
|
+
model.value.providers.length ? h4("div", { class: "absolute-voice-provider-status__providers" }, model.value.providers.map((provider) => h4("article", {
|
|
1251
|
+
class: [
|
|
1252
|
+
"absolute-voice-provider-status__provider",
|
|
1253
|
+
`absolute-voice-provider-status__provider--${provider.status}`
|
|
1254
|
+
],
|
|
1255
|
+
key: provider.provider
|
|
1256
|
+
}, [
|
|
1257
|
+
h4("header", [
|
|
1258
|
+
h4("strong", provider.label),
|
|
1259
|
+
h4("span", provider.status)
|
|
1260
|
+
]),
|
|
1261
|
+
h4("p", provider.detail),
|
|
1262
|
+
h4("dl", provider.rows.map((row) => h4("div", { key: row.label }, [
|
|
1263
|
+
h4("dt", row.label),
|
|
1264
|
+
h4("dd", row.value)
|
|
1265
|
+
])))
|
|
1266
|
+
]))) : h4("p", { class: "absolute-voice-provider-status__empty" }, "Run voice traffic to see provider health."),
|
|
1267
|
+
model.value.error ? h4("p", { class: "absolute-voice-provider-status__error" }, model.value.error) : null
|
|
1268
|
+
]);
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
// src/vue/VoiceRoutingStatus.ts
|
|
1272
|
+
import { computed as computed4, defineComponent as defineComponent5, h as h5 } from "vue";
|
|
1273
|
+
|
|
1274
|
+
// src/client/routingStatus.ts
|
|
1275
|
+
var fetchVoiceRoutingStatus = async (path = "/api/routing/latest", options = {}) => {
|
|
1276
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1277
|
+
const response = await fetchImpl(path);
|
|
1278
|
+
if (!response.ok) {
|
|
1279
|
+
throw new Error(`Voice routing status failed: HTTP ${response.status}`);
|
|
1280
|
+
}
|
|
1281
|
+
return await response.json();
|
|
1282
|
+
};
|
|
1283
|
+
var createVoiceRoutingStatusStore = (path = "/api/routing/latest", options = {}) => {
|
|
1284
|
+
const listeners = new Set;
|
|
1285
|
+
let closed = false;
|
|
1286
|
+
let timer;
|
|
1287
|
+
let snapshot = {
|
|
1288
|
+
decision: null,
|
|
1289
|
+
error: null,
|
|
1290
|
+
isLoading: false
|
|
1291
|
+
};
|
|
1292
|
+
const emit = () => {
|
|
1293
|
+
for (const listener of listeners) {
|
|
1294
|
+
listener();
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
const refresh = async () => {
|
|
1298
|
+
if (closed) {
|
|
1299
|
+
return snapshot.decision;
|
|
1300
|
+
}
|
|
1301
|
+
snapshot = {
|
|
1302
|
+
...snapshot,
|
|
1303
|
+
error: null,
|
|
1304
|
+
isLoading: true
|
|
1305
|
+
};
|
|
1306
|
+
emit();
|
|
1307
|
+
try {
|
|
1308
|
+
const decision = await fetchVoiceRoutingStatus(path, options);
|
|
1309
|
+
snapshot = {
|
|
1310
|
+
decision,
|
|
1311
|
+
error: null,
|
|
1312
|
+
isLoading: false,
|
|
1313
|
+
updatedAt: Date.now()
|
|
1314
|
+
};
|
|
1315
|
+
emit();
|
|
1316
|
+
return decision;
|
|
1317
|
+
} catch (error) {
|
|
1318
|
+
snapshot = {
|
|
1319
|
+
...snapshot,
|
|
1320
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1321
|
+
isLoading: false
|
|
1322
|
+
};
|
|
1323
|
+
emit();
|
|
1324
|
+
throw error;
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
const close = () => {
|
|
1328
|
+
closed = true;
|
|
1329
|
+
if (timer) {
|
|
1330
|
+
clearInterval(timer);
|
|
1331
|
+
timer = undefined;
|
|
1332
|
+
}
|
|
1333
|
+
listeners.clear();
|
|
1334
|
+
};
|
|
1335
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
1336
|
+
timer = setInterval(() => {
|
|
1337
|
+
refresh().catch(() => {});
|
|
1338
|
+
}, options.intervalMs);
|
|
1339
|
+
}
|
|
1340
|
+
return {
|
|
1341
|
+
close,
|
|
1342
|
+
getServerSnapshot: () => snapshot,
|
|
1343
|
+
getSnapshot: () => snapshot,
|
|
1344
|
+
refresh,
|
|
1345
|
+
subscribe: (listener) => {
|
|
1346
|
+
listeners.add(listener);
|
|
1347
|
+
return () => {
|
|
1348
|
+
listeners.delete(listener);
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
};
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
// src/client/routingStatusWidget.ts
|
|
1355
|
+
var DEFAULT_TITLE4 = "Voice Routing";
|
|
1356
|
+
var DEFAULT_DESCRIPTION4 = "Latest provider routing decision from the self-hosted trace store.";
|
|
1357
|
+
var escapeHtml5 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1358
|
+
var formatValue = (value, fallback = "None") => typeof value === "string" && value.trim() ? value : typeof value === "number" && Number.isFinite(value) ? String(value) : fallback;
|
|
1359
|
+
var createVoiceRoutingStatusViewModel = (snapshot, options = {}) => {
|
|
1360
|
+
const decision = snapshot.decision;
|
|
1361
|
+
const rows = decision ? [
|
|
1362
|
+
{ label: "Kind", value: decision.kind.toUpperCase() },
|
|
1363
|
+
{ label: "Policy", value: formatValue(decision.routing, "Unknown") },
|
|
1364
|
+
{ label: "Provider", value: formatValue(decision.provider, "Unknown") },
|
|
1365
|
+
{
|
|
1366
|
+
label: "Selected",
|
|
1367
|
+
value: formatValue(decision.selectedProvider, "Unknown")
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
label: "Fallback",
|
|
1371
|
+
value: formatValue(decision.fallbackProvider)
|
|
1372
|
+
},
|
|
1373
|
+
{ label: "Status", value: formatValue(decision.status, "unknown") },
|
|
1374
|
+
{
|
|
1375
|
+
label: "Latency budget",
|
|
1376
|
+
value: typeof decision.latencyBudgetMs === "number" ? `${decision.latencyBudgetMs}ms` : "None"
|
|
1377
|
+
}
|
|
1378
|
+
] : [];
|
|
1379
|
+
return {
|
|
1380
|
+
decision,
|
|
1381
|
+
description: options.description ?? DEFAULT_DESCRIPTION4,
|
|
1382
|
+
error: snapshot.error,
|
|
1383
|
+
isLoading: snapshot.isLoading,
|
|
1384
|
+
label: snapshot.error ? "Unavailable" : decision ? `${formatValue(decision.kind).toUpperCase()} ${formatValue(decision.status, "unknown")}` : snapshot.isLoading ? "Checking" : "No routing yet",
|
|
1385
|
+
rows,
|
|
1386
|
+
status: snapshot.error ? "error" : decision ? "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
1387
|
+
title: options.title ?? DEFAULT_TITLE4,
|
|
1388
|
+
updatedAt: snapshot.updatedAt
|
|
1389
|
+
};
|
|
1390
|
+
};
|
|
1391
|
+
var renderVoiceRoutingStatusHTML = (snapshot, options = {}) => {
|
|
1392
|
+
const model = createVoiceRoutingStatusViewModel(snapshot, options);
|
|
1393
|
+
const rows = model.rows.length ? `<div class="absolute-voice-routing-status__grid">${model.rows.map((row) => `<div>
|
|
1394
|
+
<span>${escapeHtml5(row.label)}</span>
|
|
1395
|
+
<strong>${escapeHtml5(row.value)}</strong>
|
|
1396
|
+
</div>`).join("")}</div>` : '<p class="absolute-voice-routing-status__empty">Start a voice session to see the selected provider.</p>';
|
|
1397
|
+
return `<section class="absolute-voice-routing-status absolute-voice-routing-status--${escapeHtml5(model.status)}">
|
|
1398
|
+
<header class="absolute-voice-routing-status__header">
|
|
1399
|
+
<span class="absolute-voice-routing-status__eyebrow">${escapeHtml5(model.title)}</span>
|
|
1400
|
+
<strong class="absolute-voice-routing-status__label">${escapeHtml5(model.label)}</strong>
|
|
1401
|
+
</header>
|
|
1402
|
+
<p class="absolute-voice-routing-status__description">${escapeHtml5(model.description)}</p>
|
|
1403
|
+
${rows}
|
|
1404
|
+
${model.error ? `<p class="absolute-voice-routing-status__error">${escapeHtml5(model.error)}</p>` : ""}
|
|
1405
|
+
</section>`;
|
|
1406
|
+
};
|
|
1407
|
+
var getVoiceRoutingStatusCSS = () => `.absolute-voice-routing-status{border:1px solid #d8d2c4;border-radius:20px;background:#fffaf0;color:#16130d;padding:18px;box-shadow:0 18px 40px rgba(47,37,18,.12);font-family:inherit}.absolute-voice-routing-status--error{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-routing-status__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-routing-status__eyebrow{color:#73664f;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-routing-status__label{font-size:24px;line-height:1}.absolute-voice-routing-status__description{color:#514733;margin:12px 0 0}.absolute-voice-routing-status__grid{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin-top:14px}.absolute-voice-routing-status__grid div{background:#fff;border:1px solid #eee4d2;border-radius:14px;padding:10px 12px}.absolute-voice-routing-status__grid span{color:#655944;display:block;font-size:12px;margin-bottom:4px}.absolute-voice-routing-status__grid strong{overflow-wrap:anywhere}.absolute-voice-routing-status__empty{color:#655944;margin:14px 0 0}.absolute-voice-routing-status__error{color:#9f1239;font-weight:700}`;
|
|
1408
|
+
var mountVoiceRoutingStatus = (element, path = "/api/routing/latest", options = {}) => {
|
|
1409
|
+
const store = createVoiceRoutingStatusStore(path, options);
|
|
1410
|
+
const render = () => {
|
|
1411
|
+
element.innerHTML = renderVoiceRoutingStatusHTML(store.getSnapshot(), options);
|
|
1412
|
+
};
|
|
1413
|
+
const unsubscribe = store.subscribe(render);
|
|
1414
|
+
render();
|
|
1415
|
+
store.refresh().catch(() => {});
|
|
1416
|
+
return {
|
|
1417
|
+
close: () => {
|
|
1418
|
+
unsubscribe();
|
|
1419
|
+
store.close();
|
|
1420
|
+
},
|
|
1421
|
+
refresh: store.refresh
|
|
1422
|
+
};
|
|
1423
|
+
};
|
|
1424
|
+
var defineVoiceRoutingStatusElement = (tagName = "absolute-voice-routing-status") => {
|
|
1425
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
customElements.define(tagName, class AbsoluteVoiceRoutingStatusElement extends HTMLElement {
|
|
1429
|
+
mounted;
|
|
1430
|
+
connectedCallback() {
|
|
1431
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
1432
|
+
this.mounted = mountVoiceRoutingStatus(this, this.getAttribute("path") ?? "/api/routing/latest", {
|
|
1433
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1434
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
1435
|
+
title: this.getAttribute("title") ?? undefined
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
disconnectedCallback() {
|
|
1439
|
+
this.mounted?.close();
|
|
1440
|
+
this.mounted = undefined;
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1445
|
+
// src/vue/useVoiceRoutingStatus.ts
|
|
1446
|
+
import { onUnmounted as onUnmounted5, ref as ref4, shallowRef as shallowRef4 } from "vue";
|
|
1447
|
+
var useVoiceRoutingStatus = (path = "/api/routing/latest", options = {}) => {
|
|
1448
|
+
const store = createVoiceRoutingStatusStore(path, options);
|
|
1449
|
+
const decision = shallowRef4(null);
|
|
1450
|
+
const error = ref4(null);
|
|
1451
|
+
const isLoading = ref4(false);
|
|
1452
|
+
const updatedAt = ref4(undefined);
|
|
1453
|
+
const sync = () => {
|
|
1454
|
+
const snapshot = store.getSnapshot();
|
|
1455
|
+
decision.value = snapshot.decision;
|
|
1456
|
+
error.value = snapshot.error;
|
|
1457
|
+
isLoading.value = snapshot.isLoading;
|
|
1458
|
+
updatedAt.value = snapshot.updatedAt;
|
|
1459
|
+
};
|
|
1460
|
+
const unsubscribe = store.subscribe(sync);
|
|
1461
|
+
sync();
|
|
1462
|
+
store.refresh().catch(() => {});
|
|
1463
|
+
onUnmounted5(() => {
|
|
1464
|
+
unsubscribe();
|
|
1465
|
+
store.close();
|
|
1466
|
+
});
|
|
1467
|
+
return {
|
|
1468
|
+
decision,
|
|
1469
|
+
error,
|
|
1470
|
+
isLoading,
|
|
1471
|
+
refresh: store.refresh,
|
|
1472
|
+
updatedAt
|
|
1473
|
+
};
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
// src/vue/VoiceRoutingStatus.ts
|
|
1477
|
+
var VoiceRoutingStatus = defineComponent5({
|
|
1478
|
+
name: "VoiceRoutingStatus",
|
|
1479
|
+
props: {
|
|
1480
|
+
class: {
|
|
1481
|
+
default: "",
|
|
1482
|
+
type: String
|
|
1483
|
+
},
|
|
1484
|
+
description: {
|
|
1485
|
+
default: undefined,
|
|
1486
|
+
type: String
|
|
1487
|
+
},
|
|
1488
|
+
intervalMs: {
|
|
1489
|
+
default: 5000,
|
|
1490
|
+
type: Number
|
|
1491
|
+
},
|
|
1492
|
+
path: {
|
|
1493
|
+
default: "/api/routing/latest",
|
|
1494
|
+
type: String
|
|
1495
|
+
},
|
|
1496
|
+
title: {
|
|
1497
|
+
default: undefined,
|
|
1498
|
+
type: String
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
setup(props) {
|
|
1502
|
+
const options = {
|
|
1503
|
+
description: props.description,
|
|
1504
|
+
intervalMs: props.intervalMs,
|
|
1505
|
+
title: props.title
|
|
1506
|
+
};
|
|
1507
|
+
const status = useVoiceRoutingStatus(props.path, options);
|
|
1508
|
+
const model = computed4(() => createVoiceRoutingStatusViewModel({
|
|
1509
|
+
decision: status.decision.value,
|
|
1510
|
+
error: status.error.value,
|
|
1511
|
+
isLoading: status.isLoading.value,
|
|
1512
|
+
updatedAt: status.updatedAt.value
|
|
1513
|
+
}, options));
|
|
1514
|
+
return () => h5("section", {
|
|
1515
|
+
class: [
|
|
1516
|
+
"absolute-voice-routing-status",
|
|
1517
|
+
`absolute-voice-routing-status--${model.value.status}`,
|
|
1518
|
+
props.class
|
|
1519
|
+
]
|
|
1520
|
+
}, [
|
|
1521
|
+
h5("header", { class: "absolute-voice-routing-status__header" }, [
|
|
1522
|
+
h5("span", { class: "absolute-voice-routing-status__eyebrow" }, model.value.title),
|
|
1523
|
+
h5("strong", { class: "absolute-voice-routing-status__label" }, model.value.label)
|
|
1524
|
+
]),
|
|
1525
|
+
h5("p", { class: "absolute-voice-routing-status__description" }, model.value.description),
|
|
1526
|
+
model.value.rows.length ? h5("div", { class: "absolute-voice-routing-status__grid" }, model.value.rows.map((row) => h5("div", { key: row.label }, [
|
|
1527
|
+
h5("span", row.label),
|
|
1528
|
+
h5("strong", row.value)
|
|
1529
|
+
]))) : h5("p", { class: "absolute-voice-routing-status__empty" }, "Start a voice session to see the selected provider."),
|
|
1530
|
+
model.value.error ? h5("p", { class: "absolute-voice-routing-status__error" }, model.value.error) : null
|
|
1531
|
+
]);
|
|
1532
|
+
}
|
|
1533
|
+
});
|
|
1534
|
+
// src/vue/VoiceTurnQuality.ts
|
|
1535
|
+
import { computed as computed5, defineComponent as defineComponent6, h as h6 } from "vue";
|
|
1536
|
+
|
|
1537
|
+
// src/client/turnQuality.ts
|
|
1538
|
+
var fetchVoiceTurnQuality = async (path = "/api/turn-quality", options = {}) => {
|
|
1539
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1540
|
+
const response = await fetchImpl(path);
|
|
1541
|
+
if (!response.ok) {
|
|
1542
|
+
throw new Error(`Voice turn quality failed: HTTP ${response.status}`);
|
|
1543
|
+
}
|
|
1544
|
+
return await response.json();
|
|
1545
|
+
};
|
|
1546
|
+
var createVoiceTurnQualityStore = (path = "/api/turn-quality", options = {}) => {
|
|
1547
|
+
const listeners = new Set;
|
|
1548
|
+
let closed = false;
|
|
1549
|
+
let timer;
|
|
1550
|
+
let snapshot = {
|
|
1551
|
+
error: null,
|
|
1552
|
+
isLoading: false
|
|
1553
|
+
};
|
|
1554
|
+
const emit = () => {
|
|
1555
|
+
for (const listener of listeners) {
|
|
1556
|
+
listener();
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
const refresh = async () => {
|
|
1560
|
+
if (closed) {
|
|
1561
|
+
return snapshot.report;
|
|
1562
|
+
}
|
|
1563
|
+
snapshot = {
|
|
1564
|
+
...snapshot,
|
|
1565
|
+
error: null,
|
|
1566
|
+
isLoading: true
|
|
1567
|
+
};
|
|
1568
|
+
emit();
|
|
1569
|
+
try {
|
|
1570
|
+
const report = await fetchVoiceTurnQuality(path, options);
|
|
1571
|
+
snapshot = {
|
|
1572
|
+
error: null,
|
|
1573
|
+
isLoading: false,
|
|
1574
|
+
report,
|
|
1575
|
+
updatedAt: Date.now()
|
|
1576
|
+
};
|
|
1577
|
+
emit();
|
|
1578
|
+
return report;
|
|
1579
|
+
} catch (error) {
|
|
1580
|
+
snapshot = {
|
|
1581
|
+
...snapshot,
|
|
1582
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1583
|
+
isLoading: false
|
|
1584
|
+
};
|
|
1585
|
+
emit();
|
|
1586
|
+
throw error;
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
const close = () => {
|
|
1590
|
+
closed = true;
|
|
1591
|
+
if (timer) {
|
|
1592
|
+
clearInterval(timer);
|
|
1593
|
+
timer = undefined;
|
|
1594
|
+
}
|
|
1595
|
+
listeners.clear();
|
|
1596
|
+
};
|
|
1597
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
1598
|
+
timer = setInterval(() => {
|
|
1599
|
+
refresh().catch(() => {});
|
|
1600
|
+
}, options.intervalMs);
|
|
1601
|
+
}
|
|
1602
|
+
return {
|
|
1603
|
+
close,
|
|
1604
|
+
getServerSnapshot: () => snapshot,
|
|
1605
|
+
getSnapshot: () => snapshot,
|
|
1606
|
+
refresh,
|
|
1607
|
+
subscribe: (listener) => {
|
|
1608
|
+
listeners.add(listener);
|
|
1609
|
+
return () => {
|
|
1610
|
+
listeners.delete(listener);
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1616
|
+
// src/client/turnQualityWidget.ts
|
|
1617
|
+
var DEFAULT_TITLE5 = "Turn Quality";
|
|
1618
|
+
var DEFAULT_DESCRIPTION5 = "Per-turn STT confidence, fallback selection, corrections, and transcript coverage.";
|
|
1619
|
+
var escapeHtml6 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1620
|
+
var formatConfidence = (value) => typeof value === "number" ? `${Math.round(value * 100)}%` : "n/a";
|
|
1621
|
+
var formatMaybe = (value) => value === undefined || value === "" ? "n/a" : String(value);
|
|
1622
|
+
var getTurnDetail = (turn) => {
|
|
1623
|
+
if (turn.status === "fail") {
|
|
1624
|
+
return "Empty or unusable committed turn; inspect transcripts and adapter events.";
|
|
1625
|
+
}
|
|
1626
|
+
if (turn.fallbackUsed) {
|
|
1627
|
+
return `Fallback STT selected${turn.fallbackSelectionReason ? ` by ${turn.fallbackSelectionReason}` : ""}.`;
|
|
1628
|
+
}
|
|
1629
|
+
if (turn.correctionChanged) {
|
|
1630
|
+
return `Correction changed the turn${turn.correctionProvider ? ` via ${turn.correctionProvider}` : ""}.`;
|
|
1631
|
+
}
|
|
1632
|
+
if (turn.status === "warn") {
|
|
1633
|
+
return "Turn completed with quality warnings.";
|
|
1634
|
+
}
|
|
1635
|
+
if (turn.status === "unknown") {
|
|
1636
|
+
return "No quality diagnostics were recorded for this turn.";
|
|
1637
|
+
}
|
|
1638
|
+
return "Turn quality looks healthy.";
|
|
1639
|
+
};
|
|
1640
|
+
var createVoiceTurnQualityViewModel = (snapshot, options = {}) => {
|
|
1641
|
+
const turns = (snapshot.report?.turns ?? []).map((turn) => ({
|
|
1642
|
+
...turn,
|
|
1643
|
+
detail: getTurnDetail(turn),
|
|
1644
|
+
label: turn.text || "Empty turn",
|
|
1645
|
+
rows: [
|
|
1646
|
+
{ label: "Source", value: turn.source ?? "unknown" },
|
|
1647
|
+
{ label: "Confidence", value: formatConfidence(turn.averageConfidence) },
|
|
1648
|
+
{ label: "Fallback", value: turn.fallbackUsed ? "Yes" : "No" },
|
|
1649
|
+
{ label: "Correction", value: turn.correctionChanged ? "Changed" : "None" },
|
|
1650
|
+
{ label: "Transcripts", value: `${turn.selectedTranscriptCount} selected` },
|
|
1651
|
+
{ label: "Cost", value: formatMaybe(turn.costUnits) }
|
|
1652
|
+
]
|
|
1653
|
+
}));
|
|
1654
|
+
const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
|
|
1655
|
+
const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
|
|
1656
|
+
return {
|
|
1657
|
+
description: options.description ?? DEFAULT_DESCRIPTION5,
|
|
1658
|
+
error: snapshot.error,
|
|
1659
|
+
isLoading: snapshot.isLoading,
|
|
1660
|
+
label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} failed` : warningCount > 0 ? `${warningCount} warnings` : `${turns.length} healthy` : snapshot.isLoading ? "Checking" : "No turns",
|
|
1661
|
+
status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
1662
|
+
title: options.title ?? DEFAULT_TITLE5,
|
|
1663
|
+
turns,
|
|
1664
|
+
updatedAt: snapshot.updatedAt
|
|
1665
|
+
};
|
|
1666
|
+
};
|
|
1667
|
+
var renderVoiceTurnQualityHTML = (snapshot, options = {}) => {
|
|
1668
|
+
const model = createVoiceTurnQualityViewModel(snapshot, options);
|
|
1669
|
+
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--${escapeHtml6(turn.status)}">
|
|
1670
|
+
<header>
|
|
1671
|
+
<strong>${escapeHtml6(turn.label)}</strong>
|
|
1672
|
+
<span>${escapeHtml6(turn.status)}</span>
|
|
1673
|
+
</header>
|
|
1674
|
+
<p>${escapeHtml6(turn.detail)}</p>
|
|
1675
|
+
<dl>${turn.rows.map((row) => `<div>
|
|
1676
|
+
<dt>${escapeHtml6(row.label)}</dt>
|
|
1677
|
+
<dd>${escapeHtml6(row.value)}</dd>
|
|
1678
|
+
</div>`).join("")}</dl>
|
|
1679
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-turn-quality__empty">Complete a voice turn to see STT quality diagnostics.</p>';
|
|
1680
|
+
return `<section class="absolute-voice-turn-quality absolute-voice-turn-quality--${escapeHtml6(model.status)}">
|
|
1681
|
+
<header class="absolute-voice-turn-quality__header">
|
|
1682
|
+
<span class="absolute-voice-turn-quality__eyebrow">${escapeHtml6(model.title)}</span>
|
|
1683
|
+
<strong class="absolute-voice-turn-quality__label">${escapeHtml6(model.label)}</strong>
|
|
1684
|
+
</header>
|
|
1685
|
+
<p class="absolute-voice-turn-quality__description">${escapeHtml6(model.description)}</p>
|
|
1686
|
+
${turns}
|
|
1687
|
+
${model.error ? `<p class="absolute-voice-turn-quality__error">${escapeHtml6(model.error)}</p>` : ""}
|
|
1688
|
+
</section>`;
|
|
1689
|
+
};
|
|
1690
|
+
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}`;
|
|
1691
|
+
var mountVoiceTurnQuality = (element, path = "/api/turn-quality", options = {}) => {
|
|
1692
|
+
const store = createVoiceTurnQualityStore(path, options);
|
|
1693
|
+
const render = () => {
|
|
1694
|
+
element.innerHTML = renderVoiceTurnQualityHTML(store.getSnapshot(), options);
|
|
1695
|
+
};
|
|
1696
|
+
const unsubscribe = store.subscribe(render);
|
|
1697
|
+
render();
|
|
1698
|
+
store.refresh().catch(() => {});
|
|
1699
|
+
return {
|
|
1700
|
+
close: () => {
|
|
1701
|
+
unsubscribe();
|
|
1702
|
+
store.close();
|
|
1703
|
+
},
|
|
1704
|
+
refresh: store.refresh
|
|
1705
|
+
};
|
|
1706
|
+
};
|
|
1707
|
+
var defineVoiceTurnQualityElement = (tagName = "absolute-voice-turn-quality") => {
|
|
1708
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1709
|
+
return;
|
|
1710
|
+
}
|
|
1711
|
+
customElements.define(tagName, class AbsoluteVoiceTurnQualityElement extends HTMLElement {
|
|
1712
|
+
mounted;
|
|
1713
|
+
connectedCallback() {
|
|
1714
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
1715
|
+
this.mounted = mountVoiceTurnQuality(this, this.getAttribute("path") ?? "/api/turn-quality", {
|
|
1716
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1717
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
1718
|
+
title: this.getAttribute("title") ?? undefined
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
disconnectedCallback() {
|
|
1722
|
+
this.mounted?.close();
|
|
1723
|
+
this.mounted = undefined;
|
|
1724
|
+
}
|
|
1725
|
+
});
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
// src/vue/useVoiceTurnQuality.ts
|
|
1729
|
+
import { onUnmounted as onUnmounted6, shallowRef as shallowRef5 } from "vue";
|
|
1730
|
+
var useVoiceTurnQuality = (path = "/api/turn-quality", options = {}) => {
|
|
1731
|
+
const store = createVoiceTurnQualityStore(path, options);
|
|
1732
|
+
const error = shallowRef5(null);
|
|
1733
|
+
const isLoading = shallowRef5(false);
|
|
1734
|
+
const report = shallowRef5();
|
|
1735
|
+
const updatedAt = shallowRef5(undefined);
|
|
1736
|
+
const sync = () => {
|
|
1737
|
+
const snapshot = store.getSnapshot();
|
|
1738
|
+
error.value = snapshot.error;
|
|
1739
|
+
isLoading.value = snapshot.isLoading;
|
|
1740
|
+
report.value = snapshot.report;
|
|
1741
|
+
updatedAt.value = snapshot.updatedAt;
|
|
1742
|
+
};
|
|
1743
|
+
const unsubscribe = store.subscribe(sync);
|
|
1744
|
+
sync();
|
|
1745
|
+
store.refresh().catch(() => {});
|
|
1746
|
+
onUnmounted6(() => {
|
|
1747
|
+
unsubscribe();
|
|
1748
|
+
store.close();
|
|
1749
|
+
});
|
|
1750
|
+
return { error, isLoading, refresh: store.refresh, report, updatedAt };
|
|
1751
|
+
};
|
|
1752
|
+
|
|
1753
|
+
// src/vue/VoiceTurnQuality.ts
|
|
1754
|
+
var VoiceTurnQuality = defineComponent6({
|
|
1755
|
+
name: "VoiceTurnQuality",
|
|
1756
|
+
props: {
|
|
1757
|
+
class: { default: "", type: String },
|
|
1758
|
+
description: { default: undefined, type: String },
|
|
1759
|
+
intervalMs: { default: 5000, type: Number },
|
|
1760
|
+
path: { default: "/api/turn-quality", type: String },
|
|
1761
|
+
title: { default: undefined, type: String }
|
|
1762
|
+
},
|
|
1763
|
+
setup(props) {
|
|
1764
|
+
const options = {
|
|
1765
|
+
description: props.description,
|
|
1766
|
+
intervalMs: props.intervalMs,
|
|
1767
|
+
title: props.title
|
|
1768
|
+
};
|
|
1769
|
+
const quality = useVoiceTurnQuality(props.path, options);
|
|
1770
|
+
const model = computed5(() => createVoiceTurnQualityViewModel({
|
|
1771
|
+
error: quality.error.value,
|
|
1772
|
+
isLoading: quality.isLoading.value,
|
|
1773
|
+
report: quality.report.value,
|
|
1774
|
+
updatedAt: quality.updatedAt.value
|
|
1775
|
+
}, options));
|
|
1776
|
+
return () => h6("section", {
|
|
1777
|
+
class: [
|
|
1778
|
+
"absolute-voice-turn-quality",
|
|
1779
|
+
`absolute-voice-turn-quality--${model.value.status}`,
|
|
1780
|
+
props.class
|
|
1781
|
+
]
|
|
1782
|
+
}, [
|
|
1783
|
+
h6("header", { class: "absolute-voice-turn-quality__header" }, [
|
|
1784
|
+
h6("span", { class: "absolute-voice-turn-quality__eyebrow" }, model.value.title),
|
|
1785
|
+
h6("strong", { class: "absolute-voice-turn-quality__label" }, model.value.label)
|
|
1786
|
+
]),
|
|
1787
|
+
h6("p", { class: "absolute-voice-turn-quality__description" }, model.value.description),
|
|
1788
|
+
model.value.turns.length ? h6("div", { class: "absolute-voice-turn-quality__turns" }, model.value.turns.map((turn) => h6("article", {
|
|
1789
|
+
class: [
|
|
1790
|
+
"absolute-voice-turn-quality__turn",
|
|
1791
|
+
`absolute-voice-turn-quality__turn--${turn.status}`
|
|
1792
|
+
],
|
|
1793
|
+
key: `${turn.sessionId}:${turn.turnId}`
|
|
1794
|
+
}, [
|
|
1795
|
+
h6("header", [
|
|
1796
|
+
h6("strong", turn.label),
|
|
1797
|
+
h6("span", turn.status)
|
|
1798
|
+
]),
|
|
1799
|
+
h6("p", turn.detail),
|
|
1800
|
+
h6("dl", turn.rows.map((row) => h6("div", { key: row.label }, [
|
|
1801
|
+
h6("dt", row.label),
|
|
1802
|
+
h6("dd", row.value)
|
|
1803
|
+
])))
|
|
1804
|
+
]))) : h6("p", { class: "absolute-voice-turn-quality__empty" }, "Complete a voice turn to see STT quality diagnostics."),
|
|
1805
|
+
model.value.error ? h6("p", { class: "absolute-voice-turn-quality__error" }, model.value.error) : null
|
|
1806
|
+
]);
|
|
1807
|
+
}
|
|
1808
|
+
});
|
|
1809
|
+
// src/vue/useVoiceStream.ts
|
|
1810
|
+
import { onUnmounted as onUnmounted7, ref as ref5, shallowRef as shallowRef6 } from "vue";
|
|
74
1811
|
|
|
75
1812
|
// src/client/actions.ts
|
|
76
1813
|
var normalizeErrorMessage = (value) => {
|
|
@@ -120,6 +1857,12 @@ var serverMessageToAction = (message) => {
|
|
|
120
1857
|
sessionId: message.sessionId,
|
|
121
1858
|
type: "complete"
|
|
122
1859
|
};
|
|
1860
|
+
case "call_lifecycle":
|
|
1861
|
+
return {
|
|
1862
|
+
event: message.event,
|
|
1863
|
+
sessionId: message.sessionId,
|
|
1864
|
+
type: "call_lifecycle"
|
|
1865
|
+
};
|
|
123
1866
|
case "error":
|
|
124
1867
|
return {
|
|
125
1868
|
message: normalizeErrorMessage(message.message),
|
|
@@ -163,7 +1906,7 @@ var DEFAULT_SCENARIO_QUERY_PARAM = "scenarioId";
|
|
|
163
1906
|
var noop = () => {};
|
|
164
1907
|
var noopUnsubscribe = () => noop;
|
|
165
1908
|
var NOOP_CONNECTION = {
|
|
166
|
-
|
|
1909
|
+
callControl: noop,
|
|
167
1910
|
close: noop,
|
|
168
1911
|
endTurn: noop,
|
|
169
1912
|
getReadyState: () => WS_CLOSED,
|
|
@@ -171,6 +1914,7 @@ var NOOP_CONNECTION = {
|
|
|
171
1914
|
getSessionId: () => "",
|
|
172
1915
|
send: noop,
|
|
173
1916
|
sendAudio: noop,
|
|
1917
|
+
start: () => {},
|
|
174
1918
|
subscribe: noopUnsubscribe
|
|
175
1919
|
};
|
|
176
1920
|
var createSessionId = () => crypto.randomUUID();
|
|
@@ -192,6 +1936,7 @@ var isVoiceServerMessage = (value) => {
|
|
|
192
1936
|
switch (value.type) {
|
|
193
1937
|
case "audio":
|
|
194
1938
|
case "assistant":
|
|
1939
|
+
case "call_lifecycle":
|
|
195
1940
|
case "complete":
|
|
196
1941
|
case "error":
|
|
197
1942
|
case "final":
|
|
@@ -332,6 +2077,12 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
332
2077
|
const endTurn = () => {
|
|
333
2078
|
send({ type: "end_turn" });
|
|
334
2079
|
};
|
|
2080
|
+
const callControl = (message) => {
|
|
2081
|
+
send({
|
|
2082
|
+
...message,
|
|
2083
|
+
type: "call_control"
|
|
2084
|
+
});
|
|
2085
|
+
};
|
|
335
2086
|
const close = () => {
|
|
336
2087
|
clearTimers();
|
|
337
2088
|
if (state.ws) {
|
|
@@ -349,7 +2100,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
349
2100
|
};
|
|
350
2101
|
connect();
|
|
351
2102
|
return {
|
|
352
|
-
|
|
2103
|
+
callControl,
|
|
353
2104
|
close,
|
|
354
2105
|
endTurn,
|
|
355
2106
|
getReadyState: () => state.ws?.readyState ?? WS_CLOSED,
|
|
@@ -357,6 +2108,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
357
2108
|
getSessionId: () => state.sessionId,
|
|
358
2109
|
send,
|
|
359
2110
|
sendAudio,
|
|
2111
|
+
start,
|
|
360
2112
|
subscribe
|
|
361
2113
|
};
|
|
362
2114
|
};
|
|
@@ -365,6 +2117,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
365
2117
|
var createInitialState = () => ({
|
|
366
2118
|
assistantAudio: [],
|
|
367
2119
|
assistantTexts: [],
|
|
2120
|
+
call: null,
|
|
368
2121
|
error: null,
|
|
369
2122
|
isConnected: false,
|
|
370
2123
|
scenarioId: null,
|
|
@@ -408,6 +2161,20 @@ var createVoiceStreamStore = () => {
|
|
|
408
2161
|
status: "completed"
|
|
409
2162
|
};
|
|
410
2163
|
break;
|
|
2164
|
+
case "call_lifecycle":
|
|
2165
|
+
state = {
|
|
2166
|
+
...state,
|
|
2167
|
+
call: {
|
|
2168
|
+
...state.call,
|
|
2169
|
+
disposition: action.event.type === "end" ? action.event.disposition : state.call?.disposition,
|
|
2170
|
+
endedAt: action.event.type === "end" ? action.event.at : state.call?.endedAt,
|
|
2171
|
+
events: [...state.call?.events ?? [], action.event],
|
|
2172
|
+
lastEventAt: action.event.at,
|
|
2173
|
+
startedAt: state.call?.startedAt ?? action.event.at
|
|
2174
|
+
},
|
|
2175
|
+
sessionId: action.sessionId
|
|
2176
|
+
};
|
|
2177
|
+
break;
|
|
411
2178
|
case "connected":
|
|
412
2179
|
state = {
|
|
413
2180
|
...state,
|
|
@@ -494,6 +2261,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
494
2261
|
}
|
|
495
2262
|
});
|
|
496
2263
|
return {
|
|
2264
|
+
callControl(message) {
|
|
2265
|
+
connection.callControl(message);
|
|
2266
|
+
},
|
|
497
2267
|
close() {
|
|
498
2268
|
unsubscribeConnection();
|
|
499
2269
|
connection.close();
|
|
@@ -537,6 +2307,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
537
2307
|
get assistantAudio() {
|
|
538
2308
|
return store.getSnapshot().assistantAudio;
|
|
539
2309
|
},
|
|
2310
|
+
get call() {
|
|
2311
|
+
return store.getSnapshot().call;
|
|
2312
|
+
},
|
|
540
2313
|
sendAudio(audio) {
|
|
541
2314
|
connection.sendAudio(audio);
|
|
542
2315
|
},
|
|
@@ -552,17 +2325,19 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
552
2325
|
// src/vue/useVoiceStream.ts
|
|
553
2326
|
var useVoiceStream = (path, options = {}) => {
|
|
554
2327
|
const stream = createVoiceStream(path, options);
|
|
555
|
-
const assistantAudio =
|
|
556
|
-
const assistantTexts =
|
|
557
|
-
const
|
|
558
|
-
const
|
|
559
|
-
const
|
|
560
|
-
const
|
|
561
|
-
const
|
|
562
|
-
const
|
|
2328
|
+
const assistantAudio = shallowRef6([]);
|
|
2329
|
+
const assistantTexts = shallowRef6([]);
|
|
2330
|
+
const call = shallowRef6(null);
|
|
2331
|
+
const error = ref5(null);
|
|
2332
|
+
const isConnected = ref5(false);
|
|
2333
|
+
const partial = ref5("");
|
|
2334
|
+
const sessionId = ref5(stream.sessionId);
|
|
2335
|
+
const status = ref5(stream.status);
|
|
2336
|
+
const turns = shallowRef6([]);
|
|
563
2337
|
const sync = () => {
|
|
564
2338
|
assistantAudio.value = [...stream.assistantAudio];
|
|
565
2339
|
assistantTexts.value = [...stream.assistantTexts];
|
|
2340
|
+
call.value = stream.call;
|
|
566
2341
|
error.value = stream.error;
|
|
567
2342
|
isConnected.value = stream.isConnected;
|
|
568
2343
|
partial.value = stream.partial;
|
|
@@ -576,10 +2351,12 @@ var useVoiceStream = (path, options = {}) => {
|
|
|
576
2351
|
unsubscribe();
|
|
577
2352
|
stream.close();
|
|
578
2353
|
};
|
|
579
|
-
|
|
2354
|
+
onUnmounted7(destroy);
|
|
580
2355
|
return {
|
|
581
2356
|
assistantAudio,
|
|
582
2357
|
assistantTexts,
|
|
2358
|
+
call,
|
|
2359
|
+
callControl: (message) => stream.callControl(message),
|
|
583
2360
|
close: () => destroy(),
|
|
584
2361
|
endTurn: () => stream.endTurn(),
|
|
585
2362
|
error,
|
|
@@ -592,7 +2369,7 @@ var useVoiceStream = (path, options = {}) => {
|
|
|
592
2369
|
};
|
|
593
2370
|
};
|
|
594
2371
|
// src/vue/useVoiceController.ts
|
|
595
|
-
import { onUnmounted as
|
|
2372
|
+
import { onUnmounted as onUnmounted8, ref as ref6, shallowRef as shallowRef7 } from "vue";
|
|
596
2373
|
|
|
597
2374
|
// src/client/htmx.ts
|
|
598
2375
|
var DEFAULT_EVENT_NAME = "voice-refresh";
|
|
@@ -1056,6 +2833,7 @@ var resolveVoiceRuntimePreset = (name = "default") => {
|
|
|
1056
2833
|
var createInitialState2 = (stream) => ({
|
|
1057
2834
|
assistantAudio: [...stream.assistantAudio],
|
|
1058
2835
|
assistantTexts: [...stream.assistantTexts],
|
|
2836
|
+
call: stream.call,
|
|
1059
2837
|
error: stream.error,
|
|
1060
2838
|
isConnected: stream.isConnected,
|
|
1061
2839
|
isRecording: false,
|
|
@@ -1085,6 +2863,7 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1085
2863
|
...state,
|
|
1086
2864
|
assistantAudio: [...stream.assistantAudio],
|
|
1087
2865
|
assistantTexts: [...stream.assistantTexts],
|
|
2866
|
+
call: stream.call,
|
|
1088
2867
|
error: stream.error,
|
|
1089
2868
|
isConnected: stream.isConnected,
|
|
1090
2869
|
partial: stream.partial,
|
|
@@ -1162,6 +2941,7 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1162
2941
|
bindHTMX(bindingOptions) {
|
|
1163
2942
|
return bindVoiceHTMX(stream, bindingOptions);
|
|
1164
2943
|
},
|
|
2944
|
+
callControl: (message) => stream.callControl(message),
|
|
1165
2945
|
close,
|
|
1166
2946
|
endTurn: () => stream.endTurn(),
|
|
1167
2947
|
get error() {
|
|
@@ -1214,6 +2994,9 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1214
2994
|
},
|
|
1215
2995
|
get assistantAudio() {
|
|
1216
2996
|
return state.assistantAudio;
|
|
2997
|
+
},
|
|
2998
|
+
get call() {
|
|
2999
|
+
return state.call;
|
|
1217
3000
|
}
|
|
1218
3001
|
};
|
|
1219
3002
|
};
|
|
@@ -1221,16 +3004,16 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1221
3004
|
// src/vue/useVoiceController.ts
|
|
1222
3005
|
var useVoiceController = (path, options = {}) => {
|
|
1223
3006
|
const controller = createVoiceController(path, options);
|
|
1224
|
-
const assistantAudio =
|
|
1225
|
-
const assistantTexts =
|
|
1226
|
-
const error =
|
|
1227
|
-
const isConnected =
|
|
1228
|
-
const isRecording =
|
|
1229
|
-
const partial =
|
|
1230
|
-
const recordingError =
|
|
1231
|
-
const sessionId =
|
|
1232
|
-
const status =
|
|
1233
|
-
const turns =
|
|
3007
|
+
const assistantAudio = shallowRef7([]);
|
|
3008
|
+
const assistantTexts = shallowRef7([]);
|
|
3009
|
+
const error = ref6(null);
|
|
3010
|
+
const isConnected = ref6(false);
|
|
3011
|
+
const isRecording = ref6(false);
|
|
3012
|
+
const partial = ref6("");
|
|
3013
|
+
const recordingError = ref6(null);
|
|
3014
|
+
const sessionId = ref6(controller.sessionId);
|
|
3015
|
+
const status = ref6(controller.status);
|
|
3016
|
+
const turns = shallowRef7([]);
|
|
1234
3017
|
const sync = () => {
|
|
1235
3018
|
assistantAudio.value = [...controller.assistantAudio];
|
|
1236
3019
|
assistantTexts.value = [...controller.assistantTexts];
|
|
@@ -1249,7 +3032,7 @@ var useVoiceController = (path, options = {}) => {
|
|
|
1249
3032
|
unsubscribe();
|
|
1250
3033
|
controller.close();
|
|
1251
3034
|
};
|
|
1252
|
-
|
|
3035
|
+
onUnmounted8(destroy);
|
|
1253
3036
|
return {
|
|
1254
3037
|
assistantAudio,
|
|
1255
3038
|
assistantTexts,
|
|
@@ -1270,7 +3053,246 @@ var useVoiceController = (path, options = {}) => {
|
|
|
1270
3053
|
turns
|
|
1271
3054
|
};
|
|
1272
3055
|
};
|
|
3056
|
+
// src/vue/useVoiceTraceTimeline.ts
|
|
3057
|
+
import { onUnmounted as onUnmounted9, ref as ref7, shallowRef as shallowRef8 } from "vue";
|
|
3058
|
+
|
|
3059
|
+
// src/client/traceTimeline.ts
|
|
3060
|
+
var fetchVoiceTraceTimeline = async (path = "/api/voice-traces", options = {}) => {
|
|
3061
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
3062
|
+
const response = await fetchImpl(path);
|
|
3063
|
+
if (!response.ok) {
|
|
3064
|
+
throw new Error(`Voice trace timeline failed: HTTP ${response.status}`);
|
|
3065
|
+
}
|
|
3066
|
+
return await response.json();
|
|
3067
|
+
};
|
|
3068
|
+
var createVoiceTraceTimelineStore = (path = "/api/voice-traces", options = {}) => {
|
|
3069
|
+
const listeners = new Set;
|
|
3070
|
+
let closed = false;
|
|
3071
|
+
let timer;
|
|
3072
|
+
let snapshot = {
|
|
3073
|
+
error: null,
|
|
3074
|
+
isLoading: false,
|
|
3075
|
+
report: null
|
|
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 = {
|
|
3087
|
+
...snapshot,
|
|
3088
|
+
error: null,
|
|
3089
|
+
isLoading: true
|
|
3090
|
+
};
|
|
3091
|
+
emit();
|
|
3092
|
+
try {
|
|
3093
|
+
const report = await fetchVoiceTraceTimeline(path, options);
|
|
3094
|
+
snapshot = {
|
|
3095
|
+
error: null,
|
|
3096
|
+
isLoading: false,
|
|
3097
|
+
report,
|
|
3098
|
+
updatedAt: Date.now()
|
|
3099
|
+
};
|
|
3100
|
+
emit();
|
|
3101
|
+
return report;
|
|
3102
|
+
} catch (error) {
|
|
3103
|
+
snapshot = {
|
|
3104
|
+
...snapshot,
|
|
3105
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3106
|
+
isLoading: false
|
|
3107
|
+
};
|
|
3108
|
+
emit();
|
|
3109
|
+
throw error;
|
|
3110
|
+
}
|
|
3111
|
+
};
|
|
3112
|
+
const close = () => {
|
|
3113
|
+
closed = true;
|
|
3114
|
+
if (timer) {
|
|
3115
|
+
clearInterval(timer);
|
|
3116
|
+
timer = undefined;
|
|
3117
|
+
}
|
|
3118
|
+
listeners.clear();
|
|
3119
|
+
};
|
|
3120
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
3121
|
+
timer = setInterval(() => {
|
|
3122
|
+
refresh().catch(() => {});
|
|
3123
|
+
}, options.intervalMs);
|
|
3124
|
+
}
|
|
3125
|
+
return {
|
|
3126
|
+
close,
|
|
3127
|
+
getServerSnapshot: () => snapshot,
|
|
3128
|
+
getSnapshot: () => snapshot,
|
|
3129
|
+
refresh,
|
|
3130
|
+
subscribe: (listener) => {
|
|
3131
|
+
listeners.add(listener);
|
|
3132
|
+
return () => {
|
|
3133
|
+
listeners.delete(listener);
|
|
3134
|
+
};
|
|
3135
|
+
}
|
|
3136
|
+
};
|
|
3137
|
+
};
|
|
3138
|
+
|
|
3139
|
+
// src/vue/useVoiceTraceTimeline.ts
|
|
3140
|
+
var useVoiceTraceTimeline = (path = "/api/voice-traces", options = {}) => {
|
|
3141
|
+
const store = createVoiceTraceTimelineStore(path, options);
|
|
3142
|
+
const error = ref7(null);
|
|
3143
|
+
const isLoading = ref7(false);
|
|
3144
|
+
const report = shallowRef8(null);
|
|
3145
|
+
const updatedAt = ref7(undefined);
|
|
3146
|
+
const sync = () => {
|
|
3147
|
+
const snapshot = store.getSnapshot();
|
|
3148
|
+
error.value = snapshot.error;
|
|
3149
|
+
isLoading.value = snapshot.isLoading;
|
|
3150
|
+
report.value = snapshot.report;
|
|
3151
|
+
updatedAt.value = snapshot.updatedAt;
|
|
3152
|
+
};
|
|
3153
|
+
const unsubscribe = store.subscribe(sync);
|
|
3154
|
+
sync();
|
|
3155
|
+
store.refresh().catch(() => {});
|
|
3156
|
+
onUnmounted9(() => {
|
|
3157
|
+
unsubscribe();
|
|
3158
|
+
store.close();
|
|
3159
|
+
});
|
|
3160
|
+
return {
|
|
3161
|
+
error,
|
|
3162
|
+
isLoading,
|
|
3163
|
+
refresh: store.refresh,
|
|
3164
|
+
report,
|
|
3165
|
+
updatedAt
|
|
3166
|
+
};
|
|
3167
|
+
};
|
|
3168
|
+
// src/vue/useVoiceWorkflowStatus.ts
|
|
3169
|
+
import { onUnmounted as onUnmounted10, ref as ref8, shallowRef as shallowRef9 } from "vue";
|
|
3170
|
+
|
|
3171
|
+
// src/client/workflowStatus.ts
|
|
3172
|
+
var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
|
|
3173
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
3174
|
+
const response = await fetchImpl(path);
|
|
3175
|
+
if (!response.ok) {
|
|
3176
|
+
throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
|
|
3177
|
+
}
|
|
3178
|
+
return await response.json();
|
|
3179
|
+
};
|
|
3180
|
+
var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
|
|
3181
|
+
const listeners = new Set;
|
|
3182
|
+
let closed = false;
|
|
3183
|
+
let timer;
|
|
3184
|
+
let snapshot = {
|
|
3185
|
+
error: null,
|
|
3186
|
+
isLoading: false
|
|
3187
|
+
};
|
|
3188
|
+
const emit = () => {
|
|
3189
|
+
for (const listener of listeners) {
|
|
3190
|
+
listener();
|
|
3191
|
+
}
|
|
3192
|
+
};
|
|
3193
|
+
const refresh = async () => {
|
|
3194
|
+
if (closed) {
|
|
3195
|
+
return snapshot.report;
|
|
3196
|
+
}
|
|
3197
|
+
snapshot = {
|
|
3198
|
+
...snapshot,
|
|
3199
|
+
error: null,
|
|
3200
|
+
isLoading: true
|
|
3201
|
+
};
|
|
3202
|
+
emit();
|
|
3203
|
+
try {
|
|
3204
|
+
const report = await fetchVoiceWorkflowStatus(path, options);
|
|
3205
|
+
snapshot = {
|
|
3206
|
+
error: null,
|
|
3207
|
+
isLoading: false,
|
|
3208
|
+
report,
|
|
3209
|
+
updatedAt: Date.now()
|
|
3210
|
+
};
|
|
3211
|
+
emit();
|
|
3212
|
+
return report;
|
|
3213
|
+
} catch (error) {
|
|
3214
|
+
snapshot = {
|
|
3215
|
+
...snapshot,
|
|
3216
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3217
|
+
isLoading: false
|
|
3218
|
+
};
|
|
3219
|
+
emit();
|
|
3220
|
+
throw error;
|
|
3221
|
+
}
|
|
3222
|
+
};
|
|
3223
|
+
const close = () => {
|
|
3224
|
+
closed = true;
|
|
3225
|
+
if (timer) {
|
|
3226
|
+
clearInterval(timer);
|
|
3227
|
+
timer = undefined;
|
|
3228
|
+
}
|
|
3229
|
+
listeners.clear();
|
|
3230
|
+
};
|
|
3231
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
3232
|
+
timer = setInterval(() => {
|
|
3233
|
+
refresh().catch(() => {});
|
|
3234
|
+
}, options.intervalMs);
|
|
3235
|
+
}
|
|
3236
|
+
return {
|
|
3237
|
+
close,
|
|
3238
|
+
getServerSnapshot: () => snapshot,
|
|
3239
|
+
getSnapshot: () => snapshot,
|
|
3240
|
+
refresh,
|
|
3241
|
+
subscribe: (listener) => {
|
|
3242
|
+
listeners.add(listener);
|
|
3243
|
+
return () => {
|
|
3244
|
+
listeners.delete(listener);
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
};
|
|
3248
|
+
};
|
|
3249
|
+
|
|
3250
|
+
// src/vue/useVoiceWorkflowStatus.ts
|
|
3251
|
+
var useVoiceWorkflowStatus = (path = "/evals/scenarios/json", options = {}) => {
|
|
3252
|
+
const store = createVoiceWorkflowStatusStore(path, options);
|
|
3253
|
+
const error = ref8(null);
|
|
3254
|
+
const isLoading = ref8(false);
|
|
3255
|
+
const report = shallowRef9(undefined);
|
|
3256
|
+
const updatedAt = ref8(undefined);
|
|
3257
|
+
const sync = () => {
|
|
3258
|
+
const snapshot = store.getSnapshot();
|
|
3259
|
+
error.value = snapshot.error;
|
|
3260
|
+
isLoading.value = snapshot.isLoading;
|
|
3261
|
+
report.value = snapshot.report;
|
|
3262
|
+
updatedAt.value = snapshot.updatedAt;
|
|
3263
|
+
};
|
|
3264
|
+
const unsubscribe = store.subscribe(sync);
|
|
3265
|
+
sync();
|
|
3266
|
+
if (typeof window !== "undefined") {
|
|
3267
|
+
store.refresh().catch(() => {});
|
|
3268
|
+
}
|
|
3269
|
+
onUnmounted10(() => {
|
|
3270
|
+
unsubscribe();
|
|
3271
|
+
store.close();
|
|
3272
|
+
});
|
|
3273
|
+
return {
|
|
3274
|
+
error,
|
|
3275
|
+
isLoading,
|
|
3276
|
+
refresh: store.refresh,
|
|
3277
|
+
report,
|
|
3278
|
+
updatedAt
|
|
3279
|
+
};
|
|
3280
|
+
};
|
|
1273
3281
|
export {
|
|
3282
|
+
useVoiceWorkflowStatus,
|
|
3283
|
+
useVoiceTurnQuality,
|
|
3284
|
+
useVoiceTraceTimeline,
|
|
1274
3285
|
useVoiceStream,
|
|
1275
|
-
|
|
3286
|
+
useVoiceRoutingStatus,
|
|
3287
|
+
useVoiceProviderStatus,
|
|
3288
|
+
useVoiceProviderSimulationControls,
|
|
3289
|
+
useVoiceProviderCapabilities,
|
|
3290
|
+
useVoiceController,
|
|
3291
|
+
useVoiceAppKitStatus,
|
|
3292
|
+
VoiceTurnQuality,
|
|
3293
|
+
VoiceRoutingStatus,
|
|
3294
|
+
VoiceProviderStatus,
|
|
3295
|
+
VoiceProviderSimulationControls,
|
|
3296
|
+
VoiceProviderCapabilities,
|
|
3297
|
+
VoiceOpsStatus
|
|
1276
3298
|
};
|