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.
- package/README.md +43 -29
- package/TOOLS.md +9 -8
- package/dist/agent-tabs.d.ts +56 -0
- package/dist/aria-hidden.d.ts +1 -0
- package/dist/aside/cli-binary.d.ts +7 -0
- package/dist/aside/cli-contract.d.ts +9 -0
- package/dist/aside/errors.d.ts +8 -0
- package/dist/aside/line-transport.d.ts +11 -0
- package/dist/aside/mcp-transport.d.ts +11 -0
- package/dist/aside/onboard.d.ts +76 -0
- package/dist/aside/session-types.d.ts +68 -0
- package/dist/aside/session.d.ts +20 -0
- package/{bin/omowright-cloak.mjs → dist/bin/omowright-cloak.js} +28 -31
- package/dist/bridge-schemas.d.ts +326 -0
- package/dist/bridge-transport.d.ts +144 -0
- package/dist/browser-context.d.ts +4024 -0
- package/dist/browser-process.d.ts +10 -0
- package/dist/bsk/browser-signals.d.ts +23 -0
- package/dist/bsk/browsers.d.ts +46 -0
- package/dist/bsk/connect.d.ts +23 -0
- package/dist/bsk/daemon-info.d.ts +16 -0
- package/dist/bsk/external-extension.d.ts +74 -0
- package/dist/bsk/identify-browser.d.ts +48 -0
- package/dist/bsk/install-cli.d.ts +37 -0
- package/dist/bsk/ipc-client.d.ts +45 -0
- package/dist/bsk/onboard.d.ts +96 -0
- package/dist/bsk/reply-fields.d.ts +3 -0
- package/dist/bsk/screenshot.d.ts +24 -0
- package/dist/bsk/session.d.ts +142 -0
- package/dist/bsk/snapshot.d.ts +16 -0
- package/dist/bsk/targets.d.ts +20 -0
- package/dist/captcha-wait.d.ts +17 -0
- package/dist/captcha.d.ts +46 -0
- package/dist/cdp-errors.d.ts +38 -0
- package/dist/cdp-methods.d.ts +10 -0
- package/dist/cdp-protocol.d.ts +459 -0
- package/dist/chrome-profile.d.ts +77 -0
- package/dist/chrome.d.ts +130 -0
- package/dist/cloak-profile.d.ts +43 -0
- package/dist/connection.d.ts +4024 -0
- package/dist/console-events.d.ts +22 -0
- package/dist/cookies.d.ts +42 -0
- package/dist/core.d.ts +10810 -0
- package/dist/cua.d.ts +56 -0
- package/dist/dialog-policy.d.ts +43 -0
- package/dist/ego/bindings.d.ts +68 -0
- package/dist/ego/cdp-client.d.ts +28 -0
- package/dist/ego/client.d.ts +8 -0
- package/dist/ego/errors.d.ts +7 -0
- package/dist/emulate.d.ts +62 -0
- package/dist/engines.d.ts +59 -0
- package/dist/events.d.ts +93 -0
- package/dist/frames-snapshot.d.ts +58 -0
- package/dist/har.d.ts +88 -0
- package/dist/human-handoff.d.ts +30 -0
- package/{src/index.js → dist/index.d.ts} +12 -55
- package/dist/index.js +39478 -0
- package/dist/injected.d.ts +1 -0
- package/dist/instance-lock.d.ts +5 -0
- package/dist/instances.d.ts +45 -0
- package/dist/internal-capability.d.ts +1 -0
- package/dist/launch-endpoint.d.ts +34 -0
- package/dist/layers.d.ts +31 -0
- package/dist/llm.d.ts +1349 -0
- package/dist/lock-backend-win32-xbcm60vz.js +57 -0
- package/dist/lock-backend-win32.d.ts +3 -0
- package/dist/lock-backend.d.ts +6 -0
- package/dist/native-host-win32.d.ts +38 -0
- package/dist/network-events.d.ts +66 -0
- package/dist/network-snoop.d.ts +56 -0
- package/dist/nul-frames.d.ts +4 -0
- package/dist/open-shadow-query.d.ts +1 -0
- package/dist/owner-only.d.ts +15 -0
- package/dist/page-bundle.js +1597 -0
- package/dist/page-events.d.ts +25 -0
- package/dist/page-routes.d.ts +30 -0
- package/dist/page-setup.d.ts +55 -0
- package/dist/pipe.d.ts +71 -0
- package/dist/process-start-time.d.ts +2 -0
- package/dist/read-property.d.ts +2 -0
- package/dist/routes.d.ts +60 -0
- package/dist/running-browser.d.ts +39 -0
- package/dist/scroll-collect.d.ts +36 -0
- package/dist/serial-emitter.d.ts +5 -0
- package/dist/shared-connections.d.ts +11 -0
- package/dist/snapshot-diff.d.ts +57 -0
- package/dist/text-matching.d.ts +21 -0
- package/dist/trace.d.ts +59 -0
- package/dist/url-match.d.ts +7 -0
- package/dist/viewport.d.ts +26 -0
- package/dist/ws.d.ts +62 -0
- package/package.json +47 -26
- package/presets/agent-events/SKILL.md +1 -1
- package/presets/captcha/SKILL.md +1 -3
- package/presets/chrome/SKILL.md +2 -2
- package/presets/cloak-bridge/SKILL.md +11 -11
- package/presets/network/SKILL.md +15 -13
- package/presets/visual-browse/SKILL.md +14 -10
- package/skills/omowright/SKILL.md +83 -49
- package/skills/omowright/references/aside.md +50 -0
- package/skills/omowright/references/browserskill.md +29 -32
- package/skills/omowright/references/ego.md +24 -0
- package/skills/omowright/references/eval-kernel.md +44 -23
- package/skills/omowright/references/frames-layers-human.md +16 -7
- package/skills/omowright/references/quickstart.md +7 -4
- package/skills/omowright/references/stealth.md +11 -8
- package/src/agent-tabs.js +0 -179
- package/src/aria-hidden.js +0 -47
- package/src/bridge-schemas.js +0 -44
- package/src/bridge-transport.js +0 -83
- package/src/browser-context.js +0 -105
- package/src/browser-process.js +0 -127
- package/src/bsk/browser-signals.js +0 -90
- package/src/bsk/browsers.js +0 -114
- package/src/bsk/connect.js +0 -75
- package/src/bsk/daemon-info.js +0 -100
- package/src/bsk/external-extension.js +0 -110
- package/src/bsk/identify-browser.js +0 -88
- package/src/bsk/install-cli.js +0 -81
- package/src/bsk/ipc-client.js +0 -236
- package/src/bsk/onboard.js +0 -140
- package/src/bsk/screenshot.js +0 -49
- package/src/bsk/session.js +0 -131
- package/src/bsk/snapshot.js +0 -56
- package/src/bsk/targets.js +0 -25
- package/src/captcha-wait.js +0 -79
- package/src/captcha.js +0 -142
- package/src/cdp-errors.js +0 -23
- package/src/cdp-methods.js +0 -69
- package/src/chrome-profile.js +0 -176
- package/src/chrome.js +0 -194
- package/src/cloak-profile.js +0 -266
- package/src/connection.js +0 -234
- package/src/console-events.js +0 -12
- package/src/cookies.js +0 -39
- package/src/core.js +0 -1702
- package/src/cua.js +0 -74
- package/src/dialog-policy.js +0 -80
- package/src/emulate.js +0 -127
- package/src/events.js +0 -111
- package/src/frames-snapshot.js +0 -138
- package/src/har.js +0 -103
- package/src/human-handoff.js +0 -124
- package/src/injected.js +0 -3
- package/src/instance-lock.js +0 -74
- package/src/instances.js +0 -490
- package/src/internal-capability.js +0 -1
- package/src/launch-endpoint.js +0 -185
- package/src/layers.js +0 -138
- package/src/llm.js +0 -201
- package/src/lock-backend-win32.js +0 -54
- package/src/lock-backend.js +0 -81
- package/src/native-host-win32.js +0 -201
- package/src/network-events.js +0 -223
- package/src/network-snoop.js +0 -229
- package/src/nul-frames.js +0 -28
- package/src/open-shadow-query.js +0 -101
- package/src/owner-only.js +0 -196
- package/src/page-bundle.js +0 -1478
- package/src/page-events.js +0 -45
- package/src/page-routes.js +0 -94
- package/src/page-setup.js +0 -239
- package/src/pipe.js +0 -418
- package/src/process-start-time.js +0 -64
- package/src/routes.js +0 -256
- package/src/running-browser.js +0 -85
- package/src/scroll-collect.js +0 -73
- package/src/serial-emitter.js +0 -17
- package/src/shared-connections.js +0 -285
- package/src/snapshot-diff.js +0 -75
- package/src/text-matching.js +0 -101
- package/src/trace.js +0 -183
- package/src/url-match.js +0 -148
- 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
|
|
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
|
-
//
|
|
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
|
-
// -
|
|
45
|
-
// - link "Learn more" [ref=e1]
|
|
46
|
+
// - link "Learn more" [ref=e1]
|
|
46
47
|
|
|
47
|
-
await page.locator("e1").click();
|
|
48
|
+
await page.locator("e1").click(); // refs come straight from the snapshot
|
|
48
49
|
await browser.close();
|
|
49
50
|
```
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
64
|
-
|
|
|
65
|
-
| news.ycombinator.com
|
|
66
|
-
| en.wikipedia.org/wiki/Web_browser
|
|
67
|
-
| github.com/code-yeongyu/omowright \* | app-like
|
|
68
|
-
| example.com
|
|
69
|
-
| httpbin.org/forms/post
|
|
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
|
-
|
|
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,
|
|
107
|
-
maxScrolls: 15,
|
|
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",
|
|
110
|
-
settleMs: 800,
|
|
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;
|
|
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
|
|
244
|
-
|
|
|
245
|
-
| `presets/network`
|
|
246
|
-
| `presets/visual-browse` | Coordinate UI, **CUA scroll**, viewport pinning, extension popups
|
|
247
|
-
| `presets/captcha`
|
|
248
|
-
| `presets/chrome`
|
|
249
|
-
| `presets/agent-events`
|
|
250
|
-
| `presets/cloak-bridge`
|
|
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.
|
|
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
|
|
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.
|
|
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 => {
|
|
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;
|
|
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;
|
|
39
|
+
for (let index = 0;index < argv.length; index += 1) {
|
|
37
40
|
const arg = argv[index];
|
|
38
|
-
if (arg === "--help")
|
|
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 (
|
|
51
|
+
if (isValueOption(arg)) {
|
|
48
52
|
const value = argv[++index];
|
|
49
|
-
if (!value)
|
|
50
|
-
|
|
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)
|
|
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)
|
|
107
|
+
if (!shuttingDown)
|
|
108
|
+
await browser?.close();
|
|
112
109
|
}
|