Commit Graph

202 Commits

Author SHA1 Message Date
ShawnPana c19a9a5b1b feat: add browser-use config command (set, get, list, unset)
CLI config management driven by CONFIG_KEYS schema. Validates keys,
coerces types (int for timeout), shows all values with config list.
2026-04-01 15:49:17 -07:00
ShawnPana e7dfbd23ae feat: install.sh creates config.json on install
Creates ~/.browser-use/config.json with {} if it doesn't exist,
with 0600 permissions. Ensures config file is always present
regardless of install method.
2026-04-01 15:38:28 -07:00
ShawnPana d60dd24cdf feat: rewrite setup as interactive post-install command
Six steps: home dir, config.json, Chromium, profile-use, cloudflared,
validation + config display. Interactive prompts for downloads (steps
3-5), --yes for CI. Idempotent — skips what's already installed.
2026-04-01 15:36:47 -07:00
ShawnPana 2e7dff8aa6 feat: doctor shows config state with all keys from schema
After diagnostics, doctor now displays config section showing all
CONFIG_KEYS values: api_key (masked), profile ID, proxy, timeout.
Uses get_config_display() from config module. Includes docs link.
2026-04-01 15:33:14 -07:00
ShawnPana 7cf543dc91 feat: add CLI config module as single source of truth
New browser_use/skill_cli/config.py with CONFIG_KEYS schema, read/write
helpers, get_config_value (with defaults), and get_config_display (for
doctor). Refactored cloud.py to import from config module instead of
inline helpers. Removed hardcoded proxy code validation — server-side
validation covers 249 country codes.
2026-04-01 15:29:51 -07:00
ShawnPana c2c9aa8556 feat: cloud signup command, unified base URL, auth isolation
- browser-use cloud signup: challenge-response agent self-registration
- browser-use cloud signup --verify: verify and save API key
- browser-use cloud signup --claim: generate account claim URL
- Base URL convention unified: BROWSER_USE_CLOUD_BASE_URL is host-only
  (e.g. https://api.browser-use.com), CLI appends /api/{version}
- CLI daemon blocked from falling back to library's cloud_auth.json
- cloud connect validates API key before spawning daemon
- No-key error message mentions cloud signup
2026-03-31 21:14:20 -07:00
ShawnPana 9fd3d81f8b fix: default cloud connect proxy to US, validate country codes
_get_cloud_connect_proxy defaults to 'us' when not in config.
Invalid codes (including null, false, 'none') return None (no proxy).
2026-03-31 14:17:42 -07:00
ShawnPana 032e73eec7 feat: config-driven proxy/timeout for cloud connect, enable recording
cloud connect reads cloud_connect_proxy and cloud_connect_timeout from
~/.browser-use/config.json. Recording always enabled via enableRecording
default on CreateBrowserRequest. No CLI flags — edit config for custom
settings, use cloud v2 REST for full control.
2026-03-31 13:44:27 -07:00
ShawnPana 2b9ee57975 fix: CloudBrowserClient respects BROWSER_USE_CLOUD_BASE_URL in CLI
CLIBrowserSession._provision_cloud_browser now reads the env var and
overrides CloudBrowserClient.api_base_url before provisioning. This
keeps the change CLI-only without modifying library code.
2026-03-31 12:51:44 -07:00
ShawnPana 584b1a0854 feat: add BROWSER_USE_CLOUD_BASE_URL env var override
Single env var to override the cloud API base URL for all versions.
Per-version overrides (BROWSER_USE_CLOUD_BASE_URL_V2/V3) still take
precedence for backward compatibility.
2026-03-31 12:38:01 -07:00
ShawnPana b4b2a4c18d feat: zero-config cloud connect with auto-managed profile
cloud connect now works with no flags. On first use, creates a
"Browser Use CLI" profile via the Cloud API and saves the ID to
config.json. Subsequent connects reuse it (validates on each call,
recreates if deleted).

Removed --timeout, --proxy-country, --profile-id flags and their
plumbing through daemon/sessions. Power users who need custom browser
settings use cloud v2 POST /browsers directly.
2026-03-31 12:28:42 -07:00
ShawnPana 8d557b3de7 docs: update README tabs section and file layout for recent changes
Replace standalone switch/close-tab with tab subcommands.
Add state.json to file layout.
2026-03-30 20:11:39 -07:00
ShawnPana 526bde4d0f refactor: remove standalone switch and close-tab command aliases
These were duplicates of tab switch and tab close with separate
lock-checking and focus-resolution code paths. Having one way to
do each thing reduces maintenance surface and avoids isolation bugs.
2026-03-30 20:09:50 -07:00
ShawnPana a6744f4ade fix: tab close uses caller's logical focus, not Chrome's global focus
Default close-tab and tab-close paths used session_manager.get_focused_target()
which returns Chrome's globally focused tab. In multi-agent mode this lets
one agent close another's tab. Now uses agent_focus_target_id first, falling
back to global focus only in single-agent mode.

Also: fresh daemon spawn now uses phase-aware state file waiting (15s) instead
of fixed 5s socket polling, consistent with ensure_daemon's probe logic.
2026-03-30 20:04:01 -07:00
ShawnPana d59c0e6984 fix: CLI reconciliation gaps found by codex review
- ensure_daemon now phase-aware: waits for initializing/starting/
  shutting_down with staleness timeouts, errors on unhealthy sessions
- _close_session only cleans files after confirmed PID death
- _handle_sessions won't delete live daemon's files on stale terminal state
- _probe_session uses socket_pid for split-brain PID resolution
- _is_daemon_process works on Windows (wmic)
- Updated + added robustness tests (codex-authored)
2026-03-30 19:49:57 -07:00
ShawnPana f222c98bbf feat: unified session probe and cross-platform lifecycle helpers
Replace scattered PID/socket/process checks with _probe_session() that
reads the state file, reconciles PIDs, checks liveness, and probes the
socket without deleting anything. Callers decide cleanup policy.

Adds _is_pid_alive, _is_daemon_process, _terminate_pid (cross-platform
with SIGKILL escalation), _close_session (shared by close and close-all).

sessions command now shows phase column. close and close-all both handle
orphaned daemons via SIGTERM fallback. close polls for PID disappearance
up to 15s before giving up.
2026-03-30 18:47:34 -07:00
ShawnPana 8ade5748e2 feat: add daemon lifecycle state file and shutdown re-entrancy guard
Daemon now writes <session>.state.json at each lifecycle transition
(initializing → ready → starting → running → shutting_down → stopped/failed).
All shutdown triggers funneled through _request_shutdown() to prevent
double cleanup. Startup rollback on failure cleans up browser resources.

Also fixes cloud browser leak: CLIBrowserSession.stop() now explicitly
stops the remote browser via API instead of just disconnecting the
websocket.

Daemon ping response now includes PID for split-brain resolution.
2026-03-30 18:43:21 -07:00
ShawnPana ac48ebecaf fix: SIGTERM fallback for orphaned daemons in close command
When the daemon's socket is unreachable but the PID file references a
live process, close now sends SIGTERM directly instead of printing
"No active browser session" and leaving the daemon running forever.
2026-03-30 18:39:06 -07:00
ShawnPana e989797541 fix: sweep orphaned sockets in sessions command
Sockets without a corresponding live PID file were never cleaned up
because cleanup was only triggered per-session on next use. Add a
glob pass in _handle_sessions to remove any .sock file that doesn't
match a live session.
2026-03-29 18:05:56 -07:00
ShawnPana 18c2199e22 fix: serialize multi-agent focus swaps with dispatch lock
Concurrent agents could interleave focus swaps on the shared
BrowserSession, corrupting each other's state. Wrap the entire
swap-execute-restore cycle in _dispatch_lock and separate the
tab-ownership path from single-agent mode.
2026-03-28 15:58:29 -07:00
ShawnPana 4be3525d81 fix: use JS scrollBy instead of CDP gesture for CLI scroll command
CDP input gesture simulation doesn't work in --connect mode (external
Chrome). Switch to window.scrollBy via Runtime.evaluate which works
regardless of connection mode.
2026-03-28 15:58:24 -07:00
ShawnPana ae93cee5c2 fix: unify CLI cloud auth so cloud connect uses ~/.browser-use/config.json
cloud connect was silently reading credentials from the library's
~/.config/browseruse/cloud_auth.json, bypassing cloud login/logout
entirely. Now ensure_daemon injects the CLI config's API key into the
daemon subprocess env, so all cloud commands share a single auth source.
2026-03-28 15:56:56 -07:00
ShawnPana 6bb73ab274 merge upstream/main, resolve install_lite.sh conflict (take upstream) 2026-03-26 11:40:33 -07:00
ShawnPana 464bd167c3 fix: daemon zombie on close, add idle timeout, clean up PID file before exit 2026-03-26 11:31:15 -07:00
shawn pana 7e92031593 Merge branch 'main' into install-lite 2026-03-26 09:43:49 -07:00
ShawnPana e3a994a39d fix: non-fatal validate + curl check before use 2026-03-26 09:40:35 -07:00
ShawnPana 2f41a42eab extract CLI deps to requirements-cli.txt + add CI test 2026-03-26 09:27:18 -07:00
ShawnPana 822a4d948b add aiohttp to lite install deps (needed by LocalBrowserWatchdog._wait_for_cdp_url) 2026-03-26 09:15:29 -07:00
ShawnPana a2cbe678b7 add lightweight CLI install script 2026-03-26 09:15:29 -07:00
ShawnPana 24a0df7e72 add aiohttp to lite install deps (needed by LocalBrowserWatchdog._wait_for_cdp_url) 2026-03-25 22:27:43 -07:00
ShawnPana d8aeaa9ab4 add lightweight CLI install script 2026-03-25 22:15:45 -07:00
ShawnPana e09ba11ef1 feat: remove event bus dependency, add dialog handling
- Remove event bus tab listeners from daemon — track tabs directly
- Remove dead event bus fallback branches from commands/browser.py
- Replace SwitchTabEvent/CloseTabEvent dispatches with direct CDP calls
- Update python_session.py to use ActionHandler instead of event bus
- Add JS dialog handler (alert/confirm/prompt) to CLIBrowserSession
- Surface auto-dismissed popup messages in state output
- Only dummy EventBus() for watchdog constructors remains (unavoidable)
2026-03-25 16:37:26 -07:00
Laith Weinberger 9b401cf04c fix tunnel process kill and daemon spawn on windows 2026-03-25 19:28:47 -04:00
Laith Weinberger a31809b83d preserve error exit code 2026-03-25 17:15:34 -04:00
ShawnPana 4c5fae3a17 feat: lightweight CLIBrowserSession — no watchdogs, no event bus
CLIBrowserSession.start() now handles all three browser modes without
loading watchdogs or the event bus:

- --connect: CDP URL already known, calls connect() directly
- Managed Chromium: launches browser via LocalBrowserWatchdog._launch_browser()
  (instantiated as plain object, not registered on event bus), then connect()
- Cloud: provisions via CloudBrowserClient, then connect()

All modes converge at connect() for lightweight CDP setup. Also adds
process cleanup in kill() for managed Chromium, and is_cdp_connected
property for daemon watchdog polling.
2026-03-25 14:13:25 -07:00
Laith Weinberger c9ea2fb1cf fix daemon orphaning when external browser dies on --connect/--cdp-url 2026-03-25 17:07:03 -04:00
ShawnPana 7bb2741292 feat: lightweight CLIBrowserSession — no watchdogs, no event bus
Subclass BrowserSession as CLIBrowserSession that calls connect()
directly instead of start(). Skips all 13 watchdogs and event bus
handler registration. Actions execute via ActionHandler which calls
DefaultActionWatchdog methods directly and DomService for DOM snapshots.

- CLIBrowserSession.start() → connect() only (CDP + SessionManager)
- CLIBrowserSession.stop() → close websocket directly (no BrowserStopEvent)
- CLIBrowserSession.kill() → Browser.close + disconnect
- ActionHandler wraps DefaultActionWatchdog for click/type/scroll/keys/etc
- DomService called directly for state (no DOMWatchdog)
- Monkey-patches _enable_page_monitoring to no-op after initial connect
- Disables auto-reconnect (_intentional_stop = True)
- Falls back to event bus path if ActionHandler is not available
2026-03-25 13:28:12 -07:00
laithrw b6e17ceb05 Merge branch 'main' into fix/install-shell-detection 2026-03-25 16:13:42 -04:00
ShawnPana f819d3e3a6 feat: add tab command (list, new, switch, close) and agent registration
- `browser-use register` assigns numeric agent index for --connect mode
- `--connect <index>` requires explicit agent index (no more bare --connect)
- `tab list` shows all tabs with lock status per agent
- `tab new [url]` creates a new tab without visually switching
- `tab switch <index>` changes agent focus without activating Chrome tab
- `tab close <index> [index...]` closes multiple tabs in one command
- Agent registry in ~/.browser-use/agents.json with 5min expiry
- Improved error messages guide agents to register or use their own tab
- Session lock prevents double BrowserSession creation on simultaneous connect
- Updated SKILL.md with register workflow and tab commands
2026-03-24 17:27:38 -07:00
shawn pana 9deff4a40e Merge branch 'main' into multi-session 2026-03-24 16:40:31 -07:00
ShawnPana 31694df283 feat: multi-agent tab isolation for --connect mode
Multiple agents can share one browser via --connect without interfering
with each other. Each agent registers with `browser-use register` to get
a numeric index, then passes it with `--connect <index>` on every command.

- Tab locking: mutating commands (click, type, open) lock the tab to the
  agent. Other agents get an error if they try to mutate the same tab.
  Read-only commands (state, screenshot) work on any tab.
- Agent registry: agents.json tracks registered agents with timestamps.
  Expired agents (5min inactive) get cleaned up automatically.
- Session lock: prevents double BrowserSession creation when two agents
  connect simultaneously.
- Focus swap: daemon swaps agent_focus_target_id and cached_selector_map
  per-agent before each command, so element indices are isolated.
2026-03-24 16:38:53 -07:00
Laith Weinberger e44ce7ce73 fix linux profile detection for chromium users 2026-03-24 18:14:22 -04:00
Ishan Shah bb40ff255b fix: mark install.sh as executable in git 2026-03-22 19:52:30 -07:00
Ishan Shah fddc133aa9 fix: detect uv installed via curl script 2026-03-22 19:39:49 -07:00
Hirokazu Tanaka 65a57742f5 fix: align print_next_steps shell detection with configure_path
Ensure print_next_steps() falls back to .profile for non-bash/zsh
shells, matching the behavior of configure_path().
2026-03-22 14:41:36 +09:00
Hirokazu Tanaka ba8bdb56ba fix: use login shell instead of running shell for PATH configuration
When the install script is executed via `curl ... | bash`, it always
runs in a bash process, so $BASH_VERSION is always set regardless of
the user's actual shell. This causes PATH to be written to ~/.bashrc
even for zsh users, making the `browser-use` command unavailable.

Use $SHELL (the user's login shell) instead of $BASH_VERSION/$ZSH_VERSION
to detect the correct shell RC file.

Fixes #4440
2026-03-22 14:36:36 +09:00
ShawnPana dbb356d2eb fall back to raw profile value when Chrome metadata can't be read
If list_chrome_profiles() returns empty (permissions, corrupt Local State,
first-run Chrome), skip resolution and use the profile value as-is instead
of always raising RuntimeError.
2026-03-19 23:14:31 -07:00
ShawnPana 566bca0a88 handle ping success:false case in ensure_daemon config check
Previous commit fixed the exception path. This fixes the case where
ping returns a response with success:false — same fallthrough bug.
2026-03-19 23:10:22 -07:00
ShawnPana edfd554f0f fix ensure_daemon falling through on ping failure with explicit config
When ping fails but daemon is alive, return instead of trying to spawn
a second daemon. The old daemon holds the socket so the new one can't
bind, causing silent config mismatch.
2026-03-19 23:06:31 -07:00
ShawnPana 1b5edbaac9 fix tunnel example: add cloud connect before opening tunnel URL 2026-03-19 22:58:12 -07:00