@enricai/barnacle 1.0.0
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/LICENSE +21 -0
- package/README.md +958 -0
- package/dist/api/errors.d.ts +88 -0
- package/dist/api/errors.d.ts.map +1 -0
- package/dist/api/errors.js +164 -0
- package/dist/api/errors.js.map +1 -0
- package/dist/api/helpers/envelope.d.ts +13 -0
- package/dist/api/helpers/envelope.d.ts.map +1 -0
- package/dist/api/helpers/envelope.js +20 -0
- package/dist/api/helpers/envelope.js.map +1 -0
- package/dist/api/helpers/reply.d.ts +9 -0
- package/dist/api/helpers/reply.d.ts.map +1 -0
- package/dist/api/helpers/reply.js +14 -0
- package/dist/api/helpers/reply.js.map +1 -0
- package/dist/api/plugins/auth.d.ts +27 -0
- package/dist/api/plugins/auth.d.ts.map +1 -0
- package/dist/api/plugins/auth.js +111 -0
- package/dist/api/plugins/auth.js.map +1 -0
- package/dist/api/plugins/error-handler.d.ts +12 -0
- package/dist/api/plugins/error-handler.d.ts.map +1 -0
- package/dist/api/plugins/error-handler.js +72 -0
- package/dist/api/plugins/error-handler.js.map +1 -0
- package/dist/api/plugins/request-context.d.ts +17 -0
- package/dist/api/plugins/request-context.d.ts.map +1 -0
- package/dist/api/plugins/request-context.js +61 -0
- package/dist/api/plugins/request-context.js.map +1 -0
- package/dist/api/routes/health.d.ts +55 -0
- package/dist/api/routes/health.d.ts.map +1 -0
- package/dist/api/routes/health.js +137 -0
- package/dist/api/routes/health.js.map +1 -0
- package/dist/api/routes/plugins-introspection.d.ts +17 -0
- package/dist/api/routes/plugins-introspection.d.ts.map +1 -0
- package/dist/api/routes/plugins-introspection.js +13 -0
- package/dist/api/routes/plugins-introspection.js.map +1 -0
- package/dist/api/schemas/common.d.ts +114 -0
- package/dist/api/schemas/common.d.ts.map +1 -0
- package/dist/api/schemas/common.js +109 -0
- package/dist/api/schemas/common.js.map +1 -0
- package/dist/api/schemas/telemetry.d.ts +66 -0
- package/dist/api/schemas/telemetry.d.ts.map +1 -0
- package/dist/api/schemas/telemetry.js +52 -0
- package/dist/api/schemas/telemetry.js.map +1 -0
- package/dist/cache/keyed-ttl-cache.d.ts +45 -0
- package/dist/cache/keyed-ttl-cache.d.ts.map +1 -0
- package/dist/cache/keyed-ttl-cache.js +69 -0
- package/dist/cache/keyed-ttl-cache.js.map +1 -0
- package/dist/cache/response-cache.d.ts +37 -0
- package/dist/cache/response-cache.d.ts.map +1 -0
- package/dist/cache/response-cache.js +114 -0
- package/dist/cache/response-cache.js.map +1 -0
- package/dist/config.d.ts +258 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +138 -0
- package/dist/config.js.map +1 -0
- package/dist/lib/applicant-payload.d.ts +28 -0
- package/dist/lib/applicant-payload.d.ts.map +1 -0
- package/dist/lib/applicant-payload.js +20 -0
- package/dist/lib/applicant-payload.js.map +1 -0
- package/dist/lib/application-address.d.ts +16 -0
- package/dist/lib/application-address.d.ts.map +1 -0
- package/dist/lib/application-address.js +20 -0
- package/dist/lib/application-address.js.map +1 -0
- package/dist/lib/application-answers.d.ts +151 -0
- package/dist/lib/application-answers.d.ts.map +1 -0
- package/dist/lib/application-answers.js +95 -0
- package/dist/lib/application-answers.js.map +1 -0
- package/dist/lib/application-identity.d.ts +18 -0
- package/dist/lib/application-identity.d.ts.map +1 -0
- package/dist/lib/application-identity.js +20 -0
- package/dist/lib/application-identity.js.map +1 -0
- package/dist/lib/application-resume.d.ts +21 -0
- package/dist/lib/application-resume.d.ts.map +1 -0
- package/dist/lib/application-resume.js +23 -0
- package/dist/lib/application-resume.js.map +1 -0
- package/dist/lib/bedrock.d.ts +22 -0
- package/dist/lib/bedrock.d.ts.map +1 -0
- package/dist/lib/bedrock.js +35 -0
- package/dist/lib/bedrock.js.map +1 -0
- package/dist/lib/case-insensitive-headers.d.ts +15 -0
- package/dist/lib/case-insensitive-headers.d.ts.map +1 -0
- package/dist/lib/case-insensitive-headers.js +29 -0
- package/dist/lib/case-insensitive-headers.js.map +1 -0
- package/dist/lib/chromium-client-hints.d.ts +11 -0
- package/dist/lib/chromium-client-hints.d.ts.map +1 -0
- package/dist/lib/chromium-client-hints.js +17 -0
- package/dist/lib/chromium-client-hints.js.map +1 -0
- package/dist/lib/cookie-value.d.ts +8 -0
- package/dist/lib/cookie-value.d.ts.map +1 -0
- package/dist/lib/cookie-value.js +14 -0
- package/dist/lib/cookie-value.js.map +1 -0
- package/dist/lib/datadog.d.ts +8 -0
- package/dist/lib/datadog.d.ts.map +1 -0
- package/dist/lib/datadog.js +27 -0
- package/dist/lib/datadog.js.map +1 -0
- package/dist/lib/dd-metrics.d.ts +28 -0
- package/dist/lib/dd-metrics.d.ts.map +1 -0
- package/dist/lib/dd-metrics.js +62 -0
- package/dist/lib/dd-metrics.js.map +1 -0
- package/dist/lib/dispatch-metrics.d.ts +19 -0
- package/dist/lib/dispatch-metrics.d.ts.map +1 -0
- package/dist/lib/dispatch-metrics.js +65 -0
- package/dist/lib/dispatch-metrics.js.map +1 -0
- package/dist/lib/env.d.ts +37 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/env.js +70 -0
- package/dist/lib/env.js.map +1 -0
- package/dist/lib/errors.d.ts +15 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +20 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/http.d.ts +7 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/http.js +14 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/job-tracking.d.ts +17 -0
- package/dist/lib/job-tracking.d.ts.map +1 -0
- package/dist/lib/job-tracking.js +19 -0
- package/dist/lib/job-tracking.js.map +1 -0
- package/dist/lib/llm/anthropic-client.d.ts +12 -0
- package/dist/lib/llm/anthropic-client.d.ts.map +1 -0
- package/dist/lib/llm/anthropic-client.js +23 -0
- package/dist/lib/llm/anthropic-client.js.map +1 -0
- package/dist/lib/llm/judge.d.ts +57 -0
- package/dist/lib/llm/judge.d.ts.map +1 -0
- package/dist/lib/llm/judge.js +123 -0
- package/dist/lib/llm/judge.js.map +1 -0
- package/dist/lib/llm/judges/error-messages.d.ts +38 -0
- package/dist/lib/llm/judges/error-messages.d.ts.map +1 -0
- package/dist/lib/llm/judges/error-messages.js +72 -0
- package/dist/lib/llm/judges/error-messages.js.map +1 -0
- package/dist/lib/llm/judges/invalid-fields.d.ts +43 -0
- package/dist/lib/llm/judges/invalid-fields.d.ts.map +1 -0
- package/dist/lib/llm/judges/invalid-fields.js +80 -0
- package/dist/lib/llm/judges/invalid-fields.js.map +1 -0
- package/dist/lib/llm/judges/modal-priority.d.ts +41 -0
- package/dist/lib/llm/judges/modal-priority.d.ts.map +1 -0
- package/dist/lib/llm/judges/modal-priority.js +74 -0
- package/dist/lib/llm/judges/modal-priority.js.map +1 -0
- package/dist/lib/llm/judges/select-option.d.ts +49 -0
- package/dist/lib/llm/judges/select-option.d.ts.map +1 -0
- package/dist/lib/llm/judges/select-option.js +90 -0
- package/dist/lib/llm/judges/select-option.js.map +1 -0
- package/dist/lib/llm/judges/verify-submit.d.ts +68 -0
- package/dist/lib/llm/judges/verify-submit.d.ts.map +1 -0
- package/dist/lib/llm/judges/verify-submit.js +89 -0
- package/dist/lib/llm/judges/verify-submit.js.map +1 -0
- package/dist/lib/llm/schemas.d.ts +220 -0
- package/dist/lib/llm/schemas.d.ts.map +1 -0
- package/dist/lib/llm/schemas.js +239 -0
- package/dist/lib/llm/schemas.js.map +1 -0
- package/dist/lib/logging.d.ts +39 -0
- package/dist/lib/logging.d.ts.map +1 -0
- package/dist/lib/logging.js +219 -0
- package/dist/lib/logging.js.map +1 -0
- package/dist/lib/multipart.d.ts +34 -0
- package/dist/lib/multipart.d.ts.map +1 -0
- package/dist/lib/multipart.js +55 -0
- package/dist/lib/multipart.js.map +1 -0
- package/dist/lib/option-matcher.d.ts +15 -0
- package/dist/lib/option-matcher.d.ts.map +1 -0
- package/dist/lib/option-matcher.js +69 -0
- package/dist/lib/option-matcher.js.map +1 -0
- package/dist/lib/phone.d.ts +11 -0
- package/dist/lib/phone.d.ts.map +1 -0
- package/dist/lib/phone.js +17 -0
- package/dist/lib/phone.js.map +1 -0
- package/dist/lib/random.d.ts +22 -0
- package/dist/lib/random.d.ts.map +1 -0
- package/dist/lib/random.js +33 -0
- package/dist/lib/random.js.map +1 -0
- package/dist/lib/statsd.d.ts +11 -0
- package/dist/lib/statsd.d.ts.map +1 -0
- package/dist/lib/statsd.js +68 -0
- package/dist/lib/statsd.js.map +1 -0
- package/dist/lib/telemetry/call-capture.d.ts +89 -0
- package/dist/lib/telemetry/call-capture.d.ts.map +1 -0
- package/dist/lib/telemetry/call-capture.js +190 -0
- package/dist/lib/telemetry/call-capture.js.map +1 -0
- package/dist/lib/telemetry/call-types.d.ts +65 -0
- package/dist/lib/telemetry/call-types.d.ts.map +1 -0
- package/dist/lib/telemetry/call-types.js +68 -0
- package/dist/lib/telemetry/call-types.js.map +1 -0
- package/dist/lib/telemetry/run-state.d.ts +15 -0
- package/dist/lib/telemetry/run-state.d.ts.map +1 -0
- package/dist/lib/telemetry/run-state.js +23 -0
- package/dist/lib/telemetry/run-state.js.map +1 -0
- package/dist/lib/telemetry/s3-sink.d.ts +48 -0
- package/dist/lib/telemetry/s3-sink.d.ts.map +1 -0
- package/dist/lib/telemetry/s3-sink.js +229 -0
- package/dist/lib/telemetry/s3-sink.js.map +1 -0
- package/dist/lib/telemetry/submission-capture.d.ts +45 -0
- package/dist/lib/telemetry/submission-capture.d.ts.map +1 -0
- package/dist/lib/telemetry/submission-capture.js +57 -0
- package/dist/lib/telemetry/submission-capture.js.map +1 -0
- package/dist/lib/telemetry/telemetry-paths.d.ts +59 -0
- package/dist/lib/telemetry/telemetry-paths.d.ts.map +1 -0
- package/dist/lib/telemetry/telemetry-paths.js +103 -0
- package/dist/lib/telemetry/telemetry-paths.js.map +1 -0
- package/dist/lib/tracking-click.d.ts +20 -0
- package/dist/lib/tracking-click.d.ts.map +1 -0
- package/dist/lib/tracking-click.js +75 -0
- package/dist/lib/tracking-click.js.map +1 -0
- package/dist/lib/url-capture.d.ts +8 -0
- package/dist/lib/url-capture.d.ts.map +1 -0
- package/dist/lib/url-capture.js +17 -0
- package/dist/lib/url-capture.js.map +1 -0
- package/dist/lib/us-states.d.ts +20 -0
- package/dist/lib/us-states.d.ts.map +1 -0
- package/dist/lib/us-states.js +86 -0
- package/dist/lib/us-states.js.map +1 -0
- package/dist/lib/zod-multipart.d.ts +18 -0
- package/dist/lib/zod-multipart.d.ts.map +1 -0
- package/dist/lib/zod-multipart.js +35 -0
- package/dist/lib/zod-multipart.js.map +1 -0
- package/dist/plugins/config-plugin.d.ts +77 -0
- package/dist/plugins/config-plugin.d.ts.map +1 -0
- package/dist/plugins/config-plugin.js +216 -0
- package/dist/plugins/config-plugin.js.map +1 -0
- package/dist/plugins/discover.d.ts +72 -0
- package/dist/plugins/discover.d.ts.map +1 -0
- package/dist/plugins/discover.js +265 -0
- package/dist/plugins/discover.js.map +1 -0
- package/dist/plugins/json-schema-to-zod.d.ts +47 -0
- package/dist/plugins/json-schema-to-zod.d.ts.map +1 -0
- package/dist/plugins/json-schema-to-zod.js +85 -0
- package/dist/plugins/json-schema-to-zod.js.map +1 -0
- package/dist/plugins/loader.d.ts +34 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +348 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/plugin-api-version.d.ts +8 -0
- package/dist/plugins/plugin-api-version.d.ts.map +1 -0
- package/dist/plugins/plugin-api-version.js +11 -0
- package/dist/plugins/plugin-api-version.js.map +1 -0
- package/dist/plugins/plugin-manifest-envelope.d.ts +16 -0
- package/dist/plugins/plugin-manifest-envelope.d.ts.map +1 -0
- package/dist/plugins/plugin-manifest-envelope.js +19 -0
- package/dist/plugins/plugin-manifest-envelope.js.map +1 -0
- package/dist/scraper/behavioral-signals.d.ts +16 -0
- package/dist/scraper/behavioral-signals.d.ts.map +1 -0
- package/dist/scraper/behavioral-signals.js +30 -0
- package/dist/scraper/behavioral-signals.js.map +1 -0
- package/dist/scraper/errors.d.ts +193 -0
- package/dist/scraper/errors.d.ts.map +1 -0
- package/dist/scraper/errors.js +226 -0
- package/dist/scraper/errors.js.map +1 -0
- package/dist/scraper/fixtures.d.ts +23 -0
- package/dist/scraper/fixtures.d.ts.map +1 -0
- package/dist/scraper/fixtures.js +48 -0
- package/dist/scraper/fixtures.js.map +1 -0
- package/dist/scraper/flow-runner.d.ts +1319 -0
- package/dist/scraper/flow-runner.d.ts.map +1 -0
- package/dist/scraper/flow-runner.js +5637 -0
- package/dist/scraper/flow-runner.js.map +1 -0
- package/dist/scraper/graphql-client.d.ts +30 -0
- package/dist/scraper/graphql-client.d.ts.map +1 -0
- package/dist/scraper/graphql-client.js +14 -0
- package/dist/scraper/graphql-client.js.map +1 -0
- package/dist/scraper/http-client.d.ts +75 -0
- package/dist/scraper/http-client.d.ts.map +1 -0
- package/dist/scraper/http-client.js +189 -0
- package/dist/scraper/http-client.js.map +1 -0
- package/dist/scraper/http-status-classifier.d.ts +12 -0
- package/dist/scraper/http-status-classifier.d.ts.map +1 -0
- package/dist/scraper/http-status-classifier.js +29 -0
- package/dist/scraper/http-status-classifier.js.map +1 -0
- package/dist/scraper/metrics.d.ts +50 -0
- package/dist/scraper/metrics.d.ts.map +1 -0
- package/dist/scraper/metrics.js +85 -0
- package/dist/scraper/metrics.js.map +1 -0
- package/dist/scraper/navigate.d.ts +20 -0
- package/dist/scraper/navigate.d.ts.map +1 -0
- package/dist/scraper/navigate.js +30 -0
- package/dist/scraper/navigate.js.map +1 -0
- package/dist/scraper/oracle-sentinels.d.ts +22 -0
- package/dist/scraper/oracle-sentinels.d.ts.map +1 -0
- package/dist/scraper/oracle-sentinels.js +40 -0
- package/dist/scraper/oracle-sentinels.js.map +1 -0
- package/dist/scraper/parse-json-response.d.ts +16 -0
- package/dist/scraper/parse-json-response.d.ts.map +1 -0
- package/dist/scraper/parse-json-response.js +37 -0
- package/dist/scraper/parse-json-response.js.map +1 -0
- package/dist/scraper/pool.d.ts +37 -0
- package/dist/scraper/pool.d.ts.map +1 -0
- package/dist/scraper/pool.js +105 -0
- package/dist/scraper/pool.js.map +1 -0
- package/dist/scraper/rate-limited-json-client.d.ts +35 -0
- package/dist/scraper/rate-limited-json-client.d.ts.map +1 -0
- package/dist/scraper/rate-limited-json-client.js +29 -0
- package/dist/scraper/rate-limited-json-client.js.map +1 -0
- package/dist/scraper/raw-fetch.d.ts +49 -0
- package/dist/scraper/raw-fetch.d.ts.map +1 -0
- package/dist/scraper/raw-fetch.js +40 -0
- package/dist/scraper/raw-fetch.js.map +1 -0
- package/dist/scraper/require-response-field.d.ts +23 -0
- package/dist/scraper/require-response-field.d.ts.map +1 -0
- package/dist/scraper/require-response-field.js +42 -0
- package/dist/scraper/require-response-field.js.map +1 -0
- package/dist/scraper/retry.d.ts +33 -0
- package/dist/scraper/retry.d.ts.map +1 -0
- package/dist/scraper/retry.js +122 -0
- package/dist/scraper/retry.js.map +1 -0
- package/dist/scraper/session-browserbase.d.ts +35 -0
- package/dist/scraper/session-browserbase.d.ts.map +1 -0
- package/dist/scraper/session-browserbase.js +198 -0
- package/dist/scraper/session-browserbase.js.map +1 -0
- package/dist/scraper/session-shared.d.ts +29 -0
- package/dist/scraper/session-shared.d.ts.map +1 -0
- package/dist/scraper/session-shared.js +35 -0
- package/dist/scraper/session-shared.js.map +1 -0
- package/dist/scraper/session-steel.d.ts +31 -0
- package/dist/scraper/session-steel.d.ts.map +1 -0
- package/dist/scraper/session-steel.js +140 -0
- package/dist/scraper/session-steel.js.map +1 -0
- package/dist/scraper/session-warmup.d.ts +31 -0
- package/dist/scraper/session-warmup.d.ts.map +1 -0
- package/dist/scraper/session-warmup.js +46 -0
- package/dist/scraper/session-warmup.js.map +1 -0
- package/dist/scraper/session.d.ts +21 -0
- package/dist/scraper/session.d.ts.map +1 -0
- package/dist/scraper/session.js +28 -0
- package/dist/scraper/session.js.map +1 -0
- package/dist/scraper/stagehand-guard.d.ts +128 -0
- package/dist/scraper/stagehand-guard.d.ts.map +1 -0
- package/dist/scraper/stagehand-guard.js +337 -0
- package/dist/scraper/stagehand-guard.js.map +1 -0
- package/dist/scraper/throttle.d.ts +21 -0
- package/dist/scraper/throttle.d.ts.map +1 -0
- package/dist/scraper/throttle.js +45 -0
- package/dist/scraper/throttle.js.map +1 -0
- package/dist/scripts/hca-inbox-poll.d.ts +19 -0
- package/dist/scripts/hca-inbox-poll.d.ts.map +1 -0
- package/dist/scripts/hca-inbox-poll.js +151 -0
- package/dist/scripts/hca-inbox-poll.js.map +1 -0
- package/dist/scripts/judge-llm-batch.d.ts +98 -0
- package/dist/scripts/judge-llm-batch.d.ts.map +1 -0
- package/dist/scripts/judge-llm-batch.js +350 -0
- package/dist/scripts/judge-llm-batch.js.map +1 -0
- package/dist/scripts/llm-heal.d.ts +165 -0
- package/dist/scripts/llm-heal.d.ts.map +1 -0
- package/dist/scripts/llm-heal.js +595 -0
- package/dist/scripts/llm-heal.js.map +1 -0
- package/dist/scripts/migrate-telemetry-dir-names.d.ts +57 -0
- package/dist/scripts/migrate-telemetry-dir-names.d.ts.map +1 -0
- package/dist/scripts/migrate-telemetry-dir-names.js +156 -0
- package/dist/scripts/migrate-telemetry-dir-names.js.map +1 -0
- package/dist/scripts/probe-setinputfiles.d.ts +28 -0
- package/dist/scripts/probe-setinputfiles.d.ts.map +1 -0
- package/dist/scripts/probe-setinputfiles.js +95 -0
- package/dist/scripts/probe-setinputfiles.js.map +1 -0
- package/dist/scripts/recon-browser.d.ts +304 -0
- package/dist/scripts/recon-browser.d.ts.map +1 -0
- package/dist/scripts/recon-browser.js +1833 -0
- package/dist/scripts/recon-browser.js.map +1 -0
- package/dist/scripts/recon-generate.d.ts +182 -0
- package/dist/scripts/recon-generate.d.ts.map +1 -0
- package/dist/scripts/recon-generate.js +2572 -0
- package/dist/scripts/recon-generate.js.map +1 -0
- package/dist/scripts/recon-heal.d.ts +176 -0
- package/dist/scripts/recon-heal.d.ts.map +1 -0
- package/dist/scripts/recon-heal.js +584 -0
- package/dist/scripts/recon-heal.js.map +1 -0
- package/dist/scripts/recon-http.d.ts +19 -0
- package/dist/scripts/recon-http.d.ts.map +1 -0
- package/dist/scripts/recon-http.js +377 -0
- package/dist/scripts/recon-http.js.map +1 -0
- package/dist/scripts/recon-replay-jobs.d.ts +21 -0
- package/dist/scripts/recon-replay-jobs.d.ts.map +1 -0
- package/dist/scripts/recon-replay-jobs.js +221 -0
- package/dist/scripts/recon-replay-jobs.js.map +1 -0
- package/dist/scripts/recon-shared.d.ts +52 -0
- package/dist/scripts/recon-shared.d.ts.map +1 -0
- package/dist/scripts/recon-shared.js +68 -0
- package/dist/scripts/recon-shared.js.map +1 -0
- package/dist/scripts/recon-summarize.d.ts +15 -0
- package/dist/scripts/recon-summarize.d.ts.map +1 -0
- package/dist/scripts/recon-summarize.js +233 -0
- package/dist/scripts/recon-summarize.js.map +1 -0
- package/dist/scripts/smoke-test.d.ts +22 -0
- package/dist/scripts/smoke-test.d.ts.map +1 -0
- package/dist/scripts/smoke-test.js +236 -0
- package/dist/scripts/smoke-test.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +189 -0
- package/dist/server.js.map +1 -0
- package/dist/site-plugin.d.ts +226 -0
- package/dist/site-plugin.d.ts.map +1 -0
- package/dist/site-plugin.js +13 -0
- package/dist/site-plugin.js.map +1 -0
- package/dist/testing/answers-fixture.d.ts +13 -0
- package/dist/testing/answers-fixture.d.ts.map +1 -0
- package/dist/testing/answers-fixture.js +37 -0
- package/dist/testing/answers-fixture.js.map +1 -0
- package/dist/testing/batch-email-confirmation.d.ts +58 -0
- package/dist/testing/batch-email-confirmation.d.ts.map +1 -0
- package/dist/testing/batch-email-confirmation.js +62 -0
- package/dist/testing/batch-email-confirmation.js.map +1 -0
- package/dist/testing/batch-report.d.ts +33 -0
- package/dist/testing/batch-report.d.ts.map +1 -0
- package/dist/testing/batch-report.js +30 -0
- package/dist/testing/batch-report.js.map +1 -0
- package/dist/testing/contract-parity-suite.d.ts +55 -0
- package/dist/testing/contract-parity-suite.d.ts.map +1 -0
- package/dist/testing/contract-parity-suite.js +39 -0
- package/dist/testing/contract-parity-suite.js.map +1 -0
- package/dist/testing/coverage-guard-suite.d.ts +46 -0
- package/dist/testing/coverage-guard-suite.d.ts.map +1 -0
- package/dist/testing/coverage-guard-suite.js +39 -0
- package/dist/testing/coverage-guard-suite.js.map +1 -0
- package/dist/testing/fixtures/resume.pdf +54 -0
- package/dist/testing/integration-runner.d.ts +62 -0
- package/dist/testing/integration-runner.d.ts.map +1 -0
- package/dist/testing/integration-runner.js +46 -0
- package/dist/testing/integration-runner.js.map +1 -0
- package/dist/testing/mock-fetch-response.d.ts +7 -0
- package/dist/testing/mock-fetch-response.d.ts.map +1 -0
- package/dist/testing/mock-fetch-response.js +16 -0
- package/dist/testing/mock-fetch-response.js.map +1 -0
- package/dist/testing/persona-fixture.d.ts +77 -0
- package/dist/testing/persona-fixture.d.ts.map +1 -0
- package/dist/testing/persona-fixture.js +83 -0
- package/dist/testing/persona-fixture.js.map +1 -0
- package/dist/testing/replay-integration-suite.d.ts +50 -0
- package/dist/testing/replay-integration-suite.d.ts.map +1 -0
- package/dist/testing/replay-integration-suite.js +45 -0
- package/dist/testing/replay-integration-suite.js.map +1 -0
- package/dist/testing/resume-fixture.d.ts +39 -0
- package/dist/testing/resume-fixture.d.ts.map +1 -0
- package/dist/testing/resume-fixture.js +38 -0
- package/dist/testing/resume-fixture.js.map +1 -0
- package/dist/testmail/client.d.ts +61 -0
- package/dist/testmail/client.d.ts.map +1 -0
- package/dist/testmail/client.js +190 -0
- package/dist/testmail/client.js.map +1 -0
- package/dist/testmail/errors.d.ts +18 -0
- package/dist/testmail/errors.d.ts.map +1 -0
- package/dist/testmail/errors.js +29 -0
- package/dist/testmail/errors.js.map +1 -0
- package/dist/types/dispatch-metrics.d.ts +46 -0
- package/dist/types/dispatch-metrics.d.ts.map +1 -0
- package/dist/types/dispatch-metrics.js +25 -0
- package/dist/types/dispatch-metrics.js.map +1 -0
- package/dist/types/logging.d.ts +11 -0
- package/dist/types/logging.d.ts.map +1 -0
- package/dist/types/logging.js +3 -0
- package/dist/types/logging.js.map +1 -0
- package/package.json +283 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Canonical call_type string constants for all LLM call sites Barnacle owns
|
|
4
|
+
* directly. Referencing these avoids magic strings in call sites, tests, and
|
|
5
|
+
* the judge/self-heal skills (feat-004/005).
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CALL_TYPE_JUDGE_SELECT_OPTION = exports.CALL_TYPE_JUDGE_ERROR_MESSAGES = exports.CALL_TYPE_JUDGE_MODAL_PRIORITY = exports.CALL_TYPE_JUDGE_INVALID_FIELDS = exports.CALL_TYPE_JUDGE_SUBMIT_VERIFY = exports.CALL_TYPE_STAGEHAND_EXTRACT = exports.CALL_TYPE_STAGEHAND_OBSERVE = exports.CALL_TYPE_STAGEHAND_ACT = exports.CALL_TYPE_LLM_PROMPT_PATCH = exports.CALL_TYPE_RECON_FLOW_PATCH = exports.CALL_TYPE_RECON_REPLAN = exports.CALL_TYPE_RECON_REPHRASE = void 0;
|
|
9
|
+
/** Attempt-4 rephrase inside the recon-browser step-healing cascade. */
|
|
10
|
+
exports.CALL_TYPE_RECON_REPHRASE = "recon-rephrase";
|
|
11
|
+
/** Global replan after a step terminally fails in recon-browser. */
|
|
12
|
+
exports.CALL_TYPE_RECON_REPLAN = "recon-replan";
|
|
13
|
+
/** Patch proposal from the recon-flow-patch-generator (recon-heal). */
|
|
14
|
+
exports.CALL_TYPE_RECON_FLOW_PATCH = "recon-flow-patch";
|
|
15
|
+
/** Patch proposal from the llm-call-patch-generator (llm-heal). */
|
|
16
|
+
exports.CALL_TYPE_LLM_PROMPT_PATCH = "llm-prompt-patch";
|
|
17
|
+
/**
|
|
18
|
+
* Stagehand `act()` envelope-validation. Captured by the guardedAct wrapper
|
|
19
|
+
* so every Stagehand-driven LLM call lands in the same NDJSON sink as
|
|
20
|
+
* Barnacle's own Anthropic-SDK calls. Per the user directive that every
|
|
21
|
+
* LLM-touching surface enforces a schema, every act call is logged
|
|
22
|
+
* regardless of outcome — full parity with our other call-type telemetry.
|
|
23
|
+
*/
|
|
24
|
+
exports.CALL_TYPE_STAGEHAND_ACT = "stagehand-act";
|
|
25
|
+
/** Stagehand `observe()` envelope-validation. See CALL_TYPE_STAGEHAND_ACT. */
|
|
26
|
+
exports.CALL_TYPE_STAGEHAND_OBSERVE = "stagehand-observe";
|
|
27
|
+
/** Stagehand `extract()` schema-enforced call. See CALL_TYPE_STAGEHAND_ACT. */
|
|
28
|
+
exports.CALL_TYPE_STAGEHAND_EXTRACT = "stagehand-extract";
|
|
29
|
+
/**
|
|
30
|
+
* Haiku 4.5 judge for submit-success verification. Replaces the per-site
|
|
31
|
+
* regex (`submitEndpointPattern`) that mislabeled successful submits as
|
|
32
|
+
* failures whenever AppCast used a different POST URL than the regex
|
|
33
|
+
* expected. The judge receives evidence (recent network captures, page
|
|
34
|
+
* URL/title, unfocused observe, site criteria) and returns a discriminated
|
|
35
|
+
* verdict — verified=true requires multi-signal corroboration to prevent
|
|
36
|
+
* lax false positives.
|
|
37
|
+
*/
|
|
38
|
+
exports.CALL_TYPE_JUDGE_SUBMIT_VERIFY = "judge-submit-verify";
|
|
39
|
+
/**
|
|
40
|
+
* Haiku 4.5 judge for invalid-field detection. Replaces INVALID_CLASS_RX
|
|
41
|
+
* (limited to ng-invalid / mat-form-field-invalid / is-invalid class
|
|
42
|
+
* signatures) with structured detection covering aria-invalid attributes,
|
|
43
|
+
* data-invalid attributes, and arbitrary framework variants we haven't
|
|
44
|
+
* seen yet. Strict prompting: only mark a field present when there's a
|
|
45
|
+
* structural invalid marker, not just visual red-border styling.
|
|
46
|
+
*/
|
|
47
|
+
exports.CALL_TYPE_JUDGE_INVALID_FIELDS = "judge-invalid-fields";
|
|
48
|
+
/**
|
|
49
|
+
* Haiku 4.5 judge for modal-priority ranking of unfocused-observe
|
|
50
|
+
* candidates. Replaces MODAL_PRIORITY_RX (keyword regex over English
|
|
51
|
+
* descriptions). Surfaces modals/dialogs/overlays that BLOCK the form,
|
|
52
|
+
* skips always-visible panels and sidebars that don't.
|
|
53
|
+
*/
|
|
54
|
+
exports.CALL_TYPE_JUDGE_MODAL_PRIORITY = "judge-modal-priority";
|
|
55
|
+
/**
|
|
56
|
+
* Haiku 4.5 judge for visible-error-message extraction. Replaces
|
|
57
|
+
* errorPattern (class-name regex). Extracts structurally-marked error
|
|
58
|
+
* messages with field hints and severity, skipping placeholder/help text.
|
|
59
|
+
*/
|
|
60
|
+
exports.CALL_TYPE_JUDGE_ERROR_MESSAGES = "judge-error-messages";
|
|
61
|
+
/**
|
|
62
|
+
* Haiku 4.5 judge that picks the best AVAILABLE option for a required
|
|
63
|
+
* dropdown when the flow's hardcoded answer text doesn't exist in this
|
|
64
|
+
* requisition's option list (per-req screening-question variance). Used by
|
|
65
|
+
* `trySelectPrimitive`'s LLM fallback.
|
|
66
|
+
*/
|
|
67
|
+
exports.CALL_TYPE_JUDGE_SELECT_OPTION = "judge-select-option";
|
|
68
|
+
//# sourceMappingURL=call-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-types.js","sourceRoot":"","sources":["../../../src/lib/telemetry/call-types.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,wEAAwE;AAC3D,QAAA,wBAAwB,GAAG,gBAAgB,CAAC;AAEzD,oEAAoE;AACvD,QAAA,sBAAsB,GAAG,cAAc,CAAC;AAErD,uEAAuE;AAC1D,QAAA,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D,mEAAmE;AACtD,QAAA,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D;;;;;;GAMG;AACU,QAAA,uBAAuB,GAAG,eAAe,CAAC;AAEvD,8EAA8E;AACjE,QAAA,2BAA2B,GAAG,mBAAmB,CAAC;AAE/D,+EAA+E;AAClE,QAAA,2BAA2B,GAAG,mBAAmB,CAAC;AAE/D;;;;;;;;GAQG;AACU,QAAA,6BAA6B,GAAG,qBAAqB,CAAC;AAEnE;;;;;;;GAOG;AACU,QAAA,8BAA8B,GAAG,sBAAsB,CAAC;AAErE;;;;;GAKG;AACU,QAAA,8BAA8B,GAAG,sBAAsB,CAAC;AAErE;;;;GAIG;AACU,QAAA,8BAA8B,GAAG,sBAAsB,CAAC;AAErE;;;;;GAKG;AACU,QAAA,6BAA6B,GAAG,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface RunState {
|
|
2
|
+
/** Absolute path of the currently open .barnacle/events/*.ndjson file, or null when idle. */
|
|
3
|
+
currentRunFile: string | null;
|
|
4
|
+
/** Uncompressed byte count of the current run file, or 0 when idle. */
|
|
5
|
+
currentRunFileSizeBytes: number;
|
|
6
|
+
/** Number of orphaned NDJSON files recovered at last boot. */
|
|
7
|
+
orphansRecovered: number;
|
|
8
|
+
}
|
|
9
|
+
/** Exposes the current run state to health.ts without coupling it to the event-stream writer. */
|
|
10
|
+
export declare function getTelemetryState(): RunState;
|
|
11
|
+
/** Allows the event-stream subsystem (or tests) to update state without importing health.ts. */
|
|
12
|
+
export declare function setTelemetryState(partial: Partial<RunState>): void;
|
|
13
|
+
/** Restores initial defaults between test cases so state doesn't bleed across tests. */
|
|
14
|
+
export declare function resetTelemetryState(): void;
|
|
15
|
+
//# sourceMappingURL=run-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-state.d.ts","sourceRoot":"","sources":["../../../src/lib/telemetry/run-state.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,6FAA6F;IAC7F,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,uEAAuE;IACvE,uBAAuB,EAAE,MAAM,CAAC;IAChC,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAQD,iGAAiG;AACjG,wBAAgB,iBAAiB,IAAI,QAAQ,CAE5C;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAElE;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTelemetryState = getTelemetryState;
|
|
4
|
+
exports.setTelemetryState = setTelemetryState;
|
|
5
|
+
exports.resetTelemetryState = resetTelemetryState;
|
|
6
|
+
let state = {
|
|
7
|
+
currentRunFile: null,
|
|
8
|
+
currentRunFileSizeBytes: 0,
|
|
9
|
+
orphansRecovered: 0,
|
|
10
|
+
};
|
|
11
|
+
/** Exposes the current run state to health.ts without coupling it to the event-stream writer. */
|
|
12
|
+
function getTelemetryState() {
|
|
13
|
+
return { ...state };
|
|
14
|
+
}
|
|
15
|
+
/** Allows the event-stream subsystem (or tests) to update state without importing health.ts. */
|
|
16
|
+
function setTelemetryState(partial) {
|
|
17
|
+
state = { ...state, ...partial };
|
|
18
|
+
}
|
|
19
|
+
/** Restores initial defaults between test cases so state doesn't bleed across tests. */
|
|
20
|
+
function resetTelemetryState() {
|
|
21
|
+
state = { currentRunFile: null, currentRunFileSizeBytes: 0, orphansRecovered: 0 };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=run-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-state.js","sourceRoot":"","sources":["../../../src/lib/telemetry/run-state.ts"],"names":[],"mappings":";;AAgBA,8CAEC;AAGD,8CAEC;AAGD,kDAEC;AAnBD,IAAI,KAAK,GAAa;IACpB,cAAc,EAAE,IAAI;IACpB,uBAAuB,EAAE,CAAC;IAC1B,gBAAgB,EAAE,CAAC;CACpB,CAAC;AAEF,iGAAiG;AACjG,SAAgB,iBAAiB;IAC/B,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;AACtB,CAAC;AAED,gGAAgG;AAChG,SAAgB,iBAAiB,CAAC,OAA0B;IAC1D,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC;AACnC,CAAC;AAED,wFAAwF;AACxF,SAAgB,mBAAmB;IACjC,KAAK,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Buffered S3 sink that mirrors local NDJSON telemetry so it survives ECS
|
|
3
|
+
* container restarts. Opt-in: entirely inert (no S3Client construction, no
|
|
4
|
+
* network calls) when `config.telemetry.s3.bucket` is unset. Buffers lines
|
|
5
|
+
* in module-level arrays and flushes each non-empty buffer to a single S3
|
|
6
|
+
* object on an interval, early when a buffer crosses
|
|
7
|
+
* `config.telemetry.s3.maxBufferLines`, or at shutdown; a 5000-line hard
|
|
8
|
+
* cap per buffer drops the oldest lines to bound memory during sustained
|
|
9
|
+
* upload failures.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Buffers one NDJSON line from the LLM call-capture sink. No-op when no
|
|
13
|
+
* bucket is configured so callers can invoke this unconditionally.
|
|
14
|
+
*/
|
|
15
|
+
export declare function bufferCallLine(line: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Buffers one NDJSON line from the submission-capture sink. No-op when no
|
|
18
|
+
* bucket is configured so callers can invoke this unconditionally.
|
|
19
|
+
*/
|
|
20
|
+
export declare function bufferSubmissionLine(line: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Flushes both buffers to S3, one object per non-empty buffer. Concurrent
|
|
23
|
+
* calls coalesce onto a single in-flight upload — the promise is registered
|
|
24
|
+
* synchronously (before any await) so callers that race in during the same
|
|
25
|
+
* tick observe and await the same flush instead of double-uploading.
|
|
26
|
+
*
|
|
27
|
+
* Snapshot-and-swap: the live buffers are captured and reset to `[]`
|
|
28
|
+
* synchronously (safe under the single-threaded event loop) so lines
|
|
29
|
+
* pushed by callers during the upload land in a fresh buffer rather than
|
|
30
|
+
* being included in, or dropped from, the in-flight snapshot. On failure
|
|
31
|
+
* the snapshot is restored ahead of whatever accumulated during the
|
|
32
|
+
* upload, oldest-first, respecting the hard cap.
|
|
33
|
+
*/
|
|
34
|
+
export declare function flushTelemetryToS3(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Starts the periodic flush timer. `.unref()` so a pending timer never
|
|
37
|
+
* blocks process exit — matches the pool.ts timer pattern. No-op when no
|
|
38
|
+
* bucket is configured.
|
|
39
|
+
*/
|
|
40
|
+
export declare function startS3SinkTimer(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Stops the periodic timer and performs a final bounded-time flush. Called
|
|
43
|
+
* during graceful shutdown alongside shutdownStatsD/drainTrackingClicks.
|
|
44
|
+
*/
|
|
45
|
+
export declare function shutdownS3Sink(): Promise<void>;
|
|
46
|
+
/** Test-only helper: resets all module state to its initial values between test cases. */
|
|
47
|
+
export declare function resetS3Sink(): void;
|
|
48
|
+
//# sourceMappingURL=s3-sink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-sink.d.ts","sourceRoot":"","sources":["../../../src/lib/telemetry/s3-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAuDH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAIjD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAIvD;AA0CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAsBlD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CASvC;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAUpD;AAED,0FAA0F;AAC1F,wBAAgB,WAAW,IAAI,IAAI,CASlC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Buffered S3 sink that mirrors local NDJSON telemetry so it survives ECS
|
|
4
|
+
* container restarts. Opt-in: entirely inert (no S3Client construction, no
|
|
5
|
+
* network calls) when `config.telemetry.s3.bucket` is unset. Buffers lines
|
|
6
|
+
* in module-level arrays and flushes each non-empty buffer to a single S3
|
|
7
|
+
* object on an interval, early when a buffer crosses
|
|
8
|
+
* `config.telemetry.s3.maxBufferLines`, or at shutdown; a 5000-line hard
|
|
9
|
+
* cap per buffer drops the oldest lines to bound memory during sustained
|
|
10
|
+
* upload failures.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.bufferCallLine = bufferCallLine;
|
|
47
|
+
exports.bufferSubmissionLine = bufferSubmissionLine;
|
|
48
|
+
exports.flushTelemetryToS3 = flushTelemetryToS3;
|
|
49
|
+
exports.startS3SinkTimer = startS3SinkTimer;
|
|
50
|
+
exports.shutdownS3Sink = shutdownS3Sink;
|
|
51
|
+
exports.resetS3Sink = resetS3Sink;
|
|
52
|
+
const node_crypto_1 = require("node:crypto");
|
|
53
|
+
const os = __importStar(require("node:os"));
|
|
54
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
55
|
+
const date_fns_1 = require("date-fns");
|
|
56
|
+
const config_1 = require("../../config");
|
|
57
|
+
const errors_1 = require("../../lib/errors");
|
|
58
|
+
const logging_1 = require("../../lib/logging");
|
|
59
|
+
const logger = (0, logging_1.getLogger)({ name: "telemetry/s3-sink" });
|
|
60
|
+
const HARD_CAP_LINES = 5000;
|
|
61
|
+
const SHUTDOWN_FLUSH_TIMEOUT_MS = 20_000;
|
|
62
|
+
let client;
|
|
63
|
+
let callsBuffer = [];
|
|
64
|
+
let submissionsBuffer = [];
|
|
65
|
+
let timer;
|
|
66
|
+
let inFlightFlush;
|
|
67
|
+
/** Lazily constructs the S3 client. Never called on the bucket-unset path. */
|
|
68
|
+
function getClient() {
|
|
69
|
+
if (!client) {
|
|
70
|
+
client = new client_s3_1.S3Client({ region: config_1.config.bedrock.region });
|
|
71
|
+
}
|
|
72
|
+
return client;
|
|
73
|
+
}
|
|
74
|
+
/** Appends a line to `buffer`, dropping the oldest entries past the hard cap. */
|
|
75
|
+
function pushWithCap(buffer, line) {
|
|
76
|
+
buffer.push(line);
|
|
77
|
+
if (buffer.length > HARD_CAP_LINES) {
|
|
78
|
+
buffer.splice(0, buffer.length - HARD_CAP_LINES);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Prepends `lines` back onto `buffer` after a failed upload, respecting the hard cap. */
|
|
82
|
+
function restoreWithCap(buffer, lines) {
|
|
83
|
+
const merged = [...lines, ...buffer];
|
|
84
|
+
return merged.length > HARD_CAP_LINES ? merged.slice(merged.length - HARD_CAP_LINES) : merged;
|
|
85
|
+
}
|
|
86
|
+
/** Flushes in the background once `buffer` crosses the configured threshold. */
|
|
87
|
+
function maybeThresholdFlush(buffer) {
|
|
88
|
+
if (buffer.length < config_1.config.telemetry.s3.maxBufferLines)
|
|
89
|
+
return;
|
|
90
|
+
flushTelemetryToS3().catch((err) => {
|
|
91
|
+
logger.warn(`s3-sink: threshold flush failed: ${(0, errors_1.toErrorMessage)(err)}`);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Buffers one NDJSON line from the LLM call-capture sink. No-op when no
|
|
96
|
+
* bucket is configured so callers can invoke this unconditionally.
|
|
97
|
+
*/
|
|
98
|
+
function bufferCallLine(line) {
|
|
99
|
+
if (!config_1.config.telemetry.s3.bucket)
|
|
100
|
+
return;
|
|
101
|
+
pushWithCap(callsBuffer, line);
|
|
102
|
+
maybeThresholdFlush(callsBuffer);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Buffers one NDJSON line from the submission-capture sink. No-op when no
|
|
106
|
+
* bucket is configured so callers can invoke this unconditionally.
|
|
107
|
+
*/
|
|
108
|
+
function bufferSubmissionLine(line) {
|
|
109
|
+
if (!config_1.config.telemetry.s3.bucket)
|
|
110
|
+
return;
|
|
111
|
+
pushWithCap(submissionsBuffer, line);
|
|
112
|
+
maybeThresholdFlush(submissionsBuffer);
|
|
113
|
+
}
|
|
114
|
+
/** Builds the S3 object key for one uploaded batch, partitioned by day for lifecycle policies and manual browsing. */
|
|
115
|
+
function buildObjectKey(name, prefix) {
|
|
116
|
+
const datePartition = (0, date_fns_1.formatISO)(new Date(), { representation: "date" });
|
|
117
|
+
const hostname = os.hostname();
|
|
118
|
+
const epochMs = Date.now();
|
|
119
|
+
const shortUuid = (0, node_crypto_1.randomUUID)().slice(0, 8);
|
|
120
|
+
return `${prefix}/${name}/${datePartition}/${hostname}-${epochMs}-${shortUuid}.ndjson`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Uploads a single non-empty buffer snapshot as one NDJSON object. Returns
|
|
124
|
+
* the lines to restore to the live buffer: empty on success, the full
|
|
125
|
+
* snapshot on failure so the next flush retries them.
|
|
126
|
+
*/
|
|
127
|
+
async function flushOne(name, snapshot) {
|
|
128
|
+
if (snapshot.length === 0)
|
|
129
|
+
return [];
|
|
130
|
+
const bucket = config_1.config.telemetry.s3.bucket;
|
|
131
|
+
if (!bucket)
|
|
132
|
+
return [];
|
|
133
|
+
try {
|
|
134
|
+
const key = buildObjectKey(name, config_1.config.telemetry.s3.prefix);
|
|
135
|
+
await getClient().send(new client_s3_1.PutObjectCommand({
|
|
136
|
+
Bucket: bucket,
|
|
137
|
+
Key: key,
|
|
138
|
+
Body: snapshot.join(""),
|
|
139
|
+
ContentType: "application/x-ndjson",
|
|
140
|
+
}));
|
|
141
|
+
logger.info(`flushed ${snapshot.length} ${name} line(s) to s3://${bucket}/${key}`);
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
logger.warn(`s3-sink: flush of ${name} buffer failed, retaining for retry: ${(0, errors_1.toErrorMessage)(err)}`);
|
|
146
|
+
return snapshot;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Flushes both buffers to S3, one object per non-empty buffer. Concurrent
|
|
151
|
+
* calls coalesce onto a single in-flight upload — the promise is registered
|
|
152
|
+
* synchronously (before any await) so callers that race in during the same
|
|
153
|
+
* tick observe and await the same flush instead of double-uploading.
|
|
154
|
+
*
|
|
155
|
+
* Snapshot-and-swap: the live buffers are captured and reset to `[]`
|
|
156
|
+
* synchronously (safe under the single-threaded event loop) so lines
|
|
157
|
+
* pushed by callers during the upload land in a fresh buffer rather than
|
|
158
|
+
* being included in, or dropped from, the in-flight snapshot. On failure
|
|
159
|
+
* the snapshot is restored ahead of whatever accumulated during the
|
|
160
|
+
* upload, oldest-first, respecting the hard cap.
|
|
161
|
+
*/
|
|
162
|
+
function flushTelemetryToS3() {
|
|
163
|
+
if (!config_1.config.telemetry.s3.bucket)
|
|
164
|
+
return Promise.resolve();
|
|
165
|
+
if (inFlightFlush)
|
|
166
|
+
return inFlightFlush;
|
|
167
|
+
const callsSnapshot = callsBuffer;
|
|
168
|
+
const submissionsSnapshot = submissionsBuffer;
|
|
169
|
+
callsBuffer = [];
|
|
170
|
+
submissionsBuffer = [];
|
|
171
|
+
const promise = Promise.all([
|
|
172
|
+
flushOne("calls", callsSnapshot),
|
|
173
|
+
flushOne("submissions", submissionsSnapshot),
|
|
174
|
+
])
|
|
175
|
+
.then(([callsRemainder, submissionsRemainder]) => {
|
|
176
|
+
callsBuffer = restoreWithCap(callsBuffer, callsRemainder);
|
|
177
|
+
submissionsBuffer = restoreWithCap(submissionsBuffer, submissionsRemainder);
|
|
178
|
+
})
|
|
179
|
+
.finally(() => {
|
|
180
|
+
inFlightFlush = undefined;
|
|
181
|
+
});
|
|
182
|
+
inFlightFlush = promise;
|
|
183
|
+
return promise;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Starts the periodic flush timer. `.unref()` so a pending timer never
|
|
187
|
+
* blocks process exit — matches the pool.ts timer pattern. No-op when no
|
|
188
|
+
* bucket is configured.
|
|
189
|
+
*/
|
|
190
|
+
function startS3SinkTimer() {
|
|
191
|
+
if (!config_1.config.telemetry.s3.bucket)
|
|
192
|
+
return;
|
|
193
|
+
if (timer)
|
|
194
|
+
return;
|
|
195
|
+
timer = setInterval(() => {
|
|
196
|
+
flushTelemetryToS3().catch((err) => {
|
|
197
|
+
logger.warn(`s3-sink: periodic flush failed: ${(0, errors_1.toErrorMessage)(err)}`);
|
|
198
|
+
});
|
|
199
|
+
}, config_1.config.telemetry.s3.flushIntervalMs);
|
|
200
|
+
timer.unref();
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Stops the periodic timer and performs a final bounded-time flush. Called
|
|
204
|
+
* during graceful shutdown alongside shutdownStatsD/drainTrackingClicks.
|
|
205
|
+
*/
|
|
206
|
+
async function shutdownS3Sink() {
|
|
207
|
+
if (timer) {
|
|
208
|
+
clearInterval(timer);
|
|
209
|
+
timer = undefined;
|
|
210
|
+
}
|
|
211
|
+
if (!config_1.config.telemetry.s3.bucket)
|
|
212
|
+
return;
|
|
213
|
+
await Promise.race([
|
|
214
|
+
flushTelemetryToS3(),
|
|
215
|
+
new Promise((resolve) => setTimeout(resolve, SHUTDOWN_FLUSH_TIMEOUT_MS)),
|
|
216
|
+
]);
|
|
217
|
+
}
|
|
218
|
+
/** Test-only helper: resets all module state to its initial values between test cases. */
|
|
219
|
+
function resetS3Sink() {
|
|
220
|
+
if (timer) {
|
|
221
|
+
clearInterval(timer);
|
|
222
|
+
}
|
|
223
|
+
client = undefined;
|
|
224
|
+
callsBuffer = [];
|
|
225
|
+
submissionsBuffer = [];
|
|
226
|
+
timer = undefined;
|
|
227
|
+
inFlightFlush = undefined;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=s3-sink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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,cAAc;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,aAAa,CAAC,KAAK,CAAC,CAAC;QACrB,KAAK,GAAG,SAAS,CAAC;IACpB,CAAC;IACD,IAAI,CAAC,eAAM,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM;QAAE,OAAO;IACxC,MAAM,OAAO,CAAC,IAAI,CAAC;QACjB,kBAAkB,EAAE;QACpB,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;KAC/E,CAAC,CAAC;AACL,CAAC;AAED,0FAA0F;AAC1F,SAAgB,WAAW;IACzB,IAAI,KAAK,EAAE,CAAC;QACV,aAAa,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,MAAM,GAAG,SAAS,CAAC;IACnB,WAAW,GAAG,EAAE,CAAC;IACjB,iBAAiB,GAAG,EAAE,CAAC;IACvB,KAAK,GAAG,SAAS,CAAC;IAClB,aAAa,GAAG,SAAS,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Append-only NDJSON sink for dispatch submission envelopes. One line per
|
|
3
|
+
* plugin invocation captures the outcome — siteId, requestId, inbound payload,
|
|
4
|
+
* status, audit payload, error message, duration — so downstream tooling (ETL,
|
|
5
|
+
* jq, ad-hoc queries) can answer "what did we submit for jobId X on date Y,
|
|
6
|
+
* and did it succeed?" without a database.
|
|
7
|
+
*
|
|
8
|
+
* Kept on a separate sink from calls.ndjson because the judge and self-heal
|
|
9
|
+
* readers Zod-parse every calls.ndjson line as an LlmCallSample; mixing record
|
|
10
|
+
* shapes would force a discriminator + filter on every consumer.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod/v4";
|
|
13
|
+
/**
|
|
14
|
+
* Validated shape of one submission envelope sample. Carries the dispatch
|
|
15
|
+
* outcome (siteId, status, audit payload, error message, duration) plus the
|
|
16
|
+
* inbound request body and requestId needed to correlate with upstream traces.
|
|
17
|
+
*/
|
|
18
|
+
export declare const submissionEnvelopeSampleSchema: z.ZodObject<{
|
|
19
|
+
siteId: z.ZodString;
|
|
20
|
+
requestId: z.ZodString;
|
|
21
|
+
inboundPayload: z.ZodUnknown;
|
|
22
|
+
status: z.ZodEnum<{
|
|
23
|
+
error: "error";
|
|
24
|
+
submitted: "submitted";
|
|
25
|
+
}>;
|
|
26
|
+
auditPayload: z.ZodUnknown;
|
|
27
|
+
errorMessage: z.ZodNullable<z.ZodString>;
|
|
28
|
+
durationMs: z.ZodNumber;
|
|
29
|
+
ts: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type SubmissionEnvelopeSample = z.infer<typeof submissionEnvelopeSampleSchema>;
|
|
32
|
+
/** Input to `captureSubmissionEnvelope` — `ts` is derived internally so callers omit it. */
|
|
33
|
+
export type SubmissionEnvelopeInput = Omit<SubmissionEnvelopeSample, "ts">;
|
|
34
|
+
/** Options for `captureSubmissionEnvelope`. */
|
|
35
|
+
export interface CaptureSubmissionOptions {
|
|
36
|
+
/** Override the sink path; used in tests to avoid touching the real file. */
|
|
37
|
+
sinkPath?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Appends one validated NDJSON line for a dispatch outcome to the configured
|
|
41
|
+
* sink. Errors are logged and swallowed — telemetry must never break the
|
|
42
|
+
* happy path, matching the contract `captureLlmCall` enforces for LLM samples.
|
|
43
|
+
*/
|
|
44
|
+
export declare function captureSubmissionEnvelope(input: SubmissionEnvelopeInput, opts?: CaptureSubmissionOptions): Promise<void>;
|
|
45
|
+
//# sourceMappingURL=submission-capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submission-capture.d.ts","sourceRoot":"","sources":["../../../src/lib/telemetry/submission-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAQ3B;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;iBASzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,4FAA4F;AAC5F,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;AAE3E,+CAA+C;AAC/C,MAAM,WAAW,wBAAwB;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,uBAAuB,EAC9B,IAAI,GAAE,wBAA6B,GAClC,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Append-only NDJSON sink for dispatch submission envelopes. One line per
|
|
4
|
+
* plugin invocation captures the outcome — siteId, requestId, inbound payload,
|
|
5
|
+
* status, audit payload, error message, duration — so downstream tooling (ETL,
|
|
6
|
+
* jq, ad-hoc queries) can answer "what did we submit for jobId X on date Y,
|
|
7
|
+
* and did it succeed?" without a database.
|
|
8
|
+
*
|
|
9
|
+
* Kept on a separate sink from calls.ndjson because the judge and self-heal
|
|
10
|
+
* readers Zod-parse every calls.ndjson line as an LlmCallSample; mixing record
|
|
11
|
+
* shapes would force a discriminator + filter on every consumer.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.submissionEnvelopeSampleSchema = void 0;
|
|
15
|
+
exports.captureSubmissionEnvelope = captureSubmissionEnvelope;
|
|
16
|
+
const promises_1 = require("node:fs/promises");
|
|
17
|
+
const node_path_1 = require("node:path");
|
|
18
|
+
const date_fns_1 = require("date-fns");
|
|
19
|
+
const v4_1 = require("zod/v4");
|
|
20
|
+
const config_1 = require("../../config");
|
|
21
|
+
const logging_1 = require("../../lib/logging");
|
|
22
|
+
const s3_sink_1 = require("../../lib/telemetry/s3-sink");
|
|
23
|
+
const logger = (0, logging_1.getLogger)({ name: "telemetry/submission-capture" });
|
|
24
|
+
/**
|
|
25
|
+
* Validated shape of one submission envelope sample. Carries the dispatch
|
|
26
|
+
* outcome (siteId, status, audit payload, error message, duration) plus the
|
|
27
|
+
* inbound request body and requestId needed to correlate with upstream traces.
|
|
28
|
+
*/
|
|
29
|
+
exports.submissionEnvelopeSampleSchema = v4_1.z.object({
|
|
30
|
+
siteId: v4_1.z.string(),
|
|
31
|
+
requestId: v4_1.z.string(),
|
|
32
|
+
inboundPayload: v4_1.z.unknown(),
|
|
33
|
+
status: v4_1.z.enum(["submitted", "error"]),
|
|
34
|
+
auditPayload: v4_1.z.unknown(),
|
|
35
|
+
errorMessage: v4_1.z.string().nullable(),
|
|
36
|
+
durationMs: v4_1.z.number(),
|
|
37
|
+
ts: v4_1.z.string(),
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Appends one validated NDJSON line for a dispatch outcome to the configured
|
|
41
|
+
* sink. Errors are logged and swallowed — telemetry must never break the
|
|
42
|
+
* happy path, matching the contract `captureLlmCall` enforces for LLM samples.
|
|
43
|
+
*/
|
|
44
|
+
async function captureSubmissionEnvelope(input, opts = {}) {
|
|
45
|
+
const sinkPath = opts.sinkPath ?? config_1.config.telemetry.submissionsNdjsonPath;
|
|
46
|
+
const sample = { ...input, ts: (0, date_fns_1.formatISO)(new Date()) };
|
|
47
|
+
try {
|
|
48
|
+
const line = `${JSON.stringify(sample)}\n`;
|
|
49
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(sinkPath), { recursive: true });
|
|
50
|
+
await (0, promises_1.appendFile)(sinkPath, line, "utf8");
|
|
51
|
+
(0, s3_sink_1.bufferSubmissionLine)(line);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
logger.error(`captureSubmissionEnvelope: failed to write to ${sinkPath}: ${String(err)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=submission-capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submission-capture.js","sourceRoot":"","sources":["../../../src/lib/telemetry/submission-capture.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AA8CH,8DAeC;AA3DD,+CAAqD;AACrD,yCAAoC;AAEpC,uCAAqC;AACrC,+BAA2B;AAE3B,qCAAkC;AAClC,2CAA0C;AAC1C,qDAA+D;AAE/D,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE,CAAC,CAAC;AAEnE;;;;GAIG;AACU,QAAA,8BAA8B,GAAG,MAAC,CAAC,MAAM,CAAC;IACrD,MAAM,EAAE,MAAC,CAAC,MAAM,EAAE;IAClB,SAAS,EAAE,MAAC,CAAC,MAAM,EAAE;IACrB,cAAc,EAAE,MAAC,CAAC,OAAO,EAAE;IAC3B,MAAM,EAAE,MAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACtC,YAAY,EAAE,MAAC,CAAC,OAAO,EAAE;IACzB,YAAY,EAAE,MAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,UAAU,EAAE,MAAC,CAAC,MAAM,EAAE;IACtB,EAAE,EAAE,MAAC,CAAC,MAAM,EAAE;CACf,CAAC,CAAC;AAaH;;;;GAIG;AACI,KAAK,UAAU,yBAAyB,CAC7C,KAA8B,EAC9B,OAAiC,EAAE;IAEnC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,eAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC;IACzE,MAAM,MAAM,GAA6B,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,IAAA,oBAAS,EAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;IAEjF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;QAC3C,MAAM,IAAA,gBAAK,EAAC,IAAA,mBAAO,EAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,MAAM,IAAA,qBAAU,EAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACzC,IAAA,8BAAoB,EAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,iDAAiD,QAAQ,KAAK,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path helpers for per-site, per-URL telemetry partitioning. Lets each site's
|
|
3
|
+
* recon flow accumulate its LLM call corpus next to the flow file itself
|
|
4
|
+
* (durable as part of the site definition) rather than into a single global
|
|
5
|
+
* sink. The per-URL directory name keeps one URL's history isolated from
|
|
6
|
+
* another's, so cross-run pattern analysis on a specific target stays clean.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Canonicalize a URL so trivially-different forms of the same target
|
|
10
|
+
* (query-param reorderings, trailing slashes, scheme case) collapse to the
|
|
11
|
+
* same identity. Query parameters are dropped entirely because the sites in
|
|
12
|
+
* the current corpus identify targets by path, not by query state.
|
|
13
|
+
*/
|
|
14
|
+
export declare function canonicalizeUrl(rawUrl: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Filesystem-safe directory name for a URL using the form
|
|
17
|
+
* `<unix-ms-timestamp>-<short-hash>`. The timestamp makes `ls runs/` sort
|
|
18
|
+
* chronologically by default. The hash (first 8 hex chars of SHA-1 over
|
|
19
|
+
* the canonical URL) gives URL-deterministic identity, so multiple runs of
|
|
20
|
+
* the same target can be grouped with `awk -F- '{print $NF}' | sort | uniq -c`
|
|
21
|
+
* without consulting any sidecar.
|
|
22
|
+
*
|
|
23
|
+
* Why a caller-supplied timestamp instead of `Date.now()` inline: two
|
|
24
|
+
* helpers below (`resolveRunCallsPath`, `resolveRunUrlPath`) need to agree
|
|
25
|
+
* on the same directory within a single run, so the caller captures
|
|
26
|
+
* `Date.now()` once at run-start and threads it through both calls. Same
|
|
27
|
+
* `(timestampMs, rawUrl)` always yields the same dirName — deterministic.
|
|
28
|
+
*
|
|
29
|
+
* The `url.txt` sidecar continues to carry the authoritative URL; the hash
|
|
30
|
+
* is not reversed in any current consumer.
|
|
31
|
+
*/
|
|
32
|
+
export declare function urlDirName(timestampMs: number, rawUrl: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the per-site telemetry directory from the flow file path. Returns
|
|
35
|
+
* null when no flow file was supplied (inline --flow mode, where there's no
|
|
36
|
+
* durable home for the data) so the caller can short-circuit to a no-op sink.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveSiteTelemetryDir(flowFile: string | null): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Per-URL `calls.ndjson` sink path within a site telemetry directory.
|
|
41
|
+
* `timestampMs` is the run-start timestamp captured once by the caller so
|
|
42
|
+
* sibling calls (`resolveRunUrlPath`) land in the same directory.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveRunCallsPath(siteTelemetryDir: string, timestampMs: number, rawUrl: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Per-URL `url.txt` companion path. The directory name is `<ts>-<hash>`;
|
|
47
|
+
* the sidecar carries the original URL so any engineer browsing the
|
|
48
|
+
* telemetry tree sees the URL without needing to recover it from the hash.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveRunUrlPath(siteTelemetryDir: string, timestampMs: number, rawUrl: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Concatenate every `runs/<urlDirName>/calls.ndjson` under the site telemetry
|
|
53
|
+
* directory into a single NDJSON string. Used when a consumer needs the
|
|
54
|
+
* site's full call history (cross-URL pattern analysis) rather than a single
|
|
55
|
+
* URL's slice. Returns empty string when the directory doesn't exist yet —
|
|
56
|
+
* the caller treats that the same as "no telemetry recorded."
|
|
57
|
+
*/
|
|
58
|
+
export declare function readSiteCallsNdjson(siteTelemetryDir: string): string;
|
|
59
|
+
//# sourceMappingURL=telemetry-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-paths.d.ts","sourceRoot":"","sources":["../../../src/lib/telemetry/telemetry-paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAItE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAG9E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CASpE"}
|