@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/angular/index.js +265 -0
- package/dist/client/htmxBootstrap.js +330 -7
- package/dist/client/index.js +322 -0
- package/dist/generated/htmxBootstrapBundle.d.ts +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +1231 -497
- package/dist/mediaPipelineRoutes.d.ts +55 -1
- package/dist/mediaPipelineSurfaces.d.ts +48 -0
- package/dist/productionReadiness.d.ts +17 -0
- package/dist/proofTrends.d.ts +25 -0
- package/dist/react/index.js +322 -0
- package/dist/sessionObservability.d.ts +41 -0
- package/dist/svelte/index.js +265 -0
- package/dist/testing/index.js +265 -0
- package/dist/vue/index.js +322 -0
- package/dist/vue/useVoiceReadinessFailures.d.ts +16 -0
- package/package.json +2 -2
package/dist/svelte/index.js
CHANGED
|
@@ -4262,6 +4262,8 @@ var serverMessageToAction = (message) => {
|
|
|
4262
4262
|
};
|
|
4263
4263
|
|
|
4264
4264
|
// node_modules/@absolutejs/media/dist/index.js
|
|
4265
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
4266
|
+
import { join } from "path";
|
|
4265
4267
|
var formatLabel = (format) => `${format.container}/${format.encoding}/${String(format.sampleRateHz)}hz/${String(format.channels)}ch`;
|
|
4266
4268
|
var formatMatches = (actual, expected) => actual.container === expected.container && actual.encoding === expected.encoding && actual.sampleRateHz === expected.sampleRateHz && actual.channels === expected.channels;
|
|
4267
4269
|
var pushIssue = (issues, severity, code, message) => {
|
|
@@ -4922,6 +4924,269 @@ var buildMediaPipelineCalibrationReport = (input = {}) => {
|
|
|
4922
4924
|
turnCommitFrames: turnCommitFrames.length
|
|
4923
4925
|
};
|
|
4924
4926
|
};
|
|
4927
|
+
var DEFAULT_METADATA_DENY = [
|
|
4928
|
+
"audioPayload",
|
|
4929
|
+
"auth",
|
|
4930
|
+
"authorization",
|
|
4931
|
+
"cookie",
|
|
4932
|
+
"email",
|
|
4933
|
+
"phone",
|
|
4934
|
+
"phoneNumber",
|
|
4935
|
+
"rawPayload",
|
|
4936
|
+
"secret",
|
|
4937
|
+
"token",
|
|
4938
|
+
"transcript",
|
|
4939
|
+
"utterance"
|
|
4940
|
+
];
|
|
4941
|
+
var DEFAULT_TRUNCATE = 8;
|
|
4942
|
+
var issueCodes = (issues) => Array.from(new Set(issues.map((issue) => issue.code)));
|
|
4943
|
+
var lastEventKind = (events) => events[events.length - 1]?.kind;
|
|
4944
|
+
var formatOptionalMs = (value) => value === undefined ? "n/a" : `${String(Math.round(value))}ms`;
|
|
4945
|
+
var formatRatio = (value) => `${(value * 100).toFixed(1)}%`;
|
|
4946
|
+
var escapeMarkdownCell = (value) => value.replace(/\|/g, "\\|").replace(/\n/g, " ");
|
|
4947
|
+
var renderIssuesTable = (issues) => {
|
|
4948
|
+
if (issues.length === 0) {
|
|
4949
|
+
return `- No issues.
|
|
4950
|
+
`;
|
|
4951
|
+
}
|
|
4952
|
+
const rows = issues.map((issue) => `| ${issue.severity} | ${escapeMarkdownCell(issue.code)} | ${escapeMarkdownCell(issue.message)} |`).join(`
|
|
4953
|
+
`);
|
|
4954
|
+
return `| Severity | Code | Message |
|
|
4955
|
+
| --- | --- | --- |
|
|
4956
|
+
${rows}
|
|
4957
|
+
`;
|
|
4958
|
+
};
|
|
4959
|
+
var summarizeMediaQualityReport = (report) => ({
|
|
4960
|
+
backpressureEvents: report.backpressureEvents,
|
|
4961
|
+
description: `${report.totalFrames} frame(s), ${report.gapCount} gap(s), speech ${formatRatio(report.speechRatio)}, status ${report.status}.`,
|
|
4962
|
+
driftMs: report.timestampDriftMs,
|
|
4963
|
+
frameCount: report.totalFrames,
|
|
4964
|
+
gapCount: report.gapCount,
|
|
4965
|
+
issueCodes: issueCodes(report.issues),
|
|
4966
|
+
issueCount: report.issues.length,
|
|
4967
|
+
jitterMs: report.jitterMs,
|
|
4968
|
+
silenceRatio: report.silenceRatio,
|
|
4969
|
+
speechRatio: report.speechRatio,
|
|
4970
|
+
status: report.status
|
|
4971
|
+
});
|
|
4972
|
+
var summarizeMediaTransportReport = (report) => ({
|
|
4973
|
+
backpressureEvents: report.backpressureEvents,
|
|
4974
|
+
description: `${report.name}: ${report.state}, in ${report.inputFrames}, out ${report.outputFrames}, backpressure ${report.backpressureEvents}.`,
|
|
4975
|
+
errors: report.events.filter((event) => event.kind === "error").length,
|
|
4976
|
+
inputFrames: report.inputFrames,
|
|
4977
|
+
lastEventKind: lastEventKind(report.events),
|
|
4978
|
+
name: report.name,
|
|
4979
|
+
outputFrames: report.outputFrames,
|
|
4980
|
+
state: report.state,
|
|
4981
|
+
status: report.status
|
|
4982
|
+
});
|
|
4983
|
+
var summarizeMediaProcessorGraphReport = (report) => {
|
|
4984
|
+
const errorIssueCodes = Array.from(new Set(report.errors.map((event) => event.kind)));
|
|
4985
|
+
return {
|
|
4986
|
+
backpressureEvents: report.backpressure.events.length,
|
|
4987
|
+
description: `${report.name}: ${report.state}, ${report.nodes.length} node(s), in ${report.inputFrames}, out ${report.emittedFrames}, dropped ${report.droppedFrames}.`,
|
|
4988
|
+
droppedFrames: report.droppedFrames,
|
|
4989
|
+
edgeCount: report.edges.length,
|
|
4990
|
+
edgeEventCount: report.edgeEvents.length,
|
|
4991
|
+
emittedFrames: report.emittedFrames,
|
|
4992
|
+
errorCount: report.errors.length,
|
|
4993
|
+
inputFrames: report.inputFrames,
|
|
4994
|
+
issueCodes: errorIssueCodes,
|
|
4995
|
+
lifecycleEventCount: report.lifecycleEvents.length,
|
|
4996
|
+
name: report.name,
|
|
4997
|
+
nodeCount: report.nodes.length,
|
|
4998
|
+
state: report.state,
|
|
4999
|
+
status: report.status,
|
|
5000
|
+
timingMaxMs: report.timing.maxNodeMs
|
|
5001
|
+
};
|
|
5002
|
+
};
|
|
5003
|
+
var renderMediaQualityMarkdown = (report, options = {}) => {
|
|
5004
|
+
const title = options.title ?? "Media Quality Report";
|
|
5005
|
+
const lines = [
|
|
5006
|
+
`# ${title}`,
|
|
5007
|
+
"",
|
|
5008
|
+
`Status: **${report.status}**`,
|
|
5009
|
+
"",
|
|
5010
|
+
"| Metric | Value |",
|
|
5011
|
+
"| --- | ---: |",
|
|
5012
|
+
`| Total frames | ${report.totalFrames} |`,
|
|
5013
|
+
`| Input audio | ${report.inputAudioFrames} |`,
|
|
5014
|
+
`| Assistant audio | ${report.assistantAudioFrames} |`,
|
|
5015
|
+
`| Gaps | ${report.gapCount} |`,
|
|
5016
|
+
`| Jitter | ${formatOptionalMs(report.jitterMs)} |`,
|
|
5017
|
+
`| Timestamp drift | ${formatOptionalMs(report.timestampDriftMs)} |`,
|
|
5018
|
+
`| Speech ratio | ${formatRatio(report.speechRatio)} |`,
|
|
5019
|
+
`| Silence ratio | ${formatRatio(report.silenceRatio)} |`,
|
|
5020
|
+
`| Backpressure events | ${report.backpressureEvents} |`,
|
|
5021
|
+
"",
|
|
5022
|
+
"## Issues",
|
|
5023
|
+
"",
|
|
5024
|
+
renderIssuesTable(report.issues).trimEnd()
|
|
5025
|
+
];
|
|
5026
|
+
return `${lines.join(`
|
|
5027
|
+
`)}
|
|
5028
|
+
`;
|
|
5029
|
+
};
|
|
5030
|
+
var renderMediaTransportMarkdown = (report, options = {}) => {
|
|
5031
|
+
const title = options.title ?? `Media Transport: ${report.name}`;
|
|
5032
|
+
const limit = options.redact?.truncateArraysAt ?? DEFAULT_TRUNCATE;
|
|
5033
|
+
const events = report.events.slice(-limit);
|
|
5034
|
+
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(`
|
|
5035
|
+
`);
|
|
5036
|
+
const lines = [
|
|
5037
|
+
`# ${title}`,
|
|
5038
|
+
"",
|
|
5039
|
+
`Status: **${report.status}** \xB7 State: **${report.state}**`,
|
|
5040
|
+
"",
|
|
5041
|
+
"| Metric | Value |",
|
|
5042
|
+
"| --- | ---: |",
|
|
5043
|
+
`| Input frames | ${report.inputFrames} |`,
|
|
5044
|
+
`| Output frames | ${report.outputFrames} |`,
|
|
5045
|
+
`| Backpressure events | ${report.backpressureEvents} |`,
|
|
5046
|
+
`| Connected | ${report.connected ? "yes" : "no"} |`,
|
|
5047
|
+
`| Closed | ${report.closed ? "yes" : "no"} |`,
|
|
5048
|
+
`| Failed | ${report.failed ? "yes" : "no"} |`,
|
|
5049
|
+
"",
|
|
5050
|
+
`## Last ${events.length} event(s)`,
|
|
5051
|
+
"",
|
|
5052
|
+
eventRows
|
|
5053
|
+
];
|
|
5054
|
+
return `${lines.join(`
|
|
5055
|
+
`)}
|
|
5056
|
+
`;
|
|
5057
|
+
};
|
|
5058
|
+
var renderMediaProcessorGraphMarkdown = (report, options = {}) => {
|
|
5059
|
+
const title = options.title ?? `Media Processor Graph: ${report.name}`;
|
|
5060
|
+
const limit = options.redact?.truncateArraysAt ?? DEFAULT_TRUNCATE;
|
|
5061
|
+
const nodeRows = report.nodes.map((node) => `| ${escapeMarkdownCell(node.name)} | ${node.kind} | ${node.status} | ${node.inputFrames} | ${node.emittedFrames} | ${node.droppedFrames} | ${node.errors.length} |`).join(`
|
|
5062
|
+
`);
|
|
5063
|
+
const edgeRows = report.edges.slice(0, limit).map((edge) => `| ${escapeMarkdownCell(edge.from)} | ${escapeMarkdownCell(edge.to)} | ${edge.status} | ${edge.emittedFrames} |`).join(`
|
|
5064
|
+
`);
|
|
5065
|
+
const issues = report.errors.map((event) => ({
|
|
5066
|
+
code: event.kind,
|
|
5067
|
+
message: event.error ?? `Processor graph ${event.kind} (state ${event.state}).`,
|
|
5068
|
+
severity: "error"
|
|
5069
|
+
}));
|
|
5070
|
+
const lines = [
|
|
5071
|
+
`# ${title}`,
|
|
5072
|
+
"",
|
|
5073
|
+
`Status: **${report.status}** \xB7 State: **${report.state}**`,
|
|
5074
|
+
"",
|
|
5075
|
+
"| Metric | Value |",
|
|
5076
|
+
"| --- | ---: |",
|
|
5077
|
+
`| Nodes | ${report.nodes.length} |`,
|
|
5078
|
+
`| Input frames | ${report.inputFrames} |`,
|
|
5079
|
+
`| Emitted frames | ${report.emittedFrames} |`,
|
|
5080
|
+
`| Dropped frames | ${report.droppedFrames} |`,
|
|
5081
|
+
`| Lifecycle events | ${report.lifecycleEvents.length} |`,
|
|
5082
|
+
`| Edge events | ${report.edgeEvents.length} |`,
|
|
5083
|
+
`| Backpressure events | ${report.backpressure.events.length} |`,
|
|
5084
|
+
`| Timing max | ${formatOptionalMs(report.timing.maxNodeMs)} |`,
|
|
5085
|
+
`| Timing average | ${formatOptionalMs(report.timing.averageNodeMs)} |`,
|
|
5086
|
+
"",
|
|
5087
|
+
"## Nodes",
|
|
5088
|
+
"",
|
|
5089
|
+
nodeRows ? `| Node | Kind | Status | In | Out | Dropped | Errors |
|
|
5090
|
+
| --- | --- | --- | ---: | ---: | ---: | ---: |
|
|
5091
|
+
${nodeRows}` : "- No nodes.",
|
|
5092
|
+
"",
|
|
5093
|
+
`## Edges (showing up to ${limit})`,
|
|
5094
|
+
"",
|
|
5095
|
+
edgeRows ? `| From | To | Status | Frames |
|
|
5096
|
+
| --- | --- | --- | ---: |
|
|
5097
|
+
${edgeRows}` : "- No edges.",
|
|
5098
|
+
"",
|
|
5099
|
+
"## Errors",
|
|
5100
|
+
"",
|
|
5101
|
+
renderIssuesTable(issues).trimEnd()
|
|
5102
|
+
];
|
|
5103
|
+
return `${lines.join(`
|
|
5104
|
+
`)}
|
|
5105
|
+
`;
|
|
5106
|
+
};
|
|
5107
|
+
var truncateArrays = (value, limit, seen) => {
|
|
5108
|
+
if (Array.isArray(value)) {
|
|
5109
|
+
const head = value.slice(0, limit).map((entry) => truncateArrays(entry, limit, seen));
|
|
5110
|
+
if (value.length > limit) {
|
|
5111
|
+
return [...head, { truncated: value.length - limit }];
|
|
5112
|
+
}
|
|
5113
|
+
return head;
|
|
5114
|
+
}
|
|
5115
|
+
if (value && typeof value === "object") {
|
|
5116
|
+
if (seen.has(value))
|
|
5117
|
+
return value;
|
|
5118
|
+
seen.add(value);
|
|
5119
|
+
const next = {};
|
|
5120
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
5121
|
+
next[key] = truncateArrays(entry, limit, seen);
|
|
5122
|
+
}
|
|
5123
|
+
return next;
|
|
5124
|
+
}
|
|
5125
|
+
return value;
|
|
5126
|
+
};
|
|
5127
|
+
var applyRedaction = (value, options, seen) => {
|
|
5128
|
+
const mode = options.mode ?? "omit";
|
|
5129
|
+
const maskValue = options.maskValue ?? "[redacted]";
|
|
5130
|
+
const allow = new Set(options.metadataAllow ?? []);
|
|
5131
|
+
const deny = new Set(options.metadataDeny ?? DEFAULT_METADATA_DENY);
|
|
5132
|
+
const walk = (input) => {
|
|
5133
|
+
if (Array.isArray(input)) {
|
|
5134
|
+
return input.map((entry) => walk(entry));
|
|
5135
|
+
}
|
|
5136
|
+
if (input && typeof input === "object") {
|
|
5137
|
+
if (seen.has(input))
|
|
5138
|
+
return input;
|
|
5139
|
+
seen.add(input);
|
|
5140
|
+
const next = {};
|
|
5141
|
+
for (const [key, entry] of Object.entries(input)) {
|
|
5142
|
+
if (allow.has(key)) {
|
|
5143
|
+
next[key] = entry;
|
|
5144
|
+
continue;
|
|
5145
|
+
}
|
|
5146
|
+
if (deny.has(key)) {
|
|
5147
|
+
if (mode === "mask")
|
|
5148
|
+
next[key] = maskValue;
|
|
5149
|
+
continue;
|
|
5150
|
+
}
|
|
5151
|
+
next[key] = walk(entry);
|
|
5152
|
+
}
|
|
5153
|
+
return next;
|
|
5154
|
+
}
|
|
5155
|
+
return input;
|
|
5156
|
+
};
|
|
5157
|
+
return walk(value);
|
|
5158
|
+
};
|
|
5159
|
+
var redactMediaReport = (report, options = {}) => {
|
|
5160
|
+
const limit = options.truncateArraysAt ?? DEFAULT_TRUNCATE;
|
|
5161
|
+
const truncated = truncateArrays(report, limit, new WeakSet);
|
|
5162
|
+
return applyRedaction(truncated, options, new WeakSet);
|
|
5163
|
+
};
|
|
5164
|
+
var buildArtifactPair = (report, summary, markdown, options) => {
|
|
5165
|
+
const jsonValue = options.redact ? redactMediaReport(report, options.redact) : report;
|
|
5166
|
+
return {
|
|
5167
|
+
json: JSON.stringify(jsonValue, null, 2),
|
|
5168
|
+
jsonValue,
|
|
5169
|
+
markdown,
|
|
5170
|
+
summary
|
|
5171
|
+
};
|
|
5172
|
+
};
|
|
5173
|
+
var buildMediaQualityArtifact = (report, options = {}) => buildArtifactPair(report, summarizeMediaQualityReport(report), renderMediaQualityMarkdown(report, options), options);
|
|
5174
|
+
var buildMediaTransportArtifact = (report, options = {}) => buildArtifactPair(report, summarizeMediaTransportReport(report), renderMediaTransportMarkdown(report, options), options);
|
|
5175
|
+
var buildMediaProcessorGraphArtifact = (report, options = {}) => buildArtifactPair(report, summarizeMediaProcessorGraphReport(report), renderMediaProcessorGraphMarkdown(report, options), options);
|
|
5176
|
+
var writeMediaArtifact = async (input) => {
|
|
5177
|
+
await mkdir(input.dir, { recursive: true });
|
|
5178
|
+
const jsonPath = join(input.dir, `${input.slug}.json`);
|
|
5179
|
+
const markdownPath = join(input.dir, `${input.slug}.md`);
|
|
5180
|
+
await Promise.all([
|
|
5181
|
+
writeFile(jsonPath, input.json, "utf8"),
|
|
5182
|
+
writeFile(markdownPath, input.markdown, "utf8")
|
|
5183
|
+
]);
|
|
5184
|
+
return {
|
|
5185
|
+
jsonPath,
|
|
5186
|
+
markdownPath,
|
|
5187
|
+
summary: input.summary
|
|
5188
|
+
};
|
|
5189
|
+
};
|
|
4925
5190
|
|
|
4926
5191
|
// src/client/browserMedia.ts
|
|
4927
5192
|
var DEFAULT_BROWSER_MEDIA_PATH = "/api/voice/browser-media";
|
package/dist/testing/index.js
CHANGED
|
@@ -2160,6 +2160,8 @@ var serverMessageToAction = (message) => {
|
|
|
2160
2160
|
};
|
|
2161
2161
|
|
|
2162
2162
|
// node_modules/@absolutejs/media/dist/index.js
|
|
2163
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
2164
|
+
import { join } from "path";
|
|
2163
2165
|
var formatLabel = (format) => `${format.container}/${format.encoding}/${String(format.sampleRateHz)}hz/${String(format.channels)}ch`;
|
|
2164
2166
|
var formatMatches = (actual, expected) => actual.container === expected.container && actual.encoding === expected.encoding && actual.sampleRateHz === expected.sampleRateHz && actual.channels === expected.channels;
|
|
2165
2167
|
var pushIssue = (issues, severity, code, message) => {
|
|
@@ -2820,6 +2822,269 @@ var buildMediaPipelineCalibrationReport = (input = {}) => {
|
|
|
2820
2822
|
turnCommitFrames: turnCommitFrames.length
|
|
2821
2823
|
};
|
|
2822
2824
|
};
|
|
2825
|
+
var DEFAULT_METADATA_DENY = [
|
|
2826
|
+
"audioPayload",
|
|
2827
|
+
"auth",
|
|
2828
|
+
"authorization",
|
|
2829
|
+
"cookie",
|
|
2830
|
+
"email",
|
|
2831
|
+
"phone",
|
|
2832
|
+
"phoneNumber",
|
|
2833
|
+
"rawPayload",
|
|
2834
|
+
"secret",
|
|
2835
|
+
"token",
|
|
2836
|
+
"transcript",
|
|
2837
|
+
"utterance"
|
|
2838
|
+
];
|
|
2839
|
+
var DEFAULT_TRUNCATE = 8;
|
|
2840
|
+
var issueCodes = (issues) => Array.from(new Set(issues.map((issue) => issue.code)));
|
|
2841
|
+
var lastEventKind = (events) => events[events.length - 1]?.kind;
|
|
2842
|
+
var formatOptionalMs = (value) => value === undefined ? "n/a" : `${String(Math.round(value))}ms`;
|
|
2843
|
+
var formatRatio = (value) => `${(value * 100).toFixed(1)}%`;
|
|
2844
|
+
var escapeMarkdownCell = (value) => value.replace(/\|/g, "\\|").replace(/\n/g, " ");
|
|
2845
|
+
var renderIssuesTable = (issues) => {
|
|
2846
|
+
if (issues.length === 0) {
|
|
2847
|
+
return `- No issues.
|
|
2848
|
+
`;
|
|
2849
|
+
}
|
|
2850
|
+
const rows = issues.map((issue) => `| ${issue.severity} | ${escapeMarkdownCell(issue.code)} | ${escapeMarkdownCell(issue.message)} |`).join(`
|
|
2851
|
+
`);
|
|
2852
|
+
return `| Severity | Code | Message |
|
|
2853
|
+
| --- | --- | --- |
|
|
2854
|
+
${rows}
|
|
2855
|
+
`;
|
|
2856
|
+
};
|
|
2857
|
+
var summarizeMediaQualityReport = (report) => ({
|
|
2858
|
+
backpressureEvents: report.backpressureEvents,
|
|
2859
|
+
description: `${report.totalFrames} frame(s), ${report.gapCount} gap(s), speech ${formatRatio(report.speechRatio)}, status ${report.status}.`,
|
|
2860
|
+
driftMs: report.timestampDriftMs,
|
|
2861
|
+
frameCount: report.totalFrames,
|
|
2862
|
+
gapCount: report.gapCount,
|
|
2863
|
+
issueCodes: issueCodes(report.issues),
|
|
2864
|
+
issueCount: report.issues.length,
|
|
2865
|
+
jitterMs: report.jitterMs,
|
|
2866
|
+
silenceRatio: report.silenceRatio,
|
|
2867
|
+
speechRatio: report.speechRatio,
|
|
2868
|
+
status: report.status
|
|
2869
|
+
});
|
|
2870
|
+
var summarizeMediaTransportReport = (report) => ({
|
|
2871
|
+
backpressureEvents: report.backpressureEvents,
|
|
2872
|
+
description: `${report.name}: ${report.state}, in ${report.inputFrames}, out ${report.outputFrames}, backpressure ${report.backpressureEvents}.`,
|
|
2873
|
+
errors: report.events.filter((event) => event.kind === "error").length,
|
|
2874
|
+
inputFrames: report.inputFrames,
|
|
2875
|
+
lastEventKind: lastEventKind(report.events),
|
|
2876
|
+
name: report.name,
|
|
2877
|
+
outputFrames: report.outputFrames,
|
|
2878
|
+
state: report.state,
|
|
2879
|
+
status: report.status
|
|
2880
|
+
});
|
|
2881
|
+
var summarizeMediaProcessorGraphReport = (report) => {
|
|
2882
|
+
const errorIssueCodes = Array.from(new Set(report.errors.map((event) => event.kind)));
|
|
2883
|
+
return {
|
|
2884
|
+
backpressureEvents: report.backpressure.events.length,
|
|
2885
|
+
description: `${report.name}: ${report.state}, ${report.nodes.length} node(s), in ${report.inputFrames}, out ${report.emittedFrames}, dropped ${report.droppedFrames}.`,
|
|
2886
|
+
droppedFrames: report.droppedFrames,
|
|
2887
|
+
edgeCount: report.edges.length,
|
|
2888
|
+
edgeEventCount: report.edgeEvents.length,
|
|
2889
|
+
emittedFrames: report.emittedFrames,
|
|
2890
|
+
errorCount: report.errors.length,
|
|
2891
|
+
inputFrames: report.inputFrames,
|
|
2892
|
+
issueCodes: errorIssueCodes,
|
|
2893
|
+
lifecycleEventCount: report.lifecycleEvents.length,
|
|
2894
|
+
name: report.name,
|
|
2895
|
+
nodeCount: report.nodes.length,
|
|
2896
|
+
state: report.state,
|
|
2897
|
+
status: report.status,
|
|
2898
|
+
timingMaxMs: report.timing.maxNodeMs
|
|
2899
|
+
};
|
|
2900
|
+
};
|
|
2901
|
+
var renderMediaQualityMarkdown = (report, options = {}) => {
|
|
2902
|
+
const title = options.title ?? "Media Quality Report";
|
|
2903
|
+
const lines = [
|
|
2904
|
+
`# ${title}`,
|
|
2905
|
+
"",
|
|
2906
|
+
`Status: **${report.status}**`,
|
|
2907
|
+
"",
|
|
2908
|
+
"| Metric | Value |",
|
|
2909
|
+
"| --- | ---: |",
|
|
2910
|
+
`| Total frames | ${report.totalFrames} |`,
|
|
2911
|
+
`| Input audio | ${report.inputAudioFrames} |`,
|
|
2912
|
+
`| Assistant audio | ${report.assistantAudioFrames} |`,
|
|
2913
|
+
`| Gaps | ${report.gapCount} |`,
|
|
2914
|
+
`| Jitter | ${formatOptionalMs(report.jitterMs)} |`,
|
|
2915
|
+
`| Timestamp drift | ${formatOptionalMs(report.timestampDriftMs)} |`,
|
|
2916
|
+
`| Speech ratio | ${formatRatio(report.speechRatio)} |`,
|
|
2917
|
+
`| Silence ratio | ${formatRatio(report.silenceRatio)} |`,
|
|
2918
|
+
`| Backpressure events | ${report.backpressureEvents} |`,
|
|
2919
|
+
"",
|
|
2920
|
+
"## Issues",
|
|
2921
|
+
"",
|
|
2922
|
+
renderIssuesTable(report.issues).trimEnd()
|
|
2923
|
+
];
|
|
2924
|
+
return `${lines.join(`
|
|
2925
|
+
`)}
|
|
2926
|
+
`;
|
|
2927
|
+
};
|
|
2928
|
+
var renderMediaTransportMarkdown = (report, options = {}) => {
|
|
2929
|
+
const title = options.title ?? `Media Transport: ${report.name}`;
|
|
2930
|
+
const limit = options.redact?.truncateArraysAt ?? DEFAULT_TRUNCATE;
|
|
2931
|
+
const events = report.events.slice(-limit);
|
|
2932
|
+
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(`
|
|
2933
|
+
`);
|
|
2934
|
+
const lines = [
|
|
2935
|
+
`# ${title}`,
|
|
2936
|
+
"",
|
|
2937
|
+
`Status: **${report.status}** \xB7 State: **${report.state}**`,
|
|
2938
|
+
"",
|
|
2939
|
+
"| Metric | Value |",
|
|
2940
|
+
"| --- | ---: |",
|
|
2941
|
+
`| Input frames | ${report.inputFrames} |`,
|
|
2942
|
+
`| Output frames | ${report.outputFrames} |`,
|
|
2943
|
+
`| Backpressure events | ${report.backpressureEvents} |`,
|
|
2944
|
+
`| Connected | ${report.connected ? "yes" : "no"} |`,
|
|
2945
|
+
`| Closed | ${report.closed ? "yes" : "no"} |`,
|
|
2946
|
+
`| Failed | ${report.failed ? "yes" : "no"} |`,
|
|
2947
|
+
"",
|
|
2948
|
+
`## Last ${events.length} event(s)`,
|
|
2949
|
+
"",
|
|
2950
|
+
eventRows
|
|
2951
|
+
];
|
|
2952
|
+
return `${lines.join(`
|
|
2953
|
+
`)}
|
|
2954
|
+
`;
|
|
2955
|
+
};
|
|
2956
|
+
var renderMediaProcessorGraphMarkdown = (report, options = {}) => {
|
|
2957
|
+
const title = options.title ?? `Media Processor Graph: ${report.name}`;
|
|
2958
|
+
const limit = options.redact?.truncateArraysAt ?? DEFAULT_TRUNCATE;
|
|
2959
|
+
const nodeRows = report.nodes.map((node) => `| ${escapeMarkdownCell(node.name)} | ${node.kind} | ${node.status} | ${node.inputFrames} | ${node.emittedFrames} | ${node.droppedFrames} | ${node.errors.length} |`).join(`
|
|
2960
|
+
`);
|
|
2961
|
+
const edgeRows = report.edges.slice(0, limit).map((edge) => `| ${escapeMarkdownCell(edge.from)} | ${escapeMarkdownCell(edge.to)} | ${edge.status} | ${edge.emittedFrames} |`).join(`
|
|
2962
|
+
`);
|
|
2963
|
+
const issues = report.errors.map((event) => ({
|
|
2964
|
+
code: event.kind,
|
|
2965
|
+
message: event.error ?? `Processor graph ${event.kind} (state ${event.state}).`,
|
|
2966
|
+
severity: "error"
|
|
2967
|
+
}));
|
|
2968
|
+
const lines = [
|
|
2969
|
+
`# ${title}`,
|
|
2970
|
+
"",
|
|
2971
|
+
`Status: **${report.status}** \xB7 State: **${report.state}**`,
|
|
2972
|
+
"",
|
|
2973
|
+
"| Metric | Value |",
|
|
2974
|
+
"| --- | ---: |",
|
|
2975
|
+
`| Nodes | ${report.nodes.length} |`,
|
|
2976
|
+
`| Input frames | ${report.inputFrames} |`,
|
|
2977
|
+
`| Emitted frames | ${report.emittedFrames} |`,
|
|
2978
|
+
`| Dropped frames | ${report.droppedFrames} |`,
|
|
2979
|
+
`| Lifecycle events | ${report.lifecycleEvents.length} |`,
|
|
2980
|
+
`| Edge events | ${report.edgeEvents.length} |`,
|
|
2981
|
+
`| Backpressure events | ${report.backpressure.events.length} |`,
|
|
2982
|
+
`| Timing max | ${formatOptionalMs(report.timing.maxNodeMs)} |`,
|
|
2983
|
+
`| Timing average | ${formatOptionalMs(report.timing.averageNodeMs)} |`,
|
|
2984
|
+
"",
|
|
2985
|
+
"## Nodes",
|
|
2986
|
+
"",
|
|
2987
|
+
nodeRows ? `| Node | Kind | Status | In | Out | Dropped | Errors |
|
|
2988
|
+
| --- | --- | --- | ---: | ---: | ---: | ---: |
|
|
2989
|
+
${nodeRows}` : "- No nodes.",
|
|
2990
|
+
"",
|
|
2991
|
+
`## Edges (showing up to ${limit})`,
|
|
2992
|
+
"",
|
|
2993
|
+
edgeRows ? `| From | To | Status | Frames |
|
|
2994
|
+
| --- | --- | --- | ---: |
|
|
2995
|
+
${edgeRows}` : "- No edges.",
|
|
2996
|
+
"",
|
|
2997
|
+
"## Errors",
|
|
2998
|
+
"",
|
|
2999
|
+
renderIssuesTable(issues).trimEnd()
|
|
3000
|
+
];
|
|
3001
|
+
return `${lines.join(`
|
|
3002
|
+
`)}
|
|
3003
|
+
`;
|
|
3004
|
+
};
|
|
3005
|
+
var truncateArrays = (value, limit, seen) => {
|
|
3006
|
+
if (Array.isArray(value)) {
|
|
3007
|
+
const head = value.slice(0, limit).map((entry) => truncateArrays(entry, limit, seen));
|
|
3008
|
+
if (value.length > limit) {
|
|
3009
|
+
return [...head, { truncated: value.length - limit }];
|
|
3010
|
+
}
|
|
3011
|
+
return head;
|
|
3012
|
+
}
|
|
3013
|
+
if (value && typeof value === "object") {
|
|
3014
|
+
if (seen.has(value))
|
|
3015
|
+
return value;
|
|
3016
|
+
seen.add(value);
|
|
3017
|
+
const next = {};
|
|
3018
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
3019
|
+
next[key] = truncateArrays(entry, limit, seen);
|
|
3020
|
+
}
|
|
3021
|
+
return next;
|
|
3022
|
+
}
|
|
3023
|
+
return value;
|
|
3024
|
+
};
|
|
3025
|
+
var applyRedaction = (value, options, seen) => {
|
|
3026
|
+
const mode = options.mode ?? "omit";
|
|
3027
|
+
const maskValue = options.maskValue ?? "[redacted]";
|
|
3028
|
+
const allow = new Set(options.metadataAllow ?? []);
|
|
3029
|
+
const deny = new Set(options.metadataDeny ?? DEFAULT_METADATA_DENY);
|
|
3030
|
+
const walk = (input) => {
|
|
3031
|
+
if (Array.isArray(input)) {
|
|
3032
|
+
return input.map((entry) => walk(entry));
|
|
3033
|
+
}
|
|
3034
|
+
if (input && typeof input === "object") {
|
|
3035
|
+
if (seen.has(input))
|
|
3036
|
+
return input;
|
|
3037
|
+
seen.add(input);
|
|
3038
|
+
const next = {};
|
|
3039
|
+
for (const [key, entry] of Object.entries(input)) {
|
|
3040
|
+
if (allow.has(key)) {
|
|
3041
|
+
next[key] = entry;
|
|
3042
|
+
continue;
|
|
3043
|
+
}
|
|
3044
|
+
if (deny.has(key)) {
|
|
3045
|
+
if (mode === "mask")
|
|
3046
|
+
next[key] = maskValue;
|
|
3047
|
+
continue;
|
|
3048
|
+
}
|
|
3049
|
+
next[key] = walk(entry);
|
|
3050
|
+
}
|
|
3051
|
+
return next;
|
|
3052
|
+
}
|
|
3053
|
+
return input;
|
|
3054
|
+
};
|
|
3055
|
+
return walk(value);
|
|
3056
|
+
};
|
|
3057
|
+
var redactMediaReport = (report, options = {}) => {
|
|
3058
|
+
const limit = options.truncateArraysAt ?? DEFAULT_TRUNCATE;
|
|
3059
|
+
const truncated = truncateArrays(report, limit, new WeakSet);
|
|
3060
|
+
return applyRedaction(truncated, options, new WeakSet);
|
|
3061
|
+
};
|
|
3062
|
+
var buildArtifactPair = (report, summary, markdown, options) => {
|
|
3063
|
+
const jsonValue = options.redact ? redactMediaReport(report, options.redact) : report;
|
|
3064
|
+
return {
|
|
3065
|
+
json: JSON.stringify(jsonValue, null, 2),
|
|
3066
|
+
jsonValue,
|
|
3067
|
+
markdown,
|
|
3068
|
+
summary
|
|
3069
|
+
};
|
|
3070
|
+
};
|
|
3071
|
+
var buildMediaQualityArtifact = (report, options = {}) => buildArtifactPair(report, summarizeMediaQualityReport(report), renderMediaQualityMarkdown(report, options), options);
|
|
3072
|
+
var buildMediaTransportArtifact = (report, options = {}) => buildArtifactPair(report, summarizeMediaTransportReport(report), renderMediaTransportMarkdown(report, options), options);
|
|
3073
|
+
var buildMediaProcessorGraphArtifact = (report, options = {}) => buildArtifactPair(report, summarizeMediaProcessorGraphReport(report), renderMediaProcessorGraphMarkdown(report, options), options);
|
|
3074
|
+
var writeMediaArtifact = async (input) => {
|
|
3075
|
+
await mkdir(input.dir, { recursive: true });
|
|
3076
|
+
const jsonPath = join(input.dir, `${input.slug}.json`);
|
|
3077
|
+
const markdownPath = join(input.dir, `${input.slug}.md`);
|
|
3078
|
+
await Promise.all([
|
|
3079
|
+
writeFile(jsonPath, input.json, "utf8"),
|
|
3080
|
+
writeFile(markdownPath, input.markdown, "utf8")
|
|
3081
|
+
]);
|
|
3082
|
+
return {
|
|
3083
|
+
jsonPath,
|
|
3084
|
+
markdownPath,
|
|
3085
|
+
summary: input.summary
|
|
3086
|
+
};
|
|
3087
|
+
};
|
|
2823
3088
|
|
|
2824
3089
|
// src/client/browserMedia.ts
|
|
2825
3090
|
var DEFAULT_BROWSER_MEDIA_PATH = "/api/voice/browser-media";
|