@leitwerk-dev/server 0.5.2 → 0.5.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.
Files changed (71) hide show
  1. package/dist/{app-DZUsf76a.d.ts → app-B8gyS_Id.d.ts} +82 -76
  2. package/dist/app-XAQTAQ5Y.js +8 -0
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/{chunk-AJ2DQWI3.js → chunk-6STQ3LAP.js} +133 -83
  5. package/dist/chunk-6STQ3LAP.js.map +1 -0
  6. package/dist/{chunk-6EEU4QOU.js → chunk-ZA5TDEM5.js} +302 -144
  7. package/dist/chunk-ZA5TDEM5.js.map +1 -0
  8. package/dist/config/config-loader.d.ts.map +1 -1
  9. package/dist/dashboard-model-issues.d.ts.map +1 -1
  10. package/dist/future-execution/execution.d.ts.map +1 -1
  11. package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
  12. package/dist/future-execution/lifecycle.d.ts.map +1 -1
  13. package/dist/future-execution/reconciliation.d.ts.map +1 -1
  14. package/dist/index.js +2 -2
  15. package/dist/main.js +3 -3
  16. package/dist/process-engine/ops/execute-action.d.ts.map +1 -1
  17. package/dist/process-engine/ops/retry-startup.d.ts.map +1 -1
  18. package/dist/process-engine/turn-start-preflight.d.ts.map +1 -1
  19. package/dist/process-model-config.d.ts.map +1 -1
  20. package/dist/process-model-policy/construct.d.ts +1 -0
  21. package/dist/process-model-policy/construct.d.ts.map +1 -1
  22. package/dist/process-model-policy/evaluate.d.ts +3 -3
  23. package/dist/process-model-policy/evaluate.d.ts.map +1 -1
  24. package/dist/process-model-policy/index.d.ts +1 -0
  25. package/dist/process-model-policy/index.d.ts.map +1 -1
  26. package/dist/process-model-policy/launch.d.ts.map +1 -1
  27. package/dist/process-model-policy/project.d.ts.map +1 -1
  28. package/dist/process-model-policy/requirements.d.ts +16 -0
  29. package/dist/process-model-policy/requirements.d.ts.map +1 -0
  30. package/dist/process-model-policy/types.d.ts +87 -75
  31. package/dist/process-model-policy/types.d.ts.map +1 -1
  32. package/dist/process-model-policy-presenter.d.ts.map +1 -1
  33. package/dist/process-model-selection.d.ts.map +1 -1
  34. package/dist/process-title-generator.d.ts +2 -0
  35. package/dist/process-title-generator.d.ts.map +1 -1
  36. package/dist/routes/process-actions.d.ts.map +1 -1
  37. package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
  38. package/dist/test-helpers/process-model-fixtures.d.ts +6 -0
  39. package/dist/test-helpers/process-model-fixtures.d.ts.map +1 -1
  40. package/dist/testing.js +1 -1
  41. package/package.json +12 -12
  42. package/src/app.ts +21 -0
  43. package/src/config/config-loader.ts +5 -0
  44. package/src/dashboard-model-issues.ts +66 -5
  45. package/src/future-execution/execution.ts +3 -8
  46. package/src/future-execution/launch-lifecycle.ts +15 -10
  47. package/src/future-execution/lifecycle.ts +1 -0
  48. package/src/future-execution/reconciliation.ts +2 -34
  49. package/src/launch-coordinator.ts +2 -2
  50. package/src/process-engine/ops/execute-action.ts +1 -0
  51. package/src/process-engine/ops/retry-startup.ts +10 -12
  52. package/src/process-engine/turn-start-preflight.ts +38 -15
  53. package/src/process-model-config.ts +7 -3
  54. package/src/process-model-policy/construct.ts +61 -3
  55. package/src/process-model-policy/evaluate.ts +73 -64
  56. package/src/process-model-policy/index.ts +16 -14
  57. package/src/process-model-policy/launch.ts +27 -29
  58. package/src/process-model-policy/project.ts +72 -43
  59. package/src/process-model-policy/requirements.ts +73 -0
  60. package/src/process-model-policy/types.ts +108 -78
  61. package/src/process-model-policy-presenter.ts +18 -2
  62. package/src/process-model-selection.ts +2 -0
  63. package/src/process-title-generator.ts +12 -16
  64. package/src/routes/launchers.ts +1 -1
  65. package/src/routes/process-actions.ts +1 -0
  66. package/src/supervisor/worker-start-payload-builder.ts +6 -1
  67. package/src/test-helpers/process-model-fixtures.ts +25 -4
  68. package/dist/app-2TCRADVA.js +0 -8
  69. package/dist/chunk-6EEU4QOU.js.map +0 -1
  70. package/dist/chunk-AJ2DQWI3.js.map +0 -1
  71. /package/dist/{app-2TCRADVA.js.map → app-XAQTAQ5Y.js.map} +0 -0
@@ -67,7 +67,6 @@ import {
67
67
  isHttpsOrLoopbackHttpUrl,
68
68
  isInternalEngineFailureCode,
69
69
  isLoopbackHttpUrl,
70
- isPinnedModelSelection,
71
70
  isSafeSessionInstanceId,
72
71
  isSkillModelInvocable,
73
72
  isTurnAvailableForProcessGraph,
@@ -133,7 +132,7 @@ import {
133
132
  verifyOpaqueToken,
134
133
  withTimeout,
135
134
  writeTurnWait
136
- } from "./chunk-6EEU4QOU.js";
135
+ } from "./chunk-ZA5TDEM5.js";
137
136
 
138
137
  // src/app.ts
139
138
  import path10 from "node:path";
@@ -3929,7 +3928,7 @@ async function executeScheduledLaunch(deps, execution) {
3929
3928
  async prepare(payload) {
3930
3929
  const prepared = await deps.launchPlans.prepare(payload.launchPlan, {
3931
3930
  modelConfig: payload.modelConfig,
3932
- invalidModelConfig: "reject"
3931
+ invalidModelConfig: "retain"
3933
3932
  });
3934
3933
  if (!prepared.ok) {
3935
3934
  return {
@@ -4064,6 +4063,7 @@ function createFutureExecutionExecutor(deps) {
4064
4063
  const snapshot = deps.modelStatusCache.snapshot();
4065
4064
  const result = deps.processModelPolicy.evaluate({
4066
4065
  kind: "runtime_selection",
4066
+ target: { kind: "process_default" },
4067
4067
  availability: snapshot,
4068
4068
  processId: execution.processId,
4069
4069
  selection: execution.modelSelection
@@ -4132,7 +4132,7 @@ function createFutureExecutionExecutor(deps) {
4132
4132
  if (!latest || latest.nextRunAt > asOf) {
4133
4133
  return;
4134
4134
  }
4135
- if ((!latest.modelSelection || latest.kind === "action" && !isPinnedModelSelection(latest.modelSelection)) && deps.processGraphs && deps.processActionRegistry && deps.turnRecords) {
4135
+ if (deps.processGraphs && deps.processActionRegistry && deps.turnRecords) {
4136
4136
  const projected = await projectFutureExecutionModelState(
4137
4137
  {
4138
4138
  processes: deps.processes,
@@ -4395,7 +4395,7 @@ function createFutureLaunchLifecycle(deps, options = {}) {
4395
4395
  modelConfig: normalizeLaunchModelConfigInput(input.modelConfig),
4396
4396
  invalidModelConfig: "reject"
4397
4397
  });
4398
- if (!prepared.ok && schedule.value.mode === "now") {
4398
+ if (!prepared.ok) {
4399
4399
  return {
4400
4400
  ok: false,
4401
4401
  outcome: {
@@ -4405,20 +4405,23 @@ function createFutureLaunchLifecycle(deps, options = {}) {
4405
4405
  };
4406
4406
  }
4407
4407
  const launchPlan = applySubmittedProcessTitleToLaunchPlan(prepared.launchPlan, input);
4408
+ const preview = deps.processModelPolicy.project({
4409
+ kind: "launcher_preview",
4410
+ processId: launchPlan.processId,
4411
+ plan: launchPlan,
4412
+ modelConfig: prepared.modelConfig,
4413
+ availability: deps.modelStatusCache.snapshot()
4414
+ });
4415
+ const issues = preview.turns.filter((turn) => turn.effective.error).map((turn) => ({
4416
+ code: "model_not_ready",
4417
+ message: `${turn.turnId}: ${turn.effective.error}`
4418
+ }));
4419
+ if (issues.length) return { ok: false, outcome: { kind: "invalid", issues } };
4408
4420
  const modelState = projectLaunchPlanModelState(launchPlan, {
4409
4421
  policy: deps.processModelPolicy,
4410
4422
  availability: deps.modelStatusCache.snapshot(),
4411
4423
  detectedAt: operationTime.toISOString()
4412
4424
  });
4413
- if (!prepared.ok && !modelState.blockedReason) {
4414
- return {
4415
- ok: false,
4416
- outcome: {
4417
- kind: "invalid",
4418
- issues: presentLaunchPlanPreparationIssues(prepared.errors)
4419
- }
4420
- };
4421
- }
4422
4425
  return { ok: true, launchPlan, modelState, schedule: schedule.value };
4423
4426
  }
4424
4427
  async function persistPreparedLaunch(input) {
@@ -4732,7 +4735,7 @@ async function reconcileFutureExecutionModelBlocks(input) {
4732
4735
  effects.push(buildFutureExecutionUpdatedEffect(updated, "updated"));
4733
4736
  };
4734
4737
  const parkStaleEvaluation = () => {
4735
- const blockedReason2 = toFutureExecutionBlockReason(
4738
+ const blockedReason = toFutureExecutionBlockReason(
4736
4739
  {
4737
4740
  ok: false,
4738
4741
  code: "stale_evaluation_snapshot",
@@ -4742,8 +4745,8 @@ async function reconcileFutureExecutionModelBlocks(input) {
4742
4745
  input.asOf,
4743
4746
  current.blockedReason
4744
4747
  );
4745
- if (sameModelPolicyState(current, { ...current, blockedReason: blockedReason2 })) return;
4746
- updateCurrent({ blockedReason: blockedReason2 });
4748
+ if (sameModelPolicyState(current, { ...current, blockedReason })) return;
4749
+ updateCurrent({ blockedReason });
4747
4750
  };
4748
4751
  const evaluateStable = async (evaluate) => {
4749
4752
  const evaluation = await evaluateAtStableAvailabilityRevision({
@@ -4765,35 +4768,7 @@ async function reconcileFutureExecutionModelBlocks(input) {
4765
4768
  const projected = evaluation.value;
4766
4769
  if (projected && !sameModelPolicyState(current, projected)) updateCurrent(projected);
4767
4770
  };
4768
- if (!isPinnedModelSelection(current.modelSelection)) {
4769
- await projectCurrent();
4770
- return;
4771
- }
4772
- if (!current.modelSelection) {
4773
- await projectCurrent();
4774
- if (!current.modelSelection) return;
4775
- }
4776
- const validation = await evaluateStable(
4777
- (snapshot) => input.policy.evaluate({
4778
- kind: "runtime_selection",
4779
- availability: snapshot,
4780
- processId: current.processId,
4781
- selection: current.modelSelection ?? null
4782
- })
4783
- );
4784
- if (!validation.ok) {
4785
- parkStaleEvaluation();
4786
- return;
4787
- }
4788
- const result = validation.value;
4789
- const inheritedInvalid = !result.ok && current.modelSelection.provenance.kind === "inherited" && (result.code === "unknown_model_profile" || result.code === "model_profile_not_allowed");
4790
- if (inheritedInvalid) {
4791
- await projectCurrent();
4792
- return;
4793
- }
4794
- const blockedReason = toFutureExecutionBlockReason(result, input.asOf, current.blockedReason);
4795
- if (sameModelPolicyState(current, { ...current, blockedReason })) return;
4796
- updateCurrent({ blockedReason });
4771
+ await projectCurrent();
4797
4772
  });
4798
4773
  }
4799
4774
  const reaction = await runFutureExecutionPostCommitEffects(input, effects);
@@ -4865,6 +4840,7 @@ async function validateScheduledActionRequest(deps, process2, actionId, input, n
4865
4840
  if (typeof nextTurnModelProfileId === "string") {
4866
4841
  const result = deps.processModelPolicy.evaluate({
4867
4842
  kind: "runtime_selection",
4843
+ target: { kind: "turn", turnId: validation.candidateSelectedTurnId },
4868
4844
  availability: deps.modelStatusCache.snapshot(),
4869
4845
  processId: process2.processId,
4870
4846
  selection: {
@@ -6438,8 +6414,8 @@ function createLaunchCoordinator(deps) {
6438
6414
  ...watcher.launchModelConfig,
6439
6415
  defaultModelProfileId: eventProfile ?? watcher.launchModelConfig.defaultModelProfileId
6440
6416
  },
6441
- // Event selections express ticket/user intent. Never silently drop them.
6442
- invalidModelConfig: eventProfile ? "reject" : "omit"
6417
+ // Keep watcher intent; the affected turn enforces policy before starting.
6418
+ invalidModelConfig: "retain"
6443
6419
  }
6444
6420
  );
6445
6421
  return prepared.ok ? { ok: true, value: prepared.launchPlan } : {
@@ -7408,19 +7384,16 @@ var RetryStartup = defineOperation({
7408
7384
  return reject("retry_target_missing", "Startup retry requires a failed current start");
7409
7385
  }
7410
7386
  const id = generateId("tsr");
7411
- const state = failed.state.kind === "preparation_failed" ? {
7412
- ...failed.state,
7413
- // A new operator retry must validate current inputs; the previous
7414
- // failure remains on its original start record.
7387
+ const preparation = {
7415
7388
  code: "model_required",
7416
7389
  safeSummary: "LLM start requires retry preparation"
7417
- } : failed.state.start.kind === "automatic" ? { kind: "starting", start: failed.state.start } : {
7390
+ };
7391
+ const state = failed.state.kind === "preparation_failed" ? { ...failed.state, ...preparation } : input.automaticRetry || failed.state.start.kind === "automatic" ? { kind: "starting", start: failed.state.start } : {
7418
7392
  kind: "preparation_failed",
7419
7393
  requestedModelProfileId: failed.state.start.model.profileId,
7420
7394
  providerOptions: { ...failed.state.start.providerOptions },
7421
- code: "model_required",
7422
- safeSummary: "LLM start requires retry preparation",
7423
- ...failed.state.start.modelSelectionProvenance ? { modelSelectionProvenance: failed.state.start.modelSelectionProvenance } : {}
7395
+ ...failed.state.start.modelSelectionProvenance ? { modelSelectionProvenance: failed.state.start.modelSelectionProvenance } : {},
7396
+ ...preparation
7424
7397
  };
7425
7398
  state.automaticRetry = input.automaticRetry;
7426
7399
  const writes = createWrites({
@@ -8311,6 +8284,7 @@ var ExecuteAction = defineOperation({
8311
8284
  if (input.opts.nextTurnModelProfileId !== null) {
8312
8285
  const evaluation = ctx.deps.processModelPolicy.evaluate({
8313
8286
  kind: "runtime_selection",
8287
+ target: { kind: "turn", turnId: candidateSelectedTurnId },
8314
8288
  availability: ctx.deps.getModelAvailabilitySnapshot(),
8315
8289
  processId: ctx.process.processId,
8316
8290
  selection: {
@@ -11841,6 +11815,7 @@ function createProcessModelSelection(deps) {
11841
11815
  if (!process2) return null;
11842
11816
  return deps.processModelPolicy.project({
11843
11817
  kind: "profile_options",
11818
+ target: { kind: "process_default" },
11844
11819
  processId: process2.processId,
11845
11820
  availability: deps.modelStatusCache.snapshot()
11846
11821
  }).map(presentModelProfileOption);
@@ -11904,6 +11879,7 @@ function createProcessModelSelection(deps) {
11904
11879
  turnStarts: deps.turnStarts,
11905
11880
  resolveCompatibleModelProfileIds: (providerId, modelId) => deps.processModelPolicy.project({
11906
11881
  kind: "compatible_profiles",
11882
+ target: { kind: "turn", turnId },
11907
11883
  availability,
11908
11884
  processId: process2.processId,
11909
11885
  providerId,
@@ -12223,10 +12199,6 @@ function normalizeLaunchPlanTitle(launchPlan) {
12223
12199
  normalizeProcessTitleInput(launchPlan.processInput.title)
12224
12200
  );
12225
12201
  }
12226
- function isTitleModelAllowedForProcess(config, processId, modelProfileId) {
12227
- const allowedProfiles = config.process_configs?.[processId]?.allowed_model_profiles;
12228
- return !allowedProfiles || allowedProfiles.includes(modelProfileId);
12229
- }
12230
12202
  function collectProcessTitleRuntimeDiagnostics(services) {
12231
12203
  const extensionLoadDiagnostics = services.resourceLoader.getExtensions().errors.map(({ path: extensionPath, error }) => ({
12232
12204
  type: "error",
@@ -12347,7 +12319,7 @@ function computeProcessTitleRetryDelayMs(attemptCount, policy) {
12347
12319
  return Math.max(1, Math.min(policy.maxDelayMs, scaledDelay));
12348
12320
  }
12349
12321
  var DefaultProcessTitleGenerator = class {
12350
- constructor(config, repos, broadcaster, logger, runtime = createDefaultRuntimeDeps(), extensionHost, futureExecutionTitleApplier, getLaunchCoordinator) {
12322
+ constructor(config, repos, broadcaster, logger, runtime = createDefaultRuntimeDeps(), extensionHost, futureExecutionTitleApplier, getLaunchCoordinator, modelPolicyError) {
12351
12323
  this.config = config;
12352
12324
  this.repos = repos;
12353
12325
  this.broadcaster = broadcaster;
@@ -12356,6 +12328,7 @@ var DefaultProcessTitleGenerator = class {
12356
12328
  this.extensionHost = extensionHost;
12357
12329
  this.futureExecutionTitleApplier = futureExecutionTitleApplier;
12358
12330
  this.getLaunchCoordinator = getLaunchCoordinator;
12331
+ this.modelPolicyError = modelPolicyError;
12359
12332
  this.configuredProfileId = trimToNull2(config.pi.process_title_generation.model_profile);
12360
12333
  this.retryPolicy = buildProcessTitleRetryPolicy(config);
12361
12334
  this.expandedAgentDir = expandPiAgentDir(config.pi.agent_dir);
@@ -12369,6 +12342,7 @@ var DefaultProcessTitleGenerator = class {
12369
12342
  extensionHost;
12370
12343
  futureExecutionTitleApplier;
12371
12344
  getLaunchCoordinator;
12345
+ modelPolicyError;
12372
12346
  configuredProfileId;
12373
12347
  retryPolicy;
12374
12348
  expandedAgentDir;
@@ -12446,11 +12420,8 @@ var DefaultProcessTitleGenerator = class {
12446
12420
  if (normalizedLaunchPlan.processInput.title || !this.configuredProfileId) {
12447
12421
  return null;
12448
12422
  }
12449
- if (!isTitleModelAllowedForProcess(
12450
- this.config,
12451
- normalizedLaunchPlan.processId,
12452
- this.configuredProfileId
12453
- )) {
12423
+ const policyError = this.modelPolicyError ? this.modelPolicyError(normalizedLaunchPlan.processId, this.configuredProfileId) : this.config.process_configs?.[normalizedLaunchPlan.processId]?.allowed_model_profiles?.includes(this.configuredProfileId) === false;
12424
+ if (policyError) {
12454
12425
  this.logger?.warn(
12455
12426
  "Skipping process title generation because the configured model profile is not allowed for this process",
12456
12427
  {
@@ -12666,6 +12637,8 @@ var DefaultProcessTitleGenerator = class {
12666
12637
  }
12667
12638
  }
12668
12639
  async generateTitle(job) {
12640
+ const policyError = this.modelPolicyError?.(job.processDefinitionId, job.modelProfileId);
12641
+ if (policyError) return { ok: false, error: policyError };
12669
12642
  const configuredProfile = this.config.pi.model_profiles.find(
12670
12643
  (profile2) => profile2.id === job.modelProfileId
12671
12644
  );
@@ -12767,7 +12740,8 @@ function createProcessTitleGenerator(options) {
12767
12740
  runtime,
12768
12741
  options.extensionHost,
12769
12742
  options.futureExecutionTitleApplier,
12770
- options.getLaunchCoordinator
12743
+ options.getLaunchCoordinator,
12744
+ options.modelPolicyError
12771
12745
  );
12772
12746
  }
12773
12747
 
@@ -14141,12 +14115,12 @@ import { parseFutureActionPayloadJson as parseFutureActionPayloadJson4, parseFut
14141
14115
  function buildDashboardModelIssues(deps) {
14142
14116
  const issues = /* @__PURE__ */ new Map();
14143
14117
  const availability = deps.modelStatusCache.snapshot();
14144
- function add(code, key, message, source) {
14118
+ function add(code, key, message, source, severity) {
14145
14119
  const id = JSON.stringify([code, key]);
14146
14120
  const issue = issues.get(id) ?? {
14147
14121
  id,
14148
14122
  code,
14149
- severity: code === "model_stale" ? "warning" : "error",
14123
+ severity: severity ?? (code === "model_stale" ? "warning" : "error"),
14150
14124
  message,
14151
14125
  sources: []
14152
14126
  };
@@ -14154,11 +14128,12 @@ function buildDashboardModelIssues(deps) {
14154
14128
  issue.sources.push(source);
14155
14129
  issues.set(id, issue);
14156
14130
  }
14157
- function check(profileId, source, processId = "") {
14131
+ function check(profileId, source, processId = "", turnId, preference = false) {
14158
14132
  const id = trimToNull3(profileId);
14159
14133
  if (!id) return;
14160
14134
  const result = deps.processModelPolicy.evaluate({
14161
14135
  kind: "runtime_selection",
14136
+ target: turnId ? { kind: "turn", turnId } : { kind: "process_default" },
14162
14137
  processId,
14163
14138
  selection: {
14164
14139
  modelProfileId: id,
@@ -14166,7 +14141,7 @@ function buildDashboardModelIssues(deps) {
14166
14141
  },
14167
14142
  availability
14168
14143
  });
14169
- if (result.ok) return;
14144
+ if (result.ok || preference && result.code === "model_profile_not_allowed") return;
14170
14145
  const key = result.code === "model_profile_not_allowed" ? JSON.stringify([id, processId]) : id;
14171
14146
  const message = presentProcessModelPolicyFailure(result);
14172
14147
  add(
@@ -14180,7 +14155,9 @@ function buildDashboardModelIssues(deps) {
14180
14155
  check(
14181
14156
  input.defaultModelProfileId,
14182
14157
  { ...source, label: `${source.label}: default model` },
14183
- input.processId
14158
+ input.processId,
14159
+ void 0,
14160
+ true
14184
14161
  );
14185
14162
  check(
14186
14163
  input.selectedTurnModelProfileId,
@@ -14204,9 +14181,40 @@ function buildDashboardModelIssues(deps) {
14204
14181
  check(
14205
14182
  config2.modelProfileId,
14206
14183
  { ...source, label: `${source.label}: ${turnId}` },
14207
- input.processId
14184
+ input.processId,
14185
+ turnId
14208
14186
  );
14209
14187
  }
14188
+ for (const processId of deps.processGraphs.keys()) {
14189
+ check(
14190
+ deps.config?.pi.process_title_generation.model_profile,
14191
+ { label: `${processId}: title generation`, href: null },
14192
+ processId
14193
+ );
14194
+ const preview = deps.processModelPolicy.project({
14195
+ kind: "launcher_preview",
14196
+ processId,
14197
+ modelConfig: {},
14198
+ availability
14199
+ });
14200
+ for (const turn of preview.turns) {
14201
+ if (!turn.effective.error && (turn.effective.ranking?.kind === "cost_id" || (turn.effective.ranking?.tiedProfileIds.length ?? 0) > 1))
14202
+ add(
14203
+ "automatic_model_tiebreak",
14204
+ `${processId}/${turn.turnId}`,
14205
+ `Selected '${turn.effective.profile?.id}' by ${turn.effective.ranking?.kind === "cost_id" ? "cost group and profile ID" : `cost group and profile ID among equal-specificity defaults: ${turn.effective.ranking?.tiedProfileIds.join(", ")}`}`,
14206
+ { label: `${processId}: ${turn.turnId}`, href: null },
14207
+ "warning"
14208
+ );
14209
+ if (turn.effective.error)
14210
+ add(
14211
+ "model_policy_blocked",
14212
+ turn.effective.profile?.id ?? `${processId}/${turn.turnId}`,
14213
+ turn.effective.error,
14214
+ { label: `${processId}: ${turn.turnId}`, href: null }
14215
+ );
14216
+ }
14217
+ }
14210
14218
  const config = deps.config;
14211
14219
  if (config) {
14212
14220
  for (const profile2 of config.pi.model_profiles)
@@ -14221,13 +14229,17 @@ function buildDashboardModelIssues(deps) {
14221
14229
  check(
14222
14230
  processConfig.default_model_profile,
14223
14231
  { label: `${prefix}.default_model_profile`, href: null },
14224
- processId
14232
+ processId,
14233
+ void 0,
14234
+ true
14225
14235
  );
14226
14236
  for (const [turnId, turnConfig] of Object.entries(processConfig.turn_configs ?? {}))
14227
14237
  check(
14228
14238
  turnConfig.model_profile,
14229
14239
  { label: `${prefix}.turn_configs.${turnId}.model_profile`, href: null },
14230
- processId
14240
+ processId,
14241
+ turnId,
14242
+ true
14231
14243
  );
14232
14244
  }
14233
14245
  }
@@ -14247,12 +14259,19 @@ function buildDashboardModelIssues(deps) {
14247
14259
  }
14248
14260
  for (const watcher of deps.processWatchers?.listAll() ?? []) {
14249
14261
  const source = { label: watcher.configPath, href: "/watchers" };
14250
- check(watcher.launchModelConfig.defaultModelProfileId, source, watcher.processId);
14262
+ check(
14263
+ watcher.launchModelConfig.defaultModelProfileId,
14264
+ source,
14265
+ watcher.processId,
14266
+ void 0,
14267
+ true
14268
+ );
14251
14269
  for (const [turnId, turnConfig] of Object.entries(watcher.launchModelConfig.turnConfigs ?? {}))
14252
14270
  check(
14253
14271
  turnConfig.modelProfileId,
14254
14272
  { ...source, label: `${source.label}: ${turnId}` },
14255
- watcher.processId
14273
+ watcher.processId,
14274
+ turnId
14256
14275
  );
14257
14276
  }
14258
14277
  for (const process2 of deps.processes.listModelConfigurations()) {
@@ -14769,7 +14788,7 @@ function registerLauncherRoutes(app, deps, futureExecutionLifecycle) {
14769
14788
  title = resolved.launcher.launchPlan.processInput.title ?? null;
14770
14789
  const preparedLaunchPlan = await deps.launchPlans.prepare(
14771
14790
  resolved.launcher.launchPlan,
14772
- { invalidModelConfig: "omit" }
14791
+ { invalidModelConfig: "retain" }
14773
14792
  );
14774
14793
  if (!preparedLaunchPlan.ok) {
14775
14794
  warnings.push(...presentLaunchPlanPreparationIssues(preparedLaunchPlan.errors));
@@ -15091,6 +15110,7 @@ function registerProcessActionRoutes(app, deps, futureExecutionLifecycle) {
15091
15110
  );
15092
15111
  const profiles = deps.processModelPolicy.project({
15093
15112
  kind: "profile_options",
15113
+ target: { kind: "process_default" },
15094
15114
  processId: process2.processId,
15095
15115
  availability: deps.modelStatusCache.snapshot()
15096
15116
  });
@@ -16183,13 +16203,17 @@ function prepareProcessModelConfig(input) {
16183
16203
  else turnConfigs[id] = { ...turnConfigs[id], modelProfileId: config.modelProfileId };
16184
16204
  }
16185
16205
  const selections = [
16186
- patch.defaultModelProfileId,
16187
- ...Object.values(patch.turnConfigs ?? {}).map((config) => config.modelProfileId)
16206
+ { id: patch.defaultModelProfileId, target: { kind: "process_default" } },
16207
+ ...Object.entries(patch.turnConfigs ?? {}).map(([turnId, config]) => ({
16208
+ id: config.modelProfileId,
16209
+ target: { kind: "turn", turnId }
16210
+ }))
16188
16211
  ];
16189
- for (const id of selections) {
16212
+ for (const { id, target } of selections) {
16190
16213
  if (!id) continue;
16191
16214
  const validation = policy.evaluate({
16192
16215
  kind: "runtime_selection",
16216
+ target,
16193
16217
  processId: process2.processId,
16194
16218
  availability,
16195
16219
  selection: {
@@ -19280,7 +19304,12 @@ function buildWorkerConfigSnapshot(config) {
19280
19304
  );
19281
19305
  return {
19282
19306
  workers: buildWorkerRuntimeSettingsSnapshot(config),
19283
- pi: config.pi,
19307
+ pi: {
19308
+ ...config.pi,
19309
+ model_profiles: config.pi.model_profiles.map(
19310
+ ({ labels: _labels, default: _default, ...profile2 }) => profile2
19311
+ )
19312
+ },
19284
19313
  ...Object.keys(processConfigs).length > 0 ? { process_configs: processConfigs } : {}
19285
19314
  };
19286
19315
  }
@@ -21159,12 +21188,17 @@ ${configErrors.join("\n")}`);
21159
21188
  const status = modelStatusCache.snapshot().profiles.find((entry) => entry.profileId === profile2.id);
21160
21189
  return {
21161
21190
  value: profile2.id,
21191
+ labels: [...new Set(profile2.labels ?? [])],
21162
21192
  label: `${profile2.id} \u2014 ${profile2.provider}/${profile2.model_id}`,
21163
21193
  ...status?.availability === "available" ? {} : { disabledReason: status?.safeReason ?? "Model unavailable" }
21164
21194
  };
21165
21195
  })
21166
21196
  });
21167
21197
  const processModelPolicy = createServerProcessModelPolicy({
21198
+ capabilities: (providerId, modelId) => {
21199
+ const provider = modelProviderRegistry.require(providerId);
21200
+ return provider.definition.capabilities?.({ config: provider.config, modelId }) ?? {};
21201
+ },
21168
21202
  scopedSettings,
21169
21203
  config,
21170
21204
  processGraphs,
@@ -21177,6 +21211,8 @@ ${configErrors.join("\n")}`);
21177
21211
  markStartup("extension_ui_catalog");
21178
21212
  const launcherModelProfiles = config.pi.model_profiles.map(
21179
21213
  (profile2) => ({
21214
+ labels: [...new Set(profile2.labels ?? [])],
21215
+ default: profile2.default ?? false,
21180
21216
  id: profile2.id,
21181
21217
  provider: profile2.provider,
21182
21218
  modelId: profile2.model_id,
@@ -21189,6 +21225,7 @@ ${configErrors.join("\n")}`);
21189
21225
  const getModelProfilesForProcess = (processId) => {
21190
21226
  return processModelPolicy.project({
21191
21227
  kind: "profile_options",
21228
+ target: { kind: "process_default" },
21192
21229
  processId,
21193
21230
  availability: modelStatusCache.snapshot()
21194
21231
  }).map((profile2) => launcherModelProfilesById.get(profile2.id)).filter(
@@ -21227,6 +21264,19 @@ ${configErrors.join("\n")}`);
21227
21264
  error: "Future execution lifecycle is not initialized"
21228
21265
  });
21229
21266
  const processTitles = opts.processTitleGenerator ?? (config.pi.process_title_generation.model_profile === null ? void 0 : createProcessTitleGenerator({
21267
+ modelPolicyError: (processId, modelProfileId) => {
21268
+ const result = processModelPolicy.evaluate({
21269
+ kind: "runtime_selection",
21270
+ target: { kind: "process_default" },
21271
+ processId,
21272
+ selection: {
21273
+ modelProfileId,
21274
+ provenance: { kind: "inherited", source: "fixed_purpose" }
21275
+ },
21276
+ availability: modelStatusCache.snapshot()
21277
+ });
21278
+ return result.ok ? null : `Title model '${modelProfileId}' blocked: ${result.code}`;
21279
+ },
21230
21280
  config,
21231
21281
  repos,
21232
21282
  broadcaster,
@@ -22051,4 +22101,4 @@ ${configErrors.join("\n")}`);
22051
22101
  export {
22052
22102
  createAppContext
22053
22103
  };
22054
- //# sourceMappingURL=chunk-AJ2DQWI3.js.map
22104
+ //# sourceMappingURL=chunk-6STQ3LAP.js.map