Commit Graph

7 Commits

Author SHA1 Message Date
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 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 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
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
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 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
ShawnPana a568f45979 feat(cli): add cloud task/session management and subagent support
Cloud API Integration:
- Add cloud_task.py with full Cloud API client (tasks, sessions)
- Support for task creation, status polling, stopping, and logs
- Session management: create, list, get, stop, delete

Agent Task Options (remote mode):
- --llm: specify model (gpt-4o, claude-sonnet-4-20250514, gemini-2.0-flash)
- --proxy-country: proxy location (default: us)
- --session-id: reuse existing cloud session
- --keep-alive: preserve session after task
- --no-wait: async execution, return task_id immediately
- --stream: stream status updates
- --flash: fast execution mode
- --thinking: extended reasoning
- --vision/--no-vision: control vision capability

CLI Commands:
- task list [--limit N] [--status running|finished] [--json]
- task status <task-id> [--json]
- task stop <task-id>
- task logs <task-id>
- session list [--limit N] [--status active|stopped] [--json]
- session get <session-id> [--json]
- session stop <session-id> | --all

Documentation:
- Add comprehensive subagent examples to SKILL.md files
- Document session=agent, task=work mental model
- Examples for parallel agents, session reuse, agent management
2026-02-10 12:33:05 -08:00