Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -708,14 +708,24 @@ curl -o .claude/skills/agent-browser/SKILL.md \

[Browserbase](https://browserbase.com) provides remote browser infrastructure to make deployment of agentic browsing agents easy. Use it when running the agent-browser CLI in an environment where a local browser isn't feasible.

To enable Browserbase, set these environment variables:
To enable Browserbase, use the `-p` flag:

```bash
export BROWSERBASE_API_KEY="your-api-key"
export BROWSERBASE_PROJECT_ID="your-project-id"
agent-browser -p browserbase open https://example.com
```

When both variables are set, agent-browser automatically connects to a Browserbase session instead of launching a local browser. All commands work identically.
Or use environment variables for CI/scripts:

```bash
export AGENT_BROWSER_PROVIDER=browserbase
export BROWSERBASE_API_KEY="your-api-key"
export BROWSERBASE_PROJECT_ID="your-project-id"
agent-browser open https://example.com
```

When enabled, agent-browser connects to a Browserbase session instead of launching a local browser. All commands work identically.

Get your API key and project ID from the [Browserbase Dashboard](https://browserbase.com/overview).

Expand Down
4 changes: 4 additions & 0 deletions cli/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,8 @@ Options:
e.g., --proxy "http://user:pass@127.0.0.1:7890"
--proxy-bypass <hosts> Bypass proxy for these hosts (or AGENT_BROWSER_PROXY_BYPASS)
e.g., --proxy-bypass "localhost,*.internal.com"
-p, --provider <name> Cloud browser provider
e.g., -p browserbase (or AGENT_BROWSER_PROVIDER env)
--json JSON output
--full, -f Full page screenshot
--headed Show browser window (not headless)
Expand All @@ -1545,6 +1547,7 @@ Options:
Environment:
AGENT_BROWSER_SESSION Session name (default: "default")
AGENT_BROWSER_EXECUTABLE_PATH Custom browser executable path
AGENT_BROWSER_PROVIDER Cloud browser provider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AGENT_BROWSER_PROVIDER Cloud browser provider
AGENT_BROWSER_PROVIDER Cloud browser provider

Trailing space after 'Cloud browser provider' in environment variable help text

Fix on Vercel

AGENT_BROWSER_STREAM_PORT Enable WebSocket streaming on port (e.g., 9223)

Examples:
Expand All @@ -1557,6 +1560,7 @@ Examples:
agent-browser screenshot --full
agent-browser --cdp 9222 snapshot # Connect via CDP port
agent-browser --profile ~/.myapp open example.com # Persistent profile
agent-browser -p browserbase open example.com # Using Browserbase cloud browser
"#
);
}
Expand Down
17 changes: 17 additions & 0 deletions skills/agent-browser/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ agent-browser --proxy <url> ... # Use proxy server
agent-browser --headers <json> ... # HTTP headers scoped to URL's origin
agent-browser --executable-path <p> # Custom browser executable
agent-browser --extension <path> ... # Load browser extension (repeatable)
agent-browser -p <provider> ... # Cloud browser provider (--provider)
agent-browser --help # Show help (-h)
agent-browser --version # Show version (-V)
agent-browser <command> --help # Show detailed help for a command
Expand All @@ -248,10 +249,26 @@ agent-browser --proxy socks5://proxy.com:1080 open example.com
AGENT_BROWSER_SESSION="mysession" # Default session name
AGENT_BROWSER_EXECUTABLE_PATH="/path/chrome" # Custom browser path
AGENT_BROWSER_EXTENSIONS="/ext1,/ext2" # Comma-separated extension paths
AGENT_BROWSER_PROVIDER="browserbase" # Cloud browser provider
AGENT_BROWSER_STREAM_PORT="9223" # WebSocket streaming port
AGENT_BROWSER_HOME="/path/to/agent-browser" # Custom install location (for daemon.js)
```

## Cloud browser providers

Use `-p` to connect to cloud browser infrastructure instead of launching a local browser:

```bash
# Browserbase (requires BROWSERBASE_API_KEY + BROWSERBASE_PROJECT_ID)
agent-browser -p browserbase open https://example.com
```

Or set via environment variable:
```bash
export AGENT_BROWSER_PROVIDER=browserbase
agent-browser open https://example.com
```

## Example: Form submission

```bash
Expand Down
24 changes: 18 additions & 6 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ export class BrowserManager {
this.browserbaseSessionId = session.id;
this.browserbaseApiKey = browserbaseApiKey;
this.browser = browser;
context.setDefaultTimeout(10000);
context.setDefaultTimeout(60000);
this.contexts.push(context);
this.pages.push(page);
this.activePageIndex = 0;
Expand Down Expand Up @@ -844,14 +844,26 @@ export class BrowserManager {
return;
}

// Try connecting to cloud browser providers if configured
// Browserbase: auto-connects when BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID are set
if (await this.connectToBrowserbase()) {
// Check for explicit provider flag
const provider = options.provider ?? process.env.AGENT_BROWSER_PROVIDER;

// Browserbase: explicit opt-in via -p browserbase or auto-connect when env vars are set
if (provider === 'browserbase') {
const connected = await this.connectToBrowserbase();
if (!connected) {
throw new Error(
'BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID are required when using browserbase as a provider'
);
}
return;
Comment on lines +852 to +858
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const connected = await this.connectToBrowserbase();
if (!connected) {
throw new Error(
'BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID are required when using browserbase as a provider'
);
}
return;
try {
const connected = await this.connectToBrowserbase();
if (!connected) {
throw new Error(
'BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID are required when using browserbase as a provider'
);
}
return;
} catch (error) {
// Ensure a descriptive error message is thrown
if (error instanceof Error && error.message.includes('BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID are required')) {
throw error;
}
throw new Error(
`Failed to connect to Browserbase: ${error instanceof Error ? error.message : String(error)}`
);
}

When provider='browserbase' is explicitly set, missing env vars produce one error message while API/network failures produce different raw errors, causing inconsistent error handling

Fix on Vercel

}

// Try auto-connecting to Browserbase when env vars are set (no explicit provider)
if (!provider && (await this.connectToBrowserbase())) {
return;
}

// Browser Use: requires explicit opt-in via -p browseruse flag or AGENT_BROWSER_PROVIDER=browseruse
const provider = options.provider ?? process.env.AGENT_BROWSER_PROVIDER;
// Browser Use: requires explicit opt-in via -p browseruse flag
if (provider === 'browseruse') {
await this.connectToBrowserUse();
return;
Expand Down