omowright 0.0.0 → 0.1.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 (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +282 -2
  3. package/TOOLS.md +366 -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 +84 -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 +186 -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 +96 -0
  18. package/skills/omowright/references/stealth.md +174 -0
  19. package/src/agent-tabs.js +160 -0
  20. package/src/bridge-schemas.js +44 -0
  21. package/src/bridge-transport.js +57 -0
  22. package/src/browser-process.js +122 -0
  23. package/src/bsk/browser-signals.js +90 -0
  24. package/src/bsk/browsers.js +114 -0
  25. package/src/bsk/connect.js +45 -0
  26. package/src/bsk/daemon-info.js +100 -0
  27. package/src/bsk/external-extension.js +110 -0
  28. package/src/bsk/identify-browser.js +88 -0
  29. package/src/bsk/install-cli.js +81 -0
  30. package/src/bsk/ipc-client.js +236 -0
  31. package/src/bsk/onboard.js +133 -0
  32. package/src/bsk/screenshot.js +49 -0
  33. package/src/bsk/session.js +131 -0
  34. package/src/bsk/snapshot.js +56 -0
  35. package/src/bsk/targets.js +25 -0
  36. package/src/captcha-wait.js +74 -0
  37. package/src/captcha.js +142 -0
  38. package/src/cdp-errors.js +23 -0
  39. package/src/cdp-methods.js +61 -0
  40. package/src/chrome-profile.js +176 -0
  41. package/src/chrome.js +192 -0
  42. package/src/cloak-profile.js +266 -0
  43. package/src/connection.js +135 -0
  44. package/src/cookies.js +29 -0
  45. package/src/core.js +1710 -0
  46. package/src/cua.js +74 -0
  47. package/src/dialog-policy.js +80 -0
  48. package/src/emulate.js +127 -0
  49. package/src/events.js +111 -0
  50. package/src/frames-snapshot.js +138 -0
  51. package/src/har.js +103 -0
  52. package/src/human-handoff.js +122 -0
  53. package/src/index.js +86 -0
  54. package/src/injected.js +3 -0
  55. package/src/instance-lock.js +230 -0
  56. package/src/instances.js +493 -0
  57. package/src/internal-capability.js +1 -0
  58. package/src/launch-endpoint.js +185 -0
  59. package/src/layers.js +138 -0
  60. package/src/llm.js +201 -0
  61. package/src/lock-file.js +130 -0
  62. package/src/native-host-win32.js +201 -0
  63. package/src/network-events.js +201 -0
  64. package/src/network-snoop.js +229 -0
  65. package/src/open-shadow-query.js +22 -0
  66. package/src/owner-only.js +109 -0
  67. package/src/page-bundle.js +1397 -0
  68. package/src/page-routes.js +94 -0
  69. package/src/pipe.js +391 -0
  70. package/src/routes.js +256 -0
  71. package/src/running-browser.js +85 -0
  72. package/src/scroll-collect.js +73 -0
  73. package/src/serial-emitter.js +17 -0
  74. package/src/shared-connections.js +278 -0
  75. package/src/snapshot-diff.js +75 -0
  76. package/src/trace.js +183 -0
  77. package/src/url-match.js +148 -0
  78. 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,283 @@
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.
154
+ - **Shared attaches.** Chrome asks the user to allow remote debugging once per
155
+ connection to their own profile, so `connect(url)` and `connectNamed`
156
+ attaches in one process share one CDP connection per browser (keyed by its
157
+ GUID). Each call returns a handle on it: `close()` RELEASES that handle, and
158
+ only the last release disconnects. Pages attached through one handle are the
159
+ same pages for every handle and stay attached until the last release. A
160
+ handle never changes what another holder gets: on a shared connection
161
+ `setDialogPolicy` throws `SharedConnectionError` (pass `dialogPolicy` when
162
+ attaching to get a connection of your own), a sole holder's
163
+ `setDialogPolicy` works and that connection is never shared again, and
164
+ properties, client writes and listeners stay with the handle. A connection
165
+ is never shared when an `authorizer` (or any non-plain client option) is
166
+ set, nor between callers whose options differ (`dialogPolicy` included). A
167
+ shared handle's reconnect never reaches a browser other than the one it
168
+ was opened for; an unshared connection (one with an authorizer, say)
169
+ reconnects to whatever answers on its URL.
170
+ - **Scoped endpoints.** An app can hand OmOWright a limited browser (say, one
171
+ thread's tabs) behind a token: `connect(url, { client: { authorizer } })`
172
+ sends `Authorization` from `authorizer.resolveAuthorization({ forceRefresh })`
173
+ and asks once more with `forceRefresh` after a 401. Keep the token out of the
174
+ URL. `OMOWRIGHT_PAGE_CDP_METHODS` lists every command the page API sends, so
175
+ such an endpoint can allow exactly those and refuse the rest. The list
176
+ includes `DOM.setFileInputFiles`, which puts a local file into a page's file
177
+ input; the page then reads it, so a thread endpoint should only hand it paths
178
+ the user chose. `createEvents()` needs a full endpoint (it sends
179
+ `Browser.setDownloadBehavior`).
180
+ - **Agent signals.** `createEvents()` pushes `tabOpened`, `popupOpened`,
181
+ `downloadStarted` / `downloadFinished` and friends, so agents stop polling.
182
+ `createAgentTabs()` opens every tab in its own background window, so it never
183
+ steals focus. Headed rendering and screenshots are verified on Linux and macOS.
184
+ - **Frames and overlays.** OOPIF-aware snapshots, `describeLayers()` for the
185
+ dialog or toast that swallowed your click, and a dialog policy for
186
+ `alert` / `confirm` / `prompt`.
187
+ - **Flight recorder.** `createTrace()` writes a jsonl timeline, HAR and step
188
+ screenshots, so a failed run is a directory to read.
189
+ - **Routes and emulation.** `createRoutes()` (Fetch domain) to fulfil or abort
190
+ requests, `emulate()` with device presets.
191
+ - **Human handoff.** `requestHuman()` for login, OTP and consent screens.
192
+ - **Real-profile reads.** `createChromeApi()` exposes MV3-shaped tabs, windows,
193
+ bookmarks, history, downloads and topSites over CDP and profile files; the
194
+ bridge extension in `bridge/extension/` covers what CDP cannot see.
195
+ - **CAPTCHA helpers.** `createCaptcha()` clicks checkboxes, drags sliders and
196
+ OCRs text regions (macOS Vision built in, any `ocr(buffer)` pluggable).
197
+ - **Stealth profiles.** `connectCloakProfile()` pins a CloakBrowser fingerprint
198
+ seed to a persistent profile and refuses to change identity silently.
199
+ - **The user's own browser.** `connectBrowserSkill()` drives the browser the
200
+ user is already signed into through [BrowserSkill](https://github.com/Tencent/BrowserSkill)
201
+ (stock daemon and Web Store extension, spoken to over its IPC socket — no
202
+ process per call). `bskSnapshot()` returns the same `{ tree, refs }` shape
203
+ without leaving a global or a DOM attribute behind, and `bskOnboard()`
204
+ installs the CLI, starts the daemon and registers the extension in the browser
205
+ the user actually uses (default browser, running process, recent use; it asks
206
+ when those disagree) so the only thing left for the user is one **Enable** click.
207
+
208
+ ## Install
209
+
210
+ ```bash
211
+ npm i omowright
212
+ # or
213
+ bun add omowright
214
+ ```
215
+
216
+ To track unreleased changes, install from GitHub instead:
217
+
218
+ ```bash
219
+ bun add github:code-yeongyu/omowright
220
+ ```
221
+
222
+ Bun >= 1.4 is recommended; Node >= 22 is supported. Runtime dependencies are
223
+ `ws` and `zod`. OmOWright never downloads a browser: point it at any Chromium,
224
+ Chrome, a Chromium headless shell, or CloakBrowser.
225
+
226
+ ## Agent skill
227
+
228
+ `skills/omowright/` is a self-contained agent skill (`SKILL.md` plus
229
+ references) that routes a model through the library: the snapshot/ref loop,
230
+ the obstacle ladder (refs, overlays, coordinates, viewport pin, CAPTCHA,
231
+ browser log), stealth profiles, eval-kernel usage, frames and human handoff,
232
+ the attached BrowserSkill engine, and reading a 1Password web-vault item
233
+ safely. Task presets live in `presets/`:
234
+
235
+ | Preset | Covers |
236
+ | --- | --- |
237
+ | `presets/network` | Snoop JSON APIs, wait for requests, **collect while scrolling**, traces, routes |
238
+ | `presets/visual-browse` | Coordinate UI, **CUA scroll**, viewport pinning, extension popups |
239
+ | `presets/captcha` | Checkbox, slider, OCR and image-grid challenges |
240
+ | `presets/chrome` | Tabs, windows, bookmarks, history, downloads, topSites |
241
+ | `presets/agent-events` | Tab, popup and download push events |
242
+ | `presets/cloak-bridge` | The MV3 bridge extension and native-messaging host |
243
+
244
+ Install the skill by copying or symlinking `skills/omowright` (in an npm
245
+ install, `node_modules/omowright/skills/omowright`) into your harness's
246
+ skills directory (for example `~/.agents/skills/omowright`). The
247
+ agent-facing tool reference is [`TOOLS.md`](TOOLS.md); machine-readable schemas
248
+ ship as the `toolSchemas` export.
249
+
250
+ ## Persistent CloakBrowser profiles
251
+
252
+ For long-lived authenticated work, use `connectCloakProfile()` or the bundled
253
+ `omowright-cloak` launcher. The first run stores a random fingerprint seed in
254
+ `.omowright-cloak.json` (mode `0600`) inside the private profile (mode `0700`;
255
+ on Windows, a protected ACL that grants only the current user, plus SYSTEM and
256
+ Administrators, Windows' root equivalents, where Windows put them);
257
+ later runs reuse it and reject a conflicting seed. Never copy Google or
258
+ 1Password cookies between profiles. Full lifecycle:
259
+ [`docs/cloakbrowser-persistent-profile.md`](docs/cloakbrowser-persistent-profile.md).
260
+
261
+ ## Development
262
+
263
+ ```bash
264
+ bun install
265
+ bun run test # Bun runner
266
+ bun run test:node # Node test runner, same files
267
+ ```
268
+
269
+ Live tests need a Chromium headless shell. Set `SHELL_BIN` (and
270
+ `CLOAKBROWSER_BIN` for the event-bridge test) to its path, or install one into
271
+ Playwright's cache. CI installs `chrome-headless-shell` with
272
+ `@puppeteer/browsers` and runs both runners on Ubuntu. `test/hygiene.test.mjs`
273
+ fails the build if a tracked file contains an absolute home path, a personal
274
+ address or a private host.
275
+
276
+ ## Credits
277
+
278
+ The design follows [Jun's article](https://x.com/hyojun_at/article/2070234507995910413)
279
+ on the harness behind [Aside](https://aside.com). Go read it; then go try Aside.
280
+
281
+ ## License
282
+
283
+ [MIT](LICENSE). Copyright (c) 2026 Yeongyu Kim.