browser-use--browser-harness
96ccb7692b
* remote: Python API for remote browsers, profiles, and local-profile sync
No CLI, no new entrypoint. Every helper is a Python function callable from
inside a normal `browser-harness <<'PY'` block. run.py pre-imports them.
admin.py:
- start_remote_daemon(name, profileName=None, **create_kwargs)
Now forwards every documented POST /browsers kwarg (profileId, profileName,
proxyCountryCode, timeout, customProxy, browserScreenWidth/Height, ...).
profileName is resolved client-side via list_cloud_profiles — no browser-use
API change needed. Prints liveUrl and auto-opens it locally when a GUI is
detected (macOS/Windows always; Linux needs $DISPLAY / $WAYLAND_DISPLAY);
headless servers print only.
- list_cloud_profiles() — GET /api/v3/profiles + per-profile detail; returns
[{id, name, cookieDomains, lastUsedAt, userId}]. Agents should report
len(cookieDomains) not the full list — profiles can have 500 cookies across
dozens of domains.
- list_local_profiles(), sync_local_profile(name) — shell out to `profile-use`.
sync_local_profile returns the newly-created cloud UUID.
Profile-sync skill rewritten Python-first with the chat-driven flow (ask the
user which profile; summarize by domain count, never dump cookies) and calls
out the two upstream limitations (sync always creates a new cloud profile; no
per-domain filtering) that need a PR to browser-use/profile-use — they can't
be fixed in browser-harness because the Browser Use API has no cookie
upload/download endpoint.
SKILL.md remote-browsers section updated to match, leading with the parallel
sub-agent use case.
* remote: fix misleading 'no GUI' message when webbrowser.open raises
cubic flagged this on #84: if _has_local_gui() is True but webbrowser.open
raises (e.g. no default browser configured), the code fell through to the
final 'no local GUI — share the liveUrl' line, which is wrong on both counts.
Restructure so each branch produces exactly one accurate message.
44 行
859 B
Python
44 行
859 B
Python
import sys
|
|
|
|
from admin import (
|
|
ensure_daemon,
|
|
list_cloud_profiles,
|
|
list_local_profiles,
|
|
restart_daemon,
|
|
start_remote_daemon,
|
|
sync_local_profile,
|
|
)
|
|
from helpers import *
|
|
|
|
HELP = """Browser Harness
|
|
|
|
Read SKILL.md for the default workflow and examples.
|
|
|
|
Typical usage:
|
|
uv run bh <<'PY'
|
|
ensure_real_tab()
|
|
print(page_info())
|
|
PY
|
|
|
|
Helpers are pre-imported. The daemon auto-starts and connects to the running browser.
|
|
"""
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) > 1 and sys.argv[1] in {"-h", "--help"}:
|
|
print(HELP)
|
|
return
|
|
if sys.stdin.isatty():
|
|
sys.exit(
|
|
"browser-harness reads Python from stdin. Use:\n"
|
|
" browser-harness <<'PY'\n"
|
|
" print(page_info())\n"
|
|
" PY"
|
|
)
|
|
ensure_daemon()
|
|
exec(sys.stdin.read())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|