@kolisachint/hoocode-agent 0.4.162 → 0.4.164

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 (339) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/cli/args.d.ts +0 -6
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +0 -31
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/config.d.ts +0 -40
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +4 -50
  9. package/dist/config.js.map +1 -1
  10. package/dist/core/agent-frontmatter.d.ts +0 -28
  11. package/dist/core/agent-frontmatter.d.ts.map +1 -1
  12. package/dist/core/agent-frontmatter.js +0 -6
  13. package/dist/core/agent-frontmatter.js.map +1 -1
  14. package/dist/core/agent-session-services.d.ts +0 -2
  15. package/dist/core/agent-session-services.d.ts.map +1 -1
  16. package/dist/core/agent-session-services.js +0 -2
  17. package/dist/core/agent-session-services.js.map +1 -1
  18. package/dist/core/agent-session.d.ts.map +1 -1
  19. package/dist/core/agent-session.js +0 -2
  20. package/dist/core/agent-session.js.map +1 -1
  21. package/dist/core/auth-guidance.d.ts +0 -1
  22. package/dist/core/auth-guidance.d.ts.map +1 -1
  23. package/dist/core/auth-guidance.js +1 -1
  24. package/dist/core/auth-guidance.js.map +1 -1
  25. package/dist/core/embsearch/chunker.d.ts +0 -2
  26. package/dist/core/embsearch/chunker.d.ts.map +1 -1
  27. package/dist/core/embsearch/chunker.js +1 -1
  28. package/dist/core/embsearch/chunker.js.map +1 -1
  29. package/dist/core/embsearch/index-meta.d.ts +0 -2
  30. package/dist/core/embsearch/index-meta.d.ts.map +1 -1
  31. package/dist/core/embsearch/index-meta.js +0 -6
  32. package/dist/core/embsearch/index-meta.js.map +1 -1
  33. package/dist/core/export-html/ansi-to-html.d.ts +0 -4
  34. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  35. package/dist/core/export-html/ansi-to-html.js +1 -1
  36. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  37. package/dist/core/extensions/index.d.ts +3 -3
  38. package/dist/core/extensions/index.d.ts.map +1 -1
  39. package/dist/core/extensions/index.js +1 -1
  40. package/dist/core/extensions/index.js.map +1 -1
  41. package/dist/core/extensions/plugins/authoring.d.ts +2 -2
  42. package/dist/core/extensions/plugins/authoring.d.ts.map +1 -1
  43. package/dist/core/extensions/plugins/authoring.js +0 -0
  44. package/dist/core/extensions/plugins/authoring.js.map +1 -1
  45. package/dist/core/extensions/plugins/formats/index.d.ts +2 -6
  46. package/dist/core/extensions/plugins/formats/index.d.ts.map +1 -1
  47. package/dist/core/extensions/plugins/formats/index.js +2 -3
  48. package/dist/core/extensions/plugins/formats/index.js.map +1 -1
  49. package/dist/core/extensions/plugins/formats/shared.d.ts +0 -2
  50. package/dist/core/extensions/plugins/formats/shared.d.ts.map +1 -1
  51. package/dist/core/extensions/plugins/formats/shared.js +1 -1
  52. package/dist/core/extensions/plugins/formats/shared.js.map +1 -1
  53. package/dist/core/extensions/plugins/formats/types.d.ts +4 -3
  54. package/dist/core/extensions/plugins/formats/types.d.ts.map +1 -1
  55. package/dist/core/extensions/plugins/formats/types.js.map +1 -1
  56. package/dist/core/extensions/plugins/install.d.ts +0 -2
  57. package/dist/core/extensions/plugins/install.d.ts.map +1 -1
  58. package/dist/core/extensions/plugins/install.js +1 -1
  59. package/dist/core/extensions/plugins/install.js.map +1 -1
  60. package/dist/core/extensions/plugins/manifest.d.ts +0 -6
  61. package/dist/core/extensions/plugins/manifest.d.ts.map +1 -1
  62. package/dist/core/extensions/plugins/manifest.js +0 -6
  63. package/dist/core/extensions/plugins/manifest.js.map +1 -1
  64. package/dist/core/extensions/plugins/marketplace.d.ts +3 -3
  65. package/dist/core/extensions/plugins/marketplace.d.ts.map +1 -1
  66. package/dist/core/extensions/plugins/marketplace.js.map +1 -1
  67. package/dist/core/extensions/types.d.ts +28 -28
  68. package/dist/core/extensions/types.d.ts.map +1 -1
  69. package/dist/core/extensions/types.js.map +1 -1
  70. package/dist/core/keybindings.d.ts +3 -3
  71. package/dist/core/keybindings.d.ts.map +1 -1
  72. package/dist/core/keybindings.js.map +1 -1
  73. package/dist/core/model-resolver.d.ts +0 -7
  74. package/dist/core/model-resolver.d.ts.map +1 -1
  75. package/dist/core/model-resolver.js +0 -56
  76. package/dist/core/model-resolver.js.map +1 -1
  77. package/dist/core/package-resource-discovery.d.ts +0 -10
  78. package/dist/core/package-resource-discovery.d.ts.map +1 -1
  79. package/dist/core/package-resource-discovery.js +7 -7
  80. package/dist/core/package-resource-discovery.js.map +1 -1
  81. package/dist/core/provider-health.d.ts +0 -2
  82. package/dist/core/provider-health.d.ts.map +1 -1
  83. package/dist/core/provider-health.js +1 -1
  84. package/dist/core/provider-health.js.map +1 -1
  85. package/dist/core/resolve-config-value.d.ts +0 -4
  86. package/dist/core/resolve-config-value.d.ts.map +1 -1
  87. package/dist/core/resolve-config-value.js +0 -15
  88. package/dist/core/resolve-config-value.js.map +1 -1
  89. package/dist/core/sdk.d.ts +3 -23
  90. package/dist/core/sdk.d.ts.map +1 -1
  91. package/dist/core/sdk.js +3 -5
  92. package/dist/core/sdk.js.map +1 -1
  93. package/dist/core/search/eval.d.ts +0 -3
  94. package/dist/core/search/eval.d.ts.map +1 -1
  95. package/dist/core/search/eval.js +1 -1
  96. package/dist/core/search/eval.js.map +1 -1
  97. package/dist/core/search/types.d.ts +2 -1
  98. package/dist/core/search/types.d.ts.map +1 -1
  99. package/dist/core/search/types.js.map +1 -1
  100. package/dist/core/session-cwd.d.ts +0 -1
  101. package/dist/core/session-cwd.d.ts.map +1 -1
  102. package/dist/core/session-cwd.js +1 -1
  103. package/dist/core/session-cwd.js.map +1 -1
  104. package/dist/core/settings-defaults.d.ts +0 -3
  105. package/dist/core/settings-defaults.d.ts.map +1 -1
  106. package/dist/core/settings-defaults.js +0 -3
  107. package/dist/core/settings-defaults.js.map +1 -1
  108. package/dist/core/settings-manager.d.ts +2 -9
  109. package/dist/core/settings-manager.d.ts.map +1 -1
  110. package/dist/core/settings-manager.js +0 -25
  111. package/dist/core/settings-manager.js.map +1 -1
  112. package/dist/core/settings-types.d.ts +9 -11
  113. package/dist/core/settings-types.d.ts.map +1 -1
  114. package/dist/core/settings-types.js.map +1 -1
  115. package/dist/core/subagent-inbox.d.ts +1 -3
  116. package/dist/core/subagent-inbox.d.ts.map +1 -1
  117. package/dist/core/subagent-inbox.js +1 -1
  118. package/dist/core/subagent-inbox.js.map +1 -1
  119. package/dist/core/subagent-pool.d.ts +0 -13
  120. package/dist/core/subagent-pool.d.ts.map +1 -1
  121. package/dist/core/subagent-pool.js +2 -2
  122. package/dist/core/subagent-pool.js.map +1 -1
  123. package/dist/core/task-store.d.ts +3 -3
  124. package/dist/core/task-store.d.ts.map +1 -1
  125. package/dist/core/task-store.js.map +1 -1
  126. package/dist/core/team-auto.d.ts +0 -2
  127. package/dist/core/team-auto.d.ts.map +1 -1
  128. package/dist/core/team-auto.js +1 -1
  129. package/dist/core/team-auto.js.map +1 -1
  130. package/dist/core/token-budget.d.ts +0 -13
  131. package/dist/core/token-budget.d.ts.map +1 -1
  132. package/dist/core/token-budget.js.map +1 -1
  133. package/dist/core/tools/bash.d.ts.map +1 -1
  134. package/dist/core/tools/bash.js +3 -1
  135. package/dist/core/tools/bash.js.map +1 -1
  136. package/dist/core/tools/edit-diff.d.ts +0 -38
  137. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  138. package/dist/core/tools/edit-diff.js +2 -9
  139. package/dist/core/tools/edit-diff.js.map +1 -1
  140. package/dist/core/tools/edit.d.ts.map +1 -1
  141. package/dist/core/tools/edit.js +5 -5
  142. package/dist/core/tools/edit.js.map +1 -1
  143. package/dist/core/tools/find.d.ts.map +1 -1
  144. package/dist/core/tools/find.js +8 -10
  145. package/dist/core/tools/find.js.map +1 -1
  146. package/dist/core/tools/grep.d.ts.map +1 -1
  147. package/dist/core/tools/grep.js +4 -4
  148. package/dist/core/tools/grep.js.map +1 -1
  149. package/dist/core/tools/index.d.ts +0 -24
  150. package/dist/core/tools/index.d.ts.map +1 -1
  151. package/dist/core/tools/index.js +0 -20
  152. package/dist/core/tools/index.js.map +1 -1
  153. package/dist/core/tools/ls.d.ts.map +1 -1
  154. package/dist/core/tools/ls.js +2 -2
  155. package/dist/core/tools/ls.js.map +1 -1
  156. package/dist/core/tools/native-search.d.ts +3 -2
  157. package/dist/core/tools/native-search.d.ts.map +1 -1
  158. package/dist/core/tools/native-search.js.map +1 -1
  159. package/dist/core/tools/path-utils.d.ts +0 -10
  160. package/dist/core/tools/path-utils.d.ts.map +1 -1
  161. package/dist/core/tools/path-utils.js +2 -2
  162. package/dist/core/tools/path-utils.js.map +1 -1
  163. package/dist/core/tools/plugins.d.ts +1 -20
  164. package/dist/core/tools/plugins.d.ts.map +1 -1
  165. package/dist/core/tools/plugins.js +2 -2
  166. package/dist/core/tools/plugins.js.map +1 -1
  167. package/dist/core/tools/propose-plugin.d.ts +0 -12
  168. package/dist/core/tools/propose-plugin.d.ts.map +1 -1
  169. package/dist/core/tools/propose-plugin.js +0 -1
  170. package/dist/core/tools/propose-plugin.js.map +1 -1
  171. package/dist/core/tools/read-dedup.d.ts +0 -2
  172. package/dist/core/tools/read-dedup.d.ts.map +1 -1
  173. package/dist/core/tools/read-dedup.js +1 -1
  174. package/dist/core/tools/read-dedup.js.map +1 -1
  175. package/dist/core/tools/read.d.ts.map +1 -1
  176. package/dist/core/tools/read.js +10 -8
  177. package/dist/core/tools/read.js.map +1 -1
  178. package/dist/core/tools/render-utils.d.ts +0 -5
  179. package/dist/core/tools/render-utils.d.ts.map +1 -1
  180. package/dist/core/tools/render-utils.js.map +1 -1
  181. package/dist/core/tools/search.d.ts +1 -4
  182. package/dist/core/tools/search.d.ts.map +1 -1
  183. package/dist/core/tools/search.js +6 -6
  184. package/dist/core/tools/search.js.map +1 -1
  185. package/dist/core/tools/webfetch.d.ts +1 -2
  186. package/dist/core/tools/webfetch.d.ts.map +1 -1
  187. package/dist/core/tools/webfetch.js.map +1 -1
  188. package/dist/core/tools/websearch.d.ts +1 -2
  189. package/dist/core/tools/websearch.d.ts.map +1 -1
  190. package/dist/core/tools/websearch.js.map +1 -1
  191. package/dist/core/tools/webtools-shared.d.ts +3 -5
  192. package/dist/core/tools/webtools-shared.d.ts.map +1 -1
  193. package/dist/core/tools/webtools-shared.js +1 -1
  194. package/dist/core/tools/webtools-shared.js.map +1 -1
  195. package/dist/core/warm-subagent-pool-instance.d.ts +0 -4
  196. package/dist/core/warm-subagent-pool-instance.d.ts.map +1 -1
  197. package/dist/core/warm-subagent-pool-instance.js +0 -10
  198. package/dist/core/warm-subagent-pool-instance.js.map +1 -1
  199. package/dist/core/wordmark.d.ts +1 -9
  200. package/dist/core/wordmark.d.ts.map +1 -1
  201. package/dist/core/wordmark.js +2 -26
  202. package/dist/core/wordmark.js.map +1 -1
  203. package/dist/extensions/core/config.d.ts +4 -3
  204. package/dist/extensions/core/config.d.ts.map +1 -1
  205. package/dist/extensions/core/config.js.map +1 -1
  206. package/dist/extensions/core/mcp-loader.d.ts +0 -18
  207. package/dist/extensions/core/mcp-loader.d.ts.map +1 -1
  208. package/dist/extensions/core/mcp-loader.js.map +1 -1
  209. package/dist/extensions/core/prompt-reactive/policy.d.ts +0 -8
  210. package/dist/extensions/core/prompt-reactive/policy.d.ts.map +1 -1
  211. package/dist/extensions/core/prompt-reactive/policy.js +1 -1
  212. package/dist/extensions/core/prompt-reactive/policy.js.map +1 -1
  213. package/dist/main.d.ts.map +1 -1
  214. package/dist/main.js +0 -30
  215. package/dist/main.js.map +1 -1
  216. package/dist/migrations.d.ts +0 -16
  217. package/dist/migrations.d.ts.map +1 -1
  218. package/dist/migrations.js +2 -2
  219. package/dist/migrations.js.map +1 -1
  220. package/dist/modes/interactive/brand.d.ts +0 -4
  221. package/dist/modes/interactive/brand.d.ts.map +1 -1
  222. package/dist/modes/interactive/brand.js +0 -4
  223. package/dist/modes/interactive/brand.js.map +1 -1
  224. package/dist/modes/interactive/components/index.d.ts +0 -4
  225. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  226. package/dist/modes/interactive/components/index.js +0 -5
  227. package/dist/modes/interactive/components/index.js.map +1 -1
  228. package/dist/modes/interactive/components/read-output.d.ts +0 -9
  229. package/dist/modes/interactive/components/read-output.d.ts.map +1 -1
  230. package/dist/modes/interactive/components/read-output.js +0 -20
  231. package/dist/modes/interactive/components/read-output.js.map +1 -1
  232. package/dist/modes/interactive/components/session-selector-search.d.ts +0 -17
  233. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  234. package/dist/modes/interactive/components/session-selector-search.js +2 -2
  235. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  236. package/dist/modes/interactive/components/settings-selector.d.ts +5 -14
  237. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  238. package/dist/modes/interactive/components/settings-selector.js +2 -2
  239. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  240. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  241. package/dist/modes/interactive/interactive-mode.js +0 -18
  242. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  243. package/dist/modes/interactive/login-controller.d.ts +1 -1
  244. package/dist/modes/interactive/login-controller.d.ts.map +1 -1
  245. package/dist/modes/interactive/login-controller.js +1 -1
  246. package/dist/modes/interactive/login-controller.js.map +1 -1
  247. package/dist/modes/interactive/resource-display.d.ts +0 -20
  248. package/dist/modes/interactive/resource-display.d.ts.map +1 -1
  249. package/dist/modes/interactive/resource-display.js +7 -7
  250. package/dist/modes/interactive/resource-display.js.map +1 -1
  251. package/dist/modes/interactive/theme/theme.d.ts +0 -4
  252. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  253. package/dist/modes/interactive/theme/theme.js +0 -7
  254. package/dist/modes/interactive/theme/theme.js.map +1 -1
  255. package/dist/modes/rpc/rpc-mode.d.ts +0 -1
  256. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  257. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  258. package/dist/modes/rpc/rpc-types.d.ts +0 -1
  259. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  260. package/dist/modes/rpc/rpc-types.js +3 -0
  261. package/dist/modes/rpc/rpc-types.js.map +1 -1
  262. package/dist/package-manager-cli.d.ts +0 -1
  263. package/dist/package-manager-cli.d.ts.map +1 -1
  264. package/dist/package-manager-cli.js.map +1 -1
  265. package/dist/utils/changelog.d.ts +0 -4
  266. package/dist/utils/changelog.d.ts.map +1 -1
  267. package/dist/utils/changelog.js +1 -1
  268. package/dist/utils/changelog.js.map +1 -1
  269. package/dist/utils/clipboard-native.d.ts +1 -1
  270. package/dist/utils/clipboard-native.d.ts.map +1 -1
  271. package/dist/utils/clipboard-native.js.map +1 -1
  272. package/dist/utils/paths.d.ts +0 -2
  273. package/dist/utils/paths.d.ts.map +1 -1
  274. package/dist/utils/paths.js +1 -1
  275. package/dist/utils/paths.js.map +1 -1
  276. package/dist/utils/plan/parser.d.ts +5 -4
  277. package/dist/utils/plan/parser.d.ts.map +1 -1
  278. package/dist/utils/plan/parser.js.map +1 -1
  279. package/dist/utils/tools-manager.d.ts +1 -2
  280. package/dist/utils/tools-manager.d.ts.map +1 -1
  281. package/dist/utils/tools-manager.js +2 -50
  282. package/dist/utils/tools-manager.js.map +1 -1
  283. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  284. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  285. package/examples/extensions/sandbox/package.json +1 -1
  286. package/examples/extensions/with-deps/package.json +1 -1
  287. package/package.json +4 -7
  288. package/dist/core/index.d.ts +0 -12
  289. package/dist/core/index.d.ts.map +0 -1
  290. package/dist/core/index.js +0 -12
  291. package/dist/core/index.js.map +0 -1
  292. package/dist/core/tools/browser/browser-continue.d.ts +0 -25
  293. package/dist/core/tools/browser/browser-continue.d.ts.map +0 -1
  294. package/dist/core/tools/browser/browser-continue.js +0 -84
  295. package/dist/core/tools/browser/browser-continue.js.map +0 -1
  296. package/dist/core/tools/browser/browser-run.d.ts +0 -48
  297. package/dist/core/tools/browser/browser-run.d.ts.map +0 -1
  298. package/dist/core/tools/browser/browser-run.js +0 -377
  299. package/dist/core/tools/browser/browser-run.js.map +0 -1
  300. package/dist/core/tools/browser/browsertools-shared.d.ts +0 -190
  301. package/dist/core/tools/browser/browsertools-shared.d.ts.map +0 -1
  302. package/dist/core/tools/browser/browsertools-shared.js +0 -335
  303. package/dist/core/tools/browser/browsertools-shared.js.map +0 -1
  304. package/dist/core/tools/browser/index.d.ts +0 -8
  305. package/dist/core/tools/browser/index.d.ts.map +0 -1
  306. package/dist/core/tools/browser/index.js +0 -8
  307. package/dist/core/tools/browser/index.js.map +0 -1
  308. package/dist/core/tools/doc/docedit.d.ts +0 -44
  309. package/dist/core/tools/doc/docedit.d.ts.map +0 -1
  310. package/dist/core/tools/doc/docedit.js +0 -133
  311. package/dist/core/tools/doc/docedit.js.map +0 -1
  312. package/dist/core/tools/doc/docgrep.d.ts +0 -28
  313. package/dist/core/tools/doc/docgrep.d.ts.map +0 -1
  314. package/dist/core/tools/doc/docgrep.js +0 -106
  315. package/dist/core/tools/doc/docgrep.js.map +0 -1
  316. package/dist/core/tools/doc/docpeek.d.ts +0 -25
  317. package/dist/core/tools/doc/docpeek.d.ts.map +0 -1
  318. package/dist/core/tools/doc/docpeek.js +0 -112
  319. package/dist/core/tools/doc/docpeek.js.map +0 -1
  320. package/dist/core/tools/doc/docread.d.ts +0 -32
  321. package/dist/core/tools/doc/docread.d.ts.map +0 -1
  322. package/dist/core/tools/doc/docread.js +0 -113
  323. package/dist/core/tools/doc/docread.js.map +0 -1
  324. package/dist/core/tools/doc/docscan.d.ts +0 -29
  325. package/dist/core/tools/doc/docscan.d.ts.map +0 -1
  326. package/dist/core/tools/doc/docscan.js +0 -110
  327. package/dist/core/tools/doc/docscan.js.map +0 -1
  328. package/dist/core/tools/doc/docwrite.d.ts +0 -44
  329. package/dist/core/tools/doc/docwrite.d.ts.map +0 -1
  330. package/dist/core/tools/doc/docwrite.js +0 -102
  331. package/dist/core/tools/doc/docwrite.js.map +0 -1
  332. package/dist/core/tools/doc/index.d.ts +0 -11
  333. package/dist/core/tools/doc/index.d.ts.map +0 -1
  334. package/dist/core/tools/doc/index.js +0 -11
  335. package/dist/core/tools/doc/index.js.map +0 -1
  336. package/dist/core/tools/filetools-shared.d.ts +0 -271
  337. package/dist/core/tools/filetools-shared.d.ts.map +0 -1
  338. package/dist/core/tools/filetools-shared.js +0 -403
  339. package/dist/core/tools/filetools-shared.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser-run.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/browser/browser-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE5E,OAAO,EACN,KAAK,mBAAmB,EACxB,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAEhB,KAAK,aAAa,EAGlB,KAAK,WAAW,EAEhB,0BAA0B,EAE1B,MAAM,0BAA0B,CAAC;AAElC,QAAA,MAAM,gBAAgB;;;;;;;EAmDpB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D,sEAAsE;AACtE,MAAM,WAAW,iBAAiB;IACjC,MAAM,EAAE,UAAU,GAAG,cAAc,CAAC;IACpC,qEAAqE;IACrE,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,yEAAyE;IACzE,WAAW,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvC,mEAAmE;IACnE,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB;CAAG;AAkMzE;;;;;GAKG;AACH,wBAAsB,WAAW,CAChC,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,EACnD,aAAa,CAAC,EAAE,mBAAmB,GACjC,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,CA2D7C;AAED,wBAAgB,8BAA8B,CAC7C,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,qBAAqB,GAC7B,cAAc,CAAC,OAAO,gBAAgB,EAAE,iBAAiB,CAAC,CAiG5D;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAErH","sourcesContent":["/**\n * `browser_run` tool: start a deterministic browsertools flow.\n *\n * Spawns a `browsertools serve` process and issues `flow_start`. If the flow\n * runs to completion deterministically it returns the evidence inline. If replay\n * hits a point only an LLM can resolve, the serve process suspends with\n * `Outcome::NeedsParent`: this tool fetches the suspension screenshot, parks the\n * live session under its `ResumeToken`, and returns the typed `ParentRequest`\n * (plus the screenshot as an image) to the agent. The agent reasons and answers\n * with the companion `browser_continue` tool. See {@link browsertools-shared}.\n */\n\nimport { exec } from \"node:child_process\";\nimport type { AgentTool } from \"@kolisachint/hoocode-agent-core\";\nimport type { ImageContent, TextContent } from \"@kolisachint/hoocode-ai\";\nimport { type Static, Type } from \"typebox\";\nimport type { AgentToolResult } from \"../../extensions/types.js\";\nimport { defineTool, type ToolDefinition } from \"../../extensions/types.js\";\nimport { wrapToolDefinition } from \"../tool-definition-wrapper.js\";\nimport {\n\ttype BrowserClientConfig,\n\tBrowsertoolsServeClient,\n\ttype BrowsertoolsToolOptions,\n\ttype FlowOutcome,\n\ttype GetResourceResult,\n\ttype ParentRequest,\n\tparkIdleClient,\n\tparkSession,\n\ttype ResumeToken,\n\tresolveBrowsertoolsBinary,\n\tresolveBrowsertoolsOptions,\n\ttakeIdleClient,\n} from \"./browsertools-shared.js\";\n\nconst browserRunSchema = Type.Object({\n\tflow_path: Type.Optional(\n\t\tType.String({ description: \"Path to the .flow.json file to execute. Provide this or `flow`.\" }),\n\t),\n\tflow: Type.Optional(\n\t\tType.Record(Type.String(), Type.Unknown(), {\n\t\t\tdescription:\n\t\t\t\t\"Inline flow definition object (alternative to `flow_path`). Shape: \" +\n\t\t\t\t\"{ id: string, name: string, version: number, start_url: string, steps: Step[] }. \" +\n\t\t\t\t\"Each Step is { id: string, action: Action }. Action is a tagged object keyed by \" +\n\t\t\t\t\"`action`; the exact fields per variant (do NOT add extras like `goal` to the wrong \" +\n\t\t\t\t\"variant): \" +\n\t\t\t\t'{ action: \"navigate\", url: string } | ' +\n\t\t\t\t'{ action: \"click\", selector: string, fallbacks?: string[] } | ' +\n\t\t\t\t'{ action: \"fill\", selector: string, value_tpl: string } | ' +\n\t\t\t\t'{ action: \"select\", selector: string, value_tpl: string } | ' +\n\t\t\t\t'{ action: \"wait_settle\" } | ' +\n\t\t\t\t'{ action: \"checkpoint\", asserts: Invariant[] } | ' +\n\t\t\t\t'{ action: \"decide\", goal: string } | ' +\n\t\t\t\t'{ action: \"classify\" } | ' +\n\t\t\t\t'{ action: \"verify_visual\", expected_state: string } | ' +\n\t\t\t\t'{ action: \"extract_semantic\", fields: string[] }. ' +\n\t\t\t\t\"IMPORTANT: `extract_semantic.fields` MUST be an array of field-name strings \" +\n\t\t\t\t'(e.g. [\"person\", \"movie_count\"]), never an object/map, and `extract_semantic` takes ' +\n\t\t\t\t\"no `goal` (only `decide` does). Invariant (for checkpoint asserts) is one of: \" +\n\t\t\t\t'{ kind: \"element_present\", selector: string } | ' +\n\t\t\t\t'{ kind: \"text_present\", selector?: string, substr: string } | ' +\n\t\t\t\t'{ kind: \"url_matches\", pattern: string }.',\n\t\t}),\n\t),\n\tvars: Type.Optional(\n\t\tType.Record(Type.String(), Type.Unknown(), {\n\t\t\tdescription: \"Variables interpolated into the flow ({{var}} placeholders).\",\n\t\t}),\n\t),\n\tstore: Type.Optional(Type.String({ description: \"Path to the evidence store directory for this run.\" })),\n\tlive_view: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Start a live viewer that streams the page and the agent's tool-call log over a local \" +\n\t\t\t\t\"WebSocket, and auto-open it in your default browser. Set HOOCODE_BROWSERTOOLS_NO_OPEN=1 to \" +\n\t\t\t\t\"print the URL without opening. Best for flows that suspend or run long.\",\n\t\t}),\n\t),\n\theadful: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Launch a real on-screen Chromium window instead of a headless browser. Requires a desktop \" +\n\t\t\t\t\"display; unlike live_view it does not show the tool-call log.\",\n\t\t}),\n\t),\n});\n\nexport type BrowserRunInput = Static<typeof browserRunSchema>;\n\n/** Structured details surfaced alongside the model-facing content. */\nexport interface BrowserRunDetails {\n\tstatus: \"complete\" | \"needs_parent\";\n\t/** Present when status is \"needs_parent\": resume with this token. */\n\ttoken?: ResumeToken;\n\t/** Present when status is \"needs_parent\": the kind of parent request. */\n\trequestKind?: ParentRequest[\"request\"];\n\t/** Present when status is \"complete\": the flow result/evidence. */\n\tresult?: unknown;\n}\n\nexport interface BrowserRunToolOptions extends BrowsertoolsToolOptions {}\n\n/** ParentResponse shape hint per ParentRequest kind (mirrors contract.rs). */\nfunction parentResponseHint(kind: ParentRequest[\"request\"]): string {\n\tswitch (kind) {\n\t\tcase \"classify_state\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"state\", \"state\": \"<your label>\" }';\n\t\tcase \"verify_visual\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"verified\", \"passed\": true | false }';\n\t\tcase \"extract_semantic\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"extracted\", \"fields\": { \"<field>\": \"<value>\", ... } }';\n\t\tcase \"decide_next_action\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"next_action\", \"action\": <action object> }';\n\t\tcase \"reidentify_element\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"element\", \"selector\": \"<css selector>\" }';\n\t\tdefault:\n\t\t\treturn \"Reply with browser_continue providing the appropriate ParentResponse object.\";\n\t}\n}\n\n/** A control fact from the browsertools observation (mirrors observe.rs InputFact). */\ninterface ObservationInput {\n\tkind?: string;\n\taccessible_name?: string;\n\tselector_hint?: string;\n}\n\n/** A landmark fact from the browsertools observation (mirrors observe.rs Landmark). */\ninterface ObservationLandmark {\n\trole?: string;\n\tname?: string;\n}\n\n/** The HTML-derived observation the engine attaches to decide/classify requests. */\ninterface Observation {\n\turl?: string;\n\ttitle?: string;\n\tinputs?: ObservationInput[];\n\tlandmarks?: ObservationLandmark[];\n\ttext_blocks?: string[];\n\thas_error_region?: boolean;\n}\n\n/** Truncate a string to `max` chars with an ellipsis, for compact rendering. */\nfunction clip(s: string, max = 80): string {\n\tconst t = s.trim();\n\treturn t.length > max ? `${t.slice(0, max - 1)}\\u2026` : t;\n}\n\n/** Render one observation control as a single compact line. */\nfunction renderControl(i: ObservationInput): string {\n\tconst sel = i.selector_hint && i.selector_hint !== \"button\" ? i.selector_hint : undefined;\n\tconst name = i.accessible_name ? `\"${clip(i.accessible_name, 60)}\"` : undefined;\n\tconst parts = [i.kind, name, sel].filter(Boolean);\n\treturn ` - ${parts.join(\" \")}`;\n}\n\n/**\n * Summarize a verbose `decide_next_action`/`classify_state` observation into a\n * compact, readable block instead of dumping the raw JSON (which on busy pages is\n * thousands of mostly-empty entries straight into the model context). The\n * screenshot already conveys the page; this is just the actionable text layer:\n * url/title, named controls, salient headings. Returns undefined when there is no\n * observation to summarize.\n */\nfunction summarizeObservation(observation: Observation | undefined): string | undefined {\n\tif (!observation || typeof observation !== \"object\") return undefined;\n\tconst lines: string[] = [];\n\tif (observation.title) lines.push(`page: ${clip(observation.title, 100)}`);\n\tif (observation.url) lines.push(`url: ${clip(observation.url, 120)}`);\n\tif (observation.has_error_region) lines.push(\"note: page has an error/alert region\");\n\n\tconst controls = (observation.inputs ?? []).filter((i) => i.kind !== \"_more\");\n\tif (controls.length) {\n\t\tlines.push(`controls (${controls.length}):`);\n\t\tfor (const c of controls.slice(0, 25)) lines.push(renderControl(c));\n\t\tif (controls.length > 25) lines.push(` - …+${controls.length - 25} more`);\n\t}\n\n\tconst text = (observation.text_blocks ?? []).filter((t) => t?.trim());\n\tif (text.length) {\n\t\tlines.push(\n\t\t\t`headings: ${text\n\t\t\t\t.slice(0, 12)\n\t\t\t\t.map((t) => clip(t, 50))\n\t\t\t\t.join(\" · \")}`,\n\t\t);\n\t}\n\treturn lines.length ? lines.join(\"\\n\") : undefined;\n}\n\n/**\n * Build the compact, model-facing text for a `NeedsParent` suspension. Renders\n * only the fields that matter per request kind (goal, expected_state, fields,\n * description) plus a summarized observation, rather than pretty-printing the\n * entire request — which is the dominant token sink for browser flows.\n */\nfunction formatParentRequest(request: ParentRequest): string {\n\tconst kind = request.request;\n\tconst lines: string[] = [`request: ${kind}`];\n\tconst r = request as ParentRequest & {\n\t\tgoal?: string;\n\t\texpected_state?: string;\n\t\tdescription?: string;\n\t\tfields?: string[];\n\t\tobservation?: Observation;\n\t};\n\tif (r.goal) lines.push(`goal: ${r.goal}`);\n\tif (r.expected_state) lines.push(`expected_state: ${r.expected_state}`);\n\tif (r.description) lines.push(`element: ${r.description}`);\n\tif (Array.isArray(r.fields) && r.fields.length) lines.push(`fields: ${r.fields.join(\", \")}`);\n\tconst summary = summarizeObservation(r.observation);\n\tif (summary) lines.push(summary);\n\treturn lines.join(\"\\n\");\n}\n\n/** Compact, model-facing reminder of the inline-flow action schema, appended to\n * an `invalid inline flow` error so the model can self-correct in one turn\n * instead of guessing field shapes across several rounds. */\nconst FLOW_SCHEMA_HINT =\n\t\"Inline flow shape: { id, name, version, start_url, steps: [{ id, action }] }. \" +\n\t\"Action variants (use EXACTLY these fields): \" +\n\t'{ action: \"navigate\", url } | { action: \"click\", selector, fallbacks? } | ' +\n\t'{ action: \"fill\", selector, value_tpl } | { action: \"select\", selector, value_tpl } | ' +\n\t'{ action: \"wait_settle\" } | { action: \"checkpoint\", asserts } | ' +\n\t'{ action: \"decide\", goal } | { action: \"classify\" } | ' +\n\t'{ action: \"verify_visual\", expected_state } | { action: \"extract_semantic\", fields }. ' +\n\t'`extract_semantic.fields` MUST be a string array like [\"person\",\"count\"] (not an object), ' +\n\t\"and it takes no `goal` — only `decide` does.\";\n\n/** If an error is a browsertools inline-flow validation failure, append the\n * schema hint so the model fixes the flow on the next call. Other errors pass\n * through unchanged. */\nfunction enrichFlowError(error: unknown): unknown {\n\tconst message = error instanceof Error ? error.message : String(error);\n\tif (message.includes(\"invalid inline flow\") && !message.includes(\"Action variants\")) {\n\t\treturn new Error(`${message}\\n\\n${FLOW_SCHEMA_HINT}`);\n\t}\n\treturn error;\n}\n\n/** Best-effort: open a URL in the OS default browser. Never throws. Suppressed by\n * HOOCODE_BROWSERTOOLS_NO_OPEN (the URL is still surfaced to the agent). */\nfunction openInBrowser(url: string): boolean {\n\tconst suppress = process.env.HOOCODE_BROWSERTOOLS_NO_OPEN?.trim();\n\tif (suppress === \"1\" || suppress?.toLowerCase() === \"true\") return false;\n\tconst openCmd = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n\ttry {\n\t\texec(`${openCmd} \"${url}\"`);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** Start the streamed live viewer and auto-open it. Best-effort: a failure here\n * must not abort the flow, so it degrades to returning undefined. Returns a\n * human-readable status line to prepend to the tool result, or undefined.\n *\n * When the serve client is reused across browser_run calls (the\n * reclaimed-idle path), the viewer is already running on the same port, so we\n * skip re-issuing `live_view_start` and skip auto-opening a second OS tab —\n * the user keeps the one tab they already have. */\nasync function startLiveView(client: BrowsertoolsServeClient): Promise<string | undefined> {\n\tif (client.liveViewUrl) {\n\t\treturn `Live view already open at: ${client.liveViewUrl}`;\n\t}\n\ttry {\n\t\tconst result = await client.request<{ url?: string; error?: string }>(\"live_view_start\", {});\n\t\tif (!result?.url) return undefined;\n\t\tclient.liveViewUrl = result.url;\n\t\tconst opened = openInBrowser(result.url);\n\t\treturn opened ? `Live view opened in your browser: ${result.url}` : `Live view available at: ${result.url}`;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Fetch the suspension screenshot for a ParentRequest as an ImageContent block.\n * Best-effort: a fetch failure degrades to no image rather than failing the flow. */\nasync function fetchScreenshot(\n\tclient: BrowsertoolsServeClient,\n\trequest: ParentRequest,\n): Promise<ImageContent | undefined> {\n\tif (!request.screenshot_ref) return undefined;\n\ttry {\n\t\tconst resource = await client.request<GetResourceResult>(\"get_resource\", { ref: request.screenshot_ref });\n\t\tif (!resource?.png_base64) return undefined;\n\t\treturn { type: \"image\", data: resource.png_base64, mimeType: resource.mime || \"image/png\" };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Map a `flow_start`/`flow_resume` outcome to a tool result, owning the live\n * client: dispose it on terminal outcomes, or park it under the new resume token\n * when the flow suspends again. `rounds` is the number of NeedsParent yields seen\n * so far for this flow (including the one being processed), used for the cap.\n */\nexport async function advanceFlow(\n\tclient: BrowsertoolsServeClient,\n\toutcome: FlowOutcome,\n\trounds: number,\n\topts: ReturnType<typeof resolveBrowsertoolsOptions>,\n\tbrowserConfig?: BrowserClientConfig,\n): Promise<AgentToolResult<BrowserRunDetails>> {\n\tif (outcome.outcome === \"complete\") {\n\t\tif (browserConfig) {\n\t\t\tparkIdleClient(client, browserConfig.headful, browserConfig.browserPath, browserConfig.idleTimeoutMs);\n\t\t} else {\n\t\t\tclient.dispose();\n\t\t}\n\t\tconst result = outcome.result;\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: `Flow complete.\\n${JSON.stringify(result ?? {}, null, 2)}` }],\n\t\t\tdetails: { status: \"complete\", result },\n\t\t};\n\t}\n\n\tif (outcome.outcome === \"failed\") {\n\t\tif (browserConfig) {\n\t\t\tparkIdleClient(client, browserConfig.headful, browserConfig.browserPath, browserConfig.idleTimeoutMs);\n\t\t} else {\n\t\t\tclient.dispose();\n\t\t}\n\t\tconst where = outcome.step_id ? ` at step \"${outcome.step_id}\"` : \"\";\n\t\tconst kind = outcome.kind ? ` (${outcome.kind})` : \"\";\n\t\tthrow new Error(`browsertools flow failed${where}: ${outcome.detail ?? \"unknown error\"}${kind}`);\n\t}\n\n\tif (outcome.outcome === \"needs_parent\") {\n\t\tif (rounds > opts.maxParentRounds) {\n\t\t\tclient.dispose();\n\t\t\tthrow new Error(\n\t\t\t\t`browsertools flow exceeded the maximum of ${opts.maxParentRounds} NeedsParent rounds; aborting to avoid a runaway loop`,\n\t\t\t);\n\t\t}\n\t\tconst { request, token } = outcome;\n\t\tconst image = await fetchScreenshot(client, request);\n\t\tparkSession(\n\t\t\ttoken,\n\t\t\tclient,\n\t\t\trounds,\n\t\t\tbrowserConfig?.idleTimeoutMs ?? opts.idleTimeoutMs,\n\t\t\tbrowserConfig?.headful ?? false,\n\t\t\tbrowserConfig?.browserPath,\n\t\t);\n\n\t\tconst text =\n\t\t\t`Flow suspended — parent decision required (NeedsParent).\\n` +\n\t\t\t`${formatParentRequest(request)}\\n` +\n\t\t\t`resume token: ${token}\\n` +\n\t\t\t`${parentResponseHint(request.request)}\\n` +\n\t\t\t(image ? \"A screenshot of the current page is attached.\" : \"(no screenshot available)\");\n\t\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\t\tif (image) content.push(image);\n\t\treturn {\n\t\t\tcontent,\n\t\t\tdetails: { status: \"needs_parent\", token, requestKind: request.request },\n\t\t};\n\t}\n\n\tclient.dispose();\n\tthrow new Error(`browsertools returned an unrecognized flow outcome: ${JSON.stringify(outcome)}`);\n}\n\nexport function createBrowserRunToolDefinition(\n\tcwd: string,\n\toptions?: BrowserRunToolOptions,\n): ToolDefinition<typeof browserRunSchema, BrowserRunDetails> {\n\tconst opts = resolveBrowsertoolsOptions(options);\n\treturn defineTool({\n\t\tname: \"browser_run\",\n\t\tlabel: \"browser flow\",\n\t\tdescription:\n\t\t\t\"Start a deterministic browser flow (browsertools). Runs a saved .flow.json (or inline flow) \" +\n\t\t\t\"against a headless browser and returns the evidence on completion. If the flow needs an LLM \" +\n\t\t\t\"decision mid-replay (classify a page state, verify a visual, extract a value, decide the next \" +\n\t\t\t\"action, or re-identify a drifted element) it suspends and returns a typed request plus a \" +\n\t\t\t\"screenshot; answer it with the browser_continue tool using the returned token. Off by default; \" +\n\t\t\t\"enabled with --enable-browsertools.\\n\\n\" +\n\t\t\t\"AGENTIC LOOP (preferred for exploration): for any task where you must read or navigate based on \" +\n\t\t\t\"page content, build the flow from `decide`/`extract_semantic`/`classify`/`verify_visual` steps. \" +\n\t\t\t\"Each such step SUSPENDS and hands you a screenshot of the current page. Read the screenshot, then \" +\n\t\t\t\"call browser_continue with the next action, and keep looping until the outcome is `complete`. Do \" +\n\t\t\t\"NOT fall back to webfetch/curl to read page content you could read from the screenshot — that \" +\n\t\t\t\"bypasses the live session and breaks on auth-gated or JS-rendered pages. A flow ENDS as soon as \" +\n\t\t\t\"its last step runs, so chain several `decide` steps (interleaved with `wait_settle`) when you \" +\n\t\t\t\"need a multi-step journey (search -> open result -> scroll -> extract).\\n\\n\" +\n\t\t\t\"RESUME RESPONSE SHAPES (browser_continue `response` field): decide_next_action -> \" +\n\t\t\t'{ response: \"next_action\", action: <Action> }; classify_state -> { response: \"state\", state: \"<label>\" }; ' +\n\t\t\t'verify_visual -> { response: \"verified\", passed: true|false }; extract_semantic -> ' +\n\t\t\t'{ response: \"extracted\", fields: { <field>: <value> } }; reidentify_element -> ' +\n\t\t\t'{ response: \"element\", selector: \"<css>\" }.\\n\\n' +\n\t\t\t\"ACTION (for next_action) is the same shape as a flow step's action: { action: 'navigate', url }, \" +\n\t\t\t\"{ action: 'click', selector, fallbacks?: string[] }, { action: 'fill', selector, value_tpl }, \" +\n\t\t\t\"{ action: 'select', selector, value_tpl }, { action: 'wait_settle' }. Prefer stable CSS/id \" +\n\t\t\t\"selectors, and ALWAYS pass a `fallbacks` array of alternate selectors for click/fill, because \" +\n\t\t\t\"the primary selector often drifts (e.g. click '.suggestion-link' with fallbacks \" +\n\t\t\t\"['a.mw-searchSuggest-link', '#typeahead-suggestions a']).\\n\\n\" +\n\t\t\t\"VISIBILITY: pass headful:true to launch a real on-screen browser window the user can watch; \" +\n\t\t\t\"live_view:true additionally streams a mirror + tool-call log to a local URL (set live_view:false \" +\n\t\t\t\"to suppress the mirror when the instance defaults it on).\",\n\t\tpromptSnippet: \"Run a deterministic browser flow, pausing for LLM decisions when needed\",\n\t\tparameters: browserRunSchema,\n\t\tasync execute(_toolCallId, params: BrowserRunInput, signal) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tif (!params.flow_path && !params.flow) {\n\t\t\t\tthrow new Error(\"browser_run requires either `flow_path` or `flow`\");\n\t\t\t}\n\n\t\t\tconst binaryPath = await resolveBrowsertoolsBinary(options);\n\t\t\tconst headful = params.headful ?? opts.headful;\n\t\t\t// Reuse the shared idle client if browser config matches, otherwise create a new\n\t\t\t// one. This keeps a single Chromium process and live-view port across calls.\n\t\t\tlet client = takeIdleClient(headful, opts.browserPath, opts.idleTimeoutMs);\n\t\t\tif (!client) {\n\t\t\t\tclient = new BrowsertoolsServeClient(binaryPath, {\n\t\t\t\t\tcwd,\n\t\t\t\t\tbrowserPath: opts.browserPath,\n\t\t\t\t\tserveArgs: opts.serveArgs,\n\t\t\t\t\trequestTimeoutMs: opts.requestTimeoutMs,\n\t\t\t\t\theadful,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// If the call is aborted before we hand the client to the registry, make\n\t\t\t// sure the serve process is torn down.\n\t\t\tconst onAbort = () => client.dispose();\n\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\ttry {\n\t\t\t\tconst startParams: Record<string, unknown> = {};\n\t\t\t\tif (params.flow_path) startParams.flow_path = params.flow_path;\n\t\t\t\tif (params.flow) startParams.flow = params.flow;\n\t\t\t\tif (params.vars) startParams.vars = params.vars;\n\t\t\t\tif (params.store) startParams.store = params.store;\n\n\t\t\t\t// Bring up the live viewer before the flow runs so the page render and\n\t\t\t\t// tool-call log are visible from the first step. The per-call param wins\n\t\t\t\t// over the instance default (--enable-browser-live-preview).\n\t\t\t\tconst liveViewEnabled = params.live_view ?? opts.liveView;\n\t\t\t\tconst liveViewStatus = liveViewEnabled ? await startLiveView(client) : undefined;\n\n\t\t\t\tconst outcome = await client.request<FlowOutcome>(\"flow_start\", startParams);\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tclient.dispose();\n\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t}\n\t\t\t\tconst browserConfig: BrowserClientConfig = {\n\t\t\t\t\theadful,\n\t\t\t\t\tbrowserPath: opts.browserPath,\n\t\t\t\t\tidleTimeoutMs: opts.idleTimeoutMs,\n\t\t\t\t};\n\t\t\t\tconst result = await advanceFlow(client, outcome, 1, opts, browserConfig);\n\t\t\t\tif (liveViewStatus) {\n\t\t\t\t\tresult.content.unshift({ type: \"text\", text: liveViewStatus });\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\tclient.dispose();\n\t\t\t\tthrow enrichFlowError(error);\n\t\t\t} finally {\n\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t});\n}\n\nexport function createBrowserRunTool(cwd: string, options?: BrowserRunToolOptions): AgentTool<typeof browserRunSchema> {\n\treturn wrapToolDefinition(createBrowserRunToolDefinition(cwd, options));\n}\n"]}
@@ -1,377 +0,0 @@
1
- /**
2
- * `browser_run` tool: start a deterministic browsertools flow.
3
- *
4
- * Spawns a `browsertools serve` process and issues `flow_start`. If the flow
5
- * runs to completion deterministically it returns the evidence inline. If replay
6
- * hits a point only an LLM can resolve, the serve process suspends with
7
- * `Outcome::NeedsParent`: this tool fetches the suspension screenshot, parks the
8
- * live session under its `ResumeToken`, and returns the typed `ParentRequest`
9
- * (plus the screenshot as an image) to the agent. The agent reasons and answers
10
- * with the companion `browser_continue` tool. See {@link browsertools-shared}.
11
- */
12
- import { exec } from "node:child_process";
13
- import { Type } from "typebox";
14
- import { defineTool } from "../../extensions/types.js";
15
- import { wrapToolDefinition } from "../tool-definition-wrapper.js";
16
- import { BrowsertoolsServeClient, parkIdleClient, parkSession, resolveBrowsertoolsBinary, resolveBrowsertoolsOptions, takeIdleClient, } from "./browsertools-shared.js";
17
- const browserRunSchema = Type.Object({
18
- flow_path: Type.Optional(Type.String({ description: "Path to the .flow.json file to execute. Provide this or `flow`." })),
19
- flow: Type.Optional(Type.Record(Type.String(), Type.Unknown(), {
20
- description: "Inline flow definition object (alternative to `flow_path`). Shape: " +
21
- "{ id: string, name: string, version: number, start_url: string, steps: Step[] }. " +
22
- "Each Step is { id: string, action: Action }. Action is a tagged object keyed by " +
23
- "`action`; the exact fields per variant (do NOT add extras like `goal` to the wrong " +
24
- "variant): " +
25
- '{ action: "navigate", url: string } | ' +
26
- '{ action: "click", selector: string, fallbacks?: string[] } | ' +
27
- '{ action: "fill", selector: string, value_tpl: string } | ' +
28
- '{ action: "select", selector: string, value_tpl: string } | ' +
29
- '{ action: "wait_settle" } | ' +
30
- '{ action: "checkpoint", asserts: Invariant[] } | ' +
31
- '{ action: "decide", goal: string } | ' +
32
- '{ action: "classify" } | ' +
33
- '{ action: "verify_visual", expected_state: string } | ' +
34
- '{ action: "extract_semantic", fields: string[] }. ' +
35
- "IMPORTANT: `extract_semantic.fields` MUST be an array of field-name strings " +
36
- '(e.g. ["person", "movie_count"]), never an object/map, and `extract_semantic` takes ' +
37
- "no `goal` (only `decide` does). Invariant (for checkpoint asserts) is one of: " +
38
- '{ kind: "element_present", selector: string } | ' +
39
- '{ kind: "text_present", selector?: string, substr: string } | ' +
40
- '{ kind: "url_matches", pattern: string }.',
41
- })),
42
- vars: Type.Optional(Type.Record(Type.String(), Type.Unknown(), {
43
- description: "Variables interpolated into the flow ({{var}} placeholders).",
44
- })),
45
- store: Type.Optional(Type.String({ description: "Path to the evidence store directory for this run." })),
46
- live_view: Type.Optional(Type.Boolean({
47
- description: "Start a live viewer that streams the page and the agent's tool-call log over a local " +
48
- "WebSocket, and auto-open it in your default browser. Set HOOCODE_BROWSERTOOLS_NO_OPEN=1 to " +
49
- "print the URL without opening. Best for flows that suspend or run long.",
50
- })),
51
- headful: Type.Optional(Type.Boolean({
52
- description: "Launch a real on-screen Chromium window instead of a headless browser. Requires a desktop " +
53
- "display; unlike live_view it does not show the tool-call log.",
54
- })),
55
- });
56
- /** ParentResponse shape hint per ParentRequest kind (mirrors contract.rs). */
57
- function parentResponseHint(kind) {
58
- switch (kind) {
59
- case "classify_state":
60
- return 'Reply with browser_continue response: { "response": "state", "state": "<your label>" }';
61
- case "verify_visual":
62
- return 'Reply with browser_continue response: { "response": "verified", "passed": true | false }';
63
- case "extract_semantic":
64
- return 'Reply with browser_continue response: { "response": "extracted", "fields": { "<field>": "<value>", ... } }';
65
- case "decide_next_action":
66
- return 'Reply with browser_continue response: { "response": "next_action", "action": <action object> }';
67
- case "reidentify_element":
68
- return 'Reply with browser_continue response: { "response": "element", "selector": "<css selector>" }';
69
- default:
70
- return "Reply with browser_continue providing the appropriate ParentResponse object.";
71
- }
72
- }
73
- /** Truncate a string to `max` chars with an ellipsis, for compact rendering. */
74
- function clip(s, max = 80) {
75
- const t = s.trim();
76
- return t.length > max ? `${t.slice(0, max - 1)}\u2026` : t;
77
- }
78
- /** Render one observation control as a single compact line. */
79
- function renderControl(i) {
80
- const sel = i.selector_hint && i.selector_hint !== "button" ? i.selector_hint : undefined;
81
- const name = i.accessible_name ? `"${clip(i.accessible_name, 60)}"` : undefined;
82
- const parts = [i.kind, name, sel].filter(Boolean);
83
- return ` - ${parts.join(" ")}`;
84
- }
85
- /**
86
- * Summarize a verbose `decide_next_action`/`classify_state` observation into a
87
- * compact, readable block instead of dumping the raw JSON (which on busy pages is
88
- * thousands of mostly-empty entries straight into the model context). The
89
- * screenshot already conveys the page; this is just the actionable text layer:
90
- * url/title, named controls, salient headings. Returns undefined when there is no
91
- * observation to summarize.
92
- */
93
- function summarizeObservation(observation) {
94
- if (!observation || typeof observation !== "object")
95
- return undefined;
96
- const lines = [];
97
- if (observation.title)
98
- lines.push(`page: ${clip(observation.title, 100)}`);
99
- if (observation.url)
100
- lines.push(`url: ${clip(observation.url, 120)}`);
101
- if (observation.has_error_region)
102
- lines.push("note: page has an error/alert region");
103
- const controls = (observation.inputs ?? []).filter((i) => i.kind !== "_more");
104
- if (controls.length) {
105
- lines.push(`controls (${controls.length}):`);
106
- for (const c of controls.slice(0, 25))
107
- lines.push(renderControl(c));
108
- if (controls.length > 25)
109
- lines.push(` - …+${controls.length - 25} more`);
110
- }
111
- const text = (observation.text_blocks ?? []).filter((t) => t?.trim());
112
- if (text.length) {
113
- lines.push(`headings: ${text
114
- .slice(0, 12)
115
- .map((t) => clip(t, 50))
116
- .join(" · ")}`);
117
- }
118
- return lines.length ? lines.join("\n") : undefined;
119
- }
120
- /**
121
- * Build the compact, model-facing text for a `NeedsParent` suspension. Renders
122
- * only the fields that matter per request kind (goal, expected_state, fields,
123
- * description) plus a summarized observation, rather than pretty-printing the
124
- * entire request — which is the dominant token sink for browser flows.
125
- */
126
- function formatParentRequest(request) {
127
- const kind = request.request;
128
- const lines = [`request: ${kind}`];
129
- const r = request;
130
- if (r.goal)
131
- lines.push(`goal: ${r.goal}`);
132
- if (r.expected_state)
133
- lines.push(`expected_state: ${r.expected_state}`);
134
- if (r.description)
135
- lines.push(`element: ${r.description}`);
136
- if (Array.isArray(r.fields) && r.fields.length)
137
- lines.push(`fields: ${r.fields.join(", ")}`);
138
- const summary = summarizeObservation(r.observation);
139
- if (summary)
140
- lines.push(summary);
141
- return lines.join("\n");
142
- }
143
- /** Compact, model-facing reminder of the inline-flow action schema, appended to
144
- * an `invalid inline flow` error so the model can self-correct in one turn
145
- * instead of guessing field shapes across several rounds. */
146
- const FLOW_SCHEMA_HINT = "Inline flow shape: { id, name, version, start_url, steps: [{ id, action }] }. " +
147
- "Action variants (use EXACTLY these fields): " +
148
- '{ action: "navigate", url } | { action: "click", selector, fallbacks? } | ' +
149
- '{ action: "fill", selector, value_tpl } | { action: "select", selector, value_tpl } | ' +
150
- '{ action: "wait_settle" } | { action: "checkpoint", asserts } | ' +
151
- '{ action: "decide", goal } | { action: "classify" } | ' +
152
- '{ action: "verify_visual", expected_state } | { action: "extract_semantic", fields }. ' +
153
- '`extract_semantic.fields` MUST be a string array like ["person","count"] (not an object), ' +
154
- "and it takes no `goal` — only `decide` does.";
155
- /** If an error is a browsertools inline-flow validation failure, append the
156
- * schema hint so the model fixes the flow on the next call. Other errors pass
157
- * through unchanged. */
158
- function enrichFlowError(error) {
159
- const message = error instanceof Error ? error.message : String(error);
160
- if (message.includes("invalid inline flow") && !message.includes("Action variants")) {
161
- return new Error(`${message}\n\n${FLOW_SCHEMA_HINT}`);
162
- }
163
- return error;
164
- }
165
- /** Best-effort: open a URL in the OS default browser. Never throws. Suppressed by
166
- * HOOCODE_BROWSERTOOLS_NO_OPEN (the URL is still surfaced to the agent). */
167
- function openInBrowser(url) {
168
- const suppress = process.env.HOOCODE_BROWSERTOOLS_NO_OPEN?.trim();
169
- if (suppress === "1" || suppress?.toLowerCase() === "true")
170
- return false;
171
- const openCmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
172
- try {
173
- exec(`${openCmd} "${url}"`);
174
- return true;
175
- }
176
- catch {
177
- return false;
178
- }
179
- }
180
- /** Start the streamed live viewer and auto-open it. Best-effort: a failure here
181
- * must not abort the flow, so it degrades to returning undefined. Returns a
182
- * human-readable status line to prepend to the tool result, or undefined.
183
- *
184
- * When the serve client is reused across browser_run calls (the
185
- * reclaimed-idle path), the viewer is already running on the same port, so we
186
- * skip re-issuing `live_view_start` and skip auto-opening a second OS tab —
187
- * the user keeps the one tab they already have. */
188
- async function startLiveView(client) {
189
- if (client.liveViewUrl) {
190
- return `Live view already open at: ${client.liveViewUrl}`;
191
- }
192
- try {
193
- const result = await client.request("live_view_start", {});
194
- if (!result?.url)
195
- return undefined;
196
- client.liveViewUrl = result.url;
197
- const opened = openInBrowser(result.url);
198
- return opened ? `Live view opened in your browser: ${result.url}` : `Live view available at: ${result.url}`;
199
- }
200
- catch {
201
- return undefined;
202
- }
203
- }
204
- /** Fetch the suspension screenshot for a ParentRequest as an ImageContent block.
205
- * Best-effort: a fetch failure degrades to no image rather than failing the flow. */
206
- async function fetchScreenshot(client, request) {
207
- if (!request.screenshot_ref)
208
- return undefined;
209
- try {
210
- const resource = await client.request("get_resource", { ref: request.screenshot_ref });
211
- if (!resource?.png_base64)
212
- return undefined;
213
- return { type: "image", data: resource.png_base64, mimeType: resource.mime || "image/png" };
214
- }
215
- catch {
216
- return undefined;
217
- }
218
- }
219
- /**
220
- * Map a `flow_start`/`flow_resume` outcome to a tool result, owning the live
221
- * client: dispose it on terminal outcomes, or park it under the new resume token
222
- * when the flow suspends again. `rounds` is the number of NeedsParent yields seen
223
- * so far for this flow (including the one being processed), used for the cap.
224
- */
225
- export async function advanceFlow(client, outcome, rounds, opts, browserConfig) {
226
- if (outcome.outcome === "complete") {
227
- if (browserConfig) {
228
- parkIdleClient(client, browserConfig.headful, browserConfig.browserPath, browserConfig.idleTimeoutMs);
229
- }
230
- else {
231
- client.dispose();
232
- }
233
- const result = outcome.result;
234
- return {
235
- content: [{ type: "text", text: `Flow complete.\n${JSON.stringify(result ?? {}, null, 2)}` }],
236
- details: { status: "complete", result },
237
- };
238
- }
239
- if (outcome.outcome === "failed") {
240
- if (browserConfig) {
241
- parkIdleClient(client, browserConfig.headful, browserConfig.browserPath, browserConfig.idleTimeoutMs);
242
- }
243
- else {
244
- client.dispose();
245
- }
246
- const where = outcome.step_id ? ` at step "${outcome.step_id}"` : "";
247
- const kind = outcome.kind ? ` (${outcome.kind})` : "";
248
- throw new Error(`browsertools flow failed${where}: ${outcome.detail ?? "unknown error"}${kind}`);
249
- }
250
- if (outcome.outcome === "needs_parent") {
251
- if (rounds > opts.maxParentRounds) {
252
- client.dispose();
253
- throw new Error(`browsertools flow exceeded the maximum of ${opts.maxParentRounds} NeedsParent rounds; aborting to avoid a runaway loop`);
254
- }
255
- const { request, token } = outcome;
256
- const image = await fetchScreenshot(client, request);
257
- parkSession(token, client, rounds, browserConfig?.idleTimeoutMs ?? opts.idleTimeoutMs, browserConfig?.headful ?? false, browserConfig?.browserPath);
258
- const text = `Flow suspended — parent decision required (NeedsParent).\n` +
259
- `${formatParentRequest(request)}\n` +
260
- `resume token: ${token}\n` +
261
- `${parentResponseHint(request.request)}\n` +
262
- (image ? "A screenshot of the current page is attached." : "(no screenshot available)");
263
- const content = [{ type: "text", text }];
264
- if (image)
265
- content.push(image);
266
- return {
267
- content,
268
- details: { status: "needs_parent", token, requestKind: request.request },
269
- };
270
- }
271
- client.dispose();
272
- throw new Error(`browsertools returned an unrecognized flow outcome: ${JSON.stringify(outcome)}`);
273
- }
274
- export function createBrowserRunToolDefinition(cwd, options) {
275
- const opts = resolveBrowsertoolsOptions(options);
276
- return defineTool({
277
- name: "browser_run",
278
- label: "browser flow",
279
- description: "Start a deterministic browser flow (browsertools). Runs a saved .flow.json (or inline flow) " +
280
- "against a headless browser and returns the evidence on completion. If the flow needs an LLM " +
281
- "decision mid-replay (classify a page state, verify a visual, extract a value, decide the next " +
282
- "action, or re-identify a drifted element) it suspends and returns a typed request plus a " +
283
- "screenshot; answer it with the browser_continue tool using the returned token. Off by default; " +
284
- "enabled with --enable-browsertools.\n\n" +
285
- "AGENTIC LOOP (preferred for exploration): for any task where you must read or navigate based on " +
286
- "page content, build the flow from `decide`/`extract_semantic`/`classify`/`verify_visual` steps. " +
287
- "Each such step SUSPENDS and hands you a screenshot of the current page. Read the screenshot, then " +
288
- "call browser_continue with the next action, and keep looping until the outcome is `complete`. Do " +
289
- "NOT fall back to webfetch/curl to read page content you could read from the screenshot — that " +
290
- "bypasses the live session and breaks on auth-gated or JS-rendered pages. A flow ENDS as soon as " +
291
- "its last step runs, so chain several `decide` steps (interleaved with `wait_settle`) when you " +
292
- "need a multi-step journey (search -> open result -> scroll -> extract).\n\n" +
293
- "RESUME RESPONSE SHAPES (browser_continue `response` field): decide_next_action -> " +
294
- '{ response: "next_action", action: <Action> }; classify_state -> { response: "state", state: "<label>" }; ' +
295
- 'verify_visual -> { response: "verified", passed: true|false }; extract_semantic -> ' +
296
- '{ response: "extracted", fields: { <field>: <value> } }; reidentify_element -> ' +
297
- '{ response: "element", selector: "<css>" }.\n\n' +
298
- "ACTION (for next_action) is the same shape as a flow step's action: { action: 'navigate', url }, " +
299
- "{ action: 'click', selector, fallbacks?: string[] }, { action: 'fill', selector, value_tpl }, " +
300
- "{ action: 'select', selector, value_tpl }, { action: 'wait_settle' }. Prefer stable CSS/id " +
301
- "selectors, and ALWAYS pass a `fallbacks` array of alternate selectors for click/fill, because " +
302
- "the primary selector often drifts (e.g. click '.suggestion-link' with fallbacks " +
303
- "['a.mw-searchSuggest-link', '#typeahead-suggestions a']).\n\n" +
304
- "VISIBILITY: pass headful:true to launch a real on-screen browser window the user can watch; " +
305
- "live_view:true additionally streams a mirror + tool-call log to a local URL (set live_view:false " +
306
- "to suppress the mirror when the instance defaults it on).",
307
- promptSnippet: "Run a deterministic browser flow, pausing for LLM decisions when needed",
308
- parameters: browserRunSchema,
309
- async execute(_toolCallId, params, signal) {
310
- if (signal?.aborted)
311
- throw new Error("Operation aborted");
312
- if (!params.flow_path && !params.flow) {
313
- throw new Error("browser_run requires either `flow_path` or `flow`");
314
- }
315
- const binaryPath = await resolveBrowsertoolsBinary(options);
316
- const headful = params.headful ?? opts.headful;
317
- // Reuse the shared idle client if browser config matches, otherwise create a new
318
- // one. This keeps a single Chromium process and live-view port across calls.
319
- let client = takeIdleClient(headful, opts.browserPath, opts.idleTimeoutMs);
320
- if (!client) {
321
- client = new BrowsertoolsServeClient(binaryPath, {
322
- cwd,
323
- browserPath: opts.browserPath,
324
- serveArgs: opts.serveArgs,
325
- requestTimeoutMs: opts.requestTimeoutMs,
326
- headful,
327
- });
328
- }
329
- // If the call is aborted before we hand the client to the registry, make
330
- // sure the serve process is torn down.
331
- const onAbort = () => client.dispose();
332
- signal?.addEventListener("abort", onAbort, { once: true });
333
- try {
334
- const startParams = {};
335
- if (params.flow_path)
336
- startParams.flow_path = params.flow_path;
337
- if (params.flow)
338
- startParams.flow = params.flow;
339
- if (params.vars)
340
- startParams.vars = params.vars;
341
- if (params.store)
342
- startParams.store = params.store;
343
- // Bring up the live viewer before the flow runs so the page render and
344
- // tool-call log are visible from the first step. The per-call param wins
345
- // over the instance default (--enable-browser-live-preview).
346
- const liveViewEnabled = params.live_view ?? opts.liveView;
347
- const liveViewStatus = liveViewEnabled ? await startLiveView(client) : undefined;
348
- const outcome = await client.request("flow_start", startParams);
349
- if (signal?.aborted) {
350
- client.dispose();
351
- throw new Error("Operation aborted");
352
- }
353
- const browserConfig = {
354
- headful,
355
- browserPath: opts.browserPath,
356
- idleTimeoutMs: opts.idleTimeoutMs,
357
- };
358
- const result = await advanceFlow(client, outcome, 1, opts, browserConfig);
359
- if (liveViewStatus) {
360
- result.content.unshift({ type: "text", text: liveViewStatus });
361
- }
362
- return result;
363
- }
364
- catch (error) {
365
- client.dispose();
366
- throw enrichFlowError(error);
367
- }
368
- finally {
369
- signal?.removeEventListener("abort", onAbort);
370
- }
371
- },
372
- });
373
- }
374
- export function createBrowserRunTool(cwd, options) {
375
- return wrapToolDefinition(createBrowserRunToolDefinition(cwd, options));
376
- }
377
- //# sourceMappingURL=browser-run.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser-run.js","sourceRoot":"","sources":["../../../../src/core/tools/browser/browser-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,IAAI,EAA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AAAA,CACxE","sourcesContent":["/**\n * `browser_run` tool: start a deterministic browsertools flow.\n *\n * Spawns a `browsertools serve` process and issues `flow_start`. If the flow\n * runs to completion deterministically it returns the evidence inline. If replay\n * hits a point only an LLM can resolve, the serve process suspends with\n * `Outcome::NeedsParent`: this tool fetches the suspension screenshot, parks the\n * live session under its `ResumeToken`, and returns the typed `ParentRequest`\n * (plus the screenshot as an image) to the agent. The agent reasons and answers\n * with the companion `browser_continue` tool. See {@link browsertools-shared}.\n */\n\nimport { exec } from \"node:child_process\";\nimport type { AgentTool } from \"@kolisachint/hoocode-agent-core\";\nimport type { ImageContent, TextContent } from \"@kolisachint/hoocode-ai\";\nimport { type Static, Type } from \"typebox\";\nimport type { AgentToolResult } from \"../../extensions/types.js\";\nimport { defineTool, type ToolDefinition } from \"../../extensions/types.js\";\nimport { wrapToolDefinition } from \"../tool-definition-wrapper.js\";\nimport {\n\ttype BrowserClientConfig,\n\tBrowsertoolsServeClient,\n\ttype BrowsertoolsToolOptions,\n\ttype FlowOutcome,\n\ttype GetResourceResult,\n\ttype ParentRequest,\n\tparkIdleClient,\n\tparkSession,\n\ttype ResumeToken,\n\tresolveBrowsertoolsBinary,\n\tresolveBrowsertoolsOptions,\n\ttakeIdleClient,\n} from \"./browsertools-shared.js\";\n\nconst browserRunSchema = Type.Object({\n\tflow_path: Type.Optional(\n\t\tType.String({ description: \"Path to the .flow.json file to execute. Provide this or `flow`.\" }),\n\t),\n\tflow: Type.Optional(\n\t\tType.Record(Type.String(), Type.Unknown(), {\n\t\t\tdescription:\n\t\t\t\t\"Inline flow definition object (alternative to `flow_path`). Shape: \" +\n\t\t\t\t\"{ id: string, name: string, version: number, start_url: string, steps: Step[] }. \" +\n\t\t\t\t\"Each Step is { id: string, action: Action }. Action is a tagged object keyed by \" +\n\t\t\t\t\"`action`; the exact fields per variant (do NOT add extras like `goal` to the wrong \" +\n\t\t\t\t\"variant): \" +\n\t\t\t\t'{ action: \"navigate\", url: string } | ' +\n\t\t\t\t'{ action: \"click\", selector: string, fallbacks?: string[] } | ' +\n\t\t\t\t'{ action: \"fill\", selector: string, value_tpl: string } | ' +\n\t\t\t\t'{ action: \"select\", selector: string, value_tpl: string } | ' +\n\t\t\t\t'{ action: \"wait_settle\" } | ' +\n\t\t\t\t'{ action: \"checkpoint\", asserts: Invariant[] } | ' +\n\t\t\t\t'{ action: \"decide\", goal: string } | ' +\n\t\t\t\t'{ action: \"classify\" } | ' +\n\t\t\t\t'{ action: \"verify_visual\", expected_state: string } | ' +\n\t\t\t\t'{ action: \"extract_semantic\", fields: string[] }. ' +\n\t\t\t\t\"IMPORTANT: `extract_semantic.fields` MUST be an array of field-name strings \" +\n\t\t\t\t'(e.g. [\"person\", \"movie_count\"]), never an object/map, and `extract_semantic` takes ' +\n\t\t\t\t\"no `goal` (only `decide` does). Invariant (for checkpoint asserts) is one of: \" +\n\t\t\t\t'{ kind: \"element_present\", selector: string } | ' +\n\t\t\t\t'{ kind: \"text_present\", selector?: string, substr: string } | ' +\n\t\t\t\t'{ kind: \"url_matches\", pattern: string }.',\n\t\t}),\n\t),\n\tvars: Type.Optional(\n\t\tType.Record(Type.String(), Type.Unknown(), {\n\t\t\tdescription: \"Variables interpolated into the flow ({{var}} placeholders).\",\n\t\t}),\n\t),\n\tstore: Type.Optional(Type.String({ description: \"Path to the evidence store directory for this run.\" })),\n\tlive_view: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Start a live viewer that streams the page and the agent's tool-call log over a local \" +\n\t\t\t\t\"WebSocket, and auto-open it in your default browser. Set HOOCODE_BROWSERTOOLS_NO_OPEN=1 to \" +\n\t\t\t\t\"print the URL without opening. Best for flows that suspend or run long.\",\n\t\t}),\n\t),\n\theadful: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Launch a real on-screen Chromium window instead of a headless browser. Requires a desktop \" +\n\t\t\t\t\"display; unlike live_view it does not show the tool-call log.\",\n\t\t}),\n\t),\n});\n\nexport type BrowserRunInput = Static<typeof browserRunSchema>;\n\n/** Structured details surfaced alongside the model-facing content. */\nexport interface BrowserRunDetails {\n\tstatus: \"complete\" | \"needs_parent\";\n\t/** Present when status is \"needs_parent\": resume with this token. */\n\ttoken?: ResumeToken;\n\t/** Present when status is \"needs_parent\": the kind of parent request. */\n\trequestKind?: ParentRequest[\"request\"];\n\t/** Present when status is \"complete\": the flow result/evidence. */\n\tresult?: unknown;\n}\n\nexport interface BrowserRunToolOptions extends BrowsertoolsToolOptions {}\n\n/** ParentResponse shape hint per ParentRequest kind (mirrors contract.rs). */\nfunction parentResponseHint(kind: ParentRequest[\"request\"]): string {\n\tswitch (kind) {\n\t\tcase \"classify_state\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"state\", \"state\": \"<your label>\" }';\n\t\tcase \"verify_visual\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"verified\", \"passed\": true | false }';\n\t\tcase \"extract_semantic\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"extracted\", \"fields\": { \"<field>\": \"<value>\", ... } }';\n\t\tcase \"decide_next_action\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"next_action\", \"action\": <action object> }';\n\t\tcase \"reidentify_element\":\n\t\t\treturn 'Reply with browser_continue response: { \"response\": \"element\", \"selector\": \"<css selector>\" }';\n\t\tdefault:\n\t\t\treturn \"Reply with browser_continue providing the appropriate ParentResponse object.\";\n\t}\n}\n\n/** A control fact from the browsertools observation (mirrors observe.rs InputFact). */\ninterface ObservationInput {\n\tkind?: string;\n\taccessible_name?: string;\n\tselector_hint?: string;\n}\n\n/** A landmark fact from the browsertools observation (mirrors observe.rs Landmark). */\ninterface ObservationLandmark {\n\trole?: string;\n\tname?: string;\n}\n\n/** The HTML-derived observation the engine attaches to decide/classify requests. */\ninterface Observation {\n\turl?: string;\n\ttitle?: string;\n\tinputs?: ObservationInput[];\n\tlandmarks?: ObservationLandmark[];\n\ttext_blocks?: string[];\n\thas_error_region?: boolean;\n}\n\n/** Truncate a string to `max` chars with an ellipsis, for compact rendering. */\nfunction clip(s: string, max = 80): string {\n\tconst t = s.trim();\n\treturn t.length > max ? `${t.slice(0, max - 1)}\\u2026` : t;\n}\n\n/** Render one observation control as a single compact line. */\nfunction renderControl(i: ObservationInput): string {\n\tconst sel = i.selector_hint && i.selector_hint !== \"button\" ? i.selector_hint : undefined;\n\tconst name = i.accessible_name ? `\"${clip(i.accessible_name, 60)}\"` : undefined;\n\tconst parts = [i.kind, name, sel].filter(Boolean);\n\treturn ` - ${parts.join(\" \")}`;\n}\n\n/**\n * Summarize a verbose `decide_next_action`/`classify_state` observation into a\n * compact, readable block instead of dumping the raw JSON (which on busy pages is\n * thousands of mostly-empty entries straight into the model context). The\n * screenshot already conveys the page; this is just the actionable text layer:\n * url/title, named controls, salient headings. Returns undefined when there is no\n * observation to summarize.\n */\nfunction summarizeObservation(observation: Observation | undefined): string | undefined {\n\tif (!observation || typeof observation !== \"object\") return undefined;\n\tconst lines: string[] = [];\n\tif (observation.title) lines.push(`page: ${clip(observation.title, 100)}`);\n\tif (observation.url) lines.push(`url: ${clip(observation.url, 120)}`);\n\tif (observation.has_error_region) lines.push(\"note: page has an error/alert region\");\n\n\tconst controls = (observation.inputs ?? []).filter((i) => i.kind !== \"_more\");\n\tif (controls.length) {\n\t\tlines.push(`controls (${controls.length}):`);\n\t\tfor (const c of controls.slice(0, 25)) lines.push(renderControl(c));\n\t\tif (controls.length > 25) lines.push(` - …+${controls.length - 25} more`);\n\t}\n\n\tconst text = (observation.text_blocks ?? []).filter((t) => t?.trim());\n\tif (text.length) {\n\t\tlines.push(\n\t\t\t`headings: ${text\n\t\t\t\t.slice(0, 12)\n\t\t\t\t.map((t) => clip(t, 50))\n\t\t\t\t.join(\" · \")}`,\n\t\t);\n\t}\n\treturn lines.length ? lines.join(\"\\n\") : undefined;\n}\n\n/**\n * Build the compact, model-facing text for a `NeedsParent` suspension. Renders\n * only the fields that matter per request kind (goal, expected_state, fields,\n * description) plus a summarized observation, rather than pretty-printing the\n * entire request — which is the dominant token sink for browser flows.\n */\nfunction formatParentRequest(request: ParentRequest): string {\n\tconst kind = request.request;\n\tconst lines: string[] = [`request: ${kind}`];\n\tconst r = request as ParentRequest & {\n\t\tgoal?: string;\n\t\texpected_state?: string;\n\t\tdescription?: string;\n\t\tfields?: string[];\n\t\tobservation?: Observation;\n\t};\n\tif (r.goal) lines.push(`goal: ${r.goal}`);\n\tif (r.expected_state) lines.push(`expected_state: ${r.expected_state}`);\n\tif (r.description) lines.push(`element: ${r.description}`);\n\tif (Array.isArray(r.fields) && r.fields.length) lines.push(`fields: ${r.fields.join(\", \")}`);\n\tconst summary = summarizeObservation(r.observation);\n\tif (summary) lines.push(summary);\n\treturn lines.join(\"\\n\");\n}\n\n/** Compact, model-facing reminder of the inline-flow action schema, appended to\n * an `invalid inline flow` error so the model can self-correct in one turn\n * instead of guessing field shapes across several rounds. */\nconst FLOW_SCHEMA_HINT =\n\t\"Inline flow shape: { id, name, version, start_url, steps: [{ id, action }] }. \" +\n\t\"Action variants (use EXACTLY these fields): \" +\n\t'{ action: \"navigate\", url } | { action: \"click\", selector, fallbacks? } | ' +\n\t'{ action: \"fill\", selector, value_tpl } | { action: \"select\", selector, value_tpl } | ' +\n\t'{ action: \"wait_settle\" } | { action: \"checkpoint\", asserts } | ' +\n\t'{ action: \"decide\", goal } | { action: \"classify\" } | ' +\n\t'{ action: \"verify_visual\", expected_state } | { action: \"extract_semantic\", fields }. ' +\n\t'`extract_semantic.fields` MUST be a string array like [\"person\",\"count\"] (not an object), ' +\n\t\"and it takes no `goal` — only `decide` does.\";\n\n/** If an error is a browsertools inline-flow validation failure, append the\n * schema hint so the model fixes the flow on the next call. Other errors pass\n * through unchanged. */\nfunction enrichFlowError(error: unknown): unknown {\n\tconst message = error instanceof Error ? error.message : String(error);\n\tif (message.includes(\"invalid inline flow\") && !message.includes(\"Action variants\")) {\n\t\treturn new Error(`${message}\\n\\n${FLOW_SCHEMA_HINT}`);\n\t}\n\treturn error;\n}\n\n/** Best-effort: open a URL in the OS default browser. Never throws. Suppressed by\n * HOOCODE_BROWSERTOOLS_NO_OPEN (the URL is still surfaced to the agent). */\nfunction openInBrowser(url: string): boolean {\n\tconst suppress = process.env.HOOCODE_BROWSERTOOLS_NO_OPEN?.trim();\n\tif (suppress === \"1\" || suppress?.toLowerCase() === \"true\") return false;\n\tconst openCmd = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n\ttry {\n\t\texec(`${openCmd} \"${url}\"`);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** Start the streamed live viewer and auto-open it. Best-effort: a failure here\n * must not abort the flow, so it degrades to returning undefined. Returns a\n * human-readable status line to prepend to the tool result, or undefined.\n *\n * When the serve client is reused across browser_run calls (the\n * reclaimed-idle path), the viewer is already running on the same port, so we\n * skip re-issuing `live_view_start` and skip auto-opening a second OS tab —\n * the user keeps the one tab they already have. */\nasync function startLiveView(client: BrowsertoolsServeClient): Promise<string | undefined> {\n\tif (client.liveViewUrl) {\n\t\treturn `Live view already open at: ${client.liveViewUrl}`;\n\t}\n\ttry {\n\t\tconst result = await client.request<{ url?: string; error?: string }>(\"live_view_start\", {});\n\t\tif (!result?.url) return undefined;\n\t\tclient.liveViewUrl = result.url;\n\t\tconst opened = openInBrowser(result.url);\n\t\treturn opened ? `Live view opened in your browser: ${result.url}` : `Live view available at: ${result.url}`;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Fetch the suspension screenshot for a ParentRequest as an ImageContent block.\n * Best-effort: a fetch failure degrades to no image rather than failing the flow. */\nasync function fetchScreenshot(\n\tclient: BrowsertoolsServeClient,\n\trequest: ParentRequest,\n): Promise<ImageContent | undefined> {\n\tif (!request.screenshot_ref) return undefined;\n\ttry {\n\t\tconst resource = await client.request<GetResourceResult>(\"get_resource\", { ref: request.screenshot_ref });\n\t\tif (!resource?.png_base64) return undefined;\n\t\treturn { type: \"image\", data: resource.png_base64, mimeType: resource.mime || \"image/png\" };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Map a `flow_start`/`flow_resume` outcome to a tool result, owning the live\n * client: dispose it on terminal outcomes, or park it under the new resume token\n * when the flow suspends again. `rounds` is the number of NeedsParent yields seen\n * so far for this flow (including the one being processed), used for the cap.\n */\nexport async function advanceFlow(\n\tclient: BrowsertoolsServeClient,\n\toutcome: FlowOutcome,\n\trounds: number,\n\topts: ReturnType<typeof resolveBrowsertoolsOptions>,\n\tbrowserConfig?: BrowserClientConfig,\n): Promise<AgentToolResult<BrowserRunDetails>> {\n\tif (outcome.outcome === \"complete\") {\n\t\tif (browserConfig) {\n\t\t\tparkIdleClient(client, browserConfig.headful, browserConfig.browserPath, browserConfig.idleTimeoutMs);\n\t\t} else {\n\t\t\tclient.dispose();\n\t\t}\n\t\tconst result = outcome.result;\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: `Flow complete.\\n${JSON.stringify(result ?? {}, null, 2)}` }],\n\t\t\tdetails: { status: \"complete\", result },\n\t\t};\n\t}\n\n\tif (outcome.outcome === \"failed\") {\n\t\tif (browserConfig) {\n\t\t\tparkIdleClient(client, browserConfig.headful, browserConfig.browserPath, browserConfig.idleTimeoutMs);\n\t\t} else {\n\t\t\tclient.dispose();\n\t\t}\n\t\tconst where = outcome.step_id ? ` at step \"${outcome.step_id}\"` : \"\";\n\t\tconst kind = outcome.kind ? ` (${outcome.kind})` : \"\";\n\t\tthrow new Error(`browsertools flow failed${where}: ${outcome.detail ?? \"unknown error\"}${kind}`);\n\t}\n\n\tif (outcome.outcome === \"needs_parent\") {\n\t\tif (rounds > opts.maxParentRounds) {\n\t\t\tclient.dispose();\n\t\t\tthrow new Error(\n\t\t\t\t`browsertools flow exceeded the maximum of ${opts.maxParentRounds} NeedsParent rounds; aborting to avoid a runaway loop`,\n\t\t\t);\n\t\t}\n\t\tconst { request, token } = outcome;\n\t\tconst image = await fetchScreenshot(client, request);\n\t\tparkSession(\n\t\t\ttoken,\n\t\t\tclient,\n\t\t\trounds,\n\t\t\tbrowserConfig?.idleTimeoutMs ?? opts.idleTimeoutMs,\n\t\t\tbrowserConfig?.headful ?? false,\n\t\t\tbrowserConfig?.browserPath,\n\t\t);\n\n\t\tconst text =\n\t\t\t`Flow suspended — parent decision required (NeedsParent).\\n` +\n\t\t\t`${formatParentRequest(request)}\\n` +\n\t\t\t`resume token: ${token}\\n` +\n\t\t\t`${parentResponseHint(request.request)}\\n` +\n\t\t\t(image ? \"A screenshot of the current page is attached.\" : \"(no screenshot available)\");\n\t\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\t\tif (image) content.push(image);\n\t\treturn {\n\t\t\tcontent,\n\t\t\tdetails: { status: \"needs_parent\", token, requestKind: request.request },\n\t\t};\n\t}\n\n\tclient.dispose();\n\tthrow new Error(`browsertools returned an unrecognized flow outcome: ${JSON.stringify(outcome)}`);\n}\n\nexport function createBrowserRunToolDefinition(\n\tcwd: string,\n\toptions?: BrowserRunToolOptions,\n): ToolDefinition<typeof browserRunSchema, BrowserRunDetails> {\n\tconst opts = resolveBrowsertoolsOptions(options);\n\treturn defineTool({\n\t\tname: \"browser_run\",\n\t\tlabel: \"browser flow\",\n\t\tdescription:\n\t\t\t\"Start a deterministic browser flow (browsertools). Runs a saved .flow.json (or inline flow) \" +\n\t\t\t\"against a headless browser and returns the evidence on completion. If the flow needs an LLM \" +\n\t\t\t\"decision mid-replay (classify a page state, verify a visual, extract a value, decide the next \" +\n\t\t\t\"action, or re-identify a drifted element) it suspends and returns a typed request plus a \" +\n\t\t\t\"screenshot; answer it with the browser_continue tool using the returned token. Off by default; \" +\n\t\t\t\"enabled with --enable-browsertools.\\n\\n\" +\n\t\t\t\"AGENTIC LOOP (preferred for exploration): for any task where you must read or navigate based on \" +\n\t\t\t\"page content, build the flow from `decide`/`extract_semantic`/`classify`/`verify_visual` steps. \" +\n\t\t\t\"Each such step SUSPENDS and hands you a screenshot of the current page. Read the screenshot, then \" +\n\t\t\t\"call browser_continue with the next action, and keep looping until the outcome is `complete`. Do \" +\n\t\t\t\"NOT fall back to webfetch/curl to read page content you could read from the screenshot — that \" +\n\t\t\t\"bypasses the live session and breaks on auth-gated or JS-rendered pages. A flow ENDS as soon as \" +\n\t\t\t\"its last step runs, so chain several `decide` steps (interleaved with `wait_settle`) when you \" +\n\t\t\t\"need a multi-step journey (search -> open result -> scroll -> extract).\\n\\n\" +\n\t\t\t\"RESUME RESPONSE SHAPES (browser_continue `response` field): decide_next_action -> \" +\n\t\t\t'{ response: \"next_action\", action: <Action> }; classify_state -> { response: \"state\", state: \"<label>\" }; ' +\n\t\t\t'verify_visual -> { response: \"verified\", passed: true|false }; extract_semantic -> ' +\n\t\t\t'{ response: \"extracted\", fields: { <field>: <value> } }; reidentify_element -> ' +\n\t\t\t'{ response: \"element\", selector: \"<css>\" }.\\n\\n' +\n\t\t\t\"ACTION (for next_action) is the same shape as a flow step's action: { action: 'navigate', url }, \" +\n\t\t\t\"{ action: 'click', selector, fallbacks?: string[] }, { action: 'fill', selector, value_tpl }, \" +\n\t\t\t\"{ action: 'select', selector, value_tpl }, { action: 'wait_settle' }. Prefer stable CSS/id \" +\n\t\t\t\"selectors, and ALWAYS pass a `fallbacks` array of alternate selectors for click/fill, because \" +\n\t\t\t\"the primary selector often drifts (e.g. click '.suggestion-link' with fallbacks \" +\n\t\t\t\"['a.mw-searchSuggest-link', '#typeahead-suggestions a']).\\n\\n\" +\n\t\t\t\"VISIBILITY: pass headful:true to launch a real on-screen browser window the user can watch; \" +\n\t\t\t\"live_view:true additionally streams a mirror + tool-call log to a local URL (set live_view:false \" +\n\t\t\t\"to suppress the mirror when the instance defaults it on).\",\n\t\tpromptSnippet: \"Run a deterministic browser flow, pausing for LLM decisions when needed\",\n\t\tparameters: browserRunSchema,\n\t\tasync execute(_toolCallId, params: BrowserRunInput, signal) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tif (!params.flow_path && !params.flow) {\n\t\t\t\tthrow new Error(\"browser_run requires either `flow_path` or `flow`\");\n\t\t\t}\n\n\t\t\tconst binaryPath = await resolveBrowsertoolsBinary(options);\n\t\t\tconst headful = params.headful ?? opts.headful;\n\t\t\t// Reuse the shared idle client if browser config matches, otherwise create a new\n\t\t\t// one. This keeps a single Chromium process and live-view port across calls.\n\t\t\tlet client = takeIdleClient(headful, opts.browserPath, opts.idleTimeoutMs);\n\t\t\tif (!client) {\n\t\t\t\tclient = new BrowsertoolsServeClient(binaryPath, {\n\t\t\t\t\tcwd,\n\t\t\t\t\tbrowserPath: opts.browserPath,\n\t\t\t\t\tserveArgs: opts.serveArgs,\n\t\t\t\t\trequestTimeoutMs: opts.requestTimeoutMs,\n\t\t\t\t\theadful,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// If the call is aborted before we hand the client to the registry, make\n\t\t\t// sure the serve process is torn down.\n\t\t\tconst onAbort = () => client.dispose();\n\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\ttry {\n\t\t\t\tconst startParams: Record<string, unknown> = {};\n\t\t\t\tif (params.flow_path) startParams.flow_path = params.flow_path;\n\t\t\t\tif (params.flow) startParams.flow = params.flow;\n\t\t\t\tif (params.vars) startParams.vars = params.vars;\n\t\t\t\tif (params.store) startParams.store = params.store;\n\n\t\t\t\t// Bring up the live viewer before the flow runs so the page render and\n\t\t\t\t// tool-call log are visible from the first step. The per-call param wins\n\t\t\t\t// over the instance default (--enable-browser-live-preview).\n\t\t\t\tconst liveViewEnabled = params.live_view ?? opts.liveView;\n\t\t\t\tconst liveViewStatus = liveViewEnabled ? await startLiveView(client) : undefined;\n\n\t\t\t\tconst outcome = await client.request<FlowOutcome>(\"flow_start\", startParams);\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tclient.dispose();\n\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t}\n\t\t\t\tconst browserConfig: BrowserClientConfig = {\n\t\t\t\t\theadful,\n\t\t\t\t\tbrowserPath: opts.browserPath,\n\t\t\t\t\tidleTimeoutMs: opts.idleTimeoutMs,\n\t\t\t\t};\n\t\t\t\tconst result = await advanceFlow(client, outcome, 1, opts, browserConfig);\n\t\t\t\tif (liveViewStatus) {\n\t\t\t\t\tresult.content.unshift({ type: \"text\", text: liveViewStatus });\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\tclient.dispose();\n\t\t\t\tthrow enrichFlowError(error);\n\t\t\t} finally {\n\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t});\n}\n\nexport function createBrowserRunTool(cwd: string, options?: BrowserRunToolOptions): AgentTool<typeof browserRunSchema> {\n\treturn wrapToolDefinition(createBrowserRunToolDefinition(cwd, options));\n}\n"]}