mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-19 21:52:21 +03:00
fix(types): clears 6 pre-existing release/v3.8.50 typecheck errors
typecheck:core is its own blocking CI job (quality.yml), separate from Docs Gates/Merge integrity. Confirmed pre-existing and unrelated to any current work by branching this worktree directly from upstream/release/v3.8.50 with no other merges applied. - accountSemaphore.ts: isBypassed() already excludes null/<=0 maxConcurrency before ensureGate() is called, but a boolean- returning helper isn't a type predicate TS can narrow through. Added a targeted `as number` at the one call site, with a comment explaining why it's safe. - combo/comboStructure.ts: two module-scope `const HARD_COMPAT_REASONS` declarations with different values — a genuine "can't redeclare" compile error, not a narrowing gap. The first (4-item set including "output_tokens") had zero usages between its own declaration and the second; the second (3-item set, matching the CompatFilterOptions doc comment exactly) is what hasHardCapabilityFailure/ describeCapabilityFilterExhaustion/the third call site all actually use. Removed the dead first declaration. - combo/comboStructure.ts + combo/fusionPanel.ts: both accessed `.prompt`/`.model` on a `ComboModelStep | ComboProviderWildcardStep` union after only excluding `combo-ref`, but `ComboProviderWildcardStep` has neither field — a real latent bug (fusionPanel would have pushed `undefined` into a fusion panel for a wildcard step). Narrowed to `step.kind === "model"` in comboStructure, and switched to the already-existing `getComboModelString()` helper in fusionPanel (which correctly resolves to null for unsupported step kinds, mirroring how combo-ref is already skipped there). Verified directly via a standalone script exercising both branches (wildcard vs. model step). - combo/quotaStrategies.ts: imported `preferAntigravityConnectionsWithStoredProject` from a module that never existed (`../antigravityProjectPersistence.ts`, distinct from the real `antigravityProjectPersist.ts`) — the function itself was referenced nowhere else in the codebase. Wrote the missing implementation: prefers Antigravity connections with a discovered `projectId` for reset-aware routing, failing open to the full list when none have one yet (per the file's own "Exclude... from reset-aware pool" changelog note, softened to a preference — strict exclusion would empty the pool entirely for a fleet of freshly-added accounts). Verified directly via a standalone script. - compression/engines/ccr/index.ts: `enforceGlobalBudget(owner, bytes)` was called with only `bytes` at one of its two call sites, missing the `owner` argument the other call site (and the function's own doc comment on preferring the calling principal's LRU eviction) already uses correctly. Added the missing `entry.principalId` argument. - firecrawlQuotaFetcher.ts: `fetchFirecrawlQuota` was annotated to return `Promise<QuotaInfo | null>` but every return path constructs a `FirecrawlQuota` (QuotaInfo extended with remainingCredits/planCredits/ extraCreditsInferred/overPlan) — the type the file already defines and the type `parseFirecrawlCreditUsage` already correctly returns. Widened the annotation to match; `FirecrawlQuota extends QuotaInfo` so this stays compatible with the `QuotaFetcher` contract. npm run typecheck:core and npm run check:dashboard-typecheck both pass cleanly. A subset of DB-backed tests in this area also fail, but 100% attributably to an already-tracked, unrelated migration version collision (134 -> [ccr_blocks, proxy_logs_egress_ip], see _tasks/features-v3.8.4/9route/POST-MERGE-AUDIT.md) — confirmed by every failure's stack trace bottoming out at that exact error, not at anything touched here.
This commit is contained in:
@@ -200,7 +200,9 @@ export function acquire(
|
||||
return Promise.reject(makeAbortError(signal));
|
||||
}
|
||||
|
||||
const gate = ensureGate(semaphoreKey, maxConcurrency);
|
||||
// isBypassed() above already excluded null/<=0 — ensureGate requires a plain
|
||||
// number, but a boolean-returning helper isn't a type predicate TS can narrow on.
|
||||
const gate = ensureGate(semaphoreKey, maxConcurrency as number);
|
||||
clearCleanupTimer(gate);
|
||||
|
||||
if (gate.running < gate.maxConcurrency && !isBlocked(gate)) {
|
||||
|
||||
35
open-sse/services/antigravityProjectPersistence.ts
Normal file
35
open-sse/services/antigravityProjectPersistence.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Prefer Antigravity connections with a discovered/stored `projectId` for
|
||||
* reset-aware quota routing (#7719 follow-up).
|
||||
*
|
||||
* Antigravity's Code Assist API is scoped per-project — a connection whose
|
||||
* `projectId` was never discovered (no `loadCodeAssist` round-trip has
|
||||
* completed yet, see antigravityProjectPersist.ts) cannot serve a request
|
||||
* reliably. Preferring connections that already have one avoids routing
|
||||
* reset-aware traffic to an account that will just re-trigger discovery.
|
||||
*
|
||||
* This is a preference, not a hard requirement: if none of the candidate
|
||||
* connections have a stored projectId yet (e.g. a freshly added account),
|
||||
* excluding all of them would empty the reset-aware pool entirely, which is
|
||||
* worse than routing to an undiscovered connection. Fail open to the full
|
||||
* list in that case.
|
||||
*/
|
||||
|
||||
function hasStoredProjectId(connection: Record<string, unknown>): boolean {
|
||||
if (typeof connection.projectId === "string" && connection.projectId.trim().length > 0) {
|
||||
return true;
|
||||
}
|
||||
const providerSpecificData = connection.providerSpecificData;
|
||||
if (providerSpecificData && typeof providerSpecificData === "object") {
|
||||
const nested = (providerSpecificData as Record<string, unknown>).projectId;
|
||||
if (typeof nested === "string" && nested.trim().length > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function preferAntigravityConnectionsWithStoredProject<
|
||||
T extends Record<string, unknown>,
|
||||
>(connections: T[]): T[] {
|
||||
const withStoredProject = connections.filter(hasStoredProjectId);
|
||||
return withStoredProject.length > 0 ? withStoredProject : connections;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ function normalizeRuntimeStep(
|
||||
: {}),
|
||||
weight,
|
||||
label,
|
||||
prompt: step.prompt || null,
|
||||
prompt: step.kind === "model" ? step.prompt || null : null,
|
||||
} satisfies ResolvedComboTarget;
|
||||
}
|
||||
|
||||
@@ -533,8 +533,6 @@ function hasKnownCompatibleContextLimit(
|
||||
return evaluateContextLimit(capabilities, requirements, target.modelStr) === true;
|
||||
}
|
||||
|
||||
const HARD_COMPAT_REASONS = new Set(["tools", "vision", "structured_output", "output_tokens"]);
|
||||
|
||||
/**
|
||||
* #8332: vision is a hard requirement, not a soft preference — a target whose vision
|
||||
* support is not confirmed can never succeed on an image_url request. Callers
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* literal `auto/*` string panel member already behaves via the single-
|
||||
* dispatch safety net in src/sse/handlers/chat.ts.
|
||||
*/
|
||||
import { normalizeComboStep } from "../../../src/lib/combos/steps.ts";
|
||||
import { getComboModelString, normalizeComboStep } from "../../../src/lib/combos/steps.ts";
|
||||
import { executeComboRefUnit } from "./runtimeUnits.ts";
|
||||
import type {
|
||||
ComboCollectionLike,
|
||||
@@ -51,7 +51,11 @@ export function extractFusionPanelSpec(
|
||||
panel.push(step.comboName);
|
||||
return;
|
||||
}
|
||||
panel.push(step.model);
|
||||
// Provider-wildcard steps have no concrete model to dispatch — fusion is a
|
||||
// fixed-size panel of literal models/combo-refs, not a wildcard-expanding
|
||||
// strategy (see file header). Skip rather than push an undefined model.
|
||||
const modelStr = getComboModelString(step);
|
||||
if (modelStr) panel.push(modelStr);
|
||||
});
|
||||
return { panel, comboRefUnits };
|
||||
}
|
||||
|
||||
@@ -89,9 +89,7 @@ async function getQuotaAwareConnectionsForTarget(
|
||||
? (connections as Array<Record<string, unknown>>)
|
||||
: [];
|
||||
if (provider === "antigravity" || provider === "agy") {
|
||||
activeConnections = preferAntigravityConnectionsWithStoredProject(
|
||||
activeConnections
|
||||
) as Array<Record<string, unknown>>;
|
||||
activeConnections = preferAntigravityConnectionsWithStoredProject(activeConnections);
|
||||
}
|
||||
if (
|
||||
!resetAwareConnectionCache.has(provider) &&
|
||||
|
||||
@@ -292,7 +292,10 @@ function rehydrateEntry(hash: string, principalId: string, now: number): CcrEntr
|
||||
|
||||
// Re-admit through the same budgets a fresh store would face. If the block no longer
|
||||
// fits, it stays on disk and is served straight from the row instead of being cached.
|
||||
if (enforcePrincipalBudget(entry.principalId, entry.bytes) && enforceGlobalBudget(entry.bytes)) {
|
||||
if (
|
||||
enforcePrincipalBudget(entry.principalId, entry.bytes) &&
|
||||
enforceGlobalBudget(entry.principalId, entry.bytes)
|
||||
) {
|
||||
const key = buildStoreKey(hash, principalId === ANON ? undefined : principalId);
|
||||
ccrStore.set(key, entry);
|
||||
ccrTotalBytes += entry.bytes;
|
||||
|
||||
@@ -120,7 +120,7 @@ export function getFirecrawlBaseUrl(connection?: Record<string, unknown>): strin
|
||||
export async function fetchFirecrawlQuota(
|
||||
connectionId: string,
|
||||
connection?: Record<string, unknown>
|
||||
): Promise<QuotaInfo | null> {
|
||||
): Promise<FirecrawlQuota | null> {
|
||||
const cached = quotaCache.get(connectionId);
|
||||
if (cached && Date.now() - cached.fetchedAt < CACHE_TTL_MS) {
|
||||
return cached.quota;
|
||||
|
||||
Reference in New Issue
Block a user