tuxevil-rotator 3.3.2 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased]
4
+
5
+ ## [3.5.0] - 2026-09-03
6
+
7
+ ### Added
8
+ - **Live Antigravity model discovery**: Successful quota polls now reconcile model IDs, context windows, output limits, thinking metadata, and account availability into `/v1/models` without a second discovery request ([#29](https://github.com/tuxevil/tuxevil-rotator/pull/29) by [@javargasm](https://github.com/javargasm)).
9
+
10
+ ### Fixed
11
+ - **Dynamic catalog safety**: Discovery now excludes retired `gemini-3.5-*` IDs, keys snapshots by full account identity, honors case-insensitive operator `modelSpecs` substring overrides, and keeps removed dynamic models from falling through to the generic Gemini pool ([#29](https://github.com/tuxevil/tuxevil-rotator/pull/29) by [@javargasm](https://github.com/javargasm)).
12
+
13
+ ## [3.4.0] - 2026-09-03
14
+
15
+ ### Added
16
+ - **Gemini 3.8 Flash support**: Added the native Antigravity IDs `gemini-3.8-flash-high`, `gemini-3.8-flash-medium`, and `gemini-3.8-flash-low` across model discovery, routing, context limits, pricing, dashboards, telemetry, and integration documentation. All three IDs were discovered across nine configured accounts and verified with live generation ([#28](https://github.com/tuxevil/tuxevil-rotator/pull/28) by [@CyR1en](https://github.com/CyR1en)).
17
+
18
+ ### Changed
19
+ - **Antigravity client version**: Updated the default Antigravity user agent from `1.107.0` to `2.11.0`; the newer user agent is required for Gemini 3.8 Flash discovery and generation ([#28](https://github.com/tuxevil/tuxevil-rotator/pull/28) by [@CyR1en](https://github.com/CyR1en)).
20
+ - **Gemini 3.5 Flash catalog removal**: Removed Gemini 3.5 Flash from the user-facing supported-model catalog and defaults to match Antigravity 2.11. Backend discovery may still return legacy 3.5 quota entries ([#28](https://github.com/tuxevil/tuxevil-rotator/pull/28) by [@CyR1en](https://github.com/CyR1en)).
21
+
3
22
  ## [3.3.2] - 2026-08-28
4
23
 
5
24
  ### Fixed
package/README.md CHANGED
@@ -51,6 +51,11 @@ Originally built as a multi-account rotator for Google Antigravity. It now gener
51
51
 
52
52
  ---
53
53
 
54
+ ## Current Model Update
55
+
56
+ - **Gemini 3.8 Flash Support**: Native Antigravity model IDs `gemini-3.8-flash-high`, `gemini-3.8-flash-medium`, and `gemini-3.8-flash-low`, with 1M-token context, 65,536-token output, pricing, quota routing, dashboard visualization, and telemetry support. Gemini 3.5 Flash has been removed from the user-facing catalog to match Antigravity 2.11. ([PR #28](https://github.com/tuxevil/tuxevil-rotator/pull/28) by [@CyR1en](https://github.com/CyR1en))
57
+ - **Dynamic Antigravity Discovery**: Successful quota polls reconcile live model IDs and metadata per full account identity. Newly advertised models appear in `/v1/models` and route only to accounts that advertised them; removed models disappear without falling back to the generic Gemini pool. Legacy `gemini-3.5-*` IDs stay hidden, and configured `modelSpecs` substring overrides retain precedence. ([PR #29](https://github.com/tuxevil/tuxevil-rotator/pull/29) by [@javargasm](https://github.com/javargasm))
58
+
54
59
  ## v3.2 Highlights
55
60
 
56
61
  - **Gemini 3.7 Flash Support**: Full support for Google's Gemini 3.7 Flash models (`gemini-3.7-flash`, `gemini-3.7-flash-tiered`, `gemini-3.7-flash-high`, `gemini-3.7-flash-medium`, `gemini-3.7-flash-low`) with reasoning effort / thinking level translation, pricing, dashboard visualization, and telemetry.
@@ -341,10 +346,10 @@ Thanks to these amazing people who have contributed to the project:
341
346
 
342
347
  - **[@CelestialCreator](https://github.com/CelestialCreator)** (Akshay) — Fixed admin token propagation on the hosted login landing page (`/login` to `/auth/antigravity/start`). ([PR #25](https://github.com/tuxevil/tuxevil-rotator/pull/25))
343
348
  - **[@Codder-hermes](https://github.com/Codder-hermes)** — Fixed Claude Code tool-schema requests by stripping the unsupported JSON Schema `propertyNames` keyword for Gemini and Claude-via-Gemini routes, with regression coverage for both compatibility paths. ([PR #19](https://github.com/tuxevil/tuxevil-rotator/pull/19))
344
- - **[@CyR1en](https://github.com/CyR1en)** (Ethan Bacurio) — Added Gemini 3.6 Flash and Gemini 3.7 Flash model families, shared quota-pool routing, pricing, dashboard support, and regression coverage. ([PR #18](https://github.com/tuxevil/tuxevil-rotator/pull/18), [PR #21](https://github.com/tuxevil/tuxevil-rotator/pull/21))
349
+ - **[@CyR1en](https://github.com/CyR1en)** (Ethan Bacurio) — Added Gemini 3.6, Gemini 3.7, and Gemini 3.8 Flash model families, shared quota-pool routing, pricing, dashboard support, integration documentation, and regression coverage. ([PR #18](https://github.com/tuxevil/tuxevil-rotator/pull/18), [PR #21](https://github.com/tuxevil/tuxevil-rotator/pull/21), [PR #28](https://github.com/tuxevil/tuxevil-rotator/pull/28))
345
350
  - **[@josenicomaia](https://github.com/josenicomaia)** (José Nicodemos Maia Neto) — Modularized the compatibility layer architecture, added multimodal tool response support, fixed streaming pass-through for tool executions, and added PostgreSQL storage and weighted pool quota forecasting. ([PR #8](https://github.com/tuxevil/tuxevil-rotator/pull/8), [PR #9](https://github.com/tuxevil/tuxevil-rotator/pull/9), [PR #11](https://github.com/tuxevil/tuxevil-rotator/pull/11), [PR #13](https://github.com/tuxevil/tuxevil-rotator/pull/13), [PR #14](https://github.com/tuxevil/tuxevil-rotator/pull/14))
346
351
  - **[@yashyadav711](https://github.com/yashyadav711)** (Yash) — Fixed Draft-2020-12 inline JSON-Schema union type mapping for Gemini tools support. ([PR #10](https://github.com/tuxevil/tuxevil-rotator/pull/10))
347
- - **[@javargasm](https://github.com/javargasm)** (Jeisson Alexander Vargas Marroquin) — Queued multi-request Antigravity account pooling (5×5 concurrent streams), strict FIFO overflow queue, dashboard concurrency metrics, canonical project ID resolution, 429 quota resilience with account-scoped retry, synchronous leasing, snapshot-based token refresh with generation validation, provider-scoped token publication, spend-logger memory leak fix, atomic PostgreSQL CTE daily spend aggregation with idempotent retries, virtual-key cache bounding, Anthropic tool-use compatibility layer (`tool_use`/`tool_result` content block conversion), JSON schema round-trip fixes, compat test suite expansion, model-scoped cooldowns, explicit Antigravity reset-duration parsing, idle pool normalization, RAW POLL deadline reconciliation, serialized per-account quota polling, and Ollama kickstart routing for multi-provider accounts. ([PR #3](https://github.com/tuxevil/tuxevil-rotator/pull/3), [PR #7](https://github.com/tuxevil/tuxevil-rotator/pull/7), [PR #22](https://github.com/tuxevil/tuxevil-rotator/pull/22), [PR #23](https://github.com/tuxevil/tuxevil-rotator/pull/23), [PR #24](https://github.com/tuxevil/tuxevil-rotator/pull/24), [PR #26](https://github.com/tuxevil/tuxevil-rotator/pull/26))
352
+ - **[@javargasm](https://github.com/javargasm)** (Jeisson Alexander Vargas Marroquin) — Queued multi-request Antigravity account pooling (5×5 concurrent streams), strict FIFO overflow queue, dashboard concurrency metrics, canonical project ID resolution, account-scoped dynamic Antigravity discovery and routing, 429 quota resilience with account-scoped retry, synchronous leasing, snapshot-based token refresh with generation validation, provider-scoped token publication, spend-logger memory leak fix, atomic PostgreSQL CTE daily spend aggregation with idempotent retries, virtual-key cache bounding, Anthropic tool-use compatibility layer (`tool_use`/`tool_result` content block conversion), JSON schema round-trip fixes, compat test suite expansion, model-scoped cooldowns, explicit Antigravity reset-duration parsing, idle pool normalization, RAW POLL deadline reconciliation, serialized per-account quota polling, and Ollama kickstart routing for multi-provider accounts. ([PR #3](https://github.com/tuxevil/tuxevil-rotator/pull/3), [PR #7](https://github.com/tuxevil/tuxevil-rotator/pull/7), [PR #22](https://github.com/tuxevil/tuxevil-rotator/pull/22), [PR #23](https://github.com/tuxevil/tuxevil-rotator/pull/23), [PR #24](https://github.com/tuxevil/tuxevil-rotator/pull/24), [PR #26](https://github.com/tuxevil/tuxevil-rotator/pull/26), [PR #29](https://github.com/tuxevil/tuxevil-rotator/pull/29))
348
353
 
349
354
  ## Development
350
355
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuxevil-rotator",
3
- "version": "3.3.2",
3
+ "version": "3.5.0",
4
4
  "description": "Multi-provider, multi-account AI proxy rotator with per-model routing, real-time quota tracking, and infringement detection (Google Antigravity, Ollama Cloud)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,70 @@
1
+ import { createHash } from "node:crypto";
2
+ import { normalizeAccountConfig } from "./config-normalize.js";
3
+ import type {
4
+ AccountConfig,
5
+ AccountRuntime,
6
+ ProviderCredential,
7
+ } from "./types.js";
8
+ import {
9
+ DEFAULT_PROVIDER,
10
+ getProviderProjectId,
11
+ } from "./providers/credential-helpers.js";
12
+
13
+ function credentialFingerprint(secret?: string): string {
14
+ if (!secret) return "";
15
+ // SHA-256 is intentional: this is a non-secret deduplication fingerprint, not a
16
+ // password hash. It must be deterministic and fast (bcrypt/argon2 would be wrong here).
17
+ // codeql[js/insufficient-password-hash]
18
+ return createHash("sha256").update(secret).digest("hex").slice(0, 12);
19
+ }
20
+
21
+ export function getProviderCredentialDetails(
22
+ norm: AccountConfig,
23
+ cred?: ProviderCredential,
24
+ ): {
25
+ provider: string;
26
+ projectId: string;
27
+ providerAccountId: string;
28
+ secret: string;
29
+ fingerprint: string;
30
+ } {
31
+ const provider = cred?.provider ?? DEFAULT_PROVIDER;
32
+ const projectId = getProviderProjectId(norm, provider);
33
+ let providerAccountId = cred?.providerAccountId || "";
34
+ let secret = cred?.refreshToken || cred?.apiKey || "";
35
+
36
+ if (provider === "google-antigravity") {
37
+ secret ||= norm.refreshToken || norm.apiKey || "";
38
+ } else if (provider === "openai-codex") {
39
+ providerAccountId ||= norm.codexAccountId || "";
40
+ secret ||= norm.codexRefreshToken || "";
41
+ }
42
+
43
+ const fingerprint = !projectId && !providerAccountId && secret
44
+ ? credentialFingerprint(secret)
45
+ : "";
46
+ return { provider, projectId, providerAccountId, secret, fingerprint };
47
+ }
48
+
49
+ export function getAccountIdentity(
50
+ account: AccountConfig | AccountRuntime,
51
+ ): string {
52
+ const config = "config" in account ? account.config : account;
53
+ const norm = normalizeAccountConfig(config);
54
+ const email = norm.email.toLowerCase().trim();
55
+ const creds = (norm.credentials ?? [])
56
+ .slice()
57
+ .sort((a, b) => a.provider.localeCompare(b.provider))
58
+ .map((credential) => {
59
+ const details = getProviderCredentialDetails(norm, credential);
60
+ return `${details.provider}:${details.projectId}:${details.providerAccountId}:${details.fingerprint}`;
61
+ })
62
+ .join("|");
63
+ if (!creds) {
64
+ const details = getProviderCredentialDetails(norm, {
65
+ provider: DEFAULT_PROVIDER,
66
+ });
67
+ return `${email}#${details.provider}:${details.projectId}:${details.providerAccountId}:${details.fingerprint}`;
68
+ }
69
+ return `${email}#${creds}`;
70
+ }
@@ -1,3 +1,5 @@
1
+ import { dynamicCatalog } from "../providers/google-antigravity/dynamic-catalog.js";
2
+
1
3
  export interface ModelSpec {
2
4
  maxOutputTokens: number;
3
5
  thinkingBudget: number; // -1 = adaptive (model decides), >=0 = fixed
@@ -15,15 +17,14 @@ export const DEFAULT_MODEL_SPECS: Record<string, ModelSpec> = {
15
17
  "gemini-3.1-pro-high": { maxOutputTokens: 65535, thinkingBudget: 10001, isThinking: true, contextWindow: 1_000_000 },
16
18
  "gemini-3.1-pro-low": { maxOutputTokens: 65535, thinkingBudget: 1001, isThinking: true, contextWindow: 1_000_000 },
17
19
  "gemini-3.1-pro-preview": { maxOutputTokens: 65535, thinkingBudget: 10001, isThinking: true, contextWindow: 1_000_000 },
18
- "gemini-3.5-flash": { maxOutputTokens: 65536, thinkingBudget: 10000, isThinking: true, contextWindow: 1_000_000 },
19
- "gemini-3.5-flash-medium": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true, contextWindow: 1_000_000 },
20
- "gemini-3.5-flash-low": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true, contextWindow: 1_000_000 },
21
- "gemini-3.5-flash-high": { maxOutputTokens: 65536, thinkingBudget: 10000, isThinking: true, contextWindow: 1_000_000 },
22
20
  "gemini-3.6-flash-high": { maxOutputTokens: 65536, thinkingBudget: 10000, isThinking: true, contextWindow: 1_000_000 },
23
21
  "gemini-3.6-flash-medium": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true, contextWindow: 1_000_000 },
24
22
  "gemini-3.6-flash-low": { maxOutputTokens: 65536, thinkingBudget: 1000, isThinking: true, contextWindow: 1_000_000 },
25
23
  "gemini-3.6-flash-tiered": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
26
24
  "gemini-3.7-flash-tiered": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
25
+ "gemini-3.8-flash-high": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
26
+ "gemini-3.8-flash-medium": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
27
+ "gemini-3.8-flash-low": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
27
28
  "gemini-3-flash": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true, contextWindow: 1_000_000 },
28
29
  "gemini-2.5-flash": { maxOutputTokens: 65535, thinkingBudget: 24576, isThinking: true, contextWindow: 1_000_000 },
29
30
  "gemini-2.5-pro": { maxOutputTokens: 65535, thinkingBudget: 1024, isThinking: true, contextWindow: 1_000_000 },
@@ -41,8 +42,12 @@ let modelSpecsOverride: Record<string, ModelSpec> | null = null;
41
42
  * Replace the bundled model spec table with operator-provided overrides.
42
43
  * Pass `null` to restore defaults. Called once at startup from index.ts.
43
44
  */
44
- export function setModelSpecsOverride(specs: Record<string, ModelSpec> | null): void {
45
- modelSpecsOverride = specs && Object.keys(specs).length > 0 ? specs : null;
45
+ export function setModelSpecsOverride(specs: Record<string, ModelSpec> | null): void {
46
+ modelSpecsOverride = specs && Object.keys(specs).length > 0
47
+ ? Object.fromEntries(
48
+ Object.entries(specs).map(([key, spec]) => [key.toLowerCase(), spec]),
49
+ )
50
+ : null;
46
51
  }
47
52
 
48
53
  export function getActiveModelSpecs(): Record<string, ModelSpec> {
@@ -61,13 +66,23 @@ export function getModelFamily(model: string): "claude" | "gemini" | "unknown" {
61
66
  return "unknown";
62
67
  }
63
68
 
64
- export function getModelSpec(model: string): ModelSpec {
65
- const specs = getActiveModelSpecs();
66
- const lower = model.toLowerCase();
67
- if (specs[lower]) return specs[lower];
68
- for (const [key, spec] of Object.entries(specs)) {
69
- if (lower.includes(key)) return spec;
70
- }
69
+ export function getModelSpec(model: string): ModelSpec {
70
+ const lower = model.toLowerCase();
71
+ if (modelSpecsOverride) {
72
+ if (modelSpecsOverride[lower]) return modelSpecsOverride[lower];
73
+ for (const [key, spec] of Object.entries(modelSpecsOverride)) {
74
+ if (lower.includes(key)) return spec;
75
+ }
76
+ } else if (DEFAULT_MODEL_SPECS[lower]) {
77
+ return DEFAULT_MODEL_SPECS[lower];
78
+ }
79
+ const dynamicSpec = dynamicCatalog.getModelSpec(lower);
80
+ if (dynamicSpec) return dynamicSpec;
81
+ if (!modelSpecsOverride) {
82
+ for (const [key, spec] of Object.entries(DEFAULT_MODEL_SPECS)) {
83
+ if (lower.includes(key)) return spec;
84
+ }
85
+ }
71
86
  const family = getModelFamily(model);
72
87
  if (family === "claude") return { maxOutputTokens: CLAUDE_MAX_OUTPUT_TOKENS, thinkingBudget: CLAUDE_DEFAULT_THINKING_BUDGET, isThinking: true, contextWindow: 1_000_000 };
73
88
  if (family === "gemini") return { maxOutputTokens: GEMINI_MAX_OUTPUT_TOKENS, thinkingBudget: FALLBACK_THINKING_BUDGET, isThinking: true, contextWindow: 1_000_000 };
package/src/compat.ts CHANGED
@@ -28,6 +28,7 @@ import {
28
28
  sanitizeGeminiSchema,
29
29
  sanitizeClaudeViaGeminiSchema,
30
30
  } from "./compat/schema-sanitizer.js";
31
+ import { dynamicCatalog } from "./providers/google-antigravity/dynamic-catalog.js";
31
32
  import {
32
33
  DEFAULT_MODEL_SPECS,
33
34
  setModelSpecsOverride,
@@ -515,6 +516,10 @@ function recordCompatOutcome(
515
516
  inputTokens: completion?.inputTokens ?? 0,
516
517
  outputTokens: completion?.outputTokens ?? 0,
517
518
  });
519
+ rotator.recordProxyEvent(
520
+ `[${context.requestId}] COMPAT END account=${context.label} model=${context.displayModelKey} status=${statusCode} ttfbMs=${ttfbMs} totalMs=${totalMs} inTokens=${completion?.inputTokens ?? 0} outTokens=${completion?.outputTokens ?? 0}`,
521
+ "info",
522
+ );
518
523
  logSpend({
519
524
  requestId: context.requestId,
520
525
  apiKeyHash: options?.apiKeyHash || null,
@@ -1966,31 +1971,31 @@ async function completeViaRotator(
1966
1971
 
1967
1972
  const MODEL_CATALOG = [
1968
1973
  {
1969
- id: "gemini-3.5-flash-medium",
1970
- family: "gemini-3.5-flash",
1974
+ id: "gemini-3-flash",
1975
+ family: "gemini-3-flash",
1971
1976
  ctx: 1048576,
1972
1977
  quotaPool: "gemini",
1973
1978
  multimodal: true,
1974
1979
  tools: true,
1975
1980
  },
1976
1981
  {
1977
- id: "gemini-3.5-flash-high",
1978
- family: "gemini-3.5-flash",
1982
+ id: "gemini-3.6-flash-high",
1983
+ family: "gemini-3.6-flash",
1979
1984
  ctx: 1048576,
1980
1985
  quotaPool: "gemini",
1981
1986
  multimodal: true,
1982
1987
  tools: true,
1983
1988
  },
1984
1989
  {
1985
- id: "gemini-3-flash",
1986
- family: "gemini-3.5-flash",
1990
+ id: "gemini-3.6-flash-medium",
1991
+ family: "gemini-3.6-flash",
1987
1992
  ctx: 1048576,
1988
1993
  quotaPool: "gemini",
1989
1994
  multimodal: true,
1990
1995
  tools: true,
1991
1996
  },
1992
1997
  {
1993
- id: "gemini-3.6-flash-high",
1998
+ id: "gemini-3.6-flash-low",
1994
1999
  family: "gemini-3.6-flash",
1995
2000
  ctx: 1048576,
1996
2001
  quotaPool: "gemini",
@@ -1998,7 +2003,7 @@ const MODEL_CATALOG = [
1998
2003
  tools: true,
1999
2004
  },
2000
2005
  {
2001
- id: "gemini-3.6-flash-medium",
2006
+ id: "gemini-3.6-flash-tiered",
2002
2007
  family: "gemini-3.6-flash",
2003
2008
  ctx: 1048576,
2004
2009
  quotaPool: "gemini",
@@ -2006,24 +2011,32 @@ const MODEL_CATALOG = [
2006
2011
  tools: true,
2007
2012
  },
2008
2013
  {
2009
- id: "gemini-3.6-flash-low",
2010
- family: "gemini-3.6-flash",
2014
+ id: "gemini-3.7-flash-tiered",
2015
+ family: "gemini-3.7-flash",
2011
2016
  ctx: 1048576,
2012
2017
  quotaPool: "gemini",
2013
2018
  multimodal: true,
2014
2019
  tools: true,
2015
2020
  },
2016
2021
  {
2017
- id: "gemini-3.6-flash-tiered",
2018
- family: "gemini-3.6-flash",
2022
+ id: "gemini-3.8-flash-high",
2023
+ family: "gemini-3.8-flash",
2019
2024
  ctx: 1048576,
2020
2025
  quotaPool: "gemini",
2021
2026
  multimodal: true,
2022
2027
  tools: true,
2023
2028
  },
2024
2029
  {
2025
- id: "gemini-3.7-flash-tiered",
2026
- family: "gemini-3.7-flash",
2030
+ id: "gemini-3.8-flash-medium",
2031
+ family: "gemini-3.8-flash",
2032
+ ctx: 1048576,
2033
+ quotaPool: "gemini",
2034
+ multimodal: true,
2035
+ tools: true,
2036
+ },
2037
+ {
2038
+ id: "gemini-3.8-flash-low",
2039
+ family: "gemini-3.8-flash",
2027
2040
  ctx: 1048576,
2028
2041
  quotaPool: "gemini",
2029
2042
  multimodal: true,
@@ -2081,23 +2094,44 @@ export interface OpenAIModelCatalogEntry {
2081
2094
  meta: Record<string, unknown>;
2082
2095
  }
2083
2096
 
2097
+ export interface CompatModelEntry {
2098
+ id: string;
2099
+ family: string;
2100
+ ctx: number;
2101
+ quotaPool: string;
2102
+ multimodal: boolean;
2103
+ tools: boolean;
2104
+ }
2105
+
2106
+ export function getEffectiveAntigravityModels(): CompatModelEntry[] {
2107
+ const dynamic = dynamicCatalog.getAllModels();
2108
+ const seen = new Set(MODEL_CATALOG.map((model) => model.id.toLowerCase()));
2109
+ const result: CompatModelEntry[] = MODEL_CATALOG.map((model) => ({ ...model }));
2110
+ for (const m of dynamic) {
2111
+ if (seen.has(m.id.toLowerCase())) continue;
2112
+ seen.add(m.id.toLowerCase());
2113
+ result.push({
2114
+ id: m.id,
2115
+ family: m.family,
2116
+ ctx: m.ctx,
2117
+ quotaPool: m.quotaPool,
2118
+ multimodal: m.multimodal,
2119
+ tools: m.tools,
2120
+ });
2121
+ }
2122
+ return result;
2123
+ }
2124
+
2084
2125
  /**
2085
- * Build the full OpenAI-compatible model catalog (static Antigravity catalog
2086
- * + active-provider models for Ollama, OpenAI Codex and OpenCode Zen).
2087
- *
2088
- * This is the single source of truth for "what models can the rotator route
2089
- * today" and is consumed by:
2090
- * - the public /v1/models endpoint (OpenAI compat)
2091
- * - the admin /api/models endpoint (dashboard virtual key editor)
2126
+ * Build the OpenAI-compatible `/v1/models` catalog for the proxy.
2092
2127
  *
2093
- * Pass the live AccountRotator so dynamic provider catalogs (Ollama tags
2094
- * fetched at startup, Codex base + discovered models) are included. Without
2095
- * a rotator, only the static MODEL_CATALOG is returned.
2128
+ * The static Antigravity baseline and dynamically-discovered Antigravity models
2129
+ * are always included. An active rotator also contributes its other providers.
2096
2130
  */
2097
2131
  export function buildOpenAIModelCatalog(
2098
2132
  rotator?: AccountRotator,
2099
2133
  ): OpenAIModelCatalogEntry[] {
2100
- const catalog: OpenAIModelCatalogEntry[] = MODEL_CATALOG.map(
2134
+ const catalog: OpenAIModelCatalogEntry[] = getEffectiveAntigravityModels().map(
2101
2135
  ({ id, ctx, family, quotaPool, multimodal, tools }) => ({
2102
2136
  id,
2103
2137
  object: "model",
@@ -2187,7 +2221,7 @@ export function serveOpenAIModels(
2187
2221
 
2188
2222
  export function serveGeminiModels(res: ServerResponse): void {
2189
2223
  writeJson(res, 200, {
2190
- models: MODEL_CATALOG.map(
2224
+ models: getEffectiveAntigravityModels().map(
2191
2225
  ({ id, ctx, family, quotaPool, multimodal, tools }) => ({
2192
2226
  name: `models/${id}`,
2193
2227
  baseModelId: family,
@@ -9,6 +9,8 @@
9
9
  // Values reflect input/context window only. Output max tokens are tracked
10
10
  // separately in `src/compat/model-specs.ts` via `maxOutputTokens`.
11
11
 
12
+ import { dynamicCatalog } from "./dynamic-catalog.js";
13
+
12
14
  export interface AntigravityModelSpec {
13
15
  id: string;
14
16
  contextWindow: number;
@@ -36,6 +38,9 @@ export const ANTIGRAVITY_CONTEXT_WINDOWS: Record<string, number> = {
36
38
  "gpt-oss-120b": 131_072,
37
39
  "gpt-oss-120b-medium": 131_072,
38
40
  // Google Gemini 3.x — 1M context window per deepmind.google/models/gemini/*.
41
+ "gemini-3.8-flash-high": 1_000_000,
42
+ "gemini-3.8-flash-medium": 1_000_000,
43
+ "gemini-3.8-flash-low": 1_000_000,
39
44
  "gemini-3.7-flash": 1_000_000,
40
45
  "gemini-3.7-flash-tiered": 1_000_000,
41
46
  "gemini-3.6-flash": 1_000_000,
@@ -43,11 +48,6 @@ export const ANTIGRAVITY_CONTEXT_WINDOWS: Record<string, number> = {
43
48
  "gemini-3.6-flash-medium": 1_000_000,
44
49
  "gemini-3.6-flash-low": 1_000_000,
45
50
  "gemini-3.6-flash-tiered": 1_000_000,
46
- "gemini-3.5-flash": 1_000_000,
47
- "gemini-3.5-flash-medium": 1_000_000,
48
- "gemini-3.5-flash-low": 1_000_000,
49
- "gemini-3.5-flash-high": 1_000_000,
50
- "gemini-3.5-flash-lite": 1_000_000,
51
51
  "gemini-3-flash": 1_000_000,
52
52
  "gemini-3-flash-agent": 1_000_000,
53
53
  "gemini-3-pro": 1_000_000,
@@ -73,10 +73,11 @@ const FALLBACK_CONTEXT_WINDOW = 128_000;
73
73
  * Resolve the upstream-published context window for an Antigravity model id.
74
74
  *
75
75
  * Lookup order:
76
- * 1. Exact id match (lowercased).
77
- * 2. Substring match across the table (longest key wins via the order here).
78
- * 3. Family defaults: claude -> 1M, gemini -> 1M, gpt-oss -> 131_072.
79
- * 4. Defensive fallback: 128_000.
76
+ * 1. Exact id match in static table (lowercased).
77
+ * 2. Dynamic catalog entry from live Antigravity endpoint.
78
+ * 3. Substring match across the table (longest key wins via the order here).
79
+ * 4. Family defaults: claude -> 1M, gemini -> 1M, gpt-oss -> 131_072.
80
+ * 5. Defensive fallback: 128_000.
80
81
  */
81
82
  export function getAntigravityContextWindow(model: string): number {
82
83
  if (!model) return FALLBACK_CONTEXT_WINDOW;
@@ -84,6 +85,8 @@ export function getAntigravityContextWindow(model: string): number {
84
85
  if (!lower) return FALLBACK_CONTEXT_WINDOW;
85
86
  const exact = ANTIGRAVITY_CONTEXT_WINDOWS[lower];
86
87
  if (typeof exact === "number") return exact;
88
+ const dynamicCtx = dynamicCatalog.getContextWindow(lower);
89
+ if (typeof dynamicCtx === "number") return dynamicCtx;
87
90
  // Substring fallback: pick the longest registered key that appears in lower.
88
91
  let best: { key: string; value: number } | null = null;
89
92
  for (const [key, value] of Object.entries(ANTIGRAVITY_CONTEXT_WINDOWS)) {