@heyhuynhgiabuu/pi-oauth-antigravity 0.1.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 (48) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +91 -0
  4. package/dist/auth/index.d.ts +2 -0
  5. package/dist/auth/index.js +1 -0
  6. package/dist/auth/oauth.d.ts +18 -0
  7. package/dist/auth/oauth.js +374 -0
  8. package/dist/client/client.d.ts +35 -0
  9. package/dist/client/client.js +448 -0
  10. package/dist/client/index.d.ts +1 -0
  11. package/dist/client/index.js +1 -0
  12. package/dist/diagnostics/diagnostics.d.ts +31 -0
  13. package/dist/diagnostics/diagnostics.js +68 -0
  14. package/dist/diagnostics/index.d.ts +1 -0
  15. package/dist/diagnostics/index.js +1 -0
  16. package/dist/image/image.d.ts +62 -0
  17. package/dist/image/image.js +244 -0
  18. package/dist/image/index.d.ts +1 -0
  19. package/dist/image/index.js +1 -0
  20. package/dist/index.d.ts +12 -0
  21. package/dist/index.js +182 -0
  22. package/dist/models/index.d.ts +1 -0
  23. package/dist/models/index.js +1 -0
  24. package/dist/models/models.d.ts +44 -0
  25. package/dist/models/models.js +377 -0
  26. package/dist/stream/index.d.ts +1 -0
  27. package/dist/stream/index.js +1 -0
  28. package/dist/stream/stream.d.ts +24 -0
  29. package/dist/stream/stream.js +879 -0
  30. package/dist/types/enums.d.ts +41 -0
  31. package/dist/types/enums.js +49 -0
  32. package/dist/types/index.d.ts +2 -0
  33. package/dist/types/index.js +2 -0
  34. package/dist/types/types.d.ts +259 -0
  35. package/dist/types/types.js +2 -0
  36. package/dist/usage/index.d.ts +1 -0
  37. package/dist/usage/index.js +1 -0
  38. package/dist/usage/usage.d.ts +8 -0
  39. package/dist/usage/usage.js +388 -0
  40. package/dist/utils/http.d.ts +7 -0
  41. package/dist/utils/http.js +81 -0
  42. package/dist/utils/index.d.ts +3 -0
  43. package/dist/utils/index.js +3 -0
  44. package/dist/utils/security.d.ts +8 -0
  45. package/dist/utils/security.js +60 -0
  46. package/dist/utils/util.d.ts +40 -0
  47. package/dist/utils/util.js +176 -0
  48. package/package.json +73 -0
@@ -0,0 +1,244 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import { dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
+ import { antigravityHeaders, endpointCandidates, jsonOrTextError, parseApiKey, } from "../client/client.js";
4
+ import { AntigravityRequestType, AntigravityUserAgent, GeminiRole } from "../types/enums.js";
5
+ import { antigravityFetch } from "../utils/http.js";
6
+ import { safeError } from "../utils/security.js";
7
+ import { antigravityRequestEnvelope, sanitizeText } from "../utils/util.js";
8
+ export const DEFAULT_IMAGE_MODEL = "gemini-3-pro-image";
9
+ export const IMAGE_ASPECT_RATIOS = [
10
+ "1:1",
11
+ "2:3",
12
+ "3:2",
13
+ "3:4",
14
+ "4:3",
15
+ "4:5",
16
+ "5:4",
17
+ "9:16",
18
+ "16:9",
19
+ "21:9",
20
+ ];
21
+ const IMAGE_MODEL_FALLBACKS = [
22
+ DEFAULT_IMAGE_MODEL,
23
+ "gemini-3.1-flash-image",
24
+ "gemini-3-pro-image-preview",
25
+ ];
26
+ const IMAGE_SYSTEM_INSTRUCTION = "You are an AI image generator. Generate images based on user descriptions. Focus on creating high-quality, visually appealing images that match the user's request.";
27
+ const DEFAULT_IMAGE_DIR = join(".pi", "generated-images");
28
+ const MAX_PROMPT_CHARS = 8000;
29
+ function imageExtension(mimeType) {
30
+ const lower = mimeType.toLowerCase();
31
+ if (lower.includes("jpeg") || lower.includes("jpg"))
32
+ return "jpg";
33
+ if (lower.includes("webp"))
34
+ return "webp";
35
+ if (lower.includes("gif"))
36
+ return "gif";
37
+ return "png";
38
+ }
39
+ export function assertSafeImageModel(modelId) {
40
+ const id = modelId.trim();
41
+ if (id.length === 0 || id.length > 80) {
42
+ throw new Error("Unsupported image model id.");
43
+ }
44
+ if (!/^(gemini-[a-z0-9.+-]*image[a-z0-9.+-]*|imagen-[a-z0-9.+-]+)$/i.test(id)) {
45
+ throw new Error(`Unsupported image model: ${id}`);
46
+ }
47
+ return id;
48
+ }
49
+ export function assertSafeAspectRatio(ratio) {
50
+ const value = ratio.trim();
51
+ for (const allowed of IMAGE_ASPECT_RATIOS) {
52
+ if (allowed === value)
53
+ return allowed;
54
+ }
55
+ throw new Error(`Unsupported aspect ratio: ${value}. Use one of ${IMAGE_ASPECT_RATIOS.join(", ")}.`);
56
+ }
57
+ export function parseImageCommandArgs(args) {
58
+ const tokens = args.trim().split(/\s+/).filter(Boolean);
59
+ const out = { prompt: "" };
60
+ const rest = [];
61
+ for (let i = 0; i < tokens.length; i++) {
62
+ const token = tokens[i];
63
+ if (token === undefined)
64
+ continue;
65
+ const next = tokens[i + 1];
66
+ if ((token === "--ratio" || token === "--aspect-ratio") && next) {
67
+ out.aspectRatio = next;
68
+ i += 1;
69
+ continue;
70
+ }
71
+ if (token === "--model" && next) {
72
+ out.model = next;
73
+ i += 1;
74
+ continue;
75
+ }
76
+ if (token === "--path" && next) {
77
+ out.path = next;
78
+ i += 1;
79
+ continue;
80
+ }
81
+ rest.push(token);
82
+ }
83
+ out.prompt = rest.join(" ");
84
+ return out;
85
+ }
86
+ export function resolveImageSavePath(cwd, requested, mimeType = "image/png", index) {
87
+ const ext = imageExtension(mimeType);
88
+ const stamp = new Date().toISOString().replace(/[:.]/g, "-");
89
+ const suffix = index === undefined ? "" : `-${index + 1}`;
90
+ const defaultName = `image-${stamp}${suffix}.${ext}`;
91
+ const root = resolve(cwd);
92
+ const target = requested?.trim()
93
+ ? resolve(root, requested.trim())
94
+ : resolve(root, DEFAULT_IMAGE_DIR, defaultName);
95
+ const rel = relative(root, target);
96
+ if (!rel || rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
97
+ throw new Error("Image save path must be inside the working directory.");
98
+ }
99
+ if (!extname(target))
100
+ return join(target, defaultName);
101
+ if (index === undefined)
102
+ return target;
103
+ const currentExt = extname(target);
104
+ return `${target.slice(0, -currentExt.length)}${suffix}${currentExt}`;
105
+ }
106
+ export function buildImageGenerateRequest(prompt, model, projectId, aspectRatio) {
107
+ const envelope = antigravityRequestEnvelope(model, false);
108
+ return {
109
+ project: projectId,
110
+ model,
111
+ request: {
112
+ contents: [{ role: GeminiRole.User, parts: [{ text: sanitizeText(prompt) }] }],
113
+ systemInstruction: {
114
+ role: GeminiRole.User,
115
+ parts: [{ text: IMAGE_SYSTEM_INSTRUCTION }],
116
+ },
117
+ generationConfig: {
118
+ imageConfig: { aspectRatio },
119
+ candidateCount: 1,
120
+ },
121
+ },
122
+ requestType: AntigravityRequestType.Agent,
123
+ userAgent: AntigravityUserAgent.Antigravity,
124
+ requestId: envelope.requestId,
125
+ };
126
+ }
127
+ function collectImagesFromParts(parts, images, text) {
128
+ for (const part of parts || []) {
129
+ if (part.text)
130
+ text.push(part.text);
131
+ if (part.inlineData?.data) {
132
+ images.push({
133
+ data: part.inlineData.data,
134
+ mimeType: part.inlineData.mimeType || "image/png",
135
+ });
136
+ }
137
+ }
138
+ }
139
+ export async function collectImagesFromSse(response, signal) {
140
+ if (!response.body)
141
+ throw new Error("No response body");
142
+ const reader = response.body.getReader();
143
+ const decoder = new TextDecoder();
144
+ let buffer = "";
145
+ const images = [];
146
+ const text = [];
147
+ try {
148
+ while (true) {
149
+ if (signal?.aborted)
150
+ throw new Error("Request was aborted");
151
+ const result = await reader.read();
152
+ if (result.done)
153
+ break;
154
+ if (!(result.value instanceof Uint8Array))
155
+ continue;
156
+ buffer += decoder.decode(result.value, { stream: true });
157
+ const lines = buffer.split("\n");
158
+ buffer = lines.pop() || "";
159
+ for (const line of lines) {
160
+ if (!line.startsWith("data:"))
161
+ continue;
162
+ const json = line.slice(5).trim();
163
+ if (!json || json === "[DONE]")
164
+ continue;
165
+ let chunk;
166
+ try {
167
+ chunk = JSON.parse(json);
168
+ }
169
+ catch {
170
+ continue;
171
+ }
172
+ if (chunk.error?.message)
173
+ throw new Error(chunk.error.message);
174
+ const responseData = chunk.response || chunk;
175
+ for (const candidate of responseData.candidates || []) {
176
+ collectImagesFromParts(candidate.content?.parts, images, text);
177
+ }
178
+ }
179
+ }
180
+ }
181
+ finally {
182
+ reader.releaseLock();
183
+ }
184
+ return { images, text };
185
+ }
186
+ async function writeImage(filePath, image) {
187
+ await mkdir(dirname(filePath), { recursive: true });
188
+ await writeFile(filePath, Buffer.from(image.data, "base64"));
189
+ return filePath;
190
+ }
191
+ export async function generateAntigravityImage(options) {
192
+ const prompt = options.prompt.trim();
193
+ if (!prompt)
194
+ throw new Error("Image prompt is required.");
195
+ if (prompt.length > MAX_PROMPT_CHARS) {
196
+ throw new Error(`Image prompt is too long (max ${MAX_PROMPT_CHARS} characters).`);
197
+ }
198
+ const aspectRatio = assertSafeAspectRatio(options.aspectRatio || "1:1");
199
+ const preferred = assertSafeImageModel(options.model || DEFAULT_IMAGE_MODEL);
200
+ const models = [preferred, ...IMAGE_MODEL_FALLBACKS.filter((id) => id !== preferred)];
201
+ const creds = parseApiKey(options.apiKey);
202
+ const headers = antigravityHeaders(creds.token);
203
+ let lastError = "no endpoint available";
204
+ for (const model of models) {
205
+ const body = JSON.stringify(buildImageGenerateRequest(prompt, model, creds.projectId, aspectRatio));
206
+ for (const endpoint of endpointCandidates()) {
207
+ if (options.signal?.aborted)
208
+ throw new Error("Request was aborted");
209
+ try {
210
+ const response = await antigravityFetch(`${endpoint}/v1internal:streamGenerateContent?alt=sse`, {
211
+ method: "POST",
212
+ headers,
213
+ body,
214
+ signal: options.signal,
215
+ });
216
+ if (!response.ok) {
217
+ lastError = jsonOrTextError(await response.text()).slice(0, 400);
218
+ if (response.status === 404 || [403, 429, 500, 502, 503, 504].includes(response.status)) {
219
+ continue;
220
+ }
221
+ throw new Error(`Antigravity image request failed (${response.status}): ${safeError(lastError)}`);
222
+ }
223
+ const parsed = await collectImagesFromSse(response, options.signal);
224
+ if (!parsed.images.length) {
225
+ lastError = parsed.text.join(" ").trim() || "No image data returned.";
226
+ continue;
227
+ }
228
+ const savedPaths = [];
229
+ const many = parsed.images.length > 1;
230
+ for (const [index, image] of parsed.images.entries()) {
231
+ savedPaths.push(await writeImage(resolveImageSavePath(options.cwd, options.path, image.mimeType, many ? index : undefined), image));
232
+ }
233
+ return { images: parsed.images, savedPaths, text: parsed.text, model };
234
+ }
235
+ catch (error) {
236
+ lastError = safeError(error);
237
+ if (options.signal?.aborted) {
238
+ throw new Error("Request was aborted", { cause: error });
239
+ }
240
+ }
241
+ }
242
+ }
243
+ throw new Error(`Antigravity image generation failed: ${safeError(lastError)}`);
244
+ }
@@ -0,0 +1 @@
1
+ export * from "./image.js";
@@ -0,0 +1 @@
1
+ export * from "./image.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Vendored from Rahularya01/pi-antigravity@0.6.0 (main 855c5fce, MIT).
3
+ * Local patches on top of upstream:
4
+ * - refreshAntigravityToken accepts and forwards the AbortSignal from Pi's
5
+ * refreshToken(credentials, signal) contract (pi 0.84+).
6
+ * - redactSecrets also matches Google refresh tokens in the "1//04…"
7
+ * double-slash spelling (upstream regex only matched "1/04…").
8
+ * Upgrade: diff upstream src/ against this directory and re-apply local patches,
9
+ * then run `npx tsc -p .pi/extensions/tsconfig.json --noEmit && npm run test:extensions`.
10
+ */
11
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
12
+ export default function (pi: ExtensionAPI): void;
package/dist/index.js ADDED
@@ -0,0 +1,182 @@
1
+ import { StringEnum, Type } from "@earendil-works/pi-ai";
2
+ import { registerApiProvider } from "@earendil-works/pi-ai/compat";
3
+ import { getApiKey, loginAntigravity, refreshAntigravityToken } from "./auth/index.js";
4
+ import { DEFAULT_ENDPOINT, endpointCandidates } from "./client/index.js";
5
+ import { getLastDiagnostics, runWithDiagnostics } from "./diagnostics/index.js";
6
+ import { DEFAULT_IMAGE_MODEL, generateAntigravityImage, IMAGE_ASPECT_RATIOS, parseImageCommandArgs, } from "./image/index.js";
7
+ import { ANTIGRAVITY_MODELS, PROVIDER_ID, PROVIDER_NAME } from "./models/index.js";
8
+ import { ANTIGRAVITY_API, streamAntigravity } from "./stream/index.js";
9
+ import { fetchAccountUsage, formatModelsList, formatUsageSummary, resolveApiKeyFromContext, } from "./usage/index.js";
10
+ import { prewarmConnection, redactSecrets } from "./utils/index.js";
11
+ /**
12
+ * Pi's interactive `notify` writes into the chat transcript. `console.log` in that
13
+ * mode prints to the raw terminal and paints over the TUI. Use one channel only.
14
+ */
15
+ function emitCommandOutput(ctx, text, type = "info") {
16
+ if (ctx.hasUI) {
17
+ ctx.ui.notify(text, type);
18
+ return;
19
+ }
20
+ if (type === "warning" || type === "error")
21
+ console.error(text);
22
+ else
23
+ console.log(text);
24
+ }
25
+ async function withUsage(ctx, fn) {
26
+ try {
27
+ const apiKey = await resolveApiKeyFromContext(ctx);
28
+ if (!apiKey) {
29
+ emitCommandOutput(ctx, "No Antigravity credentials. Run /login antigravity first.", "warning");
30
+ return;
31
+ }
32
+ if (ctx.hasUI)
33
+ ctx.ui.notify("Fetching Antigravity usage…", "info");
34
+ const usage = await runWithDiagnostics(() => fetchAccountUsage(apiKey));
35
+ emitCommandOutput(ctx, fn(usage));
36
+ }
37
+ catch (error) {
38
+ const msg = error instanceof Error ? error.message : String(error);
39
+ emitCommandOutput(ctx, `Antigravity usage failed: ${msg}`, "warning");
40
+ }
41
+ }
42
+ export default function (pi) {
43
+ // Open the TLS connection up front so the first message of a session does not pay
44
+ // the handshake. Opt out with ANTIGRAVITY_NO_PREWARM=1.
45
+ const primaryEndpoint = endpointCandidates()[0];
46
+ if (primaryEndpoint)
47
+ prewarmConnection(primaryEndpoint);
48
+ registerApiProvider({
49
+ api: ANTIGRAVITY_API,
50
+ stream: streamAntigravity,
51
+ streamSimple: streamAntigravity,
52
+ });
53
+ pi.registerProvider(PROVIDER_ID, {
54
+ name: PROVIDER_NAME,
55
+ baseUrl: DEFAULT_ENDPOINT,
56
+ api: ANTIGRAVITY_API,
57
+ models: ANTIGRAVITY_MODELS,
58
+ oauth: {
59
+ name: PROVIDER_NAME,
60
+ login: loginAntigravity,
61
+ refreshToken: refreshAntigravityToken,
62
+ getApiKey,
63
+ },
64
+ streamSimple: streamAntigravity,
65
+ });
66
+ pi.registerCommand("antigravity.usage", {
67
+ description: "Show Antigravity shared quota pools (Gemini / Claude+GPT, 5h + weekly)",
68
+ handler: async (_args, ctx) => {
69
+ await withUsage(ctx, formatUsageSummary);
70
+ },
71
+ });
72
+ pi.registerCommand("antigravity.models", {
73
+ description: "List Antigravity runtime models + remaining pool fraction",
74
+ handler: async (args, ctx) => {
75
+ const all = /\ball\b/i.test(args || "");
76
+ await withUsage(ctx, (usage) => formatModelsList(usage, { all }));
77
+ },
78
+ });
79
+ pi.registerCommand("antigravity.doctor", {
80
+ description: "Show sanitized Antigravity provider diagnostics",
81
+ handler: async (_args, ctx) => {
82
+ const d = getLastDiagnostics();
83
+ const lines = [
84
+ `provider=${PROVIDER_ID}`,
85
+ `lastResolvedRuntimeModel=${d.resolvedRuntimeModel || "none"}`,
86
+ `availableModels=${d.availableModels || "none"}`,
87
+ `matchedModel=${d.matchedModelDebug || "none"}`,
88
+ `lastEndpoint=${d.endpoint || "none"}`,
89
+ `lastStatus=${d.status ?? "none"}`,
90
+ `lastProjectId=${d.projectId || "none"}`,
91
+ ...(d.latencyMs !== undefined ? [`lastLatencyMs=${d.latencyMs}`] : []),
92
+ `lastError=${d.error ? redactSecrets(d.error) : "none"}`,
93
+ "transport=native-streamSimple",
94
+ "runtimeCli=not-used",
95
+ "commands=/antigravity.usage /antigravity.models /antigravity.doctor /antigravity.image",
96
+ ];
97
+ emitCommandOutput(ctx, `Antigravity doctor\n${lines.join("\n")}`);
98
+ },
99
+ });
100
+ pi.registerCommand("antigravity.image", {
101
+ description: "Generate an image via Antigravity (usage: /antigravity.image [--ratio 16:9] <prompt>)",
102
+ handler: async (args, ctx) => {
103
+ const parsed = parseImageCommandArgs(args || "");
104
+ if (!parsed.prompt) {
105
+ emitCommandOutput(ctx, "Usage: /antigravity.image [--ratio 16:9] [--model gemini-3-pro-image] [--path file.png] <prompt>", "warning");
106
+ return;
107
+ }
108
+ try {
109
+ const apiKey = await resolveApiKeyFromContext(ctx);
110
+ if (!apiKey) {
111
+ emitCommandOutput(ctx, "No Antigravity credentials. Run /login antigravity first.", "warning");
112
+ return;
113
+ }
114
+ if (ctx.hasUI)
115
+ ctx.ui.notify("Generating Antigravity image…", "info");
116
+ const result = await generateAntigravityImage({
117
+ apiKey,
118
+ cwd: ctx.cwd,
119
+ prompt: parsed.prompt,
120
+ aspectRatio: parsed.aspectRatio,
121
+ model: parsed.model,
122
+ path: parsed.path,
123
+ });
124
+ emitCommandOutput(ctx, `Saved image to ${result.savedPaths.join(", ")}`);
125
+ }
126
+ catch (error) {
127
+ const msg = error instanceof Error ? error.message : String(error);
128
+ emitCommandOutput(ctx, `Antigravity image failed: ${redactSecrets(msg)}`, "warning");
129
+ }
130
+ },
131
+ });
132
+ pi.registerTool({
133
+ name: "generate_image",
134
+ label: "Generate image",
135
+ description: "Generate an image via Antigravity using the signed-in Google account. Saves under .pi/generated-images/ unless path is set.",
136
+ promptSnippet: "Generate images via Antigravity OAuth (Gemini image models)",
137
+ promptGuidelines: [
138
+ "Use generate_image when the user asks to create, draw, or generate an image.",
139
+ ],
140
+ parameters: Type.Object({
141
+ prompt: Type.String({ description: "Image description." }),
142
+ aspectRatio: Type.Optional(StringEnum(IMAGE_ASPECT_RATIOS)),
143
+ model: Type.Optional(Type.String({
144
+ description: `Image model id. Default: ${DEFAULT_IMAGE_MODEL}.`,
145
+ })),
146
+ path: Type.Optional(Type.String({
147
+ description: "Project-relative file or directory to save the image.",
148
+ })),
149
+ }),
150
+ async execute(_toolCallId, params, signal, onUpdate, ctx) {
151
+ const apiKey = await ctx.modelRegistry.getApiKeyForProvider("antigravity");
152
+ if (!apiKey) {
153
+ throw new Error("No Antigravity credentials. Run /login antigravity first.");
154
+ }
155
+ onUpdate?.({ content: [{ type: "text", text: "Generating image…" }], details: {} });
156
+ const result = await generateAntigravityImage({
157
+ apiKey,
158
+ cwd: ctx.cwd,
159
+ prompt: params.prompt,
160
+ aspectRatio: params.aspectRatio,
161
+ model: params.model,
162
+ path: params.path,
163
+ signal,
164
+ });
165
+ const notes = result.text.join(" ").trim();
166
+ return {
167
+ content: [
168
+ {
169
+ type: "text",
170
+ text: `Saved image to ${result.savedPaths.join(", ")}${notes ? `. ${notes}` : ""}`,
171
+ },
172
+ ...result.images.map((image) => ({
173
+ type: "image",
174
+ data: image.data,
175
+ mimeType: image.mimeType,
176
+ })),
177
+ ],
178
+ details: { model: result.model, savedPaths: result.savedPaths },
179
+ };
180
+ },
181
+ });
182
+ }
@@ -0,0 +1 @@
1
+ export * from "./models.js";
@@ -0,0 +1 @@
1
+ export * from "./models.js";
@@ -0,0 +1,44 @@
1
+ import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
2
+ import type { AntigravityRouting } from "../types/types.js";
3
+ export declare const PROVIDER_ID = "antigravity";
4
+ export declare const PROVIDER_NAME = "Antigravity";
5
+ /**
6
+ * Public selectable model IDs → backend request model IDs by thinking effort.
7
+ *
8
+ * Catalog mirrors `agy models` (Antigravity CLI), which currently advertises:
9
+ * - Gemini 3.8 Flash (Low / Medium / High)
10
+ * - Gemini 3.7 Flash (Low / Medium / High)
11
+ * - Gemini 3.6 Flash (Low / Medium / High)
12
+ * - Gemini 3.5 Flash (Low / Medium / High)
13
+ * - Gemini 3.1 Pro (Low / High)
14
+ * - Claude Sonnet 4.6 (Thinking)
15
+ * - Claude Opus 4.6 (Thinking)
16
+ * - GPT-OSS 120B (Medium)
17
+ *
18
+ * Pi exposes those as public model IDs and only surfaces the exact thinking levels
19
+ * advertised by the backend for each model.
20
+ */
21
+ export declare const ANTIGRAVITY_ROUTING: Record<string, AntigravityRouting>;
22
+ /**
23
+ * Verified maximum output tokens accepted by the Cloud Code Assist backend per model/runtime ID.
24
+ * Requesting more than these limits returns a 400 Bad Request from the API.
25
+ */
26
+ export declare const RUNTIME_MAX_OUTPUT_TOKENS: Record<string, number>;
27
+ export declare function getMaxOutputTokens(modelId: string, runtimeModel?: string): number;
28
+ /** Same set as `agy models`, collapsed to public Pi model IDs. */
29
+ export declare const ANTIGRAVITY_MODELS: ProviderModelConfig[];
30
+ /** Resolve public model id + thinking effort to Antigravity runtime model id. */
31
+ export declare function getAntigravityRequestModelId(modelId: string, effort: string | undefined): string;
32
+ /**
33
+ * If a next-gen model (e.g. Gemini 3.7 Flash) is not yet available on the backend,
34
+ * provide a fallback runtime model ID (e.g. Gemini 3.6 Flash) to maintain availability.
35
+ */
36
+ export declare function getFallbackRuntimeModel(runtimeModel: string, effort?: string): string | undefined;
37
+ export type GeminiThinkingLevel = "MINIMAL" | "LOW" | "MEDIUM" | "HIGH";
38
+ export type ThinkingWire = {
39
+ includeThoughts: boolean;
40
+ thinkingLevel?: GeminiThinkingLevel;
41
+ thinkingBudget?: number;
42
+ };
43
+ export declare const ANTIGRAVITY_MODEL_ENUM: Record<string, string>;
44
+ export declare function getThinkingConfig(modelId: string, effort: string | undefined): ThinkingWire | undefined;