@senpi-ai/runtime 1.1.3 → 3.0.3
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/README.md +10 -9
- package/dist/actions/action-runtime-module.d.ts.map +1 -1
- package/dist/actions/action-runtime-module.js +1 -1
- package/dist/actions/action-runtime-module.js.map +1 -1
- package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +61 -14
- 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 +3 -0
- package/dist/actions/decision-engine.js.map +1 -1
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +140 -29
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.d.ts +6 -0
- package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.js +48 -0
- package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
- package/dist/actions/tracking-helpers.d.ts +16 -1
- package/dist/actions/tracking-helpers.d.ts.map +1 -1
- package/dist/actions/tracking-helpers.js +55 -9
- package/dist/actions/tracking-helpers.js.map +1 -1
- package/dist/actions/types.d.ts +10 -2
- package/dist/actions/types.d.ts.map +1 -1
- package/dist/actions/types.js +8 -0
- package/dist/actions/types.js.map +1 -1
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +84 -82
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +16 -110
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/constants/dsl/index.d.ts +2 -0
- package/dist/constants/dsl/index.d.ts.map +1 -1
- package/dist/constants/dsl/index.js +2 -0
- package/dist/constants/dsl/index.js.map +1 -1
- package/dist/dsl/config/parse-tiers.d.ts.map +1 -1
- package/dist/dsl/config/parse-tiers.js +6 -2
- package/dist/dsl/config/parse-tiers.js.map +1 -1
- package/dist/dsl/engine-client/config-mapping.d.ts +3 -1
- package/dist/dsl/engine-client/config-mapping.d.ts.map +1 -1
- package/dist/dsl/engine-client/config-mapping.js +3 -1
- package/dist/dsl/engine-client/config-mapping.js.map +1 -1
- package/dist/dsl/engine-client/event-mapping.d.ts +2 -0
- package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
- package/dist/dsl/engine-client/event-mapping.js +3 -0
- 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 +1 -0
- package/dist/dsl/events/build-closed-event.js.map +1 -1
- package/dist/dsl/events/guards.d.ts.map +1 -1
- package/dist/dsl/events/guards.js +10 -0
- package/dist/dsl/events/guards.js.map +1 -1
- package/dist/dsl/events/handlers.d.ts +18 -2
- package/dist/dsl/events/handlers.d.ts.map +1 -1
- package/dist/dsl/events/handlers.js +304 -208
- 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 +3 -1
- package/dist/dsl/events/initial-state.js.map +1 -1
- package/dist/dsl/monitor/create-monitor.d.ts +15 -0
- package/dist/dsl/monitor/create-monitor.d.ts.map +1 -1
- package/dist/dsl/monitor/create-monitor.js +76 -9
- package/dist/dsl/monitor/create-monitor.js.map +1 -1
- package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
- package/dist/dsl/monitor/process-one-position.js +268 -82
- package/dist/dsl/monitor/process-one-position.js.map +1 -1
- package/dist/dsl/plugin/index.d.ts +16 -1
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js +35 -4
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/dsl/plugin/options.d.ts +18 -0
- package/dist/dsl/plugin/options.d.ts.map +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +272 -32
- package/dist/index.js.map +1 -1
- package/dist/recording/emitter.d.ts +27 -0
- package/dist/recording/emitter.d.ts.map +1 -0
- package/dist/recording/emitter.js +2 -0
- package/dist/recording/emitter.js.map +1 -0
- package/dist/recording/identity.d.ts +34 -0
- package/dist/recording/identity.d.ts.map +1 -0
- package/dist/recording/identity.js +2 -0
- package/dist/recording/identity.js.map +1 -0
- package/dist/recording/index.d.ts +11 -0
- package/dist/recording/index.d.ts.map +1 -0
- package/dist/recording/index.js +2 -0
- package/dist/recording/index.js.map +1 -0
- package/dist/recording/noop-emitter.d.ts +23 -0
- package/dist/recording/noop-emitter.d.ts.map +1 -0
- package/dist/recording/noop-emitter.js +22 -0
- package/dist/recording/noop-emitter.js.map +1 -0
- package/dist/recording/otel/attributes.d.ts +35 -0
- package/dist/recording/otel/attributes.d.ts.map +1 -0
- package/dist/recording/otel/attributes.js +131 -0
- package/dist/recording/otel/attributes.js.map +1 -0
- package/dist/recording/otel/constants.d.ts +123 -0
- package/dist/recording/otel/constants.d.ts.map +1 -0
- package/dist/recording/otel/constants.js +172 -0
- package/dist/recording/otel/constants.js.map +1 -0
- package/dist/recording/otel/ids.d.ts +25 -0
- package/dist/recording/otel/ids.d.ts.map +1 -0
- package/dist/recording/otel/ids.js +37 -0
- package/dist/recording/otel/ids.js.map +1 -0
- package/dist/recording/otel/index.d.ts +13 -0
- package/dist/recording/otel/index.d.ts.map +1 -0
- package/dist/recording/otel/index.js +9 -0
- package/dist/recording/otel/index.js.map +1 -0
- package/dist/recording/otel/mappers.d.ts +100 -0
- package/dist/recording/otel/mappers.d.ts.map +1 -0
- package/dist/recording/otel/mappers.js +683 -0
- package/dist/recording/otel/mappers.js.map +1 -0
- package/dist/recording/otel/otel-emitter.d.ts +43 -0
- package/dist/recording/otel/otel-emitter.d.ts.map +1 -0
- package/dist/recording/otel/otel-emitter.js +99 -0
- package/dist/recording/otel/otel-emitter.js.map +1 -0
- package/dist/recording/otel/redaction.d.ts +47 -0
- package/dist/recording/otel/redaction.d.ts.map +1 -0
- package/dist/recording/otel/redaction.js +88 -0
- package/dist/recording/otel/redaction.js.map +1 -0
- package/dist/recording/records.d.ts +565 -0
- package/dist/recording/records.d.ts.map +1 -0
- package/dist/recording/records.js +14 -0
- package/dist/recording/records.js.map +1 -0
- package/dist/recording/transport/batcher.d.ts +59 -0
- package/dist/recording/transport/batcher.d.ts.map +1 -0
- package/dist/recording/transport/batcher.js +234 -0
- package/dist/recording/transport/batcher.js.map +1 -0
- package/dist/recording/transport/client.d.ts +41 -0
- package/dist/recording/transport/client.d.ts.map +1 -0
- package/dist/recording/transport/client.js +69 -0
- package/dist/recording/transport/client.js.map +1 -0
- package/dist/recording/transport/config.d.ts +53 -0
- package/dist/recording/transport/config.d.ts.map +1 -0
- package/dist/recording/transport/config.js +41 -0
- package/dist/recording/transport/config.js.map +1 -0
- package/dist/recording/transport/index.d.ts +16 -0
- package/dist/recording/transport/index.d.ts.map +1 -0
- package/dist/recording/transport/index.js +12 -0
- package/dist/recording/transport/index.js.map +1 -0
- package/dist/recording/transport/rows.d.ts +88 -0
- package/dist/recording/transport/rows.d.ts.map +1 -0
- package/dist/recording/transport/rows.js +15 -0
- package/dist/recording/transport/rows.js.map +1 -0
- package/dist/recording/wiring/emitter-factory.d.ts +39 -0
- package/dist/recording/wiring/emitter-factory.d.ts.map +1 -0
- package/dist/recording/wiring/emitter-factory.js +62 -0
- package/dist/recording/wiring/emitter-factory.js.map +1 -0
- package/dist/recording/wiring/identity.d.ts +27 -0
- package/dist/recording/wiring/identity.d.ts.map +1 -0
- package/dist/recording/wiring/identity.js +51 -0
- package/dist/recording/wiring/identity.js.map +1 -0
- package/dist/recording/wiring/index.d.ts +12 -0
- package/dist/recording/wiring/index.d.ts.map +1 -0
- package/dist/recording/wiring/index.js +9 -0
- package/dist/recording/wiring/index.js.map +1 -0
- package/dist/recording/wiring/record-builders.d.ts +107 -0
- package/dist/recording/wiring/record-builders.d.ts.map +1 -0
- package/dist/recording/wiring/record-builders.js +706 -0
- package/dist/recording/wiring/record-builders.js.map +1 -0
- package/dist/recording/wiring/subscriber.d.ts +28 -0
- package/dist/recording/wiring/subscriber.d.ts.map +1 -0
- package/dist/recording/wiring/subscriber.js +173 -0
- package/dist/recording/wiring/subscriber.js.map +1 -0
- package/dist/recording/wiring/values.d.ts +19 -0
- package/dist/recording/wiring/values.d.ts.map +1 -0
- package/dist/recording/wiring/values.js +49 -0
- package/dist/recording/wiring/values.js.map +1 -0
- package/dist/runtime/auto-update/command-runner.d.ts.map +1 -1
- package/dist/runtime/auto-update/command-runner.js +5 -1
- package/dist/runtime/auto-update/command-runner.js.map +1 -1
- package/dist/runtime/auto-update/resolve-package-name.d.ts +10 -0
- package/dist/runtime/auto-update/resolve-package-name.d.ts.map +1 -0
- package/dist/runtime/auto-update/resolve-package-name.js +35 -0
- package/dist/runtime/auto-update/resolve-package-name.js.map +1 -0
- package/dist/runtime/auto-update/run-update-command.d.ts +2 -0
- package/dist/runtime/auto-update/run-update-command.d.ts.map +1 -0
- package/dist/runtime/auto-update/run-update-command.js +37 -0
- package/dist/runtime/auto-update/run-update-command.js.map +1 -0
- package/dist/runtime/create-runtime-context.d.ts +2 -0
- package/dist/runtime/create-runtime-context.d.ts.map +1 -1
- package/dist/runtime/create-runtime-context.js +1 -0
- package/dist/runtime/create-runtime-context.js.map +1 -1
- package/dist/runtime/create-scanner-module.d.ts +4 -3
- package/dist/runtime/create-scanner-module.d.ts.map +1 -1
- package/dist/runtime/create-scanner-module.js +14 -5
- package/dist/runtime/create-scanner-module.js.map +1 -1
- package/dist/runtime/create-scanner-providers-for-run.d.ts.map +1 -1
- package/dist/runtime/create-scanner-providers-for-run.js +12 -1
- package/dist/runtime/create-scanner-providers-for-run.js.map +1 -1
- package/dist/runtime/load-runtime-config.d.ts +9 -0
- package/dist/runtime/load-runtime-config.d.ts.map +1 -1
- package/dist/runtime/load-runtime-config.js +41 -8
- package/dist/runtime/load-runtime-config.js.map +1 -1
- package/dist/runtime/map-strategies-registration.js +7 -8
- package/dist/runtime/map-strategies-registration.js.map +1 -1
- package/dist/runtime/map-strategies.d.ts.map +1 -1
- package/dist/runtime/map-strategies.js +12 -3
- package/dist/runtime/map-strategies.js.map +1 -1
- package/dist/runtime/recipe-version.d.ts +1 -1
- package/dist/runtime/recipe-version.d.ts.map +1 -1
- package/dist/runtime/recipe-version.js +1 -1
- package/dist/runtime/recipe-version.js.map +1 -1
- package/dist/runtime/reconcile-decide.d.ts +73 -0
- package/dist/runtime/reconcile-decide.d.ts.map +1 -0
- package/dist/runtime/reconcile-decide.js +186 -0
- package/dist/runtime/reconcile-decide.js.map +1 -0
- package/dist/runtime/reconcile-run.d.ts +62 -0
- package/dist/runtime/reconcile-run.d.ts.map +1 -0
- package/dist/runtime/reconcile-run.js +173 -0
- package/dist/runtime/reconcile-run.js.map +1 -0
- package/dist/runtime/reconcile-state.d.ts +44 -0
- package/dist/runtime/reconcile-state.d.ts.map +1 -1
- package/dist/runtime/reconcile-state.js +80 -44
- package/dist/runtime/reconcile-state.js.map +1 -1
- package/dist/runtime/risk-guard.d.ts.map +1 -1
- package/dist/runtime/risk-guard.js +17 -12
- package/dist/runtime/risk-guard.js.map +1 -1
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +3 -2
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime-schema.d.ts +4056 -793
- package/dist/runtime/runtime-schema.d.ts.map +1 -1
- package/dist/runtime/runtime-schema.js +183 -46
- package/dist/runtime/runtime-schema.js.map +1 -1
- package/dist/runtime/runtime-version.d.ts +3 -6
- package/dist/runtime/runtime-version.d.ts.map +1 -1
- package/dist/runtime/runtime-version.js +3 -6
- package/dist/runtime/runtime-version.js.map +1 -1
- package/dist/runtime/runtime.d.ts +47 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +516 -146
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/scanner-registry.d.ts +1 -1
- package/dist/runtime/scanner-registry.d.ts.map +1 -1
- package/dist/runtime/scanner-registry.js +3 -12
- package/dist/runtime/scanner-registry.js.map +1 -1
- package/dist/runtime/strategy-registry.d.ts +6 -0
- package/dist/runtime/strategy-registry.d.ts.map +1 -1
- package/dist/runtime/strategy-registry.js +1 -0
- package/dist/runtime/strategy-registry.js.map +1 -1
- package/dist/runtime/supervisor/long-running-supervisor.d.ts +222 -0
- package/dist/runtime/supervisor/long-running-supervisor.d.ts.map +1 -0
- package/dist/runtime/supervisor/long-running-supervisor.js +625 -0
- package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -0
- package/dist/runtime/supervisor/orphan-sweep.d.ts +36 -0
- package/dist/runtime/supervisor/orphan-sweep.d.ts.map +1 -0
- package/dist/runtime/supervisor/orphan-sweep.js +255 -0
- package/dist/runtime/supervisor/orphan-sweep.js.map +1 -0
- package/dist/runtime/supervisor/supervisor-utils.d.ts +37 -0
- package/dist/runtime/supervisor/supervisor-utils.d.ts.map +1 -0
- package/dist/runtime/supervisor/supervisor-utils.js +175 -0
- package/dist/runtime/supervisor/supervisor-utils.js.map +1 -0
- package/dist/runtime-api/handlers/ingest-signals.d.ts +3 -3
- package/dist/runtime-api/handlers/ingest-signals.js +3 -3
- package/dist/runtime-api/intake/acceptance-record.d.ts +103 -0
- package/dist/runtime-api/intake/acceptance-record.d.ts.map +1 -0
- package/dist/runtime-api/intake/acceptance-record.js +192 -0
- package/dist/runtime-api/intake/acceptance-record.js.map +1 -0
- package/dist/runtime-api/intake/intake-context.d.ts +31 -0
- package/dist/runtime-api/intake/intake-context.d.ts.map +1 -0
- package/dist/runtime-api/intake/intake-context.js +21 -0
- package/dist/runtime-api/intake/intake-context.js.map +1 -0
- package/dist/runtime-api/intake/intake-mount.d.ts +118 -0
- package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -0
- package/dist/runtime-api/intake/intake-mount.js +193 -0
- package/dist/runtime-api/intake/intake-mount.js.map +1 -0
- package/dist/runtime-api/intake/liveness-store.d.ts +32 -0
- package/dist/runtime-api/intake/liveness-store.d.ts.map +1 -0
- package/dist/runtime-api/intake/liveness-store.js +31 -0
- package/dist/runtime-api/intake/liveness-store.js.map +1 -0
- package/dist/runtime-api/intake/process-error-post.d.ts +15 -0
- package/dist/runtime-api/intake/process-error-post.d.ts.map +1 -0
- package/dist/runtime-api/intake/process-error-post.js +19 -0
- package/dist/runtime-api/intake/process-error-post.js.map +1 -0
- package/dist/runtime-api/intake/process-signal-post.d.ts +73 -0
- package/dist/runtime-api/intake/process-signal-post.d.ts.map +1 -0
- package/dist/runtime-api/intake/process-signal-post.js +188 -0
- package/dist/runtime-api/intake/process-signal-post.js.map +1 -0
- package/dist/runtime-api/intake/scanner-launcher.d.ts +133 -0
- package/dist/runtime-api/intake/scanner-launcher.d.ts.map +1 -0
- package/dist/runtime-api/intake/scanner-launcher.js +204 -0
- package/dist/runtime-api/intake/scanner-launcher.js.map +1 -0
- package/dist/runtime-api/intake/scanner-registry.d.ts +36 -0
- package/dist/runtime-api/intake/scanner-registry.d.ts.map +1 -0
- package/dist/runtime-api/intake/scanner-registry.js +29 -0
- package/dist/runtime-api/intake/scanner-registry.js.map +1 -0
- package/dist/runtime-api/intake/types.d.ts +61 -0
- package/dist/runtime-api/intake/types.d.ts.map +1 -0
- package/dist/runtime-api/intake/types.js +8 -0
- package/dist/runtime-api/intake/types.js.map +1 -0
- package/dist/runtime-api/routes/signals.d.ts +20 -40
- package/dist/runtime-api/routes/signals.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.js +119 -75
- package/dist/runtime-api/routes/signals.js.map +1 -1
- package/dist/runtime-api/routes/signals.schema.d.ts +24 -86
- package/dist/runtime-api/routes/signals.schema.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.schema.js +35 -50
- package/dist/runtime-api/routes/signals.schema.js.map +1 -1
- package/dist/runtime-api/server.d.ts +15 -6
- package/dist/runtime-api/server.d.ts.map +1 -1
- package/dist/runtime-api/server.js +12 -12
- package/dist/runtime-api/server.js.map +1 -1
- package/dist/scanners/events.d.ts +6 -0
- package/dist/scanners/events.d.ts.map +1 -1
- package/dist/scanners/events.js.map +1 -1
- package/dist/scanners/external/scaffold/__init__.py +16 -0
- package/dist/scanners/external/scaffold/__main__.py +155 -0
- package/dist/scanners/external/scaffold/ctx.py +78 -0
- package/dist/scanners/external/scaffold/delivery.py +263 -0
- package/dist/scanners/external/scaffold/entrypoint_loader.py +151 -0
- package/dist/scanners/external/scaffold/http_post.py +70 -0
- package/dist/scanners/external/scaffold/journal.py +247 -0
- package/dist/scanners/external/scaffold/loop_primitives.py +65 -0
- package/dist/scanners/external/scaffold/requirements.txt +11 -0
- package/dist/scanners/external/scaffold/scaffold.py +361 -0
- package/dist/scanners/external/scaffold/scaffold_state.py +114 -0
- package/dist/scanners/external/scaffold/senpi_mcp.py +250 -0
- package/dist/scanners/external/scaffold/signal_envelope.py +220 -0
- package/dist/scanners/external/scaffold/state_manager.py +175 -0
- package/dist/scanners/external-scanner-receiver.d.ts +17 -1
- package/dist/scanners/external-scanner-receiver.d.ts.map +1 -1
- package/dist/scanners/external-scanner-receiver.js +16 -3
- package/dist/scanners/external-scanner-receiver.js.map +1 -1
- package/dist/scanners/implementations/external-scanner.d.ts.map +1 -1
- package/dist/scanners/implementations/external-scanner.js +7 -1
- package/dist/scanners/implementations/external-scanner.js.map +1 -1
- package/dist/scanners/implementations/momentum.d.ts.map +1 -1
- package/dist/scanners/implementations/momentum.js +16 -0
- package/dist/scanners/implementations/momentum.js.map +1 -1
- package/dist/scanners/runtime-module.d.ts.map +1 -1
- package/dist/scanners/runtime-module.js +9 -1
- package/dist/scanners/runtime-module.js.map +1 -1
- package/dist/scripts/run-dsl-standalone-live.d.ts +1 -1
- package/dist/scripts/run-dsl-standalone-live.js +5 -3
- package/dist/scripts/run-dsl-standalone-live.js.map +1 -1
- package/dist/senpi/client.d.ts +56 -4
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +123 -24
- package/dist/senpi/client.js.map +1 -1
- package/dist/senpi/index.d.ts +2 -1
- package/dist/senpi/index.d.ts.map +1 -1
- package/dist/senpi/index.js +1 -1
- package/dist/senpi/index.js.map +1 -1
- package/dist/senpi/types.d.ts +1 -2
- package/dist/senpi/types.d.ts.map +1 -1
- package/dist/state/state-manager.d.ts +17 -0
- package/dist/state/state-manager.d.ts.map +1 -1
- package/dist/state/state-manager.js +55 -4
- package/dist/state/state-manager.js.map +1 -1
- package/dist/strategy/strategy-state.d.ts +9 -1
- package/dist/strategy/strategy-state.d.ts.map +1 -1
- package/dist/strategy/strategy-state.js +62 -9
- package/dist/strategy/strategy-state.js.map +1 -1
- package/dist/tracking/build-rehydrate-items.d.ts +15 -0
- package/dist/tracking/build-rehydrate-items.d.ts.map +1 -0
- package/dist/tracking/build-rehydrate-items.js +19 -0
- package/dist/tracking/build-rehydrate-items.js.map +1 -0
- package/dist/tracking/constants.d.ts.map +1 -1
- package/dist/tracking/constants.js +2 -0
- package/dist/tracking/constants.js.map +1 -1
- package/dist/tracking/index.d.ts +3 -0
- package/dist/tracking/index.d.ts.map +1 -1
- package/dist/tracking/index.js +2 -0
- package/dist/tracking/index.js.map +1 -1
- package/dist/tracking/position-id-registry.d.ts +69 -0
- package/dist/tracking/position-id-registry.d.ts.map +1 -0
- package/dist/tracking/position-id-registry.js +139 -0
- package/dist/tracking/position-id-registry.js.map +1 -0
- package/dist/tracking/spans/fan-out-span-transport.d.ts +22 -0
- package/dist/tracking/spans/fan-out-span-transport.d.ts.map +1 -0
- package/dist/tracking/spans/fan-out-span-transport.js +49 -0
- package/dist/tracking/spans/fan-out-span-transport.js.map +1 -0
- package/dist/tracking/spans/otel/fit-row-budget.d.ts +22 -0
- package/dist/tracking/spans/otel/fit-row-budget.d.ts.map +1 -0
- package/dist/tracking/spans/otel/fit-row-budget.js +91 -0
- package/dist/tracking/spans/otel/fit-row-budget.js.map +1 -0
- package/dist/tracking/spans/otel/map-span-to-trace-row.d.ts +16 -0
- package/dist/tracking/spans/otel/map-span-to-trace-row.d.ts.map +1 -0
- package/dist/tracking/spans/otel/map-span-to-trace-row.js +227 -0
- package/dist/tracking/spans/otel/map-span-to-trace-row.js.map +1 -0
- package/dist/tracking/spans/otel/recording-span-transport.d.ts +43 -0
- package/dist/tracking/spans/otel/recording-span-transport.d.ts.map +1 -0
- package/dist/tracking/spans/otel/recording-span-transport.js +67 -0
- package/dist/tracking/spans/otel/recording-span-transport.js.map +1 -0
- package/dist/tracking/spans/otel/span-ids.d.ts +22 -0
- package/dist/tracking/spans/otel/span-ids.d.ts.map +1 -0
- package/dist/tracking/spans/otel/span-ids.js +32 -0
- package/dist/tracking/spans/otel/span-ids.js.map +1 -0
- package/dist/tracking/spans/plugin-span-tracker.d.ts +6 -0
- package/dist/tracking/spans/plugin-span-tracker.d.ts.map +1 -1
- package/dist/tracking/spans/plugin-span-tracker.js +82 -9
- package/dist/tracking/spans/plugin-span-tracker.js.map +1 -1
- package/dist/tracking/spans/redact-pii.d.ts +3 -1
- package/dist/tracking/spans/redact-pii.d.ts.map +1 -1
- package/dist/tracking/spans/redact-pii.js +5 -1
- package/dist/tracking/spans/redact-pii.js.map +1 -1
- package/dist/tracking/spans/span-transport.d.ts +6 -0
- package/dist/tracking/spans/span-transport.d.ts.map +1 -1
- package/dist/tracking/spans/span-transport.js +1 -1
- package/dist/tracking/spans/span-transport.js.map +1 -1
- package/dist/types/dsl/index.d.ts +24 -1
- package/dist/types/dsl/index.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +6 -0
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/scanner.d.ts +7 -0
- package/dist/types/scanner.d.ts.map +1 -1
- package/dist/types/strategy.d.ts +3 -1
- package/dist/types/strategy.d.ts.map +1 -1
- package/dist/utils/keyed-mutex.d.ts +37 -0
- package/dist/utils/keyed-mutex.d.ts.map +1 -0
- package/dist/utils/keyed-mutex.js +77 -0
- package/dist/utils/keyed-mutex.js.map +1 -0
- package/dist/utils/safe-spawn.d.ts +6 -0
- package/dist/utils/safe-spawn.d.ts.map +1 -0
- package/dist/utils/safe-spawn.js +62 -0
- package/dist/utils/safe-spawn.js.map +1 -0
- package/examples/strategies/README.md +17 -12
- package/examples/strategies/iguana/README.md +135 -0
- package/examples/strategies/iguana/recipe.yaml +137 -0
- package/examples/strategies/iguana/scanners/scan.py +243 -0
- package/examples/strategies/iguana/scanners/scoring.py +152 -0
- package/examples/strategies/raptor/README.md +156 -0
- package/examples/strategies/raptor/recipe.yaml +154 -0
- package/examples/strategies/raptor/scanners/scan.py +349 -0
- package/examples/strategies/raptor/scanners/scoring.py +452 -0
- package/examples/strategies/spider/README.md +89 -0
- package/examples/strategies/spider/scalp/recipe.yaml +129 -0
- package/examples/strategies/spider/scalp/scanners/scan.py +219 -0
- package/examples/strategies/spider/scalp/scanners/scoring.py +179 -0
- package/examples/strategies/spider/swing/recipe.yaml +137 -0
- package/examples/strategies/spider/swing/scanners/scan.py +334 -0
- package/examples/strategies/spider/swing/scanners/scoring.py +184 -0
- package/examples/strategies/turbine/README.md +166 -0
- package/examples/strategies/turbine/recipe-runners.yaml +123 -0
- package/examples/strategies/turbine/recipe-volume.yaml +129 -0
- package/examples/strategies/turbine/scanners/scan.py +283 -0
- package/examples/strategies/turbine/scanners/scoring.py +190 -0
- package/openclaw.plugin.json +12 -1
- package/package.json +3 -3
- package/dist/runtime-api/handlers/group-by-scanner.d.ts +0 -43
- package/dist/runtime-api/handlers/group-by-scanner.d.ts.map +0 -1
- package/dist/runtime-api/handlers/group-by-scanner.js +0 -43
- package/dist/runtime-api/handlers/group-by-scanner.js.map +0 -1
- package/dist/scanners/external/liquidation-watchdog/README.md +0 -107
- package/dist/scanners/external/liquidation-watchdog/liquidation-watchdog.yaml +0 -48
- package/dist/scanners/external/liquidation-watchdog/producer.mjs +0 -336
- package/dist/scanners/external/momentum/README.md +0 -148
- package/dist/scanners/external/momentum/momentum.yaml +0 -116
- package/dist/scanners/external/momentum/producer.mjs +0 -251
- package/dist/scanners/external/shared/ingest.mjs +0 -112
- package/examples/README.md +0 -89
- package/examples/scanners-consumer-quickstart.mjs +0 -134
- package/examples/scanners-emerging-movers-v4.mjs +0 -287
- package/examples/scanners-liquidation-watchdog.mjs +0 -341
- package/examples/scanners-live-mcp.mjs +0 -208
- package/examples/scanners-multi-strategy.mjs +0 -165
- package/examples/scanners-position-tracker-e2e.mjs +0 -225
- package/examples/scanners-scheduled-events.mjs +0 -96
- package/examples/scanners-senpi-provider-client.mjs +0 -182
- package/examples/scanners-single-strategy.mjs +0 -198
- package/examples/strategies/dsl-showcase.yaml +0 -68
- package/examples/strategies/dsl.yaml +0 -51
- package/examples/strategies/fox-minimal-loosened.yaml +0 -240
- package/examples/strategies/fox-minimal.yaml +0 -242
- package/examples/strategies/minimal.yaml +0 -46
- package/examples/strategies/momentum/how-it-works.md +0 -48
- package/examples/strategies/momentum/momentum-guarded.yaml +0 -161
- package/examples/strategies/risk-showcase.yaml +0 -93
- package/examples/strategies/viper.yaml +0 -67
- package/examples/strategies/wolf.yaml +0 -72
- package/examples/yamls/sample-with-dsl-and-emerging-movers.yaml +0 -123
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""TURBINE — pure rotation/direction/spread functions (port of turbine-producer.py v3.2.2).
|
|
2
|
+
|
|
3
|
+
Ported VERBATIM from senpi-skills/turbine/scripts/turbine-producer.py (choose_direction,
|
|
4
|
+
pick_rotation_asset, spread parsing) and turbine_config.py (normalize_coin_key). No I/O, no
|
|
5
|
+
MCP, no daemon — pure and unit-testable. `scan.py` fetches per-asset market data via
|
|
6
|
+
ctx.senpi_mcp and hands it to these helpers.
|
|
7
|
+
|
|
8
|
+
Both turbine legs (volume + runners) share THIS scoring module: the source ran the identical
|
|
9
|
+
volume-rotation alpha on both wallets and let the wallet boundary (DSL preset + sizing) select
|
|
10
|
+
behavior. So there is no per-leg branch here — only sizing/exit differ, and those live in the
|
|
11
|
+
recipe YAMLs, not in the signal logic.
|
|
12
|
+
|
|
13
|
+
Source thresholds preserved exactly:
|
|
14
|
+
- Universe MAIN = [BTC, ETH, SOL, HYPE]; XYZ = [xyz:BRENTOIL, xyz:GOLD, xyz:SPX].
|
|
15
|
+
- Direction = funding fade: LONG_CROWDED/LONG_HEAVY -> SHORT (funding_fade_short),
|
|
16
|
+
SHORT_CROWDED/SHORT_HEAVY -> LONG (funding_fade_long), else random LONG/SHORT
|
|
17
|
+
(alternate_neutral).
|
|
18
|
+
- Rotation: probabilistic pool pick (random.random() < xyz_weight -> XYZ pool, else MAIN),
|
|
19
|
+
then a deterministic rotation index inside the pool; skip held + 90s post-close cooldown;
|
|
20
|
+
fall through to the OTHER pool if the chosen one is exhausted.
|
|
21
|
+
- Spread gate: main <= spread_main_bps (3), xyz <= spread_xyz_bps (10). spread_bps from the
|
|
22
|
+
top-of-book mid: ((ask - bid) / mid) * 10000.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
import random
|
|
26
|
+
import time
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# ── Universe (shared by both wallets) ──
|
|
30
|
+
|
|
31
|
+
VOLUME_XYZ = ["xyz:BRENTOIL", "xyz:GOLD", "xyz:SPX"]
|
|
32
|
+
VOLUME_MAIN = ["BTC", "ETH", "SOL", "HYPE"]
|
|
33
|
+
|
|
34
|
+
POST_CLOSE_COOLDOWN_SECONDS = 90
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def is_xyz(asset):
|
|
38
|
+
return asset.startswith("xyz:")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def normalize_coin_key(coin):
|
|
42
|
+
"""Canonicalize a coin string for held_keys / cooldown sets.
|
|
43
|
+
|
|
44
|
+
Port of turbine_config.normalize_coin_key (v3.2.2): preserve the xyz: prefix so that
|
|
45
|
+
main:HYPE and xyz:HYPE are distinct slot occupiers. Lowercase the prefix, uppercase the
|
|
46
|
+
symbol; bare symbols are uppercased.
|
|
47
|
+
"""
|
|
48
|
+
if not coin:
|
|
49
|
+
return ""
|
|
50
|
+
s = coin.strip()
|
|
51
|
+
if ":" in s:
|
|
52
|
+
prefix, _, symbol = s.partition(":")
|
|
53
|
+
return f"{prefix.lower()}:{symbol.upper()}"
|
|
54
|
+
return s.upper()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def safe_float(v, d=0.0):
|
|
58
|
+
try:
|
|
59
|
+
return float(v)
|
|
60
|
+
except (TypeError, ValueError):
|
|
61
|
+
return d
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# ── Direction: funding fade (verbatim from producer.choose_direction) ──
|
|
65
|
+
|
|
66
|
+
def choose_direction(regime, rng=random):
|
|
67
|
+
"""Funding fade. Crowded longs -> SHORT, crowded shorts -> LONG, flat -> coin flip.
|
|
68
|
+
|
|
69
|
+
Returns (direction, thesis). `rng` is injectable for deterministic tests; the source used
|
|
70
|
+
the module-level `random`.
|
|
71
|
+
"""
|
|
72
|
+
r = (regime or "").upper()
|
|
73
|
+
if r in ("LONG_CROWDED", "LONG_HEAVY"):
|
|
74
|
+
return "SHORT", "funding_fade_short"
|
|
75
|
+
if r in ("SHORT_CROWDED", "SHORT_HEAVY"):
|
|
76
|
+
return "LONG", "funding_fade_long"
|
|
77
|
+
return rng.choice(["LONG", "SHORT"]), "alternate_neutral"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# ── Spread parsing (verbatim from producer.query_asset_data) ──
|
|
81
|
+
|
|
82
|
+
def _lvl_px(lvl):
|
|
83
|
+
if isinstance(lvl, dict):
|
|
84
|
+
return safe_float(lvl.get("px", lvl.get("price", 0)))
|
|
85
|
+
if isinstance(lvl, list) and lvl:
|
|
86
|
+
return safe_float(lvl[0])
|
|
87
|
+
return 0.0
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def parse_asset_data(resp):
|
|
91
|
+
"""Extract bid/ask/mid/spread_bps + funding regime from a market_get_asset_data response.
|
|
92
|
+
|
|
93
|
+
Returns a dict or None when the order book is missing / one-sided / non-positive (the
|
|
94
|
+
source treated all of these as 'skip this asset'). Mirrors producer.query_asset_data
|
|
95
|
+
exactly: top-of-book levels, mid = (bid+ask)/2, spread_bps = ((ask-bid)/mid)*10000.
|
|
96
|
+
"""
|
|
97
|
+
if not resp or not isinstance(resp, dict):
|
|
98
|
+
return None
|
|
99
|
+
ad = resp.get("data", resp)
|
|
100
|
+
if not isinstance(ad, dict):
|
|
101
|
+
return None
|
|
102
|
+
ob = ad.get("order_book") or ad.get("orderBook") or {}
|
|
103
|
+
levels = ob.get("levels", [])
|
|
104
|
+
if not isinstance(levels, list) or len(levels) < 2:
|
|
105
|
+
return None
|
|
106
|
+
bids, asks = levels[0], levels[1]
|
|
107
|
+
if not bids or not asks:
|
|
108
|
+
return None
|
|
109
|
+
bid = _lvl_px(bids[0])
|
|
110
|
+
ask = _lvl_px(asks[0])
|
|
111
|
+
if bid <= 0 or ask <= 0:
|
|
112
|
+
return None
|
|
113
|
+
mid = (bid + ask) / 2.0
|
|
114
|
+
spread_bps = ((ask - bid) / mid) * 10000 if mid > 0 else 999
|
|
115
|
+
|
|
116
|
+
funding_regime = (
|
|
117
|
+
ad.get("funding_regime") or ad.get("fundingRegime") or "UNKNOWN"
|
|
118
|
+
).upper()
|
|
119
|
+
funding_annualized_pct = safe_float(
|
|
120
|
+
ad.get("funding_annualized_pct") or ad.get("fundingAnnualizedPct") or 0
|
|
121
|
+
)
|
|
122
|
+
return {
|
|
123
|
+
"bid": bid,
|
|
124
|
+
"ask": ask,
|
|
125
|
+
"mid": mid,
|
|
126
|
+
"spread_bps": round(spread_bps, 3),
|
|
127
|
+
"funding_regime": funding_regime,
|
|
128
|
+
"funding_annualized_pct": funding_annualized_pct,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def spread_ok(asset, spread_bps, spread_main_bps, spread_xyz_bps):
|
|
133
|
+
"""Spread gate: xyz assets get the wider xyz cap, everything else the main cap."""
|
|
134
|
+
max_spread = spread_xyz_bps if is_xyz(asset) else spread_main_bps
|
|
135
|
+
return spread_bps <= max_spread
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# ── Rotation pick (verbatim from producer.pick_rotation_asset) ──
|
|
139
|
+
|
|
140
|
+
def pick_rotation_asset(rot_idx, xyz_weight, held_set, last_closed, now=None, rng=random):
|
|
141
|
+
"""Pick the next rotation asset.
|
|
142
|
+
|
|
143
|
+
Probabilistic pool pick (random.random() < xyz_weight -> XYZ pool, else MAIN) + a
|
|
144
|
+
deterministic rotation index inside the chosen pool. Skips assets already held and assets
|
|
145
|
+
closed within POST_CLOSE_COOLDOWN_SECONDS (90s). Falls through to the OTHER pool if the
|
|
146
|
+
chosen one is exhausted. Returns (asset|None, new_rot_idx).
|
|
147
|
+
|
|
148
|
+
`now`/`rng` are injectable for deterministic tests; the source used time.time() / random.
|
|
149
|
+
"""
|
|
150
|
+
if now is None:
|
|
151
|
+
now = time.time()
|
|
152
|
+
|
|
153
|
+
def _try_pool(pool, idx):
|
|
154
|
+
n = len(pool)
|
|
155
|
+
for _ in range(n):
|
|
156
|
+
candidate = pool[idx % n]
|
|
157
|
+
idx = (idx + 1) % n
|
|
158
|
+
coin_key = normalize_coin_key(candidate)
|
|
159
|
+
if coin_key in held_set:
|
|
160
|
+
continue
|
|
161
|
+
last = last_closed.get(coin_key, {})
|
|
162
|
+
if last and (now - last.get("ts", 0)) < POST_CLOSE_COOLDOWN_SECONDS:
|
|
163
|
+
continue
|
|
164
|
+
return candidate, idx
|
|
165
|
+
return None, idx
|
|
166
|
+
|
|
167
|
+
use_xyz = rng.random() < xyz_weight
|
|
168
|
+
pool = VOLUME_XYZ if use_xyz else VOLUME_MAIN
|
|
169
|
+
asset, rot_idx = _try_pool(pool, rot_idx)
|
|
170
|
+
if asset is not None:
|
|
171
|
+
return asset, rot_idx
|
|
172
|
+
|
|
173
|
+
other = VOLUME_MAIN if use_xyz else VOLUME_XYZ
|
|
174
|
+
asset, rot_idx = _try_pool(other, rot_idx)
|
|
175
|
+
return asset, rot_idx
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def clamp_leverage(desired, venue_max):
|
|
179
|
+
"""Clamp desired leverage to the asset's Hyperliquid venue max.
|
|
180
|
+
|
|
181
|
+
Turbine's source used a fixed 5x and relied on the runtime to clamp per-asset. We carry the
|
|
182
|
+
same defensive clamp the spider port uses so a low-venue-cap asset never over-levers.
|
|
183
|
+
"""
|
|
184
|
+
try:
|
|
185
|
+
venue = int(venue_max)
|
|
186
|
+
except (TypeError, ValueError):
|
|
187
|
+
venue = desired
|
|
188
|
+
if venue <= 0:
|
|
189
|
+
venue = desired
|
|
190
|
+
return max(1, min(int(desired), venue))
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,18 @@
|
|
|
2
2
|
"id": "runtime",
|
|
3
3
|
"name": "Senpi Runtime",
|
|
4
4
|
"description": "Senpi runtime plugin for OpenClaw. Orchestrates scanners, LLM-based trade decisions, and a DSL trailing stop-loss exit engine.",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "3.0.3",
|
|
6
|
+
"commandAliases": [
|
|
7
|
+
{
|
|
8
|
+
"name": "senpi"
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"activation": {
|
|
12
|
+
"onStartup": true,
|
|
13
|
+
"onCommands": [
|
|
14
|
+
"senpi"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
6
17
|
"configSchema": {
|
|
7
18
|
"type": "object",
|
|
8
19
|
"additionalProperties": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senpi-ai/runtime",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Senpi runtime plugin for OpenClaw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"dev": "npm run build && node dist/index.js",
|
|
22
22
|
"watch": "tsc --watch",
|
|
23
23
|
"test": "vitest run",
|
|
24
|
+
"test:python": "python3 -m pytest python-tests/ -q",
|
|
24
25
|
"run:dsl:mock": "node dist/scripts/run-dsl-standalone-mock.js",
|
|
25
26
|
"run:dsl:live": "node dist/scripts/run-dsl-standalone-live.js",
|
|
26
27
|
"test:coverage": "vitest run --coverage",
|
|
27
|
-
"prepublishOnly": "npm run build && npm run typecheck:tests && npm test",
|
|
28
28
|
"bench": "tsx benchmarks/ingest-latency.ts"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"zod": "^3.23.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"openclaw": ">=2026.
|
|
48
|
+
"openclaw": ">=2026.5.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/async-retry": "^1.4.9",
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure helper that groups a flat `SignalItem[]` by `(address, scanner)` so
|
|
3
|
-
* the route handler can fan-out groups in parallel while keeping items within
|
|
4
|
-
* a group sequential — dodging the per-(address, scanner) ingest lock held by
|
|
5
|
-
* `ScannerEngine` during async ingest
|
|
6
|
-
* (`src/scanners/engine/engine.ts:282-287`).
|
|
7
|
-
*/
|
|
8
|
-
import type { SignalItem } from "./types.js";
|
|
9
|
-
/**
|
|
10
|
-
* A `SignalItem` paired with its original zero-based index in the input array.
|
|
11
|
-
* The index is used to re-flatten grouped results back into the caller's
|
|
12
|
-
* requested order after `Promise.all` group settlement.
|
|
13
|
-
*/
|
|
14
|
-
export interface IndexedSignalItem {
|
|
15
|
-
/** Zero-based position in the original input array. */
|
|
16
|
-
index: number;
|
|
17
|
-
/** The original signal item. */
|
|
18
|
-
item: SignalItem;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* A sequence of items that share the same `(lowercased address, scanner)` key
|
|
22
|
-
* and must be processed sequentially to avoid the per-(address, scanner) lock.
|
|
23
|
-
*/
|
|
24
|
-
export type SignalGroup = IndexedSignalItem[];
|
|
25
|
-
/**
|
|
26
|
-
* Group signal items by `(lowercased address, scanner)`.
|
|
27
|
-
*
|
|
28
|
-
* Items within a group must be processed sequentially — the runtime's scanner
|
|
29
|
-
* engine holds a per-(address, scanner) mutex during the full async ingest
|
|
30
|
-
* chain and throws `UNAVAILABLE` on concurrent calls for the same key.
|
|
31
|
-
*
|
|
32
|
-
* Groups with different keys (different address or different scanner) can be
|
|
33
|
-
* processed in parallel — they do not share the lock.
|
|
34
|
-
*
|
|
35
|
-
* Each item carries its original index so the route handler can sort results
|
|
36
|
-
* back to input order after `Promise.all` resolves.
|
|
37
|
-
*
|
|
38
|
-
* @param items Flat array of signal items as received in the request body.
|
|
39
|
-
* @returns Array of groups; order of groups is not guaranteed, but item
|
|
40
|
-
* order within each group is preserved.
|
|
41
|
-
*/
|
|
42
|
-
export declare function groupByAddressScanner(items: SignalItem[]): SignalGroup[];
|
|
43
|
-
//# sourceMappingURL=group-by-scanner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group-by-scanner.d.ts","sourceRoot":"","sources":["../../../src/runtime-api/handlers/group-by-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,iBAAiB,EAAE,CAAC;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,WAAW,EAAE,CAkBxE"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure helper that groups a flat `SignalItem[]` by `(address, scanner)` so
|
|
3
|
-
* the route handler can fan-out groups in parallel while keeping items within
|
|
4
|
-
* a group sequential — dodging the per-(address, scanner) ingest lock held by
|
|
5
|
-
* `ScannerEngine` during async ingest
|
|
6
|
-
* (`src/scanners/engine/engine.ts:282-287`).
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Group signal items by `(lowercased address, scanner)`.
|
|
10
|
-
*
|
|
11
|
-
* Items within a group must be processed sequentially — the runtime's scanner
|
|
12
|
-
* engine holds a per-(address, scanner) mutex during the full async ingest
|
|
13
|
-
* chain and throws `UNAVAILABLE` on concurrent calls for the same key.
|
|
14
|
-
*
|
|
15
|
-
* Groups with different keys (different address or different scanner) can be
|
|
16
|
-
* processed in parallel — they do not share the lock.
|
|
17
|
-
*
|
|
18
|
-
* Each item carries its original index so the route handler can sort results
|
|
19
|
-
* back to input order after `Promise.all` resolves.
|
|
20
|
-
*
|
|
21
|
-
* @param items Flat array of signal items as received in the request body.
|
|
22
|
-
* @returns Array of groups; order of groups is not guaranteed, but item
|
|
23
|
-
* order within each group is preserved.
|
|
24
|
-
*/
|
|
25
|
-
export function groupByAddressScanner(items) {
|
|
26
|
-
const grouped = new Map();
|
|
27
|
-
for (let index = 0; index < items.length; index++) {
|
|
28
|
-
const item = items[index];
|
|
29
|
-
// item is always defined inside bounds; the cast avoids a superfluous
|
|
30
|
-
// non-null assertion in strict mode.
|
|
31
|
-
const safeItem = item;
|
|
32
|
-
const key = `${safeItem.address.toLowerCase()}::${safeItem.scanner}`;
|
|
33
|
-
const existing = grouped.get(key);
|
|
34
|
-
if (existing !== undefined) {
|
|
35
|
-
existing.push({ index, item: safeItem });
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
grouped.set(key, [{ index, item: safeItem }]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return Array.from(grouped.values());
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=group-by-scanner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group-by-scanner.js","sourceRoot":"","sources":["../../../src/runtime-api/handlers/group-by-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsBH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAmB;IACvD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE/C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,sEAAsE;QACtE,qCAAqC;QACrC,MAAM,QAAQ,GAAG,IAAkB,CAAC;QACpC,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# External liquidation-watchdog producer
|
|
2
|
-
|
|
3
|
-
A real, standalone watchdog scanner that runs as an external producer:
|
|
4
|
-
|
|
5
|
-
1. Pulls clearinghouse state from the live Senpi MCP server.
|
|
6
|
-
2. Computes margin / liquidation-distance / ROE alerts using a self-contained
|
|
7
|
-
port of the watchdog logic (no dependency on the runtime's internal
|
|
8
|
-
`liquidationWatchdogScanner`).
|
|
9
|
-
3. Pushes resulting signals into a running runtime via
|
|
10
|
-
`openclaw senpi external-scanner ingest` (gateway RPC `senpi.ingestExternalScannerData`).
|
|
11
|
-
|
|
12
|
-
## Files
|
|
13
|
-
|
|
14
|
-
- `recipe.yaml` — runtime recipe declaring the matching `external_scanner`
|
|
15
|
-
(`external_liquidation_watchdog`) and a downstream LLM action wired to
|
|
16
|
-
`{{signal_external_liquidation_watchdog}}`.
|
|
17
|
-
- `producer.mjs` — the external producer entrypoint.
|
|
18
|
-
|
|
19
|
-
## Prereqs
|
|
20
|
-
|
|
21
|
-
1. Build the project so the MCP provider bridge is available:
|
|
22
|
-
```bash
|
|
23
|
-
npm run build
|
|
24
|
-
```
|
|
25
|
-
2. Install the runtime from `recipe.yaml` for your strategy wallet and start it:
|
|
26
|
-
```bash
|
|
27
|
-
openclaw senpi runtime create -p src/scanners/external/liquidation-watchdog/recipe.yaml
|
|
28
|
-
```
|
|
29
|
-
3. Ensure `openclaw` is on `PATH` and authenticated against the host running
|
|
30
|
-
that runtime.
|
|
31
|
-
4. Export Senpi MCP credentials and the target wallet:
|
|
32
|
-
```bash
|
|
33
|
-
export SENPI_API_KEY="..."
|
|
34
|
-
export SENPI_MCP_URL="https://mcp.prod.senpi.ai/mcp"
|
|
35
|
-
export STRATEGY_ADDRESS="0x..."
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Run
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
node src/scanners/external/liquidation-watchdog/producer.mjs
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
The producer fetches one clearinghouse snapshot, derives signals, and pushes
|
|
45
|
-
them. It exits non-zero on any rejection or signal-count mismatch. Re-run
|
|
46
|
-
(or wrap in `watch`/cron) for continuous monitoring.
|
|
47
|
-
|
|
48
|
-
## Env
|
|
49
|
-
|
|
50
|
-
| Var | Default | Purpose |
|
|
51
|
-
|---|---|---|
|
|
52
|
-
| `SENPI_API_KEY` | _required_ | Senpi MCP auth |
|
|
53
|
-
| `SENPI_MCP_URL` | _required_ | Senpi MCP endpoint |
|
|
54
|
-
| `STRATEGY_ADDRESS` | _required_ | Target wallet — must match the installed runtime |
|
|
55
|
-
| `EXTERNAL_SCANNER_NAME` | `external_liquidation_watchdog` | Must match `scanners[].name` in the recipe |
|
|
56
|
-
| `OPENCLAW_BIN` | `openclaw` | Path/name of the OpenClaw CLI binary |
|
|
57
|
-
| `BUFFER_WARNING_PCT` | `50` | Margin buffer % below which a WARNING alert fires |
|
|
58
|
-
| `BUFFER_CRITICAL_PCT` | `30` | Margin buffer % below which CRITICAL + WATCHDOG_CLOSE fire |
|
|
59
|
-
| `LIQ_DISTANCE_WARNING_PCT` | `30` | Per-position liq distance % warning threshold |
|
|
60
|
-
| `ROE_DANGER_PCT` | `-15` | ROE % below which a position is flagged |
|
|
61
|
-
|
|
62
|
-
## Expected response
|
|
63
|
-
|
|
64
|
-
```json
|
|
65
|
-
{
|
|
66
|
-
"accepted": true,
|
|
67
|
-
"address": "0x...",
|
|
68
|
-
"scanner": "external_liquidation_watchdog",
|
|
69
|
-
"timestamp": 1775680200000,
|
|
70
|
-
"signalCount": 3,
|
|
71
|
-
"contextUpdated": false
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Live test: force a watchdog close
|
|
76
|
-
|
|
77
|
-
To verify the end-to-end close path on a real open position, loosen the
|
|
78
|
-
producer thresholds so any healthy position trips `WATCHDOG_CLOSE`. The
|
|
79
|
-
shipped `recipe.yaml` intentionally has no `exit.dsl` block, so the watchdog
|
|
80
|
-
is the only exit path — a close is unambiguously attributable to the producer.
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
BUFFER_WARNING_PCT=99 \
|
|
84
|
-
BUFFER_CRITICAL_PCT=95 \
|
|
85
|
-
LIQ_DISTANCE_WARNING_PCT=99 \
|
|
86
|
-
ROE_DANGER_PCT=100 \
|
|
87
|
-
node src/scanners/external/liquidation-watchdog/producer.mjs
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Expect `accepted: true` with `signalCount >= 1` and the `watchdog_close`
|
|
91
|
-
action firing on the runtime. Revert the env values (and re-add a DSL preset)
|
|
92
|
-
before running unattended — without DSL, nothing else will close a position
|
|
93
|
-
between producer runs.
|
|
94
|
-
|
|
95
|
-
## Manual e2e checklist
|
|
96
|
-
|
|
97
|
-
- Happy path: live wallet with healthy positions → producer prints `0` signals
|
|
98
|
-
and skips the ingest.
|
|
99
|
-
- Triggered path: wallet with a tight liq distance or low buffer → producer
|
|
100
|
-
emits `WATCHDOG_ALERT` (and `WATCHDOG_CLOSE` for critical buffer); gateway
|
|
101
|
-
returns `accepted: true` with matching `signalCount`.
|
|
102
|
-
- Unknown wallet: change `STRATEGY_ADDRESS` to a wallet without an installed
|
|
103
|
-
runtime → expect `NOT_FOUND`.
|
|
104
|
-
- Disabled scanner: stop the runtime or rename the scanner in the recipe →
|
|
105
|
-
expect `INVALID_REQUEST`.
|
|
106
|
-
- Schema rejection: edit `toExternalBatchItem` in `producer.mjs` to drop
|
|
107
|
-
`sourceMeta` → expect a validation `INVALID_REQUEST`.
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
name: external-liquidation-watchdog
|
|
2
|
-
version: 1.0.0
|
|
3
|
-
description: >
|
|
4
|
-
External producer variant of the liquidation watchdog. Margin / liq-distance /
|
|
5
|
-
ROE alerts are computed by an out-of-process producer (see producer.mjs) and
|
|
6
|
-
pushed in via senpi.ingestExternalScannerData. Watchdog signals drive an
|
|
7
|
-
emergency CLOSE_POSITION; DSL handles normal trailing exits.
|
|
8
|
-
|
|
9
|
-
strategy:
|
|
10
|
-
wallet: "${WALLET_ADDRESS}"
|
|
11
|
-
budget: 1000
|
|
12
|
-
slots: 3
|
|
13
|
-
margin_per_slot: 300
|
|
14
|
-
trading_risk: moderate
|
|
15
|
-
enabled: true
|
|
16
|
-
|
|
17
|
-
scanners:
|
|
18
|
-
# External scanner: signals are pushed by producer.mjs, no internal interval.
|
|
19
|
-
# `fields` documents the payload shape the gateway will accept from the producer.
|
|
20
|
-
- name: external_liquidation_watchdog
|
|
21
|
-
type: external_scanner
|
|
22
|
-
outputs:
|
|
23
|
-
signals: true
|
|
24
|
-
context: false
|
|
25
|
-
config:
|
|
26
|
-
fields:
|
|
27
|
-
sourceScannerId: { type: string, required: true }
|
|
28
|
-
sourceSignalType: { type: string, required: true }
|
|
29
|
-
sourceTimestamp: { type: number, required: true }
|
|
30
|
-
sourceFactors: { type: object, required: true }
|
|
31
|
-
sourceMeta: { type: object, required: true }
|
|
32
|
-
|
|
33
|
-
actions:
|
|
34
|
-
# Emergency close on margin danger — rule-based, no LLM in the hot path.
|
|
35
|
-
- name: watchdog_close
|
|
36
|
-
action_type: CLOSE_POSITION
|
|
37
|
-
decision_mode: rule
|
|
38
|
-
scanners: [external_liquidation_watchdog]
|
|
39
|
-
min_confidence: 1
|
|
40
|
-
|
|
41
|
-
# ── NOTIFICATIONS ──
|
|
42
|
-
notifications:
|
|
43
|
-
telegram_chat_id: "${TELEGRAM_CHAT_ID}"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# No `exit:` block: for a live test we want the external watchdog to be the
|
|
47
|
-
# ONLY exit path, so a triggered close is unambiguously attributable to the
|
|
48
|
-
# producer. Re-add a DSL preset before running this recipe unattended.
|