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>
This commit is contained in:
ShawnPana
2026-03-12 11:13:43 -07:00
parent 4be221386b
commit 91e987acdc
5 changed files with 870 additions and 0 deletions

View File

@@ -288,6 +288,14 @@ def build_parser() -> argparse.ArgumentParser:
browser-use run "task" --llm gpt-4o # Specify model (requires API key)
browser-use open https://example.com""")
epilog_parts.append("""
Cloud API:
browser-use cloud login <api-key> # Save API key
browser-use cloud v2 GET /browsers # List browsers
browser-use cloud v2 POST /tasks '{...}' # Create task
browser-use cloud v2 poll <task-id> # Poll task until done
browser-use cloud v2 --help # Show API endpoints""")
epilog_parts.append("""
Setup:
browser-use install # Install Chromium browser
@@ -535,6 +543,13 @@ Setup:
# close
subparsers.add_parser('close', help='Close browser and stop daemon')
# -------------------------------------------------------------------------
# Cloud API (Generic REST passthrough)
# -------------------------------------------------------------------------
cloud_p = subparsers.add_parser('cloud', help='Browser-Use Cloud API')
cloud_p.add_argument('cloud_args', nargs=argparse.REMAINDER, help='cloud subcommand args')
# -------------------------------------------------------------------------
# Profile Management
# -------------------------------------------------------------------------
@@ -565,6 +580,12 @@ def main() -> int:
parser.print_help()
return 0
# Handle cloud subcommands without starting daemon
if args.command == 'cloud':
from browser_use.skill_cli.commands.cloud import handle_cloud_command
return handle_cloud_command(getattr(args, 'cloud_args', []))
# Handle profile subcommands without starting daemon
if args.command == 'profile':
from browser_use.skill_cli.commands.profile import handle_profile_command