@absolutejs/voice 0.0.22-beta.463 → 0.0.22-beta.465
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 +5 -662
- package/dist/client/index.js +5 -662
- package/dist/generated/htmxBootstrapBundle.d.ts +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +323 -689
- package/dist/mediaPipelineRoutes.d.ts +55 -1
- package/dist/mediaPipelineSurfaces.d.ts +48 -0
- package/dist/react/index.js +5 -662
- package/dist/svelte/index.js +5 -662
- package/dist/testing/index.js +51 -708
- package/dist/vue/index.js +5 -662
- package/package.json +3 -3
package/dist/react/index.js
CHANGED
|
@@ -11086,669 +11086,12 @@ var serverMessageToAction = (message) => {
|
|
|
11086
11086
|
}
|
|
11087
11087
|
};
|
|
11088
11088
|
|
|
11089
|
-
// node_modules/@absolutejs/media/dist/index.js
|
|
11090
|
-
var formatLabel = (format) => `${format.container}/${format.encoding}/${String(format.sampleRateHz)}hz/${String(format.channels)}ch`;
|
|
11091
|
-
var formatMatches = (actual, expected) => actual.container === expected.container && actual.encoding === expected.encoding && actual.sampleRateHz === expected.sampleRateHz && actual.channels === expected.channels;
|
|
11092
|
-
var pushIssue = (issues, severity, code, message) => {
|
|
11093
|
-
issues.push({ code, message, severity });
|
|
11094
|
-
};
|
|
11095
|
-
var numericMetadata = (frame, key) => {
|
|
11096
|
-
const value = frame.metadata?.[key];
|
|
11097
|
-
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
11098
|
-
};
|
|
11099
|
-
var average = (values) => values.length === 0 ? undefined : values.reduce((total, value) => total + value, 0) / values.length;
|
|
11100
|
-
var max = (values) => values.length === 0 ? undefined : Math.max(...values);
|
|
11101
|
-
var min = (values) => values.length === 0 ? undefined : Math.min(...values);
|
|
11102
|
-
var numericStat = (stat, key) => {
|
|
11103
|
-
const value = stat[key];
|
|
11104
|
-
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
11105
|
-
};
|
|
11106
|
-
var booleanStat = (stat, key) => {
|
|
11107
|
-
const value = stat[key];
|
|
11108
|
-
return typeof value === "boolean" ? value : undefined;
|
|
11109
|
-
};
|
|
11110
|
-
var stringStat = (stat, key) => {
|
|
11111
|
-
const value = stat[key];
|
|
11112
|
-
return typeof value === "string" ? value : undefined;
|
|
11113
|
-
};
|
|
11114
|
-
var statKey = (stat) => String(stat.id ?? stringStat(stat, "ssrc") ?? numericStat(stat, "ssrc") ?? stringStat(stat, "trackIdentifier") ?? stringStat(stat, "mid") ?? "unknown");
|
|
11115
|
-
var secondsToMs = (value) => value === undefined ? undefined : value * 1000;
|
|
11116
|
-
var DEFAULT_TELEPHONY_FORMAT = {
|
|
11117
|
-
channels: 1,
|
|
11118
|
-
container: "raw",
|
|
11119
|
-
encoding: "mulaw",
|
|
11120
|
-
sampleRateHz: 8000
|
|
11121
|
-
};
|
|
11122
|
-
var bytesToBase64 = (audio) => {
|
|
11123
|
-
const bytes = audio instanceof ArrayBuffer ? new Uint8Array(audio) : new Uint8Array(audio.buffer, audio.byteOffset, audio.byteLength);
|
|
11124
|
-
return Buffer.from(bytes).toString("base64");
|
|
11125
|
-
};
|
|
11126
|
-
var base64ToBytes = (value) => new Uint8Array(Buffer.from(value, "base64"));
|
|
11127
|
-
var unknownRecord = (value) => value && typeof value === "object" ? value : {};
|
|
11128
|
-
var firstString = (records, keys) => {
|
|
11129
|
-
for (const record of records) {
|
|
11130
|
-
for (const key of keys) {
|
|
11131
|
-
const value = record[key];
|
|
11132
|
-
if (typeof value === "string" && value.length > 0) {
|
|
11133
|
-
return value;
|
|
11134
|
-
}
|
|
11135
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
11136
|
-
return String(value);
|
|
11137
|
-
}
|
|
11138
|
-
}
|
|
11139
|
-
}
|
|
11140
|
-
return;
|
|
11141
|
-
};
|
|
11142
|
-
var firstNumber = (records, keys) => {
|
|
11143
|
-
for (const record of records) {
|
|
11144
|
-
for (const key of keys) {
|
|
11145
|
-
const value = record[key];
|
|
11146
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
11147
|
-
return value;
|
|
11148
|
-
}
|
|
11149
|
-
if (typeof value === "string") {
|
|
11150
|
-
const parsed = Number(value);
|
|
11151
|
-
if (Number.isFinite(parsed)) {
|
|
11152
|
-
return parsed;
|
|
11153
|
-
}
|
|
11154
|
-
}
|
|
11155
|
-
}
|
|
11156
|
-
}
|
|
11157
|
-
return;
|
|
11158
|
-
};
|
|
11159
|
-
var telephonyDirection = (track) => {
|
|
11160
|
-
const normalized = track?.toLowerCase();
|
|
11161
|
-
if (!normalized) {
|
|
11162
|
-
return "unknown";
|
|
11163
|
-
}
|
|
11164
|
-
if (normalized.includes("inbound") || normalized.includes("caller") || normalized.includes("in")) {
|
|
11165
|
-
return "inbound";
|
|
11166
|
-
}
|
|
11167
|
-
if (normalized.includes("outbound") || normalized.includes("assistant") || normalized.includes("out")) {
|
|
11168
|
-
return "outbound";
|
|
11169
|
-
}
|
|
11170
|
-
return "unknown";
|
|
11171
|
-
};
|
|
11172
|
-
var telephonyFrameKind = (direction) => direction === "outbound" ? "assistant-audio" : "input-audio";
|
|
11173
|
-
var telephonyEventKind = (envelope) => {
|
|
11174
|
-
const raw = firstString([envelope], ["event", "type", "eventType"]) ?? firstString([unknownRecord(envelope.message)], ["event", "type"]);
|
|
11175
|
-
const normalized = raw?.toLowerCase().replace(/[_\s-]+/g, "-");
|
|
11176
|
-
if (!normalized) {
|
|
11177
|
-
return "unknown";
|
|
11178
|
-
}
|
|
11179
|
-
if (normalized.includes("connected")) {
|
|
11180
|
-
return "connected";
|
|
11181
|
-
}
|
|
11182
|
-
if (normalized.includes("start")) {
|
|
11183
|
-
return "start";
|
|
11184
|
-
}
|
|
11185
|
-
if (normalized.includes("media")) {
|
|
11186
|
-
return "media";
|
|
11187
|
-
}
|
|
11188
|
-
if (normalized.includes("stop") || normalized.includes("closed")) {
|
|
11189
|
-
return "stop";
|
|
11190
|
-
}
|
|
11191
|
-
if (normalized.includes("error") || normalized.includes("failed")) {
|
|
11192
|
-
return "error";
|
|
11193
|
-
}
|
|
11194
|
-
return "unknown";
|
|
11195
|
-
};
|
|
11196
|
-
var normalizeWebRTCStat = (stat) => {
|
|
11197
|
-
const sample = {};
|
|
11198
|
-
for (const [key, value] of Object.entries(stat)) {
|
|
11199
|
-
if (value === null || typeof value === "boolean" || typeof value === "number" || typeof value === "string") {
|
|
11200
|
-
sample[key] = value;
|
|
11201
|
-
}
|
|
11202
|
-
}
|
|
11203
|
-
return sample;
|
|
11204
|
-
};
|
|
11205
|
-
var parseTelephonyMediaFrame = (input) => {
|
|
11206
|
-
const envelope = input.envelope;
|
|
11207
|
-
const media = unknownRecord(envelope.media);
|
|
11208
|
-
const payload = firstString([media, envelope], ["payload", "audio", "data"]) ?? firstString([unknownRecord(envelope.message)], ["payload"]);
|
|
11209
|
-
if (!payload) {
|
|
11210
|
-
return;
|
|
11211
|
-
}
|
|
11212
|
-
const carrier = input.carrier ?? firstString([envelope], ["provider"]) ?? "telephony";
|
|
11213
|
-
const streamId = firstString([media, envelope], ["streamSid", "stream_id", "streamId", "streamId", "callSid", "call_id"]);
|
|
11214
|
-
const sequenceNumber = firstString([media, envelope], ["sequenceNumber", "sequence_number", "chunk"]);
|
|
11215
|
-
const track = firstString([media, envelope], ["track", "direction"]);
|
|
11216
|
-
const direction = telephonyDirection(track);
|
|
11217
|
-
const timestamp = firstNumber([media, envelope], ["timestamp", "time", "startedAt"]);
|
|
11218
|
-
return {
|
|
11219
|
-
at: timestamp,
|
|
11220
|
-
audio: base64ToBytes(payload),
|
|
11221
|
-
format: input.format ?? DEFAULT_TELEPHONY_FORMAT,
|
|
11222
|
-
id: [
|
|
11223
|
-
carrier,
|
|
11224
|
-
streamId ?? input.sessionId ?? "stream",
|
|
11225
|
-
sequenceNumber ?? timestamp ?? Date.now()
|
|
11226
|
-
].join(":"),
|
|
11227
|
-
kind: telephonyFrameKind(direction),
|
|
11228
|
-
metadata: {
|
|
11229
|
-
carrier,
|
|
11230
|
-
direction,
|
|
11231
|
-
event: firstString([envelope], ["event", "type"]),
|
|
11232
|
-
sequenceNumber,
|
|
11233
|
-
streamId,
|
|
11234
|
-
track
|
|
11235
|
-
},
|
|
11236
|
-
sessionId: input.sessionId ?? streamId,
|
|
11237
|
-
source: "telephony"
|
|
11238
|
-
};
|
|
11239
|
-
};
|
|
11240
|
-
var serializeTelephonyMediaFrame = (input) => {
|
|
11241
|
-
const carrier = input.carrier ?? input.frame.metadata?.carrier ?? "telephony";
|
|
11242
|
-
const streamId = input.streamId ?? (typeof input.frame.metadata?.streamId === "string" ? input.frame.metadata.streamId : input.frame.sessionId);
|
|
11243
|
-
const sequenceNumber = input.sequenceNumber ?? (typeof input.frame.metadata?.sequenceNumber === "string" || typeof input.frame.metadata?.sequenceNumber === "number" ? input.frame.metadata.sequenceNumber : undefined);
|
|
11244
|
-
const direction = input.frame.kind === "assistant-audio" ? "outbound" : "inbound";
|
|
11245
|
-
const payload = input.frame.audio ? bytesToBase64(input.frame.audio) : "";
|
|
11246
|
-
if (carrier === "twilio") {
|
|
11247
|
-
return {
|
|
11248
|
-
event: "media",
|
|
11249
|
-
sequenceNumber,
|
|
11250
|
-
streamSid: streamId,
|
|
11251
|
-
media: {
|
|
11252
|
-
payload,
|
|
11253
|
-
timestamp: input.frame.at,
|
|
11254
|
-
track: direction
|
|
11255
|
-
}
|
|
11256
|
-
};
|
|
11257
|
-
}
|
|
11258
|
-
if (carrier === "telnyx") {
|
|
11259
|
-
return {
|
|
11260
|
-
event: "media",
|
|
11261
|
-
stream_id: streamId,
|
|
11262
|
-
sequence_number: sequenceNumber,
|
|
11263
|
-
media: {
|
|
11264
|
-
payload,
|
|
11265
|
-
timestamp: input.frame.at,
|
|
11266
|
-
track: direction
|
|
11267
|
-
}
|
|
11268
|
-
};
|
|
11269
|
-
}
|
|
11270
|
-
if (carrier === "plivo") {
|
|
11271
|
-
return {
|
|
11272
|
-
event: "media",
|
|
11273
|
-
streamId,
|
|
11274
|
-
sequenceNumber,
|
|
11275
|
-
media: {
|
|
11276
|
-
payload,
|
|
11277
|
-
timestamp: input.frame.at,
|
|
11278
|
-
track: direction
|
|
11279
|
-
}
|
|
11280
|
-
};
|
|
11281
|
-
}
|
|
11282
|
-
return {
|
|
11283
|
-
event: "media",
|
|
11284
|
-
provider: carrier,
|
|
11285
|
-
sequenceNumber,
|
|
11286
|
-
streamId,
|
|
11287
|
-
media: {
|
|
11288
|
-
payload,
|
|
11289
|
-
timestamp: input.frame.at,
|
|
11290
|
-
track: direction
|
|
11291
|
-
}
|
|
11292
|
-
};
|
|
11293
|
-
};
|
|
11294
|
-
var createTelephonyMediaSerializer = (input) => {
|
|
11295
|
-
const format = input.format ?? DEFAULT_TELEPHONY_FORMAT;
|
|
11296
|
-
return {
|
|
11297
|
-
carrier: input.carrier,
|
|
11298
|
-
format,
|
|
11299
|
-
parse: (envelope) => parseTelephonyMediaFrame({
|
|
11300
|
-
carrier: input.carrier,
|
|
11301
|
-
envelope,
|
|
11302
|
-
format,
|
|
11303
|
-
sessionId: input.sessionId ?? input.streamId
|
|
11304
|
-
}),
|
|
11305
|
-
serialize: (frame) => serializeTelephonyMediaFrame({
|
|
11306
|
-
carrier: input.carrier,
|
|
11307
|
-
frame,
|
|
11308
|
-
streamId: input.streamId
|
|
11309
|
-
})
|
|
11310
|
-
};
|
|
11311
|
-
};
|
|
11312
|
-
var parseTelephonyStreamEvent = (input) => {
|
|
11313
|
-
const envelope = input.envelope;
|
|
11314
|
-
const media = unknownRecord(envelope.media);
|
|
11315
|
-
const start = unknownRecord(envelope.start);
|
|
11316
|
-
const stop = unknownRecord(envelope.stop);
|
|
11317
|
-
const errorRecord = unknownRecord(envelope.error);
|
|
11318
|
-
const kind = telephonyEventKind(envelope);
|
|
11319
|
-
const carrier = input.carrier ?? firstString([envelope], ["provider", "carrier"]) ?? "telephony";
|
|
11320
|
-
const frame = kind === "media" ? parseTelephonyMediaFrame({
|
|
11321
|
-
carrier,
|
|
11322
|
-
envelope,
|
|
11323
|
-
format: input.format,
|
|
11324
|
-
sessionId: input.sessionId
|
|
11325
|
-
}) : undefined;
|
|
11326
|
-
const streamId = firstString([media, start, stop, envelope], ["streamSid", "stream_id", "streamId", "callSid", "call_id"]) ?? input.sessionId;
|
|
11327
|
-
const sequenceNumber = firstString([media, envelope], ["sequenceNumber", "sequence_number", "chunk"]);
|
|
11328
|
-
const track = firstString([media, envelope], ["track", "direction"]);
|
|
11329
|
-
return {
|
|
11330
|
-
audioBytes: frame?.audio ? frame.audio instanceof ArrayBuffer ? frame.audio.byteLength : frame.audio.byteLength : 0,
|
|
11331
|
-
at: frame?.at ?? firstNumber([media, start, stop, envelope], ["timestamp", "time", "startedAt"]),
|
|
11332
|
-
carrier,
|
|
11333
|
-
direction: telephonyDirection(track),
|
|
11334
|
-
error: firstString([errorRecord, envelope], ["message", "error", "reason"]),
|
|
11335
|
-
kind,
|
|
11336
|
-
sequenceNumber,
|
|
11337
|
-
streamId
|
|
11338
|
-
};
|
|
11339
|
-
};
|
|
11340
|
-
var buildMediaTelephonyStreamLifecycleReport = (input = {}) => {
|
|
11341
|
-
const envelopes = input.envelopes ?? [];
|
|
11342
|
-
const events = envelopes.map((envelope) => parseTelephonyStreamEvent({
|
|
11343
|
-
carrier: input.carrier,
|
|
11344
|
-
envelope
|
|
11345
|
-
}));
|
|
11346
|
-
const issues = [];
|
|
11347
|
-
const startedIndex = events.findIndex((event) => event.kind === "start");
|
|
11348
|
-
const firstMediaIndex = events.findIndex((event) => event.kind === "media");
|
|
11349
|
-
const stoppedIndex = events.findIndex((event) => event.kind === "stop");
|
|
11350
|
-
const started = startedIndex >= 0;
|
|
11351
|
-
const stopped = stoppedIndex >= 0;
|
|
11352
|
-
const mediaEvents = events.filter((event) => event.kind === "media");
|
|
11353
|
-
const audioBytes = events.reduce((total, event) => total + event.audioBytes, 0);
|
|
11354
|
-
const minAudioBytes = input.minAudioBytes ?? 1;
|
|
11355
|
-
const streamIds = Array.from(new Set(events.map((event) => event.streamId).filter(Boolean)));
|
|
11356
|
-
if ((input.requireStart ?? true) && !started) {
|
|
11357
|
-
pushIssue(issues, "error", "media.telephony_missing_start", "Telephony media stream did not include a start event.");
|
|
11358
|
-
}
|
|
11359
|
-
if ((input.requireMedia ?? true) && mediaEvents.length === 0) {
|
|
11360
|
-
pushIssue(issues, "error", "media.telephony_missing_media", "Telephony media stream did not include media payload events.");
|
|
11361
|
-
}
|
|
11362
|
-
if ((input.requireStop ?? true) && !stopped) {
|
|
11363
|
-
pushIssue(issues, input.maxMissingStop === false ? "warning" : "error", "media.telephony_missing_stop", "Telephony media stream did not include a stop event.");
|
|
11364
|
-
}
|
|
11365
|
-
if (started && firstMediaIndex >= 0 && firstMediaIndex < startedIndex) {
|
|
11366
|
-
pushIssue(issues, "error", "media.telephony_media_before_start", "Telephony media payload arrived before the stream start event.");
|
|
11367
|
-
}
|
|
11368
|
-
if (stopped && firstMediaIndex >= 0 && stoppedIndex < firstMediaIndex) {
|
|
11369
|
-
pushIssue(issues, "error", "media.telephony_stop_before_media", "Telephony media stream stopped before any media payload arrived.");
|
|
11370
|
-
}
|
|
11371
|
-
if (mediaEvents.length > 0 && audioBytes < minAudioBytes) {
|
|
11372
|
-
pushIssue(issues, "error", "media.telephony_no_audio_bytes", `Telephony media stream parsed ${String(audioBytes)} audio byte(s), below required ${String(minAudioBytes)}.`);
|
|
11373
|
-
}
|
|
11374
|
-
for (const event of events) {
|
|
11375
|
-
if (event.kind === "error") {
|
|
11376
|
-
pushIssue(issues, "error", "media.telephony_stream_error", event.error ?? "Telephony media stream emitted an error event.");
|
|
11377
|
-
}
|
|
11378
|
-
}
|
|
11379
|
-
return {
|
|
11380
|
-
audioBytes,
|
|
11381
|
-
carrier: input.carrier,
|
|
11382
|
-
checkedAt: Date.now(),
|
|
11383
|
-
events,
|
|
11384
|
-
issues,
|
|
11385
|
-
mediaEvents: mediaEvents.length,
|
|
11386
|
-
started,
|
|
11387
|
-
status: issues.some((issue) => issue.severity === "error") ? "fail" : issues.length > 0 ? "warn" : "pass",
|
|
11388
|
-
stopped,
|
|
11389
|
-
streamIds
|
|
11390
|
-
};
|
|
11391
|
-
};
|
|
11392
|
-
var buildMediaResamplingPlan = (input) => {
|
|
11393
|
-
const required = !formatMatches(input.inputFormat, input.outputFormat);
|
|
11394
|
-
return {
|
|
11395
|
-
inputFormat: input.inputFormat,
|
|
11396
|
-
outputFormat: input.outputFormat,
|
|
11397
|
-
ratio: input.outputFormat.sampleRateHz / input.inputFormat.sampleRateHz,
|
|
11398
|
-
required,
|
|
11399
|
-
status: input.inputFormat.container === input.outputFormat.container && input.inputFormat.encoding === input.outputFormat.encoding && input.inputFormat.channels === input.outputFormat.channels ? "pass" : "warn"
|
|
11400
|
-
};
|
|
11401
|
-
};
|
|
11402
|
-
var speechProbability = (frame) => {
|
|
11403
|
-
if (frame.metadata?.isSpeech === true) {
|
|
11404
|
-
return 1;
|
|
11405
|
-
}
|
|
11406
|
-
if (frame.metadata?.isSpeech === false) {
|
|
11407
|
-
return 0;
|
|
11408
|
-
}
|
|
11409
|
-
for (const key of ["speechProbability", "voiceProbability", "rms", "energy"]) {
|
|
11410
|
-
const value = numericMetadata(frame, key);
|
|
11411
|
-
if (value !== undefined) {
|
|
11412
|
-
return value;
|
|
11413
|
-
}
|
|
11414
|
-
}
|
|
11415
|
-
return 0;
|
|
11416
|
-
};
|
|
11417
|
-
var buildMediaVadReport = (input = {}) => {
|
|
11418
|
-
const frames = (input.frames ?? []).filter((frame) => frame.kind === "input-audio");
|
|
11419
|
-
const speechStartThreshold = input.speechStartThreshold ?? 0.6;
|
|
11420
|
-
const speechEndThreshold = input.speechEndThreshold ?? 0.35;
|
|
11421
|
-
const minSpeechFrames = input.minSpeechFrames ?? 1;
|
|
11422
|
-
const maxSilenceFrames = input.maxSilenceFrames ?? 1;
|
|
11423
|
-
const segments = [];
|
|
11424
|
-
let activeFrames = [];
|
|
11425
|
-
let silenceFrames = 0;
|
|
11426
|
-
const closeSegment = () => {
|
|
11427
|
-
if (activeFrames.length < minSpeechFrames) {
|
|
11428
|
-
activeFrames = [];
|
|
11429
|
-
silenceFrames = 0;
|
|
11430
|
-
return;
|
|
11431
|
-
}
|
|
11432
|
-
const first = activeFrames[0];
|
|
11433
|
-
const last = activeFrames.at(-1);
|
|
11434
|
-
if (!first) {
|
|
11435
|
-
return;
|
|
11436
|
-
}
|
|
11437
|
-
segments.push({
|
|
11438
|
-
durationMs: first.at !== undefined && last?.at !== undefined ? last.at - first.at + (last.durationMs ?? 0) : undefined,
|
|
11439
|
-
endAt: last?.at !== undefined ? last.at + (last.durationMs ?? 0) : undefined,
|
|
11440
|
-
frameCount: activeFrames.length,
|
|
11441
|
-
segmentId: `vad:${String(segments.length + 1)}`,
|
|
11442
|
-
sessionId: first.sessionId,
|
|
11443
|
-
startAt: first.at,
|
|
11444
|
-
turnId: first.turnId
|
|
11445
|
-
});
|
|
11446
|
-
activeFrames = [];
|
|
11447
|
-
silenceFrames = 0;
|
|
11448
|
-
};
|
|
11449
|
-
for (const frame of frames) {
|
|
11450
|
-
const probability = speechProbability(frame);
|
|
11451
|
-
if (activeFrames.length === 0) {
|
|
11452
|
-
if (probability >= speechStartThreshold) {
|
|
11453
|
-
activeFrames.push(frame);
|
|
11454
|
-
}
|
|
11455
|
-
continue;
|
|
11456
|
-
}
|
|
11457
|
-
activeFrames.push(frame);
|
|
11458
|
-
if (probability <= speechEndThreshold) {
|
|
11459
|
-
silenceFrames += 1;
|
|
11460
|
-
} else {
|
|
11461
|
-
silenceFrames = 0;
|
|
11462
|
-
}
|
|
11463
|
-
if (silenceFrames > maxSilenceFrames) {
|
|
11464
|
-
closeSegment();
|
|
11465
|
-
}
|
|
11466
|
-
}
|
|
11467
|
-
closeSegment();
|
|
11468
|
-
return {
|
|
11469
|
-
checkedAt: Date.now(),
|
|
11470
|
-
inputAudioFrames: frames.length,
|
|
11471
|
-
segments,
|
|
11472
|
-
status: frames.length === 0 ? "warn" : "pass"
|
|
11473
|
-
};
|
|
11474
|
-
};
|
|
11475
|
-
var buildMediaInterruptionReport = (input = {}) => {
|
|
11476
|
-
const issues = [];
|
|
11477
|
-
const interruptionFrames = (input.frames ?? []).filter((frame) => frame.kind === "interruption");
|
|
11478
|
-
const latenciesMs = interruptionFrames.map((frame) => frame.latencyMs).filter((latency) => typeof latency === "number");
|
|
11479
|
-
const maxInterruptionLatencyMs = input.maxInterruptionLatencyMs;
|
|
11480
|
-
if (interruptionFrames.length === 0) {
|
|
11481
|
-
pushIssue(issues, "warning", "media.interruption_missing", "No interruption frame was observed.");
|
|
11482
|
-
}
|
|
11483
|
-
if (maxInterruptionLatencyMs !== undefined && latenciesMs.some((latency) => latency > maxInterruptionLatencyMs)) {
|
|
11484
|
-
pushIssue(issues, "error", "media.interruption_latency", `Interruption latency exceeded ${String(maxInterruptionLatencyMs)}ms.`);
|
|
11485
|
-
}
|
|
11486
|
-
return {
|
|
11487
|
-
checkedAt: Date.now(),
|
|
11488
|
-
interruptionFrames: interruptionFrames.length,
|
|
11489
|
-
issues,
|
|
11490
|
-
latenciesMs,
|
|
11491
|
-
status: issues.some((issue) => issue.severity === "error") ? "fail" : issues.length > 0 ? "warn" : "pass"
|
|
11492
|
-
};
|
|
11493
|
-
};
|
|
11494
|
-
var buildMediaQualityReport = (input = {}) => {
|
|
11495
|
-
const frames = [...input.frames ?? []].sort((a, b) => (a.at ?? 0) - (b.at ?? 0));
|
|
11496
|
-
const audioFrames = frames.filter((frame) => frame.kind === "input-audio" || frame.kind === "assistant-audio");
|
|
11497
|
-
const inputAudioFrames = frames.filter((frame) => frame.kind === "input-audio");
|
|
11498
|
-
const assistantAudioFrames = frames.filter((frame) => frame.kind === "assistant-audio");
|
|
11499
|
-
const issues = [];
|
|
11500
|
-
const gapsMs = [];
|
|
11501
|
-
for (const [index, frame] of audioFrames.entries()) {
|
|
11502
|
-
const previous = audioFrames[index - 1];
|
|
11503
|
-
if (previous?.at === undefined || frame.at === undefined || previous.durationMs === undefined) {
|
|
11504
|
-
continue;
|
|
11505
|
-
}
|
|
11506
|
-
const gap = frame.at - (previous.at + previous.durationMs);
|
|
11507
|
-
if (gap > 0) {
|
|
11508
|
-
gapsMs.push(gap);
|
|
11509
|
-
}
|
|
11510
|
-
}
|
|
11511
|
-
const jitterMs = audioFrames.map((frame) => numericMetadata(frame, "jitterMs")).filter((value) => value !== undefined).at(-1) ?? max(gapsMs);
|
|
11512
|
-
const first = audioFrames.find((frame) => frame.at !== undefined);
|
|
11513
|
-
const last = audioFrames.toReversed().find((frame) => frame.at !== undefined);
|
|
11514
|
-
const durationMs = first?.at !== undefined && last?.at !== undefined ? last.at - first.at + (last.durationMs ?? 0) : undefined;
|
|
11515
|
-
const expectedDurationMs = audioFrames.length > 0 ? audioFrames.reduce((total, frame) => total + (frame.durationMs ?? 0), 0) : undefined;
|
|
11516
|
-
const timestampDriftMs = durationMs !== undefined && expectedDurationMs !== undefined ? Math.max(0, durationMs - expectedDurationMs) : undefined;
|
|
11517
|
-
const speechScores = inputAudioFrames.map(speechProbability);
|
|
11518
|
-
const speechFrames = speechScores.filter((score) => score >= 0.6).length;
|
|
11519
|
-
const silenceFrames = speechScores.filter((score) => score <= 0.35).length;
|
|
11520
|
-
const unknownSpeechFrames = Math.max(0, inputAudioFrames.length - speechFrames - silenceFrames);
|
|
11521
|
-
const speechRatio = inputAudioFrames.length === 0 ? 0 : speechFrames / inputAudioFrames.length;
|
|
11522
|
-
const silenceRatio = inputAudioFrames.length === 0 ? 0 : silenceFrames / inputAudioFrames.length;
|
|
11523
|
-
const levels = audioFrames.map((frame) => numericMetadata(frame, "level") ?? numericMetadata(frame, "rms") ?? numericMetadata(frame, "energy")).filter((value) => value !== undefined);
|
|
11524
|
-
const backpressureEvents = input.transport?.backpressureEvents ?? 0;
|
|
11525
|
-
const maxGapMs = input.maxGapMs;
|
|
11526
|
-
if (maxGapMs !== undefined && gapsMs.some((gap) => gap > maxGapMs)) {
|
|
11527
|
-
pushIssue(issues, "warning", "media.quality_gap", `Observed media gap above ${String(maxGapMs)}ms.`);
|
|
11528
|
-
}
|
|
11529
|
-
if (input.maxJitterMs !== undefined && jitterMs !== undefined && jitterMs > input.maxJitterMs) {
|
|
11530
|
-
pushIssue(issues, "warning", "media.quality_jitter", `Observed jitter ${String(jitterMs)}ms above ${String(input.maxJitterMs)}ms.`);
|
|
11531
|
-
}
|
|
11532
|
-
if (input.maxTimestampDriftMs !== undefined && timestampDriftMs !== undefined && timestampDriftMs > input.maxTimestampDriftMs) {
|
|
11533
|
-
pushIssue(issues, "warning", "media.quality_timestamp_drift", `Observed timestamp drift ${String(timestampDriftMs)}ms above ${String(input.maxTimestampDriftMs)}ms.`);
|
|
11534
|
-
}
|
|
11535
|
-
if (input.minSpeechRatio !== undefined && inputAudioFrames.length > 0 && speechRatio < input.minSpeechRatio) {
|
|
11536
|
-
pushIssue(issues, "warning", "media.quality_speech_ratio", `Observed speech ratio ${String(speechRatio)} below ${String(input.minSpeechRatio)}.`);
|
|
11537
|
-
}
|
|
11538
|
-
if (input.maxBackpressureEvents !== undefined && backpressureEvents > input.maxBackpressureEvents) {
|
|
11539
|
-
pushIssue(issues, "warning", "media.quality_backpressure", `Observed ${String(backpressureEvents)} backpressure event(s), above ${String(input.maxBackpressureEvents)}.`);
|
|
11540
|
-
}
|
|
11541
|
-
return {
|
|
11542
|
-
assistantAudioFrames: assistantAudioFrames.length,
|
|
11543
|
-
backpressureEvents,
|
|
11544
|
-
checkedAt: Date.now(),
|
|
11545
|
-
durationMs,
|
|
11546
|
-
gapCount: gapsMs.length,
|
|
11547
|
-
gapsMs,
|
|
11548
|
-
inputAudioFrames: inputAudioFrames.length,
|
|
11549
|
-
issues,
|
|
11550
|
-
jitterMs,
|
|
11551
|
-
levelAverage: average(levels),
|
|
11552
|
-
levelMax: max(levels),
|
|
11553
|
-
levelMin: min(levels),
|
|
11554
|
-
silenceFrames,
|
|
11555
|
-
silenceRatio,
|
|
11556
|
-
speechFrames,
|
|
11557
|
-
speechRatio,
|
|
11558
|
-
status: issues.some((issue) => issue.severity === "error") ? "fail" : issues.length > 0 ? "warn" : "pass",
|
|
11559
|
-
timestampDriftMs,
|
|
11560
|
-
totalFrames: frames.length,
|
|
11561
|
-
unknownSpeechFrames
|
|
11562
|
-
};
|
|
11563
|
-
};
|
|
11564
|
-
var buildMediaWebRTCStatsReport = (input = {}) => {
|
|
11565
|
-
const stats = input.stats ?? [];
|
|
11566
|
-
const issues = [];
|
|
11567
|
-
const inbound = stats.filter((stat) => stat.type === "inbound-rtp" && stringStat(stat, "kind") !== "video");
|
|
11568
|
-
const outbound = stats.filter((stat) => stat.type === "outbound-rtp" && stringStat(stat, "kind") !== "video");
|
|
11569
|
-
const candidatePairs = stats.filter((stat) => stat.type === "candidate-pair");
|
|
11570
|
-
const audioTracks = stats.filter((stat) => (stat.type === "track" || stat.type === "media-source") && stringStat(stat, "kind") === "audio");
|
|
11571
|
-
const activeCandidatePairs = candidatePairs.filter((stat) => booleanStat(stat, "selected") === true || booleanStat(stat, "nominated") === true || stringStat(stat, "state") === "succeeded").length;
|
|
11572
|
-
const liveAudioTracks = audioTracks.filter((stat) => stringStat(stat, "readyState") !== "ended" && stringStat(stat, "trackState") !== "ended" && booleanStat(stat, "ended") !== true).length;
|
|
11573
|
-
const endedAudioTracks = audioTracks.filter((stat) => stringStat(stat, "readyState") === "ended" || stringStat(stat, "trackState") === "ended" || booleanStat(stat, "ended") === true).length;
|
|
11574
|
-
const inboundPackets = inbound.reduce((total, stat) => total + (numericStat(stat, "packetsReceived") ?? 0), 0);
|
|
11575
|
-
const outboundPackets = outbound.reduce((total, stat) => total + (numericStat(stat, "packetsSent") ?? 0), 0);
|
|
11576
|
-
const packetsLost = [...inbound, ...outbound].reduce((total, stat) => total + Math.max(0, numericStat(stat, "packetsLost") ?? 0), 0);
|
|
11577
|
-
const packetLossDenominator = inboundPackets + packetsLost;
|
|
11578
|
-
const packetLossRatio = packetLossDenominator === 0 ? 0 : packetsLost / packetLossDenominator;
|
|
11579
|
-
const bytesReceived = inbound.reduce((total, stat) => total + (numericStat(stat, "bytesReceived") ?? 0), 0);
|
|
11580
|
-
const bytesSent = outbound.reduce((total, stat) => total + (numericStat(stat, "bytesSent") ?? 0), 0);
|
|
11581
|
-
const roundTripTimeMs = max(candidatePairs.map((stat) => secondsToMs(numericStat(stat, "currentRoundTripTime") ?? numericStat(stat, "roundTripTime"))).filter((value) => value !== undefined));
|
|
11582
|
-
const jitterMs = max([...inbound, ...outbound].map((stat) => secondsToMs(numericStat(stat, "jitter"))).filter((value) => value !== undefined));
|
|
11583
|
-
const jitterBufferDelayMs = max(inbound.map((stat) => {
|
|
11584
|
-
const delay = numericStat(stat, "jitterBufferDelay");
|
|
11585
|
-
const emitted = numericStat(stat, "jitterBufferEmittedCount");
|
|
11586
|
-
return delay !== undefined && emitted !== undefined && emitted > 0 ? delay / emitted * 1000 : undefined;
|
|
11587
|
-
}).filter((value) => value !== undefined));
|
|
11588
|
-
const audioLevels = audioTracks.map((stat) => numericStat(stat, "audioLevel")).filter((value) => value !== undefined);
|
|
11589
|
-
if (input.requireConnectedCandidatePair && candidatePairs.length > 0 && activeCandidatePairs === 0) {
|
|
11590
|
-
pushIssue(issues, "error", "media.webrtc_candidate_pair_missing", "No active WebRTC candidate pair was observed.");
|
|
11591
|
-
}
|
|
11592
|
-
if (input.requireLiveAudioTrack && liveAudioTracks === 0) {
|
|
11593
|
-
pushIssue(issues, "error", "media.webrtc_audio_track_missing", "No live WebRTC audio track was observed.");
|
|
11594
|
-
}
|
|
11595
|
-
if (input.maxPacketLossRatio !== undefined && packetLossRatio > input.maxPacketLossRatio) {
|
|
11596
|
-
pushIssue(issues, "warning", "media.webrtc_packet_loss", `Observed WebRTC packet loss ratio ${String(packetLossRatio)} above ${String(input.maxPacketLossRatio)}.`);
|
|
11597
|
-
}
|
|
11598
|
-
if (input.maxRoundTripTimeMs !== undefined && roundTripTimeMs !== undefined && roundTripTimeMs > input.maxRoundTripTimeMs) {
|
|
11599
|
-
pushIssue(issues, "warning", "media.webrtc_round_trip_time", `Observed WebRTC RTT ${String(roundTripTimeMs)}ms above ${String(input.maxRoundTripTimeMs)}ms.`);
|
|
11600
|
-
}
|
|
11601
|
-
if (input.maxJitterMs !== undefined && jitterMs !== undefined && jitterMs > input.maxJitterMs) {
|
|
11602
|
-
pushIssue(issues, "warning", "media.webrtc_jitter", `Observed WebRTC jitter ${String(jitterMs)}ms above ${String(input.maxJitterMs)}ms.`);
|
|
11603
|
-
}
|
|
11604
|
-
return {
|
|
11605
|
-
activeCandidatePairs,
|
|
11606
|
-
audioLevelAverage: average(audioLevels),
|
|
11607
|
-
bytesReceived,
|
|
11608
|
-
bytesSent,
|
|
11609
|
-
checkedAt: Date.now(),
|
|
11610
|
-
endedAudioTracks,
|
|
11611
|
-
inboundPackets,
|
|
11612
|
-
issues,
|
|
11613
|
-
jitterBufferDelayMs,
|
|
11614
|
-
jitterMs,
|
|
11615
|
-
liveAudioTracks,
|
|
11616
|
-
outboundPackets,
|
|
11617
|
-
packetLossRatio,
|
|
11618
|
-
packetsLost,
|
|
11619
|
-
roundTripTimeMs,
|
|
11620
|
-
status: issues.some((issue) => issue.severity === "error") ? "fail" : issues.length > 0 ? "warn" : "pass",
|
|
11621
|
-
totalStats: stats.length
|
|
11622
|
-
};
|
|
11623
|
-
};
|
|
11624
|
-
var collectMediaWebRTCStats = async (input) => {
|
|
11625
|
-
const report = await input.peerConnection.getStats(input.selector ?? null);
|
|
11626
|
-
return [...report.values()].map(normalizeWebRTCStat);
|
|
11627
|
-
};
|
|
11628
|
-
var buildMediaWebRTCStreamContinuityReport = (input = {}) => {
|
|
11629
|
-
const stats = input.stats ?? [];
|
|
11630
|
-
const previousStats = input.previousStats ?? [];
|
|
11631
|
-
const issues = [];
|
|
11632
|
-
const previousByKey = new Map(previousStats.map((stat) => [statKey(stat), stat]));
|
|
11633
|
-
const audioRtp = stats.filter((stat) => (stat.type === "inbound-rtp" || stat.type === "outbound-rtp") && stringStat(stat, "kind") !== "video" && stringStat(stat, "mediaType") !== "video");
|
|
11634
|
-
const streams = audioRtp.map((stat) => {
|
|
11635
|
-
const direction = stat.type === "outbound-rtp" ? "outbound" : "inbound";
|
|
11636
|
-
const packetsKey = direction === "outbound" ? "packetsSent" : "packetsReceived";
|
|
11637
|
-
const bytesKey = direction === "outbound" ? "bytesSent" : "bytesReceived";
|
|
11638
|
-
const previous = previousByKey.get(statKey(stat));
|
|
11639
|
-
const currentPackets = numericStat(stat, packetsKey);
|
|
11640
|
-
const previousPackets = previous ? numericStat(previous, packetsKey) : undefined;
|
|
11641
|
-
const currentBytes = numericStat(stat, bytesKey);
|
|
11642
|
-
const previousBytes = previous ? numericStat(previous, bytesKey) : undefined;
|
|
11643
|
-
const timeDeltaMs = stat.timestamp !== undefined && previous?.timestamp !== undefined ? stat.timestamp - previous.timestamp : undefined;
|
|
11644
|
-
return {
|
|
11645
|
-
bytesDelta: currentBytes !== undefined && previousBytes !== undefined ? currentBytes - previousBytes : undefined,
|
|
11646
|
-
currentPackets,
|
|
11647
|
-
direction,
|
|
11648
|
-
id: statKey(stat),
|
|
11649
|
-
packetDelta: currentPackets !== undefined && previousPackets !== undefined ? currentPackets - previousPackets : undefined,
|
|
11650
|
-
previousPackets,
|
|
11651
|
-
timeDeltaMs
|
|
11652
|
-
};
|
|
11653
|
-
});
|
|
11654
|
-
const inbound = streams.filter((stream) => stream.direction === "inbound");
|
|
11655
|
-
const outbound = streams.filter((stream) => stream.direction === "outbound");
|
|
11656
|
-
const maxObservedGapMs = max(streams.map((stream) => stream.timeDeltaMs).filter((value) => value !== undefined));
|
|
11657
|
-
const stalledInboundStreams = inbound.filter((stream) => input.maxInboundPacketStallMs !== undefined && stream.timeDeltaMs !== undefined && stream.timeDeltaMs >= input.maxInboundPacketStallMs && stream.packetDelta !== undefined && stream.packetDelta <= 0).length;
|
|
11658
|
-
const stalledOutboundStreams = outbound.filter((stream) => input.maxOutboundPacketStallMs !== undefined && stream.timeDeltaMs !== undefined && stream.timeDeltaMs >= input.maxOutboundPacketStallMs && stream.packetDelta !== undefined && stream.packetDelta <= 0).length;
|
|
11659
|
-
if (input.requireInboundAudio && inbound.length === 0) {
|
|
11660
|
-
pushIssue(issues, "error", "media.webrtc_inbound_audio_missing", "No inbound WebRTC audio RTP stream was observed.");
|
|
11661
|
-
}
|
|
11662
|
-
if (input.requireOutboundAudio && outbound.length === 0) {
|
|
11663
|
-
pushIssue(issues, "error", "media.webrtc_outbound_audio_missing", "No outbound WebRTC audio RTP stream was observed.");
|
|
11664
|
-
}
|
|
11665
|
-
if (input.maxGapMs !== undefined && maxObservedGapMs !== undefined && maxObservedGapMs > input.maxGapMs) {
|
|
11666
|
-
pushIssue(issues, "warning", "media.webrtc_stream_gap", `Observed WebRTC stream sample gap ${String(maxObservedGapMs)}ms above ${String(input.maxGapMs)}ms.`);
|
|
11667
|
-
}
|
|
11668
|
-
if (stalledInboundStreams > 0) {
|
|
11669
|
-
pushIssue(issues, "error", "media.webrtc_inbound_stalled", `${String(stalledInboundStreams)} inbound WebRTC audio stream(s) stopped receiving packets.`);
|
|
11670
|
-
}
|
|
11671
|
-
if (stalledOutboundStreams > 0) {
|
|
11672
|
-
pushIssue(issues, "error", "media.webrtc_outbound_stalled", `${String(stalledOutboundStreams)} outbound WebRTC audio stream(s) stopped sending packets.`);
|
|
11673
|
-
}
|
|
11674
|
-
return {
|
|
11675
|
-
checkedAt: Date.now(),
|
|
11676
|
-
inboundAudioStreams: inbound.length,
|
|
11677
|
-
issues,
|
|
11678
|
-
maxObservedGapMs,
|
|
11679
|
-
outboundAudioStreams: outbound.length,
|
|
11680
|
-
stalledInboundStreams,
|
|
11681
|
-
stalledOutboundStreams,
|
|
11682
|
-
status: issues.some((issue) => issue.severity === "error") ? "fail" : issues.length > 0 ? "warn" : "pass",
|
|
11683
|
-
streams,
|
|
11684
|
-
totalStats: stats.length
|
|
11685
|
-
};
|
|
11686
|
-
};
|
|
11687
|
-
var buildMediaPipelineCalibrationReport = (input = {}) => {
|
|
11688
|
-
const frames = input.frames ?? [];
|
|
11689
|
-
const issues = [];
|
|
11690
|
-
const inputFrames = frames.filter((frame) => frame.kind === "input-audio");
|
|
11691
|
-
const assistantFrames = frames.filter((frame) => frame.kind === "assistant-audio");
|
|
11692
|
-
const turnCommitFrames = frames.filter((frame) => frame.kind === "turn-commit");
|
|
11693
|
-
const interruptionFrameRecords = frames.filter((frame) => frame.kind === "interruption");
|
|
11694
|
-
const traceLinkedFrames = frames.filter((frame) => frame.traceEventId).length;
|
|
11695
|
-
const backpressureFrames = frames.filter((frame) => Boolean(frame.metadata?.backpressure)).length;
|
|
11696
|
-
const audioLatencies = assistantFrames.map((frame) => frame.latencyMs).filter((latency) => typeof latency === "number");
|
|
11697
|
-
const firstAudioLatencyMs = audioLatencies.length > 0 ? Math.min(...audioLatencies) : undefined;
|
|
11698
|
-
const jitterValues = frames.map((frame) => numericMetadata(frame, "jitterMs")).filter((value) => value !== undefined);
|
|
11699
|
-
const jitterMs = jitterValues.length > 0 ? Math.max(...jitterValues) : undefined;
|
|
11700
|
-
const inputFormat = input.inputFormat ?? inputFrames.find((frame) => frame.format)?.format;
|
|
11701
|
-
const outputFormat = input.outputFormat ?? assistantFrames.find((frame) => frame.format)?.format;
|
|
11702
|
-
const resamplingRequired = Boolean(input.expectedInputFormat && inputFormat && inputFormat.sampleRateHz !== input.expectedInputFormat.sampleRateHz) || Boolean(input.expectedOutputFormat && outputFormat && outputFormat.sampleRateHz !== input.expectedOutputFormat.sampleRateHz);
|
|
11703
|
-
const resamplingTargetHz = resamplingRequired && input.expectedInputFormat ? input.expectedInputFormat.sampleRateHz : resamplingRequired ? input.expectedOutputFormat?.sampleRateHz : undefined;
|
|
11704
|
-
if (inputFrames.length === 0) {
|
|
11705
|
-
pushIssue(issues, "warning", "media.input_audio_missing", "No input audio frames were observed.");
|
|
11706
|
-
}
|
|
11707
|
-
if (assistantFrames.length === 0) {
|
|
11708
|
-
pushIssue(issues, "warning", "media.assistant_audio_missing", "No assistant audio frames were observed.");
|
|
11709
|
-
}
|
|
11710
|
-
if (input.expectedInputFormat && inputFormat && !formatMatches(inputFormat, input.expectedInputFormat)) {
|
|
11711
|
-
pushIssue(issues, inputFormat.sampleRateHz === input.expectedInputFormat.sampleRateHz ? "warning" : "error", "media.input_format_mismatch", `Input format ${formatLabel(inputFormat)} does not match expected ${formatLabel(input.expectedInputFormat)}.`);
|
|
11712
|
-
}
|
|
11713
|
-
if (input.expectedOutputFormat && outputFormat && !formatMatches(outputFormat, input.expectedOutputFormat)) {
|
|
11714
|
-
pushIssue(issues, outputFormat.sampleRateHz === input.expectedOutputFormat.sampleRateHz ? "warning" : "error", "media.output_format_mismatch", `Output format ${formatLabel(outputFormat)} does not match expected ${formatLabel(input.expectedOutputFormat)}.`);
|
|
11715
|
-
}
|
|
11716
|
-
if (firstAudioLatencyMs !== undefined && input.maxFirstAudioLatencyMs !== undefined && firstAudioLatencyMs > input.maxFirstAudioLatencyMs) {
|
|
11717
|
-
pushIssue(issues, "error", "media.first_audio_latency", `First audio latency ${String(firstAudioLatencyMs)}ms exceeds budget ${String(input.maxFirstAudioLatencyMs)}ms.`);
|
|
11718
|
-
}
|
|
11719
|
-
if (jitterMs !== undefined && input.maxJitterMs !== undefined && jitterMs > input.maxJitterMs) {
|
|
11720
|
-
pushIssue(issues, "warning", "media.jitter", `Media jitter ${String(jitterMs)}ms exceeds budget ${String(input.maxJitterMs)}ms.`);
|
|
11721
|
-
}
|
|
11722
|
-
if (input.maxBackpressureFrames !== undefined && backpressureFrames > input.maxBackpressureFrames) {
|
|
11723
|
-
pushIssue(issues, "warning", "media.backpressure", `Backpressure frame count ${String(backpressureFrames)} exceeds budget ${String(input.maxBackpressureFrames)}.`);
|
|
11724
|
-
}
|
|
11725
|
-
if (input.requireInterruptionFrame && interruptionFrameRecords.length === 0) {
|
|
11726
|
-
pushIssue(issues, "warning", "media.interruption_missing", "No interruption frame was observed.");
|
|
11727
|
-
}
|
|
11728
|
-
if (input.requireTraceEvidence && traceLinkedFrames === 0) {
|
|
11729
|
-
pushIssue(issues, "warning", "media.trace_evidence_missing", "No media frames were linked to trace evidence.");
|
|
11730
|
-
}
|
|
11731
|
-
return {
|
|
11732
|
-
assistantAudioFrames: assistantFrames.length,
|
|
11733
|
-
backpressureFrames,
|
|
11734
|
-
checkedAt: Date.now(),
|
|
11735
|
-
firstAudioLatencyMs,
|
|
11736
|
-
inputAudioFrames: inputFrames.length,
|
|
11737
|
-
inputFormat,
|
|
11738
|
-
interruptionFrames: interruptionFrameRecords.length,
|
|
11739
|
-
issues,
|
|
11740
|
-
jitterMs,
|
|
11741
|
-
outputFormat,
|
|
11742
|
-
resamplingRequired,
|
|
11743
|
-
resamplingTargetHz,
|
|
11744
|
-
status: issues.some((issue) => issue.severity === "error") ? "fail" : issues.length > 0 ? "warn" : "pass",
|
|
11745
|
-
surface: input.surface ?? "media-pipeline",
|
|
11746
|
-
traceLinkedFrames,
|
|
11747
|
-
turnCommitFrames: turnCommitFrames.length
|
|
11748
|
-
};
|
|
11749
|
-
};
|
|
11750
|
-
|
|
11751
11089
|
// src/client/browserMedia.ts
|
|
11090
|
+
import {
|
|
11091
|
+
buildMediaWebRTCStatsReport,
|
|
11092
|
+
buildMediaWebRTCStreamContinuityReport,
|
|
11093
|
+
collectMediaWebRTCStats
|
|
11094
|
+
} from "@absolutejs/media";
|
|
11752
11095
|
var DEFAULT_BROWSER_MEDIA_PATH = "/api/voice/browser-media";
|
|
11753
11096
|
var DEFAULT_BROWSER_MEDIA_INTERVAL_MS = 5000;
|
|
11754
11097
|
var resolvePeerConnection = async (options) => options.peerConnection ?? await options.getPeerConnection?.() ?? null;
|