Add Linux support with cross-platform database path detection
- Add platform-specific database path detection for macOS, Windows, and Linux - Make User-Agent header dynamic based on current OS and architecture - Maintain backward compatibility with existing macOS installations - Tested on Linux: server now correctly finds ~/.config/Antigravity database
This commit is contained in:
@@ -3,9 +3,38 @@
|
|||||||
* Based on: https://github.com/NoeFabris/opencode-antigravity-auth
|
* Based on: https://github.com/NoeFabris/opencode-antigravity-auth
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { homedir } from 'os';
|
import { homedir, platform, arch } from 'os';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Antigravity database path based on the current platform.
|
||||||
|
* - macOS: ~/Library/Application Support/Antigravity/...
|
||||||
|
* - Windows: ~/AppData/Roaming/Antigravity/...
|
||||||
|
* - Linux/other: ~/.config/Antigravity/...
|
||||||
|
* @returns {string} Full path to the Antigravity state database
|
||||||
|
*/
|
||||||
|
function getAntigravityDbPath() {
|
||||||
|
const home = homedir();
|
||||||
|
switch (platform()) {
|
||||||
|
case 'darwin':
|
||||||
|
return join(home, 'Library/Application Support/Antigravity/User/globalStorage/state.vscdb');
|
||||||
|
case 'win32':
|
||||||
|
return join(home, 'AppData/Roaming/Antigravity/User/globalStorage/state.vscdb');
|
||||||
|
default: // linux, freebsd, etc.
|
||||||
|
return join(home, '.config/Antigravity/User/globalStorage/state.vscdb');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate platform-specific User-Agent string.
|
||||||
|
* @returns {string} User-Agent in format "antigravity/version os/arch"
|
||||||
|
*/
|
||||||
|
function getPlatformUserAgent() {
|
||||||
|
const os = platform();
|
||||||
|
const architecture = arch();
|
||||||
|
return `antigravity/1.11.5 ${os}/${architecture}`;
|
||||||
|
}
|
||||||
|
|
||||||
// Cloud Code API endpoints (in fallback order)
|
// Cloud Code API endpoints (in fallback order)
|
||||||
const ANTIGRAVITY_ENDPOINT_DAILY = 'https://daily-cloudcode-pa.sandbox.googleapis.com';
|
const ANTIGRAVITY_ENDPOINT_DAILY = 'https://daily-cloudcode-pa.sandbox.googleapis.com';
|
||||||
const ANTIGRAVITY_ENDPOINT_PROD = 'https://cloudcode-pa.googleapis.com';
|
const ANTIGRAVITY_ENDPOINT_PROD = 'https://cloudcode-pa.googleapis.com';
|
||||||
@@ -18,7 +47,7 @@ export const ANTIGRAVITY_ENDPOINT_FALLBACKS = [
|
|||||||
|
|
||||||
// Required headers for Antigravity API requests
|
// Required headers for Antigravity API requests
|
||||||
export const ANTIGRAVITY_HEADERS = {
|
export const ANTIGRAVITY_HEADERS = {
|
||||||
'User-Agent': 'antigravity/1.11.5 darwin/arm64',
|
'User-Agent': getPlatformUserAgent(),
|
||||||
'X-Goog-Api-Client': 'google-cloud-sdk vscode_cloudshelleditor/0.1',
|
'X-Goog-Api-Client': 'google-cloud-sdk vscode_cloudshelleditor/0.1',
|
||||||
'Client-Metadata': JSON.stringify({
|
'Client-Metadata': JSON.stringify({
|
||||||
ideType: 'IDE_UNSPECIFIED',
|
ideType: 'IDE_UNSPECIFIED',
|
||||||
@@ -80,10 +109,8 @@ export const ACCOUNT_CONFIG_PATH = join(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Antigravity app database path (for legacy single-account token extraction)
|
// Antigravity app database path (for legacy single-account token extraction)
|
||||||
export const ANTIGRAVITY_DB_PATH = join(
|
// Uses platform-specific path detection
|
||||||
homedir(),
|
export const ANTIGRAVITY_DB_PATH = getAntigravityDbPath();
|
||||||
'Library/Application Support/Antigravity/User/globalStorage/state.vscdb'
|
|
||||||
);
|
|
||||||
|
|
||||||
export const DEFAULT_COOLDOWN_MS = 60 * 1000; // 1 minute default cooldown
|
export const DEFAULT_COOLDOWN_MS = 60 * 1000; // 1 minute default cooldown
|
||||||
export const MAX_RETRIES = 5; // Max retry attempts across accounts
|
export const MAX_RETRIES = 5; // Max retry attempts across accounts
|
||||||
|
|||||||
Reference in New Issue
Block a user