agent-web-interface 4.3.0 → 4.5.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 (461) hide show
  1. package/dist/src/browser/browser-session-config.d.ts +33 -0
  2. package/dist/src/browser/browser-session-config.d.ts.map +1 -0
  3. package/dist/src/browser/browser-session-config.js +24 -0
  4. package/dist/src/browser/browser-session-config.js.map +1 -0
  5. package/dist/src/browser/connection-utils.d.ts +48 -0
  6. package/dist/src/browser/connection-utils.d.ts.map +1 -0
  7. package/dist/src/browser/connection-utils.js +129 -0
  8. package/dist/src/browser/connection-utils.js.map +1 -0
  9. package/dist/src/browser/ensure-browser.d.ts +12 -27
  10. package/dist/src/browser/ensure-browser.d.ts.map +1 -1
  11. package/dist/src/browser/ensure-browser.js +104 -37
  12. package/dist/src/browser/ensure-browser.js.map +1 -1
  13. package/dist/src/browser/index.d.ts +4 -1
  14. package/dist/src/browser/index.d.ts.map +1 -1
  15. package/dist/src/browser/index.js +3 -1
  16. package/dist/src/browser/index.js.map +1 -1
  17. package/dist/src/browser/session-manager.d.ts +21 -89
  18. package/dist/src/browser/session-manager.d.ts.map +1 -1
  19. package/dist/src/browser/session-manager.js +122 -132
  20. package/dist/src/browser/session-manager.js.map +1 -1
  21. package/dist/src/browser/session-manager.types.d.ts +102 -0
  22. package/dist/src/browser/session-manager.types.d.ts.map +1 -0
  23. package/dist/src/browser/session-manager.types.js +11 -0
  24. package/dist/src/browser/session-manager.types.js.map +1 -0
  25. package/dist/src/cli/args.d.ts +12 -18
  26. package/dist/src/cli/args.d.ts.map +1 -1
  27. package/dist/src/cli/args.js +35 -40
  28. package/dist/src/cli/args.js.map +1 -1
  29. package/dist/src/form/constraint-extraction.d.ts +36 -0
  30. package/dist/src/form/constraint-extraction.d.ts.map +1 -0
  31. package/dist/src/form/constraint-extraction.js +117 -0
  32. package/dist/src/form/constraint-extraction.js.map +1 -0
  33. package/dist/src/form/field-extractor.d.ts.map +1 -1
  34. package/dist/src/form/field-extractor.js +16 -450
  35. package/dist/src/form/field-extractor.js.map +1 -1
  36. package/dist/src/form/field-state-extractor.d.ts +22 -0
  37. package/dist/src/form/field-state-extractor.d.ts.map +1 -0
  38. package/dist/src/form/field-state-extractor.js +55 -0
  39. package/dist/src/form/field-state-extractor.js.map +1 -0
  40. package/dist/src/form/form-actions.d.ts +45 -0
  41. package/dist/src/form/form-actions.d.ts.map +1 -0
  42. package/dist/src/form/form-actions.js +108 -0
  43. package/dist/src/form/form-actions.js.map +1 -0
  44. package/dist/src/form/form-detector.d.ts +0 -36
  45. package/dist/src/form/form-detector.d.ts.map +1 -1
  46. package/dist/src/form/form-detector.js +11 -376
  47. package/dist/src/form/form-detector.js.map +1 -1
  48. package/dist/src/form/form-state.d.ts.map +1 -1
  49. package/dist/src/form/form-state.js +16 -4
  50. package/dist/src/form/form-state.js.map +1 -1
  51. package/dist/src/form/input-clustering.d.ts +15 -0
  52. package/dist/src/form/input-clustering.d.ts.map +1 -0
  53. package/dist/src/form/input-clustering.js +61 -0
  54. package/dist/src/form/input-clustering.js.map +1 -0
  55. package/dist/src/form/intent-inference.d.ts +28 -0
  56. package/dist/src/form/intent-inference.d.ts.map +1 -0
  57. package/dist/src/form/intent-inference.js +137 -0
  58. package/dist/src/form/intent-inference.js.map +1 -0
  59. package/dist/src/form/purpose-inference.d.ts +50 -0
  60. package/dist/src/form/purpose-inference.d.ts.map +1 -0
  61. package/dist/src/form/purpose-inference.js +313 -0
  62. package/dist/src/form/purpose-inference.js.map +1 -0
  63. package/dist/src/form/submit-detection.d.ts +36 -0
  64. package/dist/src/form/submit-detection.d.ts.map +1 -0
  65. package/dist/src/form/submit-detection.js +101 -0
  66. package/dist/src/form/submit-detection.js.map +1 -0
  67. package/dist/src/form/types.d.ts +2 -2
  68. package/dist/src/gateway/http-gateway.d.ts +56 -0
  69. package/dist/src/gateway/http-gateway.d.ts.map +1 -0
  70. package/dist/src/gateway/http-gateway.js +229 -0
  71. package/dist/src/gateway/http-gateway.js.map +1 -0
  72. package/dist/src/gateway/json-rpc-errors.d.ts +6 -0
  73. package/dist/src/gateway/json-rpc-errors.d.ts.map +1 -0
  74. package/dist/src/gateway/json-rpc-errors.js +11 -0
  75. package/dist/src/gateway/json-rpc-errors.js.map +1 -0
  76. package/dist/src/gateway/session-router.d.ts +80 -0
  77. package/dist/src/gateway/session-router.d.ts.map +1 -0
  78. package/dist/src/gateway/session-router.js +177 -0
  79. package/dist/src/gateway/session-router.js.map +1 -0
  80. package/dist/src/http-entry.d.ts +20 -0
  81. package/dist/src/http-entry.d.ts.map +1 -0
  82. package/dist/src/http-entry.js +112 -0
  83. package/dist/src/http-entry.js.map +1 -0
  84. package/dist/src/index.d.ts +1 -10
  85. package/dist/src/index.d.ts.map +1 -1
  86. package/dist/src/index.js +25 -227
  87. package/dist/src/index.js.map +1 -1
  88. package/dist/src/lib/text-utils.d.ts +0 -24
  89. package/dist/src/lib/text-utils.d.ts.map +1 -1
  90. package/dist/src/lib/text-utils.js +2 -38
  91. package/dist/src/lib/text-utils.js.map +1 -1
  92. package/dist/src/observation/eid-linker.d.ts.map +1 -1
  93. package/dist/src/observation/eid-linker.js +1 -21
  94. package/dist/src/observation/eid-linker.js.map +1 -1
  95. package/dist/src/observation/observation-accumulator.d.ts +1 -1
  96. package/dist/src/observation/observation-accumulator.js +1 -1
  97. package/dist/src/observation/observer-script.d.ts +1 -1
  98. package/dist/src/observation/observer-script.d.ts.map +1 -1
  99. package/dist/src/observation/observer-script.js +129 -7
  100. package/dist/src/observation/observer-script.js.map +1 -1
  101. package/dist/src/query/disambiguation.d.ts +18 -0
  102. package/dist/src/query/disambiguation.d.ts.map +1 -0
  103. package/dist/src/query/disambiguation.js +123 -0
  104. package/dist/src/query/disambiguation.js.map +1 -0
  105. package/dist/src/query/fuzzy-match.d.ts +17 -0
  106. package/dist/src/query/fuzzy-match.d.ts.map +1 -0
  107. package/dist/src/query/fuzzy-match.js +34 -0
  108. package/dist/src/query/fuzzy-match.js.map +1 -0
  109. package/dist/src/query/index.d.ts +3 -0
  110. package/dist/src/query/index.d.ts.map +1 -1
  111. package/dist/src/query/index.js +6 -0
  112. package/dist/src/query/index.js.map +1 -1
  113. package/dist/src/query/query-engine.d.ts +0 -35
  114. package/dist/src/query/query-engine.d.ts.map +1 -1
  115. package/dist/src/query/query-engine.js +9 -309
  116. package/dist/src/query/query-engine.js.map +1 -1
  117. package/dist/src/query/scoring.d.ts +52 -0
  118. package/dist/src/query/scoring.d.ts.map +1 -0
  119. package/dist/src/query/scoring.js +162 -0
  120. package/dist/src/query/scoring.js.map +1 -0
  121. package/dist/src/server/index.d.ts +0 -1
  122. package/dist/src/server/index.d.ts.map +1 -1
  123. package/dist/src/server/index.js +0 -1
  124. package/dist/src/server/index.js.map +1 -1
  125. package/dist/src/server/mcp-server.d.ts +6 -2
  126. package/dist/src/server/mcp-server.d.ts.map +1 -1
  127. package/dist/src/server/mcp-server.js +3 -91
  128. package/dist/src/server/mcp-server.js.map +1 -1
  129. package/dist/src/server/server-config.d.ts +4 -20
  130. package/dist/src/server/server-config.d.ts.map +1 -1
  131. package/dist/src/server/server-config.js +6 -50
  132. package/dist/src/server/server-config.js.map +1 -1
  133. package/dist/src/server/tool-registrar.types.d.ts +25 -0
  134. package/dist/src/server/tool-registrar.types.d.ts.map +1 -0
  135. package/dist/src/server/tool-registrar.types.js +10 -0
  136. package/dist/src/server/tool-registrar.types.js.map +1 -0
  137. package/dist/src/server/tool-result-handler.d.ts +61 -0
  138. package/dist/src/server/tool-result-handler.d.ts.map +1 -0
  139. package/dist/src/server/tool-result-handler.js +137 -0
  140. package/dist/src/server/tool-result-handler.js.map +1 -0
  141. package/dist/src/session/session-controller.d.ts +123 -0
  142. package/dist/src/session/session-controller.d.ts.map +1 -0
  143. package/dist/src/session/session-controller.js +273 -0
  144. package/dist/src/session/session-controller.js.map +1 -0
  145. package/dist/src/shared/services/index.d.ts +0 -2
  146. package/dist/src/shared/services/index.d.ts.map +1 -1
  147. package/dist/src/shared/services/index.js +0 -2
  148. package/dist/src/shared/services/index.js.map +1 -1
  149. package/dist/src/shared/version.d.ts +10 -0
  150. package/dist/src/shared/version.d.ts.map +1 -0
  151. package/dist/src/shared/version.js +32 -0
  152. package/dist/src/shared/version.js.map +1 -0
  153. package/dist/src/snapshot/element-resolver.d.ts +27 -15
  154. package/dist/src/snapshot/element-resolver.d.ts.map +1 -1
  155. package/dist/src/snapshot/element-resolver.js +196 -91
  156. package/dist/src/snapshot/element-resolver.js.map +1 -1
  157. package/dist/src/snapshot/extractors/attribute-extractor.d.ts.map +1 -1
  158. package/dist/src/snapshot/extractors/attribute-extractor.js +4 -0
  159. package/dist/src/snapshot/extractors/attribute-extractor.js.map +1 -1
  160. package/dist/src/snapshot/extractors/ax-extractor.d.ts +1 -1
  161. package/dist/src/snapshot/extractors/ax-extractor.d.ts.map +1 -1
  162. package/dist/src/snapshot/extractors/ax-extractor.js +4 -1
  163. package/dist/src/snapshot/extractors/ax-extractor.js.map +1 -1
  164. package/dist/src/snapshot/extractors/index.d.ts +1 -1
  165. package/dist/src/snapshot/extractors/index.d.ts.map +1 -1
  166. package/dist/src/snapshot/extractors/index.js +1 -1
  167. package/dist/src/snapshot/extractors/index.js.map +1 -1
  168. package/dist/src/snapshot/extractors/layout-extractor.d.ts +9 -7
  169. package/dist/src/snapshot/extractors/layout-extractor.d.ts.map +1 -1
  170. package/dist/src/snapshot/extractors/layout-extractor.js +34 -19
  171. package/dist/src/snapshot/extractors/layout-extractor.js.map +1 -1
  172. package/dist/src/snapshot/extractors/region-resolver.d.ts.map +1 -1
  173. package/dist/src/snapshot/extractors/region-resolver.js +8 -0
  174. package/dist/src/snapshot/extractors/region-resolver.js.map +1 -1
  175. package/dist/src/snapshot/extractors/state-extractor.d.ts +2 -2
  176. package/dist/src/snapshot/extractors/state-extractor.d.ts.map +1 -1
  177. package/dist/src/snapshot/extractors/state-extractor.js +22 -2
  178. package/dist/src/snapshot/extractors/state-extractor.js.map +1 -1
  179. package/dist/src/snapshot/extractors/types.d.ts +14 -0
  180. package/dist/src/snapshot/extractors/types.d.ts.map +1 -1
  181. package/dist/src/snapshot/extractors/types.js +16 -0
  182. package/dist/src/snapshot/extractors/types.js.map +1 -1
  183. package/dist/src/snapshot/frame-context.d.ts +68 -0
  184. package/dist/src/snapshot/frame-context.d.ts.map +1 -0
  185. package/dist/src/snapshot/frame-context.js +131 -0
  186. package/dist/src/snapshot/frame-context.js.map +1 -0
  187. package/dist/src/snapshot/heading-index.d.ts +28 -0
  188. package/dist/src/snapshot/heading-index.d.ts.map +1 -0
  189. package/dist/src/snapshot/heading-index.js +108 -0
  190. package/dist/src/snapshot/heading-index.js.map +1 -0
  191. package/dist/src/snapshot/index.d.ts +5 -3
  192. package/dist/src/snapshot/index.d.ts.map +1 -1
  193. package/dist/src/snapshot/index.js +3 -2
  194. package/dist/src/snapshot/index.js.map +1 -1
  195. package/dist/src/snapshot/kind-mapping.d.ts +30 -0
  196. package/dist/src/snapshot/kind-mapping.d.ts.map +1 -0
  197. package/dist/src/snapshot/kind-mapping.js +114 -0
  198. package/dist/src/snapshot/kind-mapping.js.map +1 -0
  199. package/dist/src/snapshot/node-filter.d.ts +31 -0
  200. package/dist/src/snapshot/node-filter.d.ts.map +1 -0
  201. package/dist/src/snapshot/node-filter.js +137 -0
  202. package/dist/src/snapshot/node-filter.js.map +1 -0
  203. package/dist/src/snapshot/node-synthesizer.d.ts +62 -0
  204. package/dist/src/snapshot/node-synthesizer.d.ts.map +1 -0
  205. package/dist/src/snapshot/node-synthesizer.js +185 -0
  206. package/dist/src/snapshot/node-synthesizer.js.map +1 -0
  207. package/dist/src/snapshot/snapshot-compiler.d.ts +2 -36
  208. package/dist/src/snapshot/snapshot-compiler.d.ts.map +1 -1
  209. package/dist/src/snapshot/snapshot-compiler.js +40 -549
  210. package/dist/src/snapshot/snapshot-compiler.js.map +1 -1
  211. package/dist/src/snapshot/snapshot.types.d.ts +17 -3
  212. package/dist/src/snapshot/snapshot.types.d.ts.map +1 -1
  213. package/dist/src/snapshot/snapshot.types.js +8 -0
  214. package/dist/src/snapshot/snapshot.types.js.map +1 -1
  215. package/dist/src/state/actionables-filter.d.ts +5 -0
  216. package/dist/src/state/actionables-filter.d.ts.map +1 -1
  217. package/dist/src/state/actionables-filter.js +28 -6
  218. package/dist/src/state/actionables-filter.js.map +1 -1
  219. package/dist/src/state/atoms-extractor.d.ts.map +1 -1
  220. package/dist/src/state/atoms-extractor.js +3 -23
  221. package/dist/src/state/atoms-extractor.js.map +1 -1
  222. package/dist/src/state/diff-engine.d.ts.map +1 -1
  223. package/dist/src/state/diff-engine.js +9 -36
  224. package/dist/src/state/diff-engine.js.map +1 -1
  225. package/dist/src/state/element-identity.d.ts +3 -6
  226. package/dist/src/state/element-identity.d.ts.map +1 -1
  227. package/dist/src/state/element-identity.js +10 -7
  228. package/dist/src/state/element-identity.js.map +1 -1
  229. package/dist/src/state/element-ref.types.d.ts +5 -27
  230. package/dist/src/state/element-ref.types.d.ts.map +1 -1
  231. package/dist/src/state/element-registry.d.ts.map +1 -1
  232. package/dist/src/state/element-registry.js +6 -4
  233. package/dist/src/state/element-registry.js.map +1 -1
  234. package/dist/src/state/hash-utils.d.ts +24 -0
  235. package/dist/src/state/hash-utils.d.ts.map +1 -0
  236. package/dist/src/state/hash-utils.js +41 -0
  237. package/dist/src/state/hash-utils.js.map +1 -0
  238. package/dist/src/state/layer-detector.d.ts.map +1 -1
  239. package/dist/src/state/layer-detector.js +15 -286
  240. package/dist/src/state/layer-detector.js.map +1 -1
  241. package/dist/src/state/layer-detectors/drawer-detector.d.ts +32 -0
  242. package/dist/src/state/layer-detectors/drawer-detector.d.ts.map +1 -0
  243. package/dist/src/state/layer-detectors/drawer-detector.js +96 -0
  244. package/dist/src/state/layer-detectors/drawer-detector.js.map +1 -0
  245. package/dist/src/state/layer-detectors/index.d.ts +10 -0
  246. package/dist/src/state/layer-detectors/index.d.ts.map +1 -0
  247. package/dist/src/state/layer-detectors/index.js +10 -0
  248. package/dist/src/state/layer-detectors/index.js.map +1 -0
  249. package/dist/src/state/layer-detectors/modal-detector.d.ts +30 -0
  250. package/dist/src/state/layer-detectors/modal-detector.d.ts.map +1 -0
  251. package/dist/src/state/layer-detectors/modal-detector.js +127 -0
  252. package/dist/src/state/layer-detectors/modal-detector.js.map +1 -0
  253. package/dist/src/state/layer-detectors/popover-detector.d.ts +20 -0
  254. package/dist/src/state/layer-detectors/popover-detector.d.ts.map +1 -0
  255. package/dist/src/state/layer-detectors/popover-detector.js +76 -0
  256. package/dist/src/state/layer-detectors/popover-detector.js.map +1 -0
  257. package/dist/src/state/layer-detectors/toast-detector.d.ts +24 -0
  258. package/dist/src/state/layer-detectors/toast-detector.d.ts.map +1 -0
  259. package/dist/src/state/layer-detectors/toast-detector.js +48 -0
  260. package/dist/src/state/layer-detectors/toast-detector.js.map +1 -0
  261. package/dist/src/state/region-mapping.d.ts +13 -0
  262. package/dist/src/state/region-mapping.d.ts.map +1 -0
  263. package/dist/src/state/region-mapping.js +25 -0
  264. package/dist/src/state/region-mapping.js.map +1 -0
  265. package/dist/src/state/state-manager.d.ts.map +1 -1
  266. package/dist/src/state/state-manager.js +11 -193
  267. package/dist/src/state/state-manager.js.map +1 -1
  268. package/dist/src/state/state-renderer.d.ts.map +1 -1
  269. package/dist/src/state/state-renderer.js +17 -3
  270. package/dist/src/state/state-renderer.js.map +1 -1
  271. package/dist/src/state/types.d.ts +10 -5
  272. package/dist/src/state/types.d.ts.map +1 -1
  273. package/dist/src/state/url-sanitization.d.ts +22 -0
  274. package/dist/src/state/url-sanitization.d.ts.map +1 -0
  275. package/dist/src/state/url-sanitization.js +76 -0
  276. package/dist/src/state/url-sanitization.js.map +1 -0
  277. package/dist/src/state/value-masking.d.ts +36 -0
  278. package/dist/src/state/value-masking.d.ts.map +1 -0
  279. package/dist/src/state/value-masking.js +86 -0
  280. package/dist/src/state/value-masking.js.map +1 -0
  281. package/dist/src/tools/action-context.d.ts +55 -0
  282. package/dist/src/tools/action-context.d.ts.map +1 -0
  283. package/dist/src/tools/action-context.js +69 -0
  284. package/dist/src/tools/action-context.js.map +1 -0
  285. package/dist/src/tools/action-stabilization.d.ts +48 -0
  286. package/dist/src/tools/action-stabilization.d.ts.map +1 -0
  287. package/dist/src/tools/action-stabilization.js +93 -0
  288. package/dist/src/tools/action-stabilization.js.map +1 -0
  289. package/dist/src/tools/browser-tools.d.ts +9 -167
  290. package/dist/src/tools/browser-tools.d.ts.map +1 -1
  291. package/dist/src/tools/browser-tools.js +15 -651
  292. package/dist/src/tools/browser-tools.js.map +1 -1
  293. package/dist/src/tools/canvas-tools.d.ts +2 -1
  294. package/dist/src/tools/canvas-tools.d.ts.map +1 -1
  295. package/dist/src/tools/canvas-tools.js +5 -7
  296. package/dist/src/tools/canvas-tools.js.map +1 -1
  297. package/dist/src/tools/effect-tracker.d.ts +25 -0
  298. package/dist/src/tools/effect-tracker.d.ts.map +1 -0
  299. package/dist/src/tools/effect-tracker.js +69 -0
  300. package/dist/src/tools/effect-tracker.js.map +1 -0
  301. package/dist/src/tools/errors.d.ts +2 -34
  302. package/dist/src/tools/errors.d.ts.map +1 -1
  303. package/dist/src/tools/errors.js +1 -44
  304. package/dist/src/tools/errors.js.map +1 -1
  305. package/dist/src/tools/execute-action.d.ts +5 -34
  306. package/dist/src/tools/execute-action.d.ts.map +1 -1
  307. package/dist/src/tools/execute-action.js +37 -297
  308. package/dist/src/tools/execute-action.js.map +1 -1
  309. package/dist/src/tools/form-tools.d.ts +5 -10
  310. package/dist/src/tools/form-tools.d.ts.map +1 -1
  311. package/dist/src/tools/form-tools.js +42 -22
  312. package/dist/src/tools/form-tools.js.map +1 -1
  313. package/dist/src/tools/index.d.ts +6 -6
  314. package/dist/src/tools/index.d.ts.map +1 -1
  315. package/dist/src/tools/index.js +16 -17
  316. package/dist/src/tools/index.js.map +1 -1
  317. package/dist/src/tools/interaction-tools.d.ts +47 -0
  318. package/dist/src/tools/interaction-tools.d.ts.map +1 -0
  319. package/dist/src/tools/interaction-tools.js +135 -0
  320. package/dist/src/tools/interaction-tools.js.map +1 -0
  321. package/dist/src/tools/navigation-detection.d.ts +31 -0
  322. package/dist/src/tools/navigation-detection.d.ts.map +1 -0
  323. package/dist/src/tools/navigation-detection.js +46 -0
  324. package/dist/src/tools/navigation-detection.js.map +1 -0
  325. package/dist/src/tools/navigation-tools.d.ts +51 -0
  326. package/dist/src/tools/navigation-tools.d.ts.map +1 -0
  327. package/dist/src/tools/navigation-tools.js +171 -0
  328. package/dist/src/tools/navigation-tools.js.map +1 -0
  329. package/dist/src/tools/observation-tools.d.ts +54 -0
  330. package/dist/src/tools/observation-tools.d.ts.map +1 -0
  331. package/dist/src/tools/observation-tools.js +243 -0
  332. package/dist/src/tools/observation-tools.js.map +1 -0
  333. package/dist/src/tools/readability-tools.d.ts +16 -0
  334. package/dist/src/tools/readability-tools.d.ts.map +1 -0
  335. package/dist/src/tools/readability-tools.js +45 -0
  336. package/dist/src/tools/readability-tools.js.map +1 -0
  337. package/dist/src/tools/response-builder.d.ts +20 -32
  338. package/dist/src/tools/response-builder.d.ts.map +1 -1
  339. package/dist/src/tools/response-builder.js +32 -48
  340. package/dist/src/tools/response-builder.js.map +1 -1
  341. package/dist/src/tools/stale-element-retry.d.ts +37 -0
  342. package/dist/src/tools/stale-element-retry.d.ts.map +1 -0
  343. package/dist/src/tools/stale-element-retry.js +103 -0
  344. package/dist/src/tools/stale-element-retry.js.map +1 -0
  345. package/dist/src/tools/tool-context.d.ts +4 -36
  346. package/dist/src/tools/tool-context.d.ts.map +1 -1
  347. package/dist/src/tools/tool-context.js +6 -75
  348. package/dist/src/tools/tool-context.js.map +1 -1
  349. package/dist/src/tools/tool-context.types.d.ts +141 -0
  350. package/dist/src/tools/tool-context.types.d.ts.map +1 -0
  351. package/dist/src/tools/tool-context.types.js +11 -0
  352. package/dist/src/tools/tool-context.types.js.map +1 -0
  353. package/dist/src/tools/tool-registration.d.ts +25 -0
  354. package/dist/src/tools/tool-registration.d.ts.map +1 -0
  355. package/dist/src/tools/tool-registration.js +180 -0
  356. package/dist/src/tools/tool-registration.js.map +1 -0
  357. package/dist/src/tools/tool-schemas.d.ts +176 -1950
  358. package/dist/src/tools/tool-schemas.d.ts.map +1 -1
  359. package/dist/src/tools/tool-schemas.js +80 -320
  360. package/dist/src/tools/tool-schemas.js.map +1 -1
  361. package/dist/src/tools/viewport-tools.d.ts +37 -0
  362. package/dist/src/tools/viewport-tools.d.ts.map +1 -0
  363. package/dist/src/tools/viewport-tools.js +101 -0
  364. package/dist/src/tools/viewport-tools.js.map +1 -0
  365. package/dist/src/worker/chrome-worker-process.d.ts +4 -0
  366. package/dist/src/worker/chrome-worker-process.d.ts.map +1 -1
  367. package/dist/src/worker/chrome-worker-process.js +1 -1
  368. package/dist/src/worker/chrome-worker-process.js.map +1 -1
  369. package/package.json +7 -3
  370. package/dist/src/factpack/action-selector.d.ts +0 -36
  371. package/dist/src/factpack/action-selector.d.ts.map +0 -1
  372. package/dist/src/factpack/action-selector.js +0 -367
  373. package/dist/src/factpack/action-selector.js.map +0 -1
  374. package/dist/src/factpack/dialog-detector.d.ts +0 -19
  375. package/dist/src/factpack/dialog-detector.d.ts.map +0 -1
  376. package/dist/src/factpack/dialog-detector.js +0 -354
  377. package/dist/src/factpack/dialog-detector.js.map +0 -1
  378. package/dist/src/factpack/form-detector.d.ts +0 -28
  379. package/dist/src/factpack/form-detector.d.ts.map +0 -1
  380. package/dist/src/factpack/form-detector.js +0 -555
  381. package/dist/src/factpack/form-detector.js.map +0 -1
  382. package/dist/src/factpack/index.d.ts +0 -32
  383. package/dist/src/factpack/index.d.ts.map +0 -1
  384. package/dist/src/factpack/index.js +0 -73
  385. package/dist/src/factpack/index.js.map +0 -1
  386. package/dist/src/factpack/page-classifier.d.ts +0 -22
  387. package/dist/src/factpack/page-classifier.d.ts.map +0 -1
  388. package/dist/src/factpack/page-classifier.js +0 -526
  389. package/dist/src/factpack/page-classifier.js.map +0 -1
  390. package/dist/src/factpack/types.d.ts +0 -307
  391. package/dist/src/factpack/types.d.ts.map +0 -1
  392. package/dist/src/factpack/types.js +0 -12
  393. package/dist/src/factpack/types.js.map +0 -1
  394. package/dist/src/lib/constants.d.ts +0 -27
  395. package/dist/src/lib/constants.d.ts.map +0 -1
  396. package/dist/src/lib/constants.js +0 -63
  397. package/dist/src/lib/constants.js.map +0 -1
  398. package/dist/src/lib/index.d.ts +0 -12
  399. package/dist/src/lib/index.d.ts.map +0 -1
  400. package/dist/src/lib/index.js +0 -17
  401. package/dist/src/lib/index.js.map +0 -1
  402. package/dist/src/lib/regions.d.ts +0 -29
  403. package/dist/src/lib/regions.d.ts.map +0 -1
  404. package/dist/src/lib/regions.js +0 -93
  405. package/dist/src/lib/regions.js.map +0 -1
  406. package/dist/src/lib/scoring.d.ts +0 -47
  407. package/dist/src/lib/scoring.d.ts.map +0 -1
  408. package/dist/src/lib/scoring.js +0 -79
  409. package/dist/src/lib/scoring.js.map +0 -1
  410. package/dist/src/lib/selectors.d.ts +0 -42
  411. package/dist/src/lib/selectors.d.ts.map +0 -1
  412. package/dist/src/lib/selectors.js +0 -138
  413. package/dist/src/lib/selectors.js.map +0 -1
  414. package/dist/src/renderer/budget-manager.d.ts +0 -46
  415. package/dist/src/renderer/budget-manager.d.ts.map +0 -1
  416. package/dist/src/renderer/budget-manager.js +0 -133
  417. package/dist/src/renderer/budget-manager.js.map +0 -1
  418. package/dist/src/renderer/constants.d.ts +0 -38
  419. package/dist/src/renderer/constants.d.ts.map +0 -1
  420. package/dist/src/renderer/constants.js +0 -29
  421. package/dist/src/renderer/constants.js.map +0 -1
  422. package/dist/src/renderer/index.d.ts +0 -12
  423. package/dist/src/renderer/index.d.ts.map +0 -1
  424. package/dist/src/renderer/index.js +0 -16
  425. package/dist/src/renderer/index.js.map +0 -1
  426. package/dist/src/renderer/section-renderers.d.ts +0 -42
  427. package/dist/src/renderer/section-renderers.d.ts.map +0 -1
  428. package/dist/src/renderer/section-renderers.js +0 -252
  429. package/dist/src/renderer/section-renderers.js.map +0 -1
  430. package/dist/src/renderer/token-counter.d.ts +0 -45
  431. package/dist/src/renderer/token-counter.d.ts.map +0 -1
  432. package/dist/src/renderer/token-counter.js +0 -65
  433. package/dist/src/renderer/token-counter.js.map +0 -1
  434. package/dist/src/renderer/types.d.ts +0 -71
  435. package/dist/src/renderer/types.d.ts.map +0 -1
  436. package/dist/src/renderer/types.js +0 -7
  437. package/dist/src/renderer/types.js.map +0 -1
  438. package/dist/src/renderer/xml-renderer.d.ts +0 -42
  439. package/dist/src/renderer/xml-renderer.d.ts.map +0 -1
  440. package/dist/src/renderer/xml-renderer.js +0 -103
  441. package/dist/src/renderer/xml-renderer.js.map +0 -1
  442. package/dist/src/server/session-store.d.ts +0 -163
  443. package/dist/src/server/session-store.d.ts.map +0 -1
  444. package/dist/src/server/session-store.js +0 -248
  445. package/dist/src/server/session-store.js.map +0 -1
  446. package/dist/src/session/session-worker-binding.d.ts +0 -57
  447. package/dist/src/session/session-worker-binding.d.ts.map +0 -1
  448. package/dist/src/session/session-worker-binding.js +0 -109
  449. package/dist/src/session/session-worker-binding.js.map +0 -1
  450. package/dist/src/shared/services/dom-transformer.service.d.ts +0 -71
  451. package/dist/src/shared/services/dom-transformer.service.d.ts.map +0 -1
  452. package/dist/src/shared/services/dom-transformer.service.js +0 -190
  453. package/dist/src/shared/services/dom-transformer.service.js.map +0 -1
  454. package/dist/src/shared/services/selector-builder.service.d.ts +0 -53
  455. package/dist/src/shared/services/selector-builder.service.d.ts.map +0 -1
  456. package/dist/src/shared/services/selector-builder.service.js +0 -240
  457. package/dist/src/shared/services/selector-builder.service.js.map +0 -1
  458. package/dist/src/state/constants.d.ts +0 -125
  459. package/dist/src/state/constants.d.ts.map +0 -1
  460. package/dist/src/state/constants.js +0 -131
  461. package/dist/src/state/constants.js.map +0 -1
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Navigation Tools
3
+ *
4
+ * MCP tool handlers for browser navigation and session management.
5
+ */
6
+ import type { ToolContext } from './tool-context.types.js';
7
+ /**
8
+ * List all open browser pages with their metadata.
9
+ *
10
+ * Syncs with browser context to ensure all tabs are registered,
11
+ * including tabs opened externally or after reconnection.
12
+ *
13
+ * @returns XML result with page list
14
+ */
15
+ export declare function listPages(rawInput: unknown, ctx: ToolContext): Promise<import('./tool-schemas.js').ListPagesOutput>;
16
+ /**
17
+ * Close a specific page.
18
+ *
19
+ * @param rawInput - Close options (will be validated)
20
+ * @returns Close result
21
+ */
22
+ export declare function closePage(rawInput: unknown, ctx: ToolContext): Promise<import('./tool-schemas.js').ClosePageOutput>;
23
+ /**
24
+ * Navigate to a URL.
25
+ *
26
+ * @param rawInput - Navigation options (will be validated)
27
+ * @returns Navigation result with snapshot data
28
+ */
29
+ export declare function navigate(rawInput: unknown, ctx: ToolContext): Promise<import('./tool-schemas.js').NavigateOutput>;
30
+ /**
31
+ * Go back in browser history.
32
+ *
33
+ * @param rawInput - Navigation options (will be validated)
34
+ * @returns Navigation result with snapshot data
35
+ */
36
+ export declare function goBack(rawInput: unknown, ctx: ToolContext): Promise<import('./tool-schemas.js').GoBackOutput>;
37
+ /**
38
+ * Go forward in browser history.
39
+ *
40
+ * @param rawInput - Navigation options (will be validated)
41
+ * @returns Navigation result with snapshot data
42
+ */
43
+ export declare function goForward(rawInput: unknown, ctx: ToolContext): Promise<import('./tool-schemas.js').GoForwardOutput>;
44
+ /**
45
+ * Reload the current page.
46
+ *
47
+ * @param rawInput - Navigation options (will be validated)
48
+ * @returns Navigation result with snapshot data
49
+ */
50
+ export declare function reload(rawInput: unknown, ctx: ToolContext): Promise<import('./tool-schemas.js').ReloadOutput>;
51
+ //# sourceMappingURL=navigation-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/navigation-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AA4D3D;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,OAAO,mBAAmB,EAAE,eAAe,CAAC,CA2BtD;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,OAAO,mBAAmB,EAAE,eAAe,CAAC,CAStD;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,OAAO,mBAAmB,EAAE,cAAc,CAAC,CA+CrD;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAC1B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,OAAO,mBAAmB,EAAE,YAAY,CAAC,CAGnD;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,OAAO,mBAAmB,EAAE,eAAe,CAAC,CAGtD;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAC1B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,OAAO,mBAAmB,EAAE,YAAY,CAAC,CAGnD"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Navigation Tools
3
+ *
4
+ * MCP tool handlers for browser navigation and session management.
5
+ */
6
+ import { ClosePageInputSchema, NavigateInputSchema, GoBackInputSchema, GoForwardInputSchema, ReloadInputSchema, } from './tool-schemas.js';
7
+ import { stabilizeAfterNavigation } from './action-stabilization.js';
8
+ import { buildClosePageResponse, buildListPagesResponse } from './response-builder.js';
9
+ /**
10
+ * Execute a navigation action with snapshot capture.
11
+ * Consolidates goBack, goForward, and reload handlers.
12
+ *
13
+ * Waits for both DOM stabilization and network idle after navigation
14
+ * to ensure the page is fully loaded before capturing snapshot.
15
+ *
16
+ * @param pageId - Optional page ID
17
+ * @param action - Navigation action to execute
18
+ * @returns State response after navigation
19
+ */
20
+ async function executeNavigationAction(pageId, ctx, action) {
21
+ let handle = await ctx.resolvePageOrCreate(pageId);
22
+ const page_id = handle.page_id;
23
+ ctx.touchPage(page_id);
24
+ // Clear dependency tracker before navigation (old dependencies no longer valid)
25
+ ctx.getDependencyTracker().clearPage(page_id);
26
+ // Execute navigation
27
+ switch (action) {
28
+ case 'back':
29
+ await handle.page.goBack();
30
+ break;
31
+ case 'forward':
32
+ await handle.page.goForward();
33
+ break;
34
+ case 'reload':
35
+ await handle.page.reload();
36
+ break;
37
+ }
38
+ // Wait for page to stabilize (DOM + network idle)
39
+ await stabilizeAfterNavigation(handle.page);
40
+ // Re-inject observation accumulator (new document context after navigation)
41
+ await ctx.getObservationAccumulator().inject(handle.page);
42
+ // Auto-capture snapshot after navigation
43
+ const captureResult = await ctx.captureSnapshotWithRecovery(handle, page_id);
44
+ handle = captureResult.handle;
45
+ const snapshot = captureResult.snapshot;
46
+ ctx.getSnapshotStore().store(page_id, snapshot);
47
+ // Return XML state response (trimmed for navigation snapshots)
48
+ const stateManager = ctx.getStateManager(page_id);
49
+ return stateManager.generateResponse(snapshot, { trimRegions: true });
50
+ }
51
+ /**
52
+ * List all open browser pages with their metadata.
53
+ *
54
+ * Syncs with browser context to ensure all tabs are registered,
55
+ * including tabs opened externally or after reconnection.
56
+ *
57
+ * @returns XML result with page list
58
+ */
59
+ export async function listPages(rawInput, ctx) {
60
+ // Sync to pick up any unregistered browser tabs
61
+ const pages = await ctx.syncPages();
62
+ const pageInfos = await Promise.all(pages.map(async (h) => {
63
+ const liveUrl = h.page.url?.() ?? h.url ?? '';
64
+ let liveTitle = h.title ?? '';
65
+ if (typeof h.page.title === 'function') {
66
+ try {
67
+ liveTitle = await h.page.title();
68
+ }
69
+ catch {
70
+ // Ignore pages that cannot expose title in the current state.
71
+ }
72
+ }
73
+ h.url = liveUrl;
74
+ h.title = liveTitle;
75
+ return {
76
+ page_id: h.page_id,
77
+ url: liveUrl,
78
+ title: liveTitle,
79
+ };
80
+ }));
81
+ return buildListPagesResponse(pageInfos);
82
+ }
83
+ /**
84
+ * Close a specific page.
85
+ *
86
+ * @param rawInput - Close options (will be validated)
87
+ * @returns Close result
88
+ */
89
+ export async function closePage(rawInput, ctx) {
90
+ const input = ClosePageInputSchema.parse(rawInput);
91
+ await ctx.closePage(input.page_id);
92
+ ctx.getSnapshotStore().removeByPageId(input.page_id);
93
+ ctx.removeStateManager(input.page_id); // Clean up state manager
94
+ ctx.getDependencyTracker().clearPage(input.page_id); // Clean up dependencies
95
+ return buildClosePageResponse(input.page_id);
96
+ }
97
+ /**
98
+ * Navigate to a URL.
99
+ *
100
+ * @param rawInput - Navigation options (will be validated)
101
+ * @returns Navigation result with snapshot data
102
+ */
103
+ export async function navigate(rawInput, ctx) {
104
+ const input = NavigateInputSchema.parse(rawInput);
105
+ // Apply browser preferences if provided
106
+ if (input.headless !== undefined ||
107
+ input.isolated !== undefined ||
108
+ input.auto_connect !== undefined) {
109
+ // auto_connect means "connect to my existing Chrome, not a launched browser".
110
+ // If a launched browser is already running, shut it down first so we can
111
+ // reconnect to the user's Chrome instead.
112
+ if (input.auto_connect && !ctx.canReconfigure()) {
113
+ await ctx.resetBrowser();
114
+ }
115
+ if (ctx.canReconfigure()) {
116
+ ctx.setBrowserConfig({
117
+ headless: input.headless,
118
+ isolated: input.isolated,
119
+ autoConnect: input.auto_connect,
120
+ });
121
+ }
122
+ }
123
+ // navigate is excluded from the pre-handler ensureBrowser() call so that
124
+ // browser config (auto_connect, headless, isolated) can be set first.
125
+ await ctx.ensureBrowser();
126
+ let handle = await ctx.resolvePageOrCreate(input.page_id);
127
+ const page_id = handle.page_id;
128
+ ctx.touchPage(page_id);
129
+ // Clear dependency tracker before navigation (old dependencies no longer valid)
130
+ ctx.getDependencyTracker().clearPage(page_id);
131
+ await ctx.navigateTo(page_id, input.url);
132
+ // Auto-capture snapshot after navigation
133
+ const captureResult = await ctx.captureSnapshotWithRecovery(handle, page_id);
134
+ handle = captureResult.handle;
135
+ const snapshot = captureResult.snapshot;
136
+ ctx.getSnapshotStore().store(page_id, snapshot);
137
+ // Return XML state response directly (trimmed for navigation snapshots)
138
+ const stateManager = ctx.getStateManager(page_id);
139
+ return stateManager.generateResponse(snapshot, { trimRegions: true });
140
+ }
141
+ /**
142
+ * Go back in browser history.
143
+ *
144
+ * @param rawInput - Navigation options (will be validated)
145
+ * @returns Navigation result with snapshot data
146
+ */
147
+ export async function goBack(rawInput, ctx) {
148
+ const input = GoBackInputSchema.parse(rawInput);
149
+ return executeNavigationAction(input.page_id, ctx, 'back');
150
+ }
151
+ /**
152
+ * Go forward in browser history.
153
+ *
154
+ * @param rawInput - Navigation options (will be validated)
155
+ * @returns Navigation result with snapshot data
156
+ */
157
+ export async function goForward(rawInput, ctx) {
158
+ const input = GoForwardInputSchema.parse(rawInput);
159
+ return executeNavigationAction(input.page_id, ctx, 'forward');
160
+ }
161
+ /**
162
+ * Reload the current page.
163
+ *
164
+ * @param rawInput - Navigation options (will be validated)
165
+ * @returns Navigation result with snapshot data
166
+ */
167
+ export async function reload(rawInput, ctx) {
168
+ const input = ReloadInputSchema.parse(rawInput);
169
+ return executeNavigationAction(input.page_id, ctx, 'reload');
170
+ }
171
+ //# sourceMappingURL=navigation-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-tools.js","sourceRoot":"","sources":["../../../src/tools/navigation-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAQvF;;;;;;;;;;GAUG;AACH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,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,OAAO,uBAAuB,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Observation Tools
3
+ *
4
+ * MCP tool handlers for page observation: snapshots, find, get_element, scroll.
5
+ */
6
+ import type { NodeKind } from '../snapshot/snapshot.types.js';
7
+ import type { ToolContext } from './tool-context.types.js';
8
+ /**
9
+ * Capture a fresh snapshot of the current page.
10
+ *
11
+ * @param rawInput - Capture options (will be validated)
12
+ * @returns Snapshot data for the current page
13
+ */
14
+ export declare function captureSnapshot(rawInput: unknown, ctx: ToolContext): Promise<import('./tool-schemas.js').CaptureSnapshotOutput>;
15
+ /**
16
+ * Map schema kind values to internal NodeKind values.
17
+ *
18
+ * The find schema uses user-friendly names that don't always match
19
+ * internal NodeKind values. For example, 'textbox' in the schema maps to
20
+ * both 'input' and 'textarea' internally.
21
+ *
22
+ * @param schemaKind - Kind value from the find schema
23
+ * @returns Matching NodeKind value(s)
24
+ */
25
+ export declare function mapSchemaKindToNodeKind(schemaKind: string): NodeKind | NodeKind[];
26
+ /**
27
+ * Find elements by semantic criteria.
28
+ *
29
+ * @param rawInput - Query filters (will be validated)
30
+ * @returns Matched nodes
31
+ */
32
+ export declare function findElements(rawInput: unknown, ctx: ToolContext): import('./tool-schemas.js').FindElementsOutput;
33
+ /**
34
+ * Get full details for a specific node.
35
+ *
36
+ * @param rawInput - Node details request (will be validated)
37
+ * @returns Full node details
38
+ */
39
+ export declare function getNodeDetails(rawInput: unknown, ctx: ToolContext): import('./tool-schemas.js').GetNodeDetailsOutput;
40
+ /**
41
+ * Scroll an element into view.
42
+ *
43
+ * @param rawInput - Scroll options (will be validated)
44
+ * @returns Scroll result with delta
45
+ */
46
+ export declare function scrollElementIntoView(rawInput: unknown, ctx: ToolContext): Promise<import('./tool-schemas.js').ScrollElementIntoViewOutput>;
47
+ /**
48
+ * Scroll the page up or down.
49
+ *
50
+ * @param rawInput - Scroll options (will be validated)
51
+ * @returns Scroll result with delta
52
+ */
53
+ export declare function scrollPage(rawInput: unknown, ctx: ToolContext): Promise<import('./tool-schemas.js').ScrollPageOutput>;
54
+ //# sourceMappingURL=observation-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/observation-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,+BAA+B,CAAC;AAW9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,OAAO,mBAAmB,EAAE,qBAAqB,CAAC,CA8B5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,EAAE,CASjF;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,mBAAmB,EAAE,kBAAkB,CA0FhD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,mBAAmB,EAAE,oBAAoB,CAoDlD;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,OAAO,mBAAmB,EAAE,2BAA2B,CAAC,CAwBlE;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,OAAO,mBAAmB,EAAE,gBAAgB,CAAC,CAmBvD"}
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Observation Tools
3
+ *
4
+ * MCP tool handlers for page observation: snapshots, find, get_element, scroll.
5
+ */
6
+ import { scrollIntoView, scrollPage as scrollPageByAmount } from '../snapshot/index.js';
7
+ import { ATTACHMENT_SIGNIFICANCE_THRESHOLD } from '../observation/observation.types.js';
8
+ import { CaptureSnapshotInputSchema, FindElementsInputSchema, GetNodeDetailsInputSchema, ScrollElementIntoViewInputSchema, ScrollPageInputSchema, } from './tool-schemas.js';
9
+ import { QueryEngine } from '../query/query-engine.js';
10
+ import { isReadableNode, isStructuralNode, isLiveRegionNode } from '../snapshot/snapshot.types.js';
11
+ import { computeEid } from '../state/element-identity.js';
12
+ import { LIVE_REGION_KINDS } from '../state/actionables-filter.js';
13
+ import { executeAction, executeActionWithRetry } from './execute-action.js';
14
+ import { buildFindElementsResponse, buildGetElementDetailsResponse, } from './response-builder.js';
15
+ import { prepareActionContext } from './action-context.js';
16
+ /**
17
+ * Capture a fresh snapshot of the current page.
18
+ *
19
+ * @param rawInput - Capture options (will be validated)
20
+ * @returns Snapshot data for the current page
21
+ */
22
+ export async function captureSnapshot(rawInput, ctx) {
23
+ const input = CaptureSnapshotInputSchema.parse(rawInput);
24
+ let handle = ctx.resolveExistingPage(input.page_id);
25
+ const page_id = handle.page_id;
26
+ // Capture any accumulated observations (no action window)
27
+ const observations = await ctx
28
+ .getObservationAccumulator()
29
+ .getAccumulatedObservations(handle.page);
30
+ const captureResult = await ctx.captureSnapshotWithRecovery(handle, page_id);
31
+ handle = captureResult.handle;
32
+ const snapshot = captureResult.snapshot;
33
+ // Filter observations to reduce noise (threshold 5 requires semantic signals)
34
+ const filteredObservations = ctx
35
+ .getObservationAccumulator()
36
+ .filterBySignificance(observations, ATTACHMENT_SIGNIFICANCE_THRESHOLD);
37
+ // Attach accumulated observations to snapshot if any
38
+ if (filteredObservations.sincePrevious.length > 0) {
39
+ snapshot.observations = filteredObservations;
40
+ }
41
+ ctx.getSnapshotStore().store(page_id, snapshot);
42
+ // Return XML state response directly (trimmed for observation snapshots)
43
+ const stateManager = ctx.getStateManager(page_id);
44
+ return stateManager.generateResponse(snapshot, { trimRegions: true });
45
+ }
46
+ /**
47
+ * Map schema kind values to internal NodeKind values.
48
+ *
49
+ * The find schema uses user-friendly names that don't always match
50
+ * internal NodeKind values. For example, 'textbox' in the schema maps to
51
+ * both 'input' and 'textarea' internally.
52
+ *
53
+ * @param schemaKind - Kind value from the find schema
54
+ * @returns Matching NodeKind value(s)
55
+ */
56
+ export function mapSchemaKindToNodeKind(schemaKind) {
57
+ switch (schemaKind) {
58
+ case 'textbox':
59
+ return ['input', 'textarea'];
60
+ case 'alert':
61
+ return [...LIVE_REGION_KINDS];
62
+ default:
63
+ return schemaKind;
64
+ }
65
+ }
66
+ /**
67
+ * Find elements by semantic criteria.
68
+ *
69
+ * @param rawInput - Query filters (will be validated)
70
+ * @returns Matched nodes
71
+ */
72
+ export function findElements(rawInput, ctx) {
73
+ const input = FindElementsInputSchema.parse(rawInput);
74
+ const handle = ctx.resolveExistingPage(input.page_id);
75
+ const page_id = handle.page_id;
76
+ const snap = ctx.getSnapshotStore().getByPageId(page_id);
77
+ if (!snap) {
78
+ throw new Error(`No snapshot for page ${page_id} - capture a snapshot first`);
79
+ }
80
+ // Build query request from input
81
+ const request = {
82
+ limit: input.limit,
83
+ };
84
+ if (input.kind) {
85
+ request.kind = mapSchemaKindToNodeKind(input.kind);
86
+ }
87
+ if (input.label) {
88
+ request.label = { text: input.label, mode: 'contains', caseSensitive: false };
89
+ }
90
+ if (input.region) {
91
+ request.region = input.region;
92
+ }
93
+ const engine = new QueryEngine(snap);
94
+ const response = engine.find(request);
95
+ // Get registry and state manager for EID lookup
96
+ const stateManager = ctx.getStateManager(page_id);
97
+ const registry = stateManager.getElementRegistry();
98
+ const activeLayer = stateManager.getActiveLayer();
99
+ const matches = response.matches.map((m) => {
100
+ // Check if this is a readable/structural (non-interactive) node
101
+ const isNonInteractive = isReadableNode(m.node) || isStructuralNode(m.node) || isLiveRegionNode(m.node);
102
+ // Look up EID from registry (for interactive nodes)
103
+ const registryEid = registry.getEidBySnapshotAndBackendNodeId(snap.snapshot_id, m.node.backend_node_id);
104
+ // Determine EID:
105
+ // - Interactive nodes: use registry EID
106
+ // - Non-interactive nodes with include_readable: compute rd-* ID on-demand
107
+ // - Non-interactive nodes without include_readable: use unknown-* fallback
108
+ let eid;
109
+ if (registryEid) {
110
+ eid = registryEid;
111
+ }
112
+ else if (isNonInteractive && input.include_readable) {
113
+ // Compute on-demand semantic ID for readable content with rd- prefix
114
+ eid = `rd-${computeEid(m.node, activeLayer).substring(0, 10)}`;
115
+ }
116
+ else {
117
+ eid = `unknown-${m.node.backend_node_id}`;
118
+ }
119
+ const match = {
120
+ eid,
121
+ kind: m.node.kind,
122
+ label: m.node.label,
123
+ selector: m.node.find?.primary ?? '',
124
+ region: m.node.where.region,
125
+ };
126
+ // Include state if present (type-safe assignment via NodeState interface)
127
+ if (m.node.state) {
128
+ match.state = m.node.state;
129
+ }
130
+ // Include attributes if present (filter to common ones)
131
+ if (m.node.attributes) {
132
+ const attrs = {};
133
+ if (m.node.attributes.input_type)
134
+ attrs.input_type = m.node.attributes.input_type;
135
+ if (m.node.attributes.placeholder)
136
+ attrs.placeholder = m.node.attributes.placeholder;
137
+ if (m.node.attributes.value)
138
+ attrs.value = m.node.attributes.value;
139
+ if (m.node.attributes.href)
140
+ attrs.href = m.node.attributes.href;
141
+ if (m.node.attributes.alt)
142
+ attrs.alt = m.node.attributes.alt;
143
+ if (m.node.attributes.src)
144
+ attrs.src = m.node.attributes.src;
145
+ if (Object.keys(attrs).length > 0) {
146
+ match.attributes = attrs;
147
+ }
148
+ }
149
+ return match;
150
+ });
151
+ return buildFindElementsResponse(page_id, snap.snapshot_id, matches);
152
+ }
153
+ /**
154
+ * Get full details for a specific node.
155
+ *
156
+ * @param rawInput - Node details request (will be validated)
157
+ * @returns Full node details
158
+ */
159
+ export function getNodeDetails(rawInput, ctx) {
160
+ const input = GetNodeDetailsInputSchema.parse(rawInput);
161
+ const handle = ctx.resolveExistingPage(input.page_id);
162
+ const page_id = handle.page_id;
163
+ const snap = ctx.getSnapshotStore().getByPageId(page_id);
164
+ if (!snap) {
165
+ throw new Error(`No snapshot for page ${page_id} - capture a snapshot first`);
166
+ }
167
+ // Look up element by EID from registry
168
+ const stateManager = ctx.getStateManager(page_id);
169
+ const elementRef = stateManager.getElementRegistry().getByEid(input.eid);
170
+ if (!elementRef) {
171
+ throw new Error(`Element with eid ${input.eid} not found in registry`);
172
+ }
173
+ // Find the node by backend_node_id
174
+ const node = snap.nodes.find((n) => n.backend_node_id === elementRef.ref.backend_node_id);
175
+ if (!node) {
176
+ throw new Error(`Element with eid ${input.eid} has stale reference`);
177
+ }
178
+ const details = {
179
+ eid: input.eid,
180
+ kind: node.kind,
181
+ label: node.label,
182
+ where: {
183
+ region: node.where.region,
184
+ group_id: node.where.group_id,
185
+ group_path: node.where.group_path,
186
+ heading_context: node.where.heading_context,
187
+ },
188
+ layout: {
189
+ bbox: node.layout.bbox,
190
+ display: node.layout.display,
191
+ screen_zone: node.layout.screen_zone,
192
+ },
193
+ };
194
+ if (node.state) {
195
+ details.state = { ...node.state };
196
+ }
197
+ if (node.find) {
198
+ details.find = { primary: node.find.primary, alternates: node.find.alternates };
199
+ }
200
+ if (node.attributes) {
201
+ details.attributes = { ...node.attributes };
202
+ }
203
+ return buildGetElementDetailsResponse(page_id, snap.snapshot_id, details);
204
+ }
205
+ /**
206
+ * Scroll an element into view.
207
+ *
208
+ * @param rawInput - Scroll options (will be validated)
209
+ * @returns Scroll result with delta
210
+ */
211
+ export async function scrollElementIntoView(rawInput, ctx) {
212
+ const input = ScrollElementIntoViewInputSchema.parse(rawInput);
213
+ const { handleRef, pageId, captureSnapshot } = await prepareActionContext(input.page_id, ctx);
214
+ const snap = ctx.requireSnapshot(pageId);
215
+ const node = ctx.resolveElementByEid(pageId, input.eid, snap);
216
+ // Execute action with automatic retry on stale elements
217
+ const result = await executeActionWithRetry(handleRef.current, node, async (backendNodeId) => {
218
+ await scrollIntoView(handleRef.current.cdp, backendNodeId);
219
+ }, ctx, ctx.getSnapshotStore(), captureSnapshot);
220
+ // Store snapshot for future queries
221
+ ctx.getSnapshotStore().store(pageId, result.snapshot);
222
+ // Return XML state response directly
223
+ return result.state_response;
224
+ }
225
+ /**
226
+ * Scroll the page up or down.
227
+ *
228
+ * @param rawInput - Scroll options (will be validated)
229
+ * @returns Scroll result with delta
230
+ */
231
+ export async function scrollPage(rawInput, ctx) {
232
+ const input = ScrollPageInputSchema.parse(rawInput);
233
+ const { handleRef, pageId, captureSnapshot } = await prepareActionContext(input.page_id, ctx);
234
+ // Execute action with new simplified wrapper
235
+ const result = await executeAction(handleRef.current, async () => {
236
+ await scrollPageByAmount(handleRef.current.cdp, input.direction, input.amount);
237
+ }, ctx, captureSnapshot);
238
+ // Store snapshot for future queries
239
+ ctx.getSnapshotStore().store(pageId, result.snapshot);
240
+ // Return XML state response directly
241
+ return result.state_response;
242
+ }
243
+ //# sourceMappingURL=observation-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation-tools.js","sourceRoot":"","sources":["../../../src/tools/observation-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,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,oBAAoB,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAE9F,6CAA6C;IAC7C,MAAM,MAAM,GAAG,MAAM,aAAa,CAChC,SAAS,CAAC,OAAO,EACjB,KAAK,IAAI,EAAE;QACT,MAAM,kBAAkB,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjF,CAAC,EACD,GAAG,EACH,eAAe,CAChB,CAAC;IAEF,oCAAoC;IACpC,GAAG,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEtD,qCAAqC;IACrC,OAAO,MAAM,CAAC,cAAc,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Readability Tools
3
+ *
4
+ * MCP tool handler for extracting clean, readable page content
5
+ * using Mozilla's Readability.js (the engine behind Firefox Reader View).
6
+ */
7
+ import { type ReadPageOutput } from './tool-schemas.js';
8
+ import type { ToolContext } from './tool-context.types.js';
9
+ /**
10
+ * Extract the main readable content from the page.
11
+ *
12
+ * Uses Mozilla Readability (Firefox Reader View engine) to strip
13
+ * navigation, ads, and clutter, returning clean text with metadata.
14
+ */
15
+ export declare function readPage(rawInput: unknown, ctx: ToolContext): Promise<ReadPageOutput>;
16
+ //# sourceMappingURL=readability-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readability-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/readability-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CA+B3F"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Readability Tools
3
+ *
4
+ * MCP tool handler for extracting clean, readable page content
5
+ * using Mozilla's Readability.js (the engine behind Firefox Reader View).
6
+ */
7
+ import { Readability } from '@mozilla/readability';
8
+ import { JSDOM } from 'jsdom';
9
+ import { ReadPageInputSchema } from './tool-schemas.js';
10
+ import { buildReadPageResponse } from './response-builder.js';
11
+ /**
12
+ * Extract the main readable content from the page.
13
+ *
14
+ * Uses Mozilla Readability (Firefox Reader View engine) to strip
15
+ * navigation, ads, and clutter, returning clean text with metadata.
16
+ */
17
+ export async function readPage(rawInput, ctx) {
18
+ const input = ReadPageInputSchema.parse(rawInput);
19
+ const handle = ctx.resolveExistingPage(input.page_id);
20
+ // Get full page HTML and URL
21
+ const html = await handle.page.content();
22
+ const url = handle.page.url();
23
+ // Parse with JSDOM and extract with Readability
24
+ const doc = new JSDOM(html, { url });
25
+ try {
26
+ const reader = new Readability(doc.window.document);
27
+ const article = reader.parse();
28
+ if (!article) {
29
+ return '<result type="read_page"><error>Could not extract readable content from this page. The page may not have article-like content. Try using snapshot instead for structured page state.</error></result>';
30
+ }
31
+ return buildReadPageResponse({
32
+ title: article.title ?? '',
33
+ byline: article.byline ?? null,
34
+ excerpt: article.excerpt ?? null,
35
+ siteName: article.siteName ?? null,
36
+ lang: article.lang ?? null,
37
+ textContent: article.textContent ?? '',
38
+ length: article.length ?? 0,
39
+ });
40
+ }
41
+ finally {
42
+ doc.window.close();
43
+ }
44
+ }
45
+ //# sourceMappingURL=readability-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readability-tools.js","sourceRoot":"","sources":["../../../src/tools/readability-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAuB,MAAM,mBAAmB,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