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.
@@ -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. The
29
- extension therefore refuses every page action with `permission_denied` /
30
- `data.reason: "cooperation_sync_required"` unless it carries the
31
- `context_id` of the latest `session.cooperate("sync")`. A context is good
32
- for one action: sync, decide from what the sync reported, act with
33
- `{ context }`, then sync again. Gated: navigation (except the first
34
- navigation of the untouched blank tab), every input method, `evaluate` (and
35
- so `bskSnapshot`), `tabClose`, `resize`, `emulate`, `observe` with
36
- `probeHover`, and `screenshot({ fullPage: true })`. Reads (`observe`,
37
- `snapshot`, `getHtml`, `screenshot()`, `console`, `network`,
38
- `waitForNavigation`) need no context. `dependsOn: ["@e2", ...]` narrows the
39
- check to the observed regions the decision used.
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
- | Script | `evaluate(expression, {awaitPromise, timeoutMs})` → `{ok, value, error}`; Agent Window tabs only |
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.