@roll-agent/browser-use-agent 0.25.1 → 0.26.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.
@@ -15,13 +15,19 @@ AX snapshot -> select emitted @eN -> click/type -> re-observe or read back
15
15
  This is a fallback layer for unmodeled page operations. For BOSS workflows, prefer `zhipin_*` tools
16
16
  when they already express the business action.
17
17
 
18
+ The selection order is platform-specific tools, enabled applicable workflows, then generic
19
+ exploration. For deterministic multi-step operations, use `browser_execute` with explicit result
20
+ assertions. See [controlled exploration and workflows](browser-exploration.md) for helpers,
21
+ whole-script approval, resource limits and versioned workflow management. This reference describes
22
+ the compatible single-step tools and their optional strict-ref mode.
23
+
18
24
  ## Tool Summary
19
25
 
20
26
  | Tool | Input | Output | Use it for |
21
27
  | --- | --- | --- | --- |
22
- | `browser_snapshot` | `pageId?`, `maxDepth?`, `maxNodes?`, `interactiveOnly?` | `page`, `snapshot` | Observe the current page's AX tree and get `@eN` refs. It also merges limited DOM-action hints for non-semantic controls such as clickable tabs rendered as `span`, including same-target iframes when Chrome exposes child `frameId` values. |
23
- | `click_ref` | `ref`, `pageId?`, `browserActionApproval?` | `success`, `ref`, `resolvedBy`, `target` | Click a ref returned by `browser_snapshot`. |
24
- | `type_ref` | `ref`, `text`, `clear?`, `pageId?`, `browserActionApproval?` | `success`, `ref`, `resolvedBy`, `target` | Focus a ref, optionally clear it, then insert text. |
28
+ | `browser_snapshot` | `pageId?`, `scope?`, `maxDepth?`, `maxNodes?`, `interactiveOnly?` | `page`, `snapshot` | Observe AX and limited non-semantic actionable controls. Optional `scope` is a uniquely matching CSS region, applied before the region's node budget. |
29
+ | `click_ref` | `ref`, `pageId?`, `snapshotId?`, `browserActionApproval?` | `success`, `ref`, `resolvedBy`, `target` | Click an emitted ref. Passing `snapshotId` enables strict instance/page/document/snapshot binding and disables semantic fallback. |
30
+ | `type_ref` | `ref`, `text`, `clear?`, `pageId?`, `snapshotId?`, `browserActionApproval?` | `success`, `ref`, `resolvedBy`, `target` | Focus a ref, optionally clear it, then insert text, with the same optional strict binding. |
25
31
 
26
32
  `browser_snapshot.snapshot` contains:
27
33
 
@@ -29,6 +35,10 @@ when they already express the business action.
29
35
  | --- | --- |
30
36
  | `nodes` | AX nodes returned to the orchestrator. With `interactiveOnly:true`, this is a flat list of interactive nodes. |
31
37
  | `refs` | Current-snapshot handles, shaped as `@e1`, `@e2`, ... |
38
+ | `snapshotId` | Identity of this observation; use with its refs to request strict validation. |
39
+ | `browserInstance`, `pageId`, `documentId` | Originating instance, target and document identity; refs cannot move between these scopes. |
40
+ | `scope` | Requested CSS region, when supplied. An ambiguous or missing region is rejected. |
41
+ | `coverageWarnings` | Explicit observation gaps, such as canvas, incomplete iframe coverage or truncated DOM context scanning. |
32
42
  | `nodeCount` | Number of returned nodes. |
33
43
  | `truncated` | `true` when `maxNodes` stopped traversal. |
34
44
  | `maxNodes` | Effective node cap after applying `BROWSER_SECURITY_JSON.maxSnapshotNodes`. |
@@ -41,6 +51,11 @@ Each `refs[]` item contains `ref`, optional `backendNodeId`, optional `frameId`,
41
51
  and appear in `nodes[]` with `properties.domActionable:true`, `properties.domActionKind`, and
42
52
  `properties.domActionHints`.
43
53
 
54
+ Refs can also carry `context` with a form, dialog or nearby label, and a `locator` hint when a
55
+ unique CSS target can be identified. These hints aid selection and reusable scripts; they are not
56
+ durable guarantees after the page changes. Reusable locators are checked for uniqueness again at
57
+ execution time.
58
+
44
59
  Iframe handling:
45
60
 
46
61
  ```text
@@ -53,8 +68,21 @@ main AX tree -> iframe node backendNodeId -> DOM.describeNode -> child frameId
53
68
  ```
54
69
 
55
70
  When an iframe child ref is clicked or typed, `click_ref` / `type_ref` keep the `frameId` in the
56
- resolved `target`. If the original `backendNodeId` is stale, the fallback re-queries that same frame's
57
- AX tree before dispatching the viewport action.
71
+ resolved `target`. Only legacy calls without `snapshotId` may fall back to re-querying that frame's
72
+ AX tree when the original `backendNodeId` is stale. Strict calls stop instead.
73
+
74
+ ## Structural choice rows
75
+
76
+ Native select options, ARIA choice roles, actionable list rows and independently actionable repeated
77
+ siblings are treated as atomic choices. A row can include an icon and multiple text descendants;
78
+ its container no longer consumes all descendant choices simply because the combined name is short.
79
+ Existing AX semantic roles are preserved. Plain prose lists and a single clickable card with text
80
+ children are not automatically split into choices. This grouping is independent of site labels,
81
+ domains and component classes.
82
+
83
+ For a single-select field, use `page.inspectControl(field)` and `page.choose(field, {label})` inside
84
+ `browser_execute`. See [control helpers](browser-exploration.md#通用单选控件) for portal association,
85
+ strict frame identity, result assertions and supported limits.
58
86
 
59
87
  ## Selection Logic
60
88
 
@@ -64,30 +92,45 @@ Choose a target in this order:
64
92
  2. Reject refs with `disabled:true`.
65
93
  3. For non-semantic clickable text, match `role:"clickable"`, the visible label, and
66
94
  `properties.domActionable:true`; examples include tab/filter labels such as `未读`.
67
- 4. If there are multiple matching nodes, prefer visible task context from nearby `nodes` data or take
68
- another snapshot with `interactiveOnly:false` and a small `maxDepth`.
95
+ 4. If multiple nodes match, inspect `context` and nearby nodes, or request a uniquely matching
96
+ `scope` with `interactiveOnly:false`. Select the intended ref explicitly; do not assume the first
97
+ same-name button is correct. Script locators reject non-unique matches.
69
98
  5. If a matching ref includes `frameId`, pass the ref normally; do not pass `frameId` manually.
70
- 6. Keep the selected `page.pageId` and pass it back to `click_ref` / `type_ref` when multiple pages are open.
99
+ 6. Keep `page.pageId` and `snapshot.snapshotId` and pass both back to the single-step action. For
100
+ multiple instances, also keep the same `browserInstance`; it is not inferred from the ref.
71
101
 
72
102
  Do not construct refs manually. Only pass refs emitted by the most recent snapshot for that page.
73
103
 
74
104
  ## Action Flow
75
105
 
76
- ```bash
77
- roll run browser-use-agent browser_snapshot --input-json '{"interactiveOnly":true}' --json
78
- roll run browser-use-agent click_ref --input-json '{"ref":"@e3"}' --json
79
- roll run browser-use-agent browser_snapshot --input-json '{"interactiveOnly":true}' --json
106
+ First obtain a real `pageId` from `list_pages`, then call `browser_snapshot` with that page and an
107
+ optional region. Build the action from the returned identities and the selected ref. For example,
108
+ the following `click_ref` JSON is a template: replace both placeholders and `@e3` with values from
109
+ the same current snapshot; do not copy a ref from another execution.
110
+
111
+ ```json
112
+ {
113
+ "pageId": "<page.pageId>",
114
+ "snapshotId": "<snapshot.snapshotId>",
115
+ "ref": "@e3"
116
+ }
80
117
  ```
81
118
 
82
- For text input:
83
-
84
- ```bash
85
- roll run browser-use-agent type_ref --input-json '{"ref":"@e5","text":"hello","clear":true}' --json
86
- ```
119
+ Save the completed object as an input file and use
120
+ `roll run browser-use-agent click_ref --input-file <input-file> --json`. For `type_ref`, use a
121
+ textbox ref and add `text` and optional `clear:true`. Add the same `browserInstance` used to obtain
122
+ the snapshot when selecting an instance explicitly.
87
123
 
88
124
  When `BROWSER_SECURITY_JSON.actionPolicy` is `confirm`, the first side-effecting action can return
89
- `needs_confirmation`. In that case, take `details.approvalRequest.retryInput` from the structured
90
- error and merge it into the retry input unchanged.
125
+ `needs_confirmation`. Obtain explicit user approval before merging
126
+ `details.approvalRequest.retryInput` into the original input unchanged. Possessing the returned
127
+ credential is not user approval. Single-step tools use `browserActionApproval`; controlled scripts
128
+ use `scriptApproval`, and workflow activation uses `toolActionApproval`. Do not interchange them.
129
+
130
+ Single-step `success:true` confirms dispatch, not a verified business outcome. Read the resulting
131
+ field or business state, or use `browser_execute` with an explicit `expect` / `postconditions` and
132
+ check `verification`. Refresh the snapshot when the next action needs new target information;
133
+ do not require a full-page snapshot after every action.
91
134
 
92
135
  ## Visual Feedback
93
136
 
@@ -112,15 +155,20 @@ Refresh the snapshot before reusing `@eN` after any of these events:
112
155
  - a prior `click_ref` that may re-render the target area
113
156
  - `click_ref` / `type_ref` returns a stale-ref or not-found error
114
157
 
115
- `click_ref` and `type_ref` first resolve by `backendNodeId` when the ref has one. If that fails, they
116
- fall back to `role/name/nth`. The fallback is useful for small re-renders, but it is not a business
117
- identity.
158
+ With `snapshotId`, the latest snapshot, browser instance, page and document must all match; a
159
+ detached backend node stops the action without `role/name/nth` fallback. A newer snapshot also
160
+ invalidates the older snapshot identity. Scripts always require this strict binding for
161
+ `page.ref(ref, snapshotId)`.
162
+
163
+ Legacy `click_ref` / `type_ref` calls without `snapshotId` first resolve by `backendNodeId`, then may
164
+ fall back to `role/name/nth`. That fallback preserves compatibility but is not a business identity;
165
+ prefer strict mode for new callers.
118
166
 
119
167
  ## Relationship To BOSS Refs
120
168
 
121
169
  | Ref family | Produced by | Consumed by | Meaning |
122
170
  | --- | --- | --- | --- |
123
- | `@eN` | `browser_snapshot` | `click_ref`, `type_ref` | Generic AX element handle for the current page snapshot. |
171
+ | `@eN` | `browser_snapshot` or script `page.snapshot()` | `click_ref`, `type_ref`, script `page.ref(ref, snapshotId)` | Generic AX element handle for the originating instance/page snapshot. |
124
172
  | `@cN` | `zhipin_get_candidate_list` | `zhipin_say_hello`, `zhipin_open_resume` | BOSS recommendation candidate handle. |
125
173
  | `@jN` | `zhipin_list_recommend_jobs` | `zhipin_select_recommend_job` | BOSS recommendation job-filter handle. |
126
174
 
@@ -143,8 +191,12 @@ Do not pass one ref family into another tool family.
143
191
  resolve child `frameId` values. The recursion stops at `maxNodes`, skipped frame errors, or repeated
144
192
  frame IDs. Cross-target/OOPIF iframe traversal is not implemented here because it requires flattened
145
193
  CDP `sessionId` routing, which this native controller intentionally does not expose yet.
146
- - Only click and text input are covered. Drag, hover, keyboard shortcuts, file upload, and complex gestures still need
147
- dedicated tools.
194
+ - These single-step ref tools cover click and text input. `browser_execute` additionally supports
195
+ controlled hover, key presses, scrolling, navigation, waits and assertions. Arbitrary browser
196
+ shortcuts, file upload and complex gestures are outside that helper surface.
197
+ - Generic pointer/text actions check same-origin iframe ancestors for overlays and focus changes.
198
+ Unsupported transforms return a coverage gap; cross-origin ancestry is also blocked, with origin
199
+ policy errors taking precedence when an origin is not allowed.
148
200
  - The implementation does not call `Runtime.enable()` for the native CDP path. Fallback matching may use
149
201
  `Runtime.evaluate`, but it does not enable the Runtime domain. This avoids that specific detection point, not every
150
202
  possible anti-automation signal.