@absolutejs/voice 0.0.22-beta.451 → 0.0.22-beta.453

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.
@@ -6261,6 +6261,7 @@ var readString = (value) => typeof value === "string" && value.trim() ? value :
6261
6261
  var readNumber2 = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
6262
6262
  var readProofTrendMaxLiveP95 = (report) => report.summary.maxLiveP95Ms ?? maxNumber(report.cycles.map((cycle) => cycle.liveLatency?.p95Ms));
6263
6263
  var readProofTrendMaxProviderP95 = (report) => report.summary.maxProviderP95Ms ?? maxNumber((report.summary.providers ?? []).map((provider) => provider.p95Ms)) ?? maxNumber(report.cycles.flatMap((cycle) => (cycle.providers ?? []).map((provider) => provider.p95Ms)));
6264
+ var readProofTrendMaxReconnectP95 = (report) => report.summary.maxReconnectP95Ms ?? report.summary.reconnect?.resumeLatencyP95Ms ?? maxNumber(report.cycles.map((cycle) => cycle.reconnect?.resumeLatencyP95Ms));
6264
6265
  var readProofTrendMaxTurnP95 = (report) => report.summary.maxTurnP95Ms ?? maxNumber(report.cycles.map((cycle) => cycle.turnLatency?.p95Ms));
6265
6266
  var readRuntimeChannelMetric = (report, key) => {
6266
6267
  const summaryValue = report.summary.runtimeChannel?.[key];
@@ -6322,6 +6323,42 @@ var aggregateProofTrendRuntimeChannel = (channels) => {
6322
6323
  status: channels.some((channel) => channel.status === "fail") ? "fail" : channels.some((channel) => channel.status === "warn") ? "warn" : channels.every((channel) => channel.status === "pass") ? "pass" : undefined
6323
6324
  };
6324
6325
  };
6326
+ var aggregateProofTrendReconnect = (reconnects) => {
6327
+ if (reconnects.length === 0) {
6328
+ return;
6329
+ }
6330
+ const hasFailure = reconnects.some((reconnect) => reconnect.status === "fail" || reconnect.exhausted === true || reconnect.reconnected === false || reconnect.resumed === false);
6331
+ return {
6332
+ attempts: maxNumber(reconnects.map((reconnect) => reconnect.attempts)),
6333
+ exhausted: reconnects.some((reconnect) => reconnect.exhausted === true),
6334
+ maxAttempts: maxNumber(reconnects.map((reconnect) => reconnect.maxAttempts)),
6335
+ resumeLatencyP95Ms: maxNumber(reconnects.map((reconnect) => reconnect.resumeLatencyP95Ms)),
6336
+ reconnected: reconnects.some((reconnect) => reconnect.reconnected === true),
6337
+ resumed: reconnects.some((reconnect) => reconnect.resumed === true),
6338
+ samples: reconnects.reduce((total, reconnect) => total + (reconnect.samples ?? 0), 0),
6339
+ snapshotCount: reconnects.reduce((total, reconnect) => total + (reconnect.snapshotCount ?? 0), 0),
6340
+ status: hasFailure ? "fail" : reconnects.some((reconnect) => reconnect.status === "warn") ? "warn" : "pass"
6341
+ };
6342
+ };
6343
+ var summarizeReconnectTraceEvidence = (events) => {
6344
+ const reconnectEvents = events.filter((event) => event.type === "client.reconnect");
6345
+ if (reconnectEvents.length === 0) {
6346
+ return;
6347
+ }
6348
+ const statuses = reconnectEvents.map((event) => readString(readTraceRecord(event).status)).filter((status) => status !== undefined);
6349
+ const reconnectPayloads = reconnectEvents.map((event) => readTraceRecord(event));
6350
+ return {
6351
+ attempts: maxNumber(reconnectPayloads.map((payload) => readNumber2(payload.attempts))),
6352
+ exhausted: statuses.includes("exhausted"),
6353
+ maxAttempts: maxNumber(reconnectPayloads.map((payload) => readNumber2(payload.maxAttempts))),
6354
+ resumeLatencyP95Ms: percentile(reconnectPayloads.map((payload) => readNumber2(payload.resumeLatencyP95Ms) ?? readNumber2(payload.resumeLatencyMs)).filter((value) => value !== undefined), 95),
6355
+ reconnected: statuses.includes("reconnecting"),
6356
+ resumed: statuses.includes("resumed") || statuses.includes("pass"),
6357
+ samples: reconnectEvents.length,
6358
+ snapshotCount: reconnectEvents.length,
6359
+ status: reconnectEvents.some((event) => isFailingTraceStatus(readTraceStatus(readTraceRecord(event)))) ? "fail" : "pass"
6360
+ };
6361
+ };
6325
6362
  var readTraceRecord = (event) => event.payload;
6326
6363
  var readTraceProfileId = (events, options) => {
6327
6364
  for (const event of events) {
@@ -6469,6 +6506,7 @@ var buildVoiceRealCallProfileEvidenceFromTraceEvents = (events, options = {}) =>
6469
6506
  }).filter((value) => value !== undefined);
6470
6507
  const turnP95Ms = summarizeTurnTraceP95(sessionEvents);
6471
6508
  const providerP95Ms = maxNumber(providers.map((provider) => provider.p95Ms));
6509
+ const reconnect = summarizeReconnectTraceEvidence(sessionEvents);
6472
6510
  const runtimeChannel = summarizeRuntimeChannelTraceEvidence(sessionEvents);
6473
6511
  const surfaces = readRealCallProfileTraceSurfaces(sessionEvents);
6474
6512
  if (providers.length === 0 && runtimeChannel === undefined && liveLatencies.length === 0 && surfaces.length === 0) {
@@ -6484,6 +6522,7 @@ var buildVoiceRealCallProfileEvidenceFromTraceEvents = (events, options = {}) =>
6484
6522
  profileLabel: options.profileLabels?.[profileId] ?? (profileId === options.defaultProfileId ? options.defaultProfileLabel : undefined),
6485
6523
  providerP95Ms,
6486
6524
  providers,
6525
+ reconnect,
6487
6526
  runtimeChannel,
6488
6527
  sessionId,
6489
6528
  surfaces: surfaces.length > 0 ? surfaces : undefined,
@@ -6491,11 +6530,46 @@ var buildVoiceRealCallProfileEvidenceFromTraceEvents = (events, options = {}) =>
6491
6530
  };
6492
6531
  }).filter((evidence) => evidence !== undefined);
6493
6532
  };
6533
+ var normalizeReconnectReport = (report) => ("contract" in report) ? report.contract : report;
6534
+ var buildVoiceRealCallProfileEvidenceFromReconnectProofReports = (input, options = {}) => {
6535
+ const reports = Array.isArray(input) ? input : [input];
6536
+ const profileId = options.profileId ?? "reconnect-resume";
6537
+ return reports.map((report, index) => {
6538
+ const contract = normalizeReconnectReport(report);
6539
+ const generatedAt = "generatedAt" in report ? report.generatedAt : new Date(contract.checkedAt).toISOString();
6540
+ const ok = "ok" in report ? report.ok : contract.pass;
6541
+ const operationsRecordHref = typeof options.operationsRecordHref === "function" ? options.operationsRecordHref(report, index) : options.operationsRecordHref;
6542
+ const sessionId = typeof options.sessionId === "function" ? options.sessionId(report, index) : options.sessionId ?? `reconnect-proof-${String(index + 1)}-${String(contract.checkedAt)}`;
6543
+ return {
6544
+ generatedAt,
6545
+ ok,
6546
+ operationsRecordHref,
6547
+ profileDescription: options.profileDescription,
6548
+ profileId,
6549
+ profileLabel: options.profileLabel,
6550
+ reconnect: {
6551
+ attempts: contract.summary.attempts,
6552
+ exhausted: contract.summary.exhausted,
6553
+ maxAttempts: contract.summary.maxAttempts,
6554
+ resumeLatencyP95Ms: contract.resumeLatencyP95Ms,
6555
+ reconnected: contract.summary.reconnected,
6556
+ resumed: contract.summary.resumed,
6557
+ samples: 1,
6558
+ snapshotCount: contract.snapshotCount,
6559
+ status: ok ? "pass" : "fail"
6560
+ },
6561
+ sessionId,
6562
+ surfaces: [...new Set(["reconnect", ...options.surfaces ?? []])].sort()
6563
+ };
6564
+ });
6565
+ };
6494
6566
  var loadVoiceRealCallProfileEvidenceFromTraceStore = async (options) => buildVoiceRealCallProfileEvidenceFromTraceEvents(await options.store.list({ limit: options.limit ?? 5000 }), options);
6567
+ var loadVoiceRealCallProfileEvidenceFromStore = async (options) => options.store.list(options);
6495
6568
  var realCallProfileTraceSignalTypes = new Set([
6496
6569
  "client.barge_in",
6497
6570
  "client.browser_media",
6498
6571
  "client.live_latency",
6572
+ "client.reconnect",
6499
6573
  "client.telephony_media",
6500
6574
  "provider.decision",
6501
6575
  "session.error",
@@ -6558,15 +6632,16 @@ var readProofTrendProviders = (reports) => aggregateProofTrendProviders(reports.
6558
6632
  var exceedsProofTrendBudget = (value, budget) => value !== undefined && (!Number.isFinite(value) || value > budget);
6559
6633
  var readProofTrendProfileStatus = (profile, budgets) => {
6560
6634
  const runtimeChannel = profile.runtimeChannel;
6561
- const hasBudgetEvidence = profile.maxLiveP95Ms !== undefined || profile.maxProviderP95Ms !== undefined || profile.maxTurnP95Ms !== undefined || profile.providers?.some((provider) => provider.p95Ms !== undefined) === true || runtimeChannel?.maxFirstAudioLatencyMs !== undefined || runtimeChannel?.maxInterruptionP95Ms !== undefined || runtimeChannel?.maxJitterMs !== undefined || runtimeChannel?.maxTimestampDriftMs !== undefined || runtimeChannel?.maxBackpressureEvents !== undefined;
6562
- const budgetFailed = exceedsProofTrendBudget(profile.maxLiveP95Ms, budgets.maxLiveP95Ms) || exceedsProofTrendBudget(profile.maxProviderP95Ms, budgets.maxProviderP95Ms) || exceedsProofTrendBudget(profile.maxTurnP95Ms, budgets.maxTurnP95Ms) || exceedsProofTrendBudget(runtimeChannel?.maxFirstAudioLatencyMs, budgets.maxRuntimeFirstAudioLatencyMs) || exceedsProofTrendBudget(runtimeChannel?.maxInterruptionP95Ms, budgets.maxRuntimeInterruptionP95Ms) || exceedsProofTrendBudget(runtimeChannel?.maxJitterMs, budgets.maxRuntimeJitterMs) || exceedsProofTrendBudget(runtimeChannel?.maxTimestampDriftMs, budgets.maxRuntimeTimestampDriftMs) || exceedsProofTrendBudget(runtimeChannel?.maxBackpressureEvents, 0);
6635
+ const reconnect = profile.reconnect;
6636
+ const hasBudgetEvidence = profile.maxLiveP95Ms !== undefined || profile.maxProviderP95Ms !== undefined || profile.maxReconnectP95Ms !== undefined || profile.maxTurnP95Ms !== undefined || profile.providers?.some((provider) => provider.p95Ms !== undefined) === true || runtimeChannel?.maxFirstAudioLatencyMs !== undefined || runtimeChannel?.maxInterruptionP95Ms !== undefined || runtimeChannel?.maxJitterMs !== undefined || runtimeChannel?.maxTimestampDriftMs !== undefined || runtimeChannel?.maxBackpressureEvents !== undefined || reconnect?.resumeLatencyP95Ms !== undefined || reconnect?.samples !== undefined;
6637
+ const budgetFailed = exceedsProofTrendBudget(profile.maxLiveP95Ms, budgets.maxLiveP95Ms) || exceedsProofTrendBudget(profile.maxProviderP95Ms, budgets.maxProviderP95Ms) || exceedsProofTrendBudget(profile.maxReconnectP95Ms ?? reconnect?.resumeLatencyP95Ms, budgets.maxReconnectP95Ms) || exceedsProofTrendBudget(profile.maxTurnP95Ms, budgets.maxTurnP95Ms) || exceedsProofTrendBudget(runtimeChannel?.maxFirstAudioLatencyMs, budgets.maxRuntimeFirstAudioLatencyMs) || exceedsProofTrendBudget(runtimeChannel?.maxInterruptionP95Ms, budgets.maxRuntimeInterruptionP95Ms) || exceedsProofTrendBudget(runtimeChannel?.maxJitterMs, budgets.maxRuntimeJitterMs) || exceedsProofTrendBudget(runtimeChannel?.maxTimestampDriftMs, budgets.maxRuntimeTimestampDriftMs) || exceedsProofTrendBudget(runtimeChannel?.maxBackpressureEvents, 0) || reconnect?.status === "fail";
6563
6638
  if (budgetFailed || !hasBudgetEvidence && profile.status === "fail") {
6564
6639
  return "fail";
6565
6640
  }
6566
- if (profile.status === "warn" || runtimeChannel?.status === "warn" || profile.providers?.some((provider) => provider.status === "warn") === true) {
6641
+ if (profile.status === "warn" || reconnect?.status === "warn" || runtimeChannel?.status === "warn" || profile.providers?.some((provider) => provider.status === "warn") === true) {
6567
6642
  return "warn";
6568
6643
  }
6569
- if (hasBudgetEvidence || profile.status === "pass" || runtimeChannel?.status === "pass" || profile.providers?.some((provider) => provider.status === "pass") === true) {
6644
+ if (hasBudgetEvidence || profile.status === "pass" || reconnect?.status === "pass" || runtimeChannel?.status === "pass" || profile.providers?.some((provider) => provider.status === "pass") === true) {
6570
6645
  return "pass";
6571
6646
  }
6572
6647
  return;
@@ -6576,6 +6651,7 @@ var buildVoiceProofTrendProfileSummaries = (input, options = {}) => {
6576
6651
  const definitions = options.profiles ?? DEFAULT_VOICE_PROOF_TREND_PROFILE_DEFINITIONS;
6577
6652
  const providerCap = options.maxProviderP95Ms ?? 1000;
6578
6653
  const liveCap = options.maxLiveP95Ms ?? 800;
6654
+ const reconnectCap = options.maxReconnectP95Ms ?? 1500;
6579
6655
  const turnCap = options.maxTurnP95Ms ?? 700;
6580
6656
  const runtimeFirstAudioCap = options.maxRuntimeFirstAudioLatencyMs ?? 600;
6581
6657
  const runtimeInterruptionCap = options.maxRuntimeInterruptionP95Ms ?? 300;
@@ -6584,6 +6660,7 @@ var buildVoiceProofTrendProfileSummaries = (input, options = {}) => {
6584
6660
  const budgets = {
6585
6661
  maxLiveP95Ms: liveCap,
6586
6662
  maxProviderP95Ms: providerCap,
6663
+ maxReconnectP95Ms: reconnectCap,
6587
6664
  maxRuntimeFirstAudioLatencyMs: runtimeFirstAudioCap,
6588
6665
  maxRuntimeInterruptionP95Ms: runtimeInterruptionCap,
6589
6666
  maxRuntimeJitterMs: runtimeJitterCap,
@@ -6606,8 +6683,10 @@ var buildVoiceProofTrendProfileSummaries = (input, options = {}) => {
6606
6683
  label: definition.label ?? profiles.find(Boolean)?.label,
6607
6684
  maxLiveP95Ms: maxNumber(profiles.map((profile) => profile.maxLiveP95Ms)),
6608
6685
  maxProviderP95Ms: maxNumber(profiles.map((profile) => profile.maxProviderP95Ms)),
6686
+ maxReconnectP95Ms: maxNumber(profiles.map((profile) => profile.maxReconnectP95Ms)),
6609
6687
  maxTurnP95Ms: maxNumber(profiles.map((profile) => profile.maxTurnP95Ms)),
6610
6688
  providers: aggregateProofTrendProviders(profiles.flatMap((profile) => profile.providers ?? [])),
6689
+ reconnect: aggregateProofTrendReconnect(profiles.map((profile) => profile.reconnect).filter((reconnect) => reconnect !== undefined)),
6611
6690
  runtimeChannel: aggregateProofTrendRuntimeChannel(profiles.map((profile) => profile.runtimeChannel).filter((channel) => channel !== undefined)),
6612
6691
  sessionCount: profiles.reduce((total, profile) => total + (profile.sessionCount ?? 0), 0),
6613
6692
  surfaces: [
@@ -6647,6 +6726,7 @@ var buildVoiceProofTrendProfileSummaries = (input, options = {}) => {
6647
6726
  var buildVoiceProofTrendReportFromRealCallProfiles = (options) => {
6648
6727
  const providerCap = options.maxProviderP95Ms ?? 1000;
6649
6728
  const liveCap = options.maxLiveP95Ms ?? 800;
6729
+ const reconnectCap = options.maxReconnectP95Ms ?? 1500;
6650
6730
  const turnCap = options.maxTurnP95Ms ?? 700;
6651
6731
  const runtimeFirstAudioCap = options.maxRuntimeFirstAudioLatencyMs ?? 600;
6652
6732
  const runtimeInterruptionCap = options.maxRuntimeInterruptionP95Ms ?? 300;
@@ -6655,6 +6735,7 @@ var buildVoiceProofTrendReportFromRealCallProfiles = (options) => {
6655
6735
  const budgets = {
6656
6736
  maxLiveP95Ms: liveCap,
6657
6737
  maxProviderP95Ms: providerCap,
6738
+ maxReconnectP95Ms: reconnectCap,
6658
6739
  maxRuntimeFirstAudioLatencyMs: runtimeFirstAudioCap,
6659
6740
  maxRuntimeInterruptionP95Ms: runtimeInterruptionCap,
6660
6741
  maxRuntimeJitterMs: runtimeJitterCap,
@@ -6684,8 +6765,10 @@ var buildVoiceProofTrendReportFromRealCallProfiles = (options) => {
6684
6765
  label: definition.label ?? matchingEvidence.find((evidence) => evidence.profileLabel)?.profileLabel,
6685
6766
  maxLiveP95Ms: maxNumber(matchingEvidence.map((evidence) => evidence.liveP95Ms)),
6686
6767
  maxProviderP95Ms: maxNumber(matchingEvidence.map((evidence) => evidence.providerP95Ms)),
6768
+ maxReconnectP95Ms: maxNumber(matchingEvidence.map((evidence) => evidence.reconnect?.resumeLatencyP95Ms)),
6687
6769
  maxTurnP95Ms: maxNumber(matchingEvidence.map((evidence) => evidence.turnP95Ms)),
6688
6770
  providers: aggregateProofTrendProviders(matchingEvidence.flatMap((evidence) => evidence.providers ?? [])),
6771
+ reconnect: aggregateProofTrendReconnect(matchingEvidence.map((evidence) => evidence.reconnect).filter((reconnect) => reconnect !== undefined)),
6689
6772
  runtimeChannel: aggregateProofTrendRuntimeChannel(matchingEvidence.map((evidence) => evidence.runtimeChannel).filter((channel) => channel !== undefined)),
6690
6773
  sessionCount: new Set(matchingEvidence.map((evidence) => evidence.sessionId)).size,
6691
6774
  surfaces: [
@@ -6704,6 +6787,7 @@ var buildVoiceProofTrendReportFromRealCallProfiles = (options) => {
6704
6787
  ok: evidence.ok !== false,
6705
6788
  providers: evidence.providers,
6706
6789
  runtimeChannel: evidence.runtimeChannel,
6790
+ reconnect: evidence.reconnect,
6707
6791
  turnLatency: evidence.turnP95Ms === undefined ? undefined : {
6708
6792
  p95Ms: evidence.turnP95Ms,
6709
6793
  samples: 1,
@@ -6714,9 +6798,11 @@ var buildVoiceProofTrendReportFromRealCallProfiles = (options) => {
6714
6798
  cycles: options.evidence.length,
6715
6799
  maxLiveP95Ms: maxNumber(options.evidence.map((evidence) => evidence.liveP95Ms)),
6716
6800
  maxProviderP95Ms: maxNumber(options.evidence.map((evidence) => evidence.providerP95Ms)),
6801
+ maxReconnectP95Ms: maxNumber(options.evidence.map((evidence) => evidence.reconnect?.resumeLatencyP95Ms)),
6717
6802
  maxTurnP95Ms: maxNumber(options.evidence.map((evidence) => evidence.turnP95Ms)),
6718
6803
  profiles,
6719
6804
  providers: aggregateProofTrendProviders(options.evidence.flatMap((evidence) => evidence.providers ?? [])),
6805
+ reconnect: aggregateProofTrendReconnect(options.evidence.map((evidence) => evidence.reconnect).filter((reconnect) => reconnect !== undefined)),
6720
6806
  runtimeChannel: aggregateProofTrendRuntimeChannel(options.evidence.map((evidence) => evidence.runtimeChannel).filter((channel) => channel !== undefined))
6721
6807
  };
6722
6808
  return buildVoiceProofTrendReport({
@@ -7321,6 +7407,74 @@ var createVoiceInMemoryRealCallProfileRecoveryJobStore = (options = {}) => {
7321
7407
  }
7322
7408
  };
7323
7409
  };
7410
+ var normalizeRealCallProfileEvidenceTableName = (value) => value.trim().replace(/[^a-zA-Z0-9_]+/g, "_").replace(/^_+|_+$/g, "") || "voice_real_call_profile_evidence";
7411
+ var parseRealCallProfileEvidenceBoundary = (value) => value === undefined ? undefined : value instanceof Date ? value.getTime() : typeof value === "number" ? value : Date.parse(value);
7412
+ var readRealCallProfileEvidenceSortTime = (evidence, fallback) => Date.parse(evidence.generatedAt ?? fallback) || Date.parse(fallback);
7413
+ var createVoiceSQLiteRealCallProfileEvidenceStore = (options = {}) => {
7414
+ const { Database: SQLiteDatabase } = __require("bun:sqlite");
7415
+ const database = options.database ?? new SQLiteDatabase(options.path ?? ":memory:", {
7416
+ create: true
7417
+ });
7418
+ const tableName = normalizeRealCallProfileEvidenceTableName(options.tableName ?? "voice_real_call_profile_evidence");
7419
+ const now = () => (options.now ?? (() => new Date))().toISOString();
7420
+ const createId = () => `${options.idPrefix ?? "voice-profile-evidence"}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
7421
+ database.exec("PRAGMA journal_mode = WAL;");
7422
+ database.exec("PRAGMA synchronous = NORMAL;");
7423
+ database.exec("PRAGMA busy_timeout = 5000;");
7424
+ database.exec(`CREATE TABLE IF NOT EXISTS "${tableName}" (
7425
+ id TEXT PRIMARY KEY,
7426
+ sort_at INTEGER NOT NULL,
7427
+ profile_id TEXT NOT NULL,
7428
+ session_id TEXT NOT NULL,
7429
+ created_at TEXT NOT NULL,
7430
+ payload TEXT NOT NULL
7431
+ )`);
7432
+ const selectStatement = database.query(`SELECT payload FROM "${tableName}" WHERE id = ?1 LIMIT 1`);
7433
+ const listStatement = database.query(`SELECT payload FROM "${tableName}" ORDER BY sort_at DESC, id DESC`);
7434
+ const upsertStatement = database.query(`INSERT INTO "${tableName}" (id, sort_at, profile_id, session_id, created_at, payload)
7435
+ VALUES (?1, ?2, ?3, ?4, ?5, ?6)
7436
+ ON CONFLICT(id) DO UPDATE SET
7437
+ sort_at = excluded.sort_at,
7438
+ profile_id = excluded.profile_id,
7439
+ session_id = excluded.session_id,
7440
+ created_at = excluded.created_at,
7441
+ payload = excluded.payload`);
7442
+ const deleteStatement = database.query(`DELETE FROM "${tableName}" WHERE id = ?1`);
7443
+ const writeEvidence = (record) => {
7444
+ upsertStatement.run(record.id, readRealCallProfileEvidenceSortTime(record, record.createdAt), record.profileId, record.sessionId, record.createdAt, JSON.stringify(record));
7445
+ return record;
7446
+ };
7447
+ const readEvidence = (id) => {
7448
+ const row = selectStatement.get(id);
7449
+ return row ? JSON.parse(row.payload) : undefined;
7450
+ };
7451
+ const matchesListOptions = (record, input) => {
7452
+ const evidenceTime = readRealCallProfileEvidenceSortTime(record, record.createdAt);
7453
+ const since = parseRealCallProfileEvidenceBoundary(input.since);
7454
+ const until = parseRealCallProfileEvidenceBoundary(input.until);
7455
+ return (!input.profileId || record.profileId === input.profileId) && (!input.sessionId || record.sessionId === input.sessionId) && (since === undefined || Number.isNaN(since) || evidenceTime >= since) && (until === undefined || Number.isNaN(until) || evidenceTime <= until);
7456
+ };
7457
+ return {
7458
+ append(input) {
7459
+ const createdAt = input.createdAt ?? now();
7460
+ return writeEvidence({
7461
+ ...input,
7462
+ createdAt,
7463
+ id: input.id ?? createId()
7464
+ });
7465
+ },
7466
+ get(id) {
7467
+ return readEvidence(id);
7468
+ },
7469
+ list(input = {}) {
7470
+ const limit = Number.isFinite(input.limit) && input.limit !== undefined && input.limit > 0 ? Math.floor(input.limit) : 500;
7471
+ return listStatement.all().map((row) => JSON.parse(row.payload)).filter((record) => matchesListOptions(record, input)).slice(0, limit);
7472
+ },
7473
+ remove(id) {
7474
+ deleteStatement.run(id);
7475
+ }
7476
+ };
7477
+ };
7324
7478
  var normalizeRealCallRecoveryJobTableName = (value) => value.trim().replace(/[^a-zA-Z0-9_]+/g, "_").replace(/^_+|_+$/g, "") || "voice_real_call_profile_recovery_jobs";
7325
7479
  var createVoiceSQLiteRealCallProfileRecoveryJobStore = (options = {}) => {
7326
7480
  const { Database: SQLiteDatabase } = __require("bun:sqlite");
@@ -7535,10 +7689,12 @@ var buildVoiceRealCallProfileHistoryReport = (options = {}) => {
7535
7689
  failedReports: history.filter((report) => report.ok !== true).length,
7536
7690
  maxLiveP95Ms: maxNumber(profileHistory.map(readProofTrendMaxLiveP95)),
7537
7691
  maxProviderP95Ms: maxNumber(profileHistory.map(readProofTrendMaxProviderP95)),
7692
+ maxReconnectP95Ms: maxNumber(profileHistory.map(readProofTrendMaxReconnectP95)),
7538
7693
  maxTurnP95Ms: maxNumber(profileHistory.map(readProofTrendMaxTurnP95)),
7539
7694
  profileCount: profiles.length,
7540
7695
  profiles,
7541
7696
  providers: readProofTrendProviders(profileHistory),
7697
+ reconnect: aggregateProofTrendReconnect(profileHistory.map((report) => report.summary.reconnect).filter((reconnect) => reconnect !== undefined)),
7542
7698
  runtimeChannel: aggregateProofTrendRuntimeChannel(profileHistory.map(readProofTrendRuntimeChannel).filter((channel) => channel !== undefined))
7543
7699
  };
7544
7700
  const trend = buildVoiceProofTrendReport({
@@ -7572,6 +7728,13 @@ var buildVoiceRealCallProfileHistoryReport = (options = {}) => {
7572
7728
  trend
7573
7729
  };
7574
7730
  };
7731
+ var buildVoiceRealCallProfileHistoryReportFromStore = async (options) => {
7732
+ const evidence = await options.store.list(options);
7733
+ return buildVoiceRealCallProfileHistoryReport({
7734
+ ...options,
7735
+ evidence
7736
+ });
7737
+ };
7575
7738
  var normalizeProviderStatus = (status) => status === "pass" ? "pass" : status === "fail" ? "fail" : "warn";
7576
7739
  var providerSortScore = (provider) => [
7577
7740
  recommendationStatusRank[provider.status],
package/dist/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { assertVoicePlatformCoverage, buildVoicePlatformCoverageSummary, createV
31
31
  export { assertVoiceCompetitiveCoverage, buildVoiceCompetitiveCoverageReport, createVoiceCompetitiveCoverageRoutes, evaluateVoiceCompetitiveCoverage, renderVoiceCompetitiveCoverageHTML, renderVoiceCompetitiveCoverageMarkdown, } from "./competitiveCoverage";
32
32
  export type { VoiceCompetitiveCoverageAssertionInput, VoiceCompetitiveCoverageAssertionReport, VoiceCompetitiveCoverageIssue, VoiceCompetitiveCoverageLevel, VoiceCompetitiveCoverageReport, VoiceCompetitiveCoverageReportInput, VoiceCompetitiveCoverageRoutesOptions, VoiceCompetitiveCoverageStatus, VoiceCompetitiveCoverageSummary, VoiceCompetitiveDepthLevel, VoiceCompetitiveEvidence, VoiceCompetitiveSurface, } from "./competitiveCoverage";
33
33
  export type { VoicePlatformCoverageAssertionInput, VoicePlatformCoverageAssertionReport, VoicePlatformCoverageEvidence, VoicePlatformCoverageRoutesOptions, VoicePlatformCoverageStatus, VoicePlatformCoverageSummary, VoicePlatformCoverageSummaryInput, VoicePlatformCoverageSurface, } from "./platformCoverage";
34
- export { assertVoiceProofTrendEvidence, appendVoiceRealCallProfileRecoveryEvidence, buildEmptyVoiceProofTrendReport, buildVoiceProofTrendProfileSummaries, buildVoiceProofTrendRecommendationReport, buildVoiceProofTrendReportFromRealCallProfiles, buildVoiceProofTrendReport, buildVoiceRealCallProfileEvidenceFromTraceEvents, buildVoiceRealCallProfileDefaults, buildVoiceRealCallProfileHistoryReport, buildVoiceRealCallProfileReadinessCheck, buildVoiceRealCallProfileRecoveryJobHistoryCheck, buildVoiceRealCallProfileRecoveryActions, createVoiceInMemoryRealCallProfileRecoveryJobStore, createVoiceRealCallProfileTraceCollector, createVoiceSQLiteRealCallProfileRecoveryJobStore, createVoiceProofTrendRecommendationRoutes, createVoiceProofTrendRoutes, createVoiceRealCallProfileHistoryRoutes, createVoiceRealCallProfileRecoveryActionRoutes, DEFAULT_VOICE_PROOF_TREND_PROFILE_DEFINITIONS, DEFAULT_VOICE_PROOF_TRENDS_MAX_AGE_MS, evaluateVoiceProofTrendEvidence, formatVoiceProofTrendAge, loadVoiceRealCallProfileEvidenceFromTraceStore, normalizeVoiceProofTrendReport, readVoiceProofTrendReportFile, renderVoiceProofTrendRecommendationHTML, renderVoiceProofTrendRecommendationMarkdown, renderVoiceRealCallProfileHistoryHTML, renderVoiceRealCallProfileHistoryMarkdown, runVoiceRealCallProfileRecoveryLoop, resolveVoiceRealCallProfileProviderRoute, } from "./proofTrends";
34
+ export { assertVoiceProofTrendEvidence, appendVoiceRealCallProfileRecoveryEvidence, buildEmptyVoiceProofTrendReport, buildVoiceProofTrendProfileSummaries, buildVoiceProofTrendRecommendationReport, buildVoiceProofTrendReportFromRealCallProfiles, buildVoiceProofTrendReport, buildVoiceRealCallProfileEvidenceFromTraceEvents, buildVoiceRealCallProfileEvidenceFromReconnectProofReports, buildVoiceRealCallProfileDefaults, buildVoiceRealCallProfileHistoryReport, buildVoiceRealCallProfileHistoryReportFromStore, buildVoiceRealCallProfileReadinessCheck, buildVoiceRealCallProfileRecoveryJobHistoryCheck, buildVoiceRealCallProfileRecoveryActions, createVoiceInMemoryRealCallProfileRecoveryJobStore, createVoiceRealCallProfileTraceCollector, createVoiceSQLiteRealCallProfileEvidenceStore, createVoiceSQLiteRealCallProfileRecoveryJobStore, createVoiceProofTrendRecommendationRoutes, createVoiceProofTrendRoutes, createVoiceRealCallProfileHistoryRoutes, createVoiceRealCallProfileRecoveryActionRoutes, DEFAULT_VOICE_PROOF_TREND_PROFILE_DEFINITIONS, DEFAULT_VOICE_PROOF_TRENDS_MAX_AGE_MS, evaluateVoiceProofTrendEvidence, formatVoiceProofTrendAge, loadVoiceRealCallProfileEvidenceFromStore, loadVoiceRealCallProfileEvidenceFromTraceStore, normalizeVoiceProofTrendReport, readVoiceProofTrendReportFile, renderVoiceProofTrendRecommendationHTML, renderVoiceProofTrendRecommendationMarkdown, renderVoiceRealCallProfileHistoryHTML, renderVoiceRealCallProfileHistoryMarkdown, runVoiceRealCallProfileRecoveryLoop, resolveVoiceRealCallProfileProviderRoute, } from "./proofTrends";
35
35
  export { createVoiceEvidenceAssertion, createVoiceProofAssertion, summarizeVoiceProofAssertions, } from "./proofAssertions";
36
36
  export { buildVoiceSessionSnapshot, buildVoiceSessionSnapshotStatus, createVoiceSessionSnapshotRoutes, parseVoiceSessionSnapshot, } from "./sessionSnapshot";
37
37
  export { buildVoiceCallDebuggerReport, createVoiceCallDebuggerRoutes, renderVoiceCallDebuggerHTML, resolveLatestVoiceCallDebuggerSessionId, } from "./callDebugger";
@@ -46,7 +46,7 @@ export { buildVoiceProviderDecisionTraceReport, createVoiceProviderDecisionTrace
46
46
  export type { VoiceProviderDecisionStatus, VoiceProviderDecisionSurfaceReport, VoiceProviderDecisionTrace, VoiceProviderDecisionTraceInput, VoiceProviderDecisionTraceIssue, VoiceProviderDecisionTraceReport, VoiceProviderDecisionTraceReportOptions, VoiceProviderDecisionTraceRoutesOptions, } from "./providerDecisionTraces";
47
47
  export { appendVoiceIOProviderRouterTraceEvent, appendVoiceProviderRouterTraceEvent, buildVoiceIOProviderRouterTraceEvent, buildVoiceProviderRouterTraceEvent, } from "./providerRouterTraces";
48
48
  export type { VoiceIOProviderRouterTraceAppendOptions, VoiceIOProviderRouterTraceEventOptions, VoiceProviderRouterTraceAppendOptions, VoiceProviderRouterTraceEventOptions, } from "./providerRouterTraces";
49
- export type { VoiceProofTrendAssertionInput, VoiceProofTrendAssertionReport, VoiceProofTrendCycle, VoiceProofTrendProfileDefinition, VoiceProofTrendProfileRecommendation, VoiceProofTrendProfileSummaryOptions, VoiceProofTrendProfileSummary, VoiceProofTrendProviderRecommendation, VoiceProofTrendProviderSummary, VoiceProofTrendRecommendation, VoiceProofTrendRecommendationOptions, VoiceProofTrendRecommendationReport, VoiceProofTrendRecommendationRoutesOptions, VoiceProofTrendRecommendationStatus, VoiceProofTrendRecommendationSurface, VoiceProofTrendRealCallProfileEvidence, VoiceProofTrendRealCallProfileReportOptions, VoiceProofTrendReport, VoiceProofTrendReportInput, VoiceProofTrendRoutesOptions, VoiceProofTrendRuntimeChannelSummary, VoiceProofTrendStatus, VoiceProofTrendSummary, VoiceRealCallProfileDefault, VoiceRealCallProfileDefaultsOptions, VoiceRealCallProfileDefaultsReport, VoiceRealCallProfileHistoryOptions, VoiceRealCallProfileHistoryReport, VoiceRealCallProfileHistoryRoutesOptions, VoiceRealCallProfileProviderRouteOptions, VoiceRealCallProfileReadinessCheckOptions, VoiceRealCallProfileRecoveryActionOptions, VoiceRealCallProfileRecoveryAction, VoiceRealCallProfileRecoveryActionHandler, VoiceRealCallProfileRecoveryActionHandlerInput, VoiceRealCallProfileRecoveryActionId, VoiceRealCallProfileRecoveryJobHistoryCheckOptions, VoiceRealCallProfileRecoveryActionResult, VoiceRealCallProfileRecoveryActionRoutesOptions, VoiceRealCallProfileRecoveryJob, VoiceRealCallProfileRecoveryJobCreateInput, VoiceRealCallProfileRecoveryJobListOptions, VoiceRealCallProfileRecoveryJobStatus, VoiceRealCallProfileRecoveryJobStore, VoiceRealCallProfileRecoveryJobUpdate, VoiceRealCallProfileRecoveryLoopAction, VoiceRealCallProfileRecoveryLoopJob, VoiceRealCallProfileRecoveryLoopJobResult, VoiceRealCallProfileRecoveryLoopOptions, VoiceRealCallProfileRecoveryLoopReport, VoiceRealCallProfileRecoveryLoopStartFailure, VoiceRealCallProfileRecoveryEvidenceOptions, VoiceRealCallProfileRecoveryEvidenceProvider, VoiceRealCallProfileRecoveryEvidenceProviderRole, VoiceRealCallProfileRecoveryEvidenceResult, VoiceSQLiteRealCallProfileRecoveryJobStoreOptions, VoiceRealCallProfileTraceCollector, VoiceRealCallProfileTraceCollectorEvidenceOptions, VoiceRealCallProfileTraceCollectorOptions, VoiceRealCallProfileTraceEvidenceOptions, VoiceRealCallProfileTraceStoreEvidenceOptions, } from "./proofTrends";
49
+ export type { VoiceProofTrendAssertionInput, VoiceProofTrendAssertionReport, VoiceProofTrendCycle, VoiceProofTrendProfileDefinition, VoiceProofTrendProfileRecommendation, VoiceProofTrendProfileSummaryOptions, VoiceProofTrendProfileSummary, VoiceProofTrendProviderRecommendation, VoiceProofTrendProviderSummary, VoiceProofTrendReconnectSummary, VoiceProofTrendRecommendation, VoiceProofTrendRecommendationOptions, VoiceProofTrendRecommendationReport, VoiceProofTrendRecommendationRoutesOptions, VoiceProofTrendRecommendationStatus, VoiceProofTrendRecommendationSurface, VoiceProofTrendRealCallProfileEvidence, VoiceProofTrendRealCallProfileReportOptions, VoiceProofTrendReport, VoiceProofTrendReportInput, VoiceProofTrendRoutesOptions, VoiceProofTrendRuntimeChannelSummary, VoiceProofTrendStatus, VoiceProofTrendSummary, VoiceRealCallProfileDefault, VoiceRealCallProfileDefaultsOptions, VoiceRealCallProfileDefaultsReport, VoiceRealCallProfileEvidenceCreateInput, VoiceRealCallProfileEvidenceListOptions, VoiceRealCallProfileEvidenceRecord, VoiceRealCallProfileEvidenceStore, VoiceRealCallProfileHistoryOptions, VoiceRealCallProfileHistoryReport, VoiceRealCallProfileHistoryRoutesOptions, VoiceRealCallProfileProviderRouteOptions, VoiceRealCallProfileReadinessCheckOptions, VoiceRealCallProfileRecoveryActionOptions, VoiceRealCallProfileRecoveryAction, VoiceRealCallProfileRecoveryActionHandler, VoiceRealCallProfileRecoveryActionHandlerInput, VoiceRealCallProfileRecoveryActionId, VoiceRealCallProfileRecoveryJobHistoryCheckOptions, VoiceRealCallProfileRecoveryActionResult, VoiceRealCallProfileRecoveryActionRoutesOptions, VoiceRealCallProfileRecoveryJob, VoiceRealCallProfileRecoveryJobCreateInput, VoiceRealCallProfileRecoveryJobListOptions, VoiceRealCallProfileRecoveryJobStatus, VoiceRealCallProfileRecoveryJobStore, VoiceRealCallProfileRecoveryJobUpdate, VoiceRealCallProfileRecoveryLoopAction, VoiceRealCallProfileRecoveryLoopJob, VoiceRealCallProfileRecoveryLoopJobResult, VoiceRealCallProfileRecoveryLoopOptions, VoiceRealCallProfileRecoveryLoopReport, VoiceRealCallProfileRecoveryLoopStartFailure, VoiceRealCallProfileRecoveryEvidenceOptions, VoiceRealCallProfileRecoveryEvidenceProvider, VoiceRealCallProfileRecoveryEvidenceProviderRole, VoiceRealCallProfileRecoveryEvidenceResult, VoiceSQLiteRealCallProfileRecoveryJobStoreOptions, VoiceRealCallProfileTraceCollector, VoiceRealCallProfileTraceCollectorEvidenceOptions, VoiceRealCallProfileTraceCollectorOptions, VoiceRealCallProfileTraceEvidenceOptions, VoiceRealCallProfileTraceStoreEvidenceOptions, VoiceReconnectRealCallProfileEvidenceOptions, VoiceSQLiteRealCallProfileEvidenceStoreOptions, } from "./proofTrends";
50
50
  export { assertVoiceSloCalibration, buildVoiceSloCalibrationReport, buildVoiceSloReadinessThresholdReport, createVoiceSloReadinessThresholdOptions, createVoiceSloReadinessThresholdRoutes, createVoiceSloThresholdProfile, createVoiceSloCalibrationRoutes, renderVoiceSloCalibrationMarkdown, renderVoiceSloReadinessThresholdHTML, renderVoiceSloReadinessThresholdMarkdown, } from "./sloCalibration";
51
51
  export type { VoiceSloCalibrationMetricKey, VoiceSloCalibrationOptions, VoiceSloCalibrationReport, VoiceSloCalibrationRoutesOptions, VoiceSloCalibrationSample, VoiceSloCalibrationStatus, VoiceSloCalibrationThreshold, VoiceSloCalibrationThresholds, VoiceSloReadinessThresholdReport, VoiceSloReadinessThresholdReportOptions, VoiceSloReadinessThresholdOptions, VoiceSloReadinessThresholdRoutesOptions, VoiceSloThresholdProfile, } from "./sloCalibration";
52
52
  export { assertVoiceLiveOpsControlEvidence, assertVoiceLiveOpsEvidence, buildVoiceLiveOpsControlState, createVoiceLiveOpsController, createVoiceLiveOpsRoutes, createVoiceMemoryLiveOpsControlStore, evaluateVoiceLiveOpsControlEvidence, evaluateVoiceLiveOpsEvidence, getVoiceLiveOpsControlStatus, VOICE_LIVE_OPS_ACTIONS, } from "./liveOps";