Release binaries / Build macOS ARM64 (push) Has been cancelled
Release binaries / Build macOS x64 (push) Has been cancelled
Release binaries / Build Linux ARM64 (push) Has been cancelled
Release binaries / Build Linux musl ARM64 (push) Has been cancelled
Release binaries / Build Linux musl x64 (push) Has been cancelled
Release binaries / Build Linux x64 (push) Has been cancelled
Release binaries / Build Windows x64 (push) Has been cancelled
Release binaries / Attach binaries to GitHub Release (push) Has been cancelled
Standalone product rename across the whole repo (issue: project identity): - Binary/package/repo/skill/docs: agent-browser[-stealth] → chrome-use (single binary name `chrome-use`; old aliases agent-browser/abs dropped). - Version: 0.27.0-fork.51 → 1.0.0 (drop the upstream-fork counter). - Native-messaging host: com.agent_browser.connect → com.leeguoo.chrome_use (CLI + ab-connect extension in lockstep — this is a breaking handshake change, extension bumped 0.4.2 → 0.5.0, needs a Web Store republish). - Config dir: ~/.agent-browser → ~/.chrome-use. - README/zh: reframed from "stealth fork of agent-browser" to a standalone product with a small `originally based on vercel-labs/agent-browser` credit. - Kept AGENT_BROWSER_* env vars working (63 vars across the codebase; renaming them would break every existing script/skill for no user-facing gain). Build green, 802 unit tests pass, fmt + clippy clean. Upstream attribution to vercel-labs/agent-browser preserved.
141 lines
3.9 KiB
Rust
141 lines
3.9 KiB
Rust
//! Check the local environment: CLI version, platform, state/socket dirs,
|
|
//! and free disk space.
|
|
|
|
use std::path::Path;
|
|
|
|
use super::helpers::{disk_free_bytes, human_size, is_writable_dir};
|
|
use super::{Check, Status};
|
|
use crate::connection::get_socket_dir;
|
|
use crate::native::state::get_state_dir;
|
|
|
|
pub(super) fn check(checks: &mut Vec<Check>) {
|
|
let category = "Environment";
|
|
|
|
let version = env!("CARGO_PKG_VERSION");
|
|
let platform = format!("{} {}", std::env::consts::OS, std::env::consts::ARCH);
|
|
checks.push(Check::new(
|
|
"env.version",
|
|
category,
|
|
Status::Pass,
|
|
format!("CLI version {} ({})", version, platform),
|
|
));
|
|
|
|
match dirs::home_dir() {
|
|
Some(home) => checks.push(Check::new(
|
|
"env.home",
|
|
category,
|
|
Status::Pass,
|
|
format!("Home directory {}", home.display()),
|
|
)),
|
|
None => checks.push(Check::new(
|
|
"env.home",
|
|
category,
|
|
Status::Fail,
|
|
"Could not determine home directory",
|
|
)),
|
|
}
|
|
|
|
let state_dir = get_state_dir();
|
|
let socket_dir = get_socket_dir();
|
|
|
|
// Under the default setup, state and socket dirs are the same
|
|
// (~/.chrome-use). Collapse to a single line when they match;
|
|
// split when XDG_RUNTIME_DIR or AGENT_BROWSER_SOCKET_DIR diverts
|
|
// sockets elsewhere.
|
|
if state_dir == socket_dir {
|
|
push_dir_check(
|
|
checks,
|
|
"env.state_dir",
|
|
category,
|
|
"State and socket directory",
|
|
&state_dir,
|
|
);
|
|
} else {
|
|
push_dir_check(
|
|
checks,
|
|
"env.state_dir",
|
|
category,
|
|
"State directory",
|
|
&state_dir,
|
|
);
|
|
push_dir_check(
|
|
checks,
|
|
"env.socket_dir",
|
|
category,
|
|
"Socket directory",
|
|
&socket_dir,
|
|
);
|
|
}
|
|
|
|
match disk_free_bytes(&state_dir) {
|
|
Some(bytes) => {
|
|
let mb = bytes / (1024 * 1024);
|
|
let human = human_size(bytes);
|
|
if mb < 500 {
|
|
checks.push(
|
|
Check::new(
|
|
"env.disk_free",
|
|
category,
|
|
Status::Warn,
|
|
format!("Low disk space at state dir: {} free", human),
|
|
)
|
|
.with_fix("free up disk space; Chrome installs require ~500 MB"),
|
|
);
|
|
} else {
|
|
checks.push(Check::new(
|
|
"env.disk_free",
|
|
category,
|
|
Status::Pass,
|
|
format!("{} free at state dir", human),
|
|
));
|
|
}
|
|
}
|
|
None => checks.push(Check::new(
|
|
"env.disk_free",
|
|
category,
|
|
Status::Info,
|
|
"Disk free check unavailable on this platform",
|
|
)),
|
|
}
|
|
}
|
|
|
|
fn push_dir_check(
|
|
checks: &mut Vec<Check>,
|
|
id: &'static str,
|
|
category: &'static str,
|
|
label: &str,
|
|
dir: &Path,
|
|
) {
|
|
if dir.exists() {
|
|
if is_writable_dir(dir) {
|
|
checks.push(Check::new(
|
|
id,
|
|
category,
|
|
Status::Pass,
|
|
format!("{} {}", label, dir.display()),
|
|
));
|
|
} else {
|
|
checks.push(
|
|
Check::new(
|
|
id,
|
|
category,
|
|
Status::Fail,
|
|
format!("{} not writable: {}", label, dir.display()),
|
|
)
|
|
.with_fix(format!("chmod u+rwx {}", dir.display())),
|
|
);
|
|
}
|
|
} else {
|
|
checks.push(Check::new(
|
|
id,
|
|
category,
|
|
Status::Info,
|
|
format!(
|
|
"{} does not exist yet (will be created on first use): {}",
|
|
label,
|
|
dir.display()
|
|
),
|
|
));
|
|
}
|
|
}
|