dsh-live-voice-debugger 0.4.1 → 0.5.0
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/lib/client.js +67 -14
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -45,6 +45,25 @@ var DIAGNOSTIC_KEY = /* @__PURE__ */ Symbol.for("dsh-live-voice.diagnostics.v1")
|
|
|
45
45
|
var DIAGNOSTIC_CHANGED = "dsh-live-voice:diagnostics-changed";
|
|
46
46
|
|
|
47
47
|
// src/inspector.ts
|
|
48
|
+
function semantic(module2, value) {
|
|
49
|
+
if (value == null) return null;
|
|
50
|
+
if (module2 === "vadRuntime")
|
|
51
|
+
return {
|
|
52
|
+
status: value.status ?? null,
|
|
53
|
+
workerActive: value.workerActive ?? null,
|
|
54
|
+
activeSources: value.activeSources ?? null,
|
|
55
|
+
assets: value.assets ?? null
|
|
56
|
+
};
|
|
57
|
+
const omitted = {
|
|
58
|
+
capture: ["level"],
|
|
59
|
+
vad: ["probability", "silenceMs"],
|
|
60
|
+
chunker: ["bufferedSamples", "bufferedChunks", "silenceSamples", "durationMs"]
|
|
61
|
+
};
|
|
62
|
+
if (!omitted[module2]) return value;
|
|
63
|
+
const result = { ...value };
|
|
64
|
+
for (const key of omitted[module2]) delete result[key];
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
48
67
|
function createInspector(source, now = Date.now, limit = 200) {
|
|
49
68
|
let previous = null;
|
|
50
69
|
let sequence = 0;
|
|
@@ -56,22 +75,56 @@ function createInspector(source, now = Date.now, limit = 200) {
|
|
|
56
75
|
previous = next;
|
|
57
76
|
return;
|
|
58
77
|
}
|
|
78
|
+
const append = (sessionId, module2, before, after) => {
|
|
79
|
+
if (!previous || JSON.stringify(before) === JSON.stringify(after)) return;
|
|
80
|
+
entries.push({
|
|
81
|
+
sequence: ++sequence,
|
|
82
|
+
timeMs: now(),
|
|
83
|
+
sessionId,
|
|
84
|
+
module: module2,
|
|
85
|
+
level: module2.endsWith("error") && after?.present ? "error" : "debug",
|
|
86
|
+
before,
|
|
87
|
+
after
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
append(
|
|
91
|
+
null,
|
|
92
|
+
"vadRuntime",
|
|
93
|
+
semantic("vadRuntime", previous?.vadRuntime),
|
|
94
|
+
semantic("vadRuntime", next?.vadRuntime)
|
|
95
|
+
);
|
|
96
|
+
for (const sourceId of /* @__PURE__ */ new Set([
|
|
97
|
+
...Object.keys(previous?.audioSources ?? {}),
|
|
98
|
+
...Object.keys(next?.audioSources ?? {})
|
|
99
|
+
])) {
|
|
100
|
+
const old = previous?.audioSources?.[sourceId];
|
|
101
|
+
const current = next?.audioSources?.[sourceId];
|
|
102
|
+
if (sourceId === "vad") {
|
|
103
|
+
append(
|
|
104
|
+
null,
|
|
105
|
+
"audioSources.vad",
|
|
106
|
+
semantic("vadRuntime", old),
|
|
107
|
+
semantic("vadRuntime", current)
|
|
108
|
+
);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
for (const module2 of /* @__PURE__ */ new Set([...Object.keys(old ?? {}), ...Object.keys(current ?? {})])) {
|
|
112
|
+
append(
|
|
113
|
+
null,
|
|
114
|
+
"audioSources." + sourceId + "." + module2,
|
|
115
|
+
semantic(module2, old?.[module2]),
|
|
116
|
+
semantic(module2, current?.[module2])
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
59
120
|
for (const [sessionId, session] of Object.entries(next?.sessions ?? {})) {
|
|
60
121
|
for (const [module2, value] of Object.entries(session)) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
timeMs: now(),
|
|
68
|
-
sessionId,
|
|
69
|
-
module: module2,
|
|
70
|
-
level: module2 === "error" && value?.present ? "error" : "debug",
|
|
71
|
-
before: before ?? null,
|
|
72
|
-
after: normalized
|
|
73
|
-
});
|
|
74
|
-
}
|
|
122
|
+
append(
|
|
123
|
+
sessionId,
|
|
124
|
+
module2,
|
|
125
|
+
semantic(module2, previous?.sessions?.[sessionId]?.[module2]),
|
|
126
|
+
semantic(module2, value)
|
|
127
|
+
);
|
|
75
128
|
}
|
|
76
129
|
}
|
|
77
130
|
entries = entries.slice(-Math.max(1, limit));
|