Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcefc729e8 | ||
|
|
f4a8f79a22 | ||
|
|
6cf74817d8 | ||
|
|
14ffd30417 | ||
|
|
17686fdbf8 | ||
|
|
22532d756c | ||
|
|
68e2e351b1 | ||
|
|
d95d32831e | ||
|
|
1a4c440d9e | ||
|
|
d1fbdaadeb | ||
|
|
839aaa5586 | ||
|
|
a7f9c24fdb | ||
|
|
42ade7b4e8 | ||
|
|
2dabed973e | ||
|
|
dd2deff06c |
@@ -49,29 +49,6 @@ jobs:
|
||||
- name: Run Rust tests
|
||||
run: cargo test --profile ci --manifest-path cli/Cargo.toml
|
||||
|
||||
dashboard:
|
||||
name: Dashboard
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --filter dashboard
|
||||
working-directory: packages/dashboard
|
||||
|
||||
- name: Build dashboard
|
||||
run: pnpm build
|
||||
working-directory: packages/dashboard
|
||||
|
||||
rust-cross:
|
||||
name: Rust (${{ matrix.os }} - ${{ matrix.target }})
|
||||
if: github.event_name != 'pull_request'
|
||||
@@ -108,6 +85,11 @@ jobs:
|
||||
if: github.event_name != 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
needs: rust
|
||||
# This fork forbids headless by default (always-headed for stealth), but CI
|
||||
# runners have no display. Opt into the documented display-less escape so
|
||||
# launched Chrome can start; e2e tests exercise functionality, not stealth.
|
||||
env:
|
||||
AGENT_BROWSER_ALLOW_HEADLESS: "1"
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -135,6 +117,10 @@ jobs:
|
||||
if: github.event_name != 'pull_request'
|
||||
runs-on: windows-latest
|
||||
needs: rust-cross
|
||||
# Headless-forbidden fork on a headless CI runner — opt into the escape so
|
||||
# `agent-browser open` can launch Chrome.
|
||||
env:
|
||||
AGENT_BROWSER_ALLOW_HEADLESS: "1"
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
||||
@@ -38,6 +38,10 @@ __pycache__/
|
||||
*.webm
|
||||
test/e2e/.dogfood-output/
|
||||
|
||||
# ...but these are real repo assets, not test artifacts — keep them tracked
|
||||
!assets/*.png
|
||||
!extensions/ab-connect/icons/*.png
|
||||
|
||||
# Package manager
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
# agent-browser-stealth
|
||||
|
||||

|
||||
|
||||
Stealth fork of [agent-browser](https://github.com/vercel-labs/agent-browser) — connects to your real Chrome, shares your login sessions, and is undetectable by anti-bot systems.
|
||||
|
||||
For basic usage, commands, and API reference, see the [upstream documentation](https://github.com/vercel-labs/agent-browser).
|
||||
|
||||
## Why this fork?
|
||||
|
||||
<img src="assets/fingerprint.png" alt="real but undetectable fingerprint" width="300" align="right" />
|
||||
|
||||
**agent-browser** launches a fresh browser with an empty profile. You need to log in again, and websites can detect it's automated.
|
||||
|
||||
**agent-browser-stealth** connects to your existing Chrome. Your cookies, sessions, and browser fingerprint are all real — because it IS your real browser.
|
||||
@@ -115,6 +119,8 @@ In CI environments, standalone mode is used automatically.
|
||||
|
||||
## Anti-detection
|
||||
|
||||
<img src="assets/shield.png" alt="stealth shield" width="320" align="right" />
|
||||
|
||||
When connected to your real Chrome, we inject **zero** JavaScript patches. Your browser's fingerprint is completely genuine. The guiding rule is **native CDP/Chrome overrides over JS lies** — a re-defined getter is itself detectable; a native override isn't.
|
||||
|
||||
- `navigator.webdriver = false` via `Emulation.setAutomationOverride` (native, undetectable by CreepJS-style lie tests).
|
||||
@@ -124,11 +130,27 @@ When connected to your real Chrome, we inject **zero** JavaScript patches. Your
|
||||
|
||||
| Test site | Result |
|
||||
|---|---|
|
||||
| [CreepJS](https://abrahamjuliot.github.io/creepjs/) | 0% stealth, 0% headless |
|
||||
| [bot.sannysoft.com](https://bot.sannysoft.com) | All green |
|
||||
| [Cloudflare Turnstile](https://nowsecure.nl) | Passed |
|
||||
| [CreepJS](https://abrahamjuliot.github.io/creepjs/) | **0% stealth · 0% headless** (no override traces at all) |
|
||||
| [bot.incolumitas.com](https://bot.incolumitas.com/) | all checks OK — `overflowTest`, `overrideTest`, `puppeteerExtraStealthUsed`, worker consistency |
|
||||
| [bot.sannysoft.com](https://bot.sannysoft.com) | all green |
|
||||
| [BrowserScan](https://www.browserscan.net/bot-detection) | Webdriver · User-Agent · CDP all clean |
|
||||
| [Cloudflare Turnstile](https://nowsecure.nl) | passed |
|
||||
|
||||
When using `--launch` mode (standalone browser), a full suite of 32 stealth patches is applied for headless Chrome.
|
||||
`0% stealth` on CreepJS is the key number: because the connect path patches **nothing**, there is no override for a lie-detector to catch. (Dashboards that read `navigator.languages` order or IP geolocation may show a soft "navigator"/"location" flag — that tracks *your real Chrome's* language list and network, not an automation tell.)
|
||||
|
||||
When using `--launch` mode (standalone browser), a full suite of stealth patches is applied instead, and it still passes the suite above.
|
||||
|
||||
### Verify it yourself
|
||||
|
||||
Don't take our word for it — point your connected Chrome at the toughest public detectors and compare:
|
||||
|
||||
- **[CreepJS](https://abrahamjuliot.github.io/creepjs/)** — the most thorough fingerprint / lie detector
|
||||
- **[bot.incolumitas.com](https://bot.incolumitas.com/)** — behavioral + fingerprint scoring with a public methodology
|
||||
- **[BrowserScan](https://www.browserscan.net/bot-detection)** — Webdriver / User-Agent / CDP / Navigator
|
||||
- **[bot.sannysoft.com](https://bot.sannysoft.com)** — the classic automation-marker checklist
|
||||
- **[pixelscan.net](https://pixelscan.net/)** · **[iphey.com](https://iphey.com/)** — consistency & identity
|
||||
|
||||
We deliberately **don't ship our own bot detector** — the strongest, most honest benchmark is the market's best detectors run against your real browser.
|
||||
|
||||
### Tuning knobs (environment variables)
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 1.0 MiB |
|
After Width: | Height: | Size: 1.7 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
@@ -45,7 +45,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "agent-browser-stealth"
|
||||
version = "0.27.0-fork.26"
|
||||
version = "0.27.0-fork.31"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"async-trait",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "agent-browser-stealth"
|
||||
version = "0.27.0-fork.26"
|
||||
version = "0.27.0-fork.31"
|
||||
edition = "2021"
|
||||
description = "Fast browser automation CLI for AI agents"
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -620,7 +620,7 @@ fn parse_command_inner(args: &[String], flags: &Flags) -> Result<Value, ParseErr
|
||||
// racing into a half-rendered UI.
|
||||
let state_override = if rest.iter().any(|&s| s == "--gone" || s == "--detached") {
|
||||
Some("detached")
|
||||
} else if rest.iter().any(|&s| s == "--hidden") {
|
||||
} else if rest.contains(&"--hidden") {
|
||||
Some("hidden")
|
||||
} else {
|
||||
None
|
||||
@@ -1069,8 +1069,8 @@ fn parse_command_inner(args: &[String], flags: &Flags) -> Result<Value, ParseErr
|
||||
// Top-level shortcuts for `get <x>` status reads — users naturally type
|
||||
// `agent-browser url` / `cdp-url` / `title` without the `get` prefix
|
||||
// (and expect `cdp-url`/`cdp_url` to work interchangeably).
|
||||
"url" | "cdp-url" | "cdp_url" | "title" | "html" | "text" | "value"
|
||||
| "count" | "box" | "styles" | "attr" => {
|
||||
"url" | "cdp-url" | "cdp_url" | "title" | "html" | "text" | "value" | "count" | "box"
|
||||
| "styles" | "attr" => {
|
||||
let sub = if cmd == "cdp_url" { "cdp-url" } else { cmd };
|
||||
let mut get_args: Vec<&str> = Vec::with_capacity(rest.len() + 1);
|
||||
get_args.push(sub);
|
||||
@@ -5177,11 +5177,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_find_role_missing_action_verb_with_name_flag() {
|
||||
let err = parse_command(
|
||||
&args("find role button --name Submit"),
|
||||
&default_flags(),
|
||||
)
|
||||
.unwrap_err();
|
||||
let err =
|
||||
parse_command(&args("find role button --name Submit"), &default_flags()).unwrap_err();
|
||||
let msg = err.format();
|
||||
assert!(
|
||||
msg.contains("Missing action verb"),
|
||||
@@ -5199,11 +5196,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_find_testid_missing_action_verb_with_exact_flag() {
|
||||
let err = parse_command(
|
||||
&args("find testid foo --exact"),
|
||||
&default_flags(),
|
||||
)
|
||||
.unwrap_err();
|
||||
let err = parse_command(&args("find testid foo --exact"), &default_flags()).unwrap_err();
|
||||
assert!(err.format().contains("Missing action verb"));
|
||||
}
|
||||
|
||||
@@ -5252,11 +5245,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_wait_gone_with_timeout() {
|
||||
let cmd = parse_command(
|
||||
&args("wait .modal --gone --timeout 2000"),
|
||||
&default_flags(),
|
||||
)
|
||||
.unwrap();
|
||||
let cmd =
|
||||
parse_command(&args("wait .modal --gone --timeout 2000"), &default_flags()).unwrap();
|
||||
assert_eq!(cmd["selector"], ".modal");
|
||||
assert_eq!(cmd["state"], "detached");
|
||||
assert_eq!(cmd["timeout"], 2000);
|
||||
|
||||
@@ -24,6 +24,11 @@ pub const HOST_NAME: &str = "com.agent_browser.connect";
|
||||
/// that extension talk to this host, and the force-install policy references it.
|
||||
pub const EXTENSION_ID: &str = "ciiljdlhdpfckdcfkphgmfalanpdejep";
|
||||
|
||||
/// The Chrome Web Store assigns its own id (the manifest "key" is stripped from
|
||||
/// store uploads), so the published build has a different origin than the local
|
||||
/// Load-unpacked one. Allow both to talk to the native-messaging host.
|
||||
pub const STORE_EXTENSION_ID: &str = "knfcmbamhjmaonkfnjhldjedeobeafmk";
|
||||
|
||||
/// Update URL the force-install policy points at. MUST be the Chrome Web Store
|
||||
/// endpoint: Chrome 149 tags any **off-Web-Store** force-installed extension
|
||||
/// `[BLOCKED]` on an unmanaged browser (verified on macOS — chrome://policy shows
|
||||
@@ -34,7 +39,8 @@ pub const UPDATE_URL: &str = "https://clients2.google.com/service/update2/crx";
|
||||
|
||||
/// Public Web Store listing — the guaranteed one-click "Add to Chrome" path,
|
||||
/// and the fallback when the force-install profile can't be approved headlessly.
|
||||
pub const STORE_URL: &str = "https://chromewebstore.google.com/detail/ciiljdlhdpfckdcfkphgmfalanpdejep";
|
||||
pub const STORE_URL: &str =
|
||||
"https://chromewebstore.google.com/detail/ciiljdlhdpfckdcfkphgmfalanpdejep";
|
||||
|
||||
/// Stable identifiers for the generated Chrome configuration profile, so a
|
||||
/// re-install replaces (rather than duplicates) it in System Settings.
|
||||
@@ -52,7 +58,11 @@ pub fn run_connect(args: &[String], json: bool) {
|
||||
let removed = remove_host_manifests();
|
||||
let profile_removed = remove_force_install_profile();
|
||||
if json {
|
||||
report(json, true, &format!("removed {removed} native-host manifest(s)"));
|
||||
report(
|
||||
json,
|
||||
true,
|
||||
&format!("removed {removed} native-host manifest(s)"),
|
||||
);
|
||||
} else {
|
||||
println!("✓ removed {removed} native-host manifest(s).");
|
||||
if profile_removed {
|
||||
@@ -94,7 +104,10 @@ pub fn run_connect(args: &[String], json: bool) {
|
||||
}
|
||||
match profile {
|
||||
Ok(path) => {
|
||||
println!("\n✓ Chrome force-install profile written:\n {}", path.display());
|
||||
println!(
|
||||
"\n✓ Chrome force-install profile written:\n {}",
|
||||
path.display()
|
||||
);
|
||||
if cfg!(target_os = "macos") {
|
||||
println!(
|
||||
"\nGet the extension into Chrome (one-time). Either:\n\
|
||||
@@ -174,7 +187,10 @@ fn install_native_host() -> Result<Vec<String>, String> {
|
||||
"description": "agent-browser connect — native messaging host",
|
||||
"path": launcher.display().to_string(),
|
||||
"type": "stdio",
|
||||
"allowed_origins": [format!("chrome-extension://{EXTENSION_ID}/")],
|
||||
"allowed_origins": [
|
||||
format!("chrome-extension://{EXTENSION_ID}/"),
|
||||
format!("chrome-extension://{STORE_EXTENSION_ID}/"),
|
||||
],
|
||||
});
|
||||
let body = serde_json::to_string_pretty(&manifest).map_err(|e| e.to_string())?;
|
||||
|
||||
@@ -300,7 +316,12 @@ fn native_messaging_dirs() -> Vec<PathBuf> {
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
{
|
||||
if let Some(config) = dirs::config_dir() {
|
||||
for sub in ["google-chrome", "chromium", "microsoft-edge", "BraveSoftware/Brave-Browser"] {
|
||||
for sub in [
|
||||
"google-chrome",
|
||||
"chromium",
|
||||
"microsoft-edge",
|
||||
"BraveSoftware/Brave-Browser",
|
||||
] {
|
||||
dirs_out.push(config.join(sub).join("NativeMessagingHosts"));
|
||||
}
|
||||
}
|
||||
@@ -347,7 +368,11 @@ fn nm_log(line: &str) {
|
||||
if let Some(p) = path.parent() {
|
||||
let _ = std::fs::create_dir_all(p);
|
||||
}
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new().create(true).append(true).open(&path) {
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(&path)
|
||||
{
|
||||
let _ = writeln!(f, "{line}");
|
||||
}
|
||||
}
|
||||
@@ -387,7 +412,10 @@ pub fn relay_url() -> Option<String> {
|
||||
/// file) so only this user's agent-browser — not arbitrary local processes —
|
||||
/// can drive the browser. No token, no user interaction.
|
||||
pub fn run_nm_host() {
|
||||
let rt = match tokio::runtime::Builder::new_multi_thread().enable_all().build() {
|
||||
let rt = match tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
{
|
||||
Ok(rt) => rt,
|
||||
Err(e) => {
|
||||
nm_log(&format!("[nm-host] runtime build failed: {e}"));
|
||||
@@ -531,6 +559,9 @@ async fn nm_host_main() {
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
// The handshake-callback Result type is dictated by tokio-tungstenite's
|
||||
// accept_hdr_async contract; its Err variant (an http Response) can't be shrunk.
|
||||
#[allow(clippy::result_large_err)]
|
||||
async fn handle_cdp_client(
|
||||
stream: tokio::net::TcpStream,
|
||||
guid: String,
|
||||
@@ -539,7 +570,9 @@ async fn handle_cdp_client(
|
||||
mut from_relay: tokio::sync::mpsc::UnboundedReceiver<String>,
|
||||
to_ext: tokio::sync::mpsc::Sender<Vec<u8>>,
|
||||
clients: std::sync::Arc<
|
||||
tokio::sync::Mutex<std::collections::HashMap<u64, tokio::sync::mpsc::UnboundedSender<String>>>,
|
||||
tokio::sync::Mutex<
|
||||
std::collections::HashMap<u64, tokio::sync::mpsc::UnboundedSender<String>>,
|
||||
>,
|
||||
>,
|
||||
) {
|
||||
use crate::native::relay::ClientRoute;
|
||||
|
||||
@@ -90,7 +90,7 @@ pub fn run_find_url(args: &[String], json: bool) {
|
||||
}
|
||||
|
||||
// Most-recently-added first (date_added is microseconds since 1601).
|
||||
hits.sort_by(|a, b| b.date_added.cmp(&a.date_added));
|
||||
hits.sort_by_key(|b| std::cmp::Reverse(b.date_added));
|
||||
hits.truncate(limit);
|
||||
|
||||
if json {
|
||||
@@ -142,10 +142,7 @@ fn walk(node: &Value, folder: &str, keywords: &[String], out: &mut Vec<Hit>) {
|
||||
let url = node.get("url").and_then(|v| v.as_str()).unwrap_or("");
|
||||
// Skip non-navigable bookmarks: javascript: bookmarklets and data:
|
||||
// URIs aren't pages you can visit, and their bodies can be huge.
|
||||
if url.is_empty()
|
||||
|| url.starts_with("javascript:")
|
||||
|| url.starts_with("data:")
|
||||
{
|
||||
if url.is_empty() || url.starts_with("javascript:") || url.starts_with("data:") {
|
||||
return;
|
||||
}
|
||||
let hay = format!("{} {}", name.to_lowercase(), url.to_lowercase());
|
||||
|
||||
@@ -460,8 +460,7 @@ pub fn parse_flags(args: &[String]) -> Flags {
|
||||
auto_connect: !env_var_is_truthy("AGENT_BROWSER_NO_AUTO_CONNECT")
|
||||
&& (env_var_is_truthy("AGENT_BROWSER_AUTO_CONNECT")
|
||||
|| config.auto_connect.unwrap_or(true)),
|
||||
force_launch: env_var_is_truthy("AGENT_BROWSER_FORCE_LAUNCH")
|
||||
|| env::var("CI").is_ok(),
|
||||
force_launch: env_var_is_truthy("AGENT_BROWSER_FORCE_LAUNCH") || env::var("CI").is_ok(),
|
||||
session_name: env::var("AGENT_BROWSER_SESSION_NAME")
|
||||
.ok()
|
||||
.or(config.session_name),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
mod chat;
|
||||
mod color;
|
||||
mod commands;
|
||||
mod connection;
|
||||
mod connect;
|
||||
mod connection;
|
||||
mod doctor;
|
||||
mod findurl;
|
||||
mod flags;
|
||||
|
||||
@@ -1525,10 +1525,14 @@ async fn connect_auto_with_fresh_tab() -> Result<BrowserManager, String> {
|
||||
// about:blank. Failing here lets the caller surface the real error.
|
||||
if let Err(e) = mgr
|
||||
.client
|
||||
.send_command("Runtime.evaluate", Some(serde_json::json!({
|
||||
"expression": "1",
|
||||
"returnByValue": true,
|
||||
})), Some(&session_id))
|
||||
.send_command(
|
||||
"Runtime.evaluate",
|
||||
Some(serde_json::json!({
|
||||
"expression": "1",
|
||||
"returnByValue": true,
|
||||
})),
|
||||
Some(&session_id),
|
||||
)
|
||||
.await
|
||||
{
|
||||
return Err(format!(
|
||||
@@ -1818,7 +1822,11 @@ async fn apply_stealth_to_session(state: &DaemonState, session_id: &str) {
|
||||
|
||||
/// Apply stealth to the active page session (initial connect/launch).
|
||||
async fn apply_stealth_to_browser(state: &DaemonState) {
|
||||
let session_id = match state.browser.as_ref().and_then(|m| m.active_session_id().ok()) {
|
||||
let session_id = match state
|
||||
.browser
|
||||
.as_ref()
|
||||
.and_then(|m| m.active_session_id().ok())
|
||||
{
|
||||
Some(sid) => sid.to_string(),
|
||||
None => return,
|
||||
};
|
||||
|
||||
@@ -271,7 +271,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn identical_fingerprints_score_one() {
|
||||
let a = fp("button", "Submit", &[("id", "go"), ("class", "btn primary")]);
|
||||
let a = fp(
|
||||
"button",
|
||||
"Submit",
|
||||
&[("id", "go"), ("class", "btn primary")],
|
||||
);
|
||||
assert!((score(&a, &a) - 1.0).abs() < 1e-9);
|
||||
}
|
||||
|
||||
@@ -308,7 +312,12 @@ mod tests {
|
||||
let mut b = fp("button", "OK", &[]);
|
||||
a.ancestors = vec!["form#f".into(), "div.col".into(), "body".into()];
|
||||
// b wrapped in an extra div — DOM path changed but mostly preserved
|
||||
b.ancestors = vec!["form#f".into(), "div.wrap".into(), "div.col".into(), "body".into()];
|
||||
b.ancestors = vec![
|
||||
"form#f".into(),
|
||||
"div.wrap".into(),
|
||||
"div.col".into(),
|
||||
"body".into(),
|
||||
];
|
||||
let s = score(&a, &b);
|
||||
assert!(s > 0.85, "got {s}");
|
||||
}
|
||||
|
||||
@@ -1094,7 +1094,10 @@ impl BrowserManager {
|
||||
if !via_relay {
|
||||
return None;
|
||||
}
|
||||
let name = DAEMON_SESSION.get().map(String::as_str).unwrap_or("default");
|
||||
let name = DAEMON_SESSION
|
||||
.get()
|
||||
.map(String::as_str)
|
||||
.unwrap_or("default");
|
||||
if name.is_empty() {
|
||||
None
|
||||
} else {
|
||||
@@ -1853,8 +1856,14 @@ mod tests {
|
||||
#[test]
|
||||
fn liveness_transport_error_is_dead_for_both_kinds() {
|
||||
// A closed/reset WebSocket is a genuine death — reconnect in both cases.
|
||||
assert!(!connection_alive_from_probe(LivenessProbe::TransportError, true));
|
||||
assert!(!connection_alive_from_probe(LivenessProbe::TransportError, false));
|
||||
assert!(!connection_alive_from_probe(
|
||||
LivenessProbe::TransportError,
|
||||
true
|
||||
));
|
||||
assert!(!connection_alive_from_probe(
|
||||
LivenessProbe::TransportError,
|
||||
false
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -146,6 +146,16 @@ struct ChromeArgs {
|
||||
temp_user_data_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
/// Whether to launch Chrome headless. The stealth fork FORBIDS headless (it's a
|
||||
/// bot-detection tell), so this is `false` unless an operator explicitly opts in
|
||||
/// via `AGENT_BROWSER_ALLOW_HEADLESS=1` for a display-less server. The `headless`
|
||||
/// LaunchOption is intentionally ignored — headed is non-negotiable for stealth.
|
||||
fn launch_headless() -> bool {
|
||||
std::env::var("AGENT_BROWSER_ALLOW_HEADLESS")
|
||||
.map(|v| v == "1" || v.eq_ignore_ascii_case("true"))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Decide the `--force-webrtc-ip-handling-policy` value, if any, for a launched
|
||||
/// Chrome. Returns `None` to leave WebRTC at Chrome's default behavior.
|
||||
fn webrtc_ip_handling_policy(has_proxy: bool) -> Option<&'static str> {
|
||||
@@ -202,9 +212,13 @@ fn build_chrome_args(options: &LaunchOptions) -> Result<ChromeArgs, String> {
|
||||
.as_ref()
|
||||
.is_some_and(|exts| !exts.is_empty());
|
||||
|
||||
// Extensions require headed mode in native Chrome (content scripts are not
|
||||
// injected in headless mode). Skip --headless when extensions are loaded.
|
||||
if options.headless && !has_extensions {
|
||||
// Stealth fork: NEVER launch headless. Headless Chrome is a detectable tell
|
||||
// (creepjs scores ~33% headless even with new-headless; a real GPU and a
|
||||
// headed window score 0%). So we always launch headed and ignore the
|
||||
// `headless` option. The only escape is an explicit AGENT_BROWSER_ALLOW_HEADLESS=1
|
||||
// for genuinely display-less servers (discouraged — it forfeits stealth).
|
||||
// Extensions also require headed mode (content scripts aren't injected headless).
|
||||
if launch_headless() && !has_extensions {
|
||||
args.push("--headless=new".to_string());
|
||||
// Linux paints native scrollbars into viewport screenshots unless
|
||||
// Chrome is launched with this flag. `--hide-scrollbars` is
|
||||
@@ -278,7 +292,7 @@ fn build_chrome_args(options: &LaunchOptions) -> Result<ChromeArgs, String> {
|
||||
.iter()
|
||||
.any(|a| a.starts_with("--start-maximized") || a.starts_with("--window-size="));
|
||||
|
||||
if !has_window_size && options.headless && !has_extensions {
|
||||
if !has_window_size && launch_headless() && !has_extensions {
|
||||
let (w, h) = options.viewport_size.unwrap_or((1280, 720));
|
||||
args.push(format!("--window-size={},{}", w, h));
|
||||
}
|
||||
@@ -759,6 +773,26 @@ fn running_process_cmdlines() -> Option<Vec<String>> {
|
||||
}
|
||||
|
||||
pub async fn auto_connect_cdp() -> Result<String, String> {
|
||||
// Prefer the dialog-free `ab-connect` extension relay when it is live.
|
||||
// The relay drives the user's REAL Chrome via the extension's
|
||||
// `chrome.debugger` permission, which — unlike a raw `--remote-debugging-port`
|
||||
// CDP attach — never triggers Chrome 136+'s per-connection
|
||||
// "Allow remote debugging?" consent modal. The native-messaging host writes
|
||||
// ~/.agent-browser/relay-cdp-url while connected and removes it on exit, so a
|
||||
// present URL means the relay is up. This must win over the DevToolsActivePort
|
||||
// / :9222 probes below: if the user's Chrome happens to also be listening on a
|
||||
// debug port, attaching there would pop the consent dialog and defeat the
|
||||
// whole zero-interaction extension path.
|
||||
if let Some(relay) = crate::connect::relay_url() {
|
||||
// The relay is a local CDP-over-WS endpoint we connect to like Chrome.
|
||||
// A bare TCP liveness check (no WS upgrade) confirms it is actually
|
||||
// accepting before we commit, mirroring the consent-free probe used for
|
||||
// DevToolsActivePort.
|
||||
if relay_is_live(&relay).await {
|
||||
return Ok(relay);
|
||||
}
|
||||
}
|
||||
|
||||
let user_data_dirs = get_chrome_user_data_dirs();
|
||||
|
||||
for dir in &user_data_dirs {
|
||||
@@ -779,11 +813,13 @@ pub async fn auto_connect_cdp() -> Result<String, String> {
|
||||
}
|
||||
}
|
||||
|
||||
Err("No running Chrome with remote debugging found. Remote debugging is a \
|
||||
Err(
|
||||
"No running Chrome with remote debugging found. Remote debugging is a \
|
||||
startup flag, not a setting: fully quit Chrome and relaunch it with \
|
||||
--remote-debugging-port=9222 (then agent-browser auto-connects), or pass \
|
||||
--cdp <port>/--launch."
|
||||
.to_string())
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Resolve a CDP WebSocket URL from a DevToolsActivePort entry.
|
||||
@@ -827,15 +863,27 @@ async fn resolve_cdp_from_active_port(port: u16, ws_path: &str) -> Result<String
|
||||
async fn tcp_port_alive(port: u16) -> bool {
|
||||
let timeout = Duration::from_secs(1);
|
||||
matches!(
|
||||
tokio::time::timeout(
|
||||
timeout,
|
||||
tokio::net::TcpStream::connect(("127.0.0.1", port)),
|
||||
)
|
||||
.await,
|
||||
tokio::time::timeout(timeout, tokio::net::TcpStream::connect(("127.0.0.1", port)),).await,
|
||||
Ok(Ok(_))
|
||||
)
|
||||
}
|
||||
|
||||
/// Consent-free liveness for the `ab-connect` relay ws URL (`ws://127.0.0.1:<port>/…`).
|
||||
/// Parses the port and does a bare TCP connect — a stale relay-cdp-url file
|
||||
/// (host exited without cleanup) must not divert auto-connect away from the
|
||||
/// working port path.
|
||||
async fn relay_is_live(ws_url: &str) -> bool {
|
||||
let port = ws_url
|
||||
.strip_prefix("ws://")
|
||||
.and_then(|rest| rest.split('/').next())
|
||||
.and_then(|hostport| hostport.rsplit(':').next())
|
||||
.and_then(|p| p.parse::<u16>().ok());
|
||||
match port {
|
||||
Some(p) => tcp_port_alive(p).await,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the default Chrome user-data directory paths for the current platform.
|
||||
/// Includes Chrome, Chrome Canary, Chromium, and Brave.
|
||||
pub fn get_chrome_user_data_dirs() -> Vec<PathBuf> {
|
||||
@@ -1520,24 +1568,44 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_args_headless_includes_headless_flag() {
|
||||
fn test_build_args_forbids_headless_by_default() {
|
||||
// Stealth fork: headless is FORBIDDEN. `headless: true` is ignored — the
|
||||
// launch is always headed (no --headless / swiftshader / forced size).
|
||||
let g = EnvGuard::new(&["AGENT_BROWSER_ALLOW_HEADLESS"]);
|
||||
g.remove("AGENT_BROWSER_ALLOW_HEADLESS");
|
||||
let opts = LaunchOptions {
|
||||
headless: true,
|
||||
..Default::default()
|
||||
};
|
||||
let result = build_chrome_args(&opts).unwrap();
|
||||
assert!(
|
||||
!result.args.iter().any(|a| a.contains("--headless")),
|
||||
"headless must be forbidden even when the headless option is true"
|
||||
);
|
||||
assert!(!result
|
||||
.args
|
||||
.iter()
|
||||
.any(|a| a == "--enable-unsafe-swiftshader"));
|
||||
if let Some(dir) = result.temp_user_data_dir {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_args_allow_headless_escape() {
|
||||
// The only way back to headless: an explicit opt-in for display-less servers.
|
||||
let g = EnvGuard::new(&["AGENT_BROWSER_ALLOW_HEADLESS"]);
|
||||
g.set("AGENT_BROWSER_ALLOW_HEADLESS", "1");
|
||||
let opts = LaunchOptions {
|
||||
headless: true,
|
||||
..Default::default()
|
||||
};
|
||||
let result = build_chrome_args(&opts).unwrap();
|
||||
assert!(result.args.iter().any(|a| a == "--headless=new"));
|
||||
assert!(result.args.iter().any(|a| a == "--hide-scrollbars"));
|
||||
assert!(result
|
||||
.args
|
||||
.iter()
|
||||
.any(|a| a == "--enable-unsafe-swiftshader"));
|
||||
assert!(result.args.iter().any(|a| a == "--window-size=1280,720"));
|
||||
// Temp dir created when no profile
|
||||
assert!(result.temp_user_data_dir.is_some());
|
||||
let dir = result.temp_user_data_dir.unwrap();
|
||||
assert!(dir.exists());
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
if let Some(dir) = result.temp_user_data_dir {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2111,7 +2179,11 @@ mod tests {
|
||||
let ws_path = "/devtools/browser/test-uuid-1234";
|
||||
|
||||
let result = resolve_cdp_from_active_port(port, ws_path).await;
|
||||
assert!(result.is_ok(), "should succeed when port is live: {:?}", result);
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"should succeed when port is live: {:?}",
|
||||
result
|
||||
);
|
||||
assert_eq!(
|
||||
result.unwrap(),
|
||||
format!("ws://127.0.0.1:{}{}", port, ws_path),
|
||||
@@ -2137,11 +2209,8 @@ mod tests {
|
||||
// The liveness check connects then drops without writing anything.
|
||||
// Assert we receive no WebSocket upgrade bytes (EOF / no data).
|
||||
let mut buf = [0u8; 128];
|
||||
let read = tokio::time::timeout(
|
||||
Duration::from_millis(500),
|
||||
stream.read(&mut buf),
|
||||
)
|
||||
.await;
|
||||
let read =
|
||||
tokio::time::timeout(Duration::from_millis(500), stream.read(&mut buf)).await;
|
||||
match read {
|
||||
Ok(Ok(n)) => assert_eq!(n, 0, "resolve must not send a WS/CDP handshake"),
|
||||
Ok(Err(_)) | Err(_) => {} // closed or nothing sent — both fine
|
||||
@@ -2166,4 +2235,35 @@ mod tests {
|
||||
let result = resolve_cdp_from_active_port(port, "/devtools/browser/dead").await;
|
||||
assert!(result.is_err(), "should fail when nothing is listening");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_relay_is_live_true_when_listening() {
|
||||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
let url = format!("ws://127.0.0.1:{}/abc-guid", port);
|
||||
assert!(
|
||||
relay_is_live(&url).await,
|
||||
"relay_is_live should be true while the port is accepting"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_relay_is_live_false_when_dead() {
|
||||
// Bind to grab a free port, then drop so nothing is listening.
|
||||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
drop(listener);
|
||||
let url = format!("ws://127.0.0.1:{}/abc-guid", port);
|
||||
assert!(
|
||||
!relay_is_live(&url).await,
|
||||
"relay_is_live must be false for a stale relay-cdp-url (host exited)"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_relay_is_live_false_on_malformed_url() {
|
||||
assert!(!relay_is_live("not-a-ws-url").await);
|
||||
assert!(!relay_is_live("ws://127.0.0.1/no-port").await);
|
||||
assert!(!relay_is_live("ws://127.0.0.1:notaport/x").await);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,6 +346,11 @@ mod tests {
|
||||
|
||||
#[cfg(unix)]
|
||||
#[tokio::test]
|
||||
// Spawns a real child process and binds a TCP server with timing-based
|
||||
// readiness assumptions; flaky under CI load (intermittent "exited before
|
||||
// CDP became ready" / connection-refused races). Run locally with
|
||||
// `--ignored` when touching lightpanda startup.
|
||||
#[ignore = "process spawn + socket timing race, flaky in CI"]
|
||||
async fn waits_for_ready_without_logs() {
|
||||
let port = unused_port();
|
||||
tokio::spawn(serve_json_version_once_after_delay(
|
||||
|
||||
@@ -276,12 +276,8 @@ pub async fn resolve_element_center(
|
||||
//
|
||||
// Set AGENT_BROWSER_VERIFY_CLICK_TARGET=0 to skip.
|
||||
if std::env::var("AGENT_BROWSER_VERIFY_CLICK_TARGET").as_deref() != Ok("0") {
|
||||
if let Err(e) =
|
||||
verify_click_target(client, effective_session_id, active_id, &ref_id, x, y)
|
||||
.await
|
||||
{
|
||||
return Err(e);
|
||||
}
|
||||
verify_click_target(client, effective_session_id, active_id, &ref_id, x, y)
|
||||
.await?;
|
||||
}
|
||||
return Ok((x, y, effective_session_id.to_string()));
|
||||
}
|
||||
@@ -586,7 +582,9 @@ async fn verify_click_target(
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
let Ok(resolved) = resolve_resp else { return Ok(()) };
|
||||
let Ok(resolved) = resolve_resp else {
|
||||
return Ok(());
|
||||
};
|
||||
let Some(object_id) = resolved
|
||||
.get("object")
|
||||
.and_then(|o| o.get("objectId"))
|
||||
|
||||
@@ -24,10 +24,24 @@ pub async fn click(
|
||||
// inside the viewport. Without this, an element below the fold (or revealed
|
||||
// after scroll/popup) yields off-viewport coordinates and the click lands on
|
||||
// whatever currently occupies that point. Best-effort: ignore failures.
|
||||
scroll_into_view_if_needed(client, session_id, ref_map, selector_or_ref, iframe_sessions).await;
|
||||
scroll_into_view_if_needed(
|
||||
client,
|
||||
session_id,
|
||||
ref_map,
|
||||
selector_or_ref,
|
||||
iframe_sessions,
|
||||
)
|
||||
.await;
|
||||
|
||||
if mode == "dom" {
|
||||
return dom_click(client, session_id, ref_map, selector_or_ref, iframe_sessions).await;
|
||||
return dom_click(
|
||||
client,
|
||||
session_id,
|
||||
ref_map,
|
||||
selector_or_ref,
|
||||
iframe_sessions,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
let resolved = resolve_element_center(
|
||||
@@ -57,9 +71,15 @@ pub async fn click(
|
||||
"[click] coordinate click failed ({e}); falling back to DOM dispatch \
|
||||
(set AGENT_BROWSER_CLICK_MODE=coord to disable)"
|
||||
);
|
||||
dom_click(client, session_id, ref_map, selector_or_ref, iframe_sessions)
|
||||
.await
|
||||
.map_err(|dom_err| format!("{e}\n(DOM-dispatch fallback also failed: {dom_err})"))
|
||||
dom_click(
|
||||
client,
|
||||
session_id,
|
||||
ref_map,
|
||||
selector_or_ref,
|
||||
iframe_sessions,
|
||||
)
|
||||
.await
|
||||
.map_err(|dom_err| format!("{e}\n(DOM-dispatch fallback also failed: {dom_err})"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ pub mod policy;
|
||||
#[allow(dead_code)]
|
||||
pub mod providers;
|
||||
#[allow(dead_code)]
|
||||
pub mod relay;
|
||||
#[allow(dead_code)]
|
||||
pub mod react;
|
||||
#[allow(dead_code)]
|
||||
pub mod recording;
|
||||
#[allow(dead_code)]
|
||||
pub mod relay;
|
||||
#[allow(dead_code)]
|
||||
pub mod screenshot;
|
||||
#[allow(dead_code)]
|
||||
pub mod snapshot;
|
||||
|
||||
@@ -129,12 +129,18 @@ impl RelayState {
|
||||
ClientRoute::Local(json!({ "id": id, "result": {} }))
|
||||
}
|
||||
"Target.getTargets" => {
|
||||
let infos: Vec<Value> =
|
||||
self.targets.values().map(|t| t.target_info.clone()).collect();
|
||||
let infos: Vec<Value> = self
|
||||
.targets
|
||||
.values()
|
||||
.map(|t| t.target_info.clone())
|
||||
.collect();
|
||||
ClientRoute::Local(json!({ "id": id, "result": { "targetInfos": infos } }))
|
||||
}
|
||||
"Target.attachToTarget" => {
|
||||
let target_id = params.get("targetId").and_then(|t| t.as_str()).unwrap_or("");
|
||||
let target_id = params
|
||||
.get("targetId")
|
||||
.and_then(|t| t.as_str())
|
||||
.unwrap_or("");
|
||||
match self.targets.get(target_id) {
|
||||
Some(entry) => ClientRoute::Local(
|
||||
json!({ "id": id, "result": { "sessionId": entry.session_id } }),
|
||||
@@ -237,7 +243,10 @@ impl RelayState {
|
||||
.to_string();
|
||||
self.targets.insert(
|
||||
tid.to_string(),
|
||||
TargetEntry { session_id: sid, target_info: info.clone() },
|
||||
TargetEntry {
|
||||
session_id: sid,
|
||||
target_info: info.clone(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -305,7 +314,10 @@ mod tests {
|
||||
fn learns_target_from_attached_event_and_does_not_forward_it() {
|
||||
let mut s = RelayState::new();
|
||||
let out = s.handle_ext_message(&attached_event("T1", "cb-tab-1"), "tok");
|
||||
assert!(out.is_empty(), "attachedToTarget should be consumed, not forwarded");
|
||||
assert!(
|
||||
out.is_empty(),
|
||||
"attachedToTarget should be consumed, not forwarded"
|
||||
);
|
||||
// Now getTargets must report it.
|
||||
let route = s.route_client_command(1, &json!({ "id": 1, "method": "Target.getTargets" }));
|
||||
match route {
|
||||
@@ -384,8 +396,14 @@ mod tests {
|
||||
fn reply_routes_back_to_the_issuing_client_with_original_id() {
|
||||
let mut s = RelayState::new();
|
||||
// Two clients each send a command that happens to share original id 1.
|
||||
let r1 = s.route_client_command(100, &json!({ "id": 1, "method": "Page.navigate", "params": {} }));
|
||||
let r2 = s.route_client_command(200, &json!({ "id": 1, "method": "Page.reload", "params": {} }));
|
||||
let r1 = s.route_client_command(
|
||||
100,
|
||||
&json!({ "id": 1, "method": "Page.navigate", "params": {} }),
|
||||
);
|
||||
let r2 = s.route_client_command(
|
||||
200,
|
||||
&json!({ "id": 1, "method": "Page.reload", "params": {} }),
|
||||
);
|
||||
let g1 = match r1 {
|
||||
ClientRoute::Forward(v) => v["id"].as_i64().unwrap(),
|
||||
_ => panic!(),
|
||||
@@ -419,7 +437,10 @@ mod tests {
|
||||
#[test]
|
||||
fn forward_command_error_is_wrapped_and_routed() {
|
||||
let mut s = RelayState::new();
|
||||
let r = s.route_client_command(5, &json!({ "id": 3, "method": "Page.navigate", "params": {} }));
|
||||
let r = s.route_client_command(
|
||||
5,
|
||||
&json!({ "id": 3, "method": "Page.navigate", "params": {} }),
|
||||
);
|
||||
let gid = match r {
|
||||
ClientRoute::Forward(v) => v["id"].as_i64().unwrap(),
|
||||
_ => panic!(),
|
||||
@@ -459,7 +480,10 @@ mod tests {
|
||||
#[test]
|
||||
fn drop_client_clears_its_pending() {
|
||||
let mut s = RelayState::new();
|
||||
let r = s.route_client_command(9, &json!({ "id": 1, "method": "Page.navigate", "params": {} }));
|
||||
let r = s.route_client_command(
|
||||
9,
|
||||
&json!({ "id": 1, "method": "Page.navigate", "params": {} }),
|
||||
);
|
||||
let gid = match r {
|
||||
ClientRoute::Forward(v) => v["id"].as_i64().unwrap(),
|
||||
_ => panic!(),
|
||||
@@ -478,7 +502,12 @@ mod tests {
|
||||
let mut s = RelayState::new();
|
||||
let req = json!({ "type": "req", "id": "c1", "method": "connect", "params": { "auth": { "token": "good" } } });
|
||||
let ok = s.handle_ext_message(&req, "good");
|
||||
assert_eq!(ok, vec![RelayOut::ToExt(json!({ "type": "res", "id": "c1", "ok": true }))]);
|
||||
assert_eq!(
|
||||
ok,
|
||||
vec![RelayOut::ToExt(
|
||||
json!({ "type": "res", "id": "c1", "ok": true })
|
||||
)]
|
||||
);
|
||||
|
||||
let bad = s.handle_ext_message(&req, "different");
|
||||
match &bad[0] {
|
||||
|
||||
@@ -2,11 +2,11 @@ use std::collections::HashMap;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
use super::adaptive::ElementFingerprint;
|
||||
use super::cdp::client::CdpClient;
|
||||
use super::cdp::types::{
|
||||
AXNode, AXProperty, AXValue, EvaluateParams, EvaluateResult, GetFullAXTreeResult,
|
||||
};
|
||||
use super::adaptive::ElementFingerprint;
|
||||
use super::element::{resolve_ax_session, RefMap};
|
||||
|
||||
const INTERACTIVE_ROLES: &[&str] = &[
|
||||
|
||||
@@ -186,9 +186,7 @@ fn resolve_timezone(locale: Option<&str>) -> Option<String> {
|
||||
return None;
|
||||
}
|
||||
if raw.eq_ignore_ascii_case("auto") {
|
||||
return locale
|
||||
.and_then(locale_default_timezone)
|
||||
.map(str::to_string);
|
||||
return locale.and_then(locale_default_timezone).map(str::to_string);
|
||||
}
|
||||
Some(raw.to_string())
|
||||
}
|
||||
@@ -265,8 +263,7 @@ pub fn strip_source_url_labels(input: &str) -> String {
|
||||
let re_line = regex_lite::Regex::new(r"(?i)\n?\s*//[@#]\s*sourceURL=[^\n\r]*").unwrap();
|
||||
let output = re_line.replace_all(input, "");
|
||||
// Remove /*# sourceURL=...*/ block comments
|
||||
let re_block =
|
||||
regex_lite::Regex::new(r"(?is)\n?\s*/\*[@#]\s*sourceURL=[\s\S]*?\*/").unwrap();
|
||||
let re_block = regex_lite::Regex::new(r"(?is)\n?\s*/\*[@#]\s*sourceURL=[\s\S]*?\*/").unwrap();
|
||||
re_block.replace_all(&output, "").to_string()
|
||||
}
|
||||
|
||||
@@ -370,7 +367,10 @@ mod timezone_tests {
|
||||
assert_eq!(resolve_timezone(Some("en-US")), None);
|
||||
|
||||
std::env::set_var("AGENT_BROWSER_TIMEZONE", "auto");
|
||||
assert_eq!(resolve_timezone(Some("ja-JP")), Some("Asia/Tokyo".to_string()));
|
||||
assert_eq!(
|
||||
resolve_timezone(Some("ja-JP")),
|
||||
Some("Asia/Tokyo".to_string())
|
||||
);
|
||||
assert_eq!(resolve_timezone(Some("xx-YY")), None);
|
||||
assert_eq!(resolve_timezone(None), None);
|
||||
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
const __abStealth = { locale: "en-US", languages: ["en-US", "en"], allowWebGLContextFallback: false, hideCanvas: false, canvasSeed: 0 };
|
||||
// Redefine a navigator property on its PROTOTYPE (Navigator / WorkerNavigator),
|
||||
// the way real Chrome exposes these — as prototype getters, NOT instance own
|
||||
// properties. Adding an own property to the `navigator` instance is itself a
|
||||
// detectable automation tell: real Chrome's `Object.getOwnPropertyNames(navigator)`
|
||||
// is empty, so any name we leave on the instance is caught by rebrowser's
|
||||
// `navigatorWebdriver` probe and similar checks. We mirror the proven `vendor`
|
||||
// patch below: define on the prototype, native-mask the getter's toString, then
|
||||
// delete any instance shadow. Falls back to an instance define only if the
|
||||
// prototype is locked. (A top-level `const` like this is script-scoped, not a
|
||||
// `window` property, so it does not leak — same as `__abStealth` above.)
|
||||
const __abRedefineNavProto = (name, getterImpl) => {
|
||||
try {
|
||||
const proto = Object.getPrototypeOf(navigator);
|
||||
const nativeGet = Object.getOwnPropertyDescriptor(proto, name) && Object.getOwnPropertyDescriptor(proto, name).get;
|
||||
const getter = function () { return getterImpl(); };
|
||||
if (nativeGet) {
|
||||
Object.defineProperty(getter, 'name', { value: 'get ' + name, configurable: true });
|
||||
Object.defineProperty(getter, 'toString', { value: () => nativeGet.toString(), configurable: true, writable: true });
|
||||
}
|
||||
Object.defineProperty(proto, name, { get: getter, configurable: true, enumerable: true });
|
||||
try { delete navigator[name]; } catch (e) {}
|
||||
return true;
|
||||
} catch (e) {
|
||||
try { Object.defineProperty(navigator, name, { get: () => getterImpl(), configurable: true }); } catch (e2) {}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
(function(){
|
||||
// Prefer the CDP-level automation override (Emulation.setAutomationOverride),
|
||||
// which makes navigator.webdriver report `false` NATIVELY — undetectable by
|
||||
@@ -354,18 +381,8 @@ const __abStealth = { locale: "en-US", languages: ["en-US", "en"], allowWebGLCon
|
||||
const config = (typeof __abStealth === 'object' && __abStealth) ? __abStealth : null;
|
||||
if (!config || !Array.isArray(config.languages) || config.languages.length === 0) return;
|
||||
const locale = typeof config.locale === 'string' ? config.locale : config.languages[0];
|
||||
try {
|
||||
Object.defineProperty(navigator, 'language', {
|
||||
get: () => locale,
|
||||
configurable: true,
|
||||
});
|
||||
} catch {}
|
||||
try {
|
||||
Object.defineProperty(navigator, 'languages', {
|
||||
get: () => config.languages.slice(),
|
||||
configurable: true,
|
||||
});
|
||||
} catch {}
|
||||
__abRedefineNavProto('language', () => locale);
|
||||
__abRedefineNavProto('languages', () => config.languages.slice());
|
||||
})();
|
||||
(function(){
|
||||
const ua = String(navigator.userAgent || '');
|
||||
@@ -394,6 +411,24 @@ const __abStealth = { locale: "en-US", languages: ["en-US", "en"], allowWebGLCon
|
||||
defineVendor(navigator);
|
||||
})();
|
||||
(function(){
|
||||
// Native > JS lies: a real headed Chrome already exposes the correct, fully
|
||||
// native navigator.plugins (5 PDF-viewer aliases, a native item() that does
|
||||
// the WebIDL uint32-index wrap, length on the prototype). Overriding that
|
||||
// with a JS fake is strictly worse — it ships a non-native item() whose
|
||||
// .toString() reveals the patch, breaks the uint32 wrap (incolumitas
|
||||
// overflowTest), and pins an anachronistic "Native Client" plugin that modern
|
||||
// Chrome removed. Since this fork forbids headless and always launches headed,
|
||||
// the native plugins are present, so we leave them alone. We only fall back to
|
||||
// a synthetic list when native plugins are genuinely empty (e.g. the
|
||||
// discouraged AGENT_BROWSER_ALLOW_HEADLESS escape on old headless).
|
||||
try {
|
||||
const np = navigator.plugins;
|
||||
const itemNative =
|
||||
np && typeof np.item === 'function' &&
|
||||
/\[native code\]/.test(Function.prototype.toString.call(np.item));
|
||||
if (np && np.length > 0 && itemNative) return;
|
||||
} catch (e) {}
|
||||
|
||||
const makeMimeType = (type, suffixes, description) => {
|
||||
const mime = Object.create(MimeType.prototype);
|
||||
Object.defineProperties(mime, {
|
||||
@@ -427,40 +462,54 @@ const __abStealth = { locale: "en-US", languages: ["en-US", "en"], allowWebGLCon
|
||||
return plugin;
|
||||
};
|
||||
|
||||
// Make a fake method masquerade as native: name + `[native code]` toString.
|
||||
const maskNative = (fn, name) => {
|
||||
Object.defineProperty(fn, 'name', { value: name, configurable: true });
|
||||
Object.defineProperty(fn, 'toString', {
|
||||
value: () => `function ${name}() { [native code] }`,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
return fn;
|
||||
};
|
||||
|
||||
// Modern Chrome (since ~v109) exposes exactly these 5 PDF-viewer aliases and
|
||||
// two mimeTypes (application/pdf, text/pdf). Native Client was removed years
|
||||
// ago, so it must NOT appear. Each plugin carries both mimeTypes.
|
||||
const pdfMime = makeMimeType('application/pdf', 'pdf', 'Portable Document Format');
|
||||
const chromePdfMime = makeMimeType(
|
||||
'application/x-google-chrome-pdf',
|
||||
'pdf',
|
||||
'Portable Document Format'
|
||||
);
|
||||
const naclMime = makeMimeType('application/x-nacl', '', 'Native Client Executable');
|
||||
const pnaclMime = makeMimeType('application/x-pnacl', '', 'Portable Native Client Executable');
|
||||
const textPdfMime = makeMimeType('text/pdf', 'pdf', 'Portable Document Format');
|
||||
const mimes = [pdfMime, textPdfMime];
|
||||
|
||||
const plugins = [
|
||||
makePlugin('Chrome PDF Plugin', 'Portable Document Format', 'internal-pdf-viewer', [chromePdfMime]),
|
||||
makePlugin('Chrome PDF Viewer', '', 'mhjfbmdgcfjbbpaeojofohoefgiehjai', [pdfMime]),
|
||||
makePlugin('Native Client', '', 'internal-nacl-plugin', [naclMime, pnaclMime]),
|
||||
];
|
||||
'PDF Viewer',
|
||||
'Chrome PDF Viewer',
|
||||
'Chromium PDF Viewer',
|
||||
'Microsoft Edge PDF Viewer',
|
||||
'WebKit built-in PDF',
|
||||
].map((name) => makePlugin(name, 'Portable Document Format', 'internal-pdf-viewer', mimes));
|
||||
|
||||
const pluginArray = Object.create(PluginArray.prototype);
|
||||
plugins.forEach((p, i) => {
|
||||
pluginArray[i] = p;
|
||||
pluginArray[p.name] = p;
|
||||
});
|
||||
Object.defineProperty(pluginArray, 'length', { get: () => plugins.length });
|
||||
pluginArray.item = (i) => plugins[i] || null;
|
||||
pluginArray.namedItem = (name) => plugins.find(p => p.name === name) || null;
|
||||
pluginArray.refresh = () => {};
|
||||
// `i >>> 0` replicates the WebIDL unsigned-long index coercion, so
|
||||
// item(2**32) wraps to item(0) like the real native PluginArray.item.
|
||||
pluginArray.item = maskNative((i) => plugins[i >>> 0] || null, 'item');
|
||||
pluginArray.namedItem = maskNative((name) => plugins.find(p => p.name === name) || null, 'namedItem');
|
||||
pluginArray.refresh = maskNative(() => {}, 'refresh');
|
||||
pluginArray[Symbol.iterator] = function*() { for (const p of plugins) yield p; };
|
||||
|
||||
const mimeTypes = [chromePdfMime, pdfMime, naclMime, pnaclMime];
|
||||
const mimeTypes = [pdfMime, textPdfMime];
|
||||
const mimeTypeArray = Object.create(MimeTypeArray.prototype);
|
||||
mimeTypes.forEach((m, i) => {
|
||||
mimeTypeArray[i] = m;
|
||||
mimeTypeArray[m.type] = m;
|
||||
});
|
||||
Object.defineProperty(mimeTypeArray, 'length', { get: () => mimeTypes.length });
|
||||
mimeTypeArray.item = (i) => mimeTypes[i] || null;
|
||||
mimeTypeArray.namedItem = (name) => mimeTypes.find(m => m.type === name) || null;
|
||||
mimeTypeArray.item = maskNative((i) => mimeTypes[i >>> 0] || null, 'item');
|
||||
mimeTypeArray.namedItem = maskNative((name) => mimeTypes.find(m => m.type === name) || null, 'namedItem');
|
||||
mimeTypeArray[Symbol.iterator] = function*() { for (const m of mimeTypes) yield m; };
|
||||
|
||||
Object.defineProperty(navigator, 'plugins', {
|
||||
@@ -1023,10 +1072,15 @@ const __abStealth = { locale: "en-US", languages: ["en-US", "en"], allowWebGLCon
|
||||
return false;
|
||||
}
|
||||
};
|
||||
if (defineContacts(navigator)) return;
|
||||
try {
|
||||
defineContacts(Object.getPrototypeOf(navigator));
|
||||
} catch {}
|
||||
// Prototype-first (like the vendor patch): real Chrome exposes navigator
|
||||
// members on the prototype, not as instance own properties. Define on the
|
||||
// prototype and remove any instance shadow so Object.getOwnPropertyNames(navigator)
|
||||
// stays empty; fall back to the instance only if the prototype is locked.
|
||||
if (defineContacts(Object.getPrototypeOf(navigator))) {
|
||||
try { delete navigator.contacts; } catch {}
|
||||
return;
|
||||
}
|
||||
defineContacts(navigator);
|
||||
})();
|
||||
(function(){
|
||||
const ContentIndexCtor = typeof ContentIndex === 'function'
|
||||
@@ -1233,12 +1287,7 @@ const __abStealth = { locale: "en-US", languages: ["en-US", "en"], allowWebGLCon
|
||||
}
|
||||
return values;
|
||||
};
|
||||
try {
|
||||
Object.defineProperty(navigator, 'userAgentData', {
|
||||
get: () => patched,
|
||||
configurable: true,
|
||||
});
|
||||
} catch {}
|
||||
__abRedefineNavProto('userAgentData', () => patched);
|
||||
})();
|
||||
(function(){
|
||||
const ua = navigator.userAgent;
|
||||
|
||||
@@ -1082,7 +1082,7 @@ Global Options:
|
||||
--json Output as JSON
|
||||
--session <name> Use specific session
|
||||
--headers <json> Set HTTP headers (scoped to this origin)
|
||||
--headed Show browser window
|
||||
--headed Show browser window (default; headless is forbidden — it's a bot tell)
|
||||
--enable react-devtools Inject the React DevTools hook before any page JS
|
||||
--init-script <path> Register a page init script (repeatable)
|
||||
|
||||
@@ -3114,7 +3114,8 @@ Options:
|
||||
--screenshot-dir <path> Default screenshot output directory (or AGENT_BROWSER_SCREENSHOT_DIR)
|
||||
--screenshot-quality <n> JPEG quality 0-100; ignored for PNG (or AGENT_BROWSER_SCREENSHOT_QUALITY)
|
||||
--screenshot-format <fmt> Screenshot format: png, jpeg (or AGENT_BROWSER_SCREENSHOT_FORMAT)
|
||||
--headed Show browser window (not headless) (or AGENT_BROWSER_HEADED env)
|
||||
--headed Always on (default). Headless is forbidden (bot-detection tell);
|
||||
display-less servers can opt back in with AGENT_BROWSER_ALLOW_HEADLESS=1
|
||||
--cdp <port> Connect via CDP (Chrome DevTools Protocol)
|
||||
--color-scheme <scheme> Color scheme: dark, light, no-preference (or AGENT_BROWSER_COLOR_SCHEME)
|
||||
--download-path <path> Default download directory (or AGENT_BROWSER_DOWNLOAD_PATH)
|
||||
|
||||
@@ -84,7 +84,9 @@ fn embedded_skills_root() -> Option<PathBuf> {
|
||||
let _ = fs::create_dir_all(base.join("skills"));
|
||||
let _ = fs::create_dir_all(base.join("skill-data"));
|
||||
if EMBEDDED_SKILLS.extract(base.join("skills")).is_err()
|
||||
|| EMBEDDED_SKILL_DATA.extract(base.join("skill-data")).is_err()
|
||||
|| EMBEDDED_SKILL_DATA
|
||||
.extract(base.join("skill-data"))
|
||||
.is_err()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,10 @@ pub fn run_upgrade() {
|
||||
color::success_indicator()
|
||||
);
|
||||
} else {
|
||||
eprintln!("{} Upgrade failed. Install manually:", color::error_indicator());
|
||||
eprintln!(
|
||||
"{} Upgrade failed. Install manually:",
|
||||
color::error_indicator()
|
||||
);
|
||||
eprintln!(" curl -fsSL {} | sh", INSTALL_URL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ const SKIP_URL = /^(chrome|chrome-extension|devtools|chrome-untrusted|edge|about
|
||||
|
||||
/** @type {chrome.runtime.Port|null} */
|
||||
let port = null
|
||||
/** Whether the native-messaging host (the local agent-browser CLI) is linked.
|
||||
* Read by the popup status page. */
|
||||
let hostConnected = false
|
||||
let nextSession = 1
|
||||
/** tabId -> { sessionId, targetId } */
|
||||
const tabs = new Map()
|
||||
@@ -92,13 +95,16 @@ function connectHost() {
|
||||
if (port) return
|
||||
try {
|
||||
port = chrome.runtime.connectNative(HOST_NAME)
|
||||
hostConnected = true
|
||||
} catch (e) {
|
||||
port = null
|
||||
hostConnected = false
|
||||
return
|
||||
}
|
||||
port.onMessage.addListener((msg) => void whenReady(() => onHostMessage(msg)))
|
||||
port.onDisconnect.addListener(() => {
|
||||
port = null
|
||||
hostConnected = false
|
||||
// Sessions are stale once the host is gone; the daemon re-discovers on
|
||||
// reconnect. Keep chrome.debugger attached so reconnect is cheap.
|
||||
for (const tabId of tabs.keys()) setBadge(tabId, 'connecting')
|
||||
@@ -343,7 +349,18 @@ chrome.tabs.onRemoved.addListener((tabId) => void whenReady(() => detachTab(tabI
|
||||
|
||||
chrome.runtime.onInstalled.addListener(() => void whenReady(connectHost))
|
||||
chrome.runtime.onStartup.addListener(() => void whenReady(connectHost))
|
||||
chrome.action.onClicked.addListener(() => void whenReady(connectHost))
|
||||
|
||||
// Popup status page asks for the live pairing state. Attempt a (re)connect on
|
||||
// demand so opening the popup also nudges the link awake, then report.
|
||||
chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
|
||||
if (msg && msg.type === 'ab-status') {
|
||||
if (!port) {
|
||||
try { connectHost() } catch (e) {}
|
||||
}
|
||||
sendResponse({ connected: hostConnected, tabCount: tabs.size, host: HOST_NAME })
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
// MV3 service workers get suspended; an alarm wakes us to keep the host link
|
||||
// and badges fresh.
|
||||
|
||||
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 644 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "agent-browser connect",
|
||||
"version": "0.4.0",
|
||||
"description": "Let agent-browser drive your logged-in Chrome — install once, no token, no per-use confirmation.",
|
||||
"name": "agent-browser-stealth",
|
||||
"version": "0.4.1",
|
||||
"description": "Let agent-browser drive your logged-in Chrome \u2014 install once, no token, no per-use confirmation.",
|
||||
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6vQIyscGIPYPZdSpPwPL0+0gxUROyRgCpmvCSDoc8XUm4qm97VbKnD9Ijc1lV22lNWZtE78gaRjt6BeSfuMgnBymnhLKjN1gU6AI5QUU0mrJyeHdWKvrKQR5FmsM2A7Xr1ykE2SiiS8zNUS3Y/6O5l+Nva7wrVy6E4a2dkBVQkOsu+DV+nEZvhIyuDY5D5SPXqNwUTWTaglwj5mjvHz36xSwCWlPmrtJ+ED0AUyrb2z4GIOmvk4kqtBVrh/UD058klLo4CkYOnIybB5aV6WYuwarfPY4bF/dLggPem+ewLNTUNBuwrxj/A4nUv0LJTuRO8rR7f8WR9qnRCY0Ic5saQIDAQAB",
|
||||
"icons": {
|
||||
"16": "icons/icon16.png",
|
||||
@@ -24,6 +24,7 @@
|
||||
"type": "module"
|
||||
},
|
||||
"action": {
|
||||
"default_title": "agent-browser connect"
|
||||
"default_title": "agent-browser-stealth",
|
||||
"default_popup": "popup.html"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<style>
|
||||
:root {
|
||||
--bg: #0f1115;
|
||||
--panel: #161a21;
|
||||
--fg: #e6edf3;
|
||||
--muted: #8b949e;
|
||||
--cyan: #2ad4ff;
|
||||
--green: #3fb950;
|
||||
--amber: #d29922;
|
||||
--border: #232a33;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; }
|
||||
body {
|
||||
width: 320px;
|
||||
background: var(--bg);
|
||||
color: var(--fg);
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 16px 16px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
header img { width: 32px; height: 32px; border-radius: 7px; }
|
||||
header .title { font-weight: 600; font-size: 14px; }
|
||||
header .ver { color: var(--muted); font-size: 11px; }
|
||||
main { padding: 14px 16px 8px; }
|
||||
.status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
padding: 10px 12px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 9px;
|
||||
}
|
||||
.dot {
|
||||
width: 9px; height: 9px; border-radius: 50%;
|
||||
background: var(--muted); flex: none;
|
||||
box-shadow: 0 0 0 0 rgba(0,0,0,0);
|
||||
}
|
||||
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
|
||||
.dot.off { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
|
||||
.status .label { font-weight: 600; }
|
||||
.status .sub { color: var(--muted); font-size: 11px; }
|
||||
.desc { color: var(--muted); margin: 12px 2px 4px; }
|
||||
.hint {
|
||||
margin: 10px 0 2px;
|
||||
padding: 9px 11px;
|
||||
background: #1d1a12;
|
||||
border: 1px solid #3a3014;
|
||||
border-radius: 8px;
|
||||
color: #e3c878;
|
||||
font-size: 12px;
|
||||
display: none;
|
||||
}
|
||||
.hint code {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
padding: 6px 8px;
|
||||
background: #0b0d10;
|
||||
border-radius: 6px;
|
||||
color: var(--cyan);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
font-size: 11.5px;
|
||||
user-select: all;
|
||||
}
|
||||
footer {
|
||||
padding: 10px 16px 14px;
|
||||
border-top: 1px solid var(--border);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
footer .privacy { color: var(--muted); font-size: 11px; }
|
||||
footer a { color: var(--cyan); text-decoration: none; font-size: 11px; cursor: pointer; }
|
||||
footer a:hover { text-decoration: underline; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<img src="icons/icon128.png" alt="" />
|
||||
<div>
|
||||
<div class="title">agent-browser-stealth</div>
|
||||
<div class="ver">local automation bridge</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="status">
|
||||
<span id="dot" class="dot"></span>
|
||||
<div>
|
||||
<div class="label" id="statusLabel">Checking…</div>
|
||||
<div class="sub" id="statusSub">contacting the local CLI</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="desc">
|
||||
Lets your locally-installed <strong>agent-browser</strong> command-line tool
|
||||
drive your own logged-in Chrome tabs — entirely on this machine, only when
|
||||
you run a command. No remote server, no data collection.
|
||||
</p>
|
||||
|
||||
<div class="hint" id="hint">
|
||||
Not linked yet. Install & pair the CLI, then reopen this popup:
|
||||
<code>agent-browser extension install</code>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<span class="privacy">No tracking · no remote server</span>
|
||||
<a id="repo" data-href="https://github.com/leeguooooo/agent-browser-stealth">GitHub ↗</a>
|
||||
</footer>
|
||||
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,64 @@
|
||||
// Popup status page for agent-browser-stealth.
|
||||
// Asks the service worker whether the native-messaging link to the local
|
||||
// agent-browser CLI is live, and renders a paired / not-paired indicator.
|
||||
|
||||
const dot = document.getElementById('dot')
|
||||
const label = document.getElementById('statusLabel')
|
||||
const sub = document.getElementById('statusSub')
|
||||
const hint = document.getElementById('hint')
|
||||
|
||||
let resolved = false
|
||||
|
||||
function render(state) {
|
||||
resolved = true
|
||||
const connected = !!(state && state.connected)
|
||||
dot.classList.remove('on', 'off')
|
||||
if (connected) {
|
||||
dot.classList.add('on')
|
||||
label.textContent = 'Connected'
|
||||
const n = state.tabCount | 0
|
||||
sub.textContent =
|
||||
n > 0
|
||||
? `bridged to the local CLI · ${n} tab${n === 1 ? '' : 's'} attached`
|
||||
: 'bridged to the local CLI · ready'
|
||||
hint.style.display = 'none'
|
||||
} else {
|
||||
dot.classList.add('off')
|
||||
label.textContent = 'Not paired'
|
||||
sub.textContent = 'no local agent-browser CLI linked'
|
||||
hint.style.display = 'block'
|
||||
}
|
||||
}
|
||||
|
||||
function queryStatus() {
|
||||
try {
|
||||
chrome.runtime.sendMessage({ type: 'ab-status' }, (resp) => {
|
||||
// lastError fires if the service worker can't be reached.
|
||||
if (chrome.runtime.lastError) {
|
||||
render({ connected: false })
|
||||
return
|
||||
}
|
||||
render(resp)
|
||||
})
|
||||
} catch (e) {
|
||||
render({ connected: false })
|
||||
}
|
||||
}
|
||||
|
||||
// Open the repo in a real tab (no inline handlers under MV3 CSP).
|
||||
const repo = document.getElementById('repo')
|
||||
if (repo) {
|
||||
repo.addEventListener('click', () => {
|
||||
chrome.tabs.create({ url: repo.dataset.href })
|
||||
})
|
||||
}
|
||||
|
||||
// Query now, then once more shortly after — opening the popup also nudges the
|
||||
// service worker to (re)connect the host, which may complete a beat later.
|
||||
queryStatus()
|
||||
setTimeout(queryStatus, 700)
|
||||
|
||||
// Never leave the popup stuck on "Checking…" if the worker never answers.
|
||||
setTimeout(() => {
|
||||
if (!resolved) render({ connected: false })
|
||||
}, 1500)
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Chrome Web Store 提交指南 — agent-browser connect</title>
|
||||
<title>Chrome Web Store 提交指南 — agent-browser-stealth</title>
|
||||
<style>
|
||||
:root{--fg:#1a1a1a;--muted:#5c5c5c;--accent:#2563eb;--warn:#b45309;--ok:#15803d;--border:#e2e2e2;--bg:#fff;--code:#f5f5f7}
|
||||
*{box-sizing:border-box}
|
||||
@@ -28,7 +28,7 @@
|
||||
<body>
|
||||
<header>
|
||||
<h1>Chrome Web Store 提交指南</h1>
|
||||
<div class="sub">agent-browser connect · 上传包 <code>extensions/ab-connect.zip</code> · id 锁定为 <code>ciiljdlhdpfckdcfkphgmfalanpdejep</code></div>
|
||||
<div class="sub">agent-browser-stealth · 上传包 <code>extensions/ab-connect.zip</code> · id 锁定为 <code>ciiljdlhdpfckdcfkphgmfalanpdejep</code></div>
|
||||
</header>
|
||||
|
||||
<p>为什么必须走商店:实测 Chrome 149 在<strong>非企业托管</strong>的 Mac 上,会把"非 Web Store"的 force-install 扩展直接标成 <code>[BLOCKED]</code>。商店扩展不受此限。这也是 codex / claude 扩展都发商店的原因。</p>
|
||||
@@ -53,13 +53,13 @@
|
||||
<h2>三、商店信息(直接复制以下文案)</h2>
|
||||
|
||||
<h3>名称 / Name</h3>
|
||||
<pre>agent-browser connect</pre>
|
||||
<pre>agent-browser-stealth</pre>
|
||||
|
||||
<h3>简介 / Summary(≤132 字符)</h3>
|
||||
<pre>Let your own agent-browser CLI drive your logged-in Chrome — a local automation bridge. No remote server, no token.</pre>
|
||||
|
||||
<h3>详细描述 / Description</h3>
|
||||
<pre>agent-browser connect is the in-browser half of the open-source agent-browser CLI. It lets the
|
||||
<pre>agent-browser-stealth is the in-browser half of the open-source agent-browser CLI. It lets the
|
||||
command-line tool you installed on this same computer automate the Chrome you're already logged
|
||||
into — opening pages, clicking, filling forms, reading the DOM — driven entirely by you.
|
||||
|
||||
@@ -94,6 +94,7 @@ automate pages the user is working with, entirely on the user's machine and at t
|
||||
<tr><th>权限</th><th>理由(复制到对应输入框)</th></tr>
|
||||
<tr><td class="field">debugger</td><td>Attaches the Chrome DevTools Protocol to the user's own active tab so the paired local agent-browser CLI can automate it (navigate, click, read DOM) only while the user is running a command. Commands arrive solely from the local CLI via native messaging; there is no remote endpoint.</td></tr>
|
||||
<tr><td class="field">tabs</td><td>Enumerate and target the correct open tab to attach automation to.</td></tr>
|
||||
<tr><td class="field">tabGroups</td><td>Organizes the tabs the local agent-browser CLI drives into a labeled, colored Chrome tab group per automation session, so the user can see at a glance which tabs are under automation and they stay visually separated from the user's own tabs.</td></tr>
|
||||
<tr><td class="field">nativeMessaging</td><td>The sole communication channel: a local native-messaging connection to the agent-browser CLI installed on the same machine. No network is used.</td></tr>
|
||||
<tr><td class="field">storage</td><td>Persist small local pairing/configuration state for the extension.</td></tr>
|
||||
<tr><td class="field">alarms</td><td>Keep the MV3 service worker alive during longer automation sessions.</td></tr>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Privacy Policy — agent-browser connect</title>
|
||||
<title>Privacy Policy — agent-browser-stealth</title>
|
||||
<style>
|
||||
:root{
|
||||
--fg:#1a1a1a; --muted:#5c5c5c; --accent:#2563eb; --border:#e2e2e2; --bg:#fff; --code:#f5f5f5;
|
||||
@@ -26,7 +26,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Privacy Policy — agent-browser connect</h1>
|
||||
<h1>Privacy Policy — agent-browser-stealth</h1>
|
||||
<div class="sub">Chrome extension (id <code>ciiljdlhdpfckdcfkphgmfalanpdejep</code>) · Last updated 2026-06-09</div>
|
||||
</header>
|
||||
|
||||
@@ -36,7 +36,7 @@ user's own <code>agent-browser</code> command-line tool, running on the same com
|
||||
user's logged-in Chrome.</p>
|
||||
|
||||
<h2>What the extension does</h2>
|
||||
<p>agent-browser connect pairs Chrome with the locally-installed <code>agent-browser</code> CLI over
|
||||
<p>agent-browser-stealth pairs Chrome with the locally-installed <code>agent-browser</code> CLI over
|
||||
Chrome <em>native messaging</em> (a local inter-process channel; no network socket, no token). When
|
||||
the user issues an automation command in the CLI, the extension relays Chrome DevTools Protocol
|
||||
operations to the tab the user targets. Everything happens on the user's machine, initiated by the
|
||||
@@ -71,7 +71,7 @@ extension talks only to a program the user installed on the same computer.</p>
|
||||
<p>Source code, issues, and contact: <code>https://github.com/leeguooooo/agent-browser-stealth</code></p>
|
||||
|
||||
<footer>
|
||||
agent-browser connect is open source (Apache-2.0). This policy applies to the extension only.
|
||||
agent-browser-stealth is open source (Apache-2.0). This policy applies to the extension only.
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "agent-browser-stealth",
|
||||
"version": "0.27.0-fork.26",
|
||||
"description": "Browser automation CLI for AI agents \u2014 stealth fork with anti-detection",
|
||||
"version": "0.27.0-fork.31",
|
||||
"description": "Browser automation CLI for AI agents — stealth fork with anti-detection",
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@11.1.3",
|
||||
"files": [
|
||||
|
||||
@@ -27,17 +27,10 @@ if (!cargoVersionMatch) {
|
||||
|
||||
const cargoVersion = cargoVersionMatch[1];
|
||||
|
||||
// Read dashboard package.json version
|
||||
const dashboardPkg = JSON.parse(readFileSync(join(rootDir, 'packages/dashboard/package.json'), 'utf-8'));
|
||||
const dashboardVersion = dashboardPkg.version;
|
||||
|
||||
const mismatches = [];
|
||||
if (packageVersion !== cargoVersion) {
|
||||
mismatches.push(` cli/Cargo.toml: ${cargoVersion}`);
|
||||
}
|
||||
if (packageVersion !== dashboardVersion) {
|
||||
mismatches.push(` packages/dashboard: ${dashboardVersion}`);
|
||||
}
|
||||
|
||||
if (mismatches.length > 0) {
|
||||
console.error('Version mismatch detected!');
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Build the Chrome Web Store upload package extensions/ab-connect.zip (and a signed
|
||||
# extensions/ab-connect.crx for reference) from extensions/ab-connect, keeping the
|
||||
# extension id constant via the stable signing key + manifest "key".
|
||||
# extensions/ab-connect.crx for reference) from extensions/ab-connect.
|
||||
#
|
||||
# The id MUST stay ciiljdlhdpfckdcfkphgmfalanpdejep so the native-messaging
|
||||
# allowed_origins and the force-install policy keep matching. The id is pinned by
|
||||
# the "key" field in manifest.json (kept in the uploaded zip on purpose).
|
||||
# IMPORTANT — the "key" field:
|
||||
# * The unpacked DIR (Load-unpacked) and the signed .crx KEEP the manifest "key",
|
||||
# which pins the id to ciiljdlhdpfckdcfkphgmfalanpdejep so the native-messaging
|
||||
# allowed_origins + managed force-install policy keep matching for local/dev use.
|
||||
# * The Web Store UPLOAD zip MUST NOT contain "key" — the store rejects it
|
||||
# ("manifest must not contain 'key'") and assigns its own id. So this script
|
||||
# strips "key" from the manifest inside the zip only. After the first upload,
|
||||
# note the store-assigned id and add it to the native-messaging allowed_origins
|
||||
# (cli/src/connect.rs EXTENSION_ID) so the store build can pair too.
|
||||
#
|
||||
# The private key lives at .secrets/ab-connect.pem and is git-ignored.
|
||||
#
|
||||
@@ -20,20 +25,35 @@ KEY=.secrets/ab-connect.pem
|
||||
EXT=extensions/ab-connect
|
||||
CHROME="${CHROME_BIN:-/Applications/Google Chrome.app/Contents/MacOS/Google Chrome}"
|
||||
|
||||
# Web Store upload package (zip of the unpacked extension, dotfiles excluded).
|
||||
# Web Store upload package: stage a copy with the "key" field removed, then zip.
|
||||
STAGE=$(mktemp -d)
|
||||
trap 'rm -rf "$STAGE"' EXIT
|
||||
cp -R "$EXT/." "$STAGE/"
|
||||
python3 - "$STAGE/manifest.json" <<'PY'
|
||||
import json, sys
|
||||
p = sys.argv[1]
|
||||
m = json.load(open(p))
|
||||
m.pop("key", None) # the Web Store forbids the "key" field in uploads
|
||||
json.dump(m, open(p, "w"), indent=2)
|
||||
open(p, "a").write("\n")
|
||||
PY
|
||||
rm -f extensions/ab-connect.zip
|
||||
( cd "$EXT" && zip -rq ../ab-connect.zip . -x '.*' )
|
||||
( cd "$STAGE" && zip -rq "$OLDPWD/extensions/ab-connect.zip" . -x '.*' )
|
||||
[ -f extensions/ab-connect.zip ] || { echo "error: zip failed" >&2; exit 1; }
|
||||
if unzip -p extensions/ab-connect.zip manifest.json | grep -q '"key"'; then
|
||||
echo "error: 'key' still present in upload zip" >&2; exit 1
|
||||
fi
|
||||
echo "packed extensions/ab-connect.zip (key stripped for Web Store)"
|
||||
|
||||
# Signed crx (reference / non-store force-install for managed setups).
|
||||
# Signed crx (reference / non-store force-install for managed setups) — keeps "key"
|
||||
# via the signing key so the id stays ciiljdlhdpfckdcfkphgmfalanpdejep.
|
||||
if [ -f "$KEY" ]; then
|
||||
rm -f extensions/ab-connect.crx
|
||||
"$CHROME" --pack-extension="$PWD/$EXT" --pack-extension-key="$PWD/$KEY" >/dev/null 2>&1 || true
|
||||
ID=$(openssl rsa -in "$KEY" -pubout -outform DER 2>/dev/null \
|
||||
| openssl dgst -sha256 -binary | xxd -p -c256 | head -c32 | tr '0-9a-f' 'a-p')
|
||||
echo "extension id: $ID"
|
||||
echo "local/crx extension id: $ID"
|
||||
else
|
||||
echo "note: $KEY missing — built zip only (no crx)."
|
||||
fi
|
||||
echo "packed extensions/ab-connect.zip"
|
||||
echo "manifest version: $(grep -o '"version"[^,]*' "$EXT/manifest.json" | head -1)"
|
||||
|
||||
@@ -51,11 +51,24 @@ hand-constructed URL often doesn't.
|
||||
When the task needs the user's *live* logged-in window (their real session, the
|
||||
window they're looking at — not a fresh browser), use the extension connect flow:
|
||||
`agent-browser extension install` once, load `extensions/ab-connect` in
|
||||
`chrome://extensions` once (a GUI step you can perform with a **computer-use /
|
||||
GUI-automation tool** like the `cua-driver` skill — see
|
||||
`references/commands.md` → "Drive your real, logged-in Chrome"), then
|
||||
`agent-browser extension connect`. After that it's zero-confirmation, zero-token
|
||||
CLI. Use `--launch` instead when a fresh, isolated browser is fine.
|
||||
`chrome://extensions` once (it shows up as **agent-browser-stealth**; a GUI step
|
||||
you can perform with a **computer-use / GUI-automation tool** like the
|
||||
`cua-driver` skill — see `references/commands.md` → "Drive your real, logged-in
|
||||
Chrome"). Once the extension is loaded, plain `agent-browser open <url>`
|
||||
auto-connects through it — `auto_connect_cdp` **prefers the live extension relay
|
||||
over a raw `--remote-debugging-port`**, so Chrome 136+'s "Allow remote debugging?"
|
||||
consent popup never fires. `agent-browser extension connect` is the explicit form
|
||||
of the same path. Zero-confirmation, zero-token. Use `--launch` instead when a
|
||||
fresh, isolated browser is fine.
|
||||
|
||||
Each `--session` that connects gets its **own colored Chrome tab group** (named
|
||||
after the session) and drives only its own tabs — multiple agents share the one
|
||||
real browser without cross-talk, and the user's own tabs are never grouped. CDP
|
||||
drives the page without moving the user's mouse/keyboard, so it doesn't fight
|
||||
them for control. **Anti-detection ranking: this real logged-in Chrome (extension
|
||||
connect) > a headed launched browser > headless (forbidden).** A genuine human
|
||||
browser has no headless/automation tells at all, so prefer it for anything
|
||||
anti-bot-sensitive.
|
||||
|
||||
## Two ways to drive a page — and when to drop to `eval`
|
||||
|
||||
@@ -506,7 +519,9 @@ and [references/authentication.md](references/authentication.md).
|
||||
```bash
|
||||
--session <name> # isolated browser session
|
||||
--json # JSON output (for machine parsing)
|
||||
--headed # show the window (default is headless)
|
||||
--headed # default & always-on for stealth — headless is FORBIDDEN
|
||||
# (a bot tell: creepjs flags ~33% headless vs 0% headed).
|
||||
# Display-less servers only: AGENT_BROWSER_ALLOW_HEADLESS=1
|
||||
--auto-connect # connect to an already-running Chrome
|
||||
--cdp <port> # connect to a specific CDP port
|
||||
--profile <name|path> # use a Chrome profile (login state survives)
|
||||
|
||||
@@ -302,7 +302,8 @@ agent-browser state load auth.json # Restore saved state
|
||||
```bash
|
||||
agent-browser --session <name> ... # Isolated browser session
|
||||
agent-browser --json ... # JSON output for parsing
|
||||
agent-browser --headed ... # Show browser window (not headless)
|
||||
agent-browser --headed ... # Default & always-on (stealth). Headless is FORBIDDEN
|
||||
# (bot tell); display-less servers: AGENT_BROWSER_ALLOW_HEADLESS=1
|
||||
agent-browser --full ... # Full page screenshot (-f)
|
||||
agent-browser --cdp <port> ... # Connect via Chrome DevTools Protocol
|
||||
agent-browser -p <provider> ... # Cloud browser provider (--provider)
|
||||
@@ -329,11 +330,29 @@ One-time setup:
|
||||
```bash
|
||||
agent-browser extension install # writes the native-messaging host manifest
|
||||
```
|
||||
Then load the extension **once** — this is a GUI step (Chrome's `chrome://extensions`
|
||||
is privileged; the CLI can't load an unpacked extension):
|
||||
|
||||
The native-messaging host accepts **both** extension origins, so the extension
|
||||
can be installed either way:
|
||||
|
||||
1. **Load unpacked (works today)** — load `<repo>/extensions/ab-connect` from
|
||||
source; its pinned `key` gives the stable id `ciiljdlhd…`.
|
||||
2. **Chrome Web Store (once published)** — one-click *Add to Chrome*; the store
|
||||
strips the `key` and assigns its own id (`knfcmbamhjmaonkfnjhldjedeobeafmk`),
|
||||
which `connect.rs` also allow-lists. (Submitted for review; until it's live,
|
||||
use Load unpacked.)
|
||||
|
||||
For Load unpacked — a GUI step (Chrome's `chrome://extensions` is privileged; the
|
||||
CLI can't load an unpacked extension):
|
||||
|
||||
> chrome://extensions → enable **Developer mode** (top-right) → **Load unpacked** →
|
||||
> select `<repo>/extensions/ab-connect`
|
||||
> select `<repo>/extensions/ab-connect` (it appears in the list as
|
||||
> **agent-browser-stealth**)
|
||||
|
||||
Once loaded, the relay goes live and plain `agent-browser open <url>` connects
|
||||
through it automatically — `auto_connect_cdp` prefers the live extension relay
|
||||
over a raw `--remote-debugging-port`, so Chrome 136+'s "Allow remote debugging?"
|
||||
consent popup never appears. `agent-browser extension connect` is the explicit
|
||||
form of the same path.
|
||||
|
||||
**You can do this load step yourself with a computer-use / GUI-automation tool**
|
||||
(e.g. the `cua-driver` skill) — drive `chrome://extensions`, toggle Developer
|
||||
|
||||