Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs(debug): document scripted browser runs with pnpm debug web

Steven Enamakel86ea65ba0ed1
diff --git a/AGENTS.md b/AGENTS.md
index ec93fbfbdb..d9afe7ea80 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -112,6 +112,19 @@ DevTools client can attach to it. Run the same SPA in Chrome instead:
desktop core's port; the default scans 7788-7808), `OPENHUMAN_CORE_TOKEN`, and
`OPENHUMAN_WORKSPACE` (point it at a scratch dir for a clean profile).
+Scripted browser runs (Playwright, headless): `pnpm debug web` boots a
+throwaway stack (the mock backend, a fresh `openhuman-core serve` on a scratch
+workspace, Vite with `OPENHUMAN_VITE_NO_WATCH=1`) and signs in through the real
+GitHub button, which the mock answers like the backend. `--script <file.mjs>`
+runs a scenario against the signed-in page (default export receives `page`,
+`mock.set(key, value)` for mock behaviors such as `llmStreamScript`, `rpc`,
+`screenshot` and `log`); without it the stack stays up until Ctrl-C. Logs and
+screenshots go to `target/debug-logs/web-<ts>/`. Example:
+`scripts/debug/web-scripts/stop-mid-turn.mjs`. Set `OPENHUMAN_VITE_NO_WATCH=1`
+on any Vite run that dies with `ENOSPC: System limit for number of file
+watchers reached`. `--headed` needs the full Chromium build
+(`pnpm --filter openhuman-app exec playwright install chromium`).
+
Long CI build or test commands must run through
`scripts/ci-cancel-aware.sh`. Do not export `CARGO_TARGET_DIR`; the repository
already configures shared build output where appropriate.
diff --git a/scripts/debug/README.md b/scripts/debug/README.md
index 2133a58319..cb9d76811a 100644
--- a/scripts/debug/README.md
+++ b/scripts/debug/README.md
@@ -33,6 +33,29 @@ pnpm debug logs last --tail 100
Logs land in `target/debug-logs/<kind>-<suffix>-<timestamp>.log`. The directory
is created on demand and is safe to delete — nothing else writes there.
+## Browser scenarios (`pnpm debug web`)
+
+```sh
+pnpm debug web # stack + signed-in page, up until Ctrl-C
+pnpm debug web --script scripts/debug/web-scripts/stop-mid-turn.mjs
+pnpm debug web --script my-scenario.mjs --keep # leave the stack up afterwards
+```
+
+`web-ui.mjs` starts the shared mock backend in-process, a fresh
+`openhuman-core serve` (built if missing) on a scratch workspace, and Vite with
+`OPENHUMAN_VITE_NO_WATCH=1` (no file watcher or HMR, so it survives a host whose
+inotify watch limit is used up). It opens the SPA in Playwright Chromium through
+`/__dev-connect` and signs in through the real GitHub button: the mock answers
+`/auth/<provider>/login?redirectUri=<vite>/__dev-auth` like the backend.
+
+A scenario is an ES module whose default export receives
+`{ page, context, browser, mock, rpc, urls, logDir, screenshot, log }`.
+`mock.set(key, value)` sets a mock behavior (`llmStreamScript` scripts the LLM
+stream, see `scripts/mock-api/routes/llm.mjs`), `rpc(method, params)` calls the
+core, and `screenshot(name)` saves into the run's artifact directory
+(`target/debug-logs/web-<ts>/`: `core.log`, `vite.log`, `browser.log`,
+screenshots, the scratch workspace). A thrown error saves `failure.png`.
+
## Why
- **Filtering** — positional pattern + `-t "<name>"` for Vitest, single spec