@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
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
buildFutureExecutionSummaries,
|
|
16
16
|
buildLauncherModelConfigSchema,
|
|
17
17
|
buildPrimaryPathSnapshotFromTree,
|
|
18
|
-
buildProcessActionRegistry,
|
|
19
18
|
buildProcessFlowViewForProcess,
|
|
20
19
|
buildProcessLaunchConfigurationView,
|
|
21
20
|
buildProcessRunDetailsView,
|
|
@@ -88,7 +87,6 @@ import {
|
|
|
88
87
|
resolveCurrentExecutionTurnRecordId,
|
|
89
88
|
resolveDockerRegistryCredentials,
|
|
90
89
|
resolveProcessStorageSize,
|
|
91
|
-
resolveTurnIntegrationToolNames,
|
|
92
90
|
resolveWorkerPiAgentDir,
|
|
93
91
|
routeConfig,
|
|
94
92
|
sendActionRequestNormalizationError,
|
|
@@ -102,7 +100,7 @@ import {
|
|
|
102
100
|
validateConfig,
|
|
103
101
|
validatePhysicalSourcePath,
|
|
104
102
|
verifyOpaqueToken
|
|
105
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-ZSKM25SD.js";
|
|
106
104
|
|
|
107
105
|
// src/app.ts
|
|
108
106
|
import path9 from "node:path";
|
|
@@ -4667,6 +4665,7 @@ function createFutureLaunchLifecycle(deps, options = {}) {
|
|
|
4667
4665
|
return result.result;
|
|
4668
4666
|
}
|
|
4669
4667
|
return {
|
|
4668
|
+
/** @internal */
|
|
4670
4669
|
async prepareLaunch(launcherId, request, opts) {
|
|
4671
4670
|
return prepareLaunchInternal({
|
|
4672
4671
|
launcherId,
|
|
@@ -4674,6 +4673,7 @@ function createFutureLaunchLifecycle(deps, options = {}) {
|
|
|
4674
4673
|
...opts?.resolvedLauncher ? { resolvedLauncher: opts.resolvedLauncher } : {}
|
|
4675
4674
|
});
|
|
4676
4675
|
},
|
|
4676
|
+
/** @internal */
|
|
4677
4677
|
async commitPreparedLaunch(prepared, opts) {
|
|
4678
4678
|
if (prepared.schedule.mode !== "now")
|
|
4679
4679
|
return persistPreparedLaunch({ ...prepared, actor: opts?.actor ?? SYSTEM_ACTOR2 });
|
|
@@ -4691,6 +4691,7 @@ function createFutureLaunchLifecycle(deps, options = {}) {
|
|
|
4691
4691
|
operation: "created"
|
|
4692
4692
|
};
|
|
4693
4693
|
},
|
|
4694
|
+
/** @internal */
|
|
4694
4695
|
async applyGeneratedFutureLaunchTitleIfUnchanged(input) {
|
|
4695
4696
|
return runFutureExecutionExclusive(
|
|
4696
4697
|
deps.processOperations,
|
|
@@ -4732,6 +4733,7 @@ function createFutureLaunchLifecycle(deps, options = {}) {
|
|
|
4732
4733
|
}
|
|
4733
4734
|
);
|
|
4734
4735
|
},
|
|
4736
|
+
/** @internal */
|
|
4735
4737
|
async reviseScheduledLaunch(futureExecutionId, request, opts) {
|
|
4736
4738
|
const operationTime = now2();
|
|
4737
4739
|
return runFutureExecutionExclusive(deps.processOperations, futureExecutionId, async () => {
|
|
@@ -5057,9 +5059,13 @@ function createFutureExecutionLifecycle(deps, _options = {}) {
|
|
|
5057
5059
|
return items;
|
|
5058
5060
|
}
|
|
5059
5061
|
return {
|
|
5062
|
+
/** @internal */
|
|
5060
5063
|
prepareLaunch: launchLifecycle.prepareLaunch,
|
|
5064
|
+
/** @internal */
|
|
5061
5065
|
commitPreparedLaunch: launchLifecycle.commitPreparedLaunch,
|
|
5066
|
+
/** @internal */
|
|
5062
5067
|
reviseScheduledLaunch: launchLifecycle.reviseScheduledLaunch,
|
|
5068
|
+
/** @internal */
|
|
5063
5069
|
async scheduleAction(process2, actionId, request, opts) {
|
|
5064
5070
|
const operationTime = nowFn();
|
|
5065
5071
|
const scheduleValidation = validateScheduleRequestInput2(request.schedule, ["now", "once"]);
|
|
@@ -5102,6 +5108,7 @@ function createFutureExecutionLifecycle(deps, _options = {}) {
|
|
|
5102
5108
|
...opts?.actor ? { actor: opts.actor } : {}
|
|
5103
5109
|
});
|
|
5104
5110
|
},
|
|
5111
|
+
/** @internal */
|
|
5105
5112
|
async reviseScheduledAction(futureExecutionId, request, opts) {
|
|
5106
5113
|
const operationTime = nowFn();
|
|
5107
5114
|
return runFutureExecutionExclusive(
|
|
@@ -5176,6 +5183,7 @@ function createFutureExecutionLifecycle(deps, _options = {}) {
|
|
|
5176
5183
|
}
|
|
5177
5184
|
);
|
|
5178
5185
|
},
|
|
5186
|
+
/** @internal */
|
|
5179
5187
|
async cancel(futureExecutionId) {
|
|
5180
5188
|
return runFutureExecutionExclusive(deps.processOperations, futureExecutionId, async () => {
|
|
5181
5189
|
const execution = deps.futureExecutions.getById(futureExecutionId);
|
|
@@ -5191,7 +5199,9 @@ function createFutureExecutionLifecycle(deps, _options = {}) {
|
|
|
5191
5199
|
};
|
|
5192
5200
|
});
|
|
5193
5201
|
},
|
|
5202
|
+
/** @internal */
|
|
5194
5203
|
applyGeneratedFutureLaunchTitleIfUnchanged: launchLifecycle.applyGeneratedFutureLaunchTitleIfUnchanged,
|
|
5204
|
+
/** @internal */
|
|
5195
5205
|
async reconcileModelAvailability(input) {
|
|
5196
5206
|
const asOf = input.asOf ?? nowFn().toISOString();
|
|
5197
5207
|
if (!deps.processGraphs || !deps.processActionRegistry) {
|
|
@@ -5213,18 +5223,32 @@ function createFutureExecutionLifecycle(deps, _options = {}) {
|
|
|
5213
5223
|
processTitles: deps.processTitles,
|
|
5214
5224
|
asOf
|
|
5215
5225
|
});
|
|
5216
|
-
return result.reaction.ok ? {
|
|
5226
|
+
return result.reaction.ok ? {
|
|
5227
|
+
/** @internal */
|
|
5228
|
+
kind: "reconciled",
|
|
5229
|
+
/** @internal */
|
|
5230
|
+
changed: result.changed,
|
|
5231
|
+
/** @internal */
|
|
5232
|
+
asOf
|
|
5233
|
+
} : {
|
|
5234
|
+
/** @internal */
|
|
5217
5235
|
kind: "committed_with_reaction_error",
|
|
5236
|
+
/** @internal */
|
|
5218
5237
|
changed: result.changed,
|
|
5238
|
+
/** @internal */
|
|
5219
5239
|
asOf,
|
|
5240
|
+
/** @internal */
|
|
5220
5241
|
error: result.reaction.message,
|
|
5242
|
+
/** @internal */
|
|
5221
5243
|
code: result.reaction.code
|
|
5222
5244
|
};
|
|
5223
5245
|
},
|
|
5246
|
+
/** @internal */
|
|
5224
5247
|
async reconcileMissedScheduleOccurrences(asOf) {
|
|
5225
5248
|
await executor.reconcileMissedCronRowsOnStartup(asOf);
|
|
5226
5249
|
return { kind: "occurrences_advanced", asOf };
|
|
5227
5250
|
},
|
|
5251
|
+
/** @internal */
|
|
5228
5252
|
async runDueWork(asOf) {
|
|
5229
5253
|
const blockedItems = await executeDueRows(
|
|
5230
5254
|
deps.futureExecutions.listBlockedCronDue(asOf),
|
|
@@ -5249,16 +5273,17 @@ function startFutureExecutionScheduler(lifecycle, options = {}) {
|
|
|
5249
5273
|
const pollIntervalMs = options.pollIntervalMs ?? 1e3;
|
|
5250
5274
|
const nowFn = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
5251
5275
|
let timer = null;
|
|
5252
|
-
let tickInProgress
|
|
5276
|
+
let tickInProgress;
|
|
5253
5277
|
async function tick() {
|
|
5254
5278
|
if (tickInProgress) {
|
|
5255
|
-
return;
|
|
5279
|
+
return tickInProgress;
|
|
5256
5280
|
}
|
|
5257
|
-
tickInProgress =
|
|
5281
|
+
tickInProgress = lifecycle.runDueWork(nowFn().toISOString()).then(() => {
|
|
5282
|
+
});
|
|
5258
5283
|
try {
|
|
5259
|
-
await
|
|
5284
|
+
await tickInProgress;
|
|
5260
5285
|
} finally {
|
|
5261
|
-
tickInProgress =
|
|
5286
|
+
tickInProgress = void 0;
|
|
5262
5287
|
}
|
|
5263
5288
|
}
|
|
5264
5289
|
return {
|
|
@@ -5272,21 +5297,302 @@ function startFutureExecutionScheduler(lifecycle, options = {}) {
|
|
|
5272
5297
|
void tick();
|
|
5273
5298
|
}, pollIntervalMs);
|
|
5274
5299
|
},
|
|
5275
|
-
stop() {
|
|
5300
|
+
async stop() {
|
|
5276
5301
|
if (timer) {
|
|
5277
5302
|
clearInterval(timer);
|
|
5278
5303
|
timer = null;
|
|
5279
5304
|
}
|
|
5305
|
+
await tickInProgress;
|
|
5280
5306
|
}
|
|
5281
5307
|
};
|
|
5282
5308
|
}
|
|
5283
5309
|
|
|
5284
5310
|
// src/integration-tool-registry.ts
|
|
5285
5311
|
import {
|
|
5312
|
+
bindExternalWrites
|
|
5313
|
+
} from "@leitwerk-dev/external-writes/internal";
|
|
5314
|
+
import {
|
|
5315
|
+
objectArg,
|
|
5286
5316
|
parseJsonData,
|
|
5287
5317
|
RESERVED_INTEGRATION_TOOL_NAMES
|
|
5288
5318
|
} from "@leitwerk-dev/process-sdk";
|
|
5289
5319
|
import * as v2 from "valibot";
|
|
5320
|
+
|
|
5321
|
+
// src/process-action-registry.ts
|
|
5322
|
+
import {
|
|
5323
|
+
createServerProcessBuilder,
|
|
5324
|
+
getExternalActionArmingId as getExternalActionArmingId2,
|
|
5325
|
+
getExternalSourceTransitionId as getExternalSourceTransitionId2,
|
|
5326
|
+
isAutomaticTurnDefinition,
|
|
5327
|
+
isExternalTurnDefinition as isExternalTurnDefinition2,
|
|
5328
|
+
isHumanTurnDefinition as isHumanTurnDefinition2,
|
|
5329
|
+
resolveHumanTurnView,
|
|
5330
|
+
toProcessGraphView
|
|
5331
|
+
} from "@leitwerk-dev/process-sdk";
|
|
5332
|
+
function resolveTurnIntegrationToolNames(registry, process2, turnId) {
|
|
5333
|
+
const turn = registry.getTurnDefinition(process2.processId, turnId);
|
|
5334
|
+
if (turn?.kind !== "llm" && turn?.kind !== "automatic") return [];
|
|
5335
|
+
const dynamic = turn.kind === "llm" && turn.resolveIntegrationTools ? (() => {
|
|
5336
|
+
const context = registry.resolveContextData(process2.processId, process2);
|
|
5337
|
+
return turn.resolveIntegrationTools?.(context.params, context.state) ?? [];
|
|
5338
|
+
})() : [];
|
|
5339
|
+
return [.../* @__PURE__ */ new Set([...turn.integrationTools ?? [], ...dynamic])];
|
|
5340
|
+
}
|
|
5341
|
+
function resolveProcessContextData(processDef, process2) {
|
|
5342
|
+
if (!processDef) {
|
|
5343
|
+
return { params: {}, state: {} };
|
|
5344
|
+
}
|
|
5345
|
+
const params2 = process2.paramsJson ? processDef.paramsCodec.parse(JSON.parse(process2.paramsJson)) : processDef.paramsCodec.parse(void 0);
|
|
5346
|
+
const state = process2.stateJson ? processDef.stateCodec.parse(JSON.parse(process2.stateJson)) : processDef.initialState(params2);
|
|
5347
|
+
return { params: params2, state };
|
|
5348
|
+
}
|
|
5349
|
+
function resolveCurrentTurnForProcess(processDef, process2) {
|
|
5350
|
+
if (!processDef || !process2.selectedTurnId) {
|
|
5351
|
+
return null;
|
|
5352
|
+
}
|
|
5353
|
+
const selectedTurn = processDef.turns.get(process2.selectedTurnId)?.definition;
|
|
5354
|
+
if (!selectedTurn) {
|
|
5355
|
+
return null;
|
|
5356
|
+
}
|
|
5357
|
+
return { turnId: process2.selectedTurnId, turnDef: selectedTurn };
|
|
5358
|
+
}
|
|
5359
|
+
function listExternalTriggers(turnId, turnDef, ctx) {
|
|
5360
|
+
if (isHumanTurnDefinition2(turnDef)) {
|
|
5361
|
+
const view = resolveHumanTurnView({ turnId, turn: turnDef });
|
|
5362
|
+
return [
|
|
5363
|
+
...view.externalTriggers.map((trigger) => ({
|
|
5364
|
+
id: trigger.id,
|
|
5365
|
+
kind: "human_action_external_trigger",
|
|
5366
|
+
label: trigger.label,
|
|
5367
|
+
description: trigger.description
|
|
5368
|
+
})),
|
|
5369
|
+
...view.externalActions.filter((action) => {
|
|
5370
|
+
const definition = turnDef.externalActions?.[action.externalActionId];
|
|
5371
|
+
return !definition?.when || definition.when(ctx);
|
|
5372
|
+
}).map((action) => ({
|
|
5373
|
+
id: action.id,
|
|
5374
|
+
externalActionId: action.externalActionId,
|
|
5375
|
+
kind: action.sourceKind,
|
|
5376
|
+
sourceKind: action.sourceKind,
|
|
5377
|
+
label: action.label,
|
|
5378
|
+
description: action.description
|
|
5379
|
+
}))
|
|
5380
|
+
];
|
|
5381
|
+
}
|
|
5382
|
+
if (isExternalTurnDefinition2(turnDef)) {
|
|
5383
|
+
return turnDef.transitions.map((transition, index) => ({
|
|
5384
|
+
id: getExternalSourceTransitionId2({ turnId, source: transition.source, index }),
|
|
5385
|
+
kind: transition.source.kind,
|
|
5386
|
+
label: transition.source.label ?? null,
|
|
5387
|
+
description: transition.source.description ?? null
|
|
5388
|
+
}));
|
|
5389
|
+
}
|
|
5390
|
+
if (isAutomaticTurnDefinition(turnDef) && ctx.process.lifecycleStatus === "waiting") {
|
|
5391
|
+
return Object.entries(turnDef.externalActions ?? {}).filter(([, action]) => !action.when || action.when(ctx)).map(([externalActionId, action]) => ({
|
|
5392
|
+
id: getExternalActionArmingId2({ turnId, externalActionId }),
|
|
5393
|
+
externalActionId,
|
|
5394
|
+
kind: action.source.kind,
|
|
5395
|
+
sourceKind: action.source.kind,
|
|
5396
|
+
label: action.label ?? action.source.label ?? null,
|
|
5397
|
+
description: action.description ?? action.source.description ?? null
|
|
5398
|
+
}));
|
|
5399
|
+
}
|
|
5400
|
+
return [];
|
|
5401
|
+
}
|
|
5402
|
+
function resolveCurrentVisibleActionForProcess(processDef, process2, actionId) {
|
|
5403
|
+
const currentTurn = resolveCurrentTurnForProcess(processDef, process2);
|
|
5404
|
+
if (!currentTurn || !isHumanTurnDefinition2(currentTurn.turnDef)) {
|
|
5405
|
+
return null;
|
|
5406
|
+
}
|
|
5407
|
+
const view = resolveHumanTurnView({ turnId: currentTurn.turnId, turn: currentTurn.turnDef });
|
|
5408
|
+
return view.actions.find((candidate) => candidate.actionId === actionId) ?? null;
|
|
5409
|
+
}
|
|
5410
|
+
function isTurnScopedActionForProcess(processDef, actionId) {
|
|
5411
|
+
if (!processDef) {
|
|
5412
|
+
return false;
|
|
5413
|
+
}
|
|
5414
|
+
for (const [turnId, { definition: turnDef }] of processDef.turns) {
|
|
5415
|
+
if (isHumanTurnDefinition2(turnDef)) {
|
|
5416
|
+
const view = resolveHumanTurnView({ turnId, turn: turnDef });
|
|
5417
|
+
if (view.actions.some((action) => action.actionId === actionId) || view.externalTriggers.some((trigger) => trigger.actionId === actionId)) {
|
|
5418
|
+
return true;
|
|
5419
|
+
}
|
|
5420
|
+
}
|
|
5421
|
+
}
|
|
5422
|
+
return false;
|
|
5423
|
+
}
|
|
5424
|
+
function buildSelectedTurnSummaryForProcess(processDef, process2, projects = []) {
|
|
5425
|
+
const currentTurn = resolveCurrentTurnForProcess(processDef, process2);
|
|
5426
|
+
if (!currentTurn) {
|
|
5427
|
+
return null;
|
|
5428
|
+
}
|
|
5429
|
+
const { params: params2, state } = resolveProcessContextData(processDef, process2);
|
|
5430
|
+
return {
|
|
5431
|
+
turnId: currentTurn.turnId,
|
|
5432
|
+
kind: currentTurn.turnDef.kind,
|
|
5433
|
+
description: currentTurn.turnDef.description,
|
|
5434
|
+
commentary: isHumanTurnDefinition2(currentTurn.turnDef) ? currentTurn.turnDef.commentary ?? null : null,
|
|
5435
|
+
externalTriggers: listExternalTriggers(currentTurn.turnId, currentTurn.turnDef, {
|
|
5436
|
+
process: process2,
|
|
5437
|
+
projects,
|
|
5438
|
+
params: params2,
|
|
5439
|
+
state
|
|
5440
|
+
})
|
|
5441
|
+
};
|
|
5442
|
+
}
|
|
5443
|
+
function resolveActionTarget(definition, processDef, process2) {
|
|
5444
|
+
if (!definition) return null;
|
|
5445
|
+
const metadata = definition;
|
|
5446
|
+
const preview = "preview" in metadata ? metadata.preview : metadata;
|
|
5447
|
+
if (preview.kind === "fixed_turn") {
|
|
5448
|
+
return { definition, candidateSelectedTurnId: preview.turnId, lifecycleStatus: null };
|
|
5449
|
+
}
|
|
5450
|
+
if (preview.kind === "terminal") {
|
|
5451
|
+
return { definition, candidateSelectedTurnId: null, lifecycleStatus: preview.lifecycleStatus };
|
|
5452
|
+
}
|
|
5453
|
+
if (!processDef || !process2.selectedTurnId) return null;
|
|
5454
|
+
const transitions = toProcessGraphView(processDef).turns.get(process2.selectedTurnId)?.transitions ?? [];
|
|
5455
|
+
const matchingTransitions = transitions.filter(
|
|
5456
|
+
(transition2) => transition2.trigger === preview.trigger
|
|
5457
|
+
);
|
|
5458
|
+
if (matchingTransitions.length !== 1) return null;
|
|
5459
|
+
const [transition] = matchingTransitions;
|
|
5460
|
+
return {
|
|
5461
|
+
definition,
|
|
5462
|
+
candidateSelectedTurnId: transition.nextTurnId ?? null,
|
|
5463
|
+
lifecycleStatus: transition.lifecycleStatus ?? null
|
|
5464
|
+
};
|
|
5465
|
+
}
|
|
5466
|
+
function resolveActionPreviewForProcess(processDef, process2, action, actionId) {
|
|
5467
|
+
const visibleAction = resolveCurrentVisibleActionForProcess(processDef, process2, actionId);
|
|
5468
|
+
const definition = visibleAction?.preview ?? visibleAction?.scheduling?.preview ?? action?.preview ?? action?.scheduling?.preview ?? null;
|
|
5469
|
+
return resolveActionTarget(definition, processDef, process2);
|
|
5470
|
+
}
|
|
5471
|
+
function resolveTurnScopedActionForProcess(processDef, process2, actionId, source) {
|
|
5472
|
+
const currentTurn = resolveCurrentTurnForProcess(processDef, process2);
|
|
5473
|
+
if (!currentTurn || !isHumanTurnDefinition2(currentTurn.turnDef)) return null;
|
|
5474
|
+
const view = resolveHumanTurnView({ turnId: currentTurn.turnId, turn: currentTurn.turnDef });
|
|
5475
|
+
const action = view.actions.find((candidate) => candidate.actionId === actionId);
|
|
5476
|
+
if (!action) return null;
|
|
5477
|
+
const common = {
|
|
5478
|
+
turnId: currentTurn.turnId,
|
|
5479
|
+
semanticEntryRefKey: currentTurn.turnDef.reviewSemanticRef ?? null,
|
|
5480
|
+
acceptanceState: action.acceptanceState
|
|
5481
|
+
};
|
|
5482
|
+
if (source !== "external") {
|
|
5483
|
+
return { ...common, kind: "ui_human_action", turnType: "human" };
|
|
5484
|
+
}
|
|
5485
|
+
const externalTrigger = view.externalTriggers.find((trigger) => trigger.actionId === actionId);
|
|
5486
|
+
if (!externalTrigger) return null;
|
|
5487
|
+
return {
|
|
5488
|
+
...common,
|
|
5489
|
+
kind: "external_human_trigger",
|
|
5490
|
+
turnType: "external",
|
|
5491
|
+
externalTrigger: {
|
|
5492
|
+
id: externalTrigger.id,
|
|
5493
|
+
actionId: externalTrigger.actionId,
|
|
5494
|
+
label: externalTrigger.label,
|
|
5495
|
+
description: externalTrigger.description
|
|
5496
|
+
}
|
|
5497
|
+
};
|
|
5498
|
+
}
|
|
5499
|
+
function buildProcessActionRegistry(catalog) {
|
|
5500
|
+
const serverDefs = /* @__PURE__ */ new Map();
|
|
5501
|
+
const processDefs = /* @__PURE__ */ new Map();
|
|
5502
|
+
for (const [processId, processDef] of catalog.processes) {
|
|
5503
|
+
processDefs.set(processId, processDef);
|
|
5504
|
+
if (!processDef.server) {
|
|
5505
|
+
continue;
|
|
5506
|
+
}
|
|
5507
|
+
const builder = createServerProcessBuilder();
|
|
5508
|
+
processDef.server(builder);
|
|
5509
|
+
serverDefs.set(processId, builder.getDefinition());
|
|
5510
|
+
}
|
|
5511
|
+
return {
|
|
5512
|
+
getAction(processId, actionId) {
|
|
5513
|
+
const def = serverDefs.get(processId);
|
|
5514
|
+
if (!def) return void 0;
|
|
5515
|
+
return def.actions.get(actionId);
|
|
5516
|
+
},
|
|
5517
|
+
isTurnScopedAction(processId, actionId) {
|
|
5518
|
+
return isTurnScopedActionForProcess(processDefs.get(processId), actionId);
|
|
5519
|
+
},
|
|
5520
|
+
listVisibleActions(processId, ctx) {
|
|
5521
|
+
const def = serverDefs.get(processId);
|
|
5522
|
+
const processDef = processDefs.get(processId);
|
|
5523
|
+
const currentTurn = resolveCurrentTurnForProcess(processDef, ctx.process);
|
|
5524
|
+
if (!def || !currentTurn || !isHumanTurnDefinition2(currentTurn.turnDef)) {
|
|
5525
|
+
return [];
|
|
5526
|
+
}
|
|
5527
|
+
const view = resolveHumanTurnView({
|
|
5528
|
+
turnId: currentTurn.turnId,
|
|
5529
|
+
turn: currentTurn.turnDef
|
|
5530
|
+
});
|
|
5531
|
+
const visible = [];
|
|
5532
|
+
for (const turnAction of view.actions) {
|
|
5533
|
+
const action = def.actions.get(turnAction.actionId);
|
|
5534
|
+
if (!action) {
|
|
5535
|
+
continue;
|
|
5536
|
+
}
|
|
5537
|
+
visible.push({
|
|
5538
|
+
id: action.id,
|
|
5539
|
+
label: turnAction.label ?? action.label,
|
|
5540
|
+
description: turnAction.description ?? null,
|
|
5541
|
+
form: action.form,
|
|
5542
|
+
preview: resolveActionPreviewForProcess(processDef, ctx.process, action, action.id)
|
|
5543
|
+
});
|
|
5544
|
+
}
|
|
5545
|
+
return visible;
|
|
5546
|
+
},
|
|
5547
|
+
getSelectedTurnSummary(processId, process2, projects) {
|
|
5548
|
+
return buildSelectedTurnSummaryForProcess(processDefs.get(processId), process2, projects);
|
|
5549
|
+
},
|
|
5550
|
+
getServerDefinition(processId) {
|
|
5551
|
+
return serverDefs.get(processId);
|
|
5552
|
+
},
|
|
5553
|
+
getTurnDefinition(processId, turnId) {
|
|
5554
|
+
return processDefs.get(processId)?.turns.get(turnId)?.definition;
|
|
5555
|
+
},
|
|
5556
|
+
getProcessGraph(processId) {
|
|
5557
|
+
return processDefs.get(processId);
|
|
5558
|
+
},
|
|
5559
|
+
getProcessDisplayName(processId) {
|
|
5560
|
+
return processDefs.get(processId)?.displayName;
|
|
5561
|
+
},
|
|
5562
|
+
resolveContextData(processId, process2) {
|
|
5563
|
+
return resolveProcessContextData(processDefs.get(processId), process2);
|
|
5564
|
+
},
|
|
5565
|
+
resolveTurnScopedAction(processId, process2, actionId, source) {
|
|
5566
|
+
return resolveTurnScopedActionForProcess(
|
|
5567
|
+
processDefs.get(processId),
|
|
5568
|
+
process2,
|
|
5569
|
+
actionId,
|
|
5570
|
+
source
|
|
5571
|
+
);
|
|
5572
|
+
},
|
|
5573
|
+
resolveActionPreview(processId, process2, actionId) {
|
|
5574
|
+
return resolveActionPreviewForProcess(
|
|
5575
|
+
processDefs.get(processId),
|
|
5576
|
+
process2,
|
|
5577
|
+
serverDefs.get(processId)?.actions.get(actionId),
|
|
5578
|
+
actionId
|
|
5579
|
+
);
|
|
5580
|
+
},
|
|
5581
|
+
resolveActionScheduling(processId, process2, actionId) {
|
|
5582
|
+
const action = serverDefs.get(processId)?.actions.get(actionId);
|
|
5583
|
+
if (action?.executionMode === "side_effect") return null;
|
|
5584
|
+
const processDef = processDefs.get(processId);
|
|
5585
|
+
const visibleAction = resolveCurrentVisibleActionForProcess(processDef, process2, actionId);
|
|
5586
|
+
return resolveActionTarget(
|
|
5587
|
+
visibleAction?.scheduling ?? action?.scheduling ?? null,
|
|
5588
|
+
processDef,
|
|
5589
|
+
process2
|
|
5590
|
+
);
|
|
5591
|
+
}
|
|
5592
|
+
};
|
|
5593
|
+
}
|
|
5594
|
+
|
|
5595
|
+
// src/integration-tool-registry.ts
|
|
5290
5596
|
var TOOL_NAME = /^[a-z][a-z0-9_]{0,63}$/;
|
|
5291
5597
|
var RESERVED_TOOL_NAMES = new Set(RESERVED_INTEGRATION_TOOL_NAMES);
|
|
5292
5598
|
function isTicketCreationTool(definition) {
|
|
@@ -5421,12 +5727,7 @@ function resolveJsonPointer(value, pointer) {
|
|
|
5421
5727
|
return current[key];
|
|
5422
5728
|
}, value);
|
|
5423
5729
|
}
|
|
5424
|
-
|
|
5425
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
5426
|
-
throw new Error("Integration tool arguments must be an object");
|
|
5427
|
-
}
|
|
5428
|
-
return value;
|
|
5429
|
-
}
|
|
5730
|
+
var parseToolArgs = (value) => objectArg(value, "Integration tool arguments must be an object");
|
|
5430
5731
|
function persistedTicketActor(value) {
|
|
5431
5732
|
return parseSchema(persistedActorSchema, value, "Ticket creation actor is invalid");
|
|
5432
5733
|
}
|
|
@@ -5465,6 +5766,10 @@ function withTicketDestinationParameter(parameters, destinations) {
|
|
|
5465
5766
|
};
|
|
5466
5767
|
}
|
|
5467
5768
|
var IntegrationToolRegistry = class {
|
|
5769
|
+
constructor(writes) {
|
|
5770
|
+
this.writes = writes;
|
|
5771
|
+
}
|
|
5772
|
+
writes;
|
|
5468
5773
|
tools = /* @__PURE__ */ new Map();
|
|
5469
5774
|
executions = /* @__PURE__ */ new Map();
|
|
5470
5775
|
register(definition) {
|
|
@@ -5552,7 +5857,11 @@ var IntegrationToolRegistry = class {
|
|
|
5552
5857
|
throw new Error("Integration tool execution cancelled");
|
|
5553
5858
|
}
|
|
5554
5859
|
return definition.execute(
|
|
5555
|
-
{
|
|
5860
|
+
{
|
|
5861
|
+
...ctx,
|
|
5862
|
+
signal: controller.signal,
|
|
5863
|
+
externalWrites: bindExternalWrites(this.writes, ctx.process.id)
|
|
5864
|
+
},
|
|
5556
5865
|
definition.parse?.(args) ?? parseToolArgs(args)
|
|
5557
5866
|
);
|
|
5558
5867
|
}).finally(() => this.executions.delete(ctx.idempotencyKey));
|
|
@@ -8850,7 +9159,7 @@ import {
|
|
|
8850
9159
|
areSemanticEntryRefsEqual as sameEntryRef
|
|
8851
9160
|
} from "@leitwerk-dev/domain";
|
|
8852
9161
|
import {
|
|
8853
|
-
isAutomaticTurnDefinition as
|
|
9162
|
+
isAutomaticTurnDefinition as isAutomaticTurnDefinition3,
|
|
8854
9163
|
isLlmTurnDefinition as isLlmTurnDefinition4,
|
|
8855
9164
|
parseStructuralProcessState
|
|
8856
9165
|
} from "@leitwerk-dev/process-sdk";
|
|
@@ -8964,7 +9273,7 @@ import {
|
|
|
8964
9273
|
trimString
|
|
8965
9274
|
} from "@leitwerk-dev/domain";
|
|
8966
9275
|
import {
|
|
8967
|
-
isAutomaticTurnDefinition,
|
|
9276
|
+
isAutomaticTurnDefinition as isAutomaticTurnDefinition2,
|
|
8968
9277
|
isLlmTurnDefinition as isLlmTurnDefinition3
|
|
8969
9278
|
} from "@leitwerk-dev/process-sdk";
|
|
8970
9279
|
import * as v3 from "valibot";
|
|
@@ -9056,7 +9365,7 @@ function resolveOutcomeValidationContract(turnDefinition, turnId, outcome) {
|
|
|
9056
9365
|
`'${turnId}' is not registered in the loaded turn catalog`
|
|
9057
9366
|
);
|
|
9058
9367
|
}
|
|
9059
|
-
if (!isLlmTurnDefinition3(turnDefinition) && !
|
|
9368
|
+
if (!isLlmTurnDefinition3(turnDefinition) && !isAutomaticTurnDefinition2(turnDefinition)) {
|
|
9060
9369
|
return validationFailure2(
|
|
9061
9370
|
"turn_outcome_unsupported",
|
|
9062
9371
|
`'${turnId}' does not support turn outcomes`
|
|
@@ -9410,7 +9719,7 @@ function validatePublishedProductOutcome(input) {
|
|
|
9410
9719
|
}
|
|
9411
9720
|
function resolveOutcomePublication(input) {
|
|
9412
9721
|
const definition = input.processGraphs.get(input.processId)?.turns.get(input.turnId)?.definition;
|
|
9413
|
-
if (!definition || !isLlmTurnDefinition4(definition) && !
|
|
9722
|
+
if (!definition || !isLlmTurnDefinition4(definition) && !isAutomaticTurnDefinition3(definition)) {
|
|
9414
9723
|
return { productName: input.turnPublishedProduct, markdownParameterName: null };
|
|
9415
9724
|
}
|
|
9416
9725
|
const outcome = definition.outcomes?.[input.outcome];
|
|
@@ -11860,7 +12169,9 @@ function createProcessQuestionService(input) {
|
|
|
11860
12169
|
});
|
|
11861
12170
|
};
|
|
11862
12171
|
return {
|
|
12172
|
+
/** @internal */
|
|
11863
12173
|
listOpen: (instanceId) => input.repos.questionRequests.listOpen(instanceId),
|
|
12174
|
+
/** @internal */
|
|
11864
12175
|
async handleWorkerRequest(instanceId, workerLeaseId, workerId, payload) {
|
|
11865
12176
|
const result = await input.processOperations.runExclusive(
|
|
11866
12177
|
instanceId,
|
|
@@ -11916,6 +12227,7 @@ function createProcessQuestionService(input) {
|
|
|
11916
12227
|
instanceId
|
|
11917
12228
|
);
|
|
11918
12229
|
},
|
|
12230
|
+
/** @internal */
|
|
11919
12231
|
async submitAnswers(instanceId, requestId, draftInput, actor) {
|
|
11920
12232
|
try {
|
|
11921
12233
|
const result = await input.processOperations.runExclusive(
|
|
@@ -11955,7 +12267,10 @@ function createProcessQuestionService(input) {
|
|
|
11955
12267
|
eventType: "question_answered",
|
|
11956
12268
|
data: { requestId: request.id, actorId: actor.id }
|
|
11957
12269
|
});
|
|
11958
|
-
return {
|
|
12270
|
+
return {
|
|
12271
|
+
ok: true,
|
|
12272
|
+
request: answered
|
|
12273
|
+
};
|
|
11959
12274
|
})
|
|
11960
12275
|
);
|
|
11961
12276
|
if (!result.ok) return result;
|
|
@@ -11983,12 +12298,12 @@ import { parseDurationMs as parseDurationMs2 } from "@leitwerk-dev/watcher-utils
|
|
|
11983
12298
|
import { preflightHostDocker } from "@leitwerk-dev/worker-runners/local";
|
|
11984
12299
|
function resolveKubernetesDockerConfig(config) {
|
|
11985
12300
|
const docker = config.kubernetes?.docker;
|
|
11986
|
-
if (!docker?.runtime_class_name?.trim() || typeof docker.host_users !== "boolean" || !docker.process_storage_class_name?.trim()) {
|
|
12301
|
+
if (!docker?.runtime_class_name?.trim() || (docker.gvisor ? docker.host_users !== void 0 : typeof docker.host_users !== "boolean") || !docker.process_storage_class_name?.trim()) {
|
|
11987
12302
|
return void 0;
|
|
11988
12303
|
}
|
|
11989
12304
|
return {
|
|
11990
12305
|
runtimeClassName: docker.runtime_class_name,
|
|
11991
|
-
hostUsers: docker.host_users,
|
|
12306
|
+
...docker.gvisor ? { gvisor: true } : { hostUsers: docker.host_users },
|
|
11992
12307
|
processStorageClassName: docker.process_storage_class_name,
|
|
11993
12308
|
...docker.network ? { network: docker.network } : {}
|
|
11994
12309
|
};
|
|
@@ -12952,7 +13267,9 @@ var MIME_BY_EXTENSION = {
|
|
|
12952
13267
|
webp: "image/webp"
|
|
12953
13268
|
};
|
|
12954
13269
|
var ResultImageStore = class {
|
|
13270
|
+
/** @internal */
|
|
12955
13271
|
rootDir;
|
|
13272
|
+
/** @internal */
|
|
12956
13273
|
constructor(input) {
|
|
12957
13274
|
this.rootDir = path3.resolve(input.rootDir);
|
|
12958
13275
|
}
|
|
@@ -12961,6 +13278,7 @@ var ResultImageStore = class {
|
|
|
12961
13278
|
throw new Error("Invalid result image storage id");
|
|
12962
13279
|
return path3.join(this.rootDir, instanceId, turnRecordId);
|
|
12963
13280
|
}
|
|
13281
|
+
/** @internal */
|
|
12964
13282
|
async put(input) {
|
|
12965
13283
|
const dir = this.turnDir(input.instanceId, input.turnRecordId);
|
|
12966
13284
|
await mkdir(dir, { recursive: true });
|
|
@@ -12976,11 +13294,13 @@ var ResultImageStore = class {
|
|
|
12976
13294
|
}
|
|
12977
13295
|
return { imageId, mimeType: input.mimeType, byteSize: input.bytes.length };
|
|
12978
13296
|
}
|
|
13297
|
+
/** @internal */
|
|
12979
13298
|
async deleteProcess(instanceId) {
|
|
12980
13299
|
if (!isResultImageStorageSegment(instanceId))
|
|
12981
13300
|
throw new Error("Invalid result image storage id");
|
|
12982
13301
|
await rm(path3.join(this.rootDir, instanceId), { recursive: true, force: true });
|
|
12983
13302
|
}
|
|
13303
|
+
/** @internal */
|
|
12984
13304
|
async cleanupProcesses(input) {
|
|
12985
13305
|
let entries;
|
|
12986
13306
|
try {
|
|
@@ -12998,6 +13318,7 @@ var ResultImageStore = class {
|
|
|
12998
13318
|
}
|
|
12999
13319
|
return removed;
|
|
13000
13320
|
}
|
|
13321
|
+
/** @internal */
|
|
13001
13322
|
async get(instanceId, turnRecordId, imageId) {
|
|
13002
13323
|
const extension = parseResultImageId(imageId)?.extension;
|
|
13003
13324
|
if (!extension) return null;
|
|
@@ -13014,6 +13335,138 @@ var ResultImageStore = class {
|
|
|
13014
13335
|
}
|
|
13015
13336
|
};
|
|
13016
13337
|
|
|
13338
|
+
// src/server-bootstrap/app-lifecycle.ts
|
|
13339
|
+
async function collectCleanupErrors(operations) {
|
|
13340
|
+
const errors = [];
|
|
13341
|
+
for (const operation of [...operations].reverse()) {
|
|
13342
|
+
try {
|
|
13343
|
+
await operation();
|
|
13344
|
+
} catch (error) {
|
|
13345
|
+
errors.push(error);
|
|
13346
|
+
}
|
|
13347
|
+
}
|
|
13348
|
+
return errors;
|
|
13349
|
+
}
|
|
13350
|
+
function createAppLifecycle(input) {
|
|
13351
|
+
const { app } = input;
|
|
13352
|
+
let closing = false;
|
|
13353
|
+
let closePromise;
|
|
13354
|
+
let startupOperation;
|
|
13355
|
+
let startupPromise;
|
|
13356
|
+
let binding2;
|
|
13357
|
+
let bindOperation;
|
|
13358
|
+
const cleanupErrors = [];
|
|
13359
|
+
function assertOpen() {
|
|
13360
|
+
if (closing) throw new Error("AppContext startup interrupted: context is closed");
|
|
13361
|
+
}
|
|
13362
|
+
function close() {
|
|
13363
|
+
closing = true;
|
|
13364
|
+
backgroundServicesReady = false;
|
|
13365
|
+
closePromise ??= (async () => {
|
|
13366
|
+
await bindOperation?.catch(() => {
|
|
13367
|
+
});
|
|
13368
|
+
await startupOperation?.catch(() => {
|
|
13369
|
+
});
|
|
13370
|
+
await app.close();
|
|
13371
|
+
})();
|
|
13372
|
+
return closePromise;
|
|
13373
|
+
}
|
|
13374
|
+
async function failStartup(error) {
|
|
13375
|
+
try {
|
|
13376
|
+
await close();
|
|
13377
|
+
} catch (cleanupError) {
|
|
13378
|
+
throw new AggregateError([error, cleanupError], "Server startup failed and cleanup failed", {
|
|
13379
|
+
cause: error
|
|
13380
|
+
});
|
|
13381
|
+
}
|
|
13382
|
+
throw error;
|
|
13383
|
+
}
|
|
13384
|
+
async function listen(options = {}) {
|
|
13385
|
+
assertOpen();
|
|
13386
|
+
if (binding2) {
|
|
13387
|
+
for (const key of ["host", "port", "useBoundAddressAsBaseUrl"]) {
|
|
13388
|
+
if (options[key] !== void 0 && options[key] !== binding2[key])
|
|
13389
|
+
throw new Error(`Conflicting listener option: ${key}`);
|
|
13390
|
+
}
|
|
13391
|
+
} else {
|
|
13392
|
+
if (app.server.listening) throw new Error("Cannot adopt a manually bound listener");
|
|
13393
|
+
const requested = {
|
|
13394
|
+
host: options.host ?? input.server.host,
|
|
13395
|
+
port: options.port ?? input.server.port,
|
|
13396
|
+
useBoundAddressAsBaseUrl: options.useBoundAddressAsBaseUrl ?? false
|
|
13397
|
+
};
|
|
13398
|
+
if (requested.useBoundAddressAsBaseUrl && (input.authEnabled || !["127.0.0.1", "::1", "localhost"].includes(requested.host)))
|
|
13399
|
+
throw new Error("Bound base URL requires an unauthenticated loopback listener");
|
|
13400
|
+
binding2 = requested;
|
|
13401
|
+
bindOperation = (async () => {
|
|
13402
|
+
const started = performance.now();
|
|
13403
|
+
const address = await app.listen({ host: requested.host, port: requested.port });
|
|
13404
|
+
app.log.info(
|
|
13405
|
+
{ listenDurationMs: Math.round((performance.now() - started) * 10) / 10 },
|
|
13406
|
+
"Server HTTP listener ready"
|
|
13407
|
+
);
|
|
13408
|
+
const info = app.server.address();
|
|
13409
|
+
if (!info || typeof info === "string") throw new Error("Expected TCP listener address");
|
|
13410
|
+
if (requested.useBoundAddressAsBaseUrl) input.server.base_url = address;
|
|
13411
|
+
return { address, port: info.port };
|
|
13412
|
+
})();
|
|
13413
|
+
}
|
|
13414
|
+
let result;
|
|
13415
|
+
try {
|
|
13416
|
+
if (!bindOperation) throw new Error("Listener was not initialized");
|
|
13417
|
+
result = await bindOperation;
|
|
13418
|
+
} catch (error) {
|
|
13419
|
+
return failStartup(error);
|
|
13420
|
+
}
|
|
13421
|
+
await startServices();
|
|
13422
|
+
assertOpen();
|
|
13423
|
+
return result;
|
|
13424
|
+
}
|
|
13425
|
+
function startServices() {
|
|
13426
|
+
if (closing)
|
|
13427
|
+
return Promise.reject(new Error("AppContext startup interrupted: context is closed"));
|
|
13428
|
+
if (startupPromise) return startupPromise;
|
|
13429
|
+
startupOperation = (async () => {
|
|
13430
|
+
await bindOperation;
|
|
13431
|
+
assertOpen();
|
|
13432
|
+
await input.reconcile(assertOpen);
|
|
13433
|
+
for (const hook of input.startHooks) {
|
|
13434
|
+
assertOpen();
|
|
13435
|
+
await hook();
|
|
13436
|
+
}
|
|
13437
|
+
assertOpen();
|
|
13438
|
+
backgroundServicesReady = true;
|
|
13439
|
+
})();
|
|
13440
|
+
startupPromise = startupOperation.catch(failStartup);
|
|
13441
|
+
return startupPromise;
|
|
13442
|
+
}
|
|
13443
|
+
let backgroundServicesReady = false;
|
|
13444
|
+
let cleanupOperation;
|
|
13445
|
+
function cleanup() {
|
|
13446
|
+
closing = true;
|
|
13447
|
+
backgroundServicesReady = false;
|
|
13448
|
+
cleanupOperation ??= (async () => {
|
|
13449
|
+
await startupOperation?.catch(() => {
|
|
13450
|
+
});
|
|
13451
|
+
cleanupErrors.push(...await collectCleanupErrors(input.preCloseCleanup.splice(0)));
|
|
13452
|
+
})();
|
|
13453
|
+
return cleanupOperation;
|
|
13454
|
+
}
|
|
13455
|
+
app.addHook("preClose", cleanup);
|
|
13456
|
+
async function finishCleanup() {
|
|
13457
|
+
await cleanup();
|
|
13458
|
+
cleanupErrors.push(...await collectCleanupErrors([input.closeDatabase]));
|
|
13459
|
+
if (cleanupErrors.length) throw new AggregateError(cleanupErrors, "AppContext cleanup failed");
|
|
13460
|
+
}
|
|
13461
|
+
return {
|
|
13462
|
+
listen,
|
|
13463
|
+
close,
|
|
13464
|
+
isReady: () => backgroundServicesReady,
|
|
13465
|
+
isClosing: () => closing,
|
|
13466
|
+
finishCleanup
|
|
13467
|
+
};
|
|
13468
|
+
}
|
|
13469
|
+
|
|
13017
13470
|
// src/server-bootstrap/build-host-capabilities.ts
|
|
13018
13471
|
import path4 from "node:path";
|
|
13019
13472
|
import { SYSTEM_ACTOR as SYSTEM_ACTOR6 } from "@leitwerk-dev/domain";
|
|
@@ -15524,6 +15977,7 @@ function createSessionTransferHelperRelays(deps) {
|
|
|
15524
15977
|
return helper;
|
|
15525
15978
|
}
|
|
15526
15979
|
return {
|
|
15980
|
+
/** @internal */
|
|
15527
15981
|
create(input) {
|
|
15528
15982
|
const attempt = deps.repos.sessionTransfers.getActiveByInstance(input.instanceId);
|
|
15529
15983
|
if (!attempt || attempt.state !== "queued" && attempt.state !== "exporting") {
|
|
@@ -15566,16 +16020,19 @@ function createSessionTransferHelperRelays(deps) {
|
|
|
15566
16020
|
fail: runtime.fail
|
|
15567
16021
|
};
|
|
15568
16022
|
},
|
|
16023
|
+
/** @internal */
|
|
15569
16024
|
sweep() {
|
|
15570
16025
|
const currentTime = now2().getTime();
|
|
15571
16026
|
for (const helper of helpers.values()) {
|
|
15572
16027
|
if (helper.expiresAt <= currentTime) helper.fail(new Error("export_helper_expired"));
|
|
15573
16028
|
}
|
|
15574
16029
|
},
|
|
16030
|
+
/** @internal */
|
|
15575
16031
|
stop() {
|
|
15576
16032
|
for (const helper of helpers.values()) helper.fail(new Error("server_stopping"));
|
|
15577
16033
|
helpers.clear();
|
|
15578
16034
|
},
|
|
16035
|
+
/** @internal */
|
|
15579
16036
|
helperSpec(input) {
|
|
15580
16037
|
const helper = active(input.exportId, input.credential);
|
|
15581
16038
|
if (!helper || helper.reported || helper.streamAccepted) return null;
|
|
@@ -15588,6 +16045,7 @@ function createSessionTransferHelperRelays(deps) {
|
|
|
15588
16045
|
limits: { ...deps.limits }
|
|
15589
16046
|
};
|
|
15590
16047
|
},
|
|
16048
|
+
/** @internal */
|
|
15591
16049
|
async reportHelperPreflight(input) {
|
|
15592
16050
|
const helper = active(input.exportId, input.credential);
|
|
15593
16051
|
if (!helper || helper.reported || helper.streamAccepted) return false;
|
|
@@ -15610,6 +16068,7 @@ function createSessionTransferHelperRelays(deps) {
|
|
|
15610
16068
|
return false;
|
|
15611
16069
|
}
|
|
15612
16070
|
},
|
|
16071
|
+
/** @internal */
|
|
15613
16072
|
acceptHelperStream(input) {
|
|
15614
16073
|
const helper = active(input.exportId, input.credential);
|
|
15615
16074
|
if (!helper?.reported || helper.streamAccepted) return false;
|
|
@@ -16457,6 +16916,7 @@ function createIpcHandler(deps, callbacks) {
|
|
|
16457
16916
|
}
|
|
16458
16917
|
);
|
|
16459
16918
|
return {
|
|
16919
|
+
/** @internal */
|
|
16460
16920
|
handleMessage(envelope) {
|
|
16461
16921
|
const decoded = decodeWorkerToServerMessage(envelope);
|
|
16462
16922
|
if (!decoded.ok) {
|
|
@@ -17740,9 +18200,11 @@ function createWorkerWebSocketIpcManager(options = {}) {
|
|
|
17740
18200
|
}
|
|
17741
18201
|
}
|
|
17742
18202
|
return {
|
|
18203
|
+
/** @internal */
|
|
17743
18204
|
setUnknownWorkerConnectionsRetryable(enabled) {
|
|
17744
18205
|
retryUnknownWorkerConnections = enabled;
|
|
17745
18206
|
},
|
|
18207
|
+
/** @internal */
|
|
17746
18208
|
verifyWorkerToken({
|
|
17747
18209
|
instanceId,
|
|
17748
18210
|
workerId,
|
|
@@ -17751,6 +18213,7 @@ function createWorkerWebSocketIpcManager(options = {}) {
|
|
|
17751
18213
|
const entry = pending.get(connectionKey(instanceId, workerId));
|
|
17752
18214
|
return entry ? verifyWorkerConnectToken(token, entry.tokenHash) : false;
|
|
17753
18215
|
},
|
|
18216
|
+
/** @internal */
|
|
17754
18217
|
registerWorker({
|
|
17755
18218
|
instanceId,
|
|
17756
18219
|
workerId,
|
|
@@ -17768,6 +18231,7 @@ function createWorkerWebSocketIpcManager(options = {}) {
|
|
|
17768
18231
|
outbound: []
|
|
17769
18232
|
});
|
|
17770
18233
|
},
|
|
18234
|
+
/** @internal */
|
|
17771
18235
|
bindSocket({
|
|
17772
18236
|
instanceId,
|
|
17773
18237
|
workerId,
|
|
@@ -17838,6 +18302,7 @@ function createWorkerWebSocketIpcManager(options = {}) {
|
|
|
17838
18302
|
});
|
|
17839
18303
|
return { ok: true };
|
|
17840
18304
|
},
|
|
18305
|
+
/** @internal */
|
|
17841
18306
|
send(instanceId, workerId, message) {
|
|
17842
18307
|
const entry = pending.get(connectionKey(instanceId, workerId));
|
|
17843
18308
|
if (!entry) {
|
|
@@ -17857,6 +18322,7 @@ function createWorkerWebSocketIpcManager(options = {}) {
|
|
|
17857
18322
|
}
|
|
17858
18323
|
queueOutbound(entry, data);
|
|
17859
18324
|
},
|
|
18325
|
+
/** @internal */
|
|
17860
18326
|
unregister(instanceId, workerId, reason) {
|
|
17861
18327
|
const key = connectionKey(instanceId, workerId);
|
|
17862
18328
|
const entry = pending.get(key);
|
|
@@ -17877,6 +18343,9 @@ function createWorkerWebSocketIpcManager(options = {}) {
|
|
|
17877
18343
|
}
|
|
17878
18344
|
|
|
17879
18345
|
// src/supervisor/worker-supervisor.ts
|
|
18346
|
+
function isLiveWorkerLease(lease, workerId) {
|
|
18347
|
+
return lease?.workerId === workerId && !["draining", "cleanup", "failed", "exited"].includes(lease.state);
|
|
18348
|
+
}
|
|
17880
18349
|
function generateWorkerId() {
|
|
17881
18350
|
const ts = Date.now().toString(36);
|
|
17882
18351
|
const rand = Math.random().toString(36).slice(2, 10);
|
|
@@ -17955,19 +18424,11 @@ function createWorkerSupervisor(deps) {
|
|
|
17955
18424
|
);
|
|
17956
18425
|
}
|
|
17957
18426
|
function clearStartupTimer(instanceId) {
|
|
17958
|
-
|
|
17959
|
-
if (timer === void 0) {
|
|
17960
|
-
return;
|
|
17961
|
-
}
|
|
17962
|
-
clearTimeout(timer);
|
|
18427
|
+
clearTimeout(startupTimers.get(instanceId));
|
|
17963
18428
|
startupTimers.delete(instanceId);
|
|
17964
18429
|
}
|
|
17965
18430
|
function clearIdleStopTimer(instanceId) {
|
|
17966
|
-
|
|
17967
|
-
if (timer === void 0) {
|
|
17968
|
-
return;
|
|
17969
|
-
}
|
|
17970
|
-
clearTimeout(timer);
|
|
18431
|
+
clearTimeout(idleStopTimers.get(instanceId));
|
|
17971
18432
|
idleStopTimers.delete(instanceId);
|
|
17972
18433
|
}
|
|
17973
18434
|
function selectedTurnForProcess(instanceId) {
|
|
@@ -18168,25 +18629,19 @@ function createWorkerSupervisor(deps) {
|
|
|
18168
18629
|
clearStartupTimer(instanceId);
|
|
18169
18630
|
clearIdleStopTimer(instanceId);
|
|
18170
18631
|
const leaseBeforeError = safeGetLeaseByInstance(instanceId);
|
|
18171
|
-
const shouldNormalizeProcessError = leaseBeforeError?.workerId === workerId && leaseBeforeError.state !== "draining" && leaseBeforeError.state !== "cleanup" && leaseBeforeError.state !== "failed" && leaseBeforeError.state !== "exited";
|
|
18172
18632
|
const shouldStopWorker = error instanceof WorkerOutboundBufferOverflowError;
|
|
18173
|
-
if (
|
|
18174
|
-
|
|
18175
|
-
|
|
18176
|
-
|
|
18177
|
-
|
|
18178
|
-
|
|
18179
|
-
|
|
18180
|
-
|
|
18633
|
+
if (isLiveWorkerLease(leaseBeforeError, workerId)) {
|
|
18634
|
+
const errorMessage3 = error instanceof Error ? error.message : String(error);
|
|
18635
|
+
const startupTimedOut = startupTimedOutWorkers.delete(
|
|
18636
|
+
timedOutWorkerKey(instanceId, workerId)
|
|
18637
|
+
);
|
|
18638
|
+
const failedBeforeBootstrap = leaseBeforeError.state === "spawning" || leaseBeforeError.state === "bootstrapping";
|
|
18639
|
+
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
18640
|
+
errorCode: shouldStopWorker ? "worker_websocket_outbound_buffer_overflow" : startupTimedOut ? "startup_timeout" : failedBeforeBootstrap ? "spawn_error" : "process_error",
|
|
18641
|
+
message: startupTimedOut ? `Worker startup timed out after ${startupTimeoutMs}ms: ${errorMessage3}` : failedBeforeBootstrap ? `Worker process error before bootstrap completed: ${errorMessage3}` : `Worker process error: ${errorMessage3}`,
|
|
18642
|
+
errorClass: "infrastructure"
|
|
18643
|
+
});
|
|
18181
18644
|
}
|
|
18182
|
-
const errorMessage3 = error instanceof Error ? error.message : String(error);
|
|
18183
|
-
const startupTimedOut = startupTimedOutWorkers.delete(timedOutWorkerKey(instanceId, workerId));
|
|
18184
|
-
const failedBeforeBootstrap = leaseBeforeError.state === "spawning" || leaseBeforeError.state === "bootstrapping";
|
|
18185
|
-
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
18186
|
-
errorCode: shouldStopWorker ? "worker_websocket_outbound_buffer_overflow" : startupTimedOut ? "startup_timeout" : failedBeforeBootstrap ? "spawn_error" : "process_error",
|
|
18187
|
-
message: startupTimedOut ? `Worker startup timed out after ${startupTimeoutMs}ms: ${errorMessage3}` : failedBeforeBootstrap ? `Worker process error before bootstrap completed: ${errorMessage3}` : `Worker process error: ${errorMessage3}`,
|
|
18188
|
-
errorClass: "infrastructure"
|
|
18189
|
-
});
|
|
18190
18645
|
if (shouldStopWorker) {
|
|
18191
18646
|
const handle = workers.get(instanceId);
|
|
18192
18647
|
if (handle?.workerId === workerId) {
|
|
@@ -18210,8 +18665,7 @@ function createWorkerSupervisor(deps) {
|
|
|
18210
18665
|
pendingCleanup.delete(instanceId);
|
|
18211
18666
|
const leaseBeforeExit = safeGetLeaseByInstance(instanceId);
|
|
18212
18667
|
const startupTimedOut = startupTimedOutWorkers.delete(timedOutWorkerKey(instanceId, workerId));
|
|
18213
|
-
|
|
18214
|
-
if (shouldNormalizeUnexpectedExit) {
|
|
18668
|
+
if (isLiveWorkerLease(leaseBeforeExit, workerId)) {
|
|
18215
18669
|
const diagnostics = formatWorkerExitDiagnostics(info);
|
|
18216
18670
|
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
18217
18671
|
errorCode: startupTimedOut ? "startup_timeout" : info?.oomKilled ? "process_oom_killed" : "process_exited",
|
|
@@ -18257,31 +18711,7 @@ function createWorkerSupervisor(deps) {
|
|
|
18257
18711
|
}
|
|
18258
18712
|
};
|
|
18259
18713
|
}
|
|
18260
|
-
function
|
|
18261
|
-
if (!runnerRuntime) {
|
|
18262
|
-
throw new Error("runner runtime is not configured");
|
|
18263
|
-
}
|
|
18264
|
-
runnerRuntime.webSocketIpc.registerWorker({
|
|
18265
|
-
instanceId: input.instanceId,
|
|
18266
|
-
workerId: input.workerId,
|
|
18267
|
-
callbacks: {
|
|
18268
|
-
onEnvelope: input.onEnvelope,
|
|
18269
|
-
onInvalidOutput: input.onInvalidMessage,
|
|
18270
|
-
onRuntimeError: input.onRuntimeError
|
|
18271
|
-
},
|
|
18272
|
-
tokenHash: input.tokenHash
|
|
18273
|
-
});
|
|
18274
|
-
return {
|
|
18275
|
-
unregister(reason) {
|
|
18276
|
-
runnerRuntime.webSocketIpc.unregister(input.instanceId, input.workerId, reason);
|
|
18277
|
-
}
|
|
18278
|
-
};
|
|
18279
|
-
}
|
|
18280
|
-
function resolveRunnerStartSelection(instanceId) {
|
|
18281
|
-
const process2 = deps.processes.getById(instanceId);
|
|
18282
|
-
if (!process2) {
|
|
18283
|
-
throw new Error(`Cannot start worker for missing process ${instanceId}`);
|
|
18284
|
-
}
|
|
18714
|
+
function resolveRunnerStartSelection(process2) {
|
|
18285
18715
|
if (deps.config.workers.runner === "local") {
|
|
18286
18716
|
return {
|
|
18287
18717
|
selection: {
|
|
@@ -18296,7 +18726,7 @@ function createWorkerSupervisor(deps) {
|
|
|
18296
18726
|
buildRuntimeProfileSelectionInput({
|
|
18297
18727
|
config: deps.config,
|
|
18298
18728
|
processId: process2.processId,
|
|
18299
|
-
componentKeys: deps.projects.listByInstance(
|
|
18729
|
+
componentKeys: deps.projects.listByInstance(process2.id).map((project) => project.key)
|
|
18300
18730
|
})
|
|
18301
18731
|
);
|
|
18302
18732
|
if (!selection.ok) {
|
|
@@ -18315,9 +18745,9 @@ function createWorkerSupervisor(deps) {
|
|
|
18315
18745
|
return deps.config.server.base_url;
|
|
18316
18746
|
}
|
|
18317
18747
|
async function startRunnerWorker(options, connect) {
|
|
18318
|
-
const { selection, profile } = resolveRunnerStartSelection(options.instanceId);
|
|
18319
18748
|
const process2 = deps.processes.getById(options.instanceId);
|
|
18320
18749
|
if (!process2) throw new Error(`Cannot start worker for missing process ${options.instanceId}`);
|
|
18750
|
+
const { selection, profile } = resolveRunnerStartSelection(process2);
|
|
18321
18751
|
const docker = deps.processGraphs.get(process2.processId)?.runtime?.docker === true;
|
|
18322
18752
|
const resourceLimits = profile?.resources?.limits ?? (profile?.resources ? { cpu: profile.resources.cpu, memory: profile.resources.memory } : void 0);
|
|
18323
18753
|
const observer = createStartupObserver(
|
|
@@ -18449,44 +18879,43 @@ function createWorkerSupervisor(deps) {
|
|
|
18449
18879
|
let unregisterStartRegistration;
|
|
18450
18880
|
const earlyEnvelopes = [];
|
|
18451
18881
|
try {
|
|
18452
|
-
|
|
18453
|
-
instanceId,
|
|
18454
|
-
workerId,
|
|
18455
|
-
startupDeadlineMs,
|
|
18456
|
-
resolvedExtensionEntriesJson: deps.resolvedExtensionEntriesJson,
|
|
18457
|
-
onEnvelope: (envelope) => {
|
|
18458
|
-
if (workers.has(instanceId)) {
|
|
18459
|
-
routeEnvelope(envelope, instanceId);
|
|
18460
|
-
} else {
|
|
18461
|
-
earlyEnvelopes.push(envelope);
|
|
18462
|
-
}
|
|
18463
|
-
},
|
|
18464
|
-
onInvalidMessage: () => {
|
|
18465
|
-
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
18466
|
-
errorCode: "invalid_worker_websocket_ipc",
|
|
18467
|
-
message: "Worker emitted invalid WebSocket IPC message",
|
|
18468
|
-
errorClass: "infrastructure"
|
|
18469
|
-
});
|
|
18470
|
-
},
|
|
18471
|
-
onRuntimeError: (error) => handleProcessError(instanceId, workerId, error),
|
|
18472
|
-
snapshotToken,
|
|
18473
|
-
onRuntimeExit: () => {
|
|
18474
|
-
processExitedBeforeRegistration = !workers.has(instanceId);
|
|
18475
|
-
}
|
|
18476
|
-
};
|
|
18477
|
-
const connect = registerRunnerWebSocket({
|
|
18882
|
+
runnerRuntime.webSocketIpc.registerWorker({
|
|
18478
18883
|
instanceId,
|
|
18479
18884
|
workerId,
|
|
18480
18885
|
tokenHash: connectTokenHash,
|
|
18481
|
-
|
|
18482
|
-
|
|
18483
|
-
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
|
|
18488
|
-
|
|
18886
|
+
callbacks: {
|
|
18887
|
+
onEnvelope: (envelope) => {
|
|
18888
|
+
if (workers.has(instanceId)) {
|
|
18889
|
+
routeEnvelope(envelope, instanceId);
|
|
18890
|
+
} else {
|
|
18891
|
+
earlyEnvelopes.push(envelope);
|
|
18892
|
+
}
|
|
18893
|
+
},
|
|
18894
|
+
onInvalidOutput: () => {
|
|
18895
|
+
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
18896
|
+
errorCode: "invalid_worker_websocket_ipc",
|
|
18897
|
+
message: "Worker emitted invalid WebSocket IPC message",
|
|
18898
|
+
errorClass: "infrastructure"
|
|
18899
|
+
});
|
|
18900
|
+
},
|
|
18901
|
+
onRuntimeError: (error) => handleProcessError(instanceId, workerId, error)
|
|
18902
|
+
}
|
|
18489
18903
|
});
|
|
18904
|
+
const unregister = (reason) => runnerRuntime.webSocketIpc.unregister(instanceId, workerId, reason);
|
|
18905
|
+
unregisterStartRegistration = () => unregister("start_failed");
|
|
18906
|
+
handle = await startRunnerWorker(
|
|
18907
|
+
{
|
|
18908
|
+
instanceId,
|
|
18909
|
+
workerId,
|
|
18910
|
+
startupDeadlineMs,
|
|
18911
|
+
resolvedExtensionEntriesJson: deps.resolvedExtensionEntriesJson,
|
|
18912
|
+
snapshotToken,
|
|
18913
|
+
onRuntimeExit: () => {
|
|
18914
|
+
processExitedBeforeRegistration = !workers.has(instanceId);
|
|
18915
|
+
}
|
|
18916
|
+
},
|
|
18917
|
+
{ token: connectToken, unregister }
|
|
18918
|
+
);
|
|
18490
18919
|
unregisterStartRegistration = void 0;
|
|
18491
18920
|
} catch (error) {
|
|
18492
18921
|
unregisterStartRegistration?.();
|
|
@@ -18574,14 +19003,10 @@ function createWorkerSupervisor(deps) {
|
|
|
18574
19003
|
if (!handle) {
|
|
18575
19004
|
return;
|
|
18576
19005
|
}
|
|
18577
|
-
|
|
19006
|
+
sendToCurrentWorker(instanceId, handle.workerId, {
|
|
18578
19007
|
type: "worker.abort_turn",
|
|
18579
|
-
instanceId,
|
|
18580
|
-
workerId: handle.workerId,
|
|
18581
|
-
messageId: randomUUID6(),
|
|
18582
19008
|
payload: { reason }
|
|
18583
19009
|
});
|
|
18584
|
-
handle.send(msg);
|
|
18585
19010
|
},
|
|
18586
19011
|
deliverInputs(instanceId, inputs) {
|
|
18587
19012
|
const handle = workers.get(instanceId);
|
|
@@ -18665,7 +19090,9 @@ function createToolApprovalGate(input) {
|
|
|
18665
19090
|
}
|
|
18666
19091
|
}
|
|
18667
19092
|
return {
|
|
19093
|
+
/** @internal */
|
|
18668
19094
|
reconcile,
|
|
19095
|
+
/** @internal */
|
|
18669
19096
|
async review(requestInput) {
|
|
18670
19097
|
if (!isCurrentTurn(input.repos, requestInput)) return { kind: "declined" };
|
|
18671
19098
|
const result = input.repos.toolApprovalRequests.createIdempotent(requestInput);
|
|
@@ -18677,9 +19104,11 @@ function createToolApprovalGate(input) {
|
|
|
18677
19104
|
waiters.set(result.request.id, pending);
|
|
18678
19105
|
});
|
|
18679
19106
|
},
|
|
19107
|
+
/** @internal */
|
|
18680
19108
|
listOpen(instanceId) {
|
|
18681
19109
|
return input.repos.toolApprovalRequests.listOpen(instanceId);
|
|
18682
19110
|
},
|
|
19111
|
+
/** @internal */
|
|
18683
19112
|
async resolve(instanceId, requestId, decision, actor) {
|
|
18684
19113
|
const resolved = await input.processOperations.runExclusive(
|
|
18685
19114
|
instanceId,
|
|
@@ -18701,6 +19130,7 @@ function createToolApprovalGate(input) {
|
|
|
18701
19130
|
reconcile(instanceId);
|
|
18702
19131
|
return resolved;
|
|
18703
19132
|
},
|
|
19133
|
+
/** @internal */
|
|
18704
19134
|
cancelTurn(instanceId, turnRecordId) {
|
|
18705
19135
|
const changed = input.repos.toolApprovalRequests.cancelOpenByTurn(instanceId, turnRecordId);
|
|
18706
19136
|
reconcile(instanceId);
|
|
@@ -18808,10 +19238,6 @@ async function createConfiguredWorkerRunnerRuntime(input) {
|
|
|
18808
19238
|
});
|
|
18809
19239
|
return { ...created, webSocketIpc: input.webSocketIpc };
|
|
18810
19240
|
}
|
|
18811
|
-
async function createApp(opts = {}) {
|
|
18812
|
-
const ctx = await createAppContext(opts);
|
|
18813
|
-
return ctx.app;
|
|
18814
|
-
}
|
|
18815
19241
|
async function createAppContext(opts = {}) {
|
|
18816
19242
|
const startupStartedAt = performance.now();
|
|
18817
19243
|
let previousStartupMark = startupStartedAt;
|
|
@@ -18846,238 +19272,249 @@ ${configErrors.join("\n")}`);
|
|
|
18846
19272
|
);
|
|
18847
19273
|
previousStartupMark = now2;
|
|
18848
19274
|
};
|
|
18849
|
-
|
|
18850
|
-
|
|
18851
|
-
|
|
18852
|
-
const
|
|
18853
|
-
|
|
18854
|
-
|
|
18855
|
-
|
|
18856
|
-
|
|
18857
|
-
|
|
18858
|
-
|
|
18859
|
-
|
|
18860
|
-
|
|
18861
|
-
|
|
18862
|
-
|
|
18863
|
-
|
|
18864
|
-
|
|
18865
|
-
|
|
18866
|
-
|
|
18867
|
-
|
|
18868
|
-
|
|
18869
|
-
|
|
18870
|
-
|
|
18871
|
-
|
|
18872
|
-
|
|
18873
|
-
|
|
18874
|
-
|
|
18875
|
-
|
|
18876
|
-
|
|
18877
|
-
|
|
18878
|
-
|
|
18879
|
-
|
|
18880
|
-
|
|
18881
|
-
|
|
18882
|
-
|
|
18883
|
-
|
|
18884
|
-
|
|
18885
|
-
);
|
|
18886
|
-
|
|
18887
|
-
|
|
18888
|
-
|
|
18889
|
-
|
|
18890
|
-
|
|
18891
|
-
|
|
18892
|
-
|
|
18893
|
-
|
|
18894
|
-
|
|
18895
|
-
|
|
18896
|
-
|
|
18897
|
-
|
|
18898
|
-
|
|
18899
|
-
|
|
18900
|
-
|
|
18901
|
-
|
|
18902
|
-
|
|
18903
|
-
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18915
|
-
|
|
18916
|
-
|
|
18917
|
-
|
|
18918
|
-
|
|
18919
|
-
|
|
18920
|
-
|
|
18921
|
-
|
|
18922
|
-
|
|
18923
|
-
extensionCatalog.
|
|
18924
|
-
|
|
18925
|
-
|
|
18926
|
-
|
|
18927
|
-
|
|
18928
|
-
|
|
18929
|
-
|
|
18930
|
-
|
|
18931
|
-
|
|
18932
|
-
|
|
18933
|
-
|
|
18934
|
-
|
|
18935
|
-
const launcherModelProfilesById = new Map(
|
|
18936
|
-
launcherModelProfiles.map((profile) => [profile.id, profile])
|
|
18937
|
-
);
|
|
18938
|
-
const getModelProfilesForProcess = (processId) => {
|
|
18939
|
-
return processModelPolicy.project({
|
|
18940
|
-
kind: "profile_options",
|
|
18941
|
-
processId,
|
|
18942
|
-
availability: modelStatusCache.snapshot()
|
|
18943
|
-
}).map((profile) => launcherModelProfilesById.get(profile.id)).filter(
|
|
18944
|
-
(profile) => profile !== void 0
|
|
19275
|
+
let finishCleanup;
|
|
19276
|
+
let stopAcquiredWorkers;
|
|
19277
|
+
let closeOwnedDatabase;
|
|
19278
|
+
const preCloseCleanup = [];
|
|
19279
|
+
try {
|
|
19280
|
+
await app.register(cookie);
|
|
19281
|
+
markStartup("fastify_plugins");
|
|
19282
|
+
const ownsDb = !opts.db;
|
|
19283
|
+
const db = opts.db ?? createConfiguredDatabase(config);
|
|
19284
|
+
if (ownsDb) closeOwnedDatabase = () => closeDatabase(db);
|
|
19285
|
+
preCloseCleanup.push(() => stopAcquiredWorkers?.());
|
|
19286
|
+
app.addHook("onClose", async () => {
|
|
19287
|
+
await finishCleanup?.();
|
|
19288
|
+
});
|
|
19289
|
+
markStartup("database");
|
|
19290
|
+
const { resolvedExtensionEntries, extensionCatalog } = await loadServerExtensionCatalog({
|
|
19291
|
+
config,
|
|
19292
|
+
extensionCatalog: opts.extensionCatalog,
|
|
19293
|
+
resolvedExtensionEntries: opts.resolvedExtensionEntries,
|
|
19294
|
+
extensionLoadingStartDir: opts.extensionLoadingStartDir
|
|
19295
|
+
});
|
|
19296
|
+
markStartup("extension_catalog");
|
|
19297
|
+
const modelProviderRegistry = createModelProviderRegistry({
|
|
19298
|
+
sets: extensionCatalog.modelProviders,
|
|
19299
|
+
piContributions: extensionCatalog.piContributions,
|
|
19300
|
+
extensionConfig: config.extensions ?? {},
|
|
19301
|
+
modelProfiles: config.pi.model_profiles,
|
|
19302
|
+
titleModelProfileId: config.pi.process_title_generation.model_profile
|
|
19303
|
+
});
|
|
19304
|
+
const credentialCipher = createCredentialCipherFromEnvironment();
|
|
19305
|
+
const repos = createAllRepos(db, {
|
|
19306
|
+
...credentialCipher ? { credentialCipher } : {}
|
|
19307
|
+
});
|
|
19308
|
+
repos.transaction((transactionRepos) => {
|
|
19309
|
+
transactionRepos.skills.reconcile([]);
|
|
19310
|
+
transactionRepos.skills.backfillDependencies();
|
|
19311
|
+
});
|
|
19312
|
+
const skillCatalog = createSkillCatalogService({
|
|
19313
|
+
repositories: config.skill_repositories ?? [],
|
|
19314
|
+
repos
|
|
19315
|
+
});
|
|
19316
|
+
await skillCatalog.refresh();
|
|
19317
|
+
markStartup("skill_catalog");
|
|
19318
|
+
if (!credentialCipher && repos.providerCredentials.count() > 0) {
|
|
19319
|
+
throw new Error(
|
|
19320
|
+
"Encrypted provider credentials exist but LEITWERK_CREDENTIAL_ENCRYPTION_KEY is unavailable"
|
|
19321
|
+
);
|
|
19322
|
+
}
|
|
19323
|
+
const modelProviderCredentials = createModelProviderCredentialService({
|
|
19324
|
+
registry: modelProviderRegistry,
|
|
19325
|
+
repo: repos.providerCredentials
|
|
19326
|
+
});
|
|
19327
|
+
modelProviderCredentials.initialize();
|
|
19328
|
+
const modelStatusCache = createModelStatusCache({
|
|
19329
|
+
registry: modelProviderRegistry,
|
|
19330
|
+
modelProfiles: config.pi.model_profiles,
|
|
19331
|
+
credentialStatus: opts.modelProviderCredentialStatus ?? (modelProviderRegistry.size > 0 ? modelProviderCredentials.status : defaultModelProviderCredentialStatus)
|
|
19332
|
+
});
|
|
19333
|
+
await modelStatusCache.refresh();
|
|
19334
|
+
const modelProviderServerAdapters = await createModelProviderServerAdapterRegistry({
|
|
19335
|
+
registry: modelProviderRegistry,
|
|
19336
|
+
modelProfiles: config.pi.model_profiles,
|
|
19337
|
+
credentials: modelProviderCredentials,
|
|
19338
|
+
createBuiltinAdapter: (providerId) => createBuiltinPiServerAdapter(providerId)
|
|
19339
|
+
});
|
|
19340
|
+
const piResourceBundles = createPiResourceBundleCache();
|
|
19341
|
+
const piResourceBundlePins = createPiResourceBundlePinReconciler({
|
|
19342
|
+
turnStarts: repos.turnStarts,
|
|
19343
|
+
turnRecords: repos.turnRecords,
|
|
19344
|
+
bundleCache: piResourceBundles
|
|
19345
|
+
});
|
|
19346
|
+
markStartup("model_providers");
|
|
19347
|
+
const broadcaster = createBroadcaster();
|
|
19348
|
+
const processOperations = createProcessOperationCoordinator();
|
|
19349
|
+
const processGraphs = extensionCatalog.processes;
|
|
19350
|
+
const processActionRegistry = buildProcessActionRegistry(extensionCatalog);
|
|
19351
|
+
const integrationTools = new IntegrationToolRegistry(repos.externalWrites);
|
|
19352
|
+
const processUiRegistry = buildProcessUiRegistry(extensionCatalog);
|
|
19353
|
+
const processModelPolicy = createServerProcessModelPolicy({
|
|
19354
|
+
config,
|
|
19355
|
+
processGraphs,
|
|
19356
|
+
processActionRegistry
|
|
19357
|
+
});
|
|
19358
|
+
const extensionUiCatalog = await buildExtensionUiCatalog(
|
|
19359
|
+
extensionCatalog.modules,
|
|
19360
|
+
opts.extensionUiRuntimeLane ? { runtimeLane: opts.extensionUiRuntimeLane } : {}
|
|
18945
19361
|
);
|
|
18946
|
-
|
|
18947
|
-
|
|
18948
|
-
|
|
18949
|
-
|
|
18950
|
-
|
|
18951
|
-
|
|
18952
|
-
|
|
18953
|
-
modelProfiles: launcherModelProfiles,
|
|
18954
|
-
getModelProfilesForProcess,
|
|
18955
|
-
processModelPolicy
|
|
18956
|
-
});
|
|
18957
|
-
const workerWebSocketIpc = createWorkerWebSocketIpcManager();
|
|
18958
|
-
workerWebSocketIpc.setUnknownWorkerConnectionsRetryable(true);
|
|
18959
|
-
const serverEpoch = `epoch_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
18960
|
-
const sessionSnapshots = createProjectedSessionSnapshotStore(
|
|
18961
|
-
createFileBackedProcessSessionSnapshotStore(config.storage.tree_files_dir),
|
|
18962
|
-
repos
|
|
18963
|
-
);
|
|
18964
|
-
for (const process2 of repos.processes.listAll()) await sessionSnapshots.backfill(process2.id);
|
|
18965
|
-
const sessionReader = new ProcessSessionReader(sessionSnapshots);
|
|
18966
|
-
const resultImages = new ResultImageStore({
|
|
18967
|
-
rootDir: path9.join(config.storage.tree_files_dir, "result-images")
|
|
18968
|
-
});
|
|
18969
|
-
const authService = createAuthService({ config, repos });
|
|
18970
|
-
await registerWebsocket(app, broadcaster, workerWebSocketIpc, authService);
|
|
18971
|
-
const extensionHost = createExtensionHost();
|
|
18972
|
-
let launchCoordinator;
|
|
18973
|
-
let applyGeneratedFutureExecutionTitle = async () => ({
|
|
18974
|
-
kind: "failed",
|
|
18975
|
-
error: "Future execution lifecycle is not initialized"
|
|
18976
|
-
});
|
|
18977
|
-
const processTitles = opts.processTitleGenerator ?? (config.pi.process_title_generation.model_profile === null ? void 0 : createProcessTitleGenerator({
|
|
18978
|
-
config,
|
|
18979
|
-
repos,
|
|
18980
|
-
broadcaster,
|
|
18981
|
-
extensionHost,
|
|
18982
|
-
futureExecutionTitleApplier: (input) => applyGeneratedFutureExecutionTitle(input),
|
|
18983
|
-
getLaunchCoordinator: () => launchCoordinator,
|
|
18984
|
-
logger: {
|
|
18985
|
-
warn: (message, details) => app.log.warn(details ?? {}, message)
|
|
18986
|
-
},
|
|
18987
|
-
runtime: {
|
|
18988
|
-
generateTitle: ({ prompt, maxTokens, providerOptions }) => modelProviderServerAdapters.generateText({
|
|
18989
|
-
profileId: config.pi.process_title_generation.model_profile,
|
|
18990
|
-
prompt,
|
|
18991
|
-
systemPrompt: TITLE_SYSTEM_PROMPT,
|
|
18992
|
-
maxTokens,
|
|
18993
|
-
request: providerOptions
|
|
19362
|
+
markStartup("extension_ui_catalog");
|
|
19363
|
+
const launcherModelProfiles = config.pi.model_profiles.map(
|
|
19364
|
+
(profile) => ({
|
|
19365
|
+
id: profile.id,
|
|
19366
|
+
provider: profile.provider,
|
|
19367
|
+
modelId: profile.model_id,
|
|
19368
|
+
thinkingLevel: profile.thinking_level ?? "off"
|
|
18994
19369
|
})
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
|
|
19004
|
-
|
|
19005
|
-
|
|
19006
|
-
|
|
19007
|
-
|
|
19008
|
-
|
|
19009
|
-
|
|
19010
|
-
|
|
19011
|
-
|
|
19012
|
-
|
|
19013
|
-
|
|
19014
|
-
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
|
|
19027
|
-
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
|
|
19031
|
-
|
|
19032
|
-
|
|
19033
|
-
|
|
19034
|
-
|
|
19035
|
-
|
|
19036
|
-
|
|
19037
|
-
|
|
19038
|
-
|
|
19039
|
-
|
|
19040
|
-
|
|
19370
|
+
);
|
|
19371
|
+
const launcherModelProfilesById = new Map(
|
|
19372
|
+
launcherModelProfiles.map((profile) => [profile.id, profile])
|
|
19373
|
+
);
|
|
19374
|
+
const getModelProfilesForProcess = (processId) => {
|
|
19375
|
+
return processModelPolicy.project({
|
|
19376
|
+
kind: "profile_options",
|
|
19377
|
+
processId,
|
|
19378
|
+
availability: modelStatusCache.snapshot()
|
|
19379
|
+
}).map((profile) => launcherModelProfilesById.get(profile.id)).filter(
|
|
19380
|
+
(profile) => profile !== void 0
|
|
19381
|
+
);
|
|
19382
|
+
};
|
|
19383
|
+
const launcherService = buildProcessLauncherRegistry(extensionCatalog, {
|
|
19384
|
+
modelProfiles: launcherModelProfiles,
|
|
19385
|
+
commitMessages: config.commit_messages,
|
|
19386
|
+
getModelProfilesForProcess
|
|
19387
|
+
});
|
|
19388
|
+
const processWatcherService = buildProcessWatcherRegistry(extensionCatalog, config, {
|
|
19389
|
+
modelProfiles: launcherModelProfiles,
|
|
19390
|
+
getModelProfilesForProcess,
|
|
19391
|
+
processModelPolicy
|
|
19392
|
+
});
|
|
19393
|
+
const workerWebSocketIpc = createWorkerWebSocketIpcManager();
|
|
19394
|
+
workerWebSocketIpc.setUnknownWorkerConnectionsRetryable(true);
|
|
19395
|
+
const serverEpoch = `epoch_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
19396
|
+
const sessionSnapshots = createProjectedSessionSnapshotStore(
|
|
19397
|
+
createFileBackedProcessSessionSnapshotStore(config.storage.tree_files_dir),
|
|
19398
|
+
repos
|
|
19399
|
+
);
|
|
19400
|
+
for (const process2 of repos.processes.listAll()) await sessionSnapshots.backfill(process2.id);
|
|
19401
|
+
const sessionReader = new ProcessSessionReader(sessionSnapshots);
|
|
19402
|
+
const resultImages = new ResultImageStore({
|
|
19403
|
+
rootDir: path9.join(config.storage.tree_files_dir, "result-images")
|
|
19404
|
+
});
|
|
19405
|
+
const authService = createAuthService({ config, repos });
|
|
19406
|
+
await registerWebsocket(app, broadcaster, workerWebSocketIpc, authService);
|
|
19407
|
+
const extensionHost = createExtensionHost();
|
|
19408
|
+
let launchCoordinator;
|
|
19409
|
+
let applyGeneratedFutureExecutionTitle = async () => ({
|
|
19410
|
+
kind: "failed",
|
|
19411
|
+
error: "Future execution lifecycle is not initialized"
|
|
19412
|
+
});
|
|
19413
|
+
const processTitles = opts.processTitleGenerator ?? (config.pi.process_title_generation.model_profile === null ? void 0 : createProcessTitleGenerator({
|
|
19414
|
+
config,
|
|
19415
|
+
repos,
|
|
19416
|
+
broadcaster,
|
|
19417
|
+
extensionHost,
|
|
19418
|
+
futureExecutionTitleApplier: (input) => applyGeneratedFutureExecutionTitle(input),
|
|
19419
|
+
getLaunchCoordinator: () => launchCoordinator,
|
|
19420
|
+
logger: {
|
|
19421
|
+
warn: (message, details) => app.log.warn(details ?? {}, message)
|
|
19041
19422
|
},
|
|
19042
|
-
|
|
19043
|
-
|
|
19044
|
-
|
|
19045
|
-
|
|
19046
|
-
|
|
19047
|
-
|
|
19048
|
-
|
|
19049
|
-
|
|
19050
|
-
profileIds,
|
|
19051
|
-
logger: app.log
|
|
19052
|
-
});
|
|
19423
|
+
runtime: {
|
|
19424
|
+
generateTitle: ({ prompt, maxTokens, providerOptions }) => modelProviderServerAdapters.generateText({
|
|
19425
|
+
profileId: config.pi.process_title_generation.model_profile,
|
|
19426
|
+
prompt,
|
|
19427
|
+
systemPrompt: TITLE_SYSTEM_PROMPT,
|
|
19428
|
+
maxTokens,
|
|
19429
|
+
request: providerOptions
|
|
19430
|
+
})
|
|
19053
19431
|
}
|
|
19432
|
+
}));
|
|
19433
|
+
const baseDeps = {
|
|
19434
|
+
...repos,
|
|
19435
|
+
broadcaster,
|
|
19436
|
+
processOperations
|
|
19437
|
+
};
|
|
19438
|
+
let invalidateExternalSourceArmings = null;
|
|
19439
|
+
const projectMutations = createProjectMutationService({
|
|
19440
|
+
projects: baseDeps.projects,
|
|
19441
|
+
transaction: baseDeps.transaction,
|
|
19442
|
+
broadcaster,
|
|
19443
|
+
onProjectMutated: (project) => invalidateExternalSourceArmings?.(project.instanceId)
|
|
19054
19444
|
});
|
|
19055
|
-
|
|
19056
|
-
|
|
19057
|
-
|
|
19058
|
-
|
|
19059
|
-
|
|
19060
|
-
|
|
19445
|
+
const launcherRecentValues = createLauncherRecentValuesService({
|
|
19446
|
+
repos: baseDeps,
|
|
19447
|
+
launcherService
|
|
19448
|
+
});
|
|
19449
|
+
const launchPlans = {
|
|
19450
|
+
async prepare(launchPlan, opts2 = {}) {
|
|
19451
|
+
return processModelPolicy.prepareLaunchPlan(launchPlan, opts2);
|
|
19452
|
+
}
|
|
19453
|
+
};
|
|
19454
|
+
const launcherModelConfigs = createLauncherModelConfigService({
|
|
19455
|
+
launcherService,
|
|
19456
|
+
launchPlans,
|
|
19457
|
+
processModelPolicy,
|
|
19458
|
+
modelStatusCache
|
|
19459
|
+
});
|
|
19460
|
+
const polling = createPollingCoordinator(app.log);
|
|
19461
|
+
const startHooks = [];
|
|
19462
|
+
const stopHooks = [];
|
|
19463
|
+
preCloseCleanup.push(async () => {
|
|
19464
|
+
const errors = await collectCleanupErrors(stopHooks);
|
|
19465
|
+
if (errors.length) throw new AggregateError(errors, "Background service cleanup failed");
|
|
19466
|
+
});
|
|
19467
|
+
const modelRefreshWork = /* @__PURE__ */ new Set();
|
|
19468
|
+
let modelStatusRefreshTimer = null;
|
|
19469
|
+
let futureExecutionLifecycle;
|
|
19470
|
+
async function refreshModelStatusAndApplyTransitions() {
|
|
19471
|
+
const snapshot = await modelStatusCache.refresh();
|
|
19472
|
+
await applyProcessModelAvailabilityTransitions({
|
|
19473
|
+
snapshot,
|
|
19474
|
+
reconcileFutureExecutions: async (profileIds) => {
|
|
19475
|
+
await futureExecutionLifecycle.reconcileModelAvailability({
|
|
19476
|
+
availability: snapshot,
|
|
19477
|
+
profileIds
|
|
19478
|
+
});
|
|
19479
|
+
},
|
|
19480
|
+
recoverProcesses: async (profileIds) => {
|
|
19481
|
+
await recoverModelAvailabilityFailures({
|
|
19482
|
+
processes: baseDeps.processes,
|
|
19483
|
+
turnStarts: baseDeps.turnStarts,
|
|
19484
|
+
commands: processEngine,
|
|
19485
|
+
policy: processModelPolicy,
|
|
19486
|
+
availability: snapshot,
|
|
19487
|
+
cause: "availability_transition",
|
|
19488
|
+
profileIds,
|
|
19489
|
+
logger: app.log
|
|
19490
|
+
});
|
|
19491
|
+
}
|
|
19061
19492
|
});
|
|
19062
|
-
}, 15e3);
|
|
19063
|
-
});
|
|
19064
|
-
stopHooks.push(() => {
|
|
19065
|
-
if (modelStatusRefreshTimer) clearInterval(modelStatusRefreshTimer);
|
|
19066
|
-
modelStatusRefreshTimer = null;
|
|
19067
|
-
});
|
|
19068
|
-
let stopAuthSweep = null;
|
|
19069
|
-
startHooks.push(() => {
|
|
19070
|
-
stopAuthSweep = authService.startExpiredAuthStateSweep();
|
|
19071
|
-
});
|
|
19072
|
-
stopHooks.push(() => {
|
|
19073
|
-
stopAuthSweep?.();
|
|
19074
|
-
stopAuthSweep = null;
|
|
19075
|
-
});
|
|
19076
|
-
async function startBackgroundServices() {
|
|
19077
|
-
if (backgroundServicesStarted) {
|
|
19078
|
-
return;
|
|
19079
19493
|
}
|
|
19080
|
-
|
|
19494
|
+
startHooks.push(() => {
|
|
19495
|
+
if (modelProviderRegistry.size === 0) return;
|
|
19496
|
+
modelStatusRefreshTimer = setInterval(() => {
|
|
19497
|
+
const work = refreshModelStatusAndApplyTransitions().catch((error) => {
|
|
19498
|
+
app.log.warn({ error }, "Model provider status refresh failed");
|
|
19499
|
+
});
|
|
19500
|
+
modelRefreshWork.add(work);
|
|
19501
|
+
void work.finally(() => modelRefreshWork.delete(work));
|
|
19502
|
+
}, 15e3);
|
|
19503
|
+
});
|
|
19504
|
+
stopHooks.push(async () => {
|
|
19505
|
+
if (modelStatusRefreshTimer) clearInterval(modelStatusRefreshTimer);
|
|
19506
|
+
modelStatusRefreshTimer = null;
|
|
19507
|
+
await Promise.all(modelRefreshWork);
|
|
19508
|
+
});
|
|
19509
|
+
let stopAuthSweep = null;
|
|
19510
|
+
startHooks.push(() => {
|
|
19511
|
+
stopAuthSweep = authService.startExpiredAuthStateSweep();
|
|
19512
|
+
});
|
|
19513
|
+
stopHooks.push(() => {
|
|
19514
|
+
stopAuthSweep?.();
|
|
19515
|
+
stopAuthSweep = null;
|
|
19516
|
+
});
|
|
19517
|
+
async function reconcileStartup(assertOpen) {
|
|
19081
19518
|
if (!supervisor) {
|
|
19082
19519
|
throw new Error("worker supervisor not initialized");
|
|
19083
19520
|
}
|
|
@@ -19086,6 +19523,7 @@ ${configErrors.join("\n")}`);
|
|
|
19086
19523
|
await futureExecutionLifecycle.reconcileModelAvailability({
|
|
19087
19524
|
availability: modelStatusCache.snapshot()
|
|
19088
19525
|
});
|
|
19526
|
+
assertOpen();
|
|
19089
19527
|
await recoverModelAvailabilityFailures({
|
|
19090
19528
|
processes: baseDeps.processes,
|
|
19091
19529
|
turnStarts: baseDeps.turnStarts,
|
|
@@ -19095,13 +19533,16 @@ ${configErrors.join("\n")}`);
|
|
|
19095
19533
|
cause: "startup_reconciliation",
|
|
19096
19534
|
logger: app.log
|
|
19097
19535
|
});
|
|
19536
|
+
assertOpen();
|
|
19098
19537
|
await reconcilePersistedProcessModelIntegrity({
|
|
19099
19538
|
processes: baseDeps.processes,
|
|
19100
19539
|
commands: processEngine,
|
|
19101
19540
|
policy: processModelPolicy,
|
|
19102
19541
|
logger: app.log
|
|
19103
19542
|
});
|
|
19543
|
+
assertOpen();
|
|
19104
19544
|
await supervisor.adoptRegisteredWorkers();
|
|
19545
|
+
assertOpen();
|
|
19105
19546
|
await reconcileProcessesOnStartup({
|
|
19106
19547
|
config,
|
|
19107
19548
|
processes: baseDeps.processes,
|
|
@@ -19115,684 +19556,611 @@ ${configErrors.join("\n")}`);
|
|
|
19115
19556
|
processActionRegistry,
|
|
19116
19557
|
logger: app.log
|
|
19117
19558
|
});
|
|
19118
|
-
|
|
19559
|
+
assertOpen();
|
|
19119
19560
|
} finally {
|
|
19120
19561
|
workerWebSocketIpc.setUnknownWorkerConnectionsRetryable(false);
|
|
19121
19562
|
}
|
|
19122
19563
|
}
|
|
19123
|
-
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
backgroundServicesReady = false;
|
|
19131
|
-
backgroundServicesStarted = false;
|
|
19132
|
-
for (const hook of [...stopHooks].reverse()) {
|
|
19133
|
-
await hook();
|
|
19134
|
-
}
|
|
19135
|
-
throw error;
|
|
19136
|
-
}
|
|
19137
|
-
}
|
|
19138
|
-
async function stopBackgroundServices() {
|
|
19139
|
-
backgroundServicesReady = false;
|
|
19140
|
-
if (!backgroundServicesStarted) {
|
|
19141
|
-
return;
|
|
19142
|
-
}
|
|
19143
|
-
backgroundServicesStarted = false;
|
|
19144
|
-
for (const hook of [...stopHooks].reverse()) {
|
|
19145
|
-
await hook();
|
|
19146
|
-
}
|
|
19147
|
-
}
|
|
19148
|
-
let supervisor;
|
|
19149
|
-
let isNewTurnBlocked = (_instanceId) => false;
|
|
19150
|
-
const afterSuccessHooks = /* @__PURE__ */ new Set();
|
|
19151
|
-
const toastTtlMs = parseDurationMs8(config.server.websocket.toast_ttl, 6e3, {
|
|
19152
|
-
allowHours: true
|
|
19153
|
-
});
|
|
19154
|
-
const processEngine = createProcessEngine({
|
|
19155
|
-
processes: baseDeps.processes,
|
|
19156
|
-
events: baseDeps.events,
|
|
19157
|
-
futureExecutions: baseDeps.futureExecutions,
|
|
19158
|
-
projects: baseDeps.projects,
|
|
19159
|
-
inputs: baseDeps.inputs,
|
|
19160
|
-
pendingExternalSourceFires: baseDeps.pendingExternalSourceFires,
|
|
19161
|
-
leafOutcomeSnapshots: baseDeps.leafOutcomeSnapshots,
|
|
19162
|
-
questionRequests: baseDeps.questionRequests,
|
|
19163
|
-
turnRecords: baseDeps.turnRecords,
|
|
19164
|
-
turnStarts: baseDeps.turnStarts,
|
|
19165
|
-
leases: baseDeps.leases,
|
|
19166
|
-
turnAnnotations: baseDeps.turnAnnotations,
|
|
19167
|
-
transaction: baseDeps.transaction,
|
|
19168
|
-
broadcaster,
|
|
19169
|
-
config,
|
|
19170
|
-
toastTtlMs,
|
|
19171
|
-
processOperations,
|
|
19172
|
-
getSupervisor: () => supervisor,
|
|
19173
|
-
extensionHost,
|
|
19174
|
-
processGraphs,
|
|
19175
|
-
sessionReader,
|
|
19176
|
-
getProcessActionRegistry: () => processActionRegistry,
|
|
19177
|
-
getProcessUiRegistry: () => processUiRegistry,
|
|
19178
|
-
logger: app.log,
|
|
19179
|
-
processModelPolicy,
|
|
19180
|
-
getModelAvailabilitySnapshot: () => modelStatusCache.snapshot(),
|
|
19181
|
-
afterRecord(process2) {
|
|
19182
|
-
piResourceBundlePins.reconcile(process2);
|
|
19183
|
-
toolApprovalGate.reconcile(process2.id);
|
|
19184
|
-
},
|
|
19185
|
-
afterSuccessHooks,
|
|
19186
|
-
isNewTurnBlocked: (instanceId) => isNewTurnBlocked(instanceId),
|
|
19187
|
-
prepareTurnStarts: (process2, writes, providerOptions, availabilitySnapshot) => prepareCreatedTurnStarts(
|
|
19188
|
-
{
|
|
19189
|
-
config,
|
|
19190
|
-
registry: modelProviderRegistry,
|
|
19191
|
-
modelStatusCache,
|
|
19192
|
-
piContributions: extensionCatalog.piContributions,
|
|
19193
|
-
bundleCache: piResourceBundles,
|
|
19194
|
-
projects: baseDeps.projects,
|
|
19195
|
-
processSkills: baseDeps.processSkills
|
|
19196
|
-
},
|
|
19197
|
-
process2,
|
|
19198
|
-
writes,
|
|
19199
|
-
providerOptions,
|
|
19200
|
-
availabilitySnapshot
|
|
19201
|
-
)
|
|
19202
|
-
});
|
|
19203
|
-
const processQuestions = createProcessQuestionService({
|
|
19204
|
-
repos: baseDeps,
|
|
19205
|
-
processOperations,
|
|
19206
|
-
broadcaster,
|
|
19207
|
-
getWorkerId: (instanceId) => supervisor?.getWorker(instanceId)?.workerId ?? null,
|
|
19208
|
-
sendQuestionResponse: (instanceId, workerId, payload) => supervisor?.questionResponse(instanceId, workerId, payload),
|
|
19209
|
-
emitQuestionRequested: (request) => extensionHost.emit("question_requested", { instanceId: request.instanceId, request }).catch(
|
|
19210
|
-
(error) => app.log.error(
|
|
19211
|
-
{ error, instanceId: request.instanceId },
|
|
19212
|
-
"Question delivery event failed"
|
|
19213
|
-
)
|
|
19214
|
-
)
|
|
19215
|
-
});
|
|
19216
|
-
const toolApprovalGate = createToolApprovalGate({
|
|
19217
|
-
repos: baseDeps,
|
|
19218
|
-
processOperations
|
|
19219
|
-
});
|
|
19220
|
-
const integrationToolRequests = createIntegrationToolRequestService({
|
|
19221
|
-
registry: integrationTools,
|
|
19222
|
-
repos: baseDeps,
|
|
19223
|
-
processActionRegistry,
|
|
19224
|
-
toolApprovalGate
|
|
19225
|
-
});
|
|
19226
|
-
const diagnosticTraceWriter = createDiagnosticTraceWriter(
|
|
19227
|
-
path9.join(config.storage.tree_files_dir, "diagnostic-traces")
|
|
19228
|
-
);
|
|
19229
|
-
const ipcHandler = createIpcHandler(
|
|
19230
|
-
{
|
|
19231
|
-
startupObservations: baseDeps.startupObservations,
|
|
19564
|
+
let supervisor;
|
|
19565
|
+
let isNewTurnBlocked = (_instanceId) => false;
|
|
19566
|
+
const afterSuccessHooks = /* @__PURE__ */ new Set();
|
|
19567
|
+
const toastTtlMs = parseDurationMs8(config.server.websocket.toast_ttl, 6e3, {
|
|
19568
|
+
allowHours: true
|
|
19569
|
+
});
|
|
19570
|
+
const processEngine = createProcessEngine({
|
|
19232
19571
|
processes: baseDeps.processes,
|
|
19233
|
-
|
|
19572
|
+
events: baseDeps.events,
|
|
19573
|
+
futureExecutions: baseDeps.futureExecutions,
|
|
19234
19574
|
projects: baseDeps.projects,
|
|
19235
19575
|
inputs: baseDeps.inputs,
|
|
19236
|
-
|
|
19237
|
-
|
|
19576
|
+
pendingExternalSourceFires: baseDeps.pendingExternalSourceFires,
|
|
19577
|
+
leafOutcomeSnapshots: baseDeps.leafOutcomeSnapshots,
|
|
19578
|
+
questionRequests: baseDeps.questionRequests,
|
|
19238
19579
|
turnRecords: baseDeps.turnRecords,
|
|
19239
|
-
|
|
19240
|
-
|
|
19241
|
-
|
|
19580
|
+
turnStarts: baseDeps.turnStarts,
|
|
19581
|
+
leases: baseDeps.leases,
|
|
19582
|
+
turnAnnotations: baseDeps.turnAnnotations,
|
|
19583
|
+
transaction: baseDeps.transaction,
|
|
19242
19584
|
broadcaster,
|
|
19243
|
-
|
|
19244
|
-
|
|
19245
|
-
|
|
19246
|
-
|
|
19247
|
-
|
|
19248
|
-
|
|
19249
|
-
|
|
19250
|
-
|
|
19251
|
-
|
|
19252
|
-
|
|
19253
|
-
|
|
19254
|
-
|
|
19255
|
-
|
|
19256
|
-
|
|
19257
|
-
|
|
19258
|
-
return result;
|
|
19259
|
-
},
|
|
19260
|
-
appendDiagnosticTrace(instanceId, text) {
|
|
19261
|
-
try {
|
|
19262
|
-
diagnosticTraceWriter.append(instanceId, text);
|
|
19263
|
-
} catch (error) {
|
|
19264
|
-
app.log.warn({ error, instanceId }, "Could not append worker diagnostic trace");
|
|
19265
|
-
}
|
|
19266
|
-
},
|
|
19267
|
-
workerEventLogger: config.workers.log_worker_events_to_stdout ? (entry) => {
|
|
19268
|
-
app.log.info({ source: "worker_event", ...entry }, "worker.event");
|
|
19269
|
-
} : void 0
|
|
19270
|
-
},
|
|
19271
|
-
{
|
|
19272
|
-
onTurnTerminalRecorded(instanceId, workerId, turnRecordId) {
|
|
19273
|
-
supervisor?.acknowledgeTurnTerminal(instanceId, workerId, { turnRecordId });
|
|
19274
|
-
},
|
|
19275
|
-
onTurnFailedRecorded(input) {
|
|
19276
|
-
app.log.warn(input, "Worker turn failed");
|
|
19585
|
+
config,
|
|
19586
|
+
toastTtlMs,
|
|
19587
|
+
processOperations,
|
|
19588
|
+
getSupervisor: () => supervisor,
|
|
19589
|
+
extensionHost,
|
|
19590
|
+
processGraphs,
|
|
19591
|
+
sessionReader,
|
|
19592
|
+
getProcessActionRegistry: () => processActionRegistry,
|
|
19593
|
+
getProcessUiRegistry: () => processUiRegistry,
|
|
19594
|
+
logger: app.log,
|
|
19595
|
+
processModelPolicy,
|
|
19596
|
+
getModelAvailabilitySnapshot: () => modelStatusCache.snapshot(),
|
|
19597
|
+
afterRecord(process2) {
|
|
19598
|
+
piResourceBundlePins.reconcile(process2);
|
|
19599
|
+
toolApprovalGate.reconcile(process2.id);
|
|
19277
19600
|
},
|
|
19278
|
-
|
|
19279
|
-
|
|
19280
|
-
|
|
19281
|
-
|
|
19282
|
-
|
|
19283
|
-
|
|
19284
|
-
|
|
19285
|
-
|
|
19286
|
-
|
|
19287
|
-
|
|
19288
|
-
|
|
19601
|
+
afterSuccessHooks,
|
|
19602
|
+
isNewTurnBlocked: (instanceId) => isNewTurnBlocked(instanceId),
|
|
19603
|
+
prepareTurnStarts: (process2, writes, providerOptions, availabilitySnapshot) => prepareCreatedTurnStarts(
|
|
19604
|
+
{
|
|
19605
|
+
config,
|
|
19606
|
+
registry: modelProviderRegistry,
|
|
19607
|
+
modelStatusCache,
|
|
19608
|
+
piContributions: extensionCatalog.piContributions,
|
|
19609
|
+
bundleCache: piResourceBundles,
|
|
19610
|
+
projects: baseDeps.projects,
|
|
19611
|
+
processSkills: baseDeps.processSkills
|
|
19612
|
+
},
|
|
19613
|
+
process2,
|
|
19614
|
+
writes,
|
|
19615
|
+
providerOptions,
|
|
19616
|
+
availabilitySnapshot
|
|
19617
|
+
)
|
|
19618
|
+
});
|
|
19619
|
+
const processQuestions = createProcessQuestionService({
|
|
19620
|
+
repos: baseDeps,
|
|
19621
|
+
processOperations,
|
|
19622
|
+
broadcaster,
|
|
19623
|
+
getWorkerId: (instanceId) => supervisor?.getWorker(instanceId)?.workerId ?? null,
|
|
19624
|
+
sendQuestionResponse: (instanceId, workerId, payload) => supervisor?.questionResponse(instanceId, workerId, payload),
|
|
19625
|
+
emitQuestionRequested: (request) => extensionHost.emit("question_requested", { instanceId: request.instanceId, request }).catch(
|
|
19626
|
+
(error) => app.log.error(
|
|
19627
|
+
{ error, instanceId: request.instanceId },
|
|
19628
|
+
"Question delivery event failed"
|
|
19629
|
+
)
|
|
19630
|
+
)
|
|
19631
|
+
});
|
|
19632
|
+
const toolApprovalGate = createToolApprovalGate({
|
|
19633
|
+
repos: baseDeps,
|
|
19634
|
+
processOperations
|
|
19635
|
+
});
|
|
19636
|
+
const integrationToolRequests = createIntegrationToolRequestService({
|
|
19637
|
+
registry: integrationTools,
|
|
19638
|
+
repos: baseDeps,
|
|
19639
|
+
processActionRegistry,
|
|
19640
|
+
toolApprovalGate
|
|
19641
|
+
});
|
|
19642
|
+
const diagnosticTraceWriter = createDiagnosticTraceWriter(
|
|
19643
|
+
path9.join(config.storage.tree_files_dir, "diagnostic-traces")
|
|
19644
|
+
);
|
|
19645
|
+
const ipcHandler = createIpcHandler(
|
|
19646
|
+
{
|
|
19647
|
+
startupObservations: baseDeps.startupObservations,
|
|
19648
|
+
processes: baseDeps.processes,
|
|
19649
|
+
getLaunchCoordinator: () => launchCoordinator,
|
|
19650
|
+
projects: baseDeps.projects,
|
|
19651
|
+
inputs: baseDeps.inputs,
|
|
19652
|
+
events: baseDeps.events,
|
|
19653
|
+
leases: baseDeps.leases,
|
|
19654
|
+
turnRecords: baseDeps.turnRecords,
|
|
19655
|
+
handleIntegrationToolRequest: (instanceId, payload) => integrationToolRequests.handle(instanceId, payload),
|
|
19656
|
+
handleIntegrationToolCancel: (instanceId, payload) => void integrationToolRequests.cancel(instanceId, payload),
|
|
19657
|
+
processQuestions,
|
|
19658
|
+
broadcaster,
|
|
19659
|
+
commands: processEngine,
|
|
19660
|
+
updateCredential: ({ providerId, expectedRevision, values }) => {
|
|
19661
|
+
const result = modelProviderCredentials.compareAndSet({
|
|
19662
|
+
providerId,
|
|
19663
|
+
expectedRevision,
|
|
19664
|
+
value: values
|
|
19665
|
+
});
|
|
19666
|
+
if (result.accepted && !lifecycle.isClosing()) {
|
|
19667
|
+
const work = refreshModelStatusAndApplyTransitions().catch((error) => {
|
|
19668
|
+
app.log.warn(
|
|
19669
|
+
{ error, providerId },
|
|
19670
|
+
"Model status refresh after credential update failed"
|
|
19671
|
+
);
|
|
19672
|
+
});
|
|
19673
|
+
modelRefreshWork.add(work);
|
|
19674
|
+
void work.finally(() => modelRefreshWork.delete(work));
|
|
19289
19675
|
}
|
|
19290
|
-
|
|
19291
|
-
|
|
19292
|
-
|
|
19293
|
-
|
|
19294
|
-
|
|
19295
|
-
|
|
19296
|
-
|
|
19297
|
-
|
|
19298
|
-
|
|
19299
|
-
|
|
19300
|
-
|
|
19301
|
-
|
|
19676
|
+
return result;
|
|
19677
|
+
},
|
|
19678
|
+
appendDiagnosticTrace(instanceId, text) {
|
|
19679
|
+
try {
|
|
19680
|
+
diagnosticTraceWriter.append(instanceId, text);
|
|
19681
|
+
} catch (error) {
|
|
19682
|
+
app.log.warn({ error, instanceId }, "Could not append worker diagnostic trace");
|
|
19683
|
+
}
|
|
19684
|
+
},
|
|
19685
|
+
workerEventLogger: config.workers.log_worker_events_to_stdout ? (entry) => {
|
|
19686
|
+
app.log.info({ source: "worker_event", ...entry }, "worker.event");
|
|
19687
|
+
} : void 0
|
|
19302
19688
|
},
|
|
19303
|
-
|
|
19304
|
-
|
|
19689
|
+
{
|
|
19690
|
+
onTurnTerminalRecorded(instanceId, workerId, turnRecordId) {
|
|
19691
|
+
supervisor?.acknowledgeTurnTerminal(instanceId, workerId, { turnRecordId });
|
|
19692
|
+
},
|
|
19693
|
+
onTurnFailedRecorded(input) {
|
|
19694
|
+
app.log.warn(input, "Worker turn failed");
|
|
19695
|
+
},
|
|
19696
|
+
onTurnTerminalRecordingFailed(input) {
|
|
19697
|
+
app.log.error(input, "Worker turn terminal recording failed");
|
|
19698
|
+
baseDeps.events.create({
|
|
19699
|
+
instanceId: input.instanceId,
|
|
19700
|
+
eventType: "worker_terminal_recording_failed",
|
|
19701
|
+
data: {
|
|
19702
|
+
workerId: input.workerId,
|
|
19703
|
+
turnRecordId: input.turnRecordId,
|
|
19704
|
+
terminalType: input.terminalType,
|
|
19705
|
+
code: input.code,
|
|
19706
|
+
message: input.message
|
|
19707
|
+
}
|
|
19708
|
+
});
|
|
19709
|
+
},
|
|
19710
|
+
onWorkerTurnStartAccepted(instanceId, workerId, payload) {
|
|
19711
|
+
supervisor?.acceptTurnStart(
|
|
19712
|
+
instanceId,
|
|
19713
|
+
workerId,
|
|
19714
|
+
payload.startRecordId,
|
|
19715
|
+
payload.turnRecordId
|
|
19716
|
+
);
|
|
19717
|
+
},
|
|
19718
|
+
onCredentialUpdateResult(instanceId, workerId, payload) {
|
|
19719
|
+
supervisor?.credentialUpdateResult(instanceId, workerId, payload);
|
|
19720
|
+
},
|
|
19721
|
+
onIntegrationToolResult(instanceId, workerId, payload) {
|
|
19722
|
+
supervisor?.integrationToolResult(instanceId, workerId, payload);
|
|
19723
|
+
}
|
|
19305
19724
|
}
|
|
19306
|
-
}
|
|
19307
|
-
);
|
|
19308
|
-
const repositoryCredentials = new RepositoryCredentialService(extensionCatalog.processes);
|
|
19309
|
-
const sessionTransferLimits = config.session_transfer ? {
|
|
19310
|
-
maxEntries: config.session_transfer.max_entries,
|
|
19311
|
-
maxLogicalBytes: config.session_transfer.max_logical_bytes,
|
|
19312
|
-
maxCompressedBytes: config.session_transfer.max_compressed_bytes
|
|
19313
|
-
} : DEFAULT_SESSION_TRANSFER_LIMITS;
|
|
19314
|
-
const sessionTransferHelperRelays = createSessionTransferHelperRelays({
|
|
19315
|
-
repos: baseDeps,
|
|
19316
|
-
limits: sessionTransferLimits
|
|
19317
|
-
});
|
|
19318
|
-
const supervisorConfig = config;
|
|
19319
|
-
const runnerRuntime = await createConfiguredWorkerRunnerRuntime({
|
|
19320
|
-
config: supervisorConfig,
|
|
19321
|
-
webSocketIpc: workerWebSocketIpc,
|
|
19322
|
-
provided: opts.workerRunnerRuntime,
|
|
19323
|
-
helperRelays: sessionTransferHelperRelays,
|
|
19324
|
-
onVolumePoolError: () => app.log.warn("Volume pre-provisioning failed; retrying in the background"),
|
|
19325
|
-
localWorkerSpawnImpl: opts.localWorkerSpawnImpl,
|
|
19326
|
-
localWorkerDockerPreflightImpl: opts.localWorkerDockerPreflightImpl
|
|
19327
|
-
});
|
|
19328
|
-
if (runnerRuntime.volumePool) {
|
|
19329
|
-
startHooks.push(() => runnerRuntime.volumePool?.start());
|
|
19330
|
-
stopHooks.push(() => runnerRuntime.volumePool?.stop());
|
|
19331
|
-
}
|
|
19332
|
-
markStartup("worker_runner");
|
|
19333
|
-
supervisor = createWorkerSupervisor({
|
|
19334
|
-
startupObservations: baseDeps.startupObservations,
|
|
19335
|
-
config: supervisorConfig,
|
|
19336
|
-
processGraphs,
|
|
19337
|
-
processActionRegistry,
|
|
19338
|
-
processModelPolicy,
|
|
19339
|
-
ipcHandler,
|
|
19340
|
-
leases: baseDeps.leases,
|
|
19341
|
-
getLaunchCoordinator: () => launchCoordinator,
|
|
19342
|
-
processes: baseDeps.processes,
|
|
19343
|
-
projects: baseDeps.projects,
|
|
19344
|
-
inputs: baseDeps.inputs,
|
|
19345
|
-
turnRecords: baseDeps.turnRecords,
|
|
19346
|
-
turnStarts: baseDeps.turnStarts,
|
|
19347
|
-
events: baseDeps.events,
|
|
19348
|
-
broadcaster,
|
|
19349
|
-
runnerRuntime,
|
|
19350
|
-
logger: app.log,
|
|
19351
|
-
resolvedExtensionEntriesJson: serializeResolvedExtensionEntries(resolvedExtensionEntries),
|
|
19352
|
-
serverEpoch,
|
|
19353
|
-
resolveResourceBundle(digest) {
|
|
19354
|
-
return piResourceBundles.get(digest);
|
|
19355
|
-
},
|
|
19356
|
-
resolveRepositoryCredentials: (input) => repositoryCredentials.resolveWorkerCredentials(input),
|
|
19357
|
-
integrationTools,
|
|
19358
|
-
resolveCredential: (providerId, options) => modelProviderCredentials.resolve(providerId, options)
|
|
19359
|
-
});
|
|
19360
|
-
let staleHeartbeatWatchdog = null;
|
|
19361
|
-
let retainedVolumeCleanupTimer = null;
|
|
19362
|
-
let retainedVolumeCleanupRunning = false;
|
|
19363
|
-
const releasedRetainedVolumes = /* @__PURE__ */ new Set();
|
|
19364
|
-
async function runRetainedVolumeCleanup() {
|
|
19365
|
-
if (retainedVolumeCleanupRunning) return;
|
|
19366
|
-
retainedVolumeCleanupRunning = true;
|
|
19367
|
-
const processes = baseDeps.processes.listAll();
|
|
19368
|
-
const now2 = /* @__PURE__ */ new Date();
|
|
19369
|
-
const policy = {
|
|
19370
|
-
completedProcessRetention: config.workers.cleanup.completed_process_retention,
|
|
19371
|
-
errorProcessRetention: config.workers.cleanup.error_process_retention
|
|
19372
|
-
};
|
|
19373
|
-
const expiredImageProcesses = new Set(
|
|
19374
|
-
planProcessVolumeRetentionCleanup({ processes, now: now2, policy })
|
|
19375
19725
|
);
|
|
19376
|
-
|
|
19377
|
-
|
|
19378
|
-
|
|
19379
|
-
|
|
19380
|
-
|
|
19381
|
-
|
|
19382
|
-
|
|
19383
|
-
|
|
19384
|
-
|
|
19385
|
-
}
|
|
19386
|
-
|
|
19387
|
-
|
|
19388
|
-
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19393
|
-
|
|
19394
|
-
|
|
19395
|
-
}
|
|
19396
|
-
|
|
19397
|
-
|
|
19398
|
-
|
|
19399
|
-
}
|
|
19400
|
-
}
|
|
19401
|
-
startHooks.push(() => {
|
|
19402
|
-
if (!supervisor) {
|
|
19403
|
-
throw new Error("worker supervisor not initialized");
|
|
19726
|
+
const repositoryCredentials = new RepositoryCredentialService(extensionCatalog.processes);
|
|
19727
|
+
const sessionTransferLimits = config.session_transfer ? {
|
|
19728
|
+
maxEntries: config.session_transfer.max_entries,
|
|
19729
|
+
maxLogicalBytes: config.session_transfer.max_logical_bytes,
|
|
19730
|
+
maxCompressedBytes: config.session_transfer.max_compressed_bytes
|
|
19731
|
+
} : DEFAULT_SESSION_TRANSFER_LIMITS;
|
|
19732
|
+
const sessionTransferHelperRelays = createSessionTransferHelperRelays({
|
|
19733
|
+
repos: baseDeps,
|
|
19734
|
+
limits: sessionTransferLimits
|
|
19735
|
+
});
|
|
19736
|
+
const supervisorConfig = config;
|
|
19737
|
+
const runnerRuntime = await createConfiguredWorkerRunnerRuntime({
|
|
19738
|
+
config: supervisorConfig,
|
|
19739
|
+
webSocketIpc: workerWebSocketIpc,
|
|
19740
|
+
provided: opts.workerRunnerRuntime,
|
|
19741
|
+
helperRelays: sessionTransferHelperRelays,
|
|
19742
|
+
onVolumePoolError: () => app.log.warn("Volume pre-provisioning failed; retrying in the background"),
|
|
19743
|
+
localWorkerSpawnImpl: opts.localWorkerSpawnImpl,
|
|
19744
|
+
localWorkerDockerPreflightImpl: opts.localWorkerDockerPreflightImpl
|
|
19745
|
+
});
|
|
19746
|
+
if (runnerRuntime.volumePool) {
|
|
19747
|
+
startHooks.push(() => runnerRuntime.volumePool?.start());
|
|
19748
|
+
stopHooks.push(() => runnerRuntime.volumePool?.stop());
|
|
19404
19749
|
}
|
|
19405
|
-
|
|
19406
|
-
|
|
19407
|
-
|
|
19408
|
-
|
|
19409
|
-
|
|
19410
|
-
|
|
19411
|
-
|
|
19412
|
-
|
|
19413
|
-
);
|
|
19414
|
-
staleHeartbeatWatchdog = startStaleHeartbeatWatchdog({
|
|
19750
|
+
markStartup("worker_runner");
|
|
19751
|
+
supervisor = createWorkerSupervisor({
|
|
19752
|
+
startupObservations: baseDeps.startupObservations,
|
|
19753
|
+
config: supervisorConfig,
|
|
19754
|
+
processGraphs,
|
|
19755
|
+
processActionRegistry,
|
|
19756
|
+
processModelPolicy,
|
|
19757
|
+
ipcHandler,
|
|
19415
19758
|
leases: baseDeps.leases,
|
|
19759
|
+
getLaunchCoordinator: () => launchCoordinator,
|
|
19416
19760
|
processes: baseDeps.processes,
|
|
19761
|
+
projects: baseDeps.projects,
|
|
19762
|
+
inputs: baseDeps.inputs,
|
|
19417
19763
|
turnRecords: baseDeps.turnRecords,
|
|
19418
19764
|
turnStarts: baseDeps.turnStarts,
|
|
19419
|
-
|
|
19420
|
-
|
|
19421
|
-
|
|
19765
|
+
events: baseDeps.events,
|
|
19766
|
+
broadcaster,
|
|
19767
|
+
runnerRuntime,
|
|
19768
|
+
logger: app.log,
|
|
19769
|
+
resolvedExtensionEntriesJson: serializeResolvedExtensionEntries(resolvedExtensionEntries),
|
|
19770
|
+
serverEpoch,
|
|
19771
|
+
resolveResourceBundle(digest) {
|
|
19772
|
+
return piResourceBundles.get(digest);
|
|
19773
|
+
},
|
|
19774
|
+
resolveRepositoryCredentials: (input) => repositoryCredentials.resolveWorkerCredentials(input),
|
|
19775
|
+
integrationTools,
|
|
19776
|
+
resolveCredential: (providerId, options) => modelProviderCredentials.resolve(providerId, options)
|
|
19422
19777
|
});
|
|
19423
|
-
|
|
19424
|
-
|
|
19425
|
-
|
|
19426
|
-
|
|
19427
|
-
|
|
19428
|
-
|
|
19429
|
-
|
|
19778
|
+
let staleHeartbeatWatchdog = null;
|
|
19779
|
+
let workersClosedForServerShutdown = false;
|
|
19780
|
+
stopAcquiredWorkers = async () => {
|
|
19781
|
+
if (workersClosedForServerShutdown) return;
|
|
19782
|
+
workersClosedForServerShutdown = true;
|
|
19783
|
+
if (config.workers.runner === "local") await supervisor?.shutdownAll("server_shutdown");
|
|
19784
|
+
else await supervisor?.detachAll("server_shutdown");
|
|
19785
|
+
};
|
|
19786
|
+
let retentionWork;
|
|
19787
|
+
let retainedVolumeCleanupTimer = null;
|
|
19788
|
+
let retainedVolumeCleanupRunning = false;
|
|
19789
|
+
const releasedRetainedVolumes = /* @__PURE__ */ new Set();
|
|
19790
|
+
async function runRetainedVolumeCleanup() {
|
|
19791
|
+
if (retainedVolumeCleanupRunning) return;
|
|
19792
|
+
retainedVolumeCleanupRunning = true;
|
|
19793
|
+
const processes = baseDeps.processes.listAll();
|
|
19794
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
19795
|
+
const policy = {
|
|
19796
|
+
completedProcessRetention: config.workers.cleanup.completed_process_retention,
|
|
19797
|
+
errorProcessRetention: config.workers.cleanup.error_process_retention
|
|
19798
|
+
};
|
|
19799
|
+
const expiredImageProcesses = new Set(
|
|
19800
|
+
planProcessVolumeRetentionCleanup({ processes, now: now2, policy })
|
|
19801
|
+
);
|
|
19802
|
+
try {
|
|
19803
|
+
const released = await cleanupRetainedProcessVolumes({
|
|
19804
|
+
volume: runnerRuntime.volume,
|
|
19805
|
+
processes,
|
|
19806
|
+
now: now2,
|
|
19807
|
+
policy,
|
|
19808
|
+
alreadyReleased: releasedRetainedVolumes
|
|
19809
|
+
});
|
|
19810
|
+
for (const instanceId of released) releasedRetainedVolumes.add(instanceId);
|
|
19811
|
+
} catch (error) {
|
|
19812
|
+
app.log.warn({ error }, "retained process volume cleanup failed");
|
|
19813
|
+
}
|
|
19814
|
+
try {
|
|
19815
|
+
await resultImages.cleanupProcesses({
|
|
19816
|
+
// Refresh after volume cleanup so a process created during the sweep is
|
|
19817
|
+
// never mistaken for an orphan.
|
|
19818
|
+
retainedInstanceIds: new Set(baseDeps.processes.listAll().map((process2) => process2.id)),
|
|
19819
|
+
expiredInstanceIds: expiredImageProcesses
|
|
19820
|
+
});
|
|
19821
|
+
} catch (error) {
|
|
19822
|
+
app.log.warn({ error }, "retained result image cleanup failed");
|
|
19823
|
+
} finally {
|
|
19824
|
+
retainedVolumeCleanupRunning = false;
|
|
19825
|
+
}
|
|
19430
19826
|
}
|
|
19431
|
-
|
|
19432
|
-
|
|
19433
|
-
|
|
19434
|
-
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
19441
|
-
|
|
19442
|
-
|
|
19443
|
-
|
|
19444
|
-
|
|
19445
|
-
|
|
19446
|
-
|
|
19447
|
-
|
|
19448
|
-
|
|
19449
|
-
|
|
19450
|
-
|
|
19451
|
-
|
|
19452
|
-
|
|
19453
|
-
|
|
19454
|
-
|
|
19455
|
-
|
|
19456
|
-
|
|
19457
|
-
|
|
19458
|
-
|
|
19459
|
-
|
|
19460
|
-
|
|
19461
|
-
|
|
19462
|
-
|
|
19463
|
-
|
|
19464
|
-
|
|
19465
|
-
|
|
19466
|
-
|
|
19467
|
-
|
|
19468
|
-
|
|
19469
|
-
|
|
19470
|
-
|
|
19471
|
-
|
|
19472
|
-
|
|
19473
|
-
|
|
19474
|
-
|
|
19475
|
-
processOperations,
|
|
19476
|
-
processTitles,
|
|
19477
|
-
extensionHost,
|
|
19478
|
-
launcherService,
|
|
19479
|
-
launcherRecentValues,
|
|
19480
|
-
processGraphs,
|
|
19481
|
-
processActionRegistry: processActionRegistry ?? void 0,
|
|
19482
|
-
processModelPolicy,
|
|
19483
|
-
launchPlans,
|
|
19484
|
-
modelStatusCache,
|
|
19485
|
-
launchPipeline,
|
|
19486
|
-
assertRuntimeAvailable: (processId) => assertProcessRuntimeAvailable(
|
|
19827
|
+
startHooks.push(() => {
|
|
19828
|
+
if (!supervisor) {
|
|
19829
|
+
throw new Error("worker supervisor not initialized");
|
|
19830
|
+
}
|
|
19831
|
+
retentionWork = runRetainedVolumeCleanup();
|
|
19832
|
+
const cleanupIntervalMs = Math.max(
|
|
19833
|
+
6e4,
|
|
19834
|
+
parseDurationMs8(config.workers.cleanup.transient_ttl, 36e5, { allowHours: true })
|
|
19835
|
+
);
|
|
19836
|
+
retainedVolumeCleanupTimer = setInterval(() => {
|
|
19837
|
+
if (!retainedVolumeCleanupRunning) retentionWork = runRetainedVolumeCleanup();
|
|
19838
|
+
}, cleanupIntervalMs);
|
|
19839
|
+
staleHeartbeatWatchdog = startStaleHeartbeatWatchdog({
|
|
19840
|
+
leases: baseDeps.leases,
|
|
19841
|
+
processes: baseDeps.processes,
|
|
19842
|
+
turnRecords: baseDeps.turnRecords,
|
|
19843
|
+
turnStarts: baseDeps.turnStarts,
|
|
19844
|
+
ipcHandler,
|
|
19845
|
+
supervisor,
|
|
19846
|
+
staleHeartbeatTimeout: config.workers.stale_heartbeat_timeout
|
|
19847
|
+
});
|
|
19848
|
+
});
|
|
19849
|
+
stopHooks.push(async () => {
|
|
19850
|
+
staleHeartbeatWatchdog?.stop();
|
|
19851
|
+
staleHeartbeatWatchdog = null;
|
|
19852
|
+
if (retainedVolumeCleanupTimer) {
|
|
19853
|
+
clearInterval(retainedVolumeCleanupTimer);
|
|
19854
|
+
retainedVolumeCleanupTimer = null;
|
|
19855
|
+
}
|
|
19856
|
+
await retentionWork;
|
|
19857
|
+
});
|
|
19858
|
+
if (processTitles?.start) {
|
|
19859
|
+
startHooks.push(() => processTitles.start?.());
|
|
19860
|
+
}
|
|
19861
|
+
if (processTitles?.close) {
|
|
19862
|
+
stopHooks.push(() => processTitles.close?.());
|
|
19863
|
+
}
|
|
19864
|
+
const launchPipeline = createLaunchPipeline({
|
|
19865
|
+
launchRuns: baseDeps.launchRuns,
|
|
19866
|
+
broadcaster,
|
|
19867
|
+
titleGenerationAvailable: Boolean(processTitles),
|
|
19868
|
+
logger: app.log
|
|
19869
|
+
});
|
|
19870
|
+
const assertRuntimeAvailable = (processId) => assertProcessRuntimeAvailable(
|
|
19487
19871
|
{
|
|
19488
19872
|
config,
|
|
19489
19873
|
processes: extensionCatalog.processes,
|
|
19490
19874
|
dockerInfo: opts.localWorkerDockerPreflightImpl
|
|
19491
19875
|
},
|
|
19492
19876
|
processId
|
|
19493
|
-
)
|
|
19494
|
-
|
|
19495
|
-
|
|
19496
|
-
|
|
19497
|
-
|
|
19498
|
-
|
|
19499
|
-
|
|
19500
|
-
|
|
19501
|
-
|
|
19502
|
-
|
|
19503
|
-
|
|
19504
|
-
|
|
19505
|
-
|
|
19506
|
-
|
|
19507
|
-
|
|
19508
|
-
|
|
19509
|
-
|
|
19510
|
-
|
|
19511
|
-
|
|
19512
|
-
|
|
19513
|
-
|
|
19514
|
-
|
|
19515
|
-
|
|
19516
|
-
|
|
19517
|
-
|
|
19518
|
-
|
|
19519
|
-
|
|
19520
|
-
|
|
19521
|
-
|
|
19522
|
-
|
|
19523
|
-
|
|
19524
|
-
|
|
19525
|
-
|
|
19526
|
-
|
|
19527
|
-
|
|
19528
|
-
|
|
19529
|
-
|
|
19530
|
-
|
|
19531
|
-
|
|
19532
|
-
|
|
19533
|
-
|
|
19534
|
-
|
|
19535
|
-
|
|
19536
|
-
|
|
19537
|
-
|
|
19538
|
-
|
|
19539
|
-
|
|
19540
|
-
|
|
19541
|
-
|
|
19542
|
-
|
|
19543
|
-
|
|
19544
|
-
|
|
19545
|
-
|
|
19546
|
-
|
|
19547
|
-
|
|
19548
|
-
|
|
19549
|
-
|
|
19550
|
-
|
|
19551
|
-
|
|
19552
|
-
|
|
19553
|
-
|
|
19554
|
-
|
|
19555
|
-
|
|
19556
|
-
|
|
19557
|
-
|
|
19558
|
-
|
|
19559
|
-
|
|
19560
|
-
|
|
19561
|
-
|
|
19562
|
-
|
|
19563
|
-
|
|
19564
|
-
|
|
19565
|
-
processes: baseDeps.processes,
|
|
19566
|
-
processEngine,
|
|
19567
|
-
processOperations,
|
|
19568
|
-
supervisor,
|
|
19569
|
-
volume: runnerRuntime.volume,
|
|
19570
|
-
sessionSnapshots,
|
|
19571
|
-
resultImages,
|
|
19572
|
-
sessionTransfers,
|
|
19573
|
-
deletionPending,
|
|
19574
|
-
broadcaster,
|
|
19575
|
-
logger: app.log
|
|
19576
|
-
});
|
|
19577
|
-
const processActionListDeps = {
|
|
19578
|
-
projects: baseDeps.projects,
|
|
19579
|
-
futureExecutions: baseDeps.futureExecutions,
|
|
19580
|
-
turnRecords: baseDeps.turnRecords,
|
|
19581
|
-
turnStarts: baseDeps.turnStarts,
|
|
19582
|
-
processGraphs,
|
|
19583
|
-
processActionRegistry
|
|
19584
|
-
};
|
|
19585
|
-
const processModelSelection = createProcessModelSelection({
|
|
19586
|
-
processGraphs,
|
|
19587
|
-
processActionRegistry,
|
|
19588
|
-
processes: baseDeps.processes,
|
|
19589
|
-
projects: baseDeps.projects,
|
|
19590
|
-
scheduledActions: baseDeps.futureExecutions,
|
|
19591
|
-
turnRecords: baseDeps.turnRecords,
|
|
19592
|
-
turnStarts: baseDeps.turnStarts,
|
|
19593
|
-
instanceTrees: sessionReader,
|
|
19594
|
-
processModelPolicy,
|
|
19595
|
-
modelStatusCache
|
|
19596
|
-
});
|
|
19597
|
-
const hostCapabilities = buildHostCapabilities({
|
|
19598
|
-
config,
|
|
19599
|
-
baseDeps,
|
|
19600
|
-
projectMutations,
|
|
19601
|
-
commands: processEngine,
|
|
19602
|
-
getSupervisor: () => supervisor,
|
|
19603
|
-
listVisibleActionsForProcess(instanceId) {
|
|
19877
|
+
);
|
|
19878
|
+
const processLaunchDeps = {
|
|
19879
|
+
...baseDeps,
|
|
19880
|
+
broadcaster,
|
|
19881
|
+
commands: processEngine,
|
|
19882
|
+
processTitles,
|
|
19883
|
+
extensionHost,
|
|
19884
|
+
logger: app.log,
|
|
19885
|
+
repositoryCredentials,
|
|
19886
|
+
getSupervisor: () => supervisor,
|
|
19887
|
+
assertRuntimeAvailable
|
|
19888
|
+
};
|
|
19889
|
+
const createProcess = createProcessFromLaunchPlan.bind(null, processLaunchDeps);
|
|
19890
|
+
futureExecutionLifecycle = createFutureExecutionLifecycle({
|
|
19891
|
+
futureExecutions: baseDeps.futureExecutions,
|
|
19892
|
+
processes: baseDeps.processes,
|
|
19893
|
+
projects: baseDeps.projects,
|
|
19894
|
+
processRelations: baseDeps.processRelations,
|
|
19895
|
+
handoffDedupKeys: baseDeps.handoffDedupKeys,
|
|
19896
|
+
turnRecords: baseDeps.turnRecords,
|
|
19897
|
+
skills: baseDeps.skills,
|
|
19898
|
+
processSkills: baseDeps.processSkills,
|
|
19899
|
+
transaction: baseDeps.transaction,
|
|
19900
|
+
broadcaster,
|
|
19901
|
+
commands: processEngine,
|
|
19902
|
+
processOperations,
|
|
19903
|
+
processTitles,
|
|
19904
|
+
extensionHost,
|
|
19905
|
+
launcherService,
|
|
19906
|
+
launcherRecentValues,
|
|
19907
|
+
processGraphs,
|
|
19908
|
+
processActionRegistry: processActionRegistry ?? void 0,
|
|
19909
|
+
processModelPolicy,
|
|
19910
|
+
launchPlans,
|
|
19911
|
+
modelStatusCache,
|
|
19912
|
+
launchPipeline,
|
|
19913
|
+
assertRuntimeAvailable,
|
|
19914
|
+
logger: app.log
|
|
19915
|
+
});
|
|
19916
|
+
applyGeneratedFutureExecutionTitle = (input) => futureExecutionLifecycle.applyGeneratedFutureLaunchTitleIfUnchanged(input);
|
|
19917
|
+
launchCoordinator = createLaunchCoordinator({
|
|
19918
|
+
events: baseDeps.events,
|
|
19919
|
+
commands: processEngine,
|
|
19920
|
+
launchRuns: baseDeps.launchRuns,
|
|
19921
|
+
processes: baseDeps.processes,
|
|
19922
|
+
leases: baseDeps.leases,
|
|
19923
|
+
turnRecords: baseDeps.turnRecords,
|
|
19924
|
+
turnStarts: baseDeps.turnStarts,
|
|
19925
|
+
titleJobs: baseDeps.titleJobs,
|
|
19926
|
+
launcherService,
|
|
19927
|
+
futureExecutionLifecycle,
|
|
19928
|
+
launchPipeline,
|
|
19929
|
+
launchPlans,
|
|
19930
|
+
createProcessFromLaunchPlan: createProcess,
|
|
19931
|
+
titleGenerationAvailable: Boolean(processTitles),
|
|
19932
|
+
logger: app.log
|
|
19933
|
+
});
|
|
19934
|
+
startHooks.push(() => launchCoordinator?.reconcileIncomplete());
|
|
19935
|
+
const futureExecutionScheduler = startFutureExecutionScheduler(futureExecutionLifecycle);
|
|
19936
|
+
startHooks.push(() => futureExecutionScheduler.start());
|
|
19937
|
+
stopHooks.push(() => futureExecutionScheduler.stop());
|
|
19938
|
+
const externalSourceService = createExternalSourceService({
|
|
19939
|
+
events: baseDeps.events,
|
|
19940
|
+
processes: baseDeps.processes,
|
|
19941
|
+
projects: baseDeps.projects,
|
|
19942
|
+
pendingExternalSourceFires: baseDeps.pendingExternalSourceFires,
|
|
19943
|
+
commands: processEngine,
|
|
19944
|
+
processActionRegistry
|
|
19945
|
+
});
|
|
19946
|
+
invalidateExternalSourceArmings = (instanceId) => externalSourceService.invalidateArmings(instanceId);
|
|
19947
|
+
startHooks.push(() => externalSourceService.reconcileAllArmings());
|
|
19948
|
+
afterSuccessHooks.add(async (instanceId) => {
|
|
19604
19949
|
const process2 = baseDeps.processes.getById(instanceId);
|
|
19605
|
-
|
|
19606
|
-
|
|
19607
|
-
|
|
19608
|
-
|
|
19609
|
-
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19613
|
-
|
|
19614
|
-
|
|
19615
|
-
|
|
19616
|
-
|
|
19617
|
-
|
|
19618
|
-
|
|
19619
|
-
|
|
19620
|
-
});
|
|
19621
|
-
await setupServerExtensions(
|
|
19622
|
-
extensionCatalog,
|
|
19623
|
-
{
|
|
19624
|
-
events: extensionHost,
|
|
19950
|
+
if (process2) piResourceBundlePins.reconcile(process2);
|
|
19951
|
+
await externalSourceService.reconcileArmings(instanceId);
|
|
19952
|
+
await externalSourceService.drainQueued(instanceId);
|
|
19953
|
+
});
|
|
19954
|
+
if (!supervisor) throw new Error("worker supervisor not initialized");
|
|
19955
|
+
const deletionPending = /* @__PURE__ */ new Set();
|
|
19956
|
+
const sessionTransfers = createSessionTransferService({
|
|
19957
|
+
repos: baseDeps,
|
|
19958
|
+
processOperations,
|
|
19959
|
+
supervisor,
|
|
19960
|
+
exporter: runnerRuntime.exporter,
|
|
19961
|
+
helperRelays: sessionTransferHelperRelays,
|
|
19962
|
+
sessionSource: sessionSnapshots,
|
|
19963
|
+
config,
|
|
19964
|
+
limits: sessionTransferLimits,
|
|
19625
19965
|
logger: app.log,
|
|
19626
|
-
|
|
19627
|
-
|
|
19628
|
-
|
|
19629
|
-
|
|
19630
|
-
|
|
19631
|
-
|
|
19632
|
-
},
|
|
19633
|
-
onStop(handler) {
|
|
19634
|
-
stopHooks.push(handler);
|
|
19635
|
-
}
|
|
19636
|
-
},
|
|
19637
|
-
(id) => config.extensions?.[id]
|
|
19638
|
-
);
|
|
19639
|
-
integrationTools.validateTicketProcesses(extensionCatalog.processes);
|
|
19640
|
-
startHooks.push(() => polling.start());
|
|
19641
|
-
stopHooks.push(() => polling.stop());
|
|
19642
|
-
for (const process2 of extensionCatalog.processes.values()) {
|
|
19643
|
-
for (const [turnId, binding2] of process2.turns) {
|
|
19644
|
-
const definition = binding2.definition;
|
|
19645
|
-
if (definition.kind !== "llm" || !definition.integrationTools?.length) continue;
|
|
19646
|
-
try {
|
|
19647
|
-
integrationTools.declarations(definition.integrationTools);
|
|
19648
|
-
} catch (error) {
|
|
19649
|
-
throw new Error(
|
|
19650
|
-
`Invalid integration tools for process '${process2.id}' turn '${turnId}': ${error instanceof Error ? error.message : String(error)}`
|
|
19966
|
+
isDeletionPending: (instanceId) => deletionPending.has(instanceId),
|
|
19967
|
+
onUpdated: (attempt) => {
|
|
19968
|
+
broadcaster.sendDurable(
|
|
19969
|
+
"session_transfer.updated",
|
|
19970
|
+
{ attemptId: attempt.id },
|
|
19971
|
+
attempt.instanceId
|
|
19651
19972
|
);
|
|
19652
19973
|
}
|
|
19653
|
-
}
|
|
19654
|
-
|
|
19655
|
-
|
|
19656
|
-
|
|
19657
|
-
|
|
19658
|
-
|
|
19659
|
-
|
|
19660
|
-
|
|
19661
|
-
|
|
19662
|
-
|
|
19663
|
-
|
|
19664
|
-
|
|
19665
|
-
|
|
19666
|
-
|
|
19667
|
-
|
|
19668
|
-
|
|
19669
|
-
|
|
19670
|
-
|
|
19671
|
-
|
|
19672
|
-
|
|
19673
|
-
|
|
19674
|
-
|
|
19675
|
-
|
|
19676
|
-
|
|
19677
|
-
|
|
19678
|
-
|
|
19679
|
-
|
|
19680
|
-
|
|
19681
|
-
|
|
19682
|
-
|
|
19683
|
-
|
|
19684
|
-
|
|
19685
|
-
|
|
19686
|
-
|
|
19687
|
-
|
|
19688
|
-
|
|
19689
|
-
|
|
19690
|
-
|
|
19691
|
-
|
|
19692
|
-
|
|
19693
|
-
|
|
19694
|
-
|
|
19695
|
-
|
|
19696
|
-
|
|
19697
|
-
|
|
19698
|
-
|
|
19699
|
-
|
|
19700
|
-
|
|
19701
|
-
|
|
19702
|
-
|
|
19703
|
-
|
|
19704
|
-
|
|
19705
|
-
|
|
19706
|
-
|
|
19707
|
-
|
|
19708
|
-
|
|
19709
|
-
|
|
19710
|
-
|
|
19711
|
-
|
|
19712
|
-
|
|
19713
|
-
|
|
19714
|
-
|
|
19715
|
-
|
|
19716
|
-
|
|
19717
|
-
|
|
19718
|
-
|
|
19719
|
-
|
|
19720
|
-
|
|
19721
|
-
|
|
19722
|
-
|
|
19723
|
-
|
|
19724
|
-
|
|
19974
|
+
});
|
|
19975
|
+
isNewTurnBlocked = (instanceId) => {
|
|
19976
|
+
const attempt = sessionTransfers.activeForProcess(instanceId);
|
|
19977
|
+
return attempt?.state === "queued" || attempt?.state === "exporting";
|
|
19978
|
+
};
|
|
19979
|
+
startHooks.push(async () => {
|
|
19980
|
+
await sessionTransfers.reconcile();
|
|
19981
|
+
sessionTransfers.start();
|
|
19982
|
+
});
|
|
19983
|
+
stopHooks.push(() => sessionTransfers.stop());
|
|
19984
|
+
const processDeletion = createProcessDeletionService({
|
|
19985
|
+
processes: baseDeps.processes,
|
|
19986
|
+
processEngine,
|
|
19987
|
+
processOperations,
|
|
19988
|
+
supervisor,
|
|
19989
|
+
volume: runnerRuntime.volume,
|
|
19990
|
+
sessionSnapshots,
|
|
19991
|
+
resultImages,
|
|
19992
|
+
sessionTransfers,
|
|
19993
|
+
deletionPending,
|
|
19994
|
+
broadcaster,
|
|
19995
|
+
logger: app.log
|
|
19996
|
+
});
|
|
19997
|
+
const processActionListDeps = {
|
|
19998
|
+
projects: baseDeps.projects,
|
|
19999
|
+
futureExecutions: baseDeps.futureExecutions,
|
|
20000
|
+
turnRecords: baseDeps.turnRecords,
|
|
20001
|
+
turnStarts: baseDeps.turnStarts,
|
|
20002
|
+
processGraphs,
|
|
20003
|
+
processActionRegistry
|
|
20004
|
+
};
|
|
20005
|
+
const processModelSelection = createProcessModelSelection({
|
|
20006
|
+
processGraphs,
|
|
20007
|
+
processActionRegistry,
|
|
20008
|
+
processes: baseDeps.processes,
|
|
20009
|
+
projects: baseDeps.projects,
|
|
20010
|
+
scheduledActions: baseDeps.futureExecutions,
|
|
20011
|
+
turnRecords: baseDeps.turnRecords,
|
|
20012
|
+
turnStarts: baseDeps.turnStarts,
|
|
20013
|
+
instanceTrees: sessionReader,
|
|
20014
|
+
processModelPolicy,
|
|
20015
|
+
modelStatusCache
|
|
20016
|
+
});
|
|
20017
|
+
const hostCapabilities = buildHostCapabilities({
|
|
20018
|
+
config,
|
|
20019
|
+
baseDeps,
|
|
20020
|
+
projectMutations,
|
|
20021
|
+
commands: processEngine,
|
|
20022
|
+
getSupervisor: () => supervisor,
|
|
20023
|
+
listVisibleActionsForProcess(instanceId) {
|
|
20024
|
+
const process2 = baseDeps.processes.getById(instanceId);
|
|
20025
|
+
return process2 ? listVisibleActionsForProcess(processActionListDeps, process2) : [];
|
|
20026
|
+
},
|
|
20027
|
+
launcherService,
|
|
20028
|
+
launcherRecentValues,
|
|
20029
|
+
launcherModelConfigs,
|
|
20030
|
+
launchPlans,
|
|
20031
|
+
processWatcherService,
|
|
20032
|
+
polling,
|
|
20033
|
+
externalSourceService,
|
|
20034
|
+
processModelSelection,
|
|
20035
|
+
resultImages,
|
|
20036
|
+
repositoryCredentials,
|
|
20037
|
+
processQuestions,
|
|
20038
|
+
launchCoordinator,
|
|
20039
|
+
preProvidedCapabilities: opts.preProvidedCapabilities
|
|
20040
|
+
});
|
|
20041
|
+
await setupServerExtensions(
|
|
20042
|
+
extensionCatalog,
|
|
20043
|
+
{
|
|
20044
|
+
events: extensionHost,
|
|
20045
|
+
logger: app.log,
|
|
20046
|
+
provide: hostCapabilities.provide.bind(hostCapabilities),
|
|
20047
|
+
get: hostCapabilities.get.bind(hostCapabilities),
|
|
20048
|
+
require: hostCapabilities.require.bind(hostCapabilities),
|
|
20049
|
+
tool: (definition) => integrationTools.register(definition),
|
|
20050
|
+
onStart(handler) {
|
|
20051
|
+
startHooks.push(handler);
|
|
20052
|
+
},
|
|
20053
|
+
onStop(handler) {
|
|
20054
|
+
stopHooks.push(handler);
|
|
20055
|
+
}
|
|
20056
|
+
},
|
|
20057
|
+
(id) => config.extensions?.[id]
|
|
20058
|
+
);
|
|
20059
|
+
integrationTools.validateTicketProcesses(extensionCatalog.processes);
|
|
20060
|
+
startHooks.push(() => polling.start());
|
|
20061
|
+
stopHooks.push(() => polling.stop());
|
|
20062
|
+
for (const process2 of extensionCatalog.processes.values()) {
|
|
20063
|
+
for (const [turnId, binding2] of process2.turns) {
|
|
20064
|
+
const definition = binding2.definition;
|
|
20065
|
+
if (definition.kind !== "llm" || !definition.integrationTools?.length) continue;
|
|
20066
|
+
try {
|
|
20067
|
+
integrationTools.declarations(definition.integrationTools);
|
|
20068
|
+
} catch (error) {
|
|
20069
|
+
throw new Error(
|
|
20070
|
+
`Invalid integration tools for process '${process2.id}' turn '${turnId}': ${error instanceof Error ? error.message : String(error)}`
|
|
20071
|
+
);
|
|
20072
|
+
}
|
|
19725
20073
|
}
|
|
19726
20074
|
}
|
|
19727
|
-
|
|
19728
|
-
|
|
19729
|
-
|
|
19730
|
-
|
|
19731
|
-
|
|
19732
|
-
|
|
19733
|
-
|
|
19734
|
-
|
|
19735
|
-
|
|
19736
|
-
|
|
19737
|
-
|
|
19738
|
-
|
|
19739
|
-
|
|
19740
|
-
|
|
19741
|
-
|
|
19742
|
-
|
|
19743
|
-
|
|
19744
|
-
|
|
19745
|
-
|
|
19746
|
-
|
|
19747
|
-
|
|
20075
|
+
markStartup("server_extensions");
|
|
20076
|
+
const deps = {
|
|
20077
|
+
externalSourceService,
|
|
20078
|
+
...baseDeps,
|
|
20079
|
+
launchCoordinator,
|
|
20080
|
+
processGraphs,
|
|
20081
|
+
supervisor,
|
|
20082
|
+
processEngine,
|
|
20083
|
+
processQuestions,
|
|
20084
|
+
toolApprovalGate,
|
|
20085
|
+
processDeletion,
|
|
20086
|
+
processActionRegistry,
|
|
20087
|
+
processUiRegistry,
|
|
20088
|
+
extensionHost,
|
|
20089
|
+
launcherService,
|
|
20090
|
+
launcherRecentValues,
|
|
20091
|
+
launchPlans,
|
|
20092
|
+
processTitles,
|
|
20093
|
+
toolRenderers: extensionCatalog.toolRenderers,
|
|
20094
|
+
config,
|
|
20095
|
+
sessionReader,
|
|
20096
|
+
futureExecutionLifecycle,
|
|
20097
|
+
modelProviderRegistry,
|
|
20098
|
+
modelProviderCredentialStatus: modelProviderCredentials.status,
|
|
20099
|
+
modelStatusCache,
|
|
20100
|
+
processModelPolicy,
|
|
20101
|
+
processModelSelection,
|
|
20102
|
+
skillCatalog,
|
|
20103
|
+
sessionTransferService: sessionTransfers
|
|
20104
|
+
};
|
|
20105
|
+
registerHttp({
|
|
20106
|
+
app,
|
|
20107
|
+
isReady: () => lifecycle.isReady(),
|
|
20108
|
+
deps,
|
|
20109
|
+
authService,
|
|
20110
|
+
processWatcherService,
|
|
20111
|
+
extensionUiCatalog,
|
|
20112
|
+
integrationTools,
|
|
20113
|
+
sessionSnapshots,
|
|
20114
|
+
resultImages,
|
|
20115
|
+
maxSessionSnapshotBytes: config.workers.session_snapshot_max_size_bytes,
|
|
20116
|
+
extensionUiAssetCacheControl: process.env.LEITWERK_RUNTIME_LANE === "source" ? "no-store" : void 0
|
|
20117
|
+
});
|
|
20118
|
+
markStartup("routes_ready");
|
|
20119
|
+
const lifecycle = createAppLifecycle({
|
|
20120
|
+
app,
|
|
20121
|
+
server: config.server,
|
|
20122
|
+
authEnabled: authService.config.enabled,
|
|
20123
|
+
reconcile: reconcileStartup,
|
|
20124
|
+
startHooks,
|
|
20125
|
+
preCloseCleanup,
|
|
20126
|
+
closeDatabase: () => closeOwnedDatabase?.()
|
|
20127
|
+
});
|
|
20128
|
+
finishCleanup = lifecycle.finishCleanup;
|
|
20129
|
+
return {
|
|
20130
|
+
app,
|
|
20131
|
+
db,
|
|
20132
|
+
broadcaster,
|
|
20133
|
+
config,
|
|
20134
|
+
deps,
|
|
20135
|
+
modelProviderRegistry,
|
|
20136
|
+
modelProviderServerAdapters,
|
|
20137
|
+
modelStatusCache,
|
|
20138
|
+
extensionUiCatalog,
|
|
20139
|
+
processGraphs,
|
|
20140
|
+
extensionHost,
|
|
20141
|
+
projectMutations,
|
|
20142
|
+
ipcHandler,
|
|
20143
|
+
supervisor,
|
|
20144
|
+
listen: lifecycle.listen,
|
|
20145
|
+
close: lifecycle.close,
|
|
20146
|
+
isReady: lifecycle.isReady
|
|
20147
|
+
};
|
|
20148
|
+
} catch (error) {
|
|
20149
|
+
const errors = [
|
|
20150
|
+
error,
|
|
20151
|
+
...await collectCleanupErrors([
|
|
20152
|
+
() => app.close(),
|
|
20153
|
+
() => closeOwnedDatabase?.(),
|
|
20154
|
+
...preCloseCleanup
|
|
20155
|
+
])
|
|
20156
|
+
];
|
|
20157
|
+
if (errors.length > 1)
|
|
20158
|
+
throw new AggregateError(errors, "Context construction and cleanup failed", { cause: error });
|
|
20159
|
+
throw error;
|
|
20160
|
+
}
|
|
19748
20161
|
}
|
|
19749
20162
|
|
|
19750
20163
|
export {
|
|
19751
|
-
buildExtensionUiCatalog,
|
|
19752
|
-
resolveExtensionUiAssetPath,
|
|
19753
|
-
inferExtensionUiAssetContentType,
|
|
19754
|
-
createExtensionHost,
|
|
19755
|
-
buildTurnSelectionWrites,
|
|
19756
|
-
emitDeferredExtensionEvent,
|
|
19757
|
-
buildProjectUpdatedFrame,
|
|
19758
|
-
buildProjectUpdatedEffect,
|
|
19759
|
-
commitProjectCreate,
|
|
19760
|
-
commitProjectUpdate,
|
|
19761
|
-
createProjectMutationService,
|
|
19762
|
-
createBuiltinPiServerAdapter,
|
|
19763
|
-
createModelProviderCredentialService,
|
|
19764
|
-
createModelStatusCache,
|
|
19765
|
-
resolveRegisteredProviderOptions,
|
|
19766
|
-
validateConfiguredProviderOptions,
|
|
19767
|
-
loadProviderOptionChoices,
|
|
19768
|
-
defaultModelProviderCredentialStatus,
|
|
19769
|
-
createModelProviderRegistry,
|
|
19770
|
-
createModelProviderServerAdapterRegistry,
|
|
19771
|
-
assemblePiResourceSnapshot,
|
|
19772
|
-
PI_RESOURCE_SNAPSHOT_SCHEMA_VERSION2 as PI_RESOURCE_SNAPSHOT_SCHEMA_VERSION,
|
|
19773
|
-
createPiResourceBundleCache,
|
|
19774
|
-
createPiResourceBundlePinReconciler,
|
|
19775
|
-
buildParkProcessWrites,
|
|
19776
|
-
buildRetryWrites,
|
|
19777
|
-
buildTurnFailedWrites,
|
|
19778
|
-
buildTurnOutcomeWrites,
|
|
19779
|
-
createProcessEngine,
|
|
19780
|
-
shouldResumeProcessOnStartup,
|
|
19781
|
-
reconcileProcessesOnStartup,
|
|
19782
|
-
selectWorkerRuntimeProfile,
|
|
19783
|
-
buildRuntimeProfileSelectionInput,
|
|
19784
|
-
normalizeProcessTitle,
|
|
19785
|
-
buildProcessTitleSourceFields,
|
|
19786
|
-
buildProcessTitlePrompt,
|
|
19787
|
-
createProcessTitleGenerator,
|
|
19788
|
-
buildProcessWatcherRegistry,
|
|
19789
|
-
ResultImageStore,
|
|
19790
|
-
registerUiRendererRoutes,
|
|
19791
|
-
registerWatcherRoutes,
|
|
19792
|
-
resolveServerTlsOptions,
|
|
19793
|
-
createIpcHandler,
|
|
19794
|
-
createWorkerSupervisor,
|
|
19795
|
-
createApp,
|
|
19796
20164
|
createAppContext
|
|
19797
20165
|
};
|
|
19798
|
-
//# sourceMappingURL=chunk-
|
|
20166
|
+
//# sourceMappingURL=chunk-CNITOV76.js.map
|