@leitwerk-dev/server 0.1.7 → 0.1.9
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.d.ts.map +1 -1
- package/dist/app.js +24 -15
- package/dist/app.js.map +1 -1
- package/dist/{chunk-GIWHTJSL.js → chunk-2ESDXLNE.js} +228 -101
- package/dist/chunk-2ESDXLNE.js.map +1 -0
- package/dist/{chunk-OO6VH4FX.js → chunk-DFHOPJRZ.js} +405 -259
- package/dist/chunk-DFHOPJRZ.js.map +1 -0
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-loader.js +14 -25
- package/dist/config/config-loader.js.map +1 -1
- package/dist/config/config-types.d.ts +5 -17
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/db/skill-repo.d.ts +2 -2
- package/dist/db/skill-repo.d.ts.map +1 -1
- package/dist/db/skill-repo.js +24 -32
- package/dist/db/skill-repo.js.map +1 -1
- package/dist/external-source-service.d.ts.map +1 -1
- package/dist/external-source-service.js +5 -2
- package/dist/external-source-service.js.map +1 -1
- package/dist/future-execution/execution.d.ts +1 -1
- package/dist/future-execution/execution.d.ts.map +1 -1
- package/dist/future-execution/execution.js +1 -13
- package/dist/future-execution/execution.js.map +1 -1
- package/dist/integration-tool-registry.js +1 -1
- package/dist/integration-tool-registry.js.map +1 -1
- package/dist/model-providers/builtin-server-adapter.d.ts.map +1 -1
- package/dist/model-providers/builtin-server-adapter.js +10 -2
- package/dist/model-providers/builtin-server-adapter.js.map +1 -1
- package/dist/process-action-registry.d.ts +2 -4
- package/dist/process-action-registry.d.ts.map +1 -1
- package/dist/process-action-registry.js +31 -28
- package/dist/process-action-registry.js.map +1 -1
- package/dist/process-engine/engine.d.ts.map +1 -1
- package/dist/process-engine/engine.js +4 -4
- package/dist/process-engine/engine.js.map +1 -1
- package/dist/process-engine/operation.d.ts +4 -0
- package/dist/process-engine/operation.d.ts.map +1 -1
- package/dist/process-engine/ops/execute-action.d.ts.map +1 -1
- package/dist/process-engine/ops/execute-action.js +0 -3
- package/dist/process-engine/ops/execute-action.js.map +1 -1
- package/dist/process-engine/ops/worker-failure.d.ts +2 -0
- package/dist/process-engine/ops/worker-failure.d.ts.map +1 -1
- package/dist/process-engine/ops/worker-failure.js +2 -0
- package/dist/process-engine/ops/worker-failure.js.map +1 -1
- package/dist/process-engine/runner.d.ts +2 -2
- package/dist/process-engine/runner.d.ts.map +1 -1
- package/dist/process-engine/runner.js +13 -1
- package/dist/process-engine/runner.js.map +1 -1
- package/dist/process-engine/types.d.ts +10 -4
- package/dist/process-engine/types.d.ts.map +1 -1
- package/dist/process-engine/writes/build-server-transition-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-server-transition-writes.js +2 -8
- package/dist/process-engine/writes/build-server-transition-writes.js.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.js +1 -2
- package/dist/process-engine/writes/build-turn-outcome-writes.js.map +1 -1
- package/dist/process-engine/writes/build-turn-selection-writes.d.ts +1 -2
- package/dist/process-engine/writes/build-turn-selection-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-selection-writes.js +1 -57
- package/dist/process-engine/writes/build-turn-selection-writes.js.map +1 -1
- package/dist/process-engine/writes/build-worker-failure-writes.d.ts +3 -1
- package/dist/process-engine/writes/build-worker-failure-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-worker-failure-writes.js +2 -1
- package/dist/process-engine/writes/build-worker-failure-writes.js.map +1 -1
- package/dist/process-launch-executor.d.ts +6 -4
- package/dist/process-launch-executor.d.ts.map +1 -1
- package/dist/process-launch-executor.js +16 -1
- package/dist/process-launch-executor.js.map +1 -1
- package/dist/process-launch-plan.d.ts.map +1 -1
- package/dist/process-launch-plan.js +1 -0
- package/dist/process-launch-plan.js.map +1 -1
- package/dist/process-operator-attention.d.ts +1 -1
- package/dist/process-operator-attention.d.ts.map +1 -1
- package/dist/process-operator-attention.js +1 -1
- package/dist/process-operator-attention.js.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.js +24 -3
- package/dist/process-ui-snapshot-presenter.js.map +1 -1
- package/dist/process-watcher-registry.d.ts.map +1 -1
- package/dist/process-watcher-registry.js +13 -5
- package/dist/process-watcher-registry.js.map +1 -1
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +1 -2
- package/dist/routes/skills.js.map +1 -1
- package/dist/server-automatic-turn-drainer.d.ts.map +1 -1
- package/dist/server-automatic-turn-drainer.js +15 -0
- package/dist/server-automatic-turn-drainer.js.map +1 -1
- package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
- package/dist/server-bootstrap/build-host-capabilities.js +1 -0
- package/dist/server-bootstrap/build-host-capabilities.js.map +1 -1
- package/dist/skills/skill-frontmatter.d.ts +4 -0
- package/dist/skills/skill-frontmatter.d.ts.map +1 -0
- package/dist/skills/skill-frontmatter.js +13 -0
- package/dist/skills/skill-frontmatter.js.map +1 -0
- package/dist/skills/source-importer.d.ts +2 -3
- package/dist/skills/source-importer.d.ts.map +1 -1
- package/dist/skills/source-importer.js +16 -62
- package/dist/skills/source-importer.js.map +1 -1
- package/dist/supervisor/accepted-turn-start-replay.d.ts +9 -0
- package/dist/supervisor/accepted-turn-start-replay.d.ts.map +1 -0
- package/dist/supervisor/accepted-turn-start-replay.js +23 -0
- package/dist/supervisor/accepted-turn-start-replay.js.map +1 -0
- package/dist/supervisor/ipc-handler.d.ts +9 -0
- package/dist/supervisor/ipc-handler.d.ts.map +1 -1
- package/dist/supervisor/ipc-handler.js +9 -4
- package/dist/supervisor/ipc-handler.js.map +1 -1
- package/dist/supervisor/stale-heartbeat-watchdog.d.ts +1 -1
- package/dist/supervisor/stale-heartbeat-watchdog.d.ts.map +1 -1
- package/dist/supervisor/stale-heartbeat-watchdog.js +47 -5
- package/dist/supervisor/stale-heartbeat-watchdog.js.map +1 -1
- package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
- package/dist/supervisor/worker-event-ingestor.js +16 -0
- package/dist/supervisor/worker-event-ingestor.js.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts +2 -4
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.js +3 -1
- package/dist/supervisor/worker-start-payload-builder.js.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +4 -5
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- package/dist/supervisor/worker-supervisor.js +31 -0
- package/dist/supervisor/worker-supervisor.js.map +1 -1
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts +12 -3
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts.map +1 -1
- package/dist/supervisor/worker-turn-ipc-recorder.js +129 -33
- package/dist/supervisor/worker-turn-ipc-recorder.js.map +1 -1
- package/dist/supervisor/worker-websocket-ipc.d.ts.map +1 -1
- package/dist/supervisor/worker-websocket-ipc.js +20 -10
- package/dist/supervisor/worker-websocket-ipc.js.map +1 -1
- package/dist/test-helpers/fake-worker-supervisor.d.ts.map +1 -1
- package/dist/test-helpers/fake-worker-supervisor.js +4 -0
- package/dist/test-helpers/fake-worker-supervisor.js.map +1 -1
- package/dist/test-helpers/ipc-handler-harness.d.ts.map +1 -1
- package/dist/test-helpers/ipc-handler-harness.js +1 -20
- package/dist/test-helpers/ipc-handler-harness.js.map +1 -1
- package/dist/test-helpers/process-fixtures.d.ts +1 -1
- package/dist/test-helpers/process-fixtures.d.ts.map +1 -1
- package/dist/test-helpers/process-fixtures.js +0 -6
- package/dist/test-helpers/process-fixtures.js.map +1 -1
- package/dist/turn-progress.d.ts +12 -0
- package/dist/turn-progress.d.ts.map +1 -0
- package/dist/turn-progress.js +108 -0
- package/dist/turn-progress.js.map +1 -0
- package/dist/{writes-DUwQe8MD.d.ts → writes-DNXpryd0.d.ts} +68 -36
- package/package.json +10 -10
- package/src/app.ts +25 -15
- package/src/config/config-loader.ts +33 -25
- package/src/config/config-types.ts +6 -13
- package/src/db/skill-repo.ts +26 -36
- package/src/external-source-service.ts +5 -2
- package/src/future-execution/execution.ts +2 -13
- package/src/integration-tool-registry.ts +1 -1
- package/src/model-providers/builtin-server-adapter.ts +10 -2
- package/src/process-action-registry.ts +48 -40
- package/src/process-engine/engine.ts +6 -4
- package/src/process-engine/operation.ts +5 -0
- package/src/process-engine/ops/execute-action.ts +0 -3
- package/src/process-engine/ops/worker-failure.ts +4 -0
- package/src/process-engine/runner.ts +13 -0
- package/src/process-engine/types.ts +14 -2
- package/src/process-engine/writes/build-server-transition-writes.ts +1 -14
- package/src/process-engine/writes/build-turn-outcome-writes.ts +1 -2
- package/src/process-engine/writes/build-turn-selection-writes.ts +0 -75
- package/src/process-engine/writes/build-worker-failure-writes.ts +4 -1
- package/src/process-launch-executor.ts +24 -15
- package/src/process-launch-plan.ts +1 -0
- package/src/process-operator-attention.ts +7 -3
- package/src/process-ui-snapshot-presenter.ts +24 -6
- package/src/process-watcher-registry.ts +15 -5
- package/src/routes/skills.ts +1 -3
- package/src/server-automatic-turn-drainer.ts +20 -1
- package/src/server-bootstrap/build-host-capabilities.ts +1 -0
- package/src/skills/skill-frontmatter.ts +13 -0
- package/src/skills/source-importer.ts +20 -82
- package/src/supervisor/accepted-turn-start-replay.ts +40 -0
- package/src/supervisor/ipc-handler.ts +18 -4
- package/src/supervisor/stale-heartbeat-watchdog.ts +55 -6
- package/src/supervisor/worker-event-ingestor.ts +15 -0
- package/src/supervisor/worker-start-payload-builder.ts +5 -2
- package/src/supervisor/worker-supervisor.ts +43 -4
- package/src/supervisor/worker-turn-ipc-recorder.ts +185 -46
- package/src/supervisor/worker-websocket-ipc.ts +28 -13
- package/src/test-helpers/fake-worker-supervisor.ts +4 -0
- package/src/test-helpers/ipc-handler-harness.ts +1 -22
- package/src/test-helpers/process-fixtures.ts +1 -6
- package/src/turn-progress.ts +114 -0
- package/dist/chunk-GIWHTJSL.js.map +0 -1
- package/dist/chunk-OO6VH4FX.js.map +0 -1
- package/dist/skills/catalog-sync.d.ts +0 -9
- package/dist/skills/catalog-sync.d.ts.map +0 -1
- package/dist/skills/catalog-sync.js +0 -7
- package/dist/skills/catalog-sync.js.map +0 -1
- package/src/skills/catalog-sync.ts +0 -13
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { TurnProgressReport, TurnProgressStepStatus } from "@leitwerk-dev/domain";
|
|
2
|
+
import { createDurableWsFrame } from "@leitwerk-dev/protocol";
|
|
3
|
+
import type { RepositoryBundle } from "./db/repositories.js";
|
|
4
|
+
import type { Broadcaster } from "./ws/broadcast.js";
|
|
5
|
+
|
|
6
|
+
const STEP_STATUSES = new Set<TurnProgressStepStatus>([
|
|
7
|
+
"incomplete",
|
|
8
|
+
"in_progress",
|
|
9
|
+
"completed",
|
|
10
|
+
"failed",
|
|
11
|
+
]);
|
|
12
|
+
const LINK_KINDS = new Set(["pull_request", "merge_request", "commit", "pipeline", "other"]);
|
|
13
|
+
|
|
14
|
+
function text(value: unknown, max: number): string {
|
|
15
|
+
return typeof value === "string" ? value.trim().slice(0, max) : "";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function safeExternalUrl(value: unknown): string {
|
|
19
|
+
const candidate = text(value, 2_000);
|
|
20
|
+
try {
|
|
21
|
+
const url = new URL(candidate);
|
|
22
|
+
return (url.protocol === "https:" || url.protocol === "http:") && !url.username && !url.password
|
|
23
|
+
? url.toString()
|
|
24
|
+
: "";
|
|
25
|
+
} catch {
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function normalizeTurnProgressReport(value: unknown): TurnProgressReport | null {
|
|
31
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
32
|
+
const raw = value as Record<string, unknown>;
|
|
33
|
+
const title = text(raw.title, 160);
|
|
34
|
+
if (!title || !Array.isArray(raw.steps) || raw.steps.length > 50) return null;
|
|
35
|
+
const ids = new Set<string>();
|
|
36
|
+
const steps = raw.steps.flatMap((value) => {
|
|
37
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return [];
|
|
38
|
+
const step = value as Record<string, unknown>;
|
|
39
|
+
const id = text(step.id, 80);
|
|
40
|
+
const label = text(step.label, 240);
|
|
41
|
+
const status = step.status;
|
|
42
|
+
const detail = text(step.detail, 1_000);
|
|
43
|
+
if (!id || ids.has(id) || !label || !STEP_STATUSES.has(status as TurnProgressStepStatus)) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
ids.add(id);
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
id,
|
|
50
|
+
label,
|
|
51
|
+
status: status as TurnProgressStepStatus,
|
|
52
|
+
...(detail ? { detail } : {}),
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
});
|
|
56
|
+
if (steps.length !== raw.steps.length || steps.length === 0) return null;
|
|
57
|
+
const linkIds = new Set<string>();
|
|
58
|
+
const rawLinks = raw.links === undefined ? [] : raw.links;
|
|
59
|
+
if (!Array.isArray(rawLinks) || rawLinks.length > 20) return null;
|
|
60
|
+
const links = rawLinks.flatMap((value) => {
|
|
61
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return [];
|
|
62
|
+
const link = value as Record<string, unknown>;
|
|
63
|
+
const id = text(link.id, 80);
|
|
64
|
+
const label = text(link.label, 240);
|
|
65
|
+
const url = safeExternalUrl(link.url);
|
|
66
|
+
const kind = text(link.kind, 40);
|
|
67
|
+
if (!id || linkIds.has(id) || !label || !url) return [];
|
|
68
|
+
if (kind && !LINK_KINDS.has(kind)) return [];
|
|
69
|
+
linkIds.add(id);
|
|
70
|
+
return [
|
|
71
|
+
{
|
|
72
|
+
id,
|
|
73
|
+
label,
|
|
74
|
+
url,
|
|
75
|
+
...(kind ? { kind: kind as NonNullable<TurnProgressReport["links"]>[number]["kind"] } : {}),
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
});
|
|
79
|
+
if (links.length !== rawLinks.length) return null;
|
|
80
|
+
return { title, steps, ...(links.length > 0 ? { links } : {}) };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function recordTurnProgress(
|
|
84
|
+
deps: Pick<RepositoryBundle, "processes" | "turnRecords" | "events"> & {
|
|
85
|
+
broadcaster: Broadcaster;
|
|
86
|
+
},
|
|
87
|
+
input: { instanceId: string; turnRecordId: string; report: unknown },
|
|
88
|
+
): boolean {
|
|
89
|
+
const process = deps.processes.getById(input.instanceId);
|
|
90
|
+
const turnRecord = deps.turnRecords.getById(input.turnRecordId);
|
|
91
|
+
const report = normalizeTurnProgressReport(input.report);
|
|
92
|
+
if (
|
|
93
|
+
!process ||
|
|
94
|
+
!turnRecord ||
|
|
95
|
+
turnRecord.instanceId !== input.instanceId ||
|
|
96
|
+
turnRecord.status !== "running" ||
|
|
97
|
+
process.selectedTurnId !== turnRecord.turnId ||
|
|
98
|
+
!report
|
|
99
|
+
)
|
|
100
|
+
return false;
|
|
101
|
+
deps.events.create({
|
|
102
|
+
instanceId: input.instanceId,
|
|
103
|
+
eventType: "turn.progress",
|
|
104
|
+
data: { turnRecordId: input.turnRecordId, report },
|
|
105
|
+
});
|
|
106
|
+
deps.broadcaster.broadcast(
|
|
107
|
+
createDurableWsFrame({
|
|
108
|
+
type: "process.event",
|
|
109
|
+
instanceId: input.instanceId,
|
|
110
|
+
payload: { eventType: "turn_progress", level: "info", message: "Turn progress updated" },
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
113
|
+
return true;
|
|
114
|
+
}
|