Commit Graph

14 Commits

Author SHA1 Message Date
ShawnPana 0530545c1a fix: API key single source of truth (config.json only), daemon-safe profile creation
- Remove BROWSER_USE_API_KEY env var as a read source from CLI code; config.json is the only source of truth
- Split _create_cloud_profile into daemon-safe _inner (raises) and CLI wrapper (sys.exit)
- Daemon auto-heal no longer kills process on profile creation API errors
2026-04-02 11:51:38 -07:00
ShawnPana 1deb430f8f perf: skip profile validation HTTP call on cloud connect
_get_or_create_cloud_profile reads config instantly instead of
validating via GET /profiles/{id} on every connect. If the profile
is invalid, _provision_cloud_browser auto-heals by creating a new
one and retrying. Saves ~500ms-1s on every cloud connect.
2026-04-02 11:21:12 -07:00
ShawnPana f27c567aad fix: enable_recording defaults False in library, configurable in CLI
Library keeps recording off by default. CLI reads cloud_connect_recording
from config (defaults True). Users can disable with:
  browser-use config set cloud_connect_recording false
2026-04-01 22:22:33 -07:00
ShawnPana a2bcc1a3f9 fix: wrap Page.enable in try/except (not supported on root CDP client)
Page.enable fails on browser-level CDP targets. Wrap in try/except
like the library's PopupsWatchdog does. Dialog handler still
registers regardless — events may fire on some CDP implementations.
2026-04-01 22:13:55 -07:00
ShawnPana 0bf1f02d97 fix: CI failures — ruff formatting, type errors, test_setup_command
- Ruff format all skill_cli and test files
- Fix type: get_config_value returns str|int|None, callers cast properly
- Fix type: BrowserWrapper.actions is non-optional (always provided)
- Fix type: config comparison uses 'is' not '=='
- Rewrite test_setup_command for new setup.handle(yes=True) API
- Add None guard in test_cli_lifecycle for state file
2026-04-01 19:58:33 -07:00
ShawnPana d750babbec fix: timeout cloud browser stop to prevent blocking event loop
5s timeout on stop_browser() API call. If it hangs, skip and
disconnect — cloud browser will time out server-side.
2026-04-01 19:34:53 -07:00
ShawnPana b19a8bb0b0 fix: treat empty BROWSER_USE_API_KEY as unset
Empty string or whitespace-only env var now treated as missing
across all CLI code that checks the API key.
2026-04-01 19:24:23 -07:00
ShawnPana f26bd52af0 fix: enable Page domain before registering dialog handler
Page.enable() must be called on the root CDP client before
javascriptDialogOpening events will fire. Without this, JS dialogs
freeze all CDP commands because the auto-dismiss handler never triggers.
2026-04-01 19:11:52 -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 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 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 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
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
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