pub mod client;
pub mod proxy;
pub mod retry;
pub mod token;
pub mod transform;
pub use client::GeminiProxyClient;
pub const CODE_ASSIST_BASE_URL_STABLE: &str = "https://cloudcode-pa.googleapis.com";
pub const CODE_ASSIST_BASE_URL_DAILY: &str = "https://daily-cloudcode-pa.googleapis.com";
pub fn code_assist_base_url() -> String {
match std::env::var("NITPICKER_CODE_ASSIST_HOST").ok().as_deref() {
Some("stable") => CODE_ASSIST_BASE_URL_STABLE.to_string(),
Some("daily") | None => CODE_ASSIST_BASE_URL_DAILY.to_string(),
Some(other) => other.to_string(),
}
}
pub const ANTIGRAVITY_CLI_VERSION: &str = "1.5.20";
pub const ANTIGRAVITY_CLI_CL: &str = "1031873201";
pub fn build_gemini_user_agent() -> String {
let version = env_or("NITPICKER_ANTIGRAVITY_CLI_VERSION", ANTIGRAVITY_CLI_VERSION);
let cl = env_or("NITPICKER_ANTIGRAVITY_CLI_CL", ANTIGRAVITY_CLI_CL);
let os_type = match std::env::consts::OS {
"macos" => "darwin",
other => other,
};
let arch = match std::env::consts::ARCH {
"aarch64" => "arm64",
"x86_64" => "amd64",
other => other,
};
format!(
"antigravity/cli/{version} (aidev_client; os_type={os_type}; arch={arch}; cl={cl}; auth_method=consumer)"
)
}
fn env_or(key: &str, default: &str) -> String {
match std::env::var(key) {
Ok(value) if !value.trim().is_empty() => value.trim().to_string(),
_ => default.to_string(),
}
}
pub fn antigravity_platform() -> String {
match std::env::var("NITPICKER_ANTIGRAVITY_PLATFORM") {
Ok(value) if !value.trim().is_empty() => value.trim().to_string(),
_ => match (std::env::consts::OS, std::env::consts::ARCH) {
("macos", "x86_64") => "DARWIN_AMD64".to_string(),
("macos", "aarch64") => "DARWIN_ARM64".to_string(),
("linux", "x86_64") => "LINUX_AMD64".to_string(),
("linux", "aarch64") => "LINUX_ARM64".to_string(),
("windows", "x86_64") => "WINDOWS_AMD64".to_string(),
("windows", "aarch64") => "WINDOWS_ARM64".to_string(),
_ => "DARWIN_ARM64".to_string(),
},
}
}
pub fn create_activity_request_id() -> String {
use rand::RngExt;
let mut rng = rand::rng();
let chars: String = (0..8)
.map(|_| {
const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyz0123456789";
CHARSET[rng.random_range(0..CHARSET.len())] as char
})
.collect();
chars
}