@absolutejs/voice 0.0.22-beta.133 → 0.0.22-beta.135
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/dist/index.js +40 -3
- package/dist/productionReadiness.d.ts +13 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12447,6 +12447,9 @@ var escapeHtml20 = (value) => value.replaceAll("&", "&").replaceAll("<", "&l
|
|
|
12447
12447
|
var increment4 = (record, key) => {
|
|
12448
12448
|
record[key] = (record[key] ?? 0) + 1;
|
|
12449
12449
|
};
|
|
12450
|
+
var isProviderErrorEvent = (event) => event.type === "session.error" && (event.payload.providerStatus === "error" || typeof event.payload.error === "string");
|
|
12451
|
+
var isRecoveredProviderFallbackEvent = (event) => event.type === "session.error" && (event.payload.providerStatus === "fallback" || event.payload.status === "fallback") && event.payload.recovered === true;
|
|
12452
|
+
var turnRecoveryKey = (event) => event.turnId ?? `session:${event.sessionId}`;
|
|
12450
12453
|
var buildReplayTurns = (events) => {
|
|
12451
12454
|
const turns = new Map;
|
|
12452
12455
|
const getTurn = (turnId) => {
|
|
@@ -12547,12 +12550,13 @@ var summarizeVoiceSessions = async (options = {}) => {
|
|
|
12547
12550
|
const providers = new Set;
|
|
12548
12551
|
let latestOutcome;
|
|
12549
12552
|
let errorCount = 0;
|
|
12553
|
+
const recoveredTurns = new Set(sorted.filter(isRecoveredProviderFallbackEvent).map((event) => turnRecoveryKey(event)));
|
|
12550
12554
|
for (const event of sorted) {
|
|
12551
12555
|
const provider = getString9(event.payload.provider);
|
|
12552
12556
|
if (provider) {
|
|
12553
12557
|
providers.add(provider);
|
|
12554
12558
|
}
|
|
12555
|
-
if (event
|
|
12559
|
+
if (isProviderErrorEvent(event) && !recoveredTurns.has(turnRecoveryKey(event))) {
|
|
12556
12560
|
errorCount += 1;
|
|
12557
12561
|
increment4(providerErrors, provider ?? "unknown");
|
|
12558
12562
|
}
|
|
@@ -19489,6 +19493,12 @@ var resolveReconnectContracts = async (options, input) => {
|
|
|
19489
19493
|
}
|
|
19490
19494
|
return typeof options.reconnectContracts === "function" ? await options.reconnectContracts(input) : options.reconnectContracts;
|
|
19491
19495
|
};
|
|
19496
|
+
var resolveBargeInReports = async (options, input) => {
|
|
19497
|
+
if (options.bargeInReports === false || options.bargeInReports === undefined) {
|
|
19498
|
+
return;
|
|
19499
|
+
}
|
|
19500
|
+
return typeof options.bargeInReports === "function" ? await options.bargeInReports(input) : options.bargeInReports;
|
|
19501
|
+
};
|
|
19492
19502
|
var defaultAuditRequirements = [
|
|
19493
19503
|
{
|
|
19494
19504
|
label: "Provider-call audit",
|
|
@@ -19647,7 +19657,8 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
|
|
|
19647
19657
|
agentSquadContracts,
|
|
19648
19658
|
providerRoutingContracts,
|
|
19649
19659
|
phoneAgentSmokes,
|
|
19650
|
-
reconnectContracts
|
|
19660
|
+
reconnectContracts,
|
|
19661
|
+
bargeInReports
|
|
19651
19662
|
] = await Promise.all([
|
|
19652
19663
|
evaluateVoiceQuality({ events }),
|
|
19653
19664
|
Promise.all([
|
|
@@ -19673,7 +19684,8 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
|
|
|
19673
19684
|
resolveAgentSquadContracts(options, { query, request }),
|
|
19674
19685
|
resolveProviderRoutingContracts(options, { query, request }),
|
|
19675
19686
|
resolvePhoneAgentSmokes(options, { query, request }),
|
|
19676
|
-
resolveReconnectContracts(options, { query, request })
|
|
19687
|
+
resolveReconnectContracts(options, { query, request }),
|
|
19688
|
+
resolveBargeInReports(options, { query, request })
|
|
19677
19689
|
]);
|
|
19678
19690
|
const degradedProviders = providers.filter((provider) => provider.status === "degraded" || provider.status === "rate-limited" || provider.status === "suppressed").length;
|
|
19679
19691
|
const failedSessions = sessions.filter((session) => session.status === "failed").length;
|
|
@@ -19806,6 +19818,13 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
|
|
|
19806
19818
|
status: reconnectContracts.some((report) => !report.pass) ? "fail" : reconnectContracts.length === 0 ? "warn" : "pass",
|
|
19807
19819
|
total: reconnectContracts.length
|
|
19808
19820
|
} : undefined;
|
|
19821
|
+
const bargeInSummary = bargeInReports ? {
|
|
19822
|
+
failed: bargeInReports.reduce((total, report) => total + report.failed, 0),
|
|
19823
|
+
passed: bargeInReports.reduce((total, report) => total + report.passed, 0),
|
|
19824
|
+
status: bargeInReports.some((report) => report.status === "fail" || report.failed > 0) ? "fail" : bargeInReports.length === 0 || bargeInReports.some((report) => report.status === "empty" || report.status === "warn" || report.total === 0) ? "warn" : "pass",
|
|
19825
|
+
total: bargeInReports.reduce((total, report) => total + report.total, 0),
|
|
19826
|
+
warnings: bargeInReports.filter((report) => report.status === "warn").length
|
|
19827
|
+
} : undefined;
|
|
19809
19828
|
if (agentSquadContractSummary) {
|
|
19810
19829
|
checks.push({
|
|
19811
19830
|
detail: agentSquadContractSummary.status === "pass" ? `${agentSquadContractSummary.passed} agent squad contract(s) are passing.` : agentSquadContractSummary.total === 0 ? "No agent squad contracts are configured." : `${agentSquadContractSummary.failed} agent squad contract(s) failed.`,
|
|
@@ -19870,6 +19889,22 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
|
|
|
19870
19889
|
]
|
|
19871
19890
|
});
|
|
19872
19891
|
}
|
|
19892
|
+
if (bargeInSummary) {
|
|
19893
|
+
checks.push({
|
|
19894
|
+
detail: bargeInSummary.status === "pass" ? `${bargeInSummary.passed} barge-in interruption(s) stopped within threshold.` : bargeInSummary.total === 0 ? "No barge-in interruption proof is recorded yet." : bargeInSummary.status === "fail" ? `${bargeInSummary.failed} barge-in interruption(s) exceeded threshold.` : `${bargeInSummary.warnings} barge-in proof report(s) have warnings.`,
|
|
19895
|
+
href: options.links?.bargeIn ?? "/barge-in",
|
|
19896
|
+
label: "Barge-in interruption proof",
|
|
19897
|
+
status: bargeInSummary.status,
|
|
19898
|
+
value: `${bargeInSummary.passed}/${bargeInSummary.total}`,
|
|
19899
|
+
actions: bargeInSummary.status === "pass" ? [] : [
|
|
19900
|
+
{
|
|
19901
|
+
description: "Open barge-in proof and confirm assistant speech stops when the caller interrupts.",
|
|
19902
|
+
href: options.links?.bargeIn ?? "/barge-in",
|
|
19903
|
+
label: "Open barge-in proof"
|
|
19904
|
+
}
|
|
19905
|
+
]
|
|
19906
|
+
});
|
|
19907
|
+
}
|
|
19873
19908
|
if (audit) {
|
|
19874
19909
|
const missingLabels = audit.missing.map((requirement) => requirement.label ?? requirement.type);
|
|
19875
19910
|
checks.push({
|
|
@@ -19942,6 +19977,7 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
|
|
|
19942
19977
|
agentSquadContracts: "/agent-squad-contract",
|
|
19943
19978
|
audit: "/audit",
|
|
19944
19979
|
auditDeliveries: "/audit",
|
|
19980
|
+
bargeIn: "/barge-in",
|
|
19945
19981
|
carriers: "/carriers",
|
|
19946
19982
|
handoffs: "/handoffs",
|
|
19947
19983
|
handoffRetry: "/api/voice-handoffs/retry",
|
|
@@ -19960,6 +19996,7 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
|
|
|
19960
19996
|
agentSquadContracts: agentSquadContractSummary,
|
|
19961
19997
|
audit,
|
|
19962
19998
|
auditDeliveries,
|
|
19999
|
+
bargeIn: bargeInSummary,
|
|
19963
20000
|
carriers: carrierSummary,
|
|
19964
20001
|
handoffs: {
|
|
19965
20002
|
failed: handoffs.failed,
|
|
@@ -3,6 +3,7 @@ import { type VoiceTelephonyCarrierMatrixInput } from './telephony/matrix';
|
|
|
3
3
|
import type { VoiceTraceEventStore } from './trace';
|
|
4
4
|
import type { VoiceTraceSinkDeliveryStore } from './trace';
|
|
5
5
|
import type { VoiceAgentSquadContractReport } from './agentSquadContract';
|
|
6
|
+
import type { VoiceBargeInReport } from './bargeInRoutes';
|
|
6
7
|
import type { VoiceProviderRoutingContractReport } from './providerRoutingContract';
|
|
7
8
|
import type { VoicePhoneAgentProductionSmokeReport } from './phoneAgentProductionSmoke';
|
|
8
9
|
import type { VoiceReconnectContractReport } from './reconnectContract';
|
|
@@ -30,6 +31,7 @@ export type VoiceProductionReadinessReport = {
|
|
|
30
31
|
agentSquadContracts?: string;
|
|
31
32
|
audit?: string;
|
|
32
33
|
auditDeliveries?: string;
|
|
34
|
+
bargeIn?: string;
|
|
33
35
|
carriers?: string;
|
|
34
36
|
handoffs?: string;
|
|
35
37
|
handoffRetry?: string;
|
|
@@ -52,6 +54,13 @@ export type VoiceProductionReadinessReport = {
|
|
|
52
54
|
};
|
|
53
55
|
audit?: VoiceProductionReadinessAuditSummary;
|
|
54
56
|
auditDeliveries?: VoiceProductionReadinessAuditDeliverySummary;
|
|
57
|
+
bargeIn?: {
|
|
58
|
+
failed: number;
|
|
59
|
+
passed: number;
|
|
60
|
+
status: VoiceProductionReadinessStatus;
|
|
61
|
+
total: number;
|
|
62
|
+
warnings: number;
|
|
63
|
+
};
|
|
55
64
|
carriers?: {
|
|
56
65
|
failing: number;
|
|
57
66
|
providers: number;
|
|
@@ -171,6 +180,10 @@ export type VoiceProductionReadinessRoutesOptions = {
|
|
|
171
180
|
}) => Promise<readonly VoiceAgentSquadContractReport[]> | readonly VoiceAgentSquadContractReport[]);
|
|
172
181
|
audit?: false | VoiceProductionReadinessAuditOptions;
|
|
173
182
|
auditDeliveries?: false | VoiceProductionReadinessAuditDeliveryOptions;
|
|
183
|
+
bargeInReports?: false | readonly VoiceBargeInReport[] | ((input: {
|
|
184
|
+
query: Record<string, unknown>;
|
|
185
|
+
request: Request;
|
|
186
|
+
}) => Promise<readonly VoiceBargeInReport[]> | readonly VoiceBargeInReport[]);
|
|
174
187
|
carriers?: false | readonly VoiceTelephonyCarrierMatrixInput[] | ((input: {
|
|
175
188
|
query: Record<string, unknown>;
|
|
176
189
|
request: Request;
|