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.0.1";
pub fn build_gemini_user_agent(model: &str) -> String {
let version = std::env::var("NITPICKER_ANTIGRAVITY_CLI_VERSION")
.ok()
.and_then(|v| {
let trimmed = v.trim();
if trimmed.is_empty() {
None
} else {
Some(trimmed.to_string())
}
})
.unwrap_or_else(|| ANTIGRAVITY_CLI_VERSION.to_string());
let platform = std::env::consts::OS;
let arch = std::env::consts::ARCH;
format!("antigravity-cli/{version}/{model} ({platform}; {arch})")
}
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
}