@leitwerk-dev/server 0.2.0 → 0.2.1
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-7PKX73TU.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-XTXH6623.js → chunk-CNITOV76.js} +1359 -991
- package/dist/chunk-CNITOV76.js.map +1 -0
- package/dist/{chunk-AGC2ND53.js → chunk-ZSKM25SD.js} +588 -667
- package/dist/chunk-ZSKM25SD.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 +17 -0
- package/dist/test-helpers/accepted-turn-start.d.ts.map +1 -1
- 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 +4 -7
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +2 -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 +28 -2
- 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 +4 -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-7PKX73TU.js.map} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
import type { ProcessInstance, WorkerLease } from "@leitwerk-dev/domain";
|
|
2
3
|
import {
|
|
3
4
|
parseResolvedExtensionEntries,
|
|
4
5
|
RUNTIME_EXTENSION_ALLOWED_ROOTS_ENV,
|
|
@@ -72,44 +73,72 @@ import {
|
|
|
72
73
|
type WorkerWebSocketIpcManager,
|
|
73
74
|
} from "./worker-websocket-ipc.js";
|
|
74
75
|
|
|
76
|
+
/** @internal */
|
|
75
77
|
export interface SupervisorDeps
|
|
76
78
|
extends Pick<
|
|
77
79
|
RepositoryBundle,
|
|
78
80
|
"leases" | "processes" | "projects" | "inputs" | "turnRecords" | "turnStarts" | "events"
|
|
79
81
|
> {
|
|
82
|
+
/** @internal */
|
|
80
83
|
startupObservations?: RepositoryBundle["startupObservations"];
|
|
84
|
+
/** @internal */
|
|
81
85
|
config: LeitwerkConfig;
|
|
86
|
+
/** @internal */
|
|
82
87
|
getLaunchCoordinator?: () => LaunchCoordinator | undefined;
|
|
88
|
+
/** @internal */
|
|
83
89
|
processGraphs: ProcessGraphRegistry;
|
|
90
|
+
/** @internal */
|
|
84
91
|
processActionRegistry: ProcessActionRegistry;
|
|
92
|
+
/** @internal */
|
|
85
93
|
processModelPolicy: ServerProcessModelPolicy;
|
|
94
|
+
/** @internal */
|
|
86
95
|
ipcHandler: ReturnType<typeof createIpcHandler>;
|
|
96
|
+
/** @internal */
|
|
87
97
|
broadcaster: Broadcaster;
|
|
98
|
+
/** @internal */
|
|
88
99
|
runnerRuntime: {
|
|
100
|
+
/** @internal */
|
|
89
101
|
runner: WorkerRunner;
|
|
102
|
+
/** @internal */
|
|
90
103
|
volume?: ProcessVolume;
|
|
104
|
+
/** @internal */
|
|
91
105
|
webSocketIpc: WorkerWebSocketIpcManager;
|
|
92
106
|
};
|
|
107
|
+
/** @internal */
|
|
93
108
|
resolvedExtensionEntriesJson?: string;
|
|
109
|
+
/** @internal */
|
|
94
110
|
serverEpoch?: string;
|
|
111
|
+
/** @internal */
|
|
95
112
|
logger?: WorkerUnitCleanupLogger;
|
|
113
|
+
/** @internal */
|
|
96
114
|
resolveResourceBundle?: (digest: string) => PiResourceBundle | null;
|
|
115
|
+
/** @internal */
|
|
97
116
|
resolveRepositoryCredentials?: WorkerStartPayloadBuilderDeps["resolveRepositoryCredentials"];
|
|
117
|
+
/** @internal */
|
|
98
118
|
integrationTools?: WorkerStartPayloadBuilderDeps["integrationTools"];
|
|
119
|
+
/** @internal */
|
|
99
120
|
resolveCredential?: WorkerStartPayloadBuilderDeps["resolveCredential"];
|
|
100
121
|
}
|
|
101
122
|
|
|
123
|
+
/** @public */
|
|
102
124
|
export interface WorkerHandle {
|
|
125
|
+
/** @internal */
|
|
103
126
|
workerId: string;
|
|
127
|
+
/** @internal */
|
|
104
128
|
instanceId: string;
|
|
105
|
-
/** Runtime-specific handle id when known; used to distinguish duplicate units during adoption scans. */
|
|
129
|
+
/** Runtime-specific handle id when known; used to distinguish duplicate units during adoption scans. @internal */
|
|
106
130
|
unitId?: string;
|
|
131
|
+
/** @internal */
|
|
107
132
|
namespace?: string;
|
|
133
|
+
/** @internal */
|
|
108
134
|
send(message: ServerToWorkerMessage): void;
|
|
135
|
+
/** @internal */
|
|
109
136
|
kill(signal?: NodeJS.Signals | number): void;
|
|
110
|
-
/** Stops the physical runtime and rejects if disappearance cannot be confirmed. */
|
|
137
|
+
/** Stops the physical runtime and rejects if disappearance cannot be confirmed. @internal */
|
|
111
138
|
killAndWait?(signal?: NodeJS.Signals | number): Promise<void>;
|
|
139
|
+
/** @internal */
|
|
112
140
|
detach(reason: string): void;
|
|
141
|
+
/** @internal */
|
|
113
142
|
onceExit(listener: () => void): void;
|
|
114
143
|
}
|
|
115
144
|
|
|
@@ -119,9 +148,6 @@ interface RunnerWorkerStartOptions {
|
|
|
119
148
|
startupDeadlineMs: number;
|
|
120
149
|
resolvedExtensionEntriesJson?: string;
|
|
121
150
|
snapshotToken?: string;
|
|
122
|
-
onEnvelope(envelope: IpcEnvelope): void;
|
|
123
|
-
onInvalidMessage(): void;
|
|
124
|
-
onRuntimeError(error: unknown): void;
|
|
125
151
|
onRuntimeExit(): void;
|
|
126
152
|
}
|
|
127
153
|
|
|
@@ -129,52 +155,75 @@ type ServerToWorkerMessageBody<T = ServerToWorkerMessage> = T extends ServerToWo
|
|
|
129
155
|
? Pick<T, "type" | "payload">
|
|
130
156
|
: never;
|
|
131
157
|
|
|
158
|
+
/** @public */
|
|
132
159
|
export interface WorkerSupervisor {
|
|
133
|
-
/** Returns undefined when accepted into the capacity queue. */
|
|
160
|
+
/** Returns undefined when accepted into the capacity queue. @internal */
|
|
134
161
|
spawnWorker(instanceId: string): Promise<WorkerHandle | undefined>;
|
|
162
|
+
/** @internal */
|
|
135
163
|
stopWorker(instanceId: string, reason: string): Promise<void>;
|
|
164
|
+
/** @internal */
|
|
136
165
|
abortTurn(instanceId: string, reason: string): void;
|
|
166
|
+
/** @internal */
|
|
137
167
|
deliverInputs(instanceId: string, inputs: InputDelivery[]): void;
|
|
168
|
+
/** @internal */
|
|
138
169
|
acceptTurnStart(
|
|
139
170
|
instanceId: string,
|
|
140
171
|
workerId: string,
|
|
141
172
|
startRecordId: string,
|
|
142
173
|
turnRecordId: string,
|
|
143
174
|
): void;
|
|
175
|
+
/** @internal */
|
|
144
176
|
reconcileAcceptedTurnStart(instanceId: string, workerId: string): boolean;
|
|
177
|
+
/** @internal */
|
|
145
178
|
acknowledgeTurnTerminal(
|
|
146
179
|
instanceId: string,
|
|
147
180
|
workerId: string,
|
|
148
181
|
payload: WorkerTurnTerminalRecordedPayload,
|
|
149
182
|
): void;
|
|
183
|
+
/** @internal */
|
|
150
184
|
questionResponse(
|
|
151
185
|
instanceId: string,
|
|
152
186
|
workerId: string,
|
|
153
187
|
payload: WorkerQuestionResponsePayload,
|
|
154
188
|
): void;
|
|
189
|
+
/** @internal */
|
|
155
190
|
credentialUpdateResult(
|
|
156
191
|
instanceId: string,
|
|
157
192
|
workerId: string,
|
|
158
193
|
payload: WorkerCredentialUpdateResultPayload,
|
|
159
194
|
): void;
|
|
195
|
+
/** @internal */
|
|
160
196
|
integrationToolResult(
|
|
161
197
|
instanceId: string,
|
|
162
198
|
workerId: string,
|
|
163
199
|
payload: WorkerIntegrationToolResultPayload,
|
|
164
200
|
): void;
|
|
201
|
+
/** @public */
|
|
165
202
|
getWorker(instanceId: string): WorkerHandle | undefined;
|
|
203
|
+
/** @internal */
|
|
166
204
|
isAdoptionPending(instanceId: string): boolean;
|
|
205
|
+
/** @internal */
|
|
167
206
|
adoptRegisteredWorkers(): Promise<void>;
|
|
207
|
+
/** @internal */
|
|
168
208
|
detachAll(reason: string): Promise<void>;
|
|
209
|
+
/** @public */
|
|
169
210
|
shutdownAll(reason: string): Promise<void>;
|
|
170
211
|
}
|
|
171
212
|
|
|
213
|
+
function isLiveWorkerLease(lease: WorkerLease | null, workerId: string): lease is WorkerLease {
|
|
214
|
+
return (
|
|
215
|
+
lease?.workerId === workerId &&
|
|
216
|
+
!["draining", "cleanup", "failed", "exited"].includes(lease.state)
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
172
220
|
function generateWorkerId(): string {
|
|
173
221
|
const ts = Date.now().toString(36);
|
|
174
222
|
const rand = Math.random().toString(36).slice(2, 10);
|
|
175
223
|
return `wkr_${ts}${rand}`;
|
|
176
224
|
}
|
|
177
225
|
|
|
226
|
+
/** @internal */
|
|
178
227
|
export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
179
228
|
const workers = new Map<string, WorkerHandle>();
|
|
180
229
|
const startupTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
@@ -274,20 +323,12 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
274
323
|
}
|
|
275
324
|
|
|
276
325
|
function clearStartupTimer(instanceId: string): void {
|
|
277
|
-
|
|
278
|
-
if (timer === undefined) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
clearTimeout(timer);
|
|
326
|
+
clearTimeout(startupTimers.get(instanceId));
|
|
282
327
|
startupTimers.delete(instanceId);
|
|
283
328
|
}
|
|
284
329
|
|
|
285
330
|
function clearIdleStopTimer(instanceId: string): void {
|
|
286
|
-
|
|
287
|
-
if (timer === undefined) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
clearTimeout(timer);
|
|
331
|
+
clearTimeout(idleStopTimers.get(instanceId));
|
|
291
332
|
idleStopTimers.delete(instanceId);
|
|
292
333
|
}
|
|
293
334
|
|
|
@@ -547,41 +588,30 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
547
588
|
clearStartupTimer(instanceId);
|
|
548
589
|
clearIdleStopTimer(instanceId);
|
|
549
590
|
const leaseBeforeError = safeGetLeaseByInstance(instanceId);
|
|
550
|
-
const shouldNormalizeProcessError =
|
|
551
|
-
leaseBeforeError?.workerId === workerId &&
|
|
552
|
-
leaseBeforeError.state !== "draining" &&
|
|
553
|
-
leaseBeforeError.state !== "cleanup" &&
|
|
554
|
-
leaseBeforeError.state !== "failed" &&
|
|
555
|
-
leaseBeforeError.state !== "exited";
|
|
556
591
|
const shouldStopWorker = error instanceof WorkerOutboundBufferOverflowError;
|
|
557
|
-
if (
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
? "startup_timeout"
|
|
592
|
+
if (isLiveWorkerLease(leaseBeforeError, workerId)) {
|
|
593
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
594
|
+
const startupTimedOut = startupTimedOutWorkers.delete(
|
|
595
|
+
timedOutWorkerKey(instanceId, workerId),
|
|
596
|
+
);
|
|
597
|
+
const failedBeforeBootstrap =
|
|
598
|
+
leaseBeforeError.state === "spawning" || leaseBeforeError.state === "bootstrapping";
|
|
599
|
+
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
600
|
+
errorCode: shouldStopWorker
|
|
601
|
+
? "worker_websocket_outbound_buffer_overflow"
|
|
602
|
+
: startupTimedOut
|
|
603
|
+
? "startup_timeout"
|
|
604
|
+
: failedBeforeBootstrap
|
|
605
|
+
? "spawn_error"
|
|
606
|
+
: "process_error",
|
|
607
|
+
message: startupTimedOut
|
|
608
|
+
? `Worker startup timed out after ${startupTimeoutMs}ms: ${errorMessage}`
|
|
575
609
|
: failedBeforeBootstrap
|
|
576
|
-
?
|
|
577
|
-
:
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
? `Worker process error before bootstrap completed: ${errorMessage}`
|
|
582
|
-
: `Worker process error: ${errorMessage}`,
|
|
583
|
-
errorClass: "infrastructure",
|
|
584
|
-
});
|
|
610
|
+
? `Worker process error before bootstrap completed: ${errorMessage}`
|
|
611
|
+
: `Worker process error: ${errorMessage}`,
|
|
612
|
+
errorClass: "infrastructure",
|
|
613
|
+
});
|
|
614
|
+
}
|
|
585
615
|
if (shouldStopWorker) {
|
|
586
616
|
const handle = workers.get(instanceId);
|
|
587
617
|
if (handle?.workerId === workerId) {
|
|
@@ -607,13 +637,7 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
607
637
|
pendingCleanup.delete(instanceId);
|
|
608
638
|
const leaseBeforeExit = safeGetLeaseByInstance(instanceId);
|
|
609
639
|
const startupTimedOut = startupTimedOutWorkers.delete(timedOutWorkerKey(instanceId, workerId));
|
|
610
|
-
|
|
611
|
-
leaseBeforeExit?.workerId === workerId &&
|
|
612
|
-
leaseBeforeExit.state !== "draining" &&
|
|
613
|
-
leaseBeforeExit.state !== "cleanup" &&
|
|
614
|
-
leaseBeforeExit.state !== "failed" &&
|
|
615
|
-
leaseBeforeExit.state !== "exited";
|
|
616
|
-
if (shouldNormalizeUnexpectedExit) {
|
|
640
|
+
if (isLiveWorkerLease(leaseBeforeExit, workerId)) {
|
|
617
641
|
const diagnostics = formatWorkerExitDiagnostics(info);
|
|
618
642
|
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
619
643
|
errorCode: startupTimedOut
|
|
@@ -675,39 +699,7 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
675
699
|
};
|
|
676
700
|
}
|
|
677
701
|
|
|
678
|
-
function
|
|
679
|
-
instanceId: string;
|
|
680
|
-
workerId: string;
|
|
681
|
-
tokenHash: string;
|
|
682
|
-
onEnvelope(envelope: IpcEnvelope): void;
|
|
683
|
-
onInvalidMessage(): void;
|
|
684
|
-
onRuntimeError(error: unknown): void;
|
|
685
|
-
}): { unregister(reason: string): void } {
|
|
686
|
-
if (!runnerRuntime) {
|
|
687
|
-
throw new Error("runner runtime is not configured");
|
|
688
|
-
}
|
|
689
|
-
runnerRuntime.webSocketIpc.registerWorker({
|
|
690
|
-
instanceId: input.instanceId,
|
|
691
|
-
workerId: input.workerId,
|
|
692
|
-
callbacks: {
|
|
693
|
-
onEnvelope: input.onEnvelope,
|
|
694
|
-
onInvalidOutput: input.onInvalidMessage,
|
|
695
|
-
onRuntimeError: input.onRuntimeError,
|
|
696
|
-
},
|
|
697
|
-
tokenHash: input.tokenHash,
|
|
698
|
-
});
|
|
699
|
-
return {
|
|
700
|
-
unregister(reason: string) {
|
|
701
|
-
runnerRuntime.webSocketIpc.unregister(input.instanceId, input.workerId, reason);
|
|
702
|
-
},
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
function resolveRunnerStartSelection(instanceId: string) {
|
|
707
|
-
const process = deps.processes.getById(instanceId);
|
|
708
|
-
if (!process) {
|
|
709
|
-
throw new Error(`Cannot start worker for missing process ${instanceId}`);
|
|
710
|
-
}
|
|
702
|
+
function resolveRunnerStartSelection(process: ProcessInstance) {
|
|
711
703
|
if (deps.config.workers.runner === "local") {
|
|
712
704
|
return {
|
|
713
705
|
selection: {
|
|
@@ -722,7 +714,7 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
722
714
|
buildRuntimeProfileSelectionInput({
|
|
723
715
|
config: deps.config,
|
|
724
716
|
processId: process.processId,
|
|
725
|
-
componentKeys: deps.projects.listByInstance(
|
|
717
|
+
componentKeys: deps.projects.listByInstance(process.id).map((project) => project.key),
|
|
726
718
|
}),
|
|
727
719
|
);
|
|
728
720
|
if (!selection.ok) {
|
|
@@ -746,9 +738,9 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
746
738
|
options: RunnerWorkerStartOptions,
|
|
747
739
|
connect: { token: string; unregister(reason: string): void },
|
|
748
740
|
): Promise<WorkerHandle> {
|
|
749
|
-
const { selection, profile } = resolveRunnerStartSelection(options.instanceId);
|
|
750
741
|
const process = deps.processes.getById(options.instanceId);
|
|
751
742
|
if (!process) throw new Error(`Cannot start worker for missing process ${options.instanceId}`);
|
|
743
|
+
const { selection, profile } = resolveRunnerStartSelection(process);
|
|
752
744
|
const docker = deps.processGraphs.get(process.processId)?.runtime?.docker === true;
|
|
753
745
|
const resourceLimits =
|
|
754
746
|
profile?.resources?.limits ??
|
|
@@ -822,9 +814,7 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
822
814
|
});
|
|
823
815
|
}
|
|
824
816
|
|
|
825
|
-
const modelPolicyFingerprintForProcess = (
|
|
826
|
-
process: import("@leitwerk-dev/domain").ProcessInstance,
|
|
827
|
-
) => {
|
|
817
|
+
const modelPolicyFingerprintForProcess = (process: ProcessInstance) => {
|
|
828
818
|
if (process.currentExecution?.kind !== "worker_start") {
|
|
829
819
|
throw new Error(`Process '${process.id}' has no current worker start to fingerprint`);
|
|
830
820
|
}
|
|
@@ -894,44 +884,44 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
894
884
|
let unregisterStartRegistration: (() => void) | undefined;
|
|
895
885
|
const earlyEnvelopes: IpcEnvelope[] = [];
|
|
896
886
|
try {
|
|
897
|
-
|
|
898
|
-
instanceId,
|
|
899
|
-
workerId,
|
|
900
|
-
startupDeadlineMs,
|
|
901
|
-
resolvedExtensionEntriesJson: deps.resolvedExtensionEntriesJson,
|
|
902
|
-
onEnvelope: (envelope) => {
|
|
903
|
-
if (workers.has(instanceId)) {
|
|
904
|
-
routeEnvelope(envelope, instanceId);
|
|
905
|
-
} else {
|
|
906
|
-
earlyEnvelopes.push(envelope);
|
|
907
|
-
}
|
|
908
|
-
},
|
|
909
|
-
onInvalidMessage: () => {
|
|
910
|
-
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
911
|
-
errorCode: "invalid_worker_websocket_ipc",
|
|
912
|
-
message: "Worker emitted invalid WebSocket IPC message",
|
|
913
|
-
errorClass: "infrastructure",
|
|
914
|
-
});
|
|
915
|
-
},
|
|
916
|
-
onRuntimeError: (error) => handleProcessError(instanceId, workerId, error),
|
|
917
|
-
snapshotToken,
|
|
918
|
-
onRuntimeExit: () => {
|
|
919
|
-
processExitedBeforeRegistration = !workers.has(instanceId);
|
|
920
|
-
},
|
|
921
|
-
};
|
|
922
|
-
const connect = registerRunnerWebSocket({
|
|
887
|
+
runnerRuntime.webSocketIpc.registerWorker({
|
|
923
888
|
instanceId,
|
|
924
889
|
workerId,
|
|
925
890
|
tokenHash: connectTokenHash,
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
891
|
+
callbacks: {
|
|
892
|
+
onEnvelope: (envelope) => {
|
|
893
|
+
if (workers.has(instanceId)) {
|
|
894
|
+
routeEnvelope(envelope, instanceId);
|
|
895
|
+
} else {
|
|
896
|
+
earlyEnvelopes.push(envelope);
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
onInvalidOutput: () => {
|
|
900
|
+
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
901
|
+
errorCode: "invalid_worker_websocket_ipc",
|
|
902
|
+
message: "Worker emitted invalid WebSocket IPC message",
|
|
903
|
+
errorClass: "infrastructure",
|
|
904
|
+
});
|
|
905
|
+
},
|
|
906
|
+
onRuntimeError: (error) => handleProcessError(instanceId, workerId, error),
|
|
907
|
+
},
|
|
934
908
|
});
|
|
909
|
+
const unregister = (reason: string) =>
|
|
910
|
+
runnerRuntime.webSocketIpc.unregister(instanceId, workerId, reason);
|
|
911
|
+
unregisterStartRegistration = () => unregister("start_failed");
|
|
912
|
+
handle = await startRunnerWorker(
|
|
913
|
+
{
|
|
914
|
+
instanceId,
|
|
915
|
+
workerId,
|
|
916
|
+
startupDeadlineMs,
|
|
917
|
+
resolvedExtensionEntriesJson: deps.resolvedExtensionEntriesJson,
|
|
918
|
+
snapshotToken,
|
|
919
|
+
onRuntimeExit: () => {
|
|
920
|
+
processExitedBeforeRegistration = !workers.has(instanceId);
|
|
921
|
+
},
|
|
922
|
+
},
|
|
923
|
+
{ token: connectToken, unregister },
|
|
924
|
+
);
|
|
935
925
|
unregisterStartRegistration = undefined;
|
|
936
926
|
} catch (error) {
|
|
937
927
|
unregisterStartRegistration?.();
|
|
@@ -1035,14 +1025,10 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
1035
1025
|
if (!handle) {
|
|
1036
1026
|
return;
|
|
1037
1027
|
}
|
|
1038
|
-
|
|
1028
|
+
sendToCurrentWorker(instanceId, handle.workerId, {
|
|
1039
1029
|
type: "worker.abort_turn",
|
|
1040
|
-
instanceId,
|
|
1041
|
-
workerId: handle.workerId,
|
|
1042
|
-
messageId: randomUUID(),
|
|
1043
1030
|
payload: { reason },
|
|
1044
1031
|
});
|
|
1045
|
-
handle.send(msg);
|
|
1046
1032
|
},
|
|
1047
1033
|
|
|
1048
1034
|
deliverInputs(instanceId: string, inputs: InputDelivery[]): void {
|
|
@@ -17,30 +17,49 @@ export interface WorkerTurnIpcRecorderDeps
|
|
|
17
17
|
eventIngestor: ReturnType<typeof createWorkerEventIngestor>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/** @internal */
|
|
20
21
|
export interface WorkerTurnIpcRecorderCallbacks {
|
|
22
|
+
/** @internal */
|
|
21
23
|
onTurnOutcomeRecorded?: (
|
|
22
24
|
instanceId: string,
|
|
23
25
|
turnId: string,
|
|
24
26
|
outcome: string,
|
|
25
27
|
params: Record<string, unknown>,
|
|
26
28
|
) => void;
|
|
29
|
+
/** @internal */
|
|
27
30
|
onTurnTerminalRecorded?: (instanceId: string, workerId: string, turnRecordId: string) => void;
|
|
31
|
+
/** @internal */
|
|
28
32
|
onTurnFailedRecorded?: (input: {
|
|
33
|
+
/** @internal */
|
|
29
34
|
instanceId: string;
|
|
35
|
+
/** @internal */
|
|
30
36
|
workerId: string;
|
|
37
|
+
/** @internal */
|
|
31
38
|
turnRecordId: string;
|
|
39
|
+
/** @internal */
|
|
32
40
|
turnId: string;
|
|
41
|
+
/** @internal */
|
|
33
42
|
turnType: WorkerTurnFailedPayload["turnType"];
|
|
43
|
+
/** @internal */
|
|
34
44
|
errorSummary: string;
|
|
45
|
+
/** @internal */
|
|
35
46
|
errorClass?: WorkerTurnFailedPayload["errorClass"];
|
|
47
|
+
/** @internal */
|
|
36
48
|
failureCode?: WorkerTurnFailedPayload["failureCode"];
|
|
37
49
|
}) => void;
|
|
50
|
+
/** @internal */
|
|
38
51
|
onTurnTerminalRecordingFailed?: (input: {
|
|
52
|
+
/** @internal */
|
|
39
53
|
instanceId: string;
|
|
54
|
+
/** @internal */
|
|
40
55
|
workerId: string;
|
|
56
|
+
/** @internal */
|
|
41
57
|
turnRecordId: string;
|
|
58
|
+
/** @internal */
|
|
42
59
|
terminalType: "outcome" | "failure";
|
|
60
|
+
/** @internal */
|
|
43
61
|
code: string;
|
|
62
|
+
/** @internal */
|
|
44
63
|
message: string;
|
|
45
64
|
}) => void;
|
|
46
65
|
}
|
|
@@ -7,8 +7,11 @@ import type {
|
|
|
7
7
|
WorkerUnitRef,
|
|
8
8
|
} from "@leitwerk-dev/worker-runners/types";
|
|
9
9
|
|
|
10
|
+
/** @internal */
|
|
10
11
|
export interface WorkerUnitCleanupLogger {
|
|
12
|
+
/** @internal */
|
|
11
13
|
info?(bindings: Record<string, unknown>, message: string): void;
|
|
14
|
+
/** @internal */
|
|
12
15
|
warn?(bindings: Record<string, unknown>, message: string): void;
|
|
13
16
|
}
|
|
14
17
|
|
|
@@ -6,18 +6,37 @@ import {
|
|
|
6
6
|
} from "@leitwerk-dev/worker-protocol";
|
|
7
7
|
import { verifyWorkerConnectToken } from "./worker-connect-token.js";
|
|
8
8
|
|
|
9
|
+
/** @internal */
|
|
9
10
|
export interface WorkerWebSocketLike {
|
|
11
|
+
/** @internal */
|
|
10
12
|
readyState: number;
|
|
13
|
+
/** @internal */
|
|
11
14
|
send(data: string): void;
|
|
15
|
+
/** @internal */
|
|
12
16
|
close(code?: number, reason?: string): void;
|
|
17
|
+
/** @internal */
|
|
13
18
|
on(event: "message", handler: (raw: Buffer | string | ArrayBuffer | Buffer[]) => void): void;
|
|
14
|
-
|
|
19
|
+
/** @internal */
|
|
20
|
+
on(
|
|
21
|
+
event: "close",
|
|
22
|
+
handler: (event?: {
|
|
23
|
+
/** @internal */
|
|
24
|
+
code?: number;
|
|
25
|
+
/** @internal */
|
|
26
|
+
reason?: string;
|
|
27
|
+
}) => void,
|
|
28
|
+
): void;
|
|
29
|
+
/** @internal */
|
|
15
30
|
on(event: "error", handler: (error: unknown) => void): void;
|
|
16
31
|
}
|
|
17
32
|
|
|
33
|
+
/** @internal */
|
|
18
34
|
export interface WorkerWebSocketCallbacks {
|
|
35
|
+
/** @internal */
|
|
19
36
|
onEnvelope(envelope: IpcEnvelope): void;
|
|
37
|
+
/** @internal */
|
|
20
38
|
onInvalidOutput(): void;
|
|
39
|
+
/** @internal */
|
|
21
40
|
onRuntimeError(error: unknown): void;
|
|
22
41
|
}
|
|
23
42
|
|
|
@@ -66,8 +85,14 @@ function authenticate(entry: PendingWorkerConnection, text: string): boolean {
|
|
|
66
85
|
return verifyWorkerConnectToken(text, entry.tokenHash);
|
|
67
86
|
}
|
|
68
87
|
|
|
88
|
+
/** @internal */
|
|
69
89
|
export function createWorkerWebSocketIpcManager(
|
|
70
|
-
options: {
|
|
90
|
+
options: {
|
|
91
|
+
/** @internal */
|
|
92
|
+
authTimeoutMs?: number;
|
|
93
|
+
/** @internal */
|
|
94
|
+
maxBufferedMessages?: number;
|
|
95
|
+
} = {},
|
|
71
96
|
) {
|
|
72
97
|
const pending = new Map<string, PendingWorkerConnection>();
|
|
73
98
|
const authTimeoutMs = options.authTimeoutMs ?? 5_000;
|
|
@@ -151,30 +176,40 @@ export function createWorkerWebSocketIpcManager(
|
|
|
151
176
|
}
|
|
152
177
|
|
|
153
178
|
return {
|
|
179
|
+
/** @internal */
|
|
154
180
|
setUnknownWorkerConnectionsRetryable(enabled: boolean): void {
|
|
155
181
|
retryUnknownWorkerConnections = enabled;
|
|
156
182
|
},
|
|
183
|
+
/** @internal */
|
|
157
184
|
verifyWorkerToken({
|
|
158
185
|
instanceId,
|
|
159
186
|
workerId,
|
|
160
187
|
token,
|
|
161
188
|
}: {
|
|
189
|
+
/** @internal */
|
|
162
190
|
instanceId: string;
|
|
191
|
+
/** @internal */
|
|
163
192
|
workerId: string;
|
|
193
|
+
/** @internal */
|
|
164
194
|
token: string;
|
|
165
195
|
}) {
|
|
166
196
|
const entry = pending.get(connectionKey(instanceId, workerId));
|
|
167
197
|
return entry ? verifyWorkerConnectToken(token, entry.tokenHash) : false;
|
|
168
198
|
},
|
|
199
|
+
/** @internal */
|
|
169
200
|
registerWorker({
|
|
170
201
|
instanceId,
|
|
171
202
|
workerId,
|
|
172
203
|
callbacks,
|
|
173
204
|
tokenHash,
|
|
174
205
|
}: {
|
|
206
|
+
/** @internal */
|
|
175
207
|
instanceId: string;
|
|
208
|
+
/** @internal */
|
|
176
209
|
workerId: string;
|
|
210
|
+
/** @internal */
|
|
177
211
|
callbacks: WorkerWebSocketCallbacks;
|
|
212
|
+
/** @internal */
|
|
178
213
|
tokenHash: string;
|
|
179
214
|
}) {
|
|
180
215
|
pending.set(connectionKey(instanceId, workerId), {
|
|
@@ -188,15 +223,31 @@ export function createWorkerWebSocketIpcManager(
|
|
|
188
223
|
outbound: [],
|
|
189
224
|
});
|
|
190
225
|
},
|
|
226
|
+
/** @internal */
|
|
191
227
|
bindSocket({
|
|
192
228
|
instanceId,
|
|
193
229
|
workerId,
|
|
194
230
|
socket,
|
|
195
231
|
}: {
|
|
232
|
+
/** @internal */
|
|
196
233
|
instanceId: string;
|
|
234
|
+
/** @internal */
|
|
197
235
|
workerId: string;
|
|
236
|
+
/** @internal */
|
|
198
237
|
socket: WorkerWebSocketLike;
|
|
199
|
-
}):
|
|
238
|
+
}):
|
|
239
|
+
| {
|
|
240
|
+
/** @internal */
|
|
241
|
+
ok: true;
|
|
242
|
+
}
|
|
243
|
+
| {
|
|
244
|
+
/** @internal */
|
|
245
|
+
ok: false;
|
|
246
|
+
/** @internal */
|
|
247
|
+
error: string;
|
|
248
|
+
/** @internal */
|
|
249
|
+
code: number;
|
|
250
|
+
} {
|
|
200
251
|
const key = connectionKey(instanceId, workerId);
|
|
201
252
|
const entry = pending.get(key);
|
|
202
253
|
if (!entry) {
|
|
@@ -267,6 +318,7 @@ export function createWorkerWebSocketIpcManager(
|
|
|
267
318
|
|
|
268
319
|
return { ok: true };
|
|
269
320
|
},
|
|
321
|
+
/** @internal */
|
|
270
322
|
send(instanceId: string, workerId: string, message: ServerToWorkerMessage) {
|
|
271
323
|
const entry = pending.get(connectionKey(instanceId, workerId));
|
|
272
324
|
if (!entry) {
|
|
@@ -286,6 +338,7 @@ export function createWorkerWebSocketIpcManager(
|
|
|
286
338
|
}
|
|
287
339
|
queueOutbound(entry, data);
|
|
288
340
|
},
|
|
341
|
+
/** @internal */
|
|
289
342
|
unregister(instanceId: string, workerId: string, reason: string) {
|
|
290
343
|
const key = connectionKey(instanceId, workerId);
|
|
291
344
|
const entry = pending.get(key);
|
|
@@ -306,4 +359,5 @@ export function createWorkerWebSocketIpcManager(
|
|
|
306
359
|
};
|
|
307
360
|
}
|
|
308
361
|
|
|
362
|
+
/** @internal */
|
|
309
363
|
export type WorkerWebSocketIpcManager = ReturnType<typeof createWorkerWebSocketIpcManager>;
|