browxai 0.7.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 (520) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +139 -0
  3. package/THIRD_PARTY_NOTICES.md +45 -0
  4. package/dist/cli/chrome.d.ts +1 -0
  5. package/dist/cli/chrome.js +130 -0
  6. package/dist/cli/command-registry.d.ts +15 -0
  7. package/dist/cli/command-registry.js +35 -0
  8. package/dist/cli/doctor-plugins.d.ts +18 -0
  9. package/dist/cli/doctor-plugins.js +338 -0
  10. package/dist/cli/doctor.d.ts +9 -0
  11. package/dist/cli/doctor.js +407 -0
  12. package/dist/cli/init.d.ts +1 -0
  13. package/dist/cli/init.js +200 -0
  14. package/dist/cli/register-commands.d.ts +1 -0
  15. package/dist/cli/register-commands.js +22 -0
  16. package/dist/cli/serve.d.ts +14 -0
  17. package/dist/cli/serve.js +151 -0
  18. package/dist/cli.d.ts +3 -0
  19. package/dist/cli.js +129 -0
  20. package/dist/engine/adapters/adb.d.ts +72 -0
  21. package/dist/engine/adapters/adb.js +200 -0
  22. package/dist/engine/adapters/android-cdp.d.ts +54 -0
  23. package/dist/engine/adapters/android-cdp.js +110 -0
  24. package/dist/engine/adapters/android.engine.d.ts +1 -0
  25. package/dist/engine/adapters/android.engine.js +31 -0
  26. package/dist/engine/adapters/chromium.engine.d.ts +1 -0
  27. package/dist/engine/adapters/chromium.engine.js +44 -0
  28. package/dist/engine/adapters/firefox.engine.d.ts +1 -0
  29. package/dist/engine/adapters/firefox.engine.js +43 -0
  30. package/dist/engine/adapters/playwright-chromium.d.ts +43 -0
  31. package/dist/engine/adapters/playwright-chromium.js +56 -0
  32. package/dist/engine/adapters/playwright-firefox.d.ts +52 -0
  33. package/dist/engine/adapters/playwright-firefox.js +97 -0
  34. package/dist/engine/adapters/playwright-webkit.d.ts +40 -0
  35. package/dist/engine/adapters/playwright-webkit.js +79 -0
  36. package/dist/engine/adapters/safari/bidi-client.d.ts +46 -0
  37. package/dist/engine/adapters/safari/bidi-client.js +130 -0
  38. package/dist/engine/adapters/safari/launch.d.ts +56 -0
  39. package/dist/engine/adapters/safari/launch.js +104 -0
  40. package/dist/engine/adapters/safari/webdriver-client.d.ts +102 -0
  41. package/dist/engine/adapters/safari/webdriver-client.js +175 -0
  42. package/dist/engine/adapters/safari.engine.d.ts +1 -0
  43. package/dist/engine/adapters/safari.engine.js +52 -0
  44. package/dist/engine/adapters/safaridriver-hybrid.d.ts +56 -0
  45. package/dist/engine/adapters/safaridriver-hybrid.js +127 -0
  46. package/dist/engine/adapters/webkit.engine.d.ts +1 -0
  47. package/dist/engine/adapters/webkit.engine.js +47 -0
  48. package/dist/engine/capabilities.d.ts +53 -0
  49. package/dist/engine/capabilities.js +122 -0
  50. package/dist/engine/capability-registry.d.ts +9 -0
  51. package/dist/engine/capability-registry.js +20 -0
  52. package/dist/engine/index.d.ts +18 -0
  53. package/dist/engine/index.js +14 -0
  54. package/dist/engine/register-engines.d.ts +5 -0
  55. package/dist/engine/register-engines.js +16 -0
  56. package/dist/engine/registry.d.ts +145 -0
  57. package/dist/engine/registry.js +67 -0
  58. package/dist/engine/select.d.ts +48 -0
  59. package/dist/engine/select.js +128 -0
  60. package/dist/engine/session-cdp.d.ts +13 -0
  61. package/dist/engine/session-cdp.js +22 -0
  62. package/dist/engine/tool-gate.d.ts +19 -0
  63. package/dist/engine/tool-gate.js +226 -0
  64. package/dist/engine/types.d.ts +71 -0
  65. package/dist/engine/types.js +16 -0
  66. package/dist/helper/bridge.d.ts +48 -0
  67. package/dist/helper/bridge.js +200 -0
  68. package/dist/helper/browx-page.d.ts +1 -0
  69. package/dist/helper/browx-page.js +47 -0
  70. package/dist/helper/overlay-hide.d.ts +9 -0
  71. package/dist/helper/overlay-hide.js +49 -0
  72. package/dist/helper/stealth.d.ts +10 -0
  73. package/dist/helper/stealth.js +88 -0
  74. package/dist/index.d.ts +7 -0
  75. package/dist/index.js +15 -0
  76. package/dist/page/a11y.d.ts +81 -0
  77. package/dist/page/a11y.js +219 -0
  78. package/dist/page/action-substrate.d.ts +64 -0
  79. package/dist/page/action-substrate.js +118 -0
  80. package/dist/page/actionresult-blocks.d.ts +99 -0
  81. package/dist/page/actionresult-blocks.js +144 -0
  82. package/dist/page/actionresult-shape.d.ts +48 -0
  83. package/dist/page/actionresult-shape.js +155 -0
  84. package/dist/page/actionresult-types.d.ts +368 -0
  85. package/dist/page/actionresult-types.js +4 -0
  86. package/dist/page/actionresult.d.ts +4 -0
  87. package/dist/page/actionresult.js +299 -0
  88. package/dist/page/actions-probe.d.ts +32 -0
  89. package/dist/page/actions-probe.js +294 -0
  90. package/dist/page/actions-scroll.d.ts +40 -0
  91. package/dist/page/actions-scroll.js +53 -0
  92. package/dist/page/actions.d.ts +132 -0
  93. package/dist/page/actions.js +453 -0
  94. package/dist/page/archive-assets.d.ts +39 -0
  95. package/dist/page/archive-assets.js +187 -0
  96. package/dist/page/archive.d.ts +47 -0
  97. package/dist/page/archive.js +349 -0
  98. package/dist/page/asset-export.d.ts +122 -0
  99. package/dist/page/asset-export.js +376 -0
  100. package/dist/page/await_network.d.ts +16 -0
  101. package/dist/page/await_network.js +23 -0
  102. package/dist/page/bbox.d.ts +37 -0
  103. package/dist/page/bbox.js +115 -0
  104. package/dist/page/canvas-capture.d.ts +82 -0
  105. package/dist/page/canvas-capture.js +257 -0
  106. package/dist/page/canvas-diff.d.ts +51 -0
  107. package/dist/page/canvas-diff.js +131 -0
  108. package/dist/page/canvas-gesture.d.ts +53 -0
  109. package/dist/page/canvas-gesture.js +167 -0
  110. package/dist/page/canvas-transform.d.ts +96 -0
  111. package/dist/page/canvas-transform.js +150 -0
  112. package/dist/page/canvas.d.ts +8 -0
  113. package/dist/page/canvas.js +50 -0
  114. package/dist/page/capture-substrate.d.ts +111 -0
  115. package/dist/page/capture-substrate.js +139 -0
  116. package/dist/page/clipboard.d.ts +25 -0
  117. package/dist/page/clipboard.js +50 -0
  118. package/dist/page/clock.d.ts +36 -0
  119. package/dist/page/clock.js +167 -0
  120. package/dist/page/compose.d.ts +55 -0
  121. package/dist/page/compose.js +169 -0
  122. package/dist/page/console.d.ts +39 -0
  123. package/dist/page/console.js +73 -0
  124. package/dist/page/coverage.d.ts +97 -0
  125. package/dist/page/coverage.js +280 -0
  126. package/dist/page/dom-export.d.ts +41 -0
  127. package/dist/page/dom-export.js +193 -0
  128. package/dist/page/dom-walk.d.ts +91 -0
  129. package/dist/page/dom-walk.js +267 -0
  130. package/dist/page/dom_diff.d.ts +48 -0
  131. package/dist/page/dom_diff.js +121 -0
  132. package/dist/page/downloads.d.ts +80 -0
  133. package/dist/page/downloads.js +244 -0
  134. package/dist/page/drop-files.d.ts +78 -0
  135. package/dist/page/drop-files.js +310 -0
  136. package/dist/page/element-export-discovery.d.ts +64 -0
  137. package/dist/page/element-export-discovery.js +346 -0
  138. package/dist/page/element-export.d.ts +46 -0
  139. package/dist/page/element-export.js +251 -0
  140. package/dist/page/emulation-substrate.d.ts +53 -0
  141. package/dist/page/emulation-substrate.js +87 -0
  142. package/dist/page/emulation.d.ts +60 -0
  143. package/dist/page/emulation.js +162 -0
  144. package/dist/page/export-playwright-script.d.ts +47 -0
  145. package/dist/page/export-playwright-script.js +304 -0
  146. package/dist/page/extract-resolve.d.ts +22 -0
  147. package/dist/page/extract-resolve.js +341 -0
  148. package/dist/page/extract-schema.d.ts +20 -0
  149. package/dist/page/extract-schema.js +200 -0
  150. package/dist/page/extract-types.d.ts +127 -0
  151. package/dist/page/extract-types.js +8 -0
  152. package/dist/page/extract-warnings.d.ts +8 -0
  153. package/dist/page/extract-warnings.js +56 -0
  154. package/dist/page/extract.d.ts +9 -0
  155. package/dist/page/extract.js +174 -0
  156. package/dist/page/fill-form.d.ts +58 -0
  157. package/dist/page/fill-form.js +261 -0
  158. package/dist/page/find.d.ts +158 -0
  159. package/dist/page/find.js +470 -0
  160. package/dist/page/frames.d.ts +45 -0
  161. package/dist/page/frames.js +133 -0
  162. package/dist/page/generate-locator.d.ts +57 -0
  163. package/dist/page/generate-locator.js +136 -0
  164. package/dist/page/gestures.d.ts +128 -0
  165. package/dist/page/gestures.js +198 -0
  166. package/dist/page/har.d.ts +91 -0
  167. package/dist/page/har.js +174 -0
  168. package/dist/page/heap.d.ts +97 -0
  169. package/dist/page/heap.js +285 -0
  170. package/dist/page/inspect.d.ts +34 -0
  171. package/dist/page/inspect.js +75 -0
  172. package/dist/page/layout-thrash.d.ts +34 -0
  173. package/dist/page/layout-thrash.js +232 -0
  174. package/dist/page/learning.d.ts +21 -0
  175. package/dist/page/learning.js +84 -0
  176. package/dist/page/locator.d.ts +54 -0
  177. package/dist/page/locator.js +142 -0
  178. package/dist/page/memory-diff.d.ts +48 -0
  179. package/dist/page/memory-diff.js +105 -0
  180. package/dist/page/network-mask.d.ts +8 -0
  181. package/dist/page/network-mask.js +18 -0
  182. package/dist/page/network-playwright.d.ts +96 -0
  183. package/dist/page/network-playwright.js +353 -0
  184. package/dist/page/network-substrate-select.d.ts +18 -0
  185. package/dist/page/network-substrate-select.js +32 -0
  186. package/dist/page/network-substrate.d.ts +109 -0
  187. package/dist/page/network-substrate.js +161 -0
  188. package/dist/page/network-ws.d.ts +46 -0
  189. package/dist/page/network-ws.js +113 -0
  190. package/dist/page/network.d.ts +194 -0
  191. package/dist/page/network.js +415 -0
  192. package/dist/page/overflow-detect.d.ts +102 -0
  193. package/dist/page/overflow-detect.js +449 -0
  194. package/dist/page/pdf.d.ts +69 -0
  195. package/dist/page/pdf.js +109 -0
  196. package/dist/page/perf-audit-analysers.d.ts +40 -0
  197. package/dist/page/perf-audit-analysers.js +369 -0
  198. package/dist/page/perf-audit-runner.d.ts +20 -0
  199. package/dist/page/perf-audit-runner.js +195 -0
  200. package/dist/page/perf-audit-types.d.ts +41 -0
  201. package/dist/page/perf-audit-types.js +5 -0
  202. package/dist/page/perf-audit.d.ts +37 -0
  203. package/dist/page/perf-audit.js +377 -0
  204. package/dist/page/perf.d.ts +127 -0
  205. package/dist/page/perf.js +373 -0
  206. package/dist/page/plan.d.ts +192 -0
  207. package/dist/page/plan.js +308 -0
  208. package/dist/page/point_probe.d.ts +46 -0
  209. package/dist/page/point_probe.js +99 -0
  210. package/dist/page/recording.d.ts +67 -0
  211. package/dist/page/recording.js +172 -0
  212. package/dist/page/refs.d.ts +92 -0
  213. package/dist/page/refs.js +134 -0
  214. package/dist/page/regions.d.ts +23 -0
  215. package/dist/page/regions.js +32 -0
  216. package/dist/page/routes.d.ts +40 -0
  217. package/dist/page/routes.js +87 -0
  218. package/dist/page/safari-actions.d.ts +12 -0
  219. package/dist/page/safari-actions.js +144 -0
  220. package/dist/page/sample.d.ts +64 -0
  221. package/dist/page/sample.js +216 -0
  222. package/dist/page/screenshot-on.d.ts +51 -0
  223. package/dist/page/screenshot-on.js +150 -0
  224. package/dist/page/screenshot-save.d.ts +36 -0
  225. package/dist/page/screenshot-save.js +53 -0
  226. package/dist/page/screenshot-schedule.d.ts +50 -0
  227. package/dist/page/screenshot-schedule.js +155 -0
  228. package/dist/page/script-substrate.d.ts +32 -0
  229. package/dist/page/script-substrate.js +47 -0
  230. package/dist/page/seed-random.d.ts +45 -0
  231. package/dist/page/seed-random.js +144 -0
  232. package/dist/page/set-of-marks.d.ts +96 -0
  233. package/dist/page/set-of-marks.js +245 -0
  234. package/dist/page/shadow.d.ts +136 -0
  235. package/dist/page/shadow.js +400 -0
  236. package/dist/page/shortcut.d.ts +50 -0
  237. package/dist/page/shortcut.js +147 -0
  238. package/dist/page/snapshot-substrate-safari.d.ts +30 -0
  239. package/dist/page/snapshot-substrate-safari.js +84 -0
  240. package/dist/page/snapshot-substrate-select.d.ts +24 -0
  241. package/dist/page/snapshot-substrate-select.js +34 -0
  242. package/dist/page/snapshot-substrate.d.ts +58 -0
  243. package/dist/page/snapshot-substrate.js +135 -0
  244. package/dist/page/snapshot.d.ts +24 -0
  245. package/dist/page/snapshot.js +162 -0
  246. package/dist/page/solve-captcha.d.ts +76 -0
  247. package/dist/page/solve-captcha.js +286 -0
  248. package/dist/page/storage-substrate-types.d.ts +221 -0
  249. package/dist/page/storage-substrate-types.js +6 -0
  250. package/dist/page/storage-substrate.d.ts +215 -0
  251. package/dist/page/storage-substrate.js +280 -0
  252. package/dist/page/structural.d.ts +9 -0
  253. package/dist/page/structural.js +152 -0
  254. package/dist/page/substrate-bundle-safari.d.ts +8 -0
  255. package/dist/page/substrate-bundle-safari.js +42 -0
  256. package/dist/page/substrate-bundle.d.ts +6 -0
  257. package/dist/page/substrate-bundle.js +53 -0
  258. package/dist/page/text_search.d.ts +44 -0
  259. package/dist/page/text_search.js +90 -0
  260. package/dist/page/upload.d.ts +28 -0
  261. package/dist/page/upload.js +62 -0
  262. package/dist/page/verify.d.ts +63 -0
  263. package/dist/page/verify.js +451 -0
  264. package/dist/page/video.d.ts +115 -0
  265. package/dist/page/video.js +169 -0
  266. package/dist/page/visibility.d.ts +22 -0
  267. package/dist/page/visibility.js +94 -0
  268. package/dist/page/watch.d.ts +29 -0
  269. package/dist/page/watch.js +99 -0
  270. package/dist/page/workers.d.ts +126 -0
  271. package/dist/page/workers.js +490 -0
  272. package/dist/page/ws-interactive.d.ts +82 -0
  273. package/dist/page/ws-interactive.js +318 -0
  274. package/dist/plugin/cli.d.ts +45 -0
  275. package/dist/plugin/cli.js +496 -0
  276. package/dist/plugin/command-registry.d.ts +9 -0
  277. package/dist/plugin/command-registry.js +23 -0
  278. package/dist/plugin/depgraph.d.ts +37 -0
  279. package/dist/plugin/depgraph.js +186 -0
  280. package/dist/plugin/manifest.d.ts +182 -0
  281. package/dist/plugin/manifest.js +219 -0
  282. package/dist/plugin/package-manager.d.ts +22 -0
  283. package/dist/plugin/package-manager.js +40 -0
  284. package/dist/plugin/resolver.d.ts +85 -0
  285. package/dist/plugin/resolver.js +166 -0
  286. package/dist/plugin/runtime.d.ts +77 -0
  287. package/dist/plugin/runtime.js +402 -0
  288. package/dist/plugin/types.d.ts +113 -0
  289. package/dist/plugin/types.js +4 -0
  290. package/dist/policy/confirm.d.ts +76 -0
  291. package/dist/policy/confirm.js +162 -0
  292. package/dist/policy/origin.d.ts +17 -0
  293. package/dist/policy/origin.js +79 -0
  294. package/dist/sdk/client.d.ts +21 -0
  295. package/dist/sdk/client.js +174 -0
  296. package/dist/sdk/index.d.ts +32 -0
  297. package/dist/sdk/index.js +61 -0
  298. package/dist/sdk/plugin-types.d.ts +33 -0
  299. package/dist/sdk/plugin-types.js +22 -0
  300. package/dist/sdk/registry.d.ts +17 -0
  301. package/dist/sdk/registry.js +94 -0
  302. package/dist/sdk/socket-transport.d.ts +20 -0
  303. package/dist/sdk/socket-transport.js +90 -0
  304. package/dist/sdk/tool-types.d.ts +634 -0
  305. package/dist/sdk/tool-types.js +28 -0
  306. package/dist/sdk/transport-in-process.d.ts +21 -0
  307. package/dist/sdk/transport-in-process.js +44 -0
  308. package/dist/sdk/transport-registry.d.ts +19 -0
  309. package/dist/sdk/transport-registry.js +31 -0
  310. package/dist/sdk/transport-socket.d.ts +12 -0
  311. package/dist/sdk/transport-socket.js +77 -0
  312. package/dist/sdk/transport-stdio-child.d.ts +10 -0
  313. package/dist/sdk/transport-stdio-child.js +47 -0
  314. package/dist/sdk/transport.d.ts +10 -0
  315. package/dist/sdk/transport.js +35 -0
  316. package/dist/sdk/types.d.ts +176 -0
  317. package/dist/sdk/types.js +10 -0
  318. package/dist/server.d.ts +33 -0
  319. package/dist/server.js +327 -0
  320. package/dist/session/artifacts.d.ts +52 -0
  321. package/dist/session/artifacts.js +177 -0
  322. package/dist/session/byob-attach.d.ts +26 -0
  323. package/dist/session/byob-attach.js +187 -0
  324. package/dist/session/byob.d.ts +8 -0
  325. package/dist/session/byob.js +20 -0
  326. package/dist/session/cache-storage.d.ts +100 -0
  327. package/dist/session/cache-storage.js +166 -0
  328. package/dist/session/device-emu.d.ts +149 -0
  329. package/dist/session/device-emu.js +545 -0
  330. package/dist/session/device.d.ts +14 -0
  331. package/dist/session/device.js +44 -0
  332. package/dist/session/dialog.d.ts +62 -0
  333. package/dist/session/dialog.js +164 -0
  334. package/dist/session/emulation.d.ts +69 -0
  335. package/dist/session/emulation.js +168 -0
  336. package/dist/session/extensions.d.ts +113 -0
  337. package/dist/session/extensions.js +237 -0
  338. package/dist/session/fs-picker.d.ts +144 -0
  339. package/dist/session/fs-picker.js +666 -0
  340. package/dist/session/idb-storage.d.ts +86 -0
  341. package/dist/session/idb-storage.js +229 -0
  342. package/dist/session/incognito.d.ts +3 -0
  343. package/dist/session/incognito.js +20 -0
  344. package/dist/session/launch-options.d.ts +41 -0
  345. package/dist/session/launch-options.js +200 -0
  346. package/dist/session/managed.d.ts +3 -0
  347. package/dist/session/managed.js +16 -0
  348. package/dist/session/metrics.d.ts +45 -0
  349. package/dist/session/metrics.js +75 -0
  350. package/dist/session/notification.d.ts +122 -0
  351. package/dist/session/notification.js +426 -0
  352. package/dist/session/permission.d.ts +144 -0
  353. package/dist/session/permission.js +600 -0
  354. package/dist/session/playwright-post-wire.d.ts +8 -0
  355. package/dist/session/playwright-post-wire.js +148 -0
  356. package/dist/session/policy-buffer.d.ts +21 -0
  357. package/dist/session/policy-buffer.js +47 -0
  358. package/dist/session/profile-snapshot.d.ts +11 -0
  359. package/dist/session/profile-snapshot.js +53 -0
  360. package/dist/session/registry.d.ts +365 -0
  361. package/dist/session/registry.js +98 -0
  362. package/dist/session/safari-post-wire.d.ts +8 -0
  363. package/dist/session/safari-post-wire.js +28 -0
  364. package/dist/session/safari-session.d.ts +10 -0
  365. package/dist/session/safari-session.js +39 -0
  366. package/dist/session/storage.d.ts +148 -0
  367. package/dist/session/storage.js +350 -0
  368. package/dist/session/types.d.ts +113 -0
  369. package/dist/session/types.js +5 -0
  370. package/dist/session/wedge.d.ts +15 -0
  371. package/dist/session/wedge.js +41 -0
  372. package/dist/tools/action-core-tools.d.ts +13 -0
  373. package/dist/tools/action-core-tools.js +156 -0
  374. package/dist/tools/action-form-tools.d.ts +12 -0
  375. package/dist/tools/action-form-tools.js +179 -0
  376. package/dist/tools/action-gesture-tools.d.ts +9 -0
  377. package/dist/tools/action-gesture-tools.js +115 -0
  378. package/dist/tools/action-history-tools.d.ts +8 -0
  379. package/dist/tools/action-history-tools.js +67 -0
  380. package/dist/tools/action-tool.d.ts +42 -0
  381. package/dist/tools/action-tool.js +58 -0
  382. package/dist/tools/action-tools.d.ts +20 -0
  383. package/dist/tools/action-tools.js +28 -0
  384. package/dist/tools/batch-act-tools.d.ts +10 -0
  385. package/dist/tools/batch-act-tools.js +276 -0
  386. package/dist/tools/batch-human-tools.d.ts +8 -0
  387. package/dist/tools/batch-human-tools.js +148 -0
  388. package/dist/tools/canvas-tools.d.ts +40 -0
  389. package/dist/tools/canvas-tools.js +368 -0
  390. package/dist/tools/capture-report-diagnostics-tools.d.ts +7 -0
  391. package/dist/tools/capture-report-diagnostics-tools.js +318 -0
  392. package/dist/tools/capture-report-element-export-tools.d.ts +8 -0
  393. package/dist/tools/capture-report-element-export-tools.js +197 -0
  394. package/dist/tools/capture-report-export-tools.d.ts +8 -0
  395. package/dist/tools/capture-report-export-tools.js +246 -0
  396. package/dist/tools/capture-report-marks-tools.d.ts +9 -0
  397. package/dist/tools/capture-report-marks-tools.js +221 -0
  398. package/dist/tools/capture-report-upload-tools.d.ts +8 -0
  399. package/dist/tools/capture-report-upload-tools.js +277 -0
  400. package/dist/tools/config-approval-tools.d.ts +8 -0
  401. package/dist/tools/config-approval-tools.js +166 -0
  402. package/dist/tools/deep-coverage-tools.d.ts +8 -0
  403. package/dist/tools/deep-coverage-tools.js +325 -0
  404. package/dist/tools/deep-determinism-tools.d.ts +8 -0
  405. package/dist/tools/deep-determinism-tools.js +276 -0
  406. package/dist/tools/deep-perf-tools.d.ts +19 -0
  407. package/dist/tools/deep-perf-tools.js +324 -0
  408. package/dist/tools/device-emulation-tools.d.ts +9 -0
  409. package/dist/tools/device-emulation-tools.js +137 -0
  410. package/dist/tools/extensions-batch-tools.d.ts +18 -0
  411. package/dist/tools/extensions-batch-tools.js +24 -0
  412. package/dist/tools/extensions-rebuild.d.ts +22 -0
  413. package/dist/tools/extensions-rebuild.js +208 -0
  414. package/dist/tools/extensions-tools.d.ts +2 -0
  415. package/dist/tools/extensions-tools.js +331 -0
  416. package/dist/tools/forms-fill-tools.d.ts +8 -0
  417. package/dist/tools/forms-fill-tools.js +109 -0
  418. package/dist/tools/forms-plan-tools.d.ts +7 -0
  419. package/dist/tools/forms-plan-tools.js +159 -0
  420. package/dist/tools/forms-recording-mode-tools.d.ts +8 -0
  421. package/dist/tools/forms-recording-mode-tools.js +71 -0
  422. package/dist/tools/forms-recording-tools.d.ts +14 -0
  423. package/dist/tools/forms-recording-tools.js +22 -0
  424. package/dist/tools/forms-refs-tools.d.ts +8 -0
  425. package/dist/tools/forms-refs-tools.js +90 -0
  426. package/dist/tools/gesture-coord-tools.d.ts +8 -0
  427. package/dist/tools/gesture-coord-tools.js +168 -0
  428. package/dist/tools/gesture-emulation-tools.d.ts +8 -0
  429. package/dist/tools/gesture-emulation-tools.js +135 -0
  430. package/dist/tools/gesture-network-tools.d.ts +17 -0
  431. package/dist/tools/gesture-network-tools.js +27 -0
  432. package/dist/tools/gesture-route-tools.d.ts +8 -0
  433. package/dist/tools/gesture-route-tools.js +142 -0
  434. package/dist/tools/gesture-websocket-tools.d.ts +8 -0
  435. package/dist/tools/gesture-websocket-tools.js +122 -0
  436. package/dist/tools/gesture-worker-tools.d.ts +9 -0
  437. package/dist/tools/gesture-worker-tools.js +200 -0
  438. package/dist/tools/host-build.d.ts +76 -0
  439. package/dist/tools/host-build.js +516 -0
  440. package/dist/tools/host.d.ts +287 -0
  441. package/dist/tools/host.js +1 -0
  442. package/dist/tools/input-tools.d.ts +10 -0
  443. package/dist/tools/input-tools.js +176 -0
  444. package/dist/tools/live-emulation-tools.d.ts +9 -0
  445. package/dist/tools/live-emulation-tools.js +353 -0
  446. package/dist/tools/plugin-runtime.d.ts +36 -0
  447. package/dist/tools/plugin-runtime.js +274 -0
  448. package/dist/tools/read-observe-buffer-tools.d.ts +9 -0
  449. package/dist/tools/read-observe-buffer-tools.js +385 -0
  450. package/dist/tools/read-observe-capture-tools.d.ts +12 -0
  451. package/dist/tools/read-observe-capture-tools.js +376 -0
  452. package/dist/tools/read-observe-dom-tools.d.ts +8 -0
  453. package/dist/tools/read-observe-dom-tools.js +308 -0
  454. package/dist/tools/read-observe-extract-tools.d.ts +8 -0
  455. package/dist/tools/read-observe-extract-tools.js +232 -0
  456. package/dist/tools/read-observe-verify-tools.d.ts +8 -0
  457. package/dist/tools/read-observe-verify-tools.js +316 -0
  458. package/dist/tools/schemas.d.ts +29 -0
  459. package/dist/tools/schemas.js +58 -0
  460. package/dist/tools/secrets-captcha-tools.d.ts +9 -0
  461. package/dist/tools/secrets-captcha-tools.js +231 -0
  462. package/dist/tools/session-dialog-permission-tools.d.ts +9 -0
  463. package/dist/tools/session-dialog-permission-tools.js +287 -0
  464. package/dist/tools/session-lifecycle-tools.d.ts +8 -0
  465. package/dist/tools/session-lifecycle-tools.js +314 -0
  466. package/dist/tools/session-notification-device-tools.d.ts +9 -0
  467. package/dist/tools/session-notification-device-tools.js +156 -0
  468. package/dist/tools/session-policy-tools.d.ts +16 -0
  469. package/dist/tools/session-policy-tools.js +22 -0
  470. package/dist/tools/session-registry.d.ts +28 -0
  471. package/dist/tools/session-registry.js +427 -0
  472. package/dist/tools/storage-artifact-har-video-tools.d.ts +8 -0
  473. package/dist/tools/storage-artifact-har-video-tools.js +311 -0
  474. package/dist/tools/storage-cache-idb-tools.d.ts +8 -0
  475. package/dist/tools/storage-cache-idb-tools.js +347 -0
  476. package/dist/tools/storage-state-cookies-tools.d.ts +8 -0
  477. package/dist/tools/storage-state-cookies-tools.js +223 -0
  478. package/dist/tools/storage-tools.d.ts +17 -0
  479. package/dist/tools/storage-tools.js +25 -0
  480. package/dist/tools/storage-web-auth-tools.d.ts +10 -0
  481. package/dist/tools/storage-web-auth-tools.js +230 -0
  482. package/dist/tools/tool-metadata.d.ts +8 -0
  483. package/dist/tools/tool-metadata.js +185 -0
  484. package/dist/util/batch.d.ts +83 -0
  485. package/dist/util/batch.js +191 -0
  486. package/dist/util/capabilities.d.ts +504 -0
  487. package/dist/util/capabilities.js +254 -0
  488. package/dist/util/config-store.d.ts +103 -0
  489. package/dist/util/config-store.js +206 -0
  490. package/dist/util/config.d.ts +11 -0
  491. package/dist/util/config.js +28 -0
  492. package/dist/util/credentials.d.ts +136 -0
  493. package/dist/util/credentials.js +622 -0
  494. package/dist/util/deadline.d.ts +22 -0
  495. package/dist/util/deadline.js +62 -0
  496. package/dist/util/diagnostics.d.ts +161 -0
  497. package/dist/util/diagnostics.js +579 -0
  498. package/dist/util/egress-sanitiser.d.ts +29 -0
  499. package/dist/util/egress-sanitiser.js +52 -0
  500. package/dist/util/failure.d.ts +8 -0
  501. package/dist/util/failure.js +50 -0
  502. package/dist/util/flake-check.d.ts +109 -0
  503. package/dist/util/flake-check.js +342 -0
  504. package/dist/util/invariant.d.ts +25 -0
  505. package/dist/util/invariant.js +66 -0
  506. package/dist/util/logging.d.ts +6 -0
  507. package/dist/util/logging.js +12 -0
  508. package/dist/util/predicates.d.ts +62 -0
  509. package/dist/util/predicates.js +340 -0
  510. package/dist/util/secrets.d.ts +104 -0
  511. package/dist/util/secrets.js +219 -0
  512. package/dist/util/tokens.d.ts +6 -0
  513. package/dist/util/tokens.js +24 -0
  514. package/dist/util/url-sanitizer.d.ts +19 -0
  515. package/dist/util/url-sanitizer.js +70 -0
  516. package/dist/util/version.d.ts +2 -0
  517. package/dist/util/version.js +21 -0
  518. package/dist/util/workspace.d.ts +7 -0
  519. package/dist/util/workspace.js +22 -0
  520. package/package.json +120 -0
@@ -0,0 +1,415 @@
1
+ // CDP network tap for an "action window" — open before dispatch, close after
2
+ // network-idle-ish quiet. Filters out the high-noise/low-signal resource types by
3
+ // default (images, fonts, stylesheets, media, beacons); they're still counted in
4
+ // the summary's `byType.other` bucket if you want the totals back.
5
+ import { invariant } from "../util/invariant.js";
6
+ import { patternisePath } from "../util/url-sanitizer.js";
7
+ import { maskedUrl } from "./network-mask.js";
8
+ export const MUTATION_METHODS = new Set(["POST", "PUT", "PATCH", "DELETE"]);
9
+ const MAX_RESPONSE_SHAPE_KEYS = 20;
10
+ export const MAX_BODY_BYTES_TO_PARSE = 256_000; // skip parsing huge bodies; ~256KB JSON ceiling
11
+ const NOISE_TYPES = new Set(["Image", "Font", "Stylesheet", "Media", "Manifest"]);
12
+ const BEACON_HINTS = ["beacon", "/collect", "analytics", "gtag", "doubleclick", "pixel"];
13
+ function isBeacon(url) {
14
+ const lower = url.toLowerCase();
15
+ return BEACON_HINTS.some((h) => lower.includes(h));
16
+ }
17
+ /** Map Playwright's `request.resourceType()` (lowercase, a slightly coarser
18
+ * taxonomy) onto the CDP-capitalised type names the CDP tap emits, so the
19
+ * noise-fold (`NOISE_TYPES`) + `byType` summary buckets are identical in shape
20
+ * across engines. The resourceType nuance to be aware of: a few
21
+ * CDP types (`Ping`, `CSPViolationReport`, `Preflight`, …) have no Playwright
22
+ * equivalent and fold into `Other`; `xhr`/`fetch` both map to their CDP forms.
23
+ * This is the only place engine resourceType skew is reconciled. */
24
+ const PW_RESOURCE_TYPE = {
25
+ document: "Document",
26
+ stylesheet: "Stylesheet",
27
+ image: "Image",
28
+ media: "Media",
29
+ font: "Font",
30
+ script: "Script",
31
+ texttrack: "TextTrack",
32
+ xhr: "XHR",
33
+ fetch: "Fetch",
34
+ eventsource: "EventSource",
35
+ websocket: "WebSocket",
36
+ manifest: "Manifest",
37
+ other: "Other",
38
+ };
39
+ /** Exported for unit tests of the cross-engine resourceType reconciliation. */
40
+ export function cdpTypeFromPlaywright(resourceType) {
41
+ return PW_RESOURCE_TYPE[resourceType] ?? "Other";
42
+ }
43
+ /** Fold a finished-entry list into the `{summary, requests}` the network_read /
44
+ * action-tap egress emits: noise/beacon entries collapse into `summary.byType
45
+ * .other` (and stay out of `requests`), failures count toward `summary.failed`,
46
+ * and the surviving "interesting" entries have their URL masked at egress. This
47
+ * is the EXACT logic the CDP `NetworkTap.close()` / `NetworkBuffer.recent()`
48
+ * loops run inline; extracted so the Playwright-event buffers/tap produce a
49
+ * byte-identical shape without duplicating the rule. */
50
+ export function foldInteresting(entries, secrets) {
51
+ const summary = { total: entries.length, byType: {}, failed: 0 };
52
+ const interesting = [];
53
+ for (const e of entries) {
54
+ let bucket = e.type;
55
+ if (NOISE_TYPES.has(e.type) || isBeacon(e.url))
56
+ bucket = "other";
57
+ summary.byType[bucket] = (summary.byType[bucket] ?? 0) + 1;
58
+ if (e.failed)
59
+ summary.failed += 1;
60
+ if (bucket !== "other")
61
+ interesting.push({ ...e, url: maskedUrl(e.url, secrets) });
62
+ }
63
+ return { summary, requests: interesting };
64
+ }
65
+ export class NetworkTap {
66
+ cdp;
67
+ secrets;
68
+ requests = new Map();
69
+ finished = [];
70
+ mutationPromises = [];
71
+ listeners = [];
72
+ enabled = false;
73
+ /** Optional per-session secrets registry. When non-null, every URL +
74
+ * response-shape key that leaves through `close()` is run through the
75
+ * egress masking layer in addition to the URL sanitiser. */
76
+ constructor(cdp, secrets = null) {
77
+ this.cdp = cdp;
78
+ this.secrets = secrets;
79
+ }
80
+ async open() {
81
+ if (!this.enabled) {
82
+ await this.cdp.send("Network.enable");
83
+ this.enabled = true;
84
+ }
85
+ this.requests.clear();
86
+ this.finished = [];
87
+ this.mutationPromises = [];
88
+ const onRequest = (e) => {
89
+ this.requests.set(e.requestId, {
90
+ method: e.request.method,
91
+ url: e.request.url,
92
+ type: e.type ?? "Other",
93
+ startedAt: Date.now(),
94
+ });
95
+ };
96
+ const onResponse = (e) => {
97
+ const r = this.requests.get(e.requestId);
98
+ if (!r)
99
+ return;
100
+ const ms = Date.now() - r.startedAt;
101
+ this.finished.push({
102
+ method: r.method,
103
+ url: r.url,
104
+ status: e.response.status,
105
+ type: r.type,
106
+ ms,
107
+ });
108
+ // write-shaped + 2xx → kick off a bounded body probe for `mutations`.
109
+ // Captured request fields are snapshotted into the closure since the entry
110
+ // gets deleted below.
111
+ if (MUTATION_METHODS.has(r.method) && e.response.status >= 200 && e.response.status < 300) {
112
+ this.mutationPromises.push(probeMutation(this.cdp, e.requestId, {
113
+ method: r.method,
114
+ url: r.url,
115
+ status: e.response.status,
116
+ durationMs: ms,
117
+ }));
118
+ }
119
+ this.requests.delete(e.requestId);
120
+ };
121
+ const onFailed = (e) => {
122
+ const r = this.requests.get(e.requestId);
123
+ if (!r)
124
+ return;
125
+ this.finished.push({
126
+ method: r.method,
127
+ url: r.url,
128
+ type: r.type,
129
+ failed: true,
130
+ ms: Date.now() - r.startedAt,
131
+ });
132
+ this.requests.delete(e.requestId);
133
+ };
134
+ this.cdp.on("Network.requestWillBeSent", onRequest);
135
+ this.cdp.on("Network.responseReceived", onResponse);
136
+ this.cdp.on("Network.loadingFailed", onFailed);
137
+ this.listeners = [
138
+ () => this.cdp.off("Network.requestWillBeSent", onRequest),
139
+ () => this.cdp.off("Network.responseReceived", onResponse),
140
+ () => this.cdp.off("Network.loadingFailed", onFailed),
141
+ ];
142
+ }
143
+ /**
144
+ * Stop listening and produce a `{ summary, requests, mutations }` snapshot of
145
+ * the window. `requests` only includes the "interesting" entries (non-noise,
146
+ * non-beacon). Noise still counts toward `summary.byType.other`. `mutations`
147
+ * is awaited from the response-body probes kicked off during the window.
148
+ */
149
+ async close() {
150
+ for (const off of this.listeners)
151
+ off();
152
+ this.listeners = [];
153
+ // The summary/interesting fold is the shared `foldInteresting` rule (RFC 0004
154
+ // P3 / D4) — noise/beacon entries collapse into `summary.byType.other` and stay
155
+ // out of `requests`, failures count toward `summary.failed`, and surviving
156
+ // entries are URL-masked at egress. The ring keeps the raw url so beacon
157
+ // detection / url-substring filtering still see the real value; masking
158
+ // composes with the URL sanitiser (regex on URL shape vs literal value scan).
159
+ const { summary, requests: interesting } = foldInteresting(this.finished, this.secrets);
160
+ const mutationsRaw = (await Promise.all(this.mutationPromises)).filter((m) => m !== null);
161
+ // mask mutation URLs + responseShape keys at egress. A response-key name
162
+ // (`sessionToken`, `apiSecret`) typically won't literally equal a
163
+ // registered value, but the key list is still string data — applying the
164
+ // egress layer here keeps the rule "every egress sink masks" absolute.
165
+ const mutations = mutationsRaw.map((m) => {
166
+ const out = {
167
+ ...m,
168
+ urlPattern: this.secrets ? this.secrets.applyMaskInText(m.urlPattern) : m.urlPattern,
169
+ };
170
+ if (m.responseShape && this.secrets) {
171
+ out.responseShape = m.responseShape.map((k) => this.secrets.applyMaskInText(k));
172
+ }
173
+ return out;
174
+ });
175
+ return { summary, requests: interesting, mutations };
176
+ }
177
+ }
178
+ export { sanitizeFrame, WsBuffer } from "./network-ws.js";
179
+ /**
180
+ * fetch a response body by CDP request id. Gated behind the off-by-
181
+ * default `network-body` capability — full bodies can carry PII / tokens.
182
+ * Bounded (`maxBytes`, default 256 KB). Best-effort: the renderer discards
183
+ * bodies fairly quickly, so this can legitimately fail with "not available".
184
+ */
185
+ export async function fetchResponseBody(cdp, requestId, maxBytes = 256_000, secrets = null) {
186
+ try {
187
+ const { body, base64Encoded } = await cdp.send("Network.getResponseBody", { requestId });
188
+ const sliced = body.length > maxBytes ? body.slice(0, maxBytes) : body;
189
+ const truncated = body.length > maxBytes;
190
+ // egress masking. Base64 bodies pass through unchanged — the literal
191
+ // real-value scan would never match an encoded form, and the agent's
192
+ // contract for base64 is "decode then re-mask on your side." Document
193
+ // this caveat in docs/tool-reference.md.
194
+ const out = !base64Encoded && secrets ? secrets.applyMaskInText(sliced) : sliced;
195
+ return { ok: true, body: out, base64Encoded, ...(truncated ? { truncated: true } : {}) };
196
+ }
197
+ catch (e) {
198
+ return {
199
+ ok: false,
200
+ error: (e instanceof Error ? e.message : String(e)) +
201
+ " — response bodies are short-lived; fetch right after the request, and note bodies aren't retained across navigations.",
202
+ };
203
+ }
204
+ }
205
+ async function probeMutation(cdp, requestId, detail) {
206
+ try {
207
+ const { body, base64Encoded } = await cdp.send("Network.getResponseBody", { requestId });
208
+ if (base64Encoded)
209
+ return mutationWithoutShape(detail);
210
+ if (body.length > MAX_BODY_BYTES_TO_PARSE)
211
+ return mutationWithoutShape(detail);
212
+ const trimmed = body.trim();
213
+ if (!trimmed)
214
+ return mutationWithoutShape(detail);
215
+ if (trimmed[0] !== "{" && trimmed[0] !== "[")
216
+ return mutationWithoutShape(detail);
217
+ const parsed = JSON.parse(trimmed);
218
+ return mutationWithShape(detail, extractTopLevelKeys(parsed));
219
+ }
220
+ catch {
221
+ // Body unavailable (already discarded), CDP error, or JSON parse failure.
222
+ // Skip the entry — we'd rather omit than emit something misleading.
223
+ return null;
224
+ }
225
+ }
226
+ export function mutationWithoutShape(detail) {
227
+ return {
228
+ method: detail.method,
229
+ urlPattern: patterniseUrl(detail.url),
230
+ status: detail.status,
231
+ ok: true,
232
+ durationMs: detail.durationMs,
233
+ };
234
+ }
235
+ /** Build a mutation entry, attaching the response shape only when non-empty —
236
+ * the success path shared by the CDP and Playwright probes. */
237
+ export function mutationWithShape(detail, responseShape) {
238
+ const entry = mutationWithoutShape(detail);
239
+ if (responseShape && responseShape.length > 0)
240
+ entry.responseShape = responseShape;
241
+ return entry;
242
+ }
243
+ /**
244
+ * Strip the query string and replace id-shaped path segments with `:id`. Keeps
245
+ * the route stable across requests for the same logical endpoint without
246
+ * leaking the specific record id in the result.
247
+ *
248
+ * Exported for unit tests.
249
+ */
250
+ export function patterniseUrl(url) {
251
+ let u;
252
+ try {
253
+ u = new URL(url);
254
+ }
255
+ catch {
256
+ return url;
257
+ }
258
+ return `${u.origin}${patternisePath(u.pathname)}`;
259
+ }
260
+ /**
261
+ * Extract the top-level keys of a parsed JSON body. For an object, returns
262
+ * `Object.keys()`. For an array of objects, returns the first element's keys
263
+ * (prefixed with `[].` to signal array shape). Returns null otherwise.
264
+ *
265
+ * Capped at MAX_RESPONSE_SHAPE_KEYS entries. Exported for unit tests.
266
+ */
267
+ export function extractTopLevelKeys(parsed) {
268
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
269
+ return Object.keys(parsed).slice(0, MAX_RESPONSE_SHAPE_KEYS);
270
+ }
271
+ if (Array.isArray(parsed) &&
272
+ parsed.length > 0 &&
273
+ parsed[0] &&
274
+ typeof parsed[0] === "object" &&
275
+ !Array.isArray(parsed[0])) {
276
+ return Object.keys(parsed[0])
277
+ .slice(0, MAX_RESPONSE_SHAPE_KEYS)
278
+ .map((k) => `[].${k}`);
279
+ }
280
+ return null;
281
+ }
282
+ /**
283
+ * Session-wide ring buffer of network requests. Same shape as NetworkTap but
284
+ * always-on for the lifetime of the session — exposed via the `network_read`
285
+ * MCP tool. Per-action attribution still lives in `ActionResult.network`;
286
+ * this is the "what happened recently across the session" surface.
287
+ */
288
+ export class NetworkBuffer {
289
+ cdp;
290
+ cap;
291
+ requests = new Map();
292
+ ring = [];
293
+ /** requestId → entry pointer for the entries currently in `ring`. Lets
294
+ * `Network.loadingFinished` stamp `bytes` onto the corresponding entry
295
+ * without a linear scan. Pruned in `push` when an entry is evicted. */
296
+ byReqId = new Map();
297
+ enabled = false;
298
+ secrets = null;
299
+ constructor(
300
+ // CDP is the network-tap substrate today; a later change will port it onto
301
+ // Playwright's request/response events so non-CDP engines are supported.
302
+ // On an engine without CDP (Firefox) the buffer
303
+ // is constructed but never attaches — `recent`/`since` reads return empty
304
+ // until the substrate port lands, rather than throwing at session creation.
305
+ cdp, cap = 500) {
306
+ this.cdp = cdp;
307
+ this.cap = cap;
308
+ // L7/L8: the ring cap is the bound that keeps the buffer from growing without
309
+ // limit (the audit's bounded-resource inventory pins it at 500). A
310
+ // non-positive cap would break `push`'s eviction (the ring could never retain
311
+ // an entry, or `shift()` would underflow), so the bound MUST be positive. The
312
+ // default is 500 and the only caller passes nothing, so this holds; the
313
+ // invariant makes the bound's positivity an asserted contract, not an
314
+ // assumption.
315
+ invariant(this.cap > 0, `NetworkBuffer ring cap must be positive, got ${this.cap}`);
316
+ }
317
+ setSecrets(secrets) {
318
+ this.secrets = secrets;
319
+ }
320
+ async attach() {
321
+ if (this.enabled || !this.cdp)
322
+ return;
323
+ await this.cdp.send("Network.enable");
324
+ this.enabled = true;
325
+ this.cdp.on("Network.requestWillBeSent", (e) => {
326
+ this.requests.set(e.requestId, {
327
+ method: e.request.method,
328
+ url: e.request.url,
329
+ type: e.type ?? "Other",
330
+ startedAt: Date.now(),
331
+ });
332
+ });
333
+ this.cdp.on("Network.responseReceived", (e) => {
334
+ const r = this.requests.get(e.requestId);
335
+ if (!r)
336
+ return;
337
+ const entry = {
338
+ method: r.method,
339
+ url: r.url,
340
+ status: e.response.status,
341
+ type: r.type,
342
+ ms: Date.now() - r.startedAt,
343
+ requestId: e.requestId,
344
+ };
345
+ if (e.response.mimeType)
346
+ entry.mimeType = e.response.mimeType;
347
+ this.push(entry);
348
+ // Index the just-pushed entry by requestId so a subsequent
349
+ // `Network.loadingFinished` can stamp the encoded byte size on it
350
+ // without a linear scan. Cleared on eviction (see `push`).
351
+ this.byReqId.set(e.requestId, entry);
352
+ this.requests.delete(e.requestId);
353
+ });
354
+ this.cdp.on("Network.loadingFinished", (e) => {
355
+ const entry = this.byReqId.get(e.requestId);
356
+ if (!entry)
357
+ return;
358
+ if (typeof e.encodedDataLength === "number" && e.encodedDataLength >= 0) {
359
+ entry.bytes = e.encodedDataLength;
360
+ }
361
+ });
362
+ this.cdp.on("Network.loadingFailed", (e) => {
363
+ const r = this.requests.get(e.requestId);
364
+ if (!r)
365
+ return;
366
+ this.push({
367
+ method: r.method,
368
+ url: r.url,
369
+ type: r.type,
370
+ failed: true,
371
+ ms: Date.now() - r.startedAt,
372
+ requestId: e.requestId,
373
+ });
374
+ this.requests.delete(e.requestId);
375
+ });
376
+ }
377
+ push(entry) {
378
+ this.ring.push(entry);
379
+ if (this.ring.length > this.cap) {
380
+ const evicted = this.ring.shift();
381
+ if (evicted?.requestId)
382
+ this.byReqId.delete(evicted.requestId);
383
+ }
384
+ // L7: the ring is bounded — one push evicts at most one entry, so the length
385
+ // is `<= cap` after every push. This is the bounded-buffer property the
386
+ // network surface depends on; asserting it post-eviction makes "the ring
387
+ // never exceeds its cap" a tested invariant rather than a comment.
388
+ invariant(this.ring.length <= this.cap, `NetworkBuffer ring exceeded cap (${this.ring.length} > ${this.cap})`);
389
+ }
390
+ /** Raw, read-only snapshot of the ring — every entry, no noise/beacon
391
+ * folding, no egress masking. The masked / bucketed shape used by the
392
+ * `network_read` tool stays unchanged (see `recent`). This view is for
393
+ * consumers that need the full set as captured (e.g. `asset_export`
394
+ * iterating to pick image/font/media responses out of the ring). */
395
+ iter() {
396
+ return this.ring;
397
+ }
398
+ /** Most-recent N entries; noise + beacons are folded into the `other` bucket of the summary. */
399
+ recent(limit = 50) {
400
+ // Routed through the shared `foldInteresting` rule (RFC 0004 P3 / D4) — the
401
+ // CDP `NetworkBuffer.recent()` now produces the byte-identical shape the
402
+ // Playwright buffer already did, instead of a fourth inlined copy of the fold.
403
+ return foldInteresting(this.ring.slice(-limit), this.secrets);
404
+ }
405
+ }
406
+ // ===========================================================================
407
+ // Off-Chromium (Playwright-events) network/WebSocket capture lives in a sibling
408
+ // module (`network-playwright.ts`) to keep this file under the size budget.
409
+ //
410
+ // RFC 0004 P4 / D10 — these classes are NOT re-exported through this barrel: a
411
+ // runtime re-export here (and `network-playwright.ts` importing runtime helpers
412
+ // back from here) formed a genuine import cycle that the no-circular rule flags
413
+ // at `error`. The sole runtime consumer (`network-substrate.ts`) now imports
414
+ // them DIRECTLY from `./network-playwright.js`, so the only surviving edge is
415
+ // `network-playwright.ts` → `network.ts` — one-directional, no cycle.
@@ -0,0 +1,102 @@
1
+ export type OverflowType = "layout" | "clipped" | "text-ellipsis" | "viewport-horizontal";
2
+ export type OverflowScope = "viewport" | "document";
3
+ export interface OverflowDetectArgs {
4
+ /** Scope of the scan. `"document"` (default) walks every element; `"viewport"`
5
+ * skips elements whose bounding rect is fully outside the current viewport. */
6
+ scope?: OverflowScope;
7
+ /** Overflow shapes to surface. Default = all four. Empty array also
8
+ * treated as "all" (an empty filter is a usage error, not a no-op). */
9
+ types?: OverflowType[];
10
+ /** Cap on findings returned. Default 50, max 500. Findings past the cap
11
+ * are dropped (oldest-discovered are kept) and `truncated:true` is set. */
12
+ limit?: number;
13
+ }
14
+ export interface OverflowBbox {
15
+ x: number;
16
+ y: number;
17
+ w: number;
18
+ h: number;
19
+ }
20
+ export type OverflowEvidence = {
21
+ scrollWidth: number;
22
+ clientWidth: number;
23
+ scrollHeight: number;
24
+ clientHeight: number;
25
+ overflowX: string;
26
+ overflowY: string;
27
+ } | {
28
+ scrollWidth: number;
29
+ clientWidth: number;
30
+ visibleText: string;
31
+ fullText: string;
32
+ } | {
33
+ documentScrollWidth: number;
34
+ viewportWidth: number;
35
+ overrunPx: number;
36
+ widestDescendantSelector?: string;
37
+ widestDescendantWidth?: number;
38
+ } | {
39
+ selectorTruncated: true;
40
+ originalLength: number;
41
+ };
42
+ export interface OverflowFinding {
43
+ selector: string;
44
+ bbox: OverflowBbox | null;
45
+ type: OverflowType;
46
+ evidence: OverflowEvidence;
47
+ }
48
+ export interface OverflowDetectResult {
49
+ ok: true;
50
+ scope: OverflowScope;
51
+ findings: OverflowFinding[];
52
+ truncated: boolean;
53
+ warnings: string[];
54
+ }
55
+ export interface SelectorSynth {
56
+ selector: string;
57
+ truncated: boolean;
58
+ originalLength: number;
59
+ }
60
+ /** Pure helper for synthesising a selector against a `MinimalElement` shape.
61
+ * Used by the unit tests; the page-side mirror in `PAGE_DETECT_FN` follows
62
+ * the same tier order but operates on real `Element` instances. */
63
+ export interface MinimalElement {
64
+ tagName: string;
65
+ testId: string | null;
66
+ role: string | null;
67
+ ariaLabel: string | null;
68
+ classList: string[];
69
+ /** Optional parent chain — first entry is the immediate parent. Used
70
+ * by the nth-of-type tier (bounded at 5 levels). Each entry must
71
+ * carry `nthOfType` (1-based) + `tagName`. */
72
+ parentChain?: Array<{
73
+ tagName: string;
74
+ nthOfType: number;
75
+ }>;
76
+ nthOfType?: number;
77
+ }
78
+ export declare function synthesiseSelector(el: MinimalElement): SelectorSynth;
79
+ /** Pure helper: cap findings at `limit`, set `truncated` when exceeded.
80
+ * Exported for unit tests. */
81
+ export declare function applyLimit<T>(findings: T[], limit: number): {
82
+ kept: T[];
83
+ truncated: boolean;
84
+ };
85
+ /** Pure helper: which detector mask should be active. Empty array →
86
+ * all four (an empty filter is treated as "default", not "exclude
87
+ * everything" — the latter would be a usage error with no signal). */
88
+ export declare function resolveTypes(requested: OverflowType[] | undefined): Set<OverflowType>;
89
+ /** Pure helper for the EPSILON math — returns true when content actually
90
+ * overruns its container past the sub-pixel-noise tolerance. Centralised
91
+ * so the unit tests can pin the threshold + so changes flow through one
92
+ * site instead of four detector branches. */
93
+ export declare const OVERFLOW_EPSILON = 1;
94
+ export declare function overflows(scrollDim: number, clientDim: number, epsilon?: number): boolean;
95
+ /** Thin Page-shaped adapter so the unit tests can stub the page surface.
96
+ * Mirrors the patterns in `dom_export` / `element_export`. `evaluate`
97
+ * takes a real function (Playwright serializes it + invokes in-page) —
98
+ * passing a stringified arrow returns the function uncalled. */
99
+ export interface OverflowDetectPage {
100
+ evaluate<T, Arg>(fn: (arg: Arg) => T | Promise<T>, args?: Arg): Promise<T>;
101
+ }
102
+ export declare function detectOverflow(page: OverflowDetectPage, args?: OverflowDetectArgs): Promise<OverflowDetectResult>;