tuxevil-rotator 4.2.1 → 4.3.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 +48 -1
- package/README.md +20 -6
- package/package.json +3 -3
- package/plugins/opencode-discovery/capabilities.d.mts +7 -0
- package/plugins/opencode-discovery/capabilities.mjs +54 -0
- package/plugins/opencode-discovery/index.d.mts +60 -0
- package/plugins/opencode-discovery/index.mjs +333 -0
- package/plugins/opencode-discovery/package.json +24 -0
- package/src/audio-transcription.ts +32 -6
- package/src/cli.ts +3 -3
- package/src/compat/model-specs.ts +4 -0
- package/src/compat.ts +34 -6
- package/src/dashboard-app.ts +1 -0
- package/src/install-agent.ts +252 -143
- package/src/install-opencode.ts +211 -43
- package/src/providers/google-antigravity/catalog.ts +45 -166
- package/src/providers/google-antigravity/dynamic-catalog.ts +107 -10
- package/src/providers/google-antigravity/forward.ts +4 -2
- package/src/providers/google-antigravity/index.ts +12 -4
- package/src/providers/google-antigravity/quota.ts +9 -7
- package/src/providers/ollama/forward.ts +10 -0
- package/src/providers/openai-codex/catalog.ts +157 -18
- package/src/proxy.ts +54 -5
- package/src/rotator.ts +32 -22
- package/src/types.ts +79 -67
- package/src/web/app.tsx +4 -0
- package/src/web/lib/audio-recorder.ts +159 -0
- package/src/web/lib/colors.ts +4 -0
- package/src/web/lib/playground-storage.ts +261 -0
- package/src/web/lib/playground.ts +448 -0
- package/src/web/nav.ts +1 -0
- package/src/web/pages/Playground.tsx +1111 -0
- package/src/web/pages/Transcription.tsx +428 -0
- package/src/web/state/api.ts +3 -0
- package/src/web/state/playground-client.ts +136 -0
- package/src/web/state/playground.ts +69 -0
- package/src/web/state/router.ts +2 -2
- package/src/web/state/transcription-client.ts +93 -0
- package/src/web/styles/app.css +45 -0
- package/tools/telemetry-receiver/receiver.js +59 -46
- package/plugins/opencode-discovery.js +0 -174
package/src/install-opencode.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
import { mergeOpenCodeModels } from "../plugins/opencode-discovery/capabilities.mjs";
|
|
2
|
+
import type { RawRotatorModel } from "../plugins/opencode-discovery/index.mjs";
|
|
1
3
|
import { execSync } from "node:child_process";
|
|
2
4
|
import { readFileSync, existsSync } from "node:fs";
|
|
3
5
|
import { resolve, dirname } from "node:path";
|
|
4
6
|
import { fileURLToPath } from "node:url";
|
|
5
7
|
|
|
6
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const
|
|
9
|
+
const PLUGIN_SOURCE_DIR = resolve(__dirname, "../plugins/opencode-discovery");
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Files shipped from the repo plugin directory to the target machine.
|
|
13
|
+
* Keep in sync with plugins/opencode-discovery/.
|
|
14
|
+
*/
|
|
15
|
+
const PLUGIN_RUNTIME_SOURCE_FILES = [
|
|
16
|
+
"index.mjs",
|
|
17
|
+
"package.json",
|
|
18
|
+
"capabilities.mjs",
|
|
19
|
+
];
|
|
8
20
|
|
|
9
21
|
export interface InstallOptions {
|
|
10
22
|
host?: string;
|
|
@@ -19,45 +31,158 @@ export interface InstallOptions {
|
|
|
19
31
|
dryRun?: boolean;
|
|
20
32
|
}
|
|
21
33
|
|
|
34
|
+
export interface DiscoveryConfigInput {
|
|
35
|
+
pluginDir: string;
|
|
36
|
+
providerID: string;
|
|
37
|
+
providerName: string;
|
|
38
|
+
baseURL: string;
|
|
39
|
+
apiKey?: string;
|
|
40
|
+
models?: RawRotatorModel[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Pure config mutation shared in spirit with the self-contained node script
|
|
45
|
+
* embedded in buildRemoteInstallerScript (which runs on hosts without this TS
|
|
46
|
+
* module, so it carries its own copy — keep both in sync).
|
|
47
|
+
*
|
|
48
|
+
* Config form written for OpenCode 2.x:
|
|
49
|
+
* "plugins": [{ "package": pluginDir, "options": {...} }]
|
|
50
|
+
*
|
|
51
|
+
* Legacy cleanup: discovery entries are scrubbed from both the V2 "plugins"
|
|
52
|
+
* list and the legacy "plugin" key; other legacy entries are left untouched
|
|
53
|
+
* (OpenCode migrates them on its own).
|
|
54
|
+
*/
|
|
55
|
+
export function applyDiscoveryPluginConfig(
|
|
56
|
+
config: Record<string, unknown>,
|
|
57
|
+
{
|
|
58
|
+
pluginDir,
|
|
59
|
+
providerID,
|
|
60
|
+
providerName,
|
|
61
|
+
baseURL,
|
|
62
|
+
apiKey,
|
|
63
|
+
models,
|
|
64
|
+
}: DiscoveryConfigInput,
|
|
65
|
+
): Record<string, unknown> {
|
|
66
|
+
const isDiscoveryEntry = (entry: unknown): boolean => {
|
|
67
|
+
if (typeof entry === "string") return entry.includes("opencode-discovery");
|
|
68
|
+
if (Array.isArray(entry)) {
|
|
69
|
+
return (
|
|
70
|
+
typeof entry[0] === "string" && entry[0].includes("opencode-discovery")
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (entry && typeof entry === "object") {
|
|
74
|
+
const pkg = (entry as { package?: unknown }).package;
|
|
75
|
+
return typeof pkg === "string" && pkg.includes("opencode-discovery");
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
config.plugins = Array.isArray(config.plugins)
|
|
81
|
+
? (config.plugins as unknown[]).filter((entry) => !isDiscoveryEntry(entry))
|
|
82
|
+
: [];
|
|
83
|
+
|
|
84
|
+
if (Array.isArray(config.plugin)) {
|
|
85
|
+
const kept = (config.plugin as unknown[]).filter(
|
|
86
|
+
(entry) => !isDiscoveryEntry(entry),
|
|
87
|
+
);
|
|
88
|
+
if (kept.length > 0) {
|
|
89
|
+
config.plugin = kept;
|
|
90
|
+
} else {
|
|
91
|
+
delete config.plugin;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
(config.plugins as unknown[]).push({
|
|
96
|
+
package: pluginDir,
|
|
97
|
+
options: { baseURL, providerID, providerName },
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (!config.$schema) {
|
|
101
|
+
config.$schema = "https://opencode.ai/config.json";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!config.provider) {
|
|
105
|
+
config.provider = {};
|
|
106
|
+
}
|
|
107
|
+
const provider = config.provider as Record<string, Record<string, unknown>>;
|
|
108
|
+
const existing = provider[providerID] ?? {};
|
|
109
|
+
|
|
110
|
+
provider[providerID] = {
|
|
111
|
+
...(existing as object),
|
|
112
|
+
...(models?.length
|
|
113
|
+
? {
|
|
114
|
+
models: mergeOpenCodeModels(
|
|
115
|
+
existing.models as Record<string, unknown>,
|
|
116
|
+
models,
|
|
117
|
+
),
|
|
118
|
+
}
|
|
119
|
+
: {}),
|
|
120
|
+
npm: "@ai-sdk/openai-compatible",
|
|
121
|
+
name: providerName,
|
|
122
|
+
options: {
|
|
123
|
+
...((existing.options as object) ?? {}),
|
|
124
|
+
baseURL,
|
|
125
|
+
...(apiKey && apiKey !== "no-key" ? { apiKey } : {}),
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
if (!config.model) {
|
|
130
|
+
config.model = `${providerID}/gemini-3.8-flash-high`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return config;
|
|
134
|
+
}
|
|
135
|
+
|
|
22
136
|
/**
|
|
23
137
|
* Builds the remote installation script that will execute on the target machine.
|
|
24
138
|
*/
|
|
25
139
|
export function buildRemoteInstallerScript(
|
|
26
|
-
|
|
140
|
+
pluginFiles: Record<string, string>,
|
|
27
141
|
options: {
|
|
28
142
|
rotatorUrl: string;
|
|
29
143
|
providerId: string;
|
|
30
144
|
providerName: string;
|
|
31
145
|
apiKey?: string;
|
|
32
146
|
targetDir?: string;
|
|
33
|
-
}
|
|
147
|
+
},
|
|
34
148
|
): string {
|
|
35
|
-
|
|
149
|
+
if (!PLUGIN_RUNTIME_SOURCE_FILES.every((name) => name in pluginFiles)) {
|
|
150
|
+
throw new Error(
|
|
151
|
+
`pluginFiles must include all of: ${PLUGIN_RUNTIME_SOURCE_FILES.join(", ")}`,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
36
155
|
const targetDir = options.targetDir || "~/.config/opencode";
|
|
37
156
|
const providerId = options.providerId || "antigravity";
|
|
38
157
|
const providerName = options.providerName || "Antigravity (rotator)";
|
|
39
158
|
const rotatorUrl = options.rotatorUrl;
|
|
40
159
|
const apiKey = options.apiKey;
|
|
41
160
|
|
|
161
|
+
const fileWriteLines = PLUGIN_RUNTIME_SOURCE_FILES.map((name) => {
|
|
162
|
+
const base64 = Buffer.from(pluginFiles[name], "utf8").toString("base64");
|
|
163
|
+
return `echo "${base64}" | base64 -d > "$PLUGIN_DIR/${name}"`;
|
|
164
|
+
}).join("\n");
|
|
165
|
+
|
|
42
166
|
return `
|
|
43
167
|
set -e
|
|
44
168
|
TARGET_DIR="${targetDir}"
|
|
45
169
|
eval TARGET_DIR="$TARGET_DIR"
|
|
46
170
|
|
|
47
|
-
mkdir -p "$TARGET_DIR/plugins"
|
|
48
|
-
|
|
171
|
+
mkdir -p "$TARGET_DIR/plugins/opencode-discovery"
|
|
172
|
+
PLUGIN_DIR="$TARGET_DIR/plugins/opencode-discovery"
|
|
49
173
|
CONFIG_FILE="$TARGET_DIR/opencode.json"
|
|
50
174
|
|
|
51
|
-
echo "==> Writing plugin to $
|
|
52
|
-
|
|
175
|
+
echo "==> Writing plugin to $PLUGIN_DIR/index.mjs..."
|
|
176
|
+
${fileWriteLines}
|
|
53
177
|
|
|
54
|
-
# Prepare node script to cleanly mutate or create opencode.json
|
|
178
|
+
# Prepare node script to cleanly mutate or create opencode.json (OpenCode 2.x form)
|
|
55
179
|
node -e '
|
|
180
|
+
(async () => {
|
|
56
181
|
const fs = require("fs");
|
|
57
182
|
const path = require("path");
|
|
58
183
|
|
|
59
184
|
const configFile = process.argv[1];
|
|
60
|
-
const
|
|
185
|
+
const pluginDir = process.argv[2];
|
|
61
186
|
const providerID = process.argv[3];
|
|
62
187
|
const providerName = process.argv[4];
|
|
63
188
|
const baseURL = process.argv[5];
|
|
@@ -66,8 +191,7 @@ const apiKey = process.argv[6];
|
|
|
66
191
|
let config = {};
|
|
67
192
|
if (fs.existsSync(configFile)) {
|
|
68
193
|
try {
|
|
69
|
-
|
|
70
|
-
config = JSON.parse(raw);
|
|
194
|
+
config = JSON.parse(fs.readFileSync(configFile, "utf8"));
|
|
71
195
|
} catch (err) {
|
|
72
196
|
console.error("Warning: parsing existing " + configFile + " failed, backing up to .bak");
|
|
73
197
|
fs.copyFileSync(configFile, configFile + ".bak." + Date.now());
|
|
@@ -78,26 +202,33 @@ if (!config.$schema) {
|
|
|
78
202
|
config.$schema = "https://opencode.ai/config.json";
|
|
79
203
|
}
|
|
80
204
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
205
|
+
const isDiscoveryEntry = (entry) => {
|
|
206
|
+
if (typeof entry === "string") return entry.includes("opencode-discovery");
|
|
207
|
+
if (Array.isArray(entry)) {
|
|
208
|
+
return typeof entry[0] === "string" && entry[0].includes("opencode-discovery");
|
|
209
|
+
}
|
|
210
|
+
if (entry && typeof entry === "object") {
|
|
211
|
+
return typeof entry.package === "string" && entry.package.includes("opencode-discovery");
|
|
212
|
+
}
|
|
213
|
+
return false;
|
|
214
|
+
};
|
|
84
215
|
|
|
85
|
-
//
|
|
86
|
-
config.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
216
|
+
// V2 plugin list: scrub prior discovery entries, then register the directory
|
|
217
|
+
config.plugins = Array.isArray(config.plugins) ? config.plugins.filter(p => !isDiscoveryEntry(p)) : [];
|
|
218
|
+
config.plugins.push({
|
|
219
|
+
package: pluginDir,
|
|
220
|
+
options: { baseURL, providerID, providerName }
|
|
90
221
|
});
|
|
91
222
|
|
|
92
|
-
//
|
|
93
|
-
config.plugin
|
|
94
|
-
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
223
|
+
// Legacy V1 key: scrub discovery entries, keep everything else untouched
|
|
224
|
+
if (Array.isArray(config.plugin)) {
|
|
225
|
+
const kept = config.plugin.filter(p => !isDiscoveryEntry(p));
|
|
226
|
+
if (kept.length > 0) {
|
|
227
|
+
config.plugin = kept;
|
|
228
|
+
} else {
|
|
229
|
+
delete config.plugin;
|
|
99
230
|
}
|
|
100
|
-
|
|
231
|
+
}
|
|
101
232
|
|
|
102
233
|
if (!config.provider) {
|
|
103
234
|
config.provider = {};
|
|
@@ -122,13 +253,23 @@ if (apiKey && apiKey !== "no-key") {
|
|
|
122
253
|
config.provider[providerID].options.apiKey = apiKey;
|
|
123
254
|
}
|
|
124
255
|
|
|
256
|
+
const { fetchModels, mergeOpenCodeModels } = await import(require("url").pathToFileURL(path.join(pluginDir, "capabilities.mjs")).href);
|
|
257
|
+
try {
|
|
258
|
+
const live = await fetchModels(baseURL, apiKey);
|
|
259
|
+
config.provider[providerID].models = mergeOpenCodeModels(config.provider[providerID].models, live);
|
|
260
|
+
} catch {
|
|
261
|
+
console.warn("==> Catalog unavailable; existing models retained. Discovery will retry at startup.");
|
|
262
|
+
}
|
|
263
|
+
|
|
125
264
|
if (!config.model) {
|
|
126
265
|
config.model = providerID + "/gemini-3.8-flash-high";
|
|
127
266
|
}
|
|
128
267
|
|
|
268
|
+
if (fs.existsSync(configFile)) fs.copyFileSync(configFile, configFile + ".bak." + Date.now());
|
|
129
269
|
fs.writeFileSync(configFile, JSON.stringify(config, null, 2) + "\\n", "utf8");
|
|
130
270
|
console.log("==> Successfully updated " + configFile);
|
|
131
|
-
|
|
271
|
+
})().catch(error => { console.error(error.message); process.exitCode = 1; });
|
|
272
|
+
' "$CONFIG_FILE" "$PLUGIN_DIR" "${providerId}" "${providerName}" "${rotatorUrl}" "${apiKey || ""}"
|
|
132
273
|
|
|
133
274
|
echo "==> Installation complete! OpenCode is now configured to discover models from ${rotatorUrl}"
|
|
134
275
|
`;
|
|
@@ -137,17 +278,29 @@ echo "==> Installation complete! OpenCode is now configured to discover models f
|
|
|
137
278
|
/**
|
|
138
279
|
* Installs the discovery plugin either locally or remotely via SSH.
|
|
139
280
|
*/
|
|
140
|
-
export async function installOpenCodePlugin(
|
|
141
|
-
|
|
142
|
-
|
|
281
|
+
export async function installOpenCodePlugin(
|
|
282
|
+
options: InstallOptions,
|
|
283
|
+
): Promise<void> {
|
|
284
|
+
const pluginFiles: Record<string, string> = {};
|
|
285
|
+
for (const name of PLUGIN_RUNTIME_SOURCE_FILES) {
|
|
286
|
+
const filePath = resolve(PLUGIN_SOURCE_DIR, name);
|
|
287
|
+
if (!existsSync(filePath)) {
|
|
288
|
+
throw new Error(
|
|
289
|
+
`Plugin directory ${PLUGIN_SOURCE_DIR} does not contain ${name}`,
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
pluginFiles[name] = readFileSync(filePath, "utf8");
|
|
143
293
|
}
|
|
144
294
|
|
|
145
|
-
const
|
|
146
|
-
|
|
295
|
+
const rotatorUrl = (
|
|
296
|
+
options.rotatorUrl ||
|
|
297
|
+
process.env.TUXEVIL_ROTATOR_BASE_URL ||
|
|
298
|
+
"http://127.0.0.1:51200/v1"
|
|
299
|
+
).replace(/\/+$/, "");
|
|
147
300
|
const providerId = options.providerId || "antigravity";
|
|
148
301
|
const providerName = options.providerName || "Antigravity (rotator)";
|
|
149
302
|
|
|
150
|
-
const script = buildRemoteInstallerScript(
|
|
303
|
+
const script = buildRemoteInstallerScript(pluginFiles, {
|
|
151
304
|
rotatorUrl,
|
|
152
305
|
providerId,
|
|
153
306
|
providerName,
|
|
@@ -162,8 +315,14 @@ export async function installOpenCodePlugin(options: InstallOptions): Promise<vo
|
|
|
162
315
|
}
|
|
163
316
|
|
|
164
317
|
// Local installation
|
|
165
|
-
if (
|
|
166
|
-
|
|
318
|
+
if (
|
|
319
|
+
!options.host ||
|
|
320
|
+
options.host === "localhost" ||
|
|
321
|
+
options.host === "127.0.0.1"
|
|
322
|
+
) {
|
|
323
|
+
console.log(
|
|
324
|
+
`==> Installing OpenCode plugin locally for rotator: ${rotatorUrl}...`,
|
|
325
|
+
);
|
|
167
326
|
execSync("bash -s", {
|
|
168
327
|
input: script,
|
|
169
328
|
stdio: ["pipe", "inherit", "inherit"],
|
|
@@ -172,11 +331,16 @@ export async function installOpenCodePlugin(options: InstallOptions): Promise<vo
|
|
|
172
331
|
}
|
|
173
332
|
|
|
174
333
|
// Remote installation via SSH
|
|
175
|
-
const sshTarget = options.user
|
|
334
|
+
const sshTarget = options.user
|
|
335
|
+
? `${options.user}@${options.host}`
|
|
336
|
+
: options.host;
|
|
176
337
|
const sshArgs: string[] = [
|
|
177
|
-
"-o",
|
|
178
|
-
"
|
|
179
|
-
"-o",
|
|
338
|
+
"-o",
|
|
339
|
+
"BatchMode=yes",
|
|
340
|
+
"-o",
|
|
341
|
+
"ConnectTimeout=10",
|
|
342
|
+
"-o",
|
|
343
|
+
"StrictHostKeyChecking=accept-new",
|
|
180
344
|
];
|
|
181
345
|
|
|
182
346
|
if (options.port) {
|
|
@@ -188,7 +352,9 @@ export async function installOpenCodePlugin(options: InstallOptions): Promise<vo
|
|
|
188
352
|
|
|
189
353
|
const sshCmd = `ssh ${sshArgs.join(" ")} ${sshTarget} "bash -s"`;
|
|
190
354
|
|
|
191
|
-
console.log(
|
|
355
|
+
console.log(
|
|
356
|
+
`==> Installing OpenCode plugin remotely on ${sshTarget} (Rotator: ${rotatorUrl})...`,
|
|
357
|
+
);
|
|
192
358
|
try {
|
|
193
359
|
execSync(sshCmd, {
|
|
194
360
|
input: script,
|
|
@@ -196,6 +362,8 @@ export async function installOpenCodePlugin(options: InstallOptions): Promise<vo
|
|
|
196
362
|
});
|
|
197
363
|
} catch (err: unknown) {
|
|
198
364
|
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
199
|
-
throw new Error(`SSH installation failed on ${sshTarget}: ${errorMsg}`, {
|
|
365
|
+
throw new Error(`SSH installation failed on ${sshTarget}: ${errorMsg}`, {
|
|
366
|
+
cause: err,
|
|
367
|
+
});
|
|
200
368
|
}
|
|
201
369
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import { dynamicCatalog } from "./dynamic-catalog.js";
|
|
13
13
|
import { getModelSpec, getModelSpecOverride } from "../../compat/model-specs.js";
|
|
14
|
+
import { applyModelAlias } from "../../types.js";
|
|
14
15
|
|
|
15
16
|
export interface AntigravityModelSpec {
|
|
16
17
|
id: string;
|
|
@@ -38,6 +39,11 @@ export const ANTIGRAVITY_CONTEXT_WINDOWS: Record<string, number> = {
|
|
|
38
39
|
// OpenAI gpt-oss-120b — 131,072 per platform.openai.com/docs/models/gpt-oss-120b.
|
|
39
40
|
"gpt-oss-120b": 131_072,
|
|
40
41
|
"gpt-oss-120b-medium": 131_072,
|
|
42
|
+
// Google Gemini 4 Argon family — 1M context window.
|
|
43
|
+
"gemini-4-argon": 1_000_000,
|
|
44
|
+
"gemini-4-argon-high": 1_000_000,
|
|
45
|
+
"gemini-4-argon-medium": 1_000_000,
|
|
46
|
+
"gemini-4-argon-low": 1_000_000,
|
|
41
47
|
// Google Gemini 3.x — 1M context window per deepmind.google/models/gemini/*.
|
|
42
48
|
"gemini-3.8-flash-high": 1_000_000,
|
|
43
49
|
"gemini-3.8-flash-medium": 1_000_000,
|
|
@@ -75,8 +81,8 @@ const FALLBACK_CONTEXT_WINDOW = 128_000;
|
|
|
75
81
|
*
|
|
76
82
|
* Lookup order:
|
|
77
83
|
* 1. Operator exact/substring override.
|
|
78
|
-
* 2.
|
|
79
|
-
* 3.
|
|
84
|
+
* 2. Dynamic catalog entry from an account snapshot.
|
|
85
|
+
* 3. Exact id match in static table (lowercased).
|
|
80
86
|
* 4. Substring match across the table (longest key wins via the order here).
|
|
81
87
|
* 5. Family defaults: claude -> 1M, gemini -> 1M, gpt-oss -> 131_072.
|
|
82
88
|
* 6. Defensive fallback: 128_000.
|
|
@@ -89,10 +95,10 @@ export function getAntigravityContextWindow(model: string): number {
|
|
|
89
95
|
if (typeof overrideCtx === "number" && Number.isFinite(overrideCtx) && overrideCtx > 0) {
|
|
90
96
|
return overrideCtx;
|
|
91
97
|
}
|
|
92
|
-
const exact = ANTIGRAVITY_CONTEXT_WINDOWS[lower];
|
|
93
|
-
if (typeof exact === "number") return exact;
|
|
94
98
|
const dynamicCtx = dynamicCatalog.getContextWindow(lower);
|
|
95
99
|
if (typeof dynamicCtx === "number") return dynamicCtx;
|
|
100
|
+
const exact = ANTIGRAVITY_CONTEXT_WINDOWS[lower];
|
|
101
|
+
if (typeof exact === "number") return exact;
|
|
96
102
|
// Substring fallback: pick the longest registered key that appears in lower.
|
|
97
103
|
let best: { key: string; value: number } | null = null;
|
|
98
104
|
for (const [key, value] of Object.entries(ANTIGRAVITY_CONTEXT_WINDOWS)) {
|
|
@@ -107,145 +113,6 @@ export function getAntigravityContextWindow(model: string): number {
|
|
|
107
113
|
return FALLBACK_CONTEXT_WINDOW;
|
|
108
114
|
}
|
|
109
115
|
|
|
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
116
|
export interface CompatModelEntry {
|
|
250
117
|
id: string;
|
|
251
118
|
family: string;
|
|
@@ -261,37 +128,49 @@ export interface CompatModelEntry {
|
|
|
261
128
|
|
|
262
129
|
export function getEffectiveAntigravityModels(): CompatModelEntry[] {
|
|
263
130
|
const dynamic = dynamicCatalog.getAllModels();
|
|
264
|
-
const
|
|
265
|
-
const
|
|
131
|
+
const byId = new Map(dynamic.map((model) => [model.id.toLowerCase(), model]));
|
|
132
|
+
const toCompatModel = (
|
|
133
|
+
model: (typeof dynamic)[number],
|
|
134
|
+
id = model.id,
|
|
135
|
+
tools = model.tools,
|
|
136
|
+
): CompatModelEntry => {
|
|
266
137
|
const spec = getModelSpec(model.id);
|
|
267
|
-
const contextWindow = getModelSpecOverride(model.id)?.contextWindow ??
|
|
268
|
-
dynamicCatalog.getModelSpec(model.id)?.contextWindow;
|
|
269
138
|
return {
|
|
270
|
-
|
|
271
|
-
|
|
139
|
+
id,
|
|
140
|
+
family: model.family,
|
|
141
|
+
ctx: spec.contextWindow ?? model.ctx,
|
|
142
|
+
quotaPool: model.quotaPool,
|
|
143
|
+
multimodal: model.multimodal,
|
|
144
|
+
tools,
|
|
272
145
|
maxOutputTokens: spec.maxOutputTokens,
|
|
273
146
|
thinkingBudget: spec.thinkingBudget,
|
|
274
147
|
minThinkingBudget: spec.minThinkingBudget,
|
|
275
148
|
isThinking: spec.isThinking,
|
|
276
149
|
};
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
maxOutputTokens: spec.maxOutputTokens,
|
|
290
|
-
thinkingBudget: spec.thinkingBudget,
|
|
291
|
-
minThinkingBudget: spec.minThinkingBudget,
|
|
292
|
-
isThinking: spec.isThinking,
|
|
293
|
-
});
|
|
150
|
+
};
|
|
151
|
+
const result = dynamic.map((model) => toCompatModel(model));
|
|
152
|
+
|
|
153
|
+
// Keep the OpenAI audio compatibility name only while its configured target
|
|
154
|
+
// appears in a current Antigravity account snapshot.
|
|
155
|
+
if (!byId.has("whisper-1")) {
|
|
156
|
+
const target = applyModelAlias("whisper-1")
|
|
157
|
+
.trim()
|
|
158
|
+
.replace(/^models\//i, "")
|
|
159
|
+
.toLowerCase();
|
|
160
|
+
const backingModel = byId.get(target);
|
|
161
|
+
if (backingModel) result.push(toCompatModel(backingModel, "whisper-1", false));
|
|
294
162
|
}
|
|
295
163
|
|
|
296
164
|
return result;
|
|
297
165
|
}
|
|
166
|
+
|
|
167
|
+
/** Whether an id or configured operator alias resolves to a current snapshot model. */
|
|
168
|
+
export function isDynamicallyAvailableAntigravityModel(model: string): boolean {
|
|
169
|
+
const normalize = (value: string) => value.trim().replace(/^models\//i, "").toLowerCase();
|
|
170
|
+
const normalized = normalize(model);
|
|
171
|
+
const aliased = normalize(applyModelAlias(model));
|
|
172
|
+
return Boolean(
|
|
173
|
+
dynamicCatalog.getModel(normalized) ??
|
|
174
|
+
dynamicCatalog.getModel(aliased),
|
|
175
|
+
);
|
|
176
|
+
}
|