omowright 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -150,7 +150,15 @@ sleep to tune.
150
150
  instance with liveness. The registry directory is owner-only (mode `0700`; on
151
151
  Windows a protected ACL), so on Windows it must live on a volume with ACLs:
152
152
  on FAT32, exFAT or a share without ACLs `connectNamed` throws instead of
153
- leaving the registry open.
153
+ leaving the registry open. The registry must be on a local filesystem;
154
+ network filesystems (NFS/SMB) do not provide the cross-process guarantees
155
+ required here. Linux needs the `flock` utility from util-linux or BusyBox.
156
+ Locks are kernel-held and released on process exit; their zero-byte `.flock`
157
+ files persist. Never delete or rename a `.flock` while clients use the registry.
158
+ **Upgrading from 0.1.0:** stop all clients sharing a registry before upgrading
159
+ them together; old and new versions use different locks and must not overlap.
160
+ Legacy `.lock`, `.lock.*.stale`, and `.lock.*.tmp` files are ignored and left
161
+ untouched; remove them manually only after all clients have upgraded.
154
162
  - **Shared attaches.** Chrome asks the user to allow remote debugging once per
155
163
  connection to their own profile, so `connect(url)` and `connectNamed`
156
164
  attaches in one process share one CDP connection per browser (keyed by its
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`, `isVisible`, `waitFor`, `first/nth/last`, `filter`.
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()`. Response
60
- body reads wait for transfer completion and decode base64 when necessary.
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/getLastFocused/
99
- getAll`, `bookmarks.*` (read-only), `history.search/getVisits`,
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 has two known races when a takeover meets a live holder:
127
- two callers can hold a name for a moment, and a released lock can come back
128
- and block the name until its holder's process exits (tracked in #62).
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. A dropped socket is reconnected once, and a browser
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; never
237
- launches a browser of its own.
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.context()` and raw CDP `_sendToTarget` exist but are escape hatches;
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omowright",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "OmOWright browser automation for standard Chromium CDP endpoints.",
6
6
  "license": "MIT",
@@ -47,8 +47,8 @@
47
47
  },
48
48
  "scripts": {
49
49
  "preversion": "git diff --quiet HEAD --",
50
- "test": "bun test test/download.test.mjs test/source-scope.test.mjs test/no-raw-tls-client.test.mjs test/running-browser.test.mjs test/branding.test.mjs test/hygiene.test.mjs test/llm.test.mjs test/integration.test.mjs test/wait-for-url.test.mjs test/interaction.test.mjs test/getby-locators.test.mjs test/captcha.test.mjs test/captcha.integration.test.mjs test/chrome.test.mjs test/cookies.test.mjs test/scoped-endpoint.test.mjs test/pipe.test.mjs test/browser-pidfile.test.mjs test/instances.test.mjs test/instances-shared-connection.test.mjs test/cloak-profile.test.mjs test/cloak-profile.integration.test.mjs test/events.test.mjs test/agent-tabs.test.mjs test/events.integration.test.mjs test/bridge-transport.test.mjs test/bridge-host-dir.test.mjs test/skill-docs.test.mjs test/dialogs.test.mjs test/emulate.test.mjs test/frames-snapshot.test.mjs test/frames-snapshot.live-attach.test.mjs test/har.test.mjs test/human-handoff.test.mjs test/index-exports.test.mjs test/layers.test.mjs test/network-snoop.test.mjs test/routes.test.mjs test/routes.live.test.mjs test/scroll-collect.test.mjs test/trace.test.mjs test/trace.live.test.mjs test/bsk-ipc-client.test.mjs test/bsk-session.test.mjs test/bsk-session-cooperate.test.mjs test/bsk-snapshot.test.mjs test/bsk-external-extension.test.mjs test/bsk-browser-choice.test.mjs test/bsk-doctor.test.mjs test/bsk-daemon-start.test.mjs",
51
- "test:node": "node --test test/download.test.mjs test/source-scope.test.mjs test/no-raw-tls-client.test.mjs test/running-browser.test.mjs test/branding.test.mjs test/hygiene.test.mjs test/llm.test.mjs test/integration.test.mjs test/wait-for-url.test.mjs test/interaction.test.mjs test/getby-locators.test.mjs test/captcha.test.mjs test/captcha.integration.test.mjs test/chrome.test.mjs test/cookies.test.mjs test/scoped-endpoint.test.mjs test/pipe.test.mjs test/browser-pidfile.test.mjs test/instances.test.mjs test/instances-shared-connection.test.mjs test/cloak-profile.test.mjs test/cloak-profile.integration.test.mjs test/events.test.mjs test/agent-tabs.test.mjs test/events.integration.test.mjs test/bridge-transport.test.mjs test/bridge-host-dir.test.mjs test/skill-docs.test.mjs test/dialogs.test.mjs test/emulate.test.mjs test/frames-snapshot.test.mjs test/frames-snapshot.live-attach.test.mjs test/har.test.mjs test/human-handoff.test.mjs test/index-exports.test.mjs test/layers.test.mjs test/network-snoop.test.mjs test/routes.test.mjs test/routes.live.test.mjs test/scroll-collect.test.mjs test/trace.test.mjs test/trace.live.test.mjs test/bsk-ipc-client.test.mjs test/bsk-session.test.mjs test/bsk-session-cooperate.test.mjs test/bsk-snapshot.test.mjs test/bsk-external-extension.test.mjs test/bsk-browser-choice.test.mjs test/bsk-doctor.test.mjs test/bsk-daemon-start.test.mjs",
50
+ "test": "bun test test/async-dispose.test.mjs test/page-setup.test.mjs test/wait-for-function.test.mjs test/download.test.mjs test/source-scope.test.mjs test/no-raw-tls-client.test.mjs test/running-browser.test.mjs test/branding.test.mjs test/hygiene.test.mjs test/llm.test.mjs test/integration.test.mjs test/wait-for-url.test.mjs test/interaction.test.mjs test/getby-locators.test.mjs test/captcha.test.mjs test/captcha.integration.test.mjs test/chrome.test.mjs test/cookies.test.mjs test/scoped-endpoint.test.mjs test/pipe.test.mjs test/pipe-frames.test.mjs test/browser-pidfile.test.mjs test/instances.test.mjs test/instances-shared-connection.test.mjs test/cloak-profile.test.mjs test/cloak-profile.integration.test.mjs test/events.test.mjs test/agent-tabs.test.mjs test/events.integration.test.mjs test/bridge-transport.test.mjs test/bridge-host-dir.test.mjs test/skill-docs.test.mjs test/dialogs.test.mjs test/emulate.test.mjs test/frames-snapshot.test.mjs test/frames-snapshot.live-attach.test.mjs test/har.test.mjs test/human-handoff.test.mjs test/index-exports.test.mjs test/layers.test.mjs test/network-snoop.test.mjs test/routes.test.mjs test/routes.live.test.mjs test/scroll-collect.test.mjs test/trace.test.mjs test/trace.live.test.mjs test/bsk-ipc-client.test.mjs test/bsk-session.test.mjs test/bsk-session-cooperate.test.mjs test/bsk-snapshot.test.mjs test/bsk-external-extension.test.mjs test/bsk-browser-choice.test.mjs test/bsk-doctor.test.mjs test/bsk-daemon-start.test.mjs",
51
+ "test:node": "node --test test/async-dispose.test.mjs test/page-setup.test.mjs test/wait-for-function.test.mjs test/download.test.mjs test/source-scope.test.mjs test/no-raw-tls-client.test.mjs test/running-browser.test.mjs test/branding.test.mjs test/hygiene.test.mjs test/llm.test.mjs test/integration.test.mjs test/wait-for-url.test.mjs test/interaction.test.mjs test/getby-locators.test.mjs test/captcha.test.mjs test/captcha.integration.test.mjs test/chrome.test.mjs test/cookies.test.mjs test/scoped-endpoint.test.mjs test/pipe.test.mjs test/pipe-frames.test.mjs test/browser-pidfile.test.mjs test/instances.test.mjs test/instances-shared-connection.test.mjs test/cloak-profile.test.mjs test/cloak-profile.integration.test.mjs test/events.test.mjs test/agent-tabs.test.mjs test/events.integration.test.mjs test/bridge-transport.test.mjs test/bridge-host-dir.test.mjs test/skill-docs.test.mjs test/dialogs.test.mjs test/emulate.test.mjs test/frames-snapshot.test.mjs test/frames-snapshot.live-attach.test.mjs test/har.test.mjs test/human-handoff.test.mjs test/index-exports.test.mjs test/layers.test.mjs test/network-snoop.test.mjs test/routes.test.mjs test/routes.live.test.mjs test/scroll-collect.test.mjs test/trace.test.mjs test/trace.live.test.mjs test/bsk-ipc-client.test.mjs test/bsk-session.test.mjs test/bsk-session-cooperate.test.mjs test/bsk-snapshot.test.mjs test/bsk-external-extension.test.mjs test/bsk-browser-choice.test.mjs test/bsk-doctor.test.mjs test/bsk-daemon-start.test.mjs",
52
52
  "test:cloak-profile": "node --test test/cloak-profile.test.mjs test/cloak-profile.integration.test.mjs",
53
53
  "test:cloak-profile:bun": "bun test test/cloak-profile.test.mjs test/cloak-profile.integration.test.mjs"
54
54
  },
@@ -38,13 +38,17 @@ Tab lifecycle stays on `connection.newTab(url)` / `page.close()`; interaction on
38
38
 
39
39
  ## windows — CDP `Browser.getWindowForTarget`
40
40
 
41
- `get(windowId, queryOptions?)`, `getCurrent(queryOptions?)`,
42
- `getLastFocused(queryOptions?)`, `getAll(queryOptions?)`.
41
+ `get(windowId, queryOptions?)`, `getCurrent(queryOptions?)`, `getAll(queryOptions?)`.
43
42
 
44
43
  - `queryOptions: { populate?: boolean }` — `populate: true` adds a `tabs` array.
45
- - Returns `{ id, focused, type, state, alwaysOnTop, incognito, tabs? }`.
46
- - Headless sessions have exactly one window; `getCurrent`/`getLastFocused` return
47
- the first.
44
+ - Returns `{ id, type, state, alwaysOnTop, incognito, tabs? }`. **THERE IS NO
45
+ `focused` FIELD**: CDP exposes no window focus state, and `document.hasFocus()`
46
+ is true in every page OmOWright attaches to (it enables focus emulation),
47
+ background agent windows included.
48
+ - `getLastFocused()` throws `UnsupportedOperationError` for the same reason. With
49
+ the extension bridge, follow `chrome.windows.onFocusChanged` instead.
50
+ - `getCurrent` returns the first window; it does not tell you where the user is
51
+ working.
48
52
 
49
53
  ## bookmarks — profile `Bookmarks` JSON, read-only
50
54
 
@@ -54,7 +54,13 @@ per-user `bsk-daemon-<hash>` scheduled task that runs `bsk daemon start
54
54
  --foreground` under `conhost.exe --headless`, so no console window opens.
55
55
  It never falls back to a headless browser: when no
56
56
  extension is connected it throws `no_browser_connected` and `bskDoctor()`
57
- tells you the one step that is missing.
57
+ tells you the one step that is missing. It also refuses extension 0.4.0 with
58
+ `extension_outdated`: that release puts each task's tabs into a "BrowserSkill"
59
+ tab group the browser saves and syncs, so the group outlives the task. With no
60
+ `browser` named, an up-to-date connected browser is picked instead; otherwise
61
+ the user updates the extension to 0.4.1 or later and deletes any saved
62
+ "BrowserSkill" groups by hand. `bskDoctor()` reports such browsers in
63
+ `outdatedExtensions` and is not `ready` while they are the only ones connected.
58
64
 
59
65
  ## What the session can do
60
66
 
@@ -106,6 +112,9 @@ if (!report.ready) {
106
112
  // result.needsChoice === true: nothing was registered; ask the user which
107
113
  // browser they use (result.identification.candidates), then call again with
108
114
  // { browser: "<id>" }.
115
+ // result.outdatedExtensions non-empty and ready === false: the only connected
116
+ // extension is 0.4.0; humanStep (also sent to onHumanStep) tells the user to
117
+ // update it to 0.4.1 or later and delete saved "BrowserSkill" tab groups.
109
118
  // result.daemon.running === false: humanStep is null and nothing was
110
119
  // registered; result.nextStep says how to start the daemon. Start it and
111
120
  // call again before telling the user anything.
@@ -70,14 +70,27 @@ await page.close();
70
70
  ```js
71
71
  const snap = await page.snapshot(); // { tree, refs } or JSON string
72
72
  const tree = compactSnapshot(snap); // raw tree, ~57% smaller
73
- await page.snapshot({ interactive: true }); // interactive elements only
73
+ await page.snapshot({ interactive: true }); // controls, headings, landmarks and state feedback
74
74
  await page.snapshot({ maxDepth: 20, maxChars: 4000, selector: "main" });
75
75
  ```
76
76
 
77
77
  Tree lines look like `- link "Learn more" [ref=e1]` — feed `e1` to
78
78
  `page.locator("e1")`. **EVERY NEW SNAPSHOT INVALIDATES EARLIER REFS**: re-snapshot
79
79
  after each state change, never act on a stale ref. Start with
80
- `interactive: true`; escalate to a full snapshot only when the target is missing.
80
+ `interactive: true`; escalate to a full snapshot when a target or needed text is
81
+ missing or truncated. Interactive reads keep capped text for clickable nodes,
82
+ scrollable containers and live regions: roles alert, alertdialog, status, log,
83
+ timer and marquee, and any `aria-live="polite"` or `"assertive"` element such as
84
+ a toast. A clickable or scrollable node keeps up to 100 characters of its own
85
+ text. Every other piece of text inside a live region counts toward that region's
86
+ 100 characters in total, however many items it holds, so two toasts each keep
87
+ their own text and a long log keeps only its start. A live region nested inside
88
+ a clickable or scrollable node, such as a toast in a scrollable pane, keeps its
89
+ own 100 characters beside the node's. Clickable or scrollable nodes inside or
90
+ around a live region keep their own 100 on top, so a scrollable `role="log"`
91
+ keeps up to 100 characters of its own text plus 100 for entries that are kept
92
+ nodes (`aria-live="off"` text is dropped; an invalid `aria-live` value counts
93
+ as unset). Other free-standing body prose is omitted.
81
94
 
82
95
  ## Readiness and dialogs
83
96
 
package/src/agent-tabs.js CHANGED
@@ -42,11 +42,26 @@ export class AgentTabManager {
42
42
  // paints (Page.captureScreenshot hangs) and requestAnimationFrame never fires.
43
43
  // Its own window doesn't take focus from the user's tab, and the tab renders
44
44
  // (verified headed on Linux and macOS).
45
- const result = await this.#connection.cdp.send("Target.createTarget", { url, background: true, newWindow: true }, undefined, { capability: CAPABILITY });
45
+ const result = await this.#connection.cdp.send("Target.createTarget", {
46
+ url: "about:blank", background: true, newWindow: true,
47
+ ...(options.browserContextId ? { browserContextId: options.browserContextId } : {}),
48
+ }, undefined, { capability: CAPABILITY });
46
49
  const targetId = result.targetId;
47
50
  // CloakBrowser headless defers renderer startup for background targets until
48
51
  // activation; activating before attach avoids Page.enable timing out.
49
52
  if (await this.#isHeadless()) await this.#connection.cdp.send("Target.activateTarget", { targetId });
53
+ // Finish session/domain setup on a stable document before starting a
54
+ // navigation that can replace the renderer or its execution contexts.
55
+ const tab = await this.adopt(targetId, { viewport });
56
+ if (url !== "about:blank") await tab.page.goto(url);
57
+ return tab;
58
+ }
59
+
60
+ async adopt(targetId, options = {}) {
61
+ if (this.#disposed) throw Error("Agent tab manager is disposed");
62
+ const existing = this.#owned.get(targetId);
63
+ if (existing) return this.#public(existing);
64
+ const viewport = { ...this.viewport, ...(options.viewport ?? {}) };
50
65
  const record = { targetId, page: null, viewport: Object.freeze({ ...viewport }), repinQueue: Promise.resolve() };
51
66
  this.#owned.set(targetId, record);
52
67
  try {
@@ -147,6 +162,10 @@ export class AgentTabManager {
147
162
  }
148
163
  }
149
164
 
165
+ export function getAgentTabs(connection) {
166
+ return managers.get(connection);
167
+ }
168
+
150
169
  export function createAgentTabs(connection, options = {}) {
151
170
  const current = managers.get(connection);
152
171
  if (current) {
@@ -0,0 +1,47 @@
1
+ // Self-contained because role locator queries serialize this into the frame's isolated world.
2
+ // Port of Playwright's isElementHiddenForAria (packages/injected/src/roleUtils.ts): getByRole skips the elements it
3
+ // reports unless includeHidden is set. `cache` memoizes the ancestor walk for one query.
4
+ export function isElementHiddenForAria(element, cache) {
5
+ const getStyle = node => node.ownerDocument?.defaultView?.getComputedStyle(node);
6
+ const isVisibleTextNode = text => {
7
+ const range = text.ownerDocument.createRange();
8
+ range.selectNode(text);
9
+ const rect = range.getBoundingClientRect();
10
+ return rect.width > 0 && rect.height > 0;
11
+ };
12
+ const belongsToDisplayNoneOrAriaHiddenOrNonSlotted = node => {
13
+ let hidden = cache.get(node);
14
+ if (hidden === undefined) {
15
+ // Light-DOM children of a shadow host render only when a slot takes them.
16
+ hidden = !!(node.parentElement && node.parentElement.shadowRoot && !node.assignedSlot);
17
+ if (!hidden) {
18
+ const style = getStyle(node);
19
+ hidden = !style || style.display === "none" || node.getAttribute("aria-hidden")?.toLowerCase() === "true";
20
+ }
21
+ if (!hidden) {
22
+ const parent = node.parentElement ?? (node.parentNode?.nodeType === 11 ? node.parentNode.host : null);
23
+ if (parent) hidden = belongsToDisplayNoneOrAriaHiddenOrNonSlotted(parent);
24
+ }
25
+ cache.set(node, hidden);
26
+ }
27
+ return hidden;
28
+ };
29
+ // A form's named controls can shadow its tagName.
30
+ const tagName = typeof element.tagName === "string" ? element.tagName.toUpperCase() : "FORM";
31
+ if (["STYLE", "SCRIPT", "NOSCRIPT", "TEMPLATE"].includes(tagName)) return true;
32
+ const style = getStyle(element);
33
+ const isSlot = element.nodeName === "SLOT";
34
+ if (style?.display === "contents" && !isSlot) {
35
+ // display:contents is not rendered itself, but its child nodes are.
36
+ for (let child = element.firstChild; child; child = child.nextSibling) {
37
+ if (child.nodeType === 1 && !isElementHiddenForAria(child, cache)) return false;
38
+ if (child.nodeType === 3 && isVisibleTextNode(child)) return false;
39
+ }
40
+ return true;
41
+ }
42
+ // <option> inside <select> and <slot> ignore visibility and content-visibility; checkVisibility() covers
43
+ // content-visibility and closed <details> up the flat tree.
44
+ const isOptionInsideSelect = element.nodeName === "OPTION" && !!element.closest("select");
45
+ if (!isOptionInsideSelect && !isSlot && style && (!element.checkVisibility() || style.visibility !== "visible")) return true;
46
+ return belongsToDisplayNoneOrAriaHiddenOrNonSlotted(element);
47
+ }
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import path from "node:path";
3
- import { mkdir, open, readFile, rename, lstat, chmod } from "node:fs/promises";
3
+ import { mkdir, open, readFile, readlink, realpath, rename, lstat, chmod } from "node:fs/promises";
4
4
  import { homedir } from "node:os";
5
5
  import { TextDecoder } from "node:util";
6
6
  import { createChromeApi as createStandaloneChromeApi } from "./chrome.js";
@@ -46,7 +46,33 @@ const NATIVE_HOST_DIRS = {
46
46
  linux: { chrome: [".config", "google-chrome"], chromium: [".config", "chromium"] },
47
47
  };
48
48
  export function defaultNativeMessagingHostDir(browser = "chrome", platform = process.platform) { if (platform === "win32") { if (!WIN32_REGISTRY_KEYS[browser]) throw new BridgeProtocolError("custom browser requires nativeMessagingHostDir"); return path.win32.join(process.env.LOCALAPPDATA || path.win32.join(homedir(), "AppData", "Local"), "omowright", "NativeMessagingHosts", browser); } const byBrowser = NATIVE_HOST_DIRS[platform]; if (!byBrowser) throw new BridgeProtocolError(`no default nativeMessagingHostDir on ${platform}; pass nativeMessagingHostDir`); const segments = byBrowser[browser]; if (!segments) throw new BridgeProtocolError("custom browser requires nativeMessagingHostDir"); return path.join(homedir(), ...segments, "NativeMessagingHosts"); }
49
- async function secureDirectory(dir) { const absolute = path.resolve(dir); const parts = absolute.split(path.sep).filter(Boolean); let current = path.parse(absolute).root; let final; for (const [index, part] of parts.entries()) { current = path.join(current, part); let info = await lstat(current).catch(() => null); if (!info) { await mkdir(current, { mode: 0o700 }); info = await lstat(current); } if (current !== "/var" && (info.isSymbolicLink() || !info.isDirectory())) throw new BridgeProtocolError("nativeMessagingHostDir security rejected"); if (current !== "/var" && info.uid !== process.getuid?.() && info.uid !== 0) throw new BridgeProtocolError("nativeMessagingHostDir ownership rejected"); const stickyRootAncestor = index < parts.length - 1 && info.uid === 0 && (info.mode & 0o1000) !== 0; if (current !== "/var" && !stickyRootAncestor && (info.mode & 0o022) !== 0) throw new BridgeProtocolError("nativeMessagingHostDir security rejected"); final = info; } if (!final || (final.uid !== process.getuid?.() && final.uid !== 0)) throw new BridgeProtocolError("nativeMessagingHostDir ownership rejected"); if ((final.mode & 0o077) !== 0) await chmod(absolute, 0o700); }
49
+ async function secureDirectory(dir) {
50
+ const absolute = path.resolve(dir); const parts = absolute.split(path.sep).filter(Boolean);
51
+ let current = path.parse(absolute).root; let final;
52
+ while (parts.length) {
53
+ current = path.join(current, parts.shift());
54
+ let info = await lstat(current).catch(() => null);
55
+ if (!info) { await mkdir(current, { mode: 0o700 }); info = await lstat(current); }
56
+ if (info.isSymbolicLink()) {
57
+ if (process.platform !== "darwin" || !["/tmp", "/var", "/etc"].includes(current) || info.uid !== 0) throw new BridgeProtocolError(`nativeMessagingHostDir security rejected at ${current}: symlink is not a root-owned macOS system alias`);
58
+ let target, resolved;
59
+ try { target = await readlink(current); resolved = await realpath(current); }
60
+ catch (error) { throw new BridgeProtocolError(`nativeMessagingHostDir security rejected at ${current}: system alias could not be resolved (${error.code ?? error.message})`); }
61
+ if (!resolved.startsWith("/private/")) throw new BridgeProtocolError(`nativeMessagingHostDir security rejected at ${current}: system alias target is outside /private`);
62
+ // Walk the target from its root too: resolving the entire path would hide unsafe components.
63
+ parts.unshift(...target.split(path.sep).filter(Boolean));
64
+ current = path.isAbsolute(target) ? path.parse(target).root : path.dirname(current);
65
+ continue;
66
+ }
67
+ if (!info.isDirectory()) throw new BridgeProtocolError(`nativeMessagingHostDir security rejected at ${current}: not a directory`);
68
+ if (info.uid !== process.getuid?.() && info.uid !== 0) throw new BridgeProtocolError(`nativeMessagingHostDir ownership rejected at ${current}: not owned by the current user or root`);
69
+ const stickyRootAncestor = parts.length > 0 && info.uid === 0 && (info.mode & 0o1000) !== 0;
70
+ if (!stickyRootAncestor && (info.mode & 0o022) !== 0) throw new BridgeProtocolError(`nativeMessagingHostDir security rejected at ${current}: writable by others`);
71
+ final = info;
72
+ }
73
+ if (!final || (final.uid !== process.getuid?.() && final.uid !== 0)) throw new BridgeProtocolError(`nativeMessagingHostDir ownership rejected at ${current}: not owned by the current user or root`);
74
+ if ((final.mode & 0o077) !== 0) await chmod(absolute, 0o700);
75
+ }
50
76
  async function secureExecutable(hostPath) { const info = await lstat(hostPath).catch(() => null); if (!info?.isFile() || info.isSymbolicLink() || info.uid !== process.getuid?.() || (info.mode & 0o111) === 0 || (info.mode & 0o022) !== 0) throw new BridgeProtocolError("hostPath must be a securely owned executable file"); }
51
77
  export async function installNativeMessagingHost({ hostName = HOST_NAME, hostPath, extensionId, browser = "chrome", nativeMessagingHostDir, force = false, endpointPath, registryKey } = {}) { const win32 = process.platform === "win32"; if (endpointPath !== undefined) throw new BridgeProtocolError("endpointPath is not supported"); if (hostName !== HOST_NAME || !/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/.test(hostName)) throw new BridgeProtocolError("invalid hostName"); if (!path.isAbsolute(hostPath ?? "")) throw new BridgeProtocolError("hostPath must be absolute"); if (!win32) await secureExecutable(hostPath); if (!/^[a-p]{32}$/.test(extensionId ?? "")) throw new BridgeProtocolError("invalid extensionId"); if (!nativeMessagingHostDir && browser === "cloakbrowser") throw new BridgeProtocolError("CloakBrowser nativeMessagingHostDir must be explicit and verified"); if (registryKey !== undefined && !win32) throw new BridgeProtocolError("registryKey is only used on win32"); const dir = nativeMessagingHostDir ?? defaultNativeMessagingHostDir(browser);
52
78
  const manifest = { name: hostName, description: "OmOWright internal CloakBrowser native messaging bridge.", path: hostPath, type: "stdio", allowed_origins: [`chrome-extension://${extensionId}/`] };
@@ -0,0 +1,105 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { cookieToCdp } from "./cookies.js";
4
+ import { createAgentTabs, getAgentTabs } from "./agent-tabs.js";
5
+
6
+ export class BrowserContext {
7
+ #connection;
8
+ #scope;
9
+ #origins = new Set();
10
+
11
+ constructor(connection, browserContextId) {
12
+ this.#connection = connection;
13
+ this.#scope = browserContextId ? { browserContextId } : {};
14
+ }
15
+
16
+ trackOrigin(url) {
17
+ if (!/^https?:\/\//.test(url ?? "")) return;
18
+ this.#origins.add(new URL(url).origin);
19
+ }
20
+
21
+ async cookies(urls = []) {
22
+ const { cookies } = await this.#connection.cdp.send("Storage.getCookies", this.#scope);
23
+ const parsed = (typeof urls === "string" ? [urls] : urls).map(url => new URL(url));
24
+ return cookies.filter(cookie => !parsed.length || parsed.some(url => {
25
+ const domain = cookie.domain.startsWith(".") ? cookie.domain.slice(1) : cookie.domain;
26
+ if (url.hostname !== domain && !(cookie.domain.startsWith(".") && url.hostname.endsWith(`.${domain}`))) return false;
27
+ if (cookie.secure && url.protocol !== "https:" && url.hostname !== "localhost") return false;
28
+ const pathname = cookie.path.endsWith("/") ? cookie.path : `${cookie.path}/`;
29
+ return url.pathname === cookie.path || `${url.pathname}/`.startsWith(pathname);
30
+ })).map(cookie => {
31
+ const { name, value, domain, path, expires, httpOnly, secure } = cookie;
32
+ const out = { name, value, domain, path, expires, httpOnly, secure, sameSite: cookie.sameSite ?? "Lax" };
33
+ if (cookie.partitionKey) out.partitionKey = cookie.partitionKey.topLevelSite;
34
+ return out;
35
+ });
36
+ }
37
+
38
+ async addCookies(cookies) {
39
+ const normalized = cookies.map(cookie => {
40
+ if (typeof cookie.name !== "string" || typeof cookie.value !== "string") {
41
+ throw new TypeError("Cookie name and value must be strings");
42
+ }
43
+ if (cookie.url !== undefined) {
44
+ if (cookie.domain !== undefined || cookie.path !== undefined) throw new Error("Cookie must have either url or domain and path");
45
+ const url = new URL(cookie.url);
46
+ if (!/^https?:$/.test(url.protocol)) throw new Error("Cookie url must be HTTP or HTTPS");
47
+ return cookieToCdp({
48
+ ...cookie, domain: url.hostname,
49
+ path: url.pathname.slice(0, url.pathname.lastIndexOf("/") + 1),
50
+ secure: cookie.secure ?? url.protocol === "https:",
51
+ });
52
+ }
53
+ if (!cookie.domain || !cookie.path) throw new Error("Cookie must have either url or domain and path");
54
+ return cookieToCdp(cookie);
55
+ });
56
+ await this.#connection.cdp.send("Storage.setCookies", { ...this.#scope, cookies: normalized });
57
+ }
58
+
59
+ async clearCookies(options = {}) {
60
+ const filters = Object.entries(options).filter(([key]) => ["name", "domain", "path"].includes(key));
61
+ if (!filters.length) {
62
+ await this.#connection.cdp.send("Storage.clearCookies", this.#scope);
63
+ return;
64
+ }
65
+ // Storage.clearCookies is context scoped. Reinstall survivors rather than
66
+ // issuing a browser-global Network.deleteCookies for another context.
67
+ const survivors = (await this.cookies()).filter(cookie => !filters.every(([key, filter]) =>
68
+ filter instanceof RegExp
69
+ ? new RegExp(filter.source, filter.flags.replace(/[gy]/g, "")).test(cookie[key])
70
+ : cookie[key] === filter));
71
+ await this.#connection.cdp.send("Storage.clearCookies", this.#scope);
72
+ await this.addCookies(survivors);
73
+ }
74
+
75
+ async newPage() {
76
+ return (await (getAgentTabs(this.#connection) ?? createAgentTabs(this.#connection))
77
+ .create("about:blank", this.#scope)).page;
78
+ }
79
+
80
+ async storageState(options = {}) {
81
+ const state = { cookies: await this.cookies(), origins: [] };
82
+ if (this.#origins.size) {
83
+ // Read through a blank intercepted page: an origin may no longer have an
84
+ // open frame, and visiting its real document could mutate saved storage.
85
+ const page = await this.newPage();
86
+ try {
87
+ await page.route("**/*", route => route.fulfill({ contentType: "text/html", body: "<html></html>" }));
88
+ for (const origin of this.#origins) {
89
+ await page.goto(origin, { waitUntil: "domcontentloaded" });
90
+ const { entries } = await page._sendToTarget("DOMStorage.getDOMStorageItems", {
91
+ storageId: { securityOrigin: origin, isLocalStorage: true },
92
+ });
93
+ if (entries.length) state.origins.push({ origin, localStorage: entries.map(([name, value]) => ({ name, value })) });
94
+ }
95
+ } finally {
96
+ await page.close();
97
+ }
98
+ }
99
+ if (options.path !== undefined) {
100
+ await mkdir(path.dirname(path.resolve(options.path)), { recursive: true });
101
+ await writeFile(options.path, JSON.stringify(state, null, 2));
102
+ }
103
+ return state;
104
+ }
105
+ }
@@ -7,7 +7,7 @@ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7
7
  import path from "node:path";
8
8
  import { setTimeout as sleep } from "node:timers/promises";
9
9
  import { isPidAlive } from "./instance-lock.js";
10
- import { ownProcessStartTime, processStartTime } from "./lock-file.js";
10
+ import { ownProcessStartTime, processStartTime } from "./process-start-time.js";
11
11
 
12
12
  export const TERM_GRACE_MS = 5_000;
13
13
  const PID_FILE_NAME = "omowright-browser.pid";
@@ -35,6 +35,11 @@ export function profileDirFromArgs(browserArgs) {
35
35
  const signalsCanAskToQuit = process.platform !== "win32";
36
36
 
37
37
  export async function terminateChild(child, { quitRequested = false } = {}) {
38
+ // No pid means the spawn itself failed (e.g. ENOENT): there is no process to
39
+ // end. Neither runtime emits "exit" for such a child; node at least sets a
40
+ // negative exitCode, but bun leaves it null, so the wait below would hang
41
+ // forever (#154).
42
+ if (child.pid === undefined) return;
38
43
  if (child.exitCode !== null || child.signalCode !== null) return;
39
44
  const exited = new Promise((resolve) => child.once("exit", resolve));
40
45
  if (signalsCanAskToQuit) {