@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
|
@@ -50,6 +50,7 @@ import type { ServerProcessModelPolicy } from "../process-model-policy/index.js"
|
|
|
50
50
|
import { presentLaunchPlanPreparationIssues } from "../process-model-policy-presenter.js";
|
|
51
51
|
import type { ProcessOperationCoordinator } from "../process-operation-coordinator.js";
|
|
52
52
|
import type { ProcessTitleGenerator } from "../process-title-generator.js";
|
|
53
|
+
import { type LaunchSkillDefaults, resolveLaunchSkills } from "../skills/launch-skills.js";
|
|
53
54
|
import type { Broadcaster } from "../ws/broadcast.js";
|
|
54
55
|
import { projectLaunchPlanModelState } from "./model-projection.js";
|
|
55
56
|
import {
|
|
@@ -65,7 +66,7 @@ import { planConsumeFutureExecution } from "./transition-planner.js";
|
|
|
65
66
|
export interface FutureExecutionIssue extends LauncherValidationError {}
|
|
66
67
|
|
|
67
68
|
/** @internal */
|
|
68
|
-
type LaunchFailure =
|
|
69
|
+
export type LaunchFailure =
|
|
69
70
|
| {
|
|
70
71
|
/** @internal */
|
|
71
72
|
kind: "invalid";
|
|
@@ -147,31 +148,10 @@ export type LaunchMutationOutcome =
|
|
|
147
148
|
export interface NormalizedScheduledLaunchInput extends ParsedLauncherRequestBody {}
|
|
148
149
|
|
|
149
150
|
/** @internal */
|
|
150
|
-
export type ValidatedLaunchSchedule =
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
/** @internal */
|
|
155
|
-
nextRunAt: null;
|
|
156
|
-
/** @internal */
|
|
157
|
-
cronExpression: null;
|
|
158
|
-
}
|
|
159
|
-
| {
|
|
160
|
-
/** @internal */
|
|
161
|
-
mode: "once";
|
|
162
|
-
/** @internal */
|
|
163
|
-
nextRunAt: string;
|
|
164
|
-
/** @internal */
|
|
165
|
-
cronExpression: null;
|
|
166
|
-
}
|
|
167
|
-
| {
|
|
168
|
-
/** @internal */
|
|
169
|
-
mode: "cron";
|
|
170
|
-
/** @internal */
|
|
171
|
-
nextRunAt: string;
|
|
172
|
-
/** @internal */
|
|
173
|
-
cronExpression: string;
|
|
174
|
-
};
|
|
151
|
+
export type ValidatedLaunchSchedule = Extract<
|
|
152
|
+
ReturnType<typeof validateScheduleRequestInput>,
|
|
153
|
+
{ ok: true }
|
|
154
|
+
>["value"];
|
|
175
155
|
|
|
176
156
|
/** @internal */
|
|
177
157
|
export interface PreparedLaunch {
|
|
@@ -234,6 +214,7 @@ export interface FutureLaunchLifecycleDeps
|
|
|
234
214
|
processModelPolicy: ServerProcessModelPolicy;
|
|
235
215
|
modelStatusCache: Pick<ModelStatusCache, "snapshot">;
|
|
236
216
|
logger?: ProcessEngineLogger;
|
|
217
|
+
skillDefaults?: LaunchSkillDefaults;
|
|
237
218
|
}
|
|
238
219
|
|
|
239
220
|
function invalidOutcome(
|
|
@@ -244,13 +225,14 @@ function invalidOutcome(
|
|
|
244
225
|
}
|
|
245
226
|
|
|
246
227
|
function resolveSelectedSkills(
|
|
247
|
-
|
|
228
|
+
deps: FutureLaunchLifecycleDeps,
|
|
229
|
+
processId: string,
|
|
248
230
|
ids: readonly string[],
|
|
249
231
|
):
|
|
250
232
|
| { ok: true; value: readonly SkillSelection[] }
|
|
251
233
|
| { ok: false; outcome: Extract<LaunchFailure, { kind: "invalid" }> } {
|
|
252
234
|
try {
|
|
253
|
-
return { ok: true, value:
|
|
235
|
+
return { ok: true, value: resolveLaunchSkills(deps, processId, ids) };
|
|
254
236
|
} catch (error) {
|
|
255
237
|
return {
|
|
256
238
|
ok: false,
|
|
@@ -293,30 +275,61 @@ function launchFailureOutcome(
|
|
|
293
275
|
: { kind: "failed", issue };
|
|
294
276
|
}
|
|
295
277
|
|
|
296
|
-
function
|
|
278
|
+
function preservedScheduleSkills(
|
|
279
|
+
payload: FutureLaunchPayload,
|
|
280
|
+
selectedSkillIds: readonly string[] | undefined,
|
|
281
|
+
): readonly SkillSelection[] | undefined {
|
|
282
|
+
if (selectedSkillIds === undefined) return payload.resourceSelections;
|
|
283
|
+
const previous = new Set(payload.selectedSkillIds);
|
|
284
|
+
const selected = new Set(selectedSkillIds);
|
|
285
|
+
return previous.size === selected.size && [...selected].every((id) => previous.has(id))
|
|
286
|
+
? payload.resourceSelections
|
|
287
|
+
: undefined;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function normalizeScheduledLaunchUpdate(
|
|
297
291
|
execution: FutureExecution,
|
|
298
292
|
request: NormalizedScheduledLaunchInput,
|
|
299
|
-
|
|
293
|
+
expectedLauncherId?: string,
|
|
300
294
|
) {
|
|
295
|
+
const parsed = parseFutureLaunchPayloadJson(execution.payloadJson);
|
|
296
|
+
if (!parsed.ok)
|
|
297
|
+
return {
|
|
298
|
+
ok: false as const,
|
|
299
|
+
outcome: invalidOutcome("invalid_payload", "Scheduled launch payload is invalid"),
|
|
300
|
+
};
|
|
301
|
+
const payload = parsed.value;
|
|
302
|
+
const launcherId = execution.launcherId ?? payload.launchPlan.launcherId;
|
|
303
|
+
if (expectedLauncherId !== undefined && launcherId !== expectedLauncherId)
|
|
304
|
+
return {
|
|
305
|
+
ok: false as const,
|
|
306
|
+
outcome: invalidOutcome("invalid_schedule", "Schedule belongs to another launcher"),
|
|
307
|
+
};
|
|
301
308
|
const schedule = request.scheduleProvided
|
|
302
309
|
? ({ ok: true, value: request.schedule } as const)
|
|
303
310
|
: resolveStoredScheduleRequest(execution);
|
|
304
|
-
if (!schedule.ok)
|
|
311
|
+
if (!schedule.ok)
|
|
312
|
+
return { ok: false as const, outcome: { kind: "invalid" as const, issues: [schedule.issue] } };
|
|
305
313
|
return {
|
|
306
314
|
ok: true as const,
|
|
307
315
|
value: {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
316
|
+
launcherId,
|
|
317
|
+
request: {
|
|
318
|
+
title: request.titleProvided ? request.title : payload.launchPlan.processInput.title,
|
|
319
|
+
titleProvided: true,
|
|
320
|
+
launcherInput: request.launcherInputProvided
|
|
321
|
+
? request.launcherInput
|
|
322
|
+
: payload.launcherInput,
|
|
323
|
+
launcherInputProvided: true,
|
|
324
|
+
skillIds: request.skillIds ?? payload.selectedSkillIds,
|
|
325
|
+
modelConfig: request.modelConfigProvided ? request.modelConfig : payload.modelConfig,
|
|
326
|
+
modelConfigProvided: request.modelConfigProvided,
|
|
327
|
+
schedule: schedule.value,
|
|
328
|
+
scheduleProvided: true,
|
|
329
|
+
actor: payload.actor,
|
|
330
|
+
},
|
|
331
|
+
baseLaunchPlan: payload.launchPlan,
|
|
332
|
+
resourceSelections: preservedScheduleSkills(payload, request.skillIds),
|
|
320
333
|
},
|
|
321
334
|
};
|
|
322
335
|
}
|
|
@@ -389,6 +402,7 @@ export function createFutureLaunchLifecycle(
|
|
|
389
402
|
async function persistPreparedLaunch(
|
|
390
403
|
input: PreparedLaunch & { existing?: FutureExecution; actor: Actor },
|
|
391
404
|
): Promise<LaunchMutationOutcome> {
|
|
405
|
+
if (input.launchPlan.preview) throw new Error("Launcher previews cannot be committed");
|
|
392
406
|
if (input.schedule.mode === "now") throw new Error("Immediate launches cannot be persisted");
|
|
393
407
|
const values = {
|
|
394
408
|
scheduleKind: input.schedule.mode,
|
|
@@ -444,9 +458,10 @@ export function createFutureLaunchLifecycle(
|
|
|
444
458
|
? { ok: true as const, launcher: input.resolvedLauncher }
|
|
445
459
|
: await deps.launcherService.resolveUiLauncher(input.launcherId, input.request.launcherInput);
|
|
446
460
|
if (!resolved.ok) return { ok: false, outcome: launcherResolutionFailure(resolved) };
|
|
447
|
-
const resourceSelections =
|
|
448
|
-
|
|
449
|
-
|
|
461
|
+
const resourceSelections =
|
|
462
|
+
input.resourceSelections !== undefined
|
|
463
|
+
? { ok: true as const, value: input.resourceSelections }
|
|
464
|
+
: resolveSelectedSkills(deps, resolved.launcher.processId, input.request.skillIds ?? []);
|
|
450
465
|
if (!resourceSelections.ok) return { ok: false, outcome: resourceSelections.outcome };
|
|
451
466
|
|
|
452
467
|
// A revised launch uses its persisted plan as the source of stored model
|
|
@@ -491,12 +506,10 @@ export function createFutureLaunchLifecycle(
|
|
|
491
506
|
actor?: Actor,
|
|
492
507
|
): Promise<LaunchMutationOutcome> {
|
|
493
508
|
const opened = deps.launchPipeline.open({ launcherId: existing.launcherId, origin: "ui" });
|
|
494
|
-
type ResolvedRevision =
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
actor: Actor;
|
|
499
|
-
};
|
|
509
|
+
type ResolvedRevision = Extract<
|
|
510
|
+
ReturnType<typeof normalizeScheduledLaunchUpdate>,
|
|
511
|
+
{ ok: true }
|
|
512
|
+
>["value"] & { launcher: ResolvedProcessLauncher; actor: Actor };
|
|
500
513
|
const result = await deps.launchPipeline.run<
|
|
501
514
|
ResolvedRevision,
|
|
502
515
|
PreparedLaunch & { actor: Actor },
|
|
@@ -510,23 +523,19 @@ export function createFutureLaunchLifecycle(
|
|
|
510
523
|
});
|
|
511
524
|
if (!deps.launcherService)
|
|
512
525
|
return failure({ kind: "unavailable", reason: "Launcher service is not available" });
|
|
513
|
-
const
|
|
514
|
-
if (!
|
|
515
|
-
return failure(invalidOutcome("invalid_payload", "Scheduled launch payload is invalid"));
|
|
516
|
-
const launchRequest = resolveScheduledLaunchUpdateRequest(existing, request, parsed.value);
|
|
517
|
-
if (!launchRequest.ok) return failure({ kind: "invalid", issues: [launchRequest.issue] });
|
|
526
|
+
const update = normalizeScheduledLaunchUpdate(existing, request);
|
|
527
|
+
if (!update.ok) return failure(update.outcome);
|
|
518
528
|
const resolved = await deps.launcherService.resolveUiLauncher(
|
|
519
|
-
|
|
520
|
-
|
|
529
|
+
update.value.launcherId,
|
|
530
|
+
update.value.request.launcherInput,
|
|
521
531
|
);
|
|
522
532
|
if (!resolved.ok) return failure(launcherResolutionFailure(resolved));
|
|
523
533
|
return {
|
|
524
534
|
kind: "resolved",
|
|
525
535
|
value: {
|
|
526
|
-
|
|
527
|
-
request: launchRequest.value,
|
|
536
|
+
...update.value,
|
|
528
537
|
launcher: resolved.launcher,
|
|
529
|
-
actor: actor ??
|
|
538
|
+
actor: actor ?? update.value.request.actor ?? SYSTEM_ACTOR,
|
|
530
539
|
},
|
|
531
540
|
};
|
|
532
541
|
},
|
|
@@ -544,10 +553,8 @@ export function createFutureLaunchLifecycle(
|
|
|
544
553
|
},
|
|
545
554
|
async prepare(resolved) {
|
|
546
555
|
const prepared = await prepareLaunchInternal({
|
|
556
|
+
...resolved,
|
|
547
557
|
launcherId: resolved.launcher.launcherId,
|
|
548
|
-
request: resolved.request,
|
|
549
|
-
baseLaunchPlan: resolved.payload.launchPlan,
|
|
550
|
-
resourceSelections: request.skillIds ? undefined : resolved.payload.resourceSelections,
|
|
551
558
|
operationTime,
|
|
552
559
|
resolvedLauncher: resolved.launcher,
|
|
553
560
|
});
|
|
@@ -638,8 +645,19 @@ export function createFutureLaunchLifecycle(
|
|
|
638
645
|
opts?: {
|
|
639
646
|
/** @internal */
|
|
640
647
|
resolvedLauncher?: ResolvedProcessLauncher;
|
|
648
|
+
/** Existing schedule being previewed; pins survive unchanged skill selections. @internal */
|
|
649
|
+
futureExecutionId?: string;
|
|
641
650
|
},
|
|
642
651
|
): Promise<PreparedLaunchResult> {
|
|
652
|
+
if (opts?.futureExecutionId !== undefined) {
|
|
653
|
+
const existing = deps.futureExecutions.getById(opts.futureExecutionId);
|
|
654
|
+
if (!existing || existing.kind !== "launch") {
|
|
655
|
+
return { ok: false, outcome: { kind: "not_found", target: "launch" } };
|
|
656
|
+
}
|
|
657
|
+
const update = normalizeScheduledLaunchUpdate(existing, request, launcherId);
|
|
658
|
+
if (!update.ok) return update;
|
|
659
|
+
return prepareLaunchInternal({ ...update.value, resolvedLauncher: opts.resolvedLauncher });
|
|
660
|
+
}
|
|
643
661
|
return prepareLaunchInternal({
|
|
644
662
|
launcherId,
|
|
645
663
|
request,
|
|
@@ -769,23 +787,14 @@ export function createFutureLaunchLifecycle(
|
|
|
769
787
|
if (!existing || existing.kind !== "launch") return { kind: "not_found", target: "launch" };
|
|
770
788
|
if (request.scheduleProvided && request.schedule.mode === "now")
|
|
771
789
|
return launchScheduledNow(existing, request, operationTime, opts?.actor);
|
|
772
|
-
const
|
|
773
|
-
if (!
|
|
774
|
-
|
|
775
|
-
const launchRequest = resolveScheduledLaunchUpdateRequest(existing, request, parsed.value);
|
|
776
|
-
if (!launchRequest.ok) return { kind: "invalid", issues: [launchRequest.issue] };
|
|
777
|
-
const prepared = await prepareLaunchInternal({
|
|
778
|
-
launcherId: existing.launcherId ?? parsed.value.launchPlan.launcherId,
|
|
779
|
-
request: launchRequest.value,
|
|
780
|
-
baseLaunchPlan: parsed.value.launchPlan,
|
|
781
|
-
resourceSelections: request.skillIds ? undefined : parsed.value.resourceSelections,
|
|
782
|
-
operationTime,
|
|
783
|
-
});
|
|
790
|
+
const update = normalizeScheduledLaunchUpdate(existing, request);
|
|
791
|
+
if (!update.ok) return update.outcome;
|
|
792
|
+
const prepared = await prepareLaunchInternal({ ...update.value, operationTime });
|
|
784
793
|
if (!prepared.ok) return prepared.outcome;
|
|
785
794
|
return persistPreparedLaunch({
|
|
786
795
|
...prepared.prepared,
|
|
787
796
|
existing,
|
|
788
|
-
actor: opts?.actor ??
|
|
797
|
+
actor: opts?.actor ?? update.value.request.actor ?? SYSTEM_ACTOR,
|
|
789
798
|
});
|
|
790
799
|
});
|
|
791
800
|
},
|
|
@@ -25,7 +25,11 @@ import {
|
|
|
25
25
|
type FutureExecutionExecutorDeps,
|
|
26
26
|
type FutureExecutionItemOutcome,
|
|
27
27
|
} from "./execution.js";
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
createFutureLaunchLifecycle,
|
|
30
|
+
type FutureExecutionIssue,
|
|
31
|
+
type LaunchFailure as LifecycleFailure,
|
|
32
|
+
} from "./launch-lifecycle.js";
|
|
29
33
|
import { evaluateFutureModelSelection } from "./model-projection.js";
|
|
30
34
|
import { reconcileFutureExecutionModelBlocks } from "./reconciliation.js";
|
|
31
35
|
import {
|
|
@@ -61,39 +65,6 @@ export interface FutureExecutionLifecycleOptions {
|
|
|
61
65
|
now?: () => Date;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
/** @internal */
|
|
65
|
-
type LifecycleFailure =
|
|
66
|
-
| {
|
|
67
|
-
/** @internal */
|
|
68
|
-
kind: "invalid";
|
|
69
|
-
/** @internal */
|
|
70
|
-
issues: readonly FutureExecutionIssue[];
|
|
71
|
-
}
|
|
72
|
-
| {
|
|
73
|
-
/** @internal */
|
|
74
|
-
kind: "not_found";
|
|
75
|
-
/** @internal */
|
|
76
|
-
target: "future_execution" | "launch" | "action" | "process";
|
|
77
|
-
}
|
|
78
|
-
| {
|
|
79
|
-
/** @internal */
|
|
80
|
-
kind: "conflict";
|
|
81
|
-
/** @internal */
|
|
82
|
-
issue: FutureExecutionIssue;
|
|
83
|
-
}
|
|
84
|
-
| {
|
|
85
|
-
/** @internal */
|
|
86
|
-
kind: "unavailable";
|
|
87
|
-
/** @internal */
|
|
88
|
-
reason: string;
|
|
89
|
-
}
|
|
90
|
-
| {
|
|
91
|
-
/** @internal */
|
|
92
|
-
kind: "failed";
|
|
93
|
-
/** @internal */
|
|
94
|
-
issue: FutureExecutionIssue;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
68
|
/** @internal */
|
|
98
69
|
export type ActionMutationOutcome =
|
|
99
70
|
| {
|
|
@@ -131,6 +131,7 @@ export async function projectFutureExecutionModelState(
|
|
|
131
131
|
policy: deps.policy,
|
|
132
132
|
availability: deps.availability,
|
|
133
133
|
detectedAt: now().toISOString(),
|
|
134
|
+
existingBlockedReason: execution.blockedReason,
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
137
|
if (!execution.instanceId || !execution.actionId) return null;
|
|
@@ -159,6 +160,7 @@ export async function projectFutureExecutionModelState(
|
|
|
159
160
|
overrideModelProfileId: parsed.value.nextTurnModelProfileId,
|
|
160
161
|
overrideProvided: parsed.value.nextTurnModelProfileId !== null,
|
|
161
162
|
detectedAt: now().toISOString(),
|
|
163
|
+
existingBlockedReason: execution.blockedReason,
|
|
162
164
|
});
|
|
163
165
|
}
|
|
164
166
|
|
|
@@ -6,6 +6,7 @@ import type { ProcessActionRegistry } from "../process-action-registry.js";
|
|
|
6
6
|
import type { ProcessGraphRegistry } from "../process-graph.js";
|
|
7
7
|
import {
|
|
8
8
|
evaluateAtStableAvailabilityRevision,
|
|
9
|
+
isPinnedModelSelection,
|
|
9
10
|
type ServerProcessModelPolicy,
|
|
10
11
|
} from "../process-model-policy/index.js";
|
|
11
12
|
import type { ProcessOperationCoordinator } from "../process-operation-coordinator.js";
|
|
@@ -35,6 +36,7 @@ export async function reconcileFutureExecutionModelBlocks(input: {
|
|
|
35
36
|
availability: ModelStatusCacheSnapshot;
|
|
36
37
|
getModelAvailabilitySnapshot: () => ModelStatusCacheSnapshot;
|
|
37
38
|
profileIds?: ReadonlySet<string>;
|
|
39
|
+
instanceId?: string;
|
|
38
40
|
broadcaster: Broadcaster;
|
|
39
41
|
processTitles?: ProcessTitleGenerator;
|
|
40
42
|
asOf: string;
|
|
@@ -42,6 +44,7 @@ export async function reconcileFutureExecutionModelBlocks(input: {
|
|
|
42
44
|
let changed = 0;
|
|
43
45
|
const effects: PostCommitEffect[] = [];
|
|
44
46
|
for (const candidate of input.futureExecutions.listAll()) {
|
|
47
|
+
if (input.instanceId && candidate.instanceId !== input.instanceId) continue;
|
|
45
48
|
if (
|
|
46
49
|
candidate.modelSelection &&
|
|
47
50
|
input.profileIds &&
|
|
@@ -98,6 +101,10 @@ export async function reconcileFutureExecutionModelBlocks(input: {
|
|
|
98
101
|
if (projected && !sameModelPolicyState(current, projected)) updateCurrent(projected);
|
|
99
102
|
};
|
|
100
103
|
|
|
104
|
+
if (!isPinnedModelSelection(current.modelSelection)) {
|
|
105
|
+
await projectCurrent();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
101
108
|
if (!current.modelSelection) {
|
|
102
109
|
await projectCurrent();
|
|
103
110
|
if (!current.modelSelection) return;
|
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
import type { FutureExecution, ProcessInstance } from "@leitwerk-dev/domain";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProcessLauncherService } from "@leitwerk-dev/process-sdk";
|
|
3
3
|
import { parseFutureActionPayloadJson, parseFutureLaunchPayloadJson } from "@leitwerk-dev/protocol";
|
|
4
4
|
import type {
|
|
5
5
|
FutureActionSummary,
|
|
6
6
|
FutureExecutionSummary,
|
|
7
7
|
FutureLaunchSummary,
|
|
8
|
-
ProcessActionSummary as HttpProcessActionSummary,
|
|
9
8
|
ScheduledActionDetail,
|
|
10
9
|
} from "@leitwerk-dev/protocol/http-contracts";
|
|
11
10
|
import type { RepositoryBundle } from "./db/repositories.js";
|
|
12
|
-
import
|
|
11
|
+
import { buildActionSummaryForProcess } from "./process-action-presenter.js";
|
|
12
|
+
import {
|
|
13
|
+
listCurrentVisibleActions,
|
|
14
|
+
type ProcessOperatorAttentionDeps,
|
|
15
|
+
} from "./process-operator-attention.js";
|
|
13
16
|
|
|
14
17
|
export interface FutureExecutionPresenterDeps
|
|
15
18
|
extends Pick<RepositoryBundle, "futureExecutions" | "processes"> {
|
|
16
19
|
launcherService: ProcessLauncherService;
|
|
17
|
-
processActionRegistry?: ProcessActionRegistry;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface BuildScheduledActionSummaryDeps extends FutureExecutionPresenterDeps {
|
|
21
|
-
buildActionSummaryForProcess: (
|
|
22
|
-
process: ProcessInstance,
|
|
23
|
-
actionId: string,
|
|
24
|
-
action: { id: string; label: string; form?: FormDefinition },
|
|
25
|
-
labelOverride?: string | null,
|
|
26
|
-
overrides?: { supportsScheduling?: boolean },
|
|
27
|
-
) => HttpProcessActionSummary;
|
|
28
20
|
}
|
|
29
21
|
|
|
30
22
|
function futureSummaryState(execution: FutureExecution) {
|
|
@@ -126,7 +118,7 @@ export function buildFutureExecutionSummaries(
|
|
|
126
118
|
}
|
|
127
119
|
|
|
128
120
|
export function getScheduledActionDetailForProcess(
|
|
129
|
-
deps:
|
|
121
|
+
deps: ProcessOperatorAttentionDeps,
|
|
130
122
|
process: ProcessInstance,
|
|
131
123
|
): ScheduledActionDetail | null {
|
|
132
124
|
if (!deps.processActionRegistry) {
|
|
@@ -152,12 +144,12 @@ export function getScheduledActionDetailForProcess(
|
|
|
152
144
|
actionLabel,
|
|
153
145
|
input: payload.input,
|
|
154
146
|
nextTurnModelProfileId: payload.nextTurnModelProfileId,
|
|
155
|
-
action:
|
|
156
|
-
process,
|
|
157
|
-
|
|
158
|
-
action,
|
|
159
|
-
actionLabel,
|
|
160
|
-
|
|
161
|
-
),
|
|
147
|
+
action: buildActionSummaryForProcess(deps, process, {
|
|
148
|
+
...listCurrentVisibleActions(deps, process).find((candidate) => candidate.id === action.id),
|
|
149
|
+
id: action.id,
|
|
150
|
+
form: action.form,
|
|
151
|
+
label: actionLabel.trim() ? actionLabel : action.label,
|
|
152
|
+
supportsScheduling: true,
|
|
153
|
+
}),
|
|
162
154
|
};
|
|
163
155
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Actor, resolveJsonPointer, type TurnProgressReport } from "@leitwerk-dev/domain";
|
|
2
2
|
import {
|
|
3
3
|
bindExternalWrites,
|
|
4
4
|
type ExternalWriteLogRepoLike,
|
|
@@ -34,8 +34,8 @@ type RegisteredIntegrationTool = IntegrationToolDefinition<unknown>;
|
|
|
34
34
|
type TicketCreationTool = RegisteredIntegrationTool & { capability: TicketCreationCapability };
|
|
35
35
|
type IntegrationToolExecutionInput = Omit<
|
|
36
36
|
IntegrationToolExecutionContext,
|
|
37
|
-
"signal" | "externalWrites"
|
|
38
|
-
|
|
37
|
+
"signal" | "externalWrites" | "reportProgress"
|
|
38
|
+
> & { reportProgress?: IntegrationToolExecutionContext["reportProgress"] };
|
|
39
39
|
|
|
40
40
|
interface PendingIntegrationToolExecution {
|
|
41
41
|
readonly controller: AbortController;
|
|
@@ -104,6 +104,7 @@ const ticketCapabilitySchema = v.object({
|
|
|
104
104
|
startTurnId: nonEmptyString,
|
|
105
105
|
titlePath: v.optional(v.string()),
|
|
106
106
|
descriptionPath: v.optional(v.string()),
|
|
107
|
+
descriptionFormat: v.optional(v.picklist(["plain", "markdown"])),
|
|
107
108
|
destinations: v.optional(v.unknown()),
|
|
108
109
|
});
|
|
109
110
|
const destinationSummarySchema = v.pipe(
|
|
@@ -192,18 +193,6 @@ export function validateTicketCreationReceipt(value: unknown): TicketCreationRec
|
|
|
192
193
|
};
|
|
193
194
|
}
|
|
194
195
|
|
|
195
|
-
function resolveJsonPointer(value: unknown, pointer: string): unknown {
|
|
196
|
-
if (pointer === "") return value;
|
|
197
|
-
return pointer
|
|
198
|
-
.slice(1)
|
|
199
|
-
.split("/")
|
|
200
|
-
.reduce<unknown>((current, token) => {
|
|
201
|
-
if (!current || typeof current !== "object") return undefined;
|
|
202
|
-
const key = token.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
203
|
-
return (current as Record<string, unknown>)[key];
|
|
204
|
-
}, value);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
196
|
const parseToolArgs = (value: unknown) =>
|
|
208
197
|
objectArg(value, "Integration tool arguments must be an object");
|
|
209
198
|
|
|
@@ -357,6 +346,7 @@ export class IntegrationToolRegistry {
|
|
|
357
346
|
if (!definition) throw new Error(`Unknown integration tool '${name}'`);
|
|
358
347
|
return {
|
|
359
348
|
name: definition.name,
|
|
349
|
+
...(definition.modelVisible === false ? { modelVisible: false } : {}),
|
|
360
350
|
description: definition.description,
|
|
361
351
|
parameters:
|
|
362
352
|
definition.capability?.kind === "ticket_creation" && definition.capability.destinations
|
|
@@ -380,6 +370,9 @@ export class IntegrationToolRegistry {
|
|
|
380
370
|
return definition.execute(
|
|
381
371
|
{
|
|
382
372
|
...ctx,
|
|
373
|
+
reportProgress: (report) => {
|
|
374
|
+
if (!controller.signal.aborted) ctx.reportProgress?.(report);
|
|
375
|
+
},
|
|
383
376
|
signal: controller.signal,
|
|
384
377
|
externalWrites: bindExternalWrites(this.writes, ctx.process.id),
|
|
385
378
|
},
|
|
@@ -391,6 +384,30 @@ export class IntegrationToolRegistry {
|
|
|
391
384
|
return promise;
|
|
392
385
|
}
|
|
393
386
|
|
|
387
|
+
/** Only trusted server extensions use this path; approval-gated ticket tools require worker IPC. */
|
|
388
|
+
executeServer(
|
|
389
|
+
name: string,
|
|
390
|
+
args: unknown,
|
|
391
|
+
ctx: IntegrationToolExecutionInput,
|
|
392
|
+
signal: AbortSignal,
|
|
393
|
+
): Promise<unknown> {
|
|
394
|
+
const definition = this.tools.get(name);
|
|
395
|
+
if (!definition || definition.capability)
|
|
396
|
+
throw new Error(`Tool '${name}' is unavailable to server maintenance`);
|
|
397
|
+
signal.throwIfAborted();
|
|
398
|
+
return definition.execute(
|
|
399
|
+
{
|
|
400
|
+
...ctx,
|
|
401
|
+
signal,
|
|
402
|
+
reportProgress: (report) => {
|
|
403
|
+
if (!signal.aborted) ctx.reportProgress?.(report);
|
|
404
|
+
},
|
|
405
|
+
externalWrites: bindExternalWrites(this.writes, ctx.process.id),
|
|
406
|
+
},
|
|
407
|
+
definition.parse?.(args) ?? parseToolArgs(args),
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
394
411
|
cancel(idempotencyKey: string): boolean {
|
|
395
412
|
const execution = this.executions.get(idempotencyKey);
|
|
396
413
|
if (!execution) return false;
|
|
@@ -413,6 +430,11 @@ export function createIntegrationToolRequestService(input: {
|
|
|
413
430
|
repos: Pick<RepositoryBundle, "processes" | "projects" | "turnRecords" | "turnStarts">;
|
|
414
431
|
processActionRegistry: Pick<ProcessActionRegistry, "getTurnDefinition" | "resolveContextData">;
|
|
415
432
|
toolApprovalGate?: ToolApprovalGate;
|
|
433
|
+
reportProgress?: (input: {
|
|
434
|
+
instanceId: string;
|
|
435
|
+
turnRecordId: string;
|
|
436
|
+
report: TurnProgressReport;
|
|
437
|
+
}) => void;
|
|
416
438
|
}) {
|
|
417
439
|
const pending = new Map<
|
|
418
440
|
string,
|
|
@@ -453,22 +475,26 @@ export function createIntegrationToolRequestService(input: {
|
|
|
453
475
|
if (process.selectedTurnId !== turn.turnId) {
|
|
454
476
|
return fail("Integration tool call targets a stale turn");
|
|
455
477
|
}
|
|
456
|
-
const
|
|
457
|
-
if (signal.aborted)
|
|
478
|
+
const isActive = () => {
|
|
479
|
+
if (signal.aborted) return false;
|
|
458
480
|
const current = input.repos.processes.getById(instanceId);
|
|
459
481
|
const currentTurn = input.repos.turnRecords.getById(payload.turnRecordId);
|
|
460
482
|
const start =
|
|
461
483
|
current?.currentExecution?.kind === "worker_start"
|
|
462
484
|
? input.repos.turnStarts.getById(current.currentExecution.id)
|
|
463
485
|
: null;
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
486
|
+
return Boolean(
|
|
487
|
+
current &&
|
|
488
|
+
currentTurn?.status === "running" &&
|
|
489
|
+
currentTurn.instanceId === instanceId &&
|
|
490
|
+
current.selectedTurnId === turn.turnId &&
|
|
491
|
+
start?.state.kind === "accepted" &&
|
|
492
|
+
start.state.turnRecordId === payload.turnRecordId,
|
|
493
|
+
);
|
|
494
|
+
};
|
|
495
|
+
const assertActive = () => {
|
|
496
|
+
if (signal.aborted) throw new Error("Integration tool execution cancelled");
|
|
497
|
+
if (!isActive()) throw new Error("Integration tool call targets a stale turn record");
|
|
472
498
|
};
|
|
473
499
|
const authorizedTools = resolveTurnIntegrationToolNames(
|
|
474
500
|
input.processActionRegistry,
|
|
@@ -484,7 +510,10 @@ export function createIntegrationToolRequestService(input: {
|
|
|
484
510
|
const project = projectKey
|
|
485
511
|
? (projects.find((candidate) => candidate.key === projectKey) ?? null)
|
|
486
512
|
: null;
|
|
487
|
-
if (projectKey && !project)
|
|
513
|
+
if (projectKey && !project)
|
|
514
|
+
return fail(
|
|
515
|
+
`Unknown process project '${projectKey}'. Available project keys: ${projects.map((candidate) => candidate.key).join(", ") || "(none)"}`,
|
|
516
|
+
);
|
|
488
517
|
try {
|
|
489
518
|
let ticketDestination: TicketCreationDestinationSnapshot | undefined;
|
|
490
519
|
let executionArgs = payload.args;
|
|
@@ -545,6 +574,10 @@ export function createIntegrationToolRequestService(input: {
|
|
|
545
574
|
projects,
|
|
546
575
|
turn,
|
|
547
576
|
project,
|
|
577
|
+
reportProgress: (report) => {
|
|
578
|
+
if (isActive())
|
|
579
|
+
input.reportProgress?.({ instanceId, turnRecordId: payload.turnRecordId, report });
|
|
580
|
+
},
|
|
548
581
|
...(ticketDestination ? { ticketDestination } : {}),
|
|
549
582
|
idempotencyKey: integrationToolIdempotencyKey({
|
|
550
583
|
instanceId,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type LaunchRun, SYSTEM_ACTOR } from "@leitwerk-dev/domain";
|
|
2
|
-
import { expect, vi } from "vitest";
|
|
3
|
-
import { createInMemoryDatabase } from "./db/database.js";
|
|
2
|
+
import { expect, onTestFinished, vi } from "vitest";
|
|
3
|
+
import { closeDatabase, createInMemoryDatabase } from "./db/database.js";
|
|
4
4
|
import { createAllRepos } from "./db/repositories.js";
|
|
5
5
|
import { createLaunchCoordinator } from "./launch-coordinator.js";
|
|
6
6
|
import { createLaunchPipeline, initialLaunchSteps } from "./launch-pipeline.js";
|
|
@@ -48,7 +48,9 @@ export function createCoordinatorHarness(
|
|
|
48
48
|
processLaunches?: Record<string, unknown>;
|
|
49
49
|
} = {},
|
|
50
50
|
) {
|
|
51
|
-
const
|
|
51
|
+
const db = createInMemoryDatabase();
|
|
52
|
+
onTestFinished(() => closeDatabase(db));
|
|
53
|
+
const repos = createAllRepos(db);
|
|
52
54
|
const broadcaster = { sendDurable: vi.fn() } as never;
|
|
53
55
|
const resolvedLauncher = {
|
|
54
56
|
processId: "demo",
|
|
@@ -121,7 +123,9 @@ export function createCoordinatorHarness(
|
|
|
121
123
|
export function createWatcherHarness(
|
|
122
124
|
overrides: { launchPlans?: unknown; processLaunches?: unknown } = {},
|
|
123
125
|
) {
|
|
124
|
-
const
|
|
126
|
+
const db = createInMemoryDatabase();
|
|
127
|
+
onTestFinished(() => closeDatabase(db));
|
|
128
|
+
const repos = createAllRepos(db);
|
|
125
129
|
const process = repos.processes.create({
|
|
126
130
|
processId: "demo",
|
|
127
131
|
selectedTurnId: "start",
|
|
@@ -629,9 +629,18 @@ export function createLaunchCoordinator(deps: LaunchCoordinatorDeps): LaunchCoor
|
|
|
629
629
|
return bindLaunchPreparationChecks(attempt.preparationChecks, attempt.launchConfig);
|
|
630
630
|
},
|
|
631
631
|
async prepare(attempt) {
|
|
632
|
+
const eventProfile = attempt.launchConfig.defaultModelProfileId;
|
|
632
633
|
const prepared = await deps.launchPlans.prepare(
|
|
633
634
|
withWatcherHandoffDedupKey(attempt.launchPlan, admissionKey),
|
|
634
|
-
{
|
|
635
|
+
{
|
|
636
|
+
modelConfig: {
|
|
637
|
+
...watcher.launchModelConfig,
|
|
638
|
+
defaultModelProfileId:
|
|
639
|
+
eventProfile ?? watcher.launchModelConfig.defaultModelProfileId,
|
|
640
|
+
},
|
|
641
|
+
// Event selections express ticket/user intent. Never silently drop them.
|
|
642
|
+
invalidModelConfig: eventProfile ? "reject" : "omit",
|
|
643
|
+
},
|
|
635
644
|
);
|
|
636
645
|
return prepared.ok
|
|
637
646
|
? { ok: true as const, value: prepared.launchPlan }
|