@senpi-ai/runtime 1.1.2 → 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 +161 -26
- 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 +10 -0
- package/dist/runtime/risk-guard.d.ts.map +1 -1
- package/dist/runtime/risk-guard.js +23 -24
- 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 +517 -134
- 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-lifecycle.d.ts +45 -0
- package/dist/runtime/strategy-lifecycle.d.ts.map +1 -0
- package/dist/runtime/strategy-lifecycle.js +117 -0
- package/dist/runtime/strategy-lifecycle.js.map +1 -0
- 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/hooks.d.ts +1 -0
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/hooks.js +1 -0
- package/dist/types/hooks.js.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
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ if (process.env.DD_TRACE_ENABLED === "true") {
|
|
|
24
24
|
__require("dd-trace").init();
|
|
25
25
|
}
|
|
26
26
|
import { readFileSync } from "node:fs";
|
|
27
|
-
import { join } from "node:path";
|
|
27
|
+
import { join, dirname } from "node:path";
|
|
28
28
|
import { SenpiClient } from "./senpi/client.js";
|
|
29
29
|
import { buildRuntimeStateDir, archiveStateDir } from "./runtime/state-layout.js";
|
|
30
30
|
import { registerSenpiCli } from "./cli/senpi-commands.js";
|
|
@@ -33,7 +33,6 @@ import { getDefaultStateDir } from "./runtime/default-state-dir.js";
|
|
|
33
33
|
import { createNotificationService } from "./runtime/notifications.js";
|
|
34
34
|
import { run } from "./runtime/run.js";
|
|
35
35
|
import { AutoUpdateCoordinator } from "./runtime/auto-update/coordinator.js";
|
|
36
|
-
import { runCommand } from "./runtime/auto-update/command-runner.js";
|
|
37
36
|
import { resolveAutoUpdateConfig } from "./runtime/auto-update/types.js";
|
|
38
37
|
import { SkillsCoordinatorUnavailableError, SkillsUpdateCoordinator, resolveSkillsManagerConfig, } from "./skills-manager/index.js";
|
|
39
38
|
import { createScannerProvidersForRun } from "./runtime/create-scanner-providers-for-run.js";
|
|
@@ -41,15 +40,21 @@ import { initDsl } from "./dsl/index.js";
|
|
|
41
40
|
import { initHealth } from "./health/index.js";
|
|
42
41
|
import { initRisk } from "./risk/index.js";
|
|
43
42
|
import { VERSION } from "./version.js";
|
|
43
|
+
import { resolvePackageName } from "./runtime/auto-update/resolve-package-name.js";
|
|
44
|
+
import { runOpenClawPluginsUpdate } from "./runtime/auto-update/run-update-command.js";
|
|
44
45
|
import { BUS_EVENT_MAP } from "./tracking/constants.js";
|
|
45
46
|
import { createPluginEventTracker } from "./tracking/plugin-event-tracker.js";
|
|
46
47
|
import { createPluginSpanTracker, registerSpanHooks, setDefaultSpanTracker, } from "./tracking/spans/index.js";
|
|
47
48
|
import { getLogLevel, getLogLevelSource, parseLogLevel, setErrorNotifier, setLogLevel, } from "./utils/logger.js";
|
|
48
49
|
import { ExternalScannerIngestError, } from "./scanners/external-scanner-receiver.js";
|
|
49
50
|
import { createLogger } from "./utils/logger.js";
|
|
51
|
+
import { fileURLToPath } from "node:url";
|
|
50
52
|
import { loadApiConfig } from "./runtime-api/config.js";
|
|
51
53
|
import { startApi } from "./runtime-api/lifecycle.js";
|
|
52
54
|
import { ingestSignalsHandler } from "./runtime-api/handlers/ingest-signals.js";
|
|
55
|
+
import { createIntakeContext } from "./runtime-api/intake/intake-context.js";
|
|
56
|
+
import { wireRuntime, intakeUrlFor } from "./runtime-api/intake/intake-mount.js";
|
|
57
|
+
import { loadRuntimeConfig } from "./runtime/load-runtime-config.js";
|
|
53
58
|
/** Initialize all core features (DSL, risk, health) on the given event bus. */
|
|
54
59
|
export function initCore(bus) {
|
|
55
60
|
initDsl(bus);
|
|
@@ -186,12 +191,23 @@ function readPluginManifestVersion() {
|
|
|
186
191
|
return VERSION;
|
|
187
192
|
}
|
|
188
193
|
const PLUGIN_MANIFEST_VERSION = readPluginManifestVersion();
|
|
194
|
+
/**
|
|
195
|
+
* NPM package name resolved from the installed `package.json` at runtime.
|
|
196
|
+
* Lets the auto-updater poll whichever npm package this plugin was published
|
|
197
|
+
* under (e.g. `@senpi-ai/runtime` in prod, `@senpi/runtime` on the
|
|
198
|
+
* openclaw-upgrade dev channel). Falls back to the prod name when unreadable.
|
|
199
|
+
* See `runtime/auto-update/resolve-package-name.ts`.
|
|
200
|
+
*/
|
|
201
|
+
const PLUGIN_PACKAGE_NAME = resolvePackageName();
|
|
189
202
|
/**
|
|
190
203
|
* OpenClaw plugin entry.
|
|
191
204
|
* Boots from internal registry (installed_runtimes.json) in stateDir; does not read runtime list from config.
|
|
192
205
|
*/
|
|
193
206
|
const senpiRuntimePlugin = {
|
|
194
|
-
id
|
|
207
|
+
// Must match openclaw.plugin.json `id` — openclaw loader rejects the plugin
|
|
208
|
+
// when `installed_plugins.json` record id (sourced from the manifest) and
|
|
209
|
+
// the runtime export id differ. v2026.5.x is strict; v2026.2.x was lenient.
|
|
210
|
+
id: "runtime",
|
|
195
211
|
name: "Senpi Trading Runtime",
|
|
196
212
|
version: VERSION,
|
|
197
213
|
description: "Senpi trading runtime plugin for OpenClaw — orchestrates scanners, actions, and DSL exit engine",
|
|
@@ -247,6 +263,10 @@ const senpiRuntimePlugin = {
|
|
|
247
263
|
pluginLogger.error("[senpi-runtime] mcpTransport or apiKey is required (provide via gateway, api, or config)");
|
|
248
264
|
return;
|
|
249
265
|
}
|
|
266
|
+
// Self-report the MCP transport path so a deployed box never leaves it ambiguous.
|
|
267
|
+
// mcpTransport = gateway-injected (no eager connect); apiKey = self-managed SenpiClient
|
|
268
|
+
// (lazy connect — the R7 boot-resilience path). No secret is logged, only presence + url.
|
|
269
|
+
pluginLogger.info(`[senpi-runtime] MCP transport: ${mcpTransport ? "mcpTransport (gateway-injected)" : "apiKey (self-managed SenpiClient)"}; mcpUrl=${process.env.SENPI_MCP_URL ?? "(default)"}`);
|
|
250
270
|
const pluginEventTracker = createPluginEventTracker(apiKey ?? process.env.SENPI_API_KEY);
|
|
251
271
|
// Span telemetry — one tracker per gateway, shared across all hosted runtimes
|
|
252
272
|
// and OpenClaw hook activity. Captures llm/tool/subagent/agent_end via
|
|
@@ -265,6 +285,40 @@ const senpiRuntimePlugin = {
|
|
|
265
285
|
}
|
|
266
286
|
const runtimeHandles = new Map();
|
|
267
287
|
let apiHandle;
|
|
288
|
+
// Supervised scanner state — module-scoped so stop() can reach them.
|
|
289
|
+
// Created eagerly at register() time (not deferred to start()) so that
|
|
290
|
+
// senpi.installRuntime can wire scanners regardless of whether start()
|
|
291
|
+
// has already been called (the gateway may invoke installRuntime before
|
|
292
|
+
// start() completes, or even before start() is ever called).
|
|
293
|
+
//
|
|
294
|
+
// FAIL-CLOSED on corrupt acceptance record: if the FileAcceptanceRecord
|
|
295
|
+
// inside createIntakeContext throws (corrupt / unreadable dedup file), we
|
|
296
|
+
// catch here and DISABLE supervised intake rather than crashing the whole
|
|
297
|
+
// gateway. A corrupt INTAKE dedup file must NOT take down DSL monitoring /
|
|
298
|
+
// reconcile that protects already-open positions. With intake disabled:
|
|
299
|
+
// - /signals is not mounted (no new trade acceptance)
|
|
300
|
+
// - supervised-scanner launchers are not built or started
|
|
301
|
+
// - DSL monitor + reconcile boot normally for existing positions
|
|
302
|
+
// Remediation: clear or repair the acceptance-record.json file and restart.
|
|
303
|
+
let sharedIntakeContext;
|
|
304
|
+
try {
|
|
305
|
+
sharedIntakeContext = createIntakeContext({
|
|
306
|
+
// Durable acceptance high-water-mark: a gateway restart must NOT re-accept an
|
|
307
|
+
// already-accepted signal (double-process / double-trade risk, proven on the
|
|
308
|
+
// box). One file for the box; keys are namespaced by runtimeId+scannerName so
|
|
309
|
+
// runtimes never mix marks.
|
|
310
|
+
acceptanceRecordPath: join(baseStateDir, "acceptance-record.json"),
|
|
311
|
+
logger: pluginLogger,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
catch (intakeErr) {
|
|
315
|
+
pluginLogger.error(`[senpi-runtime] FATAL: corrupt acceptance record at ${join(baseStateDir, "acceptance-record.json")}` +
|
|
316
|
+
` — supervised intake DISABLED; DSL monitor and reconcile will boot normally.` +
|
|
317
|
+
` Remediation: clear or repair the file and restart.`, { err: intakeErr });
|
|
318
|
+
// sharedIntakeContext remains undefined — callers below are guarded.
|
|
319
|
+
}
|
|
320
|
+
let routeAcceptedSignalToRuntime;
|
|
321
|
+
const launchers = new Map();
|
|
268
322
|
// Dedicated logger for the runtime-api subtree — required because the
|
|
269
323
|
// PluginLogger surface (info/warn/error) lacks `debug`, while the
|
|
270
324
|
// Logger contract used by `runtime-api/` includes it.
|
|
@@ -304,7 +358,7 @@ const senpiRuntimePlugin = {
|
|
|
304
358
|
const autoUpdateCoordinator = new AutoUpdateCoordinator({
|
|
305
359
|
enabled: true,
|
|
306
360
|
config: autoUpdateConfig,
|
|
307
|
-
packageName:
|
|
361
|
+
packageName: PLUGIN_PACKAGE_NAME,
|
|
308
362
|
currentVersion: VERSION,
|
|
309
363
|
stateDir: join(baseStateDir, "auto-update"),
|
|
310
364
|
logger: pluginLogger,
|
|
@@ -312,18 +366,21 @@ const senpiRuntimePlugin = {
|
|
|
312
366
|
? (msg) => lifecycleNotifications.notify(msg)
|
|
313
367
|
: async () => { },
|
|
314
368
|
stopRuntimesForUpdate: async () => {
|
|
369
|
+
// Stop supervised scanner children BEFORE stopping runtime handles so
|
|
370
|
+
// scaffold processes do not POST to a handle that is already torn down.
|
|
371
|
+
// Mirrors the service stop() teardown order.
|
|
372
|
+
if (launchers.size > 0) {
|
|
373
|
+
await Promise.allSettled([...launchers.values()].map((l) => l.stop()));
|
|
374
|
+
launchers.clear();
|
|
375
|
+
}
|
|
315
376
|
for (const [, handle] of runtimeHandles) {
|
|
316
377
|
await handle.stop();
|
|
317
378
|
}
|
|
318
379
|
},
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (result.code !== 0) {
|
|
324
|
-
throw new Error(result.stderr || `openclaw plugins update failed with code ${result.code}`);
|
|
325
|
-
}
|
|
326
|
-
},
|
|
380
|
+
// Use the resolved npm package name (not a hardcoded plugin id) so
|
|
381
|
+
// the update follows the same npm channel as the version check —
|
|
382
|
+
// see runtime/auto-update/run-update-command.ts.
|
|
383
|
+
runUpdateCommand: runOpenClawPluginsUpdate,
|
|
327
384
|
configFromApi: api.config,
|
|
328
385
|
loadConfig: api.runtime?.config
|
|
329
386
|
? () => api.runtime.config.loadConfig()
|
|
@@ -373,6 +430,42 @@ const senpiRuntimePlugin = {
|
|
|
373
430
|
mcpTransport,
|
|
374
431
|
apiKey,
|
|
375
432
|
});
|
|
433
|
+
// Wire the shared accepted callback now that runtimeHandles is
|
|
434
|
+
// being populated. sharedIntakeContext was created eagerly at register()
|
|
435
|
+
// time so /signals can be mounted even for a pure-legacy box.
|
|
436
|
+
// The single server-level onAccepted resolves registry → runtimeId
|
|
437
|
+
// → handle for any runtime's scanner (shared across all runtimes).
|
|
438
|
+
// Guard: if intake context is disabled (corrupt record at boot), skip wiring —
|
|
439
|
+
// /signals will not be mounted and no signals will be routed.
|
|
440
|
+
if (sharedIntakeContext) {
|
|
441
|
+
const ctx = sharedIntakeContext;
|
|
442
|
+
routeAcceptedSignalToRuntime = (signal, _correlationId, scannerId) => {
|
|
443
|
+
const resolved = ctx.registry.resolve(scannerId);
|
|
444
|
+
if (!resolved)
|
|
445
|
+
return;
|
|
446
|
+
const h = runtimeHandles.get(resolved.runtimeId);
|
|
447
|
+
if (!h)
|
|
448
|
+
return;
|
|
449
|
+
const request = {
|
|
450
|
+
scanner: resolved.scannerName,
|
|
451
|
+
asset: signal.asset,
|
|
452
|
+
direction: signal.direction,
|
|
453
|
+
...(signal.signal_type !== undefined && { signal_type: signal.signal_type }),
|
|
454
|
+
data: signal.data,
|
|
455
|
+
// Per-signal sizing rides at the top level; the open-position action
|
|
456
|
+
// reads request.marginUsd / request.leverage directly. Without this a
|
|
457
|
+
// supervised signal's sizing is lost ("no margin source resolved").
|
|
458
|
+
...(signal.marginUsd !== undefined && { marginUsd: signal.marginUsd }),
|
|
459
|
+
...(signal.leverage !== undefined && { leverage: signal.leverage }),
|
|
460
|
+
};
|
|
461
|
+
void h
|
|
462
|
+
.ingestExternalScannerData(request)
|
|
463
|
+
.then(() => {
|
|
464
|
+
apiLogger.info(`[intake] ingest ok scanner=${resolved.scannerName} asset=${signal.asset} scanner_id=${scannerId}`);
|
|
465
|
+
})
|
|
466
|
+
.catch((err) => apiLogger.error("[intake] ingest failed", { scannerId, err }));
|
|
467
|
+
};
|
|
468
|
+
}
|
|
376
469
|
const started = [];
|
|
377
470
|
try {
|
|
378
471
|
for (const entry of registry.runtimes) {
|
|
@@ -394,9 +487,51 @@ const senpiRuntimePlugin = {
|
|
|
394
487
|
});
|
|
395
488
|
runtimeHandles.set(entry.id, handle);
|
|
396
489
|
started.push(entry.id);
|
|
490
|
+
// ── supervised scanner mount (additive; guarded) ──────────────────
|
|
491
|
+
// Boot path: used for runtimes already present in the registry at
|
|
492
|
+
// startup. A runtime installed live, after the API is listening,
|
|
493
|
+
// takes the hotLauncher path instead (see "hot-install" below).
|
|
494
|
+
// wireRuntime returns null for pure-legacy runtimes — no behavior
|
|
495
|
+
// change for those. For supervised runtimes the launcher is built
|
|
496
|
+
// (scanners registered into sharedIntakeContext) but NOT started;
|
|
497
|
+
// start() is deferred until after the HTTP API is listening below.
|
|
498
|
+
// Skip entirely if intake context is disabled (corrupt acceptance record).
|
|
499
|
+
if (sharedIntakeContext) {
|
|
500
|
+
try {
|
|
501
|
+
const runtimeConfig = await loadRuntimeConfig(pathOrContent, { fromPath: hasPath });
|
|
502
|
+
// Content-installed runtimes carry their recipe dir in the registry
|
|
503
|
+
// entry (runtimeYamlDir) so relative scanner paths still resolve
|
|
504
|
+
// after a restart; path-installed ones derive it from the path.
|
|
505
|
+
const recipeDir = hasPath ? dirname(pathOrContent) : entry.runtimeYamlDir;
|
|
506
|
+
const scaffoldPackageDir = fileURLToPath(new URL("./scanners/external", import.meta.url));
|
|
507
|
+
const apiConfig = loadApiConfig(api.pluginConfig);
|
|
508
|
+
const launcher = wireRuntime({
|
|
509
|
+
runtimeConfig,
|
|
510
|
+
recipeDir,
|
|
511
|
+
runtimeId: entry.id,
|
|
512
|
+
wallet: runtimeConfig.strategy?.wallet ?? entry.wallet ?? "",
|
|
513
|
+
sharedCtx: sharedIntakeContext,
|
|
514
|
+
runtimeHandles,
|
|
515
|
+
intakeUrl: intakeUrlFor(apiConfig.host, apiConfig.port),
|
|
516
|
+
scaffoldPackageDir,
|
|
517
|
+
runtimeStateDir: entryStateDir,
|
|
518
|
+
logger: apiLogger,
|
|
519
|
+
});
|
|
520
|
+
if (launcher)
|
|
521
|
+
launchers.set(entry.id, launcher);
|
|
522
|
+
}
|
|
523
|
+
catch (mountErr) {
|
|
524
|
+
// Mount failure is non-fatal: the runtime itself is already up.
|
|
525
|
+
// Log and skip the launcher for this runtime.
|
|
526
|
+
apiLogger.error("[senpi-runtime] scanner mount failed — runtime running without supervised scanners", { runtimeId: entry.id, err: mountErr });
|
|
527
|
+
}
|
|
528
|
+
}
|
|
397
529
|
}
|
|
398
530
|
}
|
|
399
531
|
catch (err) {
|
|
532
|
+
// On runtime loop failure, stop any launchers we already built.
|
|
533
|
+
await Promise.allSettled([...launchers.values()].map((l) => l.stop()));
|
|
534
|
+
launchers.clear();
|
|
400
535
|
for (let i = started.length - 1; i >= 0; i--) {
|
|
401
536
|
const h = runtimeHandles.get(started[i]);
|
|
402
537
|
if (h)
|
|
@@ -424,11 +559,17 @@ const senpiRuntimePlugin = {
|
|
|
424
559
|
if (process.env.SENPI_RUNTIME_API_DISABLED !== "true") {
|
|
425
560
|
try {
|
|
426
561
|
const apiConfig = loadApiConfig(api.pluginConfig);
|
|
562
|
+
// Always mount /signals: Fastify cannot add routes after listen(),
|
|
563
|
+
// so a pure-legacy box must have the route pre-mounted to support a
|
|
564
|
+
// later hot-install of a supervised recipe. With an empty registry
|
|
565
|
+
// the route returns UNKNOWN_SCANNER — harmless.
|
|
427
566
|
apiHandle = await startApi({
|
|
428
567
|
runtimeHandles,
|
|
429
568
|
apiConfig,
|
|
430
569
|
logger: apiLogger,
|
|
431
570
|
version: PLUGIN_MANIFEST_VERSION,
|
|
571
|
+
intakeContext: sharedIntakeContext,
|
|
572
|
+
onAccepted: routeAcceptedSignalToRuntime,
|
|
432
573
|
});
|
|
433
574
|
apiHandle.ready();
|
|
434
575
|
}
|
|
@@ -439,6 +580,9 @@ const senpiRuntimePlugin = {
|
|
|
439
580
|
// mid-rollback, then stop every runtime handle that was hydrated
|
|
440
581
|
// above.
|
|
441
582
|
await autoUpdateCoordinator.stop().catch(() => { });
|
|
583
|
+
// Stop any launchers so spawned scaffolds are not leaked.
|
|
584
|
+
await Promise.allSettled([...launchers.values()].map((l) => l.stop()));
|
|
585
|
+
launchers.clear();
|
|
442
586
|
for (let i = started.length - 1; i >= 0; i--) {
|
|
443
587
|
const h = runtimeHandles.get(started[i]);
|
|
444
588
|
if (h)
|
|
@@ -447,6 +591,20 @@ const senpiRuntimePlugin = {
|
|
|
447
591
|
}
|
|
448
592
|
throw err;
|
|
449
593
|
}
|
|
594
|
+
// The HTTP API is now listening — start the supervised scanners.
|
|
595
|
+
// Each start is isolated: a partial-spawn failure removes that launcher
|
|
596
|
+
// from the map immediately (no orphaned children until shutdown) and
|
|
597
|
+
// the runtime stays up without supervised scanners.
|
|
598
|
+
for (const [id, launcher] of launchers) {
|
|
599
|
+
try {
|
|
600
|
+
await launcher.start();
|
|
601
|
+
}
|
|
602
|
+
catch (startErr) {
|
|
603
|
+
await launcher.stop().catch(() => { });
|
|
604
|
+
launchers.delete(id);
|
|
605
|
+
apiLogger.error("[senpi-runtime] supervised scanner launch failed — runtime running without it", { err: startErr });
|
|
606
|
+
}
|
|
607
|
+
}
|
|
450
608
|
}
|
|
451
609
|
if (lifecycleNotifications) {
|
|
452
610
|
const n = started.length;
|
|
@@ -469,6 +627,14 @@ const senpiRuntimePlugin = {
|
|
|
469
627
|
await apiHandle.close();
|
|
470
628
|
apiHandle = undefined;
|
|
471
629
|
}
|
|
630
|
+
// Stop launchers: unregister scanner_ids + await supervisor.stop()
|
|
631
|
+
// (kills children + descendants). Runs AFTER apiHandle.close() so no
|
|
632
|
+
// in-flight POST races the teardown. Promise.allSettled so a
|
|
633
|
+
// launcher failure never blocks the remaining teardown.
|
|
634
|
+
if (launchers.size > 0) {
|
|
635
|
+
await Promise.allSettled([...launchers.values()].map((l) => l.stop()));
|
|
636
|
+
launchers.clear();
|
|
637
|
+
}
|
|
472
638
|
// Stop the coordinator next so it cannot schedule a new tick or call
|
|
473
639
|
// stopRuntimesForUpdate() (auto-restart path after an update) while
|
|
474
640
|
// we are tearing down the handles below.
|
|
@@ -506,6 +672,12 @@ const senpiRuntimePlugin = {
|
|
|
506
672
|
const id = typeof params?.id === "string" ? params.id : undefined;
|
|
507
673
|
const runtimeYamlPath = typeof params?.runtimeYamlPath === "string" ? params.runtimeYamlPath : undefined;
|
|
508
674
|
const runtimeYamlContent = typeof params?.runtimeYamlContent === "string" ? params.runtimeYamlContent : undefined;
|
|
675
|
+
// Recipe directory hint. The CLI reads the -p file and sends its CONTENT
|
|
676
|
+
// (so remote gateways work), which loses the recipe's directory — needed to
|
|
677
|
+
// resolve an external scanner's relative `path: ./` and to let the scaffold
|
|
678
|
+
// import the author's scan module. The CLI forwards the dir here so we can
|
|
679
|
+
// still resolve relative paths even though only content was sent.
|
|
680
|
+
const runtimeYamlDir = typeof params?.runtimeYamlDir === "string" && params.runtimeYamlDir.length > 0 ? params.runtimeYamlDir : undefined;
|
|
509
681
|
const hasPath = runtimeYamlPath !== undefined && runtimeYamlPath.length > 0;
|
|
510
682
|
const hasContent = runtimeYamlContent !== undefined;
|
|
511
683
|
if (!hasPath && !hasContent) {
|
|
@@ -518,14 +690,16 @@ const senpiRuntimePlugin = {
|
|
|
518
690
|
}
|
|
519
691
|
const pathOrContent = runtimeYamlPath ?? runtimeYamlContent;
|
|
520
692
|
// Parse YAML first to extract name, version, and wallet for ID derivation.
|
|
693
|
+
// parsedConfig is lifted to function scope so the install-wire block can use it.
|
|
521
694
|
let parsedSchemaVersion;
|
|
522
695
|
let runtimeName = "";
|
|
523
696
|
let wallet = "";
|
|
697
|
+
let parsedConfig;
|
|
524
698
|
try {
|
|
525
|
-
const { loadRuntimeConfig } = await import("./runtime/load-runtime-config.js");
|
|
526
|
-
const { extractMajorVersion } = await import("./runtime/runtime-version.js");
|
|
527
|
-
|
|
528
|
-
parsedSchemaVersion =
|
|
699
|
+
const { loadRuntimeConfig: lrc } = await import("./runtime/load-runtime-config.js");
|
|
700
|
+
const { extractMajorVersion: emv } = await import("./runtime/runtime-version.js");
|
|
701
|
+
parsedConfig = await lrc(pathOrContent, { fromPath: hasPath });
|
|
702
|
+
parsedSchemaVersion = emv(parsedConfig.version);
|
|
529
703
|
runtimeName = parsedConfig.name;
|
|
530
704
|
wallet = parsedConfig.strategy?.wallet ?? "";
|
|
531
705
|
}
|
|
@@ -627,7 +801,15 @@ const senpiRuntimePlugin = {
|
|
|
627
801
|
}
|
|
628
802
|
const entry = hasPath
|
|
629
803
|
? { id: resolvedId, runtimeYamlPath, schemaVersion: parsedSchemaVersion, wallet }
|
|
630
|
-
: {
|
|
804
|
+
: {
|
|
805
|
+
id: resolvedId,
|
|
806
|
+
runtimeYamlContent: runtimeYamlContent,
|
|
807
|
+
schemaVersion: parsedSchemaVersion,
|
|
808
|
+
wallet,
|
|
809
|
+
// Persist the recipe dir so a gateway restart can resolve an
|
|
810
|
+
// external scanner's relative `path: ./` (content installs drop it).
|
|
811
|
+
...(runtimeYamlDir ? { runtimeYamlDir } : {}),
|
|
812
|
+
};
|
|
631
813
|
const valid = validateEntry(entry);
|
|
632
814
|
if (!valid.ok) {
|
|
633
815
|
respond(false, undefined, toError(valid.error));
|
|
@@ -665,6 +847,56 @@ const senpiRuntimePlugin = {
|
|
|
665
847
|
runtimeId: resolvedId,
|
|
666
848
|
});
|
|
667
849
|
runtimeHandles.set(resolvedId, handle);
|
|
850
|
+
// ── hot-install supervised scanner wire ───────────────────────────────
|
|
851
|
+
// Live-install path: used when a runtime is registered after boot via
|
|
852
|
+
// senpi.installRuntime, while the API is already listening — the
|
|
853
|
+
// counterpart to the boot-time `launcher` above. A runtime takes exactly
|
|
854
|
+
// one path: boot-present → `launcher` (deferred start); installed live →
|
|
855
|
+
// `hotLauncher` (immediate start). The two are mutually exclusive because
|
|
856
|
+
// installRuntime rejects any id/wallet already in the registry before
|
|
857
|
+
// wiring (the hasId guard), so a boot-present runtime never re-enters here.
|
|
858
|
+
// The API is already listening at this point, so we wire and start
|
|
859
|
+
// immediately (no deferred start needed). Any failure is swallowed so
|
|
860
|
+
// the install itself is not rolled back — the runtime is already up.
|
|
861
|
+
// Gate on the same API-disabled flag as the boot path: when the HTTP API
|
|
862
|
+
// is off (a test-only seam), the /signals route is never mounted, so
|
|
863
|
+
// starting scanners would only spawn children that POST to a closed port.
|
|
864
|
+
if (parsedConfig &&
|
|
865
|
+
sharedIntakeContext &&
|
|
866
|
+
process.env.SENPI_RUNTIME_API_DISABLED !== "true") {
|
|
867
|
+
try {
|
|
868
|
+
const apiConfig = loadApiConfig(api.pluginConfig);
|
|
869
|
+
const scaffoldPackageDir = fileURLToPath(new URL("./scanners/external", import.meta.url));
|
|
870
|
+
const entryStateDir = buildRuntimeStateDir(baseStateDir, resolvedId, wallet);
|
|
871
|
+
const hotLauncher = wireRuntime({
|
|
872
|
+
runtimeConfig: parsedConfig,
|
|
873
|
+
recipeDir: hasPath ? dirname(pathOrContent) : runtimeYamlDir,
|
|
874
|
+
runtimeId: resolvedId,
|
|
875
|
+
wallet,
|
|
876
|
+
sharedCtx: sharedIntakeContext,
|
|
877
|
+
runtimeHandles,
|
|
878
|
+
intakeUrl: intakeUrlFor(apiConfig.host, apiConfig.port),
|
|
879
|
+
scaffoldPackageDir,
|
|
880
|
+
runtimeStateDir: entryStateDir,
|
|
881
|
+
logger: apiLogger,
|
|
882
|
+
});
|
|
883
|
+
if (hotLauncher) {
|
|
884
|
+
try {
|
|
885
|
+
await hotLauncher.start();
|
|
886
|
+
launchers.set(resolvedId, hotLauncher);
|
|
887
|
+
}
|
|
888
|
+
catch (startErr) {
|
|
889
|
+
await hotLauncher.stop().catch(() => { });
|
|
890
|
+
apiLogger.error("[senpi-runtime] hot-install supervised scanner launch failed — runtime running without it", { runtimeId: resolvedId, err: startErr });
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
catch (wireErr) {
|
|
895
|
+
// Wire failure must NOT fail the install — the runtime is already up.
|
|
896
|
+
apiLogger.error("[senpi-runtime] hot-install wiring failed — runtime running without supervised scanners", { runtimeId: resolvedId, err: wireErr });
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
668
900
|
respond(true, { id: resolvedId, name: runtimeName, wallet });
|
|
669
901
|
}
|
|
670
902
|
catch (err) {
|
|
@@ -673,7 +905,7 @@ const senpiRuntimePlugin = {
|
|
|
673
905
|
const msg = err instanceof Error ? err.message : String(err);
|
|
674
906
|
respond(false, undefined, toUnavailable(`Could not start the runtime. This is usually due to invalid or incomplete YAML.\n\n${msg}`));
|
|
675
907
|
}
|
|
676
|
-
});
|
|
908
|
+
}, { scope: "operator.write" });
|
|
677
909
|
api.registerGatewayMethod("senpi.listRuntimes", async (ctx) => {
|
|
678
910
|
const respond = ctx.respond;
|
|
679
911
|
const { readRegistry } = await import("./runtime/strategy-registry.js");
|
|
@@ -685,7 +917,7 @@ const senpiRuntimePlugin = {
|
|
|
685
917
|
status: runtimeHandles.has(e.id) ? "running" : "stopped",
|
|
686
918
|
}));
|
|
687
919
|
respond(true, { runtimes });
|
|
688
|
-
});
|
|
920
|
+
}, { scope: "operator.read" });
|
|
689
921
|
api.registerGatewayMethod("senpi.deleteRuntime", async (ctx) => {
|
|
690
922
|
const { params } = ctx;
|
|
691
923
|
const respond = ctx.respond;
|
|
@@ -731,6 +963,14 @@ const senpiRuntimePlugin = {
|
|
|
731
963
|
await handle.stop();
|
|
732
964
|
runtimeHandles.delete(targetId);
|
|
733
965
|
}
|
|
966
|
+
// Stop and remove the launcher for this runtime (if any).
|
|
967
|
+
// No-op for legacy runtimes. .stop() kills scaffold children + unregisters
|
|
968
|
+
// scanner_ids from the shared registry.
|
|
969
|
+
const launcherToStop = launchers.get(targetId);
|
|
970
|
+
if (launcherToStop) {
|
|
971
|
+
await launcherToStop.stop().catch(() => { });
|
|
972
|
+
launchers.delete(targetId);
|
|
973
|
+
}
|
|
734
974
|
// Archive state directory before removing from registry
|
|
735
975
|
if (deletedEntry) {
|
|
736
976
|
const runtimeStateDir = buildRuntimeStateDir(baseStateDir, targetId, deletedEntry.wallet ?? "");
|
|
@@ -763,7 +1003,7 @@ const senpiRuntimePlugin = {
|
|
|
763
1003
|
await writeRegistry(baseStateDir, { ...registry, runtimes: next });
|
|
764
1004
|
}
|
|
765
1005
|
respond(true, { id: targetId });
|
|
766
|
-
});
|
|
1006
|
+
}, { scope: "operator.write" });
|
|
767
1007
|
/**
|
|
768
1008
|
* Gateway shim for `senpi.ingestExternalScannerData`.
|
|
769
1009
|
*
|
|
@@ -851,7 +1091,7 @@ const senpiRuntimePlugin = {
|
|
|
851
1091
|
message: `Failed to ingest external scanner data: ${formatGatewayError(error)}`,
|
|
852
1092
|
});
|
|
853
1093
|
}
|
|
854
|
-
});
|
|
1094
|
+
}, { scope: "operator.write" });
|
|
855
1095
|
api.registerGatewayMethod("senpi.listDslPositions", async (ctx) => {
|
|
856
1096
|
const respond = ctx.respond;
|
|
857
1097
|
const runtimeId = typeof ctx.params?.runtimeId === "string" ? ctx.params.runtimeId : undefined;
|
|
@@ -876,7 +1116,7 @@ const senpiRuntimePlugin = {
|
|
|
876
1116
|
}
|
|
877
1117
|
}
|
|
878
1118
|
respond(true, { positions });
|
|
879
|
-
});
|
|
1119
|
+
}, { scope: "operator.read" });
|
|
880
1120
|
api.registerGatewayMethod("senpi.getDslPositionState", async (ctx) => {
|
|
881
1121
|
const respond = ctx.respond;
|
|
882
1122
|
const asset = typeof ctx.params?.asset === "string" ? ctx.params.asset : undefined;
|
|
@@ -917,7 +1157,7 @@ const senpiRuntimePlugin = {
|
|
|
917
1157
|
return;
|
|
918
1158
|
}
|
|
919
1159
|
respond(true, { positions: matches });
|
|
920
|
-
});
|
|
1160
|
+
}, { scope: "operator.read" });
|
|
921
1161
|
api.registerGatewayMethod("senpi.listDslArchives", async (ctx) => {
|
|
922
1162
|
const respond = ctx.respond;
|
|
923
1163
|
const runtimeId = typeof ctx.params?.runtimeId === "string" ? ctx.params.runtimeId : undefined;
|
|
@@ -943,7 +1183,7 @@ const senpiRuntimePlugin = {
|
|
|
943
1183
|
if (limit && limit > 0)
|
|
944
1184
|
closes = closes.slice(0, limit);
|
|
945
1185
|
respond(true, { closes });
|
|
946
|
-
});
|
|
1186
|
+
}, { scope: "operator.read" });
|
|
947
1187
|
api.registerGatewayMethod("senpi.getHealthStatus", async (ctx) => {
|
|
948
1188
|
const respond = ctx.respond;
|
|
949
1189
|
const updater = autoUpdateCoordinator.getSnapshot();
|
|
@@ -971,7 +1211,7 @@ const senpiRuntimePlugin = {
|
|
|
971
1211
|
}
|
|
972
1212
|
const statuses = await collectRuntimeHealthStatuses(runtimeHandles, api.logger);
|
|
973
1213
|
respond(true, { statuses, updater });
|
|
974
|
-
});
|
|
1214
|
+
}, { scope: "operator.read" });
|
|
975
1215
|
api.registerGatewayMethod("senpi.getSystemState", async (ctx) => {
|
|
976
1216
|
const respond = ctx.respond;
|
|
977
1217
|
const updater = autoUpdateCoordinator.getSnapshot();
|
|
@@ -999,7 +1239,7 @@ const senpiRuntimePlugin = {
|
|
|
999
1239
|
}
|
|
1000
1240
|
const states = await collectRuntimeSystemStates(runtimeHandles, api.logger, baseStateDir);
|
|
1001
1241
|
respond(true, { states, updater });
|
|
1002
|
-
});
|
|
1242
|
+
}, { scope: "operator.read" });
|
|
1003
1243
|
/**
|
|
1004
1244
|
* Action layer — read-only inspection.
|
|
1005
1245
|
*
|
|
@@ -1048,7 +1288,7 @@ const senpiRuntimePlugin = {
|
|
|
1048
1288
|
}
|
|
1049
1289
|
}
|
|
1050
1290
|
respond(true, { actions: merged });
|
|
1051
|
-
});
|
|
1291
|
+
}, { scope: "operator.read" });
|
|
1052
1292
|
api.registerGatewayMethod("senpi.getActionState", async (ctx) => {
|
|
1053
1293
|
const respond = ctx.respond;
|
|
1054
1294
|
const runtimeId = typeof ctx.params?.runtimeId === "string" ? ctx.params.runtimeId : undefined;
|
|
@@ -1085,7 +1325,7 @@ const senpiRuntimePlugin = {
|
|
|
1085
1325
|
message: `Failed to read action state: ${formatGatewayError(err)}`,
|
|
1086
1326
|
});
|
|
1087
1327
|
}
|
|
1088
|
-
});
|
|
1328
|
+
}, { scope: "operator.read" });
|
|
1089
1329
|
api.registerGatewayMethod("senpi.getActionHistory", async (ctx) => {
|
|
1090
1330
|
const respond = ctx.respond;
|
|
1091
1331
|
const runtimeId = typeof ctx.params?.runtimeId === "string" ? ctx.params.runtimeId : undefined;
|
|
@@ -1149,13 +1389,13 @@ const senpiRuntimePlugin = {
|
|
|
1149
1389
|
message: `Failed to read action history: ${formatGatewayError(err)}`,
|
|
1150
1390
|
});
|
|
1151
1391
|
}
|
|
1152
|
-
});
|
|
1392
|
+
}, { scope: "operator.read" });
|
|
1153
1393
|
// ─── Skills manager — read + mutate ──────────────────────────────────────
|
|
1154
1394
|
api.registerGatewayMethod("senpi.skills.status", async (ctx) => {
|
|
1155
1395
|
const respond = ctx.respond;
|
|
1156
1396
|
const snapshot = skillsCoordinator.getSnapshot();
|
|
1157
1397
|
respond(true, { snapshot });
|
|
1158
|
-
});
|
|
1398
|
+
}, { scope: "operator.read" });
|
|
1159
1399
|
api.registerGatewayMethod("senpi.skills.update", async (ctx) => {
|
|
1160
1400
|
const respond = ctx.respond;
|
|
1161
1401
|
const name = typeof ctx.params?.name === "string" ? ctx.params.name.trim() : undefined;
|
|
@@ -1180,7 +1420,7 @@ const senpiRuntimePlugin = {
|
|
|
1180
1420
|
message: err instanceof Error ? err.message : String(err),
|
|
1181
1421
|
});
|
|
1182
1422
|
}
|
|
1183
|
-
});
|
|
1423
|
+
}, { scope: "operator.write" });
|
|
1184
1424
|
api.registerGatewayMethod("senpi.skills.updateAll", async (ctx) => {
|
|
1185
1425
|
const respond = ctx.respond;
|
|
1186
1426
|
try {
|
|
@@ -1200,7 +1440,7 @@ const senpiRuntimePlugin = {
|
|
|
1200
1440
|
message: err instanceof Error ? err.message : String(err),
|
|
1201
1441
|
});
|
|
1202
1442
|
}
|
|
1203
|
-
});
|
|
1443
|
+
}, { scope: "operator.write" });
|
|
1204
1444
|
api.logger.info(`[senpi-runtime] v${VERSION} plugin registered — stateDir: ${baseStateDir}`);
|
|
1205
1445
|
},
|
|
1206
1446
|
};
|