@senpi/runtime 3.0.6-dev.skill-manager-v2.20260629194505 → 3.0.9-dev.20260710204324
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/dist/actions/action-events.d.ts +67 -0
- package/dist/actions/action-events.d.ts.map +1 -0
- package/dist/actions/action-events.js +164 -0
- package/dist/actions/action-events.js.map +1 -0
- package/dist/actions/close-position/close-position.action.d.ts +1 -1
- package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +108 -86
- package/dist/actions/close-position/close-position.action.js.map +1 -1
- package/dist/actions/decision-engine.d.ts.map +1 -1
- package/dist/actions/decision-engine.js +40 -28
- package/dist/actions/decision-engine.js.map +1 -1
- package/dist/actions/event-derivation.d.ts +61 -0
- package/dist/actions/event-derivation.d.ts.map +1 -0
- package/dist/actions/event-derivation.js +180 -0
- package/dist/actions/event-derivation.js.map +1 -0
- package/dist/actions/llm-decision/anthropic-llm-decision.d.ts +5 -9
- package/dist/actions/llm-decision/anthropic-llm-decision.d.ts.map +1 -1
- package/dist/actions/llm-decision/anthropic-llm-decision.js +6 -87
- package/dist/actions/llm-decision/anthropic-llm-decision.js.map +1 -1
- package/dist/actions/llm-decision/factory.d.ts +0 -6
- package/dist/actions/llm-decision/factory.d.ts.map +1 -1
- package/dist/actions/llm-decision/factory.js +0 -2
- package/dist/actions/llm-decision/factory.js.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.d.ts.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.js +26 -7
- package/dist/actions/llm-decision/openclaw-llm-decision.js.map +1 -1
- package/dist/actions/open-position/open-position.action.d.ts +1 -1
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +282 -224
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.js +3 -6
- package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +61 -0
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts +14 -0
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +390 -2
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
- package/dist/dsl/engine-client/event-mapping.js +0 -3
- package/dist/dsl/engine-client/event-mapping.js.map +1 -1
- package/dist/dsl/events/build-closed-event.d.ts.map +1 -1
- package/dist/dsl/events/build-closed-event.js +0 -1
- package/dist/dsl/events/build-closed-event.js.map +1 -1
- package/dist/dsl/events/handlers.d.ts.map +1 -1
- package/dist/dsl/events/handlers.js +2 -4
- package/dist/dsl/events/handlers.js.map +1 -1
- package/dist/dsl/events/initial-state.d.ts.map +1 -1
- package/dist/dsl/events/initial-state.js +1 -0
- package/dist/dsl/events/initial-state.js.map +1 -1
- package/dist/dsl/monitor/create-monitor.d.ts +3 -0
- package/dist/dsl/monitor/create-monitor.d.ts.map +1 -1
- package/dist/dsl/monitor/create-monitor.js +76 -58
- package/dist/dsl/monitor/create-monitor.js.map +1 -1
- package/dist/dsl/monitor/dsl-failure-events.d.ts +42 -0
- package/dist/dsl/monitor/dsl-failure-events.d.ts.map +1 -0
- package/dist/dsl/monitor/dsl-failure-events.js +73 -0
- package/dist/dsl/monitor/dsl-failure-events.js.map +1 -0
- package/dist/dsl/monitor/process-one-position.d.ts +2 -1
- package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
- package/dist/dsl/monitor/process-one-position.js +130 -196
- package/dist/dsl/monitor/process-one-position.js.map +1 -1
- package/dist/dsl/plugin/index.d.ts +10 -0
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js +48 -4
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/dsl/plugin/options.d.ts +3 -0
- package/dist/dsl/plugin/options.d.ts.map +1 -1
- package/dist/health/types.d.ts +14 -0
- package/dist/health/types.d.ts.map +1 -1
- package/dist/health/types.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +264 -79
- package/dist/index.js.map +1 -1
- package/dist/risk/risk-audit-log.d.ts +7 -0
- package/dist/risk/risk-audit-log.d.ts.map +1 -1
- package/dist/risk/risk-audit-log.js +48 -1
- package/dist/risk/risk-audit-log.js.map +1 -1
- package/dist/runtime/__tests__/helpers/runtime-gateway-harness.d.ts +2 -0
- package/dist/runtime/__tests__/helpers/runtime-gateway-harness.d.ts.map +1 -1
- package/dist/runtime/__tests__/helpers/runtime-gateway-harness.js +24 -3
- package/dist/runtime/__tests__/helpers/runtime-gateway-harness.js.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +2 -2
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/runtime/create-actions.d.ts.map +1 -1
- package/dist/runtime/create-actions.js +40 -15
- package/dist/runtime/create-actions.js.map +1 -1
- package/dist/runtime/create-runtime-context.d.ts +1 -1
- package/dist/runtime/create-runtime-context.d.ts.map +1 -1
- package/dist/runtime/create-scanner-module.d.ts +2 -1
- package/dist/runtime/create-scanner-module.d.ts.map +1 -1
- package/dist/runtime/create-scanner-module.js +2 -1
- package/dist/runtime/create-scanner-module.js.map +1 -1
- package/dist/runtime/domain-events.d.ts +43 -0
- package/dist/runtime/domain-events.d.ts.map +1 -0
- package/dist/runtime/domain-events.js +181 -0
- package/dist/runtime/domain-events.js.map +1 -0
- package/dist/runtime/lifecycle-events.d.ts +86 -0
- package/dist/runtime/lifecycle-events.d.ts.map +1 -0
- package/dist/runtime/lifecycle-events.js +200 -0
- package/dist/runtime/lifecycle-events.js.map +1 -0
- package/dist/runtime/notifications.js +2 -2
- package/dist/runtime/notifications.js.map +1 -1
- package/dist/{tracking → runtime}/position-id-registry.d.ts +14 -1
- package/dist/runtime/position-id-registry.d.ts.map +1 -0
- package/dist/{tracking → runtime}/position-id-registry.js +20 -3
- package/dist/runtime/position-id-registry.js.map +1 -0
- package/dist/runtime/run.d.ts +2 -4
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime-schema.d.ts +276 -588
- package/dist/runtime/runtime-schema.d.ts.map +1 -1
- package/dist/runtime/runtime-schema.js +8 -28
- package/dist/runtime/runtime-schema.js.map +1 -1
- package/dist/runtime/runtime.d.ts +23 -9
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +276 -248
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/strategy-lifecycle.d.ts.map +1 -1
- package/dist/runtime/strategy-lifecycle.js +13 -1
- package/dist/runtime/strategy-lifecycle.js.map +1 -1
- package/dist/runtime/supervisor/long-running-supervisor.d.ts +3 -0
- package/dist/runtime/supervisor/long-running-supervisor.d.ts.map +1 -1
- package/dist/runtime/supervisor/long-running-supervisor.js +27 -53
- package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
- package/dist/runtime-api/config.d.ts +2 -2
- package/dist/runtime-api/config.js +4 -4
- package/dist/runtime-api/config.js.map +1 -1
- package/dist/runtime-api/handlers/ingest-signals.d.ts +5 -3
- package/dist/runtime-api/handlers/ingest-signals.d.ts.map +1 -1
- package/dist/runtime-api/handlers/ingest-signals.js +14 -5
- package/dist/runtime-api/handlers/ingest-signals.js.map +1 -1
- package/dist/runtime-api/intake/ingest-mutex.d.ts +16 -0
- package/dist/runtime-api/intake/ingest-mutex.d.ts.map +1 -0
- package/dist/runtime-api/intake/ingest-mutex.js +18 -0
- package/dist/runtime-api/intake/ingest-mutex.js.map +1 -0
- package/dist/runtime-api/intake/intake-events.d.ts +44 -0
- package/dist/runtime-api/intake/intake-events.d.ts.map +1 -0
- package/dist/runtime-api/intake/intake-events.js +131 -0
- package/dist/runtime-api/intake/intake-events.js.map +1 -0
- package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-mount.js +8 -2
- package/dist/runtime-api/intake/intake-mount.js.map +1 -1
- package/dist/runtime-api/intake/scanner-launcher.d.ts +2 -0
- package/dist/runtime-api/intake/scanner-launcher.d.ts.map +1 -1
- package/dist/runtime-api/intake/scanner-launcher.js +58 -15
- package/dist/runtime-api/intake/scanner-launcher.js.map +1 -1
- package/dist/runtime-api/intake/scanner-registry.d.ts +3 -0
- package/dist/runtime-api/intake/scanner-registry.d.ts.map +1 -1
- package/dist/runtime-api/intake/scanner-registry.js +3 -0
- package/dist/runtime-api/intake/scanner-registry.js.map +1 -1
- package/dist/runtime-api/intake/supervisor-events.d.ts +61 -0
- package/dist/runtime-api/intake/supervisor-events.d.ts.map +1 -0
- package/dist/runtime-api/intake/supervisor-events.js +173 -0
- package/dist/runtime-api/intake/supervisor-events.js.map +1 -0
- package/dist/runtime-api/routes/signals.d.ts +1 -1
- package/dist/runtime-api/routes/signals.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.js +121 -35
- package/dist/runtime-api/routes/signals.js.map +1 -1
- package/dist/runtime-api/server.d.ts.map +1 -1
- package/dist/runtime-api/server.js +10 -1
- package/dist/runtime-api/server.js.map +1 -1
- package/dist/scanners/engine/data-providers.d.ts +3 -0
- package/dist/scanners/engine/data-providers.d.ts.map +1 -1
- package/dist/scanners/engine/data-providers.js.map +1 -1
- package/dist/scanners/engine/engine.d.ts +18 -0
- package/dist/scanners/engine/engine.d.ts.map +1 -1
- package/dist/scanners/engine/engine.js +96 -2
- package/dist/scanners/engine/engine.js.map +1 -1
- package/dist/scanners/engine/input-resolver.d.ts.map +1 -1
- package/dist/scanners/engine/input-resolver.js +9 -7
- package/dist/scanners/engine/input-resolver.js.map +1 -1
- package/dist/scanners/runtime-module.d.ts +3 -0
- package/dist/scanners/runtime-module.d.ts.map +1 -1
- package/dist/scanners/runtime-module.js +7 -0
- package/dist/scanners/runtime-module.js.map +1 -1
- package/dist/senpi/client.d.ts +10 -0
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +113 -46
- package/dist/senpi/client.js.map +1 -1
- package/dist/skills-manager/bootstrap.d.ts.map +1 -1
- package/dist/skills-manager/bootstrap.js +22 -33
- package/dist/skills-manager/bootstrap.js.map +1 -1
- package/dist/skills-manager/clone-groups.d.ts +20 -0
- package/dist/skills-manager/clone-groups.d.ts.map +1 -0
- package/dist/skills-manager/clone-groups.js +45 -0
- package/dist/skills-manager/clone-groups.js.map +1 -0
- package/dist/skills-manager/coordinator.d.ts.map +1 -1
- package/dist/skills-manager/coordinator.js +111 -75
- package/dist/skills-manager/coordinator.js.map +1 -1
- package/dist/skills-manager/manifest.d.ts +24 -0
- package/dist/skills-manager/manifest.d.ts.map +1 -1
- package/dist/skills-manager/manifest.js +23 -10
- package/dist/skills-manager/manifest.js.map +1 -1
- package/dist/skills-manager/skills-manifest.json +12 -7
- package/dist/skills-manager/types.d.ts +12 -0
- package/dist/skills-manager/types.d.ts.map +1 -1
- package/dist/state/state-events.d.ts +13 -0
- package/dist/state/state-events.d.ts.map +1 -0
- package/dist/state/state-events.js +22 -0
- package/dist/state/state-events.js.map +1 -0
- package/dist/state/state-manager.d.ts.map +1 -1
- package/dist/state/state-manager.js +14 -1
- package/dist/state/state-manager.js.map +1 -1
- package/dist/telemetry/attributes.d.ts +13 -0
- package/dist/telemetry/attributes.d.ts.map +1 -0
- package/dist/telemetry/attributes.js +22 -0
- package/dist/telemetry/attributes.js.map +1 -0
- package/dist/{tracking → telemetry}/context.d.ts +12 -5
- package/dist/telemetry/context.d.ts.map +1 -0
- package/dist/{tracking → telemetry}/context.js +4 -4
- package/dist/telemetry/context.js.map +1 -0
- package/dist/{recording/records.d.ts → telemetry/event-builders.d.ts} +145 -33
- package/dist/telemetry/event-builders.d.ts.map +1 -0
- package/dist/{recording/wiring/record-builders.js → telemetry/event-builders.js} +94 -40
- package/dist/telemetry/event-builders.js.map +1 -0
- package/dist/telemetry/event-store.d.ts +66 -0
- package/dist/telemetry/event-store.d.ts.map +1 -0
- package/dist/telemetry/event-store.js +202 -0
- package/dist/telemetry/event-store.js.map +1 -0
- package/dist/telemetry/identity.d.ts +72 -0
- package/dist/telemetry/identity.d.ts.map +1 -0
- package/dist/{recording/wiring → telemetry}/identity.js +6 -2
- package/dist/telemetry/identity.js.map +1 -0
- package/dist/telemetry/metrics.d.ts +169 -0
- package/dist/telemetry/metrics.d.ts.map +1 -0
- package/dist/telemetry/metrics.js +437 -0
- package/dist/telemetry/metrics.js.map +1 -0
- package/dist/telemetry/otel-sdk.d.ts +93 -0
- package/dist/telemetry/otel-sdk.d.ts.map +1 -0
- package/dist/telemetry/otel-sdk.js +297 -0
- package/dist/telemetry/otel-sdk.js.map +1 -0
- package/dist/telemetry/spans/constants.d.ts +12 -0
- package/dist/telemetry/spans/constants.d.ts.map +1 -0
- package/dist/telemetry/spans/constants.js +12 -0
- package/dist/telemetry/spans/constants.js.map +1 -0
- package/dist/telemetry/spans/gen-ai.d.ts +74 -0
- package/dist/telemetry/spans/gen-ai.d.ts.map +1 -0
- package/dist/telemetry/spans/gen-ai.js +339 -0
- package/dist/telemetry/spans/gen-ai.js.map +1 -0
- package/dist/telemetry/spans/index.d.ts +11 -0
- package/dist/telemetry/spans/index.d.ts.map +1 -0
- package/dist/telemetry/spans/index.js +11 -0
- package/dist/telemetry/spans/index.js.map +1 -0
- package/dist/{tracking → telemetry}/spans/redact-pii.d.ts +19 -21
- package/dist/telemetry/spans/redact-pii.d.ts.map +1 -0
- package/dist/{tracking → telemetry}/spans/redact-pii.js +35 -32
- package/dist/telemetry/spans/redact-pii.js.map +1 -0
- package/dist/telemetry/spans/sanitize-payload.d.ts.map +1 -0
- package/dist/telemetry/spans/sanitize-payload.js.map +1 -0
- package/dist/telemetry/spans/span-hooks.d.ts +18 -0
- package/dist/telemetry/spans/span-hooks.d.ts.map +1 -0
- package/dist/telemetry/spans/span-hooks.js +764 -0
- package/dist/telemetry/spans/span-hooks.js.map +1 -0
- package/dist/telemetry/tool-plane.d.ts +31 -0
- package/dist/telemetry/tool-plane.d.ts.map +1 -0
- package/dist/telemetry/tool-plane.js +70 -0
- package/dist/telemetry/tool-plane.js.map +1 -0
- package/dist/telemetry/trace-identity.d.ts +32 -0
- package/dist/telemetry/trace-identity.d.ts.map +1 -0
- package/dist/telemetry/trace-identity.js +62 -0
- package/dist/telemetry/trace-identity.js.map +1 -0
- package/dist/telemetry/tracing.d.ts +33 -0
- package/dist/telemetry/tracing.d.ts.map +1 -0
- package/dist/telemetry/tracing.js +70 -0
- package/dist/telemetry/tracing.js.map +1 -0
- package/dist/types/dsl/index.d.ts +8 -9
- package/dist/types/dsl/index.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +1 -1
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/scanner.d.ts +2 -0
- package/dist/types/scanner.d.ts.map +1 -1
- package/dist/utils/event-catalog.d.ts +506 -0
- package/dist/utils/event-catalog.d.ts.map +1 -0
- package/dist/utils/event-catalog.js +142 -0
- package/dist/utils/event-catalog.js.map +1 -0
- package/dist/utils/logger.d.ts +63 -5
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +360 -27
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/wallet-address.d.ts +3 -0
- package/dist/utils/wallet-address.d.ts.map +1 -0
- package/dist/utils/wallet-address.js +17 -0
- package/dist/utils/wallet-address.js.map +1 -0
- package/openclaw.plugin.json +20 -6
- package/package.json +10 -2
- package/dist/actions/tracking-helpers.d.ts +0 -28
- package/dist/actions/tracking-helpers.d.ts.map +0 -1
- package/dist/actions/tracking-helpers.js +0 -93
- package/dist/actions/tracking-helpers.js.map +0 -1
- package/dist/recording/emitter.d.ts +0 -27
- package/dist/recording/emitter.d.ts.map +0 -1
- package/dist/recording/emitter.js +0 -2
- package/dist/recording/emitter.js.map +0 -1
- package/dist/recording/identity.d.ts +0 -34
- package/dist/recording/identity.d.ts.map +0 -1
- package/dist/recording/identity.js +0 -2
- package/dist/recording/identity.js.map +0 -1
- package/dist/recording/index.d.ts +0 -11
- package/dist/recording/index.d.ts.map +0 -1
- package/dist/recording/index.js +0 -2
- package/dist/recording/index.js.map +0 -1
- package/dist/recording/noop-emitter.d.ts +0 -23
- package/dist/recording/noop-emitter.d.ts.map +0 -1
- package/dist/recording/noop-emitter.js +0 -22
- package/dist/recording/noop-emitter.js.map +0 -1
- package/dist/recording/otel/attributes.d.ts +0 -35
- package/dist/recording/otel/attributes.d.ts.map +0 -1
- package/dist/recording/otel/attributes.js +0 -131
- package/dist/recording/otel/attributes.js.map +0 -1
- package/dist/recording/otel/constants.d.ts +0 -123
- package/dist/recording/otel/constants.d.ts.map +0 -1
- package/dist/recording/otel/constants.js +0 -172
- package/dist/recording/otel/constants.js.map +0 -1
- package/dist/recording/otel/ids.d.ts +0 -25
- package/dist/recording/otel/ids.d.ts.map +0 -1
- package/dist/recording/otel/ids.js +0 -37
- package/dist/recording/otel/ids.js.map +0 -1
- package/dist/recording/otel/index.d.ts +0 -13
- package/dist/recording/otel/index.d.ts.map +0 -1
- package/dist/recording/otel/index.js +0 -9
- package/dist/recording/otel/index.js.map +0 -1
- package/dist/recording/otel/mappers.d.ts +0 -100
- package/dist/recording/otel/mappers.d.ts.map +0 -1
- package/dist/recording/otel/mappers.js +0 -683
- package/dist/recording/otel/mappers.js.map +0 -1
- package/dist/recording/otel/otel-emitter.d.ts +0 -43
- package/dist/recording/otel/otel-emitter.d.ts.map +0 -1
- package/dist/recording/otel/otel-emitter.js +0 -99
- package/dist/recording/otel/otel-emitter.js.map +0 -1
- package/dist/recording/otel/redaction.d.ts +0 -47
- package/dist/recording/otel/redaction.d.ts.map +0 -1
- package/dist/recording/otel/redaction.js +0 -88
- package/dist/recording/otel/redaction.js.map +0 -1
- package/dist/recording/records.d.ts.map +0 -1
- package/dist/recording/records.js +0 -14
- package/dist/recording/records.js.map +0 -1
- package/dist/recording/transport/batcher.d.ts +0 -59
- package/dist/recording/transport/batcher.d.ts.map +0 -1
- package/dist/recording/transport/batcher.js +0 -234
- package/dist/recording/transport/batcher.js.map +0 -1
- package/dist/recording/transport/client.d.ts +0 -41
- package/dist/recording/transport/client.d.ts.map +0 -1
- package/dist/recording/transport/client.js +0 -69
- package/dist/recording/transport/client.js.map +0 -1
- package/dist/recording/transport/config.d.ts +0 -53
- package/dist/recording/transport/config.d.ts.map +0 -1
- package/dist/recording/transport/config.js +0 -41
- package/dist/recording/transport/config.js.map +0 -1
- package/dist/recording/transport/index.d.ts +0 -16
- package/dist/recording/transport/index.d.ts.map +0 -1
- package/dist/recording/transport/index.js +0 -12
- package/dist/recording/transport/index.js.map +0 -1
- package/dist/recording/transport/rows.d.ts +0 -88
- package/dist/recording/transport/rows.d.ts.map +0 -1
- package/dist/recording/transport/rows.js +0 -15
- package/dist/recording/transport/rows.js.map +0 -1
- package/dist/recording/wiring/emitter-factory.d.ts +0 -39
- package/dist/recording/wiring/emitter-factory.d.ts.map +0 -1
- package/dist/recording/wiring/emitter-factory.js +0 -62
- package/dist/recording/wiring/emitter-factory.js.map +0 -1
- package/dist/recording/wiring/identity.d.ts +0 -27
- package/dist/recording/wiring/identity.d.ts.map +0 -1
- package/dist/recording/wiring/identity.js.map +0 -1
- package/dist/recording/wiring/index.d.ts +0 -12
- package/dist/recording/wiring/index.d.ts.map +0 -1
- package/dist/recording/wiring/index.js +0 -9
- package/dist/recording/wiring/index.js.map +0 -1
- package/dist/recording/wiring/record-builders.d.ts +0 -107
- package/dist/recording/wiring/record-builders.d.ts.map +0 -1
- package/dist/recording/wiring/record-builders.js.map +0 -1
- package/dist/recording/wiring/subscriber.d.ts +0 -28
- package/dist/recording/wiring/subscriber.d.ts.map +0 -1
- package/dist/recording/wiring/subscriber.js +0 -173
- package/dist/recording/wiring/subscriber.js.map +0 -1
- package/dist/recording/wiring/values.d.ts +0 -19
- package/dist/recording/wiring/values.d.ts.map +0 -1
- package/dist/recording/wiring/values.js +0 -49
- package/dist/recording/wiring/values.js.map +0 -1
- package/dist/tracking/build-rehydrate-items.d.ts +0 -15
- package/dist/tracking/build-rehydrate-items.d.ts.map +0 -1
- package/dist/tracking/build-rehydrate-items.js +0 -19
- package/dist/tracking/build-rehydrate-items.js.map +0 -1
- package/dist/tracking/constants.d.ts +0 -24
- package/dist/tracking/constants.d.ts.map +0 -1
- package/dist/tracking/constants.js +0 -52
- package/dist/tracking/constants.js.map +0 -1
- package/dist/tracking/context.d.ts.map +0 -1
- package/dist/tracking/context.js.map +0 -1
- package/dist/tracking/index.d.ts +0 -16
- package/dist/tracking/index.d.ts.map +0 -1
- package/dist/tracking/index.js +0 -11
- package/dist/tracking/index.js.map +0 -1
- package/dist/tracking/plugin-event-tracker.d.ts +0 -13
- package/dist/tracking/plugin-event-tracker.d.ts.map +0 -1
- package/dist/tracking/plugin-event-tracker.js +0 -27
- package/dist/tracking/plugin-event-tracker.js.map +0 -1
- package/dist/tracking/position-id-registry.d.ts.map +0 -1
- package/dist/tracking/position-id-registry.js.map +0 -1
- package/dist/tracking/spans/constants.d.ts +0 -19
- package/dist/tracking/spans/constants.d.ts.map +0 -1
- package/dist/tracking/spans/constants.js +0 -31
- package/dist/tracking/spans/constants.js.map +0 -1
- package/dist/tracking/spans/fan-out-span-transport.d.ts +0 -22
- package/dist/tracking/spans/fan-out-span-transport.d.ts.map +0 -1
- package/dist/tracking/spans/fan-out-span-transport.js +0 -49
- package/dist/tracking/spans/fan-out-span-transport.js.map +0 -1
- package/dist/tracking/spans/index.d.ts +0 -13
- package/dist/tracking/spans/index.d.ts.map +0 -1
- package/dist/tracking/spans/index.js +0 -16
- package/dist/tracking/spans/index.js.map +0 -1
- package/dist/tracking/spans/otel/fit-row-budget.d.ts +0 -22
- package/dist/tracking/spans/otel/fit-row-budget.d.ts.map +0 -1
- package/dist/tracking/spans/otel/fit-row-budget.js +0 -91
- package/dist/tracking/spans/otel/fit-row-budget.js.map +0 -1
- package/dist/tracking/spans/otel/map-span-to-trace-row.d.ts +0 -16
- package/dist/tracking/spans/otel/map-span-to-trace-row.d.ts.map +0 -1
- package/dist/tracking/spans/otel/map-span-to-trace-row.js +0 -227
- package/dist/tracking/spans/otel/map-span-to-trace-row.js.map +0 -1
- package/dist/tracking/spans/otel/recording-span-transport.d.ts +0 -43
- package/dist/tracking/spans/otel/recording-span-transport.d.ts.map +0 -1
- package/dist/tracking/spans/otel/recording-span-transport.js +0 -67
- package/dist/tracking/spans/otel/recording-span-transport.js.map +0 -1
- package/dist/tracking/spans/otel/span-ids.d.ts +0 -22
- package/dist/tracking/spans/otel/span-ids.d.ts.map +0 -1
- package/dist/tracking/spans/otel/span-ids.js +0 -32
- package/dist/tracking/spans/otel/span-ids.js.map +0 -1
- package/dist/tracking/spans/plugin-span-tracker.d.ts +0 -9
- package/dist/tracking/spans/plugin-span-tracker.d.ts.map +0 -1
- package/dist/tracking/spans/plugin-span-tracker.js +0 -115
- package/dist/tracking/spans/plugin-span-tracker.js.map +0 -1
- package/dist/tracking/spans/redact-pii.d.ts.map +0 -1
- package/dist/tracking/spans/redact-pii.js.map +0 -1
- package/dist/tracking/spans/sanitize-payload.d.ts.map +0 -1
- package/dist/tracking/spans/sanitize-payload.js.map +0 -1
- package/dist/tracking/spans/span-hooks.d.ts +0 -28
- package/dist/tracking/spans/span-hooks.d.ts.map +0 -1
- package/dist/tracking/spans/span-hooks.js +0 -409
- package/dist/tracking/spans/span-hooks.js.map +0 -1
- package/dist/tracking/spans/span-tracker.d.ts +0 -133
- package/dist/tracking/spans/span-tracker.d.ts.map +0 -1
- package/dist/tracking/spans/span-tracker.js +0 -721
- package/dist/tracking/spans/span-tracker.js.map +0 -1
- package/dist/tracking/spans/span-transport.d.ts +0 -71
- package/dist/tracking/spans/span-transport.d.ts.map +0 -1
- package/dist/tracking/spans/span-transport.js +0 -240
- package/dist/tracking/spans/span-transport.js.map +0 -1
- package/dist/tracking/spans/types.d.ts +0 -101
- package/dist/tracking/spans/types.d.ts.map +0 -1
- package/dist/tracking/spans/types.js +0 -6
- package/dist/tracking/spans/types.js.map +0 -1
- package/dist/tracking/tracker.d.ts +0 -30
- package/dist/tracking/tracker.d.ts.map +0 -1
- package/dist/tracking/tracker.js +0 -66
- package/dist/tracking/tracker.js.map +0 -1
- package/dist/tracking/tracking-handler.d.ts +0 -12
- package/dist/tracking/tracking-handler.d.ts.map +0 -1
- package/dist/tracking/tracking-handler.js +0 -148
- package/dist/tracking/tracking-handler.js.map +0 -1
- package/dist/tracking/transport.d.ts +0 -35
- package/dist/tracking/transport.d.ts.map +0 -1
- package/dist/tracking/transport.js +0 -133
- package/dist/tracking/transport.js.map +0 -1
- package/dist/tracking/types.d.ts +0 -21
- package/dist/tracking/types.d.ts.map +0 -1
- package/dist/tracking/types.js +0 -6
- package/dist/tracking/types.js.map +0 -1
- /package/dist/{tracking → telemetry}/spans/sanitize-payload.d.ts +0 -0
- /package/dist/{tracking → telemetry}/spans/sanitize-payload.js +0 -0
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* domain events and runtime errors.
|
|
2
|
+
* Event contract types + pure builders: bus-event payloads → telemetry records.
|
|
4
3
|
*
|
|
5
4
|
* Each record is one atomic "work unit": plain, immutable, serializable data with no methods or
|
|
6
5
|
* builder dance; variants are modelled with a discriminator field plus optionals. The types are
|
|
7
6
|
* transport-agnostic — nothing here knows about spans, attributes, or any wire format.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* The builders read a loosely-typed payload defensively (the `asObject`/`str`/`num`/`bool`/
|
|
9
|
+
* `toEpochMs` helpers below) and return a fully-populated record (or `null` when the event cannot
|
|
10
|
+
* yield one). Redaction is NOT done here — records are populated faithfully; a downstream mapper is
|
|
11
|
+
* the single redaction seam.
|
|
12
|
+
*
|
|
13
|
+
* Identity (service, recipe, runtime, strategy address, boot id) is stamped by the identity layer
|
|
14
|
+
* and is never on a record — see {@link IdentityEnvelope}. Timestamps are epoch milliseconds; ISO
|
|
15
|
+
* strings (and, for a scan result, an epoch-ms number) from the bus are converted once here, so
|
|
16
|
+
* consumers never parse dates.
|
|
17
|
+
*/
|
|
18
|
+
/** A plain object, or `undefined` for anything else (null, array, primitive). */
|
|
19
|
+
export declare function asObject(value: unknown): Record<string, unknown> | undefined;
|
|
20
|
+
/** A non-empty string, or `undefined`. */
|
|
21
|
+
export declare function str(value: unknown): string | undefined;
|
|
22
|
+
/** A finite number, coercing numeric strings; `undefined` otherwise. */
|
|
23
|
+
export declare function num(value: unknown): number | undefined;
|
|
24
|
+
/** A boolean, or `undefined` (so absence stays distinct from `false`). */
|
|
25
|
+
export declare function bool(value: unknown): boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* ISO string or epoch-ms number → epoch ms. Falls back to `fallbackMs` when the value is missing
|
|
28
|
+
* or unparseable, so a record always carries a usable timestamp instead of `NaN`.
|
|
12
29
|
*/
|
|
30
|
+
export declare function toEpochMs(value: unknown, fallbackMs: number): number;
|
|
13
31
|
/**
|
|
14
32
|
* Trade direction as the bus reports it. The alias itself is non-null; sites that admit a
|
|
15
33
|
* non-directional signal widen it to `TradeDirection | null` (e.g. {@link SignalSummary}).
|
|
@@ -36,7 +54,7 @@ export type ScannerRunOutcome = "complete" | "skipped" | "error";
|
|
|
36
54
|
* One scanner execution attempt (the work unit). Folds the bus's `scanner:run:start` +
|
|
37
55
|
* terminal `scanner:run:{complete,skip,error}` events into a single atomic record so a
|
|
38
56
|
* duration is always derivable (`endedAt - startedAt`). Skip/error early-exit paths can
|
|
39
|
-
* terminate without a paired `scanner:run:start` event; in that case
|
|
57
|
+
* terminate without a paired `scanner:run:start` event; in that case `startedAt` is filled
|
|
40
58
|
* with the run's attempt timestamp (which equals `endedAt`), so duration is 0 rather than absent.
|
|
41
59
|
* The skipped/disabled distinction lives on `outcome`/`statusDetail`, not on a missing start.
|
|
42
60
|
*/
|
|
@@ -49,8 +67,8 @@ export interface ScannerRunRecord {
|
|
|
49
67
|
/** Raw engine status: `ok`|`heartbeat`|`skipped`|`halted`|`disabled`|`error`. */
|
|
50
68
|
readonly statusDetail?: string;
|
|
51
69
|
/**
|
|
52
|
-
* Run start, epoch ms (from `scanner:run:start`). Required: on a no-start early-exit path
|
|
53
|
-
*
|
|
70
|
+
* Run start, epoch ms (from `scanner:run:start`). Required: on a no-start early-exit path it is
|
|
71
|
+
* set to the attempt timestamp (= `endedAt`), so a `Duration` is always derivable.
|
|
54
72
|
*/
|
|
55
73
|
readonly startedAt: number;
|
|
56
74
|
/** Run completion, epoch ms (terminal event timestamp). */
|
|
@@ -68,7 +86,7 @@ export interface ScannerRunRecord {
|
|
|
68
86
|
/** Error class name (`Error.name`) when `outcome === "error"` — the error-grouping key. */
|
|
69
87
|
readonly errorName?: string;
|
|
70
88
|
}
|
|
71
|
-
/** How the decision was produced
|
|
89
|
+
/** How the decision was produced. */
|
|
72
90
|
export type DecisionMode = "llm" | "script" | "agent" | "rule" | "none";
|
|
73
91
|
/** Decision produced by the decision layer for an evaluation pass. */
|
|
74
92
|
export interface SignalDecision {
|
|
@@ -87,8 +105,6 @@ export interface SignalDecision {
|
|
|
87
105
|
readonly model?: string;
|
|
88
106
|
readonly tokensUsed?: number | null;
|
|
89
107
|
readonly durationMs?: number;
|
|
90
|
-
/** Epoch ms when the decision phase ended — the llm.decision child's end; its window is `[endedAt − durationMs, endedAt]`. */
|
|
91
|
-
readonly endedAt?: number;
|
|
92
108
|
}
|
|
93
109
|
/** Coarse result of acting on an evaluated signal. */
|
|
94
110
|
export type SignalOutcomeResult = "executed" | "rejected" | "skipped" | "below_confidence" | "error";
|
|
@@ -122,6 +138,10 @@ export interface SignalOutcome {
|
|
|
122
138
|
readonly errorName?: string;
|
|
123
139
|
readonly leverage?: number;
|
|
124
140
|
readonly marginAmount?: number;
|
|
141
|
+
/** Which precedence rule sized the margin (the {@link MarginSource} breadcrumb). */
|
|
142
|
+
readonly marginSource?: string;
|
|
143
|
+
/** Applied percent of withdrawable — present only for the percent-based margin sources. */
|
|
144
|
+
readonly marginPct?: number;
|
|
125
145
|
readonly notionalValue?: number;
|
|
126
146
|
readonly orderId?: string;
|
|
127
147
|
readonly entryPrice?: number;
|
|
@@ -215,7 +235,7 @@ export interface PositionLifecycleRecord {
|
|
|
215
235
|
* Externally-detected vs runtime-opened discriminator (`"runtime_opened"` |
|
|
216
236
|
* `"externally_detected"`), from the PositionIdRegistry's intent-vs-fresh mint observation.
|
|
217
237
|
* Populated on `opened` only (the registry surfaces it solely on confirm-open); absent on every
|
|
218
|
-
* other lifecycle event.
|
|
238
|
+
* other lifecycle event.
|
|
219
239
|
*/
|
|
220
240
|
readonly reconciliationSource?: string;
|
|
221
241
|
}
|
|
@@ -410,14 +430,14 @@ export interface RuntimeStateRecord {
|
|
|
410
430
|
export type DecisionActionIntent = "open" | "close" | "none";
|
|
411
431
|
/**
|
|
412
432
|
* The judgment over one evaluation pass, as a discrete log event (`decision.made`). Derived from
|
|
413
|
-
* the same
|
|
414
|
-
*
|
|
433
|
+
* the same action-result payload that builds {@link SignalEvaluatedRecord}. The trace view keeps the
|
|
434
|
+
* decision on the `llm.decision` span; this is its logs-only twin so
|
|
415
435
|
* a logs-only consumer (the self-learning agent) can read "what the strategy decided and why"
|
|
416
436
|
* without walking spans.
|
|
417
437
|
*
|
|
418
438
|
* `reasoning` is the Body (uncapped free-text). Market-context fields (`fundingRegime`/
|
|
419
|
-
* `marketRegime`/`markPrice`) are reserved keys: they are NOT on the
|
|
420
|
-
* payload today, so
|
|
439
|
+
* `marketRegime`/`markPrice`) are reserved keys: they are NOT on the action-result
|
|
440
|
+
* payload today, so they are left undefined (absent = NULL).
|
|
421
441
|
*/
|
|
422
442
|
export interface DecisionMadeRecord {
|
|
423
443
|
readonly type: "decision_made";
|
|
@@ -440,8 +460,8 @@ export interface DecisionMadeRecord {
|
|
|
440
460
|
export type SignalOutcomeDisposition = "accepted" | "rejected" | "blocked" | "error";
|
|
441
461
|
/**
|
|
442
462
|
* One signal's disposition, as a discrete log event (`signal.outcome`). One per evaluation in the
|
|
443
|
-
* pass, derived from the same
|
|
444
|
-
*
|
|
463
|
+
* pass, derived from the same action-result payload that builds {@link SignalEvaluatedRecord}.
|
|
464
|
+
* The four-value `result` collapses the granular per-signal
|
|
445
465
|
* {@link SignalOutcomeResult}; the open `reasonCode` is kept verbatim for the fine-grained reason.
|
|
446
466
|
*
|
|
447
467
|
* `rawSignal` is the variable-shaped scanner evidence → the Body (redacted in the mapper). The
|
|
@@ -466,8 +486,10 @@ export interface SignalOutcomeRecord {
|
|
|
466
486
|
readonly leverage?: number;
|
|
467
487
|
readonly notionalValue?: number;
|
|
468
488
|
readonly size?: number;
|
|
469
|
-
/**
|
|
489
|
+
/** Which precedence rule sized the margin (the {@link MarginSource} breadcrumb). */
|
|
470
490
|
readonly marginSource?: string;
|
|
491
|
+
/** Applied percent of withdrawable — present only for the percent-based margin sources. */
|
|
492
|
+
readonly marginPct?: number;
|
|
471
493
|
readonly orderId?: string;
|
|
472
494
|
readonly errorName?: string;
|
|
473
495
|
/** The raw scanner signal payload (incl. its `meta`/`factors`) → the Body, redacted in the mapper. */
|
|
@@ -475,11 +497,11 @@ export interface SignalOutcomeRecord {
|
|
|
475
497
|
}
|
|
476
498
|
/**
|
|
477
499
|
* One DSL exit attempt as a discrete log event (`dsl.close_attempt`) — exit attempts / venue
|
|
478
|
-
* failures / retries, span-only today. Derived from the
|
|
500
|
+
* failures / retries, span-only today. Derived from the DSL close-attempt payload
|
|
479
501
|
* (already consumed to build the {@link DslTickRecord} trace) — a second consumer for the log.
|
|
480
502
|
*
|
|
481
503
|
* No `errorName`: only `String(e)` is available at the producer emit site, so the error class name
|
|
482
|
-
* is omitted
|
|
504
|
+
* is omitted.
|
|
483
505
|
*/
|
|
484
506
|
export interface DslCloseAttemptRecord {
|
|
485
507
|
readonly type: "dsl_close_attempt";
|
|
@@ -495,8 +517,8 @@ export interface DslCloseAttemptRecord {
|
|
|
495
517
|
}
|
|
496
518
|
/**
|
|
497
519
|
* One scan's funnel summary as a discrete log event (`scanner.summary`) — the anti-spam roll-up of
|
|
498
|
-
* what a scan considered and dropped. Derived from the SAME
|
|
499
|
-
* builds {@link ScannerRunRecord} (its `summary.funnel`)
|
|
520
|
+
* what a scan considered and dropped. Derived from the SAME scanner-run payload that
|
|
521
|
+
* builds {@link ScannerRunRecord} (its `summary.funnel`). One row per scan: the
|
|
500
522
|
* dropped candidates are ONE Body array, never one row per drop.
|
|
501
523
|
*
|
|
502
524
|
* `passedAssets` is a small linkage list (the survivors, each detailed by its own `signal.outcome`);
|
|
@@ -524,15 +546,14 @@ export type OrderEventKind = "placed" | "filled" | "failed";
|
|
|
524
546
|
* One order-execution event as a discrete log event (`order.{placed,filled,failed}`) — the venue
|
|
525
547
|
* execution granularity (placement vs fill, maker/taker, venue rejects) that the position-level
|
|
526
548
|
* `position_lifecycle` event can't carry. Emitted additively by the open/close actions at the
|
|
527
|
-
* submit/success/failure points
|
|
549
|
+
* submit/success/failure points. `event` discriminates which
|
|
528
550
|
* optional fields apply.
|
|
529
551
|
*
|
|
530
552
|
* Overlap with `position_lifecycle.opened`/`.closed` is intentional: the lifecycle event is the
|
|
531
553
|
* settled position-level fact; `order.*` is the execution-level fact. Both are emitted; no dedupe.
|
|
532
554
|
*
|
|
533
|
-
* `limitPrice`/`fees`/`partial` are reserved-but-unpopulated
|
|
534
|
-
*
|
|
535
|
-
* raw response → the Body.
|
|
555
|
+
* `limitPrice`/`fees`/`partial` are reserved-but-unpopulated — they are not in scope at the action's
|
|
556
|
+
* submission point. `error` on `failed` is the optional venue raw response → the Body.
|
|
536
557
|
*/
|
|
537
558
|
export interface OrderEventRecord {
|
|
538
559
|
readonly type: "order_event";
|
|
@@ -545,21 +566,112 @@ export interface OrderEventRecord {
|
|
|
545
566
|
readonly direction?: TradeDirection | null;
|
|
546
567
|
readonly orderType?: string;
|
|
547
568
|
readonly size?: number;
|
|
548
|
-
/** Reserved — unpopulated
|
|
569
|
+
/** Reserved — unpopulated (not in scope at the submission point). */
|
|
549
570
|
readonly limitPrice?: number;
|
|
550
571
|
readonly reduceOnly?: boolean;
|
|
551
572
|
readonly fillPrice?: number;
|
|
552
573
|
readonly fillSize?: number;
|
|
553
574
|
readonly executionAsMaker?: boolean | null;
|
|
554
|
-
/** Reserved — unpopulated
|
|
575
|
+
/** Reserved — unpopulated (not in scope). */
|
|
555
576
|
readonly fees?: number;
|
|
556
|
-
/** Reserved — unpopulated
|
|
577
|
+
/** Reserved — unpopulated (not in scope). */
|
|
557
578
|
readonly partial?: boolean;
|
|
558
579
|
readonly reason?: string;
|
|
559
580
|
readonly errorName?: string;
|
|
560
581
|
/** The optional venue raw response on `failed` → the Body. */
|
|
561
582
|
readonly error?: string;
|
|
562
583
|
}
|
|
563
|
-
/**
|
|
564
|
-
|
|
565
|
-
|
|
584
|
+
/** From a scanner-run payload (complete / skipped / error): complete runs carry the whole
|
|
585
|
+
* `ScanResult`; skip/error carry status + reason. */
|
|
586
|
+
export declare function buildScannerRun(payload: unknown, nowMs: number): ScannerRunRecord | null;
|
|
587
|
+
/**
|
|
588
|
+
* The `scanner.summary` anti-spam log record, derived from the SAME scanner-run payload
|
|
589
|
+
* that {@link buildScannerRun} reads (its `data.summary.funnel.dropped`).
|
|
590
|
+
*
|
|
591
|
+
* Returns `null` when there is no `data.summary.funnel`: skip/error runs and scanners without a
|
|
592
|
+
* funnel produce no summary event (the survivors are detailed by their own `signal.outcome` events,
|
|
593
|
+
* and "didn't run at all" is `scanner_run.skipped`). One record per scan; the dropped candidates are
|
|
594
|
+
* one Body array, never one row per drop.
|
|
595
|
+
*/
|
|
596
|
+
export declare function buildScannerSummary(payload: unknown, nowMs: number): ScannerSummaryRecord | null;
|
|
597
|
+
/**
|
|
598
|
+
* Read-only position.id lookup, (address, dex, asset) → the live id or undefined. Injected by
|
|
599
|
+
* the runtime as a narrow accessor over the PositionIdRegistry — the registry is the single
|
|
600
|
+
* source of truth; builders never receive the registry (or RuntimeContext) itself.
|
|
601
|
+
*/
|
|
602
|
+
export type PositionIdResolver = (address: string, dex: string, asset: string) => string | undefined;
|
|
603
|
+
/**
|
|
604
|
+
* Build the whole pass record from an action-result payload alone — the producers echo the scan
|
|
605
|
+
* provenance onto the payload (`scannerId`, `scannerSignals`, `minConfidence`, `runId`), and the
|
|
606
|
+
* decision itself rides `result.data._decisionMeta`, so no pairing is needed.
|
|
607
|
+
*
|
|
608
|
+
* `evaluations` is one entry per per-signal result, each enriched with the matching input signal
|
|
609
|
+
* (or a summary synthesized from the result entry when none matches — e.g. close-position's
|
|
610
|
+
* static-params path, which carries no `scannerSignals`). A pass without `_decisionMeta` yields no
|
|
611
|
+
* `decision` (the contract allows a decision-less pass).
|
|
612
|
+
*
|
|
613
|
+
* The pass window is a point anchored at the action-result timestamp (`startedAt === endedAt`); the
|
|
614
|
+
* decision's own `durationMs` (from `_decisionMeta`) carries the timing.
|
|
615
|
+
*/
|
|
616
|
+
export declare function buildSignalEvaluated(actionResultPayload: unknown, nowMs: number, resolvePositionId?: PositionIdResolver): SignalEvaluatedRecord | null;
|
|
617
|
+
/**
|
|
618
|
+
* The pass's `decision.made` log record, derived from the built pass record — `null` when the pass
|
|
619
|
+
* carried no decision (a decision-less pass yields no judgment event). One per pass.
|
|
620
|
+
*/
|
|
621
|
+
export declare function buildDecisionMade(record: SignalEvaluatedRecord): DecisionMadeRecord | null;
|
|
622
|
+
/**
|
|
623
|
+
* One `signal.outcome` log record per evaluation in the pass, derived from the built pass record.
|
|
624
|
+
* `rawSignal` is the evaluation's {@link SignalSummary} (incl. its `meta`/`factors`) — the variable
|
|
625
|
+
* scanner evidence; redaction over it happens in the mapper, not here.
|
|
626
|
+
*/
|
|
627
|
+
export declare function buildSignalOutcomes(record: SignalEvaluatedRecord): SignalOutcomeRecord[];
|
|
628
|
+
/**
|
|
629
|
+
* From the DSL close-attempt monitor payload — the second consumer (alongside the
|
|
630
|
+
* tick trace). Fields at the payload root: `positionId`, `asset`, `dex`, `closeReason`, `attempt`,
|
|
631
|
+
* `outcome` ("ok"|"error"), `error`, ISO `timestamp`. `null` when the payload is not an object.
|
|
632
|
+
*/
|
|
633
|
+
export declare function buildDslCloseAttempt(payload: unknown, nowMs: number): DslCloseAttemptRecord | null;
|
|
634
|
+
/**
|
|
635
|
+
* From the additive order events the open/close actions fire (the HookEvent shape:
|
|
636
|
+
* fields under a `data` envelope). One record per event; `eventKind` discriminates which fields the
|
|
637
|
+
* payload carries (placed: order/size; filled: fill; failed: reason/error). `positionId` maps from
|
|
638
|
+
* `__positionId`. `null` when no `asset` is resolvable — the asset is the one always-present scalar.
|
|
639
|
+
*
|
|
640
|
+
* Faithful population only (no redaction here — the mapper is the single redaction seam).
|
|
641
|
+
*/
|
|
642
|
+
export declare function buildOrderEvent(eventKind: OrderEventKind, payload: unknown, nowMs: number): OrderEventRecord | null;
|
|
643
|
+
/**
|
|
644
|
+
* From an `on_position_*` event. Action-driven events arrive as HookEvents (fields under a `data`
|
|
645
|
+
* envelope); the DSL monitor / reconcile paths emit `on_position_closed` flat (fields at the root,
|
|
646
|
+
* always with an `asset`), so a flat payload carrying an `asset` is read as-is. The DSL archive
|
|
647
|
+
* handler's re-broadcast of a close is marked `source: "dsl_archive"` and skipped — the close it
|
|
648
|
+
* mirrors was already recorded from the original emit. (`on_open_order_submitted` is deliberately
|
|
649
|
+
* not recorded — its submit fact is already on the signal-evaluation view, avoiding a double count.)
|
|
650
|
+
*/
|
|
651
|
+
export declare function buildPositionLifecycle(event: PositionLifecycleEvent, payload: unknown, nowMs: number): PositionLifecycleRecord | null;
|
|
652
|
+
/** From a `dsl.*` event (fields live at the payload root, with an ISO `timestamp`). */
|
|
653
|
+
export declare function buildDslTransition(transition: DslTransitionKind, payload: unknown, nowMs: number): DslTransitionRecord | null;
|
|
654
|
+
/**
|
|
655
|
+
* From the monitor's DSL tick / position / close-attempt / sl-update payloads (fields at the
|
|
656
|
+
* payload root). Each payload yields one record —
|
|
657
|
+
* the deterministic ids derived from `tickId` (and `tickId:positionKey`, both bootId-scoped by
|
|
658
|
+
* the mapper) thread them into one trace, so no pairing is needed here. Essentials are `tickId`
|
|
659
|
+
* plus a numeric work window; on clock skew (`endedAt < startedAt`) the start is pulled up to the
|
|
660
|
+
* end, matching the pass-window convention. The price-fetch window is kept only when both stamps
|
|
661
|
+
* are present (a half window is fabricated extent). No `nowMs` fallback: work windows are
|
|
662
|
+
* producer-stamped; nothing here is fabricated.
|
|
663
|
+
*/
|
|
664
|
+
export declare function buildDslTick(unit: DslTickUnit, payload: unknown): DslTickRecord | null;
|
|
665
|
+
/** From `signal_processing_error` — a bucket-2 error with no specific domain record home. */
|
|
666
|
+
export declare function buildRuntimeError(payload: unknown, nowMs: number): RuntimeErrorRecord | null;
|
|
667
|
+
/**
|
|
668
|
+
* From the runtime-started payload. The `config` blob is the injected **unresolved** config (not the
|
|
669
|
+
* resolved `data.config`): resolving inlines secrets, and the unresolved form is what the
|
|
670
|
+
* `configHash` is computed over, so blob and hash agree.
|
|
671
|
+
*/
|
|
672
|
+
export declare function buildRuntimeStarted(payload: unknown, unresolvedConfig: Record<string, unknown> | undefined, nowMs: number): RuntimeLifecycleRecord | null;
|
|
673
|
+
/** From the runtime-stopped payload. */
|
|
674
|
+
export declare function buildRuntimeStopped(payload: unknown, nowMs: number): RuntimeLifecycleRecord | null;
|
|
675
|
+
/** From the self-pause HookEvents (`on_strategy_self_paused`/`on_daily_limit_hit`/`on_drawdown_cap_hit`). */
|
|
676
|
+
export declare function buildRuntimePaused(payload: unknown, fallbackGateId: string, nowMs: number): RuntimeStateRecord | null;
|
|
677
|
+
//# sourceMappingURL=event-builders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-builders.d.ts","sourceRoot":"","sources":["../../src/telemetry/event-builders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,iFAAiF;AACjF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,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AC,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAgD7H;AASD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAkCtF;AAID,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CA2B5F;AAID;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI,CAczJ;AAED,wCAAwC;AACxC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI,CAWlG;AAID,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAcrH"}
|
|
@@ -1,13 +1,70 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* loosely-typed payload defensively and returns a fully-populated record (or `null` when the event
|
|
4
|
-
* cannot yield one). Redaction is NOT done here — records are populated faithfully; the mapper is the
|
|
5
|
-
* single redaction seam.
|
|
2
|
+
* Event contract types + pure builders: bus-event payloads → telemetry records.
|
|
6
3
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Each record is one atomic "work unit": plain, immutable, serializable data with no methods or
|
|
5
|
+
* builder dance; variants are modelled with a discriminator field plus optionals. The types are
|
|
6
|
+
* transport-agnostic — nothing here knows about spans, attributes, or any wire format.
|
|
7
|
+
*
|
|
8
|
+
* The builders read a loosely-typed payload defensively (the `asObject`/`str`/`num`/`bool`/
|
|
9
|
+
* `toEpochMs` helpers below) and return a fully-populated record (or `null` when the event cannot
|
|
10
|
+
* yield one). Redaction is NOT done here — records are populated faithfully; a downstream mapper is
|
|
11
|
+
* the single redaction seam.
|
|
12
|
+
*
|
|
13
|
+
* Identity (service, recipe, runtime, strategy address, boot id) is stamped by the identity layer
|
|
14
|
+
* and is never on a record — see {@link IdentityEnvelope}. Timestamps are epoch milliseconds; ISO
|
|
15
|
+
* strings (and, for a scan result, an epoch-ms number) from the bus are converted once here, so
|
|
16
|
+
* consumers never parse dates.
|
|
9
17
|
*/
|
|
10
|
-
|
|
18
|
+
// ─── Defensive payload readers ─────────────────────────────────────────────────
|
|
19
|
+
//
|
|
20
|
+
// The builders read loosely-typed event data and must never throw while doing so, so every accessor
|
|
21
|
+
// coerces or returns `undefined` rather than trusting a shape.
|
|
22
|
+
/** A plain object, or `undefined` for anything else (null, array, primitive). */
|
|
23
|
+
export function asObject(value) {
|
|
24
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
/** A non-empty string, or `undefined`. */
|
|
30
|
+
export function str(value) {
|
|
31
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
32
|
+
}
|
|
33
|
+
/** A finite number, coercing numeric strings; `undefined` otherwise. */
|
|
34
|
+
export function num(value) {
|
|
35
|
+
if (typeof value === "number")
|
|
36
|
+
return Number.isFinite(value) ? value : undefined;
|
|
37
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
38
|
+
const n = Number(value);
|
|
39
|
+
return Number.isFinite(n) ? n : undefined;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
/** A boolean, or `undefined` (so absence stays distinct from `false`). */
|
|
44
|
+
export function bool(value) {
|
|
45
|
+
return typeof value === "boolean" ? value : undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* ISO string or epoch-ms number → epoch ms. Falls back to `fallbackMs` when the value is missing
|
|
49
|
+
* or unparseable, so a record always carries a usable timestamp instead of `NaN`.
|
|
50
|
+
*/
|
|
51
|
+
export function toEpochMs(value, fallbackMs) {
|
|
52
|
+
if (typeof value === "number")
|
|
53
|
+
return Number.isFinite(value) ? value : fallbackMs;
|
|
54
|
+
if (typeof value === "string") {
|
|
55
|
+
// A purely-numeric string is epoch ms, not a date to parse (Date.parse would mangle it).
|
|
56
|
+
if (/^-?\d+$/.test(value.trim())) {
|
|
57
|
+
const n = Number(value);
|
|
58
|
+
return Number.isFinite(n) ? n : fallbackMs;
|
|
59
|
+
}
|
|
60
|
+
const ms = Date.parse(value);
|
|
61
|
+
return Number.isNaN(ms) ? fallbackMs : ms;
|
|
62
|
+
}
|
|
63
|
+
return fallbackMs;
|
|
64
|
+
}
|
|
65
|
+
// ════════════════════════════════════════════════════════════════════════════════
|
|
66
|
+
// Pure builders: bus-event payloads → records
|
|
67
|
+
// ════════════════════════════════════════════════════════════════════════════════
|
|
11
68
|
/** `"LONG"`/`"SHORT"` → {@link TradeDirection}, else `null` (non-directional). */
|
|
12
69
|
function direction(value) {
|
|
13
70
|
return value === "LONG" || value === "SHORT" ? value : null;
|
|
@@ -52,8 +109,8 @@ function buildSignalSummary(raw, fallbackTs) {
|
|
|
52
109
|
meta: asObject(s.meta),
|
|
53
110
|
};
|
|
54
111
|
}
|
|
55
|
-
/** From a
|
|
56
|
-
*
|
|
112
|
+
/** From a scanner-run payload (complete / skipped / error): complete runs carry the whole
|
|
113
|
+
* `ScanResult`; skip/error carry status + reason. */
|
|
57
114
|
export function buildScannerRun(payload, nowMs) {
|
|
58
115
|
const p = asObject(payload);
|
|
59
116
|
const data = asObject(p?.data);
|
|
@@ -85,10 +142,10 @@ export function buildScannerRun(payload, nowMs) {
|
|
|
85
142
|
error: outcome === "error" ? str(data.reason) : undefined,
|
|
86
143
|
};
|
|
87
144
|
}
|
|
88
|
-
// ─── Scanner funnel summary (
|
|
145
|
+
// ─── Scanner funnel summary (derived from the scanner-run payload) ────────
|
|
89
146
|
/**
|
|
90
|
-
* The `scanner.summary` anti-spam log record, derived from the SAME
|
|
91
|
-
* that {@link buildScannerRun} reads (its `data.summary.funnel.dropped`)
|
|
147
|
+
* The `scanner.summary` anti-spam log record, derived from the SAME scanner-run payload
|
|
148
|
+
* that {@link buildScannerRun} reads (its `data.summary.funnel.dropped`).
|
|
92
149
|
*
|
|
93
150
|
* Returns `null` when there is no `data.summary.funnel`: skip/error runs and scanners without a
|
|
94
151
|
* funnel produce no summary event (the survivors are detailed by their own `signal.outcome` events,
|
|
@@ -141,7 +198,7 @@ export function buildScannerSummary(payload, nowMs) {
|
|
|
141
198
|
droppedCandidates: droppedCount > 0 ? droppedCandidates : undefined,
|
|
142
199
|
};
|
|
143
200
|
}
|
|
144
|
-
// ─── Signal evaluation (single-sourced from
|
|
201
|
+
// ─── Signal evaluation (single-sourced from the action-result payload) ────────────
|
|
145
202
|
/** Reason codes where the system evaluated a trade and actively blocked it (see {@link classifyOutcome}). */
|
|
146
203
|
const REJECTED_REASONS = new Set(["insufficient_margin", "invalid_direction", "no_margin_configured", "below_min_notional"]);
|
|
147
204
|
/** Reason codes where no trade was applicable / attempted. */
|
|
@@ -185,6 +242,8 @@ function buildOutcome(raw, positionId) {
|
|
|
185
242
|
error,
|
|
186
243
|
leverage: num(r.leverage),
|
|
187
244
|
marginAmount: num(r.marginAmount),
|
|
245
|
+
marginSource: str(r.marginSource),
|
|
246
|
+
marginPct: num(r.marginPct),
|
|
188
247
|
notionalValue: num(r.notionalValue),
|
|
189
248
|
orderId: str(r.orderId),
|
|
190
249
|
entryPrice: num(r.entryPrice),
|
|
@@ -195,7 +254,7 @@ function buildOutcome(raw, positionId) {
|
|
|
195
254
|
availableMarginAmount: num(r.availableMarginAmount),
|
|
196
255
|
};
|
|
197
256
|
}
|
|
198
|
-
/** The `data` envelope, embedded `result`, and per-signal `results[]` entries from
|
|
257
|
+
/** The `data` envelope, embedded `result`, and per-signal `results[]` entries from an action-result payload. */
|
|
199
258
|
function actionResults(actionResultPayload) {
|
|
200
259
|
const p = asObject(actionResultPayload);
|
|
201
260
|
const data = asObject(p?.data);
|
|
@@ -204,7 +263,7 @@ function actionResults(actionResultPayload) {
|
|
|
204
263
|
return { data, result, resultData, results: Array.isArray(resultData?.results) ? resultData.results : [] };
|
|
205
264
|
}
|
|
206
265
|
/**
|
|
207
|
-
* The
|
|
266
|
+
* The stamping rule: every per-signal outcome that pertains to a real position — open,
|
|
208
267
|
* just-submitted, or evaluated on a held asset (even when rejected/skipped) — carries that
|
|
209
268
|
* position's id; only a signal on an asset with no live position resolves to nothing. The
|
|
210
269
|
* lookup is deliberately unconditional on the outcome classification. The result entry's own
|
|
@@ -248,20 +307,17 @@ function buildEvaluations(results, findSignal, fallbackTs, resolvePositionId, ad
|
|
|
248
307
|
});
|
|
249
308
|
}
|
|
250
309
|
/**
|
|
251
|
-
* Build the whole pass record from
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* `result.data._decisionMeta`, so no pairing with `tracking.decision` is needed.
|
|
310
|
+
* Build the whole pass record from an action-result payload alone — the producers echo the scan
|
|
311
|
+
* provenance onto the payload (`scannerId`, `scannerSignals`, `minConfidence`, `runId`), and the
|
|
312
|
+
* decision itself rides `result.data._decisionMeta`, so no pairing is needed.
|
|
255
313
|
*
|
|
256
314
|
* `evaluations` is one entry per per-signal result, each enriched with the matching input signal
|
|
257
315
|
* (or a summary synthesized from the result entry when none matches — e.g. close-position's
|
|
258
316
|
* static-params path, which carries no `scannerSignals`). A pass without `_decisionMeta` yields no
|
|
259
317
|
* `decision` (the contract allows a decision-less pass).
|
|
260
318
|
*
|
|
261
|
-
* The pass
|
|
262
|
-
*
|
|
263
|
-
* (`endedAt < startedAt`) the start is pulled up to `endedAt`, yielding a zero (never negative)
|
|
264
|
-
* duration.
|
|
319
|
+
* The pass window is a point anchored at the action-result timestamp (`startedAt === endedAt`); the
|
|
320
|
+
* decision's own `durationMs` (from `_decisionMeta`) carries the timing.
|
|
265
321
|
*/
|
|
266
322
|
export function buildSignalEvaluated(actionResultPayload, nowMs, resolvePositionId) {
|
|
267
323
|
const { data, result, resultData, results } = actionResults(actionResultPayload);
|
|
@@ -269,9 +325,7 @@ export function buildSignalEvaluated(actionResultPayload, nowMs, resolvePosition
|
|
|
269
325
|
return null;
|
|
270
326
|
const p = asObject(actionResultPayload);
|
|
271
327
|
const endedAt = toEpochMs(p?.timestamp, nowMs);
|
|
272
|
-
|
|
273
|
-
if (endedAt < startedAt)
|
|
274
|
-
startedAt = endedAt;
|
|
328
|
+
const startedAt = endedAt;
|
|
275
329
|
const signals = Array.isArray(data.scannerSignals)
|
|
276
330
|
? data.scannerSignals.map((s) => buildSignalSummary(s, startedAt))
|
|
277
331
|
: [];
|
|
@@ -295,7 +349,6 @@ export function buildSignalEvaluated(actionResultPayload, nowMs, resolvePosition
|
|
|
295
349
|
model: str(meta.model),
|
|
296
350
|
tokensUsed: numOrNull(meta.tokensUsed),
|
|
297
351
|
durationMs: num(meta.durationMs),
|
|
298
|
-
endedAt: num(data.decisionEndedAt),
|
|
299
352
|
}
|
|
300
353
|
: undefined;
|
|
301
354
|
return {
|
|
@@ -308,7 +361,7 @@ export function buildSignalEvaluated(actionResultPayload, nowMs, resolvePosition
|
|
|
308
361
|
evaluations,
|
|
309
362
|
};
|
|
310
363
|
}
|
|
311
|
-
// ─── Self-learning event log: decision.made + signal.outcome
|
|
364
|
+
// ─── Self-learning event log: decision.made + signal.outcome ─────────────
|
|
312
365
|
//
|
|
313
366
|
// Both are DERIVED from the SAME built SignalEvaluatedRecord (single-source, DRY) — no re-parse of
|
|
314
367
|
// the payload, no new bus event. The mapper does the redaction; these builders populate faithfully.
|
|
@@ -354,7 +407,7 @@ export function buildDecisionMade(record) {
|
|
|
354
407
|
confidenceThreshold: d.confidenceThreshold,
|
|
355
408
|
durationMs: d.durationMs,
|
|
356
409
|
actionIntent: actionIntent(d.actionType),
|
|
357
|
-
// Market context
|
|
410
|
+
// Market context is NOT on the payload today → left undefined.
|
|
358
411
|
reasoning: d.reasoning,
|
|
359
412
|
};
|
|
360
413
|
}
|
|
@@ -380,23 +433,24 @@ export function buildSignalOutcomes(record) {
|
|
|
380
433
|
reasonCode: outcome.reasonCode,
|
|
381
434
|
positionId: outcome.positionId,
|
|
382
435
|
marginAmount: outcome.marginAmount,
|
|
436
|
+
marginSource: outcome.marginSource,
|
|
437
|
+
marginPct: outcome.marginPct,
|
|
383
438
|
leverage: outcome.leverage,
|
|
384
439
|
notionalValue: outcome.notionalValue,
|
|
385
440
|
size: outcome.size,
|
|
386
|
-
// marginSource is NOT on the payload today → left undefined (see impl notes).
|
|
387
441
|
orderId: outcome.orderId,
|
|
388
442
|
errorName: outcome.errorName,
|
|
389
443
|
rawSignal: { ...signal },
|
|
390
444
|
};
|
|
391
445
|
});
|
|
392
446
|
}
|
|
393
|
-
// ─── Self-learning event log: dsl.close_attempt
|
|
447
|
+
// ─── Self-learning event log: dsl.close_attempt ──────────────────────────
|
|
394
448
|
/** Coerces the producer's outcome string to the close-attempt result enum; default `error`. */
|
|
395
449
|
function closeAttemptResult(value) {
|
|
396
450
|
return value === "ok" ? "ok" : "error";
|
|
397
451
|
}
|
|
398
452
|
/**
|
|
399
|
-
* From the
|
|
453
|
+
* From the DSL close-attempt monitor payload — the second consumer (alongside the
|
|
400
454
|
* tick trace). Fields at the payload root: `positionId`, `asset`, `dex`, `closeReason`, `attempt`,
|
|
401
455
|
* `outcome` ("ok"|"error"), `error`, ISO `timestamp`. `null` when the payload is not an object.
|
|
402
456
|
*/
|
|
@@ -416,9 +470,9 @@ export function buildDslCloseAttempt(payload, nowMs) {
|
|
|
416
470
|
error: str(p.error),
|
|
417
471
|
};
|
|
418
472
|
}
|
|
419
|
-
// ─── Self-learning event log: order.{placed,filled,failed}
|
|
473
|
+
// ─── Self-learning event log: order.{placed,filled,failed} ────────────────
|
|
420
474
|
/**
|
|
421
|
-
* From the additive
|
|
475
|
+
* From the additive order events the open/close actions fire (the HookEvent shape:
|
|
422
476
|
* fields under a `data` envelope). One record per event; `eventKind` discriminates which fields the
|
|
423
477
|
* payload carries (placed: order/size; filled: fill; failed: reason/error). `positionId` maps from
|
|
424
478
|
* `__positionId`. `null` when no `asset` is resolvable — the asset is the one always-present scalar.
|
|
@@ -570,8 +624,8 @@ function dslTickOutcome(value) {
|
|
|
570
624
|
return value === "ok" || value === "error" ? value : undefined;
|
|
571
625
|
}
|
|
572
626
|
/**
|
|
573
|
-
* From the monitor's
|
|
574
|
-
*
|
|
627
|
+
* From the monitor's DSL tick / position / close-attempt / sl-update payloads (fields at the
|
|
628
|
+
* payload root). Each payload yields one record —
|
|
575
629
|
* the deterministic ids derived from `tickId` (and `tickId:positionKey`, both bootId-scoped by
|
|
576
630
|
* the mapper) thread them into one trace, so no pairing is needed here. Essentials are `tickId`
|
|
577
631
|
* plus a numeric work window; on clock skew (`endedAt < startedAt`) the start is pulled up to the
|
|
@@ -651,8 +705,8 @@ export function buildRuntimeError(payload, nowMs) {
|
|
|
651
705
|
}
|
|
652
706
|
// ─── Runtime lifecycle ───────────────────────────────────────────────────────
|
|
653
707
|
/**
|
|
654
|
-
* From
|
|
655
|
-
* resolved `data.config`
|
|
708
|
+
* From the runtime-started payload. The `config` blob is the injected **unresolved** config (not the
|
|
709
|
+
* resolved `data.config`): resolving inlines secrets, and the unresolved form is what the
|
|
656
710
|
* `configHash` is computed over, so blob and hash agree.
|
|
657
711
|
*/
|
|
658
712
|
export function buildRuntimeStarted(payload, unresolvedConfig, nowMs) {
|
|
@@ -671,7 +725,7 @@ export function buildRuntimeStarted(payload, unresolvedConfig, nowMs) {
|
|
|
671
725
|
config: unresolvedConfig,
|
|
672
726
|
};
|
|
673
727
|
}
|
|
674
|
-
/** From
|
|
728
|
+
/** From the runtime-stopped payload. */
|
|
675
729
|
export function buildRuntimeStopped(payload, nowMs) {
|
|
676
730
|
const p = asObject(payload);
|
|
677
731
|
const data = asObject(p?.data);
|
|
@@ -703,4 +757,4 @@ export function buildRuntimePaused(payload, fallbackGateId, nowMs) {
|
|
|
703
757
|
metrics: asObject(data.metrics) ?? null,
|
|
704
758
|
};
|
|
705
759
|
}
|
|
706
|
-
//# sourceMappingURL=
|
|
760
|
+
//# sourceMappingURL=event-builders.js.map
|