
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
agent-tbrowser
Advanced tools
Headless browser automation CLI for AI agents. Fast Rust CLI with Node.js fallback.
npm install -g agent-tbrowser
agent-tbrowser install # Download Chromium
git clone https://github.com/kokouaserge/custom-agent-browser
cd agent-tbrowser
pnpm install
pnpm build
pnpm build:native # Requires Rust (https://rustup.rs)
pnpm link --global # Makes agent-tbrowser available globally
agent-tbrowser install
On Linux, install system dependencies:
agent-tbrowser install --with-deps
# or manually: npx playwright install-deps chromium
agent-tbrowser open example.com
agent-tbrowser snapshot # Get accessibility tree with refs
agent-tbrowser click @e2 # Click by ref from snapshot
agent-tbrowser fill @e3 "test@example.com" # Fill by ref
agent-tbrowser get text @e1 # Get text by ref
agent-tbrowser screenshot page.png
agent-tbrowser close
agent-tbrowser click "#submit"
agent-tbrowser fill "#email" "test@example.com"
agent-tbrowser find role button click --name "Submit"
agent-tbrowser open <url> # Navigate to URL (aliases: goto, navigate)
agent-tbrowser click <sel> # Click element
agent-tbrowser dblclick <sel> # Double-click element
agent-tbrowser focus <sel> # Focus element
agent-tbrowser type <sel> <text> # Type into element
agent-tbrowser fill <sel> <text> # Clear and fill
agent-tbrowser press <key> # Press key (Enter, Tab, Control+a) (alias: key)
agent-tbrowser keydown <key> # Hold key down
agent-tbrowser keyup <key> # Release key
agent-tbrowser hover <sel> # Hover element
agent-tbrowser select <sel> <val> # Select dropdown option
agent-tbrowser check <sel> # Check checkbox
agent-tbrowser uncheck <sel> # Uncheck checkbox
agent-tbrowser scroll <dir> [px] # Scroll (up/down/left/right)
agent-tbrowser scrollintoview <sel> # Scroll element into view (alias: scrollinto)
agent-tbrowser drag <src> <tgt> # Drag and drop
agent-tbrowser upload <sel> <files> # Upload files
agent-tbrowser screenshot [path] # Take screenshot (--full for full page)
agent-tbrowser pdf <path> # Save as PDF
agent-tbrowser snapshot # Accessibility tree with refs (best for AI)
agent-tbrowser eval <js> # Run JavaScript
agent-tbrowser close # Close browser (aliases: quit, exit)
agent-tbrowser get text <sel> # Get text content
agent-tbrowser get html <sel> # Get innerHTML
agent-tbrowser get value <sel> # Get input value
agent-tbrowser get attr <sel> <attr> # Get attribute
agent-tbrowser get title # Get page title
agent-tbrowser get url # Get current URL
agent-tbrowser get count <sel> # Count matching elements
agent-tbrowser get box <sel> # Get bounding box
agent-tbrowser is visible <sel> # Check if visible
agent-tbrowser is enabled <sel> # Check if enabled
agent-tbrowser is checked <sel> # Check if checked
agent-tbrowser find role <role> <action> [value] # By ARIA role
agent-tbrowser find text <text> <action> # By text content
agent-tbrowser find label <label> <action> [value] # By label
agent-tbrowser find placeholder <ph> <action> [value] # By placeholder
agent-tbrowser find alt <text> <action> # By alt text
agent-tbrowser find title <text> <action> # By title attr
agent-tbrowser find testid <id> <action> [value] # By data-testid
agent-tbrowser find first <sel> <action> [value] # First match
agent-tbrowser find last <sel> <action> [value] # Last match
agent-tbrowser find nth <n> <sel> <action> [value] # Nth match
Actions: click, fill, check, hover, text
Examples:
agent-tbrowser find role button click --name "Submit"
agent-tbrowser find text "Sign In" click
agent-tbrowser find label "Email" fill "test@test.com"
agent-tbrowser find first ".item" click
agent-tbrowser find nth 2 "a" text
agent-tbrowser wait <selector> # Wait for element to be visible
agent-tbrowser wait <ms> # Wait for time (milliseconds)
agent-tbrowser wait --text "Welcome" # Wait for text to appear
agent-tbrowser wait --url "**/dash" # Wait for URL pattern
agent-tbrowser wait --load networkidle # Wait for load state
agent-tbrowser wait --fn "window.ready === true" # Wait for JS condition
Load states: load, domcontentloaded, networkidle
agent-tbrowser mouse move <x> <y> # Move mouse
agent-tbrowser mouse down [button] # Press button (left/right/middle)
agent-tbrowser mouse up [button] # Release button
agent-tbrowser mouse wheel <dy> [dx] # Scroll wheel
agent-tbrowser set viewport <w> <h> # Set viewport size
agent-tbrowser set device <name> # Emulate device ("iPhone 14")
agent-tbrowser set geo <lat> <lng> # Set geolocation
agent-tbrowser set offline [on|off] # Toggle offline mode
agent-tbrowser set headers <json> # Extra HTTP headers
agent-tbrowser set credentials <u> <p> # HTTP basic auth
agent-tbrowser set media [dark|light] # Emulate color scheme
agent-tbrowser cookies # Get all cookies
agent-tbrowser cookies set <name> <val> # Set cookie
agent-tbrowser cookies clear # Clear cookies
agent-tbrowser storage local # Get all localStorage
agent-tbrowser storage local <key> # Get specific key
agent-tbrowser storage local set <k> <v> # Set value
agent-tbrowser storage local clear # Clear all
agent-tbrowser storage session # Same for sessionStorage
agent-tbrowser network route <url> # Intercept requests
agent-tbrowser network route <url> --abort # Block requests
agent-tbrowser network route <url> --body <json> # Mock response
agent-tbrowser network unroute [url] # Remove routes
agent-tbrowser network requests # View tracked requests
agent-tbrowser network requests --filter api # Filter requests
agent-tbrowser tab # List tabs
agent-tbrowser tab new [url] # New tab (optionally with URL)
agent-tbrowser tab <n> # Switch to tab n
agent-tbrowser tab close [n] # Close tab
agent-tbrowser window new # New window
agent-tbrowser frame <sel> # Switch to iframe
agent-tbrowser frame main # Back to main frame
agent-tbrowser dialog accept [text] # Accept (with optional prompt text)
agent-tbrowser dialog dismiss # Dismiss
agent-tbrowser trace start [path] # Start recording trace
agent-tbrowser trace stop [path] # Stop and save trace
agent-tbrowser console # View console messages
agent-tbrowser console --clear # Clear console
agent-tbrowser errors # View page errors
agent-tbrowser errors --clear # Clear errors
agent-tbrowser highlight <sel> # Highlight element
agent-tbrowser state save <path> # Save auth state
agent-tbrowser state load <path> # Load auth state
agent-tbrowser back # Go back
agent-tbrowser forward # Go forward
agent-tbrowser reload # Reload page
agent-tbrowser install # Download Chromium browser
agent-tbrowser install --with-deps # Also install system deps (Linux)
Run multiple isolated browser instances:
# Different sessions
agent-tbrowser --session agent1 open site-a.com
agent-tbrowser --session agent2 open site-b.com
# Or via environment variable
AGENT_BROWSER_SESSION=agent1 agent-tbrowser click "#btn"
# List active sessions
agent-tbrowser session list
# Output:
# Active sessions:
# -> default
# agent1
# Show current session
agent-tbrowser session
Each session has its own:
The snapshot command supports filtering to reduce output size:
agent-tbrowser snapshot # Full accessibility tree
agent-tbrowser snapshot -i # Interactive elements only (buttons, inputs, links)
agent-tbrowser snapshot -c # Compact (remove empty structural elements)
agent-tbrowser snapshot -d 3 # Limit depth to 3 levels
agent-tbrowser snapshot -s "#main" # Scope to CSS selector
agent-tbrowser snapshot -i -c -d 5 # Combine options
| Option | Description |
|---|---|
-i, --interactive | Only show interactive elements (buttons, links, inputs) |
-c, --compact | Remove empty structural elements |
-d, --depth <n> | Limit tree depth |
-s, --selector <sel> | Scope to CSS selector |
| Option | Description |
|---|---|
--session <name> | Use isolated session (or AGENT_BROWSER_SESSION env) |
--headers <json> | Set HTTP headers scoped to the URL's origin |
--executable-path <path> | Custom browser executable (or AGENT_BROWSER_EXECUTABLE_PATH env) |
--json | JSON output (for agents) |
--full, -f | Full page screenshot |
--name, -n | Locator name filter |
--exact | Exact text match |
--headed | Show browser window (not headless) |
--cdp <port> | Connect via Chrome DevTools Protocol |
--debug | Debug output |
Refs provide deterministic element selection from snapshots:
# 1. Get snapshot with refs
agent-tbrowser snapshot
# Output:
# - heading "Example Domain" [ref=e1] [level=1]
# - button "Submit" [ref=e2]
# - textbox "Email" [ref=e3]
# - link "Learn more" [ref=e4]
# 2. Use refs to interact
agent-tbrowser click @e2 # Click the button
agent-tbrowser fill @e3 "test@example.com" # Fill the textbox
agent-tbrowser get text @e1 # Get heading text
agent-tbrowser hover @e4 # Hover the link
Why use refs?
agent-tbrowser click "#id"
agent-tbrowser click ".class"
agent-tbrowser click "div > button"
agent-tbrowser click "text=Submit"
agent-tbrowser click "xpath=//button"
agent-tbrowser find role button click --name "Submit"
agent-tbrowser find label "Email" fill "test@test.com"
Use --json for machine-readable output:
agent-tbrowser snapshot --json
# Returns: {"success":true,"data":{"snapshot":"...","refs":{"e1":{"role":"heading","name":"Title"},...}}}
agent-tbrowser get text @e1 --json
agent-tbrowser is visible @e2 --json
# 1. Navigate and get snapshot
agent-tbrowser open example.com
agent-tbrowser snapshot -i --json # AI parses tree and refs
# 2. AI identifies target refs from snapshot
# 3. Execute actions using refs
agent-tbrowser click @e2
agent-tbrowser fill @e3 "input text"
# 4. Get new snapshot if page changed
agent-tbrowser snapshot -i --json
Show the browser window for debugging:
agent-tbrowser open example.com --headed
This opens a visible browser window instead of running headless.
Use --headers to set HTTP headers for a specific origin, enabling authentication without login flows:
# Headers are scoped to api.example.com only
agent-tbrowser open api.example.com --headers '{"Authorization": "Bearer <token>"}'
# Requests to api.example.com include the auth header
agent-tbrowser snapshot -i --json
agent-tbrowser click @e2
# Navigate to another domain - headers are NOT sent (safe!)
agent-tbrowser open other-site.com
This is useful for:
To set headers for multiple origins, use --headers with each open command:
agent-tbrowser open api.example.com --headers '{"Authorization": "Bearer token1"}'
agent-tbrowser open api.acme.com --headers '{"Authorization": "Bearer token2"}'
For global headers (all domains), use set headers:
agent-tbrowser set headers '{"X-Custom-Header": "value"}'
Use a custom browser executable instead of the bundled Chromium. This is useful for:
@sparticuz/chromium (~50MB vs ~684MB)# Via flag
agent-tbrowser --executable-path /path/to/chromium open example.com
# Via environment variable
AGENT_BROWSER_EXECUTABLE_PATH=/path/to/chromium agent-tbrowser open example.com
import chromium from '@sparticuz/chromium';
import { BrowserManager } from 'agent-tbrowser';
export async function handler() {
const browser = new BrowserManager();
await browser.launch({
executablePath: await chromium.executablePath(),
headless: true,
});
// ... use browser
}
The SDK provides natural language browser automation. Describe elements in plain language, and the SDK finds them using LLM + cache.
import { createRunner } from 'agent-tbrowser/sdk';
// Create LLM client (e.g., Anthropic)
const llm = {
complete: async (prompt: string) => {
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
messages: [{ role: 'user', content: prompt }],
});
return {
text: response.content[0].type === 'text' ? response.content[0].text : '',
usage: {
input: response.usage.input_tokens,
output: response.usage.output_tokens,
},
};
},
};
// Local browser
const runner = await createRunner({
llm,
local: { headless: false },
});
// Natural language automation
await runner.open('https://example.com');
await runner.click('the login button');
await runner.fill('email input', 'user@example.com');
await runner.fill('password field', 'secret123');
await runner.click('submit button');
await runner.close();
// TBrowser
const runner = await createRunner({
mode: 'cloud',
cloud: {
provider: 'tbrowser',
apiKey: process.env.TBROWSER_API_KEY,
apiUrl: process.env.TBROWSER_API_URL,
},
llm,
});
// Browserbase
const runner = await createRunner({
mode: 'cloud',
cloud: {
provider: 'browserbase',
apiKey: process.env.BROWSERBASE_API_KEY,
projectId: process.env.BROWSERBASE_PROJECT_ID,
},
llm,
});
// Hyperbrowser
const runner = await createRunner({
mode: 'cloud',
cloud: {
provider: 'hyperbrowser',
apiKey: process.env.HYPERBROWSER_API_KEY,
},
llm,
});
// Get session info
console.log('Session:', runner.getSessionId());
console.log('Provider:', runner.getCloudProvider());
The SDK provides 70+ actions organized by category:
| Category | Actions |
|---|---|
| Navigation | open, back, forward, reload |
| Interactions | click, dblclick, fill, type, select, check, uncheck, hover, focus, drag, dropFiles |
| Keyboard | press, keyDown, keyUp |
| Mouse | mouseMove, mouseDown, mouseUp, mouseWheel, scroll, scrollToElement |
| Getters | getText, getHtml, getValue, getAttribute, getTitle, getUrl, getCount, getBoundingBox |
| State | isVisible, isEnabled, isChecked, isHidden, isEditable |
| Wait | waitForElement, waitForTimeout, waitForUrl, waitForPageLoad |
| Tabs/Frames | newTab, switchTab, closeTab, listTabs, switchToFrame, switchToMainFrame |
| Storage | getCookies, setCookie, clearCookies, getLocalStorage, setLocalStorageItem, clearLocalStorage |
| Network | startRequestTracking, getRequests, mockRoute, blockRoute, setExtraHeaders, setOffline |
| Debug | startTracing, stopTracing, highlight, getSnapshot, getDebugInfo, pdf |
| Config | setViewport, setGeolocation, setColorScheme, setTimezone, setLocale |
See SDK Documentation for complete API reference.
Connect to an existing browser via Chrome DevTools Protocol:
# Connect to Electron app
agent-tbrowser --cdp 9222 snapshot
# Connect to Chrome with remote debugging
# (Start Chrome with: google-chrome --remote-debugging-port=9222)
agent-tbrowser --cdp 9222 open about:blank
This enables control of:
Stream the browser viewport via WebSocket for live preview or "pair browsing" where a human can watch and interact alongside an AI agent.
Set the AGENT_BROWSER_STREAM_PORT environment variable:
AGENT_BROWSER_STREAM_PORT=9223 agent-tbrowser open example.com
This starts a WebSocket server on the specified port that streams the browser viewport and accepts input events.
Connect to ws://localhost:9223 to receive frames and send input:
Receive frames:
{
"type": "frame",
"data": "<base64-encoded-jpeg>",
"metadata": {
"deviceWidth": 1280,
"deviceHeight": 720,
"pageScaleFactor": 1,
"offsetTop": 0,
"scrollOffsetX": 0,
"scrollOffsetY": 0
}
}
Send mouse events:
{
"type": "input_mouse",
"eventType": "mousePressed",
"x": 100,
"y": 200,
"button": "left",
"clickCount": 1
}
Send keyboard events:
{
"type": "input_keyboard",
"eventType": "keyDown",
"key": "Enter",
"code": "Enter"
}
Send touch events:
{
"type": "input_touch",
"eventType": "touchStart",
"touchPoints": [{ "x": 100, "y": 200 }]
}
For advanced use, control streaming directly via the protocol:
import { BrowserManager } from 'agent-tbrowser';
const browser = new BrowserManager();
await browser.launch({ headless: true });
await browser.navigate('https://example.com');
// Start screencast
await browser.startScreencast((frame) => {
// frame.data is base64-encoded image
// frame.metadata contains viewport info
console.log('Frame received:', frame.metadata.deviceWidth, 'x', frame.metadata.deviceHeight);
}, {
format: 'jpeg',
quality: 80,
maxWidth: 1280,
maxHeight: 720,
});
// Inject mouse events
await browser.injectMouseEvent({
type: 'mousePressed',
x: 100,
y: 200,
button: 'left',
});
// Inject keyboard events
await browser.injectKeyboardEvent({
type: 'keyDown',
key: 'Enter',
code: 'Enter',
});
// Stop when done
await browser.stopScreencast();
agent-tbrowser uses a client-daemon architecture:
The daemon starts automatically on first command and persists between commands for fast subsequent operations.
Browser Engine: Uses Chromium by default. The daemon also supports Firefox and WebKit via the Playwright protocol.
| Platform | Binary | Fallback |
|---|---|---|
| macOS ARM64 | Native Rust | Node.js |
| macOS x64 | Native Rust | Node.js |
| Linux ARM64 | Native Rust | Node.js |
| Linux x64 | Native Rust | Node.js |
| Windows x64 | Native Rust | Node.js |
The simplest approach - just tell your agent to use it:
Use agent-tbrowser to test the login flow. Run agent-tbrowser --help to see available commands.
The --help output is comprehensive and most agents can figure it out from there.
For more consistent results, add to your project or global instructions file:
## Browser Automation
Use `agent-tbrowser` for web automation. Run `agent-tbrowser --help` for all commands.
Core workflow:
1. `agent-tbrowser open <url>` - Navigate to page
2. `agent-tbrowser snapshot -i` - Get interactive elements with refs (@e1, @e2)
3. `agent-tbrowser click @e1` / `fill @e2 "text"` - Interact using refs
4. Re-snapshot after page changes
For Claude Code, a skill provides richer context:
cp -r node_modules/agent-tbrowser/skills/agent-tbrowser .claude/skills/
Or download:
mkdir -p .claude/skills/agent-tbrowser
curl -o .claude/skills/agent-tbrowser/SKILL.md \
https://raw.githubusercontent.com/kokouaserge/custom-agent-browser/main/skills/agent-tbrowser/SKILL.md
Apache-2.0
FAQs
Headless browser automation CLI for AI agents
We found that agent-tbrowser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.