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]
### 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
### 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
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
const ANTIGRAVITY_HEADERS = {
"User-Agent": "antigravity/1.15.8 darwin/arm64",
"X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1",
"Client-Metadata": JSON.stringify({
ideType: "IDE_UNSPECIFIED",
platform: "PLATFORM_UNSPECIFIED",
pluginType: "GEMINI",
}),
};
const DEFAULT_ANTIGRAVITY_VERSION = "1.15.8";
function getAntigravityHeaders() {
const version = process.env.PI_AI_ANTIGRAVITY_VERSION || DEFAULT_ANTIGRAVITY_VERSION;
return {
"User-Agent": `antigravity/${version} darwin/arm64`,
"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).
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);
options?.onPayload?.(requestBody);
const headers = isAntigravity ? ANTIGRAVITY_HEADERS : GEMINI_CLI_HEADERS;
const headers = isAntigravity ? getAntigravityHeaders() : GEMINI_CLI_HEADERS;
const requestHeaders = {
Authorization: `Bearer ${accessToken}`,

View file

@ -5,6 +5,7 @@
### Added
- 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

View file

@ -288,6 +288,7 @@ ${chalk.bold("Environment Variables:")}
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)
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):")}
read - Read file contents