@absolutejs/voice 0.0.22-beta.280 → 0.0.22-beta.282

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
@@ -18,6 +18,8 @@ export { assertVoicePlatformCoverage, buildVoicePlatformCoverageSummary, createV
18
18
  export type { VoicePlatformCoverageAssertionInput, VoicePlatformCoverageAssertionReport, VoicePlatformCoverageEvidence, VoicePlatformCoverageRoutesOptions, VoicePlatformCoverageStatus, VoicePlatformCoverageSummary, VoicePlatformCoverageSummaryInput, VoicePlatformCoverageSurface } from './platformCoverage';
19
19
  export { assertVoiceProofTrendEvidence, buildEmptyVoiceProofTrendReport, buildVoiceProofTrendReport, createVoiceProofTrendRoutes, DEFAULT_VOICE_PROOF_TRENDS_MAX_AGE_MS, evaluateVoiceProofTrendEvidence, formatVoiceProofTrendAge, normalizeVoiceProofTrendReport, readVoiceProofTrendReportFile } from './proofTrends';
20
20
  export type { VoiceProofTrendAssertionInput, VoiceProofTrendAssertionReport, VoiceProofTrendCycle, VoiceProofTrendReport, VoiceProofTrendReportInput, VoiceProofTrendRoutesOptions, VoiceProofTrendStatus, VoiceProofTrendSummary } from './proofTrends';
21
+ export { assertVoiceSloCalibration, buildVoiceSloCalibrationReport, createVoiceSloThresholdProfile, createVoiceSloCalibrationRoutes, renderVoiceSloCalibrationMarkdown } from './sloCalibration';
22
+ export type { VoiceSloCalibrationMetricKey, VoiceSloCalibrationOptions, VoiceSloCalibrationReport, VoiceSloCalibrationRoutesOptions, VoiceSloCalibrationSample, VoiceSloCalibrationStatus, VoiceSloCalibrationThreshold, VoiceSloCalibrationThresholds, VoiceSloThresholdProfile } from './sloCalibration';
21
23
  export { assertVoiceLiveOpsControlEvidence, assertVoiceLiveOpsEvidence, buildVoiceLiveOpsControlState, createVoiceLiveOpsController, createVoiceLiveOpsRoutes, createVoiceMemoryLiveOpsControlStore, evaluateVoiceLiveOpsControlEvidence, evaluateVoiceLiveOpsEvidence, getVoiceLiveOpsControlStatus, VOICE_LIVE_OPS_ACTIONS } from './liveOps';
22
24
  export type { VoiceLiveOpsAction, VoiceLiveOpsActionInput, VoiceLiveOpsActionResult, VoiceLiveOpsControllerOptions, VoiceLiveOpsControlState, VoiceLiveOpsControlStatus, VoiceLiveOpsControlStore, VoiceLiveOpsControlEvidenceInput, VoiceLiveOpsControlEvidenceReport, VoiceLiveOpsEvidenceInput, VoiceLiveOpsEvidenceReport, VoiceLiveOpsRoutesOptions } from './liveOps';
23
25
  export { buildVoiceDeliveryRuntimeReport, createVoiceDeliveryRuntime, createVoiceDeliveryRuntimePresetConfig, createVoiceDeliveryRuntimeRoutes, renderVoiceDeliveryRuntimeHTML } from './deliveryRuntime';
package/dist/index.js CHANGED
@@ -12621,8 +12621,208 @@ var formatVoiceProofTrendAge = (ageMs) => {
12621
12621
  const days = Math.floor(hours / 24);
12622
12622
  return `${days}d ${hours % 24}h`;
12623
12623
  };
12624
- // src/liveOps.ts
12624
+ // src/sloCalibration.ts
12625
12625
  import { Elysia as Elysia15 } from "elysia";
12626
+ var DEFAULT_HEADROOM_MULTIPLIER = 1.5;
12627
+ var DEFAULT_WARN_RATIO = 0.8;
12628
+ var DEFAULT_MIN_PASSING_RUNS = 3;
12629
+ var roundMs = (value) => Math.max(1, Math.ceil(value));
12630
+ var finiteNumber = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0;
12631
+ var percentile = (values, rank) => {
12632
+ if (values.length === 0) {
12633
+ return;
12634
+ }
12635
+ const sorted = [...values].sort((left, right) => left - right);
12636
+ const index = Math.min(sorted.length - 1, Math.max(0, Math.ceil(rank / 100 * sorted.length) - 1));
12637
+ return sorted[index];
12638
+ };
12639
+ var normalizeSample = (input) => {
12640
+ if ("summary" in input) {
12641
+ return {
12642
+ generatedAt: input.generatedAt,
12643
+ liveP95Ms: input.summary.maxLiveP95Ms,
12644
+ ok: input.ok,
12645
+ providerP95Ms: input.summary.maxProviderP95Ms,
12646
+ runId: input.runId,
12647
+ source: input.source || input.outputDir,
12648
+ turnP95Ms: input.summary.maxTurnP95Ms
12649
+ };
12650
+ }
12651
+ return input;
12652
+ };
12653
+ var createThreshold = (metric, values, options) => {
12654
+ const baselineP95Ms = percentile(values, 95);
12655
+ const maxObservedMs = values.length > 0 ? Math.max(...values) : undefined;
12656
+ const recommendedMs = baselineP95Ms === undefined ? undefined : roundMs(Math.max(options.minimumMs, baselineP95Ms * options.headroomMultiplier));
12657
+ const warnAfterMs = recommendedMs === undefined ? undefined : roundMs(Math.max(options.minimumMs, recommendedMs * options.warnRatio));
12658
+ return {
12659
+ baselineP95Ms,
12660
+ failAfterMs: recommendedMs,
12661
+ headroomMultiplier: options.headroomMultiplier,
12662
+ maxObservedMs,
12663
+ metric,
12664
+ minimumMs: options.minimumMs,
12665
+ recommendedMs,
12666
+ samples: values.length,
12667
+ status: values.length > 0 ? "pass" : "warn",
12668
+ warnAfterMs
12669
+ };
12670
+ };
12671
+ var buildVoiceSloCalibrationReport = (input, options = {}) => {
12672
+ const headroomMultiplier = finiteNumber(options.headroomMultiplier) && options.headroomMultiplier >= 1 ? options.headroomMultiplier : DEFAULT_HEADROOM_MULTIPLIER;
12673
+ const warnRatio = finiteNumber(options.warnRatio) && options.warnRatio > 0 && options.warnRatio < 1 ? options.warnRatio : DEFAULT_WARN_RATIO;
12674
+ const minPassingRuns = Math.max(1, Math.floor(options.minPassingRuns ?? DEFAULT_MIN_PASSING_RUNS));
12675
+ const samples = input.map(normalizeSample);
12676
+ const passingSamples = samples.filter((sample) => sample.ok === true);
12677
+ const issues = [];
12678
+ if (passingSamples.length < minPassingRuns) {
12679
+ issues.push(`Expected at least ${String(minPassingRuns)} passing SLO calibration run(s), found ${String(passingSamples.length)}.`);
12680
+ }
12681
+ const valuesFor = (key) => passingSamples.map((sample) => sample[key]).filter((value) => finiteNumber(value));
12682
+ const thresholds = {
12683
+ interruption: createThreshold("interruption", valuesFor("interruptionP95Ms"), {
12684
+ headroomMultiplier,
12685
+ minimumMs: options.interruptionMinimumMs ?? 250,
12686
+ warnRatio
12687
+ }),
12688
+ liveLatency: createThreshold("liveLatency", valuesFor("liveP95Ms"), {
12689
+ headroomMultiplier,
12690
+ minimumMs: options.liveLatencyMinimumMs ?? 600,
12691
+ warnRatio
12692
+ }),
12693
+ monitorRun: createThreshold("monitorRun", valuesFor("monitorRunP95Ms"), {
12694
+ headroomMultiplier,
12695
+ minimumMs: options.monitorRunMinimumMs ?? 1000,
12696
+ warnRatio
12697
+ }),
12698
+ notifierDelivery: createThreshold("notifierDelivery", valuesFor("notifierDeliveryP95Ms"), {
12699
+ headroomMultiplier,
12700
+ minimumMs: options.notifierDeliveryMinimumMs ?? 2000,
12701
+ warnRatio
12702
+ }),
12703
+ provider: createThreshold("provider", valuesFor("providerP95Ms"), {
12704
+ headroomMultiplier,
12705
+ minimumMs: options.providerMinimumMs ?? 1000,
12706
+ warnRatio
12707
+ }),
12708
+ reconnect: createThreshold("reconnect", valuesFor("reconnectP95Ms"), {
12709
+ headroomMultiplier,
12710
+ minimumMs: options.reconnectMinimumMs ?? 1500,
12711
+ warnRatio
12712
+ }),
12713
+ turnLatency: createThreshold("turnLatency", valuesFor("turnP95Ms"), {
12714
+ headroomMultiplier,
12715
+ minimumMs: options.turnLatencyMinimumMs ?? 250,
12716
+ warnRatio
12717
+ })
12718
+ };
12719
+ for (const threshold of Object.values(thresholds)) {
12720
+ if (threshold.status !== "pass") {
12721
+ issues.push(`Missing ${threshold.metric} samples for SLO threshold calibration.`);
12722
+ }
12723
+ }
12724
+ const providerP95 = thresholds.provider.recommendedMs;
12725
+ const recommendedProviderSloThresholds = providerP95 === undefined ? {} : {
12726
+ llm: { maxP95ElapsedMs: providerP95 },
12727
+ stt: { maxP95ElapsedMs: providerP95 },
12728
+ tts: { maxP95ElapsedMs: providerP95 }
12729
+ };
12730
+ const blockingIssues = issues.filter((issue) => !issue.startsWith("Missing interruption") && !issue.startsWith("Missing monitorRun") && !issue.startsWith("Missing notifierDelivery") && !issue.startsWith("Missing reconnect"));
12731
+ const ok = blockingIssues.length === 0;
12732
+ return {
12733
+ generatedAt: new Date().toISOString(),
12734
+ issues,
12735
+ minPassingRuns,
12736
+ ok,
12737
+ passingRuns: passingSamples.length,
12738
+ recommendedProviderSloThresholds,
12739
+ runs: samples.length,
12740
+ sources: [
12741
+ ...new Set(samples.map((sample) => sample.source || sample.runId).filter((value) => typeof value === "string"))
12742
+ ],
12743
+ status: ok ? issues.length > 0 ? "warn" : "pass" : "fail",
12744
+ thresholds
12745
+ };
12746
+ };
12747
+ var assertVoiceSloCalibration = (input, options = {}) => {
12748
+ const report = buildVoiceSloCalibrationReport(input, options);
12749
+ if (!report.ok) {
12750
+ throw new Error(`Voice SLO calibration failed: ${report.issues.join(" ")}`);
12751
+ }
12752
+ return report;
12753
+ };
12754
+ var thresholdValue = (threshold) => threshold.recommendedMs ?? threshold.failAfterMs;
12755
+ var createVoiceSloThresholdProfile = (input, options = {}) => {
12756
+ const report = Array.isArray(input) ? buildVoiceSloCalibrationReport(input, options) : input;
12757
+ const liveLatencyFailAfterMs = thresholdValue(report.thresholds.liveLatency);
12758
+ const interruptionFailAfterMs = thresholdValue(report.thresholds.interruption);
12759
+ return {
12760
+ bargeIn: {
12761
+ thresholdMs: interruptionFailAfterMs
12762
+ },
12763
+ issues: report.issues,
12764
+ liveLatency: {
12765
+ failAfterMs: liveLatencyFailAfterMs,
12766
+ warnAfterMs: report.thresholds.liveLatency.warnAfterMs
12767
+ },
12768
+ monitoring: {
12769
+ monitorRunFailAfterMs: thresholdValue(report.thresholds.monitorRun),
12770
+ notifierDeliveryFailAfterMs: thresholdValue(report.thresholds.notifierDelivery)
12771
+ },
12772
+ providerSlo: report.recommendedProviderSloThresholds,
12773
+ reconnect: {
12774
+ failAfterMs: thresholdValue(report.thresholds.reconnect)
12775
+ },
12776
+ status: report.status
12777
+ };
12778
+ };
12779
+ var escapeMarkdown = (value) => value.replaceAll("|", "\\|");
12780
+ var renderVoiceSloCalibrationMarkdown = (report, options = {}) => {
12781
+ const rows = Object.values(report.thresholds).map((threshold) => `| ${escapeMarkdown(threshold.metric)} | ${threshold.status} | ${threshold.samples} | ${threshold.baselineP95Ms ?? "n/a"} | ${threshold.warnAfterMs ?? "n/a"} | ${threshold.failAfterMs ?? "n/a"} |`).join(`
12782
+ `);
12783
+ return `# ${options.title ?? "Voice SLO Calibration"}
12784
+
12785
+ Generated: ${report.generatedAt}
12786
+
12787
+ Status: **${report.status}**
12788
+
12789
+ Passing runs: ${report.passingRuns}/${report.runs}
12790
+
12791
+ | Metric | Status | Samples | Baseline p95 | Warn after | Fail after |
12792
+ | --- | --- | ---: | ---: | ---: | ---: |
12793
+ ${rows}
12794
+
12795
+ Issues:
12796
+
12797
+ ${report.issues.map((issue) => `- ${issue}`).join(`
12798
+ `) || "- None"}
12799
+ `;
12800
+ };
12801
+ var createVoiceSloCalibrationRoutes = (options) => {
12802
+ const path = options.path ?? "/api/voice/slo-calibration";
12803
+ const markdownPath = options.markdownPath === undefined ? "/voice/slo-calibration.md" : options.markdownPath;
12804
+ const routes = new Elysia15({
12805
+ name: options.name ?? "absolutejs-voice-slo-calibration"
12806
+ });
12807
+ const loadReport = async () => buildVoiceSloCalibrationReport(typeof options.source === "function" ? await options.source() : options.source, options);
12808
+ routes.get(path, async () => Response.json(await loadReport(), { headers: options.headers }));
12809
+ if (markdownPath !== false) {
12810
+ routes.get(markdownPath, async () => {
12811
+ const report = await loadReport();
12812
+ return new Response(renderVoiceSloCalibrationMarkdown(report, {
12813
+ title: options.title
12814
+ }), {
12815
+ headers: {
12816
+ "content-type": "text/markdown; charset=utf-8",
12817
+ ...Object.fromEntries(new Headers(options.headers))
12818
+ }
12819
+ });
12820
+ });
12821
+ }
12822
+ return routes;
12823
+ };
12824
+ // src/liveOps.ts
12825
+ import { Elysia as Elysia16 } from "elysia";
12626
12826
  var VOICE_LIVE_OPS_ACTIONS = [
12627
12827
  "assign",
12628
12828
  "create-task",
@@ -12932,7 +13132,7 @@ var createVoiceLiveOpsRoutes = (options = {}) => {
12932
13132
  const controller = createVoiceLiveOpsController(options);
12933
13133
  const path = options.path ?? "/api/voice/live-ops/action";
12934
13134
  const controlPath = options.controlPath ?? "/api/voice/live-ops/control/:sessionId";
12935
- return new Elysia15({
13135
+ return new Elysia16({
12936
13136
  name: options.name ?? "absolutejs-voice-live-ops"
12937
13137
  }).post(path, async ({ request, set }) => {
12938
13138
  try {
@@ -12954,7 +13154,7 @@ var createVoiceLiveOpsRoutes = (options = {}) => {
12954
13154
  });
12955
13155
  };
12956
13156
  // src/deliveryRuntime.ts
12957
- import { Elysia as Elysia16 } from "elysia";
13157
+ import { Elysia as Elysia17 } from "elysia";
12958
13158
  import { mkdir } from "fs/promises";
12959
13159
  import { dirname, join } from "path";
12960
13160
  var escapeHtml16 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
@@ -13208,7 +13408,7 @@ var createVoiceDeliveryRuntimeRoutes = (options) => {
13208
13408
  const htmlPath = options.htmlPath === undefined ? "/delivery-runtime" : options.htmlPath;
13209
13409
  const tickPath = options.tickPath === undefined ? "/api/voice-delivery-runtime/tick" : options.tickPath;
13210
13410
  const requeueDeadLettersPath = options.requeueDeadLettersPath === undefined ? "/api/voice-delivery-runtime/requeue-dead-letters" : options.requeueDeadLettersPath;
13211
- const routes = new Elysia16({
13411
+ const routes = new Elysia17({
13212
13412
  name: options.name ?? "absolutejs-voice-delivery-runtime"
13213
13413
  }).get(path, () => buildVoiceDeliveryRuntimeReport(options.runtime));
13214
13414
  if (tickPath !== false) {
@@ -13244,7 +13444,7 @@ var createVoiceDeliveryRuntimeRoutes = (options) => {
13244
13444
  return routes;
13245
13445
  };
13246
13446
  // src/dataControl.ts
13247
- import { Elysia as Elysia17 } from "elysia";
13447
+ import { Elysia as Elysia18 } from "elysia";
13248
13448
  var voiceComplianceRedactionDefaults = {
13249
13449
  keys: [
13250
13450
  "apiKey",
@@ -13783,7 +13983,7 @@ var parseRetentionPolicyBody = (body, options, dryRun) => {
13783
13983
  var createVoiceDataControlRoutes = (options) => {
13784
13984
  const path = options.path ?? "/data-control";
13785
13985
  const title = options.title ?? "AbsoluteJS Voice Data Control";
13786
- const routes = new Elysia17({
13986
+ const routes = new Elysia18({
13787
13987
  name: options.name ?? "absolutejs-voice-data-control"
13788
13988
  });
13789
13989
  routes.get(path, async ({ query }) => {
@@ -13859,15 +14059,15 @@ var createVoiceDataControlRoutes = (options) => {
13859
14059
  return routes;
13860
14060
  };
13861
14061
  // src/evalRoutes.ts
13862
- import { Elysia as Elysia20 } from "elysia";
14062
+ import { Elysia as Elysia21 } from "elysia";
13863
14063
  import { mkdir as mkdir2 } from "fs/promises";
13864
14064
  import { dirname as dirname2 } from "path";
13865
14065
 
13866
14066
  // src/qualityRoutes.ts
13867
- import { Elysia as Elysia19 } from "elysia";
14067
+ import { Elysia as Elysia20 } from "elysia";
13868
14068
 
13869
14069
  // src/handoffHealth.ts
13870
- import { Elysia as Elysia18 } from "elysia";
14070
+ import { Elysia as Elysia19 } from "elysia";
13871
14071
  var escapeHtml18 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
13872
14072
  var getString7 = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
13873
14073
  var isStatus = (value) => value === "delivered" || value === "failed" || value === "skipped";
@@ -14050,7 +14250,7 @@ var createVoiceHandoffHealthHTMLHandler = (options = {}) => async ({ query }) =>
14050
14250
  var createVoiceHandoffHealthRoutes = (options = {}) => {
14051
14251
  const path = options.path ?? "/api/voice-handoffs";
14052
14252
  const htmlPath = options.htmlPath === undefined ? `${path}/htmx` : options.htmlPath;
14053
- const routes = new Elysia18({
14253
+ const routes = new Elysia19({
14054
14254
  name: options.name ?? "absolutejs-voice-handoff-health"
14055
14255
  }).get(path, createVoiceHandoffHealthJSONHandler(options));
14056
14256
  if (htmlPath) {
@@ -14181,7 +14381,7 @@ var renderVoiceQualityHTML = (report, options = {}) => {
14181
14381
  };
14182
14382
  var createVoiceQualityRoutes = (options) => {
14183
14383
  const path = options.path ?? "/quality";
14184
- const routes = new Elysia19({
14384
+ const routes = new Elysia20({
14185
14385
  name: options.name ?? "absolutejs-voice-quality"
14186
14386
  });
14187
14387
  const getReport = () => evaluateVoiceQuality({
@@ -14594,7 +14794,7 @@ var renderVoiceScenarioFixtureEvalHTML = (report, options = {}) => {
14594
14794
  };
14595
14795
  var createVoiceEvalRoutes = (options) => {
14596
14796
  const path = options.path ?? "/evals";
14597
- const routes = new Elysia20({
14797
+ const routes = new Elysia21({
14598
14798
  name: options.name ?? "absolutejs-voice-evals"
14599
14799
  });
14600
14800
  const getReport = () => runVoiceSessionEvals({
@@ -14731,10 +14931,10 @@ var createVoiceEvalRoutes = (options) => {
14731
14931
  return routes;
14732
14932
  };
14733
14933
  // src/simulationSuite.ts
14734
- import { Elysia as Elysia23 } from "elysia";
14934
+ import { Elysia as Elysia24 } from "elysia";
14735
14935
 
14736
14936
  // src/outcomeContract.ts
14737
- import { Elysia as Elysia21 } from "elysia";
14937
+ import { Elysia as Elysia22 } from "elysia";
14738
14938
  var escapeHtml21 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
14739
14939
  var resolveSessionHref2 = (value, sessionId) => {
14740
14940
  if (value === false) {
@@ -14983,7 +15183,7 @@ var createVoiceOutcomeContractHTMLHandler = (options) => async () => {
14983
15183
  var createVoiceOutcomeContractRoutes = (options) => {
14984
15184
  const path = options.path ?? "/api/outcome-contracts";
14985
15185
  const htmlPath = options.htmlPath === undefined ? `${path}/htmx` : options.htmlPath;
14986
- const routes = new Elysia21({
15186
+ const routes = new Elysia22({
14987
15187
  name: options.name ?? "absolutejs-voice-outcome-contracts"
14988
15188
  }).get(path, createVoiceOutcomeContractJSONHandler(options));
14989
15189
  if (htmlPath) {
@@ -14993,7 +15193,7 @@ var createVoiceOutcomeContractRoutes = (options) => {
14993
15193
  };
14994
15194
 
14995
15195
  // src/toolContract.ts
14996
- import { Elysia as Elysia22 } from "elysia";
15196
+ import { Elysia as Elysia23 } from "elysia";
14997
15197
 
14998
15198
  // src/toolRuntime.ts
14999
15199
  var toErrorMessage4 = (error) => error instanceof Error ? error.message : String(error);
@@ -15517,7 +15717,7 @@ var createVoiceToolContractHTMLHandler = (options) => async () => {
15517
15717
  var createVoiceToolContractRoutes = (options) => {
15518
15718
  const path = options.path ?? "/api/tool-contracts";
15519
15719
  const htmlPath = options.htmlPath === undefined ? `${path}/htmx` : options.htmlPath;
15520
- const routes = new Elysia22({
15720
+ const routes = new Elysia23({
15521
15721
  name: options.name ?? "absolutejs-voice-tool-contracts"
15522
15722
  }).get(path, createVoiceToolContractJSONHandler(options));
15523
15723
  if (htmlPath) {
@@ -15769,7 +15969,7 @@ app.use(
15769
15969
  var createVoiceSimulationSuiteRoutes = (options) => {
15770
15970
  const path = options.path ?? "/api/voice/simulations";
15771
15971
  const htmlPath = options.htmlPath === undefined ? "/voice/simulations" : options.htmlPath;
15772
- const app = new Elysia23({
15972
+ const app = new Elysia24({
15773
15973
  name: options.name ?? "absolutejs-voice-simulation-suite"
15774
15974
  }).get(path, () => runVoiceSimulationSuite(options));
15775
15975
  if (htmlPath) {
@@ -16081,7 +16281,7 @@ var createVoiceWorkflowContractHandler = (input) => {
16081
16281
  };
16082
16282
  };
16083
16283
  // src/sessionReplay.ts
16084
- import { Elysia as Elysia24 } from "elysia";
16284
+ import { Elysia as Elysia25 } from "elysia";
16085
16285
  var getString10 = (value) => typeof value === "string" ? value : undefined;
16086
16286
  var escapeHtml24 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
16087
16287
  var increment4 = (record, key) => {
@@ -16321,7 +16521,7 @@ var createVoiceSessionsHTMLHandler = (options = {}) => async ({ query }) => {
16321
16521
  var createVoiceSessionListRoutes = (options = {}) => {
16322
16522
  const path = options.path ?? "/api/voice-sessions";
16323
16523
  const htmlPath = options.htmlPath === undefined ? `${path}/htmx` : options.htmlPath;
16324
- const routes = new Elysia24({
16524
+ const routes = new Elysia25({
16325
16525
  name: options.name ?? "absolutejs-voice-session-list"
16326
16526
  }).get(path, createVoiceSessionsJSONHandler(options));
16327
16527
  if (htmlPath) {
@@ -16349,7 +16549,7 @@ var createVoiceSessionReplayHTMLHandler = (options) => async ({ params }) => {
16349
16549
  var createVoiceSessionReplayRoutes = (options) => {
16350
16550
  const path = options.path ?? "/api/voice-sessions/:sessionId/replay";
16351
16551
  const htmlPath = options.htmlPath === undefined ? `${path}/htmx` : options.htmlPath;
16352
- const routes = new Elysia24({
16552
+ const routes = new Elysia25({
16353
16553
  name: options.name ?? "absolutejs-voice-session-replay"
16354
16554
  }).get(path, createVoiceSessionReplayJSONHandler(options));
16355
16555
  if (htmlPath) {
@@ -16663,7 +16863,7 @@ var assertVoiceAgentSquadContractEvidence = (reports, input = {}) => {
16663
16863
  return report;
16664
16864
  };
16665
16865
  // src/turnLatency.ts
16666
- import { Elysia as Elysia25 } from "elysia";
16866
+ import { Elysia as Elysia26 } from "elysia";
16667
16867
  var DEFAULT_WARN_AFTER_MS = 1800;
16668
16868
  var DEFAULT_FAIL_AFTER_MS = 3200;
16669
16869
  var escapeHtml25 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
@@ -16819,7 +17019,7 @@ var createVoiceTurnLatencyHTMLHandler = (options) => async () => {
16819
17019
  var createVoiceTurnLatencyRoutes = (options) => {
16820
17020
  const path = options.path ?? "/api/turn-latency";
16821
17021
  const htmlPath = options.htmlPath === undefined ? `${path}/htmx` : options.htmlPath;
16822
- const routes = new Elysia25({
17022
+ const routes = new Elysia26({
16823
17023
  name: options.name ?? "absolutejs-voice-turn-latency"
16824
17024
  }).get(path, createVoiceTurnLatencyJSONHandler(options));
16825
17025
  if (htmlPath) {
@@ -16828,9 +17028,9 @@ var createVoiceTurnLatencyRoutes = (options) => {
16828
17028
  return routes;
16829
17029
  };
16830
17030
  // src/liveLatency.ts
16831
- import { Elysia as Elysia26 } from "elysia";
17031
+ import { Elysia as Elysia27 } from "elysia";
16832
17032
  var escapeHtml26 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
16833
- var percentile = (values, percentileValue) => {
17033
+ var percentile2 = (values, percentileValue) => {
16834
17034
  if (values.length === 0) {
16835
17035
  return;
16836
17036
  }
@@ -16866,8 +17066,8 @@ var summarizeVoiceLiveLatency = async (options) => {
16866
17066
  averageLatencyMs: latencies.length > 0 ? Math.round(latencies.reduce((total, value) => total + value, 0) / latencies.length) : undefined,
16867
17067
  checkedAt: Date.now(),
16868
17068
  failed,
16869
- p50LatencyMs: percentile(latencies, 50),
16870
- p95LatencyMs: percentile(latencies, 95),
17069
+ p50LatencyMs: percentile2(latencies, 50),
17070
+ p95LatencyMs: percentile2(latencies, 95),
16871
17071
  recent,
16872
17072
  status: latencies.length === 0 ? "empty" : failed > 0 ? "fail" : warnings > 0 ? "warn" : "pass",
16873
17073
  total: latencies.length,
@@ -16902,7 +17102,7 @@ await traceStore.append({
16902
17102
  var createVoiceLiveLatencyRoutes = (options) => {
16903
17103
  const path = options.path ?? "/api/live-latency";
16904
17104
  const htmlPath = options.htmlPath === undefined ? "/live-latency" : options.htmlPath;
16905
- const routes = new Elysia26({
17105
+ const routes = new Elysia27({
16906
17106
  name: options.name ?? "absolutejs-voice-live-latency"
16907
17107
  }).get(path, () => summarizeVoiceLiveLatency(options));
16908
17108
  if (htmlPath) {
@@ -16943,7 +17143,7 @@ var TRACE_TYPES = [
16943
17143
  ];
16944
17144
  var getNumber6 = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
16945
17145
  var getString12 = (value) => typeof value === "string" && value.trim() ? value : undefined;
16946
- var percentile2 = (values, percentileValue) => {
17146
+ var percentile3 = (values, percentileValue) => {
16947
17147
  if (values.length === 0) {
16948
17148
  return;
16949
17149
  }
@@ -17151,8 +17351,8 @@ var summarizeStage = (stage, measurements, options) => {
17151
17351
  label: STAGE_LABELS[stage],
17152
17352
  maxMs: latencies.length > 0 ? Math.max(...latencies) : undefined,
17153
17353
  measurements: stageMeasurements,
17154
- p50Ms: percentile2(latencies, 50),
17155
- p95Ms: percentile2(latencies, 95),
17354
+ p50Ms: percentile3(latencies, 50),
17355
+ p95Ms: percentile3(latencies, 95),
17156
17356
  stage,
17157
17357
  status: stageMeasurements.length === 0 ? "empty" : failed > 0 ? "fail" : warnings > 0 ? "warn" : "pass",
17158
17358
  total: stageMeasurements.length,
@@ -17221,7 +17421,7 @@ None.
17221
17421
  `}`;
17222
17422
  };
17223
17423
  // src/turnQuality.ts
17224
- import { Elysia as Elysia27 } from "elysia";
17424
+ import { Elysia as Elysia28 } from "elysia";
17225
17425
  var DEFAULT_CONFIDENCE_WARN_THRESHOLD = 0.72;
17226
17426
  var escapeHtml27 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
17227
17427
  var getTurnLatencyMs = (turn) => {
@@ -17328,7 +17528,7 @@ var createVoiceTurnQualityHTMLHandler = (options) => async () => {
17328
17528
  var createVoiceTurnQualityRoutes = (options) => {
17329
17529
  const path = options.path ?? "/api/turn-quality";
17330
17530
  const htmlPath = options.htmlPath === undefined ? `${path}/htmx` : options.htmlPath;
17331
- const routes = new Elysia27({
17531
+ const routes = new Elysia28({
17332
17532
  name: options.name ?? "absolutejs-voice-turn-quality"
17333
17533
  }).get(path, createVoiceTurnQualityJSONHandler(options));
17334
17534
  if (htmlPath) {
@@ -17337,7 +17537,7 @@ var createVoiceTurnQualityRoutes = (options) => {
17337
17537
  return routes;
17338
17538
  };
17339
17539
  // src/telephonyOutcome.ts
17340
- import { Elysia as Elysia28 } from "elysia";
17540
+ import { Elysia as Elysia29 } from "elysia";
17341
17541
  var DEFAULT_COMPLETED_STATUSES = [
17342
17542
  "answered",
17343
17543
  "completed",
@@ -18098,7 +18298,7 @@ var createVoiceTelephonyWebhookHandler = (options = {}) => async (input) => {
18098
18298
  var createVoiceTelephonyWebhookRoutes = (options = {}) => {
18099
18299
  const path = options.path ?? "/api/voice/telephony/webhook";
18100
18300
  const handler = createVoiceTelephonyWebhookHandler(options);
18101
- return new Elysia28({
18301
+ return new Elysia29({
18102
18302
  name: options.name ?? "absolutejs-voice-telephony-webhooks"
18103
18303
  }).post(path, async ({ query, request }) => {
18104
18304
  try {
@@ -18119,12 +18319,12 @@ var createVoiceTelephonyWebhookRoutes = (options = {}) => {
18119
18319
  });
18120
18320
  };
18121
18321
  // src/phoneAgent.ts
18122
- import { Elysia as Elysia34 } from "elysia";
18322
+ import { Elysia as Elysia35 } from "elysia";
18123
18323
 
18124
18324
  // src/telephony/plivo.ts
18125
18325
  import { Buffer as Buffer5 } from "buffer";
18126
18326
  import { Database } from "bun:sqlite";
18127
- import { Elysia as Elysia30 } from "elysia";
18327
+ import { Elysia as Elysia31 } from "elysia";
18128
18328
 
18129
18329
  // src/telephony/contract.ts
18130
18330
  var DEFAULT_REQUIREMENTS = [
@@ -18208,7 +18408,7 @@ var evaluateVoiceTelephonyContract = (input) => {
18208
18408
 
18209
18409
  // src/telephony/twilio.ts
18210
18410
  import { Buffer as Buffer4 } from "buffer";
18211
- import { Elysia as Elysia29 } from "elysia";
18411
+ import { Elysia as Elysia30 } from "elysia";
18212
18412
  var TWILIO_MULAW_SAMPLE_RATE = 8000;
18213
18413
  var VOICE_PCM_SAMPLE_RATE = 16000;
18214
18414
  var escapeXml2 = (value) => value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("'", "&apos;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
@@ -18781,7 +18981,7 @@ var createTwilioVoiceRoutes = (options) => {
18781
18981
  const smokePath = options.smoke?.path === false ? false : options.smoke?.path ?? "/api/voice/twilio/smoke";
18782
18982
  const bridges = new WeakMap;
18783
18983
  const webhookPolicy = options.webhook?.policy ?? options.outcomePolicy ?? createVoiceTelephonyOutcomePolicy();
18784
- const app = new Elysia29({
18984
+ const app = new Elysia30({
18785
18985
  name: options.name ?? "absolutejs-voice-twilio"
18786
18986
  }).get(twimlPath, async ({ query, request }) => {
18787
18987
  const streamUrl = await resolveTwilioStreamUrl(options, {
@@ -19452,7 +19652,7 @@ var createPlivoVoiceRoutes = (options = {}) => {
19452
19652
  nonceStore: options.webhook.nonceStore,
19453
19653
  verificationUrl: options.webhook.verificationUrl
19454
19654
  }) : undefined);
19455
- const app = new Elysia30({
19655
+ const app = new Elysia31({
19456
19656
  name: options.name ?? "absolutejs-voice-plivo"
19457
19657
  }).get(answerPath, async ({ query, request }) => {
19458
19658
  const streamUrl = await resolvePlivoStreamUrl(options, {
@@ -19564,7 +19764,7 @@ var createPlivoVoiceRoutes = (options = {}) => {
19564
19764
  // src/telephony/telnyx.ts
19565
19765
  import { Buffer as Buffer6 } from "buffer";
19566
19766
  import { Database as Database2 } from "bun:sqlite";
19567
- import { Elysia as Elysia31 } from "elysia";
19767
+ import { Elysia as Elysia32 } from "elysia";
19568
19768
  var escapeXml4 = (value) => value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("'", "&apos;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
19569
19769
  var escapeHtml30 = (value) => value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("'", "&#39;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
19570
19770
  var joinUrlPath4 = (origin, path) => `${origin.replace(/\/$/, "")}${path.startsWith("/") ? path : `/${path}`}`;
@@ -20066,7 +20266,7 @@ var createTelnyxVoiceRoutes = (options = {}) => {
20066
20266
  publicKey: options.webhook.publicKey,
20067
20267
  toleranceSeconds: options.webhook.toleranceSeconds
20068
20268
  }) : undefined);
20069
- const app = new Elysia31({
20269
+ const app = new Elysia32({
20070
20270
  name: options.name ?? "absolutejs-voice-telnyx"
20071
20271
  }).get(texmlPath, async ({ query, request }) => {
20072
20272
  const streamUrl = await resolveTelnyxStreamUrl(options, {
@@ -20176,7 +20376,7 @@ var createTelnyxVoiceRoutes = (options = {}) => {
20176
20376
  };
20177
20377
 
20178
20378
  // src/telephony/matrix.ts
20179
- import { Elysia as Elysia32 } from "elysia";
20379
+ import { Elysia as Elysia33 } from "elysia";
20180
20380
  var escapeHtml31 = (value) => value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("'", "&#39;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
20181
20381
  var labelForProvider = (provider) => provider.split("-").map((part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`).join(" ");
20182
20382
  var resolveEntryStatus = (contract, setup, smoke) => {
@@ -20260,7 +20460,7 @@ ${entry.issues.length ? `<ul style="margin:12px 0 0; padding-left:18px;">${entry
20260
20460
  </main>`;
20261
20461
  var createVoiceTelephonyCarrierMatrixRoutes = (options) => {
20262
20462
  const path = options.path ?? "/api/voice/telephony/carriers";
20263
- return new Elysia32({
20463
+ return new Elysia33({
20264
20464
  name: options.name ?? "absolutejs-voice-telephony-carrier-matrix"
20265
20465
  }).get(path, async ({ query, request }) => {
20266
20466
  const providers = await options.load({ query, request });
@@ -20282,7 +20482,7 @@ var createVoiceTelephonyCarrierMatrixRoutes = (options) => {
20282
20482
  };
20283
20483
 
20284
20484
  // src/phoneAgentProductionSmoke.ts
20285
- import { Elysia as Elysia33 } from "elysia";
20485
+ import { Elysia as Elysia34 } from "elysia";
20286
20486
  var defaultRequirements = [
20287
20487
  "media-started",
20288
20488
  "transcript",
@@ -20425,7 +20625,7 @@ var createVoicePhoneAgentProductionSmokeHTMLHandler = (options) => async ({
20425
20625
  var createVoicePhoneAgentProductionSmokeRoutes = (options) => {
20426
20626
  const path = options.path ?? "/api/voice/phone/smoke-contract";
20427
20627
  const htmlPath = options.htmlPath === undefined ? "/voice/phone/smoke-contract" : options.htmlPath;
20428
- const routes = new Elysia33({
20628
+ const routes = new Elysia34({
20429
20629
  name: options.name ?? "absolutejs-voice-phone-smoke-contract"
20430
20630
  }).get(path, createVoicePhoneAgentProductionSmokeJSONHandler(options));
20431
20631
  if (htmlPath) {
@@ -20756,7 +20956,7 @@ var createVoicePhoneAgent = (options) => {
20756
20956
  setupPath: resolveSetupPath(carrier),
20757
20957
  smokePath: resolveSmokePath(carrier)
20758
20958
  }));
20759
- const app = new Elysia34({
20959
+ const app = new Elysia35({
20760
20960
  name: options.name ?? "absolutejs-voice-phone-agent"
20761
20961
  });
20762
20962
  for (const carrier of options.carriers) {
@@ -22815,7 +23015,7 @@ var createOpenAIVoiceTTS = (options) => {
22815
23015
  };
22816
23016
  };
22817
23017
  // src/providerCapabilities.ts
22818
- import { Elysia as Elysia35 } from "elysia";
23018
+ import { Elysia as Elysia36 } from "elysia";
22819
23019
  var escapeHtml34 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
22820
23020
  var fromProviderList = (kind, providers, options) => (providers ?? []).map((provider) => ({
22821
23021
  configured: true,
@@ -22916,7 +23116,7 @@ var createVoiceProviderCapabilityHTMLHandler = (options) => async () => {
22916
23116
  var createVoiceProviderCapabilityRoutes = (options) => {
22917
23117
  const path = options.path ?? "/api/provider-capabilities";
22918
23118
  const htmlPath = options.htmlPath === undefined ? `${path}/htmx` : options.htmlPath;
22919
- const routes = new Elysia35({
23119
+ const routes = new Elysia36({
22920
23120
  name: options.name ?? "absolutejs-voice-provider-capabilities"
22921
23121
  }).get(path, createVoiceProviderCapabilityJSONHandler(options));
22922
23122
  if (htmlPath) {
@@ -22925,7 +23125,7 @@ var createVoiceProviderCapabilityRoutes = (options) => {
22925
23125
  return routes;
22926
23126
  };
22927
23127
  // src/resilienceRoutes.ts
22928
- import { Elysia as Elysia36 } from "elysia";
23128
+ import { Elysia as Elysia37 } from "elysia";
22929
23129
  var escapeHtml35 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
22930
23130
  var getString13 = (value) => typeof value === "string" ? value : undefined;
22931
23131
  var getNumber7 = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
@@ -23369,7 +23569,7 @@ var registerSimulationRoutes = (routes, simulation, defaultPathPrefix) => {
23369
23569
  };
23370
23570
  var createVoiceResilienceRoutes = (options) => {
23371
23571
  const path = options.path ?? "/resilience";
23372
- const routes = new Elysia36({
23572
+ const routes = new Elysia37({
23373
23573
  name: options.name ?? "absolutejs-voice-resilience"
23374
23574
  }).get(path, async () => {
23375
23575
  const events = await options.store.list();
@@ -23551,7 +23751,7 @@ var assertVoiceProviderRoutingContractEvidence = (reports, input = {}) => {
23551
23751
  return report;
23552
23752
  };
23553
23753
  // src/providerSlo.ts
23554
- import { Elysia as Elysia37 } from "elysia";
23754
+ import { Elysia as Elysia38 } from "elysia";
23555
23755
  var defaultThresholds = {
23556
23756
  llm: {
23557
23757
  maxAverageElapsedMs: 2500,
@@ -23590,7 +23790,7 @@ var rate3 = (count, total) => count / Math.max(1, total);
23590
23790
  var uniqueSorted5 = (values) => [
23591
23791
  ...new Set(values.filter((value) => typeof value === "string"))
23592
23792
  ].sort();
23593
- var percentile3 = (values, rank) => {
23793
+ var percentile4 = (values, rank) => {
23594
23794
  if (values.length === 0) {
23595
23795
  return 0;
23596
23796
  }
@@ -23648,7 +23848,7 @@ var summarizeKind = (kind, events, thresholds, required) => {
23648
23848
  unit: "rate"
23649
23849
  }),
23650
23850
  p95ElapsedMs: createMetric2({
23651
- actual: percentile3(latencies, 95),
23851
+ actual: percentile4(latencies, 95),
23652
23852
  label: "P95 latency",
23653
23853
  threshold: thresholds.maxP95ElapsedMs,
23654
23854
  unit: "ms"
@@ -23905,7 +24105,7 @@ var createVoiceProviderSloRoutes = (options) => {
23905
24105
  ...options.headers ?? {}
23906
24106
  };
23907
24107
  const buildReport = () => buildVoiceProviderSloReport(options);
23908
- const app = new Elysia37({ name: options.name ?? "absolute-voice-provider-slos" });
24108
+ const app = new Elysia38({ name: options.name ?? "absolute-voice-provider-slos" });
23909
24109
  app.get(path, async () => Response.json(await buildReport(), { headers }));
23910
24110
  if (markdownPath !== false) {
23911
24111
  app.get(markdownPath, async () => {
@@ -23935,10 +24135,10 @@ var createVoiceProviderSloRoutes = (options) => {
23935
24135
  return app;
23936
24136
  };
23937
24137
  // src/productionReadiness.ts
23938
- import { Elysia as Elysia43 } from "elysia";
24138
+ import { Elysia as Elysia44 } from "elysia";
23939
24139
 
23940
24140
  // src/telephony/security.ts
23941
- import { Elysia as Elysia38 } from "elysia";
24141
+ import { Elysia as Elysia39 } from "elysia";
23942
24142
 
23943
24143
  // src/postgresStore.ts
23944
24144
  var normalizeIdentifierSegment = (value) => value.trim().replace(/[^a-zA-Z0-9_]+/g, "_").replace(/^_+|_+$/g, "") || "voice";
@@ -24676,7 +24876,7 @@ var assertVoiceTelephonyWebhookSecurityEvidence = (report, input = {}) => {
24676
24876
  };
24677
24877
  var createVoiceTelephonyWebhookSecurityRoutes = (options) => {
24678
24878
  const path = options.path ?? "/api/voice/telephony/webhook-security";
24679
- return new Elysia38({
24879
+ return new Elysia39({
24680
24880
  name: options.name ?? "absolutejs-voice-telephony-webhook-security"
24681
24881
  }).get(path, () => buildVoiceTelephonyWebhookSecurityReport(options.options));
24682
24882
  };
@@ -24733,7 +24933,7 @@ var createVoiceTelephonyWebhookSecurityPreset = (options = {}) => {
24733
24933
  };
24734
24934
 
24735
24935
  // src/opsRecovery.ts
24736
- import { Elysia as Elysia39 } from "elysia";
24936
+ import { Elysia as Elysia40 } from "elysia";
24737
24937
  var escapeHtml37 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
24738
24938
  var getString14 = (value) => typeof value === "string" && value.trim() ? value.trim() : undefined;
24739
24939
  var hrefForSession = (value, sessionId) => {
@@ -24960,7 +25160,7 @@ var createVoiceOpsRecoveryRoutes = (options = {}) => {
24960
25160
  const path = options.path ?? "/api/voice/ops-recovery";
24961
25161
  const htmlPath = options.htmlPath === undefined ? "/ops-recovery" : options.htmlPath;
24962
25162
  const markdownPath = options.markdownPath === undefined ? `${path}.md` : options.markdownPath;
24963
- const routes = new Elysia39({
25163
+ const routes = new Elysia40({
24964
25164
  name: options.name ?? "absolutejs-voice-ops-recovery"
24965
25165
  }).get(path, async () => buildVoiceOpsRecoveryReport(options));
24966
25166
  if (htmlPath) {
@@ -24990,17 +25190,17 @@ var createVoiceOpsRecoveryRoutes = (options = {}) => {
24990
25190
  };
24991
25191
 
24992
25192
  // src/observabilityExport.ts
24993
- import { Elysia as Elysia42 } from "elysia";
25193
+ import { Elysia as Elysia43 } from "elysia";
24994
25194
  import { Database as Database4 } from "bun:sqlite";
24995
25195
  import { createHash } from "crypto";
24996
25196
  import { mkdir as mkdir4, readFile as readFile2, stat, unlink } from "fs/promises";
24997
25197
  import { join as join3 } from "path";
24998
25198
 
24999
25199
  // src/operationsRecord.ts
25000
- import { Elysia as Elysia41 } from "elysia";
25200
+ import { Elysia as Elysia42 } from "elysia";
25001
25201
 
25002
25202
  // src/traceTimeline.ts
25003
- import { Elysia as Elysia40 } from "elysia";
25203
+ import { Elysia as Elysia41 } from "elysia";
25004
25204
  var escapeHtml38 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
25005
25205
  var getString15 = (value) => typeof value === "string" && value.trim() ? value : undefined;
25006
25206
  var getNumber8 = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
@@ -25226,7 +25426,7 @@ var createVoiceTraceTimelineRoutes = (options) => {
25226
25426
  const path = options.path ?? "/api/voice-traces";
25227
25427
  const htmlPath = options.htmlPath ?? "/traces";
25228
25428
  const title = options.title ?? "AbsoluteJS Voice Trace Timelines";
25229
- const routes = new Elysia40({
25429
+ const routes = new Elysia41({
25230
25430
  name: options.name ?? "absolutejs-voice-trace-timelines"
25231
25431
  });
25232
25432
  const buildReport = async () => summarizeVoiceTraceTimeline(await options.store.list(), {
@@ -25624,7 +25824,7 @@ var createVoiceOperationsRecordRoutes = (options) => {
25624
25824
  const htmlPath = options.htmlPath === undefined ? "/voice-operations/:sessionId" : options.htmlPath;
25625
25825
  const incidentPath = options.incidentPath === undefined ? `${path}/incident.md` : options.incidentPath;
25626
25826
  const incidentHtmlPath = options.incidentHtmlPath === undefined && htmlPath ? `${htmlPath}/incident.md` : options.incidentHtmlPath;
25627
- const routes = new Elysia41({
25827
+ const routes = new Elysia42({
25628
25828
  name: options.name ?? "absolutejs-voice-operations-record"
25629
25829
  });
25630
25830
  const buildRecord = (sessionId) => buildVoiceOperationsRecord({
@@ -26275,7 +26475,7 @@ var createVoiceObservabilityExportReplayRoutes = (options) => {
26275
26475
  ...options.headers ?? {}
26276
26476
  };
26277
26477
  const buildReport = () => resolveVoiceObservabilityExportReplayReport(options.source);
26278
- const app = new Elysia42({
26478
+ const app = new Elysia43({
26279
26479
  name: options.name ?? "absolute-voice-observability-export-replay"
26280
26480
  });
26281
26481
  app.get(path, async () => Response.json(await buildReport(), { headers }));
@@ -27084,7 +27284,7 @@ var createVoiceObservabilityExportRoutes = (options = {}) => {
27084
27284
  artifactDownload: options.links?.artifactDownload ?? (artifactDownloadPath ? (artifact) => `${artifactDownloadPath}/${encodeURIComponent(artifact.id)}` : undefined)
27085
27285
  }
27086
27286
  });
27087
- const app = new Elysia42({
27287
+ const app = new Elysia43({
27088
27288
  name: options.name ?? "absolute-voice-observability-export"
27089
27289
  });
27090
27290
  app.get(path, async () => Response.json(await buildReport(), { headers }));
@@ -28531,7 +28731,7 @@ var createVoiceProductionReadinessRoutes = (options) => {
28531
28731
  const path = options.path ?? "/api/production-readiness";
28532
28732
  const gatePath = options.gatePath === undefined ? "/api/production-readiness/gate" : options.gatePath;
28533
28733
  const htmlPath = options.htmlPath ?? "/production-readiness";
28534
- const routes = new Elysia43({
28734
+ const routes = new Elysia44({
28535
28735
  name: options.name ?? "absolutejs-voice-production-readiness"
28536
28736
  });
28537
28737
  routes.get(path, async ({ query, request }) => buildVoiceProductionReadinessReport(options, { query, request }));
@@ -28568,7 +28768,7 @@ var createVoiceProductionReadinessRoutes = (options) => {
28568
28768
  return routes;
28569
28769
  };
28570
28770
  // src/voiceMonitoring.ts
28571
- import { Elysia as Elysia44 } from "elysia";
28771
+ import { Elysia as Elysia45 } from "elysia";
28572
28772
  var escapeHtml41 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
28573
28773
  var issueIdForRun = (run) => `voice-monitor:${run.id}:${run.impactedSessions?.[0] ?? "global"}`;
28574
28774
  var rollupStatus4 = (runs) => runs.some((run) => run.status === "fail") ? "fail" : runs.some((run) => run.status === "warn") ? "warn" : "pass";
@@ -28849,7 +29049,7 @@ var createVoiceMonitorRoutes = (options) => {
28849
29049
  monitors: options.monitors,
28850
29050
  now: options.now
28851
29051
  });
28852
- const routes = new Elysia44({
29052
+ const routes = new Elysia45({
28853
29053
  name: options.name ?? "absolutejs-voice-monitoring"
28854
29054
  }).get(path, report).get(`${path}.md`, async () => {
28855
29055
  return new Response(renderVoiceMonitorMarkdown(await report()), {
@@ -28896,7 +29096,7 @@ var createVoiceMonitorRoutes = (options) => {
28896
29096
  };
28897
29097
  var createVoiceMonitorRunnerRoutes = (options) => {
28898
29098
  const path = options.path ?? "/api/voice/monitor-runner";
28899
- return new Elysia44({
29099
+ return new Elysia45({
28900
29100
  name: options.name ?? "absolutejs-voice-monitor-runner"
28901
29101
  }).get(path, () => ({
28902
29102
  isRunning: options.runner.isRunning()
@@ -29272,7 +29472,7 @@ var recommendVoiceReadinessProfile = (options) => {
29272
29472
  };
29273
29473
  };
29274
29474
  // src/providerStackRecommendations.ts
29275
- import { Elysia as Elysia45 } from "elysia";
29475
+ import { Elysia as Elysia46 } from "elysia";
29276
29476
  var escapeHtml42 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
29277
29477
  var profileProviderPriorities = {
29278
29478
  "meeting-recorder": {
@@ -29638,7 +29838,7 @@ var createVoiceProviderContractMatrixHTMLHandler = (options) => async () => {
29638
29838
  var createVoiceProviderContractMatrixRoutes = (options) => {
29639
29839
  const path = options.path ?? "/api/provider-contracts";
29640
29840
  const htmlPath = options.htmlPath ?? "/provider-contracts";
29641
- const routes = new Elysia45({
29841
+ const routes = new Elysia46({
29642
29842
  name: options.name ?? "absolutejs-voice-provider-contract-matrix"
29643
29843
  });
29644
29844
  const jsonHandler = createVoiceProviderContractMatrixJSONHandler(options.matrix);
@@ -29756,7 +29956,7 @@ var assertVoiceProviderStackEvidence = (report, input = {}) => {
29756
29956
  return assertion;
29757
29957
  };
29758
29958
  // src/opsConsoleRoutes.ts
29759
- import { Elysia as Elysia46 } from "elysia";
29959
+ import { Elysia as Elysia47 } from "elysia";
29760
29960
  var DEFAULT_LINKS = [
29761
29961
  {
29762
29962
  description: "Quality gates for CI, deploy checks, and production readiness.",
@@ -29873,7 +30073,7 @@ var renderVoiceOpsConsoleHTML = (report, options = {}) => {
29873
30073
  };
29874
30074
  var createVoiceOpsConsoleRoutes = (options) => {
29875
30075
  const path = options.path ?? "/ops-console";
29876
- const routes = new Elysia46({
30076
+ const routes = new Elysia47({
29877
30077
  name: options.name ?? "absolutejs-voice-ops-console"
29878
30078
  });
29879
30079
  const getReport = () => buildVoiceOpsConsoleReport(options);
@@ -29890,7 +30090,7 @@ var createVoiceOpsConsoleRoutes = (options) => {
29890
30090
  return routes;
29891
30091
  };
29892
30092
  // src/incidentBundle.ts
29893
- import { Elysia as Elysia47 } from "elysia";
30093
+ import { Elysia as Elysia48 } from "elysia";
29894
30094
  var filterIncidentBundleArtifacts = (artifacts, filter = {}) => artifacts.filter((artifact) => {
29895
30095
  if (filter.sessionId && artifact.sessionId !== filter.sessionId) {
29896
30096
  return false;
@@ -30091,7 +30291,7 @@ var buildVoiceIncidentBundle = async (options) => {
30091
30291
  var createVoiceIncidentBundleRoutes = (options) => {
30092
30292
  const path = options.path ?? "/api/voice-incidents/:sessionId";
30093
30293
  const markdownPath = options.markdownPath === undefined ? "/voice-incidents/:sessionId/markdown" : options.markdownPath;
30094
- const routes = new Elysia47({
30294
+ const routes = new Elysia48({
30095
30295
  name: options.name ?? "absolutejs-voice-incident-bundle"
30096
30296
  });
30097
30297
  const getSessionId = (params) => params.sessionId ?? "";
@@ -30292,7 +30492,7 @@ var summarizeVoiceOpsStatus = async (options) => {
30292
30492
  };
30293
30493
  };
30294
30494
  // src/opsStatusRoutes.ts
30295
- import { Elysia as Elysia48 } from "elysia";
30495
+ import { Elysia as Elysia49 } from "elysia";
30296
30496
  var escapeHtml44 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
30297
30497
  var renderVoiceOpsStatusHTML = (report, options = {}) => {
30298
30498
  const title = options.title ?? "AbsoluteJS Voice Ops Status";
@@ -30304,7 +30504,7 @@ var renderVoiceOpsStatusHTML = (report, options = {}) => {
30304
30504
  };
30305
30505
  var createVoiceOpsStatusRoutes = (options) => {
30306
30506
  const path = options.path ?? "/api/voice/ops-status";
30307
- const routes = new Elysia48({
30507
+ const routes = new Elysia49({
30308
30508
  name: options.name ?? "absolutejs-voice-ops-status"
30309
30509
  });
30310
30510
  routes.get(path, async () => summarizeVoiceOpsStatus(options));
@@ -30737,7 +30937,7 @@ var createVoiceTTSProviderRouter = (options) => {
30737
30937
  };
30738
30938
  };
30739
30939
  // src/traceDeliveryRoutes.ts
30740
- import { Elysia as Elysia49 } from "elysia";
30940
+ import { Elysia as Elysia50 } from "elysia";
30741
30941
  var escapeHtml45 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
30742
30942
  var getString19 = (value) => typeof value === "string" && value.trim() ? value.trim() : undefined;
30743
30943
  var getNumber11 = (value) => {
@@ -30846,7 +31046,7 @@ var createVoiceTraceDeliveryRoutes = (options) => {
30846
31046
  const path = options.path ?? "/api/voice-trace-deliveries";
30847
31047
  const htmlPath = options.htmlPath === undefined ? "/traces/deliveries" : options.htmlPath;
30848
31048
  const workerPath = options.workerPath === undefined ? `${path}/drain` : options.workerPath;
30849
- const routes = new Elysia49({
31049
+ const routes = new Elysia50({
30850
31050
  name: options.name ?? "absolutejs-voice-trace-deliveries"
30851
31051
  }).get(path, createVoiceTraceDeliveryJSONHandler(options));
30852
31052
  if (htmlPath !== false) {
@@ -30943,7 +31143,7 @@ var createVoiceMemoryStore = () => {
30943
31143
  return { get, getOrCreate, list, remove, set };
30944
31144
  };
30945
31145
  // src/opsWebhook.ts
30946
- import { Elysia as Elysia50 } from "elysia";
31146
+ import { Elysia as Elysia51 } from "elysia";
30947
31147
  var toHex6 = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
30948
31148
  var signVoiceOpsWebhookBody = async (input) => {
30949
31149
  const encoder = new TextEncoder;
@@ -31073,7 +31273,7 @@ var verifyVoiceOpsWebhookSignature = async (input) => {
31073
31273
  };
31074
31274
  var createVoiceOpsWebhookReceiverRoutes = (options = {}) => {
31075
31275
  const path = options.path ?? "/api/voice-ops/webhook";
31076
- return new Elysia50().post(path, async ({ body, request, set }) => {
31276
+ return new Elysia51().post(path, async ({ body, request, set }) => {
31077
31277
  const bodyText = typeof body === "string" ? body : JSON.stringify(body);
31078
31278
  if (options.signingSecret) {
31079
31279
  const verification = await verifyVoiceOpsWebhookSignature({
@@ -31528,7 +31728,7 @@ var resolveVoiceOpsPreset = (name, overrides = {}) => {
31528
31728
  };
31529
31729
  };
31530
31730
  // src/postCallAnalysis.ts
31531
- import { Elysia as Elysia51 } from "elysia";
31731
+ import { Elysia as Elysia52 } from "elysia";
31532
31732
  var isStore = (value) => Boolean(value) && typeof value === "object" && value !== null && ("list" in value);
31533
31733
  var asArray = async (value) => Array.isArray(value) ? value : isStore(value) ? await value.list() : [];
31534
31734
  var getPathValue3 = (source, path) => {
@@ -31707,7 +31907,7 @@ var resolvePostCallAnalysisReport = async (options, input) => {
31707
31907
  };
31708
31908
  var createVoicePostCallAnalysisRoutes = (options = {}) => {
31709
31909
  const path = options.path ?? "/api/voice/post-call-analysis";
31710
- const routes = new Elysia51({
31910
+ const routes = new Elysia52({
31711
31911
  name: options.name ?? "absolutejs-voice-post-call-analysis"
31712
31912
  });
31713
31913
  routes.get(path, async ({ query }) => {
@@ -31732,7 +31932,7 @@ var createVoicePostCallAnalysisRoutes = (options = {}) => {
31732
31932
  return routes;
31733
31933
  };
31734
31934
  // src/guardrails.ts
31735
- import { Elysia as Elysia52 } from "elysia";
31935
+ import { Elysia as Elysia53 } from "elysia";
31736
31936
  var stringifyContent = (value) => typeof value === "string" ? value : JSON.stringify(value) ?? "";
31737
31937
  var appliesToStage = (rule, stage) => !rule.stages || rule.stages.length === 0 || rule.stages.includes(stage);
31738
31938
  var matchesRule = async (rule, input) => {
@@ -32034,7 +32234,7 @@ var resolveGuardrailReport = async (options, input) => {
32034
32234
  };
32035
32235
  var createVoiceGuardrailRoutes = (options = {}) => {
32036
32236
  const path = options.path ?? "/api/voice/guardrails";
32037
- const routes = new Elysia52({
32237
+ const routes = new Elysia53({
32038
32238
  name: options.name ?? "absolutejs-voice-guardrails"
32039
32239
  });
32040
32240
  routes.all(path, async ({ request }) => {
@@ -32549,6 +32749,7 @@ export {
32549
32749
  renderVoiceTraceDeliveryHTML,
32550
32750
  renderVoiceToolContractHTML,
32551
32751
  renderVoiceTelephonyCarrierMatrixHTML,
32752
+ renderVoiceSloCalibrationMarkdown,
32552
32753
  renderVoiceSimulationSuiteHTML,
32553
32754
  renderVoiceSessionsHTML,
32554
32755
  renderVoiceScenarioFixtureEvalHTML,
@@ -32729,6 +32930,8 @@ export {
32729
32930
  createVoiceTaskSLABreachedEvent,
32730
32931
  createVoiceTaskCreatedEvent,
32731
32932
  createVoiceTTSProviderRouter,
32933
+ createVoiceSloThresholdProfile,
32934
+ createVoiceSloCalibrationRoutes,
32732
32935
  createVoiceSimulationSuiteRoutes,
32733
32936
  createVoiceSessionsJSONHandler,
32734
32937
  createVoiceSessionsHTMLHandler,
@@ -32962,6 +33165,7 @@ export {
32962
33165
  buildVoiceTraceReplay,
32963
33166
  buildVoiceTraceDeliveryReport,
32964
33167
  buildVoiceTelephonyWebhookSecurityReport,
33168
+ buildVoiceSloCalibrationReport,
32965
33169
  buildVoiceProviderSloReport,
32966
33170
  buildVoiceProviderContractMatrix,
32967
33171
  buildVoiceProofTrendReport,
@@ -33000,6 +33204,7 @@ export {
33000
33204
  assertVoiceToolContractEvidence,
33001
33205
  assertVoiceTelephonyWebhookSecurityEvidence,
33002
33206
  assertVoiceTelephonyWebhookNormalizationEvidence,
33207
+ assertVoiceSloCalibration,
33003
33208
  assertVoiceSimulationSuiteEvidence,
33004
33209
  assertVoiceProviderStackEvidence,
33005
33210
  assertVoiceProviderSloEvidence,
@@ -0,0 +1,124 @@
1
+ import { Elysia } from 'elysia';
2
+ import type { VoiceProviderSloThresholdConfig } from './providerSlo';
3
+ import type { VoiceProofTrendReport } from './proofTrends';
4
+ export type VoiceSloCalibrationStatus = 'fail' | 'pass' | 'warn';
5
+ export type VoiceSloCalibrationMetricKey = 'interruption' | 'liveLatency' | 'monitorRun' | 'notifierDelivery' | 'provider' | 'reconnect' | 'turnLatency';
6
+ export type VoiceSloCalibrationSample = {
7
+ generatedAt?: string;
8
+ interruptionP95Ms?: number;
9
+ liveP95Ms?: number;
10
+ monitorRunP95Ms?: number;
11
+ notifierDeliveryP95Ms?: number;
12
+ ok?: boolean;
13
+ providerP95Ms?: number;
14
+ reconnectP95Ms?: number;
15
+ runId?: string;
16
+ source?: string;
17
+ turnP95Ms?: number;
18
+ };
19
+ export type VoiceSloCalibrationThreshold = {
20
+ baselineP95Ms?: number;
21
+ failAfterMs?: number;
22
+ headroomMultiplier: number;
23
+ maxObservedMs?: number;
24
+ metric: VoiceSloCalibrationMetricKey;
25
+ minimumMs: number;
26
+ recommendedMs?: number;
27
+ samples: number;
28
+ status: VoiceSloCalibrationStatus;
29
+ warnAfterMs?: number;
30
+ };
31
+ export type VoiceSloCalibrationThresholds = {
32
+ interruption: VoiceSloCalibrationThreshold;
33
+ liveLatency: VoiceSloCalibrationThreshold;
34
+ monitorRun: VoiceSloCalibrationThreshold;
35
+ notifierDelivery: VoiceSloCalibrationThreshold;
36
+ provider: VoiceSloCalibrationThreshold;
37
+ reconnect: VoiceSloCalibrationThreshold;
38
+ turnLatency: VoiceSloCalibrationThreshold;
39
+ };
40
+ export type VoiceSloCalibrationReport = {
41
+ generatedAt: string;
42
+ issues: string[];
43
+ minPassingRuns: number;
44
+ ok: boolean;
45
+ passingRuns: number;
46
+ recommendedProviderSloThresholds: VoiceProviderSloThresholdConfig;
47
+ runs: number;
48
+ sources: string[];
49
+ status: VoiceSloCalibrationStatus;
50
+ thresholds: VoiceSloCalibrationThresholds;
51
+ };
52
+ export type VoiceSloThresholdProfile = {
53
+ bargeIn: {
54
+ thresholdMs?: number;
55
+ };
56
+ issues: string[];
57
+ liveLatency: {
58
+ failAfterMs?: number;
59
+ warnAfterMs?: number;
60
+ };
61
+ monitoring: {
62
+ monitorRunFailAfterMs?: number;
63
+ notifierDeliveryFailAfterMs?: number;
64
+ };
65
+ providerSlo: VoiceProviderSloThresholdConfig;
66
+ reconnect: {
67
+ failAfterMs?: number;
68
+ };
69
+ status: VoiceSloCalibrationStatus;
70
+ };
71
+ export type VoiceSloCalibrationOptions = {
72
+ headroomMultiplier?: number;
73
+ liveLatencyMinimumMs?: number;
74
+ minPassingRuns?: number;
75
+ monitorRunMinimumMs?: number;
76
+ notifierDeliveryMinimumMs?: number;
77
+ providerMinimumMs?: number;
78
+ reconnectMinimumMs?: number;
79
+ interruptionMinimumMs?: number;
80
+ turnLatencyMinimumMs?: number;
81
+ warnRatio?: number;
82
+ };
83
+ export type VoiceSloCalibrationRoutesOptions = VoiceSloCalibrationOptions & {
84
+ headers?: HeadersInit;
85
+ markdownPath?: false | string;
86
+ name?: string;
87
+ path?: string;
88
+ source: (() => Promise<Array<VoiceProofTrendReport | VoiceSloCalibrationSample>> | Array<VoiceProofTrendReport | VoiceSloCalibrationSample>) | Array<VoiceProofTrendReport | VoiceSloCalibrationSample>;
89
+ title?: string;
90
+ };
91
+ export declare const buildVoiceSloCalibrationReport: (input: Array<VoiceProofTrendReport | VoiceSloCalibrationSample>, options?: VoiceSloCalibrationOptions) => VoiceSloCalibrationReport;
92
+ export declare const assertVoiceSloCalibration: (input: Array<VoiceProofTrendReport | VoiceSloCalibrationSample>, options?: VoiceSloCalibrationOptions) => VoiceSloCalibrationReport;
93
+ export declare const createVoiceSloThresholdProfile: (input: VoiceSloCalibrationReport | Array<VoiceProofTrendReport | VoiceSloCalibrationSample>, options?: VoiceSloCalibrationOptions) => VoiceSloThresholdProfile;
94
+ export declare const renderVoiceSloCalibrationMarkdown: (report: VoiceSloCalibrationReport, options?: {
95
+ title?: string;
96
+ }) => string;
97
+ export declare const createVoiceSloCalibrationRoutes: (options: VoiceSloCalibrationRoutesOptions) => Elysia<"", {
98
+ decorator: {};
99
+ store: {};
100
+ derive: {};
101
+ resolve: {};
102
+ }, {
103
+ typebox: {};
104
+ error: {};
105
+ }, {
106
+ schema: {};
107
+ standaloneSchema: {};
108
+ macro: {};
109
+ macroFn: {};
110
+ parser: {};
111
+ response: {};
112
+ }, {}, {
113
+ derive: {};
114
+ resolve: {};
115
+ schema: {};
116
+ standaloneSchema: {};
117
+ response: {};
118
+ }, {
119
+ derive: {};
120
+ resolve: {};
121
+ schema: {};
122
+ standaloneSchema: {};
123
+ response: {};
124
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.280",
3
+ "version": "0.0.22-beta.282",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",