stitchkit 0.93.0 → 0.94.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 +198 -0
- package/README.md +5 -2
- package/dist/agent-runtime/children-control.d.ts +6 -0
- package/dist/agent-runtime/children-control.d.ts.map +1 -0
- package/dist/agent-runtime/children-spawn.d.ts +6 -0
- package/dist/agent-runtime/children-spawn.d.ts.map +1 -0
- package/dist/agent-runtime/children-state.d.ts +46 -0
- package/dist/agent-runtime/children-state.d.ts.map +1 -0
- package/dist/agent-runtime/children-usage.d.ts +8 -0
- package/dist/agent-runtime/children-usage.d.ts.map +1 -0
- package/dist/agent-runtime/children.d.ts +11 -14
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +2 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/contained-darwin.d.ts +38 -0
- package/dist/agent-runtime/contained-darwin.d.ts.map +1 -0
- package/dist/agent-runtime/contained-files.d.ts +11 -26
- package/dist/agent-runtime/contained-files.d.ts.map +1 -1
- package/dist/agent-runtime/contained-scan.d.ts +21 -0
- package/dist/agent-runtime/contained-scan.d.ts.map +1 -0
- package/dist/agent-runtime/contained-write.d.ts +9 -0
- package/dist/agent-runtime/contained-write.d.ts.map +1 -0
- package/dist/agent-runtime/deferred-tool-types.d.ts +4 -3
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/events.d.ts +1 -1
- package/dist/agent-runtime/events.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts +0 -1
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +0 -5
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +3 -2
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +1 -1
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter.d.ts +29 -0
- package/dist/agent-runtime/openrouter.d.ts.map +1 -0
- package/dist/agent-runtime/projections.d.ts +1 -1
- package/dist/agent-runtime/projections.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts +17 -0
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution-state.d.ts +133 -0
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution.d.ts +17 -33
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts +18 -0
- package/dist/agent-runtime/run-failure.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-attempts.d.ts +6 -0
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -0
- package/dist/agent-runtime/run-prompt-history.d.ts +58 -0
- package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts +26 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-parts.d.ts +17 -0
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -0
- package/dist/agent-runtime/run-terminal.d.ts +11 -0
- package/dist/agent-runtime/run-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts +22 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-admission-gate.d.ts +29 -0
- package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-control.d.ts +9 -0
- package/dist/agent-runtime/runtime-control.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-recovery.d.ts +10 -0
- package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-state.d.ts +36 -0
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-submit.d.ts +5 -0
- package/dist/agent-runtime/runtime-submit.d.ts.map +1 -0
- package/dist/agent-runtime/runtime.d.ts +10 -5
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +34 -0
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -0
- package/dist/agent-runtime/schedules.d.ts +34 -0
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-bun.d.ts +12 -0
- package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-events.d.ts +5 -0
- package/dist/agent-runtime/sqlite-events.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-history.d.ts +7 -0
- package/dist/agent-runtime/sqlite-history.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-ledger.d.ts +7 -0
- package/dist/agent-runtime/sqlite-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-node.d.ts +12 -0
- package/dist/agent-runtime/sqlite-node.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-reads.d.ts +14 -0
- package/dist/agent-runtime/sqlite-reads.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-rows.d.ts +178 -0
- package/dist/agent-runtime/sqlite-rows.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-schema.d.ts +7 -0
- package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-transactions.d.ts +25 -0
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite.d.ts +10 -6
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts +16 -0
- package/dist/agent-runtime/store-archive.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +434 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts +18 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-support.d.ts +130 -0
- package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts +12 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance.d.ts +40 -0
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -0
- package/dist/agent-runtime/store-create.d.ts +11 -0
- package/dist/agent-runtime/store-create.d.ts.map +1 -0
- package/dist/agent-runtime/store-driver-contract.d.ts +814 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -0
- package/dist/agent-runtime/store-events.d.ts +7 -89
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory.d.ts +4 -0
- package/dist/agent-runtime/store-memory.d.ts.map +1 -0
- package/dist/agent-runtime/store-mutate.d.ts +13 -0
- package/dist/agent-runtime/store-mutate.d.ts.map +1 -0
- package/dist/agent-runtime/store-purge.d.ts +1 -1
- package/dist/agent-runtime/store-purge.d.ts.map +1 -1
- package/dist/agent-runtime/store-reads.d.ts +29 -0
- package/dist/agent-runtime/store-reads.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-history.d.ts +10 -0
- package/dist/agent-runtime/store-reduce-history.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-run.d.ts +14 -0
- package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts +76 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-terminal.d.ts +6 -0
- package/dist/agent-runtime/store-reduce-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/store-reducer.d.ts +24 -0
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -0
- package/dist/agent-runtime/store-snapshot.d.ts +19 -0
- package/dist/agent-runtime/store-snapshot.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +1 -1
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/application/admission-rate.d.ts +21 -0
- package/dist/application/admission-rate.d.ts.map +1 -0
- package/dist/application/admission-run.d.ts +8 -0
- package/dist/application/admission-run.d.ts.map +1 -0
- package/dist/application/admission.d.ts +1 -1
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock.d.ts +9 -34
- package/dist/application/diagnostic-journal-lock.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/events.d.ts +1 -1
- package/dist/application/events.d.ts.map +1 -1
- package/dist/application/file-state-store.d.ts +23 -0
- package/dist/application/file-state-store.d.ts.map +1 -0
- package/dist/application/health.d.ts +1 -1
- package/dist/application/health.d.ts.map +1 -1
- package/dist/application/kernel-admission.d.ts +8 -0
- package/dist/application/kernel-admission.d.ts.map +1 -0
- package/dist/application/kernel-contract.d.ts +142 -0
- package/dist/application/kernel-contract.d.ts.map +1 -0
- package/dist/application/kernel-resource-context.d.ts +24 -0
- package/dist/application/kernel-resource-context.d.ts.map +1 -0
- package/dist/application/kernel-restart.d.ts +5 -0
- package/dist/application/kernel-restart.d.ts.map +1 -0
- package/dist/application/kernel-rollback.d.ts +4 -0
- package/dist/application/kernel-rollback.d.ts.map +1 -0
- package/dist/application/kernel-shutdown.d.ts +6 -0
- package/dist/application/kernel-shutdown.d.ts.map +1 -0
- package/dist/application/kernel-start.d.ts +20 -0
- package/dist/application/kernel-start.d.ts.map +1 -0
- package/dist/application/kernel-state.d.ts +116 -0
- package/dist/application/kernel-state.d.ts.map +1 -0
- package/dist/application/kernel.d.ts +9 -140
- package/dist/application/kernel.d.ts.map +1 -1
- package/dist/application/latest-sink.d.ts +1 -1
- package/dist/application/latest-sink.d.ts.map +1 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/opentelemetry.d.ts +1 -1
- package/dist/application/opentelemetry.d.ts.map +1 -1
- package/dist/application/schedule.d.ts +0 -1
- package/dist/application/schedule.d.ts.map +1 -1
- package/dist/application/watch-hub-core.d.ts +122 -0
- package/dist/application/watch-hub-core.d.ts.map +1 -0
- package/dist/application/watch-hub.d.ts +3 -3
- package/dist/application/watch-hub.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts +14 -0
- package/dist/browser/client-executors.d.ts.map +1 -0
- package/dist/browser/client-multipart.d.ts +1 -1
- package/dist/browser/client-multipart.d.ts.map +1 -1
- package/dist/browser/client-url.d.ts +1 -1
- package/dist/browser/client-url.d.ts.map +1 -1
- package/dist/browser/client.d.ts +3 -2
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/contract-stream.d.ts +1 -1
- package/dist/browser/contract-stream.d.ts.map +1 -1
- package/dist/browser/http-fetch.d.ts +22 -0
- package/dist/browser/http-fetch.d.ts.map +1 -0
- package/dist/browser/http.d.ts +2 -4
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/live-state-core.d.ts +63 -0
- package/dist/browser/live-state-core.d.ts.map +1 -0
- package/dist/browser/live-state.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +26 -0
- package/dist/browser/realtime-client.d.ts.map +1 -0
- package/dist/browser/resumable.d.ts +1 -28
- package/dist/browser/resumable.d.ts.map +1 -1
- package/dist/browser/retained.d.ts.map +1 -0
- package/dist/browser/socket-io-connection.d.ts +82 -0
- package/dist/browser/socket-io-connection.d.ts.map +1 -0
- package/dist/browser/socket-io-peer.d.ts +20 -0
- package/dist/browser/socket-io-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-trace.d.ts +31 -0
- package/dist/browser/socket-io-trace.d.ts.map +1 -0
- package/dist/browser/socket-io.d.ts +24 -18
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +14 -2
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +134 -0
- package/dist/contract/client-types.d.ts.map +1 -0
- package/dist/contract/define-validation.d.ts +30 -0
- package/dist/contract/define-validation.d.ts.map +1 -0
- package/dist/contract/define.d.ts +47 -394
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +56 -0
- package/dist/contract/normalize.d.ts.map +1 -0
- package/dist/contract/runtime-context.d.ts +131 -0
- package/dist/contract/runtime-context.d.ts.map +1 -0
- package/dist/contract/tool-options.d.ts +105 -0
- package/dist/contract/tool-options.d.ts.map +1 -0
- package/dist/contract/tool-view.d.ts +148 -0
- package/dist/contract/tool-view.d.ts.map +1 -0
- package/dist/declaration/declaration.d.ts.map +1 -0
- package/dist/durability/contract.d.ts +259 -0
- package/dist/durability/contract.d.ts.map +1 -0
- package/dist/durability/effect.d.ts +24 -0
- package/dist/durability/effect.d.ts.map +1 -0
- package/dist/durability/engine.d.ts +14 -0
- package/dist/durability/engine.d.ts.map +1 -0
- package/dist/durability/events.d.ts +103 -0
- package/dist/durability/events.d.ts.map +1 -0
- package/dist/durability/json.d.ts +3 -0
- package/dist/durability/json.d.ts.map +1 -0
- package/dist/durability/ledger.d.ts +27 -0
- package/dist/durability/ledger.d.ts.map +1 -0
- package/dist/durability/parks.d.ts +22 -0
- package/dist/durability/parks.d.ts.map +1 -0
- package/dist/durability/scheduler.d.ts +30 -0
- package/dist/durability/scheduler.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +5 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/browser.js +124 -0
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/coding-tools.js +22 -0
- package/dist/entrypoints/agent-runtime/harness.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/harness.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/harness.js +739 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/openrouter.js +270 -0
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +5 -0
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/sandbox.js +797 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +44 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.js +46 -0
- package/dist/entrypoints/agent-runtime/testing.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/testing.js +1116 -0
- package/dist/entrypoints/agent-runtime.d.ts +42 -0
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime.js +2670 -0
- package/dist/entrypoints/application/diagnostic-journal.d.ts +21 -0
- package/dist/entrypoints/application/diagnostic-journal.d.ts.map +1 -0
- package/dist/entrypoints/application/diagnostic-journal.js +492 -0
- package/dist/entrypoints/application/grammy.d.ts +2 -0
- package/dist/entrypoints/application/grammy.d.ts.map +1 -0
- package/dist/entrypoints/application/grammy.js +169 -0
- package/dist/entrypoints/application/opentelemetry.d.ts +2 -0
- package/dist/entrypoints/application/opentelemetry.d.ts.map +1 -0
- package/dist/entrypoints/application/opentelemetry.js +250 -0
- package/dist/entrypoints/application/schemas.d.ts +15 -0
- package/dist/entrypoints/application/schemas.d.ts.map +1 -0
- package/dist/entrypoints/application/schemas.js +27 -0
- package/dist/entrypoints/application.d.ts +23 -0
- package/dist/entrypoints/application.d.ts.map +1 -0
- package/dist/entrypoints/application.js +2016 -0
- package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -0
- package/dist/entrypoints/bin/upgrade-cli.js +177 -0
- package/dist/entrypoints/cli.d.ts +44 -0
- package/dist/entrypoints/cli.d.ts.map +1 -0
- package/dist/entrypoints/cli.js +773 -0
- package/dist/entrypoints/contract.d.ts +12 -0
- package/dist/entrypoints/contract.d.ts.map +1 -0
- package/dist/entrypoints/contract.js +64 -0
- package/dist/entrypoints/declaration.d.ts +2 -0
- package/dist/entrypoints/declaration.d.ts.map +1 -0
- package/dist/entrypoints/declaration.js +183 -0
- package/dist/entrypoints/files.d.ts +5 -0
- package/dist/entrypoints/files.d.ts.map +1 -0
- package/dist/entrypoints/files.js +111 -0
- package/dist/entrypoints/geo.d.ts +3 -0
- package/dist/entrypoints/geo.d.ts.map +1 -0
- package/dist/entrypoints/geo.js +245 -0
- package/dist/entrypoints/google.d.ts +2 -0
- package/dist/entrypoints/google.d.ts.map +1 -0
- package/dist/entrypoints/google.js +175 -0
- package/dist/entrypoints/index.d.ts +17 -0
- package/dist/entrypoints/index.d.ts.map +1 -0
- package/dist/entrypoints/index.js +764 -0
- package/dist/entrypoints/live.d.ts +19 -0
- package/dist/entrypoints/live.d.ts.map +1 -0
- package/dist/entrypoints/live.js +302 -0
- package/dist/entrypoints/node.d.ts +19 -0
- package/dist/entrypoints/node.d.ts.map +1 -0
- package/dist/entrypoints/node.js +308 -0
- package/dist/entrypoints/oauth.d.ts +2 -0
- package/dist/entrypoints/oauth.d.ts.map +1 -0
- package/dist/entrypoints/oauth.js +170 -0
- package/dist/entrypoints/observability.d.ts +19 -0
- package/dist/entrypoints/observability.d.ts.map +1 -0
- package/dist/entrypoints/observability.js +567 -0
- package/dist/entrypoints/primitives.d.ts +3 -0
- package/dist/entrypoints/primitives.d.ts.map +1 -0
- package/dist/entrypoints/primitives.js +749 -0
- package/dist/entrypoints/react.d.ts +5 -0
- package/dist/entrypoints/react.d.ts.map +1 -0
- package/dist/entrypoints/react.js +403 -0
- package/dist/entrypoints/release.d.ts +15 -0
- package/dist/entrypoints/release.d.ts.map +1 -0
- package/dist/entrypoints/release.js +196 -0
- package/dist/entrypoints/remote.d.ts +9 -0
- package/dist/entrypoints/remote.d.ts.map +1 -0
- package/dist/entrypoints/remote.js +66 -0
- package/dist/entrypoints/server.d.ts +39 -0
- package/dist/entrypoints/server.d.ts.map +1 -0
- package/dist/entrypoints/server.js +2009 -0
- package/dist/entrypoints/telegram.d.ts +3 -0
- package/dist/entrypoints/telegram.d.ts.map +1 -0
- package/dist/entrypoints/telegram.js +224 -0
- package/dist/entrypoints/testing.d.ts +10 -0
- package/dist/entrypoints/testing.d.ts.map +1 -0
- package/dist/entrypoints/testing.js +1377 -0
- package/dist/entrypoints/tools/connections.d.ts +19 -0
- package/dist/entrypoints/tools/connections.d.ts.map +1 -0
- package/dist/entrypoints/tools/connections.js +1110 -0
- package/dist/entrypoints/tools/contract.d.ts +29 -0
- package/dist/entrypoints/tools/contract.d.ts.map +1 -0
- package/dist/entrypoints/tools/contract.js +24 -0
- package/dist/entrypoints/tools/invoker.d.ts +9 -0
- package/dist/entrypoints/tools/invoker.d.ts.map +1 -0
- package/dist/entrypoints/tools/invoker.js +20 -0
- package/dist/entrypoints/tools.d.ts +54 -0
- package/dist/entrypoints/tools.d.ts.map +1 -0
- package/dist/entrypoints/tools.js +3009 -0
- package/dist/entrypoints/tracking/server.d.ts +15 -0
- package/dist/entrypoints/tracking/server.d.ts.map +1 -0
- package/dist/entrypoints/tracking.d.ts +24 -0
- package/dist/entrypoints/tracking.d.ts.map +1 -0
- package/dist/entrypoints/tracking.js +1140 -0
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/file-io.d.ts +14 -0
- package/dist/files/file-io.d.ts.map +1 -0
- package/dist/google/google.d.ts.map +1 -0
- package/dist/index-0b1ess5e.js +38 -0
- package/dist/index-1j8pm5t0.js +412 -0
- package/dist/index-1zbbzgfh.js +89 -0
- package/dist/index-2bxbyab0.js +47 -0
- package/dist/index-2gxzjvyr.js +266 -0
- package/dist/index-35mh5bhj.js +177 -0
- package/dist/index-48ffdxgk.js +6 -0
- package/dist/index-4gcnakhx.js +82 -0
- package/dist/index-55hkhm67.js +343 -0
- package/dist/index-79z7m7dt.js +675 -0
- package/dist/index-7f68ghdn.js +3618 -0
- package/dist/index-7p1f0vp2.js +154 -0
- package/dist/index-83bdg97s.js +16 -0
- package/dist/index-863ea9jb.js +154 -0
- package/dist/index-8p52kd5p.js +242 -0
- package/dist/index-d9pk3td4.js +326 -0
- package/dist/index-dce5wxcq.js +63 -0
- package/dist/index-e01r054k.js +105 -0
- package/dist/index-ensd0r74.js +595 -0
- package/dist/index-eqqvgdb3.js +46 -0
- package/dist/index-gxrt5h6v.js +341 -0
- package/dist/index-h6eeys1v.js +211 -0
- package/dist/index-ham5sz8m.js +734 -0
- package/dist/index-het2he5g.js +1387 -0
- package/dist/index-hffjpmq9.js +30 -0
- package/dist/index-hmp4800j.js +51 -0
- package/dist/index-k30h66yd.js +317 -0
- package/dist/index-k5hsfc3j.js +31 -0
- package/dist/index-khtgb21r.js +92 -0
- package/dist/index-m9zn6cpq.js +51 -0
- package/dist/index-ndddxtyx.js +324 -0
- package/dist/index-ngfhvfpd.js +30 -0
- package/dist/index-np4m8hd3.js +1205 -0
- package/dist/index-p3vsv1fb.js +3493 -0
- package/dist/index-p5r7qpdd.js +85 -0
- package/dist/index-p9e0w8hs.js +1084 -0
- package/dist/index-p9sh0xx4.js +64 -0
- package/dist/index-paz6sgdp.js +371 -0
- package/dist/index-px2gm2jp.js +448 -0
- package/dist/index-qwhynv6x.js +103 -0
- package/dist/index-s812ycat.js +65 -0
- package/dist/index-sp1tzwnb.js +281 -0
- package/dist/index-t9rhjr9f.js +2306 -0
- package/dist/index-v260df89.js +342 -0
- package/dist/index-w906953s.js +946 -0
- package/dist/index-wdkt63w3.js +214 -0
- package/dist/index-wqgjfstn.js +18 -0
- package/dist/index-wsm5w4ee.js +1023 -0
- package/dist/index-xw3s75nj.js +100 -0
- package/dist/index-yw4fzmdz.js +268 -0
- package/dist/index-zfrhfn82.js +85 -0
- package/dist/index-znfs20ss.js +98 -0
- package/dist/internal/atomic-file.d.ts +23 -2
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/backoff.d.ts +29 -0
- package/dist/internal/backoff.d.ts.map +1 -0
- package/dist/internal/canonical-json.d.ts +21 -11
- package/dist/internal/canonical-json.d.ts.map +1 -1
- package/dist/internal/channel.d.ts.map +1 -0
- package/dist/internal/exclusive-lock.d.ts +51 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -0
- package/dist/internal/logger.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +47 -0
- package/dist/internal/process-identity.d.ts.map +1 -0
- package/dist/internal/request.d.ts.map +1 -0
- package/dist/internal/stable-digest.d.ts +0 -43
- package/dist/internal/stable-digest.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +0 -8
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/internal/with-exclusive-lock.d.ts +67 -0
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -0
- package/dist/internal/zod-issues.d.ts +38 -0
- package/dist/internal/zod-issues.d.ts.map +1 -0
- package/dist/json-schema/dialect.d.ts +17 -0
- package/dist/json-schema/dialect.d.ts.map +1 -0
- package/dist/json-schema/json-schema.d.ts.map +1 -0
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/live/watch-delta.d.ts.map +1 -1
- package/dist/oauth/authorization-code.d.ts +57 -0
- package/dist/oauth/authorization-code.d.ts.map +1 -0
- package/dist/observability/audit.d.ts +3 -3
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/bounded-logger.d.ts +1 -1
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/observability/bounded-sink.d.ts +81 -0
- package/dist/observability/bounded-sink.d.ts.map +1 -0
- package/dist/observability/context.d.ts +1 -1
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event.d.ts +2 -1
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/observability/work.d.ts +1 -1
- package/dist/observability/work.d.ts.map +1 -1
- package/dist/primitives/audit.d.ts +1 -1
- package/dist/primitives/audit.d.ts.map +1 -1
- package/dist/primitives/export-operation.d.ts +4 -2
- package/dist/primitives/export-operation.d.ts.map +1 -1
- package/dist/realtime/registry.d.ts +0 -5
- package/dist/realtime/registry.d.ts.map +1 -1
- package/dist/realtime/socket.d.ts +1 -1
- package/dist/realtime/socket.d.ts.map +1 -1
- package/dist/server/bun.d.ts +0 -1
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/context-contribution.d.ts +1 -1
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/context.d.ts +2 -2
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts +15 -0
- package/dist/server/contract-method.d.ts.map +1 -0
- package/dist/server/contract-stream.d.ts +1 -1
- package/dist/server/contract-stream.d.ts.map +1 -1
- package/dist/server/create.d.ts +8 -0
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/endpoint-dispatch.d.ts +10 -0
- package/dist/server/endpoint-dispatch.d.ts.map +1 -0
- package/dist/server/endpoint-response.d.ts +19 -0
- package/dist/server/endpoint-response.d.ts.map +1 -0
- package/dist/server/error-dispatch.d.ts +17 -1
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +2 -2
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +44 -0
- package/dist/server/handler-state.d.ts.map +1 -0
- package/dist/server/implement-registry.d.ts +54 -0
- package/dist/server/implement-registry.d.ts.map +1 -0
- package/dist/server/implement.d.ts +9 -55
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/middleware/auth.d.ts +1 -31
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +17 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/middleware/jwt.d.ts +31 -0
- package/dist/server/middleware/jwt.d.ts.map +1 -0
- package/dist/server/middleware/trust-fence.d.ts +1 -1
- package/dist/server/middleware/trust-fence.d.ts.map +1 -1
- package/dist/server/multipart-reader.d.ts +22 -0
- package/dist/server/multipart-reader.d.ts.map +1 -0
- package/dist/server/multipart.d.ts +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/oauth/cimd.d.ts +88 -0
- package/dist/server/oauth/cimd.d.ts.map +1 -0
- package/dist/server/oauth/endpoints.d.ts +39 -0
- package/dist/server/oauth/endpoints.d.ts.map +1 -0
- package/dist/server/oauth/metadata.d.ts +28 -0
- package/dist/server/oauth/metadata.d.ts.map +1 -0
- package/dist/server/oauth/provider.d.ts +117 -0
- package/dist/server/oauth/provider.d.ts.map +1 -0
- package/dist/server/realtime.d.ts +1 -1
- package/dist/server/realtime.d.ts.map +1 -1
- package/dist/server/request-completion.d.ts +16 -0
- package/dist/server/request-completion.d.ts.map +1 -0
- package/dist/server/response-metadata.d.ts +1 -1
- package/dist/server/response-metadata.d.ts.map +1 -1
- package/dist/server/route-table.d.ts +9 -0
- package/dist/server/route-table.d.ts.map +1 -0
- package/dist/server/stream.d.ts +0 -13
- package/dist/server/stream.d.ts.map +1 -1
- package/dist/server/streaming-pump.d.ts +66 -0
- package/dist/server/streaming-pump.d.ts.map +1 -0
- package/dist/server/streaming-route.d.ts +12 -5
- package/dist/server/streaming-route.d.ts.map +1 -1
- package/dist/server/types.d.ts +10 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-bun.d.ts.map +1 -1
- package/dist/server/unix-client-http1.d.ts +76 -0
- package/dist/server/unix-client-http1.d.ts.map +1 -0
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/testing/handler-clients.d.ts +32 -0
- package/dist/testing/handler-clients.d.ts.map +1 -0
- package/dist/testing/managed-resource-conformance-scenarios.d.ts.map +1 -1
- package/dist/testing/realtime-probe.d.ts +33 -0
- package/dist/testing/realtime-probe.d.ts.map +1 -0
- package/dist/testing/surface-conformance.d.ts +2 -32
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest-digest.d.ts +44 -0
- package/dist/testing/surface-manifest-digest.d.ts.map +1 -0
- package/dist/testing/surface-manifest.d.ts +30 -4
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +1 -1
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-fields.d.ts +31 -0
- package/dist/tools/cli/args-fields.d.ts.map +1 -0
- package/dist/tools/cli/args-route.d.ts +42 -0
- package/dist/tools/cli/args-route.d.ts.map +1 -0
- package/dist/tools/cli/args-view.d.ts +32 -0
- package/dist/tools/cli/args-view.d.ts.map +1 -0
- package/dist/tools/cli/args.d.ts +80 -0
- package/dist/tools/cli/args.d.ts.map +1 -0
- package/dist/tools/cli/argument-error.d.ts +5 -0
- package/dist/tools/cli/argument-error.d.ts.map +1 -0
- package/dist/tools/cli/checkpoint.d.ts +24 -0
- package/dist/tools/cli/checkpoint.d.ts.map +1 -0
- package/dist/tools/cli/command.d.ts +70 -0
- package/dist/tools/cli/command.d.ts.map +1 -0
- package/dist/tools/cli/config.d.ts +90 -0
- package/dist/tools/cli/config.d.ts.map +1 -0
- package/dist/tools/cli/create-cli.d.ts +36 -0
- package/dist/tools/cli/create-cli.d.ts.map +1 -0
- package/dist/tools/cli/download.d.ts +8 -0
- package/dist/tools/cli/download.d.ts.map +1 -0
- package/dist/tools/cli/format.d.ts +50 -0
- package/dist/tools/cli/format.d.ts.map +1 -0
- package/dist/tools/cli/help.d.ts +24 -0
- package/dist/tools/cli/help.d.ts.map +1 -0
- package/dist/tools/cli/installer.d.ts +34 -0
- package/dist/tools/cli/installer.d.ts.map +1 -0
- package/dist/tools/cli/invoke.d.ts +144 -0
- package/dist/tools/cli/invoke.d.ts.map +1 -0
- package/dist/tools/cli/io.d.ts +10 -0
- package/dist/tools/cli/io.d.ts.map +1 -0
- package/dist/tools/cli/managed-surface.d.ts +30 -0
- package/dist/tools/cli/managed-surface.d.ts.map +1 -0
- package/dist/tools/cli/manifest.d.ts +80 -0
- package/dist/tools/cli/manifest.d.ts.map +1 -0
- package/dist/tools/cli/policy.d.ts +27 -0
- package/dist/tools/cli/policy.d.ts.map +1 -0
- package/dist/tools/cli/prepare.d.ts +14 -0
- package/dist/tools/cli/prepare.d.ts.map +1 -0
- package/dist/tools/cli/profile.d.ts +40 -0
- package/dist/tools/cli/profile.d.ts.map +1 -0
- package/dist/tools/cli/run-managed.d.ts +5 -0
- package/dist/tools/cli/run-managed.d.ts.map +1 -0
- package/dist/tools/cli/run-native.d.ts +9 -0
- package/dist/tools/cli/run-native.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +40 -0
- package/dist/tools/cli/session.d.ts.map +1 -0
- package/dist/tools/cli/signature.d.ts +81 -0
- package/dist/tools/cli/signature.d.ts.map +1 -0
- package/dist/tools/cli/stream.d.ts +93 -0
- package/dist/tools/cli/stream.d.ts.map +1 -0
- package/dist/tools/cli/update.d.ts +145 -0
- package/dist/tools/cli/update.d.ts.map +1 -0
- package/dist/tools/cli/view.d.ts +12 -0
- package/dist/tools/cli/view.d.ts.map +1 -0
- package/dist/tools/cli/wait.d.ts +54 -0
- package/dist/tools/cli/wait.d.ts.map +1 -0
- package/dist/tools/connections/runtime.d.ts +1 -1
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +3 -3
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/durability-context.d.ts +1 -1
- package/dist/tools/durability-context.d.ts.map +1 -1
- package/dist/tools/execute-args.d.ts +23 -0
- package/dist/tools/execute-args.d.ts.map +1 -0
- package/dist/tools/execute-hooks.d.ts +146 -0
- package/dist/tools/execute-hooks.d.ts.map +1 -0
- package/dist/tools/execute-result.d.ts +40 -0
- package/dist/tools/execute-result.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +31 -193
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts +9 -6
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/internal/tool-view.d.ts +41 -0
- package/dist/tools/internal/tool-view.d.ts.map +1 -0
- package/dist/tools/invoker.d.ts +13 -4
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +1 -1
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +3 -3
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -2
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/app.d.ts +62 -0
- package/dist/tools/mcp/app.d.ts.map +1 -0
- package/dist/tools/mcp/catalog.d.ts +68 -0
- package/dist/tools/mcp/catalog.d.ts.map +1 -0
- package/dist/tools/mcp/handler.d.ts +46 -0
- package/dist/tools/mcp/handler.d.ts.map +1 -0
- package/dist/tools/mcp/mount.d.ts +152 -0
- package/dist/tools/mcp/mount.d.ts.map +1 -0
- package/dist/tools/mcp/prepare.d.ts +76 -0
- package/dist/tools/mcp/prepare.d.ts.map +1 -0
- package/dist/tools/mcp/progress.d.ts +46 -0
- package/dist/tools/mcp/progress.d.ts.map +1 -0
- package/dist/tools/mcp/register.d.ts +36 -0
- package/dist/tools/mcp/register.d.ts.map +1 -0
- package/dist/tools/mcp/round-context.d.ts +38 -0
- package/dist/tools/mcp/round-context.d.ts.map +1 -0
- package/dist/tools/mcp/round-policy.d.ts +33 -0
- package/dist/tools/mcp/round-policy.d.ts.map +1 -0
- package/dist/tools/mcp/round.d.ts +53 -0
- package/dist/tools/mcp/round.d.ts.map +1 -0
- package/dist/tools/mcp/runtime-tools.d.ts +25 -0
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -0
- package/dist/tools/mcp/stdio-signals.d.ts +33 -0
- package/dist/tools/mcp/stdio-signals.d.ts.map +1 -0
- package/dist/tools/mcp/stdio.d.ts +20 -0
- package/dist/tools/mcp/stdio.d.ts.map +1 -0
- package/dist/tools/mcp/trace.d.ts +12 -0
- package/dist/tools/mcp/trace.d.ts.map +1 -0
- package/dist/tools/mount.d.ts +14 -7
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +4 -3
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-binding-types.d.ts +127 -0
- package/dist/tools/operations/async-operation-binding-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-binding.d.ts +28 -0
- package/dist/tools/operations/async-operation-binding.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-canonical-types.d.ts +110 -0
- package/dist/tools/operations/async-operation-canonical-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-canonical.d.ts +7 -0
- package/dist/tools/operations/async-operation-canonical.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-contract.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-id.d.ts +23 -0
- package/dist/tools/operations/async-operation-id.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +41 -0
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime-types.d.ts +69 -0
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime.d.ts +5 -0
- package/dist/tools/operations/async-operation-runtime.d.ts.map +1 -0
- package/dist/tools/operations/define-wait-tool.d.ts +22 -0
- package/dist/tools/operations/define-wait-tool.d.ts.map +1 -0
- package/dist/tools/operations/mount-wait.d.ts.map +1 -0
- package/dist/tools/operations/wait-core.d.ts.map +1 -0
- package/dist/tools/remote.d.ts +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +13 -4
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -0
- package/dist/tools/schema/flatten-join.d.ts.map +1 -0
- package/dist/tools/schema/flatten.d.ts.map +1 -0
- package/dist/tools/schema/portable-formats.d.ts.map +1 -0
- package/dist/tools/schema/presentation.d.ts +24 -0
- package/dist/tools/schema/presentation.d.ts.map +1 -0
- package/dist/tools/schema/schema.d.ts.map +1 -0
- package/dist/tools/schema/untyped-properties.d.ts.map +1 -0
- package/dist/tools/surface.d.ts +2 -3
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/tool-logger.d.ts +1 -1
- package/dist/tools/tool-logger.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +4 -4
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-download-tool.d.ts +18 -0
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -0
- package/dist/tools/transfer/define-upload-tool.d.ts +16 -0
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -0
- package/dist/tools/transfer/define-view-file-tool.d.ts +10 -0
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -0
- package/dist/tools/transfer/download-core.d.ts +20 -0
- package/dist/tools/transfer/download-core.d.ts.map +1 -0
- package/dist/tools/transfer/managed-file-error.d.ts +6 -0
- package/dist/tools/transfer/managed-file-error.d.ts.map +1 -0
- package/dist/tools/transfer/mount-download.d.ts +41 -0
- package/dist/tools/transfer/mount-download.d.ts.map +1 -0
- package/dist/tools/transfer/mount-upload.d.ts +21 -0
- package/dist/tools/transfer/mount-upload.d.ts.map +1 -0
- package/dist/tools/transfer/native-result.d.ts.map +1 -0
- package/dist/tools/transfer/upload-core.d.ts +4 -0
- package/dist/tools/transfer/upload-core.d.ts.map +1 -0
- package/dist/tools/transfer/view-file-contract.d.ts.map +1 -0
- package/dist/tools/transfer/view-file.d.ts +62 -0
- package/dist/tools/transfer/view-file.d.ts.map +1 -0
- package/dist/tools/transports.d.ts +1 -1
- package/dist/tools/transports.d.ts.map +1 -1
- package/dist/tracking/client-listeners.d.ts +30 -0
- package/dist/tracking/client-listeners.d.ts.map +1 -0
- package/dist/tracking/client-visit.d.ts +61 -0
- package/dist/tracking/client-visit.d.ts.map +1 -0
- package/dist/tracking/client.d.ts +3 -2
- package/dist/tracking/client.d.ts.map +1 -1
- package/dist/tracking/contract.d.ts +1 -1
- package/dist/tracking/contract.d.ts.map +1 -1
- package/llms/agent-runtime-browser.txt +33 -0
- package/llms/agent-runtime-coding-tools.txt +58 -0
- package/llms/agent-runtime-harness.txt +45 -0
- package/llms/agent-runtime-openrouter.txt +22 -0
- package/llms/agent-runtime-sandbox.txt +159 -0
- package/llms/agent-runtime-sqlite-bun.txt +29 -0
- package/llms/agent-runtime-sqlite-node.txt +26 -0
- package/llms/agent-runtime-testing.txt +30 -0
- package/llms/agent-runtime.2.txt +550 -0
- package/llms/agent-runtime.3.txt +311 -0
- package/llms/agent-runtime.txt +893 -0
- package/llms/application-diagnostic-journal.txt +30 -0
- package/llms/application-grammy.txt +27 -0
- package/llms/application-opentelemetry.txt +27 -0
- package/llms/application-schemas.txt +42 -0
- package/llms/application.2.txt +487 -0
- package/llms/application.txt +886 -0
- package/llms/cli.2.txt +80 -0
- package/llms/cli.txt +948 -0
- package/llms/contract.txt +606 -0
- package/llms/declaration.txt +286 -0
- package/llms/files.txt +33 -0
- package/llms/geo.txt +114 -0
- package/llms/google.txt +27 -0
- package/llms/live.txt +471 -0
- package/llms/node.txt +43 -0
- package/llms/oauth.txt +136 -0
- package/llms/observability.txt +893 -0
- package/llms/primitives.txt +158 -0
- package/llms/react.txt +184 -0
- package/llms/release.txt +176 -0
- package/llms/remote.txt +25 -0
- package/llms/server.2.txt +361 -0
- package/llms/server.3.txt +1031 -0
- package/llms/server.4.txt +905 -0
- package/llms/server.5.txt +250 -0
- package/llms/server.txt +996 -0
- package/llms/stitchkit.2.txt +836 -0
- package/llms/stitchkit.3.txt +147 -0
- package/llms/stitchkit.txt +260 -0
- package/llms/telegram.txt +30 -0
- package/llms/testing.txt +676 -0
- package/llms/tools-connections.txt +45 -0
- package/llms/tools-contract.txt +9 -0
- package/llms/tools-invoker.txt +9 -0
- package/llms/tools.2.txt +647 -0
- package/llms/tools.3.txt +288 -0
- package/llms/tools.txt +966 -0
- package/llms/tracking-server.txt +32 -0
- package/llms/tracking.txt +263 -0
- package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
- package/llms/upgrading-0.53.0-0.67.0.txt +1174 -0
- package/llms/upgrading-0.68.0-0.94.0.txt +1159 -0
- package/llms/upgrading.txt +215 -0
- package/llms-full.txt +312 -77
- package/llms.txt +54 -5
- package/package.json +84 -83
- package/dist/agent-runtime/durability-contract.d.ts +0 -176
- package/dist/agent-runtime/durability-contract.d.ts.map +0 -1
- package/dist/agent-runtime/durability-json.d.ts +0 -3
- package/dist/agent-runtime/durability-json.d.ts.map +0 -1
- package/dist/agent-runtime/durability-ledger.d.ts +0 -16
- package/dist/agent-runtime/durability-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/durability-scheduler.d.ts +0 -29
- package/dist/agent-runtime/durability-scheduler.d.ts.map +0 -1
- package/dist/agent-runtime/durability.d.ts +0 -14
- package/dist/agent-runtime/durability.d.ts.map +0 -1
- package/dist/agent-runtime/store-driver.d.ts +0 -814
- package/dist/agent-runtime/store-driver.d.ts.map +0 -1
- package/dist/agent-runtime-browser.d.ts +0 -5
- package/dist/agent-runtime-browser.d.ts.map +0 -1
- package/dist/agent-runtime-browser.js +0 -124
- package/dist/agent-runtime-coding-tools.d.ts +0 -2
- package/dist/agent-runtime-coding-tools.d.ts.map +0 -1
- package/dist/agent-runtime-coding-tools.js +0 -23
- package/dist/agent-runtime-harness.d.ts +0 -2
- package/dist/agent-runtime-harness.d.ts.map +0 -1
- package/dist/agent-runtime-harness.js +0 -729
- package/dist/agent-runtime-openrouter.d.ts +0 -29
- package/dist/agent-runtime-openrouter.d.ts.map +0 -1
- package/dist/agent-runtime-openrouter.js +0 -270
- package/dist/agent-runtime-sandbox.d.ts +0 -5
- package/dist/agent-runtime-sandbox.d.ts.map +0 -1
- package/dist/agent-runtime-sandbox.js +0 -798
- package/dist/agent-runtime-sqlite-bun.d.ts +0 -11
- package/dist/agent-runtime-sqlite-bun.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-bun.js +0 -42
- package/dist/agent-runtime-sqlite-node.d.ts +0 -11
- package/dist/agent-runtime-sqlite-node.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-node.js +0 -44
- package/dist/agent-runtime-testing.d.ts +0 -3
- package/dist/agent-runtime-testing.d.ts.map +0 -1
- package/dist/agent-runtime-testing.js +0 -156
- package/dist/agent-runtime.d.ts +0 -38
- package/dist/agent-runtime.d.ts.map +0 -1
- package/dist/agent-runtime.js +0 -2607
- package/dist/application/channel.d.ts.map +0 -1
- package/dist/application-diagnostic-journal.d.ts +0 -21
- package/dist/application-diagnostic-journal.d.ts.map +0 -1
- package/dist/application-diagnostic-journal.js +0 -632
- package/dist/application-grammy.d.ts +0 -2
- package/dist/application-grammy.d.ts.map +0 -1
- package/dist/application-grammy.js +0 -169
- package/dist/application-opentelemetry.d.ts +0 -2
- package/dist/application-opentelemetry.d.ts.map +0 -1
- package/dist/application-opentelemetry.js +0 -250
- package/dist/application-schemas.d.ts +0 -15
- package/dist/application-schemas.d.ts.map +0 -1
- package/dist/application-schemas.js +0 -27
- package/dist/application.d.ts +0 -22
- package/dist/application.d.ts.map +0 -1
- package/dist/application.js +0 -1977
- package/dist/cli.d.ts +0 -41
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -753
- package/dist/contract/index.d.ts +0 -8
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/contract/index.js +0 -55
- package/dist/declaration.d.ts.map +0 -1
- package/dist/declaration.js +0 -183
- package/dist/files.d.ts +0 -3
- package/dist/files.d.ts.map +0 -1
- package/dist/files.js +0 -15
- package/dist/geo.d.ts +0 -3
- package/dist/geo.d.ts.map +0 -1
- package/dist/geo.js +0 -245
- package/dist/google.d.ts.map +0 -1
- package/dist/google.js +0 -175
- package/dist/index-0a349c33.js +0 -470
- package/dist/index-0j3vcp5m.js +0 -28
- package/dist/index-2c2bjw3s.js +0 -51
- package/dist/index-2na0qrfn.js +0 -214
- package/dist/index-2qzskm8h.js +0 -63
- package/dist/index-3bmnp41g.js +0 -2169
- package/dist/index-3xwxfj4z.js +0 -334
- package/dist/index-4fpa9dy2.js +0 -51
- package/dist/index-6kyksz9y.js +0 -268
- package/dist/index-77fekveh.js +0 -44
- package/dist/index-7gnkny4z.js +0 -326
- package/dist/index-7zbps32p.js +0 -89
- package/dist/index-9f8ztey6.js +0 -588
- package/dist/index-a11g2kry.js +0 -866
- package/dist/index-a916km3r.js +0 -45
- package/dist/index-actkayzn.js +0 -367
- package/dist/index-bn2cjajt.js +0 -524
- package/dist/index-bx75zwt7.js +0 -63
- package/dist/index-cby4ar3v.js +0 -46
- package/dist/index-cnyk6te3.js +0 -77
- package/dist/index-cxqhvq21.js +0 -413
- package/dist/index-e0znv5gn.js +0 -176
- package/dist/index-e42wzzz5.js +0 -154
- package/dist/index-f477k430.js +0 -324
- package/dist/index-f9mb610r.js +0 -177
- package/dist/index-fadnxwna.js +0 -1046
- package/dist/index-fq77yfzc.js +0 -1303
- package/dist/index-h9etkkyk.js +0 -1126
- package/dist/index-hrbajay7.js +0 -1196
- package/dist/index-kw9t5ayn.js +0 -507
- package/dist/index-mzvgxp0n.js +0 -80
- package/dist/index-n0f51dfn.js +0 -3170
- package/dist/index-p13mwz16.js +0 -16
- package/dist/index-s8cnx02s.js +0 -90
- package/dist/index-sr93cwf9.js +0 -325
- package/dist/index-tmwcrptx.js +0 -85
- package/dist/index-v5573g1k.js +0 -142
- package/dist/index-vjpvjqpn.js +0 -86
- package/dist/index-vk3kq9sb.js +0 -3344
- package/dist/index-wc4x00bn.js +0 -103
- package/dist/index-wnfk50r0.js +0 -211
- package/dist/index-yewwh1w4.js +0 -647
- package/dist/index-yn8remb1.js +0 -290
- package/dist/index-ywd0y6m1.js +0 -394
- package/dist/index-zwkgfq1s.js +0 -345
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -632
- package/dist/internal/errors.d.ts +0 -92
- package/dist/internal/errors.d.ts.map +0 -1
- package/dist/internal/observability-sink.d.ts +0 -81
- package/dist/internal/observability-sink.d.ts.map +0 -1
- package/dist/live.d.ts +0 -19
- package/dist/live.d.ts.map +0 -1
- package/dist/live.js +0 -282
- package/dist/logger.d.ts.map +0 -1
- package/dist/node.d.ts +0 -18
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -303
- package/dist/oauth.d.ts +0 -57
- package/dist/oauth.d.ts.map +0 -1
- package/dist/oauth.js +0 -170
- package/dist/observability/index.d.ts +0 -19
- package/dist/observability/index.d.ts.map +0 -1
- package/dist/observability/index.js +0 -569
- package/dist/primitives.d.ts +0 -3
- package/dist/primitives.d.ts.map +0 -1
- package/dist/primitives.js +0 -754
- package/dist/react.d.ts +0 -5
- package/dist/react.d.ts.map +0 -1
- package/dist/react.js +0 -403
- package/dist/release.d.ts +0 -15
- package/dist/release.d.ts.map +0 -1
- package/dist/release.js +0 -196
- package/dist/remote.d.ts +0 -9
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js +0 -88
- package/dist/retained.d.ts.map +0 -1
- package/dist/server/file-state-store.d.ts +0 -23
- package/dist/server/file-state-store.d.ts.map +0 -1
- package/dist/server/index.d.ts +0 -36
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js +0 -1745
- package/dist/server/request.d.ts.map +0 -1
- package/dist/telegram.d.ts +0 -3
- package/dist/telegram.d.ts.map +0 -1
- package/dist/telegram.js +0 -224
- package/dist/testing/agent-store-conformance.d.ts +0 -40
- package/dist/testing/agent-store-conformance.d.ts.map +0 -1
- package/dist/testing.d.ts +0 -39
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -2209
- package/dist/tool-invoker.d.ts +0 -9
- package/dist/tool-invoker.d.ts.map +0 -1
- package/dist/tool-invoker.js +0 -21
- package/dist/tools/async-operation-contract.d.ts.map +0 -1
- package/dist/tools/async-operation.d.ts +0 -332
- package/dist/tools/async-operation.d.ts.map +0 -1
- package/dist/tools/cli-args.d.ts +0 -143
- package/dist/tools/cli-args.d.ts.map +0 -1
- package/dist/tools/cli-checkpoint.d.ts +0 -24
- package/dist/tools/cli-checkpoint.d.ts.map +0 -1
- package/dist/tools/cli-command.d.ts +0 -70
- package/dist/tools/cli-command.d.ts.map +0 -1
- package/dist/tools/cli-format.d.ts +0 -49
- package/dist/tools/cli-format.d.ts.map +0 -1
- package/dist/tools/cli-installer.d.ts +0 -34
- package/dist/tools/cli-installer.d.ts.map +0 -1
- package/dist/tools/cli-invoke.d.ts +0 -143
- package/dist/tools/cli-invoke.d.ts.map +0 -1
- package/dist/tools/cli-manifest.d.ts +0 -80
- package/dist/tools/cli-manifest.d.ts.map +0 -1
- package/dist/tools/cli-policy.d.ts +0 -27
- package/dist/tools/cli-policy.d.ts.map +0 -1
- package/dist/tools/cli-profile.d.ts +0 -40
- package/dist/tools/cli-profile.d.ts.map +0 -1
- package/dist/tools/cli-signature.d.ts +0 -81
- package/dist/tools/cli-signature.d.ts.map +0 -1
- package/dist/tools/cli-stream.d.ts +0 -93
- package/dist/tools/cli-stream.d.ts.map +0 -1
- package/dist/tools/cli-update.d.ts +0 -126
- package/dist/tools/cli-update.d.ts.map +0 -1
- package/dist/tools/cli-view.d.ts +0 -12
- package/dist/tools/cli-view.d.ts.map +0 -1
- package/dist/tools/cli-wait.d.ts +0 -54
- package/dist/tools/cli-wait.d.ts.map +0 -1
- package/dist/tools/cli.d.ts +0 -94
- package/dist/tools/cli.d.ts.map +0 -1
- package/dist/tools/coerce.d.ts.map +0 -1
- package/dist/tools/connections/index.d.ts +0 -20
- package/dist/tools/connections/index.d.ts.map +0 -1
- package/dist/tools/connections/index.js +0 -1107
- package/dist/tools/define-download-tool.d.ts +0 -18
- package/dist/tools/define-download-tool.d.ts.map +0 -1
- package/dist/tools/define-upload-tool.d.ts +0 -16
- package/dist/tools/define-upload-tool.d.ts.map +0 -1
- package/dist/tools/define-view-file-tool.d.ts +0 -10
- package/dist/tools/define-view-file-tool.d.ts.map +0 -1
- package/dist/tools/define-wait-tool.d.ts +0 -22
- package/dist/tools/define-wait-tool.d.ts.map +0 -1
- package/dist/tools/download-core.d.ts +0 -20
- package/dist/tools/download-core.d.ts.map +0 -1
- package/dist/tools/flatten-join.d.ts.map +0 -1
- package/dist/tools/flatten.d.ts.map +0 -1
- package/dist/tools/json-schema-dialect.d.ts +0 -17
- package/dist/tools/json-schema-dialect.d.ts.map +0 -1
- package/dist/tools/json-schema.d.ts.map +0 -1
- package/dist/tools/managed-file-error.d.ts +0 -6
- package/dist/tools/managed-file-error.d.ts.map +0 -1
- package/dist/tools/mcp-app.d.ts +0 -62
- package/dist/tools/mcp-app.d.ts.map +0 -1
- package/dist/tools/mcp-catalog.d.ts +0 -68
- package/dist/tools/mcp-catalog.d.ts.map +0 -1
- package/dist/tools/mcp-handler.d.ts +0 -46
- package/dist/tools/mcp-handler.d.ts.map +0 -1
- package/dist/tools/mcp-prepare.d.ts +0 -75
- package/dist/tools/mcp-prepare.d.ts.map +0 -1
- package/dist/tools/mcp-progress.d.ts +0 -46
- package/dist/tools/mcp-progress.d.ts.map +0 -1
- package/dist/tools/mcp-round-policy.d.ts +0 -33
- package/dist/tools/mcp-round-policy.d.ts.map +0 -1
- package/dist/tools/mcp-round.d.ts +0 -61
- package/dist/tools/mcp-round.d.ts.map +0 -1
- package/dist/tools/mcp-stdio-signals.d.ts +0 -33
- package/dist/tools/mcp-stdio-signals.d.ts.map +0 -1
- package/dist/tools/mcp-stdio.d.ts +0 -20
- package/dist/tools/mcp-stdio.d.ts.map +0 -1
- package/dist/tools/mcp-trace.d.ts +0 -12
- package/dist/tools/mcp-trace.d.ts.map +0 -1
- package/dist/tools/mcp.d.ts +0 -152
- package/dist/tools/mcp.d.ts.map +0 -1
- package/dist/tools/mount-download.d.ts +0 -41
- package/dist/tools/mount-download.d.ts.map +0 -1
- package/dist/tools/mount-upload.d.ts +0 -21
- package/dist/tools/mount-upload.d.ts.map +0 -1
- package/dist/tools/mount-wait.d.ts.map +0 -1
- package/dist/tools/native-mcp.d.ts +0 -20
- package/dist/tools/native-mcp.d.ts.map +0 -1
- package/dist/tools/native-result.d.ts.map +0 -1
- package/dist/tools/oauth-metadata.d.ts +0 -28
- package/dist/tools/oauth-metadata.d.ts.map +0 -1
- package/dist/tools/oauth-provider.d.ts +0 -184
- package/dist/tools/oauth-provider.d.ts.map +0 -1
- package/dist/tools/portable-formats.d.ts.map +0 -1
- package/dist/tools/presentation.d.ts +0 -22
- package/dist/tools/presentation.d.ts.map +0 -1
- package/dist/tools/schema.d.ts.map +0 -1
- package/dist/tools/untyped-properties.d.ts.map +0 -1
- package/dist/tools/upload-core.d.ts +0 -4
- package/dist/tools/upload-core.d.ts.map +0 -1
- package/dist/tools/view-file-contract.d.ts.map +0 -1
- package/dist/tools/view-file.d.ts +0 -62
- package/dist/tools/view-file.d.ts.map +0 -1
- package/dist/tools/wait-core.d.ts.map +0 -1
- package/dist/tools-contract.d.ts +0 -29
- package/dist/tools-contract.d.ts.map +0 -1
- package/dist/tools-contract.js +0 -24
- package/dist/tools.d.ts +0 -50
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js +0 -2930
- package/dist/tracking-server.d.ts +0 -15
- package/dist/tracking-server.d.ts.map +0 -1
- package/dist/tracking.d.ts +0 -24
- package/dist/tracking.d.ts.map +0 -1
- package/dist/tracking.js +0 -1092
- package/dist/upgrade-cli.d.ts.map +0 -1
- package/dist/upgrade-cli.js +0 -177
- /package/dist/{retained.d.ts → browser/retained.d.ts} +0 -0
- /package/dist/{declaration.d.ts → declaration/declaration.d.ts} +0 -0
- /package/dist/{upgrade-cli.d.ts → entrypoints/bin/upgrade-cli.d.ts} +0 -0
- /package/dist/{tracking-server.js → entrypoints/tracking/server.js} +0 -0
- /package/dist/{google.d.ts → google/google.d.ts} +0 -0
- /package/dist/{index-pq95qkbf.js → index-5jm36zv1.js} +0 -0
- /package/dist/{application → internal}/channel.d.ts +0 -0
- /package/dist/{logger.d.ts → internal/logger.d.ts} +0 -0
- /package/dist/{server → internal}/request.d.ts +0 -0
- /package/dist/{tools → json-schema}/json-schema.d.ts +0 -0
- /package/dist/tools/{async-operation-contract.d.ts → operations/async-operation-contract.d.ts} +0 -0
- /package/dist/tools/{mount-wait.d.ts → operations/mount-wait.d.ts} +0 -0
- /package/dist/tools/{wait-core.d.ts → operations/wait-core.d.ts} +0 -0
- /package/dist/tools/{coerce.d.ts → schema/coerce.d.ts} +0 -0
- /package/dist/tools/{flatten-join.d.ts → schema/flatten-join.d.ts} +0 -0
- /package/dist/tools/{flatten.d.ts → schema/flatten.d.ts} +0 -0
- /package/dist/tools/{portable-formats.d.ts → schema/portable-formats.d.ts} +0 -0
- /package/dist/tools/{schema.d.ts → schema/schema.d.ts} +0 -0
- /package/dist/tools/{untyped-properties.d.ts → schema/untyped-properties.d.ts} +0 -0
- /package/dist/tools/{native-result.d.ts → transfer/native-result.d.ts} +0 -0
- /package/dist/tools/{view-file-contract.d.ts → transfer/view-file-contract.d.ts} +0 -0
|
@@ -0,0 +1,1140 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ApiError
|
|
3
|
+
} from "../index-v260df89.js";
|
|
4
|
+
import {
|
|
5
|
+
defineContract
|
|
6
|
+
} from "../index-k30h66yd.js";
|
|
7
|
+
import"../index-4gcnakhx.js";
|
|
8
|
+
import"../index-zcgf3gqf.js";
|
|
9
|
+
import"../index-kzfs85xp.js";
|
|
10
|
+
import"../index-hffjpmq9.js";
|
|
11
|
+
|
|
12
|
+
// src/tracking/attribution.ts
|
|
13
|
+
import { z as z2 } from "zod";
|
|
14
|
+
|
|
15
|
+
// src/tracking/schemas.ts
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
var UtmDataSchema = z.object({
|
|
18
|
+
source: z.string().max(200).optional(),
|
|
19
|
+
medium: z.string().max(200).optional(),
|
|
20
|
+
campaign: z.string().max(200).optional(),
|
|
21
|
+
content: z.string().max(200).optional(),
|
|
22
|
+
term: z.string().max(200).optional()
|
|
23
|
+
});
|
|
24
|
+
var AttributionDataSchema = z.object({
|
|
25
|
+
utm: UtmDataSchema.optional(),
|
|
26
|
+
referrer: z.string().optional(),
|
|
27
|
+
landingPage: z.string().optional()
|
|
28
|
+
});
|
|
29
|
+
var DEFAULT_BUILD_ID_PATTERN = /^(dev|[a-f0-9]{7,40})$/;
|
|
30
|
+
var TrackingDispositionStatusSchema = z.enum([
|
|
31
|
+
"accepted",
|
|
32
|
+
"duplicate",
|
|
33
|
+
"identity-invalid",
|
|
34
|
+
"excluded-bot"
|
|
35
|
+
]);
|
|
36
|
+
var TrackingDispositionSchema = z.object({
|
|
37
|
+
eventId: z.uuid(),
|
|
38
|
+
status: TrackingDispositionStatusSchema
|
|
39
|
+
});
|
|
40
|
+
var TrackEventsResponseSchema = z.object({
|
|
41
|
+
accepted: z.number().int().nonnegative(),
|
|
42
|
+
dispositions: z.array(TrackingDispositionSchema)
|
|
43
|
+
});
|
|
44
|
+
var VisitBootstrapResponseSchema = z.object({
|
|
45
|
+
visitId: z.uuid(),
|
|
46
|
+
expiresAt: z.iso.datetime()
|
|
47
|
+
});
|
|
48
|
+
var TrackingOutboxStateSchema = z.enum(["available", "unavailable"]);
|
|
49
|
+
function trackingEventShape(eventTypes) {
|
|
50
|
+
return {
|
|
51
|
+
eventId: z.uuid(),
|
|
52
|
+
visitId: z.uuid(),
|
|
53
|
+
browserStreamId: z.uuid(),
|
|
54
|
+
browserSequence: z.number().int().nonnegative(),
|
|
55
|
+
type: z.enum(eventTypes),
|
|
56
|
+
page: z.string().max(2000),
|
|
57
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
58
|
+
clientTimestamp: z.number()
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function visitEntryContextShape(buildIdPattern) {
|
|
62
|
+
return {
|
|
63
|
+
browserStreamId: z.uuid(),
|
|
64
|
+
previousVisitId: z.uuid().optional(),
|
|
65
|
+
origin: z.url().max(500),
|
|
66
|
+
landingPath: z.string().startsWith("/").max(300).regex(/^[^?#]*$/),
|
|
67
|
+
referrer: z.url().max(2000).optional(),
|
|
68
|
+
utm: UtmDataSchema.optional(),
|
|
69
|
+
displayMode: z.enum(["browser", "standalone"]),
|
|
70
|
+
screenWidth: z.number().int().positive().max(20000),
|
|
71
|
+
screenHeight: z.number().int().positive().max(20000),
|
|
72
|
+
buildId: z.string().regex(buildIdPattern),
|
|
73
|
+
outboxState: TrackingOutboxStateSchema,
|
|
74
|
+
outboxQueued: z.number().int().nonnegative().max(1000),
|
|
75
|
+
outboxDropped: z.number().int().nonnegative()
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function createTrackingSchemas(config) {
|
|
79
|
+
const base = z.object(trackingEventShape(config.eventTypes));
|
|
80
|
+
const event = config.eventExtras ? base.extend(config.eventExtras.shape) : base;
|
|
81
|
+
const buildIdPattern = config.buildIdPattern ?? DEFAULT_BUILD_ID_PATTERN;
|
|
82
|
+
const maxEvents = config.maxEventsPerBatch ?? 50;
|
|
83
|
+
return {
|
|
84
|
+
event,
|
|
85
|
+
request: z.object({
|
|
86
|
+
buildId: z.string().regex(buildIdPattern),
|
|
87
|
+
events: z.array(event).min(1).max(maxEvents),
|
|
88
|
+
utm: UtmDataSchema.optional()
|
|
89
|
+
}),
|
|
90
|
+
response: TrackEventsResponseSchema,
|
|
91
|
+
disposition: TrackingDispositionSchema,
|
|
92
|
+
entry: z.object(visitEntryContextShape(buildIdPattern)),
|
|
93
|
+
bootstrap: VisitBootstrapResponseSchema
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/tracking/attribution.ts
|
|
98
|
+
var StoredTouchSchema = z2.object({ data: AttributionDataSchema, capturedAt: z2.number() });
|
|
99
|
+
var StoredAttributionSchema = z2.object({
|
|
100
|
+
firstTouch: StoredTouchSchema,
|
|
101
|
+
currentTouch: StoredTouchSchema
|
|
102
|
+
});
|
|
103
|
+
function normalize(value) {
|
|
104
|
+
if (!value)
|
|
105
|
+
return;
|
|
106
|
+
return value.toLowerCase().trim().slice(0, 200) || undefined;
|
|
107
|
+
}
|
|
108
|
+
function parseUtmFromSearch(search) {
|
|
109
|
+
const params = new URLSearchParams(search);
|
|
110
|
+
const source = normalize(params.get("utm_source"));
|
|
111
|
+
if (!source)
|
|
112
|
+
return null;
|
|
113
|
+
return {
|
|
114
|
+
source,
|
|
115
|
+
medium: normalize(params.get("utm_medium")),
|
|
116
|
+
campaign: normalize(params.get("utm_campaign")),
|
|
117
|
+
content: normalize(params.get("utm_content")),
|
|
118
|
+
term: normalize(params.get("utm_term"))
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function parseReferrer(referrer, currentHostname, referrerMap = []) {
|
|
122
|
+
if (!referrer)
|
|
123
|
+
return null;
|
|
124
|
+
try {
|
|
125
|
+
const hostname = new URL(referrer).hostname.toLowerCase();
|
|
126
|
+
if (hostname === currentHostname.toLowerCase())
|
|
127
|
+
return null;
|
|
128
|
+
const match = referrerMap.find((rule) => rule.pattern.test(hostname));
|
|
129
|
+
return match ? { source: match.source, medium: match.medium } : { source: hostname, medium: "referral" };
|
|
130
|
+
} catch {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function readStored(storage, key, now, ttlMs) {
|
|
135
|
+
try {
|
|
136
|
+
const raw = storage.getItem(key);
|
|
137
|
+
if (!raw)
|
|
138
|
+
return null;
|
|
139
|
+
const parsed = StoredAttributionSchema.safeParse(JSON.parse(raw));
|
|
140
|
+
if (!parsed.success || now - parsed.data.firstTouch.capturedAt > ttlMs) {
|
|
141
|
+
storage.removeItem(key);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
return parsed.data;
|
|
145
|
+
} catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function writeStored(storage, key, value) {
|
|
150
|
+
try {
|
|
151
|
+
storage.setItem(key, JSON.stringify(value));
|
|
152
|
+
} catch {}
|
|
153
|
+
}
|
|
154
|
+
function resolveAttribution({
|
|
155
|
+
search,
|
|
156
|
+
referrer,
|
|
157
|
+
pathname,
|
|
158
|
+
hostname,
|
|
159
|
+
storage,
|
|
160
|
+
referrerMap = [],
|
|
161
|
+
storageKey = "tracking.attribution",
|
|
162
|
+
ttlMs = 90 * 24 * 60 * 60 * 1000,
|
|
163
|
+
now = Date.now()
|
|
164
|
+
}) {
|
|
165
|
+
const stored = readStored(storage, storageKey, now, ttlMs);
|
|
166
|
+
const urlUtm = parseUtmFromSearch(search);
|
|
167
|
+
if (urlUtm) {
|
|
168
|
+
const currentTouch = {
|
|
169
|
+
utm: urlUtm,
|
|
170
|
+
referrer: referrer || undefined,
|
|
171
|
+
landingPage: pathname
|
|
172
|
+
};
|
|
173
|
+
const persisted = {
|
|
174
|
+
firstTouch: {
|
|
175
|
+
data: stored?.firstTouch.data ?? currentTouch,
|
|
176
|
+
capturedAt: stored?.firstTouch.capturedAt ?? now
|
|
177
|
+
},
|
|
178
|
+
currentTouch: { data: currentTouch, capturedAt: now }
|
|
179
|
+
};
|
|
180
|
+
writeStored(storage, storageKey, persisted);
|
|
181
|
+
return {
|
|
182
|
+
firstTouch: persisted.firstTouch.data,
|
|
183
|
+
currentTouch: persisted.currentTouch.data
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
if (stored)
|
|
187
|
+
return { firstTouch: stored.firstTouch.data, currentTouch: stored.currentTouch.data };
|
|
188
|
+
const fromReferrer = parseReferrer(referrer, hostname, referrerMap);
|
|
189
|
+
const firstTouch = {
|
|
190
|
+
utm: fromReferrer ? { source: fromReferrer.source, medium: fromReferrer.medium } : undefined,
|
|
191
|
+
referrer: referrer || undefined,
|
|
192
|
+
landingPage: pathname
|
|
193
|
+
};
|
|
194
|
+
writeStored(storage, storageKey, {
|
|
195
|
+
firstTouch: { data: firstTouch, capturedAt: now },
|
|
196
|
+
currentTouch: { data: firstTouch, capturedAt: now }
|
|
197
|
+
});
|
|
198
|
+
return { firstTouch, currentTouch: firstTouch };
|
|
199
|
+
}
|
|
200
|
+
// src/tracking/beacon.ts
|
|
201
|
+
function sendUnloadBeacon(url, body, sender = typeof navigator === "undefined" ? undefined : navigator) {
|
|
202
|
+
if (!sender || typeof sender.sendBeacon !== "function")
|
|
203
|
+
return false;
|
|
204
|
+
return sender.sendBeacon(url, body);
|
|
205
|
+
}
|
|
206
|
+
// src/tracking/clicks.ts
|
|
207
|
+
function label(target) {
|
|
208
|
+
return (target?.textContent ?? "").trim().slice(0, 100) || undefined;
|
|
209
|
+
}
|
|
210
|
+
function sanitizedHref(value, origin) {
|
|
211
|
+
if (!value)
|
|
212
|
+
return;
|
|
213
|
+
try {
|
|
214
|
+
const url = new URL(value, origin);
|
|
215
|
+
return url.origin === origin ? url.pathname : `${url.origin}${url.pathname}`;
|
|
216
|
+
} catch {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function resolveTrackedClick(target, { origin, attributes = {}, isAction = () => true }) {
|
|
221
|
+
if (!target)
|
|
222
|
+
return null;
|
|
223
|
+
const trackAttribute = attributes.track ?? "data-track";
|
|
224
|
+
const actionAttribute = attributes.action ?? "data-track-action";
|
|
225
|
+
const contextAttribute = attributes.context ?? "data-track-context";
|
|
226
|
+
const tracked = target.closest(`[${trackAttribute}], [${actionAttribute}]`);
|
|
227
|
+
const anchor = target.closest("a[href]");
|
|
228
|
+
const href = anchor?.getAttribute("href") ?? tracked?.getAttribute("href") ?? null;
|
|
229
|
+
let sameOriginNavigation = false;
|
|
230
|
+
let outbound = false;
|
|
231
|
+
if (href) {
|
|
232
|
+
try {
|
|
233
|
+
const url = new URL(href, origin);
|
|
234
|
+
sameOriginNavigation = url.origin === origin;
|
|
235
|
+
outbound = url.protocol.startsWith("http") && !sameOriginNavigation;
|
|
236
|
+
} catch {
|
|
237
|
+
sameOriginNavigation = false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const result = { leavesPage: sameOriginNavigation || outbound };
|
|
241
|
+
if (tracked) {
|
|
242
|
+
const action = tracked.getAttribute(actionAttribute);
|
|
243
|
+
const element = tracked.getAttribute(trackAttribute);
|
|
244
|
+
if (action && isAction(action)) {
|
|
245
|
+
result.interaction = {
|
|
246
|
+
action,
|
|
247
|
+
context: tracked.getAttribute(contextAttribute) ?? undefined
|
|
248
|
+
};
|
|
249
|
+
} else if (element) {
|
|
250
|
+
result.click = {
|
|
251
|
+
element,
|
|
252
|
+
elementText: label(tracked),
|
|
253
|
+
href: sanitizedHref(href, origin)
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (outbound && href) {
|
|
258
|
+
result.outbound = { href: sanitizedHref(href, origin) ?? href, label: label(anchor) };
|
|
259
|
+
}
|
|
260
|
+
return result.interaction || result.click || result.outbound ? result : null;
|
|
261
|
+
}
|
|
262
|
+
// src/tracking/client-listeners.ts
|
|
263
|
+
function wireTrackingListeners(deps) {
|
|
264
|
+
const { host, builtin } = deps;
|
|
265
|
+
const unsubscribe = [];
|
|
266
|
+
const renewThenFlush = () => void deps.renewVisit().then(() => deps.flushOutbox());
|
|
267
|
+
unsubscribe.push(host.on("online", renewThenFlush));
|
|
268
|
+
unsubscribe.push(host.interval(() => void deps.flushOutbox(), deps.heartbeatMs));
|
|
269
|
+
let hiddenAt = null;
|
|
270
|
+
let lastLeaveAt = Number.NEGATIVE_INFINITY;
|
|
271
|
+
const onHide = () => {
|
|
272
|
+
const at = host.now();
|
|
273
|
+
if (at - lastLeaveAt < 1000)
|
|
274
|
+
return;
|
|
275
|
+
lastLeaveAt = at;
|
|
276
|
+
deps.sendOnUnload(deps.leaveDraft(deps.currentPage()));
|
|
277
|
+
deps.releaseLease();
|
|
278
|
+
};
|
|
279
|
+
unsubscribe.push(host.on("pagehide", onHide));
|
|
280
|
+
unsubscribe.push(host.on("visibilitychange", () => {
|
|
281
|
+
if (!host.visible()) {
|
|
282
|
+
hiddenAt = host.wallClock();
|
|
283
|
+
onHide();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
deps.meter.checkpoint();
|
|
287
|
+
if (hiddenAt !== null && host.wallClock() - hiddenAt >= deps.renewAfterHiddenMs) {
|
|
288
|
+
renewThenFlush();
|
|
289
|
+
}
|
|
290
|
+
hiddenAt = null;
|
|
291
|
+
}));
|
|
292
|
+
unsubscribe.push(host.interval(() => {
|
|
293
|
+
deps.send([deps.draft(builtin.heartbeat, { ...deps.meter.heartbeat(host.visible()) })]);
|
|
294
|
+
}, deps.heartbeatMs));
|
|
295
|
+
unsubscribe.push(host.on("scroll", () => deps.scroll.record(host.scrollDepth())));
|
|
296
|
+
unsubscribe.push(host.interval(() => {
|
|
297
|
+
for (const milestone of deps.scroll.observe(host.scrollDepth())) {
|
|
298
|
+
deps.send([deps.draft(builtin.scrollDepth, { maxPercent: milestone })]);
|
|
299
|
+
}
|
|
300
|
+
}, 2000));
|
|
301
|
+
unsubscribe.push(host.onClick((target) => {
|
|
302
|
+
const click = resolveTrackedClick(target, {
|
|
303
|
+
origin: host.page().origin,
|
|
304
|
+
attributes: deps.clickAttributes,
|
|
305
|
+
isAction: deps.isAction
|
|
306
|
+
});
|
|
307
|
+
if (!click)
|
|
308
|
+
return;
|
|
309
|
+
const drafts = [];
|
|
310
|
+
if (click.interaction)
|
|
311
|
+
drafts.push(deps.draft(builtin.interaction, { ...click.interaction }));
|
|
312
|
+
if (click.click)
|
|
313
|
+
drafts.push(deps.draft(builtin.click, { ...click.click }));
|
|
314
|
+
if (click.outbound)
|
|
315
|
+
drafts.push(deps.draft(builtin.outboundClick, { ...click.outbound }));
|
|
316
|
+
if (click.leavesPage)
|
|
317
|
+
for (const item of drafts)
|
|
318
|
+
deps.sendOnUnload(item);
|
|
319
|
+
else
|
|
320
|
+
deps.send(drafts);
|
|
321
|
+
}));
|
|
322
|
+
return unsubscribe;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/tracking/delivery.ts
|
|
326
|
+
function isRetryable(error) {
|
|
327
|
+
return ApiError.is(error) && (error.status === 0 || error.status >= 500);
|
|
328
|
+
}
|
|
329
|
+
function isUnauthorized(error) {
|
|
330
|
+
return ApiError.is(error) && (error.status === 401 || error.status === 403);
|
|
331
|
+
}
|
|
332
|
+
async function deliverTrackingBatch({
|
|
333
|
+
request,
|
|
334
|
+
onFailure,
|
|
335
|
+
onUnauthorized,
|
|
336
|
+
wait = (delayMs) => new Promise((resolve) => setTimeout(resolve, delayMs)),
|
|
337
|
+
retryDelayMs = 250
|
|
338
|
+
}) {
|
|
339
|
+
let recovered = false;
|
|
340
|
+
for (let attempt = 0;attempt < 2; attempt += 1) {
|
|
341
|
+
try {
|
|
342
|
+
await request();
|
|
343
|
+
return "delivered";
|
|
344
|
+
} catch (error) {
|
|
345
|
+
if (attempt === 0 && isRetryable(error)) {
|
|
346
|
+
await wait(retryDelayMs);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (isUnauthorized(error) && onUnauthorized && !recovered) {
|
|
350
|
+
recovered = true;
|
|
351
|
+
if (await onUnauthorized())
|
|
352
|
+
continue;
|
|
353
|
+
return "auth-invalidated";
|
|
354
|
+
}
|
|
355
|
+
onFailure(error);
|
|
356
|
+
return "failed";
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return "failed";
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// src/tracking/sequence-reserve.ts
|
|
363
|
+
function createSequenceReserve(reserve, options = {}) {
|
|
364
|
+
const blockSize = options.blockSize ?? 16;
|
|
365
|
+
const lowWater = options.lowWater ?? 4;
|
|
366
|
+
const pool = [];
|
|
367
|
+
let pending = null;
|
|
368
|
+
let fallback = null;
|
|
369
|
+
const pushFallbackBlock = () => {
|
|
370
|
+
for (let i = 0;i < blockSize; i += 1) {
|
|
371
|
+
fallback = (fallback ?? 0) + 1;
|
|
372
|
+
pool.push(fallback);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
const refill = () => {
|
|
376
|
+
if (pending)
|
|
377
|
+
return pending;
|
|
378
|
+
if (fallback !== null) {
|
|
379
|
+
pushFallbackBlock();
|
|
380
|
+
return Promise.resolve();
|
|
381
|
+
}
|
|
382
|
+
pending = reserve(blockSize).then((reserved) => {
|
|
383
|
+
pool.push(...reserved);
|
|
384
|
+
}).catch((error) => {
|
|
385
|
+
fallback = (options.fallbackBase ?? (() => Math.floor(Math.random() * 1e6)))() * 1e6;
|
|
386
|
+
options.onUnavailable?.(error);
|
|
387
|
+
pushFallbackBlock();
|
|
388
|
+
}).finally(() => {
|
|
389
|
+
pending = null;
|
|
390
|
+
});
|
|
391
|
+
return pending;
|
|
392
|
+
};
|
|
393
|
+
return {
|
|
394
|
+
take() {
|
|
395
|
+
const next = pool.shift() ?? null;
|
|
396
|
+
if (pool.length < lowWater)
|
|
397
|
+
refill();
|
|
398
|
+
return next;
|
|
399
|
+
},
|
|
400
|
+
refill,
|
|
401
|
+
shared: () => fallback === null,
|
|
402
|
+
reset() {
|
|
403
|
+
fallback = null;
|
|
404
|
+
pool.length = 0;
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/tracking/client-visit.ts
|
|
410
|
+
function bootstrapTrackingVisit(deps, renew) {
|
|
411
|
+
const { visit, config, host, outbox, sequences, captureAttribution, fail } = deps;
|
|
412
|
+
if (!renew && visit.visitId && visit.browserStreamId)
|
|
413
|
+
return Promise.resolve(visit.visitId);
|
|
414
|
+
if (visit.bootstrapping)
|
|
415
|
+
return visit.bootstrapping;
|
|
416
|
+
const run = (async () => {
|
|
417
|
+
try {
|
|
418
|
+
const health = outbox ? await outbox.health() : { state: "unavailable", queued: 0, dropped: 0 };
|
|
419
|
+
const wasAvailable = visit.outboxAvailable;
|
|
420
|
+
visit.outboxAvailable = health.state === "available";
|
|
421
|
+
if (visit.outboxAvailable && !wasAvailable && !sequences.shared())
|
|
422
|
+
sequences.reset();
|
|
423
|
+
visit.browserStreamId = visit.outboxAvailable && outbox ? await outbox.streamId() : visit.browserStreamId ?? host.randomUUID();
|
|
424
|
+
await sequences.refill();
|
|
425
|
+
const page = host.page();
|
|
426
|
+
const touch = captureAttribution(page.search, page.pathname);
|
|
427
|
+
const response = await config.bootstrap({
|
|
428
|
+
browserStreamId: visit.browserStreamId,
|
|
429
|
+
previousVisitId: visit.visitId ?? undefined,
|
|
430
|
+
origin: page.origin,
|
|
431
|
+
landingPath: page.pathname,
|
|
432
|
+
referrer: page.referrer || undefined,
|
|
433
|
+
utm: touch?.currentTouch.utm?.source ? touch.currentTouch.utm : undefined,
|
|
434
|
+
displayMode: page.displayMode,
|
|
435
|
+
screenWidth: page.screenWidth,
|
|
436
|
+
screenHeight: page.screenHeight,
|
|
437
|
+
buildId: config.buildId,
|
|
438
|
+
outboxState: health.state,
|
|
439
|
+
outboxQueued: health.queued,
|
|
440
|
+
outboxDropped: health.dropped
|
|
441
|
+
});
|
|
442
|
+
visit.visitId = response.visitId;
|
|
443
|
+
config.onVisit?.(visit.visitId);
|
|
444
|
+
return visit.visitId;
|
|
445
|
+
} catch (error) {
|
|
446
|
+
fail("visit bootstrap", error);
|
|
447
|
+
return null;
|
|
448
|
+
} finally {
|
|
449
|
+
visit.bootstrapping = null;
|
|
450
|
+
}
|
|
451
|
+
})();
|
|
452
|
+
visit.bootstrapping = run;
|
|
453
|
+
return run;
|
|
454
|
+
}
|
|
455
|
+
function createOutboxFlusher(deps) {
|
|
456
|
+
const { outbox } = deps;
|
|
457
|
+
let flushing = null;
|
|
458
|
+
let queued = null;
|
|
459
|
+
const flushOutbox = () => {
|
|
460
|
+
if (!outbox || !deps.isAvailable())
|
|
461
|
+
return Promise.resolve();
|
|
462
|
+
if (flushing) {
|
|
463
|
+
queued ??= flushing.then(() => {
|
|
464
|
+
queued = null;
|
|
465
|
+
return flushOutbox();
|
|
466
|
+
});
|
|
467
|
+
return queued;
|
|
468
|
+
}
|
|
469
|
+
flushing = (async () => {
|
|
470
|
+
try {
|
|
471
|
+
if (!await outbox.acquireLease(deps.owner))
|
|
472
|
+
return;
|
|
473
|
+
const batch = await outbox.readBatch(deps.batchSize);
|
|
474
|
+
if (batch.length === 0)
|
|
475
|
+
return;
|
|
476
|
+
const response = await deps.deliver(batch);
|
|
477
|
+
if (response) {
|
|
478
|
+
await outbox.acknowledge(response.dispositions.map((item) => item.eventId));
|
|
479
|
+
}
|
|
480
|
+
} catch (error) {
|
|
481
|
+
deps.fail("outbox flush", error);
|
|
482
|
+
} finally {
|
|
483
|
+
flushing = null;
|
|
484
|
+
}
|
|
485
|
+
})();
|
|
486
|
+
return flushing;
|
|
487
|
+
};
|
|
488
|
+
return flushOutbox;
|
|
489
|
+
}
|
|
490
|
+
function createVisitSequences(outbox, visit, options, fail) {
|
|
491
|
+
return createSequenceReserve((count) => {
|
|
492
|
+
if (!outbox || !visit.outboxAvailable)
|
|
493
|
+
return Promise.reject(new Error("outbox unavailable"));
|
|
494
|
+
return outbox.reserveSequences(count);
|
|
495
|
+
}, {
|
|
496
|
+
...options,
|
|
497
|
+
onUnavailable: outbox ? (error) => {
|
|
498
|
+
visit.outboxAvailable = false;
|
|
499
|
+
fail("sequence reservation", error);
|
|
500
|
+
} : undefined
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
function pageAttribution(host, storage, referrerMap, search, pathname) {
|
|
504
|
+
const page = host.page();
|
|
505
|
+
return resolveAttribution({
|
|
506
|
+
search,
|
|
507
|
+
pathname,
|
|
508
|
+
referrer: page.referrer,
|
|
509
|
+
hostname: page.hostname,
|
|
510
|
+
storage,
|
|
511
|
+
referrerMap,
|
|
512
|
+
now: host.wallClock()
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function pageViewDraft(host, type, pathname, previous) {
|
|
516
|
+
const page = host.page();
|
|
517
|
+
return {
|
|
518
|
+
type,
|
|
519
|
+
page: pathname,
|
|
520
|
+
metadata: {
|
|
521
|
+
title: page.title,
|
|
522
|
+
screenWidth: page.viewportWidth,
|
|
523
|
+
screenHeight: page.viewportHeight,
|
|
524
|
+
referrer: previous ? undefined : page.referrer || undefined
|
|
525
|
+
},
|
|
526
|
+
clientTimestamp: host.wallClock()
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
async function materializeAll(drafts, materialize, sequences) {
|
|
530
|
+
const events = [];
|
|
531
|
+
for (const draft of drafts) {
|
|
532
|
+
let event = materialize(draft);
|
|
533
|
+
if (!event) {
|
|
534
|
+
await sequences.refill();
|
|
535
|
+
event = materialize(draft);
|
|
536
|
+
}
|
|
537
|
+
if (event)
|
|
538
|
+
events.push(event);
|
|
539
|
+
}
|
|
540
|
+
return events;
|
|
541
|
+
}
|
|
542
|
+
async function deliverTrackedEvents(config, request, fail) {
|
|
543
|
+
let response = null;
|
|
544
|
+
const outcome = await deliverTrackingBatch({
|
|
545
|
+
request: async () => {
|
|
546
|
+
response = await config.deliver(request);
|
|
547
|
+
},
|
|
548
|
+
onUnauthorized: config.onUnauthorized,
|
|
549
|
+
onFailure: (error) => fail("event delivery", error)
|
|
550
|
+
});
|
|
551
|
+
return outcome === "delivered" ? response : null;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/tracking/scroll.ts
|
|
555
|
+
function scrollDepthPercent(view) {
|
|
556
|
+
const scrollable = view.scrollHeight - view.innerHeight;
|
|
557
|
+
if (scrollable <= 0)
|
|
558
|
+
return 0;
|
|
559
|
+
return Math.max(0, Math.min(100, Math.round(view.scrollY / scrollable * 100)));
|
|
560
|
+
}
|
|
561
|
+
function createScrollMilestones(milestones = [25, 50, 75, 100]) {
|
|
562
|
+
const sorted = [...milestones].sort((a, b) => a - b);
|
|
563
|
+
let deepest = 0;
|
|
564
|
+
const fired = new Set;
|
|
565
|
+
return {
|
|
566
|
+
record(percent) {
|
|
567
|
+
deepest = Math.max(deepest, percent);
|
|
568
|
+
},
|
|
569
|
+
observe(percent) {
|
|
570
|
+
deepest = Math.max(deepest, percent);
|
|
571
|
+
const reached = [];
|
|
572
|
+
for (const milestone of sorted) {
|
|
573
|
+
if (deepest >= milestone && !fired.has(milestone)) {
|
|
574
|
+
fired.add(milestone);
|
|
575
|
+
reached.push(milestone);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return reached;
|
|
579
|
+
},
|
|
580
|
+
max: () => deepest,
|
|
581
|
+
reset() {
|
|
582
|
+
deepest = 0;
|
|
583
|
+
fired.clear();
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// src/tracking/visible-time.ts
|
|
589
|
+
function createVisibleTimeMeter(options = {}) {
|
|
590
|
+
const now = options.now ?? (() => performance.now());
|
|
591
|
+
const wallClock = options.wallClock ?? (() => Date.now());
|
|
592
|
+
const randomUUID = options.randomUUID ?? (() => crypto.randomUUID());
|
|
593
|
+
let checkpointAt = now();
|
|
594
|
+
const cut = () => {
|
|
595
|
+
const at = now();
|
|
596
|
+
const activeDurationMs = Math.max(0, Math.round(at - checkpointAt));
|
|
597
|
+
checkpointAt = at;
|
|
598
|
+
return {
|
|
599
|
+
activeIntervalId: randomUUID(),
|
|
600
|
+
activeDurationMs,
|
|
601
|
+
intervalStartedAt: wallClock() - activeDurationMs
|
|
602
|
+
};
|
|
603
|
+
};
|
|
604
|
+
return {
|
|
605
|
+
checkpoint() {
|
|
606
|
+
checkpointAt = now();
|
|
607
|
+
},
|
|
608
|
+
cut,
|
|
609
|
+
heartbeat(visible) {
|
|
610
|
+
if (visible)
|
|
611
|
+
return { ...cut(), isVisible: true };
|
|
612
|
+
return { isVisible: false, activeDurationMs: 0 };
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// src/tracking/client.ts
|
|
618
|
+
var CONVENTIONAL_TRACKING_EVENT_TYPES = {
|
|
619
|
+
pageView: "PAGE_VIEW",
|
|
620
|
+
pageLeave: "PAGE_LEAVE",
|
|
621
|
+
scrollDepth: "SCROLL_DEPTH",
|
|
622
|
+
heartbeat: "SESSION_HEARTBEAT",
|
|
623
|
+
click: "CLICK",
|
|
624
|
+
outboundClick: "OUTBOUND_CLICK",
|
|
625
|
+
interaction: "INTERACTION"
|
|
626
|
+
};
|
|
627
|
+
function chunk(items, size) {
|
|
628
|
+
const chunks = [];
|
|
629
|
+
for (let at = 0;at < items.length; at += size)
|
|
630
|
+
chunks.push(items.slice(at, at + size));
|
|
631
|
+
return chunks;
|
|
632
|
+
}
|
|
633
|
+
function unloadBeacon(unloadUrl) {
|
|
634
|
+
return (request) => unloadUrl === undefined ? false : sendUnloadBeacon(unloadUrl, JSON.stringify(request));
|
|
635
|
+
}
|
|
636
|
+
function currentUtmOf(attribution) {
|
|
637
|
+
return attribution?.currentTouch.utm?.source ? attribution.currentTouch.utm : undefined;
|
|
638
|
+
}
|
|
639
|
+
function trackingTimings(config) {
|
|
640
|
+
if (typeof config.buildId !== "string" || config.buildId.length === 0) {
|
|
641
|
+
throw new Error('[stitchkit] tracking client requires a buildId — a git SHA or "dev"');
|
|
642
|
+
}
|
|
643
|
+
return {
|
|
644
|
+
heartbeatMs: config.heartbeatMs ?? 30000,
|
|
645
|
+
renewAfterHiddenMs: config.renewAfterHiddenMs ?? 30 * 60 * 1000,
|
|
646
|
+
pendingLimit: config.pendingLimit ?? 100,
|
|
647
|
+
batchSize: config.batchSize ?? 50
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
function createTrackingClient(config) {
|
|
651
|
+
const { host, builtin, outbox } = config;
|
|
652
|
+
const { heartbeatMs, renewAfterHiddenMs, pendingLimit, batchSize } = trackingTimings(config);
|
|
653
|
+
const fail = config.onFailure ?? (() => {
|
|
654
|
+
return;
|
|
655
|
+
});
|
|
656
|
+
const decorate = config.decorate ?? ((event) => event);
|
|
657
|
+
const unload = config.unload ?? unloadBeacon(config.unloadUrl);
|
|
658
|
+
const visit = {
|
|
659
|
+
browserStreamId: null,
|
|
660
|
+
visitId: null,
|
|
661
|
+
outboxAvailable: outbox !== undefined,
|
|
662
|
+
bootstrapping: null
|
|
663
|
+
};
|
|
664
|
+
let pending = [];
|
|
665
|
+
let currentPage = null;
|
|
666
|
+
let attribution = null;
|
|
667
|
+
let running = 0;
|
|
668
|
+
const flushOwner = host.randomUUID();
|
|
669
|
+
const meter = createVisibleTimeMeter(host);
|
|
670
|
+
const scroll = createScrollMilestones(config.scrollMilestones);
|
|
671
|
+
const sequences = createVisitSequences(outbox, visit, config.sequence, fail);
|
|
672
|
+
const captureAttribution = (search, pathname) => {
|
|
673
|
+
if (!host.storage)
|
|
674
|
+
return null;
|
|
675
|
+
attribution = pageAttribution(host, host.storage, config.referrerMap, search, pathname);
|
|
676
|
+
return attribution;
|
|
677
|
+
};
|
|
678
|
+
const bootstrapVisit = (renew = false) => bootstrapTrackingVisit({ visit, config, host, outbox, sequences, captureAttribution, fail }, renew);
|
|
679
|
+
const deliver = (events) => deliverTrackedEvents(config, { buildId: config.buildId, events, utm: currentUtmOf(attribution) }, fail);
|
|
680
|
+
const flushOutbox = createOutboxFlusher({
|
|
681
|
+
outbox,
|
|
682
|
+
isAvailable: () => visit.outboxAvailable,
|
|
683
|
+
owner: flushOwner,
|
|
684
|
+
batchSize,
|
|
685
|
+
deliver,
|
|
686
|
+
fail
|
|
687
|
+
});
|
|
688
|
+
const materialize = (draft2) => {
|
|
689
|
+
if (!visit.visitId || !visit.browserStreamId)
|
|
690
|
+
return null;
|
|
691
|
+
const sequence = sequences.take();
|
|
692
|
+
if (sequence === null)
|
|
693
|
+
return null;
|
|
694
|
+
return decorate({
|
|
695
|
+
...draft2,
|
|
696
|
+
eventId: host.randomUUID(),
|
|
697
|
+
visitId: visit.visitId,
|
|
698
|
+
browserStreamId: visit.browserStreamId,
|
|
699
|
+
browserSequence: sequence
|
|
700
|
+
});
|
|
701
|
+
};
|
|
702
|
+
const persistAndFlush = async (events) => {
|
|
703
|
+
if (!outbox || !visit.outboxAvailable) {
|
|
704
|
+
for (const batch of chunk(events, batchSize))
|
|
705
|
+
await deliver(batch);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
try {
|
|
709
|
+
for (const event of events)
|
|
710
|
+
await outbox.enqueue(event);
|
|
711
|
+
await flushOutbox();
|
|
712
|
+
} catch (error) {
|
|
713
|
+
fail("event persistence", error);
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
const drainPending = () => {
|
|
717
|
+
const drafts = pending.splice(0);
|
|
718
|
+
if (drafts.length > 0)
|
|
719
|
+
send(drafts);
|
|
720
|
+
};
|
|
721
|
+
const send = (drafts) => {
|
|
722
|
+
if (!visit.visitId || !visit.browserStreamId) {
|
|
723
|
+
pending = [...pending, ...drafts].slice(-pendingLimit);
|
|
724
|
+
bootstrapVisit().then((issued) => {
|
|
725
|
+
if (issued)
|
|
726
|
+
drainPending();
|
|
727
|
+
});
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
materializeAll(drafts, materialize, sequences).then(async (events) => {
|
|
731
|
+
if (events.length > 0)
|
|
732
|
+
await persistAndFlush(events);
|
|
733
|
+
});
|
|
734
|
+
};
|
|
735
|
+
const sendOnUnload = (draft2) => {
|
|
736
|
+
const event = materialize(draft2);
|
|
737
|
+
if (!event) {
|
|
738
|
+
send([draft2]);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
unload({ buildId: config.buildId, events: [event], utm: currentUtmOf(attribution) });
|
|
742
|
+
if (outbox && visit.outboxAvailable)
|
|
743
|
+
outbox.enqueue(event).catch((error) => fail("unload event persistence", error));
|
|
744
|
+
};
|
|
745
|
+
const draft = (type, metadata) => {
|
|
746
|
+
const page = currentPage ?? host.page().pathname;
|
|
747
|
+
return { type, page, metadata, clientTimestamp: host.wallClock() };
|
|
748
|
+
};
|
|
749
|
+
const leaveDraft = (page) => {
|
|
750
|
+
const metadata = { ...meter.cut(), scrollDepthPercent: scroll.max() };
|
|
751
|
+
return { type: builtin.pageLeave, page, metadata, clientTimestamp: host.wallClock() };
|
|
752
|
+
};
|
|
753
|
+
const track = (type, metadata) => send([draft(type, metadata === undefined ? undefined : asMetadata(metadata))]);
|
|
754
|
+
const onNavigate = (pathname, search) => {
|
|
755
|
+
captureAttribution(search, pathname);
|
|
756
|
+
const previous = currentPage;
|
|
757
|
+
if (previous === pathname)
|
|
758
|
+
return;
|
|
759
|
+
if (previous && host.visible())
|
|
760
|
+
send([leaveDraft(previous)]);
|
|
761
|
+
currentPage = pathname;
|
|
762
|
+
meter.checkpoint();
|
|
763
|
+
scroll.reset();
|
|
764
|
+
send([pageViewDraft(host, builtin.pageView, pathname, previous)]);
|
|
765
|
+
};
|
|
766
|
+
const start = () => {
|
|
767
|
+
const generation = ++running;
|
|
768
|
+
bootstrapVisit().then((issued) => {
|
|
769
|
+
if (!issued || generation !== running)
|
|
770
|
+
return;
|
|
771
|
+
drainPending();
|
|
772
|
+
flushOutbox();
|
|
773
|
+
});
|
|
774
|
+
const unsubscribe = wireTrackingListeners({
|
|
775
|
+
host,
|
|
776
|
+
builtin,
|
|
777
|
+
heartbeatMs,
|
|
778
|
+
renewAfterHiddenMs,
|
|
779
|
+
meter,
|
|
780
|
+
scroll,
|
|
781
|
+
draft,
|
|
782
|
+
leaveDraft,
|
|
783
|
+
send,
|
|
784
|
+
sendOnUnload,
|
|
785
|
+
flushOutbox,
|
|
786
|
+
renewVisit: () => bootstrapVisit(true),
|
|
787
|
+
currentPage: () => currentPage ?? host.page().pathname,
|
|
788
|
+
releaseLease: () => {
|
|
789
|
+
if (outbox && visit.outboxAvailable)
|
|
790
|
+
outbox.releaseLease(flushOwner).catch(() => {
|
|
791
|
+
return;
|
|
792
|
+
});
|
|
793
|
+
},
|
|
794
|
+
clickAttributes: config.clickAttributes,
|
|
795
|
+
isAction: config.isAction
|
|
796
|
+
});
|
|
797
|
+
return () => {
|
|
798
|
+
running += 1;
|
|
799
|
+
for (const off of unsubscribe.splice(0))
|
|
800
|
+
off();
|
|
801
|
+
};
|
|
802
|
+
};
|
|
803
|
+
return {
|
|
804
|
+
track,
|
|
805
|
+
onNavigate,
|
|
806
|
+
start,
|
|
807
|
+
visitId: () => visit.visitId,
|
|
808
|
+
browserStreamId: () => visit.browserStreamId,
|
|
809
|
+
attribution: () => attribution
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
function asMetadata(value) {
|
|
813
|
+
return typeof value === "object" && value !== null ? { ...value } : undefined;
|
|
814
|
+
}
|
|
815
|
+
// src/tracking/contract.ts
|
|
816
|
+
function createTrackingContract(config) {
|
|
817
|
+
const schemas = createTrackingSchemas(config);
|
|
818
|
+
return defineContract({ prefix: config.prefix ?? "tracking", scope: config.scope }, {
|
|
819
|
+
bootstrap: {
|
|
820
|
+
method: "POST",
|
|
821
|
+
path: "/visit",
|
|
822
|
+
expose: ["HTTP"],
|
|
823
|
+
desc: "Issue or renew a browser visit lease",
|
|
824
|
+
input: schemas.entry,
|
|
825
|
+
output: schemas.bootstrap
|
|
826
|
+
},
|
|
827
|
+
track: {
|
|
828
|
+
method: "POST",
|
|
829
|
+
path: "/events",
|
|
830
|
+
expose: ["HTTP"],
|
|
831
|
+
desc: "Batch track browser events",
|
|
832
|
+
input: schemas.request,
|
|
833
|
+
output: schemas.response,
|
|
834
|
+
safelistedBody: true,
|
|
835
|
+
maxJsonBodyBytes: config.maxJsonBodyBytes ?? 256 * 1024
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
// src/tracking/host.ts
|
|
840
|
+
function browserTrackingHost() {
|
|
841
|
+
return {
|
|
842
|
+
page: () => ({
|
|
843
|
+
pathname: window.location.pathname,
|
|
844
|
+
search: window.location.search,
|
|
845
|
+
origin: window.location.origin,
|
|
846
|
+
hostname: window.location.hostname,
|
|
847
|
+
title: document.title,
|
|
848
|
+
referrer: document.referrer,
|
|
849
|
+
viewportWidth: window.innerWidth,
|
|
850
|
+
viewportHeight: window.innerHeight,
|
|
851
|
+
screenWidth: window.screen.width,
|
|
852
|
+
screenHeight: window.screen.height,
|
|
853
|
+
displayMode: window.matchMedia("(display-mode: standalone)").matches ? "standalone" : "browser"
|
|
854
|
+
}),
|
|
855
|
+
visible: () => document.visibilityState === "visible",
|
|
856
|
+
scrollDepth() {
|
|
857
|
+
const scrollable = document.documentElement.scrollHeight - window.innerHeight;
|
|
858
|
+
if (scrollable <= 0)
|
|
859
|
+
return 0;
|
|
860
|
+
return Math.max(0, Math.min(100, Math.round(window.scrollY / scrollable * 100)));
|
|
861
|
+
},
|
|
862
|
+
on(event, handler) {
|
|
863
|
+
const target = event === "visibilitychange" ? document : window;
|
|
864
|
+
const options = event === "scroll" ? { passive: true } : undefined;
|
|
865
|
+
target.addEventListener(event, handler, options);
|
|
866
|
+
return () => target.removeEventListener(event, handler);
|
|
867
|
+
},
|
|
868
|
+
onClick(handler) {
|
|
869
|
+
const listener = (event) => {
|
|
870
|
+
handler(event.target instanceof Element ? event.target : null);
|
|
871
|
+
};
|
|
872
|
+
document.addEventListener("click", listener, { capture: true });
|
|
873
|
+
return () => document.removeEventListener("click", listener, { capture: true });
|
|
874
|
+
},
|
|
875
|
+
interval(handler, ms) {
|
|
876
|
+
const id = window.setInterval(handler, ms);
|
|
877
|
+
return () => window.clearInterval(id);
|
|
878
|
+
},
|
|
879
|
+
now: () => performance.now(),
|
|
880
|
+
wallClock: () => Date.now(),
|
|
881
|
+
randomUUID: () => crypto.randomUUID(),
|
|
882
|
+
storage: (() => {
|
|
883
|
+
try {
|
|
884
|
+
return window.localStorage;
|
|
885
|
+
} catch {
|
|
886
|
+
return null;
|
|
887
|
+
}
|
|
888
|
+
})()
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
// src/tracking/once-per-page.ts
|
|
892
|
+
function createOncePerPage(options = {}) {
|
|
893
|
+
const windowMs = options.windowMs ?? 15000;
|
|
894
|
+
const now = options.now ?? (() => Date.now());
|
|
895
|
+
const seen = new Map;
|
|
896
|
+
return {
|
|
897
|
+
should(key, page) {
|
|
898
|
+
const scoped = `${page}|${key}`;
|
|
899
|
+
const at = now();
|
|
900
|
+
const last = seen.get(scoped);
|
|
901
|
+
if (last !== undefined && at - last < windowMs)
|
|
902
|
+
return false;
|
|
903
|
+
seen.set(scoped, at);
|
|
904
|
+
return true;
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
// src/tracking/outbox.ts
|
|
909
|
+
var META_STREAM = "streamId";
|
|
910
|
+
var META_SEQUENCE = "sequence";
|
|
911
|
+
var META_LEASE = "lease";
|
|
912
|
+
var META_DROPPED = "dropped";
|
|
913
|
+
function numberOr(value, fallback) {
|
|
914
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
915
|
+
}
|
|
916
|
+
function leaseOf(raw) {
|
|
917
|
+
if (typeof raw !== "object" || raw === null)
|
|
918
|
+
return null;
|
|
919
|
+
const owner = Reflect.get(raw, "owner");
|
|
920
|
+
const expiresAt = Reflect.get(raw, "expiresAt");
|
|
921
|
+
return typeof owner === "string" && typeof expiresAt === "number" ? { owner, expiresAt } : null;
|
|
922
|
+
}
|
|
923
|
+
function createTrackingOutbox(storage, options = {}) {
|
|
924
|
+
const maxEvents = options.maxEvents ?? 1000;
|
|
925
|
+
const maxAgeMs = options.maxAgeMs ?? 7 * 24 * 60 * 60 * 1000;
|
|
926
|
+
const leaseMs = options.leaseMs ?? 3000;
|
|
927
|
+
const now = options.now ?? (() => Date.now());
|
|
928
|
+
const randomUUID = options.randomUUID ?? (() => crypto.randomUUID());
|
|
929
|
+
const trim = () => storage.transact(async ({ meta, events }) => {
|
|
930
|
+
const all = await events.all();
|
|
931
|
+
const cutoff = now() - maxAgeMs;
|
|
932
|
+
const remove = all.filter((record, index) => record.enqueuedAt < cutoff || index < all.length - maxEvents);
|
|
933
|
+
for (const record of remove)
|
|
934
|
+
events.delete(record.event.eventId);
|
|
935
|
+
if (remove.length > 0) {
|
|
936
|
+
meta.put(META_DROPPED, numberOr(await meta.get(META_DROPPED), 0) + remove.length);
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
return {
|
|
940
|
+
streamId: () => storage.transact(async ({ meta }) => {
|
|
941
|
+
const existing = await meta.get(META_STREAM);
|
|
942
|
+
if (typeof existing === "string")
|
|
943
|
+
return existing;
|
|
944
|
+
const created = randomUUID();
|
|
945
|
+
meta.put(META_STREAM, created);
|
|
946
|
+
return created;
|
|
947
|
+
}),
|
|
948
|
+
reserveSequences: (count) => storage.transact(async ({ meta }) => {
|
|
949
|
+
const start = numberOr(await meta.get(META_SEQUENCE), 0) + 1;
|
|
950
|
+
meta.put(META_SEQUENCE, start + count - 1);
|
|
951
|
+
return Array.from({ length: count }, (_, index) => start + index);
|
|
952
|
+
}),
|
|
953
|
+
async enqueue(event) {
|
|
954
|
+
await storage.transact(async ({ events }) => {
|
|
955
|
+
events.put({ event, enqueuedAt: now() });
|
|
956
|
+
});
|
|
957
|
+
await trim();
|
|
958
|
+
},
|
|
959
|
+
acquireLease: (owner) => storage.transact(async ({ meta }) => {
|
|
960
|
+
const lease = leaseOf(await meta.get(META_LEASE));
|
|
961
|
+
const at = now();
|
|
962
|
+
const acquired = lease === null || lease.owner === owner || lease.expiresAt <= at;
|
|
963
|
+
if (acquired)
|
|
964
|
+
meta.put(META_LEASE, { owner, expiresAt: at + leaseMs });
|
|
965
|
+
return acquired;
|
|
966
|
+
}),
|
|
967
|
+
releaseLease: (owner) => storage.transact(async ({ meta }) => {
|
|
968
|
+
const lease = leaseOf(await meta.get(META_LEASE));
|
|
969
|
+
if (lease?.owner === owner)
|
|
970
|
+
meta.delete(META_LEASE);
|
|
971
|
+
}),
|
|
972
|
+
readBatch: (limit = 50) => storage.transact(async ({ events }) => (await events.all()).slice(0, limit).map((record) => record.event), "readonly"),
|
|
973
|
+
acknowledge: async (eventIds) => {
|
|
974
|
+
if (eventIds.length === 0)
|
|
975
|
+
return;
|
|
976
|
+
await storage.transact(async ({ events }) => {
|
|
977
|
+
for (const id of eventIds)
|
|
978
|
+
events.delete(id);
|
|
979
|
+
});
|
|
980
|
+
},
|
|
981
|
+
async health() {
|
|
982
|
+
try {
|
|
983
|
+
return await storage.transact(async ({ meta, events }) => ({
|
|
984
|
+
state: "available",
|
|
985
|
+
queued: await events.count(),
|
|
986
|
+
dropped: numberOr(await meta.get(META_DROPPED), 0)
|
|
987
|
+
}), "readonly");
|
|
988
|
+
} catch {
|
|
989
|
+
return { state: "unavailable", queued: 0, dropped: 0 };
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
// src/tracking/outbox-storage-indexeddb.ts
|
|
995
|
+
var VERSION = 1;
|
|
996
|
+
var EVENTS = "events";
|
|
997
|
+
var META = "meta";
|
|
998
|
+
function requestResult(request) {
|
|
999
|
+
return new Promise((resolve, reject) => {
|
|
1000
|
+
request.onsuccess = () => resolve(request.result);
|
|
1001
|
+
request.onerror = () => reject(request.error);
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
function transactionDone(transaction) {
|
|
1005
|
+
return new Promise((resolve, reject) => {
|
|
1006
|
+
transaction.oncomplete = () => resolve();
|
|
1007
|
+
const failure = (event) => {
|
|
1008
|
+
const target = event.target;
|
|
1009
|
+
if (typeof target === "object" && target !== null && "error" in target && target.error instanceof Error) {
|
|
1010
|
+
return target.error;
|
|
1011
|
+
}
|
|
1012
|
+
return transaction.error ?? new Error("IndexedDB transaction aborted");
|
|
1013
|
+
};
|
|
1014
|
+
transaction.onerror = (event) => reject(failure(event));
|
|
1015
|
+
transaction.onabort = (event) => reject(failure(event));
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
function openDatabase(name, factory) {
|
|
1019
|
+
return new Promise((resolve, reject) => {
|
|
1020
|
+
const request = factory.open(name, VERSION);
|
|
1021
|
+
request.onupgradeneeded = () => {
|
|
1022
|
+
const database = request.result;
|
|
1023
|
+
if (!database.objectStoreNames.contains(EVENTS)) {
|
|
1024
|
+
const events = database.createObjectStore(EVENTS, { keyPath: "event.eventId" });
|
|
1025
|
+
events.createIndex("sequence", "event.browserSequence", { unique: true });
|
|
1026
|
+
}
|
|
1027
|
+
if (!database.objectStoreNames.contains(META))
|
|
1028
|
+
database.createObjectStore(META);
|
|
1029
|
+
};
|
|
1030
|
+
request.onsuccess = () => resolve(request.result);
|
|
1031
|
+
request.onerror = () => reject(request.error);
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
function indexedDbOutboxStorage(name, factory = () => indexedDB) {
|
|
1035
|
+
return {
|
|
1036
|
+
async transact(fn, mode = "readwrite") {
|
|
1037
|
+
const database = await openDatabase(name, factory());
|
|
1038
|
+
try {
|
|
1039
|
+
const transaction = database.transaction([META, EVENTS], mode);
|
|
1040
|
+
const meta = transaction.objectStore(META);
|
|
1041
|
+
const events = transaction.objectStore(EVENTS);
|
|
1042
|
+
let result;
|
|
1043
|
+
try {
|
|
1044
|
+
result = await fn({
|
|
1045
|
+
meta: {
|
|
1046
|
+
get: (key) => requestResult(meta.get(key)),
|
|
1047
|
+
put: (key, value) => void meta.put(value, key),
|
|
1048
|
+
delete: (key) => void meta.delete(key)
|
|
1049
|
+
},
|
|
1050
|
+
events: {
|
|
1051
|
+
put: (record) => void events.put(record),
|
|
1052
|
+
delete: (eventId) => void events.delete(eventId),
|
|
1053
|
+
all: async () => {
|
|
1054
|
+
const raw = await requestResult(events.index("sequence").getAll());
|
|
1055
|
+
return raw.flatMap((value) => isRecord(value) ? [value] : []);
|
|
1056
|
+
},
|
|
1057
|
+
count: () => requestResult(events.count())
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
} catch (error) {
|
|
1061
|
+
transaction.abort();
|
|
1062
|
+
throw error;
|
|
1063
|
+
}
|
|
1064
|
+
await transactionDone(transaction);
|
|
1065
|
+
return result;
|
|
1066
|
+
} finally {
|
|
1067
|
+
database.close();
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
function isRecord(value) {
|
|
1073
|
+
if (typeof value !== "object" || value === null)
|
|
1074
|
+
return false;
|
|
1075
|
+
const event = Reflect.get(value, "event");
|
|
1076
|
+
return typeof Reflect.get(value, "enqueuedAt") === "number" && typeof event === "object" && event !== null && typeof Reflect.get(event, "eventId") === "string" && typeof Reflect.get(event, "browserSequence") === "number";
|
|
1077
|
+
}
|
|
1078
|
+
// src/tracking/outbox-storage-memory.ts
|
|
1079
|
+
function memoryOutboxStorage() {
|
|
1080
|
+
let meta = new Map;
|
|
1081
|
+
let events = new Map;
|
|
1082
|
+
let chain = Promise.resolve();
|
|
1083
|
+
return {
|
|
1084
|
+
transact(fn) {
|
|
1085
|
+
const run = chain.then(async () => {
|
|
1086
|
+
const nextMeta = new Map(meta);
|
|
1087
|
+
const nextEvents = new Map(events);
|
|
1088
|
+
const result = await fn({
|
|
1089
|
+
meta: {
|
|
1090
|
+
get: async (key) => nextMeta.get(key),
|
|
1091
|
+
put: (key, value) => void nextMeta.set(key, value),
|
|
1092
|
+
delete: (key) => void nextMeta.delete(key)
|
|
1093
|
+
},
|
|
1094
|
+
events: {
|
|
1095
|
+
put: (record) => void nextEvents.set(record.event.eventId, record),
|
|
1096
|
+
delete: (eventId) => void nextEvents.delete(eventId),
|
|
1097
|
+
all: async () => [...nextEvents.values()].sort((a, b) => a.event.browserSequence - b.event.browserSequence),
|
|
1098
|
+
count: async () => nextEvents.size
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
meta = nextMeta;
|
|
1102
|
+
events = nextEvents;
|
|
1103
|
+
return result;
|
|
1104
|
+
});
|
|
1105
|
+
chain = run.catch(() => {
|
|
1106
|
+
return;
|
|
1107
|
+
});
|
|
1108
|
+
return run;
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
export {
|
|
1113
|
+
sendUnloadBeacon,
|
|
1114
|
+
scrollDepthPercent,
|
|
1115
|
+
resolveTrackedClick,
|
|
1116
|
+
resolveAttribution,
|
|
1117
|
+
parseUtmFromSearch,
|
|
1118
|
+
parseReferrer,
|
|
1119
|
+
memoryOutboxStorage,
|
|
1120
|
+
indexedDbOutboxStorage,
|
|
1121
|
+
deliverTrackingBatch,
|
|
1122
|
+
createVisibleTimeMeter,
|
|
1123
|
+
createTrackingSchemas,
|
|
1124
|
+
createTrackingOutbox,
|
|
1125
|
+
createTrackingContract,
|
|
1126
|
+
createTrackingClient,
|
|
1127
|
+
createSequenceReserve,
|
|
1128
|
+
createScrollMilestones,
|
|
1129
|
+
createOncePerPage,
|
|
1130
|
+
browserTrackingHost,
|
|
1131
|
+
VisitBootstrapResponseSchema,
|
|
1132
|
+
UtmDataSchema,
|
|
1133
|
+
TrackingOutboxStateSchema,
|
|
1134
|
+
TrackingDispositionStatusSchema,
|
|
1135
|
+
TrackingDispositionSchema,
|
|
1136
|
+
TrackEventsResponseSchema,
|
|
1137
|
+
DEFAULT_BUILD_ID_PATTERN,
|
|
1138
|
+
CONVENTIONAL_TRACKING_EVENT_TYPES,
|
|
1139
|
+
AttributionDataSchema
|
|
1140
|
+
};
|