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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (416) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1369 -10
  3. package/dist/base/run-control-command.d.ts +15 -0
  4. package/dist/base/run-control-command.js +20 -0
  5. package/dist/build-info.json +6 -0
  6. package/dist/commands/diff.d.ts +6 -1
  7. package/dist/commands/diff.js +9 -3
  8. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  9. package/dist/commands/onboarding/browser/click.js +19 -0
  10. package/dist/commands/onboarding/browser/emulate.d.ts +93 -0
  11. package/dist/commands/onboarding/browser/emulate.js +23 -0
  12. package/dist/commands/onboarding/browser/navigate.d.ts +67 -0
  13. package/dist/commands/onboarding/browser/navigate.js +18 -0
  14. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  15. package/dist/commands/onboarding/browser/panel.js +12 -0
  16. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  17. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  18. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  19. package/dist/commands/onboarding/browser/reset.js +18 -0
  20. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  21. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  22. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  23. package/dist/commands/onboarding/browser/state.js +12 -0
  24. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  25. package/dist/commands/onboarding/browser/tabs.js +16 -0
  26. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  27. package/dist/commands/onboarding/cache/clear.js +12 -0
  28. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  29. package/dist/commands/onboarding/cache/errors.js +12 -0
  30. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  31. package/dist/commands/onboarding/cache/evict.js +15 -0
  32. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  33. package/dist/commands/onboarding/cache/get.js +17 -0
  34. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  35. package/dist/commands/onboarding/cache/list.js +15 -0
  36. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  37. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  38. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  39. package/dist/commands/onboarding/cache/refresh.js +18 -0
  40. package/dist/commands/onboarding/cdp.d.ts +81 -0
  41. package/dist/commands/onboarding/cdp.js +18 -0
  42. package/dist/commands/onboarding/debug/arm.d.ts +77 -0
  43. package/dist/commands/onboarding/debug/arm.js +18 -0
  44. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  45. package/dist/commands/onboarding/debug/await.js +18 -0
  46. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  47. package/dist/commands/onboarding/debug/disarm.js +12 -0
  48. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  49. package/dist/commands/onboarding/debug/eval.js +16 -0
  50. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  51. package/dist/commands/onboarding/debug/release.js +12 -0
  52. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  53. package/dist/commands/onboarding/debug/resume.js +12 -0
  54. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  55. package/dist/commands/onboarding/debug/status.js +12 -0
  56. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  57. package/dist/commands/onboarding/debug/step.js +15 -0
  58. package/dist/commands/onboarding/files/list.d.ts +58 -0
  59. package/dist/commands/onboarding/files/list.js +12 -0
  60. package/dist/commands/onboarding/files/read.d.ts +73 -0
  61. package/dist/commands/onboarding/files/read.js +16 -0
  62. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  63. package/dist/commands/onboarding/files/rebuild.js +18 -0
  64. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  65. package/dist/commands/onboarding/files/validate.js +12 -0
  66. package/dist/commands/onboarding/fouc.d.ts +77 -0
  67. package/dist/commands/onboarding/fouc.js +16 -0
  68. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  69. package/dist/commands/onboarding/inject/add.js +17 -0
  70. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  71. package/dist/commands/onboarding/inject/clear.js +12 -0
  72. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  73. package/dist/commands/onboarding/inject/list.js +12 -0
  74. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  75. package/dist/commands/onboarding/inject/read.js +18 -0
  76. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  77. package/dist/commands/onboarding/inject/recipes.js +12 -0
  78. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  79. package/dist/commands/onboarding/inject/remove.js +15 -0
  80. package/dist/commands/onboarding/list.d.ts +13 -0
  81. package/dist/commands/onboarding/list.js +12 -0
  82. package/dist/commands/onboarding/logs.d.ts +41 -0
  83. package/dist/commands/onboarding/logs.js +256 -0
  84. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  85. package/dist/commands/onboarding/navwalk.js +19 -0
  86. package/dist/commands/onboarding/response.d.ts +67 -0
  87. package/dist/commands/onboarding/response.js +18 -0
  88. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  89. package/dist/commands/onboarding/rum/beacons.js +16 -0
  90. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  91. package/dist/commands/onboarding/rum/get.js +18 -0
  92. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  93. package/dist/commands/onboarding/rum/key.js +13 -0
  94. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  95. package/dist/commands/onboarding/rum/previous.js +12 -0
  96. package/dist/commands/onboarding/status.d.ts +13 -0
  97. package/dist/commands/onboarding/status.js +17 -0
  98. package/dist/commands/onboarding/todo.d.ts +58 -0
  99. package/dist/commands/onboarding/todo.js +12 -0
  100. package/dist/commands/onboarding/viewport.d.ts +101 -0
  101. package/dist/commands/onboarding/viewport.js +18 -0
  102. package/dist/commands/onboarding/watch.d.ts +93 -0
  103. package/dist/commands/onboarding/watch.js +16 -0
  104. package/dist/commands/onboarding.d.ts +26 -0
  105. package/dist/commands/onboarding.js +220 -3
  106. package/dist/commands/origin-request.d.ts +4 -0
  107. package/dist/commands/origin-request.js +4 -0
  108. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  109. package/dist/commands/spec/onboarding.spec.js +127 -0
  110. package/dist/services/cli/build-info.d.ts +33 -0
  111. package/dist/services/cli/build-info.js +63 -0
  112. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  113. package/dist/services/cli/cli-environment-factory.js +1 -0
  114. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  115. package/dist/services/cli/cli-service-factory.js +1 -1
  116. package/dist/services/cli/cli-service-model.d.ts +29 -10
  117. package/dist/services/cli/cli-service.d.ts +60 -11
  118. package/dist/services/cli/cli-service.js +196 -32
  119. package/dist/services/cli/index.d.ts +2 -0
  120. package/dist/services/cli/index.js +2 -0
  121. package/dist/services/cli/sink.d.ts +47 -0
  122. package/dist/services/cli/sink.js +31 -0
  123. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  124. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  125. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  126. package/dist/services/cli/spec/build-info.spec.js +10 -0
  127. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  128. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  129. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  130. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  131. package/dist/services/cli/spec/memory-cli.js +9 -0
  132. package/dist/services/diff/config-at-ref.d.ts +20 -0
  133. package/dist/services/diff/config-at-ref.js +33 -0
  134. package/dist/services/diff/diff-service-build-context.d.ts +8 -0
  135. package/dist/services/diff/diff-service-build-context.js +40 -1
  136. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  137. package/dist/services/diff/diff-service-factory.js +48 -20
  138. package/dist/services/diff/diff-service.d.ts +11 -0
  139. package/dist/services/diff/diff-service.js +37 -11
  140. package/dist/services/diff/page-source.d.ts +12 -0
  141. package/dist/services/diff/page-source.js +16 -11
  142. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  143. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  144. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  145. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  146. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  147. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  148. package/dist/services/git/git-repository.d.ts +2 -0
  149. package/dist/services/git/git-repository.js +6 -0
  150. package/dist/services/integration-api/customer-config-flags.js +1 -0
  151. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  152. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  153. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  154. package/dist/services/onboarding/browser/console-log.js +27 -0
  155. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  156. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  157. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  158. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  159. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  160. package/dist/services/onboarding/control/body-inspect.js +106 -0
  161. package/dist/services/onboarding/control/browser-session.d.ts +521 -0
  162. package/dist/services/onboarding/control/browser-session.js +1273 -0
  163. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  164. package/dist/services/onboarding/control/config-validation.js +46 -0
  165. package/dist/services/onboarding/control/control-protocol.d.ts +1390 -0
  166. package/dist/services/onboarding/control/control-protocol.js +69 -0
  167. package/dist/services/onboarding/control/control-server.d.ts +284 -0
  168. package/dist/services/onboarding/control/control-server.js +1609 -0
  169. package/dist/services/onboarding/control/debug-session.d.ts +190 -0
  170. package/dist/services/onboarding/control/debug-session.js +801 -0
  171. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  172. package/dist/services/onboarding/control/fouc.js +151 -0
  173. package/dist/services/onboarding/control/index.d.ts +4 -0
  174. package/dist/services/onboarding/control/index.js +4 -0
  175. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  176. package/dist/services/onboarding/control/navwalk.js +248 -0
  177. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  178. package/dist/services/onboarding/control/preload-registry.js +829 -0
  179. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  180. package/dist/services/onboarding/control/response-explainer.js +257 -0
  181. package/dist/services/onboarding/control/rum.d.ts +8 -0
  182. package/dist/services/onboarding/control/rum.js +220 -0
  183. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  184. package/dist/services/onboarding/control/service-worker-tracker.js +119 -0
  185. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  186. package/dist/services/onboarding/control/viewport.js +344 -0
  187. package/dist/services/onboarding/control/watch.d.ts +26 -0
  188. package/dist/services/onboarding/control/watch.js +149 -0
  189. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  190. package/dist/services/onboarding/dashboard/index.js +7 -2
  191. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  192. package/dist/services/onboarding/fetch-event-handler.js +94 -32
  193. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +4 -25
  194. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  195. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  196. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  197. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  198. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  199. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  200. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  201. package/dist/services/onboarding/html-charset.d.ts +28 -0
  202. package/dist/services/onboarding/html-charset.js +57 -0
  203. package/dist/services/onboarding/onboarding-model.d.ts +30 -1
  204. package/dist/services/onboarding/onboarding-model.js +10 -1
  205. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  206. package/dist/services/onboarding/onboarding-service-build-context.js +6 -0
  207. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  208. package/dist/services/onboarding/onboarding-service-factory.js +131 -17
  209. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  210. package/dist/services/onboarding/onboarding-service.js +135 -22
  211. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  212. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  213. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  214. package/dist/services/onboarding/request-cache/cache.js +128 -17
  215. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  216. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  217. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  218. package/dist/services/onboarding/spec/control/browser-session.spec.js +526 -0
  219. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  220. package/dist/services/onboarding/spec/control/control-server.spec.js +338 -0
  221. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  222. package/dist/services/onboarding/spec/control/debug-session.spec.js +693 -0
  223. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  224. package/dist/services/onboarding/spec/control/fakes.js +66 -0
  225. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  226. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  227. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  228. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  229. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  230. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  231. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  232. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  233. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  234. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  235. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  236. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  237. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  238. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  239. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  240. package/dist/services/onboarding/spec/control/watch.spec.js +172 -0
  241. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  242. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +202 -0
  243. package/dist/services/onboarding/spec/fetch-events/customer-domain-document-response.spec.d.ts +1 -0
  244. package/dist/services/onboarding/spec/fetch-events/customer-domain-document-response.spec.js +39 -0
  245. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  246. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  247. package/dist/services/onboarding/spec/html-charset.spec.d.ts +1 -0
  248. package/dist/services/onboarding/spec/html-charset.spec.js +58 -0
  249. package/dist/services/onboarding/spec/onboarding-model.spec.js +37 -0
  250. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -0
  251. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  252. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  253. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  254. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  255. package/dist/services/onboarding/spec/virtual-orestes-app/index.spec.d.ts +1 -0
  256. package/dist/services/onboarding/spec/virtual-orestes-app/index.spec.js +19 -0
  257. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  258. package/dist/services/onboarding/todo-collector.js +49 -12
  259. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +34 -0
  260. package/dist/services/onboarding/virtual-orestes-app/index.js +85 -53
  261. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  262. package/dist/services/origin-request/asset-variations.js +11 -4
  263. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  264. package/dist/services/origin-request/origin-fetcher.js +43 -5
  265. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  266. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  267. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  268. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  269. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  270. package/dist/services/origin-request/origin-request-service.js +273 -49
  271. package/dist/services/origin-request/runtime-config-source.js +9 -4
  272. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  273. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  274. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  275. package/dist/services/query-builder/rules/rule-match.js +70 -0
  276. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  277. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  278. package/dist/services/run-control/browser/run-browser-contexts.d.ts +541 -0
  279. package/dist/services/run-control/browser/run-browser-contexts.js +78 -0
  280. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  281. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  282. package/dist/services/run-control/browser/run-browser-service.d.ts +64 -0
  283. package/dist/services/run-control/browser/run-browser-service.js +199 -0
  284. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  285. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  286. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  287. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  288. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  289. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  290. package/dist/services/run-control/control-client.d.ts +36 -0
  291. package/dist/services/run-control/control-client.js +147 -0
  292. package/dist/services/run-control/debug/run-debug-contexts.d.ts +411 -0
  293. package/dist/services/run-control/debug/run-debug-contexts.js +44 -0
  294. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  295. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  296. package/dist/services/run-control/debug/run-debug-service.d.ts +38 -0
  297. package/dist/services/run-control/debug/run-debug-service.js +161 -0
  298. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  299. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  300. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  301. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  302. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  303. package/dist/services/run-control/files/run-files-service.js +120 -0
  304. package/dist/services/run-control/index.d.ts +32 -0
  305. package/dist/services/run-control/index.js +31 -0
  306. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  307. package/dist/services/run-control/inject/run-inject-contexts.js +32 -0
  308. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  309. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  310. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  311. package/dist/services/run-control/inject/run-inject-service.js +203 -0
  312. package/dist/services/run-control/live-run.d.ts +37 -0
  313. package/dist/services/run-control/live-run.js +56 -0
  314. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  315. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  316. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  317. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  318. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  319. package/dist/services/run-control/probe/run-probe-service.js +193 -0
  320. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  321. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  322. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  323. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  324. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  325. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  326. package/dist/services/run-control/run-answer.d.ts +28 -0
  327. package/dist/services/run-control/run-answer.js +58 -0
  328. package/dist/services/run-control/run-control-context.d.ts +102 -0
  329. package/dist/services/run-control/run-control-context.js +36 -0
  330. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  331. package/dist/services/run-control/run-control-flags.js +22 -0
  332. package/dist/services/run-control/run-control-model.d.ts +9 -0
  333. package/dist/services/run-control/run-control-model.js +1 -0
  334. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  335. package/dist/services/run-control/run-control-service-factory.js +26 -0
  336. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  337. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  338. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  339. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  340. package/dist/services/run-control/session/run-session-service.d.ts +25 -0
  341. package/dist/services/run-control/session/run-session-service.js +95 -0
  342. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  343. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
  344. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  345. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  346. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  347. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  348. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  349. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  350. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  351. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +224 -0
  352. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  353. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  354. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  355. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  356. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  357. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  358. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  359. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  360. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  361. package/dist/services/run-control/spec/session/run-session-service.spec.js +101 -0
  362. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  363. package/dist/services/run-log/crash-mirror.js +69 -0
  364. package/dist/services/run-log/index.d.ts +11 -0
  365. package/dist/services/run-log/index.js +11 -0
  366. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  367. package/dist/services/run-log/jsonl-appender.js +91 -0
  368. package/dist/services/run-log/log-event-model.d.ts +104 -0
  369. package/dist/services/run-log/log-event-model.js +56 -0
  370. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  371. package/dist/services/run-log/log-query-service-factory.js +14 -0
  372. package/dist/services/run-log/log-query-service.d.ts +59 -0
  373. package/dist/services/run-log/log-query-service.js +111 -0
  374. package/dist/services/run-log/log-reader.d.ts +84 -0
  375. package/dist/services/run-log/log-reader.js +180 -0
  376. package/dist/services/run-log/log-summary.d.ts +72 -0
  377. package/dist/services/run-log/log-summary.js +208 -0
  378. package/dist/services/run-log/redaction.d.ts +34 -0
  379. package/dist/services/run-log/redaction.js +124 -0
  380. package/dist/services/run-log/request-log.d.ts +80 -0
  381. package/dist/services/run-log/request-log.js +69 -0
  382. package/dist/services/run-log/request-summary.d.ts +76 -0
  383. package/dist/services/run-log/request-summary.js +0 -0
  384. package/dist/services/run-log/run-log.d.ts +61 -0
  385. package/dist/services/run-log/run-log.js +102 -0
  386. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  387. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  388. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  389. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  390. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  391. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  392. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  393. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  394. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  395. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  396. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  397. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  398. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  399. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  400. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  401. package/dist/services/run-registry/exit-classification.js +42 -0
  402. package/dist/services/run-registry/index.d.ts +3 -0
  403. package/dist/services/run-registry/index.js +3 -0
  404. package/dist/services/run-registry/process-identity.d.ts +28 -0
  405. package/dist/services/run-registry/process-identity.js +80 -0
  406. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  407. package/dist/services/run-registry/run-registry-model.js +16 -0
  408. package/dist/services/run-registry/run-registry.d.ts +150 -0
  409. package/dist/services/run-registry/run-registry.js +409 -0
  410. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  411. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  412. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  413. package/dist/services/run-registry/spec/run-registry.spec.js +509 -0
  414. package/dist/services/setup/os/tool-registry.js +2 -2
  415. package/oclif.manifest.json +3293 -272
  416. package/package.json +21 -3
@@ -0,0 +1,19 @@
1
+ import { expect } from "chai";
2
+ import { describe, it } from "mocha";
3
+ import iconv from "iconv-lite";
4
+ import { VirtualOrestesApp } from "../../virtual-orestes-app/index.js";
5
+ describe("VirtualOrestesApp", () => {
6
+ it("decodes the Speed Kit document by its <meta charset>", async () => {
7
+ const html = '<html><head><meta charset="shift_jis"><title>掃除機</title></head></html>';
8
+ const body = iconv.encode(html, "shift_jis");
9
+ // getResponseText needs no collaborator, so the constructor is skipped.
10
+ const app = Object.create(VirtualOrestesApp.prototype);
11
+ const result = await app["getResponseText"](new Response(new Uint8Array(body), {
12
+ headers: { "content-type": "text/html" },
13
+ }));
14
+ expect(result).to.deep.equal({
15
+ responseContent: html,
16
+ textEncoding: "shift_jis",
17
+ });
18
+ });
19
+ });
@@ -1,13 +1,18 @@
1
1
  import { InstallResourceInterface } from "../integration-api/integration-api-model.js";
2
2
  export interface task {
3
3
  todo: string;
4
+ /** The three lines beneath it, URI-encoded — see {@link TodoCollector}. */
4
5
  context: string;
5
6
  file: string;
6
7
  line: number;
7
8
  }
8
9
  /**
9
- * Represents a TodoCollector class that collects open tasks from files.
10
- * This files will then be injected to the current open page, so you or the browser-extension can access and display them
10
+ * Collects the open tasks written into a customer's config files.
11
+ *
12
+ * Read by two consumers with different needs: the devtools panel, which the
13
+ * messages are shaped for, and `sk onboarding todo` over the control socket. `context` is
14
+ * URI-encoded because the panel's transport expects it that way; the control
15
+ * handler decodes it again rather than handing an agent percent-escapes.
11
16
  */
12
17
  export declare class TodoCollector {
13
18
  private files;
@@ -1,8 +1,35 @@
1
1
  import { FILE_TYPE } from "../integration-api/index.js";
2
- const TODO_MATCH = /(todo[^\n\r()|]*)((?:(?:\r\n|\r|\n)[^\n\r()|]*){3})/i;
3
2
  /**
4
- * Represents a TodoCollector class that collects open tasks from files.
5
- * This files will then be injected to the current open page, so you or the browser-extension can access and display them
3
+ * A `TODO` and the three lines under it.
4
+ *
5
+ * Global on purpose. It used to be matched with a non-global regex through
6
+ * `String.replace`, which calls its replacer once — so a file with four open
7
+ * tasks reported one, and the other three were invisible to both the devtools
8
+ * panel and anything else that asked.
9
+ *
10
+ * Three further things that each silently dropped a task, all of them found
11
+ * against a real config:
12
+ *
13
+ * - **The context is a lookahead.** Consuming the three lines moved
14
+ * `lastIndex` past them, so a second `TODO` written inside that window was
15
+ * swallowed into the first one's context and never reported. Two notes in a
16
+ * row is the ordinary way people write them.
17
+ * - **Parentheses are allowed.** The text and the context lines used to be
18
+ * `[^\n\r()|]*`, so a `(`, `)` or `|` anywhere in the task or in the three
19
+ * lines beneath it failed the whole match and the task vanished — and a JS
20
+ * config is full of them. `// TODO confirm the wishlist pattern` sitting one
21
+ * line above `/wish(-)?list/i` was invisible.
22
+ * - **Fewer than three lines is enough.** `{3}` required them, so a `TODO` in
23
+ * the last lines of a file matched nothing.
24
+ */
25
+ const TODO_MATCH = /(todo[^\n\r]*)(?=((?:(?:\r\n|\r|\n)[^\n\r]*){0,3}))/gi;
26
+ /**
27
+ * Collects the open tasks written into a customer's config files.
28
+ *
29
+ * Read by two consumers with different needs: the devtools panel, which the
30
+ * messages are shaped for, and `sk onboarding todo` over the control socket. `context` is
31
+ * URI-encoded because the panel's transport expects it that way; the control
32
+ * handler decodes it again rather than handing an agent percent-escapes.
6
33
  */
7
34
  export class TodoCollector {
8
35
  files;
@@ -10,21 +37,31 @@ export class TodoCollector {
10
37
  this.files = files;
11
38
  }
12
39
  getOpenTasks() {
13
- const configFiles = this.files.filter((file) => {
14
- return !(file.type === FILE_TYPE.VIRTUAL_FILE);
15
- });
40
+ const configFiles = this.files.filter((file) => file.type !== FILE_TYPE.VIRTUAL_FILE);
16
41
  const tasks = [];
17
42
  for (const configFile of configFiles) {
18
43
  const content = configFile.getContent();
19
- content.replace(TODO_MATCH, (taskString, task, taskContext) => {
44
+ // A fresh regex per file: a global one carries `lastIndex` between
45
+ // calls, so sharing the constant would make every second file start
46
+ // matching from wherever the previous one stopped.
47
+ const pattern = new RegExp(TODO_MATCH.source, TODO_MATCH.flags);
48
+ let match;
49
+ while ((match = pattern.exec(content)) !== null) {
20
50
  tasks.push({
21
- todo: task,
22
- context: encodeURI(taskContext),
51
+ todo: match[1],
52
+ context: encodeURI(match[2]),
23
53
  file: configFile.path,
24
- line: this.lineNumber(task, content),
54
+ // From the match position, not from a text search. Two identical
55
+ // TODOs in one file both reported the first one's line.
56
+ line: this.lineNumberByIndex(match.index, content),
25
57
  });
26
- return taskString;
27
- });
58
+ // A zero-length match would otherwise spin here forever. The context
59
+ // is a lookahead, so `lastIndex` sits at the end of the TODO's own
60
+ // line — which is what leaves the lines beneath it open to match.
61
+ if (match.index === pattern.lastIndex) {
62
+ pattern.lastIndex += 1;
63
+ }
64
+ }
28
65
  }
29
66
  return tasks;
30
67
  }
@@ -5,6 +5,7 @@ import { Cache } from "../request-cache/cache.js";
5
5
  import { CliServiceInterface } from "../../cli/index.js";
6
6
  import { OriginFetcher } from "../../origin-request/index.js";
7
7
  import { CustomerConfig } from "../../integration-api/index.js";
8
+ import { LocalCacheErrorEntry } from "../control/control-protocol.js";
8
9
  import { DevtoolsExtensionApi } from "../browser/extension/devtools-extension-api.js";
9
10
  export declare class VirtualOrestesApp {
10
11
  private customerConfig;
@@ -18,6 +19,26 @@ export declare class VirtualOrestesApp {
18
19
  private prerendererHintShown;
19
20
  constructor(customerConfig: CustomerConfig, originFetcher: OriginFetcher, documentHandler: DocumentHandlerServer, cache: Cache, cli: CliServiceInterface, developmentToolsMessages: DevtoolsExtensionApi, removeContentSecurityPolicy?: boolean);
20
21
  fetchAssetResponse(event: Protocol.Fetch.RequestPausedEvent): Promise<Partial<Protocol.Fetch.FulfillRequestRequest> | AbortResponse>;
22
+ /** The variations the runtime config names: see {@link OriginFetcher.namedVariations}. */
23
+ namedVariations(): string[];
24
+ /**
25
+ * Build and cache one variation of a url without the browser asking for it.
26
+ *
27
+ * The same path a real asset request takes — {@link buildResponse} fetches
28
+ * the origin with the variation's headers, runs the documentHandler over it
29
+ * and caches the result — with the request synthesised rather than
30
+ * intercepted. That is what makes a variation reachable at all: a browser is
31
+ * one device at a time, so mobile and desktop can never both be in the cache
32
+ * from browsing, and the comparison everyone wants to make is between exactly
33
+ * those two.
34
+ *
35
+ * Throws what the build threw. The caller is asking for one specific entry,
36
+ * so a failure is the answer to its question, not a background detail —
37
+ * unlike {@link refreshEntry}, which is fire-and-forget and logs instead.
38
+ *
39
+ * @returns the cache key the entry was stored under.
40
+ */
41
+ prewarm(originUrl: string, variation: string): Promise<string>;
21
42
  /**
22
43
  * Re-warm all cached entries for the given origin url in the background.
23
44
  *
@@ -49,6 +70,19 @@ export declare class VirtualOrestesApp {
49
70
  private refreshEntry;
50
71
  private buildResponse;
51
72
  private getResponseText;
73
+ /**
74
+ * The urls the local documentHandler could not build, as they stand now.
75
+ *
76
+ * Already collected for the devtools panel; this is the same list for a
77
+ * reader without one. State rather than history: an entry disappears once the
78
+ * same url and variation builds successfully, so an empty list means nothing
79
+ * is currently failing, not that nothing ever did.
80
+ *
81
+ * `occurredAt` is converted to ISO on the way out — the panel wants epoch
82
+ * milliseconds to sort by, a reader wants a timestamp it can compare against
83
+ * a log line.
84
+ */
85
+ getLocalCacheErrors(): LocalCacheErrorEntry[];
52
86
  private localCacheErrorKey;
53
87
  private recordLocalCacheError;
54
88
  private clearLocalCacheError;
@@ -1,10 +1,10 @@
1
+ import { assetOriginUrl, assetRequestUrl } from "../request-cache/asset-key.js";
1
2
  import { BaqendResponse } from "../browser/baqend-response.js";
2
3
  import { ABORT_SERVER_TIMING, ABORT_STATUS_CODE, isDocumentHandlerAbort, isLocalPrerendererUnreachable, LOCAL_PRERENDERER_PORT, prerenderFailure, } from "../../document-handler-runtime/document-handler-abort.js";
3
4
  import { isBlockedOriginStatus, ORIGIN_ERROR_STATUS_CODE, originErrorCauseName, originErrorCode, originErrorServerTiming, } from "../../origin-request/index.js";
4
5
  import { safe } from "../../../helpers/safe.js";
5
- import { META_CONTENT_TYPE_REGEX, } from "../onboarding-model.js";
6
6
  import iconv from "iconv-lite";
7
- import { UnsupportedEncodingError } from "../error/unsupported-encoding-error.js";
7
+ import { decodeHtml } from "../html-charset.js";
8
8
  import { removeContentSecurityMetaTag, rewriteInstallResource, } from "../html-rewrites.js";
9
9
  // for none encodable chars use a space, so the broken char is invisible.
10
10
  // We are using the same trick in our node.js server
@@ -52,6 +52,32 @@ export class VirtualOrestesApp {
52
52
  }
53
53
  return this.buildResponse(event.request.url);
54
54
  }
55
+ /** The variations the runtime config names: see {@link OriginFetcher.namedVariations}. */
56
+ namedVariations() {
57
+ return this.originFetcher.namedVariations();
58
+ }
59
+ /**
60
+ * Build and cache one variation of a url without the browser asking for it.
61
+ *
62
+ * The same path a real asset request takes — {@link buildResponse} fetches
63
+ * the origin with the variation's headers, runs the documentHandler over it
64
+ * and caches the result — with the request synthesised rather than
65
+ * intercepted. That is what makes a variation reachable at all: a browser is
66
+ * one device at a time, so mobile and desktop can never both be in the cache
67
+ * from browsing, and the comparison everyone wants to make is between exactly
68
+ * those two.
69
+ *
70
+ * Throws what the build threw. The caller is asking for one specific entry,
71
+ * so a failure is the answer to its question, not a background detail —
72
+ * unlike {@link refreshEntry}, which is fire-and-forget and logs instead.
73
+ *
74
+ * @returns the cache key the entry was stored under.
75
+ */
76
+ async prewarm(originUrl, variation) {
77
+ const requestUrl = assetRequestUrl(this.customerConfig.appDomain, originUrl, variation);
78
+ await this.buildResponse(requestUrl);
79
+ return requestUrl;
80
+ }
55
81
  /**
56
82
  * Re-warm all cached entries for the given origin url in the background.
57
83
  *
@@ -67,10 +93,13 @@ export class VirtualOrestesApp {
67
93
  .map(([key]) => key)
68
94
  .filter((key) => key.includes(originUrl));
69
95
  if (matchingKeys.length === 0) {
70
- this.cli.write(`changeDetection for url: ${originUrl} - nothing cached to refresh`);
96
+ this.cli.write(`changeDetection for url: ${originUrl} - nothing cached to refresh`, false, { scope: "cache", data: { url: originUrl, refreshed: 0 } });
71
97
  return;
72
98
  }
73
- this.cli.write(`changeDetection triggered for url: ${originUrl} - refreshing dh-cache in background`);
99
+ this.cli.write(`changeDetection triggered for url: ${originUrl} - refreshing dh-cache in background`, false, {
100
+ scope: "cache",
101
+ data: { url: originUrl, refreshed: matchingKeys.length },
102
+ });
74
103
  for (const key of matchingKeys) {
75
104
  await this.refreshEntry(key);
76
105
  }
@@ -92,7 +121,10 @@ export class VirtualOrestesApp {
92
121
  if (matchingKeys.length === 0) {
93
122
  return;
94
123
  }
95
- this.cli.write(`refreshing ${matchingKeys.length} dh-cache entries for current url ${currentUrl} in background`);
124
+ this.cli.write(`refreshing ${matchingKeys.length} dh-cache entries for current url ${currentUrl} in background`, false, {
125
+ scope: "cache",
126
+ data: { url: currentUrl, refreshed: matchingKeys.length },
127
+ });
96
128
  for (const key of matchingKeys) {
97
129
  await this.refreshEntry(key);
98
130
  }
@@ -108,7 +140,7 @@ export class VirtualOrestesApp {
108
140
  const result = await safe(this.buildResponse(requestUrl));
109
141
  if (result.success === false) {
110
142
  this.cache.removeEntry(requestUrl);
111
- this.cli.writeError(`failed to refresh dh-cache entry ${requestUrl}: ${result.error}`);
143
+ this.cli.writeError(`failed to refresh dh-cache entry ${requestUrl}: ${result.error}`, false, { scope: "cache", data: { url: requestUrl, error: result.error } });
112
144
  }
113
145
  }
114
146
  async buildResponse(requestUrl) {
@@ -146,7 +178,7 @@ export class VirtualOrestesApp {
146
178
  if (!this.isHtmlContentHeader(response?.headers) ||
147
179
  !this.isValidHtmlContent(responseContent)) {
148
180
  const customResponse = new BaqendResponse(responseContent, `text/html; charset=${textEncoding}`, customHeaders);
149
- this.cache.addEntry(requestUrl, customResponse);
181
+ this.cache.addEntry(requestUrl, customResponse, responseContent);
150
182
  return customResponse;
151
183
  }
152
184
  const customResponse = await safe(this.documentHandler.transform(`text/html;charset=${textEncoding}`, responseContent, variation, originUrl, this.convertResponseHeadersToOrestesFormat(response)));
@@ -184,37 +216,35 @@ export class VirtualOrestesApp {
184
216
  name: "x-sk-detected-encoding",
185
217
  value: textEncoding,
186
218
  });
187
- const baqendResponse = new BaqendResponse(Buffer.isBuffer(skResponse.body)
219
+ // Decoded, and cached decoded: only Chrome needs the base64.
220
+ const decodedBody = Buffer.isBuffer(skResponse.body)
188
221
  ? skResponse.body
189
- : iconv.encode(skResponse.body, textEncoding), skResponse.headers["content-type"] ?? `text/html;charset=${textEncoding}`, [...customHeaders, ...originHeaders]);
190
- this.cache.addEntry(requestUrl, baqendResponse);
222
+ : iconv.encode(skResponse.body, textEncoding);
223
+ const baqendResponse = new BaqendResponse(decodedBody, skResponse.headers["content-type"] ?? `text/html;charset=${textEncoding}`, [...customHeaders, ...originHeaders]);
224
+ this.cache.addEntry(requestUrl, baqendResponse, decodedBody);
191
225
  return baqendResponse;
192
226
  }
193
227
  async getResponseText(response) {
194
- const buffer = Buffer.from(await response.arrayBuffer());
195
- const contentType = response?.headers.get("content-type") || "";
196
- const charsetRegex = /charset=([^\s"(),./:;<=>?@[\]]*)/i;
197
- const encodingFromHeader = (contentType && charsetRegex.test(contentType)
198
- ? charsetRegex.exec(contentType)[1]
199
- : null) ?? "utf-8";
200
- if (!iconv.encodingExists(encodingFromHeader)) {
201
- throw new UnsupportedEncodingError(`encoding is not supported by cli: "${encodingFromHeader}"`);
202
- }
203
- let encodedBody = iconv.decode(buffer, encodingFromHeader);
204
- const metaSelector = META_CONTENT_TYPE_REGEX;
205
- const encodingFromBodyMeta = metaSelector.test(encodedBody)
206
- ? metaSelector.exec(encodedBody)[1]
207
- : null;
208
- if (encodingFromBodyMeta && encodingFromBodyMeta !== encodingFromHeader) {
209
- if (!iconv.encodingExists(encodingFromBodyMeta)) {
210
- throw new UnsupportedEncodingError(`encoding is not supported by cli: "${encodingFromBodyMeta}"`);
211
- }
212
- encodedBody = iconv.decode(buffer, encodingFromBodyMeta);
213
- }
214
- return {
215
- responseContent: encodedBody,
216
- textEncoding: encodingFromBodyMeta ?? encodingFromHeader,
217
- };
228
+ const { text, charset } = decodeHtml(response?.headers.get("content-type") || "", Buffer.from(await response.arrayBuffer()));
229
+ return { responseContent: text, textEncoding: charset };
230
+ }
231
+ /**
232
+ * The urls the local documentHandler could not build, as they stand now.
233
+ *
234
+ * Already collected for the devtools panel; this is the same list for a
235
+ * reader without one. State rather than history: an entry disappears once the
236
+ * same url and variation builds successfully, so an empty list means nothing
237
+ * is currently failing, not that nothing ever did.
238
+ *
239
+ * `occurredAt` is converted to ISO on the way out — the panel wants epoch
240
+ * milliseconds to sort by, a reader wants a timestamp it can compare against
241
+ * a log line.
242
+ */
243
+ getLocalCacheErrors() {
244
+ return [...this.localCacheErrors.values()].map((error) => ({
245
+ ...error,
246
+ occurredAt: new Date(error.occurredAt).toISOString(),
247
+ }));
218
248
  }
219
249
  localCacheErrorKey(url, variation) {
220
250
  return `${url}|${variation}`;
@@ -261,13 +291,17 @@ export class VirtualOrestesApp {
261
291
  this.warnPrerendererUnreachable();
262
292
  return;
263
293
  }
294
+ const meta = {
295
+ scope: "documentHandler",
296
+ data: { aborted: true, status: ABORT_STATUS_CODE, error: message },
297
+ };
264
298
  const failure = prerenderFailure(error);
265
299
  if (failure) {
266
300
  this.cli.writeError(`[DocumentHandler:local]: SSR failed for ${failure.url} (${failure.variation}): ` +
267
- `${failure.detailMessage ?? "no error message"}`);
301
+ `${failure.detailMessage ?? "no error message"}`, false, meta);
268
302
  return;
269
303
  }
270
- this.cli.writeWarning(`[DocumentHandler:local]: ${message}`);
304
+ this.cli.writeWarning(`[DocumentHandler:local]: ${message}`, false, meta);
271
305
  }
272
306
  warnPrerendererUnreachable() {
273
307
  const unreachable = `no pre-renderer is listening on localhost:${LOCAL_PRERENDERER_PORT}`;
@@ -314,9 +348,18 @@ export class VirtualOrestesApp {
314
348
  return this.returnAbortResponse(customResponse, customHeaders);
315
349
  }
316
350
  const message = `Could not transform html: - ${customResponse.error}`;
317
- this.cli.writeError(`[VirtualOrestes]: ${message}`);
318
- this.cli.comment(customResponse.errorObj.stack);
319
- this.cli.writeWarning("Suggestion: check files: config_documentHandler.es6 | custom_documentHandler.js");
351
+ this.cli.writeError(`[VirtualOrestes]: ${message}`, false, {
352
+ scope: "documentHandler",
353
+ data: {
354
+ error: customResponse.error,
355
+ stack: customResponse.errorObj.stack,
356
+ },
357
+ });
358
+ this.cli.comment(customResponse.errorObj.stack, false, {
359
+ scope: "documentHandler",
360
+ level: "debug",
361
+ });
362
+ this.cli.writeWarning("Suggestion: check files: config_documentHandler.es6 | custom_documentHandler.js", false, { scope: "documentHandler" });
320
363
  customHeaders.push({ name: "x-error", value: message });
321
364
  return new BaqendResponse(message, null, customHeaders, 500);
322
365
  }
@@ -333,7 +376,7 @@ export class VirtualOrestesApp {
333
376
  value: response?.headers.get("location") || "",
334
377
  });
335
378
  const redirectResponse = new BaqendResponse("", null, customHeaders, response.status);
336
- this.cache.addEntry(requestUrl, redirectResponse);
379
+ this.cache.addEntry(requestUrl, redirectResponse, "");
337
380
  return redirectResponse;
338
381
  }
339
382
  handleCdnRedirect(customHeaders, response, requestUrl) {
@@ -351,22 +394,11 @@ export class VirtualOrestesApp {
351
394
  // the CDN redirect surfaced as a bare ClientError (`AssetAPIHandler.ts:200-205`).
352
395
  serverTimingHeader.value += ",errorcode;desc=202";
353
396
  const redirectResponse = new BaqendResponse("", null, customHeaders, 400);
354
- this.cache.addEntry(requestUrl, redirectResponse);
397
+ this.cache.addEntry(requestUrl, redirectResponse, "");
355
398
  return redirectResponse;
356
399
  }
357
400
  getAssetUrl(requestUrl) {
358
- const url = new URL(requestUrl);
359
- const parametersToDelete = [];
360
- for (const [name] of url.searchParams.entries()) {
361
- if (name.startsWith("bq")) {
362
- parametersToDelete.push(name);
363
- }
364
- }
365
- for (const parameter of parametersToDelete) {
366
- url.searchParams.delete(parameter);
367
- }
368
- const cleanedUrl = url.toString();
369
- return cleanedUrl.split("app.baqend.com/v1/asset/")[1];
401
+ return assetOriginUrl(requestUrl);
370
402
  }
371
403
  getCachedResponse(requestUrl) {
372
404
  const response = this.cache.getEntry(requestUrl);
@@ -19,6 +19,13 @@ export interface AssetVariation {
19
19
  regex?: string | null;
20
20
  /** Which config key produced this entry. Set during resolution, for reporting. */
21
21
  matchedKey?: string;
22
+ /**
23
+ * Set during resolution, for reporting: the entry came from a regex key that
24
+ * matched the requested variation, not from a key of that name. Carried on
25
+ * the entry because only the resolution knows it — reading it back off the
26
+ * finished chain cannot tell a named key from a matched template.
27
+ */
28
+ viaTemplate?: boolean;
22
29
  }
23
30
  export type AssetVariationMap = Record<string, AssetVariation>;
24
31
  /** An entry of the runtime config's `speedKit.originMap`, keyed by origin or by host. */
@@ -48,6 +55,13 @@ export declare const DEFAULT_TYPE = "default";
48
55
  export declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15 (compatible; SpeedKit/1.0)";
49
56
  export declare const MOBILE_USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_6_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Mobile/15E148 Safari/604.1 (compatible; SpeedKit/1.0)";
50
57
  export declare const TABLET_USER_AGENT = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 (compatible; SpeedKit/1.0)";
58
+ /**
59
+ * The variation types the server resolves whether a config defines them or not.
60
+ *
61
+ * Exported because "which variations exist" is otherwise answered with the config's own keys alone,
62
+ * and a config that defines none reads as "nothing can be passed" while these three still work.
63
+ */
64
+ export declare const DEVICE_DEFAULT_TYPES: string[];
51
65
  /** Thrown where the server would throw UndefinedVariationException. */
52
66
  export declare class UndefinedVariationError extends Error {
53
67
  constructor(variationType: string);
@@ -22,6 +22,13 @@ const DEVICE_DEFAULTS = {
22
22
  mobile: { headers: { "user-agent": MOBILE_USER_AGENT } },
23
23
  tablet: { headers: { "user-agent": TABLET_USER_AGENT } },
24
24
  };
25
+ /**
26
+ * The variation types the server resolves whether a config defines them or not.
27
+ *
28
+ * Exported because "which variations exist" is otherwise answered with the config's own keys alone,
29
+ * and a config that defines none reads as "nothing can be passed" while these three still work.
30
+ */
31
+ export const DEVICE_DEFAULT_TYPES = Object.keys(DEVICE_DEFAULTS);
25
32
  /** Group names a template captures, e.g. `storeId` from `(?<storeId>.*)`. */
26
33
  const CAPTURING_TEMPLATES = /<(\w+)>/g;
27
34
  /** Thrown where the server would throw UndefinedVariationException. */
@@ -64,6 +71,7 @@ function applyTemplate(entry, variationType) {
64
71
  };
65
72
  return {
66
73
  matchedKey: entry.matchedKey,
74
+ viaTemplate: true,
67
75
  urlPrefix: entry.urlPrefix ? substitute(entry.urlPrefix) : entry.urlPrefix,
68
76
  encodePrefixedUrl: entry.encodePrefixedUrl,
69
77
  queryParams: (entry.queryParams ?? []).map(substitute),
@@ -180,16 +188,15 @@ export function resolveRequest(custom, url, variationType, { hostOverride, origi
180
188
  const originalHost = originEntry?.origin && originEntry.overrideHostHeader
181
189
  ? parsed.hostname
182
190
  : undefined;
183
- const isTemplate = chain.some((config) => config.matchedKey !== WILD_CARD &&
184
- !DEVICE_DEFAULTS[config.matchedKey ?? ""]) &&
185
- !chain.some((config) => config.matchedKey?.startsWith("device-default:"));
186
191
  const headers = buildHeaders(chain, hostOverride, originEntry, originalHost);
187
192
  const originMapHeaders = Object.entries(originEntry?.headers ?? {})
188
193
  .filter(([key, value]) => headers[key.toLowerCase()] === String(value))
189
194
  .map(([key]) => key.toLowerCase());
190
195
  return {
191
196
  appliedKeys: chain.map((config) => config.matchedKey ?? "?"),
192
- resolutionPath: isTemplate ? "template" : "named",
197
+ resolutionPath: chain.some((config) => config.viaTemplate)
198
+ ? "template"
199
+ : "named",
193
200
  ...(originMapKey ? { originMapKey, originMapHeaders } : {}),
194
201
  url: buildUrl(requestUrl, chain),
195
202
  headers,
@@ -35,6 +35,13 @@ export declare class OriginFetcher {
35
35
  /** Warnings already shown, so a per-fetch condition is reported once per session. */
36
36
  private readonly warned;
37
37
  constructor(deps: OriginFetcherDeps);
38
+ /**
39
+ * The variations the runtime config names. The wildcard and the regex
40
+ * templates are not variations of their own, and the device defaults are
41
+ * left out: whether a config ever produces `tablet` is decided in the
42
+ * browser, by `detectDevice` or the user agent, and nothing here can tell.
43
+ */
44
+ namedVariations(): string[];
38
45
  /** The request, without sending it. */
39
46
  prepare(originUrl: string, variation?: string): PreparedOriginRequest;
40
47
  /**
@@ -18,6 +18,18 @@ export class OriginFetcher {
18
18
  constructor(deps) {
19
19
  this.deps = deps;
20
20
  }
21
+ /**
22
+ * The variations the runtime config names. The wildcard and the regex
23
+ * templates are not variations of their own, and the device defaults are
24
+ * left out: whether a config ever produces `tablet` is decided in the
25
+ * browser, by `detectDevice` or the user agent, and nothing here can tell.
26
+ */
27
+ namedVariations() {
28
+ const variations = this.deps.config?.variations ?? {};
29
+ return Object.entries(variations)
30
+ .filter(([key, entry]) => key !== "*" && !key.startsWith("device-default:") && !entry?.regex)
31
+ .map(([key]) => key);
32
+ }
21
33
  /** The request, without sending it. */
22
34
  prepare(originUrl, variation) {
23
35
  // A missing runtime config is not reported here; the load that failed says what it costs.
@@ -42,15 +54,38 @@ export class OriginFetcher {
42
54
  async fetch(originUrl, variation) {
43
55
  const { url, init } = this.prepare(originUrl, variation);
44
56
  const action = `ORIGIN:FETCH:${randomUUID()}`;
45
- this.deps.cli.startAction(action, `[documentHandler:fetch]: ${url}`);
57
+ this.deps.cli.startAction(action, `[documentHandler:fetch]: ${url}`, {
58
+ scope: "documentHandler",
59
+ data: { url, originUrl, variation },
60
+ });
61
+ const startedAt = Date.now();
46
62
  try {
47
63
  const response = await originFetch(url, init);
48
- this.deps.cli.successAction(action);
64
+ this.deps.cli.successAction(action, undefined, {
65
+ scope: "documentHandler",
66
+ data: {
67
+ url,
68
+ variation,
69
+ status: response.status,
70
+ durationMs: Date.now() - startedAt,
71
+ },
72
+ });
49
73
  return { response, url };
50
74
  }
51
75
  catch (error) {
52
- this.deps.cli.failAction(action, `error while fetching Asset: ${originUrl}`);
53
- this.deps.cli.writeError(String(error));
76
+ this.deps.cli.failAction(action, `error while fetching Asset: ${originUrl}`, {
77
+ scope: "documentHandler",
78
+ data: {
79
+ url,
80
+ originUrl,
81
+ variation,
82
+ durationMs: Date.now() - startedAt,
83
+ error: String(error),
84
+ },
85
+ });
86
+ this.deps.cli.writeError(String(error), false, {
87
+ scope: "documentHandler",
88
+ });
54
89
  return undefined;
55
90
  }
56
91
  }
@@ -94,6 +129,9 @@ export class OriginFetcher {
94
129
  if (this.warned.has(key))
95
130
  return;
96
131
  this.warned.add(key);
97
- this.deps.cli.writeWarning(message);
132
+ this.deps.cli.writeWarning(message, false, {
133
+ scope: "documentHandler",
134
+ data: { once: key },
135
+ });
98
136
  }
99
137
  }
@@ -11,6 +11,8 @@ declare const flags: {
11
11
  host: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
12
12
  body: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
13
13
  grep: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
14
+ select: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
15
+ maxMatches: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
14
16
  json: Interfaces.BooleanFlag<boolean>;
15
17
  variations: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
16
18
  raw: Interfaces.BooleanFlag<boolean>;
@@ -26,8 +28,21 @@ export interface OriginRequestOptions {
26
28
  readonly host?: string;
27
29
  readonly bodyFile?: string;
28
30
  readonly grep?: string;
31
+ readonly select?: string;
32
+ readonly maxMatches?: number;
29
33
  readonly json?: boolean;
30
34
  readonly variationsFile?: string;
35
+ /**
36
+ * The origin a relative {@link pageUrl} is resolved against, when the
37
+ * caller knows one the config cannot supply.
38
+ *
39
+ * A customer with several origins and no `domain` has no base in its
40
+ * config, and picking `origins[0]` would answer about the wrong site. But
41
+ * a run *is* on one of them — the one `-d` or the startup prompt chose —
42
+ * and that is the origin whoever is asking means. Passed in rather than
43
+ * looked up, because this service has no idea a run exists.
44
+ */
45
+ readonly base?: string;
31
46
  }
32
47
  export interface OriginRequestServiceBuildContextValues extends CommandContextValues, OriginRequestOptions {
33
48
  }
@@ -45,6 +60,8 @@ export declare class OriginRequestServiceBuildContext extends OriginRequestServi
45
60
  host: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
46
61
  body: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
47
62
  grep: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
63
+ select: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
64
+ maxMatches: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
48
65
  json: Interfaces.BooleanFlag<boolean>;
49
66
  variations: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
50
67
  raw: Interfaces.BooleanFlag<boolean>;
@@ -34,6 +34,12 @@ const flags = {
34
34
  grep: Flags.string({
35
35
  description: "Print body lines matching this regex, case-insensitive",
36
36
  }),
37
+ select: Flags.string({
38
+ description: "Count and sample what this CSS selector matches in the body, e.g. 'script[src*=\"analytics\"]'",
39
+ }),
40
+ maxMatches: Flags.integer({
41
+ description: "How many --select and --grep matches to show. Default 10",
42
+ }),
37
43
  json: Flags.boolean({
38
44
  description: "Machine-readable output",
39
45
  }),
@@ -72,6 +78,8 @@ export class OriginRequestServiceBuildContext extends Context() {
72
78
  host: parsedFlags.host,
73
79
  bodyFile: parsedFlags.body,
74
80
  grep: parsedFlags.grep,
81
+ select: parsedFlags.select,
82
+ maxMatches: parsedFlags.maxMatches,
75
83
  json: parsedFlags.json,
76
84
  variationsFile: parsedFlags.variations,
77
85
  });
@@ -6,11 +6,6 @@ export declare class OriginRequestServiceFactory {
6
6
  constructor(context: OriginRequestServiceBuildContext);
7
7
  buildService(): Promise<OriginRequestService>;
8
8
  private build;
9
- /**
10
- * The runtime config: a local file when one is named, else the app's. Without a customer there is
11
- * no app, and the request carries Speed Kit's device defaults only.
12
- */
13
- private loadRuntimeConfig;
14
9
  private getIntegrationFiles;
15
10
  private getConfigApi;
16
11
  }