@leitwerk-dev/server 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-BuJCdkvy.d.ts → app-CtlotzYm.d.ts} +312 -121
- package/dist/app-KR3N2JAE.js +8 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/auth/fastify-auth.d.ts +9 -0
- package/dist/auth/fastify-auth.d.ts.map +1 -1
- package/dist/{chunk-QCHS3X33.js → chunk-OUA5EZS2.js} +3127 -689
- package/dist/chunk-OUA5EZS2.js.map +1 -0
- package/dist/{chunk-HK6BLLHA.js → chunk-YLWY4UTT.js} +2424 -1580
- package/dist/chunk-YLWY4UTT.js.map +1 -0
- package/dist/config/config-loader.d.ts +1 -1
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-types.d.ts +16 -1
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/config/kubernetes-docker-isolation.d.ts +7 -0
- package/dist/config/kubernetes-docker-isolation.d.ts.map +1 -0
- package/dist/dashboard-model-issues.d.ts +10 -0
- package/dist/dashboard-model-issues.d.ts.map +1 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/execution-inspection-repo.d.ts +15 -0
- package/dist/db/execution-inspection-repo.d.ts.map +1 -0
- package/dist/db/history-window.d.ts +11 -0
- package/dist/db/history-window.d.ts.map +1 -0
- package/dist/db/process-event-repo.d.ts +2 -0
- package/dist/db/process-event-repo.d.ts.map +1 -1
- package/dist/db/process-instance-repo.d.ts +21 -1
- package/dist/db/process-instance-repo.d.ts.map +1 -1
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts +2 -1
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts.map +1 -1
- package/dist/db/process-project-repo.d.ts +2 -0
- package/dist/db/process-project-repo.d.ts.map +1 -1
- package/dist/db/process-skill-repo.d.ts.map +1 -1
- package/dist/db/process-turn-annotation-repo.d.ts +4 -1
- package/dist/db/process-turn-annotation-repo.d.ts.map +1 -1
- package/dist/db/process-turn-record-repo.d.ts +4 -0
- package/dist/db/process-turn-record-repo.d.ts.map +1 -1
- package/dist/db/publication-repo.d.ts +5 -0
- package/dist/db/publication-repo.d.ts.map +1 -0
- package/dist/db/repositories.d.ts +12 -0
- package/dist/db/repositories.d.ts.map +1 -1
- package/dist/db/schema.d.ts +693 -2
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/scoped-settings-repo.d.ts +37 -0
- package/dist/db/scoped-settings-repo.d.ts.map +1 -0
- package/dist/db/skill-repo.d.ts +3 -0
- package/dist/db/skill-repo.d.ts.map +1 -1
- package/dist/db/turn-start-record-repo.d.ts +2 -1
- package/dist/db/turn-start-record-repo.d.ts.map +1 -1
- package/dist/db/turn-summary-repo.d.ts +10 -1
- package/dist/db/turn-summary-repo.d.ts.map +1 -1
- package/dist/db/worker-lease-repo.d.ts +2 -1
- package/dist/db/worker-lease-repo.d.ts.map +1 -1
- package/dist/domain-logic/outcome-tools.d.ts.map +1 -1
- package/dist/domain-logic/worker-lease-lifecycle.d.ts.map +1 -1
- package/dist/external-source-service.d.ts.map +1 -1
- package/dist/future-execution/execution.d.ts +4 -1
- package/dist/future-execution/execution.d.ts.map +1 -1
- package/dist/future-execution/launch-lifecycle.d.ts +9 -25
- package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
- package/dist/future-execution/lifecycle.d.ts +3 -28
- package/dist/future-execution/lifecycle.d.ts.map +1 -1
- package/dist/future-execution/model-projection.d.ts.map +1 -1
- package/dist/future-execution/reconciliation.d.ts +1 -0
- package/dist/future-execution/reconciliation.d.ts.map +1 -1
- package/dist/future-execution-presenter.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/integration-tool-registry.d.ts +11 -2
- package/dist/integration-tool-registry.d.ts.map +1 -1
- package/dist/launch-coordinator.d.ts.map +1 -1
- package/dist/launcher-model-config-service.d.ts +7 -1
- package/dist/launcher-model-config-service.d.ts.map +1 -1
- package/dist/leaf-outcome-snapshot-capture.d.ts +1 -0
- package/dist/leaf-outcome-snapshot-capture.d.ts.map +1 -1
- package/dist/main.js +3 -3
- package/dist/primary-path-snapshot.d.ts.map +1 -1
- package/dist/process-action-presenter.d.ts +1 -6
- package/dist/process-action-presenter.d.ts.map +1 -1
- package/dist/process-action-registry.d.ts.map +1 -1
- package/dist/process-engine/decision.d.ts +2 -0
- package/dist/process-engine/decision.d.ts.map +1 -1
- package/dist/process-engine/engine.d.ts.map +1 -1
- package/dist/process-engine/mapped-turns.d.ts.map +1 -1
- package/dist/process-engine/ops/automatic-retry-startup.d.ts +8 -0
- package/dist/process-engine/ops/automatic-retry-startup.d.ts.map +1 -0
- package/dist/process-engine/ops/continue-failed-turn.d.ts.map +1 -1
- package/dist/process-engine/ops/process-observation.d.ts +6 -0
- package/dist/process-engine/ops/process-observation.d.ts.map +1 -0
- package/dist/process-engine/ops/retry-failed-turn.d.ts.map +1 -1
- package/dist/process-engine/ops/retry-startup.d.ts +2 -0
- package/dist/process-engine/ops/retry-startup.d.ts.map +1 -1
- package/dist/process-engine/ops/start-process.d.ts +2 -0
- package/dist/process-engine/ops/start-process.d.ts.map +1 -1
- package/dist/process-engine/ops/turn-outcome.d.ts.map +1 -1
- package/dist/process-engine/ops/turn-wait.d.ts +30 -0
- package/dist/process-engine/ops/turn-wait.d.ts.map +1 -0
- package/dist/process-engine/ops/update-model-config.d.ts +9 -0
- package/dist/process-engine/ops/update-model-config.d.ts.map +1 -0
- package/dist/process-engine/recorder.d.ts.map +1 -1
- package/dist/process-engine/turn-start-preflight.d.ts +6 -0
- package/dist/process-engine/turn-start-preflight.d.ts.map +1 -1
- package/dist/process-engine/turn-wait-state.d.ts +24 -0
- package/dist/process-engine/turn-wait-state.d.ts.map +1 -0
- package/dist/process-engine/turn-worker-requirement.d.ts +2 -0
- package/dist/process-engine/turn-worker-requirement.d.ts.map +1 -1
- package/dist/process-engine/types.d.ts +13 -2
- package/dist/process-engine/types.d.ts.map +1 -1
- package/dist/process-engine/writes/build-process-abort-writes.d.ts +3 -1
- package/dist/process-engine/writes/build-process-abort-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +2 -0
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/commit-writes.d.ts +2 -0
- package/dist/process-engine/writes/commit-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/writes.d.ts +28 -60
- package/dist/process-engine/writes/writes.d.ts.map +1 -1
- package/dist/process-graph.d.ts +1 -1
- package/dist/process-graph.d.ts.map +1 -1
- package/dist/process-inspection-reader.d.ts +21 -0
- package/dist/process-inspection-reader.d.ts.map +1 -0
- package/dist/process-inspection-trace.d.ts +13 -0
- package/dist/process-inspection-trace.d.ts.map +1 -0
- package/dist/process-inspection.d.ts +22 -0
- package/dist/process-inspection.d.ts.map +1 -0
- package/dist/process-instance-tree-presenter.d.ts +4 -3
- package/dist/process-instance-tree-presenter.d.ts.map +1 -1
- package/dist/process-launch-executor.d.ts +2 -0
- package/dist/process-launch-executor.d.ts.map +1 -1
- package/dist/process-launch-plan.d.ts +1 -0
- package/dist/process-launch-plan.d.ts.map +1 -1
- package/dist/process-launcher-registry.d.ts.map +1 -1
- package/dist/process-model-availability-recovery.d.ts +1 -1
- package/dist/process-model-availability-recovery.d.ts.map +1 -1
- package/dist/process-model-config.d.ts +19 -0
- package/dist/process-model-config.d.ts.map +1 -0
- package/dist/process-model-policy/construct.d.ts.map +1 -1
- package/dist/process-model-policy/evaluate.d.ts.map +1 -1
- package/dist/process-model-policy/index.d.ts +4 -1
- package/dist/process-model-policy/index.d.ts.map +1 -1
- package/dist/process-model-policy/project.d.ts.map +1 -1
- package/dist/process-model-policy/types.d.ts +18 -0
- package/dist/process-model-policy/types.d.ts.map +1 -1
- package/dist/process-model-policy-presenter.d.ts.map +1 -1
- package/dist/process-runtime-availability.d.ts +2 -1
- package/dist/process-runtime-availability.d.ts.map +1 -1
- package/dist/process-turn-trace.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts +14 -3
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- package/dist/routes/dashboard.d.ts +17 -0
- package/dist/routes/dashboard.d.ts.map +1 -0
- package/dist/routes/future-executions.d.ts.map +1 -1
- package/dist/routes/launchers.d.ts.map +1 -1
- package/dist/routes/process-actions.d.ts.map +1 -1
- package/dist/routes/process-detail.d.ts.map +1 -1
- package/dist/routes/process-model-config.d.ts +4 -0
- package/dist/routes/process-model-config.d.ts.map +1 -0
- package/dist/routes/process-route-helpers.d.ts +8 -9
- package/dist/routes/process-route-helpers.d.ts.map +1 -1
- package/dist/routes/processes.d.ts.map +1 -1
- package/dist/routes/settings.d.ts +11 -0
- package/dist/routes/settings.d.ts.map +1 -0
- package/dist/routes/ticket-creation.d.ts.map +1 -1
- package/dist/scoped-settings-service.d.ts +98 -0
- package/dist/scoped-settings-service.d.ts.map +1 -0
- package/dist/server-bootstrap/build-host-capabilities.d.ts +2 -0
- package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
- package/dist/server-bootstrap/register-http.d.ts.map +1 -1
- package/dist/session-summary-projection.d.ts.map +1 -1
- package/dist/skills/bundled-skills.d.ts +5 -0
- package/dist/skills/bundled-skills.d.ts.map +1 -0
- package/dist/skills/catalog-service.d.ts +1 -0
- package/dist/skills/catalog-service.d.ts.map +1 -1
- package/dist/skills/extension-importer.d.ts +11 -0
- package/dist/skills/extension-importer.d.ts.map +1 -0
- package/dist/skills/launch-skills.d.ts +11 -0
- package/dist/skills/launch-skills.d.ts.map +1 -0
- package/dist/skills/skill-frontmatter.d.ts +7 -0
- package/dist/skills/skill-frontmatter.d.ts.map +1 -1
- package/dist/skills/source-importer.d.ts +3 -0
- package/dist/skills/source-importer.d.ts.map +1 -1
- package/dist/startup-evidence.d.ts +4 -3
- package/dist/startup-evidence.d.ts.map +1 -1
- package/dist/startup-retry-policy.d.ts +8 -0
- package/dist/startup-retry-policy.d.ts.map +1 -0
- package/dist/supervisor/execution-inspection-ingestor.d.ts +9 -0
- package/dist/supervisor/execution-inspection-ingestor.d.ts.map +1 -0
- package/dist/supervisor/ipc-handler.d.ts +2 -0
- package/dist/supervisor/ipc-handler.d.ts.map +1 -1
- package/dist/supervisor/worker-event-ingestor.d.ts +1 -0
- package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +2 -0
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- package/dist/test-helpers/prepared-fixture-start.d.ts.map +1 -1
- package/dist/test-helpers/process-model-fixtures.d.ts +1 -0
- package/dist/test-helpers/process-model-fixtures.d.ts.map +1 -1
- package/dist/test-helpers/scoped-settings-fixtures.d.ts +16 -0
- package/dist/test-helpers/scoped-settings-fixtures.d.ts.map +1 -0
- package/dist/test-helpers/skill-fixtures.d.ts +4 -0
- package/dist/test-helpers/skill-fixtures.d.ts.map +1 -0
- package/dist/testing.js +2 -1
- package/dist/testing.js.map +1 -1
- package/dist/tool-approval-gate.d.ts +3 -0
- package/dist/tool-approval-gate.d.ts.map +1 -1
- package/dist/turn-progress.d.ts.map +1 -1
- package/dist/turn-wait-service.d.ts +28 -0
- package/dist/turn-wait-service.d.ts.map +1 -0
- package/dist/worker-runtime-profile-selection.d.ts +2 -0
- package/dist/worker-runtime-profile-selection.d.ts.map +1 -1
- package/package.json +20 -19
- package/src/app.ts +177 -25
- package/src/auth/fastify-auth.ts +13 -0
- package/src/config/config-loader.ts +42 -2
- package/src/config/config-types.ts +16 -1
- package/src/config/kubernetes-docker-isolation.ts +21 -0
- package/src/dashboard-model-issues.ts +199 -0
- package/src/db/database.ts +131 -40
- package/src/db/execution-inspection-repo.ts +163 -0
- package/src/db/history-window.ts +18 -0
- package/src/db/process-event-repo.ts +88 -10
- package/src/db/process-instance-repo.ts +33 -2
- package/src/db/process-leaf-outcome-snapshot-repo.ts +8 -2
- package/src/db/process-project-repo.ts +4 -0
- package/src/db/process-skill-repo.ts +9 -2
- package/src/db/process-turn-annotation-repo.ts +27 -9
- package/src/db/process-turn-record-repo.ts +45 -12
- package/src/db/publication-repo.ts +63 -0
- package/src/db/repositories.ts +17 -0
- package/src/db/schema.ts +103 -1
- package/src/db/scoped-settings-repo.ts +234 -0
- package/src/db/skill-repo.ts +89 -27
- package/src/db/turn-start-record-repo.ts +13 -3
- package/src/db/turn-summary-repo.ts +36 -4
- package/src/db/worker-lease-repo.ts +8 -2
- package/src/domain-logic/outcome-tools.ts +18 -216
- package/src/domain-logic/worker-lease-lifecycle.ts +2 -1
- package/src/external-source-service.ts +33 -7
- package/src/future-execution/execution.ts +9 -2
- package/src/future-execution/launch-lifecycle.ts +87 -78
- package/src/future-execution/lifecycle.ts +5 -34
- package/src/future-execution/model-projection.ts +2 -0
- package/src/future-execution/reconciliation.ts +7 -0
- package/src/future-execution-presenter.ts +7 -8
- package/src/integration-tool-registry.ts +59 -26
- package/src/launch-coordinator.ts +10 -1
- package/src/launcher-model-config-service.ts +24 -3
- package/src/leaf-outcome-snapshot-capture.ts +2 -0
- package/src/primary-path-snapshot.ts +3 -4
- package/src/process-action-presenter.ts +22 -57
- package/src/process-action-registry.ts +31 -39
- package/src/process-engine/decision.ts +10 -0
- package/src/process-engine/engine.ts +25 -2
- package/src/process-engine/mapped-turns.ts +5 -7
- package/src/process-engine/ops/automatic-retry-startup.ts +93 -0
- package/src/process-engine/ops/continue-failed-turn.ts +2 -13
- package/src/process-engine/ops/process-observation.ts +119 -0
- package/src/process-engine/ops/retry-failed-turn.ts +2 -12
- package/src/process-engine/ops/retry-startup.ts +20 -16
- package/src/process-engine/ops/start-process.ts +34 -2
- package/src/process-engine/ops/turn-outcome.ts +61 -60
- package/src/process-engine/ops/turn-wait.ts +225 -0
- package/src/process-engine/ops/update-model-config.ts +66 -0
- package/src/process-engine/recorder.ts +34 -5
- package/src/process-engine/turn-start-preflight.ts +168 -105
- package/src/process-engine/turn-wait-state.ts +126 -0
- package/src/process-engine/turn-worker-requirement.ts +4 -0
- package/src/process-engine/types.ts +21 -0
- package/src/process-engine/writes/build-process-abort-writes.ts +30 -20
- package/src/process-engine/writes/build-turn-outcome-writes.ts +39 -2
- package/src/process-engine/writes/commit-writes.ts +16 -4
- package/src/process-engine/writes/writes.ts +59 -74
- package/src/process-graph.ts +0 -1
- package/src/process-inspection-reader.ts +305 -0
- package/src/process-inspection-trace.ts +176 -0
- package/src/process-inspection.ts +169 -0
- package/src/process-instance-tree-presenter.ts +56 -216
- package/src/process-launch-executor.ts +5 -2
- package/src/process-launch-plan.ts +17 -2
- package/src/process-launcher-registry.ts +28 -16
- package/src/process-model-availability-recovery.ts +6 -4
- package/src/process-model-config.ts +100 -0
- package/src/process-model-policy/construct.ts +1 -0
- package/src/process-model-policy/evaluate.ts +34 -32
- package/src/process-model-policy/index.ts +45 -3
- package/src/process-model-policy/project.ts +62 -76
- package/src/process-model-policy/types.ts +26 -0
- package/src/process-model-policy-presenter.ts +7 -3
- package/src/process-runtime-availability.ts +9 -4
- package/src/process-turn-trace.ts +12 -24
- package/src/process-ui-snapshot-presenter.ts +210 -295
- package/src/routes/dashboard.ts +106 -0
- package/src/routes/future-executions.ts +5 -5
- package/src/routes/launchers.ts +51 -1
- package/src/routes/process-actions.ts +10 -10
- package/src/routes/process-detail.ts +25 -2
- package/src/routes/process-model-config.ts +70 -0
- package/src/routes/process-route-helpers.ts +153 -162
- package/src/routes/processes.ts +2 -0
- package/src/routes/settings.ts +173 -0
- package/src/routes/ticket-creation.ts +28 -5
- package/src/scoped-settings-service.ts +797 -0
- package/src/server-bootstrap/build-host-capabilities.ts +42 -0
- package/src/server-bootstrap/register-http.ts +12 -1
- package/src/session-summary-projection.ts +1 -2
- package/src/skills/bundled-skills.ts +64 -0
- package/src/skills/catalog-service.ts +35 -6
- package/src/skills/extension-importer.ts +94 -0
- package/src/skills/launch-skills.ts +19 -0
- package/src/skills/skill-frontmatter.ts +19 -6
- package/src/skills/source-importer.ts +7 -13
- package/src/startup-evidence.ts +29 -8
- package/src/startup-retry-policy.ts +106 -0
- package/src/supervisor/execution-inspection-ingestor.ts +55 -0
- package/src/supervisor/ipc-handler.ts +2 -0
- package/src/supervisor/worker-event-ingestor.ts +30 -14
- package/src/supervisor/worker-start-payload-builder.ts +17 -0
- package/src/supervisor/worker-supervisor.ts +26 -1
- package/src/test-helpers/prepared-fixture-start.ts +1 -0
- package/src/test-helpers/process-model-fixtures.ts +2 -0
- package/src/test-helpers/scoped-settings-fixtures.ts +126 -0
- package/src/test-helpers/skill-fixtures.ts +28 -0
- package/src/tool-approval-gate.ts +16 -0
- package/src/turn-progress.ts +3 -2
- package/src/turn-wait-service.ts +228 -0
- package/src/worker-runtime-profile-selection.ts +8 -1
- package/dist/app-MSJXFK33.js +0 -8
- package/dist/chunk-HK6BLLHA.js.map +0 -1
- package/dist/chunk-QCHS3X33.js.map +0 -1
- /package/dist/{app-MSJXFK33.js.map → app-KR3N2JAE.js.map} +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { DashboardResponseBody } from "@leitwerk-dev/protocol/http-contracts";
|
|
2
|
+
import type { FastifyInstance } from "fastify";
|
|
3
|
+
import {
|
|
4
|
+
buildDashboardModelIssues,
|
|
5
|
+
type DashboardModelIssueDeps,
|
|
6
|
+
} from "../dashboard-model-issues.js";
|
|
7
|
+
import type { RouteDeps } from "./processes.js";
|
|
8
|
+
|
|
9
|
+
/** @internal */
|
|
10
|
+
export type DashboardRouteDeps = DashboardModelIssueDeps &
|
|
11
|
+
Pick<RouteDeps, "turnSummaries" | "skillCatalog">;
|
|
12
|
+
|
|
13
|
+
/** Aggregate each accepted LLM turn once, including active, failed and retry branches. @internal */
|
|
14
|
+
export function aggregateDashboardCosts(
|
|
15
|
+
rows: readonly {
|
|
16
|
+
/** @internal */ providerId: string | null;
|
|
17
|
+
/** @internal */ modelId: string | null;
|
|
18
|
+
/** @internal */ costUsd: number | null;
|
|
19
|
+
}[],
|
|
20
|
+
): DashboardResponseBody["costs"] {
|
|
21
|
+
const groups = new Map<string, DashboardResponseBody["costs"]["byModel"][number]>();
|
|
22
|
+
let totalUsd = 0;
|
|
23
|
+
let pricedTurnCount = 0;
|
|
24
|
+
for (const row of rows) {
|
|
25
|
+
if (typeof row.costUsd !== "number" || !Number.isFinite(row.costUsd)) continue;
|
|
26
|
+
const providerId = row.providerId && row.modelId ? row.providerId : null;
|
|
27
|
+
const modelId = providerId ? row.modelId : null;
|
|
28
|
+
const key = JSON.stringify([providerId, modelId]);
|
|
29
|
+
const group = groups.get(key) ?? { providerId, modelId, costUsd: 0, turnCount: 0 };
|
|
30
|
+
group.turnCount += 1;
|
|
31
|
+
group.costUsd += row.costUsd;
|
|
32
|
+
totalUsd += row.costUsd;
|
|
33
|
+
pricedTurnCount += 1;
|
|
34
|
+
groups.set(key, group);
|
|
35
|
+
}
|
|
36
|
+
const missingCostTurnCount = rows.length - pricedTurnCount;
|
|
37
|
+
return {
|
|
38
|
+
totalUsd: rows.length > 0 && pricedTurnCount === 0 ? null : totalUsd,
|
|
39
|
+
totalLlmTurnCount: rows.length,
|
|
40
|
+
pricedTurnCount,
|
|
41
|
+
missingCostTurnCount,
|
|
42
|
+
isPartial: missingCostTurnCount > 0,
|
|
43
|
+
byModel: [...groups.values()].sort(
|
|
44
|
+
(a, b) =>
|
|
45
|
+
b.costUsd - a.costUsd ||
|
|
46
|
+
(a.providerId ?? "").localeCompare(b.providerId ?? "") ||
|
|
47
|
+
(a.modelId ?? "").localeCompare(b.modelId ?? ""),
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** @internal */
|
|
53
|
+
export function buildDashboard(deps: DashboardRouteDeps): DashboardResponseBody {
|
|
54
|
+
const items = [...deps.processGraphs.values()]
|
|
55
|
+
.map((process) => ({ id: process.id, name: process.displayName }))
|
|
56
|
+
.sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id));
|
|
57
|
+
const watchers = (deps.processWatchers?.listAll() ?? [])
|
|
58
|
+
.map((watcher) => ({
|
|
59
|
+
id: `${watcher.processId}.${watcher.watcherId}`,
|
|
60
|
+
name: watcher.watcherLabel,
|
|
61
|
+
enabled: watcher.enabled,
|
|
62
|
+
}))
|
|
63
|
+
.sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id));
|
|
64
|
+
const skills = deps.skillCatalog?.list().installedSkills ?? [];
|
|
65
|
+
const bundled = skills.filter((skill) => skill.registrationKind === "bundled").length;
|
|
66
|
+
const lifecycle: Record<string, number> = Object.fromEntries(
|
|
67
|
+
deps.processes.countOverviewByLifecycle({}).map((row) => [row.lifecycleStatus, row.value]),
|
|
68
|
+
);
|
|
69
|
+
const processTotal = Object.values(lifecycle).reduce((sum, count) => sum + count, 0);
|
|
70
|
+
lifecycle.running = (lifecycle.active ?? 0) + (lifecycle.discovered ?? 0);
|
|
71
|
+
const statuses = ["running", "waiting", "error", "completed", "aborted"] as const;
|
|
72
|
+
return {
|
|
73
|
+
generatedAt: new Date().toISOString(),
|
|
74
|
+
definitions: { total: items.length, items },
|
|
75
|
+
watchers: {
|
|
76
|
+
total: watchers.length,
|
|
77
|
+
enabled: watchers.filter((watcher) => watcher.enabled).length,
|
|
78
|
+
items: watchers,
|
|
79
|
+
},
|
|
80
|
+
skills: { total: skills.length, installed: skills.length - bundled, bundled },
|
|
81
|
+
processes: {
|
|
82
|
+
total: processTotal,
|
|
83
|
+
byStatus: statuses.map((status) => ({ status, count: lifecycle[status] ?? 0 })),
|
|
84
|
+
byDefinition: deps.processes
|
|
85
|
+
.listOverviewProcessTypes({ status: "all" })
|
|
86
|
+
.map((row) => ({
|
|
87
|
+
processId: row.processId,
|
|
88
|
+
name: deps.processGraphs.get(row.processId)?.displayName ?? row.processId,
|
|
89
|
+
count: row.value,
|
|
90
|
+
}))
|
|
91
|
+
.sort(
|
|
92
|
+
(a, b) =>
|
|
93
|
+
b.count - a.count ||
|
|
94
|
+
a.name.localeCompare(b.name) ||
|
|
95
|
+
a.processId.localeCompare(b.processId),
|
|
96
|
+
),
|
|
97
|
+
},
|
|
98
|
+
costs: aggregateDashboardCosts(deps.turnSummaries.listDashboardCosts()),
|
|
99
|
+
configuration: { issues: buildDashboardModelIssues(deps) },
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** @internal */
|
|
104
|
+
export function registerDashboardRoutes(app: FastifyInstance, deps: DashboardRouteDeps): void {
|
|
105
|
+
app.get("/api/dashboard", async () => buildDashboard(deps));
|
|
106
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { parseActionRequestBody } from "@leitwerk-dev/protocol";
|
|
1
2
|
import type { CronPreviewResponseBody } from "@leitwerk-dev/protocol/http-contracts";
|
|
2
3
|
import type { FastifyInstance } from "fastify";
|
|
3
4
|
import { nextCronOccurrenceUtc } from "../domain-logic/cron.js";
|
|
4
5
|
import type { FutureExecutionLifecycle } from "../future-execution/index.js";
|
|
5
6
|
import { buildFutureExecutionListView } from "../future-execution-presenter.js";
|
|
6
7
|
import {
|
|
7
|
-
normalizeActionRequest,
|
|
8
8
|
normalizeLauncherRequest,
|
|
9
9
|
type RouteDeps,
|
|
10
10
|
resolveActor,
|
|
@@ -89,13 +89,13 @@ export function registerFutureExecutionRoutes(
|
|
|
89
89
|
app.put<{ Params: { futureExecutionId: string }; Body: unknown }>(
|
|
90
90
|
"/api/future-executions/:futureExecutionId/action",
|
|
91
91
|
async (req, reply) => {
|
|
92
|
-
const
|
|
93
|
-
if (!
|
|
94
|
-
return sendActionRequestNormalizationError(reply,
|
|
92
|
+
const parsed = parseActionRequestBody(req.body);
|
|
93
|
+
if (!parsed.ok) {
|
|
94
|
+
return sendActionRequestNormalizationError(reply, parsed.error);
|
|
95
95
|
}
|
|
96
96
|
const result = await futureExecutionLifecycle.reviseScheduledAction(
|
|
97
97
|
req.params.futureExecutionId,
|
|
98
|
-
|
|
98
|
+
parsed.value,
|
|
99
99
|
{ actor: resolveActor(req) },
|
|
100
100
|
);
|
|
101
101
|
return sendScheduledActionMutationResponse(reply, deps, result);
|
package/src/routes/launchers.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
LauncherOptionsResponseBody,
|
|
6
6
|
LauncherRecentValuesResponseBody,
|
|
7
7
|
LaunchersResponseBody,
|
|
8
|
+
LauncherValidationResponseBody,
|
|
8
9
|
LaunchRunResponseBody,
|
|
9
10
|
ProcessLaunchRunsResponseBody,
|
|
10
11
|
StartLaunchRunResponseBody,
|
|
@@ -57,7 +58,7 @@ export function registerLauncherRoutes(
|
|
|
57
58
|
: {};
|
|
58
59
|
const warnings: Array<{ code: string; message: string; fieldId?: string }> = [];
|
|
59
60
|
if (launcher) {
|
|
60
|
-
const resolved = await deps.launcherService.
|
|
61
|
+
const resolved = await deps.launcherService.resolveUiLauncherPreview(
|
|
61
62
|
req.params.launcherId,
|
|
62
63
|
defaults,
|
|
63
64
|
);
|
|
@@ -108,6 +109,54 @@ export function registerLauncherRoutes(
|
|
|
108
109
|
},
|
|
109
110
|
);
|
|
110
111
|
|
|
112
|
+
app.post<{
|
|
113
|
+
Params: { launcherId: string };
|
|
114
|
+
Querystring: { futureExecutionId?: string };
|
|
115
|
+
Body: unknown;
|
|
116
|
+
}>(
|
|
117
|
+
"/api/launchers/:launcherId/validate",
|
|
118
|
+
{
|
|
119
|
+
schema: {
|
|
120
|
+
querystring: {
|
|
121
|
+
type: "object",
|
|
122
|
+
properties: { futureExecutionId: { type: "string", minLength: 1, pattern: "\\S" } },
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
async (req, reply) => {
|
|
127
|
+
const normalized = normalizeLauncherRequest(req.body);
|
|
128
|
+
if (!normalized.ok) {
|
|
129
|
+
return sendLauncherRequestNormalizationError(reply, normalized.error);
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const resolved = await deps.launcherService.resolveUiLauncherPreview(
|
|
133
|
+
req.params.launcherId,
|
|
134
|
+
normalized.request.launcherInput,
|
|
135
|
+
);
|
|
136
|
+
if (!resolved.ok)
|
|
137
|
+
return { errors: resolved.errors } satisfies LauncherValidationResponseBody;
|
|
138
|
+
// Apply shared skills, models and schedule rules to the preview only.
|
|
139
|
+
// Submission always resolves the complete executable configuration again.
|
|
140
|
+
const result = await futureExecutionLifecycle.prepareLaunch(
|
|
141
|
+
req.params.launcherId,
|
|
142
|
+
normalized.request,
|
|
143
|
+
{
|
|
144
|
+
resolvedLauncher: resolved.launcher,
|
|
145
|
+
futureExecutionId: req.query.futureExecutionId,
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
if (result.ok) return { errors: [] } satisfies LauncherValidationResponseBody;
|
|
149
|
+
if (result.outcome.kind === "invalid") {
|
|
150
|
+
return { errors: result.outcome.issues } satisfies LauncherValidationResponseBody;
|
|
151
|
+
}
|
|
152
|
+
return sendLauncherMutationResponse(reply, deps, result.outcome);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (sendLauncherLookupFailure(reply, error)) return;
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
|
|
111
160
|
app.post<{ Params: { launcherId: string }; Body: unknown }>(
|
|
112
161
|
"/api/launchers/:launcherId/model-config-preview",
|
|
113
162
|
async (req, reply) => {
|
|
@@ -120,6 +169,7 @@ export function registerLauncherRoutes(
|
|
|
120
169
|
try {
|
|
121
170
|
previewResult = await buildLauncherModelConfigPreviewForLauncher({
|
|
122
171
|
launcherService: deps.launcherService,
|
|
172
|
+
scopedSettingsService: deps.scopedSettingsService,
|
|
123
173
|
launchPlans: deps.launchPlans,
|
|
124
174
|
launcherId: req.params.launcherId,
|
|
125
175
|
launcherInput: normalized.request.launcherInput,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseActionRequestBody } from "@leitwerk-dev/protocol";
|
|
1
2
|
import type {
|
|
2
3
|
ModelProviderOptionsResponseBody,
|
|
3
4
|
ProcessActionModelPreviewResponseBody,
|
|
@@ -9,7 +10,6 @@ import { listVisibleActionsForProcess } from "../process-action-presenter.js";
|
|
|
9
10
|
import { sendEngineFailure } from "./process-engine-http.js";
|
|
10
11
|
import {
|
|
11
12
|
getProcessOrReply,
|
|
12
|
-
normalizeActionRequest,
|
|
13
13
|
normalizeContinueRequest,
|
|
14
14
|
normalizeRecoveryModelRequest,
|
|
15
15
|
type RouteDeps,
|
|
@@ -174,7 +174,7 @@ export function registerProcessActionRoutes(
|
|
|
174
174
|
const result = await deps.processEngine.retryStartup(
|
|
175
175
|
req.params.instanceId,
|
|
176
176
|
req.params.startRecordId,
|
|
177
|
-
|
|
177
|
+
{ ...options, actor: resolveActor(req) },
|
|
178
178
|
);
|
|
179
179
|
deps.launchCoordinator.refresh(req.params.instanceId);
|
|
180
180
|
if (!result.ok) {
|
|
@@ -219,14 +219,14 @@ export function registerProcessActionRoutes(
|
|
|
219
219
|
if (!process) {
|
|
220
220
|
return null;
|
|
221
221
|
}
|
|
222
|
-
const
|
|
223
|
-
if (!
|
|
224
|
-
sendActionRequestNormalizationError(reply,
|
|
222
|
+
const parsed = parseActionRequestBody(req.body);
|
|
223
|
+
if (!parsed.ok) {
|
|
224
|
+
sendActionRequestNormalizationError(reply, parsed.error);
|
|
225
225
|
return null;
|
|
226
226
|
}
|
|
227
227
|
return {
|
|
228
228
|
process,
|
|
229
|
-
request:
|
|
229
|
+
request: parsed.value,
|
|
230
230
|
processActionRegistry: deps.processActionRegistry,
|
|
231
231
|
};
|
|
232
232
|
}
|
|
@@ -234,14 +234,14 @@ export function registerProcessActionRoutes(
|
|
|
234
234
|
app.post<{ Params: { instanceId: string; actionId: string }; Body: unknown }>(
|
|
235
235
|
"/api/processes/:instanceId/actions/:actionId/model-preview",
|
|
236
236
|
async (req, reply) => {
|
|
237
|
-
const
|
|
238
|
-
if (!
|
|
239
|
-
return sendActionRequestNormalizationError(reply,
|
|
237
|
+
const parsed = parseActionRequestBody(req.body);
|
|
238
|
+
if (!parsed.ok) {
|
|
239
|
+
return sendActionRequestNormalizationError(reply, parsed.error);
|
|
240
240
|
}
|
|
241
241
|
const result = await deps.processModelSelection.preview(
|
|
242
242
|
req.params.instanceId,
|
|
243
243
|
req.params.actionId,
|
|
244
|
-
|
|
244
|
+
parsed.value.input,
|
|
245
245
|
);
|
|
246
246
|
if (result.kind === "operational_failure") {
|
|
247
247
|
if (result.code === "process_not_found") {
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
} from "@leitwerk-dev/protocol/http-contracts";
|
|
5
5
|
import type { FastifyInstance, FastifyReply } from "fastify";
|
|
6
6
|
import { buildFutureExecutionSummaries } from "../future-execution-presenter.js";
|
|
7
|
+
import { ProcessInspectionReader } from "../process-inspection-reader.js";
|
|
7
8
|
import { getProcessDisplayName } from "../process-operator-attention.js";
|
|
8
9
|
import {
|
|
9
10
|
buildProcessBrowse,
|
|
@@ -20,6 +21,25 @@ export function registerProcessDetailRoutes(app: FastifyInstance, deps: RouteDep
|
|
|
20
21
|
const diagnosticsAssembler = new ProcessDiagnosticsAssembler(deps);
|
|
21
22
|
const primaryPathAssembler = new ProcessPrimaryPathAssembler(deps);
|
|
22
23
|
const uiSnapshotAssembler = new ProcessUiSnapshotAssembler(deps);
|
|
24
|
+
const inspection = new ProcessInspectionReader(deps);
|
|
25
|
+
app.get<{
|
|
26
|
+
Params: { instanceId: string; turnRecordId: string };
|
|
27
|
+
Querystring: { section?: string; entryId?: string; itemId?: string; boundaryFor?: string };
|
|
28
|
+
}>("/api/processes/:instanceId/turn-records/:turnRecordId/inspection", async (req, reply) => {
|
|
29
|
+
const { instanceId, turnRecordId } = req.params;
|
|
30
|
+
const section = req.query.section ?? "summary";
|
|
31
|
+
if (!["summary", "trace", "context", "configuration"].includes(section))
|
|
32
|
+
return reply.code(400).send({ error: "Unknown inspection section" });
|
|
33
|
+
const body =
|
|
34
|
+
section === "trace"
|
|
35
|
+
? await inspection.trace(instanceId, turnRecordId, req.query)
|
|
36
|
+
: section === "context"
|
|
37
|
+
? await inspection.context(instanceId, turnRecordId)
|
|
38
|
+
: section === "configuration"
|
|
39
|
+
? inspection.configuration(instanceId, turnRecordId)
|
|
40
|
+
: inspection.summary(instanceId, turnRecordId);
|
|
41
|
+
return body ?? reply.code(404).send({ error: "Execution not found in this process" });
|
|
42
|
+
});
|
|
23
43
|
|
|
24
44
|
app.get("/api/processes", async () => {
|
|
25
45
|
const instances = deps.processes.listAll();
|
|
@@ -99,11 +119,14 @@ export function registerProcessDetailRoutes(app: FastifyInstance, deps: RouteDep
|
|
|
99
119
|
);
|
|
100
120
|
}
|
|
101
121
|
|
|
102
|
-
app.get<{ Params: { instanceId: string } }>(
|
|
122
|
+
app.get<{ Params: { instanceId: string }; Querystring: { beforeTurnRecordId?: string } }>(
|
|
103
123
|
"/api/processes/:instanceId/ui-snapshot",
|
|
104
124
|
async (req, reply) => {
|
|
105
125
|
const startedAt = performance.now();
|
|
106
|
-
const snapshot = await uiSnapshotAssembler.assemble(
|
|
126
|
+
const snapshot = await uiSnapshotAssembler.assemble(
|
|
127
|
+
req.params.instanceId,
|
|
128
|
+
req.query.beforeTurnRecordId,
|
|
129
|
+
);
|
|
107
130
|
reply.header(
|
|
108
131
|
"Server-Timing",
|
|
109
132
|
`ui-snapshot;dur=${(performance.now() - startedAt).toFixed(1)}`,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ProcessModelConfigResponseBody } from "@leitwerk-dev/protocol/http-contracts";
|
|
2
|
+
import type { FastifyInstance } from "fastify";
|
|
3
|
+
import { reconcileFutureExecutionModelBlocks } from "../future-execution/reconciliation.js";
|
|
4
|
+
import { UpdateModelConfig } from "../process-engine/ops/update-model-config.js";
|
|
5
|
+
import {
|
|
6
|
+
parseProcessModelConfigPatch,
|
|
7
|
+
prepareProcessModelConfig,
|
|
8
|
+
} from "../process-model-config.js";
|
|
9
|
+
import { getProcessOrReply, type RouteDeps, resolveActor } from "./process-route-helpers.js";
|
|
10
|
+
|
|
11
|
+
export function registerProcessModelConfigRoutes(app: FastifyInstance, deps: RouteDeps) {
|
|
12
|
+
for (const preview of [true, false]) {
|
|
13
|
+
app.route<{ Params: { instanceId: string } }>({
|
|
14
|
+
method: preview ? "POST" : "PATCH",
|
|
15
|
+
url: `/api/processes/:instanceId/model-config${preview ? "/preview" : ""}`,
|
|
16
|
+
async handler(req, reply): Promise<ProcessModelConfigResponseBody | undefined> {
|
|
17
|
+
const process = getProcessOrReply(deps, req.params.instanceId, reply);
|
|
18
|
+
if (!process) return;
|
|
19
|
+
const policy = deps.processModelPolicy;
|
|
20
|
+
const cache = deps.modelStatusCache;
|
|
21
|
+
if (!policy || !cache || !deps.processActionRegistry)
|
|
22
|
+
return reply.code(503).send({ error: "Model policy is unavailable" });
|
|
23
|
+
let patch: ReturnType<typeof parseProcessModelConfigPatch>;
|
|
24
|
+
try {
|
|
25
|
+
patch = parseProcessModelConfigPatch(req.body);
|
|
26
|
+
if (preview) {
|
|
27
|
+
const prepared = prepareProcessModelConfig({
|
|
28
|
+
process,
|
|
29
|
+
patch,
|
|
30
|
+
policy,
|
|
31
|
+
availability: cache.snapshot(),
|
|
32
|
+
});
|
|
33
|
+
return { modelConfiguration: prepared.modelConfiguration };
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return reply.code(400).send({
|
|
37
|
+
error: error instanceof Error ? error.message : "Invalid model configuration",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const result = await deps.processEngine.run(UpdateModelConfig, {
|
|
41
|
+
instanceId: process.id,
|
|
42
|
+
patch,
|
|
43
|
+
actor: resolveActor(req),
|
|
44
|
+
});
|
|
45
|
+
if (!result.ok)
|
|
46
|
+
return reply
|
|
47
|
+
.code(
|
|
48
|
+
result.code === "process_not_found"
|
|
49
|
+
? 404
|
|
50
|
+
: result.stage === "post_commit"
|
|
51
|
+
? 500
|
|
52
|
+
: 400,
|
|
53
|
+
)
|
|
54
|
+
.send({ error: result.message });
|
|
55
|
+
// The engine has released its process lock. Future execution coordination must come after it.
|
|
56
|
+
await reconcileFutureExecutionModelBlocks({
|
|
57
|
+
...deps,
|
|
58
|
+
processGraphs: deps.processGraphs,
|
|
59
|
+
processActionRegistry: deps.processActionRegistry,
|
|
60
|
+
policy,
|
|
61
|
+
availability: cache.snapshot(),
|
|
62
|
+
getModelAvailabilitySnapshot: () => cache.snapshot(),
|
|
63
|
+
instanceId: process.id,
|
|
64
|
+
asOf: new Date().toISOString(),
|
|
65
|
+
});
|
|
66
|
+
return result.data;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|