omowright 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,6 +36,7 @@ export interface NetworkSnoopOptions {
36
36
  maxEntries?: number | undefined;
37
37
  maxBodyBytes?: number | undefined;
38
38
  }
39
+ export declare const JSON_MIME: RegExp;
39
40
  /**
40
41
  * Buffers CDP network traffic for a single page session.
41
42
  *
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Strips a value being entered (fill/type) out of the error its failure raised, so a secret typed
3
+ * into a form never reaches an agent transcript (#335). The layers below (a CDP transport, the
4
+ * BrowserSkill daemon) may quote the command they refused, raw or JSON-escaped, in the message,
5
+ * the stack, a `data` payload or a cause; each is rewritten in place down the cause chain.
6
+ */
7
+ export declare function redactValue(error: unknown, value: string): unknown;
@@ -1,12 +1,10 @@
1
- /**
2
- * Scroll-driven collection over a network snoop (see ./network-snoop.ts).
3
- */
4
1
  export interface ScrollPage {
5
2
  viewportSize(): {
6
3
  width: number;
7
4
  height: number;
8
5
  } | null | undefined;
9
6
  evaluate<T>(pageFunction: () => T): Promise<T>;
7
+ evaluate<T, A>(pageFunction: (arg: A) => T | PromiseLike<T>, arg: A): Promise<T>;
10
8
  mouse: {
11
9
  move(x: number, y: number): Promise<unknown>;
12
10
  wheel(deltaX: number, deltaY: number): Promise<unknown>;
@@ -14,14 +12,26 @@ export interface ScrollPage {
14
12
  }
15
13
  export interface JsonSnoop {
16
14
  popJson(): Iterable<unknown>;
15
+ /** Resolves on the next buffered entry the predicate accepts; rejects after timeoutMs. */
16
+ waitFor(match: (entry: {
17
+ mimeType: string | null;
18
+ }) => unknown, options: {
19
+ timeoutMs: number;
20
+ }): Promise<unknown>;
17
21
  }
18
22
  export type ScrollMode = "wheel" | "end";
23
+ /** The timer that bounds each round; defaults to the global setTimeout/clearTimeout. */
24
+ export interface ScrollClock {
25
+ setTimeout(callback: () => void, ms: number): unknown;
26
+ clearTimeout(handle: unknown): void;
27
+ }
19
28
  export interface CollectWhileScrollingOptions {
20
29
  minItems?: number;
21
30
  maxScrolls?: number;
22
31
  extract?: (json: unknown) => Iterable<unknown>;
23
32
  scroll?: ScrollMode;
24
33
  settleMs?: number;
34
+ clock?: ScrollClock;
25
35
  }
26
36
  export interface CollectWhileScrollingResult {
27
37
  rounds: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omowright",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "OmOWright browser automation for standard Chromium CDP endpoints.",
5
5
  "keywords": [
6
6
  "accessibility-snapshot",
@@ -51,7 +51,7 @@
51
51
  "test:cloak-profile": "bun test test/cloak-profile.test.ts test/cloak-profile.integration.test.ts",
52
52
  "typecheck": "bun check --no-script --no-pretty -p tsconfig.json",
53
53
  "typecheck:control": "bun scripts/typecheck-control.ts",
54
- "check": "bun run typecheck:control && bun run typecheck && bun run lint && bun run fmt:check",
54
+ "check": "bun scripts/bsk-protocol.ts --check && bun run typecheck:control && bun run typecheck && bun run lint && bun run fmt:check",
55
55
  "lint": "oxlint --deny-warnings src bin bridge test scripts && bun scripts/lint-ratchet.ts",
56
56
  "lint:ratchet:update": "bun scripts/lint-ratchet.ts --update",
57
57
  "lint:fix": "oxlint --fix src bin bridge test scripts",
@@ -59,7 +59,6 @@ const gen = collectWhileScrolling(page, snoop, {
59
59
  maxScrolls: 15,
60
60
  extract: (json) => json.items ?? [],
61
61
  scroll: "wheel", // "end" jumps to the bottom instead
62
- settleMs: 800,
63
62
  });
64
63
  let step;
65
64
  while (!(step = await gen.next()).done) items.push(step.value);
@@ -67,7 +66,9 @@ step.value; // { rounds, total, stoppedBecause }
67
66
  ```
68
67
 
69
68
  `for await (const item of gen)` works too when you don't need the return
70
- value. The loop drains first, then scrolls, and stops on `minItems`,
69
+ value. A round ends as soon as the next response lands or the page grows;
70
+ `settleMs` (default 800) only bounds a round in which neither happens, so leave
71
+ it alone unless the endpoint is slower than that. The loop drains first, then scrolls, and stops on `minItems`,
71
72
  `maxScrolls`, or two consecutive rounds where the document height didn't grow
72
73
  (`noGrowth`). The default `extract` accepts bodies that are already arrays.
73
74
 
@@ -36,16 +36,8 @@ disagree, every coordinate is wrong by the same constant offset and retrying
36
36
  repeats the miss. Pin both to one box:
37
37
 
38
38
  ```js
39
- await page._sendToTarget("Emulation.setDeviceMetricsOverride", {
40
- width: 1440,
41
- height: 900,
42
- deviceScaleFactor: 1,
43
- mobile: false,
44
- screenWidth: 1440,
45
- screenHeight: 900,
46
- viewport: { x: 0, y: 0, width: 1440, height: 900, scale: 1 },
47
- });
48
- const size = await page.refreshViewportSize(); // -> { width: 1440, height: 900 }
39
+ const { repinViewport, DEFAULT_AGENT_VIEWPORT } = await import("omowright");
40
+ const size = await repinViewport(page, DEFAULT_AGENT_VIEWPORT); // -> { width: 1440, height: 900 }
49
41
  ```
50
42
 
51
43
  Pin every page you act on, including tabs you did not open, then take a fresh
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: omowright
3
- description: "The default code-driven browser path for interactive browsing work: drives any browser from code with token-efficient a11y snapshots (compactSnapshot drops the refs map), ref-based clicks, coordinate control (CUA), viewport pinning, CAPTCHA input helpers for reCAPTCHA, Turnstile, hCaptcha, slider and text OCR, with a human fallback (not a solver), Chrome MV3 APIs (tabs/bookmarks/history/downloads/topSites), network snoop (read API JSON instead of DOM), flight-recorder trace (jsonl + HAR + screenshots), OOPIF-aware snapshots, dialog policy, human handoff for login/OTP, device emulation, request routes, and one connectBrowser() entry that picks the engine in priority order: the user's agent browser (Aside, Ego Lite), then the user's own browser through BrowserSkill, then the owned stealth CloakBrowser with zero exposed CDP ports; each engine has its own setup check (asideOnboard, bskOnboard). MUST USE for interactive browser work: scraping, blocked/WAF/JS-rendered pages, logins, the user's logged-in sites and open tabs, extension popups, form filling, screenshots, web QA, CAPTCHAs. The ulw-research browsing lane runs on ultimate-browsing, not this skill."
3
+ description: "The default code-driven browser path for interactive browsing work: token-efficient a11y snapshots (compactSnapshot drops the refs map), ref-based clicks, condition waits instead of fixed delays, coordinate control (CUA), viewport pinning, CAPTCHA input helpers (reCAPTCHA, Turnstile, hCaptcha, slider, text OCR) with a human fallback, Chrome MV3 APIs, network snoop (read API JSON instead of DOM), flight-recorder trace, OOPIF-aware snapshots, dialog policy, human handoff for login/OTP, device emulation, request routes, and one connectBrowser() entry that picks the engine in order: the user's agent browser (Aside, Ego Lite), the user's own browser through BrowserSkill, then the owned stealth CloakBrowser with zero exposed CDP ports. MUST USE for interactive browser work: scraping, blocked/WAF/JS-rendered pages, logins, the user's logged-in sites and open tabs, extension popups, form filling, screenshots, web QA, CAPTCHAs. The ulw-research browsing lane runs on ultimate-browsing, not this skill."
4
4
  ---
5
5
 
6
6
  # OmOWright
@@ -74,18 +74,37 @@ empty tree, not an error. A search does not move the diff baseline, and `find` c
74
74
  be combined with `diff`. `maxChars` still caps the whole captured tree before the
75
75
  search runs, so leave it off when searching a large page.
76
76
 
77
+ ## Wait for a state, never for a clock
78
+
79
+ **NEVER WRITE A FIXED DELAY** (`Bun.sleep`, `setTimeout`, `waitForTimeout`): it fails on a
80
+ slow page and wastes itself on a fast one. Wait for the state you need, and start the
81
+ wait before the action that causes it.
82
+
83
+ | Waiting for | Call |
84
+ | --- | --- |
85
+ | Something appearing or changing in the page | `page.waitForFunction(fn, arg, { timeout })` (options are the THIRD argument), `page.locator(ref).waitFor({ state: "visible" })` |
86
+ | The request an action triggers | `const got = page.waitForResponse(urlOrPredicate)`, act, `await got`; `snoop.waitFor(match)` with a snoop open |
87
+ | A navigation | `page.waitForURL(globOrRegExp)`, `page.waitForLoadState("networkidle")` |
88
+ | A new tab | `page.waitForEvent("popup")`, subscribed before the click |
89
+ | A person (login, OTP, CAPTCHA) | `requestHuman(page, { prompt, until })` |
90
+
91
+ Nothing follows `goto` or `newTab`: both already wait for content. A wait that can outlast
92
+ one tool call (a person, a deploy, a slow job) is not awaited in that call: start it, hand
93
+ its completion to your harness's watcher, keep working. Pattern in
94
+ `references/eval-kernel.md`.
95
+
77
96
  ## Owned engine: CloakBrowser
78
97
 
79
98
  When omowright owns the browser, use the CloakBrowser binary, not a plain headless shell: most real
80
99
  targets sit behind WAFs or bot scoring, and CloakBrowser's source-level
81
100
  fingerprint patches (Cloudflare Turnstile, FingerprintJS, BrowserScan) make it
82
101
  the safe choice. Plain headless shell is the speed fallback for trivially open
83
- pages: any Chrome/Chromium or
84
- `~/Library/Caches/ms-playwright/chromium_headless_shell-*/.../chrome-headless-shell`.
102
+ pages. Take either path from code, never from a guess:
85
103
 
86
- ```bash
87
- python3 -c "import cloakbrowser; print(cloakbrowser.binary_info()['binary_path'])"
88
- # -> ~/.cloakbrowser/chromium-<ver>/Chromium.app/Contents/MacOS/Chromium
104
+ ```js
105
+ const { findCloakBrowserPath, detectBrowsers } = await import("omowright");
106
+ const browserPath = findCloakBrowserPath(); // newest ~/.cloakbrowser/chromium-*; throws when none is installed (set CLOAKBROWSER_BIN off macOS)
107
+ const chrome = detectBrowsers().find((b) => b.installed)?.binary; // an installed Chrome-family binary, for the fallback
89
108
  ```
90
109
 
91
110
  For a reused authenticated profile, use `connectCloakProfile({ profileDir, fingerprintSeed })` from the package (or the `omowright-cloak --profile "$HOME/.local/share/omowright-cloak" --url <url> --once --snapshot` launcher). First use pins a fingerprint seed in a mode-`0600` metadata file inside the mode-`0700` profile; later runs reuse it and **REJECT a conflicting seed** instead of silently changing identity. It passes the fixed `--fingerprint=<seed>` plus the platform flag on every `connectPipe()` launch. The seed is an identity pin, not a credential store.
@@ -124,18 +143,15 @@ CUA acts in viewport pixels. When the render surface and coordinate space
124
143
  disagree, every coordinate is off by a constant and retrying repeats the miss:
125
144
 
126
145
  ```js
127
- await page._sendToTarget("Emulation.setDeviceMetricsOverride", {
128
- width: 1440,
129
- height: 900,
130
- deviceScaleFactor: 1,
131
- mobile: false,
132
- screenWidth: 1440,
133
- screenHeight: 900,
134
- viewport: { x: 0, y: 0, width: 1440, height: 900, scale: 1 },
135
- });
136
- await page.refreshViewportSize(); // -> { width: 1440, height: 900 }
146
+ const { repinViewport, DEFAULT_AGENT_VIEWPORT } = await import("omowright");
147
+ await repinViewport(page, DEFAULT_AGENT_VIEWPORT); // -> { width: 1440, height: 900 }
137
148
  ```
138
149
 
150
+ For a device instead of a box, `emulate(page, "iphone-14")` (also `pixel-7`, `ipad-air`,
151
+ `desktop-1440`) sets metrics, touch and user agent together, and
152
+ `page.emulateMedia({ colorScheme })` covers media features. Raw `Emulation.*` CDP is never
153
+ needed for either.
154
+
139
155
  Pin every page you act on, including tabs you did not open, then take a fresh
140
156
  screenshot — coordinates read off an unpinned screenshot are stale.
141
157
 
@@ -166,9 +182,12 @@ Preset and `TOOLS.md` paths are relative to the package root.
166
182
  their own browser; 1Password sessions are device-bound and never work from
167
183
  cookies. Detail in `references/stealth.md`. Cookie reuse is fine for ordinary
168
184
  sessions (Grafana, internal tools).
169
- - **Always `compactSnapshot()`** before sending a snapshot to a model — the refs
170
- map resolves in-page, so dropping it is free; it was 7% to 64% of the bytes
171
- across pages measured on 2026-11-09.
185
+ - **Read within a budget.** `compactSnapshot()` before a model reads any snapshot
186
+ (the refs map resolves in-page; it was 7% to 64% of the bytes, measured
187
+ 2026-11-09). Check `snapshotTokens(snapshot)` (`{ bytes, estTokens }`) before
188
+ printing a tree you have not measured, and narrow a large one with `find`,
189
+ `selector`, `interactive: true` or `maxChars`. `page.evaluate` returns the
190
+ fields you need, never `innerHTML` or a whole document's `innerText`.
172
191
  - **Refs die on every new snapshot.** Pass `page.locator("e1")` straight from the
173
192
  latest snapshot; never reuse a ref across snapshots, never put one in CSS.
174
193
  - **Refs stay page-level.** Child-frame refs look like `f1e3` and still go to
@@ -25,18 +25,54 @@ await session.stop(); // ALWAYS: returns borrowed tabs, closes the Agent Window
25
25
 
26
26
  ### Shared control (BrowserSkill 0.4+)
27
27
 
28
- The person at the keyboard can work in the task tab while the agent does. The
29
- extension therefore refuses every page action with `permission_denied` /
30
- `data.reason: "cooperation_sync_required"` unless it carries the
31
- `context_id` of the latest `session.cooperate("sync")`. A context is good
32
- for one action: sync, decide from what the sync reported, act with
33
- `{ context }`, then sync again. Gated: navigation (except the first
34
- navigation of the untouched blank tab), every input method, `evaluate` (and
35
- so `bskSnapshot`), `tabClose`, `resize`, `emulate`, `observe` with
36
- `probeHover`, and `screenshot({ fullPage: true })`. Reads (`observe`,
37
- `snapshot`, `getHtml`, `screenshot()`, `console`, `network`,
38
- `waitForNavigation`) need no context. `dependsOn: ["@e2", ...]` narrows the
39
- check to the observed regions the decision used.
28
+ The person at the keyboard can work in the task tab while the agent does, so
29
+ the extension refuses a page action unless it carries what the latest
30
+ `session.cooperate("sync")` returned. Gated: navigation, every input method,
31
+ `drag`, `evaluate` (and so `bskSnapshot`), `tabClose`, `resize`, `emulate`,
32
+ `observe` with `probeHover`, and `screenshot({ fullPage: true })`. Reads
33
+ (`observe`, `snapshot`, `getHtml`, `read`, `extract`, `screenshot()`,
34
+ `console`, `network`, `waitForNavigation`, `waitForElement`) need no context.
35
+
36
+ Every gated action takes `{ context, observation, expect, dependsOn }`
37
+ besides its own options; any other key throws. A session runs under one
38
+ control policy, chosen by its first sync and fixed after that:
39
+
40
+ | Action | `strict` (the default) | `target` (`cooperate("sync", { controlPolicy: "target" })`) |
41
+ | ---------------------------------------- | ------------------------------------ | ----------------------------------------------------------- |
42
+ | click, hover, fill, ... on a ref/selector | a fresh `context` per action | `context`; the same one serves the next DOM action |
43
+ | `evaluate` (and `bskSnapshot`) | a fresh `context` per action | `context` plus an unused `observation`, or `expect` facts, or `unverified: true` |
44
+ | `press` with no target, `navigate` | a fresh `context` per action | `context` plus an unused `observation` |
45
+ | `dependsOn` | narrows the check to observed regions | refused; state facts in `expect` instead |
46
+
47
+ The sync result carries `context_id` and, when the daemon sends one,
48
+ `observation_id`; pass them as `{ context, observation }`. An observation is
49
+ good for one action. `expect` is a list of literal facts the extension checks
50
+ right before the input, for example
51
+ `[{ target: "#total", field: "text", equals: "3" }]` (`field` is `text`,
52
+ `value`, `checked`, `attribute` or `exists`); a false fact refuses the action
53
+ with `reason: "precondition_failed"` and nothing is sent to the page.
54
+
55
+ ```js
56
+ const { connectBrowserSkill } = await import("omowright");
57
+
58
+ const session = await connectBrowserSkill({ name: "check out", focused: false });
59
+ await session.navigate("https://example.com/cart");
60
+ const sync = await session.cooperate("sync", { controlPolicy: "target" });
61
+ const context = sync.context_id;
62
+ await session.click("#apply-coupon", { context });
63
+ await session.click("#checkout", { context, expect: [{ target: "#total", field: "text", equals: "$3.00" }] });
64
+ const next = await session.cooperate("sync");
65
+ await session.press("Enter", { context: next.context_id, observation: next.observation_id });
66
+ const { items } = await session.read("h1"); // no context needed
67
+ await session.stop();
68
+ ```
69
+
70
+ A session's first `navigate` can meet the extension while the new task tab is
71
+ still committing its blank document. That refusal ("The initial task tab
72
+ changed", nothing sent to the page) is handled inside `navigate`: it waits on
73
+ `waitForNavigation` for the tab to settle, checks in `tabList` that the tab is
74
+ still blank, and sends the navigate once more. If the tab never settles or has
75
+ moved on, `navigate` throws the refusal with the tab's state in the message.
40
76
 
41
77
  On `cooperation_sync_required`, call `session.cooperate("wait", { timeoutMs })`
42
78
  (at most 25 s) until it reports `ready`, sync again and replan from the live
@@ -67,12 +103,28 @@ Targets are a ref (`"e3"` / `"@e3"` from `session.observe()` or
67
103
  `session.snapshot()`), a CSS selector, or `{ captureId, x, y }` from a
68
104
  screenshot.
69
105
 
106
+ On an extension older than 0.4.0 there is no shared control: `cooperate("sync")`
107
+ resolves without a `context_id` and actions run ungated, so the loop above runs
108
+ unchanged there.
109
+
110
+ A `BskSession` is not a page: it has no `goto`, `locator` or `listTargets`.
111
+ Read with `observe({ maxTokens })` first: it is the cheapest read, needs no
112
+ sync context, and its `@eN` refs work inside shadow roots and frames. To wait,
113
+ use `navigate(url, { waitUntil: "networkidle" })` for a page that renders after
114
+ load and `waitForNavigation()` after an action that navigates; for a later
115
+ state, `evaluate` a promise that resolves when the state holds
116
+ (`{ awaitPromise: true, timeoutMs, context }`; `evaluate` is a gated action).
117
+ Never a fixed delay.
118
+
70
119
  | Need | Call |
71
120
  | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
72
121
  | Navigate / history | `navigate(url, {waitUntil, timeoutMs})`, `back()`, `forward()`, `reload({hard})`, `waitForNavigation()` |
73
122
  | Read the page | `observe({maxTokens, cursor, probeHover})` (VOM text with `@eN` refs), `snapshot()`, `getHtml({ref, maxBytes})`, `bskSnapshot(session)` (OmOWright tree + css) |
123
+ | Read values | `read(target, {fields, maxNodes})` (text, value, attributes of matching nodes), `extract("table" \| "list" \| "discover", {target, itemSelector, fields})` |
124
+ | Wait | `waitForElement(target, {state: "visible" \| "hidden" \| "attached" \| "detached", timeoutMs})`, `waitForNavigation()` |
74
125
  | Act | `click(target, {button, clickCount, modifiers})`, `hover`, `fill(target, value)`, `press(key, {target, holdMs})`, `select(target, values)`, `focus`, `blur`, `scrollTo`, `wheel({deltaY})` |
75
- | Script | `evaluate(expression, {awaitPromise, timeoutMs})` → `{ok, value, error}`; Agent Window tabs only |
126
+ | Drag | `drag({selector} \| {ref}, {target, delta: {x, y}, mode})` |
127
+ | Script | `evaluate(expression, {awaitPromise, timeoutMs, unverified})` → `{ok, value, error}`; Agent Window tabs only |
76
128
  | Pixels | `screenshot({ref})` → `{buffer, width, height, captureId}`; `screenshot({fullPage: true})` streams the capture back in chunks |
77
129
  | Tabs | `tabList({scope: "user"})`, `tabCreate({url})`, `tabSelect(id)`, `tabClose(id)`, `tabBorrow(id)` (the user confirms), `tabReturn(id)` |
78
130
  | Humans | `requestHelp({prompt, targets, completionCriteria, timeoutMs})` for login, CAPTCHA, OTP, payment — the extension shows an overlay and waits |
@@ -82,7 +134,10 @@ Anything the daemon refuses comes back as a `BskRpcError` with the daemon's
82
134
  `code` (`not_found`, `invalid_params`, `permission_denied`, `timeout`,
83
135
  `cdp_failed`, `user_aborted`, `no_browser_connected`, ...). Long calls can be
84
136
  cancelled: `const h = session.client.callWithHandle(...)`, then
85
- `session.client.cancel(h.rpcId)`.
137
+ `session.client.cancel(h.rpcId)`. The rest of the daemon's tools (dialogs,
138
+ uploads and downloads, recording, `debug`) are reachable as
139
+ `session.tool("dialog_accept", { dialog_id })` with the daemon's own parameter
140
+ names.
86
141
 
87
142
  ## bskSnapshot leaves no trace
88
143
 
@@ -190,3 +245,10 @@ socket. On another machine, run the library where the daemon is (for example
190
245
  through a machine mesh), or pair the extension to a daemon in server mode
191
246
  (`bsk daemon start --mode server`, WSS required off loopback). Windows named
192
247
  pipes are not discovered automatically; pass `sockPath` explicitly.
248
+
249
+ When the process cannot reach the daemon by socket path at all, pass your own
250
+ transport as `connectBrowserSkill({ client })`. It is any object with
251
+ `call(method, params, options)` that sends one daemon request (`system.status`,
252
+ `session.start`, `tool.*`, `session.stop`) and resolves with its `result` or
253
+ rejects with a `BskRpcError`. The exported type `BskClient` describes it, and
254
+ the session uses nothing else.
@@ -7,11 +7,15 @@ parallel. It does not keep child processes alive for you.
7
7
  **ONLY `globalThis.*` SURVIVES ACROSS CELLS.** Top-level `const`/`let` bindings do
8
8
  not; re-import or read from `globalThis` in later cells.
9
9
 
10
- **A BROWSER SPAWNED IN A CELL CAN DIE WHEN THAT CELL SETTLES.** Measured, not
11
- assumed: `Bun.spawn` children were killed with SIGKILL at cell completion, and
12
- `connectPipe` (which uses `child_process.spawn` without detaching) lost a
13
- browser between two cells. A `globalThis.omw` handle whose process is gone
14
- rejects every call. Two patterns hold up:
10
+ **CONNECT ONCE AND KEEP THE HANDLE ON `globalThis`.** A new connect in every
11
+ cell throws away the page state and pays the launch again.
12
+
13
+ **WHETHER A BROWSER SPAWNED IN A CELL OUTLIVES IT DEPENDS ON THE HARNESS.**
14
+ Measured both ways: an older eval kernel killed `Bun.spawn` children with
15
+ SIGKILL at cell completion and lost a `connectPipe` browser between two cells;
16
+ omo's kernel kept a `connectPipe` browser and an unawaited `waitForFunction`
17
+ alive across cells (2026-11-26). A `globalThis.omw` handle whose process is gone
18
+ rejects every call, so probe before reuse. Two patterns hold up everywhere:
15
19
 
16
20
  1. **One cell, whole job.** Connect, act, close in the same cell. Right for any
17
21
  job that fits in one cell's runtime; the parallel lanes below are this shape.
@@ -81,6 +85,33 @@ await omwPage.locator("e1").click();
81
85
  display(await omwPage.screenshot({ type: "png" })); // display() renders images inline
82
86
  ```
83
87
 
88
+ ## Waits that outlast a cell
89
+
90
+ A cell that awaits a person, a deploy or a slow job is detached by the harness
91
+ (after 30 s in omo) and then holds the kernel: every later cell queues behind
92
+ it. Subscribe the harness watcher first, start the wait without awaiting it, and
93
+ return:
94
+
95
+ ```js
96
+ const flag = path.join(os.tmpdir(), `omowright-signed-in-${Date.now()}.flag`);
97
+ await tool.monitor({ description: "sign-in finished", path: flag, event: "create" });
98
+ globalThis.omwWait = omwPage
99
+ .waitForFunction(() => document.querySelector("[data-user]") !== null, undefined, { timeout: 600_000 })
100
+ .then(
101
+ () => fs.writeFileSync(flag, "ok"),
102
+ (error) => fs.writeFileSync(flag, `failed: ${error.message}`),
103
+ );
104
+ ```
105
+
106
+ The cell returns at once, the kernel stays free for other cells on the same
107
+ `omwPage`, and the file event wakes the turn on success and on timeout alike,
108
+ so a wait never ends silently. Read the flag, then continue from the live page.
109
+ Measured on 2026-11-26: the event arrived as the page state flipped, and a 2 s
110
+ bound reported `WaitForFunctionTimeoutError` at 2004 ms. `tool.monitor` is omo's
111
+ watcher; in another harness use its file or command watch. The same rule covers
112
+ a dev server or a deploy the page depends on: watch it with a command monitor
113
+ that prints one line when it is ready, never with a loop in a cell.
114
+
84
115
  ## Parallel lanes (research fan-out)
85
116
 
86
117
  Each lane gets its own browser and profile: no shared state, and the pipe
@@ -101,6 +101,12 @@ const result = await requestHuman(page, {
101
101
  if (result.outcome !== "continued") throw new Error(`handoff ${result.outcome}`);
102
102
  ```
103
103
 
104
+ **IN AN EVAL CELL, DO NOT `await` THE HANDOFF.** A person takes longer than a
105
+ cell, and an awaited handoff holds the kernel until they finish. Subscribe the
106
+ harness watcher, start `requestHuman(...)` without `await`, write its outcome to
107
+ the watched file in `.then`, and return; the page stays usable from other cells
108
+ meanwhile. Pattern in `eval-kernel.md` (next to this file), "Waits that outlast a cell".
109
+
104
110
  The call brings the window to the front, injects a shadow-DOM banner with your
105
111
  prompt and a Done button, then polls every `pollMs` for `until` or the button.
106
112
  Pass an `AbortSignal` as `signal` to cancel from your side. The banner is
@@ -129,4 +135,5 @@ fields (`width, height, deviceScaleFactor, mobile, hasTouch, userAgent,
129
135
  platform`) for a custom device. The original UA is captured on the first call
130
136
  per page, so `null` always returns to where you started. Re-snapshot after
131
137
  switching: layout changes move refs, and a mobile layout often swaps a nav bar
132
- for a menu button.
138
+ for a menu button. Media features are separate:
139
+ `page.emulateMedia({ colorScheme: "dark", reducedMotion: "reduce" })`.
@@ -65,9 +65,16 @@ await page.pdf({ path, format?, margin? });
65
65
  await page.locator("e1").click(); // ref or CSS
66
66
  await page.locator("input[name=q]").fill("text");
67
67
  await page.keyboard.press("Enter"); await page.mouse.wheel(0, 400);
68
+ await page.waitForFunction(() => window.ready === true, undefined, { timeout: 10_000 }); // a page state; options are the 3rd argument
69
+ const saved = page.waitForResponse("**/api/cart"); // start the wait, then act, then await it
70
+ await page.locator("e7").click(); await saved;
71
+ await page.waitForURL("**/dashboard"); await page.waitForLoadState("networkidle");
68
72
  await page.close();
69
73
  ```
70
74
 
75
+ Wait with these, never with a fixed delay; the full table is in `SKILL.md` ("Wait for a
76
+ state, never for a clock").
77
+
71
78
  ## Snapshot discipline
72
79
 
73
80
  ```js