@absolutejs/voice 0.0.22-beta.7 → 0.0.22-beta.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +205 -0
- package/dist/agent.d.ts +2 -0
- package/dist/angular/index.d.ts +6 -0
- package/dist/angular/index.js +833 -43
- package/dist/angular/voice-app-kit-status.service.d.ts +12 -0
- package/dist/angular/voice-ops-status.component.d.ts +15 -0
- package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
- package/dist/angular/voice-provider-status.service.d.ts +12 -0
- package/dist/angular/voice-routing-status.service.d.ts +11 -0
- package/dist/angular/voice-stream.service.d.ts +2 -0
- package/dist/angular/voice-turn-quality.service.d.ts +12 -0
- package/dist/angular/voice-workflow-status.service.d.ts +12 -0
- package/dist/appKit.d.ts +94 -0
- package/dist/assistantHealth.d.ts +81 -0
- package/dist/client/actions.d.ts +22 -0
- package/dist/client/appKitStatus.d.ts +19 -0
- package/dist/client/connection.d.ts +3 -0
- package/dist/client/htmxBootstrap.js +44 -2
- package/dist/client/index.d.ts +26 -0
- package/dist/client/index.js +1290 -2
- package/dist/client/opsStatusWidget.d.ts +40 -0
- package/dist/client/providerCapabilities.d.ts +19 -0
- package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
- package/dist/client/providerSimulationControls.d.ts +33 -0
- package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
- package/dist/client/providerStatus.d.ts +19 -0
- package/dist/client/providerStatusWidget.d.ts +32 -0
- package/dist/client/routingStatus.d.ts +19 -0
- package/dist/client/routingStatusWidget.d.ts +28 -0
- package/dist/client/turnQuality.d.ts +19 -0
- package/dist/client/turnQualityWidget.d.ts +32 -0
- package/dist/client/workflowStatus.d.ts +19 -0
- package/dist/diagnosticsRoutes.d.ts +44 -0
- package/dist/evalRoutes.d.ts +213 -0
- package/dist/handoff.d.ts +54 -0
- package/dist/handoffHealth.d.ts +94 -0
- package/dist/index.d.ts +44 -4
- package/dist/index.js +5602 -175
- package/dist/modelAdapters.d.ts +75 -0
- package/dist/opsConsoleRoutes.d.ts +77 -0
- package/dist/opsWebhook.d.ts +126 -0
- package/dist/outcomeContract.d.ts +112 -0
- package/dist/providerAdapters.d.ts +48 -0
- package/dist/providerCapabilities.d.ts +92 -0
- package/dist/providerHealth.d.ts +79 -0
- package/dist/qualityRoutes.d.ts +76 -0
- package/dist/queue.d.ts +52 -0
- package/dist/react/VoiceOpsStatus.d.ts +6 -0
- package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
- package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
- package/dist/react/VoiceProviderStatus.d.ts +6 -0
- package/dist/react/VoiceRoutingStatus.d.ts +6 -0
- package/dist/react/VoiceTurnQuality.d.ts +6 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.js +1884 -11
- package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
- package/dist/react/useVoiceController.d.ts +2 -0
- package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
- package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
- package/dist/react/useVoiceProviderStatus.d.ts +8 -0
- package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/react/useVoiceStream.d.ts +2 -0
- package/dist/react/useVoiceTurnQuality.d.ts +8 -0
- package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
- package/dist/resilienceRoutes.d.ts +117 -0
- package/dist/sessionReplay.d.ts +175 -0
- package/dist/svelte/createVoiceAppKitStatus.d.ts +8 -0
- package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
- package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
- package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
- package/dist/svelte/createVoiceProviderStatus.d.ts +10 -0
- package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
- package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
- package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
- package/dist/svelte/index.d.ts +8 -0
- package/dist/svelte/index.js +1330 -3
- package/dist/telephonyOutcome.d.ts +143 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +1537 -7
- package/dist/testing/ioProviderSimulator.d.ts +41 -0
- package/dist/testing/providerSimulator.d.ts +44 -0
- package/dist/toolContract.d.ts +130 -0
- package/dist/toolRuntime.d.ts +50 -0
- package/dist/trace.d.ts +1 -1
- package/dist/turnQuality.d.ts +94 -0
- package/dist/types.d.ts +84 -2
- package/dist/vue/VoiceOpsStatus.d.ts +30 -0
- package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
- package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
- package/dist/vue/VoiceProviderStatus.d.ts +51 -0
- package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
- package/dist/vue/VoiceTurnQuality.d.ts +51 -0
- package/dist/vue/index.d.ts +13 -0
- package/dist/vue/index.js +1934 -25
- package/dist/vue/useVoiceAppKitStatus.d.ts +9 -0
- package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
- package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
- package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
- package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/vue/useVoiceStream.d.ts +2 -0
- package/dist/vue/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/client/index.js
CHANGED
|
@@ -80,7 +80,7 @@ var DEFAULT_SCENARIO_QUERY_PARAM = "scenarioId";
|
|
|
80
80
|
var noop = () => {};
|
|
81
81
|
var noopUnsubscribe = () => noop;
|
|
82
82
|
var NOOP_CONNECTION = {
|
|
83
|
-
|
|
83
|
+
callControl: noop,
|
|
84
84
|
close: noop,
|
|
85
85
|
endTurn: noop,
|
|
86
86
|
getReadyState: () => WS_CLOSED,
|
|
@@ -88,6 +88,7 @@ var NOOP_CONNECTION = {
|
|
|
88
88
|
getSessionId: () => "",
|
|
89
89
|
send: noop,
|
|
90
90
|
sendAudio: noop,
|
|
91
|
+
start: () => {},
|
|
91
92
|
subscribe: noopUnsubscribe
|
|
92
93
|
};
|
|
93
94
|
var createSessionId = () => crypto.randomUUID();
|
|
@@ -109,6 +110,7 @@ var isVoiceServerMessage = (value) => {
|
|
|
109
110
|
switch (value.type) {
|
|
110
111
|
case "audio":
|
|
111
112
|
case "assistant":
|
|
113
|
+
case "call_lifecycle":
|
|
112
114
|
case "complete":
|
|
113
115
|
case "error":
|
|
114
116
|
case "final":
|
|
@@ -249,6 +251,12 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
249
251
|
const endTurn = () => {
|
|
250
252
|
send({ type: "end_turn" });
|
|
251
253
|
};
|
|
254
|
+
const callControl = (message) => {
|
|
255
|
+
send({
|
|
256
|
+
...message,
|
|
257
|
+
type: "call_control"
|
|
258
|
+
});
|
|
259
|
+
};
|
|
252
260
|
const close = () => {
|
|
253
261
|
clearTimers();
|
|
254
262
|
if (state.ws) {
|
|
@@ -266,7 +274,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
266
274
|
};
|
|
267
275
|
connect();
|
|
268
276
|
return {
|
|
269
|
-
|
|
277
|
+
callControl,
|
|
270
278
|
close,
|
|
271
279
|
endTurn,
|
|
272
280
|
getReadyState: () => state.ws?.readyState ?? WS_CLOSED,
|
|
@@ -274,6 +282,7 @@ var createVoiceConnection = (path, options = {}) => {
|
|
|
274
282
|
getSessionId: () => state.sessionId,
|
|
275
283
|
send,
|
|
276
284
|
sendAudio,
|
|
285
|
+
start,
|
|
277
286
|
subscribe
|
|
278
287
|
};
|
|
279
288
|
};
|
|
@@ -671,6 +680,12 @@ var serverMessageToAction = (message) => {
|
|
|
671
680
|
sessionId: message.sessionId,
|
|
672
681
|
type: "complete"
|
|
673
682
|
};
|
|
683
|
+
case "call_lifecycle":
|
|
684
|
+
return {
|
|
685
|
+
event: message.event,
|
|
686
|
+
sessionId: message.sessionId,
|
|
687
|
+
type: "call_lifecycle"
|
|
688
|
+
};
|
|
674
689
|
case "error":
|
|
675
690
|
return {
|
|
676
691
|
message: normalizeErrorMessage(message.message),
|
|
@@ -707,6 +722,7 @@ var serverMessageToAction = (message) => {
|
|
|
707
722
|
var createInitialState2 = () => ({
|
|
708
723
|
assistantAudio: [],
|
|
709
724
|
assistantTexts: [],
|
|
725
|
+
call: null,
|
|
710
726
|
error: null,
|
|
711
727
|
isConnected: false,
|
|
712
728
|
scenarioId: null,
|
|
@@ -750,6 +766,20 @@ var createVoiceStreamStore = () => {
|
|
|
750
766
|
status: "completed"
|
|
751
767
|
};
|
|
752
768
|
break;
|
|
769
|
+
case "call_lifecycle":
|
|
770
|
+
state = {
|
|
771
|
+
...state,
|
|
772
|
+
call: {
|
|
773
|
+
...state.call,
|
|
774
|
+
disposition: action.event.type === "end" ? action.event.disposition : state.call?.disposition,
|
|
775
|
+
endedAt: action.event.type === "end" ? action.event.at : state.call?.endedAt,
|
|
776
|
+
events: [...state.call?.events ?? [], action.event],
|
|
777
|
+
lastEventAt: action.event.at,
|
|
778
|
+
startedAt: state.call?.startedAt ?? action.event.at
|
|
779
|
+
},
|
|
780
|
+
sessionId: action.sessionId
|
|
781
|
+
};
|
|
782
|
+
break;
|
|
753
783
|
case "connected":
|
|
754
784
|
state = {
|
|
755
785
|
...state,
|
|
@@ -836,6 +866,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
836
866
|
}
|
|
837
867
|
});
|
|
838
868
|
return {
|
|
869
|
+
callControl(message) {
|
|
870
|
+
connection.callControl(message);
|
|
871
|
+
},
|
|
839
872
|
close() {
|
|
840
873
|
unsubscribeConnection();
|
|
841
874
|
connection.close();
|
|
@@ -879,6 +912,9 @@ var createVoiceStream = (path, options = {}) => {
|
|
|
879
912
|
get assistantAudio() {
|
|
880
913
|
return store.getSnapshot().assistantAudio;
|
|
881
914
|
},
|
|
915
|
+
get call() {
|
|
916
|
+
return store.getSnapshot().call;
|
|
917
|
+
},
|
|
882
918
|
sendAudio(audio) {
|
|
883
919
|
connection.sendAudio(audio);
|
|
884
920
|
},
|
|
@@ -1352,6 +1388,7 @@ var resolveVoiceRuntimePreset = (name = "default") => {
|
|
|
1352
1388
|
var createInitialState3 = (stream) => ({
|
|
1353
1389
|
assistantAudio: [...stream.assistantAudio],
|
|
1354
1390
|
assistantTexts: [...stream.assistantTexts],
|
|
1391
|
+
call: stream.call,
|
|
1355
1392
|
error: stream.error,
|
|
1356
1393
|
isConnected: stream.isConnected,
|
|
1357
1394
|
isRecording: false,
|
|
@@ -1381,6 +1418,7 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1381
1418
|
...state,
|
|
1382
1419
|
assistantAudio: [...stream.assistantAudio],
|
|
1383
1420
|
assistantTexts: [...stream.assistantTexts],
|
|
1421
|
+
call: stream.call,
|
|
1384
1422
|
error: stream.error,
|
|
1385
1423
|
isConnected: stream.isConnected,
|
|
1386
1424
|
partial: stream.partial,
|
|
@@ -1458,6 +1496,7 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1458
1496
|
bindHTMX(bindingOptions) {
|
|
1459
1497
|
return bindVoiceHTMX(stream, bindingOptions);
|
|
1460
1498
|
},
|
|
1499
|
+
callControl: (message) => stream.callControl(message),
|
|
1461
1500
|
close,
|
|
1462
1501
|
endTurn: () => stream.endTurn(),
|
|
1463
1502
|
get error() {
|
|
@@ -1510,6 +1549,9 @@ var createVoiceController = (path, options = {}) => {
|
|
|
1510
1549
|
},
|
|
1511
1550
|
get assistantAudio() {
|
|
1512
1551
|
return state.assistantAudio;
|
|
1552
|
+
},
|
|
1553
|
+
get call() {
|
|
1554
|
+
return state.call;
|
|
1513
1555
|
}
|
|
1514
1556
|
};
|
|
1515
1557
|
};
|
|
@@ -1581,14 +1623,1260 @@ var createVoiceDuplexController = (path, options = {}) => {
|
|
|
1581
1623
|
}
|
|
1582
1624
|
};
|
|
1583
1625
|
};
|
|
1626
|
+
// src/client/appKitStatus.ts
|
|
1627
|
+
var fetchVoiceAppKitStatus = async (path = "/app-kit/status", options = {}) => {
|
|
1628
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1629
|
+
const response = await fetchImpl(path);
|
|
1630
|
+
if (!response.ok) {
|
|
1631
|
+
throw new Error(`Voice app kit status failed: HTTP ${response.status}`);
|
|
1632
|
+
}
|
|
1633
|
+
return await response.json();
|
|
1634
|
+
};
|
|
1635
|
+
var createVoiceAppKitStatusStore = (path = "/app-kit/status", options = {}) => {
|
|
1636
|
+
const listeners = new Set;
|
|
1637
|
+
let closed = false;
|
|
1638
|
+
let timer;
|
|
1639
|
+
let snapshot = {
|
|
1640
|
+
error: null,
|
|
1641
|
+
isLoading: false
|
|
1642
|
+
};
|
|
1643
|
+
const emit = () => {
|
|
1644
|
+
for (const listener of listeners) {
|
|
1645
|
+
listener();
|
|
1646
|
+
}
|
|
1647
|
+
};
|
|
1648
|
+
const refresh = async () => {
|
|
1649
|
+
if (closed) {
|
|
1650
|
+
return snapshot.report;
|
|
1651
|
+
}
|
|
1652
|
+
snapshot = {
|
|
1653
|
+
...snapshot,
|
|
1654
|
+
error: null,
|
|
1655
|
+
isLoading: true
|
|
1656
|
+
};
|
|
1657
|
+
emit();
|
|
1658
|
+
try {
|
|
1659
|
+
const report = await fetchVoiceAppKitStatus(path, options);
|
|
1660
|
+
snapshot = {
|
|
1661
|
+
error: null,
|
|
1662
|
+
isLoading: false,
|
|
1663
|
+
report,
|
|
1664
|
+
updatedAt: Date.now()
|
|
1665
|
+
};
|
|
1666
|
+
emit();
|
|
1667
|
+
return report;
|
|
1668
|
+
} catch (error) {
|
|
1669
|
+
snapshot = {
|
|
1670
|
+
...snapshot,
|
|
1671
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1672
|
+
isLoading: false
|
|
1673
|
+
};
|
|
1674
|
+
emit();
|
|
1675
|
+
throw error;
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
const close = () => {
|
|
1679
|
+
closed = true;
|
|
1680
|
+
if (timer) {
|
|
1681
|
+
clearInterval(timer);
|
|
1682
|
+
timer = undefined;
|
|
1683
|
+
}
|
|
1684
|
+
listeners.clear();
|
|
1685
|
+
};
|
|
1686
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
1687
|
+
timer = setInterval(() => {
|
|
1688
|
+
refresh().catch(() => {});
|
|
1689
|
+
}, options.intervalMs);
|
|
1690
|
+
}
|
|
1691
|
+
return {
|
|
1692
|
+
close,
|
|
1693
|
+
getServerSnapshot: () => snapshot,
|
|
1694
|
+
getSnapshot: () => snapshot,
|
|
1695
|
+
refresh,
|
|
1696
|
+
subscribe: (listener) => {
|
|
1697
|
+
listeners.add(listener);
|
|
1698
|
+
return () => {
|
|
1699
|
+
listeners.delete(listener);
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
};
|
|
1704
|
+
// src/client/opsStatusWidget.ts
|
|
1705
|
+
var DEFAULT_TITLE = "Voice Ops Status";
|
|
1706
|
+
var DEFAULT_DESCRIPTION = "Certified workflow, provider, and handoff readiness from the AbsoluteJS voice app kit.";
|
|
1707
|
+
var SURFACE_LABELS = {
|
|
1708
|
+
handoffs: "Handoffs",
|
|
1709
|
+
providers: "Providers",
|
|
1710
|
+
quality: "Quality",
|
|
1711
|
+
sessions: "Sessions",
|
|
1712
|
+
workflows: "Workflows"
|
|
1713
|
+
};
|
|
1714
|
+
var escapeHtml = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1715
|
+
var readNumber = (value, key) => value && typeof value === "object" && (key in value) ? Number(value[key] ?? 0) : 0;
|
|
1716
|
+
var surfaceDetail = (surface) => {
|
|
1717
|
+
const total = readNumber(surface, "total");
|
|
1718
|
+
const failed = readNumber(surface, "failed");
|
|
1719
|
+
const degraded = readNumber(surface, "degraded");
|
|
1720
|
+
const source = surface && typeof surface === "object" && "source" in surface && typeof surface.source === "string" ? ` from ${surface.source}` : "";
|
|
1721
|
+
if (degraded > 0) {
|
|
1722
|
+
return `${degraded} degraded of ${total}`;
|
|
1723
|
+
}
|
|
1724
|
+
if (failed > 0) {
|
|
1725
|
+
return `${failed} failing of ${total}${source}`;
|
|
1726
|
+
}
|
|
1727
|
+
return total > 0 ? `${total} passing${source}` : `No failures${source}`;
|
|
1728
|
+
};
|
|
1729
|
+
var getVoiceOpsStatusLabel = (report, error) => {
|
|
1730
|
+
if (error) {
|
|
1731
|
+
return "Unavailable";
|
|
1732
|
+
}
|
|
1733
|
+
if (!report) {
|
|
1734
|
+
return "Checking";
|
|
1735
|
+
}
|
|
1736
|
+
return report.status === "pass" ? "Passing" : "Needs attention";
|
|
1737
|
+
};
|
|
1738
|
+
var createVoiceOpsStatusViewModel = (snapshot, options = {}) => {
|
|
1739
|
+
const report = snapshot.report;
|
|
1740
|
+
const surfaces = Object.entries(report?.surfaces ?? {}).map(([id, surface]) => {
|
|
1741
|
+
const failed = readNumber(surface, "failed") || readNumber(surface, "degraded");
|
|
1742
|
+
const total = readNumber(surface, "total");
|
|
1743
|
+
const status = surface && typeof surface === "object" && "status" in surface ? surface.status ?? "pass" : "pass";
|
|
1744
|
+
return {
|
|
1745
|
+
detail: surfaceDetail(surface),
|
|
1746
|
+
failed,
|
|
1747
|
+
id,
|
|
1748
|
+
label: SURFACE_LABELS[id] ?? id,
|
|
1749
|
+
status,
|
|
1750
|
+
total
|
|
1751
|
+
};
|
|
1752
|
+
});
|
|
1753
|
+
return {
|
|
1754
|
+
description: options.description ?? DEFAULT_DESCRIPTION,
|
|
1755
|
+
error: snapshot.error,
|
|
1756
|
+
isLoading: snapshot.isLoading,
|
|
1757
|
+
label: getVoiceOpsStatusLabel(report, snapshot.error),
|
|
1758
|
+
links: options.includeLinks === false ? [] : report?.links ?? [],
|
|
1759
|
+
passed: report?.passed ?? 0,
|
|
1760
|
+
status: snapshot.error ? "error" : report ? report.status : snapshot.isLoading ? "loading" : "loading",
|
|
1761
|
+
surfaces,
|
|
1762
|
+
title: options.title ?? DEFAULT_TITLE,
|
|
1763
|
+
total: report?.total ?? 0,
|
|
1764
|
+
updatedAt: snapshot.updatedAt
|
|
1765
|
+
};
|
|
1766
|
+
};
|
|
1767
|
+
var renderVoiceOpsStatusHTML = (snapshot, options = {}) => {
|
|
1768
|
+
const model = createVoiceOpsStatusViewModel(snapshot, options);
|
|
1769
|
+
const surfaces = model.surfaces.length ? model.surfaces.map((surface) => `<li class="absolute-voice-ops-status__surface absolute-voice-ops-status__surface--${escapeHtml(surface.status)}">
|
|
1770
|
+
<span>${escapeHtml(surface.label)}</span>
|
|
1771
|
+
<strong>${escapeHtml(surface.detail)}</strong>
|
|
1772
|
+
</li>`).join("") : '<li class="absolute-voice-ops-status__surface"><span>Status</span><strong>Waiting for first check</strong></li>';
|
|
1773
|
+
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>` : "";
|
|
1774
|
+
return `<section class="absolute-voice-ops-status absolute-voice-ops-status--${escapeHtml(model.status)}">
|
|
1775
|
+
<header class="absolute-voice-ops-status__header">
|
|
1776
|
+
<span class="absolute-voice-ops-status__eyebrow">${escapeHtml(model.title)}</span>
|
|
1777
|
+
<strong class="absolute-voice-ops-status__label">${escapeHtml(model.label)}</strong>
|
|
1778
|
+
</header>
|
|
1779
|
+
<p class="absolute-voice-ops-status__description">${escapeHtml(model.description)}</p>
|
|
1780
|
+
<div class="absolute-voice-ops-status__summary">
|
|
1781
|
+
<span>${model.passed} passing</span>
|
|
1782
|
+
<span>${Math.max(model.total - model.passed, 0)} failing</span>
|
|
1783
|
+
<span>${model.total} checks</span>
|
|
1784
|
+
</div>
|
|
1785
|
+
<ul class="absolute-voice-ops-status__surfaces">${surfaces}</ul>
|
|
1786
|
+
${model.error ? `<p class="absolute-voice-ops-status__error">${escapeHtml(model.error)}</p>` : ""}
|
|
1787
|
+
${links}
|
|
1788
|
+
</section>`;
|
|
1789
|
+
};
|
|
1790
|
+
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}`;
|
|
1791
|
+
var mountVoiceOpsStatus = (element, path = "/app-kit/status", options = {}) => {
|
|
1792
|
+
const store = createVoiceAppKitStatusStore(path, options);
|
|
1793
|
+
const render = () => {
|
|
1794
|
+
element.innerHTML = renderVoiceOpsStatusHTML(store.getSnapshot(), options);
|
|
1795
|
+
};
|
|
1796
|
+
const unsubscribe = store.subscribe(render);
|
|
1797
|
+
render();
|
|
1798
|
+
store.refresh().catch(() => {});
|
|
1799
|
+
return {
|
|
1800
|
+
close: () => {
|
|
1801
|
+
unsubscribe();
|
|
1802
|
+
store.close();
|
|
1803
|
+
},
|
|
1804
|
+
refresh: store.refresh
|
|
1805
|
+
};
|
|
1806
|
+
};
|
|
1807
|
+
var defineVoiceOpsStatusElement = (tagName = "absolute-voice-ops-status") => {
|
|
1808
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1809
|
+
return;
|
|
1810
|
+
}
|
|
1811
|
+
customElements.define(tagName, class AbsoluteVoiceOpsStatusElement extends HTMLElement {
|
|
1812
|
+
mounted;
|
|
1813
|
+
connectedCallback() {
|
|
1814
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
1815
|
+
this.mounted = mountVoiceOpsStatus(this, this.getAttribute("path") ?? "/app-kit/status", {
|
|
1816
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1817
|
+
includeLinks: this.getAttribute("include-links") !== "false",
|
|
1818
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
1819
|
+
title: this.getAttribute("title") ?? undefined
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
disconnectedCallback() {
|
|
1823
|
+
this.mounted?.close();
|
|
1824
|
+
this.mounted = undefined;
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
1827
|
+
};
|
|
1828
|
+
// src/client/routingStatus.ts
|
|
1829
|
+
var fetchVoiceRoutingStatus = async (path = "/api/routing/latest", options = {}) => {
|
|
1830
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
1831
|
+
const response = await fetchImpl(path);
|
|
1832
|
+
if (!response.ok) {
|
|
1833
|
+
throw new Error(`Voice routing status failed: HTTP ${response.status}`);
|
|
1834
|
+
}
|
|
1835
|
+
return await response.json();
|
|
1836
|
+
};
|
|
1837
|
+
var createVoiceRoutingStatusStore = (path = "/api/routing/latest", options = {}) => {
|
|
1838
|
+
const listeners = new Set;
|
|
1839
|
+
let closed = false;
|
|
1840
|
+
let timer;
|
|
1841
|
+
let snapshot = {
|
|
1842
|
+
decision: null,
|
|
1843
|
+
error: null,
|
|
1844
|
+
isLoading: false
|
|
1845
|
+
};
|
|
1846
|
+
const emit = () => {
|
|
1847
|
+
for (const listener of listeners) {
|
|
1848
|
+
listener();
|
|
1849
|
+
}
|
|
1850
|
+
};
|
|
1851
|
+
const refresh = async () => {
|
|
1852
|
+
if (closed) {
|
|
1853
|
+
return snapshot.decision;
|
|
1854
|
+
}
|
|
1855
|
+
snapshot = {
|
|
1856
|
+
...snapshot,
|
|
1857
|
+
error: null,
|
|
1858
|
+
isLoading: true
|
|
1859
|
+
};
|
|
1860
|
+
emit();
|
|
1861
|
+
try {
|
|
1862
|
+
const decision = await fetchVoiceRoutingStatus(path, options);
|
|
1863
|
+
snapshot = {
|
|
1864
|
+
decision,
|
|
1865
|
+
error: null,
|
|
1866
|
+
isLoading: false,
|
|
1867
|
+
updatedAt: Date.now()
|
|
1868
|
+
};
|
|
1869
|
+
emit();
|
|
1870
|
+
return decision;
|
|
1871
|
+
} catch (error) {
|
|
1872
|
+
snapshot = {
|
|
1873
|
+
...snapshot,
|
|
1874
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1875
|
+
isLoading: false
|
|
1876
|
+
};
|
|
1877
|
+
emit();
|
|
1878
|
+
throw error;
|
|
1879
|
+
}
|
|
1880
|
+
};
|
|
1881
|
+
const close = () => {
|
|
1882
|
+
closed = true;
|
|
1883
|
+
if (timer) {
|
|
1884
|
+
clearInterval(timer);
|
|
1885
|
+
timer = undefined;
|
|
1886
|
+
}
|
|
1887
|
+
listeners.clear();
|
|
1888
|
+
};
|
|
1889
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
1890
|
+
timer = setInterval(() => {
|
|
1891
|
+
refresh().catch(() => {});
|
|
1892
|
+
}, options.intervalMs);
|
|
1893
|
+
}
|
|
1894
|
+
return {
|
|
1895
|
+
close,
|
|
1896
|
+
getServerSnapshot: () => snapshot,
|
|
1897
|
+
getSnapshot: () => snapshot,
|
|
1898
|
+
refresh,
|
|
1899
|
+
subscribe: (listener) => {
|
|
1900
|
+
listeners.add(listener);
|
|
1901
|
+
return () => {
|
|
1902
|
+
listeners.delete(listener);
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
};
|
|
1907
|
+
// src/client/routingStatusWidget.ts
|
|
1908
|
+
var DEFAULT_TITLE2 = "Voice Routing";
|
|
1909
|
+
var DEFAULT_DESCRIPTION2 = "Latest provider routing decision from the self-hosted trace store.";
|
|
1910
|
+
var escapeHtml2 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1911
|
+
var formatValue = (value, fallback = "None") => typeof value === "string" && value.trim() ? value : typeof value === "number" && Number.isFinite(value) ? String(value) : fallback;
|
|
1912
|
+
var createVoiceRoutingStatusViewModel = (snapshot, options = {}) => {
|
|
1913
|
+
const decision = snapshot.decision;
|
|
1914
|
+
const rows = decision ? [
|
|
1915
|
+
{ label: "Kind", value: decision.kind.toUpperCase() },
|
|
1916
|
+
{ label: "Policy", value: formatValue(decision.routing, "Unknown") },
|
|
1917
|
+
{ label: "Provider", value: formatValue(decision.provider, "Unknown") },
|
|
1918
|
+
{
|
|
1919
|
+
label: "Selected",
|
|
1920
|
+
value: formatValue(decision.selectedProvider, "Unknown")
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
label: "Fallback",
|
|
1924
|
+
value: formatValue(decision.fallbackProvider)
|
|
1925
|
+
},
|
|
1926
|
+
{ label: "Status", value: formatValue(decision.status, "unknown") },
|
|
1927
|
+
{
|
|
1928
|
+
label: "Latency budget",
|
|
1929
|
+
value: typeof decision.latencyBudgetMs === "number" ? `${decision.latencyBudgetMs}ms` : "None"
|
|
1930
|
+
}
|
|
1931
|
+
] : [];
|
|
1932
|
+
return {
|
|
1933
|
+
decision,
|
|
1934
|
+
description: options.description ?? DEFAULT_DESCRIPTION2,
|
|
1935
|
+
error: snapshot.error,
|
|
1936
|
+
isLoading: snapshot.isLoading,
|
|
1937
|
+
label: snapshot.error ? "Unavailable" : decision ? `${formatValue(decision.kind).toUpperCase()} ${formatValue(decision.status, "unknown")}` : snapshot.isLoading ? "Checking" : "No routing yet",
|
|
1938
|
+
rows,
|
|
1939
|
+
status: snapshot.error ? "error" : decision ? "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
1940
|
+
title: options.title ?? DEFAULT_TITLE2,
|
|
1941
|
+
updatedAt: snapshot.updatedAt
|
|
1942
|
+
};
|
|
1943
|
+
};
|
|
1944
|
+
var renderVoiceRoutingStatusHTML = (snapshot, options = {}) => {
|
|
1945
|
+
const model = createVoiceRoutingStatusViewModel(snapshot, options);
|
|
1946
|
+
const rows = model.rows.length ? `<div class="absolute-voice-routing-status__grid">${model.rows.map((row) => `<div>
|
|
1947
|
+
<span>${escapeHtml2(row.label)}</span>
|
|
1948
|
+
<strong>${escapeHtml2(row.value)}</strong>
|
|
1949
|
+
</div>`).join("")}</div>` : '<p class="absolute-voice-routing-status__empty">Start a voice session to see the selected provider.</p>';
|
|
1950
|
+
return `<section class="absolute-voice-routing-status absolute-voice-routing-status--${escapeHtml2(model.status)}">
|
|
1951
|
+
<header class="absolute-voice-routing-status__header">
|
|
1952
|
+
<span class="absolute-voice-routing-status__eyebrow">${escapeHtml2(model.title)}</span>
|
|
1953
|
+
<strong class="absolute-voice-routing-status__label">${escapeHtml2(model.label)}</strong>
|
|
1954
|
+
</header>
|
|
1955
|
+
<p class="absolute-voice-routing-status__description">${escapeHtml2(model.description)}</p>
|
|
1956
|
+
${rows}
|
|
1957
|
+
${model.error ? `<p class="absolute-voice-routing-status__error">${escapeHtml2(model.error)}</p>` : ""}
|
|
1958
|
+
</section>`;
|
|
1959
|
+
};
|
|
1960
|
+
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}`;
|
|
1961
|
+
var mountVoiceRoutingStatus = (element, path = "/api/routing/latest", options = {}) => {
|
|
1962
|
+
const store = createVoiceRoutingStatusStore(path, options);
|
|
1963
|
+
const render = () => {
|
|
1964
|
+
element.innerHTML = renderVoiceRoutingStatusHTML(store.getSnapshot(), options);
|
|
1965
|
+
};
|
|
1966
|
+
const unsubscribe = store.subscribe(render);
|
|
1967
|
+
render();
|
|
1968
|
+
store.refresh().catch(() => {});
|
|
1969
|
+
return {
|
|
1970
|
+
close: () => {
|
|
1971
|
+
unsubscribe();
|
|
1972
|
+
store.close();
|
|
1973
|
+
},
|
|
1974
|
+
refresh: store.refresh
|
|
1975
|
+
};
|
|
1976
|
+
};
|
|
1977
|
+
var defineVoiceRoutingStatusElement = (tagName = "absolute-voice-routing-status") => {
|
|
1978
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1981
|
+
customElements.define(tagName, class AbsoluteVoiceRoutingStatusElement extends HTMLElement {
|
|
1982
|
+
mounted;
|
|
1983
|
+
connectedCallback() {
|
|
1984
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
1985
|
+
this.mounted = mountVoiceRoutingStatus(this, this.getAttribute("path") ?? "/api/routing/latest", {
|
|
1986
|
+
description: this.getAttribute("description") ?? undefined,
|
|
1987
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
1988
|
+
title: this.getAttribute("title") ?? undefined
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
disconnectedCallback() {
|
|
1992
|
+
this.mounted?.close();
|
|
1993
|
+
this.mounted = undefined;
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
};
|
|
1997
|
+
// src/client/providerStatus.ts
|
|
1998
|
+
var fetchVoiceProviderStatus = async (path = "/api/provider-status", options = {}) => {
|
|
1999
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2000
|
+
const response = await fetchImpl(path);
|
|
2001
|
+
if (!response.ok) {
|
|
2002
|
+
throw new Error(`Voice provider status failed: HTTP ${response.status}`);
|
|
2003
|
+
}
|
|
2004
|
+
return await response.json();
|
|
2005
|
+
};
|
|
2006
|
+
var createVoiceProviderStatusStore = (path = "/api/provider-status", options = {}) => {
|
|
2007
|
+
const listeners = new Set;
|
|
2008
|
+
let closed = false;
|
|
2009
|
+
let timer;
|
|
2010
|
+
let snapshot = {
|
|
2011
|
+
error: null,
|
|
2012
|
+
isLoading: false,
|
|
2013
|
+
providers: []
|
|
2014
|
+
};
|
|
2015
|
+
const emit = () => {
|
|
2016
|
+
for (const listener of listeners) {
|
|
2017
|
+
listener();
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
const refresh = async () => {
|
|
2021
|
+
if (closed) {
|
|
2022
|
+
return snapshot.providers;
|
|
2023
|
+
}
|
|
2024
|
+
snapshot = {
|
|
2025
|
+
...snapshot,
|
|
2026
|
+
error: null,
|
|
2027
|
+
isLoading: true
|
|
2028
|
+
};
|
|
2029
|
+
emit();
|
|
2030
|
+
try {
|
|
2031
|
+
const providers = await fetchVoiceProviderStatus(path, options);
|
|
2032
|
+
snapshot = {
|
|
2033
|
+
error: null,
|
|
2034
|
+
isLoading: false,
|
|
2035
|
+
providers,
|
|
2036
|
+
updatedAt: Date.now()
|
|
2037
|
+
};
|
|
2038
|
+
emit();
|
|
2039
|
+
return providers;
|
|
2040
|
+
} catch (error) {
|
|
2041
|
+
snapshot = {
|
|
2042
|
+
...snapshot,
|
|
2043
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2044
|
+
isLoading: false
|
|
2045
|
+
};
|
|
2046
|
+
emit();
|
|
2047
|
+
throw error;
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
const close = () => {
|
|
2051
|
+
closed = true;
|
|
2052
|
+
if (timer) {
|
|
2053
|
+
clearInterval(timer);
|
|
2054
|
+
timer = undefined;
|
|
2055
|
+
}
|
|
2056
|
+
listeners.clear();
|
|
2057
|
+
};
|
|
2058
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2059
|
+
timer = setInterval(() => {
|
|
2060
|
+
refresh().catch(() => {});
|
|
2061
|
+
}, options.intervalMs);
|
|
2062
|
+
}
|
|
2063
|
+
return {
|
|
2064
|
+
close,
|
|
2065
|
+
getServerSnapshot: () => snapshot,
|
|
2066
|
+
getSnapshot: () => snapshot,
|
|
2067
|
+
refresh,
|
|
2068
|
+
subscribe: (listener) => {
|
|
2069
|
+
listeners.add(listener);
|
|
2070
|
+
return () => {
|
|
2071
|
+
listeners.delete(listener);
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
};
|
|
2075
|
+
};
|
|
2076
|
+
// src/client/providerCapabilities.ts
|
|
2077
|
+
var fetchVoiceProviderCapabilities = async (path = "/api/provider-capabilities", options = {}) => {
|
|
2078
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2079
|
+
const response = await fetchImpl(path);
|
|
2080
|
+
if (!response.ok) {
|
|
2081
|
+
throw new Error(`Voice provider capabilities failed: HTTP ${response.status}`);
|
|
2082
|
+
}
|
|
2083
|
+
return await response.json();
|
|
2084
|
+
};
|
|
2085
|
+
var createVoiceProviderCapabilitiesStore = (path = "/api/provider-capabilities", options = {}) => {
|
|
2086
|
+
const listeners = new Set;
|
|
2087
|
+
let closed = false;
|
|
2088
|
+
let timer;
|
|
2089
|
+
let snapshot = {
|
|
2090
|
+
error: null,
|
|
2091
|
+
isLoading: false
|
|
2092
|
+
};
|
|
2093
|
+
const emit = () => {
|
|
2094
|
+
for (const listener of listeners) {
|
|
2095
|
+
listener();
|
|
2096
|
+
}
|
|
2097
|
+
};
|
|
2098
|
+
const refresh = async () => {
|
|
2099
|
+
if (closed) {
|
|
2100
|
+
return snapshot.report;
|
|
2101
|
+
}
|
|
2102
|
+
snapshot = {
|
|
2103
|
+
...snapshot,
|
|
2104
|
+
error: null,
|
|
2105
|
+
isLoading: true
|
|
2106
|
+
};
|
|
2107
|
+
emit();
|
|
2108
|
+
try {
|
|
2109
|
+
const report = await fetchVoiceProviderCapabilities(path, options);
|
|
2110
|
+
snapshot = {
|
|
2111
|
+
error: null,
|
|
2112
|
+
isLoading: false,
|
|
2113
|
+
report,
|
|
2114
|
+
updatedAt: Date.now()
|
|
2115
|
+
};
|
|
2116
|
+
emit();
|
|
2117
|
+
return report;
|
|
2118
|
+
} catch (error) {
|
|
2119
|
+
snapshot = {
|
|
2120
|
+
...snapshot,
|
|
2121
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2122
|
+
isLoading: false
|
|
2123
|
+
};
|
|
2124
|
+
emit();
|
|
2125
|
+
throw error;
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
const close = () => {
|
|
2129
|
+
closed = true;
|
|
2130
|
+
if (timer) {
|
|
2131
|
+
clearInterval(timer);
|
|
2132
|
+
timer = undefined;
|
|
2133
|
+
}
|
|
2134
|
+
listeners.clear();
|
|
2135
|
+
};
|
|
2136
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2137
|
+
timer = setInterval(() => {
|
|
2138
|
+
refresh().catch(() => {});
|
|
2139
|
+
}, options.intervalMs);
|
|
2140
|
+
}
|
|
2141
|
+
return {
|
|
2142
|
+
close,
|
|
2143
|
+
getServerSnapshot: () => snapshot,
|
|
2144
|
+
getSnapshot: () => snapshot,
|
|
2145
|
+
refresh,
|
|
2146
|
+
subscribe: (listener) => {
|
|
2147
|
+
listeners.add(listener);
|
|
2148
|
+
return () => {
|
|
2149
|
+
listeners.delete(listener);
|
|
2150
|
+
};
|
|
2151
|
+
}
|
|
2152
|
+
};
|
|
2153
|
+
};
|
|
2154
|
+
// src/client/turnQuality.ts
|
|
2155
|
+
var fetchVoiceTurnQuality = async (path = "/api/turn-quality", options = {}) => {
|
|
2156
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2157
|
+
const response = await fetchImpl(path);
|
|
2158
|
+
if (!response.ok) {
|
|
2159
|
+
throw new Error(`Voice turn quality failed: HTTP ${response.status}`);
|
|
2160
|
+
}
|
|
2161
|
+
return await response.json();
|
|
2162
|
+
};
|
|
2163
|
+
var createVoiceTurnQualityStore = (path = "/api/turn-quality", options = {}) => {
|
|
2164
|
+
const listeners = new Set;
|
|
2165
|
+
let closed = false;
|
|
2166
|
+
let timer;
|
|
2167
|
+
let snapshot = {
|
|
2168
|
+
error: null,
|
|
2169
|
+
isLoading: false
|
|
2170
|
+
};
|
|
2171
|
+
const emit = () => {
|
|
2172
|
+
for (const listener of listeners) {
|
|
2173
|
+
listener();
|
|
2174
|
+
}
|
|
2175
|
+
};
|
|
2176
|
+
const refresh = async () => {
|
|
2177
|
+
if (closed) {
|
|
2178
|
+
return snapshot.report;
|
|
2179
|
+
}
|
|
2180
|
+
snapshot = {
|
|
2181
|
+
...snapshot,
|
|
2182
|
+
error: null,
|
|
2183
|
+
isLoading: true
|
|
2184
|
+
};
|
|
2185
|
+
emit();
|
|
2186
|
+
try {
|
|
2187
|
+
const report = await fetchVoiceTurnQuality(path, options);
|
|
2188
|
+
snapshot = {
|
|
2189
|
+
error: null,
|
|
2190
|
+
isLoading: false,
|
|
2191
|
+
report,
|
|
2192
|
+
updatedAt: Date.now()
|
|
2193
|
+
};
|
|
2194
|
+
emit();
|
|
2195
|
+
return report;
|
|
2196
|
+
} catch (error) {
|
|
2197
|
+
snapshot = {
|
|
2198
|
+
...snapshot,
|
|
2199
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2200
|
+
isLoading: false
|
|
2201
|
+
};
|
|
2202
|
+
emit();
|
|
2203
|
+
throw error;
|
|
2204
|
+
}
|
|
2205
|
+
};
|
|
2206
|
+
const close = () => {
|
|
2207
|
+
closed = true;
|
|
2208
|
+
if (timer) {
|
|
2209
|
+
clearInterval(timer);
|
|
2210
|
+
timer = undefined;
|
|
2211
|
+
}
|
|
2212
|
+
listeners.clear();
|
|
2213
|
+
};
|
|
2214
|
+
if (options.intervalMs && options.intervalMs > 0) {
|
|
2215
|
+
timer = setInterval(() => {
|
|
2216
|
+
refresh().catch(() => {});
|
|
2217
|
+
}, options.intervalMs);
|
|
2218
|
+
}
|
|
2219
|
+
return {
|
|
2220
|
+
close,
|
|
2221
|
+
getServerSnapshot: () => snapshot,
|
|
2222
|
+
getSnapshot: () => snapshot,
|
|
2223
|
+
refresh,
|
|
2224
|
+
subscribe: (listener) => {
|
|
2225
|
+
listeners.add(listener);
|
|
2226
|
+
return () => {
|
|
2227
|
+
listeners.delete(listener);
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
};
|
|
2232
|
+
// src/client/providerSimulationControls.ts
|
|
2233
|
+
var postSimulation = async (pathPrefix, mode, provider, fetchImpl) => {
|
|
2234
|
+
const response = await fetchImpl(`${pathPrefix}/${mode}?provider=${encodeURIComponent(provider)}`, { method: "POST" });
|
|
2235
|
+
const body = await response.json().catch(() => null);
|
|
2236
|
+
if (!response.ok) {
|
|
2237
|
+
const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Voice provider simulation failed: HTTP ${response.status}`;
|
|
2238
|
+
throw new Error(message);
|
|
2239
|
+
}
|
|
2240
|
+
return body;
|
|
2241
|
+
};
|
|
2242
|
+
var createVoiceProviderSimulationControlsStore = (options) => {
|
|
2243
|
+
const listeners = new Set;
|
|
2244
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2245
|
+
const pathPrefix = options.pathPrefix ?? `/api/${options.kind ?? "stt"}-simulate`;
|
|
2246
|
+
let closed = false;
|
|
2247
|
+
let snapshot = {
|
|
2248
|
+
error: null,
|
|
2249
|
+
isRunning: false,
|
|
2250
|
+
lastResult: null,
|
|
2251
|
+
mode: null,
|
|
2252
|
+
provider: null
|
|
2253
|
+
};
|
|
2254
|
+
const emit = () => {
|
|
2255
|
+
for (const listener of listeners) {
|
|
2256
|
+
listener();
|
|
2257
|
+
}
|
|
2258
|
+
};
|
|
2259
|
+
const run = async (provider, mode) => {
|
|
2260
|
+
if (closed) {
|
|
2261
|
+
return snapshot.lastResult;
|
|
2262
|
+
}
|
|
2263
|
+
snapshot = {
|
|
2264
|
+
...snapshot,
|
|
2265
|
+
error: null,
|
|
2266
|
+
isRunning: true,
|
|
2267
|
+
mode,
|
|
2268
|
+
provider
|
|
2269
|
+
};
|
|
2270
|
+
emit();
|
|
2271
|
+
try {
|
|
2272
|
+
const result = await postSimulation(pathPrefix, mode, provider, fetchImpl);
|
|
2273
|
+
snapshot = {
|
|
2274
|
+
error: null,
|
|
2275
|
+
isRunning: false,
|
|
2276
|
+
lastResult: result,
|
|
2277
|
+
mode,
|
|
2278
|
+
provider,
|
|
2279
|
+
updatedAt: Date.now()
|
|
2280
|
+
};
|
|
2281
|
+
emit();
|
|
2282
|
+
return result;
|
|
2283
|
+
} catch (error) {
|
|
2284
|
+
snapshot = {
|
|
2285
|
+
...snapshot,
|
|
2286
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2287
|
+
isRunning: false
|
|
2288
|
+
};
|
|
2289
|
+
emit();
|
|
2290
|
+
throw error;
|
|
2291
|
+
}
|
|
2292
|
+
};
|
|
2293
|
+
const close = () => {
|
|
2294
|
+
closed = true;
|
|
2295
|
+
listeners.clear();
|
|
2296
|
+
};
|
|
2297
|
+
return {
|
|
2298
|
+
close,
|
|
2299
|
+
getServerSnapshot: () => snapshot,
|
|
2300
|
+
getSnapshot: () => snapshot,
|
|
2301
|
+
run,
|
|
2302
|
+
subscribe: (listener) => {
|
|
2303
|
+
listeners.add(listener);
|
|
2304
|
+
return () => {
|
|
2305
|
+
listeners.delete(listener);
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2309
|
+
};
|
|
2310
|
+
// src/client/providerSimulationControlsWidget.ts
|
|
2311
|
+
var escapeHtml3 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2312
|
+
var formatKind = (kind) => (kind ?? "stt").toUpperCase();
|
|
2313
|
+
var createVoiceProviderSimulationControlsViewModel = (snapshot, options) => {
|
|
2314
|
+
const configuredProviders = options.providers.filter((provider) => provider.configured !== false);
|
|
2315
|
+
const fallbackReady = !options.fallbackRequiredProvider || configuredProviders.some((entry) => entry.provider === options.fallbackRequiredProvider);
|
|
2316
|
+
const failureProviders = (options.failureProviders ? options.failureProviders.map((provider) => ({ provider })) : configuredProviders).filter((provider) => configuredProviders.some((entry) => entry.provider === provider.provider));
|
|
2317
|
+
return {
|
|
2318
|
+
canSimulateFailure: configuredProviders.length > 0 && fallbackReady,
|
|
2319
|
+
description: options.failureMessage ?? `Simulate ${formatKind(options.kind)} provider failure and recovery without changing credentials.`,
|
|
2320
|
+
error: snapshot.error,
|
|
2321
|
+
failureProviders,
|
|
2322
|
+
isRunning: snapshot.isRunning,
|
|
2323
|
+
label: snapshot.isRunning ? `Running ${snapshot.mode ?? "simulation"}` : snapshot.lastResult ? `${snapshot.lastResult.provider} ${snapshot.lastResult.mode} simulated` : configuredProviders.length ? `${configuredProviders.length} configured` : "No configured providers",
|
|
2324
|
+
providers: configuredProviders,
|
|
2325
|
+
resultText: snapshot.lastResult ? JSON.stringify(snapshot.lastResult, null, 2) : null,
|
|
2326
|
+
title: options.title ?? `${formatKind(options.kind)} Failure Simulation`
|
|
2327
|
+
};
|
|
2328
|
+
};
|
|
2329
|
+
var renderVoiceProviderSimulationControlsHTML = (snapshot, options) => {
|
|
2330
|
+
const model = createVoiceProviderSimulationControlsViewModel(snapshot, options);
|
|
2331
|
+
const failureButtons = model.failureProviders.map((provider) => `<button type="button" data-voice-provider-fail="${escapeHtml3(provider.provider)}"${!model.canSimulateFailure || snapshot.isRunning ? " disabled" : ""}>Simulate ${escapeHtml3(provider.provider)} ${escapeHtml3(formatKind(options.kind))} failure</button>`).join("");
|
|
2332
|
+
const recoveryButtons = model.providers.map((provider) => `<button type="button" data-voice-provider-recover="${escapeHtml3(provider.provider)}"${snapshot.isRunning ? " disabled" : ""}>Mark ${escapeHtml3(provider.provider)} recovered</button>`).join("");
|
|
2333
|
+
return `<section class="absolute-voice-provider-simulation absolute-voice-provider-simulation--${snapshot.error ? "error" : snapshot.isRunning ? "running" : "ready"}">
|
|
2334
|
+
<header class="absolute-voice-provider-simulation__header">
|
|
2335
|
+
<span class="absolute-voice-provider-simulation__eyebrow">${escapeHtml3(model.title)}</span>
|
|
2336
|
+
<strong class="absolute-voice-provider-simulation__label">${escapeHtml3(model.label)}</strong>
|
|
2337
|
+
</header>
|
|
2338
|
+
<p class="absolute-voice-provider-simulation__description">${escapeHtml3(model.description)}</p>
|
|
2339
|
+
${model.canSimulateFailure ? "" : `<p class="absolute-voice-provider-simulation__empty">${escapeHtml3(options.fallbackRequiredMessage ?? "Configure fallback providers before simulating failure.")}</p>`}
|
|
2340
|
+
<div class="absolute-voice-provider-simulation__actions">${failureButtons}${recoveryButtons}</div>
|
|
2341
|
+
${snapshot.error ? `<p class="absolute-voice-provider-simulation__error">${escapeHtml3(snapshot.error)}</p>` : ""}
|
|
2342
|
+
${model.resultText ? `<pre class="absolute-voice-provider-simulation__result">${escapeHtml3(model.resultText)}</pre>` : ""}
|
|
2343
|
+
</section>`;
|
|
2344
|
+
};
|
|
2345
|
+
var bindVoiceProviderSimulationControls = (element, store) => {
|
|
2346
|
+
const onClick = (event) => {
|
|
2347
|
+
const target = event.target;
|
|
2348
|
+
if (!(target instanceof HTMLElement)) {
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2351
|
+
const failProvider = target.getAttribute("data-voice-provider-fail");
|
|
2352
|
+
const recoverProvider = target.getAttribute("data-voice-provider-recover");
|
|
2353
|
+
if (failProvider) {
|
|
2354
|
+
store.run(failProvider, "failure").catch(() => {});
|
|
2355
|
+
}
|
|
2356
|
+
if (recoverProvider) {
|
|
2357
|
+
store.run(recoverProvider, "recovery").catch(() => {});
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2360
|
+
element.addEventListener("click", onClick);
|
|
2361
|
+
return () => element.removeEventListener("click", onClick);
|
|
2362
|
+
};
|
|
2363
|
+
var mountVoiceProviderSimulationControls = (element, options) => {
|
|
2364
|
+
const store = createVoiceProviderSimulationControlsStore(options);
|
|
2365
|
+
const render = () => {
|
|
2366
|
+
element.innerHTML = renderVoiceProviderSimulationControlsHTML(store.getSnapshot(), options);
|
|
2367
|
+
};
|
|
2368
|
+
const unsubscribeStore = store.subscribe(render);
|
|
2369
|
+
const unsubscribeDom = bindVoiceProviderSimulationControls(element, store);
|
|
2370
|
+
render();
|
|
2371
|
+
return {
|
|
2372
|
+
close: () => {
|
|
2373
|
+
unsubscribeDom();
|
|
2374
|
+
unsubscribeStore();
|
|
2375
|
+
store.close();
|
|
2376
|
+
},
|
|
2377
|
+
run: store.run
|
|
2378
|
+
};
|
|
2379
|
+
};
|
|
2380
|
+
var defineVoiceProviderSimulationControlsElement = (tagName = "absolute-voice-provider-simulation") => {
|
|
2381
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
customElements.define(tagName, class AbsoluteVoiceProviderSimulationElement extends HTMLElement {
|
|
2385
|
+
mounted;
|
|
2386
|
+
connectedCallback() {
|
|
2387
|
+
const providers = (this.getAttribute("providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean).map((provider) => ({ provider }));
|
|
2388
|
+
const failureProviders = (this.getAttribute("failure-providers") ?? "").split(",").map((provider) => provider.trim()).filter(Boolean);
|
|
2389
|
+
this.mounted = mountVoiceProviderSimulationControls(this, {
|
|
2390
|
+
failureProviders: failureProviders.length ? failureProviders : undefined,
|
|
2391
|
+
fallbackRequiredMessage: this.getAttribute("fallback-required-message") ?? undefined,
|
|
2392
|
+
fallbackRequiredProvider: this.getAttribute("fallback-required-provider") ?? undefined,
|
|
2393
|
+
failureMessage: this.getAttribute("failure-message") ?? undefined,
|
|
2394
|
+
kind: this.getAttribute("kind") ?? "stt",
|
|
2395
|
+
pathPrefix: this.getAttribute("path-prefix") ?? undefined,
|
|
2396
|
+
providers,
|
|
2397
|
+
title: this.getAttribute("title") ?? undefined
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
2400
|
+
disconnectedCallback() {
|
|
2401
|
+
this.mounted?.close();
|
|
2402
|
+
this.mounted = undefined;
|
|
2403
|
+
}
|
|
2404
|
+
});
|
|
2405
|
+
};
|
|
2406
|
+
// src/client/providerStatusWidget.ts
|
|
2407
|
+
var DEFAULT_TITLE3 = "Voice Providers";
|
|
2408
|
+
var DEFAULT_DESCRIPTION3 = "Live provider health, fallback counts, latency, and suppression state from your self-hosted trace store.";
|
|
2409
|
+
var escapeHtml4 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2410
|
+
var formatProvider = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
2411
|
+
var formatStatus = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
2412
|
+
var formatLatency = (value) => typeof value === "number" ? `${value}ms` : "No samples";
|
|
2413
|
+
var formatSuppression = (value) => typeof value === "number" ? `${Math.ceil(value / 1000)}s` : "None";
|
|
2414
|
+
var getProviderDetail = (provider) => {
|
|
2415
|
+
if (provider.status === "suppressed") {
|
|
2416
|
+
return provider.lastError ? `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)} after ${provider.lastError}.` : `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)}.`;
|
|
2417
|
+
}
|
|
2418
|
+
if (provider.status === "recoverable") {
|
|
2419
|
+
return "Cooldown expired; ready for recovery traffic.";
|
|
2420
|
+
}
|
|
2421
|
+
if (provider.status === "rate-limited") {
|
|
2422
|
+
return "Rate limit detected; router should avoid this provider.";
|
|
2423
|
+
}
|
|
2424
|
+
if (provider.status === "degraded") {
|
|
2425
|
+
return provider.lastError ?? "Recent provider errors detected.";
|
|
2426
|
+
}
|
|
2427
|
+
if (provider.status === "healthy") {
|
|
2428
|
+
return provider.recommended ? "Healthy and currently recommended." : "Healthy and available for routing.";
|
|
2429
|
+
}
|
|
2430
|
+
return "No provider traffic observed yet.";
|
|
2431
|
+
};
|
|
2432
|
+
var isWarningStatus = (status) => status === "degraded" || status === "rate-limited" || status === "recoverable" || status === "suppressed";
|
|
2433
|
+
var createVoiceProviderStatusViewModel = (snapshot, options = {}) => {
|
|
2434
|
+
const providers = snapshot.providers.map((provider) => ({
|
|
2435
|
+
...provider,
|
|
2436
|
+
detail: getProviderDetail(provider),
|
|
2437
|
+
label: `${formatProvider(provider.provider)}${provider.recommended ? " recommended" : ""}`,
|
|
2438
|
+
rows: [
|
|
2439
|
+
{ label: "Runs", value: String(provider.runCount) },
|
|
2440
|
+
{ label: "Avg latency", value: formatLatency(provider.averageElapsedMs) },
|
|
2441
|
+
{ label: "Errors", value: String(provider.errorCount) },
|
|
2442
|
+
{ label: "Timeouts", value: String(provider.timeoutCount) },
|
|
2443
|
+
{ label: "Fallbacks", value: String(provider.fallbackCount) },
|
|
2444
|
+
{
|
|
2445
|
+
label: "Suppression",
|
|
2446
|
+
value: formatSuppression(provider.suppressionRemainingMs)
|
|
2447
|
+
}
|
|
2448
|
+
]
|
|
2449
|
+
}));
|
|
2450
|
+
const warningCount = providers.filter((provider) => isWarningStatus(provider.status)).length;
|
|
2451
|
+
const healthyCount = providers.filter((provider) => provider.status === "healthy").length;
|
|
2452
|
+
return {
|
|
2453
|
+
description: options.description ?? DEFAULT_DESCRIPTION3,
|
|
2454
|
+
error: snapshot.error,
|
|
2455
|
+
isLoading: snapshot.isLoading,
|
|
2456
|
+
label: snapshot.error ? "Unavailable" : providers.length ? warningCount > 0 ? `${warningCount} needs attention` : `${healthyCount} healthy` : snapshot.isLoading ? "Checking" : "No provider traffic",
|
|
2457
|
+
providers,
|
|
2458
|
+
status: snapshot.error ? "error" : providers.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2459
|
+
title: options.title ?? DEFAULT_TITLE3,
|
|
2460
|
+
updatedAt: snapshot.updatedAt
|
|
2461
|
+
};
|
|
2462
|
+
};
|
|
2463
|
+
var renderVoiceProviderStatusHTML = (snapshot, options = {}) => {
|
|
2464
|
+
const model = createVoiceProviderStatusViewModel(snapshot, options);
|
|
2465
|
+
const providers = model.providers.length ? `<div class="absolute-voice-provider-status__providers">${model.providers.map((provider) => `<article class="absolute-voice-provider-status__provider absolute-voice-provider-status__provider--${escapeHtml4(provider.status)}">
|
|
2466
|
+
<header>
|
|
2467
|
+
<strong>${escapeHtml4(provider.label)}</strong>
|
|
2468
|
+
<span>${escapeHtml4(formatStatus(provider.status))}</span>
|
|
2469
|
+
</header>
|
|
2470
|
+
<p>${escapeHtml4(provider.detail)}</p>
|
|
2471
|
+
<dl>${provider.rows.map((row) => `<div>
|
|
2472
|
+
<dt>${escapeHtml4(row.label)}</dt>
|
|
2473
|
+
<dd>${escapeHtml4(row.value)}</dd>
|
|
2474
|
+
</div>`).join("")}</dl>
|
|
2475
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-status__empty">Run voice traffic to see provider health.</p>';
|
|
2476
|
+
return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${escapeHtml4(model.status)}">
|
|
2477
|
+
<header class="absolute-voice-provider-status__header">
|
|
2478
|
+
<span class="absolute-voice-provider-status__eyebrow">${escapeHtml4(model.title)}</span>
|
|
2479
|
+
<strong class="absolute-voice-provider-status__label">${escapeHtml4(model.label)}</strong>
|
|
2480
|
+
</header>
|
|
2481
|
+
<p class="absolute-voice-provider-status__description">${escapeHtml4(model.description)}</p>
|
|
2482
|
+
${providers}
|
|
2483
|
+
${model.error ? `<p class="absolute-voice-provider-status__error">${escapeHtml4(model.error)}</p>` : ""}
|
|
2484
|
+
</section>`;
|
|
2485
|
+
};
|
|
2486
|
+
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}`;
|
|
2487
|
+
var mountVoiceProviderStatus = (element, path = "/api/provider-status", options = {}) => {
|
|
2488
|
+
const store = createVoiceProviderStatusStore(path, options);
|
|
2489
|
+
const render = () => {
|
|
2490
|
+
element.innerHTML = renderVoiceProviderStatusHTML(store.getSnapshot(), options);
|
|
2491
|
+
};
|
|
2492
|
+
const unsubscribe = store.subscribe(render);
|
|
2493
|
+
render();
|
|
2494
|
+
store.refresh().catch(() => {});
|
|
2495
|
+
return {
|
|
2496
|
+
close: () => {
|
|
2497
|
+
unsubscribe();
|
|
2498
|
+
store.close();
|
|
2499
|
+
},
|
|
2500
|
+
refresh: store.refresh
|
|
2501
|
+
};
|
|
2502
|
+
};
|
|
2503
|
+
var defineVoiceProviderStatusElement = (tagName = "absolute-voice-provider-status") => {
|
|
2504
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
customElements.define(tagName, class AbsoluteVoiceProviderStatusElement extends HTMLElement {
|
|
2508
|
+
mounted;
|
|
2509
|
+
connectedCallback() {
|
|
2510
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2511
|
+
this.mounted = mountVoiceProviderStatus(this, this.getAttribute("path") ?? "/api/provider-status", {
|
|
2512
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2513
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2514
|
+
title: this.getAttribute("title") ?? undefined
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2517
|
+
disconnectedCallback() {
|
|
2518
|
+
this.mounted?.close();
|
|
2519
|
+
this.mounted = undefined;
|
|
2520
|
+
}
|
|
2521
|
+
});
|
|
2522
|
+
};
|
|
2523
|
+
// src/client/providerCapabilitiesWidget.ts
|
|
2524
|
+
var DEFAULT_TITLE4 = "Provider Capabilities";
|
|
2525
|
+
var DEFAULT_DESCRIPTION4 = "Configured, selected, and healthy voice providers for this deployment.";
|
|
2526
|
+
var escapeHtml5 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2527
|
+
var formatProvider2 = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
2528
|
+
var formatKind2 = (kind) => kind.toUpperCase();
|
|
2529
|
+
var formatStatus2 = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
2530
|
+
var getCapabilityDetail = (capability) => {
|
|
2531
|
+
if (!capability.configured) {
|
|
2532
|
+
return "Not configured in this deployment.";
|
|
2533
|
+
}
|
|
2534
|
+
if (capability.selected) {
|
|
2535
|
+
return `Selected ${capability.kind.toUpperCase()} provider for new sessions.`;
|
|
2536
|
+
}
|
|
2537
|
+
if (capability.health?.status === "healthy") {
|
|
2538
|
+
return "Configured and healthy fallback candidate.";
|
|
2539
|
+
}
|
|
2540
|
+
if (capability.health?.status === "idle") {
|
|
2541
|
+
return "Configured; no traffic observed yet.";
|
|
2542
|
+
}
|
|
2543
|
+
if (capability.health?.lastError) {
|
|
2544
|
+
return capability.health.lastError;
|
|
2545
|
+
}
|
|
2546
|
+
return "Configured and available.";
|
|
2547
|
+
};
|
|
2548
|
+
var isWarningStatus2 = (status) => status === "degraded" || status === "rate-limited" || status === "suppressed" || status === "unconfigured";
|
|
2549
|
+
var createVoiceProviderCapabilitiesViewModel = (snapshot, options = {}) => {
|
|
2550
|
+
const capabilities = (snapshot.report?.capabilities ?? []).map((capability) => ({
|
|
2551
|
+
...capability,
|
|
2552
|
+
detail: getCapabilityDetail(capability),
|
|
2553
|
+
label: `${formatProvider2(capability.provider)} ${formatKind2(capability.kind)}`,
|
|
2554
|
+
rows: [
|
|
2555
|
+
{ label: "Status", value: formatStatus2(capability.status) },
|
|
2556
|
+
{ label: "Selected", value: capability.selected ? "Yes" : "No" },
|
|
2557
|
+
{ label: "Model", value: capability.model ?? "Default" },
|
|
2558
|
+
{
|
|
2559
|
+
label: "Features",
|
|
2560
|
+
value: capability.features?.join(", ") || "Not specified"
|
|
2561
|
+
},
|
|
2562
|
+
{ label: "Runs", value: String(capability.health?.runCount ?? 0) },
|
|
2563
|
+
{ label: "Errors", value: String(capability.health?.errorCount ?? 0) }
|
|
2564
|
+
]
|
|
2565
|
+
}));
|
|
2566
|
+
const warningCount = capabilities.filter((capability) => isWarningStatus2(capability.status)).length;
|
|
2567
|
+
const selectedCount = snapshot.report?.selected ?? capabilities.filter((capability) => capability.selected).length;
|
|
2568
|
+
return {
|
|
2569
|
+
capabilities,
|
|
2570
|
+
description: options.description ?? DEFAULT_DESCRIPTION4,
|
|
2571
|
+
error: snapshot.error,
|
|
2572
|
+
isLoading: snapshot.isLoading,
|
|
2573
|
+
label: snapshot.error ? "Unavailable" : capabilities.length ? warningCount > 0 ? `${warningCount} needs attention` : `${selectedCount} selected` : snapshot.isLoading ? "Checking" : "No capabilities",
|
|
2574
|
+
status: snapshot.error ? "error" : capabilities.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2575
|
+
title: options.title ?? DEFAULT_TITLE4,
|
|
2576
|
+
updatedAt: snapshot.updatedAt
|
|
2577
|
+
};
|
|
2578
|
+
};
|
|
2579
|
+
var renderVoiceProviderCapabilitiesHTML = (snapshot, options = {}) => {
|
|
2580
|
+
const model = createVoiceProviderCapabilitiesViewModel(snapshot, options);
|
|
2581
|
+
const capabilities = model.capabilities.length ? `<div class="absolute-voice-provider-capabilities__providers">${model.capabilities.map((capability) => `<article class="absolute-voice-provider-capabilities__provider absolute-voice-provider-capabilities__provider--${escapeHtml5(capability.status)}">
|
|
2582
|
+
<header>
|
|
2583
|
+
<strong>${escapeHtml5(capability.label)}</strong>
|
|
2584
|
+
<span>${escapeHtml5(formatStatus2(capability.status))}</span>
|
|
2585
|
+
</header>
|
|
2586
|
+
<p>${escapeHtml5(capability.detail)}</p>
|
|
2587
|
+
<dl>${capability.rows.map((row) => `<div>
|
|
2588
|
+
<dt>${escapeHtml5(row.label)}</dt>
|
|
2589
|
+
<dd>${escapeHtml5(row.value)}</dd>
|
|
2590
|
+
</div>`).join("")}</dl>
|
|
2591
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-capabilities__empty">Configure provider capabilities to see deployment coverage.</p>';
|
|
2592
|
+
return `<section class="absolute-voice-provider-capabilities absolute-voice-provider-capabilities--${escapeHtml5(model.status)}">
|
|
2593
|
+
<header class="absolute-voice-provider-capabilities__header">
|
|
2594
|
+
<span class="absolute-voice-provider-capabilities__eyebrow">${escapeHtml5(model.title)}</span>
|
|
2595
|
+
<strong class="absolute-voice-provider-capabilities__label">${escapeHtml5(model.label)}</strong>
|
|
2596
|
+
</header>
|
|
2597
|
+
<p class="absolute-voice-provider-capabilities__description">${escapeHtml5(model.description)}</p>
|
|
2598
|
+
${capabilities}
|
|
2599
|
+
${model.error ? `<p class="absolute-voice-provider-capabilities__error">${escapeHtml5(model.error)}</p>` : ""}
|
|
2600
|
+
</section>`;
|
|
2601
|
+
};
|
|
2602
|
+
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}`;
|
|
2603
|
+
var mountVoiceProviderCapabilities = (element, path = "/api/provider-capabilities", options = {}) => {
|
|
2604
|
+
const store = createVoiceProviderCapabilitiesStore(path, options);
|
|
2605
|
+
const render = () => {
|
|
2606
|
+
element.innerHTML = renderVoiceProviderCapabilitiesHTML(store.getSnapshot(), options);
|
|
2607
|
+
};
|
|
2608
|
+
const unsubscribe = store.subscribe(render);
|
|
2609
|
+
render();
|
|
2610
|
+
store.refresh().catch(() => {});
|
|
2611
|
+
return {
|
|
2612
|
+
close: () => {
|
|
2613
|
+
unsubscribe();
|
|
2614
|
+
store.close();
|
|
2615
|
+
},
|
|
2616
|
+
refresh: store.refresh
|
|
2617
|
+
};
|
|
2618
|
+
};
|
|
2619
|
+
var defineVoiceProviderCapabilitiesElement = (tagName = "absolute-voice-provider-capabilities") => {
|
|
2620
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2621
|
+
return;
|
|
2622
|
+
}
|
|
2623
|
+
customElements.define(tagName, class AbsoluteVoiceProviderCapabilitiesElement extends HTMLElement {
|
|
2624
|
+
mounted;
|
|
2625
|
+
connectedCallback() {
|
|
2626
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2627
|
+
this.mounted = mountVoiceProviderCapabilities(this, this.getAttribute("path") ?? "/api/provider-capabilities", {
|
|
2628
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2629
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2630
|
+
title: this.getAttribute("title") ?? undefined
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2633
|
+
disconnectedCallback() {
|
|
2634
|
+
this.mounted?.close();
|
|
2635
|
+
this.mounted = undefined;
|
|
2636
|
+
}
|
|
2637
|
+
});
|
|
2638
|
+
};
|
|
2639
|
+
// src/client/turnQualityWidget.ts
|
|
2640
|
+
var DEFAULT_TITLE5 = "Turn Quality";
|
|
2641
|
+
var DEFAULT_DESCRIPTION5 = "Per-turn STT confidence, fallback selection, corrections, and transcript coverage.";
|
|
2642
|
+
var escapeHtml6 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2643
|
+
var formatConfidence = (value) => typeof value === "number" ? `${Math.round(value * 100)}%` : "n/a";
|
|
2644
|
+
var formatMaybe = (value) => value === undefined || value === "" ? "n/a" : String(value);
|
|
2645
|
+
var getTurnDetail = (turn) => {
|
|
2646
|
+
if (turn.status === "fail") {
|
|
2647
|
+
return "Empty or unusable committed turn; inspect transcripts and adapter events.";
|
|
2648
|
+
}
|
|
2649
|
+
if (turn.fallbackUsed) {
|
|
2650
|
+
return `Fallback STT selected${turn.fallbackSelectionReason ? ` by ${turn.fallbackSelectionReason}` : ""}.`;
|
|
2651
|
+
}
|
|
2652
|
+
if (turn.correctionChanged) {
|
|
2653
|
+
return `Correction changed the turn${turn.correctionProvider ? ` via ${turn.correctionProvider}` : ""}.`;
|
|
2654
|
+
}
|
|
2655
|
+
if (turn.status === "warn") {
|
|
2656
|
+
return "Turn completed with quality warnings.";
|
|
2657
|
+
}
|
|
2658
|
+
if (turn.status === "unknown") {
|
|
2659
|
+
return "No quality diagnostics were recorded for this turn.";
|
|
2660
|
+
}
|
|
2661
|
+
return "Turn quality looks healthy.";
|
|
2662
|
+
};
|
|
2663
|
+
var createVoiceTurnQualityViewModel = (snapshot, options = {}) => {
|
|
2664
|
+
const turns = (snapshot.report?.turns ?? []).map((turn) => ({
|
|
2665
|
+
...turn,
|
|
2666
|
+
detail: getTurnDetail(turn),
|
|
2667
|
+
label: turn.text || "Empty turn",
|
|
2668
|
+
rows: [
|
|
2669
|
+
{ label: "Source", value: turn.source ?? "unknown" },
|
|
2670
|
+
{ label: "Confidence", value: formatConfidence(turn.averageConfidence) },
|
|
2671
|
+
{ label: "Fallback", value: turn.fallbackUsed ? "Yes" : "No" },
|
|
2672
|
+
{ label: "Correction", value: turn.correctionChanged ? "Changed" : "None" },
|
|
2673
|
+
{ label: "Transcripts", value: `${turn.selectedTranscriptCount} selected` },
|
|
2674
|
+
{ label: "Cost", value: formatMaybe(turn.costUnits) }
|
|
2675
|
+
]
|
|
2676
|
+
}));
|
|
2677
|
+
const warningCount = snapshot.report?.warnings ?? turns.filter((turn) => turn.status === "warn").length;
|
|
2678
|
+
const failedCount = snapshot.report?.failed ?? turns.filter((turn) => turn.status === "fail").length;
|
|
2679
|
+
return {
|
|
2680
|
+
description: options.description ?? DEFAULT_DESCRIPTION5,
|
|
2681
|
+
error: snapshot.error,
|
|
2682
|
+
isLoading: snapshot.isLoading,
|
|
2683
|
+
label: snapshot.error ? "Unavailable" : turns.length ? failedCount > 0 ? `${failedCount} failed` : warningCount > 0 ? `${warningCount} warnings` : `${turns.length} healthy` : snapshot.isLoading ? "Checking" : "No turns",
|
|
2684
|
+
status: snapshot.error ? "error" : turns.length ? failedCount > 0 || warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2685
|
+
title: options.title ?? DEFAULT_TITLE5,
|
|
2686
|
+
turns,
|
|
2687
|
+
updatedAt: snapshot.updatedAt
|
|
2688
|
+
};
|
|
2689
|
+
};
|
|
2690
|
+
var renderVoiceTurnQualityHTML = (snapshot, options = {}) => {
|
|
2691
|
+
const model = createVoiceTurnQualityViewModel(snapshot, options);
|
|
2692
|
+
const turns = model.turns.length ? `<div class="absolute-voice-turn-quality__turns">${model.turns.map((turn) => `<article class="absolute-voice-turn-quality__turn absolute-voice-turn-quality__turn--${escapeHtml6(turn.status)}">
|
|
2693
|
+
<header>
|
|
2694
|
+
<strong>${escapeHtml6(turn.label)}</strong>
|
|
2695
|
+
<span>${escapeHtml6(turn.status)}</span>
|
|
2696
|
+
</header>
|
|
2697
|
+
<p>${escapeHtml6(turn.detail)}</p>
|
|
2698
|
+
<dl>${turn.rows.map((row) => `<div>
|
|
2699
|
+
<dt>${escapeHtml6(row.label)}</dt>
|
|
2700
|
+
<dd>${escapeHtml6(row.value)}</dd>
|
|
2701
|
+
</div>`).join("")}</dl>
|
|
2702
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-turn-quality__empty">Complete a voice turn to see STT quality diagnostics.</p>';
|
|
2703
|
+
return `<section class="absolute-voice-turn-quality absolute-voice-turn-quality--${escapeHtml6(model.status)}">
|
|
2704
|
+
<header class="absolute-voice-turn-quality__header">
|
|
2705
|
+
<span class="absolute-voice-turn-quality__eyebrow">${escapeHtml6(model.title)}</span>
|
|
2706
|
+
<strong class="absolute-voice-turn-quality__label">${escapeHtml6(model.label)}</strong>
|
|
2707
|
+
</header>
|
|
2708
|
+
<p class="absolute-voice-turn-quality__description">${escapeHtml6(model.description)}</p>
|
|
2709
|
+
${turns}
|
|
2710
|
+
${model.error ? `<p class="absolute-voice-turn-quality__error">${escapeHtml6(model.error)}</p>` : ""}
|
|
2711
|
+
</section>`;
|
|
2712
|
+
};
|
|
2713
|
+
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}`;
|
|
2714
|
+
var mountVoiceTurnQuality = (element, path = "/api/turn-quality", options = {}) => {
|
|
2715
|
+
const store = createVoiceTurnQualityStore(path, options);
|
|
2716
|
+
const render = () => {
|
|
2717
|
+
element.innerHTML = renderVoiceTurnQualityHTML(store.getSnapshot(), options);
|
|
2718
|
+
};
|
|
2719
|
+
const unsubscribe = store.subscribe(render);
|
|
2720
|
+
render();
|
|
2721
|
+
store.refresh().catch(() => {});
|
|
2722
|
+
return {
|
|
2723
|
+
close: () => {
|
|
2724
|
+
unsubscribe();
|
|
2725
|
+
store.close();
|
|
2726
|
+
},
|
|
2727
|
+
refresh: store.refresh
|
|
2728
|
+
};
|
|
2729
|
+
};
|
|
2730
|
+
var defineVoiceTurnQualityElement = (tagName = "absolute-voice-turn-quality") => {
|
|
2731
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
customElements.define(tagName, class AbsoluteVoiceTurnQualityElement extends HTMLElement {
|
|
2735
|
+
mounted;
|
|
2736
|
+
connectedCallback() {
|
|
2737
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2738
|
+
this.mounted = mountVoiceTurnQuality(this, this.getAttribute("path") ?? "/api/turn-quality", {
|
|
2739
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2740
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2741
|
+
title: this.getAttribute("title") ?? undefined
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
disconnectedCallback() {
|
|
2745
|
+
this.mounted?.close();
|
|
2746
|
+
this.mounted = undefined;
|
|
2747
|
+
}
|
|
2748
|
+
});
|
|
2749
|
+
};
|
|
2750
|
+
// src/client/workflowStatus.ts
|
|
2751
|
+
var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
|
|
2752
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2753
|
+
const response = await fetchImpl(path);
|
|
2754
|
+
if (!response.ok) {
|
|
2755
|
+
throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
|
|
2756
|
+
}
|
|
2757
|
+
return await response.json();
|
|
2758
|
+
};
|
|
2759
|
+
var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
|
|
2760
|
+
const listeners = new Set;
|
|
2761
|
+
let closed = false;
|
|
2762
|
+
let timer;
|
|
2763
|
+
let snapshot = {
|
|
2764
|
+
error: null,
|
|
2765
|
+
isLoading: false
|
|
2766
|
+
};
|
|
2767
|
+
const emit = () => {
|
|
2768
|
+
for (const listener of listeners) {
|
|
2769
|
+
listener();
|
|
2770
|
+
}
|
|
2771
|
+
};
|
|
2772
|
+
const refresh = async () => {
|
|
2773
|
+
if (closed) {
|
|
2774
|
+
return snapshot.report;
|
|
2775
|
+
}
|
|
2776
|
+
snapshot = {
|
|
2777
|
+
...snapshot,
|
|
2778
|
+
error: null,
|
|
2779
|
+
isLoading: true
|
|
2780
|
+
};
|
|
2781
|
+
emit();
|
|
2782
|
+
try {
|
|
2783
|
+
const report = await fetchVoiceWorkflowStatus(path, options);
|
|
2784
|
+
snapshot = {
|
|
2785
|
+
error: null,
|
|
2786
|
+
isLoading: false,
|
|
2787
|
+
report,
|
|
2788
|
+
updatedAt: Date.now()
|
|
2789
|
+
};
|
|
2790
|
+
emit();
|
|
2791
|
+
return report;
|
|
2792
|
+
} catch (error) {
|
|
2793
|
+
snapshot = {
|
|
2794
|
+
...snapshot,
|
|
2795
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2796
|
+
isLoading: false
|
|
2797
|
+
};
|
|
2798
|
+
emit();
|
|
2799
|
+
throw error;
|
|
2800
|
+
}
|
|
2801
|
+
};
|
|
2802
|
+
const close = () => {
|
|
2803
|
+
closed = true;
|
|
2804
|
+
if (timer) {
|
|
2805
|
+
clearInterval(timer);
|
|
2806
|
+
timer = undefined;
|
|
2807
|
+
}
|
|
2808
|
+
listeners.clear();
|
|
2809
|
+
};
|
|
2810
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
2811
|
+
timer = setInterval(() => {
|
|
2812
|
+
refresh().catch(() => {});
|
|
2813
|
+
}, options.intervalMs);
|
|
2814
|
+
}
|
|
2815
|
+
return {
|
|
2816
|
+
close,
|
|
2817
|
+
getServerSnapshot: () => snapshot,
|
|
2818
|
+
getSnapshot: () => snapshot,
|
|
2819
|
+
refresh,
|
|
2820
|
+
subscribe: (listener) => {
|
|
2821
|
+
listeners.add(listener);
|
|
2822
|
+
return () => {
|
|
2823
|
+
listeners.delete(listener);
|
|
2824
|
+
};
|
|
2825
|
+
}
|
|
2826
|
+
};
|
|
2827
|
+
};
|
|
1584
2828
|
export {
|
|
2829
|
+
renderVoiceTurnQualityHTML,
|
|
2830
|
+
renderVoiceRoutingStatusHTML,
|
|
2831
|
+
renderVoiceProviderStatusHTML,
|
|
2832
|
+
renderVoiceProviderSimulationControlsHTML,
|
|
2833
|
+
renderVoiceProviderCapabilitiesHTML,
|
|
2834
|
+
renderVoiceOpsStatusHTML,
|
|
2835
|
+
mountVoiceTurnQuality,
|
|
2836
|
+
mountVoiceRoutingStatus,
|
|
2837
|
+
mountVoiceProviderStatus,
|
|
2838
|
+
mountVoiceProviderSimulationControls,
|
|
2839
|
+
mountVoiceProviderCapabilities,
|
|
2840
|
+
mountVoiceOpsStatus,
|
|
2841
|
+
getVoiceTurnQualityCSS,
|
|
2842
|
+
getVoiceRoutingStatusCSS,
|
|
2843
|
+
getVoiceProviderStatusCSS,
|
|
2844
|
+
getVoiceProviderCapabilitiesCSS,
|
|
2845
|
+
getVoiceOpsStatusLabel,
|
|
2846
|
+
getVoiceOpsStatusCSS,
|
|
2847
|
+
fetchVoiceWorkflowStatus,
|
|
2848
|
+
fetchVoiceTurnQuality,
|
|
2849
|
+
fetchVoiceRoutingStatus,
|
|
2850
|
+
fetchVoiceProviderStatus,
|
|
2851
|
+
fetchVoiceProviderCapabilities,
|
|
2852
|
+
fetchVoiceAppKitStatus,
|
|
2853
|
+
defineVoiceTurnQualityElement,
|
|
2854
|
+
defineVoiceRoutingStatusElement,
|
|
2855
|
+
defineVoiceProviderStatusElement,
|
|
2856
|
+
defineVoiceProviderSimulationControlsElement,
|
|
2857
|
+
defineVoiceProviderCapabilitiesElement,
|
|
2858
|
+
defineVoiceOpsStatusElement,
|
|
1585
2859
|
decodeVoiceAudioChunk,
|
|
2860
|
+
createVoiceWorkflowStatusStore,
|
|
2861
|
+
createVoiceTurnQualityViewModel,
|
|
2862
|
+
createVoiceTurnQualityStore,
|
|
1586
2863
|
createVoiceStream,
|
|
2864
|
+
createVoiceRoutingStatusViewModel,
|
|
2865
|
+
createVoiceRoutingStatusStore,
|
|
2866
|
+
createVoiceProviderStatusViewModel,
|
|
2867
|
+
createVoiceProviderStatusStore,
|
|
2868
|
+
createVoiceProviderSimulationControlsViewModel,
|
|
2869
|
+
createVoiceProviderSimulationControlsStore,
|
|
2870
|
+
createVoiceProviderCapabilitiesViewModel,
|
|
2871
|
+
createVoiceProviderCapabilitiesStore,
|
|
2872
|
+
createVoiceOpsStatusViewModel,
|
|
1587
2873
|
createVoiceDuplexController,
|
|
1588
2874
|
createVoiceController,
|
|
1589
2875
|
createVoiceConnection,
|
|
1590
2876
|
createVoiceAudioPlayer,
|
|
2877
|
+
createVoiceAppKitStatusStore,
|
|
1591
2878
|
createMicrophoneCapture,
|
|
2879
|
+
bindVoiceProviderSimulationControls,
|
|
1592
2880
|
bindVoiceHTMX,
|
|
1593
2881
|
bindVoiceBargeIn
|
|
1594
2882
|
};
|