Files
OmniRoute/tests/unit/cli-tools.test.ts
Diego Rodrigues de Sa e Souza 0cd388efb8 Release v3.7.4 (#1730)
* chore(release): v3.7.4 — version bump, openapi and changelog sync

* fix: preserve previous_response_id and conversation_id fields on empty input array (#1729)

* fix: bypass UI validation block for optional API keys and fix string fallback typing (#1721)

* fix(proxy): disable HTTP keep-alive and pipelining in Undici proxy dispatcher to prevent socket hang up

* feat(proxy): implement bulk proxy import via pipe-delimited parser with update-or-create logic

* docs: update changelog for v3.7.4 fixes and proxy features

* test: update responses store expectations for empty input arrays

* feat(pwa): add fullscreen installable PWA with manifest, service worker, and cross-platform app icons. (#1728)

Integrated into release/v3.7.4

* Fix image provider validation and Stability image requests (#1726)

Integrated into release/v3.7.4

* docs: add PR 1726 and PR 1728 to v3.7.4 changelog

* fix(security): replace insecure Math.random with crypto.getRandomValues for fallback UUID generation

* fix(migrations): intercept 007 migration to use IF NOT EXISTS logic on fresh installs

Fixes #1733

* test: fix typescript compilation errors in unit tests

* fix(db): reconcile legacy reasoning cache migration

* chore(release): bump to v3.7.4 — changelog, docs, version sync

* fix(cc-compatible): preserve Claude Code system skeleton (#1740)

Integrated into release/v3.7.4

* docs(changelog): update for PR #1740 merge

* docs(changelog): include workflow updates

* fix(db): reconcile legacy reasoning cache migration (#1734)

Integrated into release/v3.7.4

* Add endpoint tunnel visibility settings (#1743)

Integrated into release/v3.7.4

* Normalize max reasoning effort for Codex routing (#1744)

Integrated into release/v3.7.4

* Fix Claude Code gateway config helper (#1745)

Integrated into release/v3.7.4

* Refresh CLI fingerprint provider profiles (#1746)

Integrated into release/v3.7.4

* Integrated into release/v3.7.4 (PR #1742)

* docs(changelog): update for PRs 1742-1746

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: Yash Ghule <y.ghule77@gmail.com>
Co-authored-by: backryun <bakryun0718@proton.me>
Co-authored-by: dhaern <manker_lol@hotmail.com>
Co-authored-by: Randi <55005611+rdself@users.noreply.github.com>
Co-authored-by: Duncan L <leungd@gmail.com>
2026-04-28 20:46:25 -03:00

117 lines
4.1 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
const { CLI_TOOLS } = await import("../../src/shared/constants/cliTools.ts");
const {
CLI_COMPAT_PROVIDER_IDS,
CLI_COMPAT_OMITTED_PROVIDER_IDS,
CLI_COMPAT_TOGGLE_IDS,
IMPLEMENTED_CLI_FINGERPRINT_PROVIDER_IDS,
normalizeCliCompatProviderId,
} =
await import("../../src/shared/constants/cliCompatProviders.ts");
const { CLI_TOOL_IDS } = await import("../../src/shared/services/cliRuntime.ts");
const { applyFingerprint, isCliCompatEnabled, setCliCompatProviders } = await import(
"../../open-sse/config/cliFingerprints.ts"
);
test("Amp CLI is registered as a guide-based CLI tool with shorthand mapping guidance", () => {
const amp = CLI_TOOLS.amp;
assert.ok(amp);
assert.equal(amp.configType, "guide");
assert.equal(amp.defaultCommand, "amp");
assert.deepEqual(amp.modelAliases, ["g25p", "g25f", "cs45", "g54"]);
const notesText = (amp.notes || [])
.map((note) => note?.text || "")
.join(" ")
.toLowerCase();
assert.match(notesText, /shorthand/);
assert.match(notesText, /g25p/);
assert.match(notesText, /claude-sonnet-4-5-20250929/);
});
test("Amp CLI is discoverable in runtime tooling but excluded from provider fingerprint toggles", () => {
assert.ok(CLI_TOOL_IDS.includes("amp"));
assert.equal(CLI_COMPAT_PROVIDER_IDS.includes("amp"), false);
});
test("Hermes quick-config is registered as a guide-based CLI tool", () => {
const hermes = CLI_TOOLS.hermes;
assert.ok(hermes);
assert.equal(hermes.configType, "guide");
assert.equal(hermes.defaultCommand, "hermes");
assert.ok(Array.isArray(hermes.guideSteps));
assert.ok(String(hermes.codeBlock?.code || "").includes('"baseURL": "{{baseUrl}}"'));
assert.ok(CLI_TOOL_IDS.includes("hermes"));
});
test("CLI fingerprint toggles only expose implemented fingerprints and functional legacy aliases", () => {
const implemented = new Set<string>(IMPLEMENTED_CLI_FINGERPRINT_PROVIDER_IDS);
for (const providerId of CLI_COMPAT_PROVIDER_IDS) {
assert.equal(
implemented.has(providerId),
true,
`${providerId} should have an implemented fingerprint`
);
}
for (const toggleId of CLI_COMPAT_TOGGLE_IDS) {
const providerId = normalizeCliCompatProviderId(toggleId);
assert.equal(
implemented.has(providerId),
true,
`${toggleId} should map to an implemented fingerprint provider`
);
}
for (const providerId of IMPLEMENTED_CLI_FINGERPRINT_PROVIDER_IDS) {
assert.equal(CLI_COMPAT_PROVIDER_IDS.includes(providerId), true);
}
for (const providerId of CLI_COMPAT_OMITTED_PROVIDER_IDS) {
assert.equal(CLI_COMPAT_PROVIDER_IDS.includes(providerId), false);
assert.equal((CLI_COMPAT_TOGGLE_IDS as readonly string[]).includes(providerId), false);
}
assert.equal(CLI_COMPAT_TOGGLE_IDS.includes("copilot"), true);
assert.equal((CLI_COMPAT_TOGGLE_IDS as readonly string[]).includes("github"), false);
});
test("CLI fingerprint preserves Codex executor User-Agent and maps legacy Copilot alias", () => {
const codex = applyFingerprint(
"codex",
{
Authorization: "Bearer token",
"User-Agent": "codex-cli/0.125.0 (Windows 10.0.26100; x64)",
},
{ model: "gpt-5.5", messages: [], stream: true }
);
assert.equal(codex.headers["User-Agent"], "codex-cli/0.125.0 (Windows 10.0.26100; x64)");
assert.deepEqual(Object.keys(JSON.parse(codex.bodyString)), ["model", "messages", "stream"]);
const copilot = applyFingerprint(
"copilot",
{ Authorization: "Bearer token", Accept: "application/json" },
{ model: "gpt-4o", messages: [] }
);
assert.equal(copilot.headers["User-Agent"], "GitHubCopilotChat/0.45.1");
});
test("CLI fingerprint keeps legacy Copilot settings functional without exposing duplicate UI toggles", () => {
assert.equal(normalizeCliCompatProviderId("copilot"), "github");
assert.equal(normalizeCliCompatProviderId("GitHub"), "github");
try {
setCliCompatProviders(["copilot"]);
assert.equal(isCliCompatEnabled("github"), true);
assert.equal(isCliCompatEnabled("copilot"), true);
} finally {
setCliCompatProviders([]);
}
});