@speedkit/cli 4.50.4 → 4.51.0-run-control.1

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 (416) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1369 -10
  3. package/dist/base/run-control-command.d.ts +15 -0
  4. package/dist/base/run-control-command.js +20 -0
  5. package/dist/build-info.json +6 -0
  6. package/dist/commands/diff.d.ts +6 -1
  7. package/dist/commands/diff.js +9 -3
  8. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  9. package/dist/commands/onboarding/browser/click.js +19 -0
  10. package/dist/commands/onboarding/browser/emulate.d.ts +93 -0
  11. package/dist/commands/onboarding/browser/emulate.js +23 -0
  12. package/dist/commands/onboarding/browser/navigate.d.ts +67 -0
  13. package/dist/commands/onboarding/browser/navigate.js +18 -0
  14. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  15. package/dist/commands/onboarding/browser/panel.js +12 -0
  16. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  17. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  18. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  19. package/dist/commands/onboarding/browser/reset.js +18 -0
  20. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  21. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  22. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  23. package/dist/commands/onboarding/browser/state.js +12 -0
  24. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  25. package/dist/commands/onboarding/browser/tabs.js +16 -0
  26. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  27. package/dist/commands/onboarding/cache/clear.js +12 -0
  28. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  29. package/dist/commands/onboarding/cache/errors.js +12 -0
  30. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  31. package/dist/commands/onboarding/cache/evict.js +15 -0
  32. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  33. package/dist/commands/onboarding/cache/get.js +17 -0
  34. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  35. package/dist/commands/onboarding/cache/list.js +15 -0
  36. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  37. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  38. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  39. package/dist/commands/onboarding/cache/refresh.js +18 -0
  40. package/dist/commands/onboarding/cdp.d.ts +81 -0
  41. package/dist/commands/onboarding/cdp.js +18 -0
  42. package/dist/commands/onboarding/debug/arm.d.ts +77 -0
  43. package/dist/commands/onboarding/debug/arm.js +18 -0
  44. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  45. package/dist/commands/onboarding/debug/await.js +18 -0
  46. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  47. package/dist/commands/onboarding/debug/disarm.js +12 -0
  48. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  49. package/dist/commands/onboarding/debug/eval.js +16 -0
  50. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  51. package/dist/commands/onboarding/debug/release.js +12 -0
  52. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  53. package/dist/commands/onboarding/debug/resume.js +12 -0
  54. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  55. package/dist/commands/onboarding/debug/status.js +12 -0
  56. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  57. package/dist/commands/onboarding/debug/step.js +15 -0
  58. package/dist/commands/onboarding/files/list.d.ts +58 -0
  59. package/dist/commands/onboarding/files/list.js +12 -0
  60. package/dist/commands/onboarding/files/read.d.ts +73 -0
  61. package/dist/commands/onboarding/files/read.js +16 -0
  62. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  63. package/dist/commands/onboarding/files/rebuild.js +18 -0
  64. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  65. package/dist/commands/onboarding/files/validate.js +12 -0
  66. package/dist/commands/onboarding/fouc.d.ts +77 -0
  67. package/dist/commands/onboarding/fouc.js +16 -0
  68. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  69. package/dist/commands/onboarding/inject/add.js +17 -0
  70. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  71. package/dist/commands/onboarding/inject/clear.js +12 -0
  72. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  73. package/dist/commands/onboarding/inject/list.js +12 -0
  74. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  75. package/dist/commands/onboarding/inject/read.js +18 -0
  76. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  77. package/dist/commands/onboarding/inject/recipes.js +12 -0
  78. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  79. package/dist/commands/onboarding/inject/remove.js +15 -0
  80. package/dist/commands/onboarding/list.d.ts +13 -0
  81. package/dist/commands/onboarding/list.js +12 -0
  82. package/dist/commands/onboarding/logs.d.ts +41 -0
  83. package/dist/commands/onboarding/logs.js +256 -0
  84. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  85. package/dist/commands/onboarding/navwalk.js +19 -0
  86. package/dist/commands/onboarding/response.d.ts +67 -0
  87. package/dist/commands/onboarding/response.js +18 -0
  88. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  89. package/dist/commands/onboarding/rum/beacons.js +16 -0
  90. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  91. package/dist/commands/onboarding/rum/get.js +18 -0
  92. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  93. package/dist/commands/onboarding/rum/key.js +13 -0
  94. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  95. package/dist/commands/onboarding/rum/previous.js +12 -0
  96. package/dist/commands/onboarding/status.d.ts +13 -0
  97. package/dist/commands/onboarding/status.js +17 -0
  98. package/dist/commands/onboarding/todo.d.ts +58 -0
  99. package/dist/commands/onboarding/todo.js +12 -0
  100. package/dist/commands/onboarding/viewport.d.ts +101 -0
  101. package/dist/commands/onboarding/viewport.js +18 -0
  102. package/dist/commands/onboarding/watch.d.ts +93 -0
  103. package/dist/commands/onboarding/watch.js +16 -0
  104. package/dist/commands/onboarding.d.ts +26 -0
  105. package/dist/commands/onboarding.js +220 -3
  106. package/dist/commands/origin-request.d.ts +4 -0
  107. package/dist/commands/origin-request.js +4 -0
  108. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  109. package/dist/commands/spec/onboarding.spec.js +127 -0
  110. package/dist/services/cli/build-info.d.ts +33 -0
  111. package/dist/services/cli/build-info.js +63 -0
  112. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  113. package/dist/services/cli/cli-environment-factory.js +1 -0
  114. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  115. package/dist/services/cli/cli-service-factory.js +1 -1
  116. package/dist/services/cli/cli-service-model.d.ts +29 -10
  117. package/dist/services/cli/cli-service.d.ts +60 -11
  118. package/dist/services/cli/cli-service.js +196 -32
  119. package/dist/services/cli/index.d.ts +2 -0
  120. package/dist/services/cli/index.js +2 -0
  121. package/dist/services/cli/sink.d.ts +47 -0
  122. package/dist/services/cli/sink.js +31 -0
  123. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  124. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  125. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  126. package/dist/services/cli/spec/build-info.spec.js +10 -0
  127. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  128. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  129. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  130. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  131. package/dist/services/cli/spec/memory-cli.js +9 -0
  132. package/dist/services/diff/config-at-ref.d.ts +20 -0
  133. package/dist/services/diff/config-at-ref.js +33 -0
  134. package/dist/services/diff/diff-service-build-context.d.ts +8 -0
  135. package/dist/services/diff/diff-service-build-context.js +40 -1
  136. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  137. package/dist/services/diff/diff-service-factory.js +48 -20
  138. package/dist/services/diff/diff-service.d.ts +11 -0
  139. package/dist/services/diff/diff-service.js +37 -11
  140. package/dist/services/diff/page-source.d.ts +12 -0
  141. package/dist/services/diff/page-source.js +16 -11
  142. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  143. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  144. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  145. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  146. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  147. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  148. package/dist/services/git/git-repository.d.ts +2 -0
  149. package/dist/services/git/git-repository.js +6 -0
  150. package/dist/services/integration-api/customer-config-flags.js +1 -0
  151. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  152. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  153. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  154. package/dist/services/onboarding/browser/console-log.js +27 -0
  155. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  156. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  157. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  158. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  159. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  160. package/dist/services/onboarding/control/body-inspect.js +106 -0
  161. package/dist/services/onboarding/control/browser-session.d.ts +521 -0
  162. package/dist/services/onboarding/control/browser-session.js +1273 -0
  163. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  164. package/dist/services/onboarding/control/config-validation.js +46 -0
  165. package/dist/services/onboarding/control/control-protocol.d.ts +1390 -0
  166. package/dist/services/onboarding/control/control-protocol.js +69 -0
  167. package/dist/services/onboarding/control/control-server.d.ts +284 -0
  168. package/dist/services/onboarding/control/control-server.js +1609 -0
  169. package/dist/services/onboarding/control/debug-session.d.ts +190 -0
  170. package/dist/services/onboarding/control/debug-session.js +801 -0
  171. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  172. package/dist/services/onboarding/control/fouc.js +151 -0
  173. package/dist/services/onboarding/control/index.d.ts +4 -0
  174. package/dist/services/onboarding/control/index.js +4 -0
  175. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  176. package/dist/services/onboarding/control/navwalk.js +248 -0
  177. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  178. package/dist/services/onboarding/control/preload-registry.js +829 -0
  179. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  180. package/dist/services/onboarding/control/response-explainer.js +257 -0
  181. package/dist/services/onboarding/control/rum.d.ts +8 -0
  182. package/dist/services/onboarding/control/rum.js +220 -0
  183. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  184. package/dist/services/onboarding/control/service-worker-tracker.js +119 -0
  185. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  186. package/dist/services/onboarding/control/viewport.js +344 -0
  187. package/dist/services/onboarding/control/watch.d.ts +26 -0
  188. package/dist/services/onboarding/control/watch.js +149 -0
  189. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  190. package/dist/services/onboarding/dashboard/index.js +7 -2
  191. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  192. package/dist/services/onboarding/fetch-event-handler.js +94 -32
  193. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +4 -25
  194. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  195. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  196. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  197. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  198. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  199. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  200. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  201. package/dist/services/onboarding/html-charset.d.ts +28 -0
  202. package/dist/services/onboarding/html-charset.js +57 -0
  203. package/dist/services/onboarding/onboarding-model.d.ts +30 -1
  204. package/dist/services/onboarding/onboarding-model.js +10 -1
  205. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  206. package/dist/services/onboarding/onboarding-service-build-context.js +6 -0
  207. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  208. package/dist/services/onboarding/onboarding-service-factory.js +131 -17
  209. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  210. package/dist/services/onboarding/onboarding-service.js +135 -22
  211. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  212. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  213. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  214. package/dist/services/onboarding/request-cache/cache.js +128 -17
  215. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  216. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  217. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  218. package/dist/services/onboarding/spec/control/browser-session.spec.js +526 -0
  219. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  220. package/dist/services/onboarding/spec/control/control-server.spec.js +338 -0
  221. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  222. package/dist/services/onboarding/spec/control/debug-session.spec.js +693 -0
  223. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  224. package/dist/services/onboarding/spec/control/fakes.js +66 -0
  225. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  226. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  227. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  228. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  229. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  230. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  231. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  232. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  233. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  234. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  235. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  236. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  237. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  238. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  239. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  240. package/dist/services/onboarding/spec/control/watch.spec.js +172 -0
  241. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  242. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +202 -0
  243. package/dist/services/onboarding/spec/fetch-events/customer-domain-document-response.spec.d.ts +1 -0
  244. package/dist/services/onboarding/spec/fetch-events/customer-domain-document-response.spec.js +39 -0
  245. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  246. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  247. package/dist/services/onboarding/spec/html-charset.spec.d.ts +1 -0
  248. package/dist/services/onboarding/spec/html-charset.spec.js +58 -0
  249. package/dist/services/onboarding/spec/onboarding-model.spec.js +37 -0
  250. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -0
  251. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  252. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  253. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  254. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  255. package/dist/services/onboarding/spec/virtual-orestes-app/index.spec.d.ts +1 -0
  256. package/dist/services/onboarding/spec/virtual-orestes-app/index.spec.js +19 -0
  257. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  258. package/dist/services/onboarding/todo-collector.js +49 -12
  259. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +34 -0
  260. package/dist/services/onboarding/virtual-orestes-app/index.js +85 -53
  261. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  262. package/dist/services/origin-request/asset-variations.js +11 -4
  263. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  264. package/dist/services/origin-request/origin-fetcher.js +43 -5
  265. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  266. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  267. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  268. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  269. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  270. package/dist/services/origin-request/origin-request-service.js +273 -49
  271. package/dist/services/origin-request/runtime-config-source.js +9 -4
  272. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  273. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  274. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  275. package/dist/services/query-builder/rules/rule-match.js +70 -0
  276. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  277. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  278. package/dist/services/run-control/browser/run-browser-contexts.d.ts +541 -0
  279. package/dist/services/run-control/browser/run-browser-contexts.js +78 -0
  280. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  281. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  282. package/dist/services/run-control/browser/run-browser-service.d.ts +64 -0
  283. package/dist/services/run-control/browser/run-browser-service.js +199 -0
  284. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  285. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  286. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  287. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  288. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  289. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  290. package/dist/services/run-control/control-client.d.ts +36 -0
  291. package/dist/services/run-control/control-client.js +147 -0
  292. package/dist/services/run-control/debug/run-debug-contexts.d.ts +411 -0
  293. package/dist/services/run-control/debug/run-debug-contexts.js +44 -0
  294. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  295. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  296. package/dist/services/run-control/debug/run-debug-service.d.ts +38 -0
  297. package/dist/services/run-control/debug/run-debug-service.js +161 -0
  298. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  299. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  300. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  301. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  302. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  303. package/dist/services/run-control/files/run-files-service.js +120 -0
  304. package/dist/services/run-control/index.d.ts +32 -0
  305. package/dist/services/run-control/index.js +31 -0
  306. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  307. package/dist/services/run-control/inject/run-inject-contexts.js +32 -0
  308. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  309. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  310. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  311. package/dist/services/run-control/inject/run-inject-service.js +203 -0
  312. package/dist/services/run-control/live-run.d.ts +37 -0
  313. package/dist/services/run-control/live-run.js +56 -0
  314. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  315. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  316. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  317. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  318. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  319. package/dist/services/run-control/probe/run-probe-service.js +193 -0
  320. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  321. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  322. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  323. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  324. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  325. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  326. package/dist/services/run-control/run-answer.d.ts +28 -0
  327. package/dist/services/run-control/run-answer.js +58 -0
  328. package/dist/services/run-control/run-control-context.d.ts +102 -0
  329. package/dist/services/run-control/run-control-context.js +36 -0
  330. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  331. package/dist/services/run-control/run-control-flags.js +22 -0
  332. package/dist/services/run-control/run-control-model.d.ts +9 -0
  333. package/dist/services/run-control/run-control-model.js +1 -0
  334. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  335. package/dist/services/run-control/run-control-service-factory.js +26 -0
  336. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  337. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  338. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  339. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  340. package/dist/services/run-control/session/run-session-service.d.ts +25 -0
  341. package/dist/services/run-control/session/run-session-service.js +95 -0
  342. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  343. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
  344. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  345. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  346. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  347. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  348. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  349. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  350. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  351. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +224 -0
  352. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  353. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  354. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  355. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  356. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  357. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  358. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  359. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  360. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  361. package/dist/services/run-control/spec/session/run-session-service.spec.js +101 -0
  362. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  363. package/dist/services/run-log/crash-mirror.js +69 -0
  364. package/dist/services/run-log/index.d.ts +11 -0
  365. package/dist/services/run-log/index.js +11 -0
  366. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  367. package/dist/services/run-log/jsonl-appender.js +91 -0
  368. package/dist/services/run-log/log-event-model.d.ts +104 -0
  369. package/dist/services/run-log/log-event-model.js +56 -0
  370. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  371. package/dist/services/run-log/log-query-service-factory.js +14 -0
  372. package/dist/services/run-log/log-query-service.d.ts +59 -0
  373. package/dist/services/run-log/log-query-service.js +111 -0
  374. package/dist/services/run-log/log-reader.d.ts +84 -0
  375. package/dist/services/run-log/log-reader.js +180 -0
  376. package/dist/services/run-log/log-summary.d.ts +72 -0
  377. package/dist/services/run-log/log-summary.js +208 -0
  378. package/dist/services/run-log/redaction.d.ts +34 -0
  379. package/dist/services/run-log/redaction.js +124 -0
  380. package/dist/services/run-log/request-log.d.ts +80 -0
  381. package/dist/services/run-log/request-log.js +69 -0
  382. package/dist/services/run-log/request-summary.d.ts +76 -0
  383. package/dist/services/run-log/request-summary.js +0 -0
  384. package/dist/services/run-log/run-log.d.ts +61 -0
  385. package/dist/services/run-log/run-log.js +102 -0
  386. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  387. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  388. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  389. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  390. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  391. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  392. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  393. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  394. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  395. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  396. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  397. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  398. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  399. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  400. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  401. package/dist/services/run-registry/exit-classification.js +42 -0
  402. package/dist/services/run-registry/index.d.ts +3 -0
  403. package/dist/services/run-registry/index.js +3 -0
  404. package/dist/services/run-registry/process-identity.d.ts +28 -0
  405. package/dist/services/run-registry/process-identity.js +80 -0
  406. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  407. package/dist/services/run-registry/run-registry-model.js +16 -0
  408. package/dist/services/run-registry/run-registry.d.ts +150 -0
  409. package/dist/services/run-registry/run-registry.js +409 -0
  410. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  411. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  412. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  413. package/dist/services/run-registry/spec/run-registry.spec.js +509 -0
  414. package/dist/services/setup/os/tool-registry.js +2 -2
  415. package/oclif.manifest.json +3293 -272
  416. package/package.json +21 -3
@@ -0,0 +1,23 @@
1
+ import { FoucData } from "./control-protocol.js";
2
+ import { PreloadRegistry } from "./preload-registry.js";
3
+ export interface FoucOptions {
4
+ selector?: string;
5
+ durationMs?: number;
6
+ }
7
+ /**
8
+ * Catch a paint that happened before the page was styled.
9
+ *
10
+ * The symptom is a flash of unstyled content, and it is the one Speed Kit
11
+ * failure that is invisible by the time anyone can look: by the end of the load
12
+ * the page is styled, so every after-the-fact inspection says it is fine. The
13
+ * only way to see it is to sample across the load itself.
14
+ *
15
+ * The test is a comparison rather than a screenshot: did a contentful paint
16
+ * happen while the document had fewer stylesheets applied than it ended up
17
+ * with. That is a heuristic and it is worth knowing which way it errs — a page
18
+ * that loads a late, purely decorative sheet reads as a flash it never had, and
19
+ * a page whose first sheet arrives with the document but applies to nothing
20
+ * reads as clean. The samples are returned so the verdict can be checked rather
21
+ * than taken.
22
+ */
23
+ export declare function runFouc(preloads: PreloadRegistry, reload: () => Promise<void>, options: FoucOptions): Promise<FoucData>;
@@ -0,0 +1,151 @@
1
+ /** Fast enough to land between a paint and the stylesheet that follows it. */
2
+ const SAMPLE_MS = 16;
3
+ const DEFAULT_DURATION_MS = 8_000;
4
+ const MAX_DURATION_MS = 60_000;
5
+ /**
6
+ * Catch a paint that happened before the page was styled.
7
+ *
8
+ * The symptom is a flash of unstyled content, and it is the one Speed Kit
9
+ * failure that is invisible by the time anyone can look: by the end of the load
10
+ * the page is styled, so every after-the-fact inspection says it is fine. The
11
+ * only way to see it is to sample across the load itself.
12
+ *
13
+ * The test is a comparison rather than a screenshot: did a contentful paint
14
+ * happen while the document had fewer stylesheets applied than it ended up
15
+ * with. That is a heuristic and it is worth knowing which way it errs — a page
16
+ * that loads a late, purely decorative sheet reads as a flash it never had, and
17
+ * a page whose first sheet arrives with the document but applies to nothing
18
+ * reads as clean. The samples are returned so the verdict can be checked rather
19
+ * than taken.
20
+ */
21
+ export async function runFouc(preloads, reload, options) {
22
+ const durationMs = Math.min(MAX_DURATION_MS, Math.max(1_000, options.durationMs ?? DEFAULT_DURATION_MS));
23
+ const selector = options.selector ?? null;
24
+ await preloads.reserve("fouc", foucScript(selector));
25
+ try {
26
+ // Always: a sampler installed mid-life has already missed the only moment
27
+ // that matters.
28
+ await reload();
29
+ await delay(durationMs);
30
+ const read = await preloads.read("fouc", Number.MAX_SAFE_INTEGER);
31
+ const samples = (read.records ?? [])
32
+ .map(({ t, v }) => ({ t, ...v }))
33
+ .filter((sample) => typeof sample.sheets === "number");
34
+ return analyse(samples, selector, durationMs);
35
+ }
36
+ finally {
37
+ await preloads.release("fouc").catch(() => undefined);
38
+ }
39
+ }
40
+ function analyse(samples, selector, durationMs) {
41
+ const sheetsFinal = samples.length > 0 ? samples[samples.length - 1].sheets : null;
42
+ const firstPainted = samples.find((sample) => sample.painted) ?? null;
43
+ const fcp = firstPainted?.fcp ?? null;
44
+ // The document as the paint found it: the last sample taken before it, on
45
+ // the same clock. The first sample *after* it can already have the sheet the
46
+ // paint went without.
47
+ const atPaint = fcp === null
48
+ ? firstPainted
49
+ : ([...samples].reverse().find((sample) => sample.t <= fcp) ??
50
+ firstPainted);
51
+ const settled = sheetsFinal === null
52
+ ? null
53
+ : (samples.find((sample) => sample.sheets === sheetsFinal) ?? null);
54
+ const sheetsAtPaint = atPaint?.sheets ?? null;
55
+ const pendingAtPaint = atPaint?.pending ?? [];
56
+ const unstyledPaint = (atPaint?.pendingCount ?? 0) > 0;
57
+ const lateSheets = sheetsAtPaint === null || sheetsFinal === null
58
+ ? null
59
+ : Math.max(0, sheetsFinal - sheetsAtPaint);
60
+ const backgrounds = [];
61
+ let previous;
62
+ for (const sample of samples) {
63
+ if (sample.background !== previous) {
64
+ backgrounds.push({ t: sample.t, value: sample.background });
65
+ previous = sample.background;
66
+ }
67
+ }
68
+ const paintedAt = fcp === null ? (firstPainted?.t ?? null) : Math.round(fcp);
69
+ return {
70
+ selector,
71
+ durationMs,
72
+ unstyledPaint,
73
+ paintedAt,
74
+ settledAt: settled?.t ?? null,
75
+ sheetsAtPaint,
76
+ sheetsFinal,
77
+ pendingAtPaint,
78
+ lateSheets,
79
+ backgrounds,
80
+ samples,
81
+ verdict: verdictFor(samples, {
82
+ paintedAt,
83
+ pendingCount: atPaint?.pendingCount ?? 0,
84
+ pendingAtPaint,
85
+ lateSheets,
86
+ }),
87
+ };
88
+ }
89
+ /**
90
+ * Unstyled means a stylesheet that was already in the document had not loaded
91
+ * when the page painted. It used to mean "fewer sheets than at the end", and a
92
+ * widget inserting its own sheets after the paint made every load read as a
93
+ * flash, with numbers that changed from run to run.
94
+ */
95
+ function verdictFor(samples, { paintedAt, pendingCount, pendingAtPaint, lateSheets }) {
96
+ if (samples.length === 0) {
97
+ return "nothing was sampled — the page did not load within the window, or the preload never ran.";
98
+ }
99
+ if (paintedAt === null) {
100
+ return "no contentful paint in the window. Nothing rendered, so there was nothing to flash — look at why the page did not paint.";
101
+ }
102
+ const late = lateSheets && lateSheets > 0
103
+ ? ` ${lateSheets} more stylesheet${lateSheets === 1 ? " was" : "s were"} added after the paint, by script; a paint cannot wait for those, so they are not counted — if one of them styles what is on screen, look at the backgrounds.`
104
+ : "";
105
+ if (pendingCount > 0) {
106
+ return `painted at ${paintedAt}ms while ${pendingCount} stylesheet${pendingCount === 1 ? "" : "s"} already in the document had not loaded (${pendingAtPaint.join(", ")}${pendingCount > pendingAtPaint.length ? ", …" : ""}) — content was on screen before the page was styled.${late}`;
107
+ }
108
+ return `painted at ${paintedAt}ms with every stylesheet in the document loaded — no unstyled paint in this load.${late}`;
109
+ }
110
+ function delay(ms) {
111
+ return new Promise((resolve) => {
112
+ const timer = setTimeout(resolve, ms);
113
+ timer.unref();
114
+ });
115
+ }
116
+ /**
117
+ * The sampler, reading the three things a flash shows up in.
118
+ *
119
+ * The sheet count is the signal; the paint entry is the clock; the background
120
+ * is the corroboration a human can recognise, because a flash is nearly always
121
+ * a background going from white to the brand colour or the other way about.
122
+ */
123
+ function foucScript(selector) {
124
+ return `
125
+ var target = ${JSON.stringify(selector)};
126
+
127
+ var take = guard(function () {
128
+ var element = target ? document.querySelector(target) : document.body;
129
+ var painted = false;
130
+ try {
131
+ painted = (performance.getEntriesByType("paint") || []).some(function (entry) {
132
+ return entry.name === "first-contentful-paint";
133
+ });
134
+ } catch (ignored) {
135
+ // Not every engine exposes paint timing; the sheet count still works.
136
+ }
137
+
138
+ record({
139
+ sheets: (document.styleSheets || []).length,
140
+ painted: painted,
141
+ present: Boolean(element),
142
+ background: element ? getComputedStyle(element).backgroundColor : null
143
+ });
144
+ });
145
+
146
+ take();
147
+ var timer = setInterval(function () {
148
+ if (slot.disabled) { clearInterval(timer); return; }
149
+ take();
150
+ }, ${SAMPLE_MS});`;
151
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./browser-session.js";
2
+ export * from "./control-protocol.js";
3
+ export * from "./control-server.js";
4
+ export * from "./service-worker-tracker.js";
@@ -0,0 +1,4 @@
1
+ export * from "./browser-session.js";
2
+ export * from "./control-protocol.js";
3
+ export * from "./control-server.js";
4
+ export * from "./service-worker-tracker.js";
@@ -0,0 +1,65 @@
1
+ import { NavwalkData, NavwalkFlow } from "./control-protocol.js";
2
+ export declare class NoTriggerError extends Error {
3
+ readonly code = "NO_TRIGGER";
4
+ }
5
+ /** One Document request, before it is deduped and classified. */
6
+ export interface RawDocumentHit {
7
+ url: string;
8
+ status: number | null;
9
+ /** False for a request seen in a popup the flow opened. */
10
+ main: boolean;
11
+ }
12
+ /**
13
+ * What walking a flow needs from the browser.
14
+ *
15
+ * `collectDocumentRequests` is the whole reason this is not a page-level
16
+ * capability: the hops that matter happen in targets the main page does not
17
+ * own, and a capture scoped to one target misses precisely the ones worth
18
+ * having.
19
+ */
20
+ export interface NavwalkBrowser {
21
+ url(): string | null;
22
+ evaluate<T>(expression: string): Promise<T>;
23
+ /** The return is ignored; `BrowserController` answers with more. */
24
+ navigate(url: string): Promise<unknown>;
25
+ /** Watch every target now open and every one that appears. Returns a stop. */
26
+ collectDocumentRequests(onHit: (hit: RawDocumentHit) => void): Promise<() => Promise<void>>;
27
+ }
28
+ export interface NavwalkOptions {
29
+ flow?: NavwalkFlow;
30
+ click?: string;
31
+ url?: string;
32
+ waitMs?: number;
33
+ /**
34
+ * Pages this run knows to be accelerated — what the documentHandler has
35
+ * cached. A prefix that would also disable one of them is too broad, and is
36
+ * dropped from the candidates with the page it would have caught.
37
+ */
38
+ knownPages?: string[];
39
+ }
40
+ /**
41
+ * Walk a login or checkout flow and report every same-origin document hop.
42
+ *
43
+ * `tools/sk-auth-walk.mjs` promoted. It exists because the obvious tools answer
44
+ * the wrong question: a network list scoped to the main target since the last
45
+ * navigation misses the interim 302s once the flow bounces off-domain, and
46
+ * misses document requests in the popup a "sign in with…" control opens. Those
47
+ * are exactly the hops that have to be named in `disabledScopes`, and they are
48
+ * invisible in a single-target snapshot.
49
+ *
50
+ * The output is candidates, not an answer. Which prefix to write is a judgement
51
+ * about what else it would catch, and that lives in the config rather than in
52
+ * this capture.
53
+ */
54
+ export declare function runNavwalk(browser: NavwalkBrowser, options: NavwalkOptions): Promise<NavwalkData>;
55
+ /**
56
+ * Drop every candidate that would also disable a page known to be accelerated.
57
+ *
58
+ * `/it-it` is a prefix of the login hop on a site whose every page sits under
59
+ * `/it-it`, and offering it as a scope offers to switch Speed Kit off for the
60
+ * whole market. The evidence is concrete pages — the one the walk started on,
61
+ * and what the documentHandler cached — rather than a reading of the
62
+ * `enabledSites` patterns, which can be regexes. A page the flow itself hit is
63
+ * not evidence against its own scope.
64
+ */
65
+ export declare function pruneScopes(data: NavwalkData, knownPages: string[]): NavwalkData;
@@ -0,0 +1,248 @@
1
+ /** Long enough for a redirect chain and an auth bounce to finish. */
2
+ const DEFAULT_WAIT_MS = 9_000;
3
+ /**
4
+ * The header account control, in the languages the customers are in.
5
+ *
6
+ * Matched against text, `aria-label` and `href`, because a shop that shows an
7
+ * icon has the word only in one of the three.
8
+ */
9
+ const LOGIN_MATCH = "log\\s?in|sign\\s?in|anmelden|mein konto|my account|/account|/login|/customer";
10
+ /** The cart's checkout CTA, reached after landing on `/cart`. */
11
+ const CHECKOUT_MATCH = "check\\s?out|zur kasse|kasse|proceed|/checkout|bezahlen";
12
+ export class NoTriggerError extends Error {
13
+ code = "NO_TRIGGER";
14
+ }
15
+ /**
16
+ * Walk a login or checkout flow and report every same-origin document hop.
17
+ *
18
+ * `tools/sk-auth-walk.mjs` promoted. It exists because the obvious tools answer
19
+ * the wrong question: a network list scoped to the main target since the last
20
+ * navigation misses the interim 302s once the flow bounces off-domain, and
21
+ * misses document requests in the popup a "sign in with…" control opens. Those
22
+ * are exactly the hops that have to be named in `disabledScopes`, and they are
23
+ * invisible in a single-target snapshot.
24
+ *
25
+ * The output is candidates, not an answer. Which prefix to write is a judgement
26
+ * about what else it would catch, and that lives in the config rather than in
27
+ * this capture.
28
+ */
29
+ export async function runNavwalk(browser, options) {
30
+ const waitMs = Math.min(60_000, Math.max(500, options.waitMs ?? DEFAULT_WAIT_MS));
31
+ const flow = options.flow ?? (options.click ? null : "login");
32
+ // Where to put the tab back, and the first page a candidate must not cover:
33
+ // the walk starts on an ordinary accelerated page, almost by definition.
34
+ const startedOn = browser.url();
35
+ if (options.url) {
36
+ await browser.navigate(options.url);
37
+ await settle();
38
+ }
39
+ // The checkout CTA is on the cart, so a walk that starts anywhere else clicks
40
+ // whatever happens to match and reports a flow it never entered.
41
+ if (flow === "checkout") {
42
+ const origin = await browser.evaluate("location.origin");
43
+ await browser.navigate(`${origin}/cart`);
44
+ await settle();
45
+ }
46
+ const hits = [];
47
+ const stop = await browser.collectDocumentRequests((hit) => hits.push(hit));
48
+ try {
49
+ const host = await browser.evaluate("location.host");
50
+ // Everything captured so far belongs to the page that is already loaded —
51
+ // ambient iframes, pixel sandboxes, a Shopify web-pixel worker. Only hops
52
+ // the trigger produces are scope candidates.
53
+ hits.length = 0;
54
+ const clicked = await browser.evaluate(clickExpression(triggerFor(flow, options.click), selectorFor(options.click)));
55
+ if (clicked === "NONE") {
56
+ throw new NoTriggerError(`nothing on the page matched the trigger — pass \`click\` with the control's text or a CSS selector for the ${flow ?? "flow"} entry point`);
57
+ }
58
+ await delay(waitMs);
59
+ const walked = shape(hits, { host, clicked, flow, waitedMs: waitMs });
60
+ const pruned = pruneScopes(walked, [
61
+ ...[startedOn, options.url].filter(Boolean),
62
+ ...(options.knownPages ?? []),
63
+ ]);
64
+ return { ...pruned, startedOn, ...(await goBack(browser, startedOn)) };
65
+ }
66
+ finally {
67
+ await stop();
68
+ }
69
+ }
70
+ /**
71
+ * Put the tab back where the walk found it.
72
+ *
73
+ * A login flow ends on an identity provider as often as not, and a run left
74
+ * there makes every later op answer about the wrong site. When going back
75
+ * fails, the answer says where the tab was left instead.
76
+ */
77
+ async function goBack(browser, startedOn) {
78
+ const endedOn = browser.url();
79
+ if (!startedOn || endedOn === startedOn) {
80
+ return { endedOn, returned: false };
81
+ }
82
+ try {
83
+ await browser.navigate(startedOn);
84
+ return { endedOn, returned: true };
85
+ }
86
+ catch {
87
+ return { endedOn, returned: false };
88
+ }
89
+ }
90
+ /**
91
+ * Drop every candidate that would also disable a page known to be accelerated.
92
+ *
93
+ * `/it-it` is a prefix of the login hop on a site whose every page sits under
94
+ * `/it-it`, and offering it as a scope offers to switch Speed Kit off for the
95
+ * whole market. The evidence is concrete pages — the one the walk started on,
96
+ * and what the documentHandler cached — rather than a reading of the
97
+ * `enabledSites` patterns, which can be regexes. A page the flow itself hit is
98
+ * not evidence against its own scope.
99
+ */
100
+ export function pruneScopes(data, knownPages) {
101
+ const flowPaths = new Set(data.sameOrigin.map((hit) => hit.path));
102
+ const guarded = knownPages
103
+ .map((page) => {
104
+ try {
105
+ return new URL(page);
106
+ }
107
+ catch {
108
+ return null;
109
+ }
110
+ })
111
+ .filter((url) => url !== null && url.host === data.host)
112
+ .filter((url) => !flowPaths.has(url.pathname));
113
+ const droppedScopes = [];
114
+ const keep = (scope) => {
115
+ const covered = guarded.find((url) => url.pathname === scope || url.pathname.startsWith(`${scope}/`));
116
+ if (covered) {
117
+ droppedScopes.push({ scope, covers: covered.href });
118
+ return false;
119
+ }
120
+ return true;
121
+ };
122
+ return {
123
+ ...data,
124
+ candidateScopes: {
125
+ depth1: data.candidateScopes.depth1.filter(keep),
126
+ depth2: data.candidateScopes.depth2.filter(keep),
127
+ },
128
+ droppedScopes,
129
+ };
130
+ }
131
+ function triggerFor(flow, click) {
132
+ if (click && !/[.#[]/.test(click)) {
133
+ return click;
134
+ }
135
+ if (flow === "checkout") {
136
+ return CHECKOUT_MATCH;
137
+ }
138
+ return flow === "login" ? LOGIN_MATCH : null;
139
+ }
140
+ /** A CSS selector is anything with a selector character in it. */
141
+ function selectorFor(click) {
142
+ return click && /[.#[]/.test(click) ? click : null;
143
+ }
144
+ function shape(hits, { host, clicked, flow, waitedMs }) {
145
+ // One entry per url, preferring the one that carries a status: the request
146
+ // and its response arrive as two events and only the second knows the code.
147
+ const byUrl = new Map();
148
+ for (const hit of hits) {
149
+ const previous = byUrl.get(hit.url);
150
+ if (!previous || (previous.status === null && hit.status !== null)) {
151
+ byUrl.set(hit.url, hit);
152
+ }
153
+ }
154
+ const all = [];
155
+ for (const hit of byUrl.values()) {
156
+ let parsed;
157
+ try {
158
+ parsed = new URL(hit.url);
159
+ }
160
+ catch {
161
+ continue;
162
+ }
163
+ all.push({
164
+ url: hit.url,
165
+ path: parsed.pathname,
166
+ status: hit.status,
167
+ target: hit.main ? "main" : "popup",
168
+ sameOrigin: parsed.host === host,
169
+ });
170
+ }
171
+ const sameOrigin = all.filter((hit) => hit.sameOrigin);
172
+ const offOrigin = all.filter((hit) => !hit.sameOrigin);
173
+ const depth1 = new Set();
174
+ const depth2 = new Set();
175
+ for (const hit of sameOrigin) {
176
+ const segments = hit.path.split("/").filter(Boolean);
177
+ if (segments.length >= 1) {
178
+ depth1.add(`/${segments[0]}`);
179
+ }
180
+ if (segments.length >= 2) {
181
+ depth2.add(`/${segments.slice(0, 2).join("/")}`);
182
+ }
183
+ }
184
+ return {
185
+ host,
186
+ clicked,
187
+ flow,
188
+ waitedMs,
189
+ sameOrigin,
190
+ offOrigin,
191
+ candidateScopes: {
192
+ depth1: [...depth1].sort(),
193
+ depth2: [...depth2].sort(),
194
+ },
195
+ droppedScopes: [],
196
+ startedOn: null,
197
+ endedOn: null,
198
+ returned: false,
199
+ };
200
+ }
201
+ /**
202
+ * Find the control and click it, returning what it clicked.
203
+ *
204
+ * Evaluated in the page rather than driven through a selector API, so it works
205
+ * whatever the site is built with — and it clicks the real control instead of
206
+ * navigating to a guessed url, which is the point: the hops are produced by
207
+ * what the control actually does.
208
+ */
209
+ function clickExpression(matchText, selector) {
210
+ return `(function (matchText, selector) {
211
+ function visible(element) {
212
+ var box = element.getBoundingClientRect();
213
+ return box.width > 0 && box.height > 0;
214
+ }
215
+
216
+ var found = null;
217
+ if (selector) found = document.querySelector(selector);
218
+ if (!found && matchText) {
219
+ var pattern = new RegExp(matchText, "i");
220
+ found = Array.prototype.slice
221
+ .call(document.querySelectorAll("a,button,[role=button]"))
222
+ .filter(visible)
223
+ .find(function (element) {
224
+ return (
225
+ pattern.test((element.textContent || "").trim()) ||
226
+ pattern.test(element.getAttribute("aria-label") || "") ||
227
+ pattern.test(element.getAttribute("href") || "")
228
+ );
229
+ });
230
+ }
231
+ if (!found) return "NONE";
232
+
233
+ var label = (found.textContent || found.getAttribute("aria-label") || "").trim();
234
+ found.click();
235
+ return found.tagName.toLowerCase() + ' "' + label.slice(0, 40) + '" href=' +
236
+ (found.getAttribute("href") || "-");
237
+ })(${JSON.stringify(matchText)}, ${JSON.stringify(selector)})`;
238
+ }
239
+ /** Long enough for a navigation this function asked for to have started. */
240
+ function settle() {
241
+ return delay(2_500);
242
+ }
243
+ function delay(ms) {
244
+ return new Promise((resolve) => {
245
+ const timer = setTimeout(resolve, ms);
246
+ timer.unref();
247
+ });
248
+ }
@@ -0,0 +1,150 @@
1
+ import { InjectAddData, InjectListData, InjectReadData, InjectRecipeParam, InjectRecipesData, InjectRemoveData } from "./control-protocol.js";
2
+ /** How many may be registered at once. */
3
+ export declare const PRELOAD_LIMIT = 8;
4
+ /** Minutes a preload lives for when the caller names no TTL. */
5
+ export declare const DEFAULT_TTL_MINUTES = 30;
6
+ /**
7
+ * What the registry needs from the browser, and nothing else.
8
+ *
9
+ * The same argument {@link PageEvaluator} makes: handed a `Page` or a
10
+ * `CDPSession`, this would grow reasons to reach for the rest of CDP. Three
11
+ * methods are the whole of what managing preloads takes, and they are trivially
12
+ * faked, so the recipes can be tested for what they *emit* without a browser.
13
+ */
14
+ export interface PreloadTransport {
15
+ /** Whether there is a document to register against at all. */
16
+ readonly pageAvailable: boolean;
17
+ /** `Page.addScriptToEvaluateOnNewDocument`; returns its identifier. */
18
+ addScript(source: string): Promise<string>;
19
+ removeScript(identifier: string): Promise<void>;
20
+ /** `Runtime.evaluate`, never `page.evaluate` — the page may be paused. */
21
+ evaluate<T>(expression: string): Promise<T>;
22
+ }
23
+ export declare class NoSuchPreloadError extends Error {
24
+ readonly code = "NO_SUCH_PRELOAD";
25
+ }
26
+ export declare class UnknownRecipeError extends Error {
27
+ readonly recipes: string[];
28
+ readonly code = "UNKNOWN_RECIPE";
29
+ constructor(message: string, recipes: string[]);
30
+ }
31
+ export declare class BadRecipeParamsError extends Error {
32
+ readonly params: InjectRecipeParam[];
33
+ readonly code = "BAD_RECIPE_PARAMS";
34
+ constructor(message: string, params: InjectRecipeParam[]);
35
+ }
36
+ export declare class InjectSourceRequiredError extends Error {
37
+ readonly code = "INJECT_SOURCE_REQUIRED";
38
+ }
39
+ export declare class TooManyPreloadsError extends Error {
40
+ readonly registered: string[];
41
+ readonly code = "TOO_MANY_PRELOADS";
42
+ constructor(message: string, registered: string[]);
43
+ }
44
+ /**
45
+ * The key a reserved preload is filed under.
46
+ *
47
+ * A reserved entry belongs to another tool rather than to a caller of
48
+ * `sk onboarding inject`, so it is addressed by a stable name instead of an allocated id.
49
+ */
50
+ export type ReservedPreload = "debug" | "watch" | "fouc";
51
+ /**
52
+ * The preloads a run has registered, and the only thing allowed to add one.
53
+ *
54
+ * Three consumers wanted `Page.addScriptToEvaluateOnNewDocument` — the sampler,
55
+ * the breakpoint bridge's flag delivery, and injected hooks — and three ad-hoc
56
+ * call sites would have meant three ways to leave a script behind. A preload
57
+ * outlives the turn that added it, survives every navigation, and is invisible
58
+ * to the human watching the run's output. So it is registered in one place that
59
+ * can list them, expire them, and switch off the copy already running.
60
+ */
61
+ export declare class PreloadRegistry {
62
+ private readonly transport;
63
+ /**
64
+ * Told whenever what is installed changes.
65
+ *
66
+ * The hook the tab marker hangs off: "an agent has left something in this
67
+ * page" is exactly the set of moments this fires on, and it is the
68
+ * condition worth showing rather than the fact that a tool ran.
69
+ */
70
+ private readonly onChange?;
71
+ private readonly registered;
72
+ /** Set while a retire is in flight, so one notification covers the batch. */
73
+ private changed;
74
+ private counter;
75
+ /** Expired since the last time anyone was told, so an absence is explained. */
76
+ private expired;
77
+ constructor(transport: PreloadTransport,
78
+ /**
79
+ * Told whenever what is installed changes.
80
+ *
81
+ * The hook the tab marker hangs off: "an agent has left something in this
82
+ * page" is exactly the set of moments this fires on, and it is the
83
+ * condition worth showing rather than the fact that a tool ran.
84
+ */
85
+ onChange?: () => void);
86
+ /**
87
+ * What is installed, without asking the page.
88
+ *
89
+ * `list` needs an evaluation to say whether a script is running; this only
90
+ * answers what is registered, which is all a status label needs and cheap
91
+ * enough to compute on every change.
92
+ */
93
+ summary(): {
94
+ count: number;
95
+ origins: string[];
96
+ };
97
+ get size(): number;
98
+ recipes(): InjectRecipesData;
99
+ add(request: {
100
+ recipe?: string;
101
+ params?: Record<string, unknown>;
102
+ source?: string;
103
+ ttlMinutes?: number;
104
+ }): Promise<InjectAddData>;
105
+ list(): Promise<InjectListData>;
106
+ read(preload: string, limit?: number): Promise<InjectReadData>;
107
+ remove(preload: string): Promise<InjectRemoveData>;
108
+ clear(): Promise<InjectRemoveData>;
109
+ /**
110
+ * Install a script another tool owns, under a name instead of an id.
111
+ *
112
+ * Registered here rather than straight onto the transport so that one place
113
+ * still knows about every script running in the page: an agent that reads
114
+ * `sk onboarding inject list`, sees nothing, and concludes the page is unmodified while
115
+ * `sk onboarding debug` has hooks in it has been misled by the tool built to prevent
116
+ * exactly that. Replacing an existing reservation is the normal case — arming
117
+ * a different set of breakpoints is a new script under the same name.
118
+ */
119
+ reserve(name: ReservedPreload, body: string): Promise<void>;
120
+ release(name: ReservedPreload): Promise<boolean>;
121
+ /**
122
+ * Register everything again against a session that has just been made.
123
+ *
124
+ * A CDP session does not survive being detached, and the identifiers it
125
+ * handed out do not either. Without this a preload would keep appearing in
126
+ * `list` while no longer running in the browser, which is the one failure
127
+ * this tool cannot afford: every conclusion drawn from an empty buffer would
128
+ * be wrong in the same direction.
129
+ */
130
+ reapply(): Promise<void>;
131
+ /** Whatever is left at the end of the run, dropped without ceremony. */
132
+ dispose(): void;
133
+ private require;
134
+ private expire;
135
+ /**
136
+ * Unregister and switch off, in that order.
137
+ *
138
+ * Unregistering stops the *next* document. The copy already running in this
139
+ * one has already installed its hooks and cannot be taken back out, so it is
140
+ * switched off through the flag every recipe checks before it records. A
141
+ * removal that did only the first half would leave a spy recording into a
142
+ * buffer nothing lists.
143
+ */
144
+ private retire;
145
+ /** Every entry's page-side state in one evaluation, or null when there is no page. */
146
+ private pageState;
147
+ private describe;
148
+ private evaluateQuietly;
149
+ private drainExpired;
150
+ }