mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 15:22:12 +03:00
* fix(models): preserve static registry models not covered by synced discovery * feat(models): add functional gateway mirror synthesizer * feat(models): add functional gateway mirror gate predicate * feat(models): add functional gateway mirror DB gate * feat(models): wire functional gateway mirrors into /v1/models * refactor(models): extract synced-coverage helper to pure leaf (file-size gate) * fix(db): re-export functional gateway mirrors gate from localDb (db-rules) * fix(i18n): translate functional gateway mirror flag for Vietnamese (locale completeness) --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
buildFunctionalGatewayPredicate,
|
|
type FunctionalGatewayGateSnapshot,
|
|
} from "../../src/app/api/v1/models/functionalGatewayPredicate.ts";
|
|
|
|
test("provider on makes its gateway-owned models eligible", () => {
|
|
const snapshot: FunctionalGatewayGateSnapshot = {
|
|
global: false,
|
|
providers: new Map([["agentrouter", "on"]]),
|
|
models: new Map(),
|
|
};
|
|
const pred = buildFunctionalGatewayPredicate(snapshot);
|
|
assert.equal(
|
|
pred({ id: "agentrouter/deepseek/deepseek-v4-flash", owned_by: "agentrouter" }),
|
|
true
|
|
);
|
|
assert.equal(pred({ id: "deepseek/deepseek-v4-flash", owned_by: "deepseek" }), false);
|
|
});
|
|
|
|
test("model off wins over provider on", () => {
|
|
const snapshot: FunctionalGatewayGateSnapshot = {
|
|
global: false,
|
|
providers: new Map([["agentrouter", "on"]]),
|
|
models: new Map([["agentrouter/deepseek/deepseek-v4-flash", "off"]]),
|
|
};
|
|
const pred = buildFunctionalGatewayPredicate(snapshot);
|
|
assert.equal(
|
|
pred({ id: "agentrouter/deepseek/deepseek-v4-flash", owned_by: "agentrouter" }),
|
|
false
|
|
);
|
|
});
|
|
|
|
test("global on makes everything eligible, model off still wins", () => {
|
|
const snapshot: FunctionalGatewayGateSnapshot = {
|
|
global: true,
|
|
providers: new Map(),
|
|
models: new Map([["agentrouter/deepseek/deepseek-v4-flash", "off"]]),
|
|
};
|
|
const pred = buildFunctionalGatewayPredicate(snapshot);
|
|
assert.equal(pred({ id: "agentrouter/gpt-5.6-luna", owned_by: "agentrouter" }), true);
|
|
assert.equal(
|
|
pred({ id: "agentrouter/deepseek/deepseek-v4-flash", owned_by: "agentrouter" }),
|
|
false
|
|
);
|
|
});
|