mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
refactor(open-sse): D1c — forceStream hardcode → PROVIDERS schema (#5)
chatCore providerRequiresStreaming: switch provider-name → PROVIDERS[provider].forceStream. Thêm forceStream:true vào registry openai/codex/commandcode. verify-providers allowlist added-fields (forceStream/urlSuffix verified bằng golden + runtime test riêng). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,8 +8,14 @@ import { PROVIDERS } from "../../open-sse/config/providers.js";
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
const baseline = JSON.parse(readFileSync(join(here, "providers-baseline.json"), "utf8"));
|
||||
|
||||
// Normalize via JSON roundtrip so function/undefined are dropped identically.
|
||||
// Fields intentionally added during refactor (verified by dedicated runtime tests, not byte-baseline).
|
||||
const ADDED_FIELDS = new Set(["forceStream", "urlSuffix"]);
|
||||
|
||||
// Normalize via JSON roundtrip so function/undefined are dropped identically; drop added fields.
|
||||
const current = JSON.parse(JSON.stringify(PROVIDERS));
|
||||
for (const id of Object.keys(current)) {
|
||||
for (const f of ADDED_FIELDS) delete current[id][f];
|
||||
}
|
||||
|
||||
const diffs = [];
|
||||
const allIds = new Set([...Object.keys(baseline), ...Object.keys(current)]);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Guards forceStream moved from chatCore hardcode → PROVIDERS schema (#5).
|
||||
import { describe, it, expect } from "vitest";
|
||||
|
||||
const FORCED = ["openai", "codex", "commandcode"];
|
||||
|
||||
describe("forceStream provider config", () => {
|
||||
it("only openai/codex/commandcode force streaming", async () => {
|
||||
const { PROVIDERS } = await import("../../open-sse/config/providers.js");
|
||||
for (const id of FORCED) {
|
||||
expect(PROVIDERS[id]?.forceStream, `${id} forced`).toBe(true);
|
||||
}
|
||||
// a sample of others must NOT force
|
||||
for (const id of ["deepseek", "claude", "gemini", "openrouter"]) {
|
||||
expect(PROVIDERS[id]?.forceStream, `${id} not forced`).not.toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user