@browserbasehq/orca 3.2.1-preview.3 → 3.4.0-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/dist/cjs/lib/inference.js +1 -8
  2. package/dist/cjs/lib/inference.js.map +1 -1
  3. package/dist/cjs/lib/prompt.js +3 -1
  4. package/dist/cjs/lib/prompt.js.map +1 -1
  5. package/dist/cjs/lib/v3/agent/AgentProvider.js +3 -0
  6. package/dist/cjs/lib/v3/agent/AgentProvider.js.map +1 -1
  7. package/dist/cjs/lib/v3/agent/tools/fillFormVision.js +16 -12
  8. package/dist/cjs/lib/v3/agent/tools/fillFormVision.js.map +1 -1
  9. package/dist/cjs/lib/v3/agent/utils/validateExperimentalFeatures.js +0 -4
  10. package/dist/cjs/lib/v3/agent/utils/validateExperimentalFeatures.js.map +1 -1
  11. package/dist/cjs/lib/v3/api.d.ts +1 -0
  12. package/dist/cjs/lib/v3/api.js +15 -3
  13. package/dist/cjs/lib/v3/api.js.map +1 -1
  14. package/dist/cjs/lib/v3/dom/build/a11yScripts.generated.js +12 -12
  15. package/dist/cjs/lib/v3/dom/build/a11yScripts.generated.js.map +1 -1
  16. package/dist/cjs/lib/v3/dom/build/locatorScripts.generated.js +48 -48
  17. package/dist/cjs/lib/v3/dom/build/locatorScripts.generated.js.map +1 -1
  18. package/dist/cjs/lib/v3/dom/build/reRenderScriptContent.d.ts +1 -1
  19. package/dist/cjs/lib/v3/dom/build/reRenderScriptContent.js +1 -1
  20. package/dist/cjs/lib/v3/dom/build/reRenderScriptContent.js.map +1 -1
  21. package/dist/cjs/lib/v3/dom/build/screenshotScripts.generated.js +2 -2
  22. package/dist/cjs/lib/v3/dom/build/screenshotScripts.generated.js.map +1 -1
  23. package/dist/cjs/lib/v3/dom/build/scriptV3Content.d.ts +1 -1
  24. package/dist/cjs/lib/v3/dom/build/scriptV3Content.js +1 -1
  25. package/dist/cjs/lib/v3/dom/build/scriptV3Content.js.map +1 -1
  26. package/dist/cjs/lib/v3/handlers/extractHandler.js +3 -1
  27. package/dist/cjs/lib/v3/handlers/extractHandler.js.map +1 -1
  28. package/dist/cjs/lib/v3/handlers/v3AgentHandler.js +3 -5
  29. package/dist/cjs/lib/v3/handlers/v3AgentHandler.js.map +1 -1
  30. package/dist/cjs/lib/v3/index.d.ts +1 -1
  31. package/dist/cjs/lib/v3/llm/CerebrasClient.js +1 -1
  32. package/dist/cjs/lib/v3/llm/CerebrasClient.js.map +1 -1
  33. package/dist/cjs/lib/v3/llm/GroqClient.js +1 -1
  34. package/dist/cjs/lib/v3/llm/GroqClient.js.map +1 -1
  35. package/dist/cjs/lib/v3/types/private/agent.d.ts +5 -0
  36. package/dist/cjs/lib/v3/types/private/agent.js +11 -0
  37. package/dist/cjs/lib/v3/types/private/agent.js.map +1 -1
  38. package/dist/cjs/lib/v3/types/private/handlers.d.ts +1 -0
  39. package/dist/cjs/lib/v3/types/private/handlers.js.map +1 -1
  40. package/dist/cjs/lib/v3/types/private/snapshot.d.ts +8 -0
  41. package/dist/cjs/lib/v3/types/private/snapshot.js.map +1 -1
  42. package/dist/cjs/lib/v3/types/public/agent.d.ts +2 -3
  43. package/dist/cjs/lib/v3/types/public/agent.js +3 -0
  44. package/dist/cjs/lib/v3/types/public/agent.js.map +1 -1
  45. package/dist/cjs/lib/v3/types/public/api.d.ts +5 -1
  46. package/dist/cjs/lib/v3/types/public/api.js +15 -2
  47. package/dist/cjs/lib/v3/types/public/api.js.map +1 -1
  48. package/dist/cjs/lib/v3/types/public/methods.d.ts +1 -0
  49. package/dist/cjs/lib/v3/types/public/methods.js.map +1 -1
  50. package/dist/cjs/lib/v3/understudy/a11y/snapshot/a11yTree.js +21 -12
  51. package/dist/cjs/lib/v3/understudy/a11y/snapshot/a11yTree.js.map +1 -1
  52. package/dist/cjs/lib/v3/understudy/a11y/snapshot/capture.d.ts +11 -2
  53. package/dist/cjs/lib/v3/understudy/a11y/snapshot/capture.js +268 -21
  54. package/dist/cjs/lib/v3/understudy/a11y/snapshot/capture.js.map +1 -1
  55. package/dist/cjs/lib/v3/understudy/a11y/snapshot/domTree.js +60 -7
  56. package/dist/cjs/lib/v3/understudy/a11y/snapshot/domTree.js.map +1 -1
  57. package/dist/cjs/lib/v3/understudy/frameRegistry.js +16 -5
  58. package/dist/cjs/lib/v3/understudy/frameRegistry.js.map +1 -1
  59. package/dist/cjs/lib/v3/v3.d.ts +1 -0
  60. package/dist/cjs/lib/v3/v3.js +15 -14
  61. package/dist/cjs/lib/v3/v3.js.map +1 -1
  62. package/dist/cjs/lib/version.d.ts +1 -1
  63. package/dist/cjs/lib/version.js +1 -1
  64. package/dist/cjs/lib/version.js.map +1 -1
  65. package/dist/cjs/tests/integration/observe-element-id-format.spec.js +130 -0
  66. package/dist/cjs/tests/integration/observe-element-id-format.spec.js.map +1 -0
  67. package/dist/cjs/tests/unit/agent-mode-routing.test.js +88 -0
  68. package/dist/cjs/tests/unit/agent-mode-routing.test.js.map +1 -0
  69. package/dist/cjs/tests/unit/agent-temperature.test.d.ts +1 -0
  70. package/dist/cjs/tests/unit/agent-temperature.test.js +191 -0
  71. package/dist/cjs/tests/unit/agent-temperature.test.js.map +1 -0
  72. package/dist/cjs/tests/unit/agent-variables-validation.test.d.ts +1 -0
  73. package/dist/cjs/tests/unit/agent-variables-validation.test.js +43 -0
  74. package/dist/cjs/tests/unit/agent-variables-validation.test.js.map +1 -0
  75. package/dist/cjs/tests/unit/api-client-observe-variables.test.js +47 -0
  76. package/dist/cjs/tests/unit/api-client-observe-variables.test.js.map +1 -1
  77. package/dist/cjs/tests/unit/api-optional-model-api-key.test.js +60 -0
  78. package/dist/cjs/tests/unit/api-optional-model-api-key.test.js.map +1 -1
  79. package/dist/cjs/tests/unit/api-variables-schema.test.js +25 -0
  80. package/dist/cjs/tests/unit/api-variables-schema.test.js.map +1 -1
  81. package/dist/cjs/tests/unit/frame-registry-oopif-adoption.test.d.ts +1 -0
  82. package/dist/cjs/tests/unit/frame-registry-oopif-adoption.test.js +60 -0
  83. package/dist/cjs/tests/unit/frame-registry-oopif-adoption.test.js.map +1 -0
  84. package/dist/cjs/tests/unit/inference-temperature.test.d.ts +1 -0
  85. package/dist/cjs/tests/unit/inference-temperature.test.js +65 -0
  86. package/dist/cjs/tests/unit/inference-temperature.test.js.map +1 -0
  87. package/dist/cjs/tests/unit/openai-compatible-temperature.test.d.ts +1 -0
  88. package/dist/cjs/tests/unit/openai-compatible-temperature.test.js +84 -0
  89. package/dist/cjs/tests/unit/openai-compatible-temperature.test.js.map +1 -0
  90. package/dist/cjs/tests/unit/prompt-observe-variables.test.js +6 -0
  91. package/dist/cjs/tests/unit/prompt-observe-variables.test.js.map +1 -1
  92. package/dist/cjs/tests/unit/public-api/llm-and-agents.test.js +3 -0
  93. package/dist/cjs/tests/unit/public-api/llm-and-agents.test.js.map +1 -1
  94. package/dist/cjs/tests/unit/public-api/public-types.test.js.map +1 -1
  95. package/dist/cjs/tests/unit/snapshot-a11y-resolvers.test.js +106 -5
  96. package/dist/cjs/tests/unit/snapshot-a11y-resolvers.test.js.map +1 -1
  97. package/dist/cjs/tests/unit/snapshot-a11y-tree-utils.test.js +20 -0
  98. package/dist/cjs/tests/unit/snapshot-a11y-tree-utils.test.js.map +1 -1
  99. package/dist/cjs/tests/unit/snapshot-capture-orchestration.test.js +119 -9
  100. package/dist/cjs/tests/unit/snapshot-capture-orchestration.test.js.map +1 -1
  101. package/dist/esm/lib/inference.js +1 -8
  102. package/dist/esm/lib/inference.js.map +1 -1
  103. package/dist/esm/lib/prompt.js +3 -1
  104. package/dist/esm/lib/prompt.js.map +1 -1
  105. package/dist/esm/lib/v3/agent/AgentProvider.js +3 -0
  106. package/dist/esm/lib/v3/agent/AgentProvider.js.map +1 -1
  107. package/dist/esm/lib/v3/agent/tools/fillFormVision.js +16 -12
  108. package/dist/esm/lib/v3/agent/tools/fillFormVision.js.map +1 -1
  109. package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.js +0 -4
  110. package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.js.map +1 -1
  111. package/dist/esm/lib/v3/api.d.ts +1 -0
  112. package/dist/esm/lib/v3/api.js +15 -3
  113. package/dist/esm/lib/v3/api.js.map +1 -1
  114. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js +12 -12
  115. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js.map +1 -1
  116. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js +48 -48
  117. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js.map +1 -1
  118. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.d.ts +1 -1
  119. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js +1 -1
  120. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js.map +1 -1
  121. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js +2 -2
  122. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js.map +1 -1
  123. package/dist/esm/lib/v3/dom/build/scriptV3Content.d.ts +1 -1
  124. package/dist/esm/lib/v3/dom/build/scriptV3Content.js +1 -1
  125. package/dist/esm/lib/v3/dom/build/scriptV3Content.js.map +1 -1
  126. package/dist/esm/lib/v3/handlers/extractHandler.js +3 -1
  127. package/dist/esm/lib/v3/handlers/extractHandler.js.map +1 -1
  128. package/dist/esm/lib/v3/handlers/v3AgentHandler.js +3 -5
  129. package/dist/esm/lib/v3/handlers/v3AgentHandler.js.map +1 -1
  130. package/dist/esm/lib/v3/index.d.ts +1 -1
  131. package/dist/esm/lib/v3/llm/CerebrasClient.js +1 -1
  132. package/dist/esm/lib/v3/llm/CerebrasClient.js.map +1 -1
  133. package/dist/esm/lib/v3/llm/GroqClient.js +1 -1
  134. package/dist/esm/lib/v3/llm/GroqClient.js.map +1 -1
  135. package/dist/esm/lib/v3/types/private/agent.d.ts +5 -0
  136. package/dist/esm/lib/v3/types/private/agent.js +10 -1
  137. package/dist/esm/lib/v3/types/private/agent.js.map +1 -1
  138. package/dist/esm/lib/v3/types/private/handlers.d.ts +1 -0
  139. package/dist/esm/lib/v3/types/private/handlers.js.map +1 -1
  140. package/dist/esm/lib/v3/types/private/snapshot.d.ts +8 -0
  141. package/dist/esm/lib/v3/types/private/snapshot.js.map +1 -1
  142. package/dist/esm/lib/v3/types/public/agent.d.ts +2 -3
  143. package/dist/esm/lib/v3/types/public/agent.js +3 -0
  144. package/dist/esm/lib/v3/types/public/agent.js.map +1 -1
  145. package/dist/esm/lib/v3/types/public/api.d.ts +5 -1
  146. package/dist/esm/lib/v3/types/public/api.js +15 -2
  147. package/dist/esm/lib/v3/types/public/api.js.map +1 -1
  148. package/dist/esm/lib/v3/types/public/methods.d.ts +1 -0
  149. package/dist/esm/lib/v3/types/public/methods.js.map +1 -1
  150. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js +21 -12
  151. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js.map +1 -1
  152. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.d.ts +11 -2
  153. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js +267 -22
  154. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js.map +1 -1
  155. package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.js +60 -7
  156. package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.js.map +1 -1
  157. package/dist/esm/lib/v3/understudy/frameRegistry.js +16 -5
  158. package/dist/esm/lib/v3/understudy/frameRegistry.js.map +1 -1
  159. package/dist/esm/lib/v3/v3.d.ts +1 -0
  160. package/dist/esm/lib/v3/v3.js +15 -14
  161. package/dist/esm/lib/v3/v3.js.map +1 -1
  162. package/dist/esm/lib/version.d.ts +1 -1
  163. package/dist/esm/lib/version.js +1 -1
  164. package/dist/esm/lib/version.js.map +1 -1
  165. package/dist/esm/tests/integration/observe-element-id-format.spec.d.ts +1 -0
  166. package/dist/esm/tests/integration/observe-element-id-format.spec.js +128 -0
  167. package/dist/esm/tests/integration/observe-element-id-format.spec.js.map +1 -0
  168. package/dist/esm/tests/unit/agent-mode-routing.test.d.ts +1 -0
  169. package/dist/esm/tests/unit/agent-mode-routing.test.js +86 -0
  170. package/dist/esm/tests/unit/agent-mode-routing.test.js.map +1 -0
  171. package/dist/esm/tests/unit/agent-temperature.test.d.ts +1 -0
  172. package/dist/esm/tests/unit/agent-temperature.test.js +189 -0
  173. package/dist/esm/tests/unit/agent-temperature.test.js.map +1 -0
  174. package/dist/esm/tests/unit/agent-variables-validation.test.d.ts +1 -0
  175. package/dist/esm/tests/unit/agent-variables-validation.test.js +41 -0
  176. package/dist/esm/tests/unit/agent-variables-validation.test.js.map +1 -0
  177. package/dist/esm/tests/unit/api-client-observe-variables.test.js +47 -0
  178. package/dist/esm/tests/unit/api-client-observe-variables.test.js.map +1 -1
  179. package/dist/esm/tests/unit/api-optional-model-api-key.test.js +60 -0
  180. package/dist/esm/tests/unit/api-optional-model-api-key.test.js.map +1 -1
  181. package/dist/esm/tests/unit/api-variables-schema.test.js +25 -0
  182. package/dist/esm/tests/unit/api-variables-schema.test.js.map +1 -1
  183. package/dist/esm/tests/unit/frame-registry-oopif-adoption.test.d.ts +1 -0
  184. package/dist/esm/tests/unit/frame-registry-oopif-adoption.test.js +58 -0
  185. package/dist/esm/tests/unit/frame-registry-oopif-adoption.test.js.map +1 -0
  186. package/dist/esm/tests/unit/inference-temperature.test.d.ts +1 -0
  187. package/dist/esm/tests/unit/inference-temperature.test.js +63 -0
  188. package/dist/esm/tests/unit/inference-temperature.test.js.map +1 -0
  189. package/dist/esm/tests/unit/openai-compatible-temperature.test.d.ts +1 -0
  190. package/dist/esm/tests/unit/openai-compatible-temperature.test.js +82 -0
  191. package/dist/esm/tests/unit/openai-compatible-temperature.test.js.map +1 -0
  192. package/dist/esm/tests/unit/prompt-observe-variables.test.js +6 -0
  193. package/dist/esm/tests/unit/prompt-observe-variables.test.js.map +1 -1
  194. package/dist/esm/tests/unit/public-api/llm-and-agents.test.js +3 -0
  195. package/dist/esm/tests/unit/public-api/llm-and-agents.test.js.map +1 -1
  196. package/dist/esm/tests/unit/public-api/public-types.test.js.map +1 -1
  197. package/dist/esm/tests/unit/snapshot-a11y-resolvers.test.js +106 -5
  198. package/dist/esm/tests/unit/snapshot-a11y-resolvers.test.js.map +1 -1
  199. package/dist/esm/tests/unit/snapshot-a11y-tree-utils.test.js +20 -0
  200. package/dist/esm/tests/unit/snapshot-a11y-tree-utils.test.js.map +1 -1
  201. package/dist/esm/tests/unit/snapshot-capture-orchestration.test.js +119 -9
  202. package/dist/esm/tests/unit/snapshot-capture-orchestration.test.js.map +1 -1
  203. package/package.json +1 -1
  204. package/dist/cjs/tests/integration/agent-captcha-autosolve.spec.js +0 -56
  205. package/dist/cjs/tests/integration/agent-captcha-autosolve.spec.js.map +0 -1
  206. package/dist/esm/tests/integration/agent-captcha-autosolve.spec.js +0 -54
  207. package/dist/esm/tests/integration/agent-captcha-autosolve.spec.js.map +0 -1
  208. /package/dist/cjs/tests/integration/{agent-captcha-autosolve.spec.d.ts → observe-element-id-format.spec.d.ts} +0 -0
  209. /package/dist/{esm/tests/integration/agent-captcha-autosolve.spec.d.ts → cjs/tests/unit/agent-mode-routing.test.d.ts} +0 -0
@@ -7,6 +7,11 @@ export type SnapshotOptions = {
7
7
  * Supports XPath (prefixed with `xpath=` or starting with `/`) and CSS with iframe hops via `>>`.
8
8
  */
9
9
  focusSelector?: string;
10
+ /**
11
+ * Exclude matching elements and their descendants from the captured snapshot.
12
+ * Each selector may be XPath (prefixed with `xpath=` or starting with `/`) or CSS.
13
+ */
14
+ ignoreSelectors?: string[];
10
15
  /**
11
16
  * Pierce shadow DOM when calling DOM.getDocument. Defaults to true to retain the
12
17
  * existing behaviour.
@@ -51,6 +56,8 @@ export type SessionDomIndex = {
51
56
  scrollByBe: Map<number, boolean>;
52
57
  docRootOf: Map<number, number>;
53
58
  contentDocRootByIframe: Map<number, number>;
59
+ enterByBe: Map<number, number>;
60
+ exitByBe: Map<number, number>;
54
61
  };
55
62
  export type FrameDomMaps = {
56
63
  tagNameMap: Record<string, string>;
@@ -93,6 +100,7 @@ export type A11yNode = {
93
100
  };
94
101
  export type A11yOptions = {
95
102
  focusSelector?: string;
103
+ isIgnoredBackendNode?: (backendNodeId: number) => boolean;
96
104
  experimental: boolean;
97
105
  tagNameMap: Record<string, string>;
98
106
  scrollableMap: Record<string, boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../../../../lib/v3/types/private/snapshot.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options that control how hybrid snapshots and targeted scopes are captured.\n */\nexport type SnapshotOptions = {\n /**\n * Filter the snapshot to a specific element/subtree using a selector that can cross iframes.\n * Supports XPath (prefixed with `xpath=` or starting with `/`) and CSS with iframe hops via `>>`.\n */\n focusSelector?: string;\n /**\n * Pierce shadow DOM when calling DOM.getDocument. Defaults to true to retain the\n * existing behaviour.\n */\n pierceShadow?: boolean;\n /**\n * Toggle whether iframe subtrees are included in the merged snapshot. Defaults to true.\n */\n includeIframes?: boolean;\n /**\n * Optional feature flag that surfaces experimental traversal tweaks in the Accessibility layer.\n */\n experimental?: boolean;\n};\n\n/**\n * Hybrid snapshot payload consumed by act/extract/observe handlers.\n */\nexport type HybridSnapshot = {\n /** Merged outline across every frame. */\n combinedTree: string;\n /** EncodedId (frameOrdinal-backendNodeId) -> absolute XPath. */\n combinedXpathMap: Record<string, string>;\n /** EncodedId -> URL extracted from AX properties. */\n combinedUrlMap: Record<string, string>;\n /** Per-frame payloads expose the original relative data for debugging. */\n perFrame?: PerFrameSnapshot[];\n};\n\nexport type PerFrameSnapshot = {\n frameId: string;\n outline: string;\n xpathMap: Record<string, string>;\n urlMap: Record<string, string>;\n};\n\n/**\n * Compact encoding of DOM data for an entire session. Shared between capture\n * and focus helpers so DOM traversal can be unit tested in isolation.\n */\nexport type SessionDomIndex = {\n rootBackend: number;\n absByBe: Map<number, string>;\n tagByBe: Map<number, string>;\n scrollByBe: Map<number, boolean>;\n docRootOf: Map<number, number>;\n contentDocRootByIframe: Map<number, number>;\n};\n\nexport type FrameDomMaps = {\n tagNameMap: Record<string, string>;\n xpathMap: Record<string, string>;\n scrollableMap: Record<string, boolean>;\n urlMap: Record<string, string>;\n};\n\nexport type ResolvedLocation = {\n frameId: string;\n backendNodeId: number;\n absoluteXPath: string;\n};\n\nexport type ResolvedFocusFrame = {\n targetFrameId: string;\n tailXPath: string;\n absPrefix: string;\n};\n\nexport type ResolvedCssFocus = {\n targetFrameId: string;\n tailSelector: string;\n absPrefix: string;\n};\n\nexport type Axis = \"child\" | \"desc\";\n\nexport type Step = {\n axis: Axis;\n raw: string;\n name: string;\n};\n\nexport type A11yNode = {\n role: string;\n name?: string;\n description?: string;\n value?: string | number | boolean;\n nodeId: string;\n backendDOMNodeId?: number;\n parentId?: string;\n childIds?: string[];\n children?: A11yNode[];\n encodedId?: string;\n};\n\nexport type A11yOptions = {\n focusSelector?: string;\n experimental: boolean;\n tagNameMap: Record<string, string>;\n scrollableMap: Record<string, boolean>;\n encode: (backendNodeId: number) => string;\n};\n\nexport type AccessibilityTreeResult = {\n outline: string;\n urlMap: Record<string, string>;\n scopeApplied: boolean;\n};\n\nexport type FrameParentIndex = Map<string, string | null>;\n\n/**\n * Shared frame metadata that every snapshot step needs.\n * - `rootId`: stable identifier for the main frame so we can detect root prefixes.\n * - `parentByFrame`: lookup table for iframe parentage (used by focus scoping and prefixing).\n * - `frames`: DFS-ordered frame ids so merging walks parents before children.\n */\nexport type FrameContext = {\n rootId: string;\n parentByFrame: FrameParentIndex;\n frames: string[];\n};\n"]}
1
+ {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../../../../lib/v3/types/private/snapshot.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options that control how hybrid snapshots and targeted scopes are captured.\n */\nexport type SnapshotOptions = {\n /**\n * Filter the snapshot to a specific element/subtree using a selector that can cross iframes.\n * Supports XPath (prefixed with `xpath=` or starting with `/`) and CSS with iframe hops via `>>`.\n */\n focusSelector?: string;\n /**\n * Exclude matching elements and their descendants from the captured snapshot.\n * Each selector may be XPath (prefixed with `xpath=` or starting with `/`) or CSS.\n */\n ignoreSelectors?: string[];\n /**\n * Pierce shadow DOM when calling DOM.getDocument. Defaults to true to retain the\n * existing behaviour.\n */\n pierceShadow?: boolean;\n /**\n * Toggle whether iframe subtrees are included in the merged snapshot. Defaults to true.\n */\n includeIframes?: boolean;\n /**\n * Optional feature flag that surfaces experimental traversal tweaks in the Accessibility layer.\n */\n experimental?: boolean;\n};\n\n/**\n * Hybrid snapshot payload consumed by act/extract/observe handlers.\n */\nexport type HybridSnapshot = {\n /** Merged outline across every frame. */\n combinedTree: string;\n /** EncodedId (frameOrdinal-backendNodeId) -> absolute XPath. */\n combinedXpathMap: Record<string, string>;\n /** EncodedId -> URL extracted from AX properties. */\n combinedUrlMap: Record<string, string>;\n /** Per-frame payloads expose the original relative data for debugging. */\n perFrame?: PerFrameSnapshot[];\n};\n\nexport type PerFrameSnapshot = {\n frameId: string;\n outline: string;\n xpathMap: Record<string, string>;\n urlMap: Record<string, string>;\n};\n\n/**\n * Compact encoding of DOM data for an entire session. Shared between capture\n * and focus helpers so DOM traversal can be unit tested in isolation.\n */\nexport type SessionDomIndex = {\n rootBackend: number;\n absByBe: Map<number, string>;\n tagByBe: Map<number, string>;\n scrollByBe: Map<number, boolean>;\n docRootOf: Map<number, number>;\n contentDocRootByIframe: Map<number, number>;\n enterByBe: Map<number, number>;\n exitByBe: Map<number, number>;\n};\n\nexport type FrameDomMaps = {\n tagNameMap: Record<string, string>;\n xpathMap: Record<string, string>;\n scrollableMap: Record<string, boolean>;\n urlMap: Record<string, string>;\n};\n\nexport type ResolvedLocation = {\n frameId: string;\n backendNodeId: number;\n absoluteXPath: string;\n};\n\nexport type ResolvedFocusFrame = {\n targetFrameId: string;\n tailXPath: string;\n absPrefix: string;\n};\n\nexport type ResolvedCssFocus = {\n targetFrameId: string;\n tailSelector: string;\n absPrefix: string;\n};\n\nexport type Axis = \"child\" | \"desc\";\n\nexport type Step = {\n axis: Axis;\n raw: string;\n name: string;\n};\n\nexport type A11yNode = {\n role: string;\n name?: string;\n description?: string;\n value?: string | number | boolean;\n nodeId: string;\n backendDOMNodeId?: number;\n parentId?: string;\n childIds?: string[];\n children?: A11yNode[];\n encodedId?: string;\n};\n\nexport type A11yOptions = {\n focusSelector?: string;\n isIgnoredBackendNode?: (backendNodeId: number) => boolean;\n experimental: boolean;\n tagNameMap: Record<string, string>;\n scrollableMap: Record<string, boolean>;\n encode: (backendNodeId: number) => string;\n};\n\nexport type AccessibilityTreeResult = {\n outline: string;\n urlMap: Record<string, string>;\n scopeApplied: boolean;\n};\n\nexport type FrameParentIndex = Map<string, string | null>;\n\n/**\n * Shared frame metadata that every snapshot step needs.\n * - `rootId`: stable identifier for the main frame so we can detect root prefixes.\n * - `parentByFrame`: lookup table for iframe parentage (used by focus scoping and prefixing).\n * - `frames`: DFS-ordered frame ids so merging walks parents before children.\n */\nexport type FrameContext = {\n rootId: string;\n parentByFrame: FrameParentIndex;\n frames: string[];\n};\n"]}
@@ -334,9 +334,8 @@ export interface AgentExecuteOptionsBase {
334
334
  *
335
335
  * Accepts both simple values and rich objects with descriptions (same type as `act`).
336
336
  *
337
- * **Note:** Not supported in CUA mode (`mode: "cua"`). Requires `experimental: true`.
337
+ * **Note:** Not supported in CUA mode (`mode: "cua"`).
338
338
  *
339
- * @experimental
340
339
  * @example
341
340
  * ```typescript
342
341
  * // Simple values
@@ -397,7 +396,7 @@ export interface AgentStreamExecuteOptions extends AgentExecuteOptionsBase {
397
396
  callbacks?: AgentStreamCallbacks;
398
397
  }
399
398
  export type AgentType = "openai" | "anthropic" | "google" | "microsoft" | "bedrock";
400
- export declare const AVAILABLE_CUA_MODELS: readonly ["openai/gpt-5.4", "openai/computer-use-preview", "openai/computer-use-preview-2025-03-11", "anthropic/claude-opus-4-5-20251101", "anthropic/claude-opus-4-6", "anthropic/claude-sonnet-4-6", "anthropic/claude-haiku-4-5-20251001", "anthropic/claude-sonnet-4-20250514", "anthropic/claude-sonnet-4-5-20250929", "google/gemini-2.5-computer-use-preview-10-2025", "google/gemini-3-flash-preview", "google/gemini-3-pro-preview", "microsoft/fara-7b"];
399
+ export declare const AVAILABLE_CUA_MODELS: readonly ["openai/gpt-5.4", "openai/gpt-5.4-mini", "openai/gpt-5.5", "openai/computer-use-preview", "openai/computer-use-preview-2025-03-11", "anthropic/claude-opus-4-5-20251101", "anthropic/claude-opus-4-6", "anthropic/claude-sonnet-4-6", "anthropic/claude-haiku-4-5", "anthropic/claude-haiku-4-5-20251001", "anthropic/claude-sonnet-4-20250514", "anthropic/claude-sonnet-4-5-20250929", "google/gemini-2.5-computer-use-preview-10-2025", "google/gemini-3-flash-preview", "google/gemini-3-pro-preview", "microsoft/fara-7b"];
401
400
  export type AvailableCuaModel = (typeof AVAILABLE_CUA_MODELS)[number];
402
401
  export interface AgentExecutionOptions<TOptions extends AgentExecuteOptions = AgentExecuteOptions> {
403
402
  options: TOptions;
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AVAILABLE_CUA_MODELS = void 0;
4
4
  exports.AVAILABLE_CUA_MODELS = [
5
5
  "openai/gpt-5.4",
6
+ "openai/gpt-5.4-mini",
7
+ "openai/gpt-5.5",
6
8
  "openai/computer-use-preview",
7
9
  "openai/computer-use-preview-2025-03-11",
8
10
  "anthropic/claude-opus-4-5-20251101",
9
11
  "anthropic/claude-opus-4-6",
10
12
  "anthropic/claude-sonnet-4-6",
13
+ "anthropic/claude-haiku-4-5",
11
14
  "anthropic/claude-haiku-4-5-20251001",
12
15
  "anthropic/claude-sonnet-4-20250514",
13
16
  "anthropic/claude-sonnet-4-5-20250929",
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../../../../lib/v3/types/public/agent.ts"],"names":[],"mappings":";;;AAkca,QAAA,oBAAoB,GAAG;IAClC,gBAAgB;IAChB,6BAA6B;IAC7B,wCAAwC;IACxC,oCAAoC;IACpC,2BAA2B;IAC3B,6BAA6B;IAC7B,qCAAqC;IACrC,oCAAoC;IACpC,sCAAsC;IACtC,gDAAgD;IAChD,+BAA+B;IAC/B,6BAA6B;IAC7B,mBAAmB;CACX,CAAC","sourcesContent":["import type { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport {\n ToolSet,\n ModelMessage,\n wrapLanguageModel,\n StreamTextResult,\n StepResult,\n PrepareStepFunction,\n GenerateTextOnStepFinishCallback,\n StreamTextOnStepFinishCallback,\n StreamTextOnErrorCallback,\n StreamTextOnChunkCallback,\n StreamTextOnFinishCallback,\n} from \"ai\";\nimport { LogLine } from \"./logs.js\";\nimport { ClientOptions } from \"./model.js\";\nimport { StagehandZodObject } from \"../../zodCompat.js\";\n\n// Re-export ModelMessage for consumers who want to use it for conversation continuation\nexport type { ModelMessage } from \"ai\";\n\n// Re-export Tool type for consumers who want to define custom tools\nexport type { Tool } from \"ai\";\nimport { Page as PlaywrightPage } from \"playwright-core\";\nimport { Page as PuppeteerPage } from \"puppeteer-core\";\nimport { Page as PatchrightPage } from \"patchright-core\";\nimport { Page } from \"../../understudy/page.js\";\n\n// =============================================================================\n// Variable Types\n// =============================================================================\n\n/**\n * A variable value can be a simple primitive or a rich object with an optional description.\n * This unified type is shared across `act`, `agent.execute`, and other methods.\n *\n * @example Simple (backward-compatible):\n * ```typescript\n * variables: { username: \"john@example.com\" }\n * ```\n *\n * @example Rich with description (useful for agents):\n * ```typescript\n * variables: {\n * username: { value: \"john@example.com\", description: \"The login email\" }\n * }\n * ```\n */\nexport type VariableValue =\n | string\n | number\n | boolean\n | { value: string | number | boolean; description?: string };\n\n/**\n * A collection of named variables for use in act, agent, and other methods.\n */\nexport type Variables = Record<string, VariableValue>;\n\nexport interface AgentContext {\n options: AgentExecuteOptionsBase;\n maxSteps: number;\n systemPrompt: string;\n allTools: ToolSet;\n messages: ModelMessage[];\n wrappedModel: ReturnType<typeof wrapLanguageModel>;\n initialPageUrl: string;\n}\n\nexport interface AgentState {\n collectedReasoning: string[];\n actions: AgentAction[];\n finalMessage: string;\n completed: boolean;\n currentPageUrl: string;\n}\n\nexport interface AgentAction {\n type: string;\n reasoning?: string;\n taskCompleted?: boolean;\n action?: string;\n // Tool-specific fields\n timeMs?: number; // wait tool\n pageText?: string; // ariaTree tool\n pageUrl?: string; // ariaTree tool\n instruction?: string; // various tools\n [key: string]: unknown;\n}\n\nexport interface AgentResult {\n success: boolean;\n message: string;\n actions: AgentAction[];\n completed: boolean;\n metadata?: Record<string, unknown>;\n usage?: {\n input_tokens: number;\n output_tokens: number;\n reasoning_tokens?: number;\n cached_input_tokens?: number;\n inference_time_ms: number;\n };\n /**\n * The conversation messages from this execution.\n * Pass these to a subsequent execute() call via the `messages` option to continue the conversation.\n * @experimental\n */\n messages?: ModelMessage[];\n /**\n * Custom output data extracted based on the `output` schema provided in execute options.\n * Only populated if an `output` schema was provided.\n * @experimental\n */\n output?: Record<string, unknown>;\n}\n\nexport type AgentStreamResult = StreamTextResult<ToolSet, never> & {\n result: Promise<AgentResult>;\n};\n\n/**\n * Base callbacks shared between execute (non-streaming) and streaming modes.\n */\nexport interface AgentCallbacks {\n /**\n * Optional function called before each step to modify settings.\n * You can change the model, tool choices, active tools, system prompt,\n * and input messages for each step.\n */\n prepareStep?: PrepareStepFunction<ToolSet>;\n /**\n * Callback called when each step (LLM call) is finished.\n * This is called for intermediate steps as well as the final step.\n */\n onStepFinish?:\n | GenerateTextOnStepFinishCallback<ToolSet>\n | StreamTextOnStepFinishCallback<ToolSet>;\n}\n\n/**\n * Error message type for streaming-only callbacks used in non-streaming mode.\n * This provides a clear error message when users try to use streaming callbacks without stream: true.\n */\ntype StreamingCallbackNotAvailable =\n \"This callback requires 'stream: true' in AgentConfig. Set stream: true to use streaming callbacks like onChunk, onFinish, onError, and onAbort.\";\n\n/**\n * Error message for safety confirmation callback misuse.\n * Safety confirmations are only available for non-streaming CUA agent executions.\n */\ntype SafetyConfirmationCallbackNotAvailable =\n \"Safety confirmation callbacks are only available via non-streaming AgentExecuteOptions.callbacks when using mode: 'cua'.\";\n\n/**\n * Callbacks specific to the non-streaming execute method.\n */\nexport interface AgentExecuteCallbacks extends AgentCallbacks {\n /**\n * Callback called when each step (LLM call) is finished.\n */\n onStepFinish?: GenerateTextOnStepFinishCallback<ToolSet>;\n /**\n * Callback for handling safety confirmation requests from CUA providers.\n * Only available when running an agent configured with mode: \"cua\".\n */\n onSafetyConfirmation?: SafetyConfirmationHandler;\n\n /**\n * NOT AVAILABLE in non-streaming mode.\n * This callback requires `stream: true` in AgentConfig.\n *\n * @example\n * ```typescript\n * // Enable streaming to use onChunk:\n * const agent = stagehand.agent({ stream: true });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: { onChunk: async (chunk) => console.log(chunk) }\n * });\n * ```\n */\n onChunk?: StreamingCallbackNotAvailable;\n\n /**\n * NOT AVAILABLE in non-streaming mode.\n * This callback requires `stream: true` in AgentConfig.\n *\n * @example\n * ```typescript\n * // Enable streaming to use onFinish:\n * const agent = stagehand.agent({ stream: true });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: { onFinish: (event) => console.log(\"Done!\", event) }\n * });\n * ```\n */\n onFinish?: StreamingCallbackNotAvailable;\n\n /**\n * NOT AVAILABLE in non-streaming mode.\n * This callback requires `stream: true` in AgentConfig.\n *\n * @example\n * ```typescript\n * // Enable streaming to use onError:\n * const agent = stagehand.agent({ stream: true });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: { onError: ({ error }) => console.error(error) }\n * });\n * ```\n */\n onError?: StreamingCallbackNotAvailable;\n\n /**\n * NOT AVAILABLE in non-streaming mode.\n * This callback requires `stream: true` in AgentConfig.\n *\n * @example\n * ```typescript\n * // Enable streaming to use onAbort:\n * const agent = stagehand.agent({ stream: true });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: { onAbort: (event) => console.log(\"Aborted\", event.steps) }\n * });\n * ```\n */\n onAbort?: StreamingCallbackNotAvailable;\n}\n\n/**\n * Callbacks specific to the streaming mode.\n */\nexport interface AgentStreamCallbacks extends AgentCallbacks {\n /**\n * Callback called when each step (LLM call) is finished during streaming.\n */\n onStepFinish?: StreamTextOnStepFinishCallback<ToolSet>;\n /**\n * Callback called when an error occurs during streaming.\n * Use this to log errors or handle error states.\n */\n onError?: StreamTextOnErrorCallback;\n /**\n * Callback called for each chunk of the stream.\n * Stream processing will pause until the callback promise resolves.\n */\n onChunk?: StreamTextOnChunkCallback<ToolSet>;\n /**\n * Callback called when the stream finishes.\n */\n onFinish?: StreamTextOnFinishCallback<ToolSet>;\n /**\n * Callback called when the stream is aborted.\n */\n onAbort?: (event: {\n steps: Array<StepResult<ToolSet>>;\n }) => PromiseLike<void> | void;\n /**\n * NOT AVAILABLE in streaming mode.\n * Safety confirmations currently require non-streaming execute() on CUA agents.\n */\n onSafetyConfirmation?: SafetyConfirmationCallbackNotAvailable;\n}\n\n/**\n * Base options for agent execution (without callbacks).\n */\nexport interface AgentExecuteOptionsBase {\n instruction: string;\n maxSteps?: number;\n page?: PlaywrightPage | PuppeteerPage | PatchrightPage | Page;\n highlightCursor?: boolean;\n /**\n * Previous conversation messages to continue from.\n * Pass the `messages` from a previous AgentResult to continue that conversation.\n * @experimental\n */\n messages?: ModelMessage[];\n /**\n * An AbortSignal that can be used to cancel the agent execution.\n * When aborted, the agent will stop and return a partial result.\n * @experimental\n *\n * @example\n * ```typescript\n * const controller = new AbortController();\n * setTimeout(() => controller.abort(), 30000); // 30 second timeout\n *\n * const result = await agent.execute({\n * instruction: \"...\",\n * signal: controller.signal\n * });\n * ```\n */\n signal?: AbortSignal;\n /**\n * Tools to exclude from this execution.\n * Pass an array of tool names to prevent the agent from using those tools.\n *\n * **Note:** Not supported in CUA mode (`mode: \"cua\"`).\n *\n * **Available tools by mode:**\n *\n * **DOM mode (default):**\n * - `act` - Perform semantic actions (click, type, etc.)\n * - `fillForm` - Fill form fields using DOM selectors\n * - `ariaTree` - Get accessibility tree of the page\n * - `extract` - Extract structured data from page\n * - `goto` - Navigate to a URL\n * - `scroll` - Scroll using semantic directions (up/down/left/right)\n * - `keys` - Press keyboard keys\n * - `navback` - Navigate back in history\n * - `screenshot` - Take a screenshot\n * - `think` - Agent reasoning/planning step\n * - `wait` - Wait for time or condition\n * - `done` - Mark task as complete\n * - `search` - Web search (requires useSearch: true and BROWSERBASE_API_KEY)\n *\n * **Hybrid mode:**\n * - `click` - Click at specific coordinates\n * - `type` - Type text at coordinates\n * - `dragAndDrop` - Drag from one point to another\n * - `clickAndHold` - Click and hold at coordinates\n * - `fillFormVision` - Fill forms using vision/coordinates\n * - `act` - Perform semantic actions\n * - `ariaTree` - Get accessibility tree\n * - `extract` - Extract data from page\n * - `goto` - Navigate to URL\n * - `scroll` - Scroll using coordinates\n * - `keys` - Press keyboard keys\n * - `navback` - Navigate back\n * - `screenshot` - Take screenshot\n * - `think` - Agent reasoning step\n * - `wait` - Wait for time/condition\n * - `done` - Mark task complete\n * - `search` - Web search (requires useSearch: true and BROWSERBASE_API_KEY)\n *\n * @experimental\n * @example\n * ```typescript\n * // Exclude screenshot and extract tools\n * const result = await agent.execute({\n * instruction: \"Click the submit button\",\n * excludeTools: [\"screenshot\", \"extract\"]\n * });\n * ```\n */\n excludeTools?: string[];\n /**\n * A Zod schema defining custom output data to return when the task completes.\n * The agent will populate this data in the final done tool call.\n *\n * @experimental\n * @example\n * ```typescript\n * const result = await agent.execute({\n * instruction: \"Find the cheapest flight from NYC to LA\",\n * output: z.object({\n * price: z.string().describe(\"The price of the flight\"),\n * airline: z.string().describe(\"The airline name\"),\n * departureTime: z.string().describe(\"Departure time\"),\n * }),\n * });\n *\n * console.log(result.output); // { price: \"$199\", airline: \"Delta\", departureTime: \"8:00 AM\" }\n * ```\n */\n output?: StagehandZodObject;\n /**\n * Variables that the agent can use when filling forms or typing text.\n * The agent will see variable names and descriptions in the system prompt,\n * and can use them via `%variableName%` syntax in act/type/fillForm tool calls.\n *\n * Accepts both simple values and rich objects with descriptions (same type as `act`).\n *\n * **Note:** Not supported in CUA mode (`mode: \"cua\"`). Requires `experimental: true`.\n *\n * @experimental\n * @example\n * ```typescript\n * // Simple values\n * variables: { username: \"john@example.com\", password: \"secret123\" }\n *\n * // Rich values with descriptions (helps the agent understand context)\n * variables: {\n * username: { value: \"john@example.com\", description: \"The login email\" },\n * password: { value: \"secret123\", description: \"The login password\" },\n * }\n * ```\n */\n variables?: Variables;\n /**\n * Timeout in milliseconds for each agent tool call.\n * If a tool call exceeds this duration, it will be aborted and\n * reported back to the LLM as a timeout error so it can retry or adjust.\n * For tools that call v3 methods (act, extract, fillForm, ariaTree), the\n * timeout is also forwarded to the underlying v3 call for true cancellation.\n * @default 45000 (45 seconds)\n */\n toolTimeout?: number;\n /**\n * Enable the web search tool powered by Browserbase Search API.\n * Requires a valid Browserbase API key (BROWSERBASE_API_KEY).\n * When set to true, the agent gains access to a `search` tool for web searches.\n *\n * @example\n * ```typescript\n * const result = await agent.execute({\n * instruction: \"Find the latest news about AI\",\n * useSearch: true,\n * });\n * ```\n */\n useSearch?: boolean;\n}\n\n/**\n * Options for non-streaming agent execution.\n * Only accepts AgentExecuteCallbacks (no streaming-specific callbacks like onChunk, onFinish).\n */\nexport interface AgentExecuteOptions extends AgentExecuteOptionsBase {\n /**\n * Callbacks for non-streaming agent execution.\n * For streaming callbacks (onChunk, onFinish, onError, onAbort), use stream: true in AgentConfig.\n */\n callbacks?: AgentExecuteCallbacks;\n}\n\n/**\n * Options for streaming agent execution.\n * Accepts AgentStreamCallbacks including onChunk, onFinish, onError, and onAbort.\n */\nexport interface AgentStreamExecuteOptions extends AgentExecuteOptionsBase {\n /**\n * Callbacks for streaming agent execution.\n * Includes streaming-specific callbacks: onChunk, onFinish, onError, onAbort.\n */\n callbacks?: AgentStreamCallbacks;\n}\nexport type AgentType =\n | \"openai\"\n | \"anthropic\"\n | \"google\"\n | \"microsoft\"\n | \"bedrock\";\n\nexport const AVAILABLE_CUA_MODELS = [\n \"openai/gpt-5.4\",\n \"openai/computer-use-preview\",\n \"openai/computer-use-preview-2025-03-11\",\n \"anthropic/claude-opus-4-5-20251101\",\n \"anthropic/claude-opus-4-6\",\n \"anthropic/claude-sonnet-4-6\",\n \"anthropic/claude-haiku-4-5-20251001\",\n \"anthropic/claude-sonnet-4-20250514\",\n \"anthropic/claude-sonnet-4-5-20250929\",\n \"google/gemini-2.5-computer-use-preview-10-2025\",\n \"google/gemini-3-flash-preview\",\n \"google/gemini-3-pro-preview\",\n \"microsoft/fara-7b\",\n] as const;\nexport type AvailableCuaModel = (typeof AVAILABLE_CUA_MODELS)[number];\n\nexport interface AgentExecutionOptions<\n TOptions extends AgentExecuteOptions = AgentExecuteOptions,\n> {\n options: TOptions;\n logger: (message: LogLine) => void;\n retries?: number;\n}\n\nexport interface AgentHandlerOptions {\n modelName: string;\n clientOptions?: ClientOptions;\n userProvidedInstructions?: string;\n experimental?: boolean;\n}\n\nexport interface ActionExecutionResult {\n success: boolean;\n error?: string;\n data?: unknown;\n}\n\n/**\n * Represents a safety check that requires user confirmation before proceeding.\n * These are issued by CUA providers (OpenAI, Google) when the agent attempts\n * potentially risky actions.\n */\nexport interface SafetyCheck {\n /** Unique identifier for this safety check */\n id: string;\n /** Code identifying the type of safety concern */\n code: string;\n /** Human-readable description of the safety concern */\n message: string;\n}\n\n/**\n * Response from the user for a safety confirmation request.\n */\nexport interface SafetyConfirmationResponse {\n /** Whether the user acknowledged/approved the safety checks */\n acknowledged: boolean;\n}\n\n/**\n * Callback for handling safety confirmation requests.\n * Called when the CUA provider issues safety checks that require user confirmation.\n * The callback should return a promise that resolves when the user has made a decision.\n *\n * @param safetyChecks - Array of safety checks requiring confirmation\n * @returns Promise resolving to the user's response\n *\n * @example\n * ```typescript\n * const agent = stagehand.agent({\n * mode: \"cua\",\n * });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: {\n * onSafetyConfirmation: async (checks) => {\n * console.log(\"Safety checks:\", checks);\n * const userApproved = await showConfirmationDialog(checks);\n * return { acknowledged: userApproved };\n * },\n * },\n * });\n * ```\n */\nexport type SafetyConfirmationHandler = (\n safetyChecks: SafetyCheck[],\n) => Promise<SafetyConfirmationResponse>;\n\n// Anthropic types:\n\nexport interface ToolUseItem extends ResponseItem {\n type: \"tool_use\";\n id: string; // This is the correct property name from Anthropic's API\n name: string; // Name of the tool being used\n input: Record<string, unknown>;\n}\n\nexport interface AnthropicMessage {\n role: string;\n content: string | Array<AnthropicContentBlock>;\n}\n\nexport interface AnthropicContentBlock {\n type: string;\n [key: string]: unknown;\n}\n\nexport interface AnthropicTextBlock extends AnthropicContentBlock {\n type: \"text\";\n text: string;\n}\n\nexport interface AnthropicToolResult {\n type: \"tool_result\";\n tool_use_id: string;\n content: string | Array<AnthropicContentBlock>;\n}\n\n// OpenAI types:\n\nexport interface ResponseItem {\n type: string;\n id: string;\n [key: string]: unknown;\n}\n\nexport interface ComputerCallItem extends ResponseItem {\n type: \"computer_call\";\n call_id: string;\n action?: {\n type: string;\n [key: string]: unknown;\n };\n actions?: Array<{\n type: string;\n [key: string]: unknown;\n }>;\n pending_safety_checks?: Array<{\n id: string;\n code: string;\n message: string;\n }>;\n}\n\nexport interface FunctionCallItem extends ResponseItem {\n type: \"function_call\";\n call_id: string;\n name: string;\n arguments: string;\n}\n\nexport type ResponseInputItem =\n | { role: string; content: string }\n | {\n type: \"computer_call_output\";\n call_id: string;\n output:\n | {\n type: \"input_image\" | \"computer_screenshot\";\n image_url: string;\n detail?: \"original\" | \"high\" | \"low\";\n current_url?: string;\n error?: string;\n [key: string]: unknown;\n }\n | string;\n acknowledged_safety_checks?: Array<{\n id: string;\n code: string;\n message: string;\n }>;\n }\n | {\n type: \"function_call_output\";\n call_id: string;\n output: string;\n };\n\nexport interface AgentInstance {\n execute: (\n instructionOrOptions: string | AgentExecuteOptions,\n ) => Promise<AgentResult>;\n}\n\nexport type AgentProviderType = AgentType;\n\nexport type AgentModelConfig<TModelName extends string = string> = {\n modelName: TModelName;\n} & Record<string, unknown>;\n\n/**\n * Agent tool mode determines which set of tools are available to the agent.\n * - 'dom': Uses DOM-based tools (act, fillForm) - better for structured page interactions\n * - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, etc.) - better for visual/screenshot-based interactions\n * - 'cua': Uses Computer Use Agent (CUA) providers like Anthropic Claude or Google Gemini for screenshot-based automation\n */\nexport type AgentToolMode = \"dom\" | \"hybrid\" | \"cua\";\n\nexport type AgentConfig = {\n /**\n * Custom system prompt to provide to the agent. Overrides the default system prompt.\n */\n systemPrompt?: string;\n /**\n * MCP integrations - Array of Client objects\n */\n integrations?: (Client | string)[];\n /**\n * Tools passed to the agent client\n */\n tools?: ToolSet;\n /**\n * @deprecated Use `mode: \"cua\"` instead. This option will be removed in a future version.\n * Enables Computer Use Agent (CUA) mode.\n */\n cua?: boolean;\n /**\n * The model to use for agent functionality\n */\n model?: string | AgentModelConfig<string>;\n /**\n * The model to use for tool execution (observe/act calls within agent tools).\n * If not specified, inherits from the main model configuration.\n * Format: \"provider/model\" (e.g., \"openai/gpt-4o-mini\", \"google/gemini-2.0-flash-exp\")\n */\n executionModel?: string | AgentModelConfig<string>;\n /**\n * Enable streaming mode for the agent.\n * When true, execute() returns AgentStreamResult with textStream for incremental output.\n * When false (default), execute() returns AgentResult after completion.\n */\n stream?: boolean;\n /**\n * Tool mode for the agent. Determines which set of tools are available.\n * - 'dom' (default): Uses DOM-based tools (act, fillForm) for structured interactions\n * - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, clickAndHold, fillFormVision)\n * for visual/screenshot-based interactions\n * - 'cua': Uses Computer Use Agent (CUA) providers for screenshot-based automation\n */\n mode?: AgentToolMode;\n};\n\n/**\n * Agent instance returned when stream: true is set in AgentConfig.\n * execute() returns a streaming result that can be consumed incrementally.\n * Accepts AgentStreamExecuteOptions with streaming-specific callbacks.\n */\nexport interface StreamingAgentInstance {\n execute: (\n instructionOrOptions: string | AgentStreamExecuteOptions,\n ) => Promise<AgentStreamResult>;\n}\n\n/**\n * Agent instance returned when stream is false or not set in AgentConfig.\n * execute() returns a result after the agent completes.\n * Accepts AgentExecuteOptions with non-streaming callbacks only.\n */\nexport interface NonStreamingAgentInstance {\n execute: (\n instructionOrOptions: string | AgentExecuteOptions,\n ) => Promise<AgentResult>;\n}\n\n// =============================================================================\n// Vision Action Tool Result Types\n// =============================================================================\n\n/**\n * Content item type for toModelOutput return values.\n * Used in tool definitions to return text and/or media to the model.\n */\nexport type ModelOutputContentItem =\n | { type: \"text\"; text: string }\n | { type: \"media\"; mediaType: string; data: string };\n\nexport interface ClickToolResult {\n success: boolean;\n describe?: string;\n coordinates?: number[];\n error?: string;\n screenshotBase64?: string;\n}\n\nexport interface TypeToolResult {\n success: boolean;\n describe?: string;\n text?: string;\n error?: string;\n screenshotBase64?: string;\n}\n\nexport interface DragAndDropToolResult {\n success: boolean;\n describe?: string;\n error?: string;\n screenshotBase64?: string;\n}\n\nexport interface FillFormField {\n action: string;\n value: string;\n coordinates: { x: number; y: number };\n}\n\nexport interface FillFormVisionToolResult {\n success: boolean;\n playwrightArguments?: FillFormField[];\n error?: string;\n screenshotBase64?: string;\n}\n\nexport interface ScrollToolResult {\n success: boolean;\n message: string;\n scrolledPixels: number;\n error?: string;\n}\n\nexport interface ScrollVisionToolResult extends ScrollToolResult {\n screenshotBase64?: string;\n}\n\nexport interface WaitToolResult {\n success: boolean;\n waited: number;\n screenshotBase64?: string;\n error?: string;\n}\n"]}
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../../../../lib/v3/types/public/agent.ts"],"names":[],"mappings":";;;AAica,QAAA,oBAAoB,GAAG;IAClC,gBAAgB;IAChB,qBAAqB;IACrB,gBAAgB;IAChB,6BAA6B;IAC7B,wCAAwC;IACxC,oCAAoC;IACpC,2BAA2B;IAC3B,6BAA6B;IAC7B,4BAA4B;IAC5B,qCAAqC;IACrC,oCAAoC;IACpC,sCAAsC;IACtC,gDAAgD;IAChD,+BAA+B;IAC/B,6BAA6B;IAC7B,mBAAmB;CACX,CAAC","sourcesContent":["import type { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport {\n ToolSet,\n ModelMessage,\n wrapLanguageModel,\n StreamTextResult,\n StepResult,\n PrepareStepFunction,\n GenerateTextOnStepFinishCallback,\n StreamTextOnStepFinishCallback,\n StreamTextOnErrorCallback,\n StreamTextOnChunkCallback,\n StreamTextOnFinishCallback,\n} from \"ai\";\nimport { LogLine } from \"./logs.js\";\nimport { ClientOptions } from \"./model.js\";\nimport { StagehandZodObject } from \"../../zodCompat.js\";\n\n// Re-export ModelMessage for consumers who want to use it for conversation continuation\nexport type { ModelMessage } from \"ai\";\n\n// Re-export Tool type for consumers who want to define custom tools\nexport type { Tool } from \"ai\";\nimport { Page as PlaywrightPage } from \"playwright-core\";\nimport { Page as PuppeteerPage } from \"puppeteer-core\";\nimport { Page as PatchrightPage } from \"patchright-core\";\nimport { Page } from \"../../understudy/page.js\";\n\n// =============================================================================\n// Variable Types\n// =============================================================================\n\n/**\n * A variable value can be a simple primitive or a rich object with an optional description.\n * This unified type is shared across `act`, `agent.execute`, and other methods.\n *\n * @example Simple (backward-compatible):\n * ```typescript\n * variables: { username: \"john@example.com\" }\n * ```\n *\n * @example Rich with description (useful for agents):\n * ```typescript\n * variables: {\n * username: { value: \"john@example.com\", description: \"The login email\" }\n * }\n * ```\n */\nexport type VariableValue =\n | string\n | number\n | boolean\n | { value: string | number | boolean; description?: string };\n\n/**\n * A collection of named variables for use in act, agent, and other methods.\n */\nexport type Variables = Record<string, VariableValue>;\n\nexport interface AgentContext {\n options: AgentExecuteOptionsBase;\n maxSteps: number;\n systemPrompt: string;\n allTools: ToolSet;\n messages: ModelMessage[];\n wrappedModel: ReturnType<typeof wrapLanguageModel>;\n initialPageUrl: string;\n}\n\nexport interface AgentState {\n collectedReasoning: string[];\n actions: AgentAction[];\n finalMessage: string;\n completed: boolean;\n currentPageUrl: string;\n}\n\nexport interface AgentAction {\n type: string;\n reasoning?: string;\n taskCompleted?: boolean;\n action?: string;\n // Tool-specific fields\n timeMs?: number; // wait tool\n pageText?: string; // ariaTree tool\n pageUrl?: string; // ariaTree tool\n instruction?: string; // various tools\n [key: string]: unknown;\n}\n\nexport interface AgentResult {\n success: boolean;\n message: string;\n actions: AgentAction[];\n completed: boolean;\n metadata?: Record<string, unknown>;\n usage?: {\n input_tokens: number;\n output_tokens: number;\n reasoning_tokens?: number;\n cached_input_tokens?: number;\n inference_time_ms: number;\n };\n /**\n * The conversation messages from this execution.\n * Pass these to a subsequent execute() call via the `messages` option to continue the conversation.\n * @experimental\n */\n messages?: ModelMessage[];\n /**\n * Custom output data extracted based on the `output` schema provided in execute options.\n * Only populated if an `output` schema was provided.\n * @experimental\n */\n output?: Record<string, unknown>;\n}\n\nexport type AgentStreamResult = StreamTextResult<ToolSet, never> & {\n result: Promise<AgentResult>;\n};\n\n/**\n * Base callbacks shared between execute (non-streaming) and streaming modes.\n */\nexport interface AgentCallbacks {\n /**\n * Optional function called before each step to modify settings.\n * You can change the model, tool choices, active tools, system prompt,\n * and input messages for each step.\n */\n prepareStep?: PrepareStepFunction<ToolSet>;\n /**\n * Callback called when each step (LLM call) is finished.\n * This is called for intermediate steps as well as the final step.\n */\n onStepFinish?:\n | GenerateTextOnStepFinishCallback<ToolSet>\n | StreamTextOnStepFinishCallback<ToolSet>;\n}\n\n/**\n * Error message type for streaming-only callbacks used in non-streaming mode.\n * This provides a clear error message when users try to use streaming callbacks without stream: true.\n */\ntype StreamingCallbackNotAvailable =\n \"This callback requires 'stream: true' in AgentConfig. Set stream: true to use streaming callbacks like onChunk, onFinish, onError, and onAbort.\";\n\n/**\n * Error message for safety confirmation callback misuse.\n * Safety confirmations are only available for non-streaming CUA agent executions.\n */\ntype SafetyConfirmationCallbackNotAvailable =\n \"Safety confirmation callbacks are only available via non-streaming AgentExecuteOptions.callbacks when using mode: 'cua'.\";\n\n/**\n * Callbacks specific to the non-streaming execute method.\n */\nexport interface AgentExecuteCallbacks extends AgentCallbacks {\n /**\n * Callback called when each step (LLM call) is finished.\n */\n onStepFinish?: GenerateTextOnStepFinishCallback<ToolSet>;\n /**\n * Callback for handling safety confirmation requests from CUA providers.\n * Only available when running an agent configured with mode: \"cua\".\n */\n onSafetyConfirmation?: SafetyConfirmationHandler;\n\n /**\n * NOT AVAILABLE in non-streaming mode.\n * This callback requires `stream: true` in AgentConfig.\n *\n * @example\n * ```typescript\n * // Enable streaming to use onChunk:\n * const agent = stagehand.agent({ stream: true });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: { onChunk: async (chunk) => console.log(chunk) }\n * });\n * ```\n */\n onChunk?: StreamingCallbackNotAvailable;\n\n /**\n * NOT AVAILABLE in non-streaming mode.\n * This callback requires `stream: true` in AgentConfig.\n *\n * @example\n * ```typescript\n * // Enable streaming to use onFinish:\n * const agent = stagehand.agent({ stream: true });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: { onFinish: (event) => console.log(\"Done!\", event) }\n * });\n * ```\n */\n onFinish?: StreamingCallbackNotAvailable;\n\n /**\n * NOT AVAILABLE in non-streaming mode.\n * This callback requires `stream: true` in AgentConfig.\n *\n * @example\n * ```typescript\n * // Enable streaming to use onError:\n * const agent = stagehand.agent({ stream: true });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: { onError: ({ error }) => console.error(error) }\n * });\n * ```\n */\n onError?: StreamingCallbackNotAvailable;\n\n /**\n * NOT AVAILABLE in non-streaming mode.\n * This callback requires `stream: true` in AgentConfig.\n *\n * @example\n * ```typescript\n * // Enable streaming to use onAbort:\n * const agent = stagehand.agent({ stream: true });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: { onAbort: (event) => console.log(\"Aborted\", event.steps) }\n * });\n * ```\n */\n onAbort?: StreamingCallbackNotAvailable;\n}\n\n/**\n * Callbacks specific to the streaming mode.\n */\nexport interface AgentStreamCallbacks extends AgentCallbacks {\n /**\n * Callback called when each step (LLM call) is finished during streaming.\n */\n onStepFinish?: StreamTextOnStepFinishCallback<ToolSet>;\n /**\n * Callback called when an error occurs during streaming.\n * Use this to log errors or handle error states.\n */\n onError?: StreamTextOnErrorCallback;\n /**\n * Callback called for each chunk of the stream.\n * Stream processing will pause until the callback promise resolves.\n */\n onChunk?: StreamTextOnChunkCallback<ToolSet>;\n /**\n * Callback called when the stream finishes.\n */\n onFinish?: StreamTextOnFinishCallback<ToolSet>;\n /**\n * Callback called when the stream is aborted.\n */\n onAbort?: (event: {\n steps: Array<StepResult<ToolSet>>;\n }) => PromiseLike<void> | void;\n /**\n * NOT AVAILABLE in streaming mode.\n * Safety confirmations currently require non-streaming execute() on CUA agents.\n */\n onSafetyConfirmation?: SafetyConfirmationCallbackNotAvailable;\n}\n\n/**\n * Base options for agent execution (without callbacks).\n */\nexport interface AgentExecuteOptionsBase {\n instruction: string;\n maxSteps?: number;\n page?: PlaywrightPage | PuppeteerPage | PatchrightPage | Page;\n highlightCursor?: boolean;\n /**\n * Previous conversation messages to continue from.\n * Pass the `messages` from a previous AgentResult to continue that conversation.\n * @experimental\n */\n messages?: ModelMessage[];\n /**\n * An AbortSignal that can be used to cancel the agent execution.\n * When aborted, the agent will stop and return a partial result.\n * @experimental\n *\n * @example\n * ```typescript\n * const controller = new AbortController();\n * setTimeout(() => controller.abort(), 30000); // 30 second timeout\n *\n * const result = await agent.execute({\n * instruction: \"...\",\n * signal: controller.signal\n * });\n * ```\n */\n signal?: AbortSignal;\n /**\n * Tools to exclude from this execution.\n * Pass an array of tool names to prevent the agent from using those tools.\n *\n * **Note:** Not supported in CUA mode (`mode: \"cua\"`).\n *\n * **Available tools by mode:**\n *\n * **DOM mode (default):**\n * - `act` - Perform semantic actions (click, type, etc.)\n * - `fillForm` - Fill form fields using DOM selectors\n * - `ariaTree` - Get accessibility tree of the page\n * - `extract` - Extract structured data from page\n * - `goto` - Navigate to a URL\n * - `scroll` - Scroll using semantic directions (up/down/left/right)\n * - `keys` - Press keyboard keys\n * - `navback` - Navigate back in history\n * - `screenshot` - Take a screenshot\n * - `think` - Agent reasoning/planning step\n * - `wait` - Wait for time or condition\n * - `done` - Mark task as complete\n * - `search` - Web search (requires useSearch: true and BROWSERBASE_API_KEY)\n *\n * **Hybrid mode:**\n * - `click` - Click at specific coordinates\n * - `type` - Type text at coordinates\n * - `dragAndDrop` - Drag from one point to another\n * - `clickAndHold` - Click and hold at coordinates\n * - `fillFormVision` - Fill forms using vision/coordinates\n * - `act` - Perform semantic actions\n * - `ariaTree` - Get accessibility tree\n * - `extract` - Extract data from page\n * - `goto` - Navigate to URL\n * - `scroll` - Scroll using coordinates\n * - `keys` - Press keyboard keys\n * - `navback` - Navigate back\n * - `screenshot` - Take screenshot\n * - `think` - Agent reasoning step\n * - `wait` - Wait for time/condition\n * - `done` - Mark task complete\n * - `search` - Web search (requires useSearch: true and BROWSERBASE_API_KEY)\n *\n * @experimental\n * @example\n * ```typescript\n * // Exclude screenshot and extract tools\n * const result = await agent.execute({\n * instruction: \"Click the submit button\",\n * excludeTools: [\"screenshot\", \"extract\"]\n * });\n * ```\n */\n excludeTools?: string[];\n /**\n * A Zod schema defining custom output data to return when the task completes.\n * The agent will populate this data in the final done tool call.\n *\n * @experimental\n * @example\n * ```typescript\n * const result = await agent.execute({\n * instruction: \"Find the cheapest flight from NYC to LA\",\n * output: z.object({\n * price: z.string().describe(\"The price of the flight\"),\n * airline: z.string().describe(\"The airline name\"),\n * departureTime: z.string().describe(\"Departure time\"),\n * }),\n * });\n *\n * console.log(result.output); // { price: \"$199\", airline: \"Delta\", departureTime: \"8:00 AM\" }\n * ```\n */\n output?: StagehandZodObject;\n /**\n * Variables that the agent can use when filling forms or typing text.\n * The agent will see variable names and descriptions in the system prompt,\n * and can use them via `%variableName%` syntax in act/type/fillForm tool calls.\n *\n * Accepts both simple values and rich objects with descriptions (same type as `act`).\n *\n * **Note:** Not supported in CUA mode (`mode: \"cua\"`).\n *\n * @example\n * ```typescript\n * // Simple values\n * variables: { username: \"john@example.com\", password: \"secret123\" }\n *\n * // Rich values with descriptions (helps the agent understand context)\n * variables: {\n * username: { value: \"john@example.com\", description: \"The login email\" },\n * password: { value: \"secret123\", description: \"The login password\" },\n * }\n * ```\n */\n variables?: Variables;\n /**\n * Timeout in milliseconds for each agent tool call.\n * If a tool call exceeds this duration, it will be aborted and\n * reported back to the LLM as a timeout error so it can retry or adjust.\n * For tools that call v3 methods (act, extract, fillForm, ariaTree), the\n * timeout is also forwarded to the underlying v3 call for true cancellation.\n * @default 45000 (45 seconds)\n */\n toolTimeout?: number;\n /**\n * Enable the web search tool powered by Browserbase Search API.\n * Requires a valid Browserbase API key (BROWSERBASE_API_KEY).\n * When set to true, the agent gains access to a `search` tool for web searches.\n *\n * @example\n * ```typescript\n * const result = await agent.execute({\n * instruction: \"Find the latest news about AI\",\n * useSearch: true,\n * });\n * ```\n */\n useSearch?: boolean;\n}\n\n/**\n * Options for non-streaming agent execution.\n * Only accepts AgentExecuteCallbacks (no streaming-specific callbacks like onChunk, onFinish).\n */\nexport interface AgentExecuteOptions extends AgentExecuteOptionsBase {\n /**\n * Callbacks for non-streaming agent execution.\n * For streaming callbacks (onChunk, onFinish, onError, onAbort), use stream: true in AgentConfig.\n */\n callbacks?: AgentExecuteCallbacks;\n}\n\n/**\n * Options for streaming agent execution.\n * Accepts AgentStreamCallbacks including onChunk, onFinish, onError, and onAbort.\n */\nexport interface AgentStreamExecuteOptions extends AgentExecuteOptionsBase {\n /**\n * Callbacks for streaming agent execution.\n * Includes streaming-specific callbacks: onChunk, onFinish, onError, onAbort.\n */\n callbacks?: AgentStreamCallbacks;\n}\nexport type AgentType =\n | \"openai\"\n | \"anthropic\"\n | \"google\"\n | \"microsoft\"\n | \"bedrock\";\n\nexport const AVAILABLE_CUA_MODELS = [\n \"openai/gpt-5.4\",\n \"openai/gpt-5.4-mini\",\n \"openai/gpt-5.5\",\n \"openai/computer-use-preview\",\n \"openai/computer-use-preview-2025-03-11\",\n \"anthropic/claude-opus-4-5-20251101\",\n \"anthropic/claude-opus-4-6\",\n \"anthropic/claude-sonnet-4-6\",\n \"anthropic/claude-haiku-4-5\",\n \"anthropic/claude-haiku-4-5-20251001\",\n \"anthropic/claude-sonnet-4-20250514\",\n \"anthropic/claude-sonnet-4-5-20250929\",\n \"google/gemini-2.5-computer-use-preview-10-2025\",\n \"google/gemini-3-flash-preview\",\n \"google/gemini-3-pro-preview\",\n \"microsoft/fara-7b\",\n] as const;\nexport type AvailableCuaModel = (typeof AVAILABLE_CUA_MODELS)[number];\n\nexport interface AgentExecutionOptions<\n TOptions extends AgentExecuteOptions = AgentExecuteOptions,\n> {\n options: TOptions;\n logger: (message: LogLine) => void;\n retries?: number;\n}\n\nexport interface AgentHandlerOptions {\n modelName: string;\n clientOptions?: ClientOptions;\n userProvidedInstructions?: string;\n experimental?: boolean;\n}\n\nexport interface ActionExecutionResult {\n success: boolean;\n error?: string;\n data?: unknown;\n}\n\n/**\n * Represents a safety check that requires user confirmation before proceeding.\n * These are issued by CUA providers (OpenAI, Google) when the agent attempts\n * potentially risky actions.\n */\nexport interface SafetyCheck {\n /** Unique identifier for this safety check */\n id: string;\n /** Code identifying the type of safety concern */\n code: string;\n /** Human-readable description of the safety concern */\n message: string;\n}\n\n/**\n * Response from the user for a safety confirmation request.\n */\nexport interface SafetyConfirmationResponse {\n /** Whether the user acknowledged/approved the safety checks */\n acknowledged: boolean;\n}\n\n/**\n * Callback for handling safety confirmation requests.\n * Called when the CUA provider issues safety checks that require user confirmation.\n * The callback should return a promise that resolves when the user has made a decision.\n *\n * @param safetyChecks - Array of safety checks requiring confirmation\n * @returns Promise resolving to the user's response\n *\n * @example\n * ```typescript\n * const agent = stagehand.agent({\n * mode: \"cua\",\n * });\n * await agent.execute({\n * instruction: \"...\",\n * callbacks: {\n * onSafetyConfirmation: async (checks) => {\n * console.log(\"Safety checks:\", checks);\n * const userApproved = await showConfirmationDialog(checks);\n * return { acknowledged: userApproved };\n * },\n * },\n * });\n * ```\n */\nexport type SafetyConfirmationHandler = (\n safetyChecks: SafetyCheck[],\n) => Promise<SafetyConfirmationResponse>;\n\n// Anthropic types:\n\nexport interface ToolUseItem extends ResponseItem {\n type: \"tool_use\";\n id: string; // This is the correct property name from Anthropic's API\n name: string; // Name of the tool being used\n input: Record<string, unknown>;\n}\n\nexport interface AnthropicMessage {\n role: string;\n content: string | Array<AnthropicContentBlock>;\n}\n\nexport interface AnthropicContentBlock {\n type: string;\n [key: string]: unknown;\n}\n\nexport interface AnthropicTextBlock extends AnthropicContentBlock {\n type: \"text\";\n text: string;\n}\n\nexport interface AnthropicToolResult {\n type: \"tool_result\";\n tool_use_id: string;\n content: string | Array<AnthropicContentBlock>;\n}\n\n// OpenAI types:\n\nexport interface ResponseItem {\n type: string;\n id: string;\n [key: string]: unknown;\n}\n\nexport interface ComputerCallItem extends ResponseItem {\n type: \"computer_call\";\n call_id: string;\n action?: {\n type: string;\n [key: string]: unknown;\n };\n actions?: Array<{\n type: string;\n [key: string]: unknown;\n }>;\n pending_safety_checks?: Array<{\n id: string;\n code: string;\n message: string;\n }>;\n}\n\nexport interface FunctionCallItem extends ResponseItem {\n type: \"function_call\";\n call_id: string;\n name: string;\n arguments: string;\n}\n\nexport type ResponseInputItem =\n | { role: string; content: string }\n | {\n type: \"computer_call_output\";\n call_id: string;\n output:\n | {\n type: \"input_image\" | \"computer_screenshot\";\n image_url: string;\n detail?: \"original\" | \"high\" | \"low\";\n current_url?: string;\n error?: string;\n [key: string]: unknown;\n }\n | string;\n acknowledged_safety_checks?: Array<{\n id: string;\n code: string;\n message: string;\n }>;\n }\n | {\n type: \"function_call_output\";\n call_id: string;\n output: string;\n };\n\nexport interface AgentInstance {\n execute: (\n instructionOrOptions: string | AgentExecuteOptions,\n ) => Promise<AgentResult>;\n}\n\nexport type AgentProviderType = AgentType;\n\nexport type AgentModelConfig<TModelName extends string = string> = {\n modelName: TModelName;\n} & Record<string, unknown>;\n\n/**\n * Agent tool mode determines which set of tools are available to the agent.\n * - 'dom': Uses DOM-based tools (act, fillForm) - better for structured page interactions\n * - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, etc.) - better for visual/screenshot-based interactions\n * - 'cua': Uses Computer Use Agent (CUA) providers like Anthropic Claude or Google Gemini for screenshot-based automation\n */\nexport type AgentToolMode = \"dom\" | \"hybrid\" | \"cua\";\n\nexport type AgentConfig = {\n /**\n * Custom system prompt to provide to the agent. Overrides the default system prompt.\n */\n systemPrompt?: string;\n /**\n * MCP integrations - Array of Client objects\n */\n integrations?: (Client | string)[];\n /**\n * Tools passed to the agent client\n */\n tools?: ToolSet;\n /**\n * @deprecated Use `mode: \"cua\"` instead. This option will be removed in a future version.\n * Enables Computer Use Agent (CUA) mode.\n */\n cua?: boolean;\n /**\n * The model to use for agent functionality\n */\n model?: string | AgentModelConfig<string>;\n /**\n * The model to use for tool execution (observe/act calls within agent tools).\n * If not specified, inherits from the main model configuration.\n * Format: \"provider/model\" (e.g., \"openai/gpt-4o-mini\", \"google/gemini-2.0-flash-exp\")\n */\n executionModel?: string | AgentModelConfig<string>;\n /**\n * Enable streaming mode for the agent.\n * When true, execute() returns AgentStreamResult with textStream for incremental output.\n * When false (default), execute() returns AgentResult after completion.\n */\n stream?: boolean;\n /**\n * Tool mode for the agent. Determines which set of tools are available.\n * - 'dom' (default): Uses DOM-based tools (act, fillForm) for structured interactions\n * - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, clickAndHold, fillFormVision)\n * for visual/screenshot-based interactions\n * - 'cua': Uses Computer Use Agent (CUA) providers for screenshot-based automation\n */\n mode?: AgentToolMode;\n};\n\n/**\n * Agent instance returned when stream: true is set in AgentConfig.\n * execute() returns a streaming result that can be consumed incrementally.\n * Accepts AgentStreamExecuteOptions with streaming-specific callbacks.\n */\nexport interface StreamingAgentInstance {\n execute: (\n instructionOrOptions: string | AgentStreamExecuteOptions,\n ) => Promise<AgentStreamResult>;\n}\n\n/**\n * Agent instance returned when stream is false or not set in AgentConfig.\n * execute() returns a result after the agent completes.\n * Accepts AgentExecuteOptions with non-streaming callbacks only.\n */\nexport interface NonStreamingAgentInstance {\n execute: (\n instructionOrOptions: string | AgentExecuteOptions,\n ) => Promise<AgentResult>;\n}\n\n// =============================================================================\n// Vision Action Tool Result Types\n// =============================================================================\n\n/**\n * Content item type for toModelOutput return values.\n * Used in tool definitions to return text and/or media to the model.\n */\nexport type ModelOutputContentItem =\n | { type: \"text\"; text: string }\n | { type: \"media\"; mediaType: string; data: string };\n\nexport interface ClickToolResult {\n success: boolean;\n describe?: string;\n coordinates?: number[];\n error?: string;\n screenshotBase64?: string;\n}\n\nexport interface TypeToolResult {\n success: boolean;\n describe?: string;\n text?: string;\n error?: string;\n screenshotBase64?: string;\n}\n\nexport interface DragAndDropToolResult {\n success: boolean;\n describe?: string;\n error?: string;\n screenshotBase64?: string;\n}\n\nexport interface FillFormField {\n action: string;\n value: string;\n coordinates: { x: number; y: number };\n}\n\nexport interface FillFormVisionToolResult {\n success: boolean;\n playwrightArguments?: FillFormField[];\n error?: string;\n screenshotBase64?: string;\n}\n\nexport interface ScrollToolResult {\n success: boolean;\n message: string;\n scrolledPixels: number;\n error?: string;\n}\n\nexport interface ScrollVisionToolResult extends ScrollToolResult {\n screenshotBase64?: string;\n}\n\nexport interface WaitToolResult {\n success: boolean;\n waited: number;\n screenshotBase64?: string;\n error?: string;\n}\n"]}
@@ -628,6 +628,7 @@ export declare const ExtractOptionsSchema: z.ZodOptional<z.ZodObject<{
628
628
  }, z.core.$strip>, z.ZodString]>>;
629
629
  timeout: z.ZodOptional<z.ZodNumber>;
630
630
  selector: z.ZodOptional<z.ZodString>;
631
+ ignoreSelectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
631
632
  }, z.core.$strip>>;
632
633
  export declare const ExtractRequestSchema: z.ZodObject<{
633
634
  instruction: z.ZodOptional<z.ZodString>;
@@ -648,6 +649,7 @@ export declare const ExtractRequestSchema: z.ZodObject<{
648
649
  }, z.core.$strip>, z.ZodString]>>;
649
650
  timeout: z.ZodOptional<z.ZodNumber>;
650
651
  selector: z.ZodOptional<z.ZodString>;
652
+ ignoreSelectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
651
653
  }, z.core.$strip>>;
652
654
  frameId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
653
655
  streamResponse: z.ZodOptional<z.ZodBoolean>;
@@ -822,6 +824,7 @@ export declare const AgentExecuteOptionsSchema: z.ZodObject<{
822
824
  highlightCursor: z.ZodOptional<z.ZodBoolean>;
823
825
  useSearch: z.ZodOptional<z.ZodBoolean>;
824
826
  toolTimeout: z.ZodOptional<z.ZodNumber>;
827
+ variables: z.ZodOptional<z.ZodType<import("./agent.js").Variables, unknown, z.core.$ZodTypeInternals<import("./agent.js").Variables, unknown>>>;
825
828
  }, z.core.$strip>;
826
829
  export declare const AgentExecuteRequestSchema: z.ZodObject<{
827
830
  agentConfig: z.ZodObject<{
@@ -872,6 +875,7 @@ export declare const AgentExecuteRequestSchema: z.ZodObject<{
872
875
  highlightCursor: z.ZodOptional<z.ZodBoolean>;
873
876
  useSearch: z.ZodOptional<z.ZodBoolean>;
874
877
  toolTimeout: z.ZodOptional<z.ZodNumber>;
878
+ variables: z.ZodOptional<z.ZodType<import("./agent.js").Variables, unknown, z.core.$ZodTypeInternals<import("./agent.js").Variables, unknown>>>;
875
879
  }, z.core.$strip>;
876
880
  frameId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
877
881
  streamResponse: z.ZodOptional<z.ZodBoolean>;
@@ -1128,7 +1132,7 @@ export declare const openApiSecuritySchemes: {
1128
1132
  readonly type: "apiKey";
1129
1133
  readonly in: "header";
1130
1134
  readonly name: "x-bb-project-id";
1131
- readonly description: "Browserbase project ID";
1135
+ readonly description: "Deprecated. Browserbase API keys are now project-scoped, so this header is no longer required.";
1132
1136
  };
1133
1137
  readonly ModelApiKey: {
1134
1138
  readonly type: "apiKey";
@@ -271,7 +271,10 @@ exports.BrowserbaseRegionSchema = v4_1.z
271
271
  /** Browserbase session creation parameters */
272
272
  exports.BrowserbaseSessionCreateParamsSchema = v4_1.z
273
273
  .object({
274
- projectId: v4_1.z.string().optional(),
274
+ projectId: v4_1.z.string().optional().meta({
275
+ deprecated: true,
276
+ description: "Deprecated. Browserbase API keys are now project-scoped, so this field is no longer required.",
277
+ }),
275
278
  browserSettings: exports.BrowserbaseBrowserSettingsSchema.optional(),
276
279
  extensionId: v4_1.z.string().optional(),
277
280
  keepAlive: v4_1.z.boolean().optional(),
@@ -454,6 +457,13 @@ exports.ExtractOptionsSchema = v4_1.z
454
457
  description: "CSS selector to scope extraction to a specific element",
455
458
  example: "#main-content",
456
459
  }),
460
+ ignoreSelectors: v4_1.z
461
+ .array(v4_1.z.string())
462
+ .optional()
463
+ .meta({
464
+ description: "Selectors for elements and subtrees that should be excluded from extraction",
465
+ example: ["nav", ".cookie-banner", "#sidebar-ads"],
466
+ }),
457
467
  })
458
468
  .optional()
459
469
  .meta({ id: "ExtractOptions" });
@@ -658,6 +668,9 @@ exports.AgentExecuteOptionsSchema = v4_1.z
658
668
  description: "Timeout in milliseconds for each agent tool call",
659
669
  example: 30000,
660
670
  }),
671
+ variables: variables_js_1.VariablesSchema.optional().meta({
672
+ description: "Variables available to the agent via %variableName% syntax in supported tools",
673
+ }),
661
674
  })
662
675
  .meta({ id: "AgentExecuteOptions" });
663
676
  exports.AgentExecuteRequestSchema = v4_1.z
@@ -860,7 +873,7 @@ exports.openApiSecuritySchemes = {
860
873
  type: "apiKey",
861
874
  in: "header",
862
875
  name: "x-bb-project-id",
863
- description: "Browserbase project ID",
876
+ description: "Deprecated. Browserbase API keys are now project-scoped, so this header is no longer required.",
864
877
  },
865
878
  ModelApiKey: {
866
879
  type: "apiKey",