Automaton Chandleryby Dead Reckoning Foundry

SKILL · community · trust T0

browser-harness: drive your running Chrome over CDP

Version 1.1.0
sha256: d53a30a9765897bda5f1e962002cbdab521540862c2fe6ef504143c36e361d73

Adapted from browser-use/browser-harness by Browser Use, MIT licence. Includes material from davidondrej/skills by David Ondrej, MIT licence. Licence notice · upstream file

What you need before this works

  • The open-source browser-harness tool (browser-use/browser-harness, MIT) installed so that `browser-harness` is on your PATH. Install it from that project's own instructions; they are not part of this skill.
  • A running Chrome, or another Chromium-based browser, with remote debugging enabled.
  • Only for the optional remote-browser mode: a Browser Use account and a BROWSER_USE_API_KEY in the environment.

The packout supplies this skill's text only. It does not install browser-harness, start a debuggable browser or supply a Browser Use account or key. Without the tool or the browser the skill tells the agent to stop.

View raw

---
name: ams-skill-browser-harness
description: "Direct browser control over CDP. Use when the task needs a real browser: automate, scrape, test or interact with web pages in the user's already-running Chrome, drive a UI journey end to end. Requires the open-source browser-harness tool."
---

# browser-harness

Requires: the open-source browser-harness tool (https://github.com/browser-use/browser-harness, MIT) installed so that `browser-harness` is on PATH, and a running Chrome (or another Chromium-based browser) with remote debugging enabled. For install or connection problems, follow that project's own install instructions; they are not part of this skill. If the tool or a debuggable browser is missing, stop and say so.

**Routing check first:** if the task needs no interaction (no clicks, logins, or forms) and you only want page content, fetch it over plain HTTP instead of driving a browser. Use browser-harness when the task needs a real browser: interaction, JS-heavy flows, logged-in sessions, or visual verification.

## Usage

```bash
browser-harness -c '
new_tab("https://example.com")
wait_for_load()
print(page_info())
'
```

- Invoke as `browser-harness -c '<python>'`; helpers are pre-imported and the daemon starts automatically. You never start or stop it manually.
- First navigation is new_tab(url), not goto_url(url): goto runs in the user's active tab and clobbers their work.

## Remote browsers (optional)

Use remote browsers for parallel sub-agents (each gets its own isolated browser via a distinct BU_NAME) or on a headless server. This needs a Browser Use account and a BROWSER_USE_API_KEY in the environment; skip this section without one. start_remote_daemon, list_cloud_profiles, list_local_profiles and sync_local_profile are pre-imported.

When supervising sub-agents, after each check send the user one very short status line: what they are doing and whether they are on track.

```bash
browser-harness -c '
start_remote_daemon("work")                               # default: clean browser, no profile
# start_remote_daemon("work", profileName="my-work")      # reuse a cloud profile (already logged in)
# start_remote_daemon("work", profileId="<uuid>")         # same, but by UUID
# start_remote_daemon("work", proxyCountryCode="de", timeout=120)   # DE proxy, 2-hour timeout
# start_remote_daemon("work", proxyCountryCode=None)      # disable the Browser Use proxy
'

BU_NAME=work browser-harness -c '
new_tab("https://example.com")
print(page_info())
'
```

start_remote_daemon prints liveUrl and opens it locally if a GUI is detected so the user can watch along; on a headless server it only prints, so share the URL. The daemon stops the cloud browser on shutdown, which persists profile state. Running remote daemons bill until their timeout.

## What actually works

- Screenshots first: capture_screenshot() to understand the page, find visible targets, and decide whether you need a click, a selector, or more navigation.
- Clicking: capture_screenshot(), read the pixel off the image, click_at_xy(x, y), then capture_screenshot() to verify. Resist the reflex of "locate first, then click": no getBoundingClientRect, no selector hunt. Drop to DOM only when the target has no visible geometry (hidden input, 0×0 node). Hit-testing happens in Chrome's browser process, so clicks go through iframes, shadow DOM and cross-origin frames without extra work.
- Bulk HTTP: http_get(url) with a thread pool. No browser for static pages.
- After navigation: wait_for_load().
- Wrong or stale tab: ensure_real_tab(). The daemon also auto-recovers from stale sessions on the next call.
- Verification: print(page_info()) is the simplest "is this alive?" check, but screenshots are the default way to verify that a visible action worked.
- DOM reads: use js(...) for inspection and extraction when the screenshot shows that coordinates are the wrong tool.
- Iframe-heavy sites (cloud consoles, CRMs): click_at_xy(x, y) passes through; only drop to iframe DOM work when coordinate clicks are the wrong tool.
- Auth wall: redirected to login means stop and ask the user. Never type credentials read from screenshots.
- Raw CDP for anything the helpers do not cover: cdp("Domain.method", params).

## Design constraints

- Coordinate clicks are the default. Input.dispatchMouseEvent goes through iframes, shadow DOM and cross-origin at the compositor level.
- Connect to the user's running browser. Do not launch your own.
- Prefer raw CDP strings over typed wrappers.
- Keep helpers short. Put task-specific helpers in your own helper file; do not build a manager layer (no retry framework, session manager, daemon supervisor, config system or logging framework).

## Other Chromium browsers

Brave works the same as Chrome. Enable remote debugging at brave://inspect/#remote-debugging (the same checkbox as in Chrome); the harness auto-discovers Brave's profile directory.

## Authenticated content extraction (proven pattern)

Because the harness uses the user's real browser and its live sessions, it can read login-walled or paywalled pages (social posts, professional networks) where plain fetch tools fail.

```bash
browser-harness -c '
new_tab("https://example.com/some/login-walled/page")
wait_for_load()
import time
time.sleep(5)  # let JS-heavy pages render
text = js("""
    const article = document.querySelector("article");
    if (article) return article.innerText;
    return document.body.innerText;
""")
with open("/tmp/extracted.txt", "w") as f:
    f.write(text)
print("Written", len(text), "chars")
'
```

- Write to a temp file to avoid shell escaping issues with large text.
- Sleep generously for JS-heavy single-page apps (3-5s).
- For very long pages, js(...) with innerText grabs everything including below-the-fold content.

## Gotchas (field-tested)

- Omnibox popups are fake page targets. Filter chrome://omnibox-popup... and other internals when you need a real tab.
- CDP target order is not Chrome's visible tab-strip order. Use UI automation when the user means "the first/second tab I can see"; Target.activateTarget only shows a known target.
- Default daemon sessions can go stale; ensure_real_tab() re-attaches to a real page.
- The Browser Use API is camelCase on the wire (cdpUrl, proxyCountryCode, ...).
- A remote cdpUrl is HTTPS, not ws. Resolve the websocket URL via /json/version.
- Stop cloud browsers with PATCH /browsers/{id} and {"action":"stop"}.
- After every meaningful action, re-screenshot before assuming it worked: check changed state, open menus, navigation, visible errors.
- Prefer compositor-level actions over framework hacks: screenshots, coordinate clicks and raw key input before DOM-specific workarounds.