fix: cross-platform support + auto token from state.vscdb

- User-Agent now matches actual OS (macOS/Windows/Linux)
- grep -oP replaced with grep -oE for macOS BSD compat
- Port-killer gated with cfg(unix)/cfg(windows)
- zg binary: macOS uses launchctl, Windows uses schtasks
- Data dir mismatch fixed in mitm-redirect.sh
- Windows setup-windows.ps1 ProjectDir fixed
- README: token path, prerequisites updated
- setup-linux.sh: pre-flight dependency checks
- OAuth token auto-read from Antigravity state.vscdb
- Version bump to 1.0.1
This commit is contained in:
Nikketryhard
2026-02-18 04:09:41 -06:00
parent efdb98e6f0
commit 134126358f
12 changed files with 397 additions and 70 deletions

View File

@@ -104,12 +104,12 @@ fn extract_binary_versions(install_dir: &str) -> (Option<String>, Option<String>
return (None, None);
}
// Use grep -oP on the binary to avoid loading the whole thing into memory
// Use grep -oE on the binary to avoid loading the whole thing into memory
let chrome = Command::new("sh")
.args([
"-c",
&format!(
"strings '{}' | grep -oP 'Chrome/[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+' | head -1",
"strings '{}' | grep -oE 'Chrome/[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+' | head -1",
binary
),
])
@@ -124,7 +124,7 @@ fn extract_binary_versions(install_dir: &str) -> (Option<String>, Option<String>
.args([
"-c",
&format!(
"strings '{}' | grep -oP 'Electron/[0-9]+\\.[0-9]+\\.[0-9]+' | head -1",
"strings '{}' | grep -oE 'Electron/[0-9]+\\.[0-9]+\\.[0-9]+' | head -1",
binary
),
])
@@ -234,8 +234,9 @@ pub fn token_file_path() -> String {
/// User-Agent string matching the Electron webview — computed once.
pub static USER_AGENT: LazyLock<String> = LazyLock::new(|| {
let os_part = user_agent_os_part();
format!(
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 \
"Mozilla/5.0 ({os_part}) AppleWebKit/537.36 \
(KHTML, like Gecko) Antigravity/{} \
Chrome/{} Electron/{} Safari/537.36",
antigravity_version(),
@@ -244,6 +245,22 @@ pub static USER_AGENT: LazyLock<String> = LazyLock::new(|| {
)
});
/// Returns the OS portion of the User-Agent string matching real Electron/Chrome.
fn user_agent_os_part() -> &'static str {
#[cfg(target_os = "macos")]
{
"Macintosh; Intel Mac OS X 10_15_7"
}
#[cfg(target_os = "windows")]
{
"Windows NT 10.0; Win64; x64"
}
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
{
"X11; Linux x86_64"
}
}
/// Chrome major version for sec-ch-ua header — computed once.
pub static CHROME_MAJOR: LazyLock<String> = LazyLock::new(|| {
chrome_version()