@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
@@ -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;
@@ -0,0 +1,115 @@
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
+ const ASSET_PATH = "app.baqend.com/v1/asset/";
15
+ const VARIATION_PARAMETER = "bqvariation";
16
+ /** What an absent `bqvariation` means, in the words `buildResponse` uses. */
17
+ export const DEFAULT_VARIATION = "default";
18
+ /**
19
+ * The origin url an asset request is for: everything after the asset path, with
20
+ * Speed Kit's own `bq*` parameters removed.
21
+ *
22
+ * Returns null when the key is not an asset url — a caller that cannot decode a
23
+ * key should say so rather than present a mangled one.
24
+ */
25
+ export function assetOriginUrl(key) {
26
+ let url;
27
+ try {
28
+ url = new URL(key);
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ for (const name of [...url.searchParams.keys()]) {
34
+ if (name.startsWith("bq")) {
35
+ url.searchParams.delete(name);
36
+ }
37
+ }
38
+ const [, origin] = url.toString().split(ASSET_PATH);
39
+ return origin ?? null;
40
+ }
41
+ /**
42
+ * Speed Kit's per-request bookkeeping on an asset url: the deployed config and
43
+ * Speed Kit versions, the page-impression counter (with its `;…` suffix), the
44
+ * fetch mode and the debug pass. None of them changes the document the
45
+ * documentHandler builds.
46
+ */
47
+ const BOOKKEEPING_PARAMETERS = ["bqcv", "bqsk", "bqpi", "bqcache", "bqpass"];
48
+ /**
49
+ * The key the dh-cache stores a request under: the request url without
50
+ * {@link BOOKKEEPING_PARAMETERS}.
51
+ *
52
+ * Keyed by the raw url, one page was several entries — `bqpi` counts page
53
+ * impressions, so a page's second request missed its first — and an entry
54
+ * `cache prewarm` built, which carries none of them, was never the one the
55
+ * page read. `bqcv` goes too: a run copies it from the deployed install
56
+ * resource, so it stays the same however the local config changes. A string
57
+ * that is not a url is returned as it is.
58
+ */
59
+ export function cacheKey(requestUri) {
60
+ let url;
61
+ try {
62
+ url = new URL(requestUri);
63
+ }
64
+ catch {
65
+ return requestUri;
66
+ }
67
+ if (!BOOKKEEPING_PARAMETERS.some((name) => url.searchParams.has(name))) {
68
+ return requestUri;
69
+ }
70
+ for (const name of BOOKKEEPING_PARAMETERS) {
71
+ url.searchParams.delete(name);
72
+ }
73
+ return url.toString();
74
+ }
75
+ /** The variation an asset request carries, or null for the default. */
76
+ export function assetVariation(key) {
77
+ try {
78
+ return new URL(key).searchParams.get(VARIATION_PARAMETER)?.trim() || null;
79
+ }
80
+ catch {
81
+ return null;
82
+ }
83
+ }
84
+ export function decodeAssetKey(key) {
85
+ return {
86
+ originUrl: assetOriginUrl(key) ?? key,
87
+ variation: assetVariation(key),
88
+ };
89
+ }
90
+ /**
91
+ * The asset request url a browser would have sent for this origin url and
92
+ * variation — the key the dh-cache stores an entry under.
93
+ *
94
+ * The inverse of {@link decodeAssetKey}, and it has to agree with it exactly:
95
+ * an entry written under a key no request will ever match is cached and
96
+ * unreachable, which looks from outside like a cache that silently does
97
+ * nothing.
98
+ *
99
+ * The origin url goes in verbatim. Speed Kit strips query parameters in the
100
+ * *service worker*, before an asset request is made at all, so building the
101
+ * request here bypasses that — two urls differing only in a parameter stay two
102
+ * entries even where the worker would have collapsed them. That is the point
103
+ * for anyone comparing them, and a trap for anyone assuming this reproduces
104
+ * what the browser would have asked for.
105
+ */
106
+ export function assetRequestUrl(appDomain, originUrl, variation) {
107
+ const url = new URL(`https://${appDomain}/v1/asset/${originUrl}`);
108
+ // The default carries no parameter, because that is how the worker sends it
109
+ // and `buildResponse` reads its absence as `default`. Writing it explicitly
110
+ // would key the default variation apart from every entry the browser makes.
111
+ if (variation && variation !== DEFAULT_VARIATION) {
112
+ url.searchParams.set(VARIATION_PARAMETER, variation);
113
+ }
114
+ return url.toString();
115
+ }
@@ -1,15 +1,72 @@
1
+ import { Protocol } from "devtools-protocol";
1
2
  import { BaqendResponse } from "../browser/baqend-response.js";
2
3
  import { CliServiceInterface } from "../../cli/index.js";
4
+ /** What the cache remembers about an entry, without holding its body. */
5
+ export interface CacheEntry {
6
+ status: number;
7
+ headers: Protocol.Fetch.HeaderEntry[];
8
+ contentType: string | null;
9
+ /** Size of the decoded body. */
10
+ bytes: number;
11
+ /** Hash of the content, so "did the origin actually change" is answerable. */
12
+ sha: string;
13
+ /** Where the decoded body lives. */
14
+ path: string;
15
+ cachedAt: string;
16
+ }
3
17
  /**
4
- * This class represents a cache for storing responses from the localDocumentHandler.
18
+ * The local documentHandler's response cache, kept on disk.
19
+ *
20
+ * Bodies are written as they are cached and read back when they are served,
21
+ * rather than held in memory. A transformed page is commonly several hundred
22
+ * kilobytes, and `BaqendResponse` stores its body base64-encoded — a third
23
+ * larger again — so a session that browses a site of any size accumulates
24
+ * hundreds of megabytes it never releases.
25
+ *
26
+ * Stored **decoded**. The content exists decoded before a response is built,
27
+ * and only Chrome's `Fetch.fulfillRequest` needs base64, so encoding on the way
28
+ * out is both cheaper and leaves a file that can simply be opened.
29
+ *
30
+ * The read this adds to a cache hit is nothing next to what follows it: the
31
+ * file was written moments ago and is in the page cache, while the response
32
+ * still has to cross CDP into Chrome.
33
+ *
34
+ * Living in the run directory means two further things fall out. The bodies are
35
+ * pruned by the run's own retention, and a finished run's cache is still
36
+ * readable — which is what makes a post-mortem possible at all.
5
37
  */
6
38
  export declare class Cache {
7
39
  private cli;
8
- private inMemoryCache;
9
- constructor(cli: CliServiceInterface);
10
- getAll(): IterableIterator<[string, BaqendResponse]>;
40
+ private readonly directory;
41
+ private readonly entries;
42
+ constructor(cli: CliServiceInterface, directory: string);
43
+ /** Metadata for every entry. No body is read. */
44
+ getAll(): IterableIterator<[string, CacheEntry]>;
45
+ /** Metadata for one entry, without touching the disk. */
46
+ getMeta(requestUri: string): CacheEntry | null;
47
+ has(requestUri: string): boolean;
48
+ /**
49
+ * The cached response, rebuilt from disk.
50
+ *
51
+ * Returns null when the entry is unknown *or* its body has gone — a file
52
+ * removed underneath us is a cache miss, not a crash.
53
+ */
11
54
  getEntry(requestUri: string): BaqendResponse | null;
12
- addEntry(requestUri: string, response: BaqendResponse): void;
55
+ /**
56
+ * @param body the response as it exists before Chrome's base64 encoding.
57
+ */
58
+ addEntry(requestUri: string, response: BaqendResponse, body: string | Buffer): void;
59
+ /** Note: a **substring** match over keys, not an exact one. It surprises people. */
13
60
  removeEntry(requestUri: string): void;
14
61
  clear(): void;
62
+ /** Everything this cache wrote, for a run that is shutting down. */
63
+ destroy(): void;
64
+ /**
65
+ * Named after the key, not the content.
66
+ *
67
+ * Content-addressing would let two urls with identical bodies share a file,
68
+ * and then evicting one would pull the body out from under the other.
69
+ */
70
+ private pathFor;
71
+ private unlink;
15
72
  }