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
address PR review comments: fix cloud v2 --help, guard double signal, error to stderr, stale port
ShawnPana54f3febdfa2c
diff --git a/browser_use/skill_cli/README.md b/browser_use/skill_cli/README.mdindex 0ce332aea..6b9f55ba1 100644--- a/browser_use/skill_cli/README.md+++ b/browser_use/skill_cli/README.md@@ -415,8 +415,8 @@ echo $env:PATH### "Failed to start daemon" errorKill zombie processes:```powershell-# Find process on port-netstat -ano | findstr 49200+# Find browser-use Python processes+tasklist | findstr python# Kill by PIDtaskkill /PID <pid> /Fdiff --git a/browser_use/skill_cli/commands/cloud.py b/browser_use/skill_cli/commands/cloud.pyindex 0886e0b70..e695186d4 100644--- a/browser_use/skill_cli/commands/cloud.py+++ b/browser_use/skill_cli/commands/cloud.py@@ -15,6 +15,7 @@ import jsonimport osimport sysimport time+import typingimport urllib.errorimport urllib.requestfrom pathlib import Path@@ -126,15 +127,17 @@ def _http_request(method: str, url: str, body: bytes | None, api_key: str, timeosys.exit(1)-def _print_json(data: bytes) -> None:+def _print_json(data: bytes, file: typing.TextIO | None = None) -> None:"""Pretty-print JSON, raw fallback."""+ out = file or sys.stdouttry:parsed = json.loads(data)- print(json.dumps(parsed, indent=2))+ print(json.dumps(parsed, indent=2), file=out)except (json.JSONDecodeError, ValueError):- sys.stdout.buffer.write(data)- sys.stdout.buffer.write(b'\n')- sys.stdout.buffer.flush()+ buf = out.buffer if hasattr(out, 'buffer') else sys.stdout.buffer+ buf.write(data)+ buf.write(b'\n')+ buf.flush()# ---------------------------------------------------------------------------@@ -375,7 +378,7 @@ def _cloud_rest(argv: list[str], version: str) -> int:if 400 <= status < 500:print(f'HTTP {status}', file=sys.stderr)- _print_json(resp_body)+ _print_json(resp_body, file=sys.stderr)# Try to suggest correct body from specspec_data = _fetch_spec(version)@@ -391,7 +394,7 @@ def _cloud_rest(argv: list[str], version: str) -> int:if status >= 500:print(f'HTTP {status}', file=sys.stderr)- _print_json(resp_body)+ _print_json(resp_body, file=sys.stderr)return 1_print_json(resp_body)@@ -413,7 +416,7 @@ def _cloud_poll(argv: list[str], version: str) -> int:if status_code >= 400:print(f'\nHTTP {status_code}', file=sys.stderr)- _print_json(resp_body)+ _print_json(resp_body, file=sys.stderr)return 2try:@@ -433,7 +436,7 @@ def _cloud_poll(argv: list[str], version: str) -> int:if task_status == 'failed':print('', file=sys.stderr)- _print_json(resp_body)+ _print_json(resp_body, file=sys.stderr)return 2time.sleep(2)diff --git a/browser_use/skill_cli/daemon.py b/browser_use/skill_cli/daemon.pyindex 3f5d551c9..32a3b77aa 100644--- a/browser_use/skill_cli/daemon.py+++ b/browser_use/skill_cli/daemon.py@@ -216,7 +216,8 @@ class Daemon:loop = asyncio.get_running_loop()def signal_handler():- self._shutdown_task = asyncio.create_task(self.shutdown())+ if not self._shutdown_task or self._shutdown_task.done():+ self._shutdown_task = asyncio.create_task(self.shutdown())for sig in (signal.SIGINT, signal.SIGTERM):try:diff --git a/browser_use/skill_cli/main.py b/browser_use/skill_cli/main.pyindex c61f090bd..85dd038e1 100755--- a/browser_use/skill_cli/main.py+++ b/browser_use/skill_cli/main.py@@ -133,11 +133,11 @@ if '--template' in sys.argv:sys.exit(0)# Handle 'cloud --help' / 'cloud -h' early — argparse intercepts --help before-# REMAINDER can capture it, so we route to our custom usage printer directly-if _get_subcommand() == 'cloud' and any(arg in sys.argv for arg in ('--help', '-h')):- # Only intercept if --help comes after 'cloud', not before it+# REMAINDER can capture it, so we route to our custom usage printer directly.+# Only intercept when --help is immediately after 'cloud' (not 'cloud v2 --help').+if _get_subcommand() == 'cloud':cloud_idx = sys.argv.index('cloud')- if any(arg in sys.argv[cloud_idx + 1:] for arg in ('--help', '-h')):+ if cloud_idx + 1 < len(sys.argv) and sys.argv[cloud_idx + 1] in ('--help', '-h'):from browser_use.skill_cli.commands.cloud import handle_cloud_commandsys.exit(handle_cloud_command(['--help']))