feat(ai): add PI_AI_ANTIGRAVITY_VERSION env var override

Allows users to override the Antigravity User-Agent version when Google
updates their version requirements, avoiding the need to wait for a
package release.

Fixes #1129
This commit is contained in:
Mario Zechner 2026-02-01 09:15:58 +01:00
parent 71d7a14b18
commit e9ca0be769
5 changed files with 29 additions and 10 deletions

View file

@ -2,6 +2,10 @@
## [Unreleased] ## [Unreleased]
### Added
- Added `PI_AI_ANTIGRAVITY_VERSION` environment variable to override the Antigravity User-Agent version when Google updates their version requirements ([#1129](https://github.com/badlogic/pi-mono/issues/1129))
## [0.50.8] - 2026-02-01 ## [0.50.8] - 2026-02-01
### Added ### Added

View file

@ -911,6 +911,14 @@ const response = await complete(model, context, {
}); });
``` ```
#### Antigravity Version Override
Set `PI_AI_ANTIGRAVITY_VERSION` to override the Antigravity User-Agent version when Google updates their requirements:
```bash
export PI_AI_ANTIGRAVITY_VERSION="1.23.0"
```
#### Cache Retention #### Cache Retention
Set `PI_CACHE_RETENTION=long` to extend prompt cache retention: Set `PI_CACHE_RETENTION=long` to extend prompt cache retention:

View file

@ -72,15 +72,20 @@ const GEMINI_CLI_HEADERS = {
}; };
// Headers for Antigravity (sandbox endpoint) - requires specific User-Agent // Headers for Antigravity (sandbox endpoint) - requires specific User-Agent
const ANTIGRAVITY_HEADERS = { const DEFAULT_ANTIGRAVITY_VERSION = "1.15.8";
"User-Agent": "antigravity/1.15.8 darwin/arm64",
"X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1", function getAntigravityHeaders() {
"Client-Metadata": JSON.stringify({ const version = process.env.PI_AI_ANTIGRAVITY_VERSION || DEFAULT_ANTIGRAVITY_VERSION;
ideType: "IDE_UNSPECIFIED", return {
platform: "PLATFORM_UNSPECIFIED", "User-Agent": `antigravity/${version} darwin/arm64`,
pluginType: "GEMINI", "X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1",
}), "Client-Metadata": JSON.stringify({
}; ideType: "IDE_UNSPECIFIED",
platform: "PLATFORM_UNSPECIFIED",
pluginType: "GEMINI",
}),
};
}
// Antigravity system instruction (ported from CLIProxyAPI v6.6.89). // Antigravity system instruction (ported from CLIProxyAPI v6.6.89).
const ANTIGRAVITY_SYSTEM_INSTRUCTION = `<identity> const ANTIGRAVITY_SYSTEM_INSTRUCTION = `<identity>
@ -430,7 +435,7 @@ export const streamGoogleGeminiCli: StreamFunction<"google-gemini-cli", GoogleGe
const requestBody = buildRequest(model, context, projectId, options, isAntigravity); const requestBody = buildRequest(model, context, projectId, options, isAntigravity);
options?.onPayload?.(requestBody); options?.onPayload?.(requestBody);
const headers = isAntigravity ? ANTIGRAVITY_HEADERS : GEMINI_CLI_HEADERS; const headers = isAntigravity ? getAntigravityHeaders() : GEMINI_CLI_HEADERS;
const requestHeaders = { const requestHeaders = {
Authorization: `Bearer ${accessToken}`, Authorization: `Bearer ${accessToken}`,

View file

@ -5,6 +5,7 @@
### Added ### Added
- Added `titlebar-spinner.ts` example extension that shows a braille spinner animation in the terminal title while the agent is working. - Added `titlebar-spinner.ts` example extension that shows a braille spinner animation in the terminal title while the agent is working.
- Added `PI_AI_ANTIGRAVITY_VERSION` environment variable documentation to help text ([#1129](https://github.com/badlogic/pi-mono/issues/1129))
## [0.50.8] - 2026-02-01 ## [0.50.8] - 2026-02-01

View file

@ -288,6 +288,7 @@ ${chalk.bold("Environment Variables:")}
AWS_REGION - AWS region for Amazon Bedrock (e.g., us-east-1) AWS_REGION - AWS region for Amazon Bedrock (e.g., us-east-1)
${ENV_AGENT_DIR.padEnd(32)} - Session storage directory (default: ~/${CONFIG_DIR_NAME}/agent) ${ENV_AGENT_DIR.padEnd(32)} - Session storage directory (default: ~/${CONFIG_DIR_NAME}/agent)
PI_SHARE_VIEWER_URL - Base URL for /share command (default: https://buildwithpi.ai/session/) PI_SHARE_VIEWER_URL - Base URL for /share command (default: https://buildwithpi.ai/session/)
PI_AI_ANTIGRAVITY_VERSION - Override Antigravity User-Agent version (e.g., 1.23.0)
${chalk.bold("Available Tools (default: read, bash, edit, write):")} ${chalk.bold("Available Tools (default: read, bash, edit, write):")}
read - Read file contents read - Read file contents