Commit Graph

29 Commits

Author SHA1 Message Date
ShawnPana 92de59c6cc fix(cli): fix pyright type errors in CLI
- Remove invalid cdp_url parameter from create_browser_session calls
- Replace deleted GetCookiesEvent with direct _cdp_get_cookies() call
- Add type assertion for cookies_file after error check
- Use unique variable names for CDP results to avoid type conflicts
- Add type ignores for CDP typed return values used as dicts
2026-02-02 13:05:11 -08:00
ShawnPana 4de76454a7 fix(cli): fix error check in profile sync and remove deleted event import 2026-02-02 10:57:21 -08:00
ShawnPana ad47a97518 style: apply ruff formatting 2026-02-02 10:51:08 -08:00
shawn pana 7d02013b71 Merge branch 'main' into main 2026-02-02 10:47:30 -08:00
ShawnPana a961021670 refactor(cli): move CDP logic into CLI, remove events and watchdogs
Move all CLI-specific CDP logic directly into browser.py command
handlers instead of using events and watchdogs. This keeps the CLI
self-contained and avoids adding CLI-specific code to the core library.

- Remove 14 CLI-specific events from events.py
- Remove 3 watchdog files (cookies, interactions, wait)
- Remove watchdog registrations from session.py
- Implement direct CDP calls in browser.py for cookies, wait, hover,
  dblclick, rightclick, and get commands
2026-02-02 10:44:30 -08:00
ShawnPana 545004322b style: fix formatting 2026-01-31 22:29:57 -08:00
ShawnPana cddc00f6da fix: delegate --template flag to init_main for full template support 2026-01-31 22:24:23 -08:00
Gregor Žunič 0cb96ea5d0 fix: restore install, init, --mcp commands in skill_cli
PR #3911 changed the browser-use entry point to skill_cli/main.py but
didn't port the early command interception for install, init, --template,
and --mcp. This broke:

- `browser-use install` (installs Chromium via playwright)
- `browser-use init` (generates template files)
- `browser-use --template` (direct template generation)
- `browser-use --mcp` (MCP server mode)

This fix adds early command interception to skill_cli/main.py, matching
the behavior from browser_use/cli.py. Commands are handled before argparse
to avoid loading heavy dependencies for simple setup tasks.

Also adds tests to prevent regression.
2026-01-31 21:44:19 -08:00
Saurav Panda a7250241b2 Revert "feat(cli): add --cdp-url flag to connect to existing browser via CDP (#3927)"
This reverts commit e0504b1c7d, reversing
changes made to f798633548.
2026-01-31 21:11:54 -08:00
ShawnPana 2d992c3726 feat(cli): add cloud profile management and cookie sync
- Add cloud profile commands: list, create, get, update, delete
- Add profile sync command to sync local Chrome cookies to cloud
- Add profile cookies command to list cookies by domain
- Add cookies export/import commands for bulk transfer
- Optimize cookie import using Network.setCookies (bulk API)
- Real browser now runs headless by default (use --headed for visible)
- Support --domain flag for syncing specific domain cookies only
- Update SKILL.md with cloud profile workflow documentation
2026-01-31 20:02:50 -08:00
ShawnPana 2b2dc2b4e5 feat(cli): add profile list-local command and fix real browser profile loading
- Add `profile list-local` command to discover local Chrome profiles
- Fix real browser mode to properly pass `profile_directory` to BrowserSession
- Document profile management workflow in SKILL.md
2026-01-31 18:25:17 -08:00
ShawnPana 9abfc327cc feat(cli): add get command for info retrieval (title, html, text, value, attributes, bbox)
Adds information retrieval commands to the browser-use CLI:
- get title: page title
- get html: full page or element HTML via selector
- get text: text content of element by index
- get value: input/textarea value by index
- get attributes: all attributes of element by index
- get bbox: bounding box (x, y, width, height) of element
2026-01-31 17:34:33 -08:00
ShawnPana 3ca625b75e feat(cli): add hover, dblclick, rightclick interaction commands
Adds mouse interaction commands to the browser-use CLI:
- hover: move mouse over element (triggers CSS :hover effects)
- dblclick: double-click element
- rightclick: right-click element (context menu)
2026-01-31 17:28:20 -08:00
ShawnPana 33e03b7b0f feat(cli): add wait command for selector and text conditions
Adds wait conditions to the browser-use CLI with two subcommands:
- wait selector: wait for CSS selector with state options (visible, hidden, attached, detached)
- wait text: wait for text to appear on the page
Both support custom timeout in milliseconds.
2026-01-31 17:17:35 -08:00
ShawnPana 45d244e01c feat(cli): add cookies command for get/set/clear operations
Adds cookie management to the browser-use CLI with three subcommands:
- cookies get: retrieve all cookies or filter by URL
- cookies set: create cookies with domain, path, secure, httpOnly options
- cookies clear: remove all cookies or filter by URL
2026-01-31 17:09:35 -08:00
Saurav Panda 7a32885644 Merge branch 'main' into feat/cdp-url-cli-support 2026-01-29 11:13:15 -08:00
Marcin 9a1fb547d3 fix(cli): use 'cdp-default' session name when --cdp-url is provided
This prevents conflicts when switching between browser modes. Session parameters
(browser mode, cdp_url, etc.) are set at creation time and cannot be changed.
Without this fix, an existing 'default' session using chromium mode would be
silently reused when the user specifies --cdp-url, causing the CDP connection
to be ignored.

The same issue would occur switching between any browser modes (e.g., --browser
chromium to --browser real), but CDP is the most common case where users expect
to connect to a specific existing browser instance.

The session remap is placed early in main() before any command handling (server,
sessions, close --all) so those commands also target the correct session.

Users can still override with explicit --session flag if needed.
2026-01-27 09:00:38 +01:00
Saurav Panda acd05e30e0 removed duplicate --headed flag from skill cli 2026-01-25 11:34:09 -08:00
Marcin 965bc68195 style: format ensure_server function signature 2026-01-24 08:56:07 +01:00
Marcin 1791462de1 feat(cli): add --cdp-url flag to connect to existing browser via CDP
This adds support for connecting to an existing browser instance via
Chrome DevTools Protocol (CDP) URL in the skill_cli commands.

## Why

The current skill_cli only supports three browser modes:
- chromium: Launches a new Playwright-managed Chromium
- real: Launches users Chrome with profile
- remote: Uses Browser-Use Cloud

However, many use cases require connecting to an already-running browser:
- Remote browser automation via SSH tunnels
- Connecting to browsers in Docker containers
- Reusing authenticated browser sessions
- Integration with Claude Code on remote servers

The BrowserSession class already supports cdp_url, but it was not
exposed through the skill_cli. The TUI mode has this option, but the
simple CLI commands did not.

## Changes

- main.py: Added --cdp-url argument and pass-through to server
- server.py: Accept and store cdp_url, pass to session registry
- sessions.py: Handle cdp_url in session creation (takes precedence)

## Usage

browser-use --cdp-url http://localhost:9222 open https://example.com
browser-use --cdp-url http://localhost:9222 state
browser-use --cdp-url http://localhost:9222 click 5

## Testing

Tested with Chrome remote debugging over SSH tunnel - successfully
controlled a local macOS Chrome browser from a remote Linux server.

Vibe coded with Claude Opus 4.5

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 08:21:11 +01:00
BouquetAntoine 1a01e5dff7 feat(cli): add ChatBrowserUse support for BROWSER_USE_API_KEY
The CLI 'run' command now supports BROWSER_USE_API_KEY as an LLM option,
using ChatBrowserUse which is optimized for browser automation tasks.

This aligns the CLI behavior with the documented supported models at
https://docs.browser-use.com/supported-models which shows ChatBrowserUse
as a valid LLM option using BROWSER_USE_API_KEY.

Changes:
- Add ChatBrowserUse as first LLM option in get_llm() when BROWSER_USE_API_KEY is set
- Update error message to mention BROWSER_USE_API_KEY
2026-01-22 17:18:08 +01:00
Gregor Žunič b6bdc17bcb addresses cubic 2026-01-21 22:17:07 -08:00
Gregor Žunič 5fc3a428c7 better remote session management 2026-01-21 22:12:51 -08:00
Gregor Žunič c7c5cae20e remote browser fixes + readme 2026-01-21 21:49:26 -08:00
Gregor Žunič 08c72f67ba chore: Remove auxiliary planning docs 2026-01-21 21:20:44 -08:00
Gregor Žunič 5e75df3eb0 fix: Clean up Python command output format 2026-01-21 21:16:20 -08:00
Gregor Žunič 4716ae50ce fix: State command now outputs LLM representation, add CLI aliases
- State command outputs same format that browser-use agents see
- Added aliases: bu, browser (all work the same)
- Headed mode now correctly shows browser window
2026-01-19 09:36:20 -08:00
Gregor Žunič 0f9e955276 refactor: Rename CLI from 'bu' to 'browser-use'
- Change main entry point to 'browser-use'
- Move TUI to 'browser-use-tui'
- Add README with human instructions
- Update SKILL.md references

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 09:11:39 -08:00
Gregor Žunič c4ffaca6e7 feat: Add fast CLI for browser automation (bu command)
Implements a fast, persistent browser automation CLI per CLI_SPEC.md:

- Fast CLI layer using stdlib only (<50ms startup)
- Session server with Unix socket IPC (TCP on Windows)
- Browser modes: chromium, real, remote
- Commands: open, click, type, input, scroll, back, screenshot,
  state, switch, close-tab, keys, select, eval, extract
- Python execution with persistent namespace (Jupyter-like REPL)
- Agent task execution (requires API key)
- JSON output mode

The CLI maintains browser sessions across commands, enabling complex
multi-step workflows. Includes Claude skill description for AI-assisted
browser automation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 01:05:35 -08:00