@speedkit/cli 4.50.5 → 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 (406) hide show
  1. package/README.md +1369 -10
  2. package/dist/base/run-control-command.d.ts +15 -0
  3. package/dist/base/run-control-command.js +20 -0
  4. package/dist/build-info.json +6 -0
  5. package/dist/commands/diff.d.ts +6 -1
  6. package/dist/commands/diff.js +9 -3
  7. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  8. package/dist/commands/onboarding/browser/click.js +19 -0
  9. package/dist/commands/onboarding/browser/emulate.d.ts +93 -0
  10. package/dist/commands/onboarding/browser/emulate.js +23 -0
  11. package/dist/commands/onboarding/browser/navigate.d.ts +67 -0
  12. package/dist/commands/onboarding/browser/navigate.js +18 -0
  13. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  14. package/dist/commands/onboarding/browser/panel.js +12 -0
  15. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  16. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  17. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  18. package/dist/commands/onboarding/browser/reset.js +18 -0
  19. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  20. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  21. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  22. package/dist/commands/onboarding/browser/state.js +12 -0
  23. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  24. package/dist/commands/onboarding/browser/tabs.js +16 -0
  25. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  26. package/dist/commands/onboarding/cache/clear.js +12 -0
  27. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  28. package/dist/commands/onboarding/cache/errors.js +12 -0
  29. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  30. package/dist/commands/onboarding/cache/evict.js +15 -0
  31. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  32. package/dist/commands/onboarding/cache/get.js +17 -0
  33. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  34. package/dist/commands/onboarding/cache/list.js +15 -0
  35. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  36. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  37. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  38. package/dist/commands/onboarding/cache/refresh.js +18 -0
  39. package/dist/commands/onboarding/cdp.d.ts +81 -0
  40. package/dist/commands/onboarding/cdp.js +18 -0
  41. package/dist/commands/onboarding/debug/arm.d.ts +77 -0
  42. package/dist/commands/onboarding/debug/arm.js +18 -0
  43. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  44. package/dist/commands/onboarding/debug/await.js +18 -0
  45. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  46. package/dist/commands/onboarding/debug/disarm.js +12 -0
  47. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  48. package/dist/commands/onboarding/debug/eval.js +16 -0
  49. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  50. package/dist/commands/onboarding/debug/release.js +12 -0
  51. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  52. package/dist/commands/onboarding/debug/resume.js +12 -0
  53. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  54. package/dist/commands/onboarding/debug/status.js +12 -0
  55. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  56. package/dist/commands/onboarding/debug/step.js +15 -0
  57. package/dist/commands/onboarding/files/list.d.ts +58 -0
  58. package/dist/commands/onboarding/files/list.js +12 -0
  59. package/dist/commands/onboarding/files/read.d.ts +73 -0
  60. package/dist/commands/onboarding/files/read.js +16 -0
  61. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  62. package/dist/commands/onboarding/files/rebuild.js +18 -0
  63. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  64. package/dist/commands/onboarding/files/validate.js +12 -0
  65. package/dist/commands/onboarding/fouc.d.ts +77 -0
  66. package/dist/commands/onboarding/fouc.js +16 -0
  67. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  68. package/dist/commands/onboarding/inject/add.js +17 -0
  69. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  70. package/dist/commands/onboarding/inject/clear.js +12 -0
  71. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  72. package/dist/commands/onboarding/inject/list.js +12 -0
  73. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  74. package/dist/commands/onboarding/inject/read.js +18 -0
  75. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  76. package/dist/commands/onboarding/inject/recipes.js +12 -0
  77. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  78. package/dist/commands/onboarding/inject/remove.js +15 -0
  79. package/dist/commands/onboarding/list.d.ts +13 -0
  80. package/dist/commands/onboarding/list.js +12 -0
  81. package/dist/commands/onboarding/logs.d.ts +41 -0
  82. package/dist/commands/onboarding/logs.js +256 -0
  83. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  84. package/dist/commands/onboarding/navwalk.js +19 -0
  85. package/dist/commands/onboarding/response.d.ts +67 -0
  86. package/dist/commands/onboarding/response.js +18 -0
  87. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  88. package/dist/commands/onboarding/rum/beacons.js +16 -0
  89. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  90. package/dist/commands/onboarding/rum/get.js +18 -0
  91. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  92. package/dist/commands/onboarding/rum/key.js +13 -0
  93. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  94. package/dist/commands/onboarding/rum/previous.js +12 -0
  95. package/dist/commands/onboarding/status.d.ts +13 -0
  96. package/dist/commands/onboarding/status.js +17 -0
  97. package/dist/commands/onboarding/todo.d.ts +58 -0
  98. package/dist/commands/onboarding/todo.js +12 -0
  99. package/dist/commands/onboarding/viewport.d.ts +101 -0
  100. package/dist/commands/onboarding/viewport.js +18 -0
  101. package/dist/commands/onboarding/watch.d.ts +93 -0
  102. package/dist/commands/onboarding/watch.js +16 -0
  103. package/dist/commands/onboarding.d.ts +26 -0
  104. package/dist/commands/onboarding.js +220 -3
  105. package/dist/commands/origin-request.d.ts +4 -0
  106. package/dist/commands/origin-request.js +4 -0
  107. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  108. package/dist/commands/spec/onboarding.spec.js +127 -0
  109. package/dist/services/cli/build-info.d.ts +33 -0
  110. package/dist/services/cli/build-info.js +63 -0
  111. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  112. package/dist/services/cli/cli-environment-factory.js +1 -0
  113. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  114. package/dist/services/cli/cli-service-factory.js +1 -1
  115. package/dist/services/cli/cli-service-model.d.ts +29 -10
  116. package/dist/services/cli/cli-service.d.ts +60 -11
  117. package/dist/services/cli/cli-service.js +196 -32
  118. package/dist/services/cli/index.d.ts +2 -0
  119. package/dist/services/cli/index.js +2 -0
  120. package/dist/services/cli/sink.d.ts +47 -0
  121. package/dist/services/cli/sink.js +31 -0
  122. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  123. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  124. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  125. package/dist/services/cli/spec/build-info.spec.js +10 -0
  126. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  127. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  128. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  129. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  130. package/dist/services/cli/spec/memory-cli.js +9 -0
  131. package/dist/services/diff/config-at-ref.d.ts +20 -0
  132. package/dist/services/diff/config-at-ref.js +33 -0
  133. package/dist/services/diff/diff-service-build-context.d.ts +8 -0
  134. package/dist/services/diff/diff-service-build-context.js +40 -1
  135. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  136. package/dist/services/diff/diff-service-factory.js +48 -20
  137. package/dist/services/diff/diff-service.d.ts +11 -0
  138. package/dist/services/diff/diff-service.js +37 -11
  139. package/dist/services/diff/page-source.d.ts +12 -0
  140. package/dist/services/diff/page-source.js +16 -11
  141. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  142. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  143. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  144. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  145. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  146. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  147. package/dist/services/git/git-repository.d.ts +2 -0
  148. package/dist/services/git/git-repository.js +6 -0
  149. package/dist/services/integration-api/customer-config-flags.js +1 -0
  150. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  151. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  152. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  153. package/dist/services/onboarding/browser/console-log.js +27 -0
  154. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  155. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  156. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  157. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  158. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  159. package/dist/services/onboarding/control/body-inspect.js +106 -0
  160. package/dist/services/onboarding/control/browser-session.d.ts +521 -0
  161. package/dist/services/onboarding/control/browser-session.js +1273 -0
  162. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  163. package/dist/services/onboarding/control/config-validation.js +46 -0
  164. package/dist/services/onboarding/control/control-protocol.d.ts +1390 -0
  165. package/dist/services/onboarding/control/control-protocol.js +69 -0
  166. package/dist/services/onboarding/control/control-server.d.ts +284 -0
  167. package/dist/services/onboarding/control/control-server.js +1609 -0
  168. package/dist/services/onboarding/control/debug-session.d.ts +190 -0
  169. package/dist/services/onboarding/control/debug-session.js +801 -0
  170. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  171. package/dist/services/onboarding/control/fouc.js +151 -0
  172. package/dist/services/onboarding/control/index.d.ts +4 -0
  173. package/dist/services/onboarding/control/index.js +4 -0
  174. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  175. package/dist/services/onboarding/control/navwalk.js +248 -0
  176. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  177. package/dist/services/onboarding/control/preload-registry.js +829 -0
  178. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  179. package/dist/services/onboarding/control/response-explainer.js +257 -0
  180. package/dist/services/onboarding/control/rum.d.ts +8 -0
  181. package/dist/services/onboarding/control/rum.js +220 -0
  182. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  183. package/dist/services/onboarding/control/service-worker-tracker.js +119 -0
  184. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  185. package/dist/services/onboarding/control/viewport.js +344 -0
  186. package/dist/services/onboarding/control/watch.d.ts +26 -0
  187. package/dist/services/onboarding/control/watch.js +149 -0
  188. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  189. package/dist/services/onboarding/dashboard/index.js +7 -2
  190. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  191. package/dist/services/onboarding/fetch-event-handler.js +94 -32
  192. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  193. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  194. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  195. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  196. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  197. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  198. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  199. package/dist/services/onboarding/onboarding-model.d.ts +30 -0
  200. package/dist/services/onboarding/onboarding-model.js +10 -0
  201. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  202. package/dist/services/onboarding/onboarding-service-build-context.js +6 -0
  203. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  204. package/dist/services/onboarding/onboarding-service-factory.js +131 -17
  205. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  206. package/dist/services/onboarding/onboarding-service.js +135 -22
  207. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  208. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  209. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  210. package/dist/services/onboarding/request-cache/cache.js +128 -17
  211. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  212. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  213. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  214. package/dist/services/onboarding/spec/control/browser-session.spec.js +526 -0
  215. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  216. package/dist/services/onboarding/spec/control/control-server.spec.js +338 -0
  217. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  218. package/dist/services/onboarding/spec/control/debug-session.spec.js +693 -0
  219. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  220. package/dist/services/onboarding/spec/control/fakes.js +66 -0
  221. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  222. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  223. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  224. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  225. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  226. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  227. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  228. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  229. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  230. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  231. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  232. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  233. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  234. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  235. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  236. package/dist/services/onboarding/spec/control/watch.spec.js +172 -0
  237. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  238. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +202 -0
  239. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  240. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  241. package/dist/services/onboarding/spec/onboarding-model.spec.js +37 -0
  242. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -0
  243. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  244. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  245. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  246. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  247. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  248. package/dist/services/onboarding/todo-collector.js +49 -12
  249. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +34 -0
  250. package/dist/services/onboarding/virtual-orestes-app/index.js +82 -27
  251. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  252. package/dist/services/origin-request/asset-variations.js +11 -4
  253. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  254. package/dist/services/origin-request/origin-fetcher.js +43 -5
  255. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  256. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  257. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  258. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  259. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  260. package/dist/services/origin-request/origin-request-service.js +273 -49
  261. package/dist/services/origin-request/runtime-config-source.js +9 -4
  262. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  263. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  264. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  265. package/dist/services/query-builder/rules/rule-match.js +70 -0
  266. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  267. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  268. package/dist/services/run-control/browser/run-browser-contexts.d.ts +541 -0
  269. package/dist/services/run-control/browser/run-browser-contexts.js +78 -0
  270. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  271. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  272. package/dist/services/run-control/browser/run-browser-service.d.ts +64 -0
  273. package/dist/services/run-control/browser/run-browser-service.js +199 -0
  274. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  275. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  276. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  277. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  278. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  279. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  280. package/dist/services/run-control/control-client.d.ts +36 -0
  281. package/dist/services/run-control/control-client.js +147 -0
  282. package/dist/services/run-control/debug/run-debug-contexts.d.ts +411 -0
  283. package/dist/services/run-control/debug/run-debug-contexts.js +44 -0
  284. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  285. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  286. package/dist/services/run-control/debug/run-debug-service.d.ts +38 -0
  287. package/dist/services/run-control/debug/run-debug-service.js +161 -0
  288. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  289. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  290. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  291. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  292. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  293. package/dist/services/run-control/files/run-files-service.js +120 -0
  294. package/dist/services/run-control/index.d.ts +32 -0
  295. package/dist/services/run-control/index.js +31 -0
  296. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  297. package/dist/services/run-control/inject/run-inject-contexts.js +32 -0
  298. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  299. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  300. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  301. package/dist/services/run-control/inject/run-inject-service.js +203 -0
  302. package/dist/services/run-control/live-run.d.ts +37 -0
  303. package/dist/services/run-control/live-run.js +56 -0
  304. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  305. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  306. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  307. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  308. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  309. package/dist/services/run-control/probe/run-probe-service.js +193 -0
  310. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  311. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  312. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  313. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  314. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  315. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  316. package/dist/services/run-control/run-answer.d.ts +28 -0
  317. package/dist/services/run-control/run-answer.js +58 -0
  318. package/dist/services/run-control/run-control-context.d.ts +102 -0
  319. package/dist/services/run-control/run-control-context.js +36 -0
  320. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  321. package/dist/services/run-control/run-control-flags.js +22 -0
  322. package/dist/services/run-control/run-control-model.d.ts +9 -0
  323. package/dist/services/run-control/run-control-model.js +1 -0
  324. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  325. package/dist/services/run-control/run-control-service-factory.js +26 -0
  326. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  327. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  328. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  329. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  330. package/dist/services/run-control/session/run-session-service.d.ts +25 -0
  331. package/dist/services/run-control/session/run-session-service.js +95 -0
  332. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  333. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
  334. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  335. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  336. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  337. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  338. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  339. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  340. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  341. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +224 -0
  342. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  343. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  344. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  345. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  346. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  347. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  348. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  349. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  350. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  351. package/dist/services/run-control/spec/session/run-session-service.spec.js +101 -0
  352. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  353. package/dist/services/run-log/crash-mirror.js +69 -0
  354. package/dist/services/run-log/index.d.ts +11 -0
  355. package/dist/services/run-log/index.js +11 -0
  356. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  357. package/dist/services/run-log/jsonl-appender.js +91 -0
  358. package/dist/services/run-log/log-event-model.d.ts +104 -0
  359. package/dist/services/run-log/log-event-model.js +56 -0
  360. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  361. package/dist/services/run-log/log-query-service-factory.js +14 -0
  362. package/dist/services/run-log/log-query-service.d.ts +59 -0
  363. package/dist/services/run-log/log-query-service.js +111 -0
  364. package/dist/services/run-log/log-reader.d.ts +84 -0
  365. package/dist/services/run-log/log-reader.js +180 -0
  366. package/dist/services/run-log/log-summary.d.ts +72 -0
  367. package/dist/services/run-log/log-summary.js +208 -0
  368. package/dist/services/run-log/redaction.d.ts +34 -0
  369. package/dist/services/run-log/redaction.js +124 -0
  370. package/dist/services/run-log/request-log.d.ts +80 -0
  371. package/dist/services/run-log/request-log.js +69 -0
  372. package/dist/services/run-log/request-summary.d.ts +76 -0
  373. package/dist/services/run-log/request-summary.js +0 -0
  374. package/dist/services/run-log/run-log.d.ts +61 -0
  375. package/dist/services/run-log/run-log.js +102 -0
  376. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  377. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  378. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  379. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  380. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  381. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  382. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  383. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  384. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  385. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  386. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  387. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  388. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  389. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  390. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  391. package/dist/services/run-registry/exit-classification.js +42 -0
  392. package/dist/services/run-registry/index.d.ts +3 -0
  393. package/dist/services/run-registry/index.js +3 -0
  394. package/dist/services/run-registry/process-identity.d.ts +28 -0
  395. package/dist/services/run-registry/process-identity.js +80 -0
  396. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  397. package/dist/services/run-registry/run-registry-model.js +16 -0
  398. package/dist/services/run-registry/run-registry.d.ts +150 -0
  399. package/dist/services/run-registry/run-registry.js +409 -0
  400. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  401. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  402. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  403. package/dist/services/run-registry/spec/run-registry.spec.js +509 -0
  404. package/dist/services/setup/os/tool-registry.js +2 -2
  405. package/oclif.manifest.json +3293 -272
  406. package/package.json +20 -2
@@ -2,6 +2,19 @@ import { safe } from "../../../helpers/safe.js";
2
2
  import { FILE_TYPE, } from "../../integration-api/index.js";
3
3
  import { INTEGRATION_FILES } from "../../../models/files.js";
4
4
  import { race } from "../../../helpers/race.js";
5
+ /**
6
+ * A rebuild asked for before the run wired its watchers.
7
+ *
8
+ * Typed rather than a bare `Error` so the control server can answer it as
9
+ * `NO_REBUILD` — "ask again once the page is up" is a different instruction to
10
+ * the caller than "the rebuild failed", and the two are indistinguishable once
11
+ * they are both a message string.
12
+ */
13
+ export class NoRebuildContextError extends Error {
14
+ constructor() {
15
+ super("this run has not wired its file watchers yet, so there are no rebuild groups to trigger — they are wired once the page is ready");
16
+ }
17
+ }
5
18
  /**
6
19
  * Add different callbacks that will be executed if a local file is changed.
7
20
  */
@@ -15,6 +28,8 @@ export class FileWatcher {
15
28
  // Set by OnboardingServiceFactory. When present, config changes re-warm the
16
29
  // dh-cache in the background instead of just clearing it.
17
30
  cacheRefresher;
31
+ /** What the watchers were wired with, so a rebuild can reuse it. */
32
+ rebuildContext;
18
33
  constructor(cli, customerConfig, files, documentHandler, browserContext, cache) {
19
34
  this.cli = cli;
20
35
  this.customerConfig = customerConfig;
@@ -54,6 +69,15 @@ export class FileWatcher {
54
69
  */
55
70
  addCallbackOnFileChange(page, serviceWorkerReinstallCallback, signal) {
56
71
  const installResource = this.files.getByName(INTEGRATION_FILES.BUILD.INSTALL);
72
+ // Kept so the same groups can be triggered without a file having changed —
73
+ // which is what `rebuild()` is. Held rather than re-derived because the
74
+ // page and the reinstall callback belong to the run, and rediscovering them
75
+ // later would mean guessing at things the run already decided.
76
+ this.rebuildContext = {
77
+ page,
78
+ installResource,
79
+ serviceWorkerReinstallCallback,
80
+ };
57
81
  this.handleServiceWorkerDependencies(page, installResource, serviceWorkerReinstallCallback, signal);
58
82
  this.handleGenericConfigFiles(page, installResource, signal);
59
83
  this.handleDynamicStyles(page, signal);
@@ -89,7 +113,10 @@ export class FileWatcher {
89
113
  file.onChange(async (file) => {
90
114
  const result = await safe(this.onChangeServiceWorkerCallback(file, page, installResource, serviceWorkerReinstallCallback));
91
115
  if (result.success === false) {
92
- this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`);
116
+ this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`, false, {
117
+ scope: "config",
118
+ data: { file: file.name, error: result.error },
119
+ });
93
120
  }
94
121
  }, { signal });
95
122
  }
@@ -123,7 +150,10 @@ export class FileWatcher {
123
150
  file.onChange(async (file) => {
124
151
  const result = await safe(this.onChangeConfigFileCallback(page, installResource, file));
125
152
  if (result.success === false) {
126
- this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`);
153
+ this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`, false, {
154
+ scope: "config",
155
+ data: { file: file.name, error: result.error },
156
+ });
127
157
  }
128
158
  }, { signal });
129
159
  }
@@ -148,7 +178,10 @@ export class FileWatcher {
148
178
  .onChange(async (file) => {
149
179
  const result = await safe(this.onChangeDynamicStyleCallback(file, page));
150
180
  if (result.success === false) {
151
- this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`);
181
+ this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`, false, {
182
+ scope: "config",
183
+ data: { file: file.name, error: result.error },
184
+ });
152
185
  }
153
186
  }, { signal });
154
187
  }
@@ -162,7 +195,19 @@ export class FileWatcher {
162
195
  * @private
163
196
  */
164
197
  async onChangeServiceWorkerCallback(file, page, installResource, serviceWorkerReinstallCallback) {
165
- this.cli.writeWarning(`changed file: ${file.name} (reinstall serviceWorker)`);
198
+ this.cli.writeWarning(`changed file: ${file.name} (reinstall serviceWorker)`, false, { scope: "config", data: { file: file.name, reinstallsSw: true } });
199
+ await this.rebuildServiceWorkerGroup(page, installResource, serviceWorkerReinstallCallback, file);
200
+ }
201
+ /**
202
+ * The service-worker group's effects, without a file having changed.
203
+ *
204
+ * Split out of the callback above rather than reimplemented beside it: the
205
+ * blast radius of this group is the thing a caller is asking for when it
206
+ * asks for a rebuild, and a second copy of it would drift from the one the
207
+ * watcher actually runs — at which point `sk onboarding files rebuild` would be
208
+ * reproducing something the run never does.
209
+ */
210
+ async rebuildServiceWorkerGroup(page, installResource, serviceWorkerReinstallCallback, file) {
166
211
  // clear speed-kit-service-worker-caches and uninstall serviceWorker
167
212
  await this.safeClearPageBrowsersCacheStorage(page);
168
213
  await this.unregisterServiceWorker(page);
@@ -171,6 +216,63 @@ export class FileWatcher {
171
216
  // tell puppeteer to reinstall serviceworker on next navigate
172
217
  await serviceWorkerReinstallCallback(file);
173
218
  }
219
+ /** The generic-config group's effects, without a file having changed. */
220
+ async rebuildDocumentHandlerGroup(page, installResource) {
221
+ await this.safeClearPageBrowsersCacheStorage(page);
222
+ await this.documentHandler.buildDocumentHandler();
223
+ this.clearOrRefreshCache(page);
224
+ await installResource.buildContent();
225
+ }
226
+ /**
227
+ * Run a rebuild group on demand, as if one of its files had changed.
228
+ *
229
+ * The groups are the run's own, so what this does to the browser and the
230
+ * caches is exactly what an edit to one of those files does — which is the
231
+ * point. It reports what it did rather than returning void, because the
232
+ * effects reach past the files: a documentHandler rebuild empties the
233
+ * dh-cache, and a caller comparing two measurements across one of these has
234
+ * to know that the second is against a cold cache.
235
+ *
236
+ * @returns what each group did, in the order it ran.
237
+ */
238
+ async rebuild(target) {
239
+ if (!this.rebuildContext) {
240
+ throw new NoRebuildContextError();
241
+ }
242
+ const { page, installResource, serviceWorkerReinstallCallback } = this.rebuildContext;
243
+ const steps = [];
244
+ // documentHandler first when both are asked for. It ends by rebuilding the
245
+ // install resource, and so does the service-worker group — running install
246
+ // last means the reinstall is armed after the final build rather than
247
+ // before it.
248
+ if (target === "documentHandler" || target === "all") {
249
+ await this.rebuildDocumentHandlerGroup(page, installResource);
250
+ steps.push({
251
+ target: "documentHandler",
252
+ did: [
253
+ "rebuilt the local documentHandler",
254
+ this.cacheRefresher
255
+ ? "cleared the dh-cache and re-warmed the open page's entries in the background"
256
+ : "cleared the dh-cache",
257
+ "cleared Speed Kit's caches in the browser",
258
+ "rebuilt the install resource",
259
+ ],
260
+ });
261
+ }
262
+ if (target === "install" || target === "all") {
263
+ await this.rebuildServiceWorkerGroup(page, installResource, serviceWorkerReinstallCallback);
264
+ steps.push({
265
+ target: "install",
266
+ did: [
267
+ "cleared Speed Kit's caches in the browser",
268
+ "unregistered the service worker",
269
+ "rebuilt the install resource",
270
+ "armed a service-worker reinstall for the next navigation",
271
+ ],
272
+ });
273
+ }
274
+ return steps;
275
+ }
174
276
  /**
175
277
  * fileWatcherCallback that will rebuild the local documentHandler
176
278
  *
@@ -180,11 +282,11 @@ export class FileWatcher {
180
282
  * @private
181
283
  */
182
284
  async onChangeConfigFileCallback(page, installResource, file) {
183
- this.cli.writeWarning(`changed file: ${file.name}`);
184
- await this.safeClearPageBrowsersCacheStorage(page);
185
- await this.documentHandler.buildDocumentHandler();
186
- this.clearOrRefreshCache(page);
187
- await installResource.buildContent();
285
+ this.cli.writeWarning(`changed file: ${file.name}`, false, {
286
+ scope: "config",
287
+ data: { file: file.name },
288
+ });
289
+ await this.rebuildDocumentHandlerGroup(page, installResource);
188
290
  }
189
291
  /**
190
292
  * fileWatcherCallback that will reinstall the serviceWorker
@@ -194,7 +296,10 @@ export class FileWatcher {
194
296
  * @private
195
297
  */
196
298
  async onChangeDynamicStyleCallback(file, page) {
197
- this.cli.writeWarning(`changed file: ${file.name}`);
299
+ this.cli.writeWarning(`changed file: ${file.name}`, false, {
300
+ scope: "config",
301
+ data: { file: file.name },
302
+ });
198
303
  await this.documentHandler.buildDocumentHandler();
199
304
  this.clearOrRefreshCache(page);
200
305
  const escapedStyles = encodeURI(file.getContent());
@@ -205,7 +310,7 @@ export class FileWatcher {
205
310
  if (evaluateResult.success === false &&
206
311
  !evaluateResult.error.includes("timeout")) {
207
312
  // The stack already starts with the message, so this is not a duplicate.
208
- this.cli.writeError(evaluateResult.errorObj?.stack ?? evaluateResult.error);
313
+ this.cli.writeError(evaluateResult.errorObj?.stack ?? evaluateResult.error, false, { scope: "config", data: { file: file.name } });
209
314
  }
210
315
  }
211
316
  /**
@@ -217,7 +322,7 @@ export class FileWatcher {
217
322
  async safeClearPageBrowsersCacheStorage(page) {
218
323
  const result = await safe(this.clearPageBrowsersCacheStorage(page));
219
324
  if (result.success === false) {
220
- this.cli.writeError(result.error);
325
+ this.cli.writeError(result.error, false, { scope: "cache" });
221
326
  }
222
327
  }
223
328
  /**
@@ -186,9 +186,39 @@ export interface LocalCacheError {
186
186
  stack: string | null;
187
187
  occurredAt: number;
188
188
  }
189
+ /**
190
+ * What a run command is doing to this browser right now.
191
+ *
192
+ * Read by the devtools extension, which turns the tab strip red while it is
193
+ * active — see `lib/agent-tab-state.ts` there. Additive to the union on
194
+ * purpose: an extension too old to know the id ignores it, so the protocol
195
+ * version does not move.
196
+ */
197
+ export interface AgentActivity {
198
+ active: boolean;
199
+ /** The sharpest thing installed — `sk debug` over `sk inject (3)`. */
200
+ label: string | null;
201
+ /** ISO, when it became active. */
202
+ since?: string;
203
+ /**
204
+ * The breakpoints `sk onboarding debug` has armed, in its 1–4 numbering.
205
+ *
206
+ * The CLI sets the page's sessionStorage flags directly and the extension's
207
+ * injector reads them, so the pause already lands in the right place without
208
+ * this. The panel is the part that needs telling: its switches are backed by
209
+ * extension storage rather than read back from the page, deliberately —
210
+ * an `inspectedWindow.eval` during a navigation races the document swap and
211
+ * queues behind a paused JS thread, which is exactly what an armed
212
+ * breakpoint produces.
213
+ */
214
+ breakpoints?: number[];
215
+ }
189
216
  export type DevelopmentToolsMessage = {
190
217
  id: "skCli";
191
218
  data: SkCliInfo;
219
+ } | {
220
+ id: "agent";
221
+ data: AgentActivity;
192
222
  } | {
193
223
  id: "athena";
194
224
  data: AthenaInfo;
@@ -253,6 +253,16 @@ export class BrowserContext {
253
253
  ...this.getLaunchOnlyArgs(),
254
254
  ...this.getSystemChromeFlags(),
255
255
  ]),
256
+ // Puppeteer installs its own signal handlers by default, and its SIGINT
257
+ // one is `this.kill(); process.exit(130)` — a bare exit, out from under
258
+ // whatever the CLI was doing. That would skip the run's status stamp, the
259
+ // control-socket unlink and the cache teardown, all of which live in the
260
+ // `finally` of `commands/onboarding.ts`. The command registers its own
261
+ // handlers before the browser launches and owns shutdown; the browser
262
+ // closes as part of it.
263
+ handleSIGINT: false,
264
+ handleSIGTERM: false,
265
+ handleSIGHUP: false,
256
266
  // Strip Puppeteer's default `--enable-automation` so Chrome doesn't show
257
267
  // the "Chrome is being controlled by automated test software" infobar.
258
268
  ignoreDefaultArgs: [
@@ -17,6 +17,7 @@ declare const flags: {
17
17
  debuggingPort: Interfaces.BooleanFlag<boolean>;
18
18
  debugPort: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
19
19
  verboseLevel: Interfaces.BooleanFlag<boolean>;
20
+ logFile: Interfaces.BooleanFlag<boolean>;
20
21
  ignoreContentSecurityPolicy: Interfaces.BooleanFlag<boolean>;
21
22
  headless: Interfaces.BooleanFlag<boolean>;
22
23
  device: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
@@ -50,6 +51,8 @@ export interface OnboardingServiceBuildContextValues extends CommandContextValue
50
51
  readonly testing?: string;
51
52
  /** The app of `--inject`, when no customer config names it. */
52
53
  readonly app?: string;
54
+ /** Whether the run writes a structured copy of its output to `log.jsonl`. */
55
+ readonly logFile: boolean;
53
56
  }
54
57
  declare const OnboardingServiceBuildContext_base: new (values: OnboardingServiceBuildContextValues) => Readonly<OnboardingServiceBuildContextValues>;
55
58
  /** What `sk onboarding` starts: a local Speed Kit dev environment for one customer. */
@@ -65,6 +68,7 @@ export declare class OnboardingServiceBuildContext extends OnboardingServiceBuil
65
68
  debuggingPort: Interfaces.BooleanFlag<boolean>;
66
69
  debugPort: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
67
70
  verboseLevel: Interfaces.BooleanFlag<boolean>;
71
+ logFile: Interfaces.BooleanFlag<boolean>;
68
72
  ignoreContentSecurityPolicy: Interfaces.BooleanFlag<boolean>;
69
73
  headless: Interfaces.BooleanFlag<boolean>;
70
74
  device: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
@@ -56,6 +56,11 @@ const flags = {
56
56
  default: false,
57
57
  description: "Show all messages",
58
58
  }),
59
+ logFile: Flags.boolean({
60
+ allowNo: true,
61
+ default: true,
62
+ description: "Write a structured copy of this run's output to log.jsonl in the run directory, readable afterwards with `sk onboarding logs`. Use --no-log-file to keep the run off disk entirely.",
63
+ }),
59
64
  ignoreContentSecurityPolicy: Flags.boolean({
60
65
  char: "s",
61
66
  default: false,
@@ -118,6 +123,7 @@ export class OnboardingServiceBuildContext extends Context() {
118
123
  testing: parsedFlags.inject === LATEST_INSTALLATION
119
124
  ? undefined
120
125
  : parsedFlags.inject,
126
+ logFile: parsedFlags.logFile,
121
127
  });
122
128
  }
123
129
  }
@@ -1,13 +1,29 @@
1
1
  import { OnboardingServiceBuildContext } from "./onboarding-service-build-context.js";
2
+ import { RunHandle } from "../run-registry/index.js";
2
3
  import { BrowserContext } from "./onboarding-model.js";
3
4
  import { OnboardingService } from "./onboarding-service.js";
4
5
  import { BrowseService } from "./browse/browse-service.js";
5
6
  import { InjectService } from "./inject/inject-service.js";
6
7
  import { DeployedInstallation } from "./inject/deployed-installation.js";
7
8
  import { BrowserExtensions } from "./browser/extension/extension-validator.js";
9
+ import { RequestLogInterface } from "../run-log/index.js";
8
10
  export declare class OnboardingServiceFactory {
9
11
  private readonly context;
10
- constructor(context: OnboardingServiceBuildContext);
12
+ /** Recorded by the command; filled in here once the config is known. */
13
+ private readonly run?;
14
+ /**
15
+ * Where intercepted requests go. Owned by the command, because it is the
16
+ * one place that decides whether this run writes anything to disk.
17
+ */
18
+ private readonly requestLog?;
19
+ constructor(context: OnboardingServiceBuildContext,
20
+ /** Recorded by the command; filled in here once the config is known. */
21
+ run?: RunHandle,
22
+ /**
23
+ * Where intercepted requests go. Owned by the command, because it is the
24
+ * one place that decides whether this run writes anything to disk.
25
+ */
26
+ requestLog?: RequestLogInterface);
11
27
  /**
12
28
  * The service `sk onboarding` runs: the browse service under `--browse`, the inject service under
13
29
  * `--inject`, the onboarding service otherwise.
@@ -4,6 +4,8 @@ import { INTEGRATION_FILES } from "../../models/files.js";
4
4
  import { AthenaServiceBuildContext, AthenaServiceFactory, } from "../athena/index.js";
5
5
  import { BundleServiceFactory } from "../bundler/index.js";
6
6
  import { createDiffEngine, PageSource } from "../diff/index.js";
7
+ import { BrowserSession, ControlServer } from "./control/index.js";
8
+ import { validateLoadedConfig } from "./control/config-validation.js";
7
9
  import { DocumentHandlerRuntimeServiceBuildContext } from "../document-handler-runtime/document-handler-runtime-service-build-context.js";
8
10
  import DocumentHandlerRuntimeServiceFactory from "../document-handler-runtime/factory/document-handler-runtime-service-factory.js";
9
11
  import { documentHandlerRuntimeFiles } from "../document-handler-runtime/runtime-files.js";
@@ -47,6 +49,9 @@ import { VirtualOrestesApp } from "./virtual-orestes-app/index.js";
47
49
  import { ConfigApiContext, ConfigApiServiceFactory, } from "../config-api/index.js";
48
50
  import * as fs from "node:fs";
49
51
  import * as path from "node:path";
52
+ import { join } from "node:path";
53
+ import { mkdtempSync } from "node:fs";
54
+ import { tmpdir } from "node:os";
50
55
  import { StaticRecipe } from "../integration-api/virtual/static-recipe.js";
51
56
  import { DiffAgainstCurrentPage } from "./dashboard/diff-against-current-page.js";
52
57
  import { ExtensionDownloader } from "./browser/extension/extension-downloader.js";
@@ -57,8 +62,19 @@ import { ParameterQueryServiceBuildContext } from "../query-builder/query-builde
57
62
  import { formatChromeFeatureFinding, formatChromeFlagDuplicate, } from "../../helpers/chrome-flags.js";
58
63
  export class OnboardingServiceFactory {
59
64
  context;
60
- constructor(context) {
65
+ run;
66
+ requestLog;
67
+ constructor(context,
68
+ /** Recorded by the command; filled in here once the config is known. */
69
+ run,
70
+ /**
71
+ * Where intercepted requests go. Owned by the command, because it is the
72
+ * one place that decides whether this run writes anything to disk.
73
+ */
74
+ requestLog) {
61
75
  this.context = context;
76
+ this.run = run;
77
+ this.requestLog = requestLog;
62
78
  }
63
79
  /**
64
80
  * The service `sk onboarding` runs: the browse service under `--browse`, the inject service under
@@ -98,7 +114,13 @@ export class OnboardingServiceFactory {
98
114
  ];
99
115
  return new InjectService({
100
116
  browserContext,
101
- fetchEventHandler: new FetchEventHandler(handlers, customerConfig, cli, this.getConfigApi(customerConfig.app)),
117
+ fetchEventHandler: new FetchEventHandler({
118
+ browserFetchEvents: handlers,
119
+ customerConfig,
120
+ cli,
121
+ client: this.getConfigApi(customerConfig.app),
122
+ requestLog: this.requestLog,
123
+ }),
102
124
  installation,
103
125
  scope: customerConfig.scope,
104
126
  cli,
@@ -196,10 +218,20 @@ export class OnboardingServiceFactory {
196
218
  cli.writeWarning(formatChromeFeatureFinding(finding));
197
219
  }
198
220
  if (this.context.debuggingPort || this.context.headless) {
199
- cli.writeWarning(`Chrome remote debugging enabled on port ${this.context.debugPort}.`);
221
+ cli.writeWarning(`Chrome remote debugging enabled on port ${this.context.debugPort}.`, false,
222
+ // Yellow on the terminal because it changes how Chrome behaves, but it
223
+ // is not a problem — and `--summary` lists every warning as one.
224
+ {
225
+ scope: "browser",
226
+ level: "info",
227
+ data: { debugPort: this.context.debugPort },
228
+ });
200
229
  }
201
230
  if (this.context.headless) {
202
- cli.writeWarning("Running in headless mode.");
231
+ cli.writeWarning("Running in headless mode.", false, {
232
+ scope: "browser",
233
+ data: { headless: true },
234
+ });
203
235
  }
204
236
  if (browserContext.emulation) {
205
237
  const { device, userAgent, viewport } = browserContext.emulation;
@@ -215,6 +247,7 @@ export class OnboardingServiceFactory {
215
247
  const cli = this.context.environment.cli;
216
248
  const files = await this.getIntegrationFiles(cli);
217
249
  const customerConfig = files.getCustomerConfig().config;
250
+ this.run?.update({ app: customerConfig.app });
218
251
  // Before any origin request, so Chrome and the CLI agree on the route out.
219
252
  applyOriginProxy(customerConfig.chromeFlags, cli);
220
253
  // Also before any origin request: an origin behind bot protection refuses the CLI outright,
@@ -228,7 +261,19 @@ export class OnboardingServiceFactory {
228
261
  cli.writeWarning("Fetching every origin document through a second headless Chrome.");
229
262
  }
230
263
  const domainToStart = await this.getUrlForTest(customerConfig, cli);
231
- const cache = new Cache(cli);
264
+ // Recorded, not derived: a customer with several origins and no `domain`
265
+ // has nothing in its config that says which site this run is on, and
266
+ // `origins[0]` is a guess that is wrong for anyone started with `-d` or who
267
+ // picked the second entry at the prompt. `sk origin-request` reads it back to
268
+ // resolve a relative url the way the control socket already does for a live
269
+ // run — and from here it survives the run, so a post-mortem resolves too.
270
+ this.run?.update({ domain: domainToStart });
271
+ // Inside the run directory, so the run's own retention prunes the bodies
272
+ // and a finished run's cache is still readable. Without a run — a test
273
+ // harness — a temp directory keeps it to one code path.
274
+ const cache = new Cache(cli, this.run
275
+ ? join(this.run.dir, "dh-cache")
276
+ : mkdtempSync(join(tmpdir(), "sk-dh-cache-")));
232
277
  const documentHandler = await new DocumentHandlerRuntimeServiceFactory(new DocumentHandlerRuntimeServiceBuildContext({
233
278
  environment: this.context.environment,
234
279
  configName: this.context.configName,
@@ -242,13 +287,66 @@ export class OnboardingServiceFactory {
242
287
  const { browserContext, browserExtensions } = await this.prepareBrowser(domainToStart, customerConfig.chromeFlags);
243
288
  const fileWatcher = new FileWatcher(cli, customerConfig, files, documentHandler, browserContext, cache);
244
289
  const athenaClient = (await this.getAthenaClient(customerConfig.app)) || null;
245
- const messageHandler = await this.prepareMessagehandler(athenaClient, files, customerConfig);
290
+ // One collector, read by both consumers: the devtools panel gets it as a
291
+ // message, `sk onboarding todo` reads it over the control socket. Two instances would
292
+ // drift the moment either started caching.
293
+ const todos = new TodoCollector(files.getInstallResources());
294
+ const messageHandler = await this.prepareMessagehandler(athenaClient, files, customerConfig, todos);
246
295
  const speedKitServiceWorkerJs = new SpeedKitServiceWorkerJs(customerConfig, files.getByName(INTEGRATION_FILES.CUSTOM.SW));
247
- const fetchHandler = await this.getFetchEventHandler(files, customerConfig, documentHandler, cache, cli, browserContext, athenaClient, messageHandler, fileWatcher, speedKitServiceWorkerJs);
296
+ const { fetchHandler, orestesApp, rumPi } = await this.getFetchEventHandler(files, customerConfig, documentHandler, cache, cli, browserContext, athenaClient, messageHandler, fileWatcher, speedKitServiceWorkerJs);
248
297
  const extensionBridge = new ExtensionBridge(cli, browserExtensions.hasDevtoolsExtension);
249
- return new OnboardingService(browserContext, customerConfig, fetchHandler, fileWatcher, cli, messageHandler, extensionBridge, speedKitServiceWorkerJs, browserFetch);
298
+ // Constructed here so it holds the same Cache the run does, not a second
299
+ // one. Its lifetime is the run's: OnboardingService starts it against the
300
+ // shutdown signal.
301
+ // The run fills this in once it has a page; until then every op that needs
302
+ // one answers NO_PAGE rather than hanging on something that is not there.
303
+ const browserSession = new BrowserSession();
304
+ const controlServer = this.run
305
+ ? new ControlServer(this.run.dir, this.run.id, {
306
+ cache,
307
+ cli,
308
+ files,
309
+ session: browserSession,
310
+ todos,
311
+ // `browserContext.domain`, not `customerConfig.domain`: the latter is
312
+ // a bare host in every config_customer, and `new URL(input, base)`
313
+ // parses the base first and throws when it has no scheme — even for
314
+ // an absolute input. That made every `sk onboarding response` call fail with
315
+ // BAD_URL blaming the url the caller passed. This one is
316
+ // `ensureHttps`-ed and honours `-d` and the multi-origin prompt, so
317
+ // it is also the origin the run is actually driving — `origins[0]`
318
+ // would resolve a relative url against the wrong site for a customer
319
+ // started on their second origin.
320
+ origin: browserContext.domain,
321
+ // Undefined without `--local`, and the op says so rather than
322
+ // failing obscurely: there is no local documentHandler to build with.
323
+ prewarm: orestesApp
324
+ ? (url, variation) => orestesApp.prewarm(url, variation)
325
+ : undefined,
326
+ variations: orestesApp
327
+ ? () => orestesApp.namedVariations()
328
+ : undefined,
329
+ rumBeacons: rumPi ? () => rumPi.beacons() : undefined,
330
+ cacheErrors: orestesApp
331
+ ? () => orestesApp.getLocalCacheErrors()
332
+ : undefined,
333
+ // The watcher's own rebuild groups, so an on-demand rebuild has the
334
+ // same blast radius as the file change that would have triggered it.
335
+ // It answers NO_REBUILD until the run has wired its watchers, which
336
+ // is after the page is ready.
337
+ rebuild: (target) => fileWatcher.rebuild(target),
338
+ validate: () => validateLoadedConfig(customerConfig, files),
339
+ // Evaluated per call, not captured: the config is the thing being
340
+ // edited, and explaining a url against the version loaded at startup
341
+ // would answer about a file the user has since changed.
342
+ speedKitConfig: () => files
343
+ .getSpeedKitConfig()
344
+ .evaluate(customerConfig.app, customerConfig.origins[0]),
345
+ })
346
+ : undefined;
347
+ return new OnboardingService(browserContext, customerConfig, fetchHandler, fileWatcher, cli, messageHandler, extensionBridge, speedKitServiceWorkerJs, browserFetch, controlServer, browserSession, this.run);
250
348
  }
251
- async prepareMessagehandler(athenaClient, files, customerConfig) {
349
+ async prepareMessagehandler(athenaClient, files, customerConfig, todos) {
252
350
  const messageHandler = new DevtoolsExtensionApi();
253
351
  messageHandler.addMessage({
254
352
  id: "skCli",
@@ -261,10 +359,9 @@ export class OnboardingServiceFactory {
261
359
  id: "athena",
262
360
  data: { client: !!athenaClient },
263
361
  });
264
- const fileTodoCollector = new TodoCollector(files.getInstallResources());
265
362
  messageHandler.addMessage({
266
363
  id: "todo",
267
- data: [...fileTodoCollector.getOpenTasks()],
364
+ data: [...todos.getOpenTasks()],
268
365
  });
269
366
  const appToken = await this.getAppToken(customerConfig.app);
270
367
  if (appToken) {
@@ -288,15 +385,21 @@ export class OnboardingServiceFactory {
288
385
  return result.data.token ?? null;
289
386
  }
290
387
  async buildInstallResource(speedKitInstallContext, files, cli) {
291
- cli.startAction("ONBOARDING:BUILD:INSTALL_RESOURCE", "build file install_resource");
388
+ cli.startAction("ONBOARDING:BUILD:INSTALL_RESOURCE", "build file install_resource", { scope: "config" });
292
389
  const installResourceFile = new VirtualFile(INTEGRATION_FILES.BUILD.INSTALL, new InstallFileRecipe(speedKitInstallContext));
293
390
  const result = await safe(installResourceFile.buildContent());
294
391
  if (result.success === true) {
295
392
  files.addFile(installResourceFile);
296
- cli.successAction("ONBOARDING:BUILD:INSTALL_RESOURCE");
393
+ cli.successAction("ONBOARDING:BUILD:INSTALL_RESOURCE", undefined, {
394
+ scope: "config",
395
+ data: { file: INTEGRATION_FILES.BUILD.INSTALL },
396
+ });
297
397
  return;
298
398
  }
299
- cli.failAction("ONBOARDING:BUILD:INSTALL_RESOURCE", result.error);
399
+ cli.failAction("ONBOARDING:BUILD:INSTALL_RESOURCE", result.error, {
400
+ scope: "config",
401
+ data: { file: INTEGRATION_FILES.BUILD.INSTALL, error: result.error },
402
+ });
300
403
  }
301
404
  async getAthenaClient(app) {
302
405
  // no promptForLogin: onboarding shows the Athena data when a login is
@@ -350,8 +453,19 @@ export class OnboardingServiceFactory {
350
453
  const orestesApp = new VirtualOrestesApp(customerConfig, originFetcher, documentHandler, cache, cli, messageHandler, this.context.ignoreContentSecurityPolicy);
351
454
  // let config-file changes re-warm the dh-cache in the background
352
455
  fileWatcher.setCacheRefresher(orestesApp);
353
- handlers.push(new SpeedKitAssetRequest(customerConfig, orestesApp), new SpeedKitRumPiRequest(customerConfig, orestesApp));
354
- return new FetchEventHandler(handlers, customerConfig, cli, configApi);
456
+ const rumPi = new SpeedKitRumPiRequest(customerConfig, orestesApp);
457
+ handlers.push(new SpeedKitAssetRequest(customerConfig, orestesApp), rumPi);
458
+ return {
459
+ rumPi,
460
+ fetchHandler: new FetchEventHandler({
461
+ browserFetchEvents: handlers,
462
+ customerConfig,
463
+ cli,
464
+ client: configApi,
465
+ requestLog: this.requestLog,
466
+ }),
467
+ orestesApp,
468
+ };
355
469
  }
356
470
  async getIntegrationFiles(cli) {
357
471
  const projectRoot = path.resolve(this.context.customerPath, "../..");
@@ -376,7 +490,7 @@ export class OnboardingServiceFactory {
376
490
  ];
377
491
  // if speed-kit is npm-linked, use linked local files else fetch latest released sw and df
378
492
  if (isSpeedKitLinked) {
379
- cli.writeWarning(`Linked Speed-Kit found in node_modules. Using built sw, df and loader.`);
493
+ cli.writeWarning(`Linked Speed-Kit found in node_modules. Using built sw, df and loader.`, false, { scope: "config", data: { speedKitLinked: true } });
380
494
  integrationApiArray.push({
381
495
  name: INTEGRATION_FILES.CUSTOM.SW,
382
496
  recipe: new StaticRecipe(fs.readFileSync(swPath, "utf-8")),