@absolutejs/voice 0.0.22-beta.24 → 0.0.22-beta.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3112 -236
- package/dist/agent.d.ts +62 -0
- package/dist/agentSquadContract.d.ts +69 -0
- package/dist/angular/index.d.ts +14 -0
- package/dist/angular/index.js +3266 -1097
- package/dist/angular/voice-agent-squad-status.service.d.ts +12 -0
- 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-live-ops.service.d.ts +11 -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-platform-coverage.service.d.ts +12 -0
- package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
- package/dist/angular/voice-provider-contracts.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/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 +746 -0
- package/dist/campaignDialers.d.ts +90 -0
- package/dist/client/actions.d.ts +105 -0
- package/dist/client/agentSquadStatus.d.ts +37 -0
- package/dist/client/agentSquadStatusWidget.d.ts +24 -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 +64 -0
- package/dist/client/index.js +4594 -21
- package/dist/client/liveOps.d.ts +22 -0
- package/dist/client/liveOpsWidget.d.ts +23 -0
- 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/platformCoverage.d.ts +19 -0
- package/dist/client/platformCoverageWidget.d.ts +37 -0
- package/dist/client/providerCapabilities.d.ts +19 -0
- package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
- package/dist/client/providerContracts.d.ts +19 -0
- package/dist/client/providerContractsWidget.d.ts +37 -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 +36 -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 +140 -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 +219 -0
- package/dist/fileStore.d.ts +14 -2
- package/dist/handoff.d.ts +54 -0
- package/dist/handoffHealth.d.ts +94 -0
- package/dist/incidentBundle.d.ts +116 -0
- package/dist/index.d.ts +128 -13
- package/dist/index.js +23685 -5200
- package/dist/latencySlo.d.ts +56 -0
- package/dist/liveLatency.d.ts +78 -0
- package/dist/liveOps.d.ts +122 -0
- package/dist/modelAdapters.d.ts +23 -2
- package/dist/observabilityExport.d.ts +428 -0
- package/dist/openaiRealtime.d.ts +27 -0
- package/dist/openaiTTS.d.ts +18 -0
- package/dist/operationsRecord.d.ts +158 -0
- package/dist/opsActionAuditRoutes.d.ts +99 -0
- package/dist/opsConsoleRoutes.d.ts +80 -0
- package/dist/opsRecovery.d.ts +137 -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 +115 -0
- package/dist/phoneAgent.d.ts +76 -0
- package/dist/phoneAgentProductionSmoke.d.ts +115 -0
- package/dist/platformCoverage.d.ts +73 -0
- package/dist/postgresStore.d.ts +13 -2
- package/dist/productionReadiness.d.ts +466 -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/providerSlo.d.ts +114 -0
- package/dist/providerStackRecommendations.d.ts +145 -0
- package/dist/qualityRoutes.d.ts +76 -0
- package/dist/queue.d.ts +61 -0
- package/dist/react/VoiceAgentSquadStatus.d.ts +5 -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/VoicePlatformCoverage.d.ts +6 -0
- package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
- package/dist/react/VoiceProviderContracts.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 +28 -0
- package/dist/react/index.js +4359 -33
- package/dist/react/useVoiceAgentSquadStatus.d.ts +8 -0
- 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/useVoiceLiveOps.d.ts +9 -0
- package/dist/react/useVoiceOpsActionCenter.d.ts +11 -0
- package/dist/react/useVoiceOpsStatus.d.ts +8 -0
- package/dist/react/useVoicePlatformCoverage.d.ts +8 -0
- package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
- package/dist/react/useVoiceProviderContracts.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 +37 -0
- package/dist/reconnectContract.d.ts +87 -0
- package/dist/resilienceRoutes.d.ts +143 -0
- package/dist/sessionReplay.d.ts +12 -0
- package/dist/simulationSuite.d.ts +121 -0
- package/dist/sqliteStore.d.ts +13 -2
- package/dist/svelte/createVoiceAgentSquadStatus.d.ts +9 -0
- package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
- package/dist/svelte/createVoiceDeliveryRuntime.d.ts +11 -0
- package/dist/svelte/createVoiceLiveOps.d.ts +13 -0
- package/dist/svelte/createVoiceOpsActionCenter.d.ts +10 -0
- package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
- package/dist/svelte/createVoicePlatformCoverage.d.ts +7 -0
- package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
- package/dist/svelte/createVoiceProviderContracts.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 +15 -0
- package/dist/svelte/index.js +4664 -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 +1 -0
- package/dist/testing/index.js +2024 -69
- package/dist/testing/ioProviderSimulator.d.ts +41 -0
- package/dist/toolContract.d.ts +133 -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 +97 -0
- package/dist/turnLatency.d.ts +95 -0
- package/dist/turnQuality.d.ts +94 -0
- package/dist/types.d.ts +180 -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/VoicePlatformCoverage.d.ts +23 -0
- package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
- package/dist/vue/VoiceProviderContracts.d.ts +21 -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 +26 -0
- package/dist/vue/index.js +4136 -57
- package/dist/vue/useVoiceAgentSquadStatus.d.ts +9 -0
- 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/useVoiceLiveOps.d.ts +9 -0
- package/dist/vue/useVoiceOpsActionCenter.d.ts +11 -0
- package/dist/vue/useVoiceOpsStatus.d.ts +9 -0
- package/dist/vue/useVoicePlatformCoverage.d.ts +9 -0
- package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
- package/dist/vue/useVoiceProviderContracts.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/react/index.js
CHANGED
|
@@ -69,8 +69,4113 @@ 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/react/useVoiceOpsStatus.tsx
|
|
73
|
+
import { useEffect, useRef, useSyncExternalStore } from "react";
|
|
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/react/useVoiceOpsStatus.tsx
|
|
155
|
+
var useVoiceOpsStatus = (path = "/api/voice/ops-status", options = {}) => {
|
|
156
|
+
const storeRef = useRef(null);
|
|
157
|
+
if (!storeRef.current) {
|
|
158
|
+
storeRef.current = createVoiceOpsStatusStore(path, options);
|
|
159
|
+
}
|
|
160
|
+
const store = storeRef.current;
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
store.refresh().catch(() => {});
|
|
163
|
+
return () => store.close();
|
|
164
|
+
}, [store]);
|
|
165
|
+
return {
|
|
166
|
+
...useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
167
|
+
refresh: store.refresh
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// src/client/opsStatusWidget.ts
|
|
172
|
+
var DEFAULT_TITLE = "Voice Ops Status";
|
|
173
|
+
var DEFAULT_DESCRIPTION = "Certified workflow, provider, and handoff readiness from your AbsoluteJS voice app.";
|
|
174
|
+
var SURFACE_LABELS = {
|
|
175
|
+
handoffs: "Handoffs",
|
|
176
|
+
providers: "Providers",
|
|
177
|
+
quality: "Quality",
|
|
178
|
+
sessions: "Sessions",
|
|
179
|
+
workflows: "Workflows"
|
|
180
|
+
};
|
|
181
|
+
var escapeHtml = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
182
|
+
var readNumber = (value, key) => value && typeof value === "object" && (key in value) ? Number(value[key] ?? 0) : 0;
|
|
183
|
+
var surfaceDetail = (surface) => {
|
|
184
|
+
const total = readNumber(surface, "total");
|
|
185
|
+
const failed = readNumber(surface, "failed");
|
|
186
|
+
const degraded = readNumber(surface, "degraded");
|
|
187
|
+
const source = surface && typeof surface === "object" && "source" in surface && typeof surface.source === "string" ? ` from ${surface.source}` : "";
|
|
188
|
+
if (degraded > 0) {
|
|
189
|
+
return `${degraded} degraded of ${total}`;
|
|
190
|
+
}
|
|
191
|
+
if (failed > 0) {
|
|
192
|
+
return `${failed} failing of ${total}${source}`;
|
|
193
|
+
}
|
|
194
|
+
return total > 0 ? `${total} passing${source}` : `No failures${source}`;
|
|
195
|
+
};
|
|
196
|
+
var getVoiceOpsStatusLabel = (report, error) => {
|
|
197
|
+
if (error) {
|
|
198
|
+
return "Unavailable";
|
|
199
|
+
}
|
|
200
|
+
if (!report) {
|
|
201
|
+
return "Checking";
|
|
202
|
+
}
|
|
203
|
+
return report.status === "pass" ? "Passing" : "Needs attention";
|
|
204
|
+
};
|
|
205
|
+
var createVoiceOpsStatusViewModel = (snapshot, options = {}) => {
|
|
206
|
+
const report = snapshot.report;
|
|
207
|
+
const surfaces = Object.entries(report?.surfaces ?? {}).map(([id, surface]) => {
|
|
208
|
+
const failed = readNumber(surface, "failed") || readNumber(surface, "degraded");
|
|
209
|
+
const total = readNumber(surface, "total");
|
|
210
|
+
const status = surface && typeof surface === "object" && "status" in surface ? surface.status ?? "pass" : "pass";
|
|
211
|
+
return {
|
|
212
|
+
detail: surfaceDetail(surface),
|
|
213
|
+
failed,
|
|
214
|
+
id,
|
|
215
|
+
label: SURFACE_LABELS[id] ?? id,
|
|
216
|
+
status,
|
|
217
|
+
total
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
description: options.description ?? DEFAULT_DESCRIPTION,
|
|
222
|
+
error: snapshot.error,
|
|
223
|
+
isLoading: snapshot.isLoading,
|
|
224
|
+
label: getVoiceOpsStatusLabel(report, snapshot.error),
|
|
225
|
+
links: options.includeLinks === false ? [] : report?.links ?? [],
|
|
226
|
+
passed: report?.passed ?? 0,
|
|
227
|
+
status: snapshot.error ? "error" : report ? report.status : snapshot.isLoading ? "loading" : "loading",
|
|
228
|
+
surfaces,
|
|
229
|
+
title: options.title ?? DEFAULT_TITLE,
|
|
230
|
+
total: report?.total ?? 0,
|
|
231
|
+
updatedAt: snapshot.updatedAt
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
var renderVoiceOpsStatusHTML = (snapshot, options = {}) => {
|
|
235
|
+
const model = createVoiceOpsStatusViewModel(snapshot, options);
|
|
236
|
+
const surfaces = model.surfaces.length ? model.surfaces.map((surface) => `<li class="absolute-voice-ops-status__surface absolute-voice-ops-status__surface--${escapeHtml(surface.status)}">
|
|
237
|
+
<span>${escapeHtml(surface.label)}</span>
|
|
238
|
+
<strong>${escapeHtml(surface.detail)}</strong>
|
|
239
|
+
</li>`).join("") : '<li class="absolute-voice-ops-status__surface"><span>Status</span><strong>Waiting for first check</strong></li>';
|
|
240
|
+
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>` : "";
|
|
241
|
+
return `<section class="absolute-voice-ops-status absolute-voice-ops-status--${escapeHtml(model.status)}">
|
|
242
|
+
<header class="absolute-voice-ops-status__header">
|
|
243
|
+
<span class="absolute-voice-ops-status__eyebrow">${escapeHtml(model.title)}</span>
|
|
244
|
+
<strong class="absolute-voice-ops-status__label">${escapeHtml(model.label)}</strong>
|
|
245
|
+
</header>
|
|
246
|
+
<p class="absolute-voice-ops-status__description">${escapeHtml(model.description)}</p>
|
|
247
|
+
<div class="absolute-voice-ops-status__summary">
|
|
248
|
+
<span>${model.passed} passing</span>
|
|
249
|
+
<span>${Math.max(model.total - model.passed, 0)} failing</span>
|
|
250
|
+
<span>${model.total} checks</span>
|
|
251
|
+
</div>
|
|
252
|
+
<ul class="absolute-voice-ops-status__surfaces">${surfaces}</ul>
|
|
253
|
+
${model.error ? `<p class="absolute-voice-ops-status__error">${escapeHtml(model.error)}</p>` : ""}
|
|
254
|
+
${links}
|
|
255
|
+
</section>`;
|
|
256
|
+
};
|
|
257
|
+
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}`;
|
|
258
|
+
var mountVoiceOpsStatus = (element, path = "/api/voice/ops-status", options = {}) => {
|
|
259
|
+
const store = createVoiceOpsStatusStore(path, options);
|
|
260
|
+
const render = () => {
|
|
261
|
+
element.innerHTML = renderVoiceOpsStatusHTML(store.getSnapshot(), options);
|
|
262
|
+
};
|
|
263
|
+
const unsubscribe = store.subscribe(render);
|
|
264
|
+
render();
|
|
265
|
+
store.refresh().catch(() => {});
|
|
266
|
+
return {
|
|
267
|
+
close: () => {
|
|
268
|
+
unsubscribe();
|
|
269
|
+
store.close();
|
|
270
|
+
},
|
|
271
|
+
refresh: store.refresh
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
var defineVoiceOpsStatusElement = (tagName = "absolute-voice-ops-status") => {
|
|
275
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
customElements.define(tagName, class AbsoluteVoiceOpsStatusElement extends HTMLElement {
|
|
279
|
+
mounted;
|
|
280
|
+
connectedCallback() {
|
|
281
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
282
|
+
this.mounted = mountVoiceOpsStatus(this, this.getAttribute("path") ?? "/api/voice/ops-status", {
|
|
283
|
+
description: this.getAttribute("description") ?? undefined,
|
|
284
|
+
includeLinks: this.getAttribute("include-links") !== "false",
|
|
285
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
286
|
+
title: this.getAttribute("title") ?? undefined
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
disconnectedCallback() {
|
|
290
|
+
this.mounted?.close();
|
|
291
|
+
this.mounted = undefined;
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
// src/react/VoiceOpsStatus.tsx
|
|
297
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
298
|
+
var VoiceOpsStatus = ({
|
|
299
|
+
className,
|
|
300
|
+
path = "/api/voice/ops-status",
|
|
301
|
+
...options
|
|
302
|
+
}) => {
|
|
303
|
+
const snapshot = useVoiceOpsStatus(path, options);
|
|
304
|
+
const model = createVoiceOpsStatusViewModel(snapshot, options);
|
|
305
|
+
return /* @__PURE__ */ jsxDEV("section", {
|
|
306
|
+
className: [
|
|
307
|
+
"absolute-voice-ops-status",
|
|
308
|
+
`absolute-voice-ops-status--${model.status}`,
|
|
309
|
+
className
|
|
310
|
+
].filter(Boolean).join(" "),
|
|
311
|
+
children: [
|
|
312
|
+
/* @__PURE__ */ jsxDEV("header", {
|
|
313
|
+
className: "absolute-voice-ops-status__header",
|
|
314
|
+
children: [
|
|
315
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
316
|
+
className: "absolute-voice-ops-status__eyebrow",
|
|
317
|
+
children: model.title
|
|
318
|
+
}, undefined, false, undefined, this),
|
|
319
|
+
/* @__PURE__ */ jsxDEV("strong", {
|
|
320
|
+
className: "absolute-voice-ops-status__label",
|
|
321
|
+
children: model.label
|
|
322
|
+
}, undefined, false, undefined, this)
|
|
323
|
+
]
|
|
324
|
+
}, undefined, true, undefined, this),
|
|
325
|
+
/* @__PURE__ */ jsxDEV("p", {
|
|
326
|
+
className: "absolute-voice-ops-status__description",
|
|
327
|
+
children: model.description
|
|
328
|
+
}, undefined, false, undefined, this),
|
|
329
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
330
|
+
className: "absolute-voice-ops-status__summary",
|
|
331
|
+
children: [
|
|
332
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
333
|
+
children: [
|
|
334
|
+
model.passed,
|
|
335
|
+
" passing"
|
|
336
|
+
]
|
|
337
|
+
}, undefined, true, undefined, this),
|
|
338
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
339
|
+
children: [
|
|
340
|
+
Math.max(model.total - model.passed, 0),
|
|
341
|
+
" failing"
|
|
342
|
+
]
|
|
343
|
+
}, undefined, true, undefined, this),
|
|
344
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
345
|
+
children: [
|
|
346
|
+
model.total,
|
|
347
|
+
" checks"
|
|
348
|
+
]
|
|
349
|
+
}, undefined, true, undefined, this)
|
|
350
|
+
]
|
|
351
|
+
}, undefined, true, undefined, this),
|
|
352
|
+
/* @__PURE__ */ jsxDEV("ul", {
|
|
353
|
+
className: "absolute-voice-ops-status__surfaces",
|
|
354
|
+
children: model.surfaces.length > 0 ? model.surfaces.map((surface) => /* @__PURE__ */ jsxDEV("li", {
|
|
355
|
+
className: `absolute-voice-ops-status__surface absolute-voice-ops-status__surface--${surface.status}`,
|
|
356
|
+
children: [
|
|
357
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
358
|
+
children: surface.label
|
|
359
|
+
}, undefined, false, undefined, this),
|
|
360
|
+
/* @__PURE__ */ jsxDEV("strong", {
|
|
361
|
+
children: surface.detail
|
|
362
|
+
}, undefined, false, undefined, this)
|
|
363
|
+
]
|
|
364
|
+
}, surface.id, true, undefined, this)) : /* @__PURE__ */ jsxDEV("li", {
|
|
365
|
+
className: "absolute-voice-ops-status__surface",
|
|
366
|
+
children: [
|
|
367
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
368
|
+
children: "Status"
|
|
369
|
+
}, undefined, false, undefined, this),
|
|
370
|
+
/* @__PURE__ */ jsxDEV("strong", {
|
|
371
|
+
children: "Waiting for first check"
|
|
372
|
+
}, undefined, false, undefined, this)
|
|
373
|
+
]
|
|
374
|
+
}, undefined, true, undefined, this)
|
|
375
|
+
}, undefined, false, undefined, this),
|
|
376
|
+
model.error ? /* @__PURE__ */ jsxDEV("p", {
|
|
377
|
+
className: "absolute-voice-ops-status__error",
|
|
378
|
+
children: model.error
|
|
379
|
+
}, undefined, false, undefined, this) : null,
|
|
380
|
+
model.links.length > 0 ? /* @__PURE__ */ jsxDEV("nav", {
|
|
381
|
+
className: "absolute-voice-ops-status__links",
|
|
382
|
+
children: model.links.slice(0, 4).map((link) => /* @__PURE__ */ jsxDEV("a", {
|
|
383
|
+
href: link.href,
|
|
384
|
+
children: link.label
|
|
385
|
+
}, `${link.label}:${link.href}`, false, undefined, this))
|
|
386
|
+
}, undefined, false, undefined, this) : null
|
|
387
|
+
]
|
|
388
|
+
}, undefined, true, undefined, this);
|
|
389
|
+
};
|
|
390
|
+
// src/client/opsActionCenter.ts
|
|
391
|
+
var recordVoiceOpsActionResult = async (result, options = {}) => {
|
|
392
|
+
if (options.auditPath === false) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
const path = options.auditPath ?? "/api/voice/ops-actions/audit";
|
|
396
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
397
|
+
const response = await fetchImpl(path, {
|
|
398
|
+
body: JSON.stringify(result),
|
|
399
|
+
headers: {
|
|
400
|
+
"Content-Type": "application/json"
|
|
401
|
+
},
|
|
402
|
+
method: "POST"
|
|
403
|
+
});
|
|
404
|
+
if (!response.ok) {
|
|
405
|
+
throw new Error(`Voice ops action audit failed: HTTP ${response.status}`);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
var createVoiceOpsActionCenterActions = (options = {}) => {
|
|
409
|
+
const deliveryRuntimePath = options.deliveryRuntimePath ?? "/api/voice-delivery-runtime";
|
|
410
|
+
const actions = [];
|
|
411
|
+
if (options.includeProductionReadiness !== false) {
|
|
412
|
+
actions.push({
|
|
413
|
+
description: "Refresh the production readiness report.",
|
|
414
|
+
id: "production-readiness",
|
|
415
|
+
label: "Refresh readiness",
|
|
416
|
+
method: "GET",
|
|
417
|
+
path: options.productionReadinessPath ?? "/api/production-readiness"
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
if (options.includeDeliveryRuntime !== false) {
|
|
421
|
+
actions.push({
|
|
422
|
+
description: "Drain pending and failed audit/trace deliveries.",
|
|
423
|
+
id: "delivery-runtime.tick",
|
|
424
|
+
label: "Tick delivery workers",
|
|
425
|
+
method: "POST",
|
|
426
|
+
path: `${deliveryRuntimePath.replace(/\/$/, "")}/tick`
|
|
427
|
+
}, {
|
|
428
|
+
description: "Move reviewed dead letters back to live delivery queues.",
|
|
429
|
+
id: "delivery-runtime.requeue-dead-letters",
|
|
430
|
+
label: "Requeue dead letters",
|
|
431
|
+
method: "POST",
|
|
432
|
+
path: `${deliveryRuntimePath.replace(/\/$/, "")}/requeue-dead-letters`
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
if (options.includeTurnLatencyProof !== false) {
|
|
436
|
+
actions.push({
|
|
437
|
+
description: "Run the synthetic turn latency proof.",
|
|
438
|
+
id: "turn-latency.proof",
|
|
439
|
+
label: "Run latency proof",
|
|
440
|
+
method: "POST",
|
|
441
|
+
path: options.turnLatencyProofPath ?? "/api/turn-latency/proof"
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
if (options.includeProviderSimulation !== false) {
|
|
445
|
+
const pathPrefix = options.providerSimulationPathPrefix ?? "/api/stt-simulate";
|
|
446
|
+
for (const provider of options.providers ?? []) {
|
|
447
|
+
actions.push({
|
|
448
|
+
description: `Simulate ${provider} provider failure.`,
|
|
449
|
+
id: `provider.${provider}.failure`,
|
|
450
|
+
label: `Simulate ${provider} failure`,
|
|
451
|
+
method: "POST",
|
|
452
|
+
path: `${pathPrefix}/failure?provider=${encodeURIComponent(provider)}`
|
|
453
|
+
}, {
|
|
454
|
+
description: `Mark ${provider} provider recovered.`,
|
|
455
|
+
id: `provider.${provider}.recovery`,
|
|
456
|
+
label: `Recover ${provider}`,
|
|
457
|
+
method: "POST",
|
|
458
|
+
path: `${pathPrefix}/recovery?provider=${encodeURIComponent(provider)}`
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return actions;
|
|
463
|
+
};
|
|
464
|
+
var runVoiceOpsAction = async (action, options = {}) => {
|
|
465
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
466
|
+
const response = await fetchImpl(action.path, {
|
|
467
|
+
method: action.method ?? "POST"
|
|
468
|
+
});
|
|
469
|
+
const body = await response.json().catch(() => null);
|
|
470
|
+
if (!response.ok) {
|
|
471
|
+
const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice ops action "${action.id}" failed: HTTP ${response.status}`;
|
|
472
|
+
throw new Error(message);
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
actionId: action.id,
|
|
476
|
+
body,
|
|
477
|
+
ok: response.ok,
|
|
478
|
+
ranAt: Date.now(),
|
|
479
|
+
status: response.status
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
var createVoiceOpsActionCenterStore = (options = {}) => {
|
|
483
|
+
const listeners = new Set;
|
|
484
|
+
let closed = false;
|
|
485
|
+
let timer;
|
|
486
|
+
let snapshot = {
|
|
487
|
+
actions: options.actions ?? createVoiceOpsActionCenterActions(),
|
|
488
|
+
error: null,
|
|
489
|
+
isRunning: false
|
|
490
|
+
};
|
|
491
|
+
const emit = () => {
|
|
492
|
+
for (const listener of listeners) {
|
|
493
|
+
listener();
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
const setActions = (actions) => {
|
|
497
|
+
snapshot = { ...snapshot, actions, updatedAt: Date.now() };
|
|
498
|
+
emit();
|
|
499
|
+
};
|
|
500
|
+
const run = async (actionId) => {
|
|
501
|
+
if (closed) {
|
|
502
|
+
return snapshot.lastResult;
|
|
503
|
+
}
|
|
504
|
+
const action = snapshot.actions.find((item) => item.id === actionId);
|
|
505
|
+
if (!action) {
|
|
506
|
+
throw new Error(`Voice ops action "${actionId}" is not configured.`);
|
|
507
|
+
}
|
|
508
|
+
if (action.disabled) {
|
|
509
|
+
throw new Error(`Voice ops action "${actionId}" is disabled.`);
|
|
510
|
+
}
|
|
511
|
+
snapshot = {
|
|
512
|
+
...snapshot,
|
|
513
|
+
error: null,
|
|
514
|
+
isRunning: true,
|
|
515
|
+
runningActionId: action.id
|
|
516
|
+
};
|
|
517
|
+
emit();
|
|
518
|
+
try {
|
|
519
|
+
const result = await runVoiceOpsAction(action, options);
|
|
520
|
+
await options.onActionResult?.(result);
|
|
521
|
+
await recordVoiceOpsActionResult(result, options);
|
|
522
|
+
snapshot = {
|
|
523
|
+
...snapshot,
|
|
524
|
+
error: null,
|
|
525
|
+
isRunning: false,
|
|
526
|
+
lastResult: result,
|
|
527
|
+
runningActionId: undefined,
|
|
528
|
+
updatedAt: Date.now()
|
|
529
|
+
};
|
|
530
|
+
emit();
|
|
531
|
+
return result;
|
|
532
|
+
} catch (error) {
|
|
533
|
+
const result = {
|
|
534
|
+
actionId: action.id,
|
|
535
|
+
body: null,
|
|
536
|
+
error: error instanceof Error ? error.message : String(error),
|
|
537
|
+
ok: false,
|
|
538
|
+
ranAt: Date.now(),
|
|
539
|
+
status: 0
|
|
540
|
+
};
|
|
541
|
+
await options.onActionResult?.(result);
|
|
542
|
+
await recordVoiceOpsActionResult(result, options).catch(() => {});
|
|
543
|
+
snapshot = {
|
|
544
|
+
...snapshot,
|
|
545
|
+
error: error instanceof Error ? error.message : String(error),
|
|
546
|
+
isRunning: false,
|
|
547
|
+
runningActionId: undefined
|
|
548
|
+
};
|
|
549
|
+
emit();
|
|
550
|
+
throw error;
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
const close = () => {
|
|
554
|
+
closed = true;
|
|
555
|
+
if (timer) {
|
|
556
|
+
clearInterval(timer);
|
|
557
|
+
timer = undefined;
|
|
558
|
+
}
|
|
559
|
+
listeners.clear();
|
|
560
|
+
};
|
|
561
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
562
|
+
timer = setInterval(() => {
|
|
563
|
+
emit();
|
|
564
|
+
}, options.intervalMs);
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
close,
|
|
568
|
+
getServerSnapshot: () => snapshot,
|
|
569
|
+
getSnapshot: () => snapshot,
|
|
570
|
+
run,
|
|
571
|
+
setActions,
|
|
572
|
+
subscribe: (listener) => {
|
|
573
|
+
listeners.add(listener);
|
|
574
|
+
return () => {
|
|
575
|
+
listeners.delete(listener);
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
// src/client/opsActionCenterWidget.ts
|
|
582
|
+
var DEFAULT_TITLE2 = "Voice Ops Action Center";
|
|
583
|
+
var DEFAULT_DESCRIPTION2 = "Run production voice proofs and operator actions from one primitive panel.";
|
|
584
|
+
var escapeHtml2 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
585
|
+
var createVoiceOpsActionCenterViewModel = (snapshot, options = {}) => {
|
|
586
|
+
const status = snapshot.error ? "error" : snapshot.isRunning ? "running" : snapshot.lastResult ? "completed" : "ready";
|
|
587
|
+
return {
|
|
588
|
+
actions: snapshot.actions.map((action) => ({
|
|
589
|
+
description: action.description ?? "",
|
|
590
|
+
disabled: Boolean(action.disabled || snapshot.isRunning),
|
|
591
|
+
id: action.id,
|
|
592
|
+
isRunning: snapshot.runningActionId === action.id,
|
|
593
|
+
label: action.label
|
|
594
|
+
})),
|
|
595
|
+
description: options.description ?? DEFAULT_DESCRIPTION2,
|
|
596
|
+
error: snapshot.error,
|
|
597
|
+
isRunning: snapshot.isRunning,
|
|
598
|
+
label: status === "error" ? "Needs attention" : status === "running" ? "Running" : status === "completed" ? "Action completed" : "Ready",
|
|
599
|
+
lastResultLabel: snapshot.lastResult ? `${snapshot.lastResult.actionId} returned HTTP ${snapshot.lastResult.status}` : "No action has run yet.",
|
|
600
|
+
status,
|
|
601
|
+
title: options.title ?? DEFAULT_TITLE2
|
|
602
|
+
};
|
|
603
|
+
};
|
|
604
|
+
var renderVoiceOpsActionCenterHTML = (snapshot, options = {}) => {
|
|
605
|
+
const model = createVoiceOpsActionCenterViewModel(snapshot, options);
|
|
606
|
+
const actions = model.actions.map((action) => `<button type="button" data-absolute-voice-ops-action="${escapeHtml2(action.id)}"${action.disabled ? " disabled" : ""}>
|
|
607
|
+
${escapeHtml2(action.isRunning ? "Working..." : action.label)}
|
|
608
|
+
</button>`).join("");
|
|
609
|
+
return `<section class="absolute-voice-ops-action-center absolute-voice-ops-action-center--${escapeHtml2(model.status)}">
|
|
610
|
+
<header class="absolute-voice-ops-action-center__header">
|
|
611
|
+
<span class="absolute-voice-ops-action-center__eyebrow">${escapeHtml2(model.title)}</span>
|
|
612
|
+
<strong class="absolute-voice-ops-action-center__label">${escapeHtml2(model.label)}</strong>
|
|
613
|
+
</header>
|
|
614
|
+
<p class="absolute-voice-ops-action-center__description">${escapeHtml2(model.description)}</p>
|
|
615
|
+
<div class="absolute-voice-ops-action-center__actions">${actions}</div>
|
|
616
|
+
<p class="absolute-voice-ops-action-center__result">${escapeHtml2(model.lastResultLabel)}</p>
|
|
617
|
+
${model.error ? `<p class="absolute-voice-ops-action-center__error">${escapeHtml2(model.error)}</p>` : ""}
|
|
618
|
+
</section>`;
|
|
619
|
+
};
|
|
620
|
+
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}`;
|
|
621
|
+
var mountVoiceOpsActionCenter = (element, options = {}) => {
|
|
622
|
+
const store = createVoiceOpsActionCenterStore(options);
|
|
623
|
+
const render = () => {
|
|
624
|
+
element.innerHTML = renderVoiceOpsActionCenterHTML(store.getSnapshot(), options);
|
|
625
|
+
};
|
|
626
|
+
const unsubscribe = store.subscribe(render);
|
|
627
|
+
const handleClick = (event) => {
|
|
628
|
+
const target = event.target;
|
|
629
|
+
if (!(target instanceof Element)) {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
const action = target.closest("[data-absolute-voice-ops-action]");
|
|
633
|
+
const actionId = action?.getAttribute("data-absolute-voice-ops-action");
|
|
634
|
+
if (actionId) {
|
|
635
|
+
store.run(actionId).catch(() => {});
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
element.addEventListener?.("click", handleClick);
|
|
639
|
+
render();
|
|
640
|
+
return {
|
|
641
|
+
close: () => {
|
|
642
|
+
element.removeEventListener?.("click", handleClick);
|
|
643
|
+
unsubscribe();
|
|
644
|
+
store.close();
|
|
645
|
+
},
|
|
646
|
+
run: store.run
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
var defineVoiceOpsActionCenterElement = (tagName = "absolute-voice-ops-action-center", options = {}) => {
|
|
650
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
customElements.define(tagName, class AbsoluteVoiceOpsActionCenterElement extends HTMLElement {
|
|
654
|
+
mounted;
|
|
655
|
+
connectedCallback() {
|
|
656
|
+
this.mounted = mountVoiceOpsActionCenter(this, {
|
|
657
|
+
...options,
|
|
658
|
+
description: this.getAttribute("description") ?? options.description,
|
|
659
|
+
title: this.getAttribute("title") ?? options.title
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
disconnectedCallback() {
|
|
663
|
+
this.mounted?.close();
|
|
664
|
+
this.mounted = undefined;
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
// src/react/useVoiceOpsActionCenter.tsx
|
|
670
|
+
import { useEffect as useEffect2, useRef as useRef2, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
671
|
+
var useVoiceOpsActionCenter = (options = {}) => {
|
|
672
|
+
const storeRef = useRef2(null);
|
|
673
|
+
if (!storeRef.current) {
|
|
674
|
+
storeRef.current = createVoiceOpsActionCenterStore(options);
|
|
675
|
+
}
|
|
676
|
+
const store = storeRef.current;
|
|
677
|
+
useEffect2(() => () => store.close(), [store]);
|
|
678
|
+
return {
|
|
679
|
+
...useSyncExternalStore2(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
680
|
+
run: store.run,
|
|
681
|
+
setActions: store.setActions
|
|
682
|
+
};
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
// src/react/VoiceOpsActionCenter.tsx
|
|
686
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
687
|
+
var VoiceOpsActionCenter = ({
|
|
688
|
+
className,
|
|
689
|
+
...options
|
|
690
|
+
}) => {
|
|
691
|
+
const snapshot = useVoiceOpsActionCenter(options);
|
|
692
|
+
const model = createVoiceOpsActionCenterViewModel(snapshot, options);
|
|
693
|
+
return /* @__PURE__ */ jsxDEV2("section", {
|
|
694
|
+
className: [
|
|
695
|
+
"absolute-voice-ops-action-center",
|
|
696
|
+
`absolute-voice-ops-action-center--${model.status}`,
|
|
697
|
+
className
|
|
698
|
+
].filter(Boolean).join(" "),
|
|
699
|
+
children: [
|
|
700
|
+
/* @__PURE__ */ jsxDEV2("header", {
|
|
701
|
+
className: "absolute-voice-ops-action-center__header",
|
|
702
|
+
children: [
|
|
703
|
+
/* @__PURE__ */ jsxDEV2("span", {
|
|
704
|
+
className: "absolute-voice-ops-action-center__eyebrow",
|
|
705
|
+
children: model.title
|
|
706
|
+
}, undefined, false, undefined, this),
|
|
707
|
+
/* @__PURE__ */ jsxDEV2("strong", {
|
|
708
|
+
className: "absolute-voice-ops-action-center__label",
|
|
709
|
+
children: model.label
|
|
710
|
+
}, undefined, false, undefined, this)
|
|
711
|
+
]
|
|
712
|
+
}, undefined, true, undefined, this),
|
|
713
|
+
/* @__PURE__ */ jsxDEV2("p", {
|
|
714
|
+
className: "absolute-voice-ops-action-center__description",
|
|
715
|
+
children: model.description
|
|
716
|
+
}, undefined, false, undefined, this),
|
|
717
|
+
/* @__PURE__ */ jsxDEV2("div", {
|
|
718
|
+
className: "absolute-voice-ops-action-center__actions",
|
|
719
|
+
children: model.actions.map((action) => /* @__PURE__ */ jsxDEV2("button", {
|
|
720
|
+
disabled: action.disabled,
|
|
721
|
+
onClick: () => {
|
|
722
|
+
snapshot.run(action.id).catch(() => {});
|
|
723
|
+
},
|
|
724
|
+
type: "button",
|
|
725
|
+
children: action.isRunning ? "Working..." : action.label
|
|
726
|
+
}, action.id, false, undefined, this))
|
|
727
|
+
}, undefined, false, undefined, this),
|
|
728
|
+
/* @__PURE__ */ jsxDEV2("p", {
|
|
729
|
+
className: "absolute-voice-ops-action-center__result",
|
|
730
|
+
children: model.lastResultLabel
|
|
731
|
+
}, undefined, false, undefined, this),
|
|
732
|
+
model.error ? /* @__PURE__ */ jsxDEV2("p", {
|
|
733
|
+
className: "absolute-voice-ops-action-center__error",
|
|
734
|
+
children: model.error
|
|
735
|
+
}, undefined, false, undefined, this) : null
|
|
736
|
+
]
|
|
737
|
+
}, undefined, true, undefined, this);
|
|
738
|
+
};
|
|
739
|
+
// src/client/deliveryRuntime.ts
|
|
740
|
+
var getDefaultActionPath = (path, action, options) => {
|
|
741
|
+
if (action === "tick") {
|
|
742
|
+
return options.tickPath ?? `${path.replace(/\/$/, "")}/tick`;
|
|
743
|
+
}
|
|
744
|
+
return options.requeueDeadLettersPath ?? `${path.replace(/\/$/, "")}/requeue-dead-letters`;
|
|
745
|
+
};
|
|
746
|
+
var fetchVoiceDeliveryRuntime = async (path = "/api/voice-delivery-runtime", options = {}) => {
|
|
747
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
748
|
+
const response = await fetchImpl(path);
|
|
749
|
+
if (!response.ok) {
|
|
750
|
+
throw new Error(`Voice delivery runtime failed: HTTP ${response.status}`);
|
|
751
|
+
}
|
|
752
|
+
return await response.json();
|
|
753
|
+
};
|
|
754
|
+
var runVoiceDeliveryRuntimeAction = async (action, path = "/api/voice-delivery-runtime", options = {}) => {
|
|
755
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
756
|
+
const response = await fetchImpl(getDefaultActionPath(path, action, options), {
|
|
757
|
+
method: "POST"
|
|
758
|
+
});
|
|
759
|
+
if (!response.ok) {
|
|
760
|
+
throw new Error(`Voice delivery runtime ${action} failed: HTTP ${response.status}`);
|
|
761
|
+
}
|
|
762
|
+
const body = await response.json();
|
|
763
|
+
return {
|
|
764
|
+
action,
|
|
765
|
+
result: body.result,
|
|
766
|
+
summary: body.summary,
|
|
767
|
+
updatedAt: Date.now()
|
|
768
|
+
};
|
|
769
|
+
};
|
|
770
|
+
var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", options = {}) => {
|
|
771
|
+
const listeners = new Set;
|
|
772
|
+
let closed = false;
|
|
773
|
+
let timer;
|
|
774
|
+
let snapshot = {
|
|
775
|
+
actionError: null,
|
|
776
|
+
actionStatus: "idle",
|
|
777
|
+
error: null,
|
|
778
|
+
isLoading: false
|
|
779
|
+
};
|
|
780
|
+
const emit = () => {
|
|
781
|
+
for (const listener of listeners) {
|
|
782
|
+
listener();
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
const refresh = async () => {
|
|
786
|
+
if (closed) {
|
|
787
|
+
return snapshot.report;
|
|
788
|
+
}
|
|
789
|
+
snapshot = {
|
|
790
|
+
...snapshot,
|
|
791
|
+
error: null,
|
|
792
|
+
isLoading: true
|
|
793
|
+
};
|
|
794
|
+
emit();
|
|
795
|
+
try {
|
|
796
|
+
const report = await fetchVoiceDeliveryRuntime(path, options);
|
|
797
|
+
snapshot = {
|
|
798
|
+
...snapshot,
|
|
799
|
+
error: null,
|
|
800
|
+
isLoading: false,
|
|
801
|
+
report,
|
|
802
|
+
updatedAt: Date.now()
|
|
803
|
+
};
|
|
804
|
+
emit();
|
|
805
|
+
return report;
|
|
806
|
+
} catch (error) {
|
|
807
|
+
snapshot = {
|
|
808
|
+
...snapshot,
|
|
809
|
+
error: error instanceof Error ? error.message : String(error),
|
|
810
|
+
isLoading: false
|
|
811
|
+
};
|
|
812
|
+
emit();
|
|
813
|
+
throw error;
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
const runAction = async (action) => {
|
|
817
|
+
if (closed) {
|
|
818
|
+
return snapshot.lastAction;
|
|
819
|
+
}
|
|
820
|
+
snapshot = {
|
|
821
|
+
...snapshot,
|
|
822
|
+
actionError: null,
|
|
823
|
+
actionStatus: "running"
|
|
824
|
+
};
|
|
825
|
+
emit();
|
|
826
|
+
try {
|
|
827
|
+
const result = await runVoiceDeliveryRuntimeAction(action, path, options);
|
|
828
|
+
snapshot = {
|
|
829
|
+
...snapshot,
|
|
830
|
+
actionError: null,
|
|
831
|
+
actionStatus: "completed",
|
|
832
|
+
lastAction: result
|
|
833
|
+
};
|
|
834
|
+
emit();
|
|
835
|
+
await refresh();
|
|
836
|
+
return result;
|
|
837
|
+
} catch (error) {
|
|
838
|
+
snapshot = {
|
|
839
|
+
...snapshot,
|
|
840
|
+
actionError: error instanceof Error ? error.message : String(error),
|
|
841
|
+
actionStatus: "failed"
|
|
842
|
+
};
|
|
843
|
+
emit();
|
|
844
|
+
throw error;
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
const close = () => {
|
|
848
|
+
closed = true;
|
|
849
|
+
if (timer) {
|
|
850
|
+
clearInterval(timer);
|
|
851
|
+
timer = undefined;
|
|
852
|
+
}
|
|
853
|
+
listeners.clear();
|
|
854
|
+
};
|
|
855
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
856
|
+
timer = setInterval(() => {
|
|
857
|
+
refresh().catch(() => {});
|
|
858
|
+
}, options.intervalMs);
|
|
859
|
+
}
|
|
860
|
+
return {
|
|
861
|
+
close,
|
|
862
|
+
getServerSnapshot: () => snapshot,
|
|
863
|
+
getSnapshot: () => snapshot,
|
|
864
|
+
requeueDeadLetters: () => runAction("requeue-dead-letters"),
|
|
865
|
+
refresh,
|
|
866
|
+
tick: () => runAction("tick"),
|
|
867
|
+
subscribe: (listener) => {
|
|
868
|
+
listeners.add(listener);
|
|
869
|
+
return () => {
|
|
870
|
+
listeners.delete(listener);
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
// src/client/deliveryRuntimeWidget.ts
|
|
877
|
+
var DEFAULT_TITLE3 = "Voice Delivery Runtime";
|
|
878
|
+
var DEFAULT_DESCRIPTION3 = "Audit and trace delivery worker health from your AbsoluteJS voice app.";
|
|
879
|
+
var escapeHtml3 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
880
|
+
var createSurface = (id, summary) => {
|
|
881
|
+
if (!summary) {
|
|
882
|
+
return {
|
|
883
|
+
deadLettered: 0,
|
|
884
|
+
detail: "Worker disabled",
|
|
885
|
+
failed: 0,
|
|
886
|
+
id,
|
|
887
|
+
label: id === "audit" ? "Audit delivery" : "Trace delivery",
|
|
888
|
+
pending: 0,
|
|
889
|
+
status: "disabled",
|
|
890
|
+
total: 0
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
const blocked = summary.failed + summary.deadLettered;
|
|
894
|
+
return {
|
|
895
|
+
deadLettered: summary.deadLettered,
|
|
896
|
+
detail: `${summary.delivered}/${summary.total} delivered, ${summary.pending} pending`,
|
|
897
|
+
failed: summary.failed,
|
|
898
|
+
id,
|
|
899
|
+
label: id === "audit" ? "Audit delivery" : "Trace delivery",
|
|
900
|
+
pending: summary.pending,
|
|
901
|
+
status: blocked > 0 ? "warn" : "pass",
|
|
902
|
+
total: summary.total
|
|
903
|
+
};
|
|
904
|
+
};
|
|
905
|
+
var createVoiceDeliveryRuntimeViewModel = (snapshot, options = {}) => {
|
|
906
|
+
const report = snapshot.report;
|
|
907
|
+
const surfaces = [
|
|
908
|
+
createSurface("audit", report?.summary.audit),
|
|
909
|
+
createSurface("trace", report?.summary.trace)
|
|
910
|
+
];
|
|
911
|
+
const hasWarnings = surfaces.some((surface) => surface.status === "warn");
|
|
912
|
+
return {
|
|
913
|
+
description: options.description ?? DEFAULT_DESCRIPTION3,
|
|
914
|
+
error: snapshot.error,
|
|
915
|
+
actionError: snapshot.actionError,
|
|
916
|
+
actionStatus: snapshot.actionStatus,
|
|
917
|
+
isLoading: snapshot.isLoading,
|
|
918
|
+
isRunning: Boolean(report?.isRunning),
|
|
919
|
+
label: snapshot.error ? "Unavailable" : report ? report.isRunning ? "Running" : "Stopped" : "Checking",
|
|
920
|
+
status: snapshot.error ? "error" : report ? hasWarnings ? "warn" : "pass" : "loading",
|
|
921
|
+
surfaces,
|
|
922
|
+
title: options.title ?? DEFAULT_TITLE3,
|
|
923
|
+
updatedAt: snapshot.updatedAt
|
|
924
|
+
};
|
|
925
|
+
};
|
|
926
|
+
var renderVoiceDeliveryRuntimeHTML = (snapshot, options = {}) => {
|
|
927
|
+
const model = createVoiceDeliveryRuntimeViewModel(snapshot, options);
|
|
928
|
+
const surfaces = model.surfaces.map((surface) => `<li class="absolute-voice-delivery-runtime__surface absolute-voice-delivery-runtime__surface--${escapeHtml3(surface.status)}">
|
|
929
|
+
<span>${escapeHtml3(surface.label)}</span>
|
|
930
|
+
<strong>${escapeHtml3(surface.detail)}</strong>
|
|
931
|
+
<small>${String(surface.failed)} failed · ${String(surface.deadLettered)} dead-lettered</small>
|
|
932
|
+
</li>`).join("");
|
|
933
|
+
const actions = options.includeActions === false ? "" : `<div class="absolute-voice-delivery-runtime__actions">
|
|
934
|
+
<button type="button" data-absolute-voice-delivery-runtime-action="tick">${model.actionStatus === "running" ? "Working..." : "Tick workers"}</button>
|
|
935
|
+
<button type="button" data-absolute-voice-delivery-runtime-action="requeue-dead-letters"${model.surfaces.some((surface) => surface.deadLettered > 0) ? "" : " disabled"}>Requeue dead letters</button>
|
|
936
|
+
</div>`;
|
|
937
|
+
const actionError = model.actionError ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml3(model.actionError)}</p>` : "";
|
|
938
|
+
return `<section class="absolute-voice-delivery-runtime absolute-voice-delivery-runtime--${escapeHtml3(model.status)}">
|
|
939
|
+
<header class="absolute-voice-delivery-runtime__header">
|
|
940
|
+
<span class="absolute-voice-delivery-runtime__eyebrow">${escapeHtml3(model.title)}</span>
|
|
941
|
+
<strong class="absolute-voice-delivery-runtime__label">${escapeHtml3(model.label)}</strong>
|
|
942
|
+
</header>
|
|
943
|
+
<p class="absolute-voice-delivery-runtime__description">${escapeHtml3(model.description)}</p>
|
|
944
|
+
<ul class="absolute-voice-delivery-runtime__surfaces">${surfaces}</ul>
|
|
945
|
+
${actions}
|
|
946
|
+
${actionError}
|
|
947
|
+
${model.error ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml3(model.error)}</p>` : ""}
|
|
948
|
+
</section>`;
|
|
949
|
+
};
|
|
950
|
+
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}`;
|
|
951
|
+
var mountVoiceDeliveryRuntime = (element, path = "/api/voice-delivery-runtime", options = {}) => {
|
|
952
|
+
const store = createVoiceDeliveryRuntimeStore(path, options);
|
|
953
|
+
const render = () => {
|
|
954
|
+
element.innerHTML = renderVoiceDeliveryRuntimeHTML(store.getSnapshot(), options);
|
|
955
|
+
};
|
|
956
|
+
const unsubscribe = store.subscribe(render);
|
|
957
|
+
const handleClick = (event) => {
|
|
958
|
+
const target = event.target;
|
|
959
|
+
if (!(target instanceof Element)) {
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
const action = target.closest("[data-absolute-voice-delivery-runtime-action]");
|
|
963
|
+
const actionName = action?.getAttribute("data-absolute-voice-delivery-runtime-action");
|
|
964
|
+
if (actionName === "tick") {
|
|
965
|
+
store.tick().catch(() => {});
|
|
966
|
+
}
|
|
967
|
+
if (actionName === "requeue-dead-letters") {
|
|
968
|
+
store.requeueDeadLetters().catch(() => {});
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
element.addEventListener?.("click", handleClick);
|
|
972
|
+
render();
|
|
973
|
+
store.refresh().catch(() => {});
|
|
974
|
+
return {
|
|
975
|
+
close: () => {
|
|
976
|
+
element.removeEventListener?.("click", handleClick);
|
|
977
|
+
unsubscribe();
|
|
978
|
+
store.close();
|
|
979
|
+
},
|
|
980
|
+
refresh: store.refresh
|
|
981
|
+
};
|
|
982
|
+
};
|
|
983
|
+
var defineVoiceDeliveryRuntimeElement = (tagName = "absolute-voice-delivery-runtime") => {
|
|
984
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
customElements.define(tagName, class AbsoluteVoiceDeliveryRuntimeElement extends HTMLElement {
|
|
988
|
+
mounted;
|
|
989
|
+
connectedCallback() {
|
|
990
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
991
|
+
this.mounted = mountVoiceDeliveryRuntime(this, this.getAttribute("path") ?? "/api/voice-delivery-runtime", {
|
|
992
|
+
description: this.getAttribute("description") ?? undefined,
|
|
993
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
994
|
+
title: this.getAttribute("title") ?? undefined
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
disconnectedCallback() {
|
|
998
|
+
this.mounted?.close();
|
|
999
|
+
this.mounted = undefined;
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
// src/react/useVoiceDeliveryRuntime.tsx
|
|
1005
|
+
import { useEffect as useEffect3, useRef as useRef3, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
1006
|
+
var useVoiceDeliveryRuntime = (path = "/api/voice-delivery-runtime", options = {}) => {
|
|
1007
|
+
const storeRef = useRef3(null);
|
|
1008
|
+
if (!storeRef.current) {
|
|
1009
|
+
storeRef.current = createVoiceDeliveryRuntimeStore(path, options);
|
|
1010
|
+
}
|
|
1011
|
+
const store = storeRef.current;
|
|
1012
|
+
useEffect3(() => {
|
|
1013
|
+
store.refresh().catch(() => {});
|
|
1014
|
+
return () => store.close();
|
|
1015
|
+
}, [store]);
|
|
1016
|
+
return {
|
|
1017
|
+
...useSyncExternalStore3(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
1018
|
+
requeueDeadLetters: store.requeueDeadLetters,
|
|
1019
|
+
refresh: store.refresh,
|
|
1020
|
+
tick: store.tick
|
|
1021
|
+
};
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
// src/react/VoiceDeliveryRuntime.tsx
|
|
1025
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
1026
|
+
var VoiceDeliveryRuntime = ({
|
|
1027
|
+
className,
|
|
1028
|
+
includeActions = true,
|
|
1029
|
+
path = "/api/voice-delivery-runtime",
|
|
1030
|
+
...options
|
|
1031
|
+
}) => {
|
|
1032
|
+
const snapshot = useVoiceDeliveryRuntime(path, options);
|
|
1033
|
+
const model = createVoiceDeliveryRuntimeViewModel(snapshot, options);
|
|
1034
|
+
const hasDeadLetters = model.surfaces.some((surface) => surface.deadLettered > 0);
|
|
1035
|
+
return /* @__PURE__ */ jsxDEV3("section", {
|
|
1036
|
+
className: [
|
|
1037
|
+
"absolute-voice-delivery-runtime",
|
|
1038
|
+
`absolute-voice-delivery-runtime--${model.status}`,
|
|
1039
|
+
className
|
|
1040
|
+
].filter(Boolean).join(" "),
|
|
1041
|
+
children: [
|
|
1042
|
+
/* @__PURE__ */ jsxDEV3("header", {
|
|
1043
|
+
className: "absolute-voice-delivery-runtime__header",
|
|
1044
|
+
children: [
|
|
1045
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
1046
|
+
className: "absolute-voice-delivery-runtime__eyebrow",
|
|
1047
|
+
children: model.title
|
|
1048
|
+
}, undefined, false, undefined, this),
|
|
1049
|
+
/* @__PURE__ */ jsxDEV3("strong", {
|
|
1050
|
+
className: "absolute-voice-delivery-runtime__label",
|
|
1051
|
+
children: model.label
|
|
1052
|
+
}, undefined, false, undefined, this)
|
|
1053
|
+
]
|
|
1054
|
+
}, undefined, true, undefined, this),
|
|
1055
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
1056
|
+
className: "absolute-voice-delivery-runtime__description",
|
|
1057
|
+
children: model.description
|
|
1058
|
+
}, undefined, false, undefined, this),
|
|
1059
|
+
/* @__PURE__ */ jsxDEV3("ul", {
|
|
1060
|
+
className: "absolute-voice-delivery-runtime__surfaces",
|
|
1061
|
+
children: model.surfaces.map((surface) => /* @__PURE__ */ jsxDEV3("li", {
|
|
1062
|
+
className: `absolute-voice-delivery-runtime__surface absolute-voice-delivery-runtime__surface--${surface.status}`,
|
|
1063
|
+
children: [
|
|
1064
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
1065
|
+
children: surface.label
|
|
1066
|
+
}, undefined, false, undefined, this),
|
|
1067
|
+
/* @__PURE__ */ jsxDEV3("strong", {
|
|
1068
|
+
children: surface.detail
|
|
1069
|
+
}, undefined, false, undefined, this),
|
|
1070
|
+
/* @__PURE__ */ jsxDEV3("small", {
|
|
1071
|
+
children: [
|
|
1072
|
+
surface.failed,
|
|
1073
|
+
" failed / ",
|
|
1074
|
+
surface.deadLettered,
|
|
1075
|
+
" dead-lettered"
|
|
1076
|
+
]
|
|
1077
|
+
}, undefined, true, undefined, this)
|
|
1078
|
+
]
|
|
1079
|
+
}, surface.id, true, undefined, this))
|
|
1080
|
+
}, undefined, false, undefined, this),
|
|
1081
|
+
includeActions ? /* @__PURE__ */ jsxDEV3("div", {
|
|
1082
|
+
className: "absolute-voice-delivery-runtime__actions",
|
|
1083
|
+
children: [
|
|
1084
|
+
/* @__PURE__ */ jsxDEV3("button", {
|
|
1085
|
+
disabled: model.actionStatus === "running",
|
|
1086
|
+
onClick: () => {
|
|
1087
|
+
snapshot.tick().catch(() => {});
|
|
1088
|
+
},
|
|
1089
|
+
type: "button",
|
|
1090
|
+
children: model.actionStatus === "running" ? "Working..." : "Tick workers"
|
|
1091
|
+
}, undefined, false, undefined, this),
|
|
1092
|
+
/* @__PURE__ */ jsxDEV3("button", {
|
|
1093
|
+
disabled: model.actionStatus === "running" || !hasDeadLetters,
|
|
1094
|
+
onClick: () => {
|
|
1095
|
+
snapshot.requeueDeadLetters().catch(() => {});
|
|
1096
|
+
},
|
|
1097
|
+
type: "button",
|
|
1098
|
+
children: "Requeue dead letters"
|
|
1099
|
+
}, undefined, false, undefined, this)
|
|
1100
|
+
]
|
|
1101
|
+
}, undefined, true, undefined, this) : null,
|
|
1102
|
+
model.actionError ? /* @__PURE__ */ jsxDEV3("p", {
|
|
1103
|
+
className: "absolute-voice-delivery-runtime__error",
|
|
1104
|
+
children: model.actionError
|
|
1105
|
+
}, undefined, false, undefined, this) : null,
|
|
1106
|
+
model.error ? /* @__PURE__ */ jsxDEV3("p", {
|
|
1107
|
+
className: "absolute-voice-delivery-runtime__error",
|
|
1108
|
+
children: model.error
|
|
1109
|
+
}, undefined, false, undefined, this) : null
|
|
1110
|
+
]
|
|
1111
|
+
}, undefined, true, undefined, this);
|
|
1112
|
+
};
|
|
1113
|
+
// src/react/useVoicePlatformCoverage.tsx
|
|
1114
|
+
import { useEffect as useEffect4, useRef as useRef4, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
1115
|
+
|
|
1116
|
+
// src/client/platformCoverage.ts
|
|
1117
|
+
var fetchVoicePlatformCoverage = async (path = "/api/voice/platform-coverage", options = {}) => {
|
|
1118
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1119
|
+
const response = await fetchImpl(path);
|
|
1120
|
+
if (!response.ok) {
|
|
1121
|
+
throw new Error(`Voice platform coverage failed: HTTP ${response.status}`);
|
|
1122
|
+
}
|
|
1123
|
+
return await response.json();
|
|
1124
|
+
};
|
|
1125
|
+
var createVoicePlatformCoverageStore = (path = "/api/voice/platform-coverage", options = {}) => {
|
|
1126
|
+
const listeners = new Set;
|
|
1127
|
+
let closed = false;
|
|
1128
|
+
let timer;
|
|
1129
|
+
let snapshot = {
|
|
1130
|
+
error: null,
|
|
1131
|
+
isLoading: false
|
|
1132
|
+
};
|
|
1133
|
+
const emit = () => {
|
|
1134
|
+
for (const listener of listeners) {
|
|
1135
|
+
listener();
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
const refresh = async () => {
|
|
1139
|
+
if (closed) {
|
|
1140
|
+
return snapshot.report;
|
|
1141
|
+
}
|
|
1142
|
+
snapshot = {
|
|
1143
|
+
...snapshot,
|
|
1144
|
+
error: null,
|
|
1145
|
+
isLoading: true
|
|
1146
|
+
};
|
|
1147
|
+
emit();
|
|
1148
|
+
try {
|
|
1149
|
+
const report = await fetchVoicePlatformCoverage(path, options);
|
|
1150
|
+
snapshot = {
|
|
1151
|
+
error: null,
|
|
1152
|
+
isLoading: false,
|
|
1153
|
+
report,
|
|
1154
|
+
updatedAt: Date.now()
|
|
1155
|
+
};
|
|
1156
|
+
emit();
|
|
1157
|
+
return report;
|
|
1158
|
+
} catch (error) {
|
|
1159
|
+
snapshot = {
|
|
1160
|
+
...snapshot,
|
|
1161
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1162
|
+
isLoading: false
|
|
1163
|
+
};
|
|
1164
|
+
emit();
|
|
1165
|
+
throw error;
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
const close = () => {
|
|
1169
|
+
closed = true;
|
|
1170
|
+
if (timer) {
|
|
1171
|
+
clearInterval(timer);
|
|
1172
|
+
timer = undefined;
|
|
1173
|
+
}
|
|
1174
|
+
listeners.clear();
|
|
1175
|
+
};
|
|
1176
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
1177
|
+
timer = setInterval(() => {
|
|
1178
|
+
refresh().catch(() => {});
|
|
1179
|
+
}, options.intervalMs);
|
|
1180
|
+
}
|
|
1181
|
+
return {
|
|
1182
|
+
close,
|
|
1183
|
+
getServerSnapshot: () => snapshot,
|
|
1184
|
+
getSnapshot: () => snapshot,
|
|
1185
|
+
refresh,
|
|
1186
|
+
subscribe: (listener) => {
|
|
1187
|
+
listeners.add(listener);
|
|
1188
|
+
return () => {
|
|
1189
|
+
listeners.delete(listener);
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
// src/react/useVoicePlatformCoverage.tsx
|
|
1196
|
+
var useVoicePlatformCoverage = (path = "/api/voice/platform-coverage", options = {}) => {
|
|
1197
|
+
const storeRef = useRef4(null);
|
|
1198
|
+
if (!storeRef.current) {
|
|
1199
|
+
storeRef.current = createVoicePlatformCoverageStore(path, options);
|
|
1200
|
+
}
|
|
1201
|
+
const store = storeRef.current;
|
|
1202
|
+
useEffect4(() => {
|
|
1203
|
+
store.refresh().catch(() => {});
|
|
1204
|
+
return () => store.close();
|
|
1205
|
+
}, [store]);
|
|
1206
|
+
return {
|
|
1207
|
+
...useSyncExternalStore4(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
1208
|
+
refresh: store.refresh
|
|
1209
|
+
};
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
// src/client/platformCoverageWidget.ts
|
|
1213
|
+
var DEFAULT_TITLE4 = "Platform Replacement Coverage";
|
|
1214
|
+
var DEFAULT_DESCRIPTION4 = "Code-owned coverage for hosted voice-platform surfaces, backed by the same proof routes used by release evidence.";
|
|
1215
|
+
var DEFAULT_LINKS = [
|
|
1216
|
+
{ href: "/switching-from-vapi", label: "Switching guide" },
|
|
1217
|
+
{ href: "/api/voice/vapi-coverage", label: "Coverage JSON" }
|
|
1218
|
+
];
|
|
1219
|
+
var escapeHtml4 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1220
|
+
var formatStatus = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
1221
|
+
var surfaceDetail2 = (surface) => {
|
|
1222
|
+
if (surface.status === "pass") {
|
|
1223
|
+
return surface.replacement;
|
|
1224
|
+
}
|
|
1225
|
+
if (surface.gap) {
|
|
1226
|
+
return surface.gap;
|
|
1227
|
+
}
|
|
1228
|
+
if (surface.missingEvidence?.length) {
|
|
1229
|
+
return `Missing evidence: ${surface.missingEvidence.join(", ")}`;
|
|
1230
|
+
}
|
|
1231
|
+
return surface.replacement;
|
|
1232
|
+
};
|
|
1233
|
+
var createVoicePlatformCoverageViewModel = (snapshot, options = {}) => {
|
|
1234
|
+
const allSurfaces = snapshot.report?.coverage ?? [];
|
|
1235
|
+
const failing = allSurfaces.filter((surface) => surface.status !== "pass");
|
|
1236
|
+
const limit = options.limit ?? 6;
|
|
1237
|
+
const surfaces = allSurfaces.slice(0, limit).map((surface) => ({
|
|
1238
|
+
...surface,
|
|
1239
|
+
detail: surfaceDetail2(surface),
|
|
1240
|
+
label: surface.surface
|
|
1241
|
+
}));
|
|
1242
|
+
return {
|
|
1243
|
+
description: options.description ?? DEFAULT_DESCRIPTION4,
|
|
1244
|
+
error: snapshot.error,
|
|
1245
|
+
isLoading: snapshot.isLoading,
|
|
1246
|
+
label: snapshot.error ? "Unavailable" : snapshot.report ? failing.length ? `${failing.length} gaps` : `${snapshot.report.total} surfaces passing` : snapshot.isLoading ? "Checking" : "No coverage report",
|
|
1247
|
+
links: options.links ?? DEFAULT_LINKS,
|
|
1248
|
+
status: snapshot.error ? "error" : snapshot.report ? failing.length ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
1249
|
+
surfaces,
|
|
1250
|
+
title: options.title ?? DEFAULT_TITLE4,
|
|
1251
|
+
updatedAt: snapshot.updatedAt
|
|
1252
|
+
};
|
|
1253
|
+
};
|
|
1254
|
+
var renderVoicePlatformCoverageHTML = (snapshot, options = {}) => {
|
|
1255
|
+
const model = createVoicePlatformCoverageViewModel(snapshot, options);
|
|
1256
|
+
const surfaces = model.surfaces.length ? `<div class="absolute-voice-platform-coverage__surfaces">${model.surfaces.map((surface) => `<article class="absolute-voice-platform-coverage__surface absolute-voice-platform-coverage__surface--${escapeHtml4(surface.status)}">
|
|
1257
|
+
<header>
|
|
1258
|
+
<strong>${escapeHtml4(surface.label)}</strong>
|
|
1259
|
+
<span>${escapeHtml4(formatStatus(surface.status))}</span>
|
|
1260
|
+
</header>
|
|
1261
|
+
<p>${escapeHtml4(surface.detail)}</p>
|
|
1262
|
+
<small>${surface.evidence.filter((item) => item.ok).length}/${surface.evidence.length} evidence checks passing</small>
|
|
1263
|
+
</article>`).join("")}</div>` : `<p class="absolute-voice-platform-coverage__empty">${model.error ? escapeHtml4(model.error) : "Run the proof pack to populate platform coverage evidence."}</p>`;
|
|
1264
|
+
const links = model.links.length ? `<p class="absolute-voice-platform-coverage__links">${model.links.map((link) => `<a href="${escapeHtml4(link.href)}">${escapeHtml4(link.label)}</a>`).join("")}</p>` : "";
|
|
1265
|
+
return `<section class="absolute-voice-platform-coverage absolute-voice-platform-coverage--${escapeHtml4(model.status)}">
|
|
1266
|
+
<header class="absolute-voice-platform-coverage__header">
|
|
1267
|
+
<span class="absolute-voice-platform-coverage__eyebrow">${escapeHtml4(model.title)}</span>
|
|
1268
|
+
<strong class="absolute-voice-platform-coverage__label">${escapeHtml4(model.label)}</strong>
|
|
1269
|
+
</header>
|
|
1270
|
+
<p class="absolute-voice-platform-coverage__description">${escapeHtml4(model.description)}</p>
|
|
1271
|
+
${surfaces}
|
|
1272
|
+
${links}
|
|
1273
|
+
${model.error ? `<p class="absolute-voice-platform-coverage__error">${escapeHtml4(model.error)}</p>` : ""}
|
|
1274
|
+
</section>`;
|
|
1275
|
+
};
|
|
1276
|
+
var getVoicePlatformCoverageCSS = () => `.absolute-voice-platform-coverage{border:1px solid #c7d2fe;border-radius:20px;background:#f8fbff;color:#111827;padding:18px;box-shadow:0 18px 40px rgba(30,64,175,.12);font-family:inherit}.absolute-voice-platform-coverage--warning,.absolute-voice-platform-coverage--error{border-color:#f2a7a7;background:#fff7f4}.absolute-voice-platform-coverage__header,.absolute-voice-platform-coverage__surface header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-platform-coverage__eyebrow{color:#1d4ed8;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-platform-coverage__label{font-size:24px;line-height:1}.absolute-voice-platform-coverage__description,.absolute-voice-platform-coverage__surface p,.absolute-voice-platform-coverage__surface small,.absolute-voice-platform-coverage__empty{color:#475569}.absolute-voice-platform-coverage__surfaces{display:grid;gap:10px;margin-top:14px}.absolute-voice-platform-coverage__surface{background:#fff;border:1px solid #dbeafe;border-radius:16px;padding:12px}.absolute-voice-platform-coverage__surface--pass{border-color:#86efac}.absolute-voice-platform-coverage__surface--fail,.absolute-voice-platform-coverage__surface--missing,.absolute-voice-platform-coverage__surface--stale{border-color:#f2a7a7}.absolute-voice-platform-coverage__surface p{margin:8px 0}.absolute-voice-platform-coverage__surface span{text-transform:capitalize}.absolute-voice-platform-coverage__links{display:flex;flex-wrap:wrap;gap:8px;margin:14px 0 0}.absolute-voice-platform-coverage__links a{border:1px solid #bfdbfe;border-radius:999px;color:#1d4ed8;font-weight:800;padding:6px 10px;text-decoration:none}.absolute-voice-platform-coverage__error{color:#9f1239;font-weight:700}`;
|
|
1277
|
+
var mountVoicePlatformCoverage = (element, path = "/api/voice/platform-coverage", options = {}) => {
|
|
1278
|
+
const store = createVoicePlatformCoverageStore(path, options);
|
|
1279
|
+
const render = () => {
|
|
1280
|
+
element.innerHTML = renderVoicePlatformCoverageHTML(store.getSnapshot(), options);
|
|
1281
|
+
};
|
|
1282
|
+
const unsubscribe = store.subscribe(render);
|
|
1283
|
+
render();
|
|
1284
|
+
store.refresh().catch(() => {});
|
|
1285
|
+
return {
|
|
1286
|
+
close: () => {
|
|
1287
|
+
unsubscribe();
|
|
1288
|
+
store.close();
|
|
1289
|
+
},
|
|
1290
|
+
refresh: store.refresh
|
|
1291
|
+
};
|
|
1292
|
+
};
|
|
1293
|
+
var defineVoicePlatformCoverageElement = (tagName = "absolute-voice-platform-coverage") => {
|
|
1294
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
customElements.define(tagName, class AbsoluteVoicePlatformCoverageElement extends HTMLElement {
|
|
1298
|
+
mounted;
|
|
1299
|
+
connectedCallback() {
|
|
1300
|
+
this.mounted = mountVoicePlatformCoverage(this, this.getAttribute("path") ?? "/api/voice/platform-coverage", {
|
|
1301
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1302
|
+
intervalMs: Number(this.getAttribute("interval-ms") ?? 0) || undefined,
|
|
1303
|
+
limit: Number(this.getAttribute("limit") ?? 0) || undefined,
|
|
1304
|
+
title: this.getAttribute("title") ?? undefined
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
disconnectedCallback() {
|
|
1308
|
+
this.mounted?.close();
|
|
1309
|
+
this.mounted = undefined;
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1314
|
+
// src/react/VoicePlatformCoverage.tsx
|
|
1315
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
1316
|
+
var VoicePlatformCoverage = ({
|
|
1317
|
+
className,
|
|
1318
|
+
path = "/api/voice/platform-coverage",
|
|
1319
|
+
...options
|
|
1320
|
+
}) => {
|
|
1321
|
+
const snapshot = useVoicePlatformCoverage(path, options);
|
|
1322
|
+
const model = createVoicePlatformCoverageViewModel(snapshot, options);
|
|
1323
|
+
return /* @__PURE__ */ jsxDEV4("section", {
|
|
1324
|
+
className: [
|
|
1325
|
+
"absolute-voice-platform-coverage",
|
|
1326
|
+
`absolute-voice-platform-coverage--${model.status}`,
|
|
1327
|
+
className
|
|
1328
|
+
].filter(Boolean).join(" "),
|
|
1329
|
+
children: [
|
|
1330
|
+
/* @__PURE__ */ jsxDEV4("header", {
|
|
1331
|
+
className: "absolute-voice-platform-coverage__header",
|
|
1332
|
+
children: [
|
|
1333
|
+
/* @__PURE__ */ jsxDEV4("span", {
|
|
1334
|
+
className: "absolute-voice-platform-coverage__eyebrow",
|
|
1335
|
+
children: model.title
|
|
1336
|
+
}, undefined, false, undefined, this),
|
|
1337
|
+
/* @__PURE__ */ jsxDEV4("strong", {
|
|
1338
|
+
className: "absolute-voice-platform-coverage__label",
|
|
1339
|
+
children: model.label
|
|
1340
|
+
}, undefined, false, undefined, this)
|
|
1341
|
+
]
|
|
1342
|
+
}, undefined, true, undefined, this),
|
|
1343
|
+
/* @__PURE__ */ jsxDEV4("p", {
|
|
1344
|
+
className: "absolute-voice-platform-coverage__description",
|
|
1345
|
+
children: model.description
|
|
1346
|
+
}, undefined, false, undefined, this),
|
|
1347
|
+
model.surfaces.length ? /* @__PURE__ */ jsxDEV4("div", {
|
|
1348
|
+
className: "absolute-voice-platform-coverage__surfaces",
|
|
1349
|
+
children: model.surfaces.map((surface) => /* @__PURE__ */ jsxDEV4("article", {
|
|
1350
|
+
className: [
|
|
1351
|
+
"absolute-voice-platform-coverage__surface",
|
|
1352
|
+
`absolute-voice-platform-coverage__surface--${surface.status}`
|
|
1353
|
+
].join(" "),
|
|
1354
|
+
children: [
|
|
1355
|
+
/* @__PURE__ */ jsxDEV4("header", {
|
|
1356
|
+
children: [
|
|
1357
|
+
/* @__PURE__ */ jsxDEV4("strong", {
|
|
1358
|
+
children: surface.label
|
|
1359
|
+
}, undefined, false, undefined, this),
|
|
1360
|
+
/* @__PURE__ */ jsxDEV4("span", {
|
|
1361
|
+
children: surface.status
|
|
1362
|
+
}, undefined, false, undefined, this)
|
|
1363
|
+
]
|
|
1364
|
+
}, undefined, true, undefined, this),
|
|
1365
|
+
/* @__PURE__ */ jsxDEV4("p", {
|
|
1366
|
+
children: surface.detail
|
|
1367
|
+
}, undefined, false, undefined, this),
|
|
1368
|
+
/* @__PURE__ */ jsxDEV4("small", {
|
|
1369
|
+
children: [
|
|
1370
|
+
surface.evidence.filter((item) => item.ok).length,
|
|
1371
|
+
"/",
|
|
1372
|
+
surface.evidence.length,
|
|
1373
|
+
" evidence checks passing"
|
|
1374
|
+
]
|
|
1375
|
+
}, undefined, true, undefined, this)
|
|
1376
|
+
]
|
|
1377
|
+
}, surface.surface, true, undefined, this))
|
|
1378
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV4("p", {
|
|
1379
|
+
className: "absolute-voice-platform-coverage__empty",
|
|
1380
|
+
children: model.error ?? "Run the proof pack to populate platform coverage evidence."
|
|
1381
|
+
}, undefined, false, undefined, this),
|
|
1382
|
+
model.links.length ? /* @__PURE__ */ jsxDEV4("p", {
|
|
1383
|
+
className: "absolute-voice-platform-coverage__links",
|
|
1384
|
+
children: model.links.map((link) => /* @__PURE__ */ jsxDEV4("a", {
|
|
1385
|
+
href: link.href,
|
|
1386
|
+
children: link.label
|
|
1387
|
+
}, link.href, false, undefined, this))
|
|
1388
|
+
}, undefined, false, undefined, this) : null,
|
|
1389
|
+
model.error ? /* @__PURE__ */ jsxDEV4("p", {
|
|
1390
|
+
className: "absolute-voice-platform-coverage__error",
|
|
1391
|
+
children: model.error
|
|
1392
|
+
}, undefined, false, undefined, this) : null
|
|
1393
|
+
]
|
|
1394
|
+
}, undefined, true, undefined, this);
|
|
1395
|
+
};
|
|
1396
|
+
// src/client/providerSimulationControls.ts
|
|
1397
|
+
var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
|
|
1398
|
+
const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
|
|
1399
|
+
const body = await response.json().catch(() => null);
|
|
1400
|
+
if (!response.ok) {
|
|
1401
|
+
const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice provider simulation failed: HTTP ${response.status}`;
|
|
1402
|
+
throw new Error(message);
|
|
1403
|
+
}
|
|
1404
|
+
return body;
|
|
1405
|
+
};
|
|
1406
|
+
var createVoiceProviderSimulationControlsStore = (options) => {
|
|
1407
|
+
const listeners = new Set;
|
|
1408
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1409
|
+
const pathPrefix = options.pathPrefix ?? `/api/${options.kind ?? "stt"}-simulate`;
|
|
1410
|
+
let closed = false;
|
|
1411
|
+
let snapshot = {
|
|
1412
|
+
error: null,
|
|
1413
|
+
isRunning: false,
|
|
1414
|
+
lastResult: null,
|
|
1415
|
+
mode: null,
|
|
1416
|
+
provider: null
|
|
1417
|
+
};
|
|
1418
|
+
const emit = () => {
|
|
1419
|
+
for (const listener of listeners) {
|
|
1420
|
+
listener();
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
const run = async (provider, mode) => {
|
|
1424
|
+
if (closed) {
|
|
1425
|
+
return snapshot.lastResult;
|
|
1426
|
+
}
|
|
1427
|
+
snapshot = {
|
|
1428
|
+
...snapshot,
|
|
1429
|
+
error: null,
|
|
1430
|
+
isRunning: true,
|
|
1431
|
+
mode,
|
|
1432
|
+
provider
|
|
1433
|
+
};
|
|
1434
|
+
emit();
|
|
1435
|
+
try {
|
|
1436
|
+
const result = await postSimulation(pathPrefix, mode, provider, fetchImpl);
|
|
1437
|
+
snapshot = {
|
|
1438
|
+
error: null,
|
|
1439
|
+
isRunning: false,
|
|
1440
|
+
lastResult: result,
|
|
1441
|
+
mode,
|
|
1442
|
+
provider,
|
|
1443
|
+
updatedAt: Date.now()
|
|
1444
|
+
};
|
|
1445
|
+
emit();
|
|
1446
|
+
return result;
|
|
1447
|
+
} catch (error) {
|
|
1448
|
+
snapshot = {
|
|
1449
|
+
...snapshot,
|
|
1450
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1451
|
+
isRunning: false
|
|
1452
|
+
};
|
|
1453
|
+
emit();
|
|
1454
|
+
throw error;
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
const close = () => {
|
|
1458
|
+
closed = true;
|
|
1459
|
+
listeners.clear();
|
|
1460
|
+
};
|
|
1461
|
+
return {
|
|
1462
|
+
close,
|
|
1463
|
+
getServerSnapshot: () => snapshot,
|
|
1464
|
+
getSnapshot: () => snapshot,
|
|
1465
|
+
run,
|
|
1466
|
+
subscribe: (listener) => {
|
|
1467
|
+
listeners.add(listener);
|
|
1468
|
+
return () => {
|
|
1469
|
+
listeners.delete(listener);
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1475
|
+
// src/client/providerSimulationControlsWidget.ts
|
|
1476
|
+
var escapeHtml5 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1477
|
+
var formatKind = (kind) => (kind ?? "stt").toUpperCase();
|
|
1478
|
+
var createVoiceProviderSimulationControlsViewModel = (snapshot, options) => {
|
|
1479
|
+
const configuredProviders = options.providers.filter((provider) => provider.configured !== false);
|
|
1480
|
+
const fallbackReady = !options.fallbackRequiredProvider || configuredProviders.some((entry) => entry.provider === options.fallbackRequiredProvider);
|
|
1481
|
+
const failureProviders = (options.failureProviders ? options.failureProviders.map((provider) => ({ provider })) : configuredProviders).filter((provider) => configuredProviders.some((entry) => entry.provider === provider.provider));
|
|
1482
|
+
return {
|
|
1483
|
+
canSimulateFailure: configuredProviders.length > 0 && fallbackReady,
|
|
1484
|
+
description: options.failureMessage ?? `Simulate ${formatKind(options.kind)} provider failure and recovery without changing credentials.`,
|
|
1485
|
+
error: snapshot.error,
|
|
1486
|
+
failureProviders,
|
|
1487
|
+
isRunning: snapshot.isRunning,
|
|
1488
|
+
label: snapshot.isRunning ? `Running ${snapshot.mode ?? "simulation"}` : snapshot.lastResult ? `${snapshot.lastResult.provider} ${snapshot.lastResult.mode} simulated` : configuredProviders.length ? `${configuredProviders.length} configured` : "No configured providers",
|
|
1489
|
+
providers: configuredProviders,
|
|
1490
|
+
resultText: snapshot.lastResult ? JSON.stringify(snapshot.lastResult, null, 2) : null,
|
|
1491
|
+
title: options.title ?? `${formatKind(options.kind)} Failure Simulation`
|
|
1492
|
+
};
|
|
1493
|
+
};
|
|
1494
|
+
var renderVoiceProviderSimulationControlsHTML = (snapshot, options) => {
|
|
1495
|
+
const model = createVoiceProviderSimulationControlsViewModel(snapshot, options);
|
|
1496
|
+
const failureButtons = model.failureProviders.map((provider) => `<button type="button" data-voice-provider-fail="${escapeHtml5(provider.provider)}"${!model.canSimulateFailure || snapshot.isRunning ? " disabled" : ""}>Simulate ${escapeHtml5(provider.provider)} ${escapeHtml5(formatKind(options.kind))} failure</button>`).join("");
|
|
1497
|
+
const recoveryButtons = model.providers.map((provider) => `<button type="button" data-voice-provider-recover="${escapeHtml5(provider.provider)}"${snapshot.isRunning ? " disabled" : ""}>Mark ${escapeHtml5(provider.provider)} recovered</button>`).join("");
|
|
1498
|
+
return `<section class="absolute-voice-provider-simulation absolute-voice-provider-simulation--${snapshot.error ? "error" : snapshot.isRunning ? "running" : "ready"}">
|
|
1499
|
+
<header class="absolute-voice-provider-simulation__header">
|
|
1500
|
+
<span class="absolute-voice-provider-simulation__eyebrow">${escapeHtml5(model.title)}</span>
|
|
1501
|
+
<strong class="absolute-voice-provider-simulation__label">${escapeHtml5(model.label)}</strong>
|
|
1502
|
+
</header>
|
|
1503
|
+
<p class="absolute-voice-provider-simulation__description">${escapeHtml5(model.description)}</p>
|
|
1504
|
+
${model.canSimulateFailure ? "" : `<p class="absolute-voice-provider-simulation__empty">${escapeHtml5(options.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure.")}</p>`}
|
|
1505
|
+
<div class="absolute-voice-provider-simulation__actions">${failureButtons}${recoveryButtons}</div>
|
|
1506
|
+
${snapshot.error ? `<p class="absolute-voice-provider-simulation__error">${escapeHtml5(snapshot.error)}</p>` : ""}
|
|
1507
|
+
${model.resultText ? `<pre class="absolute-voice-provider-simulation__result">${escapeHtml5(model.resultText)}</pre>` : ""}
|
|
1508
|
+
</section>`;
|
|
1509
|
+
};
|
|
1510
|
+
var bindVoiceProviderSimulationControls = (element, store) => {
|
|
1511
|
+
const onClick = (event) => {
|
|
1512
|
+
const target = event.target;
|
|
1513
|
+
if (!(target instanceof HTMLElement)) {
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
const failProvider = target.getAttribute("data-voice-provider-fail");
|
|
1517
|
+
const recoverProvider = target.getAttribute("data-voice-provider-recover");
|
|
1518
|
+
if (failProvider) {
|
|
1519
|
+
store.run(failProvider, "failure").catch(() => {});
|
|
1520
|
+
}
|
|
1521
|
+
if (recoverProvider) {
|
|
1522
|
+
store.run(recoverProvider, "recovery").catch(() => {});
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
element.addEventListener("click", onClick);
|
|
1526
|
+
return () => element.removeEventListener("click", onClick);
|
|
1527
|
+
};
|
|
1528
|
+
var mountVoiceProviderSimulationControls = (element, options) => {
|
|
1529
|
+
const store = createVoiceProviderSimulationControlsStore(options);
|
|
1530
|
+
const render = () => {
|
|
1531
|
+
element.innerHTML = renderVoiceProviderSimulationControlsHTML(store.getSnapshot(), options);
|
|
1532
|
+
};
|
|
1533
|
+
const unsubscribeStore = store.subscribe(render);
|
|
1534
|
+
const unsubscribeDom = bindVoiceProviderSimulationControls(element, store);
|
|
1535
|
+
render();
|
|
1536
|
+
return {
|
|
1537
|
+
close: () => {
|
|
1538
|
+
unsubscribeDom();
|
|
1539
|
+
unsubscribeStore();
|
|
1540
|
+
store.close();
|
|
1541
|
+
},
|
|
1542
|
+
run: store.run
|
|
1543
|
+
};
|
|
1544
|
+
};
|
|
1545
|
+
var defineVoiceProviderSimulationControlsElement = (tagName = "absolute-voice-provider-simulation") => {
|
|
1546
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
customElements.define(tagName, class AbsoluteVoiceProviderSimulationElement extends HTMLElement {
|
|
1550
|
+
mounted;
|
|
1551
|
+
connectedCallback() {
|
|
1552
|
+
const providers = (this.getAttribute("providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean).map((provider) => ({ provider }));
|
|
1553
|
+
const failureProviders = (this.getAttribute("failure-providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean);
|
|
1554
|
+
this.mounted = mountVoiceProviderSimulationControls(this, {
|
|
1555
|
+
failureProviders: failureProviders.length ? failureProviders : undefined,
|
|
1556
|
+
fallbackRequiredMessage: this.getAttribute("fallback-required-message") ?? undefined,
|
|
1557
|
+
fallbackRequiredProvider: this.getAttribute("fallback-required-provider") ?? undefined,
|
|
1558
|
+
failureMessage: this.getAttribute("failure-message") ?? undefined,
|
|
1559
|
+
kind: this.getAttribute("kind") ?? "stt",
|
|
1560
|
+
pathPrefix: this.getAttribute("path-prefix") ?? undefined,
|
|
1561
|
+
providers,
|
|
1562
|
+
title: this.getAttribute("title") ?? undefined
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1565
|
+
disconnectedCallback() {
|
|
1566
|
+
this.mounted?.close();
|
|
1567
|
+
this.mounted = undefined;
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
};
|
|
1571
|
+
|
|
1572
|
+
// src/react/useVoiceProviderSimulationControls.tsx
|
|
1573
|
+
import { useEffect as useEffect5, useRef as useRef5, useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
1574
|
+
var useVoiceProviderSimulationControls = (options) => {
|
|
1575
|
+
const storeRef = useRef5(null);
|
|
1576
|
+
if (!storeRef.current) {
|
|
1577
|
+
storeRef.current = createVoiceProviderSimulationControlsStore(options);
|
|
1578
|
+
}
|
|
1579
|
+
const store = storeRef.current;
|
|
1580
|
+
useEffect5(() => () => store.close(), [store]);
|
|
1581
|
+
return {
|
|
1582
|
+
...useSyncExternalStore5(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
1583
|
+
run: store.run
|
|
1584
|
+
};
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
// src/react/VoiceProviderSimulationControls.tsx
|
|
1588
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
1589
|
+
var VoiceProviderSimulationControls = ({
|
|
1590
|
+
className,
|
|
1591
|
+
...options
|
|
1592
|
+
}) => {
|
|
1593
|
+
const snapshot = useVoiceProviderSimulationControls(options);
|
|
1594
|
+
const model = createVoiceProviderSimulationControlsViewModel(snapshot, options);
|
|
1595
|
+
const run = (provider, mode) => {
|
|
1596
|
+
snapshot.run(provider, mode).catch(() => {});
|
|
1597
|
+
};
|
|
1598
|
+
return /* @__PURE__ */ jsxDEV5("section", {
|
|
1599
|
+
className: [
|
|
1600
|
+
"absolute-voice-provider-simulation",
|
|
1601
|
+
`absolute-voice-provider-simulation--${snapshot.error ? "error" : snapshot.isRunning ? "running" : "ready"}`,
|
|
1602
|
+
className
|
|
1603
|
+
].filter(Boolean).join(" "),
|
|
1604
|
+
children: [
|
|
1605
|
+
/* @__PURE__ */ jsxDEV5("header", {
|
|
1606
|
+
className: "absolute-voice-provider-simulation__header",
|
|
1607
|
+
children: [
|
|
1608
|
+
/* @__PURE__ */ jsxDEV5("span", {
|
|
1609
|
+
className: "absolute-voice-provider-simulation__eyebrow",
|
|
1610
|
+
children: model.title
|
|
1611
|
+
}, undefined, false, undefined, this),
|
|
1612
|
+
/* @__PURE__ */ jsxDEV5("strong", {
|
|
1613
|
+
className: "absolute-voice-provider-simulation__label",
|
|
1614
|
+
children: model.label
|
|
1615
|
+
}, undefined, false, undefined, this)
|
|
1616
|
+
]
|
|
1617
|
+
}, undefined, true, undefined, this),
|
|
1618
|
+
/* @__PURE__ */ jsxDEV5("p", {
|
|
1619
|
+
className: "absolute-voice-provider-simulation__description",
|
|
1620
|
+
children: model.description
|
|
1621
|
+
}, undefined, false, undefined, this),
|
|
1622
|
+
model.canSimulateFailure ? null : /* @__PURE__ */ jsxDEV5("p", {
|
|
1623
|
+
className: "absolute-voice-provider-simulation__empty",
|
|
1624
|
+
children: options.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure."
|
|
1625
|
+
}, undefined, false, undefined, this),
|
|
1626
|
+
/* @__PURE__ */ jsxDEV5("div", {
|
|
1627
|
+
className: "absolute-voice-provider-simulation__actions",
|
|
1628
|
+
children: [
|
|
1629
|
+
model.failureProviders.map((provider) => /* @__PURE__ */ jsxDEV5("button", {
|
|
1630
|
+
disabled: !model.canSimulateFailure || snapshot.isRunning,
|
|
1631
|
+
onClick: () => run(provider.provider, "failure"),
|
|
1632
|
+
type: "button",
|
|
1633
|
+
children: [
|
|
1634
|
+
"Simulate ",
|
|
1635
|
+
provider.provider,
|
|
1636
|
+
" ",
|
|
1637
|
+
(options.kind ?? "stt").toUpperCase(),
|
|
1638
|
+
" ",
|
|
1639
|
+
"failure"
|
|
1640
|
+
]
|
|
1641
|
+
}, `fail-${provider.provider}`, true, undefined, this)),
|
|
1642
|
+
model.providers.map((provider) => /* @__PURE__ */ jsxDEV5("button", {
|
|
1643
|
+
disabled: snapshot.isRunning,
|
|
1644
|
+
onClick: () => run(provider.provider, "recovery"),
|
|
1645
|
+
type: "button",
|
|
1646
|
+
children: [
|
|
1647
|
+
"Mark ",
|
|
1648
|
+
provider.provider,
|
|
1649
|
+
" recovered"
|
|
1650
|
+
]
|
|
1651
|
+
}, `recover-${provider.provider}`, true, undefined, this))
|
|
1652
|
+
]
|
|
1653
|
+
}, undefined, true, undefined, this),
|
|
1654
|
+
snapshot.error ? /* @__PURE__ */ jsxDEV5("p", {
|
|
1655
|
+
className: "absolute-voice-provider-simulation__error",
|
|
1656
|
+
children: snapshot.error
|
|
1657
|
+
}, undefined, false, undefined, this) : null,
|
|
1658
|
+
model.resultText ? /* @__PURE__ */ jsxDEV5("pre", {
|
|
1659
|
+
className: "absolute-voice-provider-simulation__result",
|
|
1660
|
+
children: model.resultText
|
|
1661
|
+
}, undefined, false, undefined, this) : null
|
|
1662
|
+
]
|
|
1663
|
+
}, undefined, true, undefined, this);
|
|
1664
|
+
};
|
|
1665
|
+
// src/react/useVoiceProviderCapabilities.tsx
|
|
1666
|
+
import { useEffect as useEffect6, useRef as useRef6, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
1667
|
+
|
|
1668
|
+
// src/client/providerCapabilities.ts
|
|
1669
|
+
var fetchVoiceProviderCapabilities = async (path = "/api/provider-capabilities", options = {}) => {
|
|
1670
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1671
|
+
const response = await fetchImpl(path);
|
|
1672
|
+
if (!response.ok) {
|
|
1673
|
+
throw new Error(`Voice provider capabilities failed: HTTP ${response.status}`);
|
|
1674
|
+
}
|
|
1675
|
+
return await response.json();
|
|
1676
|
+
};
|
|
1677
|
+
var createVoiceProviderCapabilitiesStore = (path = "/api/provider-capabilities", options = {}) => {
|
|
1678
|
+
const listeners = new Set;
|
|
1679
|
+
let closed = false;
|
|
1680
|
+
let timer;
|
|
1681
|
+
let snapshot = {
|
|
1682
|
+
error: null,
|
|
1683
|
+
isLoading: false
|
|
1684
|
+
};
|
|
1685
|
+
const emit = () => {
|
|
1686
|
+
for (const listener of listeners) {
|
|
1687
|
+
listener();
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
const refresh = async () => {
|
|
1691
|
+
if (closed) {
|
|
1692
|
+
return snapshot.report;
|
|
1693
|
+
}
|
|
1694
|
+
snapshot = {
|
|
1695
|
+
...snapshot,
|
|
1696
|
+
error: null,
|
|
1697
|
+
isLoading: true
|
|
1698
|
+
};
|
|
1699
|
+
emit();
|
|
1700
|
+
try {
|
|
1701
|
+
const report = await fetchVoiceProviderCapabilities(path, options);
|
|
1702
|
+
snapshot = {
|
|
1703
|
+
error: null,
|
|
1704
|
+
isLoading: false,
|
|
1705
|
+
report,
|
|
1706
|
+
updatedAt: Date.now()
|
|
1707
|
+
};
|
|
1708
|
+
emit();
|
|
1709
|
+
return report;
|
|
1710
|
+
} catch (error) {
|
|
1711
|
+
snapshot = {
|
|
1712
|
+
...snapshot,
|
|
1713
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1714
|
+
isLoading: false
|
|
1715
|
+
};
|
|
1716
|
+
emit();
|
|
1717
|
+
throw error;
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
const close = () => {
|
|
1721
|
+
closed = true;
|
|
1722
|
+
if (timer) {
|
|
1723
|
+
clearInterval(timer);
|
|
1724
|
+
timer = undefined;
|
|
1725
|
+
}
|
|
1726
|
+
listeners.clear();
|
|
1727
|
+
};
|
|
1728
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
1729
|
+
timer = setInterval(() => {
|
|
1730
|
+
refresh().catch(() => {});
|
|
1731
|
+
}, options.intervalMs);
|
|
1732
|
+
}
|
|
1733
|
+
return {
|
|
1734
|
+
close,
|
|
1735
|
+
getServerSnapshot: () => snapshot,
|
|
1736
|
+
getSnapshot: () => snapshot,
|
|
1737
|
+
refresh,
|
|
1738
|
+
subscribe: (listener) => {
|
|
1739
|
+
listeners.add(listener);
|
|
1740
|
+
return () => {
|
|
1741
|
+
listeners.delete(listener);
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
// src/react/useVoiceProviderCapabilities.tsx
|
|
1748
|
+
var useVoiceProviderCapabilities = (path = "/api/provider-capabilities", options = {}) => {
|
|
1749
|
+
const storeRef = useRef6(null);
|
|
1750
|
+
if (!storeRef.current) {
|
|
1751
|
+
storeRef.current = createVoiceProviderCapabilitiesStore(path, options);
|
|
1752
|
+
}
|
|
1753
|
+
const store = storeRef.current;
|
|
1754
|
+
useEffect6(() => {
|
|
1755
|
+
store.refresh().catch(() => {});
|
|
1756
|
+
return () => store.close();
|
|
1757
|
+
}, [store]);
|
|
1758
|
+
return {
|
|
1759
|
+
...useSyncExternalStore6(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
1760
|
+
refresh: store.refresh
|
|
1761
|
+
};
|
|
1762
|
+
};
|
|
1763
|
+
|
|
1764
|
+
// src/client/providerCapabilitiesWidget.ts
|
|
1765
|
+
var DEFAULT_TITLE5 = "Provider Capabilities";
|
|
1766
|
+
var DEFAULT_DESCRIPTION5 = "Configured, selected, and healthy voice providers for this deployment.";
|
|
1767
|
+
var escapeHtml6 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1768
|
+
var formatProvider = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
1769
|
+
var formatKind2 = (kind) => kind.toUpperCase();
|
|
1770
|
+
var formatStatus2 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
1771
|
+
var getCapabilityDetail = (capability) => {
|
|
1772
|
+
if (!capability.configured) {
|
|
1773
|
+
return "Not configured in this deployment.";
|
|
1774
|
+
}
|
|
1775
|
+
if (capability.selected) {
|
|
1776
|
+
return `Selected ${capability.kind.toUpperCase()} provider for new sessions.`;
|
|
1777
|
+
}
|
|
1778
|
+
if (capability.health?.status === "healthy") {
|
|
1779
|
+
return "Configured and healthy fallback candidate.";
|
|
1780
|
+
}
|
|
1781
|
+
if (capability.health?.status === "idle") {
|
|
1782
|
+
return "Configured; no traffic observed yet.";
|
|
1783
|
+
}
|
|
1784
|
+
if (capability.health?.lastError) {
|
|
1785
|
+
return capability.health.lastError;
|
|
1786
|
+
}
|
|
1787
|
+
return "Configured and available.";
|
|
1788
|
+
};
|
|
1789
|
+
var isWarningStatus = (status) => status === "degraded" || status === "rate-limited" || status === "suppressed" || status === "unconfigured";
|
|
1790
|
+
var createVoiceProviderCapabilitiesViewModel = (snapshot, options = {}) => {
|
|
1791
|
+
const capabilities = (snapshot.report?.capabilities ?? []).map((capability) => ({
|
|
1792
|
+
...capability,
|
|
1793
|
+
detail: getCapabilityDetail(capability),
|
|
1794
|
+
label: `${formatProvider(capability.provider)} ${formatKind2(capability.kind)}`,
|
|
1795
|
+
rows: [
|
|
1796
|
+
{ label: "Status", value: formatStatus2(capability.status) },
|
|
1797
|
+
{ label: "Selected", value: capability.selected ? "Yes" : "No" },
|
|
1798
|
+
{ label: "Model", value: capability.model ?? "Default" },
|
|
1799
|
+
{
|
|
1800
|
+
label: "Features",
|
|
1801
|
+
value: capability.features?.join(", ") || "Not specified"
|
|
1802
|
+
},
|
|
1803
|
+
{ label: "Runs", value: String(capability.health?.runCount ?? 0) },
|
|
1804
|
+
{ label: "Errors", value: String(capability.health?.errorCount ?? 0) }
|
|
1805
|
+
]
|
|
1806
|
+
}));
|
|
1807
|
+
const warningCount = capabilities.filter((capability) => isWarningStatus(capability.status)).length;
|
|
1808
|
+
const selectedCount = snapshot.report?.selected ?? capabilities.filter((capability) => capability.selected).length;
|
|
1809
|
+
return {
|
|
1810
|
+
capabilities,
|
|
1811
|
+
description: options.description ?? DEFAULT_DESCRIPTION5,
|
|
1812
|
+
error: snapshot.error,
|
|
1813
|
+
isLoading: snapshot.isLoading,
|
|
1814
|
+
label: snapshot.error ? "Unavailable" : capabilities.length ? warningCount > 0 ? `${warningCount} needs attention` : `${selectedCount} selected` : snapshot.isLoading ? "Checking" : "No capabilities",
|
|
1815
|
+
status: snapshot.error ? "error" : capabilities.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
1816
|
+
title: options.title ?? DEFAULT_TITLE5,
|
|
1817
|
+
updatedAt: snapshot.updatedAt
|
|
1818
|
+
};
|
|
1819
|
+
};
|
|
1820
|
+
var renderVoiceProviderCapabilitiesHTML = (snapshot, options = {}) => {
|
|
1821
|
+
const model = createVoiceProviderCapabilitiesViewModel(snapshot, options);
|
|
1822
|
+
const capabilities = model.capabilities.length ? `<div class="absolute-voice-provider-capabilities__providers">${model.capabilities.map((capability) => `<article class="absolute-voice-provider-capabilities__provider absolute-voice-provider-capabilities__provider--${escapeHtml6(capability.status)}">
|
|
1823
|
+
<header>
|
|
1824
|
+
<strong>${escapeHtml6(capability.label)}</strong>
|
|
1825
|
+
<span>${escapeHtml6(formatStatus2(capability.status))}</span>
|
|
1826
|
+
</header>
|
|
1827
|
+
<p>${escapeHtml6(capability.detail)}</p>
|
|
1828
|
+
<dl>${capability.rows.map((row) => `<div>
|
|
1829
|
+
<dt>${escapeHtml6(row.label)}</dt>
|
|
1830
|
+
<dd>${escapeHtml6(row.value)}</dd>
|
|
1831
|
+
</div>`).join("")}</dl>
|
|
1832
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-capabilities__empty">Configure provider capabilities to see deployment coverage.</p>';
|
|
1833
|
+
return `<section class="absolute-voice-provider-capabilities absolute-voice-provider-capabilities--${escapeHtml6(model.status)}">
|
|
1834
|
+
<header class="absolute-voice-provider-capabilities__header">
|
|
1835
|
+
<span class="absolute-voice-provider-capabilities__eyebrow">${escapeHtml6(model.title)}</span>
|
|
1836
|
+
<strong class="absolute-voice-provider-capabilities__label">${escapeHtml6(model.label)}</strong>
|
|
1837
|
+
</header>
|
|
1838
|
+
<p class="absolute-voice-provider-capabilities__description">${escapeHtml6(model.description)}</p>
|
|
1839
|
+
${capabilities}
|
|
1840
|
+
${model.error ? `<p class="absolute-voice-provider-capabilities__error">${escapeHtml6(model.error)}</p>` : ""}
|
|
1841
|
+
</section>`;
|
|
1842
|
+
};
|
|
1843
|
+
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}`;
|
|
1844
|
+
var mountVoiceProviderCapabilities = (element, path = "/api/provider-capabilities", options = {}) => {
|
|
1845
|
+
const store = createVoiceProviderCapabilitiesStore(path, options);
|
|
1846
|
+
const render = () => {
|
|
1847
|
+
element.innerHTML = renderVoiceProviderCapabilitiesHTML(store.getSnapshot(), options);
|
|
1848
|
+
};
|
|
1849
|
+
const unsubscribe = store.subscribe(render);
|
|
1850
|
+
render();
|
|
1851
|
+
store.refresh().catch(() => {});
|
|
1852
|
+
return {
|
|
1853
|
+
close: () => {
|
|
1854
|
+
unsubscribe();
|
|
1855
|
+
store.close();
|
|
1856
|
+
},
|
|
1857
|
+
refresh: store.refresh
|
|
1858
|
+
};
|
|
1859
|
+
};
|
|
1860
|
+
var defineVoiceProviderCapabilitiesElement = (tagName = "absolute-voice-provider-capabilities") => {
|
|
1861
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1862
|
+
return;
|
|
1863
|
+
}
|
|
1864
|
+
customElements.define(tagName, class AbsoluteVoiceProviderCapabilitiesElement extends HTMLElement {
|
|
1865
|
+
mounted;
|
|
1866
|
+
connectedCallback() {
|
|
1867
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
1868
|
+
this.mounted = mountVoiceProviderCapabilities(this, this.getAttribute("path") ?? "/api/provider-capabilities", {
|
|
1869
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1870
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
1871
|
+
title: this.getAttribute("title") ?? undefined
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
disconnectedCallback() {
|
|
1875
|
+
this.mounted?.close();
|
|
1876
|
+
this.mounted = undefined;
|
|
1877
|
+
}
|
|
1878
|
+
});
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
// src/react/VoiceProviderCapabilities.tsx
|
|
1882
|
+
import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
|
|
1883
|
+
var VoiceProviderCapabilities = ({
|
|
1884
|
+
className,
|
|
1885
|
+
path = "/api/provider-capabilities",
|
|
1886
|
+
...options
|
|
1887
|
+
}) => {
|
|
1888
|
+
const snapshot = useVoiceProviderCapabilities(path, options);
|
|
1889
|
+
const model = createVoiceProviderCapabilitiesViewModel(snapshot, options);
|
|
1890
|
+
return /* @__PURE__ */ jsxDEV6("section", {
|
|
1891
|
+
className: [
|
|
1892
|
+
"absolute-voice-provider-capabilities",
|
|
1893
|
+
`absolute-voice-provider-capabilities--${model.status}`,
|
|
1894
|
+
className
|
|
1895
|
+
].filter(Boolean).join(" "),
|
|
1896
|
+
children: [
|
|
1897
|
+
/* @__PURE__ */ jsxDEV6("header", {
|
|
1898
|
+
className: "absolute-voice-provider-capabilities__header",
|
|
1899
|
+
children: [
|
|
1900
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
1901
|
+
className: "absolute-voice-provider-capabilities__eyebrow",
|
|
1902
|
+
children: model.title
|
|
1903
|
+
}, undefined, false, undefined, this),
|
|
1904
|
+
/* @__PURE__ */ jsxDEV6("strong", {
|
|
1905
|
+
className: "absolute-voice-provider-capabilities__label",
|
|
1906
|
+
children: model.label
|
|
1907
|
+
}, undefined, false, undefined, this)
|
|
1908
|
+
]
|
|
1909
|
+
}, undefined, true, undefined, this),
|
|
1910
|
+
/* @__PURE__ */ jsxDEV6("p", {
|
|
1911
|
+
className: "absolute-voice-provider-capabilities__description",
|
|
1912
|
+
children: model.description
|
|
1913
|
+
}, undefined, false, undefined, this),
|
|
1914
|
+
model.capabilities.length ? /* @__PURE__ */ jsxDEV6("div", {
|
|
1915
|
+
className: "absolute-voice-provider-capabilities__providers",
|
|
1916
|
+
children: model.capabilities.map((capability) => /* @__PURE__ */ jsxDEV6("article", {
|
|
1917
|
+
className: [
|
|
1918
|
+
"absolute-voice-provider-capabilities__provider",
|
|
1919
|
+
`absolute-voice-provider-capabilities__provider--${capability.status}`
|
|
1920
|
+
].join(" "),
|
|
1921
|
+
children: [
|
|
1922
|
+
/* @__PURE__ */ jsxDEV6("header", {
|
|
1923
|
+
children: [
|
|
1924
|
+
/* @__PURE__ */ jsxDEV6("strong", {
|
|
1925
|
+
children: capability.label
|
|
1926
|
+
}, undefined, false, undefined, this),
|
|
1927
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
1928
|
+
children: capability.status
|
|
1929
|
+
}, undefined, false, undefined, this)
|
|
1930
|
+
]
|
|
1931
|
+
}, undefined, true, undefined, this),
|
|
1932
|
+
/* @__PURE__ */ jsxDEV6("p", {
|
|
1933
|
+
children: capability.detail
|
|
1934
|
+
}, undefined, false, undefined, this),
|
|
1935
|
+
/* @__PURE__ */ jsxDEV6("dl", {
|
|
1936
|
+
children: capability.rows.map((row) => /* @__PURE__ */ jsxDEV6("div", {
|
|
1937
|
+
children: [
|
|
1938
|
+
/* @__PURE__ */ jsxDEV6("dt", {
|
|
1939
|
+
children: row.label
|
|
1940
|
+
}, undefined, false, undefined, this),
|
|
1941
|
+
/* @__PURE__ */ jsxDEV6("dd", {
|
|
1942
|
+
children: row.value
|
|
1943
|
+
}, undefined, false, undefined, this)
|
|
1944
|
+
]
|
|
1945
|
+
}, row.label, true, undefined, this))
|
|
1946
|
+
}, undefined, false, undefined, this)
|
|
1947
|
+
]
|
|
1948
|
+
}, `${capability.kind}:${capability.provider}`, true, undefined, this))
|
|
1949
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV6("p", {
|
|
1950
|
+
className: "absolute-voice-provider-capabilities__empty",
|
|
1951
|
+
children: "Configure provider capabilities to see deployment coverage."
|
|
1952
|
+
}, undefined, false, undefined, this),
|
|
1953
|
+
model.error ? /* @__PURE__ */ jsxDEV6("p", {
|
|
1954
|
+
className: "absolute-voice-provider-capabilities__error",
|
|
1955
|
+
children: model.error
|
|
1956
|
+
}, undefined, false, undefined, this) : null
|
|
1957
|
+
]
|
|
1958
|
+
}, undefined, true, undefined, this);
|
|
1959
|
+
};
|
|
1960
|
+
// src/react/useVoiceProviderContracts.tsx
|
|
1961
|
+
import { useEffect as useEffect7, useRef as useRef7, useSyncExternalStore as useSyncExternalStore7 } from "react";
|
|
1962
|
+
|
|
1963
|
+
// src/client/providerContracts.ts
|
|
1964
|
+
var fetchVoiceProviderContracts = async (path = "/api/provider-contracts", options = {}) => {
|
|
1965
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1966
|
+
const response = await fetchImpl(path);
|
|
1967
|
+
if (!response.ok) {
|
|
1968
|
+
throw new Error(`Voice provider contracts failed: HTTP ${response.status}`);
|
|
1969
|
+
}
|
|
1970
|
+
return await response.json();
|
|
1971
|
+
};
|
|
1972
|
+
var createVoiceProviderContractsStore = (path = "/api/provider-contracts", options = {}) => {
|
|
1973
|
+
const listeners = new Set;
|
|
1974
|
+
let closed = false;
|
|
1975
|
+
let timer;
|
|
1976
|
+
let snapshot = {
|
|
1977
|
+
error: null,
|
|
1978
|
+
isLoading: false
|
|
1979
|
+
};
|
|
1980
|
+
const emit = () => {
|
|
1981
|
+
for (const listener of listeners) {
|
|
1982
|
+
listener();
|
|
1983
|
+
}
|
|
1984
|
+
};
|
|
1985
|
+
const refresh = async () => {
|
|
1986
|
+
if (closed) {
|
|
1987
|
+
return snapshot.report;
|
|
1988
|
+
}
|
|
1989
|
+
snapshot = { ...snapshot, error: null, isLoading: true };
|
|
1990
|
+
emit();
|
|
1991
|
+
try {
|
|
1992
|
+
const report = await fetchVoiceProviderContracts(path, options);
|
|
1993
|
+
snapshot = {
|
|
1994
|
+
error: null,
|
|
1995
|
+
isLoading: false,
|
|
1996
|
+
report,
|
|
1997
|
+
updatedAt: Date.now()
|
|
1998
|
+
};
|
|
1999
|
+
emit();
|
|
2000
|
+
return report;
|
|
2001
|
+
} catch (error) {
|
|
2002
|
+
snapshot = {
|
|
2003
|
+
...snapshot,
|
|
2004
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2005
|
+
isLoading: false
|
|
2006
|
+
};
|
|
2007
|
+
emit();
|
|
2008
|
+
throw error;
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
const close = () => {
|
|
2012
|
+
closed = true;
|
|
2013
|
+
if (timer) {
|
|
2014
|
+
clearInterval(timer);
|
|
2015
|
+
timer = undefined;
|
|
2016
|
+
}
|
|
2017
|
+
listeners.clear();
|
|
2018
|
+
};
|
|
2019
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2020
|
+
timer = setInterval(() => {
|
|
2021
|
+
refresh().catch(() => {});
|
|
2022
|
+
}, options.intervalMs);
|
|
2023
|
+
}
|
|
2024
|
+
return {
|
|
2025
|
+
close,
|
|
2026
|
+
getServerSnapshot: () => snapshot,
|
|
2027
|
+
getSnapshot: () => snapshot,
|
|
2028
|
+
refresh,
|
|
2029
|
+
subscribe: (listener) => {
|
|
2030
|
+
listeners.add(listener);
|
|
2031
|
+
return () => {
|
|
2032
|
+
listeners.delete(listener);
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
};
|
|
2036
|
+
};
|
|
2037
|
+
|
|
2038
|
+
// src/react/useVoiceProviderContracts.tsx
|
|
2039
|
+
var useVoiceProviderContracts = (path = "/api/provider-contracts", options = {}) => {
|
|
2040
|
+
const storeRef = useRef7(null);
|
|
2041
|
+
if (!storeRef.current) {
|
|
2042
|
+
storeRef.current = createVoiceProviderContractsStore(path, options);
|
|
2043
|
+
}
|
|
2044
|
+
const store = storeRef.current;
|
|
2045
|
+
useEffect7(() => {
|
|
2046
|
+
store.refresh().catch(() => {});
|
|
2047
|
+
return () => store.close();
|
|
2048
|
+
}, [store]);
|
|
2049
|
+
return {
|
|
2050
|
+
...useSyncExternalStore7(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
2051
|
+
refresh: store.refresh
|
|
2052
|
+
};
|
|
2053
|
+
};
|
|
2054
|
+
|
|
2055
|
+
// src/client/providerContractsWidget.ts
|
|
2056
|
+
var DEFAULT_TITLE6 = "Provider Contracts";
|
|
2057
|
+
var DEFAULT_DESCRIPTION6 = "Production contract coverage for provider env, latency, fallback, streaming, and capabilities.";
|
|
2058
|
+
var escapeHtml7 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2059
|
+
var formatProvider2 = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
2060
|
+
var formatStatus3 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
2061
|
+
var contractDetail = (row) => {
|
|
2062
|
+
const failing = row.checks.filter((check) => check.status !== "pass");
|
|
2063
|
+
if (failing.length === 0) {
|
|
2064
|
+
return "Provider contract is production-ready.";
|
|
2065
|
+
}
|
|
2066
|
+
return failing.map((check) => `${check.label}: ${check.detail ?? check.status}`).join(" ");
|
|
2067
|
+
};
|
|
2068
|
+
var createVoiceProviderContractsViewModel = (snapshot, options = {}) => {
|
|
2069
|
+
const rows = (snapshot.report?.rows ?? []).map((row) => ({
|
|
2070
|
+
...row,
|
|
2071
|
+
detail: contractDetail(row),
|
|
2072
|
+
label: `${formatProvider2(row.provider)} ${row.kind.toUpperCase()}`,
|
|
2073
|
+
remediations: row.checks.filter((check) => check.status !== "pass" && check.remediation).map((check) => ({
|
|
2074
|
+
detail: check.remediation?.detail ?? "",
|
|
2075
|
+
href: check.remediation?.href,
|
|
2076
|
+
label: check.remediation?.label ?? check.label
|
|
2077
|
+
})),
|
|
2078
|
+
rows: [
|
|
2079
|
+
{ label: "Status", value: formatStatus3(row.status) },
|
|
2080
|
+
{ label: "Selected", value: row.selected ? "Yes" : "No" },
|
|
2081
|
+
{ label: "Configured", value: row.configured ? "Yes" : "No" },
|
|
2082
|
+
{
|
|
2083
|
+
label: "Checks",
|
|
2084
|
+
value: row.checks.map((check) => `${check.label}: ${formatStatus3(check.status)}`).join(", ")
|
|
2085
|
+
}
|
|
2086
|
+
]
|
|
2087
|
+
}));
|
|
2088
|
+
const warningCount = snapshot.report ? snapshot.report.failed + snapshot.report.warned : rows.filter((row) => row.status !== "pass").length;
|
|
2089
|
+
return {
|
|
2090
|
+
description: options.description ?? DEFAULT_DESCRIPTION6,
|
|
2091
|
+
error: snapshot.error,
|
|
2092
|
+
isLoading: snapshot.isLoading,
|
|
2093
|
+
label: snapshot.error ? "Unavailable" : rows.length ? warningCount > 0 ? `${warningCount} needs attention` : `${rows.length} passing` : snapshot.isLoading ? "Checking" : "No contracts",
|
|
2094
|
+
rows,
|
|
2095
|
+
status: snapshot.error ? "error" : rows.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2096
|
+
title: options.title ?? DEFAULT_TITLE6,
|
|
2097
|
+
updatedAt: snapshot.updatedAt
|
|
2098
|
+
};
|
|
2099
|
+
};
|
|
2100
|
+
var renderVoiceProviderContractsHTML = (snapshot, options = {}) => {
|
|
2101
|
+
const model = createVoiceProviderContractsViewModel(snapshot, options);
|
|
2102
|
+
const rows = model.rows.length ? `<div class="absolute-voice-provider-contracts__rows">${model.rows.map((row) => `<article class="absolute-voice-provider-contracts__row absolute-voice-provider-contracts__row--${escapeHtml7(row.status)}">
|
|
2103
|
+
<header>
|
|
2104
|
+
<strong>${escapeHtml7(row.label)}</strong>
|
|
2105
|
+
<span>${escapeHtml7(formatStatus3(row.status))}</span>
|
|
2106
|
+
</header>
|
|
2107
|
+
<p>${escapeHtml7(row.detail)}</p>
|
|
2108
|
+
${row.remediations.length ? `<ul class="absolute-voice-provider-contracts__remediations">${row.remediations.map((remediation) => `<li>${remediation.href ? `<a href="${escapeHtml7(remediation.href)}">${escapeHtml7(remediation.label)}</a>` : `<strong>${escapeHtml7(remediation.label)}</strong>`}<span>${escapeHtml7(remediation.detail)}</span></li>`).join("")}</ul>` : ""}
|
|
2109
|
+
<dl>${row.rows.map((item) => `<div>
|
|
2110
|
+
<dt>${escapeHtml7(item.label)}</dt>
|
|
2111
|
+
<dd>${escapeHtml7(item.value)}</dd>
|
|
2112
|
+
</div>`).join("")}</dl>
|
|
2113
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-contracts__empty">Configure provider contracts to see production coverage.</p>';
|
|
2114
|
+
return `<section class="absolute-voice-provider-contracts absolute-voice-provider-contracts--${escapeHtml7(model.status)}">
|
|
2115
|
+
<header class="absolute-voice-provider-contracts__header">
|
|
2116
|
+
<span class="absolute-voice-provider-contracts__eyebrow">${escapeHtml7(model.title)}</span>
|
|
2117
|
+
<strong class="absolute-voice-provider-contracts__label">${escapeHtml7(model.label)}</strong>
|
|
2118
|
+
</header>
|
|
2119
|
+
<p class="absolute-voice-provider-contracts__description">${escapeHtml7(model.description)}</p>
|
|
2120
|
+
${rows}
|
|
2121
|
+
${model.error ? `<p class="absolute-voice-provider-contracts__error">${escapeHtml7(model.error)}</p>` : ""}
|
|
2122
|
+
</section>`;
|
|
2123
|
+
};
|
|
2124
|
+
var getVoiceProviderContractsCSS = () => `.absolute-voice-provider-contracts{border:1px solid #b8dcc7;border-radius:20px;background:#f7fff9;color:#09140d;padding:18px;box-shadow:0 18px 40px rgba(21,83,45,.12);font-family:inherit}.absolute-voice-provider-contracts--error,.absolute-voice-provider-contracts--warning{border-color:#f2a7a7;background:#fff7f4}.absolute-voice-provider-contracts__header,.absolute-voice-provider-contracts__row header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-provider-contracts__eyebrow{color:#166534;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-provider-contracts__label{font-size:24px;line-height:1}.absolute-voice-provider-contracts__description,.absolute-voice-provider-contracts__row p,.absolute-voice-provider-contracts__row dt,.absolute-voice-provider-contracts__empty{color:#405448}.absolute-voice-provider-contracts__rows{display:grid;gap:12px;margin-top:14px}.absolute-voice-provider-contracts__row{background:#fff;border:1px solid #d6eadb;border-radius:16px;padding:14px}.absolute-voice-provider-contracts__row--pass{border-color:#86efac}.absolute-voice-provider-contracts__row--warn,.absolute-voice-provider-contracts__row--fail{border-color:#f2a7a7}.absolute-voice-provider-contracts__row p{margin:10px 0}.absolute-voice-provider-contracts__remediations{display:grid;gap:8px;list-style:none;margin:0 0 10px;padding:0}.absolute-voice-provider-contracts__remediations li{background:#fff7ed;border:1px solid #fed7aa;border-radius:12px;display:grid;gap:3px;padding:8px}.absolute-voice-provider-contracts__remediations a,.absolute-voice-provider-contracts__remediations strong{color:#9a3412}.absolute-voice-provider-contracts__remediations span{color:#7c2d12}.absolute-voice-provider-contracts__row dl{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr));margin:0}.absolute-voice-provider-contracts__row div{background:#f7fff9;border:1px solid #d6eadb;border-radius:12px;padding:8px}.absolute-voice-provider-contracts__row dt{font-size:12px}.absolute-voice-provider-contracts__row dd{font-weight:800;margin:4px 0 0}.absolute-voice-provider-contracts__error{color:#9f1239;font-weight:700}`;
|
|
2125
|
+
var mountVoiceProviderContracts = (element, path = "/api/provider-contracts", options = {}) => {
|
|
2126
|
+
const store = createVoiceProviderContractsStore(path, options);
|
|
2127
|
+
const render = () => {
|
|
2128
|
+
element.innerHTML = renderVoiceProviderContractsHTML(store.getSnapshot(), options);
|
|
2129
|
+
};
|
|
2130
|
+
const unsubscribe = store.subscribe(render);
|
|
2131
|
+
render();
|
|
2132
|
+
store.refresh().catch(() => {});
|
|
2133
|
+
return {
|
|
2134
|
+
close: () => {
|
|
2135
|
+
unsubscribe();
|
|
2136
|
+
store.close();
|
|
2137
|
+
},
|
|
2138
|
+
refresh: store.refresh
|
|
2139
|
+
};
|
|
2140
|
+
};
|
|
2141
|
+
var defineVoiceProviderContractsElement = (tagName = "absolute-voice-provider-contracts") => {
|
|
2142
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
customElements.define(tagName, class AbsoluteVoiceProviderContractsElement extends HTMLElement {
|
|
2146
|
+
mounted;
|
|
2147
|
+
connectedCallback() {
|
|
2148
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2149
|
+
this.mounted = mountVoiceProviderContracts(this, this.getAttribute("path") ?? "/api/provider-contracts", {
|
|
2150
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2151
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2152
|
+
title: this.getAttribute("title") ?? undefined
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
disconnectedCallback() {
|
|
2156
|
+
this.mounted?.close();
|
|
2157
|
+
this.mounted = undefined;
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
};
|
|
2161
|
+
|
|
2162
|
+
// src/react/VoiceProviderContracts.tsx
|
|
2163
|
+
import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
|
|
2164
|
+
var VoiceProviderContracts = ({
|
|
2165
|
+
className,
|
|
2166
|
+
path = "/api/provider-contracts",
|
|
2167
|
+
...options
|
|
2168
|
+
}) => {
|
|
2169
|
+
const snapshot = useVoiceProviderContracts(path, options);
|
|
2170
|
+
const model = createVoiceProviderContractsViewModel(snapshot, options);
|
|
2171
|
+
return /* @__PURE__ */ jsxDEV7("section", {
|
|
2172
|
+
className: [
|
|
2173
|
+
"absolute-voice-provider-contracts",
|
|
2174
|
+
`absolute-voice-provider-contracts--${model.status}`,
|
|
2175
|
+
className
|
|
2176
|
+
].filter(Boolean).join(" "),
|
|
2177
|
+
children: [
|
|
2178
|
+
/* @__PURE__ */ jsxDEV7("header", {
|
|
2179
|
+
className: "absolute-voice-provider-contracts__header",
|
|
2180
|
+
children: [
|
|
2181
|
+
/* @__PURE__ */ jsxDEV7("span", {
|
|
2182
|
+
className: "absolute-voice-provider-contracts__eyebrow",
|
|
2183
|
+
children: model.title
|
|
2184
|
+
}, undefined, false, undefined, this),
|
|
2185
|
+
/* @__PURE__ */ jsxDEV7("strong", {
|
|
2186
|
+
className: "absolute-voice-provider-contracts__label",
|
|
2187
|
+
children: model.label
|
|
2188
|
+
}, undefined, false, undefined, this)
|
|
2189
|
+
]
|
|
2190
|
+
}, undefined, true, undefined, this),
|
|
2191
|
+
/* @__PURE__ */ jsxDEV7("p", {
|
|
2192
|
+
className: "absolute-voice-provider-contracts__description",
|
|
2193
|
+
children: model.description
|
|
2194
|
+
}, undefined, false, undefined, this),
|
|
2195
|
+
model.rows.length ? /* @__PURE__ */ jsxDEV7("div", {
|
|
2196
|
+
className: "absolute-voice-provider-contracts__rows",
|
|
2197
|
+
children: model.rows.map((row) => /* @__PURE__ */ jsxDEV7("article", {
|
|
2198
|
+
className: [
|
|
2199
|
+
"absolute-voice-provider-contracts__row",
|
|
2200
|
+
`absolute-voice-provider-contracts__row--${row.status}`
|
|
2201
|
+
].join(" "),
|
|
2202
|
+
children: [
|
|
2203
|
+
/* @__PURE__ */ jsxDEV7("header", {
|
|
2204
|
+
children: [
|
|
2205
|
+
/* @__PURE__ */ jsxDEV7("strong", {
|
|
2206
|
+
children: row.label
|
|
2207
|
+
}, undefined, false, undefined, this),
|
|
2208
|
+
/* @__PURE__ */ jsxDEV7("span", {
|
|
2209
|
+
children: row.status
|
|
2210
|
+
}, undefined, false, undefined, this)
|
|
2211
|
+
]
|
|
2212
|
+
}, undefined, true, undefined, this),
|
|
2213
|
+
/* @__PURE__ */ jsxDEV7("p", {
|
|
2214
|
+
children: row.detail
|
|
2215
|
+
}, undefined, false, undefined, this),
|
|
2216
|
+
row.remediations.length ? /* @__PURE__ */ jsxDEV7("ul", {
|
|
2217
|
+
className: "absolute-voice-provider-contracts__remediations",
|
|
2218
|
+
children: row.remediations.map((remediation) => /* @__PURE__ */ jsxDEV7("li", {
|
|
2219
|
+
children: [
|
|
2220
|
+
remediation.href ? /* @__PURE__ */ jsxDEV7("a", {
|
|
2221
|
+
href: remediation.href,
|
|
2222
|
+
children: remediation.label
|
|
2223
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV7("strong", {
|
|
2224
|
+
children: remediation.label
|
|
2225
|
+
}, undefined, false, undefined, this),
|
|
2226
|
+
/* @__PURE__ */ jsxDEV7("span", {
|
|
2227
|
+
children: remediation.detail
|
|
2228
|
+
}, undefined, false, undefined, this)
|
|
2229
|
+
]
|
|
2230
|
+
}, `${row.kind}:${row.provider}:${remediation.label}`, true, undefined, this))
|
|
2231
|
+
}, undefined, false, undefined, this) : null,
|
|
2232
|
+
/* @__PURE__ */ jsxDEV7("dl", {
|
|
2233
|
+
children: row.rows.map((item) => /* @__PURE__ */ jsxDEV7("div", {
|
|
2234
|
+
children: [
|
|
2235
|
+
/* @__PURE__ */ jsxDEV7("dt", {
|
|
2236
|
+
children: item.label
|
|
2237
|
+
}, undefined, false, undefined, this),
|
|
2238
|
+
/* @__PURE__ */ jsxDEV7("dd", {
|
|
2239
|
+
children: item.value
|
|
2240
|
+
}, undefined, false, undefined, this)
|
|
2241
|
+
]
|
|
2242
|
+
}, item.label, true, undefined, this))
|
|
2243
|
+
}, undefined, false, undefined, this)
|
|
2244
|
+
]
|
|
2245
|
+
}, `${row.kind}:${row.provider}`, true, undefined, this))
|
|
2246
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV7("p", {
|
|
2247
|
+
className: "absolute-voice-provider-contracts__empty",
|
|
2248
|
+
children: "Configure provider contracts to see production coverage."
|
|
2249
|
+
}, undefined, false, undefined, this),
|
|
2250
|
+
model.error ? /* @__PURE__ */ jsxDEV7("p", {
|
|
2251
|
+
className: "absolute-voice-provider-contracts__error",
|
|
2252
|
+
children: model.error
|
|
2253
|
+
}, undefined, false, undefined, this) : null
|
|
2254
|
+
]
|
|
2255
|
+
}, undefined, true, undefined, this);
|
|
2256
|
+
};
|
|
2257
|
+
// src/react/useVoiceProviderStatus.tsx
|
|
2258
|
+
import { useEffect as useEffect8, useRef as useRef8, useSyncExternalStore as useSyncExternalStore8 } from "react";
|
|
2259
|
+
|
|
2260
|
+
// src/client/providerStatus.ts
|
|
2261
|
+
var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
|
|
2262
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2263
|
+
const response = await fetchImpl(path);
|
|
2264
|
+
if (!response.ok) {
|
|
2265
|
+
throw new Error(`Voice provider status failed: HTTP ${response.status}`);
|
|
2266
|
+
}
|
|
2267
|
+
return await response.json();
|
|
2268
|
+
};
|
|
2269
|
+
var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
|
|
2270
|
+
const listeners = new Set;
|
|
2271
|
+
let closed = false;
|
|
2272
|
+
let timer;
|
|
2273
|
+
let snapshot = {
|
|
2274
|
+
error: null,
|
|
2275
|
+
isLoading: false,
|
|
2276
|
+
providers: []
|
|
2277
|
+
};
|
|
2278
|
+
const emit = () => {
|
|
2279
|
+
for (const listener of listeners) {
|
|
2280
|
+
listener();
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2283
|
+
const refresh = async () => {
|
|
2284
|
+
if (closed) {
|
|
2285
|
+
return snapshot.providers;
|
|
2286
|
+
}
|
|
2287
|
+
snapshot = {
|
|
2288
|
+
...snapshot,
|
|
2289
|
+
error: null,
|
|
2290
|
+
isLoading: true
|
|
2291
|
+
};
|
|
2292
|
+
emit();
|
|
2293
|
+
try {
|
|
2294
|
+
const providers = await fetchVoiceProviderStatus(path, options);
|
|
2295
|
+
snapshot = {
|
|
2296
|
+
error: null,
|
|
2297
|
+
isLoading: false,
|
|
2298
|
+
providers,
|
|
2299
|
+
updatedAt: Date.now()
|
|
2300
|
+
};
|
|
2301
|
+
emit();
|
|
2302
|
+
return providers;
|
|
2303
|
+
} catch (error) {
|
|
2304
|
+
snapshot = {
|
|
2305
|
+
...snapshot,
|
|
2306
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2307
|
+
isLoading: false
|
|
2308
|
+
};
|
|
2309
|
+
emit();
|
|
2310
|
+
throw error;
|
|
2311
|
+
}
|
|
2312
|
+
};
|
|
2313
|
+
const close = () => {
|
|
2314
|
+
closed = true;
|
|
2315
|
+
if (timer) {
|
|
2316
|
+
clearInterval(timer);
|
|
2317
|
+
timer = undefined;
|
|
2318
|
+
}
|
|
2319
|
+
listeners.clear();
|
|
2320
|
+
};
|
|
2321
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2322
|
+
timer = setInterval(() => {
|
|
2323
|
+
refresh().catch(() => {});
|
|
2324
|
+
}, options.intervalMs);
|
|
2325
|
+
}
|
|
2326
|
+
return {
|
|
2327
|
+
close,
|
|
2328
|
+
getServerSnapshot: () => snapshot,
|
|
2329
|
+
getSnapshot: () => snapshot,
|
|
2330
|
+
refresh,
|
|
2331
|
+
subscribe: (listener) => {
|
|
2332
|
+
listeners.add(listener);
|
|
2333
|
+
return () => {
|
|
2334
|
+
listeners.delete(listener);
|
|
2335
|
+
};
|
|
2336
|
+
}
|
|
2337
|
+
};
|
|
2338
|
+
};
|
|
2339
|
+
|
|
2340
|
+
// src/react/useVoiceProviderStatus.tsx
|
|
2341
|
+
var useVoiceProviderStatus = (path = "/api/provider-status", options = {}) => {
|
|
2342
|
+
const storeRef = useRef8(null);
|
|
2343
|
+
if (!storeRef.current) {
|
|
2344
|
+
storeRef.current = createVoiceProviderStatusStore(path, options);
|
|
2345
|
+
}
|
|
2346
|
+
const store = storeRef.current;
|
|
2347
|
+
useEffect8(() => {
|
|
2348
|
+
store.refresh().catch(() => {});
|
|
2349
|
+
return () => store.close();
|
|
2350
|
+
}, [store]);
|
|
2351
|
+
return {
|
|
2352
|
+
...useSyncExternalStore8(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
2353
|
+
refresh: store.refresh
|
|
2354
|
+
};
|
|
2355
|
+
};
|
|
2356
|
+
|
|
2357
|
+
// src/client/providerStatusWidget.ts
|
|
2358
|
+
var DEFAULT_TITLE7 = "Voice Providers";
|
|
2359
|
+
var DEFAULT_DESCRIPTION7 = "Live provider health, fallback counts, latency, and suppression state from your self-hosted trace store.";
|
|
2360
|
+
var escapeHtml8 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2361
|
+
var formatProvider3 = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
2362
|
+
var formatStatus4 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
2363
|
+
var formatLatency = (value) => typeof value === "number" ? `${value}ms` : "No samples";
|
|
2364
|
+
var formatSuppression = (value) => typeof value === "number" ? `${Math.ceil(value / 1000)}s` : "None";
|
|
2365
|
+
var getProviderDetail = (provider) => {
|
|
2366
|
+
if (provider.status === "suppressed") {
|
|
2367
|
+
return provider.lastError ? `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)} after ${provider.lastError}.` : `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)}.`;
|
|
2368
|
+
}
|
|
2369
|
+
if (provider.status === "recoverable") {
|
|
2370
|
+
return "Cooldown expired; ready for recovery traffic.";
|
|
2371
|
+
}
|
|
2372
|
+
if (provider.status === "rate-limited") {
|
|
2373
|
+
return "Rate limit detected; router should avoid this provider.";
|
|
2374
|
+
}
|
|
2375
|
+
if (provider.status === "degraded") {
|
|
2376
|
+
return provider.lastError ?? "Recent provider errors detected.";
|
|
2377
|
+
}
|
|
2378
|
+
if (provider.status === "healthy") {
|
|
2379
|
+
return provider.recommended ? "Healthy and currently recommended." : "Healthy and available for routing.";
|
|
2380
|
+
}
|
|
2381
|
+
return "No provider traffic observed yet.";
|
|
2382
|
+
};
|
|
2383
|
+
var isWarningStatus2 = (status) => status === "degraded" || status === "rate-limited" || status === "recoverable" || status === "suppressed";
|
|
2384
|
+
var createVoiceProviderStatusViewModel = (snapshot, options = {}) => {
|
|
2385
|
+
const providers = snapshot.providers.map((provider) => ({
|
|
2386
|
+
...provider,
|
|
2387
|
+
detail: getProviderDetail(provider),
|
|
2388
|
+
label: `${formatProvider3(provider.provider)}${provider.recommended ? " recommended" : ""}`,
|
|
2389
|
+
rows: [
|
|
2390
|
+
{ label: "Runs", value: String(provider.runCount) },
|
|
2391
|
+
{ label: "Avg latency", value: formatLatency(provider.averageElapsedMs) },
|
|
2392
|
+
{ label: "Errors", value: String(provider.errorCount) },
|
|
2393
|
+
{ label: "Timeouts", value: String(provider.timeoutCount) },
|
|
2394
|
+
{ label: "Fallbacks", value: String(provider.fallbackCount) },
|
|
2395
|
+
{
|
|
2396
|
+
label: "Suppression",
|
|
2397
|
+
value: formatSuppression(provider.suppressionRemainingMs)
|
|
2398
|
+
}
|
|
2399
|
+
]
|
|
2400
|
+
}));
|
|
2401
|
+
const warningCount = providers.filter((provider) => isWarningStatus2(provider.status)).length;
|
|
2402
|
+
const healthyCount = providers.filter((provider) => provider.status === "healthy").length;
|
|
2403
|
+
return {
|
|
2404
|
+
description: options.description ?? DEFAULT_DESCRIPTION7,
|
|
2405
|
+
error: snapshot.error,
|
|
2406
|
+
isLoading: snapshot.isLoading,
|
|
2407
|
+
label: snapshot.error ? "Unavailable" : providers.length ? warningCount > 0 ? `${warningCount} needs attention` : `${healthyCount} healthy` : snapshot.isLoading ? "Checking" : "No provider traffic",
|
|
2408
|
+
providers,
|
|
2409
|
+
status: snapshot.error ? "error" : providers.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2410
|
+
title: options.title ?? DEFAULT_TITLE7,
|
|
2411
|
+
updatedAt: snapshot.updatedAt
|
|
2412
|
+
};
|
|
2413
|
+
};
|
|
2414
|
+
var renderVoiceProviderStatusHTML = (snapshot, options = {}) => {
|
|
2415
|
+
const model = createVoiceProviderStatusViewModel(snapshot, options);
|
|
2416
|
+
const providers = model.providers.length ? `<div class="absolute-voice-provider-status__providers">${model.providers.map((provider) => `<article class="absolute-voice-provider-status__provider absolute-voice-provider-status__provider--${escapeHtml8(provider.status)}">
|
|
2417
|
+
<header>
|
|
2418
|
+
<strong>${escapeHtml8(provider.label)}</strong>
|
|
2419
|
+
<span>${escapeHtml8(formatStatus4(provider.status))}</span>
|
|
2420
|
+
</header>
|
|
2421
|
+
<p>${escapeHtml8(provider.detail)}</p>
|
|
2422
|
+
<dl>${provider.rows.map((row) => `<div>
|
|
2423
|
+
<dt>${escapeHtml8(row.label)}</dt>
|
|
2424
|
+
<dd>${escapeHtml8(row.value)}</dd>
|
|
2425
|
+
</div>`).join("")}</dl>
|
|
2426
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-status__empty">Run voice traffic to see provider health.</p>';
|
|
2427
|
+
return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${escapeHtml8(model.status)}">
|
|
2428
|
+
<header class="absolute-voice-provider-status__header">
|
|
2429
|
+
<span class="absolute-voice-provider-status__eyebrow">${escapeHtml8(model.title)}</span>
|
|
2430
|
+
<strong class="absolute-voice-provider-status__label">${escapeHtml8(model.label)}</strong>
|
|
2431
|
+
</header>
|
|
2432
|
+
<p class="absolute-voice-provider-status__description">${escapeHtml8(model.description)}</p>
|
|
2433
|
+
${providers}
|
|
2434
|
+
${model.error ? `<p class="absolute-voice-provider-status__error">${escapeHtml8(model.error)}</p>` : ""}
|
|
2435
|
+
</section>`;
|
|
2436
|
+
};
|
|
2437
|
+
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}`;
|
|
2438
|
+
var mountVoiceProviderStatus = (element, path = "/api/provider-status", options = {}) => {
|
|
2439
|
+
const store = createVoiceProviderStatusStore(path, options);
|
|
2440
|
+
const render = () => {
|
|
2441
|
+
element.innerHTML = renderVoiceProviderStatusHTML(store.getSnapshot(), options);
|
|
2442
|
+
};
|
|
2443
|
+
const unsubscribe = store.subscribe(render);
|
|
2444
|
+
render();
|
|
2445
|
+
store.refresh().catch(() => {});
|
|
2446
|
+
return {
|
|
2447
|
+
close: () => {
|
|
2448
|
+
unsubscribe();
|
|
2449
|
+
store.close();
|
|
2450
|
+
},
|
|
2451
|
+
refresh: store.refresh
|
|
2452
|
+
};
|
|
2453
|
+
};
|
|
2454
|
+
var defineVoiceProviderStatusElement = (tagName = "absolute-voice-provider-status") => {
|
|
2455
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2456
|
+
return;
|
|
2457
|
+
}
|
|
2458
|
+
customElements.define(tagName, class AbsoluteVoiceProviderStatusElement extends HTMLElement {
|
|
2459
|
+
mounted;
|
|
2460
|
+
connectedCallback() {
|
|
2461
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2462
|
+
this.mounted = mountVoiceProviderStatus(this, this.getAttribute("path") ?? "/api/provider-status", {
|
|
2463
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2464
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2465
|
+
title: this.getAttribute("title") ?? undefined
|
|
2466
|
+
});
|
|
2467
|
+
}
|
|
2468
|
+
disconnectedCallback() {
|
|
2469
|
+
this.mounted?.close();
|
|
2470
|
+
this.mounted = undefined;
|
|
2471
|
+
}
|
|
2472
|
+
});
|
|
2473
|
+
};
|
|
2474
|
+
|
|
2475
|
+
// src/react/VoiceProviderStatus.tsx
|
|
2476
|
+
import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
|
|
2477
|
+
var VoiceProviderStatus = ({
|
|
2478
|
+
className,
|
|
2479
|
+
path = "/api/provider-status",
|
|
2480
|
+
...options
|
|
2481
|
+
}) => {
|
|
2482
|
+
const snapshot = useVoiceProviderStatus(path, options);
|
|
2483
|
+
const model = createVoiceProviderStatusViewModel(snapshot, options);
|
|
2484
|
+
return /* @__PURE__ */ jsxDEV8("section", {
|
|
2485
|
+
className: [
|
|
2486
|
+
"absolute-voice-provider-status",
|
|
2487
|
+
`absolute-voice-provider-status--${model.status}`,
|
|
2488
|
+
className
|
|
2489
|
+
].filter(Boolean).join(" "),
|
|
2490
|
+
children: [
|
|
2491
|
+
/* @__PURE__ */ jsxDEV8("header", {
|
|
2492
|
+
className: "absolute-voice-provider-status__header",
|
|
2493
|
+
children: [
|
|
2494
|
+
/* @__PURE__ */ jsxDEV8("span", {
|
|
2495
|
+
className: "absolute-voice-provider-status__eyebrow",
|
|
2496
|
+
children: model.title
|
|
2497
|
+
}, undefined, false, undefined, this),
|
|
2498
|
+
/* @__PURE__ */ jsxDEV8("strong", {
|
|
2499
|
+
className: "absolute-voice-provider-status__label",
|
|
2500
|
+
children: model.label
|
|
2501
|
+
}, undefined, false, undefined, this)
|
|
2502
|
+
]
|
|
2503
|
+
}, undefined, true, undefined, this),
|
|
2504
|
+
/* @__PURE__ */ jsxDEV8("p", {
|
|
2505
|
+
className: "absolute-voice-provider-status__description",
|
|
2506
|
+
children: model.description
|
|
2507
|
+
}, undefined, false, undefined, this),
|
|
2508
|
+
model.providers.length ? /* @__PURE__ */ jsxDEV8("div", {
|
|
2509
|
+
className: "absolute-voice-provider-status__providers",
|
|
2510
|
+
children: model.providers.map((provider) => /* @__PURE__ */ jsxDEV8("article", {
|
|
2511
|
+
className: [
|
|
2512
|
+
"absolute-voice-provider-status__provider",
|
|
2513
|
+
`absolute-voice-provider-status__provider--${provider.status}`
|
|
2514
|
+
].join(" "),
|
|
2515
|
+
children: [
|
|
2516
|
+
/* @__PURE__ */ jsxDEV8("header", {
|
|
2517
|
+
children: [
|
|
2518
|
+
/* @__PURE__ */ jsxDEV8("strong", {
|
|
2519
|
+
children: provider.label
|
|
2520
|
+
}, undefined, false, undefined, this),
|
|
2521
|
+
/* @__PURE__ */ jsxDEV8("span", {
|
|
2522
|
+
children: provider.status
|
|
2523
|
+
}, undefined, false, undefined, this)
|
|
2524
|
+
]
|
|
2525
|
+
}, undefined, true, undefined, this),
|
|
2526
|
+
/* @__PURE__ */ jsxDEV8("p", {
|
|
2527
|
+
children: provider.detail
|
|
2528
|
+
}, undefined, false, undefined, this),
|
|
2529
|
+
/* @__PURE__ */ jsxDEV8("dl", {
|
|
2530
|
+
children: provider.rows.map((row) => /* @__PURE__ */ jsxDEV8("div", {
|
|
2531
|
+
children: [
|
|
2532
|
+
/* @__PURE__ */ jsxDEV8("dt", {
|
|
2533
|
+
children: row.label
|
|
2534
|
+
}, undefined, false, undefined, this),
|
|
2535
|
+
/* @__PURE__ */ jsxDEV8("dd", {
|
|
2536
|
+
children: row.value
|
|
2537
|
+
}, undefined, false, undefined, this)
|
|
2538
|
+
]
|
|
2539
|
+
}, row.label, true, undefined, this))
|
|
2540
|
+
}, undefined, false, undefined, this)
|
|
2541
|
+
]
|
|
2542
|
+
}, provider.provider, true, undefined, this))
|
|
2543
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV8("p", {
|
|
2544
|
+
className: "absolute-voice-provider-status__empty",
|
|
2545
|
+
children: "Run voice traffic to see provider health."
|
|
2546
|
+
}, undefined, false, undefined, this),
|
|
2547
|
+
model.error ? /* @__PURE__ */ jsxDEV8("p", {
|
|
2548
|
+
className: "absolute-voice-provider-status__error",
|
|
2549
|
+
children: model.error
|
|
2550
|
+
}, undefined, false, undefined, this) : null
|
|
2551
|
+
]
|
|
2552
|
+
}, undefined, true, undefined, this);
|
|
2553
|
+
};
|
|
2554
|
+
// src/react/useVoiceRoutingStatus.tsx
|
|
2555
|
+
import { useEffect as useEffect9, useRef as useRef9, useSyncExternalStore as useSyncExternalStore9 } from "react";
|
|
2556
|
+
|
|
2557
|
+
// src/client/routingStatus.ts
|
|
2558
|
+
var fetchVoiceRoutingStatus = async (path = "/api/routing/latest", options = {}) => {
|
|
2559
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2560
|
+
const response = await fetchImpl(path);
|
|
2561
|
+
if (!response.ok) {
|
|
2562
|
+
throw new Error(`Voice routing status failed: HTTP ${response.status}`);
|
|
2563
|
+
}
|
|
2564
|
+
return await response.json();
|
|
2565
|
+
};
|
|
2566
|
+
var createVoiceRoutingStatusStore = (path = "/api/routing/latest", options = {}) => {
|
|
2567
|
+
const listeners = new Set;
|
|
2568
|
+
let closed = false;
|
|
2569
|
+
let timer;
|
|
2570
|
+
let snapshot = {
|
|
2571
|
+
decision: null,
|
|
2572
|
+
error: null,
|
|
2573
|
+
isLoading: false
|
|
2574
|
+
};
|
|
2575
|
+
const emit = () => {
|
|
2576
|
+
for (const listener of listeners) {
|
|
2577
|
+
listener();
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
const refresh = async () => {
|
|
2581
|
+
if (closed) {
|
|
2582
|
+
return snapshot.decision;
|
|
2583
|
+
}
|
|
2584
|
+
snapshot = {
|
|
2585
|
+
...snapshot,
|
|
2586
|
+
error: null,
|
|
2587
|
+
isLoading: true
|
|
2588
|
+
};
|
|
2589
|
+
emit();
|
|
2590
|
+
try {
|
|
2591
|
+
const decision = await fetchVoiceRoutingStatus(path, options);
|
|
2592
|
+
snapshot = {
|
|
2593
|
+
decision,
|
|
2594
|
+
error: null,
|
|
2595
|
+
isLoading: false,
|
|
2596
|
+
updatedAt: Date.now()
|
|
2597
|
+
};
|
|
2598
|
+
emit();
|
|
2599
|
+
return decision;
|
|
2600
|
+
} catch (error) {
|
|
2601
|
+
snapshot = {
|
|
2602
|
+
...snapshot,
|
|
2603
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2604
|
+
isLoading: false
|
|
2605
|
+
};
|
|
2606
|
+
emit();
|
|
2607
|
+
throw error;
|
|
2608
|
+
}
|
|
2609
|
+
};
|
|
2610
|
+
const close = () => {
|
|
2611
|
+
closed = true;
|
|
2612
|
+
if (timer) {
|
|
2613
|
+
clearInterval(timer);
|
|
2614
|
+
timer = undefined;
|
|
2615
|
+
}
|
|
2616
|
+
listeners.clear();
|
|
2617
|
+
};
|
|
2618
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2619
|
+
timer = setInterval(() => {
|
|
2620
|
+
refresh().catch(() => {});
|
|
2621
|
+
}, options.intervalMs);
|
|
2622
|
+
}
|
|
2623
|
+
return {
|
|
2624
|
+
close,
|
|
2625
|
+
getServerSnapshot: () => snapshot,
|
|
2626
|
+
getSnapshot: () => snapshot,
|
|
2627
|
+
refresh,
|
|
2628
|
+
subscribe: (listener) => {
|
|
2629
|
+
listeners.add(listener);
|
|
2630
|
+
return () => {
|
|
2631
|
+
listeners.delete(listener);
|
|
2632
|
+
};
|
|
2633
|
+
}
|
|
2634
|
+
};
|
|
2635
|
+
};
|
|
2636
|
+
|
|
2637
|
+
// src/react/useVoiceRoutingStatus.tsx
|
|
2638
|
+
var useVoiceRoutingStatus = (path = "/api/routing/latest", options = {}) => {
|
|
2639
|
+
const storeRef = useRef9(null);
|
|
2640
|
+
if (!storeRef.current) {
|
|
2641
|
+
storeRef.current = createVoiceRoutingStatusStore(path, options);
|
|
2642
|
+
}
|
|
2643
|
+
const store = storeRef.current;
|
|
2644
|
+
useEffect9(() => {
|
|
2645
|
+
store.refresh().catch(() => {});
|
|
2646
|
+
return () => store.close();
|
|
2647
|
+
}, [store]);
|
|
2648
|
+
return {
|
|
2649
|
+
...useSyncExternalStore9(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
2650
|
+
refresh: store.refresh
|
|
2651
|
+
};
|
|
2652
|
+
};
|
|
2653
|
+
|
|
2654
|
+
// src/client/routingStatusWidget.ts
|
|
2655
|
+
var DEFAULT_TITLE8 = "Voice Routing";
|
|
2656
|
+
var DEFAULT_DESCRIPTION8 = "Latest provider routing decision from the self-hosted trace store.";
|
|
2657
|
+
var escapeHtml9 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2658
|
+
var formatValue = (value, fallback = "None") => typeof value === "string" && value.trim() ? value : typeof value === "number" && Number.isFinite(value) ? String(value) : fallback;
|
|
2659
|
+
var createVoiceRoutingStatusViewModel = (snapshot, options = {}) => {
|
|
2660
|
+
const decision = snapshot.decision;
|
|
2661
|
+
const rows = decision ? [
|
|
2662
|
+
{ label: "Kind", value: decision.kind.toUpperCase() },
|
|
2663
|
+
{ label: "Policy", value: formatValue(decision.routing, "Unknown") },
|
|
2664
|
+
{ label: "Provider", value: formatValue(decision.provider, "Unknown") },
|
|
2665
|
+
{
|
|
2666
|
+
label: "Selected",
|
|
2667
|
+
value: formatValue(decision.selectedProvider, "Unknown")
|
|
2668
|
+
},
|
|
2669
|
+
{
|
|
2670
|
+
label: "Fallback",
|
|
2671
|
+
value: formatValue(decision.fallbackProvider)
|
|
2672
|
+
},
|
|
2673
|
+
{ label: "Status", value: formatValue(decision.status, "unknown") },
|
|
2674
|
+
{
|
|
2675
|
+
label: "Latency budget",
|
|
2676
|
+
value: typeof decision.latencyBudgetMs === "number" ? `${decision.latencyBudgetMs}ms` : "None"
|
|
2677
|
+
}
|
|
2678
|
+
] : [];
|
|
2679
|
+
return {
|
|
2680
|
+
decision,
|
|
2681
|
+
description: options.description ?? DEFAULT_DESCRIPTION8,
|
|
2682
|
+
error: snapshot.error,
|
|
2683
|
+
isLoading: snapshot.isLoading,
|
|
2684
|
+
label: snapshot.error ? "Unavailable" : decision ? `${formatValue(decision.kind).toUpperCase()} ${formatValue(decision.status, "unknown")}` : snapshot.isLoading ? "Checking" : "No routing yet",
|
|
2685
|
+
rows,
|
|
2686
|
+
status: snapshot.error ? "error" : decision ? "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2687
|
+
title: options.title ?? DEFAULT_TITLE8,
|
|
2688
|
+
updatedAt: snapshot.updatedAt
|
|
2689
|
+
};
|
|
2690
|
+
};
|
|
2691
|
+
var renderVoiceRoutingStatusHTML = (snapshot, options = {}) => {
|
|
2692
|
+
const model = createVoiceRoutingStatusViewModel(snapshot, options);
|
|
2693
|
+
const rows = model.rows.length ? `<div class="absolute-voice-routing-status__grid">${model.rows.map((row) => `<div>
|
|
2694
|
+
<span>${escapeHtml9(row.label)}</span>
|
|
2695
|
+
<strong>${escapeHtml9(row.value)}</strong>
|
|
2696
|
+
</div>`).join("")}</div>` : '<p class="absolute-voice-routing-status__empty">Start a voice session to see the selected provider.</p>';
|
|
2697
|
+
return `<section class="absolute-voice-routing-status absolute-voice-routing-status--${escapeHtml9(model.status)}">
|
|
2698
|
+
<header class="absolute-voice-routing-status__header">
|
|
2699
|
+
<span class="absolute-voice-routing-status__eyebrow">${escapeHtml9(model.title)}</span>
|
|
2700
|
+
<strong class="absolute-voice-routing-status__label">${escapeHtml9(model.label)}</strong>
|
|
2701
|
+
</header>
|
|
2702
|
+
<p class="absolute-voice-routing-status__description">${escapeHtml9(model.description)}</p>
|
|
2703
|
+
${rows}
|
|
2704
|
+
${model.error ? `<p class="absolute-voice-routing-status__error">${escapeHtml9(model.error)}</p>` : ""}
|
|
2705
|
+
</section>`;
|
|
2706
|
+
};
|
|
2707
|
+
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}`;
|
|
2708
|
+
var mountVoiceRoutingStatus = (element, path = "/api/routing/latest", options = {}) => {
|
|
2709
|
+
const store = createVoiceRoutingStatusStore(path, options);
|
|
2710
|
+
const render = () => {
|
|
2711
|
+
element.innerHTML = renderVoiceRoutingStatusHTML(store.getSnapshot(), options);
|
|
2712
|
+
};
|
|
2713
|
+
const unsubscribe = store.subscribe(render);
|
|
2714
|
+
render();
|
|
2715
|
+
store.refresh().catch(() => {});
|
|
2716
|
+
return {
|
|
2717
|
+
close: () => {
|
|
2718
|
+
unsubscribe();
|
|
2719
|
+
store.close();
|
|
2720
|
+
},
|
|
2721
|
+
refresh: store.refresh
|
|
2722
|
+
};
|
|
2723
|
+
};
|
|
2724
|
+
var defineVoiceRoutingStatusElement = (tagName = "absolute-voice-routing-status") => {
|
|
2725
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
customElements.define(tagName, class AbsoluteVoiceRoutingStatusElement extends HTMLElement {
|
|
2729
|
+
mounted;
|
|
2730
|
+
connectedCallback() {
|
|
2731
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2732
|
+
this.mounted = mountVoiceRoutingStatus(this, this.getAttribute("path") ?? "/api/routing/latest", {
|
|
2733
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2734
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2735
|
+
title: this.getAttribute("title") ?? undefined
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
disconnectedCallback() {
|
|
2739
|
+
this.mounted?.close();
|
|
2740
|
+
this.mounted = undefined;
|
|
2741
|
+
}
|
|
2742
|
+
});
|
|
2743
|
+
};
|
|
2744
|
+
|
|
2745
|
+
// src/react/VoiceRoutingStatus.tsx
|
|
2746
|
+
import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
|
|
2747
|
+
var VoiceRoutingStatus = ({
|
|
2748
|
+
className,
|
|
2749
|
+
path = "/api/routing/latest",
|
|
2750
|
+
...options
|
|
2751
|
+
}) => {
|
|
2752
|
+
const snapshot = useVoiceRoutingStatus(path, options);
|
|
2753
|
+
const model = createVoiceRoutingStatusViewModel(snapshot, options);
|
|
2754
|
+
return /* @__PURE__ */ jsxDEV9("section", {
|
|
2755
|
+
className: [
|
|
2756
|
+
"absolute-voice-routing-status",
|
|
2757
|
+
`absolute-voice-routing-status--${model.status}`,
|
|
2758
|
+
className
|
|
2759
|
+
].filter(Boolean).join(" "),
|
|
2760
|
+
children: [
|
|
2761
|
+
/* @__PURE__ */ jsxDEV9("header", {
|
|
2762
|
+
className: "absolute-voice-routing-status__header",
|
|
2763
|
+
children: [
|
|
2764
|
+
/* @__PURE__ */ jsxDEV9("span", {
|
|
2765
|
+
className: "absolute-voice-routing-status__eyebrow",
|
|
2766
|
+
children: model.title
|
|
2767
|
+
}, undefined, false, undefined, this),
|
|
2768
|
+
/* @__PURE__ */ jsxDEV9("strong", {
|
|
2769
|
+
className: "absolute-voice-routing-status__label",
|
|
2770
|
+
children: model.label
|
|
2771
|
+
}, undefined, false, undefined, this)
|
|
2772
|
+
]
|
|
2773
|
+
}, undefined, true, undefined, this),
|
|
2774
|
+
/* @__PURE__ */ jsxDEV9("p", {
|
|
2775
|
+
className: "absolute-voice-routing-status__description",
|
|
2776
|
+
children: model.description
|
|
2777
|
+
}, undefined, false, undefined, this),
|
|
2778
|
+
model.rows.length ? /* @__PURE__ */ jsxDEV9("div", {
|
|
2779
|
+
className: "absolute-voice-routing-status__grid",
|
|
2780
|
+
children: model.rows.map((row) => /* @__PURE__ */ jsxDEV9("div", {
|
|
2781
|
+
children: [
|
|
2782
|
+
/* @__PURE__ */ jsxDEV9("span", {
|
|
2783
|
+
children: row.label
|
|
2784
|
+
}, undefined, false, undefined, this),
|
|
2785
|
+
/* @__PURE__ */ jsxDEV9("strong", {
|
|
2786
|
+
children: row.value
|
|
2787
|
+
}, undefined, false, undefined, this)
|
|
2788
|
+
]
|
|
2789
|
+
}, row.label, true, undefined, this))
|
|
2790
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV9("p", {
|
|
2791
|
+
className: "absolute-voice-routing-status__empty",
|
|
2792
|
+
children: "Start a voice session to see the selected provider."
|
|
2793
|
+
}, undefined, false, undefined, this),
|
|
2794
|
+
model.error ? /* @__PURE__ */ jsxDEV9("p", {
|
|
2795
|
+
className: "absolute-voice-routing-status__error",
|
|
2796
|
+
children: model.error
|
|
2797
|
+
}, undefined, false, undefined, this) : null
|
|
2798
|
+
]
|
|
2799
|
+
}, undefined, true, undefined, this);
|
|
2800
|
+
};
|
|
2801
|
+
// src/client/traceTimeline.ts
|
|
2802
|
+
var fetchVoiceTraceTimeline = async (path = "/api/voice-traces", options = {}) => {
|
|
2803
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2804
|
+
const response = await fetchImpl(path);
|
|
2805
|
+
if (!response.ok) {
|
|
2806
|
+
throw new Error(`Voice trace timeline failed: HTTP ${response.status}`);
|
|
2807
|
+
}
|
|
2808
|
+
return await response.json();
|
|
2809
|
+
};
|
|
2810
|
+
var createVoiceTraceTimelineStore = (path = "/api/voice-traces", options = {}) => {
|
|
2811
|
+
const listeners = new Set;
|
|
2812
|
+
let closed = false;
|
|
2813
|
+
let timer;
|
|
2814
|
+
let snapshot = {
|
|
2815
|
+
error: null,
|
|
2816
|
+
isLoading: false,
|
|
2817
|
+
report: null
|
|
2818
|
+
};
|
|
2819
|
+
const emit = () => {
|
|
2820
|
+
for (const listener of listeners) {
|
|
2821
|
+
listener();
|
|
2822
|
+
}
|
|
2823
|
+
};
|
|
2824
|
+
const refresh = async () => {
|
|
2825
|
+
if (closed) {
|
|
2826
|
+
return snapshot.report;
|
|
2827
|
+
}
|
|
2828
|
+
snapshot = {
|
|
2829
|
+
...snapshot,
|
|
2830
|
+
error: null,
|
|
2831
|
+
isLoading: true
|
|
2832
|
+
};
|
|
2833
|
+
emit();
|
|
2834
|
+
try {
|
|
2835
|
+
const report = await fetchVoiceTraceTimeline(path, options);
|
|
2836
|
+
snapshot = {
|
|
2837
|
+
error: null,
|
|
2838
|
+
isLoading: false,
|
|
2839
|
+
report,
|
|
2840
|
+
updatedAt: Date.now()
|
|
2841
|
+
};
|
|
2842
|
+
emit();
|
|
2843
|
+
return report;
|
|
2844
|
+
} catch (error) {
|
|
2845
|
+
snapshot = {
|
|
2846
|
+
...snapshot,
|
|
2847
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2848
|
+
isLoading: false
|
|
2849
|
+
};
|
|
2850
|
+
emit();
|
|
2851
|
+
throw error;
|
|
2852
|
+
}
|
|
2853
|
+
};
|
|
2854
|
+
const close = () => {
|
|
2855
|
+
closed = true;
|
|
2856
|
+
if (timer) {
|
|
2857
|
+
clearInterval(timer);
|
|
2858
|
+
timer = undefined;
|
|
2859
|
+
}
|
|
2860
|
+
listeners.clear();
|
|
2861
|
+
};
|
|
2862
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2863
|
+
timer = setInterval(() => {
|
|
2864
|
+
refresh().catch(() => {});
|
|
2865
|
+
}, options.intervalMs);
|
|
2866
|
+
}
|
|
2867
|
+
return {
|
|
2868
|
+
close,
|
|
2869
|
+
getServerSnapshot: () => snapshot,
|
|
2870
|
+
getSnapshot: () => snapshot,
|
|
2871
|
+
refresh,
|
|
2872
|
+
subscribe: (listener) => {
|
|
2873
|
+
listeners.add(listener);
|
|
2874
|
+
return () => {
|
|
2875
|
+
listeners.delete(listener);
|
|
2876
|
+
};
|
|
2877
|
+
}
|
|
2878
|
+
};
|
|
2879
|
+
};
|
|
2880
|
+
|
|
2881
|
+
// src/client/traceTimelineWidget.ts
|
|
2882
|
+
var DEFAULT_TITLE9 = "Voice Traces";
|
|
2883
|
+
var DEFAULT_DESCRIPTION9 = "Latest call timelines with provider latency, fallbacks, handoffs, and errors from your self-hosted trace store.";
|
|
2884
|
+
var escapeHtml10 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2885
|
+
var formatMs = (value) => typeof value === "number" ? `${value}ms` : "n/a";
|
|
2886
|
+
var formatProviders = (session) => session.providers.length ? session.providers.map((provider) => provider.provider).join(", ") : "No providers";
|
|
2887
|
+
var createVoiceTraceTimelineViewModel = (snapshot, options = {}) => {
|
|
2888
|
+
const sessions = (snapshot.report?.sessions ?? []).slice(0, options.limit ?? 3).map((session) => ({
|
|
2889
|
+
...session,
|
|
2890
|
+
detailHref: `${options.detailBasePath ?? "/traces"}/${encodeURIComponent(session.sessionId)}`,
|
|
2891
|
+
durationLabel: formatMs(session.summary.callDurationMs),
|
|
2892
|
+
incidentBundleHref: options.incidentBundleBasePath === false ? undefined : `${options.incidentBundleBasePath ?? "/voice-incidents"}/${encodeURIComponent(session.sessionId)}/markdown`,
|
|
2893
|
+
label: `${session.summary.eventCount} events / ${session.summary.turnCount} turns`,
|
|
2894
|
+
operationsRecordHref: options.operationsRecordBasePath === false ? undefined : `${options.operationsRecordBasePath ?? "/voice-operations"}/${encodeURIComponent(session.sessionId)}`,
|
|
2895
|
+
providerLabel: formatProviders(session)
|
|
2896
|
+
}));
|
|
2897
|
+
const failed = sessions.filter((session) => session.status === "failed").length;
|
|
2898
|
+
const warnings = sessions.filter((session) => session.status === "warning").length;
|
|
2899
|
+
return {
|
|
2900
|
+
description: options.description ?? DEFAULT_DESCRIPTION9,
|
|
2901
|
+
error: snapshot.error,
|
|
2902
|
+
isLoading: snapshot.isLoading,
|
|
2903
|
+
label: snapshot.error ? "Unavailable" : failed > 0 ? `${failed} failed` : warnings > 0 ? `${warnings} warning` : sessions.length ? `${sessions.length} recent` : snapshot.isLoading ? "Checking" : "No traces yet",
|
|
2904
|
+
sessions,
|
|
2905
|
+
status: snapshot.error ? "error" : failed > 0 ? "failed" : warnings > 0 ? "warning" : sessions.length ? "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2906
|
+
title: options.title ?? DEFAULT_TITLE9,
|
|
2907
|
+
updatedAt: snapshot.updatedAt
|
|
2908
|
+
};
|
|
2909
|
+
};
|
|
2910
|
+
var renderVoiceTraceTimelineWidgetHTML = (snapshot, options = {}) => {
|
|
2911
|
+
const model = createVoiceTraceTimelineViewModel(snapshot, options);
|
|
2912
|
+
const sessions = model.sessions.length ? `<div class="absolute-voice-trace-timeline__sessions">${model.sessions.map((session) => {
|
|
2913
|
+
const supportLinks = [
|
|
2914
|
+
`<a href="${escapeHtml10(session.detailHref)}">Open timeline</a>`,
|
|
2915
|
+
session.operationsRecordHref ? `<a href="${escapeHtml10(session.operationsRecordHref)}">Open operations record</a>` : undefined,
|
|
2916
|
+
session.incidentBundleHref ? `<a href="${escapeHtml10(session.incidentBundleHref)}">Export incident bundle</a>` : undefined
|
|
2917
|
+
].filter(Boolean).join("");
|
|
2918
|
+
return `<article class="absolute-voice-trace-timeline__session absolute-voice-trace-timeline__session--${escapeHtml10(session.status)}">
|
|
2919
|
+
<header>
|
|
2920
|
+
<strong>${escapeHtml10(session.sessionId)}</strong>
|
|
2921
|
+
<span>${escapeHtml10(session.status)}</span>
|
|
2922
|
+
</header>
|
|
2923
|
+
<p>${escapeHtml10(session.label)} \xB7 ${escapeHtml10(session.durationLabel)} \xB7 ${escapeHtml10(session.providerLabel)}</p>
|
|
2924
|
+
<p class="absolute-voice-trace-timeline__actions">${supportLinks}</p>
|
|
2925
|
+
</article>`;
|
|
2926
|
+
}).join("")}</div>` : '<p class="absolute-voice-trace-timeline__empty">Run a voice session to see call timelines.</p>';
|
|
2927
|
+
return `<section class="absolute-voice-trace-timeline absolute-voice-trace-timeline--${escapeHtml10(model.status)}">
|
|
2928
|
+
<header class="absolute-voice-trace-timeline__header">
|
|
2929
|
+
<span class="absolute-voice-trace-timeline__eyebrow">${escapeHtml10(model.title)}</span>
|
|
2930
|
+
<strong class="absolute-voice-trace-timeline__label">${escapeHtml10(model.label)}</strong>
|
|
2931
|
+
</header>
|
|
2932
|
+
<p class="absolute-voice-trace-timeline__description">${escapeHtml10(model.description)}</p>
|
|
2933
|
+
${sessions}
|
|
2934
|
+
${model.error ? `<p class="absolute-voice-trace-timeline__error">${escapeHtml10(model.error)}</p>` : ""}
|
|
2935
|
+
</section>`;
|
|
2936
|
+
};
|
|
2937
|
+
var getVoiceTraceTimelineCSS = () => `.absolute-voice-trace-timeline{border:1px solid #bad7d3;border-radius:20px;background:#f3fffb;color:#09201c;padding:18px;box-shadow:0 18px 40px rgba(9,32,28,.12);font-family:inherit}.absolute-voice-trace-timeline--error,.absolute-voice-trace-timeline--failed{border-color:#f2a7a7;background:#fff5f3}.absolute-voice-trace-timeline--warning{border-color:#fbbf24;background:#fffaf0}.absolute-voice-trace-timeline__header,.absolute-voice-trace-timeline__session header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-trace-timeline__eyebrow{color:#17665b;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-trace-timeline__label{font-size:24px;line-height:1}.absolute-voice-trace-timeline__description,.absolute-voice-trace-timeline__session p,.absolute-voice-trace-timeline__empty{color:#35544f}.absolute-voice-trace-timeline__sessions{display:grid;gap:12px;margin-top:14px}.absolute-voice-trace-timeline__session{background:#fff;border:1px solid #cfe7e2;border-radius:16px;padding:14px}.absolute-voice-trace-timeline__session--failed{border-color:#f2a7a7}.absolute-voice-trace-timeline__session--warning{border-color:#fbbf24}.absolute-voice-trace-timeline__session p{margin:10px 0}.absolute-voice-trace-timeline__actions{display:flex;flex-wrap:wrap;gap:10px}.absolute-voice-trace-timeline__session a{color:#0f766e;font-weight:800}.absolute-voice-trace-timeline__empty{margin:14px 0 0}.absolute-voice-trace-timeline__error{color:#9f1239;font-weight:700}`;
|
|
2938
|
+
var mountVoiceTraceTimeline = (element, path = "/api/voice-traces", options = {}) => {
|
|
2939
|
+
const store = createVoiceTraceTimelineStore(path, options);
|
|
2940
|
+
const render = () => {
|
|
2941
|
+
element.innerHTML = renderVoiceTraceTimelineWidgetHTML(store.getSnapshot(), options);
|
|
2942
|
+
};
|
|
2943
|
+
const unsubscribe = store.subscribe(render);
|
|
2944
|
+
render();
|
|
2945
|
+
store.refresh().catch(() => {});
|
|
2946
|
+
return {
|
|
2947
|
+
close: () => {
|
|
2948
|
+
unsubscribe();
|
|
2949
|
+
store.close();
|
|
2950
|
+
},
|
|
2951
|
+
refresh: store.refresh
|
|
2952
|
+
};
|
|
2953
|
+
};
|
|
2954
|
+
var defineVoiceTraceTimelineElement = (tagName = "absolute-voice-trace-timeline") => {
|
|
2955
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2956
|
+
return;
|
|
2957
|
+
}
|
|
2958
|
+
customElements.define(tagName, class AbsoluteVoiceTraceTimelineElement extends HTMLElement {
|
|
2959
|
+
mounted;
|
|
2960
|
+
connectedCallback() {
|
|
2961
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2962
|
+
const limit = Number(this.getAttribute("limit") ?? 3);
|
|
2963
|
+
this.mounted = mountVoiceTraceTimeline(this, this.getAttribute("path") ?? "/api/voice-traces", {
|
|
2964
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2965
|
+
detailBasePath: this.getAttribute("detail-base-path") ?? undefined,
|
|
2966
|
+
incidentBundleBasePath: this.getAttribute("incident-bundle-base-path") ?? undefined,
|
|
2967
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2968
|
+
limit: Number.isFinite(limit) ? limit : 3,
|
|
2969
|
+
operationsRecordBasePath: this.getAttribute("operations-record-base-path") ?? undefined,
|
|
2970
|
+
title: this.getAttribute("title") ?? undefined
|
|
2971
|
+
});
|
|
2972
|
+
}
|
|
2973
|
+
disconnectedCallback() {
|
|
2974
|
+
this.mounted?.close();
|
|
2975
|
+
this.mounted = undefined;
|
|
2976
|
+
}
|
|
2977
|
+
});
|
|
2978
|
+
};
|
|
2979
|
+
|
|
2980
|
+
// src/react/useVoiceTraceTimeline.tsx
|
|
2981
|
+
import { useEffect as useEffect10, useRef as useRef10, useSyncExternalStore as useSyncExternalStore10 } from "react";
|
|
2982
|
+
var useVoiceTraceTimeline = (path = "/api/voice-traces", options = {}) => {
|
|
2983
|
+
const storeRef = useRef10(null);
|
|
2984
|
+
if (!storeRef.current) {
|
|
2985
|
+
storeRef.current = createVoiceTraceTimelineStore(path, options);
|
|
2986
|
+
}
|
|
2987
|
+
const store = storeRef.current;
|
|
2988
|
+
useEffect10(() => {
|
|
2989
|
+
store.refresh().catch(() => {});
|
|
2990
|
+
return () => store.close();
|
|
2991
|
+
}, [store]);
|
|
2992
|
+
return {
|
|
2993
|
+
...useSyncExternalStore10(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
2994
|
+
refresh: store.refresh
|
|
2995
|
+
};
|
|
2996
|
+
};
|
|
2997
|
+
|
|
2998
|
+
// src/react/VoiceTraceTimeline.tsx
|
|
2999
|
+
import { jsxDEV as jsxDEV10 } from "react/jsx-dev-runtime";
|
|
3000
|
+
var VoiceTraceTimeline = ({
|
|
3001
|
+
className,
|
|
3002
|
+
path = "/api/voice-traces",
|
|
3003
|
+
...options
|
|
3004
|
+
}) => {
|
|
3005
|
+
const snapshot = useVoiceTraceTimeline(path, options);
|
|
3006
|
+
const model = createVoiceTraceTimelineViewModel(snapshot, options);
|
|
3007
|
+
return /* @__PURE__ */ jsxDEV10("section", {
|
|
3008
|
+
className: [
|
|
3009
|
+
"absolute-voice-trace-timeline",
|
|
3010
|
+
`absolute-voice-trace-timeline--${model.status}`,
|
|
3011
|
+
className
|
|
3012
|
+
].filter(Boolean).join(" "),
|
|
3013
|
+
children: [
|
|
3014
|
+
/* @__PURE__ */ jsxDEV10("header", {
|
|
3015
|
+
className: "absolute-voice-trace-timeline__header",
|
|
3016
|
+
children: [
|
|
3017
|
+
/* @__PURE__ */ jsxDEV10("span", {
|
|
3018
|
+
className: "absolute-voice-trace-timeline__eyebrow",
|
|
3019
|
+
children: model.title
|
|
3020
|
+
}, undefined, false, undefined, this),
|
|
3021
|
+
/* @__PURE__ */ jsxDEV10("strong", {
|
|
3022
|
+
className: "absolute-voice-trace-timeline__label",
|
|
3023
|
+
children: model.label
|
|
3024
|
+
}, undefined, false, undefined, this)
|
|
3025
|
+
]
|
|
3026
|
+
}, undefined, true, undefined, this),
|
|
3027
|
+
/* @__PURE__ */ jsxDEV10("p", {
|
|
3028
|
+
className: "absolute-voice-trace-timeline__description",
|
|
3029
|
+
children: model.description
|
|
3030
|
+
}, undefined, false, undefined, this),
|
|
3031
|
+
model.sessions.length ? /* @__PURE__ */ jsxDEV10("div", {
|
|
3032
|
+
className: "absolute-voice-trace-timeline__sessions",
|
|
3033
|
+
children: model.sessions.map((session) => /* @__PURE__ */ jsxDEV10("article", {
|
|
3034
|
+
className: [
|
|
3035
|
+
"absolute-voice-trace-timeline__session",
|
|
3036
|
+
`absolute-voice-trace-timeline__session--${session.status}`
|
|
3037
|
+
].join(" "),
|
|
3038
|
+
children: [
|
|
3039
|
+
/* @__PURE__ */ jsxDEV10("header", {
|
|
3040
|
+
children: [
|
|
3041
|
+
/* @__PURE__ */ jsxDEV10("strong", {
|
|
3042
|
+
children: session.sessionId
|
|
3043
|
+
}, undefined, false, undefined, this),
|
|
3044
|
+
/* @__PURE__ */ jsxDEV10("span", {
|
|
3045
|
+
children: session.status
|
|
3046
|
+
}, undefined, false, undefined, this)
|
|
3047
|
+
]
|
|
3048
|
+
}, undefined, true, undefined, this),
|
|
3049
|
+
/* @__PURE__ */ jsxDEV10("p", {
|
|
3050
|
+
children: [
|
|
3051
|
+
session.label,
|
|
3052
|
+
" \xB7 ",
|
|
3053
|
+
session.durationLabel,
|
|
3054
|
+
" \xB7",
|
|
3055
|
+
" ",
|
|
3056
|
+
session.providerLabel
|
|
3057
|
+
]
|
|
3058
|
+
}, undefined, true, undefined, this),
|
|
3059
|
+
/* @__PURE__ */ jsxDEV10("p", {
|
|
3060
|
+
className: "absolute-voice-trace-timeline__actions",
|
|
3061
|
+
children: [
|
|
3062
|
+
/* @__PURE__ */ jsxDEV10("a", {
|
|
3063
|
+
href: session.detailHref,
|
|
3064
|
+
children: "Open timeline"
|
|
3065
|
+
}, undefined, false, undefined, this),
|
|
3066
|
+
session.operationsRecordHref ? /* @__PURE__ */ jsxDEV10("a", {
|
|
3067
|
+
href: session.operationsRecordHref,
|
|
3068
|
+
children: "Open operations record"
|
|
3069
|
+
}, undefined, false, undefined, this) : null,
|
|
3070
|
+
session.incidentBundleHref ? /* @__PURE__ */ jsxDEV10("a", {
|
|
3071
|
+
href: session.incidentBundleHref,
|
|
3072
|
+
children: "Export incident bundle"
|
|
3073
|
+
}, undefined, false, undefined, this) : null
|
|
3074
|
+
]
|
|
3075
|
+
}, undefined, true, undefined, this)
|
|
3076
|
+
]
|
|
3077
|
+
}, session.sessionId, true, undefined, this))
|
|
3078
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV10("p", {
|
|
3079
|
+
className: "absolute-voice-trace-timeline__empty",
|
|
3080
|
+
children: "Run a voice session to see call timelines."
|
|
3081
|
+
}, undefined, false, undefined, this),
|
|
3082
|
+
model.error ? /* @__PURE__ */ jsxDEV10("p", {
|
|
3083
|
+
className: "absolute-voice-trace-timeline__error",
|
|
3084
|
+
children: model.error
|
|
3085
|
+
}, undefined, false, undefined, this) : null
|
|
3086
|
+
]
|
|
3087
|
+
}, undefined, true, undefined, this);
|
|
3088
|
+
};
|
|
3089
|
+
// src/react/useVoiceAgentSquadStatus.tsx
|
|
3090
|
+
import { useEffect as useEffect11, useRef as useRef11, useSyncExternalStore as useSyncExternalStore11 } from "react";
|
|
3091
|
+
|
|
3092
|
+
// src/client/agentSquadStatus.ts
|
|
3093
|
+
var getString = (value) => typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
3094
|
+
var getPayloadString = (event, key) => getString(event.payload?.[key]);
|
|
3095
|
+
var eventStatus = (event) => {
|
|
3096
|
+
const status = getPayloadString(event, "status");
|
|
3097
|
+
if (status === "blocked")
|
|
3098
|
+
return "blocked";
|
|
3099
|
+
if (status === "unknown-target")
|
|
3100
|
+
return "unknown-target";
|
|
3101
|
+
if (status === "allowed")
|
|
3102
|
+
return "handoff";
|
|
3103
|
+
return event.type === "agent.result" ? "active" : "handoff";
|
|
3104
|
+
};
|
|
3105
|
+
var deriveSessionSpecialist = (session) => {
|
|
3106
|
+
const events = [...session.events].sort((left, right) => left.at - right.at);
|
|
3107
|
+
const agentEvents = events.filter((event) => event.type === "agent.handoff" || event.type === "agent.context" || event.type === "agent.result" || event.type === "agent.model");
|
|
3108
|
+
const latest = agentEvents.at(-1);
|
|
3109
|
+
if (!latest) {
|
|
3110
|
+
return {
|
|
3111
|
+
lastEventAt: session.lastEventAt,
|
|
3112
|
+
sessionId: session.sessionId,
|
|
3113
|
+
status: "idle"
|
|
3114
|
+
};
|
|
3115
|
+
}
|
|
3116
|
+
const handoffEvents = events.filter((event) => event.type === "agent.handoff");
|
|
3117
|
+
const lastHandoff = handoffEvents.at(-1);
|
|
3118
|
+
const latestAgentId = getPayloadString(latest, "agentId");
|
|
3119
|
+
const handoffStatus = lastHandoff ? eventStatus(lastHandoff) : undefined;
|
|
3120
|
+
const currentTarget = handoffStatus === "blocked" || handoffStatus === "unknown-target" ? getPayloadString(lastHandoff, "fromAgentId") ?? latestAgentId : getPayloadString(lastHandoff ?? latest, "targetAgentId") ?? latestAgentId;
|
|
3121
|
+
return {
|
|
3122
|
+
fromAgentId: getPayloadString(lastHandoff ?? latest, "fromAgentId"),
|
|
3123
|
+
lastEventAt: latest.at,
|
|
3124
|
+
reason: getPayloadString(lastHandoff ?? latest, "reason") ?? getPayloadString(latest, "handoffTarget"),
|
|
3125
|
+
sessionId: session.sessionId,
|
|
3126
|
+
status: lastHandoff ? eventStatus(lastHandoff) : "active",
|
|
3127
|
+
summary: getPayloadString(lastHandoff ?? latest, "summary"),
|
|
3128
|
+
targetAgentId: currentTarget,
|
|
3129
|
+
turnId: latest.turnId
|
|
3130
|
+
};
|
|
3131
|
+
};
|
|
3132
|
+
var buildVoiceAgentSquadStatusReport = (timeline, options = {}) => {
|
|
3133
|
+
const sessions = (timeline?.sessions ?? []).filter((session) => !options.sessionId || session.sessionId === options.sessionId).map(deriveSessionSpecialist).sort((left, right) => (right.lastEventAt ?? 0) - (left.lastEventAt ?? 0));
|
|
3134
|
+
const active = sessions.filter((session) => session.status !== "idle");
|
|
3135
|
+
return {
|
|
3136
|
+
active,
|
|
3137
|
+
checkedAt: timeline?.checkedAt,
|
|
3138
|
+
current: active[0] ?? sessions[0],
|
|
3139
|
+
sessionCount: sessions.length,
|
|
3140
|
+
sessions
|
|
3141
|
+
};
|
|
3142
|
+
};
|
|
3143
|
+
var createVoiceAgentSquadStatusStore = (path = "/api/voice-traces", options = {}) => {
|
|
3144
|
+
const timelineStore = createVoiceTraceTimelineStore(path, options);
|
|
3145
|
+
const getReport = () => buildVoiceAgentSquadStatusReport(timelineStore.getSnapshot().report, {
|
|
3146
|
+
sessionId: options.sessionId
|
|
3147
|
+
});
|
|
3148
|
+
const getSnapshot = () => {
|
|
3149
|
+
const snapshot = timelineStore.getSnapshot();
|
|
3150
|
+
return {
|
|
3151
|
+
error: snapshot.error,
|
|
3152
|
+
isLoading: snapshot.isLoading,
|
|
3153
|
+
report: getReport(),
|
|
3154
|
+
updatedAt: snapshot.updatedAt
|
|
3155
|
+
};
|
|
3156
|
+
};
|
|
3157
|
+
return {
|
|
3158
|
+
close: timelineStore.close,
|
|
3159
|
+
getServerSnapshot: getSnapshot,
|
|
3160
|
+
getSnapshot,
|
|
3161
|
+
refresh: timelineStore.refresh,
|
|
3162
|
+
subscribe: timelineStore.subscribe
|
|
3163
|
+
};
|
|
3164
|
+
};
|
|
3165
|
+
|
|
3166
|
+
// src/react/useVoiceAgentSquadStatus.tsx
|
|
3167
|
+
var useVoiceAgentSquadStatus = (path = "/api/voice-traces", options = {}) => {
|
|
3168
|
+
const storeRef = useRef11(null);
|
|
3169
|
+
if (!storeRef.current) {
|
|
3170
|
+
storeRef.current = createVoiceAgentSquadStatusStore(path, options);
|
|
3171
|
+
}
|
|
3172
|
+
const store = storeRef.current;
|
|
3173
|
+
useEffect11(() => {
|
|
3174
|
+
store.refresh().catch(() => {});
|
|
3175
|
+
return () => store.close();
|
|
3176
|
+
}, [store]);
|
|
3177
|
+
return {
|
|
3178
|
+
...useSyncExternalStore11(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
3179
|
+
refresh: store.refresh
|
|
3180
|
+
};
|
|
3181
|
+
};
|
|
3182
|
+
|
|
3183
|
+
// src/client/agentSquadStatusWidget.ts
|
|
3184
|
+
var DEFAULT_TITLE10 = "Voice Agent Squad";
|
|
3185
|
+
var DEFAULT_DESCRIPTION10 = "Current specialist and recent handoffs from your self-hosted voice traces.";
|
|
3186
|
+
var escapeHtml11 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
3187
|
+
var labelFor = (current) => {
|
|
3188
|
+
if (!current)
|
|
3189
|
+
return "Waiting for specialist activity";
|
|
3190
|
+
if (current.status === "blocked")
|
|
3191
|
+
return "Handoff blocked";
|
|
3192
|
+
if (current.status === "unknown-target")
|
|
3193
|
+
return "Unknown specialist";
|
|
3194
|
+
if (current.targetAgentId)
|
|
3195
|
+
return `Current: ${current.targetAgentId}`;
|
|
3196
|
+
return "Specialist active";
|
|
3197
|
+
};
|
|
3198
|
+
var createVoiceAgentSquadStatusViewModel = (snapshot, options = {}) => ({
|
|
3199
|
+
current: snapshot.report.current,
|
|
3200
|
+
description: options.description ?? DEFAULT_DESCRIPTION10,
|
|
3201
|
+
error: snapshot.error,
|
|
3202
|
+
isLoading: snapshot.isLoading,
|
|
3203
|
+
label: snapshot.error ? "Unavailable" : labelFor(snapshot.report.current),
|
|
3204
|
+
sessionCount: snapshot.report.sessionCount,
|
|
3205
|
+
sessions: snapshot.report.sessions,
|
|
3206
|
+
title: options.title ?? DEFAULT_TITLE10,
|
|
3207
|
+
updatedAt: snapshot.updatedAt
|
|
3208
|
+
});
|
|
3209
|
+
var renderVoiceAgentSquadStatusHTML = (snapshot, options = {}) => {
|
|
3210
|
+
const model = createVoiceAgentSquadStatusViewModel(snapshot, options);
|
|
3211
|
+
const current = model.current;
|
|
3212
|
+
const rows = model.sessions.length ? model.sessions.slice(0, 5).map((session) => `<li>
|
|
3213
|
+
<span>${escapeHtml11(session.sessionId)}</span>
|
|
3214
|
+
<strong>${escapeHtml11(session.targetAgentId ?? "none")}</strong>
|
|
3215
|
+
<em>${escapeHtml11(session.status)}</em>
|
|
3216
|
+
${session.summary || session.reason ? `<p>${escapeHtml11(session.summary ?? session.reason ?? "")}</p>` : ""}
|
|
3217
|
+
</li>`).join("") : "<li><span>No squad traces yet.</span><strong>Waiting</strong></li>";
|
|
3218
|
+
return `<section class="absolute-voice-agent-squad-status">
|
|
3219
|
+
<header>
|
|
3220
|
+
<span>${escapeHtml11(model.title)}</span>
|
|
3221
|
+
<strong>${escapeHtml11(model.label)}</strong>
|
|
3222
|
+
</header>
|
|
3223
|
+
<p>${escapeHtml11(model.description)}</p>
|
|
3224
|
+
<div>
|
|
3225
|
+
<span>Session</span><strong>${escapeHtml11(current?.sessionId ?? "n/a")}</strong>
|
|
3226
|
+
<span>From</span><strong>${escapeHtml11(current?.fromAgentId ?? "n/a")}</strong>
|
|
3227
|
+
<span>Status</span><strong>${escapeHtml11(current?.status ?? "idle")}</strong>
|
|
3228
|
+
</div>
|
|
3229
|
+
<ul>${rows}</ul>
|
|
3230
|
+
${model.error ? `<p class="absolute-voice-agent-squad-status__error">${escapeHtml11(model.error)}</p>` : ""}
|
|
3231
|
+
</section>`;
|
|
3232
|
+
};
|
|
3233
|
+
var getVoiceAgentSquadStatusCSS = () => `.absolute-voice-agent-squad-status{border:1px solid #38bdf866;border-radius:20px;background:#0f172a;color:#f8fafc;padding:18px;font-family:inherit}.absolute-voice-agent-squad-status header{display:grid;gap:4px}.absolute-voice-agent-squad-status header span{color:#7dd3fc;font-size:12px;font-weight:900;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-agent-squad-status header strong{font-size:20px}.absolute-voice-agent-squad-status p{color:#cbd5e1}.absolute-voice-agent-squad-status div{display:grid;gap:6px;grid-template-columns:max-content 1fr;margin:14px 0}.absolute-voice-agent-squad-status div span{color:#94a3b8}.absolute-voice-agent-squad-status ul{display:grid;gap:8px;list-style:none;margin:0;padding:0}.absolute-voice-agent-squad-status li{background:#020617;border:1px solid #1e293b;border-radius:14px;padding:10px}.absolute-voice-agent-squad-status li span{color:#94a3b8;display:block;font-size:12px}.absolute-voice-agent-squad-status li strong{display:block}.absolute-voice-agent-squad-status li em{color:#7dd3fc;font-style:normal}.absolute-voice-agent-squad-status__error{color:#fecaca;font-weight:800}`;
|
|
3234
|
+
var mountVoiceAgentSquadStatus = (element, path = "/api/voice-traces", options = {}) => {
|
|
3235
|
+
if (!element) {
|
|
3236
|
+
throw new Error("mountVoiceAgentSquadStatus requires an element.");
|
|
3237
|
+
}
|
|
3238
|
+
const store = createVoiceAgentSquadStatusStore(path, options);
|
|
3239
|
+
const render = () => {
|
|
3240
|
+
element.innerHTML = `<style>${getVoiceAgentSquadStatusCSS()}</style>${renderVoiceAgentSquadStatusHTML(store.getSnapshot(), options)}`;
|
|
3241
|
+
};
|
|
3242
|
+
const unsubscribe = store.subscribe(render);
|
|
3243
|
+
render();
|
|
3244
|
+
store.refresh().catch(() => {});
|
|
3245
|
+
return {
|
|
3246
|
+
close: () => {
|
|
3247
|
+
unsubscribe();
|
|
3248
|
+
store.close();
|
|
3249
|
+
},
|
|
3250
|
+
refresh: store.refresh
|
|
3251
|
+
};
|
|
3252
|
+
};
|
|
3253
|
+
var defineVoiceAgentSquadStatusElement = (tagName = "absolute-voice-agent-squad-status", options = {}) => {
|
|
3254
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
3255
|
+
return;
|
|
3256
|
+
}
|
|
3257
|
+
customElements.define(tagName, class AbsoluteVoiceAgentSquadStatusElement extends HTMLElement {
|
|
3258
|
+
mounted;
|
|
3259
|
+
connectedCallback() {
|
|
3260
|
+
this.mounted = mountVoiceAgentSquadStatus(this, this.getAttribute("path") ?? "/api/voice-traces", {
|
|
3261
|
+
...options,
|
|
3262
|
+
description: this.getAttribute("description") ?? options.description,
|
|
3263
|
+
sessionId: this.getAttribute("session-id") ?? options.sessionId,
|
|
3264
|
+
title: this.getAttribute("title") ?? options.title
|
|
3265
|
+
});
|
|
3266
|
+
}
|
|
3267
|
+
disconnectedCallback() {
|
|
3268
|
+
this.mounted?.close();
|
|
3269
|
+
this.mounted = undefined;
|
|
3270
|
+
}
|
|
3271
|
+
});
|
|
3272
|
+
};
|
|
3273
|
+
|
|
3274
|
+
// src/react/VoiceAgentSquadStatus.tsx
|
|
3275
|
+
import { jsxDEV as jsxDEV11 } from "react/jsx-dev-runtime";
|
|
3276
|
+
function VoiceAgentSquadStatus({
|
|
3277
|
+
path = "/api/voice-traces",
|
|
3278
|
+
...options
|
|
3279
|
+
}) {
|
|
3280
|
+
const snapshot = useVoiceAgentSquadStatus(path, options);
|
|
3281
|
+
const model = createVoiceAgentSquadStatusViewModel(snapshot, options);
|
|
3282
|
+
const current = model.current;
|
|
3283
|
+
return /* @__PURE__ */ jsxDEV11("section", {
|
|
3284
|
+
className: "absolute-voice-agent-squad-status",
|
|
3285
|
+
children: [
|
|
3286
|
+
/* @__PURE__ */ jsxDEV11("header", {
|
|
3287
|
+
children: [
|
|
3288
|
+
/* @__PURE__ */ jsxDEV11("span", {
|
|
3289
|
+
children: model.title
|
|
3290
|
+
}, undefined, false, undefined, this),
|
|
3291
|
+
/* @__PURE__ */ jsxDEV11("strong", {
|
|
3292
|
+
children: model.label
|
|
3293
|
+
}, undefined, false, undefined, this)
|
|
3294
|
+
]
|
|
3295
|
+
}, undefined, true, undefined, this),
|
|
3296
|
+
/* @__PURE__ */ jsxDEV11("p", {
|
|
3297
|
+
children: model.description
|
|
3298
|
+
}, undefined, false, undefined, this),
|
|
3299
|
+
/* @__PURE__ */ jsxDEV11("dl", {
|
|
3300
|
+
children: [
|
|
3301
|
+
/* @__PURE__ */ jsxDEV11("div", {
|
|
3302
|
+
children: [
|
|
3303
|
+
/* @__PURE__ */ jsxDEV11("dt", {
|
|
3304
|
+
children: "Session"
|
|
3305
|
+
}, undefined, false, undefined, this),
|
|
3306
|
+
/* @__PURE__ */ jsxDEV11("dd", {
|
|
3307
|
+
children: current?.sessionId ?? "n/a"
|
|
3308
|
+
}, undefined, false, undefined, this)
|
|
3309
|
+
]
|
|
3310
|
+
}, undefined, true, undefined, this),
|
|
3311
|
+
/* @__PURE__ */ jsxDEV11("div", {
|
|
3312
|
+
children: [
|
|
3313
|
+
/* @__PURE__ */ jsxDEV11("dt", {
|
|
3314
|
+
children: "Current specialist"
|
|
3315
|
+
}, undefined, false, undefined, this),
|
|
3316
|
+
/* @__PURE__ */ jsxDEV11("dd", {
|
|
3317
|
+
children: current?.targetAgentId ?? "none"
|
|
3318
|
+
}, undefined, false, undefined, this)
|
|
3319
|
+
]
|
|
3320
|
+
}, undefined, true, undefined, this),
|
|
3321
|
+
/* @__PURE__ */ jsxDEV11("div", {
|
|
3322
|
+
children: [
|
|
3323
|
+
/* @__PURE__ */ jsxDEV11("dt", {
|
|
3324
|
+
children: "Status"
|
|
3325
|
+
}, undefined, false, undefined, this),
|
|
3326
|
+
/* @__PURE__ */ jsxDEV11("dd", {
|
|
3327
|
+
children: current?.status ?? "idle"
|
|
3328
|
+
}, undefined, false, undefined, this)
|
|
3329
|
+
]
|
|
3330
|
+
}, undefined, true, undefined, this)
|
|
3331
|
+
]
|
|
3332
|
+
}, undefined, true, undefined, this),
|
|
3333
|
+
model.error ? /* @__PURE__ */ jsxDEV11("p", {
|
|
3334
|
+
children: model.error
|
|
3335
|
+
}, undefined, false, undefined, this) : null
|
|
3336
|
+
]
|
|
3337
|
+
}, undefined, true, undefined, this);
|
|
3338
|
+
}
|
|
3339
|
+
// src/react/useVoiceTurnLatency.tsx
|
|
3340
|
+
import { useEffect as useEffect12, useRef as useRef12, useSyncExternalStore as useSyncExternalStore12 } from "react";
|
|
3341
|
+
|
|
3342
|
+
// src/client/turnLatency.ts
|
|
3343
|
+
var fetchVoiceTurnLatency = async (path = "/api/turn-latency", options = {}) => {
|
|
3344
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
3345
|
+
const response = await fetchImpl(path);
|
|
3346
|
+
if (!response.ok) {
|
|
3347
|
+
throw new Error(`Voice turn latency failed: HTTP ${response.status}`);
|
|
3348
|
+
}
|
|
3349
|
+
return await response.json();
|
|
3350
|
+
};
|
|
3351
|
+
var runVoiceTurnLatencyProof = async (path, options = {}) => {
|
|
3352
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
3353
|
+
const response = await fetchImpl(path, { method: "POST" });
|
|
3354
|
+
if (!response.ok) {
|
|
3355
|
+
throw new Error(`Voice turn latency proof failed: HTTP ${response.status}`);
|
|
3356
|
+
}
|
|
3357
|
+
return response.json();
|
|
3358
|
+
};
|
|
3359
|
+
var createVoiceTurnLatencyStore = (path = "/api/turn-latency", options = {}) => {
|
|
3360
|
+
const listeners = new Set;
|
|
3361
|
+
let closed = false;
|
|
3362
|
+
let timer;
|
|
3363
|
+
let snapshot = {
|
|
3364
|
+
error: null,
|
|
3365
|
+
isLoading: false
|
|
3366
|
+
};
|
|
3367
|
+
const emit = () => {
|
|
3368
|
+
for (const listener of listeners) {
|
|
3369
|
+
listener();
|
|
3370
|
+
}
|
|
3371
|
+
};
|
|
3372
|
+
const refresh = async () => {
|
|
3373
|
+
if (closed) {
|
|
3374
|
+
return snapshot.report;
|
|
3375
|
+
}
|
|
3376
|
+
snapshot = { ...snapshot, error: null, isLoading: true };
|
|
3377
|
+
emit();
|
|
3378
|
+
try {
|
|
3379
|
+
const report = await fetchVoiceTurnLatency(path, options);
|
|
3380
|
+
snapshot = {
|
|
3381
|
+
error: null,
|
|
3382
|
+
isLoading: false,
|
|
3383
|
+
report,
|
|
3384
|
+
updatedAt: Date.now()
|
|
3385
|
+
};
|
|
3386
|
+
emit();
|
|
3387
|
+
return report;
|
|
3388
|
+
} catch (error) {
|
|
3389
|
+
snapshot = {
|
|
3390
|
+
...snapshot,
|
|
3391
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3392
|
+
isLoading: false
|
|
3393
|
+
};
|
|
3394
|
+
emit();
|
|
3395
|
+
throw error;
|
|
3396
|
+
}
|
|
3397
|
+
};
|
|
3398
|
+
const runProof = async () => {
|
|
3399
|
+
if (!options.proofPath) {
|
|
3400
|
+
throw new Error("Voice turn latency proof path is not configured.");
|
|
3401
|
+
}
|
|
3402
|
+
snapshot = { ...snapshot, error: null, isLoading: true };
|
|
3403
|
+
emit();
|
|
3404
|
+
try {
|
|
3405
|
+
await runVoiceTurnLatencyProof(options.proofPath, options);
|
|
3406
|
+
return await refresh();
|
|
3407
|
+
} catch (error) {
|
|
3408
|
+
snapshot = {
|
|
3409
|
+
...snapshot,
|
|
3410
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3411
|
+
isLoading: false
|
|
3412
|
+
};
|
|
3413
|
+
emit();
|
|
3414
|
+
throw error;
|
|
3415
|
+
}
|
|
3416
|
+
};
|
|
3417
|
+
const close = () => {
|
|
3418
|
+
closed = true;
|
|
3419
|
+
if (timer) {
|
|
3420
|
+
clearInterval(timer);
|
|
3421
|
+
timer = undefined;
|
|
3422
|
+
}
|
|
3423
|
+
listeners.clear();
|
|
3424
|
+
};
|
|
3425
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
3426
|
+
timer = setInterval(() => {
|
|
3427
|
+
refresh().catch(() => {});
|
|
3428
|
+
}, options.intervalMs);
|
|
3429
|
+
}
|
|
3430
|
+
return {
|
|
3431
|
+
close,
|
|
3432
|
+
getServerSnapshot: () => snapshot,
|
|
3433
|
+
getSnapshot: () => snapshot,
|
|
3434
|
+
refresh,
|
|
3435
|
+
runProof,
|
|
3436
|
+
subscribe: (listener) => {
|
|
3437
|
+
listeners.add(listener);
|
|
3438
|
+
return () => {
|
|
3439
|
+
listeners.delete(listener);
|
|
3440
|
+
};
|
|
3441
|
+
}
|
|
3442
|
+
};
|
|
3443
|
+
};
|
|
3444
|
+
|
|
3445
|
+
// src/react/useVoiceTurnLatency.tsx
|
|
3446
|
+
var useVoiceTurnLatency = (path = "/api/turn-latency", options = {}) => {
|
|
3447
|
+
const storeRef = useRef12(null);
|
|
3448
|
+
if (!storeRef.current) {
|
|
3449
|
+
storeRef.current = createVoiceTurnLatencyStore(path, options);
|
|
3450
|
+
}
|
|
3451
|
+
const store = storeRef.current;
|
|
3452
|
+
useEffect12(() => {
|
|
3453
|
+
store.refresh().catch(() => {});
|
|
3454
|
+
return () => store.close();
|
|
3455
|
+
}, [store]);
|
|
3456
|
+
return {
|
|
3457
|
+
...useSyncExternalStore12(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
3458
|
+
refresh: store.refresh,
|
|
3459
|
+
runProof: store.runProof
|
|
3460
|
+
};
|
|
3461
|
+
};
|
|
3462
|
+
|
|
3463
|
+
// src/client/turnLatencyWidget.ts
|
|
3464
|
+
var DEFAULT_TITLE11 = "Turn Latency";
|
|
3465
|
+
var DEFAULT_DESCRIPTION11 = "Per-turn timing from first transcript to commit and assistant response start.";
|
|
3466
|
+
var DEFAULT_PROOF_LABEL = "Run latency proof";
|
|
3467
|
+
var escapeHtml12 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
3468
|
+
var formatMs2 = (value) => typeof value === "number" ? `${Math.round(value)}ms` : "n/a";
|
|
3469
|
+
var createVoiceTurnLatencyViewModel = (snapshot, options = {}) => {
|
|
3470
|
+
const turns = (snapshot.report?.turns ?? []).map((turn) => ({
|
|
3471
|
+
...turn,
|
|
3472
|
+
label: turn.text || "Empty turn",
|
|
3473
|
+
rows: turn.stages.map((stage) => ({
|
|
3474
|
+
label: stage.label,
|
|
3475
|
+
value: formatMs2(stage.valueMs)
|
|
3476
|
+
}))
|
|
3477
|
+
}));
|
|
3478
|
+
const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
|
|
3479
|
+
const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
|
|
3480
|
+
return {
|
|
3481
|
+
description: options.description ?? DEFAULT_DESCRIPTION11,
|
|
3482
|
+
error: snapshot.error,
|
|
3483
|
+
isLoading: snapshot.isLoading,
|
|
3484
|
+
label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} slow` : warningCount > 0 ? `${warningCount} warnings` : `avg ${formatMs2(snapshot.report?.averageTotalMs)}` : snapshot.isLoading ? "Checking" : "No turns",
|
|
3485
|
+
proofLabel: options.proofPath ? options.proofLabel ?? DEFAULT_PROOF_LABEL : undefined,
|
|
3486
|
+
showProofAction: Boolean(options.proofPath),
|
|
3487
|
+
status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
3488
|
+
title: options.title ?? DEFAULT_TITLE11,
|
|
3489
|
+
turns,
|
|
3490
|
+
updatedAt: snapshot.updatedAt
|
|
3491
|
+
};
|
|
3492
|
+
};
|
|
3493
|
+
var renderVoiceTurnLatencyHTML = (snapshot, options = {}) => {
|
|
3494
|
+
const model = createVoiceTurnLatencyViewModel(snapshot, options);
|
|
3495
|
+
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--${escapeHtml12(turn.status)}">
|
|
3496
|
+
<header>
|
|
3497
|
+
<strong>${escapeHtml12(turn.label)}</strong>
|
|
3498
|
+
<span>${escapeHtml12(turn.status)}</span>
|
|
3499
|
+
</header>
|
|
3500
|
+
<dl>${turn.rows.map((row) => `<div>
|
|
3501
|
+
<dt>${escapeHtml12(row.label)}</dt>
|
|
3502
|
+
<dd>${escapeHtml12(row.value)}</dd>
|
|
3503
|
+
</div>`).join("")}</dl>
|
|
3504
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-turn-latency__empty">Complete a voice turn to see latency diagnostics.</p>';
|
|
3505
|
+
return `<section class="absolute-voice-turn-latency absolute-voice-turn-latency--${escapeHtml12(model.status)}">
|
|
3506
|
+
<header class="absolute-voice-turn-latency__header">
|
|
3507
|
+
<span class="absolute-voice-turn-latency__eyebrow">${escapeHtml12(model.title)}</span>
|
|
3508
|
+
<strong class="absolute-voice-turn-latency__label">${escapeHtml12(model.label)}</strong>
|
|
3509
|
+
</header>
|
|
3510
|
+
<p class="absolute-voice-turn-latency__description">${escapeHtml12(model.description)}</p>
|
|
3511
|
+
${model.showProofAction ? `<button class="absolute-voice-turn-latency__proof" data-absolute-voice-turn-latency-proof type="button">${escapeHtml12(model.proofLabel ?? DEFAULT_PROOF_LABEL)}</button>` : ""}
|
|
3512
|
+
${turns}
|
|
3513
|
+
${model.error ? `<p class="absolute-voice-turn-latency__error">${escapeHtml12(model.error)}</p>` : ""}
|
|
3514
|
+
</section>`;
|
|
3515
|
+
};
|
|
3516
|
+
var mountVoiceTurnLatency = (element, path = "/api/turn-latency", options = {}) => {
|
|
3517
|
+
const store = createVoiceTurnLatencyStore(path, options);
|
|
3518
|
+
const render = () => {
|
|
3519
|
+
element.innerHTML = renderVoiceTurnLatencyHTML(store.getSnapshot(), options);
|
|
3520
|
+
};
|
|
3521
|
+
const handleClick = (event) => {
|
|
3522
|
+
const target = event.target;
|
|
3523
|
+
if (target instanceof Element && target.closest("[data-absolute-voice-turn-latency-proof]")) {
|
|
3524
|
+
store.runProof().catch(() => {});
|
|
3525
|
+
}
|
|
3526
|
+
};
|
|
3527
|
+
const unsubscribe = store.subscribe(render);
|
|
3528
|
+
element.addEventListener("click", handleClick);
|
|
3529
|
+
render();
|
|
3530
|
+
store.refresh().catch(() => {});
|
|
3531
|
+
return {
|
|
3532
|
+
close: () => {
|
|
3533
|
+
element.removeEventListener("click", handleClick);
|
|
3534
|
+
unsubscribe();
|
|
3535
|
+
store.close();
|
|
3536
|
+
},
|
|
3537
|
+
refresh: store.refresh
|
|
3538
|
+
};
|
|
3539
|
+
};
|
|
3540
|
+
var defineVoiceTurnLatencyElement = (tagName = "absolute-voice-turn-latency") => {
|
|
3541
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
3542
|
+
return;
|
|
3543
|
+
}
|
|
3544
|
+
customElements.define(tagName, class AbsoluteVoiceTurnLatencyElement extends HTMLElement {
|
|
3545
|
+
mounted;
|
|
3546
|
+
connectedCallback() {
|
|
3547
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
3548
|
+
this.mounted = mountVoiceTurnLatency(this, this.getAttribute("path") ?? "/api/turn-latency", {
|
|
3549
|
+
description: this.getAttribute("description") ?? undefined,
|
|
3550
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
3551
|
+
proofLabel: this.getAttribute("proof-label") ?? undefined,
|
|
3552
|
+
proofPath: this.getAttribute("proof-path") ?? undefined,
|
|
3553
|
+
title: this.getAttribute("title") ?? undefined
|
|
3554
|
+
});
|
|
3555
|
+
}
|
|
3556
|
+
disconnectedCallback() {
|
|
3557
|
+
this.mounted?.close();
|
|
3558
|
+
this.mounted = undefined;
|
|
3559
|
+
}
|
|
3560
|
+
});
|
|
3561
|
+
};
|
|
3562
|
+
|
|
3563
|
+
// src/react/VoiceTurnLatency.tsx
|
|
3564
|
+
import { jsxDEV as jsxDEV12 } from "react/jsx-dev-runtime";
|
|
3565
|
+
var VoiceTurnLatency = ({
|
|
3566
|
+
className,
|
|
3567
|
+
path = "/api/turn-latency",
|
|
3568
|
+
...options
|
|
3569
|
+
}) => {
|
|
3570
|
+
const latency = useVoiceTurnLatency(path, options);
|
|
3571
|
+
const model = createVoiceTurnLatencyViewModel(latency, options);
|
|
3572
|
+
return /* @__PURE__ */ jsxDEV12("section", {
|
|
3573
|
+
className: [
|
|
3574
|
+
"absolute-voice-turn-latency",
|
|
3575
|
+
`absolute-voice-turn-latency--${model.status}`,
|
|
3576
|
+
className
|
|
3577
|
+
].filter(Boolean).join(" "),
|
|
3578
|
+
children: [
|
|
3579
|
+
/* @__PURE__ */ jsxDEV12("header", {
|
|
3580
|
+
className: "absolute-voice-turn-latency__header",
|
|
3581
|
+
children: [
|
|
3582
|
+
/* @__PURE__ */ jsxDEV12("span", {
|
|
3583
|
+
className: "absolute-voice-turn-latency__eyebrow",
|
|
3584
|
+
children: model.title
|
|
3585
|
+
}, undefined, false, undefined, this),
|
|
3586
|
+
/* @__PURE__ */ jsxDEV12("strong", {
|
|
3587
|
+
className: "absolute-voice-turn-latency__label",
|
|
3588
|
+
children: model.label
|
|
3589
|
+
}, undefined, false, undefined, this)
|
|
3590
|
+
]
|
|
3591
|
+
}, undefined, true, undefined, this),
|
|
3592
|
+
/* @__PURE__ */ jsxDEV12("p", {
|
|
3593
|
+
className: "absolute-voice-turn-latency__description",
|
|
3594
|
+
children: model.description
|
|
3595
|
+
}, undefined, false, undefined, this),
|
|
3596
|
+
model.showProofAction ? /* @__PURE__ */ jsxDEV12("button", {
|
|
3597
|
+
className: "absolute-voice-turn-latency__proof",
|
|
3598
|
+
onClick: () => {
|
|
3599
|
+
latency.runProof().catch(() => {});
|
|
3600
|
+
},
|
|
3601
|
+
type: "button",
|
|
3602
|
+
children: model.proofLabel
|
|
3603
|
+
}, undefined, false, undefined, this) : null,
|
|
3604
|
+
model.turns.length ? /* @__PURE__ */ jsxDEV12("div", {
|
|
3605
|
+
className: "absolute-voice-turn-latency__turns",
|
|
3606
|
+
children: model.turns.map((turn) => /* @__PURE__ */ jsxDEV12("article", {
|
|
3607
|
+
className: [
|
|
3608
|
+
"absolute-voice-turn-latency__turn",
|
|
3609
|
+
`absolute-voice-turn-latency__turn--${turn.status}`
|
|
3610
|
+
].join(" "),
|
|
3611
|
+
children: [
|
|
3612
|
+
/* @__PURE__ */ jsxDEV12("header", {
|
|
3613
|
+
children: [
|
|
3614
|
+
/* @__PURE__ */ jsxDEV12("strong", {
|
|
3615
|
+
children: turn.label
|
|
3616
|
+
}, undefined, false, undefined, this),
|
|
3617
|
+
/* @__PURE__ */ jsxDEV12("span", {
|
|
3618
|
+
children: turn.status
|
|
3619
|
+
}, undefined, false, undefined, this)
|
|
3620
|
+
]
|
|
3621
|
+
}, undefined, true, undefined, this),
|
|
3622
|
+
/* @__PURE__ */ jsxDEV12("dl", {
|
|
3623
|
+
children: turn.rows.map((row) => /* @__PURE__ */ jsxDEV12("div", {
|
|
3624
|
+
children: [
|
|
3625
|
+
/* @__PURE__ */ jsxDEV12("dt", {
|
|
3626
|
+
children: row.label
|
|
3627
|
+
}, undefined, false, undefined, this),
|
|
3628
|
+
/* @__PURE__ */ jsxDEV12("dd", {
|
|
3629
|
+
children: row.value
|
|
3630
|
+
}, undefined, false, undefined, this)
|
|
3631
|
+
]
|
|
3632
|
+
}, row.label, true, undefined, this))
|
|
3633
|
+
}, undefined, false, undefined, this)
|
|
3634
|
+
]
|
|
3635
|
+
}, `${turn.sessionId}:${turn.turnId}`, true, undefined, this))
|
|
3636
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV12("p", {
|
|
3637
|
+
className: "absolute-voice-turn-latency__empty",
|
|
3638
|
+
children: "Complete a voice turn to see latency diagnostics."
|
|
3639
|
+
}, undefined, false, undefined, this),
|
|
3640
|
+
model.error ? /* @__PURE__ */ jsxDEV12("p", {
|
|
3641
|
+
className: "absolute-voice-turn-latency__error",
|
|
3642
|
+
children: model.error
|
|
3643
|
+
}, undefined, false, undefined, this) : null
|
|
3644
|
+
]
|
|
3645
|
+
}, undefined, true, undefined, this);
|
|
3646
|
+
};
|
|
3647
|
+
// src/react/useVoiceTurnQuality.tsx
|
|
3648
|
+
import { useEffect as useEffect13, useRef as useRef13, useSyncExternalStore as useSyncExternalStore13 } from "react";
|
|
3649
|
+
|
|
3650
|
+
// src/client/turnQuality.ts
|
|
3651
|
+
var fetchVoiceTurnQuality = async (path = "/api/turn-quality", options = {}) => {
|
|
3652
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
3653
|
+
const response = await fetchImpl(path);
|
|
3654
|
+
if (!response.ok) {
|
|
3655
|
+
throw new Error(`Voice turn quality failed: HTTP ${response.status}`);
|
|
3656
|
+
}
|
|
3657
|
+
return await response.json();
|
|
3658
|
+
};
|
|
3659
|
+
var createVoiceTurnQualityStore = (path = "/api/turn-quality", options = {}) => {
|
|
3660
|
+
const listeners = new Set;
|
|
3661
|
+
let closed = false;
|
|
3662
|
+
let timer;
|
|
3663
|
+
let snapshot = {
|
|
3664
|
+
error: null,
|
|
3665
|
+
isLoading: false
|
|
3666
|
+
};
|
|
3667
|
+
const emit = () => {
|
|
3668
|
+
for (const listener of listeners) {
|
|
3669
|
+
listener();
|
|
3670
|
+
}
|
|
3671
|
+
};
|
|
3672
|
+
const refresh = async () => {
|
|
3673
|
+
if (closed) {
|
|
3674
|
+
return snapshot.report;
|
|
3675
|
+
}
|
|
3676
|
+
snapshot = {
|
|
3677
|
+
...snapshot,
|
|
3678
|
+
error: null,
|
|
3679
|
+
isLoading: true
|
|
3680
|
+
};
|
|
3681
|
+
emit();
|
|
3682
|
+
try {
|
|
3683
|
+
const report = await fetchVoiceTurnQuality(path, options);
|
|
3684
|
+
snapshot = {
|
|
3685
|
+
error: null,
|
|
3686
|
+
isLoading: false,
|
|
3687
|
+
report,
|
|
3688
|
+
updatedAt: Date.now()
|
|
3689
|
+
};
|
|
3690
|
+
emit();
|
|
3691
|
+
return report;
|
|
3692
|
+
} catch (error) {
|
|
3693
|
+
snapshot = {
|
|
3694
|
+
...snapshot,
|
|
3695
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3696
|
+
isLoading: false
|
|
3697
|
+
};
|
|
3698
|
+
emit();
|
|
3699
|
+
throw error;
|
|
3700
|
+
}
|
|
3701
|
+
};
|
|
3702
|
+
const close = () => {
|
|
3703
|
+
closed = true;
|
|
3704
|
+
if (timer) {
|
|
3705
|
+
clearInterval(timer);
|
|
3706
|
+
timer = undefined;
|
|
3707
|
+
}
|
|
3708
|
+
listeners.clear();
|
|
3709
|
+
};
|
|
3710
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
3711
|
+
timer = setInterval(() => {
|
|
3712
|
+
refresh().catch(() => {});
|
|
3713
|
+
}, options.intervalMs);
|
|
3714
|
+
}
|
|
3715
|
+
return {
|
|
3716
|
+
close,
|
|
3717
|
+
getServerSnapshot: () => snapshot,
|
|
3718
|
+
getSnapshot: () => snapshot,
|
|
3719
|
+
refresh,
|
|
3720
|
+
subscribe: (listener) => {
|
|
3721
|
+
listeners.add(listener);
|
|
3722
|
+
return () => {
|
|
3723
|
+
listeners.delete(listener);
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
};
|
|
3727
|
+
};
|
|
3728
|
+
|
|
3729
|
+
// src/react/useVoiceTurnQuality.tsx
|
|
3730
|
+
var useVoiceTurnQuality = (path = "/api/turn-quality", options = {}) => {
|
|
3731
|
+
const storeRef = useRef13(null);
|
|
3732
|
+
if (!storeRef.current) {
|
|
3733
|
+
storeRef.current = createVoiceTurnQualityStore(path, options);
|
|
3734
|
+
}
|
|
3735
|
+
const store = storeRef.current;
|
|
3736
|
+
useEffect13(() => {
|
|
3737
|
+
store.refresh().catch(() => {});
|
|
3738
|
+
return () => store.close();
|
|
3739
|
+
}, [store]);
|
|
3740
|
+
return {
|
|
3741
|
+
...useSyncExternalStore13(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
3742
|
+
refresh: store.refresh
|
|
3743
|
+
};
|
|
3744
|
+
};
|
|
3745
|
+
|
|
3746
|
+
// src/client/turnQualityWidget.ts
|
|
3747
|
+
var DEFAULT_TITLE12 = "Turn Quality";
|
|
3748
|
+
var DEFAULT_DESCRIPTION12 = "Per-turn STT confidence, fallback selection, corrections, and transcript coverage.";
|
|
3749
|
+
var escapeHtml13 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
3750
|
+
var formatConfidence = (value) => typeof value === "number" ? `${Math.round(value * 100)}%` : "n/a";
|
|
3751
|
+
var formatMaybe = (value) => value === undefined || value === "" ? "n/a" : String(value);
|
|
3752
|
+
var getTurnDetail = (turn) => {
|
|
3753
|
+
if (turn.status === "fail") {
|
|
3754
|
+
return "Empty or unusable committed turn; inspect transcripts and adapter events.";
|
|
3755
|
+
}
|
|
3756
|
+
if (turn.fallbackUsed) {
|
|
3757
|
+
return `Fallback STT selected${turn.fallbackSelectionReason ? ` by ${turn.fallbackSelectionReason}` : ""}.`;
|
|
3758
|
+
}
|
|
3759
|
+
if (turn.correctionChanged) {
|
|
3760
|
+
return `Correction changed the turn${turn.correctionProvider ? ` via ${turn.correctionProvider}` : ""}.`;
|
|
3761
|
+
}
|
|
3762
|
+
if (turn.status === "warn") {
|
|
3763
|
+
return "Turn completed with quality warnings.";
|
|
3764
|
+
}
|
|
3765
|
+
if (turn.status === "unknown") {
|
|
3766
|
+
return "No quality diagnostics were recorded for this turn.";
|
|
3767
|
+
}
|
|
3768
|
+
return "Turn quality looks healthy.";
|
|
3769
|
+
};
|
|
3770
|
+
var createVoiceTurnQualityViewModel = (snapshot, options = {}) => {
|
|
3771
|
+
const turns = (snapshot.report?.turns ?? []).map((turn) => ({
|
|
3772
|
+
...turn,
|
|
3773
|
+
detail: getTurnDetail(turn),
|
|
3774
|
+
label: turn.text || "Empty turn",
|
|
3775
|
+
rows: [
|
|
3776
|
+
{ label: "Source", value: turn.source ?? "unknown" },
|
|
3777
|
+
{ label: "Confidence", value: formatConfidence(turn.averageConfidence) },
|
|
3778
|
+
{ label: "Fallback", value: turn.fallbackUsed ? "Yes" : "No" },
|
|
3779
|
+
{ label: "Correction", value: turn.correctionChanged ? "Changed" : "None" },
|
|
3780
|
+
{ label: "Transcripts", value: `${turn.selectedTranscriptCount} selected` },
|
|
3781
|
+
{ label: "Cost", value: formatMaybe(turn.costUnits) }
|
|
3782
|
+
]
|
|
3783
|
+
}));
|
|
3784
|
+
const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
|
|
3785
|
+
const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
|
|
3786
|
+
return {
|
|
3787
|
+
description: options.description ?? DEFAULT_DESCRIPTION12,
|
|
3788
|
+
error: snapshot.error,
|
|
3789
|
+
isLoading: snapshot.isLoading,
|
|
3790
|
+
label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} failed` : warningCount > 0 ? `${warningCount} warnings` : `${turns.length} healthy` : snapshot.isLoading ? "Checking" : "No turns",
|
|
3791
|
+
status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
3792
|
+
title: options.title ?? DEFAULT_TITLE12,
|
|
3793
|
+
turns,
|
|
3794
|
+
updatedAt: snapshot.updatedAt
|
|
3795
|
+
};
|
|
3796
|
+
};
|
|
3797
|
+
var renderVoiceTurnQualityHTML = (snapshot, options = {}) => {
|
|
3798
|
+
const model = createVoiceTurnQualityViewModel(snapshot, options);
|
|
3799
|
+
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--${escapeHtml13(turn.status)}">
|
|
3800
|
+
<header>
|
|
3801
|
+
<strong>${escapeHtml13(turn.label)}</strong>
|
|
3802
|
+
<span>${escapeHtml13(turn.status)}</span>
|
|
3803
|
+
</header>
|
|
3804
|
+
<p>${escapeHtml13(turn.detail)}</p>
|
|
3805
|
+
<dl>${turn.rows.map((row) => `<div>
|
|
3806
|
+
<dt>${escapeHtml13(row.label)}</dt>
|
|
3807
|
+
<dd>${escapeHtml13(row.value)}</dd>
|
|
3808
|
+
</div>`).join("")}</dl>
|
|
3809
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-turn-quality__empty">Complete a voice turn to see STT quality diagnostics.</p>';
|
|
3810
|
+
return `<section class="absolute-voice-turn-quality absolute-voice-turn-quality--${escapeHtml13(model.status)}">
|
|
3811
|
+
<header class="absolute-voice-turn-quality__header">
|
|
3812
|
+
<span class="absolute-voice-turn-quality__eyebrow">${escapeHtml13(model.title)}</span>
|
|
3813
|
+
<strong class="absolute-voice-turn-quality__label">${escapeHtml13(model.label)}</strong>
|
|
3814
|
+
</header>
|
|
3815
|
+
<p class="absolute-voice-turn-quality__description">${escapeHtml13(model.description)}</p>
|
|
3816
|
+
${turns}
|
|
3817
|
+
${model.error ? `<p class="absolute-voice-turn-quality__error">${escapeHtml13(model.error)}</p>` : ""}
|
|
3818
|
+
</section>`;
|
|
3819
|
+
};
|
|
3820
|
+
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}`;
|
|
3821
|
+
var mountVoiceTurnQuality = (element, path = "/api/turn-quality", options = {}) => {
|
|
3822
|
+
const store = createVoiceTurnQualityStore(path, options);
|
|
3823
|
+
const render = () => {
|
|
3824
|
+
element.innerHTML = renderVoiceTurnQualityHTML(store.getSnapshot(), options);
|
|
3825
|
+
};
|
|
3826
|
+
const unsubscribe = store.subscribe(render);
|
|
3827
|
+
render();
|
|
3828
|
+
store.refresh().catch(() => {});
|
|
3829
|
+
return {
|
|
3830
|
+
close: () => {
|
|
3831
|
+
unsubscribe();
|
|
3832
|
+
store.close();
|
|
3833
|
+
},
|
|
3834
|
+
refresh: store.refresh
|
|
3835
|
+
};
|
|
3836
|
+
};
|
|
3837
|
+
var defineVoiceTurnQualityElement = (tagName = "absolute-voice-turn-quality") => {
|
|
3838
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
3839
|
+
return;
|
|
3840
|
+
}
|
|
3841
|
+
customElements.define(tagName, class AbsoluteVoiceTurnQualityElement extends HTMLElement {
|
|
3842
|
+
mounted;
|
|
3843
|
+
connectedCallback() {
|
|
3844
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
3845
|
+
this.mounted = mountVoiceTurnQuality(this, this.getAttribute("path") ?? "/api/turn-quality", {
|
|
3846
|
+
description: this.getAttribute("description") ?? undefined,
|
|
3847
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
3848
|
+
title: this.getAttribute("title") ?? undefined
|
|
3849
|
+
});
|
|
3850
|
+
}
|
|
3851
|
+
disconnectedCallback() {
|
|
3852
|
+
this.mounted?.close();
|
|
3853
|
+
this.mounted = undefined;
|
|
3854
|
+
}
|
|
3855
|
+
});
|
|
3856
|
+
};
|
|
3857
|
+
|
|
3858
|
+
// src/react/VoiceTurnQuality.tsx
|
|
3859
|
+
import { jsxDEV as jsxDEV13 } from "react/jsx-dev-runtime";
|
|
3860
|
+
var VoiceTurnQuality = ({
|
|
3861
|
+
className,
|
|
3862
|
+
path = "/api/turn-quality",
|
|
3863
|
+
...options
|
|
3864
|
+
}) => {
|
|
3865
|
+
const snapshot = useVoiceTurnQuality(path, options);
|
|
3866
|
+
const model = createVoiceTurnQualityViewModel(snapshot, options);
|
|
3867
|
+
return /* @__PURE__ */ jsxDEV13("section", {
|
|
3868
|
+
className: [
|
|
3869
|
+
"absolute-voice-turn-quality",
|
|
3870
|
+
`absolute-voice-turn-quality--${model.status}`,
|
|
3871
|
+
className
|
|
3872
|
+
].filter(Boolean).join(" "),
|
|
3873
|
+
children: [
|
|
3874
|
+
/* @__PURE__ */ jsxDEV13("header", {
|
|
3875
|
+
className: "absolute-voice-turn-quality__header",
|
|
3876
|
+
children: [
|
|
3877
|
+
/* @__PURE__ */ jsxDEV13("span", {
|
|
3878
|
+
className: "absolute-voice-turn-quality__eyebrow",
|
|
3879
|
+
children: model.title
|
|
3880
|
+
}, undefined, false, undefined, this),
|
|
3881
|
+
/* @__PURE__ */ jsxDEV13("strong", {
|
|
3882
|
+
className: "absolute-voice-turn-quality__label",
|
|
3883
|
+
children: model.label
|
|
3884
|
+
}, undefined, false, undefined, this)
|
|
3885
|
+
]
|
|
3886
|
+
}, undefined, true, undefined, this),
|
|
3887
|
+
/* @__PURE__ */ jsxDEV13("p", {
|
|
3888
|
+
className: "absolute-voice-turn-quality__description",
|
|
3889
|
+
children: model.description
|
|
3890
|
+
}, undefined, false, undefined, this),
|
|
3891
|
+
model.turns.length ? /* @__PURE__ */ jsxDEV13("div", {
|
|
3892
|
+
className: "absolute-voice-turn-quality__turns",
|
|
3893
|
+
children: model.turns.map((turn) => /* @__PURE__ */ jsxDEV13("article", {
|
|
3894
|
+
className: [
|
|
3895
|
+
"absolute-voice-turn-quality__turn",
|
|
3896
|
+
`absolute-voice-turn-quality__turn--${turn.status}`
|
|
3897
|
+
].join(" "),
|
|
3898
|
+
children: [
|
|
3899
|
+
/* @__PURE__ */ jsxDEV13("header", {
|
|
3900
|
+
children: [
|
|
3901
|
+
/* @__PURE__ */ jsxDEV13("strong", {
|
|
3902
|
+
children: turn.label
|
|
3903
|
+
}, undefined, false, undefined, this),
|
|
3904
|
+
/* @__PURE__ */ jsxDEV13("span", {
|
|
3905
|
+
children: turn.status
|
|
3906
|
+
}, undefined, false, undefined, this)
|
|
3907
|
+
]
|
|
3908
|
+
}, undefined, true, undefined, this),
|
|
3909
|
+
/* @__PURE__ */ jsxDEV13("p", {
|
|
3910
|
+
children: turn.detail
|
|
3911
|
+
}, undefined, false, undefined, this),
|
|
3912
|
+
/* @__PURE__ */ jsxDEV13("dl", {
|
|
3913
|
+
children: turn.rows.map((row) => /* @__PURE__ */ jsxDEV13("div", {
|
|
3914
|
+
children: [
|
|
3915
|
+
/* @__PURE__ */ jsxDEV13("dt", {
|
|
3916
|
+
children: row.label
|
|
3917
|
+
}, undefined, false, undefined, this),
|
|
3918
|
+
/* @__PURE__ */ jsxDEV13("dd", {
|
|
3919
|
+
children: row.value
|
|
3920
|
+
}, undefined, false, undefined, this)
|
|
3921
|
+
]
|
|
3922
|
+
}, row.label, true, undefined, this))
|
|
3923
|
+
}, undefined, false, undefined, this)
|
|
3924
|
+
]
|
|
3925
|
+
}, `${turn.sessionId}:${turn.turnId}`, true, undefined, this))
|
|
3926
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV13("p", {
|
|
3927
|
+
className: "absolute-voice-turn-quality__empty",
|
|
3928
|
+
children: "Complete a voice turn to see STT quality diagnostics."
|
|
3929
|
+
}, undefined, false, undefined, this),
|
|
3930
|
+
model.error ? /* @__PURE__ */ jsxDEV13("p", {
|
|
3931
|
+
className: "absolute-voice-turn-quality__error",
|
|
3932
|
+
children: model.error
|
|
3933
|
+
}, undefined, false, undefined, this) : null
|
|
3934
|
+
]
|
|
3935
|
+
}, undefined, true, undefined, this);
|
|
3936
|
+
};
|
|
3937
|
+
// src/react/useVoiceLiveOps.tsx
|
|
3938
|
+
import { useEffect as useEffect14, useRef as useRef14, useSyncExternalStore as useSyncExternalStore14 } from "react";
|
|
3939
|
+
|
|
3940
|
+
// src/client/liveOps.ts
|
|
3941
|
+
var postVoiceLiveOpsAction = async (input, options = {}) => {
|
|
3942
|
+
if (!input.sessionId) {
|
|
3943
|
+
throw new Error("Start a voice session before running live ops actions.");
|
|
3944
|
+
}
|
|
3945
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
3946
|
+
const response = await fetchImpl(options.actionPath ?? "/api/voice/live-ops/action", {
|
|
3947
|
+
body: JSON.stringify(input),
|
|
3948
|
+
headers: {
|
|
3949
|
+
"Content-Type": "application/json"
|
|
3950
|
+
},
|
|
3951
|
+
method: "POST"
|
|
3952
|
+
});
|
|
3953
|
+
const payload = await response.json().catch(() => null);
|
|
3954
|
+
if (!response.ok || !payload?.ok) {
|
|
3955
|
+
const message = payload && typeof payload === "object" && "error" in payload ? String(payload.error) : `Voice live ops action failed: HTTP ${response.status}`;
|
|
3956
|
+
throw new Error(message);
|
|
3957
|
+
}
|
|
3958
|
+
return payload;
|
|
3959
|
+
};
|
|
3960
|
+
var createVoiceLiveOpsStore = (options = {}) => {
|
|
3961
|
+
const listeners = new Set;
|
|
3962
|
+
let closed = false;
|
|
3963
|
+
let snapshot = {
|
|
3964
|
+
error: null,
|
|
3965
|
+
isRunning: false
|
|
3966
|
+
};
|
|
3967
|
+
const emit = () => {
|
|
3968
|
+
for (const listener of listeners) {
|
|
3969
|
+
listener();
|
|
3970
|
+
}
|
|
3971
|
+
};
|
|
3972
|
+
const run = async (input) => {
|
|
3973
|
+
if (closed) {
|
|
3974
|
+
return snapshot.lastResult;
|
|
3975
|
+
}
|
|
3976
|
+
snapshot = {
|
|
3977
|
+
...snapshot,
|
|
3978
|
+
error: null,
|
|
3979
|
+
isRunning: true,
|
|
3980
|
+
runningAction: input.action
|
|
3981
|
+
};
|
|
3982
|
+
emit();
|
|
3983
|
+
try {
|
|
3984
|
+
const result = await postVoiceLiveOpsAction(input, options);
|
|
3985
|
+
await options.onControl?.(result);
|
|
3986
|
+
snapshot = {
|
|
3987
|
+
...snapshot,
|
|
3988
|
+
error: null,
|
|
3989
|
+
isRunning: false,
|
|
3990
|
+
lastResult: result,
|
|
3991
|
+
runningAction: undefined,
|
|
3992
|
+
updatedAt: Date.now()
|
|
3993
|
+
};
|
|
3994
|
+
emit();
|
|
3995
|
+
return result;
|
|
3996
|
+
} catch (error) {
|
|
3997
|
+
snapshot = {
|
|
3998
|
+
...snapshot,
|
|
3999
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4000
|
+
isRunning: false,
|
|
4001
|
+
runningAction: undefined,
|
|
4002
|
+
updatedAt: Date.now()
|
|
4003
|
+
};
|
|
4004
|
+
emit();
|
|
4005
|
+
throw error;
|
|
4006
|
+
}
|
|
4007
|
+
};
|
|
4008
|
+
const close = () => {
|
|
4009
|
+
closed = true;
|
|
4010
|
+
listeners.clear();
|
|
4011
|
+
};
|
|
4012
|
+
return {
|
|
4013
|
+
close,
|
|
4014
|
+
getServerSnapshot: () => snapshot,
|
|
4015
|
+
getSnapshot: () => snapshot,
|
|
4016
|
+
run,
|
|
4017
|
+
subscribe: (listener) => {
|
|
4018
|
+
listeners.add(listener);
|
|
4019
|
+
return () => {
|
|
4020
|
+
listeners.delete(listener);
|
|
4021
|
+
};
|
|
4022
|
+
}
|
|
4023
|
+
};
|
|
4024
|
+
};
|
|
4025
|
+
|
|
4026
|
+
// src/react/useVoiceLiveOps.tsx
|
|
4027
|
+
var useVoiceLiveOps = (options = {}) => {
|
|
4028
|
+
const storeRef = useRef14(null);
|
|
4029
|
+
if (!storeRef.current) {
|
|
4030
|
+
storeRef.current = createVoiceLiveOpsStore(options);
|
|
4031
|
+
}
|
|
4032
|
+
const store = storeRef.current;
|
|
4033
|
+
useEffect14(() => () => store.close(), [store]);
|
|
4034
|
+
return {
|
|
4035
|
+
...useSyncExternalStore14(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
4036
|
+
run: store.run
|
|
4037
|
+
};
|
|
4038
|
+
};
|
|
4039
|
+
// src/react/useVoiceCampaignDialerProof.tsx
|
|
4040
|
+
import { useEffect as useEffect15, useRef as useRef15, useSyncExternalStore as useSyncExternalStore15 } from "react";
|
|
4041
|
+
|
|
4042
|
+
// src/client/campaignDialerProof.ts
|
|
4043
|
+
var fetchVoiceCampaignDialerProofStatus = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
|
|
4044
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
4045
|
+
const response = await fetchImpl(path);
|
|
4046
|
+
if (!response.ok) {
|
|
4047
|
+
throw new Error(`Voice campaign dialer proof status failed: HTTP ${response.status}`);
|
|
4048
|
+
}
|
|
4049
|
+
return await response.json();
|
|
4050
|
+
};
|
|
4051
|
+
var runVoiceCampaignDialerProofAction = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
|
|
4052
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
4053
|
+
const response = await fetchImpl(path, { method: "POST" });
|
|
4054
|
+
if (!response.ok) {
|
|
4055
|
+
throw new Error(`Voice campaign dialer proof failed: HTTP ${response.status}`);
|
|
4056
|
+
}
|
|
4057
|
+
return await response.json();
|
|
4058
|
+
};
|
|
4059
|
+
var createVoiceCampaignDialerProofStore = (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
|
|
4060
|
+
const listeners = new Set;
|
|
4061
|
+
let closed = false;
|
|
4062
|
+
let timer;
|
|
4063
|
+
let snapshot = {
|
|
4064
|
+
error: null,
|
|
4065
|
+
isLoading: false
|
|
4066
|
+
};
|
|
4067
|
+
const emit = () => {
|
|
4068
|
+
for (const listener of listeners) {
|
|
4069
|
+
listener();
|
|
4070
|
+
}
|
|
4071
|
+
};
|
|
4072
|
+
const refresh = async () => {
|
|
4073
|
+
if (closed) {
|
|
4074
|
+
return snapshot.status;
|
|
4075
|
+
}
|
|
4076
|
+
snapshot = { ...snapshot, error: null, isLoading: true };
|
|
4077
|
+
emit();
|
|
4078
|
+
try {
|
|
4079
|
+
const status = await fetchVoiceCampaignDialerProofStatus(path, options);
|
|
4080
|
+
snapshot = {
|
|
4081
|
+
...snapshot,
|
|
4082
|
+
error: null,
|
|
4083
|
+
isLoading: false,
|
|
4084
|
+
status,
|
|
4085
|
+
updatedAt: Date.now()
|
|
4086
|
+
};
|
|
4087
|
+
emit();
|
|
4088
|
+
return status;
|
|
4089
|
+
} catch (error) {
|
|
4090
|
+
snapshot = {
|
|
4091
|
+
...snapshot,
|
|
4092
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4093
|
+
isLoading: false
|
|
4094
|
+
};
|
|
4095
|
+
emit();
|
|
4096
|
+
throw error;
|
|
4097
|
+
}
|
|
4098
|
+
};
|
|
4099
|
+
const runProof = async () => {
|
|
4100
|
+
const runPath = options.runPath ?? snapshot.status?.runPath ?? path;
|
|
4101
|
+
snapshot = { ...snapshot, error: null, isLoading: true };
|
|
4102
|
+
emit();
|
|
4103
|
+
try {
|
|
4104
|
+
const report = await runVoiceCampaignDialerProofAction(runPath, options);
|
|
4105
|
+
snapshot = {
|
|
4106
|
+
...snapshot,
|
|
4107
|
+
error: null,
|
|
4108
|
+
isLoading: false,
|
|
4109
|
+
report,
|
|
4110
|
+
status: {
|
|
4111
|
+
generatedAt: Date.now(),
|
|
4112
|
+
mode: report.mode,
|
|
4113
|
+
ok: report.ok,
|
|
4114
|
+
providers: report.providers.map((provider) => provider.provider),
|
|
4115
|
+
runPath,
|
|
4116
|
+
safe: true
|
|
4117
|
+
},
|
|
4118
|
+
updatedAt: Date.now()
|
|
4119
|
+
};
|
|
4120
|
+
emit();
|
|
4121
|
+
return report;
|
|
4122
|
+
} catch (error) {
|
|
4123
|
+
snapshot = {
|
|
4124
|
+
...snapshot,
|
|
4125
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4126
|
+
isLoading: false
|
|
4127
|
+
};
|
|
4128
|
+
emit();
|
|
4129
|
+
throw error;
|
|
4130
|
+
}
|
|
4131
|
+
};
|
|
4132
|
+
const close = () => {
|
|
4133
|
+
closed = true;
|
|
4134
|
+
if (timer) {
|
|
4135
|
+
clearInterval(timer);
|
|
4136
|
+
timer = undefined;
|
|
4137
|
+
}
|
|
4138
|
+
listeners.clear();
|
|
4139
|
+
};
|
|
4140
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
4141
|
+
timer = setInterval(() => {
|
|
4142
|
+
refresh().catch(() => {});
|
|
4143
|
+
}, options.intervalMs);
|
|
4144
|
+
}
|
|
4145
|
+
return {
|
|
4146
|
+
close,
|
|
4147
|
+
getServerSnapshot: () => snapshot,
|
|
4148
|
+
getSnapshot: () => snapshot,
|
|
4149
|
+
refresh,
|
|
4150
|
+
runProof,
|
|
4151
|
+
subscribe: (listener) => {
|
|
4152
|
+
listeners.add(listener);
|
|
4153
|
+
return () => {
|
|
4154
|
+
listeners.delete(listener);
|
|
4155
|
+
};
|
|
4156
|
+
}
|
|
4157
|
+
};
|
|
4158
|
+
};
|
|
4159
|
+
|
|
4160
|
+
// src/react/useVoiceCampaignDialerProof.tsx
|
|
4161
|
+
var useVoiceCampaignDialerProof = (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
|
|
4162
|
+
const storeRef = useRef15(null);
|
|
4163
|
+
if (!storeRef.current) {
|
|
4164
|
+
storeRef.current = createVoiceCampaignDialerProofStore(path, options);
|
|
4165
|
+
}
|
|
4166
|
+
const store = storeRef.current;
|
|
4167
|
+
useEffect15(() => {
|
|
4168
|
+
store.refresh().catch(() => {});
|
|
4169
|
+
return () => store.close();
|
|
4170
|
+
}, [store]);
|
|
4171
|
+
return {
|
|
4172
|
+
...useSyncExternalStore15(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
4173
|
+
refresh: store.refresh,
|
|
4174
|
+
runProof: store.runProof
|
|
4175
|
+
};
|
|
4176
|
+
};
|
|
72
4177
|
// src/react/useVoiceStream.tsx
|
|
73
|
-
import { useEffect, useRef, useSyncExternalStore } from "react";
|
|
4178
|
+
import { useEffect as useEffect16, useRef as useRef16, useSyncExternalStore as useSyncExternalStore16 } from "react";
|
|
74
4179
|
|
|
75
4180
|
// src/client/actions.ts
|
|
76
4181
|
var normalizeErrorMessage = (value) => {
|
|
@@ -120,6 +4225,17 @@ var serverMessageToAction = (message) => {
|
|
|
120
4225
|
sessionId: message.sessionId,
|
|
121
4226
|
type: "complete"
|
|
122
4227
|
};
|
|
4228
|
+
case "connection":
|
|
4229
|
+
return {
|
|
4230
|
+
reconnect: message.reconnect,
|
|
4231
|
+
type: "connection"
|
|
4232
|
+
};
|
|
4233
|
+
case "call_lifecycle":
|
|
4234
|
+
return {
|
|
4235
|
+
event: message.event,
|
|
4236
|
+
sessionId: message.sessionId,
|
|
4237
|
+
type: "call_lifecycle"
|
|
4238
|
+
};
|
|
123
4239
|
case "error":
|
|
124
4240
|
return {
|
|
125
4241
|
message: normalizeErrorMessage(message.message),
|
|
@@ -135,6 +4251,17 @@ var serverMessageToAction = (message) => {
|
|
|
135
4251
|
transcript: message.transcript,
|
|
136
4252
|
type: "partial"
|
|
137
4253
|
};
|
|
4254
|
+
case "replay":
|
|
4255
|
+
return {
|
|
4256
|
+
assistantTexts: message.assistantTexts,
|
|
4257
|
+
call: message.call,
|
|
4258
|
+
partial: message.partial,
|
|
4259
|
+
scenarioId: message.scenarioId,
|
|
4260
|
+
sessionId: message.sessionId,
|
|
4261
|
+
status: message.status,
|
|
4262
|
+
turns: message.turns,
|
|
4263
|
+
type: "replay"
|
|
4264
|
+
};
|
|
138
4265
|
case "session":
|
|
139
4266
|
return {
|
|
140
4267
|
sessionId: message.sessionId,
|
|
@@ -163,7 +4290,7 @@ var DEFAULT_SCENARIO_QUERY_PARAM = "scenarioId";
|
|
|
163
4290
|
var noop = () => {};
|
|
164
4291
|
var noopUnsubscribe = () => noop;
|
|
165
4292
|
var NOOP_CONNECTION = {
|
|
166
|
-
|
|
4293
|
+
callControl: noop,
|
|
167
4294
|
close: noop,
|
|
168
4295
|
endTurn: noop,
|
|
169
4296
|
getReadyState: () => WS_CLOSED,
|
|
@@ -171,6 +4298,7 @@ var NOOP_CONNECTION = {
|
|
|
171
4298
|
getSessionId: () => "",
|
|
172
4299
|
send: noop,
|
|
173
4300
|
sendAudio: noop,
|
|
4301
|
+
start: () => {},
|
|
174
4302
|
subscribe: noopUnsubscribe
|
|
175
4303
|
};
|
|
176
4304
|
var createSessionId = () => crypto.randomUUID();
|
|
@@ -192,11 +4320,14 @@ var isVoiceServerMessage = (value) => {
|
|
|
192
4320
|
switch (value.type) {
|
|
193
4321
|
case "audio":
|
|
194
4322
|
case "assistant":
|
|
4323
|
+
case "call_lifecycle":
|
|
195
4324
|
case "complete":
|
|
4325
|
+
case "connection":
|
|
196
4326
|
case "error":
|
|
197
4327
|
case "final":
|
|
198
4328
|
case "partial":
|
|
199
4329
|
case "pong":
|
|
4330
|
+
case "replay":
|
|
200
4331
|
case "session":
|
|
201
4332
|
case "turn":
|
|
202
4333
|
return true;
|
|
@@ -233,6 +4364,9 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
233
4364
|
sessionId: options.sessionId ?? createSessionId(),
|
|
234
4365
|
ws: null
|
|
235
4366
|
};
|
|
4367
|
+
const emitConnection = (reconnect) => {
|
|
4368
|
+
listeners.forEach((listener) => listener(reconnect));
|
|
4369
|
+
};
|
|
236
4370
|
const clearTimers = () => {
|
|
237
4371
|
if (state.pingInterval) {
|
|
238
4372
|
clearInterval(state.pingInterval);
|
|
@@ -255,9 +4389,28 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
255
4389
|
}
|
|
256
4390
|
};
|
|
257
4391
|
const scheduleReconnect = () => {
|
|
4392
|
+
const nextAttemptAt = Date.now() + RECONNECT_DELAY_MS;
|
|
258
4393
|
state.reconnectAttempts += 1;
|
|
4394
|
+
emitConnection({
|
|
4395
|
+
reconnect: {
|
|
4396
|
+
attempts: state.reconnectAttempts,
|
|
4397
|
+
lastDisconnectAt: Date.now(),
|
|
4398
|
+
maxAttempts: maxReconnectAttempts,
|
|
4399
|
+
nextAttemptAt,
|
|
4400
|
+
status: "reconnecting"
|
|
4401
|
+
},
|
|
4402
|
+
type: "connection"
|
|
4403
|
+
});
|
|
259
4404
|
state.reconnectTimeout = setTimeout(() => {
|
|
260
4405
|
if (state.reconnectAttempts > maxReconnectAttempts) {
|
|
4406
|
+
emitConnection({
|
|
4407
|
+
reconnect: {
|
|
4408
|
+
attempts: state.reconnectAttempts,
|
|
4409
|
+
maxAttempts: maxReconnectAttempts,
|
|
4410
|
+
status: "exhausted"
|
|
4411
|
+
},
|
|
4412
|
+
type: "connection"
|
|
4413
|
+
});
|
|
261
4414
|
return;
|
|
262
4415
|
}
|
|
263
4416
|
connect();
|
|
@@ -267,9 +4420,21 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
267
4420
|
const ws = new WebSocket(buildWsUrl(path, state.sessionId, state.scenarioId));
|
|
268
4421
|
ws.binaryType = "arraybuffer";
|
|
269
4422
|
ws.onopen = () => {
|
|
4423
|
+
const wasReconnecting = state.reconnectAttempts > 0;
|
|
270
4424
|
state.isConnected = true;
|
|
271
|
-
state.reconnectAttempts = 0;
|
|
272
4425
|
flushPendingMessages();
|
|
4426
|
+
if (wasReconnecting) {
|
|
4427
|
+
emitConnection({
|
|
4428
|
+
reconnect: {
|
|
4429
|
+
attempts: state.reconnectAttempts,
|
|
4430
|
+
lastResumedAt: Date.now(),
|
|
4431
|
+
maxAttempts: maxReconnectAttempts,
|
|
4432
|
+
status: "resumed"
|
|
4433
|
+
},
|
|
4434
|
+
type: "connection"
|
|
4435
|
+
});
|
|
4436
|
+
state.reconnectAttempts = 0;
|
|
4437
|
+
}
|
|
273
4438
|
listeners.forEach((listener) => listener({
|
|
274
4439
|
scenarioId: state.scenarioId ?? undefined,
|
|
275
4440
|
sessionId: state.sessionId,
|
|
@@ -299,6 +4464,16 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
299
4464
|
const reconnectable = shouldReconnect && event.code !== WS_NORMAL_CLOSURE && state.reconnectAttempts < maxReconnectAttempts;
|
|
300
4465
|
if (reconnectable) {
|
|
301
4466
|
scheduleReconnect();
|
|
4467
|
+
} else if (shouldReconnect && event.code !== WS_NORMAL_CLOSURE) {
|
|
4468
|
+
emitConnection({
|
|
4469
|
+
reconnect: {
|
|
4470
|
+
attempts: state.reconnectAttempts,
|
|
4471
|
+
lastDisconnectAt: Date.now(),
|
|
4472
|
+
maxAttempts: maxReconnectAttempts,
|
|
4473
|
+
status: "exhausted"
|
|
4474
|
+
},
|
|
4475
|
+
type: "connection"
|
|
4476
|
+
});
|
|
302
4477
|
}
|
|
303
4478
|
};
|
|
304
4479
|
state.ws = ws;
|
|
@@ -332,6 +4507,12 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
332
4507
|
const endTurn = () => {
|
|
333
4508
|
send({ type: "end_turn" });
|
|
334
4509
|
};
|
|
4510
|
+
const callControl = (message) => {
|
|
4511
|
+
send({
|
|
4512
|
+
...message,
|
|
4513
|
+
type: "call_control"
|
|
4514
|
+
});
|
|
4515
|
+
};
|
|
335
4516
|
const close = () => {
|
|
336
4517
|
clearTimers();
|
|
337
4518
|
if (state.ws) {
|
|
@@ -349,7 +4530,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
349
4530
|
};
|
|
350
4531
|
connect();
|
|
351
4532
|
return {
|
|
352
|
-
|
|
4533
|
+
callControl,
|
|
353
4534
|
close,
|
|
354
4535
|
endTurn,
|
|
355
4536
|
getReadyState: () => state.ws?.readyState ?? WS_CLOSED,
|
|
@@ -357,18 +4538,26 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
357
4538
|
getSessionId: () => state.sessionId,
|
|
358
4539
|
send,
|
|
359
4540
|
sendAudio,
|
|
4541
|
+
start,
|
|
360
4542
|
subscribe
|
|
361
4543
|
};
|
|
362
4544
|
};
|
|
363
4545
|
|
|
364
4546
|
// src/client/store.ts
|
|
4547
|
+
var createInitialReconnectState = () => ({
|
|
4548
|
+
attempts: 0,
|
|
4549
|
+
maxAttempts: 0,
|
|
4550
|
+
status: "idle"
|
|
4551
|
+
});
|
|
365
4552
|
var createInitialState = () => ({
|
|
366
4553
|
assistantAudio: [],
|
|
367
4554
|
assistantTexts: [],
|
|
4555
|
+
call: null,
|
|
368
4556
|
error: null,
|
|
369
4557
|
isConnected: false,
|
|
370
4558
|
scenarioId: null,
|
|
371
4559
|
partial: "",
|
|
4560
|
+
reconnect: createInitialReconnectState(),
|
|
372
4561
|
sessionId: null,
|
|
373
4562
|
status: "idle",
|
|
374
4563
|
turns: []
|
|
@@ -408,10 +4597,36 @@ var createVoiceStreamStore = () => {
|
|
|
408
4597
|
status: "completed"
|
|
409
4598
|
};
|
|
410
4599
|
break;
|
|
4600
|
+
case "call_lifecycle":
|
|
4601
|
+
state = {
|
|
4602
|
+
...state,
|
|
4603
|
+
call: {
|
|
4604
|
+
...state.call,
|
|
4605
|
+
disposition: action.event.type === "end" ? action.event.disposition : state.call?.disposition,
|
|
4606
|
+
endedAt: action.event.type === "end" ? action.event.at : state.call?.endedAt,
|
|
4607
|
+
events: [...state.call?.events ?? [], action.event],
|
|
4608
|
+
lastEventAt: action.event.at,
|
|
4609
|
+
startedAt: state.call?.startedAt ?? action.event.at
|
|
4610
|
+
},
|
|
4611
|
+
sessionId: action.sessionId
|
|
4612
|
+
};
|
|
4613
|
+
break;
|
|
411
4614
|
case "connected":
|
|
412
4615
|
state = {
|
|
413
4616
|
...state,
|
|
414
|
-
isConnected: true
|
|
4617
|
+
isConnected: true,
|
|
4618
|
+
reconnect: state.reconnect.status === "reconnecting" ? {
|
|
4619
|
+
...state.reconnect,
|
|
4620
|
+
lastResumedAt: Date.now(),
|
|
4621
|
+
nextAttemptAt: undefined,
|
|
4622
|
+
status: "resumed"
|
|
4623
|
+
} : state.reconnect
|
|
4624
|
+
};
|
|
4625
|
+
break;
|
|
4626
|
+
case "connection":
|
|
4627
|
+
state = {
|
|
4628
|
+
...state,
|
|
4629
|
+
reconnect: action.reconnect
|
|
415
4630
|
};
|
|
416
4631
|
break;
|
|
417
4632
|
case "disconnected":
|
|
@@ -439,6 +4654,26 @@ var createVoiceStreamStore = () => {
|
|
|
439
4654
|
partial: action.transcript.text
|
|
440
4655
|
};
|
|
441
4656
|
break;
|
|
4657
|
+
case "replay":
|
|
4658
|
+
state = {
|
|
4659
|
+
...state,
|
|
4660
|
+
assistantTexts: [...action.assistantTexts],
|
|
4661
|
+
call: action.call ?? null,
|
|
4662
|
+
error: null,
|
|
4663
|
+
isConnected: action.status === "active",
|
|
4664
|
+
partial: action.partial,
|
|
4665
|
+
reconnect: state.reconnect.status === "reconnecting" ? {
|
|
4666
|
+
...state.reconnect,
|
|
4667
|
+
lastResumedAt: Date.now(),
|
|
4668
|
+
nextAttemptAt: undefined,
|
|
4669
|
+
status: "resumed"
|
|
4670
|
+
} : state.reconnect,
|
|
4671
|
+
scenarioId: action.scenarioId ?? state.scenarioId,
|
|
4672
|
+
sessionId: action.sessionId,
|
|
4673
|
+
status: action.status,
|
|
4674
|
+
turns: [...action.turns]
|
|
4675
|
+
};
|
|
4676
|
+
break;
|
|
442
4677
|
case "session":
|
|
443
4678
|
state = {
|
|
444
4679
|
...state,
|
|
@@ -486,14 +4721,41 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
486
4721
|
const notify = () => {
|
|
487
4722
|
subscribers.forEach((subscriber) => subscriber());
|
|
488
4723
|
};
|
|
4724
|
+
const reportReconnect = () => {
|
|
4725
|
+
if (!options.reconnectReportPath || typeof fetch === "undefined") {
|
|
4726
|
+
return;
|
|
4727
|
+
}
|
|
4728
|
+
const snapshot = store.getSnapshot();
|
|
4729
|
+
const body = JSON.stringify({
|
|
4730
|
+
at: Date.now(),
|
|
4731
|
+
reconnect: snapshot.reconnect,
|
|
4732
|
+
scenarioId: snapshot.scenarioId,
|
|
4733
|
+
sessionId: connection.getSessionId(),
|
|
4734
|
+
turnIds: snapshot.turns.map((turn) => turn.id)
|
|
4735
|
+
});
|
|
4736
|
+
fetch(options.reconnectReportPath, {
|
|
4737
|
+
body,
|
|
4738
|
+
headers: {
|
|
4739
|
+
"Content-Type": "application/json"
|
|
4740
|
+
},
|
|
4741
|
+
keepalive: true,
|
|
4742
|
+
method: "POST"
|
|
4743
|
+
}).catch(() => {});
|
|
4744
|
+
};
|
|
489
4745
|
const unsubscribeConnection = connection.subscribe((message) => {
|
|
490
4746
|
const action = serverMessageToAction(message);
|
|
491
4747
|
if (action) {
|
|
492
4748
|
store.dispatch(action);
|
|
4749
|
+
if (message.type === "connection") {
|
|
4750
|
+
reportReconnect();
|
|
4751
|
+
}
|
|
493
4752
|
notify();
|
|
494
4753
|
}
|
|
495
4754
|
});
|
|
496
4755
|
return {
|
|
4756
|
+
callControl(message) {
|
|
4757
|
+
connection.callControl(message);
|
|
4758
|
+
},
|
|
497
4759
|
close() {
|
|
498
4760
|
unsubscribeConnection();
|
|
499
4761
|
connection.close();
|
|
@@ -522,6 +4784,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
522
4784
|
get partial() {
|
|
523
4785
|
return store.getSnapshot().partial;
|
|
524
4786
|
},
|
|
4787
|
+
get reconnect() {
|
|
4788
|
+
return store.getSnapshot().reconnect;
|
|
4789
|
+
},
|
|
525
4790
|
get sessionId() {
|
|
526
4791
|
return connection.getSessionId();
|
|
527
4792
|
},
|
|
@@ -537,6 +4802,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
537
4802
|
get assistantAudio() {
|
|
538
4803
|
return store.getSnapshot().assistantAudio;
|
|
539
4804
|
},
|
|
4805
|
+
get call() {
|
|
4806
|
+
return store.getSnapshot().call;
|
|
4807
|
+
},
|
|
540
4808
|
sendAudio(audio) {
|
|
541
4809
|
connection.sendAudio(audio);
|
|
542
4810
|
},
|
|
@@ -553,30 +4821,37 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
553
4821
|
var EMPTY_SNAPSHOT = {
|
|
554
4822
|
assistantAudio: [],
|
|
555
4823
|
assistantTexts: [],
|
|
4824
|
+
call: null,
|
|
556
4825
|
error: null,
|
|
557
4826
|
isConnected: false,
|
|
558
4827
|
partial: "",
|
|
4828
|
+
reconnect: {
|
|
4829
|
+
attempts: 0,
|
|
4830
|
+
maxAttempts: 0,
|
|
4831
|
+
status: "idle"
|
|
4832
|
+
},
|
|
559
4833
|
sessionId: "",
|
|
560
4834
|
status: "idle",
|
|
561
4835
|
turns: []
|
|
562
4836
|
};
|
|
563
4837
|
var useVoiceStream = (path, options = {}) => {
|
|
564
|
-
const streamRef =
|
|
4838
|
+
const streamRef = useRef16(null);
|
|
565
4839
|
if (!streamRef.current) {
|
|
566
4840
|
streamRef.current = createVoiceStream(path, options);
|
|
567
4841
|
}
|
|
568
4842
|
const stream = streamRef.current;
|
|
569
|
-
|
|
570
|
-
const snapshot =
|
|
4843
|
+
useEffect16(() => () => stream.close(), [stream]);
|
|
4844
|
+
const snapshot = useSyncExternalStore16(stream.subscribe, stream.getSnapshot, stream.getServerSnapshot) ?? EMPTY_SNAPSHOT;
|
|
571
4845
|
return {
|
|
572
4846
|
...snapshot,
|
|
4847
|
+
callControl: (message) => stream.callControl(message),
|
|
573
4848
|
close: () => stream.close(),
|
|
574
4849
|
endTurn: () => stream.endTurn(),
|
|
575
4850
|
sendAudio: (audio) => stream.sendAudio(audio)
|
|
576
4851
|
};
|
|
577
4852
|
};
|
|
578
4853
|
// src/react/useVoiceController.tsx
|
|
579
|
-
import { useEffect as
|
|
4854
|
+
import { useEffect as useEffect17, useRef as useRef17, useSyncExternalStore as useSyncExternalStore17 } from "react";
|
|
580
4855
|
|
|
581
4856
|
// src/client/htmx.ts
|
|
582
4857
|
var DEFAULT_EVENT_NAME = "voice-refresh";
|
|
@@ -1040,10 +5315,12 @@ var resolveVoiceRuntimePreset = (name = "default") => {
|
|
|
1040
5315
|
var createInitialState2 = (stream) => ({
|
|
1041
5316
|
assistantAudio: [...stream.assistantAudio],
|
|
1042
5317
|
assistantTexts: [...stream.assistantTexts],
|
|
5318
|
+
call: stream.call,
|
|
1043
5319
|
error: stream.error,
|
|
1044
5320
|
isConnected: stream.isConnected,
|
|
1045
5321
|
isRecording: false,
|
|
1046
5322
|
partial: stream.partial,
|
|
5323
|
+
reconnect: stream.reconnect,
|
|
1047
5324
|
recordingError: null,
|
|
1048
5325
|
sessionId: stream.sessionId,
|
|
1049
5326
|
scenarioId: stream.scenarioId,
|
|
@@ -1069,9 +5346,11 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1069
5346
|
...state,
|
|
1070
5347
|
assistantAudio: [...stream.assistantAudio],
|
|
1071
5348
|
assistantTexts: [...stream.assistantTexts],
|
|
5349
|
+
call: stream.call,
|
|
1072
5350
|
error: stream.error,
|
|
1073
5351
|
isConnected: stream.isConnected,
|
|
1074
5352
|
partial: stream.partial,
|
|
5353
|
+
reconnect: stream.reconnect,
|
|
1075
5354
|
sessionId: stream.sessionId,
|
|
1076
5355
|
scenarioId: stream.scenarioId,
|
|
1077
5356
|
status: stream.status,
|
|
@@ -1096,7 +5375,13 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1096
5375
|
capture = createMicrophoneCapture({
|
|
1097
5376
|
channelCount: options.capture?.channelCount ?? preset.capture.channelCount,
|
|
1098
5377
|
onLevel: options.capture?.onLevel,
|
|
1099
|
-
onAudio: (audio) =>
|
|
5378
|
+
onAudio: (audio) => {
|
|
5379
|
+
if (options.capture?.onAudio) {
|
|
5380
|
+
options.capture.onAudio(audio, stream.sendAudio);
|
|
5381
|
+
return;
|
|
5382
|
+
}
|
|
5383
|
+
stream.sendAudio(audio);
|
|
5384
|
+
},
|
|
1100
5385
|
sampleRateHz: options.capture?.sampleRateHz ?? preset.capture.sampleRateHz
|
|
1101
5386
|
});
|
|
1102
5387
|
return capture;
|
|
@@ -1146,6 +5431,7 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1146
5431
|
bindHTMX(bindingOptions) {
|
|
1147
5432
|
return bindVoiceHTMX(stream, bindingOptions);
|
|
1148
5433
|
},
|
|
5434
|
+
callControl: (message) => stream.callControl(message),
|
|
1149
5435
|
close,
|
|
1150
5436
|
endTurn: () => stream.endTurn(),
|
|
1151
5437
|
get error() {
|
|
@@ -1165,6 +5451,9 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1165
5451
|
get recordingError() {
|
|
1166
5452
|
return state.recordingError;
|
|
1167
5453
|
},
|
|
5454
|
+
get reconnect() {
|
|
5455
|
+
return state.reconnect;
|
|
5456
|
+
},
|
|
1168
5457
|
sendAudio: (audio) => stream.sendAudio(audio),
|
|
1169
5458
|
get sessionId() {
|
|
1170
5459
|
return state.sessionId;
|
|
@@ -1198,6 +5487,9 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1198
5487
|
},
|
|
1199
5488
|
get assistantAudio() {
|
|
1200
5489
|
return state.assistantAudio;
|
|
5490
|
+
},
|
|
5491
|
+
get call() {
|
|
5492
|
+
return state.call;
|
|
1201
5493
|
}
|
|
1202
5494
|
};
|
|
1203
5495
|
};
|
|
@@ -1206,26 +5498,33 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1206
5498
|
var EMPTY_SNAPSHOT2 = {
|
|
1207
5499
|
assistantAudio: [],
|
|
1208
5500
|
assistantTexts: [],
|
|
5501
|
+
call: null,
|
|
1209
5502
|
error: null,
|
|
1210
5503
|
isConnected: false,
|
|
1211
5504
|
isRecording: false,
|
|
1212
5505
|
partial: "",
|
|
5506
|
+
reconnect: {
|
|
5507
|
+
attempts: 0,
|
|
5508
|
+
maxAttempts: 0,
|
|
5509
|
+
status: "idle"
|
|
5510
|
+
},
|
|
1213
5511
|
recordingError: null,
|
|
1214
5512
|
sessionId: "",
|
|
1215
5513
|
status: "idle",
|
|
1216
5514
|
turns: []
|
|
1217
5515
|
};
|
|
1218
5516
|
var useVoiceController = (path, options = {}) => {
|
|
1219
|
-
const controllerRef =
|
|
5517
|
+
const controllerRef = useRef17(null);
|
|
1220
5518
|
if (!controllerRef.current) {
|
|
1221
5519
|
controllerRef.current = createVoiceController(path, options);
|
|
1222
5520
|
}
|
|
1223
5521
|
const controller = controllerRef.current;
|
|
1224
|
-
|
|
1225
|
-
const snapshot =
|
|
5522
|
+
useEffect17(() => () => controller.close(), [controller]);
|
|
5523
|
+
const snapshot = useSyncExternalStore17(controller.subscribe, controller.getSnapshot, controller.getServerSnapshot) ?? EMPTY_SNAPSHOT2;
|
|
1226
5524
|
return {
|
|
1227
5525
|
...snapshot,
|
|
1228
5526
|
bindHTMX: controller.bindHTMX,
|
|
5527
|
+
callControl: (message) => controller.callControl(message),
|
|
1229
5528
|
close: () => controller.close(),
|
|
1230
5529
|
endTurn: () => controller.endTurn(),
|
|
1231
5530
|
sendAudio: (audio) => controller.sendAudio(audio),
|
|
@@ -1234,26 +5533,25 @@ var useVoiceController = (path, options = {}) => {
|
|
|
1234
5533
|
toggleRecording: () => controller.toggleRecording()
|
|
1235
5534
|
};
|
|
1236
5535
|
};
|
|
1237
|
-
// src/react/
|
|
1238
|
-
import { useEffect as
|
|
5536
|
+
// src/react/useVoiceWorkflowStatus.tsx
|
|
5537
|
+
import { useEffect as useEffect18, useRef as useRef18, useSyncExternalStore as useSyncExternalStore18 } from "react";
|
|
1239
5538
|
|
|
1240
|
-
// src/client/
|
|
1241
|
-
var
|
|
5539
|
+
// src/client/workflowStatus.ts
|
|
5540
|
+
var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
|
|
1242
5541
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1243
5542
|
const response = await fetchImpl(path);
|
|
1244
5543
|
if (!response.ok) {
|
|
1245
|
-
throw new Error(`Voice
|
|
5544
|
+
throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
|
|
1246
5545
|
}
|
|
1247
5546
|
return await response.json();
|
|
1248
5547
|
};
|
|
1249
|
-
var
|
|
5548
|
+
var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
|
|
1250
5549
|
const listeners = new Set;
|
|
1251
5550
|
let closed = false;
|
|
1252
5551
|
let timer;
|
|
1253
5552
|
let snapshot = {
|
|
1254
5553
|
error: null,
|
|
1255
|
-
isLoading: false
|
|
1256
|
-
providers: []
|
|
5554
|
+
isLoading: false
|
|
1257
5555
|
};
|
|
1258
5556
|
const emit = () => {
|
|
1259
5557
|
for (const listener of listeners) {
|
|
@@ -1262,7 +5560,7 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
|
|
|
1262
5560
|
};
|
|
1263
5561
|
const refresh = async () => {
|
|
1264
5562
|
if (closed) {
|
|
1265
|
-
return snapshot.
|
|
5563
|
+
return snapshot.report;
|
|
1266
5564
|
}
|
|
1267
5565
|
snapshot = {
|
|
1268
5566
|
...snapshot,
|
|
@@ -1271,15 +5569,15 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
|
|
|
1271
5569
|
};
|
|
1272
5570
|
emit();
|
|
1273
5571
|
try {
|
|
1274
|
-
const
|
|
5572
|
+
const report = await fetchVoiceWorkflowStatus(path, options);
|
|
1275
5573
|
snapshot = {
|
|
1276
5574
|
error: null,
|
|
1277
5575
|
isLoading: false,
|
|
1278
|
-
|
|
5576
|
+
report,
|
|
1279
5577
|
updatedAt: Date.now()
|
|
1280
5578
|
};
|
|
1281
5579
|
emit();
|
|
1282
|
-
return
|
|
5580
|
+
return report;
|
|
1283
5581
|
} catch (error) {
|
|
1284
5582
|
snapshot = {
|
|
1285
5583
|
...snapshot,
|
|
@@ -1298,7 +5596,7 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
|
|
|
1298
5596
|
}
|
|
1299
5597
|
listeners.clear();
|
|
1300
5598
|
};
|
|
1301
|
-
if (options.intervalMs && options.intervalMs > 0) {
|
|
5599
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
1302
5600
|
timer = setInterval(() => {
|
|
1303
5601
|
refresh().catch(() => {});
|
|
1304
5602
|
}, options.intervalMs);
|
|
@@ -1317,24 +5615,52 @@ var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {
|
|
|
1317
5615
|
};
|
|
1318
5616
|
};
|
|
1319
5617
|
|
|
1320
|
-
// src/react/
|
|
1321
|
-
var
|
|
1322
|
-
const storeRef =
|
|
5618
|
+
// src/react/useVoiceWorkflowStatus.tsx
|
|
5619
|
+
var useVoiceWorkflowStatus = (path = "/evals/scenarios/json", options = {}) => {
|
|
5620
|
+
const storeRef = useRef18(null);
|
|
1323
5621
|
if (!storeRef.current) {
|
|
1324
|
-
storeRef.current =
|
|
5622
|
+
storeRef.current = createVoiceWorkflowStatusStore(path, options);
|
|
1325
5623
|
}
|
|
1326
5624
|
const store = storeRef.current;
|
|
1327
|
-
|
|
5625
|
+
useEffect18(() => {
|
|
1328
5626
|
store.refresh().catch(() => {});
|
|
1329
5627
|
return () => store.close();
|
|
1330
5628
|
}, [store]);
|
|
1331
5629
|
return {
|
|
1332
|
-
...
|
|
5630
|
+
...useSyncExternalStore18(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
1333
5631
|
refresh: store.refresh
|
|
1334
5632
|
};
|
|
1335
5633
|
};
|
|
1336
5634
|
export {
|
|
5635
|
+
useVoiceWorkflowStatus,
|
|
5636
|
+
useVoiceTurnQuality,
|
|
5637
|
+
useVoiceTurnLatency,
|
|
5638
|
+
useVoiceTraceTimeline,
|
|
1337
5639
|
useVoiceStream,
|
|
5640
|
+
useVoiceRoutingStatus,
|
|
1338
5641
|
useVoiceProviderStatus,
|
|
1339
|
-
|
|
5642
|
+
useVoiceProviderSimulationControls,
|
|
5643
|
+
useVoiceProviderContracts,
|
|
5644
|
+
useVoiceProviderCapabilities,
|
|
5645
|
+
useVoicePlatformCoverage,
|
|
5646
|
+
useVoiceOpsStatus,
|
|
5647
|
+
useVoiceOpsActionCenter,
|
|
5648
|
+
useVoiceLiveOps,
|
|
5649
|
+
useVoiceDeliveryRuntime,
|
|
5650
|
+
useVoiceController,
|
|
5651
|
+
useVoiceCampaignDialerProof,
|
|
5652
|
+
useVoiceAgentSquadStatus,
|
|
5653
|
+
VoiceTurnQuality,
|
|
5654
|
+
VoiceTurnLatency,
|
|
5655
|
+
VoiceTraceTimeline,
|
|
5656
|
+
VoiceRoutingStatus,
|
|
5657
|
+
VoiceProviderStatus,
|
|
5658
|
+
VoiceProviderSimulationControls,
|
|
5659
|
+
VoiceProviderContracts,
|
|
5660
|
+
VoiceProviderCapabilities,
|
|
5661
|
+
VoicePlatformCoverage,
|
|
5662
|
+
VoiceOpsStatus,
|
|
5663
|
+
VoiceOpsActionCenter,
|
|
5664
|
+
VoiceDeliveryRuntime,
|
|
5665
|
+
VoiceAgentSquadStatus
|
|
1340
5666
|
};
|