Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
refactor: Rename CLI from 'bu' to 'browser-use'
Gregor Žunič0f9e95527648
diff --git a/browser_use/skill_cli/README.md b/browser_use/skill_cli/README.mdnew file mode 100644index 000000000..f8a0ff042--- /dev/null+++ b/browser_use/skill_cli/README.md@@ -0,0 +1,173 @@+# Browser-Use CLI++Fast, persistent browser automation from the command line.++## Installation++```bash+# From the browser-use repo directory+uv pip install -e .++# Or with pip+pip install -e .+```++## Quick Start++```bash+# Open a webpage (starts browser automatically)+browser-use open https://example.com++# See clickable elements with their indices+browser-use state++# Click an element by index+browser-use click 5++# Type text into focused element+browser-use type "Hello World"++# Fill a specific input field (click + type)+browser-use input 3 "[email protected]"++# Take a screenshot+browser-use screenshot output.png++# Close the browser+browser-use close+```++## Browser Modes++```bash+# Default: headless Chromium+browser-use open https://example.com++# Visible browser window+browser-use --headed open https://example.com++# Use your real Chrome (with existing logins/cookies)+browser-use --browser real open https://gmail.com++# Cloud browser (requires BROWSER_USE_API_KEY)+browser-use --browser remote open https://example.com+```++## All Commands++### Navigation+| Command | Description |+|---------|-------------|+| `browser-use open <url>` | Navigate to URL |+| `browser-use back` | Go back in history |+| `browser-use scroll down` | Scroll down |+| `browser-use scroll up` | Scroll up |++### Inspection+| Command | Description |+|---------|-------------|+| `browser-use state` | Get URL, title, and clickable elements |+| `browser-use screenshot [path]` | Take screenshot (base64 if no path) |+| `browser-use screenshot --full path.png` | Full page screenshot |++### Interaction+| Command | Description |+|---------|-------------|+| `browser-use click <index>` | Click element by index |+| `browser-use type "text"` | Type into focused element |+| `browser-use input <index> "text"` | Click element, then type |+| `browser-use keys "Enter"` | Send keyboard keys |+| `browser-use keys "Control+a"` | Send key combination |+| `browser-use select <index> "value"` | Select dropdown option |++### Tabs+| Command | Description |+|---------|-------------|+| `browser-use switch <tab>` | Switch to tab by index |+| `browser-use close-tab` | Close current tab |+| `browser-use close-tab <tab>` | Close specific tab |++### JavaScript & Data+| Command | Description |+|---------|-------------|+| `browser-use eval "js code"` | Execute JavaScript |+| `browser-use extract "query"` | Extract data with LLM |++### Python (Persistent Session)+```bash+browser-use python "x = 42" # Set variable+browser-use python "print(x)" # Access variable (prints: 42)+browser-use python "print(browser.url)" # Access browser+browser-use python --vars # Show defined variables+browser-use python --reset # Clear namespace+browser-use python --file script.py # Run Python file+```++### Session Management+| Command | Description |+|---------|-------------|+| `browser-use sessions` | List active sessions |+| `browser-use close` | Close browser session |+| `browser-use close --all` | Close all sessions |+| `browser-use server status` | Check if server is running |+| `browser-use server stop` | Stop server |++## Global Options++| Option | Description |+|--------|-------------|+| `--session NAME` | Use named session (default: "default") |+| `--browser MODE` | Browser mode: chromium, real, remote |+| `--headed` | Show browser window |+| `--profile NAME` | Chrome profile (real mode) |+| `--json` | Output as JSON |+| `--api-key KEY` | Override API key |++## Examples++### Fill a Form+```bash+browser-use open https://example.com/contact+browser-use state+# Shows: [0] input "Name", [1] input "Email", [2] button "Submit"+browser-use input 0 "John Doe"+browser-use input 1 "[email protected]"+browser-use click 2+```++### Extract Data with JavaScript+```bash+browser-use open https://news.ycombinator.com+browser-use eval "Array.from(document.querySelectorAll('.titleline a')).slice(0,5).map(a => a.textContent)"+```++### Multi-Session Workflow+```bash+browser-use --session work open https://work.example.com+browser-use --session personal open https://personal.example.com+browser-use --session work state+browser-use --session personal state+browser-use close --all+```++### Python Automation+```bash+browser-use open https://example.com+browser-use python "+for i in range(5):+ browser.scroll('down')+ browser.wait(0.5)+browser.screenshot('scrolled.png')+"+```++## How It Works++The CLI uses a session server architecture:++1. First command starts a background server (browser stays open)+2. Subsequent commands communicate via Unix socket+3. Browser persists across commands for fast interaction+4. Server auto-starts when needed, stops with `browser-use server stop`++This gives you ~50ms command latency instead of waiting for browser startup each time.diff --git a/pyproject.toml b/pyproject.tomlindex cf0e4897c..a8a7c7719 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -92,9 +92,8 @@ all = ["browser-use[cli,examples,aws,oci]"]Repository = "https://github.com/browser-use/browser-use"[project.scripts]-browseruse = "browser_use.cli:main"-browser-use = "browser_use.cli:main"-bu = "browser_use.skill_cli.main:main" # Fast CLI for browser automation+browser-use = "browser_use.skill_cli.main:main" # Fast CLI for browser automation+browser-use-tui = "browser_use.cli:main" # Legacy TUI interface[build-system]requires = ["hatchling"]diff --git a/skills/browser-use/SKILL.md b/skills/browser-use/SKILL.mdindex 7eaff9f2f..89e2ed9ca 100644--- a/skills/browser-use/SKILL.md+++ b/skills/browser-use/SKILL.md@@ -1,39 +1,39 @@---name: browser-usedescription: Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, or extract information from web pages.-allowed-tools: Bash(bu:*)+allowed-tools: Bash(browser-use:*)---# Browser Automation with browser-use CLI-The `bu` command provides fast, persistent browser automation. It maintains browser sessions across commands, enabling complex multi-step workflows.+The `browser-use` command provides fast, persistent browser automation. It maintains browser sessions across commands, enabling complex multi-step workflows.## Quick Start```bash-bu open https://example.com # Navigate to URL-bu state # Get page elements with indices-bu click 5 # Click element by index-bu type "Hello World" # Type text-bu screenshot # Take screenshot-bu close # Close browser+browser-use open https://example.com # Navigate to URL+browser-use state # Get page elements with indices+browser-use click 5 # Click element by index+browser-use type "Hello World" # Type text+browser-use screenshot # Take screenshot+browser-use close # Close browser```## Core Workflow-1. **Navigate**: `bu open <url>` - Opens URL (starts browser if needed)-2. **Inspect**: `bu state` - Returns clickable elements with indices-3. **Interact**: Use indices from state to interact (`bu click 5`, `bu input 3 "text"`)-4. **Verify**: `bu state` or `bu screenshot` to confirm actions+1. **Navigate**: `browser-use open <url>` - Opens URL (starts browser if needed)+2. **Inspect**: `browser-use state` - Returns clickable elements with indices+3. **Interact**: Use indices from state to interact (`browser-use click 5`, `browser-use input 3 "text"`)+4. **Verify**: `browser-use state` or `browser-use screenshot` to confirm actions5. **Repeat**: Browser stays open between commands## Browser Modes```bash-bu --browser chromium open <url> # Default: headless Chromium-bu --browser chromium --headed open <url> # Visible Chromium window-bu --browser real open <url> # User's Chrome with login sessions-bu --browser remote open <url> # Cloud browser (requires API key)+browser-use --browser chromium open <url> # Default: headless Chromium+browser-use --browser chromium --headed open <url> # Visible Chromium window+browser-use --browser real open <url> # User's Chrome with login sessions+browser-use --browser remote open <url> # Cloud browser (requires API key)```- **chromium**: Fast, isolated, headless by default@@ -44,51 +44,51 @@ bu --browser remote open <url> # Cloud browser (requires API key)### Navigation```bash-bu open <url> # Navigate to URL-bu back # Go back in history-bu scroll down # Scroll down-bu scroll up # Scroll up+browser-use open <url> # Navigate to URL+browser-use back # Go back in history+browser-use scroll down # Scroll down+browser-use scroll up # Scroll up```### Page State```bash-bu state # Get URL, title, and clickable elements-bu screenshot # Take screenshot (outputs base64)-bu screenshot path.png # Save screenshot to file-bu screenshot --full path.png # Full page screenshot+browser-use state # Get URL, title, and clickable elements+browser-use screenshot # Take screenshot (outputs base64)+browser-use screenshot path.png # Save screenshot to file+browser-use screenshot --full path.png # Full page screenshot```-### Interactions (use indices from `bu state`)+### Interactions (use indices from `browser-use state`)```bash-bu click <index> # Click element-bu type "text" # Type text into focused element-bu input <index> "text" # Click element, then type text-bu keys "Enter" # Send keyboard keys-bu keys "Control+a" # Send key combination-bu select <index> "option" # Select dropdown option+browser-use click <index> # Click element+browser-use type "text" # Type text into focused element+browser-use input <index> "text" # Click element, then type text+browser-use keys "Enter" # Send keyboard keys+browser-use keys "Control+a" # Send key combination+browser-use select <index> "option" # Select dropdown option```### Tab Management```bash-bu switch <tab> # Switch to tab by index-bu close-tab # Close current tab-bu close-tab <tab> # Close specific tab+browser-use switch <tab> # Switch to tab by index+browser-use close-tab # Close current tab+browser-use close-tab <tab> # Close specific tab```### JavaScript & Data```bash-bu eval "document.title" # Execute JavaScript, return result-bu extract "all product prices" # Extract data using LLM (requires API key)+browser-use eval "document.title" # Execute JavaScript, return result+browser-use extract "all product prices" # Extract data using LLM (requires API key)```### Python Execution (Persistent Session)```bash-bu python "x = 42" # Set variable-bu python "print(x)" # Access variable (outputs: 42)-bu python "print(browser.url)" # Access browser object-bu python --vars # Show defined variables-bu python --reset # Clear Python namespace-bu python --file script.py # Execute Python file+browser-use python "x = 42" # Set variable+browser-use python "print(x)" # Access variable (outputs: 42)+browser-use python "print(browser.url)" # Access browser object+browser-use python --vars # Show defined variables+browser-use python --reset # Clear Python namespace+browser-use python --file script.py # Execute Python file```The Python session maintains state across commands. The `browser` object provides:@@ -103,24 +103,24 @@ The Python session maintains state across commands. The `browser` object provide### Agent Tasks (Requires API Key)```bash-bu run "Fill the contact form with test data" # Run AI agent-bu run "Extract all product prices" --max-steps 50+browser-use run "Fill the contact form with test data" # Run AI agent+browser-use run "Extract all product prices" --max-steps 50```Agent tasks use an LLM to autonomously complete complex browser tasks. Requires `BROWSER_USE_API_KEY` or configured LLM API key (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc).### Session Management```bash-bu sessions # List active sessions-bu close # Close current session-bu close --all # Close all sessions+browser-use sessions # List active sessions+browser-use close # Close current session+browser-use close --all # Close all sessions```### Server Control```bash-bu server status # Check if server is running-bu server stop # Stop server-bu server logs # View server logs+browser-use server status # Check if server is running+browser-use server stop # Stop server+browser-use server logs # View server logs```## Global Options@@ -138,71 +138,71 @@ bu server logs # View server logs### Form Submission```bash-bu open https://example.com/contact-bu state-# Shows: [0] input "Name", [1] input "Email", [2] textarea "Message", [3] button "Submit"-bu input 0 "John Doe"-bu input 1 "[email protected]"-bu input 2 "Hello, this is a test message."-bu click 3-bu state # Verify success+browser-use open https://example.com/contact+browser-use state+# Shows: [0] input "Name", [1] input "Email", [2] textarea "Message", [3] browser-usetton "Submit"+browser-use input 0 "John Doe"+browser-use input 1 "[email protected]"+browser-use input 2 "Hello, this is a test message."+browser-use click 3+browser-use state # Verify success```### Multi-Session Workflows```bash-bu --session work open https://work.example.com-bu --session personal open https://personal.example.com-bu --session work state # Check work session-bu --session personal state # Check personal session-bu close --all # Close both sessions+browser-use --session work open https://work.example.com+browser-use --session personal open https://personal.example.com+browser-use --session work state # Check work session+browser-use --session personal state # Check personal session+browser-use close --all # Close both sessions```### Data Extraction with Python```bash-bu open https://example.com/products-bu python "+browser-use open https://example.com/products+browser-use python "products = []for i in range(20):browser.scroll('down')browser.screenshot('products.png')"-bu python "print(f'Captured {len(products)} products')"+browser-use python "print(f'Captured {len(products)} products')"```### Using Real Browser (Logged-In Sessions)```bash-bu --browser real open https://gmail.com+browser-use --browser real open https://gmail.com# Uses your actual Chrome with existing login sessions-bu state # Already logged in!+browser-use state # Already logged in!```## Tips-1. **Always run `bu state` first** to see available elements and their indices-2. **Use `--headed` for debugging** to see what the browser is doing+1. **Always run `browser-use state` first** to see available elements and their indices+2. **Use `--headed` for debrowser-usegging** to see what the browser is doing3. **Sessions persist** - the browser stays open between commands4. **Use `--json` for parsing** output programmatically-5. **Python variables persist** across `bu python` commands within a session+5. **Python variables persist** across `browser-use python` commands within a session6. **Real browser mode** preserves your login sessions and extensions## Troubleshooting**Browser won't start?**```bash-bu server stop # Stop any stuck server-bu --headed open <url> # Try with visible window+browser-use server stop # Stop any stuck server+browser-use --headed open <url> # Try with visible window```**Element not found?**```bash-bu state # Check current elements-bu scroll down # Element might be below fold-bu state # Check again+browser-use state # Check current elements+browser-use scroll down # Element might be below fold+browser-use state # Check again```**Session issues?**```bash-bu sessions # Check active sessions-bu close --all # Clean slate-bu open <url> # Fresh start+browser-use sessions # Check active sessions+browser-use close --all # Clean slate+browser-use open <url> # Fresh start```