tuxevil-rotator 4.0.0 → 4.2.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +8 -1
  3. package/package.json +1 -1
  4. package/src/audio-transcription.ts +44 -4
  5. package/src/compat.ts +196 -222
  6. package/src/config-defaults.ts +5 -0
  7. package/src/config-overrides.ts +16 -0
  8. package/src/dashboard-live.ts +10 -8
  9. package/src/dashboard-types.ts +94 -1
  10. package/src/dashboard.ts +194 -1
  11. package/src/effort-levels.ts +43 -0
  12. package/src/effort-routing.ts +304 -0
  13. package/src/index.ts +2 -5
  14. package/src/model-catalog-revision.ts +20 -0
  15. package/src/model-catalog.ts +304 -0
  16. package/src/providers/adapter.ts +18 -0
  17. package/src/providers/google-antigravity/catalog.ts +190 -1
  18. package/src/providers/google-antigravity/forward.ts +2 -0
  19. package/src/providers/google-antigravity/index.ts +11 -0
  20. package/src/providers/google-antigravity/translators.ts +67 -14
  21. package/src/providers/ollama/index.ts +11 -1
  22. package/src/providers/ollama/quota-poll-store.ts +22 -1
  23. package/src/providers/ollama/quota.ts +95 -23
  24. package/src/providers/openai-codex/catalog.ts +9 -4
  25. package/src/providers/openai-codex/index.ts +18 -2
  26. package/src/providers/opencode-zen/index.ts +11 -2
  27. package/src/proxy.ts +143 -28
  28. package/src/rotator.ts +296 -21
  29. package/src/settings-repository.ts +36 -5
  30. package/src/types.ts +72 -26
  31. package/src/validators.ts +37 -1
  32. package/src/web/app.tsx +6 -1
  33. package/src/web/components/icons.tsx +29 -0
  34. package/src/web/components/overlays.tsx +13 -1
  35. package/src/web/components/ui.tsx +6 -1
  36. package/src/web/lib/accounts.ts +1 -0
  37. package/src/web/lib/attention.ts +12 -0
  38. package/src/web/lib/effort.ts +407 -0
  39. package/src/web/lib/models.ts +284 -0
  40. package/src/web/lib/pools.ts +53 -9
  41. package/src/web/lib/status.ts +13 -3
  42. package/src/web/nav.ts +1 -0
  43. package/src/web/pages/AccountDetail.tsx +16 -2
  44. package/src/web/pages/EffortRouting.tsx +1130 -0
  45. package/src/web/pages/Models.tsx +888 -0
  46. package/src/web/pages/Overview.tsx +31 -15
  47. package/src/web/pages/Usage.tsx +3 -3
  48. package/src/web/state/api.ts +31 -0
  49. package/src/web/state/model-catalog.ts +103 -0
  50. package/src/web/state/router.ts +150 -19
  51. package/src/web/state/store.ts +6 -6
  52. package/src/web/styles/app.css +854 -0
package/src/index.ts CHANGED
@@ -16,11 +16,10 @@ import {
16
16
  import { warnIfUsingFallbackOAuthCreds } from "./providers/google-antigravity/oauth.js";
17
17
  import { warnIfInsecureTelemetryEndpoint } from "./telemetry.js";
18
18
  import {
19
- setModelSpecsOverride,
20
19
  loadResponsesStore,
21
20
  flushResponsesStore,
22
21
  } from "./compat.js";
23
- import { setModelAliasesOverride, setEffortRoutingOverride } from "./types.js";
22
+ import { applyConfigOverrides } from "./config-overrides.js";
24
23
  import { readTextFile, writeTextFileAtomic } from "./storage.js";
25
24
  import { initDb, isDbConfigured } from "./db-store.js";
26
25
  import { runKeyMigrations } from "./key-migrations.js";
@@ -212,9 +211,7 @@ export async function main(): Promise<void> {
212
211
  maybeWarnAboutProxyExposure(config);
213
212
  warnIfUsingFallbackOAuthCreds();
214
213
  warnIfInsecureTelemetryEndpoint();
215
- setModelSpecsOverride(config.modelSpecs ?? null);
216
- setModelAliasesOverride(config.modelAliases ?? null);
217
- setEffortRoutingOverride(config.effortRouting ?? null);
214
+ applyConfigOverrides(config);
218
215
  void loadResponsesStore();
219
216
 
220
217
  const rotator = new AccountRotator(config);
@@ -0,0 +1,20 @@
1
+ import { createHash } from "node:crypto";
2
+ import { getProviderOrder, isProviderTurnedOff, listCatalogModels, type ModelCatalogSource } from "./model-catalog.js";
3
+
4
+ /** A stable revision of the public catalog, independent of traffic and timers. */
5
+ export function getModelCatalogRevision(source: ModelCatalogSource): string {
6
+ const config = source.getConfig?.();
7
+ const state = {
8
+ providers: getProviderOrder(source).map((id) => ({
9
+ id,
10
+ enabled: !isProviderTurnedOff(config, id),
11
+ active: source.hasActiveProvider?.(id) ?? true,
12
+ })),
13
+ models: listCatalogModels(source),
14
+ autoEnableNewModels: config?.autoEnableNewModels ?? true,
15
+ effortRouting: config?.effortRouting ?? null,
16
+ // The switch of an id no provider lists, such as an effort-routed id, is not in `models`.
17
+ disabledModels: (config?.disabledModels ?? []).map((key) => key.trim().toLowerCase()).sort(),
18
+ };
19
+ return createHash("sha256").update(JSON.stringify(state)).digest("hex").slice(0, 32);
20
+ }
@@ -0,0 +1,304 @@
1
+ // Which provider serves a model, and which providers and models the operator
2
+ // turned off on the dashboard's Models page.
3
+ //
4
+ // Every provider lists the models it serves (ProviderAdapter.listModels). When
5
+ // more than one provider lists the same id, `providerOrder` decides which one
6
+ // gets the request. Ids no provider lists (aliases, upstream names, ids a
7
+ // provider claims by pattern) keep the fixed ownership checks in
8
+ // providers/registry.ts, so routing for them is unchanged.
9
+
10
+ import type { Config } from "./types.js";
11
+ import { applyModelAlias, getEffortRoutingRule } from "./types.js";
12
+ import type { ProviderModel } from "./providers/adapter.js";
13
+ import {
14
+ findProviderForModel,
15
+ getProviderAdapter,
16
+ isKnownProvider,
17
+ } from "./providers/registry.js";
18
+
19
+ /**
20
+ * Priority for ids more than one provider lists, before the operator changes
21
+ * it. Matches the historical ownership order in findProviderForModel, so
22
+ * upgrading changes no routing.
23
+ */
24
+ export const DEFAULT_PROVIDER_ORDER: readonly string[] = [
25
+ "opencode-zen",
26
+ "openai-codex",
27
+ "ollama",
28
+ "google-antigravity",
29
+ ];
30
+
31
+ /** The rotator state the catalog reads. Test stubs may omit any of it. */
32
+ export interface ModelCatalogSource {
33
+ getConfig?(): Config;
34
+ getOllamaModels?(): string[];
35
+ getCodexModels?(): string[];
36
+ /** Whether an in-service account can use the provider right now. */
37
+ hasActiveProvider?(providerId: string): boolean;
38
+ }
39
+
40
+ export type ModelOffReason = "provider" | "model" | "review";
41
+
42
+ /** The model's own switch, regardless of its provider's switch. */
43
+ export type ModelSwitch = "on" | "off" | "review";
44
+
45
+ export interface CatalogModel extends ProviderModel {
46
+ providerId: string;
47
+ /** Why the model is off, or null when it is served. */
48
+ offReason: ModelOffReason | null;
49
+ modelSwitch: ModelSwitch;
50
+ }
51
+
52
+ export type ModelRoute =
53
+ /** Send the request to this provider. */
54
+ | { kind: "provider"; providerId: string; modelId: string }
55
+ /** Every provider that serves the model is turned off for it. */
56
+ | { kind: "off"; providerIds: string[] }
57
+ /** No provider lists the id; callers keep their own provider checks. */
58
+ | { kind: "unlisted" };
59
+
60
+ interface ModelSettings {
61
+ order: string[];
62
+ disabledProviders: Set<string>;
63
+ disabledModels: Set<string>;
64
+ autoEnableNewModels: boolean;
65
+ reviewedModels: Set<string>;
66
+ }
67
+
68
+ /** Config key for one provider's copy of a model: "ollama/gpt-oss:120b". */
69
+ export function modelKey(providerId: string, modelId: string): string {
70
+ return `${providerId}/${modelId}`;
71
+ }
72
+
73
+ /** Splits "provider/model"; model ids may themselves contain slashes. */
74
+ export function parseModelKey(key: string): { providerId: string; modelId: string } | null {
75
+ const slash = key.indexOf("/");
76
+ if (slash <= 0 || slash === key.length - 1) return null;
77
+ const providerId = key.slice(0, slash);
78
+ if (!isKnownProvider(providerId)) return null;
79
+ return { providerId, modelId: key.slice(slash + 1) };
80
+ }
81
+
82
+ const fold = (value: string) => value.trim().toLowerCase();
83
+
84
+ /** Configured order, limited to known providers, with any missing ones appended in default order. */
85
+ export function resolveProviderOrder(order: readonly string[] | undefined): string[] {
86
+ const out: string[] = [];
87
+ for (const id of [...(order ?? []), ...DEFAULT_PROVIDER_ORDER]) {
88
+ if (isKnownProvider(id) && !out.includes(id)) out.push(id);
89
+ }
90
+ return out;
91
+ }
92
+
93
+ function readSettings(config: Partial<Config> | undefined): ModelSettings {
94
+ return {
95
+ order: resolveProviderOrder(config?.providerOrder),
96
+ disabledProviders: new Set(config?.disabledProviders ?? []),
97
+ disabledModels: new Set((config?.disabledModels ?? []).map(fold)),
98
+ autoEnableNewModels: config?.autoEnableNewModels ?? true,
99
+ reviewedModels: new Set((config?.reviewedModels ?? []).map(fold)),
100
+ };
101
+ }
102
+
103
+ function modelSwitchFor(settings: ModelSettings, providerId: string, modelId: string): ModelSwitch {
104
+ const key = fold(modelKey(providerId, modelId));
105
+ if (settings.disabledModels.has(key)) return "off";
106
+ if (!settings.autoEnableNewModels && !settings.reviewedModels.has(key)) return "review";
107
+ return "on";
108
+ }
109
+
110
+ function offReasonFor(settings: ModelSettings, providerId: string, modelId: string): ModelOffReason | null {
111
+ if (settings.disabledProviders.has(providerId)) return "provider";
112
+ const own = modelSwitchFor(settings, providerId, modelId);
113
+ return own === "off" ? "model" : own === "review" ? "review" : null;
114
+ }
115
+
116
+ function listFor(source: ModelCatalogSource, settings: ModelSettings): CatalogModel[] {
117
+ const context = {
118
+ ollamaModels: source.getOllamaModels?.() ?? [],
119
+ codexModels: source.getCodexModels?.() ?? [],
120
+ };
121
+ const out: CatalogModel[] = [];
122
+ for (const providerId of settings.order) {
123
+ for (const model of getProviderAdapter(providerId).listModels(context)) {
124
+ out.push({
125
+ ...model,
126
+ providerId,
127
+ offReason: offReasonFor(settings, providerId, model.id),
128
+ modelSwitch: modelSwitchFor(settings, providerId, model.id),
129
+ });
130
+ }
131
+ }
132
+ return out;
133
+ }
134
+
135
+ /** Every provider's models, in provider order, with whether each is off. */
136
+ export function listCatalogModels(source: ModelCatalogSource): CatalogModel[] {
137
+ return listFor(source, readSettings(source.getConfig?.()));
138
+ }
139
+
140
+ /** Provider ids in routing order. */
141
+ export function getProviderOrder(source: ModelCatalogSource): string[] {
142
+ return resolveProviderOrder(source.getConfig?.()?.providerOrder);
143
+ }
144
+
145
+ export function isProviderTurnedOff(config: Partial<Config> | undefined, providerId: string): boolean {
146
+ return (config?.disabledProviders ?? []).includes(providerId);
147
+ }
148
+
149
+ /** Whether one provider's copy of a model may be listed and served. */
150
+ export function isModelServed(source: ModelCatalogSource, providerId: string, modelId: string): boolean {
151
+ return offReasonFor(readSettings(source.getConfig?.()), providerId, modelId) === null;
152
+ }
153
+
154
+ /**
155
+ * Decide which provider serves a requested model id.
156
+ *
157
+ * Exact ids a provider lists win. When several providers list it, the first
158
+ * one in provider order that is on and has a usable account gets it; if none
159
+ * has an account, the first one that is on still gets it so the request fails
160
+ * the usual way ("no account available") instead of with a different error.
161
+ */
162
+ export function resolveModelRoute(source: ModelCatalogSource, model: string): ModelRoute {
163
+ const settings = readSettings(source.getConfig?.());
164
+ const catalog = listFor(source, settings);
165
+ const lookup = (id: string) => {
166
+ const wanted = fold(id);
167
+ return catalog.filter((entry) => fold(entry.id) === wanted);
168
+ };
169
+
170
+ let listed = lookup(model);
171
+ if (listed.length === 0) {
172
+ // Operator-facing aliases ("gpt-oss-120b") stand for a listed upstream id.
173
+ const alias = applyModelAlias(model);
174
+ if (fold(alias) !== fold(model)) listed = lookup(alias);
175
+ }
176
+
177
+ if (listed.length === 0) {
178
+ // Effort aliases always dispatch to Antigravity, whatever their name looks like.
179
+ const ownerId =
180
+ findProviderForModel(model, {
181
+ ollamaModels: new Set(source.getOllamaModels?.() ?? []),
182
+ codexModels: new Set(source.getCodexModels?.() ?? []),
183
+ })?.id ?? (getEffortRoutingRule(model) ? "google-antigravity" : null);
184
+ if (ownerId && isTurnedOff(settings, catalog, ownerId, model)) {
185
+ return { kind: "off", providerIds: [ownerId] };
186
+ }
187
+ return { kind: "unlisted" };
188
+ }
189
+
190
+ const on = listed.filter((entry) => entry.offReason === null);
191
+ if (on.length === 0) {
192
+ return { kind: "off", providerIds: [...new Set(listed.map((entry) => entry.providerId))] };
193
+ }
194
+ const chosen = on.find((entry) => source.hasActiveProvider?.(entry.providerId) ?? true) ?? on[0];
195
+ return { kind: "provider", providerId: chosen.providerId, modelId: chosen.id };
196
+ }
197
+
198
+ /**
199
+ * Whether `providerId` may not serve `model`: the provider is off, the model's
200
+ * key is turned off, or the provider lists it and it waits for review. Unlisted
201
+ * ids are checked against explicit keys only, since review applies to listed
202
+ * models.
203
+ */
204
+ function isTurnedOff(settings: ModelSettings, catalog: CatalogModel[], providerId: string, model: string): boolean {
205
+ if (settings.disabledProviders.has(providerId)) return true;
206
+ const wanted = fold(model);
207
+ const listed = catalog.find((entry) => entry.providerId === providerId && fold(entry.id) === wanted);
208
+ if (listed) return listed.offReason !== null;
209
+ return settings.disabledModels.has(fold(modelKey(providerId, model)));
210
+ }
211
+
212
+ /** The parts of a request the switches are checked against. */
213
+ export interface RequestModels {
214
+ /** Id sent upstream (after aliasing). */
215
+ model: string;
216
+ /** Concrete model or effort alias requested before target selection. */
217
+ requestedModel?: string;
218
+ /** Catalog id the request resolved to before upstream aliasing, if different. */
219
+ catalogModel?: string;
220
+ /** Provider already chosen for the request. */
221
+ providerId?: string;
222
+ }
223
+
224
+ /**
225
+ * Whether a request about to be sent targets a model or provider that is
226
+ * turned off. Checks the requested id, selected catalog id, and upstream id
227
+ * (plus their upstream aliases), against the pinned provider when there is
228
+ * one and against routing otherwise.
229
+ */
230
+ export function isRequestOff(source: ModelCatalogSource, request: RequestModels): boolean {
231
+ const ids = new Set<string>();
232
+ for (const id of [request.requestedModel, request.catalogModel, request.model]) {
233
+ if (!id) continue;
234
+ ids.add(id);
235
+ ids.add(applyModelAlias(id));
236
+ }
237
+ if (request.providerId) {
238
+ const settings = readSettings(source.getConfig?.());
239
+ const catalog = listFor(source, settings);
240
+ return [...ids].some((id) => isTurnedOff(settings, catalog, request.providerId!, id));
241
+ }
242
+ return [...ids].some((id) => resolveModelRoute(source, id).kind === "off");
243
+ }
244
+
245
+ /** Whether one provider may send this model upstream (benchmarks, kickstarts). */
246
+ export function isProviderModelOff(source: ModelCatalogSource, providerId: string, model: string): boolean {
247
+ return isRequestOff(source, { model, providerId });
248
+ }
249
+
250
+ /** Provider that serves a model, or null to fall back to the caller's own checks. */
251
+ export function routedProviderId(source: ModelCatalogSource, model: string): string | null {
252
+ const route = resolveModelRoute(source, model);
253
+ return route.kind === "provider" ? route.providerId : null;
254
+ }
255
+
256
+ /** Client-facing explanation for a request to a model that is turned off. */
257
+ export function modelOffMessage(model: string): string {
258
+ return `The model '${model}' is turned off on this rotator. Turn it back on from the dashboard's Models page.`;
259
+ }
260
+
261
+ // ── Settings updates ─────────────────────────────────────────────────────
262
+ // Each returns only the config fields it changes.
263
+
264
+ type ModelConfigPatch = Pick<
265
+ Config,
266
+ "providerOrder" | "disabledProviders" | "disabledModels" | "autoEnableNewModels" | "reviewedModels"
267
+ >;
268
+
269
+ export function setProviderTurnedOff(config: Config, providerId: string, off: boolean): Partial<ModelConfigPatch> {
270
+ const rest = (config.disabledProviders ?? []).filter((id) => id !== providerId);
271
+ return { disabledProviders: off ? [...rest, providerId] : rest };
272
+ }
273
+
274
+ export function setModelsTurnedOff(config: Config, keys: string[], off: boolean): Partial<ModelConfigPatch> {
275
+ const folded = new Set(keys.map(fold));
276
+ const disabled = (config.disabledModels ?? []).filter((key) => !folded.has(fold(key)));
277
+ const patch: Partial<ModelConfigPatch> = { disabledModels: off ? [...disabled, ...keys] : disabled };
278
+ if (config.autoEnableNewModels === false) {
279
+ // A decision either way means the model has been reviewed.
280
+ const reviewed = config.reviewedModels ?? [];
281
+ const known = new Set(reviewed.map(fold));
282
+ patch.reviewedModels = [...reviewed, ...keys.filter((key) => !known.has(fold(key)))];
283
+ }
284
+ return patch;
285
+ }
286
+
287
+ /**
288
+ * Turning automatic enabling off records every model listed now as reviewed,
289
+ * so only models found later wait for review. Turning it back on forgets the
290
+ * list, and anything waiting is served.
291
+ */
292
+ export function setAutoEnableNewModels(
293
+ source: ModelCatalogSource,
294
+ on: boolean,
295
+ ): Partial<ModelConfigPatch> {
296
+ if (on) return { autoEnableNewModels: true, reviewedModels: undefined };
297
+ const config = source.getConfig?.();
298
+ if (config?.autoEnableNewModels === false) return {};
299
+ const current = listFor(source, readSettings({ ...config, autoEnableNewModels: true }));
300
+ return {
301
+ autoEnableNewModels: false,
302
+ reviewedModels: current.map((entry) => modelKey(entry.providerId, entry.id)),
303
+ };
304
+ }
@@ -65,6 +65,22 @@ export interface TierRanking {
65
65
  [tier: string]: number;
66
66
  }
67
67
 
68
+ /** One model a provider can serve, as listed on the dashboard's Models page. */
69
+ export interface ProviderModel {
70
+ id: string;
71
+ contextWindow: number | null;
72
+ /** Quota row the model draws from (`account.quota[].modelKey`). */
73
+ quotaPool: string;
74
+ /** Built into the rotator, or found at runtime from the provider. */
75
+ source: "catalog" | "discovered";
76
+ }
77
+
78
+ /** Model ids the rotator discovers at runtime for providers without a fixed list. */
79
+ export interface ModelListContext {
80
+ ollamaModels: readonly string[];
81
+ codexModels: readonly string[];
82
+ }
83
+
68
84
  export interface ProviderFeatures {
69
85
  /** Project/model circuit breakers on repeated 429s (opt-in via config). */
70
86
  circuitBreakers: boolean;
@@ -141,6 +157,8 @@ export interface ProviderAdapter {
141
157
  clearQuotaCache?(account: AccountRuntime): void;
142
158
 
143
159
  // --- Catalog / helpers ---
160
+ /** Every model this provider can serve right now. */
161
+ listModels(context: ModelListContext): ProviderModel[];
144
162
  /** Whether a model belongs to this provider. */
145
163
  ownsModel?(
146
164
  model: string,
@@ -10,7 +10,7 @@
10
10
  // separately in `src/compat/model-specs.ts` via `maxOutputTokens`.
11
11
 
12
12
  import { dynamicCatalog } from "./dynamic-catalog.js";
13
- import { getModelSpecOverride } from "../../compat/model-specs.js";
13
+ import { getModelSpec, getModelSpecOverride } from "../../compat/model-specs.js";
14
14
 
15
15
  export interface AntigravityModelSpec {
16
16
  id: string;
@@ -106,3 +106,192 @@ export function getAntigravityContextWindow(model: string): number {
106
106
  if (lower.includes("gpt-oss")) return GPT_OSS_DEFAULT_CONTEXT_WINDOW;
107
107
  return FALLBACK_CONTEXT_WINDOW;
108
108
  }
109
+
110
+ // Static Antigravity models every install lists, before dynamic discovery adds
111
+ // the models each account reports.
112
+ const MODEL_CATALOG = [
113
+ {
114
+ id: "gemini-3-flash",
115
+ family: "gemini-3-flash",
116
+ ctx: 1048576,
117
+ quotaPool: "gemini",
118
+ multimodal: true,
119
+ tools: true,
120
+ },
121
+ {
122
+ id: "gemini-3.6-flash-high",
123
+ family: "gemini-3.6-flash",
124
+ ctx: 1048576,
125
+ quotaPool: "gemini",
126
+ multimodal: true,
127
+ tools: true,
128
+ },
129
+ {
130
+ id: "gemini-3.6-flash-medium",
131
+ family: "gemini-3.6-flash",
132
+ ctx: 1048576,
133
+ quotaPool: "gemini",
134
+ multimodal: true,
135
+ tools: true,
136
+ },
137
+ {
138
+ id: "gemini-3.6-flash-low",
139
+ family: "gemini-3.6-flash",
140
+ ctx: 1048576,
141
+ quotaPool: "gemini",
142
+ multimodal: true,
143
+ tools: true,
144
+ },
145
+ {
146
+ id: "gemini-3.6-flash-tiered",
147
+ family: "gemini-3.6-flash",
148
+ ctx: 1048576,
149
+ quotaPool: "gemini",
150
+ multimodal: true,
151
+ tools: true,
152
+ },
153
+ {
154
+ id: "gemini-3.7-flash-tiered",
155
+ family: "gemini-3.7-flash",
156
+ ctx: 1048576,
157
+ quotaPool: "gemini",
158
+ multimodal: true,
159
+ tools: true,
160
+ },
161
+ {
162
+ id: "gemini-3.8-flash-high",
163
+ family: "gemini-3.8-flash",
164
+ ctx: 1048576,
165
+ quotaPool: "gemini",
166
+ multimodal: true,
167
+ tools: true,
168
+ },
169
+ {
170
+ id: "gemini-3.8-flash-medium",
171
+ family: "gemini-3.8-flash",
172
+ ctx: 1048576,
173
+ quotaPool: "gemini",
174
+ multimodal: true,
175
+ tools: true,
176
+ },
177
+ {
178
+ id: "gemini-3.8-flash-low",
179
+ family: "gemini-3.8-flash",
180
+ ctx: 1048576,
181
+ quotaPool: "gemini",
182
+ multimodal: true,
183
+ tools: true,
184
+ },
185
+ {
186
+ id: "gemini-3.1-pro-low",
187
+ family: "gemini-3.1-pro",
188
+ ctx: 1048576,
189
+ quotaPool: "gemini",
190
+ multimodal: true,
191
+ tools: true,
192
+ },
193
+ {
194
+ id: "gemini-3.1-pro-high",
195
+ family: "gemini-3.1-pro",
196
+ ctx: 1048576,
197
+ quotaPool: "gemini",
198
+ multimodal: true,
199
+ tools: true,
200
+ },
201
+ {
202
+ id: "claude-sonnet-4-6",
203
+ family: "claude",
204
+ ctx: 1000000,
205
+ quotaPool: "claude",
206
+ multimodal: true,
207
+ tools: true,
208
+ },
209
+ {
210
+ id: "claude-opus-4-6-thinking",
211
+ family: "claude",
212
+ ctx: 1000000,
213
+ quotaPool: "claude",
214
+ multimodal: true,
215
+ tools: true,
216
+ },
217
+ {
218
+ id: "gpt-oss-120b-medium",
219
+ family: "gpt-oss",
220
+ ctx: 131072,
221
+ quotaPool: "claude",
222
+ multimodal: false,
223
+ tools: true,
224
+ },
225
+ {
226
+ id: "gemini-3.5-flash-lite",
227
+ family: "gemini-3.5-flash",
228
+ ctx: 1048576,
229
+ quotaPool: "gemini",
230
+ multimodal: true,
231
+ tools: true,
232
+ },
233
+ {
234
+ id: "whisper-1",
235
+ family: "gemini-3.8-flash",
236
+ ctx: 1048576,
237
+ quotaPool: "gemini",
238
+ multimodal: true,
239
+ tools: false,
240
+ },
241
+ ] as const;
242
+
243
+ /** Whether the rotator ships this id, as opposed to an account reporting it. */
244
+ export function isBuiltInAntigravityModel(model: string): boolean {
245
+ const wanted = model.trim().toLowerCase();
246
+ return MODEL_CATALOG.some((entry) => entry.id.toLowerCase() === wanted);
247
+ }
248
+
249
+ export interface CompatModelEntry {
250
+ id: string;
251
+ family: string;
252
+ ctx: number;
253
+ quotaPool: string;
254
+ multimodal: boolean;
255
+ tools: boolean;
256
+ maxOutputTokens: number;
257
+ thinkingBudget: number;
258
+ minThinkingBudget?: number;
259
+ isThinking: boolean;
260
+ }
261
+
262
+ export function getEffectiveAntigravityModels(): CompatModelEntry[] {
263
+ const dynamic = dynamicCatalog.getAllModels();
264
+ const seen = new Set(MODEL_CATALOG.map((model) => model.id.toLowerCase()));
265
+ const result: CompatModelEntry[] = MODEL_CATALOG.map((model) => {
266
+ const spec = getModelSpec(model.id);
267
+ const contextWindow = getModelSpecOverride(model.id)?.contextWindow ??
268
+ dynamicCatalog.getModelSpec(model.id)?.contextWindow;
269
+ return {
270
+ ...model,
271
+ ctx: contextWindow ?? model.ctx,
272
+ maxOutputTokens: spec.maxOutputTokens,
273
+ thinkingBudget: spec.thinkingBudget,
274
+ minThinkingBudget: spec.minThinkingBudget,
275
+ isThinking: spec.isThinking,
276
+ };
277
+ });
278
+ for (const m of dynamic) {
279
+ if (seen.has(m.id.toLowerCase())) continue;
280
+ seen.add(m.id.toLowerCase());
281
+ const spec = getModelSpec(m.id);
282
+ result.push({
283
+ id: m.id,
284
+ family: m.family,
285
+ ctx: spec.contextWindow ?? m.ctx,
286
+ quotaPool: m.quotaPool,
287
+ multimodal: m.multimodal,
288
+ tools: m.tools,
289
+ maxOutputTokens: spec.maxOutputTokens,
290
+ thinkingBudget: spec.thinkingBudget,
291
+ minThinkingBudget: spec.minThinkingBudget,
292
+ isThinking: spec.isThinking,
293
+ });
294
+ }
295
+
296
+ return result;
297
+ }
@@ -332,6 +332,8 @@ export async function forwardRequest(
332
332
 
333
333
  const {
334
334
  displayModel: _displayModel,
335
+ requestedModel: _requestedModel,
336
+ catalogModel: _catalogModel,
335
337
  providerId: _providerId,
336
338
  selectionMode: _selectionMode,
337
339
  selectionConfidence: _selectionConfidence,
@@ -7,8 +7,10 @@
7
7
 
8
8
  import type {
9
9
  ProviderAdapter,
10
+ ProviderModel,
10
11
  QuotaFetchContext,
11
12
  } from "../adapter.js";
13
+ import { getEffectiveAntigravityModels, isBuiltInAntigravityModel } from "./catalog.js";
12
14
  import { fetchProviderQuota } from "./quota.js";
13
15
  import {
14
16
  forwardRequest,
@@ -168,6 +170,15 @@ export const googleAntigravityAdapter: ProviderAdapter = {
168
170
  );
169
171
  },
170
172
 
173
+ listModels(): ProviderModel[] {
174
+ return getEffectiveAntigravityModels().map((model) => ({
175
+ id: model.id,
176
+ contextWindow: model.ctx,
177
+ quotaPool: model.quotaPool,
178
+ source: isBuiltInAntigravityModel(model.id) ? "catalog" : "discovered",
179
+ }));
180
+ },
181
+
171
182
  ownsModel(model: string): boolean {
172
183
  return resolveQuotaModelKey(model) !== null || model.includes("gemini") || model.includes("claude");
173
184
  },