Commit Graph

689 Commits

Author SHA1 Message Date
ShawnPana 2f41a42eab extract CLI deps to requirements-cli.txt + add CI test 2026-03-26 09:27:18 -07:00
Laith Weinberger 544ad89287 widen retry timing assertions so CI stops flaking 2026-03-21 02:20:17 -04:00
shawn pana a2c2fa33aa Merge branch 'main' into cli 2026-03-20 09:34:45 -07:00
reformedot ad41865559 Refactor User-Agent assertion in CDP headers test
- Updated the assertion for the User-Agent header in the /json/version endpoint test to improve readability by using a multi-line format.
- This change enhances the clarity of the test's intent while maintaining the existing validation logic.

These modifications contribute to better maintainability of the test code.
2026-03-20 00:47:59 -07:00
reformedot f64f587d09 Enhance header validation in CDP client tests
- Improved assertions in tests to ensure all user-provided headers are present in the additional_headers.
- Added checks to confirm that the User-Agent header is injected for remote connections, ensuring consistent behavior across tests.
- Updated the test for the /json/version endpoint to validate the presence and format of the User-Agent header.

These changes enhance the reliability of header handling in the CDP client tests.
2026-03-20 00:43:15 -07:00
ShawnPana c26f228e5a fix cloud --help to show custom usage, tighten test assertions
- Intercept `cloud --help` early so it routes to _print_cloud_usage()
  instead of argparse's generic stub
- Remove permissive `or 'cloud'` fallback in epilog test assertion
- Delete no-op regex test that didn't verify actual code
- Tighten default socket path assertion to check 'default.sock'
2026-03-19 21:48:28 -07:00
ShawnPana f0ca934ae0 fix pyright errors in test_cli_cloud.py: type handler callbacks correctly 2026-03-19 21:12:32 -07:00
ShawnPana 91c02012c3 merge origin/main into cli, resolve agent.py delete conflict 2026-03-19 21:06:38 -07:00
Saurav Panda 6d86be3a6b fix: detect skeleton screens and retry navigation for blank SPA pages 2026-03-19 18:48:47 -07:00
Saurav Panda 0ee771d0fa updated to use temp_path by pytest 2026-03-19 18:19:36 -07:00
ShawnPana 694a111fad add upload command to CLI, extract find_file_input_near_element to BrowserSession
- Add `browser-use upload <index> <path>` command for uploading files to
  file input elements via the CLI
- Extract find_file_input_near_element from nested closures in tools/service.py
  to a reusable method on BrowserSession, deduplicating two copies
- Add BrowserWrapper.upload() for the Python REPL
- Resolve file paths to absolute on the client side before sending to daemon
- Update SKILL.md files and README with upload command docs
2026-03-19 17:02:34 -07:00
Saurav Panda cc1cf2b1c7 Merge branch 'main' into fix-image-url-stripping 2026-03-19 15:34:27 -07:00
Saurav Panda 9445a9ff9e fix image URLs stripped from extracted markdown 2026-03-19 15:29:06 -07:00
ShawnPana d3e1818496 consolidate CLI files under ~/.browser-use/, add profile-use integration and doctor checks
Unify all CLI-managed files under ~/.browser-use/ (config, sockets, PIDs,
binaries, tunnels) instead of scattering across ~/.config/browser-use/ and
~/.browser-use/run/. Add profile-use Go binary as managed subcommand via
browser-use profile, with auto-download fallback and install.sh integration.
Wire cloudflared and profile-use availability checks into browser-use doctor.
2026-03-18 16:16:28 -07:00
ShawnPana bff2918558 add --connect flag for Chrome auto-discovery and fix daemon shutdown for external browsers
Adds `--connect` to auto-discover running Chrome instances via DevToolsActivePort
files and well-known port probing, eliminating manual CDP URL construction. Fixes
daemon process hanging on `close` when connected to external browsers (--connect,
--cdp-url, cloud) by calling stop() (disconnect) instead of kill() (terminate).
2026-03-18 09:41:58 -07:00
Ahmed Aly 0d0eae16d2 zach/chore: fix ruff 2026-03-17 03:48:54 +00:00
Ahmed Aly e8d1681cd5 zach/chore: strip password field values from DOM snapshots sent to LLM 2026-03-17 03:26:24 +00:00
ShawnPana bfa886afea add cloud command and config utilities
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 10:12:49 -07:00
ShawnPana 3318f56318 simplify CLI infrastructure: single-session daemon, remove install modes, streamline setup
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 10:12:41 -07:00
ShawnPana 91e987acdc add browser-use cloud command: generic REST passthrough to Cloud API
Login/logout with API key persistence, versioned REST calls (v2/v3),
task polling, and OpenAPI-driven help. Stdlib only, no daemon needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 11:13:43 -07:00
ShawnPana 4be221386b changes 2026-03-11 12:57:50 -07:00
ShawnPana 859cb97063 simplify daemon architecture: single session, socket-as-liveness, no PID/lock files
Replace the multi-session server (server.py, SessionRegistry, portalocker locking,
PID files, orphan detection) with a minimal daemon (daemon.py) that holds one
BrowserSession in memory. Socket file existence = alive. Auto-exits when browser
dies via CDP watchdog.

-2277 lines, +142 lines across 20 files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 19:05:44 -08:00
Saurav Panda 2552caeca4 fixed code styling issue 2026-02-25 12:26:10 -08:00
Saurav Panda 8270346ccf improved csv file generation 2026-02-25 11:45:05 -08:00
Saurav Panda 95215d6211 Add save_as_pdf agent action for CDP-based page-to-PDF export 2026-02-24 18:35:34 -08:00
Saurav Panda de8039288d Merge branch 'main' into browser-use-radio-button-interaction-issue 2026-02-23 16:55:36 -08:00
Saurav Panda 84babc6b75 fix radio button click occlusion when label overlaps input 2026-02-23 16:19:05 -08:00
Saurav Panda e50588f3c7 fixed styling issues 2026-02-23 15:24:40 -08:00
Saurav Panda 6713afc636 updated _navigate_and_wait 2026-02-21 19:45:54 -08:00
Saurav Panda 69d96c1f45 Merge branch 'main' into cli-add-cordinate-clicking 2026-02-19 18:45:52 -08:00
Saurav Panda 552b2f3b60 fixed ruff format 2026-02-19 18:38:23 -08:00
Saurav Panda 41edfca525 fixed code style issues 2026-02-19 18:17:24 -08:00
Saurav Panda 86b12491dc fixed remote urls in tests 2026-02-19 16:04:06 -08:00
Saurav Panda a3eee8edfe fixed mcp issue 2026-02-19 15:55:22 -08:00
Saurav Panda 33b3af15e6 fixed lint issues 2026-02-19 12:53:46 -08:00
Saurav Panda c18ee5412f add file atttachments to structured output. 2026-02-19 12:43:05 -08:00
Saurav Panda 3f63677756 new direct cli mode 2026-02-19 10:18:12 -08:00
Saurav Panda 7833fcd137 added cookie overlay fix 2026-02-17 11:47:23 -08:00
ShawnPana bff682fee6 fix: address CI lint failures
- Remove unused `import os` from test_doctor_command.py
- Add assert for proc.stdout in test_server_locking.py to satisfy pyright

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 10:36:27 -08:00
ShawnPana 99b0fab320 test(doctor): remove mocking, use real objects per test policy
- Removed all unittest.mock.patch usage
- Tests now use real functions and verify structure/behavior
- Use monkeypatch for env vars (acceptable for test isolation)
- Tests adapt to system state (cloudflared may or may not exist)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 10:30:12 -08:00
ShawnPana c8242e7edd fix(cli): prevent orphaned server processes with flock-based locking
The session server had a race condition where concurrent CLI calls could
spawn multiple server processes. The old server would be orphaned when
the new one overwrote the PID file and deleted its socket.

Changes:
- Add flock-based locking using portalocker (already a dependency)
- Server acquires exclusive lock before writing PID file
- CLI checks both is_server_running() AND is_session_locked()
- Add kill_orphaned_server() to clean up servers with PID but no lock
- Increase socket timeout from 0.1s to 0.5s for reliability
- cleanup_session_files() now removes .lock and .meta files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 10:10:05 -08:00
ShawnPana 4d8c4e5e48 refactor(cli): consolidate tunnel code into single tunnel.py
- Rename tunnel_manager.py to tunnel.py
- Remove dead code: commands/tunnel.py (session-scoped implementation never reached)
- Remove TunnelInfo dataclass and tunnels field from sessions.py
- Remove tunnel routing from server.py (unreachable code path)
- Update imports in main.py, doctor.py, setup.py, and tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 02:09:55 -08:00
ShawnPana e34ee5898e fix(tests): remove unused imports and fix formatting
Pre-commit hooks auto-fixed:
- test_doctor_command.py: Remove unused browser_use import
- test_install_config.py: Remove unused tempfile import, fix formatting
- test_session_browser_mode.py: Remove unused imports (patch, pytest), fix formatting
- test_setup_command.py: Remove unused pytest import

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 15:48:26 -08:00
ShawnPana 35271ed802 fix: address cubic-dev-ai code review concerns from PR #4078
- agent.py: Move API key check inside remote mode block only, allowing
  local mode to work with OPENAI/ANTHROPIC keys without BROWSER_USE_API_KEY
- tunnel_manager.py: Close log file handle on success path to prevent
  file descriptor leak
- profile.py: Use stderr for progress messages when --json flag is set;
  add cleanup_cloud_profile() to delete orphaned cloud profiles on sync failure
- install.sh: Add guard for --api-key requiring a value; warn on unknown
  arguments instead of silently ignoring; fix read -p with < /dev/tty
  for piped install (curl | bash)
- test_setup_command.py: Remove all unittest.mock usage per repo guidelines,
  replace with real function calls that verify structure and logic

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 15:38:01 -08:00
ShawnPana c0dd7875b8 feat(install): mode-based installation with interactive TUI
Add installation mode selection that determines which browser modes are
available at runtime. This enables lightweight remote-only installs for
sandboxed agents (skipping ~300MB Chromium download).

## Install Modes

- `--remote-only`: Only remote mode, installs cloudflared, skips Chromium
- `--local-only`: Only local modes (chromium/real), skips cloudflared
- `--full`: All modes available (default interactive selection)

## Runtime Behavior

- Single installed mode becomes the default (no --browser flag needed)
- Requesting unavailable mode shows clear error with reinstall instructions
- No config file = all modes available (backward compat for pip users)

## Changes

**New: browser_use/skill_cli/install_config.py**
- Manages ~/.browser-use/install-config.json
- get_config(), save_config(), is_mode_available(), get_default_mode()
- get_mode_unavailable_error() for helpful reinstall guidance

**Modified: browser_use/skill_cli/main.py**
- build_parser() uses config for --browser choices and default
- Validates mode availability before starting session server

**Modified: browser_use/skill_cli/sessions.py**
- create_browser_session() validates mode before creation

**Modified: install.sh**
- Command-line flags: --full, --remote-only, --local-only, --api-key
- Interactive TUI with fallback: gum → whiptail → pure bash menu
- Conditional dependency installation based on selected modes
- Writes install-config.json with installed modes

**Updated: skills/remote-browser/SKILL.md**
- Simplified examples (no --browser remote needed with --remote-only)
- Updated setup instructions for mode-based installation

**New: tests/ci/test_install_config.py**
- 13 tests covering config module
2026-02-09 20:36:08 -08:00
ShawnPana 9f51461bbd fix(cli): error when requesting remote browser on local session + improve docs
When a session is started without --browser remote and a subsequent command
uses --browser remote, the CLI now errors with guidance instead of silently
using the local browser (which loses cloud features like live_url).

Code changes:
- Add session metadata file to track browser_mode per session
- Error only when remote requested but session is local
- Allow local-on-remote (user gets more features than requested)
- Clean up metadata on session close

SKILL.md improvements:
- Clarify that --browser remote only needed on FIRST command
- Add table showing session modes
- Add "What happens if you forget" section with error example
- Add troubleshooting entry for mode mismatch error

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-09 18:20:06 -08:00
ShawnPana 3c9b2501ac fix(cli): detect browser mode mismatch between existing session and requested mode
When a session is started with --browser chromium and a subsequent command
uses --browser remote (or vice versa), the CLI now detects the mismatch and
provides actionable error guidance instead of silently using the wrong mode.

Changes:
- Add get_session_metadata_path() to track session config in temp files
- Write browser_mode, headed, profile to metadata on server start
- Check metadata in ensure_server() and error if modes don't match
- Clean up metadata file on session close

Example error:
  Error: Session 'default' is running with --browser chromium,
  but --browser remote was requested.

  Options:
    1. Use existing browser: browser-use --browser chromium <command>
    2. Use different session: browser-use --browser remote --session other <command>
    3. Close existing session: browser-use close

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-09 18:10:46 -08:00
ShawnPana f40235242a refactor: remove pycloudflared, install cloudflared directly in install.sh
- Remove pycloudflared dependency from pyproject.toml
- Simplify tunnel_manager.py to just use shutil.which('cloudflared')
- Add install_cloudflared() to install.sh that downloads binary from
  official Cloudflare GitHub releases based on platform/arch
- Update SKILL.md with manual cloudflared install instructions
- Update setup.py messages for missing cloudflared

install.sh supported platforms:
- Linux (x86_64, arm64) - full support, downloads binary to ~/.local/bin
- macOS (Intel, Apple Silicon) - full support, uses brew or direct download
- Windows WSL - works (treated as Linux)
- Native Windows - not supported (bash script), use manual install
2026-02-09 17:03:56 -08:00
ShawnPana 9520a0b04e feat: frictionless installation system with setup/doctor commands
- Add TunnelManager for auto-install cloudflared via pycloudflared
- Add 'browser-use setup' command with profile-based configuration
- Add 'browser-use doctor' command for health checks
- Add install.sh bootstrap script (dev testing version)
- Add pycloudflared dependency
- Add comprehensive tests for new functionality
2026-02-09 16:09:38 -08:00
Saurav Panda bb5914f251 added milder nudge for action loop 2026-02-05 11:17:20 -08:00