@leitwerk-dev/server 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-WfwKzrVk.d.ts → app-CsuxFZT5.d.ts} +332 -111
- package/dist/app-JM4CBTND.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-LK3RO6C7.js → chunk-FPMDWQF7.js} +3050 -645
- package/dist/chunk-FPMDWQF7.js.map +1 -0
- package/dist/{chunk-KIOQNNG6.js → chunk-MBHRCQFE.js} +2781 -1822
- package/dist/chunk-MBHRCQFE.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 +14 -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/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/mapped-llm-run-repo.d.ts +56 -0
- package/dist/db/mapped-llm-run-repo.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 +4 -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 +7 -1
- 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/repo-helpers.d.ts +6 -0
- package/dist/db/repo-helpers.d.ts.map +1 -1
- package/dist/db/repositories.d.ts +16 -0
- package/dist/db/repositories.d.ts.map +1 -1
- package/dist/db/schema.d.ts +1177 -71
- 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 +1 -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/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 +4 -14
- 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-test-harness.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 +11 -0
- package/dist/process-action-presenter.d.ts.map +1 -0
- 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 +45 -0
- package/dist/process-engine/mapped-turns.d.ts.map +1 -0
- package/dist/process-engine/operation.d.ts +1 -1
- package/dist/process-engine/operation.d.ts.map +1 -1
- package/dist/process-engine/ops/accept-worker-turn-start.d.ts +2 -0
- package/dist/process-engine/ops/accept-worker-turn-start.d.ts.map +1 -1
- 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.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 +10 -1
- 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-recovery-start-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +10 -1
- 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.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/reserve-selected-turn-start.d.ts +5 -0
- package/dist/process-engine/writes/reserve-selected-turn-start.d.ts.map +1 -0
- package/dist/process-engine/writes/writes.d.ts +35 -49
- 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-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-navigation.d.ts +12 -2
- package/dist/process-turn-navigation.d.ts.map +1 -1
- package/dist/process-turn-trace.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts +15 -3
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- 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-diagnostics-assembler.d.ts +3 -1
- package/dist/routes/process-diagnostics-assembler.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-primary-path-assembler.d.ts +4 -12
- package/dist/routes/process-primary-path-assembler.d.ts.map +1 -1
- package/dist/routes/process-route-helpers.d.ts +15 -41
- 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 +83 -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 +5 -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 +3 -0
- package/dist/startup-evidence.d.ts.map +1 -1
- 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 +2 -0
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +4 -0
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts +2 -2
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts.map +1 -1
- package/dist/test-helpers/accepted-turn-start.d.ts +18 -4
- package/dist/test-helpers/accepted-turn-start.d.ts.map +1 -1
- package/dist/test-helpers/owned-test-deps.d.ts +18 -0
- package/dist/test-helpers/owned-test-deps.d.ts.map +1 -0
- 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.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +14 -10
- 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 +117 -5
- package/src/auth/fastify-auth.ts +13 -0
- package/src/config/config-loader.ts +40 -2
- package/src/config/config-types.ts +14 -1
- package/src/config/kubernetes-docker-isolation.ts +21 -0
- package/src/db/database.ts +159 -40
- package/src/db/execution-inspection-repo.ts +163 -0
- package/src/db/history-window.ts +18 -0
- package/src/db/mapped-llm-run-repo.ts +177 -0
- package/src/db/process-event-repo.ts +88 -10
- package/src/db/process-instance-repo.ts +9 -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 +53 -13
- package/src/db/publication-repo.ts +63 -0
- package/src/db/repo-helpers.ts +11 -1
- package/src/db/repositories.ts +22 -0
- package/src/db/schema.ts +173 -2
- 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 +12 -3
- package/src/db/worker-lease-repo.ts +8 -2
- package/src/domain-logic/outcome-tools.ts +4 -149
- 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 +14 -22
- package/src/integration-tool-registry.ts +59 -26
- package/src/launch-coordinator-test-harness.ts +8 -4
- 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 +98 -0
- package/src/process-action-registry.ts +31 -39
- package/src/process-engine/decision.ts +10 -0
- package/src/process-engine/engine.ts +13 -4
- package/src/process-engine/mapped-turns.ts +328 -0
- package/src/process-engine/operation.ts +1 -1
- package/src/process-engine/ops/accept-worker-turn-start.ts +6 -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 +10 -13
- package/src/process-engine/ops/start-process.ts +34 -2
- package/src/process-engine/ops/turn-outcome.ts +65 -62
- 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 +33 -5
- package/src/process-engine/runner.ts +8 -8
- 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 +15 -0
- package/src/process-engine/writes/build-process-abort-writes.ts +30 -19
- package/src/process-engine/writes/build-recovery-start-writes.ts +1 -0
- package/src/process-engine/writes/build-turn-outcome-writes.ts +118 -21
- package/src/process-engine/writes/build-turn-selection-writes.ts +2 -31
- package/src/process-engine/writes/commit-writes.ts +20 -2
- package/src/process-engine/writes/reserve-selected-turn-start.ts +44 -0
- package/src/process-engine/writes/writes.ts +73 -61
- 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-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-navigation.ts +86 -8
- package/src/process-turn-trace.ts +12 -24
- package/src/process-ui-snapshot-presenter.ts +249 -298
- 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-diagnostics-assembler.ts +32 -6
- package/src/routes/process-model-config.ts +70 -0
- package/src/routes/process-primary-path-assembler.ts +17 -33
- package/src/routes/process-route-helpers.ts +161 -327
- 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 +736 -0
- package/src/server-bootstrap/build-host-capabilities.ts +42 -0
- package/src/server-bootstrap/register-http.ts +7 -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 +97 -0
- package/src/skills/launch-skills.ts +19 -0
- package/src/skills/skill-frontmatter.ts +13 -0
- package/src/skills/source-importer.ts +3 -0
- package/src/startup-evidence.ts +20 -0
- package/src/supervisor/execution-inspection-ingestor.ts +55 -0
- package/src/supervisor/ipc-handler.ts +29 -18
- package/src/supervisor/worker-event-ingestor.ts +30 -14
- package/src/supervisor/worker-start-payload-builder.ts +42 -0
- package/src/supervisor/worker-supervisor.ts +5 -0
- package/src/supervisor/worker-turn-ipc-recorder.ts +13 -1
- package/src/test-helpers/accepted-turn-start.ts +51 -27
- package/src/test-helpers/owned-test-deps.ts +45 -0
- 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/testing.ts +4 -1
- 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-4QSV4FUQ.js +0 -8
- package/dist/chunk-KIOQNNG6.js.map +0 -1
- package/dist/chunk-LK3RO6C7.js.map +0 -1
- /package/dist/{app-4QSV4FUQ.js.map → app-JM4CBTND.js.map} +0 -0
|
@@ -14,8 +14,10 @@ import {
|
|
|
14
14
|
type ProvidedCapability,
|
|
15
15
|
type RegisteredProcessWatcherLike,
|
|
16
16
|
} from "@leitwerk-dev/process-sdk";
|
|
17
|
+
import { createWikiIntegration, topicWikiCapability } from "@leitwerk-dev/wiki/integration";
|
|
17
18
|
import type { LeitwerkConfig } from "../config/index.js";
|
|
18
19
|
import type { RepositoryBundle } from "../db/repositories.js";
|
|
20
|
+
import type { IntegrationToolRegistry } from "../integration-tool-registry.js";
|
|
19
21
|
import type { LaunchCoordinator } from "../launch-coordinator.js";
|
|
20
22
|
import type { ProcessEngine } from "../process-engine/types.js";
|
|
21
23
|
import type { ProjectMutationService } from "../project-mutation-service.js";
|
|
@@ -28,6 +30,7 @@ export function buildHostCapabilities(input: {
|
|
|
28
30
|
baseDeps: RepositoryBundle & { broadcaster: Broadcaster };
|
|
29
31
|
projectMutations: ProjectMutationService;
|
|
30
32
|
commands: ProcessEngine;
|
|
33
|
+
integrationTools: IntegrationToolRegistry;
|
|
31
34
|
getSupervisor: () => WorkerSupervisor | undefined;
|
|
32
35
|
listVisibleActionsForProcess: (instanceId: string) => readonly ProcessActionSummaryLike[];
|
|
33
36
|
launcherService: unknown;
|
|
@@ -45,9 +48,47 @@ export function buildHostCapabilities(input: {
|
|
|
45
48
|
preProvidedCapabilities?: readonly ProvidedCapability[];
|
|
46
49
|
}) {
|
|
47
50
|
const hostCapabilities = createCapabilityAccessor([
|
|
51
|
+
{ token: topicWikiCapability, value: createWikiIntegration(input.baseDeps.topicWiki) },
|
|
48
52
|
{
|
|
49
53
|
token: coreHostCapabilities.serverSetup,
|
|
50
54
|
value: {
|
|
55
|
+
async callIntegrationTool(
|
|
56
|
+
expected: import("@leitwerk-dev/domain").ProcessInstance,
|
|
57
|
+
projectKey: string,
|
|
58
|
+
name: string,
|
|
59
|
+
args: Record<string, unknown>,
|
|
60
|
+
signal: AbortSignal,
|
|
61
|
+
) {
|
|
62
|
+
const process = input.baseDeps.processes.getById(expected.id);
|
|
63
|
+
if (
|
|
64
|
+
!process ||
|
|
65
|
+
process.lifecycleStatus !== expected.lifecycleStatus ||
|
|
66
|
+
process.selectedTurnId !== expected.selectedTurnId ||
|
|
67
|
+
process.paramsJson !== expected.paramsJson ||
|
|
68
|
+
process.stateJson !== expected.stateJson ||
|
|
69
|
+
process.planRevision !== expected.planRevision
|
|
70
|
+
)
|
|
71
|
+
throw new Error("Process changed before maintenance delivery");
|
|
72
|
+
const projects = input.baseDeps.projects.listByInstance(process.id);
|
|
73
|
+
const project = projects.find((candidate) => candidate.key === projectKey);
|
|
74
|
+
const turn = input.baseDeps.turnRecords.listByInstance(process.id).at(-1);
|
|
75
|
+
if (!project || !turn)
|
|
76
|
+
throw new Error(
|
|
77
|
+
"Maintenance delivery requires a bound project and publication history",
|
|
78
|
+
);
|
|
79
|
+
return input.integrationTools.executeServer(
|
|
80
|
+
name,
|
|
81
|
+
{ ...args, projectKey },
|
|
82
|
+
{
|
|
83
|
+
process,
|
|
84
|
+
projects,
|
|
85
|
+
project,
|
|
86
|
+
turn,
|
|
87
|
+
idempotencyKey: `maintenance:${process.id}:${projectKey}:${name}`,
|
|
88
|
+
},
|
|
89
|
+
signal,
|
|
90
|
+
);
|
|
91
|
+
},
|
|
51
92
|
get serverBaseUrl() {
|
|
52
93
|
return input.config.server.base_url;
|
|
53
94
|
},
|
|
@@ -56,6 +97,7 @@ export function buildHostCapabilities(input: {
|
|
|
56
97
|
},
|
|
57
98
|
components: input.config.components,
|
|
58
99
|
externalWrites: input.baseDeps.externalWrites,
|
|
100
|
+
publications: input.baseDeps.publications,
|
|
59
101
|
processes: input.baseDeps.processes,
|
|
60
102
|
projects: input.projectMutations,
|
|
61
103
|
events: input.baseDeps.events,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { registerTopicWikiRoutes } from "@leitwerk-dev/wiki/server";
|
|
1
2
|
import type { FastifyInstance } from "fastify";
|
|
2
3
|
import { registerApiTokenAudit } from "../auth/api-token-audit.js";
|
|
3
4
|
import type { AuthService } from "../auth/auth-service.js";
|
|
4
|
-
import { requireApiActor } from "../auth/fastify-auth.js";
|
|
5
|
+
import { actorForRequest, requireApiActor } from "../auth/fastify-auth.js";
|
|
5
6
|
import { registerAuthRoutes } from "../auth/routes.js";
|
|
6
7
|
import type { ExtensionUiCatalog } from "../extension-ui/catalog.js";
|
|
7
8
|
import type { IntegrationToolRegistry } from "../integration-tool-registry.js";
|
|
@@ -11,6 +12,7 @@ import { registerInternalSessionTransferExportRoutes } from "../routes/internal-
|
|
|
11
12
|
import { registerInternalWorkerSessionSnapshotRoutes } from "../routes/internal-worker-session-snapshot.js";
|
|
12
13
|
import { type RouteDeps, registerProcessRoutes } from "../routes/processes.js";
|
|
13
14
|
import { registerResultImageRoutes } from "../routes/result-images.js";
|
|
15
|
+
import { registerSettingsRoutes } from "../routes/settings.js";
|
|
14
16
|
import { registerSkillRoutes } from "../routes/skills.js";
|
|
15
17
|
import { registerTicketCreationRoutes } from "../routes/ticket-creation.js";
|
|
16
18
|
import { registerUiRendererRoutes } from "../routes/ui-renderers.js";
|
|
@@ -74,6 +76,10 @@ export function registerHttp(input: {
|
|
|
74
76
|
store: input.resultImages,
|
|
75
77
|
});
|
|
76
78
|
registerProcessRoutes(input.app, input.deps);
|
|
79
|
+
if (input.deps.topicWiki)
|
|
80
|
+
registerTopicWikiRoutes(input.app, input.deps.topicWiki, actorForRequest);
|
|
81
|
+
if (input.deps.scopedSettingsService)
|
|
82
|
+
registerSettingsRoutes(input.app, input.deps.scopedSettingsService, input.deps);
|
|
77
83
|
registerWatcherRoutes(input.app, { processWatchers: input.processWatcherService });
|
|
78
84
|
registerTicketCreationRoutes(input.app, input.deps, input.integrationTools);
|
|
79
85
|
if (input.deps.skillCatalog) {
|
|
@@ -90,8 +90,7 @@ export function createProjectedSessionSnapshotStore(
|
|
|
90
90
|
},
|
|
91
91
|
backfill(instanceId: string) {
|
|
92
92
|
return serial(instanceId, async () => {
|
|
93
|
-
for (const turn of repos.turnRecords.
|
|
94
|
-
if (repos.turnSummaries.get(turn.id)) continue;
|
|
93
|
+
for (const turn of repos.turnRecords.listMissingSummaries(instanceId)) {
|
|
95
94
|
let summary = emptyCompactTurnSummary();
|
|
96
95
|
for (const event of repos.events.listByTurnRecord(instanceId, turn.id)) {
|
|
97
96
|
summary = applyEventToCompactTurnSummary(summary, {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import type { CatalogPiContribution } from "@leitwerk-dev/extension-runtime";
|
|
3
|
+
import type { InstalledSkillCatalogDetail } from "@leitwerk-dev/protocol";
|
|
4
|
+
import { createCanonicalPiResourceBundle } from "@leitwerk-dev/worker-protocol";
|
|
5
|
+
import { ResourceCollector } from "../pi-resources/resource-collector.js";
|
|
6
|
+
import { isSkillModelInvocable, skillMetadata } from "./skill-frontmatter.js";
|
|
7
|
+
import { SAFE_SKILL_ID_PATTERN } from "./skill-id.js";
|
|
8
|
+
|
|
9
|
+
/** Read the same declared skill directories used by worker snapshots. @internal */
|
|
10
|
+
export async function importBundledSkills(
|
|
11
|
+
contributions: readonly CatalogPiContribution[],
|
|
12
|
+
): Promise<InstalledSkillCatalogDetail[]> {
|
|
13
|
+
const skills = new Map<string, InstalledSkillCatalogDetail>();
|
|
14
|
+
const collector = new ResourceCollector();
|
|
15
|
+
for (const contribution of contributions) {
|
|
16
|
+
for (const directory of contribution.resources.skillDirectories) {
|
|
17
|
+
await collector.addDirectory(directory, "skills", {
|
|
18
|
+
kind: "skill",
|
|
19
|
+
ownerExtensionId: contribution.ownerExtensionId,
|
|
20
|
+
packageName: contribution.packageName,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const files = collector.toResourceFiles();
|
|
25
|
+
for (const file of files) {
|
|
26
|
+
if (!file.path.endsWith("/SKILL.md")) continue;
|
|
27
|
+
const skillRoot = path.posix.dirname(file.path);
|
|
28
|
+
const skillId = path.posix.basename(skillRoot);
|
|
29
|
+
if (!SAFE_SKILL_ID_PATTERN.test(skillId)) {
|
|
30
|
+
throw new Error(`Bundled skill has an invalid id '${skillId}' at '${file.path}'`);
|
|
31
|
+
}
|
|
32
|
+
if (skills.has(skillId)) throw new Error(`Duplicate bundled skill id '${skillId}'`);
|
|
33
|
+
const skillMarkdown = Buffer.from(file.content).toString("utf8");
|
|
34
|
+
const metadata = skillMetadata(skillMarkdown);
|
|
35
|
+
const sourceExtensionId = collector.provenance.find(
|
|
36
|
+
(source) => source.snapshotPath === file.path,
|
|
37
|
+
)?.ownerExtensionId;
|
|
38
|
+
const bundle = createCanonicalPiResourceBundle(
|
|
39
|
+
files.filter((candidate) => candidate.path.startsWith(`${skillRoot}/`)),
|
|
40
|
+
);
|
|
41
|
+
skills.set(skillId, {
|
|
42
|
+
id: skillId,
|
|
43
|
+
label: metadata.name ?? skillId,
|
|
44
|
+
description: metadata.description,
|
|
45
|
+
registrationKind: "bundled",
|
|
46
|
+
...(sourceExtensionId ? { sourceExtensionId } : {}),
|
|
47
|
+
activeRevisionId: bundle.digest,
|
|
48
|
+
activeSourceRevision: null,
|
|
49
|
+
sourceRepositoryId: null,
|
|
50
|
+
updateAvailable: false,
|
|
51
|
+
modelInvocable: isSkillModelInvocable(skillMarkdown),
|
|
52
|
+
usage: {
|
|
53
|
+
attachedAllTime: 0,
|
|
54
|
+
attachedLast30Days: 0,
|
|
55
|
+
invokedAllTime: 0,
|
|
56
|
+
invokedLast30Days: 0,
|
|
57
|
+
},
|
|
58
|
+
skillMarkdown,
|
|
59
|
+
processes: [],
|
|
60
|
+
revisions: [],
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return [...skills.values()];
|
|
64
|
+
}
|
|
@@ -27,9 +27,16 @@ export interface SkillCatalogService {
|
|
|
27
27
|
export function createSkillCatalogService(input: {
|
|
28
28
|
repositories: readonly SkillRepositoryConfig[];
|
|
29
29
|
repos: RepositoryBundle;
|
|
30
|
+
bundledSkills?: readonly InstalledSkillCatalogDetail[];
|
|
30
31
|
importRepository?: typeof importSkillRepository;
|
|
31
32
|
}): SkillCatalogService {
|
|
32
33
|
const importRepository = input.importRepository ?? importSkillRepository;
|
|
34
|
+
const bundledSkills = new Map((input.bundledSkills ?? []).map((skill) => [skill.id, skill]));
|
|
35
|
+
for (const skill of input.repos.skills.listAvailable()) {
|
|
36
|
+
if (bundledSkills.has(skill.id)) {
|
|
37
|
+
throw new Error(`Bundled skill '${skill.id}' conflicts with an installed skill`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
33
40
|
const statuses = new Map<string, { lastRefreshedAt: string | null; error: string | null }>();
|
|
34
41
|
let refreshPromise: Promise<SkillsCatalogResponseBody> | null = null;
|
|
35
42
|
input.repos.transaction((repos) =>
|
|
@@ -52,10 +59,25 @@ export function createSkillCatalogService(input: {
|
|
|
52
59
|
};
|
|
53
60
|
});
|
|
54
61
|
|
|
55
|
-
const list = (): SkillsCatalogResponseBody =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
const list = (): SkillsCatalogResponseBody => {
|
|
63
|
+
const catalog = input.repos.skills.catalog();
|
|
64
|
+
return {
|
|
65
|
+
repositories: summaries(),
|
|
66
|
+
availableSkills: catalog.availableSkills.map((skill) =>
|
|
67
|
+
bundledSkills.has(skill.id)
|
|
68
|
+
? { ...skill, conflict: !skill.stale, registered: false, updateAvailable: false }
|
|
69
|
+
: skill,
|
|
70
|
+
),
|
|
71
|
+
installedSkills: [
|
|
72
|
+
...catalog.installedSkills,
|
|
73
|
+
...[...bundledSkills.values()].map(
|
|
74
|
+
({ skillMarkdown, processes, revisions, ...skill }) => skill,
|
|
75
|
+
),
|
|
76
|
+
].sort(
|
|
77
|
+
(left, right) => left.label.localeCompare(right.label) || left.id.localeCompare(right.id),
|
|
78
|
+
),
|
|
79
|
+
};
|
|
80
|
+
};
|
|
59
81
|
|
|
60
82
|
const refresh = (): Promise<SkillsCatalogResponseBody> => {
|
|
61
83
|
if (refreshPromise) return refreshPromise;
|
|
@@ -88,17 +110,24 @@ export function createSkillCatalogService(input: {
|
|
|
88
110
|
list,
|
|
89
111
|
refresh,
|
|
90
112
|
detail(repositoryId, skillId) {
|
|
91
|
-
|
|
113
|
+
const detail = input.repos.skills.getCatalogDetail(repositoryId, skillId);
|
|
114
|
+
return detail && bundledSkills.has(skillId)
|
|
115
|
+
? { ...detail, conflict: !detail.stale, registered: false, updateAvailable: false }
|
|
116
|
+
: detail;
|
|
92
117
|
},
|
|
93
118
|
installedDetail(skillId) {
|
|
94
|
-
return input.repos.skills.getInstalledDetail(skillId);
|
|
119
|
+
return bundledSkills.get(skillId) ?? input.repos.skills.getInstalledDetail(skillId);
|
|
95
120
|
},
|
|
96
121
|
register(repositoryId, skillId) {
|
|
122
|
+
if (bundledSkills.has(skillId)) {
|
|
123
|
+
throw new Error(`Skill '${skillId}' has a conflicting bundled extension skill`);
|
|
124
|
+
}
|
|
97
125
|
return input.repos.transaction((repos) =>
|
|
98
126
|
repos.skills.registerCatalogEntry(repositoryId, skillId),
|
|
99
127
|
);
|
|
100
128
|
},
|
|
101
129
|
remove(skillId) {
|
|
130
|
+
if (bundledSkills.has(skillId)) return false;
|
|
102
131
|
return input.repos.transaction((repos) => repos.skills.remove(skillId));
|
|
103
132
|
},
|
|
104
133
|
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { lstat, readFile, realpath } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import type { LoadedExtensionModule } from "@leitwerk-dev/extension-runtime";
|
|
4
|
+
import { parseSkillPackManifest, type SkillRevisionProvenance } from "@leitwerk-dev/protocol";
|
|
5
|
+
import { createCanonicalPiResourceBundle } from "@leitwerk-dev/worker-protocol";
|
|
6
|
+
import { parse as parseYaml } from "yaml";
|
|
7
|
+
import { ResourceCollector } from "../pi-resources/resource-collector.js";
|
|
8
|
+
import type { ImportedSkill } from "./source-importer.js";
|
|
9
|
+
|
|
10
|
+
/** @internal */
|
|
11
|
+
export interface ImportedExtensionSkill extends ImportedSkill {
|
|
12
|
+
/** @internal */
|
|
13
|
+
provenance: SkillRevisionProvenance;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function packagePath(packageRoot: string, target: string): Promise<string> {
|
|
17
|
+
const relative = path.relative(packageRoot, target);
|
|
18
|
+
if (
|
|
19
|
+
!relative ||
|
|
20
|
+
relative === ".." ||
|
|
21
|
+
relative.startsWith(`..${path.sep}`) ||
|
|
22
|
+
path.isAbsolute(relative)
|
|
23
|
+
) {
|
|
24
|
+
throw new Error(`Skill-pack path escapes package: ${target}`);
|
|
25
|
+
}
|
|
26
|
+
let current = packageRoot;
|
|
27
|
+
for (const part of relative.split(path.sep)) {
|
|
28
|
+
current = path.join(current, part);
|
|
29
|
+
if ((await lstat(current)).isSymbolicLink())
|
|
30
|
+
throw new Error(`Skill-pack symlink is forbidden: ${current}`);
|
|
31
|
+
}
|
|
32
|
+
return current;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Import only declared packages; no network or patch execution at runtime. @internal */
|
|
36
|
+
export async function importExtensionSkills(
|
|
37
|
+
modules: readonly LoadedExtensionModule[],
|
|
38
|
+
): Promise<ImportedExtensionSkill[]> {
|
|
39
|
+
const imported: ImportedExtensionSkill[] = [];
|
|
40
|
+
for (const loaded of modules) {
|
|
41
|
+
if (!loaded.skillPackPath) continue;
|
|
42
|
+
const packageRoot = await realpath(loaded.packageDir);
|
|
43
|
+
const manifestPath = await packagePath(
|
|
44
|
+
packageRoot,
|
|
45
|
+
path.resolve(packageRoot, path.relative(loaded.packageDir, loaded.skillPackPath)),
|
|
46
|
+
);
|
|
47
|
+
const manifest = parseSkillPackManifest(JSON.parse(await readFile(manifestPath, "utf8")));
|
|
48
|
+
for (const skill of manifest.skills) {
|
|
49
|
+
const directory = await packagePath(
|
|
50
|
+
packageRoot,
|
|
51
|
+
path.resolve(path.dirname(manifestPath), skill.directory),
|
|
52
|
+
);
|
|
53
|
+
const provenance: SkillRevisionProvenance = {
|
|
54
|
+
extensionId: loaded.module.manifest.id,
|
|
55
|
+
packageName: loaded.packageName,
|
|
56
|
+
packageVersion: loaded.packageVersion ?? loaded.module.manifest.version,
|
|
57
|
+
upstream: manifest.upstream,
|
|
58
|
+
sourcePath: skill.sourcePath,
|
|
59
|
+
patchDigest: manifest.patchDigest,
|
|
60
|
+
dependencies: skill.dependencies,
|
|
61
|
+
};
|
|
62
|
+
const collector = new ResourceCollector();
|
|
63
|
+
await collector.addDirectory(
|
|
64
|
+
directory,
|
|
65
|
+
`skills/${skill.id}`,
|
|
66
|
+
{
|
|
67
|
+
kind: "skill",
|
|
68
|
+
ownerExtensionId: provenance.extensionId,
|
|
69
|
+
packageName: provenance.packageName,
|
|
70
|
+
},
|
|
71
|
+
{ forbiddenNames: new Set([".git", ".leitwerk-skill.json"]) },
|
|
72
|
+
);
|
|
73
|
+
const markdown = collector.files.get(`skills/${skill.id}/SKILL.md`);
|
|
74
|
+
const header =
|
|
75
|
+
markdown &&
|
|
76
|
+
/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(Buffer.from(markdown).toString("utf8"));
|
|
77
|
+
const metadata = header ? parseYaml(header[1]) : null;
|
|
78
|
+
if (metadata?.name !== skill.id || metadata.description !== skill.description) {
|
|
79
|
+
throw new Error(`Skill '${skill.id}' frontmatter does not match its pack manifest`);
|
|
80
|
+
}
|
|
81
|
+
// Include dependency/provenance changes in revision identity even when prose is unchanged.
|
|
82
|
+
collector.addBytes(
|
|
83
|
+
`skills/${skill.id}/.leitwerk-skill.json`,
|
|
84
|
+
Buffer.from(JSON.stringify(provenance)),
|
|
85
|
+
);
|
|
86
|
+
imported.push({
|
|
87
|
+
skillId: skill.id,
|
|
88
|
+
label: skill.label,
|
|
89
|
+
description: skill.description,
|
|
90
|
+
sourceRevision: manifest.upstream.commit,
|
|
91
|
+
provenance,
|
|
92
|
+
bundle: createCanonicalPiResourceBundle(collector.toResourceFiles()),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return imported;
|
|
97
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SkillSelection } from "@leitwerk-dev/protocol";
|
|
2
|
+
import type { LeitwerkConfig } from "../config/config-types.js";
|
|
3
|
+
import type { RepositoryBundle } from "../db/repositories.js";
|
|
4
|
+
|
|
5
|
+
/** Server-owned defaults, resolved only when selecting skills for a new launch. @internal */
|
|
6
|
+
export type LaunchSkillDefaults = Pick<LeitwerkConfig, "default_skills" | "process_configs">;
|
|
7
|
+
|
|
8
|
+
/** @internal */
|
|
9
|
+
export function resolveLaunchSkills(
|
|
10
|
+
deps: { skills: RepositoryBundle["skills"]; skillDefaults?: LaunchSkillDefaults },
|
|
11
|
+
processId: string,
|
|
12
|
+
selectedSkillIds: readonly string[] = [],
|
|
13
|
+
): SkillSelection[] {
|
|
14
|
+
const defaults =
|
|
15
|
+
deps.skillDefaults?.process_configs?.[processId]?.default_skills ??
|
|
16
|
+
deps.skillDefaults?.default_skills ??
|
|
17
|
+
[];
|
|
18
|
+
return deps.skills.resolveActive([...new Set([...defaults, ...selectedSkillIds])]);
|
|
19
|
+
}
|
|
@@ -15,3 +15,16 @@ function frontmatter(markdown: string): Record<string, unknown> | null {
|
|
|
15
15
|
export function isSkillModelInvocable(markdown: string): boolean {
|
|
16
16
|
return frontmatter(markdown)?.["disable-model-invocation"] !== true;
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
/** @internal */
|
|
20
|
+
export function skillMetadata(markdown: string): {
|
|
21
|
+
name: string | null;
|
|
22
|
+
description: string | null;
|
|
23
|
+
} {
|
|
24
|
+
const metadata = frontmatter(markdown);
|
|
25
|
+
const text = (key: string): string | null => {
|
|
26
|
+
const value = metadata?.[key];
|
|
27
|
+
return typeof value === "string" ? value.trim() || null : null;
|
|
28
|
+
};
|
|
29
|
+
return { name: text("name"), description: text("description") };
|
|
30
|
+
}
|
|
@@ -3,6 +3,7 @@ import { mkdtemp, readdir, readFile, rm } from "node:fs/promises";
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
|
+
import type { SkillRevisionProvenance } from "@leitwerk-dev/protocol";
|
|
6
7
|
import {
|
|
7
8
|
createCanonicalPiResourceBundle,
|
|
8
9
|
type PiResourceBundle,
|
|
@@ -17,6 +18,8 @@ const FORBIDDEN_SKILL_NAMES = new Set([".git"]);
|
|
|
17
18
|
|
|
18
19
|
/** @internal */
|
|
19
20
|
export interface ImportedSkill {
|
|
21
|
+
/** Explicit extension provenance and dependencies. @internal */
|
|
22
|
+
provenance?: SkillRevisionProvenance;
|
|
20
23
|
/** @internal */
|
|
21
24
|
skillId: string;
|
|
22
25
|
/** @internal */
|
package/src/startup-evidence.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
StartupRecoverySummary,
|
|
14
14
|
} from "@leitwerk-dev/protocol";
|
|
15
15
|
import { completeLaunchWhenReady, failLaunchRun } from "./launch-pipeline.js";
|
|
16
|
+
import { pendingTurnWait } from "./process-engine/turn-wait-state.js";
|
|
16
17
|
|
|
17
18
|
export interface StartupEvidenceInput {
|
|
18
19
|
process: ProcessInstance;
|
|
@@ -23,6 +24,7 @@ export interface StartupEvidenceInput {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export interface StartupEvidence {
|
|
27
|
+
readiness?: { message: string | null };
|
|
26
28
|
attempts: readonly StartupAttemptSummary[];
|
|
27
29
|
currentAttempt: StartupAttemptSummary | null;
|
|
28
30
|
authoritativeAttemptId: string | null;
|
|
@@ -259,6 +261,9 @@ export function buildStartupEvidence(input: StartupEvidenceInput): StartupEviden
|
|
|
259
261
|
null;
|
|
260
262
|
return {
|
|
261
263
|
attempts: recoveredAttempts,
|
|
264
|
+
...(pendingTurnWait(input.process)?.initialSelection
|
|
265
|
+
? { readiness: { message: pendingTurnWait(input.process)?.message ?? null } }
|
|
266
|
+
: {}),
|
|
262
267
|
currentAttempt,
|
|
263
268
|
authoritativeAttemptId: authoritative?.startRecordId ?? null,
|
|
264
269
|
recovery: buildStartupRecovery(input.process, turnStartsById),
|
|
@@ -343,6 +348,21 @@ export function projectLaunchRunStartup(
|
|
|
343
348
|
}),
|
|
344
349
|
};
|
|
345
350
|
const failedStep = attempt?.steps.find((step) => step.status === "failed");
|
|
351
|
+
if (!attempt && evidence.readiness) {
|
|
352
|
+
next = {
|
|
353
|
+
...next,
|
|
354
|
+
steps: next.steps.map((step) =>
|
|
355
|
+
step.id === "start_worker"
|
|
356
|
+
? {
|
|
357
|
+
...step,
|
|
358
|
+
status: "pending",
|
|
359
|
+
label: "Waiting for startup prerequisites",
|
|
360
|
+
safeSummary: evidence.readiness?.message ?? "Checking startup prerequisites…",
|
|
361
|
+
}
|
|
362
|
+
: step,
|
|
363
|
+
),
|
|
364
|
+
};
|
|
365
|
+
}
|
|
346
366
|
if (failedStep) {
|
|
347
367
|
next = failLaunchRun(
|
|
348
368
|
next,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ExecutionInspectionCapture } from "@leitwerk-dev/domain";
|
|
2
|
+
import type { RepositoryBundle } from "../db/repositories.js";
|
|
3
|
+
|
|
4
|
+
/** Accepted execution ownership is checked before retaining any expanded evidence. */
|
|
5
|
+
export function ingestExecutionInspection(
|
|
6
|
+
deps: Pick<RepositoryBundle, "executionInspections" | "turnRecords" | "leases">,
|
|
7
|
+
input: { instanceId: string; workerId: string; turnRecordId: string; capture: unknown },
|
|
8
|
+
): boolean {
|
|
9
|
+
const record = deps.turnRecords.getById(input.turnRecordId);
|
|
10
|
+
const lease = deps.leases.getByInstance(input.instanceId);
|
|
11
|
+
if (
|
|
12
|
+
!record ||
|
|
13
|
+
record.instanceId !== input.instanceId ||
|
|
14
|
+
record.status !== "running" ||
|
|
15
|
+
!record.turnStartRecordId ||
|
|
16
|
+
!lease ||
|
|
17
|
+
lease.workerId !== input.workerId ||
|
|
18
|
+
lease.turnStartRecordId !== record.turnStartRecordId ||
|
|
19
|
+
lease.exitedAt !== null
|
|
20
|
+
)
|
|
21
|
+
return false;
|
|
22
|
+
const capture = input.capture as ExecutionInspectionCapture | null;
|
|
23
|
+
if (
|
|
24
|
+
!capture ||
|
|
25
|
+
capture.version !== 1 ||
|
|
26
|
+
typeof capture.id !== "string" ||
|
|
27
|
+
!capture.id ||
|
|
28
|
+
typeof capture.timestamp !== "string" ||
|
|
29
|
+
!capture.fact ||
|
|
30
|
+
!["model_input", "supplied_context", "product_consumed", "entry_link"].includes(
|
|
31
|
+
capture.fact.kind,
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
return false;
|
|
35
|
+
if (capture.fact.kind === "supplied_context") {
|
|
36
|
+
for (const product of capture.fact.products) {
|
|
37
|
+
const producer = deps.turnRecords.getById(product.producerTurnRecordId);
|
|
38
|
+
if (
|
|
39
|
+
!producer ||
|
|
40
|
+
producer.instanceId !== input.instanceId ||
|
|
41
|
+
producer.resultPiEntryId !== product.entryId
|
|
42
|
+
)
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
deps.executionInspections.append({
|
|
47
|
+
...capture,
|
|
48
|
+
id: `${input.turnRecordId}:${capture.id}`,
|
|
49
|
+
instanceId: input.instanceId,
|
|
50
|
+
turnRecordId: record.id,
|
|
51
|
+
startRecordId: record.turnStartRecordId,
|
|
52
|
+
workerLeaseId: lease.id,
|
|
53
|
+
});
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
@@ -48,6 +48,8 @@ export interface IpcHandlerDeps
|
|
|
48
48
|
/** @internal */
|
|
49
49
|
startupObservations?: RepositoryBundle["startupObservations"];
|
|
50
50
|
/** @internal */
|
|
51
|
+
executionInspections?: RepositoryBundle["executionInspections"];
|
|
52
|
+
/** @internal */
|
|
51
53
|
getLaunchCoordinator?: () => LaunchCoordinator | undefined;
|
|
52
54
|
/** @internal */
|
|
53
55
|
processQuestions?: ProcessQuestionService;
|
|
@@ -285,36 +287,45 @@ export function createIpcHandler(deps: IpcHandlerDeps, callbacks: IpcHandlerCall
|
|
|
285
287
|
break;
|
|
286
288
|
}
|
|
287
289
|
case "worker.turn_started": {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
290
|
+
let accepted = false;
|
|
291
|
+
const onRecorded = (turnRecordId: string) => {
|
|
292
|
+
accepted = true;
|
|
293
|
+
eventIngestor.noteTurnStarted(instanceId, turnRecordId);
|
|
294
|
+
callbacks.onWorkerTurnStartAccepted?.(instanceId, workerId, {
|
|
291
295
|
startRecordId: msg.payload.startRecordId,
|
|
292
|
-
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
|
|
296
|
+
turnRecordId,
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
void deps.commands
|
|
300
|
+
.acceptWorkerTurnStart(
|
|
301
|
+
instanceId,
|
|
302
|
+
{
|
|
303
|
+
workerLeaseId: activeLease.id,
|
|
304
|
+
startRecordId: msg.payload.startRecordId,
|
|
305
|
+
proposedTurnRecordId: msg.payload.proposedTurnRecordId,
|
|
306
|
+
},
|
|
307
|
+
{ onRecorded },
|
|
308
|
+
)
|
|
309
|
+
.then(() => {
|
|
310
|
+
if (!accepted) {
|
|
296
311
|
callbacks.onWorkerFailed?.(instanceId, workerId, "Worker turn start was rejected");
|
|
297
312
|
return;
|
|
298
313
|
}
|
|
299
|
-
eventIngestor.noteTurnStarted(instanceId, result.data.turnRecordId);
|
|
300
|
-
// Acceptance persists the correlated turn record before launch projection.
|
|
301
314
|
launchCoordinator?.refresh(instanceId);
|
|
302
|
-
callbacks.onWorkerTurnStartAccepted?.(instanceId, workerId, {
|
|
303
|
-
startRecordId: msg.payload.startRecordId,
|
|
304
|
-
turnRecordId: result.data.turnRecordId,
|
|
305
|
-
});
|
|
306
315
|
})
|
|
307
|
-
.catch(() =>
|
|
308
|
-
|
|
309
|
-
|
|
316
|
+
.catch(() => {
|
|
317
|
+
// Delivery/projection failures do not undo durable acceptance; replay is safe.
|
|
318
|
+
if (!accepted)
|
|
319
|
+
callbacks.onWorkerFailed?.(instanceId, workerId, "Worker turn start failed");
|
|
320
|
+
});
|
|
310
321
|
break;
|
|
311
322
|
}
|
|
312
323
|
case "worker.turn_outcome": {
|
|
313
|
-
turnRecorder.recordTurnOutcome(instanceId, workerId, msg.payload);
|
|
324
|
+
turnRecorder.recordTurnOutcome(instanceId, workerId, activeLease.id, msg.payload);
|
|
314
325
|
break;
|
|
315
326
|
}
|
|
316
327
|
case "worker.turn_failed": {
|
|
317
|
-
turnRecorder.recordTurnFailed(instanceId, workerId, msg.payload);
|
|
328
|
+
turnRecorder.recordTurnFailed(instanceId, workerId, activeLease.id, msg.payload);
|
|
318
329
|
break;
|
|
319
330
|
}
|
|
320
331
|
case "worker.lifecycle_parked": {
|