refactor(open-sse): DRY SSE primitives into utils/sseConstants.js

Gom SSE_DONE + SSE_HEADERS + SSE_HEADERS_NO_BUFFER vào 1 file không
phụ thuộc (tránh kéo usageDb vào executor). Áp cho kiro, cursor, qoder,
github, commandcode, perplexity-web, grok-web. Byte-for-byte verified
(headers/DONE giữ nguyên; biến thể no-buffer dùng const riêng).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
decolua
2026-06-13 21:42:59 +07:00
parent 0a8d92a6ba
commit 6ee4555821
9 changed files with 42 additions and 25 deletions

View File

@@ -8,6 +8,7 @@ import {
} from "../utils/cursorProtobuf.js";
import { buildCursorHeaders } from "../utils/cursorChecksum.js";
import { estimateUsage } from "../utils/usageTracking.js";
import { SSE_DONE, SSE_HEADERS } from "../utils/sseConstants.js";
import { FORMATS } from "../translator/formats.js";
import { proxyAwareFetch } from "../utils/proxyFetch.js";
import zlib from "zlib";
@@ -775,15 +776,11 @@ export class CursorExecutor extends BaseExecutor {
usage
})}\n\n`
);
chunks.push("data: [DONE]\n\n");
chunks.push(SSE_DONE);
return new Response(chunks.join(""), {
status: 200,
headers: {
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache",
"Connection": "keep-alive"
}
headers: { ...SSE_HEADERS }
});
}