Commit Graph

4415 Commits

Author SHA1 Message Date
Laith Weinberger 1905f6aff1 drop confusing commands, rename type to type-text
- Rm extract (dead, always errored)
- Rm sessions (confusable with cloud session)
- Rm server (overlaps with close)
- Rename type to type-text to distinguish from input
- Clarify close vs session stop and cookies vs profile cookies in help text and docs
2026-02-23 12:54:57 -05:00
Laith Weinberger 60c88343f9 fix: skill_cli mode handling, --json flag positioning, and code cleanup
- Auto-detect browser mode from existing session metadata instead of assuming default; error on explicit mode conflicts
- Make --json work after subcommands (not just before) via argparse SUPPRESS
- Deduplicate utils between main.py and utils.py (lazy portalocker import)
- Extract inline command handlers from main() into standalone functions
- Fix get_available_modes() to match is_mode_available() LOCAL_MODES logic
- Fix setup validation icons for boolean results
- Delete unused protocol.py
2026-02-19 17:59:38 -05:00
Aitor 802f17cf91 Merge branch 'main' into feat/add-custom-headers-support-and-example 2026-02-18 06:22:42 +01:00
reformedot de659f9768 feat: add custom headres support + add example 2026-02-17 21:15:11 -08:00
Saurav Panda 0184d8d5ae Merge branch 'main' into cookie-accept-issue 2026-02-17 20:47:28 -08:00
Magnus Müller ae3ad7244b Merge branch 'main' into cursor/agent-event-output-truncation-bd60 2026-02-17 17:36:10 -08:00
Magnus Müller 868db5e657 Update MAX_STRING_LENGTH to 500000
Increased the maximum string length from 100K to 500K characters.
2026-02-17 17:33:50 -08:00
Cursor Agent e03a18935e Fix UnboundLocalError for action_name in multi_act exception handler
Move action_name extraction before the try block so it's always
defined when the except block references it. Previously, if
_check_stop_or_pause() raised InterruptedError before action_name
was assigned, the exception handler would fail with:

  UnboundLocalError: cannot access local variable 'action_name'
  where it is not associated with a value

Also reuse the action_data dict for the 'done' action check since
it's now available earlier in the loop.

Co-authored-by: Magnus Müller <MagMueller@users.noreply.github.com>
2026-02-18 01:24:06 +00:00
Cursor Agent cc4e5185d5 fix: truncate done_output to max length in UpdateAgentTaskEvent.from_agent()
The done_output field has max_length=100000, but agent.history.final_result()
can return arbitrarily long strings (e.g., large data extractions). This caused
Pydantic validation errors when constructing UpdateAgentTaskEvent at the end of
agent.run(), crashing the entire run even though the task itself succeeded.

Truncate done_output to MAX_STRING_LENGTH before passing to the constructor.

Co-authored-by: Magnus Müller <MagMueller@users.noreply.github.com>
2026-02-18 01:21:41 +00:00
laithrw e9c7061187 Merge branch 'main' into keep-alive-eventbus-fix 2026-02-17 16:51:54 -05:00
Saurav Panda 7833fcd137 added cookie overlay fix 2026-02-17 11:47:23 -08:00
Cursor Agent 270e418cea feat(agent): expose max_clickable_elements_length as Agent parameter
- Add max_clickable_elements_length parameter to Agent.__init__ with default 40000
- Add max_clickable_elements_length to AgentSettings
- Pass parameter through MessageManager to AgentMessagePrompt
- Bump version to 0.11.10a2

Co-authored-by: Magnus Müller <MagMueller@users.noreply.github.com>
2026-02-17 02:07:09 +00:00
Laith Weinberger 3de7f1d9c8 fix keep-alive hang 2026-02-16 19:56:41 -05:00
Laith Weinberger 6db6678a83 style: format downloads_watchdog 2026-02-16 17:36:10 -05:00
Laith Weinberger 0536f5808c Merge origin/main into fix-minimal-issue-7JLZB 2026-02-16 17:33:02 -05:00
Laith Weinberger c6c431c95d fix(#3515): avoid stale download caches 2026-02-16 17:32:12 -05:00
ShawnPana 8af57fa19a feat(install): always install from GitHub main branch
Changes install.sh to clone from github.com/browser-use/browser-use@main
by default instead of installing from PyPI. Custom branches and repos
can still be specified via BROWSER_USE_BRANCH and BROWSER_USE_REPO
environment variables.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 11:37:18 -08:00
ShawnPana a1d20ed81c fix(cli): include --remote-only in remote mode error messages
Previously only suggested --full, but --remote-only is a lighter-weight
option when users only need cloud browser support.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 10:26:31 -08:00
ShawnPana 5ccfc44da8 refactor: move install.sh to browser_use/skill_cli/
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 10:19:45 -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 7706c55532 refactor(cli): consolidate SDK/task/session files into cloud_task.py and cloud_session.py
- Create commands/utils.py with SDK singleton and format_duration helper
- Merge task_management.py into cloud_task.py (SDK wrappers + CLI handlers)
- Create cloud_session.py from session parts of cloud_task.py + session_management.py
- Delete sdk.py, task_management.py, session_management.py
- Update imports in main.py, agent.py, profile.py, __init__.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 01:47:44 -08:00
ShawnPana 5aeb6beeb5 style: fix ruff lint/format issues
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 01:07:22 -08:00
ShawnPana ada8b77d0b docs(cli): add missing commands and flags to skill documentation
- Add missing commands: init, setup, session create, session share, profile create
- Add missing agent run flags: --wait, --start-url, --metadata, --secret,
  --allowed-domain, --skill-id, --structured-output, --judge, --judge-ground-truth
- Add missing task status flags: --step, --reverse, --session filter
- Add missing cookie flags: --same-site, --expires
- Add scroll --amount, get bbox, profile pagination flags
- Add Python execution section to remote-browser/SKILL.md
- Add Cloud Profile Management section to remote-browser/SKILL.md
- Add missing browser wrapper methods to Python docs
- Fix incorrect profile list-local command references

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 00:46:35 -08:00
ShawnPana 79e91e6adf fix(cli): update install script URL to /cli/install.sh
Update all references from browser-use.com/install.sh to
browser-use.com/cli/install.sh across documentation and code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 00:24:48 -08:00
ShawnPana 22d7c53700 fix(cli): revert chat.py changes, hardcode browser-use models in CLI
Reverts changes to browser_use/llm/browser_use/chat.py to keep
CLI changes isolated. Browser-use models are now hardcoded in
agent.py instead of importing from chat.py.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 23:56:15 -08:00
ShawnPana fae720ba77 fix(cli): address cubic review concerns
- Forward all cloud-only flags in _handle_remote_run_with_wait
  Previously only forwarded 6 params; now includes session_id, vision,
  metadata, secrets, allowed_domains, skill_ids, structured_output,
  judge, judge_ground_truth, plus session creation for profile/proxy

- Use asyncio.to_thread for blocking SDK call in poll_until_complete
  Prevents client.tasks.get_task from blocking the event loop while
  polling for task completion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 23:53:25 -08:00
shawn pana a8fa7f3fa2 Update browser_use/skill_cli/README.md
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2026-02-11 23:52:42 -08:00
shawn pana a2e9a33b8f Update browser_use/skill_cli/README.md
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2026-02-11 23:52:33 -08:00
ShawnPana af9383a2c7 refactor(cli): use SDK verified model lists instead of hardcoded prefixes
- Replace _get_provider_from_model() prefix inference (gpt-*, claude-*, etc.)
  with _get_provider_for_model() that checks SDK Literal types directly:
  - OpenAI: openai.types.shared.chat_model.ChatModel
  - Anthropic: anthropic.types.model_param.ModelParam
  - Google: browser_use.llm.google.chat.VerifiedGeminiModels
  - Browser-Use: VALID_BROWSER_USE_MODELS constant

- Add VALID_BROWSER_USE_MODELS constant to ChatBrowserUse for consistency

- Simplify get_llm() to use native browser-use Chat classes instead of
  langchain imports with try/except fallbacks

- Update default models: o3, claude-sonnet-4-0, gemini-flash-latest

- Remove browser-use/* pattern support (cloud models only)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 23:49:11 -08:00
ShawnPana c5dcb52cc9 fix(cli): make poll_until_complete async and show task_id immediately with --wait
Changes:

1. cloud_task.py: Convert poll_until_complete to async
   - Use `await asyncio.sleep()` instead of blocking `time.sleep()`
   - Properly yields control to event loop during polling

2. agent.py: Simplify poll call
   - Just `await cloud_task.poll_until_complete()` directly
   - Remove unnecessary `asyncio.to_thread()` wrapper

3. main.py: Handle --wait directly for immediate feedback
   - Bypass server for remote + run + --wait
   - Print task_id and session_id immediately after task creation
   - Show "waiting... done." progress indicator
   - Handle Ctrl+C gracefully (task continues remotely)
   - Use asyncio.run() for clean event loop management

Before:
  $ browser-use -b remote run "task" --wait
  # (waits silently, then shows everything at once)

After:
  $ browser-use -b remote run "task" --wait
  mode: remote
  task_id: abc123
  session_id: xyz789
  waiting... done.
  status: finished
  output: result here

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 23:12:27 -08:00
shawn pana b8e9dc2a62 Merge branch 'main' into frictionless-install 2026-02-11 19:28:55 -08:00
ShawnPana af1ac137c0 fix(cli): run blocking poll in thread to avoid blocking event loop
Use asyncio.to_thread() for poll_until_complete to prevent time.sleep()
from blocking the async event loop when --wait is used.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 19:24:43 -08:00
ShawnPana 1a9f51c541 refactor(cli): use browser-use-sdk for all cloud operations
Replace custom HTTP client with browser-use-sdk for tasks and sessions,
completing the SDK migration started in 8a992229.

## SDK Migration
- Add `sdk.py` with singleton client factory (`get_sdk_client()`)
- Rewrite `cloud_task.py` to use SDK (-300 lines)
- All functions return typed SDK models (TaskView, SessionView, etc.)
- Add `_filter_none()` to omit None values (SDK sends null, API rejects)

## No Client-Side Defaults
- Remove hardcoded defaults from CLI (max_steps, proxy_country, etc.)
- Let API use its own defaults (documented at docs.cloud.browser-use.com)
- Only pass values user explicitly sets

## New CLI Features
- `session create` - create session without task
- `session share <id>` - create/delete public share URLs
- `task list --session <id>` - filter tasks by session
- New task flags: --metadata, --secret, --allowed-domain, --skill-id,
  --structured-output, --judge, --judge-ground-truth, --start-url

## Async by Default
- Change `--no-wait` to `--wait` (flip default behavior)
- Tasks return immediately with task_id by default
- Use `--wait` to block until completion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 19:12:32 -08:00
ShawnPana 8a9922291d refactor(cli): use browser-use-sdk for cloud profile operations
Replace raw urllib HTTP calls with the official browser-use-sdk client
for all cloud profile API operations. This provides:

- Type-safe responses (ProfileView, ProfileListResponse)
- Cleaner error handling via SDK exceptions
- Consistent SDK usage pattern (matches skills/service.py)
- Removes 40 lines of manual HTTP/auth handling from main.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 16:39:08 -08:00
Saurav Panda 30a8b0f66c Merge branch 'main' into drop-down-click-failure 2026-02-11 15:43:54 -08:00
Saurav Panda 4857d190e3 comment linting issue 2026-02-11 15:01:25 -08:00
shawn pana 0d30058285 Merge branch 'browser-use:main' into frictionless-install 2026-02-11 13:41:14 -08:00
ShawnPana 7d088f19ae docs(cli): add prerequisites section and Windows troubleshooting
- Move prerequisites before install commands (no longer hidden)
- Add Windows troubleshooting section with common issues
- Minor wording improvements

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 10:59:02 -08:00
ShawnPana e8576859d7 docs(cli): update README with all new commands
- Installation: one-line install with platform notes, manual install option
- Agent tasks: local and remote mode with all flags
- Task management: list, status, stop, logs
- Cloud sessions: list, get, stop
- Tunnels: expose local servers to cloud browsers
- Profile management: local and cloud profiles
- New commands: hover, dblclick, rightclick, cookies, wait, get

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 10:37:24 -08:00
ShawnPana fd3db0615a fix(cli): hide server console window on Windows
Use CREATE_NO_WINDOW instead of DETACHED_PROCESS to prevent
a blank console window from appearing when the server starts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 23:19:56 -08:00
ShawnPana 5e811e2ba4 fix(cli): Windows compatibility fixes for session server
- Use ctypes.OpenProcess on Windows for process existence check
  (os.kill raises WinError 87 or SystemError on Windows)
- Use 127.0.0.1 instead of localhost to avoid IPv6 binding issues
- Add reuse_address=True to asyncio.start_server for TCP port reuse

Fixes issues reported in:
- #3912 (os.kill fails on Windows)
- #3918 (WinError 87 in is_server_running)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 22:48:53 -08:00
ShawnPana d4b1a243c0 fix(cli): doctor command now shows check results
Previously doctor said "See details above" but never printed the actual
check results. Now prints each check with status icon and details.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 22:24:01 -08:00
Saurav Panda ae3b8be538 reverted to original gaurd for multi action failure 2026-02-10 20:56:03 -08:00
Saurav Panda 8263a8d91d change max failure to 5 2026-02-10 19:12:45 -08:00
Saurav Panda 126a420dce fixed cdp error timeout detection in browser closed 2026-02-10 19:04:00 -08:00
Saurav Panda 30dbf9e535 fix: retry select_dropdown when options are lazily populated 2026-02-10 18:50:05 -08:00
Saurav Panda 42cbf9ca15 Changed consecutive failure to 7 2026-02-10 18:31:30 -08:00
ShawnPana 7769fbec94 perf(cli): parallelize session stop --all for faster cleanup
Use asyncio.to_thread() with thread pool to stop multiple cloud
sessions concurrently instead of sequentially. Results in ~3.5x
speedup (3.8s vs 13.3s for 5 sessions).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 17:16:27 -08:00
Saurav Panda 33831f2b12 increase default consecutive failure to 5 2026-02-10 17:08:35 -08:00