mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-07 15:52:52 +03:00
## New Features - Combo Builder v2 wizard UI (multi-stage: Basics → Steps → Strategy → Review) - Combo Step Architecture Schema v2 (ComboModelStep, ComboRefStep, pinned accounts) - Composite Tiers system for tiered model routing with fallback chains - Model Capabilities Registry (unified resolver merging specs + registry + synced data) - Observability module (buildHealthPayload, buildTelemetryPayload, buildSessionsSummary) - Session & Quota Monitor panels on Health dashboard - Combo Health per-target analytics via resolveNestedComboTargets() - Combo Builder Options API (GET /api/combos/builder/options) ## Performance - Middleware lazy loading (apiAuth, db/settings, modelSyncScheduler) - E2E auth bypass mode (NEXT_PUBLIC_OMNIROUTE_E2E_MODE) ## Bug Fixes - P2C credential selection with quota headroom awareness - Fixed-account combo steps bypass model cooldowns/circuit breakers - Combo metrics per-target tracking (byTarget with executionKey) - Call logs schema expansion (7 new columns + composite index) - Quota monitor lifecycle enrichment (status, snapshots, summary) - Codex quota fetcher hardening ## Maintenance - DB migration 021 (combo_call_log_targets) - Combo CRUD normalization on read - Playwright config + build script improvements - OpenAPI spec version sync to 3.6.4 ## Tests - 16 new test suites + 12 existing test updates - 86 files changed, +8318 -1378 lines
187 lines
5.3 KiB
JavaScript
187 lines
5.3 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const builderDraft = await import("../../src/lib/combos/builderDraft.ts");
|
|
|
|
test("parseQualifiedModel keeps provider prefix and the full tail model id", () => {
|
|
assert.deepEqual(builderDraft.parseQualifiedModel("openrouter/openai/gpt-5.4"), {
|
|
providerId: "openrouter",
|
|
modelId: "openai/gpt-5.4",
|
|
});
|
|
assert.deepEqual(builderDraft.parseQualifiedModel("codex/gpt-5.3-codex"), {
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
});
|
|
assert.equal(builderDraft.parseQualifiedModel("combo-only"), null);
|
|
});
|
|
|
|
test("buildPrecisionComboModelStep preserves provider/model/account triple", () => {
|
|
assert.deepEqual(
|
|
builderDraft.buildPrecisionComboModelStep({
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
connectionId: "conn-codex-a",
|
|
connectionLabel: "Codex A",
|
|
weight: 35,
|
|
}),
|
|
{
|
|
kind: "model",
|
|
providerId: "codex",
|
|
model: "codex/gpt-5.3-codex",
|
|
connectionId: "conn-codex-a",
|
|
label: "Codex A",
|
|
weight: 35,
|
|
}
|
|
);
|
|
});
|
|
|
|
test("hasExactModelStepDuplicate blocks only exact provider/model/connection repeats", () => {
|
|
const existing = [
|
|
builderDraft.buildPrecisionComboModelStep({
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
connectionId: "conn-a",
|
|
}),
|
|
builderDraft.buildPrecisionComboModelStep({
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
connectionId: "conn-b",
|
|
}),
|
|
builderDraft.buildPrecisionComboModelStep({
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
}),
|
|
{ kind: "combo-ref", comboName: "fallback", weight: 0 },
|
|
];
|
|
|
|
assert.equal(
|
|
builderDraft.hasExactModelStepDuplicate(
|
|
existing,
|
|
builderDraft.buildPrecisionComboModelStep({
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
connectionId: "conn-a",
|
|
})
|
|
),
|
|
true
|
|
);
|
|
assert.equal(
|
|
builderDraft.hasExactModelStepDuplicate(
|
|
existing,
|
|
builderDraft.buildPrecisionComboModelStep({
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
connectionId: "conn-c",
|
|
})
|
|
),
|
|
false
|
|
);
|
|
assert.equal(
|
|
builderDraft.hasExactModelStepDuplicate(
|
|
existing,
|
|
builderDraft.buildPrecisionComboModelStep({
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
})
|
|
),
|
|
true
|
|
);
|
|
});
|
|
|
|
test("findNextSuggestedConnectionId advances to the next unused connection for the same model", () => {
|
|
const existing = [
|
|
builderDraft.buildPrecisionComboModelStep({
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
connectionId: "conn-a",
|
|
}),
|
|
builderDraft.buildPrecisionComboModelStep({
|
|
providerId: "codex",
|
|
modelId: "gpt-5.3-codex",
|
|
connectionId: "conn-b",
|
|
}),
|
|
];
|
|
|
|
assert.equal(
|
|
builderDraft.findNextSuggestedConnectionId(existing, "codex", "gpt-5.3-codex", [
|
|
{ id: "conn-a" },
|
|
{ id: "conn-b" },
|
|
{ id: "conn-c" },
|
|
]),
|
|
"conn-c"
|
|
);
|
|
assert.equal(
|
|
builderDraft.findNextSuggestedConnectionId(existing, "codex", "gpt-5.3-codex", [
|
|
{ id: "conn-a" },
|
|
{ id: "conn-b" },
|
|
]),
|
|
builderDraft.COMBO_BUILDER_AUTO_CONNECTION
|
|
);
|
|
});
|
|
|
|
test("combo builder stage helpers expose completion state and linear navigation", () => {
|
|
assert.deepEqual(
|
|
builderDraft.getComboBuilderStageChecks({
|
|
name: "codex-stack",
|
|
nameError: "",
|
|
modelsCount: 2,
|
|
hasInvalidWeightedTotal: false,
|
|
hasCostOptimizedWithoutPricing: false,
|
|
}),
|
|
{
|
|
basics: true,
|
|
steps: true,
|
|
strategy: true,
|
|
review: false,
|
|
}
|
|
);
|
|
|
|
assert.deepEqual(
|
|
builderDraft.getComboBuilderStageChecks({
|
|
name: "",
|
|
nameError: "Required",
|
|
modelsCount: 0,
|
|
hasInvalidWeightedTotal: true,
|
|
hasCostOptimizedWithoutPricing: false,
|
|
}),
|
|
{
|
|
basics: false,
|
|
steps: false,
|
|
strategy: false,
|
|
review: false,
|
|
}
|
|
);
|
|
|
|
assert.equal(builderDraft.getNextComboBuilderStage("basics"), "steps");
|
|
assert.equal(builderDraft.getNextComboBuilderStage("steps"), "strategy");
|
|
assert.equal(builderDraft.getNextComboBuilderStage("strategy"), "review");
|
|
assert.equal(builderDraft.getNextComboBuilderStage("review"), "review");
|
|
assert.equal(builderDraft.getPreviousComboBuilderStage("review"), "strategy");
|
|
assert.equal(builderDraft.getPreviousComboBuilderStage("basics"), "basics");
|
|
|
|
const checks = builderDraft.getComboBuilderStageChecks({
|
|
name: "codex-stack",
|
|
nameError: "",
|
|
modelsCount: 1,
|
|
hasInvalidWeightedTotal: true,
|
|
hasCostOptimizedWithoutPricing: false,
|
|
});
|
|
|
|
assert.equal(builderDraft.canAccessComboBuilderStage("basics", checks), true);
|
|
assert.equal(builderDraft.canAccessComboBuilderStage("steps", checks), true);
|
|
assert.equal(builderDraft.canAccessComboBuilderStage("strategy", checks), true);
|
|
assert.equal(builderDraft.canAccessComboBuilderStage("review", checks), true);
|
|
|
|
const lockedChecks = builderDraft.getComboBuilderStageChecks({
|
|
name: "",
|
|
nameError: "Required",
|
|
modelsCount: 0,
|
|
hasInvalidWeightedTotal: false,
|
|
hasCostOptimizedWithoutPricing: false,
|
|
});
|
|
|
|
assert.equal(builderDraft.canAccessComboBuilderStage("steps", lockedChecks), false);
|
|
assert.equal(builderDraft.canAccessComboBuilderStage("strategy", lockedChecks), false);
|
|
assert.equal(builderDraft.canAccessComboBuilderStage("review", lockedChecks), false);
|
|
});
|