Skip to content

Commit a08762c

Browse files
author
bcode
committed
sync: harness fefca43
41 upstream commits since 216a2c9. Includes the src-layout reorg (PR #229) and Windows IPC support (PR #225) — the trigger for this sync. Adapted our integration to the new layout: - browser-execute.ts: spawn 'browser-harness' console-script via 'uv run --project <dir> browser-harness -c "<code>"' instead of 'python run.py -c'. - harness.ts: PRESERVED_PATHS now points at 'agent-workspace/agent_helpers.py' (the new agent-editable surface) instead of root 'helpers.py'. - harness-sync.md, AGENTS.md, UPSTREAM.md: path-allowlist updated to src-layout. Smoke test now imports from the 'browser_harness' package and exercises the entry-point script. - browser-execute.txt: prompt updated to point at src/browser_harness/helpers.py and agent-workspace/agent_helpers.py. Smoke tests pass (imports + 'browser-harness --version'); 5/5 packages typecheck clean. Divergences touched: none (still just .gitignore + .venv/).
1 parent f60a8f0 commit a08762c

105 files changed

Lines changed: 1779 additions & 195 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,16 @@ See `UPSTREAM.md` for the canonical version. Short form:
135135
### Vendored harness
136136

137137
`packages/bcode-browser/harness/` is vendored from
138-
`browser-use/browser-harness`. Path-allowlist policy:
139-
140-
- `helpers.py` — editable. Primary BrowserCode extension surface.
141-
- `daemon.py`, `admin.py` — protected. Pull verbatim. If behavior change
142-
is needed, upstream a PR to `browser-use/browser-harness`.
143-
- `interaction-skills/`, `domain-skills/` — verbatim. Never edit.
138+
`browser-use/browser-harness`. Path-allowlist policy (post upstream PR #229
139+
src-layout reorg):
140+
141+
- `agent-workspace/agent_helpers.py` — editable. Primary BrowserCode
142+
extension surface.
143+
- `src/browser_harness/*.py` (`daemon.py`, `admin.py`, `helpers.py`,
144+
`run.py`, `_ipc.py`) — protected. Pull verbatim. If behavior change is
145+
needed, upstream a PR to `browser-use/browser-harness`.
146+
- `interaction-skills/`, `agent-workspace/domain-skills/` — verbatim.
147+
Never edit.
144148

145149
Sync workflow lives in `harness-sync.md`.
146150

UPSTREAM.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Future Yellow modifications (per ROADMAP):
5454

5555
Every Yellow modification should be evaluated for conversion to a Green extension point via upstream PR. See decisions.md §1c and ROADMAP F8.
5656

57-
The harness has its own narrower zone policy (see §3 below): `helpers.py` is editable, `daemon.py`/`admin.py` are protected, deliberate divergences are logged per-file.
57+
The harness has its own narrower zone policy (see §3 below): `agent-workspace/agent_helpers.py` is editable, the `src/browser_harness/` core package is protected, deliberate divergences are logged per-file.
5858

5959
---
6060

@@ -83,19 +83,20 @@ Each upstream has its own append-only table. Add a row every time you pull.
8383
| Date | From SHA | To SHA | By | Notes |
8484
|---|---|---|---|---|
8585
| 2026-04-26 | — (initial) | `216a2c9` | bcode | Initial vendor at A2. Verbatim copy of `browser-use/browser-harness@216a2c9`. No divergences yet. |
86+
| 2026-04-28 | `216a2c9` | `fefca43` | bcode | 41 upstream commits. **Major restructure** (PR #229): src-layout reorg (`*.py``src/browser_harness/*.py`), `domain-skills/``agent-workspace/domain-skills/`, agent-editable surface moved from root `helpers.py` to `agent-workspace/agent_helpers.py`, new `_ipc.py` for Windows TCP / POSIX AF_UNIX support, tests moved to `tests/{unit,integration}/`. Also: Expedia/Substack/Loom/Gmail domain skills, screenshot max-dim, helpers.switch_tab dict-accept, websockets pin 15.0.1, BU_CDP_URL, doctor improvements, JS eval refactor. Adapted our integration: `browser-execute.ts` invokes `browser-harness` console-script (not `python run.py`); `harness.ts` `PRESERVED_PATHS` updated to `agent-workspace/agent_helpers.py`; smoke test now imports from `browser_harness` package; `browser-execute.txt` prompt updated to point at new helper paths. Divergences touched: none (still just `.gitignore` + `.venv/`). |
8687

8788
---
8889

8990
## 3. Harness divergences
9091

9192
Per-file record of where `packages/bcode-browser/harness/` deliberately differs from upstream. Read this *before* a sync diff so intentional differences aren't mistaken for missing features.
9293

93-
Path-allowlist policy (decisions.md §3.7, §4.5):
94+
Path-allowlist policy (decisions.md §3.7, §4.5; updated for upstream PR #229 src-layout reorg):
9495

95-
- `helpers.py` — editable; primary BrowserCode extension surface. Divergences expected.
96-
- `daemon.py`, `admin.py` — protected. Pulled verbatim from upstream. If behavior change is needed, upstream a PR to `browser-use/browser-harness`.
97-
- `interaction-skills/`, `domain-skills/` — verbatim from upstream. We never edit these.
98-
- Other files (`run.py`, `pyproject.toml`, `LICENSE`, `README.md`, etc.) — divergence allowed but discouraged.
96+
- `agent-workspace/agent_helpers.py` — editable; primary BrowserCode extension surface. Divergences expected.
97+
- `src/browser_harness/*.py` (`daemon.py`, `admin.py`, `helpers.py`, `run.py`, `_ipc.py`) — protected. Pulled verbatim from upstream. If behavior change is needed, upstream a PR to `browser-use/browser-harness`.
98+
- `interaction-skills/`, `agent-workspace/domain-skills/` — verbatim from upstream. We never edit these.
99+
- Other files (`pyproject.toml`, `LICENSE`, `README.md`, etc.) — divergence allowed but discouraged.
99100

100101
| File | Section | Direction | Reason |
101102
|---|---|---|---|

harness-sync.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,24 @@ This is where the agent earns its keep. For each file changed in `<recorded-sha>
6262

6363
| File category | Action |
6464
|---|---|
65-
| Files not in our divergences table (incl. `daemon.py`, `admin.py`, `domain-skills/`, `interaction-skills/`, `pyproject.toml`, `LICENSE`, etc.) | Take upstream verbatim — `cp temp/browser-harness/<path> packages/bcode-browser/harness/<path>`. |
65+
| Files not in our divergences table (incl. `src/browser_harness/*.py`, `agent-workspace/domain-skills/`, `interaction-skills/`, `tests/`, `pyproject.toml`, `LICENSE`, etc.) | Take upstream verbatim — `cp temp/browser-harness/<path> packages/bcode-browser/harness/<path>`. |
6666
| Files in our divergences table | Read each upstream hunk. For each, decide: **take** (apply upstream change to our file), **skip** (our divergence wins, ignore upstream change), or **adapt** (rewrite our divergence to coexist with the upstream change). Update the divergences row if its reason or scope shifts. |
6767
| New upstream files | Copy in. |
6868
| Files we have but upstream removed | Decide: keep ours (record in divergences) or delete. |
6969

7070
Path-allowlist policy stays in force during sync resolution as well as normal development:
71-
- `helpers.py` — editable, agent's primary extension surface.
72-
- `daemon.py`, `admin.py` — protected. Always take upstream verbatim. If upstream regresses, file an issue at `browser-use/browser-harness` and pin to the prior SHA, do not patch locally.
71+
- `agent-workspace/agent_helpers.py` — editable, agent's primary extension surface (post PR #229).
72+
- `src/browser_harness/*.py` (`daemon.py`, `admin.py`, `helpers.py`, `run.py`, `_ipc.py`) — protected. Always take upstream verbatim. If upstream regresses, file an issue at `browser-use/browser-harness` and pin to the prior SHA, do not patch locally.
7373

7474
### 6. Smoke test
7575

7676
```sh
7777
cd packages/bcode-browser/harness
78-
uv run python -c "import run, helpers, daemon, admin; print('imports ok')"
78+
uv run python -c "from browser_harness import run, helpers, daemon, admin, _ipc; print('imports ok')"
79+
uv run browser-harness --version
7980
```
8081

81-
Verifies the package builds, deps resolve, and all four modules import. We don't try to start the daemon here — that needs a real Chrome and is covered by integration tests, not the sync workflow.
82+
The first line verifies the package builds, deps resolve, and the core modules import. The second exercises the console-script entry point we invoke from `browser-execute.ts`. We don't try to start the daemon here — that needs a real Chrome and is covered by integration tests, not the sync workflow.
8283

8384
### 7. Update UPSTREAM.md
8485

packages/bcode-browser/harness/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
The simplest, thinnest, **self-healing** harness that gives LLM **complete freedom** to complete any browser task. Built directly on CDP.
66

7-
The agent writes what's missing, mid-task. No framework, no recipes, no rails. One websocket to Chrome, nothing between.
7+
The agent writes what's missing, mid-task, inside `agent-workspace/`. No framework, no recipes, no rails. One websocket to Chrome, nothing between.
88

99
```
1010
● agent: wants to upload a file
1111
12-
helpers.py → upload_file() missing
12+
agent-workspace/agent_helpers.py → helper missing
1313
14-
● agent edits the harness and writes it helpers.py 192 → 199 lines
15-
│ + upload_file()
14+
● agent writes it agent_helpers.py
15+
│ + custom helper
1616
✓ file uploaded
1717
```
1818

@@ -25,14 +25,14 @@ Paste into Claude Code or Codex:
2525
```text
2626
Set up https://github.com/browser-use/browser-harness for me.
2727
28-
Read `install.md` first to install and connect this repo to my real browser. Then read `SKILL.md` for normal usage. Always read `helpers.py` because that is where the functions are. When you open a setup or verification tab, activate it so I can see the active browser tab. After it is installed, open this repository in my browser and, if I am logged in to GitHub, ask me whether you should star it for me as a quick demo that the interaction works — only click the star if I say yes. If I am not logged in, just go to browser-use.com.
28+
Read `install.md` first to install and connect this repo to my real browser. Then read `SKILL.md` for normal usage. Use `agent-workspace/agent_helpers.py` and `agent-workspace/domain-skills/` for task-specific edits. When you open a setup or verification tab, activate it so I can see the active browser tab. After it is installed, open this repository in my browser and, if I am logged in to GitHub, ask me whether you should star it for me as a quick demo that the interaction works — only click the star if I say yes. If I am not logged in, just go to browser-use.com.
2929
```
3030

3131
When this page appears, tick the checkbox so the agent can connect to your browser:
3232

3333
<img src="docs/setup-remote-debugging.png" alt="Remote debugging setup" width="520" style="border-radius: 12px;" />
3434

35-
See [domain-skills/](domain-skills/) for example tasks.
35+
See [agent-workspace/domain-skills/](agent-workspace/domain-skills/) for example tasks.
3636

3737
## Free remote browsers
3838

@@ -46,16 +46,16 @@ Useful for stealth, sub-agents, or deployment.<br>
4646

4747
- `install.md` — first-time install and browser bootstrap
4848
- `SKILL.md` — day-to-day usage
49-
- `run.py` (~36 lines) — runs plain Python with helpers preloaded
50-
- `helpers.py` (~195 lines) — starting tool calls; the agent edits these
51-
- `admin.py` + `daemon.py` (~361 lines) — daemon bootstrap plus the CDP websocket and socket bridge
49+
- `src/browser_harness/` — protected core package
50+
- `agent-workspace/agent_helpers.py` — helper code the agent edits
51+
- `agent-workspace/domain-skills/` — reusable site-specific skills the agent edits
5252

5353
## Contributing
5454

55-
PRs and improvements welcome. The best way to help: **contribute a new domain skill** under [domain-skills/](domain-skills/) for a site or task you use often (LinkedIn outreach, ordering on Amazon, filing expenses, etc.). Each skill teaches the agent the selectors, flows, and edge cases it would otherwise have to rediscover.
55+
PRs and improvements welcome. The best way to help: **contribute a new domain skill** under [agent-workspace/domain-skills/](agent-workspace/domain-skills/) for a site or task you use often (LinkedIn outreach, ordering on Amazon, filing expenses, etc.). Each skill teaches the agent the selectors, flows, and edge cases it would otherwise have to rediscover.
5656

5757
- **Skills are written by the harness, not by you.** Just run your task with the agent — when it figures something non-obvious out, it files the skill itself (see [SKILL.md](SKILL.md)). Please don't hand-author skill files; agent-generated ones reflect what actually works in the browser.
58-
- Open a PR with the generated `domain-skills/<site>/` folder — small and focused is great.
58+
- Open a PR with the generated `agent-workspace/domain-skills/<site>/` folder — small and focused is great.
5959
- Bug fixes, docs tweaks, and helper improvements are equally welcome.
6060
- Browse existing skills (`github/`, `linkedin/`, `amazon/`, ...) to see the shape.
6161

packages/bcode-browser/harness/SKILL.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ description: Direct browser control via CDP. Use when the user wants to automate
55

66
# browser-harness
77

8-
Direct browser control via CDP. Read helpers.py — that's where the functions live. For setup, install, or connection problems, read install.md.
8+
Direct browser control via CDP. For task-specific edits, use `agent-workspace/agent_helpers.py` and `agent-workspace/domain-skills/`. For setup, install, or connection problems, read install.md.
99

1010
## Usage
1111

1212
```bash
13-
browser-harness <<'PY'
13+
browser-harness -c '
1414
new_tab("https://docs.browser-use.com")
1515
wait_for_load()
1616
print(page_info())
17-
PY
17+
'
1818
```
1919

2020
- Invoke as browser-harness — it's on $PATH. No cd, no uv run.
@@ -30,9 +30,9 @@ Available domain skills:
3030
## Tool call shape
3131

3232
```bash
33-
browser-harness <<'PY'
33+
browser-harness -c '
3434
# any python. helpers pre-imported. daemon auto-starts.
35-
PY
35+
'
3636
```
3737

3838
run.py calls ensure_daemon() before exec — you never start/stop manually unless you want to.
@@ -42,18 +42,18 @@ run.py calls ensure_daemon() before exec — you never start/stop manually unles
4242
Use remote for parallel sub-agents (each gets its own isolated browser via a distinct BU_NAME) or on a headless server. BROWSER_USE_API_KEY must be set. start_remote_daemon, list_cloud_profiles, list_local_profiles, sync_local_profile are pre-imported.
4343

4444
```bash
45-
browser-harness <<'PY'
45+
browser-harness -c '
4646
start_remote_daemon("work") # default — clean browser, no profile
4747
# start_remote_daemon("work", profileName="my-work") # reuse a cloud profile (already logged in)
4848
# start_remote_daemon("work", profileId="<uuid>") # same, but by UUID
4949
# start_remote_daemon("work", proxyCountryCode="de", timeout=120) # DE proxy, 2-hour timeout
5050
# start_remote_daemon("work", proxyCountryCode=None) # disable the Browser Use proxy
51-
PY
51+
'
5252

53-
BU_NAME=work browser-harness <<'PY'
53+
BU_NAME=work browser-harness -c '
5454
new_tab("https://example.com")
5555
print(page_info())
56-
PY
56+
'
5757
```
5858

5959
start_remote_daemon prints liveUrl and auto-opens it in the local browser (if a GUI is detected) so the user can watch along. Headless servers print only — share the URL with the user. The daemon PATCHes the cloud browser to stop on shutdown, which persists profile state. Running remote daemons bill until timeout.
@@ -62,7 +62,7 @@ Profiles (cookies-only login state) live in interaction-skills/profile-sync.md
6262

6363
## Search first
6464

65-
Search domain-skills/ first for the domain you are working on before inventing a new approach.
65+
Search `agent-workspace/domain-skills/` first for the domain you are working on before inventing a new approach.
6666

6767
Only if you start struggling with a specific mechanic while navigating, look in interaction-skills/ for helpers. The available interaction skills are:
6868
- cookies.md
@@ -85,13 +85,13 @@ Only if you start struggling with a specific mechanic while navigating, look in
8585
Useful commands:
8686

8787
```bash
88-
rg --files domain-skills
89-
rg -n "tiktok|upload" domain-skills
88+
rg --files agent-workspace/domain-skills
89+
rg -n "tiktok|upload" agent-workspace/domain-skills
9090
```
9191

9292
## Always contribute back
9393

94-
If you learned anything non-obvious about how a site works, open a PR to domain-skills/<site>/ before you finish. Default to contributing. The harness gets better only because agents file what they learn. If figuring something out cost you a few steps, the next run should not pay the same tax.
94+
If you learned anything non-obvious about how a site works, open a PR to `agent-workspace/domain-skills/<site>/` before you finish. Default to contributing. The harness gets better only because agents file what they learn. If figuring something out cost you a few steps, the next run should not pay the same tax.
9595

9696
Examples of what's worth a PR:
9797

@@ -118,7 +118,7 @@ The *durable* shape of the site — the map, not the diary. Focus on what the ne
118118

119119
- Raw pixel coordinates. They break on viewport, zoom, and layout changes. Describe how to *locate* the target (selector, scrollIntoView, aria-label, visible text) — never where it happened to be on your screen.
120120
- Run narration or step-by-step of the specific task you just did.
121-
- Secrets, cookies, session tokens, user-specific state. domain-skills/ is shared and public.
121+
- Secrets, cookies, session tokens, user-specific state. `agent-workspace/domain-skills/` is shared and public.
122122

123123
## What actually works
124124

@@ -139,7 +139,7 @@ The *durable* shape of the site — the map, not the diary. Focus on what the ne
139139
- Connect to the user's running Chrome. Don't launch your own browser.
140140
- cdp-use is only for CDPClient.send_raw. Prefer raw CDP strings over typed wrappers.
141141
- run.py stays tiny. No argparse, subcommands, or extra control layer.
142-
- Helpers stay short. Browser primitives in helpers.py; daemon/bootstrap and remote session admin live in admin.py.
142+
- Core helpers stay short. Put task-specific helper additions in `agent-workspace/agent_helpers.py`; daemon/bootstrap and remote session admin live in the core package.
143143
- Don't add a manager layer. No retries framework, session manager, daemon supervisor, config system, or logging framework.
144144

145145
## Gotchas (field-tested)
@@ -158,4 +158,4 @@ The *durable* shape of the site — the map, not the diary. Focus on what the ne
158158
## Interaction notes
159159

160160
- interaction-skills/ holds reusable UI mechanics such as dialogs, tabs, dropdowns, iframes, and uploads.
161-
- domain-skills/ holds site-specific workflows and should be updated when you discover reusable patterns for a website.
161+
- `agent-workspace/domain-skills/` holds site-specific workflows and should be updated when you discover reusable patterns for a website.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""Agent-editable browser helpers.
2+
3+
Add task-specific browser primitives here. Core helpers from browser_harness.helpers
4+
load this file when BH_AGENT_WORKSPACE points at this directory, or when this
5+
repo's default agent-workspace exists.
6+
"""
7+

packages/bcode-browser/harness/domain-skills/amazon/product-search.md renamed to packages/bcode-browser/harness/agent-workspace/domain-skills/amazon/product-search.md

File renamed without changes.

packages/bcode-browser/harness/domain-skills/archive-org/scraping.md renamed to packages/bcode-browser/harness/agent-workspace/domain-skills/archive-org/scraping.md

File renamed without changes.

packages/bcode-browser/harness/domain-skills/arxiv-bulk/scraping.md renamed to packages/bcode-browser/harness/agent-workspace/domain-skills/arxiv-bulk/scraping.md

File renamed without changes.

packages/bcode-browser/harness/domain-skills/arxiv/scraping.md renamed to packages/bcode-browser/harness/agent-workspace/domain-skills/arxiv/scraping.md

File renamed without changes.

0 commit comments

Comments
 (0)