Files
OmniRoute/tests/unit/codex-tools-split.test.ts
Ankit e61b75f007 fix(config): externalize ws for copilot-m365-web executor (#6098, closes #6062)
Externalize ws / bufferutil / utf-8-validate in serverExternalPackages so the copilot-m365-web WebSocket masking path works at runtime (bundling ws → TypeError: b.mask is not a function → 80s chat timeout). Regression guard in next-config.test.ts.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
2026-07-03 16:36:35 -03:00

30 lines
1.4 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 codex executor tool-normalization extraction.
// The hosted-tool passthrough + free-plan gating live in codex/tools.ts (self-contained,
// console.debug only). codex.ts re-exports them so external importers keep the path.
const HERE = dirname(fileURLToPath(import.meta.url));
const EXE = join(HERE, "../../open-sse/executors");
test("leaf hosts the tool normalizers and does not import the host", () => {
const src = readFileSync(join(EXE, "codex/tools.ts"), "utf8");
assert.match(src, /export function normalizeCodexTools\b/);
assert.match(src, /export function isCodexFreePlan\b/);
assert.doesNotMatch(src, /from "\.\.\/codex\.ts"/);
});
test("codex.ts re-exports them for external importers", () => {
const host = readFileSync(join(EXE, "codex.ts"), "utf8");
assert.match(host, /export \{[^}]*normalizeCodexTools[^}]*\} from "\.\/codex\/tools\.ts"/s);
});
test("both import paths resolve to the same function", async () => {
const viaHost = (await import("../../open-sse/executors/codex.ts")).normalizeCodexTools;
const viaLeaf = (await import("../../open-sse/executors/codex/tools.ts")).normalizeCodexTools;
assert.equal(viaHost, viaLeaf);
});