mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-01 12:22:24 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
64 lines
2.7 KiB
JavaScript
64 lines
2.7 KiB
JavaScript
// Regression test for #7913: `omniroute setup opencode --auth` spawns the
|
|
// `opencode.cmd` shim on win32. Since Node's CVE-2024-27980 hardening,
|
|
// spawning a `.cmd`/`.bat` shim with `shell:false` throws EINVAL — the same
|
|
// class already fixed for codex (bin/cli/commands/launch-codex.mjs,
|
|
// crediting #6263) and qodercli/Auggie (#6263/#6304). This callsite was
|
|
// missed; `resolveOpenCodeAuthSpawn` must use `shell: isWin`.
|
|
//
|
|
// Tested through the pure `resolveOpenCodeAuthSpawn(providerId, platform)`
|
|
// resolver (no child_process mocking, no process.platform mutation — both of
|
|
// which required an unavailable --experimental-test-module-mocks flag in CI).
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
resolveOpenCodeAuthSpawn,
|
|
resolveOpenCodeAuthProviderId,
|
|
} from "../../bin/cli/commands/setup-open-code.mjs";
|
|
|
|
test("resolveOpenCodeAuthSpawn: win32 spawns opencode.cmd with shell:true (repro #7913)", () => {
|
|
const spawn = resolveOpenCodeAuthSpawn("omniroute", "win32");
|
|
assert.equal(spawn.command, "opencode.cmd");
|
|
assert.equal(
|
|
spawn.options.shell,
|
|
true,
|
|
`expected shell:true on win32 (the EINVAL fix), got shell:${spawn.options.shell}`
|
|
);
|
|
assert.deepEqual(spawn.args, ["auth", "login", "--provider", "opencode-omniroute"]);
|
|
});
|
|
|
|
test("resolveOpenCodeAuthSpawn: linux/darwin spawn bare opencode with shell:false (no regression)", () => {
|
|
for (const platform of ["linux", "darwin"]) {
|
|
const spawn = resolveOpenCodeAuthSpawn("omniroute", platform);
|
|
assert.equal(spawn.command, "opencode", `command on ${platform}`);
|
|
assert.equal(
|
|
spawn.options.shell,
|
|
false,
|
|
`expected shell:false on ${platform}, got shell:${spawn.options.shell}`
|
|
);
|
|
}
|
|
});
|
|
|
|
test("resolveOpenCodeAuthSpawn: prefixes provider id for auth login (#8830)", () => {
|
|
const spawn = resolveOpenCodeAuthSpawn("anthropic", "linux");
|
|
assert.deepEqual(spawn.args, ["auth", "login", "--provider", "opencode-anthropic"]);
|
|
});
|
|
|
|
test("resolveOpenCodeAuthProviderId: adds opencode- prefix when absent (#8830)", () => {
|
|
assert.equal(resolveOpenCodeAuthProviderId("omniroute"), "opencode-omniroute");
|
|
assert.equal(resolveOpenCodeAuthProviderId("omniroute-preprod"), "opencode-omniroute-preprod");
|
|
assert.equal(resolveOpenCodeAuthProviderId("anthropic"), "opencode-anthropic");
|
|
});
|
|
|
|
test("resolveOpenCodeAuthProviderId: idempotent — passes through already-prefixed ids (#8830)", () => {
|
|
assert.equal(resolveOpenCodeAuthProviderId("opencode-omniroute"), "opencode-omniroute");
|
|
assert.equal(
|
|
resolveOpenCodeAuthProviderId("opencode-omniroute-preprod"),
|
|
"opencode-omniroute-preprod"
|
|
);
|
|
assert.equal(
|
|
resolveOpenCodeAuthProviderId("opencode-anthropic"),
|
|
"opencode-anthropic"
|
|
);
|
|
});
|