@speedkit/cli 4.51.1 → 4.52.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.
- package/CHANGELOG.md +14 -0
- package/README.md +1426 -14
- package/dist/base/run-control-command.d.ts +15 -0
- package/dist/base/run-control-command.js +20 -0
- package/dist/build-info.json +6 -0
- package/dist/commands/diff.d.ts +7 -1
- package/dist/commands/diff.js +9 -3
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.js +14 -3
- package/dist/commands/onboarding/browser/click.d.ts +75 -0
- package/dist/commands/onboarding/browser/click.js +19 -0
- package/dist/commands/onboarding/browser/emulate.d.ts +105 -0
- package/dist/commands/onboarding/browser/emulate.js +26 -0
- package/dist/commands/onboarding/browser/navigate.d.ts +75 -0
- package/dist/commands/onboarding/browser/navigate.js +19 -0
- package/dist/commands/onboarding/browser/panel.d.ts +63 -0
- package/dist/commands/onboarding/browser/panel.js +12 -0
- package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
- package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
- package/dist/commands/onboarding/browser/reset.d.ts +71 -0
- package/dist/commands/onboarding/browser/reset.js +18 -0
- package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
- package/dist/commands/onboarding/browser/screenshot.js +19 -0
- package/dist/commands/onboarding/browser/state.d.ts +63 -0
- package/dist/commands/onboarding/browser/state.js +12 -0
- package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
- package/dist/commands/onboarding/browser/tabs.js +16 -0
- package/dist/commands/onboarding/cache/clear.d.ts +58 -0
- package/dist/commands/onboarding/cache/clear.js +12 -0
- package/dist/commands/onboarding/cache/errors.d.ts +58 -0
- package/dist/commands/onboarding/cache/errors.js +12 -0
- package/dist/commands/onboarding/cache/evict.d.ts +62 -0
- package/dist/commands/onboarding/cache/evict.js +15 -0
- package/dist/commands/onboarding/cache/get.d.ts +85 -0
- package/dist/commands/onboarding/cache/get.js +17 -0
- package/dist/commands/onboarding/cache/list.d.ts +58 -0
- package/dist/commands/onboarding/cache/list.js +15 -0
- package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
- package/dist/commands/onboarding/cache/prewarm.js +20 -0
- package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
- package/dist/commands/onboarding/cache/refresh.js +18 -0
- package/dist/commands/onboarding/cdp.d.ts +81 -0
- package/dist/commands/onboarding/cdp.js +18 -0
- package/dist/commands/onboarding/debug/arm.d.ts +83 -0
- package/dist/commands/onboarding/debug/arm.js +19 -0
- package/dist/commands/onboarding/debug/await.d.ts +71 -0
- package/dist/commands/onboarding/debug/await.js +18 -0
- package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
- package/dist/commands/onboarding/debug/disarm.js +12 -0
- package/dist/commands/onboarding/debug/eval.d.ts +75 -0
- package/dist/commands/onboarding/debug/eval.js +16 -0
- package/dist/commands/onboarding/debug/release.d.ts +63 -0
- package/dist/commands/onboarding/debug/release.js +12 -0
- package/dist/commands/onboarding/debug/resume.d.ts +63 -0
- package/dist/commands/onboarding/debug/resume.js +12 -0
- package/dist/commands/onboarding/debug/status.d.ts +63 -0
- package/dist/commands/onboarding/debug/status.js +12 -0
- package/dist/commands/onboarding/debug/step.d.ts +67 -0
- package/dist/commands/onboarding/debug/step.js +15 -0
- package/dist/commands/onboarding/files/list.d.ts +58 -0
- package/dist/commands/onboarding/files/list.js +12 -0
- package/dist/commands/onboarding/files/read.d.ts +73 -0
- package/dist/commands/onboarding/files/read.js +16 -0
- package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
- package/dist/commands/onboarding/files/rebuild.js +18 -0
- package/dist/commands/onboarding/files/validate.d.ts +58 -0
- package/dist/commands/onboarding/files/validate.js +12 -0
- package/dist/commands/onboarding/fouc.d.ts +77 -0
- package/dist/commands/onboarding/fouc.js +16 -0
- package/dist/commands/onboarding/inject/add.d.ts +89 -0
- package/dist/commands/onboarding/inject/add.js +17 -0
- package/dist/commands/onboarding/inject/clear.d.ts +63 -0
- package/dist/commands/onboarding/inject/clear.js +12 -0
- package/dist/commands/onboarding/inject/list.d.ts +63 -0
- package/dist/commands/onboarding/inject/list.js +12 -0
- package/dist/commands/onboarding/inject/read.d.ts +75 -0
- package/dist/commands/onboarding/inject/read.js +18 -0
- package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
- package/dist/commands/onboarding/inject/recipes.js +12 -0
- package/dist/commands/onboarding/inject/remove.d.ts +67 -0
- package/dist/commands/onboarding/inject/remove.js +15 -0
- package/dist/commands/onboarding/list.d.ts +13 -0
- package/dist/commands/onboarding/list.js +12 -0
- package/dist/commands/onboarding/logs.d.ts +41 -0
- package/dist/commands/onboarding/logs.js +257 -0
- package/dist/commands/onboarding/navwalk.d.ts +95 -0
- package/dist/commands/onboarding/navwalk.js +19 -0
- package/dist/commands/onboarding/response.d.ts +67 -0
- package/dist/commands/onboarding/response.js +18 -0
- package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
- package/dist/commands/onboarding/rum/beacons.js +16 -0
- package/dist/commands/onboarding/rum/get.d.ts +77 -0
- package/dist/commands/onboarding/rum/get.js +18 -0
- package/dist/commands/onboarding/rum/key.d.ts +67 -0
- package/dist/commands/onboarding/rum/key.js +13 -0
- package/dist/commands/onboarding/rum/previous.d.ts +63 -0
- package/dist/commands/onboarding/rum/previous.js +12 -0
- package/dist/commands/onboarding/status.d.ts +13 -0
- package/dist/commands/onboarding/status.js +17 -0
- package/dist/commands/onboarding/stop.d.ts +13 -0
- package/dist/commands/onboarding/stop.js +17 -0
- package/dist/commands/onboarding/todo.d.ts +58 -0
- package/dist/commands/onboarding/todo.js +12 -0
- package/dist/commands/onboarding/viewport.d.ts +101 -0
- package/dist/commands/onboarding/viewport.js +18 -0
- package/dist/commands/onboarding/watch.d.ts +93 -0
- package/dist/commands/onboarding/watch.js +16 -0
- package/dist/commands/onboarding.d.ts +26 -0
- package/dist/commands/onboarding.js +221 -4
- package/dist/commands/origin-request.d.ts +4 -0
- package/dist/commands/origin-request.js +4 -0
- package/dist/commands/spec/onboarding.spec.d.ts +1 -0
- package/dist/commands/spec/onboarding.spec.js +127 -0
- package/dist/services/browser-fetch/device-emulation.d.ts +11 -0
- package/dist/services/browser-fetch/device-emulation.js +14 -0
- package/dist/services/cli/build-info.d.ts +33 -0
- package/dist/services/cli/build-info.js +63 -0
- package/dist/services/cli/cli-environment-factory.d.ts +3 -0
- package/dist/services/cli/cli-environment-factory.js +1 -0
- package/dist/services/cli/cli-service-build-context.d.ts +3 -0
- package/dist/services/cli/cli-service-factory.js +1 -1
- package/dist/services/cli/cli-service-model.d.ts +29 -10
- package/dist/services/cli/cli-service.d.ts +60 -11
- package/dist/services/cli/cli-service.js +196 -32
- package/dist/services/cli/index.d.ts +2 -0
- package/dist/services/cli/index.js +2 -0
- package/dist/services/cli/sink.d.ts +47 -0
- package/dist/services/cli/sink.js +31 -0
- package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
- package/dist/services/cli/spec/build-identity.spec.js +85 -0
- package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
- package/dist/services/cli/spec/build-info.spec.js +10 -0
- package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
- package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
- package/dist/services/cli/spec/cli-service.spec.js +113 -50
- package/dist/services/cli/spec/memory-cli.d.ts +9 -0
- package/dist/services/cli/spec/memory-cli.js +9 -0
- package/dist/services/diff/config-at-ref.d.ts +20 -0
- package/dist/services/diff/config-at-ref.js +33 -0
- package/dist/services/diff/diff-service-build-context.d.ts +12 -0
- package/dist/services/diff/diff-service-build-context.js +45 -1
- package/dist/services/diff/diff-service-factory.d.ts +2 -0
- package/dist/services/diff/diff-service-factory.js +65 -25
- package/dist/services/diff/diff-service.d.ts +11 -0
- package/dist/services/diff/diff-service.js +37 -11
- package/dist/services/diff/page-source.d.ts +12 -0
- package/dist/services/diff/page-source.js +16 -11
- package/dist/services/diff/run-runtime-config.d.ts +33 -0
- package/dist/services/diff/run-runtime-config.js +74 -0
- package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
- package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
- package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
- package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
- package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
- package/dist/services/diff/spec/diff-service.spec.js +95 -0
- package/dist/services/diff/spec/run-runtime-config.spec.d.ts +1 -0
- package/dist/services/diff/spec/run-runtime-config.spec.js +87 -0
- package/dist/services/git/git-repository.d.ts +2 -0
- package/dist/services/git/git-repository.js +6 -0
- package/dist/services/integration-api/customer-config-flags.js +1 -0
- package/dist/services/onboarding/browse/browse-service.d.ts +13 -1
- package/dist/services/onboarding/browse/browse-service.js +43 -7
- package/dist/services/onboarding/browser/answer-dialogs.d.ts +12 -0
- package/dist/services/onboarding/browser/answer-dialogs.js +25 -0
- package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
- package/dist/services/onboarding/browser/baqend-response.js +23 -0
- package/dist/services/onboarding/browser/console-log.d.ts +9 -0
- package/dist/services/onboarding/browser/console-log.js +27 -0
- package/dist/services/onboarding/browser/emulate-device.d.ts +12 -1
- package/dist/services/onboarding/browser/emulate-device.js +68 -13
- package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
- package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
- package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
- package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
- package/dist/services/onboarding/browser/launch-browser.d.ts +2 -1
- package/dist/services/onboarding/browser/launch-browser.js +6 -1
- package/dist/services/onboarding/browser/resume-restarted-workers.d.ts +14 -0
- package/dist/services/onboarding/browser/resume-restarted-workers.js +26 -0
- package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
- package/dist/services/onboarding/control/body-inspect.js +106 -0
- package/dist/services/onboarding/control/browser-session.d.ts +547 -0
- package/dist/services/onboarding/control/browser-session.js +1337 -0
- package/dist/services/onboarding/control/config-validation.d.ts +17 -0
- package/dist/services/onboarding/control/config-validation.js +46 -0
- package/dist/services/onboarding/control/control-protocol.d.ts +1430 -0
- package/dist/services/onboarding/control/control-protocol.js +58 -0
- package/dist/services/onboarding/control/control-server.d.ts +292 -0
- package/dist/services/onboarding/control/control-server.js +1629 -0
- package/dist/services/onboarding/control/debug-session.d.ts +219 -0
- package/dist/services/onboarding/control/debug-session.js +897 -0
- package/dist/services/onboarding/control/fouc.d.ts +23 -0
- package/dist/services/onboarding/control/fouc.js +151 -0
- package/dist/services/onboarding/control/index.d.ts +4 -0
- package/dist/services/onboarding/control/index.js +4 -0
- package/dist/services/onboarding/control/navigate-wait.d.ts +33 -0
- package/dist/services/onboarding/control/navigate-wait.js +56 -0
- package/dist/services/onboarding/control/navwalk.d.ts +65 -0
- package/dist/services/onboarding/control/navwalk.js +248 -0
- package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
- package/dist/services/onboarding/control/preload-registry.js +829 -0
- package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
- package/dist/services/onboarding/control/response-explainer.js +257 -0
- package/dist/services/onboarding/control/rum.d.ts +8 -0
- package/dist/services/onboarding/control/rum.js +220 -0
- package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
- package/dist/services/onboarding/control/service-worker-tracker.js +120 -0
- package/dist/services/onboarding/control/viewport.d.ts +45 -0
- package/dist/services/onboarding/control/viewport.js +344 -0
- package/dist/services/onboarding/control/watch.d.ts +26 -0
- package/dist/services/onboarding/control/watch.js +157 -0
- package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
- package/dist/services/onboarding/dashboard/index.js +7 -2
- package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
- package/dist/services/onboarding/fetch-event-handler.js +103 -32
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
- package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
- package/dist/services/onboarding/file-events/file-watcher.js +117 -12
- package/dist/services/onboarding/inject/inject-service.js +1 -1
- package/dist/services/onboarding/onboarding-model.d.ts +40 -7
- package/dist/services/onboarding/onboarding-model.js +20 -9
- package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
- package/dist/services/onboarding/onboarding-service-build-context.js +7 -1
- package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
- package/dist/services/onboarding/onboarding-service-factory.js +150 -23
- package/dist/services/onboarding/onboarding-service.d.ts +40 -1
- package/dist/services/onboarding/onboarding-service.js +139 -23
- package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
- package/dist/services/onboarding/request-cache/asset-key.js +115 -0
- package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
- package/dist/services/onboarding/request-cache/cache.js +128 -17
- package/dist/services/onboarding/spec/browser/answer-dialogs.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browser/answer-dialogs.spec.js +66 -0
- package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
- package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.js +45 -0
- package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/browser-session.spec.js +753 -0
- package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/control-server.spec.js +371 -0
- package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/debug-session.spec.js +751 -0
- package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
- package/dist/services/onboarding/spec/control/fakes.js +67 -0
- package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
- package/dist/services/onboarding/spec/control/navigate-wait.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/navigate-wait.spec.js +47 -0
- package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
- package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
- package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
- package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
- package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
- package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/watch.spec.js +187 -0
- package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/fetch-event-handler.spec.js +219 -0
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
- package/dist/services/onboarding/spec/onboarding-model.spec.js +39 -3
- package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +25 -1
- package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
- package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
- package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.js +65 -0
- package/dist/services/onboarding/templates/install-speed-kit-html-template.js +11 -0
- package/dist/services/onboarding/templates/spec/install-speed-kit-html-template.spec.d.ts +1 -0
- package/dist/services/onboarding/templates/spec/install-speed-kit-html-template.spec.js +119 -0
- package/dist/services/onboarding/todo-collector.d.ts +7 -2
- package/dist/services/onboarding/todo-collector.js +49 -12
- package/dist/services/onboarding/virtual-orestes-app/index.d.ts +38 -0
- package/dist/services/onboarding/virtual-orestes-app/index.js +113 -27
- package/dist/services/origin-request/asset-variations.d.ts +14 -0
- package/dist/services/origin-request/asset-variations.js +11 -4
- package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
- package/dist/services/origin-request/origin-fetcher.js +43 -5
- package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
- package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
- package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
- package/dist/services/origin-request/origin-request-service-factory.js +2 -30
- package/dist/services/origin-request/origin-request-service.d.ts +121 -6
- package/dist/services/origin-request/origin-request-service.js +273 -49
- package/dist/services/origin-request/runtime-config-source.d.ts +6 -0
- package/dist/services/origin-request/runtime-config-source.js +15 -4
- package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
- package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
- package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
- package/dist/services/query-builder/rules/rule-match.js +70 -0
- package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
- package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
- package/dist/services/run-control/browser/run-browser-contexts.d.ts +557 -0
- package/dist/services/run-control/browser/run-browser-contexts.js +91 -0
- package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
- package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
- package/dist/services/run-control/browser/run-browser-service.d.ts +68 -0
- package/dist/services/run-control/browser/run-browser-service.js +206 -0
- package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
- package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
- package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
- package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
- package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
- package/dist/services/run-control/cache/run-cache-service.js +151 -0
- package/dist/services/run-control/control-client.d.ts +36 -0
- package/dist/services/run-control/control-client.js +147 -0
- package/dist/services/run-control/debug/run-debug-contexts.d.ts +416 -0
- package/dist/services/run-control/debug/run-debug-contexts.js +47 -0
- package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
- package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
- package/dist/services/run-control/debug/run-debug-service.d.ts +39 -0
- package/dist/services/run-control/debug/run-debug-service.js +164 -0
- package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
- package/dist/services/run-control/files/run-files-contexts.js +26 -0
- package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
- package/dist/services/run-control/files/run-files-service-factory.js +7 -0
- package/dist/services/run-control/files/run-files-service.d.ts +29 -0
- package/dist/services/run-control/files/run-files-service.js +120 -0
- package/dist/services/run-control/index.d.ts +32 -0
- package/dist/services/run-control/index.js +31 -0
- package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
- package/dist/services/run-control/inject/run-inject-contexts.js +38 -0
- package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
- package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
- package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
- package/dist/services/run-control/inject/run-inject-service.js +227 -0
- package/dist/services/run-control/live-run.d.ts +37 -0
- package/dist/services/run-control/live-run.js +56 -0
- package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
- package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
- package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
- package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
- package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
- package/dist/services/run-control/probe/run-probe-service.js +194 -0
- package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
- package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
- package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
- package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
- package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
- package/dist/services/run-control/rum/run-rum-service.js +122 -0
- package/dist/services/run-control/run-answer.d.ts +28 -0
- package/dist/services/run-control/run-answer.js +58 -0
- package/dist/services/run-control/run-control-context.d.ts +102 -0
- package/dist/services/run-control/run-control-context.js +36 -0
- package/dist/services/run-control/run-control-flags.d.ts +12 -0
- package/dist/services/run-control/run-control-flags.js +22 -0
- package/dist/services/run-control/run-control-model.d.ts +9 -0
- package/dist/services/run-control/run-control-model.js +1 -0
- package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
- package/dist/services/run-control/run-control-service-factory.js +26 -0
- package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
- package/dist/services/run-control/session/run-session-contexts.js +20 -0
- package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
- package/dist/services/run-control/session/run-session-service-factory.js +18 -0
- package/dist/services/run-control/session/run-session-service.d.ts +32 -0
- package/dist/services/run-control/session/run-session-service.js +151 -0
- package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/browser/run-browser-service.spec.js +328 -0
- package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
- package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
- package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
- package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/inject/run-inject-service.spec.js +251 -0
- package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
- package/dist/services/run-control/spec/live-run-fixture.js +109 -0
- package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
- package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
- package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
- package/dist/services/run-control/spec/run-answer.spec.js +57 -0
- package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/session/run-session-service.spec.js +150 -0
- package/dist/services/run-log/crash-mirror.d.ts +31 -0
- package/dist/services/run-log/crash-mirror.js +69 -0
- package/dist/services/run-log/index.d.ts +11 -0
- package/dist/services/run-log/index.js +11 -0
- package/dist/services/run-log/jsonl-appender.d.ts +46 -0
- package/dist/services/run-log/jsonl-appender.js +91 -0
- package/dist/services/run-log/log-event-model.d.ts +104 -0
- package/dist/services/run-log/log-event-model.js +56 -0
- package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
- package/dist/services/run-log/log-query-service-factory.js +14 -0
- package/dist/services/run-log/log-query-service.d.ts +59 -0
- package/dist/services/run-log/log-query-service.js +111 -0
- package/dist/services/run-log/log-reader.d.ts +84 -0
- package/dist/services/run-log/log-reader.js +180 -0
- package/dist/services/run-log/log-summary.d.ts +72 -0
- package/dist/services/run-log/log-summary.js +208 -0
- package/dist/services/run-log/redaction.d.ts +34 -0
- package/dist/services/run-log/redaction.js +124 -0
- package/dist/services/run-log/request-log.d.ts +82 -0
- package/dist/services/run-log/request-log.js +69 -0
- package/dist/services/run-log/request-summary.d.ts +76 -0
- package/dist/services/run-log/request-summary.js +0 -0
- package/dist/services/run-log/run-log.d.ts +61 -0
- package/dist/services/run-log/run-log.js +102 -0
- package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
- package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-reader.spec.js +109 -0
- package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-summary.spec.js +153 -0
- package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
- package/dist/services/run-log/spec/redaction.spec.js +61 -0
- package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
- package/dist/services/run-log/spec/request-log.spec.js +101 -0
- package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
- package/dist/services/run-log/spec/request-summary.spec.js +171 -0
- package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
- package/dist/services/run-log/spec/run-log.spec.js +122 -0
- package/dist/services/run-registry/exit-classification.d.ts +39 -0
- package/dist/services/run-registry/exit-classification.js +42 -0
- package/dist/services/run-registry/index.d.ts +3 -0
- package/dist/services/run-registry/index.js +3 -0
- package/dist/services/run-registry/process-identity.d.ts +28 -0
- package/dist/services/run-registry/process-identity.js +80 -0
- package/dist/services/run-registry/run-registry-model.d.ts +128 -0
- package/dist/services/run-registry/run-registry-model.js +16 -0
- package/dist/services/run-registry/run-registry.d.ts +155 -0
- package/dist/services/run-registry/run-registry.js +430 -0
- package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
- package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
- package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
- package/dist/services/run-registry/spec/run-registry.spec.js +526 -0
- package/dist/services/setup/os/tool-registry.js +2 -2
- package/oclif.manifest.json +3414 -293
- 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
|
+
}
|