@absolutejs/voice 0.0.22-beta.362 → 0.0.22-beta.364

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 CHANGED
@@ -31986,6 +31986,14 @@ var resolveProviderOrchestration = async (options, input) => {
31986
31986
  }
31987
31987
  return typeof options.providerOrchestration === "function" ? await options.providerOrchestration(input) : options.providerOrchestration;
31988
31988
  };
31989
+ var isVoiceProfileSwitchReadinessReport = (value) => typeof value.status === "string" && typeof value.generatedAt === "string" && typeof value.summary === "object";
31990
+ var resolveProfileSwitchReadiness = async (options, input) => {
31991
+ if (options.profileSwitchReadiness === false || options.profileSwitchReadiness === undefined) {
31992
+ return;
31993
+ }
31994
+ const value = typeof options.profileSwitchReadiness === "function" ? await options.profileSwitchReadiness(input) : options.profileSwitchReadiness;
31995
+ return isVoiceProfileSwitchReadinessReport(value) ? value : buildVoiceProfileSwitchReadinessReport(value);
31996
+ };
31989
31997
  var resolveProviderStack = async (options, input) => {
31990
31998
  if (options.providerStack === false || options.providerStack === undefined) {
31991
31999
  return;
@@ -32415,10 +32423,12 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
32415
32423
  const request = input.request ?? new Request("http://localhost/");
32416
32424
  const query = input.query ?? {};
32417
32425
  const events = await options.store.list();
32418
- const routingEvents = listVoiceRoutingEvents(events);
32426
+ const minTraceAt = typeof options.traceMaxAgeMs === "number" && Number.isFinite(options.traceMaxAgeMs) && options.traceMaxAgeMs > 0 ? Date.now() - options.traceMaxAgeMs : undefined;
32427
+ const readinessEvents = minTraceAt === undefined ? events : events.filter((event) => event.at >= minTraceAt);
32428
+ const routingEvents = listVoiceRoutingEvents(readinessEvents);
32419
32429
  const routingSessions = summarizeVoiceRoutingSessions(routingEvents);
32420
- const liveLatency = summarizeLiveLatency(events, options);
32421
- const providerRecovery = summarizeVoiceProviderFallbackRecovery(events);
32430
+ const liveLatency = summarizeLiveLatency(readinessEvents, options);
32431
+ const providerRecovery = summarizeVoiceProviderFallbackRecovery(readinessEvents);
32422
32432
  const [
32423
32433
  quality,
32424
32434
  providers,
@@ -32434,6 +32444,7 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
32434
32444
  providerRoutingContracts,
32435
32445
  providerSlo,
32436
32446
  providerOrchestration,
32447
+ profileSwitchReadiness,
32437
32448
  providerStack,
32438
32449
  providerContractMatrix,
32439
32450
  phoneAgentSmokes,
@@ -32453,23 +32464,23 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
32453
32464
  proofSources,
32454
32465
  additionalChecks
32455
32466
  ] = await Promise.all([
32456
- evaluateVoiceQuality({ events }),
32467
+ evaluateVoiceQuality({ events: readinessEvents }),
32457
32468
  Promise.all([
32458
32469
  summarizeVoiceProviderHealth({
32459
- events,
32470
+ events: readinessEvents,
32460
32471
  providers: options.llmProviders ?? []
32461
32472
  }),
32462
32473
  summarizeVoiceProviderHealth({
32463
- events: events.filter((event) => event.payload.kind === "stt"),
32474
+ events: readinessEvents.filter((event) => event.payload.kind === "stt"),
32464
32475
  providers: options.sttProviders ?? []
32465
32476
  }),
32466
32477
  summarizeVoiceProviderHealth({
32467
- events: events.filter((event) => event.payload.kind === "tts"),
32478
+ events: readinessEvents.filter((event) => event.payload.kind === "tts"),
32468
32479
  providers: options.ttsProviders ?? []
32469
32480
  })
32470
32481
  ]).then((groups) => groups.flat()),
32471
- summarizeVoiceSessions({ events, status: "all" }),
32472
- summarizeVoiceHandoffHealth({ events }),
32482
+ summarizeVoiceSessions({ events: readinessEvents, status: "all" }),
32483
+ summarizeVoiceHandoffHealth({ events: readinessEvents }),
32473
32484
  summarizeAuditEvidence(options),
32474
32485
  summarizeAuditDeliveries(options),
32475
32486
  summarizeOpsActionHistory(options),
@@ -32480,6 +32491,7 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
32480
32491
  resolveProviderRoutingContracts(options, { query, request }),
32481
32492
  resolveProviderSlo(options, { query, request }),
32482
32493
  resolveProviderOrchestration(options, { query, request }),
32494
+ resolveProfileSwitchReadiness(options, { query, request }),
32483
32495
  resolveProviderStack(options, { query, request }),
32484
32496
  resolveProviderContractMatrix(options, { query, request }),
32485
32497
  resolvePhoneAgentSmokes(options, { query, request }),
@@ -32505,7 +32517,7 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
32505
32517
  const failedSessionItems = sessions.filter((session) => session.status === "failed");
32506
32518
  const operationsRecords = buildOperationsRecordLinks({
32507
32519
  base: options.links?.operationsRecords ?? "/voice-operations",
32508
- events,
32520
+ events: readinessEvents,
32509
32521
  failedSessionIds: failedSessionItems.map((session) => session.sessionId),
32510
32522
  liveLatencyFailAfterMs: options.liveLatencyFailAfterMs ?? 3200,
32511
32523
  liveLatencyMaxAgeMs: options.liveLatencyMaxAgeMs,
@@ -33208,6 +33220,28 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
33208
33220
  ]
33209
33221
  });
33210
33222
  }
33223
+ if (profileSwitchReadiness) {
33224
+ const issueLabels = profileSwitchReadiness.issues.map((issue) => issue.code);
33225
+ checks.push({
33226
+ detail: profileSwitchReadiness.status === "pass" ? `${profileSwitchReadiness.summary.decisions} profile switch guard decision(s) are backed by readiness evidence.` : issueLabels.length > 0 ? `Profile switch readiness issues: ${issueLabels.join(", ")}.` : "Profile switch readiness needs attention.",
33227
+ href: options.links?.profileSwitchReadiness ?? "/voice/profile-switch-readiness",
33228
+ label: "Profile switch readiness",
33229
+ status: profileSwitchReadiness.status,
33230
+ value: `${profileSwitchReadiness.summary.sessions}/${profileSwitchReadiness.summary.decisions}`,
33231
+ actions: profileSwitchReadiness.status === "pass" ? [] : [
33232
+ {
33233
+ description: "Open profile switch readiness to inspect policy proof, audit evidence, trace evidence, and live decisions.",
33234
+ href: options.links?.profileSwitchReadiness ?? "/voice/profile-switch-readiness",
33235
+ label: "Open profile readiness"
33236
+ },
33237
+ {
33238
+ description: "Open live profile switch decisions recorded from audit and trace stores.",
33239
+ href: options.links?.profileSwitchLiveDecisions ?? "/voice/profile-switch-live-decisions",
33240
+ label: "Open live decisions"
33241
+ }
33242
+ ]
33243
+ });
33244
+ }
33211
33245
  if (audit) {
33212
33246
  const missingLabels = audit.missing.map((requirement) => requirement.label ?? requirement.type);
33213
33247
  checks.push({
@@ -33399,6 +33433,9 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
33399
33433
  opsActions: "/voice/ops-actions",
33400
33434
  opsRecovery: "/ops-recovery",
33401
33435
  phoneAgentSmoke: "/sessions",
33436
+ profileSwitchLiveDecisions: "/voice/profile-switch-live-decisions",
33437
+ profileSwitchPolicy: "/voice/profile-switch-policy",
33438
+ profileSwitchReadiness: "/voice/profile-switch-readiness",
33402
33439
  telephonyMedia: "/voice/telephony-media",
33403
33440
  telephonyWebhookSecurity: "/api/voice/telephony/webhook-security",
33404
33441
  providerContracts: "/provider-contracts",
@@ -33452,6 +33489,15 @@ var buildVoiceProductionReadinessReport = async (options, input = {}) => {
33452
33489
  providerContractMatrix,
33453
33490
  providerOrchestration: providerOrchestrationSummary,
33454
33491
  providerRecovery,
33492
+ profileSwitchReadiness: profileSwitchReadiness ? {
33493
+ auditEvents: profileSwitchReadiness.summary.auditEvents,
33494
+ decisions: profileSwitchReadiness.summary.decisions,
33495
+ issues: profileSwitchReadiness.issues.length,
33496
+ policyCases: profileSwitchReadiness.summary.policyCases,
33497
+ sessions: profileSwitchReadiness.summary.sessions,
33498
+ status: profileSwitchReadiness.status,
33499
+ traceEvents: profileSwitchReadiness.summary.traceEvents
33500
+ } : undefined,
33455
33501
  phoneAgentSmokes: phoneAgentSmokeSummary,
33456
33502
  telephonyMedia: telephonyMediaSummary,
33457
33503
  telephonyWebhookSecurity: telephonyWebhookSecuritySummary,
@@ -22,6 +22,7 @@ import { type VoiceObservabilityExportDeliveryHistory, type VoiceObservabilityEx
22
22
  import type { VoiceMediaPipelineReport } from './mediaPipelineRoutes';
23
23
  import type { VoiceTelephonyMediaReport } from './telephonyMediaRoutes';
24
24
  import type { MediaWebRTCStatsReport } from '@absolutejs/media';
25
+ import { type VoiceProfileSwitchReadinessOptions, type VoiceProfileSwitchReadinessReport } from './profileSwitchRecommendation';
25
26
  export type VoiceProductionReadinessObservabilityExportDeliveryHistoryOptions = {
26
27
  failOnMissing?: boolean;
27
28
  failOnStale?: boolean;
@@ -140,6 +141,9 @@ export type VoiceProductionReadinessReport = {
140
141
  opsActions?: string;
141
142
  opsRecovery?: string;
142
143
  phoneAgentSmoke?: string;
144
+ profileSwitchLiveDecisions?: string;
145
+ profileSwitchPolicy?: string;
146
+ profileSwitchReadiness?: string;
143
147
  telephonyWebhookSecurity?: string;
144
148
  telephonyMedia?: string;
145
149
  providerContracts?: string;
@@ -283,6 +287,15 @@ export type VoiceProductionReadinessReport = {
283
287
  warned: number;
284
288
  };
285
289
  providerRecovery: VoiceProviderFallbackRecoverySummary;
290
+ profileSwitchReadiness?: {
291
+ auditEvents: number;
292
+ decisions: number;
293
+ issues: number;
294
+ policyCases?: number;
295
+ sessions: number;
296
+ status: VoiceProductionReadinessStatus;
297
+ traceEvents: number;
298
+ };
286
299
  phoneAgentSmokes?: {
287
300
  failed: number;
288
301
  passed: number;
@@ -540,6 +553,10 @@ export type VoiceProductionReadinessRoutesOptions = {
540
553
  query: Record<string, unknown>;
541
554
  request: Request;
542
555
  }) => Promise<VoiceProviderOrchestrationReport> | VoiceProviderOrchestrationReport);
556
+ profileSwitchReadiness?: false | VoiceProfileSwitchReadinessReport | VoiceProfileSwitchReadinessOptions | ((input: {
557
+ query: Record<string, unknown>;
558
+ request: Request;
559
+ }) => Promise<VoiceProfileSwitchReadinessReport | VoiceProfileSwitchReadinessOptions> | VoiceProfileSwitchReadinessReport | VoiceProfileSwitchReadinessOptions);
543
560
  providerStack?: false | VoiceProviderStackCapabilityGapReport | ((input: {
544
561
  query: Record<string, unknown>;
545
562
  request: Request;
@@ -564,6 +581,7 @@ export type VoiceProductionReadinessRoutesOptions = {
564
581
  title?: string;
565
582
  traceDeliveries?: false | VoiceProductionReadinessTraceDeliveryOptions;
566
583
  ttsProviders?: readonly string[];
584
+ traceMaxAgeMs?: number;
567
585
  liveLatencyWarnAfterMs?: number;
568
586
  liveLatencyFailAfterMs?: number;
569
587
  liveLatencyMaxAgeMs?: number;
@@ -56,6 +56,9 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
56
56
  readonly opsActions?: string | undefined;
57
57
  readonly opsRecovery?: string | undefined;
58
58
  readonly phoneAgentSmoke?: string | undefined;
59
+ readonly profileSwitchLiveDecisions?: string | undefined;
60
+ readonly profileSwitchPolicy?: string | undefined;
61
+ readonly profileSwitchReadiness?: string | undefined;
59
62
  readonly telephonyWebhookSecurity?: string | undefined;
60
63
  readonly telephonyMedia?: string | undefined;
61
64
  readonly providerContracts?: string | undefined;
@@ -369,6 +372,15 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
369
372
  readonly unresolvedErrors: number;
370
373
  readonly unresolvedSessions: number;
371
374
  };
375
+ readonly profileSwitchReadiness?: {
376
+ readonly auditEvents: number;
377
+ readonly decisions: number;
378
+ readonly issues: number;
379
+ readonly policyCases?: number | undefined;
380
+ readonly sessions: number;
381
+ readonly status: import("..").VoiceProductionReadinessStatus;
382
+ readonly traceEvents: number;
383
+ } | undefined;
372
384
  readonly phoneAgentSmokes?: {
373
385
  readonly failed: number;
374
386
  readonly passed: number;
@@ -489,6 +501,9 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
489
501
  readonly opsActions?: string | undefined;
490
502
  readonly opsRecovery?: string | undefined;
491
503
  readonly phoneAgentSmoke?: string | undefined;
504
+ readonly profileSwitchLiveDecisions?: string | undefined;
505
+ readonly profileSwitchPolicy?: string | undefined;
506
+ readonly profileSwitchReadiness?: string | undefined;
492
507
  readonly telephonyWebhookSecurity?: string | undefined;
493
508
  readonly telephonyMedia?: string | undefined;
494
509
  readonly providerContracts?: string | undefined;
@@ -802,6 +817,15 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
802
817
  readonly unresolvedErrors: number;
803
818
  readonly unresolvedSessions: number;
804
819
  };
820
+ readonly profileSwitchReadiness?: {
821
+ readonly auditEvents: number;
822
+ readonly decisions: number;
823
+ readonly issues: number;
824
+ readonly policyCases?: number | undefined;
825
+ readonly sessions: number;
826
+ readonly status: import("..").VoiceProductionReadinessStatus;
827
+ readonly traceEvents: number;
828
+ } | undefined;
805
829
  readonly phoneAgentSmokes?: {
806
830
  readonly failed: number;
807
831
  readonly passed: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.362",
3
+ "version": "0.0.22-beta.364",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",