@leitwerk-dev/server 0.3.1 → 0.4.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-BuJCdkvy.d.ts → app-CtlotzYm.d.ts} +312 -121
- package/dist/app-KR3N2JAE.js +8 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/auth/fastify-auth.d.ts +9 -0
- package/dist/auth/fastify-auth.d.ts.map +1 -1
- package/dist/{chunk-QCHS3X33.js → chunk-OUA5EZS2.js} +3127 -689
- package/dist/chunk-OUA5EZS2.js.map +1 -0
- package/dist/{chunk-HK6BLLHA.js → chunk-YLWY4UTT.js} +2424 -1580
- package/dist/chunk-YLWY4UTT.js.map +1 -0
- package/dist/config/config-loader.d.ts +1 -1
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-types.d.ts +16 -1
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/config/kubernetes-docker-isolation.d.ts +7 -0
- package/dist/config/kubernetes-docker-isolation.d.ts.map +1 -0
- package/dist/dashboard-model-issues.d.ts +10 -0
- package/dist/dashboard-model-issues.d.ts.map +1 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/execution-inspection-repo.d.ts +15 -0
- package/dist/db/execution-inspection-repo.d.ts.map +1 -0
- package/dist/db/history-window.d.ts +11 -0
- package/dist/db/history-window.d.ts.map +1 -0
- package/dist/db/process-event-repo.d.ts +2 -0
- package/dist/db/process-event-repo.d.ts.map +1 -1
- package/dist/db/process-instance-repo.d.ts +21 -1
- package/dist/db/process-instance-repo.d.ts.map +1 -1
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts +2 -1
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts.map +1 -1
- package/dist/db/process-project-repo.d.ts +2 -0
- package/dist/db/process-project-repo.d.ts.map +1 -1
- package/dist/db/process-skill-repo.d.ts.map +1 -1
- package/dist/db/process-turn-annotation-repo.d.ts +4 -1
- package/dist/db/process-turn-annotation-repo.d.ts.map +1 -1
- package/dist/db/process-turn-record-repo.d.ts +4 -0
- package/dist/db/process-turn-record-repo.d.ts.map +1 -1
- package/dist/db/publication-repo.d.ts +5 -0
- package/dist/db/publication-repo.d.ts.map +1 -0
- package/dist/db/repositories.d.ts +12 -0
- package/dist/db/repositories.d.ts.map +1 -1
- package/dist/db/schema.d.ts +693 -2
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/scoped-settings-repo.d.ts +37 -0
- package/dist/db/scoped-settings-repo.d.ts.map +1 -0
- package/dist/db/skill-repo.d.ts +3 -0
- package/dist/db/skill-repo.d.ts.map +1 -1
- package/dist/db/turn-start-record-repo.d.ts +2 -1
- package/dist/db/turn-start-record-repo.d.ts.map +1 -1
- package/dist/db/turn-summary-repo.d.ts +10 -1
- package/dist/db/turn-summary-repo.d.ts.map +1 -1
- package/dist/db/worker-lease-repo.d.ts +2 -1
- package/dist/db/worker-lease-repo.d.ts.map +1 -1
- package/dist/domain-logic/outcome-tools.d.ts.map +1 -1
- package/dist/domain-logic/worker-lease-lifecycle.d.ts.map +1 -1
- package/dist/external-source-service.d.ts.map +1 -1
- package/dist/future-execution/execution.d.ts +4 -1
- package/dist/future-execution/execution.d.ts.map +1 -1
- package/dist/future-execution/launch-lifecycle.d.ts +9 -25
- package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
- package/dist/future-execution/lifecycle.d.ts +3 -28
- package/dist/future-execution/lifecycle.d.ts.map +1 -1
- package/dist/future-execution/model-projection.d.ts.map +1 -1
- package/dist/future-execution/reconciliation.d.ts +1 -0
- package/dist/future-execution/reconciliation.d.ts.map +1 -1
- package/dist/future-execution-presenter.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/integration-tool-registry.d.ts +11 -2
- package/dist/integration-tool-registry.d.ts.map +1 -1
- package/dist/launch-coordinator.d.ts.map +1 -1
- package/dist/launcher-model-config-service.d.ts +7 -1
- package/dist/launcher-model-config-service.d.ts.map +1 -1
- package/dist/leaf-outcome-snapshot-capture.d.ts +1 -0
- package/dist/leaf-outcome-snapshot-capture.d.ts.map +1 -1
- package/dist/main.js +3 -3
- package/dist/primary-path-snapshot.d.ts.map +1 -1
- package/dist/process-action-presenter.d.ts +1 -6
- package/dist/process-action-presenter.d.ts.map +1 -1
- package/dist/process-action-registry.d.ts.map +1 -1
- package/dist/process-engine/decision.d.ts +2 -0
- package/dist/process-engine/decision.d.ts.map +1 -1
- package/dist/process-engine/engine.d.ts.map +1 -1
- package/dist/process-engine/mapped-turns.d.ts.map +1 -1
- package/dist/process-engine/ops/automatic-retry-startup.d.ts +8 -0
- package/dist/process-engine/ops/automatic-retry-startup.d.ts.map +1 -0
- package/dist/process-engine/ops/continue-failed-turn.d.ts.map +1 -1
- package/dist/process-engine/ops/process-observation.d.ts +6 -0
- package/dist/process-engine/ops/process-observation.d.ts.map +1 -0
- package/dist/process-engine/ops/retry-failed-turn.d.ts.map +1 -1
- package/dist/process-engine/ops/retry-startup.d.ts +2 -0
- package/dist/process-engine/ops/retry-startup.d.ts.map +1 -1
- package/dist/process-engine/ops/start-process.d.ts +2 -0
- package/dist/process-engine/ops/start-process.d.ts.map +1 -1
- package/dist/process-engine/ops/turn-outcome.d.ts.map +1 -1
- package/dist/process-engine/ops/turn-wait.d.ts +30 -0
- package/dist/process-engine/ops/turn-wait.d.ts.map +1 -0
- package/dist/process-engine/ops/update-model-config.d.ts +9 -0
- package/dist/process-engine/ops/update-model-config.d.ts.map +1 -0
- package/dist/process-engine/recorder.d.ts.map +1 -1
- package/dist/process-engine/turn-start-preflight.d.ts +6 -0
- package/dist/process-engine/turn-start-preflight.d.ts.map +1 -1
- package/dist/process-engine/turn-wait-state.d.ts +24 -0
- package/dist/process-engine/turn-wait-state.d.ts.map +1 -0
- package/dist/process-engine/turn-worker-requirement.d.ts +2 -0
- package/dist/process-engine/turn-worker-requirement.d.ts.map +1 -1
- package/dist/process-engine/types.d.ts +13 -2
- package/dist/process-engine/types.d.ts.map +1 -1
- package/dist/process-engine/writes/build-process-abort-writes.d.ts +3 -1
- package/dist/process-engine/writes/build-process-abort-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +2 -0
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/commit-writes.d.ts +2 -0
- package/dist/process-engine/writes/commit-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/writes.d.ts +28 -60
- 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-inspection-reader.d.ts +21 -0
- package/dist/process-inspection-reader.d.ts.map +1 -0
- package/dist/process-inspection-trace.d.ts +13 -0
- package/dist/process-inspection-trace.d.ts.map +1 -0
- package/dist/process-inspection.d.ts +22 -0
- package/dist/process-inspection.d.ts.map +1 -0
- package/dist/process-instance-tree-presenter.d.ts +4 -3
- package/dist/process-instance-tree-presenter.d.ts.map +1 -1
- package/dist/process-launch-executor.d.ts +2 -0
- package/dist/process-launch-executor.d.ts.map +1 -1
- package/dist/process-launch-plan.d.ts +1 -0
- package/dist/process-launch-plan.d.ts.map +1 -1
- package/dist/process-launcher-registry.d.ts.map +1 -1
- package/dist/process-model-availability-recovery.d.ts +1 -1
- package/dist/process-model-availability-recovery.d.ts.map +1 -1
- package/dist/process-model-config.d.ts +19 -0
- package/dist/process-model-config.d.ts.map +1 -0
- package/dist/process-model-policy/construct.d.ts.map +1 -1
- package/dist/process-model-policy/evaluate.d.ts.map +1 -1
- package/dist/process-model-policy/index.d.ts +4 -1
- package/dist/process-model-policy/index.d.ts.map +1 -1
- package/dist/process-model-policy/project.d.ts.map +1 -1
- package/dist/process-model-policy/types.d.ts +18 -0
- package/dist/process-model-policy/types.d.ts.map +1 -1
- package/dist/process-model-policy-presenter.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-turn-trace.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts +14 -3
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- package/dist/routes/dashboard.d.ts +17 -0
- package/dist/routes/dashboard.d.ts.map +1 -0
- package/dist/routes/future-executions.d.ts.map +1 -1
- package/dist/routes/launchers.d.ts.map +1 -1
- package/dist/routes/process-actions.d.ts.map +1 -1
- package/dist/routes/process-detail.d.ts.map +1 -1
- package/dist/routes/process-model-config.d.ts +4 -0
- package/dist/routes/process-model-config.d.ts.map +1 -0
- package/dist/routes/process-route-helpers.d.ts +8 -9
- package/dist/routes/process-route-helpers.d.ts.map +1 -1
- package/dist/routes/processes.d.ts.map +1 -1
- package/dist/routes/settings.d.ts +11 -0
- package/dist/routes/settings.d.ts.map +1 -0
- package/dist/routes/ticket-creation.d.ts.map +1 -1
- package/dist/scoped-settings-service.d.ts +98 -0
- package/dist/scoped-settings-service.d.ts.map +1 -0
- package/dist/server-bootstrap/build-host-capabilities.d.ts +2 -0
- package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
- package/dist/server-bootstrap/register-http.d.ts.map +1 -1
- package/dist/session-summary-projection.d.ts.map +1 -1
- package/dist/skills/bundled-skills.d.ts +5 -0
- package/dist/skills/bundled-skills.d.ts.map +1 -0
- package/dist/skills/catalog-service.d.ts +1 -0
- package/dist/skills/catalog-service.d.ts.map +1 -1
- package/dist/skills/extension-importer.d.ts +11 -0
- package/dist/skills/extension-importer.d.ts.map +1 -0
- package/dist/skills/launch-skills.d.ts +11 -0
- package/dist/skills/launch-skills.d.ts.map +1 -0
- package/dist/skills/skill-frontmatter.d.ts +7 -0
- package/dist/skills/skill-frontmatter.d.ts.map +1 -1
- package/dist/skills/source-importer.d.ts +3 -0
- package/dist/skills/source-importer.d.ts.map +1 -1
- package/dist/startup-evidence.d.ts +4 -3
- package/dist/startup-evidence.d.ts.map +1 -1
- package/dist/startup-retry-policy.d.ts +8 -0
- package/dist/startup-retry-policy.d.ts.map +1 -0
- package/dist/supervisor/execution-inspection-ingestor.d.ts +9 -0
- package/dist/supervisor/execution-inspection-ingestor.d.ts.map +1 -0
- package/dist/supervisor/ipc-handler.d.ts +2 -0
- package/dist/supervisor/ipc-handler.d.ts.map +1 -1
- package/dist/supervisor/worker-event-ingestor.d.ts +1 -0
- package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +2 -0
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- package/dist/test-helpers/prepared-fixture-start.d.ts.map +1 -1
- package/dist/test-helpers/process-model-fixtures.d.ts +1 -0
- package/dist/test-helpers/process-model-fixtures.d.ts.map +1 -1
- package/dist/test-helpers/scoped-settings-fixtures.d.ts +16 -0
- package/dist/test-helpers/scoped-settings-fixtures.d.ts.map +1 -0
- package/dist/test-helpers/skill-fixtures.d.ts +4 -0
- package/dist/test-helpers/skill-fixtures.d.ts.map +1 -0
- package/dist/testing.js +2 -1
- package/dist/testing.js.map +1 -1
- package/dist/tool-approval-gate.d.ts +3 -0
- package/dist/tool-approval-gate.d.ts.map +1 -1
- package/dist/turn-progress.d.ts.map +1 -1
- package/dist/turn-wait-service.d.ts +28 -0
- package/dist/turn-wait-service.d.ts.map +1 -0
- package/dist/worker-runtime-profile-selection.d.ts +2 -0
- package/dist/worker-runtime-profile-selection.d.ts.map +1 -1
- package/package.json +20 -19
- package/src/app.ts +177 -25
- package/src/auth/fastify-auth.ts +13 -0
- package/src/config/config-loader.ts +42 -2
- package/src/config/config-types.ts +16 -1
- package/src/config/kubernetes-docker-isolation.ts +21 -0
- package/src/dashboard-model-issues.ts +199 -0
- package/src/db/database.ts +131 -40
- package/src/db/execution-inspection-repo.ts +163 -0
- package/src/db/history-window.ts +18 -0
- package/src/db/process-event-repo.ts +88 -10
- package/src/db/process-instance-repo.ts +33 -2
- package/src/db/process-leaf-outcome-snapshot-repo.ts +8 -2
- package/src/db/process-project-repo.ts +4 -0
- package/src/db/process-skill-repo.ts +9 -2
- package/src/db/process-turn-annotation-repo.ts +27 -9
- package/src/db/process-turn-record-repo.ts +45 -12
- package/src/db/publication-repo.ts +63 -0
- package/src/db/repositories.ts +17 -0
- package/src/db/schema.ts +103 -1
- package/src/db/scoped-settings-repo.ts +234 -0
- package/src/db/skill-repo.ts +89 -27
- package/src/db/turn-start-record-repo.ts +13 -3
- package/src/db/turn-summary-repo.ts +36 -4
- package/src/db/worker-lease-repo.ts +8 -2
- package/src/domain-logic/outcome-tools.ts +18 -216
- package/src/domain-logic/worker-lease-lifecycle.ts +2 -1
- package/src/external-source-service.ts +33 -7
- package/src/future-execution/execution.ts +9 -2
- package/src/future-execution/launch-lifecycle.ts +87 -78
- package/src/future-execution/lifecycle.ts +5 -34
- package/src/future-execution/model-projection.ts +2 -0
- package/src/future-execution/reconciliation.ts +7 -0
- package/src/future-execution-presenter.ts +7 -8
- package/src/integration-tool-registry.ts +59 -26
- package/src/launch-coordinator.ts +10 -1
- package/src/launcher-model-config-service.ts +24 -3
- package/src/leaf-outcome-snapshot-capture.ts +2 -0
- package/src/primary-path-snapshot.ts +3 -4
- package/src/process-action-presenter.ts +22 -57
- package/src/process-action-registry.ts +31 -39
- package/src/process-engine/decision.ts +10 -0
- package/src/process-engine/engine.ts +25 -2
- package/src/process-engine/mapped-turns.ts +5 -7
- package/src/process-engine/ops/automatic-retry-startup.ts +93 -0
- package/src/process-engine/ops/continue-failed-turn.ts +2 -13
- package/src/process-engine/ops/process-observation.ts +119 -0
- package/src/process-engine/ops/retry-failed-turn.ts +2 -12
- package/src/process-engine/ops/retry-startup.ts +20 -16
- package/src/process-engine/ops/start-process.ts +34 -2
- package/src/process-engine/ops/turn-outcome.ts +61 -60
- package/src/process-engine/ops/turn-wait.ts +225 -0
- package/src/process-engine/ops/update-model-config.ts +66 -0
- package/src/process-engine/recorder.ts +34 -5
- package/src/process-engine/turn-start-preflight.ts +168 -105
- package/src/process-engine/turn-wait-state.ts +126 -0
- package/src/process-engine/turn-worker-requirement.ts +4 -0
- package/src/process-engine/types.ts +21 -0
- package/src/process-engine/writes/build-process-abort-writes.ts +30 -20
- package/src/process-engine/writes/build-turn-outcome-writes.ts +39 -2
- package/src/process-engine/writes/commit-writes.ts +16 -4
- package/src/process-engine/writes/writes.ts +59 -74
- package/src/process-graph.ts +0 -1
- package/src/process-inspection-reader.ts +305 -0
- package/src/process-inspection-trace.ts +176 -0
- package/src/process-inspection.ts +169 -0
- package/src/process-instance-tree-presenter.ts +56 -216
- package/src/process-launch-executor.ts +5 -2
- package/src/process-launch-plan.ts +17 -2
- package/src/process-launcher-registry.ts +28 -16
- package/src/process-model-availability-recovery.ts +6 -4
- package/src/process-model-config.ts +100 -0
- package/src/process-model-policy/construct.ts +1 -0
- package/src/process-model-policy/evaluate.ts +34 -32
- package/src/process-model-policy/index.ts +45 -3
- package/src/process-model-policy/project.ts +62 -76
- package/src/process-model-policy/types.ts +26 -0
- package/src/process-model-policy-presenter.ts +7 -3
- package/src/process-runtime-availability.ts +9 -4
- package/src/process-turn-trace.ts +12 -24
- package/src/process-ui-snapshot-presenter.ts +210 -295
- package/src/routes/dashboard.ts +106 -0
- package/src/routes/future-executions.ts +5 -5
- package/src/routes/launchers.ts +51 -1
- package/src/routes/process-actions.ts +10 -10
- package/src/routes/process-detail.ts +25 -2
- package/src/routes/process-model-config.ts +70 -0
- package/src/routes/process-route-helpers.ts +153 -162
- package/src/routes/processes.ts +2 -0
- package/src/routes/settings.ts +173 -0
- package/src/routes/ticket-creation.ts +28 -5
- package/src/scoped-settings-service.ts +797 -0
- package/src/server-bootstrap/build-host-capabilities.ts +42 -0
- package/src/server-bootstrap/register-http.ts +12 -1
- package/src/session-summary-projection.ts +1 -2
- package/src/skills/bundled-skills.ts +64 -0
- package/src/skills/catalog-service.ts +35 -6
- package/src/skills/extension-importer.ts +94 -0
- package/src/skills/launch-skills.ts +19 -0
- package/src/skills/skill-frontmatter.ts +19 -6
- package/src/skills/source-importer.ts +7 -13
- package/src/startup-evidence.ts +29 -8
- package/src/startup-retry-policy.ts +106 -0
- package/src/supervisor/execution-inspection-ingestor.ts +55 -0
- package/src/supervisor/ipc-handler.ts +2 -0
- package/src/supervisor/worker-event-ingestor.ts +30 -14
- package/src/supervisor/worker-start-payload-builder.ts +17 -0
- package/src/supervisor/worker-supervisor.ts +26 -1
- package/src/test-helpers/prepared-fixture-start.ts +1 -0
- package/src/test-helpers/process-model-fixtures.ts +2 -0
- package/src/test-helpers/scoped-settings-fixtures.ts +126 -0
- package/src/test-helpers/skill-fixtures.ts +28 -0
- package/src/tool-approval-gate.ts +16 -0
- package/src/turn-progress.ts +3 -2
- package/src/turn-wait-service.ts +228 -0
- package/src/worker-runtime-profile-selection.ts +8 -1
- package/dist/app-MSJXFK33.js +0 -8
- package/dist/chunk-HK6BLLHA.js.map +0 -1
- package/dist/chunk-QCHS3X33.js.map +0 -1
- /package/dist/{app-MSJXFK33.js.map → app-KR3N2JAE.js.map} +0 -0
package/src/app.ts
CHANGED
|
@@ -14,9 +14,12 @@ import type {
|
|
|
14
14
|
ProvidedCapability,
|
|
15
15
|
ServerExtensionEventMap,
|
|
16
16
|
} from "@leitwerk-dev/process-sdk";
|
|
17
|
+
import { scopedSettingsCapability } from "@leitwerk-dev/process-sdk";
|
|
17
18
|
import type { ModelProfileSnapshot } from "@leitwerk-dev/protocol";
|
|
18
19
|
import { DEFAULT_SESSION_TRANSFER_LIMITS } from "@leitwerk-dev/session-transfer";
|
|
19
20
|
import { createPollingCoordinator, parseDurationMs } from "@leitwerk-dev/watcher-utils";
|
|
21
|
+
import { topicWikiCapability } from "@leitwerk-dev/wiki/integration";
|
|
22
|
+
import { createTopicWikiRepo, registerWikiTools } from "@leitwerk-dev/wiki/server";
|
|
20
23
|
import {
|
|
21
24
|
cleanupRetainedProcessVolumes,
|
|
22
25
|
type ProcessStateExporter,
|
|
@@ -105,6 +108,7 @@ import {
|
|
|
105
108
|
import { RepositoryCredentialService } from "./repository-credentials/service.js";
|
|
106
109
|
import { ResultImageStore } from "./result-image-store.js";
|
|
107
110
|
import type { RouteDeps } from "./routes/processes.js";
|
|
111
|
+
import { createScopedSettingsService } from "./scoped-settings-service.js";
|
|
108
112
|
import { collectCleanupErrors, createAppLifecycle } from "./server-bootstrap/app-lifecycle.js";
|
|
109
113
|
import { buildHostCapabilities } from "./server-bootstrap/build-host-capabilities.js";
|
|
110
114
|
import { loadServerExtensionCatalog } from "./server-bootstrap/load-extension-catalog.js";
|
|
@@ -114,7 +118,9 @@ import { resolveServerTlsOptions } from "./server-topology.js";
|
|
|
114
118
|
import { createProjectedSessionSnapshotStore } from "./session-summary-projection.js";
|
|
115
119
|
import { createSessionTransferHelperRelays } from "./session-transfer-helper-relays.js";
|
|
116
120
|
import { createSessionTransferService } from "./session-transfer-service.js";
|
|
121
|
+
import { importBundledSkills } from "./skills/bundled-skills.js";
|
|
117
122
|
import { createSkillCatalogService } from "./skills/catalog-service.js";
|
|
123
|
+
import { importExtensionSkills } from "./skills/extension-importer.js";
|
|
118
124
|
import { createDiagnosticTraceWriter } from "./supervisor/diagnostic-trace-writer.js";
|
|
119
125
|
import { createIpcHandler, type IpcHandler } from "./supervisor/ipc-handler.js";
|
|
120
126
|
import { startStaleHeartbeatWatchdog } from "./supervisor/stale-heartbeat-watchdog.js";
|
|
@@ -124,11 +130,22 @@ import {
|
|
|
124
130
|
type WorkerWebSocketIpcManager,
|
|
125
131
|
} from "./supervisor/worker-websocket-ipc.js";
|
|
126
132
|
import { createToolApprovalGate } from "./tool-approval-gate.js";
|
|
133
|
+
import { recordTurnProgress } from "./turn-progress.js";
|
|
134
|
+
import { createTurnWaitService } from "./turn-wait-service.js";
|
|
127
135
|
import { defaultWorkerRuntimeProfile } from "./worker-runtime-profile-selection.js";
|
|
128
136
|
import { type Broadcaster, createBroadcaster } from "./ws/broadcast.js";
|
|
129
137
|
|
|
130
138
|
/** @public */
|
|
131
139
|
export interface AppOptions {
|
|
140
|
+
/** Clock and cadence seam for readiness integration tests. @internal */
|
|
141
|
+
turnWait?: {
|
|
142
|
+
/** @internal */
|
|
143
|
+
now?: () => number;
|
|
144
|
+
/** @internal */
|
|
145
|
+
pollIntervalMs?: number;
|
|
146
|
+
/** @internal */
|
|
147
|
+
timeoutMs?: number;
|
|
148
|
+
};
|
|
132
149
|
/** @public */
|
|
133
150
|
config?: LeitwerkConfig;
|
|
134
151
|
/** @internal */
|
|
@@ -242,7 +259,12 @@ async function createConfiguredWorkerRunnerRuntime(input: {
|
|
|
242
259
|
webSocketIpc: WorkerWebSocketIpcManager;
|
|
243
260
|
provided?: AppOptions["workerRunnerRuntime"];
|
|
244
261
|
helperRelays: ProcessStateExportHelperRelayProvider;
|
|
245
|
-
onVolumePoolError: () => void;
|
|
262
|
+
onVolumePoolError: (error?: unknown) => void;
|
|
263
|
+
onImagePreparationEvent: NonNullable<
|
|
264
|
+
Parameters<
|
|
265
|
+
typeof import("@leitwerk-dev/worker-runners/kubernetes").createKubernetesWorkerRunner
|
|
266
|
+
>[0]["imagePreload"]
|
|
267
|
+
>["onEvent"];
|
|
246
268
|
localWorkerSpawnImpl?: AppOptions["localWorkerSpawnImpl"];
|
|
247
269
|
localWorkerDockerPreflightImpl?: AppOptions["localWorkerDockerPreflightImpl"];
|
|
248
270
|
}): Promise<{
|
|
@@ -250,7 +272,7 @@ async function createConfiguredWorkerRunnerRuntime(input: {
|
|
|
250
272
|
volume?: ProcessVolume;
|
|
251
273
|
exporter: ProcessStateExporter;
|
|
252
274
|
webSocketIpc: WorkerWebSocketIpcManager;
|
|
253
|
-
|
|
275
|
+
preparation?: { start(): void; stop(): Promise<void> };
|
|
254
276
|
}> {
|
|
255
277
|
if (input.provided) {
|
|
256
278
|
return {
|
|
@@ -286,9 +308,18 @@ async function createConfiguredWorkerRunnerRuntime(input: {
|
|
|
286
308
|
});
|
|
287
309
|
const created = createKubernetesWorkerRunner({
|
|
288
310
|
client: kubernetesClient,
|
|
311
|
+
reclaimOnClose: processVolume?.reclaim_on_close === true,
|
|
289
312
|
preProvision: processVolume?.pre_provision
|
|
290
313
|
? { ...processVolume.pre_provision, onError: input.onVolumePoolError }
|
|
291
314
|
: undefined,
|
|
315
|
+
imagePreload: input.config.kubernetes?.image_preload?.enabled
|
|
316
|
+
? {
|
|
317
|
+
images: Object.values(input.config.worker_runtime_profiles ?? {}).map(
|
|
318
|
+
(profile) => profile.image,
|
|
319
|
+
),
|
|
320
|
+
onEvent: input.onImagePreparationEvent,
|
|
321
|
+
}
|
|
322
|
+
: undefined,
|
|
292
323
|
processNamespacePrefix:
|
|
293
324
|
input.config.kubernetes?.process_namespace_prefix ?? "leitwerk-process-",
|
|
294
325
|
volume: {
|
|
@@ -421,7 +452,9 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
421
452
|
const repos = createAllRepos(db, {
|
|
422
453
|
...(credentialCipher ? { credentialCipher } : {}),
|
|
423
454
|
});
|
|
455
|
+
const extensionSkills = await importExtensionSkills(extensionCatalog.modules);
|
|
424
456
|
repos.transaction((transactionRepos) => {
|
|
457
|
+
transactionRepos.skills.reconcileExtensions(extensionSkills);
|
|
425
458
|
// Directly configured skills are no longer supported. Deactivate any left by an older release.
|
|
426
459
|
transactionRepos.skills.reconcile([]);
|
|
427
460
|
transactionRepos.skills.backfillDependencies();
|
|
@@ -429,6 +462,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
429
462
|
const skillCatalog = createSkillCatalogService({
|
|
430
463
|
repositories: config.skill_repositories ?? [],
|
|
431
464
|
repos,
|
|
465
|
+
bundledSkills: await importBundledSkills(extensionCatalog.piContributions),
|
|
432
466
|
});
|
|
433
467
|
await skillCatalog.refresh();
|
|
434
468
|
markStartup("skill_catalog");
|
|
@@ -467,12 +501,34 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
467
501
|
markStartup("model_providers");
|
|
468
502
|
|
|
469
503
|
const broadcaster = createBroadcaster();
|
|
504
|
+
repos.topicWiki = createTopicWikiRepo(db, (topicId) =>
|
|
505
|
+
broadcaster.sendDurable("wiki.updated", { topicId }),
|
|
506
|
+
);
|
|
470
507
|
const processOperations = createProcessOperationCoordinator();
|
|
471
508
|
const processGraphs = extensionCatalog.processes;
|
|
472
509
|
const processActionRegistry = buildProcessActionRegistry(extensionCatalog);
|
|
473
510
|
const integrationTools = new IntegrationToolRegistry(repos.externalWrites);
|
|
474
511
|
const processUiRegistry = buildProcessUiRegistry(extensionCatalog);
|
|
512
|
+
const scopedSettings = createScopedSettingsService({
|
|
513
|
+
repos,
|
|
514
|
+
catalog: extensionCatalog,
|
|
515
|
+
config,
|
|
516
|
+
modelChoices: () =>
|
|
517
|
+
config.pi.model_profiles.map((profile) => {
|
|
518
|
+
const status = modelStatusCache
|
|
519
|
+
.snapshot()
|
|
520
|
+
.profiles.find((entry) => entry.profileId === profile.id);
|
|
521
|
+
return {
|
|
522
|
+
value: profile.id,
|
|
523
|
+
label: `${profile.id} — ${profile.provider}/${profile.model_id}`,
|
|
524
|
+
...(status?.availability === "available"
|
|
525
|
+
? {}
|
|
526
|
+
: { disabledReason: status?.safeReason ?? "Model unavailable" }),
|
|
527
|
+
};
|
|
528
|
+
}),
|
|
529
|
+
});
|
|
475
530
|
const processModelPolicy = createServerProcessModelPolicy({
|
|
531
|
+
scopedSettings,
|
|
476
532
|
config,
|
|
477
533
|
processGraphs,
|
|
478
534
|
processActionRegistry,
|
|
@@ -590,6 +646,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
590
646
|
},
|
|
591
647
|
};
|
|
592
648
|
const launcherModelConfigs = createLauncherModelConfigService({
|
|
649
|
+
scopedSettingsService: scopedSettings,
|
|
593
650
|
launcherService,
|
|
594
651
|
launchPlans,
|
|
595
652
|
processModelPolicy,
|
|
@@ -737,6 +794,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
737
794
|
processModelPolicy,
|
|
738
795
|
getModelAvailabilitySnapshot: () => modelStatusCache.snapshot(),
|
|
739
796
|
afterRecord(process) {
|
|
797
|
+
invalidateExternalSourceArmings?.(process.id);
|
|
740
798
|
// The process volume is the durable source for an already-created start.
|
|
741
799
|
// A missing server-cache entry is valid after restart.
|
|
742
800
|
piResourceBundlePins.reconcile(process);
|
|
@@ -749,11 +807,15 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
749
807
|
{
|
|
750
808
|
config,
|
|
751
809
|
registry: modelProviderRegistry,
|
|
810
|
+
processActionRegistry,
|
|
811
|
+
mappedRuns: baseDeps.mappedRuns,
|
|
752
812
|
modelStatusCache,
|
|
753
813
|
piContributions: extensionCatalog.piContributions,
|
|
754
814
|
bundleCache: piResourceBundles,
|
|
755
815
|
projects: baseDeps.projects,
|
|
756
816
|
processSkills: baseDeps.processSkills,
|
|
817
|
+
scopedSettings,
|
|
818
|
+
processModelPolicy,
|
|
757
819
|
},
|
|
758
820
|
process,
|
|
759
821
|
writes,
|
|
@@ -783,18 +845,23 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
783
845
|
const toolApprovalGate = createToolApprovalGate({
|
|
784
846
|
repos: baseDeps,
|
|
785
847
|
processOperations,
|
|
848
|
+
broadcaster,
|
|
786
849
|
});
|
|
787
850
|
const integrationToolRequests = createIntegrationToolRequestService({
|
|
788
851
|
registry: integrationTools,
|
|
789
852
|
repos: baseDeps,
|
|
790
853
|
processActionRegistry,
|
|
791
854
|
toolApprovalGate,
|
|
855
|
+
reportProgress: (report) => {
|
|
856
|
+
recordTurnProgress(baseDeps, report);
|
|
857
|
+
},
|
|
792
858
|
});
|
|
793
859
|
const diagnosticTraceWriter = createDiagnosticTraceWriter(
|
|
794
860
|
path.join(config.storage.tree_files_dir, "diagnostic-traces"),
|
|
795
861
|
);
|
|
796
862
|
const ipcHandler = createIpcHandler(
|
|
797
863
|
{
|
|
864
|
+
executionInspections: baseDeps.executionInspections,
|
|
798
865
|
startupObservations: baseDeps.startupObservations,
|
|
799
866
|
processes: baseDeps.processes,
|
|
800
867
|
getLaunchCoordinator: () => launchCoordinator,
|
|
@@ -899,17 +966,25 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
899
966
|
webSocketIpc: workerWebSocketIpc,
|
|
900
967
|
provided: opts.workerRunnerRuntime,
|
|
901
968
|
helperRelays: sessionTransferHelperRelays,
|
|
902
|
-
onVolumePoolError: () =>
|
|
903
|
-
app.log.warn(
|
|
969
|
+
onVolumePoolError: (error) =>
|
|
970
|
+
app.log.warn(
|
|
971
|
+
{ err: error },
|
|
972
|
+
"Volume pool degraded; inspect preparation Pods and CSI storage scheduling",
|
|
973
|
+
),
|
|
974
|
+
onImagePreparationEvent: (event) => {
|
|
975
|
+
if (event.outcome === "succeeded") app.log.info(event, "Worker image prepared");
|
|
976
|
+
else app.log.warn(event, "Worker image preparation failed; retrying in the background");
|
|
977
|
+
},
|
|
904
978
|
localWorkerSpawnImpl: opts.localWorkerSpawnImpl,
|
|
905
979
|
localWorkerDockerPreflightImpl: opts.localWorkerDockerPreflightImpl,
|
|
906
980
|
});
|
|
907
|
-
if (runnerRuntime.
|
|
908
|
-
startHooks.push(() => runnerRuntime.
|
|
909
|
-
stopHooks.push(() => runnerRuntime.
|
|
981
|
+
if (runnerRuntime.preparation) {
|
|
982
|
+
startHooks.push(() => runnerRuntime.preparation?.start());
|
|
983
|
+
stopHooks.push(() => runnerRuntime.preparation?.stop());
|
|
910
984
|
}
|
|
911
985
|
markStartup("worker_runner");
|
|
912
986
|
supervisor = createWorkerSupervisor({
|
|
987
|
+
executionInspections: baseDeps.executionInspections,
|
|
913
988
|
startupObservations: baseDeps.startupObservations,
|
|
914
989
|
config: supervisorConfig,
|
|
915
990
|
processGraphs,
|
|
@@ -951,30 +1026,67 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
951
1026
|
let retentionWork: Promise<void> | undefined;
|
|
952
1027
|
let retainedVolumeCleanupTimer: NodeJS.Timeout | null = null;
|
|
953
1028
|
let retainedVolumeCleanupRunning = false;
|
|
954
|
-
const
|
|
1029
|
+
const retentionPolicy = {
|
|
1030
|
+
completedProcessRetention: config.workers.cleanup.completed_process_retention,
|
|
1031
|
+
errorProcessRetention: config.workers.cleanup.error_process_retention,
|
|
1032
|
+
};
|
|
1033
|
+
const reclaimTerminalStorage =
|
|
1034
|
+
config.workers.runner === "kubernetes" &&
|
|
1035
|
+
config.kubernetes?.process_volume.reclaim_on_close === true;
|
|
1036
|
+
const volumeRetentionPolicy = reclaimTerminalStorage
|
|
1037
|
+
? { ...retentionPolicy, completedProcessRetention: "0s", abortedProcessRetention: "0s" }
|
|
1038
|
+
: retentionPolicy;
|
|
1039
|
+
const pendingVolumeReleases = new Set<Promise<void>>();
|
|
1040
|
+
function releaseRetainedVolume(instanceId: string): Promise<void> {
|
|
1041
|
+
const work = processOperations.runExclusive(instanceId, async () => {
|
|
1042
|
+
// Re-read under the lifecycle lock so a resumed process keeps its workspace.
|
|
1043
|
+
const process = baseDeps.processes.getById(instanceId);
|
|
1044
|
+
const lease = baseDeps.leases.getByInstance(instanceId);
|
|
1045
|
+
if (!process || (lease && !lease.exitedAt)) return;
|
|
1046
|
+
await cleanupRetainedProcessVolumes({
|
|
1047
|
+
volume: runnerRuntime.volume,
|
|
1048
|
+
processes: [process],
|
|
1049
|
+
now: new Date(),
|
|
1050
|
+
policy: volumeRetentionPolicy,
|
|
1051
|
+
reclaimTerminalBackingStorage: reclaimTerminalStorage,
|
|
1052
|
+
});
|
|
1053
|
+
});
|
|
1054
|
+
pendingVolumeReleases.add(work);
|
|
1055
|
+
return work.finally(() => pendingVolumeReleases.delete(work));
|
|
1056
|
+
}
|
|
1057
|
+
afterSuccessHooks.add(async (instanceId) => {
|
|
1058
|
+
const process = baseDeps.processes.getById(instanceId);
|
|
1059
|
+
if (
|
|
1060
|
+
!reclaimTerminalStorage ||
|
|
1061
|
+
!process ||
|
|
1062
|
+
!["completed", "aborted"].includes(process.lifecycleStatus)
|
|
1063
|
+
)
|
|
1064
|
+
return;
|
|
1065
|
+
try {
|
|
1066
|
+
await releaseRetainedVolume(instanceId);
|
|
1067
|
+
} catch (err) {
|
|
1068
|
+
app.log.warn({ err, instanceId }, "process PVC release failed; retention sweep will retry");
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
955
1071
|
async function runRetainedVolumeCleanup(): Promise<void> {
|
|
956
1072
|
if (retainedVolumeCleanupRunning) return;
|
|
957
1073
|
retainedVolumeCleanupRunning = true;
|
|
958
1074
|
const processes = baseDeps.processes.listAll();
|
|
959
1075
|
const now = new Date();
|
|
960
|
-
const policy = {
|
|
961
|
-
completedProcessRetention: config.workers.cleanup.completed_process_retention,
|
|
962
|
-
errorProcessRetention: config.workers.cleanup.error_process_retention,
|
|
963
|
-
};
|
|
964
1076
|
const expiredImageProcesses = new Set(
|
|
965
|
-
planProcessVolumeRetentionCleanup({ processes, now, policy }),
|
|
1077
|
+
planProcessVolumeRetentionCleanup({ processes, now, policy: retentionPolicy }),
|
|
966
1078
|
);
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1079
|
+
const expiredVolumes = planProcessVolumeRetentionCleanup({
|
|
1080
|
+
processes,
|
|
1081
|
+
now,
|
|
1082
|
+
policy: volumeRetentionPolicy,
|
|
1083
|
+
});
|
|
1084
|
+
for (const instanceId of expiredVolumes) {
|
|
1085
|
+
try {
|
|
1086
|
+
await releaseRetainedVolume(instanceId);
|
|
1087
|
+
} catch (err) {
|
|
1088
|
+
app.log.warn({ err, instanceId }, "retained process volume cleanup failed");
|
|
1089
|
+
}
|
|
978
1090
|
}
|
|
979
1091
|
try {
|
|
980
1092
|
await resultImages.cleanupProcesses({
|
|
@@ -1019,6 +1131,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
1019
1131
|
retainedVolumeCleanupTimer = null;
|
|
1020
1132
|
}
|
|
1021
1133
|
await retentionWork;
|
|
1134
|
+
await Promise.allSettled([...pendingVolumeReleases]);
|
|
1022
1135
|
});
|
|
1023
1136
|
|
|
1024
1137
|
if (processTitles?.start) {
|
|
@@ -1045,6 +1158,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
1045
1158
|
);
|
|
1046
1159
|
const processLaunchDeps = {
|
|
1047
1160
|
...baseDeps,
|
|
1161
|
+
skillDefaults: config,
|
|
1048
1162
|
broadcaster,
|
|
1049
1163
|
commands: processEngine,
|
|
1050
1164
|
processTitles,
|
|
@@ -1056,6 +1170,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
1056
1170
|
};
|
|
1057
1171
|
const createProcess = createProcessFromLaunchPlan.bind(null, processLaunchDeps);
|
|
1058
1172
|
futureExecutionLifecycle = createFutureExecutionLifecycle({
|
|
1173
|
+
skillDefaults: config,
|
|
1059
1174
|
futureExecutions: baseDeps.futureExecutions,
|
|
1060
1175
|
processes: baseDeps.processes,
|
|
1061
1176
|
projects: baseDeps.projects,
|
|
@@ -1187,6 +1302,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
1187
1302
|
modelStatusCache,
|
|
1188
1303
|
});
|
|
1189
1304
|
const hostCapabilities = buildHostCapabilities({
|
|
1305
|
+
integrationTools,
|
|
1190
1306
|
config,
|
|
1191
1307
|
baseDeps,
|
|
1192
1308
|
projectMutations,
|
|
@@ -1211,6 +1327,33 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
1211
1327
|
preProvidedCapabilities: opts.preProvidedCapabilities,
|
|
1212
1328
|
});
|
|
1213
1329
|
|
|
1330
|
+
hostCapabilities.provide(scopedSettingsCapability, scopedSettings);
|
|
1331
|
+
const turnWaitService = createTurnWaitService({
|
|
1332
|
+
commitMessages: config.commit_messages,
|
|
1333
|
+
processes: baseDeps.processes,
|
|
1334
|
+
projects: baseDeps.projects,
|
|
1335
|
+
processGraphs,
|
|
1336
|
+
registry: processActionRegistry,
|
|
1337
|
+
commands: processEngine,
|
|
1338
|
+
require: hostCapabilities.require.bind(hostCapabilities),
|
|
1339
|
+
...opts.turnWait,
|
|
1340
|
+
});
|
|
1341
|
+
polling.create({
|
|
1342
|
+
id: "turn-readiness",
|
|
1343
|
+
pollOnce: turnWaitService.poll,
|
|
1344
|
+
isEnabled: () => true,
|
|
1345
|
+
pollInterval: () => "1s",
|
|
1346
|
+
defaultIntervalMs: 1000,
|
|
1347
|
+
});
|
|
1348
|
+
afterSuccessHooks.add((instanceId) => {
|
|
1349
|
+
// Resolving readiness invokes this hook again; never await our own check.
|
|
1350
|
+
void turnWaitService.check(instanceId).catch((error: unknown) => {
|
|
1351
|
+
app.log.error({ err: error, instanceId }, "Turn readiness check failed");
|
|
1352
|
+
});
|
|
1353
|
+
});
|
|
1354
|
+
const wiki = hostCapabilities.require(topicWikiCapability);
|
|
1355
|
+
if (Array.isArray(wiki)) throw new Error("Wiki integration must be singular");
|
|
1356
|
+
registerWikiTools({ tool: (definition) => integrationTools.register(definition) }, wiki);
|
|
1214
1357
|
await setupServerExtensions(
|
|
1215
1358
|
extensionCatalog,
|
|
1216
1359
|
{
|
|
@@ -1231,7 +1374,10 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
1231
1374
|
);
|
|
1232
1375
|
integrationTools.validateTicketProcesses(extensionCatalog.processes);
|
|
1233
1376
|
startHooks.push(() => polling.start());
|
|
1234
|
-
stopHooks.push(() =>
|
|
1377
|
+
stopHooks.push(async () => {
|
|
1378
|
+
await turnWaitService.stop();
|
|
1379
|
+
await polling.stop();
|
|
1380
|
+
});
|
|
1235
1381
|
for (const process of extensionCatalog.processes.values()) {
|
|
1236
1382
|
for (const [turnId, binding] of process.turns) {
|
|
1237
1383
|
const definition = binding.definition;
|
|
@@ -1248,6 +1394,12 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
1248
1394
|
markStartup("server_extensions");
|
|
1249
1395
|
|
|
1250
1396
|
const deps: RouteDeps = {
|
|
1397
|
+
onSettingsChanged: async () => {
|
|
1398
|
+
await futureExecutionLifecycle.reconcileModelAvailability({
|
|
1399
|
+
availability: modelStatusCache.snapshot(),
|
|
1400
|
+
});
|
|
1401
|
+
},
|
|
1402
|
+
scopedSettingsService: scopedSettings,
|
|
1251
1403
|
externalSourceService,
|
|
1252
1404
|
...baseDeps,
|
|
1253
1405
|
launchCoordinator,
|
package/src/auth/fastify-auth.ts
CHANGED
|
@@ -2,16 +2,25 @@ import { type Actor, ADMIN_ACTOR } from "@leitwerk-dev/domain";
|
|
|
2
2
|
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
3
3
|
import type { AuthService } from "./auth-service.js";
|
|
4
4
|
|
|
5
|
+
/** @internal */
|
|
5
6
|
export interface TokenAuditContext {
|
|
7
|
+
/** @internal */
|
|
6
8
|
operation: string;
|
|
9
|
+
/** @internal */
|
|
7
10
|
tokenId?: string;
|
|
11
|
+
/** @internal */
|
|
8
12
|
actor?: Actor;
|
|
13
|
+
/** @internal */
|
|
9
14
|
ownerKind?: "user" | "anonymous";
|
|
15
|
+
/** @internal */
|
|
10
16
|
count?: number;
|
|
11
17
|
}
|
|
12
18
|
declare module "fastify" {
|
|
19
|
+
/** @internal */
|
|
13
20
|
interface FastifyRequest {
|
|
21
|
+
/** @internal */
|
|
14
22
|
actor?: Actor;
|
|
23
|
+
/** @internal */
|
|
15
24
|
tokenAudit?: TokenAuditContext;
|
|
16
25
|
}
|
|
17
26
|
}
|
|
@@ -57,9 +66,13 @@ export function authenticateRequest(auth: AuthService, request: FastifyRequest):
|
|
|
57
66
|
const result = auth.apiTokens.resolve(match[1]);
|
|
58
67
|
if (result.token) {
|
|
59
68
|
request.tokenAudit = {
|
|
69
|
+
/** @internal */
|
|
60
70
|
operation: "bearer_request",
|
|
71
|
+
/** @internal */
|
|
61
72
|
tokenId: result.token.id,
|
|
73
|
+
/** @internal */
|
|
62
74
|
actor: result.token.owner.actor,
|
|
75
|
+
/** @internal */
|
|
63
76
|
ownerKind: result.token.owner.kind,
|
|
64
77
|
};
|
|
65
78
|
}
|
|
@@ -17,6 +17,7 @@ import { resolveDockerRegistryCredentials } from "../docker-registry-credentials
|
|
|
17
17
|
import { isValidStorageSize } from "../process-storage-size.js";
|
|
18
18
|
import { SAFE_SKILL_ID_PATTERN } from "../skills/skill-id.js";
|
|
19
19
|
import type { LeitwerkConfig } from "./config-types.js";
|
|
20
|
+
import { resolveKubernetesDockerIsolation } from "./kubernetes-docker-isolation.js";
|
|
20
21
|
import { isHttpsOrLoopbackHttpUrl, isValidHttpUrl, parseHttpUrl } from "./url-policy.js";
|
|
21
22
|
|
|
22
23
|
const DEFAULT_SEARCH_PATHS = ["./leitwerk.yaml", "~/.leitwerk/leitwerk.yaml"];
|
|
@@ -135,12 +136,19 @@ export function loadConfigFromFile(filePath: string): ConfigLoadResult | ConfigL
|
|
|
135
136
|
export function loadConfig(explicitPath?: string): ConfigLoadResult | ConfigLoadError {
|
|
136
137
|
const filePath = resolveConfigPath(explicitPath);
|
|
137
138
|
if (!filePath) {
|
|
138
|
-
return {
|
|
139
|
+
return {
|
|
140
|
+
ok: false,
|
|
141
|
+
error:
|
|
142
|
+
"Configuration file required: configure pi.default_model_profile and pi.model_profiles",
|
|
143
|
+
};
|
|
139
144
|
}
|
|
140
145
|
return loadConfigFromFile(filePath);
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
const stringArraySchema = v.array(v.string());
|
|
149
|
+
const skillIdsSchema = v.array(
|
|
150
|
+
v.pipe(v.string(), v.regex(SAFE_SKILL_ID_PATTERN, "Invalid skill ID")),
|
|
151
|
+
);
|
|
144
152
|
const modelTurnConfigSchema = v.looseObject({
|
|
145
153
|
model_profile: v.optional(v.string()),
|
|
146
154
|
});
|
|
@@ -287,6 +295,10 @@ const configSchema = v.looseObject({
|
|
|
287
295
|
),
|
|
288
296
|
pi: v.looseObject({
|
|
289
297
|
agent_dir: v.string(),
|
|
298
|
+
default_model_profile: v.pipe(
|
|
299
|
+
v.string(),
|
|
300
|
+
v.check((value) => value.trim() !== "", "Must be a non-empty model profile ID"),
|
|
301
|
+
),
|
|
290
302
|
model_profiles: v.array(
|
|
291
303
|
v.looseObject({
|
|
292
304
|
id: v.string(),
|
|
@@ -320,6 +332,7 @@ const configSchema = v.looseObject({
|
|
|
320
332
|
v.record(
|
|
321
333
|
v.string(),
|
|
322
334
|
v.looseObject({
|
|
335
|
+
default_skills: v.optional(skillIdsSchema),
|
|
323
336
|
default_model_profile: v.optional(v.string()),
|
|
324
337
|
allowed_model_profiles: v.optional(v.pipe(stringArraySchema, v.nonEmpty())),
|
|
325
338
|
worker_runtime_profile: v.optional(v.string()),
|
|
@@ -350,6 +363,7 @@ const configSchema = v.looseObject({
|
|
|
350
363
|
sources: stringArraySchema,
|
|
351
364
|
}),
|
|
352
365
|
auth: v.optional(authConfigSchema),
|
|
366
|
+
default_skills: v.optional(skillIdsSchema),
|
|
353
367
|
docker_registries: v.optional(
|
|
354
368
|
v.strictObject({
|
|
355
369
|
profiles: v.record(v.string(), v.strictObject(dockerRegistryCredentialSchema.entries)),
|
|
@@ -381,7 +395,9 @@ const configSchema = v.looseObject({
|
|
|
381
395
|
api_server_url: v.optional(v.string()),
|
|
382
396
|
default_worker_runtime_profile: v.optional(v.string()),
|
|
383
397
|
worker_service_account: v.optional(v.string()),
|
|
398
|
+
image_preload: v.optional(v.strictObject({ enabled: v.boolean() })),
|
|
384
399
|
process_volume: v.looseObject({
|
|
400
|
+
reclaim_on_close: v.optional(v.boolean()),
|
|
385
401
|
storage_class_name: v.optional(v.string()),
|
|
386
402
|
pre_provision: v.optional(
|
|
387
403
|
v.strictObject({ count: v.pipe(v.number(), v.integer(), v.minValue(0)) }),
|
|
@@ -392,8 +408,11 @@ const configSchema = v.looseObject({
|
|
|
392
408
|
}),
|
|
393
409
|
docker: v.optional(
|
|
394
410
|
v.strictObject({
|
|
411
|
+
worker_runtime_profile: v.optional(v.pipe(v.string(), v.trim(), v.nonEmpty())),
|
|
412
|
+
node_selector: v.optional(v.record(v.string(), v.string())),
|
|
395
413
|
runtime_class_name: v.optional(v.string()),
|
|
396
414
|
host_users: v.optional(v.boolean()),
|
|
415
|
+
isolation: v.optional(v.picklist(["gvisor", "virtual-machine"])),
|
|
397
416
|
gvisor: v.optional(v.boolean()),
|
|
398
417
|
process_storage_class_name: v.optional(v.string()),
|
|
399
418
|
network: v.optional(dockerNetworkSchema),
|
|
@@ -495,6 +514,11 @@ function collectModelProfileReferenceErrors(config: LeitwerkConfig): string[] {
|
|
|
495
514
|
.filter((profileId) => typeof profileId === "string" && profileId.trim() !== ""),
|
|
496
515
|
);
|
|
497
516
|
const titleModelProfile = config.pi.process_title_generation.model_profile;
|
|
517
|
+
if (!configuredModelProfileIds.has(config.pi.default_model_profile)) {
|
|
518
|
+
errors.push(
|
|
519
|
+
`Unknown model profile '${config.pi.default_model_profile}' at pi.default_model_profile`,
|
|
520
|
+
);
|
|
521
|
+
}
|
|
498
522
|
if (typeof titleModelProfile === "string") {
|
|
499
523
|
if (titleModelProfile.trim() === "") {
|
|
500
524
|
errors.push(
|
|
@@ -560,6 +584,10 @@ function collectWorkerRuntimeProfileErrors(config: LeitwerkConfig): string[] {
|
|
|
560
584
|
config.kubernetes?.default_worker_runtime_profile,
|
|
561
585
|
"kubernetes.default_worker_runtime_profile",
|
|
562
586
|
);
|
|
587
|
+
checkReference(
|
|
588
|
+
config.kubernetes?.docker?.worker_runtime_profile,
|
|
589
|
+
"kubernetes.docker.worker_runtime_profile",
|
|
590
|
+
);
|
|
563
591
|
}
|
|
564
592
|
for (const [key, component] of Object.entries(config.components)) {
|
|
565
593
|
checkReference(component.worker_runtime_profile, `components.${key}.worker_runtime_profile`);
|
|
@@ -737,6 +765,14 @@ function collectKubernetesRunnerConfigErrors(config: LeitwerkConfig): string[] {
|
|
|
737
765
|
errors.push(
|
|
738
766
|
"worker_runtime_profiles must include at least one profile when workers.runner is 'kubernetes'",
|
|
739
767
|
);
|
|
768
|
+
if (k.image_preload?.enabled) {
|
|
769
|
+
for (const [id, profile] of Object.entries(config.worker_runtime_profiles ?? {})) {
|
|
770
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._:/-]*@sha256:[0-9a-f]{64}$/.test(profile.image))
|
|
771
|
+
errors.push(
|
|
772
|
+
`worker_runtime_profiles.${id}.image must be digest-qualified when kubernetes.image_preload.enabled is true`,
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
740
776
|
const defaultProfile = k.default_worker_runtime_profile ?? config.workers.default_runtime_profile;
|
|
741
777
|
if (!defaultProfile?.trim())
|
|
742
778
|
errors.push(
|
|
@@ -935,6 +971,7 @@ function validateResolvedConfig(config: Record<string, unknown>): string[] {
|
|
|
935
971
|
...collectLocalRunnerConfigErrors(resolvedConfig),
|
|
936
972
|
...collectDockerRunnerConfigErrors(resolvedConfig),
|
|
937
973
|
...collectKubernetesRunnerConfigErrors(resolvedConfig),
|
|
974
|
+
...resolveKubernetesDockerIsolation(resolvedConfig.kubernetes?.docker).errors,
|
|
938
975
|
...collectInternalTlsConfigErrors(resolvedConfig),
|
|
939
976
|
...collectAuthConfigErrors(resolvedConfig),
|
|
940
977
|
];
|
|
@@ -974,7 +1011,7 @@ export function sanitizeConfigForLogging(value: unknown, path: readonly string[]
|
|
|
974
1011
|
return sanitized;
|
|
975
1012
|
}
|
|
976
1013
|
|
|
977
|
-
/** @public */
|
|
1014
|
+
/** Configuration template; set model_profiles and default_model_profile before startup. @public */
|
|
978
1015
|
export function getDefaultConfig(): LeitwerkConfig {
|
|
979
1016
|
return {
|
|
980
1017
|
skill_repositories: [],
|
|
@@ -1028,6 +1065,7 @@ export function getDefaultConfig(): LeitwerkConfig {
|
|
|
1028
1065
|
pi: {
|
|
1029
1066
|
agent_dir: "~/.pi/leitwerk",
|
|
1030
1067
|
model_profiles: [],
|
|
1068
|
+
default_model_profile: "",
|
|
1031
1069
|
process_title_generation: {
|
|
1032
1070
|
model_profile: null,
|
|
1033
1071
|
retry: {
|
|
@@ -1048,6 +1086,7 @@ export function getDefaultConfig(): LeitwerkConfig {
|
|
|
1048
1086
|
},
|
|
1049
1087
|
},
|
|
1050
1088
|
process_configs: {},
|
|
1089
|
+
default_skills: [],
|
|
1051
1090
|
notifications: {
|
|
1052
1091
|
all: { enabled: false, type: "teams_webhook", url: "" },
|
|
1053
1092
|
debug: { enabled: false, type: "teams_webhook", url: "" },
|
|
@@ -1078,6 +1117,7 @@ export function getDefaultConfig(): LeitwerkConfig {
|
|
|
1078
1117
|
default_worker_runtime_profile: "generic",
|
|
1079
1118
|
worker_service_account: "leitwerk-worker",
|
|
1080
1119
|
process_volume: {
|
|
1120
|
+
reclaim_on_close: false,
|
|
1081
1121
|
size: "20Gi",
|
|
1082
1122
|
access_modes: ["ReadWriteOnce"],
|
|
1083
1123
|
mount_path: "/state",
|
|
@@ -148,6 +148,8 @@ export interface DockerRunnerConfig {
|
|
|
148
148
|
|
|
149
149
|
/** @internal */
|
|
150
150
|
export interface KubernetesProcessVolumeConfig {
|
|
151
|
+
/** Discard terminal workspaces and their backing storage; disabled by default. @internal */
|
|
152
|
+
reclaim_on_close?: boolean;
|
|
151
153
|
/** Optional ready-volume target; zero stops replenishment. @internal */
|
|
152
154
|
pre_provision?: {
|
|
153
155
|
/** @internal */
|
|
@@ -165,11 +167,17 @@ export interface KubernetesProcessVolumeConfig {
|
|
|
165
167
|
|
|
166
168
|
/** @internal */
|
|
167
169
|
export interface KubernetesDockerConfig {
|
|
170
|
+
/** Default profile for Docker processes without an explicit process/component profile. @internal */
|
|
171
|
+
worker_runtime_profile?: string;
|
|
172
|
+
/** Docker-only selector keys override matching global Pod selector keys. @internal */
|
|
173
|
+
node_selector?: Record<string, string>;
|
|
168
174
|
/** Pod RuntimeClass selected for every Docker-requiring process. @internal */
|
|
169
175
|
runtime_class_name?: string;
|
|
170
176
|
/** Pod user-namespace policy passed directly to spec.hostUsers. @internal */
|
|
171
177
|
host_users?: boolean;
|
|
172
|
-
/**
|
|
178
|
+
/** Trusted sandbox policy for a separately qualified cluster runtime. @internal */
|
|
179
|
+
isolation?: "gvisor" | "virtual-machine";
|
|
180
|
+
/** Legacy alias for isolation: gvisor when isolation is omitted. @internal */
|
|
173
181
|
gvisor?: boolean;
|
|
174
182
|
/** StorageClass selected for the process's single retained PVC. @internal */
|
|
175
183
|
process_storage_class_name?: string;
|
|
@@ -217,6 +225,11 @@ export interface LocalWorkerRunnerConfig {
|
|
|
217
225
|
|
|
218
226
|
/** @internal */
|
|
219
227
|
export interface KubernetesRunnerConfig {
|
|
228
|
+
/** Optional worker image preparation on eligible nodes; disabled by default. @internal */
|
|
229
|
+
image_preload?: {
|
|
230
|
+
/** @internal */
|
|
231
|
+
enabled: boolean;
|
|
232
|
+
};
|
|
220
233
|
/** Dedicated namespace where the singleton server runs. @internal */
|
|
221
234
|
server_namespace: string;
|
|
222
235
|
/** Safe DNS prefix used to derive one namespace per process instance. @internal */
|
|
@@ -394,6 +407,8 @@ export interface LeitwerkConfig extends ConfigSnapshot {
|
|
|
394
407
|
internal_tls?: InternalTlsConfig;
|
|
395
408
|
/** Git repositories scanned for operator-managed skills. @internal */
|
|
396
409
|
skill_repositories?: SkillRepositoryConfig[];
|
|
410
|
+
/** Installed skill IDs included in new launches unless replaced by process defaults. @public */
|
|
411
|
+
default_skills?: string[];
|
|
397
412
|
/** Server-owned repository-aware commit-message generation rules. @internal */
|
|
398
413
|
commit_messages?: CommitMessageConfig;
|
|
399
414
|
/** Bounded archive and extraction ceilings for local session transfer. @internal */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { KubernetesDockerConfig } from "./config-types.js";
|
|
2
|
+
|
|
3
|
+
/** Normalize trusted sandbox selection before passing it to a worker runner. @internal */
|
|
4
|
+
export function resolveKubernetesDockerIsolation(docker: KubernetesDockerConfig | undefined): {
|
|
5
|
+
isolation: KubernetesDockerConfig["isolation"];
|
|
6
|
+
errors: string[];
|
|
7
|
+
} {
|
|
8
|
+
const isolation = docker?.isolation ?? (docker?.gvisor ? "gvisor" : undefined);
|
|
9
|
+
const errors: string[] = [];
|
|
10
|
+
if (
|
|
11
|
+
docker?.isolation !== undefined &&
|
|
12
|
+
docker.gvisor !== undefined &&
|
|
13
|
+
docker.gvisor !== (docker.isolation === "gvisor")
|
|
14
|
+
) {
|
|
15
|
+
errors.push("kubernetes.docker.gvisor conflicts with kubernetes.docker.isolation");
|
|
16
|
+
}
|
|
17
|
+
if (isolation !== undefined && docker?.host_users !== undefined) {
|
|
18
|
+
errors.push("kubernetes.docker.host_users must be omitted for sandbox isolation");
|
|
19
|
+
}
|
|
20
|
+
return { isolation, errors };
|
|
21
|
+
}
|