mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-14 02:42:24 +03:00
Rebased onto the current release/v3.8.51 tip as part of a combined provider-retirement/provenance merge batch (Designer Web, Felo Web, Runtime, GPL-derived removal all landed together already). Conflicts resolved: - `src/shared/constants/providerRetirement.ts`: add/add conflict — combined `felo-web`/`felo` (already-merged) with `qwen-web`/`qw` into one `RUNTIME_RETIRED_PROVIDER_IDS` set, kept both `assertRuntimeProviderAvailable`/`assertRuntimeModelProviderAvailable` helpers. - `open-sse/config/providers/registry/minimax/web/index.ts`: modify/delete — kept deleted (file is hailuo-web's registry entry, already retired by #11691; this PR's own change to it was just a comment reword on a since-removed target). - `open-sse/executors/index.ts`, `executorProxy.ts`, `virtualFactory.ts`, `autoStrategy.ts`, `model.ts`, `chat.ts`, `chatHelpers.ts`, `auth.ts`, `src/lib/db/providers.ts`, `reservedProviderPrefixes.ts`: combined the Designer + Runtime (Felo + Qwen) retirement guard calls at each shared chokepoint — compute-once-then-OR pattern, consistent with the prior Designer+Felo combination. - `src/shared/constants/providers/web-cookie.ts`, `tests/snapshots/provider/translate-path.json`, `tests/snapshots/executors/executor-map.json`: both sides had inserted a different retired provider (qwen-web vs. already-retired raycast/hailuo-web) at the same dict position — resolved by dropping both. `executor-map.json`'s `keyCount` recomputed to 135 (matches actual merged `entries`). - `tests/unit/chatcore-executor-proxy.test.ts`, `tests/unit/provider-node-reserved-prefix.test.ts`: split into independent Felo/Qwen test blocks (established pattern for coexisting retirement-mechanism tests); recomputed `RESERVED_PREFIX_COUNT` to 398 (Designer+Felo+Qwen tombstones on top of the post-#11691 REGISTRY, verified via direct module evaluation, not hand-derived). - `config/quality/test-masking-allowlist.json`: additive merge of Qwen's `_deletedWithReplacement` entries alongside Designer's. - `README.md` + all `docs/i18n/*/README.md` mirrors, `docs/getting-started/FREE-TIERS-GUIDE.md`, `docs/reference/FREE_TIERS.md`, `docs/diagrams/free-tier-budget.svg`, `docs/screenshots/free-tier-budget-card.svg`: recomputed the free-tier catalog counts (447 entries / 440 active / 7 discontinued) from the actual merged `freeModelCatalog.data.ts`, regenerated the budget-card SVG via its real generator (`scripts/research/gen-budget-card-svg.mjs`), and dropped the retired Qwen quick-start row / QWEN MODELS section from every i18n README (identical unlocalized block across all 34 locales). - Also fixed a duplicate-import merge artifact in `src/lib/db/providers.ts` (`isRuntimeRetiredProviderId` imported twice) caught by `typecheck:core`, and rebaselined `file-size-baseline.json` for the combined retirement-guard growth (`virtualFactory.ts` +3, with justification). Focused suite green (345/345 across executor-proxy, reserved-prefix, migration-167, qwen-web-retirement, virtual-auto-combo, web-cookie/session, executor-map-golden and siblings), plus `typecheck:core` and `check-file-size`/`check-changelog-integrity` clean. Thanks for the provenance-hold retirement work — appreciated.
94 lines
4.1 KiB
TypeScript
94 lines
4.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
FREE_MODEL_BUDGETS,
|
|
FREE_TIER_BOOSTS,
|
|
computeFreeModelTotals,
|
|
} from "../../open-sse/config/freeModelCatalog.ts";
|
|
|
|
const FREE_TYPES = [
|
|
"recurring-daily",
|
|
"recurring-monthly",
|
|
"recurring-credit",
|
|
"recurring-uncapped",
|
|
"one-time-initial",
|
|
"keyless",
|
|
"discontinued",
|
|
];
|
|
|
|
test("FREE_MODEL_BUDGETS is a non-empty array of well-formed per-model records", () => {
|
|
assert.ok(Array.isArray(FREE_MODEL_BUDGETS) && FREE_MODEL_BUDGETS.length >= 400);
|
|
for (const m of FREE_MODEL_BUDGETS) {
|
|
assert.equal(typeof m.provider, "string");
|
|
assert.equal(typeof m.modelId, "string");
|
|
assert.ok(Number.isInteger(m.monthlyTokens) && m.monthlyTokens >= 0);
|
|
assert.ok(Number.isInteger(m.creditTokens) && m.creditTokens >= 0);
|
|
assert.ok(FREE_TYPES.includes(m.freeType), `bad freeType ${m.freeType}`);
|
|
}
|
|
});
|
|
|
|
test("computeFreeModelTotals dedupes shared pools AND per-account credits, tiers honestly", () => {
|
|
const t = computeFreeModelTotals();
|
|
// pool-deduped steady recurring should be in a defensible band (NOT the inflated per-model sum)
|
|
assert.ok(
|
|
t.steadyRecurringTokens >= 1_000_000_000 && t.steadyRecurringTokens <= 3_000_000_000,
|
|
`steady=${t.steadyRecurringTokens}`
|
|
);
|
|
assert.ok(t.steadyWithRecurringCreditsTokens >= t.steadyRecurringTokens);
|
|
assert.ok(t.firstMonthRealisticTokens >= t.steadyWithRecurringCreditsTokens);
|
|
// one-time credits must be pool-deduped: a multi-model provider's signup credit counts once.
|
|
const naiveOneTime = FREE_MODEL_BUDGETS.filter((m) => m.freeType === "one-time-initial").reduce(
|
|
(s, m) => s + m.creditTokens,
|
|
0
|
|
);
|
|
assert.ok(
|
|
t.firstMonthRealisticTokens - t.steadyWithRecurringCreditsTokens < naiveOneTime,
|
|
"one-time credits not deduped"
|
|
);
|
|
assert.equal(t.modelCount, FREE_MODEL_BUDGETS.length);
|
|
assert.equal(typeof t.headline, "string");
|
|
});
|
|
|
|
test("excludeTosAvoid drops avoid-flagged models from the totals", () => {
|
|
const all = computeFreeModelTotals();
|
|
const clean = computeFreeModelTotals({ excludeTosAvoid: true });
|
|
assert.ok(clean.modelCount < all.modelCount);
|
|
assert.ok(clean.steadyRecurringTokens <= all.steadyRecurringTokens);
|
|
});
|
|
|
|
test("recurring-uncapped models are surfaced but NEVER summed into the steady headline", () => {
|
|
const t = computeFreeModelTotals();
|
|
// every uncapped record must carry monthlyTokens 0 (un-quantifiable, not counted)
|
|
for (const m of FREE_MODEL_BUDGETS) {
|
|
if (m.freeType === "recurring-uncapped")
|
|
assert.equal(m.monthlyTokens, 0, `${m.provider}/${m.modelId} uncapped but counted`);
|
|
}
|
|
// uncappedProviders is the de-duped provider list and is non-empty (siliconflow, glm-cn, kilo…)
|
|
assert.ok(Array.isArray(t.uncappedProviders) && t.uncappedProviders.length >= 3);
|
|
for (const p of ["siliconflow", "glm-cn", "kilo-gateway"]) {
|
|
assert.ok(t.uncappedProviders.includes(p), `expected ${p} among uncapped providers`);
|
|
}
|
|
});
|
|
|
|
test("deposit-unlock boost is reported separately, not folded into steady", () => {
|
|
const t = computeFreeModelTotals();
|
|
// OpenRouter $10 -> 1000 RPD boost is live (openrouter-free pool present)
|
|
assert.ok(t.boostMonthlyTokens >= 24_000_000, `boost=${t.boostMonthlyTokens}`);
|
|
assert.equal(FREE_TIER_BOOSTS["openrouter-free"].provider, "openrouter");
|
|
// the boost must NOT already be inside the steady number
|
|
assert.ok(t.boostMonthlyTokens < t.steadyRecurringTokens);
|
|
});
|
|
|
|
test("2026-06-17 refresh: discontinued providers dropped, new free providers added", () => {
|
|
const providers = new Set(FREE_MODEL_BUDGETS.map((m) => m.provider));
|
|
// dead in 2026 — must be gone from the budget catalog
|
|
for (const dead of ["chutes", "phind", "kluster", "gitlawb", "aimlapi", "theoldllm"]) {
|
|
assert.ok(!providers.has(dead), `${dead} should be removed (discontinued)`);
|
|
}
|
|
assert.equal(providers.has("qwen-web"), false, "retired qwen-web must stay out of routing");
|
|
// discovered in the refresh — must be present
|
|
for (const fresh of ["kilo-gateway", "opencode-zen", "glm-cn"]) {
|
|
assert.ok(providers.has(fresh), `${fresh} should be added`);
|
|
}
|
|
});
|