mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-15 19:52:50 +03:00
* feat(cursor): prefer live synced catalog for listing and Test All When an active synced Cursor catalog exists, list only live models plus injected auto routers (and customs). Keep the static registry as offline fallback. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(cursor): send live-catalog model ids verbatim on AgentRun Skip #7289 effort/reasoning splits when the exact id is in the active synced Cursor catalog so AgentRun does not rewrite flattened live ids into missing bases that return AI Model Not Found. Also wires auto-cost/balance/intelligence to default + optimization for the injected routers. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: yansigit <yansigit@users.noreply.github.com>
133 lines
3.9 KiB
TypeScript
133 lines
3.9 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
buildSyncedModelIdsByCanonicalProvider,
|
|
shouldSuppressStaticModelBySyncedCoverage,
|
|
shouldSuppressStaticModelForExclusiveListing,
|
|
} from "../../src/app/api/v1/models/catalogSyncedCoverage.ts";
|
|
import type { SyncedAvailableModel } from "../../src/lib/db/models/synced.ts";
|
|
|
|
test("static model covered by synced list IS suppressed (current behavior kept)", () => {
|
|
assert.equal(
|
|
shouldSuppressStaticModelBySyncedCoverage({
|
|
providerHasSynced: true,
|
|
staticModelId: "gpt-5.6-luna",
|
|
syncedModelIds: ["gpt-5.6-luna", "moonshotai/Kimi-K3"],
|
|
}),
|
|
true
|
|
);
|
|
});
|
|
|
|
test("static model NOT covered by synced list is preserved (the bug fix)", () => {
|
|
assert.equal(
|
|
shouldSuppressStaticModelBySyncedCoverage({
|
|
providerHasSynced: true,
|
|
staticModelId: "deepseek/deepseek-v4-flash",
|
|
syncedModelIds: ["gpt-5.6-luna", "moonshotai/Kimi-K3"],
|
|
}),
|
|
false
|
|
);
|
|
});
|
|
|
|
test("static model covered by synced list with prefix normalization IS suppressed", () => {
|
|
assert.equal(
|
|
shouldSuppressStaticModelBySyncedCoverage({
|
|
providerHasSynced: true,
|
|
staticModelId: "deepseek/deepseek-v4-flash",
|
|
syncedModelIds: ["deepseek/deepseek-v4-flash", "gpt-5.6-luna"],
|
|
}),
|
|
true
|
|
);
|
|
});
|
|
|
|
test("no synced models -> nothing suppressed", () => {
|
|
assert.equal(
|
|
shouldSuppressStaticModelBySyncedCoverage({
|
|
providerHasSynced: false,
|
|
staticModelId: "deepseek/deepseek-v4-flash",
|
|
syncedModelIds: [],
|
|
}),
|
|
false
|
|
);
|
|
});
|
|
|
|
test("buildSyncedModelIdsByCanonicalProvider groups synced ids by canonical provider", () => {
|
|
const syncedModels: Record<string, SyncedAvailableModel[]> = {
|
|
"command-code": [
|
|
{ id: "gpt-5.6-luna", name: "Luna", source: "imported" },
|
|
{ id: "moonshotai/Kimi-K3", name: "Kimi K3", source: "imported" },
|
|
{ id: "", name: "Invalid", source: "imported" },
|
|
],
|
|
deepseek: [{ id: "deepseek-v4-flash", name: "DeepSeek V4 Flash", source: "imported" }],
|
|
};
|
|
const byCanonical = buildSyncedModelIdsByCanonicalProvider(
|
|
syncedModels,
|
|
(aliasOrId, fallback) => (aliasOrId === "cmd" ? "command-code" : fallback || aliasOrId),
|
|
{},
|
|
{ "command-code": "cmd" }
|
|
);
|
|
const cmd = byCanonical.get("command-code");
|
|
assert.ok(cmd);
|
|
assert.ok(cmd.has("gpt-5.6-luna"));
|
|
assert.ok(cmd.has("moonshotai/Kimi-K3"));
|
|
assert.equal(cmd.has(""), false);
|
|
const ds = byCanonical.get("deepseek");
|
|
assert.ok(ds);
|
|
assert.ok(ds.has("deepseek-v4-flash"));
|
|
});
|
|
|
|
test("exclusive listing: any static row suppressed when provider has synced catalog", () => {
|
|
assert.equal(
|
|
shouldSuppressStaticModelForExclusiveListing({
|
|
exclusiveListing: true,
|
|
providerHasSynced: true,
|
|
staticModelId: "claude-4.6-sonnet-high",
|
|
syncedModelIds: ["claude-4.6-sonnet", "composer-2.5"],
|
|
}),
|
|
true
|
|
);
|
|
assert.equal(
|
|
shouldSuppressStaticModelForExclusiveListing({
|
|
exclusiveListing: true,
|
|
providerHasSynced: true,
|
|
staticModelId: "composer-2.5",
|
|
syncedModelIds: ["claude-4.6-sonnet", "composer-2.5"],
|
|
}),
|
|
true
|
|
);
|
|
});
|
|
|
|
test("exclusive listing: does not suppress when synced is empty", () => {
|
|
assert.equal(
|
|
shouldSuppressStaticModelForExclusiveListing({
|
|
exclusiveListing: true,
|
|
providerHasSynced: false,
|
|
staticModelId: "claude-4.6-sonnet-high",
|
|
syncedModelIds: [],
|
|
}),
|
|
false
|
|
);
|
|
});
|
|
|
|
test("exclusive listing: non-exclusive providers keep coverage behavior", () => {
|
|
assert.equal(
|
|
shouldSuppressStaticModelForExclusiveListing({
|
|
exclusiveListing: false,
|
|
providerHasSynced: true,
|
|
staticModelId: "deepseek/deepseek-v4-flash",
|
|
syncedModelIds: ["gpt-5.6-luna"],
|
|
}),
|
|
false
|
|
);
|
|
assert.equal(
|
|
shouldSuppressStaticModelForExclusiveListing({
|
|
exclusiveListing: false,
|
|
providerHasSynced: true,
|
|
staticModelId: "gpt-5.6-luna",
|
|
syncedModelIds: ["gpt-5.6-luna"],
|
|
}),
|
|
true
|
|
);
|
|
});
|