omowright 0.3.3 → 0.3.4
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/dist/bsk/dom-reads.d.ts +31 -0
- package/dist/bsk/first-navigate.d.ts +14 -0
- package/dist/bsk/protocol/params.generated.d.ts +1511 -0
- package/dist/bsk/screenshot.d.ts +6 -8
- package/dist/bsk/session.d.ts +47 -28
- package/dist/bsk/shared-tab.d.ts +22 -0
- package/dist/bsk/snapshot.d.ts +3 -4
- package/dist/bsk/targets.d.ts +8 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +221 -123
- package/package.json +2 -2
- package/skills/omowright/references/browserskill.md +63 -14
|
@@ -25,18 +25,54 @@ await session.stop(); // ALWAYS: returns borrowed tabs, closes the Agent Window
|
|
|
25
25
|
|
|
26
26
|
### Shared control (BrowserSkill 0.4+)
|
|
27
27
|
|
|
28
|
-
The person at the keyboard can work in the task tab while the agent does
|
|
29
|
-
extension
|
|
30
|
-
`
|
|
31
|
-
`
|
|
32
|
-
|
|
33
|
-
`
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
The person at the keyboard can work in the task tab while the agent does, so
|
|
29
|
+
the extension refuses a page action unless it carries what the latest
|
|
30
|
+
`session.cooperate("sync")` returned. Gated: navigation, every input method,
|
|
31
|
+
`drag`, `evaluate` (and so `bskSnapshot`), `tabClose`, `resize`, `emulate`,
|
|
32
|
+
`observe` with `probeHover`, and `screenshot({ fullPage: true })`. Reads
|
|
33
|
+
(`observe`, `snapshot`, `getHtml`, `read`, `extract`, `screenshot()`,
|
|
34
|
+
`console`, `network`, `waitForNavigation`, `waitForElement`) need no context.
|
|
35
|
+
|
|
36
|
+
Every gated action takes `{ context, observation, expect, dependsOn }`
|
|
37
|
+
besides its own options; any other key throws. A session runs under one
|
|
38
|
+
control policy, chosen by its first sync and fixed after that:
|
|
39
|
+
|
|
40
|
+
| Action | `strict` (the default) | `target` (`cooperate("sync", { controlPolicy: "target" })`) |
|
|
41
|
+
| ---------------------------------------- | ------------------------------------ | ----------------------------------------------------------- |
|
|
42
|
+
| click, hover, fill, ... on a ref/selector | a fresh `context` per action | `context`; the same one serves the next DOM action |
|
|
43
|
+
| `evaluate` (and `bskSnapshot`) | a fresh `context` per action | `context` plus an unused `observation`, or `expect` facts, or `unverified: true` |
|
|
44
|
+
| `press` with no target, `navigate` | a fresh `context` per action | `context` plus an unused `observation` |
|
|
45
|
+
| `dependsOn` | narrows the check to observed regions | refused; state facts in `expect` instead |
|
|
46
|
+
|
|
47
|
+
The sync result carries `context_id` and, when the daemon sends one,
|
|
48
|
+
`observation_id`; pass them as `{ context, observation }`. An observation is
|
|
49
|
+
good for one action. `expect` is a list of literal facts the extension checks
|
|
50
|
+
right before the input, for example
|
|
51
|
+
`[{ target: "#total", field: "text", equals: "3" }]` (`field` is `text`,
|
|
52
|
+
`value`, `checked`, `attribute` or `exists`); a false fact refuses the action
|
|
53
|
+
with `reason: "precondition_failed"` and nothing is sent to the page.
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const { connectBrowserSkill } = await import("omowright");
|
|
57
|
+
|
|
58
|
+
const session = await connectBrowserSkill({ name: "check out", focused: false });
|
|
59
|
+
await session.navigate("https://example.com/cart");
|
|
60
|
+
const sync = await session.cooperate("sync", { controlPolicy: "target" });
|
|
61
|
+
const context = sync.context_id;
|
|
62
|
+
await session.click("#apply-coupon", { context });
|
|
63
|
+
await session.click("#checkout", { context, expect: [{ target: "#total", field: "text", equals: "$3.00" }] });
|
|
64
|
+
const next = await session.cooperate("sync");
|
|
65
|
+
await session.press("Enter", { context: next.context_id, observation: next.observation_id });
|
|
66
|
+
const { items } = await session.read("h1"); // no context needed
|
|
67
|
+
await session.stop();
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
A session's first `navigate` can meet the extension while the new task tab is
|
|
71
|
+
still committing its blank document. That refusal ("The initial task tab
|
|
72
|
+
changed", nothing sent to the page) is handled inside `navigate`: it waits on
|
|
73
|
+
`waitForNavigation` for the tab to settle, checks in `tabList` that the tab is
|
|
74
|
+
still blank, and sends the navigate once more. If the tab never settles or has
|
|
75
|
+
moved on, `navigate` throws the refusal with the tab's state in the message.
|
|
40
76
|
|
|
41
77
|
On `cooperation_sync_required`, call `session.cooperate("wait", { timeoutMs })`
|
|
42
78
|
(at most 25 s) until it reports `ready`, sync again and replan from the live
|
|
@@ -84,8 +120,11 @@ Never a fixed delay.
|
|
|
84
120
|
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
85
121
|
| Navigate / history | `navigate(url, {waitUntil, timeoutMs})`, `back()`, `forward()`, `reload({hard})`, `waitForNavigation()` |
|
|
86
122
|
| Read the page | `observe({maxTokens, cursor, probeHover})` (VOM text with `@eN` refs), `snapshot()`, `getHtml({ref, maxBytes})`, `bskSnapshot(session)` (OmOWright tree + css) |
|
|
123
|
+
| Read values | `read(target, {fields, maxNodes})` (text, value, attributes of matching nodes), `extract("table" \| "list" \| "discover", {target, itemSelector, fields})` |
|
|
124
|
+
| Wait | `waitForElement(target, {state: "visible" \| "hidden" \| "attached" \| "detached", timeoutMs})`, `waitForNavigation()` |
|
|
87
125
|
| Act | `click(target, {button, clickCount, modifiers})`, `hover`, `fill(target, value)`, `press(key, {target, holdMs})`, `select(target, values)`, `focus`, `blur`, `scrollTo`, `wheel({deltaY})` |
|
|
88
|
-
|
|
|
126
|
+
| Drag | `drag({selector} \| {ref}, {target, delta: {x, y}, mode})` |
|
|
127
|
+
| Script | `evaluate(expression, {awaitPromise, timeoutMs, unverified})` → `{ok, value, error}`; Agent Window tabs only |
|
|
89
128
|
| Pixels | `screenshot({ref})` → `{buffer, width, height, captureId}`; `screenshot({fullPage: true})` streams the capture back in chunks |
|
|
90
129
|
| Tabs | `tabList({scope: "user"})`, `tabCreate({url})`, `tabSelect(id)`, `tabClose(id)`, `tabBorrow(id)` (the user confirms), `tabReturn(id)` |
|
|
91
130
|
| Humans | `requestHelp({prompt, targets, completionCriteria, timeoutMs})` for login, CAPTCHA, OTP, payment — the extension shows an overlay and waits |
|
|
@@ -95,7 +134,10 @@ Anything the daemon refuses comes back as a `BskRpcError` with the daemon's
|
|
|
95
134
|
`code` (`not_found`, `invalid_params`, `permission_denied`, `timeout`,
|
|
96
135
|
`cdp_failed`, `user_aborted`, `no_browser_connected`, ...). Long calls can be
|
|
97
136
|
cancelled: `const h = session.client.callWithHandle(...)`, then
|
|
98
|
-
`session.client.cancel(h.rpcId)`.
|
|
137
|
+
`session.client.cancel(h.rpcId)`. The rest of the daemon's tools (dialogs,
|
|
138
|
+
uploads and downloads, recording, `debug`) are reachable as
|
|
139
|
+
`session.tool("dialog_accept", { dialog_id })` with the daemon's own parameter
|
|
140
|
+
names.
|
|
99
141
|
|
|
100
142
|
## bskSnapshot leaves no trace
|
|
101
143
|
|
|
@@ -203,3 +245,10 @@ socket. On another machine, run the library where the daemon is (for example
|
|
|
203
245
|
through a machine mesh), or pair the extension to a daemon in server mode
|
|
204
246
|
(`bsk daemon start --mode server`, WSS required off loopback). Windows named
|
|
205
247
|
pipes are not discovered automatically; pass `sockPath` explicitly.
|
|
248
|
+
|
|
249
|
+
When the process cannot reach the daemon by socket path at all, pass your own
|
|
250
|
+
transport as `connectBrowserSkill({ client })`. It is any object with
|
|
251
|
+
`call(method, params, options)` that sends one daemon request (`system.status`,
|
|
252
|
+
`session.start`, `tool.*`, `session.stop`) and resolves with its `result` or
|
|
253
|
+
rejects with a `BskRpcError`. The exported type `BskClient` describes it, and
|
|
254
|
+
the session uses nothing else.
|