Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(quota,sse): clear SonarCloud new-reliability findings on the v3.8.12 diff
diegosouzapw5bebf0e53cca
diff --git a/open-sse/executors/chipotle.ts b/open-sse/executors/chipotle.tsindex e01daef023..e1a98c1a81 100644--- a/open-sse/executors/chipotle.ts+++ b/open-sse/executors/chipotle.ts@@ -62,7 +62,7 @@ class AmeliaClient {async connect(): Promise<void> {if (!this.session) throw new Error("Call init() first");- if (this.connectPromise) return this.connectPromise;+ if (this.connectPromise !== null) return this.connectPromise;this.connectPromise = this._connect();try {diff --git a/open-sse/services/grokTlsClient.ts b/open-sse/services/grokTlsClient.tsindex bc0b6e5b9e..d0e51f602d 100644--- a/open-sse/services/grokTlsClient.ts+++ b/open-sse/services/grokTlsClient.ts@@ -41,7 +41,7 @@ function installExitHook(): void {if (exitHookInstalled) return;exitHookInstalled = true;const stop = async () => {- if (!clientPromise) return;+ if (clientPromise === null) return;try {const c = (await clientPromise) as { stop?: () => Promise<unknown> };await c.stop?.();diff --git a/src/app/(dashboard)/dashboard/usage/components/BudgetTab.tsx b/src/app/(dashboard)/dashboard/usage/components/BudgetTab.tsxindex 4f02966e36..aef40fcaec 100644--- a/src/app/(dashboard)/dashboard/usage/components/BudgetTab.tsx+++ b/src/app/(dashboard)/dashboard/usage/components/BudgetTab.tsx@@ -722,8 +722,12 @@ function BudgetRow({borderLeft: `3px solid ${status === "all" ? "transparent" : meta.dot}`,}}>- {/* Checkbox */}- <div onClick={(e) => e.stopPropagation()}>+ {/* Checkbox — wrapper only stops the row-expand trigger from firing */}+ <div+ role="presentation"+ onClick={(e) => e.stopPropagation()}+ onKeyDown={(e) => e.stopPropagation()}+ ><input type="checkbox" checked={isSelected} onChange={onToggleSelect} /></div>diff --git a/src/lib/quota/sqliteQuotaStore.ts b/src/lib/quota/sqliteQuotaStore.tsindex 51417df3bd..3849f0112d 100644--- a/src/lib/quota/sqliteQuotaStore.ts+++ b/src/lib/quota/sqliteQuotaStore.ts@@ -17,7 +17,6 @@import {getPool,- listAllocationsForApiKey,getBucket,incrementBucket,getPair,@@ -148,90 +147,15 @@ export class SqliteQuotaStore implements QuotaStore {};}- const { allocations } = pool;- const totalWeight = allocations.reduce((sum, a) => sum + a.weight, 0);-- // Build per-dimension snapshots- // Dimensions come from the allocations (we aggregate consumption per key- // for each active allocation dimension). Since QuotaPool doesn't directly- // carry dimensions (the plan does), we infer the set of known dimension- // keys by scanning all consumed buckets for the apiKeys in this pool.- //- // Practical approach: look up all consumptions for each apiKeyId in the- // pool's allocations and group by dimension key.-- // Collect all (apiKeyId, dimensionKey) pairs consumed within pool- const dimMap = new Map<- string, // dimKey = "<poolId>:<unit>:<window>"- {- unit: string;- window: string;- perKey: Map<string, number>; // apiKeyId → consumed- }- >();-- for (const alloc of allocations) {- // We don't have a direct "list all dimension keys for a pool" query;- // instead we scan listAllocationsForApiKey to find which pools the key- // participates in, and derive dimensions via best-effort getBucket.- // For poolUsage we rely on the dimension keys we can discover.- // Since dimensions live in ProviderPlan (resolved separately), we peek- // via direct getBucket reads for the current bucket only.- //- // Note: This is intentionally a lightweight implementation. The full- // dimension list should come from the resolved plan; here we surface- // what's been stored in quota_consumption for this pool.-- const { apiKeyId } = alloc;- // listAllocationsForApiKey returns pairs across all pools; filter to this one- const allAllocsForKey = listAllocationsForApiKey(apiKeyId);- for (const { poolId: pid } of allAllocsForKey) {- if (pid !== poolId) continue;- // The dimension keys for this pool are known if consumption exists- // We can't list all keys without a query, so we rely on the calling- // context having pre-populated via consume(). For dashboard use,- // the pool dimensions are read from the provider plan.- }-- // We only read dimensions that we can discover from what was actually- // consumed. For a richer implementation, the caller should pass the- // resolved plan dimensions (done in REST routes - F8).- // Here: peek for common windows to detect what's in use.- }-- // Since we cannot enumerate all dimension keys without a table scan,- // return a minimal snapshot — the REST route (F8) will combine this- // with plan data to produce the full response.- const dimensionSnapshots: PoolUsageSnapshot["dimensions"] = [];-- for (const [_dimKey, dimData] of dimMap) {- let consumedTotal = 0;- const perKey: PoolUsageSnapshot["dimensions"][number]["perKey"] = [];-- for (const [apiKeyId, consumed] of dimData.perKey) {- consumedTotal += consumed;- const alloc = allocations.find((a) => a.apiKeyId === apiKeyId);- const weight = alloc?.weight ?? 0;- // limit comes from the plan — here we set to 0 as placeholder- const fairShare = 0; // overridden when plan is available- const deficit = consumed - fairShare;- const borrowing = consumed > fairShare && consumed <= consumedTotal;- perKey.push({ apiKeyId, consumed, fairShare, deficit, borrowing });- }-- dimensionSnapshots.push({- unit: dimData.unit as PoolUsageSnapshot["dimensions"][number]["unit"],- window: dimData.window as PoolUsageSnapshot["dimensions"][number]["window"],- limit: 0,- consumedTotal,- perKey,- });- }-+ // QuotaPool does not carry dimension definitions — those live in the+ // ProviderPlan, resolved separately. Without a plan we cannot enumerate+ // dimension keys here, so this lightweight snapshot returns no dimensions.+ // The REST route (F8) calls poolUsageWithDimensions() with the resolved+ // plan to produce the full per-dimension response.return {poolId,generatedAt: new Date(nowMs).toISOString(),- dimensions: dimensionSnapshots,+ dimensions: [],};}