fix(net-scope): region gate denial 改为紧致 stream 记录

Fixes the host crash in #84.

denialStream 原先写入 4 条裸 chunk(block-start/text-delta/block-end/finish)。dsh-llm firstRunMemberTime 只认 chunk/text-chunks/reasoning-chunks/tool-call-chunks,裸记录没有 .texts,append 当下 TypeError 被当成 fatal load failure,systemd Restart=always 后 web token 一直变。现包成 { type: chunk, time, chunk },与 AssistantStreamAccumulator 一致。不改写历史 session.v4.jsonl.zstd。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-09 10:16:14 +08:00
1 parent bb850ce8d4
commit 0a291fd07f
1 file changed
+24 -1
+24 -1
View File
@@ -450,7 +450,14 @@ async function denialMessage() {
};
}
function denialStream() {
const COMPACT_STREAM_TYPES = new Set([
"chunk",
"text-chunks",
"reasoning-chunks",
"tool-call-chunks",
]);
function denialChunks() {
return [
{ type: "block-start", index: 0, blockType: "text" },
{ type: "text-delta", index: 0, text: DENIAL },
@@ -459,6 +466,22 @@ function denialStream() {
];
}
/** 宿主持久化只要 Accumulator 紧致记录;裸 chunk 会让 firstRunMemberTime 读 undefined.length(#84)。 */
function denialStream(now = Date.now()) {
const time0 = Number.isSafeInteger(now) ? now : Date.now();
const stream = denialChunks().map((chunk, i) => ({
type: "chunk",
time: time0 + i,
chunk,
}));
for (const record of stream) {
if (!record || !COMPACT_STREAM_TYPES.has(record.type)) {
throw new TypeError("denial stream must use compact Assistant records");
}
}
return stream;
}
async function appendDenial(session, turn, step) {
session.append("assistant/message", {
turn,