mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-16 11:52:26 +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.
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
/**
|
|
* Provider ids that must remain unavailable even when stale rows are restored
|
|
* after migrations have already run. Keep canonical ids and legacy aliases
|
|
* together so neither executor dispatch nor credential selection can fall back.
|
|
*/
|
|
export const RUNTIME_RETIRED_PROVIDER_IDS: ReadonlySet<string> = new Set([
|
|
"felo-web",
|
|
"felo",
|
|
"qwen-web",
|
|
"qw",
|
|
]);
|
|
export const RUNTIME_PROVIDER_RETIRED_ERROR_CODE = "PROVIDER_RETIRED";
|
|
export const RUNTIME_PROVIDER_RETIRED_MESSAGE = "Provider is retired and unavailable.";
|
|
|
|
type RuntimeProviderRetirementError = Error & {
|
|
code: typeof RUNTIME_PROVIDER_RETIRED_ERROR_CODE;
|
|
status: 410;
|
|
};
|
|
|
|
export function isRuntimeRetiredProviderId(providerId: unknown): providerId is string {
|
|
return (
|
|
typeof providerId === "string" &&
|
|
RUNTIME_RETIRED_PROVIDER_IDS.has(providerId.trim().toLowerCase())
|
|
);
|
|
}
|
|
|
|
export function assertRuntimeProviderAvailable(providerId: unknown): void {
|
|
if (!isRuntimeRetiredProviderId(providerId)) return;
|
|
|
|
const error = new Error(RUNTIME_PROVIDER_RETIRED_MESSAGE) as RuntimeProviderRetirementError;
|
|
error.code = RUNTIME_PROVIDER_RETIRED_ERROR_CODE;
|
|
error.status = 410;
|
|
throw error;
|
|
}
|
|
|
|
export function assertRuntimeModelProviderAvailable(modelId: unknown): void {
|
|
if (typeof modelId !== "string") return;
|
|
const slashIndex = modelId.indexOf("/");
|
|
if (slashIndex <= 0) return;
|
|
assertRuntimeProviderAvailable(modelId.slice(0, slashIndex));
|
|
}
|
|
|
|
export function isRuntimeProviderRetirementError(
|
|
error: unknown
|
|
): error is RuntimeProviderRetirementError {
|
|
if (!(error instanceof Error)) return false;
|
|
const typed = error as Error & { code?: unknown; status?: unknown };
|
|
return typed.code === RUNTIME_PROVIDER_RETIRED_ERROR_CODE && typed.status === 410;
|
|
}
|