@matterfact/embed 0.12.0 → 0.13.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.
- package/README.md +41 -0
- package/dist/{chunk-M5TS546Z.js → chunk-C7DXO37G.js} +2 -2
- package/dist/{chunk-ZXMJWCQV.js → chunk-JLJG3MDX.js} +57 -35
- package/dist/chunk-JLJG3MDX.js.map +1 -0
- package/dist/chunk-QZCUQZJK.js +3 -0
- package/dist/chunk-QZCUQZJK.js.map +7 -0
- package/dist/{chunk-C4XGE6BO.js → chunk-S6OT47DL.js} +56 -34
- package/dist/chunk-S6OT47DL.js.map +1 -0
- package/dist/{chunk-WAUSVV7Y.js → chunk-UA4Y2O64.js} +2 -2
- package/dist/{context-4LP3EDXL.js → context-DAXACLSP.js} +3 -3
- package/dist/{context-4LP3EDXL.js.map → context-DAXACLSP.js.map} +1 -1
- package/dist/{context-ZSPDZWIB.js → context-IJK345PN.js} +2 -2
- package/dist/embed.js +1 -1
- package/dist/embed.js.map +3 -3
- package/dist/index.cjs +82 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -2
- package/dist/index.d.ts +73 -2
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +82 -32
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +28 -1
- package/dist/react.d.ts +28 -1
- package/dist/react.js +29 -1
- package/dist/react.js.map +1 -1
- package/dist/{snapshot-OR5SVEUD.js → snapshot-EVBNVVCT.js} +2 -2
- package/dist/{snapshot-X6FPP3HF.js → snapshot-P5SVKSPB.js} +3 -3
- package/dist/{snapshot-X6FPP3HF.js.map → snapshot-P5SVKSPB.js.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-C4XGE6BO.js.map +0 -1
- package/dist/chunk-SR4ZNUAN.js +0 -3
- package/dist/chunk-SR4ZNUAN.js.map +0 -7
- package/dist/chunk-ZXMJWCQV.js.map +0 -1
- /package/dist/{chunk-M5TS546Z.js.map → chunk-C7DXO37G.js.map} +0 -0
- /package/dist/{chunk-WAUSVV7Y.js.map → chunk-UA4Y2O64.js.map} +0 -0
- /package/dist/{context-ZSPDZWIB.js.map → context-IJK345PN.js.map} +0 -0
- /package/dist/{snapshot-OR5SVEUD.js.map → snapshot-EVBNVVCT.js.map} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
isPrivate,
|
|
4
4
|
redact
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-S6OT47DL.js";
|
|
6
6
|
|
|
7
7
|
// src/dom/snapshot.ts
|
|
8
8
|
import { isDisabled as isDisabled2, isInaccessible } from "dom-accessibility-api";
|
|
@@ -459,4 +459,4 @@ export {
|
|
|
459
459
|
snapshot,
|
|
460
460
|
snapshotRegion
|
|
461
461
|
};
|
|
462
|
-
//# sourceMappingURL=snapshot-
|
|
462
|
+
//# sourceMappingURL=snapshot-EVBNVVCT.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { redact, isPrivate } from './chunk-
|
|
1
|
+
import { redact, isPrivate } from './chunk-JLJG3MDX.js';
|
|
2
2
|
import { isInaccessible, getRole, computeAccessibleName, isDisabled } from 'dom-accessibility-api';
|
|
3
3
|
|
|
4
4
|
function createStyleCache() {
|
|
@@ -443,5 +443,5 @@ function snapshotRegion(root) {
|
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
export { clearRefs, resolveRef, snapshot, snapshotRegion };
|
|
446
|
-
//# sourceMappingURL=snapshot-
|
|
447
|
-
//# sourceMappingURL=snapshot-
|
|
446
|
+
//# sourceMappingURL=snapshot-P5SVKSPB.js.map
|
|
447
|
+
//# sourceMappingURL=snapshot-P5SVKSPB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dom/a11y.ts","../src/dom/refs.ts","../src/dom/snapshot.ts"],"names":["isDisabled"],"mappings":";;;AAkCO,SAAS,gBAAA,GAA4B;AAC1C,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AAA,MAAM,OAAO,QAAA,CAAS,IAAA;AACtB,EAAA,IAAI,CAAC,IAAA,EAAM,OAAO,EAAE,IAAA,EAAM,IAAI,SAAA,EAAW,KAAA,EAAO,WAAA,EAAa,EAAC,EAAE;AAEhE,EAAA,aAAA,EAAc;AAEd,EAAA,MAAM,cAAwB,EAAC;AAC/B,EAAA,MAAM,EAAA,GAAK,OAAO,WAAA,IAAe,CAAA;AACjC,EAAA,MAAM,EAAA,GAAK,OAAO,UAAA,IAAc,CAAA;AAChC,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,IAAA,EAAM,CAAC,KAAK,EAAA,KAAO;AACrC,IAAA,MAAM,CAAA,GAAI,GAAG,qBAAA,EAAsB;AAGnC,IAAA,IAAI,CAAA,CAAE,MAAA,GAAS,CAAA,IAAK,CAAA,CAAE,GAAA,GAAM,EAAA,IAAM,CAAA,CAAE,KAAA,GAAQ,CAAA,IAAK,CAAA,CAAE,IAAA,GAAO,EAAA,EAAI;AAC5D,MAAA,WAAA,CAAY,KAAK,GAAG,CAAA;AAAA,IACtB;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,GAAG,MAAA,EAAQ,WAAA,EAAY;AAClC;AAWO,SAAS,eAAe,IAAA,EAG7B;AACA,EAAA,IAAI,CAAC,KAAK,WAAA,EAAa,OAAO,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,KAAA,EAAM;AAC3D,EAAA,OAAO,KAAK,IAAI,CAAA;AAClB","file":"snapshot-X6FPP3HF.js","sourcesContent":["import {\n computeAccessibleName,\n getRole,\n isDisabled,\n} from 'dom-accessibility-api';\n\n/**\n * Role, name, visibility, interactability, state.\n *\n * WHAT WE ADOPTED: role and accessible name come from `dom-accessibility-api`\n * (MIT, zero deps) — the engine behind testing-library's `getByRole`. Accessible\n * name is a genuinely hard spec (accname walks aria-labelledby graphs, ::before\n * content, <label> associations, alt/title fallbacks, and recursive\n * name-from-content) and a hand-rolled version is wrong in ways you only discover\n * on a customer's page.\n *\n * WHAT WE BUILT: everything below that. Visibility and pointer-events are ~20 lines\n * from first principles (see `isVisible`/`receivesPointerEvents`) and the state\n * reads are direct DOM/ARIA reads, so we vendored nothing and took on no\n * Apache-2.0 attribution obligation.\n */\n\n/** A memoised `getComputedStyle`, shaped to be passed straight to accname. */\nexport type StyleOf = typeof window.getComputedStyle;\n\n/**\n * One computed style per element per snapshot.\n *\n * Not a micro-optimisation: `computeAccessibleName` calls back into\n * getComputedStyle for every descendant it walks while building a name from\n * content, so on a page of nested divs the uncached cost is quadratic-ish. The\n * cache is per-snapshot (a fresh WeakMap each walk), so it can never go stale\n * across snapshots.\n */\nexport function createStyleCache(): StyleOf {\n const cache = new WeakMap<Element, CSSStyleDeclaration>();\n return ((el: Element, pseudo?: string | null): CSSStyleDeclaration => {\n // Pseudo-element lookups are rare and must not poison the element cache.\n if (pseudo) return window.getComputedStyle(el, pseudo);\n let style = cache.get(el);\n if (!style) {\n style = window.getComputedStyle(el);\n cache.set(el, style);\n }\n return style;\n }) as StyleOf;\n}\n\n/**\n * Does this environment do layout at all?\n *\n * In a browser the root element always has a box. In jsdom — which has no layout\n * engine — *everything* reports zero client rects, so a box-based visibility check\n * would hide the entire page and our tests would assert on an empty snapshot. So we\n * feature-detect layout once per walk and fall back to style-only visibility when\n * there is none. This is a test-environment concession, stated out loud rather than\n * hidden behind a mock.\n */\nexport function hasLayout(): boolean {\n return document.documentElement.getClientRects().length > 0;\n}\n\n/**\n * Visible enough to be worth telling the agent about.\n *\n * `display` and `visibility` are read from the computed style, which already\n * accounts for inheritance — and because the walk is top-down and prunes whole\n * subtrees, we never pay for an ancestor walk. `display: contents` is the one\n * subtlety: such an element generates no box of its own but its children do, so it\n * must not be treated as invisible or we would drop a real subtree.\n */\nexport function isVisible(\n el: Element,\n style: CSSStyleDeclaration,\n layout: boolean,\n): boolean {\n const display = style.display;\n if (display === 'none') return false;\n\n const visibility = style.visibility;\n if (visibility === 'hidden' || visibility === 'collapse') return false;\n\n // `opacity: 0` is a standard \"hide from sight, keep for a11y\" technique. It still\n // reports a box, so the area check below misses it. We treat fully-transparent as\n // hidden; a partially-transparent element is genuinely on screen.\n if (Number(style.opacity) === 0) return false;\n\n // A `display: contents` element generates no box of its own but its children do,\n // so it must not be judged by its own (nonexistent) geometry — we let it through\n // and test each child on its own merits.\n if (layout && display !== 'contents') {\n // Area, not merely \"has a box\": `width:0;height:0;overflow:hidden` is one of the\n // commonest ways to hide a thing, and such an element still reports a client\n // rect. This is the check Playwright's own isVisible() makes.\n const box = el.getBoundingClientRect();\n if (box.width <= 0 || box.height <= 0) return false;\n\n // The sr-only / visually-hidden family: `clip: rect(0 0 0 0)` and its modern\n // `clip-path: inset(50%)` shrink the element to nothing while keeping a 1px box,\n // and `position:absolute; left:-9999px` parks it far off any real page. All three\n // are \"screen-reader only\" idioms — present for a11y, not for sight — so an agent\n // reading the page should skip them too. (getClientRects().length === 0 catches\n // the clipped ones; the far-offscreen check catches the parked ones.)\n if (el.getClientRects().length === 0) return false;\n if (box.right < -2000 || box.bottom < -2000) return false;\n }\n\n return true;\n}\n\n/**\n * Can a pointer actually reach it?\n *\n * `pointer-events` is an INHERITED property, so the computed value on the element\n * already encodes every ancestor's `pointer-events: none` — and correctly honours a\n * descendant that opts back in with `pointer-events: auto`. That is the whole check:\n * no ancestor walk, no hit-test. We deliberately do NOT test for occlusion (is\n * something painted on top of it) the way Playwright's actionability check does —\n * we are describing the page, not clicking it, and an element under a sticky header\n * is still worth telling the agent about.\n */\nexport function receivesPointerEvents(style: CSSStyleDeclaration): boolean {\n return style.pointerEvents !== 'none';\n}\n\n/** Roles that are inherently operable. */\nconst INTERACTIVE_ROLES = new Set([\n 'button',\n 'checkbox',\n 'combobox',\n 'link',\n 'listbox',\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio',\n 'option',\n 'radio',\n 'searchbox',\n 'slider',\n 'spinbutton',\n 'switch',\n 'tab',\n 'textbox',\n 'treeitem',\n]);\n\n/** Tags that are operable regardless of what role they compute to. */\nconst INTERACTIVE_TAGS = new Set([\n 'BUTTON',\n 'INPUT',\n 'SELECT',\n 'TEXTAREA',\n 'SUMMARY',\n]);\n\n/** `contenteditable` — present and not explicitly \"false\" (covers \"\", \"true\", \"plaintext-only\"). */\nexport function isEditable(el: Element): boolean {\n const v = el.getAttribute('contenteditable');\n return v !== null && v !== 'false';\n}\n\n/**\n * Is this element something the user can operate?\n *\n * THIS IS THE INTERESTING FUNCTION, so here is the reasoning in full.\n *\n * The obvious way to answer it — ask the DOM what event listeners are attached —\n * IS NOT AVAILABLE. `getEventListeners()` exists only inside DevTools (and via CDP).\n * We are ordinary page JS on a customer's website, so every `addEventListener` a\n * React, Vue or Svelte app ever registered is, to us, completely invisible. This is\n * precisely where the browser-use style of in-page DOM extraction degrades on real\n * apps: it cannot see a single handler, so it either misses the app's controls or\n * guesses wildly. We therefore never ask \"does it have a handler\"; we ask \"does it\n * PRESENT ITSELF as operable\", in four descending tiers of confidence:\n *\n * 1. TAG SEMANTICS (certain). button, input, select, textarea, summary, a[href].\n * 2. COMPUTED ROLE (certain). role=button|link|checkbox|… whether implicit or\n * author-supplied. A div with role=\"button\" is a\n * button as far as the platform, a screen reader,\n * and the user are concerned.\n * 3. FOCUSABILITY (strong). tabindex >= 0, or contenteditable. An app that\n * made a div keyboard-reachable did so on purpose.\n * 4. `cursor: pointer` (WEAK). Last resort, and the reason for the guard below.\n *\n * Tier 4 needs care, because `cursor` is INHERITED: a card with `cursor: pointer`\n * makes every span, every icon and every text node inside it report `pointer` too,\n * and a naive check would mint a ref for each of them and drown the snapshot. So we\n * only count the element that *introduced* the pointer cursor — the one whose parent\n * did not already have it. That is almost exactly the clickable card itself.\n */\nexport function isInteractive(\n el: Element,\n role: string | null,\n style: CSSStyleDeclaration,\n parentStyle: CSSStyleDeclaration | null,\n): boolean {\n const tag = el.tagName;\n\n // 1. tag semantics\n // An <a href> is interactive, but a hrefless <a> is NOT a dead end — it may be a\n // JS-nav link, an <a role=\"button\">, or a Bootstrap `.btn` anchor. So href is a\n // positive signal, not a gate: fall through to the role/tabindex/cursor tiers\n // rather than returning false and dropping every SPA link.\n if (tag === 'A' && el.hasAttribute('href')) return true;\n if (INTERACTIVE_TAGS.has(tag)) return true;\n\n // 2. computed role\n if (role !== null && INTERACTIVE_ROLES.has(role)) return true;\n\n // 3. focusability\n const tabindex = el.getAttribute('tabindex');\n if (tabindex !== null && Number(tabindex) >= 0) return true;\n if (isEditable(el)) return true;\n\n // 4. cursor: pointer, but only where it originates (see above)\n if (style.cursor === 'pointer' && parentStyle?.cursor !== 'pointer')\n return true;\n\n return false;\n}\n\n/**\n * Roles whose accessible name IS their text content (ARIA \"Name From: contents\").\n *\n * This is the exact list from the ARIA spec, and it earns its place: it is what tells\n * the walk that the \"Export CSV\" inside `<button>Export CSV</button>` has ALREADY been\n * emitted, as the button's name, and must not be repeated as a child text node.\n *\n * The tempting shortcut — \"skip any text that appears inside the parent's name\" — is\n * wrong, and wrong in a way that silently deletes content: a card labelled\n * `aria-label=\"Acme Corp order\"` containing the text \"Acme Corp\" would lose it,\n * because one is a substring of the other by coincidence. Ask the role, not the string.\n */\nexport const NAME_FROM_CONTENT = new Set([\n 'button',\n 'cell',\n 'checkbox',\n 'columnheader',\n 'gridcell',\n 'heading',\n 'link',\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio',\n 'option',\n 'radio',\n 'row',\n 'rowheader',\n 'switch',\n 'tab',\n 'tooltip',\n 'treeitem',\n]);\n\n/* ─────────────────────────────── state ────────────────────────────────── */\n\n/** Roles whose content IS the user's data. We report that a value exists, never what it is. */\nconst VALUE_ROLES = new Set(['textbox', 'searchbox', 'spinbutton']);\n\n/**\n * Roles we refuse to descend into, because their children/content ARE the value.\n *\n * A `<textarea>`'s child text node is literally what the user typed; a\n * contenteditable's subtree is the document they are writing. Refusing to walk in is\n * how \"never emit a value\" is enforced STRUCTURALLY, rather than by remembering to\n * filter at every emit site.\n *\n * `<select>` is deliberately NOT here. Its options are a bounded, author-defined\n * enumeration — the affordance the agent most needs (\"what can I set this to\"), not\n * the free-text user data the opaque rule exists to contain. The snapshot emits them\n * directly instead (capped, selected one marked): see emitSelectOptions in\n * snapshot.ts.\n */\nconst OPAQUE_TAGS = new Set(['INPUT', 'TEXTAREA']);\n\nexport function isOpaque(el: Element): boolean {\n return OPAQUE_TAGS.has(el.tagName) || isEditable(el);\n}\n\n/**\n * Has the user put something in this field?\n *\n * `.value` is read and immediately thrown away — only its LENGTH escapes. This is\n * the single most useful bit about a form (\"is the email box already filled in?\")\n * and the single most dangerous string on the page, so it is reduced to one bit at\n * the point of reading and never travels.\n */\nfunction isFilled(el: Element, role: string): boolean {\n const tag = el.tagName;\n if (tag === 'INPUT' || tag === 'TEXTAREA') {\n if (!VALUE_ROLES.has(role)) return false; // checkbox.value is \"on\" — meaningless\n return ((el as HTMLInputElement).value ?? '').length > 0;\n }\n if (isEditable(el)) return (el.textContent ?? '').trim().length > 0;\n return false;\n}\n\nfunction ariaFlag(el: Element, attr: string): 'true' | 'mixed' | null {\n const v = el.getAttribute(attr);\n if (v === 'true') return 'true';\n if (v === 'mixed') return 'mixed';\n return null;\n}\n\n/**\n * The bracketed attributes, in Playwright's order:\n * [checked] [disabled] [expanded] [level=N] [pressed] [selected]\n * plus our one addition, [filled] — see isFilled. `[ref=eN]` is appended by the\n * caller and always comes last.\n */\nexport function states(el: Element, role: string): string {\n const out: string[] = [];\n const tag = el.tagName;\n\n // checked\n if (tag === 'INPUT' && (role === 'checkbox' || role === 'radio')) {\n if ((el as HTMLInputElement).checked) out.push('[checked]');\n } else {\n const checked = ariaFlag(el, 'aria-checked');\n if (checked === 'mixed') out.push('[checked=mixed]');\n else if (checked === 'true') out.push('[checked]');\n }\n\n // disabled — dom-accessibility-api handles fieldset/optgroup inheritance and aria-disabled\n if (isDisabled(el)) out.push('[disabled]');\n\n // expanded — <summary> reflects its parent <details>, which has no ARIA attribute\n const expanded = el.getAttribute('aria-expanded');\n if (expanded === 'true' || expanded === 'false') {\n if (expanded === 'true') out.push('[expanded]');\n } else if (tag === 'SUMMARY') {\n const details = el.parentElement;\n if (\n details?.tagName === 'DETAILS' &&\n (details as HTMLDetailsElement).open\n ) {\n out.push('[expanded]');\n }\n }\n\n // level\n if (role === 'heading') {\n const aria = el.getAttribute('aria-level');\n const level = aria ? Number(aria) : Number(tag[1]);\n if (Number.isFinite(level) && level > 0) out.push(`[level=${level}]`);\n }\n\n // pressed\n const pressed = ariaFlag(el, 'aria-pressed');\n if (pressed === 'mixed') out.push('[pressed=mixed]');\n else if (pressed === 'true') out.push('[pressed]');\n\n // selected\n if (el.getAttribute('aria-selected') === 'true') out.push('[selected]');\n\n // filled (ours — a boolean, never the value)\n if (isFilled(el, role)) out.push('[filled]');\n\n return out.join(' ');\n}\n\n/* ─────────────────────────── role & name ──────────────────────────────── */\n\n/**\n * The computed role, with one correction.\n *\n * `getRole` follows HTML-AAM and returns null for a contenteditable div — but every\n * real browser exposes it to assistive tech as a textbox, and that is what it is to\n * the user and to the agent. We say textbox.\n */\nexport function roleOf(el: Element): string | null {\n if (isEditable(el)) return 'textbox';\n return getRole(el);\n}\n\n/**\n * Selector for anything whose CONTENT is the user's data — a form control, a\n * contenteditable, a valued widget, or a host-marked private region.\n */\nconst UNTRUSTED_CONTENT =\n 'input,textarea,select,[contenteditable=\"\"],[contenteditable=\"true\"],[aria-valuetext],[data-mf-private]';\n\n/**\n * Would computing this element's ACCESSIBLE NAME read the user's data?\n *\n * This is the leak the structural `isOpaque` walk cannot see. `computeAccessibleName`\n * runs its OWN descendant walk, inside dom-accessibility-api, that knows nothing about\n * our opaque set or `data-mf-private` — it will happily read `input.value`,\n * `aria-valuetext`, a contenteditable's text, or a private subtree, and fold it into\n * the name of a name-from-content ANCESTOR or any `aria-labelledby` referrer. So a\n * value our walk refuses to enter re-enters through the parent's name.\n *\n * Two vectors, both handled:\n * - name-from-content: the name is built from descendant text. If any descendant is\n * untrusted, the name is tainted.\n * - aria-labelledby: the name is pulled from a referenced element. If any referent\n * is (or contains) untrusted content, the name is tainted.\n *\n * `aria-label` and `title` are author-written static strings; a site that copies its\n * own secret into one is exposing it deliberately and we cannot defend that. The\n * automatic-computation vectors are the ones we must close.\n */\nfunction nameIsUntrusted(el: Element): boolean {\n const labelledby = el.getAttribute('aria-labelledby');\n if (labelledby) {\n for (const id of labelledby.split(/\\s+/)) {\n if (!id) continue;\n const ref = el.ownerDocument.getElementById(id);\n if (!ref) continue;\n if (\n ref.matches(UNTRUSTED_CONTENT) ||\n ref.querySelector(UNTRUSTED_CONTENT)\n ) {\n return true;\n }\n }\n return false;\n }\n // No explicit label attributes → the name, if any, is name-from-content.\n if (el.hasAttribute('aria-label')) return false;\n return el.querySelector(UNTRUSTED_CONTENT) !== null;\n}\n\nexport function nameOf(el: Element, styleOf: StyleOf): string {\n const name = computeAccessibleName(el, {\n getComputedStyle: styleOf,\n // jsdom logs a console error if you claim pseudo-element support it doesn't have.\n computedStyleSupportsPseudoElements: false,\n });\n if (!name) return '';\n\n // A tainted name would leak a value or a private string. Drop it entirely and let\n // the element stand on its role + ref. Losing a name costs the agent a little\n // context; keeping a leaked one is a breach. The trade is not close.\n if (nameIsUntrusted(el)) {\n // Preserve an explicit author label if one exists and is not itself the taint —\n // aria-labelledby taints were already caught above, so any aria-label here is safe.\n return el.getAttribute('aria-label') || '';\n }\n return name;\n}\n","import type { ElementRef } from '../protocol';\n\n/**\n * Element handles.\n *\n * The mechanism is Playwright's, deliberately (see protocol.ts): the agent never\n * learns a selector, it learns `e12`, and `e12` is turned back into an element\n * HERE, in the page, by us.\n *\n * Three properties matter and all are load-bearing:\n *\n * 1. THE MAP IS A WeakMap, NOT AN EXPANDO ON THE ELEMENT. An earlier version\n * stamped `el._mfRef`. Non-enumerable, so invisible to `Object.keys`/spreads/\n * `JSON.stringify` — but STILL reachable via `Object.getOwnPropertyNames` and\n * `Reflect.ownKeys`, and, worse, it parked the element's accessible name on the\n * customer's live DOM node indefinitely. A `WeakMap<Element, RefEntry>` mutates\n * nothing on their objects, is invisible to every enumeration and serialization\n * API without exception, cannot collide with a property the host already has,\n * and still gives us node-identity survival across GC for free.\n *\n * 2. A REF IS REGENERATED WHEN ROLE OR NAME CHANGES. Frameworks recycle DOM nodes:\n * a virtualised list scrolls, and the <button> that said \"Approve\" is the very\n * same node that now says \"Delete\". Keying the ref on (role, name) means that\n * node gets a NEW id and the old id resolves to nothing.\n *\n * 3. A REF IS SCOPED TO ONE SNAPSHOT GENERATION. (2) is necessary but not\n * sufficient: two icon-only \"Delete\" buttons in a virtualised table have the\n * SAME (role, name), so a recycled node whose role+name are unchanged would keep\n * its ref and silently retarget a different logical row. So a ref also carries\n * the generation it was minted in, and resolveRef refuses a ref from an older\n * generation — the agent must re-snapshot to get a fresh, valid handle. Loud\n * staleness beats silent retargeting.\n */\n\ninterface RefEntry {\n id: ElementRef;\n /** role + name at mint time. Changes here invalidate the ref. */\n key: string;\n /** The snapshot generation this ref belongs to. */\n gen: number;\n}\n\n/**\n * Monotonic across snapshots, never reused — like Playwright's. An id is only ever\n * handed out once in a page's lifetime, so a stale ref can never be *silently*\n * correct by colliding with a newer element; it just resolves to null.\n */\nlet counter = 0;\n\n/** Bumped once per full snapshot. A ref is only valid within its own generation. */\nlet generation = 0;\n\n/**\n * Element identity, off the host's objects entirely. Keyed by element so a recycled\n * node is recognised across snapshots; the entry carries the (role,name) key and the\n * generation for the two staleness checks above.\n */\nconst entries = new WeakMap<Element, RefEntry>();\n\n/** id -> element, for resolution. Rebuilt each generation from exactly what was emitted. */\nconst registry = new Map<ElementRef, Element>();\n\n/** Called once per FULL snapshot, before the walk. A region read does NOT call this. */\nexport function beginSnapshot(): void {\n generation++;\n registry.clear();\n}\n\n/**\n * Mint (or reuse) the ref for an element and register it for resolution.\n * Only ever called for elements that are visible AND receive pointer events.\n */\nexport function refFor(el: Element, role: string, name: string): ElementRef {\n const key = `${role} ${name}`;\n\n let entry = entries.get(el);\n if (!entry || entry.key !== key) {\n entry = { id: `e${++counter}`, key, gen: generation };\n entries.set(el, entry);\n } else {\n // Same node, same identity — carry it into the current generation so a fresh\n // snapshot re-validates a still-present element rather than orphaning it.\n entry.gen = generation;\n }\n\n registry.set(entry.id, el);\n return entry.id;\n}\n\n/**\n * Turn a ref back into an element.\n *\n * Three ways this returns null, each deliberate:\n * - unknown id (never minted, or from a cleared generation) → not in the registry;\n * - the element left the page → `isConnected` is false. A detached node still\n * answers every question (role, name, a zero box), so without this an action\n * would silently no-op against a ghost;\n * - the ref is from an OLDER generation → its entry.gen has been superseded. This is\n * what stops a recycled-node retarget: the agent is told the handle is stale and\n * must re-snapshot, rather than acting on the wrong row.\n */\nexport function resolveRef(ref: ElementRef): Element | null {\n const el = registry.get(ref);\n if (!el) return null;\n if (!el.isConnected) {\n registry.delete(ref);\n return null;\n }\n const entry = entries.get(el);\n if (!entry || entry.id !== ref || entry.gen !== generation) return null;\n return el;\n}\n\n/** Test-only: reset counters so refs are deterministic per test. */\nexport function __resetRefs(): void {\n counter = 0;\n generation = 0;\n registry.clear();\n}\n\n/**\n * Drop every ref's resolvability, without touching `counter`/`generation` — an old\n * id must never come back valid after this (unlike `__resetRefs`, which is test-only\n * determinism and would let ids collide again). Called from `context.ts`'s `stop()`\n * so a ref minted before a `pageContext:false` opt-out (or before an unmount) can't\n * be resolved afterward — belt-and-suspenders alongside `sendRegion`'s own\n * `pageContextOn` gate, in case a stale ref is ever replayed.\n */\nexport function clearRefs(): void {\n registry.clear();\n}\n","import { isDisabled, isInaccessible } from 'dom-accessibility-api';\n\nimport { isPrivate, redact } from '../context';\nimport {\n createStyleCache,\n hasLayout,\n isInteractive,\n NAME_FROM_CONTENT,\n isOpaque,\n isVisible,\n nameOf,\n receivesPointerEvents,\n roleOf,\n states,\n type StyleOf,\n} from './a11y';\nimport { beginSnapshot, refFor } from './refs';\n\nexport { resolveRef, clearRefs } from './refs';\n\n/**\n * The page, as the agent sees it.\n *\n * We emit Playwright's ARIA-snapshot YAML, and that choice is the point of this\n * file. It is not our format: it is the one the frontier models have seen most, via\n * playwright-mcp, so a model already knows how to read it and already knows that\n * `[ref=e12]` is the thing you hand back to act. Inventing our own dialect here\n * would cost us capability for nothing.\n *\n * - heading \"Orders\" [level=1]\n * - textbox \"Search orders\" [ref=e5]\n * - list:\n * - listitem:\n * - link \"Order #1043\" [ref=e8]\n * - text: \"Unpaid\"\n * - button \"Export CSV\" [ref=e12]\n *\n * Not raw HTML: a real page is tens of thousands of tokens of div soup, gives the\n * model nothing to act with, and is a prompt-injection firehose.\n */\n\n/* ─────────────────────────────── budgets ──────────────────────────────── */\n\n/**\n * These exist because the failure they prevent is not \"the snapshot is big\", it is\n * \"the agent confidently tells the user about a button that does not exist\". A model\n * given a silently-cut-off page has no way to know it was cut off, so it fills the\n * gap. Hence: hard caps, and `truncated: true` travels with the payload so the agent\n * can be TOLD it is not seeing everything.\n *\n * The two caps do different jobs, and conflating them is how you get a bad snapshot:\n *\n * MAX_LINES bounds the MODEL'S CONTEXT. 800 lines of ARIA YAML is ~12 KB, a few\n * thousand tokens — a dense dashboard, and about as much page as is useful to\n * reason over at once.\n *\n * MAX_NODES bounds the MAIN THREAD. It counts elements *visited*, most of which are\n * the wrapper divs of a modern app and emit nothing at all. Measured in Chrome on a\n * deeply-nested 52k-element table, visiting 4000 nodes costs ~25ms of walk. Set it\n * to 1500 (a tempting round number) and a div-soup page truncates at ~460 lines —\n * we would stop while HALF the line budget was still unspent, and tell the agent it\n * could not see a page we had simply given up on early.\n */\nconst MAX_NODES = 4000;\nconst MAX_LINES = 800;\nconst MAX_NAME = 120;\nconst MAX_TEXT = 120;\n/**\n * Max `<option>`s emitted per `<select>` before the rest is summarised. A country or\n * timezone picker runs to hundreds; the option list is an affordance to show, not a\n * reason to spend the line budget. The selected option is always in the first slice\n * in practice, but if a huge list has its selection past the cap the \"+N more\"\n * marker tells the agent it isn't seeing every choice.\n */\nconst MAX_OPTIONS = 25;\n\n/* ─────────────────────────────── model ────────────────────────────────── */\n\ninterface AriaNode {\n role: string;\n /** Raw accessible name. Redacted and truncated at render time, not here. */\n name: string;\n /** Pre-rendered bracket attributes, `[checked] [ref=e5]`. */\n props: string;\n children: (AriaNode | string)[];\n}\n\ninterface Walk {\n styleOf: StyleOf;\n layout: boolean;\n nodes: number;\n lines: number;\n truncated: boolean;\n /** Called for every element that gets a ref, so a caller can note which are on screen. */\n onRef?: (ref: string, el: Element) => void;\n}\n\n/** Elements that carry no meaning of their own: their children stand in for them. */\nconst TRANSPARENT = new Set(['generic', 'presentation', 'none']);\n\n/**\n * Never walked. `<script>`/`<style>`/`<noscript>` are the obvious ones; `<svg>` is\n * here because its innards are hundreds of `<path>` nodes of pure noise — any title\n * it carries is already folded into its parent's accessible name by accname.\n */\nconst SKIP_TAGS = new Set([\n 'SCRIPT',\n 'STYLE',\n 'NOSCRIPT',\n 'TEMPLATE',\n 'SVG',\n 'HEAD',\n 'LINK',\n 'META',\n 'BASE',\n]);\n\n/* ─────────────────────────────── walking ──────────────────────────────── */\n\n/** False once any budget is spent — the caller stops and we mark the snapshot truncated. */\nfunction withinBudget(w: Walk): boolean {\n if (w.nodes >= MAX_NODES || w.lines >= MAX_LINES) {\n w.truncated = true;\n return false;\n }\n return true;\n}\n\n/**\n * Is this element ours?\n *\n * The widget must never appear in its own snapshot: the agent describing its own\n * chat window back to itself is both useless and a lovely little feedback loop.\n */\nfunction isOurs(el: Element): boolean {\n return el.id === 'matterfact-embed' || el.hasAttribute('data-mf-embed');\n}\n\n/**\n * Hidden from assistive tech — and therefore from us.\n *\n * This is `isInaccessible()`'s rule set applied ONE NODE AT A TIME, top-down.\n * `isInaccessible()` itself walks every ancestor on every call, which over a whole\n * tree is the O(n·depth) blow-up the budget forbids; because we descend from the\n * root and prune the entire subtree the moment a node is hidden, the composition of\n * these local checks is exactly equivalent and costs O(1) per node. (We still call\n * the real thing once, on the root, as a backstop.)\n */\nfunction isHidden(\n el: Element,\n style: CSSStyleDeclaration,\n layout: boolean,\n): boolean {\n if (el.getAttribute('aria-hidden') === 'true') return true;\n if (el.hasAttribute('hidden') || el.hasAttribute('inert')) return true;\n return !isVisible(el, style, layout);\n}\n\n/**\n * The nodes a parent should walk.\n *\n * An open shadow root REPLACES its host's light children — those only reach the\n * screen by being slotted, and we pick them up when we hit the `<slot>` that pulls\n * them in. Walking both would emit every web component's contents twice. A closed\n * shadow root is opaque to us by design, exactly as it is to the rest of the page.\n */\nfunction childrenOf(el: Element): ArrayLike<Node> {\n if (el.shadowRoot) return el.shadowRoot.childNodes;\n if (el.tagName === 'SLOT') {\n const assigned = (el as HTMLSlotElement).assignedNodes({ flatten: true });\n // An unfilled slot renders its own fallback content.\n if (assigned.length) return assigned;\n }\n return el.childNodes;\n}\n\n/** ArrayLike + index loop, not for-of: a NodeList needs `DOM.Iterable`, and copying one to iterate it allocates an array per element for nothing. */\nfunction visitChildren(\n el: Element,\n parent: AriaNode,\n style: CSSStyleDeclaration,\n w: Walk,\n): void {\n const children = childrenOf(el);\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child) visitNode(child, parent, style, w);\n }\n}\n\nfunction visitText(node: Text, parent: AriaNode, w: Walk): void {\n const text = (node.nodeValue ?? '').replace(/\\s+/g, ' ').trim();\n if (!text) return;\n\n // The text of a button, a link or a heading IS its accessible name — we already\n // emitted it on the parent's line, and repeating it as a child would double the\n // tokens and imply a second, separate thing on the page. Decided by ROLE, never by\n // string-matching against the name (see NAME_FROM_CONTENT).\n if (NAME_FROM_CONTENT.has(parent.role)) return;\n\n if (!withinBudget(w)) return;\n w.lines++;\n parent.children.push(text);\n}\n\n/**\n * A native `<select>`, expanded into its options.\n *\n * The generic walk can't do this: a closed select's `<option>`s have no layout box,\n * so isVisible would prune them. Yet the options are exactly the affordance the agent\n * needs — \"what can I set this to\" — and, unlike an `<input>` value, they are a\n * bounded, author-defined set rather than free text the user typed. So we emit them,\n * and mark the selected one: it names one of the choices we are ALREADY showing, so\n * it reveals nothing a human looking at the control wouldn't see. Labels are redacted\n * at render time like every other name; the list is capped; a select the host deems\n * sensitive is hidden the usual way (`data-mf-private`) and never reaches here.\n *\n * `.options` is the flat HTMLOptionsCollection, so `<optgroup>` nesting is already\n * flattened for us; `<select multiple>` (role listbox) works through the same path.\n */\n/** One option, in Playwright's shape: `- option \"label\" [disabled] [selected]`. The\n * name is trimmed so a whitespace-only option renders `- option` (no \"\"). Disabled is\n * `:disabled` (which catches an <optgroup disabled> that isDisabled/opt.disabled miss)\n * OR isDisabled (which adds aria-disabled). Bracket order matches states(): [disabled]\n * before [selected]. */\nfunction optionNode(opt: HTMLOptionElement): AriaNode {\n const disabled = opt.matches(':disabled') || isDisabled(opt);\n return {\n role: 'option',\n name: (opt.label || opt.textContent || '').trim(),\n props:\n (disabled ? ' [disabled]' : '') + (opt.selected ? ' [selected]' : ''),\n children: [],\n };\n}\n\nfunction emitSelectOptions(\n select: HTMLSelectElement,\n parent: AriaNode,\n w: Walk,\n): void {\n const options = select.options;\n const shown = Math.min(options.length, MAX_OPTIONS);\n for (let i = 0; i < shown; i++) {\n if (!withinBudget(w)) return;\n const opt = options[i];\n if (!opt || isPrivate(opt)) continue;\n w.lines++;\n parent.children.push(optionNode(opt));\n }\n // The selected option IS the field's current value — the one option the agent most\n // needs. In a long list (country, timezone) the selection can sit past the cap, so\n // the front slice above would show none marked [selected]. Surface any selected\n // option that fell outside the cap regardless, and don't double-count it as hidden.\n let extraSelected = 0;\n const selected = select.selectedOptions;\n for (let i = 0; i < selected.length; i++) {\n const opt = selected[i];\n if (opt && opt.index >= shown && !isPrivate(opt)) {\n if (!withinBudget(w)) return;\n w.lines++;\n parent.children.push(optionNode(opt));\n extraSelected++;\n }\n }\n const remaining = options.length - shown - extraSelected;\n if (remaining > 0 && withinBudget(w)) {\n w.lines++;\n parent.children.push(`… (+${remaining} more options)`);\n }\n}\n\n/**\n * An `<input list=\"…\">`'s datalist suggestions.\n *\n * Same affordance as a `<select>`'s options — a bounded, author-defined set the user\n * can pick — but surfaced under the (still value-opaque) input, because the\n * `<datalist>` element is display:none, so the generic walk never reaches it. The\n * input's own value stays hidden; only the suggestion labels are emitted (redacted at\n * render like every name, and capped). No [selected] — a datalist has no current\n * choice, only completions.\n */\nfunction emitDatalistOptions(\n input: HTMLInputElement,\n parent: AriaNode,\n w: Walk,\n): void {\n const list = input.list as HTMLDataListElement | null;\n if (!list) return;\n const options = list.options;\n const shown = Math.min(options.length, MAX_OPTIONS);\n for (let i = 0; i < shown; i++) {\n if (!withinBudget(w)) return;\n const opt = options[i];\n if (!opt || isPrivate(opt)) continue;\n w.lines++;\n parent.children.push(optionNode(opt));\n }\n const remaining = options.length - shown;\n if (remaining > 0 && withinBudget(w)) {\n w.lines++;\n parent.children.push(`… (+${remaining} more options)`);\n }\n}\n\nfunction visitElement(\n el: Element,\n parent: AriaNode,\n parentStyle: CSSStyleDeclaration | null,\n w: Walk,\n): void {\n if (!withinBudget(w)) return;\n if (SKIP_TAGS.has(el.tagName) || isOurs(el)) return;\n\n // Privacy first, before we so much as compute a style: `data-mf-private` and\n // password/hidden inputs take their whole subtree with them.\n if (isPrivate(el)) return;\n\n w.nodes++;\n\n const style = w.styleOf(el);\n if (isHidden(el, style, w.layout)) return;\n\n const role = roleOf(el);\n const transparent = role === null || TRANSPARENT.has(role);\n const interactive = isInteractive(el, role, style, parentStyle);\n\n // A div with a click handler is invisible to us (no getEventListeners), but a div\n // that is FOCUSABLE, or that flips the cursor to a pointer, is announcing itself.\n // Playwright emits those as `- generic [ref=eN]` and so do we: without this, every\n // custom card, chip and icon-button on a modern app would be unreachable.\n if (transparent && !interactive) {\n visitChildren(el, parent, style, w);\n return;\n }\n\n const emittedRole = role === null || TRANSPARENT.has(role) ? 'generic' : role;\n const name = nameOf(el, w.styleOf);\n\n // Refs are for things you can act on. Static text does not get one — it would be a\n // handle the agent can only ever misuse, and it doubles the size of the snapshot.\n let ref = '';\n if (interactive && receivesPointerEvents(style)) {\n const r = refFor(el, emittedRole, name);\n ref = ` [ref=${r}]`;\n w.onRef?.(r, el);\n }\n\n const state = states(el, emittedRole);\n const node: AriaNode = {\n role: emittedRole,\n name,\n props: (state ? ` ${state}` : '') + ref,\n children: [],\n };\n\n w.lines++;\n parent.children.push(node);\n\n // A native <select>: emit its options — the affordance the opaque rule used to\n // hide — instead of walking its (layout-less, hence prune-able) children.\n if (el.tagName === 'SELECT') {\n emitSelectOptions(el as HTMLSelectElement, node, w);\n return;\n }\n\n // An <input list=\"…\">: surface its datalist suggestions (the affordance) under the\n // input, then fall through to the opaque return — the value itself is never emitted.\n if (el.tagName === 'INPUT' && (el as HTMLInputElement).list) {\n emitDatalistOptions(el as HTMLInputElement, node, w);\n }\n\n // isOpaque: an <input>, <textarea> or contenteditable. Its content IS the user's\n // data, so we do not walk into it — the value cannot leak because we never go and\n // look at it. See a11y.ts.\n if (isOpaque(el)) return;\n\n visitChildren(el, node, style, w);\n}\n\nfunction visitNode(\n node: Node,\n parent: AriaNode,\n parentStyle: CSSStyleDeclaration | null,\n w: Walk,\n): void {\n if (node.nodeType === 3 /* TEXT_NODE */) {\n visitText(node as Text, parent, w);\n } else if (node.nodeType === 1 /* ELEMENT_NODE */) {\n visitElement(node as Element, parent, parentStyle, w);\n }\n // Comments, CDATA, processing instructions: nothing to say.\n}\n\n/* ────────────────────────────── rendering ─────────────────────────────── */\n\n/**\n * Redact, then truncate — in that order, and the order is the point.\n *\n * Truncate first and a 130-character line containing an email address gets cut\n * through the middle of it, the regex no longer matches, and you have shipped\n * `jane.doe@acmecorp` to the model. Redaction runs on the whole string, every time,\n * before anything is thrown away.\n */\nfunction sanitize(text: string, max: number): string {\n const collapsed = text.replace(/\\s+/g, ' ').trim();\n const clean = redact(collapsed);\n return clean.length > max ? `${clean.slice(0, max - 1)}…` : clean;\n}\n\nfunction quote(text: string): string {\n return `\"${text.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\nfunction render(\n children: (AriaNode | string)[],\n depth: number,\n out: string[],\n): void {\n const pad = ' '.repeat(depth);\n for (const child of children) {\n if (typeof child === 'string') {\n out.push(`${pad}- text: ${quote(sanitize(child, MAX_TEXT))}`);\n continue;\n }\n const name = child.name ? ` ${quote(sanitize(child.name, MAX_NAME))}` : '';\n const head = `${pad}- ${child.role}${name}${child.props}`;\n if (child.children.length) {\n out.push(`${head}:`);\n render(child.children, depth + 1, out);\n } else {\n out.push(head);\n }\n }\n}\n\n/* ─────────────────────────────── entry ────────────────────────────────── */\n\n/**\n * Walk the page and render it. Called by context.ts, which redacts the result a\n * second time on the way out — the belt to this file's braces.\n */\nfunction walk(\n root: Element,\n onRef?: (ref: string, el: Element) => void,\n): { yaml: string; truncated: boolean } {\n const styleOf = createStyleCache();\n const w: Walk = {\n styleOf,\n layout: hasLayout(),\n nodes: 0,\n lines: 0,\n truncated: false,\n onRef,\n };\n\n // The one call to the real isInaccessible(): a cheap backstop on the root, where\n // the ancestor walk costs nothing.\n if (isInaccessible(root, { getComputedStyle: styleOf })) {\n return { yaml: '', truncated: false };\n }\n\n const tree: AriaNode = { role: '', name: '', props: '', children: [] };\n visitChildren(root, tree, styleOf(root), w);\n\n const lines: string[] = [];\n render(tree.children, 0, lines);\n\n // An in-band marker, not just the out-of-band `truncated` flag. The YAML is what\n // lands in the prompt; a backend template that injects the tree but forgets to\n // surface the flag would hand the model a page that simply stops, and the model\n // fills the gap. This line is inside the payload, so it cannot be dropped on the\n // way to the prompt. (Depth-first, so what is missing is the BOTTOM of the page.)\n //\n // It REPLACES the last emitted line rather than appending — the marker is part of\n // the line budget, not an exemption from it. The final line was a truncated node\n // anyway (see MAX_LINES), so nothing meaningful is lost.\n if (w.truncated && lines.length) {\n lines[lines.length - 1] =\n '- text: \"… (snapshot truncated — more of the page is below)\"';\n }\n\n return { yaml: lines.join('\\n'), truncated: w.truncated };\n}\n\n/**\n * The full page. Mints a fresh generation of refs (beginSnapshot), so any ref the\n * agent held from a previous snapshot is now stale and resolves to null — which is\n * correct: the page may have changed under it.\n *\n * `visibleRefs` is the viewport slice — the refs whose element is actually on screen.\n * That is the \"where is your attention\" signal, and it lets the focus context name\n * the handful of things in view out of the whole tree.\n */\nexport function snapshot(): {\n yaml: string;\n truncated: boolean;\n visibleRefs: string[];\n} {\n const root = document.body;\n if (!root) return { yaml: '', truncated: false, visibleRefs: [] };\n\n beginSnapshot();\n\n const visibleRefs: string[] = [];\n const vh = window.innerHeight || 0;\n const vw = window.innerWidth || 0;\n const result = walk(root, (ref, el) => {\n const r = el.getBoundingClientRect();\n // On screen = its box intersects the viewport. Cheap; the walk already forced\n // layout, so getBoundingClientRect here is reading a warm value.\n if (r.bottom > 0 && r.top < vh && r.right > 0 && r.left < vw) {\n visibleRefs.push(ref);\n }\n });\n\n return { ...result, visibleRefs };\n}\n\n/**\n * Zoom in on one ref — the a11y sub-tree under it.\n *\n * This is the pull half: the agent has the focus context and a shallow page, and when\n * it wants the detail of a specific table or form it asks for that region rather than\n * us re-sending the whole page. It does NOT call beginSnapshot — that would clear the\n * ref map and invalidate the very ref being asked about — so the refs it mints join\n * the current generation.\n */\nexport function snapshotRegion(root: Element): {\n yaml: string;\n truncated: boolean;\n} {\n if (!root.isConnected) return { yaml: '', truncated: false };\n return walk(root);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/dom/a11y.ts","../src/dom/refs.ts","../src/dom/snapshot.ts"],"names":["isDisabled"],"mappings":";;;AAkCO,SAAS,gBAAA,GAA4B;AAC1C,EAAA,MAAM,KAAA,uBAAY,OAAA,EAAsC;AACxD,EAAA,QAAQ,CAAC,IAAa,MAAA,KAAgD;AAEpE,IAAA,IAAI,MAAA,EAAQ,OAAO,MAAA,CAAO,gBAAA,CAAiB,IAAI,MAAM,CAAA;AACrD,IAAA,IAAI,KAAA,GAAQ,KAAA,CAAM,GAAA,CAAI,EAAE,CAAA;AACxB,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,KAAA,GAAQ,MAAA,CAAO,iBAAiB,EAAE,CAAA;AAClC,MAAA,KAAA,CAAM,GAAA,CAAI,IAAI,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,CAAC,KAAK,EAAA,KAAO;AACrC,IAAA,MAAM,CAAA,GAAI,GAAG,qBAAA,EAAsB;AAGnC,IAAA,IAAI,CAAA,CAAE,MAAA,GAAS,CAAA,IAAK,CAAA,CAAE,GAAA,GAAM,EAAA,IAAM,CAAA,CAAE,KAAA,GAAQ,CAAA,IAAK,CAAA,CAAE,IAAA,GAAO,EAAA,EAAI;AAC5D,MAAA,WAAA,CAAY,KAAK,GAAG,CAAA;AAAA,IACtB;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,GAAG,MAAA,EAAQ,WAAA,EAAY;AAClC;AAWO,SAAS,eAAe,IAAA,EAG7B;AACA,EAAA,IAAI,CAAC,KAAK,WAAA,EAAa,OAAO,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,KAAA,EAAM;AAC3D,EAAA,OAAO,KAAK,IAAI,CAAA;AAClB","file":"snapshot-P5SVKSPB.js","sourcesContent":["import {\n computeAccessibleName,\n getRole,\n isDisabled,\n} from 'dom-accessibility-api';\n\n/**\n * Role, name, visibility, interactability, state.\n *\n * WHAT WE ADOPTED: role and accessible name come from `dom-accessibility-api`\n * (MIT, zero deps) — the engine behind testing-library's `getByRole`. Accessible\n * name is a genuinely hard spec (accname walks aria-labelledby graphs, ::before\n * content, <label> associations, alt/title fallbacks, and recursive\n * name-from-content) and a hand-rolled version is wrong in ways you only discover\n * on a customer's page.\n *\n * WHAT WE BUILT: everything below that. Visibility and pointer-events are ~20 lines\n * from first principles (see `isVisible`/`receivesPointerEvents`) and the state\n * reads are direct DOM/ARIA reads, so we vendored nothing and took on no\n * Apache-2.0 attribution obligation.\n */\n\n/** A memoised `getComputedStyle`, shaped to be passed straight to accname. */\nexport type StyleOf = typeof window.getComputedStyle;\n\n/**\n * One computed style per element per snapshot.\n *\n * Not a micro-optimisation: `computeAccessibleName` calls back into\n * getComputedStyle for every descendant it walks while building a name from\n * content, so on a page of nested divs the uncached cost is quadratic-ish. The\n * cache is per-snapshot (a fresh WeakMap each walk), so it can never go stale\n * across snapshots.\n */\nexport function createStyleCache(): StyleOf {\n const cache = new WeakMap<Element, CSSStyleDeclaration>();\n return ((el: Element, pseudo?: string | null): CSSStyleDeclaration => {\n // Pseudo-element lookups are rare and must not poison the element cache.\n if (pseudo) return window.getComputedStyle(el, pseudo);\n let style = cache.get(el);\n if (!style) {\n style = window.getComputedStyle(el);\n cache.set(el, style);\n }\n return style;\n }) as StyleOf;\n}\n\n/**\n * Does this environment do layout at all?\n *\n * In a browser the root element always has a box. In jsdom — which has no layout\n * engine — *everything* reports zero client rects, so a box-based visibility check\n * would hide the entire page and our tests would assert on an empty snapshot. So we\n * feature-detect layout once per walk and fall back to style-only visibility when\n * there is none. This is a test-environment concession, stated out loud rather than\n * hidden behind a mock.\n */\nexport function hasLayout(): boolean {\n return document.documentElement.getClientRects().length > 0;\n}\n\n/**\n * Visible enough to be worth telling the agent about.\n *\n * `display` and `visibility` are read from the computed style, which already\n * accounts for inheritance — and because the walk is top-down and prunes whole\n * subtrees, we never pay for an ancestor walk. `display: contents` is the one\n * subtlety: such an element generates no box of its own but its children do, so it\n * must not be treated as invisible or we would drop a real subtree.\n */\nexport function isVisible(\n el: Element,\n style: CSSStyleDeclaration,\n layout: boolean,\n): boolean {\n const display = style.display;\n if (display === 'none') return false;\n\n const visibility = style.visibility;\n if (visibility === 'hidden' || visibility === 'collapse') return false;\n\n // `opacity: 0` is a standard \"hide from sight, keep for a11y\" technique. It still\n // reports a box, so the area check below misses it. We treat fully-transparent as\n // hidden; a partially-transparent element is genuinely on screen.\n if (Number(style.opacity) === 0) return false;\n\n // A `display: contents` element generates no box of its own but its children do,\n // so it must not be judged by its own (nonexistent) geometry — we let it through\n // and test each child on its own merits.\n if (layout && display !== 'contents') {\n // Area, not merely \"has a box\": `width:0;height:0;overflow:hidden` is one of the\n // commonest ways to hide a thing, and such an element still reports a client\n // rect. This is the check Playwright's own isVisible() makes.\n const box = el.getBoundingClientRect();\n if (box.width <= 0 || box.height <= 0) return false;\n\n // The sr-only / visually-hidden family: `clip: rect(0 0 0 0)` and its modern\n // `clip-path: inset(50%)` shrink the element to nothing while keeping a 1px box,\n // and `position:absolute; left:-9999px` parks it far off any real page. All three\n // are \"screen-reader only\" idioms — present for a11y, not for sight — so an agent\n // reading the page should skip them too. (getClientRects().length === 0 catches\n // the clipped ones; the far-offscreen check catches the parked ones.)\n if (el.getClientRects().length === 0) return false;\n if (box.right < -2000 || box.bottom < -2000) return false;\n }\n\n return true;\n}\n\n/**\n * Can a pointer actually reach it?\n *\n * `pointer-events` is an INHERITED property, so the computed value on the element\n * already encodes every ancestor's `pointer-events: none` — and correctly honours a\n * descendant that opts back in with `pointer-events: auto`. That is the whole check:\n * no ancestor walk, no hit-test. We deliberately do NOT test for occlusion (is\n * something painted on top of it) the way Playwright's actionability check does —\n * we are describing the page, not clicking it, and an element under a sticky header\n * is still worth telling the agent about.\n */\nexport function receivesPointerEvents(style: CSSStyleDeclaration): boolean {\n return style.pointerEvents !== 'none';\n}\n\n/** Roles that are inherently operable. */\nconst INTERACTIVE_ROLES = new Set([\n 'button',\n 'checkbox',\n 'combobox',\n 'link',\n 'listbox',\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio',\n 'option',\n 'radio',\n 'searchbox',\n 'slider',\n 'spinbutton',\n 'switch',\n 'tab',\n 'textbox',\n 'treeitem',\n]);\n\n/** Tags that are operable regardless of what role they compute to. */\nconst INTERACTIVE_TAGS = new Set([\n 'BUTTON',\n 'INPUT',\n 'SELECT',\n 'TEXTAREA',\n 'SUMMARY',\n]);\n\n/** `contenteditable` — present and not explicitly \"false\" (covers \"\", \"true\", \"plaintext-only\"). */\nexport function isEditable(el: Element): boolean {\n const v = el.getAttribute('contenteditable');\n return v !== null && v !== 'false';\n}\n\n/**\n * Is this element something the user can operate?\n *\n * THIS IS THE INTERESTING FUNCTION, so here is the reasoning in full.\n *\n * The obvious way to answer it — ask the DOM what event listeners are attached —\n * IS NOT AVAILABLE. `getEventListeners()` exists only inside DevTools (and via CDP).\n * We are ordinary page JS on a customer's website, so every `addEventListener` a\n * React, Vue or Svelte app ever registered is, to us, completely invisible. This is\n * precisely where the browser-use style of in-page DOM extraction degrades on real\n * apps: it cannot see a single handler, so it either misses the app's controls or\n * guesses wildly. We therefore never ask \"does it have a handler\"; we ask \"does it\n * PRESENT ITSELF as operable\", in four descending tiers of confidence:\n *\n * 1. TAG SEMANTICS (certain). button, input, select, textarea, summary, a[href].\n * 2. COMPUTED ROLE (certain). role=button|link|checkbox|… whether implicit or\n * author-supplied. A div with role=\"button\" is a\n * button as far as the platform, a screen reader,\n * and the user are concerned.\n * 3. FOCUSABILITY (strong). tabindex >= 0, or contenteditable. An app that\n * made a div keyboard-reachable did so on purpose.\n * 4. `cursor: pointer` (WEAK). Last resort, and the reason for the guard below.\n *\n * Tier 4 needs care, because `cursor` is INHERITED: a card with `cursor: pointer`\n * makes every span, every icon and every text node inside it report `pointer` too,\n * and a naive check would mint a ref for each of them and drown the snapshot. So we\n * only count the element that *introduced* the pointer cursor — the one whose parent\n * did not already have it. That is almost exactly the clickable card itself.\n */\nexport function isInteractive(\n el: Element,\n role: string | null,\n style: CSSStyleDeclaration,\n parentStyle: CSSStyleDeclaration | null,\n): boolean {\n const tag = el.tagName;\n\n // 1. tag semantics\n // An <a href> is interactive, but a hrefless <a> is NOT a dead end — it may be a\n // JS-nav link, an <a role=\"button\">, or a Bootstrap `.btn` anchor. So href is a\n // positive signal, not a gate: fall through to the role/tabindex/cursor tiers\n // rather than returning false and dropping every SPA link.\n if (tag === 'A' && el.hasAttribute('href')) return true;\n if (INTERACTIVE_TAGS.has(tag)) return true;\n\n // 2. computed role\n if (role !== null && INTERACTIVE_ROLES.has(role)) return true;\n\n // 3. focusability\n const tabindex = el.getAttribute('tabindex');\n if (tabindex !== null && Number(tabindex) >= 0) return true;\n if (isEditable(el)) return true;\n\n // 4. cursor: pointer, but only where it originates (see above)\n if (style.cursor === 'pointer' && parentStyle?.cursor !== 'pointer')\n return true;\n\n return false;\n}\n\n/**\n * Roles whose accessible name IS their text content (ARIA \"Name From: contents\").\n *\n * This is the exact list from the ARIA spec, and it earns its place: it is what tells\n * the walk that the \"Export CSV\" inside `<button>Export CSV</button>` has ALREADY been\n * emitted, as the button's name, and must not be repeated as a child text node.\n *\n * The tempting shortcut — \"skip any text that appears inside the parent's name\" — is\n * wrong, and wrong in a way that silently deletes content: a card labelled\n * `aria-label=\"Acme Corp order\"` containing the text \"Acme Corp\" would lose it,\n * because one is a substring of the other by coincidence. Ask the role, not the string.\n */\nexport const NAME_FROM_CONTENT = new Set([\n 'button',\n 'cell',\n 'checkbox',\n 'columnheader',\n 'gridcell',\n 'heading',\n 'link',\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio',\n 'option',\n 'radio',\n 'row',\n 'rowheader',\n 'switch',\n 'tab',\n 'tooltip',\n 'treeitem',\n]);\n\n/* ─────────────────────────────── state ────────────────────────────────── */\n\n/** Roles whose content IS the user's data. We report that a value exists, never what it is. */\nconst VALUE_ROLES = new Set(['textbox', 'searchbox', 'spinbutton']);\n\n/**\n * Roles we refuse to descend into, because their children/content ARE the value.\n *\n * A `<textarea>`'s child text node is literally what the user typed; a\n * contenteditable's subtree is the document they are writing. Refusing to walk in is\n * how \"never emit a value\" is enforced STRUCTURALLY, rather than by remembering to\n * filter at every emit site.\n *\n * `<select>` is deliberately NOT here. Its options are a bounded, author-defined\n * enumeration — the affordance the agent most needs (\"what can I set this to\"), not\n * the free-text user data the opaque rule exists to contain. The snapshot emits them\n * directly instead (capped, selected one marked): see emitSelectOptions in\n * snapshot.ts.\n */\nconst OPAQUE_TAGS = new Set(['INPUT', 'TEXTAREA']);\n\nexport function isOpaque(el: Element): boolean {\n return OPAQUE_TAGS.has(el.tagName) || isEditable(el);\n}\n\n/**\n * Has the user put something in this field?\n *\n * `.value` is read and immediately thrown away — only its LENGTH escapes. This is\n * the single most useful bit about a form (\"is the email box already filled in?\")\n * and the single most dangerous string on the page, so it is reduced to one bit at\n * the point of reading and never travels.\n */\nfunction isFilled(el: Element, role: string): boolean {\n const tag = el.tagName;\n if (tag === 'INPUT' || tag === 'TEXTAREA') {\n if (!VALUE_ROLES.has(role)) return false; // checkbox.value is \"on\" — meaningless\n return ((el as HTMLInputElement).value ?? '').length > 0;\n }\n if (isEditable(el)) return (el.textContent ?? '').trim().length > 0;\n return false;\n}\n\nfunction ariaFlag(el: Element, attr: string): 'true' | 'mixed' | null {\n const v = el.getAttribute(attr);\n if (v === 'true') return 'true';\n if (v === 'mixed') return 'mixed';\n return null;\n}\n\n/**\n * The bracketed attributes, in Playwright's order:\n * [checked] [disabled] [expanded] [level=N] [pressed] [selected]\n * plus our one addition, [filled] — see isFilled. `[ref=eN]` is appended by the\n * caller and always comes last.\n */\nexport function states(el: Element, role: string): string {\n const out: string[] = [];\n const tag = el.tagName;\n\n // checked\n if (tag === 'INPUT' && (role === 'checkbox' || role === 'radio')) {\n if ((el as HTMLInputElement).checked) out.push('[checked]');\n } else {\n const checked = ariaFlag(el, 'aria-checked');\n if (checked === 'mixed') out.push('[checked=mixed]');\n else if (checked === 'true') out.push('[checked]');\n }\n\n // disabled — dom-accessibility-api handles fieldset/optgroup inheritance and aria-disabled\n if (isDisabled(el)) out.push('[disabled]');\n\n // expanded — <summary> reflects its parent <details>, which has no ARIA attribute\n const expanded = el.getAttribute('aria-expanded');\n if (expanded === 'true' || expanded === 'false') {\n if (expanded === 'true') out.push('[expanded]');\n } else if (tag === 'SUMMARY') {\n const details = el.parentElement;\n if (\n details?.tagName === 'DETAILS' &&\n (details as HTMLDetailsElement).open\n ) {\n out.push('[expanded]');\n }\n }\n\n // level\n if (role === 'heading') {\n const aria = el.getAttribute('aria-level');\n const level = aria ? Number(aria) : Number(tag[1]);\n if (Number.isFinite(level) && level > 0) out.push(`[level=${level}]`);\n }\n\n // pressed\n const pressed = ariaFlag(el, 'aria-pressed');\n if (pressed === 'mixed') out.push('[pressed=mixed]');\n else if (pressed === 'true') out.push('[pressed]');\n\n // selected\n if (el.getAttribute('aria-selected') === 'true') out.push('[selected]');\n\n // filled (ours — a boolean, never the value)\n if (isFilled(el, role)) out.push('[filled]');\n\n return out.join(' ');\n}\n\n/* ─────────────────────────── role & name ──────────────────────────────── */\n\n/**\n * The computed role, with one correction.\n *\n * `getRole` follows HTML-AAM and returns null for a contenteditable div — but every\n * real browser exposes it to assistive tech as a textbox, and that is what it is to\n * the user and to the agent. We say textbox.\n */\nexport function roleOf(el: Element): string | null {\n if (isEditable(el)) return 'textbox';\n return getRole(el);\n}\n\n/**\n * Selector for anything whose CONTENT is the user's data — a form control, a\n * contenteditable, a valued widget, or a host-marked private region.\n */\nconst UNTRUSTED_CONTENT =\n 'input,textarea,select,[contenteditable=\"\"],[contenteditable=\"true\"],[aria-valuetext],[data-mf-private]';\n\n/**\n * Would computing this element's ACCESSIBLE NAME read the user's data?\n *\n * This is the leak the structural `isOpaque` walk cannot see. `computeAccessibleName`\n * runs its OWN descendant walk, inside dom-accessibility-api, that knows nothing about\n * our opaque set or `data-mf-private` — it will happily read `input.value`,\n * `aria-valuetext`, a contenteditable's text, or a private subtree, and fold it into\n * the name of a name-from-content ANCESTOR or any `aria-labelledby` referrer. So a\n * value our walk refuses to enter re-enters through the parent's name.\n *\n * Two vectors, both handled:\n * - name-from-content: the name is built from descendant text. If any descendant is\n * untrusted, the name is tainted.\n * - aria-labelledby: the name is pulled from a referenced element. If any referent\n * is (or contains) untrusted content, the name is tainted.\n *\n * `aria-label` and `title` are author-written static strings; a site that copies its\n * own secret into one is exposing it deliberately and we cannot defend that. The\n * automatic-computation vectors are the ones we must close.\n */\nfunction nameIsUntrusted(el: Element): boolean {\n const labelledby = el.getAttribute('aria-labelledby');\n if (labelledby) {\n for (const id of labelledby.split(/\\s+/)) {\n if (!id) continue;\n const ref = el.ownerDocument.getElementById(id);\n if (!ref) continue;\n if (\n ref.matches(UNTRUSTED_CONTENT) ||\n ref.querySelector(UNTRUSTED_CONTENT)\n ) {\n return true;\n }\n }\n return false;\n }\n // No explicit label attributes → the name, if any, is name-from-content.\n if (el.hasAttribute('aria-label')) return false;\n return el.querySelector(UNTRUSTED_CONTENT) !== null;\n}\n\nexport function nameOf(el: Element, styleOf: StyleOf): string {\n const name = computeAccessibleName(el, {\n getComputedStyle: styleOf,\n // jsdom logs a console error if you claim pseudo-element support it doesn't have.\n computedStyleSupportsPseudoElements: false,\n });\n if (!name) return '';\n\n // A tainted name would leak a value or a private string. Drop it entirely and let\n // the element stand on its role + ref. Losing a name costs the agent a little\n // context; keeping a leaked one is a breach. The trade is not close.\n if (nameIsUntrusted(el)) {\n // Preserve an explicit author label if one exists and is not itself the taint —\n // aria-labelledby taints were already caught above, so any aria-label here is safe.\n return el.getAttribute('aria-label') || '';\n }\n return name;\n}\n","import type { ElementRef } from '../protocol';\n\n/**\n * Element handles.\n *\n * The mechanism is Playwright's, deliberately (see protocol.ts): the agent never\n * learns a selector, it learns `e12`, and `e12` is turned back into an element\n * HERE, in the page, by us.\n *\n * Three properties matter and all are load-bearing:\n *\n * 1. THE MAP IS A WeakMap, NOT AN EXPANDO ON THE ELEMENT. An earlier version\n * stamped `el._mfRef`. Non-enumerable, so invisible to `Object.keys`/spreads/\n * `JSON.stringify` — but STILL reachable via `Object.getOwnPropertyNames` and\n * `Reflect.ownKeys`, and, worse, it parked the element's accessible name on the\n * customer's live DOM node indefinitely. A `WeakMap<Element, RefEntry>` mutates\n * nothing on their objects, is invisible to every enumeration and serialization\n * API without exception, cannot collide with a property the host already has,\n * and still gives us node-identity survival across GC for free.\n *\n * 2. A REF IS REGENERATED WHEN ROLE OR NAME CHANGES. Frameworks recycle DOM nodes:\n * a virtualised list scrolls, and the <button> that said \"Approve\" is the very\n * same node that now says \"Delete\". Keying the ref on (role, name) means that\n * node gets a NEW id and the old id resolves to nothing.\n *\n * 3. A REF IS SCOPED TO ONE SNAPSHOT GENERATION. (2) is necessary but not\n * sufficient: two icon-only \"Delete\" buttons in a virtualised table have the\n * SAME (role, name), so a recycled node whose role+name are unchanged would keep\n * its ref and silently retarget a different logical row. So a ref also carries\n * the generation it was minted in, and resolveRef refuses a ref from an older\n * generation — the agent must re-snapshot to get a fresh, valid handle. Loud\n * staleness beats silent retargeting.\n */\n\ninterface RefEntry {\n id: ElementRef;\n /** role + name at mint time. Changes here invalidate the ref. */\n key: string;\n /** The snapshot generation this ref belongs to. */\n gen: number;\n}\n\n/**\n * Monotonic across snapshots, never reused — like Playwright's. An id is only ever\n * handed out once in a page's lifetime, so a stale ref can never be *silently*\n * correct by colliding with a newer element; it just resolves to null.\n */\nlet counter = 0;\n\n/** Bumped once per full snapshot. A ref is only valid within its own generation. */\nlet generation = 0;\n\n/**\n * Element identity, off the host's objects entirely. Keyed by element so a recycled\n * node is recognised across snapshots; the entry carries the (role,name) key and the\n * generation for the two staleness checks above.\n */\nconst entries = new WeakMap<Element, RefEntry>();\n\n/** id -> element, for resolution. Rebuilt each generation from exactly what was emitted. */\nconst registry = new Map<ElementRef, Element>();\n\n/** Called once per FULL snapshot, before the walk. A region read does NOT call this. */\nexport function beginSnapshot(): void {\n generation++;\n registry.clear();\n}\n\n/**\n * Mint (or reuse) the ref for an element and register it for resolution.\n * Only ever called for elements that are visible AND receive pointer events.\n */\nexport function refFor(el: Element, role: string, name: string): ElementRef {\n const key = `${role} ${name}`;\n\n let entry = entries.get(el);\n if (!entry || entry.key !== key) {\n entry = { id: `e${++counter}`, key, gen: generation };\n entries.set(el, entry);\n } else {\n // Same node, same identity — carry it into the current generation so a fresh\n // snapshot re-validates a still-present element rather than orphaning it.\n entry.gen = generation;\n }\n\n registry.set(entry.id, el);\n return entry.id;\n}\n\n/**\n * Turn a ref back into an element.\n *\n * Three ways this returns null, each deliberate:\n * - unknown id (never minted, or from a cleared generation) → not in the registry;\n * - the element left the page → `isConnected` is false. A detached node still\n * answers every question (role, name, a zero box), so without this an action\n * would silently no-op against a ghost;\n * - the ref is from an OLDER generation → its entry.gen has been superseded. This is\n * what stops a recycled-node retarget: the agent is told the handle is stale and\n * must re-snapshot, rather than acting on the wrong row.\n */\nexport function resolveRef(ref: ElementRef): Element | null {\n const el = registry.get(ref);\n if (!el) return null;\n if (!el.isConnected) {\n registry.delete(ref);\n return null;\n }\n const entry = entries.get(el);\n if (!entry || entry.id !== ref || entry.gen !== generation) return null;\n return el;\n}\n\n/** Test-only: reset counters so refs are deterministic per test. */\nexport function __resetRefs(): void {\n counter = 0;\n generation = 0;\n registry.clear();\n}\n\n/**\n * Drop every ref's resolvability, without touching `counter`/`generation` — an old\n * id must never come back valid after this (unlike `__resetRefs`, which is test-only\n * determinism and would let ids collide again). Called from `context.ts`'s `stop()`\n * so a ref minted before a `pageContext:false` opt-out (or before an unmount) can't\n * be resolved afterward — belt-and-suspenders alongside `sendRegion`'s own\n * `pageContextOn` gate, in case a stale ref is ever replayed.\n */\nexport function clearRefs(): void {\n registry.clear();\n}\n","import { isDisabled, isInaccessible } from 'dom-accessibility-api';\n\nimport { isPrivate, redact } from '../context';\nimport {\n createStyleCache,\n hasLayout,\n isInteractive,\n NAME_FROM_CONTENT,\n isOpaque,\n isVisible,\n nameOf,\n receivesPointerEvents,\n roleOf,\n states,\n type StyleOf,\n} from './a11y';\nimport { beginSnapshot, refFor } from './refs';\n\nexport { resolveRef, clearRefs } from './refs';\n\n/**\n * The page, as the agent sees it.\n *\n * We emit Playwright's ARIA-snapshot YAML, and that choice is the point of this\n * file. It is not our format: it is the one the frontier models have seen most, via\n * playwright-mcp, so a model already knows how to read it and already knows that\n * `[ref=e12]` is the thing you hand back to act. Inventing our own dialect here\n * would cost us capability for nothing.\n *\n * - heading \"Orders\" [level=1]\n * - textbox \"Search orders\" [ref=e5]\n * - list:\n * - listitem:\n * - link \"Order #1043\" [ref=e8]\n * - text: \"Unpaid\"\n * - button \"Export CSV\" [ref=e12]\n *\n * Not raw HTML: a real page is tens of thousands of tokens of div soup, gives the\n * model nothing to act with, and is a prompt-injection firehose.\n */\n\n/* ─────────────────────────────── budgets ──────────────────────────────── */\n\n/**\n * These exist because the failure they prevent is not \"the snapshot is big\", it is\n * \"the agent confidently tells the user about a button that does not exist\". A model\n * given a silently-cut-off page has no way to know it was cut off, so it fills the\n * gap. Hence: hard caps, and `truncated: true` travels with the payload so the agent\n * can be TOLD it is not seeing everything.\n *\n * The two caps do different jobs, and conflating them is how you get a bad snapshot:\n *\n * MAX_LINES bounds the MODEL'S CONTEXT. 800 lines of ARIA YAML is ~12 KB, a few\n * thousand tokens — a dense dashboard, and about as much page as is useful to\n * reason over at once.\n *\n * MAX_NODES bounds the MAIN THREAD. It counts elements *visited*, most of which are\n * the wrapper divs of a modern app and emit nothing at all. Measured in Chrome on a\n * deeply-nested 52k-element table, visiting 4000 nodes costs ~25ms of walk. Set it\n * to 1500 (a tempting round number) and a div-soup page truncates at ~460 lines —\n * we would stop while HALF the line budget was still unspent, and tell the agent it\n * could not see a page we had simply given up on early.\n */\nconst MAX_NODES = 4000;\nconst MAX_LINES = 800;\nconst MAX_NAME = 120;\nconst MAX_TEXT = 120;\n/**\n * Max `<option>`s emitted per `<select>` before the rest is summarised. A country or\n * timezone picker runs to hundreds; the option list is an affordance to show, not a\n * reason to spend the line budget. The selected option is always in the first slice\n * in practice, but if a huge list has its selection past the cap the \"+N more\"\n * marker tells the agent it isn't seeing every choice.\n */\nconst MAX_OPTIONS = 25;\n\n/* ─────────────────────────────── model ────────────────────────────────── */\n\ninterface AriaNode {\n role: string;\n /** Raw accessible name. Redacted and truncated at render time, not here. */\n name: string;\n /** Pre-rendered bracket attributes, `[checked] [ref=e5]`. */\n props: string;\n children: (AriaNode | string)[];\n}\n\ninterface Walk {\n styleOf: StyleOf;\n layout: boolean;\n nodes: number;\n lines: number;\n truncated: boolean;\n /** Called for every element that gets a ref, so a caller can note which are on screen. */\n onRef?: (ref: string, el: Element) => void;\n}\n\n/** Elements that carry no meaning of their own: their children stand in for them. */\nconst TRANSPARENT = new Set(['generic', 'presentation', 'none']);\n\n/**\n * Never walked. `<script>`/`<style>`/`<noscript>` are the obvious ones; `<svg>` is\n * here because its innards are hundreds of `<path>` nodes of pure noise — any title\n * it carries is already folded into its parent's accessible name by accname.\n */\nconst SKIP_TAGS = new Set([\n 'SCRIPT',\n 'STYLE',\n 'NOSCRIPT',\n 'TEMPLATE',\n 'SVG',\n 'HEAD',\n 'LINK',\n 'META',\n 'BASE',\n]);\n\n/* ─────────────────────────────── walking ──────────────────────────────── */\n\n/** False once any budget is spent — the caller stops and we mark the snapshot truncated. */\nfunction withinBudget(w: Walk): boolean {\n if (w.nodes >= MAX_NODES || w.lines >= MAX_LINES) {\n w.truncated = true;\n return false;\n }\n return true;\n}\n\n/**\n * Is this element ours?\n *\n * The widget must never appear in its own snapshot: the agent describing its own\n * chat window back to itself is both useless and a lovely little feedback loop.\n */\nfunction isOurs(el: Element): boolean {\n return el.id === 'matterfact-embed' || el.hasAttribute('data-mf-embed');\n}\n\n/**\n * Hidden from assistive tech — and therefore from us.\n *\n * This is `isInaccessible()`'s rule set applied ONE NODE AT A TIME, top-down.\n * `isInaccessible()` itself walks every ancestor on every call, which over a whole\n * tree is the O(n·depth) blow-up the budget forbids; because we descend from the\n * root and prune the entire subtree the moment a node is hidden, the composition of\n * these local checks is exactly equivalent and costs O(1) per node. (We still call\n * the real thing once, on the root, as a backstop.)\n */\nfunction isHidden(\n el: Element,\n style: CSSStyleDeclaration,\n layout: boolean,\n): boolean {\n if (el.getAttribute('aria-hidden') === 'true') return true;\n if (el.hasAttribute('hidden') || el.hasAttribute('inert')) return true;\n return !isVisible(el, style, layout);\n}\n\n/**\n * The nodes a parent should walk.\n *\n * An open shadow root REPLACES its host's light children — those only reach the\n * screen by being slotted, and we pick them up when we hit the `<slot>` that pulls\n * them in. Walking both would emit every web component's contents twice. A closed\n * shadow root is opaque to us by design, exactly as it is to the rest of the page.\n */\nfunction childrenOf(el: Element): ArrayLike<Node> {\n if (el.shadowRoot) return el.shadowRoot.childNodes;\n if (el.tagName === 'SLOT') {\n const assigned = (el as HTMLSlotElement).assignedNodes({ flatten: true });\n // An unfilled slot renders its own fallback content.\n if (assigned.length) return assigned;\n }\n return el.childNodes;\n}\n\n/** ArrayLike + index loop, not for-of: a NodeList needs `DOM.Iterable`, and copying one to iterate it allocates an array per element for nothing. */\nfunction visitChildren(\n el: Element,\n parent: AriaNode,\n style: CSSStyleDeclaration,\n w: Walk,\n): void {\n const children = childrenOf(el);\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child) visitNode(child, parent, style, w);\n }\n}\n\nfunction visitText(node: Text, parent: AriaNode, w: Walk): void {\n const text = (node.nodeValue ?? '').replace(/\\s+/g, ' ').trim();\n if (!text) return;\n\n // The text of a button, a link or a heading IS its accessible name — we already\n // emitted it on the parent's line, and repeating it as a child would double the\n // tokens and imply a second, separate thing on the page. Decided by ROLE, never by\n // string-matching against the name (see NAME_FROM_CONTENT).\n if (NAME_FROM_CONTENT.has(parent.role)) return;\n\n if (!withinBudget(w)) return;\n w.lines++;\n parent.children.push(text);\n}\n\n/**\n * A native `<select>`, expanded into its options.\n *\n * The generic walk can't do this: a closed select's `<option>`s have no layout box,\n * so isVisible would prune them. Yet the options are exactly the affordance the agent\n * needs — \"what can I set this to\" — and, unlike an `<input>` value, they are a\n * bounded, author-defined set rather than free text the user typed. So we emit them,\n * and mark the selected one: it names one of the choices we are ALREADY showing, so\n * it reveals nothing a human looking at the control wouldn't see. Labels are redacted\n * at render time like every other name; the list is capped; a select the host deems\n * sensitive is hidden the usual way (`data-mf-private`) and never reaches here.\n *\n * `.options` is the flat HTMLOptionsCollection, so `<optgroup>` nesting is already\n * flattened for us; `<select multiple>` (role listbox) works through the same path.\n */\n/** One option, in Playwright's shape: `- option \"label\" [disabled] [selected]`. The\n * name is trimmed so a whitespace-only option renders `- option` (no \"\"). Disabled is\n * `:disabled` (which catches an <optgroup disabled> that isDisabled/opt.disabled miss)\n * OR isDisabled (which adds aria-disabled). Bracket order matches states(): [disabled]\n * before [selected]. */\nfunction optionNode(opt: HTMLOptionElement): AriaNode {\n const disabled = opt.matches(':disabled') || isDisabled(opt);\n return {\n role: 'option',\n name: (opt.label || opt.textContent || '').trim(),\n props:\n (disabled ? ' [disabled]' : '') + (opt.selected ? ' [selected]' : ''),\n children: [],\n };\n}\n\nfunction emitSelectOptions(\n select: HTMLSelectElement,\n parent: AriaNode,\n w: Walk,\n): void {\n const options = select.options;\n const shown = Math.min(options.length, MAX_OPTIONS);\n for (let i = 0; i < shown; i++) {\n if (!withinBudget(w)) return;\n const opt = options[i];\n if (!opt || isPrivate(opt)) continue;\n w.lines++;\n parent.children.push(optionNode(opt));\n }\n // The selected option IS the field's current value — the one option the agent most\n // needs. In a long list (country, timezone) the selection can sit past the cap, so\n // the front slice above would show none marked [selected]. Surface any selected\n // option that fell outside the cap regardless, and don't double-count it as hidden.\n let extraSelected = 0;\n const selected = select.selectedOptions;\n for (let i = 0; i < selected.length; i++) {\n const opt = selected[i];\n if (opt && opt.index >= shown && !isPrivate(opt)) {\n if (!withinBudget(w)) return;\n w.lines++;\n parent.children.push(optionNode(opt));\n extraSelected++;\n }\n }\n const remaining = options.length - shown - extraSelected;\n if (remaining > 0 && withinBudget(w)) {\n w.lines++;\n parent.children.push(`… (+${remaining} more options)`);\n }\n}\n\n/**\n * An `<input list=\"…\">`'s datalist suggestions.\n *\n * Same affordance as a `<select>`'s options — a bounded, author-defined set the user\n * can pick — but surfaced under the (still value-opaque) input, because the\n * `<datalist>` element is display:none, so the generic walk never reaches it. The\n * input's own value stays hidden; only the suggestion labels are emitted (redacted at\n * render like every name, and capped). No [selected] — a datalist has no current\n * choice, only completions.\n */\nfunction emitDatalistOptions(\n input: HTMLInputElement,\n parent: AriaNode,\n w: Walk,\n): void {\n const list = input.list as HTMLDataListElement | null;\n if (!list) return;\n const options = list.options;\n const shown = Math.min(options.length, MAX_OPTIONS);\n for (let i = 0; i < shown; i++) {\n if (!withinBudget(w)) return;\n const opt = options[i];\n if (!opt || isPrivate(opt)) continue;\n w.lines++;\n parent.children.push(optionNode(opt));\n }\n const remaining = options.length - shown;\n if (remaining > 0 && withinBudget(w)) {\n w.lines++;\n parent.children.push(`… (+${remaining} more options)`);\n }\n}\n\nfunction visitElement(\n el: Element,\n parent: AriaNode,\n parentStyle: CSSStyleDeclaration | null,\n w: Walk,\n): void {\n if (!withinBudget(w)) return;\n if (SKIP_TAGS.has(el.tagName) || isOurs(el)) return;\n\n // Privacy first, before we so much as compute a style: `data-mf-private` and\n // password/hidden inputs take their whole subtree with them.\n if (isPrivate(el)) return;\n\n w.nodes++;\n\n const style = w.styleOf(el);\n if (isHidden(el, style, w.layout)) return;\n\n const role = roleOf(el);\n const transparent = role === null || TRANSPARENT.has(role);\n const interactive = isInteractive(el, role, style, parentStyle);\n\n // A div with a click handler is invisible to us (no getEventListeners), but a div\n // that is FOCUSABLE, or that flips the cursor to a pointer, is announcing itself.\n // Playwright emits those as `- generic [ref=eN]` and so do we: without this, every\n // custom card, chip and icon-button on a modern app would be unreachable.\n if (transparent && !interactive) {\n visitChildren(el, parent, style, w);\n return;\n }\n\n const emittedRole = role === null || TRANSPARENT.has(role) ? 'generic' : role;\n const name = nameOf(el, w.styleOf);\n\n // Refs are for things you can act on. Static text does not get one — it would be a\n // handle the agent can only ever misuse, and it doubles the size of the snapshot.\n let ref = '';\n if (interactive && receivesPointerEvents(style)) {\n const r = refFor(el, emittedRole, name);\n ref = ` [ref=${r}]`;\n w.onRef?.(r, el);\n }\n\n const state = states(el, emittedRole);\n const node: AriaNode = {\n role: emittedRole,\n name,\n props: (state ? ` ${state}` : '') + ref,\n children: [],\n };\n\n w.lines++;\n parent.children.push(node);\n\n // A native <select>: emit its options — the affordance the opaque rule used to\n // hide — instead of walking its (layout-less, hence prune-able) children.\n if (el.tagName === 'SELECT') {\n emitSelectOptions(el as HTMLSelectElement, node, w);\n return;\n }\n\n // An <input list=\"…\">: surface its datalist suggestions (the affordance) under the\n // input, then fall through to the opaque return — the value itself is never emitted.\n if (el.tagName === 'INPUT' && (el as HTMLInputElement).list) {\n emitDatalistOptions(el as HTMLInputElement, node, w);\n }\n\n // isOpaque: an <input>, <textarea> or contenteditable. Its content IS the user's\n // data, so we do not walk into it — the value cannot leak because we never go and\n // look at it. See a11y.ts.\n if (isOpaque(el)) return;\n\n visitChildren(el, node, style, w);\n}\n\nfunction visitNode(\n node: Node,\n parent: AriaNode,\n parentStyle: CSSStyleDeclaration | null,\n w: Walk,\n): void {\n if (node.nodeType === 3 /* TEXT_NODE */) {\n visitText(node as Text, parent, w);\n } else if (node.nodeType === 1 /* ELEMENT_NODE */) {\n visitElement(node as Element, parent, parentStyle, w);\n }\n // Comments, CDATA, processing instructions: nothing to say.\n}\n\n/* ────────────────────────────── rendering ─────────────────────────────── */\n\n/**\n * Redact, then truncate — in that order, and the order is the point.\n *\n * Truncate first and a 130-character line containing an email address gets cut\n * through the middle of it, the regex no longer matches, and you have shipped\n * `jane.doe@acmecorp` to the model. Redaction runs on the whole string, every time,\n * before anything is thrown away.\n */\nfunction sanitize(text: string, max: number): string {\n const collapsed = text.replace(/\\s+/g, ' ').trim();\n const clean = redact(collapsed);\n return clean.length > max ? `${clean.slice(0, max - 1)}…` : clean;\n}\n\nfunction quote(text: string): string {\n return `\"${text.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\nfunction render(\n children: (AriaNode | string)[],\n depth: number,\n out: string[],\n): void {\n const pad = ' '.repeat(depth);\n for (const child of children) {\n if (typeof child === 'string') {\n out.push(`${pad}- text: ${quote(sanitize(child, MAX_TEXT))}`);\n continue;\n }\n const name = child.name ? ` ${quote(sanitize(child.name, MAX_NAME))}` : '';\n const head = `${pad}- ${child.role}${name}${child.props}`;\n if (child.children.length) {\n out.push(`${head}:`);\n render(child.children, depth + 1, out);\n } else {\n out.push(head);\n }\n }\n}\n\n/* ─────────────────────────────── entry ────────────────────────────────── */\n\n/**\n * Walk the page and render it. Called by context.ts, which redacts the result a\n * second time on the way out — the belt to this file's braces.\n */\nfunction walk(\n root: Element,\n onRef?: (ref: string, el: Element) => void,\n): { yaml: string; truncated: boolean } {\n const styleOf = createStyleCache();\n const w: Walk = {\n styleOf,\n layout: hasLayout(),\n nodes: 0,\n lines: 0,\n truncated: false,\n onRef,\n };\n\n // The one call to the real isInaccessible(): a cheap backstop on the root, where\n // the ancestor walk costs nothing.\n if (isInaccessible(root, { getComputedStyle: styleOf })) {\n return { yaml: '', truncated: false };\n }\n\n const tree: AriaNode = { role: '', name: '', props: '', children: [] };\n visitChildren(root, tree, styleOf(root), w);\n\n const lines: string[] = [];\n render(tree.children, 0, lines);\n\n // An in-band marker, not just the out-of-band `truncated` flag. The YAML is what\n // lands in the prompt; a backend template that injects the tree but forgets to\n // surface the flag would hand the model a page that simply stops, and the model\n // fills the gap. This line is inside the payload, so it cannot be dropped on the\n // way to the prompt. (Depth-first, so what is missing is the BOTTOM of the page.)\n //\n // It REPLACES the last emitted line rather than appending — the marker is part of\n // the line budget, not an exemption from it. The final line was a truncated node\n // anyway (see MAX_LINES), so nothing meaningful is lost.\n if (w.truncated && lines.length) {\n lines[lines.length - 1] =\n '- text: \"… (snapshot truncated — more of the page is below)\"';\n }\n\n return { yaml: lines.join('\\n'), truncated: w.truncated };\n}\n\n/**\n * The full page. Mints a fresh generation of refs (beginSnapshot), so any ref the\n * agent held from a previous snapshot is now stale and resolves to null — which is\n * correct: the page may have changed under it.\n *\n * `visibleRefs` is the viewport slice — the refs whose element is actually on screen.\n * That is the \"where is your attention\" signal, and it lets the focus context name\n * the handful of things in view out of the whole tree.\n */\nexport function snapshot(): {\n yaml: string;\n truncated: boolean;\n visibleRefs: string[];\n} {\n const root = document.body;\n if (!root) return { yaml: '', truncated: false, visibleRefs: [] };\n\n beginSnapshot();\n\n const visibleRefs: string[] = [];\n const vh = window.innerHeight || 0;\n const vw = window.innerWidth || 0;\n const result = walk(root, (ref, el) => {\n const r = el.getBoundingClientRect();\n // On screen = its box intersects the viewport. Cheap; the walk already forced\n // layout, so getBoundingClientRect here is reading a warm value.\n if (r.bottom > 0 && r.top < vh && r.right > 0 && r.left < vw) {\n visibleRefs.push(ref);\n }\n });\n\n return { ...result, visibleRefs };\n}\n\n/**\n * Zoom in on one ref — the a11y sub-tree under it.\n *\n * This is the pull half: the agent has the focus context and a shallow page, and when\n * it wants the detail of a specific table or form it asks for that region rather than\n * us re-sending the whole page. It does NOT call beginSnapshot — that would clear the\n * ref map and invalidate the very ref being asked about — so the refs it mints join\n * the current generation.\n */\nexport function snapshotRegion(root: Element): {\n yaml: string;\n truncated: boolean;\n} {\n if (!root.isConnected) return { yaml: '', truncated: false };\n return walk(root);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterfact/embed",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "The matterfact embeddable agent: mount the chat in a cross-origin iframe (a <script> loader for any site, or a <MatterfactAgent> React component), give the agent eyes on the host page, and embed matterfact artifacts inline with <MatterfactArtifact>.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|