@leitwerk-dev/server 0.3.1 → 0.4.0

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 (309) hide show
  1. package/dist/{app-BuJCdkvy.d.ts → app-CsuxFZT5.d.ts} +262 -121
  2. package/dist/app-JM4CBTND.js +8 -0
  3. package/dist/app.d.ts +9 -0
  4. package/dist/app.d.ts.map +1 -1
  5. package/dist/auth/fastify-auth.d.ts +9 -0
  6. package/dist/auth/fastify-auth.d.ts.map +1 -1
  7. package/dist/{chunk-QCHS3X33.js → chunk-FPMDWQF7.js} +2617 -562
  8. package/dist/chunk-FPMDWQF7.js.map +1 -0
  9. package/dist/{chunk-HK6BLLHA.js → chunk-MBHRCQFE.js} +2303 -1576
  10. package/dist/chunk-MBHRCQFE.js.map +1 -0
  11. package/dist/config/config-loader.d.ts +1 -1
  12. package/dist/config/config-loader.d.ts.map +1 -1
  13. package/dist/config/config-types.d.ts +14 -1
  14. package/dist/config/config-types.d.ts.map +1 -1
  15. package/dist/config/kubernetes-docker-isolation.d.ts +7 -0
  16. package/dist/config/kubernetes-docker-isolation.d.ts.map +1 -0
  17. package/dist/db/database.d.ts.map +1 -1
  18. package/dist/db/execution-inspection-repo.d.ts +15 -0
  19. package/dist/db/execution-inspection-repo.d.ts.map +1 -0
  20. package/dist/db/history-window.d.ts +11 -0
  21. package/dist/db/history-window.d.ts.map +1 -0
  22. package/dist/db/process-event-repo.d.ts +2 -0
  23. package/dist/db/process-event-repo.d.ts.map +1 -1
  24. package/dist/db/process-instance-repo.d.ts +4 -1
  25. package/dist/db/process-instance-repo.d.ts.map +1 -1
  26. package/dist/db/process-leaf-outcome-snapshot-repo.d.ts +2 -1
  27. package/dist/db/process-leaf-outcome-snapshot-repo.d.ts.map +1 -1
  28. package/dist/db/process-project-repo.d.ts +2 -0
  29. package/dist/db/process-project-repo.d.ts.map +1 -1
  30. package/dist/db/process-skill-repo.d.ts.map +1 -1
  31. package/dist/db/process-turn-annotation-repo.d.ts +4 -1
  32. package/dist/db/process-turn-annotation-repo.d.ts.map +1 -1
  33. package/dist/db/process-turn-record-repo.d.ts +4 -0
  34. package/dist/db/process-turn-record-repo.d.ts.map +1 -1
  35. package/dist/db/publication-repo.d.ts +5 -0
  36. package/dist/db/publication-repo.d.ts.map +1 -0
  37. package/dist/db/repositories.d.ts +12 -0
  38. package/dist/db/repositories.d.ts.map +1 -1
  39. package/dist/db/schema.d.ts +693 -2
  40. package/dist/db/schema.d.ts.map +1 -1
  41. package/dist/db/scoped-settings-repo.d.ts +37 -0
  42. package/dist/db/scoped-settings-repo.d.ts.map +1 -0
  43. package/dist/db/skill-repo.d.ts +3 -0
  44. package/dist/db/skill-repo.d.ts.map +1 -1
  45. package/dist/db/turn-start-record-repo.d.ts +2 -1
  46. package/dist/db/turn-start-record-repo.d.ts.map +1 -1
  47. package/dist/db/turn-summary-repo.d.ts +1 -1
  48. package/dist/db/turn-summary-repo.d.ts.map +1 -1
  49. package/dist/db/worker-lease-repo.d.ts +2 -1
  50. package/dist/db/worker-lease-repo.d.ts.map +1 -1
  51. package/dist/domain-logic/outcome-tools.d.ts.map +1 -1
  52. package/dist/external-source-service.d.ts.map +1 -1
  53. package/dist/future-execution/execution.d.ts +4 -1
  54. package/dist/future-execution/execution.d.ts.map +1 -1
  55. package/dist/future-execution/launch-lifecycle.d.ts +9 -25
  56. package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
  57. package/dist/future-execution/lifecycle.d.ts +3 -28
  58. package/dist/future-execution/lifecycle.d.ts.map +1 -1
  59. package/dist/future-execution/model-projection.d.ts.map +1 -1
  60. package/dist/future-execution/reconciliation.d.ts +1 -0
  61. package/dist/future-execution/reconciliation.d.ts.map +1 -1
  62. package/dist/future-execution-presenter.d.ts.map +1 -1
  63. package/dist/index.js +2 -2
  64. package/dist/integration-tool-registry.d.ts +11 -2
  65. package/dist/integration-tool-registry.d.ts.map +1 -1
  66. package/dist/launch-coordinator.d.ts.map +1 -1
  67. package/dist/launcher-model-config-service.d.ts +7 -1
  68. package/dist/launcher-model-config-service.d.ts.map +1 -1
  69. package/dist/leaf-outcome-snapshot-capture.d.ts +1 -0
  70. package/dist/leaf-outcome-snapshot-capture.d.ts.map +1 -1
  71. package/dist/main.js +3 -3
  72. package/dist/primary-path-snapshot.d.ts.map +1 -1
  73. package/dist/process-action-presenter.d.ts +1 -6
  74. package/dist/process-action-presenter.d.ts.map +1 -1
  75. package/dist/process-action-registry.d.ts.map +1 -1
  76. package/dist/process-engine/decision.d.ts +2 -0
  77. package/dist/process-engine/decision.d.ts.map +1 -1
  78. package/dist/process-engine/engine.d.ts.map +1 -1
  79. package/dist/process-engine/mapped-turns.d.ts.map +1 -1
  80. package/dist/process-engine/ops/continue-failed-turn.d.ts.map +1 -1
  81. package/dist/process-engine/ops/process-observation.d.ts +6 -0
  82. package/dist/process-engine/ops/process-observation.d.ts.map +1 -0
  83. package/dist/process-engine/ops/retry-failed-turn.d.ts.map +1 -1
  84. package/dist/process-engine/ops/retry-startup.d.ts.map +1 -1
  85. package/dist/process-engine/ops/start-process.d.ts +2 -0
  86. package/dist/process-engine/ops/start-process.d.ts.map +1 -1
  87. package/dist/process-engine/ops/turn-outcome.d.ts.map +1 -1
  88. package/dist/process-engine/ops/turn-wait.d.ts +30 -0
  89. package/dist/process-engine/ops/turn-wait.d.ts.map +1 -0
  90. package/dist/process-engine/ops/update-model-config.d.ts +9 -0
  91. package/dist/process-engine/ops/update-model-config.d.ts.map +1 -0
  92. package/dist/process-engine/recorder.d.ts.map +1 -1
  93. package/dist/process-engine/turn-start-preflight.d.ts +6 -0
  94. package/dist/process-engine/turn-start-preflight.d.ts.map +1 -1
  95. package/dist/process-engine/turn-wait-state.d.ts +24 -0
  96. package/dist/process-engine/turn-wait-state.d.ts.map +1 -0
  97. package/dist/process-engine/turn-worker-requirement.d.ts +2 -0
  98. package/dist/process-engine/turn-worker-requirement.d.ts.map +1 -1
  99. package/dist/process-engine/types.d.ts +5 -1
  100. package/dist/process-engine/types.d.ts.map +1 -1
  101. package/dist/process-engine/writes/build-process-abort-writes.d.ts +3 -1
  102. package/dist/process-engine/writes/build-process-abort-writes.d.ts.map +1 -1
  103. package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +2 -0
  104. package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
  105. package/dist/process-engine/writes/commit-writes.d.ts +2 -0
  106. package/dist/process-engine/writes/commit-writes.d.ts.map +1 -1
  107. package/dist/process-engine/writes/writes.d.ts +28 -60
  108. package/dist/process-engine/writes/writes.d.ts.map +1 -1
  109. package/dist/process-graph.d.ts +1 -1
  110. package/dist/process-graph.d.ts.map +1 -1
  111. package/dist/process-inspection-reader.d.ts +21 -0
  112. package/dist/process-inspection-reader.d.ts.map +1 -0
  113. package/dist/process-inspection-trace.d.ts +13 -0
  114. package/dist/process-inspection-trace.d.ts.map +1 -0
  115. package/dist/process-inspection.d.ts +22 -0
  116. package/dist/process-inspection.d.ts.map +1 -0
  117. package/dist/process-instance-tree-presenter.d.ts +4 -3
  118. package/dist/process-instance-tree-presenter.d.ts.map +1 -1
  119. package/dist/process-launch-executor.d.ts +2 -0
  120. package/dist/process-launch-executor.d.ts.map +1 -1
  121. package/dist/process-launch-plan.d.ts +1 -0
  122. package/dist/process-launch-plan.d.ts.map +1 -1
  123. package/dist/process-launcher-registry.d.ts.map +1 -1
  124. package/dist/process-model-config.d.ts +19 -0
  125. package/dist/process-model-config.d.ts.map +1 -0
  126. package/dist/process-model-policy/construct.d.ts.map +1 -1
  127. package/dist/process-model-policy/evaluate.d.ts.map +1 -1
  128. package/dist/process-model-policy/index.d.ts +4 -1
  129. package/dist/process-model-policy/index.d.ts.map +1 -1
  130. package/dist/process-model-policy/project.d.ts.map +1 -1
  131. package/dist/process-model-policy/types.d.ts +18 -0
  132. package/dist/process-model-policy/types.d.ts.map +1 -1
  133. package/dist/process-model-policy-presenter.d.ts.map +1 -1
  134. package/dist/process-runtime-availability.d.ts +2 -1
  135. package/dist/process-runtime-availability.d.ts.map +1 -1
  136. package/dist/process-turn-trace.d.ts.map +1 -1
  137. package/dist/process-ui-snapshot-presenter.d.ts +14 -3
  138. package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
  139. package/dist/routes/future-executions.d.ts.map +1 -1
  140. package/dist/routes/launchers.d.ts.map +1 -1
  141. package/dist/routes/process-actions.d.ts.map +1 -1
  142. package/dist/routes/process-detail.d.ts.map +1 -1
  143. package/dist/routes/process-model-config.d.ts +4 -0
  144. package/dist/routes/process-model-config.d.ts.map +1 -0
  145. package/dist/routes/process-route-helpers.d.ts +8 -9
  146. package/dist/routes/process-route-helpers.d.ts.map +1 -1
  147. package/dist/routes/processes.d.ts.map +1 -1
  148. package/dist/routes/settings.d.ts +11 -0
  149. package/dist/routes/settings.d.ts.map +1 -0
  150. package/dist/routes/ticket-creation.d.ts.map +1 -1
  151. package/dist/scoped-settings-service.d.ts +83 -0
  152. package/dist/scoped-settings-service.d.ts.map +1 -0
  153. package/dist/server-bootstrap/build-host-capabilities.d.ts +2 -0
  154. package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
  155. package/dist/server-bootstrap/register-http.d.ts.map +1 -1
  156. package/dist/session-summary-projection.d.ts.map +1 -1
  157. package/dist/skills/bundled-skills.d.ts +5 -0
  158. package/dist/skills/bundled-skills.d.ts.map +1 -0
  159. package/dist/skills/catalog-service.d.ts +1 -0
  160. package/dist/skills/catalog-service.d.ts.map +1 -1
  161. package/dist/skills/extension-importer.d.ts +11 -0
  162. package/dist/skills/extension-importer.d.ts.map +1 -0
  163. package/dist/skills/launch-skills.d.ts +11 -0
  164. package/dist/skills/launch-skills.d.ts.map +1 -0
  165. package/dist/skills/skill-frontmatter.d.ts +5 -0
  166. package/dist/skills/skill-frontmatter.d.ts.map +1 -1
  167. package/dist/skills/source-importer.d.ts +3 -0
  168. package/dist/skills/source-importer.d.ts.map +1 -1
  169. package/dist/startup-evidence.d.ts +3 -0
  170. package/dist/startup-evidence.d.ts.map +1 -1
  171. package/dist/supervisor/execution-inspection-ingestor.d.ts +9 -0
  172. package/dist/supervisor/execution-inspection-ingestor.d.ts.map +1 -0
  173. package/dist/supervisor/ipc-handler.d.ts +2 -0
  174. package/dist/supervisor/ipc-handler.d.ts.map +1 -1
  175. package/dist/supervisor/worker-event-ingestor.d.ts +1 -0
  176. package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
  177. package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
  178. package/dist/supervisor/worker-supervisor.d.ts +2 -0
  179. package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
  180. package/dist/test-helpers/prepared-fixture-start.d.ts.map +1 -1
  181. package/dist/test-helpers/process-model-fixtures.d.ts +1 -0
  182. package/dist/test-helpers/process-model-fixtures.d.ts.map +1 -1
  183. package/dist/test-helpers/scoped-settings-fixtures.d.ts +16 -0
  184. package/dist/test-helpers/scoped-settings-fixtures.d.ts.map +1 -0
  185. package/dist/test-helpers/skill-fixtures.d.ts +4 -0
  186. package/dist/test-helpers/skill-fixtures.d.ts.map +1 -0
  187. package/dist/testing.js +2 -1
  188. package/dist/testing.js.map +1 -1
  189. package/dist/tool-approval-gate.d.ts +3 -0
  190. package/dist/tool-approval-gate.d.ts.map +1 -1
  191. package/dist/turn-progress.d.ts.map +1 -1
  192. package/dist/turn-wait-service.d.ts +28 -0
  193. package/dist/turn-wait-service.d.ts.map +1 -0
  194. package/dist/worker-runtime-profile-selection.d.ts +2 -0
  195. package/dist/worker-runtime-profile-selection.d.ts.map +1 -1
  196. package/package.json +20 -19
  197. package/src/app.ts +115 -5
  198. package/src/auth/fastify-auth.ts +13 -0
  199. package/src/config/config-loader.ts +40 -2
  200. package/src/config/config-types.ts +14 -1
  201. package/src/config/kubernetes-docker-isolation.ts +21 -0
  202. package/src/db/database.ts +131 -40
  203. package/src/db/execution-inspection-repo.ts +163 -0
  204. package/src/db/history-window.ts +18 -0
  205. package/src/db/process-event-repo.ts +88 -10
  206. package/src/db/process-instance-repo.ts +9 -2
  207. package/src/db/process-leaf-outcome-snapshot-repo.ts +8 -2
  208. package/src/db/process-project-repo.ts +4 -0
  209. package/src/db/process-skill-repo.ts +9 -2
  210. package/src/db/process-turn-annotation-repo.ts +27 -9
  211. package/src/db/process-turn-record-repo.ts +45 -12
  212. package/src/db/publication-repo.ts +63 -0
  213. package/src/db/repositories.ts +17 -0
  214. package/src/db/schema.ts +103 -1
  215. package/src/db/scoped-settings-repo.ts +234 -0
  216. package/src/db/skill-repo.ts +89 -27
  217. package/src/db/turn-start-record-repo.ts +8 -2
  218. package/src/db/turn-summary-repo.ts +12 -3
  219. package/src/db/worker-lease-repo.ts +8 -2
  220. package/src/domain-logic/outcome-tools.ts +4 -193
  221. package/src/external-source-service.ts +33 -7
  222. package/src/future-execution/execution.ts +9 -2
  223. package/src/future-execution/launch-lifecycle.ts +87 -78
  224. package/src/future-execution/lifecycle.ts +5 -34
  225. package/src/future-execution/model-projection.ts +2 -0
  226. package/src/future-execution/reconciliation.ts +7 -0
  227. package/src/future-execution-presenter.ts +7 -8
  228. package/src/integration-tool-registry.ts +59 -26
  229. package/src/launch-coordinator.ts +10 -1
  230. package/src/launcher-model-config-service.ts +24 -3
  231. package/src/leaf-outcome-snapshot-capture.ts +2 -0
  232. package/src/primary-path-snapshot.ts +3 -4
  233. package/src/process-action-presenter.ts +22 -57
  234. package/src/process-action-registry.ts +31 -39
  235. package/src/process-engine/decision.ts +10 -0
  236. package/src/process-engine/engine.ts +11 -2
  237. package/src/process-engine/mapped-turns.ts +5 -7
  238. package/src/process-engine/ops/continue-failed-turn.ts +2 -13
  239. package/src/process-engine/ops/process-observation.ts +119 -0
  240. package/src/process-engine/ops/retry-failed-turn.ts +2 -12
  241. package/src/process-engine/ops/retry-startup.ts +9 -13
  242. package/src/process-engine/ops/start-process.ts +34 -2
  243. package/src/process-engine/ops/turn-outcome.ts +61 -60
  244. package/src/process-engine/ops/turn-wait.ts +225 -0
  245. package/src/process-engine/ops/update-model-config.ts +66 -0
  246. package/src/process-engine/recorder.ts +21 -5
  247. package/src/process-engine/turn-start-preflight.ts +168 -105
  248. package/src/process-engine/turn-wait-state.ts +126 -0
  249. package/src/process-engine/turn-worker-requirement.ts +4 -0
  250. package/src/process-engine/types.ts +9 -0
  251. package/src/process-engine/writes/build-process-abort-writes.ts +30 -20
  252. package/src/process-engine/writes/build-turn-outcome-writes.ts +39 -2
  253. package/src/process-engine/writes/commit-writes.ts +15 -2
  254. package/src/process-engine/writes/writes.ts +59 -74
  255. package/src/process-graph.ts +0 -1
  256. package/src/process-inspection-reader.ts +305 -0
  257. package/src/process-inspection-trace.ts +176 -0
  258. package/src/process-inspection.ts +169 -0
  259. package/src/process-instance-tree-presenter.ts +56 -216
  260. package/src/process-launch-executor.ts +5 -2
  261. package/src/process-launch-plan.ts +17 -2
  262. package/src/process-launcher-registry.ts +28 -16
  263. package/src/process-model-config.ts +100 -0
  264. package/src/process-model-policy/construct.ts +1 -0
  265. package/src/process-model-policy/evaluate.ts +34 -32
  266. package/src/process-model-policy/index.ts +45 -3
  267. package/src/process-model-policy/project.ts +62 -76
  268. package/src/process-model-policy/types.ts +26 -0
  269. package/src/process-model-policy-presenter.ts +7 -3
  270. package/src/process-runtime-availability.ts +9 -4
  271. package/src/process-turn-trace.ts +12 -24
  272. package/src/process-ui-snapshot-presenter.ts +210 -295
  273. package/src/routes/future-executions.ts +5 -5
  274. package/src/routes/launchers.ts +51 -1
  275. package/src/routes/process-actions.ts +9 -9
  276. package/src/routes/process-detail.ts +25 -2
  277. package/src/routes/process-model-config.ts +70 -0
  278. package/src/routes/process-route-helpers.ts +153 -162
  279. package/src/routes/processes.ts +2 -0
  280. package/src/routes/settings.ts +173 -0
  281. package/src/routes/ticket-creation.ts +28 -5
  282. package/src/scoped-settings-service.ts +736 -0
  283. package/src/server-bootstrap/build-host-capabilities.ts +42 -0
  284. package/src/server-bootstrap/register-http.ts +7 -1
  285. package/src/session-summary-projection.ts +1 -2
  286. package/src/skills/bundled-skills.ts +64 -0
  287. package/src/skills/catalog-service.ts +35 -6
  288. package/src/skills/extension-importer.ts +97 -0
  289. package/src/skills/launch-skills.ts +19 -0
  290. package/src/skills/skill-frontmatter.ts +13 -0
  291. package/src/skills/source-importer.ts +3 -0
  292. package/src/startup-evidence.ts +20 -0
  293. package/src/supervisor/execution-inspection-ingestor.ts +55 -0
  294. package/src/supervisor/ipc-handler.ts +2 -0
  295. package/src/supervisor/worker-event-ingestor.ts +30 -14
  296. package/src/supervisor/worker-start-payload-builder.ts +17 -0
  297. package/src/supervisor/worker-supervisor.ts +3 -0
  298. package/src/test-helpers/prepared-fixture-start.ts +1 -0
  299. package/src/test-helpers/process-model-fixtures.ts +2 -0
  300. package/src/test-helpers/scoped-settings-fixtures.ts +126 -0
  301. package/src/test-helpers/skill-fixtures.ts +28 -0
  302. package/src/tool-approval-gate.ts +16 -0
  303. package/src/turn-progress.ts +3 -2
  304. package/src/turn-wait-service.ts +228 -0
  305. package/src/worker-runtime-profile-selection.ts +8 -1
  306. package/dist/app-MSJXFK33.js +0 -8
  307. package/dist/chunk-HK6BLLHA.js.map +0 -1
  308. package/dist/chunk-QCHS3X33.js.map +0 -1
  309. /package/dist/{app-MSJXFK33.js.map → app-JM4CBTND.js.map} +0 -0
@@ -1,4 +1,5 @@
1
1
  import {
2
+ isUnknownRecord,
2
3
  normalizeLaunchModelConfigInput,
3
4
  type ProcessEvent,
4
5
  type ProcessInstance,
@@ -9,7 +10,6 @@ import {
9
10
  import type { ProcessModelSelectionServiceLike } from "@leitwerk-dev/process-sdk";
10
11
  import {
11
12
  findUiLauncherById,
12
- isLlmTurnDefinition,
13
13
  type OutcomeToolParameterSpec,
14
14
  type ProcessLauncherService,
15
15
  type ProcessLaunchPlanServiceLike,
@@ -20,11 +20,7 @@ import {
20
20
  resolveProcessPiConfig,
21
21
  resolveTurnActiveToolNames,
22
22
  } from "@leitwerk-dev/process-sdk/pi-config";
23
- import {
24
- parseActionRequestBody,
25
- parseLauncherInputJson,
26
- parseLauncherRequestBody,
27
- } from "@leitwerk-dev/protocol";
23
+ import { parseLauncherInputJson, parseLauncherRequestBody } from "@leitwerk-dev/protocol";
28
24
  import type {
29
25
  LauncherModelConfigSchema,
30
26
  LauncherMutationResponseBody,
@@ -44,7 +40,6 @@ import type {
44
40
  ActionMutationOutcome,
45
41
  FutureExecutionLifecycle,
46
42
  LaunchMutationOutcome,
47
- NormalizedScheduledActionInput,
48
43
  NormalizedScheduledLaunchInput,
49
44
  } from "../future-execution/index.js";
50
45
  import {
@@ -93,6 +88,7 @@ export interface RouteDeps
93
88
  | "inputs"
94
89
  | "events"
95
90
  | "turnSummaries"
91
+ | "executionInspections"
96
92
  | "futureExecutions"
97
93
  | "skills"
98
94
  | "processSkills"
@@ -109,6 +105,12 @@ export interface RouteDeps
109
105
  | "transaction"
110
106
  > {
111
107
  /** @internal */
108
+ scopedSettingsService?: import("../scoped-settings-service.js").ScopedSettingsService;
109
+ /** @internal */
110
+ topicWiki?: RepositoryBundle["topicWiki"];
111
+ /** @internal */
112
+ onSettingsChanged?: () => Promise<void>;
113
+ /** @internal */
112
114
  mappedRuns?: RepositoryBundle["mappedRuns"];
113
115
  /** @internal */
114
116
  startupObservations?: RepositoryBundle["startupObservations"];
@@ -177,6 +179,16 @@ export function routeConfig(deps: Pick<RouteDeps, "config">): LeitwerkConfig {
177
179
  return deps.config ?? getDefaultConfig();
178
180
  }
179
181
 
182
+ function safeLaunchValue(value: unknown): unknown {
183
+ if (typeof value === "string") return redactCredentialBearingAbsoluteUrl(value);
184
+ if (Array.isArray(value)) return value.map(safeLaunchValue);
185
+ if (value && typeof value === "object")
186
+ return Object.fromEntries(
187
+ Object.entries(value).map(([key, item]) => [key, safeLaunchValue(item)]),
188
+ );
189
+ return value;
190
+ }
191
+
180
192
  function formatLaunchParameterValue(value: unknown): string | null {
181
193
  if (value === undefined || value === null) {
182
194
  return null;
@@ -185,37 +197,31 @@ function formatLaunchParameterValue(value: unknown): string | null {
185
197
  const normalized = redactCredentialBearingAbsoluteUrl(value.trim());
186
198
  return normalized === "" ? null : normalized;
187
199
  }
188
- return String(value);
200
+ return typeof value === "object"
201
+ ? JSON.stringify(safeLaunchValue(value), null, 2)
202
+ : String(value);
189
203
  }
190
204
 
191
205
  function buildLaunchParameterRows(
192
206
  params: Record<string, unknown>,
193
207
  launcher: ReturnType<ProcessLauncherService["listUiLaunchers"]>[number] | null,
194
208
  ): ProcessLaunchConfigurationView["parameters"] {
195
- const rows: Array<ProcessLaunchConfigurationView["parameters"][number]> = [];
196
- const usedFieldIds = new Set<string>();
197
- for (const field of launcher?.launchConfigSchema.fields ?? []) {
198
- if (!Object.hasOwn(params, field.id)) {
199
- continue;
200
- }
201
- usedFieldIds.add(field.id);
202
- rows.push({
203
- fieldId: field.id,
204
- label: field.label || field.id,
205
- value: formatLaunchParameterValue(params[field.id]),
206
- });
207
- }
208
- for (const fieldId of Object.keys(params).sort((left, right) => left.localeCompare(right))) {
209
- if (usedFieldIds.has(fieldId)) {
210
- continue;
211
- }
212
- rows.push({
213
- fieldId,
214
- label: fieldId,
215
- value: formatLaunchParameterValue(params[fieldId]),
216
- });
217
- }
218
- return rows;
209
+ const fields = (launcher?.launchConfigSchema.fields ?? []).filter((field) =>
210
+ Object.hasOwn(params, field.id),
211
+ );
212
+ const declared = new Set(fields.map((field) => field.id));
213
+ return [
214
+ ...fields,
215
+ ...Object.keys(params)
216
+ .sort((left, right) => left.localeCompare(right))
217
+ .filter((id) => !declared.has(id))
218
+ .map((id) => ({ id, label: id })),
219
+ ].map(({ id, label }) => ({
220
+ fieldId: id,
221
+ label: label || id,
222
+ value: formatLaunchParameterValue(params[id]),
223
+ rawValue: safeLaunchValue(params[id]),
224
+ }));
219
225
  }
220
226
 
221
227
  export function buildProcessLaunchConfigurationView(
@@ -279,18 +285,57 @@ export function buildProcessRunDetailsView(
279
285
  const turns: ProcessRunTurnView[] = [];
280
286
 
281
287
  for (const [turnId, turnContract] of contract.turns) {
282
- if (turnContract.turnType !== "llm") {
283
- continue;
284
- }
285
288
  const turnDef = deps.processActionRegistry?.getTurnDefinition(process.processId, turnId);
286
- if (!turnDef || !isLlmTurnDefinition(turnDef)) {
289
+ if (!turnDef) continue;
290
+ const common = {
291
+ turnId,
292
+ description: turnDef.description,
293
+ consumedProducts: [...(turnContract.consumedProducts ?? [])],
294
+ };
295
+ if (turnDef.kind !== "llm") {
296
+ const actions =
297
+ turnDef.kind === "human"
298
+ ? Object.entries(turnDef.actions).map(([name, action]) => ({
299
+ name,
300
+ label: action.label,
301
+ description: action.description,
302
+ form: action.form,
303
+ }))
304
+ : [];
305
+ const outcomes =
306
+ turnDef.kind === "automatic"
307
+ ? Object.entries(turnDef.outcomes ?? {}).map(([name, outcome]) => ({
308
+ name,
309
+ description: outcome?.description,
310
+ parameters: outcome?.parameters,
311
+ }))
312
+ : [];
313
+ turns.push({
314
+ ...common,
315
+ pathType: "not_applicable",
316
+ publishedProducts: [...(turnContract.publishedProducts ?? [])],
317
+ activePiToolNames: [],
318
+ outcomeActions: [],
319
+ integrationToolNames: turnDef.kind === "automatic" ? (turnDef.integrationTools ?? []) : [],
320
+ definitionContract: {
321
+ kind: turnDef.kind,
322
+ actions,
323
+ outcomes,
324
+ reviewProduct: turnDef.kind === "human" ? turnDef.reviewProduct : undefined,
325
+ },
326
+ });
287
327
  continue;
288
328
  }
289
329
  turns.push({
290
- turnId,
291
- description: turnDef.description,
330
+ ...common,
292
331
  pathType: turnDef.branchType,
293
- consumedProducts: [...(turnContract.consumedProducts ?? [])],
332
+ definitionContract: {
333
+ kind: turnDef.kind,
334
+ context: turnDef.context,
335
+ modelPurpose: turnDef.modelPurpose ?? null,
336
+ askQuestions: turnDef.askQuestions ?? false,
337
+ },
338
+ integrationToolNames: turnDef.integrationTools ?? [],
294
339
  publishedProducts: [
295
340
  ...new Set(
296
341
  [turnContract.publishedProduct, ...(turnContract.publishedProducts ?? [])].filter(
@@ -318,7 +363,7 @@ export function buildProcessRunDetailsView(
318
363
  Object.entries(toolSpec.parameters) as [string, OutcomeToolParameterSpec][]
319
364
  ).map(([parameterName, parameterSpec]) => ({
320
365
  name: parameterName,
321
- type: parameterSpec.type,
366
+ type: parameterSpec.type ?? "union",
322
367
  description: parameterSpec.description,
323
368
  required: parameterSpec.required === true,
324
369
  })),
@@ -370,75 +415,71 @@ export interface NormalizedRecoveryModelRequest {
370
415
  providerOptions?: Record<string, string>;
371
416
  }
372
417
 
373
- function normalizeProviderOptions(
374
- value: unknown,
375
- ): { ok: true; value: Record<string, string> } | { ok: false; error: string } {
376
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
377
- return { ok: false, error: "providerOptions must be an object of string values" };
378
- }
379
- const entries = Object.entries(value);
380
- if (entries.length > 64) return { ok: false, error: "providerOptions has too many fields" };
381
- const result: Record<string, string> = {};
382
- for (const [key, option] of entries) {
383
- if (!key || key.length > 128 || typeof option !== "string" || option.length > 4096) {
384
- return { ok: false, error: "providerOptions contains an invalid field" };
385
- }
386
- result[key] = option;
387
- }
388
- return { ok: true, value: result };
389
- }
418
+ const modelRequestEntries = {
419
+ nextTurnModelProfileId: v.exactOptional(
420
+ v.pipe(
421
+ v.nullish(v.string("nextTurnModelProfileId must be a string or null")),
422
+ v.transform((value) => value?.trim() || null),
423
+ ),
424
+ ),
425
+ providerOptions: v.exactOptional(
426
+ v.pipe(
427
+ v.custom<Record<string, unknown>>(
428
+ isUnknownRecord,
429
+ "providerOptions must be an object of string values",
430
+ ),
431
+ v.maxEntries(64, "providerOptions has too many fields"),
432
+ v.guard(
433
+ (options): options is Record<string, string> =>
434
+ Object.entries(options).every(
435
+ ([key, value]) =>
436
+ key.length > 0 &&
437
+ key.length <= 128 &&
438
+ typeof value === "string" &&
439
+ value.length <= 4096,
440
+ ),
441
+ "providerOptions contains an invalid field",
442
+ ),
443
+ v.transform((options) => Object.assign({}, options)),
444
+ ),
445
+ ),
446
+ };
447
+ const promptSchema = v.exactOptional(
448
+ v.pipe(
449
+ v.nullish(v.string("prompt must be a string or null")),
450
+ v.transform((value) => value ?? null),
451
+ ),
452
+ );
390
453
 
391
454
  function parseModelRequest(
392
455
  value: unknown,
393
- input: { requestName: string; allowedKeys: readonly string[]; expectedShape: string },
394
- ):
395
- | { ok: true; body: Record<string, unknown>; request: NormalizedRecoveryModelRequest }
396
- | { ok: false; error: string } {
397
- if (value === undefined || value === null) {
398
- return {
399
- ok: true,
400
- body: {},
401
- request: {},
402
- };
403
- }
404
- const parsedValue = v.safeParse(unknownRecordSchema, value);
405
- if (!parsedValue.success) {
406
- return { ok: false, error: `${input.requestName} request body must be an object` };
407
- }
408
- const body = parsedValue.output;
409
- if (Object.keys(body).some((key) => !input.allowedKeys.includes(key))) {
410
- return {
411
- ok: false,
412
- error: `${input.requestName} request body must use ${input.expectedShape}`,
413
- };
414
- }
415
- const nextTurnModelProfileIdProvided = Object.hasOwn(body, "nextTurnModelProfileId");
416
- const modelProfileId = body.nextTurnModelProfileId;
417
- if (
418
- modelProfileId !== undefined &&
419
- modelProfileId !== null &&
420
- typeof modelProfileId !== "string"
421
- ) {
422
- return { ok: false, error: "nextTurnModelProfileId must be a string or null" };
423
- }
424
- const providerOptionsProvided = Object.hasOwn(body, "providerOptions");
425
- const providerOptions = providerOptionsProvided
426
- ? normalizeProviderOptions(body.providerOptions)
427
- : ({ ok: true, value: {} } as const);
428
- if (!providerOptions.ok) return providerOptions;
429
- return {
430
- ok: true,
431
- body,
432
- request: {
433
- ...(nextTurnModelProfileIdProvided
434
- ? {
435
- nextTurnModelProfileId:
436
- typeof modelProfileId === "string" ? modelProfileId.trim() || null : null,
437
- }
438
- : {}),
439
- ...(providerOptionsProvided ? { providerOptions: providerOptions.value } : {}),
440
- },
441
- };
456
+ requestName: "continue" | "recovery",
457
+ ): { ok: true; request: NormalizedContinueRequest } | { ok: false; error: string } {
458
+ const schema =
459
+ requestName === "continue"
460
+ ? v.object({ ...modelRequestEntries, prompt: promptSchema })
461
+ : v.object(modelRequestEntries);
462
+ const shape =
463
+ requestName === "continue"
464
+ ? "{ prompt, nextTurnModelProfileId, providerOptions }"
465
+ : "{ nextTurnModelProfileId, providerOptions }";
466
+ const parsed = v.safeParse(
467
+ v.pipe(
468
+ v.unknown(),
469
+ v.check(isUnknownRecord, `${requestName} request body must be an object`),
470
+ unknownRecordSchema,
471
+ v.check(
472
+ (body) => Object.keys(body).every((key) => Object.hasOwn(schema.entries, key)),
473
+ `${requestName} request body must use ${shape}`,
474
+ ),
475
+ schema,
476
+ ),
477
+ value ?? {},
478
+ { abortEarly: true },
479
+ );
480
+ return parsed.success
481
+ ? { ok: true, request: parsed.output }
482
+ : { ok: false, error: parsed.issues[0].message };
442
483
  }
443
484
 
444
485
  export function normalizeLauncherRequest(value: unknown):
@@ -467,25 +508,6 @@ export function normalizeLauncherRequest(value: unknown):
467
508
  };
468
509
  }
469
510
 
470
- export function normalizeActionRequest(value: unknown):
471
- | {
472
- ok: true;
473
- request: NormalizedScheduledActionInput;
474
- }
475
- | {
476
- ok: false;
477
- error: string;
478
- } {
479
- const parsed = parseActionRequestBody(value);
480
- if (!parsed.ok) {
481
- return { ok: false, error: parsed.error };
482
- }
483
- return {
484
- ok: true,
485
- request: parsed.value,
486
- };
487
- }
488
-
489
511
  function isScheduleRequestError(error: string): boolean {
490
512
  return (
491
513
  error === "schedule must be an object" ||
@@ -512,38 +534,13 @@ export function sendActionRequestNormalizationError(reply: FastifyReply, error:
512
534
  export function normalizeContinueRequest(
513
535
  value: unknown,
514
536
  ): { ok: true; request: NormalizedContinueRequest } | { ok: false; error: string } {
515
- const parsed = parseModelRequest(value, {
516
- requestName: "continue",
517
- allowedKeys: ["prompt", "nextTurnModelProfileId", "providerOptions"],
518
- expectedShape: "{ prompt, nextTurnModelProfileId, providerOptions }",
519
- });
520
- if (!parsed.ok) return parsed;
521
- if (
522
- parsed.body.prompt !== undefined &&
523
- parsed.body.prompt !== null &&
524
- typeof parsed.body.prompt !== "string"
525
- ) {
526
- return { ok: false, error: "prompt must be a string or null" };
527
- }
528
- const promptProvided = Object.hasOwn(parsed.body, "prompt");
529
- return {
530
- ok: true,
531
- request: {
532
- ...parsed.request,
533
- ...(promptProvided ? { prompt: parsed.body.prompt ?? null } : {}),
534
- },
535
- };
537
+ return parseModelRequest(value, "continue");
536
538
  }
537
539
 
538
540
  export function normalizeRecoveryModelRequest(
539
541
  value: unknown,
540
542
  ): { ok: true; request: NormalizedRecoveryModelRequest } | { ok: false; error: string } {
541
- const parsed = parseModelRequest(value, {
542
- requestName: "recovery",
543
- allowedKeys: ["nextTurnModelProfileId", "providerOptions"],
544
- expectedShape: "{ nextTurnModelProfileId, providerOptions }",
545
- });
546
- return parsed.ok ? { ok: true, request: parsed.request } : parsed;
543
+ return parseModelRequest(value, "recovery");
547
544
  }
548
545
 
549
546
  export function buildLauncherModelConfigSchema(
@@ -687,16 +684,10 @@ export function sendScheduledActionMutationResponse(
687
684
  export function mergeProcessEventWindowsAscending(
688
685
  windows: readonly (readonly ProcessEvent[])[],
689
686
  ): ProcessEvent[] {
690
- const eventsById = new Map<string, ProcessEvent>();
691
- for (const window of windows) {
692
- for (const event of window) {
693
- eventsById.set(event.id, event);
694
- }
695
- }
696
- return [...eventsById.values()].sort((left, right) => {
697
- const createdAtComparison = left.createdAt.localeCompare(right.createdAt);
698
- return createdAtComparison !== 0 ? createdAtComparison : left.id.localeCompare(right.id);
699
- });
687
+ return [...new Map(windows.flat().map((event) => [event.id, event])).values()].sort(
688
+ (left, right) =>
689
+ left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id),
690
+ );
700
691
  }
701
692
 
702
693
  export { getSelectedTurnSummaryForProcess };
@@ -3,6 +3,7 @@ import { registerFutureExecutionRoutes } from "./future-executions.js";
3
3
  import { registerLauncherRoutes } from "./launchers.js";
4
4
  import { registerProcessActionRoutes } from "./process-actions.js";
5
5
  import { registerProcessDetailRoutes } from "./process-detail.js";
6
+ import { registerProcessModelConfigRoutes } from "./process-model-config.js";
6
7
  import { registerProcessQuestionRoutes } from "./process-questions.js";
7
8
  import type { RouteDeps } from "./process-route-helpers.js";
8
9
  import { registerProcessSessionRoutes } from "./process-session.js";
@@ -12,6 +13,7 @@ export type { RouteDeps } from "./process-route-helpers.js";
12
13
 
13
14
  export function registerProcessRoutes(app: FastifyInstance, deps: RouteDeps) {
14
15
  registerProcessDetailRoutes(app, deps);
16
+ registerProcessModelConfigRoutes(app, deps);
15
17
  registerLauncherRoutes(app, deps, deps.futureExecutionLifecycle);
16
18
  registerFutureExecutionRoutes(app, deps, deps.futureExecutionLifecycle);
17
19
  registerProcessActionRoutes(app, deps, deps.futureExecutionLifecycle);
@@ -0,0 +1,173 @@
1
+ import type { FastifyInstance, FastifyRequest } from "fastify";
2
+ import { actorForRequest } from "../auth/fastify-auth.js";
3
+ import type { RepositoryBundle } from "../db/repositories.js";
4
+ import type { ProcessOperationCoordinator } from "../process-operation-coordinator.js";
5
+ import type { ScopedSettingsService } from "../scoped-settings-service.js";
6
+ import { SettingsError } from "../scoped-settings-service.js";
7
+
8
+ type Change = {
9
+ subjectId: string;
10
+ key: string;
11
+ value?: unknown;
12
+ mode?: "replace";
13
+ reset?: boolean;
14
+ expectedRevision: number;
15
+ };
16
+
17
+ function parseChange(value: unknown): Change {
18
+ if (!value || typeof value !== "object" || Array.isArray(value))
19
+ throw new SettingsError("Expected a settings change", 400);
20
+ const raw = value as Record<string, unknown>;
21
+ if (
22
+ typeof raw.subjectId !== "string" ||
23
+ typeof raw.key !== "string" ||
24
+ !Number.isSafeInteger(raw.expectedRevision) ||
25
+ Number(raw.expectedRevision) < 0 ||
26
+ (raw.mode !== undefined && raw.mode !== "replace") ||
27
+ (raw.reset !== undefined && typeof raw.reset !== "boolean") ||
28
+ (!raw.reset && !Object.hasOwn(raw, "value"))
29
+ )
30
+ throw new SettingsError(
31
+ "Provide subjectId, key, value, and expectedRevision; mode must be replace",
32
+ 400,
33
+ );
34
+ return raw as Change;
35
+ }
36
+
37
+ /** @internal */
38
+ export function registerSettingsRoutes(
39
+ app: FastifyInstance,
40
+ settings: ScopedSettingsService,
41
+ repos: Pick<RepositoryBundle, "processes" | "turnStarts" | "projects" | "events"> & {
42
+ processOperations: ProcessOperationCoordinator;
43
+ broadcaster: import("../ws/broadcast.js").Broadcaster;
44
+ onSettingsChanged?: () => Promise<void>;
45
+ },
46
+ ) {
47
+ function normalizedChange(request: FastifyRequest) {
48
+ const change = parseChange(request.body);
49
+ return {
50
+ ...change,
51
+ value: change.value,
52
+ reset: change.reset ?? false,
53
+ actor: actorForRequest(request),
54
+ };
55
+ }
56
+ app.get("/api/settings/definitions", async () => ({ definitions: settings.definitions() }));
57
+ app.get("/api/settings/scopes", async () => settings.listScopes());
58
+ app.get<{ Querystring: { scopeType?: string } }>("/api/settings/overview", async (request) => {
59
+ if (!request.query.scopeType) throw new SettingsError("Provide scopeType", 400);
60
+ return settings.overview(request.query.scopeType);
61
+ });
62
+ app.post("/api/settings/scopes/refresh", async () => {
63
+ const scopes = await settings.refresh();
64
+ await repos.onSettingsChanged?.();
65
+ repos.broadcaster.sendDurable("settings.updated", { subjectId: "instance" });
66
+ return scopes;
67
+ });
68
+ app.get<{ Querystring: { subjectId?: string } }>("/api/settings/preview", async (request) =>
69
+ settings.preview(request.query.subjectId ?? "instance"),
70
+ );
71
+ app.get<{ Querystring: { subjectId: string; key: string; search?: string } }>(
72
+ "/api/settings/choices",
73
+ async (request) => {
74
+ if (!request.query.subjectId || !request.query.key)
75
+ throw new SettingsError("Provide subjectId and key", 400);
76
+ return {
77
+ choices: await settings.choices(
78
+ request.query.subjectId,
79
+ request.query.key,
80
+ request.query.search,
81
+ ),
82
+ };
83
+ },
84
+ );
85
+ app.post("/api/settings/preview", async (request) => {
86
+ return settings.previewDraft(normalizedChange(request));
87
+ });
88
+ app.put("/api/settings/overrides", async (request) => {
89
+ const change = normalizedChange(request);
90
+ settings.write(change);
91
+ await repos.onSettingsChanged?.();
92
+ repos.broadcaster.sendDurable("settings.updated", { subjectId: change.subjectId });
93
+ return settings.preview(change.subjectId);
94
+ });
95
+ app.put<{
96
+ Params: { instanceId: string };
97
+ Body: { primaryRepositoryKey: string | null; expectedPrimaryRepositoryKey: string | null };
98
+ }>("/api/settings/processes/:instanceId/primary-repository", async (request) => {
99
+ const result = await repos.processOperations.runExclusive(request.params.instanceId, () => {
100
+ const process = repos.processes.getById(request.params.instanceId);
101
+ if (!process) throw new SettingsError("Process not found", 404);
102
+ const body = request.body;
103
+ if (
104
+ !body ||
105
+ (body.primaryRepositoryKey !== null && typeof body.primaryRepositoryKey !== "string") ||
106
+ (body.expectedPrimaryRepositoryKey !== null &&
107
+ typeof body.expectedPrimaryRepositoryKey !== "string")
108
+ )
109
+ throw new SettingsError(
110
+ "Provide primaryRepositoryKey and expectedPrimaryRepositoryKey",
111
+ 400,
112
+ );
113
+ if ((process.metadata?.primaryRepositoryKey ?? null) !== body.expectedPrimaryRepositoryKey)
114
+ throw new SettingsError("Primary repository changed. Reload before saving again.", 409);
115
+ if (
116
+ body.primaryRepositoryKey !== null &&
117
+ !repos.projects
118
+ .listByInstance(process.id)
119
+ .some((project) => project.key === body.primaryRepositoryKey)
120
+ )
121
+ throw new SettingsError("Primary repository must belong to this process");
122
+ repos.processes.update(process.id, {
123
+ metadata: { ...process.metadata, primaryRepositoryKey: body.primaryRepositoryKey },
124
+ });
125
+ repos.events.create({
126
+ instanceId: process.id,
127
+ eventType: "settings.primary_repository_changed",
128
+ data: { primaryRepositoryKey: body.primaryRepositoryKey, actor: actorForRequest(request) },
129
+ });
130
+ return { primaryRepositoryKey: body.primaryRepositoryKey };
131
+ });
132
+ // Future execution coordination must run after releasing the process lock.
133
+ await repos.onSettingsChanged?.();
134
+ repos.broadcaster.sendDurable("settings.updated", { subjectId: "instance" });
135
+ return result;
136
+ });
137
+
138
+ app.get<{ Params: { instanceId: string } }>(
139
+ "/api/settings/processes/:instanceId",
140
+ async (request) => {
141
+ const process = repos.processes.getById(request.params.instanceId);
142
+ if (!process) throw new SettingsError("Process not found", 404);
143
+ const context = settings.forProcess(process);
144
+ const future = settings.previewProcess(process);
145
+ return {
146
+ primaryRepositoryKey: process.metadata?.primaryRepositoryKey ?? null,
147
+ future,
148
+ context: context.context,
149
+ explanations: context.explanations,
150
+ repositories: context.subjects.map(({ project, subject }) => ({
151
+ key: project.key,
152
+ subjectId: subject.id,
153
+ label: subject.label,
154
+ })),
155
+ captured: repos.turnStarts.listByInstance(process.id).flatMap((record) =>
156
+ record.state.kind !== "preparation_failed" &&
157
+ record.state.start?.kind === "llm" &&
158
+ record.state.start.scopedSettings
159
+ ? [
160
+ {
161
+ startRecordId: record.id,
162
+ turnId: record.turnId,
163
+ createdAt: record.createdAt,
164
+ state: record.state.kind,
165
+ settings: record.state.start.scopedSettings,
166
+ },
167
+ ]
168
+ : [],
169
+ ),
170
+ };
171
+ },
172
+ );
173
+ }
@@ -95,6 +95,9 @@ export function registerTicketCreationRoutes(
95
95
  tools: registry.ticketCatalog().map((tool) => ({
96
96
  name: tool.name,
97
97
  displayName: tool.capability.displayName,
98
+ descriptionFormat: tool.capability.descriptionFormat,
99
+ titlePath: tool.capability.titlePath,
100
+ descriptionPath: tool.capability.descriptionPath,
98
101
  })),
99
102
  }),
100
103
  );
@@ -109,6 +112,23 @@ export function registerTicketCreationRoutes(
109
112
  statusCode: 400,
110
113
  });
111
114
  }
115
+ const existing = deps.launchRuns.getByIdempotencyKey(idempotencyKey.trim());
116
+ if (existing?.instanceId) {
117
+ const relation = deps.processRelations.getByChild(existing.instanceId);
118
+ if (
119
+ existing.launcherId !== `ticket:${req.body.toolName}` ||
120
+ relation?.parentInstanceId !== req.params.instanceId ||
121
+ relation.purpose !== "ticket_creation"
122
+ ) {
123
+ return reply
124
+ .code(409)
125
+ .send({ error: "This launch key already belongs to another request" });
126
+ }
127
+ return {
128
+ childInstanceId: existing.instanceId,
129
+ relation,
130
+ } satisfies LaunchTicketCreationResponseBody;
131
+ }
112
132
  const tool = registry.resolveTicketTool(req.body.toolName);
113
133
  const { processId, startTurnId } = tool.capability;
114
134
  if (!hasProcessGraph(deps.processGraphs, processId)) {
@@ -120,6 +140,14 @@ export function registerTicketCreationRoutes(
120
140
  const destinationList = tool.capability.destinations
121
141
  ? await registry.listTicketDestinations(req.body.toolName, actor)
122
142
  : undefined;
143
+ if (destinationList && destinationList.destinations.length === 0) {
144
+ throw Object.assign(
145
+ new Error(
146
+ `No destinations are available in ${tool.capability.displayName}. Check project access and issue permissions, then try again.${destinationList.warnings?.length ? ` ${destinationList.warnings.join(" ")}` : ""}`,
147
+ ),
148
+ { statusCode: 503 },
149
+ );
150
+ }
123
151
  const { parent, context } = assembleContext(deps, req.params.instanceId, req.body);
124
152
  const launchPlan: ProcessLaunchPlan = {
125
153
  launcherId: `ticket:${req.body.toolName}`,
@@ -168,11 +196,6 @@ export function registerTicketCreationRoutes(
168
196
  }
169
197
  const relation = deps.processRelations.getByChild(launched.process.id);
170
198
  if (!relation) throw new Error("Ticket launch did not create its process relation");
171
- if (launched.error) {
172
- return reply
173
- .code(500)
174
- .send({ error: launched.error, childInstanceId: launched.process.id });
175
- }
176
199
  return {
177
200
  childInstanceId: launched.process.id,
178
201
  relation,