@absolutejs/voice 0.0.22-beta.16 → 0.0.22-beta.161
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 +1057 -5
- package/dist/agent.d.ts +24 -0
- package/dist/agentSquadContract.d.ts +64 -0
- package/dist/angular/index.d.ts +11 -0
- package/dist/angular/index.js +3072 -1106
- package/dist/angular/voice-campaign-dialer-proof.service.d.ts +14 -0
- package/dist/angular/voice-controller.service.d.ts +1 -0
- package/dist/angular/voice-delivery-runtime.component.d.ts +17 -0
- package/dist/angular/voice-delivery-runtime.service.d.ts +16 -0
- package/dist/angular/voice-ops-action-center.service.d.ts +13 -0
- package/dist/angular/voice-ops-status.component.d.ts +15 -0
- package/dist/angular/voice-ops-status.service.d.ts +12 -0
- package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
- package/dist/angular/voice-routing-status.service.d.ts +11 -0
- package/dist/angular/voice-stream.service.d.ts +3 -0
- package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
- package/dist/angular/voice-turn-latency.service.d.ts +13 -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/assistantHealth.d.ts +81 -0
- package/dist/audit.d.ts +128 -0
- package/dist/auditDeliveryRoutes.d.ts +85 -0
- package/dist/auditExport.d.ts +34 -0
- package/dist/auditRoutes.d.ts +66 -0
- package/dist/auditSinks.d.ts +151 -0
- package/dist/bargeInRoutes.d.ts +56 -0
- package/dist/campaign.d.ts +610 -0
- package/dist/campaignDialers.d.ts +90 -0
- package/dist/client/actions.d.ts +105 -0
- package/dist/client/bargeInMonitor.d.ts +7 -0
- package/dist/client/campaignDialerProof.d.ts +23 -0
- package/dist/client/connection.d.ts +3 -0
- package/dist/client/deliveryRuntime.d.ts +34 -0
- package/dist/client/deliveryRuntimeWidget.d.ts +37 -0
- package/dist/client/duplex.d.ts +1 -1
- package/dist/client/htmxBootstrap.js +747 -15
- package/dist/client/index.d.ts +50 -0
- package/dist/client/index.js +2757 -20
- package/dist/client/liveTurnLatency.d.ts +41 -0
- package/dist/client/opsActionCenter.d.ts +54 -0
- package/dist/client/opsActionCenterWidget.d.ts +29 -0
- package/dist/client/opsActionHistory.d.ts +19 -0
- package/dist/client/opsActionHistoryWidget.d.ts +11 -0
- package/dist/client/opsStatus.d.ts +19 -0
- 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/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/turnLatency.d.ts +22 -0
- package/dist/client/turnLatencyWidget.d.ts +33 -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/dataControl.d.ts +47 -0
- package/dist/deliveryRuntime.d.ts +158 -0
- package/dist/deliverySinkRoutes.d.ts +117 -0
- package/dist/demoReadyRoutes.d.ts +98 -0
- package/dist/diagnosticsRoutes.d.ts +44 -0
- package/dist/evalRoutes.d.ts +213 -0
- package/dist/fileStore.d.ts +11 -2
- package/dist/handoff.d.ts +54 -0
- package/dist/handoffHealth.d.ts +94 -0
- package/dist/index.d.ts +112 -11
- package/dist/index.js +17939 -4316
- package/dist/liveLatency.d.ts +78 -0
- package/dist/modelAdapters.d.ts +23 -2
- package/dist/openaiRealtime.d.ts +27 -0
- package/dist/openaiTTS.d.ts +18 -0
- package/dist/opsActionAuditRoutes.d.ts +99 -0
- package/dist/opsConsoleRoutes.d.ts +80 -0
- package/dist/opsStatus.d.ts +76 -0
- package/dist/opsStatusRoutes.d.ts +33 -0
- package/dist/opsWebhook.d.ts +126 -0
- package/dist/outcomeContract.d.ts +112 -0
- package/dist/phoneAgent.d.ts +62 -0
- package/dist/phoneAgentProductionSmoke.d.ts +115 -0
- package/dist/postgresStore.d.ts +13 -2
- package/dist/productionReadiness.d.ts +349 -0
- package/dist/providerAdapters.d.ts +48 -0
- package/dist/providerCapabilities.d.ts +92 -0
- package/dist/providerHealth.d.ts +1 -0
- package/dist/providerRoutingContract.d.ts +38 -0
- package/dist/qualityRoutes.d.ts +76 -0
- package/dist/queue.d.ts +61 -0
- package/dist/react/VoiceDeliveryRuntime.d.ts +7 -0
- package/dist/react/VoiceOpsActionCenter.d.ts +5 -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/VoiceTurnLatency.d.ts +6 -0
- package/dist/react/VoiceTurnQuality.d.ts +6 -0
- package/dist/react/index.d.ts +21 -0
- package/dist/react/index.js +3396 -33
- package/dist/react/useVoiceCampaignDialerProof.d.ts +10 -0
- package/dist/react/useVoiceController.d.ts +3 -0
- package/dist/react/useVoiceDeliveryRuntime.d.ts +13 -0
- package/dist/react/useVoiceOpsActionCenter.d.ts +11 -0
- package/dist/react/useVoiceOpsStatus.d.ts +8 -0
- package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
- package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
- package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/react/useVoiceStream.d.ts +3 -0
- package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
- package/dist/react/useVoiceTurnLatency.d.ts +9 -0
- package/dist/react/useVoiceTurnQuality.d.ts +8 -0
- package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
- package/dist/readinessProfiles.d.ts +20 -0
- package/dist/reconnectContract.d.ts +87 -0
- package/dist/resilienceRoutes.d.ts +142 -0
- package/dist/sessionReplay.d.ts +185 -0
- package/dist/simulationSuite.d.ts +120 -0
- package/dist/sqliteStore.d.ts +13 -2
- package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
- package/dist/svelte/createVoiceDeliveryRuntime.d.ts +11 -0
- package/dist/svelte/createVoiceOpsActionCenter.d.ts +10 -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 +4 -2
- package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
- package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
- package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
- package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
- package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
- package/dist/svelte/index.d.ts +11 -0
- package/dist/svelte/index.js +2903 -439
- 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 +135 -2
- package/dist/telephonyOutcome.d.ts +201 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +2973 -156
- 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 +19 -1
- package/dist/traceDeliveryRoutes.d.ts +86 -0
- package/dist/traceTimeline.d.ts +93 -0
- package/dist/turnLatency.d.ts +95 -0
- package/dist/turnQuality.d.ts +94 -0
- package/dist/types.d.ts +170 -4
- package/dist/vue/VoiceDeliveryRuntime.d.ts +30 -0
- package/dist/vue/VoiceOpsActionCenter.d.ts +13 -0
- 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/VoiceTurnLatency.d.ts +69 -0
- package/dist/vue/VoiceTurnQuality.d.ts +51 -0
- package/dist/vue/index.d.ts +20 -0
- package/dist/vue/index.js +3327 -53
- package/dist/vue/useVoiceCampaignDialerProof.d.ts +11 -0
- package/dist/vue/useVoiceController.d.ts +2 -1
- package/dist/vue/useVoiceDeliveryRuntime.d.ts +13 -0
- package/dist/vue/useVoiceOpsActionCenter.d.ts +11 -0
- package/dist/vue/useVoiceOpsStatus.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 +1 -1
- package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/vue/useVoiceStream.d.ts +4 -1
- package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
- package/dist/vue/useVoiceTurnLatency.d.ts +10 -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,2959 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
|
69
69
|
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
// src/vue/VoiceOpsStatus.ts
|
|
73
|
+
import { defineComponent, h } from "vue";
|
|
74
|
+
|
|
75
|
+
// src/client/opsStatus.ts
|
|
76
|
+
var fetchVoiceOpsStatus = async (path = "/api/voice/ops-status", options = {}) => {
|
|
77
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
78
|
+
const response = await fetchImpl(path);
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
throw new Error(`Voice ops status failed: HTTP ${response.status}`);
|
|
81
|
+
}
|
|
82
|
+
return await response.json();
|
|
83
|
+
};
|
|
84
|
+
var createVoiceOpsStatusStore = (path = "/api/voice/ops-status", options = {}) => {
|
|
85
|
+
const listeners = new Set;
|
|
86
|
+
let closed = false;
|
|
87
|
+
let timer;
|
|
88
|
+
let snapshot = {
|
|
89
|
+
error: null,
|
|
90
|
+
isLoading: false
|
|
91
|
+
};
|
|
92
|
+
const emit = () => {
|
|
93
|
+
for (const listener of listeners) {
|
|
94
|
+
listener();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const refresh = async () => {
|
|
98
|
+
if (closed) {
|
|
99
|
+
return snapshot.report;
|
|
100
|
+
}
|
|
101
|
+
snapshot = {
|
|
102
|
+
...snapshot,
|
|
103
|
+
error: null,
|
|
104
|
+
isLoading: true
|
|
105
|
+
};
|
|
106
|
+
emit();
|
|
107
|
+
try {
|
|
108
|
+
const report = await fetchVoiceOpsStatus(path, options);
|
|
109
|
+
snapshot = {
|
|
110
|
+
error: null,
|
|
111
|
+
isLoading: false,
|
|
112
|
+
report,
|
|
113
|
+
updatedAt: Date.now()
|
|
114
|
+
};
|
|
115
|
+
emit();
|
|
116
|
+
return report;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
snapshot = {
|
|
119
|
+
...snapshot,
|
|
120
|
+
error: error instanceof Error ? error.message : String(error),
|
|
121
|
+
isLoading: false
|
|
122
|
+
};
|
|
123
|
+
emit();
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const close = () => {
|
|
128
|
+
closed = true;
|
|
129
|
+
if (timer) {
|
|
130
|
+
clearInterval(timer);
|
|
131
|
+
timer = undefined;
|
|
132
|
+
}
|
|
133
|
+
listeners.clear();
|
|
134
|
+
};
|
|
135
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
136
|
+
timer = setInterval(() => {
|
|
137
|
+
refresh().catch(() => {});
|
|
138
|
+
}, options.intervalMs);
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
close,
|
|
142
|
+
getServerSnapshot: () => snapshot,
|
|
143
|
+
getSnapshot: () => snapshot,
|
|
144
|
+
refresh,
|
|
145
|
+
subscribe: (listener) => {
|
|
146
|
+
listeners.add(listener);
|
|
147
|
+
return () => {
|
|
148
|
+
listeners.delete(listener);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/client/opsStatusWidget.ts
|
|
155
|
+
var DEFAULT_TITLE = "Voice Ops Status";
|
|
156
|
+
var DEFAULT_DESCRIPTION = "Certified workflow, provider, and handoff readiness from your AbsoluteJS voice app.";
|
|
157
|
+
var SURFACE_LABELS = {
|
|
158
|
+
handoffs: "Handoffs",
|
|
159
|
+
providers: "Providers",
|
|
160
|
+
quality: "Quality",
|
|
161
|
+
sessions: "Sessions",
|
|
162
|
+
workflows: "Workflows"
|
|
163
|
+
};
|
|
164
|
+
var escapeHtml = (value) => value.replaceAll("&", "&").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 = "/api/voice/ops-status", options = {}) => {
|
|
242
|
+
const store = createVoiceOpsStatusStore(path, options);
|
|
243
|
+
const render = () => {
|
|
244
|
+
element.innerHTML = renderVoiceOpsStatusHTML(store.getSnapshot(), options);
|
|
245
|
+
};
|
|
246
|
+
const unsubscribe = store.subscribe(render);
|
|
247
|
+
render();
|
|
248
|
+
store.refresh().catch(() => {});
|
|
249
|
+
return {
|
|
250
|
+
close: () => {
|
|
251
|
+
unsubscribe();
|
|
252
|
+
store.close();
|
|
253
|
+
},
|
|
254
|
+
refresh: store.refresh
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
var defineVoiceOpsStatusElement = (tagName = "absolute-voice-ops-status") => {
|
|
258
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
customElements.define(tagName, class AbsoluteVoiceOpsStatusElement extends HTMLElement {
|
|
262
|
+
mounted;
|
|
263
|
+
connectedCallback() {
|
|
264
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
265
|
+
this.mounted = mountVoiceOpsStatus(this, this.getAttribute("path") ?? "/api/voice/ops-status", {
|
|
266
|
+
description: this.getAttribute("description") ?? undefined,
|
|
267
|
+
includeLinks: this.getAttribute("include-links") !== "false",
|
|
268
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
269
|
+
title: this.getAttribute("title") ?? undefined
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
disconnectedCallback() {
|
|
273
|
+
this.mounted?.close();
|
|
274
|
+
this.mounted = undefined;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// src/vue/useVoiceOpsStatus.ts
|
|
280
|
+
import { onUnmounted, ref, shallowRef } from "vue";
|
|
281
|
+
function useVoiceOpsStatus(path = "/api/voice/ops-status", options = {}) {
|
|
282
|
+
const store = createVoiceOpsStatusStore(path, options);
|
|
283
|
+
const error = ref(null);
|
|
284
|
+
const isLoading = ref(false);
|
|
285
|
+
const report = shallowRef(undefined);
|
|
286
|
+
const updatedAt = ref(undefined);
|
|
287
|
+
const sync = () => {
|
|
288
|
+
const snapshot = store.getSnapshot();
|
|
289
|
+
error.value = snapshot.error;
|
|
290
|
+
isLoading.value = snapshot.isLoading;
|
|
291
|
+
report.value = snapshot.report;
|
|
292
|
+
updatedAt.value = snapshot.updatedAt;
|
|
293
|
+
};
|
|
294
|
+
const unsubscribe = store.subscribe(sync);
|
|
295
|
+
sync();
|
|
296
|
+
if (typeof window !== "undefined") {
|
|
297
|
+
store.refresh().catch(() => {});
|
|
298
|
+
}
|
|
299
|
+
onUnmounted(() => {
|
|
300
|
+
unsubscribe();
|
|
301
|
+
store.close();
|
|
302
|
+
});
|
|
303
|
+
return {
|
|
304
|
+
error,
|
|
305
|
+
isLoading,
|
|
306
|
+
refresh: store.refresh,
|
|
307
|
+
report,
|
|
308
|
+
updatedAt
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// src/vue/VoiceOpsStatus.ts
|
|
313
|
+
var VoiceOpsStatus = defineComponent({
|
|
314
|
+
name: "VoiceOpsStatus",
|
|
315
|
+
props: {
|
|
316
|
+
description: String,
|
|
317
|
+
includeLinks: {
|
|
318
|
+
default: true,
|
|
319
|
+
type: Boolean
|
|
320
|
+
},
|
|
321
|
+
intervalMs: Number,
|
|
322
|
+
path: {
|
|
323
|
+
default: "/api/voice/ops-status",
|
|
324
|
+
type: String
|
|
325
|
+
},
|
|
326
|
+
title: String
|
|
327
|
+
},
|
|
328
|
+
setup(props) {
|
|
329
|
+
const options = {
|
|
330
|
+
description: props.description,
|
|
331
|
+
includeLinks: props.includeLinks,
|
|
332
|
+
intervalMs: props.intervalMs,
|
|
333
|
+
title: props.title
|
|
334
|
+
};
|
|
335
|
+
const status = useVoiceOpsStatus(props.path, options);
|
|
336
|
+
return () => {
|
|
337
|
+
const model = createVoiceOpsStatusViewModel({
|
|
338
|
+
error: status.error.value,
|
|
339
|
+
isLoading: status.isLoading.value,
|
|
340
|
+
report: status.report.value,
|
|
341
|
+
updatedAt: status.updatedAt.value
|
|
342
|
+
}, options);
|
|
343
|
+
return h("section", {
|
|
344
|
+
class: [
|
|
345
|
+
"absolute-voice-ops-status",
|
|
346
|
+
`absolute-voice-ops-status--${model.status}`
|
|
347
|
+
]
|
|
348
|
+
}, [
|
|
349
|
+
h("header", { class: "absolute-voice-ops-status__header" }, [
|
|
350
|
+
h("span", { class: "absolute-voice-ops-status__eyebrow" }, model.title),
|
|
351
|
+
h("strong", { class: "absolute-voice-ops-status__label" }, model.label)
|
|
352
|
+
]),
|
|
353
|
+
h("p", { class: "absolute-voice-ops-status__description" }, model.description),
|
|
354
|
+
h("div", { class: "absolute-voice-ops-status__summary" }, [
|
|
355
|
+
h("span", `${model.passed} passing`),
|
|
356
|
+
h("span", `${Math.max(model.total - model.passed, 0)} failing`),
|
|
357
|
+
h("span", `${model.total} checks`)
|
|
358
|
+
]),
|
|
359
|
+
h("ul", { class: "absolute-voice-ops-status__surfaces" }, model.surfaces.length > 0 ? model.surfaces.map((surface) => h("li", {
|
|
360
|
+
class: [
|
|
361
|
+
"absolute-voice-ops-status__surface",
|
|
362
|
+
`absolute-voice-ops-status__surface--${surface.status}`
|
|
363
|
+
],
|
|
364
|
+
key: surface.id
|
|
365
|
+
}, [h("span", surface.label), h("strong", surface.detail)])) : [
|
|
366
|
+
h("li", { class: "absolute-voice-ops-status__surface" }, [
|
|
367
|
+
h("span", "Status"),
|
|
368
|
+
h("strong", "Waiting for first check")
|
|
369
|
+
])
|
|
370
|
+
]),
|
|
371
|
+
model.error ? h("p", { class: "absolute-voice-ops-status__error" }, model.error) : null,
|
|
372
|
+
model.links.length > 0 ? h("nav", { class: "absolute-voice-ops-status__links" }, model.links.slice(0, 4).map((link) => h("a", { href: link.href, key: link.href }, link.label))) : null
|
|
373
|
+
]);
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
// src/vue/VoiceOpsActionCenter.ts
|
|
378
|
+
import { defineComponent as defineComponent2, h as h2 } from "vue";
|
|
379
|
+
|
|
380
|
+
// src/client/opsActionCenter.ts
|
|
381
|
+
var recordVoiceOpsActionResult = async (result, options = {}) => {
|
|
382
|
+
if (options.auditPath === false) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const path = options.auditPath ?? "/api/voice/ops-actions/audit";
|
|
386
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
387
|
+
const response = await fetchImpl(path, {
|
|
388
|
+
body: JSON.stringify(result),
|
|
389
|
+
headers: {
|
|
390
|
+
"Content-Type": "application/json"
|
|
391
|
+
},
|
|
392
|
+
method: "POST"
|
|
393
|
+
});
|
|
394
|
+
if (!response.ok) {
|
|
395
|
+
throw new Error(`Voice ops action audit failed: HTTP ${response.status}`);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
var createVoiceOpsActionCenterActions = (options = {}) => {
|
|
399
|
+
const deliveryRuntimePath = options.deliveryRuntimePath ?? "/api/voice-delivery-runtime";
|
|
400
|
+
const actions = [];
|
|
401
|
+
if (options.includeProductionReadiness !== false) {
|
|
402
|
+
actions.push({
|
|
403
|
+
description: "Refresh the production readiness report.",
|
|
404
|
+
id: "production-readiness",
|
|
405
|
+
label: "Refresh readiness",
|
|
406
|
+
method: "GET",
|
|
407
|
+
path: options.productionReadinessPath ?? "/api/production-readiness"
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
if (options.includeDeliveryRuntime !== false) {
|
|
411
|
+
actions.push({
|
|
412
|
+
description: "Drain pending and failed audit/trace deliveries.",
|
|
413
|
+
id: "delivery-runtime.tick",
|
|
414
|
+
label: "Tick delivery workers",
|
|
415
|
+
method: "POST",
|
|
416
|
+
path: `${deliveryRuntimePath.replace(/\/$/, "")}/tick`
|
|
417
|
+
}, {
|
|
418
|
+
description: "Move reviewed dead letters back to live delivery queues.",
|
|
419
|
+
id: "delivery-runtime.requeue-dead-letters",
|
|
420
|
+
label: "Requeue dead letters",
|
|
421
|
+
method: "POST",
|
|
422
|
+
path: `${deliveryRuntimePath.replace(/\/$/, "")}/requeue-dead-letters`
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
if (options.includeTurnLatencyProof !== false) {
|
|
426
|
+
actions.push({
|
|
427
|
+
description: "Run the synthetic turn latency proof.",
|
|
428
|
+
id: "turn-latency.proof",
|
|
429
|
+
label: "Run latency proof",
|
|
430
|
+
method: "POST",
|
|
431
|
+
path: options.turnLatencyProofPath ?? "/api/turn-latency/proof"
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
if (options.includeProviderSimulation !== false) {
|
|
435
|
+
const pathPrefix = options.providerSimulationPathPrefix ?? "/api/stt-simulate";
|
|
436
|
+
for (const provider of options.providers ?? []) {
|
|
437
|
+
actions.push({
|
|
438
|
+
description: `Simulate ${provider} provider failure.`,
|
|
439
|
+
id: `provider.${provider}.failure`,
|
|
440
|
+
label: `Simulate ${provider} failure`,
|
|
441
|
+
method: "POST",
|
|
442
|
+
path: `${pathPrefix}/failure?provider=${encodeURIComponent(provider)}`
|
|
443
|
+
}, {
|
|
444
|
+
description: `Mark ${provider} provider recovered.`,
|
|
445
|
+
id: `provider.${provider}.recovery`,
|
|
446
|
+
label: `Recover ${provider}`,
|
|
447
|
+
method: "POST",
|
|
448
|
+
path: `${pathPrefix}/recovery?provider=${encodeURIComponent(provider)}`
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return actions;
|
|
453
|
+
};
|
|
454
|
+
var runVoiceOpsAction = async (action, options = {}) => {
|
|
455
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
456
|
+
const response = await fetchImpl(action.path, {
|
|
457
|
+
method: action.method ?? "POST"
|
|
458
|
+
});
|
|
459
|
+
const body = await response.json().catch(() => null);
|
|
460
|
+
if (!response.ok) {
|
|
461
|
+
const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice ops action "${action.id}" failed: HTTP ${response.status}`;
|
|
462
|
+
throw new Error(message);
|
|
463
|
+
}
|
|
464
|
+
return {
|
|
465
|
+
actionId: action.id,
|
|
466
|
+
body,
|
|
467
|
+
ok: response.ok,
|
|
468
|
+
ranAt: Date.now(),
|
|
469
|
+
status: response.status
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
var createVoiceOpsActionCenterStore = (options = {}) => {
|
|
473
|
+
const listeners = new Set;
|
|
474
|
+
let closed = false;
|
|
475
|
+
let timer;
|
|
476
|
+
let snapshot = {
|
|
477
|
+
actions: options.actions ?? createVoiceOpsActionCenterActions(),
|
|
478
|
+
error: null,
|
|
479
|
+
isRunning: false
|
|
480
|
+
};
|
|
481
|
+
const emit = () => {
|
|
482
|
+
for (const listener of listeners) {
|
|
483
|
+
listener();
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
const setActions = (actions) => {
|
|
487
|
+
snapshot = { ...snapshot, actions, updatedAt: Date.now() };
|
|
488
|
+
emit();
|
|
489
|
+
};
|
|
490
|
+
const run = async (actionId) => {
|
|
491
|
+
if (closed) {
|
|
492
|
+
return snapshot.lastResult;
|
|
493
|
+
}
|
|
494
|
+
const action = snapshot.actions.find((item) => item.id === actionId);
|
|
495
|
+
if (!action) {
|
|
496
|
+
throw new Error(`Voice ops action "${actionId}" is not configured.`);
|
|
497
|
+
}
|
|
498
|
+
if (action.disabled) {
|
|
499
|
+
throw new Error(`Voice ops action "${actionId}" is disabled.`);
|
|
500
|
+
}
|
|
501
|
+
snapshot = {
|
|
502
|
+
...snapshot,
|
|
503
|
+
error: null,
|
|
504
|
+
isRunning: true,
|
|
505
|
+
runningActionId: action.id
|
|
506
|
+
};
|
|
507
|
+
emit();
|
|
508
|
+
try {
|
|
509
|
+
const result = await runVoiceOpsAction(action, options);
|
|
510
|
+
await options.onActionResult?.(result);
|
|
511
|
+
await recordVoiceOpsActionResult(result, options);
|
|
512
|
+
snapshot = {
|
|
513
|
+
...snapshot,
|
|
514
|
+
error: null,
|
|
515
|
+
isRunning: false,
|
|
516
|
+
lastResult: result,
|
|
517
|
+
runningActionId: undefined,
|
|
518
|
+
updatedAt: Date.now()
|
|
519
|
+
};
|
|
520
|
+
emit();
|
|
521
|
+
return result;
|
|
522
|
+
} catch (error) {
|
|
523
|
+
const result = {
|
|
524
|
+
actionId: action.id,
|
|
525
|
+
body: null,
|
|
526
|
+
error: error instanceof Error ? error.message : String(error),
|
|
527
|
+
ok: false,
|
|
528
|
+
ranAt: Date.now(),
|
|
529
|
+
status: 0
|
|
530
|
+
};
|
|
531
|
+
await options.onActionResult?.(result);
|
|
532
|
+
await recordVoiceOpsActionResult(result, options).catch(() => {});
|
|
533
|
+
snapshot = {
|
|
534
|
+
...snapshot,
|
|
535
|
+
error: error instanceof Error ? error.message : String(error),
|
|
536
|
+
isRunning: false,
|
|
537
|
+
runningActionId: undefined
|
|
538
|
+
};
|
|
539
|
+
emit();
|
|
540
|
+
throw error;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
const close = () => {
|
|
544
|
+
closed = true;
|
|
545
|
+
if (timer) {
|
|
546
|
+
clearInterval(timer);
|
|
547
|
+
timer = undefined;
|
|
548
|
+
}
|
|
549
|
+
listeners.clear();
|
|
550
|
+
};
|
|
551
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
552
|
+
timer = setInterval(() => {
|
|
553
|
+
emit();
|
|
554
|
+
}, options.intervalMs);
|
|
555
|
+
}
|
|
556
|
+
return {
|
|
557
|
+
close,
|
|
558
|
+
getServerSnapshot: () => snapshot,
|
|
559
|
+
getSnapshot: () => snapshot,
|
|
560
|
+
run,
|
|
561
|
+
setActions,
|
|
562
|
+
subscribe: (listener) => {
|
|
563
|
+
listeners.add(listener);
|
|
564
|
+
return () => {
|
|
565
|
+
listeners.delete(listener);
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
// src/client/opsActionCenterWidget.ts
|
|
572
|
+
var DEFAULT_TITLE2 = "Voice Ops Action Center";
|
|
573
|
+
var DEFAULT_DESCRIPTION2 = "Run production voice proofs and operator actions from one primitive panel.";
|
|
574
|
+
var escapeHtml2 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
575
|
+
var createVoiceOpsActionCenterViewModel = (snapshot, options = {}) => {
|
|
576
|
+
const status = snapshot.error ? "error" : snapshot.isRunning ? "running" : snapshot.lastResult ? "completed" : "ready";
|
|
577
|
+
return {
|
|
578
|
+
actions: snapshot.actions.map((action) => ({
|
|
579
|
+
description: action.description ?? "",
|
|
580
|
+
disabled: Boolean(action.disabled || snapshot.isRunning),
|
|
581
|
+
id: action.id,
|
|
582
|
+
isRunning: snapshot.runningActionId === action.id,
|
|
583
|
+
label: action.label
|
|
584
|
+
})),
|
|
585
|
+
description: options.description ?? DEFAULT_DESCRIPTION2,
|
|
586
|
+
error: snapshot.error,
|
|
587
|
+
isRunning: snapshot.isRunning,
|
|
588
|
+
label: status === "error" ? "Needs attention" : status === "running" ? "Running" : status === "completed" ? "Action completed" : "Ready",
|
|
589
|
+
lastResultLabel: snapshot.lastResult ? `${snapshot.lastResult.actionId} returned HTTP ${snapshot.lastResult.status}` : "No action has run yet.",
|
|
590
|
+
status,
|
|
591
|
+
title: options.title ?? DEFAULT_TITLE2
|
|
592
|
+
};
|
|
593
|
+
};
|
|
594
|
+
var renderVoiceOpsActionCenterHTML = (snapshot, options = {}) => {
|
|
595
|
+
const model = createVoiceOpsActionCenterViewModel(snapshot, options);
|
|
596
|
+
const actions = model.actions.map((action) => `<button type="button" data-absolute-voice-ops-action="${escapeHtml2(action.id)}"${action.disabled ? " disabled" : ""}>
|
|
597
|
+
${escapeHtml2(action.isRunning ? "Working..." : action.label)}
|
|
598
|
+
</button>`).join("");
|
|
599
|
+
return `<section class="absolute-voice-ops-action-center absolute-voice-ops-action-center--${escapeHtml2(model.status)}">
|
|
600
|
+
<header class="absolute-voice-ops-action-center__header">
|
|
601
|
+
<span class="absolute-voice-ops-action-center__eyebrow">${escapeHtml2(model.title)}</span>
|
|
602
|
+
<strong class="absolute-voice-ops-action-center__label">${escapeHtml2(model.label)}</strong>
|
|
603
|
+
</header>
|
|
604
|
+
<p class="absolute-voice-ops-action-center__description">${escapeHtml2(model.description)}</p>
|
|
605
|
+
<div class="absolute-voice-ops-action-center__actions">${actions}</div>
|
|
606
|
+
<p class="absolute-voice-ops-action-center__result">${escapeHtml2(model.lastResultLabel)}</p>
|
|
607
|
+
${model.error ? `<p class="absolute-voice-ops-action-center__error">${escapeHtml2(model.error)}</p>` : ""}
|
|
608
|
+
</section>`;
|
|
609
|
+
};
|
|
610
|
+
var getVoiceOpsActionCenterCSS = () => `.absolute-voice-ops-action-center{border:1px solid #d5cbb8;border-radius:20px;background:#fffaf1;color:#17130b;padding:18px;box-shadow:0 18px 40px rgba(58,42,16,.12);font-family:inherit}.absolute-voice-ops-action-center--error{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-ops-action-center__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-ops-action-center__eyebrow{color:#725d37;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-ops-action-center__label{font-size:28px;line-height:1}.absolute-voice-ops-action-center__description,.absolute-voice-ops-action-center__result{color:#5b4b2f;margin:12px 0 0}.absolute-voice-ops-action-center__actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.absolute-voice-ops-action-center__actions button{background:#7c4a03;border:0;border-radius:999px;color:#fff8e8;cursor:pointer;font:inherit;font-weight:800;padding:8px 12px}.absolute-voice-ops-action-center__actions button:disabled{cursor:not-allowed;opacity:.5}.absolute-voice-ops-action-center__error{color:#9f1239;font-weight:700}`;
|
|
611
|
+
var mountVoiceOpsActionCenter = (element, options = {}) => {
|
|
612
|
+
const store = createVoiceOpsActionCenterStore(options);
|
|
613
|
+
const render = () => {
|
|
614
|
+
element.innerHTML = renderVoiceOpsActionCenterHTML(store.getSnapshot(), options);
|
|
615
|
+
};
|
|
616
|
+
const unsubscribe = store.subscribe(render);
|
|
617
|
+
const handleClick = (event) => {
|
|
618
|
+
const target = event.target;
|
|
619
|
+
if (!(target instanceof Element)) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
const action = target.closest("[data-absolute-voice-ops-action]");
|
|
623
|
+
const actionId = action?.getAttribute("data-absolute-voice-ops-action");
|
|
624
|
+
if (actionId) {
|
|
625
|
+
store.run(actionId).catch(() => {});
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
element.addEventListener?.("click", handleClick);
|
|
629
|
+
render();
|
|
630
|
+
return {
|
|
631
|
+
close: () => {
|
|
632
|
+
element.removeEventListener?.("click", handleClick);
|
|
633
|
+
unsubscribe();
|
|
634
|
+
store.close();
|
|
635
|
+
},
|
|
636
|
+
run: store.run
|
|
637
|
+
};
|
|
638
|
+
};
|
|
639
|
+
var defineVoiceOpsActionCenterElement = (tagName = "absolute-voice-ops-action-center", options = {}) => {
|
|
640
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
customElements.define(tagName, class AbsoluteVoiceOpsActionCenterElement extends HTMLElement {
|
|
644
|
+
mounted;
|
|
645
|
+
connectedCallback() {
|
|
646
|
+
this.mounted = mountVoiceOpsActionCenter(this, {
|
|
647
|
+
...options,
|
|
648
|
+
description: this.getAttribute("description") ?? options.description,
|
|
649
|
+
title: this.getAttribute("title") ?? options.title
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
disconnectedCallback() {
|
|
653
|
+
this.mounted?.close();
|
|
654
|
+
this.mounted = undefined;
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
// src/vue/useVoiceOpsActionCenter.ts
|
|
660
|
+
import { onUnmounted as onUnmounted2, ref as ref2, shallowRef as shallowRef2 } from "vue";
|
|
661
|
+
function useVoiceOpsActionCenter(options = {}) {
|
|
662
|
+
const store = createVoiceOpsActionCenterStore(options);
|
|
663
|
+
const actions = shallowRef2([]);
|
|
664
|
+
const error = ref2(null);
|
|
665
|
+
const isRunning = ref2(false);
|
|
666
|
+
const lastResult = shallowRef2(undefined);
|
|
667
|
+
const runningActionId = ref2(undefined);
|
|
668
|
+
const updatedAt = ref2(undefined);
|
|
669
|
+
const sync = () => {
|
|
670
|
+
const snapshot = store.getSnapshot();
|
|
671
|
+
actions.value = snapshot.actions;
|
|
672
|
+
error.value = snapshot.error;
|
|
673
|
+
isRunning.value = snapshot.isRunning;
|
|
674
|
+
lastResult.value = snapshot.lastResult;
|
|
675
|
+
runningActionId.value = snapshot.runningActionId;
|
|
676
|
+
updatedAt.value = snapshot.updatedAt;
|
|
677
|
+
};
|
|
678
|
+
const unsubscribe = store.subscribe(sync);
|
|
679
|
+
sync();
|
|
680
|
+
onUnmounted2(() => {
|
|
681
|
+
unsubscribe();
|
|
682
|
+
store.close();
|
|
683
|
+
});
|
|
684
|
+
return {
|
|
685
|
+
actions,
|
|
686
|
+
error,
|
|
687
|
+
isRunning,
|
|
688
|
+
lastResult,
|
|
689
|
+
run: store.run,
|
|
690
|
+
runningActionId,
|
|
691
|
+
setActions: store.setActions,
|
|
692
|
+
updatedAt
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// src/vue/VoiceOpsActionCenter.ts
|
|
697
|
+
var VoiceOpsActionCenter = defineComponent2({
|
|
698
|
+
name: "VoiceOpsActionCenter",
|
|
699
|
+
props: {
|
|
700
|
+
actions: Array,
|
|
701
|
+
description: String,
|
|
702
|
+
title: String
|
|
703
|
+
},
|
|
704
|
+
setup(props) {
|
|
705
|
+
const options = {
|
|
706
|
+
actions: props.actions,
|
|
707
|
+
description: props.description,
|
|
708
|
+
title: props.title
|
|
709
|
+
};
|
|
710
|
+
const center = useVoiceOpsActionCenter(options);
|
|
711
|
+
return () => {
|
|
712
|
+
const model = createVoiceOpsActionCenterViewModel({
|
|
713
|
+
actions: center.actions.value,
|
|
714
|
+
error: center.error.value,
|
|
715
|
+
isRunning: center.isRunning.value,
|
|
716
|
+
lastResult: center.lastResult.value,
|
|
717
|
+
runningActionId: center.runningActionId.value,
|
|
718
|
+
updatedAt: center.updatedAt.value
|
|
719
|
+
}, options);
|
|
720
|
+
return h2("section", {
|
|
721
|
+
class: [
|
|
722
|
+
"absolute-voice-ops-action-center",
|
|
723
|
+
`absolute-voice-ops-action-center--${model.status}`
|
|
724
|
+
]
|
|
725
|
+
}, [
|
|
726
|
+
h2("header", { class: "absolute-voice-ops-action-center__header" }, [
|
|
727
|
+
h2("span", { class: "absolute-voice-ops-action-center__eyebrow" }, model.title),
|
|
728
|
+
h2("strong", { class: "absolute-voice-ops-action-center__label" }, model.label)
|
|
729
|
+
]),
|
|
730
|
+
h2("p", { class: "absolute-voice-ops-action-center__description" }, model.description),
|
|
731
|
+
h2("div", { class: "absolute-voice-ops-action-center__actions" }, model.actions.map((action) => h2("button", {
|
|
732
|
+
disabled: action.disabled,
|
|
733
|
+
key: action.id,
|
|
734
|
+
onClick: () => {
|
|
735
|
+
center.run(action.id).catch(() => {});
|
|
736
|
+
},
|
|
737
|
+
type: "button"
|
|
738
|
+
}, action.isRunning ? "Working..." : action.label))),
|
|
739
|
+
h2("p", { class: "absolute-voice-ops-action-center__result" }, model.lastResultLabel),
|
|
740
|
+
model.error ? h2("p", { class: "absolute-voice-ops-action-center__error" }, model.error) : null
|
|
741
|
+
]);
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
// src/vue/VoiceDeliveryRuntime.ts
|
|
746
|
+
import { defineComponent as defineComponent3, h as h3 } from "vue";
|
|
747
|
+
|
|
748
|
+
// src/client/deliveryRuntime.ts
|
|
749
|
+
var getDefaultActionPath = (path, action, options) => {
|
|
750
|
+
if (action === "tick") {
|
|
751
|
+
return options.tickPath ?? `${path.replace(/\/$/, "")}/tick`;
|
|
752
|
+
}
|
|
753
|
+
return options.requeueDeadLettersPath ?? `${path.replace(/\/$/, "")}/requeue-dead-letters`;
|
|
754
|
+
};
|
|
755
|
+
var fetchVoiceDeliveryRuntime = async (path = "/api/voice-delivery-runtime", options = {}) => {
|
|
756
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
757
|
+
const response = await fetchImpl(path);
|
|
758
|
+
if (!response.ok) {
|
|
759
|
+
throw new Error(`Voice delivery runtime failed: HTTP ${response.status}`);
|
|
760
|
+
}
|
|
761
|
+
return await response.json();
|
|
762
|
+
};
|
|
763
|
+
var runVoiceDeliveryRuntimeAction = async (action, path = "/api/voice-delivery-runtime", options = {}) => {
|
|
764
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
765
|
+
const response = await fetchImpl(getDefaultActionPath(path, action, options), {
|
|
766
|
+
method: "POST"
|
|
767
|
+
});
|
|
768
|
+
if (!response.ok) {
|
|
769
|
+
throw new Error(`Voice delivery runtime ${action} failed: HTTP ${response.status}`);
|
|
770
|
+
}
|
|
771
|
+
const body = await response.json();
|
|
772
|
+
return {
|
|
773
|
+
action,
|
|
774
|
+
result: body.result,
|
|
775
|
+
summary: body.summary,
|
|
776
|
+
updatedAt: Date.now()
|
|
777
|
+
};
|
|
778
|
+
};
|
|
779
|
+
var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", options = {}) => {
|
|
780
|
+
const listeners = new Set;
|
|
781
|
+
let closed = false;
|
|
782
|
+
let timer;
|
|
783
|
+
let snapshot = {
|
|
784
|
+
actionError: null,
|
|
785
|
+
actionStatus: "idle",
|
|
786
|
+
error: null,
|
|
787
|
+
isLoading: false
|
|
788
|
+
};
|
|
789
|
+
const emit = () => {
|
|
790
|
+
for (const listener of listeners) {
|
|
791
|
+
listener();
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
const refresh = async () => {
|
|
795
|
+
if (closed) {
|
|
796
|
+
return snapshot.report;
|
|
797
|
+
}
|
|
798
|
+
snapshot = {
|
|
799
|
+
...snapshot,
|
|
800
|
+
error: null,
|
|
801
|
+
isLoading: true
|
|
802
|
+
};
|
|
803
|
+
emit();
|
|
804
|
+
try {
|
|
805
|
+
const report = await fetchVoiceDeliveryRuntime(path, options);
|
|
806
|
+
snapshot = {
|
|
807
|
+
...snapshot,
|
|
808
|
+
error: null,
|
|
809
|
+
isLoading: false,
|
|
810
|
+
report,
|
|
811
|
+
updatedAt: Date.now()
|
|
812
|
+
};
|
|
813
|
+
emit();
|
|
814
|
+
return report;
|
|
815
|
+
} catch (error) {
|
|
816
|
+
snapshot = {
|
|
817
|
+
...snapshot,
|
|
818
|
+
error: error instanceof Error ? error.message : String(error),
|
|
819
|
+
isLoading: false
|
|
820
|
+
};
|
|
821
|
+
emit();
|
|
822
|
+
throw error;
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
const runAction = async (action) => {
|
|
826
|
+
if (closed) {
|
|
827
|
+
return snapshot.lastAction;
|
|
828
|
+
}
|
|
829
|
+
snapshot = {
|
|
830
|
+
...snapshot,
|
|
831
|
+
actionError: null,
|
|
832
|
+
actionStatus: "running"
|
|
833
|
+
};
|
|
834
|
+
emit();
|
|
835
|
+
try {
|
|
836
|
+
const result = await runVoiceDeliveryRuntimeAction(action, path, options);
|
|
837
|
+
snapshot = {
|
|
838
|
+
...snapshot,
|
|
839
|
+
actionError: null,
|
|
840
|
+
actionStatus: "completed",
|
|
841
|
+
lastAction: result
|
|
842
|
+
};
|
|
843
|
+
emit();
|
|
844
|
+
await refresh();
|
|
845
|
+
return result;
|
|
846
|
+
} catch (error) {
|
|
847
|
+
snapshot = {
|
|
848
|
+
...snapshot,
|
|
849
|
+
actionError: error instanceof Error ? error.message : String(error),
|
|
850
|
+
actionStatus: "failed"
|
|
851
|
+
};
|
|
852
|
+
emit();
|
|
853
|
+
throw error;
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
const close = () => {
|
|
857
|
+
closed = true;
|
|
858
|
+
if (timer) {
|
|
859
|
+
clearInterval(timer);
|
|
860
|
+
timer = undefined;
|
|
861
|
+
}
|
|
862
|
+
listeners.clear();
|
|
863
|
+
};
|
|
864
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
865
|
+
timer = setInterval(() => {
|
|
866
|
+
refresh().catch(() => {});
|
|
867
|
+
}, options.intervalMs);
|
|
868
|
+
}
|
|
869
|
+
return {
|
|
870
|
+
close,
|
|
871
|
+
getServerSnapshot: () => snapshot,
|
|
872
|
+
getSnapshot: () => snapshot,
|
|
873
|
+
requeueDeadLetters: () => runAction("requeue-dead-letters"),
|
|
874
|
+
refresh,
|
|
875
|
+
tick: () => runAction("tick"),
|
|
876
|
+
subscribe: (listener) => {
|
|
877
|
+
listeners.add(listener);
|
|
878
|
+
return () => {
|
|
879
|
+
listeners.delete(listener);
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
// src/client/deliveryRuntimeWidget.ts
|
|
886
|
+
var DEFAULT_TITLE3 = "Voice Delivery Runtime";
|
|
887
|
+
var DEFAULT_DESCRIPTION3 = "Audit and trace delivery worker health from your AbsoluteJS voice app.";
|
|
888
|
+
var escapeHtml3 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
889
|
+
var createSurface = (id, summary) => {
|
|
890
|
+
if (!summary) {
|
|
891
|
+
return {
|
|
892
|
+
deadLettered: 0,
|
|
893
|
+
detail: "Worker disabled",
|
|
894
|
+
failed: 0,
|
|
895
|
+
id,
|
|
896
|
+
label: id === "audit" ? "Audit delivery" : "Trace delivery",
|
|
897
|
+
pending: 0,
|
|
898
|
+
status: "disabled",
|
|
899
|
+
total: 0
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
const blocked = summary.failed + summary.deadLettered;
|
|
903
|
+
return {
|
|
904
|
+
deadLettered: summary.deadLettered,
|
|
905
|
+
detail: `${summary.delivered}/${summary.total} delivered, ${summary.pending} pending`,
|
|
906
|
+
failed: summary.failed,
|
|
907
|
+
id,
|
|
908
|
+
label: id === "audit" ? "Audit delivery" : "Trace delivery",
|
|
909
|
+
pending: summary.pending,
|
|
910
|
+
status: blocked > 0 ? "warn" : "pass",
|
|
911
|
+
total: summary.total
|
|
912
|
+
};
|
|
913
|
+
};
|
|
914
|
+
var createVoiceDeliveryRuntimeViewModel = (snapshot, options = {}) => {
|
|
915
|
+
const report = snapshot.report;
|
|
916
|
+
const surfaces = [
|
|
917
|
+
createSurface("audit", report?.summary.audit),
|
|
918
|
+
createSurface("trace", report?.summary.trace)
|
|
919
|
+
];
|
|
920
|
+
const hasWarnings = surfaces.some((surface) => surface.status === "warn");
|
|
921
|
+
return {
|
|
922
|
+
description: options.description ?? DEFAULT_DESCRIPTION3,
|
|
923
|
+
error: snapshot.error,
|
|
924
|
+
actionError: snapshot.actionError,
|
|
925
|
+
actionStatus: snapshot.actionStatus,
|
|
926
|
+
isLoading: snapshot.isLoading,
|
|
927
|
+
isRunning: Boolean(report?.isRunning),
|
|
928
|
+
label: snapshot.error ? "Unavailable" : report ? report.isRunning ? "Running" : "Stopped" : "Checking",
|
|
929
|
+
status: snapshot.error ? "error" : report ? hasWarnings ? "warn" : "pass" : "loading",
|
|
930
|
+
surfaces,
|
|
931
|
+
title: options.title ?? DEFAULT_TITLE3,
|
|
932
|
+
updatedAt: snapshot.updatedAt
|
|
933
|
+
};
|
|
934
|
+
};
|
|
935
|
+
var renderVoiceDeliveryRuntimeHTML = (snapshot, options = {}) => {
|
|
936
|
+
const model = createVoiceDeliveryRuntimeViewModel(snapshot, options);
|
|
937
|
+
const surfaces = model.surfaces.map((surface) => `<li class="absolute-voice-delivery-runtime__surface absolute-voice-delivery-runtime__surface--${escapeHtml3(surface.status)}">
|
|
938
|
+
<span>${escapeHtml3(surface.label)}</span>
|
|
939
|
+
<strong>${escapeHtml3(surface.detail)}</strong>
|
|
940
|
+
<small>${String(surface.failed)} failed · ${String(surface.deadLettered)} dead-lettered</small>
|
|
941
|
+
</li>`).join("");
|
|
942
|
+
const actions = options.includeActions === false ? "" : `<div class="absolute-voice-delivery-runtime__actions">
|
|
943
|
+
<button type="button" data-absolute-voice-delivery-runtime-action="tick">${model.actionStatus === "running" ? "Working..." : "Tick workers"}</button>
|
|
944
|
+
<button type="button" data-absolute-voice-delivery-runtime-action="requeue-dead-letters"${model.surfaces.some((surface) => surface.deadLettered > 0) ? "" : " disabled"}>Requeue dead letters</button>
|
|
945
|
+
</div>`;
|
|
946
|
+
const actionError = model.actionError ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml3(model.actionError)}</p>` : "";
|
|
947
|
+
return `<section class="absolute-voice-delivery-runtime absolute-voice-delivery-runtime--${escapeHtml3(model.status)}">
|
|
948
|
+
<header class="absolute-voice-delivery-runtime__header">
|
|
949
|
+
<span class="absolute-voice-delivery-runtime__eyebrow">${escapeHtml3(model.title)}</span>
|
|
950
|
+
<strong class="absolute-voice-delivery-runtime__label">${escapeHtml3(model.label)}</strong>
|
|
951
|
+
</header>
|
|
952
|
+
<p class="absolute-voice-delivery-runtime__description">${escapeHtml3(model.description)}</p>
|
|
953
|
+
<ul class="absolute-voice-delivery-runtime__surfaces">${surfaces}</ul>
|
|
954
|
+
${actions}
|
|
955
|
+
${actionError}
|
|
956
|
+
${model.error ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml3(model.error)}</p>` : ""}
|
|
957
|
+
</section>`;
|
|
958
|
+
};
|
|
959
|
+
var getVoiceDeliveryRuntimeCSS = () => `.absolute-voice-delivery-runtime{border:1px solid #c9d8cf;border-radius:20px;background:#f6fff9;color:#0d1b12;padding:18px;box-shadow:0 18px 40px rgba(19,55,35,.12);font-family:inherit}.absolute-voice-delivery-runtime--warn,.absolute-voice-delivery-runtime--error{border-color:#f2b56b;background:#fff9ed}.absolute-voice-delivery-runtime__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-delivery-runtime__eyebrow{color:#4e6b59;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-delivery-runtime__label{font-size:28px;line-height:1}.absolute-voice-delivery-runtime__description{color:#33483b;margin:12px 0 0}.absolute-voice-delivery-runtime__surfaces{display:grid;gap:8px;list-style:none;margin:16px 0 0;padding:0}.absolute-voice-delivery-runtime__surface{background:#fff;border:1px solid #d9eadf;border-radius:14px;display:grid;gap:4px;padding:10px 12px}.absolute-voice-delivery-runtime__surface--warn{border-color:#f2b56b}.absolute-voice-delivery-runtime__surface--disabled{opacity:.72}.absolute-voice-delivery-runtime__surface span,.absolute-voice-delivery-runtime__surface small{color:#587063}.absolute-voice-delivery-runtime__actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.absolute-voice-delivery-runtime__actions button{background:#134e2d;border:0;border-radius:999px;color:#f6fff9;cursor:pointer;font:inherit;font-weight:800;padding:8px 12px}.absolute-voice-delivery-runtime__actions button:disabled{cursor:not-allowed;opacity:.48}.absolute-voice-delivery-runtime__error{color:#9f1239;font-weight:700}`;
|
|
960
|
+
var mountVoiceDeliveryRuntime = (element, path = "/api/voice-delivery-runtime", options = {}) => {
|
|
961
|
+
const store = createVoiceDeliveryRuntimeStore(path, options);
|
|
962
|
+
const render = () => {
|
|
963
|
+
element.innerHTML = renderVoiceDeliveryRuntimeHTML(store.getSnapshot(), options);
|
|
964
|
+
};
|
|
965
|
+
const unsubscribe = store.subscribe(render);
|
|
966
|
+
const handleClick = (event) => {
|
|
967
|
+
const target = event.target;
|
|
968
|
+
if (!(target instanceof Element)) {
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
const action = target.closest("[data-absolute-voice-delivery-runtime-action]");
|
|
972
|
+
const actionName = action?.getAttribute("data-absolute-voice-delivery-runtime-action");
|
|
973
|
+
if (actionName === "tick") {
|
|
974
|
+
store.tick().catch(() => {});
|
|
975
|
+
}
|
|
976
|
+
if (actionName === "requeue-dead-letters") {
|
|
977
|
+
store.requeueDeadLetters().catch(() => {});
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
element.addEventListener?.("click", handleClick);
|
|
981
|
+
render();
|
|
982
|
+
store.refresh().catch(() => {});
|
|
983
|
+
return {
|
|
984
|
+
close: () => {
|
|
985
|
+
element.removeEventListener?.("click", handleClick);
|
|
986
|
+
unsubscribe();
|
|
987
|
+
store.close();
|
|
988
|
+
},
|
|
989
|
+
refresh: store.refresh
|
|
990
|
+
};
|
|
991
|
+
};
|
|
992
|
+
var defineVoiceDeliveryRuntimeElement = (tagName = "absolute-voice-delivery-runtime") => {
|
|
993
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
customElements.define(tagName, class AbsoluteVoiceDeliveryRuntimeElement extends HTMLElement {
|
|
997
|
+
mounted;
|
|
998
|
+
connectedCallback() {
|
|
999
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
1000
|
+
this.mounted = mountVoiceDeliveryRuntime(this, this.getAttribute("path") ?? "/api/voice-delivery-runtime", {
|
|
1001
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1002
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
1003
|
+
title: this.getAttribute("title") ?? undefined
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
disconnectedCallback() {
|
|
1007
|
+
this.mounted?.close();
|
|
1008
|
+
this.mounted = undefined;
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
// src/vue/useVoiceDeliveryRuntime.ts
|
|
1014
|
+
import { onUnmounted as onUnmounted3, ref as ref3, shallowRef as shallowRef3 } from "vue";
|
|
1015
|
+
function useVoiceDeliveryRuntime(path = "/api/voice-delivery-runtime", options = {}) {
|
|
1016
|
+
const store = createVoiceDeliveryRuntimeStore(path, options);
|
|
1017
|
+
const actionError = ref3(null);
|
|
1018
|
+
const actionStatus = ref3("idle");
|
|
1019
|
+
const error = ref3(null);
|
|
1020
|
+
const isLoading = ref3(false);
|
|
1021
|
+
const report = shallowRef3(undefined);
|
|
1022
|
+
const updatedAt = ref3(undefined);
|
|
1023
|
+
const sync = () => {
|
|
1024
|
+
const snapshot = store.getSnapshot();
|
|
1025
|
+
actionError.value = snapshot.actionError;
|
|
1026
|
+
actionStatus.value = snapshot.actionStatus;
|
|
1027
|
+
error.value = snapshot.error;
|
|
1028
|
+
isLoading.value = snapshot.isLoading;
|
|
1029
|
+
report.value = snapshot.report;
|
|
1030
|
+
updatedAt.value = snapshot.updatedAt;
|
|
1031
|
+
};
|
|
1032
|
+
const unsubscribe = store.subscribe(sync);
|
|
1033
|
+
sync();
|
|
1034
|
+
if (typeof window !== "undefined") {
|
|
1035
|
+
store.refresh().catch(() => {});
|
|
1036
|
+
}
|
|
1037
|
+
onUnmounted3(() => {
|
|
1038
|
+
unsubscribe();
|
|
1039
|
+
store.close();
|
|
1040
|
+
});
|
|
1041
|
+
return {
|
|
1042
|
+
actionError,
|
|
1043
|
+
actionStatus,
|
|
1044
|
+
error,
|
|
1045
|
+
isLoading,
|
|
1046
|
+
requeueDeadLetters: store.requeueDeadLetters,
|
|
1047
|
+
refresh: store.refresh,
|
|
1048
|
+
report,
|
|
1049
|
+
tick: store.tick,
|
|
1050
|
+
updatedAt
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
// src/vue/VoiceDeliveryRuntime.ts
|
|
1055
|
+
var VoiceDeliveryRuntime = defineComponent3({
|
|
1056
|
+
name: "VoiceDeliveryRuntime",
|
|
1057
|
+
props: {
|
|
1058
|
+
description: String,
|
|
1059
|
+
includeActions: {
|
|
1060
|
+
default: true,
|
|
1061
|
+
type: Boolean
|
|
1062
|
+
},
|
|
1063
|
+
intervalMs: Number,
|
|
1064
|
+
path: {
|
|
1065
|
+
default: "/api/voice-delivery-runtime",
|
|
1066
|
+
type: String
|
|
1067
|
+
},
|
|
1068
|
+
title: String
|
|
1069
|
+
},
|
|
1070
|
+
setup(props) {
|
|
1071
|
+
const options = {
|
|
1072
|
+
description: props.description,
|
|
1073
|
+
intervalMs: props.intervalMs,
|
|
1074
|
+
title: props.title
|
|
1075
|
+
};
|
|
1076
|
+
const runtime = useVoiceDeliveryRuntime(props.path, options);
|
|
1077
|
+
return () => {
|
|
1078
|
+
const model = createVoiceDeliveryRuntimeViewModel({
|
|
1079
|
+
error: runtime.error.value,
|
|
1080
|
+
actionError: runtime.actionError.value,
|
|
1081
|
+
actionStatus: runtime.actionStatus.value,
|
|
1082
|
+
isLoading: runtime.isLoading.value,
|
|
1083
|
+
report: runtime.report.value,
|
|
1084
|
+
updatedAt: runtime.updatedAt.value
|
|
1085
|
+
}, options);
|
|
1086
|
+
const hasDeadLetters = model.surfaces.some((surface) => surface.deadLettered > 0);
|
|
1087
|
+
return h3("section", {
|
|
1088
|
+
class: [
|
|
1089
|
+
"absolute-voice-delivery-runtime",
|
|
1090
|
+
`absolute-voice-delivery-runtime--${model.status}`
|
|
1091
|
+
]
|
|
1092
|
+
}, [
|
|
1093
|
+
h3("header", { class: "absolute-voice-delivery-runtime__header" }, [
|
|
1094
|
+
h3("span", { class: "absolute-voice-delivery-runtime__eyebrow" }, model.title),
|
|
1095
|
+
h3("strong", { class: "absolute-voice-delivery-runtime__label" }, model.label)
|
|
1096
|
+
]),
|
|
1097
|
+
h3("p", { class: "absolute-voice-delivery-runtime__description" }, model.description),
|
|
1098
|
+
h3("ul", { class: "absolute-voice-delivery-runtime__surfaces" }, model.surfaces.map((surface) => h3("li", {
|
|
1099
|
+
class: [
|
|
1100
|
+
"absolute-voice-delivery-runtime__surface",
|
|
1101
|
+
`absolute-voice-delivery-runtime__surface--${surface.status}`
|
|
1102
|
+
],
|
|
1103
|
+
key: surface.id
|
|
1104
|
+
}, [
|
|
1105
|
+
h3("span", surface.label),
|
|
1106
|
+
h3("strong", surface.detail),
|
|
1107
|
+
h3("small", `${surface.failed} failed / ${surface.deadLettered} dead-lettered`)
|
|
1108
|
+
]))),
|
|
1109
|
+
props.includeActions ? h3("div", { class: "absolute-voice-delivery-runtime__actions" }, [
|
|
1110
|
+
h3("button", {
|
|
1111
|
+
disabled: model.actionStatus === "running",
|
|
1112
|
+
onClick: () => {
|
|
1113
|
+
runtime.tick().catch(() => {});
|
|
1114
|
+
},
|
|
1115
|
+
type: "button"
|
|
1116
|
+
}, model.actionStatus === "running" ? "Working..." : "Tick workers"),
|
|
1117
|
+
h3("button", {
|
|
1118
|
+
disabled: model.actionStatus === "running" || !hasDeadLetters,
|
|
1119
|
+
onClick: () => {
|
|
1120
|
+
runtime.requeueDeadLetters().catch(() => {});
|
|
1121
|
+
},
|
|
1122
|
+
type: "button"
|
|
1123
|
+
}, "Requeue dead letters")
|
|
1124
|
+
]) : null,
|
|
1125
|
+
model.actionError ? h3("p", { class: "absolute-voice-delivery-runtime__error" }, model.actionError) : null,
|
|
1126
|
+
model.error ? h3("p", { class: "absolute-voice-delivery-runtime__error" }, model.error) : null
|
|
1127
|
+
]);
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
// src/vue/VoiceProviderSimulationControls.ts
|
|
1132
|
+
import { computed, defineComponent as defineComponent4, h as h4 } from "vue";
|
|
1133
|
+
|
|
1134
|
+
// src/client/providerSimulationControls.ts
|
|
1135
|
+
var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
|
|
1136
|
+
const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
|
|
1137
|
+
const body = await response.json().catch(() => null);
|
|
1138
|
+
if (!response.ok) {
|
|
1139
|
+
const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice provider simulation failed: HTTP ${response.status}`;
|
|
1140
|
+
throw new Error(message);
|
|
1141
|
+
}
|
|
1142
|
+
return body;
|
|
1143
|
+
};
|
|
1144
|
+
var createVoiceProviderSimulationControlsStore = (options) => {
|
|
1145
|
+
const listeners = new Set;
|
|
1146
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1147
|
+
const pathPrefix = options.pathPrefix ?? `/api/${options.kind ?? "stt"}-simulate`;
|
|
1148
|
+
let closed = false;
|
|
1149
|
+
let snapshot = {
|
|
1150
|
+
error: null,
|
|
1151
|
+
isRunning: false,
|
|
1152
|
+
lastResult: null,
|
|
1153
|
+
mode: null,
|
|
1154
|
+
provider: null
|
|
1155
|
+
};
|
|
1156
|
+
const emit = () => {
|
|
1157
|
+
for (const listener of listeners) {
|
|
1158
|
+
listener();
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
const run = async (provider, mode) => {
|
|
1162
|
+
if (closed) {
|
|
1163
|
+
return snapshot.lastResult;
|
|
1164
|
+
}
|
|
1165
|
+
snapshot = {
|
|
1166
|
+
...snapshot,
|
|
1167
|
+
error: null,
|
|
1168
|
+
isRunning: true,
|
|
1169
|
+
mode,
|
|
1170
|
+
provider
|
|
1171
|
+
};
|
|
1172
|
+
emit();
|
|
1173
|
+
try {
|
|
1174
|
+
const result = await postSimulation(pathPrefix, mode, provider, fetchImpl);
|
|
1175
|
+
snapshot = {
|
|
1176
|
+
error: null,
|
|
1177
|
+
isRunning: false,
|
|
1178
|
+
lastResult: result,
|
|
1179
|
+
mode,
|
|
1180
|
+
provider,
|
|
1181
|
+
updatedAt: Date.now()
|
|
1182
|
+
};
|
|
1183
|
+
emit();
|
|
1184
|
+
return result;
|
|
1185
|
+
} catch (error) {
|
|
1186
|
+
snapshot = {
|
|
1187
|
+
...snapshot,
|
|
1188
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1189
|
+
isRunning: false
|
|
1190
|
+
};
|
|
1191
|
+
emit();
|
|
1192
|
+
throw error;
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
const close = () => {
|
|
1196
|
+
closed = true;
|
|
1197
|
+
listeners.clear();
|
|
1198
|
+
};
|
|
1199
|
+
return {
|
|
1200
|
+
close,
|
|
1201
|
+
getServerSnapshot: () => snapshot,
|
|
1202
|
+
getSnapshot: () => snapshot,
|
|
1203
|
+
run,
|
|
1204
|
+
subscribe: (listener) => {
|
|
1205
|
+
listeners.add(listener);
|
|
1206
|
+
return () => {
|
|
1207
|
+
listeners.delete(listener);
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
// src/client/providerSimulationControlsWidget.ts
|
|
1214
|
+
var escapeHtml4 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1215
|
+
var formatKind = (kind) => (kind ?? "stt").toUpperCase();
|
|
1216
|
+
var createVoiceProviderSimulationControlsViewModel = (snapshot, options) => {
|
|
1217
|
+
const configuredProviders = options.providers.filter((provider) => provider.configured !== false);
|
|
1218
|
+
const fallbackReady = !options.fallbackRequiredProvider || configuredProviders.some((entry) => entry.provider === options.fallbackRequiredProvider);
|
|
1219
|
+
const failureProviders = (options.failureProviders ? options.failureProviders.map((provider) => ({ provider })) : configuredProviders).filter((provider) => configuredProviders.some((entry) => entry.provider === provider.provider));
|
|
1220
|
+
return {
|
|
1221
|
+
canSimulateFailure: configuredProviders.length > 0 && fallbackReady,
|
|
1222
|
+
description: options.failureMessage ?? `Simulate ${formatKind(options.kind)} provider failure and recovery without changing credentials.`,
|
|
1223
|
+
error: snapshot.error,
|
|
1224
|
+
failureProviders,
|
|
1225
|
+
isRunning: snapshot.isRunning,
|
|
1226
|
+
label: snapshot.isRunning ? `Running ${snapshot.mode ?? "simulation"}` : snapshot.lastResult ? `${snapshot.lastResult.provider} ${snapshot.lastResult.mode} simulated` : configuredProviders.length ? `${configuredProviders.length} configured` : "No configured providers",
|
|
1227
|
+
providers: configuredProviders,
|
|
1228
|
+
resultText: snapshot.lastResult ? JSON.stringify(snapshot.lastResult, null, 2) : null,
|
|
1229
|
+
title: options.title ?? `${formatKind(options.kind)} Failure Simulation`
|
|
1230
|
+
};
|
|
1231
|
+
};
|
|
1232
|
+
var renderVoiceProviderSimulationControlsHTML = (snapshot, options) => {
|
|
1233
|
+
const model = createVoiceProviderSimulationControlsViewModel(snapshot, options);
|
|
1234
|
+
const failureButtons = model.failureProviders.map((provider) => `<button type="button" data-voice-provider-fail="${escapeHtml4(provider.provider)}"${!model.canSimulateFailure || snapshot.isRunning ? " disabled" : ""}>Simulate ${escapeHtml4(provider.provider)} ${escapeHtml4(formatKind(options.kind))} failure</button>`).join("");
|
|
1235
|
+
const recoveryButtons = model.providers.map((provider) => `<button type="button" data-voice-provider-recover="${escapeHtml4(provider.provider)}"${snapshot.isRunning ? " disabled" : ""}>Mark ${escapeHtml4(provider.provider)} recovered</button>`).join("");
|
|
1236
|
+
return `<section class="absolute-voice-provider-simulation absolute-voice-provider-simulation--${snapshot.error ? "error" : snapshot.isRunning ? "running" : "ready"}">
|
|
1237
|
+
<header class="absolute-voice-provider-simulation__header">
|
|
1238
|
+
<span class="absolute-voice-provider-simulation__eyebrow">${escapeHtml4(model.title)}</span>
|
|
1239
|
+
<strong class="absolute-voice-provider-simulation__label">${escapeHtml4(model.label)}</strong>
|
|
1240
|
+
</header>
|
|
1241
|
+
<p class="absolute-voice-provider-simulation__description">${escapeHtml4(model.description)}</p>
|
|
1242
|
+
${model.canSimulateFailure ? "" : `<p class="absolute-voice-provider-simulation__empty">${escapeHtml4(options.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure.")}</p>`}
|
|
1243
|
+
<div class="absolute-voice-provider-simulation__actions">${failureButtons}${recoveryButtons}</div>
|
|
1244
|
+
${snapshot.error ? `<p class="absolute-voice-provider-simulation__error">${escapeHtml4(snapshot.error)}</p>` : ""}
|
|
1245
|
+
${model.resultText ? `<pre class="absolute-voice-provider-simulation__result">${escapeHtml4(model.resultText)}</pre>` : ""}
|
|
1246
|
+
</section>`;
|
|
1247
|
+
};
|
|
1248
|
+
var bindVoiceProviderSimulationControls = (element, store) => {
|
|
1249
|
+
const onClick = (event) => {
|
|
1250
|
+
const target = event.target;
|
|
1251
|
+
if (!(target instanceof HTMLElement)) {
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
const failProvider = target.getAttribute("data-voice-provider-fail");
|
|
1255
|
+
const recoverProvider = target.getAttribute("data-voice-provider-recover");
|
|
1256
|
+
if (failProvider) {
|
|
1257
|
+
store.run(failProvider, "failure").catch(() => {});
|
|
1258
|
+
}
|
|
1259
|
+
if (recoverProvider) {
|
|
1260
|
+
store.run(recoverProvider, "recovery").catch(() => {});
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
element.addEventListener("click", onClick);
|
|
1264
|
+
return () => element.removeEventListener("click", onClick);
|
|
1265
|
+
};
|
|
1266
|
+
var mountVoiceProviderSimulationControls = (element, options) => {
|
|
1267
|
+
const store = createVoiceProviderSimulationControlsStore(options);
|
|
1268
|
+
const render = () => {
|
|
1269
|
+
element.innerHTML = renderVoiceProviderSimulationControlsHTML(store.getSnapshot(), options);
|
|
1270
|
+
};
|
|
1271
|
+
const unsubscribeStore = store.subscribe(render);
|
|
1272
|
+
const unsubscribeDom = bindVoiceProviderSimulationControls(element, store);
|
|
1273
|
+
render();
|
|
1274
|
+
return {
|
|
1275
|
+
close: () => {
|
|
1276
|
+
unsubscribeDom();
|
|
1277
|
+
unsubscribeStore();
|
|
1278
|
+
store.close();
|
|
1279
|
+
},
|
|
1280
|
+
run: store.run
|
|
1281
|
+
};
|
|
1282
|
+
};
|
|
1283
|
+
var defineVoiceProviderSimulationControlsElement = (tagName = "absolute-voice-provider-simulation") => {
|
|
1284
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
customElements.define(tagName, class AbsoluteVoiceProviderSimulationElement extends HTMLElement {
|
|
1288
|
+
mounted;
|
|
1289
|
+
connectedCallback() {
|
|
1290
|
+
const providers = (this.getAttribute("providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean).map((provider) => ({ provider }));
|
|
1291
|
+
const failureProviders = (this.getAttribute("failure-providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean);
|
|
1292
|
+
this.mounted = mountVoiceProviderSimulationControls(this, {
|
|
1293
|
+
failureProviders: failureProviders.length ? failureProviders : undefined,
|
|
1294
|
+
fallbackRequiredMessage: this.getAttribute("fallback-required-message") ?? undefined,
|
|
1295
|
+
fallbackRequiredProvider: this.getAttribute("fallback-required-provider") ?? undefined,
|
|
1296
|
+
failureMessage: this.getAttribute("failure-message") ?? undefined,
|
|
1297
|
+
kind: this.getAttribute("kind") ?? "stt",
|
|
1298
|
+
pathPrefix: this.getAttribute("path-prefix") ?? undefined,
|
|
1299
|
+
providers,
|
|
1300
|
+
title: this.getAttribute("title") ?? undefined
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
disconnectedCallback() {
|
|
1304
|
+
this.mounted?.close();
|
|
1305
|
+
this.mounted = undefined;
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
// src/vue/useVoiceProviderSimulationControls.ts
|
|
1311
|
+
import { onUnmounted as onUnmounted4, ref as ref4 } from "vue";
|
|
1312
|
+
function useVoiceProviderSimulationControls(options) {
|
|
1313
|
+
const store = createVoiceProviderSimulationControlsStore(options);
|
|
1314
|
+
const error = ref4(null);
|
|
1315
|
+
const isRunning = ref4(false);
|
|
1316
|
+
const lastResult = ref4(null);
|
|
1317
|
+
const mode = ref4(null);
|
|
1318
|
+
const provider = ref4(null);
|
|
1319
|
+
const updatedAt = ref4(undefined);
|
|
1320
|
+
const sync = () => {
|
|
1321
|
+
const snapshot = store.getSnapshot();
|
|
1322
|
+
error.value = snapshot.error;
|
|
1323
|
+
isRunning.value = snapshot.isRunning;
|
|
1324
|
+
lastResult.value = snapshot.lastResult;
|
|
1325
|
+
mode.value = snapshot.mode;
|
|
1326
|
+
provider.value = snapshot.provider;
|
|
1327
|
+
updatedAt.value = snapshot.updatedAt;
|
|
1328
|
+
};
|
|
1329
|
+
const unsubscribe = store.subscribe(sync);
|
|
1330
|
+
sync();
|
|
1331
|
+
onUnmounted4(() => {
|
|
1332
|
+
unsubscribe();
|
|
1333
|
+
store.close();
|
|
1334
|
+
});
|
|
1335
|
+
return {
|
|
1336
|
+
error,
|
|
1337
|
+
isRunning,
|
|
1338
|
+
lastResult,
|
|
1339
|
+
mode,
|
|
1340
|
+
provider,
|
|
1341
|
+
run: store.run,
|
|
1342
|
+
updatedAt
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
// src/vue/VoiceProviderSimulationControls.ts
|
|
1347
|
+
var VoiceProviderSimulationControls = defineComponent4({
|
|
1348
|
+
name: "VoiceProviderSimulationControls",
|
|
1349
|
+
props: {
|
|
1350
|
+
class: { default: "", type: String },
|
|
1351
|
+
fallbackRequiredMessage: { default: undefined, type: String },
|
|
1352
|
+
fallbackRequiredProvider: { default: undefined, type: String },
|
|
1353
|
+
failureMessage: { default: undefined, type: String },
|
|
1354
|
+
failureProviders: {
|
|
1355
|
+
default: undefined,
|
|
1356
|
+
type: Array
|
|
1357
|
+
},
|
|
1358
|
+
kind: { default: "stt", type: String },
|
|
1359
|
+
pathPrefix: { default: undefined, type: String },
|
|
1360
|
+
providers: {
|
|
1361
|
+
required: true,
|
|
1362
|
+
type: Array
|
|
1363
|
+
},
|
|
1364
|
+
title: { default: undefined, type: String }
|
|
1365
|
+
},
|
|
1366
|
+
setup(props) {
|
|
1367
|
+
const options = {
|
|
1368
|
+
fallbackRequiredMessage: props.fallbackRequiredMessage,
|
|
1369
|
+
fallbackRequiredProvider: props.fallbackRequiredProvider,
|
|
1370
|
+
failureMessage: props.failureMessage,
|
|
1371
|
+
failureProviders: props.failureProviders,
|
|
1372
|
+
kind: props.kind,
|
|
1373
|
+
pathPrefix: props.pathPrefix,
|
|
1374
|
+
providers: props.providers,
|
|
1375
|
+
title: props.title
|
|
1376
|
+
};
|
|
1377
|
+
const controls = useVoiceProviderSimulationControls(options);
|
|
1378
|
+
const model = computed(() => createVoiceProviderSimulationControlsViewModel({
|
|
1379
|
+
error: controls.error.value,
|
|
1380
|
+
isRunning: controls.isRunning.value,
|
|
1381
|
+
lastResult: controls.lastResult.value,
|
|
1382
|
+
mode: controls.mode.value,
|
|
1383
|
+
provider: controls.provider.value,
|
|
1384
|
+
updatedAt: controls.updatedAt.value
|
|
1385
|
+
}, options));
|
|
1386
|
+
const run = (provider, mode) => {
|
|
1387
|
+
controls.run(provider, mode).catch(() => {});
|
|
1388
|
+
};
|
|
1389
|
+
return () => h4("section", {
|
|
1390
|
+
class: [
|
|
1391
|
+
"absolute-voice-provider-simulation",
|
|
1392
|
+
`absolute-voice-provider-simulation--${controls.error.value ? "error" : controls.isRunning.value ? "running" : "ready"}`,
|
|
1393
|
+
props.class
|
|
1394
|
+
]
|
|
1395
|
+
}, [
|
|
1396
|
+
h4("header", { class: "absolute-voice-provider-simulation__header" }, [
|
|
1397
|
+
h4("span", { class: "absolute-voice-provider-simulation__eyebrow" }, model.value.title),
|
|
1398
|
+
h4("strong", { class: "absolute-voice-provider-simulation__label" }, model.value.label)
|
|
1399
|
+
]),
|
|
1400
|
+
h4("p", { class: "absolute-voice-provider-simulation__description" }, model.value.description),
|
|
1401
|
+
model.value.canSimulateFailure ? null : h4("p", { class: "absolute-voice-provider-simulation__empty" }, props.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure."),
|
|
1402
|
+
h4("div", { class: "absolute-voice-provider-simulation__actions" }, [
|
|
1403
|
+
...model.value.failureProviders.map((provider) => h4("button", {
|
|
1404
|
+
disabled: !model.value.canSimulateFailure || controls.isRunning.value,
|
|
1405
|
+
key: `fail-${provider.provider}`,
|
|
1406
|
+
onClick: () => run(provider.provider, "failure"),
|
|
1407
|
+
type: "button"
|
|
1408
|
+
}, `Simulate ${provider.provider} ${props.kind.toUpperCase()} failure`)),
|
|
1409
|
+
...model.value.providers.map((provider) => h4("button", {
|
|
1410
|
+
disabled: controls.isRunning.value,
|
|
1411
|
+
key: `recover-${provider.provider}`,
|
|
1412
|
+
onClick: () => run(provider.provider, "recovery"),
|
|
1413
|
+
type: "button"
|
|
1414
|
+
}, `Mark ${provider.provider} recovered`))
|
|
1415
|
+
]),
|
|
1416
|
+
controls.error.value ? h4("p", { class: "absolute-voice-provider-simulation__error" }, controls.error.value) : null,
|
|
1417
|
+
model.value.resultText ? h4("pre", { class: "absolute-voice-provider-simulation__result" }, model.value.resultText) : null
|
|
1418
|
+
]);
|
|
1419
|
+
}
|
|
1420
|
+
});
|
|
1421
|
+
// src/vue/VoiceProviderCapabilities.ts
|
|
1422
|
+
import { computed as computed2, defineComponent as defineComponent5, h as h5 } from "vue";
|
|
1423
|
+
|
|
1424
|
+
// src/client/providerCapabilities.ts
|
|
1425
|
+
var fetchVoiceProviderCapabilities = async (path = "/api/provider-capabilities", options = {}) => {
|
|
1426
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1427
|
+
const response = await fetchImpl(path);
|
|
1428
|
+
if (!response.ok) {
|
|
1429
|
+
throw new Error(`Voice provider capabilities failed: HTTP ${response.status}`);
|
|
1430
|
+
}
|
|
1431
|
+
return await response.json();
|
|
1432
|
+
};
|
|
1433
|
+
var createVoiceProviderCapabilitiesStore = (path = "/api/provider-capabilities", options = {}) => {
|
|
1434
|
+
const listeners = new Set;
|
|
1435
|
+
let closed = false;
|
|
1436
|
+
let timer;
|
|
1437
|
+
let snapshot = {
|
|
1438
|
+
error: null,
|
|
1439
|
+
isLoading: false
|
|
1440
|
+
};
|
|
1441
|
+
const emit = () => {
|
|
1442
|
+
for (const listener of listeners) {
|
|
1443
|
+
listener();
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
const refresh = async () => {
|
|
1447
|
+
if (closed) {
|
|
1448
|
+
return snapshot.report;
|
|
1449
|
+
}
|
|
1450
|
+
snapshot = {
|
|
1451
|
+
...snapshot,
|
|
1452
|
+
error: null,
|
|
1453
|
+
isLoading: true
|
|
1454
|
+
};
|
|
1455
|
+
emit();
|
|
1456
|
+
try {
|
|
1457
|
+
const report = await fetchVoiceProviderCapabilities(path, options);
|
|
1458
|
+
snapshot = {
|
|
1459
|
+
error: null,
|
|
1460
|
+
isLoading: false,
|
|
1461
|
+
report,
|
|
1462
|
+
updatedAt: Date.now()
|
|
1463
|
+
};
|
|
1464
|
+
emit();
|
|
1465
|
+
return report;
|
|
1466
|
+
} catch (error) {
|
|
1467
|
+
snapshot = {
|
|
1468
|
+
...snapshot,
|
|
1469
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1470
|
+
isLoading: false
|
|
1471
|
+
};
|
|
1472
|
+
emit();
|
|
1473
|
+
throw error;
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
const close = () => {
|
|
1477
|
+
closed = true;
|
|
1478
|
+
if (timer) {
|
|
1479
|
+
clearInterval(timer);
|
|
1480
|
+
timer = undefined;
|
|
1481
|
+
}
|
|
1482
|
+
listeners.clear();
|
|
1483
|
+
};
|
|
1484
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
1485
|
+
timer = setInterval(() => {
|
|
1486
|
+
refresh().catch(() => {});
|
|
1487
|
+
}, options.intervalMs);
|
|
1488
|
+
}
|
|
1489
|
+
return {
|
|
1490
|
+
close,
|
|
1491
|
+
getServerSnapshot: () => snapshot,
|
|
1492
|
+
getSnapshot: () => snapshot,
|
|
1493
|
+
refresh,
|
|
1494
|
+
subscribe: (listener) => {
|
|
1495
|
+
listeners.add(listener);
|
|
1496
|
+
return () => {
|
|
1497
|
+
listeners.delete(listener);
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
// src/client/providerCapabilitiesWidget.ts
|
|
1504
|
+
var DEFAULT_TITLE4 = "Provider Capabilities";
|
|
1505
|
+
var DEFAULT_DESCRIPTION4 = "Configured, selected, and healthy voice providers for this deployment.";
|
|
1506
|
+
var escapeHtml5 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1507
|
+
var formatProvider = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
1508
|
+
var formatKind2 = (kind) => kind.toUpperCase();
|
|
1509
|
+
var formatStatus = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
1510
|
+
var getCapabilityDetail = (capability) => {
|
|
1511
|
+
if (!capability.configured) {
|
|
1512
|
+
return "Not configured in this deployment.";
|
|
1513
|
+
}
|
|
1514
|
+
if (capability.selected) {
|
|
1515
|
+
return `Selected ${capability.kind.toUpperCase()} provider for new sessions.`;
|
|
1516
|
+
}
|
|
1517
|
+
if (capability.health?.status === "healthy") {
|
|
1518
|
+
return "Configured and healthy fallback candidate.";
|
|
1519
|
+
}
|
|
1520
|
+
if (capability.health?.status === "idle") {
|
|
1521
|
+
return "Configured; no traffic observed yet.";
|
|
1522
|
+
}
|
|
1523
|
+
if (capability.health?.lastError) {
|
|
1524
|
+
return capability.health.lastError;
|
|
1525
|
+
}
|
|
1526
|
+
return "Configured and available.";
|
|
1527
|
+
};
|
|
1528
|
+
var isWarningStatus = (status) => status === "degraded" || status === "rate-limited" || status === "suppressed" || status === "unconfigured";
|
|
1529
|
+
var createVoiceProviderCapabilitiesViewModel = (snapshot, options = {}) => {
|
|
1530
|
+
const capabilities = (snapshot.report?.capabilities ?? []).map((capability) => ({
|
|
1531
|
+
...capability,
|
|
1532
|
+
detail: getCapabilityDetail(capability),
|
|
1533
|
+
label: `${formatProvider(capability.provider)} ${formatKind2(capability.kind)}`,
|
|
1534
|
+
rows: [
|
|
1535
|
+
{ label: "Status", value: formatStatus(capability.status) },
|
|
1536
|
+
{ label: "Selected", value: capability.selected ? "Yes" : "No" },
|
|
1537
|
+
{ label: "Model", value: capability.model ?? "Default" },
|
|
1538
|
+
{
|
|
1539
|
+
label: "Features",
|
|
1540
|
+
value: capability.features?.join(", ") || "Not specified"
|
|
1541
|
+
},
|
|
1542
|
+
{ label: "Runs", value: String(capability.health?.runCount ?? 0) },
|
|
1543
|
+
{ label: "Errors", value: String(capability.health?.errorCount ?? 0) }
|
|
1544
|
+
]
|
|
1545
|
+
}));
|
|
1546
|
+
const warningCount = capabilities.filter((capability) => isWarningStatus(capability.status)).length;
|
|
1547
|
+
const selectedCount = snapshot.report?.selected ?? capabilities.filter((capability) => capability.selected).length;
|
|
1548
|
+
return {
|
|
1549
|
+
capabilities,
|
|
1550
|
+
description: options.description ?? DEFAULT_DESCRIPTION4,
|
|
1551
|
+
error: snapshot.error,
|
|
1552
|
+
isLoading: snapshot.isLoading,
|
|
1553
|
+
label: snapshot.error ? "Unavailable" : capabilities.length ? warningCount > 0 ? `${warningCount} needs attention` : `${selectedCount} selected` : snapshot.isLoading ? "Checking" : "No capabilities",
|
|
1554
|
+
status: snapshot.error ? "error" : capabilities.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
1555
|
+
title: options.title ?? DEFAULT_TITLE4,
|
|
1556
|
+
updatedAt: snapshot.updatedAt
|
|
1557
|
+
};
|
|
1558
|
+
};
|
|
1559
|
+
var renderVoiceProviderCapabilitiesHTML = (snapshot, options = {}) => {
|
|
1560
|
+
const model = createVoiceProviderCapabilitiesViewModel(snapshot, options);
|
|
1561
|
+
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--${escapeHtml5(capability.status)}">
|
|
1562
|
+
<header>
|
|
1563
|
+
<strong>${escapeHtml5(capability.label)}</strong>
|
|
1564
|
+
<span>${escapeHtml5(formatStatus(capability.status))}</span>
|
|
1565
|
+
</header>
|
|
1566
|
+
<p>${escapeHtml5(capability.detail)}</p>
|
|
1567
|
+
<dl>${capability.rows.map((row) => `<div>
|
|
1568
|
+
<dt>${escapeHtml5(row.label)}</dt>
|
|
1569
|
+
<dd>${escapeHtml5(row.value)}</dd>
|
|
1570
|
+
</div>`).join("")}</dl>
|
|
1571
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-capabilities__empty">Configure provider capabilities to see deployment coverage.</p>';
|
|
1572
|
+
return `<section class="absolute-voice-provider-capabilities absolute-voice-provider-capabilities--${escapeHtml5(model.status)}">
|
|
1573
|
+
<header class="absolute-voice-provider-capabilities__header">
|
|
1574
|
+
<span class="absolute-voice-provider-capabilities__eyebrow">${escapeHtml5(model.title)}</span>
|
|
1575
|
+
<strong class="absolute-voice-provider-capabilities__label">${escapeHtml5(model.label)}</strong>
|
|
1576
|
+
</header>
|
|
1577
|
+
<p class="absolute-voice-provider-capabilities__description">${escapeHtml5(model.description)}</p>
|
|
1578
|
+
${capabilities}
|
|
1579
|
+
${model.error ? `<p class="absolute-voice-provider-capabilities__error">${escapeHtml5(model.error)}</p>` : ""}
|
|
1580
|
+
</section>`;
|
|
1581
|
+
};
|
|
1582
|
+
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}`;
|
|
1583
|
+
var mountVoiceProviderCapabilities = (element, path = "/api/provider-capabilities", options = {}) => {
|
|
1584
|
+
const store = createVoiceProviderCapabilitiesStore(path, options);
|
|
1585
|
+
const render = () => {
|
|
1586
|
+
element.innerHTML = renderVoiceProviderCapabilitiesHTML(store.getSnapshot(), options);
|
|
1587
|
+
};
|
|
1588
|
+
const unsubscribe = store.subscribe(render);
|
|
1589
|
+
render();
|
|
1590
|
+
store.refresh().catch(() => {});
|
|
1591
|
+
return {
|
|
1592
|
+
close: () => {
|
|
1593
|
+
unsubscribe();
|
|
1594
|
+
store.close();
|
|
1595
|
+
},
|
|
1596
|
+
refresh: store.refresh
|
|
1597
|
+
};
|
|
1598
|
+
};
|
|
1599
|
+
var defineVoiceProviderCapabilitiesElement = (tagName = "absolute-voice-provider-capabilities") => {
|
|
1600
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1601
|
+
return;
|
|
1602
|
+
}
|
|
1603
|
+
customElements.define(tagName, class AbsoluteVoiceProviderCapabilitiesElement extends HTMLElement {
|
|
1604
|
+
mounted;
|
|
1605
|
+
connectedCallback() {
|
|
1606
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
1607
|
+
this.mounted = mountVoiceProviderCapabilities(this, this.getAttribute("path") ?? "/api/provider-capabilities", {
|
|
1608
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1609
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
1610
|
+
title: this.getAttribute("title") ?? undefined
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
disconnectedCallback() {
|
|
1614
|
+
this.mounted?.close();
|
|
1615
|
+
this.mounted = undefined;
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
};
|
|
1619
|
+
|
|
1620
|
+
// src/vue/useVoiceProviderCapabilities.ts
|
|
1621
|
+
import { onUnmounted as onUnmounted5, shallowRef as shallowRef4 } from "vue";
|
|
1622
|
+
function useVoiceProviderCapabilities(path = "/api/provider-capabilities", options = {}) {
|
|
1623
|
+
const store = createVoiceProviderCapabilitiesStore(path, options);
|
|
1624
|
+
const error = shallowRef4(null);
|
|
1625
|
+
const isLoading = shallowRef4(false);
|
|
1626
|
+
const report = shallowRef4();
|
|
1627
|
+
const updatedAt = shallowRef4(undefined);
|
|
1628
|
+
const sync = () => {
|
|
1629
|
+
const snapshot = store.getSnapshot();
|
|
1630
|
+
error.value = snapshot.error;
|
|
1631
|
+
isLoading.value = snapshot.isLoading;
|
|
1632
|
+
report.value = snapshot.report;
|
|
1633
|
+
updatedAt.value = snapshot.updatedAt;
|
|
1634
|
+
};
|
|
1635
|
+
const unsubscribe = store.subscribe(sync);
|
|
1636
|
+
sync();
|
|
1637
|
+
store.refresh().catch(() => {});
|
|
1638
|
+
onUnmounted5(() => {
|
|
1639
|
+
unsubscribe();
|
|
1640
|
+
store.close();
|
|
1641
|
+
});
|
|
1642
|
+
return {
|
|
1643
|
+
error,
|
|
1644
|
+
isLoading,
|
|
1645
|
+
refresh: store.refresh,
|
|
1646
|
+
report,
|
|
1647
|
+
updatedAt
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// src/vue/VoiceProviderCapabilities.ts
|
|
1652
|
+
var VoiceProviderCapabilities = defineComponent5({
|
|
1653
|
+
name: "VoiceProviderCapabilities",
|
|
1654
|
+
props: {
|
|
1655
|
+
class: {
|
|
1656
|
+
default: "",
|
|
1657
|
+
type: String
|
|
1658
|
+
},
|
|
1659
|
+
description: {
|
|
1660
|
+
default: undefined,
|
|
1661
|
+
type: String
|
|
1662
|
+
},
|
|
1663
|
+
intervalMs: {
|
|
1664
|
+
default: 5000,
|
|
1665
|
+
type: Number
|
|
1666
|
+
},
|
|
1667
|
+
path: {
|
|
1668
|
+
default: "/api/provider-capabilities",
|
|
1669
|
+
type: String
|
|
1670
|
+
},
|
|
1671
|
+
title: {
|
|
1672
|
+
default: undefined,
|
|
1673
|
+
type: String
|
|
1674
|
+
}
|
|
1675
|
+
},
|
|
1676
|
+
setup(props) {
|
|
1677
|
+
const options = {
|
|
1678
|
+
description: props.description,
|
|
1679
|
+
intervalMs: props.intervalMs,
|
|
1680
|
+
title: props.title
|
|
1681
|
+
};
|
|
1682
|
+
const capabilities = useVoiceProviderCapabilities(props.path, options);
|
|
1683
|
+
const model = computed2(() => createVoiceProviderCapabilitiesViewModel({
|
|
1684
|
+
error: capabilities.error.value,
|
|
1685
|
+
isLoading: capabilities.isLoading.value,
|
|
1686
|
+
report: capabilities.report.value,
|
|
1687
|
+
updatedAt: capabilities.updatedAt.value
|
|
1688
|
+
}, options));
|
|
1689
|
+
return () => h5("section", {
|
|
1690
|
+
class: [
|
|
1691
|
+
"absolute-voice-provider-capabilities",
|
|
1692
|
+
`absolute-voice-provider-capabilities--${model.value.status}`,
|
|
1693
|
+
props.class
|
|
1694
|
+
]
|
|
1695
|
+
}, [
|
|
1696
|
+
h5("header", { class: "absolute-voice-provider-capabilities__header" }, [
|
|
1697
|
+
h5("span", { class: "absolute-voice-provider-capabilities__eyebrow" }, model.value.title),
|
|
1698
|
+
h5("strong", { class: "absolute-voice-provider-capabilities__label" }, model.value.label)
|
|
1699
|
+
]),
|
|
1700
|
+
h5("p", { class: "absolute-voice-provider-capabilities__description" }, model.value.description),
|
|
1701
|
+
model.value.capabilities.length ? h5("div", { class: "absolute-voice-provider-capabilities__providers" }, model.value.capabilities.map((capability) => h5("article", {
|
|
1702
|
+
class: [
|
|
1703
|
+
"absolute-voice-provider-capabilities__provider",
|
|
1704
|
+
`absolute-voice-provider-capabilities__provider--${capability.status}`
|
|
1705
|
+
],
|
|
1706
|
+
key: `${capability.kind}:${capability.provider}`
|
|
1707
|
+
}, [
|
|
1708
|
+
h5("header", [
|
|
1709
|
+
h5("strong", capability.label),
|
|
1710
|
+
h5("span", capability.status)
|
|
1711
|
+
]),
|
|
1712
|
+
h5("p", capability.detail),
|
|
1713
|
+
h5("dl", capability.rows.map((row) => h5("div", { key: row.label }, [
|
|
1714
|
+
h5("dt", row.label),
|
|
1715
|
+
h5("dd", row.value)
|
|
1716
|
+
])))
|
|
1717
|
+
]))) : h5("p", { class: "absolute-voice-provider-capabilities__empty" }, "Configure provider capabilities to see deployment coverage."),
|
|
1718
|
+
model.value.error ? h5("p", { class: "absolute-voice-provider-capabilities__error" }, model.value.error) : null
|
|
1719
|
+
]);
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
// src/vue/VoiceProviderStatus.ts
|
|
1723
|
+
import { computed as computed3, defineComponent as defineComponent6, h as h6 } from "vue";
|
|
1724
|
+
|
|
1725
|
+
// src/client/providerStatus.ts
|
|
1726
|
+
var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
|
|
1727
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1728
|
+
const response = await fetchImpl(path);
|
|
1729
|
+
if (!response.ok) {
|
|
1730
|
+
throw new Error(`Voice provider status failed: HTTP ${response.status}`);
|
|
1731
|
+
}
|
|
1732
|
+
return await response.json();
|
|
1733
|
+
};
|
|
1734
|
+
var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
|
|
1735
|
+
const listeners = new Set;
|
|
1736
|
+
let closed = false;
|
|
1737
|
+
let timer;
|
|
1738
|
+
let snapshot = {
|
|
1739
|
+
error: null,
|
|
1740
|
+
isLoading: false,
|
|
1741
|
+
providers: []
|
|
1742
|
+
};
|
|
1743
|
+
const emit = () => {
|
|
1744
|
+
for (const listener of listeners) {
|
|
1745
|
+
listener();
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
const refresh = async () => {
|
|
1749
|
+
if (closed) {
|
|
1750
|
+
return snapshot.providers;
|
|
1751
|
+
}
|
|
1752
|
+
snapshot = {
|
|
1753
|
+
...snapshot,
|
|
1754
|
+
error: null,
|
|
1755
|
+
isLoading: true
|
|
1756
|
+
};
|
|
1757
|
+
emit();
|
|
1758
|
+
try {
|
|
1759
|
+
const providers = await fetchVoiceProviderStatus(path, options);
|
|
1760
|
+
snapshot = {
|
|
1761
|
+
error: null,
|
|
1762
|
+
isLoading: false,
|
|
1763
|
+
providers,
|
|
1764
|
+
updatedAt: Date.now()
|
|
1765
|
+
};
|
|
1766
|
+
emit();
|
|
1767
|
+
return providers;
|
|
1768
|
+
} catch (error) {
|
|
1769
|
+
snapshot = {
|
|
1770
|
+
...snapshot,
|
|
1771
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1772
|
+
isLoading: false
|
|
1773
|
+
};
|
|
1774
|
+
emit();
|
|
1775
|
+
throw error;
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
const close = () => {
|
|
1779
|
+
closed = true;
|
|
1780
|
+
if (timer) {
|
|
1781
|
+
clearInterval(timer);
|
|
1782
|
+
timer = undefined;
|
|
1783
|
+
}
|
|
1784
|
+
listeners.clear();
|
|
1785
|
+
};
|
|
1786
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
1787
|
+
timer = setInterval(() => {
|
|
1788
|
+
refresh().catch(() => {});
|
|
1789
|
+
}, options.intervalMs);
|
|
1790
|
+
}
|
|
1791
|
+
return {
|
|
1792
|
+
close,
|
|
1793
|
+
getServerSnapshot: () => snapshot,
|
|
1794
|
+
getSnapshot: () => snapshot,
|
|
1795
|
+
refresh,
|
|
1796
|
+
subscribe: (listener) => {
|
|
1797
|
+
listeners.add(listener);
|
|
1798
|
+
return () => {
|
|
1799
|
+
listeners.delete(listener);
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
};
|
|
1803
|
+
};
|
|
1804
|
+
|
|
1805
|
+
// src/client/providerStatusWidget.ts
|
|
1806
|
+
var DEFAULT_TITLE5 = "Voice Providers";
|
|
1807
|
+
var DEFAULT_DESCRIPTION5 = "Live provider health, fallback counts, latency, and suppression state from your self-hosted trace store.";
|
|
1808
|
+
var escapeHtml6 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1809
|
+
var formatProvider2 = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
1810
|
+
var formatStatus2 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
1811
|
+
var formatLatency = (value) => typeof value === "number" ? `${value}ms` : "No samples";
|
|
1812
|
+
var formatSuppression = (value) => typeof value === "number" ? `${Math.ceil(value / 1000)}s` : "None";
|
|
1813
|
+
var getProviderDetail = (provider) => {
|
|
1814
|
+
if (provider.status === "suppressed") {
|
|
1815
|
+
return provider.lastError ? `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)} after ${provider.lastError}.` : `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)}.`;
|
|
1816
|
+
}
|
|
1817
|
+
if (provider.status === "recoverable") {
|
|
1818
|
+
return "Cooldown expired; ready for recovery traffic.";
|
|
1819
|
+
}
|
|
1820
|
+
if (provider.status === "rate-limited") {
|
|
1821
|
+
return "Rate limit detected; router should avoid this provider.";
|
|
1822
|
+
}
|
|
1823
|
+
if (provider.status === "degraded") {
|
|
1824
|
+
return provider.lastError ?? "Recent provider errors detected.";
|
|
1825
|
+
}
|
|
1826
|
+
if (provider.status === "healthy") {
|
|
1827
|
+
return provider.recommended ? "Healthy and currently recommended." : "Healthy and available for routing.";
|
|
1828
|
+
}
|
|
1829
|
+
return "No provider traffic observed yet.";
|
|
1830
|
+
};
|
|
1831
|
+
var isWarningStatus2 = (status) => status === "degraded" || status === "rate-limited" || status === "recoverable" || status === "suppressed";
|
|
1832
|
+
var createVoiceProviderStatusViewModel = (snapshot, options = {}) => {
|
|
1833
|
+
const providers = snapshot.providers.map((provider) => ({
|
|
1834
|
+
...provider,
|
|
1835
|
+
detail: getProviderDetail(provider),
|
|
1836
|
+
label: `${formatProvider2(provider.provider)}${provider.recommended ? " recommended" : ""}`,
|
|
1837
|
+
rows: [
|
|
1838
|
+
{ label: "Runs", value: String(provider.runCount) },
|
|
1839
|
+
{ label: "Avg latency", value: formatLatency(provider.averageElapsedMs) },
|
|
1840
|
+
{ label: "Errors", value: String(provider.errorCount) },
|
|
1841
|
+
{ label: "Timeouts", value: String(provider.timeoutCount) },
|
|
1842
|
+
{ label: "Fallbacks", value: String(provider.fallbackCount) },
|
|
1843
|
+
{
|
|
1844
|
+
label: "Suppression",
|
|
1845
|
+
value: formatSuppression(provider.suppressionRemainingMs)
|
|
1846
|
+
}
|
|
1847
|
+
]
|
|
1848
|
+
}));
|
|
1849
|
+
const warningCount = providers.filter((provider) => isWarningStatus2(provider.status)).length;
|
|
1850
|
+
const healthyCount = providers.filter((provider) => provider.status === "healthy").length;
|
|
1851
|
+
return {
|
|
1852
|
+
description: options.description ?? DEFAULT_DESCRIPTION5,
|
|
1853
|
+
error: snapshot.error,
|
|
1854
|
+
isLoading: snapshot.isLoading,
|
|
1855
|
+
label: snapshot.error ? "Unavailable" : providers.length ? warningCount > 0 ? `${warningCount} needs attention` : `${healthyCount} healthy` : snapshot.isLoading ? "Checking" : "No provider traffic",
|
|
1856
|
+
providers,
|
|
1857
|
+
status: snapshot.error ? "error" : providers.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
1858
|
+
title: options.title ?? DEFAULT_TITLE5,
|
|
1859
|
+
updatedAt: snapshot.updatedAt
|
|
1860
|
+
};
|
|
1861
|
+
};
|
|
1862
|
+
var renderVoiceProviderStatusHTML = (snapshot, options = {}) => {
|
|
1863
|
+
const model = createVoiceProviderStatusViewModel(snapshot, options);
|
|
1864
|
+
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--${escapeHtml6(provider.status)}">
|
|
1865
|
+
<header>
|
|
1866
|
+
<strong>${escapeHtml6(provider.label)}</strong>
|
|
1867
|
+
<span>${escapeHtml6(formatStatus2(provider.status))}</span>
|
|
1868
|
+
</header>
|
|
1869
|
+
<p>${escapeHtml6(provider.detail)}</p>
|
|
1870
|
+
<dl>${provider.rows.map((row) => `<div>
|
|
1871
|
+
<dt>${escapeHtml6(row.label)}</dt>
|
|
1872
|
+
<dd>${escapeHtml6(row.value)}</dd>
|
|
1873
|
+
</div>`).join("")}</dl>
|
|
1874
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-status__empty">Run voice traffic to see provider health.</p>';
|
|
1875
|
+
return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${escapeHtml6(model.status)}">
|
|
1876
|
+
<header class="absolute-voice-provider-status__header">
|
|
1877
|
+
<span class="absolute-voice-provider-status__eyebrow">${escapeHtml6(model.title)}</span>
|
|
1878
|
+
<strong class="absolute-voice-provider-status__label">${escapeHtml6(model.label)}</strong>
|
|
1879
|
+
</header>
|
|
1880
|
+
<p class="absolute-voice-provider-status__description">${escapeHtml6(model.description)}</p>
|
|
1881
|
+
${providers}
|
|
1882
|
+
${model.error ? `<p class="absolute-voice-provider-status__error">${escapeHtml6(model.error)}</p>` : ""}
|
|
1883
|
+
</section>`;
|
|
1884
|
+
};
|
|
1885
|
+
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}`;
|
|
1886
|
+
var mountVoiceProviderStatus = (element, path = "/api/provider-status", options = {}) => {
|
|
1887
|
+
const store = createVoiceProviderStatusStore(path, options);
|
|
1888
|
+
const render = () => {
|
|
1889
|
+
element.innerHTML = renderVoiceProviderStatusHTML(store.getSnapshot(), options);
|
|
1890
|
+
};
|
|
1891
|
+
const unsubscribe = store.subscribe(render);
|
|
1892
|
+
render();
|
|
1893
|
+
store.refresh().catch(() => {});
|
|
1894
|
+
return {
|
|
1895
|
+
close: () => {
|
|
1896
|
+
unsubscribe();
|
|
1897
|
+
store.close();
|
|
1898
|
+
},
|
|
1899
|
+
refresh: store.refresh
|
|
1900
|
+
};
|
|
1901
|
+
};
|
|
1902
|
+
var defineVoiceProviderStatusElement = (tagName = "absolute-voice-provider-status") => {
|
|
1903
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
customElements.define(tagName, class AbsoluteVoiceProviderStatusElement extends HTMLElement {
|
|
1907
|
+
mounted;
|
|
1908
|
+
connectedCallback() {
|
|
1909
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
1910
|
+
this.mounted = mountVoiceProviderStatus(this, this.getAttribute("path") ?? "/api/provider-status", {
|
|
1911
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1912
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
1913
|
+
title: this.getAttribute("title") ?? undefined
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
disconnectedCallback() {
|
|
1917
|
+
this.mounted?.close();
|
|
1918
|
+
this.mounted = undefined;
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
};
|
|
1922
|
+
|
|
1923
|
+
// src/vue/useVoiceProviderStatus.ts
|
|
1924
|
+
import { onUnmounted as onUnmounted6, ref as ref5, shallowRef as shallowRef5 } from "vue";
|
|
1925
|
+
function useVoiceProviderStatus(path = "/api/provider-status", options = {}) {
|
|
1926
|
+
const store = createVoiceProviderStatusStore(path, options);
|
|
1927
|
+
const error = ref5(null);
|
|
1928
|
+
const isLoading = ref5(false);
|
|
1929
|
+
const providers = shallowRef5([]);
|
|
1930
|
+
const updatedAt = ref5(undefined);
|
|
1931
|
+
const sync = () => {
|
|
1932
|
+
const snapshot = store.getSnapshot();
|
|
1933
|
+
error.value = snapshot.error;
|
|
1934
|
+
isLoading.value = snapshot.isLoading;
|
|
1935
|
+
providers.value = [...snapshot.providers];
|
|
1936
|
+
updatedAt.value = snapshot.updatedAt;
|
|
1937
|
+
};
|
|
1938
|
+
const unsubscribe = store.subscribe(sync);
|
|
1939
|
+
sync();
|
|
1940
|
+
store.refresh().catch(() => {});
|
|
1941
|
+
onUnmounted6(() => {
|
|
1942
|
+
unsubscribe();
|
|
1943
|
+
store.close();
|
|
1944
|
+
});
|
|
1945
|
+
return {
|
|
1946
|
+
error,
|
|
1947
|
+
isLoading,
|
|
1948
|
+
providers,
|
|
1949
|
+
refresh: store.refresh,
|
|
1950
|
+
updatedAt
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
// src/vue/VoiceProviderStatus.ts
|
|
1955
|
+
var VoiceProviderStatus = defineComponent6({
|
|
1956
|
+
name: "VoiceProviderStatus",
|
|
1957
|
+
props: {
|
|
1958
|
+
class: {
|
|
1959
|
+
default: "",
|
|
1960
|
+
type: String
|
|
1961
|
+
},
|
|
1962
|
+
description: {
|
|
1963
|
+
default: undefined,
|
|
1964
|
+
type: String
|
|
1965
|
+
},
|
|
1966
|
+
intervalMs: {
|
|
1967
|
+
default: 5000,
|
|
1968
|
+
type: Number
|
|
1969
|
+
},
|
|
1970
|
+
path: {
|
|
1971
|
+
default: "/api/provider-status",
|
|
1972
|
+
type: String
|
|
1973
|
+
},
|
|
1974
|
+
title: {
|
|
1975
|
+
default: undefined,
|
|
1976
|
+
type: String
|
|
1977
|
+
}
|
|
1978
|
+
},
|
|
1979
|
+
setup(props) {
|
|
1980
|
+
const options = {
|
|
1981
|
+
description: props.description,
|
|
1982
|
+
intervalMs: props.intervalMs,
|
|
1983
|
+
title: props.title
|
|
1984
|
+
};
|
|
1985
|
+
const status = useVoiceProviderStatus(props.path, options);
|
|
1986
|
+
const model = computed3(() => createVoiceProviderStatusViewModel({
|
|
1987
|
+
error: status.error.value,
|
|
1988
|
+
isLoading: status.isLoading.value,
|
|
1989
|
+
providers: status.providers.value,
|
|
1990
|
+
updatedAt: status.updatedAt.value
|
|
1991
|
+
}, options));
|
|
1992
|
+
return () => h6("section", {
|
|
1993
|
+
class: [
|
|
1994
|
+
"absolute-voice-provider-status",
|
|
1995
|
+
`absolute-voice-provider-status--${model.value.status}`,
|
|
1996
|
+
props.class
|
|
1997
|
+
]
|
|
1998
|
+
}, [
|
|
1999
|
+
h6("header", { class: "absolute-voice-provider-status__header" }, [
|
|
2000
|
+
h6("span", { class: "absolute-voice-provider-status__eyebrow" }, model.value.title),
|
|
2001
|
+
h6("strong", { class: "absolute-voice-provider-status__label" }, model.value.label)
|
|
2002
|
+
]),
|
|
2003
|
+
h6("p", { class: "absolute-voice-provider-status__description" }, model.value.description),
|
|
2004
|
+
model.value.providers.length ? h6("div", { class: "absolute-voice-provider-status__providers" }, model.value.providers.map((provider) => h6("article", {
|
|
2005
|
+
class: [
|
|
2006
|
+
"absolute-voice-provider-status__provider",
|
|
2007
|
+
`absolute-voice-provider-status__provider--${provider.status}`
|
|
2008
|
+
],
|
|
2009
|
+
key: provider.provider
|
|
2010
|
+
}, [
|
|
2011
|
+
h6("header", [
|
|
2012
|
+
h6("strong", provider.label),
|
|
2013
|
+
h6("span", provider.status)
|
|
2014
|
+
]),
|
|
2015
|
+
h6("p", provider.detail),
|
|
2016
|
+
h6("dl", provider.rows.map((row) => h6("div", { key: row.label }, [
|
|
2017
|
+
h6("dt", row.label),
|
|
2018
|
+
h6("dd", row.value)
|
|
2019
|
+
])))
|
|
2020
|
+
]))) : h6("p", { class: "absolute-voice-provider-status__empty" }, "Run voice traffic to see provider health."),
|
|
2021
|
+
model.value.error ? h6("p", { class: "absolute-voice-provider-status__error" }, model.value.error) : null
|
|
2022
|
+
]);
|
|
2023
|
+
}
|
|
2024
|
+
});
|
|
2025
|
+
// src/vue/VoiceRoutingStatus.ts
|
|
2026
|
+
import { computed as computed4, defineComponent as defineComponent7, h as h7 } from "vue";
|
|
2027
|
+
|
|
2028
|
+
// src/client/routingStatus.ts
|
|
2029
|
+
var fetchVoiceRoutingStatus = async (path = "/api/routing/latest", options = {}) => {
|
|
2030
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2031
|
+
const response = await fetchImpl(path);
|
|
2032
|
+
if (!response.ok) {
|
|
2033
|
+
throw new Error(`Voice routing status failed: HTTP ${response.status}`);
|
|
2034
|
+
}
|
|
2035
|
+
return await response.json();
|
|
2036
|
+
};
|
|
2037
|
+
var createVoiceRoutingStatusStore = (path = "/api/routing/latest", options = {}) => {
|
|
2038
|
+
const listeners = new Set;
|
|
2039
|
+
let closed = false;
|
|
2040
|
+
let timer;
|
|
2041
|
+
let snapshot = {
|
|
2042
|
+
decision: null,
|
|
2043
|
+
error: null,
|
|
2044
|
+
isLoading: false
|
|
2045
|
+
};
|
|
2046
|
+
const emit = () => {
|
|
2047
|
+
for (const listener of listeners) {
|
|
2048
|
+
listener();
|
|
2049
|
+
}
|
|
2050
|
+
};
|
|
2051
|
+
const refresh = async () => {
|
|
2052
|
+
if (closed) {
|
|
2053
|
+
return snapshot.decision;
|
|
2054
|
+
}
|
|
2055
|
+
snapshot = {
|
|
2056
|
+
...snapshot,
|
|
2057
|
+
error: null,
|
|
2058
|
+
isLoading: true
|
|
2059
|
+
};
|
|
2060
|
+
emit();
|
|
2061
|
+
try {
|
|
2062
|
+
const decision = await fetchVoiceRoutingStatus(path, options);
|
|
2063
|
+
snapshot = {
|
|
2064
|
+
decision,
|
|
2065
|
+
error: null,
|
|
2066
|
+
isLoading: false,
|
|
2067
|
+
updatedAt: Date.now()
|
|
2068
|
+
};
|
|
2069
|
+
emit();
|
|
2070
|
+
return decision;
|
|
2071
|
+
} catch (error) {
|
|
2072
|
+
snapshot = {
|
|
2073
|
+
...snapshot,
|
|
2074
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2075
|
+
isLoading: false
|
|
2076
|
+
};
|
|
2077
|
+
emit();
|
|
2078
|
+
throw error;
|
|
2079
|
+
}
|
|
2080
|
+
};
|
|
2081
|
+
const close = () => {
|
|
2082
|
+
closed = true;
|
|
2083
|
+
if (timer) {
|
|
2084
|
+
clearInterval(timer);
|
|
2085
|
+
timer = undefined;
|
|
2086
|
+
}
|
|
2087
|
+
listeners.clear();
|
|
2088
|
+
};
|
|
2089
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2090
|
+
timer = setInterval(() => {
|
|
2091
|
+
refresh().catch(() => {});
|
|
2092
|
+
}, options.intervalMs);
|
|
2093
|
+
}
|
|
2094
|
+
return {
|
|
2095
|
+
close,
|
|
2096
|
+
getServerSnapshot: () => snapshot,
|
|
2097
|
+
getSnapshot: () => snapshot,
|
|
2098
|
+
refresh,
|
|
2099
|
+
subscribe: (listener) => {
|
|
2100
|
+
listeners.add(listener);
|
|
2101
|
+
return () => {
|
|
2102
|
+
listeners.delete(listener);
|
|
2103
|
+
};
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
};
|
|
2107
|
+
|
|
2108
|
+
// src/client/routingStatusWidget.ts
|
|
2109
|
+
var DEFAULT_TITLE6 = "Voice Routing";
|
|
2110
|
+
var DEFAULT_DESCRIPTION6 = "Latest provider routing decision from the self-hosted trace store.";
|
|
2111
|
+
var escapeHtml7 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2112
|
+
var formatValue = (value, fallback = "None") => typeof value === "string" && value.trim() ? value : typeof value === "number" && Number.isFinite(value) ? String(value) : fallback;
|
|
2113
|
+
var createVoiceRoutingStatusViewModel = (snapshot, options = {}) => {
|
|
2114
|
+
const decision = snapshot.decision;
|
|
2115
|
+
const rows = decision ? [
|
|
2116
|
+
{ label: "Kind", value: decision.kind.toUpperCase() },
|
|
2117
|
+
{ label: "Policy", value: formatValue(decision.routing, "Unknown") },
|
|
2118
|
+
{ label: "Provider", value: formatValue(decision.provider, "Unknown") },
|
|
2119
|
+
{
|
|
2120
|
+
label: "Selected",
|
|
2121
|
+
value: formatValue(decision.selectedProvider, "Unknown")
|
|
2122
|
+
},
|
|
2123
|
+
{
|
|
2124
|
+
label: "Fallback",
|
|
2125
|
+
value: formatValue(decision.fallbackProvider)
|
|
2126
|
+
},
|
|
2127
|
+
{ label: "Status", value: formatValue(decision.status, "unknown") },
|
|
2128
|
+
{
|
|
2129
|
+
label: "Latency budget",
|
|
2130
|
+
value: typeof decision.latencyBudgetMs === "number" ? `${decision.latencyBudgetMs}ms` : "None"
|
|
2131
|
+
}
|
|
2132
|
+
] : [];
|
|
2133
|
+
return {
|
|
2134
|
+
decision,
|
|
2135
|
+
description: options.description ?? DEFAULT_DESCRIPTION6,
|
|
2136
|
+
error: snapshot.error,
|
|
2137
|
+
isLoading: snapshot.isLoading,
|
|
2138
|
+
label: snapshot.error ? "Unavailable" : decision ? `${formatValue(decision.kind).toUpperCase()} ${formatValue(decision.status, "unknown")}` : snapshot.isLoading ? "Checking" : "No routing yet",
|
|
2139
|
+
rows,
|
|
2140
|
+
status: snapshot.error ? "error" : decision ? "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2141
|
+
title: options.title ?? DEFAULT_TITLE6,
|
|
2142
|
+
updatedAt: snapshot.updatedAt
|
|
2143
|
+
};
|
|
2144
|
+
};
|
|
2145
|
+
var renderVoiceRoutingStatusHTML = (snapshot, options = {}) => {
|
|
2146
|
+
const model = createVoiceRoutingStatusViewModel(snapshot, options);
|
|
2147
|
+
const rows = model.rows.length ? `<div class="absolute-voice-routing-status__grid">${model.rows.map((row) => `<div>
|
|
2148
|
+
<span>${escapeHtml7(row.label)}</span>
|
|
2149
|
+
<strong>${escapeHtml7(row.value)}</strong>
|
|
2150
|
+
</div>`).join("")}</div>` : '<p class="absolute-voice-routing-status__empty">Start a voice session to see the selected provider.</p>';
|
|
2151
|
+
return `<section class="absolute-voice-routing-status absolute-voice-routing-status--${escapeHtml7(model.status)}">
|
|
2152
|
+
<header class="absolute-voice-routing-status__header">
|
|
2153
|
+
<span class="absolute-voice-routing-status__eyebrow">${escapeHtml7(model.title)}</span>
|
|
2154
|
+
<strong class="absolute-voice-routing-status__label">${escapeHtml7(model.label)}</strong>
|
|
2155
|
+
</header>
|
|
2156
|
+
<p class="absolute-voice-routing-status__description">${escapeHtml7(model.description)}</p>
|
|
2157
|
+
${rows}
|
|
2158
|
+
${model.error ? `<p class="absolute-voice-routing-status__error">${escapeHtml7(model.error)}</p>` : ""}
|
|
2159
|
+
</section>`;
|
|
2160
|
+
};
|
|
2161
|
+
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}`;
|
|
2162
|
+
var mountVoiceRoutingStatus = (element, path = "/api/routing/latest", options = {}) => {
|
|
2163
|
+
const store = createVoiceRoutingStatusStore(path, options);
|
|
2164
|
+
const render = () => {
|
|
2165
|
+
element.innerHTML = renderVoiceRoutingStatusHTML(store.getSnapshot(), options);
|
|
2166
|
+
};
|
|
2167
|
+
const unsubscribe = store.subscribe(render);
|
|
2168
|
+
render();
|
|
2169
|
+
store.refresh().catch(() => {});
|
|
2170
|
+
return {
|
|
2171
|
+
close: () => {
|
|
2172
|
+
unsubscribe();
|
|
2173
|
+
store.close();
|
|
2174
|
+
},
|
|
2175
|
+
refresh: store.refresh
|
|
2176
|
+
};
|
|
2177
|
+
};
|
|
2178
|
+
var defineVoiceRoutingStatusElement = (tagName = "absolute-voice-routing-status") => {
|
|
2179
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
customElements.define(tagName, class AbsoluteVoiceRoutingStatusElement extends HTMLElement {
|
|
2183
|
+
mounted;
|
|
2184
|
+
connectedCallback() {
|
|
2185
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2186
|
+
this.mounted = mountVoiceRoutingStatus(this, this.getAttribute("path") ?? "/api/routing/latest", {
|
|
2187
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2188
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2189
|
+
title: this.getAttribute("title") ?? undefined
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
disconnectedCallback() {
|
|
2193
|
+
this.mounted?.close();
|
|
2194
|
+
this.mounted = undefined;
|
|
2195
|
+
}
|
|
2196
|
+
});
|
|
2197
|
+
};
|
|
2198
|
+
|
|
2199
|
+
// src/vue/useVoiceRoutingStatus.ts
|
|
2200
|
+
import { onUnmounted as onUnmounted7, ref as ref6, shallowRef as shallowRef6 } from "vue";
|
|
2201
|
+
function useVoiceRoutingStatus(path = "/api/routing/latest", options = {}) {
|
|
2202
|
+
const store = createVoiceRoutingStatusStore(path, options);
|
|
2203
|
+
const decision = shallowRef6(null);
|
|
2204
|
+
const error = ref6(null);
|
|
2205
|
+
const isLoading = ref6(false);
|
|
2206
|
+
const updatedAt = ref6(undefined);
|
|
2207
|
+
const sync = () => {
|
|
2208
|
+
const snapshot = store.getSnapshot();
|
|
2209
|
+
decision.value = snapshot.decision;
|
|
2210
|
+
error.value = snapshot.error;
|
|
2211
|
+
isLoading.value = snapshot.isLoading;
|
|
2212
|
+
updatedAt.value = snapshot.updatedAt;
|
|
2213
|
+
};
|
|
2214
|
+
const unsubscribe = store.subscribe(sync);
|
|
2215
|
+
sync();
|
|
2216
|
+
store.refresh().catch(() => {});
|
|
2217
|
+
onUnmounted7(() => {
|
|
2218
|
+
unsubscribe();
|
|
2219
|
+
store.close();
|
|
2220
|
+
});
|
|
2221
|
+
return {
|
|
2222
|
+
decision,
|
|
2223
|
+
error,
|
|
2224
|
+
isLoading,
|
|
2225
|
+
refresh: store.refresh,
|
|
2226
|
+
updatedAt
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
// src/vue/VoiceRoutingStatus.ts
|
|
2231
|
+
var VoiceRoutingStatus = defineComponent7({
|
|
2232
|
+
name: "VoiceRoutingStatus",
|
|
2233
|
+
props: {
|
|
2234
|
+
class: {
|
|
2235
|
+
default: "",
|
|
2236
|
+
type: String
|
|
2237
|
+
},
|
|
2238
|
+
description: {
|
|
2239
|
+
default: undefined,
|
|
2240
|
+
type: String
|
|
2241
|
+
},
|
|
2242
|
+
intervalMs: {
|
|
2243
|
+
default: 5000,
|
|
2244
|
+
type: Number
|
|
2245
|
+
},
|
|
2246
|
+
path: {
|
|
2247
|
+
default: "/api/routing/latest",
|
|
2248
|
+
type: String
|
|
2249
|
+
},
|
|
2250
|
+
title: {
|
|
2251
|
+
default: undefined,
|
|
2252
|
+
type: String
|
|
2253
|
+
}
|
|
2254
|
+
},
|
|
2255
|
+
setup(props) {
|
|
2256
|
+
const options = {
|
|
2257
|
+
description: props.description,
|
|
2258
|
+
intervalMs: props.intervalMs,
|
|
2259
|
+
title: props.title
|
|
2260
|
+
};
|
|
2261
|
+
const status = useVoiceRoutingStatus(props.path, options);
|
|
2262
|
+
const model = computed4(() => createVoiceRoutingStatusViewModel({
|
|
2263
|
+
decision: status.decision.value,
|
|
2264
|
+
error: status.error.value,
|
|
2265
|
+
isLoading: status.isLoading.value,
|
|
2266
|
+
updatedAt: status.updatedAt.value
|
|
2267
|
+
}, options));
|
|
2268
|
+
return () => h7("section", {
|
|
2269
|
+
class: [
|
|
2270
|
+
"absolute-voice-routing-status",
|
|
2271
|
+
`absolute-voice-routing-status--${model.value.status}`,
|
|
2272
|
+
props.class
|
|
2273
|
+
]
|
|
2274
|
+
}, [
|
|
2275
|
+
h7("header", { class: "absolute-voice-routing-status__header" }, [
|
|
2276
|
+
h7("span", { class: "absolute-voice-routing-status__eyebrow" }, model.value.title),
|
|
2277
|
+
h7("strong", { class: "absolute-voice-routing-status__label" }, model.value.label)
|
|
2278
|
+
]),
|
|
2279
|
+
h7("p", { class: "absolute-voice-routing-status__description" }, model.value.description),
|
|
2280
|
+
model.value.rows.length ? h7("div", { class: "absolute-voice-routing-status__grid" }, model.value.rows.map((row) => h7("div", { key: row.label }, [
|
|
2281
|
+
h7("span", row.label),
|
|
2282
|
+
h7("strong", row.value)
|
|
2283
|
+
]))) : h7("p", { class: "absolute-voice-routing-status__empty" }, "Start a voice session to see the selected provider."),
|
|
2284
|
+
model.value.error ? h7("p", { class: "absolute-voice-routing-status__error" }, model.value.error) : null
|
|
2285
|
+
]);
|
|
2286
|
+
}
|
|
2287
|
+
});
|
|
2288
|
+
// src/vue/VoiceTurnLatency.ts
|
|
2289
|
+
import { computed as computed5, defineComponent as defineComponent8, h as h8 } from "vue";
|
|
2290
|
+
|
|
2291
|
+
// src/client/turnLatency.ts
|
|
2292
|
+
var fetchVoiceTurnLatency = async (path = "/api/turn-latency", options = {}) => {
|
|
2293
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2294
|
+
const response = await fetchImpl(path);
|
|
2295
|
+
if (!response.ok) {
|
|
2296
|
+
throw new Error(`Voice turn latency failed: HTTP ${response.status}`);
|
|
2297
|
+
}
|
|
2298
|
+
return await response.json();
|
|
2299
|
+
};
|
|
2300
|
+
var runVoiceTurnLatencyProof = async (path, options = {}) => {
|
|
2301
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2302
|
+
const response = await fetchImpl(path, { method: "POST" });
|
|
2303
|
+
if (!response.ok) {
|
|
2304
|
+
throw new Error(`Voice turn latency proof failed: HTTP ${response.status}`);
|
|
2305
|
+
}
|
|
2306
|
+
return response.json();
|
|
2307
|
+
};
|
|
2308
|
+
var createVoiceTurnLatencyStore = (path = "/api/turn-latency", options = {}) => {
|
|
2309
|
+
const listeners = new Set;
|
|
2310
|
+
let closed = false;
|
|
2311
|
+
let timer;
|
|
2312
|
+
let snapshot = {
|
|
2313
|
+
error: null,
|
|
2314
|
+
isLoading: false
|
|
2315
|
+
};
|
|
2316
|
+
const emit = () => {
|
|
2317
|
+
for (const listener of listeners) {
|
|
2318
|
+
listener();
|
|
2319
|
+
}
|
|
2320
|
+
};
|
|
2321
|
+
const refresh = async () => {
|
|
2322
|
+
if (closed) {
|
|
2323
|
+
return snapshot.report;
|
|
2324
|
+
}
|
|
2325
|
+
snapshot = { ...snapshot, error: null, isLoading: true };
|
|
2326
|
+
emit();
|
|
2327
|
+
try {
|
|
2328
|
+
const report = await fetchVoiceTurnLatency(path, options);
|
|
2329
|
+
snapshot = {
|
|
2330
|
+
error: null,
|
|
2331
|
+
isLoading: false,
|
|
2332
|
+
report,
|
|
2333
|
+
updatedAt: Date.now()
|
|
2334
|
+
};
|
|
2335
|
+
emit();
|
|
2336
|
+
return report;
|
|
2337
|
+
} catch (error) {
|
|
2338
|
+
snapshot = {
|
|
2339
|
+
...snapshot,
|
|
2340
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2341
|
+
isLoading: false
|
|
2342
|
+
};
|
|
2343
|
+
emit();
|
|
2344
|
+
throw error;
|
|
2345
|
+
}
|
|
2346
|
+
};
|
|
2347
|
+
const runProof = async () => {
|
|
2348
|
+
if (!options.proofPath) {
|
|
2349
|
+
throw new Error("Voice turn latency proof path is not configured.");
|
|
2350
|
+
}
|
|
2351
|
+
snapshot = { ...snapshot, error: null, isLoading: true };
|
|
2352
|
+
emit();
|
|
2353
|
+
try {
|
|
2354
|
+
await runVoiceTurnLatencyProof(options.proofPath, options);
|
|
2355
|
+
return await refresh();
|
|
2356
|
+
} catch (error) {
|
|
2357
|
+
snapshot = {
|
|
2358
|
+
...snapshot,
|
|
2359
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2360
|
+
isLoading: false
|
|
2361
|
+
};
|
|
2362
|
+
emit();
|
|
2363
|
+
throw error;
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
const close = () => {
|
|
2367
|
+
closed = true;
|
|
2368
|
+
if (timer) {
|
|
2369
|
+
clearInterval(timer);
|
|
2370
|
+
timer = undefined;
|
|
2371
|
+
}
|
|
2372
|
+
listeners.clear();
|
|
2373
|
+
};
|
|
2374
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2375
|
+
timer = setInterval(() => {
|
|
2376
|
+
refresh().catch(() => {});
|
|
2377
|
+
}, options.intervalMs);
|
|
2378
|
+
}
|
|
2379
|
+
return {
|
|
2380
|
+
close,
|
|
2381
|
+
getServerSnapshot: () => snapshot,
|
|
2382
|
+
getSnapshot: () => snapshot,
|
|
2383
|
+
refresh,
|
|
2384
|
+
runProof,
|
|
2385
|
+
subscribe: (listener) => {
|
|
2386
|
+
listeners.add(listener);
|
|
2387
|
+
return () => {
|
|
2388
|
+
listeners.delete(listener);
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
};
|
|
2393
|
+
|
|
2394
|
+
// src/client/turnLatencyWidget.ts
|
|
2395
|
+
var DEFAULT_TITLE7 = "Turn Latency";
|
|
2396
|
+
var DEFAULT_DESCRIPTION7 = "Per-turn timing from first transcript to commit and assistant response start.";
|
|
2397
|
+
var DEFAULT_PROOF_LABEL = "Run latency proof";
|
|
2398
|
+
var escapeHtml8 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2399
|
+
var formatMs = (value) => typeof value === "number" ? `${Math.round(value)}ms` : "n/a";
|
|
2400
|
+
var createVoiceTurnLatencyViewModel = (snapshot, options = {}) => {
|
|
2401
|
+
const turns = (snapshot.report?.turns ?? []).map((turn) => ({
|
|
2402
|
+
...turn,
|
|
2403
|
+
label: turn.text || "Empty turn",
|
|
2404
|
+
rows: turn.stages.map((stage) => ({
|
|
2405
|
+
label: stage.label,
|
|
2406
|
+
value: formatMs(stage.valueMs)
|
|
2407
|
+
}))
|
|
2408
|
+
}));
|
|
2409
|
+
const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
|
|
2410
|
+
const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
|
|
2411
|
+
return {
|
|
2412
|
+
description: options.description ?? DEFAULT_DESCRIPTION7,
|
|
2413
|
+
error: snapshot.error,
|
|
2414
|
+
isLoading: snapshot.isLoading,
|
|
2415
|
+
label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} slow` : warningCount > 0 ? `${warningCount} warnings` : `avg ${formatMs(snapshot.report?.averageTotalMs)}` : snapshot.isLoading ? "Checking" : "No turns",
|
|
2416
|
+
proofLabel: options.proofPath ? options.proofLabel ?? DEFAULT_PROOF_LABEL : undefined,
|
|
2417
|
+
showProofAction: Boolean(options.proofPath),
|
|
2418
|
+
status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2419
|
+
title: options.title ?? DEFAULT_TITLE7,
|
|
2420
|
+
turns,
|
|
2421
|
+
updatedAt: snapshot.updatedAt
|
|
2422
|
+
};
|
|
2423
|
+
};
|
|
2424
|
+
var renderVoiceTurnLatencyHTML = (snapshot, options = {}) => {
|
|
2425
|
+
const model = createVoiceTurnLatencyViewModel(snapshot, options);
|
|
2426
|
+
const turns = model.turns.length ? `<div class="absolute-voice-turn-latency__turns">${model.turns.map((turn) => `<article class="absolute-voice-turn-latency__turn absolute-voice-turn-latency__turn--${escapeHtml8(turn.status)}">
|
|
2427
|
+
<header>
|
|
2428
|
+
<strong>${escapeHtml8(turn.label)}</strong>
|
|
2429
|
+
<span>${escapeHtml8(turn.status)}</span>
|
|
2430
|
+
</header>
|
|
2431
|
+
<dl>${turn.rows.map((row) => `<div>
|
|
2432
|
+
<dt>${escapeHtml8(row.label)}</dt>
|
|
2433
|
+
<dd>${escapeHtml8(row.value)}</dd>
|
|
2434
|
+
</div>`).join("")}</dl>
|
|
2435
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-turn-latency__empty">Complete a voice turn to see latency diagnostics.</p>';
|
|
2436
|
+
return `<section class="absolute-voice-turn-latency absolute-voice-turn-latency--${escapeHtml8(model.status)}">
|
|
2437
|
+
<header class="absolute-voice-turn-latency__header">
|
|
2438
|
+
<span class="absolute-voice-turn-latency__eyebrow">${escapeHtml8(model.title)}</span>
|
|
2439
|
+
<strong class="absolute-voice-turn-latency__label">${escapeHtml8(model.label)}</strong>
|
|
2440
|
+
</header>
|
|
2441
|
+
<p class="absolute-voice-turn-latency__description">${escapeHtml8(model.description)}</p>
|
|
2442
|
+
${model.showProofAction ? `<button class="absolute-voice-turn-latency__proof" data-absolute-voice-turn-latency-proof type="button">${escapeHtml8(model.proofLabel ?? DEFAULT_PROOF_LABEL)}</button>` : ""}
|
|
2443
|
+
${turns}
|
|
2444
|
+
${model.error ? `<p class="absolute-voice-turn-latency__error">${escapeHtml8(model.error)}</p>` : ""}
|
|
2445
|
+
</section>`;
|
|
2446
|
+
};
|
|
2447
|
+
var mountVoiceTurnLatency = (element, path = "/api/turn-latency", options = {}) => {
|
|
2448
|
+
const store = createVoiceTurnLatencyStore(path, options);
|
|
2449
|
+
const render = () => {
|
|
2450
|
+
element.innerHTML = renderVoiceTurnLatencyHTML(store.getSnapshot(), options);
|
|
2451
|
+
};
|
|
2452
|
+
const handleClick = (event) => {
|
|
2453
|
+
const target = event.target;
|
|
2454
|
+
if (target instanceof Element && target.closest("[data-absolute-voice-turn-latency-proof]")) {
|
|
2455
|
+
store.runProof().catch(() => {});
|
|
2456
|
+
}
|
|
2457
|
+
};
|
|
2458
|
+
const unsubscribe = store.subscribe(render);
|
|
2459
|
+
element.addEventListener("click", handleClick);
|
|
2460
|
+
render();
|
|
2461
|
+
store.refresh().catch(() => {});
|
|
2462
|
+
return {
|
|
2463
|
+
close: () => {
|
|
2464
|
+
element.removeEventListener("click", handleClick);
|
|
2465
|
+
unsubscribe();
|
|
2466
|
+
store.close();
|
|
2467
|
+
},
|
|
2468
|
+
refresh: store.refresh
|
|
2469
|
+
};
|
|
2470
|
+
};
|
|
2471
|
+
var defineVoiceTurnLatencyElement = (tagName = "absolute-voice-turn-latency") => {
|
|
2472
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2473
|
+
return;
|
|
2474
|
+
}
|
|
2475
|
+
customElements.define(tagName, class AbsoluteVoiceTurnLatencyElement extends HTMLElement {
|
|
2476
|
+
mounted;
|
|
2477
|
+
connectedCallback() {
|
|
2478
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2479
|
+
this.mounted = mountVoiceTurnLatency(this, this.getAttribute("path") ?? "/api/turn-latency", {
|
|
2480
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2481
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2482
|
+
proofLabel: this.getAttribute("proof-label") ?? undefined,
|
|
2483
|
+
proofPath: this.getAttribute("proof-path") ?? undefined,
|
|
2484
|
+
title: this.getAttribute("title") ?? undefined
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
disconnectedCallback() {
|
|
2488
|
+
this.mounted?.close();
|
|
2489
|
+
this.mounted = undefined;
|
|
2490
|
+
}
|
|
2491
|
+
});
|
|
2492
|
+
};
|
|
2493
|
+
|
|
2494
|
+
// src/vue/useVoiceTurnLatency.ts
|
|
2495
|
+
import { onUnmounted as onUnmounted8, shallowRef as shallowRef7 } from "vue";
|
|
2496
|
+
function useVoiceTurnLatency(path = "/api/turn-latency", options = {}) {
|
|
2497
|
+
const store = createVoiceTurnLatencyStore(path, options);
|
|
2498
|
+
const error = shallowRef7(null);
|
|
2499
|
+
const isLoading = shallowRef7(false);
|
|
2500
|
+
const report = shallowRef7();
|
|
2501
|
+
const updatedAt = shallowRef7(undefined);
|
|
2502
|
+
const sync = () => {
|
|
2503
|
+
const snapshot = store.getSnapshot();
|
|
2504
|
+
error.value = snapshot.error;
|
|
2505
|
+
isLoading.value = snapshot.isLoading;
|
|
2506
|
+
report.value = snapshot.report;
|
|
2507
|
+
updatedAt.value = snapshot.updatedAt;
|
|
2508
|
+
};
|
|
2509
|
+
const unsubscribe = store.subscribe(sync);
|
|
2510
|
+
sync();
|
|
2511
|
+
store.refresh().catch(() => {});
|
|
2512
|
+
onUnmounted8(() => {
|
|
2513
|
+
unsubscribe();
|
|
2514
|
+
store.close();
|
|
2515
|
+
});
|
|
2516
|
+
return {
|
|
2517
|
+
error,
|
|
2518
|
+
isLoading,
|
|
2519
|
+
refresh: store.refresh,
|
|
2520
|
+
report,
|
|
2521
|
+
runProof: store.runProof,
|
|
2522
|
+
updatedAt
|
|
2523
|
+
};
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
// src/vue/VoiceTurnLatency.ts
|
|
2527
|
+
var VoiceTurnLatency = defineComponent8({
|
|
2528
|
+
name: "VoiceTurnLatency",
|
|
2529
|
+
props: {
|
|
2530
|
+
class: { default: "", type: String },
|
|
2531
|
+
description: { default: undefined, type: String },
|
|
2532
|
+
intervalMs: { default: 5000, type: Number },
|
|
2533
|
+
path: { default: "/api/turn-latency", type: String },
|
|
2534
|
+
proofLabel: { default: undefined, type: String },
|
|
2535
|
+
proofPath: { default: undefined, type: String },
|
|
2536
|
+
title: { default: undefined, type: String }
|
|
2537
|
+
},
|
|
2538
|
+
setup(props) {
|
|
2539
|
+
const options = {
|
|
2540
|
+
description: props.description,
|
|
2541
|
+
intervalMs: props.intervalMs,
|
|
2542
|
+
proofLabel: props.proofLabel,
|
|
2543
|
+
proofPath: props.proofPath,
|
|
2544
|
+
title: props.title
|
|
2545
|
+
};
|
|
2546
|
+
const latency = useVoiceTurnLatency(props.path, options);
|
|
2547
|
+
const model = computed5(() => createVoiceTurnLatencyViewModel({
|
|
2548
|
+
error: latency.error.value,
|
|
2549
|
+
isLoading: latency.isLoading.value,
|
|
2550
|
+
report: latency.report.value,
|
|
2551
|
+
updatedAt: latency.updatedAt.value
|
|
2552
|
+
}, options));
|
|
2553
|
+
return () => h8("section", {
|
|
2554
|
+
class: [
|
|
2555
|
+
"absolute-voice-turn-latency",
|
|
2556
|
+
`absolute-voice-turn-latency--${model.value.status}`,
|
|
2557
|
+
props.class
|
|
2558
|
+
]
|
|
2559
|
+
}, [
|
|
2560
|
+
h8("header", { class: "absolute-voice-turn-latency__header" }, [
|
|
2561
|
+
h8("span", { class: "absolute-voice-turn-latency__eyebrow" }, model.value.title),
|
|
2562
|
+
h8("strong", { class: "absolute-voice-turn-latency__label" }, model.value.label)
|
|
2563
|
+
]),
|
|
2564
|
+
h8("p", { class: "absolute-voice-turn-latency__description" }, model.value.description),
|
|
2565
|
+
model.value.showProofAction ? h8("button", {
|
|
2566
|
+
class: "absolute-voice-turn-latency__proof",
|
|
2567
|
+
onClick: () => {
|
|
2568
|
+
latency.runProof().catch(() => {});
|
|
2569
|
+
},
|
|
2570
|
+
type: "button"
|
|
2571
|
+
}, model.value.proofLabel) : null,
|
|
2572
|
+
model.value.turns.length ? h8("div", { class: "absolute-voice-turn-latency__turns" }, model.value.turns.map((turn) => h8("article", {
|
|
2573
|
+
class: [
|
|
2574
|
+
"absolute-voice-turn-latency__turn",
|
|
2575
|
+
`absolute-voice-turn-latency__turn--${turn.status}`
|
|
2576
|
+
],
|
|
2577
|
+
key: `${turn.sessionId}:${turn.turnId}`
|
|
2578
|
+
}, [
|
|
2579
|
+
h8("header", [
|
|
2580
|
+
h8("strong", turn.label),
|
|
2581
|
+
h8("span", turn.status)
|
|
2582
|
+
]),
|
|
2583
|
+
h8("dl", turn.rows.map((row) => h8("div", { key: row.label }, [
|
|
2584
|
+
h8("dt", row.label),
|
|
2585
|
+
h8("dd", row.value)
|
|
2586
|
+
])))
|
|
2587
|
+
]))) : h8("p", { class: "absolute-voice-turn-latency__empty" }, "Complete a voice turn to see latency diagnostics."),
|
|
2588
|
+
model.value.error ? h8("p", { class: "absolute-voice-turn-latency__error" }, model.value.error) : null
|
|
2589
|
+
]);
|
|
2590
|
+
}
|
|
2591
|
+
});
|
|
2592
|
+
// src/vue/VoiceTurnQuality.ts
|
|
2593
|
+
import { computed as computed6, defineComponent as defineComponent9, h as h9 } from "vue";
|
|
2594
|
+
|
|
2595
|
+
// src/client/turnQuality.ts
|
|
2596
|
+
var fetchVoiceTurnQuality = async (path = "/api/turn-quality", options = {}) => {
|
|
2597
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2598
|
+
const response = await fetchImpl(path);
|
|
2599
|
+
if (!response.ok) {
|
|
2600
|
+
throw new Error(`Voice turn quality failed: HTTP ${response.status}`);
|
|
2601
|
+
}
|
|
2602
|
+
return await response.json();
|
|
2603
|
+
};
|
|
2604
|
+
var createVoiceTurnQualityStore = (path = "/api/turn-quality", options = {}) => {
|
|
2605
|
+
const listeners = new Set;
|
|
2606
|
+
let closed = false;
|
|
2607
|
+
let timer;
|
|
2608
|
+
let snapshot = {
|
|
2609
|
+
error: null,
|
|
2610
|
+
isLoading: false
|
|
2611
|
+
};
|
|
2612
|
+
const emit = () => {
|
|
2613
|
+
for (const listener of listeners) {
|
|
2614
|
+
listener();
|
|
2615
|
+
}
|
|
2616
|
+
};
|
|
2617
|
+
const refresh = async () => {
|
|
2618
|
+
if (closed) {
|
|
2619
|
+
return snapshot.report;
|
|
2620
|
+
}
|
|
2621
|
+
snapshot = {
|
|
2622
|
+
...snapshot,
|
|
2623
|
+
error: null,
|
|
2624
|
+
isLoading: true
|
|
2625
|
+
};
|
|
2626
|
+
emit();
|
|
2627
|
+
try {
|
|
2628
|
+
const report = await fetchVoiceTurnQuality(path, options);
|
|
2629
|
+
snapshot = {
|
|
2630
|
+
error: null,
|
|
2631
|
+
isLoading: false,
|
|
2632
|
+
report,
|
|
2633
|
+
updatedAt: Date.now()
|
|
2634
|
+
};
|
|
2635
|
+
emit();
|
|
2636
|
+
return report;
|
|
2637
|
+
} catch (error) {
|
|
2638
|
+
snapshot = {
|
|
2639
|
+
...snapshot,
|
|
2640
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2641
|
+
isLoading: false
|
|
2642
|
+
};
|
|
2643
|
+
emit();
|
|
2644
|
+
throw error;
|
|
2645
|
+
}
|
|
2646
|
+
};
|
|
2647
|
+
const close = () => {
|
|
2648
|
+
closed = true;
|
|
2649
|
+
if (timer) {
|
|
2650
|
+
clearInterval(timer);
|
|
2651
|
+
timer = undefined;
|
|
2652
|
+
}
|
|
2653
|
+
listeners.clear();
|
|
2654
|
+
};
|
|
2655
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2656
|
+
timer = setInterval(() => {
|
|
2657
|
+
refresh().catch(() => {});
|
|
2658
|
+
}, options.intervalMs);
|
|
2659
|
+
}
|
|
2660
|
+
return {
|
|
2661
|
+
close,
|
|
2662
|
+
getServerSnapshot: () => snapshot,
|
|
2663
|
+
getSnapshot: () => snapshot,
|
|
2664
|
+
refresh,
|
|
2665
|
+
subscribe: (listener) => {
|
|
2666
|
+
listeners.add(listener);
|
|
2667
|
+
return () => {
|
|
2668
|
+
listeners.delete(listener);
|
|
2669
|
+
};
|
|
2670
|
+
}
|
|
2671
|
+
};
|
|
2672
|
+
};
|
|
2673
|
+
|
|
2674
|
+
// src/client/turnQualityWidget.ts
|
|
2675
|
+
var DEFAULT_TITLE8 = "Turn Quality";
|
|
2676
|
+
var DEFAULT_DESCRIPTION8 = "Per-turn STT confidence, fallback selection, corrections, and transcript coverage.";
|
|
2677
|
+
var escapeHtml9 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2678
|
+
var formatConfidence = (value) => typeof value === "number" ? `${Math.round(value * 100)}%` : "n/a";
|
|
2679
|
+
var formatMaybe = (value) => value === undefined || value === "" ? "n/a" : String(value);
|
|
2680
|
+
var getTurnDetail = (turn) => {
|
|
2681
|
+
if (turn.status === "fail") {
|
|
2682
|
+
return "Empty or unusable committed turn; inspect transcripts and adapter events.";
|
|
2683
|
+
}
|
|
2684
|
+
if (turn.fallbackUsed) {
|
|
2685
|
+
return `Fallback STT selected${turn.fallbackSelectionReason ? ` by ${turn.fallbackSelectionReason}` : ""}.`;
|
|
2686
|
+
}
|
|
2687
|
+
if (turn.correctionChanged) {
|
|
2688
|
+
return `Correction changed the turn${turn.correctionProvider ? ` via ${turn.correctionProvider}` : ""}.`;
|
|
2689
|
+
}
|
|
2690
|
+
if (turn.status === "warn") {
|
|
2691
|
+
return "Turn completed with quality warnings.";
|
|
2692
|
+
}
|
|
2693
|
+
if (turn.status === "unknown") {
|
|
2694
|
+
return "No quality diagnostics were recorded for this turn.";
|
|
2695
|
+
}
|
|
2696
|
+
return "Turn quality looks healthy.";
|
|
2697
|
+
};
|
|
2698
|
+
var createVoiceTurnQualityViewModel = (snapshot, options = {}) => {
|
|
2699
|
+
const turns = (snapshot.report?.turns ?? []).map((turn) => ({
|
|
2700
|
+
...turn,
|
|
2701
|
+
detail: getTurnDetail(turn),
|
|
2702
|
+
label: turn.text || "Empty turn",
|
|
2703
|
+
rows: [
|
|
2704
|
+
{ label: "Source", value: turn.source ?? "unknown" },
|
|
2705
|
+
{ label: "Confidence", value: formatConfidence(turn.averageConfidence) },
|
|
2706
|
+
{ label: "Fallback", value: turn.fallbackUsed ? "Yes" : "No" },
|
|
2707
|
+
{ label: "Correction", value: turn.correctionChanged ? "Changed" : "None" },
|
|
2708
|
+
{ label: "Transcripts", value: `${turn.selectedTranscriptCount} selected` },
|
|
2709
|
+
{ label: "Cost", value: formatMaybe(turn.costUnits) }
|
|
2710
|
+
]
|
|
2711
|
+
}));
|
|
2712
|
+
const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
|
|
2713
|
+
const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
|
|
2714
|
+
return {
|
|
2715
|
+
description: options.description ?? DEFAULT_DESCRIPTION8,
|
|
2716
|
+
error: snapshot.error,
|
|
2717
|
+
isLoading: snapshot.isLoading,
|
|
2718
|
+
label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} failed` : warningCount > 0 ? `${warningCount} warnings` : `${turns.length} healthy` : snapshot.isLoading ? "Checking" : "No turns",
|
|
2719
|
+
status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2720
|
+
title: options.title ?? DEFAULT_TITLE8,
|
|
2721
|
+
turns,
|
|
2722
|
+
updatedAt: snapshot.updatedAt
|
|
2723
|
+
};
|
|
2724
|
+
};
|
|
2725
|
+
var renderVoiceTurnQualityHTML = (snapshot, options = {}) => {
|
|
2726
|
+
const model = createVoiceTurnQualityViewModel(snapshot, options);
|
|
2727
|
+
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--${escapeHtml9(turn.status)}">
|
|
2728
|
+
<header>
|
|
2729
|
+
<strong>${escapeHtml9(turn.label)}</strong>
|
|
2730
|
+
<span>${escapeHtml9(turn.status)}</span>
|
|
2731
|
+
</header>
|
|
2732
|
+
<p>${escapeHtml9(turn.detail)}</p>
|
|
2733
|
+
<dl>${turn.rows.map((row) => `<div>
|
|
2734
|
+
<dt>${escapeHtml9(row.label)}</dt>
|
|
2735
|
+
<dd>${escapeHtml9(row.value)}</dd>
|
|
2736
|
+
</div>`).join("")}</dl>
|
|
2737
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-turn-quality__empty">Complete a voice turn to see STT quality diagnostics.</p>';
|
|
2738
|
+
return `<section class="absolute-voice-turn-quality absolute-voice-turn-quality--${escapeHtml9(model.status)}">
|
|
2739
|
+
<header class="absolute-voice-turn-quality__header">
|
|
2740
|
+
<span class="absolute-voice-turn-quality__eyebrow">${escapeHtml9(model.title)}</span>
|
|
2741
|
+
<strong class="absolute-voice-turn-quality__label">${escapeHtml9(model.label)}</strong>
|
|
2742
|
+
</header>
|
|
2743
|
+
<p class="absolute-voice-turn-quality__description">${escapeHtml9(model.description)}</p>
|
|
2744
|
+
${turns}
|
|
2745
|
+
${model.error ? `<p class="absolute-voice-turn-quality__error">${escapeHtml9(model.error)}</p>` : ""}
|
|
2746
|
+
</section>`;
|
|
2747
|
+
};
|
|
2748
|
+
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}`;
|
|
2749
|
+
var mountVoiceTurnQuality = (element, path = "/api/turn-quality", options = {}) => {
|
|
2750
|
+
const store = createVoiceTurnQualityStore(path, options);
|
|
2751
|
+
const render = () => {
|
|
2752
|
+
element.innerHTML = renderVoiceTurnQualityHTML(store.getSnapshot(), options);
|
|
2753
|
+
};
|
|
2754
|
+
const unsubscribe = store.subscribe(render);
|
|
2755
|
+
render();
|
|
2756
|
+
store.refresh().catch(() => {});
|
|
2757
|
+
return {
|
|
2758
|
+
close: () => {
|
|
2759
|
+
unsubscribe();
|
|
2760
|
+
store.close();
|
|
2761
|
+
},
|
|
2762
|
+
refresh: store.refresh
|
|
2763
|
+
};
|
|
2764
|
+
};
|
|
2765
|
+
var defineVoiceTurnQualityElement = (tagName = "absolute-voice-turn-quality") => {
|
|
2766
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2767
|
+
return;
|
|
2768
|
+
}
|
|
2769
|
+
customElements.define(tagName, class AbsoluteVoiceTurnQualityElement extends HTMLElement {
|
|
2770
|
+
mounted;
|
|
2771
|
+
connectedCallback() {
|
|
2772
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2773
|
+
this.mounted = mountVoiceTurnQuality(this, this.getAttribute("path") ?? "/api/turn-quality", {
|
|
2774
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2775
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2776
|
+
title: this.getAttribute("title") ?? undefined
|
|
2777
|
+
});
|
|
2778
|
+
}
|
|
2779
|
+
disconnectedCallback() {
|
|
2780
|
+
this.mounted?.close();
|
|
2781
|
+
this.mounted = undefined;
|
|
2782
|
+
}
|
|
2783
|
+
});
|
|
2784
|
+
};
|
|
2785
|
+
|
|
2786
|
+
// src/vue/useVoiceTurnQuality.ts
|
|
2787
|
+
import { onUnmounted as onUnmounted9, shallowRef as shallowRef8 } from "vue";
|
|
2788
|
+
function useVoiceTurnQuality(path = "/api/turn-quality", options = {}) {
|
|
2789
|
+
const store = createVoiceTurnQualityStore(path, options);
|
|
2790
|
+
const error = shallowRef8(null);
|
|
2791
|
+
const isLoading = shallowRef8(false);
|
|
2792
|
+
const report = shallowRef8();
|
|
2793
|
+
const updatedAt = shallowRef8(undefined);
|
|
2794
|
+
const sync = () => {
|
|
2795
|
+
const snapshot = store.getSnapshot();
|
|
2796
|
+
error.value = snapshot.error;
|
|
2797
|
+
isLoading.value = snapshot.isLoading;
|
|
2798
|
+
report.value = snapshot.report;
|
|
2799
|
+
updatedAt.value = snapshot.updatedAt;
|
|
2800
|
+
};
|
|
2801
|
+
const unsubscribe = store.subscribe(sync);
|
|
2802
|
+
sync();
|
|
2803
|
+
store.refresh().catch(() => {});
|
|
2804
|
+
onUnmounted9(() => {
|
|
2805
|
+
unsubscribe();
|
|
2806
|
+
store.close();
|
|
2807
|
+
});
|
|
2808
|
+
return { error, isLoading, refresh: store.refresh, report, updatedAt };
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
// src/vue/VoiceTurnQuality.ts
|
|
2812
|
+
var VoiceTurnQuality = defineComponent9({
|
|
2813
|
+
name: "VoiceTurnQuality",
|
|
2814
|
+
props: {
|
|
2815
|
+
class: { default: "", type: String },
|
|
2816
|
+
description: { default: undefined, type: String },
|
|
2817
|
+
intervalMs: { default: 5000, type: Number },
|
|
2818
|
+
path: { default: "/api/turn-quality", type: String },
|
|
2819
|
+
title: { default: undefined, type: String }
|
|
2820
|
+
},
|
|
2821
|
+
setup(props) {
|
|
2822
|
+
const options = {
|
|
2823
|
+
description: props.description,
|
|
2824
|
+
intervalMs: props.intervalMs,
|
|
2825
|
+
title: props.title
|
|
2826
|
+
};
|
|
2827
|
+
const quality = useVoiceTurnQuality(props.path, options);
|
|
2828
|
+
const model = computed6(() => createVoiceTurnQualityViewModel({
|
|
2829
|
+
error: quality.error.value,
|
|
2830
|
+
isLoading: quality.isLoading.value,
|
|
2831
|
+
report: quality.report.value,
|
|
2832
|
+
updatedAt: quality.updatedAt.value
|
|
2833
|
+
}, options));
|
|
2834
|
+
return () => h9("section", {
|
|
2835
|
+
class: [
|
|
2836
|
+
"absolute-voice-turn-quality",
|
|
2837
|
+
`absolute-voice-turn-quality--${model.value.status}`,
|
|
2838
|
+
props.class
|
|
2839
|
+
]
|
|
2840
|
+
}, [
|
|
2841
|
+
h9("header", { class: "absolute-voice-turn-quality__header" }, [
|
|
2842
|
+
h9("span", { class: "absolute-voice-turn-quality__eyebrow" }, model.value.title),
|
|
2843
|
+
h9("strong", { class: "absolute-voice-turn-quality__label" }, model.value.label)
|
|
2844
|
+
]),
|
|
2845
|
+
h9("p", { class: "absolute-voice-turn-quality__description" }, model.value.description),
|
|
2846
|
+
model.value.turns.length ? h9("div", { class: "absolute-voice-turn-quality__turns" }, model.value.turns.map((turn) => h9("article", {
|
|
2847
|
+
class: [
|
|
2848
|
+
"absolute-voice-turn-quality__turn",
|
|
2849
|
+
`absolute-voice-turn-quality__turn--${turn.status}`
|
|
2850
|
+
],
|
|
2851
|
+
key: `${turn.sessionId}:${turn.turnId}`
|
|
2852
|
+
}, [
|
|
2853
|
+
h9("header", [
|
|
2854
|
+
h9("strong", turn.label),
|
|
2855
|
+
h9("span", turn.status)
|
|
2856
|
+
]),
|
|
2857
|
+
h9("p", turn.detail),
|
|
2858
|
+
h9("dl", turn.rows.map((row) => h9("div", { key: row.label }, [
|
|
2859
|
+
h9("dt", row.label),
|
|
2860
|
+
h9("dd", row.value)
|
|
2861
|
+
])))
|
|
2862
|
+
]))) : h9("p", { class: "absolute-voice-turn-quality__empty" }, "Complete a voice turn to see STT quality diagnostics."),
|
|
2863
|
+
model.value.error ? h9("p", { class: "absolute-voice-turn-quality__error" }, model.value.error) : null
|
|
2864
|
+
]);
|
|
2865
|
+
}
|
|
2866
|
+
});
|
|
2867
|
+
// src/vue/useVoiceCampaignDialerProof.ts
|
|
2868
|
+
import { onUnmounted as onUnmounted10, shallowRef as shallowRef9 } from "vue";
|
|
2869
|
+
|
|
2870
|
+
// src/client/campaignDialerProof.ts
|
|
2871
|
+
var fetchVoiceCampaignDialerProofStatus = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
|
|
2872
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2873
|
+
const response = await fetchImpl(path);
|
|
2874
|
+
if (!response.ok) {
|
|
2875
|
+
throw new Error(`Voice campaign dialer proof status failed: HTTP ${response.status}`);
|
|
2876
|
+
}
|
|
2877
|
+
return await response.json();
|
|
2878
|
+
};
|
|
2879
|
+
var runVoiceCampaignDialerProofAction = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
|
|
2880
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2881
|
+
const response = await fetchImpl(path, { method: "POST" });
|
|
2882
|
+
if (!response.ok) {
|
|
2883
|
+
throw new Error(`Voice campaign dialer proof failed: HTTP ${response.status}`);
|
|
2884
|
+
}
|
|
2885
|
+
return await response.json();
|
|
2886
|
+
};
|
|
2887
|
+
var createVoiceCampaignDialerProofStore = (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
|
|
2888
|
+
const listeners = new Set;
|
|
2889
|
+
let closed = false;
|
|
2890
|
+
let timer;
|
|
2891
|
+
let snapshot = {
|
|
2892
|
+
error: null,
|
|
2893
|
+
isLoading: false
|
|
2894
|
+
};
|
|
2895
|
+
const emit = () => {
|
|
2896
|
+
for (const listener of listeners) {
|
|
2897
|
+
listener();
|
|
2898
|
+
}
|
|
2899
|
+
};
|
|
2900
|
+
const refresh = async () => {
|
|
2901
|
+
if (closed) {
|
|
2902
|
+
return snapshot.status;
|
|
2903
|
+
}
|
|
2904
|
+
snapshot = { ...snapshot, error: null, isLoading: true };
|
|
2905
|
+
emit();
|
|
2906
|
+
try {
|
|
2907
|
+
const status = await fetchVoiceCampaignDialerProofStatus(path, options);
|
|
2908
|
+
snapshot = {
|
|
2909
|
+
...snapshot,
|
|
2910
|
+
error: null,
|
|
2911
|
+
isLoading: false,
|
|
2912
|
+
status,
|
|
2913
|
+
updatedAt: Date.now()
|
|
2914
|
+
};
|
|
2915
|
+
emit();
|
|
2916
|
+
return status;
|
|
2917
|
+
} catch (error) {
|
|
2918
|
+
snapshot = {
|
|
2919
|
+
...snapshot,
|
|
2920
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2921
|
+
isLoading: false
|
|
2922
|
+
};
|
|
2923
|
+
emit();
|
|
2924
|
+
throw error;
|
|
2925
|
+
}
|
|
2926
|
+
};
|
|
2927
|
+
const runProof = async () => {
|
|
2928
|
+
const runPath = options.runPath ?? snapshot.status?.runPath ?? path;
|
|
2929
|
+
snapshot = { ...snapshot, error: null, isLoading: true };
|
|
2930
|
+
emit();
|
|
2931
|
+
try {
|
|
2932
|
+
const report = await runVoiceCampaignDialerProofAction(runPath, options);
|
|
2933
|
+
snapshot = {
|
|
2934
|
+
...snapshot,
|
|
2935
|
+
error: null,
|
|
2936
|
+
isLoading: false,
|
|
2937
|
+
report,
|
|
2938
|
+
status: {
|
|
2939
|
+
generatedAt: Date.now(),
|
|
2940
|
+
mode: report.mode,
|
|
2941
|
+
ok: report.ok,
|
|
2942
|
+
providers: report.providers.map((provider) => provider.provider),
|
|
2943
|
+
runPath,
|
|
2944
|
+
safe: true
|
|
2945
|
+
},
|
|
2946
|
+
updatedAt: Date.now()
|
|
2947
|
+
};
|
|
2948
|
+
emit();
|
|
2949
|
+
return report;
|
|
2950
|
+
} catch (error) {
|
|
2951
|
+
snapshot = {
|
|
2952
|
+
...snapshot,
|
|
2953
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2954
|
+
isLoading: false
|
|
2955
|
+
};
|
|
2956
|
+
emit();
|
|
2957
|
+
throw error;
|
|
2958
|
+
}
|
|
2959
|
+
};
|
|
2960
|
+
const close = () => {
|
|
2961
|
+
closed = true;
|
|
2962
|
+
if (timer) {
|
|
2963
|
+
clearInterval(timer);
|
|
2964
|
+
timer = undefined;
|
|
2965
|
+
}
|
|
2966
|
+
listeners.clear();
|
|
2967
|
+
};
|
|
2968
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2969
|
+
timer = setInterval(() => {
|
|
2970
|
+
refresh().catch(() => {});
|
|
2971
|
+
}, options.intervalMs);
|
|
2972
|
+
}
|
|
2973
|
+
return {
|
|
2974
|
+
close,
|
|
2975
|
+
getServerSnapshot: () => snapshot,
|
|
2976
|
+
getSnapshot: () => snapshot,
|
|
2977
|
+
refresh,
|
|
2978
|
+
runProof,
|
|
2979
|
+
subscribe: (listener) => {
|
|
2980
|
+
listeners.add(listener);
|
|
2981
|
+
return () => {
|
|
2982
|
+
listeners.delete(listener);
|
|
2983
|
+
};
|
|
2984
|
+
}
|
|
2985
|
+
};
|
|
2986
|
+
};
|
|
2987
|
+
|
|
2988
|
+
// src/vue/useVoiceCampaignDialerProof.ts
|
|
2989
|
+
function useVoiceCampaignDialerProof(path = "/api/voice/campaigns/dialer-proof", options = {}) {
|
|
2990
|
+
const store = createVoiceCampaignDialerProofStore(path, options);
|
|
2991
|
+
const error = shallowRef9(null);
|
|
2992
|
+
const isLoading = shallowRef9(false);
|
|
2993
|
+
const report = shallowRef9();
|
|
2994
|
+
const status = shallowRef9();
|
|
2995
|
+
const updatedAt = shallowRef9(undefined);
|
|
2996
|
+
const sync = () => {
|
|
2997
|
+
const snapshot = store.getSnapshot();
|
|
2998
|
+
error.value = snapshot.error;
|
|
2999
|
+
isLoading.value = snapshot.isLoading;
|
|
3000
|
+
report.value = snapshot.report;
|
|
3001
|
+
status.value = snapshot.status;
|
|
3002
|
+
updatedAt.value = snapshot.updatedAt;
|
|
3003
|
+
};
|
|
3004
|
+
const unsubscribe = store.subscribe(sync);
|
|
3005
|
+
sync();
|
|
3006
|
+
if (typeof window !== "undefined") {
|
|
3007
|
+
store.refresh().catch(() => {});
|
|
3008
|
+
}
|
|
3009
|
+
onUnmounted10(() => {
|
|
3010
|
+
unsubscribe();
|
|
3011
|
+
store.close();
|
|
3012
|
+
});
|
|
3013
|
+
return {
|
|
3014
|
+
error,
|
|
3015
|
+
isLoading,
|
|
3016
|
+
refresh: store.refresh,
|
|
3017
|
+
report,
|
|
3018
|
+
runProof: store.runProof,
|
|
3019
|
+
status,
|
|
3020
|
+
updatedAt
|
|
3021
|
+
};
|
|
3022
|
+
}
|
|
72
3023
|
// src/vue/useVoiceStream.ts
|
|
73
|
-
import { onUnmounted, ref, shallowRef } from "vue";
|
|
3024
|
+
import { onUnmounted as onUnmounted11, ref as ref7, shallowRef as shallowRef10 } from "vue";
|
|
74
3025
|
|
|
75
3026
|
// src/client/actions.ts
|
|
76
3027
|
var normalizeErrorMessage = (value) => {
|
|
@@ -120,6 +3071,17 @@ var serverMessageToAction = (message) => {
|
|
|
120
3071
|
sessionId: message.sessionId,
|
|
121
3072
|
type: "complete"
|
|
122
3073
|
};
|
|
3074
|
+
case "connection":
|
|
3075
|
+
return {
|
|
3076
|
+
reconnect: message.reconnect,
|
|
3077
|
+
type: "connection"
|
|
3078
|
+
};
|
|
3079
|
+
case "call_lifecycle":
|
|
3080
|
+
return {
|
|
3081
|
+
event: message.event,
|
|
3082
|
+
sessionId: message.sessionId,
|
|
3083
|
+
type: "call_lifecycle"
|
|
3084
|
+
};
|
|
123
3085
|
case "error":
|
|
124
3086
|
return {
|
|
125
3087
|
message: normalizeErrorMessage(message.message),
|
|
@@ -135,6 +3097,17 @@ var serverMessageToAction = (message) => {
|
|
|
135
3097
|
transcript: message.transcript,
|
|
136
3098
|
type: "partial"
|
|
137
3099
|
};
|
|
3100
|
+
case "replay":
|
|
3101
|
+
return {
|
|
3102
|
+
assistantTexts: message.assistantTexts,
|
|
3103
|
+
call: message.call,
|
|
3104
|
+
partial: message.partial,
|
|
3105
|
+
scenarioId: message.scenarioId,
|
|
3106
|
+
sessionId: message.sessionId,
|
|
3107
|
+
status: message.status,
|
|
3108
|
+
turns: message.turns,
|
|
3109
|
+
type: "replay"
|
|
3110
|
+
};
|
|
138
3111
|
case "session":
|
|
139
3112
|
return {
|
|
140
3113
|
sessionId: message.sessionId,
|
|
@@ -163,7 +3136,7 @@ var DEFAULT_SCENARIO_QUERY_PARAM = "scenarioId";
|
|
|
163
3136
|
var noop = () => {};
|
|
164
3137
|
var noopUnsubscribe = () => noop;
|
|
165
3138
|
var NOOP_CONNECTION = {
|
|
166
|
-
|
|
3139
|
+
callControl: noop,
|
|
167
3140
|
close: noop,
|
|
168
3141
|
endTurn: noop,
|
|
169
3142
|
getReadyState: () => WS_CLOSED,
|
|
@@ -171,6 +3144,7 @@ var NOOP_CONNECTION = {
|
|
|
171
3144
|
getSessionId: () => "",
|
|
172
3145
|
send: noop,
|
|
173
3146
|
sendAudio: noop,
|
|
3147
|
+
start: () => {},
|
|
174
3148
|
subscribe: noopUnsubscribe
|
|
175
3149
|
};
|
|
176
3150
|
var createSessionId = () => crypto.randomUUID();
|
|
@@ -192,11 +3166,14 @@ var isVoiceServerMessage = (value) => {
|
|
|
192
3166
|
switch (value.type) {
|
|
193
3167
|
case "audio":
|
|
194
3168
|
case "assistant":
|
|
3169
|
+
case "call_lifecycle":
|
|
195
3170
|
case "complete":
|
|
3171
|
+
case "connection":
|
|
196
3172
|
case "error":
|
|
197
3173
|
case "final":
|
|
198
3174
|
case "partial":
|
|
199
3175
|
case "pong":
|
|
3176
|
+
case "replay":
|
|
200
3177
|
case "session":
|
|
201
3178
|
case "turn":
|
|
202
3179
|
return true;
|
|
@@ -233,6 +3210,9 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
233
3210
|
sessionId: options.sessionId ?? createSessionId(),
|
|
234
3211
|
ws: null
|
|
235
3212
|
};
|
|
3213
|
+
const emitConnection = (reconnect) => {
|
|
3214
|
+
listeners.forEach((listener) => listener(reconnect));
|
|
3215
|
+
};
|
|
236
3216
|
const clearTimers = () => {
|
|
237
3217
|
if (state.pingInterval) {
|
|
238
3218
|
clearInterval(state.pingInterval);
|
|
@@ -255,9 +3235,28 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
255
3235
|
}
|
|
256
3236
|
};
|
|
257
3237
|
const scheduleReconnect = () => {
|
|
3238
|
+
const nextAttemptAt = Date.now() + RECONNECT_DELAY_MS;
|
|
258
3239
|
state.reconnectAttempts += 1;
|
|
3240
|
+
emitConnection({
|
|
3241
|
+
reconnect: {
|
|
3242
|
+
attempts: state.reconnectAttempts,
|
|
3243
|
+
lastDisconnectAt: Date.now(),
|
|
3244
|
+
maxAttempts: maxReconnectAttempts,
|
|
3245
|
+
nextAttemptAt,
|
|
3246
|
+
status: "reconnecting"
|
|
3247
|
+
},
|
|
3248
|
+
type: "connection"
|
|
3249
|
+
});
|
|
259
3250
|
state.reconnectTimeout = setTimeout(() => {
|
|
260
3251
|
if (state.reconnectAttempts > maxReconnectAttempts) {
|
|
3252
|
+
emitConnection({
|
|
3253
|
+
reconnect: {
|
|
3254
|
+
attempts: state.reconnectAttempts,
|
|
3255
|
+
maxAttempts: maxReconnectAttempts,
|
|
3256
|
+
status: "exhausted"
|
|
3257
|
+
},
|
|
3258
|
+
type: "connection"
|
|
3259
|
+
});
|
|
261
3260
|
return;
|
|
262
3261
|
}
|
|
263
3262
|
connect();
|
|
@@ -267,9 +3266,21 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
267
3266
|
const ws = new WebSocket(buildWsUrl(path, state.sessionId, state.scenarioId));
|
|
268
3267
|
ws.binaryType = "arraybuffer";
|
|
269
3268
|
ws.onopen = () => {
|
|
3269
|
+
const wasReconnecting = state.reconnectAttempts > 0;
|
|
270
3270
|
state.isConnected = true;
|
|
271
|
-
state.reconnectAttempts = 0;
|
|
272
3271
|
flushPendingMessages();
|
|
3272
|
+
if (wasReconnecting) {
|
|
3273
|
+
emitConnection({
|
|
3274
|
+
reconnect: {
|
|
3275
|
+
attempts: state.reconnectAttempts,
|
|
3276
|
+
lastResumedAt: Date.now(),
|
|
3277
|
+
maxAttempts: maxReconnectAttempts,
|
|
3278
|
+
status: "resumed"
|
|
3279
|
+
},
|
|
3280
|
+
type: "connection"
|
|
3281
|
+
});
|
|
3282
|
+
state.reconnectAttempts = 0;
|
|
3283
|
+
}
|
|
273
3284
|
listeners.forEach((listener) => listener({
|
|
274
3285
|
scenarioId: state.scenarioId ?? undefined,
|
|
275
3286
|
sessionId: state.sessionId,
|
|
@@ -299,6 +3310,16 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
299
3310
|
const reconnectable = shouldReconnect && event.code !== WS_NORMAL_CLOSURE && state.reconnectAttempts < maxReconnectAttempts;
|
|
300
3311
|
if (reconnectable) {
|
|
301
3312
|
scheduleReconnect();
|
|
3313
|
+
} else if (shouldReconnect && event.code !== WS_NORMAL_CLOSURE) {
|
|
3314
|
+
emitConnection({
|
|
3315
|
+
reconnect: {
|
|
3316
|
+
attempts: state.reconnectAttempts,
|
|
3317
|
+
lastDisconnectAt: Date.now(),
|
|
3318
|
+
maxAttempts: maxReconnectAttempts,
|
|
3319
|
+
status: "exhausted"
|
|
3320
|
+
},
|
|
3321
|
+
type: "connection"
|
|
3322
|
+
});
|
|
302
3323
|
}
|
|
303
3324
|
};
|
|
304
3325
|
state.ws = ws;
|
|
@@ -332,6 +3353,12 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
332
3353
|
const endTurn = () => {
|
|
333
3354
|
send({ type: "end_turn" });
|
|
334
3355
|
};
|
|
3356
|
+
const callControl = (message) => {
|
|
3357
|
+
send({
|
|
3358
|
+
...message,
|
|
3359
|
+
type: "call_control"
|
|
3360
|
+
});
|
|
3361
|
+
};
|
|
335
3362
|
const close = () => {
|
|
336
3363
|
clearTimers();
|
|
337
3364
|
if (state.ws) {
|
|
@@ -349,7 +3376,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
349
3376
|
};
|
|
350
3377
|
connect();
|
|
351
3378
|
return {
|
|
352
|
-
|
|
3379
|
+
callControl,
|
|
353
3380
|
close,
|
|
354
3381
|
endTurn,
|
|
355
3382
|
getReadyState: () => state.ws?.readyState ?? WS_CLOSED,
|
|
@@ -357,18 +3384,26 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
357
3384
|
getSessionId: () => state.sessionId,
|
|
358
3385
|
send,
|
|
359
3386
|
sendAudio,
|
|
3387
|
+
start,
|
|
360
3388
|
subscribe
|
|
361
3389
|
};
|
|
362
3390
|
};
|
|
363
3391
|
|
|
364
3392
|
// src/client/store.ts
|
|
3393
|
+
var createInitialReconnectState = () => ({
|
|
3394
|
+
attempts: 0,
|
|
3395
|
+
maxAttempts: 0,
|
|
3396
|
+
status: "idle"
|
|
3397
|
+
});
|
|
365
3398
|
var createInitialState = () => ({
|
|
366
3399
|
assistantAudio: [],
|
|
367
3400
|
assistantTexts: [],
|
|
3401
|
+
call: null,
|
|
368
3402
|
error: null,
|
|
369
3403
|
isConnected: false,
|
|
370
3404
|
scenarioId: null,
|
|
371
3405
|
partial: "",
|
|
3406
|
+
reconnect: createInitialReconnectState(),
|
|
372
3407
|
sessionId: null,
|
|
373
3408
|
status: "idle",
|
|
374
3409
|
turns: []
|
|
@@ -408,10 +3443,36 @@ var createVoiceStreamStore = () => {
|
|
|
408
3443
|
status: "completed"
|
|
409
3444
|
};
|
|
410
3445
|
break;
|
|
3446
|
+
case "call_lifecycle":
|
|
3447
|
+
state = {
|
|
3448
|
+
...state,
|
|
3449
|
+
call: {
|
|
3450
|
+
...state.call,
|
|
3451
|
+
disposition: action.event.type === "end" ? action.event.disposition : state.call?.disposition,
|
|
3452
|
+
endedAt: action.event.type === "end" ? action.event.at : state.call?.endedAt,
|
|
3453
|
+
events: [...state.call?.events ?? [], action.event],
|
|
3454
|
+
lastEventAt: action.event.at,
|
|
3455
|
+
startedAt: state.call?.startedAt ?? action.event.at
|
|
3456
|
+
},
|
|
3457
|
+
sessionId: action.sessionId
|
|
3458
|
+
};
|
|
3459
|
+
break;
|
|
411
3460
|
case "connected":
|
|
412
3461
|
state = {
|
|
413
3462
|
...state,
|
|
414
|
-
isConnected: true
|
|
3463
|
+
isConnected: true,
|
|
3464
|
+
reconnect: state.reconnect.status === "reconnecting" ? {
|
|
3465
|
+
...state.reconnect,
|
|
3466
|
+
lastResumedAt: Date.now(),
|
|
3467
|
+
nextAttemptAt: undefined,
|
|
3468
|
+
status: "resumed"
|
|
3469
|
+
} : state.reconnect
|
|
3470
|
+
};
|
|
3471
|
+
break;
|
|
3472
|
+
case "connection":
|
|
3473
|
+
state = {
|
|
3474
|
+
...state,
|
|
3475
|
+
reconnect: action.reconnect
|
|
415
3476
|
};
|
|
416
3477
|
break;
|
|
417
3478
|
case "disconnected":
|
|
@@ -439,6 +3500,26 @@ var createVoiceStreamStore = () => {
|
|
|
439
3500
|
partial: action.transcript.text
|
|
440
3501
|
};
|
|
441
3502
|
break;
|
|
3503
|
+
case "replay":
|
|
3504
|
+
state = {
|
|
3505
|
+
...state,
|
|
3506
|
+
assistantTexts: [...action.assistantTexts],
|
|
3507
|
+
call: action.call ?? null,
|
|
3508
|
+
error: null,
|
|
3509
|
+
isConnected: action.status === "active",
|
|
3510
|
+
partial: action.partial,
|
|
3511
|
+
reconnect: state.reconnect.status === "reconnecting" ? {
|
|
3512
|
+
...state.reconnect,
|
|
3513
|
+
lastResumedAt: Date.now(),
|
|
3514
|
+
nextAttemptAt: undefined,
|
|
3515
|
+
status: "resumed"
|
|
3516
|
+
} : state.reconnect,
|
|
3517
|
+
scenarioId: action.scenarioId ?? state.scenarioId,
|
|
3518
|
+
sessionId: action.sessionId,
|
|
3519
|
+
status: action.status,
|
|
3520
|
+
turns: [...action.turns]
|
|
3521
|
+
};
|
|
3522
|
+
break;
|
|
442
3523
|
case "session":
|
|
443
3524
|
state = {
|
|
444
3525
|
...state,
|
|
@@ -486,14 +3567,41 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
486
3567
|
const notify = () => {
|
|
487
3568
|
subscribers.forEach((subscriber) => subscriber());
|
|
488
3569
|
};
|
|
3570
|
+
const reportReconnect = () => {
|
|
3571
|
+
if (!options.reconnectReportPath || typeof fetch === "undefined") {
|
|
3572
|
+
return;
|
|
3573
|
+
}
|
|
3574
|
+
const snapshot = store.getSnapshot();
|
|
3575
|
+
const body = JSON.stringify({
|
|
3576
|
+
at: Date.now(),
|
|
3577
|
+
reconnect: snapshot.reconnect,
|
|
3578
|
+
scenarioId: snapshot.scenarioId,
|
|
3579
|
+
sessionId: connection.getSessionId(),
|
|
3580
|
+
turnIds: snapshot.turns.map((turn) => turn.id)
|
|
3581
|
+
});
|
|
3582
|
+
fetch(options.reconnectReportPath, {
|
|
3583
|
+
body,
|
|
3584
|
+
headers: {
|
|
3585
|
+
"Content-Type": "application/json"
|
|
3586
|
+
},
|
|
3587
|
+
keepalive: true,
|
|
3588
|
+
method: "POST"
|
|
3589
|
+
}).catch(() => {});
|
|
3590
|
+
};
|
|
489
3591
|
const unsubscribeConnection = connection.subscribe((message) => {
|
|
490
3592
|
const action = serverMessageToAction(message);
|
|
491
3593
|
if (action) {
|
|
492
3594
|
store.dispatch(action);
|
|
3595
|
+
if (message.type === "connection") {
|
|
3596
|
+
reportReconnect();
|
|
3597
|
+
}
|
|
493
3598
|
notify();
|
|
494
3599
|
}
|
|
495
3600
|
});
|
|
496
3601
|
return {
|
|
3602
|
+
callControl(message) {
|
|
3603
|
+
connection.callControl(message);
|
|
3604
|
+
},
|
|
497
3605
|
close() {
|
|
498
3606
|
unsubscribeConnection();
|
|
499
3607
|
connection.close();
|
|
@@ -522,6 +3630,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
522
3630
|
get partial() {
|
|
523
3631
|
return store.getSnapshot().partial;
|
|
524
3632
|
},
|
|
3633
|
+
get reconnect() {
|
|
3634
|
+
return store.getSnapshot().reconnect;
|
|
3635
|
+
},
|
|
525
3636
|
get sessionId() {
|
|
526
3637
|
return connection.getSessionId();
|
|
527
3638
|
},
|
|
@@ -537,6 +3648,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
537
3648
|
get assistantAudio() {
|
|
538
3649
|
return store.getSnapshot().assistantAudio;
|
|
539
3650
|
},
|
|
3651
|
+
get call() {
|
|
3652
|
+
return store.getSnapshot().call;
|
|
3653
|
+
},
|
|
540
3654
|
sendAudio(audio) {
|
|
541
3655
|
connection.sendAudio(audio);
|
|
542
3656
|
},
|
|
@@ -550,22 +3664,26 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
550
3664
|
};
|
|
551
3665
|
|
|
552
3666
|
// src/vue/useVoiceStream.ts
|
|
553
|
-
|
|
3667
|
+
function useVoiceStream(path, options = {}) {
|
|
554
3668
|
const stream = createVoiceStream(path, options);
|
|
555
|
-
const assistantAudio =
|
|
556
|
-
const assistantTexts =
|
|
557
|
-
const
|
|
558
|
-
const
|
|
559
|
-
const
|
|
560
|
-
const
|
|
561
|
-
const
|
|
562
|
-
const
|
|
3669
|
+
const assistantAudio = shallowRef10([]);
|
|
3670
|
+
const assistantTexts = shallowRef10([]);
|
|
3671
|
+
const call = shallowRef10(null);
|
|
3672
|
+
const error = ref7(null);
|
|
3673
|
+
const isConnected = ref7(false);
|
|
3674
|
+
const partial = ref7("");
|
|
3675
|
+
const reconnect = shallowRef10(stream.reconnect);
|
|
3676
|
+
const sessionId = ref7(stream.sessionId);
|
|
3677
|
+
const status = ref7(stream.status);
|
|
3678
|
+
const turns = shallowRef10([]);
|
|
563
3679
|
const sync = () => {
|
|
564
3680
|
assistantAudio.value = [...stream.assistantAudio];
|
|
565
3681
|
assistantTexts.value = [...stream.assistantTexts];
|
|
3682
|
+
call.value = stream.call;
|
|
566
3683
|
error.value = stream.error;
|
|
567
3684
|
isConnected.value = stream.isConnected;
|
|
568
3685
|
partial.value = stream.partial;
|
|
3686
|
+
reconnect.value = stream.reconnect;
|
|
569
3687
|
sessionId.value = stream.sessionId;
|
|
570
3688
|
status.value = stream.status;
|
|
571
3689
|
turns.value = [...stream.turns];
|
|
@@ -576,23 +3694,26 @@ var useVoiceStream = (path, options = {}) => {
|
|
|
576
3694
|
unsubscribe();
|
|
577
3695
|
stream.close();
|
|
578
3696
|
};
|
|
579
|
-
|
|
3697
|
+
onUnmounted11(destroy);
|
|
580
3698
|
return {
|
|
581
3699
|
assistantAudio,
|
|
582
3700
|
assistantTexts,
|
|
3701
|
+
call,
|
|
3702
|
+
callControl: (message) => stream.callControl(message),
|
|
583
3703
|
close: () => destroy(),
|
|
584
3704
|
endTurn: () => stream.endTurn(),
|
|
585
3705
|
error,
|
|
586
3706
|
isConnected,
|
|
587
3707
|
partial,
|
|
3708
|
+
reconnect,
|
|
588
3709
|
sendAudio: (audio) => stream.sendAudio(audio),
|
|
589
3710
|
sessionId,
|
|
590
3711
|
status,
|
|
591
3712
|
turns
|
|
592
3713
|
};
|
|
593
|
-
}
|
|
3714
|
+
}
|
|
594
3715
|
// src/vue/useVoiceController.ts
|
|
595
|
-
import { onUnmounted as
|
|
3716
|
+
import { onUnmounted as onUnmounted12, ref as ref8, shallowRef as shallowRef11 } from "vue";
|
|
596
3717
|
|
|
597
3718
|
// src/client/htmx.ts
|
|
598
3719
|
var DEFAULT_EVENT_NAME = "voice-refresh";
|
|
@@ -1056,10 +4177,12 @@ var resolveVoiceRuntimePreset = (name = "default") => {
|
|
|
1056
4177
|
var createInitialState2 = (stream) => ({
|
|
1057
4178
|
assistantAudio: [...stream.assistantAudio],
|
|
1058
4179
|
assistantTexts: [...stream.assistantTexts],
|
|
4180
|
+
call: stream.call,
|
|
1059
4181
|
error: stream.error,
|
|
1060
4182
|
isConnected: stream.isConnected,
|
|
1061
4183
|
isRecording: false,
|
|
1062
4184
|
partial: stream.partial,
|
|
4185
|
+
reconnect: stream.reconnect,
|
|
1063
4186
|
recordingError: null,
|
|
1064
4187
|
sessionId: stream.sessionId,
|
|
1065
4188
|
scenarioId: stream.scenarioId,
|
|
@@ -1085,9 +4208,11 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1085
4208
|
...state,
|
|
1086
4209
|
assistantAudio: [...stream.assistantAudio],
|
|
1087
4210
|
assistantTexts: [...stream.assistantTexts],
|
|
4211
|
+
call: stream.call,
|
|
1088
4212
|
error: stream.error,
|
|
1089
4213
|
isConnected: stream.isConnected,
|
|
1090
4214
|
partial: stream.partial,
|
|
4215
|
+
reconnect: stream.reconnect,
|
|
1091
4216
|
sessionId: stream.sessionId,
|
|
1092
4217
|
scenarioId: stream.scenarioId,
|
|
1093
4218
|
status: stream.status,
|
|
@@ -1112,7 +4237,13 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1112
4237
|
capture = createMicrophoneCapture({
|
|
1113
4238
|
channelCount: options.capture?.channelCount ?? preset.capture.channelCount,
|
|
1114
4239
|
onLevel: options.capture?.onLevel,
|
|
1115
|
-
onAudio: (audio) =>
|
|
4240
|
+
onAudio: (audio) => {
|
|
4241
|
+
if (options.capture?.onAudio) {
|
|
4242
|
+
options.capture.onAudio(audio, stream.sendAudio);
|
|
4243
|
+
return;
|
|
4244
|
+
}
|
|
4245
|
+
stream.sendAudio(audio);
|
|
4246
|
+
},
|
|
1116
4247
|
sampleRateHz: options.capture?.sampleRateHz ?? preset.capture.sampleRateHz
|
|
1117
4248
|
});
|
|
1118
4249
|
return capture;
|
|
@@ -1162,6 +4293,7 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1162
4293
|
bindHTMX(bindingOptions) {
|
|
1163
4294
|
return bindVoiceHTMX(stream, bindingOptions);
|
|
1164
4295
|
},
|
|
4296
|
+
callControl: (message) => stream.callControl(message),
|
|
1165
4297
|
close,
|
|
1166
4298
|
endTurn: () => stream.endTurn(),
|
|
1167
4299
|
get error() {
|
|
@@ -1181,6 +4313,9 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1181
4313
|
get recordingError() {
|
|
1182
4314
|
return state.recordingError;
|
|
1183
4315
|
},
|
|
4316
|
+
get reconnect() {
|
|
4317
|
+
return state.reconnect;
|
|
4318
|
+
},
|
|
1184
4319
|
sendAudio: (audio) => stream.sendAudio(audio),
|
|
1185
4320
|
get sessionId() {
|
|
1186
4321
|
return state.sessionId;
|
|
@@ -1214,23 +4349,27 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1214
4349
|
},
|
|
1215
4350
|
get assistantAudio() {
|
|
1216
4351
|
return state.assistantAudio;
|
|
4352
|
+
},
|
|
4353
|
+
get call() {
|
|
4354
|
+
return state.call;
|
|
1217
4355
|
}
|
|
1218
4356
|
};
|
|
1219
4357
|
};
|
|
1220
4358
|
|
|
1221
4359
|
// src/vue/useVoiceController.ts
|
|
1222
|
-
|
|
4360
|
+
function useVoiceController(path, options = {}) {
|
|
1223
4361
|
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
|
|
1231
|
-
const
|
|
1232
|
-
const
|
|
1233
|
-
const
|
|
4362
|
+
const assistantAudio = shallowRef11([]);
|
|
4363
|
+
const assistantTexts = shallowRef11([]);
|
|
4364
|
+
const error = ref8(null);
|
|
4365
|
+
const isConnected = ref8(false);
|
|
4366
|
+
const isRecording = ref8(false);
|
|
4367
|
+
const partial = ref8("");
|
|
4368
|
+
const reconnect = shallowRef11(controller.reconnect);
|
|
4369
|
+
const recordingError = ref8(null);
|
|
4370
|
+
const sessionId = ref8(controller.sessionId);
|
|
4371
|
+
const status = ref8(controller.status);
|
|
4372
|
+
const turns = shallowRef11([]);
|
|
1234
4373
|
const sync = () => {
|
|
1235
4374
|
assistantAudio.value = [...controller.assistantAudio];
|
|
1236
4375
|
assistantTexts.value = [...controller.assistantTexts];
|
|
@@ -1238,6 +4377,7 @@ var useVoiceController = (path, options = {}) => {
|
|
|
1238
4377
|
isConnected.value = controller.isConnected;
|
|
1239
4378
|
isRecording.value = controller.isRecording;
|
|
1240
4379
|
partial.value = controller.partial;
|
|
4380
|
+
reconnect.value = controller.reconnect;
|
|
1241
4381
|
recordingError.value = controller.recordingError;
|
|
1242
4382
|
sessionId.value = controller.sessionId;
|
|
1243
4383
|
status.value = controller.status;
|
|
@@ -1249,7 +4389,7 @@ var useVoiceController = (path, options = {}) => {
|
|
|
1249
4389
|
unsubscribe();
|
|
1250
4390
|
controller.close();
|
|
1251
4391
|
};
|
|
1252
|
-
|
|
4392
|
+
onUnmounted12(destroy);
|
|
1253
4393
|
return {
|
|
1254
4394
|
assistantAudio,
|
|
1255
4395
|
assistantTexts,
|
|
@@ -1260,6 +4400,7 @@ var useVoiceController = (path, options = {}) => {
|
|
|
1260
4400
|
isConnected,
|
|
1261
4401
|
isRecording,
|
|
1262
4402
|
partial,
|
|
4403
|
+
reconnect,
|
|
1263
4404
|
recordingError,
|
|
1264
4405
|
sendAudio: (audio) => controller.sendAudio(audio),
|
|
1265
4406
|
sessionId,
|
|
@@ -1269,27 +4410,27 @@ var useVoiceController = (path, options = {}) => {
|
|
|
1269
4410
|
toggleRecording: () => controller.toggleRecording(),
|
|
1270
4411
|
turns
|
|
1271
4412
|
};
|
|
1272
|
-
}
|
|
1273
|
-
// src/vue/
|
|
1274
|
-
import { onUnmounted as
|
|
4413
|
+
}
|
|
4414
|
+
// src/vue/useVoiceTraceTimeline.ts
|
|
4415
|
+
import { onUnmounted as onUnmounted13, ref as ref9, shallowRef as shallowRef12 } from "vue";
|
|
1275
4416
|
|
|
1276
|
-
// src/client/
|
|
1277
|
-
var
|
|
4417
|
+
// src/client/traceTimeline.ts
|
|
4418
|
+
var fetchVoiceTraceTimeline = async (path = "/api/voice-traces", options = {}) => {
|
|
1278
4419
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1279
4420
|
const response = await fetchImpl(path);
|
|
1280
4421
|
if (!response.ok) {
|
|
1281
|
-
throw new Error(`Voice
|
|
4422
|
+
throw new Error(`Voice trace timeline failed: HTTP ${response.status}`);
|
|
1282
4423
|
}
|
|
1283
4424
|
return await response.json();
|
|
1284
4425
|
};
|
|
1285
|
-
var
|
|
4426
|
+
var createVoiceTraceTimelineStore = (path = "/api/voice-traces", options = {}) => {
|
|
1286
4427
|
const listeners = new Set;
|
|
1287
4428
|
let closed = false;
|
|
1288
4429
|
let timer;
|
|
1289
4430
|
let snapshot = {
|
|
1290
4431
|
error: null,
|
|
1291
4432
|
isLoading: false,
|
|
1292
|
-
|
|
4433
|
+
report: null
|
|
1293
4434
|
};
|
|
1294
4435
|
const emit = () => {
|
|
1295
4436
|
for (const listener of listeners) {
|
|
@@ -1298,7 +4439,7 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
|
|
|
1298
4439
|
};
|
|
1299
4440
|
const refresh = async () => {
|
|
1300
4441
|
if (closed) {
|
|
1301
|
-
return snapshot.
|
|
4442
|
+
return snapshot.report;
|
|
1302
4443
|
}
|
|
1303
4444
|
snapshot = {
|
|
1304
4445
|
...snapshot,
|
|
@@ -1307,15 +4448,15 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
|
|
|
1307
4448
|
};
|
|
1308
4449
|
emit();
|
|
1309
4450
|
try {
|
|
1310
|
-
const
|
|
4451
|
+
const report = await fetchVoiceTraceTimeline(path, options);
|
|
1311
4452
|
snapshot = {
|
|
1312
4453
|
error: null,
|
|
1313
4454
|
isLoading: false,
|
|
1314
|
-
|
|
4455
|
+
report,
|
|
1315
4456
|
updatedAt: Date.now()
|
|
1316
4457
|
};
|
|
1317
4458
|
emit();
|
|
1318
|
-
return
|
|
4459
|
+
return report;
|
|
1319
4460
|
} catch (error) {
|
|
1320
4461
|
snapshot = {
|
|
1321
4462
|
...snapshot,
|
|
@@ -1353,37 +4494,170 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
|
|
|
1353
4494
|
};
|
|
1354
4495
|
};
|
|
1355
4496
|
|
|
1356
|
-
// src/vue/
|
|
1357
|
-
|
|
1358
|
-
const store =
|
|
1359
|
-
const error =
|
|
1360
|
-
const isLoading =
|
|
1361
|
-
const
|
|
1362
|
-
const updatedAt =
|
|
4497
|
+
// src/vue/useVoiceTraceTimeline.ts
|
|
4498
|
+
function useVoiceTraceTimeline(path = "/api/voice-traces", options = {}) {
|
|
4499
|
+
const store = createVoiceTraceTimelineStore(path, options);
|
|
4500
|
+
const error = ref9(null);
|
|
4501
|
+
const isLoading = ref9(false);
|
|
4502
|
+
const report = shallowRef12(null);
|
|
4503
|
+
const updatedAt = ref9(undefined);
|
|
1363
4504
|
const sync = () => {
|
|
1364
4505
|
const snapshot = store.getSnapshot();
|
|
1365
4506
|
error.value = snapshot.error;
|
|
1366
4507
|
isLoading.value = snapshot.isLoading;
|
|
1367
|
-
|
|
4508
|
+
report.value = snapshot.report;
|
|
1368
4509
|
updatedAt.value = snapshot.updatedAt;
|
|
1369
4510
|
};
|
|
1370
4511
|
const unsubscribe = store.subscribe(sync);
|
|
1371
4512
|
sync();
|
|
1372
4513
|
store.refresh().catch(() => {});
|
|
1373
|
-
|
|
4514
|
+
onUnmounted13(() => {
|
|
1374
4515
|
unsubscribe();
|
|
1375
4516
|
store.close();
|
|
1376
4517
|
});
|
|
1377
4518
|
return {
|
|
1378
4519
|
error,
|
|
1379
4520
|
isLoading,
|
|
1380
|
-
providers,
|
|
1381
4521
|
refresh: store.refresh,
|
|
4522
|
+
report,
|
|
1382
4523
|
updatedAt
|
|
1383
4524
|
};
|
|
4525
|
+
}
|
|
4526
|
+
// src/vue/useVoiceWorkflowStatus.ts
|
|
4527
|
+
import { onUnmounted as onUnmounted14, ref as ref10, shallowRef as shallowRef13 } from "vue";
|
|
4528
|
+
|
|
4529
|
+
// src/client/workflowStatus.ts
|
|
4530
|
+
var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
|
|
4531
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
4532
|
+
const response = await fetchImpl(path);
|
|
4533
|
+
if (!response.ok) {
|
|
4534
|
+
throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
|
|
4535
|
+
}
|
|
4536
|
+
return await response.json();
|
|
4537
|
+
};
|
|
4538
|
+
var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
|
|
4539
|
+
const listeners = new Set;
|
|
4540
|
+
let closed = false;
|
|
4541
|
+
let timer;
|
|
4542
|
+
let snapshot = {
|
|
4543
|
+
error: null,
|
|
4544
|
+
isLoading: false
|
|
4545
|
+
};
|
|
4546
|
+
const emit = () => {
|
|
4547
|
+
for (const listener of listeners) {
|
|
4548
|
+
listener();
|
|
4549
|
+
}
|
|
4550
|
+
};
|
|
4551
|
+
const refresh = async () => {
|
|
4552
|
+
if (closed) {
|
|
4553
|
+
return snapshot.report;
|
|
4554
|
+
}
|
|
4555
|
+
snapshot = {
|
|
4556
|
+
...snapshot,
|
|
4557
|
+
error: null,
|
|
4558
|
+
isLoading: true
|
|
4559
|
+
};
|
|
4560
|
+
emit();
|
|
4561
|
+
try {
|
|
4562
|
+
const report = await fetchVoiceWorkflowStatus(path, options);
|
|
4563
|
+
snapshot = {
|
|
4564
|
+
error: null,
|
|
4565
|
+
isLoading: false,
|
|
4566
|
+
report,
|
|
4567
|
+
updatedAt: Date.now()
|
|
4568
|
+
};
|
|
4569
|
+
emit();
|
|
4570
|
+
return report;
|
|
4571
|
+
} catch (error) {
|
|
4572
|
+
snapshot = {
|
|
4573
|
+
...snapshot,
|
|
4574
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4575
|
+
isLoading: false
|
|
4576
|
+
};
|
|
4577
|
+
emit();
|
|
4578
|
+
throw error;
|
|
4579
|
+
}
|
|
4580
|
+
};
|
|
4581
|
+
const close = () => {
|
|
4582
|
+
closed = true;
|
|
4583
|
+
if (timer) {
|
|
4584
|
+
clearInterval(timer);
|
|
4585
|
+
timer = undefined;
|
|
4586
|
+
}
|
|
4587
|
+
listeners.clear();
|
|
4588
|
+
};
|
|
4589
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
4590
|
+
timer = setInterval(() => {
|
|
4591
|
+
refresh().catch(() => {});
|
|
4592
|
+
}, options.intervalMs);
|
|
4593
|
+
}
|
|
4594
|
+
return {
|
|
4595
|
+
close,
|
|
4596
|
+
getServerSnapshot: () => snapshot,
|
|
4597
|
+
getSnapshot: () => snapshot,
|
|
4598
|
+
refresh,
|
|
4599
|
+
subscribe: (listener) => {
|
|
4600
|
+
listeners.add(listener);
|
|
4601
|
+
return () => {
|
|
4602
|
+
listeners.delete(listener);
|
|
4603
|
+
};
|
|
4604
|
+
}
|
|
4605
|
+
};
|
|
1384
4606
|
};
|
|
4607
|
+
|
|
4608
|
+
// src/vue/useVoiceWorkflowStatus.ts
|
|
4609
|
+
function useVoiceWorkflowStatus(path = "/evals/scenarios/json", options = {}) {
|
|
4610
|
+
const store = createVoiceWorkflowStatusStore(path, options);
|
|
4611
|
+
const error = ref10(null);
|
|
4612
|
+
const isLoading = ref10(false);
|
|
4613
|
+
const report = shallowRef13(undefined);
|
|
4614
|
+
const updatedAt = ref10(undefined);
|
|
4615
|
+
const sync = () => {
|
|
4616
|
+
const snapshot = store.getSnapshot();
|
|
4617
|
+
error.value = snapshot.error;
|
|
4618
|
+
isLoading.value = snapshot.isLoading;
|
|
4619
|
+
report.value = snapshot.report;
|
|
4620
|
+
updatedAt.value = snapshot.updatedAt;
|
|
4621
|
+
};
|
|
4622
|
+
const unsubscribe = store.subscribe(sync);
|
|
4623
|
+
sync();
|
|
4624
|
+
if (typeof window !== "undefined") {
|
|
4625
|
+
store.refresh().catch(() => {});
|
|
4626
|
+
}
|
|
4627
|
+
onUnmounted14(() => {
|
|
4628
|
+
unsubscribe();
|
|
4629
|
+
store.close();
|
|
4630
|
+
});
|
|
4631
|
+
return {
|
|
4632
|
+
error,
|
|
4633
|
+
isLoading,
|
|
4634
|
+
refresh: store.refresh,
|
|
4635
|
+
report,
|
|
4636
|
+
updatedAt
|
|
4637
|
+
};
|
|
4638
|
+
}
|
|
1385
4639
|
export {
|
|
4640
|
+
useVoiceWorkflowStatus,
|
|
4641
|
+
useVoiceTurnQuality,
|
|
4642
|
+
useVoiceTurnLatency,
|
|
4643
|
+
useVoiceTraceTimeline,
|
|
1386
4644
|
useVoiceStream,
|
|
4645
|
+
useVoiceRoutingStatus,
|
|
1387
4646
|
useVoiceProviderStatus,
|
|
1388
|
-
|
|
4647
|
+
useVoiceProviderSimulationControls,
|
|
4648
|
+
useVoiceProviderCapabilities,
|
|
4649
|
+
useVoiceOpsStatus,
|
|
4650
|
+
useVoiceOpsActionCenter,
|
|
4651
|
+
useVoiceDeliveryRuntime,
|
|
4652
|
+
useVoiceController,
|
|
4653
|
+
useVoiceCampaignDialerProof,
|
|
4654
|
+
VoiceTurnQuality,
|
|
4655
|
+
VoiceTurnLatency,
|
|
4656
|
+
VoiceRoutingStatus,
|
|
4657
|
+
VoiceProviderStatus,
|
|
4658
|
+
VoiceProviderSimulationControls,
|
|
4659
|
+
VoiceProviderCapabilities,
|
|
4660
|
+
VoiceOpsStatus,
|
|
4661
|
+
VoiceOpsActionCenter,
|
|
4662
|
+
VoiceDeliveryRuntime
|
|
1389
4663
|
};
|