@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,41 @@
1
+ /**
2
+ * Shared DOM operation JS generators.
3
+ *
4
+ * Used by both Page (daemon mode) and CDPPage (direct CDP mode)
5
+ * to eliminate code duplication for click, type, press, wait, scroll, etc.
6
+ */
7
+ /** Generate JS to click an element by ref.
8
+ * Returns { status, x, y, w, h } for CDP fallback when JS click fails. */
9
+ export declare function clickJs(ref: string): string;
10
+ /** Generate JS to type text into an element by ref.
11
+ * Uses native setter for React compat + execCommand for contenteditable. */
12
+ export declare function typeTextJs(ref: string, text: string): string;
13
+ /** Generate JS to press a keyboard key */
14
+ export declare function pressKeyJs(key: string, modifiers?: string[]): string;
15
+ /** Generate JS to wait for text to appear in the page */
16
+ export declare function waitForTextJs(text: string, timeoutMs: number): string;
17
+ /** Generate JS for scroll */
18
+ export declare function scrollJs(direction: string, amount: number): string;
19
+ /** Generate JS for auto-scroll with lazy-load detection */
20
+ export declare function autoScrollJs(times: number, delayMs: number): string;
21
+ /** Generate JS to read performance resource entries as network requests */
22
+ export declare function networkRequestsJs(includeStatic: boolean): string;
23
+ /**
24
+ * Generate JS to wait until the DOM stabilizes (no mutations for `quietMs`),
25
+ * with a hard cap at `maxMs`. Uses MutationObserver in the browser.
26
+ *
27
+ * Returns as soon as the page stops changing, avoiding unnecessary fixed waits.
28
+ * If document.body is not available, falls back to a fixed sleep of maxMs.
29
+ */
30
+ export declare function waitForDomStableJs(maxMs: number, quietMs: number): string;
31
+ /**
32
+ * Generate JS to wait until window.__webcmd_xhr has ≥1 captured response.
33
+ * Polls every 100ms. Resolves 'captured' on success; rejects after maxMs.
34
+ * Used after installInterceptor() + goto() instead of a fixed sleep.
35
+ */
36
+ export declare function waitForCaptureJs(maxMs: number): string;
37
+ /**
38
+ * Generate JS to wait until document.querySelector(selector) returns a match.
39
+ * Uses MutationObserver for near-instant resolution; falls back to reject after timeoutMs.
40
+ */
41
+ export declare function waitForSelectorJs(selector: string, timeoutMs: number): string;
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Shared DOM operation JS generators.
3
+ *
4
+ * Used by both Page (daemon mode) and CDPPage (direct CDP mode)
5
+ * to eliminate code duplication for click, type, press, wait, scroll, etc.
6
+ */
7
+ /** Shared element lookup JS fragment (4-strategy resolution) */
8
+ function resolveElementJs(safeRef, selectorSet) {
9
+ return `
10
+ const ref = ${safeRef};
11
+ let el = document.querySelector('[data-webcmd-ref="' + ref + '"]');
12
+ if (!el) el = document.querySelector('[data-ref="' + ref + '"]');
13
+ if (!el && ref.match(/^[a-zA-Z#.\\[]/)) {
14
+ try { el = document.querySelector(ref); } catch {}
15
+ }
16
+ if (!el) {
17
+ const idx = parseInt(ref, 10);
18
+ if (!isNaN(idx)) {
19
+ el = document.querySelectorAll('${selectorSet}')[idx];
20
+ }
21
+ }`;
22
+ }
23
+ /** Generate JS to click an element by ref.
24
+ * Returns { status, x, y, w, h } for CDP fallback when JS click fails. */
25
+ export function clickJs(ref) {
26
+ const safeRef = JSON.stringify(ref);
27
+ return `
28
+ (() => {
29
+ ${resolveElementJs(safeRef, 'a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])')}
30
+ if (!el) throw new Error('Element not found: ' + ref);
31
+ el.scrollIntoView({ behavior: 'instant', block: 'center' });
32
+ const rect = el.getBoundingClientRect();
33
+ const x = Math.round(rect.left + rect.width / 2);
34
+ const y = Math.round(rect.top + rect.height / 2);
35
+ try {
36
+ el.click();
37
+ return { status: 'clicked', x, y, w: Math.round(rect.width), h: Math.round(rect.height) };
38
+ } catch (e) {
39
+ return { status: 'js_failed', x, y, w: Math.round(rect.width), h: Math.round(rect.height), error: e.message };
40
+ }
41
+ })()
42
+ `;
43
+ }
44
+ /** Generate JS to type text into an element by ref.
45
+ * Uses native setter for React compat + execCommand for contenteditable. */
46
+ export function typeTextJs(ref, text) {
47
+ const safeRef = JSON.stringify(ref);
48
+ const safeText = JSON.stringify(text);
49
+ return `
50
+ (() => {
51
+ ${resolveElementJs(safeRef, 'input, textarea, [contenteditable="true"]')}
52
+ if (!el) throw new Error('Element not found: ' + ref);
53
+ el.focus();
54
+ if (el.isContentEditable) {
55
+ // Select all content + delete, then insert (supports undo, works with rich text editors)
56
+ const sel = window.getSelection();
57
+ const range = document.createRange();
58
+ range.selectNodeContents(el);
59
+ sel.removeAllRanges();
60
+ sel.addRange(range);
61
+ document.execCommand('delete', false);
62
+ document.execCommand('insertText', false, ${safeText});
63
+ el.dispatchEvent(new Event('input', { bubbles: true }));
64
+ } else {
65
+ // Use native setter for React/framework compatibility (match element type)
66
+ const proto = el instanceof HTMLTextAreaElement
67
+ ? HTMLTextAreaElement.prototype
68
+ : HTMLInputElement.prototype;
69
+ const nativeSetter = Object.getOwnPropertyDescriptor(proto, 'value')?.set;
70
+ if (nativeSetter) {
71
+ nativeSetter.call(el, ${safeText});
72
+ } else {
73
+ el.value = ${safeText};
74
+ }
75
+ el.dispatchEvent(new Event('input', { bubbles: true }));
76
+ el.dispatchEvent(new Event('change', { bubbles: true }));
77
+ }
78
+ return 'typed';
79
+ })()
80
+ `;
81
+ }
82
+ /** Generate JS to press a keyboard key */
83
+ export function pressKeyJs(key, modifiers = []) {
84
+ const hasCtrl = modifiers.includes('Ctrl') || modifiers.includes('Control');
85
+ const hasAlt = modifiers.includes('Alt');
86
+ const hasMeta = modifiers.includes('Meta');
87
+ const hasShift = modifiers.includes('Shift');
88
+ return `
89
+ (() => {
90
+ const el = document.activeElement || document.body;
91
+ const init = {
92
+ key: ${JSON.stringify(key)},
93
+ bubbles: true,
94
+ ctrlKey: ${hasCtrl},
95
+ altKey: ${hasAlt},
96
+ metaKey: ${hasMeta},
97
+ shiftKey: ${hasShift},
98
+ };
99
+ el.dispatchEvent(new KeyboardEvent('keydown', init));
100
+ el.dispatchEvent(new KeyboardEvent('keyup', init));
101
+ return 'pressed';
102
+ })()
103
+ `;
104
+ }
105
+ /** Generate JS to wait for text to appear in the page */
106
+ export function waitForTextJs(text, timeoutMs) {
107
+ return `
108
+ new Promise((resolve, reject) => {
109
+ const deadline = Date.now() + ${timeoutMs};
110
+ const check = () => {
111
+ if (document.body.innerText.includes(${JSON.stringify(text)})) return resolve('found');
112
+ if (Date.now() > deadline) return reject(new Error('Text not found: ' + ${JSON.stringify(text)}));
113
+ setTimeout(check, 200);
114
+ };
115
+ check();
116
+ })
117
+ `;
118
+ }
119
+ /** Generate JS for scroll */
120
+ export function scrollJs(direction, amount) {
121
+ const dx = direction === 'left' ? -amount : direction === 'right' ? amount : 0;
122
+ const dy = direction === 'up' ? -amount : direction === 'down' ? amount : 0;
123
+ return `window.scrollBy(${dx}, ${dy})`;
124
+ }
125
+ /** Generate JS for auto-scroll with lazy-load detection */
126
+ export function autoScrollJs(times, delayMs) {
127
+ return `
128
+ (async () => {
129
+ if (!document.body) return;
130
+ for (let i = 0; i < ${times}; i++) {
131
+ const lastHeight = document.body.scrollHeight;
132
+ window.scrollTo(0, lastHeight);
133
+ await new Promise(resolve => {
134
+ let timeoutId;
135
+ const observer = new MutationObserver(() => {
136
+ if (document.body.scrollHeight > lastHeight) {
137
+ clearTimeout(timeoutId);
138
+ observer.disconnect();
139
+ setTimeout(resolve, 100);
140
+ }
141
+ });
142
+ observer.observe(document.body, { childList: true, subtree: true });
143
+ timeoutId = setTimeout(() => { observer.disconnect(); resolve(null); }, ${delayMs});
144
+ });
145
+ }
146
+ })()
147
+ `;
148
+ }
149
+ /** Generate JS to read performance resource entries as network requests */
150
+ export function networkRequestsJs(includeStatic) {
151
+ return `
152
+ (() => {
153
+ const entries = performance.getEntriesByType('resource');
154
+ return entries
155
+ ${includeStatic ? '' : '.filter(e => !["img", "font", "css", "script"].some(t => e.initiatorType === t))'}
156
+ .map(e => ({
157
+ url: e.name,
158
+ type: e.initiatorType,
159
+ duration: Math.round(e.duration),
160
+ size: e.transferSize || 0,
161
+ }));
162
+ })()
163
+ `;
164
+ }
165
+ /**
166
+ * Generate JS to wait until the DOM stabilizes (no mutations for `quietMs`),
167
+ * with a hard cap at `maxMs`. Uses MutationObserver in the browser.
168
+ *
169
+ * Returns as soon as the page stops changing, avoiding unnecessary fixed waits.
170
+ * If document.body is not available, falls back to a fixed sleep of maxMs.
171
+ */
172
+ export function waitForDomStableJs(maxMs, quietMs) {
173
+ return `
174
+ new Promise(resolve => {
175
+ if (!document.body) {
176
+ setTimeout(() => resolve('nobody'), ${maxMs});
177
+ return;
178
+ }
179
+ let timer = null;
180
+ let cap = null;
181
+ const done = (reason) => {
182
+ clearTimeout(timer);
183
+ clearTimeout(cap);
184
+ obs.disconnect();
185
+ resolve(reason);
186
+ };
187
+ const resetQuiet = () => {
188
+ clearTimeout(timer);
189
+ timer = setTimeout(() => done('quiet'), ${quietMs});
190
+ };
191
+ const obs = new MutationObserver(resetQuiet);
192
+ obs.observe(document.body, { childList: true, subtree: true, attributes: true });
193
+ resetQuiet();
194
+ cap = setTimeout(() => done('capped'), ${maxMs});
195
+ })
196
+ `;
197
+ }
198
+ /**
199
+ * Generate JS to wait until window.__webcmd_xhr has ≥1 captured response.
200
+ * Polls every 100ms. Resolves 'captured' on success; rejects after maxMs.
201
+ * Used after installInterceptor() + goto() instead of a fixed sleep.
202
+ */
203
+ export function waitForCaptureJs(maxMs) {
204
+ return `
205
+ new Promise((resolve, reject) => {
206
+ const deadline = Date.now() + ${maxMs};
207
+ const check = () => {
208
+ if ((window.__webcmd_xhr || []).length > 0) return resolve('captured');
209
+ if (Date.now() > deadline) return reject(new Error('No network capture within ${maxMs / 1000}s'));
210
+ setTimeout(check, 100);
211
+ };
212
+ check();
213
+ })
214
+ `;
215
+ }
216
+ /**
217
+ * Generate JS to wait until document.querySelector(selector) returns a match.
218
+ * Uses MutationObserver for near-instant resolution; falls back to reject after timeoutMs.
219
+ */
220
+ export function waitForSelectorJs(selector, timeoutMs) {
221
+ return `
222
+ new Promise((resolve, reject) => {
223
+ const sel = ${JSON.stringify(selector)};
224
+ if (document.querySelector(sel)) return resolve('found');
225
+ const cap = setTimeout(() => {
226
+ obs.disconnect();
227
+ reject(new Error('Selector not found: ' + sel));
228
+ }, ${timeoutMs});
229
+ const obs = new MutationObserver(() => {
230
+ if (document.querySelector(sel)) {
231
+ clearTimeout(cap);
232
+ obs.disconnect();
233
+ resolve('found');
234
+ }
235
+ });
236
+ obs.observe(document.body || document.documentElement, { childList: true, subtree: true });
237
+ })
238
+ `;
239
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,106 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { autoScrollJs, waitForCaptureJs, waitForSelectorJs } from './dom-helpers.js';
3
+ describe('autoScrollJs', () => {
4
+ it('returns early without error when document.body is null', async () => {
5
+ const g = globalThis;
6
+ const origDoc = g.document;
7
+ g.document = { body: null, documentElement: {} };
8
+ g.window = g;
9
+ const code = autoScrollJs(3, 500);
10
+ // Should resolve without throwing
11
+ await expect(eval(code)).resolves.not.toThrow();
12
+ g.document = origDoc;
13
+ delete g.window;
14
+ });
15
+ });
16
+ describe('waitForCaptureJs', () => {
17
+ it('returns a non-empty string', () => {
18
+ const code = waitForCaptureJs(1000);
19
+ expect(typeof code).toBe('string');
20
+ expect(code.length).toBeGreaterThan(0);
21
+ expect(code).toContain('__webcmd_xhr');
22
+ expect(code).toContain('resolve');
23
+ expect(code).toContain('reject');
24
+ });
25
+ it('resolves "captured" when __webcmd_xhr is populated before deadline', async () => {
26
+ const g = globalThis;
27
+ const captured = [];
28
+ g.__webcmd_xhr = captured;
29
+ g.window = g; // stub window for Node eval
30
+ const code = waitForCaptureJs(1000);
31
+ const promise = eval(code);
32
+ captured.push({ data: 'test' });
33
+ await expect(promise).resolves.toBe('captured');
34
+ delete g.__webcmd_xhr;
35
+ delete g.window;
36
+ });
37
+ it('rejects when __webcmd_xhr stays empty past deadline', async () => {
38
+ const g = globalThis;
39
+ g.__webcmd_xhr = [];
40
+ g.window = g;
41
+ const code = waitForCaptureJs(50); // 50ms timeout
42
+ const promise = eval(code);
43
+ await expect(promise).rejects.toThrow('No network capture within 0.05s');
44
+ delete g.__webcmd_xhr;
45
+ delete g.window;
46
+ });
47
+ it('resolves immediately when __webcmd_xhr already has data', async () => {
48
+ const g = globalThis;
49
+ g.__webcmd_xhr = [{ data: 'already here' }];
50
+ g.window = g;
51
+ const code = waitForCaptureJs(1000);
52
+ await expect(eval(code)).resolves.toBe('captured');
53
+ delete g.__webcmd_xhr;
54
+ delete g.window;
55
+ });
56
+ });
57
+ describe('waitForSelectorJs', () => {
58
+ it('returns a non-empty string', () => {
59
+ const code = waitForSelectorJs('#app', 1000);
60
+ expect(typeof code).toBe('string');
61
+ expect(code).toContain('#app');
62
+ expect(code).toContain('querySelector');
63
+ expect(code).toContain('MutationObserver');
64
+ });
65
+ it('resolves "found" immediately when selector already present', async () => {
66
+ const g = globalThis;
67
+ const fakeEl = { tagName: 'DIV' };
68
+ g.document = { querySelector: (_) => fakeEl };
69
+ const code = waitForSelectorJs('[data-testid="primaryColumn"]', 1000);
70
+ await expect(eval(code)).resolves.toBe('found');
71
+ delete g.document;
72
+ });
73
+ it('resolves "found" when selector appears after DOM mutation', async () => {
74
+ const g = globalThis;
75
+ let mutationCallback;
76
+ g.MutationObserver = class {
77
+ constructor(cb) { mutationCallback = cb; }
78
+ observe() { }
79
+ disconnect() { }
80
+ };
81
+ let calls = 0;
82
+ g.document = {
83
+ querySelector: (_) => (calls++ > 0 ? { tagName: 'DIV' } : null),
84
+ body: {},
85
+ };
86
+ const code = waitForSelectorJs('#app', 1000);
87
+ const promise = eval(code);
88
+ mutationCallback(); // simulate DOM mutation
89
+ await expect(promise).resolves.toBe('found');
90
+ delete g.document;
91
+ delete g.MutationObserver;
92
+ });
93
+ it('rejects when selector never appears within timeout', async () => {
94
+ const g = globalThis;
95
+ g.MutationObserver = class {
96
+ constructor(_cb) { }
97
+ observe() { }
98
+ disconnect() { }
99
+ };
100
+ g.document = { querySelector: (_) => null, body: {} };
101
+ const code = waitForSelectorJs('#missing', 50);
102
+ await expect(eval(code)).rejects.toThrow('Selector not found: #missing');
103
+ delete g.document;
104
+ delete g.MutationObserver;
105
+ });
106
+ });
@@ -0,0 +1,93 @@
1
+ /**
2
+ * DOM Snapshot Engine — Advanced DOM pruning for LLM consumption.
3
+ *
4
+ * Inspired by browser-use's multi-layer pruning pipeline, adapted for webcmd's
5
+ * Chrome Extension + CDP architecture. Runs entirely in-page via Runtime.evaluate.
6
+ *
7
+ * Pipeline:
8
+ * 1. Walk DOM tree, collect visibility + layout + interactivity signals
9
+ * 2. Prune invisible, zero-area, non-content elements
10
+ * 3. SVG & decoration collapse
11
+ * 4. Shadow DOM traversal
12
+ * 5. Same-origin iframe content extraction
13
+ * 6. Bounding-box parent-child dedup (link/button wrapping children)
14
+ * 7. Paint-order occlusion detection (overlay/modal coverage)
15
+ * 8. Attribute whitelist filtering
16
+ * 9. Table-aware serialization (markdown tables)
17
+ * 10. Token-efficient serialization with interactive indices
18
+ * 11. data-ref annotation for click/type targeting
19
+ * 12. Hidden interactive element hints (scroll-to-reveal)
20
+ * 13. Incremental diff (mark new elements with *)
21
+ *
22
+ * Additional tools:
23
+ * - scrollToRefJs(ref) — scroll to a data-webcmd-ref element
24
+ * - getFormStateJs() — extract all form fields as structured JSON
25
+ *
26
+ * Compound sidecar:
27
+ * After the tree, a `compounds:` section lists rich JSON for every
28
+ * date/select/file ref — format, full option list (up to cap) with
29
+ * `options_total` reflecting the true count, file `accept` + `multiple`.
30
+ * This is what the snapshot's inline attr dump cannot express and what
31
+ * agents kept blowing turns on.
32
+ */
33
+ export interface DomSnapshotOptions {
34
+ /** Extra pixels beyond viewport to include (default 800) */
35
+ viewportExpand?: number;
36
+ /** Maximum DOM depth to traverse (default 50) */
37
+ maxDepth?: number;
38
+ /** Only emit interactive elements and their landmark ancestors */
39
+ interactiveOnly?: boolean;
40
+ /** Maximum text content length per node (default 120) */
41
+ maxTextLength?: number;
42
+ /** Include scroll position info on scrollable containers (default true) */
43
+ includeScrollInfo?: boolean;
44
+ /** Enable bounding-box parent-child dedup (default true) */
45
+ bboxDedup?: boolean;
46
+ /** Traverse Shadow DOM roots (default true) */
47
+ includeShadowDom?: boolean;
48
+ /** Extract same-origin iframe content (default true) */
49
+ includeIframes?: boolean;
50
+ /** Maximum number of iframes to process (default 5) */
51
+ maxIframes?: number;
52
+ /** Enable paint-order occlusion detection (default true) */
53
+ paintOrderCheck?: boolean;
54
+ /** Annotate interactive elements with data-webcmd-ref (default true) */
55
+ annotateRefs?: boolean;
56
+ /** Report hidden interactive elements outside viewport (default true) */
57
+ reportHidden?: boolean;
58
+ /** Filter ad/noise elements (default true) */
59
+ filterAds?: boolean;
60
+ /** Serialize tables as markdown (default true) */
61
+ markdownTables?: boolean;
62
+ /** Previous snapshot hash set (JSON array of hashes) for diff marking (default null) */
63
+ previousHashes?: string | null;
64
+ }
65
+ /**
66
+ * Generate JS to scroll to an element identified by data-webcmd-ref.
67
+ * Completes the snapshot→action loop: snapshot identifies `[3]<button>`,
68
+ * caller can then `scrollToRef('3')` to bring it into view.
69
+ */
70
+ export declare function scrollToRefJs(ref: string): string;
71
+ /**
72
+ * Generate JS to extract all form field values from the page.
73
+ * Returns structured JSON: { forms: [{ id, action, fields: [{ tag, type, name, value, ... }] }] }
74
+ */
75
+ export declare function getFormStateJs(): string;
76
+ /**
77
+ * Generate JavaScript code that, when evaluated in a page context via CDP
78
+ * Runtime.evaluate, returns a pruned DOM snapshot string optimised for LLMs.
79
+ *
80
+ * The snapshot output format:
81
+ * [42]<button type=submit>Search</button>
82
+ * |scroll|<div> (0.5↑ 3.2↓)
83
+ * *[58]<a href=/r/1>Result 1</a>
84
+ * [59]<a href=/r/2>Result 2</a>
85
+ *
86
+ * - `[id]` — interactive element with backend index for targeting
87
+ * - `*` prefix — newly appeared element (incremental diff)
88
+ * - `|scroll|` — scrollable container with page counts
89
+ * - `|shadow|` — Shadow DOM boundary
90
+ * - `|iframe|` — iframe content
91
+ * - `|table|` — markdown table rendering
92
+ */
93
+ export declare function generateSnapshotJs(opts?: DomSnapshotOptions): string;