omowright 0.2.0 → 0.3.1

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 (174) hide show
  1. package/README.md +43 -29
  2. package/TOOLS.md +9 -8
  3. package/dist/agent-tabs.d.ts +56 -0
  4. package/dist/aria-hidden.d.ts +1 -0
  5. package/dist/aside/cli-binary.d.ts +7 -0
  6. package/dist/aside/cli-contract.d.ts +9 -0
  7. package/dist/aside/errors.d.ts +8 -0
  8. package/dist/aside/line-transport.d.ts +11 -0
  9. package/dist/aside/mcp-transport.d.ts +11 -0
  10. package/dist/aside/onboard.d.ts +76 -0
  11. package/dist/aside/session-types.d.ts +68 -0
  12. package/dist/aside/session.d.ts +20 -0
  13. package/{bin/omowright-cloak.mjs → dist/bin/omowright-cloak.js} +28 -31
  14. package/dist/bridge-schemas.d.ts +326 -0
  15. package/dist/bridge-transport.d.ts +144 -0
  16. package/dist/browser-context.d.ts +4024 -0
  17. package/dist/browser-process.d.ts +10 -0
  18. package/dist/bsk/browser-signals.d.ts +23 -0
  19. package/dist/bsk/browsers.d.ts +46 -0
  20. package/dist/bsk/connect.d.ts +23 -0
  21. package/dist/bsk/daemon-info.d.ts +16 -0
  22. package/dist/bsk/external-extension.d.ts +74 -0
  23. package/dist/bsk/identify-browser.d.ts +48 -0
  24. package/dist/bsk/install-cli.d.ts +37 -0
  25. package/dist/bsk/ipc-client.d.ts +45 -0
  26. package/dist/bsk/onboard.d.ts +96 -0
  27. package/dist/bsk/reply-fields.d.ts +3 -0
  28. package/dist/bsk/screenshot.d.ts +24 -0
  29. package/dist/bsk/session.d.ts +142 -0
  30. package/dist/bsk/snapshot.d.ts +16 -0
  31. package/dist/bsk/targets.d.ts +20 -0
  32. package/dist/captcha-wait.d.ts +17 -0
  33. package/dist/captcha.d.ts +46 -0
  34. package/dist/cdp-errors.d.ts +38 -0
  35. package/dist/cdp-methods.d.ts +10 -0
  36. package/dist/cdp-protocol.d.ts +459 -0
  37. package/dist/chrome-profile.d.ts +77 -0
  38. package/dist/chrome.d.ts +130 -0
  39. package/dist/cloak-profile.d.ts +43 -0
  40. package/dist/connection.d.ts +4024 -0
  41. package/dist/console-events.d.ts +22 -0
  42. package/dist/cookies.d.ts +42 -0
  43. package/dist/core.d.ts +10810 -0
  44. package/dist/cua.d.ts +56 -0
  45. package/dist/dialog-policy.d.ts +43 -0
  46. package/dist/ego/bindings.d.ts +68 -0
  47. package/dist/ego/cdp-client.d.ts +28 -0
  48. package/dist/ego/client.d.ts +8 -0
  49. package/dist/ego/errors.d.ts +7 -0
  50. package/dist/emulate.d.ts +62 -0
  51. package/dist/engines.d.ts +59 -0
  52. package/dist/events.d.ts +93 -0
  53. package/dist/frames-snapshot.d.ts +58 -0
  54. package/dist/har.d.ts +88 -0
  55. package/dist/human-handoff.d.ts +30 -0
  56. package/{src/index.js → dist/index.d.ts} +12 -55
  57. package/dist/index.js +39478 -0
  58. package/dist/injected.d.ts +1 -0
  59. package/dist/instance-lock.d.ts +5 -0
  60. package/dist/instances.d.ts +45 -0
  61. package/dist/internal-capability.d.ts +1 -0
  62. package/dist/launch-endpoint.d.ts +34 -0
  63. package/dist/layers.d.ts +31 -0
  64. package/dist/llm.d.ts +1349 -0
  65. package/dist/lock-backend-win32-xbcm60vz.js +57 -0
  66. package/dist/lock-backend-win32.d.ts +3 -0
  67. package/dist/lock-backend.d.ts +6 -0
  68. package/dist/native-host-win32.d.ts +38 -0
  69. package/dist/network-events.d.ts +66 -0
  70. package/dist/network-snoop.d.ts +56 -0
  71. package/dist/nul-frames.d.ts +4 -0
  72. package/dist/open-shadow-query.d.ts +1 -0
  73. package/dist/owner-only.d.ts +15 -0
  74. package/dist/page-bundle.js +1597 -0
  75. package/dist/page-events.d.ts +25 -0
  76. package/dist/page-routes.d.ts +30 -0
  77. package/dist/page-setup.d.ts +55 -0
  78. package/dist/pipe.d.ts +71 -0
  79. package/dist/process-start-time.d.ts +2 -0
  80. package/dist/read-property.d.ts +2 -0
  81. package/dist/routes.d.ts +60 -0
  82. package/dist/running-browser.d.ts +39 -0
  83. package/dist/scroll-collect.d.ts +36 -0
  84. package/dist/serial-emitter.d.ts +5 -0
  85. package/dist/shared-connections.d.ts +11 -0
  86. package/dist/snapshot-diff.d.ts +57 -0
  87. package/dist/text-matching.d.ts +21 -0
  88. package/dist/trace.d.ts +59 -0
  89. package/dist/url-match.d.ts +7 -0
  90. package/dist/viewport.d.ts +26 -0
  91. package/dist/ws.d.ts +62 -0
  92. package/package.json +47 -26
  93. package/presets/agent-events/SKILL.md +1 -1
  94. package/presets/captcha/SKILL.md +1 -3
  95. package/presets/chrome/SKILL.md +2 -2
  96. package/presets/cloak-bridge/SKILL.md +11 -11
  97. package/presets/network/SKILL.md +15 -13
  98. package/presets/visual-browse/SKILL.md +14 -10
  99. package/skills/omowright/SKILL.md +83 -49
  100. package/skills/omowright/references/aside.md +50 -0
  101. package/skills/omowright/references/browserskill.md +29 -32
  102. package/skills/omowright/references/ego.md +24 -0
  103. package/skills/omowright/references/eval-kernel.md +44 -23
  104. package/skills/omowright/references/frames-layers-human.md +16 -7
  105. package/skills/omowright/references/quickstart.md +7 -4
  106. package/skills/omowright/references/stealth.md +11 -8
  107. package/src/agent-tabs.js +0 -179
  108. package/src/aria-hidden.js +0 -47
  109. package/src/bridge-schemas.js +0 -44
  110. package/src/bridge-transport.js +0 -83
  111. package/src/browser-context.js +0 -105
  112. package/src/browser-process.js +0 -127
  113. package/src/bsk/browser-signals.js +0 -90
  114. package/src/bsk/browsers.js +0 -114
  115. package/src/bsk/connect.js +0 -75
  116. package/src/bsk/daemon-info.js +0 -100
  117. package/src/bsk/external-extension.js +0 -110
  118. package/src/bsk/identify-browser.js +0 -88
  119. package/src/bsk/install-cli.js +0 -81
  120. package/src/bsk/ipc-client.js +0 -236
  121. package/src/bsk/onboard.js +0 -140
  122. package/src/bsk/screenshot.js +0 -49
  123. package/src/bsk/session.js +0 -131
  124. package/src/bsk/snapshot.js +0 -56
  125. package/src/bsk/targets.js +0 -25
  126. package/src/captcha-wait.js +0 -79
  127. package/src/captcha.js +0 -142
  128. package/src/cdp-errors.js +0 -23
  129. package/src/cdp-methods.js +0 -69
  130. package/src/chrome-profile.js +0 -176
  131. package/src/chrome.js +0 -194
  132. package/src/cloak-profile.js +0 -266
  133. package/src/connection.js +0 -234
  134. package/src/console-events.js +0 -12
  135. package/src/cookies.js +0 -39
  136. package/src/core.js +0 -1702
  137. package/src/cua.js +0 -74
  138. package/src/dialog-policy.js +0 -80
  139. package/src/emulate.js +0 -127
  140. package/src/events.js +0 -111
  141. package/src/frames-snapshot.js +0 -138
  142. package/src/har.js +0 -103
  143. package/src/human-handoff.js +0 -124
  144. package/src/injected.js +0 -3
  145. package/src/instance-lock.js +0 -74
  146. package/src/instances.js +0 -490
  147. package/src/internal-capability.js +0 -1
  148. package/src/launch-endpoint.js +0 -185
  149. package/src/layers.js +0 -138
  150. package/src/llm.js +0 -201
  151. package/src/lock-backend-win32.js +0 -54
  152. package/src/lock-backend.js +0 -81
  153. package/src/native-host-win32.js +0 -201
  154. package/src/network-events.js +0 -223
  155. package/src/network-snoop.js +0 -229
  156. package/src/nul-frames.js +0 -28
  157. package/src/open-shadow-query.js +0 -101
  158. package/src/owner-only.js +0 -196
  159. package/src/page-bundle.js +0 -1478
  160. package/src/page-events.js +0 -45
  161. package/src/page-routes.js +0 -94
  162. package/src/page-setup.js +0 -239
  163. package/src/pipe.js +0 -418
  164. package/src/process-start-time.js +0 -64
  165. package/src/routes.js +0 -256
  166. package/src/running-browser.js +0 -85
  167. package/src/scroll-collect.js +0 -73
  168. package/src/serial-emitter.js +0 -17
  169. package/src/shared-connections.js +0 -285
  170. package/src/snapshot-diff.js +0 -75
  171. package/src/text-matching.js +0 -101
  172. package/src/trace.js +0 -183
  173. package/src/url-match.js +0 -148
  174. package/src/viewport.js +0 -12
package/README.md CHANGED
@@ -25,7 +25,9 @@ Jun's argument is the whole design:
25
25
  new vocabulary to teach in the prompt.
26
26
  2. **Protect the context window.** Raw DOM and raw CDP are noise. The primary
27
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.
28
+ the duplicated refs map. How much that saves depends on the page: on
29
+ 2026-11-09 it cut 7% of the bytes on example.com, 56% on a form page and
30
+ 64% on Hacker News.
29
31
  3. **CDP underneath, never on top.** Every method is a thin wrapper over CDP
30
32
  calls. The model writes Playwright; the library speaks the protocol.
31
33
  4. **Fall back to pixels.** When the DOM lies (canvas, custom widgets,
@@ -39,17 +41,29 @@ const browser = await connectPipe({ browserPath: "/path/to/chromium", browserArg
39
41
  const page = await browser.newTab("https://example.com");
40
42
 
41
43
  console.log(compactSnapshot(await page.snapshot()));
42
- // - heading "Example Domain" [level=1]
44
+ // Live pages change, so the exact tree drifts; on 2026-11-09 it read:
43
45
  // - text: "This domain is for use in documentation examples ..."
44
- // - paragraph:
45
- // - link "Learn more" [ref=e1]
46
+ // - link "Learn more" [ref=e1]
46
47
 
47
- await page.locator("e1").click(); // refs come straight from the snapshot
48
+ await page.locator("e1").click(); // refs come straight from the snapshot
48
49
  await browser.close();
49
50
  ```
50
51
 
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.
52
+ On Windows, write `browserPath` with forward slashes (`"C:/Program Files/..."`)
53
+ or as `` String.raw`C:\Program Files\...` ``. In a plain string literal each
54
+ backslash starts an escape: the launch usually fails with ENOENT, and a segment
55
+ such as `\u` or `\x` is a SyntaxError before anything runs. Give every
56
+ browser that runs at the same time its own profile through
57
+ ``browserArgs: ["--headless", `--user-data-dir=${dir}`]`` (for example a
58
+ `mkdtemp` directory). On Windows, Chrome otherwise falls back to a shared
59
+ default profile, and a second launch on it exits with code 21.
60
+
61
+ Every `page.snapshot()` returns the whole tree. Pass `{ diff: true }` to get
62
+ only what changed since the previous snapshot; it falls back to the full tree
63
+ with a `reason` when there is no usable baseline or the diff would be larger.
64
+ To look for one thing,
65
+ `page.snapshot({ find: "Checkout" })` returns only the matching lines, with
66
+ their refs and a little context around each.
53
67
 
54
68
  ## Snapshot size
55
69
 
@@ -60,13 +74,13 @@ and `compactSnapshot(await page.snapshot({ interactive: true }))`. Measured on
60
74
  2026-11-05 (UTC) at commit `4845ef5` with Chrome for Testing 156.0.8078.4
61
75
  (headless shell) on Linux.
62
76
 
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% |
77
+ | Page | Shape | Raw HTML | Snapshot | Interactive snapshot | Snapshot / HTML | Interactive / HTML |
78
+ | ------------------------------------ | ------------ | -------: | -------: | -------------------: | --------------: | -----------------: |
79
+ | news.ycombinator.com | link-heavy | 11,615 | 4,220 | 3,811 | 36.3% | 32.8% |
80
+ | en.wikipedia.org/wiki/Web_browser | long article | 143,312 | 14,155 | 12,591 | 9.9% | 8.8% |
81
+ | github.com/code-yeongyu/omowright \* | app-like | 116,378 | 5,432 | 5,481 | 4.7% | 4.7% |
82
+ | example.com | trivial | 637 | 222 | 222 | 34.9% | 34.9% |
83
+ | httpbin.org/forms/post | form | 428 | 370 | 245 | 86.4% | 57.2% |
70
84
 
71
85
  \* The interactive snapshot is read after the full one, and here it came out
72
86
  larger, so the page likely changed between the two reads: `page.goto()` can
@@ -82,7 +96,7 @@ Reproduce after `bun install` (any Chromium works for `--browser`, or set
82
96
  `OMOWRIGHT_BENCH_BROWSER`):
83
97
 
84
98
  ```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
99
+ bun scripts/bench-snapshot-tokens.ts --browser ~/.cache/ms-playwright/chromium_headless_shell-1248/chrome-headless-shell-linux64/chrome-headless-shell --browser-arg=--no-sandbox
86
100
  ```
87
101
 
88
102
  ## Scrolling is a first-class problem
@@ -103,15 +117,15 @@ await page.goto("https://example.com/feed");
103
117
 
104
118
  const items = [];
105
119
  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
120
+ minItems: 200, // stop once this many items are in hand
121
+ maxScrolls: 15, // or after this many scroll rounds
108
122
  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
123
+ scroll: "wheel", // "end" jumps to the bottom instead
124
+ settleMs: 800, // wait for the next page to land
111
125
  });
112
126
  let step;
113
127
  while (!(step = await run.next()).done) items.push(step.value);
114
- step.value; // { rounds, total, stoppedBecause: "minItems" | "maxScrolls" | "noGrowth" }
128
+ step.value; // { rounds, total, stoppedBecause: "minItems" | "maxScrolls" | "noGrowth" }
115
129
  ```
116
130
 
117
131
  It drains first, scrolls second, and stops on its own when the document stops
@@ -240,14 +254,14 @@ browser log), stealth profiles, eval-kernel usage, frames and human handoff,
240
254
  the attached BrowserSkill engine, and reading a 1Password web-vault item
241
255
  safely. Task presets live in `presets/`:
242
256
 
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 |
257
+ | Preset | Covers |
258
+ | ----------------------- | ------------------------------------------------------------------------------- |
259
+ | `presets/network` | Snoop JSON APIs, wait for requests, **collect while scrolling**, traces, routes |
260
+ | `presets/visual-browse` | Coordinate UI, **CUA scroll**, viewport pinning, extension popups |
261
+ | `presets/captcha` | Checkbox, slider, OCR and image-grid challenges |
262
+ | `presets/chrome` | Tabs, windows, bookmarks, history, downloads, topSites |
263
+ | `presets/agent-events` | Tab, popup and download push events |
264
+ | `presets/cloak-bridge` | The MV3 bridge extension and native-messaging host |
251
265
 
252
266
  Install the skill by copying or symlinking `skills/omowright` (in an npm
253
267
  install, `node_modules/omowright/skills/omowright`) into your harness's
@@ -277,7 +291,7 @@ bun run test:node # Node test runner, same files
277
291
  Live tests need a Chromium headless shell. Set `SHELL_BIN` (and
278
292
  `CLOAKBROWSER_BIN` for the event-bridge test) to its path, or install one into
279
293
  Playwright's cache. CI installs `chrome-headless-shell` with
280
- `@puppeteer/browsers` and runs both runners on Ubuntu. `test/hygiene.test.mjs`
294
+ `@puppeteer/browsers` and runs both runners on Ubuntu. `test/hygiene.test.ts`
281
295
  fails the build if a tracked file contains an absolute home path, a personal
282
296
  address or a private host.
283
297
 
package/TOOLS.md CHANGED
@@ -52,7 +52,8 @@ running Chromium DevTools endpoint).
52
52
  look like `- link "Learn more" [ref=e1]`. Options: `maxDepth` (50),
53
53
  `maxChars`, `interactive`, `showHidden`, `selector`, `ref`.
54
54
  - `compactSnapshot(snapshot)` — returns the raw tree without the refs map
55
- (refs resolve in-page; the map is ~54% of bytes on real pages). Use before
55
+ (refs resolve in-page; dropping the map saved 7% to 64% of the bytes across
56
+ pages measured on 2026-11-09). Use before
56
57
  sending snapshots to a model.
57
58
  - `page.locator(refOrCss)` — `click`, `fill`, `press`, `pressSequentially`,
58
59
  `hover`, `check`, `selectOption`, `dragTo`, `setInputFiles`, `textContent`,
@@ -218,7 +219,7 @@ running Chromium DevTools endpoint).
218
219
  `SameSite=None` dropped when not secure, name+domain deduped.
219
220
  `sanitizeCookies(cookies)` is the pure transform if you need it.
220
221
 
221
- Every tool below is exported from `src/index.js`, the same import as the core
222
+ Every tool below is exported from `src/index.ts`, the same import as the core
222
223
  loop; the module files next to it are implementation detail.
223
224
 
224
225
  - `connectNamed(name, { browserPath, browserArgs, profileDir, registryRoot?,
@@ -410,14 +411,14 @@ readiness is content-probe based).
410
411
  A policy is either an object or a function:
411
412
 
412
413
  ```js
413
- const browser = await connectPipe({ browserPath, browserArgs, storageRoot,
414
- dialogPolicy: { accept: false } }); // confirm() -> false, prompt() -> null
414
+ const browser = await connectPipe({ browserPath, browserArgs, storageRoot, dialogPolicy: { accept: false } }); // confirm() -> false, prompt() -> null
415
415
  browser.setDialogPolicy({ accept: true, promptText: "agent@example.com" }); // prompt() -> the text
416
- browser.setDialogPolicy(dialog => { // { type, message, defaultPrompt, url }
416
+ browser.setDialogPolicy((dialog) => {
417
+ // { type, message, defaultPrompt, url }
417
418
  if (dialog.type === "beforeunload") return true;
418
419
  return { accept: !/delete/i.test(dialog.message), promptText: dialog.defaultPrompt };
419
420
  });
420
- browser.cdp.dialogPolicy; // read the current policy (client getter)
421
+ browser.cdp.dialogPolicy; // read the current policy (client getter)
421
422
  ```
422
423
 
423
424
  - `{ accept: false }` dismisses: `confirm()` returns `false`, `prompt()` returns
@@ -437,13 +438,13 @@ browser.cdp.dialogPolicy; // read the current policy (cl
437
438
  `page.waitForEvent('dialog')`) leaves the dialog to the policy:
438
439
 
439
440
  ```js
440
- page.on("dialog", dialog =>
441
- dialog.type() === "prompt" ? dialog.accept("agent@example.com") : dialog.dismiss());
441
+ page.on("dialog", (dialog) => (dialog.type() === "prompt" ? dialog.accept("agent@example.com") : dialog.dismiss()));
442
442
  ```
443
443
 
444
444
  Answer inside the listener or in a promise it returns: the policy waits for
445
445
  that promise. A dialog is answered once: a second `accept()` / `dismiss()`,
446
446
  or one after the policy answered, rejects.
447
+
447
448
  - CDP listeners of `Page.javascriptDialogOpening` get the same `Dialog` as
448
449
  `meta.dialog`. On a shared connection the policy is the connection's and a
449
450
  listener belongs to the handle that added it: it answers until that handle
@@ -0,0 +1,56 @@
1
+ import type { ViewportSize } from "./viewport.js";
2
+ import type { BrowserConnection } from "./connection.js";
3
+ import type { OmOPage } from "./core.js";
4
+ type Page = InstanceType<typeof OmOPage>;
5
+ export interface AgentTabManagerOptions {
6
+ viewport?: Partial<ViewportSize> | undefined;
7
+ closeTimeoutMs?: number | undefined;
8
+ }
9
+ export interface CreateAgentTabOptions {
10
+ viewport?: Partial<ViewportSize> | undefined;
11
+ browserContextId?: string | undefined;
12
+ }
13
+ export interface AdoptAgentTabOptions {
14
+ viewport?: Partial<ViewportSize> | undefined;
15
+ }
16
+ export interface CloseAgentTabOptions {
17
+ timeoutMs?: number | undefined;
18
+ runBeforeUnload?: boolean | undefined;
19
+ }
20
+ export interface DisposeAgentTabsOptions extends CloseAgentTabOptions {
21
+ closeOwned?: boolean | undefined;
22
+ }
23
+ /** An owned tab whose page is attached. */
24
+ export interface AgentTab {
25
+ readonly targetId: string;
26
+ readonly page: Page;
27
+ readonly viewport: ViewportSize;
28
+ readonly close: (options?: CloseAgentTabOptions) => Promise<unknown>;
29
+ }
30
+ /** An owned tab view: its page is null while another adopt() is still attaching it. */
31
+ export interface AgentTabView extends Omit<AgentTab, "page"> {
32
+ readonly page: Page | null;
33
+ }
34
+ export declare class AgentTabManager {
35
+ #private;
36
+ viewport: Readonly<ViewportSize>;
37
+ closeTimeoutMs: number;
38
+ ready: Promise<unknown>;
39
+ readonly _optionsKey: string;
40
+ constructor(connection: BrowserConnection, options?: AgentTabManagerOptions);
41
+ create(url?: string, options?: CreateAgentTabOptions): Promise<AgentTab>;
42
+ adopt(targetId: string, options?: AdoptAgentTabOptions): Promise<AgentTabView>;
43
+ get(targetId: string | undefined): AgentTabView | null;
44
+ list(): AgentTabView[];
45
+ repin(tabOrTargetId: string | {
46
+ targetId: string;
47
+ } | null | undefined, viewport?: Readonly<ViewportSize>): Promise<ViewportSize>;
48
+ close(tabOrTargetId: string | {
49
+ targetId: string;
50
+ } | null | undefined, options?: CloseAgentTabOptions): Promise<unknown>;
51
+ closeAll(options?: CloseAgentTabOptions): Promise<void>;
52
+ dispose(options?: DisposeAgentTabsOptions): Promise<void>;
53
+ }
54
+ export declare function getAgentTabs(connection: BrowserConnection): AgentTabManager | undefined;
55
+ export declare function createAgentTabs(connection: BrowserConnection, options?: AgentTabManagerOptions): AgentTabManager;
56
+ export {};
@@ -0,0 +1 @@
1
+ export declare function isElementHiddenForAria(element: Element, cache: Map<Node, boolean>): boolean;
@@ -0,0 +1,7 @@
1
+ export type AsideCommand = readonly [bin?: string | null | undefined, ...lead: string[]];
2
+ export interface FindAsideBinaryOptions {
3
+ env?: NodeJS.ProcessEnv;
4
+ home?: string;
5
+ exists?: (file: string) => boolean;
6
+ }
7
+ export declare function findAsideBinary({ env, home, exists, }?: FindAsideBinaryOptions): string | null;
@@ -0,0 +1,9 @@
1
+ import type { AsideReplProtocol, AsideSpawn } from "./session-types.js";
2
+ export interface AsideCliProbeOptions {
3
+ spawn: AsideSpawn;
4
+ command: readonly [string, ...string[]];
5
+ env: NodeJS.ProcessEnv;
6
+ timeoutMs: number;
7
+ }
8
+ export declare function replTransportFor(options: AsideCliProbeOptions): Promise<AsideReplProtocol>;
9
+ export declare function asideCliVersion(options: AsideCliProbeOptions): Promise<string | null>;
@@ -0,0 +1,8 @@
1
+ import type { AsideOnboardReport } from "./onboard.js";
2
+ import type { AsideReplErrorOptions } from "./session-types.js";
3
+ export declare class AsideReplError extends Error {
4
+ code: string;
5
+ output: string[];
6
+ setup?: AsideOnboardReport;
7
+ constructor(code: string, message: string, { output, setup }?: AsideReplErrorOptions);
8
+ }
@@ -0,0 +1,11 @@
1
+ import type { AsideChildProcess, AsideTransportInfo } from "./session-types.js";
2
+ export declare class LineTransport {
3
+ #private;
4
+ constructor(child: AsideChildProcess);
5
+ ready(timeoutMs: number): Promise<AsideTransportInfo>;
6
+ call(line: string, { tag, timeoutMs }: {
7
+ tag: string;
8
+ timeoutMs: number;
9
+ }): Promise<string[]>;
10
+ close(): Promise<void>;
11
+ }
@@ -0,0 +1,11 @@
1
+ import type { AsideChildProcess, AsideTransportInfo } from "./session-types.js";
2
+ export declare class McpTransport {
3
+ #private;
4
+ constructor(child: AsideChildProcess);
5
+ ready(timeoutMs: number): Promise<AsideTransportInfo>;
6
+ call(code: string, { timeoutMs, timeoutCode }: {
7
+ timeoutMs: number;
8
+ timeoutCode?: string;
9
+ }): Promise<string[]>;
10
+ close(): Promise<void>;
11
+ }
@@ -0,0 +1,76 @@
1
+ import type { AsideCommand } from "./cli-binary.js";
2
+ export interface AsideRunResult {
3
+ code: number | null;
4
+ stdout: string;
5
+ stderr: string;
6
+ }
7
+ export type AsideCliRunner = (command: string, args: string[], env: Record<string, string | undefined>) => Promise<AsideRunResult>;
8
+ export interface AsideCliInstallCommand {
9
+ command: string;
10
+ args: string[];
11
+ env: Record<string, string | undefined>;
12
+ }
13
+ export interface InstallAsideCliOptions {
14
+ home?: string;
15
+ run?: AsideCliRunner;
16
+ }
17
+ export type InstallAsideCliResult = {
18
+ installed: boolean;
19
+ asideBin: string | null;
20
+ code: number | null;
21
+ stdout: string;
22
+ stderr: string;
23
+ restoredRcFiles: string[];
24
+ };
25
+ export type AsideCliInstallOutcome = {
26
+ installed: boolean;
27
+ asideBin?: string | null;
28
+ [key: string]: unknown;
29
+ };
30
+ export interface AsideCliReport {
31
+ installed: boolean;
32
+ bin: string | null;
33
+ version: string | null;
34
+ }
35
+ export interface AsideAuthReport {
36
+ signedIn: boolean;
37
+ account: string | null;
38
+ }
39
+ export interface AsideAppReport {
40
+ installed: boolean | null;
41
+ path: string | null;
42
+ version: string | null | undefined;
43
+ }
44
+ export interface AsideDoctorReport {
45
+ platform: string;
46
+ app: AsideAppReport;
47
+ cli: AsideCliReport;
48
+ auth: AsideAuthReport;
49
+ ready: boolean;
50
+ nextStep: string | null;
51
+ }
52
+ export interface AsideOnboardReport extends AsideDoctorReport {
53
+ install: AsideCliInstallOutcome | null;
54
+ }
55
+ export interface FindAsideAppOptions {
56
+ platform?: string;
57
+ home?: string;
58
+ exists?: (file: string) => boolean;
59
+ }
60
+ export interface AsideDoctorOptions extends FindAsideAppOptions {
61
+ env?: NodeJS.ProcessEnv;
62
+ asideCommand?: AsideCommand | undefined;
63
+ account?: string | undefined;
64
+ }
65
+ export interface AsideOnboardOptions extends AsideDoctorOptions {
66
+ installOnlyWithApp?: boolean;
67
+ installCli?: (options: {
68
+ home: string;
69
+ }) => Promise<AsideCliInstallOutcome>;
70
+ }
71
+ export declare function asideCliInstallCommand(): AsideCliInstallCommand;
72
+ export declare function installAsideCli({ home, run, }?: InstallAsideCliOptions): Promise<InstallAsideCliResult>;
73
+ export declare function findAsideApp({ platform, home, exists, }?: FindAsideAppOptions): AsideAppReport;
74
+ export declare function parseAccountStatus(output: string, account?: string): AsideAuthReport;
75
+ export declare function asideDoctor({ platform, home, env, exists, asideCommand, account, }?: AsideDoctorOptions): Promise<AsideDoctorReport>;
76
+ export declare function asideOnboard({ platform, home, env, exists, asideCommand, account, installOnlyWithApp, installCli, }?: AsideOnboardOptions): Promise<AsideOnboardReport>;
@@ -0,0 +1,68 @@
1
+ import type { SpawnOptions } from "node:child_process";
2
+ import type { AsideCommand } from "./cli-binary.js";
3
+ import type { AsideOnboardReport } from "./onboard.js";
4
+ export interface AsideReadable {
5
+ setEncoding(encoding: BufferEncoding): unknown;
6
+ on(event: "data", listener: (chunk: string) => void): unknown;
7
+ }
8
+ export interface AsideWritable {
9
+ write(data: string): unknown;
10
+ end(data?: string): unknown;
11
+ /** Present on a real child stream; a write that races the child's exit raises EPIPE here. */
12
+ on?(event: "error", listener: (error: NodeJS.ErrnoException) => void): unknown;
13
+ }
14
+ export interface AsideSpawnedProcess {
15
+ readonly stdin: AsideWritable | null;
16
+ readonly stdout: AsideReadable | null;
17
+ readonly stderr?: AsideReadable | null;
18
+ once(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): unknown;
19
+ once(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): unknown;
20
+ once(event: "spawn", listener: () => void): unknown;
21
+ once(event: "error", listener: (error: Error) => void): unknown;
22
+ kill(signal?: NodeJS.Signals): unknown;
23
+ }
24
+ export interface AsideChildProcess extends AsideSpawnedProcess {
25
+ readonly stdin: AsideWritable;
26
+ readonly stdout: AsideReadable;
27
+ }
28
+ export type AsideSpawn = (command: string, args: string[], options: SpawnOptions) => AsideSpawnedProcess;
29
+ export type AsideReplProtocol = "line" | "mcp";
30
+ export interface AsideTransportInfo {
31
+ account?: string;
32
+ sessionDir?: string;
33
+ version?: string;
34
+ }
35
+ export interface AsideReplErrorOptions {
36
+ output?: string[];
37
+ setup?: AsideOnboardReport;
38
+ }
39
+ export interface AsideSessionOptions {
40
+ callTimeoutMs?: number;
41
+ protocol?: AsideReplProtocol;
42
+ account?: string | null;
43
+ }
44
+ export interface AsideSnapshotOptions {
45
+ find?: string | RegExp;
46
+ context?: number;
47
+ interactive?: boolean;
48
+ showHidden?: boolean;
49
+ selector?: string;
50
+ ref?: string;
51
+ }
52
+ export interface ConnectAsideOptions {
53
+ account?: string;
54
+ host?: string;
55
+ asideCommand?: AsideCommand;
56
+ autoSetup?: boolean;
57
+ env?: NodeJS.ProcessEnv;
58
+ home?: string;
59
+ startTimeoutMs?: number;
60
+ callTimeoutMs?: number;
61
+ spawn?: AsideSpawn;
62
+ }
63
+ export interface Waiter {
64
+ isDone: (pending: string, lines: string[]) => boolean;
65
+ resolve: (lines: string[]) => void;
66
+ reject: (error: unknown) => void;
67
+ timer: ReturnType<typeof setTimeout>;
68
+ }
@@ -0,0 +1,20 @@
1
+ import type { AsideChildProcess, AsideSessionOptions, AsideSnapshotOptions, ConnectAsideOptions } from "./session-types.js";
2
+ export { AsideReplError } from "./errors.js";
3
+ export { findAsideBinary } from "./cli-binary.js";
4
+ export declare class AsideSession {
5
+ #private;
6
+ engine: "aside";
7
+ account: string | null;
8
+ sessionDir: string | null;
9
+ constructor(child: AsideChildProcess, { callTimeoutMs, protocol, account }?: AsideSessionOptions);
10
+ ready(timeoutMs?: number): Promise<this>;
11
+ run(code: string): Promise<unknown>;
12
+ runWithLogs(code: string): Promise<{
13
+ value: unknown;
14
+ logs: string[];
15
+ }>;
16
+ open(url: string): Promise<unknown>;
17
+ snapshot({ find, context, interactive, showHidden, selector, ref }?: AsideSnapshotOptions): Promise<unknown>;
18
+ close(): Promise<void>;
19
+ }
20
+ export declare function connectAside({ account, host, asideCommand, autoSetup, env, home, startTimeoutMs, callTimeoutMs, spawn, }?: ConnectAsideOptions): Promise<AsideSession>;
@@ -1,13 +1,7 @@
1
1
  #!/usr/bin/env node
2
-
3
- import {
4
- compactSnapshot,
5
- connectCloakProfile,
6
- resolveCloakProfile,
7
- } from "../src/index.js";
2
+ import { compactSnapshot, connectCloakProfile, resolveCloakProfile } from "../index.js";
8
3
  import os from "node:os";
9
4
  import path from "node:path";
10
-
11
5
  const HELP = `Usage: omowright-cloak [options]
12
6
 
13
7
  Launch CloakBrowser through OmOWright with a stable persistent profile.
@@ -30,12 +24,22 @@ Environment:
30
24
  CLOAK_FINGERPRINT_SEED First-use seed override
31
25
  CLOAKBROWSER_BIN CloakBrowser binary path override
32
26
  `;
33
-
27
+ const VALUE_OPTIONS = {
28
+ "--profile": "profile",
29
+ "--seed": "seed",
30
+ "--browser": "browser",
31
+ "--name": "name",
32
+ "--url": "url"
33
+ };
34
+ function isValueOption(arg) {
35
+ return arg !== undefined && Object.hasOwn(VALUE_OPTIONS, arg);
36
+ }
34
37
  function parseArgs(argv) {
35
38
  const options = { url: "about:blank", once: false, snapshot: false };
36
- for (let index = 0; index < argv.length; index += 1) {
39
+ for (let index = 0;index < argv.length; index += 1) {
37
40
  const arg = argv[index];
38
- if (arg === "--help") return { help: true };
41
+ if (arg === "--help")
42
+ return { help: true };
39
43
  if (arg === "--once") {
40
44
  options.once = true;
41
45
  continue;
@@ -44,50 +48,44 @@ function parseArgs(argv) {
44
48
  options.snapshot = true;
45
49
  continue;
46
50
  }
47
- if (["--profile", "--seed", "--browser", "--name", "--url"].includes(arg)) {
51
+ if (isValueOption(arg)) {
48
52
  const value = argv[++index];
49
- if (!value) throw new Error(`${arg} requires a value`);
50
- options[arg.slice(2)] = value;
53
+ if (!value)
54
+ throw new Error(`${arg} requires a value`);
55
+ options[VALUE_OPTIONS[arg]] = value;
51
56
  continue;
52
57
  }
53
- throw new Error(`unknown option: ${arg}`);
58
+ throw new Error(`unknown option: ${String(arg)}`);
54
59
  }
55
60
  return options;
56
61
  }
57
-
58
62
  const options = parseArgs(process.argv.slice(2));
59
63
  if (options.help) {
60
64
  console.log(HELP);
61
65
  process.exit(0);
62
66
  }
63
-
64
- const profileDir = path.resolve(
65
- options.profile ??
66
- process.env.CLOAK_PROFILE_DIR ??
67
- path.join(os.homedir(), ".local", "share", "omowright-cloak"),
68
- );
67
+ const profileDir = path.resolve(options.profile ?? process.env["CLOAK_PROFILE_DIR"] ?? path.join(os.homedir(), ".local", "share", "omowright-cloak"));
69
68
  const profile = await resolveCloakProfile({
70
69
  profileDir,
71
- fingerprintSeed: options.seed,
70
+ fingerprintSeed: options.seed
72
71
  });
73
72
  let browser;
74
73
  let shuttingDown = false;
75
74
  async function shutdown(code = 0) {
76
- if (shuttingDown) return;
75
+ if (shuttingDown)
76
+ return;
77
77
  shuttingDown = true;
78
78
  await browser?.close();
79
79
  process.exit(code);
80
80
  }
81
-
82
81
  process.once("SIGINT", () => void shutdown(130));
83
82
  process.once("SIGTERM", () => void shutdown(143));
84
-
85
83
  try {
86
84
  browser = await connectCloakProfile({
87
85
  profileDir,
88
86
  fingerprintSeed: profile.fingerprintSeed,
89
87
  browserPath: options.browser,
90
- name: options.name,
88
+ name: options.name
91
89
  });
92
90
  const page = await browser.newTab(options.url);
93
91
  const result = {
@@ -96,17 +94,16 @@ try {
96
94
  title: await page.title(),
97
95
  profileDir,
98
96
  fingerprintSeed: profile.fingerprintSeed,
99
- metadataPath: profile.metadataPath,
97
+ metadataPath: profile.metadataPath
100
98
  };
101
99
  if (options.snapshot) {
102
- result.snapshot = compactSnapshot(
103
- await page.snapshot({ interactive: true }),
104
- );
100
+ result.snapshot = compactSnapshot(await page.snapshot({ interactive: true }));
105
101
  }
106
102
  console.log(JSON.stringify(result, null, 2));
107
103
  if (!options.once) {
108
104
  await new Promise(() => {});
109
105
  }
110
106
  } finally {
111
- if (!shuttingDown) await browser?.close();
107
+ if (!shuttingDown)
108
+ await browser?.close();
112
109
  }