omowright 0.0.0 → 0.2.0

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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +290 -2
  3. package/TOOLS.md +487 -0
  4. package/bin/omowright-cloak.mjs +112 -0
  5. package/package.json +57 -4
  6. package/presets/agent-events/SKILL.md +75 -0
  7. package/presets/captcha/SKILL.md +129 -0
  8. package/presets/chrome/SKILL.md +88 -0
  9. package/presets/cloak-bridge/SKILL.md +43 -0
  10. package/presets/network/SKILL.md +126 -0
  11. package/presets/visual-browse/SKILL.md +103 -0
  12. package/skills/omowright/SKILL.md +193 -0
  13. package/skills/omowright/references/1password.md +118 -0
  14. package/skills/omowright/references/browserskill.md +195 -0
  15. package/skills/omowright/references/eval-kernel.md +100 -0
  16. package/skills/omowright/references/frames-layers-human.md +123 -0
  17. package/skills/omowright/references/quickstart.md +109 -0
  18. package/skills/omowright/references/stealth.md +174 -0
  19. package/src/agent-tabs.js +179 -0
  20. package/src/aria-hidden.js +47 -0
  21. package/src/bridge-schemas.js +44 -0
  22. package/src/bridge-transport.js +83 -0
  23. package/src/browser-context.js +105 -0
  24. package/src/browser-process.js +127 -0
  25. package/src/bsk/browser-signals.js +90 -0
  26. package/src/bsk/browsers.js +114 -0
  27. package/src/bsk/connect.js +75 -0
  28. package/src/bsk/daemon-info.js +100 -0
  29. package/src/bsk/external-extension.js +110 -0
  30. package/src/bsk/identify-browser.js +88 -0
  31. package/src/bsk/install-cli.js +81 -0
  32. package/src/bsk/ipc-client.js +236 -0
  33. package/src/bsk/onboard.js +140 -0
  34. package/src/bsk/screenshot.js +49 -0
  35. package/src/bsk/session.js +131 -0
  36. package/src/bsk/snapshot.js +56 -0
  37. package/src/bsk/targets.js +25 -0
  38. package/src/captcha-wait.js +79 -0
  39. package/src/captcha.js +142 -0
  40. package/src/cdp-errors.js +23 -0
  41. package/src/cdp-methods.js +69 -0
  42. package/src/chrome-profile.js +176 -0
  43. package/src/chrome.js +194 -0
  44. package/src/cloak-profile.js +266 -0
  45. package/src/connection.js +234 -0
  46. package/src/console-events.js +12 -0
  47. package/src/cookies.js +39 -0
  48. package/src/core.js +1702 -0
  49. package/src/cua.js +74 -0
  50. package/src/dialog-policy.js +80 -0
  51. package/src/emulate.js +127 -0
  52. package/src/events.js +111 -0
  53. package/src/frames-snapshot.js +138 -0
  54. package/src/har.js +103 -0
  55. package/src/human-handoff.js +124 -0
  56. package/src/index.js +89 -0
  57. package/src/injected.js +3 -0
  58. package/src/instance-lock.js +74 -0
  59. package/src/instances.js +490 -0
  60. package/src/internal-capability.js +1 -0
  61. package/src/launch-endpoint.js +185 -0
  62. package/src/layers.js +138 -0
  63. package/src/llm.js +201 -0
  64. package/src/lock-backend-win32.js +54 -0
  65. package/src/lock-backend.js +81 -0
  66. package/src/native-host-win32.js +201 -0
  67. package/src/network-events.js +223 -0
  68. package/src/network-snoop.js +229 -0
  69. package/src/nul-frames.js +28 -0
  70. package/src/open-shadow-query.js +101 -0
  71. package/src/owner-only.js +196 -0
  72. package/src/page-bundle.js +1478 -0
  73. package/src/page-events.js +45 -0
  74. package/src/page-routes.js +94 -0
  75. package/src/page-setup.js +239 -0
  76. package/src/pipe.js +418 -0
  77. package/src/process-start-time.js +64 -0
  78. package/src/routes.js +256 -0
  79. package/src/running-browser.js +85 -0
  80. package/src/scroll-collect.js +73 -0
  81. package/src/serial-emitter.js +17 -0
  82. package/src/shared-connections.js +285 -0
  83. package/src/snapshot-diff.js +75 -0
  84. package/src/text-matching.js +101 -0
  85. package/src/trace.js +183 -0
  86. package/src/url-match.js +148 -0
  87. package/src/viewport.js +12 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yeongyu Kim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,291 @@
1
- # omowright
1
+ # OmOWright
2
2
 
3
- Placeholder. Real releases are published from https://github.com/code-yeongyu/omowright via GitHub Actions trusted publishing.
3
+ [![CI](https://github.com/code-yeongyu/omowright/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/code-yeongyu/omowright/actions/workflows/ci.yml)
4
+
5
+ Playwright-shaped browser automation for AI agents. The API a model already
6
+ knows, a fraction of the tokens, and the scrolling primitives real websites
7
+ need.
8
+
9
+ OmOWright exists because of one article. In [How we built the SOTA browser
10
+ agent that outperforms Fable](https://x.com/hyojun_at/article/2070234507995910413),
11
+ Jun ([@hyojun_at](https://x.com/hyojun_at)) explains how [Aside](https://aside.com)
12
+ reached #1 on Online-Mind2Web, Odyssey and BU-Bench-V1: give the model the
13
+ browser interface it was trained on (Playwright), keep every tool output
14
+ high-signal, and treat CDP as an implementation detail the model never sees.
15
+ We read it, agreed with every line, and built OmOWright on those principles.
16
+
17
+ ## Why it looks like Playwright
18
+
19
+ Jun's argument is the whole design:
20
+
21
+ 1. **Follow the model's training data.** LLMs have seen more Playwright than
22
+ any other browser API, so OmOWright keeps the Playwright shape:
23
+ `page.goto`, `page.locator(...).click()`, `page.mouse.wheel`,
24
+ `page.keyboard.type`, `page.screenshot`, `getByRole`, `frameLocator`. No
25
+ new vocabulary to teach in the prompt.
26
+ 2. **Protect the context window.** Raw DOM and raw CDP are noise. The primary
27
+ read is an accessibility snapshot with refs, and `compactSnapshot()` strips
28
+ the duplicated refs map, which is about 54% of the bytes on a real page.
29
+ 3. **CDP underneath, never on top.** Every method is a thin wrapper over CDP
30
+ calls. The model writes Playwright; the library speaks the protocol.
31
+ 4. **Fall back to pixels.** When the DOM lies (canvas, custom widgets,
32
+ challenge pages), `createCua(page)` gives coordinate-level control over the
33
+ same viewport.
34
+
35
+ ```js
36
+ import { compactSnapshot, connectPipe } from "omowright";
37
+
38
+ const browser = await connectPipe({ browserPath: "/path/to/chromium", browserArgs: ["--headless"] });
39
+ const page = await browser.newTab("https://example.com");
40
+
41
+ console.log(compactSnapshot(await page.snapshot()));
42
+ // - heading "Example Domain" [level=1]
43
+ // - text: "This domain is for use in documentation examples ..."
44
+ // - paragraph:
45
+ // - link "Learn more" [ref=e1]
46
+
47
+ await page.locator("e1").click(); // refs come straight from the snapshot
48
+ await browser.close();
49
+ ```
50
+
51
+ Re-snapshots come back as a unified diff against the previous tree, so a model
52
+ reads what changed instead of the whole page again.
53
+
54
+ ## Snapshot size
55
+
56
+ Token counts per page (o200k_base, from the `gpt-tokenizer` devDependency),
57
+ each read right after `page.goto()`: the raw HTML
58
+ (`document.documentElement.outerHTML`), `compactSnapshot(await page.snapshot())`
59
+ and `compactSnapshot(await page.snapshot({ interactive: true }))`. Measured on
60
+ 2026-11-05 (UTC) at commit `4845ef5` with Chrome for Testing 156.0.8078.4
61
+ (headless shell) on Linux.
62
+
63
+ | Page | Shape | Raw HTML | Snapshot | Interactive snapshot | Snapshot / HTML | Interactive / HTML |
64
+ | --- | --- | ---: | ---: | ---: | ---: | ---: |
65
+ | news.ycombinator.com | link-heavy | 11,615 | 4,220 | 3,811 | 36.3% | 32.8% |
66
+ | en.wikipedia.org/wiki/Web_browser | long article | 143,312 | 14,155 | 12,591 | 9.9% | 8.8% |
67
+ | github.com/code-yeongyu/omowright \* | app-like | 116,378 | 5,432 | 5,481 | 4.7% | 4.7% |
68
+ | example.com | trivial | 637 | 222 | 222 | 34.9% | 34.9% |
69
+ | httpbin.org/forms/post | form | 428 | 370 | 245 | 86.4% | 57.2% |
70
+
71
+ \* The interactive snapshot is read after the full one, and here it came out
72
+ larger, so the page likely changed between the two reads: `page.goto()` can
73
+ resolve before a page like this has loaded
74
+ ([#152](https://github.com/code-yeongyu/omowright/issues/152)). The next run
75
+ read 111,370 / 5,262 / 4,443 tokens (4.7% / 4.0%).
76
+
77
+ Live pages drift, so reruns differ; the raw HTML varies most (Wikipedia read
78
+ 143,312 and then 92,100 HTML tokens in two runs in a row, and 14,155 and then
79
+ 12,925 snapshot tokens).
80
+
81
+ Reproduce after `bun install` (any Chromium works for `--browser`, or set
82
+ `OMOWRIGHT_BENCH_BROWSER`):
83
+
84
+ ```bash
85
+ node scripts/bench-snapshot-tokens.mjs --browser ~/.cache/ms-playwright/chromium_headless_shell-1248/chrome-headless-shell-linux64/chrome-headless-shell --browser-arg=--no-sandbox
86
+ ```
87
+
88
+ ## Scrolling is a first-class problem
89
+
90
+ Most of the web an agent cares about is behind a scroll: feeds, search results,
91
+ tables that page over XHR, "load more" that never ends. OmOWright treats that
92
+ as a core case rather than a `mouse.wheel` loop the agent has to invent.
93
+
94
+ **Collect while scrolling.** Pages fetch their list data as JSON; reading that
95
+ is cleaner than scraping rendered rows. `createNetworkSnoop` captures the
96
+ responses and `collectWhileScrolling` drives the page until it has enough:
97
+
98
+ ```js
99
+ import { createNetworkSnoop, collectWhileScrolling } from "omowright";
100
+
101
+ const snoop = createNetworkSnoop(page, { match: { url: /\/api\/feed/, mimeType: "json" } });
102
+ await page.goto("https://example.com/feed");
103
+
104
+ const items = [];
105
+ const run = collectWhileScrolling(page, snoop, {
106
+ minItems: 200, // stop once this many items are in hand
107
+ maxScrolls: 15, // or after this many scroll rounds
108
+ extract: (json) => json.items, // pull items out of each JSON body
109
+ scroll: "wheel", // "end" jumps to the bottom instead
110
+ settleMs: 800, // wait for the next page to land
111
+ });
112
+ let step;
113
+ while (!(step = await run.next()).done) items.push(step.value);
114
+ step.value; // { rounds, total, stoppedBecause: "minItems" | "maxScrolls" | "noGrowth" }
115
+ ```
116
+
117
+ It drains first, scrolls second, and stops on its own when the document stops
118
+ growing, so an agent never has to guess how many times to scroll.
119
+
120
+ **Scroll like a user.** `page.mouse.wheel(dx, dy)` dispatches a real wheel
121
+ event at the pointer, which is what lazy loaders and virtualized lists listen
122
+ for. `scroll: "wheel"` above uses exactly this from the viewport centre.
123
+
124
+ **Scroll to a ref.** `page.locator("e42").scrollIntoViewIfNeeded()` centres an
125
+ element in the viewport before you act on it.
126
+
127
+ **Scroll by coordinates.** `createCua(page).scroll({ x, y, scrollX, scrollY })`
128
+ scrolls at a point in viewport pixels for canvases, embedded panes and other
129
+ surfaces the accessibility tree does not describe.
130
+
131
+ **Wait for the request, not the clock.** `snoop.waitFor({ url, method })`
132
+ resolves when the response the scroll triggered has finished, so there is no
133
+ sleep to tune.
134
+
135
+ ## Everything else in the box
136
+
137
+ - **Zero-port pipe transport.** `connectPipe()` launches Chromium with
138
+ `--remote-debugging-pipe` and speaks CDP over inherited file descriptors. No
139
+ `/json/*` endpoint and no listening TCP port exist for the driven browser.
140
+ `connect(url)` attaches to an existing DevTools endpoint instead. Named
141
+ instances are the one exception: they listen on a local `127.0.0.1` port
142
+ chosen by the OS (`--remote-debugging-port=0`). That keeps the endpoint off
143
+ the network, but it is unauthenticated — any local process can drive a named
144
+ browser, which a pipe-transport browser never allows.
145
+ - **Named instances.** `connectNamed(name)` attaches to a live registered
146
+ Chromium, relaunches a stale one, and errors naming the holder (name, pid,
147
+ endpoint) when it is unresponsive; an attach requires the endpoint to answer
148
+ with the browser GUID recorded at launch, so a reused pid on a rebound port is
149
+ relaunched rather than driven. `listInstances()` lists every registered
150
+ instance with liveness. The registry directory is owner-only (mode `0700`; on
151
+ Windows a protected ACL), so on Windows it must live on a volume with ACLs:
152
+ on FAT32, exFAT or a share without ACLs `connectNamed` throws instead of
153
+ leaving the registry open. The registry must be on a local filesystem;
154
+ network filesystems (NFS/SMB) do not provide the cross-process guarantees
155
+ required here. Linux needs the `flock` utility from util-linux or BusyBox.
156
+ Locks are kernel-held and released on process exit; their zero-byte `.flock`
157
+ files persist. Never delete or rename a `.flock` while clients use the registry.
158
+ **Upgrading from 0.1.0:** stop all clients sharing a registry before upgrading
159
+ them together; old and new versions use different locks and must not overlap.
160
+ Legacy `.lock`, `.lock.*.stale`, and `.lock.*.tmp` files are ignored and left
161
+ untouched; remove them manually only after all clients have upgraded.
162
+ - **Shared attaches.** Chrome asks the user to allow remote debugging once per
163
+ connection to their own profile, so `connect(url)` and `connectNamed`
164
+ attaches in one process share one CDP connection per browser (keyed by its
165
+ GUID). Each call returns a handle on it: `close()` RELEASES that handle, and
166
+ only the last release disconnects. Pages attached through one handle are the
167
+ same pages for every handle and stay attached until the last release. A
168
+ handle never changes what another holder gets: on a shared connection
169
+ `setDialogPolicy` throws `SharedConnectionError` (pass `dialogPolicy` when
170
+ attaching to get a connection of your own), a sole holder's
171
+ `setDialogPolicy` works and that connection is never shared again, and
172
+ properties, client writes and listeners stay with the handle. A connection
173
+ is never shared when an `authorizer` (or any non-plain client option) is
174
+ set, nor between callers whose options differ (`dialogPolicy` included). A
175
+ shared handle's reconnect never reaches a browser other than the one it
176
+ was opened for; an unshared connection (one with an authorizer, say)
177
+ reconnects to whatever answers on its URL.
178
+ - **Scoped endpoints.** An app can hand OmOWright a limited browser (say, one
179
+ thread's tabs) behind a token: `connect(url, { client: { authorizer } })`
180
+ sends `Authorization` from `authorizer.resolveAuthorization({ forceRefresh })`
181
+ and asks once more with `forceRefresh` after a 401. Keep the token out of the
182
+ URL. `OMOWRIGHT_PAGE_CDP_METHODS` lists every command the page API sends, so
183
+ such an endpoint can allow exactly those and refuse the rest. The list
184
+ includes `DOM.setFileInputFiles`, which puts a local file into a page's file
185
+ input; the page then reads it, so a thread endpoint should only hand it paths
186
+ the user chose. `createEvents()` needs a full endpoint (it sends
187
+ `Browser.setDownloadBehavior`).
188
+ - **Agent signals.** `createEvents()` pushes `tabOpened`, `popupOpened`,
189
+ `downloadStarted` / `downloadFinished` and friends, so agents stop polling.
190
+ `createAgentTabs()` opens every tab in its own background window, so it never
191
+ steals focus. Headed rendering and screenshots are verified on Linux and macOS.
192
+ - **Frames and overlays.** OOPIF-aware snapshots, `describeLayers()` for the
193
+ dialog or toast that swallowed your click, and a dialog policy for
194
+ `alert` / `confirm` / `prompt`.
195
+ - **Flight recorder.** `createTrace()` writes a jsonl timeline, HAR and step
196
+ screenshots, so a failed run is a directory to read.
197
+ - **Routes and emulation.** `createRoutes()` (Fetch domain) to fulfil or abort
198
+ requests, `emulate()` with device presets.
199
+ - **Human handoff.** `requestHuman()` for login, OTP and consent screens.
200
+ - **Real-profile reads.** `createChromeApi()` exposes MV3-shaped tabs, windows,
201
+ bookmarks, history, downloads and topSites over CDP and profile files; the
202
+ bridge extension in `bridge/extension/` covers what CDP cannot see.
203
+ - **CAPTCHA helpers.** `createCaptcha()` clicks checkboxes, drags sliders and
204
+ OCRs text regions (macOS Vision built in, any `ocr(buffer)` pluggable).
205
+ - **Stealth profiles.** `connectCloakProfile()` pins a CloakBrowser fingerprint
206
+ seed to a persistent profile and refuses to change identity silently.
207
+ - **The user's own browser.** `connectBrowserSkill()` drives the browser the
208
+ user is already signed into through [BrowserSkill](https://github.com/Tencent/BrowserSkill)
209
+ (stock daemon and Web Store extension, spoken to over its IPC socket — no
210
+ process per call). `bskSnapshot()` returns the same `{ tree, refs }` shape
211
+ without leaving a global or a DOM attribute behind, and `bskOnboard()`
212
+ installs the CLI, starts the daemon and registers the extension in the browser
213
+ the user actually uses (default browser, running process, recent use; it asks
214
+ when those disagree) so the only thing left for the user is one **Enable** click.
215
+
216
+ ## Install
217
+
218
+ ```bash
219
+ npm i omowright
220
+ # or
221
+ bun add omowright
222
+ ```
223
+
224
+ To track unreleased changes, install from GitHub instead:
225
+
226
+ ```bash
227
+ bun add github:code-yeongyu/omowright
228
+ ```
229
+
230
+ Bun >= 1.4 is recommended; Node >= 22 is supported. Runtime dependencies are
231
+ `ws` and `zod`. OmOWright never downloads a browser: point it at any Chromium,
232
+ Chrome, a Chromium headless shell, or CloakBrowser.
233
+
234
+ ## Agent skill
235
+
236
+ `skills/omowright/` is a self-contained agent skill (`SKILL.md` plus
237
+ references) that routes a model through the library: the snapshot/ref loop,
238
+ the obstacle ladder (refs, overlays, coordinates, viewport pin, CAPTCHA,
239
+ browser log), stealth profiles, eval-kernel usage, frames and human handoff,
240
+ the attached BrowserSkill engine, and reading a 1Password web-vault item
241
+ safely. Task presets live in `presets/`:
242
+
243
+ | Preset | Covers |
244
+ | --- | --- |
245
+ | `presets/network` | Snoop JSON APIs, wait for requests, **collect while scrolling**, traces, routes |
246
+ | `presets/visual-browse` | Coordinate UI, **CUA scroll**, viewport pinning, extension popups |
247
+ | `presets/captcha` | Checkbox, slider, OCR and image-grid challenges |
248
+ | `presets/chrome` | Tabs, windows, bookmarks, history, downloads, topSites |
249
+ | `presets/agent-events` | Tab, popup and download push events |
250
+ | `presets/cloak-bridge` | The MV3 bridge extension and native-messaging host |
251
+
252
+ Install the skill by copying or symlinking `skills/omowright` (in an npm
253
+ install, `node_modules/omowright/skills/omowright`) into your harness's
254
+ skills directory (for example `~/.agents/skills/omowright`). The
255
+ agent-facing tool reference is [`TOOLS.md`](TOOLS.md); machine-readable schemas
256
+ ship as the `toolSchemas` export.
257
+
258
+ ## Persistent CloakBrowser profiles
259
+
260
+ For long-lived authenticated work, use `connectCloakProfile()` or the bundled
261
+ `omowright-cloak` launcher. The first run stores a random fingerprint seed in
262
+ `.omowright-cloak.json` (mode `0600`) inside the private profile (mode `0700`;
263
+ on Windows, a protected ACL that grants only the current user, plus SYSTEM and
264
+ Administrators, Windows' root equivalents, where Windows put them);
265
+ later runs reuse it and reject a conflicting seed. Never copy Google or
266
+ 1Password cookies between profiles. Full lifecycle:
267
+ [`docs/cloakbrowser-persistent-profile.md`](docs/cloakbrowser-persistent-profile.md).
268
+
269
+ ## Development
270
+
271
+ ```bash
272
+ bun install
273
+ bun run test # Bun runner
274
+ bun run test:node # Node test runner, same files
275
+ ```
276
+
277
+ Live tests need a Chromium headless shell. Set `SHELL_BIN` (and
278
+ `CLOAKBROWSER_BIN` for the event-bridge test) to its path, or install one into
279
+ Playwright's cache. CI installs `chrome-headless-shell` with
280
+ `@puppeteer/browsers` and runs both runners on Ubuntu. `test/hygiene.test.mjs`
281
+ fails the build if a tracked file contains an absolute home path, a personal
282
+ address or a private host.
283
+
284
+ ## Credits
285
+
286
+ The design follows [Jun's article](https://x.com/hyojun_at/article/2070234507995910413)
287
+ on the harness behind [Aside](https://aside.com). Go read it; then go try Aside.
288
+
289
+ ## License
290
+
291
+ [MIT](LICENSE). Copyright (c) 2026 Yeongyu Kim.