@absolutejs/voice 0.0.22-beta.6 → 0.0.22-beta.60
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/angular/index.d.ts +4 -0
- package/dist/angular/index.js +587 -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-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-workflow-status.service.d.ts +12 -0
- package/dist/appKit.d.ts +92 -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 +14 -0
- package/dist/client/index.js +713 -2
- package/dist/client/opsStatusWidget.d.ts +40 -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/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 +32 -4
- package/dist/index.js +4222 -133
- package/dist/modelAdapters.d.ts +75 -0
- package/dist/opsConsoleRoutes.d.ts +77 -0
- package/dist/opsWebhook.d.ts +126 -0
- package/dist/providerAdapters.d.ts +48 -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/VoiceProviderStatus.d.ts +6 -0
- package/dist/react/VoiceRoutingStatus.d.ts +6 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.js +1024 -11
- package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
- package/dist/react/useVoiceController.d.ts +2 -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/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/createVoiceProviderStatus.d.ts +10 -0
- package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
- package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
- package/dist/svelte/index.d.ts +5 -0
- package/dist/svelte/index.js +736 -3
- 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/trace.d.ts +1 -1
- package/dist/types.d.ts +84 -2
- package/dist/vue/VoiceOpsStatus.d.ts +30 -0
- package/dist/vue/VoiceProviderStatus.d.ts +51 -0
- package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
- package/dist/vue/index.d.ts +7 -0
- package/dist/vue/index.js +1062 -25
- package/dist/vue/useVoiceAppKitStatus.d.ts +9 -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/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,13 +1623,682 @@ 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/providerStatusWidget.ts
|
|
2077
|
+
var DEFAULT_TITLE3 = "Voice Providers";
|
|
2078
|
+
var DEFAULT_DESCRIPTION3 = "Live provider health, fallback counts, latency, and suppression state from your self-hosted trace store.";
|
|
2079
|
+
var escapeHtml3 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2080
|
+
var formatProvider = (provider) => provider.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ") || provider;
|
|
2081
|
+
var formatStatus = (status) => status.split("-").map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
2082
|
+
var formatLatency = (value) => typeof value === "number" ? `${value}ms` : "No samples";
|
|
2083
|
+
var formatSuppression = (value) => typeof value === "number" ? `${Math.ceil(value / 1000)}s` : "None";
|
|
2084
|
+
var getProviderDetail = (provider) => {
|
|
2085
|
+
if (provider.status === "suppressed") {
|
|
2086
|
+
return provider.lastError ? `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)} after ${provider.lastError}.` : `Suppressed for ${formatSuppression(provider.suppressionRemainingMs)}.`;
|
|
2087
|
+
}
|
|
2088
|
+
if (provider.status === "recoverable") {
|
|
2089
|
+
return "Cooldown expired; ready for recovery traffic.";
|
|
2090
|
+
}
|
|
2091
|
+
if (provider.status === "rate-limited") {
|
|
2092
|
+
return "Rate limit detected; router should avoid this provider.";
|
|
2093
|
+
}
|
|
2094
|
+
if (provider.status === "degraded") {
|
|
2095
|
+
return provider.lastError ?? "Recent provider errors detected.";
|
|
2096
|
+
}
|
|
2097
|
+
if (provider.status === "healthy") {
|
|
2098
|
+
return provider.recommended ? "Healthy and currently recommended." : "Healthy and available for routing.";
|
|
2099
|
+
}
|
|
2100
|
+
return "No provider traffic observed yet.";
|
|
2101
|
+
};
|
|
2102
|
+
var isWarningStatus = (status) => status === "degraded" || status === "rate-limited" || status === "recoverable" || status === "suppressed";
|
|
2103
|
+
var createVoiceProviderStatusViewModel = (snapshot, options = {}) => {
|
|
2104
|
+
const providers = snapshot.providers.map((provider) => ({
|
|
2105
|
+
...provider,
|
|
2106
|
+
detail: getProviderDetail(provider),
|
|
2107
|
+
label: `${formatProvider(provider.provider)}${provider.recommended ? " recommended" : ""}`,
|
|
2108
|
+
rows: [
|
|
2109
|
+
{ label: "Runs", value: String(provider.runCount) },
|
|
2110
|
+
{ label: "Avg latency", value: formatLatency(provider.averageElapsedMs) },
|
|
2111
|
+
{ label: "Errors", value: String(provider.errorCount) },
|
|
2112
|
+
{ label: "Timeouts", value: String(provider.timeoutCount) },
|
|
2113
|
+
{ label: "Fallbacks", value: String(provider.fallbackCount) },
|
|
2114
|
+
{
|
|
2115
|
+
label: "Suppression",
|
|
2116
|
+
value: formatSuppression(provider.suppressionRemainingMs)
|
|
2117
|
+
}
|
|
2118
|
+
]
|
|
2119
|
+
}));
|
|
2120
|
+
const warningCount = providers.filter((provider) => isWarningStatus(provider.status)).length;
|
|
2121
|
+
const healthyCount = providers.filter((provider) => provider.status === "healthy").length;
|
|
2122
|
+
return {
|
|
2123
|
+
description: options.description ?? DEFAULT_DESCRIPTION3,
|
|
2124
|
+
error: snapshot.error,
|
|
2125
|
+
isLoading: snapshot.isLoading,
|
|
2126
|
+
label: snapshot.error ? "Unavailable" : providers.length ? warningCount > 0 ? `${warningCount} needs attention` : `${healthyCount} healthy` : snapshot.isLoading ? "Checking" : "No provider traffic",
|
|
2127
|
+
providers,
|
|
2128
|
+
status: snapshot.error ? "error" : providers.length ? warningCount > 0 ? "warning" : "ready" : snapshot.isLoading ? "loading" : "empty",
|
|
2129
|
+
title: options.title ?? DEFAULT_TITLE3,
|
|
2130
|
+
updatedAt: snapshot.updatedAt
|
|
2131
|
+
};
|
|
2132
|
+
};
|
|
2133
|
+
var renderVoiceProviderStatusHTML = (snapshot, options = {}) => {
|
|
2134
|
+
const model = createVoiceProviderStatusViewModel(snapshot, options);
|
|
2135
|
+
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--${escapeHtml3(provider.status)}">
|
|
2136
|
+
<header>
|
|
2137
|
+
<strong>${escapeHtml3(provider.label)}</strong>
|
|
2138
|
+
<span>${escapeHtml3(formatStatus(provider.status))}</span>
|
|
2139
|
+
</header>
|
|
2140
|
+
<p>${escapeHtml3(provider.detail)}</p>
|
|
2141
|
+
<dl>${provider.rows.map((row) => `<div>
|
|
2142
|
+
<dt>${escapeHtml3(row.label)}</dt>
|
|
2143
|
+
<dd>${escapeHtml3(row.value)}</dd>
|
|
2144
|
+
</div>`).join("")}</dl>
|
|
2145
|
+
</article>`).join("")}</div>` : '<p class="absolute-voice-provider-status__empty">Run voice traffic to see provider health.</p>';
|
|
2146
|
+
return `<section class="absolute-voice-provider-status absolute-voice-provider-status--${escapeHtml3(model.status)}">
|
|
2147
|
+
<header class="absolute-voice-provider-status__header">
|
|
2148
|
+
<span class="absolute-voice-provider-status__eyebrow">${escapeHtml3(model.title)}</span>
|
|
2149
|
+
<strong class="absolute-voice-provider-status__label">${escapeHtml3(model.label)}</strong>
|
|
2150
|
+
</header>
|
|
2151
|
+
<p class="absolute-voice-provider-status__description">${escapeHtml3(model.description)}</p>
|
|
2152
|
+
${providers}
|
|
2153
|
+
${model.error ? `<p class="absolute-voice-provider-status__error">${escapeHtml3(model.error)}</p>` : ""}
|
|
2154
|
+
</section>`;
|
|
2155
|
+
};
|
|
2156
|
+
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}`;
|
|
2157
|
+
var mountVoiceProviderStatus = (element, path = "/api/provider-status", options = {}) => {
|
|
2158
|
+
const store = createVoiceProviderStatusStore(path, options);
|
|
2159
|
+
const render = () => {
|
|
2160
|
+
element.innerHTML = renderVoiceProviderStatusHTML(store.getSnapshot(), options);
|
|
2161
|
+
};
|
|
2162
|
+
const unsubscribe = store.subscribe(render);
|
|
2163
|
+
render();
|
|
2164
|
+
store.refresh().catch(() => {});
|
|
2165
|
+
return {
|
|
2166
|
+
close: () => {
|
|
2167
|
+
unsubscribe();
|
|
2168
|
+
store.close();
|
|
2169
|
+
},
|
|
2170
|
+
refresh: store.refresh
|
|
2171
|
+
};
|
|
2172
|
+
};
|
|
2173
|
+
var defineVoiceProviderStatusElement = (tagName = "absolute-voice-provider-status") => {
|
|
2174
|
+
if (typeof window === "undefined" || typeof customElements === "undefined" || customElements.get(tagName)) {
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
customElements.define(tagName, class AbsoluteVoiceProviderStatusElement extends HTMLElement {
|
|
2178
|
+
mounted;
|
|
2179
|
+
connectedCallback() {
|
|
2180
|
+
const intervalMs = Number(this.getAttribute("interval-ms") ?? 5000);
|
|
2181
|
+
this.mounted = mountVoiceProviderStatus(this, this.getAttribute("path") ?? "/api/provider-status", {
|
|
2182
|
+
description: this.getAttribute("description") ?? undefined,
|
|
2183
|
+
intervalMs: Number.isFinite(intervalMs) ? intervalMs : 5000,
|
|
2184
|
+
title: this.getAttribute("title") ?? undefined
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
disconnectedCallback() {
|
|
2188
|
+
this.mounted?.close();
|
|
2189
|
+
this.mounted = undefined;
|
|
2190
|
+
}
|
|
2191
|
+
});
|
|
2192
|
+
};
|
|
2193
|
+
// src/client/workflowStatus.ts
|
|
2194
|
+
var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
|
|
2195
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2196
|
+
const response = await fetchImpl(path);
|
|
2197
|
+
if (!response.ok) {
|
|
2198
|
+
throw new Error(`Voice workflow status failed: HTTP ${response.status}`);
|
|
2199
|
+
}
|
|
2200
|
+
return await response.json();
|
|
2201
|
+
};
|
|
2202
|
+
var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options = {}) => {
|
|
2203
|
+
const listeners = new Set;
|
|
2204
|
+
let closed = false;
|
|
2205
|
+
let timer;
|
|
2206
|
+
let snapshot = {
|
|
2207
|
+
error: null,
|
|
2208
|
+
isLoading: false
|
|
2209
|
+
};
|
|
2210
|
+
const emit = () => {
|
|
2211
|
+
for (const listener of listeners) {
|
|
2212
|
+
listener();
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
const refresh = async () => {
|
|
2216
|
+
if (closed) {
|
|
2217
|
+
return snapshot.report;
|
|
2218
|
+
}
|
|
2219
|
+
snapshot = {
|
|
2220
|
+
...snapshot,
|
|
2221
|
+
error: null,
|
|
2222
|
+
isLoading: true
|
|
2223
|
+
};
|
|
2224
|
+
emit();
|
|
2225
|
+
try {
|
|
2226
|
+
const report = await fetchVoiceWorkflowStatus(path, options);
|
|
2227
|
+
snapshot = {
|
|
2228
|
+
error: null,
|
|
2229
|
+
isLoading: false,
|
|
2230
|
+
report,
|
|
2231
|
+
updatedAt: Date.now()
|
|
2232
|
+
};
|
|
2233
|
+
emit();
|
|
2234
|
+
return report;
|
|
2235
|
+
} catch (error) {
|
|
2236
|
+
snapshot = {
|
|
2237
|
+
...snapshot,
|
|
2238
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2239
|
+
isLoading: false
|
|
2240
|
+
};
|
|
2241
|
+
emit();
|
|
2242
|
+
throw error;
|
|
2243
|
+
}
|
|
2244
|
+
};
|
|
2245
|
+
const close = () => {
|
|
2246
|
+
closed = true;
|
|
2247
|
+
if (timer) {
|
|
2248
|
+
clearInterval(timer);
|
|
2249
|
+
timer = undefined;
|
|
2250
|
+
}
|
|
2251
|
+
listeners.clear();
|
|
2252
|
+
};
|
|
2253
|
+
if (typeof window !== "undefined" && options.intervalMs && options.intervalMs > 0) {
|
|
2254
|
+
timer = setInterval(() => {
|
|
2255
|
+
refresh().catch(() => {});
|
|
2256
|
+
}, options.intervalMs);
|
|
2257
|
+
}
|
|
2258
|
+
return {
|
|
2259
|
+
close,
|
|
2260
|
+
getServerSnapshot: () => snapshot,
|
|
2261
|
+
getSnapshot: () => snapshot,
|
|
2262
|
+
refresh,
|
|
2263
|
+
subscribe: (listener) => {
|
|
2264
|
+
listeners.add(listener);
|
|
2265
|
+
return () => {
|
|
2266
|
+
listeners.delete(listener);
|
|
2267
|
+
};
|
|
2268
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
};
|
|
1584
2271
|
export {
|
|
2272
|
+
renderVoiceRoutingStatusHTML,
|
|
2273
|
+
renderVoiceProviderStatusHTML,
|
|
2274
|
+
renderVoiceOpsStatusHTML,
|
|
2275
|
+
mountVoiceRoutingStatus,
|
|
2276
|
+
mountVoiceProviderStatus,
|
|
2277
|
+
mountVoiceOpsStatus,
|
|
2278
|
+
getVoiceRoutingStatusCSS,
|
|
2279
|
+
getVoiceProviderStatusCSS,
|
|
2280
|
+
getVoiceOpsStatusLabel,
|
|
2281
|
+
getVoiceOpsStatusCSS,
|
|
2282
|
+
fetchVoiceWorkflowStatus,
|
|
2283
|
+
fetchVoiceRoutingStatus,
|
|
2284
|
+
fetchVoiceProviderStatus,
|
|
2285
|
+
fetchVoiceAppKitStatus,
|
|
2286
|
+
defineVoiceRoutingStatusElement,
|
|
2287
|
+
defineVoiceProviderStatusElement,
|
|
2288
|
+
defineVoiceOpsStatusElement,
|
|
1585
2289
|
decodeVoiceAudioChunk,
|
|
2290
|
+
createVoiceWorkflowStatusStore,
|
|
1586
2291
|
createVoiceStream,
|
|
2292
|
+
createVoiceRoutingStatusViewModel,
|
|
2293
|
+
createVoiceRoutingStatusStore,
|
|
2294
|
+
createVoiceProviderStatusViewModel,
|
|
2295
|
+
createVoiceProviderStatusStore,
|
|
2296
|
+
createVoiceOpsStatusViewModel,
|
|
1587
2297
|
createVoiceDuplexController,
|
|
1588
2298
|
createVoiceController,
|
|
1589
2299
|
createVoiceConnection,
|
|
1590
2300
|
createVoiceAudioPlayer,
|
|
2301
|
+
createVoiceAppKitStatusStore,
|
|
1591
2302
|
createMicrophoneCapture,
|
|
1592
2303
|
bindVoiceHTMX,
|
|
1593
2304
|
bindVoiceBargeIn
|