@leitwerk-dev/server 0.4.2 → 0.4.4
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-2TCRADVA.js +8 -0
- package/dist/{app-CtlotzYm.d.ts → app-DZUsf76a.d.ts} +30 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/auth/api-token-routes.d.ts.map +1 -1
- package/dist/auth/api-token-service.d.ts +4 -3
- package/dist/auth/api-token-service.d.ts.map +1 -1
- package/dist/auth/auth-client.d.ts +17 -12
- package/dist/auth/auth-client.d.ts.map +1 -1
- package/dist/auth/auth-config.d.ts +2 -1
- package/dist/auth/auth-config.d.ts.map +1 -1
- package/dist/auth/auth-service.d.ts +10 -10
- package/dist/auth/auth-service.d.ts.map +1 -1
- package/dist/auth/auth-test-helpers.d.ts +24 -0
- package/dist/auth/auth-test-helpers.d.ts.map +1 -1
- package/dist/auth/github-oauth-client.d.ts +3 -13
- package/dist/auth/github-oauth-client.d.ts.map +1 -1
- package/dist/auth/oidc-client.d.ts +6 -14
- package/dist/auth/oidc-client.d.ts.map +1 -1
- package/dist/auth/oidc-evidence.d.ts +22 -0
- package/dist/auth/oidc-evidence.d.ts.map +1 -0
- package/dist/auth/routes.d.ts.map +1 -1
- package/dist/{chunk-YLWY4UTT.js → chunk-6EEU4QOU.js} +162 -5
- package/dist/chunk-6EEU4QOU.js.map +1 -0
- package/dist/{chunk-OUA5EZS2.js → chunk-AJ2DQWI3.js} +225 -189
- package/dist/chunk-AJ2DQWI3.js.map +1 -0
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-types.d.ts +17 -0
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/db/api-token-repo.d.ts +3 -0
- package/dist/db/api-token-repo.d.ts.map +1 -1
- package/dist/db/auth-repo.d.ts +5 -0
- package/dist/db/auth-repo.d.ts.map +1 -1
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/schema.d.ts +32 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/launch-pipeline.d.ts.map +1 -1
- package/dist/main.js +3 -3
- package/dist/process-launcher-registry.d.ts +3 -0
- package/dist/process-launcher-registry.d.ts.map +1 -1
- package/dist/routes/launchers.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +12 -12
- package/src/app.ts +1 -0
- package/src/auth/api-token-routes.ts +17 -18
- package/src/auth/api-token-service.ts +9 -10
- package/src/auth/auth-client.ts +18 -18
- package/src/auth/auth-config.ts +18 -19
- package/src/auth/auth-service.ts +54 -72
- package/src/auth/auth-test-helpers.ts +101 -0
- package/src/auth/github-oauth-client.ts +8 -22
- package/src/auth/oidc-client.ts +34 -28
- package/src/auth/oidc-evidence.ts +168 -0
- package/src/auth/routes.ts +22 -6
- package/src/config/config-loader.ts +34 -0
- package/src/config/config-types.ts +18 -0
- package/src/db/api-token-repo.ts +6 -1
- package/src/db/auth-repo.ts +7 -0
- package/src/db/database.ts +14 -0
- package/src/db/schema.ts +2 -0
- package/src/launch-pipeline.ts +6 -0
- package/src/process-launcher-registry.ts +56 -6
- package/src/routes/launchers.ts +35 -20
- package/dist/app-KR3N2JAE.js +0 -8
- package/dist/chunk-OUA5EZS2.js.map +0 -1
- package/dist/chunk-YLWY4UTT.js.map +0 -1
- /package/dist/{app-KR3N2JAE.js.map → app-2TCRADVA.js.map} +0 -0
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SAFE_SKILL_ID_PATTERN,
|
|
8
8
|
SKILL_RESOURCE_OWNER,
|
|
9
9
|
actorForRequest,
|
|
10
|
+
actorFromClaims,
|
|
10
11
|
appendProcessEvent,
|
|
11
12
|
applyMetadataPatch,
|
|
12
13
|
applyProcessPatchField,
|
|
@@ -46,6 +47,7 @@ import {
|
|
|
46
47
|
defaultWorkerRuntimeProfile,
|
|
47
48
|
deferTurnWaitStarts,
|
|
48
49
|
evaluateAtStableAvailabilityRevision,
|
|
50
|
+
evidenceAllows,
|
|
49
51
|
failLaunchRun,
|
|
50
52
|
finishLaunchRun,
|
|
51
53
|
generateId,
|
|
@@ -61,6 +63,7 @@ import {
|
|
|
61
63
|
hasAuthorization,
|
|
62
64
|
hasProcessGraph,
|
|
63
65
|
hashOpaqueToken,
|
|
66
|
+
interpretOidcLogin,
|
|
64
67
|
isHttpsOrLoopbackHttpUrl,
|
|
65
68
|
isInternalEngineFailureCode,
|
|
66
69
|
isLoopbackHttpUrl,
|
|
@@ -130,7 +133,7 @@ import {
|
|
|
130
133
|
verifyOpaqueToken,
|
|
131
134
|
withTimeout,
|
|
132
135
|
writeTurnWait
|
|
133
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-6EEU4QOU.js";
|
|
134
137
|
|
|
135
138
|
// src/app.ts
|
|
136
139
|
import path10 from "node:path";
|
|
@@ -150,6 +153,9 @@ import {
|
|
|
150
153
|
} from "@leitwerk-dev/worker-runners";
|
|
151
154
|
import Fastify from "fastify";
|
|
152
155
|
|
|
156
|
+
// src/auth/auth-service.ts
|
|
157
|
+
import { ADMIN_ACTOR as ADMIN_ACTOR2 } from "@leitwerk-dev/domain";
|
|
158
|
+
|
|
153
159
|
// src/auth/api-token-service.ts
|
|
154
160
|
import { randomUUID } from "node:crypto";
|
|
155
161
|
import { ADMIN_ACTOR } from "@leitwerk-dev/domain";
|
|
@@ -162,19 +168,15 @@ var DEFAULT_LOGIN_FLOW_TTL_MS = 10 * 60 * 1e3;
|
|
|
162
168
|
function resolveAuthConfig(config) {
|
|
163
169
|
const auth = config.auth;
|
|
164
170
|
const serverBaseUrl = new URL(config.server.base_url);
|
|
165
|
-
const providers = (auth?.providers ?? []).map(
|
|
166
|
-
|
|
171
|
+
const providers = (auth?.providers ?? []).map((provider) => {
|
|
172
|
+
const redirect_uri = provider.redirect_uri ?? new URL("/auth/callback", serverBaseUrl).toString();
|
|
173
|
+
return provider.kind === "oidc" ? {
|
|
167
174
|
...provider,
|
|
168
|
-
redirect_uri
|
|
175
|
+
redirect_uri,
|
|
169
176
|
scopes: provider.scopes ?? ["openid", "profile", "email"],
|
|
170
177
|
identity_claim: provider.identity_claim ?? "preferred_username"
|
|
171
|
-
} : {
|
|
172
|
-
|
|
173
|
-
redirect_uri: provider.redirect_uri ?? new URL("/auth/callback", serverBaseUrl).toString(),
|
|
174
|
-
scopes: ["read:org"],
|
|
175
|
-
identity_claim: "login"
|
|
176
|
-
}
|
|
177
|
-
);
|
|
178
|
+
} : { ...provider, redirect_uri, scopes: ["read:org"], identity_claim: "login" };
|
|
179
|
+
});
|
|
178
180
|
const sessionCookieName = auth?.session?.cookie_name ?? DEFAULT_SESSION_COOKIE_NAME;
|
|
179
181
|
return {
|
|
180
182
|
enabled: auth?.enabled === true && providers.length > 0,
|
|
@@ -194,24 +196,20 @@ function resolveAuthConfig(config) {
|
|
|
194
196
|
allowlist: new Set(auth?.allowlist ?? [])
|
|
195
197
|
};
|
|
196
198
|
}
|
|
197
|
-
function isActorAllowedByConfig(actor, auth) {
|
|
199
|
+
function isActorAllowedByConfig(actor, auth, evidence) {
|
|
198
200
|
if (!auth.enabled) {
|
|
199
201
|
return true;
|
|
200
202
|
}
|
|
201
203
|
if (actor.kind !== "user" || actor.provider === null) {
|
|
202
204
|
return false;
|
|
203
205
|
}
|
|
204
|
-
if (!auth.providers.some((provider2) => provider2.id === actor.provider)) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
const prefix = `${actor.provider}:`;
|
|
208
|
-
if (!actor.id.startsWith(prefix)) return false;
|
|
209
206
|
const provider = auth.providers.find((candidate) => candidate.id === actor.provider);
|
|
210
|
-
|
|
207
|
+
if (!provider || !actor.id.startsWith(`${actor.provider}:`)) return false;
|
|
208
|
+
return provider.kind === "oauth2" || provider.kind === "oidc" && evidenceAllows(actor, provider, evidence, auth.allowlist);
|
|
211
209
|
}
|
|
212
210
|
|
|
213
211
|
// src/auth/api-token-service.ts
|
|
214
|
-
function
|
|
212
|
+
function tokenProviderBinding(provider) {
|
|
215
213
|
return provider.kind === "oidc" ? {
|
|
216
214
|
id: provider.id,
|
|
217
215
|
kind: provider.kind,
|
|
@@ -235,13 +233,6 @@ function createApiTokenService(input) {
|
|
|
235
233
|
if (auth.enabled) repo.revokeAnonymous((/* @__PURE__ */ new Date()).toISOString());
|
|
236
234
|
return {
|
|
237
235
|
policy,
|
|
238
|
-
ownerForActor(actor) {
|
|
239
|
-
if (!auth.enabled)
|
|
240
|
-
return { kind: "anonymous", id: "anonymous", actor: ADMIN_ACTOR, providerBinding: null };
|
|
241
|
-
const provider = auth.providers.find((p) => p.id === actor.provider);
|
|
242
|
-
if (!provider || !isActorAllowedByConfig(actor, auth)) throw new Error("Invalid token owner");
|
|
243
|
-
return { kind: "user", id: actor.id, actor, providerBinding: binding(provider) };
|
|
244
|
-
},
|
|
245
236
|
create(owner, name, expiresAt) {
|
|
246
237
|
if (!policy.enabled) throw new ApiTokenValidationError("API token issuance is disabled");
|
|
247
238
|
if (typeof name !== "string" || name.trim().length === 0 || name.trim().length > 100)
|
|
@@ -283,9 +274,10 @@ function createApiTokenService(input) {
|
|
|
283
274
|
if (token.owner.kind === "anonymous") {
|
|
284
275
|
if (auth.enabled) return denied;
|
|
285
276
|
} else {
|
|
286
|
-
if (!auth.enabled || !isActorAllowedByConfig(token.owner.actor, auth))
|
|
277
|
+
if (!auth.enabled || !isActorAllowedByConfig(token.owner.actor, auth, token.owner.oidcEvidence))
|
|
278
|
+
return denied;
|
|
287
279
|
const provider = auth.providers.find((p) => p.id === token.owner.actor.provider);
|
|
288
|
-
if (!provider || JSON.stringify(
|
|
280
|
+
if (!provider || JSON.stringify(tokenProviderBinding(provider)) !== JSON.stringify(token.owner.providerBinding))
|
|
289
281
|
return denied;
|
|
290
282
|
}
|
|
291
283
|
repo.touch(token.id, now2);
|
|
@@ -298,14 +290,10 @@ function createApiTokenService(input) {
|
|
|
298
290
|
}
|
|
299
291
|
|
|
300
292
|
// src/auth/github-oauth-client.ts
|
|
301
|
-
import { randomBytes } from "node:crypto";
|
|
302
293
|
var GITHUB_AUTHORIZE_URL = "https://github.com/login/oauth/authorize";
|
|
303
294
|
var GITHUB_TOKEN_URL = "https://github.com/login/oauth/access_token";
|
|
304
295
|
var GITHUB_API_URL = "https://api.github.com";
|
|
305
296
|
var GITHUB_API_VERSION = "2022-11-28";
|
|
306
|
-
function opaqueValue() {
|
|
307
|
-
return randomBytes(32).toString("base64url");
|
|
308
|
-
}
|
|
309
297
|
function githubHeaders(accessToken) {
|
|
310
298
|
return {
|
|
311
299
|
Accept: "application/vnd.github+json",
|
|
@@ -325,18 +313,17 @@ async function jsonObject(response, errorMessage3) {
|
|
|
325
313
|
function createGithubOauthClient(fetchImpl = fetch) {
|
|
326
314
|
return {
|
|
327
315
|
async createAuthorizationRequest(provider) {
|
|
328
|
-
const state =
|
|
316
|
+
const state = generateOpaqueToken();
|
|
329
317
|
const redirectUrl = new URL(GITHUB_AUTHORIZE_URL);
|
|
330
318
|
redirectUrl.searchParams.set("client_id", provider.client_id);
|
|
331
319
|
redirectUrl.searchParams.set("redirect_uri", provider.redirect_uri);
|
|
332
320
|
redirectUrl.searchParams.set("scope", provider.scopes.join(" "));
|
|
333
321
|
redirectUrl.searchParams.set("state", state);
|
|
334
322
|
return {
|
|
335
|
-
provider,
|
|
336
323
|
state,
|
|
337
324
|
// The persisted login-flow schema requires a verifier. GitHub OAuth Apps
|
|
338
325
|
// authenticate this confidential client with its secret instead of PKCE.
|
|
339
|
-
pkceVerifier:
|
|
326
|
+
pkceVerifier: generateOpaqueToken(),
|
|
340
327
|
redirectUrl: redirectUrl.toString()
|
|
341
328
|
};
|
|
342
329
|
},
|
|
@@ -384,13 +371,13 @@ import {
|
|
|
384
371
|
allowInsecureRequests,
|
|
385
372
|
authorizationCodeGrant,
|
|
386
373
|
buildAuthorizationUrl,
|
|
374
|
+
ClientError,
|
|
387
375
|
ClientSecretPost,
|
|
388
376
|
calculatePKCECodeChallenge,
|
|
389
377
|
discovery,
|
|
390
378
|
fetchUserInfo,
|
|
391
379
|
randomPKCECodeVerifier,
|
|
392
|
-
randomState
|
|
393
|
-
skipSubjectCheck
|
|
380
|
+
randomState
|
|
394
381
|
} from "openid-client";
|
|
395
382
|
function createOpenIdClient() {
|
|
396
383
|
const configs = /* @__PURE__ */ new Map();
|
|
@@ -425,7 +412,7 @@ function createOpenIdClient() {
|
|
|
425
412
|
code_challenge: codeChallenge,
|
|
426
413
|
code_challenge_method: "S256"
|
|
427
414
|
}).toString();
|
|
428
|
-
return {
|
|
415
|
+
return { state, pkceVerifier, redirectUrl };
|
|
429
416
|
},
|
|
430
417
|
async exchangeCallback(input) {
|
|
431
418
|
const config = await getConfiguration(input.provider);
|
|
@@ -439,20 +426,24 @@ function createOpenIdClient() {
|
|
|
439
426
|
{ redirect_uri: input.provider.redirect_uri }
|
|
440
427
|
);
|
|
441
428
|
const idClaims = tokens.claims();
|
|
429
|
+
if (!idClaims || typeof idClaims.sub !== "string" || !idClaims.sub.trim()) {
|
|
430
|
+
throw new Error("OIDC ID token requires a valid subject");
|
|
431
|
+
}
|
|
432
|
+
let userInfo = null;
|
|
442
433
|
if (tokens.access_token) {
|
|
443
|
-
const expectedSubject = typeof idClaims?.sub === "string" ? idClaims.sub : skipSubjectCheck;
|
|
444
434
|
try {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
);
|
|
450
|
-
return { claims: { ...idClaims ?? {}, ...userInfo } };
|
|
451
|
-
} catch {
|
|
435
|
+
userInfo = await fetchUserInfo(config, tokens.access_token, idClaims.sub);
|
|
436
|
+
} catch (error) {
|
|
437
|
+
if (!(error instanceof TypeError) && !(error instanceof ClientError && (error.code === "OAUTH_TIMEOUT" || error.cause instanceof Response && error.cause.status >= 500)))
|
|
438
|
+
throw new Error("OIDC UserInfo validation failed");
|
|
452
439
|
}
|
|
440
|
+
if (userInfo && userInfo.sub !== idClaims.sub)
|
|
441
|
+
throw new Error("OIDC UserInfo subject mismatch");
|
|
453
442
|
}
|
|
454
|
-
|
|
455
|
-
|
|
443
|
+
return {
|
|
444
|
+
idTokenClaims: idClaims,
|
|
445
|
+
userInfoClaims: userInfo
|
|
446
|
+
};
|
|
456
447
|
}
|
|
457
448
|
};
|
|
458
449
|
}
|
|
@@ -465,54 +456,37 @@ function createAuthClient(input) {
|
|
|
465
456
|
createAuthorizationRequest(provider) {
|
|
466
457
|
return provider.kind === "oidc" ? oidc.createAuthorizationRequest(provider) : github.createAuthorizationRequest(provider);
|
|
467
458
|
},
|
|
468
|
-
exchangeCallback(request) {
|
|
469
|
-
|
|
459
|
+
async exchangeCallback(request) {
|
|
460
|
+
if (request.provider.kind === "oidc")
|
|
461
|
+
return interpretOidcLogin(
|
|
462
|
+
request.provider,
|
|
463
|
+
await oidc.exchangeCallback({ ...request, provider: request.provider })
|
|
464
|
+
);
|
|
465
|
+
const { claims } = await github.exchangeCallback({ ...request, provider: request.provider });
|
|
466
|
+
return { actor: actorFromClaims(request.provider, claims), oidcEvidence: null };
|
|
470
467
|
}
|
|
471
468
|
};
|
|
472
469
|
}
|
|
473
470
|
|
|
474
471
|
// src/auth/auth-service.ts
|
|
475
|
-
function pickDisplayName(claims, identity) {
|
|
476
|
-
for (const key of ["name", "preferred_username", "email"]) {
|
|
477
|
-
const value = claims[key];
|
|
478
|
-
if (typeof value === "string" && value.trim() !== "") {
|
|
479
|
-
return value;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
return identity;
|
|
483
|
-
}
|
|
484
|
-
function actorFromOidcClaims(input) {
|
|
485
|
-
const rawIdentity = input.claims[input.provider.identity_claim];
|
|
486
|
-
const identity = typeof rawIdentity === "string" ? rawIdentity.trim() : "";
|
|
487
|
-
if (identity === "") {
|
|
488
|
-
return null;
|
|
489
|
-
}
|
|
490
|
-
return {
|
|
491
|
-
id: `${input.provider.id}:${identity}`,
|
|
492
|
-
kind: "user",
|
|
493
|
-
provider: input.provider.id,
|
|
494
|
-
displayName: pickDisplayName(input.claims, identity)
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
472
|
var DEFAULT_AUTH_SWEEP_INTERVAL_MS = 5 * 60 * 1e3;
|
|
498
|
-
function consumeValidFlow(repos, cookieValue) {
|
|
499
|
-
const idHash = hashOpaqueToken(cookieValue);
|
|
500
|
-
const flow = repos.authLoginFlows.getValid(idHash);
|
|
501
|
-
if (flow) {
|
|
502
|
-
repos.authLoginFlows.delete(idHash);
|
|
503
|
-
}
|
|
504
|
-
return flow;
|
|
505
|
-
}
|
|
506
473
|
function createAuthService(input) {
|
|
507
474
|
const auth = resolveAuthConfig(input.config);
|
|
508
|
-
const authClient = input.
|
|
509
|
-
oidc: input.oidcClient ?? createOpenIdClient()
|
|
510
|
-
});
|
|
475
|
+
const authClient = createAuthClient({ oidc: input.oidcClient, github: input.githubClient });
|
|
511
476
|
const sweepExpiredAuthState = () => ({
|
|
512
477
|
sessions: input.repos.authSessions.deleteExpired(),
|
|
513
478
|
loginFlows: input.repos.authLoginFlows.deleteExpired()
|
|
514
479
|
});
|
|
515
480
|
sweepExpiredAuthState();
|
|
481
|
+
function resolveSessionRecord(cookieValue) {
|
|
482
|
+
if (!auth.enabled || !cookieValue) return null;
|
|
483
|
+
const idHash = hashOpaqueToken(cookieValue);
|
|
484
|
+
const session = input.repos.authSessions.getValid(idHash);
|
|
485
|
+
if (!session) return null;
|
|
486
|
+
if (isActorAllowedByConfig(session.actor, auth, session.oidcEvidence)) return session;
|
|
487
|
+
input.repos.authSessions.delete(idHash);
|
|
488
|
+
return null;
|
|
489
|
+
}
|
|
516
490
|
return {
|
|
517
491
|
config: auth,
|
|
518
492
|
apiTokens: createApiTokenService({
|
|
@@ -543,10 +517,12 @@ function createAuthService(input) {
|
|
|
543
517
|
if (!auth.enabled) {
|
|
544
518
|
throw new Error("Authentication is not enabled");
|
|
545
519
|
}
|
|
546
|
-
const
|
|
520
|
+
const flowHash = hashOpaqueToken(loginCookieValue);
|
|
521
|
+
const flow = input.repos.authLoginFlows.getValid(flowHash);
|
|
547
522
|
if (!flow) {
|
|
548
523
|
throw new Error("Login flow expired or was not found");
|
|
549
524
|
}
|
|
525
|
+
input.repos.authLoginFlows.delete(flowHash);
|
|
550
526
|
const provider = auth.providers.find((p) => p.id === flow.providerId) ?? null;
|
|
551
527
|
if (!provider) {
|
|
552
528
|
throw new Error("Login provider is no longer configured");
|
|
@@ -554,42 +530,45 @@ function createAuthService(input) {
|
|
|
554
530
|
if (callbackUrl.searchParams.get("state") !== flow.state) {
|
|
555
531
|
throw new Error("Invalid authentication state");
|
|
556
532
|
}
|
|
557
|
-
const
|
|
533
|
+
const { actor, oidcEvidence } = await authClient.exchangeCallback({
|
|
558
534
|
provider,
|
|
559
535
|
callbackUrl,
|
|
560
536
|
state: flow.state,
|
|
561
537
|
pkceVerifier: flow.pkceVerifier
|
|
562
538
|
});
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
throw new Error(`Authentication identity claim ${provider.identity_claim} was not present`);
|
|
566
|
-
}
|
|
567
|
-
if (!isActorAllowedByConfig(actor, auth)) {
|
|
568
|
-
throw new Error("Authenticated user is not allowlisted");
|
|
539
|
+
if (!isActorAllowedByConfig(actor, auth, oidcEvidence)) {
|
|
540
|
+
throw new Error("Authenticated user does not satisfy admission policy");
|
|
569
541
|
}
|
|
570
542
|
const sessionCookieValue = generateOpaqueToken();
|
|
571
543
|
const expiresAt = isoFromNow(auth.sessionTtlMs);
|
|
572
544
|
input.repos.authSessions.create({
|
|
573
545
|
idHash: hashOpaqueToken(sessionCookieValue),
|
|
574
546
|
actor,
|
|
547
|
+
oidcEvidence,
|
|
575
548
|
expiresAt
|
|
576
549
|
});
|
|
577
550
|
return { sessionCookieValue, actor, expiresAt };
|
|
578
551
|
},
|
|
579
552
|
resolveSession(cookieValue) {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
if (!
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
553
|
+
return resolveSessionRecord(cookieValue)?.actor ?? null;
|
|
554
|
+
},
|
|
555
|
+
tokenOwnerForSession(cookieValue) {
|
|
556
|
+
if (!auth.enabled)
|
|
557
|
+
return { kind: "anonymous", id: "anonymous", actor: ADMIN_ACTOR2, providerBinding: null };
|
|
558
|
+
const session = resolveSessionRecord(cookieValue);
|
|
559
|
+
if (!session) return null;
|
|
560
|
+
const provider = auth.providers.find((p) => p.id === session.actor.provider);
|
|
561
|
+
if (!provider) return null;
|
|
562
|
+
return {
|
|
563
|
+
kind: "user",
|
|
564
|
+
id: session.actor.id,
|
|
565
|
+
actor: session.actor,
|
|
566
|
+
providerBinding: tokenProviderBinding(provider),
|
|
567
|
+
oidcEvidence: session.oidcEvidence
|
|
568
|
+
};
|
|
569
|
+
},
|
|
570
|
+
userInformation(cookieValue) {
|
|
571
|
+
return resolveSessionRecord(cookieValue)?.oidcEvidence ?? null;
|
|
593
572
|
},
|
|
594
573
|
logout(cookieValue) {
|
|
595
574
|
if (cookieValue) {
|
|
@@ -1796,8 +1775,8 @@ function createExternalSourceService(deps) {
|
|
|
1796
1775
|
if (!processDef) {
|
|
1797
1776
|
return null;
|
|
1798
1777
|
}
|
|
1799
|
-
for (const [turnId,
|
|
1800
|
-
const turnDef =
|
|
1778
|
+
for (const [turnId, binding] of processDef.turns) {
|
|
1779
|
+
const turnDef = binding.definition;
|
|
1801
1780
|
if (turnDef.kind !== "external") {
|
|
1802
1781
|
for (const [externalActionId, action] of Object.entries(turnDef.externalActions ?? {})) {
|
|
1803
1782
|
if (getExternalActionArmingId({ turnId, externalActionId }) === armingId) {
|
|
@@ -10065,13 +10044,13 @@ var ResolveTurnWait = defineOperation({
|
|
|
10065
10044
|
if (input.nextStateJson !== void 0 && !["retry", "error"].includes(input.result))
|
|
10066
10045
|
applyProcessPatchField(writes, process2, "stateJson", input.nextStateJson);
|
|
10067
10046
|
if (input.result === "bind") {
|
|
10068
|
-
const
|
|
10069
|
-
if (!
|
|
10047
|
+
const binding = input.initialBinding;
|
|
10048
|
+
if (!binding?.projects.length || !wait.initialSelection || process2.currentExecution || deps.projects.listByInstance(process2.id).length || deps.turnStarts.listByInstance(process2.id).length || deps.turnRecords.listByInstance(process2.id).length)
|
|
10070
10049
|
return reject(
|
|
10071
10050
|
"startup_binding_unavailable",
|
|
10072
10051
|
"Initial bindings require a process without projects or execution history"
|
|
10073
10052
|
);
|
|
10074
|
-
if (Object.keys(
|
|
10053
|
+
if (Object.keys(binding.metadata ?? {}).some(
|
|
10075
10054
|
(key) => key === "turnWait" || Object.hasOwn(process2.metadata ?? {}, key)
|
|
10076
10055
|
))
|
|
10077
10056
|
return reject(
|
|
@@ -10085,15 +10064,15 @@ var ResolveTurnWait = defineOperation({
|
|
|
10085
10064
|
process2,
|
|
10086
10065
|
"paramsJson",
|
|
10087
10066
|
JSON.stringify(
|
|
10088
|
-
definition.paramsCodec.serialize(definition.paramsCodec.parse(
|
|
10067
|
+
definition.paramsCodec.serialize(definition.paramsCodec.parse(binding.params))
|
|
10089
10068
|
)
|
|
10090
10069
|
);
|
|
10091
10070
|
applyProcessPatchField(writes, process2, "metadata", {
|
|
10092
10071
|
...process2.metadata,
|
|
10093
|
-
...
|
|
10094
|
-
...
|
|
10072
|
+
...binding.metadata,
|
|
10073
|
+
...binding.settingsContext ? { settingsContext: binding.settingsContext } : {}
|
|
10095
10074
|
});
|
|
10096
|
-
writes.initialProjects =
|
|
10075
|
+
writes.initialProjects = binding.projects.map((project) => ({
|
|
10097
10076
|
...project,
|
|
10098
10077
|
instanceId: process2.id
|
|
10099
10078
|
}));
|
|
@@ -10108,7 +10087,7 @@ var ResolveTurnWait = defineOperation({
|
|
|
10108
10087
|
eventType: "initial_repositories_bound",
|
|
10109
10088
|
level: "info",
|
|
10110
10089
|
message: "Startup repository bindings resolved",
|
|
10111
|
-
data: { projectKeys:
|
|
10090
|
+
data: { projectKeys: binding.projects.map((p) => p.key) }
|
|
10112
10091
|
});
|
|
10113
10092
|
return accept({ writes });
|
|
10114
10093
|
}
|
|
@@ -11417,7 +11396,8 @@ async function reconcileProcessesOnStartup(deps) {
|
|
|
11417
11396
|
}
|
|
11418
11397
|
|
|
11419
11398
|
// src/process-launcher-registry.ts
|
|
11420
|
-
import {
|
|
11399
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
11400
|
+
import { buildProcessLaunchers, SafeLaunchPreparationError } from "@leitwerk-dev/process-sdk";
|
|
11421
11401
|
|
|
11422
11402
|
// src/process-launch-plan.ts
|
|
11423
11403
|
import {
|
|
@@ -11569,6 +11549,25 @@ function buildProcessLauncherRegistry(catalog, options = {}) {
|
|
|
11569
11549
|
launcher: result
|
|
11570
11550
|
};
|
|
11571
11551
|
}
|
|
11552
|
+
function resolveUiReadiness(launcherId, input) {
|
|
11553
|
+
const { ui } = requireUiLauncher(launcherId);
|
|
11554
|
+
try {
|
|
11555
|
+
return ui.readiness?.(input) ?? { status: "ready", issues: [] };
|
|
11556
|
+
} catch {
|
|
11557
|
+
const correlationId = randomUUID2();
|
|
11558
|
+
options.logger?.warn(`Launcher readiness failed; correlationId=${correlationId}`);
|
|
11559
|
+
return {
|
|
11560
|
+
status: "blocked",
|
|
11561
|
+
issues: [
|
|
11562
|
+
{
|
|
11563
|
+
code: "launcher_readiness_failed",
|
|
11564
|
+
summary: "Configuration readiness could not be checked.",
|
|
11565
|
+
remediation: `Ask an operator to inspect the server logs. Reference: ${correlationId}`
|
|
11566
|
+
}
|
|
11567
|
+
]
|
|
11568
|
+
};
|
|
11569
|
+
}
|
|
11570
|
+
}
|
|
11572
11571
|
const uiLaunchers = [...launchers.values()].filter((launcher) => launcher.definition.ui).map(
|
|
11573
11572
|
(launcher) => ({
|
|
11574
11573
|
id: launcher.definition.id,
|
|
@@ -11586,8 +11585,12 @@ function buildProcessLauncherRegistry(catalog, options = {}) {
|
|
|
11586
11585
|
).sort((a, b) => a.label.localeCompare(b.label));
|
|
11587
11586
|
return {
|
|
11588
11587
|
listUiLaunchers() {
|
|
11589
|
-
return uiLaunchers
|
|
11588
|
+
return uiLaunchers.map((launcher) => ({
|
|
11589
|
+
...launcher,
|
|
11590
|
+
...requireUiLauncher(launcher.id).ui.readiness ? { readiness: resolveUiReadiness(launcher.id, {}) } : {}
|
|
11591
|
+
}));
|
|
11590
11592
|
},
|
|
11593
|
+
resolveUiReadiness,
|
|
11591
11594
|
async resolveUiDefaults(launcherId, ctx = {}) {
|
|
11592
11595
|
const { launcher, ui } = requireUiLauncher(launcherId);
|
|
11593
11596
|
return await ui.resolveDefaults?.(createLauncherContext(launcher.processId, ctx)) ?? {};
|
|
@@ -11606,10 +11609,24 @@ function buildProcessLauncherRegistry(catalog, options = {}) {
|
|
|
11606
11609
|
},
|
|
11607
11610
|
resolvePreparationChecks(launcherId, input, launchConfig) {
|
|
11608
11611
|
const { ui } = requireUiLauncher(launcherId);
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11612
|
+
const checks = [...ui.preparationChecks?.(input, launchConfig) ?? []];
|
|
11613
|
+
if (ui.readiness) {
|
|
11614
|
+
checks.unshift({
|
|
11615
|
+
id: "launcher-readiness",
|
|
11616
|
+
label: "Check launcher configuration",
|
|
11617
|
+
async run() {
|
|
11618
|
+
const readiness = resolveUiReadiness(launcherId, input);
|
|
11619
|
+
if (readiness.status !== "ready") {
|
|
11620
|
+
const summary = readiness.issues.map((issue) => `${issue.summary} ${issue.remediation}`).join(" ");
|
|
11621
|
+
throw new SafeLaunchPreparationError(
|
|
11622
|
+
"Launcher configuration is incomplete",
|
|
11623
|
+
summary || "Complete launcher configuration before launching."
|
|
11624
|
+
);
|
|
11625
|
+
}
|
|
11626
|
+
}
|
|
11627
|
+
});
|
|
11628
|
+
}
|
|
11629
|
+
return validateLaunchPreparationChecks(checks, `Launcher '${launcherId}'`);
|
|
11613
11630
|
},
|
|
11614
11631
|
async resolveUiLauncher(launcherId, input, ctx = {}) {
|
|
11615
11632
|
return resolveUiLauncher(launcherId, input, ctx, false);
|
|
@@ -13015,7 +13032,7 @@ var RepositoryCredentialService = class {
|
|
|
13015
13032
|
};
|
|
13016
13033
|
|
|
13017
13034
|
// src/result-image-store.ts
|
|
13018
|
-
import { createHash as createHash2, randomUUID as
|
|
13035
|
+
import { createHash as createHash2, randomUUID as randomUUID3 } from "node:crypto";
|
|
13019
13036
|
import { mkdir, readdir, readFile as readFile2, rename, rm, writeFile } from "node:fs/promises";
|
|
13020
13037
|
import path2 from "node:path";
|
|
13021
13038
|
import {
|
|
@@ -13051,7 +13068,7 @@ var ResultImageStore = class {
|
|
|
13051
13068
|
const digest = createHash2("sha256").update(input.bytes).digest("hex");
|
|
13052
13069
|
const imageId = `img_${digest}.${EXTENSIONS[input.mimeType]}`;
|
|
13053
13070
|
const destination = path2.join(dir, imageId);
|
|
13054
|
-
const temporary = path2.join(dir, `.${imageId}.${
|
|
13071
|
+
const temporary = path2.join(dir, `.${imageId}.${randomUUID3()}.tmp`);
|
|
13055
13072
|
try {
|
|
13056
13073
|
await writeFile(temporary, input.bytes, { flag: "wx" });
|
|
13057
13074
|
await rename(temporary, destination);
|
|
@@ -13178,8 +13195,8 @@ function createScopedSettingsService(input) {
|
|
|
13178
13195
|
}
|
|
13179
13196
|
}
|
|
13180
13197
|
for (const process2 of catalog.processes.values())
|
|
13181
|
-
for (const
|
|
13182
|
-
const def =
|
|
13198
|
+
for (const binding of process2.turns.values()) {
|
|
13199
|
+
const def = binding.definition;
|
|
13183
13200
|
if (def.kind === "llm" && def.executionPurpose && !purposes.has(def.executionPurpose))
|
|
13184
13201
|
throw new Error(`Unknown execution purpose '${def.executionPurpose}'`);
|
|
13185
13202
|
}
|
|
@@ -13318,10 +13335,10 @@ function createScopedSettingsService(input) {
|
|
|
13318
13335
|
}
|
|
13319
13336
|
function repository(project) {
|
|
13320
13337
|
const locator = normalizeSettingsLocator(project.repoLocator);
|
|
13321
|
-
const
|
|
13322
|
-
if (
|
|
13323
|
-
const aliases = "aliases" in
|
|
13324
|
-
const identity = repositorySettingsIdentity(
|
|
13338
|
+
const binding = project.metadata?.settingsRepository;
|
|
13339
|
+
if (binding && typeof binding === "object" && "origin" in binding && "repositoryId" in binding && typeof binding.origin === "string" && (typeof binding.repositoryId === "string" || typeof binding.repositoryId === "number")) {
|
|
13340
|
+
const aliases = "aliases" in binding && Array.isArray(binding.aliases) ? binding.aliases.filter((alias) => typeof alias === "string") : [];
|
|
13341
|
+
const identity = repositorySettingsIdentity(binding.origin, binding.repositoryId);
|
|
13325
13342
|
const known2 = repos.scopedSettings.findIdentity("repository", identity);
|
|
13326
13343
|
return discover({
|
|
13327
13344
|
scopeType: "repository",
|
|
@@ -13680,7 +13697,7 @@ function createAppLifecycle(input) {
|
|
|
13680
13697
|
let closePromise;
|
|
13681
13698
|
let startupOperation;
|
|
13682
13699
|
let startupPromise;
|
|
13683
|
-
let
|
|
13700
|
+
let binding;
|
|
13684
13701
|
let bindOperation;
|
|
13685
13702
|
const cleanupErrors = [];
|
|
13686
13703
|
function assertOpen() {
|
|
@@ -13710,9 +13727,9 @@ function createAppLifecycle(input) {
|
|
|
13710
13727
|
}
|
|
13711
13728
|
async function listen(options = {}) {
|
|
13712
13729
|
assertOpen();
|
|
13713
|
-
if (
|
|
13730
|
+
if (binding) {
|
|
13714
13731
|
for (const key of ["host", "port", "useBoundAddressAsBaseUrl"]) {
|
|
13715
|
-
if (options[key] !== void 0 && options[key] !==
|
|
13732
|
+
if (options[key] !== void 0 && options[key] !== binding[key])
|
|
13716
13733
|
throw new Error(`Conflicting listener option: ${key}`);
|
|
13717
13734
|
}
|
|
13718
13735
|
} else {
|
|
@@ -13724,7 +13741,7 @@ function createAppLifecycle(input) {
|
|
|
13724
13741
|
};
|
|
13725
13742
|
if (requested.useBoundAddressAsBaseUrl && (input.authEnabled || !["127.0.0.1", "::1", "localhost"].includes(requested.host)))
|
|
13726
13743
|
throw new Error("Bound base URL requires an unauthenticated loopback listener");
|
|
13727
|
-
|
|
13744
|
+
binding = requested;
|
|
13728
13745
|
bindOperation = (async () => {
|
|
13729
13746
|
const started = performance.now();
|
|
13730
13747
|
const address = await app.listen({ host: requested.host, port: requested.port });
|
|
@@ -13944,9 +13961,11 @@ function registerApiTokenAudit(app) {
|
|
|
13944
13961
|
// src/auth/api-token-routes.ts
|
|
13945
13962
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
13946
13963
|
function registerApiTokenRoutes(app, auth) {
|
|
13964
|
+
const owners = /* @__PURE__ */ new WeakMap();
|
|
13947
13965
|
const ownerForRequest = (request) => {
|
|
13948
|
-
|
|
13949
|
-
|
|
13966
|
+
const owner = owners.get(request);
|
|
13967
|
+
if (!owner) throw new Error("Browser token owner is missing");
|
|
13968
|
+
return owner;
|
|
13950
13969
|
};
|
|
13951
13970
|
const csrfKey = generateOpaqueToken();
|
|
13952
13971
|
const anonymousCookie = `${auth.config.sessionCookieName}_token_csrf`;
|
|
@@ -13959,10 +13978,12 @@ function registerApiTokenRoutes(app, auth) {
|
|
|
13959
13978
|
request.tokenAudit = {
|
|
13960
13979
|
operation: request.method === "POST" ? "token_issuance" : request.routeOptions.url?.endsWith(":id") ? "token_revocation" : "token_revoke_all"
|
|
13961
13980
|
};
|
|
13962
|
-
const
|
|
13963
|
-
if (!
|
|
13964
|
-
|
|
13965
|
-
|
|
13981
|
+
const owner = hasAuthorization(request) ? null : auth.tokenOwnerForSession(request.cookies?.[auth.config.sessionCookieName]);
|
|
13982
|
+
if (!owner) return reply.code(401).send({ error: "Browser access required" });
|
|
13983
|
+
owners.set(request, owner);
|
|
13984
|
+
request.actor = owner.actor;
|
|
13985
|
+
if (request.tokenAudit)
|
|
13986
|
+
Object.assign(request.tokenAudit, { actor: owner.actor, ownerKind: owner.kind });
|
|
13966
13987
|
if (request.method === "GET") return;
|
|
13967
13988
|
const supplied = request.headers["x-csrf-token"];
|
|
13968
13989
|
const credential = credentialFor(request);
|
|
@@ -13998,11 +14019,7 @@ function registerApiTokenRoutes(app, auth) {
|
|
|
13998
14019
|
try {
|
|
13999
14020
|
const input = body;
|
|
14000
14021
|
const result = auth.apiTokens.create(ownerForRequest(request), input.name, input.expiresAt);
|
|
14001
|
-
request.tokenAudit =
|
|
14002
|
-
...request.tokenAudit,
|
|
14003
|
-
operation: "token_issuance",
|
|
14004
|
-
tokenId: result.token.id
|
|
14005
|
-
};
|
|
14022
|
+
if (request.tokenAudit) request.tokenAudit.tokenId = result.token.id;
|
|
14006
14023
|
return reply.code(201).send(result);
|
|
14007
14024
|
} catch (error) {
|
|
14008
14025
|
if (!(error instanceof ApiTokenValidationError)) throw error;
|
|
@@ -14014,17 +14031,13 @@ function registerApiTokenRoutes(app, auth) {
|
|
|
14014
14031
|
async (request, reply) => {
|
|
14015
14032
|
if (!auth.apiTokens.revoke(ownerForRequest(request), request.params.id))
|
|
14016
14033
|
return reply.code(404).send({ error: "Token not found" });
|
|
14017
|
-
request.tokenAudit =
|
|
14018
|
-
...request.tokenAudit,
|
|
14019
|
-
operation: "token_revocation",
|
|
14020
|
-
tokenId: request.params.id
|
|
14021
|
-
};
|
|
14034
|
+
if (request.tokenAudit) request.tokenAudit.tokenId = request.params.id;
|
|
14022
14035
|
return { ok: true };
|
|
14023
14036
|
}
|
|
14024
14037
|
);
|
|
14025
14038
|
management.delete("/api/auth/tokens", async (request) => {
|
|
14026
14039
|
const count = auth.apiTokens.revokeAll(ownerForRequest(request));
|
|
14027
|
-
request.tokenAudit
|
|
14040
|
+
if (request.tokenAudit) request.tokenAudit.count = count;
|
|
14028
14041
|
return { ok: true, count };
|
|
14029
14042
|
});
|
|
14030
14043
|
});
|
|
@@ -14045,12 +14058,26 @@ function cookieOptions(input) {
|
|
|
14045
14058
|
}
|
|
14046
14059
|
function registerAuthRoutes(app, auth) {
|
|
14047
14060
|
registerApiTokenRoutes(app, auth);
|
|
14061
|
+
app.get("/api/auth/user-information", async (request, reply) => {
|
|
14062
|
+
reply.header("Cache-Control", "no-store");
|
|
14063
|
+
if (hasAuthorization(request))
|
|
14064
|
+
return reply.code(401).send({ error: "Session access required" });
|
|
14065
|
+
const information = auth.userInformation(request.cookies?.[auth.config.sessionCookieName]);
|
|
14066
|
+
if (!information) return reply.code(401).send({ error: "OIDC session required" });
|
|
14067
|
+
return reply.send(information);
|
|
14068
|
+
});
|
|
14048
14069
|
app.get("/api/auth/me", async (request, reply) => {
|
|
14049
14070
|
const actor = authenticateRequest(auth, request);
|
|
14050
14071
|
if (!actor) {
|
|
14051
14072
|
return reply.code(401).send({ authEnabled: auth.config.enabled, actor: null });
|
|
14052
14073
|
}
|
|
14053
|
-
return reply.send({
|
|
14074
|
+
return reply.send({
|
|
14075
|
+
authEnabled: auth.config.enabled,
|
|
14076
|
+
actor,
|
|
14077
|
+
userInformationAvailable: !request.headers.authorization && auth.config.providers.some(
|
|
14078
|
+
(provider) => provider.kind === "oidc" && provider.id === actor.provider
|
|
14079
|
+
)
|
|
14080
|
+
});
|
|
14054
14081
|
});
|
|
14055
14082
|
app.get("/auth/login", async (_request, reply) => {
|
|
14056
14083
|
if (!auth.config.enabled) {
|
|
@@ -14067,8 +14094,8 @@ function registerAuthRoutes(app, auth) {
|
|
|
14067
14094
|
})
|
|
14068
14095
|
);
|
|
14069
14096
|
return reply.redirect(login.redirectUrl);
|
|
14070
|
-
} catch
|
|
14071
|
-
app.log.warn(
|
|
14097
|
+
} catch {
|
|
14098
|
+
app.log.warn("Failed to start OIDC login");
|
|
14072
14099
|
return reply.code(503).send({ error: "Login is temporarily unavailable" });
|
|
14073
14100
|
}
|
|
14074
14101
|
});
|
|
@@ -14095,8 +14122,8 @@ function registerAuthRoutes(app, auth) {
|
|
|
14095
14122
|
})
|
|
14096
14123
|
);
|
|
14097
14124
|
return reply.redirect("/");
|
|
14098
|
-
} catch
|
|
14099
|
-
app.log.warn(
|
|
14125
|
+
} catch {
|
|
14126
|
+
app.log.warn("Failed to complete OIDC login");
|
|
14100
14127
|
reply.clearCookie(auth.config.loginFlowCookieName, { path: "/" });
|
|
14101
14128
|
return reply.code(403).send({ error: "Login failed" });
|
|
14102
14129
|
}
|
|
@@ -14856,27 +14883,35 @@ function registerLauncherRoutes(app, deps, futureExecutionLifecycle) {
|
|
|
14856
14883
|
return body;
|
|
14857
14884
|
}
|
|
14858
14885
|
);
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
return sendLauncherRequestNormalizationError(reply, normalized.error);
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
);
|
|
14871
|
-
const body = { options };
|
|
14872
|
-
return body;
|
|
14873
|
-
} catch (error) {
|
|
14874
|
-
if (sendLauncherLookupFailure(reply, error)) {
|
|
14875
|
-
return;
|
|
14886
|
+
function postLauncherInput(path11, resolve) {
|
|
14887
|
+
app.post(
|
|
14888
|
+
`/api/launchers/:launcherId/${path11}`,
|
|
14889
|
+
async (req, reply) => {
|
|
14890
|
+
const normalized = normalizeLauncherRequest(req.body);
|
|
14891
|
+
if (!normalized.ok) return sendLauncherRequestNormalizationError(reply, normalized.error);
|
|
14892
|
+
try {
|
|
14893
|
+
return await resolve(req.params.launcherId, normalized.request.launcherInput);
|
|
14894
|
+
} catch (error) {
|
|
14895
|
+
if (sendLauncherLookupFailure(reply, error)) return;
|
|
14896
|
+
throw error;
|
|
14876
14897
|
}
|
|
14877
|
-
throw error;
|
|
14878
14898
|
}
|
|
14879
|
-
|
|
14899
|
+
);
|
|
14900
|
+
}
|
|
14901
|
+
postLauncherInput(
|
|
14902
|
+
"readiness",
|
|
14903
|
+
(launcherId, input) => ({
|
|
14904
|
+
readiness: deps.launcherService.resolveUiReadiness?.(launcherId, input) ?? {
|
|
14905
|
+
status: "ready",
|
|
14906
|
+
issues: []
|
|
14907
|
+
}
|
|
14908
|
+
})
|
|
14909
|
+
);
|
|
14910
|
+
postLauncherInput(
|
|
14911
|
+
"options",
|
|
14912
|
+
async (launcherId, input) => ({
|
|
14913
|
+
options: await deps.launcherService.resolveUiOptions(launcherId, input)
|
|
14914
|
+
})
|
|
14880
14915
|
);
|
|
14881
14916
|
app.post(
|
|
14882
14917
|
"/api/launchers/:launcherId/launch-runs",
|
|
@@ -17234,7 +17269,7 @@ function resolveServerTlsOptions(config, readFile6 = defaultFileReader) {
|
|
|
17234
17269
|
}
|
|
17235
17270
|
|
|
17236
17271
|
// src/session-transfer-helper-relays.ts
|
|
17237
|
-
import { randomBytes
|
|
17272
|
+
import { randomBytes } from "node:crypto";
|
|
17238
17273
|
import { PassThrough } from "node:stream";
|
|
17239
17274
|
import {
|
|
17240
17275
|
sessionTransferPreflightReportSchema
|
|
@@ -17282,7 +17317,7 @@ function createSessionTransferHelperRelays(deps) {
|
|
|
17282
17317
|
if (!attempt || attempt.state !== "queued" && attempt.state !== "exporting") {
|
|
17283
17318
|
throw new Error("No active session transfer can accept an export helper");
|
|
17284
17319
|
}
|
|
17285
|
-
const exportId2 = `exp_${
|
|
17320
|
+
const exportId2 = `exp_${randomBytes(16).toString("base64url")}`;
|
|
17286
17321
|
const credential = createOpaqueToken();
|
|
17287
17322
|
const runtime = {
|
|
17288
17323
|
attemptId: attempt.id,
|
|
@@ -18666,14 +18701,14 @@ function createIpcHandler(deps, callbacks) {
|
|
|
18666
18701
|
import { parseDurationMs as parseDurationMs4 } from "@leitwerk-dev/watcher-utils";
|
|
18667
18702
|
|
|
18668
18703
|
// src/supervisor/synthetic-worker-failure.ts
|
|
18669
|
-
import { randomUUID as
|
|
18704
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
18670
18705
|
import { createIpcMessage } from "@leitwerk-dev/worker-protocol";
|
|
18671
18706
|
function createServerObservedWorkerFailedMessage(input) {
|
|
18672
18707
|
return createIpcMessage({
|
|
18673
18708
|
type: "worker.failed",
|
|
18674
18709
|
instanceId: input.instanceId,
|
|
18675
18710
|
workerId: input.workerId,
|
|
18676
|
-
messageId:
|
|
18711
|
+
messageId: randomUUID4(),
|
|
18677
18712
|
payload: {
|
|
18678
18713
|
state: input.state ?? "absent",
|
|
18679
18714
|
errorCode: input.errorCode,
|
|
@@ -18775,7 +18810,7 @@ function startStaleHeartbeatWatchdog(deps) {
|
|
|
18775
18810
|
}
|
|
18776
18811
|
|
|
18777
18812
|
// src/supervisor/worker-supervisor.ts
|
|
18778
|
-
import { randomUUID as
|
|
18813
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
18779
18814
|
import {
|
|
18780
18815
|
parseResolvedExtensionEntries,
|
|
18781
18816
|
RUNTIME_EXTENSION_ALLOWED_ROOTS_ENV,
|
|
@@ -19153,7 +19188,7 @@ function createWorkerCapacityQueue(deps) {
|
|
|
19153
19188
|
}
|
|
19154
19189
|
|
|
19155
19190
|
// src/supervisor/worker-shutdown-controller.ts
|
|
19156
|
-
import { randomUUID as
|
|
19191
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
19157
19192
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
19158
19193
|
import { parseDurationMs as parseDurationMs5 } from "@leitwerk-dev/watcher-utils";
|
|
19159
19194
|
import { createIpcMessage as createIpcMessage2 } from "@leitwerk-dev/worker-protocol";
|
|
@@ -19185,7 +19220,7 @@ function createWorkerShutdownController(input) {
|
|
|
19185
19220
|
type: "worker.stop",
|
|
19186
19221
|
instanceId,
|
|
19187
19222
|
workerId: handle.workerId,
|
|
19188
|
-
messageId:
|
|
19223
|
+
messageId: randomUUID5(),
|
|
19189
19224
|
payload: { reason }
|
|
19190
19225
|
});
|
|
19191
19226
|
handle.send(msg);
|
|
@@ -19219,7 +19254,7 @@ function createWorkerShutdownController(input) {
|
|
|
19219
19254
|
}
|
|
19220
19255
|
|
|
19221
19256
|
// src/supervisor/worker-start-payload-builder.ts
|
|
19222
|
-
import { randomUUID as
|
|
19257
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
19223
19258
|
import path9 from "node:path";
|
|
19224
19259
|
import { parseProductRefsFromStateJsonLenient } from "@leitwerk-dev/domain";
|
|
19225
19260
|
import { parseDurationMs as parseDurationMs6 } from "@leitwerk-dev/watcher-utils";
|
|
@@ -19500,7 +19535,7 @@ function createWorkerStartPayloadBuilder(deps) {
|
|
|
19500
19535
|
type: "worker.start",
|
|
19501
19536
|
instanceId,
|
|
19502
19537
|
workerId,
|
|
19503
|
-
messageId:
|
|
19538
|
+
messageId: randomUUID6(),
|
|
19504
19539
|
payload
|
|
19505
19540
|
});
|
|
19506
19541
|
}
|
|
@@ -19905,7 +19940,7 @@ function createWorkerSupervisor(deps) {
|
|
|
19905
19940
|
worker.send(
|
|
19906
19941
|
createIpcMessage4({
|
|
19907
19942
|
...message,
|
|
19908
|
-
messageId:
|
|
19943
|
+
messageId: randomUUID7(),
|
|
19909
19944
|
instanceId,
|
|
19910
19945
|
workerId
|
|
19911
19946
|
})
|
|
@@ -20055,7 +20090,7 @@ function createWorkerSupervisor(deps) {
|
|
|
20055
20090
|
type: "input.batch",
|
|
20056
20091
|
instanceId,
|
|
20057
20092
|
workerId: handle.workerId,
|
|
20058
|
-
messageId:
|
|
20093
|
+
messageId: randomUUID7(),
|
|
20059
20094
|
payload: { inputs }
|
|
20060
20095
|
});
|
|
20061
20096
|
handle.send(msg);
|
|
@@ -20573,7 +20608,7 @@ function createWorkerSupervisor(deps) {
|
|
|
20573
20608
|
createIpcMessage4({
|
|
20574
20609
|
type: "worker.turn_terminal_recorded",
|
|
20575
20610
|
payload,
|
|
20576
|
-
messageId:
|
|
20611
|
+
messageId: randomUUID7(),
|
|
20577
20612
|
instanceId,
|
|
20578
20613
|
workerId
|
|
20579
20614
|
})
|
|
@@ -20763,7 +20798,7 @@ function createTurnWaitService(deps) {
|
|
|
20763
20798
|
complete: () => ({ kind: "complete" }),
|
|
20764
20799
|
waiting: (message2) => ({ kind: "waiting", message: message2 }),
|
|
20765
20800
|
abort: (message2) => ({ kind: "abort", message: message2 }),
|
|
20766
|
-
bindInitialProjects: (
|
|
20801
|
+
bindInitialProjects: (binding) => ({ kind: "bind", binding })
|
|
20767
20802
|
};
|
|
20768
20803
|
const timedOut = new Promise((_, reject2) => {
|
|
20769
20804
|
onAbort = () => reject2(new RetryableWaitError("Waiting condition interrupted"));
|
|
@@ -21161,6 +21196,7 @@ ${configErrors.join("\n")}`);
|
|
|
21161
21196
|
);
|
|
21162
21197
|
};
|
|
21163
21198
|
const launcherService = buildProcessLauncherRegistry(extensionCatalog, {
|
|
21199
|
+
logger: { warn: (message) => app.log.warn(message) },
|
|
21164
21200
|
modelProfiles: launcherModelProfiles,
|
|
21165
21201
|
commitMessages: config.commit_messages,
|
|
21166
21202
|
getModelProfilesForProcess
|
|
@@ -21906,8 +21942,8 @@ ${configErrors.join("\n")}`);
|
|
|
21906
21942
|
await polling.stop();
|
|
21907
21943
|
});
|
|
21908
21944
|
for (const process2 of extensionCatalog.processes.values()) {
|
|
21909
|
-
for (const [turnId,
|
|
21910
|
-
const definition =
|
|
21945
|
+
for (const [turnId, binding] of process2.turns) {
|
|
21946
|
+
const definition = binding.definition;
|
|
21911
21947
|
if (definition.kind !== "llm" || !definition.integrationTools?.length) continue;
|
|
21912
21948
|
try {
|
|
21913
21949
|
integrationTools.declarations(definition.integrationTools);
|
|
@@ -22015,4 +22051,4 @@ ${configErrors.join("\n")}`);
|
|
|
22015
22051
|
export {
|
|
22016
22052
|
createAppContext
|
|
22017
22053
|
};
|
|
22018
|
-
//# sourceMappingURL=chunk-
|
|
22054
|
+
//# sourceMappingURL=chunk-AJ2DQWI3.js.map
|