The Problem
AI agents need a reliable way to control a headless browser without writing custom Selenium or Playwright scripts. Existing CLI tools are either heavyweight Node‑only solutions or require separate language bindings, making integration noisy and slow for agents that already run in a Rust or Node environment.
What This Does
agent-browser ships a native Rust binary (cli/src/main.rs) that drives Chromium via Playwright under the hood, falling back to a JavaScript implementation when the native build isn’t available. The CLI is exposed through the bin/agent-browser wrapper, which forwards commands to the Rust binary. Core browser actions live in src/browser.ts (high‑cognitive‑load, 1.6 k lines) and are orchestrated by src/actions.ts, while the low‑level protocol handling resides in src/protocol.ts.
The documentation site (docs/) is a Next.js app that renders the README‑style help pages, reusing UI components such as docs/src/components/code-block.tsx. The Docker configuration (docker/Dockerfile.build) builds a reproducible image that bundles both the Rust binary and the Node runtime.
How It Is Wired
Execution starts at cli/src/main.rs – the compiled entry point for the agent-browser command. main.rs parses CLI flags (cli/src/flags.rs) and dispatches to sub‑commands defined in cli/src/commands.rs. Each command creates a Browser instance from src/browser.ts, which internally:
- Calls
install()fromcli/src/install.rs(deep nesting, max indentation depth 8) to ensure Chromium is present. - Opens a Playwright session via the
protocolmodule (src/protocol.ts). - Executes the requested action (
click,type,snapshot, etc.) by invoking functions exported fromsrc/actions.ts.
src/actions.ts imports src/browser.ts (5 inbound edges) and src/protocol.ts (3 edges), making it a central hub; changes here ripple across the CLI. The daemon module (src/daemon.ts) runs a background server for streaming snapshots but has no inbound imports, indicating it is only invoked explicitly.
The import graph contains 32 internal modules with 17 edges and no circular dependencies. The most‑connected module is src/browser (Ca 5, Ce 2, instability 0.29), followed by src/actions (Ca 3, Ce 3, instability 0.5). The docs UI components are isolated, each with a single import edge.
How To Use It
# Clone the repo
git clone https://github.com/moses-y/agent-browser
cd agent-browser
# Install dependencies (pnpm) and build the Rust binary
pnpm install
pnpm build:native # requires rustup (see https://rustup.rs)
# Install Chromium for the CLI
pnpm link --global # makes `agent-browser` globally available
agent-browser install # downloads the browser binary
# Example command sequence
agent-browser open https://example.com
agent-browser snapshot
agent-browser click @e2
agent-browser close
The agent-browser install step runs the code in cli/src/install.rs. All runtime configuration is driven by command‑line flags; no external config files are required.
Real‑World Use
A microservice that generates automated UI reports can invoke the CLI from a Node worker:
const { execSync } = require('child_process');
execSync('agent-browser open https://myapp.internal');
execSync('agent-browser snapshot > report.json');
The worker receives a JSON accessibility tree, enabling an LLM to reason about page structure without parsing raw HTML.
Code Health & Issues
- HIGH – Pin GitHub Actions to commit SHA (
.github/workflows/ci.yml). - HIGH – Upgrade vulnerable
next@16.1.1(CVE‑2026‑44575). - MEDIUM – Declare least‑privilege
GITHUB_TOKENpermissions. - MEDIUM – Enable Dependabot/Renovate for automatic updates.
- MEDIUM – Pin Docker base image by digest (
docker/Dockerfile.build). - MEDIUM – Add dependency‑vulnerability scan to CI.
- MEDIUM – Set
persist-credentials: falseon checkout step. - MEDIUM – Add non‑root
USERin Dockerfile. - MEDIUM – Review/disable
postinstallscript inpackage.json. - LOW – Set
timeout-minuteson CI jobs.
Additional static findings: three oversized files (src/actions.ts, src/browser.ts, src/protocol.ts) each exceed 1 600 lines, and deep nesting appears in cli/src/commands.rs, cli/src/main.rs, and cli/src/install.rs. Repeated UI fragments across several docs pages suggest a DRY improvement.
The Bottom Line
agent-browser delivers a fast, Rust‑backed CLI for headless browser control with a Node fallback, suitable for AI‑driven automation pipelines. The codebase functions but suffers from large, deeply nested modules and several security‑focused hygiene gaps that should be addressed before production use. Teams comfortable with Rust and Node can adopt it quickly, provided they apply the listed hardening fixes.