@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
@@ -0,0 +1,104 @@
1
+ /**
2
+ * The shape of one line in a run's `log.jsonl`.
3
+ *
4
+ * This is an interface in the strict sense: `sk onboarding logs`
5
+ * and anything an agent writes against the file all read these fields, and a
6
+ * file outlives the build that wrote it. {@link LOG_SCHEMA_VERSION} is recorded
7
+ * in `meta.json` so a reader can tell which rules applied when the run was
8
+ * written, rather than inferring it from which fields happen to be present.
9
+ */
10
+ export declare const LOG_SCHEMA_VERSION = 1;
11
+ /**
12
+ * How much a line matters.
13
+ *
14
+ * Ordered, and filters are "this level and above", so the order below is part
15
+ * of the contract. `success` sits above `info` because a run's successes are
16
+ * its milestones — the thing someone scanning a finished run wants without the
17
+ * narration between them — and below `warn` because nothing is wrong.
18
+ */
19
+ export declare const LOG_LEVELS: readonly ["debug", "info", "success", "warn", "error"];
20
+ export type LogLevel = (typeof LOG_LEVELS)[number];
21
+ /** Rank for "this level and above". */
22
+ export declare function levelRank(level: LogLevel): number;
23
+ /**
24
+ * Which part of the run produced a line.
25
+ *
26
+ * Deliberately the vocabulary already pushed to the devtools extension in
27
+ * `DevelopmentToolsMessage` (`onboarding-model.ts`), widened with the parts of
28
+ * the run that message never covered. Two names for one thing is how a reader
29
+ * ends up filtering on `sw` and missing half the service-worker story, so new
30
+ * scopes belong here rather than in a caller's string literal.
31
+ */
32
+ export declare const LOG_SCOPES: readonly ["cli", "browser", "sw", "fetch", "documentHandler", "config", "cache", "extension", "athena", "todo", "appToken", "process", "console"];
33
+ export type LogScope = (typeof LOG_SCOPES)[number];
34
+ /** An action's place in its own lifecycle, mirroring `CliService`'s spinners. */
35
+ export type LogActionState = "start" | "success" | "fail" | "end";
36
+ /** A question put to the human, and what came back. */
37
+ export interface LogInteraction {
38
+ kind: "confirm" | "prompt" | "select" | "multiSelect";
39
+ question: string;
40
+ /**
41
+ * Absent while the question is still on screen.
42
+ *
43
+ * A prompt is logged twice — once when asked, once when answered — because
44
+ * an append-only file cannot go back and fill this in, and a run that died
45
+ * waiting at a prompt is exactly the run whose log has to show the question.
46
+ */
47
+ answer?: unknown;
48
+ /** True while the answer is still outstanding. */
49
+ pending?: boolean;
50
+ /** Answered by a default rather than by a person, e.g. under `--quiet`. */
51
+ defaulted?: boolean;
52
+ /** The answer was withheld from the log — see `redaction.ts`. */
53
+ sensitive?: boolean;
54
+ }
55
+ export interface LogEvent {
56
+ /** Monotonic within a run, from 1. The cursor for tailing. */
57
+ seq: number;
58
+ /** ISO 8601. */
59
+ ts: string;
60
+ level: LogLevel;
61
+ scope: LogScope;
62
+ /** ANSI-stripped, and redacted. Plain text, so `grep` means what it says. */
63
+ msg: string;
64
+ data?: Record<string, unknown>;
65
+ action?: {
66
+ name: string;
67
+ state: LogActionState;
68
+ };
69
+ interaction?: LogInteraction;
70
+ }
71
+ /**
72
+ * What a producer passes. `seq` and `ts` are the writer's to assign, and
73
+ * `scope` defaults, so the common call is `{ level, msg }`.
74
+ */
75
+ export interface LogEventInput {
76
+ level: LogLevel;
77
+ msg: string;
78
+ scope?: LogScope;
79
+ data?: Record<string, unknown>;
80
+ action?: {
81
+ name: string;
82
+ state: LogActionState;
83
+ };
84
+ interaction?: LogInteraction;
85
+ }
86
+ /**
87
+ * The annotation a `CliService` caller may add to a line it was printing
88
+ * anyway.
89
+ *
90
+ * This exists so structure arrives at the same call site as the prose, rather
91
+ * than through a second logging call beside it. Two calls drift: the message
92
+ * gets edited and the event does not, and the log quietly stops describing the
93
+ * terminal.
94
+ */
95
+ export interface LogMeta {
96
+ scope?: LogScope;
97
+ data?: Record<string, unknown>;
98
+ /**
99
+ * Overrides the level the method implies. `writeWarning` is a `warn`; a
100
+ * caller that knows a particular warning is routine can say `debug` and keep
101
+ * it out of a filtered read.
102
+ */
103
+ level?: LogLevel;
104
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The shape of one line in a run's `log.jsonl`.
3
+ *
4
+ * This is an interface in the strict sense: `sk onboarding logs`
5
+ * and anything an agent writes against the file all read these fields, and a
6
+ * file outlives the build that wrote it. {@link LOG_SCHEMA_VERSION} is recorded
7
+ * in `meta.json` so a reader can tell which rules applied when the run was
8
+ * written, rather than inferring it from which fields happen to be present.
9
+ */
10
+ export const LOG_SCHEMA_VERSION = 1;
11
+ /**
12
+ * How much a line matters.
13
+ *
14
+ * Ordered, and filters are "this level and above", so the order below is part
15
+ * of the contract. `success` sits above `info` because a run's successes are
16
+ * its milestones — the thing someone scanning a finished run wants without the
17
+ * narration between them — and below `warn` because nothing is wrong.
18
+ */
19
+ export const LOG_LEVELS = [
20
+ "debug",
21
+ "info",
22
+ "success",
23
+ "warn",
24
+ "error",
25
+ ];
26
+ /** Rank for "this level and above". */
27
+ export function levelRank(level) {
28
+ return LOG_LEVELS.indexOf(level);
29
+ }
30
+ /**
31
+ * Which part of the run produced a line.
32
+ *
33
+ * Deliberately the vocabulary already pushed to the devtools extension in
34
+ * `DevelopmentToolsMessage` (`onboarding-model.ts`), widened with the parts of
35
+ * the run that message never covered. Two names for one thing is how a reader
36
+ * ends up filtering on `sw` and missing half the service-worker story, so new
37
+ * scopes belong here rather than in a caller's string literal.
38
+ */
39
+ export const LOG_SCOPES = [
40
+ /** The CLI narrating itself. The default, and what an un-annotated line gets. */
41
+ "cli",
42
+ "browser",
43
+ "sw",
44
+ "fetch",
45
+ "documentHandler",
46
+ "config",
47
+ "cache",
48
+ "extension",
49
+ "athena",
50
+ "todo",
51
+ "appToken",
52
+ /** Something that escaped every other path — see `mirrorCrashes`. */
53
+ "process",
54
+ /** The page's console warnings and errors, and uncaught errors: in the log only. */
55
+ "console",
56
+ ];
@@ -0,0 +1,11 @@
1
+ import { RunRegistry } from "../run-registry/index.js";
2
+ import { LogQueryService } from "./log-query-service.js";
3
+ /**
4
+ * Builds the {@link LogQueryService} that `sk onboarding logs`
5
+ * share. All it needs is the registry the runs are recorded in.
6
+ */
7
+ export declare class LogQueryServiceFactory {
8
+ private readonly registry;
9
+ constructor(registry: RunRegistry);
10
+ getService(): LogQueryService;
11
+ }
@@ -0,0 +1,14 @@
1
+ import { LogQueryService } from "./log-query-service.js";
2
+ /**
3
+ * Builds the {@link LogQueryService} that `sk onboarding logs`
4
+ * share. All it needs is the registry the runs are recorded in.
5
+ */
6
+ export class LogQueryServiceFactory {
7
+ registry;
8
+ constructor(registry) {
9
+ this.registry = registry;
10
+ }
11
+ getService() {
12
+ return new LogQueryService(this.registry);
13
+ }
14
+ }
@@ -0,0 +1,59 @@
1
+ import { Run, RunRegistry } from "../run-registry/index.js";
2
+ import { BadLogFilterError, LogQuery, LogReadResult, LogReader } from "./log-reader.js";
3
+ import { LogSummary } from "./log-summary.js";
4
+ import { RequestQuery, RequestReadResult, RequestReader, RequestSummary } from "./request-summary.js";
5
+ /** The query as it arrives from a CLI flag or a tool argument: all strings. */
6
+ export interface LogQueryOptions {
7
+ /** Run id, customer name or path. Omit when exactly one run is live. */
8
+ run?: string;
9
+ since?: string;
10
+ until?: string;
11
+ level?: string;
12
+ /** Comma-separated, or a list. */
13
+ scope?: string | string[];
14
+ grep?: string;
15
+ url?: string;
16
+ tail?: number;
17
+ sinceSeq?: number;
18
+ }
19
+ export declare class UnknownLogValueError extends BadLogFilterError {
20
+ constructor(what: string, value: string, allowed: readonly string[]);
21
+ }
22
+ /**
23
+ * Reads a run's log, for whoever is asking.
24
+ *
25
+ * What `sk onboarding logs` runs: its flags are {@link LogQueryOptions}, and
26
+ * the command only renders what comes back.
27
+ *
28
+ * **Nothing here needs the run to be alive.** The log is a file, not a socket,
29
+ * so a crashed run from last week answers exactly as well as the one running
30
+ * now. That is the opposite of every other run-scoped tool in this CLI, and it
31
+ * is the reason this one is worth having: post-mortem is the common case.
32
+ */
33
+ export declare class LogQueryService {
34
+ private readonly registry;
35
+ constructor(registry: RunRegistry);
36
+ /** Resolve a selector to a run, with the same rules as every other tool. */
37
+ resolve(selector?: string): Run;
38
+ /** Whether this run wrote a log at all. */
39
+ hasLog(run: Run): boolean;
40
+ /** Whether this run recorded the requests it intercepted. */
41
+ hasRequests(run: Run): boolean;
42
+ read(run: Run, options?: LogQueryOptions): LogReadResult;
43
+ readRequests(run: Run, query?: RequestQuery): RequestReadResult;
44
+ /**
45
+ * The whole run at a glance.
46
+ *
47
+ * The two streams are summarised together because the question they answer
48
+ * together — "nothing went wrong, and 340 requests were handed straight to
49
+ * Chrome" — is one nobody would think to ask of either alone.
50
+ */
51
+ summarise(run: Run, options?: LogQueryOptions): LogSummary & {
52
+ requests?: RequestSummary;
53
+ };
54
+ /** A stateful reader, for `--follow` and for an agent holding a cursor. */
55
+ reader(run: Run): LogReader;
56
+ requestReader(run: Run): RequestReader;
57
+ }
58
+ /** Turn strings into a typed query, refusing what it cannot map. */
59
+ export declare function buildQuery(options: LogQueryOptions): LogQuery;
@@ -0,0 +1,111 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { LOG_LEVELS, LOG_SCOPES, } from "./log-event-model.js";
4
+ import { BadLogFilterError, LogReader, parseSince, readLog, } from "./log-reader.js";
5
+ import { summariseLog } from "./log-summary.js";
6
+ import { REQUESTS_FILE, REQUESTS_PREVIOUS_FILE } from "./request-log.js";
7
+ import { RequestReader, readRequests, summariseRequests, } from "./request-summary.js";
8
+ import { LOG_FILE, LOG_PREVIOUS_FILE } from "./run-log.js";
9
+ export class UnknownLogValueError extends BadLogFilterError {
10
+ constructor(what, value, allowed) {
11
+ super(`"${value}" is not a ${what}. Use one of: ${allowed.join(", ")}.`);
12
+ }
13
+ }
14
+ /**
15
+ * Reads a run's log, for whoever is asking.
16
+ *
17
+ * What `sk onboarding logs` runs: its flags are {@link LogQueryOptions}, and
18
+ * the command only renders what comes back.
19
+ *
20
+ * **Nothing here needs the run to be alive.** The log is a file, not a socket,
21
+ * so a crashed run from last week answers exactly as well as the one running
22
+ * now. That is the opposite of every other run-scoped tool in this CLI, and it
23
+ * is the reason this one is worth having: post-mortem is the common case.
24
+ */
25
+ export class LogQueryService {
26
+ registry;
27
+ constructor(registry) {
28
+ this.registry = registry;
29
+ }
30
+ /** Resolve a selector to a run, with the same rules as every other tool. */
31
+ resolve(selector) {
32
+ return this.registry.resolve(selector);
33
+ }
34
+ /** Whether this run wrote a log at all. */
35
+ hasLog(run) {
36
+ return (existsSync(join(run.dir, LOG_FILE)) ||
37
+ existsSync(join(run.dir, LOG_PREVIOUS_FILE)));
38
+ }
39
+ /** Whether this run recorded the requests it intercepted. */
40
+ hasRequests(run) {
41
+ return (existsSync(join(run.dir, REQUESTS_FILE)) ||
42
+ existsSync(join(run.dir, REQUESTS_PREVIOUS_FILE)));
43
+ }
44
+ read(run, options = {}) {
45
+ return readLog(run.dir, buildQuery(options));
46
+ }
47
+ readRequests(run, query = {}) {
48
+ return readRequests(run.dir, query);
49
+ }
50
+ /**
51
+ * The whole run at a glance.
52
+ *
53
+ * The two streams are summarised together because the question they answer
54
+ * together — "nothing went wrong, and 340 requests were handed straight to
55
+ * Chrome" — is one nobody would think to ask of either alone.
56
+ */
57
+ summarise(run, options = {}) {
58
+ const summary = summariseLog(readLog(run.dir, buildQuery(options)).events);
59
+ if (!this.hasRequests(run)) {
60
+ return summary;
61
+ }
62
+ return {
63
+ ...summary,
64
+ requests: summariseRequests(readRequests(run.dir).records),
65
+ };
66
+ }
67
+ /** A stateful reader, for `--follow` and for an agent holding a cursor. */
68
+ reader(run) {
69
+ return new LogReader(run.dir);
70
+ }
71
+ requestReader(run) {
72
+ return new RequestReader(run.dir);
73
+ }
74
+ }
75
+ /** Turn strings into a typed query, refusing what it cannot map. */
76
+ export function buildQuery(options) {
77
+ const query = {
78
+ sinceSeq: options.sinceSeq,
79
+ tail: options.tail,
80
+ url: options.url,
81
+ };
82
+ if (options.level) {
83
+ if (!LOG_LEVELS.includes(options.level)) {
84
+ throw new UnknownLogValueError("log level", options.level, LOG_LEVELS);
85
+ }
86
+ query.level = options.level;
87
+ }
88
+ if (options.scope) {
89
+ const names = (Array.isArray(options.scope) ? options.scope : options.scope.split(","))
90
+ .map((name) => name.trim())
91
+ .filter(Boolean);
92
+ for (const name of names) {
93
+ if (!LOG_SCOPES.includes(name)) {
94
+ throw new UnknownLogValueError("log scope", name, LOG_SCOPES);
95
+ }
96
+ }
97
+ query.scopes = names;
98
+ }
99
+ if (options.since) {
100
+ query.since = parseSince(options.since);
101
+ }
102
+ if (options.until) {
103
+ query.until = parseSince(options.until);
104
+ }
105
+ if (options.grep) {
106
+ // Case-insensitive, because nobody grepping a log for "timeout" means to
107
+ // exclude the line that happens to start a sentence with it.
108
+ query.grep = new RegExp(options.grep, "i");
109
+ }
110
+ return query;
111
+ }
@@ -0,0 +1,84 @@
1
+ import { LogEvent, LogLevel, LogScope } from "./log-event-model.js";
2
+ /**
3
+ * A filter that could not be read.
4
+ *
5
+ * Its own class because `sk onboarding logs` has to tell "you asked for
6
+ * something I cannot parse" apart from "that run does not exist", and the two call for completely different next moves.
7
+ */
8
+ export declare class BadLogFilterError extends Error {
9
+ }
10
+ /** What to select out of a run's log. Every field narrows; omitting one is "all". */
11
+ export interface LogQuery {
12
+ /** Everything *after* this sequence number. The cursor for tailing. */
13
+ sinceSeq?: number;
14
+ since?: Date;
15
+ until?: Date;
16
+ /** This level and above. */
17
+ level?: LogLevel;
18
+ scopes?: LogScope[];
19
+ grep?: RegExp;
20
+ /** Substring match against the message and any `data.url`. */
21
+ url?: string;
22
+ /** Keep only the last n matches. Applied after every other filter. */
23
+ tail?: number;
24
+ }
25
+ export interface LogReadResult {
26
+ events: LogEvent[];
27
+ /** Matches before `tail` cut them, so a tailed answer never reads as complete. */
28
+ total: number;
29
+ truncated: boolean;
30
+ /** The highest `seq` in the file, matched or not — the cursor to pass back. */
31
+ lastSeq: number;
32
+ /**
33
+ * Lines that were not JSON.
34
+ *
35
+ * Expected to be 0 or 1: the only way to get one is to read the file in the
36
+ * instant between two halves of an append, and the reader carries that
37
+ * remainder forward rather than counting it. Anything higher means something
38
+ * other than `RunLog` has written to the file.
39
+ */
40
+ malformed: number;
41
+ }
42
+ /**
43
+ * Reads one of a run's JSON-lines streams, incrementally where it can.
44
+ *
45
+ * Holds a byte offset per file so `--follow` and a polling agent re-read only
46
+ * what was appended, rather than parsing the whole run every second. An
47
+ * instance is stateful for that reason; a one-shot read wants {@link readLog}.
48
+ *
49
+ * Rotation is handled by noticing the file got shorter, which is the only
50
+ * evidence available after the fact — the writer renames the file out from
51
+ * under an open reader, and an offset into the new one would otherwise point
52
+ * into the middle of a line.
53
+ */
54
+ export declare class JsonlReader<T> {
55
+ private readonly dir;
56
+ private readonly names;
57
+ private readonly offsets;
58
+ private readonly remainders;
59
+ /** @param names the files of this stream, oldest generation first. */
60
+ constructor(dir: string, names: string[]);
61
+ /** Every file that exists right now, oldest first. */
62
+ private files;
63
+ /**
64
+ * Records appended since the last call — or, on the first call, all of them.
65
+ */
66
+ read(): {
67
+ records: T[];
68
+ malformed: number;
69
+ };
70
+ }
71
+ /** The narration stream of a run. */
72
+ export declare class LogReader extends JsonlReader<LogEvent> {
73
+ constructor(dir: string);
74
+ }
75
+ /** Read a run's whole log and apply a query. The one-shot path. */
76
+ export declare function readLog(dir: string, query?: LogQuery): LogReadResult;
77
+ export declare function filterEvents(events: LogEvent[], query: LogQuery): LogEvent[];
78
+ /**
79
+ * `--since 5m`, `--since 2026-09-18T08:00:00Z`, or a number of milliseconds.
80
+ *
81
+ * Relative first, because that is what anyone actually types at a terminal, and
82
+ * an ISO timestamp is unambiguous enough to recognise afterwards.
83
+ */
84
+ export declare function parseSince(input: string, now?: Date): Date;
@@ -0,0 +1,180 @@
1
+ import { existsSync, openSync, readSync, closeSync, statSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { levelRank } from "./log-event-model.js";
4
+ import { LOG_FILE, LOG_PREVIOUS_FILE } from "./run-log.js";
5
+ /**
6
+ * A filter that could not be read.
7
+ *
8
+ * Its own class because `sk onboarding logs` has to tell "you asked for
9
+ * something I cannot parse" apart from "that run does not exist", and the two call for completely different next moves.
10
+ */
11
+ export class BadLogFilterError extends Error {
12
+ }
13
+ /**
14
+ * Reads one of a run's JSON-lines streams, incrementally where it can.
15
+ *
16
+ * Holds a byte offset per file so `--follow` and a polling agent re-read only
17
+ * what was appended, rather than parsing the whole run every second. An
18
+ * instance is stateful for that reason; a one-shot read wants {@link readLog}.
19
+ *
20
+ * Rotation is handled by noticing the file got shorter, which is the only
21
+ * evidence available after the fact — the writer renames the file out from
22
+ * under an open reader, and an offset into the new one would otherwise point
23
+ * into the middle of a line.
24
+ */
25
+ export class JsonlReader {
26
+ dir;
27
+ names;
28
+ offsets = new Map();
29
+ remainders = new Map();
30
+ /** @param names the files of this stream, oldest generation first. */
31
+ constructor(dir, names) {
32
+ this.dir = dir;
33
+ this.names = names;
34
+ }
35
+ /** Every file that exists right now, oldest first. */
36
+ files() {
37
+ return this.names
38
+ .map((name) => join(this.dir, name))
39
+ .filter((file) => existsSync(file));
40
+ }
41
+ /**
42
+ * Records appended since the last call — or, on the first call, all of them.
43
+ */
44
+ read() {
45
+ const records = [];
46
+ let malformed = 0;
47
+ for (const file of this.files()) {
48
+ const size = statSync(file).size;
49
+ let offset = this.offsets.get(file) ?? 0;
50
+ // Shorter than where we left off: the file was rotated or truncated, so
51
+ // the offset means nothing any more and the honest move is to start over.
52
+ if (size < offset) {
53
+ offset = 0;
54
+ this.remainders.delete(file);
55
+ }
56
+ if (size === offset) {
57
+ continue;
58
+ }
59
+ const text = (this.remainders.get(file) ?? "") + readRange(file, offset, size);
60
+ this.offsets.set(file, size);
61
+ const lines = text.split("\n");
62
+ // A trailing fragment is a half-written append, not a broken line. It is
63
+ // carried over and completed by the next read.
64
+ this.remainders.set(file, lines.pop() ?? "");
65
+ for (const line of lines) {
66
+ if (!line.trim()) {
67
+ continue;
68
+ }
69
+ try {
70
+ records.push(JSON.parse(line));
71
+ }
72
+ catch {
73
+ malformed += 1;
74
+ }
75
+ }
76
+ }
77
+ return { records, malformed };
78
+ }
79
+ }
80
+ /** The narration stream of a run. */
81
+ export class LogReader extends JsonlReader {
82
+ constructor(dir) {
83
+ super(dir, [LOG_PREVIOUS_FILE, LOG_FILE]);
84
+ }
85
+ }
86
+ /** The bytes between two offsets, as text. */
87
+ function readRange(file, from, to) {
88
+ const fd = openSync(file, "r");
89
+ try {
90
+ const buffer = Buffer.alloc(to - from);
91
+ readSync(fd, buffer, 0, buffer.length, from);
92
+ return buffer.toString("utf8");
93
+ }
94
+ finally {
95
+ closeSync(fd);
96
+ }
97
+ }
98
+ /** Read a run's whole log and apply a query. The one-shot path. */
99
+ export function readLog(dir, query = {}) {
100
+ const reader = new LogReader(dir);
101
+ const { records: events, malformed } = reader.read();
102
+ const lastSeq = events.length > 0 ? events[events.length - 1].seq : 0;
103
+ const matched = filterEvents(events, query);
104
+ const tailed = query.tail !== undefined && matched.length > query.tail
105
+ ? matched.slice(-query.tail)
106
+ : matched;
107
+ return {
108
+ events: tailed,
109
+ total: matched.length,
110
+ truncated: tailed.length < matched.length,
111
+ lastSeq,
112
+ malformed,
113
+ };
114
+ }
115
+ export function filterEvents(events, query) {
116
+ const minimum = query.level === undefined ? -1 : levelRank(query.level);
117
+ const scopes = query.scopes && new Set(query.scopes);
118
+ const since = query.since?.getTime();
119
+ const until = query.until?.getTime();
120
+ return events.filter((event) => {
121
+ if (query.sinceSeq !== undefined && event.seq <= query.sinceSeq) {
122
+ return false;
123
+ }
124
+ if (levelRank(event.level) < minimum) {
125
+ return false;
126
+ }
127
+ if (scopes && !scopes.has(event.scope)) {
128
+ return false;
129
+ }
130
+ if (since !== undefined || until !== undefined) {
131
+ const at = Date.parse(event.ts);
132
+ if (since !== undefined && at < since) {
133
+ return false;
134
+ }
135
+ if (until !== undefined && at > until) {
136
+ return false;
137
+ }
138
+ }
139
+ if (query.grep && !query.grep.test(event.msg)) {
140
+ return false;
141
+ }
142
+ if (query.url !== undefined && !mentionsUrl(event, query.url)) {
143
+ return false;
144
+ }
145
+ return true;
146
+ });
147
+ }
148
+ /**
149
+ * Whether an event is about a url.
150
+ *
151
+ * Checks `data.url` as well as the message, because an enriched event carries
152
+ * the url as a field and may not repeat it in the prose — and a `--url` filter
153
+ * that only matched the prose would hide exactly the events worth having.
154
+ */
155
+ function mentionsUrl(event, needle) {
156
+ if (event.msg.includes(needle)) {
157
+ return true;
158
+ }
159
+ const url = event.data?.url;
160
+ return typeof url === "string" && url.includes(needle);
161
+ }
162
+ /**
163
+ * `--since 5m`, `--since 2026-09-18T08:00:00Z`, or a number of milliseconds.
164
+ *
165
+ * Relative first, because that is what anyone actually types at a terminal, and
166
+ * an ISO timestamp is unambiguous enough to recognise afterwards.
167
+ */
168
+ export function parseSince(input, now = new Date()) {
169
+ const relative = /^(\d+)(ms|s|m|h|d)$/.exec(input.trim());
170
+ if (relative) {
171
+ const [, amount, unit] = relative;
172
+ const factor = { ms: 1, s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000 };
173
+ return new Date(now.getTime() - Number(amount) * factor[unit]);
174
+ }
175
+ const at = new Date(input);
176
+ if (Number.isNaN(at.getTime())) {
177
+ throw new BadLogFilterError(`Cannot read "${input}" as a time. Use a relative span like 5m, 2h or 1d, or an ISO timestamp.`);
178
+ }
179
+ return at;
180
+ }