@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
@@ -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")),
@@ -7,6 +7,8 @@ import { CliServiceInterface } from "../cli/index.js";
7
7
  import { DevtoolsExtensionApi } from "./browser/extension/devtools-extension-api.js";
8
8
  import { ExtensionBridge } from "./browser/extension/extension-bridge.js";
9
9
  import { BrowserOriginFetchHandle } from "../browser-fetch/index.js";
10
+ import { BrowserSession, ControlServer } from "./control/index.js";
11
+ import { RunHandle } from "../run-registry/index.js";
10
12
  /**
11
13
  * Represents the OnboardingService which is responsible for setting up the browser to test a config using Puppeteer.
12
14
  */
@@ -20,10 +22,22 @@ export declare class OnboardingService {
20
22
  private extensionBridge;
21
23
  private speedKitServiceWorkerJs;
22
24
  private browserFetch?;
25
+ /** Absent when the run was not recorded, e.g. in a test harness. */
26
+ private controlServer?;
27
+ /** Filled in once the page is ready, so control ops can reach it. */
28
+ private browserSession?;
29
+ /** So the run can be stamped where the reason for ending is known. */
30
+ private runHandle?;
23
31
  private reinstallOnNextNavigate;
24
32
  private lastForeignSwReinstall;
25
33
  private readonly activatedSwVersions;
26
- constructor(browserContext: BrowserContext, customerConfig: CustomerConfig, fetchEventHandler: FetchEventHandler, fileWatcher: FileWatcher, cli: CliServiceInterface, developmentToolsMessages: DevtoolsExtensionApi, extensionBridge: ExtensionBridge, speedKitServiceWorkerJs: SpeedKitServiceWorkerJs, browserFetch?: BrowserOriginFetchHandle);
34
+ constructor(browserContext: BrowserContext, customerConfig: CustomerConfig, fetchEventHandler: FetchEventHandler, fileWatcher: FileWatcher, cli: CliServiceInterface, developmentToolsMessages: DevtoolsExtensionApi, extensionBridge: ExtensionBridge, speedKitServiceWorkerJs: SpeedKitServiceWorkerJs, browserFetch?: BrowserOriginFetchHandle,
35
+ /** Absent when the run was not recorded, e.g. in a test harness. */
36
+ controlServer?: ControlServer,
37
+ /** Filled in once the page is ready, so control ops can reach it. */
38
+ browserSession?: BrowserSession,
39
+ /** So the run can be stamped where the reason for ending is known. */
40
+ runHandle?: RunHandle);
27
41
  /**
28
42
  * Prepare the puppeteer browser, wire event listeners, navigate to the
29
43
  * install page, then block until either the caller aborts the signal
@@ -31,6 +45,13 @@ export declare class OnboardingService {
31
45
  * any still-open resources. File watchers close themselves via `signal`.
32
46
  */
33
47
  run(externalSignal: AbortSignal): Promise<void>;
48
+ /**
49
+ * Open the control socket, if this run has a directory to put it in.
50
+ *
51
+ * Non-fatal: a run that cannot be controlled from outside is still a run, and
52
+ * failing the developer's session over it would be the wrong trade.
53
+ */
54
+ private startControlServer;
34
55
  private prepareBrowser;
35
56
  private preparePage;
36
57
  /**
@@ -41,6 +62,19 @@ export declare class OnboardingService {
41
62
  * sk-cli. Without a loaded devtools extension there is nothing to attach
42
63
  * to — ExtensionValidator already reported why — so it is skipped.
43
64
  */
65
+ /**
66
+ * Say what an agent is doing, for the devtools extension to show.
67
+ *
68
+ * Reported, not drawn. The tab strip is browser UI with no CDP surface at
69
+ * all, so only an extension can colour it — and the one already loaded into
70
+ * the run owns that, keyed off this message. See `lib/agent-tab-state.ts` in
71
+ * team-pi/devtools.
72
+ *
73
+ * Upserted rather than appended: this is current state, not an event log, and
74
+ * a panel that had to dedupe a history to find the live value would be doing
75
+ * work this side can simply not create.
76
+ */
77
+ private reportAgentActivity;
44
78
  /**
45
79
  * Open the run's DevTools on the Speed Kit panel rather than on Elements.
46
80
  *
@@ -51,6 +85,11 @@ export declare class OnboardingService {
51
85
  private showDevtoolsPanelOnStart;
52
86
  private attachExtensionBridge;
53
87
  private findPage;
88
+ /**
89
+ * What service workers this run has seen. Nothing else records it — CDP only
90
+ * streams the events, so a reader arriving later has missed them.
91
+ */
92
+ private readonly serviceWorkers;
54
93
  private prepareCleanState;
55
94
  /**
56
95
  * Detects when the DEPLOYED service worker takes over the local session and
@@ -1,8 +1,9 @@
1
1
  import { BROWSER_EVENTS, CDP_SESSION, } from "./onboarding-model.js";
2
- import { PanelNotFoundError, showDevtoolsPanel, } from "./browser/extension/devtools-panel.js";
3
2
  import { safe } from "../../helpers/safe.js";
4
3
  import { isEmptyServiceWorkerUrl } from "./empty-service-worker.js";
5
4
  import { launchBrowser, resetBrowserState } from "./browser/launch-browser.js";
5
+ import { recordConsole } from "./browser/console-log.js";
6
+ import { ServiceWorkerTracker, } from "./control/index.js";
6
7
  // A SW version activating later than this after the last locally served sw.js
7
8
  // cannot originate from our interception — it is a deployed-build takeover.
8
9
  const LOCAL_SW_SERVE_GRACE_MS = 10_000;
@@ -21,10 +22,19 @@ export class OnboardingService {
21
22
  extensionBridge;
22
23
  speedKitServiceWorkerJs;
23
24
  browserFetch;
25
+ controlServer;
26
+ browserSession;
27
+ runHandle;
24
28
  reinstallOnNextNavigate = false;
25
29
  lastForeignSwReinstall = 0;
26
30
  activatedSwVersions = new Set();
27
- constructor(browserContext, customerConfig, fetchEventHandler, fileWatcher, cli, developmentToolsMessages, extensionBridge, speedKitServiceWorkerJs, browserFetch) {
31
+ constructor(browserContext, customerConfig, fetchEventHandler, fileWatcher, cli, developmentToolsMessages, extensionBridge, speedKitServiceWorkerJs, browserFetch,
32
+ /** Absent when the run was not recorded, e.g. in a test harness. */
33
+ controlServer,
34
+ /** Filled in once the page is ready, so control ops can reach it. */
35
+ browserSession,
36
+ /** So the run can be stamped where the reason for ending is known. */
37
+ runHandle) {
28
38
  this.browserContext = browserContext;
29
39
  this.customerConfig = customerConfig;
30
40
  this.fetchEventHandler = fetchEventHandler;
@@ -34,6 +44,9 @@ export class OnboardingService {
34
44
  this.extensionBridge = extensionBridge;
35
45
  this.speedKitServiceWorkerJs = speedKitServiceWorkerJs;
36
46
  this.browserFetch = browserFetch;
47
+ this.controlServer = controlServer;
48
+ this.browserSession = browserSession;
49
+ this.runHandle = runHandle;
37
50
  }
38
51
  /**
39
52
  * Prepare the puppeteer browser, wire event listeners, navigate to the
@@ -42,27 +55,71 @@ export class OnboardingService {
42
55
  * any still-open resources. File watchers close themselves via `signal`.
43
56
  */
44
57
  async run(externalSignal) {
45
- this.cli.startAction("ONBOARDING:PREPARE:BROWSER", `prepare browser ${this.cli.style.bold(this.browserContext.browserVersionString)}`);
58
+ this.cli.startAction("ONBOARDING:PREPARE:BROWSER", `prepare browser ${this.cli.style.bold(this.browserContext.browserVersionString)}`, {
59
+ scope: "browser",
60
+ data: { browser: this.browserContext.browserVersionString },
61
+ });
46
62
  const localController = new AbortController();
47
63
  const shutdownSignal = AbortSignal.any([
48
64
  externalSignal,
49
65
  localController.signal,
50
66
  ]);
67
+ await this.startControlServer(shutdownSignal);
51
68
  const browser = await this.prepareBrowser(localController);
52
69
  await this.attachExtensionBridge(browser);
53
70
  const page = await this.preparePage(browser, shutdownSignal);
54
- this.cli.successAction("ONBOARDING:PREPARE:BROWSER");
71
+ // The browser ops need more than a handle: the origins they may act on, and
72
+ // the run's own way of reinstalling. Both belong to the run, so they are
73
+ // lent rather than rediscovered.
74
+ //
75
+ // Every origin, not only the one this run started on. Storage is
76
+ // partitioned per origin, so an op that assumed the startup domain would
77
+ // act on the wrong site the moment the page moved to a sibling — and a
78
+ // multi-domain app is the normal case, not the exception.
79
+ this.browserSession?.attach(browser, page, {
80
+ origin: this.browserContext.domain,
81
+ origins: this.customerConfig.origins ?? [],
82
+ reinstall: () => this.reinstallSpeedKit(page, new URL(page.url()).pathname),
83
+ serviceWorkers: this.serviceWorkers,
84
+ setWorkerUserAgent: (userAgent) => {
85
+ this.speedKitServiceWorkerJs.userAgent = userAgent ?? undefined;
86
+ },
87
+ reportAgentActivity: (label, breakpoints, releasedAt) => this.reportAgentActivity(label, breakpoints, releasedAt),
88
+ extensionArms: () => this.extensionBridge.available,
89
+ devtoolsExtensionId: () => this.extensionBridge.devtoolsExtensionId,
90
+ });
91
+ this.cli.successAction("ONBOARDING:PREPARE:BROWSER", undefined, {
92
+ scope: "browser",
93
+ });
55
94
  // Not awaited: the panel registers a moment after DevTools opens, and the
56
95
  // run has no reason to wait for a convenience.
57
- void this.showDevtoolsPanelOnStart(page);
96
+ void this.showDevtoolsPanelOnStart();
58
97
  await this.navigate(page, `${this.customerConfig.scope}speed-kit-install.html?url=${this.customerConfig.scope}`);
59
98
  await waitForAbort(shutdownSignal);
99
+ // Before the browser closes, so nothing can evaluate against a page that is
100
+ // on its way out.
101
+ this.browserSession?.detach();
60
102
  await safe(browser.close());
61
103
  // The fetch browser only exists if an origin refused a direct request, but closing an unused
62
104
  // handle is free and leaving a Chrome behind is not.
63
105
  if (this.browserFetch)
64
106
  await safe(this.browserFetch.close());
65
107
  }
108
+ /**
109
+ * Open the control socket, if this run has a directory to put it in.
110
+ *
111
+ * Non-fatal: a run that cannot be controlled from outside is still a run, and
112
+ * failing the developer's session over it would be the wrong trade.
113
+ */
114
+ async startControlServer(signal) {
115
+ if (!this.controlServer) {
116
+ return;
117
+ }
118
+ const result = await safe(this.controlServer.listen(signal));
119
+ if (result.success !== true) {
120
+ this.cli.writeWarning(`control socket unavailable, external tools cannot reach this run: ${result.error}`, false, { data: { error: result.error } });
121
+ }
122
+ }
66
123
  async prepareBrowser(localController) {
67
124
  const browser = await launchBrowser(this.browserContext);
68
125
  for (const target of browser.targets()) {
@@ -71,7 +128,14 @@ export class OnboardingService {
71
128
  }
72
129
  }
73
130
  browser.on(BROWSER_EVENTS.DISCONNECTED, () => {
74
- this.cli.writeError("Browser disconnected, shutting down");
131
+ this.cli.writeError("Browser disconnected, shutting down", false, {
132
+ scope: "browser",
133
+ });
134
+ // Stamped here because this is the only place that knows *why* the run is
135
+ // ending. The command's exit handler cannot tell a closed window from a
136
+ // crash, and it can win the race to write first — recording it here means
137
+ // first-write-wins works for us rather than against us.
138
+ this.runHandle?.finish("stopped", "browser disconnected");
75
139
  localController.abort();
76
140
  });
77
141
  return browser;
@@ -81,6 +145,7 @@ export class OnboardingService {
81
145
  await safe(this.prepareCleanState(page));
82
146
  this.registerFileWatcher(page, shutdownSignal);
83
147
  this.registerReinstallSpeedKitOnNavigate(page);
148
+ recordConsole(page, this.cli);
84
149
  return page;
85
150
  }
86
151
  /**
@@ -91,6 +156,32 @@ export class OnboardingService {
91
156
  * sk-cli. Without a loaded devtools extension there is nothing to attach
92
157
  * to — ExtensionValidator already reported why — so it is skipped.
93
158
  */
159
+ /**
160
+ * Say what an agent is doing, for the devtools extension to show.
161
+ *
162
+ * Reported, not drawn. The tab strip is browser UI with no CDP surface at
163
+ * all, so only an extension can colour it — and the one already loaded into
164
+ * the run owns that, keyed off this message. See `lib/agent-tab-state.ts` in
165
+ * team-pi/devtools.
166
+ *
167
+ * Upserted rather than appended: this is current state, not an event log, and
168
+ * a panel that had to dedupe a history to find the live value would be doing
169
+ * work this side can simply not create.
170
+ */
171
+ async reportAgentActivity(label, breakpoints = [], releasedAt) {
172
+ this.developmentToolsMessages.upsertMessage({
173
+ id: "agent",
174
+ data: {
175
+ active: label !== null,
176
+ label,
177
+ breakpoints,
178
+ // The panel drops every breakpoint switch once per new value. See
179
+ // `mirrorArmedBreakpoints` in team-pi/devtools.
180
+ ...(releasedAt ? { releasedAt } : {}),
181
+ ...(label === null ? {} : { since: new Date().toISOString() }),
182
+ },
183
+ });
184
+ }
94
185
  /**
95
186
  * Open the run's DevTools on the Speed Kit panel rather than on Elements.
96
187
  *
@@ -98,22 +189,16 @@ export class OnboardingService {
98
189
  * tab, and where someone is looking at it. The selection reaches into
99
190
  * DevTools' internals, so a failure is a warning and nothing more.
100
191
  */
101
- async showDevtoolsPanelOnStart(page) {
102
- const extensionId = this.extensionBridge.devtoolsExtensionId;
103
- if (this.browserContext.headless || !extensionId) {
192
+ async showDevtoolsPanelOnStart() {
193
+ if (this.browserContext.headless ||
194
+ !this.browserSession ||
195
+ !this.extensionBridge.available) {
104
196
  return;
105
197
  }
106
- const result = await safe(showDevtoolsPanel(page, extensionId).catch((error) => {
107
- // Name the tabs DevTools did show, so a missing panel can be told
108
- // from a renamed one.
109
- if (!(error instanceof PanelNotFoundError))
110
- throw error;
111
- throw new Error(`${error.message} — DevTools shows ${error.tabs.join(", ") || "no tabs at all"}`);
112
- }));
113
- if (result.success === true) {
114
- return;
198
+ const result = await safe(this.browserSession.showPanel());
199
+ if (result.success !== true) {
200
+ this.cli.writeWarning(`DevTools did not open on the Speed Kit panel: ${result.error}`, false, { scope: "extension", data: { error: result.error } });
115
201
  }
116
- this.cli.writeWarning(`DevTools did not open on the Speed Kit panel: ${result.error}`);
117
202
  }
118
203
  async attachExtensionBridge(browser) {
119
204
  if (!this.extensionBridge.isAvailable) {
@@ -121,7 +206,7 @@ export class OnboardingService {
121
206
  }
122
207
  const result = await safe(this.extensionBridge.init(browser));
123
208
  if (result.success !== true) {
124
- this.cli.writeWarning(`ExtensionBridge unavailable, devtools panel will not receive live updates: ${result.error}`);
209
+ this.cli.writeWarning(`ExtensionBridge unavailable, devtools panel will not receive live updates: ${result.error}`, false, { scope: "extension", data: { error: result.error } });
125
210
  return;
126
211
  }
127
212
  this.developmentToolsMessages.setBridge(this.extensionBridge);
@@ -135,19 +220,32 @@ export class OnboardingService {
135
220
  }
136
221
  return browser.newPage();
137
222
  }
223
+ /**
224
+ * What service workers this run has seen. Nothing else records it — CDP only
225
+ * streams the events, so a reader arriving later has missed them.
226
+ */
227
+ serviceWorkers = new ServiceWorkerTracker();
138
228
  async prepareCleanState(page) {
139
229
  const cdpSession = await page.target().createCDPSession();
140
230
  await resetBrowserState(cdpSession, this.browserContext.domain);
141
231
  this.registerForeignSwGuard(page, cdpSession);
142
232
  safe(() => {
143
233
  cdpSession.on(CDP_SESSION.EVENTS.SERVICE_WORKER.REGISTRATION_UPDATED, ({ registrations, }) => {
234
+ this.serviceWorkers.recordRegistrations(registrations);
144
235
  for (const registration of registrations) {
145
236
  if (registration.isDeleted) {
146
237
  this.developmentToolsMessages.addMessage({
147
238
  id: "serviceWorker",
148
239
  data: `Unregistered Service Worker at ${registration.scopeURL} id: ${registration.registrationId}`,
149
240
  });
150
- this.cli.writeWarning(`${this.cli.style.yellow("Unregistered Service Worker")} at ${this.cli.style.bold(registration.scopeURL)} (${registration.registrationId})`);
241
+ this.cli.writeWarning(`${this.cli.style.yellow("Unregistered Service Worker")} at ${this.cli.style.bold(registration.scopeURL)} (${registration.registrationId})`, false, {
242
+ scope: "sw",
243
+ data: {
244
+ scopeURL: registration.scopeURL,
245
+ registrationId: registration.registrationId,
246
+ unregistered: true,
247
+ },
248
+ });
151
249
  }
152
250
  }
153
251
  });
@@ -173,11 +271,26 @@ export class OnboardingService {
173
271
  */
174
272
  registerForeignSwGuard(page, cdpSession) {
175
273
  cdpSession.on(CDP_SESSION.EVENTS.SERVICE_WORKER.VERSION_UPDATED, async ({ versions, }) => {
274
+ this.serviceWorkers.recordVersions(versions);
176
275
  for (const version of versions) {
177
276
  if (!this.isForeignSwVersion(version)) {
178
277
  continue;
179
278
  }
180
- this.cli.writeWarning(`${this.cli.style.yellow("Deployed Service Worker took over")} (version ${version.versionId}) — an update check bypassed the local interception. Reinstalling the local build.`);
279
+ // Recorded before the repair, so the takeover is visible even when
280
+ // the reinstall below is skipped by the cooldown.
281
+ this.serviceWorkers.recordTakeover(version.versionId);
282
+ // The field a reader counts on. A takeover is silent in the browser
283
+ // — with static routing the routes freeze at install time from the
284
+ // deployed config — so the only evidence it happened is this line,
285
+ // and `foreign` is what makes it findable without matching prose.
286
+ this.cli.writeWarning(`${this.cli.style.yellow("Deployed Service Worker took over")} (version ${version.versionId}) — an update check bypassed the local interception. Reinstalling the local build.`, false, {
287
+ scope: "sw",
288
+ data: {
289
+ versionId: version.versionId,
290
+ foreign: true,
291
+ takeover: true,
292
+ },
293
+ });
181
294
  this.developmentToolsMessages.addMessage({
182
295
  id: "serviceWorker",
183
296
  data: `Deployed Service Worker took over (version ${version.versionId}); reinstalling the local build`,
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The dh-cache is keyed by the full asset request url, which is a Speed Kit
3
+ * asset url with the origin url embedded in its path and the cache variation on
4
+ * a `bqvariation` search parameter:
5
+ *
6
+ * ```
7
+ * https://<app>.app.baqend.com/v1/asset/https://shop.example.com/p?bqvariation=mobile
8
+ * ```
9
+ *
10
+ * That is the right key — it is exactly what the browser asked for — and the
11
+ * wrong thing to show anyone. Decoding it is what lets a reader see
12
+ * `{originUrl, variation}` instead of 120 opaque characters.
13
+ */
14
+ /** What an absent `bqvariation` means, in the words `buildResponse` uses. */
15
+ export declare const DEFAULT_VARIATION = "default";
16
+ export interface DecodedAssetKey {
17
+ /** The origin url the entry is for, or the key itself if it does not decode. */
18
+ originUrl: string;
19
+ /** The cache variation, or null for the default. */
20
+ variation: string | null;
21
+ }
22
+ /**
23
+ * The origin url an asset request is for: everything after the asset path, with
24
+ * Speed Kit's own `bq*` parameters removed.
25
+ *
26
+ * Returns null when the key is not an asset url — a caller that cannot decode a
27
+ * key should say so rather than present a mangled one.
28
+ */
29
+ export declare function assetOriginUrl(key: string): string | null;
30
+ /**
31
+ * The key the dh-cache stores a request under: the request url without
32
+ * {@link BOOKKEEPING_PARAMETERS}.
33
+ *
34
+ * Keyed by the raw url, one page was several entries — `bqpi` counts page
35
+ * impressions, so a page's second request missed its first — and an entry
36
+ * `cache prewarm` built, which carries none of them, was never the one the
37
+ * page read. `bqcv` goes too: a run copies it from the deployed install
38
+ * resource, so it stays the same however the local config changes. A string
39
+ * that is not a url is returned as it is.
40
+ */
41
+ export declare function cacheKey(requestUri: string): string;
42
+ /** The variation an asset request carries, or null for the default. */
43
+ export declare function assetVariation(key: string): string | null;
44
+ export declare function decodeAssetKey(key: string): DecodedAssetKey;
45
+ /**
46
+ * The asset request url a browser would have sent for this origin url and
47
+ * variation — the key the dh-cache stores an entry under.
48
+ *
49
+ * The inverse of {@link decodeAssetKey}, and it has to agree with it exactly:
50
+ * an entry written under a key no request will ever match is cached and
51
+ * unreachable, which looks from outside like a cache that silently does
52
+ * nothing.
53
+ *
54
+ * The origin url goes in verbatim. Speed Kit strips query parameters in the
55
+ * *service worker*, before an asset request is made at all, so building the
56
+ * request here bypasses that — two urls differing only in a parameter stay two
57
+ * entries even where the worker would have collapsed them. That is the point
58
+ * for anyone comparing them, and a trap for anyone assuming this reproduces
59
+ * what the browser would have asked for.
60
+ */
61
+ export declare function assetRequestUrl(appDomain: string, originUrl: string, variation?: string): string;