@agentrhq/webcmd 0.1.1 → 0.1.2

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 (415) hide show
  1. package/README.md +317 -24
  2. package/dist/src/adapter-shadow.d.ts +11 -0
  3. package/dist/src/adapter-shadow.js +72 -0
  4. package/dist/src/adapter-shadow.test.d.ts +1 -0
  5. package/dist/src/adapter-shadow.test.js +49 -0
  6. package/dist/src/adapter-source.d.ts +11 -0
  7. package/dist/src/adapter-source.js +24 -0
  8. package/dist/src/adapter-source.test.d.ts +1 -0
  9. package/dist/src/adapter-source.test.js +29 -0
  10. package/dist/src/brand.d.ts +9 -0
  11. package/dist/src/brand.js +9 -0
  12. package/dist/src/brand.test.d.ts +1 -0
  13. package/dist/src/brand.test.js +15 -0
  14. package/dist/src/browser/analyze.d.ts +118 -0
  15. package/dist/src/browser/analyze.js +405 -0
  16. package/dist/src/browser/analyze.test.d.ts +1 -0
  17. package/dist/src/browser/analyze.test.js +209 -0
  18. package/dist/src/browser/article-extract.d.ts +57 -0
  19. package/dist/src/browser/article-extract.e2e.test.d.ts +1 -0
  20. package/dist/src/browser/article-extract.e2e.test.js +105 -0
  21. package/dist/src/browser/article-extract.js +169 -0
  22. package/dist/src/browser/article-extract.test.d.ts +1 -0
  23. package/dist/src/browser/article-extract.test.js +94 -0
  24. package/dist/src/browser/ax-snapshot.d.ts +37 -0
  25. package/dist/src/browser/ax-snapshot.js +217 -0
  26. package/dist/src/browser/ax-snapshot.test.d.ts +1 -0
  27. package/dist/src/browser/ax-snapshot.test.js +91 -0
  28. package/dist/src/browser/base-page.d.ts +151 -0
  29. package/dist/src/browser/base-page.js +1060 -0
  30. package/dist/src/browser/base-page.test.d.ts +1 -0
  31. package/dist/src/browser/base-page.test.js +803 -0
  32. package/dist/src/browser/bridge-readiness.d.ts +14 -0
  33. package/dist/src/browser/bridge-readiness.js +24 -0
  34. package/dist/src/browser/bridge-readiness.test.d.ts +1 -0
  35. package/dist/src/browser/bridge-readiness.test.js +58 -0
  36. package/dist/src/browser/bridge.d.ts +26 -0
  37. package/dist/src/browser/bridge.js +58 -0
  38. package/dist/src/browser/cdp-click-fixture.test.d.ts +1 -0
  39. package/dist/src/browser/cdp-click-fixture.test.js +87 -0
  40. package/dist/src/browser/cdp.d.ts +46 -0
  41. package/dist/src/browser/cdp.js +536 -0
  42. package/dist/src/browser/cdp.test.d.ts +1 -0
  43. package/dist/src/browser/cdp.test.js +79 -0
  44. package/dist/src/browser/compound.d.ts +59 -0
  45. package/dist/src/browser/compound.js +112 -0
  46. package/dist/src/browser/compound.test.d.ts +1 -0
  47. package/dist/src/browser/compound.test.js +175 -0
  48. package/dist/src/browser/config.d.ts +2 -0
  49. package/dist/src/browser/config.js +14 -0
  50. package/dist/src/browser/daemon-client.d.ts +32 -0
  51. package/dist/src/browser/daemon-client.js +135 -0
  52. package/dist/src/browser/daemon-client.test.d.ts +1 -0
  53. package/dist/src/browser/daemon-client.test.js +326 -0
  54. package/dist/src/browser/daemon-lifecycle.d.ts +37 -0
  55. package/dist/src/browser/daemon-lifecycle.js +147 -0
  56. package/dist/src/browser/daemon-transport.d.ts +54 -0
  57. package/dist/src/browser/daemon-transport.js +68 -0
  58. package/dist/src/browser/daemon-version.d.ts +4 -0
  59. package/dist/src/browser/daemon-version.js +12 -0
  60. package/dist/src/browser/dom-helpers.d.ts +41 -0
  61. package/dist/src/browser/dom-helpers.js +239 -0
  62. package/dist/src/browser/dom-helpers.test.d.ts +1 -0
  63. package/dist/src/browser/dom-helpers.test.js +106 -0
  64. package/dist/src/browser/dom-snapshot.d.ts +93 -0
  65. package/dist/src/browser/dom-snapshot.js +894 -0
  66. package/dist/src/browser/dom-snapshot.test.d.ts +11 -0
  67. package/dist/src/browser/dom-snapshot.test.js +313 -0
  68. package/dist/src/browser/errors.d.ts +38 -0
  69. package/dist/src/browser/errors.js +79 -0
  70. package/dist/src/browser/errors.test.d.ts +1 -0
  71. package/dist/src/browser/errors.test.js +60 -0
  72. package/dist/src/browser/extract.d.ts +69 -0
  73. package/dist/src/browser/extract.js +132 -0
  74. package/dist/src/browser/extract.test.d.ts +1 -0
  75. package/dist/src/browser/extract.test.js +129 -0
  76. package/dist/src/browser/find.d.ts +84 -0
  77. package/dist/src/browser/find.js +398 -0
  78. package/dist/src/browser/find.test.d.ts +1 -0
  79. package/dist/src/browser/find.test.js +180 -0
  80. package/dist/src/browser/html-tree.d.ts +75 -0
  81. package/dist/src/browser/html-tree.js +112 -0
  82. package/dist/src/browser/html-tree.test.d.ts +1 -0
  83. package/dist/src/browser/html-tree.test.js +181 -0
  84. package/dist/src/browser/index.d.ts +14 -0
  85. package/dist/src/browser/index.js +12 -0
  86. package/dist/src/browser/network-cache.d.ts +49 -0
  87. package/dist/src/browser/network-cache.js +78 -0
  88. package/dist/src/browser/network-cache.test.d.ts +1 -0
  89. package/dist/src/browser/network-cache.test.js +75 -0
  90. package/dist/src/browser/network-interceptor.d.ts +11 -0
  91. package/dist/src/browser/network-interceptor.js +11 -0
  92. package/dist/src/browser/network-key.d.ts +22 -0
  93. package/dist/src/browser/network-key.js +66 -0
  94. package/dist/src/browser/network-key.test.d.ts +1 -0
  95. package/dist/src/browser/network-key.test.js +49 -0
  96. package/dist/src/browser/page.d.ts +83 -0
  97. package/dist/src/browser/page.js +453 -0
  98. package/dist/src/browser/page.test.d.ts +1 -0
  99. package/dist/src/browser/page.test.js +406 -0
  100. package/dist/src/browser/profile.d.ts +14 -0
  101. package/dist/src/browser/profile.js +86 -0
  102. package/dist/src/browser/protocol.d.ts +63 -0
  103. package/dist/src/browser/protocol.js +1 -0
  104. package/dist/src/browser/runtime/local-cloak/actions.d.ts +3 -0
  105. package/dist/src/browser/runtime/local-cloak/actions.js +240 -0
  106. package/dist/src/browser/runtime/local-cloak/downloads.d.ts +3 -0
  107. package/dist/src/browser/runtime/local-cloak/downloads.js +28 -0
  108. package/dist/src/browser/runtime/local-cloak/network.d.ts +28 -0
  109. package/dist/src/browser/runtime/local-cloak/network.js +120 -0
  110. package/dist/src/browser/runtime/local-cloak/network.test.d.ts +1 -0
  111. package/dist/src/browser/runtime/local-cloak/network.test.js +124 -0
  112. package/dist/src/browser/runtime/local-cloak/profiles.d.ts +6 -0
  113. package/dist/src/browser/runtime/local-cloak/profiles.js +17 -0
  114. package/dist/src/browser/runtime/local-cloak/profiles.test.d.ts +1 -0
  115. package/dist/src/browser/runtime/local-cloak/profiles.test.js +19 -0
  116. package/dist/src/browser/runtime/local-cloak/provider.d.ts +15 -0
  117. package/dist/src/browser/runtime/local-cloak/provider.js +27 -0
  118. package/dist/src/browser/runtime/local-cloak/provider.test.d.ts +1 -0
  119. package/dist/src/browser/runtime/local-cloak/provider.test.js +244 -0
  120. package/dist/src/browser/runtime/local-cloak/session-manager.d.ts +77 -0
  121. package/dist/src/browser/runtime/local-cloak/session-manager.js +280 -0
  122. package/dist/src/browser/runtime/local-cloak/session-manager.test.d.ts +1 -0
  123. package/dist/src/browser/runtime/local-cloak/session-manager.test.js +92 -0
  124. package/dist/src/browser/runtime/provider.d.ts +9 -0
  125. package/dist/src/browser/runtime/provider.js +1 -0
  126. package/dist/src/browser/runtime/provider.test.d.ts +2 -0
  127. package/dist/src/browser/runtime/provider.test.js +49 -0
  128. package/dist/src/browser/shape-filter.d.ts +52 -0
  129. package/dist/src/browser/shape-filter.js +101 -0
  130. package/dist/src/browser/shape-filter.test.d.ts +1 -0
  131. package/dist/src/browser/shape-filter.test.js +101 -0
  132. package/dist/src/browser/shape.d.ts +23 -0
  133. package/dist/src/browser/shape.js +95 -0
  134. package/dist/src/browser/shape.test.d.ts +1 -0
  135. package/dist/src/browser/shape.test.js +82 -0
  136. package/dist/src/browser/stealth.d.ts +11 -0
  137. package/dist/src/browser/stealth.js +359 -0
  138. package/dist/src/browser/stealth.test.d.ts +1 -0
  139. package/dist/src/browser/stealth.test.js +134 -0
  140. package/dist/src/browser/tabs.d.ts +13 -0
  141. package/dist/src/browser/tabs.js +70 -0
  142. package/dist/src/browser/target-errors.d.ts +39 -0
  143. package/dist/src/browser/target-errors.js +45 -0
  144. package/dist/src/browser/target-errors.test.d.ts +1 -0
  145. package/dist/src/browser/target-errors.test.js +94 -0
  146. package/dist/src/browser/target-resolver.d.ts +158 -0
  147. package/dist/src/browser/target-resolver.js +570 -0
  148. package/dist/src/browser/target-resolver.test.d.ts +1 -0
  149. package/dist/src/browser/target-resolver.test.js +118 -0
  150. package/dist/src/browser/utils.d.ts +20 -0
  151. package/dist/src/browser/utils.js +64 -0
  152. package/dist/src/browser/utils.test.d.ts +1 -0
  153. package/dist/src/browser/utils.test.js +29 -0
  154. package/dist/src/browser/verify-fixture.d.ts +65 -0
  155. package/dist/src/browser/verify-fixture.js +318 -0
  156. package/dist/src/browser/verify-fixture.test.d.ts +1 -0
  157. package/dist/src/browser/verify-fixture.test.js +219 -0
  158. package/dist/src/browser/visual-refs.d.ts +11 -0
  159. package/dist/src/browser/visual-refs.js +108 -0
  160. package/dist/src/browser.test.d.ts +1 -0
  161. package/dist/src/browser.test.js +297 -0
  162. package/dist/src/build-manifest.d.ts +103 -0
  163. package/dist/src/build-manifest.js +363 -0
  164. package/dist/src/build-manifest.test.d.ts +1 -0
  165. package/dist/src/build-manifest.test.js +341 -0
  166. package/dist/src/capabilityRouting.d.ts +19 -0
  167. package/dist/src/capabilityRouting.js +56 -0
  168. package/dist/src/capabilityRouting.test.d.ts +1 -0
  169. package/dist/src/capabilityRouting.test.js +63 -0
  170. package/dist/src/cli-argv-preprocess.d.ts +63 -0
  171. package/dist/src/cli-argv-preprocess.js +303 -0
  172. package/dist/src/cli-argv-preprocess.test.d.ts +1 -0
  173. package/dist/src/cli-argv-preprocess.test.js +304 -0
  174. package/dist/src/cli.d.ts +79 -0
  175. package/dist/src/cli.js +3350 -0
  176. package/dist/src/cli.test.d.ts +1 -0
  177. package/dist/src/cli.test.js +3041 -0
  178. package/dist/src/commanderAdapter.d.ts +21 -0
  179. package/dist/src/commanderAdapter.js +208 -0
  180. package/dist/src/commanderAdapter.test.d.ts +1 -0
  181. package/dist/src/commanderAdapter.test.js +352 -0
  182. package/dist/src/commands/auth.d.ts +40 -0
  183. package/dist/src/commands/auth.js +434 -0
  184. package/dist/src/commands/auth.test.d.ts +1 -0
  185. package/dist/src/commands/auth.test.js +252 -0
  186. package/dist/src/commands/daemon.d.ts +9 -0
  187. package/dist/src/commands/daemon.js +91 -0
  188. package/dist/src/commands/daemon.test.d.ts +1 -0
  189. package/dist/src/commands/daemon.test.js +293 -0
  190. package/dist/src/completion-fast.d.ts +22 -0
  191. package/dist/src/completion-fast.js +88 -0
  192. package/dist/src/completion-shared.d.ts +13 -0
  193. package/dist/src/completion-shared.js +61 -0
  194. package/dist/src/completion.d.ts +21 -0
  195. package/dist/src/completion.js +68 -0
  196. package/dist/src/completion.test.d.ts +1 -0
  197. package/dist/src/completion.test.js +24 -0
  198. package/dist/src/constants.d.ts +18 -0
  199. package/dist/src/constants.js +41 -0
  200. package/dist/src/convention-audit.d.ts +50 -0
  201. package/dist/src/convention-audit.js +553 -0
  202. package/dist/src/convention-audit.test.d.ts +1 -0
  203. package/dist/src/convention-audit.test.js +255 -0
  204. package/dist/src/daemon/server.d.ts +13 -0
  205. package/dist/src/daemon/server.js +185 -0
  206. package/dist/src/daemon/server.test.d.ts +1 -0
  207. package/dist/src/daemon/server.test.js +132 -0
  208. package/dist/src/daemon-utils.d.ts +18 -0
  209. package/dist/src/daemon-utils.js +37 -0
  210. package/dist/src/daemon.d.ts +1 -0
  211. package/dist/src/daemon.js +27 -0
  212. package/dist/src/daemon.test.d.ts +1 -0
  213. package/dist/src/daemon.test.js +60 -0
  214. package/dist/src/discovery.d.ts +46 -0
  215. package/dist/src/discovery.js +341 -0
  216. package/dist/src/doctor.d.ts +39 -0
  217. package/dist/src/doctor.js +168 -0
  218. package/dist/src/doctor.test.d.ts +1 -0
  219. package/dist/src/doctor.test.js +302 -0
  220. package/dist/src/download/article-download.d.ts +72 -0
  221. package/dist/src/download/article-download.js +305 -0
  222. package/dist/src/download/article-download.test.d.ts +1 -0
  223. package/dist/src/download/article-download.test.js +235 -0
  224. package/dist/src/download/index.d.ts +71 -0
  225. package/dist/src/download/index.js +363 -0
  226. package/dist/src/download/index.test.d.ts +1 -0
  227. package/dist/src/download/index.test.js +174 -0
  228. package/dist/src/download/media-download.d.ts +49 -0
  229. package/dist/src/download/media-download.js +127 -0
  230. package/dist/src/download/media-download.test.d.ts +1 -0
  231. package/dist/src/download/media-download.test.js +112 -0
  232. package/dist/src/download/progress.d.ts +36 -0
  233. package/dist/src/download/progress.js +120 -0
  234. package/dist/src/download/progress.test.d.ts +1 -0
  235. package/dist/src/download/progress.test.js +36 -0
  236. package/dist/src/electron-apps.d.ts +31 -0
  237. package/dist/src/electron-apps.js +91 -0
  238. package/dist/src/electron-apps.test.d.ts +1 -0
  239. package/dist/src/electron-apps.test.js +76 -0
  240. package/dist/src/engine.test.d.ts +1 -0
  241. package/dist/src/engine.test.js +312 -0
  242. package/dist/src/errors.d.ts +114 -0
  243. package/dist/src/errors.js +174 -0
  244. package/dist/src/errors.test.d.ts +1 -0
  245. package/dist/src/errors.test.js +109 -0
  246. package/dist/src/execution.d.ts +24 -0
  247. package/dist/src/execution.js +509 -0
  248. package/dist/src/execution.test.d.ts +1 -0
  249. package/dist/src/execution.test.js +645 -0
  250. package/dist/src/external.d.ts +49 -0
  251. package/dist/src/external.js +211 -0
  252. package/dist/src/external.test.d.ts +1 -0
  253. package/dist/src/external.test.js +110 -0
  254. package/dist/src/help.d.ts +88 -0
  255. package/dist/src/help.js +556 -0
  256. package/dist/src/help.test.d.ts +1 -0
  257. package/dist/src/help.test.js +58 -0
  258. package/dist/src/hooks.d.ts +46 -0
  259. package/dist/src/hooks.js +58 -0
  260. package/dist/src/hooks.test.d.ts +4 -0
  261. package/dist/src/hooks.test.js +92 -0
  262. package/dist/src/interceptor.d.ts +44 -0
  263. package/dist/src/interceptor.js +183 -0
  264. package/dist/src/interceptor.test.d.ts +4 -0
  265. package/dist/src/interceptor.test.js +81 -0
  266. package/dist/src/launcher.d.ts +41 -0
  267. package/dist/src/launcher.js +226 -0
  268. package/dist/src/launcher.test.d.ts +1 -0
  269. package/dist/src/launcher.test.js +153 -0
  270. package/dist/src/logger.d.ts +26 -0
  271. package/dist/src/logger.js +49 -0
  272. package/dist/src/main.d.ts +5 -0
  273. package/dist/src/main.js +177 -0
  274. package/dist/src/manifest-types.d.ts +43 -0
  275. package/dist/src/manifest-types.js +9 -0
  276. package/dist/src/node-network.d.ts +10 -0
  277. package/dist/src/node-network.js +174 -0
  278. package/dist/src/node-network.test.d.ts +1 -0
  279. package/dist/src/node-network.test.js +55 -0
  280. package/dist/src/observation/artifact.d.ts +16 -0
  281. package/dist/src/observation/artifact.js +260 -0
  282. package/dist/src/observation/artifact.test.d.ts +1 -0
  283. package/dist/src/observation/artifact.test.js +121 -0
  284. package/dist/src/observation/events.d.ts +89 -0
  285. package/dist/src/observation/events.js +1 -0
  286. package/dist/src/observation/index.d.ts +7 -0
  287. package/dist/src/observation/index.js +7 -0
  288. package/dist/src/observation/manager.d.ts +9 -0
  289. package/dist/src/observation/manager.js +27 -0
  290. package/dist/src/observation/manager.test.d.ts +1 -0
  291. package/dist/src/observation/manager.test.js +13 -0
  292. package/dist/src/observation/redaction.d.ts +11 -0
  293. package/dist/src/observation/redaction.js +81 -0
  294. package/dist/src/observation/redaction.test.d.ts +1 -0
  295. package/dist/src/observation/redaction.test.js +32 -0
  296. package/dist/src/observation/retention.d.ts +32 -0
  297. package/dist/src/observation/retention.js +160 -0
  298. package/dist/src/observation/retention.test.d.ts +1 -0
  299. package/dist/src/observation/retention.test.js +118 -0
  300. package/dist/src/observation/ring-buffer.d.ts +22 -0
  301. package/dist/src/observation/ring-buffer.js +45 -0
  302. package/dist/src/observation/ring-buffer.test.d.ts +1 -0
  303. package/dist/src/observation/ring-buffer.test.js +22 -0
  304. package/dist/src/observation/session.d.ts +25 -0
  305. package/dist/src/observation/session.js +50 -0
  306. package/dist/src/output.d.ts +14 -0
  307. package/dist/src/output.js +152 -0
  308. package/dist/src/output.test.d.ts +1 -0
  309. package/dist/src/output.test.js +53 -0
  310. package/dist/src/package-exports.test.d.ts +1 -0
  311. package/dist/src/package-exports.test.js +112 -0
  312. package/dist/src/package-paths.d.ts +8 -0
  313. package/dist/src/package-paths.js +41 -0
  314. package/dist/src/pipeline/executor.d.ts +11 -0
  315. package/dist/src/pipeline/executor.js +93 -0
  316. package/dist/src/pipeline/executor.test.d.ts +4 -0
  317. package/dist/src/pipeline/executor.test.js +182 -0
  318. package/dist/src/pipeline/index.d.ts +5 -0
  319. package/dist/src/pipeline/index.js +5 -0
  320. package/dist/src/pipeline/registry.d.ts +28 -0
  321. package/dist/src/pipeline/registry.js +55 -0
  322. package/dist/src/pipeline/steps/browser.d.ts +13 -0
  323. package/dist/src/pipeline/steps/browser.js +86 -0
  324. package/dist/src/pipeline/steps/download.d.ts +18 -0
  325. package/dist/src/pipeline/steps/download.js +252 -0
  326. package/dist/src/pipeline/steps/download.test.d.ts +1 -0
  327. package/dist/src/pipeline/steps/download.test.js +102 -0
  328. package/dist/src/pipeline/steps/fetch.d.ts +5 -0
  329. package/dist/src/pipeline/steps/fetch.js +122 -0
  330. package/dist/src/pipeline/steps/fetch.test.d.ts +1 -0
  331. package/dist/src/pipeline/steps/fetch.test.js +117 -0
  332. package/dist/src/pipeline/steps/intercept.d.ts +5 -0
  333. package/dist/src/pipeline/steps/intercept.js +50 -0
  334. package/dist/src/pipeline/steps/tap.d.ts +12 -0
  335. package/dist/src/pipeline/steps/tap.js +93 -0
  336. package/dist/src/pipeline/steps/transform.d.ts +9 -0
  337. package/dist/src/pipeline/steps/transform.js +70 -0
  338. package/dist/src/pipeline/template.d.ts +17 -0
  339. package/dist/src/pipeline/template.js +344 -0
  340. package/dist/src/pipeline/template.test.d.ts +4 -0
  341. package/dist/src/pipeline/template.test.js +197 -0
  342. package/dist/src/pipeline/transform.test.d.ts +4 -0
  343. package/dist/src/pipeline/transform.test.js +133 -0
  344. package/dist/src/plugin-manifest.d.ts +70 -0
  345. package/dist/src/plugin-manifest.js +160 -0
  346. package/dist/src/plugin-manifest.test.d.ts +4 -0
  347. package/dist/src/plugin-manifest.test.js +179 -0
  348. package/dist/src/plugin-scaffold.d.ts +28 -0
  349. package/dist/src/plugin-scaffold.js +143 -0
  350. package/dist/src/plugin-scaffold.test.d.ts +4 -0
  351. package/dist/src/plugin-scaffold.test.js +83 -0
  352. package/dist/src/plugin.d.ts +146 -0
  353. package/dist/src/plugin.js +1303 -0
  354. package/dist/src/plugin.test.d.ts +4 -0
  355. package/dist/src/plugin.test.js +1363 -0
  356. package/dist/src/registry-api.d.ts +13 -0
  357. package/dist/src/registry-api.js +10 -0
  358. package/dist/src/registry.d.ts +123 -0
  359. package/dist/src/registry.js +125 -0
  360. package/dist/src/registry.test.d.ts +4 -0
  361. package/dist/src/registry.test.js +209 -0
  362. package/dist/src/runtime-copy.test.d.ts +1 -0
  363. package/dist/src/runtime-copy.test.js +29 -0
  364. package/dist/src/runtime-detect.d.ts +31 -0
  365. package/dist/src/runtime-detect.js +47 -0
  366. package/dist/src/runtime-detect.test.d.ts +1 -0
  367. package/dist/src/runtime-detect.test.js +39 -0
  368. package/dist/src/runtime-identity.test.d.ts +1 -0
  369. package/dist/src/runtime-identity.test.js +18 -0
  370. package/dist/src/runtime.d.ts +47 -0
  371. package/dist/src/runtime.js +54 -0
  372. package/dist/src/scripts/framework.d.ts +7 -0
  373. package/dist/src/scripts/framework.js +25 -0
  374. package/dist/src/scripts/interact.d.ts +4 -0
  375. package/dist/src/scripts/interact.js +20 -0
  376. package/dist/src/scripts/store.d.ts +13 -0
  377. package/dist/src/scripts/store.js +48 -0
  378. package/dist/src/serialization.d.ts +42 -0
  379. package/dist/src/serialization.js +103 -0
  380. package/dist/src/serialization.test.d.ts +1 -0
  381. package/dist/src/serialization.test.js +78 -0
  382. package/dist/src/skills.d.ts +14 -0
  383. package/dist/src/skills.js +127 -0
  384. package/dist/src/skills.test.d.ts +1 -0
  385. package/dist/src/skills.test.js +71 -0
  386. package/dist/src/snapshotFormatter.d.ts +11 -0
  387. package/dist/src/snapshotFormatter.js +338 -0
  388. package/dist/src/snapshotFormatter.test.d.ts +7 -0
  389. package/dist/src/snapshotFormatter.test.js +521 -0
  390. package/dist/src/tui.d.ts +28 -0
  391. package/dist/src/tui.js +179 -0
  392. package/dist/src/tui.test.d.ts +1 -0
  393. package/dist/src/tui.test.js +19 -0
  394. package/dist/src/types.d.ts +236 -0
  395. package/dist/src/types.js +7 -0
  396. package/dist/src/update-check.d.ts +66 -0
  397. package/dist/src/update-check.js +206 -0
  398. package/dist/src/update-check.test.d.ts +1 -0
  399. package/dist/src/update-check.test.js +117 -0
  400. package/dist/src/utils.d.ts +57 -0
  401. package/dist/src/utils.js +152 -0
  402. package/dist/src/utils.test.d.ts +1 -0
  403. package/dist/src/utils.test.js +155 -0
  404. package/dist/src/validate.d.ts +21 -0
  405. package/dist/src/validate.js +130 -0
  406. package/dist/src/validate.test.d.ts +9 -0
  407. package/dist/src/validate.test.js +90 -0
  408. package/dist/src/verify.d.ts +26 -0
  409. package/dist/src/verify.js +67 -0
  410. package/dist/src/version.d.ts +4 -0
  411. package/dist/src/version.js +22 -0
  412. package/dist/src/weixin-download.test.d.ts +1 -0
  413. package/dist/src/weixin-download.test.js +45 -0
  414. package/package.json +4 -3
  415. package/scripts/check-package-bin.mjs +95 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Tests for dom-snapshot.ts: DOM snapshot engine.
3
+ *
4
+ * Since the engine generates JavaScript strings for in-page evaluation,
5
+ * these tests validate:
6
+ * 1. The generated code is syntactically valid JS
7
+ * 2. Options are correctly embedded
8
+ * 3. The output structure matches expected format
9
+ * 4. All features are present (Shadow DOM, iframe, table, diff, etc.)
10
+ */
11
+ export {};
@@ -0,0 +1,313 @@
1
+ /**
2
+ * Tests for dom-snapshot.ts: DOM snapshot engine.
3
+ *
4
+ * Since the engine generates JavaScript strings for in-page evaluation,
5
+ * these tests validate:
6
+ * 1. The generated code is syntactically valid JS
7
+ * 2. Options are correctly embedded
8
+ * 3. The output structure matches expected format
9
+ * 4. All features are present (Shadow DOM, iframe, table, diff, etc.)
10
+ */
11
+ import { describe, it, expect } from 'vitest';
12
+ import { generateSnapshotJs, scrollToRefJs, getFormStateJs } from './dom-snapshot.js';
13
+ describe('generateSnapshotJs', () => {
14
+ it('returns a non-empty string', () => {
15
+ const js = generateSnapshotJs();
16
+ expect(typeof js).toBe('string');
17
+ expect(js.length).toBeGreaterThan(100);
18
+ });
19
+ it('generates syntactically valid JS (can be parsed)', () => {
20
+ const js = generateSnapshotJs();
21
+ expect(() => new Function(js)).not.toThrow();
22
+ });
23
+ it('embeds default options correctly', () => {
24
+ const js = generateSnapshotJs();
25
+ expect(js).toContain('VIEWPORT_EXPAND = 800');
26
+ expect(js).toContain('MAX_DEPTH = 50');
27
+ expect(js).toContain('INTERACTIVE_ONLY = false');
28
+ expect(js).toContain('MAX_TEXT_LEN = 120');
29
+ expect(js).toContain('INCLUDE_SCROLL_INFO = true');
30
+ expect(js).toContain('BBOX_DEDUP = true');
31
+ expect(js).toContain('INCLUDE_SHADOW_DOM = true');
32
+ expect(js).toContain('INCLUDE_IFRAMES = true');
33
+ expect(js).toContain('PAINT_ORDER_CHECK = true');
34
+ expect(js).toContain('ANNOTATE_REFS = true');
35
+ expect(js).toContain('REPORT_HIDDEN = true');
36
+ expect(js).toContain('FILTER_ADS = true');
37
+ expect(js).toContain('MARKDOWN_TABLES = true');
38
+ expect(js).toContain('PREV_HASHES = null');
39
+ });
40
+ it('embeds custom options correctly', () => {
41
+ const js = generateSnapshotJs({
42
+ viewportExpand: 2000,
43
+ maxDepth: 30,
44
+ interactiveOnly: true,
45
+ maxTextLength: 200,
46
+ includeScrollInfo: false,
47
+ bboxDedup: false,
48
+ includeShadowDom: false,
49
+ includeIframes: false,
50
+ maxIframes: 3,
51
+ paintOrderCheck: false,
52
+ annotateRefs: false,
53
+ reportHidden: false,
54
+ filterAds: false,
55
+ markdownTables: false,
56
+ });
57
+ expect(js).toContain('VIEWPORT_EXPAND = 2000');
58
+ expect(js).toContain('MAX_DEPTH = 30');
59
+ expect(js).toContain('INTERACTIVE_ONLY = true');
60
+ expect(js).toContain('MAX_TEXT_LEN = 200');
61
+ expect(js).toContain('INCLUDE_SCROLL_INFO = false');
62
+ expect(js).toContain('BBOX_DEDUP = false');
63
+ expect(js).toContain('INCLUDE_SHADOW_DOM = false');
64
+ expect(js).toContain('INCLUDE_IFRAMES = false');
65
+ expect(js).toContain('MAX_IFRAMES = 3');
66
+ expect(js).toContain('PAINT_ORDER_CHECK = false');
67
+ expect(js).toContain('ANNOTATE_REFS = false');
68
+ expect(js).toContain('REPORT_HIDDEN = false');
69
+ expect(js).toContain('FILTER_ADS = false');
70
+ expect(js).toContain('MARKDOWN_TABLES = false');
71
+ });
72
+ it('clamps maxDepth between 1 and 200', () => {
73
+ expect(generateSnapshotJs({ maxDepth: -5 })).toContain('MAX_DEPTH = 1');
74
+ expect(generateSnapshotJs({ maxDepth: 999 })).toContain('MAX_DEPTH = 200');
75
+ expect(generateSnapshotJs({ maxDepth: 75 })).toContain('MAX_DEPTH = 75');
76
+ });
77
+ it('wraps output as an IIFE', () => {
78
+ const js = generateSnapshotJs();
79
+ expect(js.startsWith('(() =>')).toBe(true);
80
+ expect(js.trimEnd().endsWith(')()')).toBe(true);
81
+ });
82
+ it('embeds previousHashes for incremental diff', () => {
83
+ const hashes = JSON.stringify(['12345', '67890']);
84
+ const js = generateSnapshotJs({ previousHashes: hashes });
85
+ expect(js).toContain('new Set(["12345","67890"])');
86
+ });
87
+ it('includes all core features in generated code', () => {
88
+ const js = generateSnapshotJs();
89
+ // Tag filtering
90
+ expect(js).toContain('SKIP_TAGS');
91
+ expect(js).toContain("'script'");
92
+ expect(js).toContain("'style'");
93
+ // SVG collapsing
94
+ expect(js).toContain('SVG_CHILDREN');
95
+ // Interactive detection
96
+ expect(js).toContain('INTERACTIVE_TAGS');
97
+ expect(js).toContain('INTERACTIVE_ROLES');
98
+ expect(js).toContain('isInteractive');
99
+ // Visibility
100
+ expect(js).toContain('isVisibleByCSS');
101
+ expect(js).toContain('isInExpandedViewport');
102
+ // BBox dedup
103
+ expect(js).toContain('isContainedBy');
104
+ expect(js).toContain('PROPAGATING_TAGS');
105
+ expect(js).toContain('PROPAGATING_ROLES');
106
+ expect(js).toContain('isBboxPropagator');
107
+ expect(js).toContain('isDistinctivelyInteractive');
108
+ // Shadow DOM
109
+ expect(js).toContain('shadowRoot');
110
+ expect(js).toContain('|shadow|');
111
+ // iframe
112
+ expect(js).toContain('walkIframe');
113
+ expect(js).toContain('|iframe|');
114
+ // Paint order
115
+ expect(js).toContain('isOccludedByOverlay');
116
+ expect(js).toContain('elementFromPoint');
117
+ // Ad filtering
118
+ expect(js).toContain('isAdElement');
119
+ expect(js).toContain('AD_PATTERNS');
120
+ // data-ref annotation
121
+ expect(js).toContain('data-webcmd-ref');
122
+ // Hidden elements report
123
+ expect(js).toContain('hiddenInteractives');
124
+ expect(js).toContain('hidden_interactive');
125
+ // Incremental diff
126
+ expect(js).toContain('hashElement');
127
+ expect(js).toContain('currentHashes');
128
+ expect(js).toContain('__webcmd_prev_hashes');
129
+ // Table serialization
130
+ expect(js).toContain('serializeTable');
131
+ expect(js).toContain('|table|');
132
+ // Synthetic attributes
133
+ expect(js).toContain("'YYYY-MM-DD'");
134
+ expect(js).toContain('value=••••');
135
+ // Page metadata
136
+ expect(js).toContain('location.href');
137
+ expect(js).toContain('document.title');
138
+ });
139
+ it('contains proper attribute whitelist', () => {
140
+ const js = generateSnapshotJs();
141
+ const expectedAttrs = [
142
+ 'aria-label', 'aria-expanded', 'aria-checked', 'aria-selected',
143
+ 'placeholder', 'href', 'role', 'data-testid', 'autocomplete',
144
+ ];
145
+ for (const attr of expectedAttrs) {
146
+ expect(js).toContain(`'${attr}'`);
147
+ }
148
+ });
149
+ it('includes scroll info formatting', () => {
150
+ const js = generateSnapshotJs();
151
+ expect(js).toContain('scrollHeight');
152
+ expect(js).toContain('scrollTop');
153
+ expect(js).toContain('|scroll|');
154
+ expect(js).toContain('page_scroll');
155
+ });
156
+ });
157
+ describe('BBox 99% containment filter', () => {
158
+ it('propagates bbox for both PROPAGATING_TAGS and PROPAGATING_ROLES', () => {
159
+ const js = generateSnapshotJs();
160
+ // Role-based propagator list covers the common wrapper-as-control patterns
161
+ // that show up as <div role=button><svg/><span/></div> on modern SPAs.
162
+ for (const role of ['button', 'link', 'menuitem', 'tab', 'option']) {
163
+ expect(js).toContain(`'${role}'`);
164
+ }
165
+ // propagate site uses the unified helper, not only the tag set
166
+ expect(js).toContain('isBboxPropagator(el, tag)');
167
+ });
168
+ it('suppresses interactive descendants at 0.99 containment when they are not distinctive', () => {
169
+ const js = generateSnapshotJs();
170
+ expect(js).toContain('isContainedBy(rect, parentPropagatingRect, 0.99)');
171
+ expect(js).toContain('!isDistinctivelyInteractive(el)');
172
+ // The suppression path flips the local interactive flag so the node is
173
+ // still emitted (for text / shape) but does not get its own [N] ref.
174
+ expect(js).toContain('interactive = false');
175
+ });
176
+ it('does not suppress inputs / href-bearing anchors even when fully contained', () => {
177
+ const js = generateSnapshotJs();
178
+ // Guards inside isDistinctivelyInteractive
179
+ expect(js).toContain("tag === 'input'");
180
+ expect(js).toContain("tag === 'select'");
181
+ expect(js).toContain("tag === 'textarea'");
182
+ expect(js).toContain("tag === 'a'");
183
+ expect(js).toContain("el.hasAttribute('href')");
184
+ // aria-label / aria-labelledby / id / test-id / name preserve distinctness
185
+ expect(js).toContain("el.hasAttribute('aria-label')");
186
+ expect(js).toContain("el.hasAttribute('aria-labelledby')");
187
+ expect(js).toContain("el.id");
188
+ expect(js).toContain("el.getAttribute('data-testid')");
189
+ expect(js).toContain("el.hasAttribute('name')");
190
+ });
191
+ it('keeps the existing 0.95 non-interactive dedup tier in place', () => {
192
+ const js = generateSnapshotJs();
193
+ // The original non-interactive bbox filter is still present alongside the
194
+ // new interactive tier — two complementary thresholds, not a replacement.
195
+ expect(js).toContain('isContainedBy(rect, parentPropagatingRect, 0.95)');
196
+ });
197
+ it('bbox containment branches are gated on BBOX_DEDUP flag', () => {
198
+ const off = generateSnapshotJs({ bboxDedup: false });
199
+ // When the option is off, the filter becomes inert (BBOX_DEDUP = false)
200
+ // but the inlined helpers still ship — we only guard at the call sites.
201
+ expect(off).toContain('BBOX_DEDUP = false');
202
+ expect(off).toContain('isBboxPropagator');
203
+ expect(off).toContain('isDistinctivelyInteractive');
204
+ });
205
+ });
206
+ describe('scrollToRefJs', () => {
207
+ it('generates valid JS', () => {
208
+ const js = scrollToRefJs('42');
209
+ expect(() => new Function(js)).not.toThrow();
210
+ });
211
+ it('targets data-webcmd-ref', () => {
212
+ const js = scrollToRefJs('7');
213
+ expect(js).toContain('data-webcmd-ref');
214
+ expect(js).toContain('scrollIntoView');
215
+ expect(js).toContain('"7"');
216
+ });
217
+ it('falls back to data-ref', () => {
218
+ const js = scrollToRefJs('3');
219
+ expect(js).toContain('data-ref');
220
+ });
221
+ it('returns scrolled info', () => {
222
+ const js = scrollToRefJs('1');
223
+ expect(js).toContain('scrolled: true');
224
+ expect(js).toContain('tag:');
225
+ });
226
+ });
227
+ describe('getFormStateJs', () => {
228
+ it('generates valid JS', () => {
229
+ const js = getFormStateJs();
230
+ expect(() => new Function(js)).not.toThrow();
231
+ });
232
+ it('collects form elements', () => {
233
+ const js = getFormStateJs();
234
+ expect(js).toContain('document.forms');
235
+ expect(js).toContain('form.elements');
236
+ });
237
+ it('collects orphan fields', () => {
238
+ const js = getFormStateJs();
239
+ expect(js).toContain('orphanFields');
240
+ expect(js).toContain('el.form');
241
+ });
242
+ it('handles different input types', () => {
243
+ const js = getFormStateJs();
244
+ expect(js).toContain('checkbox');
245
+ expect(js).toContain('radio');
246
+ expect(js).toContain('password');
247
+ expect(js).toContain('contenteditable');
248
+ });
249
+ it('extracts labels', () => {
250
+ const js = getFormStateJs();
251
+ expect(js).toContain('aria-label');
252
+ expect(js).toContain('label[for=');
253
+ expect(js).toContain('closest');
254
+ expect(js).toContain('placeholder');
255
+ });
256
+ it('masks passwords', () => {
257
+ const js = getFormStateJs();
258
+ expect(js).toContain('••••');
259
+ });
260
+ it('includes data-webcmd-ref in output', () => {
261
+ const js = getFormStateJs();
262
+ expect(js).toContain('data-webcmd-ref');
263
+ });
264
+ });
265
+ describe('Search Element Detection', () => {
266
+ it('includes SEARCH_INDICATORS set', () => {
267
+ const js = generateSnapshotJs();
268
+ expect(js).toContain('SEARCH_INDICATORS');
269
+ expect(js).toContain('search');
270
+ expect(js).toContain('magnify');
271
+ expect(js).toContain('glass');
272
+ });
273
+ it('includes hasFormControlDescendant function', () => {
274
+ const js = generateSnapshotJs();
275
+ expect(js).toContain('hasFormControlDescendant');
276
+ expect(js).toContain('input');
277
+ expect(js).toContain('select');
278
+ expect(js).toContain('textarea');
279
+ });
280
+ it('includes isSearchElement function', () => {
281
+ const js = generateSnapshotJs();
282
+ expect(js).toContain('isSearchElement');
283
+ expect(js).toContain('className');
284
+ expect(js).toContain('data-');
285
+ });
286
+ it('checks label wrapper detection in isInteractive', () => {
287
+ const js = generateSnapshotJs();
288
+ // Label elements without "for" attribute should check for form control descendants
289
+ expect(js).toContain('hasFormControlDescendant(el, 2)');
290
+ });
291
+ it('checks span wrapper detection in isInteractive', () => {
292
+ const js = generateSnapshotJs();
293
+ // Span elements should check for form control descendants
294
+ expect(js).toContain("tag === 'span'");
295
+ });
296
+ it('integrates search element detection into isInteractive', () => {
297
+ const js = generateSnapshotJs();
298
+ expect(js).toContain('isSearchElement(el)');
299
+ });
300
+ // Blocker B regression: compound contract must be emitted by `browser state`,
301
+ // not only by `browser find --css`. Otherwise agents inspecting the default
302
+ // snapshot still have to round-trip `find` on every date/select/file control.
303
+ it('inlines compoundInfoOf() and attaches compound info to each interactive ref', () => {
304
+ const js = generateSnapshotJs();
305
+ expect(js).toContain('function compoundInfoOf(el)');
306
+ // Wiring: the walk body should call compoundInfoOf on every interactive node
307
+ expect(js).toContain('compoundInfoOf(el)');
308
+ // And collect them into a per-ref map keyed by the same [N] index as the tree
309
+ expect(js).toContain('compoundInfos');
310
+ // And emit a sidecar section after the tree so agents can find the JSON
311
+ expect(js).toContain("'compounds ('");
312
+ });
313
+ });
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Browser connection error helpers.
3
+ *
4
+ * Simplified — no more token/runtime/CDP classification.
5
+ * The daemon architecture has a single failure mode: daemon not reachable or runtime not ready.
6
+ */
7
+ import { BrowserConnectError, type BrowserConnectKind } from '../errors.js';
8
+ /**
9
+ * Unified browser error classification.
10
+ *
11
+ * All transient error detection lives here — daemon-client, pipeline executor,
12
+ * and page retry logic all use this single system instead of maintaining
13
+ * separate pattern lists.
14
+ */
15
+ /** Error category — determines which layer should retry. */
16
+ export type BrowserErrorKind = 'extension-transient' | 'target-navigation' | 'non-retryable';
17
+ /** How the caller should handle the error. */
18
+ export interface RetryAdvice {
19
+ /** Error category — callers use this to decide whether *they* should retry. */
20
+ kind: BrowserErrorKind;
21
+ /** Whether the error is transient and worth retrying. */
22
+ retryable: boolean;
23
+ /** Suggested delay before retry (ms). */
24
+ delayMs: number;
25
+ }
26
+ /**
27
+ * Classify a browser error and return retry advice.
28
+ *
29
+ * Single source of truth for "is this error transient?" across all layers.
30
+ */
31
+ export declare function classifyBrowserError(err: unknown): RetryAdvice;
32
+ /**
33
+ * Check if an error is a transient browser error worth retrying.
34
+ * Convenience wrapper around classifyBrowserError().
35
+ */
36
+ export declare function isTransientBrowserError(err: unknown): boolean;
37
+ export type ConnectFailureKind = BrowserConnectKind;
38
+ export declare function formatBrowserConnectError(kind: ConnectFailureKind, detail?: string): BrowserConnectError;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Browser connection error helpers.
3
+ *
4
+ * Simplified — no more token/runtime/CDP classification.
5
+ * The daemon architecture has a single failure mode: daemon not reachable or runtime not ready.
6
+ */
7
+ import { BrowserConnectError } from '../errors.js';
8
+ import { DEFAULT_DAEMON_PORT } from '../constants.js';
9
+ /**
10
+ * Runtime/daemon transient patterns — service worker restarts, attach races,
11
+ * tab closure, daemon hiccups. These warrant a longer retry delay (~1500ms)
12
+ * because the runtime needs time to recover.
13
+ */
14
+ const EXTENSION_TRANSIENT_PATTERNS = [
15
+ 'Extension disconnected',
16
+ 'Extension not connected',
17
+ 'attach failed',
18
+ 'Detached while handling command',
19
+ 'Debugger is not attached to the tab',
20
+ 'no longer exists',
21
+ 'No tab with id',
22
+ 'CDP connection',
23
+ 'Daemon command failed',
24
+ 'No window with id',
25
+ ];
26
+ /**
27
+ * CDP target navigation patterns — SPA client-side redirects can invalidate the
28
+ * CDP target after chrome.tabs reports 'complete'. These warrant a shorter retry
29
+ * delay (~200ms) because the new document is usually available quickly.
30
+ */
31
+ const TARGET_NAVIGATION_PATTERNS = [
32
+ 'Inspected target navigated or closed',
33
+ ];
34
+ function errorMessage(err) {
35
+ return err instanceof Error ? err.message : String(err);
36
+ }
37
+ /**
38
+ * Classify a browser error and return retry advice.
39
+ *
40
+ * Single source of truth for "is this error transient?" across all layers.
41
+ */
42
+ export function classifyBrowserError(err) {
43
+ const msg = errorMessage(err);
44
+ // Runtime/daemon transient errors — longer recovery time
45
+ if (EXTENSION_TRANSIENT_PATTERNS.some(p => msg.includes(p))) {
46
+ return { kind: 'extension-transient', retryable: true, delayMs: 1500 };
47
+ }
48
+ // CDP target navigation errors — shorter recovery time
49
+ if (TARGET_NAVIGATION_PATTERNS.some(p => msg.includes(p))) {
50
+ return { kind: 'target-navigation', retryable: true, delayMs: 200 };
51
+ }
52
+ // CDP protocol error with target/context invalidation (e.g., -32000 "target closed" or
53
+ // -32000 "Cannot find default execution context" — both indicate the inspected target
54
+ // went away and a fresh attach should recover).
55
+ if (msg.includes('-32000') && /target|context/i.test(msg)) {
56
+ return { kind: 'target-navigation', retryable: true, delayMs: 200 };
57
+ }
58
+ return { kind: 'non-retryable', retryable: false, delayMs: 0 };
59
+ }
60
+ /**
61
+ * Check if an error is a transient browser error worth retrying.
62
+ * Convenience wrapper around classifyBrowserError().
63
+ */
64
+ export function isTransientBrowserError(err) {
65
+ return classifyBrowserError(err).retryable;
66
+ }
67
+ export function formatBrowserConnectError(kind, detail) {
68
+ switch (kind) {
69
+ case 'daemon-not-running':
70
+ return new BrowserConnectError('Cannot connect to webcmd daemon.' + (detail ? `\n\n${detail}` : ''), `Run \`webcmd doctor\` to diagnose, or \`webcmd daemon restart\` to force a fresh daemon. Default port is ${DEFAULT_DAEMON_PORT}.`, kind);
71
+ case 'runtime-not-ready':
72
+ case 'extension-not-connected':
73
+ return new BrowserConnectError('Browser runtime is not ready.' + (detail ? `\n\n${detail}` : ''), 'Run `webcmd daemon restart`. If this is the first browser-backed command, wait for CloakBrowser to finish installing its browser binary, then retry.', 'runtime-not-ready');
74
+ case 'command-failed':
75
+ return new BrowserConnectError(`Browser command failed: ${detail ?? 'unknown error'}`, undefined, kind);
76
+ default:
77
+ return new BrowserConnectError(detail ?? 'Failed to connect to browser', undefined, kind);
78
+ }
79
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,60 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { classifyBrowserError, isTransientBrowserError } from './errors.js';
3
+ describe('classifyBrowserError', () => {
4
+ it('classifies extension transient errors with 1500ms delay', () => {
5
+ for (const msg of [
6
+ 'Extension disconnected',
7
+ 'Extension not connected',
8
+ 'attach failed',
9
+ 'Detached while handling command',
10
+ 'Debugger is not attached to the tab: 123',
11
+ 'no longer exists',
12
+ 'No tab with id: 456',
13
+ 'CDP connection reset',
14
+ 'Daemon command failed',
15
+ 'No window with id: 123',
16
+ ]) {
17
+ const advice = classifyBrowserError(new Error(msg));
18
+ expect(advice.kind, `expected "${msg}" → extension-transient`).toBe('extension-transient');
19
+ expect(advice.retryable).toBe(true);
20
+ expect(advice.delayMs).toBe(1500);
21
+ }
22
+ });
23
+ it('classifies CDP target navigation errors with 200ms delay', () => {
24
+ const advice = classifyBrowserError(new Error('Inspected target navigated or closed'));
25
+ expect(advice.kind).toBe('target-navigation');
26
+ expect(advice.retryable).toBe(true);
27
+ expect(advice.delayMs).toBe(200);
28
+ });
29
+ it('classifies CDP -32000 target errors with 200ms delay', () => {
30
+ const advice = classifyBrowserError(new Error('{"code":-32000,"message":"Target closed"}'));
31
+ expect(advice.kind).toBe('target-navigation');
32
+ expect(advice.retryable).toBe(true);
33
+ expect(advice.delayMs).toBe(200);
34
+ });
35
+ it('classifies CDP -32000 execution-context errors with 200ms delay', () => {
36
+ const advice = classifyBrowserError(new Error('{"code":-32000,"message":"Cannot find default execution context"}'));
37
+ expect(advice.kind).toBe('target-navigation');
38
+ expect(advice.retryable).toBe(true);
39
+ expect(advice.delayMs).toBe(200);
40
+ });
41
+ it('returns non-retryable for unrelated errors', () => {
42
+ for (const msg of ['Permission denied', 'malformed exec payload', 'SyntaxError']) {
43
+ const advice = classifyBrowserError(new Error(msg));
44
+ expect(advice.kind).toBe('non-retryable');
45
+ expect(advice.retryable).toBe(false);
46
+ }
47
+ });
48
+ it('handles non-Error values', () => {
49
+ expect(classifyBrowserError('Extension disconnected').kind).toBe('extension-transient');
50
+ expect(classifyBrowserError(42).kind).toBe('non-retryable');
51
+ });
52
+ });
53
+ describe('isTransientBrowserError (convenience wrapper)', () => {
54
+ it('returns true for transient errors', () => {
55
+ expect(isTransientBrowserError(new Error('No window with id: 123'))).toBe(true);
56
+ });
57
+ it('returns false for non-transient errors', () => {
58
+ expect(isTransientBrowserError(new Error('Permission denied'))).toBe(false);
59
+ });
60
+ });
@@ -0,0 +1,69 @@
1
+ /**
2
+ * `browser extract` — agent-native article/content reading channel.
3
+ *
4
+ * Pipeline (from first principles — agents want the *content*, not the DOM):
5
+ * 1. Scope: select `--selector` (default: document.body or <main>/<article>)
6
+ * 2. Denoise: strip script/style/nav/header/footer/aside/iframe/svg/form, inline noise
7
+ * 3. Convert: HTML → Markdown via shared `htmlToMarkdown` (turndown)
8
+ * 4. Chunk: paragraph-boundary-aware slicing with `next_start_char` cursor
9
+ *
10
+ * Why a separate command:
11
+ * - `get html --as json` returns tree structure; useless for "read the article".
12
+ * - `get text` flattens everything; loses headings, lists, links.
13
+ * - Markdown is the agent-readable middle ground: structure preserved, noise gone.
14
+ *
15
+ * Continuation contract: the envelope always carries `start`, `end`,
16
+ * `total_chars`, and `next_start_char` (null when the last chunk was emitted).
17
+ * Agents pass `--start <next>` to continue. No session state required.
18
+ */
19
+ /**
20
+ * Returns the JS expression string used with `page.evaluate` to produce the
21
+ * cleaned HTML subtree that we then hand to `htmlToMarkdown`. We do the
22
+ * denoise/clone inside the page so we can use DOM APIs (querySelectorAll,
23
+ * cloneNode) rather than regex on serialized HTML.
24
+ */
25
+ export declare function buildExtractHtmlJs(selector: string | null): string;
26
+ export interface ExtractChunkOptions {
27
+ content: string;
28
+ start: number;
29
+ chunkSize: number;
30
+ }
31
+ export interface ExtractChunkResult {
32
+ content: string;
33
+ start: number;
34
+ end: number;
35
+ nextStartChar: number | null;
36
+ }
37
+ /**
38
+ * Slice `content` into one chunk starting at `start` with target size
39
+ * `chunkSize`. When the chunk would land mid-paragraph, we pull the break
40
+ * back to the nearest `\n\n` (or `\n`) within a small window to keep the
41
+ * output readable. If no boundary is found, we hard-cut at `start+chunkSize`.
42
+ */
43
+ export declare function chunkMarkdown(opts: ExtractChunkOptions): ExtractChunkResult;
44
+ export interface RunExtractOptions {
45
+ html: string;
46
+ url: string;
47
+ title: string;
48
+ selector: string | null;
49
+ start: number;
50
+ chunkSize: number;
51
+ }
52
+ export interface RunExtractResult {
53
+ url: string;
54
+ title: string;
55
+ selector: string | null;
56
+ total_chars: number;
57
+ chunk_size: number;
58
+ start: number;
59
+ end: number;
60
+ next_start_char: number | null;
61
+ content: string;
62
+ }
63
+ /** End-to-end host-side pipeline: HTML → markdown → chunked envelope. */
64
+ export declare function runExtractFromHtml(opts: RunExtractOptions): RunExtractResult;
65
+ export declare const __extractInternals: {
66
+ DEFAULT_CHUNK_SIZE: number;
67
+ MIN_CHUNK_SIZE: number;
68
+ MAX_CHUNK_SIZE: number;
69
+ };