2026-03-12 05:20:46 -04:00
import { platform , arch } from "os" ;
2026-06-14 02:15:48 -04:00
import { PROVIDERS , PROVIDER _OAUTH } from "./providers.js" ;
2026-03-12 05:20:46 -04:00
2026-06-14 02:15:48 -04:00
// === Gemini CLI === derive từ registry gemini-cli.transport
export const GEMINI _CLI _VERSION = PROVIDERS [ "gemini-cli" ] ? . cliVersion ;
export const GEMINI _CLI _API _CLIENT = PROVIDERS [ "gemini-cli" ] ? . apiClient ;
2026-03-12 05:20:46 -04:00
2026-05-18 04:14:01 -04:00
// Map Node arch to Gemini CLI arch string (x64/x86/arm64/...)
function geminiCLIArch ( ) {
const a = arch ( ) ;
if ( a === "ia32" ) return "x86" ;
return a ;
}
2026-03-12 05:20:46 -04:00
export function geminiCLIUserAgent ( model = "unknown" ) {
2026-05-18 04:14:01 -04:00
return ` GeminiCLI/ ${ GEMINI _CLI _VERSION } / ${ model || "unknown" } ( ${ platform ( ) } ; ${ geminiCLIArch ( ) } ; terminal) ` ;
2026-03-12 05:20:46 -04:00
}
// === GitHub Copilot ===
2026-06-14 02:15:48 -04:00
// Derive từ registry github.transport.copilot
const _ghCopilot = PROVIDERS . github ? . copilot || { } ;
2026-03-12 05:20:46 -04:00
export const GITHUB _COPILOT = {
2026-06-14 02:15:48 -04:00
VSCODE _VERSION : _ghCopilot . vscodeVersion ,
COPILOT _CHAT _VERSION : _ghCopilot . chatVersion ,
USER _AGENT : _ghCopilot . userAgent ,
API _VERSION : _ghCopilot . apiVersion ,
2026-03-12 05:20:46 -04:00
} ;
// === Antigravity enums ===
export const IDE _TYPE = {
UNSPECIFIED : 0 ,
JETSKI : 10 ,
ANTIGRAVITY : 9 ,
PLUGINS : 7
} ;
export const PLATFORM = {
UNSPECIFIED : 0 ,
DARWIN _AMD64 : 1 ,
DARWIN _ARM64 : 2 ,
LINUX _AMD64 : 3 ,
LINUX _ARM64 : 4 ,
WINDOWS _AMD64 : 5
} ;
export const PLUGIN _TYPE = {
UNSPECIFIED : 0 ,
CLOUD _CODE : 1 ,
GEMINI : 2
} ;
export function getPlatformEnum ( ) {
const os = platform ( ) ;
const architecture = arch ( ) ;
if ( os === "darwin" ) return architecture === "arm64" ? PLATFORM . DARWIN _ARM64 : PLATFORM . DARWIN _AMD64 ;
if ( os === "linux" ) return architecture === "arm64" ? PLATFORM . LINUX _ARM64 : PLATFORM . LINUX _AMD64 ;
if ( os === "win32" ) return PLATFORM . WINDOWS _AMD64 ;
return PLATFORM . UNSPECIFIED ;
}
export function getPlatformUserAgent ( ) {
return ` antigravity/1.104.0 ${ platform ( ) } / ${ arch ( ) } ` ;
}
export const CLIENT _METADATA = {
ideType : IDE _TYPE . ANTIGRAVITY ,
platform : getPlatformEnum ( ) ,
pluginType : PLUGIN _TYPE . GEMINI
} ;
// Internal anti-loop header
export const INTERNAL _REQUEST _HEADER = { name : "x-request-source" , value : "local" } ;
2026-04-01 00:48:38 -04:00
// Suffix added to client tools when forwarding to Antigravity provider (anti-ban cloaking)
export const AG _TOOL _SUFFIX = "_ide" ;
2026-03-30 01:21:24 -04:00
2026-04-04 20:46:26 -04:00
// Suffix added to client tools when forwarding to Claude provider (anti-ban cloaking)
export const CLAUDE _TOOL _SUFFIX = "_ide" ;
// CC native default tools — these are Claude Code's own tools, kept as decoys
// Client tools matching these names are skipped (not renamed), others get _cc suffix
export const CC _DEFAULT _TOOLS = new Set ( [
"Task" ,
"TaskOutput" ,
"TaskStop" ,
"TaskCreate" ,
"TaskGet" ,
"TaskUpdate" ,
"TaskList" ,
"Bash" ,
"Glob" ,
"Grep" ,
"Read" ,
"Edit" ,
"Write" ,
"NotebookEdit" ,
"WebFetch" ,
"WebSearch" ,
"AskUserQuestion" ,
"Skill" ,
"EnterPlanMode" ,
"ExitPlanMode" ,
] ) ;
2026-03-30 01:21:24 -04:00
// AG native default tools — kept as decoys with neutral description/properties
// These names must match exactly what AG sends in the real request log
export const AG _DEFAULT _TOOLS = new Set ( [
"browser_subagent" ,
"command_status" ,
"find_by_name" ,
"generate_image" ,
"grep_search" ,
"list_dir" ,
"list_resources" ,
"multi_replace_file_content" ,
"notify_user" ,
"read_resource" ,
"read_terminal" ,
"read_url_content" ,
"replace_file_content" ,
"run_command" ,
"search_web" ,
"send_command_input" ,
"task_boundary" ,
"view_content_chunk" ,
"view_file" ,
"write_to_file"
] ) ;
2026-03-12 05:20:46 -04:00
// Antigravity chat/stream headers
export const ANTIGRAVITY _HEADERS = {
2026-03-16 23:12:17 -04:00
"User-Agent" : ` antigravity/1.107.0 ${ platform ( ) } / ${ arch ( ) } `
2026-03-12 05:20:46 -04:00
} ;
// Cloud Code Assist API
export const CLOUD _CODE _API = {
loadCodeAssist : "https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist" ,
onboardUser : "https://cloudcode-pa.googleapis.com/v1internal:onboardUser" ,
} ;
export const LOAD _CODE _ASSIST _HEADERS = {
"Content-Type" : "application/json" ,
"User-Agent" : "google-api-nodejs-client/9.15.1" ,
"X-Goog-Api-Client" : "google-cloud-sdk vscode_cloudshelleditor/0.1" ,
2026-03-16 23:12:17 -04:00
"Client-Metadata" : JSON . stringify ( { ideType : IDE _TYPE . ANTIGRAVITY , platform : getPlatformEnum ( ) , pluginType : PLUGIN _TYPE . GEMINI } ) ,
2026-03-12 05:20:46 -04:00
} ;
export const LOAD _CODE _ASSIST _METADATA = {
2026-03-16 23:12:17 -04:00
ideType : IDE _TYPE . ANTIGRAVITY ,
platform : getPlatformEnum ( ) ,
pluginType : PLUGIN _TYPE . GEMINI ,
2026-03-12 05:20:46 -04:00
} ;
// System prompts
2026-04-04 20:46:26 -04:00
export const CLAUDE _SYSTEM _PROMPT = "You are Claude Code, Anthropic's official CLI for Claude." ;
2026-03-12 05:20:46 -04:00
export const ANTIGRAVITY _DEFAULT _SYSTEM = "You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.**Absolute paths only****Proactiveness**" ;
2026-06-14 02:15:48 -04:00
// Derive từ registry oauth.refreshLeadMs
export const REFRESH _LEAD _MS = Object . fromEntries (
Object . entries ( PROVIDER _OAUTH ) . filter ( ( [ , o ] ) => o . refreshLeadMs ) . map ( ( [ id , o ] ) => [ id , o . refreshLeadMs ] )
) ;
2026-04-14 00:41:06 -04:00
2026-03-12 05:20:46 -04:00
// OAuth endpoints
export const OAUTH _ENDPOINTS = {
2026-06-14 02:15:48 -04:00
google : { token : "https://oauth2.googleapis.com/token" , auth : "https://accounts.google.com/o/oauth2/auth" } ,
openai : { token : PROVIDER _OAUTH [ "codex" ] ? . tokenUrl , auth : PROVIDER _OAUTH [ "codex" ] ? . authorizeUrl } ,
anthropic : { token : PROVIDER _OAUTH [ "claude" ] ? . tokenUrl , auth : "https://api.anthropic.com/v1/oauth/authorize" } , // ≠ claude.authorizeUrl (claude.ai login) — keep
qwen : { token : PROVIDER _OAUTH [ "qwen" ] ? . tokenUrl , auth : PROVIDER _OAUTH [ "qwen" ] ? . deviceCodeUrl } ,
iflow : { token : PROVIDER _OAUTH [ "iflow" ] ? . tokenUrl , auth : PROVIDER _OAUTH [ "iflow" ] ? . authorizeUrl } ,
github : { token : PROVIDER _OAUTH [ "github" ] ? . tokenUrl , auth : PROVIDER _OAUTH [ "github" ] ? . authorizeUrl , deviceCode : PROVIDER _OAUTH [ "github" ] ? . deviceCodeUrl } ,
2026-03-12 05:20:46 -04:00
} ;
// Generate Kimi OAuth custom headers
export function buildKimiHeaders ( ) {
return {
"X-Msh-Platform" : "9router" ,
"X-Msh-Version" : "2.1.2" ,
"X-Msh-Device-Model" : typeof process !== "undefined" ? ` ${ process . platform } ${ process . arch } ` : "unknown" ,
"X-Msh-Device-Id" : ` kimi- ${ Date . now ( ) } `
} ;
}