mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-13 10:43:43 +03:00
Base-red fix for issue #9985 after the 2026-08-11 merge storm (99 PRs). Real defects fixed: - gateways.ts: close regolo entry (was swallowing naga-ac + chatanywhere from #9421), drop stale duplicate chatanywhere entry (#9594) - conol-web + deepai registry: correct ../shared import depth + deepai executor:default - modelSelectModalHelpers: close isProviderModelHidden (#9011) - driverFactory.test.ts: restore eaten test-closing brace (#9173) - usageTracking: remove duplicate cache_* props - modelCapability{Overrides,ResolutionSnapshot,Capabilities}: max_token -> max_output_tokens (#9199 vs #8908) + test align - videoGeneration: drop duplicate handleFalVideoGeneration import (mediaGeneration/fal canonical, #9982) - responseSanitizer: cast input_tokens_details before .cached_tokens access - EditConnectionModal: missing alibaba code fields, hoist validationPsd, providerPageHelpers Badge variant union - FreeBudgetCard: t() -> labels.noApiKey - peerRouting + cliRuntime: ProcessEnv typing - image-combo.test.ts: type any -> unknown - fal.test.ts: moved to tests/unit/services (collected path) 14 tests green - remove duplicate 143_job_registry.sql (146 canonical), KNOWN_GAPS fix Docs/ratchets (owner-authorized rebaselines, annotated): - CHANGELOG 3.8.50 living section restored + 42 i18n mirrors - MCP-SERVER.md 104->105 tools + i18n - ENVIRONMENT.md/.env.example: ADOBE_FIREFLY_CHROME_HEADED + DEBUG_CLAUDE_NONSTREAM - fabricated-docs allowlist: TELEGRAM proposal env vars - file-size: 5 grown files + proxyFetch 1207->1220 - dead-code 230->248, codeql 2->9 (drift from merged PRs, not this PR) - untrack _tasks symlink; agent-skills-sync --apply (config-codex-cli)
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
/**
|
|
* Build-local capability/context/override resolution snapshot (#9199).
|
|
*
|
|
* Catalog preparation bulk-loads the three capability tables once into a
|
|
* build-local view for pure in-memory resolution. This must not flip models.dev's
|
|
* module-global all-row cache, and ordinary runtime callers keep on-demand DB reads.
|
|
*
|
|
* Override maps are nested by provider then model so provider/model pairs cannot
|
|
* collide via delimiter composition.
|
|
*/
|
|
import { listModelCapabilityOverrides } from "@/lib/db/modelCapabilityOverrides";
|
|
import { listModelContextOverrides } from "@/lib/db/modelContextOverrides";
|
|
import {
|
|
loadAllSyncedCapabilitiesUncached,
|
|
type CapabilitiesByProvider,
|
|
} from "@/lib/modelsDevSync";
|
|
|
|
/** Nested provider → model → numeric override map (collision-free). */
|
|
export type NestedOverrideMap = ReadonlyMap<string, ReadonlyMap<string, number>>;
|
|
|
|
export interface ModelCapabilityResolutionSnapshot {
|
|
readonly synced: CapabilitiesByProvider;
|
|
readonly maxTokenOverrides: NestedOverrideMap;
|
|
readonly contextOverrides: NestedOverrideMap;
|
|
}
|
|
|
|
function setNestedOverride(
|
|
map: Map<string, Map<string, number>>,
|
|
provider: string,
|
|
modelId: string,
|
|
value: number
|
|
): void {
|
|
let byModel = map.get(provider);
|
|
if (!byModel) {
|
|
byModel = new Map();
|
|
map.set(provider, byModel);
|
|
}
|
|
byModel.set(modelId, value);
|
|
}
|
|
|
|
/**
|
|
* Load all three capability tables in one uninterrupted JS turn.
|
|
* Callers must not yield between the bulk reads if they need a coherent view;
|
|
* existing catalog generation guards remain authoritative across later yields.
|
|
*/
|
|
export function createModelCapabilityResolutionSnapshot(): ModelCapabilityResolutionSnapshot {
|
|
const synced = loadAllSyncedCapabilitiesUncached();
|
|
|
|
const maxTokenOverrides = new Map<string, Map<string, number>>();
|
|
for (const entry of listModelCapabilityOverrides()) {
|
|
if (entry.key !== "max_output_tokens") continue;
|
|
setNestedOverride(maxTokenOverrides, entry.provider, entry.modelId, entry.value);
|
|
}
|
|
|
|
const contextOverrides = new Map<string, Map<string, number>>();
|
|
for (const entry of listModelContextOverrides()) {
|
|
setNestedOverride(contextOverrides, entry.provider, entry.modelId, entry.realContext);
|
|
}
|
|
|
|
return {
|
|
synced,
|
|
maxTokenOverrides,
|
|
contextOverrides,
|
|
};
|
|
}
|