feat: report live voice status and harden target handling

This commit is contained in:
illusia committed 2026-09-28 22:28:16 +08:00
1 parent e0d5916a86
commit 0a4fff6f6f
19 files changed
+1003 -101

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import assert from "node:assert/strict";
import test from "node:test";
import { parseClientCommand } from "./voice-protocol.js";
test("accepts a bounded audio stats snapshot request", () => {
assert.deepEqual(parseClientCommand(JSON.stringify({
type: "audioStatsProbe",
payload: { sequence: "audio-sample-1" },
})), {
type: "audioStatsProbe",
payload: { sequence: "audio-sample-1" },
});
});
test("continues accepting the legacy control-path probe for cached clients", () => {
assert.deepEqual(parseClientCommand(JSON.stringify({
type: "latencyProbe",
payload: { sequence: "latency-old-client" },
})), {
type: "latencyProbe",
payload: { sequence: "latency-old-client" },
});
});
test("rejects audio stats requests without a short sequence id", () => {
const result = parseClientCommand(JSON.stringify({
type: "audioStatsProbe",
payload: { sequence: "x".repeat(65) },
}));
assert.deepEqual(result, {
error: { code: "INVALID_AUDIO_STATS_PROBE", message: "音频状态采样标识无效" },
});
});