@absolutejs/voice 0.0.22-beta.366 → 0.0.22-beta.367

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.d.ts CHANGED
@@ -72,7 +72,7 @@ export { buildVoiceProviderOrchestrationReport, createVoiceProviderOrchestration
72
72
  export { assertVoiceProviderRoutingContractEvidence, assertVoiceProviderRoutingContract, evaluateVoiceProviderRoutingContractEvidence, runVoiceProviderRoutingContract } from './providerRoutingContract';
73
73
  export { assertVoiceProviderSloEvidence, buildVoiceProviderSloReport, createVoiceProviderSloRoutes, evaluateVoiceProviderSloEvidence, renderVoiceProviderSloHTML, renderVoiceProviderSloMarkdown } from './providerSlo';
74
74
  export { createVoicePhoneAgentProductionSmokeHTMLHandler, createVoicePhoneAgentProductionSmokeJSONHandler, createVoicePhoneAgentProductionSmokeRoutes, renderVoicePhoneAgentProductionSmokeHTML, runVoicePhoneAgentProductionSmokeContract } from './phoneAgentProductionSmoke';
75
- export { assertVoiceProductionReadinessEvidence, buildVoiceProductionReadinessGate, buildVoiceProductionReadinessReport, createVoiceProductionReadinessRoutes, evaluateVoiceProductionReadinessEvidence, renderVoiceProductionReadinessHTML, summarizeVoiceProductionReadinessGate } from './productionReadiness';
75
+ export { assertVoiceProductionReadinessEvidence, buildVoiceProductionReadinessGate, buildVoiceProductionReadinessReport, createVoiceProductionReadinessProofRuntime, createVoiceProductionReadinessRoutes, evaluateVoiceProductionReadinessEvidence, renderVoiceProductionReadinessHTML, summarizeVoiceProductionReadinessGate } from './productionReadiness';
76
76
  export { acknowledgeVoiceMonitorIssue, buildVoiceMonitorRunReport, createVoiceMemoryMonitorIssueStore, createVoiceMemoryMonitorNotifierDeliveryReceiptStore, createVoiceMonitorRoutes, createVoiceMonitorRunner, createVoiceMonitorRunnerRoutes, createVoiceMonitorWebhookNotifier, deliverVoiceMonitorIssueNotifications, muteVoiceMonitorIssue, renderVoiceMonitorHTML, renderVoiceMonitorMarkdown, resolveVoiceMonitorIssue } from './voiceMonitoring';
77
77
  export { createVoiceReadinessProfile, recommendVoiceReadinessProfile } from './readinessProfiles';
78
78
  export { assertVoiceProviderContractMatrixEvidence, assertVoiceProviderStackEvidence, buildVoiceProviderContractMatrix, createVoiceProviderContractMatrixHTMLHandler, createVoiceProviderContractMatrixJSONHandler, createVoiceProviderContractMatrixPreset, createVoiceProviderContractMatrixRoutes, evaluateVoiceProviderContractMatrixEvidence, evaluateVoiceProviderStackEvidence, evaluateVoiceProviderStackGaps, renderVoiceProviderContractMatrixHTML, recommendVoiceProviderStack } from './providerStackRecommendations';
@@ -142,7 +142,7 @@ export type { VoicePhoneAgentCarrier, VoicePhoneAgentCarrierSummary, VoicePhoneA
142
142
  export type { VoicePhoneAgentProductionSmokeIssue, VoicePhoneAgentProductionSmokeHandlerOptions, VoicePhoneAgentProductionSmokeHTMLHandlerOptions, VoicePhoneAgentProductionSmokeOptions, VoicePhoneAgentProductionSmokeReport, VoicePhoneAgentProductionSmokeRoutesOptions, VoicePhoneAgentProductionSmokeRequirement } from './phoneAgentProductionSmoke';
143
143
  export type { VoiceOpsConsoleLink, VoiceOpsConsoleReport, VoiceOpsConsoleRoutesOptions } from './opsConsoleRoutes';
144
144
  export type { VoiceOpsStatus, VoiceOpsStatusLink, VoiceOpsStatusOptions, VoiceOpsStatusReport, VoiceOpsStatusRoutesOptions } from './opsStatus';
145
- export type { VoiceProductionReadinessAction, VoiceProductionReadinessAuditOptions, VoiceProductionReadinessAuditRequirement, VoiceProductionReadinessAuditSummary, VoiceProductionReadinessAssertionInput, VoiceProductionReadinessAssertionReport, VoiceProductionReadinessCheck, VoiceProductionReadinessGateExplanation, VoiceProductionReadinessGateIssue, VoiceProductionReadinessGateOptions, VoiceProductionReadinessGateProfile, VoiceProductionReadinessGateProfileSurface, VoiceProductionReadinessGateReport, VoiceProductionReadinessOpsActionHistoryOptions, VoiceProductionReadinessOpsActionHistorySummary, VoiceProductionReadinessOperationsRecordLink, VoiceProductionReadinessOperationsRecordLinks, VoiceProductionReadinessProfileExplanation, VoiceProductionReadinessProfileSurface, VoiceProductionReadinessProofSource, VoiceProductionReadinessReport, VoiceProductionReadinessRouteInput, VoiceProductionReadinessRoutesOptions, VoiceProductionReadinessTraceDeliverySummary, VoiceProductionReadinessAuditDeliveryOptions, VoiceProductionReadinessAuditDeliverySummary, VoiceProductionReadinessTraceDeliveryOptions, VoiceProductionReadinessStatus } from './productionReadiness';
145
+ export type { VoiceProductionReadinessAction, VoiceProductionReadinessAuditOptions, VoiceProductionReadinessAuditRequirement, VoiceProductionReadinessAuditSummary, VoiceProductionReadinessAssertionInput, VoiceProductionReadinessAssertionReport, VoiceProductionReadinessCheck, VoiceProductionReadinessGateExplanation, VoiceProductionReadinessGateIssue, VoiceProductionReadinessGateOptions, VoiceProductionReadinessGateProfile, VoiceProductionReadinessGateProfileSurface, VoiceProductionReadinessGateReport, VoiceProductionReadinessOpsActionHistoryOptions, VoiceProductionReadinessOpsActionHistorySummary, VoiceProductionReadinessOperationsRecordLink, VoiceProductionReadinessOperationsRecordLinks, VoiceProductionReadinessProfileExplanation, VoiceProductionReadinessProfileSurface, VoiceProductionReadinessProofMetadata, VoiceProductionReadinessProofRuntime, VoiceProductionReadinessProofRuntimeOptions, VoiceProductionReadinessProofRuntimeSeedOptions, VoiceProductionReadinessProofSource, VoiceProductionReadinessReport, VoiceProductionReadinessRouteInput, VoiceProductionReadinessRoutesOptions, VoiceProductionReadinessTraceDeliverySummary, VoiceProductionReadinessAuditDeliveryOptions, VoiceProductionReadinessAuditDeliverySummary, VoiceProductionReadinessTraceDeliveryOptions, VoiceProductionReadinessStatus } from './productionReadiness';
146
146
  export type { VoiceMonitorDefinition, VoiceMonitorEvaluation, VoiceMonitorEvaluationInput, VoiceMonitorIssue, VoiceMonitorIssueStatus, VoiceMonitorIssueStore, VoiceMonitorNotifier, VoiceMonitorNotifierDeliveryInput, VoiceMonitorNotifierDeliveryOptions, VoiceMonitorNotifierDeliveryReceipt, VoiceMonitorNotifierDeliveryReceiptStore, VoiceMonitorNotifierDeliveryReport, VoiceMonitorNotifierDeliveryResult, VoiceMonitorRoutesOptions, VoiceMonitorRun, VoiceMonitorRunOptions, VoiceMonitorRunReport, VoiceMonitorRunner, VoiceMonitorRunnerOptions, VoiceMonitorRunnerRoutesOptions, VoiceMonitorRunnerTickResult, VoiceMonitorSeverity, VoiceMonitorStatus, VoiceMonitorWebhookNotifierOptions } from './voiceMonitoring';
147
147
  export type { VoiceReadinessProfileName, VoiceReadinessProfileOptions, VoiceReadinessProfileRecommendation, VoiceReadinessProfileRecommendationScore, VoiceReadinessProfileRoutesOptions } from './readinessProfiles';
148
148
  export type { VoiceProviderStackChoice, VoiceProviderStackCapabilities, VoiceProviderStackCapabilityGap, VoiceProviderStackCapabilityGapInput, VoiceProviderStackCapabilityGapReport, VoiceProviderContractCheck, VoiceProviderContractCheckStatus, VoiceProviderContractDefinition, VoiceProviderContractMatrixAssertionInput, VoiceProviderContractMatrixAssertionReport, VoiceProviderContractMatrixHandlerOptions, VoiceProviderContractMatrixHTMLHandlerOptions, VoiceProviderContractMatrixInput, VoiceProviderContractMatrixPresetOptions, VoiceProviderContractMatrixReport, VoiceProviderContractMatrixRoutesOptions, VoiceProviderContractMatrixRow, VoiceProviderStackAssertionInput, VoiceProviderStackAssertionReport, VoiceProviderStackInput, VoiceProviderStackKind, VoiceProviderStackRecommendation } from './providerStackRecommendations';
package/dist/index.js CHANGED
@@ -31830,6 +31830,176 @@ var createVoiceObservabilityExportRoutes = (options = {}) => {
31830
31830
 
31831
31831
  // src/productionReadiness.ts
31832
31832
  var escapeHtml52 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
31833
+ var formatVoiceProofFreshnessDuration = (valueMs) => {
31834
+ if (valueMs < 1000) {
31835
+ return `${Math.max(0, Math.round(valueMs))}ms`;
31836
+ }
31837
+ if (valueMs < 60000) {
31838
+ return `${Math.round(valueMs / 1000)}s`;
31839
+ }
31840
+ return `${Math.round(valueMs / 60000)}m`;
31841
+ };
31842
+ var createVoiceProductionReadinessProofRuntime = (options = {}) => {
31843
+ const store = createVoiceMemoryTraceEventStore();
31844
+ const cacheMs = options.cacheMs ?? 1e4;
31845
+ const traceMaxAgeMs = options.traceMaxAgeMs ?? 30 * 60 * 1000;
31846
+ const freshnessMaxAgeMs = options.freshnessMaxAgeMs ?? traceMaxAgeMs;
31847
+ const proofSource = options.proofSource ?? "production-readiness";
31848
+ const readinessHref = options.readinessHref ?? "/api/production-readiness";
31849
+ const trendsHref = options.trendsHref ?? "/voice/proof-trends";
31850
+ const runId = options.runId ?? (() => `production-readiness-${Date.now()}-${crypto.randomUUID()}`);
31851
+ let metadata;
31852
+ let refreshPromise;
31853
+ let refreshedAt = 0;
31854
+ const cachedValues = new Map;
31855
+ const resetTraceProof = async () => {
31856
+ await Promise.all((await store.list()).map((event) => store.remove(event.id)));
31857
+ };
31858
+ const seedTraceProof = async (seed = {}) => {
31859
+ await resetTraceProof();
31860
+ const now = Date.now();
31861
+ const sessionId = seed.sessionId ?? `production-readiness-trace-${now}`;
31862
+ const scenarioId = seed.scenarioId ?? "production-readiness-proof";
31863
+ const events = [
31864
+ createVoiceTraceEvent({
31865
+ at: now,
31866
+ payload: {
31867
+ elapsedMs: seed.llmElapsedMs ?? 320,
31868
+ kind: "llm",
31869
+ provider: seed.llmProvider ?? "llm",
31870
+ providerStatus: "success",
31871
+ selectedProvider: seed.llmProvider ?? "llm",
31872
+ status: "success"
31873
+ },
31874
+ scenarioId,
31875
+ sessionId,
31876
+ type: "session.error"
31877
+ }),
31878
+ createVoiceTraceEvent({
31879
+ at: now + 1,
31880
+ payload: {
31881
+ elapsedMs: seed.sttElapsedMs ?? 82,
31882
+ kind: "stt",
31883
+ provider: seed.sttProvider ?? "stt",
31884
+ providerStatus: "success",
31885
+ selectedProvider: seed.sttProvider ?? "stt",
31886
+ status: "success"
31887
+ },
31888
+ scenarioId,
31889
+ sessionId,
31890
+ type: "session.error"
31891
+ }),
31892
+ createVoiceTraceEvent({
31893
+ at: now + 2,
31894
+ payload: {
31895
+ elapsedMs: seed.ttsElapsedMs ?? 45,
31896
+ kind: "tts",
31897
+ provider: seed.ttsProvider ?? "tts",
31898
+ providerStatus: "success",
31899
+ selectedProvider: seed.ttsProvider ?? "tts",
31900
+ status: "success"
31901
+ },
31902
+ scenarioId,
31903
+ sessionId,
31904
+ type: "session.error"
31905
+ }),
31906
+ createVoiceTraceEvent({
31907
+ at: now + 3,
31908
+ metadata: {
31909
+ source: "browser",
31910
+ surface: "live-latency-proof"
31911
+ },
31912
+ payload: {
31913
+ completedAt: now + 3,
31914
+ elapsedMs: seed.liveLatencyMs ?? 420,
31915
+ latencyMs: seed.liveLatencyMs ?? 420,
31916
+ startedAt: now + 3 - (seed.liveLatencyMs ?? 420),
31917
+ status: "assistant_audio_started",
31918
+ thresholdMs: 1800
31919
+ },
31920
+ scenarioId,
31921
+ sessionId,
31922
+ traceId: `production-readiness-live-latency-${now}`,
31923
+ type: "client.live_latency"
31924
+ })
31925
+ ];
31926
+ return Promise.all(events.map((event) => store.append(event)));
31927
+ };
31928
+ const refresh = (onRefresh) => {
31929
+ if (refreshPromise && Date.now() - refreshedAt < cacheMs) {
31930
+ return refreshPromise;
31931
+ }
31932
+ refreshPromise = (async () => {
31933
+ const generatedAt = new Date().toISOString();
31934
+ const nextMetadata = {
31935
+ generatedAt,
31936
+ refreshedAt: Date.now(),
31937
+ runId: runId(),
31938
+ source: proofSource
31939
+ };
31940
+ metadata = nextMetadata;
31941
+ await onRefresh?.(nextMetadata);
31942
+ return nextMetadata;
31943
+ })().finally(() => {
31944
+ refreshedAt = Date.now();
31945
+ });
31946
+ return refreshPromise;
31947
+ };
31948
+ const cache = async (key, loader, valueCacheMs = cacheMs) => {
31949
+ const cached = cachedValues.get(key);
31950
+ if (cached && Date.now() - cached.loadedAt < valueCacheMs) {
31951
+ return cached.value;
31952
+ }
31953
+ const value = Promise.resolve(loader());
31954
+ cachedValues.set(key, {
31955
+ loadedAt: Date.now(),
31956
+ value
31957
+ });
31958
+ return value;
31959
+ };
31960
+ const buildFreshnessCheck = async () => {
31961
+ await refresh();
31962
+ const now = Date.now();
31963
+ const proofAgeMs = metadata ? now - metadata.refreshedAt : undefined;
31964
+ const cacheAgeMs = refreshedAt ? now - refreshedAt : undefined;
31965
+ const status = metadata && (proofAgeMs ?? Infinity) <= freshnessMaxAgeMs ? "pass" : "fail";
31966
+ return {
31967
+ detail: metadata ? `Proof ${metadata.runId} refreshed ${formatVoiceProofFreshnessDuration(proofAgeMs ?? 0)} ago; route cache age is ${formatVoiceProofFreshnessDuration(cacheAgeMs ?? 0)}.` : "Production readiness proof has not been refreshed yet.",
31968
+ gateExplanation: {
31969
+ evidenceHref: readinessHref,
31970
+ observed: proofAgeMs ?? 0,
31971
+ remediation: "Reload production readiness to refresh provider SLO, live latency, proof-pack, trend, and observability export proof.",
31972
+ sourceHref: trendsHref,
31973
+ threshold: freshnessMaxAgeMs,
31974
+ thresholdLabel: "Maximum proof age",
31975
+ unit: "ms"
31976
+ },
31977
+ href: options.freshnessHref ?? trendsHref,
31978
+ label: options.freshnessLabel ?? "Proof freshness",
31979
+ proofSource: {
31980
+ detail: "Generated by the production readiness refresh path before the deploy gate evaluates cached route results.",
31981
+ href: readinessHref,
31982
+ source: metadata?.source ?? proofSource,
31983
+ sourceLabel: options.proofSourceLabel ?? "Production readiness proof refresh"
31984
+ },
31985
+ status,
31986
+ value: metadata ? `${formatVoiceProofFreshnessDuration(proofAgeMs ?? 0)} old` : "missing"
31987
+ };
31988
+ };
31989
+ return {
31990
+ buildFreshnessCheck,
31991
+ cache,
31992
+ getMetadata: () => metadata,
31993
+ options: {
31994
+ cacheMs,
31995
+ traceMaxAgeMs
31996
+ },
31997
+ refresh,
31998
+ resetTraceProof,
31999
+ seedTraceProof,
32000
+ store
32001
+ };
32002
+ };
31833
32003
  var rollupStatus4 = (checks) => checks.some((check) => check.status === "fail") ? "fail" : checks.some((check) => check.status === "warn") ? "warn" : "pass";
31834
32004
  var readinessGateCodes = {
31835
32005
  "Agent squad contracts": "voice.readiness.agent_squad_contracts",
@@ -38273,6 +38443,7 @@ export {
38273
38443
  createVoiceProfileSwitchPolicyProofRoutes,
38274
38444
  createVoiceProfileSwitchLiveDecisionRoutes,
38275
38445
  createVoiceProductionReadinessRoutes,
38446
+ createVoiceProductionReadinessProofRuntime,
38276
38447
  createVoicePostgresTraceSinkDeliveryStore,
38277
38448
  createVoicePostgresTraceEventStore,
38278
38449
  createVoicePostgresTelnyxWebhookEventStore,
@@ -3,7 +3,7 @@ import { type VoiceProviderFallbackRecoverySummary } from './sessionReplay';
3
3
  import { type VoiceTelephonyCarrierMatrixInput } from './telephony/matrix';
4
4
  import { type VoiceTelephonyWebhookSecurityOptions, type VoiceTelephonyWebhookSecurityReport } from './telephony/security';
5
5
  import type { VoiceMonitorNotifierDeliveryReport, VoiceMonitorRunReport } from './voiceMonitoring';
6
- import type { VoiceTraceEventStore } from './trace';
6
+ import { type StoredVoiceTraceEvent, type VoiceTraceEventStore } from './trace';
7
7
  import type { VoiceTraceSinkDeliveryStore } from './trace';
8
8
  import type { VoiceAgentSquadContractReport } from './agentSquadContract';
9
9
  import type { VoiceBargeInReport } from './bargeInRoutes';
@@ -110,6 +110,45 @@ export type VoiceProductionReadinessProfileExplanation = {
110
110
  purpose: string;
111
111
  surfaces: VoiceProductionReadinessProfileSurface[];
112
112
  };
113
+ export type VoiceProductionReadinessProofMetadata = {
114
+ generatedAt: string;
115
+ refreshedAt: number;
116
+ runId: string;
117
+ source: string;
118
+ };
119
+ export type VoiceProductionReadinessProofRuntimeSeedOptions = {
120
+ liveLatencyMs?: number;
121
+ llmElapsedMs?: number;
122
+ llmProvider?: string;
123
+ scenarioId?: string;
124
+ sessionId?: string;
125
+ sttElapsedMs?: number;
126
+ sttProvider?: string;
127
+ ttsElapsedMs?: number;
128
+ ttsProvider?: string;
129
+ };
130
+ export type VoiceProductionReadinessProofRuntimeOptions = {
131
+ cacheMs?: number;
132
+ freshnessHref?: string;
133
+ freshnessLabel?: string;
134
+ freshnessMaxAgeMs?: number;
135
+ proofSource?: string;
136
+ proofSourceLabel?: string;
137
+ readinessHref?: string;
138
+ runId?: () => string;
139
+ traceMaxAgeMs?: number;
140
+ trendsHref?: string;
141
+ };
142
+ export type VoiceProductionReadinessProofRuntime = {
143
+ buildFreshnessCheck: () => Promise<VoiceProductionReadinessCheck>;
144
+ cache: <TValue>(key: string, loader: () => Promise<TValue> | TValue, cacheMs?: number) => Promise<TValue>;
145
+ getMetadata: () => VoiceProductionReadinessProofMetadata | undefined;
146
+ options: Pick<VoiceProductionReadinessRoutesOptions, 'cacheMs' | 'traceMaxAgeMs'>;
147
+ refresh: (onRefresh?: (metadata: VoiceProductionReadinessProofMetadata) => Promise<void> | void) => Promise<VoiceProductionReadinessProofMetadata>;
148
+ resetTraceProof: () => Promise<void>;
149
+ seedTraceProof: (options?: VoiceProductionReadinessProofRuntimeSeedOptions) => Promise<StoredVoiceTraceEvent[]>;
150
+ store: VoiceTraceEventStore;
151
+ };
113
152
  export type VoiceProductionReadinessGateProfileSurface = VoiceProductionReadinessProfileSurface & {
114
153
  issues: VoiceProductionReadinessGateIssue[];
115
154
  status: VoiceProductionReadinessStatus;
@@ -590,6 +629,7 @@ export type VoiceProductionReadinessRoutesOptions = {
590
629
  monitoringNotifierDeliveryFailAfterMs?: number;
591
630
  reconnectResumeFailAfterMs?: number;
592
631
  };
632
+ export declare const createVoiceProductionReadinessProofRuntime: (options?: VoiceProductionReadinessProofRuntimeOptions) => VoiceProductionReadinessProofRuntime;
593
633
  export declare const summarizeVoiceProductionReadinessGate: (report: VoiceProductionReadinessReport, options?: VoiceProductionReadinessGateOptions) => VoiceProductionReadinessGateReport;
594
634
  export declare const evaluateVoiceProductionReadinessEvidence: (report: VoiceProductionReadinessReport, input?: VoiceProductionReadinessAssertionInput) => VoiceProductionReadinessAssertionReport;
595
635
  export declare const assertVoiceProductionReadinessEvidence: (report: VoiceProductionReadinessReport, input?: VoiceProductionReadinessAssertionInput) => VoiceProductionReadinessAssertionReport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.366",
3
+ "version": "0.0.22-beta.367",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",