@absolutejs/voice 0.0.22-beta.461 → 0.0.22-beta.464

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/vue/index.js CHANGED
@@ -3690,7 +3690,38 @@ var resolveRealCallEvidenceRuntimeReconnectReports = async (reports, options) =>
3690
3690
  }
3691
3691
  return Array.isArray(resolved) ? resolved : [resolved];
3692
3692
  };
3693
+ var resolveRealCallEvidenceRuntimeSurfaceEvidence = async (source, options) => {
3694
+ const resolved = typeof source === "function" ? await source(options) : source;
3695
+ if (!resolved) {
3696
+ return [];
3697
+ }
3698
+ return Array.isArray(resolved) ? [...resolved] : [resolved];
3699
+ };
3700
+ var createRealCallEvidenceRuntimeSessionId = (prefix, generatedAt) => `${prefix}-${Date.parse(generatedAt) || Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
3701
+ var buildVoiceRealCallProfileEvidenceFromRuntimeSurface = (input, options) => {
3702
+ const evidence = Array.isArray(input) ? input : [input];
3703
+ return evidence.map((item) => {
3704
+ const generatedAt = item.generatedAt ?? (options.now ?? (() => new Date))().toISOString();
3705
+ return {
3706
+ ...item,
3707
+ generatedAt,
3708
+ profileId: item.profileId ?? options.defaultProfileId,
3709
+ providers: item.providers ? [...item.providers] : undefined,
3710
+ sessionId: item.sessionId ?? createRealCallEvidenceRuntimeSessionId(options.defaultSessionPrefix, generatedAt),
3711
+ surfaces: [
3712
+ ...new Set([...item.surfaces ?? [], ...options.defaultSurfaces])
3713
+ ].sort()
3714
+ };
3715
+ });
3716
+ };
3717
+ var buildVoiceRealCallProfileEvidenceFromRuntimeProviderRoles = (input, options = {}) => buildVoiceRealCallProfileEvidenceFromRuntimeSurface(input, {
3718
+ defaultProfileId: options.defaultProfileId ?? "provider-role-evidence",
3719
+ defaultSessionPrefix: options.defaultSessionPrefix ?? "provider-role-evidence",
3720
+ defaultSurfaces: ["provider-path"],
3721
+ now: options.now
3722
+ });
3693
3723
  var mergeRealCallEvidenceRuntimeOptions = (base, override = {}) => ({
3724
+ browserEvidence: override.browserEvidence ?? base.browserEvidence,
3694
3725
  dedupe: override.dedupe ?? base.dedupe,
3695
3726
  evidenceStore: override.evidenceStore ?? base.evidenceStore,
3696
3727
  existingEvidenceLimit: override.existingEvidenceLimit ?? base.existingEvidenceLimit,
@@ -3699,6 +3730,8 @@ var mergeRealCallEvidenceRuntimeOptions = (base, override = {}) => ({
3699
3730
  ...override.history ?? {}
3700
3731
  },
3701
3732
  now: override.now ?? base.now,
3733
+ phoneEvidence: override.phoneEvidence ?? base.phoneEvidence,
3734
+ providerRoleEvidence: override.providerRoleEvidence ?? base.providerRoleEvidence,
3702
3735
  reconnectEvidence: {
3703
3736
  ...base.reconnectEvidence ?? {},
3704
3737
  ...override.reconnectEvidence ?? {}
@@ -3747,6 +3780,30 @@ var buildRealCallEvidenceRuntimeReport = async (options, input = {}) => {
3747
3780
  };
3748
3781
  var collectVoiceRealCallEvidenceRuntimeEvidence = async (options) => {
3749
3782
  const evidence = [];
3783
+ const browserEvidence = await resolveRealCallEvidenceRuntimeSurfaceEvidence(options.browserEvidence, options);
3784
+ if (browserEvidence.length > 0) {
3785
+ evidence.push(...buildVoiceRealCallProfileEvidenceFromRuntimeSurface(browserEvidence, {
3786
+ defaultProfileId: "browser-call",
3787
+ defaultSessionPrefix: "browser-call",
3788
+ defaultSurfaces: ["browser"],
3789
+ now: options.now
3790
+ }));
3791
+ }
3792
+ const phoneEvidence = await resolveRealCallEvidenceRuntimeSurfaceEvidence(options.phoneEvidence, options);
3793
+ if (phoneEvidence.length > 0) {
3794
+ evidence.push(...buildVoiceRealCallProfileEvidenceFromRuntimeSurface(phoneEvidence, {
3795
+ defaultProfileId: "phone-agent",
3796
+ defaultSessionPrefix: "phone-agent",
3797
+ defaultSurfaces: ["phone", "telephony"],
3798
+ now: options.now
3799
+ }));
3800
+ }
3801
+ const providerRoleEvidence = await resolveRealCallEvidenceRuntimeSurfaceEvidence(options.providerRoleEvidence, options);
3802
+ if (providerRoleEvidence.length > 0) {
3803
+ evidence.push(...buildVoiceRealCallProfileEvidenceFromRuntimeProviderRoles(providerRoleEvidence, {
3804
+ now: options.now
3805
+ }));
3806
+ }
3750
3807
  if (options.traceStore) {
3751
3808
  evidence.push(...buildVoiceRealCallProfileEvidenceFromTraceEvents(await options.traceStore.list({
3752
3809
  limit: options.traceEvidence?.limit ?? 5000
@@ -10413,6 +10470,8 @@ var serverMessageToAction = (message) => {
10413
10470
  };
10414
10471
 
10415
10472
  // node_modules/@absolutejs/media/dist/index.js
10473
+ import { mkdir, writeFile } from "fs/promises";
10474
+ import { join } from "path";
10416
10475
  var formatLabel = (format) => `${format.container}/${format.encoding}/${String(format.sampleRateHz)}hz/${String(format.channels)}ch`;
10417
10476
  var formatMatches = (actual, expected) => actual.container === expected.container && actual.encoding === expected.encoding && actual.sampleRateHz === expected.sampleRateHz && actual.channels === expected.channels;
10418
10477
  var pushIssue = (issues, severity, code, message) => {
@@ -11073,6 +11132,269 @@ var buildMediaPipelineCalibrationReport = (input = {}) => {
11073
11132
  turnCommitFrames: turnCommitFrames.length
11074
11133
  };
11075
11134
  };
11135
+ var DEFAULT_METADATA_DENY = [
11136
+ "audioPayload",
11137
+ "auth",
11138
+ "authorization",
11139
+ "cookie",
11140
+ "email",
11141
+ "phone",
11142
+ "phoneNumber",
11143
+ "rawPayload",
11144
+ "secret",
11145
+ "token",
11146
+ "transcript",
11147
+ "utterance"
11148
+ ];
11149
+ var DEFAULT_TRUNCATE = 8;
11150
+ var issueCodes = (issues) => Array.from(new Set(issues.map((issue) => issue.code)));
11151
+ var lastEventKind = (events) => events[events.length - 1]?.kind;
11152
+ var formatOptionalMs = (value) => value === undefined ? "n/a" : `${String(Math.round(value))}ms`;
11153
+ var formatRatio = (value) => `${(value * 100).toFixed(1)}%`;
11154
+ var escapeMarkdownCell = (value) => value.replace(/\|/g, "\\|").replace(/\n/g, " ");
11155
+ var renderIssuesTable = (issues) => {
11156
+ if (issues.length === 0) {
11157
+ return `- No issues.
11158
+ `;
11159
+ }
11160
+ const rows = issues.map((issue) => `| ${issue.severity} | ${escapeMarkdownCell(issue.code)} | ${escapeMarkdownCell(issue.message)} |`).join(`
11161
+ `);
11162
+ return `| Severity | Code | Message |
11163
+ | --- | --- | --- |
11164
+ ${rows}
11165
+ `;
11166
+ };
11167
+ var summarizeMediaQualityReport = (report) => ({
11168
+ backpressureEvents: report.backpressureEvents,
11169
+ description: `${report.totalFrames} frame(s), ${report.gapCount} gap(s), speech ${formatRatio(report.speechRatio)}, status ${report.status}.`,
11170
+ driftMs: report.timestampDriftMs,
11171
+ frameCount: report.totalFrames,
11172
+ gapCount: report.gapCount,
11173
+ issueCodes: issueCodes(report.issues),
11174
+ issueCount: report.issues.length,
11175
+ jitterMs: report.jitterMs,
11176
+ silenceRatio: report.silenceRatio,
11177
+ speechRatio: report.speechRatio,
11178
+ status: report.status
11179
+ });
11180
+ var summarizeMediaTransportReport = (report) => ({
11181
+ backpressureEvents: report.backpressureEvents,
11182
+ description: `${report.name}: ${report.state}, in ${report.inputFrames}, out ${report.outputFrames}, backpressure ${report.backpressureEvents}.`,
11183
+ errors: report.events.filter((event) => event.kind === "error").length,
11184
+ inputFrames: report.inputFrames,
11185
+ lastEventKind: lastEventKind(report.events),
11186
+ name: report.name,
11187
+ outputFrames: report.outputFrames,
11188
+ state: report.state,
11189
+ status: report.status
11190
+ });
11191
+ var summarizeMediaProcessorGraphReport = (report) => {
11192
+ const errorIssueCodes = Array.from(new Set(report.errors.map((event) => event.kind)));
11193
+ return {
11194
+ backpressureEvents: report.backpressure.events.length,
11195
+ description: `${report.name}: ${report.state}, ${report.nodes.length} node(s), in ${report.inputFrames}, out ${report.emittedFrames}, dropped ${report.droppedFrames}.`,
11196
+ droppedFrames: report.droppedFrames,
11197
+ edgeCount: report.edges.length,
11198
+ edgeEventCount: report.edgeEvents.length,
11199
+ emittedFrames: report.emittedFrames,
11200
+ errorCount: report.errors.length,
11201
+ inputFrames: report.inputFrames,
11202
+ issueCodes: errorIssueCodes,
11203
+ lifecycleEventCount: report.lifecycleEvents.length,
11204
+ name: report.name,
11205
+ nodeCount: report.nodes.length,
11206
+ state: report.state,
11207
+ status: report.status,
11208
+ timingMaxMs: report.timing.maxNodeMs
11209
+ };
11210
+ };
11211
+ var renderMediaQualityMarkdown = (report, options = {}) => {
11212
+ const title = options.title ?? "Media Quality Report";
11213
+ const lines = [
11214
+ `# ${title}`,
11215
+ "",
11216
+ `Status: **${report.status}**`,
11217
+ "",
11218
+ "| Metric | Value |",
11219
+ "| --- | ---: |",
11220
+ `| Total frames | ${report.totalFrames} |`,
11221
+ `| Input audio | ${report.inputAudioFrames} |`,
11222
+ `| Assistant audio | ${report.assistantAudioFrames} |`,
11223
+ `| Gaps | ${report.gapCount} |`,
11224
+ `| Jitter | ${formatOptionalMs(report.jitterMs)} |`,
11225
+ `| Timestamp drift | ${formatOptionalMs(report.timestampDriftMs)} |`,
11226
+ `| Speech ratio | ${formatRatio(report.speechRatio)} |`,
11227
+ `| Silence ratio | ${formatRatio(report.silenceRatio)} |`,
11228
+ `| Backpressure events | ${report.backpressureEvents} |`,
11229
+ "",
11230
+ "## Issues",
11231
+ "",
11232
+ renderIssuesTable(report.issues).trimEnd()
11233
+ ];
11234
+ return `${lines.join(`
11235
+ `)}
11236
+ `;
11237
+ };
11238
+ var renderMediaTransportMarkdown = (report, options = {}) => {
11239
+ const title = options.title ?? `Media Transport: ${report.name}`;
11240
+ const limit = options.redact?.truncateArraysAt ?? DEFAULT_TRUNCATE;
11241
+ const events = report.events.slice(-limit);
11242
+ const eventRows = events.length === 0 ? "- No transport events recorded." : ["| At | Kind | State | Buffered | Error |", "| --- | --- | --- | ---: | --- |"].concat(events.map((event) => `| ${event.at} | ${event.kind} | ${event.state} | ${event.bufferedFrames ?? ""} | ${escapeMarkdownCell(event.error ?? "")} |`)).join(`
11243
+ `);
11244
+ const lines = [
11245
+ `# ${title}`,
11246
+ "",
11247
+ `Status: **${report.status}** \xB7 State: **${report.state}**`,
11248
+ "",
11249
+ "| Metric | Value |",
11250
+ "| --- | ---: |",
11251
+ `| Input frames | ${report.inputFrames} |`,
11252
+ `| Output frames | ${report.outputFrames} |`,
11253
+ `| Backpressure events | ${report.backpressureEvents} |`,
11254
+ `| Connected | ${report.connected ? "yes" : "no"} |`,
11255
+ `| Closed | ${report.closed ? "yes" : "no"} |`,
11256
+ `| Failed | ${report.failed ? "yes" : "no"} |`,
11257
+ "",
11258
+ `## Last ${events.length} event(s)`,
11259
+ "",
11260
+ eventRows
11261
+ ];
11262
+ return `${lines.join(`
11263
+ `)}
11264
+ `;
11265
+ };
11266
+ var renderMediaProcessorGraphMarkdown = (report, options = {}) => {
11267
+ const title = options.title ?? `Media Processor Graph: ${report.name}`;
11268
+ const limit = options.redact?.truncateArraysAt ?? DEFAULT_TRUNCATE;
11269
+ const nodeRows = report.nodes.map((node) => `| ${escapeMarkdownCell(node.name)} | ${node.kind} | ${node.status} | ${node.inputFrames} | ${node.emittedFrames} | ${node.droppedFrames} | ${node.errors.length} |`).join(`
11270
+ `);
11271
+ const edgeRows = report.edges.slice(0, limit).map((edge) => `| ${escapeMarkdownCell(edge.from)} | ${escapeMarkdownCell(edge.to)} | ${edge.status} | ${edge.emittedFrames} |`).join(`
11272
+ `);
11273
+ const issues = report.errors.map((event) => ({
11274
+ code: event.kind,
11275
+ message: event.error ?? `Processor graph ${event.kind} (state ${event.state}).`,
11276
+ severity: "error"
11277
+ }));
11278
+ const lines = [
11279
+ `# ${title}`,
11280
+ "",
11281
+ `Status: **${report.status}** \xB7 State: **${report.state}**`,
11282
+ "",
11283
+ "| Metric | Value |",
11284
+ "| --- | ---: |",
11285
+ `| Nodes | ${report.nodes.length} |`,
11286
+ `| Input frames | ${report.inputFrames} |`,
11287
+ `| Emitted frames | ${report.emittedFrames} |`,
11288
+ `| Dropped frames | ${report.droppedFrames} |`,
11289
+ `| Lifecycle events | ${report.lifecycleEvents.length} |`,
11290
+ `| Edge events | ${report.edgeEvents.length} |`,
11291
+ `| Backpressure events | ${report.backpressure.events.length} |`,
11292
+ `| Timing max | ${formatOptionalMs(report.timing.maxNodeMs)} |`,
11293
+ `| Timing average | ${formatOptionalMs(report.timing.averageNodeMs)} |`,
11294
+ "",
11295
+ "## Nodes",
11296
+ "",
11297
+ nodeRows ? `| Node | Kind | Status | In | Out | Dropped | Errors |
11298
+ | --- | --- | --- | ---: | ---: | ---: | ---: |
11299
+ ${nodeRows}` : "- No nodes.",
11300
+ "",
11301
+ `## Edges (showing up to ${limit})`,
11302
+ "",
11303
+ edgeRows ? `| From | To | Status | Frames |
11304
+ | --- | --- | --- | ---: |
11305
+ ${edgeRows}` : "- No edges.",
11306
+ "",
11307
+ "## Errors",
11308
+ "",
11309
+ renderIssuesTable(issues).trimEnd()
11310
+ ];
11311
+ return `${lines.join(`
11312
+ `)}
11313
+ `;
11314
+ };
11315
+ var truncateArrays = (value, limit, seen) => {
11316
+ if (Array.isArray(value)) {
11317
+ const head = value.slice(0, limit).map((entry) => truncateArrays(entry, limit, seen));
11318
+ if (value.length > limit) {
11319
+ return [...head, { truncated: value.length - limit }];
11320
+ }
11321
+ return head;
11322
+ }
11323
+ if (value && typeof value === "object") {
11324
+ if (seen.has(value))
11325
+ return value;
11326
+ seen.add(value);
11327
+ const next = {};
11328
+ for (const [key, entry] of Object.entries(value)) {
11329
+ next[key] = truncateArrays(entry, limit, seen);
11330
+ }
11331
+ return next;
11332
+ }
11333
+ return value;
11334
+ };
11335
+ var applyRedaction = (value, options, seen) => {
11336
+ const mode = options.mode ?? "omit";
11337
+ const maskValue = options.maskValue ?? "[redacted]";
11338
+ const allow = new Set(options.metadataAllow ?? []);
11339
+ const deny = new Set(options.metadataDeny ?? DEFAULT_METADATA_DENY);
11340
+ const walk = (input) => {
11341
+ if (Array.isArray(input)) {
11342
+ return input.map((entry) => walk(entry));
11343
+ }
11344
+ if (input && typeof input === "object") {
11345
+ if (seen.has(input))
11346
+ return input;
11347
+ seen.add(input);
11348
+ const next = {};
11349
+ for (const [key, entry] of Object.entries(input)) {
11350
+ if (allow.has(key)) {
11351
+ next[key] = entry;
11352
+ continue;
11353
+ }
11354
+ if (deny.has(key)) {
11355
+ if (mode === "mask")
11356
+ next[key] = maskValue;
11357
+ continue;
11358
+ }
11359
+ next[key] = walk(entry);
11360
+ }
11361
+ return next;
11362
+ }
11363
+ return input;
11364
+ };
11365
+ return walk(value);
11366
+ };
11367
+ var redactMediaReport = (report, options = {}) => {
11368
+ const limit = options.truncateArraysAt ?? DEFAULT_TRUNCATE;
11369
+ const truncated = truncateArrays(report, limit, new WeakSet);
11370
+ return applyRedaction(truncated, options, new WeakSet);
11371
+ };
11372
+ var buildArtifactPair = (report, summary, markdown, options) => {
11373
+ const jsonValue = options.redact ? redactMediaReport(report, options.redact) : report;
11374
+ return {
11375
+ json: JSON.stringify(jsonValue, null, 2),
11376
+ jsonValue,
11377
+ markdown,
11378
+ summary
11379
+ };
11380
+ };
11381
+ var buildMediaQualityArtifact = (report, options = {}) => buildArtifactPair(report, summarizeMediaQualityReport(report), renderMediaQualityMarkdown(report, options), options);
11382
+ var buildMediaTransportArtifact = (report, options = {}) => buildArtifactPair(report, summarizeMediaTransportReport(report), renderMediaTransportMarkdown(report, options), options);
11383
+ var buildMediaProcessorGraphArtifact = (report, options = {}) => buildArtifactPair(report, summarizeMediaProcessorGraphReport(report), renderMediaProcessorGraphMarkdown(report, options), options);
11384
+ var writeMediaArtifact = async (input) => {
11385
+ await mkdir(input.dir, { recursive: true });
11386
+ const jsonPath = join(input.dir, `${input.slug}.json`);
11387
+ const markdownPath = join(input.dir, `${input.slug}.md`);
11388
+ await Promise.all([
11389
+ writeFile(jsonPath, input.json, "utf8"),
11390
+ writeFile(markdownPath, input.markdown, "utf8")
11391
+ ]);
11392
+ return {
11393
+ jsonPath,
11394
+ markdownPath,
11395
+ summary: input.summary
11396
+ };
11397
+ };
11076
11398
 
11077
11399
  // src/client/browserMedia.ts
11078
11400
  var DEFAULT_BROWSER_MEDIA_PATH = "/api/voice/browser-media";
@@ -71,6 +71,7 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
71
71
  readonly resilience?: string | undefined;
72
72
  readonly sessions?: string | undefined;
73
73
  readonly sloReadinessThresholds?: string | undefined;
74
+ readonly sessionObservability?: string | undefined;
74
75
  readonly traceDeliveries?: string | undefined;
75
76
  };
76
77
  readonly profile?: {
@@ -445,6 +446,13 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
445
446
  readonly status: import("..").VoiceProductionReadinessStatus;
446
447
  readonly total: number;
447
448
  } | undefined;
449
+ readonly sessionObservability?: {
450
+ readonly failed: number;
451
+ readonly passed: number;
452
+ readonly status: import("..").VoiceProductionReadinessStatus;
453
+ readonly total: number;
454
+ readonly warnings: number;
455
+ } | undefined;
448
456
  readonly quality: {
449
457
  readonly status: "fail" | "pass";
450
458
  };
@@ -538,6 +546,7 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
538
546
  readonly resilience?: string | undefined;
539
547
  readonly sessions?: string | undefined;
540
548
  readonly sloReadinessThresholds?: string | undefined;
549
+ readonly sessionObservability?: string | undefined;
541
550
  readonly traceDeliveries?: string | undefined;
542
551
  };
543
552
  readonly profile?: {
@@ -912,6 +921,13 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
912
921
  readonly status: import("..").VoiceProductionReadinessStatus;
913
922
  readonly total: number;
914
923
  } | undefined;
924
+ readonly sessionObservability?: {
925
+ readonly failed: number;
926
+ readonly passed: number;
927
+ readonly status: import("..").VoiceProductionReadinessStatus;
928
+ readonly total: number;
929
+ readonly warnings: number;
930
+ } | undefined;
915
931
  readonly quality: {
916
932
  readonly status: "fail" | "pass";
917
933
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.461",
3
+ "version": "0.0.22-beta.464",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -246,7 +246,7 @@
246
246
  }
247
247
  },
248
248
  "dependencies": {
249
- "@absolutejs/media": "0.0.1-beta.14"
249
+ "@absolutejs/media": "0.0.1-beta.15"
250
250
  },
251
251
  "devDependencies": {
252
252
  "@absolutejs/absolute": "0.19.0-beta.646",