mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-03 21:42:41 +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.
104 lines
3.4 KiB
TypeScript
104 lines
3.4 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import { equal, deepEqual } from "node:assert/strict";
|
|
|
|
describe("Command classification (#8461)", () => {
|
|
it("classifies read-only commands", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
const r = classifyCommand(["status"]);
|
|
equal(r?.category, "read-only");
|
|
});
|
|
|
|
it("classifies version as read-only", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["version"])?.category, "read-only");
|
|
});
|
|
|
|
it("classifies config list as read-only", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["config", "list"])?.category, "read-only");
|
|
});
|
|
|
|
it("classifies models as read-only", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["models"])?.category, "read-only");
|
|
});
|
|
|
|
it("classifies health as read-only", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["health"])?.category, "read-only");
|
|
});
|
|
|
|
it("classifies config set as mutating", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["config", "set", "key", "value"])?.category, "mutating");
|
|
});
|
|
|
|
it("classifies providers add as mutating", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["providers", "add", "openai"])?.category, "mutating");
|
|
});
|
|
|
|
it("classifies providers delete as destructive", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["providers", "delete", "my-provider"])?.category, "destructive");
|
|
});
|
|
|
|
it("classifies reset as destructive", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["reset"])?.category, "destructive");
|
|
});
|
|
|
|
it("classifies keys show as secret-affecting", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["keys", "show"])?.category, "secret-affecting");
|
|
});
|
|
|
|
it("classifies auth token as secret-affecting", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["auth", "token"])?.category, "secret-affecting");
|
|
});
|
|
|
|
it("returns null for unknown commands (denied by default)", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["nonexistent-command"]), null);
|
|
});
|
|
|
|
it("returns null for gibberish input", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
equal(classifyCommand(["xyzzy", "--foobar"]), null);
|
|
});
|
|
|
|
it("destructive priority over mutating", async () => {
|
|
const { classifyCommand } = await import(
|
|
"@/lib/copilot/commandClassification"
|
|
);
|
|
// "delete" pattern matches destructive first, even though it also matches mutating
|
|
equal(classifyCommand(["providers", "delete", "x"])?.category, "destructive");
|
|
});
|
|
}); |