devharness 0.8.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 (627) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +185 -0
  3. package/build/atomic-write.d.ts +28 -0
  4. package/build/atomic-write.d.ts.map +1 -0
  5. package/build/atomic-write.js +126 -0
  6. package/build/atomic-write.js.map +1 -0
  7. package/build/cdp-manager.d.ts +524 -0
  8. package/build/cdp-manager.d.ts.map +1 -0
  9. package/build/cdp-manager.js +1828 -0
  10. package/build/cdp-manager.js.map +1 -0
  11. package/build/cdp-manager.test.d.ts +6 -0
  12. package/build/cdp-manager.test.d.ts.map +1 -0
  13. package/build/cdp-manager.test.js +546 -0
  14. package/build/cdp-manager.test.js.map +1 -0
  15. package/build/chrome-launcher.d.ts +400 -0
  16. package/build/chrome-launcher.d.ts.map +1 -0
  17. package/build/chrome-launcher.js +1071 -0
  18. package/build/chrome-launcher.js.map +1 -0
  19. package/build/chrome-launcher.test.d.ts +11 -0
  20. package/build/chrome-launcher.test.d.ts.map +1 -0
  21. package/build/chrome-launcher.test.js +204 -0
  22. package/build/chrome-launcher.test.js.map +1 -0
  23. package/build/clickable-cache.d.ts +73 -0
  24. package/build/clickable-cache.d.ts.map +1 -0
  25. package/build/clickable-cache.js +90 -0
  26. package/build/clickable-cache.js.map +1 -0
  27. package/build/command-recorder.d.ts +401 -0
  28. package/build/command-recorder.d.ts.map +1 -0
  29. package/build/command-recorder.js +701 -0
  30. package/build/command-recorder.js.map +1 -0
  31. package/build/config.d.ts +390 -0
  32. package/build/config.d.ts.map +1 -0
  33. package/build/config.js +826 -0
  34. package/build/config.js.map +1 -0
  35. package/build/config.test.d.ts +2 -0
  36. package/build/config.test.d.ts.map +1 -0
  37. package/build/config.test.js +112 -0
  38. package/build/config.test.js.map +1 -0
  39. package/build/connection-manager.d.ts +159 -0
  40. package/build/connection-manager.d.ts.map +1 -0
  41. package/build/connection-manager.js +432 -0
  42. package/build/connection-manager.js.map +1 -0
  43. package/build/connection-manager.test.d.ts +11 -0
  44. package/build/connection-manager.test.d.ts.map +1 -0
  45. package/build/connection-manager.test.js +114 -0
  46. package/build/connection-manager.test.js.map +1 -0
  47. package/build/console-monitor.d.ts +150 -0
  48. package/build/console-monitor.d.ts.map +1 -0
  49. package/build/console-monitor.js +454 -0
  50. package/build/console-monitor.js.map +1 -0
  51. package/build/dashboard/bundle.js +1 -0
  52. package/build/dashboard/dashboard-client.d.ts +42 -0
  53. package/build/dashboard/dashboard-client.d.ts.map +1 -0
  54. package/build/dashboard/dashboard-client.js +184 -0
  55. package/build/dashboard/dashboard-client.js.map +1 -0
  56. package/build/dashboard/dashboard-hub.d.ts +50 -0
  57. package/build/dashboard/dashboard-hub.d.ts.map +1 -0
  58. package/build/dashboard/dashboard-hub.js +654 -0
  59. package/build/dashboard/dashboard-hub.js.map +1 -0
  60. package/build/dashboard/hub-lock.d.ts +16 -0
  61. package/build/dashboard/hub-lock.d.ts.map +1 -0
  62. package/build/dashboard/hub-lock.js +77 -0
  63. package/build/dashboard/hub-lock.js.map +1 -0
  64. package/build/dashboard/index.d.ts +25 -0
  65. package/build/dashboard/index.d.ts.map +1 -0
  66. package/build/dashboard/index.js +77 -0
  67. package/build/dashboard/index.js.map +1 -0
  68. package/build/dashboard/types.d.ts +83 -0
  69. package/build/dashboard/types.d.ts.map +1 -0
  70. package/build/dashboard/types.js +6 -0
  71. package/build/dashboard/types.js.map +1 -0
  72. package/build/debug-logger.d.ts +85 -0
  73. package/build/debug-logger.d.ts.map +1 -0
  74. package/build/debug-logger.js +195 -0
  75. package/build/debug-logger.js.map +1 -0
  76. package/build/debugger-aware-wrapper.d.ts +37 -0
  77. package/build/debugger-aware-wrapper.d.ts.map +1 -0
  78. package/build/debugger-aware-wrapper.js +128 -0
  79. package/build/debugger-aware-wrapper.js.map +1 -0
  80. package/build/dom-change-monitor.d.ts +92 -0
  81. package/build/dom-change-monitor.d.ts.map +1 -0
  82. package/build/dom-change-monitor.js +437 -0
  83. package/build/dom-change-monitor.js.map +1 -0
  84. package/build/element-collector.d.ts +16 -0
  85. package/build/element-collector.d.ts.map +1 -0
  86. package/build/element-collector.js +207 -0
  87. package/build/element-collector.js.map +1 -0
  88. package/build/error-helpers.d.ts +43 -0
  89. package/build/error-helpers.d.ts.map +1 -0
  90. package/build/error-helpers.js +143 -0
  91. package/build/error-helpers.js.map +1 -0
  92. package/build/formatters/console-formatter.d.ts +160 -0
  93. package/build/formatters/console-formatter.d.ts.map +1 -0
  94. package/build/formatters/console-formatter.js +338 -0
  95. package/build/formatters/console-formatter.js.map +1 -0
  96. package/build/helpers/parser-plugins.d.ts +44 -0
  97. package/build/helpers/parser-plugins.d.ts.map +1 -0
  98. package/build/helpers/parser-plugins.js +102 -0
  99. package/build/helpers/parser-plugins.js.map +1 -0
  100. package/build/helpers/paths.d.ts +79 -0
  101. package/build/helpers/paths.d.ts.map +1 -0
  102. package/build/helpers/paths.js +168 -0
  103. package/build/helpers/paths.js.map +1 -0
  104. package/build/helpers/process-liveness.d.ts +24 -0
  105. package/build/helpers/process-liveness.d.ts.map +1 -0
  106. package/build/helpers/process-liveness.js +36 -0
  107. package/build/helpers/process-liveness.js.map +1 -0
  108. package/build/helpers/process-liveness.test.d.ts +2 -0
  109. package/build/helpers/process-liveness.test.d.ts.map +1 -0
  110. package/build/helpers/process-liveness.test.js +40 -0
  111. package/build/helpers/process-liveness.test.js.map +1 -0
  112. package/build/helpers/sequence-tree.d.ts +27 -0
  113. package/build/helpers/sequence-tree.d.ts.map +1 -0
  114. package/build/helpers/sequence-tree.js +80 -0
  115. package/build/helpers/sequence-tree.js.map +1 -0
  116. package/build/helpers/sequence-tree.test.d.ts +2 -0
  117. package/build/helpers/sequence-tree.test.d.ts.map +1 -0
  118. package/build/helpers/sequence-tree.test.js +122 -0
  119. package/build/helpers/sequence-tree.test.js.map +1 -0
  120. package/build/index.d.ts +3 -0
  121. package/build/index.d.ts.map +1 -0
  122. package/build/index.js +2007 -0
  123. package/build/index.js.map +1 -0
  124. package/build/interaction-recorder.d.ts +214 -0
  125. package/build/interaction-recorder.d.ts.map +1 -0
  126. package/build/interaction-recorder.js +2007 -0
  127. package/build/interaction-recorder.js.map +1 -0
  128. package/build/issue-tracker.d.ts +107 -0
  129. package/build/issue-tracker.d.ts.map +1 -0
  130. package/build/issue-tracker.js +582 -0
  131. package/build/issue-tracker.js.map +1 -0
  132. package/build/issue-tracker.test.d.ts +2 -0
  133. package/build/issue-tracker.test.d.ts.map +1 -0
  134. package/build/issue-tracker.test.js +88 -0
  135. package/build/issue-tracker.test.js.map +1 -0
  136. package/build/launch-chrome-port.test.d.ts +14 -0
  137. package/build/launch-chrome-port.test.d.ts.map +1 -0
  138. package/build/launch-chrome-port.test.js +97 -0
  139. package/build/launch-chrome-port.test.js.map +1 -0
  140. package/build/log-processor/orchestrator.d.ts +32 -0
  141. package/build/log-processor/orchestrator.d.ts.map +1 -0
  142. package/build/log-processor/orchestrator.js +27 -0
  143. package/build/log-processor/orchestrator.js.map +1 -0
  144. package/build/logpoint-execution-tracker.d.ts +57 -0
  145. package/build/logpoint-execution-tracker.d.ts.map +1 -0
  146. package/build/logpoint-execution-tracker.js +112 -0
  147. package/build/logpoint-execution-tracker.js.map +1 -0
  148. package/build/mcp-supervisor.d.ts +3 -0
  149. package/build/mcp-supervisor.d.ts.map +1 -0
  150. package/build/mcp-supervisor.js +211 -0
  151. package/build/mcp-supervisor.js.map +1 -0
  152. package/build/messages.d.ts +165 -0
  153. package/build/messages.d.ts.map +1 -0
  154. package/build/messages.js +574 -0
  155. package/build/messages.js.map +1 -0
  156. package/build/network-monitor.d.ts +172 -0
  157. package/build/network-monitor.d.ts.map +1 -0
  158. package/build/network-monitor.js +350 -0
  159. package/build/network-monitor.js.map +1 -0
  160. package/build/overlays.d.ts +49 -0
  161. package/build/overlays.d.ts.map +1 -0
  162. package/build/overlays.js +409 -0
  163. package/build/overlays.js.map +1 -0
  164. package/build/persistent-profiles.test.d.ts +15 -0
  165. package/build/persistent-profiles.test.d.ts.map +1 -0
  166. package/build/persistent-profiles.test.js +470 -0
  167. package/build/persistent-profiles.test.js.map +1 -0
  168. package/build/port-reserver.d.ts +32 -0
  169. package/build/port-reserver.d.ts.map +1 -0
  170. package/build/port-reserver.js +118 -0
  171. package/build/port-reserver.js.map +1 -0
  172. package/build/puppeteer-manager.d.ts +47 -0
  173. package/build/puppeteer-manager.d.ts.map +1 -0
  174. package/build/puppeteer-manager.js +116 -0
  175. package/build/puppeteer-manager.js.map +1 -0
  176. package/build/recording-coverage.test.d.ts +12 -0
  177. package/build/recording-coverage.test.d.ts.map +1 -0
  178. package/build/recording-coverage.test.js +72 -0
  179. package/build/recording-coverage.test.js.map +1 -0
  180. package/build/reference-validator.d.ts +47 -0
  181. package/build/reference-validator.d.ts.map +1 -0
  182. package/build/reference-validator.js +86 -0
  183. package/build/reference-validator.js.map +1 -0
  184. package/build/reference-validator.test.d.ts +5 -0
  185. package/build/reference-validator.test.d.ts.map +1 -0
  186. package/build/reference-validator.test.js +243 -0
  187. package/build/reference-validator.test.js.map +1 -0
  188. package/build/replay-cursor.d.ts +27 -0
  189. package/build/replay-cursor.d.ts.map +1 -0
  190. package/build/replay-cursor.js +240 -0
  191. package/build/replay-cursor.js.map +1 -0
  192. package/build/runners/docker-compose-runner.d.ts +69 -0
  193. package/build/runners/docker-compose-runner.d.ts.map +1 -0
  194. package/build/runners/docker-compose-runner.js +438 -0
  195. package/build/runners/docker-compose-runner.js.map +1 -0
  196. package/build/runners/docker-runner.d.ts +65 -0
  197. package/build/runners/docker-runner.d.ts.map +1 -0
  198. package/build/runners/docker-runner.js +414 -0
  199. package/build/runners/docker-runner.js.map +1 -0
  200. package/build/runners/index.d.ts +19 -0
  201. package/build/runners/index.d.ts.map +1 -0
  202. package/build/runners/index.js +35 -0
  203. package/build/runners/index.js.map +1 -0
  204. package/build/runners/native-runner.d.ts +95 -0
  205. package/build/runners/native-runner.d.ts.map +1 -0
  206. package/build/runners/native-runner.js +370 -0
  207. package/build/runners/native-runner.js.map +1 -0
  208. package/build/runners/types.d.ts +147 -0
  209. package/build/runners/types.d.ts.map +1 -0
  210. package/build/runners/types.js +25 -0
  211. package/build/runners/types.js.map +1 -0
  212. package/build/self-restart.d.ts +12 -0
  213. package/build/self-restart.d.ts.map +1 -0
  214. package/build/self-restart.js +41 -0
  215. package/build/self-restart.js.map +1 -0
  216. package/build/self-restart.test.d.ts +2 -0
  217. package/build/self-restart.test.d.ts.map +1 -0
  218. package/build/self-restart.test.js +34 -0
  219. package/build/self-restart.test.js.map +1 -0
  220. package/build/server-claims.d.ts +161 -0
  221. package/build/server-claims.d.ts.map +1 -0
  222. package/build/server-claims.js +382 -0
  223. package/build/server-claims.js.map +1 -0
  224. package/build/server-claims.test.d.ts +2 -0
  225. package/build/server-claims.test.d.ts.map +1 -0
  226. package/build/server-claims.test.js +197 -0
  227. package/build/server-claims.test.js.map +1 -0
  228. package/build/server-manager.d.ts +438 -0
  229. package/build/server-manager.d.ts.map +1 -0
  230. package/build/server-manager.js +1674 -0
  231. package/build/server-manager.js.map +1 -0
  232. package/build/server-manager.test.d.ts +17 -0
  233. package/build/server-manager.test.d.ts.map +1 -0
  234. package/build/server-manager.test.js +122 -0
  235. package/build/server-manager.test.js.map +1 -0
  236. package/build/server-ownership.test.d.ts +2 -0
  237. package/build/server-ownership.test.d.ts.map +1 -0
  238. package/build/server-ownership.test.js +238 -0
  239. package/build/server-ownership.test.js.map +1 -0
  240. package/build/server-watcher.d.ts +21 -0
  241. package/build/server-watcher.d.ts.map +1 -0
  242. package/build/server-watcher.js +105 -0
  243. package/build/server-watcher.js.map +1 -0
  244. package/build/session-detector.d.ts +47 -0
  245. package/build/session-detector.d.ts.map +1 -0
  246. package/build/session-detector.js +229 -0
  247. package/build/session-detector.js.map +1 -0
  248. package/build/session-detector.test.d.ts +9 -0
  249. package/build/session-detector.test.d.ts.map +1 -0
  250. package/build/session-detector.test.js +45 -0
  251. package/build/session-detector.test.js.map +1 -0
  252. package/build/sourcemap-handler.d.ts +114 -0
  253. package/build/sourcemap-handler.d.ts.map +1 -0
  254. package/build/sourcemap-handler.js +479 -0
  255. package/build/sourcemap-handler.js.map +1 -0
  256. package/build/supervisor/child-manager.d.ts +43 -0
  257. package/build/supervisor/child-manager.d.ts.map +1 -0
  258. package/build/supervisor/child-manager.js +148 -0
  259. package/build/supervisor/child-manager.js.map +1 -0
  260. package/build/supervisor/child-manager.test.d.ts +2 -0
  261. package/build/supervisor/child-manager.test.d.ts.map +1 -0
  262. package/build/supervisor/child-manager.test.js +107 -0
  263. package/build/supervisor/child-manager.test.js.map +1 -0
  264. package/build/supervisor/client-watcher.d.ts +48 -0
  265. package/build/supervisor/client-watcher.d.ts.map +1 -0
  266. package/build/supervisor/client-watcher.js +186 -0
  267. package/build/supervisor/client-watcher.js.map +1 -0
  268. package/build/supervisor/client-watcher.test.d.ts +2 -0
  269. package/build/supervisor/client-watcher.test.d.ts.map +1 -0
  270. package/build/supervisor/client-watcher.test.js +121 -0
  271. package/build/supervisor/client-watcher.test.js.map +1 -0
  272. package/build/supervisor/idle-config.d.ts +30 -0
  273. package/build/supervisor/idle-config.d.ts.map +1 -0
  274. package/build/supervisor/idle-config.js +76 -0
  275. package/build/supervisor/idle-config.js.map +1 -0
  276. package/build/supervisor/idle-config.test.d.ts +2 -0
  277. package/build/supervisor/idle-config.test.d.ts.map +1 -0
  278. package/build/supervisor/idle-config.test.js +119 -0
  279. package/build/supervisor/idle-config.test.js.map +1 -0
  280. package/build/supervisor/ndjson-reader.d.ts +47 -0
  281. package/build/supervisor/ndjson-reader.d.ts.map +1 -0
  282. package/build/supervisor/ndjson-reader.js +75 -0
  283. package/build/supervisor/ndjson-reader.js.map +1 -0
  284. package/build/supervisor/ndjson-reader.test.d.ts +2 -0
  285. package/build/supervisor/ndjson-reader.test.d.ts.map +1 -0
  286. package/build/supervisor/ndjson-reader.test.js +92 -0
  287. package/build/supervisor/ndjson-reader.test.js.map +1 -0
  288. package/build/supervisor/pidfile.d.ts +11 -0
  289. package/build/supervisor/pidfile.d.ts.map +1 -0
  290. package/build/supervisor/pidfile.js +29 -0
  291. package/build/supervisor/pidfile.js.map +1 -0
  292. package/build/supervisor/pidfile.test.d.ts +8 -0
  293. package/build/supervisor/pidfile.test.d.ts.map +1 -0
  294. package/build/supervisor/pidfile.test.js +46 -0
  295. package/build/supervisor/pidfile.test.js.map +1 -0
  296. package/build/supervisor/restart-coordinator.d.ts +73 -0
  297. package/build/supervisor/restart-coordinator.d.ts.map +1 -0
  298. package/build/supervisor/restart-coordinator.js +300 -0
  299. package/build/supervisor/restart-coordinator.js.map +1 -0
  300. package/build/supervisor/restart-coordinator.test.d.ts +2 -0
  301. package/build/supervisor/restart-coordinator.test.d.ts.map +1 -0
  302. package/build/supervisor/restart-coordinator.test.js +434 -0
  303. package/build/supervisor/restart-coordinator.test.js.map +1 -0
  304. package/build/test-support/fake-execute-tool-call.d.ts +11 -0
  305. package/build/test-support/fake-execute-tool-call.d.ts.map +1 -0
  306. package/build/test-support/fake-execute-tool-call.js +19 -0
  307. package/build/test-support/fake-execute-tool-call.js.map +1 -0
  308. package/build/tool-error.d.ts +14 -0
  309. package/build/tool-error.d.ts.map +1 -0
  310. package/build/tool-error.js +18 -0
  311. package/build/tool-error.js.map +1 -0
  312. package/build/tool-response.d.ts +293 -0
  313. package/build/tool-response.d.ts.map +1 -0
  314. package/build/tool-response.js +365 -0
  315. package/build/tool-response.js.map +1 -0
  316. package/build/tools/assert-tools.d.ts +62 -0
  317. package/build/tools/assert-tools.d.ts.map +1 -0
  318. package/build/tools/assert-tools.js +330 -0
  319. package/build/tools/assert-tools.js.map +1 -0
  320. package/build/tools/breakpoint-await-abort.test.d.ts +2 -0
  321. package/build/tools/breakpoint-await-abort.test.d.ts.map +1 -0
  322. package/build/tools/breakpoint-await-abort.test.js +124 -0
  323. package/build/tools/breakpoint-await-abort.test.js.map +1 -0
  324. package/build/tools/breakpoint-tools.d.ts +99 -0
  325. package/build/tools/breakpoint-tools.d.ts.map +1 -0
  326. package/build/tools/breakpoint-tools.js +1197 -0
  327. package/build/tools/breakpoint-tools.js.map +1 -0
  328. package/build/tools/config-tools.d.ts +58 -0
  329. package/build/tools/config-tools.d.ts.map +1 -0
  330. package/build/tools/config-tools.js +180 -0
  331. package/build/tools/config-tools.js.map +1 -0
  332. package/build/tools/connection-routing.test.d.ts +12 -0
  333. package/build/tools/connection-routing.test.d.ts.map +1 -0
  334. package/build/tools/connection-routing.test.js +206 -0
  335. package/build/tools/connection-routing.test.js.map +1 -0
  336. package/build/tools/console-tools.d.ts +84 -0
  337. package/build/tools/console-tools.d.ts.map +1 -0
  338. package/build/tools/console-tools.js +241 -0
  339. package/build/tools/console-tools.js.map +1 -0
  340. package/build/tools/content-tools.d.ts +74 -0
  341. package/build/tools/content-tools.d.ts.map +1 -0
  342. package/build/tools/content-tools.js +582 -0
  343. package/build/tools/content-tools.js.map +1 -0
  344. package/build/tools/dashboard-tools.d.ts +38 -0
  345. package/build/tools/dashboard-tools.d.ts.map +1 -0
  346. package/build/tools/dashboard-tools.js +123 -0
  347. package/build/tools/dashboard-tools.js.map +1 -0
  348. package/build/tools/dom-tools.d.ts +41 -0
  349. package/build/tools/dom-tools.d.ts.map +1 -0
  350. package/build/tools/dom-tools.js +277 -0
  351. package/build/tools/dom-tools.js.map +1 -0
  352. package/build/tools/download-tools.d.ts +55 -0
  353. package/build/tools/download-tools.d.ts.map +1 -0
  354. package/build/tools/download-tools.js +280 -0
  355. package/build/tools/download-tools.js.map +1 -0
  356. package/build/tools/execution-tools.d.ts +40 -0
  357. package/build/tools/execution-tools.d.ts.map +1 -0
  358. package/build/tools/execution-tools.js +121 -0
  359. package/build/tools/execution-tools.js.map +1 -0
  360. package/build/tools/input-abort.test.d.ts +2 -0
  361. package/build/tools/input-abort.test.d.ts.map +1 -0
  362. package/build/tools/input-abort.test.js +227 -0
  363. package/build/tools/input-abort.test.js.map +1 -0
  364. package/build/tools/input-ambiguous-selector.test.d.ts +2 -0
  365. package/build/tools/input-ambiguous-selector.test.d.ts.map +1 -0
  366. package/build/tools/input-ambiguous-selector.test.js +34 -0
  367. package/build/tools/input-ambiguous-selector.test.js.map +1 -0
  368. package/build/tools/input-tools.d.ts +168 -0
  369. package/build/tools/input-tools.d.ts.map +1 -0
  370. package/build/tools/input-tools.js +1397 -0
  371. package/build/tools/input-tools.js.map +1 -0
  372. package/build/tools/inspection-tools.d.ts +112 -0
  373. package/build/tools/inspection-tools.d.ts.map +1 -0
  374. package/build/tools/inspection-tools.js +637 -0
  375. package/build/tools/inspection-tools.js.map +1 -0
  376. package/build/tools/interpolation.d.ts +30 -0
  377. package/build/tools/interpolation.d.ts.map +1 -0
  378. package/build/tools/interpolation.js +143 -0
  379. package/build/tools/interpolation.js.map +1 -0
  380. package/build/tools/issues-abort-hygiene.test.d.ts +2 -0
  381. package/build/tools/issues-abort-hygiene.test.d.ts.map +1 -0
  382. package/build/tools/issues-abort-hygiene.test.js +79 -0
  383. package/build/tools/issues-abort-hygiene.test.js.map +1 -0
  384. package/build/tools/issues-tools.d.ts +98 -0
  385. package/build/tools/issues-tools.d.ts.map +1 -0
  386. package/build/tools/issues-tools.js +821 -0
  387. package/build/tools/issues-tools.js.map +1 -0
  388. package/build/tools/issues-tools.test.d.ts +8 -0
  389. package/build/tools/issues-tools.test.d.ts.map +1 -0
  390. package/build/tools/issues-tools.test.js +184 -0
  391. package/build/tools/issues-tools.test.js.map +1 -0
  392. package/build/tools/modal-tools.d.ts +73 -0
  393. package/build/tools/modal-tools.d.ts.map +1 -0
  394. package/build/tools/modal-tools.js +161 -0
  395. package/build/tools/modal-tools.js.map +1 -0
  396. package/build/tools/network-tools.d.ts +72 -0
  397. package/build/tools/network-tools.d.ts.map +1 -0
  398. package/build/tools/network-tools.js +432 -0
  399. package/build/tools/network-tools.js.map +1 -0
  400. package/build/tools/page-tools.d.ts +78 -0
  401. package/build/tools/page-tools.d.ts.map +1 -0
  402. package/build/tools/page-tools.js +255 -0
  403. package/build/tools/page-tools.js.map +1 -0
  404. package/build/tools/plugin-tools.d.ts +16 -0
  405. package/build/tools/plugin-tools.d.ts.map +1 -0
  406. package/build/tools/plugin-tools.js +17 -0
  407. package/build/tools/plugin-tools.js.map +1 -0
  408. package/build/tools/replay-abort.test.d.ts +2 -0
  409. package/build/tools/replay-abort.test.d.ts.map +1 -0
  410. package/build/tools/replay-abort.test.js +259 -0
  411. package/build/tools/replay-abort.test.js.map +1 -0
  412. package/build/tools/replay-add-conditional.test.d.ts +2 -0
  413. package/build/tools/replay-add-conditional.test.d.ts.map +1 -0
  414. package/build/tools/replay-add-conditional.test.js +205 -0
  415. package/build/tools/replay-add-conditional.test.js.map +1 -0
  416. package/build/tools/replay-background-run.test.d.ts +2 -0
  417. package/build/tools/replay-background-run.test.d.ts.map +1 -0
  418. package/build/tools/replay-background-run.test.js +176 -0
  419. package/build/tools/replay-background-run.test.js.map +1 -0
  420. package/build/tools/replay-capture-variables.test.d.ts +2 -0
  421. package/build/tools/replay-capture-variables.test.d.ts.map +1 -0
  422. package/build/tools/replay-capture-variables.test.js +331 -0
  423. package/build/tools/replay-capture-variables.test.js.map +1 -0
  424. package/build/tools/replay-conditional-idb-and-launch.test.d.ts +11 -0
  425. package/build/tools/replay-conditional-idb-and-launch.test.d.ts.map +1 -0
  426. package/build/tools/replay-conditional-idb-and-launch.test.js +429 -0
  427. package/build/tools/replay-conditional-idb-and-launch.test.js.map +1 -0
  428. package/build/tools/replay-conditional-timeout.test.d.ts +14 -0
  429. package/build/tools/replay-conditional-timeout.test.d.ts.map +1 -0
  430. package/build/tools/replay-conditional-timeout.test.js +126 -0
  431. package/build/tools/replay-conditional-timeout.test.js.map +1 -0
  432. package/build/tools/replay-declare.test.d.ts +2 -0
  433. package/build/tools/replay-declare.test.d.ts.map +1 -0
  434. package/build/tools/replay-declare.test.js +106 -0
  435. package/build/tools/replay-declare.test.js.map +1 -0
  436. package/build/tools/replay-declared-browser-cleanup.test.d.ts +2 -0
  437. package/build/tools/replay-declared-browser-cleanup.test.d.ts.map +1 -0
  438. package/build/tools/replay-declared-browser-cleanup.test.js +103 -0
  439. package/build/tools/replay-declared-browser-cleanup.test.js.map +1 -0
  440. package/build/tools/replay-declared-profile.test.d.ts +2 -0
  441. package/build/tools/replay-declared-profile.test.d.ts.map +1 -0
  442. package/build/tools/replay-declared-profile.test.js +116 -0
  443. package/build/tools/replay-declared-profile.test.js.map +1 -0
  444. package/build/tools/replay-executor.d.ts +556 -0
  445. package/build/tools/replay-executor.d.ts.map +1 -0
  446. package/build/tools/replay-executor.js +2347 -0
  447. package/build/tools/replay-executor.js.map +1 -0
  448. package/build/tools/replay-folder-save.test.d.ts +2 -0
  449. package/build/tools/replay-folder-save.test.d.ts.map +1 -0
  450. package/build/tools/replay-folder-save.test.js +63 -0
  451. package/build/tools/replay-folder-save.test.js.map +1 -0
  452. package/build/tools/replay-formatters.d.ts +148 -0
  453. package/build/tools/replay-formatters.d.ts.map +1 -0
  454. package/build/tools/replay-formatters.js +856 -0
  455. package/build/tools/replay-formatters.js.map +1 -0
  456. package/build/tools/replay-kill-chrome-on-finish.test.d.ts +2 -0
  457. package/build/tools/replay-kill-chrome-on-finish.test.d.ts.map +1 -0
  458. package/build/tools/replay-kill-chrome-on-finish.test.js +175 -0
  459. package/build/tools/replay-kill-chrome-on-finish.test.js.map +1 -0
  460. package/build/tools/replay-multi-connection.test.d.ts +2 -0
  461. package/build/tools/replay-multi-connection.test.d.ts.map +1 -0
  462. package/build/tools/replay-multi-connection.test.js +547 -0
  463. package/build/tools/replay-multi-connection.test.js.map +1 -0
  464. package/build/tools/replay-output-and-record-options.test.d.ts +2 -0
  465. package/build/tools/replay-output-and-record-options.test.d.ts.map +1 -0
  466. package/build/tools/replay-output-and-record-options.test.js +240 -0
  467. package/build/tools/replay-output-and-record-options.test.js.map +1 -0
  468. package/build/tools/replay-production-error-shape.test.d.ts +7 -0
  469. package/build/tools/replay-production-error-shape.test.d.ts.map +1 -0
  470. package/build/tools/replay-production-error-shape.test.js +93 -0
  471. package/build/tools/replay-production-error-shape.test.js.map +1 -0
  472. package/build/tools/replay-rebase.test.d.ts +2 -0
  473. package/build/tools/replay-rebase.test.d.ts.map +1 -0
  474. package/build/tools/replay-rebase.test.js +58 -0
  475. package/build/tools/replay-rebase.test.js.map +1 -0
  476. package/build/tools/replay-retry-classification.test.d.ts +9 -0
  477. package/build/tools/replay-retry-classification.test.d.ts.map +1 -0
  478. package/build/tools/replay-retry-classification.test.js +57 -0
  479. package/build/tools/replay-retry-classification.test.js.map +1 -0
  480. package/build/tools/replay-run-registry.d.ts +55 -0
  481. package/build/tools/replay-run-registry.d.ts.map +1 -0
  482. package/build/tools/replay-run-registry.js +65 -0
  483. package/build/tools/replay-run-registry.js.map +1 -0
  484. package/build/tools/replay-sequence-reload.test.d.ts +2 -0
  485. package/build/tools/replay-sequence-reload.test.d.ts.map +1 -0
  486. package/build/tools/replay-sequence-reload.test.js +82 -0
  487. package/build/tools/replay-sequence-reload.test.js.map +1 -0
  488. package/build/tools/replay-socket-scope.test.d.ts +2 -0
  489. package/build/tools/replay-socket-scope.test.d.ts.map +1 -0
  490. package/build/tools/replay-socket-scope.test.js +75 -0
  491. package/build/tools/replay-socket-scope.test.js.map +1 -0
  492. package/build/tools/replay-step-connection.test.d.ts +2 -0
  493. package/build/tools/replay-step-connection.test.d.ts.map +1 -0
  494. package/build/tools/replay-step-connection.test.js +292 -0
  495. package/build/tools/replay-step-connection.test.js.map +1 -0
  496. package/build/tools/replay-step-timeout.test.d.ts +2 -0
  497. package/build/tools/replay-step-timeout.test.d.ts.map +1 -0
  498. package/build/tools/replay-step-timeout.test.js +204 -0
  499. package/build/tools/replay-step-timeout.test.js.map +1 -0
  500. package/build/tools/replay-tags.test.d.ts +2 -0
  501. package/build/tools/replay-tags.test.d.ts.map +1 -0
  502. package/build/tools/replay-tags.test.js +99 -0
  503. package/build/tools/replay-tags.test.js.map +1 -0
  504. package/build/tools/replay-teardown-and-foreach.test.d.ts +13 -0
  505. package/build/tools/replay-teardown-and-foreach.test.d.ts.map +1 -0
  506. package/build/tools/replay-teardown-and-foreach.test.js +318 -0
  507. package/build/tools/replay-teardown-and-foreach.test.js.map +1 -0
  508. package/build/tools/replay-tool-name-validation.test.d.ts +2 -0
  509. package/build/tools/replay-tool-name-validation.test.d.ts.map +1 -0
  510. package/build/tools/replay-tool-name-validation.test.js +280 -0
  511. package/build/tools/replay-tool-name-validation.test.js.map +1 -0
  512. package/build/tools/replay-tools.d.ts +288 -0
  513. package/build/tools/replay-tools.d.ts.map +1 -0
  514. package/build/tools/replay-tools.js +2994 -0
  515. package/build/tools/replay-tools.js.map +1 -0
  516. package/build/tools/request-abort.test.d.ts +2 -0
  517. package/build/tools/request-abort.test.d.ts.map +1 -0
  518. package/build/tools/request-abort.test.js +130 -0
  519. package/build/tools/request-abort.test.js.map +1 -0
  520. package/build/tools/request-tools.d.ts +56 -0
  521. package/build/tools/request-tools.d.ts.map +1 -0
  522. package/build/tools/request-tools.js +174 -0
  523. package/build/tools/request-tools.js.map +1 -0
  524. package/build/tools/screenshot-tools.d.ts +135 -0
  525. package/build/tools/screenshot-tools.d.ts.map +1 -0
  526. package/build/tools/screenshot-tools.js +636 -0
  527. package/build/tools/screenshot-tools.js.map +1 -0
  528. package/build/tools/server-tools.d.ts +88 -0
  529. package/build/tools/server-tools.d.ts.map +1 -0
  530. package/build/tools/server-tools.js +485 -0
  531. package/build/tools/server-tools.js.map +1 -0
  532. package/build/tools/source-tools.d.ts +46 -0
  533. package/build/tools/source-tools.d.ts.map +1 -0
  534. package/build/tools/source-tools.js +47 -0
  535. package/build/tools/source-tools.js.map +1 -0
  536. package/build/tools/storage-tools.d.ts +141 -0
  537. package/build/tools/storage-tools.d.ts.map +1 -0
  538. package/build/tools/storage-tools.js +894 -0
  539. package/build/tools/storage-tools.js.map +1 -0
  540. package/build/tools/storage-tools.test.d.ts +13 -0
  541. package/build/tools/storage-tools.test.d.ts.map +1 -0
  542. package/build/tools/storage-tools.test.js +707 -0
  543. package/build/tools/storage-tools.test.js.map +1 -0
  544. package/build/tools/tab-tools.d.ts +42 -0
  545. package/build/tools/tab-tools.d.ts.map +1 -0
  546. package/build/tools/tab-tools.js +296 -0
  547. package/build/tools/tab-tools.js.map +1 -0
  548. package/build/tools/wait-tools.d.ts +85 -0
  549. package/build/tools/wait-tools.d.ts.map +1 -0
  550. package/build/tools/wait-tools.js +236 -0
  551. package/build/tools/wait-tools.js.map +1 -0
  552. package/build/tools/wait-tools.test.d.ts +9 -0
  553. package/build/tools/wait-tools.test.d.ts.map +1 -0
  554. package/build/tools/wait-tools.test.js +193 -0
  555. package/build/tools/wait-tools.test.js.map +1 -0
  556. package/build/types.d.ts +133 -0
  557. package/build/types.d.ts.map +1 -0
  558. package/build/types.js +5 -0
  559. package/build/types.js.map +1 -0
  560. package/build/ui-verifier.d.ts +88 -0
  561. package/build/ui-verifier.d.ts.map +1 -0
  562. package/build/ui-verifier.js +540 -0
  563. package/build/ui-verifier.js.map +1 -0
  564. package/build/utils/abort.d.ts +68 -0
  565. package/build/utils/abort.d.ts.map +1 -0
  566. package/build/utils/abort.js +159 -0
  567. package/build/utils/abort.js.map +1 -0
  568. package/build/utils/abort.test.d.ts +2 -0
  569. package/build/utils/abort.test.d.ts.map +1 -0
  570. package/build/utils/abort.test.js +174 -0
  571. package/build/utils/abort.test.js.map +1 -0
  572. package/build/utils/modal-detection-core.d.ts +150 -0
  573. package/build/utils/modal-detection-core.d.ts.map +1 -0
  574. package/build/utils/modal-detection-core.js +332 -0
  575. package/build/utils/modal-detection-core.js.map +1 -0
  576. package/build/utils/modal-detection-core.test.d.ts +5 -0
  577. package/build/utils/modal-detection-core.test.d.ts.map +1 -0
  578. package/build/utils/modal-detection-core.test.js +492 -0
  579. package/build/utils/modal-detection-core.test.js.map +1 -0
  580. package/build/utils/modal-detector.d.ts +29 -0
  581. package/build/utils/modal-detector.d.ts.map +1 -0
  582. package/build/utils/modal-detector.js +281 -0
  583. package/build/utils/modal-detector.js.map +1 -0
  584. package/build/utils/modal-dismissal.d.ts +32 -0
  585. package/build/utils/modal-dismissal.d.ts.map +1 -0
  586. package/build/utils/modal-dismissal.js +190 -0
  587. package/build/utils/modal-dismissal.js.map +1 -0
  588. package/build/utils/port-check.d.ts +31 -0
  589. package/build/utils/port-check.d.ts.map +1 -0
  590. package/build/utils/port-check.js +87 -0
  591. package/build/utils/port-check.js.map +1 -0
  592. package/build/utils/port-check.test.d.ts +2 -0
  593. package/build/utils/port-check.test.d.ts.map +1 -0
  594. package/build/utils/port-check.test.js +66 -0
  595. package/build/utils/port-check.test.js.map +1 -0
  596. package/build/utils/selector-resolver.d.ts +66 -0
  597. package/build/utils/selector-resolver.d.ts.map +1 -0
  598. package/build/utils/selector-resolver.js +200 -0
  599. package/build/utils/selector-resolver.js.map +1 -0
  600. package/build/validation-helpers.d.ts +41 -0
  601. package/build/validation-helpers.d.ts.map +1 -0
  602. package/build/validation-helpers.js +236 -0
  603. package/build/validation-helpers.js.map +1 -0
  604. package/build/window-sizing.d.ts +26 -0
  605. package/build/window-sizing.d.ts.map +1 -0
  606. package/build/window-sizing.js +87 -0
  607. package/build/window-sizing.js.map +1 -0
  608. package/build/window-sizing.test.d.ts +8 -0
  609. package/build/window-sizing.test.d.ts.map +1 -0
  610. package/build/window-sizing.test.js +113 -0
  611. package/build/window-sizing.test.js.map +1 -0
  612. package/docs/README.md +74 -0
  613. package/docs/automation.md +562 -0
  614. package/docs/debugging.md +229 -0
  615. package/docs/installation.md +133 -0
  616. package/docs/instructions.md +227 -0
  617. package/docs/mcp-instructions.md +15 -0
  618. package/docs/message-system.md +327 -0
  619. package/docs/messages.md +3480 -0
  620. package/docs/parser-plugins.md +132 -0
  621. package/docs/replay.md +1411 -0
  622. package/docs/troubleshooting.md +272 -0
  623. package/docs/working_with_llm_notes.md +5 -0
  624. package/package.json +87 -0
  625. package/skills/devharness/SKILL.md +195 -0
  626. package/skills/devharness/references/sequences.md +613 -0
  627. package/skills/devharness/references/tool-categories.md +99 -0
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Wait Tool - a first-class wait primitive for sequences (bug-016)
3
+ *
4
+ * Four mutually exclusive forms:
5
+ * wait({ selector }) - until an element matching the selector exists
6
+ * wait({ selectorGone }) - until NO element matches the selector
7
+ * wait({ expression }) - until a synchronous JS expression is truthy
8
+ * wait({ ms }) - fixed sleep (last resort)
9
+ *
10
+ * All condition forms poll from the MCP side: the predicate is a SYNCHRONOUS
11
+ * expression re-evaluated over CDP on an interval. This is deliberate - it is
12
+ * NOT an in-page waitForFunction/waitForSelector:
13
+ *
14
+ * - It survives a navigation mid-wait. Each poll runs in whatever execution
15
+ * context the page currently has; if the context is destroyed between
16
+ * polls (navigation), the failed poll is swallowed and the next one runs
17
+ * in the new document. This is exactly the "step after navigate races the
18
+ * new page" case that motivated the tool.
19
+ * - It does not depend on the page's event loop making progress or on any
20
+ * in-page promise ever resolving, so it still behaves sanely when the page
21
+ * is busy - and it fails fast instead of burning the timeout when the
22
+ * debugger is paused (nothing can change while the event loop is stopped).
23
+ */
24
+ import { z } from 'zod';
25
+ import { createTool } from '../validation-helpers.js';
26
+ import { createErrorResponse, createSuccessResponse } from '../messages.js';
27
+ import { isExtendedSelector, parseExtendedSelector } from '../utils/selector-resolver.js';
28
+ import { abortableSleep, isAbortError, throwIfAborted } from '../utils/abort.js';
29
+ const waitSchema = z.object({
30
+ selector: z.string().optional().describe('Wait until an element matching this CSS selector exists. Supports extended selectors: :has-text("text") partial match, :text("text") exact match. Survives navigations that happen mid-wait.'),
31
+ selectorGone: z.string().optional().describe('Wait until NO element matches this CSS selector (spinner removed, modal closed). Same selector syntax as selector.'),
32
+ expression: z.string().optional().describe('Wait until this SYNCHRONOUS JavaScript expression evaluates truthy, e.g. "window.__probeResult !== \'PENDING\'". Re-evaluated from the MCP side on an interval - do not use await/promises; kick async work off in a prior step, store its result in a global, and wait on the global here.'),
33
+ ms: z.number().int().positive().max(300000).optional().describe('Fixed sleep in milliseconds. Last resort - prefer selector/expression, which return as soon as the condition holds and fail loudly on timeout instead of silently waiting too little (or too long).'),
34
+ timeoutMs: z.number().int().positive().max(300000).optional().describe('Give up after this many ms (default: 15000). On timeout the step fails (isError) - in a sequence that stops the run, same as any other failed step.'),
35
+ pollIntervalMs: z.number().int().min(25).max(5000).optional().describe('Interval between condition checks in ms (default: 100)'),
36
+ connectionReason: z.string().optional().describe('Connection reference (required for selector/selectorGone/expression; not used for ms). In a sequence the run-level connection is injected automatically, like every other step.'),
37
+ }).strict();
38
+ const DEFAULT_TIMEOUT_MS = 15000;
39
+ const DEFAULT_POLL_INTERVAL_MS = 100;
40
+ /**
41
+ * Build a self-contained synchronous in-page expression that evaluates to
42
+ * true when an element matching `selector` exists. Extended selectors
43
+ * (:has-text etc.) are compiled to an inline text-match - no element marking,
44
+ * so nothing is lost when the document is replaced between polls.
45
+ */
46
+ export function buildPresencePredicate(selector) {
47
+ if (!isExtendedSelector(selector)) {
48
+ return `!!document.querySelector(${JSON.stringify(selector)})`;
49
+ }
50
+ const parsed = parseExtendedSelector(selector);
51
+ if ('error' in parsed) {
52
+ return { error: parsed.error };
53
+ }
54
+ const { baseSelector, textMatch } = parsed;
55
+ if (!textMatch) {
56
+ return `!!document.querySelector(${JSON.stringify(baseSelector)})`;
57
+ }
58
+ // Matching semantics identical to resolveSelector(): textContent,
59
+ // aria-label and title; case-insensitive partial for has-text, exact for
60
+ // text/text-is.
61
+ return `(() => {
62
+ const els = document.querySelectorAll(${JSON.stringify(baseSelector)});
63
+ const matchText = ${JSON.stringify(textMatch.value)};
64
+ const partial = ${JSON.stringify(textMatch.type === 'has-text')};
65
+ for (const el of els) {
66
+ const tc = (el.textContent || '').trim();
67
+ const al = el.getAttribute('aria-label') || '';
68
+ const ti = el.getAttribute('title') || '';
69
+ if (partial) {
70
+ if ([tc, al, ti].filter(Boolean).join(' ').toLowerCase().includes(matchText.toLowerCase())) return true;
71
+ } else if (tc === matchText || al === matchText || ti === matchText) {
72
+ return true;
73
+ }
74
+ }
75
+ return false;
76
+ })()`;
77
+ }
78
+ /** Errors that mean the selector itself is bad - retrying cannot help. */
79
+ function isSelectorSyntaxError(message) {
80
+ return /is not a valid selector|Failed to execute 'querySelector/i.test(message);
81
+ }
82
+ export function createWaitTools(resolveConnectionFromReason) {
83
+ return {
84
+ wait: createTool('Wait as a sequence step - the primitive for "the previous step kicked off async work". Exactly one of: selector (element appears), selectorGone (element disappears), expression (synchronous JS predicate polls truthy), ms (fixed sleep, last resort). Condition forms poll from the MCP side, so they survive navigations mid-wait and never depend on in-page timers or promises; on timeout the step fails cleanly instead of hanging.', waitSchema,
85
+ // abortSignal: in a sequence this is the RUN's signal - a long wait is
86
+ // the most cancellable thing a run does, so `replay cancel` must
87
+ // interrupt it mid-poll instead of letting it run out its own
88
+ // timeoutMs. On abort the handler THROWS an abort-shaped error (never
89
+ // returns an isError response); the executor classifies it.
90
+ async (args, abortSignal) => {
91
+ const { selector, selectorGone, expression, ms, connectionReason } = args;
92
+ const timeoutMs = args.timeoutMs ?? DEFAULT_TIMEOUT_MS;
93
+ const pollIntervalMs = args.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
94
+ const forms = [
95
+ selector !== undefined ? 'selector' : null,
96
+ selectorGone !== undefined ? 'selectorGone' : null,
97
+ expression !== undefined ? 'expression' : null,
98
+ ms !== undefined ? 'ms' : null,
99
+ ].filter(Boolean);
100
+ if (forms.length !== 1) {
101
+ return createErrorResponse('WAIT_INVALID_ARGS', {
102
+ message: forms.length === 0
103
+ ? 'Provide exactly one of: selector, selectorGone, expression, ms.'
104
+ : `Provide exactly one of: selector, selectorGone, expression, ms - got ${forms.join(' + ')}.`,
105
+ });
106
+ }
107
+ const form = forms[0];
108
+ const buildMeta = (satisfied, elapsedMs, polls) => ({
109
+ tool: 'wait',
110
+ action: form,
111
+ timestamp: Date.now(),
112
+ wait: {
113
+ form,
114
+ condition: selector ?? selectorGone ?? expression ?? `${ms}ms`,
115
+ satisfied,
116
+ elapsedMs,
117
+ polls,
118
+ },
119
+ });
120
+ // ---- wait({ ms }): plain sleep, no browser involved -----------------
121
+ if (form === 'ms') {
122
+ const start = Date.now();
123
+ await abortableSleep(ms, abortSignal);
124
+ const response = createSuccessResponse('WAIT_SLEEP_COMPLETE', { ms: ms });
125
+ return { ...response, _meta: buildMeta(true, Date.now() - start, 0) };
126
+ }
127
+ // ---- condition forms: resolve connection, then poll -----------------
128
+ if (!connectionReason) {
129
+ return createErrorResponse('WAIT_INVALID_ARGS', {
130
+ message: `wait({ ${form} }) requires a connectionReason (the reference from launchChrome/connectDebugger).`,
131
+ });
132
+ }
133
+ const resolved = await resolveConnectionFromReason(connectionReason);
134
+ if (!resolved) {
135
+ return createErrorResponse('CONNECTION_NOT_FOUND', {
136
+ message: `No connection found for reference "${connectionReason}". Use launchChrome first, or listConnections to see active references.`,
137
+ });
138
+ }
139
+ const cdpManager = resolved.cdpManager;
140
+ if (!cdpManager?.isConnected?.()) {
141
+ return createErrorResponse('DEBUGGER_NOT_CONNECTED');
142
+ }
143
+ // Selector forms are DOM-only; expression waits are equally valid
144
+ // against a Node target (wait for a global to flip in a Node app).
145
+ if (form !== 'expression' && cdpManager.getRuntimeType?.() === 'node') {
146
+ return createErrorResponse('NODEJS_NOT_SUPPORTED', { feature: `wait.${form}` });
147
+ }
148
+ let predicate;
149
+ if (form === 'expression') {
150
+ // Trailing newline protects against a `//` comment swallowing the parenthesis.
151
+ predicate = `!!(${expression}\n)`;
152
+ }
153
+ else {
154
+ const built = buildPresencePredicate((selector ?? selectorGone));
155
+ if (typeof built !== 'string') {
156
+ return createErrorResponse('WAIT_INVALID_ARGS', {
157
+ message: `Invalid selector "${selector ?? selectorGone}": ${built.error}`,
158
+ });
159
+ }
160
+ predicate = form === 'selectorGone' ? `!(${built})` : built;
161
+ }
162
+ const conditionLabel = form === 'selector' ? `element "${selector}" to appear`
163
+ : form === 'selectorGone' ? `element "${selectorGone}" to disappear`
164
+ : `expression to be truthy: ${expression}`;
165
+ const start = Date.now();
166
+ let polls = 0;
167
+ let lastError;
168
+ while (true) {
169
+ // Cancelled (e.g. `replay cancel` aborting the run) - stop polling
170
+ // NOW, not at this wait's own timeoutMs.
171
+ throwIfAborted(abortSignal);
172
+ // A paused debugger stops the event loop: the DOM cannot change and
173
+ // no predicate can flip. Burn no time - fail fast with the reason.
174
+ if (cdpManager.isPaused?.()) {
175
+ return {
176
+ ...createErrorResponse('WAIT_DEBUGGER_PAUSED', {
177
+ condition: conditionLabel,
178
+ connectionReason,
179
+ }),
180
+ _meta: buildMeta(false, Date.now() - start, polls),
181
+ };
182
+ }
183
+ polls++;
184
+ try {
185
+ const detailed = await cdpManager.evaluateExpressionDetailed(predicate, undefined, false, // expandObjects - predicate result is a boolean
186
+ 1, { awaitPromise: false, captureRaw: true });
187
+ if (detailed.rawCaptured ? detailed.rawValue === true : detailed.formatted === 'true') {
188
+ const elapsedMs = Date.now() - start;
189
+ const response = createSuccessResponse('WAIT_CONDITION_MET', {
190
+ condition: conditionLabel,
191
+ elapsedMs,
192
+ polls,
193
+ });
194
+ return { ...response, _meta: buildMeta(true, elapsedMs, polls) };
195
+ }
196
+ lastError = undefined; // predicate evaluated cleanly, just false
197
+ }
198
+ catch (err) {
199
+ // An abort is a cancellation, not an evaluation error - rethrow
200
+ // it or the loop below would swallow the user's cancel and keep
201
+ // polling until this wait's own timeoutMs.
202
+ if (isAbortError(err))
203
+ throw err;
204
+ // Evaluation errors are expected mid-wait (execution context
205
+ // destroyed by a navigation; a global that does not exist yet).
206
+ // Swallow and keep polling - but keep the last one for the
207
+ // timeout message, and fail fast when the selector itself is
208
+ // syntactically invalid (no amount of polling fixes that).
209
+ lastError = err?.message || String(err);
210
+ if (form !== 'expression' && lastError && isSelectorSyntaxError(lastError)) {
211
+ return {
212
+ ...createErrorResponse('WAIT_INVALID_ARGS', {
213
+ message: `Invalid selector "${selector ?? selectorGone}": ${lastError}`,
214
+ }),
215
+ _meta: buildMeta(false, Date.now() - start, polls),
216
+ };
217
+ }
218
+ }
219
+ const elapsed = Date.now() - start;
220
+ if (elapsed + pollIntervalMs > timeoutMs) {
221
+ return {
222
+ ...createErrorResponse('WAIT_TIMEOUT', {
223
+ condition: conditionLabel,
224
+ timeoutMs,
225
+ polls,
226
+ lastError: lastError ? `\n**Last evaluation error:** ${lastError}` : '',
227
+ }),
228
+ _meta: buildMeta(false, elapsed, polls),
229
+ };
230
+ }
231
+ await abortableSleep(pollIntervalMs, abortSignal);
232
+ }
233
+ }),
234
+ };
235
+ }
236
+ //# sourceMappingURL=wait-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-tools.js","sourceRoot":"","sources":["../../src/tools/wait-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEjF,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8LAA8L,CAAC;IACxO,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oHAAoH,CAAC;IAClK,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6RAA6R,CAAC;IACzU,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,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AC;YACpD,CAAC;QACH,CAAC,CACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Unit tests for the wait tool (bug-016): the sequence-step wait primitive.
3
+ * Real-browser behaviour (navigation mid-wait, predicate flip) is verified
4
+ * manually against Chrome; these tests cover the pure logic - form
5
+ * validation, predicate compilation, polling/timeout behaviour and the
6
+ * paused-debugger fail-fast - against a fake CDP manager.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=wait-tools.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-tools.test.d.ts","sourceRoot":"","sources":["../../src/tools/wait-tools.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Unit tests for the wait tool (bug-016): the sequence-step wait primitive.
3
+ * Real-browser behaviour (navigation mid-wait, predicate flip) is verified
4
+ * manually against Chrome; these tests cover the pure logic - form
5
+ * validation, predicate compilation, polling/timeout behaviour and the
6
+ * paused-debugger fail-fast - against a fake CDP manager.
7
+ */
8
+ import { describe, it, expect, vi } from 'vitest';
9
+ import { createWaitTools, buildPresencePredicate } from './wait-tools.js';
10
+ import { commandNeedsBrowserConnection, TOOLS_ACCEPTING_CONNECTION, TOOLS_NEEDING_CONNECTION, } from './replay-executor.js';
11
+ function makeCdpManager(overrides = {}) {
12
+ return {
13
+ isPaused: () => false,
14
+ isConnected: () => true,
15
+ getRuntimeType: () => 'browser',
16
+ evaluateExpressionDetailed: vi.fn(async () => ({ formatted: 'true', rawValue: true, rawCaptured: true })),
17
+ ...overrides,
18
+ };
19
+ }
20
+ function makeWait(cdpManager = makeCdpManager()) {
21
+ const resolve = vi.fn(async () => ({
22
+ connection: { port: 9222 },
23
+ cdpManager,
24
+ puppeteerManager: null,
25
+ }));
26
+ const { wait } = createWaitTools(resolve);
27
+ return { wait, resolve, cdpManager };
28
+ }
29
+ describe('buildPresencePredicate', () => {
30
+ it('compiles a plain CSS selector to a querySelector check', () => {
31
+ expect(buildPresencePredicate('#app .btn')).toBe('!!document.querySelector("#app .btn")');
32
+ });
33
+ it('compiles :has-text() to an inline synchronous text match (no element marking)', () => {
34
+ const built = buildPresencePredicate('button:has-text("Join")');
35
+ expect(typeof built).toBe('string');
36
+ const expr = built;
37
+ expect(expr).toContain('querySelectorAll("button")');
38
+ expect(expr).toContain('"Join"');
39
+ // Must be self-contained: no data-attribute marking that a navigation would lose
40
+ expect(expr).not.toContain('data-cdp-selector-match');
41
+ });
42
+ it('reports invalid extended selector syntax', () => {
43
+ const built = buildPresencePredicate('button:has-text(unquoted)');
44
+ expect(built).toHaveProperty('error');
45
+ });
46
+ });
47
+ describe('wait form validation', () => {
48
+ it('rejects zero forms', async () => {
49
+ const { wait } = makeWait();
50
+ const result = await wait.handler({});
51
+ expect(result.isError).toBe(true);
52
+ expect(result.content[0].text).toContain('exactly one');
53
+ });
54
+ it('rejects two forms at once', async () => {
55
+ const { wait } = makeWait();
56
+ const result = await wait.handler({ selector: '#a', ms: 100 });
57
+ expect(result.isError).toBe(true);
58
+ expect(result.content[0].text).toContain('selector + ms');
59
+ });
60
+ it('requires connectionReason for condition forms', async () => {
61
+ const { wait } = makeWait();
62
+ const result = await wait.handler({ selector: '#a' });
63
+ expect(result.isError).toBe(true);
64
+ expect(result.content[0].text).toContain('connectionReason');
65
+ });
66
+ });
67
+ describe('wait({ ms })', () => {
68
+ it('sleeps without touching the connection', async () => {
69
+ const { wait, resolve } = makeWait();
70
+ const start = Date.now();
71
+ const result = await wait.handler({ ms: 60 });
72
+ expect(result.isError).toBeUndefined();
73
+ expect(Date.now() - start).toBeGreaterThanOrEqual(55);
74
+ expect(resolve).not.toHaveBeenCalled();
75
+ expect(result._meta?.wait).toMatchObject({ form: 'ms', satisfied: true, polls: 0 });
76
+ });
77
+ });
78
+ describe('wait condition polling', () => {
79
+ it('returns as soon as the predicate flips true', async () => {
80
+ let calls = 0;
81
+ const cdp = makeCdpManager({
82
+ evaluateExpressionDetailed: vi.fn(async () => {
83
+ calls++;
84
+ return { formatted: String(calls >= 3), rawValue: calls >= 3, rawCaptured: true };
85
+ }),
86
+ });
87
+ const { wait } = makeWait(cdp);
88
+ const result = await wait.handler({
89
+ expression: 'window.__x === 1', connectionReason: 'test', pollIntervalMs: 25,
90
+ });
91
+ expect(result.isError).toBeUndefined();
92
+ expect(calls).toBe(3);
93
+ expect(result._meta?.wait).toMatchObject({ form: 'expression', satisfied: true, polls: 3 });
94
+ });
95
+ it('swallows evaluation errors mid-wait (context destroyed by navigation) and keeps polling', async () => {
96
+ let calls = 0;
97
+ const cdp = makeCdpManager({
98
+ evaluateExpressionDetailed: vi.fn(async () => {
99
+ calls++;
100
+ if (calls < 3)
101
+ throw new Error('Execution context was destroyed');
102
+ return { formatted: 'true', rawValue: true, rawCaptured: true };
103
+ }),
104
+ });
105
+ const { wait } = makeWait(cdp);
106
+ const result = await wait.handler({
107
+ selector: '#after-nav', connectionReason: 'test', pollIntervalMs: 25,
108
+ });
109
+ expect(result.isError).toBeUndefined();
110
+ expect(calls).toBe(3);
111
+ });
112
+ it('times out cleanly with WAIT_TIMEOUT instead of hanging', async () => {
113
+ const cdp = makeCdpManager({
114
+ evaluateExpressionDetailed: vi.fn(async () => ({ formatted: 'false', rawValue: false, rawCaptured: true })),
115
+ });
116
+ const { wait } = makeWait(cdp);
117
+ const result = await wait.handler({
118
+ expression: 'false', connectionReason: 'test', timeoutMs: 120, pollIntervalMs: 25,
119
+ });
120
+ expect(result.isError).toBe(true);
121
+ expect(result.content[0].text).toContain('Timed out after 120ms');
122
+ expect(result._meta?.wait).toMatchObject({ form: 'expression', satisfied: false });
123
+ });
124
+ it('includes the last evaluation error in the timeout message', async () => {
125
+ const cdp = makeCdpManager({
126
+ evaluateExpressionDetailed: vi.fn(async () => { throw new Error('myGlobal is not defined'); }),
127
+ });
128
+ const { wait } = makeWait(cdp);
129
+ const result = await wait.handler({
130
+ expression: 'myGlobal.ready', connectionReason: 'test', timeoutMs: 80, pollIntervalMs: 25,
131
+ });
132
+ expect(result.isError).toBe(true);
133
+ expect(result.content[0].text).toContain('myGlobal is not defined');
134
+ });
135
+ it('fails fast while the debugger is paused (nothing can change)', async () => {
136
+ const evaluate = vi.fn();
137
+ const cdp = makeCdpManager({ isPaused: () => true, evaluateExpressionDetailed: evaluate });
138
+ const { wait } = makeWait(cdp);
139
+ const start = Date.now();
140
+ const result = await wait.handler({
141
+ selector: '#x', connectionReason: 'test', timeoutMs: 5000,
142
+ });
143
+ expect(result.isError).toBe(true);
144
+ expect(result.content[0].text).toContain('paused');
145
+ expect(Date.now() - start).toBeLessThan(1000);
146
+ expect(evaluate).not.toHaveBeenCalled();
147
+ });
148
+ it('fails fast on an invalid CSS selector instead of polling out the timeout', async () => {
149
+ const cdp = makeCdpManager({
150
+ evaluateExpressionDetailed: vi.fn(async () => {
151
+ throw new Error(`'###' is not a valid selector`);
152
+ }),
153
+ });
154
+ const { wait } = makeWait(cdp);
155
+ const start = Date.now();
156
+ const result = await wait.handler({
157
+ selector: '###', connectionReason: 'test', timeoutMs: 10000,
158
+ });
159
+ expect(result.isError).toBe(true);
160
+ expect(result.content[0].text).toContain('not a valid selector');
161
+ expect(Date.now() - start).toBeLessThan(1000);
162
+ });
163
+ it('rejects selector waits against a Node.js target but allows expression waits', async () => {
164
+ const cdp = makeCdpManager({ getRuntimeType: () => 'node' });
165
+ const { wait } = makeWait(cdp);
166
+ const selectorResult = await wait.handler({ selector: '#x', connectionReason: 'node-app' });
167
+ expect(selectorResult.isError).toBe(true);
168
+ const exprResult = await wait.handler({ expression: 'true', connectionReason: 'node-app' });
169
+ expect(exprResult.isError).toBeUndefined();
170
+ });
171
+ it('negates the predicate for selectorGone', async () => {
172
+ const cdp = makeCdpManager();
173
+ const { wait } = makeWait(cdp);
174
+ await wait.handler({ selectorGone: '.spinner', connectionReason: 'test' });
175
+ const predicate = cdp.evaluateExpressionDetailed.mock.calls[0][0];
176
+ expect(predicate).toBe('!(!!document.querySelector(".spinner"))');
177
+ });
178
+ });
179
+ describe('executor integration', () => {
180
+ it('wait is injectable but only browser-bound in its selector forms', () => {
181
+ expect(TOOLS_ACCEPTING_CONNECTION).toContain('wait');
182
+ // ms sleeps and expression waits must never drag a Chrome auto-launch in
183
+ expect(TOOLS_NEEDING_CONNECTION).not.toContain('wait');
184
+ expect(commandNeedsBrowserConnection({ tool: 'wait', params: { ms: 500 } })).toBe(false);
185
+ expect(commandNeedsBrowserConnection({ tool: 'wait', params: { expression: 'x' } })).toBe(false);
186
+ expect(commandNeedsBrowserConnection({ tool: 'wait', params: { selector: '#a' } })).toBe(true);
187
+ expect(commandNeedsBrowserConnection({ tool: 'wait', params: { selectorGone: '#a' } })).toBe(true);
188
+ // unchanged for everything else
189
+ expect(commandNeedsBrowserConnection({ tool: 'navigate', params: {} })).toBe(true);
190
+ expect(commandNeedsBrowserConnection({ tool: 'inspect', params: {} })).toBe(false);
191
+ });
192
+ });
193
+ //# sourceMappingURL=wait-tools.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-tools.test.js","sourceRoot":"","sources":["../../src/tools/wait-tools.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAE9B,SAAS,cAAc,CAAC,YAKnB,EAAE;IACL,OAAO;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;QACrB,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI;QACvB,cAAc,EAAE,GAAG,EAAE,CAAC,SAAS;QAC/B,0BAA0B,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM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CAAC,6BAA6B,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzF,MAAM,CAAC,6BAA6B,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjG,MAAM,CAAC,6BAA6B,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/F,MAAM,CAAC,6BAA6B,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnG,gCAAgC;QAChC,MAAM,CAAC,6BAA6B,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnF,MAAM,CAAC,6BAA6B,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Type definitions for the CDP debugger
3
+ */
4
+ /**
5
+ * Executes a registered tool by name (the replay/issues subsystems' way of
6
+ * calling tools internally). The optional signal is forwarded to the tool's
7
+ * handler; handlers that honour it THROW an abort-shaped error (see
8
+ * utils/abort.ts isAbortError) rather than returning an isError response.
9
+ * One shared type so the next parameter is not added in twelve places again.
10
+ */
11
+ export type ExecuteToolCall = (toolName: string, params: Record<string, any>, abortSignal?: AbortSignal) => Promise<any>;
12
+ export interface BreakpointInfo {
13
+ breakpointId: string;
14
+ location: {
15
+ scriptId: string;
16
+ lineNumber: number;
17
+ columnNumber?: number;
18
+ };
19
+ originalLocation?: {
20
+ url: string;
21
+ lineNumber: number;
22
+ columnNumber?: number;
23
+ };
24
+ isLogpoint?: boolean;
25
+ /**
26
+ * Status of the breakpoint:
27
+ * - 'resolved': Breakpoint is set and bound to a loaded script
28
+ * - 'pending': Breakpoint is set but script hasn't loaded yet (will activate when script loads)
29
+ */
30
+ status?: 'resolved' | 'pending';
31
+ }
32
+ /**
33
+ * DOM Breakpoint types (from CDP DOMDebugger.DOMBreakpointType)
34
+ */
35
+ export type DOMBreakpointType = 'subtree-modified' | 'attribute-modified' | 'node-removed';
36
+ /**
37
+ * DOM Breakpoint info - pauses when DOM node is modified
38
+ */
39
+ export interface DOMBreakpointInfo {
40
+ breakpointId: string;
41
+ type: 'dom';
42
+ nodeId: number;
43
+ domBreakpointType: DOMBreakpointType;
44
+ selector: string;
45
+ }
46
+ /**
47
+ * Event Listener Breakpoint info - pauses when event fires
48
+ */
49
+ export interface EventListenerBreakpointInfo {
50
+ breakpointId: string;
51
+ type: 'event';
52
+ eventName: string;
53
+ targetName?: string;
54
+ }
55
+ /**
56
+ * XHR/Fetch Breakpoint info - pauses when network request matches URL
57
+ */
58
+ export interface XHRBreakpointInfo {
59
+ breakpointId: string;
60
+ type: 'xhr';
61
+ urlPattern: string;
62
+ }
63
+ export interface CallFrame {
64
+ callFrameId: string;
65
+ functionName: string;
66
+ location: {
67
+ scriptId: string;
68
+ lineNumber: number;
69
+ columnNumber: number;
70
+ };
71
+ url: string;
72
+ scopeChain: Scope[];
73
+ }
74
+ export interface Scope {
75
+ type: string;
76
+ object: {
77
+ objectId: string;
78
+ type: string;
79
+ className?: string;
80
+ };
81
+ name?: string;
82
+ }
83
+ export interface Variable {
84
+ name: string;
85
+ value: string;
86
+ type: string;
87
+ }
88
+ export type RuntimeType = 'chrome' | 'node' | 'unknown';
89
+ export interface DebuggerState {
90
+ connected: boolean;
91
+ paused: boolean;
92
+ currentCallFrames?: CallFrame[];
93
+ breakpoints: Map<string, BreakpointInfo>;
94
+ runtimeType?: RuntimeType;
95
+ }
96
+ /**
97
+ * CDP Runtime.consoleAPICalled event parameters
98
+ */
99
+ export interface CDPConsoleMessage {
100
+ type: 'log' | 'debug' | 'info' | 'error' | 'warning' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd';
101
+ args: Array<{
102
+ type: string;
103
+ subtype?: string;
104
+ className?: string;
105
+ value?: any;
106
+ description?: string;
107
+ objectId?: string;
108
+ unserializableValue?: string;
109
+ preview?: {
110
+ type: string;
111
+ description?: string;
112
+ overflow?: boolean;
113
+ properties?: Array<{
114
+ name: string;
115
+ type: string;
116
+ value?: string;
117
+ }>;
118
+ };
119
+ }>;
120
+ executionContextId: number;
121
+ timestamp: number;
122
+ stackTrace?: {
123
+ callFrames: Array<{
124
+ functionName: string;
125
+ scriptId: string;
126
+ url: string;
127
+ lineNumber: number;
128
+ columnNumber: number;
129
+ }>;
130
+ };
131
+ }
132
+ export type ConsoleMessageCallback = (message: CDPConsoleMessage) => void;
133
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,WAAW,CAAC,EAAE,WAAW,KACtB,OAAO,CAAC,GAAG,CAAC,CAAC;AAElB,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE;QACR,QAAQ,EAAE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AAC;YACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB,UAAU,CAAC,EAAE,KAAK,CAAC;gBACjB,IAAI,EAAE,MAAM,CAAC;gBACb,IAAI,EAAE,MAAM,CAAC;gBACb,KAAK,CAAC,EAAE,MAAM,CAAC;aAChB,CAAC,CAAC;SACJ,CAAC;KACH,CAAC,CAAC;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE;QACX,UAAU,EAAE,KAAK,CAAC;YAChB,YAAY,EAAE,MAAM,CAAC;YACrB,QAAQ,EAAE,MAAM,CAAC;YACjB,GAAG,EAAE,MAAM,CAAC;YACZ,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC,CAAC;KACJ,CAAC;CACH;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC"}
package/build/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Type definitions for the CDP debugger
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}