fix: support multiple keys per action and harden runtime/parsing

This commit is contained in:
2026-08-14 10:59:25 -06:00
parent 7e3377f932
commit 733bc2b4f9
10 changed files with 180 additions and 87 deletions
+27
View File
@@ -64,3 +64,30 @@ test("decodeEvent returns null for unrelated or malformed events", () => {
assert.equal(decodeEvent({ event: "message", data: JSON.stringify({ type: "logData", data: "{}" }) }), null);
assert.equal(decodeEvent({ event: "message", data: "not json" }), null);
});
test("decodeEvent returns null when modelStatus data is not an array", () => {
const msg: SseMessage = {
event: "message",
data: JSON.stringify({
type: "modelStatus",
data: JSON.stringify({ id: "DeepSeek-V4-Flash-0731", state: "ready" }),
}),
};
assert.equal(decodeEvent(msg), null);
});
test("decodeEvent handles inflight with a non-array requests field and no request field", () => {
const msg: SseMessage = {
event: "message",
data: JSON.stringify({
type: "inflight",
data: JSON.stringify({ operation: "snapshot", requests: "oops" }),
}),
};
const ev = decodeEvent(msg);
assert.ok(ev && ev.type === "inflight");
if (ev && ev.type === "inflight") {
assert.equal(ev.operation, "snapshot");
assert.deepEqual(ev.requests, []);
}
});