@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/product-ref-state.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { WorkerInputConsumedPayload } from "@leitwerk-dev/worker-protocol";
|
|
|
3
3
|
|
|
4
4
|
import { mergeEntryRefPatchIntoStateJson } from "./entry-ref-patch.js";
|
|
5
5
|
|
|
6
|
+
/** @internal */
|
|
6
7
|
export type ProcessProductRefPatch = Record<string, ProcessProductRef | null | undefined>;
|
|
7
8
|
|
|
8
9
|
export function mergeProductRefPatchIntoStateJson(
|
|
@@ -9,27 +9,41 @@ import type { PostCommitEffect } from "./effects/post-commit-effect.js";
|
|
|
9
9
|
import { runPostCommitEffectList } from "./effects/post-commit-runner.js";
|
|
10
10
|
import type { Broadcaster } from "./ws/broadcast.js";
|
|
11
11
|
|
|
12
|
+
/** @internal */
|
|
12
13
|
export type ProjectUpdatedFrameInput = Extract<DurableWsFrameInput, { type: "project.updated" }>;
|
|
13
14
|
|
|
15
|
+
/** @internal */
|
|
14
16
|
export interface ProjectMutationCommit {
|
|
17
|
+
/** @internal */
|
|
15
18
|
project: ProcessProject | null;
|
|
19
|
+
/** @internal */
|
|
16
20
|
effects: PostCommitEffect[];
|
|
17
21
|
}
|
|
18
22
|
|
|
23
|
+
/** @internal */
|
|
19
24
|
export interface ProjectMutationService {
|
|
25
|
+
/** @internal */
|
|
20
26
|
create(input: CreateProcessProjectInput): ProcessProject;
|
|
27
|
+
/** @internal */
|
|
21
28
|
update(id: string, input: UpdateProcessProjectInput): ProcessProject | null;
|
|
29
|
+
/** @internal */
|
|
22
30
|
getById(id: string): ProcessProject | null;
|
|
31
|
+
/** @internal */
|
|
23
32
|
getByInstanceAndKey(instanceId: string, key: string): ProcessProject | null;
|
|
33
|
+
/** @internal */
|
|
24
34
|
listByInstance(instanceId: string): ProcessProject[];
|
|
25
35
|
}
|
|
26
36
|
|
|
37
|
+
/** @internal */
|
|
27
38
|
export interface ProjectMutationServiceDeps
|
|
28
39
|
extends Pick<RepositoryBundle, "projects" | "transaction"> {
|
|
40
|
+
/** @internal */
|
|
29
41
|
broadcaster: Broadcaster;
|
|
42
|
+
/** @internal */
|
|
30
43
|
onProjectMutated?: (project: ProcessProject) => void;
|
|
31
44
|
}
|
|
32
45
|
|
|
46
|
+
/** @internal */
|
|
33
47
|
export function buildProjectUpdatedFrame(project: ProcessProject): ProjectUpdatedFrameInput {
|
|
34
48
|
return {
|
|
35
49
|
type: "project.updated",
|
|
@@ -51,18 +65,24 @@ export function buildProjectUpdatedFrame(project: ProcessProject): ProjectUpdate
|
|
|
51
65
|
};
|
|
52
66
|
}
|
|
53
67
|
|
|
68
|
+
/** @internal */
|
|
54
69
|
export function buildProjectUpdatedEffect(project: ProcessProject): PostCommitEffect {
|
|
55
70
|
return { kind: "broadcast", frame: buildProjectUpdatedFrame(project) };
|
|
56
71
|
}
|
|
57
72
|
|
|
73
|
+
/** @internal */
|
|
58
74
|
export function commitProjectCreate(
|
|
59
75
|
deps: Pick<RepositoryBundle, "projects">,
|
|
60
76
|
input: CreateProcessProjectInput,
|
|
61
|
-
): ProjectMutationCommit & {
|
|
77
|
+
): ProjectMutationCommit & {
|
|
78
|
+
/** @internal */
|
|
79
|
+
project: ProcessProject;
|
|
80
|
+
} {
|
|
62
81
|
const project = deps.projects.create(input);
|
|
63
82
|
return { project, effects: [buildProjectUpdatedEffect(project)] };
|
|
64
83
|
}
|
|
65
84
|
|
|
85
|
+
/** @internal */
|
|
66
86
|
export function commitProjectUpdate(
|
|
67
87
|
deps: Pick<RepositoryBundle, "projects">,
|
|
68
88
|
id: string,
|
|
@@ -88,6 +108,7 @@ function runProjectMutationPostCommitEffects(
|
|
|
88
108
|
);
|
|
89
109
|
}
|
|
90
110
|
|
|
111
|
+
/** @internal */
|
|
91
112
|
export function createProjectMutationService(
|
|
92
113
|
deps: ProjectMutationServiceDeps,
|
|
93
114
|
): ProjectMutationService {
|
|
@@ -8,9 +8,13 @@ import {
|
|
|
8
8
|
type ResultImageMimeType,
|
|
9
9
|
} from "@leitwerk-dev/worker-protocol";
|
|
10
10
|
|
|
11
|
+
/** @internal */
|
|
11
12
|
export interface ResultImageMetadata {
|
|
13
|
+
/** @internal */
|
|
12
14
|
imageId: string;
|
|
15
|
+
/** @internal */
|
|
13
16
|
mimeType: ResultImageMimeType;
|
|
17
|
+
/** @internal */
|
|
14
18
|
byteSize: number;
|
|
15
19
|
}
|
|
16
20
|
|
|
@@ -24,9 +28,15 @@ const MIME_BY_EXTENSION: Record<string, ResultImageMimeType> = {
|
|
|
24
28
|
jpg: "image/jpeg",
|
|
25
29
|
webp: "image/webp",
|
|
26
30
|
};
|
|
31
|
+
/** @internal */
|
|
27
32
|
export class ResultImageStore {
|
|
33
|
+
/** @internal */
|
|
28
34
|
readonly rootDir: string;
|
|
29
|
-
|
|
35
|
+
/** @internal */
|
|
36
|
+
constructor(input: {
|
|
37
|
+
/** @internal */
|
|
38
|
+
rootDir: string;
|
|
39
|
+
}) {
|
|
30
40
|
this.rootDir = path.resolve(input.rootDir);
|
|
31
41
|
}
|
|
32
42
|
private turnDir(instanceId: string, turnRecordId: string): string {
|
|
@@ -34,10 +44,15 @@ export class ResultImageStore {
|
|
|
34
44
|
throw new Error("Invalid result image storage id");
|
|
35
45
|
return path.join(this.rootDir, instanceId, turnRecordId);
|
|
36
46
|
}
|
|
47
|
+
/** @internal */
|
|
37
48
|
async put(input: {
|
|
49
|
+
/** @internal */
|
|
38
50
|
instanceId: string;
|
|
51
|
+
/** @internal */
|
|
39
52
|
turnRecordId: string;
|
|
53
|
+
/** @internal */
|
|
40
54
|
bytes: Buffer;
|
|
55
|
+
/** @internal */
|
|
41
56
|
mimeType: ResultImageMimeType;
|
|
42
57
|
}): Promise<ResultImageMetadata> {
|
|
43
58
|
const dir = this.turnDir(input.instanceId, input.turnRecordId);
|
|
@@ -54,13 +69,17 @@ export class ResultImageStore {
|
|
|
54
69
|
}
|
|
55
70
|
return { imageId, mimeType: input.mimeType, byteSize: input.bytes.length };
|
|
56
71
|
}
|
|
72
|
+
/** @internal */
|
|
57
73
|
async deleteProcess(instanceId: string): Promise<void> {
|
|
58
74
|
if (!isResultImageStorageSegment(instanceId))
|
|
59
75
|
throw new Error("Invalid result image storage id");
|
|
60
76
|
await rm(path.join(this.rootDir, instanceId), { recursive: true, force: true });
|
|
61
77
|
}
|
|
78
|
+
/** @internal */
|
|
62
79
|
async cleanupProcesses(input: {
|
|
80
|
+
/** @internal */
|
|
63
81
|
retainedInstanceIds: ReadonlySet<string>;
|
|
82
|
+
/** @internal */
|
|
64
83
|
expiredInstanceIds?: ReadonlySet<string>;
|
|
65
84
|
}): Promise<string[]> {
|
|
66
85
|
let entries: Dirent[];
|
|
@@ -83,11 +102,17 @@ export class ResultImageStore {
|
|
|
83
102
|
}
|
|
84
103
|
return removed;
|
|
85
104
|
}
|
|
105
|
+
/** @internal */
|
|
86
106
|
async get(
|
|
87
107
|
instanceId: string,
|
|
88
108
|
turnRecordId: string,
|
|
89
109
|
imageId: string,
|
|
90
|
-
): Promise<{
|
|
110
|
+
): Promise<{
|
|
111
|
+
/** @internal */
|
|
112
|
+
metadata: ResultImageMetadata;
|
|
113
|
+
/** @internal */
|
|
114
|
+
bytes: Buffer;
|
|
115
|
+
} | null> {
|
|
91
116
|
const extension = parseResultImageId(imageId)?.extension;
|
|
92
117
|
if (!extension) return null;
|
|
93
118
|
try {
|
|
@@ -91,6 +91,7 @@ import type { Broadcaster } from "../ws/broadcast.js";
|
|
|
91
91
|
|
|
92
92
|
export const PRIMARY_PATH_ACTIVE_TURN_EVENT_LIMIT = 500;
|
|
93
93
|
|
|
94
|
+
/** @public */
|
|
94
95
|
export interface RouteDeps
|
|
95
96
|
extends Pick<
|
|
96
97
|
RepositoryBundle,
|
|
@@ -115,37 +116,66 @@ export interface RouteDeps
|
|
|
115
116
|
| "externalWrites"
|
|
116
117
|
| "transaction"
|
|
117
118
|
> {
|
|
119
|
+
/** @internal */
|
|
118
120
|
startupObservations?: RepositoryBundle["startupObservations"];
|
|
121
|
+
/** @public */
|
|
119
122
|
externalSourceService?: Pick<
|
|
120
123
|
import("../external-source-service.js").ExternalSourceService,
|
|
121
124
|
"currentGenerations"
|
|
122
125
|
>;
|
|
126
|
+
/** @internal */
|
|
123
127
|
broadcaster: Broadcaster;
|
|
128
|
+
/** @internal */
|
|
124
129
|
processOperations: ProcessOperationCoordinator;
|
|
130
|
+
/** @internal */
|
|
125
131
|
processQuestions: ProcessQuestionService;
|
|
132
|
+
/** @internal */
|
|
126
133
|
toolApprovalGate: ToolApprovalGate;
|
|
134
|
+
/** @internal */
|
|
127
135
|
processGraphs: ProcessGraphRegistry;
|
|
136
|
+
/** @internal */
|
|
128
137
|
supervisor?: WorkerSupervisor;
|
|
138
|
+
/** @internal */
|
|
129
139
|
processEngine: ProcessEngine;
|
|
140
|
+
/** @internal */
|
|
130
141
|
processDeletion: ProcessDeletionService;
|
|
142
|
+
/** @internal */
|
|
131
143
|
processActionRegistry?: ProcessActionRegistry;
|
|
144
|
+
/** @internal */
|
|
132
145
|
processUiRegistry?: ProcessUiRegistry;
|
|
146
|
+
/** @internal */
|
|
133
147
|
extensionHost?: ExtensionHost;
|
|
148
|
+
/** @internal */
|
|
134
149
|
launcherService: ProcessLauncherService;
|
|
150
|
+
/** @internal */
|
|
135
151
|
launchCoordinator: LaunchCoordinator;
|
|
152
|
+
/** @internal */
|
|
136
153
|
launcherRecentValues: LauncherRecentValuesService;
|
|
154
|
+
/** @internal */
|
|
137
155
|
launchPlans: ProcessLaunchPlanServiceLike;
|
|
156
|
+
/** @internal */
|
|
138
157
|
processTitles?: ProcessTitleGenerator;
|
|
158
|
+
/** @internal */
|
|
139
159
|
toolRenderers?: ReadonlyMap<string, ToolCallRendererDefinition>;
|
|
160
|
+
/** @internal */
|
|
140
161
|
config?: LeitwerkConfig;
|
|
162
|
+
/** @internal */
|
|
141
163
|
sessionReader: ProcessSessionReader;
|
|
164
|
+
/** @internal */
|
|
142
165
|
futureExecutionLifecycle: FutureExecutionLifecycle;
|
|
166
|
+
/** @internal */
|
|
143
167
|
modelProviderRegistry?: ModelProviderRegistry;
|
|
168
|
+
/** @internal */
|
|
144
169
|
modelProviderCredentialStatus?: ModelProviderCredentialStatusResolver;
|
|
170
|
+
/** @internal */
|
|
145
171
|
modelStatusCache: ModelStatusCache;
|
|
172
|
+
/** @internal */
|
|
146
173
|
processModelPolicy: ServerProcessModelPolicy;
|
|
174
|
+
/** @internal */
|
|
147
175
|
processModelSelection: ProcessModelSelectionServiceLike;
|
|
176
|
+
/** @internal */
|
|
148
177
|
skillCatalog?: SkillCatalogService;
|
|
178
|
+
/** @internal */
|
|
149
179
|
sessionTransferService?: SessionTransferService;
|
|
150
180
|
}
|
|
151
181
|
|
|
@@ -6,11 +6,15 @@ import {
|
|
|
6
6
|
resolveExtensionUiAssetPath,
|
|
7
7
|
} from "../extension-ui/catalog.js";
|
|
8
8
|
|
|
9
|
+
/** @internal */
|
|
9
10
|
export interface UiRouteDeps {
|
|
11
|
+
/** @internal */
|
|
10
12
|
extensionUiCatalog: ExtensionUiCatalog;
|
|
13
|
+
/** @internal */
|
|
11
14
|
extensionUiAssetCacheControl?: string;
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
/** @internal */
|
|
14
18
|
export function registerUiRendererRoutes(app: FastifyInstance, deps: UiRouteDeps): void {
|
|
15
19
|
app.get("/api/ui/extensions", async () => ({
|
|
16
20
|
ok: true,
|
package/src/routes/watchers.ts
CHANGED
|
@@ -10,7 +10,9 @@ import type {
|
|
|
10
10
|
RegisteredProcessWatcherLike,
|
|
11
11
|
} from "../process-watcher-registry.js";
|
|
12
12
|
|
|
13
|
+
/** @internal */
|
|
13
14
|
export interface WatcherRouteDeps {
|
|
15
|
+
/** @internal */
|
|
14
16
|
processWatchers?: ProcessWatcherServiceLike;
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -58,6 +60,7 @@ function buildWatcherSummary(watcher: RegisteredProcessWatcherLike): WatcherSumm
|
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
/** @internal */
|
|
61
64
|
export function registerWatcherRoutes(app: FastifyInstance, deps: WatcherRouteDeps): void {
|
|
62
65
|
app.get("/api/watchers", async () => {
|
|
63
66
|
const watchers = deps.processWatchers?.listAll() ?? [];
|
|
@@ -3,6 +3,7 @@ import type { WorkerInputConsumedPayload } from "@leitwerk-dev/worker-protocol";
|
|
|
3
3
|
|
|
4
4
|
import { type EntryRefPatch, mergeEntryRefPatchIntoStateJson } from "./entry-ref-patch.js";
|
|
5
5
|
|
|
6
|
+
/** @internal */
|
|
6
7
|
export type ProcessSemanticEntryRefPatch = Partial<
|
|
7
8
|
Record<ProcessSemanticEntryRefKey, EntryRefPatch[string]>
|
|
8
9
|
>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { FastifyInstance } from "fastify";
|
|
2
|
+
import type { ServerListenOptions, ServerListenResult } from "../app.js";
|
|
3
|
+
import type { LeitwerkConfig } from "../config/index.js";
|
|
4
|
+
|
|
5
|
+
type LifecycleHook = () => void | Promise<void>;
|
|
6
|
+
|
|
7
|
+
/** @internal */
|
|
8
|
+
export async function collectCleanupErrors(operations: Array<() => void | Promise<void>>) {
|
|
9
|
+
const errors: unknown[] = [];
|
|
10
|
+
for (const operation of [...operations].reverse()) {
|
|
11
|
+
try {
|
|
12
|
+
await operation();
|
|
13
|
+
} catch (error) {
|
|
14
|
+
errors.push(error);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return errors;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Coordinates one context's listener, startup and shutdown. @internal */
|
|
21
|
+
export function createAppLifecycle(input: {
|
|
22
|
+
app: FastifyInstance;
|
|
23
|
+
server: LeitwerkConfig["server"];
|
|
24
|
+
authEnabled: boolean;
|
|
25
|
+
reconcile(assertOpen: () => void): Promise<void>;
|
|
26
|
+
startHooks: readonly LifecycleHook[];
|
|
27
|
+
preCloseCleanup: LifecycleHook[];
|
|
28
|
+
closeDatabase: LifecycleHook;
|
|
29
|
+
}) {
|
|
30
|
+
const { app } = input;
|
|
31
|
+
let closing = false;
|
|
32
|
+
let closePromise: Promise<void> | undefined;
|
|
33
|
+
let startupOperation: Promise<void> | undefined;
|
|
34
|
+
let startupPromise: Promise<void> | undefined;
|
|
35
|
+
let binding: Required<ServerListenOptions> | undefined;
|
|
36
|
+
let bindOperation: Promise<ServerListenResult> | undefined;
|
|
37
|
+
const cleanupErrors: unknown[] = [];
|
|
38
|
+
function assertOpen() {
|
|
39
|
+
if (closing) throw new Error("AppContext startup interrupted: context is closed");
|
|
40
|
+
}
|
|
41
|
+
function close(): Promise<void> {
|
|
42
|
+
closing = true;
|
|
43
|
+
backgroundServicesReady = false;
|
|
44
|
+
closePromise ??= (async () => {
|
|
45
|
+
await bindOperation?.catch(() => {});
|
|
46
|
+
await startupOperation?.catch(() => {});
|
|
47
|
+
await app.close();
|
|
48
|
+
})();
|
|
49
|
+
return closePromise;
|
|
50
|
+
}
|
|
51
|
+
async function failStartup(error: unknown): Promise<never> {
|
|
52
|
+
try {
|
|
53
|
+
await close();
|
|
54
|
+
} catch (cleanupError) {
|
|
55
|
+
throw new AggregateError([error, cleanupError], "Server startup failed and cleanup failed", {
|
|
56
|
+
cause: error,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
async function listen(options: ServerListenOptions = {}): Promise<ServerListenResult> {
|
|
62
|
+
assertOpen();
|
|
63
|
+
if (binding) {
|
|
64
|
+
for (const key of ["host", "port", "useBoundAddressAsBaseUrl"] as const) {
|
|
65
|
+
if (options[key] !== undefined && options[key] !== binding[key])
|
|
66
|
+
throw new Error(`Conflicting listener option: ${key}`);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
if (app.server.listening) throw new Error("Cannot adopt a manually bound listener");
|
|
70
|
+
const requested = {
|
|
71
|
+
host: options.host ?? input.server.host,
|
|
72
|
+
port: options.port ?? input.server.port,
|
|
73
|
+
useBoundAddressAsBaseUrl: options.useBoundAddressAsBaseUrl ?? false,
|
|
74
|
+
};
|
|
75
|
+
if (
|
|
76
|
+
requested.useBoundAddressAsBaseUrl &&
|
|
77
|
+
(input.authEnabled || !["127.0.0.1", "::1", "localhost"].includes(requested.host))
|
|
78
|
+
)
|
|
79
|
+
throw new Error("Bound base URL requires an unauthenticated loopback listener");
|
|
80
|
+
binding = requested;
|
|
81
|
+
bindOperation = (async () => {
|
|
82
|
+
const started = performance.now();
|
|
83
|
+
const address = await app.listen({ host: requested.host, port: requested.port });
|
|
84
|
+
app.log.info(
|
|
85
|
+
{ listenDurationMs: Math.round((performance.now() - started) * 10) / 10 },
|
|
86
|
+
"Server HTTP listener ready",
|
|
87
|
+
);
|
|
88
|
+
const info = app.server.address();
|
|
89
|
+
if (!info || typeof info === "string") throw new Error("Expected TCP listener address");
|
|
90
|
+
if (requested.useBoundAddressAsBaseUrl) input.server.base_url = address;
|
|
91
|
+
return { address, port: info.port };
|
|
92
|
+
})();
|
|
93
|
+
}
|
|
94
|
+
let result: ServerListenResult;
|
|
95
|
+
try {
|
|
96
|
+
if (!bindOperation) throw new Error("Listener was not initialized");
|
|
97
|
+
result = await bindOperation;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
return failStartup(error);
|
|
100
|
+
}
|
|
101
|
+
await startServices();
|
|
102
|
+
assertOpen();
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
function startServices(): Promise<void> {
|
|
106
|
+
if (closing)
|
|
107
|
+
return Promise.reject(new Error("AppContext startup interrupted: context is closed"));
|
|
108
|
+
if (startupPromise) return startupPromise;
|
|
109
|
+
startupOperation = (async () => {
|
|
110
|
+
await bindOperation;
|
|
111
|
+
assertOpen();
|
|
112
|
+
await input.reconcile(assertOpen);
|
|
113
|
+
for (const hook of input.startHooks) {
|
|
114
|
+
assertOpen();
|
|
115
|
+
await hook();
|
|
116
|
+
}
|
|
117
|
+
assertOpen();
|
|
118
|
+
backgroundServicesReady = true;
|
|
119
|
+
})();
|
|
120
|
+
// Cleanup waits on the raw operation, not this promise that itself awaits close().
|
|
121
|
+
startupPromise = startupOperation.catch(failStartup);
|
|
122
|
+
return startupPromise;
|
|
123
|
+
}
|
|
124
|
+
let backgroundServicesReady = false;
|
|
125
|
+
let cleanupOperation: Promise<void> | undefined;
|
|
126
|
+
function cleanup() {
|
|
127
|
+
closing = true;
|
|
128
|
+
backgroundServicesReady = false;
|
|
129
|
+
cleanupOperation ??= (async () => {
|
|
130
|
+
await startupOperation?.catch(() => {});
|
|
131
|
+
// Stop services and workers before connection teardown; retain SQLite for onClose.
|
|
132
|
+
cleanupErrors.push(...(await collectCleanupErrors(input.preCloseCleanup.splice(0))));
|
|
133
|
+
})();
|
|
134
|
+
return cleanupOperation;
|
|
135
|
+
}
|
|
136
|
+
app.addHook("preClose", cleanup);
|
|
137
|
+
async function finishCleanup() {
|
|
138
|
+
await cleanup();
|
|
139
|
+
cleanupErrors.push(...(await collectCleanupErrors([input.closeDatabase])));
|
|
140
|
+
if (cleanupErrors.length) throw new AggregateError(cleanupErrors, "AppContext cleanup failed");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
listen,
|
|
145
|
+
close,
|
|
146
|
+
isReady: () => backgroundServicesReady,
|
|
147
|
+
isClosing: () => closing,
|
|
148
|
+
finishCleanup,
|
|
149
|
+
};
|
|
150
|
+
}
|
package/src/server-topology.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import type { LeitwerkConfig } from "./config/config-types.js";
|
|
3
3
|
|
|
4
|
-
/** Reads a file's UTF-8 contents. Injected so the pure logic stays testable. */
|
|
4
|
+
/** Reads a file's UTF-8 contents. Injected so the pure logic stays testable. @internal */
|
|
5
5
|
export type FileReader = (path: string) => string;
|
|
6
6
|
|
|
7
7
|
const defaultFileReader: FileReader = (path) => readFileSync(path, "utf8");
|
|
@@ -14,11 +14,17 @@ const defaultFileReader: FileReader = (path) => readFileSync(path, "utf8");
|
|
|
14
14
|
* verification. Config validation currently rejects `internal_tls.client_ca_file`
|
|
15
15
|
* until workers receive client cert/key material.
|
|
16
16
|
*/
|
|
17
|
+
/** @internal */
|
|
17
18
|
export interface ServerTlsOptions {
|
|
19
|
+
/** @internal */
|
|
18
20
|
cert: string;
|
|
21
|
+
/** @internal */
|
|
19
22
|
key: string;
|
|
23
|
+
/** @internal */
|
|
20
24
|
ca?: string;
|
|
25
|
+
/** @internal */
|
|
21
26
|
requestCert: boolean;
|
|
27
|
+
/** @internal */
|
|
22
28
|
rejectUnauthorized: boolean;
|
|
23
29
|
}
|
|
24
30
|
|
|
@@ -32,6 +38,7 @@ export interface ServerTlsOptions {
|
|
|
32
38
|
* verification is intentionally not configurable yet because workers do not
|
|
33
39
|
* receive client cert/key material.
|
|
34
40
|
*/
|
|
41
|
+
/** @internal */
|
|
35
42
|
export function resolveServerTlsOptions(
|
|
36
43
|
config: LeitwerkConfig,
|
|
37
44
|
readFile: FileReader = defaultFileReader,
|
|
@@ -53,9 +53,13 @@ function sameManifestAuthority(
|
|
|
53
53
|
return JSON.stringify(manifestAuthority(expected)) === JSON.stringify(manifestAuthority(actual));
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/** @internal */
|
|
56
57
|
export function createSessionTransferHelperRelays(deps: {
|
|
58
|
+
/** @internal */
|
|
57
59
|
repos: Pick<RepositoryBundle, "sessionTransfers">;
|
|
60
|
+
/** @internal */
|
|
58
61
|
limits: SessionTransferLimits;
|
|
62
|
+
/** @internal */
|
|
59
63
|
now?: () => Date;
|
|
60
64
|
}) {
|
|
61
65
|
const now = deps.now ?? (() => new Date());
|
|
@@ -83,8 +87,11 @@ export function createSessionTransferHelperRelays(deps: {
|
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
return {
|
|
90
|
+
/** @internal */
|
|
86
91
|
create(input: {
|
|
92
|
+
/** @internal */
|
|
87
93
|
instanceId: string;
|
|
94
|
+
/** @internal */
|
|
88
95
|
manifest: LeitwerkTransferManifestV1;
|
|
89
96
|
}): ProcessStateExportHelperRelay {
|
|
90
97
|
const attempt = deps.repos.sessionTransfers.getActiveByInstance(input.instanceId);
|
|
@@ -128,20 +135,30 @@ export function createSessionTransferHelperRelays(deps: {
|
|
|
128
135
|
fail: runtime.fail,
|
|
129
136
|
};
|
|
130
137
|
},
|
|
138
|
+
/** @internal */
|
|
131
139
|
sweep(): void {
|
|
132
140
|
const currentTime = now().getTime();
|
|
133
141
|
for (const helper of helpers.values()) {
|
|
134
142
|
if (helper.expiresAt <= currentTime) helper.fail(new Error("export_helper_expired"));
|
|
135
143
|
}
|
|
136
144
|
},
|
|
145
|
+
/** @internal */
|
|
137
146
|
stop(): void {
|
|
138
147
|
for (const helper of helpers.values()) helper.fail(new Error("server_stopping"));
|
|
139
148
|
helpers.clear();
|
|
140
149
|
},
|
|
150
|
+
/** @internal */
|
|
141
151
|
helperSpec(input: {
|
|
152
|
+
/** @internal */
|
|
142
153
|
exportId: string;
|
|
154
|
+
/** @internal */
|
|
143
155
|
credential: string;
|
|
144
|
-
}): {
|
|
156
|
+
}): {
|
|
157
|
+
/** @internal */
|
|
158
|
+
manifest: LeitwerkTransferManifestV1;
|
|
159
|
+
/** @internal */
|
|
160
|
+
limits: SessionTransferLimits;
|
|
161
|
+
} | null {
|
|
145
162
|
const helper = active(input.exportId, input.credential);
|
|
146
163
|
if (!helper || helper.reported || helper.streamAccepted) return null;
|
|
147
164
|
const attempt = deps.repos.sessionTransfers.getAttempt(helper.attemptId);
|
|
@@ -153,10 +170,15 @@ export function createSessionTransferHelperRelays(deps: {
|
|
|
153
170
|
limits: { ...deps.limits },
|
|
154
171
|
};
|
|
155
172
|
},
|
|
173
|
+
/** @internal */
|
|
156
174
|
async reportHelperPreflight(input: {
|
|
175
|
+
/** @internal */
|
|
157
176
|
exportId: string;
|
|
177
|
+
/** @internal */
|
|
158
178
|
credential: string;
|
|
179
|
+
/** @internal */
|
|
159
180
|
report: unknown;
|
|
181
|
+
/** @internal */
|
|
160
182
|
signal?: AbortSignal;
|
|
161
183
|
}): Promise<boolean> {
|
|
162
184
|
const helper = active(input.exportId, input.credential);
|
|
@@ -184,7 +206,15 @@ export function createSessionTransferHelperRelays(deps: {
|
|
|
184
206
|
return false;
|
|
185
207
|
}
|
|
186
208
|
},
|
|
187
|
-
|
|
209
|
+
/** @internal */
|
|
210
|
+
acceptHelperStream(input: {
|
|
211
|
+
/** @internal */
|
|
212
|
+
exportId: string;
|
|
213
|
+
/** @internal */
|
|
214
|
+
credential: string;
|
|
215
|
+
/** @internal */
|
|
216
|
+
stream: Readable;
|
|
217
|
+
}): boolean {
|
|
188
218
|
const helper = active(input.exportId, input.credential);
|
|
189
219
|
if (!helper?.reported || helper.streamAccepted) return false;
|
|
190
220
|
const attempt = deps.repos.sessionTransfers.getAttempt(helper.attemptId);
|
|
@@ -198,4 +228,5 @@ export function createSessionTransferHelperRelays(deps: {
|
|
|
198
228
|
};
|
|
199
229
|
}
|
|
200
230
|
|
|
231
|
+
/** @internal */
|
|
201
232
|
export type SessionTransferHelperRelays = ReturnType<typeof createSessionTransferHelperRelays>;
|