diff --git a/README.md b/README.md index dbdae4b..9f7cfb7 100644 --- a/README.md +++ b/README.md @@ -1,1260 +1,139 @@ -# agent-browser +# agent-browser-stealth -Stealth-first browser automation CLI engineered for anti-bot evasion. Fast Rust CLI with Node.js fallback. +Stealth-focused fork of `agent-browser` for anti-bot evasion in production automation. -Designed for production automation on detection-heavy sites: -- Always-on stealth (no opt-in flag) -- Browser and protocol-level anti-fingerprint patches -- Humanized interaction behavior by default -- Verified against CreepJS using the built-in check script +This fork keeps core browser automation capabilities in sync with upstream `agent-browser`, and focuses its own changes on stealth and anti-detection behavior. + +## Positioning + +- Core commands and workflows: aligned with upstream `agent-browser` +- Fork value: stronger anti-bot defaults and operational policies +- Default mindset: no extra stealth toggle, stealth is always on ## Installation -### Global Installation (recommended) - -Installs the native Rust binary for maximum performance: +### Global (recommended) ```bash npm install -g agent-browser-stealth -agent-browser install # Download Chromium +agent-browser install ``` -This is the fastest option -- commands run through the native Rust CLI directly with sub-millisecond parsing overhead. - -### Quick Start (no install) - -Run directly with `npx` if you want to try it without installing globally: +### Quick try with npx ```bash -npx agent-browser-stealth install # Download Chromium (first time only) -npx agent-browser-stealth open example.com -``` - -> **Note:** `npx` routes through Node.js before reaching the Rust CLI, so it is noticeably slower than a global install. For regular use, install globally. - -### Project Installation (local dependency) - -For projects that want to pin the version in `package.json`: - -```bash -npm install agent-browser-stealth npx agent-browser-stealth install -``` - -Then use via `npx` or `package.json` scripts: - -```bash npx agent-browser-stealth open example.com ``` -### Homebrew (macOS) - -```bash -brew install agent-browser -agent-browser install # Download Chromium -``` - -### From Source +### From source ```bash git clone https://github.com/leeguooooo/agent-browser cd agent-browser pnpm install pnpm build -pnpm build:native # Requires Rust (https://rustup.rs) -pnpm link --global # Makes agent-browser available globally +pnpm build:native +pnpm link --global agent-browser install ``` -### Fork Maintenance (Independent Release + Upstream Sync) - -If you maintain a fork and publish your own CLI, use this workflow: - -1. Keep an upstream-tracking branch (`upstream-main`) for clean sync history. -2. Keep your release branch (`main`) for production-ready code only. -3. Merge upstream into short-lived sync branches, then open PRs into `main`. - -One-time setup: - -```bash -git remote add upstream https://github.com/vercel-labs/agent-browser.git -git fetch upstream -``` - -Regular sync: - -```bash -pnpm run sync:upstream:push -``` - -This command: -- Fetches `upstream/main` -- Fast-forwards local `upstream-main` -- Creates `sync/YYYY-MM-DD` from local `main` -- Merges `upstream-main` into the sync branch -- Pushes the sync branch to `origin` (with `sync:upstream:push`) - -If merge conflicts occur, resolve them on the sync branch and open a PR as usual. - -Independent release checklist for forks: -- Use your own npm package name and CLI binary name (avoid conflicts with upstream package ownership). -- Update `repository`, `bugs`, and `homepage` in `package.json` to your fork. -- Configure npm Trusted Publishing (OIDC) for your package and repository workflow. -- Keep release tags and changelog in your own namespace/versioning policy. -- Use dual-version format: `-fork.` (example: `0.14.0-fork.1`). -- `agent-browser --version` should show all three: full version, upstream version, and fork version. - -### Linux Dependencies - -On Linux, install system dependencies: - -```bash -agent-browser install --with-deps -# or manually: npx playwright install-deps chromium -``` - ## Quick Start ```bash -agent-browser open example.com -agent-browser snapshot # Get accessibility tree with refs -agent-browser click @e2 # Click by ref from snapshot -agent-browser fill @e3 "test@example.com" # Fill by ref -agent-browser get text @e1 # Get text by ref +agent-browser open https://example.com +agent-browser snapshot -i +agent-browser click @e2 +agent-browser fill @e3 "test@example.com" agent-browser screenshot page.png -agent-browser --version # Includes upstream/fork metadata on fork builds -agent-browser close ``` -### Traditional Selectors (also supported) +## Anti-Bot Measures -```bash -agent-browser click "#submit" -agent-browser fill "#email" "test@example.com" -agent-browser find role button click --name "Submit" -``` +Stealth is always enabled. Legacy `launch.stealth` is accepted only for compatibility and ignored. -## Commands +### 1) Fingerprint hardening -### Core Commands +- Hides automation indicators such as `navigator.webdriver` +- Adds Chromium launch args to reduce automation fingerprints +- Rewrites headless UA markers (`HeadlessChrome`) +- Patches high-signal surfaces such as: + - `navigator.plugins` / `navigator.mimeTypes` + - `window.chrome.runtime` + - WebGL vendor/renderer exposure + - permissions/language/media/device related probes +- Applies both context init scripts and CDP-level UA overrides +- Preserves explicit custom UA from `--user-agent` or `launch({ userAgent })` -```bash -agent-browser open # Navigate to URL (aliases: goto, navigate) -agent-browser click # Click element (--new-tab to open in new tab) -agent-browser dblclick # Double-click element -agent-browser focus # Focus element -agent-browser type [--delay ] # Type into element -agent-browser fill # Clear and fill -agent-browser press # Press key (Enter, Tab, Control+a) (alias: key) -agent-browser keyboard type [--delay ] # Type with real keystrokes (no selector, current focus) -agent-browser keyboard inserttext # Insert text without key events (no selector) -agent-browser keydown # Hold key down -agent-browser keyup # Release key -agent-browser hover # Hover element -agent-browser select # Select dropdown option -agent-browser check # Check checkbox -agent-browser uncheck # Uncheck checkbox -agent-browser scroll [px] # Scroll (up/down/left/right) -agent-browser scrollintoview # Scroll element into view (alias: scrollinto) -agent-browser drag # Drag and drop -agent-browser upload # Upload files -agent-browser screenshot [path] # Take screenshot (--full for full page, saves to a temporary directory if no path) -agent-browser screenshot --annotate # Annotated screenshot with numbered element labels -agent-browser pdf # Save as PDF -agent-browser snapshot # Accessibility tree with refs (best for AI) -agent-browser eval # Run JavaScript (-b for base64, --stdin for piped input) -agent-browser connect # Connect to browser via CDP -agent-browser close # Close browser (aliases: quit, exit) -``` +### 2) Behavioral humanization -### Typing Delay And Literal Text +- Randomized typing cadence when `--delay` is used +- Random wait ranges (`wait 2000-5000`) +- Bezier-curve mouse movement before click actions +- Randomized navigation pacing -Use `--delay` as a real CLI option (outside the text argument): +### 3) Region signal alignment + +- Auto-aligns locale/timezone/Accept-Language by target TLD +- Reduces locale-timezone mismatch risk on region-sensitive sites + +### 4) Verification-aware retry + +- Detects common captcha/verification interstitial patterns +- Retries navigation with randomized backoff when triggered + +## Typing `--delay` Correctly + +Use `--delay` as an option: ```bash agent-browser type @e2 "iphone" --delay 120 agent-browser keyboard type "iphone" --delay 120 ``` -If your literal text must include `--delay`, stop option parsing with `--`: +If literal text includes `--delay`, stop option parsing with `--`: ```bash agent-browser type @e2 -- "--delay 120" agent-browser keyboard type -- "--delay 120" ``` -### Get Info +## Validation Snapshot -```bash -agent-browser get text # Get text content -agent-browser get html # Get innerHTML -agent-browser get value # Get input value -agent-browser get attr # Get attribute -agent-browser get title # Get page title -agent-browser get url # Get current URL -agent-browser get count # Count matching elements -agent-browser get box # Get bounding box -agent-browser get styles # Get computed styles -``` +Manual checks were run against common public detection pages in headed mode, including: -### Check State +- [bot.sannysoft.com](https://bot.sannysoft.com/) +- [CreepJS](https://abrahamjuliot.github.io/creepjs/) +- [areyouheadless](https://arh.antoinevastel.com/bots/areyouheadless) +- [detect-headless](https://infosimples.github.io/detect-headless) -```bash -agent-browser is visible # Check if visible -agent-browser is enabled # Check if enabled -agent-browser is checked # Check if checked -``` - -### Find Elements (Semantic Locators) - -```bash -agent-browser find role [value] # By ARIA role -agent-browser find text # By text content -agent-browser find label