mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-18 21:02:50 +03:00
Merged as part of the 39-PR owner batch of 2026-09-11, validated as a unit. Boarded into one consolidated worktree cut from `release/v3.8.51` with the other 38 — zero conflicts between them. - ESLint over every changed file: no errors (the only finding was one suppression entry the batch emptied, pruned on #13243) - `typecheck:core` clean; `check:dashboard-typecheck` OK (206 pre-existing, within baseline); `check:changelog-integrity` OK - complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437 — both under baseline - 256 assertions green: 246 under node:test and 10 under vitest, which is where `tests/unit/**/*.test.tsx` actually runs - `check-file-size`: `chatCore.ts` rebaselined 6144 → 6146 for #13278 and #13276, annotated and landed on #13243 ⚠️ base-red inherited: #12732 — the provider count (356 in the docs vs the 358 the modules define) and `open-sse/utils/stream.ts` at 3115 > frozen 3098 both reproduce on the pure tip with zero contribution from this batch.
44 lines
2.2 KiB
TypeScript
44 lines
2.2 KiB
TypeScript
/**
|
|
* Issue #11912 — a combo step declared with the raw "opencode/<model>" prefix
|
|
* is ambiguous: open-sse/services/model.ts's manual ALIAS_TO_PROVIDER_ID
|
|
* override canonicalizes ANY "opencode/<model>" string to provider
|
|
* "opencode-zen" (the api-key gateway) before dispatch. A round-robin combo
|
|
* mixing declared "opencode/<model>" targets (intended as the free/dynamic
|
|
* no-auth pool) with an explicit "opencode-zen/<model>" target therefore
|
|
* collapses every rotation slot onto the SAME provider + connection identity
|
|
* — every request executes against the single opencode-zen connection
|
|
* instead of rotating across the free pool, and the account eventually
|
|
* 429s.
|
|
*
|
|
* The combo BUILDER already avoids this for freshly-generated model strings
|
|
* by emitting the "oc/" alias for the no-auth provider (#2901,
|
|
* src/lib/combos/builderOptions.ts's rewriteQualifiedModelPrefix). This
|
|
* mirrors that same substitution at combo TARGET RESOLUTION time so a step
|
|
* saved — or hand-typed — with the raw "opencode/" prefix still reaches the
|
|
* true no-auth provider and stays a distinct rotation identity from an
|
|
* explicit "opencode-zen/<model>" target.
|
|
*
|
|
* Deliberately scoped to combo target resolution only — this never touches
|
|
* open-sse/services/model.ts's general alias-resolution path, so a raw
|
|
* client request to "opencode/<model>" outside a combo keeps routing to
|
|
* opencode-zen unchanged (#2798/#3870), and the #7993 sibling credential
|
|
* lookup (tests/unit/opencode-autocombo-search-pair.test.ts) is unaffected.
|
|
*/
|
|
|
|
const AMBIGUOUS_OPENCODE_PREFIX = "opencode";
|
|
const OPENCODE_NOAUTH_ALIAS = "oc";
|
|
|
|
/**
|
|
* Rewrite a combo-declared model string's "opencode/" prefix to the "oc/"
|
|
* no-auth alias. Every other prefix (including "opencode-zen/" and
|
|
* "opencode-go/") passes through untouched.
|
|
*/
|
|
export function resolveComboTargetModelStr(modelStr: string): string {
|
|
if (typeof modelStr !== "string" || modelStr.length === 0) return modelStr;
|
|
const slashIndex = modelStr.indexOf("/");
|
|
if (slashIndex <= 0) return modelStr;
|
|
const prefix = modelStr.slice(0, slashIndex);
|
|
if (prefix !== AMBIGUOUS_OPENCODE_PREFIX) return modelStr;
|
|
return `${OPENCODE_NOAUTH_ALIAS}${modelStr.slice(slashIndex)}`;
|
|
}
|