@leitwerk-dev/server 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-4QSV4FUQ.js +8 -0
- package/dist/{app-D4XHIbwA.d.ts → app-WfwKzrVk.d.ts} +2029 -410
- package/dist/app.d.ts +55 -12
- package/dist/app.d.ts.map +1 -1
- package/dist/{chunk-AGC2ND53.js → chunk-KIOQNNG6.js} +1645 -750
- package/dist/chunk-KIOQNNG6.js.map +1 -0
- package/dist/{chunk-XTXH6623.js → chunk-LK3RO6C7.js} +1543 -2111
- package/dist/chunk-LK3RO6C7.js.map +1 -0
- package/dist/config/config-loader.d.ts +11 -0
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-types.d.ts +152 -51
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/db/api-token-repo.d.ts +24 -0
- package/dist/db/api-token-repo.d.ts.map +1 -1
- package/dist/db/auth-repo.d.ts +30 -0
- package/dist/db/auth-repo.d.ts.map +1 -1
- package/dist/db/credential-cipher.d.ts +8 -3
- package/dist/db/credential-cipher.d.ts.map +1 -1
- package/dist/db/database.d.ts +19 -1
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/external-write-log-repo.d.ts +6 -1
- package/dist/db/external-write-log-repo.d.ts.map +1 -1
- package/dist/db/future-execution-repo.d.ts +47 -0
- package/dist/db/future-execution-repo.d.ts.map +1 -1
- package/dist/db/launch-run-repo.d.ts +17 -0
- package/dist/db/launch-run-repo.d.ts.map +1 -1
- package/dist/db/launcher-recent-value-repo.d.ts +15 -0
- package/dist/db/launcher-recent-value-repo.d.ts.map +1 -1
- package/dist/db/pending-external-source-fire-repo.d.ts +33 -0
- package/dist/db/pending-external-source-fire-repo.d.ts.map +1 -1
- package/dist/db/process-event-repo.d.ts +17 -0
- package/dist/db/process-event-repo.d.ts.map +1 -1
- package/dist/db/process-handoff-dedup-key-repo.d.ts +8 -0
- package/dist/db/process-handoff-dedup-key-repo.d.ts.map +1 -1
- package/dist/db/process-input-repo.d.ts +15 -0
- package/dist/db/process-input-repo.d.ts.map +1 -1
- package/dist/db/process-instance-repo.d.ts +49 -0
- package/dist/db/process-instance-repo.d.ts.map +1 -1
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts +18 -0
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts.map +1 -1
- package/dist/db/process-project-repo.d.ts +20 -0
- package/dist/db/process-project-repo.d.ts.map +1 -1
- package/dist/db/process-question-request-repo.d.ts +19 -0
- package/dist/db/process-question-request-repo.d.ts.map +1 -1
- package/dist/db/process-relation-repo.d.ts +5 -0
- package/dist/db/process-relation-repo.d.ts.map +1 -1
- package/dist/db/process-skill-repo.d.ts +4 -0
- package/dist/db/process-skill-repo.d.ts.map +1 -1
- package/dist/db/process-title-job-repo.d.ts +22 -0
- package/dist/db/process-title-job-repo.d.ts.map +1 -1
- package/dist/db/process-tool-approval-request-repo.d.ts +20 -0
- package/dist/db/process-tool-approval-request-repo.d.ts.map +1 -1
- package/dist/db/process-turn-annotation-repo.d.ts +22 -2
- package/dist/db/process-turn-annotation-repo.d.ts.map +1 -1
- package/dist/db/process-turn-record-repo.d.ts +27 -0
- package/dist/db/process-turn-record-repo.d.ts.map +1 -1
- package/dist/db/provider-credential-repo.d.ts +16 -0
- package/dist/db/provider-credential-repo.d.ts.map +1 -1
- package/dist/db/repositories.d.ts +33 -0
- package/dist/db/repositories.d.ts.map +1 -1
- package/dist/db/session-transfer-repo.d.ts +49 -1
- package/dist/db/session-transfer-repo.d.ts.map +1 -1
- package/dist/db/skill-repo.d.ts +20 -0
- package/dist/db/skill-repo.d.ts.map +1 -1
- package/dist/db/startup-observation-repo.d.ts +3 -0
- package/dist/db/startup-observation-repo.d.ts.map +1 -1
- package/dist/db/ticket-destination-recent-repo.d.ts +14 -0
- package/dist/db/ticket-destination-recent-repo.d.ts.map +1 -1
- package/dist/db/turn-start-record-repo.d.ts +9 -0
- package/dist/db/turn-start-record-repo.d.ts.map +1 -1
- package/dist/db/turn-summary-repo.d.ts +18 -0
- package/dist/db/turn-summary-repo.d.ts.map +1 -1
- package/dist/db/worker-lease-repo.d.ts +31 -1
- package/dist/db/worker-lease-repo.d.ts.map +1 -1
- package/dist/effects/post-commit-effect.d.ts +29 -0
- package/dist/effects/post-commit-effect.d.ts.map +1 -1
- package/dist/effects/post-commit-runner.d.ts +1 -0
- package/dist/effects/post-commit-runner.d.ts.map +1 -1
- package/dist/entry-ref-patch.d.ts +3 -0
- package/dist/entry-ref-patch.d.ts.map +1 -1
- package/dist/extension-ui/catalog.d.ts +15 -0
- package/dist/extension-ui/catalog.d.ts.map +1 -1
- package/dist/extensions/extension-host.d.ts +6 -0
- package/dist/extensions/extension-host.d.ts.map +1 -1
- package/dist/external-source-service.d.ts +8 -0
- package/dist/external-source-service.d.ts.map +1 -1
- package/dist/future-execution/execution.d.ts +23 -1
- package/dist/future-execution/execution.d.ts.map +1 -1
- package/dist/future-execution/launch-lifecycle.d.ts +76 -0
- package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
- package/dist/future-execution/lifecycle.d.ts +99 -0
- package/dist/future-execution/lifecycle.d.ts.map +1 -1
- package/dist/future-execution/model-projection.d.ts +6 -0
- package/dist/future-execution/model-projection.d.ts.map +1 -1
- package/dist/future-execution/transition-planner.d.ts +25 -0
- package/dist/future-execution/transition-planner.d.ts.map +1 -1
- package/dist/future-execution-scheduler.d.ts +1 -1
- package/dist/future-execution-scheduler.d.ts.map +1 -1
- package/dist/index.d.ts +3 -30
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -239
- package/dist/index.js.map +1 -1
- package/dist/instance-tree.d.ts +3 -0
- package/dist/instance-tree.d.ts.map +1 -1
- package/dist/integration-tool-registry.d.ts +4 -1
- package/dist/integration-tool-registry.d.ts.map +1 -1
- package/dist/launch-coordinator.d.ts +33 -0
- package/dist/launch-coordinator.d.ts.map +1 -1
- package/dist/launch-pipeline.d.ts +60 -0
- package/dist/launch-pipeline.d.ts.map +1 -1
- package/dist/launcher-recent-values-service.d.ts +3 -0
- package/dist/launcher-recent-values-service.d.ts.map +1 -1
- package/dist/main.js +7 -14
- package/dist/main.js.map +1 -1
- package/dist/model-providers/builtin-server-adapter.d.ts +1 -0
- package/dist/model-providers/builtin-server-adapter.d.ts.map +1 -1
- package/dist/model-providers/credentials.d.ts +17 -0
- package/dist/model-providers/credentials.d.ts.map +1 -1
- package/dist/model-providers/model-status-cache.d.ts +30 -1
- package/dist/model-providers/model-status-cache.d.ts.map +1 -1
- package/dist/model-providers/provider-options.d.ts +21 -1
- package/dist/model-providers/provider-options.d.ts.map +1 -1
- package/dist/model-providers/registry.d.ts +22 -2
- package/dist/model-providers/registry.d.ts.map +1 -1
- package/dist/model-providers/server-adapters.d.ts +19 -0
- package/dist/model-providers/server-adapters.d.ts.map +1 -1
- package/dist/pi-resources/assemble.d.ts +24 -4
- package/dist/pi-resources/assemble.d.ts.map +1 -1
- package/dist/pi-resources/bundle-cache.d.ts +20 -1
- package/dist/pi-resources/bundle-cache.d.ts.map +1 -1
- package/dist/pi-resources/bundle-pin-lifecycle.d.ts +5 -1
- package/dist/pi-resources/bundle-pin-lifecycle.d.ts.map +1 -1
- package/dist/pi-resources/resource-collector.d.ts +11 -0
- package/dist/pi-resources/resource-collector.d.ts.map +1 -1
- package/dist/pi-session-tree.d.ts +13 -1
- package/dist/pi-session-tree.d.ts.map +1 -1
- package/dist/process-action-registry.d.ts +47 -0
- package/dist/process-action-registry.d.ts.map +1 -1
- package/dist/process-deletion-service.d.ts +12 -0
- package/dist/process-deletion-service.d.ts.map +1 -1
- package/dist/process-engine/decision.d.ts +12 -0
- package/dist/process-engine/decision.d.ts.map +1 -1
- package/dist/process-engine/engine.d.ts +1 -0
- package/dist/process-engine/engine.d.ts.map +1 -1
- package/dist/process-engine/operation.d.ts +23 -2
- package/dist/process-engine/operation.d.ts.map +1 -1
- package/dist/process-engine/startup-reconciliation.d.ts +14 -0
- package/dist/process-engine/startup-reconciliation.d.ts.map +1 -1
- package/dist/process-engine/types.d.ts +112 -1
- package/dist/process-engine/types.d.ts.map +1 -1
- package/dist/process-engine/writes/build-process-park-writes.d.ts +3 -0
- package/dist/process-engine/writes/build-process-park-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-recovery-start-writes.d.ts +4 -0
- package/dist/process-engine/writes/build-recovery-start-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-retry-writes.d.ts +3 -0
- package/dist/process-engine/writes/build-retry-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-failed-writes.d.ts +6 -0
- package/dist/process-engine/writes/build-turn-failed-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +8 -0
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-selection-writes.d.ts +8 -0
- package/dist/process-engine/writes/build-turn-selection-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/commit-writes.d.ts +14 -0
- package/dist/process-engine/writes/commit-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/deferred-extension-events.d.ts +4 -0
- package/dist/process-engine/writes/deferred-extension-events.d.ts.map +1 -1
- package/dist/process-engine/writes/writes.d.ts +67 -0
- package/dist/process-engine/writes/writes.d.ts.map +1 -1
- package/dist/process-graph.d.ts +1 -1
- package/dist/process-graph.d.ts.map +1 -1
- package/dist/process-input-dispatch.d.ts +1 -0
- package/dist/process-input-dispatch.d.ts.map +1 -1
- package/dist/process-launch-executor.d.ts +1 -0
- package/dist/process-launch-executor.d.ts.map +1 -1
- package/dist/process-model-policy/types.d.ts +157 -1
- package/dist/process-model-policy/types.d.ts.map +1 -1
- package/dist/process-operation-coordinator.d.ts +3 -0
- package/dist/process-operation-coordinator.d.ts.map +1 -1
- package/dist/process-question-service.d.ts +36 -20
- package/dist/process-question-service.d.ts.map +1 -1
- package/dist/process-runtime-availability.d.ts +2 -1
- package/dist/process-runtime-availability.d.ts.map +1 -1
- package/dist/process-session-store.d.ts +15 -4
- package/dist/process-session-store.d.ts.map +1 -1
- package/dist/process-title-generator.d.ts +53 -0
- package/dist/process-title-generator.d.ts.map +1 -1
- package/dist/process-turn-navigation.d.ts +1 -30
- package/dist/process-turn-navigation.d.ts.map +1 -1
- package/dist/process-turn-trace.d.ts +7 -0
- package/dist/process-turn-trace.d.ts.map +1 -1
- package/dist/process-ui-registry.d.ts +2 -0
- package/dist/process-ui-registry.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts +68 -1
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- package/dist/process-watcher-registry.d.ts +5 -0
- package/dist/process-watcher-registry.d.ts.map +1 -1
- package/dist/product-ref-state.d.ts +1 -0
- package/dist/product-ref-state.d.ts.map +1 -1
- package/dist/project-mutation-service.d.ts +19 -0
- package/dist/project-mutation-service.d.ts.map +1 -1
- package/dist/result-image-store.d.ts +20 -0
- package/dist/result-image-store.d.ts.map +1 -1
- package/dist/routes/process-route-helpers.d.ts +30 -0
- package/dist/routes/process-route-helpers.d.ts.map +1 -1
- package/dist/routes/ui-renderers.d.ts +4 -0
- package/dist/routes/ui-renderers.d.ts.map +1 -1
- package/dist/routes/watchers.d.ts +3 -0
- package/dist/routes/watchers.d.ts.map +1 -1
- package/dist/semantic-entry-ref-state.d.ts +1 -0
- package/dist/semantic-entry-ref-state.d.ts.map +1 -1
- package/dist/server-bootstrap/app-lifecycle.d.ts +24 -0
- package/dist/server-bootstrap/app-lifecycle.d.ts.map +1 -0
- package/dist/server-bootstrap/build-host-capabilities.d.ts +5 -1
- package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
- package/dist/server-topology.d.ts +8 -1
- package/dist/server-topology.d.ts.map +1 -1
- package/dist/session-transfer-helper-relays.d.ts +24 -0
- package/dist/session-transfer-helper-relays.d.ts.map +1 -1
- package/dist/session-transfer-service.d.ts +63 -1
- package/dist/session-transfer-service.d.ts.map +1 -1
- package/dist/skills/catalog-service.d.ts +7 -0
- package/dist/skills/catalog-service.d.ts.map +1 -1
- package/dist/skills/source-importer.d.ts +8 -0
- package/dist/skills/source-importer.d.ts.map +1 -1
- package/dist/startup-evidence.d.ts.map +1 -1
- package/dist/supervisor/ipc-handler.d.ts +28 -0
- package/dist/supervisor/ipc-handler.d.ts.map +1 -1
- package/dist/supervisor/worker-event-ingestor.d.ts +10 -0
- package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts +13 -0
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-storage-layout.d.ts +12 -0
- package/dist/supervisor/worker-storage-layout.d.ts.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +47 -3
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts +19 -0
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts.map +1 -1
- package/dist/supervisor/worker-unit-reclaimer.d.ts +3 -0
- package/dist/supervisor/worker-unit-reclaimer.d.ts.map +1 -1
- package/dist/supervisor/worker-websocket-ipc.d.ts +37 -0
- package/dist/supervisor/worker-websocket-ipc.d.ts.map +1 -1
- package/dist/test-helpers/accepted-turn-start.d.ts +22 -0
- package/dist/test-helpers/accepted-turn-start.d.ts.map +1 -1
- package/dist/test-helpers/prepared-fixture-start.d.ts +14 -0
- package/dist/test-helpers/prepared-fixture-start.d.ts.map +1 -0
- package/dist/test-helpers/session-snapshot-fixtures.d.ts +1 -1
- package/dist/test-helpers/session-snapshot-fixtures.d.ts.map +1 -1
- package/dist/test-helpers/turn-start-preflight-fixtures.d.ts +8 -1
- package/dist/test-helpers/turn-start-preflight-fixtures.d.ts.map +1 -1
- package/dist/test-helpers/unit-deps.d.ts +8 -0
- package/dist/test-helpers/unit-deps.d.ts.map +1 -1
- package/dist/testing.d.ts +5 -7
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +60 -53
- package/dist/testing.js.map +1 -1
- package/dist/tool-approval-gate.d.ts +21 -0
- package/dist/tool-approval-gate.d.ts.map +1 -1
- package/dist/turn-result-markdown.d.ts +2 -0
- package/dist/turn-result-markdown.d.ts.map +1 -1
- package/dist/worker-runtime-profile-selection.d.ts +20 -4
- package/dist/worker-runtime-profile-selection.d.ts.map +1 -1
- package/dist/ws/broadcast.d.ts +10 -0
- package/dist/ws/broadcast.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/app.ts +916 -892
- package/src/config/config-loader.ts +12 -0
- package/src/config/config-types.ts +166 -66
- package/src/db/api-token-repo.ts +35 -2
- package/src/db/auth-repo.ts +35 -1
- package/src/db/credential-cipher.ts +8 -3
- package/src/db/database.ts +14 -0
- package/src/db/external-write-log-repo.ts +6 -1
- package/src/db/future-execution-repo.ts +51 -1
- package/src/db/launch-run-repo.ts +17 -0
- package/src/db/launcher-recent-value-repo.ts +15 -0
- package/src/db/pending-external-source-fire-repo.ts +33 -0
- package/src/db/process-event-repo.ts +21 -1
- package/src/db/process-handoff-dedup-key-repo.ts +8 -0
- package/src/db/process-input-repo.ts +15 -0
- package/src/db/process-instance-repo.ts +57 -2
- package/src/db/process-leaf-outcome-snapshot-repo.ts +18 -0
- package/src/db/process-project-repo.ts +20 -0
- package/src/db/process-question-request-repo.ts +19 -0
- package/src/db/process-relation-repo.ts +8 -1
- package/src/db/process-skill-repo.ts +4 -0
- package/src/db/process-title-job-repo.ts +30 -2
- package/src/db/process-tool-approval-request-repo.ts +24 -1
- package/src/db/process-turn-annotation-repo.ts +22 -2
- package/src/db/process-turn-record-repo.ts +27 -0
- package/src/db/provider-credential-repo.ts +20 -1
- package/src/db/repositories.ts +36 -1
- package/src/db/session-transfer-repo.ts +71 -9
- package/src/db/skill-repo.ts +24 -1
- package/src/db/startup-observation-repo.ts +3 -0
- package/src/db/ticket-destination-recent-repo.ts +14 -0
- package/src/db/turn-start-record-repo.ts +12 -1
- package/src/db/turn-summary-repo.ts +29 -2
- package/src/db/worker-lease-repo.ts +31 -1
- package/src/deployment-preflight.ts +1 -1
- package/src/effects/post-commit-effect.ts +42 -3
- package/src/effects/post-commit-runner.ts +1 -0
- package/src/entry-ref-patch.ts +9 -1
- package/src/extension-ui/catalog.ts +15 -0
- package/src/extensions/extension-host.ts +6 -0
- package/src/external-source-service.ts +12 -1
- package/src/future-execution/execution.ts +45 -8
- package/src/future-execution/launch-lifecycle.ts +145 -17
- package/src/future-execution/lifecycle.ts +124 -13
- package/src/future-execution/model-projection.ts +6 -0
- package/src/future-execution/transition-planner.ts +25 -0
- package/src/future-execution-scheduler.ts +7 -6
- package/src/index.ts +5 -153
- package/src/instance-tree.ts +3 -0
- package/src/integration-tool-registry.ts +17 -8
- package/src/launch-coordinator.ts +55 -5
- package/src/launch-pipeline.ts +103 -12
- package/src/launcher-recent-values-service.ts +3 -0
- package/src/main.ts +3 -10
- package/src/model-providers/builtin-server-adapter.ts +1 -0
- package/src/model-providers/credentials.ts +17 -0
- package/src/model-providers/model-status-cache.ts +30 -1
- package/src/model-providers/provider-options.ts +25 -2
- package/src/model-providers/registry.ts +22 -2
- package/src/model-providers/server-adapters.ts +19 -0
- package/src/pi-resources/assemble.ts +24 -4
- package/src/pi-resources/bundle-cache.ts +20 -1
- package/src/pi-resources/bundle-pin-lifecycle.ts +8 -2
- package/src/pi-resources/resource-collector.ts +11 -0
- package/src/pi-session-tree.ts +13 -1
- package/src/process-action-registry.ts +53 -1
- package/src/process-deletion-service.ts +29 -4
- package/src/process-engine/decision.ts +12 -0
- package/src/process-engine/engine.ts +1 -0
- package/src/process-engine/operation.ts +23 -2
- package/src/process-engine/startup-reconciliation.ts +14 -0
- package/src/process-engine/types.ts +176 -14
- package/src/process-engine/writes/build-process-park-writes.ts +3 -0
- package/src/process-engine/writes/build-recovery-start-writes.ts +4 -0
- package/src/process-engine/writes/build-retry-writes.ts +3 -0
- package/src/process-engine/writes/build-turn-failed-writes.ts +6 -0
- package/src/process-engine/writes/build-turn-outcome-writes.ts +8 -0
- package/src/process-engine/writes/build-turn-selection-writes.ts +8 -0
- package/src/process-engine/writes/commit-writes.ts +14 -0
- package/src/process-engine/writes/deferred-extension-events.ts +4 -0
- package/src/process-engine/writes/writes.ts +104 -10
- package/src/process-graph.ts +0 -3
- package/src/process-input-dispatch.ts +1 -0
- package/src/process-launch-executor.ts +1 -0
- package/src/process-model-policy/types.ts +195 -11
- package/src/process-operation-coordinator.ts +3 -0
- package/src/process-question-service.ts +53 -11
- package/src/process-runtime-availability.ts +4 -3
- package/src/process-session-store.ts +15 -4
- package/src/process-title-generator.ts +71 -5
- package/src/process-turn-navigation.ts +4 -1
- package/src/process-turn-trace.ts +7 -0
- package/src/process-ui-registry.ts +2 -0
- package/src/process-ui-snapshot-presenter.ts +75 -3
- package/src/process-watcher-registry.ts +5 -0
- package/src/product-ref-state.ts +1 -0
- package/src/project-mutation-service.ts +22 -1
- package/src/result-image-store.ts +27 -2
- package/src/routes/process-route-helpers.ts +30 -0
- package/src/routes/ui-renderers.ts +4 -0
- package/src/routes/watchers.ts +3 -0
- package/src/semantic-entry-ref-state.ts +1 -0
- package/src/server-bootstrap/app-lifecycle.ts +150 -0
- package/src/server-topology.ts +8 -1
- package/src/session-transfer-helper-relays.ts +33 -2
- package/src/session-transfer-service.ts +75 -7
- package/src/skills/catalog-service.ts +7 -0
- package/src/skills/source-importer.ts +8 -0
- package/src/startup-evidence.ts +23 -41
- package/src/supervisor/ipc-handler.ts +33 -1
- package/src/supervisor/worker-event-ingestor.ts +10 -0
- package/src/supervisor/worker-start-payload-builder.ts +16 -1
- package/src/supervisor/worker-storage-layout.ts +12 -0
- package/src/supervisor/worker-supervisor.ts +119 -133
- package/src/supervisor/worker-turn-ipc-recorder.ts +19 -0
- package/src/supervisor/worker-unit-reclaimer.ts +3 -0
- package/src/supervisor/worker-websocket-ipc.ts +57 -3
- package/src/test-helpers/accepted-turn-start.ts +32 -3
- package/src/test-helpers/prepared-fixture-start.ts +74 -0
- package/src/test-helpers/session-snapshot-fixtures.ts +1 -1
- package/src/test-helpers/turn-start-preflight-fixtures.ts +8 -1
- package/src/test-helpers/unit-deps.ts +13 -1
- package/src/testing.ts +5 -23
- package/src/tool-approval-gate.ts +32 -3
- package/src/turn-result-markdown.ts +2 -0
- package/src/worker-runtime-profile-selection.ts +24 -5
- package/src/ws/broadcast.ts +20 -1
- package/dist/app-I4QQUL5B.js +0 -10
- package/dist/chunk-AGC2ND53.js.map +0 -1
- package/dist/chunk-XTXH6623.js.map +0 -1
- /package/dist/{app-I4QQUL5B.js.map → app-4QSV4FUQ.js.map} +0 -0
package/src/db/auth-repo.ts
CHANGED
|
@@ -4,19 +4,31 @@ import type { LeitwerkDb } from "./database.js";
|
|
|
4
4
|
import { now } from "./repo-helpers.js";
|
|
5
5
|
import * as s from "./schema.js";
|
|
6
6
|
|
|
7
|
+
/** @internal */
|
|
7
8
|
export interface AuthSessionRecord {
|
|
9
|
+
/** @internal */
|
|
8
10
|
idHash: string;
|
|
11
|
+
/** @internal */
|
|
9
12
|
actor: Actor;
|
|
13
|
+
/** @internal */
|
|
10
14
|
createdAt: string;
|
|
15
|
+
/** @internal */
|
|
11
16
|
expiresAt: string;
|
|
12
17
|
}
|
|
13
18
|
|
|
19
|
+
/** @internal */
|
|
14
20
|
export interface AuthLoginFlowRecord {
|
|
21
|
+
/** @internal */
|
|
15
22
|
idHash: string;
|
|
23
|
+
/** @internal */
|
|
16
24
|
providerId: string;
|
|
25
|
+
/** @internal */
|
|
17
26
|
state: string;
|
|
27
|
+
/** @internal */
|
|
18
28
|
pkceVerifier: string;
|
|
29
|
+
/** @internal */
|
|
19
30
|
createdAt: string;
|
|
31
|
+
/** @internal */
|
|
20
32
|
expiresAt: string;
|
|
21
33
|
}
|
|
22
34
|
|
|
@@ -34,9 +46,18 @@ function sessionRowToRecord(row: typeof s.authSessions.$inferSelect): AuthSessio
|
|
|
34
46
|
};
|
|
35
47
|
}
|
|
36
48
|
|
|
49
|
+
/** @internal */
|
|
37
50
|
export function createAuthSessionRepo(db: LeitwerkDb) {
|
|
38
51
|
return {
|
|
39
|
-
|
|
52
|
+
/** @internal */
|
|
53
|
+
create(input: {
|
|
54
|
+
/** @internal */
|
|
55
|
+
idHash: string;
|
|
56
|
+
/** @internal */
|
|
57
|
+
actor: Actor;
|
|
58
|
+
/** @internal */
|
|
59
|
+
expiresAt: string;
|
|
60
|
+
}): AuthSessionRecord {
|
|
40
61
|
const ts = now();
|
|
41
62
|
const values = {
|
|
42
63
|
idHash: input.idHash,
|
|
@@ -50,6 +71,7 @@ export function createAuthSessionRepo(db: LeitwerkDb) {
|
|
|
50
71
|
return sessionRowToRecord(values);
|
|
51
72
|
},
|
|
52
73
|
|
|
74
|
+
/** @internal */
|
|
53
75
|
getValid(idHash: string, atIso: string = now()): AuthSessionRecord | null {
|
|
54
76
|
const row = db
|
|
55
77
|
.select()
|
|
@@ -59,11 +81,13 @@ export function createAuthSessionRepo(db: LeitwerkDb) {
|
|
|
59
81
|
return row ? sessionRowToRecord(row) : null;
|
|
60
82
|
},
|
|
61
83
|
|
|
84
|
+
/** @internal */
|
|
62
85
|
delete(idHash: string): boolean {
|
|
63
86
|
const result = db.delete(s.authSessions).where(eq(s.authSessions.idHash, idHash)).run();
|
|
64
87
|
return result.changes > 0;
|
|
65
88
|
},
|
|
66
89
|
|
|
90
|
+
/** @internal */
|
|
67
91
|
deleteExpired(atIso: string = now()): number {
|
|
68
92
|
const result = db.delete(s.authSessions).where(lt(s.authSessions.expiresAt, atIso)).run();
|
|
69
93
|
return Number(result.changes);
|
|
@@ -71,13 +95,20 @@ export function createAuthSessionRepo(db: LeitwerkDb) {
|
|
|
71
95
|
};
|
|
72
96
|
}
|
|
73
97
|
|
|
98
|
+
/** @internal */
|
|
74
99
|
export function createAuthLoginFlowRepo(db: LeitwerkDb) {
|
|
75
100
|
return {
|
|
101
|
+
/** @internal */
|
|
76
102
|
create(input: {
|
|
103
|
+
/** @internal */
|
|
77
104
|
idHash: string;
|
|
105
|
+
/** @internal */
|
|
78
106
|
providerId: string;
|
|
107
|
+
/** @internal */
|
|
79
108
|
state: string;
|
|
109
|
+
/** @internal */
|
|
80
110
|
pkceVerifier: string;
|
|
111
|
+
/** @internal */
|
|
81
112
|
expiresAt: string;
|
|
82
113
|
}): AuthLoginFlowRecord {
|
|
83
114
|
const values = {
|
|
@@ -92,6 +123,7 @@ export function createAuthLoginFlowRepo(db: LeitwerkDb) {
|
|
|
92
123
|
return values;
|
|
93
124
|
},
|
|
94
125
|
|
|
126
|
+
/** @internal */
|
|
95
127
|
getValid(idHash: string, atIso: string = now()): AuthLoginFlowRecord | null {
|
|
96
128
|
const row = db
|
|
97
129
|
.select()
|
|
@@ -101,11 +133,13 @@ export function createAuthLoginFlowRepo(db: LeitwerkDb) {
|
|
|
101
133
|
return row ?? null;
|
|
102
134
|
},
|
|
103
135
|
|
|
136
|
+
/** @internal */
|
|
104
137
|
delete(idHash: string): boolean {
|
|
105
138
|
const result = db.delete(s.authLoginFlows).where(eq(s.authLoginFlows.idHash, idHash)).run();
|
|
106
139
|
return result.changes > 0;
|
|
107
140
|
},
|
|
108
141
|
|
|
142
|
+
/** @internal */
|
|
109
143
|
deleteExpired(atIso: string = now()): number {
|
|
110
144
|
const result = db.delete(s.authLoginFlows).where(lt(s.authLoginFlows.expiresAt, atIso)).run();
|
|
111
145
|
return Number(result.changes);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
2
2
|
|
|
3
|
-
/** Application boundary for encrypted credential payloads. Callers supply deployment key material. */
|
|
3
|
+
/** Application boundary for encrypted credential payloads. Callers supply deployment key material. @internal */
|
|
4
4
|
export interface CredentialCipher {
|
|
5
|
+
/** @internal */
|
|
5
6
|
encrypt(plaintext: string): string;
|
|
7
|
+
/** @internal */
|
|
6
8
|
decrypt(ciphertext: string): string;
|
|
7
9
|
}
|
|
8
10
|
|
|
11
|
+
/** @internal */
|
|
9
12
|
export const PROVIDER_CREDENTIAL_KEY_ENV = "LEITWERK_CREDENTIAL_ENCRYPTION_KEY";
|
|
10
13
|
|
|
11
|
-
/** A missing deployment key may inspect an empty table but can never read or write credentials. */
|
|
14
|
+
/** A missing deployment key may inspect an empty table but can never read or write credentials. @internal */
|
|
12
15
|
export function createUnavailableCredentialCipher(): CredentialCipher {
|
|
13
16
|
const unavailable = (): never => {
|
|
14
17
|
throw new Error(
|
|
@@ -18,7 +21,7 @@ export function createUnavailableCredentialCipher(): CredentialCipher {
|
|
|
18
21
|
return { encrypt: unavailable, decrypt: unavailable };
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
/** Parses an exact 32-byte Base64 deployment secret. */
|
|
24
|
+
/** Parses an exact 32-byte Base64 deployment secret. @internal */
|
|
22
25
|
export function createCredentialCipherFromBase64(value: string): CredentialCipher {
|
|
23
26
|
const normalized = value.trim();
|
|
24
27
|
if (normalized === "") {
|
|
@@ -34,6 +37,7 @@ export function createCredentialCipherFromBase64(value: string): CredentialCiphe
|
|
|
34
37
|
return createAes256GcmCredentialCipher(key);
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
/** @internal */
|
|
37
41
|
export function createCredentialCipherFromEnvironment(
|
|
38
42
|
environment: NodeJS.ProcessEnv = process.env,
|
|
39
43
|
): CredentialCipher | null {
|
|
@@ -41,6 +45,7 @@ export function createCredentialCipherFromEnvironment(
|
|
|
41
45
|
return value === undefined ? null : createCredentialCipherFromBase64(value);
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
/** @internal */
|
|
44
49
|
export function createAes256GcmCredentialCipher(key: Buffer): CredentialCipher {
|
|
45
50
|
if (key.length !== 32) throw new Error("Credential encryption key must be 32 bytes");
|
|
46
51
|
return {
|
package/src/db/database.ts
CHANGED
|
@@ -6,20 +6,30 @@ import type { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
|
6
6
|
import * as schema from "./schema.js";
|
|
7
7
|
import { generateCreateIndexDDL, generateCreateTableDDL, getTableName } from "./schema-ddl.js";
|
|
8
8
|
|
|
9
|
+
/** @public */
|
|
9
10
|
export type LeitwerkDb = ReturnType<typeof drizzle>;
|
|
10
11
|
|
|
12
|
+
/** @internal */
|
|
11
13
|
export interface DatabaseOptions {
|
|
14
|
+
/** @internal */
|
|
12
15
|
sqlitePath: string;
|
|
16
|
+
/** @internal */
|
|
13
17
|
enableWAL?: boolean;
|
|
14
18
|
}
|
|
15
19
|
|
|
20
|
+
/** @internal */
|
|
16
21
|
export interface InitializeSchemaOptions {
|
|
22
|
+
/** @internal */
|
|
17
23
|
sqlitePath?: string;
|
|
18
24
|
}
|
|
19
25
|
|
|
26
|
+
/** @internal */
|
|
20
27
|
export class DatabaseSchemaMismatchError extends Error {
|
|
28
|
+
/** @internal */
|
|
21
29
|
constructor(
|
|
30
|
+
/** @internal */
|
|
22
31
|
readonly sqlitePath: string,
|
|
32
|
+
/** @internal */
|
|
23
33
|
readonly tableName: string,
|
|
24
34
|
) {
|
|
25
35
|
super(
|
|
@@ -885,6 +895,7 @@ export function applyKnownMigrations(
|
|
|
885
895
|
return { backupPath, migrationIds: migrations.map((migration) => migration.id) };
|
|
886
896
|
}
|
|
887
897
|
|
|
898
|
+
/** @internal */
|
|
888
899
|
export function initializeSchema(sqlite: DatabaseSync, opts: InitializeSchemaOptions = {}) {
|
|
889
900
|
const sqlitePath = opts.sqlitePath ?? ":memory:";
|
|
890
901
|
for (const table of ALL_TABLES) {
|
|
@@ -893,6 +904,7 @@ export function initializeSchema(sqlite: DatabaseSync, opts: InitializeSchemaOpt
|
|
|
893
904
|
}
|
|
894
905
|
}
|
|
895
906
|
|
|
907
|
+
/** @internal */
|
|
896
908
|
export function createDatabase(opts: DatabaseOptions) {
|
|
897
909
|
const fileBacked = opts.sqlitePath !== ":memory:";
|
|
898
910
|
const existingFileBackedDatabase = fileBacked && existsSync(opts.sqlitePath);
|
|
@@ -925,10 +937,12 @@ export function createDatabase(opts: DatabaseOptions) {
|
|
|
925
937
|
}
|
|
926
938
|
}
|
|
927
939
|
|
|
940
|
+
/** @internal */
|
|
928
941
|
export function createInMemoryDatabase() {
|
|
929
942
|
return createDatabase({ sqlitePath: ":memory:", enableWAL: false });
|
|
930
943
|
}
|
|
931
944
|
|
|
945
|
+
/** @internal */
|
|
932
946
|
export function closeDatabase(db: LeitwerkDb): void {
|
|
933
947
|
const sqlite = (db as unknown as { $client?: DatabaseSync }).$client;
|
|
934
948
|
sqlite?.close();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ExternalWriteLog, ExternalWriteType } from "@leitwerk-dev/domain";
|
|
2
|
-
import type { ExternalWriteLogRecordInput } from "@leitwerk-dev/external-writes";
|
|
2
|
+
import type { ExternalWriteLogRecordInput } from "@leitwerk-dev/external-writes/internal";
|
|
3
3
|
import { desc, eq } from "drizzle-orm";
|
|
4
4
|
import type { LeitwerkDb } from "./database.js";
|
|
5
5
|
import { generateId, now } from "./repo-helpers.js";
|
|
6
6
|
import * as s from "./schema.js";
|
|
7
7
|
|
|
8
|
+
/** @internal */
|
|
8
9
|
export interface CreateExternalWriteLogInput extends ExternalWriteLogRecordInput {}
|
|
9
10
|
|
|
10
11
|
function rowToExternalWriteLog(row: typeof s.externalWriteLog.$inferSelect): ExternalWriteLog {
|
|
@@ -18,8 +19,10 @@ function rowToExternalWriteLog(row: typeof s.externalWriteLog.$inferSelect): Ext
|
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
/** @public */
|
|
21
23
|
export function createExternalWriteLogRepo(db: LeitwerkDb) {
|
|
22
24
|
return {
|
|
25
|
+
/** @internal */
|
|
23
26
|
record(input: CreateExternalWriteLogInput): ExternalWriteLog {
|
|
24
27
|
const id = generateId("ewl");
|
|
25
28
|
const ts = now();
|
|
@@ -35,6 +38,7 @@ export function createExternalWriteLogRepo(db: LeitwerkDb) {
|
|
|
35
38
|
return rowToExternalWriteLog(values);
|
|
36
39
|
},
|
|
37
40
|
|
|
41
|
+
/** @internal */
|
|
38
42
|
hasDedupKey(dedupKey: string): boolean {
|
|
39
43
|
const row = db
|
|
40
44
|
.select()
|
|
@@ -44,6 +48,7 @@ export function createExternalWriteLogRepo(db: LeitwerkDb) {
|
|
|
44
48
|
return row !== undefined;
|
|
45
49
|
},
|
|
46
50
|
|
|
51
|
+
/** @public */
|
|
47
52
|
listByInstance(instanceId: string): ExternalWriteLog[] {
|
|
48
53
|
return db
|
|
49
54
|
.select()
|
|
@@ -11,43 +11,71 @@ import type { LeitwerkDb } from "./database.js";
|
|
|
11
11
|
import { generateId, now, sqliteLikePatterns } from "./repo-helpers.js";
|
|
12
12
|
import * as s from "./schema.js";
|
|
13
13
|
|
|
14
|
+
/** @internal */
|
|
14
15
|
interface FutureExecutionWritableFields {
|
|
16
|
+
/** @internal */
|
|
15
17
|
scheduleKind: FutureExecutionScheduleKind;
|
|
18
|
+
/** @internal */
|
|
16
19
|
processId: string;
|
|
20
|
+
/** @internal */
|
|
17
21
|
instanceId?: string | null;
|
|
22
|
+
/** @internal */
|
|
18
23
|
launcherId?: string | null;
|
|
24
|
+
/** @internal */
|
|
19
25
|
actionId?: string | null;
|
|
26
|
+
/** @internal */
|
|
20
27
|
payloadJson: string;
|
|
28
|
+
/** @internal */
|
|
21
29
|
cronExpression?: string | null;
|
|
30
|
+
/** @internal */
|
|
22
31
|
nextRunAt: string;
|
|
32
|
+
/** @internal */
|
|
23
33
|
modelSelection?: DurableModelSelection | null;
|
|
34
|
+
/** @internal */
|
|
24
35
|
blockedReason?: FutureExecutionBlockReason | null;
|
|
25
36
|
}
|
|
26
37
|
|
|
38
|
+
/** @internal */
|
|
27
39
|
export interface CreateFutureExecutionInput extends FutureExecutionWritableFields {
|
|
40
|
+
/** @internal */
|
|
28
41
|
id?: string;
|
|
42
|
+
/** @internal */
|
|
29
43
|
kind: FutureExecutionKind;
|
|
30
44
|
}
|
|
31
45
|
|
|
46
|
+
/** @internal */
|
|
32
47
|
export interface FutureExecutionOverviewQuery {
|
|
48
|
+
/** @internal */
|
|
33
49
|
query?: string;
|
|
50
|
+
/** @internal */
|
|
34
51
|
processType?: string;
|
|
52
|
+
/** @internal */
|
|
35
53
|
status?: "all" | "running" | "scheduled" | "needs_attention" | "completed" | "aborted";
|
|
54
|
+
/** @internal */
|
|
36
55
|
matchingLauncherIdsByTerm?: readonly (readonly string[])[];
|
|
37
56
|
}
|
|
38
57
|
|
|
58
|
+
/** @internal */
|
|
39
59
|
export interface FutureExecutionOverviewPageQuery extends FutureExecutionOverviewQuery {
|
|
60
|
+
/** @internal */
|
|
40
61
|
limit: number;
|
|
62
|
+
/** @internal */
|
|
41
63
|
offset: number;
|
|
42
64
|
}
|
|
43
65
|
|
|
66
|
+
/** @internal */
|
|
44
67
|
export interface FutureExecutionOverviewWindowQuery extends FutureExecutionOverviewQuery {
|
|
68
|
+
/** @internal */
|
|
45
69
|
limit: number;
|
|
70
|
+
/** @internal */
|
|
46
71
|
sortKey: "status" | "title" | "timeline";
|
|
72
|
+
/** @internal */
|
|
47
73
|
sortDirection: "asc" | "desc";
|
|
74
|
+
/** @internal */
|
|
48
75
|
launcherFallbackTitles: Readonly<Record<string, string>>;
|
|
49
76
|
}
|
|
50
77
|
|
|
78
|
+
/** @internal */
|
|
51
79
|
export type UpdateFutureExecutionInput = Partial<FutureExecutionWritableFields>;
|
|
52
80
|
|
|
53
81
|
function overviewPredicates(input: FutureExecutionOverviewQuery): SQL[] {
|
|
@@ -152,8 +180,10 @@ function rowToFutureExecution(row: typeof s.futureExecutions.$inferSelect): Futu
|
|
|
152
180
|
};
|
|
153
181
|
}
|
|
154
182
|
|
|
183
|
+
/** @internal */
|
|
155
184
|
export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
156
185
|
return {
|
|
186
|
+
/** @internal */
|
|
157
187
|
create(input: CreateFutureExecutionInput): FutureExecution {
|
|
158
188
|
const id = input.id ?? generateId("fut");
|
|
159
189
|
const ts = now();
|
|
@@ -177,11 +207,13 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
177
207
|
return rowToFutureExecution(values);
|
|
178
208
|
},
|
|
179
209
|
|
|
210
|
+
/** @internal */
|
|
180
211
|
getById(id: string): FutureExecution | null {
|
|
181
212
|
const row = db.select().from(s.futureExecutions).where(eq(s.futureExecutions.id, id)).get();
|
|
182
213
|
return row ? rowToFutureExecution(row) : null;
|
|
183
214
|
},
|
|
184
215
|
|
|
216
|
+
/** @internal */
|
|
185
217
|
listAll(): FutureExecution[] {
|
|
186
218
|
return db
|
|
187
219
|
.select()
|
|
@@ -191,6 +223,7 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
191
223
|
.map(rowToFutureExecution);
|
|
192
224
|
},
|
|
193
225
|
|
|
226
|
+
/** @internal */
|
|
194
227
|
countOverview(input: FutureExecutionOverviewQuery): number {
|
|
195
228
|
return (
|
|
196
229
|
db.select({ value: count() }).from(s.futureExecutions).where(overviewWhere(input)).get()
|
|
@@ -198,11 +231,17 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
198
231
|
);
|
|
199
232
|
},
|
|
200
233
|
|
|
234
|
+
/** @internal */
|
|
201
235
|
listOverviewProcessTypes(
|
|
202
236
|
input: Pick<FutureExecutionOverviewQuery, "query" | "status" | "matchingLauncherIdsByTerm">,
|
|
203
237
|
) {
|
|
204
238
|
return db
|
|
205
|
-
.select({
|
|
239
|
+
.select({
|
|
240
|
+
/** @internal */
|
|
241
|
+
processId: s.futureExecutions.processId,
|
|
242
|
+
/** @internal */
|
|
243
|
+
value: count(),
|
|
244
|
+
})
|
|
206
245
|
.from(s.futureExecutions)
|
|
207
246
|
.where(overviewWhere(input))
|
|
208
247
|
.groupBy(s.futureExecutions.processId)
|
|
@@ -210,6 +249,7 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
210
249
|
.all();
|
|
211
250
|
},
|
|
212
251
|
|
|
252
|
+
/** @internal */
|
|
213
253
|
listOverviewWindow(input: FutureExecutionOverviewWindowQuery): FutureExecution[] {
|
|
214
254
|
const fallbackCases = Object.entries(input.launcherFallbackTitles).map(
|
|
215
255
|
([launcherId, title]) => sql`when ${launcherId} then ${title}`,
|
|
@@ -245,8 +285,11 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
245
285
|
.map(rowToFutureExecution);
|
|
246
286
|
},
|
|
247
287
|
|
|
288
|
+
/** @internal */
|
|
248
289
|
listOverviewPage(input: FutureExecutionOverviewPageQuery): {
|
|
290
|
+
/** @internal */
|
|
249
291
|
items: FutureExecution[];
|
|
292
|
+
/** @internal */
|
|
250
293
|
total: number;
|
|
251
294
|
} {
|
|
252
295
|
const items = db
|
|
@@ -262,6 +305,7 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
262
305
|
return { items, total };
|
|
263
306
|
},
|
|
264
307
|
|
|
308
|
+
/** @internal */
|
|
265
309
|
listByInstance(instanceId: string): FutureExecution[] {
|
|
266
310
|
return db
|
|
267
311
|
.select()
|
|
@@ -272,6 +316,7 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
272
316
|
.map(rowToFutureExecution);
|
|
273
317
|
},
|
|
274
318
|
|
|
319
|
+
/** @internal */
|
|
275
320
|
listRunnableDue(asOf: string): FutureExecution[] {
|
|
276
321
|
return db
|
|
277
322
|
.select()
|
|
@@ -287,6 +332,7 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
287
332
|
.map(rowToFutureExecution);
|
|
288
333
|
},
|
|
289
334
|
|
|
335
|
+
/** @internal */
|
|
290
336
|
listBlockedCronDue(asOf: string): FutureExecution[] {
|
|
291
337
|
return db
|
|
292
338
|
.select()
|
|
@@ -303,6 +349,7 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
303
349
|
.map(rowToFutureExecution);
|
|
304
350
|
},
|
|
305
351
|
|
|
352
|
+
/** @internal */
|
|
306
353
|
getScheduledActionByInstance(instanceId: string): FutureExecution | null {
|
|
307
354
|
const row = db
|
|
308
355
|
.select()
|
|
@@ -315,6 +362,7 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
315
362
|
return row ? rowToFutureExecution(row) : null;
|
|
316
363
|
},
|
|
317
364
|
|
|
365
|
+
/** @internal */
|
|
318
366
|
updatePayloadJsonIfUnchanged(
|
|
319
367
|
id: string,
|
|
320
368
|
expectedPayloadJson: string,
|
|
@@ -333,6 +381,7 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
333
381
|
return result.changes > 0 ? this.getById(id) : null;
|
|
334
382
|
},
|
|
335
383
|
|
|
384
|
+
/** @internal */
|
|
336
385
|
update(id: string, input: UpdateFutureExecutionInput): FutureExecution | null {
|
|
337
386
|
const setValues: SQLiteUpdateSetSource<typeof s.futureExecutions> = {
|
|
338
387
|
updatedAt: now(),
|
|
@@ -356,6 +405,7 @@ export function createFutureExecutionRepo(db: LeitwerkDb) {
|
|
|
356
405
|
return this.getById(id);
|
|
357
406
|
},
|
|
358
407
|
|
|
408
|
+
/** @internal */
|
|
359
409
|
delete(id: string): boolean {
|
|
360
410
|
const result = db.delete(s.futureExecutions).where(eq(s.futureExecutions.id, id)).run();
|
|
361
411
|
return result.changes > 0;
|
|
@@ -32,13 +32,19 @@ function toLaunchRun(row: typeof s.launchRuns.$inferSelect): LaunchRun {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/** @internal */
|
|
35
36
|
export interface CreateLaunchRunInput {
|
|
37
|
+
/** @internal */
|
|
36
38
|
launcherId: string | null;
|
|
39
|
+
/** @internal */
|
|
37
40
|
idempotencyKey?: string | null;
|
|
41
|
+
/** @internal */
|
|
38
42
|
origin: LaunchOrigin;
|
|
43
|
+
/** @internal */
|
|
39
44
|
steps: readonly LaunchChecklistStep[];
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
/** @internal */
|
|
42
48
|
export function createLaunchRunRepo(db: LeitwerkDb) {
|
|
43
49
|
const list = (where: SQL): LaunchRun[] =>
|
|
44
50
|
db
|
|
@@ -49,6 +55,7 @@ export function createLaunchRunRepo(db: LeitwerkDb) {
|
|
|
49
55
|
.all()
|
|
50
56
|
.map(toLaunchRun);
|
|
51
57
|
return {
|
|
58
|
+
/** @internal */
|
|
52
59
|
create(input: CreateLaunchRunInput): LaunchRun {
|
|
53
60
|
const ts = now();
|
|
54
61
|
const row = {
|
|
@@ -68,11 +75,13 @@ export function createLaunchRunRepo(db: LeitwerkDb) {
|
|
|
68
75
|
return toLaunchRun(row);
|
|
69
76
|
},
|
|
70
77
|
|
|
78
|
+
/** @internal */
|
|
71
79
|
getById(id: string): LaunchRun | null {
|
|
72
80
|
const row = db.select().from(s.launchRuns).where(eq(s.launchRuns.id, id)).get();
|
|
73
81
|
return row ? toLaunchRun(row) : null;
|
|
74
82
|
},
|
|
75
83
|
|
|
84
|
+
/** @internal */
|
|
76
85
|
saveReplay(runId: string, payload: unknown): void {
|
|
77
86
|
db.insert(s.launchRunReplays)
|
|
78
87
|
.values({ launchRunId: runId, payloadJson: JSON.stringify(payload) })
|
|
@@ -83,6 +92,7 @@ export function createLaunchRunRepo(db: LeitwerkDb) {
|
|
|
83
92
|
.run();
|
|
84
93
|
},
|
|
85
94
|
|
|
95
|
+
/** @internal */
|
|
86
96
|
getReplay<T>(runId: string): T | null {
|
|
87
97
|
const row = db
|
|
88
98
|
.select({ payloadJson: s.launchRunReplays.payloadJson })
|
|
@@ -92,15 +102,18 @@ export function createLaunchRunRepo(db: LeitwerkDb) {
|
|
|
92
102
|
return row ? (JSON.parse(row.payloadJson) as T) : null;
|
|
93
103
|
},
|
|
94
104
|
|
|
105
|
+
/** @internal */
|
|
95
106
|
deleteReplay(runId: string): void {
|
|
96
107
|
db.delete(s.launchRunReplays).where(eq(s.launchRunReplays.launchRunId, runId)).run();
|
|
97
108
|
},
|
|
98
109
|
|
|
110
|
+
/** @internal */
|
|
99
111
|
getByIdempotencyKey(key: string): LaunchRun | null {
|
|
100
112
|
const row = db.select().from(s.launchRuns).where(eq(s.launchRuns.idempotencyKey, key)).get();
|
|
101
113
|
return row ? toLaunchRun(row) : null;
|
|
102
114
|
},
|
|
103
115
|
|
|
116
|
+
/** @internal */
|
|
104
117
|
archiveIdempotencyKey(id: string, key: string): void {
|
|
105
118
|
db.update(s.launchRuns)
|
|
106
119
|
.set({ idempotencyKey: `${key}:attempt:${id}` })
|
|
@@ -108,9 +121,12 @@ export function createLaunchRunRepo(db: LeitwerkDb) {
|
|
|
108
121
|
.run();
|
|
109
122
|
},
|
|
110
123
|
|
|
124
|
+
/** @internal */
|
|
111
125
|
listByInstance: (instanceId: string) => list(eq(s.launchRuns.instanceId, instanceId)),
|
|
126
|
+
/** @internal */
|
|
112
127
|
listIncomplete: () => list(inArray(s.launchRuns.status, [...ACTIVE_STATUSES])),
|
|
113
128
|
|
|
129
|
+
/** @internal */
|
|
114
130
|
compareAndSet(next: LaunchRun, expectedRevision: number): LaunchRun | null {
|
|
115
131
|
const updatedAt = now();
|
|
116
132
|
const result = db
|
|
@@ -130,6 +146,7 @@ export function createLaunchRunRepo(db: LeitwerkDb) {
|
|
|
130
146
|
return result.changes > 0 ? this.getById(next.id) : null;
|
|
131
147
|
},
|
|
132
148
|
|
|
149
|
+
/** @internal */
|
|
133
150
|
update(id: string, mutate: (current: LaunchRun) => LaunchRun): LaunchRun | null {
|
|
134
151
|
for (let attempt = 0; attempt < 8; attempt += 1) {
|
|
135
152
|
const current = this.getById(id);
|
|
@@ -3,17 +3,26 @@ import type { LeitwerkDb } from "./database.js";
|
|
|
3
3
|
import { generateId, now } from "./repo-helpers.js";
|
|
4
4
|
import * as s from "./schema.js";
|
|
5
5
|
|
|
6
|
+
/** @internal */
|
|
6
7
|
export interface LauncherRecentValue {
|
|
8
|
+
/** @internal */
|
|
7
9
|
id: string;
|
|
10
|
+
/** @internal */
|
|
8
11
|
launcherId: string;
|
|
12
|
+
/** @internal */
|
|
9
13
|
fieldId: string;
|
|
14
|
+
/** @internal */
|
|
10
15
|
value: string;
|
|
16
|
+
/** @internal */
|
|
11
17
|
createdAt: string;
|
|
18
|
+
/** @internal */
|
|
12
19
|
updatedAt: string;
|
|
13
20
|
}
|
|
14
21
|
|
|
22
|
+
/** @internal */
|
|
15
23
|
export function createLauncherRecentValueRepo(db: LeitwerkDb) {
|
|
16
24
|
return {
|
|
25
|
+
/** @internal */
|
|
17
26
|
listByLauncher(launcherId: string): LauncherRecentValue[] {
|
|
18
27
|
return db
|
|
19
28
|
.select()
|
|
@@ -23,10 +32,15 @@ export function createLauncherRecentValueRepo(db: LeitwerkDb) {
|
|
|
23
32
|
.all();
|
|
24
33
|
},
|
|
25
34
|
|
|
35
|
+
/** @internal */
|
|
26
36
|
recordValue(input: {
|
|
37
|
+
/** @internal */
|
|
27
38
|
launcherId: string;
|
|
39
|
+
/** @internal */
|
|
28
40
|
fieldId: string;
|
|
41
|
+
/** @internal */
|
|
29
42
|
value: string;
|
|
43
|
+
/** @internal */
|
|
30
44
|
limit?: number;
|
|
31
45
|
}): LauncherRecentValue {
|
|
32
46
|
const ts = now();
|
|
@@ -54,6 +68,7 @@ export function createLauncherRecentValueRepo(db: LeitwerkDb) {
|
|
|
54
68
|
return row;
|
|
55
69
|
},
|
|
56
70
|
|
|
71
|
+
/** @internal */
|
|
57
72
|
pruneField(launcherId: string, fieldId: string, limit = 5): void {
|
|
58
73
|
const stale = db
|
|
59
74
|
.select({ id: s.launcherRecentValues.id })
|
|
@@ -4,36 +4,63 @@ import type { LeitwerkDb } from "./database.js";
|
|
|
4
4
|
import { generateId, now } from "./repo-helpers.js";
|
|
5
5
|
import * as s from "./schema.js";
|
|
6
6
|
|
|
7
|
+
/** @internal */
|
|
7
8
|
export interface PendingExternalSourceFire {
|
|
9
|
+
/** @internal */
|
|
8
10
|
id: string;
|
|
11
|
+
/** @internal */
|
|
9
12
|
instanceId: string;
|
|
13
|
+
/** @internal */
|
|
10
14
|
armingId: string;
|
|
15
|
+
/** @internal */
|
|
11
16
|
turnId: string;
|
|
17
|
+
/** @internal */
|
|
12
18
|
externalActionId: string;
|
|
19
|
+
/** @internal */
|
|
13
20
|
sourceKind: string;
|
|
21
|
+
/** @internal */
|
|
14
22
|
input: Record<string, unknown>;
|
|
23
|
+
/** @internal */
|
|
15
24
|
event: Record<string, unknown>;
|
|
25
|
+
/** @internal */
|
|
16
26
|
mergeKey: string | null;
|
|
27
|
+
/** @internal */
|
|
17
28
|
queuedCount: number;
|
|
29
|
+
/** @internal */
|
|
18
30
|
createdAt: string;
|
|
31
|
+
/** @internal */
|
|
19
32
|
updatedAt: string;
|
|
20
33
|
}
|
|
21
34
|
|
|
35
|
+
/** @internal */
|
|
22
36
|
export interface CreatePendingExternalSourceFireInput {
|
|
37
|
+
/** @internal */
|
|
23
38
|
instanceId: string;
|
|
39
|
+
/** @internal */
|
|
24
40
|
armingId: string;
|
|
41
|
+
/** @internal */
|
|
25
42
|
turnId: string;
|
|
43
|
+
/** @internal */
|
|
26
44
|
externalActionId: string;
|
|
45
|
+
/** @internal */
|
|
27
46
|
sourceKind?: string;
|
|
47
|
+
/** @internal */
|
|
28
48
|
input?: Record<string, unknown>;
|
|
49
|
+
/** @internal */
|
|
29
50
|
event?: Record<string, unknown>;
|
|
51
|
+
/** @internal */
|
|
30
52
|
mergeKey?: string | null;
|
|
53
|
+
/** @internal */
|
|
31
54
|
queuedCount?: number;
|
|
32
55
|
}
|
|
33
56
|
|
|
57
|
+
/** @internal */
|
|
34
58
|
export interface UpdatePendingExternalSourceFireInput {
|
|
59
|
+
/** @internal */
|
|
35
60
|
input?: Record<string, unknown>;
|
|
61
|
+
/** @internal */
|
|
36
62
|
event?: Record<string, unknown>;
|
|
63
|
+
/** @internal */
|
|
37
64
|
queuedCount?: number;
|
|
38
65
|
}
|
|
39
66
|
|
|
@@ -63,8 +90,10 @@ function rowToPendingExternalSourceFire(
|
|
|
63
90
|
};
|
|
64
91
|
}
|
|
65
92
|
|
|
93
|
+
/** @internal */
|
|
66
94
|
export function createPendingExternalSourceFireRepo(db: LeitwerkDb) {
|
|
67
95
|
return {
|
|
96
|
+
/** @internal */
|
|
68
97
|
create(input: CreatePendingExternalSourceFireInput): PendingExternalSourceFire {
|
|
69
98
|
const ts = now();
|
|
70
99
|
const values = {
|
|
@@ -85,6 +114,7 @@ export function createPendingExternalSourceFireRepo(db: LeitwerkDb) {
|
|
|
85
114
|
return rowToPendingExternalSourceFire(values);
|
|
86
115
|
},
|
|
87
116
|
|
|
117
|
+
/** @internal */
|
|
88
118
|
listByInstance(instanceId: string): PendingExternalSourceFire[] {
|
|
89
119
|
return db
|
|
90
120
|
.select()
|
|
@@ -95,6 +125,7 @@ export function createPendingExternalSourceFireRepo(db: LeitwerkDb) {
|
|
|
95
125
|
.map(rowToPendingExternalSourceFire);
|
|
96
126
|
},
|
|
97
127
|
|
|
128
|
+
/** @internal */
|
|
98
129
|
getByMergeKey(
|
|
99
130
|
instanceId: string,
|
|
100
131
|
armingId: string,
|
|
@@ -114,6 +145,7 @@ export function createPendingExternalSourceFireRepo(db: LeitwerkDb) {
|
|
|
114
145
|
return row ? rowToPendingExternalSourceFire(row) : null;
|
|
115
146
|
},
|
|
116
147
|
|
|
148
|
+
/** @internal */
|
|
117
149
|
update(
|
|
118
150
|
id: string,
|
|
119
151
|
input: UpdatePendingExternalSourceFireInput,
|
|
@@ -137,6 +169,7 @@ export function createPendingExternalSourceFireRepo(db: LeitwerkDb) {
|
|
|
137
169
|
return row ? rowToPendingExternalSourceFire(row) : null;
|
|
138
170
|
},
|
|
139
171
|
|
|
172
|
+
/** @internal */
|
|
140
173
|
delete(id: string): boolean {
|
|
141
174
|
const result = db
|
|
142
175
|
.delete(s.pendingExternalSourceFires)
|