@leitwerk-dev/server 0.5.3 → 0.5.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-DZUsf76a.d.ts → app-DWWNqFtH.d.ts} +83 -77
- package/dist/app-VLQCV5WS.js +8 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/{chunk-6EEU4QOU.js → chunk-65CBLH7U.js} +350 -144
- package/dist/chunk-65CBLH7U.js.map +1 -0
- package/dist/chunk-C2K2AM5X.js +82 -0
- package/dist/chunk-C2K2AM5X.js.map +1 -0
- package/dist/{chunk-AJ2DQWI3.js → chunk-I3CCVPXY.js} +133 -83
- package/dist/chunk-I3CCVPXY.js.map +1 -0
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/dashboard-model-issues.d.ts.map +1 -1
- package/dist/deployment-preflight.d.ts +2 -1
- package/dist/deployment-preflight.d.ts.map +1 -1
- package/dist/extension-boot-check.d.ts +5 -0
- package/dist/extension-boot-check.d.ts.map +1 -0
- package/dist/future-execution/execution.d.ts.map +1 -1
- package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
- package/dist/future-execution/lifecycle.d.ts.map +1 -1
- package/dist/future-execution/reconciliation.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -3
- package/dist/index.js.map +1 -1
- package/dist/main.js +6 -71
- package/dist/main.js.map +1 -1
- package/dist/process-engine/ops/execute-action.d.ts.map +1 -1
- package/dist/process-engine/ops/retry-startup.d.ts.map +1 -1
- package/dist/process-engine/turn-start-preflight.d.ts.map +1 -1
- package/dist/process-model-config.d.ts.map +1 -1
- package/dist/process-model-policy/construct.d.ts +1 -0
- package/dist/process-model-policy/construct.d.ts.map +1 -1
- package/dist/process-model-policy/evaluate.d.ts +3 -3
- package/dist/process-model-policy/evaluate.d.ts.map +1 -1
- package/dist/process-model-policy/index.d.ts +1 -0
- package/dist/process-model-policy/index.d.ts.map +1 -1
- package/dist/process-model-policy/launch.d.ts.map +1 -1
- package/dist/process-model-policy/project.d.ts.map +1 -1
- package/dist/process-model-policy/requirements.d.ts +16 -0
- package/dist/process-model-policy/requirements.d.ts.map +1 -0
- package/dist/process-model-policy/types.d.ts +87 -75
- 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-model-selection.d.ts.map +1 -1
- package/dist/process-title-generator.d.ts +2 -0
- package/dist/process-title-generator.d.ts.map +1 -1
- package/dist/routes/process-actions.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/test-helpers/process-model-fixtures.d.ts +6 -0
- package/dist/test-helpers/process-model-fixtures.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +12 -12
- package/src/app.ts +21 -0
- package/src/config/config-loader.ts +5 -0
- package/src/dashboard-model-issues.ts +66 -5
- package/src/deployment-preflight.ts +15 -7
- package/src/extension-boot-check.ts +36 -0
- package/src/future-execution/execution.ts +3 -8
- package/src/future-execution/launch-lifecycle.ts +15 -10
- package/src/future-execution/lifecycle.ts +1 -0
- package/src/future-execution/reconciliation.ts +2 -34
- package/src/index.ts +1 -0
- package/src/launch-coordinator.ts +2 -2
- package/src/process-engine/ops/execute-action.ts +1 -0
- package/src/process-engine/ops/retry-startup.ts +10 -12
- package/src/process-engine/turn-start-preflight.ts +38 -15
- package/src/process-model-config.ts +7 -3
- package/src/process-model-policy/construct.ts +61 -3
- package/src/process-model-policy/evaluate.ts +73 -64
- package/src/process-model-policy/index.ts +16 -14
- package/src/process-model-policy/launch.ts +27 -29
- package/src/process-model-policy/project.ts +72 -43
- package/src/process-model-policy/requirements.ts +73 -0
- package/src/process-model-policy/types.ts +108 -78
- package/src/process-model-policy-presenter.ts +18 -2
- package/src/process-model-selection.ts +2 -0
- package/src/process-title-generator.ts +12 -16
- package/src/routes/launchers.ts +1 -1
- package/src/routes/process-actions.ts +1 -0
- package/src/supervisor/worker-start-payload-builder.ts +6 -1
- package/src/test-helpers/process-model-fixtures.ts +25 -4
- package/dist/app-2TCRADVA.js +0 -8
- package/dist/chunk-6EEU4QOU.js.map +0 -1
- package/dist/chunk-AJ2DQWI3.js.map +0 -1
- /package/dist/{app-2TCRADVA.js.map → app-VLQCV5WS.js.map} +0 -0
|
@@ -8,20 +8,19 @@ import type {
|
|
|
8
8
|
TurnStartRecord,
|
|
9
9
|
} from "@leitwerk-dev/domain";
|
|
10
10
|
import type { LaunchPlanPreparationResultLike, ProcessLaunchPlan } from "@leitwerk-dev/process-sdk";
|
|
11
|
+
import type {
|
|
12
|
+
LauncherModelConfigSchema,
|
|
13
|
+
ProcessModelConfigurationView,
|
|
14
|
+
} from "@leitwerk-dev/protocol/http-contracts";
|
|
11
15
|
import type { ModelStatusCacheSnapshot } from "../model-providers/model-status-cache.js";
|
|
12
16
|
|
|
13
17
|
/** @internal */
|
|
14
18
|
export type ProcessModelAvailabilitySnapshot = ModelStatusCacheSnapshot;
|
|
15
19
|
|
|
16
20
|
/** @internal */
|
|
17
|
-
export type PersistedModelConfigurationIssue =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/** @internal */
|
|
21
|
-
readonly reason: "invalid_json" | "not_object" | "turn_config_not_object";
|
|
22
|
-
/** @internal */
|
|
23
|
-
readonly turnId?: string;
|
|
24
|
-
};
|
|
21
|
+
export type PersistedModelConfigurationIssue = Readonly<
|
|
22
|
+
Extract<ProcessModelConfigurationView["state"], { kind: "blocked" }>["issues"][number]
|
|
23
|
+
>;
|
|
25
24
|
|
|
26
25
|
export interface ValidModelConfiguration {
|
|
27
26
|
readonly kind: "valid";
|
|
@@ -121,6 +120,10 @@ export type ModelOverride =
|
|
|
121
120
|
|
|
122
121
|
/** @internal */
|
|
123
122
|
type ProcessModelPolicyFailureBase = {
|
|
123
|
+
/** @internal */
|
|
124
|
+
readonly ranking?: ModelRankingEvidence;
|
|
125
|
+
/** @internal */
|
|
126
|
+
readonly skippedPreferences?: readonly SkippedModelPreference[];
|
|
124
127
|
/** @internal */
|
|
125
128
|
readonly ok: false;
|
|
126
129
|
/** @internal */
|
|
@@ -135,6 +138,8 @@ export type ProcessModelPolicyFailure = ProcessModelPolicyFailureBase &
|
|
|
135
138
|
| {
|
|
136
139
|
/** @internal */
|
|
137
140
|
readonly code: "model_required";
|
|
141
|
+
/** Effective hard constraints when no eligible model exists. @internal */
|
|
142
|
+
readonly requirements?: readonly PolicyRequirementLayer[];
|
|
138
143
|
}
|
|
139
144
|
| {
|
|
140
145
|
/** @internal */
|
|
@@ -149,6 +154,8 @@ export type ProcessModelPolicyFailure = ProcessModelPolicyFailureBase &
|
|
|
149
154
|
readonly modelProfileId: string;
|
|
150
155
|
/** @internal */
|
|
151
156
|
readonly processId: string;
|
|
157
|
+
/** @internal */
|
|
158
|
+
readonly rejections?: readonly ModelRequirementRejection[];
|
|
152
159
|
}
|
|
153
160
|
| {
|
|
154
161
|
/** @internal */
|
|
@@ -176,6 +183,10 @@ export type ProcessModelPolicyFailure = ProcessModelPolicyFailureBase &
|
|
|
176
183
|
);
|
|
177
184
|
/** @internal */
|
|
178
185
|
export interface ProcessModelPolicyResolution {
|
|
186
|
+
/** @internal */
|
|
187
|
+
readonly ranking?: ModelRankingEvidence;
|
|
188
|
+
/** @internal */
|
|
189
|
+
readonly skippedPreferences?: readonly SkippedModelPreference[];
|
|
179
190
|
/** @internal */
|
|
180
191
|
readonly ok: true;
|
|
181
192
|
/** @internal */
|
|
@@ -188,6 +199,8 @@ export type ProcessModelPolicyEvaluation = ProcessModelPolicyResolution | Proces
|
|
|
188
199
|
|
|
189
200
|
/** @internal */
|
|
190
201
|
export interface ProjectedModelProfile {
|
|
202
|
+
/** Independent of cached availability. @internal */
|
|
203
|
+
readonly policyReason?: string;
|
|
191
204
|
/** @internal */
|
|
192
205
|
readonly id: string;
|
|
193
206
|
/** @internal */
|
|
@@ -197,6 +210,10 @@ export interface ProjectedModelProfile {
|
|
|
197
210
|
/** @internal */
|
|
198
211
|
readonly thinkingLevel: string;
|
|
199
212
|
/** @internal */
|
|
213
|
+
readonly labels?: readonly string[];
|
|
214
|
+
/** @internal */
|
|
215
|
+
readonly default?: boolean;
|
|
216
|
+
/** @internal */
|
|
200
217
|
readonly availability: "available" | "unavailable" | "stale";
|
|
201
218
|
/** @internal */
|
|
202
219
|
readonly safeReason: string | null;
|
|
@@ -205,31 +222,21 @@ export interface ProjectedModelProfile {
|
|
|
205
222
|
}
|
|
206
223
|
|
|
207
224
|
/** @internal */
|
|
208
|
-
export
|
|
209
|
-
/** @internal */
|
|
210
|
-
readonly processConfigModelProfileId: string | null;
|
|
211
|
-
/** @internal */
|
|
212
|
-
readonly instanceModelProfileId: string | null;
|
|
213
|
-
/** @internal */
|
|
214
|
-
readonly effectiveModelProfileId: string | null;
|
|
215
|
-
/** @internal */
|
|
216
|
-
readonly source: "instance" | "process_config" | "catalog_default" | "none";
|
|
217
|
-
}
|
|
225
|
+
export type ProjectedModelDefault = Readonly<ProcessModelConfigurationView["defaultModel"]>;
|
|
218
226
|
|
|
219
227
|
/** @internal */
|
|
220
228
|
export type ProjectedModelResolutionSource = ProcessSelectedTurnModelSource | "none";
|
|
221
229
|
|
|
222
230
|
/** @internal */
|
|
223
231
|
export interface ProjectedLauncherModelSchema {
|
|
232
|
+
/** Excluded candidates with policy origins, keyed by turn; empty key denotes the process preference. @internal */
|
|
233
|
+
readonly excludedProfiles?: Readonly<Record<string, readonly ProjectedModelProfile[]>>;
|
|
234
|
+
/** @internal */
|
|
235
|
+
readonly profilesByTurn?: Readonly<Record<string, readonly ProjectedModelProfile[]>>;
|
|
224
236
|
/** @internal */
|
|
225
237
|
readonly profiles: readonly ProjectedModelProfile[];
|
|
226
238
|
/** @internal */
|
|
227
|
-
readonly turns:
|
|
228
|
-
/** @internal */
|
|
229
|
-
readonly turnId: string;
|
|
230
|
-
/** @internal */
|
|
231
|
-
readonly description: string;
|
|
232
|
-
}[];
|
|
239
|
+
readonly turns: LauncherModelConfigSchema["llmTurns"];
|
|
233
240
|
}
|
|
234
241
|
|
|
235
242
|
/** @internal */
|
|
@@ -249,6 +256,10 @@ export interface ProjectedLauncherModelPreview {
|
|
|
249
256
|
readonly description: string;
|
|
250
257
|
/** @internal */
|
|
251
258
|
readonly effective: {
|
|
259
|
+
/** @internal */
|
|
260
|
+
readonly explanation?: string;
|
|
261
|
+
/** @internal */
|
|
262
|
+
readonly ranking?: ModelRankingEvidence;
|
|
252
263
|
/** @internal */
|
|
253
264
|
readonly error?: string;
|
|
254
265
|
/** @internal */
|
|
@@ -260,60 +271,27 @@ export interface ProjectedLauncherModelPreview {
|
|
|
260
271
|
}
|
|
261
272
|
|
|
262
273
|
/** @internal */
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
/** @internal */
|
|
274
|
-
readonly issues: readonly PersistedModelConfigurationIssue[];
|
|
275
|
-
};
|
|
276
|
-
/** @internal */
|
|
277
|
-
readonly profiles: readonly ProjectedModelProfile[];
|
|
278
|
-
/** @internal */
|
|
279
|
-
readonly effectiveSelectedTurn: {
|
|
280
|
-
/** @internal */
|
|
281
|
-
readonly turnId: string;
|
|
282
|
-
/** @internal */
|
|
283
|
-
readonly description: string;
|
|
284
|
-
/** @internal */
|
|
285
|
-
readonly modelProfileId: string;
|
|
286
|
-
/** @internal */
|
|
287
|
-
readonly source: ProcessSelectedTurnModelSource;
|
|
288
|
-
} | null;
|
|
289
|
-
/** @internal */
|
|
290
|
-
readonly defaultModel: ProjectedModelDefault;
|
|
291
|
-
/** @internal */
|
|
292
|
-
readonly turns: readonly {
|
|
293
|
-
/** @internal */
|
|
294
|
-
readonly turnId: string;
|
|
295
|
-
/** @internal */
|
|
296
|
-
readonly description: string;
|
|
297
|
-
/** @internal */
|
|
298
|
-
readonly pathType: string;
|
|
299
|
-
/** @internal */
|
|
300
|
-
readonly processConfigModelProfileId: string | null;
|
|
301
|
-
/** @internal */
|
|
302
|
-
readonly instanceModelProfileId: string | null;
|
|
303
|
-
/** @internal */
|
|
304
|
-
readonly effectiveConfiguredModelProfileId: string | null;
|
|
305
|
-
/** @internal */
|
|
306
|
-
readonly fixedModelProfileId: string | null;
|
|
307
|
-
/** @internal */
|
|
308
|
-
readonly effectiveModelProfileId: string | null;
|
|
309
|
-
/** @internal */
|
|
310
|
-
readonly effectiveSource: ProcessSelectedTurnModelSource | "none";
|
|
311
|
-
/** @internal */
|
|
312
|
-
readonly effectiveError?: string;
|
|
274
|
+
type ProjectedTurnModelConfiguration = Readonly<ProcessModelConfigurationView["turns"][number]>;
|
|
275
|
+
|
|
276
|
+
/** @internal */
|
|
277
|
+
export type ProjectedProcessModelConfiguration = Readonly<
|
|
278
|
+
Omit<
|
|
279
|
+
ProcessModelConfigurationView,
|
|
280
|
+
"availableProfiles" | "profilesByTurn" | "excludedProfiles" | "turns"
|
|
281
|
+
>
|
|
282
|
+
> &
|
|
283
|
+
Pick<ProjectedLauncherModelSchema, "profiles" | "profilesByTurn" | "excludedProfiles"> & {
|
|
313
284
|
/** @internal */
|
|
314
|
-
readonly
|
|
315
|
-
|
|
316
|
-
|
|
285
|
+
readonly turns: readonly Readonly<
|
|
286
|
+
ProjectedTurnModelConfiguration &
|
|
287
|
+
Required<
|
|
288
|
+
Pick<
|
|
289
|
+
ProjectedTurnModelConfiguration,
|
|
290
|
+
"fixedModelProfileId" | "effectiveModelProfileId" | "effectiveSource"
|
|
291
|
+
>
|
|
292
|
+
>
|
|
293
|
+
>[];
|
|
294
|
+
};
|
|
317
295
|
|
|
318
296
|
/** @internal */
|
|
319
297
|
export interface ProcessModelPolicyProjectionByKind {
|
|
@@ -360,6 +338,8 @@ export type ProcessModelPolicyEvaluationSubject =
|
|
|
360
338
|
| {
|
|
361
339
|
/** @internal */
|
|
362
340
|
readonly kind: "runtime_selection";
|
|
341
|
+
/** Explicit validation scope. @internal */
|
|
342
|
+
readonly target: ModelPolicyTarget;
|
|
363
343
|
/** @internal */
|
|
364
344
|
readonly processId: string;
|
|
365
345
|
/** @internal */
|
|
@@ -386,6 +366,8 @@ export type ProcessModelPolicyProjectionSubject =
|
|
|
386
366
|
/** @internal */
|
|
387
367
|
readonly kind: "profile_options";
|
|
388
368
|
/** @internal */
|
|
369
|
+
readonly target: ModelPolicyTarget;
|
|
370
|
+
/** @internal */
|
|
389
371
|
readonly processId: string;
|
|
390
372
|
/** @internal */
|
|
391
373
|
readonly availability: ProcessModelAvailabilitySnapshot;
|
|
@@ -394,6 +376,8 @@ export type ProcessModelPolicyProjectionSubject =
|
|
|
394
376
|
/** @internal */
|
|
395
377
|
readonly kind: "compatible_profiles";
|
|
396
378
|
/** @internal */
|
|
379
|
+
readonly target: ModelPolicyTarget;
|
|
380
|
+
/** @internal */
|
|
397
381
|
readonly processId: string;
|
|
398
382
|
/** @internal */
|
|
399
383
|
readonly providerId: string;
|
|
@@ -458,7 +442,7 @@ export interface PrepareLaunchPlanOptions {
|
|
|
458
442
|
/** @internal */
|
|
459
443
|
readonly replaceModelConfig?: boolean;
|
|
460
444
|
/** @internal */
|
|
461
|
-
readonly invalidModelConfig?: "reject" | "
|
|
445
|
+
readonly invalidModelConfig?: "reject" | "retain";
|
|
462
446
|
}
|
|
463
447
|
|
|
464
448
|
/** @internal */
|
|
@@ -479,14 +463,60 @@ export interface ServerProcessModelPolicy {
|
|
|
479
463
|
/** @internal */
|
|
480
464
|
fingerprint(request: ProcessModelPolicyFingerprintSubject): string;
|
|
481
465
|
}
|
|
466
|
+
/** @internal */
|
|
467
|
+
export type ModelPolicyTarget =
|
|
468
|
+
| {
|
|
469
|
+
/** @internal */
|
|
470
|
+
readonly kind: "process_default";
|
|
471
|
+
}
|
|
472
|
+
| {
|
|
473
|
+
/** @internal */
|
|
474
|
+
readonly kind: "turn";
|
|
475
|
+
/** @internal */
|
|
476
|
+
readonly turnId: string;
|
|
477
|
+
};
|
|
478
|
+
/** @internal */
|
|
479
|
+
export interface ModelRankingEvidence {
|
|
480
|
+
/** @internal */
|
|
481
|
+
readonly kind: "marked_defaults" | "cost_id";
|
|
482
|
+
/** Equal-specificity marked defaults; ordered by the actual cost/ID tie-break. @internal */
|
|
483
|
+
readonly tiedProfileIds: readonly string[];
|
|
484
|
+
}
|
|
485
|
+
/** @internal */
|
|
486
|
+
export interface SkippedModelPreference {
|
|
487
|
+
/** @internal */
|
|
488
|
+
readonly profileId: string;
|
|
489
|
+
/** @internal */
|
|
490
|
+
readonly source: ProcessSelectedTurnModelSource;
|
|
491
|
+
/** @internal */
|
|
492
|
+
readonly rejections: readonly ModelRequirementRejection[];
|
|
493
|
+
}
|
|
494
|
+
/** @internal */
|
|
495
|
+
export interface ModelRequirementRejection {
|
|
496
|
+
/** @internal */ readonly origin: string;
|
|
497
|
+
/** @internal */ readonly code: string;
|
|
498
|
+
/** @internal */ readonly values: readonly string[];
|
|
499
|
+
}
|
|
482
500
|
export interface PolicyProfile {
|
|
501
|
+
readonly labels: readonly string[];
|
|
502
|
+
readonly default: boolean;
|
|
503
|
+
readonly capabilities: Readonly<Record<string, boolean | "unknown">>;
|
|
483
504
|
readonly id: string;
|
|
484
505
|
readonly provider: string;
|
|
485
506
|
readonly modelId: string;
|
|
486
507
|
readonly thinkingLevel: string;
|
|
487
508
|
readonly providerOptions: Readonly<Record<string, unknown>>;
|
|
488
509
|
}
|
|
510
|
+
/** @internal */
|
|
511
|
+
export interface PolicyRequirementLayer {
|
|
512
|
+
/** @internal */
|
|
513
|
+
readonly origin: string;
|
|
514
|
+
/** @internal */
|
|
515
|
+
readonly requirements: import("@leitwerk-dev/protocol").ModelRequirements;
|
|
516
|
+
}
|
|
489
517
|
export interface PolicyProcess {
|
|
518
|
+
readonly requirements: readonly PolicyRequirementLayer[];
|
|
519
|
+
readonly turnRequirements: Readonly<Record<string, readonly PolicyRequirementLayer[]>>;
|
|
490
520
|
readonly id: string;
|
|
491
521
|
readonly allowedProfileIds: ReadonlySet<string> | null;
|
|
492
522
|
readonly defaultProfileId: string | null;
|
|
@@ -27,11 +27,11 @@ export function presentLaunchPlanPreparationIssues(
|
|
|
27
27
|
export function presentProcessModelPolicyFailure(failure: ProcessModelPolicyFailure): string {
|
|
28
28
|
switch (failure.code) {
|
|
29
29
|
case "model_required":
|
|
30
|
-
return
|
|
30
|
+
return `No model satisfies this turn's requirements${failure.requirements?.length ? `: ${failure.requirements.map((layer) => `${layer.origin} ${JSON.stringify(layer.requirements)}`).join("; ")}` : ""}`;
|
|
31
31
|
case "unknown_model_profile":
|
|
32
32
|
return `Unknown model profile '${failure.modelProfileId}'`;
|
|
33
33
|
case "model_profile_not_allowed":
|
|
34
|
-
return `Model profile '${failure.modelProfileId}' is not allowed for process '${failure.processId}'`;
|
|
34
|
+
return `Model profile '${failure.modelProfileId}' is not allowed for process '${failure.processId}'${failure.rejections?.length ? `: ${failure.rejections.map((r) => `${r.code} (${r.values.join(", ")}) from ${r.origin}`).join("; ")}` : ""}`;
|
|
35
35
|
case "model_stale":
|
|
36
36
|
return failure.reason ?? "Model status has not been refreshed";
|
|
37
37
|
case "model_unavailable":
|
|
@@ -54,6 +54,9 @@ export function presentModelProfileOption(
|
|
|
54
54
|
const thinkingLevel = profile.thinkingLevel.trim();
|
|
55
55
|
return {
|
|
56
56
|
id: profile.id,
|
|
57
|
+
...(profile.policyReason ? { policyReason: profile.policyReason } : {}),
|
|
58
|
+
labels: profile.labels ?? [],
|
|
59
|
+
default: profile.default ?? false,
|
|
57
60
|
label: `${profile.id} — ${profile.providerId}/${profile.modelId}`,
|
|
58
61
|
description:
|
|
59
62
|
thinkingLevel && thinkingLevel.toLowerCase() !== "off"
|
|
@@ -65,11 +68,21 @@ export function presentModelProfileOption(
|
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
|
|
71
|
+
function presentProfileMap(
|
|
72
|
+
profiles: Readonly<Record<string, readonly ProjectedModelProfile[]>> = {},
|
|
73
|
+
) {
|
|
74
|
+
return Object.fromEntries(
|
|
75
|
+
Object.entries(profiles).map(([id, options]) => [id, options.map(presentModelProfileOption)]),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
68
79
|
export function presentLauncherModelConfigSchema(
|
|
69
80
|
projection: ProjectedLauncherModelSchema,
|
|
70
81
|
): LauncherModelConfigSchema {
|
|
71
82
|
return {
|
|
72
83
|
availableProfiles: projection.profiles.map(presentModelProfileOption),
|
|
84
|
+
profilesByTurn: presentProfileMap(projection.profilesByTurn),
|
|
85
|
+
excludedProfiles: presentProfileMap(projection.excludedProfiles),
|
|
73
86
|
llmTurns: projection.turns.map((turn) => ({ ...turn })),
|
|
74
87
|
};
|
|
75
88
|
}
|
|
@@ -93,6 +106,7 @@ export function presentLauncherModelConfigPreview(
|
|
|
93
106
|
turnId: turn.turnId,
|
|
94
107
|
description: turn.description,
|
|
95
108
|
effective: {
|
|
109
|
+
...(turn.effective.explanation ? { explanation: turn.effective.explanation } : {}),
|
|
96
110
|
...(turn.effective.error ? { error: turn.effective.error } : {}),
|
|
97
111
|
source: turn.effective.source,
|
|
98
112
|
profile: turn.effective.profile ? presentModelProfileOption(turn.effective.profile) : null,
|
|
@@ -106,6 +120,8 @@ export function presentProcessModelConfiguration(
|
|
|
106
120
|
): ProcessModelConfigurationView {
|
|
107
121
|
return {
|
|
108
122
|
state: projection.state,
|
|
123
|
+
excludedProfiles: presentProfileMap(projection.excludedProfiles),
|
|
124
|
+
profilesByTurn: presentProfileMap(projection.profilesByTurn),
|
|
109
125
|
availableProfiles: projection.profiles.map(presentModelProfileOption),
|
|
110
126
|
effectiveSelectedTurn: projection.effectiveSelectedTurn,
|
|
111
127
|
defaultModel: projection.defaultModel,
|
|
@@ -43,6 +43,7 @@ export function createProcessModelSelection(
|
|
|
43
43
|
return deps.processModelPolicy
|
|
44
44
|
.project({
|
|
45
45
|
kind: "profile_options",
|
|
46
|
+
target: { kind: "process_default" },
|
|
46
47
|
processId: process.processId,
|
|
47
48
|
availability: deps.modelStatusCache.snapshot(),
|
|
48
49
|
})
|
|
@@ -114,6 +115,7 @@ export function createProcessModelSelection(
|
|
|
114
115
|
resolveCompatibleModelProfileIds: (providerId, modelId) =>
|
|
115
116
|
deps.processModelPolicy.project({
|
|
116
117
|
kind: "compatible_profiles",
|
|
118
|
+
target: { kind: "turn", turnId },
|
|
117
119
|
availability,
|
|
118
120
|
processId: process.processId,
|
|
119
121
|
providerId,
|
|
@@ -263,15 +263,6 @@ function normalizeLaunchPlanTitle(launchPlan: ProcessLaunchPlan): ProcessLaunchP
|
|
|
263
263
|
);
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
function isTitleModelAllowedForProcess(
|
|
267
|
-
config: LeitwerkConfig,
|
|
268
|
-
processId: string,
|
|
269
|
-
modelProfileId: string,
|
|
270
|
-
): boolean {
|
|
271
|
-
const allowedProfiles = config.process_configs?.[processId]?.allowed_model_profiles;
|
|
272
|
-
return !allowedProfiles || allowedProfiles.includes(modelProfileId);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
266
|
function collectProcessTitleRuntimeDiagnostics(
|
|
276
267
|
services: AgentSessionServices,
|
|
277
268
|
): ProcessTitleRuntimeDiagnosticSummary[] {
|
|
@@ -443,6 +434,7 @@ class DefaultProcessTitleGenerator implements ProcessTitleGenerator {
|
|
|
443
434
|
private readonly extensionHost?: ExtensionHost,
|
|
444
435
|
private readonly futureExecutionTitleApplier?: FutureExecutionTitleApplier,
|
|
445
436
|
private readonly getLaunchCoordinator?: () => LaunchCoordinator | undefined,
|
|
437
|
+
private readonly modelPolicyError?: (processId: string, profileId: string) => string | null,
|
|
446
438
|
) {
|
|
447
439
|
this.configuredProfileId = trimToNull(config.pi.process_title_generation.model_profile);
|
|
448
440
|
this.retryPolicy = buildProcessTitleRetryPolicy(config);
|
|
@@ -535,13 +527,12 @@ class DefaultProcessTitleGenerator implements ProcessTitleGenerator {
|
|
|
535
527
|
if (normalizedLaunchPlan.processInput.title || !this.configuredProfileId) {
|
|
536
528
|
return null;
|
|
537
529
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
this.configuredProfileId
|
|
543
|
-
|
|
544
|
-
) {
|
|
530
|
+
const policyError = this.modelPolicyError
|
|
531
|
+
? this.modelPolicyError(normalizedLaunchPlan.processId, this.configuredProfileId)
|
|
532
|
+
: this.config.process_configs?.[
|
|
533
|
+
normalizedLaunchPlan.processId
|
|
534
|
+
]?.allowed_model_profiles?.includes(this.configuredProfileId) === false;
|
|
535
|
+
if (policyError) {
|
|
545
536
|
this.logger?.warn(
|
|
546
537
|
"Skipping process title generation because the configured model profile is not allowed for this process",
|
|
547
538
|
{
|
|
@@ -780,6 +771,8 @@ class DefaultProcessTitleGenerator implements ProcessTitleGenerator {
|
|
|
780
771
|
}
|
|
781
772
|
|
|
782
773
|
private async generateTitle(job: ProcessTitleJob): Promise<GeneratedTitleAttemptResult> {
|
|
774
|
+
const policyError = this.modelPolicyError?.(job.processDefinitionId, job.modelProfileId);
|
|
775
|
+
if (policyError) return { ok: false, error: policyError };
|
|
783
776
|
const configuredProfile = this.config.pi.model_profiles.find(
|
|
784
777
|
(profile) => profile.id === job.modelProfileId,
|
|
785
778
|
);
|
|
@@ -909,6 +902,8 @@ export function createProcessTitleGenerator(options: {
|
|
|
909
902
|
futureExecutionTitleApplier?: FutureExecutionTitleApplier;
|
|
910
903
|
/** @internal */
|
|
911
904
|
getLaunchCoordinator?: () => LaunchCoordinator | undefined;
|
|
905
|
+
/** Fixed title profile validation at queue and dispatch. @internal */
|
|
906
|
+
modelPolicyError?: (processId: string, profileId: string) => string | null;
|
|
912
907
|
}): ProcessTitleGenerator {
|
|
913
908
|
const runtime = { ...createDefaultRuntimeDeps(), ...options.runtime };
|
|
914
909
|
return new DefaultProcessTitleGenerator(
|
|
@@ -920,5 +915,6 @@ export function createProcessTitleGenerator(options: {
|
|
|
920
915
|
options.extensionHost,
|
|
921
916
|
options.futureExecutionTitleApplier,
|
|
922
917
|
options.getLaunchCoordinator,
|
|
918
|
+
options.modelPolicyError,
|
|
923
919
|
);
|
|
924
920
|
}
|
package/src/routes/launchers.ts
CHANGED
|
@@ -67,7 +67,7 @@ export function registerLauncherRoutes(
|
|
|
67
67
|
title = resolved.launcher.launchPlan.processInput.title ?? null;
|
|
68
68
|
const preparedLaunchPlan = await deps.launchPlans.prepare(
|
|
69
69
|
resolved.launcher.launchPlan,
|
|
70
|
-
{ invalidModelConfig: "
|
|
70
|
+
{ invalidModelConfig: "retain" },
|
|
71
71
|
);
|
|
72
72
|
if (!preparedLaunchPlan.ok) {
|
|
73
73
|
warnings.push(...presentLaunchPlanPreparationIssues(preparedLaunchPlan.errors));
|
|
@@ -40,6 +40,7 @@ export function registerProcessActionRoutes(
|
|
|
40
40
|
);
|
|
41
41
|
const profiles = deps.processModelPolicy.project({
|
|
42
42
|
kind: "profile_options",
|
|
43
|
+
target: { kind: "process_default" },
|
|
43
44
|
processId: process.processId,
|
|
44
45
|
availability: deps.modelStatusCache.snapshot(),
|
|
45
46
|
});
|
|
@@ -104,7 +104,12 @@ export function buildWorkerConfigSnapshot(config: LeitwerkConfig): ConfigSnapsho
|
|
|
104
104
|
);
|
|
105
105
|
return {
|
|
106
106
|
workers: buildWorkerRuntimeSettingsSnapshot(config),
|
|
107
|
-
pi:
|
|
107
|
+
pi: {
|
|
108
|
+
...config.pi,
|
|
109
|
+
model_profiles: config.pi.model_profiles.map(
|
|
110
|
+
({ labels: _labels, default: _default, ...profile }) => profile,
|
|
111
|
+
),
|
|
112
|
+
},
|
|
108
113
|
...(Object.keys(processConfigs).length > 0 ? { process_configs: processConfigs } : {}),
|
|
109
114
|
};
|
|
110
115
|
}
|
|
@@ -118,6 +118,8 @@ export function createTestModelPolicy(
|
|
|
118
118
|
profiles?: readonly {
|
|
119
119
|
id: string;
|
|
120
120
|
model_id?: string;
|
|
121
|
+
labels?: string[];
|
|
122
|
+
default?: boolean;
|
|
121
123
|
provider_options?: Record<string, unknown>;
|
|
122
124
|
}[];
|
|
123
125
|
processDefaultProfileId?: string;
|
|
@@ -125,6 +127,13 @@ export function createTestModelPolicy(
|
|
|
125
127
|
modelPurpose?: boolean;
|
|
126
128
|
purposeProfileId?: string;
|
|
127
129
|
allowedProfileIds?: readonly string[];
|
|
130
|
+
processRequirements?: import("@leitwerk-dev/protocol").ModelRequirements;
|
|
131
|
+
turnRequirements?: import("@leitwerk-dev/protocol").ModelRequirements;
|
|
132
|
+
operatorTurnRequirements?: import("@leitwerk-dev/protocol").ModelRequirements;
|
|
133
|
+
capabilities?: (
|
|
134
|
+
providerId: string,
|
|
135
|
+
modelId: string,
|
|
136
|
+
) => Readonly<Record<string, boolean | "unknown">>;
|
|
128
137
|
} = {},
|
|
129
138
|
): {
|
|
130
139
|
config: LeitwerkConfig;
|
|
@@ -143,26 +152,33 @@ export function createTestModelPolicy(
|
|
|
143
152
|
id: profile.id,
|
|
144
153
|
provider: "test",
|
|
145
154
|
model_id: profile.model_id ?? profile.id,
|
|
155
|
+
labels: profile.labels,
|
|
156
|
+
default: profile.default,
|
|
146
157
|
...(profile.provider_options ? { provider_options: profile.provider_options as never } : {}),
|
|
147
158
|
}));
|
|
148
159
|
config.pi.process_title_generation.model_profile = input.purposeProfileId ?? null;
|
|
149
160
|
config.process_configs = {
|
|
150
161
|
policy: {
|
|
162
|
+
model_requirements: input.processRequirements,
|
|
151
163
|
allowed_model_profiles: [
|
|
152
164
|
...(input.allowedProfileIds ?? config.pi.model_profiles.map((profile) => profile.id)),
|
|
153
165
|
],
|
|
154
166
|
...(input.processDefaultProfileId
|
|
155
167
|
? { default_model_profile: input.processDefaultProfileId }
|
|
156
168
|
: {}),
|
|
157
|
-
turn_configs:
|
|
158
|
-
|
|
159
|
-
|
|
169
|
+
turn_configs: {
|
|
170
|
+
run: {
|
|
171
|
+
model_profile: input.processTurnProfileId,
|
|
172
|
+
model_requirements: input.operatorTurnRequirements,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
160
175
|
},
|
|
161
176
|
};
|
|
162
177
|
const turn = createTestLlmTurn<string, Record<string, never>, Record<string, never>>(
|
|
163
178
|
"run",
|
|
164
179
|
{},
|
|
165
180
|
{
|
|
181
|
+
modelRequirements: input.turnRequirements,
|
|
166
182
|
...(input.modelPurpose || input.purposeProfileId !== undefined
|
|
167
183
|
? { modelPurpose: "process_title_generation" as const }
|
|
168
184
|
: {}),
|
|
@@ -176,7 +192,12 @@ export function createTestModelPolicy(
|
|
|
176
192
|
config,
|
|
177
193
|
graph,
|
|
178
194
|
processActionRegistry,
|
|
179
|
-
policy: createServerProcessModelPolicy({
|
|
195
|
+
policy: createServerProcessModelPolicy({
|
|
196
|
+
config,
|
|
197
|
+
processGraphs: graph,
|
|
198
|
+
processActionRegistry,
|
|
199
|
+
capabilities: input.capabilities,
|
|
200
|
+
}),
|
|
180
201
|
};
|
|
181
202
|
}
|
|
182
203
|
|