mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 12:22:14 +03:00
Extract the pure content/citation formatters (isThinkingModel, isSearchModel, cleanDeepSeekToken, formatStreamContent, DeepSeekSearchResult, appendSearchCitations) verbatim into the leaf deepseek-web/stream-format.ts. Host imports the 5 it uses back into transformSSE/collectSSEContent (cleanDeepSeekToken stays internal to the leaf). Host 1147 -> 1108 LOC. Byte-identical bodies (verbatim 34/34), leaf has zero imports (no cycle), all module-private (no re-export). PoW/auth/token-cache/HTTP dispatch untouched. Adds a split-guard; consumer tests stay green (deepseek-web 35, deepseek-web-rolling-window-2942 5, deepseek-web-tools-execute 3).
35 lines
1.5 KiB
TypeScript
35 lines
1.5 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, join } from "node:path";
|
|
|
|
// Split-guard for the deepseek-web executor stream-format extraction.
|
|
// The pure content/citation formatters live in deepseek-web/stream-format.ts
|
|
// (module-private; host imports them into transformSSE/collectSSEContent).
|
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
const EXE = join(HERE, "../../open-sse/executors");
|
|
const HOST = join(EXE, "deepseek-web.ts");
|
|
const LEAF = join(EXE, "deepseek-web/stream-format.ts");
|
|
|
|
test("leaf hosts the formatters and does not import the host", () => {
|
|
const src = readFileSync(LEAF, "utf8");
|
|
for (const sym of ["formatStreamContent", "appendSearchCitations", "isThinkingModel"]) {
|
|
assert.match(src, new RegExp(`export function ${sym}\\b`));
|
|
}
|
|
assert.doesNotMatch(src, /from "\.\.\/deepseek-web\.ts"/);
|
|
});
|
|
|
|
test("host imports the formatters back from the leaf", () => {
|
|
const host = readFileSync(HOST, "utf8");
|
|
assert.match(host, /from "\.\/deepseek-web\/stream-format\.ts"/);
|
|
});
|
|
|
|
test("formatStreamContent + model classifiers behave", async () => {
|
|
const { isThinkingModel, isSearchModel, formatStreamContent } =
|
|
await import("../../open-sse/executors/deepseek-web/stream-format.ts");
|
|
assert.equal(typeof isThinkingModel("deepseek-reasoner"), "boolean");
|
|
assert.equal(typeof isSearchModel("deepseek-search"), "boolean");
|
|
assert.equal(typeof formatStreamContent("hi", "deepseek-chat"), "string");
|
|
});
|