@yielded/agent-platform-cloudflare 0.1.0-beta.167 → 0.1.0-beta.169

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.
Files changed (97) hide show
  1. package/dist/{Alarm-B0ODr1NE.mjs → Alarm-BMEAZo3p.mjs} +261 -159
  2. package/dist/Alarm-BMEAZo3p.mjs.map +1 -0
  3. package/dist/Alarm.d.mts +29 -36
  4. package/dist/Alarm.mjs +2 -2
  5. package/dist/BrowserCredentials-C5IWfi7f.d.mts +91 -0
  6. package/dist/BrowserCredentials.d.mts +2 -91
  7. package/dist/BrowserRestCapture.mjs +3 -3
  8. package/dist/BrowserRestCapture.mjs.map +1 -1
  9. package/dist/BrowserRestCrawl.mjs +6 -6
  10. package/dist/BrowserRestCrawl.mjs.map +1 -1
  11. package/dist/{BrowserSession-RfIzxGCH.mjs → BrowserSession-BfNmyayH.mjs} +5 -5
  12. package/dist/BrowserSession-BfNmyayH.mjs.map +1 -0
  13. package/dist/{BrowserSession-B969Xg-2.d.mts → BrowserSession-Bx0V1-6_.d.mts} +6 -3
  14. package/dist/BrowserSession.d.mts +1 -1
  15. package/dist/BrowserSession.mjs +2 -2
  16. package/dist/BrowserUse-Bc2JdLW2.mjs +1528 -0
  17. package/dist/BrowserUse-Bc2JdLW2.mjs.map +1 -0
  18. package/dist/BrowserUse.d.mts +83 -0
  19. package/dist/BrowserUse.mjs +2 -0
  20. package/dist/CloudflareBindings.d.mts +8 -1
  21. package/dist/CloudflareBindings.mjs +2 -2
  22. package/dist/CloudflareBindings.mjs.map +1 -1
  23. package/dist/{CloudflareBrowser-5an6m-Qb.mjs → CloudflareBrowser-Vt8qTdYW.mjs} +11 -13
  24. package/dist/CloudflareBrowser-Vt8qTdYW.mjs.map +1 -0
  25. package/dist/CloudflareBrowser.mjs +1 -1
  26. package/dist/CloudflareCodeMode.mjs +1 -1
  27. package/dist/CloudflareCodeMode.mjs.map +1 -1
  28. package/dist/{CloudflareConfig-qDrRLofL.d.mts → CloudflareConfig-C9MvPbX8.d.mts} +9 -11
  29. package/dist/CloudflareConfig.d.mts +1 -1
  30. package/dist/CloudflareConfig.mjs +9 -12
  31. package/dist/CloudflareConfig.mjs.map +1 -1
  32. package/dist/CloudflareMemory.d.mts +3 -25
  33. package/dist/CloudflareMemory.mjs +33 -31
  34. package/dist/CloudflareMemory.mjs.map +1 -1
  35. package/dist/CloudflareScheduling.mjs +8 -15
  36. package/dist/CloudflareScheduling.mjs.map +1 -1
  37. package/dist/CloudflareSubscriptions.mjs +9 -16
  38. package/dist/CloudflareSubscriptions.mjs.map +1 -1
  39. package/dist/CloudflareThreadClient-CLZpN9zU.mjs +588 -0
  40. package/dist/CloudflareThreadClient-CLZpN9zU.mjs.map +1 -0
  41. package/dist/CloudflareThreadClient-QsVzLGGZ.d.mts +2033 -0
  42. package/dist/CloudflareThreadClient.d.mts +2 -1796
  43. package/dist/CloudflareThreadClient.mjs +2 -382
  44. package/dist/{InteractiveBrowser-BbG3kGA9.mjs → InteractiveBrowser-LdKzQeLR.mjs} +18 -19
  45. package/dist/InteractiveBrowser-LdKzQeLR.mjs.map +1 -0
  46. package/dist/InteractiveBrowser.mjs +1 -1
  47. package/dist/{ThreadObject-BcfXbzSO.d.mts → ThreadObject-7s5XnlH-.d.mts} +103 -79
  48. package/dist/{ThreadObject-DHjrnlX4.mjs → ThreadObject-CgXZMlr4.mjs} +265 -66
  49. package/dist/ThreadObject-CgXZMlr4.mjs.map +1 -0
  50. package/dist/ThreadObject.d.mts +2 -2
  51. package/dist/ThreadObject.mjs +2 -3
  52. package/dist/WakeScheduler.d.mts +6 -5
  53. package/dist/WakeScheduler.mjs +15 -11
  54. package/dist/WakeScheduler.mjs.map +1 -1
  55. package/dist/index.d.mts +7 -6
  56. package/dist/index.mjs +7 -6
  57. package/dist/page-function-CmUCcyNP.mjs +11 -0
  58. package/dist/page-function-CmUCcyNP.mjs.map +1 -0
  59. package/dist/{prepared-admission-DMX5p9dC.mjs → prepared-admission-B61A7y6O.mjs} +3 -3
  60. package/dist/{prepared-admission-DMX5p9dC.mjs.map → prepared-admission-B61A7y6O.mjs.map} +1 -1
  61. package/package.json +1 -1
  62. package/src/Alarm.ts +512 -279
  63. package/src/BrowserRestCapture.ts +2 -2
  64. package/src/BrowserRestCrawl.ts +10 -14
  65. package/src/BrowserSession.ts +10 -2
  66. package/src/BrowserUse.ts +1591 -0
  67. package/src/CloudflareBindings.ts +13 -4
  68. package/src/CloudflareCodeMode.ts +1 -1
  69. package/src/CloudflareConfig.ts +9 -12
  70. package/src/CloudflareMemory.ts +21 -28
  71. package/src/CloudflareScheduling.ts +7 -15
  72. package/src/CloudflareSubscriptions.ts +11 -20
  73. package/src/CloudflareThreadClient.ts +289 -9
  74. package/src/InteractiveBrowser.ts +325 -323
  75. package/src/ThreadObject.ts +172 -52
  76. package/src/WakeScheduler.ts +29 -18
  77. package/src/index.ts +1 -0
  78. package/src/internal/browser-dom.ts +886 -0
  79. package/src/internal/browser-file-selection.ts +8 -1
  80. package/src/internal/browser-jev-dom.ts +362 -0
  81. package/src/internal/browser-quick-action.ts +7 -8
  82. package/src/internal/browser-session-lifecycle.ts +2 -5
  83. package/src/internal/crypto.ts +41 -0
  84. package/src/internal/due-queue.ts +5 -69
  85. package/src/internal/layers.ts +100 -17
  86. package/src/internal/live-text-protocol.ts +51 -0
  87. package/src/internal/live-text.ts +256 -0
  88. package/src/internal/page-function.ts +12 -0
  89. package/src/internal/prepared-admission.ts +1 -1
  90. package/src/internal/progress-wait.ts +19 -24
  91. package/src/internal/transport.ts +1 -1
  92. package/dist/Alarm-B0ODr1NE.mjs.map +0 -1
  93. package/dist/BrowserSession-RfIzxGCH.mjs.map +0 -1
  94. package/dist/CloudflareBrowser-5an6m-Qb.mjs.map +0 -1
  95. package/dist/CloudflareThreadClient.mjs.map +0 -1
  96. package/dist/InteractiveBrowser-BbG3kGA9.mjs.map +0 -1
  97. package/dist/ThreadObject-DHjrnlX4.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserUse-Bc2JdLW2.mjs","names":[],"sources":["../src/internal/browser-dom.ts","../src/internal/browser-jev-dom.ts","../src/BrowserUse.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\n\nimport type { Control } from \"@yielded/agent/browser-use\";\n\nimport { pageFunction } from \"./page-function.ts\";\n\n/** Executor-owned input settling, matching jev-ultrafast's frame/option readiness predicate. */\nexport const settleInputDom = pageFunction(\n (ref: string | undefined) =>\n new Promise<void>((resolve) => {\n const field: Element | undefined =\n ref === undefined\n ? undefined\n : Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(ref);\n\n const autocomplete = field?.getAttribute(\"role\") === \"combobox\";\n let frames = 0;\n let stopped = false;\n let animation = 0;\n\n const finish = () => {\n if (stopped) return;\n stopped = true;\n clearTimeout(deadline);\n cancelAnimationFrame(animation);\n resolve();\n };\n\n const deadline = setTimeout(finish, autocomplete ? 200 : 50);\n\n const ready = () => {\n if (stopped) return;\n\n const ids = (field?.getAttribute(\"aria-controls\") || field?.getAttribute(\"aria-owns\") || \"\")\n .split(/\\s+/)\n .filter(Boolean);\n\n const roots = ids.length ? ids.map((id) => document.getElementById(id)) : [document];\n\n const options = roots.flatMap((root) => [\n ...(root?.querySelectorAll('[role=\"option\"]') ?? []),\n ]);\n\n if (\n ++frames >= 2 &&\n (!autocomplete ||\n options.some((element) => {\n const rect = element.getBoundingClientRect();\n\n return (\n rect.width &&\n rect.height &&\n rect.bottom > 0 &&\n rect.top < innerHeight &&\n element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true })\n );\n }))\n )\n finish();\n else animation = requestAnimationFrame(ready);\n };\n\n animation = requestAnimationFrame(ready);\n }),\n);\n\n/** Read-only executor settling: 100 ms without a DOM mutation, bounded by one second. */\nexport const settleDom = pageFunction(\n () =>\n new Promise<boolean>((resolve) => {\n let quiet: ReturnType<typeof setTimeout>;\n\n const observer = new MutationObserver(() => {\n clearTimeout(quiet);\n quiet = setTimeout(() => finish(true), 100);\n });\n\n const finish = (settled: boolean) => {\n observer.disconnect();\n clearTimeout(quiet);\n clearTimeout(deadline);\n resolve(settled);\n };\n\n const deadline = setTimeout(() => finish(false), 1_000);\n\n observer.observe(document, {\n subtree: true,\n childList: true,\n attributes: true,\n characterData: true,\n });\n quiet = setTimeout(() => finish(true), 100);\n }),\n);\n\n/** Executed in the isolated page realm; the page cannot forge the reference registry. */\nexport const inspectDom = pageFunction(\n (\n selector: string | undefined,\n prefix: string,\n maximum: number,\n optionFilter: string | undefined,\n viewportOnly = false,\n ) => {\n const registry = new Map<string, Element>();\n\n const nameChecks = new Map<\n string,\n { name: string; originalName: string; verify: () => boolean }\n >();\n\n Reflect.set(globalThis, \"@effect-agent/native-browser\", registry);\n Reflect.set(globalThis, \"@effect-agent/native-browser-name-checks\", nameChecks);\n const roots: Array<Document | ShadowRoot> = [document];\n\n const closedRoots: ReadonlyMap<Element, ShadowRoot> | undefined = Reflect.get(\n globalThis,\n \"@effect-agent/native-browser-closed-roots\",\n );\n\n const visited = new Set<Node>();\n let discoveredElements = 0;\n const candidates: Array<HTMLElement> = [];\n let scanned = 0;\n let truncated = false;\n let text = \"\";\n\n const controlSelector =\n 'button,a[href],input,textarea,select,label,[contenteditable=\"true\"],[role=\"button\"],[role=\"link\"],[role=\"checkbox\"],[role=\"radio\"],[role=\"switch\"],[role=\"tab\"],[role=\"option\"],[role=\"combobox\"],[role=\"textbox\"],[role=\"menuitem\"],[role=\"scrollbar\"]';\n\n const filter: NodeFilter = {\n acceptNode(node) {\n if (!(node instanceof Element)) return NodeFilter.FILTER_ACCEPT;\n const style = getComputedStyle(node);\n\n return node.matches('script,style,template,option,optgroup,[inert],[aria-hidden=\"true\"]') ||\n style.display === \"none\" ||\n style.opacity === \"0\" ||\n style.contentVisibility === \"hidden\"\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_ACCEPT;\n },\n };\n\n for (let index = 0; index < roots.length && !truncated; index++) {\n const root = roots[index];\n\n if (root === undefined) break;\n\n // Narrow inspection starts at matching roots, so unrelated page content\n // cannot exhaust its budget. Shadow-host discovery has a separate bound.\n if (selector !== undefined) {\n const discovery = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, filter);\n let node = discovery.nextNode();\n\n while (node !== null) {\n if (++discoveredElements > 10_000) {\n truncated = true;\n break;\n }\n if (node instanceof Element) {\n const shadow = node.shadowRoot ?? closedRoots?.get(node);\n\n if (shadow !== undefined && shadow !== null) roots.push(shadow);\n }\n node = discovery.nextNode();\n }\n }\n const matches = selector === undefined ? [root] : Array.from(root.querySelectorAll(selector));\n const scopes = matches.slice(0, 256);\n const nodes: Array<Element> = [];\n\n truncated ||= matches.length > scopes.length;\n for (const scope of scopes) {\n if (scope instanceof Element && filter.acceptNode(scope) === NodeFilter.FILTER_REJECT)\n continue;\n\n const walker = document.createTreeWalker(\n scope,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,\n filter,\n );\n\n let node: Node | null = scope instanceof Element ? scope : walker.nextNode();\n\n while (node !== null) {\n if (visited.has(node)) {\n node = walker.nextNode();\n continue;\n }\n visited.add(node);\n if (++scanned > 10_000) {\n truncated = true;\n break;\n }\n if (node instanceof Element) {\n nodes.push(node);\n const shadow = node.shadowRoot ?? closedRoots?.get(node);\n\n if (selector === undefined && shadow !== undefined && shadow !== null)\n roots.push(shadow);\n } else if (node instanceof Text) {\n const parent = node.parentElement;\n\n // Select options have their own bounded lookup; collapsed option text\n // must not bury the current form's values and validation messages.\n if (\n parent instanceof HTMLElement &&\n parent.closest('select,script,style,[inert],[aria-hidden=\"true\"]') === null &&\n parent.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true })\n ) {\n const value = node.textContent?.replace(/\\s+/g, \" \").trim() ?? \"\";\n\n if (value.length > 0) {\n const room = Math.max(0, 12_000 - text.length);\n\n text += `${value.slice(0, room)}\\n`;\n truncated ||= value.length >= room;\n }\n }\n }\n node = walker.nextNode();\n }\n if (scanned > 10_000) break;\n }\n for (const node of nodes) {\n if (selector !== undefined && !node.matches(selector) && node.closest(selector) === null)\n continue;\n if (!(node instanceof HTMLElement)) continue;\n\n const scrollable =\n node.scrollHeight > node.clientHeight &&\n [\"auto\", \"scroll\"].includes(getComputedStyle(node).overflowY);\n\n if (!node.matches(controlSelector) && !scrollable) continue;\n if (\n !node.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) ||\n node.closest('[inert],[aria-hidden=\"true\"]') !== null\n )\n continue;\n const modal = document.querySelector(\"dialog:modal\");\n\n if (modal !== null && !modal.contains(node) && node.getRootNode() === document) continue;\n candidates.push(node);\n }\n }\n\n let retained = candidates;\n\n // A popup falls back to off-screen controls only when none of its controls\n // are in view. Do not restore an entire off-screen calendar beside visible days.\n if (viewportOnly || candidates.length > maximum) {\n const visible: Array<HTMLElement> = [];\n const popupControls = new Map<Element, Array<HTMLElement>>();\n const visiblePopups = new Set<Element>();\n const offscreen: Array<HTMLElement> = [];\n\n const popupSelector =\n 'dialog[open],[role=\"dialog\"],[role=\"listbox\"],[role=\"menu\"],:popover-open';\n\n for (const node of candidates) {\n const rect = node.getBoundingClientRect();\n const x = rect.x + rect.width / 2;\n const y = rect.y + rect.height / 2;\n\n const inView = x >= 0 && x < innerWidth && y >= 0 && y < innerHeight;\n\n if (viewportOnly) {\n let popup = node.closest(popupSelector);\n\n if (popup?.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true })) {\n if (!inView) {\n const group = popupControls.get(popup) ?? [];\n\n group.push(node);\n popupControls.set(popup, group);\n continue;\n }\n while (popup !== null) {\n visiblePopups.add(popup);\n popup = popup.parentElement?.closest(popupSelector) ?? null;\n }\n }\n }\n (inView ? visible : offscreen).push(node);\n }\n\n const preferred = [\n ...visible,\n ...[...popupControls].flatMap(([popup, nodes]) => (visiblePopups.has(popup) ? [] : nodes)),\n ];\n\n retained = (\n viewportOnly ? (preferred.length > 0 ? preferred : offscreen) : [...visible, ...offscreen]\n ).slice(0, maximum);\n truncated ||= candidates.length > retained.length;\n }\n\n const readName = (node: HTMLElement) => {\n const associated = node instanceof HTMLLabelElement ? (node.control ?? node) : node;\n\n const nativeField =\n associated instanceof HTMLInputElement ||\n associated instanceof HTMLTextAreaElement ||\n associated instanceof HTMLSelectElement;\n\n const labels = nativeField ? associated.labels : null;\n const root = node.getRootNode();\n\n const labelledBy = (node.getAttribute(\"aria-labelledby\") ?? \"\")\n .split(/\\s+/)\n .map((id) =>\n root instanceof Document || root instanceof ShadowRoot\n ? (root.getElementById(id)?.textContent ?? \"\")\n : \"\",\n )\n .join(\" \");\n\n return (\n node.getAttribute(\"aria-label\") ||\n labelledBy.trim() ||\n (labels === null\n ? \"\"\n : Array.from(labels)\n .map((label) => label.textContent)\n .join(\" \")) ||\n (nativeField\n ? node.getAttribute(\"placeholder\")\n : node instanceof HTMLElement\n ? node.innerText\n : \"\") ||\n \"\"\n )\n .replace(/\\s+/g, \" \")\n .trim()\n .slice(0, 300);\n };\n\n const controls = retained.map((node, index) => {\n const ref = `${prefix}-${index}`;\n const tag = node.tagName.toLowerCase();\n const associated = node instanceof HTMLLabelElement ? (node.control ?? node) : node;\n const type = associated instanceof HTMLInputElement ? associated.type : \"\";\n\n const nativeField =\n associated instanceof HTMLInputElement ||\n associated instanceof HTMLTextAreaElement ||\n associated instanceof HTMLSelectElement;\n\n const role = node.getAttribute(\"role\");\n\n const kind =\n tag === \"label\" &&\n associated instanceof HTMLInputElement &&\n [\"checkbox\", \"radio\"].includes(type)\n ? type\n : (role ?? (type === \"checkbox\" || type === \"radio\" ? type : tag === \"a\" ? \"link\" : tag));\n\n const name = readName(node);\n\n const allOptions = node instanceof HTMLSelectElement ? Array.from(node.options) : [];\n\n const matchingOptions = allOptions.flatMap((option, index) =>\n option.selected ||\n optionFilter === undefined ||\n `${option.label}\\n${option.value}`.toLowerCase().includes(optionFilter.toLowerCase())\n ? [{ option, index }]\n : [],\n );\n\n // Keep selected state even when it falls beyond the bounded lookup window.\n const selectedOptions = matchingOptions.filter(({ option }) => option.selected);\n\n const visibleOptions = [\n ...selectedOptions.slice(0, 256),\n ...matchingOptions\n .filter(({ option }) => !option.selected)\n .slice(0, Math.max(0, 256 - selectedOptions.length)),\n ];\n\n if (matchingOptions.length > visibleOptions.length) truncated = true;\n\n const attributes = Object.fromEntries(\n [\n \"id\",\n \"name\",\n \"type\",\n \"role\",\n \"tabindex\",\n \"placeholder\",\n \"aria-label\",\n \"aria-labelledby\",\n \"aria-expanded\",\n \"aria-selected\",\n \"aria-checked\",\n \"aria-controls\",\n \"href\",\n ].flatMap((key) => {\n const value = node.getAttribute(key);\n\n return value === null ? [] : [[key, value.slice(0, 1_024)]];\n }),\n );\n\n registry.set(ref, node);\n nameChecks.set(ref, {\n name,\n originalName: name,\n verify: () => readName(node) === name,\n });\n const pointerEvents = getComputedStyle(node).pointerEvents?.slice(0, 64);\n\n return {\n ref,\n kind,\n name,\n attributes,\n ...(pointerEvents ? { pointerEvents } : {}),\n value:\n nativeField && type !== \"password\"\n ? associated.value.slice(0, 4_096)\n : node.isContentEditable\n ? node.innerText.slice(0, 4_096)\n : \"\",\n options: visibleOptions.map(({ option }) => option.value.slice(0, 4_096)),\n ...(node instanceof HTMLSelectElement\n ? {\n optionCount: allOptions.length,\n optionDetails: visibleOptions.map(({ option, index }) => ({\n index,\n value: option.value.slice(0, 4096),\n label: option.label.slice(0, 300),\n disabled:\n option.disabled ||\n (option.parentElement instanceof HTMLOptGroupElement &&\n option.parentElement.disabled),\n selected: option.selected,\n })),\n }\n : {}),\n disabled:\n associated.matches(\":disabled\") || associated.getAttribute(\"aria-disabled\") === \"true\",\n editable:\n (node instanceof HTMLInputElement &&\n !node.readOnly &&\n ![\"password\", \"file\", \"checkbox\", \"radio\", \"hidden\", \"submit\", \"button\"].includes(\n node.type,\n )) ||\n (node instanceof HTMLTextAreaElement && !node.readOnly) ||\n (node.isContentEditable && node.getAttribute(\"aria-readonly\") !== \"true\"),\n ...(associated instanceof HTMLInputElement && (type === \"checkbox\" || type === \"radio\")\n ? { checked: associated.checked }\n : {}),\n };\n });\n\n const names = new Map<string, number>();\n\n for (const control of controls) names.set(control.name, (names.get(control.name) ?? 0) + 1);\n\n const explicitLabel = (node: Element) => {\n const root = node.getRootNode();\n\n return (\n node.getAttribute(\"aria-label\") ||\n (node.getAttribute(\"aria-labelledby\") ?? \"\")\n .split(/\\s+/)\n .map((id) =>\n root instanceof Document || root instanceof ShadowRoot\n ? (root.getElementById(id)?.textContent ?? \"\")\n : \"\",\n )\n .join(\" \")\n )\n .replace(/\\s+/g, \" \")\n .trim();\n };\n\n for (const [index, control] of controls.entries()) {\n const node = retained[index];\n\n if (node === undefined || control.name.length === 0 || (names.get(control.name) ?? 0) < 2)\n continue;\n let branch: Element = node;\n\n for (let scope = node.parentElement; scope !== null; scope = scope.parentElement) {\n let source: Element | undefined = explicitLabel(scope) ? scope : undefined;\n let read = () => (source === undefined ? \"\" : explicitLabel(source));\n\n if (source === undefined) {\n for (\n let previous = branch.previousElementSibling;\n previous !== null;\n previous = previous.previousElementSibling\n ) {\n if (\n !(previous instanceof HTMLElement) ||\n !previous.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) ||\n previous.closest('[inert],[aria-hidden=\"true\"]') !== null ||\n previous.matches(controlSelector) ||\n previous.querySelector(controlSelector) !== null ||\n (previous.childElementCount > 0 &&\n !previous.matches('h1,h2,h3,h4,h5,h6,caption,figcaption,legend,[role=\"heading\"]'))\n )\n continue;\n const caption = previous.innerText.replace(/\\s+/g, \" \").trim();\n\n // Short static leaf text also serves as a caption in unlabelled containers.\n if (caption.length === 0 || caption.length > 120) continue;\n source = previous;\n const captionElement = previous;\n\n read = () => captionElement.innerText.replace(/\\s+/g, \" \").trim();\n break;\n }\n }\n const context = read();\n\n if (source !== undefined && context.length > 0) {\n const originalName = control.name;\n const container = scope;\n const caption = source;\n\n control.name = `${originalName} (${context})`.slice(0, 300);\n // Keep raw-name and contextual identity checks in the isolated realm.\n // Presentation must not weaken the existing native dispatch guard.\n nameChecks.set(control.ref, {\n name: control.name,\n originalName,\n verify: () =>\n readName(node) === originalName &&\n container.isConnected &&\n container.contains(node) &&\n container.contains(caption) &&\n (caption === container ||\n (caption.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) &&\n read() === context,\n });\n break;\n }\n branch = scope;\n }\n }\n\n return {\n text: text.slice(0, 12_000),\n controls,\n readyState: document.readyState,\n truncated: truncated || text.length > 12_000,\n };\n },\n);\n\n/** Current state after standard DOM scrolling. Pointer actions also require a hit test;\n * keyboard actions verify native focus at dispatch instead. Never dispatches input.\n */\nexport const checkDom = pageFunction(\n (target: Element | string, expected: typeof Control.Type, scroll: boolean, pointer: boolean) => {\n // A ref is looked up in this realm's registry, saving a handle round trip each way.\n const node: unknown =\n typeof target === \"string\"\n ? Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(target)\n : target;\n\n if (!(node instanceof HTMLElement) || !node.isConnected) return false;\n\n const nameCheck:\n | {\n name: string;\n originalName: string;\n kind?: string;\n viewport?: boolean;\n verify: () => boolean;\n }\n | undefined = Reflect.get(globalThis, \"@effect-agent/native-browser-name-checks\")?.get(\n expected.ref,\n );\n\n if (nameCheck !== undefined && (nameCheck.name !== expected.name || !nameCheck.verify()))\n return false;\n // Jev refs require their centers to remain in view. Do not move a visible\n // form or popup just to prepare input; the same native hit test still applies.\n if (scroll && !nameCheck?.viewport)\n node.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" });\n const associated = node instanceof HTMLLabelElement ? (node.control ?? node) : node;\n const type = associated instanceof HTMLInputElement ? associated.type : \"\";\n\n if (\n associated instanceof HTMLSelectElement &&\n expected.optionDetails !== undefined &&\n ((expected.optionCount === undefined\n ? expected.optionDetails.length\n : expected.optionCount) !== associated.options.length ||\n expected.optionDetails.some((option, index) => {\n const current = associated.options.item(option.index ?? index);\n\n return (\n current === null ||\n current.value !== option.value ||\n current.label.slice(0, 300) !== option.label ||\n current.selected !== option.selected ||\n (current.disabled ||\n (current.parentElement instanceof HTMLOptGroupElement &&\n current.parentElement.disabled)) !== option.disabled\n );\n }))\n )\n return false;\n if (node.isContentEditable && node.innerText.slice(0, 4_096) !== expected.value) return false;\n\n const kind =\n nameCheck?.kind ??\n (node instanceof HTMLLabelElement &&\n associated instanceof HTMLInputElement &&\n [\"checkbox\", \"radio\"].includes(type)\n ? type\n : (node.getAttribute(\"role\") ??\n (type === \"checkbox\" || type === \"radio\"\n ? type\n : node.tagName === \"A\"\n ? \"link\"\n : node.tagName.toLowerCase())));\n\n if (\n kind !== expected.kind ||\n associated.matches(\":disabled\") ||\n associated.getAttribute(\"aria-disabled\") === \"true\" ||\n !node.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true })\n )\n return false;\n if (\n (associated instanceof HTMLInputElement ||\n associated instanceof HTMLTextAreaElement ||\n associated instanceof HTMLSelectElement) &&\n type !== \"password\" &&\n associated.value.slice(0, 4_096) !== expected.value\n )\n return false;\n if (\n !(\n associated instanceof HTMLInputElement ||\n associated instanceof HTMLTextAreaElement ||\n associated instanceof HTMLSelectElement\n ) &&\n !node.isContentEditable &&\n !node.hasAttribute(\"aria-label\") &&\n !node.hasAttribute(\"aria-labelledby\") &&\n node.innerText.replace(/\\s+/g, \" \").trim().slice(0, 300) !==\n (nameCheck?.originalName ?? expected.name)\n )\n return false;\n if (\n expected.checked !== undefined &&\n (!(associated instanceof HTMLInputElement) || associated.checked !== expected.checked)\n )\n return false;\n if (\n Object.entries(expected.attributes ?? {}).some(\n ([key, value]) => (node.getAttribute(key) ?? \"\").slice(0, 1_024) !== value,\n )\n )\n return false;\n const ancestors = new Set<Node>();\n let ancestor: Node | null = node;\n\n while (ancestor !== null) {\n if (ancestor instanceof Element && ancestor.matches('[inert],[aria-hidden=\"true\"]'))\n return false;\n ancestors.add(ancestor);\n ancestor = ancestor instanceof ShadowRoot ? ancestor.host : ancestor.parentNode;\n }\n\n const modalSelector =\n 'dialog:modal,[role=\"dialog\"][aria-modal=\"true\"],[role=\"alertdialog\"][aria-modal=\"true\"]';\n\n const roots = new Set([document, node.getRootNode()]);\n\n for (const root of roots) {\n if (!(root instanceof Document || root instanceof ShadowRoot)) continue;\n for (const modal of root.querySelectorAll(modalSelector)) {\n if (\n !(modal instanceof HTMLElement) ||\n ancestors.has(modal) ||\n !modal.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true })\n )\n continue;\n const box = modal.getBoundingClientRect();\n\n // An ARIA modal without an on-screen box, such as a collapsed cart drawer, covers\n // nothing; the hit test below still refuses anything an open overlay obstructs.\n if (\n modal.matches(\"dialog:modal\") ||\n (box.width > 0 &&\n box.height > 0 &&\n box.right > 0 &&\n box.bottom > 0 &&\n box.left < innerWidth &&\n box.top < innerHeight)\n )\n return false;\n }\n }\n const rect = node.getBoundingClientRect();\n\n const x =\n Math.max(0, rect.left) + (Math.min(innerWidth, rect.right) - Math.max(0, rect.left)) / 2;\n\n const y =\n Math.max(0, rect.top) + (Math.min(innerHeight, rect.bottom) - Math.max(0, rect.top)) / 2;\n\n let hit = document.elementFromPoint(x, y);\n\n while (hit !== null && hit !== node && !node.contains(hit)) {\n const shadow: ShadowRoot | undefined | null =\n hit.shadowRoot ??\n Reflect.get(globalThis, \"@effect-agent/native-browser-closed-roots\")?.get(hit);\n\n if (shadow === undefined || shadow === null) break;\n const next = shadow.elementFromPoint(x, y);\n\n if (next === null || next === hit) break;\n hit = next;\n }\n\n // Keyboard-only overlays can sit above sibling card content. Require that\n // containing element to remain unobstructed, then verify native focus at dispatch.\n // This never permits a pointer click through the overlay.\n return rect.width > 0 &&\n rect.height > 0 &&\n node.isConnected &&\n (hit === node ||\n (hit !== null &&\n (node.contains(hit) ||\n (!pointer &&\n node.tabIndex >= 0 &&\n getComputedStyle(node).pointerEvents === \"none\" &&\n node.parentElement?.contains(hit)))))\n ? { x, y }\n : false;\n },\n);\n\n/** Translate a checked child point and refuse input through hidden/covered frame owners. */\nexport const checkFrameDom = pageFunction(\n async (node: Element, point: { x: number; y: number }, scroll: boolean) => {\n if (\n !(node instanceof HTMLElement) ||\n !node.isConnected ||\n !node.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true })\n )\n return false;\n if (scroll) {\n node.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" });\n // Input into an out-of-process frame is routed by the compositor's last frame, not by\n // live layout. Let a frame with the new scroll position render before input follows.\n await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));\n }\n const style = getComputedStyle(node);\n\n // The bounding rect already includes translations. Anything that scales, rotates, skews or\n // projects the frame needs a native geometry adapter; never guess.\n let ancestor: Element | null = node;\n\n while (ancestor !== null) {\n const current = getComputedStyle(ancestor);\n\n const matrix = new DOMMatrixReadOnly(\n current.transform === \"none\" ? undefined : current.transform,\n );\n\n if (\n ancestor.matches('[inert],[aria-hidden=\"true\"]') ||\n !(\n matrix.m11 === 1 &&\n matrix.m12 === 0 &&\n matrix.m13 === 0 &&\n matrix.m14 === 0 &&\n matrix.m21 === 0 &&\n matrix.m22 === 1 &&\n matrix.m23 === 0 &&\n matrix.m24 === 0 &&\n matrix.m31 === 0 &&\n matrix.m32 === 0 &&\n matrix.m33 === 1 &&\n matrix.m34 === 0 &&\n matrix.m44 === 1\n ) ||\n current.perspective !== \"none\" ||\n // Individual scale, rotate and motion-path properties apply outside `transform`.\n current.scale !== \"none\" ||\n current.rotate !== \"none\" ||\n current.offsetPath !== \"none\" ||\n (current.zoom !== \"1\" && current.zoom !== \"normal\")\n )\n return false;\n const root = ancestor.getRootNode();\n\n ancestor = ancestor.parentElement ?? (root instanceof ShadowRoot ? root.host : null);\n }\n const rect = node.getBoundingClientRect();\n\n const x =\n rect.left + parseFloat(style.borderLeftWidth) + parseFloat(style.paddingLeft) + point.x;\n\n const y = rect.top + parseFloat(style.borderTopWidth) + parseFloat(style.paddingTop) + point.y;\n let hit = document.elementFromPoint(x, y);\n\n while (hit !== null && hit !== node && !node.contains(hit)) {\n const shadow: ShadowRoot | undefined | null =\n hit.shadowRoot ??\n Reflect.get(globalThis, \"@effect-agent/native-browser-closed-roots\")?.get(hit);\n\n if (shadow === undefined || shadow === null) break;\n const next = shadow.elementFromPoint(x, y);\n\n if (next === null || next === hit) break;\n hit = next;\n }\n\n return hit === node ? { x, y } : false;\n },\n);\n\nexport const waitDom = pageFunction((selector: string, state: string, text: string | undefined) => {\n const roots: Array<Document | ShadowRoot> = [document];\n\n const closedRoots: ReadonlyMap<Element, ShadowRoot> | undefined = Reflect.get(\n globalThis,\n \"@effect-agent/native-browser-closed-roots\",\n );\n\n const expectedText = text?.replace(/\\s+/g, \" \").trim();\n let scanned = 0;\n\n for (let index = 0; index < roots.length; index++) {\n const root = roots[index];\n\n if (root === undefined) break;\n\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node) {\n if (!(node instanceof Element)) return NodeFilter.FILTER_ACCEPT;\n const style = getComputedStyle(node);\n\n return node.matches('script,style,template,option,optgroup,[inert],[aria-hidden=\"true\"]') ||\n style.display === \"none\" ||\n style.opacity === \"0\" ||\n style.contentVisibility === \"hidden\"\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_ACCEPT;\n },\n });\n\n let node = walker.nextNode();\n\n while (node !== null) {\n if (++scanned > 10_000) return false;\n if (node instanceof Element) {\n const shadow = node.shadowRoot ?? closedRoots?.get(node);\n\n if (shadow !== undefined && shadow !== null) roots.push(shadow);\n if (\n node instanceof HTMLElement &&\n node.matches(selector) &&\n node.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&\n (expectedText === undefined ||\n node.innerText.replace(/\\s+/g, \" \").trim().includes(expectedText))\n ) {\n if (state === \"hidden\") return false;\n if (\n state === \"visible\" ||\n (state === \"enabled\" &&\n !node.matches(\":disabled\") &&\n node.getAttribute(\"aria-disabled\") !== \"true\") ||\n (state === \"text\" && text !== undefined)\n )\n return true;\n }\n }\n node = walker.nextNode();\n }\n }\n\n return state === \"hidden\";\n});\n","/// <reference lib=\"dom\" />\n\n/* @license\n * Selection and accessible naming adapted from jev-ultrafast snapshot.js at 1231850.\n * Copyright (c) 2026 Browser Use\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport type { Control } from \"@yielded/agent/browser-use\";\n\nimport { pageFunction } from \"./page-function.ts\";\n\n/** Isolated-realm Jev observation. The same private refs and native guards own input. */\nexport const inspectJevDom = pageFunction(\n (\n selector: string | undefined,\n prefix: string,\n maximum: number,\n optionFilter: string | undefined,\n ) => {\n const registry = new Map<string, Element>();\n\n const checks = new Map<\n string,\n { name: string; originalName: string; kind: string; viewport: boolean; verify: () => boolean }\n >();\n\n Reflect.set(globalThis, \"@effect-agent/native-browser\", registry);\n Reflect.set(globalThis, \"@effect-agent/native-browser-name-checks\", checks);\n\n const visible = (node: Element) => {\n let ancestor: Element | null = node;\n\n while (ancestor !== null) {\n if (ancestor.matches('[aria-hidden=\"true\"],[inert]')) return false;\n const root = ancestor.getRootNode();\n\n ancestor = ancestor.parentElement ?? (root instanceof ShadowRoot ? root.host : null);\n }\n\n return node.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true });\n };\n\n const inView = (node: Element) => {\n const rect = node.getBoundingClientRect();\n const x = rect.x + rect.width / 2;\n const y = rect.y + rect.height / 2;\n\n return (\n rect.width > 0 && rect.height > 0 && x >= 0 && y >= 0 && x < innerWidth && y < innerHeight\n );\n };\n\n const name = (node: Element | null, seen = new Set<Element>()): string => {\n if (node === null || seen.has(node) || seen.size >= 10_000) return \"\";\n seen.add(node);\n\n const referenced = (node.getAttribute(\"aria-labelledby\") ?? \"\")\n .split(/\\s+/)\n .map((id) => name(document.getElementById(id), seen))\n .filter(Boolean)\n .join(\" \");\n\n const labels =\n node instanceof HTMLInputElement ||\n node instanceof HTMLTextAreaElement ||\n node instanceof HTMLSelectElement\n ? node.labels\n : null;\n\n return (\n referenced ||\n node.getAttribute(\"aria-label\") ||\n Array.from(labels ?? [])\n .map((label) => name(label, seen))\n .filter(Boolean)\n .join(\" \") ||\n (node instanceof HTMLInputElement && [\"button\", \"submit\", \"reset\"].includes(node.type)\n ? node.value\n : \"\") ||\n node.getAttribute(\"alt\") ||\n (node.tagName === \"INPUT\"\n ? \"\"\n : Array.from(node.childNodes)\n .map((child) =>\n child instanceof Text\n ? child.textContent\n : child instanceof Element && child.getAttribute(\"aria-hidden\") !== \"true\"\n ? name(child, seen)\n : \"\",\n )\n .join(\" \")\n .trim()) ||\n node.getAttribute(\"title\") ||\n node.getAttribute(\"placeholder\") ||\n \"\"\n ).slice(0, 4_096);\n };\n\n const roles = [\n \"button\",\n \"link\",\n \"checkbox\",\n \"radio\",\n \"switch\",\n \"tab\",\n \"menuitem\",\n \"menuitemradio\",\n \"option\",\n \"gridcell\",\n \"combobox\",\n \"textbox\",\n \"searchbox\",\n \"spinbutton\",\n ];\n\n const role = (node: HTMLElement) => {\n const explicit = node.getAttribute(\"role\");\n\n if (explicit !== null && roles.includes(explicit)) return explicit;\n if (node.tagName === \"BUTTON\" || node.tagName === \"SUMMARY\") return \"button\";\n if (node.tagName === \"A\") return \"link\";\n if (node instanceof HTMLSelectElement) return \"combobox\";\n if (node instanceof HTMLTextAreaElement || node.isContentEditable) return \"textbox\";\n if (node instanceof HTMLInputElement) {\n if ([\"checkbox\", \"radio\"].includes(node.type)) return node.type;\n if ([\"button\", \"submit\", \"reset\", \"image\"].includes(node.type)) return \"button\";\n if (node.type === \"search\") return \"searchbox\";\n if (node.type === \"number\") return \"spinbutton\";\n if ([\"text\", \"email\", \"url\", \"tel\"].includes(node.type)) return \"textbox\";\n }\n\n return null;\n };\n\n const value = (node: HTMLElement) =>\n (\"value\" in node\n ? String(node.value)\n : node.isContentEditable || role(node) === \"combobox\"\n ? node.innerText.trim()\n : \"\"\n ).slice(0, 4_096);\n\n const readOnly = (node: HTMLElement) =>\n ((node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) &&\n node.readOnly) ||\n node.getAttribute(\"aria-readonly\") === \"true\";\n\n const closedRoots: ReadonlyMap<Element, ShadowRoot> | undefined = Reflect.get(\n globalThis,\n \"@effect-agent/native-browser-closed-roots\",\n );\n\n const candidates = [document, ...(closedRoots?.values() ?? [])].flatMap((root) =>\n Array.from(\n root.querySelectorAll(\n 'a[href],button,input,textarea,select,summary,[contenteditable=\"true\"],' +\n roles.map((role) => `[role=\"${role}\"]`).join(\",\"),\n ),\n ),\n );\n\n const controls: Array<typeof Control.Type> = [];\n let truncated = candidates.length > 10_000;\n // A modal dialog blocks background input; offer only its controls, as default observations do.\n const modal = document.querySelector(\"dialog:modal\");\n\n for (const node of Array.from(candidates).slice(0, 10_000)) {\n if (!(node instanceof HTMLElement)) continue;\n if (selector !== undefined && !node.matches(selector) && node.closest(selector) === null)\n continue;\n if (node instanceof HTMLInputElement && [\"password\", \"file\", \"hidden\"].includes(node.type))\n continue;\n if (\n !visible(node) ||\n !inView(node) ||\n (modal !== null && !modal.contains(node)) ||\n node.matches(\":disabled\") ||\n node.closest('[aria-disabled=\"true\"]')\n )\n continue;\n const kind = role(node);\n\n if (kind === null || (kind === \"gridcell\" && node.querySelector('button,[role=\"button\"]')))\n continue;\n if (controls.length >= maximum) {\n truncated = true;\n break;\n }\n const ref = `${prefix}-${controls.length}`;\n const label = name(node) || kind;\n const currentValue = value(node);\n const readonly = readOnly(node);\n const allOptions = node instanceof HTMLSelectElement ? Array.from(node.options) : [];\n\n const matching = allOptions.flatMap((option, index) =>\n option.selected ||\n optionFilter === undefined ||\n `${option.label}\\n${option.value}`.toLowerCase().includes(optionFilter.toLowerCase())\n ? [{ option, index }]\n : [],\n );\n\n const selected = matching.filter(({ option }) => option.selected);\n\n const options = [\n ...selected.slice(0, 256),\n ...matching\n .filter(({ option }) => !option.selected)\n .slice(0, Math.max(0, 256 - selected.length)),\n ];\n\n truncated ||= matching.length > options.length;\n registry.set(ref, node);\n checks.set(ref, {\n name: label,\n originalName: node.innerText.replace(/\\s+/g, \" \").trim().slice(0, 300),\n kind,\n viewport: true,\n verify: () =>\n role(node) === kind &&\n (name(node) || kind) === label &&\n value(node) === currentValue &&\n readOnly(node) === readonly &&\n node.closest('[aria-disabled=\"true\"]') === null &&\n inView(node),\n });\n controls.push({\n ref,\n kind,\n name: label,\n value: currentValue,\n disabled: false,\n editable:\n !readonly &&\n ([\"textbox\", \"searchbox\", \"spinbutton\"].includes(kind) ||\n (kind === \"combobox\" &&\n (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement))),\n pointerEvents: getComputedStyle(node).pointerEvents.slice(0, 64),\n options: options.map(({ option }) => option.value.slice(0, 4_096)),\n ...(node instanceof HTMLSelectElement\n ? {\n optionCount: allOptions.length,\n optionDetails: options.map(({ option, index }) => ({\n index,\n value: option.value.slice(0, 4_096),\n label: option.label.slice(0, 300),\n selected: option.selected,\n disabled:\n option.disabled ||\n (option.parentElement instanceof HTMLOptGroupElement &&\n option.parentElement.disabled),\n })),\n }\n : {}),\n ...(node instanceof HTMLInputElement && [\"checkbox\", \"radio\"].includes(node.type)\n ? { checked: node.checked }\n : {}),\n attributes: Object.fromEntries(\n [\n \"id\",\n \"name\",\n \"type\",\n \"role\",\n \"tabindex\",\n \"placeholder\",\n \"aria-label\",\n \"aria-labelledby\",\n \"aria-expanded\",\n \"aria-selected\",\n \"aria-checked\",\n \"aria-readonly\",\n \"aria-disabled\",\n \"aria-controls\",\n \"href\",\n ].flatMap((key) => {\n const attribute = node.getAttribute(key);\n\n return attribute === null ? [] : [[key, attribute.slice(0, 1_024)]];\n }),\n ),\n });\n }\n\n const scopes =\n selector === undefined ? [document.body] : Array.from(document.querySelectorAll(selector));\n\n const visited = new Set<Node>();\n const words: Array<string> = [];\n const range = document.createRange();\n let length = 0;\n let scanned = 0;\n\n truncated ||= scopes.length > 256;\n for (const scope of scopes.slice(0, 256)) {\n if (scope === null) continue;\n const walker = document.createTreeWalker(scope, NodeFilter.SHOW_TEXT);\n let node = walker.nextNode();\n\n while (node !== null && length < 6_000 && scanned++ < 10_000) {\n const text = node.textContent?.trim() ?? \"\";\n const parent = node.parentElement;\n\n if (\n !visited.has(node) &&\n text &&\n parent &&\n !parent.closest(\"script,style,noscript,template\") &&\n visible(parent)\n ) {\n range.selectNodeContents(node);\n const rect = range.getBoundingClientRect();\n\n if (\n rect.width > 0 &&\n rect.height > 0 &&\n rect.bottom > 0 &&\n rect.top < innerHeight &&\n rect.right > 0 &&\n rect.left < innerWidth\n ) {\n words.push(text);\n length += text.length;\n }\n }\n visited.add(node);\n node = walker.nextNode();\n }\n }\n const text = words.join(\"\\n\");\n\n return {\n text: text.slice(0, 6_000),\n controls,\n readyState: document.readyState,\n truncated: truncated || text.length > 6_000 || scanned >= 10_000,\n page: {\n title: document.title,\n scrollY,\n viewportHeight: innerHeight,\n documentHeight: document.documentElement.scrollHeight,\n },\n };\n },\n);\n","import {\n type ActOptions,\n type ActionResult,\n type NavigateRequest,\n Action,\n BrowserActions,\n BrowserControl,\n BrowserUseError,\n InspectRequest,\n Observation,\n ScrollRequest,\n WaitRequest,\n type Control,\n DialogRequest,\n PressRequest,\n TabRequest,\n} from \"@yielded/agent/browser-use\";\nimport { InteractiveBrowserTargetUrl } from \"@yielded/agent/interactive-browser\";\nimport { Deferred, Effect, Fiber, Layer, Schema, Semaphore } from \"effect\";\nimport {\n ElementHandle,\n TimeoutError,\n type Frame,\n type Page,\n type Dialog,\n} from \"puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js\";\n\nimport type { BrowserSession } from \"./BrowserSession.ts\";\nimport {\n checkDom,\n checkFrameDom,\n inspectDom,\n settleDom,\n settleInputDom,\n waitDom,\n} from \"./internal/browser-dom.ts\";\nimport { inspectJevDom } from \"./internal/browser-jev-dom.ts\";\n\nexport type Command =\n | { readonly kind: \"observe\" | \"screenshot\" }\n | { readonly kind: \"inspect\"; readonly request: typeof InspectRequest.Type }\n | { readonly kind: \"navigate\"; readonly request: typeof NavigateRequest.Type }\n | { readonly kind: \"scroll\"; readonly request: typeof ScrollRequest.Type }\n | { readonly kind: \"wait\"; readonly request: typeof WaitRequest.Type }\n | { readonly kind: \"select-tab\"; readonly request: typeof TabRequest.Type }\n | { readonly kind: \"respond-dialog\"; readonly request: typeof DialogRequest.Type }\n | {\n readonly kind: \"act\";\n readonly action: Action | ({ readonly kind: \"press\" } & typeof PressRequest.Type);\n };\n\nexport interface Options<R = never> {\n /** Rechecked under the native session lock. The host owns origins, identity and consent. */\n readonly authorize: (\n command: Command,\n context: AuthorizationContext,\n ) => Effect.Effect<void, BrowserUseError, R>;\n readonly maxActions: number;\n readonly maxReturnedBytes: number;\n /** Prefer viewport controls; retain off-screen popups only if none of their controls are in view. Defaults to false. */\n readonly viewportOnly?: boolean;\n /** Jev reads enabled controls centered in the viewport with accessible names and at most 6,000 visible text characters. Defaults to \"default\". */\n readonly observationMode?: \"default\" | \"jev\";\n /** True waits for 100 ms of DOM quiet (at most 1 s). \"input\" waits two frames/50 ms, or visible combobox options/200 ms. Defaults to false. */\n readonly settleAfterAction?: boolean | \"input\";\n /** Cap condition waits and return a fresh observation on a condition timeout. Omit to retain timeout errors. */\n readonly maxWaitMillis?: number;\n}\n\n/** Host-only current SDK metadata. Opaque refs never replace origin or target authority. */\nexport interface AuthorizationContext {\n /** Absent only before the initial attachment read; the host authorizes that attachment. */\n readonly pageUrl?: string;\n readonly frameUrl?: string;\n /** Destination of an observed select-tab command, checked again before selection. */\n readonly tabUrl?: string;\n readonly target?: typeof Control.Type;\n}\n\nconst Limits = Schema.Struct({\n maxActions: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1_000 })),\n maxReturnedBytes: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 8 * 1024 * 1024 })),\n viewportOnly: Schema.Boolean,\n observationMode: Schema.Literals([\"default\", \"jev\"]),\n settleAfterAction: Schema.Union([Schema.Boolean, Schema.Literal(\"input\")]),\n maxWaitMillis: Schema.NullOr(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 15_000 }))),\n});\n\nconst invalid = (message: string) =>\n new BrowserUseError({ code: \"invalid\", message, dispatch: \"not-dispatched\" });\n\n// URL evidence identifies pages; opaque document payloads are not page observations.\n// Authorization and navigation fencing always use the complete native SDK URL.\nconst observedUrl = (url: string): string => {\n const payload = url.startsWith(\"data:\") ? url.indexOf(\",\") : -1;\n\n return payload < 0\n ? url.slice(0, 8_192)\n : `${url.slice(0, Math.min(payload, 256))},[payload omitted]`;\n};\n\n// CDP can resolve closed roots without modifying the page's realm or attachShadow.\n// Keep those nodes in the same isolated realm as native refs and discard old roots per read.\n// The command deadline bounds this full-frame read; the node/root caps below only bound\n// local adoption, not the CDP response size.\nconst discoverClosedRoots = async (frame: Frame): Promise<boolean> => {\n const realm = frame.isolatedRealm();\n\n await using document = await realm.evaluateHandle(() => globalThis.document);\n\n const { node } = await frame.client.send(\"DOM.describeNode\", {\n objectId: document.remoteObject().objectId,\n depth: -1,\n pierce: true,\n });\n\n const pending = [node];\n const roots: Array<number> = [];\n let scanned = 0;\n\n while (pending.length > 0 && scanned++ < 10_000 && roots.length < 256) {\n const current = pending.pop();\n\n if (current === undefined) break;\n if (current.shadowRootType === \"closed\") roots.push(current.backendNodeId);\n pending.push(...(current.children ?? []));\n pending.push(\n ...(current.shadowRoots ?? []).filter((root) => root.shadowRootType !== \"user-agent\"),\n );\n }\n await realm.evaluate(() => {\n Reflect.set(globalThis, \"@effect-agent/native-browser-closed-roots\", new Map());\n });\n for (const id of roots) {\n await using root = await realm.adoptBackendNode(id);\n\n await realm.evaluate((node) => {\n if (!(node instanceof ShadowRoot) || node.mode !== \"closed\")\n throw new Error(\"Closed shadow root is unavailable\");\n Reflect.get(globalThis, \"@effect-agent/native-browser-closed-roots\").set(node.host, node);\n }, root);\n }\n\n return pending.length > 0;\n};\n\n/** One application-neutral controller over an existing scoped native attachment.\n * No allocation, model, provider choice, input retry, or arbitrary page JS is exposed.\n * Reads re-authorize at most five times when page/frame URLs change during authorization.\n * References expire on inspection; outstanding native work retains the session's fencing.\n */\nexport const make = Effect.fnUntraced(function* <R>(\n session: Pick<BrowserSession, \"run\">,\n options: Options<R>,\n) {\n const authorityServices = yield* Effect.context<R>();\n\n const authorize = (command: Command, context: AuthorizationContext) =>\n options.authorize(command, context).pipe(Effect.provideContext(authorityServices));\n\n const limits = yield* Schema.decodeEffect(Limits)({\n maxActions: options.maxActions,\n maxReturnedBytes: options.maxReturnedBytes,\n viewportOnly: options.viewportOnly ?? false,\n observationMode: options.observationMode ?? \"default\",\n settleAfterAction: options.settleAfterAction ?? false,\n maxWaitMillis: options.maxWaitMillis ?? null,\n }).pipe(Effect.mapError(() => invalid(\"Invalid browser controller limits.\")));\n\n const lock = yield* Semaphore.make(1);\n const ownerScope = yield* Effect.scope;\n\n type Dispatch = NonNullable<(typeof ActionResult.Type)[\"dispatch\"]>;\n let pendingInput: { ref: string; fiber: Fiber.Fiber<Dispatch, BrowserUseError> } | undefined;\n let inputPage: Page | undefined;\n let dialogSignal: Deferred.Deferred<void> | undefined;\n let nextInput = 0;\n let lastTabs: NonNullable<(typeof Observation.Type)[\"tabs\"]> = [];\n\n const clearInput = () => {\n pendingInput = undefined;\n dialogSignal = undefined;\n inputPage = undefined;\n };\n\n const targets = new Map<string, { frame: string; control: typeof Control.Type }>();\n const frames = new Set<string>();\n const frameIds = new WeakMap<Frame, string>();\n const tabIds = new WeakMap<Page, string>();\n const tabs = new Map<string, Page>();\n const pendingDialogs = new Map<Page, { ref: string; dialog: Dialog }>();\n\n const listeners = new Map<\n Page,\n { dialog: (dialog: Dialog) => void; popup: (page: Page | null) => void }\n >();\n\n let activePage: Page | undefined;\n let lastNativePage: Page | undefined;\n let nextTab = 0;\n let nextDialog = 0;\n\n const tabId = (page: Page) => {\n let id = tabIds.get(page);\n\n if (id === undefined) {\n id = `t${scopeId}-${nextTab++}`;\n tabIds.set(page, id);\n }\n\n return id;\n };\n\n const attach = (page: Page) => {\n if (listeners.has(page) || listeners.size >= 32) return;\n\n const dialog = (dialog: Dialog) => {\n pendingDialogs.set(page, { ref: `dialog-${scopeId}-${nextDialog++}`, dialog });\n if (page === inputPage && dialogSignal !== undefined)\n Deferred.doneUnsafe(dialogSignal, Effect.void);\n };\n\n const popup = (page: Page | null) => {\n if (page !== null) attach(page);\n };\n\n listeners.set(page, { dialog, popup });\n page.on(\"dialog\", dialog);\n page.on(\"popup\", popup);\n };\n\n yield* Effect.addFinalizer(() =>\n session\n .run(Effect.void, async () => {\n for (const { dialog } of pendingDialogs.values()) {\n try {\n await dialog.dismiss();\n } catch {\n /* The session owner retains cleanup authority. */\n }\n }\n })\n .pipe(\n Effect.ignore,\n Effect.andThen(\n Effect.sync(() => {\n for (const [page, listener] of listeners) {\n page.off(\"dialog\", listener.dialog);\n page.off(\"popup\", listener.popup);\n }\n listeners.clear();\n pendingDialogs.clear();\n tabs.clear();\n activePage = undefined;\n targets.clear();\n frames.clear();\n }),\n ),\n ),\n );\n const scopeId = crypto.getRandomValues(new Uint32Array(2)).join(\"-\");\n let nextFrame = 0;\n\n const frameId = (frame: Frame) => {\n let id = frameIds.get(frame);\n\n if (id === undefined) {\n id = `f${scopeId}-${nextFrame++}`;\n frameIds.set(frame, id);\n }\n\n return id;\n };\n\n const resolveFrame = (page: Page, ref: string) =>\n page.frames().find((frame) => frameIds.get(frame) === ref);\n\n let generation = 0;\n let consumed = 0;\n\n const native = <A>(\n command: Command,\n action: (page: Page, stage: (name: string) => void) => Promise<A>,\n timeoutMillis?: number,\n phase?: \"prepare\" | \"input\" | \"settle\",\n ) =>\n Effect.gen(function* () {\n if (pendingInput !== undefined && phase !== \"input\" && command.kind !== \"respond-dialog\")\n return yield* invalid(\n \"Native input is pending. Inspect and respond to its dialog before another browser operation.\",\n );\n const span = yield* Effect.currentSpan.pipe(Effect.orDie);\n let authorizedUrl: string | undefined;\n let authorizedTabUrl: string | undefined;\n let authorizedFrame: { ref: string; url: string | undefined } | undefined;\n const read = [\"observe\", \"inspect\", \"wait\", \"screenshot\"].includes(command.kind);\n\n for (let attempt = 0; ; attempt++) {\n let authorizationChanged = false;\n let lostDocument = false;\n\n const result = yield* session\n .run(\n Effect.suspend(() => {\n const page = activePage ?? lastNativePage;\n\n const target =\n command.kind === \"act\"\n ? targets.get(command.action.ref)\n : command.kind === \"scroll\" && command.request.ref !== undefined\n ? targets.get(command.request.ref)\n : undefined;\n\n authorizedUrl = page?.url();\n authorizedTabUrl =\n command.kind === \"select-tab\" ? tabs.get(command.request.ref)?.url() : undefined;\n\n const frameRef =\n target?.frame ??\n (command.kind === \"inspect\" || command.kind === \"wait\"\n ? command.request.frame\n : undefined);\n\n authorizedFrame =\n frameRef === undefined\n ? undefined\n : {\n ref: frameRef,\n url: page === undefined ? undefined : resolveFrame(page, frameRef)?.url(),\n };\n\n return authorize(command, {\n ...(authorizedUrl === undefined ? {} : { pageUrl: authorizedUrl }),\n ...(authorizedTabUrl === undefined ? {} : { tabUrl: authorizedTabUrl }),\n ...(authorizedFrame === undefined ? {} : { frameUrl: authorizedFrame.url }),\n ...(target === undefined\n ? {}\n : {\n target: target.control,\n }),\n });\n }).pipe(\n Effect.mapError(\n (error) =>\n new BrowserUseError({\n code: error.code,\n message: error.message,\n dispatch: \"not-dispatched\",\n }),\n ),\n ),\n async (page) => {\n attach(page);\n const selected = activePage ?? page;\n\n lastNativePage = page;\n\n if (selected.isClosed() || selected.browserContext() !== page.browserContext())\n throw new Error(\"Observed tab is unavailable\");\n if (authorizedUrl !== undefined && selected.url() !== authorizedUrl) {\n authorizationChanged = true;\n throw new Error(\"Page changed during authorization\");\n }\n if (\n authorizedFrame !== undefined &&\n resolveFrame(selected, authorizedFrame.ref)?.url() !== authorizedFrame.url\n ) {\n authorizationChanged = true;\n throw new Error(\"Frame changed during authorization\");\n }\n if (\n command.kind === \"select-tab\" &&\n tabs.get(command.request.ref)?.url() !== authorizedTabUrl\n )\n throw new Error(\"Tab changed during authorization\");\n attach(selected);\n\n try {\n return await action(selected, (name) =>\n span.attribute(\"browser.native.stage\", name),\n );\n } catch (error) {\n // A read that loses its document to a navigation retries with fresh authorization.\n // The context can be destroyed before the page reports its new URL.\n lostDocument =\n error instanceof Error &&\n /Execution context was destroyed|Cannot find context with specified id/.test(\n error.message,\n );\n // The first read of a fresh controller has no page URL yet; a lost document\n // still retries, and the retry authorizes the page it then finds.\n if (\n read &&\n (lostDocument ||\n (authorizedUrl !== undefined && selected.url() !== authorizedUrl))\n )\n authorizationChanged = true;\n throw error;\n }\n },\n timeoutMillis === undefined ? undefined : { timeoutMillis },\n )\n .pipe(Effect.result);\n\n if (result._tag === \"Success\") return result.success;\n if (\n !read ||\n !authorizationChanged ||\n attempt >= 4 ||\n result.failure._tag !== \"BrowserSessionError\" ||\n result.failure.reason !== \"provider\" ||\n result.failure.cleanup !== \"not-requested\"\n )\n return yield* result.failure;\n\n span.attribute(\"browser.read.authorization_retries\", attempt + 1);\n // A destroyed context means the next document has not committed yet; give it time.\n yield* Effect.sleep(lostDocument ? \"250 millis\" : \"20 millis\");\n }\n }).pipe(\n Effect.mapError((error) => {\n if (error._tag === \"BrowserUseError\") return error;\n const read = [\"observe\", \"inspect\", \"wait\", \"screenshot\"].includes(command.kind);\n\n return new BrowserUseError({\n code: \"browser\",\n message: read\n ? `Browser ${command.kind} failed (${error.reason}); cleanup ${error.cleanup}. No new input was dispatched.`\n : `Browser ${error.reason}; native outcome ${error.dispatch}; cleanup ${error.cleanup}. Input is never replayed.`,\n dispatch: read || error.dispatch === \"not-dispatched\" ? \"not-dispatched\" : \"unknown\",\n });\n }),\n Effect.withSpan(`BrowserUse.${command.kind}${phase === undefined ? \"\" : `.${phase}`}`),\n );\n\n const bounded = <A>(value: A) =>\n Effect.gen(function* () {\n const bytes = new TextEncoder().encode(JSON.stringify(value)).byteLength;\n\n if (bytes > limits.maxReturnedBytes)\n return yield* invalid(\n \"Browser result exceeds the host byte budget. Narrow inspection before acting.\",\n );\n\n return value;\n });\n\n const inspect = Effect.fnUntraced(function* (\n request: typeof InspectRequest.Type,\n command: Command = { kind: \"inspect\", request },\n ) {\n yield* Schema.decodeEffect(InspectRequest)(request).pipe(\n Effect.mapError(() => invalid(\"Invalid inspection request.\")),\n );\n const selectedFrame = request.frame;\n\n if (request.frame !== undefined && !frames.has(request.frame))\n return yield* invalid(\"Frame was not observed. Inspect the page first.\");\n targets.clear();\n generation++;\n\n if (pendingInput?.fiber.pollUnsafe()?._tag === \"Failure\") {\n const failed = pendingInput.fiber;\n\n clearInput();\n yield* Fiber.join(failed);\n }\n const blocked = inputPage === undefined ? undefined : pendingDialogs.get(inputPage);\n\n if (pendingInput !== undefined && blocked !== undefined) {\n yield* authorize(command, { pageUrl: inputPage?.url() });\n\n const observation = yield* bounded({\n text: \"Native input is awaiting this JavaScript dialog. Respond before further page operations; never replay the input.\",\n controls: [],\n tabs: lastTabs,\n dialogs: [\n {\n ref: blocked.ref,\n type: blocked.dialog.type(),\n message: blocked.dialog.message().slice(0, 4096),\n defaultValue: blocked.dialog.defaultValue().slice(0, 4096),\n },\n ],\n });\n\n return observation;\n }\n\n const value = yield* native(command, async (page) => {\n const currentTabs = await page.browserContext().pages();\n\n tabs.clear();\n currentTabs.slice(0, 32).forEach((tab) => {\n tabs.set(tabId(tab), tab);\n attach(tab);\n });\n\n const tabObservation = currentTabs\n .slice(0, 32)\n .map((tab) => ({ ref: tabId(tab), url: observedUrl(tab.url()), active: tab === page }));\n\n const pending = pendingDialogs.get(page);\n\n lastTabs = tabObservation;\n\n if (pending !== undefined)\n return {\n text: \"A native JavaScript dialog blocks page interaction. Respond to its observed reference before continuing.\",\n controls: [],\n tabs: tabObservation,\n truncated: currentTabs.length > 32,\n dialogs: [\n {\n ref: pending.ref,\n type: pending.dialog.type(),\n message: pending.dialog.message().slice(0, 4096),\n defaultValue: pending.dialog.defaultValue().slice(0, 4096),\n },\n ],\n };\n const currentFrames = page.frames();\n\n if (\n selectedFrame !== undefined &&\n command.kind !== \"observe\" &&\n !currentFrames.some((frame) => frameId(frame) === selectedFrame)\n )\n throw new Error(\"Observed frame is detached\");\n frames.clear();\n currentFrames.slice(0, 32).forEach((frame) => frames.add(frameId(frame)));\n\n const inspected =\n selectedFrame === undefined\n ? [page.mainFrame()]\n : currentFrames.filter((frame) => frameId(frame) === selectedFrame);\n\n if (inspected.length === 0) inspected.push(page.mainFrame());\n\n let text = \"\";\n let readyState: (typeof Observation.Type)[\"readyState\"];\n let truncated = currentFrames.length > 32 || currentTabs.length > 32;\n let metrics: (typeof Observation.Type)[\"page\"];\n const controls: Array<typeof Control.Type> = [];\n\n for (const frame of inspected) {\n if (controls.length >= 256) {\n truncated = true;\n break;\n }\n const ref = frameId(frame);\n\n if (ref === undefined) continue;\n\n const read = async (): Promise<unknown> => {\n const rootsTruncated = await discoverClosedRoots(frame);\n\n truncated ||= rootsTruncated;\n\n return limits.observationMode === \"jev\"\n ? frame\n .isolatedRealm()\n .evaluate(\n inspectJevDom,\n request.selector,\n `r${scopeId}-${generation}-${controls.length}`,\n 256 - controls.length,\n request.optionFilter,\n )\n : frame\n .isolatedRealm()\n .evaluate(\n inspectDom,\n request.selector,\n `r${scopeId}-${generation}-${controls.length}`,\n 256 - controls.length,\n request.optionFilter,\n limits.viewportOnly,\n );\n };\n\n let result = Schema.decodeUnknownSync(Observation)(await read());\n\n // Native click acknowledgement can precede document parsing. Settle this\n // explicit readiness condition before returning an empty loading document. A document\n // still parsing after 2 s is observed as it stands, reporting readyState \"loading\".\n if (result.readyState === \"loading\") {\n const ready = await frame\n .isolatedRealm()\n .waitForFunction(() => document.readyState !== \"loading\", {\n timeout: 2_000,\n polling: \"raf\",\n })\n .catch((error: unknown) => {\n if (error instanceof TimeoutError) return undefined;\n throw error;\n });\n\n await ready?.dispose();\n result = Schema.decodeUnknownSync(Observation)(await read());\n }\n readyState = result.readyState;\n if (frame === page.mainFrame()) metrics = result.page;\n\n text += limits.observationMode === \"jev\" ? result.text : `\\n[${ref}]${result.text}`;\n truncated ||= result.truncated ?? false;\n for (const control of result.controls) {\n const current = { ...control, frame: ref };\n\n targets.set(control.ref, { frame: ref, control: current });\n controls.push(current);\n }\n }\n\n const textLimit = limits.observationMode === \"jev\" ? 6_000 : 24_000;\n\n return {\n text: text.slice(0, textLimit),\n controls,\n ...(readyState === undefined ? {} : { readyState }),\n ...(metrics === undefined ? {} : { page: metrics }),\n truncated: truncated || text.length > textLimit,\n frames: currentFrames.slice(0, 32).map((frame) => ({\n ref: frameId(frame),\n name: frame.name().slice(0, 300),\n // Fragments are client-side state; payment frames put kilobytes of parameters there.\n url: observedUrl(\n frame.url().startsWith(\"data:\") ? frame.url() : frame.url().split(\"#\", 1)[0],\n ),\n inspected: inspected.includes(frame),\n })),\n tabs: tabObservation,\n dialogs: [],\n };\n }).pipe(Effect.tapError(() => Effect.sync(() => targets.clear())));\n\n const observation = yield* bounded(value).pipe(\n Effect.tapError(() => Effect.sync(() => targets.clear())),\n );\n\n return observation;\n });\n\n const charge = Effect.fnUntraced(function* () {\n if (consumed >= limits.maxActions) return yield* invalid(\"Browser action budget exhausted.\");\n consumed++;\n });\n\n const checkedPoint = async (\n element: ElementHandle<Element>,\n frame: Frame,\n expected: typeof Control.Type,\n scroll: boolean,\n pointer = true,\n ) => {\n let point = await element.evaluate(checkDom, expected, scroll, pointer);\n\n if (point === false) return false;\n let current = frame;\n let parent = current.parentFrame();\n\n while (parent !== null) {\n await discoverClosedRoots(parent);\n await using owner = await current.frameElement();\n\n if (owner === null) return false;\n await using isolatedOwner = await parent.isolatedRealm().adoptHandle(owner);\n\n point = await isolatedOwner.evaluate(checkFrameDom, point, scroll);\n if (point === false) return false;\n current = parent;\n parent = current.parentFrame();\n }\n\n return point;\n };\n\n // Separate settling from the following read's authorization snapshot.\n const settle = (input?: { readonly frame: string; readonly ref: string }) =>\n Effect.suspend(() =>\n limits.settleAfterAction\n ? native(\n { kind: \"observe\" },\n async (page) => {\n const frame =\n limits.settleAfterAction === \"input\" && input !== undefined\n ? resolveFrame(page, input.frame)\n : page.mainFrame();\n\n if (frame === undefined) return;\n\n if (limits.settleAfterAction === \"input\")\n await frame.isolatedRealm().evaluate(settleInputDom, input?.ref);\n else await frame.isolatedRealm().evaluate(settleDom);\n },\n undefined,\n \"settle\",\n ).pipe(Effect.asVoid)\n : Effect.void,\n );\n\n const after = Effect.fnUntraced(function* (\n completed: number,\n error: string | null,\n dispatch: NonNullable<(typeof ActionResult.Type)[\"dispatch\"]>,\n frame?: string,\n alreadySettled = false,\n observe = true,\n ) {\n if (dispatch === \"acknowledged\" && !alreadySettled)\n yield* settle().pipe(\n Effect.catch((failure) =>\n Effect.sync(() => {\n error ??= failure.message;\n }),\n ),\n );\n // Without an observation, refs from before the input can no longer be authorized.\n if (!observe) targets.clear();\n\n const observation = !observe\n ? null\n : yield* inspect(frame === undefined ? {} : { frame }, {\n kind: \"observe\",\n }).pipe(\n Effect.catch((failure) => {\n error ??= `Input receipt retained; observation failed. Inspect before continuing. ${failure.message}`;\n\n return Effect.succeed(null);\n }),\n );\n\n return {\n completed,\n error,\n observation,\n dispatch,\n ...(pendingInput === undefined\n ? {}\n : { pendingInput: { ref: pendingInput.ref, reason: \"dialog\" as const } }),\n };\n });\n\n const action = Effect.fnUntraced(function* (\n value: Action | ({ readonly kind: \"press\" } & typeof PressRequest.Type),\n ) {\n if (pendingInput !== undefined)\n return yield* invalid(\"Native input is pending; respond to its dialog without replaying it.\");\n const target = targets.get(value.ref);\n\n if (target === undefined)\n return yield* invalid(\"Target was not observed. Inspect before acting.\");\n if (value.kind === \"select\" && !target.control.options.includes(value.value))\n return yield* invalid(\"Select option was not observed. Inspect with optionFilter first.\");\n yield* charge();\n const command: Command = { kind: \"act\", action: value };\n\n // Preparation has its own budget: 2 s, or 8 s inside a frame, where each frame level adds\n // owner checks and a newly mounted frame first creates its isolated world. It never waits\n // for a missing selector; an actually pending CDP request is terminated by BrowserSession,\n // not abandoned.\n const inFrame = ![...tabs.values()].some(\n (tab) => frameIds.get(tab.mainFrame()) === target.frame,\n );\n\n let dispatch: NonNullable<(typeof ActionResult.Type)[\"dispatch\"]> = \"not-dispatched\";\n let refusal: string | undefined;\n\n const ready = yield* native(\n command,\n async (page, stage) => {\n const frame = resolveFrame(page, target.frame);\n\n if (frame === undefined) return false;\n // Main-frame refs are checked in place, without resolving and releasing a handle.\n if (frame.parentFrame() === null) {\n stage(\"validate-and-scroll\");\n\n const checked = await frame\n .isolatedRealm()\n .evaluate(checkDom, value.ref, target.control, true, value.kind !== \"press\");\n\n return checked !== false;\n }\n stage(\"resolve-reference\");\n\n const handle = await frame\n .isolatedRealm()\n .evaluateHandle(\n (ref) => Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(ref) ?? null,\n value.ref,\n );\n\n try {\n const element = handle.asElement();\n\n stage(\"validate-and-scroll\");\n\n return (\n element !== null &&\n (await checkedPoint(element, frame, target.control, true, value.kind !== \"press\")) !==\n false\n );\n } finally {\n stage(\"release-reference\");\n await handle.dispose();\n }\n },\n inFrame ? 8_000 : 2_000,\n \"prepare\",\n ).pipe(\n Effect.mapError(\n (error) =>\n new BrowserUseError({\n code: error.code,\n message: error.message,\n dispatch: \"not-dispatched\",\n }),\n ),\n );\n\n if (!ready)\n return yield* invalid(\n \"Observed target is stale, disabled or obstructed. No input dispatched. Inspect for a current target.\",\n );\n\n const input = native(\n command,\n async (page, stage) => {\n inputPage = page;\n const frame = resolveFrame(page, target.frame);\n\n if (frame === undefined) return \"not-dispatched\" as const;\n // Main-frame input works on the ref in place, without resolving and releasing a handle.\n // Focus and its check stay separate reads so focus handlers run before the check.\n if (frame.parentFrame() === null) {\n const realm = frame.isolatedRealm();\n\n const point = await realm.evaluate(\n checkDom,\n value.ref,\n target.control,\n false,\n value.kind !== \"press\",\n );\n\n if (point === false) return \"not-dispatched\" as const;\n stage(\"dispatch-input\");\n if (value.kind === \"click\") {\n dispatch = \"unknown\";\n await page.mouse.click(point.x, point.y);\n } else if (value.kind === \"select\") {\n dispatch = \"unknown\";\n\n // Puppeteer's select: an enabled matching option, then input and change events.\n const selected = await realm.evaluate(\n (ref, value) => {\n const node: unknown = Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(\n ref,\n );\n\n if (\n !(node instanceof HTMLSelectElement) ||\n !Array.from(node.options).some(\n (option) =>\n !option.disabled &&\n !(\n option.parentElement instanceof HTMLOptGroupElement &&\n option.parentElement.disabled\n ) &&\n option.value === value,\n )\n )\n return false;\n if (node.multiple)\n for (const option of Array.from(node.options))\n option.selected = option.value === value;\n else {\n for (const option of Array.from(node.options)) option.selected = false;\n const match = Array.from(node.options).find((option) => option.value === value);\n\n if (match !== undefined) match.selected = true;\n }\n node.dispatchEvent(new Event(\"input\", { bubbles: true }));\n node.dispatchEvent(new Event(\"change\", { bubbles: true }));\n\n return true;\n },\n value.ref,\n value.value,\n );\n\n if (!selected) {\n dispatch = \"not-dispatched\";\n\n return \"not-dispatched\" as const;\n }\n } else if (value.kind === \"press\") {\n const focused =\n (await realm.evaluate((ref) => {\n const node: unknown = Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(\n ref,\n );\n\n if (!(node instanceof HTMLElement)) return false;\n node.focus();\n\n return true;\n }, value.ref)) &&\n (await realm.evaluate((ref) => {\n const node: unknown = Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(\n ref,\n );\n\n return (\n node instanceof Node &&\n node.isConnected &&\n Reflect.get(node.getRootNode(), \"activeElement\") === node\n );\n }, value.ref));\n\n if (!focused) return \"not-dispatched\" as const;\n dispatch = \"unknown\";\n await page.keyboard.press(value.key);\n } else {\n const focused = await realm.evaluate((ref) => {\n const node: unknown = Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(\n ref,\n );\n\n if (\n !(\n (node instanceof HTMLInputElement &&\n ![\n \"password\",\n \"file\",\n \"checkbox\",\n \"radio\",\n \"hidden\",\n \"submit\",\n \"button\",\n ].includes(node.type) &&\n !node.readOnly) ||\n (node instanceof HTMLTextAreaElement && !node.readOnly) ||\n (node instanceof HTMLElement &&\n node.isContentEditable &&\n node.getAttribute(\"aria-readonly\") !== \"true\")\n )\n )\n return false;\n node.focus();\n\n return true;\n }, value.ref);\n\n if (!focused) return \"not-dispatched\" as const;\n\n // Focus handlers can replace a field. Never transfer input to the new focus.\n const selected = await realm.evaluate((ref) => {\n const node: unknown = Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(\n ref,\n );\n\n if (\n !(node instanceof HTMLElement) ||\n !node.isConnected ||\n !(\n node.getRootNode() instanceof Document || node.getRootNode() instanceof ShadowRoot\n ) ||\n Reflect.get(node.getRootNode(), \"activeElement\") !== node\n )\n return false;\n let selected = false;\n\n if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) {\n node.select();\n selected =\n node.value.length === 0 ||\n (node.selectionStart === 0 && node.selectionEnd === node.value.length) ||\n globalThis.getSelection()?.toString() === node.value;\n } else {\n const selection = globalThis.getSelection();\n\n if (selection === null) return false;\n const range = document.createRange();\n\n range.selectNodeContents(node);\n selection.removeAllRanges();\n selection.addRange(range);\n selected =\n selection.rangeCount === 1 &&\n selection.getRangeAt(0).compareBoundaryPoints(Range.START_TO_START, range) ===\n 0 &&\n selection.getRangeAt(0).compareBoundaryPoints(Range.END_TO_END, range) === 0;\n }\n\n return (\n selected &&\n node.isConnected &&\n Reflect.get(node.getRootNode(), \"activeElement\") === node\n );\n }, value.ref);\n\n if (!selected) {\n refusal =\n \"Native selection could not prepare this field for replacement. No input dispatched.\";\n\n return \"not-dispatched\" as const;\n }\n dispatch = \"unknown\";\n await page.keyboard.sendCharacter(value.value);\n }\n dispatch = \"acknowledged\";\n\n return \"acknowledged\" as const;\n }\n\n const handle = await frame\n .isolatedRealm()\n .evaluateHandle(\n (ref) => Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(ref) ?? null,\n value.ref,\n );\n\n try {\n const element = handle.asElement();\n\n if (element === null || !(element instanceof ElementHandle))\n return \"not-dispatched\" as const;\n\n const point = await checkedPoint(\n element,\n frame,\n target.control,\n false,\n value.kind !== \"press\",\n );\n\n if (point === false) return \"not-dispatched\" as const;\n stage(\"dispatch-input\");\n if (value.kind === \"click\") {\n dispatch = \"unknown\";\n await page.mouse.click(point.x, point.y);\n } else if (value.kind === \"select\") {\n const valid = await element.evaluate(\n (node, value) =>\n node instanceof HTMLSelectElement &&\n Array.from(node.options).some(\n (option) =>\n !option.disabled &&\n !(\n option.parentElement instanceof HTMLOptGroupElement &&\n option.parentElement.disabled\n ) &&\n option.value === value,\n ),\n value.value,\n );\n\n if (!valid) return \"not-dispatched\" as const;\n dispatch = \"unknown\";\n await element.select(value.value);\n } else if (value.kind === \"press\") {\n await element.focus();\n\n const focused = await element.evaluate(\n (node) =>\n node.isConnected && Reflect.get(node.getRootNode(), \"activeElement\") === node,\n );\n\n if (!focused) return \"not-dispatched\" as const;\n dispatch = \"unknown\";\n await page.keyboard.press(value.key);\n } else {\n const fillable = await element.evaluate(\n (node) =>\n (node instanceof HTMLInputElement &&\n ![\"password\", \"file\", \"checkbox\", \"radio\", \"hidden\", \"submit\", \"button\"].includes(\n node.type,\n ) &&\n !node.readOnly) ||\n (node instanceof HTMLTextAreaElement && !node.readOnly) ||\n (node instanceof HTMLElement &&\n node.isContentEditable &&\n node.getAttribute(\"aria-readonly\") !== \"true\"),\n );\n\n if (!fillable) return \"not-dispatched\" as const;\n await element.focus();\n // Focus handlers can replace a field. Never transfer input to the new focus.\n if (\n !(await element.evaluate(\n (node) =>\n node.isConnected &&\n (node.getRootNode() instanceof Document ||\n node.getRootNode() instanceof ShadowRoot) &&\n Reflect.get(node.getRootNode(), \"activeElement\") === node,\n ))\n )\n return \"not-dispatched\" as const;\n\n const selected = await element.evaluate((node) => {\n let selected = false;\n\n if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) {\n node.select();\n selected =\n node.value.length === 0 ||\n (node.selectionStart === 0 && node.selectionEnd === node.value.length) ||\n globalThis.getSelection()?.toString() === node.value;\n } else {\n const selection = globalThis.getSelection();\n\n if (selection === null) return false;\n const range = document.createRange();\n\n range.selectNodeContents(node);\n selection.removeAllRanges();\n selection.addRange(range);\n selected =\n selection.rangeCount === 1 &&\n selection.getRangeAt(0).compareBoundaryPoints(Range.START_TO_START, range) ===\n 0 &&\n selection.getRangeAt(0).compareBoundaryPoints(Range.END_TO_END, range) === 0;\n }\n\n return (\n selected &&\n node.isConnected &&\n Reflect.get(node.getRootNode(), \"activeElement\") === node\n );\n });\n\n if (!selected) {\n refusal =\n \"Native selection could not prepare this field for replacement. No input dispatched.\";\n\n return \"not-dispatched\" as const;\n }\n\n dispatch = \"unknown\";\n await page.keyboard.sendCharacter(value.value);\n }\n\n dispatch = \"acknowledged\";\n\n return \"acknowledged\" as const;\n } finally {\n await handle.dispose();\n }\n },\n undefined,\n \"input\",\n ).pipe(\n Effect.mapError(\n (error) => new BrowserUseError({ code: error.code, message: error.message, dispatch }),\n ),\n );\n\n // The session lock and native deadline remain owned by a controller-scoped fiber.\n // A dialog suspends input without abandoning SDK work or acknowledging it early.\n const start = yield* Deferred.make<void>();\n const dialogReady = yield* Deferred.make<void>();\n const ref = `op${scopeId}-${nextInput++}`;\n\n const fiber = yield* Deferred.await(start).pipe(\n Effect.andThen(input),\n Effect.forkIn(ownerScope),\n );\n\n pendingInput = { ref, fiber };\n dialogSignal = dialogReady;\n yield* Deferred.succeed(start, undefined);\n\n const result = yield* Effect.raceFirst(\n Fiber.join(fiber),\n Deferred.await(dialogReady).pipe(Effect.as(\"unknown\" as const)),\n ).pipe(\n Effect.onInterrupt(() => Fiber.interrupt(fiber)),\n Effect.result,\n );\n\n if (result._tag === \"Failure\") {\n clearInput();\n\n return yield* result.failure;\n }\n if (result.success !== \"unknown\") clearInput();\n if (result.success === \"not-dispatched\" && refusal !== undefined)\n return yield* invalid(refusal);\n if (result.success === \"acknowledged\")\n yield* settle(\n value.kind === \"fill\" ? { frame: target.frame, ref: value.ref } : undefined,\n ).pipe(\n Effect.mapError(\n (failure) =>\n new BrowserUseError({\n code: failure.code,\n message: failure.message,\n dispatch: \"acknowledged\",\n }),\n ),\n );\n\n return result.success;\n });\n\n const act = Effect.fnUntraced(function* (\n values: ReadonlyArray<Action>,\n options: ActOptions = {},\n ) {\n yield* Schema.decodeEffect(\n Schema.Array(Action).check(Schema.isMinLength(1), Schema.isMaxLength(8)),\n )(values).pipe(Effect.mapError(() => invalid(\"Expected 1–8 valid actions.\")));\n let completed = 0;\n let error: string | null = null;\n let dispatch: NonNullable<(typeof ActionResult.Type)[\"dispatch\"]> = \"not-dispatched\";\n let frame: string | undefined;\n\n for (const value of values) {\n frame = targets.get(value.ref)?.frame ?? frame;\n const outcome = yield* action(value).pipe(Effect.result);\n\n if (outcome._tag === \"Failure\") {\n error = outcome.failure.message;\n if (outcome.failure.dispatch === \"acknowledged\") completed++;\n if (outcome.failure.dispatch === \"unknown\") dispatch = \"unknown\";\n else if (completed > 0) dispatch = \"acknowledged\";\n break;\n }\n if (outcome.success === \"not-dispatched\") {\n error = \"Observed target changed before input. Inspect before continuing.\";\n break;\n }\n if (outcome.success === \"unknown\") {\n dispatch = \"unknown\";\n error =\n \"Native input is awaiting a JavaScript dialog. Respond to it; do not replay this input.\";\n break;\n }\n dispatch = \"acknowledged\";\n completed++;\n }\n\n yield* Effect.annotateCurrentSpan({\n \"browser.completed\": completed,\n \"browser.dispatch\": dispatch,\n });\n\n return yield* after(completed, error, dispatch, frame, true, options.observe !== false);\n });\n\n const navigate = Effect.fnUntraced(function* (request: typeof NavigateRequest.Type) {\n yield* Schema.decodeEffect(InteractiveBrowserTargetUrl)(request.url).pipe(\n Effect.mapError(() => invalid(\"Navigation requires a credential-free HTTP(S) URL.\")),\n );\n yield* charge();\n targets.clear();\n\n const outcome = yield* native({ kind: \"navigate\", request }, (page) =>\n page.goto(request.url, { waitUntil: \"domcontentloaded\" }),\n ).pipe(Effect.result);\n\n return yield* after(\n outcome._tag === \"Success\" ? 1 : 0,\n outcome._tag === \"Failure\" ? outcome.failure.message : null,\n outcome._tag === \"Success\" ? \"acknowledged\" : (outcome.failure.dispatch ?? \"unknown\"),\n );\n });\n\n const scroll = Effect.fnUntraced(function* (request: typeof ScrollRequest.Type) {\n yield* Schema.decodeEffect(ScrollRequest)(request).pipe(\n Effect.mapError(() => invalid(\"Invalid scroll request.\")),\n );\n yield* charge();\n const target = request.ref === undefined ? undefined : targets.get(request.ref);\n\n if (request.ref !== undefined && target === undefined)\n return yield* invalid(\"Scroll target was not observed.\");\n\n const outcome = yield* native(\n { kind: \"scroll\", request },\n async (page) => {\n if (target === undefined) {\n const viewport = await page.evaluate(() => ({ width: innerWidth, height: innerHeight }));\n\n await page.mouse.move(viewport.width / 2, viewport.height / 2);\n await page.mouse.wheel({ deltaX: request.deltaX, deltaY: request.deltaY });\n\n return true;\n }\n\n const frame = resolveFrame(page, target.frame);\n\n if (frame === undefined) return false;\n\n const handle = await frame\n .isolatedRealm()\n .evaluateHandle(\n (ref) => Reflect.get(globalThis, \"@effect-agent/native-browser\")?.get(ref) ?? null,\n request.ref ?? \"\",\n );\n\n try {\n return await handle.evaluate(\n (node, x, y) => {\n if (!(node instanceof HTMLElement) || !node.isConnected) return false;\n node.scrollBy({ left: x, top: y, behavior: \"instant\" });\n\n return true;\n },\n request.deltaX,\n request.deltaY,\n );\n } finally {\n await handle.dispose();\n }\n },\n 2_000,\n ).pipe(Effect.result);\n\n return yield* after(\n outcome._tag === \"Success\" && outcome.success ? 1 : 0,\n outcome._tag === \"Failure\"\n ? outcome.failure.message\n : outcome.success\n ? null\n : \"Scroll target is stale.\",\n outcome._tag === \"Failure\"\n ? (outcome.failure.dispatch ?? \"unknown\")\n : outcome.success\n ? \"acknowledged\"\n : \"not-dispatched\",\n );\n });\n\n const wait = Effect.fnUntraced(function* (request: typeof WaitRequest.Type) {\n yield* Schema.decodeEffect(WaitRequest)(request).pipe(\n Effect.mapError(() => invalid(\"Invalid condition wait.\")),\n );\n const frameRef = request.frame;\n\n if (request.state === \"text\" && request.text === undefined)\n return yield* invalid(\"A text wait requires expected text.\");\n\n if (frameRef !== undefined && !frames.has(frameRef))\n return yield* invalid(\"Frame was not observed.\");\n yield* native({ kind: \"wait\", request }, async (page) => {\n const frame = frameRef === undefined ? page.mainFrame() : resolveFrame(page, frameRef);\n\n if (frame === undefined) throw new Error(\"Frame detached\");\n await discoverClosedRoots(frame);\n\n try {\n const handle = await frame.isolatedRealm().waitForFunction(\n waitDom,\n {\n timeout: Math.min(request.timeoutMillis, limits.maxWaitMillis ?? request.timeoutMillis),\n polling: \"raf\",\n },\n request.selector,\n request.state,\n request.text,\n );\n\n await handle.dispose();\n } catch (error) {\n if (\n limits.maxWaitMillis === null ||\n !(error instanceof Error) ||\n error.name !== \"TimeoutError\"\n )\n throw error;\n }\n });\n\n return yield* inspect(frameRef === undefined ? {} : { frame: frameRef });\n });\n\n const screenshot = native({ kind: \"screenshot\" }, async (page) => {\n return {\n mediaType: \"image/png\" as const,\n base64: await page.screenshot({ type: \"png\", encoding: \"base64\" }),\n };\n }).pipe(Effect.flatMap(bounded));\n\n const press = Effect.fnUntraced(function* (request: typeof PressRequest.Type) {\n yield* Schema.decodeEffect(PressRequest)(request).pipe(\n Effect.mapError(() => invalid(\"Invalid native key request.\")),\n );\n const frame = targets.get(request.ref)?.frame;\n const result = yield* action({ kind: \"press\", ...request }).pipe(Effect.result);\n\n const dispatch =\n result._tag === \"Success\" ? result.success : (result.failure.dispatch ?? \"not-dispatched\");\n\n return yield* after(\n dispatch === \"acknowledged\" ? 1 : 0,\n result._tag === \"Failure\"\n ? result.failure.message\n : result.success === \"not-dispatched\"\n ? \"Target changed before keyboard input.\"\n : null,\n dispatch,\n frame,\n true,\n );\n });\n\n const selectTab = Effect.fnUntraced(function* (request: typeof TabRequest.Type) {\n yield* Schema.decodeEffect(TabRequest)(request).pipe(\n Effect.mapError(() => invalid(\"Invalid tab request.\")),\n );\n const tab = tabs.get(request.ref);\n\n if (tab === undefined)\n return yield* invalid(\"Tab was not observed. Inspect before selecting it.\");\n yield* native({ kind: \"select-tab\", request }, async (page) => {\n if (tab.isClosed() || tab.browserContext() !== page.browserContext())\n throw new Error(\"Observed tab is unavailable\");\n await tab.bringToFront();\n activePage = tab;\n targets.clear();\n frames.clear();\n });\n\n return yield* inspect({});\n });\n\n const respondDialog = Effect.fnUntraced(function* (request: typeof DialogRequest.Type) {\n yield* Schema.decodeEffect(DialogRequest)(request).pipe(\n Effect.mapError(() => invalid(\"Invalid dialog response.\")),\n );\n yield* charge();\n const outstanding = pendingInput;\n\n if (outstanding !== undefined && inputPage !== undefined) {\n const page = inputPage;\n const pending = pendingDialogs.get(page);\n\n if (\n pending === undefined ||\n pending.ref !== request.ref ||\n (request.text !== undefined && pending.dialog.type() !== \"prompt\")\n )\n return yield* invalid(\"Observed dialog is no longer current.\");\n if (outstanding.fiber.pollUnsafe()?._tag === \"Failure\") {\n clearInput();\n const settled = yield* Fiber.join(outstanding.fiber).pipe(Effect.result);\n\n return {\n ...(yield* after(\n 0,\n \"Pending native input failed. No dialog response dispatched.\",\n \"not-dispatched\",\n )),\n settledInput: {\n ref: outstanding.ref,\n dispatch:\n settled._tag === \"Success\"\n ? settled.success\n : (settled.failure.dispatch ?? \"unknown\"),\n },\n };\n }\n\n const dialogReady = yield* Deferred.make<void>();\n\n // Re-arm before answering: the handler may open another dialog before\n // this response settles. The original input keeps its fiber and deadline.\n dialogSignal = dialogReady;\n\n const response =\n outstanding.fiber.pollUnsafe() === undefined\n ? // Suspended input owns the session lock. This is its only allowed interleaving;\n // host authority is checked immediately before responding on that exact connection.\n authorize({ kind: \"respond-dialog\", request }, { pageUrl: page.url() }).pipe(\n Effect.andThen(\n Effect.tryPromise({\n try: () =>\n request.accept ? pending.dialog.accept(request.text) : pending.dialog.dismiss(),\n catch: () =>\n new BrowserUseError({\n code: \"browser\",\n message: \"Native dialog response failed. Do not replay it.\",\n dispatch: \"unknown\",\n }),\n }),\n ),\n )\n : native({ kind: \"respond-dialog\", request }, async () => {\n if (request.accept) await pending.dialog.accept(request.text);\n else await pending.dialog.dismiss();\n });\n\n const result = yield* response.pipe(\n Effect.withSpan(\"BrowserUse.respond-dialog.input\"),\n Effect.result,\n );\n\n if (result._tag === \"Failure\")\n return yield* after(0, result.failure.message, result.failure.dispatch ?? \"not-dispatched\");\n if (pendingDialogs.get(page) === pending) pendingDialogs.delete(page);\n\n const settled = yield* Effect.raceFirst(\n Fiber.join(outstanding.fiber),\n Deferred.await(dialogReady).pipe(Effect.as(\"unknown\" as const)),\n ).pipe(\n Effect.onInterrupt(() => Fiber.interrupt(outstanding.fiber)),\n Effect.result,\n );\n\n if (settled._tag === \"Success\" && settled.success === \"unknown\")\n return yield* after(1, null, \"acknowledged\", undefined, true);\n\n clearInput();\n\n return {\n ...(yield* after(\n 1,\n settled._tag === \"Failure\" ? settled.failure.message : null,\n \"acknowledged\",\n )),\n settledInput: {\n ref: outstanding.ref,\n dispatch:\n settled._tag === \"Success\" ? settled.success : (settled.failure.dispatch ?? \"unknown\"),\n },\n };\n }\n\n const receipt: { dispatch: NonNullable<(typeof ActionResult.Type)[\"dispatch\"]> } = {\n dispatch: \"not-dispatched\",\n };\n\n const result = yield* native({ kind: \"respond-dialog\", request }, async (page) => {\n const pending = pendingDialogs.get(page);\n\n if (\n pending === undefined ||\n pending.ref !== request.ref ||\n (request.text !== undefined && pending.dialog.type() !== \"prompt\")\n )\n return false;\n receipt.dispatch = \"unknown\";\n if (request.accept) await pending.dialog.accept(request.text);\n else await pending.dialog.dismiss();\n receipt.dispatch = \"acknowledged\";\n if (pendingDialogs.get(page) === pending) pendingDialogs.delete(page);\n\n return true;\n }).pipe(Effect.result);\n\n return yield* after(\n receipt.dispatch === \"acknowledged\" ? 1 : 0,\n result._tag === \"Failure\"\n ? result.failure.message\n : result.success\n ? null\n : \"Observed dialog is no longer current.\",\n receipt.dispatch,\n );\n });\n\n const actions = BrowserActions.of({\n observe: lock.withPermit(inspect({}, { kind: \"observe\" })),\n act: (values, options) =>\n lock.withPermit(act(values, options)).pipe(Effect.withSpan(\"BrowserUse.act\")),\n });\n\n const control = BrowserControl.of({\n inspect: (request) => lock.withPermit(inspect(request)),\n navigate: (request) => lock.withPermit(navigate(request)),\n scroll: (request) => lock.withPermit(scroll(request)),\n wait: (request) => lock.withPermit(wait(request)),\n screenshot: lock.withPermit(screenshot),\n press: (request) => lock.withPermit(press(request)),\n selectTab: (request) => lock.withPermit(selectTab(request)),\n respondDialog: (request) =>\n lock.withPermit(respondDialog(request)).pipe(Effect.withSpan(\"BrowserUse.respond-dialog\")),\n });\n\n return {\n actions,\n control,\n layer: Layer.merge(\n Layer.succeed(BrowserActions, actions),\n Layer.succeed(BrowserControl, control),\n ),\n };\n});\n"],"mappings":";;;;;;;;AAOA,MAAa,iBAAiB,cAC3B,QACC,IAAI,SAAe,YAAY;CAC7B,MAAM,QACJ,QAAQ,KAAA,IACJ,KAAA,IACA,QAAQ,IAAI,YAAY,8BAA8B,CAAC,EAAE,IAAI,GAAG;CAEtE,MAAM,eAAe,OAAO,aAAa,MAAM,MAAM;CACrD,IAAI,SAAS;CACb,IAAI,UAAU;CACd,IAAI,YAAY;CAEhB,MAAM,eAAe;EACnB,IAAI,SAAS;EACb,UAAU;EACV,aAAa,QAAQ;EACrB,qBAAqB,SAAS;EAC9B,QAAQ;CACV;CAEA,MAAM,WAA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gB,OAAO,GACrC,MAAM,QAAQ,gBAAgB,OAAO,CACvC;CACF;AACF,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { t as BrowserSession } from "./BrowserSession-Bx0V1-6_.mjs";
2
+ import { Effect, Layer } from "effect";
3
+ import { ActOptions, Action, ActionResult, BrowserActions, BrowserControl, BrowserUseError, Control, DialogRequest, InspectRequest, NavigateRequest, Observation, PressRequest, ScrollRequest, TabRequest, WaitRequest } from "@yielded/agent/browser-use";
4
+ declare namespace BrowserUse_d_exports {
5
+ export { AuthorizationContext, Command, Options, make };
6
+ }
7
+ export type Command = {
8
+ readonly kind: "observe" | "screenshot";
9
+ } | {
10
+ readonly kind: "inspect";
11
+ readonly request: typeof InspectRequest.Type;
12
+ } | {
13
+ readonly kind: "navigate";
14
+ readonly request: typeof NavigateRequest.Type;
15
+ } | {
16
+ readonly kind: "scroll";
17
+ readonly request: typeof ScrollRequest.Type;
18
+ } | {
19
+ readonly kind: "wait";
20
+ readonly request: typeof WaitRequest.Type;
21
+ } | {
22
+ readonly kind: "select-tab";
23
+ readonly request: typeof TabRequest.Type;
24
+ } | {
25
+ readonly kind: "respond-dialog";
26
+ readonly request: typeof DialogRequest.Type;
27
+ } | {
28
+ readonly kind: "act";
29
+ readonly action: Action | ({
30
+ readonly kind: "press";
31
+ } & typeof PressRequest.Type);
32
+ };
33
+ export interface Options<R = never> {
34
+ /** Rechecked under the native session lock. The host owns origins, identity and consent. */
35
+ readonly authorize: (command: Command, context: AuthorizationContext) => Effect.Effect<void, BrowserUseError, R>;
36
+ readonly maxActions: number;
37
+ readonly maxReturnedBytes: number;
38
+ /** Prefer viewport controls; retain off-screen popups only if none of their controls are in view. Defaults to false. */
39
+ readonly viewportOnly?: boolean;
40
+ /** Jev reads enabled controls centered in the viewport with accessible names and at most 6,000 visible text characters. Defaults to "default". */
41
+ readonly observationMode?: "default" | "jev";
42
+ /** True waits for 100 ms of DOM quiet (at most 1 s). "input" waits two frames/50 ms, or visible combobox options/200 ms. Defaults to false. */
43
+ readonly settleAfterAction?: boolean | "input";
44
+ /** Cap condition waits and return a fresh observation on a condition timeout. Omit to retain timeout errors. */
45
+ readonly maxWaitMillis?: number;
46
+ }
47
+ /** Host-only current SDK metadata. Opaque refs never replace origin or target authority. */
48
+ export interface AuthorizationContext {
49
+ /** Absent only before the initial attachment read; the host authorizes that attachment. */
50
+ readonly pageUrl?: string;
51
+ readonly frameUrl?: string;
52
+ /** Destination of an observed select-tab command, checked again before selection. */
53
+ readonly tabUrl?: string;
54
+ readonly target?: typeof Control.Type;
55
+ }
56
+ /** One application-neutral controller over an existing scoped native attachment.
57
+ * No allocation, model, provider choice, input retry, or arbitrary page JS is exposed.
58
+ * Reads re-authorize at most five times when page/frame URLs change during authorization.
59
+ * References expire on inspection; outstanding native work retains the session's fencing.
60
+ */
61
+ export declare const make: <R>(session: Pick<BrowserSession, "run">, options: Options<R>) => Effect.Effect<{
62
+ actions: {
63
+ readonly observe: Effect.Effect<typeof Observation.Type, BrowserUseError>;
64
+ readonly act: (actions: ReadonlyArray<Action>, options?: ActOptions) => Effect.Effect<typeof ActionResult.Type, BrowserUseError>;
65
+ };
66
+ control: {
67
+ readonly inspect: (request: typeof InspectRequest.Type) => Effect.Effect<typeof Observation.Type, BrowserUseError>;
68
+ readonly navigate: (request: typeof NavigateRequest.Type) => Effect.Effect<typeof ActionResult.Type, BrowserUseError>;
69
+ readonly scroll: (request: typeof ScrollRequest.Type) => Effect.Effect<typeof ActionResult.Type, BrowserUseError>;
70
+ readonly wait: (request: typeof WaitRequest.Type) => Effect.Effect<typeof Observation.Type, BrowserUseError>;
71
+ readonly screenshot: Effect.Effect<{
72
+ readonly mediaType: "image/png";
73
+ readonly base64: string;
74
+ }, BrowserUseError>;
75
+ readonly press: (request: typeof PressRequest.Type) => Effect.Effect<typeof ActionResult.Type, BrowserUseError>;
76
+ readonly selectTab: (request: typeof TabRequest.Type) => Effect.Effect<typeof Observation.Type, BrowserUseError>;
77
+ readonly respondDialog: (request: typeof DialogRequest.Type) => Effect.Effect<typeof ActionResult.Type, BrowserUseError>;
78
+ };
79
+ layer: Layer.Layer<BrowserActions | BrowserControl, never, never>;
80
+ }, BrowserUseError, R | import("effect/Scope").Scope>;
81
+ //#endregion
82
+ export { BrowserUse_d_exports as t };
83
+ //# sourceMappingURL=BrowserUse.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { n as make } from "./BrowserUse-Bc2JdLW2.mjs";
2
+ export { make };
@@ -22,7 +22,8 @@ export declare class CloudflareBindingError extends CloudflareBindingError_base
22
22
  * and the cross-Object transport call it through `DurableObjectNamespace` stubs. Every
23
23
  * `encoded` value is a Schema-encoded envelope (`client.ts` wire schemas for host entry
24
24
  * points, `@yielded/agent-storage-cloudflare` port envelopes for `portCall`), so the RPC
25
- * boundary carries only structured-cloneable JSON. The optional trailing trace context is
25
+ * boundary carries structured-cloneable JSON, except `watchTextEncoded`, which can return
26
+ * a bounded, disposable byte stream. The optional trailing trace context is
26
27
  * transient native RPC metadata, stripped by an opted-in effect-cf receiver before decoding
27
28
  * the host or port envelope. It never enters durable state.
28
29
  */
@@ -32,10 +33,14 @@ export interface ThreadObjectRpc extends Rpc.DurableObjectBranded {
32
33
  /** Wake-hinted, poll-guaranteed settlement wait; answers an `AwaitSettlementResponse`. */
33
34
  submissionStatusEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
34
35
  awaitSettlementEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
36
+ /** Finalized canonical settlement record; requires settlement and observation authority. */
37
+ awaitSettlementRecordEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
35
38
  /** Event-driven durable progress wait; answers a `ProgressObserved` host response. */
36
39
  awaitProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
37
40
  /** Best-effort cancellation for one in-flight progress wait. */
38
41
  cancelProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
42
+ /** Authorized prospective provisional text; byte stream or encoded HostFailed. */
43
+ watchTextEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
39
44
  /** One bounded page of canonical records; answers an `ObservePageResponse`. */
40
45
  observePage(encoded: unknown, traceContext?: unknown): Promise<unknown>;
41
46
  /** Durable abort intent; answers an `AbortResponse`. */
@@ -107,6 +112,8 @@ declare const ThreadObjectIdentity_base: Context.ServiceClass<ThreadObjectIdenti
107
112
  export declare class ThreadObjectIdentity extends ThreadObjectIdentity_base {}
108
113
  declare const ThreadObjectPlacement_base: Context.ServiceClass<ThreadObjectPlacement, "@effect-agent/platform-cloudflare/ThreadObjectPlacement", {
109
114
  readonly ownsThread: (threadId: ThreadId) => boolean;
115
+ /** Present only when this physical Object owns exactly this one Thread. */
116
+ readonly threadId?: ThreadId;
110
117
  }>;
111
118
  /** Logical Threads whose canonical stores and admission ledger live in this physical Object. */
112
119
  export declare class ThreadObjectPlacement extends ThreadObjectPlacement_base {}
@@ -40,7 +40,7 @@ var ThreadObjectNamespace = class ThreadObjectNamespace extends Context.Service(
40
40
  }
41
41
  };
42
42
  /** Invoke a placed Thread using the current invocation's native RPC channel. */
43
- const callThreadObject = Effect.fn("callThreadObject")(function* (threadId, invoke, onError) {
43
+ const callThreadObject = Effect.fnUntraced(function* (threadId, invoke, onError) {
44
44
  const namespace = yield* ThreadObjectNamespace;
45
45
  const target = yield* RpcTargets.get(namespace, threadId, () => namespace.get(threadId)).pipe(Effect.mapError(onError));
46
46
  return yield* Effect.tryPromise({
@@ -54,7 +54,7 @@ const callThreadObject = Effect.fn("callThreadObject")(function* (threadId, invo
54
54
  * narrowest-boundary check (structural probe for the namespace surface the transport uses);
55
55
  * a missing or misshaped binding fails typed before any Layer is built.
56
56
  */
57
- const threadNamespaceFromEnv = Effect.fn("threadNamespaceFromEnv")(function* (env, binding) {
57
+ const threadNamespaceFromEnv = Effect.fnUntraced(function* (env, binding) {
58
58
  if (!Predicate.isObjectKeyword(env)) return yield* CloudflareBindingError.make({
59
59
  binding,
60
60
  message: "The Worker environment is not an object; no bindings are available."
@@ -1 +1 @@
1
- {"version":3,"file":"CloudflareBindings.mjs","names":[],"sources":["../src/CloudflareBindings.ts"],"sourcesContent":["import { type ThreadId } from \"@yielded/agent/identifiers\";\nimport { type ProducerId } from \"@yielded/agent/records\";\nimport { Context, Effect, Layer, Predicate, Schema } from \"effect\";\nimport { RpcTargets } from \"effect-cf\";\n\n/**\n * Cloudflare platform bindings as Effect services (DEPLOY-010: \"Cloudflare platform bindings\n * are supplied as Effect services/Layers\"). Application code never reads `env` or touches a\n * `DurableObjectState` directly — the Thread Object class constructs these Layers once\n * per incarnation and everything downstream consumes the services.\n */\n\n/** A Cloudflare platform binding was missing or carried the wrong shape (DEPLOY-003/010). */\nexport class CloudflareBindingError extends Schema.TaggedError<CloudflareBindingError>()(\n \"CloudflareBindingError\",\n {\n binding: Schema.String,\n message: Schema.String,\n },\n) {}\n\n/**\n * The RPC surface one Thread Durable Object exposes to Workers and to sibling\n * Thread Objects. `ThreadObject.make` implements it; the Worker-side client\n * and the cross-Object transport call it through `DurableObjectNamespace` stubs. Every\n * `encoded` value is a Schema-encoded envelope (`client.ts` wire schemas for host entry\n * points, `@yielded/agent-storage-cloudflare` port envelopes for `portCall`), so the RPC\n * boundary carries only structured-cloneable JSON. The optional trailing trace context is\n * transient native RPC metadata, stripped by an opted-in effect-cf receiver before decoding\n * the host or port envelope. It never enters durable state.\n */\nexport interface ThreadObjectRpc extends Rpc.DurableObjectBranded {\n /** Admission-limits gate + `DurableAgentRuntime.submit`; answers a `SubmitResponse`. */\n submitEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Wake-hinted, poll-guaranteed settlement wait; answers an `AwaitSettlementResponse`. */\n submissionStatusEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n awaitSettlementEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Event-driven durable progress wait; answers a `ProgressObserved` host response. */\n awaitProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Best-effort cancellation for one in-flight progress wait. */\n cancelProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** One bounded page of canonical records; answers an `ObservePageResponse`. */\n observePage(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Durable abort intent; answers an `AbortResponse`. */\n abortEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Durable approval decision (plan §2.6); answers a `ResolveApprovalResponse`. */\n resolveApprovalEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Authorized DUR-017 Unknown-Outcome resolution; answers a `ResolveUnknownResponse`. */\n resolveUnknownEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Owner-side cross-Object port endpoint (WP2 envelopes, executed on LOCAL facets). */\n portCall(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Droppable liveness hint from another Object: arms an immediate alarm. */\n wake(): Promise<void>;\n}\n\n/** A logical Thread endpoint may be bound to an application Object without forging its brand. */\nexport type ThreadObjectClient = Omit<ThreadObjectRpc, keyof Rpc.DurableObjectBranded>;\n\n/**\n * Deterministic logical Thread placement. The native adapter uses `idFromName(threadId)`;\n * a shared application owner can bind that logical identity into its RPC adapter instead.\n * Lookup performs no I/O and grants no authority. Calls reuse a native target within\n * one invocation; incoming requests and durable retries acquire their own targets.\n */\nexport class ThreadObjectNamespace extends Context.Service<\n ThreadObjectNamespace,\n {\n readonly get: (threadId: ThreadId) => ThreadObjectClient;\n /** Stable binding name for opted-in native RPC tracing; absent by default. */\n readonly rpcTracing?: string;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectNamespace\") {\n static layer(\n namespace: DurableObjectNamespace<ThreadObjectRpc>,\n options: { readonly rpcTracing?: string } = {},\n ): Layer.Layer<ThreadObjectNamespace> {\n return Layer.succeed(ThreadObjectNamespace)({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === undefined ? {} : { rpcTracing: options.rpcTracing }),\n });\n }\n}\n\n/** Invoke a placed Thread using the current invocation's native RPC channel. */\nexport const callThreadObject = Effect.fn(\"callThreadObject\")(function* <A, E>(\n threadId: ThreadId,\n invoke: (target: ThreadObjectClient) => Promise<A>,\n onError: (cause: unknown) => E,\n): Effect.fn.Return<A, E, ThreadObjectNamespace> {\n const namespace = yield* ThreadObjectNamespace;\n\n const target = yield* RpcTargets.get(namespace, threadId, () => namespace.get(threadId)).pipe(\n Effect.mapError(onError),\n );\n\n return yield* Effect.tryPromise({ try: () => invoke(target), catch: onError }).pipe(\n Effect.tapCause(() => RpcTargets.invalidate(target)),\n );\n});\n\n/**\n * Narrow one `env` member to a `DurableObjectNamespace`. `env` is an untyped platform value,\n * and a namespace binding is a host object no Schema can decode, so this is the documented\n * narrowest-boundary check (structural probe for the namespace surface the transport uses);\n * a missing or misshaped binding fails typed before any Layer is built.\n */\nexport const threadNamespaceFromEnv = Effect.fn(\"threadNamespaceFromEnv\")(function* (\n env: unknown,\n binding: string,\n): Effect.fn.Return<DurableObjectNamespace<ThreadObjectRpc>, CloudflareBindingError> {\n if (!Predicate.isObjectKeyword(env)) {\n return yield* CloudflareBindingError.make({\n binding,\n message: \"The Worker environment is not an object; no bindings are available.\",\n });\n }\n\n const candidate = yield* Effect.try({\n try: () => {\n const value: unknown = Reflect.get(env, binding);\n\n if (!Predicate.isObjectKeyword(value)) return undefined;\n const idFromName: unknown = Reflect.get(value, \"idFromName\");\n const get: unknown = Reflect.get(value, \"get\");\n\n return typeof idFromName === \"function\" && typeof get === \"function\" ? value : undefined;\n },\n catch: () =>\n CloudflareBindingError.make({\n binding,\n message: `env.${binding} could not be inspected as a DurableObjectNamespace binding.`,\n }),\n });\n\n if (candidate !== undefined) {\n // The structural probe above is the entire runtime contract this package relies on;\n // the assertion records that `idFromName`/`get` name a DurableObjectNamespace.\n return candidate as unknown as DurableObjectNamespace<ThreadObjectRpc>;\n }\n\n return yield* CloudflareBindingError.make({\n binding,\n message:\n `env.${binding} is not a DurableObjectNamespace binding; declare the Thread ` +\n \"Object class under this binding in the Worker configuration.\",\n });\n});\n\n/**\n * Build the namespace from Worker `env` (fails typed). Enable `rpcTracing` only when the\n * receiver also opts into the effect-cf native RPC trace-context contract.\n */\nexport const threadNamespaceLayer = (\n env: unknown,\n binding: string,\n options: { readonly rpcTracing?: boolean } = {},\n): Layer.Layer<ThreadObjectNamespace, CloudflareBindingError> =>\n Layer.effect(ThreadObjectNamespace)(\n Effect.map(threadNamespaceFromEnv(env, binding), (namespace) => ({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === true ? { rpcTracing: binding } : {}),\n })),\n );\n\n/**\n * The live Durable Object execution context of THIS incarnation. Only Layer construction and\n * the alarm service consume it; important state never lives on it (`ctx.storage` is truth,\n * everything in memory is a cache — deployment spec §11).\n */\nexport class DurableObjectContext extends Context.Service<\n DurableObjectContext,\n {\n readonly ctx: DurableObjectState;\n readonly env: unknown;\n }\n>()(\"@effect-agent/platform-cloudflare/DurableObjectContext\") {\n static layer(ctx: DurableObjectState, env: unknown): Layer.Layer<DurableObjectContext> {\n return Layer.succeed(DurableObjectContext)({ ctx, env });\n }\n}\n\n/**\n * The Thread identity this Object serializes and the producer identity its Attempts\n * write with (`{producerPrefix}:{threadId}`, plan §1.4). Derived once per incarnation\n * from `ctx.id.name` — the Object identity rule guarantees the name IS the Thread ID.\n */\nexport class ThreadObjectIdentity extends Context.Service<\n ThreadObjectIdentity,\n {\n readonly threadId: ThreadId;\n readonly producerId: ProducerId;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectIdentity\") {}\n\n/** Logical Threads whose canonical stores and admission ledger live in this physical Object. */\nexport class ThreadObjectPlacement extends Context.Service<\n ThreadObjectPlacement,\n { readonly ownsThread: (threadId: ThreadId) => boolean }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectPlacement\") {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACtF,0BACA;CACE,SAA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,KAAA;EACjF;EACA,aACE,uBAAuB,KAAK;GAC1B;GACA,SAAS,OAAO,QAAQ;EAC1B,CAAC;CACL,CAAC;CAED,IAAI,cAAc,KAAA,GAGhB,OAAO;CAGT,OAAO,OAAO,uBAAuB,KAAK;EACxC;EACA,SACE,OAAO,QAAQ;CAEnB,CAAC;AACH,CAAC;;;;;AAMD,MAAa,wBACX,KACA,SACA,UAA6C,CAAC,MAE9C,MAAM,OAAO,qBAAqB,CAAC,CACjC,OAAO,IAAI,uBAAuB,KAAK,OAAO,IAAI,eAAe;CAC/D,MAAM,aAAa,UAAU,IAAI,UAAU,WAAW,QAAQ,CAAC;CAC/D,GAAI,QAAQ,eAAe,OAAO,EAAE,YAAY,QAAQ,IAAI,CAAC;AAC/D,EAAE,CACJ;;;;;;AAOF,IAAa,uBAAb,MAAa,6BAA6B,QAAQ,QAMhD,CAAC,CAAC,wDAAwD,CAAC,CAAC;CAC5D,OAAO,MAAM,KAAyB,KAAiD;EACrF,OAAO,MAAM,QAAQ,oBAAoB,CAAC,CAAC;GAAE;GAAK;EAAI,CAAC;CACzD;AACF;;;;;;AAOA,IAAa,uBAAb,cAA0C,QAAQ,QAMhD,CAAC,CAAC,wDAAwD,CAAC,CAAC,CAAC;;AAG/D,IAAa,wBAAb,cAA2C,QAAQ,QAGjD,CAAC,CAAC,yDAAyD,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"CloudflareBindings.mjs","names":[],"sources":["../src/CloudflareBindings.ts"],"sourcesContent":["import { type ThreadId } from \"@yielded/agent/identifiers\";\nimport { type ProducerId } from \"@yielded/agent/records\";\nimport { Context, Effect, Layer, Predicate, Schema } from \"effect\";\nimport { RpcTargets } from \"effect-cf\";\n\n/**\n * Cloudflare platform bindings as Effect services (DEPLOY-010: \"Cloudflare platform bindings\n * are supplied as Effect services/Layers\"). Application code never reads `env` or touches a\n * `DurableObjectState` directly — the Thread Object class constructs these Layers once\n * per incarnation and everything downstream consumes the services.\n */\n\n/** A Cloudflare platform binding was missing or carried the wrong shape (DEPLOY-003/010). */\nexport class CloudflareBindingError extends Schema.TaggedError<CloudflareBindingError>()(\n \"CloudflareBindingError\",\n {\n binding: Schema.String,\n message: Schema.String,\n },\n) {}\n\n/**\n * The RPC surface one Thread Durable Object exposes to Workers and to sibling\n * Thread Objects. `ThreadObject.make` implements it; the Worker-side client\n * and the cross-Object transport call it through `DurableObjectNamespace` stubs. Every\n * `encoded` value is a Schema-encoded envelope (`client.ts` wire schemas for host entry\n * points, `@yielded/agent-storage-cloudflare` port envelopes for `portCall`), so the RPC\n * boundary carries structured-cloneable JSON, except `watchTextEncoded`, which can return\n * a bounded, disposable byte stream. The optional trailing trace context is\n * transient native RPC metadata, stripped by an opted-in effect-cf receiver before decoding\n * the host or port envelope. It never enters durable state.\n */\nexport interface ThreadObjectRpc extends Rpc.DurableObjectBranded {\n /** Admission-limits gate + `DurableAgentRuntime.submit`; answers a `SubmitResponse`. */\n submitEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Wake-hinted, poll-guaranteed settlement wait; answers an `AwaitSettlementResponse`. */\n submissionStatusEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n awaitSettlementEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Finalized canonical settlement record; requires settlement and observation authority. */\n awaitSettlementRecordEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Event-driven durable progress wait; answers a `ProgressObserved` host response. */\n awaitProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Best-effort cancellation for one in-flight progress wait. */\n cancelProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Authorized prospective provisional text; byte stream or encoded HostFailed. */\n watchTextEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** One bounded page of canonical records; answers an `ObservePageResponse`. */\n observePage(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Durable abort intent; answers an `AbortResponse`. */\n abortEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Durable approval decision (plan §2.6); answers a `ResolveApprovalResponse`. */\n resolveApprovalEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Authorized DUR-017 Unknown-Outcome resolution; answers a `ResolveUnknownResponse`. */\n resolveUnknownEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Owner-side cross-Object port endpoint (WP2 envelopes, executed on LOCAL facets). */\n portCall(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Droppable liveness hint from another Object: arms an immediate alarm. */\n wake(): Promise<void>;\n}\n\n/** A logical Thread endpoint may be bound to an application Object without forging its brand. */\nexport type ThreadObjectClient = Omit<ThreadObjectRpc, keyof Rpc.DurableObjectBranded>;\n\n/**\n * Deterministic logical Thread placement. The native adapter uses `idFromName(threadId)`;\n * a shared application owner can bind that logical identity into its RPC adapter instead.\n * Lookup performs no I/O and grants no authority. Calls reuse a native target within\n * one invocation; incoming requests and durable retries acquire their own targets.\n */\nexport class ThreadObjectNamespace extends Context.Service<\n ThreadObjectNamespace,\n {\n readonly get: (threadId: ThreadId) => ThreadObjectClient;\n /** Stable binding name for opted-in native RPC tracing; absent by default. */\n readonly rpcTracing?: string;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectNamespace\") {\n static layer(\n namespace: DurableObjectNamespace<ThreadObjectRpc>,\n options: { readonly rpcTracing?: string } = {},\n ): Layer.Layer<ThreadObjectNamespace> {\n return Layer.succeed(ThreadObjectNamespace)({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === undefined ? {} : { rpcTracing: options.rpcTracing }),\n });\n }\n}\n\n/** Invoke a placed Thread using the current invocation's native RPC channel. */\nexport const callThreadObject = Effect.fnUntraced(function* <A, E>(\n threadId: ThreadId,\n invoke: (target: ThreadObjectClient) => Promise<A>,\n onError: (cause: unknown) => E,\n): Effect.fn.Return<A, E, ThreadObjectNamespace> {\n const namespace = yield* ThreadObjectNamespace;\n\n const target = yield* RpcTargets.get(namespace, threadId, () => namespace.get(threadId)).pipe(\n Effect.mapError(onError),\n );\n\n return yield* Effect.tryPromise({ try: () => invoke(target), catch: onError }).pipe(\n Effect.tapCause(() => RpcTargets.invalidate(target)),\n );\n});\n\n/**\n * Narrow one `env` member to a `DurableObjectNamespace`. `env` is an untyped platform value,\n * and a namespace binding is a host object no Schema can decode, so this is the documented\n * narrowest-boundary check (structural probe for the namespace surface the transport uses);\n * a missing or misshaped binding fails typed before any Layer is built.\n */\nexport const threadNamespaceFromEnv = Effect.fnUntraced(function* (\n env: unknown,\n binding: string,\n): Effect.fn.Return<DurableObjectNamespace<ThreadObjectRpc>, CloudflareBindingError> {\n if (!Predicate.isObjectKeyword(env)) {\n return yield* CloudflareBindingError.make({\n binding,\n message: \"The Worker environment is not an object; no bindings are available.\",\n });\n }\n\n const candidate = yield* Effect.try({\n try: () => {\n const value: unknown = Reflect.get(env, binding);\n\n if (!Predicate.isObjectKeyword(value)) return undefined;\n const idFromName: unknown = Reflect.get(value, \"idFromName\");\n const get: unknown = Reflect.get(value, \"get\");\n\n return typeof idFromName === \"function\" && typeof get === \"function\" ? value : undefined;\n },\n catch: () =>\n CloudflareBindingError.make({\n binding,\n message: `env.${binding} could not be inspected as a DurableObjectNamespace binding.`,\n }),\n });\n\n if (candidate !== undefined) {\n // The structural probe above is the entire runtime contract this package relies on;\n // the assertion records that `idFromName`/`get` name a DurableObjectNamespace.\n return candidate as unknown as DurableObjectNamespace<ThreadObjectRpc>;\n }\n\n return yield* CloudflareBindingError.make({\n binding,\n message:\n `env.${binding} is not a DurableObjectNamespace binding; declare the Thread ` +\n \"Object class under this binding in the Worker configuration.\",\n });\n});\n\n/**\n * Build the namespace from Worker `env` (fails typed). Enable `rpcTracing` only when the\n * receiver also opts into the effect-cf native RPC trace-context contract.\n */\nexport const threadNamespaceLayer = (\n env: unknown,\n binding: string,\n options: { readonly rpcTracing?: boolean } = {},\n): Layer.Layer<ThreadObjectNamespace, CloudflareBindingError> =>\n Layer.effect(ThreadObjectNamespace)(\n Effect.map(threadNamespaceFromEnv(env, binding), (namespace) => ({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === true ? { rpcTracing: binding } : {}),\n })),\n );\n\n/**\n * The live Durable Object execution context of THIS incarnation. Only Layer construction and\n * the alarm service consume it; important state never lives on it (`ctx.storage` is truth,\n * everything in memory is a cache — deployment spec §11).\n */\nexport class DurableObjectContext extends Context.Service<\n DurableObjectContext,\n {\n readonly ctx: DurableObjectState;\n readonly env: unknown;\n }\n>()(\"@effect-agent/platform-cloudflare/DurableObjectContext\") {\n static layer(ctx: DurableObjectState, env: unknown): Layer.Layer<DurableObjectContext> {\n return Layer.succeed(DurableObjectContext)({ ctx, env });\n }\n}\n\n/**\n * The Thread identity this Object serializes and the producer identity its Attempts\n * write with (`{producerPrefix}:{threadId}`, plan §1.4). Derived once per incarnation\n * from `ctx.id.name` — the Object identity rule guarantees the name IS the Thread ID.\n */\nexport class ThreadObjectIdentity extends Context.Service<\n ThreadObjectIdentity,\n {\n readonly threadId: ThreadId;\n readonly producerId: ProducerId;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectIdentity\") {}\n\n/** Logical Threads whose canonical stores and admission ledger live in this physical Object. */\nexport class ThreadObjectPlacement extends Context.Service<\n ThreadObjectPlacement,\n {\n readonly ownsThread: (threadId: ThreadId) => boolean;\n /** Present only when this physical Object owns exactly this one Thread. */\n readonly threadId?: ThreadId;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectPlacement\") {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACtF,0BACA;CACE,SAAS,OAAO;CAChB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;;;;;;AAkDH,IAAa,wBAAb,MAAa,8BAA8B,QAAQ,QAOjD,CAAC,CAAC,yDAAyD,CAAC,CAAC;CAC7D,OAAO,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