omowright 0.1.0 → 0.3.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.
- package/README.md +33 -23
- package/TOOLS.md +140 -19
- 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 -53
- package/dist/index.js +39262 -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 +1587 -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 +11 -7
- 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 +77 -47
- package/skills/omowright/references/aside.md +50 -0
- package/skills/omowright/references/browserskill.md +39 -33
- 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 +17 -4
- package/skills/omowright/references/stealth.md +7 -7
- package/src/agent-tabs.js +0 -160
- package/src/bridge-schemas.js +0 -44
- package/src/bridge-transport.js +0 -57
- package/src/browser-process.js +0 -122
- package/src/bsk/browser-signals.js +0 -90
- package/src/bsk/browsers.js +0 -114
- package/src/bsk/connect.js +0 -45
- 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 -133
- 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 -74
- package/src/captcha.js +0 -142
- package/src/cdp-errors.js +0 -23
- package/src/cdp-methods.js +0 -61
- package/src/chrome-profile.js +0 -176
- package/src/chrome.js +0 -192
- package/src/cloak-profile.js +0 -266
- package/src/connection.js +0 -135
- package/src/cookies.js +0 -29
- package/src/core.js +0 -1710
- 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 -122
- package/src/injected.js +0 -3
- package/src/instance-lock.js +0 -230
- package/src/instances.js +0 -493
- 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-file.js +0 -130
- package/src/native-host-win32.js +0 -201
- package/src/network-events.js +0 -201
- package/src/network-snoop.js +0 -229
- package/src/open-shadow-query.js +0 -22
- package/src/owner-only.js +0 -109
- package/src/page-bundle.js +0 -1397
- package/src/page-routes.js +0 -94
- package/src/pipe.js +0 -391
- 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 -278
- package/src/snapshot-diff.js +0 -75
- package/src/trace.js +0 -183
- package/src/url-match.js +0 -148
- package/src/viewport.js +0 -12
package/README.md
CHANGED
|
@@ -44,12 +44,14 @@ console.log(compactSnapshot(await page.snapshot()));
|
|
|
44
44
|
// - paragraph:
|
|
45
45
|
// - link "Learn more" [ref=e1]
|
|
46
46
|
|
|
47
|
-
await page.locator("e1").click();
|
|
47
|
+
await page.locator("e1").click(); // refs come straight from the snapshot
|
|
48
48
|
await browser.close();
|
|
49
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
|
+
reads what changed instead of the whole page again. To look for one thing,
|
|
53
|
+
`page.snapshot({ find: "Checkout" })` returns only the matching lines, with
|
|
54
|
+
their refs and a little context around each.
|
|
53
55
|
|
|
54
56
|
## Snapshot size
|
|
55
57
|
|
|
@@ -60,13 +62,13 @@ and `compactSnapshot(await page.snapshot({ interactive: true }))`. Measured on
|
|
|
60
62
|
2026-11-05 (UTC) at commit `4845ef5` with Chrome for Testing 156.0.8078.4
|
|
61
63
|
(headless shell) on Linux.
|
|
62
64
|
|
|
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
|
|
65
|
+
| Page | Shape | Raw HTML | Snapshot | Interactive snapshot | Snapshot / HTML | Interactive / HTML |
|
|
66
|
+
| ------------------------------------ | ------------ | -------: | -------: | -------------------: | --------------: | -----------------: |
|
|
67
|
+
| news.ycombinator.com | link-heavy | 11,615 | 4,220 | 3,811 | 36.3% | 32.8% |
|
|
68
|
+
| en.wikipedia.org/wiki/Web_browser | long article | 143,312 | 14,155 | 12,591 | 9.9% | 8.8% |
|
|
69
|
+
| github.com/code-yeongyu/omowright \* | app-like | 116,378 | 5,432 | 5,481 | 4.7% | 4.7% |
|
|
70
|
+
| example.com | trivial | 637 | 222 | 222 | 34.9% | 34.9% |
|
|
71
|
+
| httpbin.org/forms/post | form | 428 | 370 | 245 | 86.4% | 57.2% |
|
|
70
72
|
|
|
71
73
|
\* The interactive snapshot is read after the full one, and here it came out
|
|
72
74
|
larger, so the page likely changed between the two reads: `page.goto()` can
|
|
@@ -103,15 +105,15 @@ await page.goto("https://example.com/feed");
|
|
|
103
105
|
|
|
104
106
|
const items = [];
|
|
105
107
|
const run = collectWhileScrolling(page, snoop, {
|
|
106
|
-
minItems: 200,
|
|
107
|
-
maxScrolls: 15,
|
|
108
|
+
minItems: 200, // stop once this many items are in hand
|
|
109
|
+
maxScrolls: 15, // or after this many scroll rounds
|
|
108
110
|
extract: (json) => json.items, // pull items out of each JSON body
|
|
109
|
-
scroll: "wheel",
|
|
110
|
-
settleMs: 800,
|
|
111
|
+
scroll: "wheel", // "end" jumps to the bottom instead
|
|
112
|
+
settleMs: 800, // wait for the next page to land
|
|
111
113
|
});
|
|
112
114
|
let step;
|
|
113
115
|
while (!(step = await run.next()).done) items.push(step.value);
|
|
114
|
-
step.value;
|
|
116
|
+
step.value; // { rounds, total, stoppedBecause: "minItems" | "maxScrolls" | "noGrowth" }
|
|
115
117
|
```
|
|
116
118
|
|
|
117
119
|
It drains first, scrolls second, and stops on its own when the document stops
|
|
@@ -150,7 +152,15 @@ sleep to tune.
|
|
|
150
152
|
instance with liveness. The registry directory is owner-only (mode `0700`; on
|
|
151
153
|
Windows a protected ACL), so on Windows it must live on a volume with ACLs:
|
|
152
154
|
on FAT32, exFAT or a share without ACLs `connectNamed` throws instead of
|
|
153
|
-
leaving the registry open.
|
|
155
|
+
leaving the registry open. The registry must be on a local filesystem;
|
|
156
|
+
network filesystems (NFS/SMB) do not provide the cross-process guarantees
|
|
157
|
+
required here. Linux needs the `flock` utility from util-linux or BusyBox.
|
|
158
|
+
Locks are kernel-held and released on process exit; their zero-byte `.flock`
|
|
159
|
+
files persist. Never delete or rename a `.flock` while clients use the registry.
|
|
160
|
+
**Upgrading from 0.1.0:** stop all clients sharing a registry before upgrading
|
|
161
|
+
them together; old and new versions use different locks and must not overlap.
|
|
162
|
+
Legacy `.lock`, `.lock.*.stale`, and `.lock.*.tmp` files are ignored and left
|
|
163
|
+
untouched; remove them manually only after all clients have upgraded.
|
|
154
164
|
- **Shared attaches.** Chrome asks the user to allow remote debugging once per
|
|
155
165
|
connection to their own profile, so `connect(url)` and `connectNamed`
|
|
156
166
|
attaches in one process share one CDP connection per browser (keyed by its
|
|
@@ -232,14 +242,14 @@ browser log), stealth profiles, eval-kernel usage, frames and human handoff,
|
|
|
232
242
|
the attached BrowserSkill engine, and reading a 1Password web-vault item
|
|
233
243
|
safely. Task presets live in `presets/`:
|
|
234
244
|
|
|
235
|
-
| Preset
|
|
236
|
-
|
|
|
237
|
-
| `presets/network`
|
|
238
|
-
| `presets/visual-browse` | Coordinate UI, **CUA scroll**, viewport pinning, extension popups
|
|
239
|
-
| `presets/captcha`
|
|
240
|
-
| `presets/chrome`
|
|
241
|
-
| `presets/agent-events`
|
|
242
|
-
| `presets/cloak-bridge`
|
|
245
|
+
| Preset | Covers |
|
|
246
|
+
| ----------------------- | ------------------------------------------------------------------------------- |
|
|
247
|
+
| `presets/network` | Snoop JSON APIs, wait for requests, **collect while scrolling**, traces, routes |
|
|
248
|
+
| `presets/visual-browse` | Coordinate UI, **CUA scroll**, viewport pinning, extension popups |
|
|
249
|
+
| `presets/captcha` | Checkbox, slider, OCR and image-grid challenges |
|
|
250
|
+
| `presets/chrome` | Tabs, windows, bookmarks, history, downloads, topSites |
|
|
251
|
+
| `presets/agent-events` | Tab, popup and download push events |
|
|
252
|
+
| `presets/cloak-bridge` | The MV3 bridge extension and native-messaging host |
|
|
243
253
|
|
|
244
254
|
Install the skill by copying or symlinking `skills/omowright` (in an npm
|
|
245
255
|
install, `node_modules/omowright/skills/omowright`) into your harness's
|
package/TOOLS.md
CHANGED
|
@@ -15,7 +15,14 @@ running Chromium DevTools endpoint).
|
|
|
15
15
|
- `newTab(url)` — open a tab, waits for interactivity, returns page.
|
|
16
16
|
- `listTargets()` — list open tabs (id, type, url, title).
|
|
17
17
|
- `attachPage(targetId)` — attach an existing tab.
|
|
18
|
-
- `page.goto(url)` — navigate; resolves when interactive
|
|
18
|
+
- `page.goto(url)` — navigate; resolves when interactive with the main-frame
|
|
19
|
+
document response (the final hop after redirects), or `null` for a
|
|
20
|
+
same-document navigation such as a `#hash` change. `page.reload()`,
|
|
21
|
+
`page.goBack()` and `page.goForward()` resolve the same way once the new
|
|
22
|
+
document is active (they do not wait for `load`), and `null` when there is
|
|
23
|
+
no history entry (also `null` when the transport emits no network events).
|
|
24
|
+
The response is the object described under `page.on("request" | "response")`;
|
|
25
|
+
its body stays readable after the call.
|
|
19
26
|
- `page.waitForURL(url, { timeout?, waitUntil? })` — wait until the page URL
|
|
20
27
|
matches a Playwright glob (`**` crosses `/`, `*` does not, `{a,b}` is a
|
|
21
28
|
choice, `?` is a literal question mark), a RegExp, or a predicate
|
|
@@ -25,6 +32,22 @@ running Chromium DevTools endpoint).
|
|
|
25
32
|
wait for those document events; `networkidle` waits until no request has been
|
|
26
33
|
in flight for 500 ms (requests already running when the wait starts are not
|
|
27
34
|
seen); `interactive` (default) and `stable` use the `goto` readiness probe.
|
|
35
|
+
- `page.setContent(html, { waitUntil, timeout })` — replace the document with
|
|
36
|
+
`html`; waits for `load` by default (`domcontentloaded`, `networkidle`,
|
|
37
|
+
`commit`), timeout 30000ms (0 disables it).
|
|
38
|
+
- `page.waitForTimeout(ms)` — discouraged: a fixed sleep. Wait for the state
|
|
39
|
+
you need instead (`locator.waitFor`, `page.waitForURL`, `page.waitForLoadState`).
|
|
40
|
+
- `page.waitForEvent("popup")` / `page.on("popup", listener)` — deliver the
|
|
41
|
+
newly opened page after attachment and interactivity. Subscribe before
|
|
42
|
+
`window.open(...)` or a `target="_blank"` click. The result supports `url()`,
|
|
43
|
+
`snapshot()`, `goto()`, and the other page methods. The old `{ url, windowName }`
|
|
44
|
+
event metadata is available as `popup.popupMetadata` (`url` is the originally
|
|
45
|
+
requested URL; `popup.url()` is the current URL). Only popups from agent-owned
|
|
46
|
+
tabs with an active popup listener or waiter are adopted. User tabs attached
|
|
47
|
+
with `attachPage()` and unobserved popups remain untouched. Adopted popups are
|
|
48
|
+
registered with `createAgentTabs(connection)` and closed with its owned tabs
|
|
49
|
+
or the connection. Disconnecting leaves ordinary `newTab()` tabs open.
|
|
50
|
+
A popup that closes before attachment rejects its popup waiter promptly.
|
|
28
51
|
- `page.snapshot(options?)` — PRIMARY read. Returns `{tree, refs}`; tree lines
|
|
29
52
|
look like `- link "Learn more" [ref=e1]`. Options: `maxDepth` (50),
|
|
30
53
|
`maxChars`, `interactive`, `showHidden`, `selector`, `ref`.
|
|
@@ -33,7 +56,8 @@ running Chromium DevTools endpoint).
|
|
|
33
56
|
sending snapshots to a model.
|
|
34
57
|
- `page.locator(refOrCss)` — `click`, `fill`, `press`, `pressSequentially`,
|
|
35
58
|
`hover`, `check`, `selectOption`, `dragTo`, `setInputFiles`, `textContent`,
|
|
36
|
-
`innerText`, `
|
|
59
|
+
`innerText`, `allTextContents`, `allInnerTexts`, `isVisible`, `waitFor`,
|
|
60
|
+
`first/nth/last`, `filter`, `and` (both match), `or` (either matches, document order).
|
|
37
61
|
- `page.getByRole(role, options?)`, `getByText(text, { exact })`,
|
|
38
62
|
`getByLabel(text, { exact })`, `getByPlaceholder(text, { exact })`,
|
|
39
63
|
`getByAltText(text, { exact })`, `getByTitle(text, { exact })`,
|
|
@@ -47,6 +71,63 @@ running Chromium DevTools endpoint).
|
|
|
47
71
|
`data-testid` exactly (or by RegExp); `selectors.setTestIdAttribute(name)`
|
|
48
72
|
switches the attribute for locators created afterwards.
|
|
49
73
|
- `page.evaluate(expression)` — run JS in the page.
|
|
74
|
+
- `page.addInitScript(script, arg?)` — register a function (with one serializable
|
|
75
|
+
argument), a source string, `{ content }`, or `{ path }` (relative to the
|
|
76
|
+
working directory). It runs in the main world before document scripts on
|
|
77
|
+
every navigation and child-frame attachment/navigation, including
|
|
78
|
+
out-of-process frames. It does not run in the current document.
|
|
79
|
+
- `page.exposeFunction(name, callback)` — install an async function on every
|
|
80
|
+
frame's `window`, including existing frames and future documents. Browser
|
|
81
|
+
calls forward their arguments to the host callback; its result resolves the
|
|
82
|
+
browser promise and a thrown error rejects it. Duplicate names reject.
|
|
83
|
+
Supports JSON-like values, `undefined`, non-finite numbers, `-0` and bigints.
|
|
84
|
+
This member enables Runtime on demand and keeps it enabled for the binding's
|
|
85
|
+
lifetime; ordinary page setup does not enable Runtime.
|
|
86
|
+
- `page.exposeBinding(name, callback)` — like `exposeFunction`, but the host
|
|
87
|
+
callback receives `{ context, page, frame }` before the browser arguments.
|
|
88
|
+
`context` is the real `page.context()` object and `frame` is the calling
|
|
89
|
+
frame, including a same-process or out-of-process child. Bindings survive
|
|
90
|
+
frame and page navigation and are installed in existing frames.
|
|
91
|
+
- `page.setExtraHTTPHeaders(headers)` — replace the page's extra request
|
|
92
|
+
headers, including frame requests; values must be strings. Pass `{}` to
|
|
93
|
+
clear them. Network ownership is shared with readiness and request capture,
|
|
94
|
+
so ending a transient subscription does not remove the headers.
|
|
95
|
+
- `page.setViewportSize({ width, height })` — set positive integer CSS-pixel
|
|
96
|
+
viewport and screen dimensions. On an agent-owned tab this also updates
|
|
97
|
+
its navigation pin, using the manager's serialized repin queue.
|
|
98
|
+
- `page.emulateMedia({ media?, colorScheme?, reducedMotion?, forcedColors?, contrast? })`
|
|
99
|
+
— emulate CSS media and preferences. `media` accepts `"screen"` or `"print"`;
|
|
100
|
+
`colorScheme` accepts `"light"`, `"dark"` or `"no-preference"`;
|
|
101
|
+
`reducedMotion` accepts `"reduce"` or `"no-preference"`;
|
|
102
|
+
`forcedColors` accepts `"active"` or `"none"`; `contrast` accepts `"more"` or
|
|
103
|
+
`"no-preference"`. Omitted properties retain their overrides; `null` clears
|
|
104
|
+
that property's override. Applies to current and future frame sessions.
|
|
105
|
+
- `page.context()` — the page's browser context (shared by pages in the same
|
|
106
|
+
context on this connection). Cookie reads, writes and clears are scoped to
|
|
107
|
+
that CDP browser context, including when attached to an incognito tab.
|
|
108
|
+
The supported [Playwright context methods](https://playwright.dev/docs/api/class-browsercontext)
|
|
109
|
+
are:
|
|
110
|
+
- `context.cookies(urls?)` — all cookies, or those affecting a URL string or
|
|
111
|
+
array of URLs. Returns `{ name, value, domain, path, expires, httpOnly,
|
|
112
|
+
secure, sameSite, partitionKey? }`; `expires` is Unix seconds (`-1` for a
|
|
113
|
+
session cookie).
|
|
114
|
+
- `context.addCookies(cookies)` — each cookie requires `name`, `value` and
|
|
115
|
+
either `url` or both `domain` and `path`. Optional fields: `expires`,
|
|
116
|
+
`httpOnly`, `secure`, `sameSite` (`"Strict"`, `"Lax"`, `"None"`) and
|
|
117
|
+
`partitionKey`. Unlike raw-export `injectCookies`, this preserves
|
|
118
|
+
same-name cookies at different paths.
|
|
119
|
+
- `context.clearCookies({ name?, domain?, path? }?)` — clear all cookies or
|
|
120
|
+
only those matching every supplied string or RegExp filter.
|
|
121
|
+
- `context.storageState({ path? }?)` — return `{ cookies, origins }`, where
|
|
122
|
+
each origin is `{ origin, localStorage: [{ name, value }] }`. Includes
|
|
123
|
+
localStorage for HTTP(S) origins observed by attached pages, even after
|
|
124
|
+
navigating away or closing them. A temporary, intercepted blank page reads
|
|
125
|
+
storage without running those sites' scripts or navigating existing pages.
|
|
126
|
+
With `path`, also write the same JSON, creating parent directories; relative
|
|
127
|
+
paths resolve from the current working directory. IndexedDB is not included.
|
|
128
|
+
Restore cookies with `addCookies(state.cookies)` and localStorage by
|
|
129
|
+
navigating a fresh page to each origin and setting its saved entries.
|
|
130
|
+
- `context.newPage()` — create an agent-owned blank page in this context.
|
|
50
131
|
- `page.waitForRequest(urlOrPredicate, { timeout? })` /
|
|
51
132
|
`page.waitForResponse(urlOrPredicate, { timeout? })` — wait for the next
|
|
52
133
|
matching request or response headers (default timeout: 30000ms). Match an
|
|
@@ -56,8 +137,9 @@ running Chromium DevTools endpoint).
|
|
|
56
137
|
function unsubscribes, as does `page.off(event, listener)`. Both waits and
|
|
57
138
|
listeners receive objects with `url()`, `method()`, `headers()` (lowercase
|
|
58
139
|
names), and async `body()` (Buffer), `text()`, `json()`. Request bodies are
|
|
59
|
-
the CDP request's post data; responses also expose `status()
|
|
60
|
-
body reads wait for transfer completion and
|
|
140
|
+
the CDP request's post data; responses also expose `status()` and `ok()`
|
|
141
|
+
(status 200-299). Response body reads wait for transfer completion and
|
|
142
|
+
decode base64 when necessary.
|
|
61
143
|
Bodies are cached on completion for response objects delivered to listeners.
|
|
62
144
|
If the transport refuses `Network.getResponseBody`, these reads reject with
|
|
63
145
|
the exported `NetworkBodyUnavailableError` (the transport error is `cause`),
|
|
@@ -67,9 +149,38 @@ running Chromium DevTools endpoint).
|
|
|
67
149
|
release after the last consumer and its pending response bodies finish;
|
|
68
150
|
no Runtime domain is enabled. A refused Network enable does not break page
|
|
69
151
|
setup, but a transport that emits no network events will time out waits.
|
|
152
|
+
- `page.waitForFunction(pageFunction, arg?, { timeout, polling })` — wait for
|
|
153
|
+
app-specific page state instead of sleeping. Runs `pageFunction(arg)` (a
|
|
154
|
+
function, or a string expression) in the page's main world until it returns a
|
|
155
|
+
truthy value, then resolves with that value by value: DOM nodes and functions
|
|
156
|
+
come back as `{}`, and a value CDP cannot return by value (a cycle such as
|
|
157
|
+
`window`, a symbol or a bigint) as `true`. `polling` is `"raf"` (default,
|
|
158
|
+
every animation frame, or every 100 ms when the page gets no frames, as a
|
|
159
|
+
background tab of a headful browser does) or a positive number of
|
|
160
|
+
milliseconds. `timeout`
|
|
161
|
+
defaults to 30000; `0` waits forever. A same-tab navigation during the wait
|
|
162
|
+
re-runs the function in the new document. An error thrown by the function,
|
|
163
|
+
or closing the page, rejects at once; a timeout rejects with
|
|
164
|
+
`WaitForFunctionTimeoutError` (exported; `timeoutMs`, and the message
|
|
165
|
+
carries the function source cut at 200 characters). Example:
|
|
166
|
+
`await page.waitForFunction(n => document.querySelector(".badge")?.textContent === String(n), 3)`.
|
|
70
167
|
- `page.screenshot(options?)` — image bytes (path, fullPage, clip, type, quality).
|
|
71
168
|
- `page.pdf(options?)` — PDF bytes (path, format, margin, printBackground).
|
|
72
169
|
- `page.keyboard` / `page.mouse` — press, type, insertText / move, click, wheel.
|
|
170
|
+
- `page.on(event, listener)` / `page.off(event, listener)` /
|
|
171
|
+
`page.waitForEvent(event, { timeout?, predicate? })` — page events; `on`
|
|
172
|
+
returns an unsubscribe function. The accepted names are the exported
|
|
173
|
+
`PAGE_EVENT_NAMES`: `close`, `console`, `crash`, `dialog`,
|
|
174
|
+
`domcontentloaded`, `download`, `filechooser`, `frameattached`,
|
|
175
|
+
`framedetached`, `framenavigated`, `load`, `pageerror`, `popup`, `request`,
|
|
176
|
+
`response`. Any other name throws a `TypeError` that lists them.
|
|
177
|
+
`pageerror` receives an `Error` (page `name`, `message` and `stack`) for each
|
|
178
|
+
uncaught exception or unhandled rejection in the page or its frames. The
|
|
179
|
+
Runtime domain it needs is enabled only while a `pageerror` or `console`
|
|
180
|
+
listener or an exposed function exists (pages can detect it), and exceptions thrown before the
|
|
181
|
+
subscription are not replayed. `close` fires once the tab is gone, whether
|
|
182
|
+
`page.close()`, `window.close()`, the user or another client closed it; the
|
|
183
|
+
page is disposed with it.
|
|
73
184
|
- `createCua(page)` — coordinate fallback (visual-browse equivalent): `click`,
|
|
74
185
|
`doubleClick`, `drag({path})`, `move`, `scroll`, `type`, `keypress`,
|
|
75
186
|
`getVisibleScreenshot()` (base64 PNG). Use only when refs/locators cannot
|
|
@@ -95,8 +206,9 @@ running Chromium DevTools endpoint).
|
|
|
95
206
|
Full bounds, timing, cancellation, and acceptance examples:
|
|
96
207
|
[CAPTCHA skill](presets/captcha/SKILL.md).
|
|
97
208
|
- `createChromeApi(connection, { profilePath?, downloadDir? })` — Chrome
|
|
98
|
-
MV3-shaped APIs: `tabs.query/get`, `windows.get/getCurrent/
|
|
99
|
-
|
|
209
|
+
MV3-shaped APIs: `tabs.query/get`, `windows.get/getCurrent/getAll` (no
|
|
210
|
+
`focused` field and `windows.getLastFocused` throws: CDP exposes no window
|
|
211
|
+
focus), `bookmarks.*` (read-only), `history.search/getVisits`,
|
|
100
212
|
`downloads.search/download`, `topSites.get`. Profile-backed methods need
|
|
101
213
|
`profilePath`. Write methods throw `UnsupportedOperationError` (extension
|
|
102
214
|
bridge required). Full reference: presets/chrome/.
|
|
@@ -123,9 +235,9 @@ loop; the module files next to it are implementation detail.
|
|
|
123
235
|
wait is bounded: discovery by `probeTimeoutMs`, the launch by
|
|
124
236
|
`launchTimeoutMs`, the CDP handshake by `connectTimeoutMs`, the registry lock
|
|
125
237
|
by `lockTimeoutMs` (default: the other three plus a margin).
|
|
126
|
-
The registry lock
|
|
127
|
-
|
|
128
|
-
|
|
238
|
+
The registry lock is kernel-held and released when its holder closes it or
|
|
239
|
+
exits. A timeout names the `.flock` path; use `lsof`, `fuser`, or Windows
|
|
240
|
+
`handle.exe` on that path to find its holder.
|
|
129
241
|
**The named endpoint is unauthenticated.** CDP listens on 127.0.0.1 with a
|
|
130
242
|
kernel-chosen port: off the network, but any local process or user can drive
|
|
131
243
|
that browser. Name-less launches (`connectPipe`, `connectCloakProfile()`
|
|
@@ -135,7 +247,13 @@ loop; the module files next to it are implementation detail.
|
|
|
135
247
|
Attaches in one process share one CDP connection per browser, because
|
|
136
248
|
Chrome asks the user to allow remote debugging once per connection: each
|
|
137
249
|
attach returns a handle on it, `close()` releases that handle, and the last
|
|
138
|
-
release disconnects.
|
|
250
|
+
release disconnects. Every connection handle is also async-disposable, so a
|
|
251
|
+
script can write `await using browser = await connect(url)`: the handle is
|
|
252
|
+
released when the scope ends, also on a throw, and the script exits without
|
|
253
|
+
a trailing `close()` or `process.exit()`. Agent tabs stay open for the next
|
|
254
|
+
script's `attachPage(targetId)`; popups the script attached are closed with
|
|
255
|
+
the connection, so create tabs that must outlive the script with
|
|
256
|
+
`createAgentTabs`. A dropped socket is reconnected once, and a browser
|
|
139
257
|
with another GUID always gets its own connection. Callers passing different
|
|
140
258
|
connection options (storage root, client options, `dialogPolicy`) are not
|
|
141
259
|
shared. A holder never changes what another holder gets: on a shared handle
|
|
@@ -233,8 +351,11 @@ loop; the module files next to it are implementation detail.
|
|
|
233
351
|
the BrowserSkill daemon's IPC socket and returns a `BskSession`. `browser`
|
|
234
352
|
takes an instance id, a unique label, or a browser name such as `"chrome"`
|
|
235
353
|
that exactly one connected browser carries. Throws
|
|
236
|
-
`BskRpcError` `no_browser_connected` when no extension is attached
|
|
237
|
-
|
|
354
|
+
`BskRpcError` `no_browser_connected` when no extension is attached, and
|
|
355
|
+
`extension_outdated` when the chosen extension is 0.4.0 (its task tab groups
|
|
356
|
+
stay in the user's browser after the task); with no `browser` named it picks
|
|
357
|
+
an up-to-date connected browser over a 0.4.0 one. Never launches a browser of
|
|
358
|
+
its own.
|
|
238
359
|
- `BskSession`: `navigate`, `back`, `forward`, `reload`, `observe`, `snapshot`,
|
|
239
360
|
`getHtml`, `screenshot({ ref, fullPage })`, `click`, `hover`, `fill`,
|
|
240
361
|
`press`, `select`, `focus`, `blur`, `scrollTo`, `wheel`, `evaluate`,
|
|
@@ -273,7 +394,7 @@ loop; the module files next to it are implementation detail.
|
|
|
273
394
|
CSS selectors. Every new snapshot invalidates earlier ref ids. Attached-engine
|
|
274
395
|
refs from `session.observe()` are `@eN` strings for `session.click("@e3")`;
|
|
275
396
|
`bskSnapshot` refs are clicked through `css[ref]`.
|
|
276
|
-
- `page.
|
|
397
|
+
- Raw CDP `page._sendToTarget(method, params)` exists but is an escape hatch;
|
|
277
398
|
prefer the tools above.
|
|
278
399
|
|
|
279
400
|
## Dialogs (alert / confirm / prompt / beforeunload)
|
|
@@ -289,14 +410,14 @@ readiness is content-probe based).
|
|
|
289
410
|
A policy is either an object or a function:
|
|
290
411
|
|
|
291
412
|
```js
|
|
292
|
-
const browser = await connectPipe({ browserPath, browserArgs, storageRoot,
|
|
293
|
-
dialogPolicy: { accept: false } }); // confirm() -> false, prompt() -> null
|
|
413
|
+
const browser = await connectPipe({ browserPath, browserArgs, storageRoot, dialogPolicy: { accept: false } }); // confirm() -> false, prompt() -> null
|
|
294
414
|
browser.setDialogPolicy({ accept: true, promptText: "agent@example.com" }); // prompt() -> the text
|
|
295
|
-
browser.setDialogPolicy(dialog => {
|
|
415
|
+
browser.setDialogPolicy((dialog) => {
|
|
416
|
+
// { type, message, defaultPrompt, url }
|
|
296
417
|
if (dialog.type === "beforeunload") return true;
|
|
297
418
|
return { accept: !/delete/i.test(dialog.message), promptText: dialog.defaultPrompt };
|
|
298
419
|
});
|
|
299
|
-
browser.cdp.dialogPolicy;
|
|
420
|
+
browser.cdp.dialogPolicy; // read the current policy (client getter)
|
|
300
421
|
```
|
|
301
422
|
|
|
302
423
|
- `{ accept: false }` dismisses: `confirm()` returns `false`, `prompt()` returns
|
|
@@ -316,13 +437,13 @@ browser.cdp.dialogPolicy; // read the current policy (cl
|
|
|
316
437
|
`page.waitForEvent('dialog')`) leaves the dialog to the policy:
|
|
317
438
|
|
|
318
439
|
```js
|
|
319
|
-
page.on("dialog", dialog =>
|
|
320
|
-
dialog.type() === "prompt" ? dialog.accept("agent@example.com") : dialog.dismiss());
|
|
440
|
+
page.on("dialog", (dialog) => (dialog.type() === "prompt" ? dialog.accept("agent@example.com") : dialog.dismiss()));
|
|
321
441
|
```
|
|
322
442
|
|
|
323
443
|
Answer inside the listener or in a promise it returns: the policy waits for
|
|
324
444
|
that promise. A dialog is answered once: a second `accept()` / `dismiss()`,
|
|
325
445
|
or one after the policy answered, rejects.
|
|
446
|
+
|
|
326
447
|
- CDP listeners of `Page.javascriptDialogOpening` get the same `Dialog` as
|
|
327
448
|
`meta.dialog`. On a shared connection the policy is the connection's and a
|
|
328
449
|
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 as get()/list() report it: its page is null while the tab is still being adopted. */
|
|
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<AgentTab>;
|
|
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>;
|