mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-14 02:42: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.
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
|
|
);
|
|
});
|