@jobshimo/browser-link 0.23.6 → 0.23.8
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/agent-instructions/content.js +17 -7
- package/dist/agent-instructions/content.js.map +1 -1
- package/dist/cdp/flow.d.ts +74 -10
- package/dist/cdp/flow.js +56 -19
- package/dist/cdp/flow.js.map +1 -1
- package/dist/cdp/inpage/builders.d.ts +17 -2
- package/dist/cdp/inpage/builders.js +13 -8
- package/dist/cdp/inpage/builders.js.map +1 -1
- package/dist/cdp/inpage/deep-query.d.ts +1 -1
- package/dist/cdp/inpage/deep-query.js +27 -1
- package/dist/cdp/inpage/deep-query.js.map +1 -1
- package/dist/cdp/inpage/dom-helpers.d.ts +1 -1
- package/dist/cdp/inpage/dom-helpers.js +16 -0
- package/dist/cdp/inpage/dom-helpers.js.map +1 -1
- package/dist/cdp/transport.js +7 -0
- package/dist/cdp/transport.js.map +1 -1
- package/dist/commands/about.js +2 -2
- package/dist/commands/about.js.map +1 -1
- package/dist/extension/background.js +297 -276
- package/dist/extension/background.js.map +1 -1
- package/dist/extension/flow.d.ts +74 -10
- package/dist/extension/flow.js +56 -19
- package/dist/extension/flow.js.map +1 -1
- package/dist/extension/inpage/builders.d.ts +17 -2
- package/dist/extension/inpage/builders.js +13 -8
- package/dist/extension/inpage/builders.js.map +1 -1
- package/dist/extension/inpage/deep-query.d.ts +1 -1
- package/dist/extension/inpage/deep-query.js +27 -1
- package/dist/extension/inpage/deep-query.js.map +1 -1
- package/dist/extension/inpage/dom-helpers.d.ts +1 -1
- package/dist/extension/inpage/dom-helpers.js +16 -0
- package/dist/extension/inpage/dom-helpers.js.map +1 -1
- package/dist/extension/manifest.json +1 -1
- package/dist/map/tools.js +2 -2
- package/dist/map/tools.js.map +1 -1
- package/dist/permissions.js +1 -1
- package/dist/permissions.js.map +1 -1
- package/dist/tools/browser-definitions.js +36 -8
- package/dist/tools/browser-definitions.js.map +1 -1
- package/dist/tools/browser-dispatch.js +62 -2
- package/dist/tools/browser-dispatch.js.map +1 -1
- package/dist/tools/server-instructions.js +10 -4
- package/dist/tools/server-instructions.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
* optional `frame` field with the innermost hosting iframe's selector, and
|
|
13
13
|
* entries whose generated selector could not be made unique across the deep
|
|
14
14
|
* search scope carry `ambiguous: true` (see `genSelectorInfo`).
|
|
15
|
+
*
|
|
16
|
+
* Interactive entries are gated by `isClickTarget`, not bare `isVisible`:
|
|
17
|
+
* a computed `pointer-events: none` element can never receive a real click
|
|
18
|
+
* (see the helper's comment in `dom-helpers.ts`). Headings and the text
|
|
19
|
+
* dump keep plain `isVisible`, so such elements still contribute text.
|
|
15
20
|
*/
|
|
16
21
|
export interface SnapshotOpts {
|
|
17
22
|
within_selector?: string;
|
|
@@ -27,7 +32,9 @@ export declare function buildSnapshotJs(opts?: SnapshotOpts): string;
|
|
|
27
32
|
*
|
|
28
33
|
* Role-aware: when `role` is provided, only elements whose explicit ARIA
|
|
29
34
|
* role or implicit role match are considered. When omitted, the search
|
|
30
|
-
* scans a broad set of interactive + clickable elements.
|
|
35
|
+
* scans a broad set of interactive + clickable elements. Candidates are
|
|
36
|
+
* gated by `isClickTarget` — a pointer-events:none element is never a
|
|
37
|
+
* match; it can still surface as a near-miss hint (plain `isVisible`).
|
|
31
38
|
*
|
|
32
39
|
* The scan pierces open Shadow DOM roots and same-origin iframes via
|
|
33
40
|
* `deepQueryAll`. `coords` are mapped to TOP-LEVEL viewport coordinates
|
|
@@ -62,11 +69,19 @@ export declare function buildFindJs(opts: FindOpts): string;
|
|
|
62
69
|
* view, computes the TOP-LEVEL viewport click point, and — unless `force`
|
|
63
70
|
* is set — hit-tests that point before returning it, so a covering overlay
|
|
64
71
|
* is caught before background.ts dispatches CDP mouse events. Returns:
|
|
65
|
-
* { ok: true, x, y, tag }
|
|
72
|
+
* { ok: true, x, y, tag, hit_element? }
|
|
66
73
|
* { ok: false, reason: 'invalid-selector', error }
|
|
67
74
|
* { ok: false, reason: 'not-found' }
|
|
68
75
|
* { ok: false, reason: 'occluded', blocker }
|
|
69
76
|
*
|
|
77
|
+
* `hit_element` is present ONLY when the dispatched click will land on a
|
|
78
|
+
* DIFFERENT element than the resolved target (neither the target nor a
|
|
79
|
+
* descendant): a pointer-events:none target whose real hit-target sibling
|
|
80
|
+
* takes the click (allowed, not 'occluded' — see checkOcclusion), an
|
|
81
|
+
* ancestor wrapper, or a `force` click landing on whatever covers the
|
|
82
|
+
* point — the hit-test runs under `force` too, which skips the BLOCK,
|
|
83
|
+
* not the truth-telling.
|
|
84
|
+
*
|
|
70
85
|
* The `invalid-selector` check runs BEFORE `deepQueryFirst` — a malformed
|
|
71
86
|
* CSS selector throws the identical `SyntaxError` from every root's own
|
|
72
87
|
* `querySelector`, which `deepQueryFirst`'s per-root try/catch otherwise
|
|
@@ -67,7 +67,9 @@ export function buildSnapshotJs(opts = {}) {
|
|
|
67
67
|
const sel = 'a[href], button, input, select, textarea, [role=button], [role=link], [role=checkbox], [role=tab], [role=menuitem], [contenteditable=true]';
|
|
68
68
|
const interactive = [];
|
|
69
69
|
deepQueryAll(sel, root).forEach((el) => {
|
|
70
|
-
|
|
70
|
+
// isClickTarget, not isVisible: a pointer-events:none element can
|
|
71
|
+
// never receive a real click. Headings/text keep plain isVisible.
|
|
72
|
+
if (!isClickTarget(el)) return;
|
|
71
73
|
if (inExcludedLandmark(el)) return;
|
|
72
74
|
const tag = el.tagName.toLowerCase();
|
|
73
75
|
const role = el.getAttribute('role') || tag;
|
|
@@ -145,7 +147,9 @@ export function buildFindJs(opts) {
|
|
|
145
147
|
const all = deepQueryAll(selectorSet);
|
|
146
148
|
const matches = [];
|
|
147
149
|
for (const el of all) {
|
|
148
|
-
|
|
150
|
+
// isClickTarget, not isVisible: find returns CLICK TARGETS. Near-miss
|
|
151
|
+
// ranking below keeps plain isVisible — hints, never click targets.
|
|
152
|
+
if (!isClickTarget(el)) continue;
|
|
149
153
|
const text = accessibleText(el).trim();
|
|
150
154
|
if (text.length === 0) continue;
|
|
151
155
|
const lower = text.toLowerCase();
|
|
@@ -278,13 +282,14 @@ export function buildClickResolveJs(opts) {
|
|
|
278
282
|
if (el.scrollIntoView) el.scrollIntoView({ block: 'center', inline: 'center' });
|
|
279
283
|
const center = viewportCenterOf(el);
|
|
280
284
|
const tag = el.tagName.toLowerCase();
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
return { ok: false, reason: 'occluded', blocker: occlusion.blocker };
|
|
285
|
-
}
|
|
285
|
+
const occlusion = checkOcclusion(el, center.localX, center.localY);
|
|
286
|
+
if (!occlusion.allowed && !opts.force) {
|
|
287
|
+
return { ok: false, reason: 'occluded', blocker: occlusion.blocker };
|
|
286
288
|
}
|
|
287
|
-
|
|
289
|
+
const result = { ok: true, x: center.x, y: center.y, tag };
|
|
290
|
+
const hit = occlusion.allowed ? occlusion.hit : occlusion.blocker;
|
|
291
|
+
if (hit) result.hit_element = hit;
|
|
292
|
+
return result;
|
|
288
293
|
})()
|
|
289
294
|
`;
|
|
290
295
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.js","sourceRoot":"","sources":["../../src/inpage/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"builders.js","sourceRoot":"","sources":["../../src/inpage/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA6BlD,MAAM,UAAU,eAAe,CAAC,OAAqB,EAAE;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC9B,cAAc,EAAE,O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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDrB,CAAC;AACF,CAAC;AA8BD,MAAM,UAAU,aAAa,CAAC,IAAgB;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC9B,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;QACrC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC;KAC/C,CAAC,CAAC;IACH,OAAO;;iBAEQ,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6CpB,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO;;IAEL,aAAa;IACb,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmFjB,CAAC;AACF,CAAC"}
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
* `dom-helpers.ts`), snapshot/find mark the affected entry with
|
|
38
38
|
* `ambiguous: true` so agents know not to cache that selector.
|
|
39
39
|
*/
|
|
40
|
-
export declare const DEEP_QUERY_JS = "\n function collectSearchRoots(start) {\n // start: a Document, Element or ShadowRoot to scope the search to.\n // Returns [start, ...every open shadow root and same-origin iframe\n // document reachable inside start's subtree, recursively]. The caller\n // runs .querySelectorAll()/.querySelector() on each entry directly \u2014\n // each entry's own querySelectorAll does NOT pierce into nested shadow\n // roots or iframes on its own, which is why we enumerate them here.\n var roots = [start];\n function walk(scope, depth) {\n // Depth guard, same pattern as the other recursive helpers here:\n // pathological nesting (or a cycle introduced by a broken mock)\n // must degrade to a truncated result, never a stack overflow.\n if (depth > 20) return;\n var all;\n try {\n all = scope.querySelectorAll('*');\n } catch (_) {\n return;\n }\n for (var i = 0; i < all.length; i++) {\n var el = all[i];\n if (el.shadowRoot) {\n roots.push(el.shadowRoot);\n walk(el.shadowRoot, depth + 1);\n }\n if (el.tagName === 'IFRAME') {\n var doc = null;\n try {\n doc = el.contentDocument;\n } catch (_) {\n doc = null;\n }\n if (doc) {\n roots.push(doc);\n walk(doc, depth + 1);\n }\n }\n }\n }\n walk(start, 0);\n return roots;\n }\n\n function deepWalkAll(callback, start) {\n // Tree-walk primitive: invoke callback(el) for every element reachable\n // from start (default: document) across the top document, every open\n // shadow root, and every same-origin iframe document.\n var root = start || document;\n var roots = collectSearchRoots(root);\n for (var r = 0; r < roots.length; r++) {\n var all;\n try {\n all = roots[r].querySelectorAll('*');\n } catch (_) {\n continue;\n }\n for (var i = 0; i < all.length; i++) callback(all[i]);\n }\n }\n\n function deepQueryAll(selector, start) {\n var root = start || document;\n var roots = collectSearchRoots(root);\n var out = [];\n for (var r = 0; r < roots.length; r++) {\n var found;\n try {\n found = roots[r].querySelectorAll(selector);\n } catch (_) {\n continue;\n }\n for (var i = 0; i < found.length; i++) out.push(found[i]);\n }\n return out;\n }\n\n function deepQueryFirst(selector, start) {\n var root = start || document;\n var roots = collectSearchRoots(root);\n for (var r = 0; r < roots.length; r++) {\n var el = null;\n try {\n el = roots[r].querySelector(selector);\n } catch (_) {\n el = null;\n }\n if (el) return el;\n }\n return null;\n }\n\n function frameElementChain(el) {\n // Walk up from el's own window to the top window, collecting the\n // <iframe> element that hosts each intermediate document. Outermost\n // frame first. Same-origin only \u2014 frameElement throws/returns null\n // across an origin boundary, at which point the chain simply stops\n // (the coordinate math below degrades gracefully rather than throwing).\n var chain = [];\n var doc = el.ownerDocument;\n var win = doc && doc.defaultView;\n if (!win) return chain;\n var topWin;\n try {\n topWin = win.top;\n } catch (_) {\n topWin = win;\n }\n var guard = 0;\n while (win && win !== topWin && guard < 20) {\n guard++;\n var fe = null;\n try {\n fe = win.frameElement;\n } catch (_) {\n fe = null;\n }\n if (!fe) break;\n chain.unshift(fe);\n win = fe.ownerDocument && fe.ownerDocument.defaultView;\n }\n return chain;\n }\n\n function frameViewportOriginOffset(fe) {\n // The embedded document's viewport origin sits at the frame element's\n // CONTENT box, but getBoundingClientRect() returns the BORDER box \u2014\n // border and padding must be added on top of rect.left/rect.top or\n // every coordinate inside a styled iframe lands short. clientLeft/\n // clientTop are the border widths; padding comes from computed style\n // (read through the frame's own view \u2014 same-origin, so reachable).\n var borderX = fe.clientLeft || 0;\n var borderY = fe.clientTop || 0;\n var padX = 0;\n var padY = 0;\n try {\n var view = (fe.ownerDocument && fe.ownerDocument.defaultView) || window;\n var style = view.getComputedStyle(fe);\n padX = parseFloat(style.paddingLeft) || 0;\n padY = parseFloat(style.paddingTop) || 0;\n } catch (_) {}\n return { x: borderX + padX, y: borderY + padY };\n }\n\n function clickRectOf(el) {\n // For a line-wrapped INLINE element (a link spanning two lines), the\n // center of getBoundingClientRect() can land in the unpainted gap\n // between the line boxes \u2014 elementFromPoint would report whatever sits\n // behind, and a dispatched click would miss. The first client rect is\n // always a painted fragment, so its center is a safe click point.\n // Block-level elements have exactly one client rect, identical to the\n // bounding rect \u2014 no behavior change for them.\n var rects = null;\n try {\n rects = el.getClientRects ? el.getClientRects() : null;\n } catch (_) {\n rects = null;\n }\n if (rects && rects.length > 0) return rects[0];\n return el.getBoundingClientRect();\n }\n\n function viewportCenterOf(el) {\n // Returns the element's click point in two coordinate spaces:\n // - localX/localY: relative to el's OWN document viewport (what\n // that document's elementFromPoint expects).\n // - x/y: relative to the TOP-LEVEL viewport (what CDP\n // Input.dispatchMouseEvent expects) \u2014 localX/localY plus the\n // accumulated content-box origin of every ancestor <iframe>\n // element (border-box rect + border + padding). Shadow DOM\n // boundaries need no offset: they do not introduce a new\n // coordinate space.\n // Both spaces derive from the SAME point (first-client-rect center),\n // so the occlusion hit-test and the CDP dispatch always agree.\n var rect = clickRectOf(el);\n var localX = rect.left + rect.width / 2;\n var localY = rect.top + rect.height / 2;\n var chain = frameElementChain(el);\n var offsetX = 0;\n var offsetY = 0;\n for (var i = 0; i < chain.length; i++) {\n var frameRect = chain[i].getBoundingClientRect();\n var origin = frameViewportOriginOffset(chain[i]);\n offsetX += frameRect.left + origin.x;\n offsetY += frameRect.top + origin.y;\n }\n return { x: offsetX + localX, y: offsetY + localY, localX: localX, localY: localY };\n }\n\n function composedContains(ancestor, node) {\n // Node.contains() does not cross shadow boundaries. This walks the\n // COMPOSED tree: when climbing hits a ShadowRoot (no parentNode), jump\n // to its host and keep climbing.\n var cur = node;\n var guard = 0;\n while (cur && guard < 1000) {\n guard++;\n if (cur === ancestor) return true;\n if (cur.parentNode) {\n cur = cur.parentNode;\n continue;\n }\n if (cur.host) {\n cur = cur.host;\n continue;\n }\n break;\n }\n return false;\n }\n\n function describeElement(el) {\n if (!el || !el.tagName) return 'an unknown element';\n var desc = el.tagName.toLowerCase();\n if (el.id) desc += '#' + el.id;\n if (el.classList && el.classList.length) {\n var classes = [];\n for (var i = 0; i < el.classList.length && i < 2; i++) classes.push(el.classList[i]);\n if (classes.length) desc += '.' + classes.join('.');\n }\n return desc;\n }\n\n function hitTestDeep(root, x, y) {\n var node = null;\n try {\n node = root && root.elementFromPoint ? root.elementFromPoint(x, y) : null;\n } catch (_) {\n node = null;\n }\n // The hit element may itself host a nested open shadow root whose\n // content visually covers the point \u2014 descend until elementFromPoint\n // stops finding a deeper shadow tree.\n var guard = 0;\n while (node && node.shadowRoot && guard < 20) {\n guard++;\n var inner = null;\n try {\n inner = node.shadowRoot.elementFromPoint ? node.shadowRoot.elementFromPoint(x, y) : null;\n } catch (_) {\n inner = null;\n }\n if (!inner || inner === node) break;\n node = inner;\n }\n return node;\n }\n\n function checkOcclusion(target, localX, localY) {\n // Hit-test starting from the element's OWN root (its closest shadow\n // root, or the document that owns it when not in shadow DOM) using\n // LOCAL coordinates \u2014 the same coordinate space that root's own\n // elementFromPoint expects (an iframe document's viewport starts at\n // its own top-left, not the top-level page's).\n var root = target.getRootNode ? target.getRootNode() : document;\n var hit = hitTestDeep(root, localX, localY);\n if (!hit) {\n // Nothing hit-tested at all (e.g. elementFromPoint unsupported in\n // this environment, or the point is outside the rendered area).\n // Fail open rather than block a click we cannot actually verify.\n return { allowed: true };\n }\n if (hit === target || composedContains(target, hit) || composedContains(hit, target)) {\n return { allowed: true };\n }\n return { allowed: false, blocker: describeElement(hit) };\n }\n";
|
|
40
|
+
export declare const DEEP_QUERY_JS = "\n function collectSearchRoots(start) {\n // start: a Document, Element or ShadowRoot to scope the search to.\n // Returns [start, ...every open shadow root and same-origin iframe\n // document reachable inside start's subtree, recursively]. The caller\n // runs .querySelectorAll()/.querySelector() on each entry directly \u2014\n // each entry's own querySelectorAll does NOT pierce into nested shadow\n // roots or iframes on its own, which is why we enumerate them here.\n var roots = [start];\n function walk(scope, depth) {\n // Depth guard, same pattern as the other recursive helpers here:\n // pathological nesting (or a cycle introduced by a broken mock)\n // must degrade to a truncated result, never a stack overflow.\n if (depth > 20) return;\n var all;\n try {\n all = scope.querySelectorAll('*');\n } catch (_) {\n return;\n }\n for (var i = 0; i < all.length; i++) {\n var el = all[i];\n if (el.shadowRoot) {\n roots.push(el.shadowRoot);\n walk(el.shadowRoot, depth + 1);\n }\n if (el.tagName === 'IFRAME') {\n var doc = null;\n try {\n doc = el.contentDocument;\n } catch (_) {\n doc = null;\n }\n if (doc) {\n roots.push(doc);\n walk(doc, depth + 1);\n }\n }\n }\n }\n walk(start, 0);\n return roots;\n }\n\n function deepWalkAll(callback, start) {\n // Tree-walk primitive: invoke callback(el) for every element reachable\n // from start (default: document) across the top document, every open\n // shadow root, and every same-origin iframe document.\n var root = start || document;\n var roots = collectSearchRoots(root);\n for (var r = 0; r < roots.length; r++) {\n var all;\n try {\n all = roots[r].querySelectorAll('*');\n } catch (_) {\n continue;\n }\n for (var i = 0; i < all.length; i++) callback(all[i]);\n }\n }\n\n function deepQueryAll(selector, start) {\n var root = start || document;\n var roots = collectSearchRoots(root);\n var out = [];\n for (var r = 0; r < roots.length; r++) {\n var found;\n try {\n found = roots[r].querySelectorAll(selector);\n } catch (_) {\n continue;\n }\n for (var i = 0; i < found.length; i++) out.push(found[i]);\n }\n return out;\n }\n\n function deepQueryFirst(selector, start) {\n var root = start || document;\n var roots = collectSearchRoots(root);\n for (var r = 0; r < roots.length; r++) {\n var el = null;\n try {\n el = roots[r].querySelector(selector);\n } catch (_) {\n el = null;\n }\n if (el) return el;\n }\n return null;\n }\n\n function frameElementChain(el) {\n // Walk up from el's own window to the top window, collecting the\n // <iframe> element that hosts each intermediate document. Outermost\n // frame first. Same-origin only \u2014 frameElement throws/returns null\n // across an origin boundary, at which point the chain simply stops\n // (the coordinate math below degrades gracefully rather than throwing).\n var chain = [];\n var doc = el.ownerDocument;\n var win = doc && doc.defaultView;\n if (!win) return chain;\n var topWin;\n try {\n topWin = win.top;\n } catch (_) {\n topWin = win;\n }\n var guard = 0;\n while (win && win !== topWin && guard < 20) {\n guard++;\n var fe = null;\n try {\n fe = win.frameElement;\n } catch (_) {\n fe = null;\n }\n if (!fe) break;\n chain.unshift(fe);\n win = fe.ownerDocument && fe.ownerDocument.defaultView;\n }\n return chain;\n }\n\n function frameViewportOriginOffset(fe) {\n // The embedded document's viewport origin sits at the frame element's\n // CONTENT box, but getBoundingClientRect() returns the BORDER box \u2014\n // border and padding must be added on top of rect.left/rect.top or\n // every coordinate inside a styled iframe lands short. clientLeft/\n // clientTop are the border widths; padding comes from computed style\n // (read through the frame's own view \u2014 same-origin, so reachable).\n var borderX = fe.clientLeft || 0;\n var borderY = fe.clientTop || 0;\n var padX = 0;\n var padY = 0;\n try {\n var view = (fe.ownerDocument && fe.ownerDocument.defaultView) || window;\n var style = view.getComputedStyle(fe);\n padX = parseFloat(style.paddingLeft) || 0;\n padY = parseFloat(style.paddingTop) || 0;\n } catch (_) {}\n return { x: borderX + padX, y: borderY + padY };\n }\n\n function clickRectOf(el) {\n // For a line-wrapped INLINE element (a link spanning two lines), the\n // center of getBoundingClientRect() can land in the unpainted gap\n // between the line boxes \u2014 elementFromPoint would report whatever sits\n // behind, and a dispatched click would miss. The first client rect is\n // always a painted fragment, so its center is a safe click point.\n // Block-level elements have exactly one client rect, identical to the\n // bounding rect \u2014 no behavior change for them.\n var rects = null;\n try {\n rects = el.getClientRects ? el.getClientRects() : null;\n } catch (_) {\n rects = null;\n }\n if (rects && rects.length > 0) return rects[0];\n return el.getBoundingClientRect();\n }\n\n function viewportCenterOf(el) {\n // Returns the element's click point in two coordinate spaces:\n // - localX/localY: relative to el's OWN document viewport (what\n // that document's elementFromPoint expects).\n // - x/y: relative to the TOP-LEVEL viewport (what CDP\n // Input.dispatchMouseEvent expects) \u2014 localX/localY plus the\n // accumulated content-box origin of every ancestor <iframe>\n // element (border-box rect + border + padding). Shadow DOM\n // boundaries need no offset: they do not introduce a new\n // coordinate space.\n // Both spaces derive from the SAME point (first-client-rect center),\n // so the occlusion hit-test and the CDP dispatch always agree.\n var rect = clickRectOf(el);\n var localX = rect.left + rect.width / 2;\n var localY = rect.top + rect.height / 2;\n var chain = frameElementChain(el);\n var offsetX = 0;\n var offsetY = 0;\n for (var i = 0; i < chain.length; i++) {\n var frameRect = chain[i].getBoundingClientRect();\n var origin = frameViewportOriginOffset(chain[i]);\n offsetX += frameRect.left + origin.x;\n offsetY += frameRect.top + origin.y;\n }\n return { x: offsetX + localX, y: offsetY + localY, localX: localX, localY: localY };\n }\n\n function composedContains(ancestor, node) {\n // Node.contains() does not cross shadow boundaries. This walks the\n // COMPOSED tree: when climbing hits a ShadowRoot (no parentNode), jump\n // to its host and keep climbing.\n var cur = node;\n var guard = 0;\n while (cur && guard < 1000) {\n guard++;\n if (cur === ancestor) return true;\n if (cur.parentNode) {\n cur = cur.parentNode;\n continue;\n }\n if (cur.host) {\n cur = cur.host;\n continue;\n }\n break;\n }\n return false;\n }\n\n function describeElement(el) {\n if (!el || !el.tagName) return 'an unknown element';\n var desc = el.tagName.toLowerCase();\n if (el.id) desc += '#' + el.id;\n if (el.classList && el.classList.length) {\n var classes = [];\n for (var i = 0; i < el.classList.length && i < 2; i++) classes.push(el.classList[i]);\n if (classes.length) desc += '.' + classes.join('.');\n }\n return desc;\n }\n\n function hitTestDeep(root, x, y) {\n var node = null;\n try {\n node = root && root.elementFromPoint ? root.elementFromPoint(x, y) : null;\n } catch (_) {\n node = null;\n }\n // The hit element may itself host a nested open shadow root whose\n // content visually covers the point \u2014 descend until elementFromPoint\n // stops finding a deeper shadow tree.\n var guard = 0;\n while (node && node.shadowRoot && guard < 20) {\n guard++;\n var inner = null;\n try {\n inner = node.shadowRoot.elementFromPoint ? node.shadowRoot.elementFromPoint(x, y) : null;\n } catch (_) {\n inner = null;\n }\n if (!inner || inner === node) break;\n node = inner;\n }\n return node;\n }\n\n function computedPointerEvents(el) {\n // Read through the element's own window (cross-document\n // getComputedStyle is unreliable); any failure fails open (not 'none').\n try {\n var view = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n return view.getComputedStyle(el).pointerEvents;\n } catch (_) {\n return '';\n }\n }\n\n function checkOcclusion(target, localX, localY) {\n // Hit-test starting from the element's OWN root (its closest shadow\n // root, or the document that owns it when not in shadow DOM) using\n // LOCAL coordinates \u2014 the same coordinate space that root's own\n // elementFromPoint expects (an iframe document's viewport starts at\n // its own top-left, not the top-level page's).\n var root = target.getRootNode ? target.getRootNode() : document;\n var hit = hitTestDeep(root, localX, localY);\n if (!hit) {\n // Nothing hit-tested at all (e.g. elementFromPoint unsupported in\n // this environment, or the point is outside the rendered area).\n // Fail open rather than block a click we cannot actually verify.\n return { allowed: true };\n }\n if (hit === target || composedContains(target, hit)) {\n return { allowed: true };\n }\n if (composedContains(hit, target)) {\n // ANCESTOR hit: the click targets the ancestor and never reaches\n // the element itself (events bubble upward, not down). Allowed as\n // before, but surfaced so click results can report hit_element.\n return { allowed: true, hit: describeElement(hit) };\n }\n if (computedPointerEvents(target) === 'none') {\n // A pointer-events:none target can never be the hit-test result \u2014 a\n // real user click at this exact point reaches hit instead, by the\n // page's own design (invisible a11y layer over the visual control's\n // hit-target sibling, e.g. Articulate Storyline). The hit is not a\n // blocker to dismiss; it IS what a real click activates, so allow\n // the dispatch and report the true recipient.\n return { allowed: true, hit: describeElement(hit) };\n }\n return { allowed: false, blocker: describeElement(hit) };\n }\n";
|
|
@@ -285,6 +285,17 @@ export const DEEP_QUERY_JS = `
|
|
|
285
285
|
return node;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
function computedPointerEvents(el) {
|
|
289
|
+
// Read through the element's own window (cross-document
|
|
290
|
+
// getComputedStyle is unreliable); any failure fails open (not 'none').
|
|
291
|
+
try {
|
|
292
|
+
var view = (el.ownerDocument && el.ownerDocument.defaultView) || window;
|
|
293
|
+
return view.getComputedStyle(el).pointerEvents;
|
|
294
|
+
} catch (_) {
|
|
295
|
+
return '';
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
288
299
|
function checkOcclusion(target, localX, localY) {
|
|
289
300
|
// Hit-test starting from the element's OWN root (its closest shadow
|
|
290
301
|
// root, or the document that owns it when not in shadow DOM) using
|
|
@@ -299,9 +310,24 @@ export const DEEP_QUERY_JS = `
|
|
|
299
310
|
// Fail open rather than block a click we cannot actually verify.
|
|
300
311
|
return { allowed: true };
|
|
301
312
|
}
|
|
302
|
-
if (hit === target || composedContains(target, hit)
|
|
313
|
+
if (hit === target || composedContains(target, hit)) {
|
|
303
314
|
return { allowed: true };
|
|
304
315
|
}
|
|
316
|
+
if (composedContains(hit, target)) {
|
|
317
|
+
// ANCESTOR hit: the click targets the ancestor and never reaches
|
|
318
|
+
// the element itself (events bubble upward, not down). Allowed as
|
|
319
|
+
// before, but surfaced so click results can report hit_element.
|
|
320
|
+
return { allowed: true, hit: describeElement(hit) };
|
|
321
|
+
}
|
|
322
|
+
if (computedPointerEvents(target) === 'none') {
|
|
323
|
+
// A pointer-events:none target can never be the hit-test result — a
|
|
324
|
+
// real user click at this exact point reaches hit instead, by the
|
|
325
|
+
// page's own design (invisible a11y layer over the visual control's
|
|
326
|
+
// hit-target sibling, e.g. Articulate Storyline). The hit is not a
|
|
327
|
+
// blocker to dismiss; it IS what a real click activates, so allow
|
|
328
|
+
// the dispatch and report the true recipient.
|
|
329
|
+
return { allowed: true, hit: describeElement(hit) };
|
|
330
|
+
}
|
|
305
331
|
return { allowed: false, blocker: describeElement(hit) };
|
|
306
332
|
}
|
|
307
333
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-query.js","sourceRoot":"","sources":["../../src/inpage/deep-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG
|
|
1
|
+
{"version":3,"file":"deep-query.js","sourceRoot":"","sources":["../../src/inpage/deep-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqS5B,CAAC"}
|
|
@@ -19,4 +19,4 @@
|
|
|
19
19
|
* snapshot/find builders surface it on the affected entry so agents know
|
|
20
20
|
* that selector resolves first-match-wins and must not be cached.
|
|
21
21
|
*/
|
|
22
|
-
export declare const DOM_HELPERS_JS = "\n function isVisible(el) {\n if (!(el instanceof HTMLElement)) return true;\n const style = getComputedStyle(el);\n if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') return false;\n if (el.offsetParent === null && style.position !== 'fixed') return false;\n return true;\n }\n function shortText(el) {\n const t = (el.innerText || el.textContent || '').trim();\n return t.length > 120 ? t.slice(0, 120) + '...' : t;\n }\n function safeCss(s) {\n return s.replace(/\"/g, '\\\\\"');\n }\n function genSelectorInfo(el) {\n // Uniqueness is verified with deepQueryAll \u2014 an id/testid/aria-label/\n // name that is unique in the top document can still collide with an\n // identically-attributed element inside a shadow root or same-origin\n // iframe, since each root has its own independent attribute namespace.\n if (el.id && !/^[\\d]/.test(el.id) && !/\\s/.test(el.id)) {\n try {\n const candidate = '#' + CSS.escape(el.id);\n if (deepQueryAll(candidate).length === 1) return { selector: candidate, ambiguous: false };\n } catch (_) {}\n }\n const tid = el.getAttribute('data-testid');\n if (tid) {\n const candidate = '[data-testid=\"' + safeCss(tid) + '\"]';\n if (deepQueryAll(candidate).length === 1) return { selector: candidate, ambiguous: false };\n }\n const al = el.getAttribute('aria-label');\n if (al && al.length < 60) {\n const candidate = el.tagName.toLowerCase() + '[aria-label=\"' + safeCss(al) + '\"]';\n if (deepQueryAll(candidate).length === 1) return { selector: candidate, ambiguous: false };\n }\n const name = el.getAttribute('name');\n if (name && (el.tagName === 'INPUT' || el.tagName === 'SELECT' || el.tagName === 'TEXTAREA')) {\n const candidate = el.tagName.toLowerCase() + '[name=\"' + safeCss(name) + '\"]';\n if (deepQueryAll(candidate).length === 1) return { selector: candidate, ambiguous: false };\n }\n // Structural fallback, verified like every shortcut above. The short\n // form (6 parts, indexed only where siblings force it) is preferred\n // for stability; when it matches more than one element across roots,\n // retry with a fully-qualified path (every level :nth-of-type-indexed,\n // climbed all the way to the root boundary).\n const structural = buildStructuralSelector(el, 6, false);\n try {\n if (deepQueryAll(structural).length === 1) return { selector: structural, ambiguous: false };\n } catch (_) {}\n const qualified = buildStructuralSelector(el, 32, true);\n try {\n if (deepQueryAll(qualified).length === 1) return { selector: qualified, ambiguous: false };\n } catch (_) {}\n // Still ambiguous: structurally-identical twins in different roots.\n // No CSS syntax can scope a selector to one shadow root / iframe, so\n // return the most qualified path and flag it \u2014 deepQueryFirst will\n // resolve it first-match-wins (deterministic traversal order), and\n // the flag tells agents not to cache it.\n return { selector: qualified, ambiguous: true };\n }\n function genSelector(el) {\n return genSelectorInfo(el).selector;\n }\n function buildStructuralSelector(el, maxParts, alwaysIndex) {\n // Local-root-scoped structural path: CLIMBING stops at a shadow root or\n // document boundary (parentElement is null for a shadow root's direct\n // children) \u2014 matches how deepQueryAll scopes each root's own\n // querySelectorAll call, so the path resolves back to the same element\n // when re-queried through deepQueryFirst. Sibling lookup for the\n // :nth-of-type qualifier uses parentNode rather than parentElement so a\n // shadow root's own top-level children (parentNode = the ShadowRoot,\n // which still exposes .children) get disambiguated too, even though we\n // do not climb past that boundary. With alwaysIndex, every level gets\n // an explicit :nth-of-type \u2014 maximum qualification for the retry pass.\n const parts = [];\n let cur = el;\n while (cur && cur.nodeType === 1 && cur !== document.body && parts.length < maxParts) {\n let part = cur.tagName.toLowerCase();\n const parentNode = cur.parentNode;\n if (parentNode && parentNode.children) {\n const sib = Array.from(parentNode.children).filter(s => s.tagName === cur.tagName);\n if (sib.length > 1 || alwaysIndex) {\n part += ':nth-of-type(' + (sib.indexOf(cur) + 1) + ')';\n }\n }\n parts.unshift(part);\n cur = cur.parentElement;\n }\n return parts.join(' > ');\n }\n function accessibleText(el) {\n const aria = el.getAttribute && el.getAttribute('aria-label');\n if (aria) return aria;\n const txt = (el.innerText || el.textContent || '').trim();\n if (txt) return txt;\n if ('value' in el && el.value) return String(el.value);\n const ph = el.getAttribute && el.getAttribute('placeholder');\n if (ph) return ph;\n const title = el.getAttribute && el.getAttribute('title');\n if (title) return title;\n return '';\n }\n function frameSelectorFor(el) {\n // Lightweight context field for snapshot/find entries: the selector of\n // the innermost same-origin <iframe> hosting el, or null when el lives\n // in the top document. Computed via genSelector so it benefits from the\n // same deep-uniqueness verification.\n if (el.ownerDocument === document) return null;\n const win = el.ownerDocument && el.ownerDocument.defaultView;\n let fe = null;\n try {\n fe = win && win.frameElement;\n } catch (_) {\n fe = null;\n }\n if (!fe) return null;\n return genSelector(fe);\n }\n";
|
|
22
|
+
export declare const DOM_HELPERS_JS = "\n function isVisible(el) {\n if (!(el instanceof HTMLElement)) return true;\n const style = getComputedStyle(el);\n if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') return false;\n if (el.offsetParent === null && style.position !== 'fixed') return false;\n return true;\n }\n function isClickTarget(el) {\n // A computed pointer-events:none element can never be the browser's\n // hit-test result \u2014 frameworks with an invisible accessibility layer\n // (e.g. Articulate Storyline's #acc-* elements) stack such elements\n // over the real hit-target sibling, so advertising one produces\n // clicks that report success but land elsewhere. Per-element computed\n // check, NOT a subtree prune: a descendant can re-enable itself with\n // pointer-events: auto and IS a valid target. Only the interactive\n // collections use this gate \u2014 headings/text keep plain isVisible.\n if (!isVisible(el)) return false;\n try {\n const view = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n if (view.getComputedStyle(el).pointerEvents === 'none') return false;\n } catch (_) {}\n return true;\n }\n function shortText(el) {\n const t = (el.innerText || el.textContent || '').trim();\n return t.length > 120 ? t.slice(0, 120) + '...' : t;\n }\n function safeCss(s) {\n return s.replace(/\"/g, '\\\\\"');\n }\n function genSelectorInfo(el) {\n // Uniqueness is verified with deepQueryAll \u2014 an id/testid/aria-label/\n // name that is unique in the top document can still collide with an\n // identically-attributed element inside a shadow root or same-origin\n // iframe, since each root has its own independent attribute namespace.\n if (el.id && !/^[\\d]/.test(el.id) && !/\\s/.test(el.id)) {\n try {\n const candidate = '#' + CSS.escape(el.id);\n if (deepQueryAll(candidate).length === 1) return { selector: candidate, ambiguous: false };\n } catch (_) {}\n }\n const tid = el.getAttribute('data-testid');\n if (tid) {\n const candidate = '[data-testid=\"' + safeCss(tid) + '\"]';\n if (deepQueryAll(candidate).length === 1) return { selector: candidate, ambiguous: false };\n }\n const al = el.getAttribute('aria-label');\n if (al && al.length < 60) {\n const candidate = el.tagName.toLowerCase() + '[aria-label=\"' + safeCss(al) + '\"]';\n if (deepQueryAll(candidate).length === 1) return { selector: candidate, ambiguous: false };\n }\n const name = el.getAttribute('name');\n if (name && (el.tagName === 'INPUT' || el.tagName === 'SELECT' || el.tagName === 'TEXTAREA')) {\n const candidate = el.tagName.toLowerCase() + '[name=\"' + safeCss(name) + '\"]';\n if (deepQueryAll(candidate).length === 1) return { selector: candidate, ambiguous: false };\n }\n // Structural fallback, verified like every shortcut above. The short\n // form (6 parts, indexed only where siblings force it) is preferred\n // for stability; when it matches more than one element across roots,\n // retry with a fully-qualified path (every level :nth-of-type-indexed,\n // climbed all the way to the root boundary).\n const structural = buildStructuralSelector(el, 6, false);\n try {\n if (deepQueryAll(structural).length === 1) return { selector: structural, ambiguous: false };\n } catch (_) {}\n const qualified = buildStructuralSelector(el, 32, true);\n try {\n if (deepQueryAll(qualified).length === 1) return { selector: qualified, ambiguous: false };\n } catch (_) {}\n // Still ambiguous: structurally-identical twins in different roots.\n // No CSS syntax can scope a selector to one shadow root / iframe, so\n // return the most qualified path and flag it \u2014 deepQueryFirst will\n // resolve it first-match-wins (deterministic traversal order), and\n // the flag tells agents not to cache it.\n return { selector: qualified, ambiguous: true };\n }\n function genSelector(el) {\n return genSelectorInfo(el).selector;\n }\n function buildStructuralSelector(el, maxParts, alwaysIndex) {\n // Local-root-scoped structural path: CLIMBING stops at a shadow root or\n // document boundary (parentElement is null for a shadow root's direct\n // children) \u2014 matches how deepQueryAll scopes each root's own\n // querySelectorAll call, so the path resolves back to the same element\n // when re-queried through deepQueryFirst. Sibling lookup for the\n // :nth-of-type qualifier uses parentNode rather than parentElement so a\n // shadow root's own top-level children (parentNode = the ShadowRoot,\n // which still exposes .children) get disambiguated too, even though we\n // do not climb past that boundary. With alwaysIndex, every level gets\n // an explicit :nth-of-type \u2014 maximum qualification for the retry pass.\n const parts = [];\n let cur = el;\n while (cur && cur.nodeType === 1 && cur !== document.body && parts.length < maxParts) {\n let part = cur.tagName.toLowerCase();\n const parentNode = cur.parentNode;\n if (parentNode && parentNode.children) {\n const sib = Array.from(parentNode.children).filter(s => s.tagName === cur.tagName);\n if (sib.length > 1 || alwaysIndex) {\n part += ':nth-of-type(' + (sib.indexOf(cur) + 1) + ')';\n }\n }\n parts.unshift(part);\n cur = cur.parentElement;\n }\n return parts.join(' > ');\n }\n function accessibleText(el) {\n const aria = el.getAttribute && el.getAttribute('aria-label');\n if (aria) return aria;\n const txt = (el.innerText || el.textContent || '').trim();\n if (txt) return txt;\n if ('value' in el && el.value) return String(el.value);\n const ph = el.getAttribute && el.getAttribute('placeholder');\n if (ph) return ph;\n const title = el.getAttribute && el.getAttribute('title');\n if (title) return title;\n return '';\n }\n function frameSelectorFor(el) {\n // Lightweight context field for snapshot/find entries: the selector of\n // the innermost same-origin <iframe> hosting el, or null when el lives\n // in the top document. Computed via genSelector so it benefits from the\n // same deep-uniqueness verification.\n if (el.ownerDocument === document) return null;\n const win = el.ownerDocument && el.ownerDocument.defaultView;\n let fe = null;\n try {\n fe = win && win.frameElement;\n } catch (_) {\n fe = null;\n }\n if (!fe) return null;\n return genSelector(fe);\n }\n";
|
|
@@ -27,6 +27,22 @@ export const DOM_HELPERS_JS = `
|
|
|
27
27
|
if (el.offsetParent === null && style.position !== 'fixed') return false;
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
|
+
function isClickTarget(el) {
|
|
31
|
+
// A computed pointer-events:none element can never be the browser's
|
|
32
|
+
// hit-test result — frameworks with an invisible accessibility layer
|
|
33
|
+
// (e.g. Articulate Storyline's #acc-* elements) stack such elements
|
|
34
|
+
// over the real hit-target sibling, so advertising one produces
|
|
35
|
+
// clicks that report success but land elsewhere. Per-element computed
|
|
36
|
+
// check, NOT a subtree prune: a descendant can re-enable itself with
|
|
37
|
+
// pointer-events: auto and IS a valid target. Only the interactive
|
|
38
|
+
// collections use this gate — headings/text keep plain isVisible.
|
|
39
|
+
if (!isVisible(el)) return false;
|
|
40
|
+
try {
|
|
41
|
+
const view = (el.ownerDocument && el.ownerDocument.defaultView) || window;
|
|
42
|
+
if (view.getComputedStyle(el).pointerEvents === 'none') return false;
|
|
43
|
+
} catch (_) {}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
30
46
|
function shortText(el) {
|
|
31
47
|
const t = (el.innerText || el.textContent || '').trim();
|
|
32
48
|
return t.length > 120 ? t.slice(0, 120) + '...' : t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-helpers.js","sourceRoot":"","sources":["../../src/inpage/dom-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG
|
|
1
|
+
{"version":3,"file":"dom-helpers.js","sourceRoot":"","sources":["../../src/inpage/dom-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuI7B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "browser-link",
|
|
4
|
-
"version": "0.23.
|
|
4
|
+
"version": "0.23.8",
|
|
5
5
|
"description": "Bridge between Chrome and an MCP client (Claude Code, OpenCode, GitHub Copilot CLI, …). Per-tab manual activation.",
|
|
6
6
|
"permissions": [
|
|
7
7
|
"debugger",
|
package/dist/map/tools.js
CHANGED
|
@@ -64,7 +64,7 @@ export const MAP_TOOL_DEFINITIONS = [
|
|
|
64
64
|
notes: { type: 'string' },
|
|
65
65
|
flows: {
|
|
66
66
|
type: 'array',
|
|
67
|
-
description: 'Optional named, replayable flow recipes for this app. Each `steps` array follows the EXACT browser.flow step grammar (find/click/type/press/wait_for) and is rejected with the same validation browser.flow applies. Use placeholder text for free-text values instead of real domain data (e.g. `type text "<QUERY>"`) — agents substitute the placeholder before calling browser.flow. Upserts on (app, name).',
|
|
67
|
+
description: 'Optional named, replayable flow recipes for this app. Each `steps` array follows the EXACT browser.flow step grammar (find/click/type/press/wait_for/drag) and is rejected with the same validation browser.flow applies. Use placeholder text for free-text values instead of real domain data (e.g. `type text "<QUERY>"`) — agents substitute the placeholder before calling browser.flow. Upserts on (app, name).',
|
|
68
68
|
items: {
|
|
69
69
|
type: 'object',
|
|
70
70
|
properties: {
|
|
@@ -75,7 +75,7 @@ export const MAP_TOOL_DEFINITIONS = [
|
|
|
75
75
|
description: { type: 'string' },
|
|
76
76
|
steps: {
|
|
77
77
|
type: 'array',
|
|
78
|
-
description: 'Ordered find/click/type/press/wait_for steps — browser.flow grammar.',
|
|
78
|
+
description: 'Ordered find/click/type/press/wait_for/drag steps — browser.flow grammar.',
|
|
79
79
|
items: { type: 'object' },
|
|
80
80
|
},
|
|
81
81
|
},
|
package/dist/map/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/map/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,GAGT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,MAAM,CAAC,MAAM,oBAAoB,GAAqB;IACpD;QACE,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EACT,+nBAA+nB;QACjoB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE;gBACzE,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,gJAAgJ;iBACnJ;gBACD,GAAG,EAAE;oBACH,IAA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|
120
120
|
category: 'action',
|
|
121
|
-
summary: 'Run a find/click/type/press/wait_for step sequence in one round trip',
|
|
121
|
+
summary: 'Run a find/click/type/press/wait_for/drag step sequence in one round trip',
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
name: 'browser.dialog_respond',
|
package/dist/permissions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAeH,MAAM,CAAC,MAAM,cAAc,GAAwB;IACjD,6BAA6B;IAC7B,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAAE;IACjG;QACE,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,kDAAkD;KAC5D;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,wDAAwD;KAClE;IACD;QACE,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,4BAA4B;KACtC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,sFAAsF;KAChG;IACD;QACE,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,wEAAwE;KAClF;IACD;QACE,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,+EAA+E;KACzF;IACD;QACE,IAAI,EAAE,2BAA2B;QACjC,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAA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,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED;;kEAEkE;AAClE,MAAM,UAAU,qBAAqB,CAAC,KAAoC;IACxE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAY;IACpC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IACrD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -43,7 +43,7 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
43
43
|
gotchas: [
|
|
44
44
|
'Returns only tabs the user has connected manually, plus cdp-direct tabs when that optional mode is enabled and granted (off by default — see cdp-direct docs). If the list is empty, ask the user to open the extension popup.',
|
|
45
45
|
'When an entry carries a map field, call browser.map.recall BEFORE snapshotting that tab — the persistent map already has selectors, gotchas, or flow recipes for it, and re-discovering them via a fresh snapshot/find wastes a round trip.',
|
|
46
|
-
"A tab_id starting with cdp: (transport: 'cdp') works with every tool except browser.drag/console/network/network_body/canvas_screenshot/dialog_respond/set_permission/wait_for_tab in v1 — those return a clear error naming the extension transport as the fallback.",
|
|
46
|
+
"A tab_id starting with cdp: (transport: 'cdp') works with every tool except browser.drag/console/network/network_body/canvas_screenshot/dialog_respond/set_permission/wait_for_tab in v1 — those (and a browser.flow drag step) return a clear error naming the extension transport as the fallback.",
|
|
47
47
|
],
|
|
48
48
|
},
|
|
49
49
|
},
|
|
@@ -151,7 +151,7 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
name: 'browser.snapshot',
|
|
154
|
-
description: 'Snapshot of the tab: title, url, visible text (truncated) and a list of interactive elements (buttons, links, inputs, selects, textareas) with a CSS selector and labels. Use this to understand page state before clicking or typing. The scan pierces OPEN Shadow DOM roots and same-origin iframes (nested arbitrarily) — a web component internal or an in-page iframe shows up without extra steps. An entry for an element living inside an iframe carries an extra `frame` field (the CSS selector of the innermost hosting iframe) so you know it is framed; entries in the top document or in Shadow DOM omit it. An entry whose selector could not be made unique across all roots (structurally-identical component twins) carries `ambiguous: true` — that selector resolves first-match-wins, so use it immediately and do NOT store it in the persistent map. Optional filters keep the response small: `within_selector` restricts the scan to a subtree (also deep-search-aware — it can target a subtree inside a shadow root or iframe); `only_interactive` skips headings and the text dump; `exclude` drops landmarks like nav/footer; `max_interactive` overrides the default cap of 120. The per-entry serializer omits empty-string fields, so the same call returns a leaner payload than before — no behavior change for clients that read by key.',
|
|
154
|
+
description: 'Snapshot of the tab: title, url, visible text (truncated) and a list of interactive elements (buttons, links, inputs, selects, textareas) with a CSS selector and labels. Use this to understand page state before clicking or typing. Elements whose computed `pointer-events` is `none` (invisible accessibility layers that can never receive a real click — e.g. Articulate Storyline) are excluded from the interactive list, though their text still contributes to headings/text; a descendant that re-enables itself with `pointer-events:auto` is still listed. The scan pierces OPEN Shadow DOM roots and same-origin iframes (nested arbitrarily) — a web component internal or an in-page iframe shows up without extra steps. An entry for an element living inside an iframe carries an extra `frame` field (the CSS selector of the innermost hosting iframe) so you know it is framed; entries in the top document or in Shadow DOM omit it. An entry whose selector could not be made unique across all roots (structurally-identical component twins) carries `ambiguous: true` — that selector resolves first-match-wins, so use it immediately and do NOT store it in the persistent map. Optional filters keep the response small: `within_selector` restricts the scan to a subtree (also deep-search-aware — it can target a subtree inside a shadow root or iframe); `only_interactive` skips headings and the text dump; `exclude` drops landmarks like nav/footer; `max_interactive` overrides the default cap of 120. The per-entry serializer omits empty-string fields, so the same call returns a leaner payload than before — no behavior change for clients that read by key.',
|
|
155
155
|
inputSchema: {
|
|
156
156
|
type: 'object',
|
|
157
157
|
properties: {
|
|
@@ -197,7 +197,7 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
199
|
name: 'browser.find',
|
|
200
|
-
description: 'Locate ONE interactive element by its visible text and return a stable selector plus viewport coordinates. The match is case-insensitive substring by default (set `exact:true` for full-string equality). Pass `role` to narrow to a specific ARIA role (`button`, `link`, `textbox`, `checkbox`, `tab`, `menuitem`) — without it the scan covers buttons, links, inputs, role-bearing elements, contenteditable nodes, and `[onclick]` divs (the "peruvian markup" case). The scan pierces OPEN Shadow DOM roots and same-origin iframes, same as browser.snapshot. Returns `{ matched: true, selector, coords:{x,y}, tag, text, frame?, ambiguous? }` on a unique hit, `{ matched: false, reason: "not-found", error?, near_misses? }` when nothing matches, or `{ matched: false, reason: "multiple-matches", candidates: [{selector, text, tag}] }` (up to 5) when several elements match — pick one and try again with `exact:true` or a longer text. On `not-found`, `near_misses` carries up to 3 VISIBLE candidates (`{text, selector, role?}`) ranked by substring containment then token overlap — omitted entirely when nothing plausible exists. When `role` excluded matches that the text DID find elsewhere, `error` names it explicitly (e.g. `text matched 2 elements but none with role "button" — closest: <div onclick> "GIF picker"`). `frame`, when present, is the CSS selector of the innermost iframe hosting the match. `ambiguous: true`, when present, means the selector could not be made unique across all roots (structurally-identical twins) and resolves first-match-wins — use it immediately, never cache it. `coords` are already mapped to TOP-LEVEL viewport coordinates even when the match lives inside an iframe. The returned `selector` uses the same heuristic as `browser.snapshot` (id → data-testid → aria-label → name → positional fallback, each verified unique across the full deep search scope), so a subsequent `browser.click` / `browser.type` works without re-querying.',
|
|
200
|
+
description: 'Locate ONE interactive element by its visible text and return a stable selector plus viewport coordinates. The match is case-insensitive substring by default (set `exact:true` for full-string equality). Pass `role` to narrow to a specific ARIA role (`button`, `link`, `textbox`, `checkbox`, `tab`, `menuitem`) — without it the scan covers buttons, links, inputs, role-bearing elements, contenteditable nodes, and `[onclick]` divs (the "peruvian markup" case). Elements whose computed `pointer-events` is `none` (invisible accessibility layers that can never receive a real click) are never returned as matches, though they can still surface as `near_misses` hints. The scan pierces OPEN Shadow DOM roots and same-origin iframes, same as browser.snapshot. Returns `{ matched: true, selector, coords:{x,y}, tag, text, frame?, ambiguous? }` on a unique hit, `{ matched: false, reason: "not-found", error?, near_misses? }` when nothing matches, or `{ matched: false, reason: "multiple-matches", candidates: [{selector, text, tag}] }` (up to 5) when several elements match — pick one and try again with `exact:true` or a longer text. On `not-found`, `near_misses` carries up to 3 VISIBLE candidates (`{text, selector, role?}`) ranked by substring containment then token overlap — omitted entirely when nothing plausible exists. When `role` excluded matches that the text DID find elsewhere, `error` names it explicitly (e.g. `text matched 2 elements but none with role "button" — closest: <div onclick> "GIF picker"`). `frame`, when present, is the CSS selector of the innermost iframe hosting the match. `ambiguous: true`, when present, means the selector could not be made unique across all roots (structurally-identical twins) and resolves first-match-wins — use it immediately, never cache it. `coords` are already mapped to TOP-LEVEL viewport coordinates even when the match lives inside an iframe. The returned `selector` uses the same heuristic as `browser.snapshot` (id → data-testid → aria-label → name → positional fallback, each verified unique across the full deep search scope), so a subsequent `browser.click` / `browser.type` works without re-querying.',
|
|
201
201
|
inputSchema: {
|
|
202
202
|
type: 'object',
|
|
203
203
|
properties: {
|
|
@@ -551,7 +551,7 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
551
551
|
},
|
|
552
552
|
{
|
|
553
553
|
name: 'browser.click',
|
|
554
|
-
description: 'Click an element by CSS selector in the connected tab. The selector usually comes from browser.snapshot or browser.find. The lookup pierces open Shadow DOM roots and same-origin iframes (nested arbitrarily), so a selector for a web-component internal or an in-page iframe works without extra steps. Before dispatching the click, the element is hit-tested at its own click point (starting from its own shadow root / iframe document) — if a different element covers that point, the call returns ok:false with a description of the blocker instead of clicking the wrong thing blindly. Pass `force:true` to skip that guard. Optionally waits for the page to settle after the click — see `settle_ms`.',
|
|
554
|
+
description: 'Click an element by CSS selector in the connected tab. The selector usually comes from browser.snapshot or browser.find. The lookup pierces open Shadow DOM roots and same-origin iframes (nested arbitrarily), so a selector for a web-component internal or an in-page iframe works without extra steps. Before dispatching the click, the element is hit-tested at its own click point (starting from its own shadow root / iframe document) — if a different element covers that point, the call returns ok:false with a description of the blocker instead of clicking the wrong thing blindly. Pass `force:true` to skip that guard. A target whose computed `pointer-events` is `none` (an invisible accessibility layer over the real control, e.g. Articulate Storyline) is NOT treated as covered: the click proceeds at the same point — that is what a real user click does — and the result carries `hit_element` naming the element that actually receives it. `hit_element` (same compact descriptor format as occlusion blockers) is present on ANY click whose dispatched event lands on a different element than the resolved selector — retargeted pointer-events case, an ancestor wrapper, or a `force:true` click landing on whatever covers the point — and omitted when the click hits the resolved element itself. Optionally waits for the page to settle after the click — see `settle_ms`.',
|
|
555
555
|
inputSchema: {
|
|
556
556
|
type: 'object',
|
|
557
557
|
properties: {
|
|
@@ -576,6 +576,7 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
576
576
|
'Never click a selector you have not just verified via browser.snapshot or browser.map.recall — speculating wastes a turn.',
|
|
577
577
|
'Auto-claims the tab on first use in multi-agent mode.',
|
|
578
578
|
'ok:false with an "Element covered by …" error means something else is on top of the target at click time (a modal backdrop, a loading overlay, a dropdown). Click or dismiss the covering element first, or re-snapshot — do not blindly retry with force:true.',
|
|
579
|
+
'A `hit_element` in an ok:true result is the truth about where the click landed. For a pointer-events:none target this is expected (the page routes clicks to that element by design); for a force:true click it may reveal the click went to an overlay, not your target — check it before assuming the action worked.',
|
|
579
580
|
'CLOSED shadow roots (attachShadow({mode:"closed"})) are unreachable — there is no CDP-level workaround. Cross-origin iframes are also unreachable (same-origin policy).',
|
|
580
581
|
'The result carries a compact `settle` object (`{ settled, duration_ms, mutation_count, url_changed?, focus_moved?, reason? }`) unless `settle_ms:0`. `settled:false` means the page never went quiet within `settle_timeout_ms` — not necessarily an error, some pages never stop mutating (tickers, spinners). When the settle wait itself could not run to completion, `settled:false` comes with `reason`: "context-destroyed" (the action navigated the page, destroying the observer\'s execution context — the action still succeeded, and this is itself a strong navigation signal) or "settle-error" (any other settle-side failure). With settle on, a separate browser.wait_for right after a click is usually unnecessary.',
|
|
581
582
|
'The error message distinguishes a malformed selector ("Invalid selector …") from a well-formed selector that matches nothing ("Element not found …") — a syntax error means fix the selector string itself, not retry against a fresher snapshot.',
|
|
@@ -703,13 +704,14 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
703
704
|
'Default duration is 1500ms so a human watching can follow the cursor. Drop it lower only when you are sure no library has a movement-based activation constraint.',
|
|
704
705
|
'drag_mode in the response tells you whether HTML5 native drag (dragstart/drop) or pointer-only events fired — use it to diagnose silently-failing drops.',
|
|
705
706
|
'A selector endpoint reaches into OPEN Shadow DOM roots and same-origin iframes, same limits as snapshot/find/click/type: CLOSED shadow roots and cross-origin iframes stay unreachable.',
|
|
707
|
+
'SEVERAL drags in a row (card-matching exercises, reordering many items)? Batch them as `drag` steps in ONE browser.flow call — same params per step, one round trip instead of one browser.drag call per drag.',
|
|
706
708
|
],
|
|
707
709
|
example: 'browser.drag({ tab_id: "tab_1", from_selector: "[data-testid=card-1]", to_selector: "[data-testid=column-done]" })',
|
|
708
710
|
},
|
|
709
711
|
},
|
|
710
712
|
{
|
|
711
713
|
name: 'browser.flow',
|
|
712
|
-
description: 'Run a declarative sequence of steps (find/click/type/press/wait_for) in ONE round trip instead of one MCP call per step. Steps execute strictly in order and STOP at the first failure (fail-fast) — there is no branching. A `find` step\'s resolved selector becomes the IMPLICIT TARGET for the very next click/type/press step that omits its own `selector` (an explicit `selector` on that step always overrides it and leaves the implicit target untouched for a later step). `type` and `press` steps that end up with no selector at all — no explicit one, no implicit one — act on whatever currently has focus, same as standalone browser.press; only `click` requires a resolved target and fails the flow if none is available. `click`/`type`/`press` default `settle_ms` to 150 exactly like the standalone tools, unless a step overrides it. Example (GIF picker): `{ find: { text: "GIF", role: "button" } }, { click: {} }, { wait_for: { selector: "[data-testid=gif-search]", condition: "visible" } }, { type: { selector: "[data-testid=gif-search]", text: "shrek" } }, { press: { key: "Enter" } }` — 5 steps, 1 round trip. On success returns `{ ok: true, steps_completed, results }` where each entry is `{selector}` for a find step
|
|
714
|
+
description: 'Run a declarative sequence of steps (find/click/type/press/wait_for/drag) in ONE round trip instead of one MCP call per step. Steps execute strictly in order and STOP at the first failure (fail-fast) — there is no branching. A `find` step\'s resolved selector becomes the IMPLICIT TARGET for the very next click/type/press step that omits its own `selector` (an explicit `selector` on that step always overrides it and leaves the implicit target untouched for a later step). `type` and `press` steps that end up with no selector at all — no explicit one, no implicit one — act on whatever currently has focus, same as standalone browser.press; only `click` requires a resolved target and fails the flow if none is available. A `drag` step runs a full drag-and-drop gesture with the SAME params as standalone browser.drag (each endpoint a CSS selector or a viewport x/y coordinate pair, plus duration_ms/hold options) — its endpoints are ALWAYS explicit: it neither consumes nor sets the implicit target, which survives a drag step untouched for a later click/type/press. Drag steps work on extension tabs only: on a cdp: tab_id the flow fails fast at the drag step with the same "not supported over cdp-direct" error standalone browser.drag returns there. `click`/`type`/`press` default `settle_ms` to 150 exactly like the standalone tools, unless a step overrides it. Example (GIF picker): `{ find: { text: "GIF", role: "button" } }, { click: {} }, { wait_for: { selector: "[data-testid=gif-search]", condition: "visible" } }, { type: { selector: "[data-testid=gif-search]", text: "shrek" } }, { press: { key: "Enter" } }` — 5 steps, 1 round trip. On success returns `{ ok: true, steps_completed, results }` where each entry is `{selector}` for a find step, `{ok, settle?}` for an action/wait_for step, or `{ok, drag_mode}` for a drag step (`drag_mode: "html5"|"pointer"` — the same silently-failing-drop diagnostic standalone browser.drag returns) — a click step\'s entry additionally carries `hit_element` exactly like standalone browser.click: present only when the dispatched click landed on a different element than the resolved target, omitted when the click hit the target itself. On failure returns `{ ok: false, failed_step, step_kind, error, steps_completed, recovery_snapshot }` — `error` is the same message the standalone tool would have returned for that failure, and `recovery_snapshot` is a focused `browser.snapshot({only_interactive:true, max_interactive:40})` of the page as it stands, so you see where the flow stopped without a follow-up call. `evaluate` and `navigate` are intentionally NOT flow steps in v1 — arbitrary JS inside a flow raises permission-model questions this tool does not solve yet, and a navigation mid-flow can tear down the very document later steps expect to act on; use standalone browser.navigate before a flow, or browser.evaluate after one.',
|
|
713
715
|
inputSchema: {
|
|
714
716
|
type: 'object',
|
|
715
717
|
properties: {
|
|
@@ -718,7 +720,7 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
718
720
|
type: 'array',
|
|
719
721
|
minItems: 1,
|
|
720
722
|
maxItems: 20,
|
|
721
|
-
description: 'Ordered list of steps, each exactly one of find | click | type | press | wait_for. Max 20 steps per flow.',
|
|
723
|
+
description: 'Ordered list of steps, each exactly one of find | click | type | press | wait_for | drag. Max 20 steps per flow.',
|
|
722
724
|
items: {
|
|
723
725
|
oneOf: [
|
|
724
726
|
{
|
|
@@ -835,6 +837,29 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
835
837
|
required: ['wait_for'],
|
|
836
838
|
additionalProperties: false,
|
|
837
839
|
},
|
|
840
|
+
{
|
|
841
|
+
type: 'object',
|
|
842
|
+
properties: {
|
|
843
|
+
drag: {
|
|
844
|
+
type: 'object',
|
|
845
|
+
description: 'Same endpoint contract as standalone browser.drag: provide from_selector OR both from_x/from_y, and to_selector OR both to_x/to_y. Endpoints are always explicit — a drag step never uses the implicit target from a preceding find. Extension tabs only: rejected on cdp: tabs with the same error as standalone browser.drag.',
|
|
846
|
+
properties: {
|
|
847
|
+
from_selector: { type: 'string' },
|
|
848
|
+
from_x: { type: 'number' },
|
|
849
|
+
from_y: { type: 'number' },
|
|
850
|
+
to_selector: { type: 'string' },
|
|
851
|
+
to_x: { type: 'number' },
|
|
852
|
+
to_y: { type: 'number' },
|
|
853
|
+
duration_ms: { type: 'number' },
|
|
854
|
+
hold_before_move_ms: { type: 'number' },
|
|
855
|
+
hold_before_release_ms: { type: 'number' },
|
|
856
|
+
},
|
|
857
|
+
additionalProperties: false,
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
required: ['drag'],
|
|
861
|
+
additionalProperties: false,
|
|
862
|
+
},
|
|
838
863
|
],
|
|
839
864
|
},
|
|
840
865
|
},
|
|
@@ -843,11 +868,12 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
843
868
|
additionalProperties: false,
|
|
844
869
|
},
|
|
845
870
|
doc: {
|
|
846
|
-
purpose: 'Run a declarative find/click/type/press/wait_for sequence in one round trip — the DEFAULT way to drive any multi-step UI interaction.',
|
|
871
|
+
purpose: 'Run a declarative find/click/type/press/wait_for/drag sequence in one round trip — the DEFAULT way to drive any multi-step UI interaction.',
|
|
847
872
|
when_to_use: [
|
|
848
873
|
'ANY interaction that needs more than one action tool call — find a target then act on it, act then wait for a result, fill and submit a form. Each MCP round trip you avoid is a full LLM inference you do not pay for.',
|
|
849
874
|
'The find → implicit-target → click/type/press pattern: `{find}` followed by an action step with no `selector` resolves against what find just found — no need to re-run browser.find and copy its selector into the next call by hand.',
|
|
850
875
|
'A flow that might fail partway — the failure response already carries a focused `recovery_snapshot`, so you do not need a follow-up browser.snapshot to see what state the page is in.',
|
|
876
|
+
'Repeated drag-and-drop (card-matching exercises, sortable lists, moving many cards): N drag steps in ONE flow cost one round trip instead of N standalone browser.drag calls.',
|
|
851
877
|
],
|
|
852
878
|
gotchas: [
|
|
853
879
|
'Strictly sequential, fail-fast, no branching. If step 3 needs to behave differently depending on what step 2 returned, run the steps individually instead of as one flow.',
|
|
@@ -855,7 +881,9 @@ export const BROWSER_TOOL_DEFINITIONS = [
|
|
|
855
881
|
'Only `click` requires a resolved target; `type` and `press` fall back to whatever currently has focus when neither an explicit nor an implicit selector is available, exactly like standalone browser.press.',
|
|
856
882
|
'A `find` step that resolves with `ambiguous:true` (see browser.find) fails the flow — a selector that could match the wrong structurally-identical twin is never used silently inside a flow.',
|
|
857
883
|
'An action step that triggers a NAVIGATION should be followed by a `wait_for` step — steps run back-to-back, so the next step can otherwise race the loading document and fail with a misleading "Element not found". When that race happens, the flow error carries a hint if the navigating step\'s settle reported `context-destroyed` (the navigation signal).',
|
|
858
|
-
|
|
884
|
+
"A `drag` step's endpoints are ALWAYS explicit (selector or viewport coords) — drag neither consumes nor sets the find implicit target, and a pending implicit target survives a drag step for a later click/type/press. Both endpoints must be visible in the viewport at once, same as standalone browser.drag.",
|
|
885
|
+
'Drag steps are extension-transport only: a flow containing a drag step run on a cdp: tab fails fast at that step with the same "not supported over cdp-direct" error standalone browser.drag returns — the earlier steps HAVE already executed by then.',
|
|
886
|
+
'Worst-case time budget, hard ceiling 60 seconds: each wait_for step contributes its (clamped, max 30s) timeout_ms, each action step its settle ceiling (~2.5s; ~0.5s with settle_ms:0), each drag step its duration_ms (default 1.5s, clamped at 60s) plus any holds (clamped at 10s each), plus fixed overhead. A flow whose worst case exceeds 60s is REJECTED up front with the computed budget — reduce wait_for timeout_ms values or split the flow. A full 20-step flow of action steps with default settle fits comfortably.',
|
|
859
887
|
'evaluate and navigate steps are NOT supported in v1 — see the tool description for why. Navigate before the flow; evaluate after it.',
|
|
860
888
|
'Max 20 steps per flow. For longer sequences, split into multiple browser.flow calls.',
|
|
861
889
|
],
|