mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 20:32:20 +03:00
* chore(release): open v3.8.15 development cycle Version bump 3.8.14 -> 3.8.15 (root + electron + open-sse + openapi + lockfiles) and seed the v3.8.15 changelog placeholder (root + 41 i18n mirrors). * fix(catalog): add getTokenLimit fallback for combo targets with unknown context (#3369) Integrated into release/v3.8.15. Fixes applied on the contributor's branch: removed duplicate JSDoc opening in accountFallback.ts and dropped a test asserting unreachable catalog behavior (models with no registry/spec/synced source are filtered before the getTokenLimit fallback at catalog.ts:499). * fix(combo): add 429 to PROVIDER_FAILURE_ERROR_CODES to prevent infinite retry loop (#3366) Integrated into release/v3.8.15. Comment block reconciled on the contributor's branch to remove the contradictory 'intentionally excluded' text that remained from the original code. * fix(auto-combo): include no-auth providers declaratively (#3365) Integrated into release/v3.8.15. Cleanup applied on contributor's branch: removed duplicate migration 095 (already exists from PR #3338), reverted CHANGELOG.md and i18n changelogs to release versions (release process owns these), dropped package version-bump noise from stale fork base. Core feature — declarative no-auth via serviceKinds metadata, declarative VEO as 'video' provider, anonymousFallback flag for opencode-zen/opencode-go — integrated cleanly. * fix(migrations): restore 095_provider_node_custom_headers migration The squash merge of PR #3365 accidentally deleted this migration because the cleanup commit on the contributor's branch included 'git rm' for the file (which was a duplicate on their branch). The migration was merged in v3.8.14 via PR #3338 and must be present in the release branch. Restoring from git history. * fix: update Command Code base URL from /alpha/ to /provider/v1/ (#3372) Integrated into release/v3.8.15. * feat(error-rules): provider-specific error classification with scope (#3370) Integrated into release/v3.8.15. PR has genuine value beyond #3369: (1) getProviderErrorRuleMatch now accepts native Headers objects from fetch(); (2) checkFallbackError also uses the provider rule registry — the real end-to-end wiring in the combo fallback path; (3) S4 end-to-end test proving the wiring fires. Merge commit on contributor branch resolved the add/add conflict by taking the #3370 version throughout. * fix(auto-combo): validate web-session credentials (#3371) Integrated into release/v3.8.15. Core feature: provider-aware web-session credential validation — hasUsableWebSessionCredential() replaces the broad Object.keys check in virtualFactory.ts, ensuring only sessions with the required storageKeys are included in auto-combo. Cleanup: removed duplicate 095 migration, reverted CHANGELOG/i18n, dropped package bump noise. * fix(migrations): restore 095_provider_node_custom_headers (deleted again by #3371 squash) Same issue as after #3365: git rm in the contributor cleanup commit was included in the squash, deleting this migration from release. Permanent fix needed: use 'git checkout origin/release -- <file>' instead of 'git rm' when cleaning up duplicate files in contributor branches. * fix(kiro): probe Windows %APPDATA%\kiro\storage.db in auto-import (#3363) (#3375) Integrated into release/v3.8.15. Test fix applied: kiro-windows-auto-import-3363.test.ts now sets DATA_DIR to a fresh temp dir before importing app modules, ensuring isAuthRequired() sees an empty settings DB (no password → auth not required). This fixed test 4 (synthetic SQLite) which was getting 401 due to settings DB state leakage. * chore(release): finalize v3.8.15 changelog — 2026-06-07 --------- Co-authored-by: Hernan Javier Ardila Sanchez <hjasgr@gmail.com> Co-authored-by: Paijo <14921983+oyi77@users.noreply.github.com> Co-authored-by: Muhammad Nabil Muyassar Rahman <65392758+TapZe@users.noreply.github.com> Co-authored-by: kiro-agent[bot] <245459735+kiro-agent[bot]@users.noreply.github.com>
121 lines
5.0 KiB
TypeScript
121 lines
5.0 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
/**
|
|
* Provider-specific error rules extend the global ERROR_RULES with per-provider
|
|
* signatures: headers, body markers, and a lock scope that tells the fallback
|
|
* engine whether to lock the model, the connection, or the entire provider.
|
|
*
|
|
* Each provider has its own quota model:
|
|
* - Opencode: account-wide quota. A 429 with `x-ratelimit-remaining-requests: 0`
|
|
* means the ORG is out, not just this model.
|
|
* - Minimax: per-model quota. A 429 with `x-model-quota-remaining: <model>=0`
|
|
* means only that specific model is locked.
|
|
* - Anything else: falls back to global ERROR_RULES.
|
|
*/
|
|
|
|
const { classifyError, checkFallbackError } = await import(
|
|
"../../open-sse/services/accountFallback.ts"
|
|
);
|
|
const { RateLimitReason } = await import(
|
|
"../../open-sse/config/constants.ts"
|
|
);
|
|
|
|
test("S1: Opencode 429 with x-ratelimit-remaining-requests=0 → QUOTA_EXHAUSTED, not RATE_LIMIT_EXCEEDED", () => {
|
|
// Opencode uses account-wide quota. The header `x-ratelimit-remaining-requests: 0`
|
|
// signals the whole org is out, so this MUST classify as QUOTA_EXHAUSTED so the
|
|
// engine locks the provider connection (not just the model), forcing fallback to
|
|
// a different provider.
|
|
const reason = classifyError(429, "Rate limit reached", {
|
|
provider: "opencode",
|
|
headers: { "x-ratelimit-remaining-requests": "0" },
|
|
body: { error: { message: "Rate limit reached" } },
|
|
});
|
|
assert.equal(
|
|
reason,
|
|
RateLimitReason.QUOTA_EXHAUSTED,
|
|
"Opencode account-wide quota exhaustion must classify as QUOTA_EXHAUSTED so the connection is locked, not the model"
|
|
);
|
|
});
|
|
|
|
test("S2: Minimax 429 with x-model-quota-remaining header → QUOTA_EXHAUSTED with model scope", async () => {
|
|
// Minimax uses per-model quota. The header `x-model-quota-remaining: haiku=0`
|
|
// signals ONLY that model is locked; other models on the same connection must
|
|
// remain available. classifyError returns the reason; the caller (combo.ts)
|
|
// reads the scope from providerRuleMatch to decide lockModel vs updateProviderConnection.
|
|
const { providerRuleRegistry, getProviderErrorRuleMatch } = await import(
|
|
"../../open-sse/config/providerErrorRules.ts"
|
|
);
|
|
|
|
// The registry must be loaded for minimax
|
|
const minimaxRules = providerRuleRegistry.get("minimax");
|
|
assert.ok(
|
|
minimaxRules && minimaxRules.length > 0,
|
|
"minimax must be registered in the provider rule registry"
|
|
);
|
|
|
|
// The match function returns { reason, scope } for the given provider + status + headers
|
|
const match = getProviderErrorRuleMatch("minimax", 429, {
|
|
"x-model-quota-remaining": "haiku=0",
|
|
});
|
|
assert.ok(match, "minimax must have a rule that matches 429 + per-model quota header");
|
|
assert.equal(match.reason, "quota_exhausted");
|
|
assert.equal(
|
|
match.scope,
|
|
"model",
|
|
"Minimax per-model quota must scope the lock to the model only"
|
|
);
|
|
});
|
|
|
|
test("S3: Regression — provider with no rules falls back to global ERROR_RULES unchanged", () => {
|
|
// A provider not in the registry (e.g. "unknown-vendor") must NOT cause
|
|
// classifyError to crash or return a different result. It must behave
|
|
// identically to the pre-feature implementation: global text/status rules.
|
|
const reason = classifyError(429, "rate limit reached", {
|
|
provider: "unknown-vendor",
|
|
headers: {},
|
|
body: null,
|
|
});
|
|
assert.equal(
|
|
reason,
|
|
RateLimitReason.RATE_LIMIT_EXCEEDED,
|
|
"Unknown providers must fall through to global rules without modification"
|
|
);
|
|
|
|
// And without any context at all (old call sites), still works.
|
|
const reasonNoCtx = classifyError(429, "rate limit reached");
|
|
assert.equal(reasonNoCtx, RateLimitReason.RATE_LIMIT_EXCEEDED);
|
|
});
|
|
|
|
test("S4: End-to-end — checkFallbackError forwards provider+headers to classifyError", () => {
|
|
// The wiring test: when combo.ts calls checkFallbackError with provider=opencode
|
|
// and headers containing x-ratelimit-remaining-requests: 0, the reason must be
|
|
// QUOTA_EXHAUSTED (not RATE_LIMIT_EXCEEDED). This proves the registry is ACTIVE
|
|
// in the production fallback path, not just callable in isolation.
|
|
//
|
|
// Simulate what combo.ts:3849 does — it passes provider, headers, and structuredError.
|
|
// For Opencode with account-wide quota exhausted, the fallback should signal
|
|
// quota_exhausted so the combo router skips remaining targets from the same provider.
|
|
const result = checkFallbackError(
|
|
429,
|
|
"rate limit reached", // generic body that would normally be RATE_LIMIT_EXCEEDED
|
|
0, // backoffLevel
|
|
null, // model
|
|
"opencode", // provider
|
|
{ "x-ratelimit-remaining-requests": "0" }, // headers
|
|
null, // profileOverride
|
|
null // structuredError
|
|
);
|
|
|
|
assert.equal(
|
|
result.reason,
|
|
RateLimitReason.QUOTA_EXHAUSTED,
|
|
"checkFallbackError must forward provider+headers to classifyError so the Opencode quota rule fires"
|
|
);
|
|
assert.equal(
|
|
result.shouldFallback,
|
|
true,
|
|
"quota_exhausted must trigger fallback to the next provider"
|
|
);
|
|
});
|