import { pageMetadata } from '@/lib/page-metadata'; export const metadata = pageMetadata('configuration'); # Configuration Create an `agent-browser.json` file to set persistent defaults instead of repeating flags on every command. In this fork, default launch behavior auto-attaches to an existing browser by trying `localhost:9333` (CDP) first, then auto-discovery. If both fail, commands exit instead of launching a managed browser. ## Config File Locations agent-browser checks two locations, merged in priority order:
Priority Location Scope
1 (lowest) ~/.agent-browser/config.json User-level defaults
2 ./agent-browser.json Project-level overrides
3 AGENT_BROWSER_* env vars Override config values
4 (highest) CLI flags Override everything
Project-level values override user-level values. Environment variables override both. CLI flags always win. Use `--config ` or the `AGENT_BROWSER_CONFIG` environment variable to load a specific config file instead of the default locations: ```bash agent-browser --config ./ci-config.json open example.com AGENT_BROWSER_CONFIG=./ci-config.json agent-browser open example.com ``` ## Example Config ```json { "headed": true, "proxy": "http://localhost:8080", "userAgent": "my-agent/1.0", "ignoreHttpsErrors": true } ``` ## All Options Every CLI flag can be set in the config file using its camelCase equivalent:
Config Key CLI Flag Type
headed --headed boolean
json --json boolean
full --full, -f boolean
debug --debug boolean
session --session string
sessionName --session-name string
executablePath --executable-path string
extensions --extension string[]
state --state string
proxy --proxy string
proxyBypass --proxy-bypass string
args --args string
userAgent --user-agent string
provider -p, --provider string
device --device string
ignoreHttpsErrors --ignore-https-errors boolean
allowFileAccess --allow-file-access boolean
cdp --cdp string
autoConnect --auto-connect boolean
colorScheme --color-scheme string (dark, light, no-preference)
downloadPath --download-path string
tabGroup --tab-group string (base title for session tab grouping via CDP plugin handshake)
tabGroupPluginId --tab-group-plugin-id string (expected extension ID for tab-group plugin handshake)
riskMode --risk-mode string (off, warn, block)
headers --headers string (JSON)
`riskMode` defaults to `warn` when unset. For tab grouping in CDP mode, grouping is best-effort through the extension handshake: extension available => grouped by session; extension missing/unavailable => silent no-op. With the `agent-browser-stealth` extension installed, the side panel also exposes session window isolation controls, activation guard toggles, empty-group cleanup, and per-session allowlist policy editing. ## Common Configurations ### Local Development ```json { "headed": true, "sessionName": "local-dev" } ``` ### Behind a Proxy ```json { "proxy": "http://proxy.corp.example.com:8080", "proxyBypass": "localhost,*.internal.com", "ignoreHttpsErrors": true } ``` ### CI / Devcontainer ```json { "args": "--no-sandbox,--disable-gpu", "ignoreHttpsErrors": true } ``` ### iOS Testing ```json { "provider": "ios", "device": "iPhone 16 Pro" } ``` ## Overriding Boolean Options Boolean flags accept an optional `true`/`false` value to override config settings: ```bash agent-browser --headed false open example.com ``` A bare flag is equivalent to passing `true`: ```bash agent-browser --headed open example.com # same as --headed true agent-browser --headed true open example.com # explicit ``` This applies to all boolean flags: `--headed`, `--debug`, `--json`, `--ignore-https-errors`, `--allow-file-access`, `--auto-connect`. ## Extensions Merging Extensions from user-level and project-level configs are **concatenated**, not replaced. For example, if `~/.agent-browser/config.json` specifies `["/ext1"]` and `./agent-browser.json` specifies `["/ext2"]`, the result is `["/ext1", "/ext2"]`. The `AGENT_BROWSER_EXTENSIONS` environment variable and CLI `--extension` flags follow the standard priority rules (env replaces config, CLI appends). ## Environment Variables These environment variables configure additional daemon and runtime behavior:
Variable Description Default
AGENT_BROWSER_AUTO_CONNECT Auto-discover and connect to a running Chrome instance. (disabled)
AGENT_BROWSER_ALLOW_FILE_ACCESS Allow file:// URLs to access local files. (disabled)
AGENT_BROWSER_COLOR_SCHEME Color scheme preference (dark, light, no-preference). (none)
AGENT_BROWSER_DOWNLOAD_PATH Default directory for browser downloads. (temp directory)
AGENT_BROWSER_TAB_GROUP Base title for tab grouping. Session suffix is appended automatically in CDP mode. Agent Browser Stealth
AGENT_BROWSER_TAB_GROUP_PLUGIN_ID Expected extension ID for CDP tab-group plugin handshake. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
AGENT_BROWSER_RISK_MODE Verification/captcha handling mode (off, warn, block ). warn
AGENT_BROWSER_DEFAULT_TIMEOUT Default Playwright timeout in ms. Keep below 30000 to avoid IPC timeouts. 25000
AGENT_BROWSER_SESSION_NAME Auto-save/load state persistence name (defaults to AGENT_BROWSER_SESSION when unset). (same as AGENT_BROWSER_SESSION)
AGENT_BROWSER_STATE_EXPIRE_DAYS Auto-delete saved session states older than N days. 30
AGENT_BROWSER_ENCRYPTION_KEY 64-char hex key for AES-256-GCM session encryption. (none)
AGENT_BROWSER_STREAM_PORT Enable WebSocket streaming on the specified port (e.g., 9223). (disabled)
AGENT_BROWSER_IOS_DEVICE Default iOS device name for the ios provider. (none)
AGENT_BROWSER_IOS_UDID Default iOS device UDID for the ios provider. (none)
AGENT_BROWSER_DEBUG Enable debug output (1 to enable). (disabled)
## Error Handling - **Auto-discovered config files** (`~/.agent-browser/config.json`, `./agent-browser.json`) that are missing are silently ignored. - **`--config `** with a missing or malformed file exits with an error. - **Malformed JSON** in auto-discovered files prints a warning to stderr and continues without that file. - **Unknown keys** are silently ignored for forward compatibility. > **Tip:** If your project-level `agent-browser.json` contains environment-specific values (paths, proxies), consider adding it to `.gitignore`.