@leitwerk-dev/server 0.1.3 → 0.1.5
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 +1 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +6 -0
- package/dist/app.js.map +1 -1
- package/dist/{chunk-P7YDIR2I.js → chunk-KVHAK5UR.js} +25 -10
- package/dist/chunk-KVHAK5UR.js.map +1 -0
- package/dist/deployment-preflight.d.ts +14 -0
- package/dist/deployment-preflight.d.ts.map +1 -0
- package/dist/deployment-preflight.js +69 -0
- package/dist/deployment-preflight.js.map +1 -0
- package/dist/main.js +17 -1
- package/dist/main.js.map +1 -1
- package/dist/server-bootstrap/register-http.d.ts +1 -0
- package/dist/server-bootstrap/register-http.d.ts.map +1 -1
- package/dist/server-bootstrap/register-http.js +8 -1
- package/dist/server-bootstrap/register-http.js.map +1 -1
- package/dist/supervisor/adoption/worker-adoption-coordinator.d.ts.map +1 -1
- package/dist/supervisor/adoption/worker-adoption-coordinator.js +3 -1
- package/dist/supervisor/adoption/worker-adoption-coordinator.js.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts +2 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.js +10 -6
- package/dist/supervisor/worker-start-payload-builder.js.map +1 -1
- package/package.json +10 -10
- package/src/app.ts +7 -0
- package/src/deployment-preflight.ts +85 -0
- package/src/main.ts +19 -2
- package/src/server-bootstrap/register-http.ts +11 -1
- package/src/supervisor/adoption/worker-adoption-coordinator.ts +4 -1
- package/src/supervisor/worker-start-payload-builder.ts +14 -6
- package/dist/chunk-P7YDIR2I.js.map +0 -1
|
@@ -15,6 +15,7 @@ import { healthBody } from "./register-websocket.js";
|
|
|
15
15
|
|
|
16
16
|
export function registerHttp(input: {
|
|
17
17
|
app: FastifyInstance;
|
|
18
|
+
isReady: () => boolean;
|
|
18
19
|
deps: RouteDeps;
|
|
19
20
|
processWatcherService: Parameters<typeof registerWatcherRoutes>[1]["processWatchers"];
|
|
20
21
|
extensionUiCatalog: ExtensionUiCatalog;
|
|
@@ -25,6 +26,10 @@ export function registerHttp(input: {
|
|
|
25
26
|
extensionUiAssetCacheControl?: string;
|
|
26
27
|
}): void {
|
|
27
28
|
input.app.get("/api/health", async () => healthBody());
|
|
29
|
+
input.app.get("/api/ready", async (_request, reply) => {
|
|
30
|
+
const ready = input.isReady();
|
|
31
|
+
return reply.status(ready ? 200 : 503).send({ status: ready ? "ready" : "not_ready" });
|
|
32
|
+
});
|
|
28
33
|
registerInternalWorkerSessionSnapshotRoutes({
|
|
29
34
|
app: input.app,
|
|
30
35
|
leases: input.deps.leases,
|
|
@@ -38,7 +43,12 @@ export function registerHttp(input: {
|
|
|
38
43
|
registerAuthRoutes(input.app, input.authService);
|
|
39
44
|
input.app.addHook("preHandler", async (request, reply) => {
|
|
40
45
|
const url = request.url.split("?", 1)[0] ?? request.url;
|
|
41
|
-
if (
|
|
46
|
+
if (
|
|
47
|
+
!url.startsWith("/api/") ||
|
|
48
|
+
url === "/api/health" ||
|
|
49
|
+
url === "/api/ready" ||
|
|
50
|
+
url === "/api/auth/me"
|
|
51
|
+
) {
|
|
42
52
|
return;
|
|
43
53
|
}
|
|
44
54
|
requireApiActor(input.authService, request, reply);
|
|
@@ -202,11 +202,14 @@ export function createWorkerAdoptionCoordinator(deps: WorkerAdoptionCoordinatorD
|
|
|
202
202
|
for (const descriptor of descriptors) {
|
|
203
203
|
const lease = deps.safeGetLeaseByInstance(descriptor.instanceId);
|
|
204
204
|
const process = deps.safeGetProcessById(descriptor.instanceId);
|
|
205
|
+
const canAdoptCurrentWorker =
|
|
206
|
+
descriptor.observedState !== "terminal" &&
|
|
207
|
+
process?.currentExecution?.kind === "worker_start";
|
|
205
208
|
const classification = classifyWorkerDescriptor({
|
|
206
209
|
descriptor,
|
|
207
210
|
process,
|
|
208
211
|
lease,
|
|
209
|
-
expectedModelPolicyFingerprint:
|
|
212
|
+
expectedModelPolicyFingerprint: canAdoptCurrentWorker
|
|
210
213
|
? deps.modelPolicyFingerprintForProcess(process)
|
|
211
214
|
: "",
|
|
212
215
|
alreadyAttached: deps.workers.has(descriptor.instanceId),
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type PiResourceBundle,
|
|
13
13
|
type ServerToWorkerMessage,
|
|
14
14
|
verifyCanonicalPiResourceBundle,
|
|
15
|
+
type WorkerRuntimeSettingsSnapshot,
|
|
15
16
|
type WorkerStartPayload,
|
|
16
17
|
} from "@leitwerk-dev/worker-protocol";
|
|
17
18
|
import type { LeitwerkConfig } from "../config/config-types.js";
|
|
@@ -48,6 +49,17 @@ export interface WorkerStartPayloadBuilderDeps
|
|
|
48
49
|
): { revision: number; values: Record<string, string> } | null;
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
export function buildWorkerRuntimeSettingsSnapshot(
|
|
53
|
+
config: LeitwerkConfig,
|
|
54
|
+
): WorkerRuntimeSettingsSnapshot {
|
|
55
|
+
return {
|
|
56
|
+
heartbeat_interval: config.workers.heartbeat_interval,
|
|
57
|
+
turn_max_duration: config.workers.turn_max_duration,
|
|
58
|
+
turn_inactivity_timeout: config.workers.turn_inactivity_timeout,
|
|
59
|
+
turn_abort_grace_period: config.workers.turn_abort_grace_period,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
51
63
|
const TRANSITION_SCOPED_PRODUCT_NAMES = new Set(["input", "message"]);
|
|
52
64
|
|
|
53
65
|
export function buildWorkerConfigSnapshot(config: LeitwerkConfig): ConfigSnapshot {
|
|
@@ -58,12 +70,7 @@ export function buildWorkerConfigSnapshot(config: LeitwerkConfig): ConfigSnapsho
|
|
|
58
70
|
]),
|
|
59
71
|
);
|
|
60
72
|
return {
|
|
61
|
-
workers:
|
|
62
|
-
heartbeat_interval: config.workers.heartbeat_interval,
|
|
63
|
-
turn_max_duration: config.workers.turn_max_duration,
|
|
64
|
-
turn_inactivity_timeout: config.workers.turn_inactivity_timeout,
|
|
65
|
-
turn_abort_grace_period: config.workers.turn_abort_grace_period,
|
|
66
|
-
},
|
|
73
|
+
workers: buildWorkerRuntimeSettingsSnapshot(config),
|
|
67
74
|
pi: config.pi,
|
|
68
75
|
...(Object.keys(processConfigs).length > 0 ? { process_configs: processConfigs } : {}),
|
|
69
76
|
};
|
|
@@ -300,6 +307,7 @@ export function createWorkerStartPayloadBuilder(deps: WorkerStartPayloadBuilderD
|
|
|
300
307
|
workspaceRoot: treePaths.workspaceRoot,
|
|
301
308
|
},
|
|
302
309
|
resume: treePaths.resume,
|
|
310
|
+
workerRuntimeSettings: buildWorkerRuntimeSettingsSnapshot(deps.config),
|
|
303
311
|
...(treePaths.resume ? { resumeLeafEntryId } : {}),
|
|
304
312
|
...(repositoryCredentials.length > 0 ? { repositoryCredentials } : {}),
|
|
305
313
|
};
|