omowright 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +282 -2
- package/TOOLS.md +366 -0
- package/bin/omowright-cloak.mjs +112 -0
- package/package.json +61 -4
- package/presets/agent-events/SKILL.md +75 -0
- package/presets/captcha/SKILL.md +129 -0
- package/presets/chrome/SKILL.md +84 -0
- package/presets/cloak-bridge/SKILL.md +43 -0
- package/presets/network/SKILL.md +126 -0
- package/presets/visual-browse/SKILL.md +103 -0
- package/skills/omowright/SKILL.md +193 -0
- package/skills/omowright/references/1password.md +118 -0
- package/skills/omowright/references/browserskill.md +186 -0
- package/skills/omowright/references/eval-kernel.md +100 -0
- package/skills/omowright/references/frames-layers-human.md +123 -0
- package/skills/omowright/references/quickstart.md +96 -0
- package/skills/omowright/references/stealth.md +174 -0
- package/src/agent-tabs.js +160 -0
- package/src/bridge-schemas.js +44 -0
- package/src/bridge-transport.js +57 -0
- package/src/browser-process.js +122 -0
- package/src/bsk/browser-signals.js +90 -0
- package/src/bsk/browsers.js +114 -0
- package/src/bsk/connect.js +45 -0
- package/src/bsk/daemon-info.js +100 -0
- package/src/bsk/external-extension.js +110 -0
- package/src/bsk/identify-browser.js +88 -0
- package/src/bsk/install-cli.js +81 -0
- package/src/bsk/ipc-client.js +236 -0
- package/src/bsk/onboard.js +133 -0
- package/src/bsk/screenshot.js +49 -0
- package/src/bsk/session.js +131 -0
- package/src/bsk/snapshot.js +56 -0
- package/src/bsk/targets.js +25 -0
- package/src/captcha-wait.js +74 -0
- package/src/captcha.js +142 -0
- package/src/cdp-errors.js +23 -0
- package/src/cdp-methods.js +61 -0
- package/src/chrome-profile.js +176 -0
- package/src/chrome.js +192 -0
- package/src/cloak-profile.js +266 -0
- package/src/connection.js +135 -0
- package/src/cookies.js +29 -0
- package/src/core.js +1710 -0
- package/src/cua.js +74 -0
- package/src/dialog-policy.js +80 -0
- package/src/emulate.js +127 -0
- package/src/events.js +111 -0
- package/src/frames-snapshot.js +138 -0
- package/src/har.js +103 -0
- package/src/human-handoff.js +122 -0
- package/src/index.js +86 -0
- package/src/injected.js +3 -0
- package/src/instance-lock.js +230 -0
- package/src/instances.js +493 -0
- package/src/internal-capability.js +1 -0
- package/src/launch-endpoint.js +185 -0
- package/src/layers.js +138 -0
- package/src/llm.js +201 -0
- package/src/lock-file.js +130 -0
- package/src/native-host-win32.js +201 -0
- package/src/network-events.js +201 -0
- package/src/network-snoop.js +229 -0
- package/src/open-shadow-query.js +22 -0
- package/src/owner-only.js +109 -0
- package/src/page-bundle.js +1397 -0
- package/src/page-routes.js +94 -0
- package/src/pipe.js +391 -0
- package/src/routes.js +256 -0
- package/src/running-browser.js +85 -0
- package/src/scroll-collect.js +73 -0
- package/src/serial-emitter.js +17 -0
- package/src/shared-connections.js +278 -0
- package/src/snapshot-diff.js +75 -0
- package/src/trace.js +183 -0
- package/src/url-match.js +148 -0
- package/src/viewport.js +12 -0
package/TOOLS.md
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
# OmOWright tools — agent-facing reference
|
|
2
|
+
|
|
3
|
+
Drive a browser with Playwright-shaped JS. Two transports: `connectPipe`
|
|
4
|
+
(launch a browser, zero TCP port) and `connect(cdpHttpUrl)` (attach to a
|
|
5
|
+
running Chromium DevTools endpoint).
|
|
6
|
+
|
|
7
|
+
## Core loop
|
|
8
|
+
|
|
9
|
+
1. Open or attach a tab: `connection.newTab(url)` / `connection.attachPage(targetId)`.
|
|
10
|
+
2. Read the page with `page.snapshot()` — never `page.content()` for reading.
|
|
11
|
+
3. Act through `page.locator(refOrCss)` using `[ref=eN]` ids from the snapshot.
|
|
12
|
+
|
|
13
|
+
## Tools
|
|
14
|
+
|
|
15
|
+
- `newTab(url)` — open a tab, waits for interactivity, returns page.
|
|
16
|
+
- `listTargets()` — list open tabs (id, type, url, title).
|
|
17
|
+
- `attachPage(targetId)` — attach an existing tab.
|
|
18
|
+
- `page.goto(url)` — navigate; resolves when interactive.
|
|
19
|
+
- `page.waitForURL(url, { timeout?, waitUntil? })` — wait until the page URL
|
|
20
|
+
matches a Playwright glob (`**` crosses `/`, `*` does not, `{a,b}` is a
|
|
21
|
+
choice, `?` is a literal question mark), a RegExp, or a predicate
|
|
22
|
+
`(url: URL) => boolean`. With `waitUntil` it then waits for that load state;
|
|
23
|
+
without it, it returns as soon as the URL matches.
|
|
24
|
+
- `page.waitForLoadState(state, { timeout? })` — `domcontentloaded` and `load`
|
|
25
|
+
wait for those document events; `networkidle` waits until no request has been
|
|
26
|
+
in flight for 500 ms (requests already running when the wait starts are not
|
|
27
|
+
seen); `interactive` (default) and `stable` use the `goto` readiness probe.
|
|
28
|
+
- `page.snapshot(options?)` — PRIMARY read. Returns `{tree, refs}`; tree lines
|
|
29
|
+
look like `- link "Learn more" [ref=e1]`. Options: `maxDepth` (50),
|
|
30
|
+
`maxChars`, `interactive`, `showHidden`, `selector`, `ref`.
|
|
31
|
+
- `compactSnapshot(snapshot)` — returns the raw tree without the refs map
|
|
32
|
+
(refs resolve in-page; the map is ~54% of bytes on real pages). Use before
|
|
33
|
+
sending snapshots to a model.
|
|
34
|
+
- `page.locator(refOrCss)` — `click`, `fill`, `press`, `pressSequentially`,
|
|
35
|
+
`hover`, `check`, `selectOption`, `dragTo`, `setInputFiles`, `textContent`,
|
|
36
|
+
`innerText`, `isVisible`, `waitFor`, `first/nth/last`, `filter`.
|
|
37
|
+
- `page.getByRole(role, options?)`, `getByText(text, { exact })`,
|
|
38
|
+
`getByLabel(text, { exact })`, `getByPlaceholder(text, { exact })`,
|
|
39
|
+
`getByAltText(text, { exact })`, `getByTitle(text, { exact })`,
|
|
40
|
+
`getByTestId(testId)` — Playwright locators. Frames (`page.frames()`,
|
|
41
|
+
`page.mainFrame()`), frame locators (`page.frameLocator(css)`) and locators
|
|
42
|
+
(`page.locator(css).getByTestId(id)`, scoped to that locator) have the same
|
|
43
|
+
getters. They match inside open shadow roots, never inside closed ones.
|
|
44
|
+
For placeholder, alt text and title, a string matches a
|
|
45
|
+
case-insensitive substring of the attribute, `exact: true` the whole
|
|
46
|
+
case-sensitive value, and a RegExp the raw value. `getByTestId` matches
|
|
47
|
+
`data-testid` exactly (or by RegExp); `selectors.setTestIdAttribute(name)`
|
|
48
|
+
switches the attribute for locators created afterwards.
|
|
49
|
+
- `page.evaluate(expression)` — run JS in the page.
|
|
50
|
+
- `page.waitForRequest(urlOrPredicate, { timeout? })` /
|
|
51
|
+
`page.waitForResponse(urlOrPredicate, { timeout? })` — wait for the next
|
|
52
|
+
matching request or response headers (default timeout: 30000ms). Match an
|
|
53
|
+
exact URL string, a RegExp, or a sync/async predicate over the object.
|
|
54
|
+
Register the wait before triggering the request.
|
|
55
|
+
- `page.on("request" | "response", listener)` — observe traffic; the returned
|
|
56
|
+
function unsubscribes, as does `page.off(event, listener)`. Both waits and
|
|
57
|
+
listeners receive objects with `url()`, `method()`, `headers()` (lowercase
|
|
58
|
+
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.
|
|
61
|
+
Bodies are cached on completion for response objects delivered to listeners.
|
|
62
|
+
If the transport refuses `Network.getResponseBody`, these reads reject with
|
|
63
|
+
the exported `NetworkBodyUnavailableError` (the transport error is `cause`),
|
|
64
|
+
never `null`. Failed transfers and redirects also reject body reads.
|
|
65
|
+
Network subscriptions and domain ownership are shared with
|
|
66
|
+
`createNetworkSnoop()` and readiness tracking. They start on demand and
|
|
67
|
+
release after the last consumer and its pending response bodies finish;
|
|
68
|
+
no Runtime domain is enabled. A refused Network enable does not break page
|
|
69
|
+
setup, but a transport that emits no network events will time out waits.
|
|
70
|
+
- `page.screenshot(options?)` — image bytes (path, fullPage, clip, type, quality).
|
|
71
|
+
- `page.pdf(options?)` — PDF bytes (path, format, margin, printBackground).
|
|
72
|
+
- `page.keyboard` / `page.mouse` — press, type, insertText / move, click, wheel.
|
|
73
|
+
- `createCua(page)` — coordinate fallback (visual-browse equivalent): `click`,
|
|
74
|
+
`doubleClick`, `drag({path})`, `move`, `scroll`, `type`, `keypress`,
|
|
75
|
+
`getVisibleScreenshot()` (base64 PNG). Use only when refs/locators cannot
|
|
76
|
+
target the UI (canvas, custom controls, stale refs).
|
|
77
|
+
- `createCaptcha(page, { ocr? })` — input, OCR, and explicit condition helpers,
|
|
78
|
+
not a general CAPTCHA solver. `click(bounds, opts?)` defaults to the center;
|
|
79
|
+
optional `opts.point` is an absolute top-level viewport CSS-pixel point inside
|
|
80
|
+
the bounds. Positive integer `opts.approachSteps` adds intermediate movement,
|
|
81
|
+
not a human-likeness guarantee. Re-measure after scrolling/resizing; iframe
|
|
82
|
+
bounds alone do not locate a checkbox. `drag(from, to, {steps?, settleMs?})`
|
|
83
|
+
defaults to 20 steps. Both return a compact snapshot tree string after
|
|
84
|
+
settling (`settleMs` defaults to 3000ms, allows 0), not proof of acceptance.
|
|
85
|
+
`waitFor({until, timeoutMs = 10000, pollMs = 100, signal?})` separately returns
|
|
86
|
+
`{outcome: "matched" | "timed_out" | "cancelled", elapsedMs}`, with no tree.
|
|
87
|
+
Use `click(bounds, {settleMs: 0})`, then an application-specific acceptance
|
|
88
|
+
predicate: only literal `true` matches. Checks are serial under one deadline;
|
|
89
|
+
abort takes priority over timeout, then match. Predicate errors propagate;
|
|
90
|
+
cancellation cannot retract dispatched input/requests or interrupt blocking
|
|
91
|
+
synchronous code. Take `page.screenshot()` separately for visual evidence.
|
|
92
|
+
`readText(bounds?)` OCRs a screenshot region and returns text or `null`, never
|
|
93
|
+
a tree. It defaults to macOS Vision (`macOSVisionOcr`); pass
|
|
94
|
+
`ocr: async (pngBuffer) => string` on other platforms or to use a vision model.
|
|
95
|
+
Full bounds, timing, cancellation, and acceptance examples:
|
|
96
|
+
[CAPTCHA skill](presets/captcha/SKILL.md).
|
|
97
|
+
- `createChromeApi(connection, { profilePath?, downloadDir? })` — Chrome
|
|
98
|
+
MV3-shaped APIs: `tabs.query/get`, `windows.get/getCurrent/getLastFocused/
|
|
99
|
+
getAll`, `bookmarks.*` (read-only), `history.search/getVisits`,
|
|
100
|
+
`downloads.search/download`, `topSites.get`. Profile-backed methods need
|
|
101
|
+
`profilePath`. Write methods throw `UnsupportedOperationError` (extension
|
|
102
|
+
bridge required). Full reference: presets/chrome/.
|
|
103
|
+
- `injectCookies(page, cookies)` — inject raw cookie exports (e.g. from a
|
|
104
|
+
real browser profile) with CDP sanitization handled: negative `expires`
|
|
105
|
+
dropped, `__Host-` cookies forced secure + root path + url-scoped,
|
|
106
|
+
`SameSite=None` dropped when not secure, name+domain deduped.
|
|
107
|
+
`sanitizeCookies(cookies)` is the pure transform if you need it.
|
|
108
|
+
|
|
109
|
+
Every tool below is exported from `src/index.js`, the same import as the core
|
|
110
|
+
loop; the module files next to it are implementation detail.
|
|
111
|
+
|
|
112
|
+
- `connectNamed(name, { browserPath, browserArgs, profileDir, registryRoot?,
|
|
113
|
+
dialogPolicy?, probeTimeoutMs?, launchTimeoutMs?, connectTimeoutMs?,
|
|
114
|
+
lockTimeoutMs? })`:
|
|
115
|
+
attach-or-launch a named Chromium. A healthy registered instance is attached;
|
|
116
|
+
a stale record is cleaned up and relaunched; a live pid whose recorded port
|
|
117
|
+
refuses connections, or answers as a different browser, is treated as a reused
|
|
118
|
+
pid (stale → relaunch), while an endpoint that hangs or answers wrongly throws
|
|
119
|
+
an `unresponsive holder` error naming the holder (name, pid, endpoint). The
|
|
120
|
+
record stores the browser's `webSocketDebuggerUrl` (it carries the browser
|
|
121
|
+
GUID) and an attach happens only while the endpoint still answers with it, so
|
|
122
|
+
a reused pid plus a rebound port cannot hand you a stranger's browser. Every
|
|
123
|
+
wait is bounded: discovery by `probeTimeoutMs`, the launch by
|
|
124
|
+
`launchTimeoutMs`, the CDP handshake by `connectTimeoutMs`, the registry lock
|
|
125
|
+
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).
|
|
129
|
+
**The named endpoint is unauthenticated.** CDP listens on 127.0.0.1 with a
|
|
130
|
+
kernel-chosen port: off the network, but any local process or user can drive
|
|
131
|
+
that browser. Name-less launches (`connectPipe`, `connectCloakProfile()`
|
|
132
|
+
without `name`) expose no port at all.
|
|
133
|
+
`newTab()` works on both paths; `close()` from the launcher terminates the
|
|
134
|
+
browser and removes its record, from an attached client it only detaches.
|
|
135
|
+
Attaches in one process share one CDP connection per browser, because
|
|
136
|
+
Chrome asks the user to allow remote debugging once per connection: each
|
|
137
|
+
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
|
|
139
|
+
with another GUID always gets its own connection. Callers passing different
|
|
140
|
+
connection options (storage root, client options, `dialogPolicy`) are not
|
|
141
|
+
shared. A holder never changes what another holder gets: on a shared handle
|
|
142
|
+
`setDialogPolicy` throws `SharedConnectionError` (`error.code ===
|
|
143
|
+
"shared_connection"`; pass `dialogPolicy` when attaching instead), a sole holder's `setDialogPolicy` works and that
|
|
144
|
+
connection is never shared again, properties set on a handle stay on it,
|
|
145
|
+
writing or defining `cdp`, `close` or `setDialogPolicy` on a handle throws
|
|
146
|
+
`TypeError`, the shared client can't be written through it, and listeners
|
|
147
|
+
added through `handle.cdp` are removed by that handle's `close()`.
|
|
148
|
+
`handle.cdp.transportEvents.clearListeners()` removes only that handle's
|
|
149
|
+
transport listeners, and `handle.cdp.transportEvents.emit()` throws
|
|
150
|
+
`TypeError`. The connection keeps a frozen copy of the options it was
|
|
151
|
+
attached with, so mutating your options object after attaching changes
|
|
152
|
+
nothing. `handle.cdp.dialogPolicy` on a shared connection is that frozen
|
|
153
|
+
copy (or a frozen default when you passed none), not your object, so it
|
|
154
|
+
can't be changed in place. `setDialogPolicy(undefined)` resets to the default (accept every
|
|
155
|
+
dialog).
|
|
156
|
+
`listInstances()` returns every record (`{ name, pid, endpoint,
|
|
157
|
+
webSocketDebuggerUrl, profileDir, browserPath, startedAt }`) with `alive` /
|
|
158
|
+
`responsive` liveness.
|
|
159
|
+
- `createNetworkSnoop(page, { match?, bodies=true, maxEntries=500, maxBodyBytes? })`:
|
|
160
|
+
buffer finished network entries for one page. `match` is a predicate or
|
|
161
|
+
`{ url: string|RegExp, method, mimeType, resourceType }`. Methods: `pop()`
|
|
162
|
+
(drain), `peek()` (copy), `popJson()` (drain and parse JSON bodies),
|
|
163
|
+
`waitFor(match, { timeoutMs })` (resolves with the next matching entry),
|
|
164
|
+
`summary({ max })` (one line per entry: method status mime bytes url),
|
|
165
|
+
`dispose()`. Entries carry `requestId, url, method, resourceType, status,
|
|
166
|
+
statusText, mimeType, requestHeaders, responseHeaders, postData,
|
|
167
|
+
encodedDataLength, body, base64Encoded, bodySkipped, failed, errorText,
|
|
168
|
+
startedAt, finishedAt`.
|
|
169
|
+
- `collectWhileScrolling(page, snoop, { minItems, maxScrolls=10, extract, scroll:
|
|
170
|
+
"wheel"|"end", settleMs=800 })`: async generator. Each round scrolls, settles, drains
|
|
171
|
+
`snoop.popJson()` through `extract(json) => items[]`, yield each item. Returns
|
|
172
|
+
`{ rounds, total, stoppedBecause: "minItems"|"maxScrolls"|"noGrowth" }`.
|
|
173
|
+
- `createTrace(page, { dir, screenshots=true, network=true, console=true,
|
|
174
|
+
maxBodyBytes?, events? })`: flight recorder. `step(name, fn)` runs `fn` with
|
|
175
|
+
before/after screenshots and timing, `mark(name, data)` drops a marker,
|
|
176
|
+
`stop()` flushes and returns the summary. Writes `dir/trace.jsonl` (kinds:
|
|
177
|
+
step, network, console, dialog, navigation, download, mark, warning),
|
|
178
|
+
`dir/trace.har` (HAR 1.2), `dir/summary.json`, and
|
|
179
|
+
`dir/screenshots/<seq>-<slug>-before|after.png`. `trace.dir` is the resolved
|
|
180
|
+
directory. Never sends `Runtime.enable`.
|
|
181
|
+
- `toHar(entries, { creator?, pages? })`: pure HAR 1.2 builder over snoop entries.
|
|
182
|
+
- `reconcileFrames(page)`: re-links OOPIF child frames that lost their parent;
|
|
183
|
+
returns the frames it added. `snapshotWithFrames(page, opts?)`: snapshot that
|
|
184
|
+
runs the repair first and adds `missingFrames` only when a frame could not be
|
|
185
|
+
entered at all. Details in "Frames (OOPIF) and shadow DOM" below.
|
|
186
|
+
- `requestHuman(page, { prompt, until?, timeoutMs=300000, pollMs=500, signal? })`:
|
|
187
|
+
bring the window to front, show a shadow-DOM banner with a Done button, and
|
|
188
|
+
wait. `until` is `{ url: string|RegExp }`, `{ selector }`, or
|
|
189
|
+
`async (page) => boolean`. Resolves `{ outcome: "continued"|"timed_out"|
|
|
190
|
+
"cancelled", elapsedMs, reason: "until"|"done-button"|"timed_out"|"signal" }`.
|
|
191
|
+
The banner is removed on every path.
|
|
192
|
+
- `describeLayers(page, { grid=5 })`: hit-test a grid over the viewport and
|
|
193
|
+
report `{ blocking: null | { tagName, role, name, coverage, position,
|
|
194
|
+
selectorHint, ariaModal }, candidates, viewport }`. `layersHeader(result)`
|
|
195
|
+
renders `@layers none` or `@layers blocking=<role|tag> "<name>" coverage=NN%
|
|
196
|
+
hint=<sel>`. `snapshotWithLayers(page, opts?)` prepends that header to
|
|
197
|
+
`tree` and adds a `layers` field.
|
|
198
|
+
- `DEVICE_PRESETS` (`"iphone-14"` 390x844 @3x touch, `"pixel-7"` 412x915,
|
|
199
|
+
`"ipad-air"` 820x1180, `"desktop-1440"` 1440x900) and
|
|
200
|
+
`emulate(page, nameOrPreset)`: set metrics, touch, and UA together;
|
|
201
|
+
`emulate(page, null)` clears the override and restores the UA captured on the
|
|
202
|
+
first call.
|
|
203
|
+
- `page.route(urlGlobOrRegExpOrPredicate, handler, { times }?)`,
|
|
204
|
+
`page.unroute(url, handler?)`, `page.unrouteAll()`: request interception.
|
|
205
|
+
Strings match the whole URL: `*` excludes `/`, `**` crosses directories,
|
|
206
|
+
`{png,jpg}` matches alternatives, and `?` is literal. Predicates receive
|
|
207
|
+
a `URL`. The newest matching handler runs first; `route.fallback()` passes
|
|
208
|
+
to the next match, while `route.continue({ url, method, headers, postData })`
|
|
209
|
+
sends directly to the network. Handlers receive `(route, request)`;
|
|
210
|
+
`route.request()` returns that request, with `url()`, `method()`, `headers()`,
|
|
211
|
+
`postData()` and `resourceType()`. Respond with
|
|
212
|
+
`route.fulfill({ status, headers, contentType, body, json, path })` or
|
|
213
|
+
`route.abort(errorCode?)` (default `"failed"`, also `"blockedbyclient"`, etc.).
|
|
214
|
+
`times` limits matching invocations. Fetch stays off until registration and
|
|
215
|
+
is disabled after the last route is removed or exhausted. Page methods and
|
|
216
|
+
`createRoutes(page)` share one dispatcher; `unrouteAll()` clears both.
|
|
217
|
+
- `createRoutes(page)`: legacy request interception. `route(match, handler)`,
|
|
218
|
+
`unroute(match?)`, `dispose()`, `enabled`. `match` is a glob string (`*` and
|
|
219
|
+
`?`; plain substring otherwise), a RegExp, or a predicate over
|
|
220
|
+
`{ url, method, resourceType, headers }`. The handler receives `{ request,
|
|
221
|
+
continue(overrides), fulfill({ status, headers, contentType, body }),
|
|
222
|
+
abort(reason) }`. `Fetch.enable` is sent on the first `route()` only.
|
|
223
|
+
- Dialog policy: `connectPipe({ dialogPolicy })`, `connect(url, { dialogPolicy })`,
|
|
224
|
+
`new PipeCdpClient({ dialogPolicy })`, `client.setDialogPolicy(policy)`, `client.dialogPolicy`,
|
|
225
|
+
`BrowserConnection.setDialogPolicy(policy)`. Pure helpers in
|
|
226
|
+
`src/dialog-policy.js`: `normalizeDialogPolicy(policy)`,
|
|
227
|
+
`resolveDialogAction(policy, dialogParams)`. See "Dialogs" below.
|
|
228
|
+
|
|
229
|
+
## Attached engine (BrowserSkill)
|
|
230
|
+
|
|
231
|
+
- `connectBrowserSkill({ name, browser, width, height, focused, home, sockPath,
|
|
232
|
+
autoStart, timeoutMs })`: starts a session in the user's own browser through
|
|
233
|
+
the BrowserSkill daemon's IPC socket and returns a `BskSession`. `browser`
|
|
234
|
+
takes an instance id, a unique label, or a browser name such as `"chrome"`
|
|
235
|
+
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.
|
|
238
|
+
- `BskSession`: `navigate`, `back`, `forward`, `reload`, `observe`, `snapshot`,
|
|
239
|
+
`getHtml`, `screenshot({ ref, fullPage })`, `click`, `hover`, `fill`,
|
|
240
|
+
`press`, `select`, `focus`, `blur`, `scrollTo`, `wheel`, `evaluate`,
|
|
241
|
+
`tabList`, `tabCreate`, `tabClose`, `tabSelect`, `tabBorrow`, `tabReturn`,
|
|
242
|
+
`waitForNavigation`, `requestHelp`, `console`, `network`, `resize`,
|
|
243
|
+
`emulate`, `cooperate(action)`, `stop()`. Targets: `"e3"` / `"@e3"` (daemon
|
|
244
|
+
refs), a CSS selector, or `{ captureId, x, y }`. BrowserSkill 0.4 refuses
|
|
245
|
+
page actions (`cooperation_sync_required`) without `{ context }` from the
|
|
246
|
+
latest `cooperate("sync")`; `dependsOn` narrows that check
|
|
247
|
+
(`skills/omowright/references/browserskill.md`).
|
|
248
|
+
- `bskSnapshot(session, options)`: OmOWright `{ tree, refs, css }` from an
|
|
249
|
+
attached tab with no page global and no DOM mutation; `css[ref]` is `null`
|
|
250
|
+
inside shadow roots.
|
|
251
|
+
- `bskDoctor({ browser })` / `bskOnboard({ browser, onHumanStep })`: CLI install
|
|
252
|
+
(official installer, rc-file changes reverted), daemon start, then Web Store
|
|
253
|
+
extension registration through Chrome's External Extensions
|
|
254
|
+
(`registerExternalExtension` / `unregisterExternalExtension`) for the one
|
|
255
|
+
browser the user actually uses, then a wait on
|
|
256
|
+
`system.status{wait_for_browser_ms}`. The one human step is returned as
|
|
257
|
+
`humanStep`; `needsChoice: true` means nothing was registered and the user
|
|
258
|
+
has to name the browser. While the daemon is down nothing is registered,
|
|
259
|
+
`humanStep` is `null`, and `nextStep` says how to start the daemon; otherwise
|
|
260
|
+
`nextStep` is the same step as `humanStep` (`null` once ready).
|
|
261
|
+
- `identifyBrowser({ catalog, signals, explicit, connected })` /
|
|
262
|
+
`probeBrowserSignals()` / `catalogBrowsers()` / `detectBrowsers()`: the
|
|
263
|
+
browser choice on its own — the daemon's connected `browser_name`s, default
|
|
264
|
+
browser, running process and recent-use signals, ranked; ambiguity returns
|
|
265
|
+
`needsChoice` instead of a guess.
|
|
266
|
+
- `BskIpcClient` / `BskRpcError` / `readDaemonInfo` / `resolveBskHome`: the
|
|
267
|
+
raw JSON Lines IPC client (`call`, `callWithHandle`, `cancel`) for daemon
|
|
268
|
+
methods the session does not wrap.
|
|
269
|
+
|
|
270
|
+
## Rules
|
|
271
|
+
|
|
272
|
+
- Ref ids are virtual: pass them straight to `page.locator('e1')`, never into
|
|
273
|
+
CSS selectors. Every new snapshot invalidates earlier ref ids. Attached-engine
|
|
274
|
+
refs from `session.observe()` are `@eN` strings for `session.click("@e3")`;
|
|
275
|
+
`bskSnapshot` refs are clicked through `css[ref]`.
|
|
276
|
+
- `page.context()` and raw CDP `_sendToTarget` exist but are escape hatches;
|
|
277
|
+
prefer the tools above.
|
|
278
|
+
|
|
279
|
+
## Dialogs (alert / confirm / prompt / beforeunload)
|
|
280
|
+
|
|
281
|
+
Every JavaScript dialog is **answered at the transport layer**: by a `dialog`
|
|
282
|
+
listener that answers it, otherwise by a dialog policy, so the page never hangs
|
|
283
|
+
waiting for a human, including a click that triggers `window.print()`. The default policy accepts everything, which keeps
|
|
284
|
+
the old behaviour: `alert()` returns immediately, `confirm()` returns `true`,
|
|
285
|
+
`prompt()` returns `""`, `beforeunload` never blocks navigation, and dialogs
|
|
286
|
+
during page load are handled the same way (`page.goto()` still completes because
|
|
287
|
+
readiness is content-probe based).
|
|
288
|
+
|
|
289
|
+
A policy is either an object or a function:
|
|
290
|
+
|
|
291
|
+
```js
|
|
292
|
+
const browser = await connectPipe({ browserPath, browserArgs, storageRoot,
|
|
293
|
+
dialogPolicy: { accept: false } }); // confirm() -> false, prompt() -> null
|
|
294
|
+
browser.setDialogPolicy({ accept: true, promptText: "agent@example.com" }); // prompt() -> the text
|
|
295
|
+
browser.setDialogPolicy(dialog => { // { type, message, defaultPrompt, url }
|
|
296
|
+
if (dialog.type === "beforeunload") return true;
|
|
297
|
+
return { accept: !/delete/i.test(dialog.message), promptText: dialog.defaultPrompt };
|
|
298
|
+
});
|
|
299
|
+
browser.cdp.dialogPolicy; // read the current policy (client getter)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
- `{ accept: false }` dismisses: `confirm()` returns `false`, `prompt()` returns
|
|
303
|
+
`null`. `alert()` returns either way.
|
|
304
|
+
- `promptText` is the value `prompt()` resolves to when accepted.
|
|
305
|
+
- A function policy may return `boolean` or `{ accept, promptText }`, sync or
|
|
306
|
+
async. A policy that throws falls back to accept, so a bug in the policy
|
|
307
|
+
cannot hang the page.
|
|
308
|
+
- `connectPipe({ dialogPolicy })` and `connect(url, { dialogPolicy })` set it
|
|
309
|
+
up front; `browser.setDialogPolicy()` swaps it later (it forwards to the pipe
|
|
310
|
+
or WebSocket client and throws for a transport without policy support).
|
|
311
|
+
- `page.on('dialog', dialog => ...)` hands each listener a Playwright-style
|
|
312
|
+
`Dialog`: `type()`, `message()`, `defaultValue()` (the prompt's default
|
|
313
|
+
text), `url`, `accept(promptText?)` and `dismiss()`. A listener that answers
|
|
314
|
+
replaces the policy for that dialog. The policy answers once the listeners
|
|
315
|
+
have run and none of them answered, so a listener that only looks (a trace,
|
|
316
|
+
`page.waitForEvent('dialog')`) leaves the dialog to the policy:
|
|
317
|
+
|
|
318
|
+
```js
|
|
319
|
+
page.on("dialog", dialog =>
|
|
320
|
+
dialog.type() === "prompt" ? dialog.accept("agent@example.com") : dialog.dismiss());
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Answer inside the listener or in a promise it returns: the policy waits for
|
|
324
|
+
that promise. A dialog is answered once: a second `accept()` / `dismiss()`,
|
|
325
|
+
or one after the policy answered, rejects.
|
|
326
|
+
- CDP listeners of `Page.javascriptDialogOpening` get the same `Dialog` as
|
|
327
|
+
`meta.dialog`. On a shared connection the policy is the connection's and a
|
|
328
|
+
listener belongs to the handle that added it: it answers until that handle
|
|
329
|
+
closes, then the policy answers again.
|
|
330
|
+
|
|
331
|
+
## Frames (OOPIF) and shadow DOM
|
|
332
|
+
|
|
333
|
+
- Out-of-process iframes are stitched into the snapshot as child trees under
|
|
334
|
+
the owning `- iframe [ref=eK]:` line. Child refs look like `f<N>e<M>` and go
|
|
335
|
+
straight to `page.locator("f1e3")`; the page routes them to the right frame
|
|
336
|
+
session. There is no separate frame object to hold.
|
|
337
|
+
- Plain `page.snapshot()` sees OOPIFs that existed before `attachPage()`; no
|
|
338
|
+
extra call is needed for the common case.
|
|
339
|
+
- Closed shadow roots hide the host link, so a frame inside one lands in an
|
|
340
|
+
orphan `- iframe:` block at the end of the tree. Its refs still work.
|
|
341
|
+
- `reconcileFrames(page)` re-links child frames whose parent link was lost (it
|
|
342
|
+
returns the frames it added). `snapshotWithFrames(page)` runs that repair and
|
|
343
|
+
reports `missingFrames` only when a frame could not be entered at all. Reach
|
|
344
|
+
for these when a snapshot shows an `iframe` with no children you expected.
|
|
345
|
+
- Rough edge: the first click into a freshly adopted OOPIF can land on the
|
|
346
|
+
embedder. Re-snapshot and click the ref again.
|
|
347
|
+
|
|
348
|
+
## Stealth notes
|
|
349
|
+
|
|
350
|
+
- The `Network` domain is already enabled for every page session, and pages
|
|
351
|
+
cannot observe it. `createNetworkSnoop` and `createTrace` add no new signal.
|
|
352
|
+
- `Fetch` interception changes request timing and blocking patterns that bot
|
|
353
|
+
defenses can fingerprint. It's off until the first `createRoutes().route()`
|
|
354
|
+
call, and `dispose()` turns it off again. Keep routes out of stealth runs.
|
|
355
|
+
- None of these modules send `Runtime.enable`; `requestHuman` and
|
|
356
|
+
`describeLayers` use `page.evaluate`, which shares the existing path.
|
|
357
|
+
- Device emulation swaps the UA and metrics; pair it with a matching
|
|
358
|
+
fingerprint seed when the target scores consistency.
|
|
359
|
+
|
|
360
|
+
## Readiness probe
|
|
361
|
+
|
|
362
|
+
`page.goto()` waits for meaningful content, not just `document.readyState`:
|
|
363
|
+
the page is ready when `body` exists AND (interactive elements > 0 OR
|
|
364
|
+
landmarks > 0 OR visible text >= 20 chars). A near-empty page (e.g.
|
|
365
|
+
`<h1>ok</h1>`) never satisfies the probe and `goto` times out after 30s — use
|
|
366
|
+
`page.goto(url, { waitUntil: "commit" })` for content-free fixtures.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
compactSnapshot,
|
|
5
|
+
connectCloakProfile,
|
|
6
|
+
resolveCloakProfile,
|
|
7
|
+
} from "../src/index.js";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
|
|
11
|
+
const HELP = `Usage: omowright-cloak [options]
|
|
12
|
+
|
|
13
|
+
Launch CloakBrowser through OmOWright with a stable persistent profile.
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
--profile <dir> Persistent Chromium profile directory
|
|
17
|
+
--seed <10000-99999>
|
|
18
|
+
Pin the fingerprint seed on first use
|
|
19
|
+
--browser <path> CloakBrowser Chromium binary path
|
|
20
|
+
--name <name> Register as a named instance; attach when already live.
|
|
21
|
+
A named browser listens on an unauthenticated 127.0.0.1
|
|
22
|
+
CDP port; without --name there is no port at all.
|
|
23
|
+
--url <url> Open a URL (default: about:blank)
|
|
24
|
+
--once Print state, close the browser, preserve the profile
|
|
25
|
+
--snapshot Include an interactive accessibility snapshot
|
|
26
|
+
--help Show this help
|
|
27
|
+
|
|
28
|
+
Environment:
|
|
29
|
+
CLOAK_PROFILE_DIR Default profile directory override
|
|
30
|
+
CLOAK_FINGERPRINT_SEED First-use seed override
|
|
31
|
+
CLOAKBROWSER_BIN CloakBrowser binary path override
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
function parseArgs(argv) {
|
|
35
|
+
const options = { url: "about:blank", once: false, snapshot: false };
|
|
36
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
37
|
+
const arg = argv[index];
|
|
38
|
+
if (arg === "--help") return { help: true };
|
|
39
|
+
if (arg === "--once") {
|
|
40
|
+
options.once = true;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (arg === "--snapshot") {
|
|
44
|
+
options.snapshot = true;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (["--profile", "--seed", "--browser", "--name", "--url"].includes(arg)) {
|
|
48
|
+
const value = argv[++index];
|
|
49
|
+
if (!value) throw new Error(`${arg} requires a value`);
|
|
50
|
+
options[arg.slice(2)] = value;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`unknown option: ${arg}`);
|
|
54
|
+
}
|
|
55
|
+
return options;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const options = parseArgs(process.argv.slice(2));
|
|
59
|
+
if (options.help) {
|
|
60
|
+
console.log(HELP);
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const profileDir = path.resolve(
|
|
65
|
+
options.profile ??
|
|
66
|
+
process.env.CLOAK_PROFILE_DIR ??
|
|
67
|
+
path.join(os.homedir(), ".local", "share", "omowright-cloak"),
|
|
68
|
+
);
|
|
69
|
+
const profile = await resolveCloakProfile({
|
|
70
|
+
profileDir,
|
|
71
|
+
fingerprintSeed: options.seed,
|
|
72
|
+
});
|
|
73
|
+
let browser;
|
|
74
|
+
let shuttingDown = false;
|
|
75
|
+
async function shutdown(code = 0) {
|
|
76
|
+
if (shuttingDown) return;
|
|
77
|
+
shuttingDown = true;
|
|
78
|
+
await browser?.close();
|
|
79
|
+
process.exit(code);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
process.once("SIGINT", () => void shutdown(130));
|
|
83
|
+
process.once("SIGTERM", () => void shutdown(143));
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
browser = await connectCloakProfile({
|
|
87
|
+
profileDir,
|
|
88
|
+
fingerprintSeed: profile.fingerprintSeed,
|
|
89
|
+
browserPath: options.browser,
|
|
90
|
+
name: options.name,
|
|
91
|
+
});
|
|
92
|
+
const page = await browser.newTab(options.url);
|
|
93
|
+
const result = {
|
|
94
|
+
ok: true,
|
|
95
|
+
url: await page.url(),
|
|
96
|
+
title: await page.title(),
|
|
97
|
+
profileDir,
|
|
98
|
+
fingerprintSeed: profile.fingerprintSeed,
|
|
99
|
+
metadataPath: profile.metadataPath,
|
|
100
|
+
};
|
|
101
|
+
if (options.snapshot) {
|
|
102
|
+
result.snapshot = compactSnapshot(
|
|
103
|
+
await page.snapshot({ interactive: true }),
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
console.log(JSON.stringify(result, null, 2));
|
|
107
|
+
if (!options.once) {
|
|
108
|
+
await new Promise(() => {});
|
|
109
|
+
}
|
|
110
|
+
} finally {
|
|
111
|
+
if (!shuttingDown) await browser?.close();
|
|
112
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omowright",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "OmOWright browser automation for standard Chromium CDP endpoints.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"browser-automation",
|
|
9
|
+
"cdp",
|
|
10
|
+
"chrome-devtools-protocol",
|
|
11
|
+
"chromium",
|
|
12
|
+
"ai-agent",
|
|
13
|
+
"accessibility-snapshot",
|
|
14
|
+
"llm",
|
|
15
|
+
"bun"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://github.com/code-yeongyu/omowright#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/code-yeongyu/omowright/issues"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/code-yeongyu/omowright.git"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22",
|
|
27
|
+
"bun": ">=1.4"
|
|
28
|
+
},
|
|
29
|
+
"bin": {
|
|
30
|
+
"omowright-cloak": "bin/omowright-cloak.mjs"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./src/index.js"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"src/",
|
|
37
|
+
"bin/",
|
|
38
|
+
"skills/",
|
|
39
|
+
"presets/",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE",
|
|
42
|
+
"TOOLS.md"
|
|
43
|
+
],
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"provenance": true
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
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",
|
|
52
|
+
"test:cloak-profile": "node --test test/cloak-profile.test.mjs test/cloak-profile.integration.test.mjs",
|
|
53
|
+
"test:cloak-profile:bun": "bun test test/cloak-profile.test.mjs test/cloak-profile.integration.test.mjs"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"acorn": "8.15.0",
|
|
57
|
+
"gpt-tokenizer": "4.1.0"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"ws": "^8.18.3",
|
|
61
|
+
"zod": "^4.1.5"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-events
|
|
3
|
+
description: Push browser tab and download lifecycle events plus manager-owned background tabs. Read this when an agent needs lifecycle notifications or a temporary tab without polling.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent Events
|
|
7
|
+
|
|
8
|
+
**TREAT THESE AS PUSH NOTIFICATIONS — NEVER POLL `Target.getTargets` TO DETECT
|
|
9
|
+
OPENS, CLOSES, POPUPS, OR DOWNLOADS.**
|
|
10
|
+
|
|
11
|
+
One events capability per connection; await `ready` before trusting baseline
|
|
12
|
+
discovery or download configuration:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import { createEvents, createAgentTabs } from "omowright";
|
|
16
|
+
|
|
17
|
+
const events = createEvents(connection, {
|
|
18
|
+
downloadBehavior: "allow",
|
|
19
|
+
downloadPath: "/absolute/path/to/downloads",
|
|
20
|
+
});
|
|
21
|
+
const tabs = createAgentTabs(connection);
|
|
22
|
+
await Promise.all([events.ready, tabs.ready]);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Subscribe before acting
|
|
26
|
+
|
|
27
|
+
Install the listener or `waitForEvent()` before the action that produces the
|
|
28
|
+
event. Waits are bounded; predicates may be async:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
const opened = events.waitForEvent("popupOpened", {
|
|
32
|
+
timeout: 30_000,
|
|
33
|
+
predicate: tab => tab.openerTargetId === mainTargetId,
|
|
34
|
+
});
|
|
35
|
+
await mainPage.evaluate("window.open('https://example.com')");
|
|
36
|
+
const popup = await opened;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Six push events: `tabOpened`, `tabClosed`, `popupOpened`, `downloadStarted`,
|
|
40
|
+
`downloadProgress`, `downloadFinished`. Only page targets produce tab events. A
|
|
41
|
+
popup produces both `tabOpened` and `popupOpened`; `about:blank` is a valid URL
|
|
42
|
+
and popup placeholder. Download progress is not coalesced; terminals fire exactly
|
|
43
|
+
once.
|
|
44
|
+
|
|
45
|
+
## Own temporary tabs through the manager
|
|
46
|
+
|
|
47
|
+
**CREATE TABS ONLY THROUGH `createAgentTabs(connection)`. NEVER SEND
|
|
48
|
+
`Target.createTarget` YOURSELF, NEVER CALL `Target.activateTarget`, NEVER BRING A
|
|
49
|
+
TAB TO THE FRONT.** The manager opens each tab in its own background window, so
|
|
50
|
+
automation cannot steal focus while the tab still renders, and it owns cleanup.
|
|
51
|
+
Those windows show up in `chrome.windows` like any other.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const tab = await tabs.create("about:blank", {
|
|
55
|
+
viewport: { width: 1440, height: 900 },
|
|
56
|
+
});
|
|
57
|
+
try {
|
|
58
|
+
await tab.page.goto("https://example.com");
|
|
59
|
+
await tabs.repin(tab);
|
|
60
|
+
} finally {
|
|
61
|
+
await tabs.close(tab);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
CloakBrowser headless defers renderer startup for background targets, so the
|
|
66
|
+
manager activates immediately before attaching — only for connections launched
|
|
67
|
+
with a `--headless` argument. Headed connections attach without activation.
|
|
68
|
+
|
|
69
|
+
`tabs.list()` / `tabs.get(targetId)` expose only manager-created tabs. The
|
|
70
|
+
manager pins the viewport after attach and after main-frame navigation;
|
|
71
|
+
child-frame navigation needs no re-pin. `tabs.repin` forces a fresh pin before a
|
|
72
|
+
coordinate action.
|
|
73
|
+
|
|
74
|
+
Cleanup: `await tabs.closeAll()` or `await tabs.dispose()` (owns its tabs by
|
|
75
|
+
default); `events.dispose()` closes neither the browser nor the agent tabs.
|