lazycodex-ai 5.0.0-beta.85 → 5.0.0-beta.87
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 +1 -1
- package/dist/cli/index.js +68 -41
- package/dist/cli-node/index.js +68 -41
- package/package.json +1 -1
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +2 -0
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus/gpt-6.md +1 -1
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/README.md +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +2 -2
- package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +63 -89
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/src/directive-content.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/directive.md +2 -2
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/directive.md +63 -89
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/define-goal.md +2 -3
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +2 -2
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/package-lock.json +12 -12
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/scripts/materialize-shared-upstreams.mjs +8 -2
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +2 -2
- package/packages/omo-codex/plugin/skills/browser/ATTRIBUTION.md +26 -14
- package/packages/omo-codex/plugin/skills/browser/SKILL.md +65 -52
- package/packages/omo-codex/plugin/skills/browser/references/commands.md +81 -66
- package/packages/omo-codex/plugin/skills/browser/references/install.md +31 -34
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/README.md +41 -21
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/frames-and-humans.md +33 -20
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/ladder.md +24 -22
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/network.md +35 -15
- package/packages/omo-codex/plugin/skills/browser/references/recipes/1password.md +13 -11
- package/packages/omo-codex/plugin/skills/browser/references/remote.md +5 -4
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/index.js +1534 -0
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +9 -0
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/page-bundle.js +1395 -0
- package/packages/omo-codex/plugin/skills/browser/scripts/browser-doctor.mjs +37 -32
- package/packages/omo-codex/plugin/skills/browser/scripts/browser-install.mjs +31 -44
- package/packages/omo-codex/plugin/skills/browser/scripts/omowright.mjs +25 -0
- package/packages/omo-codex/plugin/skills/debugging/SKILL.md +2 -2
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/06-fix.md +3 -3
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/08-qa.md +1 -1
- package/packages/omo-codex/plugin/skills/debugging/references/tools/browser-qa.md +104 -0
- package/packages/omo-codex/plugin/skills/frontend/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/frontend/references/design/clone-from-url.md +1 -1
- package/packages/omo-codex/plugin/skills/programming/SKILL.md +12 -18
- package/packages/omo-codex/plugin/skills/programming/references/rust/README.md +43 -15
- package/packages/omo-codex/plugin/skills/programming/references/rust/api-design.md +81 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/async-tokio.md +60 -28
- package/packages/omo-codex/plugin/skills/programming/references/rust/axum-stack.md +1 -13
- package/packages/omo-codex/plugin/skills/programming/references/rust/cargo-strict.md +44 -8
- package/packages/omo-codex/plugin/skills/programming/references/rust/clap-stack.md +8 -3
- package/packages/omo-codex/plugin/skills/programming/references/rust/concurrency.md +66 -52
- package/packages/omo-codex/plugin/skills/programming/references/rust/libraries.md +35 -25
- package/packages/omo-codex/plugin/skills/programming/references/rust/macros.md +63 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/one-liners.md +5 -3
- package/packages/omo-codex/plugin/skills/programming/references/rust/proptest-insta.md +8 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/type-state.md +50 -12
- package/packages/omo-codex/plugin/skills/programming/references/rust/unsafe-discipline.md +34 -6
- package/packages/omo-codex/plugin/skills/programming/references/rust/zero-cost-safety.md +62 -52
- package/packages/omo-codex/plugin/skills/programming/references/rust-ub/miri-sanitizers-loom.md +1 -1
- package/packages/omo-codex/plugin/skills/programming/references/rust-ub/ub-taxonomy.md +6 -3
- package/packages/omo-codex/plugin/skills/programming/scripts/rust/check-no-excuse-rules.sh +86 -75
- package/packages/omo-codex/plugin/skills/programming/scripts/rust/new-project.py +31 -28
- package/packages/omo-codex/plugin/skills/review-work/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/ultimate-browsing/SKILL.md +27 -20
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/AGENTS.md +1 -1
- package/packages/omo-codex/plugin/skills/ultimate-browsing/references/chrome-stealth.md +32 -100
- package/packages/omo-codex/plugin/skills/ultimate-browsing/references/insane-search/README.md +5 -11
- package/packages/omo-codex/plugin/skills/ultimate-browsing/references/insane-search/playwright.md +20 -37
- package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +63 -89
- package/packages/omo-codex/plugin/skills/ulw-execute/SKILL.md +4 -4
- package/packages/omo-codex/plugin/skills/ulw-loop/references/define-goal.md +2 -3
- package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +2 -2
- package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/visual-qa/references/browser-setup.md +46 -46
- package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +2 -2
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +4 -2
- package/packages/prompts-core/prompts/ultrawork/codex.md +63 -89
- package/packages/shared-skills/skills/browser/ATTRIBUTION.md +26 -14
- package/packages/shared-skills/skills/browser/SKILL.md +65 -52
- package/packages/shared-skills/skills/browser/references/commands.md +81 -66
- package/packages/shared-skills/skills/browser/references/install.md +31 -34
- package/packages/shared-skills/skills/browser/references/owned-engine/README.md +41 -21
- package/packages/shared-skills/skills/browser/references/owned-engine/frames-and-humans.md +33 -20
- package/packages/shared-skills/skills/browser/references/owned-engine/ladder.md +24 -22
- package/packages/shared-skills/skills/browser/references/owned-engine/network.md +35 -15
- package/packages/shared-skills/skills/browser/references/recipes/1password.md +13 -11
- package/packages/shared-skills/skills/browser/references/remote.md +5 -4
- package/packages/shared-skills/skills/browser/runtime/omowright/index.js +1534 -0
- package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +9 -0
- package/packages/shared-skills/skills/browser/runtime/omowright/page-bundle.js +1395 -0
- package/packages/shared-skills/skills/browser/scripts/browser-doctor.mjs +37 -32
- package/packages/shared-skills/skills/browser/scripts/browser-install.mjs +31 -44
- package/packages/shared-skills/skills/browser/scripts/omowright.mjs +25 -0
- package/packages/shared-skills/skills/debugging/SKILL.md +2 -2
- package/packages/shared-skills/skills/debugging/references/methodology/06-fix.md +3 -3
- package/packages/shared-skills/skills/debugging/references/methodology/08-qa.md +1 -1
- package/packages/shared-skills/skills/debugging/references/tools/browser-qa.md +104 -0
- package/packages/shared-skills/skills/frontend/SKILL.md +1 -1
- package/packages/shared-skills/skills/frontend/references/design/clone-from-url.md +1 -1
- package/packages/shared-skills/skills/programming/SKILL.md +12 -18
- package/packages/shared-skills/skills/programming/references/rust/README.md +43 -15
- package/packages/shared-skills/skills/programming/references/rust/api-design.md +81 -0
- package/packages/shared-skills/skills/programming/references/rust/async-tokio.md +60 -28
- package/packages/shared-skills/skills/programming/references/rust/axum-stack.md +1 -13
- package/packages/shared-skills/skills/programming/references/rust/cargo-strict.md +44 -8
- package/packages/shared-skills/skills/programming/references/rust/clap-stack.md +8 -3
- package/packages/shared-skills/skills/programming/references/rust/concurrency.md +66 -52
- package/packages/shared-skills/skills/programming/references/rust/libraries.md +35 -25
- package/packages/shared-skills/skills/programming/references/rust/macros.md +63 -0
- package/packages/shared-skills/skills/programming/references/rust/one-liners.md +5 -3
- package/packages/shared-skills/skills/programming/references/rust/proptest-insta.md +8 -0
- package/packages/shared-skills/skills/programming/references/rust/type-state.md +50 -12
- package/packages/shared-skills/skills/programming/references/rust/unsafe-discipline.md +34 -6
- package/packages/shared-skills/skills/programming/references/rust/zero-cost-safety.md +62 -52
- package/packages/shared-skills/skills/programming/references/rust-ub/miri-sanitizers-loom.md +1 -1
- package/packages/shared-skills/skills/programming/references/rust-ub/ub-taxonomy.md +6 -3
- package/packages/shared-skills/skills/programming/scripts/rust/check-no-excuse-rules.sh +86 -75
- package/packages/shared-skills/skills/programming/scripts/rust/check-no-excuse-rules.test.ts +83 -0
- package/packages/shared-skills/skills/programming/scripts/rust/new-project.py +31 -28
- package/packages/shared-skills/skills/review-work/SKILL.md +1 -1
- package/packages/shared-skills/skills/ultimate-browsing/SKILL.md +27 -20
- package/packages/shared-skills/skills/ultimate-browsing/engine/AGENTS.md +1 -1
- package/packages/shared-skills/skills/ultimate-browsing/references/chrome-stealth.md +32 -100
- package/packages/shared-skills/skills/ultimate-browsing/references/insane-search/README.md +5 -11
- package/packages/shared-skills/skills/ultimate-browsing/references/insane-search/playwright.md +20 -37
- package/packages/shared-skills/skills/ulw-execute/SKILL.md +4 -4
- package/packages/shared-skills/skills/visual-qa/SKILL.md +1 -1
- package/packages/shared-skills/skills/visual-qa/references/browser-setup.md +46 -46
- package/packages/omo-codex/plugin/skills/browser/scripts/browser-env.mjs +0 -41
- package/packages/omo-codex/plugin/skills/debugging/references/tools/playwright-cli.md +0 -112
- package/packages/omo-codex/plugin/skills/programming/scripts/rust/check-no-excuse-rules.py +0 -296
- package/packages/shared-skills/skills/browser/scripts/browser-env.mjs +0 -41
- package/packages/shared-skills/skills/debugging/references/tools/playwright-cli.md +0 -112
- package/packages/shared-skills/skills/programming/scripts/rust/check-no-excuse-rules.py +0 -296
|
@@ -1,90 +1,105 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Session methods
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`connectBrowserSkill()` returns a `BskSession`. Every method is one call on the BrowserSkill
|
|
4
|
+
daemon's tool surface; options are the daemon's parameter names in camelCase.
|
|
4
5
|
|
|
5
6
|
## Sessions
|
|
6
7
|
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
```js
|
|
9
|
+
const session = await omowright.connectBrowserSkill({ name: "<task>", focused: false, browser: "<instance id>", width: 1200, height: 800 })
|
|
10
|
+
session.sessionId // four letters, e.g. "ckhg"
|
|
11
|
+
session.browserInstanceId // which connected browser owns the Agent Window
|
|
12
|
+
await session.stop() // ALWAYS, on success and failure
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
stealing focus; drop it only when the user is watching
|
|
15
|
+
`browser` is needed only when more than one browser is connected (`bskDoctor()` lists them).
|
|
16
|
+
`focused: false` keeps the Agent Window from stealing focus; drop it only when the user is watching
|
|
17
|
+
on purpose. Throws `BskRpcError` `no_browser_connected` when no extension is attached — that is a
|
|
18
|
+
stop, not a cue to launch something else.
|
|
15
19
|
|
|
16
|
-
##
|
|
20
|
+
## Targets
|
|
17
21
|
|
|
18
|
-
|
|
|
22
|
+
| Form | Meaning |
|
|
19
23
|
|---|---|
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `evaluate "<js>" --session <id> --json` | `{ok, value}` — **check `.ok`; exit code 0 does not mean the script succeeded** |
|
|
25
|
-
| `console` / `network` | buffered log lines and responses |
|
|
24
|
+
| `"@e3"` / `"e3"` | a ref from the last `observe()` / `snapshot()` |
|
|
25
|
+
| `"#login > button"` | a CSS selector, resolved live |
|
|
26
|
+
| `{ captureId, x, y }` | a point in a screenshot, from `screenshot()` |
|
|
27
|
+
| `css.e3` from `bskSnapshot` | the light-DOM CSS path of an OmOWright ref (`null` inside shadow roots — use the daemon ref instead) |
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
cycle. A ref captured two calls ago silently addresses a different element — this is how a click
|
|
29
|
-
lands on the neighbouring row.
|
|
29
|
+
## Reading
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
| Call | Returns |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `bskSnapshot(session, { interactive, maxDepth })` | `{ tree, refs, css }` — the OmOWright accessibility tree with refs, computed in the page **without** leaving a global or touching the DOM |
|
|
34
|
+
| `session.observe({ maxTokens, cursor, probeHover })` | the daemon's semantic tree (`@vom`) with `@eN` refs, layers and hover probes — **the default read for shadow DOM and iframes** |
|
|
35
|
+
| `session.snapshot({ maxDepth, maxTokens })` | the daemon's plain accessibility tree |
|
|
36
|
+
| `session.getHtml({ ref, maxBytes })` | exact markup |
|
|
37
|
+
| `session.screenshot({ ref })` / `screenshot({ fullPage: true })` | `{ buffer, width, height, captureId }`; full-page captures stream back in chunks |
|
|
38
|
+
| `session.evaluate(expression, { awaitPromise, timeoutMs })` | `{ ok, value, error }` — **check `.ok`**; a resolved promise does not mean the script succeeded |
|
|
39
|
+
| `session.console({ since })` / `session.network({ since })` | buffered console entries / request metadata (no bodies) |
|
|
40
|
+
|
|
41
|
+
**Refs are reissued by every read.** Read a ref and act on it in the same cycle. A ref captured
|
|
42
|
+
two calls ago silently addresses a different element — this is how a click lands on the
|
|
43
|
+
neighbouring row.
|
|
32
44
|
|
|
33
45
|
## Acting
|
|
34
46
|
|
|
35
|
-
| Need |
|
|
47
|
+
| Need | Call |
|
|
36
48
|
|---|---|
|
|
37
|
-
| Click | `click
|
|
38
|
-
| Fill | `fill
|
|
39
|
-
| Select | `select
|
|
40
|
-
| Key | `press
|
|
41
|
-
| Hover | `hover
|
|
42
|
-
| Scroll into view | `
|
|
43
|
-
| Wheel | `wheel
|
|
44
|
-
| Focus / blur | `focus
|
|
45
|
-
|
|
|
49
|
+
| Click | `session.click(target, { button, clickCount, modifiers })` |
|
|
50
|
+
| Fill | `session.fill(target, value, { clearBefore })` |
|
|
51
|
+
| Select | `session.select(target, ["<option value>"])` |
|
|
52
|
+
| Key | `session.press("Enter", { target, modifiers, holdMs })` |
|
|
53
|
+
| Hover | `session.hover(target, { settleMs })` |
|
|
54
|
+
| Scroll into view | `session.scrollTo(target)` |
|
|
55
|
+
| Wheel | `session.wheel({ deltaY: 600, target })` |
|
|
56
|
+
| Focus / blur | `session.focus(target)` / `session.blur(target)` |
|
|
57
|
+
| Navigate | `session.navigate(url, { waitUntil: "load" \| "domcontentloaded" \| "networkidle" \| "commit", timeoutMs })`, `back()`, `forward()`, `reload({ hard })`, `waitForNavigation()` |
|
|
58
|
+
| Window | `session.resize(width, height)`, `session.emulate({ overrides: { width, mobile } })` |
|
|
46
59
|
|
|
47
60
|
Traps:
|
|
48
61
|
|
|
49
62
|
- `select` takes the option's **value attribute**, not its visible label.
|
|
50
|
-
- `
|
|
51
|
-
|
|
52
|
-
- A menu that a `click` opens can be toggled shut by that same click. `focus` then
|
|
53
|
-
|
|
54
|
-
- Hover-only controls report `element not visible`: hover the trigger,
|
|
55
|
-
revealed item's fresh ref.
|
|
56
|
-
|
|
57
|
-
- The clipboard is unavailable in a window started
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
- `press` without `target` goes to the focused node; `press` with a CSS selector is fine, but a
|
|
64
|
+
daemon ref must come from the current read.
|
|
65
|
+
- A menu that a `click` opens can be toggled shut by that same click. `focus` then `press("Enter")`
|
|
66
|
+
opens it reliably.
|
|
67
|
+
- Hover-only controls report `element not visible`: hover the trigger, read again, then act on the
|
|
68
|
+
revealed item's fresh ref. `observe({ probeHover: true })` finds one when no marker does, at the
|
|
69
|
+
cost of touching the live page.
|
|
70
|
+
- The clipboard is unavailable in a window started `focused: false`, so read values out of the DOM.
|
|
71
|
+
|
|
72
|
+
## Tabs
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
const { tabs } = await session.tabList({ scope: "user" }) // "user" | "agent" | "all"
|
|
76
|
+
await session.tabBorrow(tabId) // the user confirms in the browser (60 s)
|
|
77
|
+
await session.tabReturn(tabId) // stop() returns anything still borrowed
|
|
78
|
+
await session.tabCreate({ url }); await session.tabSelect(id); await session.tabClose(id)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Never invent tab ids and never repeat a denied borrow.
|
|
82
|
+
|
|
83
|
+
## Humans
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
const { outcome } = await session.requestHelp({ prompt, title, targets: ["@e4"], completionCriteria, timeoutMs })
|
|
87
|
+
// outcome: "completed" | "continued" | "cancelled" | "timed_out" | "navigated" | "disabled"
|
|
66
88
|
```
|
|
67
89
|
|
|
68
|
-
|
|
69
|
-
always return what you borrowed (`session stop` also returns them).
|
|
90
|
+
## Errors
|
|
70
91
|
|
|
71
|
-
|
|
92
|
+
Every refusal is a `BskRpcError` with the daemon's own `code`:
|
|
72
93
|
|
|
73
|
-
|
|
|
94
|
+
| `code` | Meaning | Do |
|
|
74
95
|
|---|---|---|
|
|
75
|
-
| `
|
|
76
|
-
|
|
|
77
|
-
| `
|
|
78
|
-
| `permission_denied
|
|
79
|
-
| `
|
|
80
|
-
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
If the host kills background children after each command, the daemon cannot survive between calls.
|
|
87
|
-
Set `BSK_AUTO_START=0`, share one `BSK_HOME` across every call, and start
|
|
88
|
-
`bsk daemon start --foreground` in the host's persistent background task. Check readiness with
|
|
89
|
-
`bsk status --json` in a separate call before continuing. Do not loop on launches, delete runtime
|
|
90
|
-
files, or restart a daemon another task is using.
|
|
96
|
+
| `no_browser_connected` | no extension attached | run the onboarding script, relay the human step, wait |
|
|
97
|
+
| `not_found` | stale ref or unknown session | read again; if the session is gone, start a new one |
|
|
98
|
+
| `invalid_params` | wrong option shape | fix the call, do not retry as-is |
|
|
99
|
+
| `permission_denied` | `evaluate` on a tab outside the Agent Window, or a denied borrow | stop; the user said no |
|
|
100
|
+
| `timeout` | the tool did not finish in its budget | read the page state before retrying once |
|
|
101
|
+
| `user_aborted` | the user pressed Stop in the browser | stop the task and report |
|
|
102
|
+
| `cdp_failed` | the page cannot be attached (restricted URL, DevTools open) | say which page and why |
|
|
103
|
+
|
|
104
|
+
Long calls can be cancelled: `const h = session.client.callWithHandle("tool.navigate", {...})`
|
|
105
|
+
then `await session.client.cancel(h.rpcId)`.
|
|
@@ -1,71 +1,68 @@
|
|
|
1
1
|
# Installing the attached engine
|
|
2
2
|
|
|
3
|
-
Three pieces. The
|
|
3
|
+
Three pieces. The onboarding script prepares all three; a human finishes exactly one.
|
|
4
4
|
|
|
5
5
|
| Piece | Channel | Automatable |
|
|
6
6
|
|---|---|---|
|
|
7
7
|
| `bsk` CLI + daemon | upstream installer, GitHub Releases | **yes** |
|
|
8
|
-
| Browser extension |
|
|
9
|
-
| Daemon process | auto-starts on
|
|
8
|
+
| Browser extension | registered from the Web Store listing through Chrome's external-extension mechanism | **yes, up to one click** — the browser asks the user to enable it |
|
|
9
|
+
| Daemon process | auto-starts on the first call | nothing to do |
|
|
10
10
|
|
|
11
11
|
## Supported
|
|
12
12
|
|
|
13
13
|
| | |
|
|
14
14
|
|---|---|
|
|
15
15
|
| Operating systems | macOS (Apple Silicon and Intel), Linux (x64, ARM64), Windows x64 |
|
|
16
|
-
| Browsers | Chrome, Microsoft Edge
|
|
16
|
+
| Browsers | Chrome, Microsoft Edge, Brave, Chromium — any profile the doctor lists under `browsersDetected` |
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## One command
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
node "<skill-root>/scripts/browser-install.mjs"
|
|
21
|
+
node "<skill-root>/scripts/browser-install.mjs" [--json] [--wait-ms=180000]
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
In order it: runs upstream's official `install.sh` / `install.ps1` into `~/.local/bin` (any PATH
|
|
25
|
+
line the installer appends to a shell rc file is reverted — the library calls the binary by
|
|
26
|
+
absolute path); starts the daemon with `bsk status`; and, for every Chromium-family profile it
|
|
27
|
+
finds, registers the Web Store listing as an external extension:
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
irm https://raw.githubusercontent.com/Tencent/BrowserSkill/main/install.ps1 | iex
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
The Unix installer cannot change its parent shell's `PATH`. A shell opened before the install may
|
|
36
|
-
still miss it, so either re-export in each call or use the absolute path (`$HOME/.local/bin/bsk`,
|
|
37
|
-
`bsk.exe` on Windows). Verify with `bsk --version`.
|
|
29
|
+
| Platform | Where the entry goes | The user's one step |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| macOS | `<user data dir>/External Extensions/<id>.json` | quit the browser completely, open it again, click **Enable** in the dialog |
|
|
32
|
+
| Windows | `HKCU\Software\<vendor>\<browser>\Extensions\<id>` (`reg add`, no admin) | click **Enable** on the toolbar badge; no restart |
|
|
33
|
+
| Linux (Chromium) | `<user data dir>/External Extensions/<id>.json` | relaunch; installs without a prompt |
|
|
34
|
+
| Linux (Chrome / Edge / Brave) | `/opt/google/chrome/extensions/<id>.json` and siblings — root only | otherwise open the store link it prints and click **Add** |
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
The script prints that step as `humanStep`. **Relay it verbatim and wait**; with `--wait-ms` it
|
|
37
|
+
keeps polling the daemon until the extension connects. An empty `browsersConnected` afterwards is
|
|
38
|
+
not a failure to work around — the browser is closed or the user has not clicked yet; say which
|
|
39
|
+
and ask.
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
If the user removed the extension from the browser before, Chrome blocklists its id for external
|
|
42
|
+
installs. The script detects that (`reason: "blocklisted"`) and prints the store link instead:
|
|
42
43
|
|
|
43
44
|
- Chrome: https://chromewebstore.google.com/detail/hhcmgoofomhgciiibhipgmgkgnoenaoi
|
|
44
45
|
- Edge: https://microsoftedge.microsoft.com/addons/detail/browserskill/emacgiaaaiojkkpkddmmdfhmokgmnikg
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
bsk status --json # a non-empty "browsers" array means connected
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
An empty `browsers` list is not a failure to work around. Either the browser is closed or the
|
|
53
|
-
extension is not enabled; say which and ask.
|
|
47
|
+
Enterprise force-install policies are deliberately not used: they brand the browser "managed by
|
|
48
|
+
your organization" and the user cannot remove the extension.
|
|
54
49
|
|
|
55
|
-
##
|
|
50
|
+
## Do not install upstream's skill
|
|
56
51
|
|
|
57
52
|
Upstream ships its own agent skill through `bsk install-skill`. **Do not run it here.** This
|
|
58
53
|
package already provides the skill, and upstream's copy installs under a different name into the
|
|
59
54
|
user skill directory, which takes precedence over a shipped skill — two descriptions of the same
|
|
60
|
-
|
|
55
|
+
engine, one of them shadowing the one that knows about omowright and this package's scripts.
|
|
61
56
|
|
|
62
57
|
## Diagnosing
|
|
63
58
|
|
|
64
59
|
```bash
|
|
65
|
-
node "<skill-root>/scripts/browser-doctor.mjs"
|
|
60
|
+
node "<skill-root>/scripts/browser-doctor.mjs" --json # this package's view: cli, daemon, profiles, registrations, connections
|
|
66
61
|
bsk doctor # upstream's own checks
|
|
67
62
|
bsk logs # daemon log
|
|
68
63
|
```
|
|
69
64
|
|
|
70
|
-
The daemon exits about ten minutes after the last browser disconnects and is not a system
|
|
71
|
-
so a reboot also stops it. Both heal on the next
|
|
65
|
+
The daemon exits about ten minutes after the last browser disconnects and is not a system
|
|
66
|
+
service, so a reboot also stops it. Both heal on the next call — `connectBrowserSkill()` starts it
|
|
67
|
+
unless `BSK_AUTO_START=0` (sandboxes that reap background processes keep the daemon on the host
|
|
68
|
+
and share `BSK_HOME`; see upstream's sandboxed-agents guide).
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
# The owned engine
|
|
2
2
|
|
|
3
|
-
A browser **your code launches and owns**, driven over CDP
|
|
4
|
-
the attached engine: no user logins, full control.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
A browser **your code launches and owns**, driven over CDP by omowright with its own profile. The
|
|
4
|
+
opposite of the attached engine: no user logins, full control.
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
const { omowright } = await loadOmowright()
|
|
8
|
+
const profile = mkdtempSync(join(tmpdir(), "omowright-"))
|
|
9
|
+
const browser = await omowright.connectPipe({
|
|
10
|
+
browserPath: "<CloakBrowser or chrome-headless-shell binary>",
|
|
11
|
+
browserArgs: ["--headless", "--no-first-run", `--user-data-dir=${profile}`],
|
|
12
|
+
storageRoot: profile,
|
|
13
|
+
dialogPolicy: { accept: true },
|
|
14
|
+
})
|
|
15
|
+
try {
|
|
16
|
+
const page = await browser.newTab("https://example.com/")
|
|
17
|
+
const tree = omowright.compactSnapshot(await page.snapshot()) // ALWAYS compact before a model reads it
|
|
18
|
+
await page.locator("e3").click() // refs come straight from the snapshot
|
|
19
|
+
await Bun.write("shot.png", await page.screenshot())
|
|
20
|
+
} finally {
|
|
21
|
+
await browser.close()
|
|
22
|
+
rmSync(profile, { recursive: true, force: true }) // paired: a leftover profile is a logged-in browser nobody watches
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`connectPipe` launches over `--remote-debugging-pipe`: no listening port, stdio drained, the
|
|
27
|
+
process reaped on `close()`. `connect("http://127.0.0.1:<port>")` attaches to a browser something
|
|
28
|
+
else launched. `connectCloakProfile({ profileDir })` launches CloakBrowser with a pinned
|
|
29
|
+
fingerprint seed — the stealth path for WAF and bot-scored targets, where the attached engine's
|
|
30
|
+
console capture would be a signal.
|
|
9
31
|
|
|
10
32
|
## When it is the right engine
|
|
11
33
|
|
|
@@ -16,27 +38,25 @@ If no owned engine is installed, say so and stay on the attached engine.
|
|
|
16
38
|
| Solving a challenge widget programmatically | needs coordinate control and OCR |
|
|
17
39
|
| Reading the network instead of the DOM | needs request interception on your own target |
|
|
18
40
|
| A QA flight trace (steps, HAR, screenshots) | recording someone's real session is not acceptable |
|
|
41
|
+
| Headless or unattended runs | the user's browser is on their desk |
|
|
19
42
|
|
|
20
43
|
For anything that needs the user's login, the attached engine wins. For extracting text from a
|
|
21
44
|
blocked URL, neither: use the `ultimate-browsing` skill.
|
|
22
45
|
|
|
23
|
-
##
|
|
46
|
+
## The page
|
|
24
47
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
5. A dialog policy, so `alert` / `confirm` / `beforeunload` can never block a run.
|
|
48
|
+
`OmOPage` is Playwright-shaped: `goto`, `snapshot`, `locator(ref | css)`, `click`, `fill`,
|
|
49
|
+
`press`, `hover`, `check`, `selectOption`, `dragTo`, `setInputFiles`, `screenshot`, `pdf`,
|
|
50
|
+
`evaluate`, `waitForURL`, `keyboard`, `mouse`, `frameLocator`. A snapshot is an accessibility tree
|
|
51
|
+
with virtual refs (`[ref=e3]`, cross-origin frames as `f1e3`); `compactSnapshot()` drops the refs
|
|
52
|
+
map, about half the bytes. Readiness is a content probe (body plus interactive elements, landmarks
|
|
53
|
+
or text), not a timer; `goto(url, { waitUntil: "commit" })` is the escape hatch for empty pages.
|
|
32
54
|
|
|
33
55
|
## Reference
|
|
34
56
|
|
|
35
|
-
- [ladder.md](ladder.md) — the escalation ladder, viewport pinning,
|
|
36
|
-
- [network.md](network.md) —
|
|
37
|
-
- [frames-and-humans.md](frames-and-humans.md) —
|
|
38
|
-
|
|
39
|
-
## Cleanup is paired
|
|
57
|
+
- [ladder.md](ladder.md) — the escalation ladder, viewport pinning, `createCua`, `createCaptcha`
|
|
58
|
+
- [network.md](network.md) — `createNetworkSnoop`, `collectWhileScrolling`, `createTrace`, `createRoutes`
|
|
59
|
+
- [frames-and-humans.md](frames-and-humans.md) — `snapshotWithFrames`, `describeLayers`, dialog policy, `emulate`, `requestHuman`
|
|
40
60
|
|
|
41
|
-
|
|
42
|
-
|
|
61
|
+
The library's own skill (`skills/omowright/SKILL.md` and `presets/*` in the omowright repository)
|
|
62
|
+
is the authoritative, longer treatment of each; these pages are the routing summary.
|
|
@@ -2,38 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
## Cross-origin frames and shadow DOM
|
|
4
4
|
|
|
5
|
-
A cross-origin iframe is a separate target with its own snapshot.
|
|
6
|
-
the parent so one tree describes the whole page, and
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
A cross-origin iframe is a separate target with its own snapshot. `snapshotWithFrames(page)`
|
|
6
|
+
reconciles the child trees into the parent so one tree describes the whole page, and reports
|
|
7
|
+
`missingFrames` for any it could not enter; address child elements through the page-level ref
|
|
8
|
+
(`f1e3`) — never by fetching a frame handle first. Shadow roots are traversed by the snapshot
|
|
9
|
+
engine; they are not a special case for you.
|
|
9
10
|
|
|
10
11
|
## Overlays that swallow clicks
|
|
11
12
|
|
|
12
13
|
Two identical misses on an element that is clearly visible usually means something invisible sits
|
|
13
14
|
on top: a consent banner, a modal backdrop, a sticky header, a full-viewport tracking layer.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
`describeLayers(page)` names the topmost fixed or sticky element covering the viewport, and
|
|
16
|
+
`snapshotWithLayers(page)` prefixes a snapshot with `@layers blocking=<role> "<name>"` when one
|
|
17
|
+
exists. Either the overlay is named — dismiss it and continue — or `@layers none`, which means the
|
|
18
|
+
miss has another cause and you climb the ladder instead.
|
|
17
19
|
|
|
18
20
|
## Dialogs never block
|
|
19
21
|
|
|
20
|
-
`alert`, `confirm`, `prompt`, and `beforeunload`
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
`alert`, `confirm`, `prompt`, and `beforeunload` are answered by the `dialogPolicy` passed to
|
|
23
|
+
`connectPipe` (or `browser.setDialogPolicy`), at the protocol layer, before the page sees them.
|
|
24
|
+
Default to accepting (`{ accept: true }`; a function receives `{ type, message }` and returns
|
|
25
|
+
`{ accept, promptText }`). `page.on("dialog")` still fires for observability. A run that hangs on
|
|
26
|
+
an unhandled dialog looks exactly like a hang with no cause, which is the most expensive kind to
|
|
27
|
+
diagnose.
|
|
24
28
|
|
|
25
29
|
## Device emulation
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
viewport produces a desktop page at a phone size, which is not what you are
|
|
29
|
-
viewport after emulating, and re-pin
|
|
31
|
+
`emulate(page, "iphone-14")` applies viewport, device scale factor, user agent and touch together;
|
|
32
|
+
changing only the viewport produces a desktop page at a phone size, which is not what you are
|
|
33
|
+
testing. `emulate(page, null)` restores. Re-read the viewport after emulating, and re-pin
|
|
34
|
+
coordinates.
|
|
30
35
|
|
|
31
36
|
## Handing the page to a human
|
|
32
37
|
|
|
33
38
|
When every rung fails on a login, a one-time code, or a challenge you cannot clear, the human is
|
|
34
|
-
the fallback, not the failure
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
the fallback, not the failure:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
const { outcome } = await omowright.requestHuman(page, {
|
|
43
|
+
prompt: "Please finish the sign-in in this window.",
|
|
44
|
+
until: { url: /\/dashboard/ }, // or { selector } or async (page) => boolean
|
|
45
|
+
timeoutMs: 300_000,
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
It brings the window to the front, shows a banner with a Done button, and waits on a
|
|
50
|
+
**condition** with a bounded timeout rather than a fixed delay. Respect the answer: `timed_out`
|
|
51
|
+
or `cancelled` is a stop, and the correct response is to report which rung failed with what
|
|
52
|
+
evidence. Working around the user's refusal is never correct.
|
|
@@ -5,12 +5,12 @@ defect.** The failure itself selects the next rung; never pause to ask which.
|
|
|
5
5
|
|
|
6
6
|
| Rung | Use | Climb when |
|
|
7
7
|
|---|---|---|
|
|
8
|
-
| 1. snapshot + locator(ref) | anything with a usable ref | the ref is absent, stale, obscured, or the click lands on the wrong node twice |
|
|
9
|
-
| 1b.
|
|
10
|
-
| 2. coordinates | canvas, extension popups, custom controls, drag surfaces | the click misses, or the screenshot and the coordinates disagree |
|
|
11
|
-
| 3. pin the viewport, redo rung 2 | coordinate drift after a resize, a DPI change, or a foreign tab | coordinates land correctly but the widget still refuses input |
|
|
12
|
-
| 4.
|
|
13
|
-
| 5. read the browser log | a browser-level failure | the log names a cause outside the page |
|
|
8
|
+
| 1. `page.snapshot()` + `page.locator(ref)` | anything with a usable ref | the ref is absent, stale, obscured, or the click lands on the wrong node twice |
|
|
9
|
+
| 1b. `snapshotWithLayers(page)` / `describeLayers(page)` | a blocking overlay explains two identical misses | `@layers none`, or the overlay is gone and the click still misses |
|
|
10
|
+
| 2. `createCua(page)` coordinates | canvas, extension popups, custom controls, drag surfaces | the click misses, or the screenshot and the coordinates disagree |
|
|
11
|
+
| 3. pin the viewport (`emulate(page, "desktop-1440")` / `repinViewport`), redo rung 2 | coordinate drift after a resize, a DPI change, or a foreign tab | coordinates land correctly but the widget still refuses input |
|
|
12
|
+
| 4. `createCaptcha(page)` | a challenge is the blocker | it clears and the flow still stalls |
|
|
13
|
+
| 5. read the browser log (`browser.close()` surfaces the stdio tail) | a browser-level failure | the log names a cause outside the page |
|
|
14
14
|
|
|
15
15
|
**Rung 5 ends in a written diagnosis, never a speculative code change.** A missing entitlement, a
|
|
16
16
|
dead extension service worker, an unavailable authenticator — none of those is fixed by editing
|
|
@@ -18,38 +18,40 @@ automation code.
|
|
|
18
18
|
|
|
19
19
|
## Pin the viewport before trusting any coordinate
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
`createCua(page)` acts in viewport pixels. When the render surface and the coordinate space
|
|
22
22
|
disagree, every coordinate is off by the same constant and retrying just repeats the miss. Set the
|
|
23
|
-
device metrics explicitly (width, height, `deviceScaleFactor
|
|
24
|
-
the page's viewport size, then take a **fresh**
|
|
25
|
-
screenshot are stale. Pin every page you act on, including tabs
|
|
23
|
+
device metrics explicitly (`emulate` applies width, height, `deviceScaleFactor` and touch
|
|
24
|
+
together), re-read the page's viewport size, then take a **fresh** `cua.getVisibleScreenshot()`.
|
|
25
|
+
Coordinates read off an unpinned screenshot are stale. Pin every page you act on, including tabs
|
|
26
|
+
you did not open (`createAgentTabs` re-pins on create).
|
|
26
27
|
|
|
27
28
|
## Refs
|
|
28
29
|
|
|
29
30
|
- Refs die on every new snapshot. Pass a ref straight from the latest snapshot; never reuse one
|
|
30
31
|
across snapshots and never put one in a CSS selector.
|
|
31
|
-
- Refs stay page-level. A child-frame ref still resolves through
|
|
32
|
-
frame handle to click inside an iframe.
|
|
33
|
-
- Always
|
|
32
|
+
- Refs stay page-level. A child-frame ref (`f1e3`) still resolves through `page.locator`, so you
|
|
33
|
+
never fetch a frame handle to click inside an iframe.
|
|
34
|
+
- Always `compactSnapshot()` before sending a snapshot to a model.
|
|
34
35
|
|
|
35
36
|
## Challenge widgets
|
|
36
37
|
|
|
37
38
|
A challenge is an obstacle on the path, not a stop sign: clear it, confirm it cleared, continue.
|
|
38
|
-
|
|
39
|
+
`createCaptcha(page)` gives three techniques:
|
|
39
40
|
|
|
40
|
-
- **Checkbox** (the common embedded widgets): the control lives in a nested frame, so
|
|
41
|
-
by viewport coordinates.
|
|
42
|
-
- **Slider / puzzle**: drag
|
|
43
|
-
human. Raise the step count before you change the endpoints.
|
|
44
|
-
- **Text or number**:
|
|
45
|
-
|
|
46
|
-
- **Image grid**: annotate a screenshot, then click per cell
|
|
41
|
+
- **Checkbox** (the common embedded widgets): the control lives in a nested frame, so
|
|
42
|
+
`captcha.click(bounds)` addresses it by viewport coordinates.
|
|
43
|
+
- **Slider / puzzle**: `captcha.drag(from, to, { steps })` with enough intermediate steps that the
|
|
44
|
+
motion reads as human. Raise the step count before you change the endpoints.
|
|
45
|
+
- **Text or number**: `captcha.readText(bounds)` OCRs the region — the macOS Vision framework by
|
|
46
|
+
default, or pass your own `ocr` function or a vision model.
|
|
47
|
+
- **Image grid**: annotate a screenshot, then click per cell with `createCua`.
|
|
47
48
|
|
|
48
49
|
**Bounds measured against an unpinned viewport are wrong by a constant offset.** If clicks have
|
|
49
50
|
been landing wrong, drop to rung 3 first, then re-read the bounds.
|
|
50
51
|
|
|
51
52
|
Verify with a fresh snapshot that the challenge is gone. Verification is part of the action, not a
|
|
52
|
-
separate optimistic assumption.
|
|
53
|
+
separate optimistic assumption. When every technique fails on a page a real browser passes, the
|
|
54
|
+
engine is the variable: relaunch through `connectCloakProfile()`.
|
|
53
55
|
|
|
54
56
|
## Delegating the pixel loop
|
|
55
57
|
|
|
@@ -6,37 +6,57 @@ next week. Watching traffic costs nothing on a target you own, and the page cann
|
|
|
6
6
|
|
|
7
7
|
**Snoop before you scrape.** Scroll-and-parse is the fallback, not the default.
|
|
8
8
|
|
|
9
|
+
```js
|
|
10
|
+
const snoop = omowright.createNetworkSnoop(page, { maxBodyBytes: 512 * 1024 })
|
|
11
|
+
await page.goto(url)
|
|
12
|
+
const hit = await snoop.waitFor({ url: /\/api\/search/, mimeType: "application/json" }, { timeoutMs: 10_000 })
|
|
13
|
+
const rows = snoop.popJson() // every buffered JSON body, drained
|
|
14
|
+
console.log(snoop.summary({ max: 20 })) // one line per request: method status mime size url
|
|
15
|
+
snoop.dispose()
|
|
16
|
+
```
|
|
17
|
+
|
|
9
18
|
## Wait for a request, never for a clock
|
|
10
19
|
|
|
11
|
-
A fixed sleep is a guess that fails on a slower machine and wastes time on a faster one.
|
|
12
|
-
to the response you expect **before**
|
|
13
|
-
timeout. This is the same rule that governs test code, for the same
|
|
20
|
+
A fixed sleep is a guess that fails on a slower machine and wastes time on a faster one.
|
|
21
|
+
`snoop.waitFor(match)` subscribes to the response you expect **before** you trigger the action,
|
|
22
|
+
then awaits it with a bounded timeout. This is the same rule that governs test code, for the same
|
|
23
|
+
reason.
|
|
14
24
|
|
|
15
25
|
## Collecting through infinite scroll
|
|
16
26
|
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
```js
|
|
28
|
+
for await (const batch of omowright.collectWhileScrolling(page, snoop, { minItems: 200, maxScrolls: 10, extract: (json) => json.items })) {
|
|
29
|
+
items.push(...batch)
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Scroll, collect what is new, stop on a target count or a scroll ceiling. Bound both, so a page
|
|
34
|
+
that keeps producing cannot run forever.
|
|
19
35
|
|
|
20
36
|
## Flight traces
|
|
21
37
|
|
|
22
|
-
For QA evidence,
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
For QA evidence, `createTrace(page, { dir })` records one entry per `trace.step(name, fn)` with
|
|
39
|
+
before/after screenshots, the network log and console output, written as `trace.jsonl` plus
|
|
40
|
+
`trace.har` (`toHar` builds the HAR from snoop entries). That triple is what makes a failure
|
|
41
|
+
reconstructable afterwards instead of re-runnable-in-theory. Call `trace.stop()` in `finally`.
|
|
25
42
|
|
|
26
43
|
Cap recorded body sizes. An untrimmed trace of a media-heavy page is mostly bytes nobody reads.
|
|
27
44
|
|
|
28
45
|
## Request interception
|
|
29
46
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
`createRoutes(page)` matches by glob, regular expression, or predicate and lets a handler
|
|
48
|
+
`continue`, `fulfill({ status, body })` or `abort()`: stub an endpoint, fail one request to test an
|
|
49
|
+
error path, block third-party noise. Interception is enabled on the first route and disabled on
|
|
50
|
+
`dispose()` — leaving it on slows every later navigation and changes the timing fingerprint, so
|
|
51
|
+
prefer passive snooping on bot-scored targets.
|
|
33
52
|
|
|
34
53
|
## Cookies
|
|
35
54
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
`injectCookies(page, cookies)` sanitizes what it injects (drops expired entries, keeps
|
|
56
|
+
host-prefixed cookies secure and root-scoped). Injecting an export into your own profile is
|
|
57
|
+
legitimate for ordinary sessions and useless for the ones you most want: accounts whose risk
|
|
58
|
+
engines bind a session to a device will invalidate it, and a password manager's session is
|
|
59
|
+
tab-bound and never portable.
|
|
40
60
|
|
|
41
61
|
**Never copy a session out of the user's real browser profile.** If you need their login, that is
|
|
42
62
|
the attached engine's job.
|