@leitwerk-dev/server 0.1.9 → 0.2.1

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 (1145) hide show
  1. package/dist/app-7PKX73TU.js +8 -0
  2. package/dist/app-7PKX73TU.js.map +1 -0
  3. package/dist/app-WfwKzrVk.d.ts +4869 -0
  4. package/dist/app.d.ts +58 -12
  5. package/dist/app.d.ts.map +1 -1
  6. package/dist/auth/api-token-audit.d.ts +3 -0
  7. package/dist/auth/api-token-audit.d.ts.map +1 -0
  8. package/dist/auth/api-token-policy.d.ts +8 -0
  9. package/dist/auth/api-token-policy.d.ts.map +1 -0
  10. package/dist/auth/api-token-routes.d.ts +4 -0
  11. package/dist/auth/api-token-routes.d.ts.map +1 -0
  12. package/dist/auth/api-token-service.d.ts +27 -0
  13. package/dist/auth/api-token-service.d.ts.map +1 -0
  14. package/dist/auth/auth-service.d.ts +3 -1
  15. package/dist/auth/auth-service.d.ts.map +1 -1
  16. package/dist/auth/auth-tokens.d.ts +4 -1
  17. package/dist/auth/auth-tokens.d.ts.map +1 -1
  18. package/dist/auth/fastify-auth.d.ts +10 -0
  19. package/dist/auth/fastify-auth.d.ts.map +1 -1
  20. package/dist/auth/routes.d.ts.map +1 -1
  21. package/dist/{chunk-DFHOPJRZ.js → chunk-CNITOV76.js} +18382 -16654
  22. package/dist/chunk-CNITOV76.js.map +1 -0
  23. package/dist/{chunk-2ESDXLNE.js → chunk-ZSKM25SD.js} +6857 -4531
  24. package/dist/chunk-ZSKM25SD.js.map +1 -0
  25. package/dist/config/config-loader.d.ts +11 -0
  26. package/dist/config/config-loader.d.ts.map +1 -1
  27. package/dist/config/config-types.d.ts +197 -63
  28. package/dist/config/config-types.d.ts.map +1 -1
  29. package/dist/db/api-token-repo.d.ts +57 -0
  30. package/dist/db/api-token-repo.d.ts.map +1 -0
  31. package/dist/db/auth-repo.d.ts +30 -0
  32. package/dist/db/auth-repo.d.ts.map +1 -1
  33. package/dist/db/credential-cipher.d.ts +8 -3
  34. package/dist/db/credential-cipher.d.ts.map +1 -1
  35. package/dist/db/database.d.ts +28 -11
  36. package/dist/db/database.d.ts.map +1 -1
  37. package/dist/db/external-write-log-repo.d.ts +8 -6
  38. package/dist/db/external-write-log-repo.d.ts.map +1 -1
  39. package/dist/db/future-execution-repo.d.ts +47 -2
  40. package/dist/db/future-execution-repo.d.ts.map +1 -1
  41. package/dist/db/launch-run-repo.d.ts +39 -0
  42. package/dist/db/launch-run-repo.d.ts.map +1 -0
  43. package/dist/db/launcher-recent-value-repo.d.ts +15 -1
  44. package/dist/db/launcher-recent-value-repo.d.ts.map +1 -1
  45. package/dist/db/pending-external-source-fire-repo.d.ts +33 -2
  46. package/dist/db/pending-external-source-fire-repo.d.ts.map +1 -1
  47. package/dist/db/process-event-repo.d.ts +21 -0
  48. package/dist/db/process-event-repo.d.ts.map +1 -1
  49. package/dist/db/process-handoff-dedup-key-repo.d.ts +10 -5
  50. package/dist/db/process-handoff-dedup-key-repo.d.ts.map +1 -1
  51. package/dist/db/process-input-repo.d.ts +17 -2
  52. package/dist/db/process-input-repo.d.ts.map +1 -1
  53. package/dist/db/process-instance-repo.d.ts +49 -0
  54. package/dist/db/process-instance-repo.d.ts.map +1 -1
  55. package/dist/db/process-leaf-outcome-snapshot-repo.d.ts +18 -0
  56. package/dist/db/process-leaf-outcome-snapshot-repo.d.ts.map +1 -1
  57. package/dist/db/process-project-repo.d.ts +21 -7
  58. package/dist/db/process-project-repo.d.ts.map +1 -1
  59. package/dist/db/process-question-request-repo.d.ts +19 -0
  60. package/dist/db/process-question-request-repo.d.ts.map +1 -1
  61. package/dist/db/process-relation-repo.d.ts +15 -0
  62. package/dist/db/process-relation-repo.d.ts.map +1 -0
  63. package/dist/db/process-skill-repo.d.ts +4 -0
  64. package/dist/db/process-skill-repo.d.ts.map +1 -1
  65. package/dist/db/process-title-job-repo.d.ts +31 -33
  66. package/dist/db/process-title-job-repo.d.ts.map +1 -1
  67. package/dist/db/process-tool-approval-request-repo.d.ts +47 -0
  68. package/dist/db/process-tool-approval-request-repo.d.ts.map +1 -0
  69. package/dist/db/process-turn-annotation-repo.d.ts +22 -2
  70. package/dist/db/process-turn-annotation-repo.d.ts.map +1 -1
  71. package/dist/db/process-turn-record-repo.d.ts +28 -15
  72. package/dist/db/process-turn-record-repo.d.ts.map +1 -1
  73. package/dist/db/provider-credential-repo.d.ts +16 -0
  74. package/dist/db/provider-credential-repo.d.ts.map +1 -1
  75. package/dist/db/repo-helpers.d.ts +2 -0
  76. package/dist/db/repo-helpers.d.ts.map +1 -1
  77. package/dist/db/repositories.d.ts +55 -0
  78. package/dist/db/repositories.d.ts.map +1 -1
  79. package/dist/db/schema-ddl.d.ts +0 -1
  80. package/dist/db/schema-ddl.d.ts.map +1 -1
  81. package/dist/db/schema.d.ts +2027 -1310
  82. package/dist/db/schema.d.ts.map +1 -1
  83. package/dist/db/session-transfer-repo.d.ts +112 -0
  84. package/dist/db/session-transfer-repo.d.ts.map +1 -0
  85. package/dist/db/skill-repo.d.ts +22 -2
  86. package/dist/db/skill-repo.d.ts.map +1 -1
  87. package/dist/db/startup-observation-repo.d.ts +10 -0
  88. package/dist/db/startup-observation-repo.d.ts.map +1 -0
  89. package/dist/db/ticket-destination-recent-repo.d.ts +33 -0
  90. package/dist/db/ticket-destination-recent-repo.d.ts.map +1 -0
  91. package/dist/db/turn-start-record-repo.d.ts +9 -0
  92. package/dist/db/turn-start-record-repo.d.ts.map +1 -1
  93. package/dist/db/turn-summary-repo.d.ts +43 -0
  94. package/dist/db/turn-summary-repo.d.ts.map +1 -0
  95. package/dist/db/worker-lease-repo.d.ts +37 -1
  96. package/dist/db/worker-lease-repo.d.ts.map +1 -1
  97. package/dist/deployment-preflight.d.ts +1 -1
  98. package/dist/deployment-preflight.d.ts.map +1 -1
  99. package/dist/docker-registry-credentials.d.ts +5 -0
  100. package/dist/docker-registry-credentials.d.ts.map +1 -0
  101. package/dist/domain-logic/outcome-tools.d.ts.map +1 -1
  102. package/dist/domain-logic/process-state-machine.d.ts +0 -5
  103. package/dist/domain-logic/process-state-machine.d.ts.map +1 -1
  104. package/dist/domain-logic/turn-record-guards.d.ts +2 -2
  105. package/dist/domain-logic/turn-record-guards.d.ts.map +1 -1
  106. package/dist/effects/post-commit-effect.d.ts +33 -6
  107. package/dist/effects/post-commit-effect.d.ts.map +1 -1
  108. package/dist/effects/post-commit-runner.d.ts +1 -0
  109. package/dist/effects/post-commit-runner.d.ts.map +1 -1
  110. package/dist/entry-ref-patch.d.ts +11 -0
  111. package/dist/entry-ref-patch.d.ts.map +1 -0
  112. package/dist/extension-ui/catalog.d.ts +20 -25
  113. package/dist/extension-ui/catalog.d.ts.map +1 -1
  114. package/dist/extensions/extension-host.d.ts +6 -0
  115. package/dist/extensions/extension-host.d.ts.map +1 -1
  116. package/dist/external-source-reporting.d.ts +4 -0
  117. package/dist/external-source-reporting.d.ts.map +1 -0
  118. package/dist/external-source-service.d.ts +13 -1
  119. package/dist/external-source-service.d.ts.map +1 -1
  120. package/dist/future-execution/execution.d.ts +26 -3
  121. package/dist/future-execution/execution.d.ts.map +1 -1
  122. package/dist/future-execution/index.d.ts +1 -1
  123. package/dist/future-execution/index.d.ts.map +1 -1
  124. package/dist/future-execution/launch-lifecycle.d.ts +212 -0
  125. package/dist/future-execution/launch-lifecycle.d.ts.map +1 -0
  126. package/dist/future-execution/lifecycle.d.ts +120 -77
  127. package/dist/future-execution/lifecycle.d.ts.map +1 -1
  128. package/dist/future-execution/model-projection.d.ts +6 -0
  129. package/dist/future-execution/model-projection.d.ts.map +1 -1
  130. package/dist/future-execution/reconciliation.d.ts.map +1 -1
  131. package/dist/future-execution/support.d.ts +11 -0
  132. package/dist/future-execution/support.d.ts.map +1 -1
  133. package/dist/future-execution/transition-planner.d.ts +25 -0
  134. package/dist/future-execution/transition-planner.d.ts.map +1 -1
  135. package/dist/future-execution-presenter.d.ts.map +1 -1
  136. package/dist/future-execution-scheduler.d.ts +1 -1
  137. package/dist/future-execution-scheduler.d.ts.map +1 -1
  138. package/dist/index.d.ts +3 -30
  139. package/dist/index.d.ts.map +1 -1
  140. package/dist/index.js +12 -29
  141. package/dist/index.js.map +1 -1
  142. package/dist/instance-tree.d.ts +3 -0
  143. package/dist/instance-tree.d.ts.map +1 -1
  144. package/dist/integration-tool-registry.d.ts +31 -6
  145. package/dist/integration-tool-registry.d.ts.map +1 -1
  146. package/dist/launch-coordinator-test-harness.d.ts +55 -0
  147. package/dist/launch-coordinator-test-harness.d.ts.map +1 -0
  148. package/dist/launch-coordinator.d.ts +105 -0
  149. package/dist/launch-coordinator.d.ts.map +1 -0
  150. package/dist/launch-idempotency.d.ts +17 -0
  151. package/dist/launch-idempotency.d.ts.map +1 -0
  152. package/dist/launch-pipeline.d.ts +165 -0
  153. package/dist/launch-pipeline.d.ts.map +1 -0
  154. package/dist/launcher-recent-values-service.d.ts +3 -0
  155. package/dist/launcher-recent-values-service.d.ts.map +1 -1
  156. package/dist/leaf-outcome-snapshot-capture.d.ts +1 -2
  157. package/dist/leaf-outcome-snapshot-capture.d.ts.map +1 -1
  158. package/dist/main.js +191 -71
  159. package/dist/main.js.map +1 -1
  160. package/dist/model-providers/builtin-server-adapter.d.ts +1 -0
  161. package/dist/model-providers/builtin-server-adapter.d.ts.map +1 -1
  162. package/dist/model-providers/credentials.d.ts +19 -4
  163. package/dist/model-providers/credentials.d.ts.map +1 -1
  164. package/dist/model-providers/model-status-cache.d.ts +30 -1
  165. package/dist/model-providers/model-status-cache.d.ts.map +1 -1
  166. package/dist/model-providers/provider-options.d.ts +21 -1
  167. package/dist/model-providers/provider-options.d.ts.map +1 -1
  168. package/dist/model-providers/registry.d.ts +22 -2
  169. package/dist/model-providers/registry.d.ts.map +1 -1
  170. package/dist/model-providers/server-adapters.d.ts +19 -0
  171. package/dist/model-providers/server-adapters.d.ts.map +1 -1
  172. package/dist/physical-worker-starts.d.ts +8 -0
  173. package/dist/physical-worker-starts.d.ts.map +1 -0
  174. package/dist/pi-resources/assemble.d.ts +24 -4
  175. package/dist/pi-resources/assemble.d.ts.map +1 -1
  176. package/dist/pi-resources/bundle-cache.d.ts +20 -1
  177. package/dist/pi-resources/bundle-cache.d.ts.map +1 -1
  178. package/dist/pi-resources/bundle-pin-lifecycle.d.ts +5 -1
  179. package/dist/pi-resources/bundle-pin-lifecycle.d.ts.map +1 -1
  180. package/dist/pi-resources/resource-collector.d.ts +12 -0
  181. package/dist/pi-resources/resource-collector.d.ts.map +1 -1
  182. package/dist/pi-session-tree.d.ts +13 -1
  183. package/dist/pi-session-tree.d.ts.map +1 -1
  184. package/dist/primary-path-snapshot.d.ts +0 -4
  185. package/dist/primary-path-snapshot.d.ts.map +1 -1
  186. package/dist/process-action-next-turn-model.d.ts +1 -1
  187. package/dist/process-action-next-turn-model.d.ts.map +1 -1
  188. package/dist/process-action-planner.d.ts +1 -1
  189. package/dist/process-action-planner.d.ts.map +1 -1
  190. package/dist/process-action-registry.d.ts +53 -7
  191. package/dist/process-action-registry.d.ts.map +1 -1
  192. package/dist/process-attention-notifier.d.ts.map +1 -1
  193. package/dist/process-deletion-service.d.ts +15 -0
  194. package/dist/process-deletion-service.d.ts.map +1 -1
  195. package/dist/process-engine/decision.d.ts +12 -0
  196. package/dist/process-engine/decision.d.ts.map +1 -1
  197. package/dist/process-engine/engine.d.ts +1 -0
  198. package/dist/process-engine/engine.d.ts.map +1 -1
  199. package/dist/process-engine/operation.d.ts +28 -4
  200. package/dist/process-engine/operation.d.ts.map +1 -1
  201. package/dist/process-engine/ops/abort-process.d.ts +1 -0
  202. package/dist/process-engine/ops/abort-process.d.ts.map +1 -1
  203. package/dist/process-engine/ops/abort-turn.d.ts.map +1 -1
  204. package/dist/process-engine/ops/continue-failed-turn.d.ts +2 -7
  205. package/dist/process-engine/ops/continue-failed-turn.d.ts.map +1 -1
  206. package/dist/process-engine/ops/execute-action.d.ts +2 -10
  207. package/dist/process-engine/ops/execute-action.d.ts.map +1 -1
  208. package/dist/process-engine/ops/retry-failed-turn.d.ts.map +1 -1
  209. package/dist/process-engine/ops/retry-startup.d.ts +2 -0
  210. package/dist/process-engine/ops/retry-startup.d.ts.map +1 -1
  211. package/dist/process-engine/ops/start-process.d.ts +1 -0
  212. package/dist/process-engine/ops/start-process.d.ts.map +1 -1
  213. package/dist/process-engine/ops/turn-failed.d.ts +1 -0
  214. package/dist/process-engine/ops/turn-failed.d.ts.map +1 -1
  215. package/dist/process-engine/ops/turn-outcome.d.ts +1 -0
  216. package/dist/process-engine/ops/turn-outcome.d.ts.map +1 -1
  217. package/dist/process-engine/ops/update-semantic-refs.d.ts.map +1 -1
  218. package/dist/process-engine/ops/worker-failure.d.ts.map +1 -1
  219. package/dist/process-engine/runner.d.ts +2 -2
  220. package/dist/process-engine/runner.d.ts.map +1 -1
  221. package/dist/process-engine/startup-reconciliation.d.ts +16 -2
  222. package/dist/process-engine/startup-reconciliation.d.ts.map +1 -1
  223. package/dist/process-engine/turn-start-preflight.d.ts.map +1 -1
  224. package/dist/process-engine/types.d.ts +118 -10
  225. package/dist/process-engine/types.d.ts.map +1 -1
  226. package/dist/process-engine/writes/build-continue-failed-turn-writes.d.ts +2 -5
  227. package/dist/process-engine/writes/build-continue-failed-turn-writes.d.ts.map +1 -1
  228. package/dist/process-engine/writes/build-process-abort-writes.d.ts.map +1 -1
  229. package/dist/process-engine/writes/build-process-action-writes.d.ts +1 -1
  230. package/dist/process-engine/writes/build-process-action-writes.d.ts.map +1 -1
  231. package/dist/process-engine/writes/build-process-park-writes.d.ts +3 -0
  232. package/dist/process-engine/writes/build-process-park-writes.d.ts.map +1 -1
  233. package/dist/process-engine/writes/build-recovery-start-writes.d.ts +21 -0
  234. package/dist/process-engine/writes/build-recovery-start-writes.d.ts.map +1 -0
  235. package/dist/process-engine/writes/build-retry-writes.d.ts +5 -5
  236. package/dist/process-engine/writes/build-retry-writes.d.ts.map +1 -1
  237. package/dist/process-engine/writes/build-server-transition-writes.d.ts +6 -1
  238. package/dist/process-engine/writes/build-server-transition-writes.d.ts.map +1 -1
  239. package/dist/process-engine/writes/build-turn-failed-writes.d.ts +6 -0
  240. package/dist/process-engine/writes/build-turn-failed-writes.d.ts.map +1 -1
  241. package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +9 -1
  242. package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
  243. package/dist/process-engine/writes/build-turn-selection-writes.d.ts +8 -1
  244. package/dist/process-engine/writes/build-turn-selection-writes.d.ts.map +1 -1
  245. package/dist/process-engine/writes/commit-writes.d.ts +15 -0
  246. package/dist/process-engine/writes/commit-writes.d.ts.map +1 -1
  247. package/dist/process-engine/writes/deferred-extension-events.d.ts +4 -0
  248. package/dist/process-engine/writes/deferred-extension-events.d.ts.map +1 -1
  249. package/dist/process-engine/writes/process-plan-collector.d.ts +14 -0
  250. package/dist/process-engine/writes/process-plan-collector.d.ts.map +1 -0
  251. package/dist/process-engine/writes/writes.d.ts +67 -0
  252. package/dist/process-engine/writes/writes.d.ts.map +1 -1
  253. package/dist/process-execution.d.ts +5 -0
  254. package/dist/process-execution.d.ts.map +1 -0
  255. package/dist/process-graph.d.ts +1 -1
  256. package/dist/process-graph.d.ts.map +1 -1
  257. package/dist/process-input-dispatch.d.ts +4 -8
  258. package/dist/process-input-dispatch.d.ts.map +1 -1
  259. package/dist/process-instance-tree-presenter.d.ts.map +1 -1
  260. package/dist/process-launch-executor.d.ts +38 -14
  261. package/dist/process-launch-executor.d.ts.map +1 -1
  262. package/dist/process-launch-pipeline-adapter.d.ts +17 -0
  263. package/dist/process-launch-pipeline-adapter.d.ts.map +1 -0
  264. package/dist/process-launch-plan.d.ts +2 -1
  265. package/dist/process-launch-plan.d.ts.map +1 -1
  266. package/dist/process-launcher-registry.d.ts.map +1 -1
  267. package/dist/process-model-policy/input.d.ts +1 -1
  268. package/dist/process-model-policy/input.d.ts.map +1 -1
  269. package/dist/process-model-policy/types.d.ts +157 -1
  270. package/dist/process-model-policy/types.d.ts.map +1 -1
  271. package/dist/process-model-selection.d.ts +1 -1
  272. package/dist/process-model-selection.d.ts.map +1 -1
  273. package/dist/process-operation-coordinator.d.ts +3 -0
  274. package/dist/process-operation-coordinator.d.ts.map +1 -1
  275. package/dist/process-operator-attention.d.ts.map +1 -1
  276. package/dist/process-overview-presenter.d.ts.map +1 -1
  277. package/dist/process-question-service.d.ts +36 -20
  278. package/dist/process-question-service.d.ts.map +1 -1
  279. package/dist/process-runtime-availability.d.ts +19 -0
  280. package/dist/process-runtime-availability.d.ts.map +1 -0
  281. package/dist/process-session-store.d.ts +15 -4
  282. package/dist/process-session-store.d.ts.map +1 -1
  283. package/dist/process-storage-size.d.ts +13 -0
  284. package/dist/process-storage-size.d.ts.map +1 -0
  285. package/dist/process-title-generator.d.ts +56 -0
  286. package/dist/process-title-generator.d.ts.map +1 -1
  287. package/dist/process-turn-navigation.d.ts +17 -0
  288. package/dist/process-turn-navigation.d.ts.map +1 -0
  289. package/dist/process-turn-trace.d.ts +13 -0
  290. package/dist/process-turn-trace.d.ts.map +1 -1
  291. package/dist/process-ui-registry.d.ts +2 -3
  292. package/dist/process-ui-registry.d.ts.map +1 -1
  293. package/dist/process-ui-snapshot-presenter.d.ts +96 -18
  294. package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
  295. package/dist/process-watcher-registry.d.ts +5 -0
  296. package/dist/process-watcher-registry.d.ts.map +1 -1
  297. package/dist/product-ref-state.d.ts +1 -0
  298. package/dist/product-ref-state.d.ts.map +1 -1
  299. package/dist/project-mutation-service.d.ts +19 -0
  300. package/dist/project-mutation-service.d.ts.map +1 -1
  301. package/dist/repository-credentials/service.d.ts +2 -2
  302. package/dist/repository-credentials/service.d.ts.map +1 -1
  303. package/dist/result-image-store.d.ts +20 -0
  304. package/dist/result-image-store.d.ts.map +1 -1
  305. package/dist/routes/bearer-token.d.ts +4 -0
  306. package/dist/routes/bearer-token.d.ts.map +1 -0
  307. package/dist/routes/internal-session-transfer-exports.d.ts +4 -0
  308. package/dist/routes/internal-session-transfer-exports.d.ts.map +1 -0
  309. package/dist/routes/internal-worker-auth.d.ts.map +1 -1
  310. package/dist/routes/internal-worker-session-snapshot.d.ts.map +1 -1
  311. package/dist/routes/launchers.d.ts.map +1 -1
  312. package/dist/routes/process-actions.d.ts.map +1 -1
  313. package/dist/routes/process-engine-http.d.ts.map +1 -1
  314. package/dist/routes/process-primary-path-assembler.d.ts.map +1 -1
  315. package/dist/routes/process-route-helpers.d.ts +43 -12
  316. package/dist/routes/process-route-helpers.d.ts.map +1 -1
  317. package/dist/routes/processes.d.ts.map +1 -1
  318. package/dist/routes/result-images.d.ts.map +1 -1
  319. package/dist/routes/session-transfers.d.ts +4 -0
  320. package/dist/routes/session-transfers.d.ts.map +1 -0
  321. package/dist/routes/skills.d.ts.map +1 -1
  322. package/dist/routes/ticket-creation.d.ts +5 -0
  323. package/dist/routes/ticket-creation.d.ts.map +1 -0
  324. package/dist/routes/ui-renderers.d.ts +4 -0
  325. package/dist/routes/ui-renderers.d.ts.map +1 -1
  326. package/dist/routes/watchers.d.ts +3 -0
  327. package/dist/routes/watchers.d.ts.map +1 -1
  328. package/dist/scheduled-action-preflight.d.ts +1 -1
  329. package/dist/scheduled-action-preflight.d.ts.map +1 -1
  330. package/dist/semantic-entry-ref-state.d.ts +3 -4
  331. package/dist/semantic-entry-ref-state.d.ts.map +1 -1
  332. package/dist/server-bootstrap/app-lifecycle.d.ts +24 -0
  333. package/dist/server-bootstrap/app-lifecycle.d.ts.map +1 -0
  334. package/dist/server-bootstrap/build-host-capabilities.d.ts +10 -9
  335. package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
  336. package/dist/server-bootstrap/load-extension-catalog.d.ts.map +1 -1
  337. package/dist/server-bootstrap/register-http.d.ts +2 -0
  338. package/dist/server-bootstrap/register-http.d.ts.map +1 -1
  339. package/dist/server-bootstrap/register-websocket.d.ts.map +1 -1
  340. package/dist/server-topology.d.ts +8 -1
  341. package/dist/server-topology.d.ts.map +1 -1
  342. package/dist/session-summary-projection.d.ts +12 -0
  343. package/dist/session-summary-projection.d.ts.map +1 -0
  344. package/dist/session-transfer-helper-relays.d.ts +60 -0
  345. package/dist/session-transfer-helper-relays.d.ts.map +1 -0
  346. package/dist/session-transfer-service.d.ts +155 -0
  347. package/dist/session-transfer-service.d.ts.map +1 -0
  348. package/dist/skills/catalog-service.d.ts +7 -0
  349. package/dist/skills/catalog-service.d.ts.map +1 -1
  350. package/dist/skills/invocation-detector.d.ts.map +1 -1
  351. package/dist/skills/skill-frontmatter.d.ts +0 -2
  352. package/dist/skills/skill-frontmatter.d.ts.map +1 -1
  353. package/dist/skills/source-importer.d.ts +9 -1
  354. package/dist/skills/source-importer.d.ts.map +1 -1
  355. package/dist/startup-evidence.d.ts +32 -0
  356. package/dist/startup-evidence.d.ts.map +1 -0
  357. package/dist/supervisor/accepted-turn-start-replay.d.ts +0 -1
  358. package/dist/supervisor/accepted-turn-start-replay.d.ts.map +1 -1
  359. package/dist/supervisor/adoption/worker-adoption-coordinator.d.ts +4 -5
  360. package/dist/supervisor/adoption/worker-adoption-coordinator.d.ts.map +1 -1
  361. package/dist/supervisor/diagnostic-trace-writer.d.ts +5 -0
  362. package/dist/supervisor/diagnostic-trace-writer.d.ts.map +1 -0
  363. package/dist/supervisor/ipc-handler.d.ts +34 -11
  364. package/dist/supervisor/ipc-handler.d.ts.map +1 -1
  365. package/dist/supervisor/record-worker-lifecycle-event.d.ts +10 -0
  366. package/dist/supervisor/record-worker-lifecycle-event.d.ts.map +1 -0
  367. package/dist/supervisor/stale-heartbeat-watchdog.d.ts +1 -1
  368. package/dist/supervisor/stale-heartbeat-watchdog.d.ts.map +1 -1
  369. package/dist/supervisor/startup-observer.d.ts +14 -0
  370. package/dist/supervisor/startup-observer.d.ts.map +1 -0
  371. package/dist/supervisor/worker-capacity-queue.d.ts +15 -0
  372. package/dist/supervisor/worker-capacity-queue.d.ts.map +1 -0
  373. package/dist/supervisor/worker-connect-token.d.ts +4 -3
  374. package/dist/supervisor/worker-connect-token.d.ts.map +1 -1
  375. package/dist/supervisor/worker-event-ingestor.d.ts +12 -0
  376. package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
  377. package/dist/supervisor/worker-lease-observer.d.ts +1 -0
  378. package/dist/supervisor/worker-lease-observer.d.ts.map +1 -1
  379. package/dist/supervisor/worker-shutdown-controller.d.ts.map +1 -1
  380. package/dist/supervisor/worker-start-payload-builder.d.ts +20 -5
  381. package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
  382. package/dist/supervisor/worker-storage-layout.d.ts +13 -0
  383. package/dist/supervisor/worker-storage-layout.d.ts.map +1 -1
  384. package/dist/supervisor/worker-supervisor.d.ts +55 -3
  385. package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
  386. package/dist/supervisor/worker-turn-ipc-recorder.d.ts +30 -1
  387. package/dist/supervisor/worker-turn-ipc-recorder.d.ts.map +1 -1
  388. package/dist/supervisor/worker-unit-reclaimer.d.ts +26 -0
  389. package/dist/supervisor/worker-unit-reclaimer.d.ts.map +1 -0
  390. package/dist/supervisor/worker-websocket-ipc.d.ts +37 -0
  391. package/dist/supervisor/worker-websocket-ipc.d.ts.map +1 -1
  392. package/dist/test-helpers/accepted-turn-start.d.ts +41 -0
  393. package/dist/test-helpers/accepted-turn-start.d.ts.map +1 -0
  394. package/dist/test-helpers/ipc-handler-harness.d.ts +3 -1
  395. package/dist/test-helpers/ipc-handler-harness.d.ts.map +1 -1
  396. package/dist/test-helpers/process-binding-fixtures.d.ts.map +1 -1
  397. package/dist/test-helpers/process-fixtures.d.ts +1 -6
  398. package/dist/test-helpers/process-fixtures.d.ts.map +1 -1
  399. package/dist/test-helpers/session-snapshot-fixtures.d.ts +4 -0
  400. package/dist/test-helpers/session-snapshot-fixtures.d.ts.map +1 -0
  401. package/dist/test-helpers/structural-process-fixtures.d.ts +2 -2
  402. package/dist/test-helpers/structural-process-fixtures.d.ts.map +1 -1
  403. package/dist/test-helpers/turn-start-preflight-fixtures.d.ts +8 -1
  404. package/dist/test-helpers/turn-start-preflight-fixtures.d.ts.map +1 -1
  405. package/dist/test-helpers/unit-deps.d.ts +10 -0
  406. package/dist/test-helpers/unit-deps.d.ts.map +1 -1
  407. package/dist/test-helpers/worker-runner-runtime.d.ts +3 -0
  408. package/dist/test-helpers/worker-runner-runtime.d.ts.map +1 -0
  409. package/dist/testing.d.ts +5 -6
  410. package/dist/testing.d.ts.map +1 -1
  411. package/dist/testing.js +360 -6
  412. package/dist/testing.js.map +1 -1
  413. package/dist/tool-approval-gate.d.ts +53 -0
  414. package/dist/tool-approval-gate.d.ts.map +1 -0
  415. package/dist/turn-preparation.d.ts +13 -0
  416. package/dist/turn-preparation.d.ts.map +1 -0
  417. package/dist/turn-progress.d.ts +1 -0
  418. package/dist/turn-progress.d.ts.map +1 -1
  419. package/dist/{semantic-turn-result-markdown.d.ts → turn-result-markdown.d.ts} +12 -5
  420. package/dist/turn-result-markdown.d.ts.map +1 -0
  421. package/dist/worker-runtime-profile-selection.d.ts +22 -7
  422. package/dist/worker-runtime-profile-selection.d.ts.map +1 -1
  423. package/dist/ws/broadcast.d.ts +10 -0
  424. package/dist/ws/broadcast.d.ts.map +1 -1
  425. package/package.json +13 -14
  426. package/src/app.ts +974 -755
  427. package/src/auth/api-token-audit.ts +25 -0
  428. package/src/auth/api-token-policy.ts +56 -0
  429. package/src/auth/api-token-routes.ts +113 -0
  430. package/src/auth/api-token-service.ts +118 -0
  431. package/src/auth/auth-service.ts +9 -1
  432. package/src/auth/auth-tokens.ts +22 -3
  433. package/src/auth/fastify-auth.ts +54 -13
  434. package/src/auth/routes.ts +6 -5
  435. package/src/config/config-loader.ts +157 -99
  436. package/src/config/config-types.ts +205 -76
  437. package/src/db/api-token-repo.ts +123 -0
  438. package/src/db/auth-repo.ts +39 -16
  439. package/src/db/credential-cipher.ts +8 -3
  440. package/src/db/database.ts +506 -70
  441. package/src/db/external-write-log-repo.ts +7 -6
  442. package/src/db/future-execution-repo.ts +63 -23
  443. package/src/db/launch-run-repo.ts +160 -0
  444. package/src/db/launcher-recent-value-repo.ts +37 -60
  445. package/src/db/pending-external-source-fire-repo.ts +39 -30
  446. package/src/db/process-event-repo.ts +137 -56
  447. package/src/db/process-handoff-dedup-key-repo.ts +10 -6
  448. package/src/db/process-input-repo.ts +33 -24
  449. package/src/db/process-instance-repo.ts +76 -40
  450. package/src/db/process-leaf-outcome-snapshot-repo.ts +20 -16
  451. package/src/db/process-project-repo.ts +32 -36
  452. package/src/db/process-question-request-repo.ts +32 -11
  453. package/src/db/process-relation-repo.ts +62 -0
  454. package/src/db/process-skill-repo.ts +4 -0
  455. package/src/db/process-title-job-repo.ts +113 -191
  456. package/src/db/process-tool-approval-request-repo.ts +168 -0
  457. package/src/db/process-turn-annotation-repo.ts +28 -21
  458. package/src/db/process-turn-record-repo.ts +44 -33
  459. package/src/db/provider-credential-repo.ts +20 -1
  460. package/src/db/repo-helpers.ts +15 -0
  461. package/src/db/repositories.ts +70 -4
  462. package/src/db/schema-ddl.ts +3 -10
  463. package/src/db/schema.ts +246 -12
  464. package/src/db/session-transfer-repo.ts +348 -0
  465. package/src/db/skill-repo.ts +88 -78
  466. package/src/db/startup-observation-repo.ts +43 -0
  467. package/src/db/ticket-destination-recent-repo.ts +106 -0
  468. package/src/db/turn-start-record-repo.ts +12 -1
  469. package/src/db/turn-summary-repo.ts +95 -0
  470. package/src/db/worker-lease-repo.ts +79 -12
  471. package/src/deployment-preflight.ts +10 -6
  472. package/src/docker-registry-credentials.ts +21 -0
  473. package/src/domain-logic/outcome-tools.ts +47 -134
  474. package/src/domain-logic/process-state-machine.ts +47 -94
  475. package/src/domain-logic/turn-record-guards.ts +4 -8
  476. package/src/effects/post-commit-effect.ts +51 -11
  477. package/src/effects/post-commit-runner.ts +34 -58
  478. package/src/entry-ref-patch.ts +64 -0
  479. package/src/extension-ui/catalog.ts +26 -42
  480. package/src/extensions/extension-host.ts +6 -0
  481. package/src/external-source-reporting.ts +37 -0
  482. package/src/external-source-service.ts +278 -301
  483. package/src/future-execution/execution.ts +168 -64
  484. package/src/future-execution/index.ts +2 -0
  485. package/src/future-execution/launch-lifecycle.ts +793 -0
  486. package/src/future-execution/lifecycle.ts +173 -658
  487. package/src/future-execution/model-projection.ts +6 -0
  488. package/src/future-execution/reconciliation.ts +10 -14
  489. package/src/future-execution/support.ts +20 -0
  490. package/src/future-execution/transition-planner.ts +25 -0
  491. package/src/future-execution-presenter.ts +18 -46
  492. package/src/future-execution-scheduler.ts +7 -6
  493. package/src/index.ts +5 -157
  494. package/src/instance-tree.ts +3 -0
  495. package/src/integration-tool-registry.ts +437 -33
  496. package/src/launch-coordinator-test-harness.ts +155 -0
  497. package/src/launch-coordinator.ts +769 -0
  498. package/src/launch-idempotency.ts +30 -0
  499. package/src/launch-pipeline.ts +456 -0
  500. package/src/launcher-recent-values-service.ts +3 -0
  501. package/src/leaf-outcome-snapshot-capture.ts +2 -20
  502. package/src/main.ts +3 -10
  503. package/src/model-providers/builtin-server-adapter.ts +26 -4
  504. package/src/model-providers/credentials.ts +27 -36
  505. package/src/model-providers/model-status-cache.ts +72 -71
  506. package/src/model-providers/provider-options.ts +25 -2
  507. package/src/model-providers/registry.ts +23 -6
  508. package/src/model-providers/server-adapters.ts +19 -0
  509. package/src/physical-worker-starts.ts +64 -0
  510. package/src/pi-resources/assemble.ts +28 -15
  511. package/src/pi-resources/bundle-cache.ts +37 -42
  512. package/src/pi-resources/bundle-pin-lifecycle.ts +14 -13
  513. package/src/pi-resources/resource-collector.ts +24 -29
  514. package/src/pi-session-tree.ts +13 -1
  515. package/src/primary-path-snapshot.ts +12 -29
  516. package/src/process-action-next-turn-model.ts +1 -4
  517. package/src/process-action-planner.ts +1 -1
  518. package/src/process-action-registry.ts +134 -183
  519. package/src/process-attention-notifier.ts +2 -8
  520. package/src/process-deletion-service.ts +69 -35
  521. package/src/process-engine/decision.ts +12 -0
  522. package/src/process-engine/engine.ts +17 -25
  523. package/src/process-engine/operation.ts +29 -5
  524. package/src/process-engine/ops/abort-process.ts +12 -9
  525. package/src/process-engine/ops/abort-turn.ts +5 -6
  526. package/src/process-engine/ops/continue-failed-turn.ts +4 -15
  527. package/src/process-engine/ops/execute-action.ts +5 -9
  528. package/src/process-engine/ops/retry-failed-turn.ts +2 -29
  529. package/src/process-engine/ops/retry-startup.ts +24 -4
  530. package/src/process-engine/ops/start-process.ts +10 -1
  531. package/src/process-engine/ops/turn-failed.ts +5 -3
  532. package/src/process-engine/ops/turn-outcome.ts +51 -47
  533. package/src/process-engine/ops/update-semantic-refs.ts +1 -9
  534. package/src/process-engine/ops/worker-failure.ts +15 -10
  535. package/src/process-engine/runner.ts +24 -47
  536. package/src/process-engine/startup-reconciliation.ts +33 -48
  537. package/src/process-engine/turn-start-preflight.ts +2 -14
  538. package/src/process-engine/types.ts +182 -24
  539. package/src/process-engine/writes/build-continue-failed-turn-writes.ts +17 -56
  540. package/src/process-engine/writes/build-process-abort-writes.ts +11 -34
  541. package/src/process-engine/writes/build-process-action-writes.ts +36 -150
  542. package/src/process-engine/writes/build-process-park-writes.ts +14 -14
  543. package/src/process-engine/writes/build-recovery-start-writes.ts +75 -0
  544. package/src/process-engine/writes/build-retry-writes.ts +13 -60
  545. package/src/process-engine/writes/build-server-transition-writes.ts +35 -87
  546. package/src/process-engine/writes/build-turn-failed-writes.ts +6 -0
  547. package/src/process-engine/writes/build-turn-outcome-writes.ts +23 -91
  548. package/src/process-engine/writes/build-turn-selection-writes.ts +31 -75
  549. package/src/process-engine/writes/commit-writes.ts +34 -8
  550. package/src/process-engine/writes/deferred-extension-events.ts +4 -0
  551. package/src/process-engine/writes/process-plan-collector.ts +77 -0
  552. package/src/process-engine/writes/writes.ts +104 -10
  553. package/src/process-execution.ts +10 -0
  554. package/src/process-graph.ts +0 -3
  555. package/src/process-input-dispatch.ts +3 -12
  556. package/src/process-instance-tree-presenter.ts +6 -23
  557. package/src/process-launch-executor.ts +110 -64
  558. package/src/process-launch-pipeline-adapter.ts +57 -0
  559. package/src/process-launch-plan.ts +19 -0
  560. package/src/process-launcher-registry.ts +38 -58
  561. package/src/process-model-policy/input.ts +5 -12
  562. package/src/process-model-policy/types.ts +195 -11
  563. package/src/process-model-selection.ts +1 -4
  564. package/src/process-operation-coordinator.ts +4 -4
  565. package/src/process-operator-attention.ts +2 -10
  566. package/src/process-overview-presenter.ts +30 -41
  567. package/src/process-question-service.ts +53 -11
  568. package/src/process-runtime-availability.ts +75 -0
  569. package/src/process-session-store.ts +28 -8
  570. package/src/process-storage-size.ts +45 -0
  571. package/src/process-title-generator.ts +127 -26
  572. package/src/process-turn-navigation.ts +27 -0
  573. package/src/process-turn-trace.ts +99 -202
  574. package/src/process-ui-registry.ts +7 -16
  575. package/src/process-ui-snapshot-presenter.ts +416 -200
  576. package/src/process-watcher-registry.ts +58 -50
  577. package/src/product-ref-state.ts +5 -70
  578. package/src/project-mutation-service.ts +22 -1
  579. package/src/repository-credentials/service.ts +40 -9
  580. package/src/result-image-store.ts +27 -2
  581. package/src/routes/bearer-token.ts +10 -0
  582. package/src/routes/internal-session-transfer-exports.ts +65 -0
  583. package/src/routes/internal-worker-auth.ts +2 -3
  584. package/src/routes/internal-worker-session-snapshot.ts +17 -31
  585. package/src/routes/launchers.ts +70 -6
  586. package/src/routes/process-actions.ts +12 -23
  587. package/src/routes/process-engine-http.ts +14 -16
  588. package/src/routes/process-primary-path-assembler.ts +2 -9
  589. package/src/routes/process-route-helpers.ts +84 -82
  590. package/src/routes/processes.ts +8 -0
  591. package/src/routes/result-images.ts +5 -9
  592. package/src/routes/session-transfers.ts +144 -0
  593. package/src/routes/skills.ts +3 -1
  594. package/src/routes/ticket-creation.ts +240 -0
  595. package/src/routes/ui-renderers.ts +4 -0
  596. package/src/routes/watchers.ts +3 -0
  597. package/src/scheduled-action-preflight.ts +1 -1
  598. package/src/semantic-entry-ref-state.ts +6 -85
  599. package/src/server-bootstrap/app-lifecycle.ts +150 -0
  600. package/src/server-bootstrap/build-host-capabilities.ts +29 -48
  601. package/src/server-bootstrap/load-extension-catalog.ts +4 -8
  602. package/src/server-bootstrap/register-http.ts +17 -1
  603. package/src/server-bootstrap/register-websocket.ts +3 -6
  604. package/src/server-topology.ts +8 -1
  605. package/src/session-summary-projection.ts +110 -0
  606. package/src/session-transfer-helper-relays.ts +232 -0
  607. package/src/session-transfer-service.ts +507 -0
  608. package/src/skills/catalog-service.ts +7 -0
  609. package/src/skills/invocation-detector.ts +1 -6
  610. package/src/skills/skill-frontmatter.ts +9 -5
  611. package/src/skills/source-importer.ts +40 -16
  612. package/src/startup-evidence.ts +370 -0
  613. package/src/supervisor/accepted-turn-start-replay.ts +1 -2
  614. package/src/supervisor/adoption/worker-adoption-coordinator.ts +22 -19
  615. package/src/supervisor/diagnostic-trace-writer.ts +18 -0
  616. package/src/supervisor/ipc-handler.ts +80 -55
  617. package/src/supervisor/record-worker-lifecycle-event.ts +18 -0
  618. package/src/supervisor/stale-heartbeat-watchdog.ts +41 -31
  619. package/src/supervisor/startup-observer.ts +98 -0
  620. package/src/supervisor/worker-capacity-queue.ts +72 -0
  621. package/src/supervisor/worker-connect-token.ts +5 -14
  622. package/src/supervisor/worker-event-ingestor.ts +83 -21
  623. package/src/supervisor/worker-lease-observer.ts +2 -0
  624. package/src/supervisor/worker-shutdown-controller.ts +14 -13
  625. package/src/supervisor/worker-start-payload-builder.ts +121 -77
  626. package/src/supervisor/worker-storage-layout.ts +20 -1
  627. package/src/supervisor/worker-supervisor.ts +352 -214
  628. package/src/supervisor/worker-turn-ipc-recorder.ts +119 -58
  629. package/src/supervisor/worker-unit-reclaimer.ts +139 -0
  630. package/src/supervisor/worker-websocket-ipc.ts +63 -23
  631. package/src/test-helpers/accepted-turn-start.ts +105 -0
  632. package/src/test-helpers/ipc-handler-harness.ts +5 -0
  633. package/src/test-helpers/process-binding-fixtures.ts +1 -5
  634. package/src/test-helpers/process-fixtures.ts +4 -35
  635. package/src/test-helpers/session-snapshot-fixtures.ts +20 -0
  636. package/src/test-helpers/structural-process-fixtures.ts +1 -10
  637. package/src/test-helpers/turn-start-preflight-fixtures.ts +8 -1
  638. package/src/test-helpers/unit-deps.ts +33 -1
  639. package/src/test-helpers/worker-runner-runtime.ts +32 -0
  640. package/src/testing.ts +5 -19
  641. package/src/tool-approval-gate.ts +145 -0
  642. package/src/turn-preparation.ts +53 -0
  643. package/src/turn-progress.ts +43 -27
  644. package/src/turn-result-markdown.ts +104 -0
  645. package/src/worker-runtime-profile-selection.ts +39 -14
  646. package/src/ws/broadcast.ts +20 -1
  647. package/dist/app.js +0 -922
  648. package/dist/app.js.map +0 -1
  649. package/dist/auth/auth-client.js +0 -19
  650. package/dist/auth/auth-client.js.map +0 -1
  651. package/dist/auth/auth-config.js +0 -52
  652. package/dist/auth/auth-config.js.map +0 -1
  653. package/dist/auth/auth-service.js +0 -133
  654. package/dist/auth/auth-service.js.map +0 -1
  655. package/dist/auth/auth-test-helpers.js +0 -30
  656. package/dist/auth/auth-test-helpers.js.map +0 -1
  657. package/dist/auth/auth-tokens.js +0 -11
  658. package/dist/auth/auth-tokens.js.map +0 -1
  659. package/dist/auth/fastify-auth.js +0 -20
  660. package/dist/auth/fastify-auth.js.map +0 -1
  661. package/dist/auth/github-oauth-client.js +0 -79
  662. package/dist/auth/github-oauth-client.js.map +0 -1
  663. package/dist/auth/oidc-client.js +0 -55
  664. package/dist/auth/oidc-client.js.map +0 -1
  665. package/dist/auth/routes.js +0 -74
  666. package/dist/auth/routes.js.map +0 -1
  667. package/dist/chunk-2ESDXLNE.js.map +0 -1
  668. package/dist/chunk-DFHOPJRZ.js.map +0 -1
  669. package/dist/commit-message-policy.js +0 -15
  670. package/dist/commit-message-policy.js.map +0 -1
  671. package/dist/config/config-loader.js +0 -838
  672. package/dist/config/config-loader.js.map +0 -1
  673. package/dist/config/config-types.js +0 -2
  674. package/dist/config/config-types.js.map +0 -1
  675. package/dist/config/index.js +0 -2
  676. package/dist/config/index.js.map +0 -1
  677. package/dist/config/url-policy.js +0 -25
  678. package/dist/config/url-policy.js.map +0 -1
  679. package/dist/db/auth-repo.js +0 -92
  680. package/dist/db/auth-repo.js.map +0 -1
  681. package/dist/db/credential-cipher.js +0 -47
  682. package/dist/db/credential-cipher.js.map +0 -1
  683. package/dist/db/database.js +0 -423
  684. package/dist/db/database.js.map +0 -1
  685. package/dist/db/external-write-log-repo.js +0 -49
  686. package/dist/db/external-write-log-repo.js.map +0 -1
  687. package/dist/db/future-execution-repo.js +0 -267
  688. package/dist/db/future-execution-repo.js.map +0 -1
  689. package/dist/db/index.js +0 -4
  690. package/dist/db/index.js.map +0 -1
  691. package/dist/db/launcher-recent-value-repo.js +0 -76
  692. package/dist/db/launcher-recent-value-repo.js.map +0 -1
  693. package/dist/db/pending-external-source-fire-repo.js +0 -108
  694. package/dist/db/pending-external-source-fire-repo.js.map +0 -1
  695. package/dist/db/process-event-repo.js +0 -98
  696. package/dist/db/process-event-repo.js.map +0 -1
  697. package/dist/db/process-handoff-dedup-key-repo.js +0 -34
  698. package/dist/db/process-handoff-dedup-key-repo.js.map +0 -1
  699. package/dist/db/process-input-repo.js +0 -90
  700. package/dist/db/process-input-repo.js.map +0 -1
  701. package/dist/db/process-instance-repo.js +0 -281
  702. package/dist/db/process-instance-repo.js.map +0 -1
  703. package/dist/db/process-leaf-outcome-snapshot-repo.js +0 -77
  704. package/dist/db/process-leaf-outcome-snapshot-repo.js.map +0 -1
  705. package/dist/db/process-project-repo.js +0 -129
  706. package/dist/db/process-project-repo.js.map +0 -1
  707. package/dist/db/process-question-request-repo.js +0 -99
  708. package/dist/db/process-question-request-repo.js.map +0 -1
  709. package/dist/db/process-skill-repo.js +0 -58
  710. package/dist/db/process-skill-repo.js.map +0 -1
  711. package/dist/db/process-title-job-repo.js +0 -173
  712. package/dist/db/process-title-job-repo.js.map +0 -1
  713. package/dist/db/process-turn-annotation-repo.js +0 -104
  714. package/dist/db/process-turn-annotation-repo.js.map +0 -1
  715. package/dist/db/process-turn-record-repo.js +0 -125
  716. package/dist/db/process-turn-record-repo.js.map +0 -1
  717. package/dist/db/provider-credential-repo.js +0 -60
  718. package/dist/db/provider-credential-repo.js.map +0 -1
  719. package/dist/db/repo-helpers.js +0 -20
  720. package/dist/db/repo-helpers.js.map +0 -1
  721. package/dist/db/repositories.js +0 -73
  722. package/dist/db/repositories.js.map +0 -1
  723. package/dist/db/schema-ddl.js +0 -99
  724. package/dist/db/schema-ddl.js.map +0 -1
  725. package/dist/db/schema.js +0 -475
  726. package/dist/db/schema.js.map +0 -1
  727. package/dist/db/skill-repo.js +0 -468
  728. package/dist/db/skill-repo.js.map +0 -1
  729. package/dist/db/turn-start-record-repo.js +0 -67
  730. package/dist/db/turn-start-record-repo.js.map +0 -1
  731. package/dist/db/worker-lease-repo.js +0 -109
  732. package/dist/db/worker-lease-repo.js.map +0 -1
  733. package/dist/deployment-preflight.js +0 -69
  734. package/dist/deployment-preflight.js.map +0 -1
  735. package/dist/domain-logic/cron.js +0 -25
  736. package/dist/domain-logic/cron.js.map +0 -1
  737. package/dist/domain-logic/outcome-tools.js +0 -267
  738. package/dist/domain-logic/outcome-tools.js.map +0 -1
  739. package/dist/domain-logic/process-state-machine.js +0 -140
  740. package/dist/domain-logic/process-state-machine.js.map +0 -1
  741. package/dist/domain-logic/scheduled-action-lock.js +0 -39
  742. package/dist/domain-logic/scheduled-action-lock.js.map +0 -1
  743. package/dist/domain-logic/turn-record-guards.js +0 -26
  744. package/dist/domain-logic/turn-record-guards.js.map +0 -1
  745. package/dist/domain-logic/worker-lease-lifecycle.js +0 -77
  746. package/dist/domain-logic/worker-lease-lifecycle.js.map +0 -1
  747. package/dist/effects/post-commit-effect.js +0 -8
  748. package/dist/effects/post-commit-effect.js.map +0 -1
  749. package/dist/effects/post-commit-runner.js +0 -215
  750. package/dist/effects/post-commit-runner.js.map +0 -1
  751. package/dist/extension-ui/catalog.js +0 -265
  752. package/dist/extension-ui/catalog.js.map +0 -1
  753. package/dist/extensions/extension-host.js +0 -34
  754. package/dist/extensions/extension-host.js.map +0 -1
  755. package/dist/external-source-service.js +0 -1036
  756. package/dist/external-source-service.js.map +0 -1
  757. package/dist/future-execution/execution.js +0 -309
  758. package/dist/future-execution/execution.js.map +0 -1
  759. package/dist/future-execution/index.js +0 -2
  760. package/dist/future-execution/index.js.map +0 -1
  761. package/dist/future-execution/lifecycle.js +0 -783
  762. package/dist/future-execution/lifecycle.js.map +0 -1
  763. package/dist/future-execution/model-projection.js +0 -98
  764. package/dist/future-execution/model-projection.js.map +0 -1
  765. package/dist/future-execution/reconciliation.js +0 -91
  766. package/dist/future-execution/reconciliation.js.map +0 -1
  767. package/dist/future-execution/support.js +0 -36
  768. package/dist/future-execution/support.js.map +0 -1
  769. package/dist/future-execution/transition-planner.js +0 -84
  770. package/dist/future-execution/transition-planner.js.map +0 -1
  771. package/dist/future-execution-broadcast.js +0 -13
  772. package/dist/future-execution-broadcast.js.map +0 -1
  773. package/dist/future-execution-presenter.js +0 -143
  774. package/dist/future-execution-presenter.js.map +0 -1
  775. package/dist/future-execution-scheduler.js +0 -37
  776. package/dist/future-execution-scheduler.js.map +0 -1
  777. package/dist/instance-tree.js +0 -41
  778. package/dist/instance-tree.js.map +0 -1
  779. package/dist/integration-tool-registry.js +0 -140
  780. package/dist/integration-tool-registry.js.map +0 -1
  781. package/dist/launch-title.js +0 -36
  782. package/dist/launch-title.js.map +0 -1
  783. package/dist/launcher-model-config-service.js +0 -73
  784. package/dist/launcher-model-config-service.js.map +0 -1
  785. package/dist/launcher-recent-values-service.js +0 -43
  786. package/dist/launcher-recent-values-service.js.map +0 -1
  787. package/dist/leaf-outcome-snapshot-capture.js +0 -101
  788. package/dist/leaf-outcome-snapshot-capture.js.map +0 -1
  789. package/dist/live-turn-projection.d.ts +0 -2
  790. package/dist/live-turn-projection.d.ts.map +0 -1
  791. package/dist/live-turn-projection.js +0 -2
  792. package/dist/live-turn-projection.js.map +0 -1
  793. package/dist/model-providers/builtin-server-adapter.js +0 -73
  794. package/dist/model-providers/builtin-server-adapter.js.map +0 -1
  795. package/dist/model-providers/credentials.js +0 -165
  796. package/dist/model-providers/credentials.js.map +0 -1
  797. package/dist/model-providers/index.js +0 -7
  798. package/dist/model-providers/index.js.map +0 -1
  799. package/dist/model-providers/model-status-cache.js +0 -220
  800. package/dist/model-providers/model-status-cache.js.map +0 -1
  801. package/dist/model-providers/provider-boundary-utils.js +0 -32
  802. package/dist/model-providers/provider-boundary-utils.js.map +0 -1
  803. package/dist/model-providers/provider-options.js +0 -76
  804. package/dist/model-providers/provider-options.js.map +0 -1
  805. package/dist/model-providers/registry.js +0 -138
  806. package/dist/model-providers/registry.js.map +0 -1
  807. package/dist/model-providers/server-adapters.js +0 -63
  808. package/dist/model-providers/server-adapters.js.map +0 -1
  809. package/dist/pi-resources/assemble.js +0 -275
  810. package/dist/pi-resources/assemble.js.map +0 -1
  811. package/dist/pi-resources/bundle-cache.js +0 -125
  812. package/dist/pi-resources/bundle-cache.js.map +0 -1
  813. package/dist/pi-resources/bundle-pin-lifecycle.js +0 -41
  814. package/dist/pi-resources/bundle-pin-lifecycle.js.map +0 -1
  815. package/dist/pi-resources/index.js +0 -4
  816. package/dist/pi-resources/index.js.map +0 -1
  817. package/dist/pi-resources/resource-collector.js +0 -163
  818. package/dist/pi-resources/resource-collector.js.map +0 -1
  819. package/dist/pi-session-tree.js +0 -106
  820. package/dist/pi-session-tree.js.map +0 -1
  821. package/dist/primary-path-snapshot.js +0 -246
  822. package/dist/primary-path-snapshot.js.map +0 -1
  823. package/dist/process-action-input-validation.js +0 -75
  824. package/dist/process-action-input-validation.js.map +0 -1
  825. package/dist/process-action-next-turn-model.js +0 -102
  826. package/dist/process-action-next-turn-model.js.map +0 -1
  827. package/dist/process-action-planner.js +0 -93
  828. package/dist/process-action-planner.js.map +0 -1
  829. package/dist/process-action-registry.js +0 -335
  830. package/dist/process-action-registry.js.map +0 -1
  831. package/dist/process-attention-notifier.js +0 -41
  832. package/dist/process-attention-notifier.js.map +0 -1
  833. package/dist/process-deletion-service.js +0 -48
  834. package/dist/process-deletion-service.js.map +0 -1
  835. package/dist/process-engine/decision.js +0 -22
  836. package/dist/process-engine/decision.js.map +0 -1
  837. package/dist/process-engine/engine.js +0 -168
  838. package/dist/process-engine/engine.js.map +0 -1
  839. package/dist/process-engine/index.js +0 -8
  840. package/dist/process-engine/index.js.map +0 -1
  841. package/dist/process-engine/internal-failures.js +0 -32
  842. package/dist/process-engine/internal-failures.js.map +0 -1
  843. package/dist/process-engine/operation.js +0 -4
  844. package/dist/process-engine/operation.js.map +0 -1
  845. package/dist/process-engine/ops/abort-process.js +0 -104
  846. package/dist/process-engine/ops/abort-process.js.map +0 -1
  847. package/dist/process-engine/ops/abort-turn.js +0 -48
  848. package/dist/process-engine/ops/abort-turn.js.map +0 -1
  849. package/dist/process-engine/ops/accept-worker-turn-start.js +0 -137
  850. package/dist/process-engine/ops/accept-worker-turn-start.js.map +0 -1
  851. package/dist/process-engine/ops/continue-failed-turn.js +0 -109
  852. package/dist/process-engine/ops/continue-failed-turn.js.map +0 -1
  853. package/dist/process-engine/ops/deferred-process-activation.js +0 -98
  854. package/dist/process-engine/ops/deferred-process-activation.js.map +0 -1
  855. package/dist/process-engine/ops/execute-action.js +0 -289
  856. package/dist/process-engine/ops/execute-action.js.map +0 -1
  857. package/dist/process-engine/ops/index.js +0 -17
  858. package/dist/process-engine/ops/index.js.map +0 -1
  859. package/dist/process-engine/ops/park-process.js +0 -14
  860. package/dist/process-engine/ops/park-process.js.map +0 -1
  861. package/dist/process-engine/ops/queue-inputs.js +0 -35
  862. package/dist/process-engine/ops/queue-inputs.js.map +0 -1
  863. package/dist/process-engine/ops/retry-failed-turn.js +0 -74
  864. package/dist/process-engine/ops/retry-failed-turn.js.map +0 -1
  865. package/dist/process-engine/ops/retry-startup.js +0 -65
  866. package/dist/process-engine/ops/retry-startup.js.map +0 -1
  867. package/dist/process-engine/ops/start-process.js +0 -20
  868. package/dist/process-engine/ops/start-process.js.map +0 -1
  869. package/dist/process-engine/ops/turn-failed.js +0 -34
  870. package/dist/process-engine/ops/turn-failed.js.map +0 -1
  871. package/dist/process-engine/ops/turn-outcome.js +0 -345
  872. package/dist/process-engine/ops/turn-outcome.js.map +0 -1
  873. package/dist/process-engine/ops/update-product-refs.js +0 -18
  874. package/dist/process-engine/ops/update-product-refs.js.map +0 -1
  875. package/dist/process-engine/ops/update-semantic-refs.js +0 -21
  876. package/dist/process-engine/ops/update-semantic-refs.js.map +0 -1
  877. package/dist/process-engine/ops/worker-failure.js +0 -81
  878. package/dist/process-engine/ops/worker-failure.js.map +0 -1
  879. package/dist/process-engine/reactions.js +0 -23
  880. package/dist/process-engine/reactions.js.map +0 -1
  881. package/dist/process-engine/recorder.js +0 -245
  882. package/dist/process-engine/recorder.js.map +0 -1
  883. package/dist/process-engine/runner.js +0 -206
  884. package/dist/process-engine/runner.js.map +0 -1
  885. package/dist/process-engine/startup-reconciliation.js +0 -130
  886. package/dist/process-engine/startup-reconciliation.js.map +0 -1
  887. package/dist/process-engine/state-json.js +0 -5
  888. package/dist/process-engine/state-json.js.map +0 -1
  889. package/dist/process-engine/turn-start-preflight.js +0 -229
  890. package/dist/process-engine/turn-start-preflight.js.map +0 -1
  891. package/dist/process-engine/turn-worker-requirement.js +0 -11
  892. package/dist/process-engine/turn-worker-requirement.js.map +0 -1
  893. package/dist/process-engine/types.js +0 -2
  894. package/dist/process-engine/types.js.map +0 -1
  895. package/dist/process-engine/worker-reconciliation.js +0 -29
  896. package/dist/process-engine/worker-reconciliation.js.map +0 -1
  897. package/dist/process-engine/writes/build-continue-failed-turn-writes.js +0 -95
  898. package/dist/process-engine/writes/build-continue-failed-turn-writes.js.map +0 -1
  899. package/dist/process-engine/writes/build-process-abort-writes.js +0 -64
  900. package/dist/process-engine/writes/build-process-abort-writes.js.map +0 -1
  901. package/dist/process-engine/writes/build-process-action-writes.js +0 -140
  902. package/dist/process-engine/writes/build-process-action-writes.js.map +0 -1
  903. package/dist/process-engine/writes/build-process-park-writes.js +0 -48
  904. package/dist/process-engine/writes/build-process-park-writes.js.map +0 -1
  905. package/dist/process-engine/writes/build-retry-writes.js +0 -83
  906. package/dist/process-engine/writes/build-retry-writes.js.map +0 -1
  907. package/dist/process-engine/writes/build-server-transition-writes.js +0 -75
  908. package/dist/process-engine/writes/build-server-transition-writes.js.map +0 -1
  909. package/dist/process-engine/writes/build-turn-failed-writes.js +0 -52
  910. package/dist/process-engine/writes/build-turn-failed-writes.js.map +0 -1
  911. package/dist/process-engine/writes/build-turn-outcome-writes.js +0 -170
  912. package/dist/process-engine/writes/build-turn-outcome-writes.js.map +0 -1
  913. package/dist/process-engine/writes/build-turn-selection-writes.js +0 -158
  914. package/dist/process-engine/writes/build-turn-selection-writes.js.map +0 -1
  915. package/dist/process-engine/writes/build-worker-failure-writes.js +0 -59
  916. package/dist/process-engine/writes/build-worker-failure-writes.js.map +0 -1
  917. package/dist/process-engine/writes/commit-writes.js +0 -252
  918. package/dist/process-engine/writes/commit-writes.js.map +0 -1
  919. package/dist/process-engine/writes/deferred-extension-events.js +0 -13
  920. package/dist/process-engine/writes/deferred-extension-events.js.map +0 -1
  921. package/dist/process-engine/writes/process-effects.js +0 -20
  922. package/dist/process-engine/writes/process-effects.js.map +0 -1
  923. package/dist/process-engine/writes/writes.js +0 -139
  924. package/dist/process-engine/writes/writes.js.map +0 -1
  925. package/dist/process-graph.js +0 -7
  926. package/dist/process-graph.js.map +0 -1
  927. package/dist/process-input-dispatch.js +0 -85
  928. package/dist/process-input-dispatch.js.map +0 -1
  929. package/dist/process-instance-tree-presenter.js +0 -202
  930. package/dist/process-instance-tree-presenter.js.map +0 -1
  931. package/dist/process-launch-executor.js +0 -310
  932. package/dist/process-launch-executor.js.map +0 -1
  933. package/dist/process-launch-plan-model-config.js +0 -22
  934. package/dist/process-launch-plan-model-config.js.map +0 -1
  935. package/dist/process-launch-plan.js +0 -64
  936. package/dist/process-launch-plan.js.map +0 -1
  937. package/dist/process-launcher-registry.js +0 -104
  938. package/dist/process-launcher-registry.js.map +0 -1
  939. package/dist/process-model-availability-recovery.js +0 -41
  940. package/dist/process-model-availability-recovery.js.map +0 -1
  941. package/dist/process-model-availability-transitions.js +0 -14
  942. package/dist/process-model-availability-transitions.js.map +0 -1
  943. package/dist/process-model-integrity-reconciler.js +0 -27
  944. package/dist/process-model-integrity-reconciler.js.map +0 -1
  945. package/dist/process-model-policy/construct.js +0 -94
  946. package/dist/process-model-policy/construct.js.map +0 -1
  947. package/dist/process-model-policy/evaluate.js +0 -163
  948. package/dist/process-model-policy/evaluate.js.map +0 -1
  949. package/dist/process-model-policy/fingerprint.js +0 -39
  950. package/dist/process-model-policy/fingerprint.js.map +0 -1
  951. package/dist/process-model-policy/index.js +0 -47
  952. package/dist/process-model-policy/index.js.map +0 -1
  953. package/dist/process-model-policy/input.js +0 -79
  954. package/dist/process-model-policy/input.js.map +0 -1
  955. package/dist/process-model-policy/integrity.js +0 -53
  956. package/dist/process-model-policy/integrity.js.map +0 -1
  957. package/dist/process-model-policy/launch.js +0 -171
  958. package/dist/process-model-policy/launch.js.map +0 -1
  959. package/dist/process-model-policy/project.js +0 -144
  960. package/dist/process-model-policy/project.js.map +0 -1
  961. package/dist/process-model-policy/stable-availability.js +0 -16
  962. package/dist/process-model-policy/stable-availability.js.map +0 -1
  963. package/dist/process-model-policy/types.js +0 -9
  964. package/dist/process-model-policy/types.js.map +0 -1
  965. package/dist/process-model-policy-presenter.js +0 -77
  966. package/dist/process-model-policy-presenter.js.map +0 -1
  967. package/dist/process-model-selection.js +0 -101
  968. package/dist/process-model-selection.js.map +0 -1
  969. package/dist/process-operation-coordinator.js +0 -23
  970. package/dist/process-operation-coordinator.js.map +0 -1
  971. package/dist/process-operator-attention.js +0 -149
  972. package/dist/process-operator-attention.js.map +0 -1
  973. package/dist/process-overview-presenter.js +0 -220
  974. package/dist/process-overview-presenter.js.map +0 -1
  975. package/dist/process-question-service.js +0 -131
  976. package/dist/process-question-service.js.map +0 -1
  977. package/dist/process-session-store.js +0 -210
  978. package/dist/process-session-store.js.map +0 -1
  979. package/dist/process-title-generator.js +0 -628
  980. package/dist/process-title-generator.js.map +0 -1
  981. package/dist/process-turn-trace.js +0 -482
  982. package/dist/process-turn-trace.js.map +0 -1
  983. package/dist/process-ui-registry.js +0 -22
  984. package/dist/process-ui-registry.js.map +0 -1
  985. package/dist/process-ui-snapshot-presenter.js +0 -894
  986. package/dist/process-ui-snapshot-presenter.js.map +0 -1
  987. package/dist/process-watcher-registry.js +0 -159
  988. package/dist/process-watcher-registry.js.map +0 -1
  989. package/dist/product-ref-state.js +0 -84
  990. package/dist/product-ref-state.js.map +0 -1
  991. package/dist/product-turn-result-markdown.d.ts +0 -9
  992. package/dist/product-turn-result-markdown.d.ts.map +0 -1
  993. package/dist/product-turn-result-markdown.js +0 -44
  994. package/dist/product-turn-result-markdown.js.map +0 -1
  995. package/dist/project-mutation-service.js +0 -68
  996. package/dist/project-mutation-service.js.map +0 -1
  997. package/dist/repository-credentials/service.js +0 -49
  998. package/dist/repository-credentials/service.js.map +0 -1
  999. package/dist/result-image-store.js +0 -85
  1000. package/dist/result-image-store.js.map +0 -1
  1001. package/dist/result-image-validation.js +0 -47
  1002. package/dist/result-image-validation.js.map +0 -1
  1003. package/dist/routes/future-executions.js +0 -62
  1004. package/dist/routes/future-executions.js.map +0 -1
  1005. package/dist/routes/internal-worker-auth.js +0 -33
  1006. package/dist/routes/internal-worker-auth.js.map +0 -1
  1007. package/dist/routes/internal-worker-session-snapshot.js +0 -172
  1008. package/dist/routes/internal-worker-session-snapshot.js.map +0 -1
  1009. package/dist/routes/launchers.js +0 -140
  1010. package/dist/routes/launchers.js.map +0 -1
  1011. package/dist/routes/process-actions.js +0 -210
  1012. package/dist/routes/process-actions.js.map +0 -1
  1013. package/dist/routes/process-detail.js +0 -110
  1014. package/dist/routes/process-detail.js.map +0 -1
  1015. package/dist/routes/process-diagnostics-assembler.js +0 -92
  1016. package/dist/routes/process-diagnostics-assembler.js.map +0 -1
  1017. package/dist/routes/process-engine-http.js +0 -82
  1018. package/dist/routes/process-engine-http.js.map +0 -1
  1019. package/dist/routes/process-primary-path-assembler.js +0 -67
  1020. package/dist/routes/process-primary-path-assembler.js.map +0 -1
  1021. package/dist/routes/process-questions.js +0 -12
  1022. package/dist/routes/process-questions.js.map +0 -1
  1023. package/dist/routes/process-route-helpers.js +0 -523
  1024. package/dist/routes/process-route-helpers.js.map +0 -1
  1025. package/dist/routes/process-session.js +0 -24
  1026. package/dist/routes/process-session.js.map +0 -1
  1027. package/dist/routes/processes.js +0 -15
  1028. package/dist/routes/processes.js.map +0 -1
  1029. package/dist/routes/result-images.js +0 -92
  1030. package/dist/routes/result-images.js.map +0 -1
  1031. package/dist/routes/skills.js +0 -35
  1032. package/dist/routes/skills.js.map +0 -1
  1033. package/dist/routes/ui-renderers.js +0 -40
  1034. package/dist/routes/ui-renderers.js.map +0 -1
  1035. package/dist/routes/watchers.js +0 -46
  1036. package/dist/routes/watchers.js.map +0 -1
  1037. package/dist/runtime-server-config.js +0 -46
  1038. package/dist/runtime-server-config.js.map +0 -1
  1039. package/dist/scheduled-action-preflight.js +0 -53
  1040. package/dist/scheduled-action-preflight.js.map +0 -1
  1041. package/dist/semantic-entry-ref-state.js +0 -97
  1042. package/dist/semantic-entry-ref-state.js.map +0 -1
  1043. package/dist/semantic-state-json.d.ts +0 -6
  1044. package/dist/semantic-state-json.d.ts.map +0 -1
  1045. package/dist/semantic-state-json.js +0 -6
  1046. package/dist/semantic-state-json.js.map +0 -1
  1047. package/dist/semantic-turn-result-markdown.d.ts.map +0 -1
  1048. package/dist/semantic-turn-result-markdown.js +0 -45
  1049. package/dist/semantic-turn-result-markdown.js.map +0 -1
  1050. package/dist/server-automatic-turn-drainer.d.ts +0 -13
  1051. package/dist/server-automatic-turn-drainer.d.ts.map +0 -1
  1052. package/dist/server-automatic-turn-drainer.js +0 -250
  1053. package/dist/server-automatic-turn-drainer.js.map +0 -1
  1054. package/dist/server-bootstrap/build-host-capabilities.js +0 -83
  1055. package/dist/server-bootstrap/build-host-capabilities.js.map +0 -1
  1056. package/dist/server-bootstrap/load-extension-catalog.js +0 -17
  1057. package/dist/server-bootstrap/load-extension-catalog.js.map +0 -1
  1058. package/dist/server-bootstrap/register-http.js +0 -52
  1059. package/dist/server-bootstrap/register-http.js.map +0 -1
  1060. package/dist/server-bootstrap/register-websocket.js +0 -111
  1061. package/dist/server-bootstrap/register-websocket.js.map +0 -1
  1062. package/dist/server-topology.js +0 -33
  1063. package/dist/server-topology.js.map +0 -1
  1064. package/dist/skills/catalog-service.js +0 -66
  1065. package/dist/skills/catalog-service.js.map +0 -1
  1066. package/dist/skills/invocation-detector.js +0 -54
  1067. package/dist/skills/invocation-detector.js.map +0 -1
  1068. package/dist/skills/skill-dependencies.js +0 -17
  1069. package/dist/skills/skill-dependencies.js.map +0 -1
  1070. package/dist/skills/skill-frontmatter.js +0 -13
  1071. package/dist/skills/skill-frontmatter.js.map +0 -1
  1072. package/dist/skills/skill-id.js +0 -3
  1073. package/dist/skills/skill-id.js.map +0 -1
  1074. package/dist/skills/source-importer.js +0 -105
  1075. package/dist/skills/source-importer.js.map +0 -1
  1076. package/dist/supervisor/accepted-turn-start-replay.js +0 -23
  1077. package/dist/supervisor/accepted-turn-start-replay.js.map +0 -1
  1078. package/dist/supervisor/adoption/adoption-plan.js +0 -25
  1079. package/dist/supervisor/adoption/adoption-plan.js.map +0 -1
  1080. package/dist/supervisor/adoption/worker-adoption-coordinator.js +0 -227
  1081. package/dist/supervisor/adoption/worker-adoption-coordinator.js.map +0 -1
  1082. package/dist/supervisor/idle-worker-ttl.js +0 -26
  1083. package/dist/supervisor/idle-worker-ttl.js.map +0 -1
  1084. package/dist/supervisor/ipc-handler.js +0 -281
  1085. package/dist/supervisor/ipc-handler.js.map +0 -1
  1086. package/dist/supervisor/stale-heartbeat-watchdog.js +0 -88
  1087. package/dist/supervisor/stale-heartbeat-watchdog.js.map +0 -1
  1088. package/dist/supervisor/synthetic-worker-failure.js +0 -21
  1089. package/dist/supervisor/synthetic-worker-failure.js.map +0 -1
  1090. package/dist/supervisor/worker-api-compatibility.js +0 -20
  1091. package/dist/supervisor/worker-api-compatibility.js.map +0 -1
  1092. package/dist/supervisor/worker-connect-token.js +0 -13
  1093. package/dist/supervisor/worker-connect-token.js.map +0 -1
  1094. package/dist/supervisor/worker-event-ingestor.js +0 -209
  1095. package/dist/supervisor/worker-event-ingestor.js.map +0 -1
  1096. package/dist/supervisor/worker-input-ack-handler.js +0 -37
  1097. package/dist/supervisor/worker-input-ack-handler.js.map +0 -1
  1098. package/dist/supervisor/worker-lease-observer.js +0 -79
  1099. package/dist/supervisor/worker-lease-observer.js.map +0 -1
  1100. package/dist/supervisor/worker-shutdown-controller.js +0 -68
  1101. package/dist/supervisor/worker-shutdown-controller.js.map +0 -1
  1102. package/dist/supervisor/worker-start-payload-builder.js +0 -286
  1103. package/dist/supervisor/worker-start-payload-builder.js.map +0 -1
  1104. package/dist/supervisor/worker-storage-layout.js +0 -60
  1105. package/dist/supervisor/worker-storage-layout.js.map +0 -1
  1106. package/dist/supervisor/worker-supervisor.js +0 -703
  1107. package/dist/supervisor/worker-supervisor.js.map +0 -1
  1108. package/dist/supervisor/worker-turn-ipc-recorder.js +0 -158
  1109. package/dist/supervisor/worker-turn-ipc-recorder.js.map +0 -1
  1110. package/dist/supervisor/worker-websocket-ipc.js +0 -230
  1111. package/dist/supervisor/worker-websocket-ipc.js.map +0 -1
  1112. package/dist/test-helpers/fake-worker-supervisor.js +0 -64
  1113. package/dist/test-helpers/fake-worker-supervisor.js.map +0 -1
  1114. package/dist/test-helpers/ipc-handler-harness.js +0 -314
  1115. package/dist/test-helpers/ipc-handler-harness.js.map +0 -1
  1116. package/dist/test-helpers/model-provider-fixtures.js +0 -8
  1117. package/dist/test-helpers/model-provider-fixtures.js.map +0 -1
  1118. package/dist/test-helpers/process-binding-fixtures.js +0 -121
  1119. package/dist/test-helpers/process-binding-fixtures.js.map +0 -1
  1120. package/dist/test-helpers/process-fixtures.js +0 -206
  1121. package/dist/test-helpers/process-fixtures.js.map +0 -1
  1122. package/dist/test-helpers/process-model-fixtures.js +0 -159
  1123. package/dist/test-helpers/process-model-fixtures.js.map +0 -1
  1124. package/dist/test-helpers/process-title-fixtures.js +0 -36
  1125. package/dist/test-helpers/process-title-fixtures.js.map +0 -1
  1126. package/dist/test-helpers/structural-process-fixtures.js +0 -24
  1127. package/dist/test-helpers/structural-process-fixtures.js.map +0 -1
  1128. package/dist/test-helpers/turn-fixtures.js +0 -148
  1129. package/dist/test-helpers/turn-fixtures.js.map +0 -1
  1130. package/dist/test-helpers/turn-start-preflight-fixtures.js +0 -34
  1131. package/dist/test-helpers/turn-start-preflight-fixtures.js.map +0 -1
  1132. package/dist/test-helpers/unit-deps.js +0 -106
  1133. package/dist/test-helpers/unit-deps.js.map +0 -1
  1134. package/dist/turn-progress.js +0 -108
  1135. package/dist/turn-progress.js.map +0 -1
  1136. package/dist/worker-runtime-profile-selection.js +0 -90
  1137. package/dist/worker-runtime-profile-selection.js.map +0 -1
  1138. package/dist/writes-DNXpryd0.d.ts +0 -6653
  1139. package/dist/ws/broadcast.js +0 -34
  1140. package/dist/ws/broadcast.js.map +0 -1
  1141. package/src/live-turn-projection.ts +0 -8
  1142. package/src/product-turn-result-markdown.ts +0 -70
  1143. package/src/semantic-state-json.ts +0 -18
  1144. package/src/semantic-turn-result-markdown.ts +0 -93
  1145. package/src/server-automatic-turn-drainer.ts +0 -316
@@ -0,0 +1,4869 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { CatalogPiContribution, ExtensionCatalog, DiscoveredExtensionEntry, LeitwerkRuntimeLane } from '@leitwerk-dev/extension-runtime';
3
+ import * as _leitwerk_dev_process_sdk from '@leitwerk-dev/process-sdk';
4
+ import { ServerExtensionEventMap, ModelProviderDefinition, ProviderCredentialStatus, ProviderAvailability, PiServerAdapter, HandoffDedupKeyRecordLike, ProcessActionDefinition, ServerProcessContext, ProcessActionPreviewDefinition, BuiltServerProcessDefinition, TurnDefinition, ExtensionProcessDefinition, ProcessActionExecutionSource, TurnAcceptanceState, ProcessActionSchedulingDefinition, ProcessLaunchPlan, LaunchPlanPreparationResultLike, QueuedProcessInputLike, ProcessLeafOutcomeDefinition, ServerExtensionEventName, DeferredProcessActivationSnapshotQuery, DeferredProcessActivationSnapshotResult, PreparedDeferredProcessActivation, DeferredProcessActivationOutcome, DeferredProcessActivationFailure, ProcessGraphRegistry, ActionExecutionResultLike, ProcessActionServiceLike, ProcessLaunchPlanServiceLike, ProcessLauncherService, ProgrammaticLaunchRequestLike, ProgrammaticLaunchResultLike, RegisteredProcessWatcherLike, ExternalSourceServiceLike, ProcessModelSelectionServiceLike, ProvidedCapability } from '@leitwerk-dev/process-sdk';
5
+ import { ProcessStateExportHelperRelay, ProcessStateExporter, WorkerRunner, ProcessVolume } from '@leitwerk-dev/worker-runners';
6
+ import { FastifyInstance } from 'fastify';
7
+ import { ConfigSnapshot, ServerConfigSnapshot, StorageConfigSnapshot, ComponentConfigSnapshot, WorkersConfigSnapshot, ProcessConfigSnapshot, NotificationsConfigSnapshot, SandboxConfigSnapshot, ExtensionLoadingConfigSnapshot } from '@leitwerk-dev/protocol/config-snapshot';
8
+ import { DockerNetworkConfig, PiResourceBundle, PiResourceProvenanceKind, WorkerQuestionResponsePayload, WorkerQuestionRequestedPayload, WorkerTurnFailedPayload, WorkerIntegrationToolRequestPayload, WorkerIntegrationToolResultPayload, WorkerIntegrationToolCancelPayload, WorkerTurnStartAcceptedPayload, WorkerCredentialUpdateResultPayload, IpcEnvelope, ServerToWorkerMessage, InputDelivery, WorkerTurnTerminalRecordedPayload } from '@leitwerk-dev/worker-protocol';
9
+ import { drizzle } from 'drizzle-orm/node-sqlite';
10
+ import * as _leitwerk_dev_protocol from '@leitwerk-dev/protocol';
11
+ import { LeafOutcomeRendererDescriptor, BrowserUiExtensionDescriptor, CompactTurnSummary, PrimaryPathUiSnapshot, TurnTracePreview, SkillSelection, SkillOptionSummary, SkillCatalogItem, InstalledSkillCatalogItem, SkillCatalogDetail, InstalledSkillCatalogDetail, WsFrame, KnownDurableWsFrameType, WsPayloadByType, KnownEphemeralWsFrameType, PrimaryPathEntrySnapshot, DurableWsFrameInput, ParsedLauncherRequestBody, LauncherModelConfigDefaults, LauncherValidationError, ParsedActionRequestBody, SkillsCatalogResponseBody } from '@leitwerk-dev/protocol';
12
+ import { Actor, StartupObservation, ExternalWriteLog, FutureExecutionScheduleKind, DurableModelSelection, FutureExecutionBlockReason, FutureExecutionKind, FutureExecution, LaunchOrigin, LaunchChecklistStep, LaunchRun, ProcessEvent, InputSource, InputKind, ProcessInputTarget, ProcessInput, ProcessCustomizableFields, TurnId, ProcessLifecycleStatus, CurrentExecutionRef, ModelSelectionKind, ProcessSelectedTurnModelSource, ProcessInstance, ProcessLeafOutcomeSnapshotStatus, ProcessLeafOutcomeSnapshot, ProcessProject, ProcessQuestionRequest, NormalizedQuestion, ProcessRelation, ProcessToolApprovalRequest, ProcessToolApprovalDestination, ToolApprovalStatus, TurnAnnotationReference, ProcessTurnAnnotation, ProcessTurnType, ProcessTurnRecordStatus, ModelSelectionProvenance, WorkerErrorClass, ProcessTurnRecordPathType, ProcessTurnRecord, TurnStartRecord, TurnStartRecordState, WorkerState, WorkerBootstrapReceipt, WorkerLease, ProcessTurnTerminalLifecycleStatus, ProcessSemanticEntryRefKey, LaunchModelConfigInput, TurnStartKind, QuestionAnswerDraft, ProcessProductRef, TurnFailedPayload, TurnOutcomePayload } from '@leitwerk-dev/domain';
13
+ import { ToolCallRendererDefinition } from '@leitwerk-dev/protocol/tool-renderer-contract';
14
+ import { ApiTokenMetadata, ProcessSelectedTurnSummary } from '@leitwerk-dev/protocol/http-contracts';
15
+ import { ExternalWriteLogRecordInput } from '@leitwerk-dev/external-writes/internal';
16
+ import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
17
+ import { SessionTransferAttemptWire, SessionTransferLimits, LeitwerkTransferManifestV1 } from '@leitwerk-dev/session-transfer';
18
+ import { SessionHeader, SessionEntry } from '@earendil-works/pi-coding-agent';
19
+ import * as node_stream from 'node:stream';
20
+ import { Readable, Transform } from 'node:stream';
21
+
22
+ /** @internal */
23
+ interface SkillRepositoryConfig {
24
+ /** @internal */
25
+ id: string;
26
+ /** @internal */
27
+ label?: string;
28
+ /** @internal */
29
+ url: string;
30
+ /** @internal */
31
+ ref: string;
32
+ /** Directory recursively scanned for skill directories. Defaults to `skills`. @internal */
33
+ path?: string;
34
+ }
35
+ /** @internal */
36
+ interface AuthSessionConfig {
37
+ /** @internal */
38
+ cookie_name?: string;
39
+ /** @internal */
40
+ ttl?: string;
41
+ }
42
+ /** @internal */
43
+ interface AuthOidcProviderConfig {
44
+ /** @internal */
45
+ id: string;
46
+ /** @internal */
47
+ kind: "oidc";
48
+ /** @internal */
49
+ issuer: string;
50
+ /** @internal */
51
+ client_id: string;
52
+ /** @internal */
53
+ client_secret: string;
54
+ /** @internal */
55
+ redirect_uri?: string;
56
+ /** @internal */
57
+ scopes?: string[];
58
+ /** @internal */
59
+ identity_claim?: string;
60
+ }
61
+ /** @internal */
62
+ interface AuthGithubProviderConfig {
63
+ /** @internal */
64
+ id: "github";
65
+ /** @internal */
66
+ kind: "oauth2";
67
+ /** @internal */
68
+ client_id: string;
69
+ /** @internal */
70
+ client_secret: string;
71
+ /** GitHub organization whose active members may sign in. @internal */
72
+ organization: string;
73
+ /** @internal */
74
+ redirect_uri?: string;
75
+ }
76
+ /** @internal */
77
+ type AuthProviderConfig = AuthOidcProviderConfig | AuthGithubProviderConfig;
78
+ /** @internal */
79
+ interface ApiTokensConfig {
80
+ /** @internal */
81
+ enabled?: boolean;
82
+ /** @internal */
83
+ default_ttl?: string;
84
+ /** @internal */
85
+ max_ttl?: string;
86
+ /** @internal */
87
+ allow_no_expiry?: boolean;
88
+ }
89
+ /** @internal */
90
+ interface AuthConfig {
91
+ /** @internal */
92
+ api_tokens?: ApiTokensConfig;
93
+ /** Only true enables authentication; omit or set false to keep the leitwerk unauthenticated. @internal */
94
+ enabled?: boolean;
95
+ /** @internal */
96
+ session?: AuthSessionConfig;
97
+ /** @internal */
98
+ providers?: AuthProviderConfig[];
99
+ /** Raw OIDC identity claim values that may sign in. GitHub uses organization membership. @internal */
100
+ allowlist?: string[];
101
+ }
102
+ /** @internal */
103
+ interface DockerProcessVolumeConfig {
104
+ /** `bind` mounts a host path; `named_volume` uses a Docker-managed volume. @internal */
105
+ mode: "bind" | "named_volume";
106
+ /** Host root under which per-process volumes are created (bind mode). @internal */
107
+ host_root: string;
108
+ /** Path inside the worker container where the volume is mounted. @internal */
109
+ mount_path: string;
110
+ }
111
+ /** @internal */
112
+ interface DockerPrivateDaemonConfig {
113
+ /** Exact isolation used for every Docker-requiring process. @internal */
114
+ isolation: "privileged" | "sysbox-runc";
115
+ }
116
+ /**
117
+ * Server-only Docker run-mode wiring. The worker never receives this block; it
118
+ * dials back over WebSocket using launcher-injected connect env.
119
+ */
120
+ /** @internal */
121
+ interface DockerRunnerConfig {
122
+ /** Docker Engine API socket (Podman/OrbStack/nerdctl compatible). @internal */
123
+ socket: string;
124
+ /** Shared private user-defined network for server + workers. @internal */
125
+ network: string;
126
+ /** Stable internal HTTP(S) base URL workers use for IPC, never a host IP. @internal */
127
+ server_url: string;
128
+ /** CA the worker trusts for internal TLS (self-signed ok on a private net). @internal */
129
+ server_ca_file?: string;
130
+ /** @internal */
131
+ process_volume: DockerProcessVolumeConfig;
132
+ /** Private daemon realization for Docker-requiring processes. @internal */
133
+ private_daemon?: DockerPrivateDaemonConfig;
134
+ }
135
+ /** @internal */
136
+ interface KubernetesProcessVolumeConfig {
137
+ /** Optional ready-volume target; zero stops replenishment. @internal */
138
+ pre_provision?: {
139
+ /** @internal */
140
+ count: number;
141
+ };
142
+ /** @internal */
143
+ storage_class_name?: string;
144
+ /** @internal */
145
+ size: string;
146
+ /** @internal */
147
+ access_modes: string[];
148
+ /** @internal */
149
+ mount_path: string;
150
+ }
151
+ /** @internal */
152
+ interface KubernetesDockerConfig {
153
+ /** Pod RuntimeClass selected for every Docker-requiring process. @internal */
154
+ runtime_class_name?: string;
155
+ /** Pod user-namespace policy passed directly to spec.hostUsers. @internal */
156
+ host_users?: boolean;
157
+ /** @internal Opt in to the verified gVisor Docker wrapper and guest capabilities. */
158
+ gvisor?: boolean;
159
+ /** StorageClass selected for the process's single retained PVC. @internal */
160
+ process_storage_class_name?: string;
161
+ /** @internal */
162
+ network?: DockerNetworkConfig;
163
+ }
164
+ /** @internal */
165
+ interface KubernetesHostAliasConfig {
166
+ /** @internal */
167
+ ip: string;
168
+ /** @internal */
169
+ hostnames: string[];
170
+ }
171
+ /** @internal */
172
+ interface KubernetesPodConfig {
173
+ /** @internal */
174
+ node_selector?: Record<string, string>;
175
+ /** @internal */
176
+ tolerations?: unknown[];
177
+ /** @internal */
178
+ annotations?: Record<string, string>;
179
+ /** @internal */
180
+ host_aliases?: KubernetesHostAliasConfig[];
181
+ }
182
+ /** @internal */
183
+ interface KubernetesImagePullSecretCopyConfig {
184
+ /** Secret name in the server namespace. @internal */
185
+ source_name: string;
186
+ /** Secret name created in each process namespace. @internal */
187
+ target_name: string;
188
+ }
189
+ /** Server-only Kubernetes run-mode wiring. @public */
190
+ interface LocalWorkerRunnerConfig {
191
+ /** Command used by the best-effort local dev/test runner. @internal */
192
+ command: string;
193
+ /** Arguments passed to the local worker command. @internal */
194
+ args: string[];
195
+ /** Explicit acknowledgement that Docker processes inherit host Docker authority. @public */
196
+ allow_host_docker?: boolean;
197
+ }
198
+ /** @internal */
199
+ interface KubernetesRunnerConfig {
200
+ /** Dedicated namespace where the singleton server runs. @internal */
201
+ server_namespace: string;
202
+ /** Safe DNS prefix used to derive one namespace per process instance. @internal */
203
+ process_namespace_prefix: string;
204
+ /** Stable in-cluster HTTP(S) base URL workers use to dial the server. @internal */
205
+ server_url: string;
206
+ /** Server-local CA bundle copied into process namespaces for worker TLS trust. @internal */
207
+ server_ca_file?: string;
208
+ /** Optional Kubernetes API URL override; defaults to the in-cluster service. @internal */
209
+ api_server_url?: string;
210
+ /** @internal */
211
+ default_worker_runtime_profile?: string;
212
+ /** @internal */
213
+ worker_service_account?: string;
214
+ /** @internal */
215
+ process_volume: KubernetesProcessVolumeConfig;
216
+ /** Trusted private-Docker realization. Incomplete blocks leave Docker processes unavailable. @internal */
217
+ docker?: KubernetesDockerConfig;
218
+ /** @internal */
219
+ pod?: KubernetesPodConfig;
220
+ /** @internal */
221
+ image_pull_secrets?: string[];
222
+ /** @internal */
223
+ image_pull_secret_copies?: KubernetesImagePullSecretCopyConfig[];
224
+ }
225
+ /** @internal */
226
+ interface WorkerRuntimeProfileCpuMemoryConfig {
227
+ /** @internal */
228
+ cpu?: string;
229
+ /** @internal */
230
+ memory?: string;
231
+ }
232
+ /** @internal */
233
+ interface DockerRegistryConfig {
234
+ /** Actual registry permissions are enforced by the registry, not this binding. @internal */
235
+ profiles: Record<string, {
236
+ /** @internal */
237
+ registry: string;
238
+ /** @internal */
239
+ username: string;
240
+ /** @internal */
241
+ password: string;
242
+ }>;
243
+ /** @internal */
244
+ process_bindings: Record<string, string[]>;
245
+ }
246
+ /** @internal */
247
+ interface WorkerRuntimeProfileResourcesConfig {
248
+ /** @internal */
249
+ requests?: WorkerRuntimeProfileCpuMemoryConfig;
250
+ /** @internal */
251
+ limits?: WorkerRuntimeProfileCpuMemoryConfig;
252
+ /** Back-compat shorthand interpreted as limits by Docker and manifest builders. @internal */
253
+ cpu?: string;
254
+ /** @internal */
255
+ memory?: string;
256
+ }
257
+ /**
258
+ * A reusable worker image selection authored only in leitwerk config.
259
+ * Repository branch content must never select an image.
260
+ */
261
+ /** @internal */
262
+ interface WorkerRuntimeProfileConfig {
263
+ /** Fully qualified image reference, ideally digest-pinned for production. @internal */
264
+ image: string;
265
+ /** @internal */
266
+ image_pull_policy?: string;
267
+ /** @internal */
268
+ resources?: WorkerRuntimeProfileResourcesConfig;
269
+ }
270
+ /**
271
+ * Server-only internal TLS for worker → server IPC. The server presents a cert
272
+ * with a SAN for the stable internal name; workers trust the signing CA handed
273
+ * to them via {@link DockerRunnerConfig.server_ca_file} or
274
+ * {@link KubernetesRunnerConfig.server_ca_file}. Public UI/API HTTPS is
275
+ * terminated separately by a reverse proxy. Disabled by default so local and
276
+ * parity runs stay on plain HTTP.
277
+ */
278
+ /** @internal */
279
+ interface CommitMessageTemplateConfig {
280
+ /** Human-readable instructions applied to generated commit messages. @internal */
281
+ rules: string;
282
+ }
283
+ /** @internal */
284
+ interface CommitMessageConfig {
285
+ /** Named, reusable formatting-rule templates. @internal */
286
+ templates: Record<string, CommitMessageTemplateConfig>;
287
+ /** Template used when a repository has no explicit mapping. Null/omitted uses built-in guidance. @internal */
288
+ default_template?: string | null;
289
+ /** Repository locator to template id. Locators are normalized before matching. @internal */
290
+ repositories: Record<string, string>;
291
+ }
292
+ /** @internal */
293
+ interface InternalTlsConfig {
294
+ /** @internal */
295
+ enabled: boolean;
296
+ /** PEM cert chain the server presents on the internal listener. @internal */
297
+ cert_file?: string;
298
+ /** PEM private key for {@link InternalTlsConfig.cert_file}. @internal */
299
+ key_file?: string;
300
+ /**
301
+ * Reserved for future worker client-certificate verification. Currently
302
+ * rejected by validation because workers do not receive client cert/key material.
303
+ */
304
+ /** @internal */
305
+ client_ca_file?: string;
306
+ }
307
+ /** @internal */
308
+ interface SessionTransferConfig {
309
+ /** @internal */
310
+ max_entries: number;
311
+ /** @internal */
312
+ max_logical_bytes: number;
313
+ /** @internal */
314
+ max_compressed_bytes: number;
315
+ }
316
+ /** @internal */
317
+ interface DevelopmentToolsConfig {
318
+ /** @internal */
319
+ install_timeout: string;
320
+ /** @internal */
321
+ local: {
322
+ /** @internal */
323
+ mise_command: string;
324
+ };
325
+ }
326
+ /** Server-owned config. `auth` and runner wiring are intentionally server-only and are not part of the worker ConfigSnapshot. @public */
327
+ interface LeitwerkConfig extends ConfigSnapshot {
328
+ /** @public */
329
+ server: ServerConfigSnapshot;
330
+ /** @public */
331
+ storage: StorageConfigSnapshot;
332
+ /** @internal */
333
+ components: Record<string, ComponentConfigSnapshot>;
334
+ /** @public */
335
+ workers: WorkersConfigSnapshot;
336
+ /** @internal */
337
+ development_tools: DevelopmentToolsConfig;
338
+ /** @public */
339
+ process_configs?: Record<string, ProcessConfigSnapshot>;
340
+ /** @internal */
341
+ notifications: NotificationsConfigSnapshot;
342
+ /** @internal */
343
+ sandbox: SandboxConfigSnapshot;
344
+ /** @public */
345
+ extension_loading: ExtensionLoadingConfigSnapshot;
346
+ /** Extension-owned config blocks, keyed by extension ID. @public */
347
+ extensions: Record<string, unknown>;
348
+ /** @internal */
349
+ auth?: AuthConfig;
350
+ /** Server-only Docker run-mode wiring; stripped from the worker snapshot. @internal */
351
+ docker?: DockerRunnerConfig;
352
+ /** Server-only credentials delivered exclusively through authenticated worker.start. @internal */
353
+ docker_registries?: DockerRegistryConfig;
354
+ /** Server-only Kubernetes run-mode wiring; stripped from the worker snapshot. @internal */
355
+ kubernetes?: KubernetesRunnerConfig;
356
+ /** Server-only best-effort local dev/test runner wiring; stripped from the worker snapshot. @public */
357
+ local_worker?: LocalWorkerRunnerConfig;
358
+ /** Reusable worker image selections; stripped from the worker snapshot. @internal */
359
+ worker_runtime_profiles?: Record<string, WorkerRuntimeProfileConfig>;
360
+ /** Server-only internal TLS for worker IPC; stripped from the worker snapshot. @internal */
361
+ internal_tls?: InternalTlsConfig;
362
+ /** Git repositories scanned for operator-managed skills. @internal */
363
+ skill_repositories?: SkillRepositoryConfig[];
364
+ /** Server-owned repository-aware commit-message generation rules. @internal */
365
+ commit_messages?: CommitMessageConfig;
366
+ /** Bounded archive and extraction ceilings for local session transfer. @internal */
367
+ session_transfer?: SessionTransferConfig;
368
+ }
369
+
370
+ /** @public */
371
+ type LeitwerkDb = ReturnType<typeof drizzle>;
372
+
373
+ /** @internal */
374
+ type ExtensionUiRendererLookup = Omit<LeafOutcomeRendererDescriptor, "ok">;
375
+ /** @internal */
376
+ type ExtensionUiBrowserModuleLookup = BrowserUiExtensionDescriptor;
377
+ /** @internal */
378
+ interface ExtensionUiAssetRoot {
379
+ /** @internal */
380
+ extensionManifestId: string;
381
+ /** @internal */
382
+ assetRootDir: string;
383
+ }
384
+ /** @internal */
385
+ interface ExtensionUiCatalog {
386
+ /** @internal */
387
+ getRenderer(rendererId: string): ExtensionUiRendererLookup | null;
388
+ /** @internal */
389
+ listBrowserModules(): readonly ExtensionUiBrowserModuleLookup[];
390
+ /** @internal */
391
+ getAssetRoot(extensionManifestId: string): ExtensionUiAssetRoot | null;
392
+ }
393
+
394
+ /**
395
+ * Server-side extension host. Mirrors the worker-side ProcessAPI.events pattern.
396
+ * Extensions register handlers for lifecycle events. The server emits events
397
+ * when IPC messages arrive or commands execute.
398
+ */
399
+ /** @internal */
400
+ type ExtensionEventHandler<T = unknown> = (payload: T) => void | Promise<void>;
401
+ /** @internal */
402
+ interface ExtensionHost<TEventMap extends object = ServerExtensionEventMap> {
403
+ /** @internal */
404
+ on<K extends keyof TEventMap & string>(event: K, handler: ExtensionEventHandler<TEventMap[K]>): void;
405
+ /** @internal */
406
+ off<K extends keyof TEventMap & string>(event: K, handler: ExtensionEventHandler<TEventMap[K]>): void;
407
+ /** @internal */
408
+ emit<K extends keyof TEventMap & string>(event: K, payload: TEventMap[K]): Promise<void>;
409
+ }
410
+
411
+ /** Application boundary for encrypted credential payloads. Callers supply deployment key material. @internal */
412
+ interface CredentialCipher {
413
+ /** @internal */
414
+ encrypt(plaintext: string): string;
415
+ /** @internal */
416
+ decrypt(ciphertext: string): string;
417
+ }
418
+
419
+ /** @internal */
420
+ interface ProviderCredentialRecord {
421
+ /** @internal */
422
+ providerId: string;
423
+ /** @internal */
424
+ revision: number;
425
+ /** @internal */
426
+ payload: string;
427
+ /** @internal */
428
+ createdAt: string;
429
+ /** @internal */
430
+ updatedAt: string;
431
+ }
432
+ /** @internal */
433
+ declare function createProviderCredentialRepo(db: LeitwerkDb, cipher: CredentialCipher): {
434
+ /** @internal */
435
+ count(): number;
436
+ /** @internal */
437
+ get(providerId: string): ProviderCredentialRecord | null;
438
+ /** @internal */
439
+ create(input: {
440
+ /** @internal */
441
+ providerId: string;
442
+ /** @internal */
443
+ payload: string;
444
+ }): ProviderCredentialRecord;
445
+ /** @internal */
446
+ compareAndSet(input: {
447
+ /** @internal */
448
+ providerId: string;
449
+ /** @internal */
450
+ expectedRevision: number;
451
+ /** @internal */
452
+ payload: string;
453
+ }): ProviderCredentialRecord | null;
454
+ };
455
+
456
+ /** @internal */
457
+ interface RegisteredModelProvider {
458
+ /** @internal */
459
+ readonly id: string;
460
+ /** @internal */
461
+ readonly ownerExtensionId: string;
462
+ /** @internal */
463
+ readonly packageName: string;
464
+ /** @internal */
465
+ readonly definition: ModelProviderDefinition;
466
+ /** The parsed, non-secret provider configuration fragment. @internal */
467
+ readonly config: unknown;
468
+ /** Configured credential seed, visible only to the credential service. @internal */
469
+ readonly configuredCredential: unknown | null;
470
+ /** @internal */
471
+ readonly piContribution: CatalogPiContribution | null;
472
+ }
473
+ /** @internal */
474
+ interface ModelProviderRegistry {
475
+ /** @internal */
476
+ readonly size: number;
477
+ /** @internal */
478
+ list(): readonly RegisteredModelProvider[];
479
+ /** @internal */
480
+ get(providerId: string): RegisteredModelProvider | null;
481
+ /** @internal */
482
+ require(providerId: string): RegisteredModelProvider;
483
+ }
484
+ /** @internal */
485
+ type ModelProviderCredentialStatusResolver = (provider: RegisteredModelProvider) => ProviderCredentialStatus | Promise<ProviderCredentialStatus>;
486
+
487
+ /** @internal */
488
+ interface CachedModelProfileStatus {
489
+ /** @internal */
490
+ readonly profileId: string;
491
+ /** @internal */
492
+ readonly providerId: string;
493
+ /** @internal */
494
+ readonly modelId: string;
495
+ /** @internal */
496
+ readonly availability: ProviderAvailability;
497
+ /** @internal */
498
+ readonly safeReason?: string;
499
+ /** @internal */
500
+ readonly checkedAt: string | null;
501
+ /** @internal */
502
+ readonly expiresAt: string | null;
503
+ }
504
+ /** @internal */
505
+ interface ModelAvailabilityTransition {
506
+ /** @internal */
507
+ readonly profileId: string;
508
+ /** @internal */
509
+ readonly from: ProviderAvailability;
510
+ /** @internal */
511
+ readonly to: ProviderAvailability;
512
+ }
513
+ /** @internal */
514
+ interface ModelStatusCacheSnapshot {
515
+ /** @internal */
516
+ readonly revision: number;
517
+ /** @internal */
518
+ readonly capturedAt: string;
519
+ /** @internal */
520
+ readonly profiles: readonly CachedModelProfileStatus[];
521
+ /** Present only on the refresh result that observed the transition. @internal */
522
+ readonly availabilityTransitions: readonly ModelAvailabilityTransition[];
523
+ }
524
+ /** @internal */
525
+ interface ModelStatusCache {
526
+ /** @internal */
527
+ refresh(): Promise<ModelStatusCacheSnapshot>;
528
+ /** @internal */
529
+ snapshot(): ModelStatusCacheSnapshot;
530
+ /** @internal */
531
+ get(profileId: string): CachedModelProfileStatus | null;
532
+ }
533
+
534
+ /** @internal */
535
+ interface ModelProviderServerAdapterRegistry {
536
+ /** @internal */
537
+ get(providerId: string): PiServerAdapter | null;
538
+ /** @internal */
539
+ require(providerId: string): PiServerAdapter;
540
+ /** @internal */
541
+ generateText(input: {
542
+ /** @internal */
543
+ profileId: string;
544
+ /** @internal */
545
+ prompt: string;
546
+ /** @internal */
547
+ systemPrompt: string;
548
+ /** @internal */
549
+ maxTokens: number;
550
+ /** @internal */
551
+ request: {
552
+ /** @internal */
553
+ timeoutMs?: number;
554
+ /** @internal */
555
+ maxRetries?: number;
556
+ /** @internal */
557
+ maxRetryDelayMs: number;
558
+ };
559
+ }): Promise<string>;
560
+ }
561
+
562
+ /** @internal */
563
+ type TokenProviderBinding = {
564
+ /** @internal */
565
+ id: string;
566
+ /** @internal */
567
+ kind: "oidc";
568
+ /** @internal */
569
+ issuer: string;
570
+ /** @internal */
571
+ identityClaim: string;
572
+ } | {
573
+ /** @internal */
574
+ id: string;
575
+ /** @internal */
576
+ kind: "oauth2";
577
+ /** @internal */
578
+ organization: string;
579
+ };
580
+ /** @internal */
581
+ interface ApiTokenOwner {
582
+ /** @internal */
583
+ kind: "user" | "anonymous";
584
+ /** @internal */
585
+ id: string;
586
+ /** @internal */
587
+ actor: Actor;
588
+ /** @internal */
589
+ providerBinding: TokenProviderBinding | null;
590
+ }
591
+ /** @internal */
592
+ interface ApiTokenRecord extends ApiTokenMetadata {
593
+ /** @internal */
594
+ secretHash: string;
595
+ /** @internal */
596
+ owner: ApiTokenOwner;
597
+ }
598
+ /** @internal */
599
+ declare function createApiTokenRepo(db: LeitwerkDb): {
600
+ /** @internal */
601
+ create({ owner, ...fields }: ApiTokenRecord): void;
602
+ /** @internal */
603
+ list(owner: ApiTokenOwner): ApiTokenRecord[];
604
+ /** @internal */
605
+ findByHash(hash: string): ApiTokenRecord | null;
606
+ /** @internal */
607
+ revoke(owner: ApiTokenOwner, id: string, at: string): boolean;
608
+ /** @internal */
609
+ revokeAll(owner: ApiTokenOwner, at: string): number;
610
+ /** @internal */
611
+ revokeAnonymous(at: string): number;
612
+ /** @internal */
613
+ touch(id: string, at: string): void;
614
+ };
615
+
616
+ /** @internal */
617
+ declare function createStartupObservationRepo(db: LeitwerkDb): {
618
+ /** @internal */
619
+ record(observation: StartupObservation): boolean;
620
+ /** @internal */
621
+ listByLease(workerLeaseId: string): StartupObservation[];
622
+ };
623
+
624
+ /** @internal */
625
+ interface SessionSummary {
626
+ /** @internal */
627
+ signature: string | null;
628
+ /** @internal */
629
+ leafId: string | null;
630
+ /** @internal */
631
+ primaryPath: Pick<PrimaryPathUiSnapshot, "currentLeaf" | "semanticEntryRefs" | "entryCount" | "turnAnnotations">;
632
+ /** @internal */
633
+ prompt: {
634
+ /** @internal */
635
+ text: string | null;
636
+ /** @internal */
637
+ createdAt: string | null;
638
+ };
639
+ /** @internal */
640
+ tracePreviewsByTurnRecordId: Record<string, TurnTracePreview>;
641
+ /** @internal */
642
+ continuationByTurnRecordId: Record<string, {
643
+ /** @internal */
644
+ hasProgress: boolean;
645
+ /** @internal */
646
+ userPrompt: string | null;
647
+ }>;
648
+ }
649
+ /** @internal */
650
+ declare function createTurnSummaryRepo(db: LeitwerkDb): {
651
+ /** @internal */
652
+ get(turnRecordId: string): CompactTurnSummary | null;
653
+ /** @internal */
654
+ put(instanceId: string, turnRecordId: string, summary: CompactTurnSummary): void;
655
+ /** @internal */
656
+ listByInstance(instanceId: string): Record<string, CompactTurnSummary>;
657
+ /** @internal */
658
+ getSession(instanceId: string): SessionSummary | null;
659
+ /** @internal */
660
+ putSession(instanceId: string, summary: SessionSummary): void;
661
+ /** @internal */
662
+ deleteSession(instanceId: string): void;
663
+ };
664
+
665
+ /** @internal */
666
+ interface AuthSessionRecord {
667
+ /** @internal */
668
+ idHash: string;
669
+ /** @internal */
670
+ actor: Actor;
671
+ /** @internal */
672
+ createdAt: string;
673
+ /** @internal */
674
+ expiresAt: string;
675
+ }
676
+ /** @internal */
677
+ interface AuthLoginFlowRecord {
678
+ /** @internal */
679
+ idHash: string;
680
+ /** @internal */
681
+ providerId: string;
682
+ /** @internal */
683
+ state: string;
684
+ /** @internal */
685
+ pkceVerifier: string;
686
+ /** @internal */
687
+ createdAt: string;
688
+ /** @internal */
689
+ expiresAt: string;
690
+ }
691
+ /** @internal */
692
+ declare function createAuthSessionRepo(db: LeitwerkDb): {
693
+ /** @internal */
694
+ create(input: {
695
+ /** @internal */
696
+ idHash: string;
697
+ /** @internal */
698
+ actor: Actor;
699
+ /** @internal */
700
+ expiresAt: string;
701
+ }): AuthSessionRecord;
702
+ /** @internal */
703
+ getValid(idHash: string, atIso?: string): AuthSessionRecord | null;
704
+ /** @internal */
705
+ delete(idHash: string): boolean;
706
+ /** @internal */
707
+ deleteExpired(atIso?: string): number;
708
+ };
709
+ /** @internal */
710
+ declare function createAuthLoginFlowRepo(db: LeitwerkDb): {
711
+ /** @internal */
712
+ create(input: {
713
+ /** @internal */
714
+ idHash: string;
715
+ /** @internal */
716
+ providerId: string;
717
+ /** @internal */
718
+ state: string;
719
+ /** @internal */
720
+ pkceVerifier: string;
721
+ /** @internal */
722
+ expiresAt: string;
723
+ }): AuthLoginFlowRecord;
724
+ /** @internal */
725
+ getValid(idHash: string, atIso?: string): AuthLoginFlowRecord | null;
726
+ /** @internal */
727
+ delete(idHash: string): boolean;
728
+ /** @internal */
729
+ deleteExpired(atIso?: string): number;
730
+ };
731
+
732
+ /** @internal */
733
+ interface CreateExternalWriteLogInput extends ExternalWriteLogRecordInput {
734
+ }
735
+ /** @public */
736
+ declare function createExternalWriteLogRepo(db: LeitwerkDb): {
737
+ /** @internal */
738
+ record(input: CreateExternalWriteLogInput): ExternalWriteLog;
739
+ /** @internal */
740
+ hasDedupKey(dedupKey: string): boolean;
741
+ /** @public */
742
+ listByInstance(instanceId: string): ExternalWriteLog[];
743
+ };
744
+
745
+ /** @internal */
746
+ interface FutureExecutionWritableFields {
747
+ /** @internal */
748
+ scheduleKind: FutureExecutionScheduleKind;
749
+ /** @internal */
750
+ processId: string;
751
+ /** @internal */
752
+ instanceId?: string | null;
753
+ /** @internal */
754
+ launcherId?: string | null;
755
+ /** @internal */
756
+ actionId?: string | null;
757
+ /** @internal */
758
+ payloadJson: string;
759
+ /** @internal */
760
+ cronExpression?: string | null;
761
+ /** @internal */
762
+ nextRunAt: string;
763
+ /** @internal */
764
+ modelSelection?: DurableModelSelection | null;
765
+ /** @internal */
766
+ blockedReason?: FutureExecutionBlockReason | null;
767
+ }
768
+ /** @internal */
769
+ interface CreateFutureExecutionInput extends FutureExecutionWritableFields {
770
+ /** @internal */
771
+ id?: string;
772
+ /** @internal */
773
+ kind: FutureExecutionKind;
774
+ }
775
+ /** @internal */
776
+ interface FutureExecutionOverviewQuery {
777
+ /** @internal */
778
+ query?: string;
779
+ /** @internal */
780
+ processType?: string;
781
+ /** @internal */
782
+ status?: "all" | "running" | "scheduled" | "needs_attention" | "completed" | "aborted";
783
+ /** @internal */
784
+ matchingLauncherIdsByTerm?: readonly (readonly string[])[];
785
+ }
786
+ /** @internal */
787
+ interface FutureExecutionOverviewPageQuery extends FutureExecutionOverviewQuery {
788
+ /** @internal */
789
+ limit: number;
790
+ /** @internal */
791
+ offset: number;
792
+ }
793
+ /** @internal */
794
+ interface FutureExecutionOverviewWindowQuery extends FutureExecutionOverviewQuery {
795
+ /** @internal */
796
+ limit: number;
797
+ /** @internal */
798
+ sortKey: "status" | "title" | "timeline";
799
+ /** @internal */
800
+ sortDirection: "asc" | "desc";
801
+ /** @internal */
802
+ launcherFallbackTitles: Readonly<Record<string, string>>;
803
+ }
804
+ /** @internal */
805
+ type UpdateFutureExecutionInput = Partial<FutureExecutionWritableFields>;
806
+ /** @internal */
807
+ declare function createFutureExecutionRepo(db: LeitwerkDb): {
808
+ /** @internal */
809
+ create(input: CreateFutureExecutionInput): FutureExecution;
810
+ /** @internal */
811
+ getById(id: string): FutureExecution | null;
812
+ /** @internal */
813
+ listAll(): FutureExecution[];
814
+ /** @internal */
815
+ countOverview(input: FutureExecutionOverviewQuery): number;
816
+ /** @internal */
817
+ listOverviewProcessTypes(input: Pick<FutureExecutionOverviewQuery, "query" | "status" | "matchingLauncherIdsByTerm">): {
818
+ /** @internal */
819
+ processId: string;
820
+ /** @internal */
821
+ value: number;
822
+ }[];
823
+ /** @internal */
824
+ listOverviewWindow(input: FutureExecutionOverviewWindowQuery): FutureExecution[];
825
+ /** @internal */
826
+ listOverviewPage(input: FutureExecutionOverviewPageQuery): {
827
+ /** @internal */
828
+ items: FutureExecution[];
829
+ /** @internal */
830
+ total: number;
831
+ };
832
+ /** @internal */
833
+ listByInstance(instanceId: string): FutureExecution[];
834
+ /** @internal */
835
+ listRunnableDue(asOf: string): FutureExecution[];
836
+ /** @internal */
837
+ listBlockedCronDue(asOf: string): FutureExecution[];
838
+ /** @internal */
839
+ getScheduledActionByInstance(instanceId: string): FutureExecution | null;
840
+ /** @internal */
841
+ updatePayloadJsonIfUnchanged(id: string, expectedPayloadJson: string, payloadJson: string): FutureExecution | null;
842
+ /** @internal */
843
+ update(id: string, input: UpdateFutureExecutionInput): FutureExecution | null;
844
+ /** @internal */
845
+ delete(id: string): boolean;
846
+ };
847
+
848
+ /** @internal */
849
+ interface CreateLaunchRunInput {
850
+ /** @internal */
851
+ launcherId: string | null;
852
+ /** @internal */
853
+ idempotencyKey?: string | null;
854
+ /** @internal */
855
+ origin: LaunchOrigin;
856
+ /** @internal */
857
+ steps: readonly LaunchChecklistStep[];
858
+ }
859
+ /** @internal */
860
+ declare function createLaunchRunRepo(db: LeitwerkDb): {
861
+ /** @internal */
862
+ create(input: CreateLaunchRunInput): LaunchRun;
863
+ /** @internal */
864
+ getById(id: string): LaunchRun | null;
865
+ /** @internal */
866
+ saveReplay(runId: string, payload: unknown): void;
867
+ /** @internal */
868
+ getReplay<T>(runId: string): T | null;
869
+ /** @internal */
870
+ deleteReplay(runId: string): void;
871
+ /** @internal */
872
+ getByIdempotencyKey(key: string): LaunchRun | null;
873
+ /** @internal */
874
+ archiveIdempotencyKey(id: string, key: string): void;
875
+ /** @internal */
876
+ listByInstance: (instanceId: string) => LaunchRun[];
877
+ /** @internal */
878
+ listIncomplete: () => LaunchRun[];
879
+ /** @internal */
880
+ compareAndSet(next: LaunchRun, expectedRevision: number): LaunchRun | null;
881
+ /** @internal */
882
+ update(id: string, mutate: (current: LaunchRun) => LaunchRun): LaunchRun | null;
883
+ };
884
+
885
+ /** @internal */
886
+ interface LauncherRecentValue {
887
+ /** @internal */
888
+ id: string;
889
+ /** @internal */
890
+ launcherId: string;
891
+ /** @internal */
892
+ fieldId: string;
893
+ /** @internal */
894
+ value: string;
895
+ /** @internal */
896
+ createdAt: string;
897
+ /** @internal */
898
+ updatedAt: string;
899
+ }
900
+ /** @internal */
901
+ declare function createLauncherRecentValueRepo(db: LeitwerkDb): {
902
+ /** @internal */
903
+ listByLauncher(launcherId: string): LauncherRecentValue[];
904
+ /** @internal */
905
+ recordValue(input: {
906
+ /** @internal */
907
+ launcherId: string;
908
+ /** @internal */
909
+ fieldId: string;
910
+ /** @internal */
911
+ value: string;
912
+ /** @internal */
913
+ limit?: number;
914
+ }): LauncherRecentValue;
915
+ /** @internal */
916
+ pruneField(launcherId: string, fieldId: string, limit?: number): void;
917
+ };
918
+
919
+ /** @internal */
920
+ interface PendingExternalSourceFire {
921
+ /** @internal */
922
+ id: string;
923
+ /** @internal */
924
+ instanceId: string;
925
+ /** @internal */
926
+ armingId: string;
927
+ /** @internal */
928
+ turnId: string;
929
+ /** @internal */
930
+ externalActionId: string;
931
+ /** @internal */
932
+ sourceKind: string;
933
+ /** @internal */
934
+ input: Record<string, unknown>;
935
+ /** @internal */
936
+ event: Record<string, unknown>;
937
+ /** @internal */
938
+ mergeKey: string | null;
939
+ /** @internal */
940
+ queuedCount: number;
941
+ /** @internal */
942
+ createdAt: string;
943
+ /** @internal */
944
+ updatedAt: string;
945
+ }
946
+ /** @internal */
947
+ interface CreatePendingExternalSourceFireInput {
948
+ /** @internal */
949
+ instanceId: string;
950
+ /** @internal */
951
+ armingId: string;
952
+ /** @internal */
953
+ turnId: string;
954
+ /** @internal */
955
+ externalActionId: string;
956
+ /** @internal */
957
+ sourceKind?: string;
958
+ /** @internal */
959
+ input?: Record<string, unknown>;
960
+ /** @internal */
961
+ event?: Record<string, unknown>;
962
+ /** @internal */
963
+ mergeKey?: string | null;
964
+ /** @internal */
965
+ queuedCount?: number;
966
+ }
967
+ /** @internal */
968
+ interface UpdatePendingExternalSourceFireInput {
969
+ /** @internal */
970
+ input?: Record<string, unknown>;
971
+ /** @internal */
972
+ event?: Record<string, unknown>;
973
+ /** @internal */
974
+ queuedCount?: number;
975
+ }
976
+ /** @internal */
977
+ declare function createPendingExternalSourceFireRepo(db: LeitwerkDb): {
978
+ /** @internal */
979
+ create(input: CreatePendingExternalSourceFireInput): PendingExternalSourceFire;
980
+ /** @internal */
981
+ listByInstance(instanceId: string): PendingExternalSourceFire[];
982
+ /** @internal */
983
+ getByMergeKey(instanceId: string, armingId: string, mergeKey: string): PendingExternalSourceFire | null;
984
+ /** @internal */
985
+ update(id: string, input: UpdatePendingExternalSourceFireInput): PendingExternalSourceFire | null;
986
+ /** @internal */
987
+ delete(id: string): boolean;
988
+ };
989
+
990
+ /** @internal */
991
+ interface CreateProcessEventInput {
992
+ /** @internal */
993
+ instanceId: string;
994
+ /** @internal */
995
+ eventType: string;
996
+ /** @internal */
997
+ data?: Record<string, unknown>;
998
+ }
999
+ /** @internal */
1000
+ declare function createProcessEventRepo(db: LeitwerkDb): {
1001
+ /** @internal */
1002
+ create(input: CreateProcessEventInput): ProcessEvent;
1003
+ /** @internal */
1004
+ latestSequence(instanceId: string): number;
1005
+ /** @internal */
1006
+ listByTurnRecord(instanceId: string, turnRecordId: string): ProcessEvent[];
1007
+ /** @internal */
1008
+ latestByTurnRecordEventType(instanceId: string, turnRecordId: string, eventType: string): ProcessEvent | null;
1009
+ /** @internal */
1010
+ summary(turnRecordId: string): _leitwerk_dev_protocol.CompactTurnSummary | null;
1011
+ /** @internal */
1012
+ listByInstance(instanceId: string, limit?: number): ProcessEvent[];
1013
+ /** @internal */
1014
+ listByInstanceEventTypes(instanceId: string, eventTypes: readonly string[], limit?: number): ProcessEvent[];
1015
+ /** @internal */
1016
+ listByInstanceSince(instanceId: string, sinceCreatedAt: string, options?: {
1017
+ /** @internal */
1018
+ limit?: number;
1019
+ /** @internal */
1020
+ eventTypePrefix?: string;
1021
+ }): ProcessEvent[];
1022
+ /** @internal */
1023
+ listByInstanceTurnRecordEventTypes(instanceId: string, turnRecordId: string, eventTypes: readonly string[]): ProcessEvent[];
1024
+ /** @internal */
1025
+ listByInstanceSinceEventTypes(instanceId: string, sinceCreatedAt: string, eventTypes: readonly string[], limit?: number): ProcessEvent[];
1026
+ };
1027
+
1028
+ /** @internal */
1029
+ interface ProcessHandoffDedupKeyRecord extends HandoffDedupKeyRecordLike {
1030
+ }
1031
+ /** @internal */
1032
+ interface CreateProcessHandoffDedupKeyInput {
1033
+ /** @internal */
1034
+ key: string;
1035
+ /** @internal */
1036
+ instanceId: string;
1037
+ /** @internal */
1038
+ metadata?: Record<string, unknown> | null;
1039
+ }
1040
+ /** @internal */
1041
+ declare function createProcessHandoffDedupKeyRepo(db: LeitwerkDb): {
1042
+ /** @internal */
1043
+ create(input: CreateProcessHandoffDedupKeyInput): ProcessHandoffDedupKeyRecord;
1044
+ /** @internal */
1045
+ getByKey(key: string): ProcessHandoffDedupKeyRecord | null;
1046
+ };
1047
+
1048
+ /** @internal */
1049
+ interface CreateProcessInputInput {
1050
+ /** @internal */
1051
+ instanceId: string;
1052
+ /** @internal */
1053
+ sequence: number;
1054
+ /** @internal */
1055
+ source: InputSource;
1056
+ /** @internal */
1057
+ kind: InputKind;
1058
+ /** @internal */
1059
+ target?: ProcessInputTarget | null;
1060
+ /** @internal */
1061
+ bodyMarkdown: string;
1062
+ /** @internal */
1063
+ actor?: Actor;
1064
+ }
1065
+ /** @internal */
1066
+ declare function createProcessInputRepo(db: LeitwerkDb): {
1067
+ /** @internal */
1068
+ create(input: CreateProcessInputInput): ProcessInput;
1069
+ /** @internal */
1070
+ listByInstance: (instanceId: string) => ProcessInput[];
1071
+ /** @internal */
1072
+ listUnconsumed: (instanceId: string) => ProcessInput[];
1073
+ /** @internal */
1074
+ markConsumed(id: string): boolean;
1075
+ /** @internal */
1076
+ delete(id: string): boolean;
1077
+ /** @internal */
1078
+ getMaxSequence(instanceId: string): number;
1079
+ };
1080
+
1081
+ /** @internal */
1082
+ interface ProcessLaunchIntent {
1083
+ /** @internal */
1084
+ launcherId: string;
1085
+ /** @internal */
1086
+ launcherInput: Record<string, unknown>;
1087
+ }
1088
+ /** @public */
1089
+ interface CreateProcessInstanceInput extends ProcessCustomizableFields {
1090
+ /** @public */
1091
+ processId: string;
1092
+ /** @public */
1093
+ selectedTurnId?: TurnId | null;
1094
+ /** @public */
1095
+ lifecycleStatus?: ProcessLifecycleStatus;
1096
+ /** @internal */
1097
+ currentExecution?: CurrentExecutionRef;
1098
+ /** @internal */
1099
+ selectedTurnModelKind?: ModelSelectionKind | null;
1100
+ /** @internal */
1101
+ selectedTurnModelSource?: ProcessSelectedTurnModelSource | null;
1102
+ /** @public */
1103
+ paramsJson?: string | null;
1104
+ /** @public */
1105
+ stateJson?: string | null;
1106
+ /** @internal */
1107
+ launchIntent?: ProcessLaunchIntent;
1108
+ }
1109
+ /** @internal */
1110
+ type ProcessOverviewStatusFilter = "all" | "running" | "needs_attention" | "completed" | "aborted" | "scheduled";
1111
+ /** @internal */
1112
+ interface ProcessOverviewQuery {
1113
+ /** @internal */
1114
+ query?: string;
1115
+ /** @internal */
1116
+ processType?: string;
1117
+ /** @internal */
1118
+ status?: ProcessOverviewStatusFilter;
1119
+ }
1120
+ /** @internal */
1121
+ interface ProcessOverviewWindowQuery extends ProcessOverviewQuery {
1122
+ /** @internal */
1123
+ limit: number;
1124
+ /** @internal */
1125
+ sortKey: "status" | "title" | "timeline";
1126
+ /** @internal */
1127
+ sortDirection: "asc" | "desc";
1128
+ }
1129
+ /** @public */
1130
+ interface UpdateProcessInstanceInput extends ProcessCustomizableFields {
1131
+ /** @internal */
1132
+ selectedTurnId?: TurnId | null;
1133
+ /** @internal */
1134
+ lifecycleStatus?: ProcessLifecycleStatus;
1135
+ /** @internal */
1136
+ currentExecution?: CurrentExecutionRef;
1137
+ /** @internal */
1138
+ planRevision?: number;
1139
+ /** @internal */
1140
+ selectedTurnModelKind?: ModelSelectionKind | null;
1141
+ /** @internal */
1142
+ selectedTurnModelSource?: ProcessSelectedTurnModelSource | null;
1143
+ /** @public */
1144
+ paramsJson?: string | null;
1145
+ /** @internal */
1146
+ stateJson?: string | null;
1147
+ }
1148
+ /** @public */
1149
+ declare function createProcessInstanceRepo(db: LeitwerkDb): {
1150
+ /** @internal */
1151
+ getLaunchIntent(instanceId: string): ProcessLaunchIntent | null;
1152
+ /** @public */
1153
+ create(input: CreateProcessInstanceInput): ProcessInstance;
1154
+ /** @public */
1155
+ getById(id: string): ProcessInstance | null;
1156
+ /** @public */
1157
+ listAll(): ProcessInstance[];
1158
+ /** @internal */
1159
+ listCurrent(limit: number): ProcessInstance[];
1160
+ /** @internal */
1161
+ countCurrent(): number;
1162
+ /** @internal */
1163
+ countOverview(input: ProcessOverviewQuery): number;
1164
+ /** @internal */
1165
+ countOverviewByLifecycle(input: Pick<ProcessOverviewQuery, "query" | "processType">): {
1166
+ /** @internal */
1167
+ lifecycleStatus: string;
1168
+ /** @internal */
1169
+ value: number;
1170
+ }[];
1171
+ /** @internal */
1172
+ listOverviewProcessTypes(input: Pick<ProcessOverviewQuery, "query" | "status">): {
1173
+ /** @internal */
1174
+ processId: string;
1175
+ /** @internal */
1176
+ value: number;
1177
+ }[];
1178
+ /** @internal */
1179
+ listOverviewWindow(input: ProcessOverviewWindowQuery): ProcessInstance[];
1180
+ /** @internal */
1181
+ setGeneratedTitleIfBlank(id: string, title: string): ProcessInstance | null;
1182
+ /** @public */
1183
+ update(id: string, input: UpdateProcessInstanceInput): ProcessInstance | null;
1184
+ /** @internal */
1185
+ delete(id: string): boolean;
1186
+ };
1187
+
1188
+ /** @internal */
1189
+ interface CreateProcessLeafOutcomeSnapshotInput {
1190
+ /** @internal */
1191
+ id?: string;
1192
+ /** @internal */
1193
+ instanceId: string;
1194
+ /** @internal */
1195
+ leafEntryId: string;
1196
+ /** @internal */
1197
+ turnRecordId?: string | null;
1198
+ /** @internal */
1199
+ rendererId?: string | null;
1200
+ /** @internal */
1201
+ schemaVersion?: number | null;
1202
+ /** @internal */
1203
+ props?: Record<string, unknown> | null;
1204
+ /** @internal */
1205
+ fallbackMarkdown?: string | null;
1206
+ /** @internal */
1207
+ status: ProcessLeafOutcomeSnapshotStatus;
1208
+ /** @internal */
1209
+ warningCode?: string | null;
1210
+ /** @internal */
1211
+ warningMessage?: string | null;
1212
+ /** @internal */
1213
+ anchoredAt: string;
1214
+ /** @internal */
1215
+ createdAt?: string;
1216
+ }
1217
+ /** @internal */
1218
+ declare function createProcessLeafOutcomeSnapshotRepo(db: LeitwerkDb): {
1219
+ /** @internal */
1220
+ create(input: CreateProcessLeafOutcomeSnapshotInput): ProcessLeafOutcomeSnapshot;
1221
+ /** @internal */
1222
+ listByInstance(instanceId: string): ProcessLeafOutcomeSnapshot[];
1223
+ /** @internal */
1224
+ getByInstanceAndLeafEntryId(instanceId: string, leafEntryId: string): ProcessLeafOutcomeSnapshot | null;
1225
+ };
1226
+
1227
+ /** @internal */
1228
+ interface CreateProcessProjectInput extends UpdateProcessProjectInput {
1229
+ /** @internal */
1230
+ instanceId: string;
1231
+ /** @internal */
1232
+ key: string;
1233
+ /** @internal */
1234
+ repoLocator: string;
1235
+ /** @internal */
1236
+ baseBranch: string;
1237
+ }
1238
+ /** @public */
1239
+ interface UpdateProcessProjectInput {
1240
+ /** @internal */
1241
+ repoLocator?: string;
1242
+ /** @internal */
1243
+ workBranch?: string | null;
1244
+ /** @internal */
1245
+ externalId?: string | null;
1246
+ /** @internal */
1247
+ externalUrl?: string | null;
1248
+ /** @public */
1249
+ metadata?: Record<string, unknown> | null;
1250
+ /** @internal */
1251
+ pipelineStatus?: string | null;
1252
+ /** @internal */
1253
+ baseBranch?: string;
1254
+ }
1255
+ /** @public */
1256
+ declare function createProcessProjectRepo(db: LeitwerkDb): {
1257
+ /** @internal */
1258
+ create(input: CreateProcessProjectInput): ProcessProject;
1259
+ /** @internal */
1260
+ getById(id: string): ProcessProject | null;
1261
+ /** @public */
1262
+ listByInstance(instanceId: string): ProcessProject[];
1263
+ /** @internal */
1264
+ listByInstances(instanceIds: readonly string[]): ProcessProject[];
1265
+ /** @internal */
1266
+ getByInstanceAndKey(instanceId: string, key: string): ProcessProject | null;
1267
+ /** @public */
1268
+ update(id: string, input: UpdateProcessProjectInput): ProcessProject | null;
1269
+ };
1270
+
1271
+ /** @internal */
1272
+ interface CreateQuestionRequestInput {
1273
+ /** @internal */
1274
+ instanceId: string;
1275
+ /** @internal */
1276
+ turnRecordId: string;
1277
+ /** @internal */
1278
+ toolCallId: string;
1279
+ /** @internal */
1280
+ questions: readonly NormalizedQuestion[];
1281
+ /** @internal */
1282
+ askedAt?: string;
1283
+ }
1284
+ /** @internal */
1285
+ declare function createProcessQuestionRequestRepo(db: LeitwerkDb): {
1286
+ /** @internal */
1287
+ getById: (id: string) => ProcessQuestionRequest | null;
1288
+ /** @internal */
1289
+ listByInstance: (instanceId: string) => ProcessQuestionRequest[];
1290
+ /** @internal */
1291
+ listOpen: (instanceId?: string) => ProcessQuestionRequest[];
1292
+ /** @internal */
1293
+ createIdempotent(input: CreateQuestionRequestInput): {
1294
+ /** @internal */
1295
+ kind: "created" | "replay";
1296
+ /** @internal */
1297
+ request: ProcessQuestionRequest;
1298
+ };
1299
+ /** @internal */
1300
+ answer(input: {
1301
+ /** @internal */
1302
+ id: string;
1303
+ /** @internal */
1304
+ answers: readonly string[];
1305
+ /** @internal */
1306
+ actor: Actor;
1307
+ /** @internal */
1308
+ answeredAt?: string;
1309
+ }): ProcessQuestionRequest | null;
1310
+ /** @internal */
1311
+ cancelOpenByTurn(instanceId: string, turnRecordId: string): number;
1312
+ };
1313
+
1314
+ /** @internal */
1315
+ declare function createProcessRelationRepo(db: LeitwerkDb): {
1316
+ /** @internal */
1317
+ create(input: Omit<ProcessRelation, "kind" | "createdAt"> & {
1318
+ /** @internal */
1319
+ createdAt?: string;
1320
+ }): ProcessRelation;
1321
+ /** @internal */
1322
+ getByChild(childInstanceId: string): ProcessRelation | null;
1323
+ /** @internal */
1324
+ listByParent(parentInstanceId: string): ProcessRelation[];
1325
+ };
1326
+
1327
+ /** @internal */
1328
+ interface ResourceOwner {
1329
+ /** @internal */
1330
+ readonly kind: Exclude<PiResourceProvenanceKind, "generated">;
1331
+ /** @internal */
1332
+ readonly ownerExtensionId: string | null;
1333
+ /** @internal */
1334
+ readonly packageName: string | null;
1335
+ }
1336
+ /** @internal */
1337
+ interface PiResourceLayer {
1338
+ /** @internal */
1339
+ readonly bundle: PiResourceBundle;
1340
+ /** @internal */
1341
+ readonly owner: ResourceOwner;
1342
+ }
1343
+
1344
+ /** @internal */
1345
+ declare function createProcessSkillRepo(db: LeitwerkDb): {
1346
+ /** @internal */
1347
+ attach(instanceId: string, selections: readonly SkillSelection[]): void;
1348
+ /** @internal */
1349
+ listSelections(instanceId: string): SkillSelection[];
1350
+ /** @internal */
1351
+ listResourceLayers(instanceId: string): PiResourceLayer[];
1352
+ };
1353
+
1354
+ declare const processTitleJobs: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1355
+ name: "process_title_jobs";
1356
+ schema: undefined;
1357
+ columns: {
1358
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
1359
+ name: string;
1360
+ tableName: "process_title_jobs";
1361
+ dataType: "string";
1362
+ data: string;
1363
+ driverParam: string;
1364
+ notNull: true;
1365
+ hasDefault: false;
1366
+ isPrimaryKey: true;
1367
+ isAutoincrement: false;
1368
+ hasRuntimeDefault: false;
1369
+ enumValues: [string, ...string[]];
1370
+ baseColumn: never;
1371
+ identity: undefined;
1372
+ generated: undefined;
1373
+ }, {}>;
1374
+ targetKind: drizzle_orm_sqlite_core.SQLiteColumn<{
1375
+ name: string;
1376
+ tableName: "process_title_jobs";
1377
+ dataType: "string enum";
1378
+ data: "process" | "future_execution";
1379
+ driverParam: string;
1380
+ notNull: true;
1381
+ hasDefault: false;
1382
+ isPrimaryKey: false;
1383
+ isAutoincrement: false;
1384
+ hasRuntimeDefault: false;
1385
+ enumValues: ["process", "future_execution"];
1386
+ baseColumn: never;
1387
+ identity: undefined;
1388
+ generated: undefined;
1389
+ }, {}>;
1390
+ processDefinitionId: drizzle_orm_sqlite_core.SQLiteColumn<{
1391
+ name: string;
1392
+ tableName: "process_title_jobs";
1393
+ dataType: "string";
1394
+ data: string;
1395
+ driverParam: string;
1396
+ notNull: true;
1397
+ hasDefault: false;
1398
+ isPrimaryKey: false;
1399
+ isAutoincrement: false;
1400
+ hasRuntimeDefault: false;
1401
+ enumValues: [string, ...string[]];
1402
+ baseColumn: never;
1403
+ identity: undefined;
1404
+ generated: undefined;
1405
+ }, {}>;
1406
+ processInstanceId: drizzle_orm_sqlite_core.SQLiteColumn<{
1407
+ name: string;
1408
+ tableName: "process_title_jobs";
1409
+ dataType: "string";
1410
+ data: string;
1411
+ driverParam: string;
1412
+ notNull: false;
1413
+ hasDefault: false;
1414
+ isPrimaryKey: false;
1415
+ isAutoincrement: false;
1416
+ hasRuntimeDefault: false;
1417
+ enumValues: [string, ...string[]];
1418
+ baseColumn: never;
1419
+ identity: undefined;
1420
+ generated: undefined;
1421
+ }, {}>;
1422
+ futureExecutionId: drizzle_orm_sqlite_core.SQLiteColumn<{
1423
+ name: string;
1424
+ tableName: "process_title_jobs";
1425
+ dataType: "string";
1426
+ data: string;
1427
+ driverParam: string;
1428
+ notNull: false;
1429
+ hasDefault: false;
1430
+ isPrimaryKey: false;
1431
+ isAutoincrement: false;
1432
+ hasRuntimeDefault: false;
1433
+ enumValues: [string, ...string[]];
1434
+ baseColumn: never;
1435
+ identity: undefined;
1436
+ generated: undefined;
1437
+ }, {}>;
1438
+ launchRunId: drizzle_orm_sqlite_core.SQLiteColumn<{
1439
+ name: string;
1440
+ tableName: "process_title_jobs";
1441
+ dataType: "string";
1442
+ data: string;
1443
+ driverParam: string;
1444
+ notNull: false;
1445
+ hasDefault: false;
1446
+ isPrimaryKey: false;
1447
+ isAutoincrement: false;
1448
+ hasRuntimeDefault: false;
1449
+ enumValues: [string, ...string[]];
1450
+ baseColumn: never;
1451
+ identity: undefined;
1452
+ generated: undefined;
1453
+ }, {}>;
1454
+ modelProfileId: drizzle_orm_sqlite_core.SQLiteColumn<{
1455
+ name: string;
1456
+ tableName: "process_title_jobs";
1457
+ dataType: "string";
1458
+ data: string;
1459
+ driverParam: string;
1460
+ notNull: true;
1461
+ hasDefault: false;
1462
+ isPrimaryKey: false;
1463
+ isAutoincrement: false;
1464
+ hasRuntimeDefault: false;
1465
+ enumValues: [string, ...string[]];
1466
+ baseColumn: never;
1467
+ identity: undefined;
1468
+ generated: undefined;
1469
+ }, {}>;
1470
+ prompt: drizzle_orm_sqlite_core.SQLiteColumn<{
1471
+ name: string;
1472
+ tableName: "process_title_jobs";
1473
+ dataType: "string";
1474
+ data: string;
1475
+ driverParam: string;
1476
+ notNull: true;
1477
+ hasDefault: false;
1478
+ isPrimaryKey: false;
1479
+ isAutoincrement: false;
1480
+ hasRuntimeDefault: false;
1481
+ enumValues: [string, ...string[]];
1482
+ baseColumn: never;
1483
+ identity: undefined;
1484
+ generated: undefined;
1485
+ }, {}>;
1486
+ expectedPayloadJson: drizzle_orm_sqlite_core.SQLiteColumn<{
1487
+ name: string;
1488
+ tableName: "process_title_jobs";
1489
+ dataType: "string";
1490
+ data: string;
1491
+ driverParam: string;
1492
+ notNull: false;
1493
+ hasDefault: false;
1494
+ isPrimaryKey: false;
1495
+ isAutoincrement: false;
1496
+ hasRuntimeDefault: false;
1497
+ enumValues: [string, ...string[]];
1498
+ baseColumn: never;
1499
+ identity: undefined;
1500
+ generated: undefined;
1501
+ }, {}>;
1502
+ status: drizzle_orm_sqlite_core.SQLiteColumn<{
1503
+ name: string;
1504
+ tableName: "process_title_jobs";
1505
+ dataType: "string enum";
1506
+ data: "pending" | "running" | "completed" | "superseded" | "failed";
1507
+ driverParam: string;
1508
+ notNull: true;
1509
+ hasDefault: false;
1510
+ isPrimaryKey: false;
1511
+ isAutoincrement: false;
1512
+ hasRuntimeDefault: false;
1513
+ enumValues: ["pending", "running", "completed", "superseded", "failed"];
1514
+ baseColumn: never;
1515
+ identity: undefined;
1516
+ generated: undefined;
1517
+ }, {}>;
1518
+ attemptCount: drizzle_orm_sqlite_core.SQLiteColumn<{
1519
+ name: string;
1520
+ tableName: "process_title_jobs";
1521
+ dataType: "number int53";
1522
+ data: number;
1523
+ driverParam: number;
1524
+ notNull: true;
1525
+ hasDefault: true;
1526
+ isPrimaryKey: false;
1527
+ isAutoincrement: false;
1528
+ hasRuntimeDefault: false;
1529
+ enumValues: undefined;
1530
+ baseColumn: never;
1531
+ identity: undefined;
1532
+ generated: undefined;
1533
+ }, {}>;
1534
+ maxAttempts: drizzle_orm_sqlite_core.SQLiteColumn<{
1535
+ name: string;
1536
+ tableName: "process_title_jobs";
1537
+ dataType: "number int53";
1538
+ data: number;
1539
+ driverParam: number;
1540
+ notNull: true;
1541
+ hasDefault: false;
1542
+ isPrimaryKey: false;
1543
+ isAutoincrement: false;
1544
+ hasRuntimeDefault: false;
1545
+ enumValues: undefined;
1546
+ baseColumn: never;
1547
+ identity: undefined;
1548
+ generated: undefined;
1549
+ }, {}>;
1550
+ nextRunAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1551
+ name: string;
1552
+ tableName: "process_title_jobs";
1553
+ dataType: "string";
1554
+ data: string;
1555
+ driverParam: string;
1556
+ notNull: true;
1557
+ hasDefault: false;
1558
+ isPrimaryKey: false;
1559
+ isAutoincrement: false;
1560
+ hasRuntimeDefault: false;
1561
+ enumValues: [string, ...string[]];
1562
+ baseColumn: never;
1563
+ identity: undefined;
1564
+ generated: undefined;
1565
+ }, {}>;
1566
+ lastError: drizzle_orm_sqlite_core.SQLiteColumn<{
1567
+ name: string;
1568
+ tableName: "process_title_jobs";
1569
+ dataType: "string";
1570
+ data: string;
1571
+ driverParam: string;
1572
+ notNull: false;
1573
+ hasDefault: false;
1574
+ isPrimaryKey: false;
1575
+ isAutoincrement: false;
1576
+ hasRuntimeDefault: false;
1577
+ enumValues: [string, ...string[]];
1578
+ baseColumn: never;
1579
+ identity: undefined;
1580
+ generated: undefined;
1581
+ }, {}>;
1582
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1583
+ name: string;
1584
+ tableName: "process_title_jobs";
1585
+ dataType: "string";
1586
+ data: string;
1587
+ driverParam: string;
1588
+ notNull: true;
1589
+ hasDefault: false;
1590
+ isPrimaryKey: false;
1591
+ isAutoincrement: false;
1592
+ hasRuntimeDefault: false;
1593
+ enumValues: [string, ...string[]];
1594
+ baseColumn: never;
1595
+ identity: undefined;
1596
+ generated: undefined;
1597
+ }, {}>;
1598
+ updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1599
+ name: string;
1600
+ tableName: "process_title_jobs";
1601
+ dataType: "string";
1602
+ data: string;
1603
+ driverParam: string;
1604
+ notNull: true;
1605
+ hasDefault: false;
1606
+ isPrimaryKey: false;
1607
+ isAutoincrement: false;
1608
+ hasRuntimeDefault: false;
1609
+ enumValues: [string, ...string[]];
1610
+ baseColumn: never;
1611
+ identity: undefined;
1612
+ generated: undefined;
1613
+ }, {}>;
1614
+ };
1615
+ dialect: "sqlite";
1616
+ }>;
1617
+
1618
+ /** @internal */
1619
+ type ProcessTitleJob = typeof processTitleJobs.$inferSelect;
1620
+ /** @internal */
1621
+ type EnqueueProcessTitleJobInput = {
1622
+ /** @internal */
1623
+ processDefinitionId: string;
1624
+ /** @internal */
1625
+ modelProfileId: string;
1626
+ /** @internal */
1627
+ prompt: string;
1628
+ /** @internal */
1629
+ maxAttempts: number;
1630
+ /** @internal */
1631
+ nextRunAt: string;
1632
+ } & ({
1633
+ /** @internal */
1634
+ processInstanceId: string;
1635
+ /** @internal */
1636
+ launchRunId?: string | null;
1637
+ } | {
1638
+ /** @internal */
1639
+ futureExecutionId: string;
1640
+ /** @internal */
1641
+ expectedPayloadJson: string;
1642
+ });
1643
+ /** @internal */
1644
+ declare function createProcessTitleJobRepo(db: LeitwerkDb): {
1645
+ /** @internal */
1646
+ enqueue(input: EnqueueProcessTitleJobInput): ProcessTitleJob;
1647
+ /** @internal */
1648
+ getById(id: string): ProcessTitleJob | null;
1649
+ /** @internal */
1650
+ listByProcessInstance(processInstanceId: string): ProcessTitleJob[];
1651
+ /** @internal */
1652
+ listAll(): ProcessTitleJob[];
1653
+ /** @internal */
1654
+ listDuePending(asOf: string, limit: number): ProcessTitleJob[];
1655
+ /** @internal */
1656
+ markRunning(id: string): ProcessTitleJob | null;
1657
+ /** @internal */
1658
+ reschedule(id: string, nextRunAt: string, lastError: string): ProcessTitleJob | null;
1659
+ /** @internal */
1660
+ markCompleted(id: string): ProcessTitleJob | null;
1661
+ /** @internal */
1662
+ markFailed(id: string, lastError: string): ProcessTitleJob | null;
1663
+ /** @internal */
1664
+ markSuperseded(id: string): ProcessTitleJob | null;
1665
+ };
1666
+
1667
+ /** @internal */
1668
+ declare function createProcessToolApprovalRequestRepo(db: LeitwerkDb): {
1669
+ /** @internal */
1670
+ listByInstance: (instanceId: string) => ProcessToolApprovalRequest[];
1671
+ /** @internal */
1672
+ listOpen: (instanceId?: string) => ProcessToolApprovalRequest[];
1673
+ /** @internal */
1674
+ createIdempotent(input: {
1675
+ /** @internal */
1676
+ instanceId: string;
1677
+ /** @internal */
1678
+ turnRecordId: string;
1679
+ /** @internal */
1680
+ toolCallId: string;
1681
+ /** @internal */
1682
+ toolName: string;
1683
+ /** @internal */
1684
+ arguments: Record<string, unknown>;
1685
+ /** @internal */
1686
+ destination?: ProcessToolApprovalDestination;
1687
+ /** @internal */
1688
+ requestedAt?: string;
1689
+ }): {
1690
+ /** @internal */
1691
+ kind: "created" | "replay";
1692
+ /** @internal */
1693
+ request: ProcessToolApprovalRequest;
1694
+ };
1695
+ /** @internal */
1696
+ resolve(input: {
1697
+ /** @internal */
1698
+ id: string;
1699
+ /** @internal */
1700
+ status: Exclude<ToolApprovalStatus, "open" | "cancelled">;
1701
+ /** @internal */
1702
+ actor: Actor;
1703
+ /** @internal */
1704
+ feedback?: string;
1705
+ /** @internal */
1706
+ resolvedAt?: string;
1707
+ }): ProcessToolApprovalRequest | null;
1708
+ /** @internal */
1709
+ cancelOpenByTurn(instanceId: string, turnRecordId: string): number;
1710
+ };
1711
+
1712
+ /** @internal */
1713
+ interface CreateProcessTurnAnnotationInput {
1714
+ /** @internal */
1715
+ id?: string;
1716
+ /** @internal */
1717
+ instanceId: string;
1718
+ /** @internal */
1719
+ annotationType: string;
1720
+ /** Null means append-only and therefore not addressable via upsert key. @internal */
1721
+ annotationKey?: string | null;
1722
+ /** @internal */
1723
+ references?: readonly TurnAnnotationReference[];
1724
+ /** @internal */
1725
+ payload?: Record<string, unknown>;
1726
+ /** @internal */
1727
+ createdAt?: string;
1728
+ /** @internal */
1729
+ updatedAt?: string;
1730
+ }
1731
+ /** @internal */
1732
+ interface UpdateProcessTurnAnnotationInput {
1733
+ /** @internal */
1734
+ annotationType?: string;
1735
+ /** Null means append-only and therefore not addressable via upsert key. @internal */
1736
+ annotationKey?: string | null;
1737
+ /** @internal */
1738
+ references?: readonly TurnAnnotationReference[];
1739
+ /** @internal */
1740
+ payload?: Record<string, unknown>;
1741
+ /** @internal */
1742
+ updatedAt?: string;
1743
+ }
1744
+ /** @internal */
1745
+ declare function createProcessTurnAnnotationRepo(db: LeitwerkDb): {
1746
+ /** @internal */
1747
+ create(input: CreateProcessTurnAnnotationInput): ProcessTurnAnnotation;
1748
+ /** @internal */
1749
+ getById(id: string): ProcessTurnAnnotation | null;
1750
+ /** @internal */
1751
+ findByKey(instanceId: string, annotationKey: string): ProcessTurnAnnotation | null;
1752
+ /** @internal */
1753
+ listByInstance(instanceId: string): ProcessTurnAnnotation[];
1754
+ /** @internal */
1755
+ update(id: string, input: UpdateProcessTurnAnnotationInput): ProcessTurnAnnotation | null;
1756
+ /** @internal */
1757
+ delete(id: string): boolean;
1758
+ };
1759
+
1760
+ /** @internal */
1761
+ interface CreateProcessTurnRecordInput extends UpdateProcessTurnRecordInput {
1762
+ /** @internal */
1763
+ id?: string;
1764
+ /** @internal */
1765
+ instanceId: string;
1766
+ /** @internal */
1767
+ turnId: TurnId;
1768
+ /** @internal */
1769
+ pathType?: ProcessTurnRecordPathType;
1770
+ /** @internal */
1771
+ startedAt?: string;
1772
+ }
1773
+ /** @internal */
1774
+ interface UpdateProcessTurnRecordInput {
1775
+ /** @internal */
1776
+ turnType?: ProcessTurnType;
1777
+ /** @internal */
1778
+ status?: ProcessTurnRecordStatus;
1779
+ /** @internal */
1780
+ attemptNumber?: number;
1781
+ /** @internal */
1782
+ parentTurnRecordId?: string | null;
1783
+ /** @internal */
1784
+ turnStartRecordId?: string | null;
1785
+ /** @internal */
1786
+ acceptedWorkerLeaseId?: string | null;
1787
+ /** @internal */
1788
+ forkPiEntryId?: string | null;
1789
+ /** @internal */
1790
+ resultPiEntryId?: string | null;
1791
+ /** @internal */
1792
+ modelProfileId?: string | null;
1793
+ /** @internal */
1794
+ modelSelectionProvenance?: ModelSelectionProvenance | null;
1795
+ /** @internal */
1796
+ turnResultMarkdown?: string | null;
1797
+ /** @internal */
1798
+ errorSummary?: string | null;
1799
+ /** @internal */
1800
+ errorClass?: WorkerErrorClass | null;
1801
+ /** @internal */
1802
+ endedAt?: string | null;
1803
+ }
1804
+ /** @public */
1805
+ declare function createProcessTurnRecordRepo(db: LeitwerkDb): {
1806
+ /** @internal */
1807
+ create(input: CreateProcessTurnRecordInput): ProcessTurnRecord;
1808
+ /** @internal */
1809
+ getById(id: string): ProcessTurnRecord | null;
1810
+ /** @public */
1811
+ listByInstance(instanceId: string): ProcessTurnRecord[];
1812
+ /** @internal */
1813
+ getLatestSucceededPrimaryByInstance(instanceId: string): ProcessTurnRecord | null;
1814
+ /** @internal */
1815
+ update(id: string, input: UpdateProcessTurnRecordInput): ProcessTurnRecord | null;
1816
+ };
1817
+
1818
+ /** @internal */
1819
+ interface SessionTransferGrant {
1820
+ /** @internal */
1821
+ id: string;
1822
+ /** @internal */
1823
+ instanceId: string;
1824
+ /** @internal */
1825
+ tokenHash: string;
1826
+ /** @internal */
1827
+ createdAt: string;
1828
+ /** @internal */
1829
+ expiresAt: string;
1830
+ /** @internal */
1831
+ consumedAt: string | null;
1832
+ /** @internal */
1833
+ tombstoneUntil: string | null;
1834
+ }
1835
+ /** @internal */
1836
+ interface SessionTransferAttempt extends SessionTransferAttemptWire {
1837
+ /** @internal */
1838
+ createdAt: string;
1839
+ /** @internal */
1840
+ completedAt: string | null;
1841
+ }
1842
+ /** @internal */
1843
+ declare function createSessionTransferRepo(db: LeitwerkDb): {
1844
+ /** @internal */
1845
+ createGrant(input: {
1846
+ /** @internal */
1847
+ instanceId: string;
1848
+ /** @internal */
1849
+ now: Date;
1850
+ /** @internal */
1851
+ lifetimeMs: number;
1852
+ }): {
1853
+ /** @internal */
1854
+ grant: SessionTransferGrant;
1855
+ /** @internal */
1856
+ rawToken: string;
1857
+ };
1858
+ /** @internal */
1859
+ getGrant(id: string): SessionTransferGrant | null;
1860
+ /** @internal */
1861
+ getAttempt(id: string): SessionTransferAttempt | null;
1862
+ /** @internal */
1863
+ getActiveByInstance(instanceId: string): SessionTransferAttempt | null;
1864
+ /** @internal */
1865
+ listActive(): SessionTransferAttempt[];
1866
+ /** @internal */
1867
+ startAttempt(input: {
1868
+ /** @internal */
1869
+ instanceId: string;
1870
+ /** @internal */
1871
+ grantId: string;
1872
+ /** @internal */
1873
+ token: string;
1874
+ /** @internal */
1875
+ now: Date;
1876
+ /** @internal */
1877
+ leaseMs: number;
1878
+ /** @internal */
1879
+ hardDeadlineMs: number;
1880
+ }): {
1881
+ /** @internal */
1882
+ kind: "created";
1883
+ /** @internal */
1884
+ attempt: SessionTransferAttempt;
1885
+ } | {
1886
+ /** @internal */
1887
+ kind: "not_found";
1888
+ } | {
1889
+ /** @internal */
1890
+ kind: "busy";
1891
+ };
1892
+ /** @internal */
1893
+ verifyAttempt(input: {
1894
+ /** @internal */
1895
+ instanceId: string;
1896
+ /** @internal */
1897
+ grantId: string;
1898
+ /** @internal */
1899
+ attemptId: string;
1900
+ /** @internal */
1901
+ token: string;
1902
+ }): SessionTransferAttempt | null;
1903
+ /** @internal */
1904
+ updateAttempt(id: string, patch: Partial<Omit<SessionTransferAttempt, "id" | "grantId" | "instanceId" | "createdAt" | "state">>): SessionTransferAttempt | null;
1905
+ /** @internal */
1906
+ renew(id: string, input: {
1907
+ /** @internal */
1908
+ now: Date;
1909
+ /** @internal */
1910
+ leaseMs: number;
1911
+ }): SessionTransferAttempt | null;
1912
+ /** @internal */
1913
+ acknowledge(input: {
1914
+ /** @internal */
1915
+ attemptId: string;
1916
+ /** @internal */
1917
+ now: Date;
1918
+ /** @internal */
1919
+ tombstoneMs: number;
1920
+ }): SessionTransferAttempt | null;
1921
+ /** @internal */
1922
+ revokeProcess(instanceId: string): void;
1923
+ /** @internal */
1924
+ cleanup(now: Date): void;
1925
+ };
1926
+
1927
+ /** @internal */
1928
+ interface ImportedSkill {
1929
+ /** @internal */
1930
+ skillId: string;
1931
+ /** @internal */
1932
+ label: string;
1933
+ /** @internal */
1934
+ description: string | null;
1935
+ /** @internal */
1936
+ bundle: PiResourceBundle;
1937
+ /** @internal */
1938
+ sourceRevision: string | null;
1939
+ }
1940
+ /** @internal */
1941
+ interface ImportedRepositorySkill extends ImportedSkill {
1942
+ /** @internal */
1943
+ sourcePath: string;
1944
+ }
1945
+
1946
+ /** @internal */
1947
+ declare function createSkillRepo(db: LeitwerkDb): {
1948
+ /** @internal */
1949
+ listAvailable(): SkillOptionSummary[];
1950
+ /** @internal */
1951
+ resolveActive(ids: readonly string[]): SkillSelection[];
1952
+ /** @internal */
1953
+ reconcile(imported: readonly ImportedSkill[]): void;
1954
+ /** @internal */
1955
+ backfillDependencies(): void;
1956
+ /** @internal */
1957
+ markUnconfiguredCatalogEntries(configuredRepositoryIds: readonly string[]): void;
1958
+ /** @internal */
1959
+ mergeCatalog(repositoryId: string, imported: readonly ImportedRepositorySkill[]): void;
1960
+ /** @internal */
1961
+ registerCatalogEntry(repositoryId: string, skillId: string): string;
1962
+ /** @internal */
1963
+ remove(skillId: string): boolean;
1964
+ /** @internal */
1965
+ catalog(): {
1966
+ /** @internal */
1967
+ availableSkills: SkillCatalogItem[];
1968
+ /** @internal */
1969
+ installedSkills: InstalledSkillCatalogItem[];
1970
+ };
1971
+ /** @internal */
1972
+ getCatalogDetail(repositoryId: string, skillId: string): SkillCatalogDetail | null;
1973
+ /** @internal */
1974
+ getInstalledDetail(skillId: string): InstalledSkillCatalogDetail | null;
1975
+ /** @internal */
1976
+ recordInvocations(input: {
1977
+ /** @internal */
1978
+ instanceId: string;
1979
+ /** @internal */
1980
+ turnRecordId: string;
1981
+ /** @internal */
1982
+ invocations: readonly {
1983
+ /** @internal */
1984
+ skillId: string;
1985
+ /** @internal */
1986
+ invokedAt: string;
1987
+ }[];
1988
+ }): void;
1989
+ };
1990
+
1991
+ /** @internal */
1992
+ interface TicketDestinationRecent {
1993
+ /** @internal */
1994
+ id: string;
1995
+ /** @internal */
1996
+ actorKey: string;
1997
+ /** @internal */
1998
+ toolName: string;
1999
+ /** @internal */
2000
+ destinationId: string;
2001
+ /** @internal */
2002
+ createdAt: string;
2003
+ /** @internal */
2004
+ updatedAt: string;
2005
+ }
2006
+ /** @internal */
2007
+ declare function createTicketDestinationRecentRepo(db: LeitwerkDb): {
2008
+ /** @internal */
2009
+ list(actorKey: string, toolName: string, limit?: number): TicketDestinationRecent[];
2010
+ /** @internal */
2011
+ record(input: {
2012
+ /** @internal */
2013
+ actorKey: string;
2014
+ /** @internal */
2015
+ toolName: string;
2016
+ /** @internal */
2017
+ destinationId: string;
2018
+ /** @internal */
2019
+ limit?: number;
2020
+ }): TicketDestinationRecent;
2021
+ };
2022
+
2023
+ /** @internal */
2024
+ declare function createTurnStartRecordRepo(db: LeitwerkDb): {
2025
+ /** @internal */
2026
+ create(input: Omit<TurnStartRecord, "id" | "createdAt" | "updatedAt"> & {
2027
+ /** @internal */
2028
+ id?: string;
2029
+ }): TurnStartRecord;
2030
+ /** @internal */
2031
+ getById(id: string): TurnStartRecord | null;
2032
+ /** @internal */
2033
+ listByInstance(instanceId: string): TurnStartRecord[];
2034
+ /** @internal */
2035
+ compareAndSetState(input: {
2036
+ /** @internal */
2037
+ id: string;
2038
+ /** @internal */
2039
+ expectedKind: TurnStartRecordState["kind"];
2040
+ /** @internal */
2041
+ state: TurnStartRecordState;
2042
+ }): TurnStartRecord | null;
2043
+ };
2044
+
2045
+ /** @internal */
2046
+ interface CreateWorkerLeaseInput {
2047
+ /** @internal */
2048
+ instanceId: string;
2049
+ /** @internal */
2050
+ workerId: string;
2051
+ /** @internal */
2052
+ state: WorkerState;
2053
+ /** @internal */
2054
+ serverEpoch?: string | null;
2055
+ /** @internal */
2056
+ connectTokenHash?: string | null;
2057
+ /** @internal */
2058
+ snapshotTokenHash?: string | null;
2059
+ /** @internal */
2060
+ modelPolicyFingerprint?: string | null;
2061
+ /** @internal */
2062
+ bootstrapReceipt?: WorkerBootstrapReceipt | null;
2063
+ /** @internal */
2064
+ turnStartRecordId?: string | null;
2065
+ }
2066
+ /** @internal */
2067
+ interface UpdateWorkerLeaseInput {
2068
+ /** @internal */
2069
+ state?: WorkerState;
2070
+ /** @internal */
2071
+ serverEpoch?: string | null;
2072
+ /** @internal */
2073
+ connectTokenHash?: string | null;
2074
+ /** @internal */
2075
+ snapshotTokenHash?: string | null;
2076
+ /** @internal */
2077
+ modelPolicyFingerprint?: string | null;
2078
+ /** @internal */
2079
+ lastHeartbeatAt?: string | null;
2080
+ /** @internal */
2081
+ connectedAt?: string | null;
2082
+ /** @internal */
2083
+ workspacePreparationStartedAt?: string | null;
2084
+ /** @internal */
2085
+ readyAt?: string | null;
2086
+ /** @internal */
2087
+ exitedAt?: string | null;
2088
+ }
2089
+ /** @internal */
2090
+ declare function createWorkerLeaseRepo(db: LeitwerkDb): {
2091
+ /** @internal */
2092
+ create(input: CreateWorkerLeaseInput): WorkerLease;
2093
+ /** @internal */
2094
+ getByInstance(instanceId: string): WorkerLease | null;
2095
+ /** @internal */
2096
+ getById(id: string): WorkerLease | null;
2097
+ /** @internal */
2098
+ listByInstance(instanceId: string): WorkerLease[];
2099
+ /** @internal */
2100
+ listActive(): WorkerLease[];
2101
+ /** @internal */
2102
+ update(id: string, input: UpdateWorkerLeaseInput): WorkerLease | null;
2103
+ /** @internal */
2104
+ observeTimestamp(id: string, field: "connectedAt" | "workspacePreparationStartedAt" | "readyAt"): WorkerLease | null;
2105
+ /** @internal */
2106
+ updateHeartbeat(workerId: string): boolean;
2107
+ /** Stores the first receipt only. Exact replay is accepted; changed receipts are rejected. @internal */
2108
+ compareAndSetBootstrapReceipt(id: string, receipt: WorkerBootstrapReceipt): "stored" | "replay" | "changed" | "missing";
2109
+ };
2110
+
2111
+ /** @public */
2112
+ interface RepositoryBundle {
2113
+ /** @internal */
2114
+ startupObservations: ReturnType<typeof createStartupObservationRepo>;
2115
+ /** @internal */
2116
+ turnSummaries: ReturnType<typeof createTurnSummaryRepo>;
2117
+ /** @public */
2118
+ processes: ReturnType<typeof createProcessInstanceRepo>;
2119
+ /** @public */
2120
+ projects: ReturnType<typeof createProcessProjectRepo>;
2121
+ /** @internal */
2122
+ questionRequests: ReturnType<typeof createProcessQuestionRequestRepo>;
2123
+ /** @internal */
2124
+ processRelations: ReturnType<typeof createProcessRelationRepo>;
2125
+ /** @internal */
2126
+ toolApprovalRequests: ReturnType<typeof createProcessToolApprovalRequestRepo>;
2127
+ /** @internal */
2128
+ inputs: ReturnType<typeof createProcessInputRepo>;
2129
+ /** @internal */
2130
+ events: ReturnType<typeof createProcessEventRepo>;
2131
+ /** @internal */
2132
+ handoffDedupKeys: ReturnType<typeof createProcessHandoffDedupKeyRepo>;
2133
+ /** @internal */
2134
+ futureExecutions: ReturnType<typeof createFutureExecutionRepo>;
2135
+ /** @internal */
2136
+ launcherRecentValues: ReturnType<typeof createLauncherRecentValueRepo>;
2137
+ /** @internal */
2138
+ ticketDestinationRecents: ReturnType<typeof createTicketDestinationRecentRepo>;
2139
+ /** @internal */
2140
+ launchRuns: ReturnType<typeof createLaunchRunRepo>;
2141
+ /** @internal */
2142
+ titleJobs: ReturnType<typeof createProcessTitleJobRepo>;
2143
+ /** @internal */
2144
+ pendingExternalSourceFires: ReturnType<typeof createPendingExternalSourceFireRepo>;
2145
+ /** @internal */
2146
+ leafOutcomeSnapshots: ReturnType<typeof createProcessLeafOutcomeSnapshotRepo>;
2147
+ /** @public */
2148
+ turnRecords: ReturnType<typeof createProcessTurnRecordRepo>;
2149
+ /** @internal */
2150
+ turnStarts: ReturnType<typeof createTurnStartRecordRepo>;
2151
+ /** @internal */
2152
+ turnAnnotations: ReturnType<typeof createProcessTurnAnnotationRepo>;
2153
+ /** @internal */
2154
+ leases: ReturnType<typeof createWorkerLeaseRepo>;
2155
+ /** @internal */
2156
+ providerCredentials: ReturnType<typeof createProviderCredentialRepo>;
2157
+ /** @public */
2158
+ externalWrites: ReturnType<typeof createExternalWriteLogRepo>;
2159
+ /** @internal */
2160
+ sessionTransfers: ReturnType<typeof createSessionTransferRepo>;
2161
+ /** @internal */
2162
+ skills: ReturnType<typeof createSkillRepo>;
2163
+ /** @internal */
2164
+ processSkills: ReturnType<typeof createProcessSkillRepo>;
2165
+ /** @internal */
2166
+ apiTokens: ReturnType<typeof createApiTokenRepo>;
2167
+ /** @internal */
2168
+ authSessions: ReturnType<typeof createAuthSessionRepo>;
2169
+ /** @internal */
2170
+ authLoginFlows: ReturnType<typeof createAuthLoginFlowRepo>;
2171
+ /** @internal */
2172
+ transaction<T>(fn: (repos: RepositoryBundle) => T): T;
2173
+ }
2174
+
2175
+ /** @internal */
2176
+ interface ProcessContextData {
2177
+ /** @internal */
2178
+ params: unknown;
2179
+ /** @internal */
2180
+ state: unknown;
2181
+ }
2182
+ /** @internal */
2183
+ interface ResolvedUiHumanTurnAction {
2184
+ /** @internal */
2185
+ kind: "ui_human_action";
2186
+ /** @internal */
2187
+ turnId: string;
2188
+ /** @internal */
2189
+ turnType: "human";
2190
+ /** @internal */
2191
+ semanticEntryRefKey: ProcessSemanticEntryRefKey | null;
2192
+ /** @internal */
2193
+ acceptanceState: TurnAcceptanceState;
2194
+ }
2195
+ /** @internal */
2196
+ interface ResolvedExternalHumanTriggerAction {
2197
+ /** @internal */
2198
+ kind: "external_human_trigger";
2199
+ /** @internal */
2200
+ turnId: string;
2201
+ /** @internal */
2202
+ turnType: "external";
2203
+ /** @internal */
2204
+ semanticEntryRefKey: ProcessSemanticEntryRefKey | null;
2205
+ /** @internal */
2206
+ acceptanceState: TurnAcceptanceState;
2207
+ /** @internal */
2208
+ externalTrigger: {
2209
+ /** @internal */
2210
+ id: string;
2211
+ /** @internal */
2212
+ actionId: string;
2213
+ /** @internal */
2214
+ label: string;
2215
+ /** @internal */
2216
+ description: string;
2217
+ };
2218
+ }
2219
+ /** @internal */
2220
+ type ResolvedTurnScopedAction = ResolvedUiHumanTurnAction | ResolvedExternalHumanTriggerAction;
2221
+ /** @internal */
2222
+ interface ResolvedAction<Definition> {
2223
+ /** @internal */
2224
+ definition: Definition;
2225
+ /** @internal */
2226
+ candidateSelectedTurnId: string | null;
2227
+ /** @internal */
2228
+ lifecycleStatus: ProcessTurnTerminalLifecycleStatus | null;
2229
+ }
2230
+ /** @internal */
2231
+ type ResolvedActionPreview = ResolvedAction<ProcessActionPreviewDefinition>;
2232
+ /** @internal */
2233
+ type ResolvedActionScheduling = ResolvedAction<ProcessActionSchedulingDefinition>;
2234
+ /** @internal */
2235
+ interface VisibleProcessActionSummary {
2236
+ /** @internal */
2237
+ id: string;
2238
+ /** @internal */
2239
+ label: string;
2240
+ /** @internal */
2241
+ description: string | null;
2242
+ /** @internal */
2243
+ form?: ProcessActionDefinition["form"];
2244
+ /** @internal */
2245
+ preview: ResolvedActionPreview | null;
2246
+ }
2247
+ /** @internal */
2248
+ interface ProcessActionRegistry {
2249
+ /** @internal */
2250
+ getAction(processId: string, actionId: string): ProcessActionDefinition | undefined;
2251
+ /** @internal */
2252
+ isTurnScopedAction(processId: string, actionId: string): boolean;
2253
+ /** @internal */
2254
+ listVisibleActions(processId: string, ctx: ServerProcessContext): VisibleProcessActionSummary[];
2255
+ /** @internal */
2256
+ getSelectedTurnSummary(processId: string, process: ProcessInstance, projects?: readonly ProcessProject[]): ProcessSelectedTurnSummary | null;
2257
+ /** @internal */
2258
+ getServerDefinition(processId: string): BuiltServerProcessDefinition | undefined;
2259
+ /** @internal */
2260
+ getTurnDefinition(processId: string, turnId: string): TurnDefinition<unknown, unknown> | undefined;
2261
+ /** @internal */
2262
+ getProcessGraph(processId: string): ExtensionProcessDefinition | undefined;
2263
+ /** @internal */
2264
+ getProcessDisplayName(processId: string): string | undefined;
2265
+ /** @internal */
2266
+ resolveContextData(processId: string, process: Pick<ProcessInstance, "paramsJson" | "stateJson">): ProcessContextData;
2267
+ /** @internal */
2268
+ resolveTurnScopedAction(processId: string, process: Pick<ProcessInstance, "selectedTurnId" | "paramsJson" | "stateJson">, actionId: string, source: ProcessActionExecutionSource): ResolvedTurnScopedAction | null;
2269
+ /** @internal */
2270
+ resolveActionPreview(processId: string, process: Pick<ProcessInstance, "selectedTurnId" | "paramsJson" | "stateJson">, actionId: string): ResolvedActionPreview | null;
2271
+ /** @internal */
2272
+ resolveActionScheduling(processId: string, process: Pick<ProcessInstance, "selectedTurnId" | "paramsJson" | "stateJson">, actionId: string): ResolvedActionScheduling | null;
2273
+ }
2274
+
2275
+ /** @internal */
2276
+ type ProcessModelAvailabilitySnapshot = ModelStatusCacheSnapshot;
2277
+ /** @internal */
2278
+ type PersistedModelConfigurationIssue = {
2279
+ /** @internal */
2280
+ readonly code: "invalid_turn_configs_json";
2281
+ /** @internal */
2282
+ readonly reason: "invalid_json" | "not_object" | "turn_config_not_object";
2283
+ /** @internal */
2284
+ readonly turnId?: string;
2285
+ };
2286
+ /** @internal */
2287
+ type PersistedModelRelationalIssue = {
2288
+ /** @internal */
2289
+ readonly code: "model_config_requires_llm_turn";
2290
+ /** @internal */
2291
+ readonly turnId: string;
2292
+ } | {
2293
+ /** @internal */
2294
+ readonly code: "selected_model_requires_selected_turn";
2295
+ /** @internal */
2296
+ readonly modelProfileId: string;
2297
+ } | {
2298
+ /** @internal */
2299
+ readonly code: "selected_model_requires_llm_turn";
2300
+ /** @internal */
2301
+ readonly turnId: string;
2302
+ /** @internal */
2303
+ readonly modelProfileId: string;
2304
+ };
2305
+ /** @internal */
2306
+ type PersistedModelSelectionIssue = {
2307
+ /** @internal */
2308
+ readonly code: "contradictory_provenance";
2309
+ /** @internal */
2310
+ readonly turnId: string;
2311
+ /** @internal */
2312
+ readonly modelProfileId: string;
2313
+ /** @internal */
2314
+ readonly kind: ModelSelectionKind;
2315
+ /** @internal */
2316
+ readonly source: ProcessSelectedTurnModelSource;
2317
+ };
2318
+ /** @internal */
2319
+ type PersistedModelIntegrityIssue = PersistedModelConfigurationIssue | PersistedModelRelationalIssue | PersistedModelSelectionIssue;
2320
+ /** @internal */
2321
+ type PersistedModelIntegrity = {
2322
+ /** @internal */
2323
+ readonly kind: "valid";
2324
+ } | {
2325
+ /** @internal */
2326
+ readonly kind: "malformed";
2327
+ /** @internal */
2328
+ readonly issues: readonly PersistedModelIntegrityIssue[];
2329
+ };
2330
+ /** @internal */
2331
+ type ProcessModelPolicyFailureBase = {
2332
+ /** @internal */
2333
+ readonly ok: false;
2334
+ /** @internal */
2335
+ readonly selection: DurableModelSelection | null;
2336
+ /** @internal */
2337
+ readonly availabilityRevision?: number;
2338
+ };
2339
+ /** @internal */
2340
+ type ProcessModelPolicyFailure = ProcessModelPolicyFailureBase & ({
2341
+ /** @internal */
2342
+ readonly code: "model_required";
2343
+ } | {
2344
+ /** @internal */
2345
+ readonly code: "unknown_model_profile";
2346
+ /** @internal */
2347
+ readonly modelProfileId: string;
2348
+ } | {
2349
+ /** @internal */
2350
+ readonly code: "model_profile_not_allowed";
2351
+ /** @internal */
2352
+ readonly modelProfileId: string;
2353
+ /** @internal */
2354
+ readonly processId: string;
2355
+ } | {
2356
+ /** @internal */
2357
+ readonly code: "model_unavailable" | "model_stale";
2358
+ /** @internal */
2359
+ readonly reason: string | null;
2360
+ } | {
2361
+ /** @internal */
2362
+ readonly code: "invalid_model_configuration";
2363
+ /** @internal */
2364
+ readonly source: "configuration" | "selection_provenance";
2365
+ /** @internal */
2366
+ readonly issues: readonly (PersistedModelConfigurationIssue | PersistedModelSelectionIssue)[];
2367
+ } | {
2368
+ /** @internal */
2369
+ readonly code: "stale_evaluation_snapshot";
2370
+ });
2371
+ /** @internal */
2372
+ interface ProcessModelPolicyResolution {
2373
+ /** @internal */
2374
+ readonly ok: true;
2375
+ /** @internal */
2376
+ readonly selection: DurableModelSelection | null;
2377
+ /** @internal */
2378
+ readonly availabilityRevision?: number;
2379
+ }
2380
+ /** @internal */
2381
+ type ProcessModelPolicyEvaluation = ProcessModelPolicyResolution | ProcessModelPolicyFailure;
2382
+ /** @internal */
2383
+ interface ProjectedModelProfile {
2384
+ /** @internal */
2385
+ readonly id: string;
2386
+ /** @internal */
2387
+ readonly providerId: string;
2388
+ /** @internal */
2389
+ readonly modelId: string;
2390
+ /** @internal */
2391
+ readonly thinkingLevel: string;
2392
+ /** @internal */
2393
+ readonly availability: "available" | "unavailable" | "stale";
2394
+ /** @internal */
2395
+ readonly safeReason: string | null;
2396
+ /** @internal */
2397
+ readonly checkedAt: string | null;
2398
+ }
2399
+ /** @internal */
2400
+ interface ProjectedModelDefault {
2401
+ /** @internal */
2402
+ readonly processConfigModelProfileId: string | null;
2403
+ /** @internal */
2404
+ readonly instanceModelProfileId: string | null;
2405
+ /** @internal */
2406
+ readonly effectiveModelProfileId: string | null;
2407
+ /** @internal */
2408
+ readonly source: "instance" | "process_config" | "catalog_default" | "none";
2409
+ }
2410
+ /** @internal */
2411
+ type ProjectedModelResolutionSource = ProcessSelectedTurnModelSource | "none";
2412
+ /** @internal */
2413
+ interface ProjectedLauncherModelSchema {
2414
+ /** @internal */
2415
+ readonly profiles: readonly ProjectedModelProfile[];
2416
+ /** @internal */
2417
+ readonly turns: readonly {
2418
+ /** @internal */
2419
+ readonly turnId: string;
2420
+ /** @internal */
2421
+ readonly description: string;
2422
+ }[];
2423
+ }
2424
+ /** @internal */
2425
+ interface ProjectedLauncherModelPreview {
2426
+ /** @internal */
2427
+ readonly defaultModel: {
2428
+ /** @internal */
2429
+ readonly source: ProjectedModelDefault["source"];
2430
+ /** @internal */
2431
+ readonly profile: ProjectedModelProfile | null;
2432
+ };
2433
+ /** @internal */
2434
+ readonly turns: readonly {
2435
+ /** @internal */
2436
+ readonly turnId: string;
2437
+ /** @internal */
2438
+ readonly description: string;
2439
+ /** @internal */
2440
+ readonly effective: {
2441
+ /** @internal */
2442
+ readonly source: ProjectedModelResolutionSource;
2443
+ /** @internal */
2444
+ readonly profile: ProjectedModelProfile | null;
2445
+ };
2446
+ }[];
2447
+ }
2448
+ /** @internal */
2449
+ type ProjectedProcessModelConfiguration = {
2450
+ /** @internal */
2451
+ readonly state: {
2452
+ /** @internal */
2453
+ readonly kind: "ready";
2454
+ } | {
2455
+ /** @internal */
2456
+ readonly kind: "blocked";
2457
+ /** @internal */
2458
+ readonly issues: readonly PersistedModelConfigurationIssue[];
2459
+ };
2460
+ /** @internal */
2461
+ readonly profiles: readonly ProjectedModelProfile[];
2462
+ /** @internal */
2463
+ readonly effectiveSelectedTurn: {
2464
+ /** @internal */
2465
+ readonly turnId: string;
2466
+ /** @internal */
2467
+ readonly description: string;
2468
+ /** @internal */
2469
+ readonly modelProfileId: string;
2470
+ /** @internal */
2471
+ readonly source: ProcessSelectedTurnModelSource;
2472
+ } | null;
2473
+ /** @internal */
2474
+ readonly defaultModel: ProjectedModelDefault;
2475
+ /** @internal */
2476
+ readonly turns: readonly {
2477
+ /** @internal */
2478
+ readonly turnId: string;
2479
+ /** @internal */
2480
+ readonly description: string;
2481
+ /** @internal */
2482
+ readonly pathType: string;
2483
+ /** @internal */
2484
+ readonly processConfigModelProfileId: string | null;
2485
+ /** @internal */
2486
+ readonly instanceModelProfileId: string | null;
2487
+ /** @internal */
2488
+ readonly effectiveConfiguredModelProfileId: string | null;
2489
+ /** @internal */
2490
+ readonly source: "instance" | "process_config" | "default";
2491
+ }[];
2492
+ };
2493
+ /** @internal */
2494
+ interface ProcessModelPolicyProjectionByKind {
2495
+ /** @internal */
2496
+ readonly profile_options: readonly ProjectedModelProfile[];
2497
+ /** @internal */
2498
+ readonly compatible_profiles: readonly string[];
2499
+ /** @internal */
2500
+ readonly launcher_schema: ProjectedLauncherModelSchema;
2501
+ /** @internal */
2502
+ readonly launcher_preview: ProjectedLauncherModelPreview;
2503
+ /** @internal */
2504
+ readonly process_configuration: ProjectedProcessModelConfiguration;
2505
+ }
2506
+ /** @internal */
2507
+ type ProcessModelPolicyEvaluationSubject = {
2508
+ /** @internal */
2509
+ readonly kind: "process_turn";
2510
+ /** @internal */
2511
+ readonly process: ProcessInstance;
2512
+ /** @internal */
2513
+ readonly turnId: string;
2514
+ /** @internal */
2515
+ readonly availability?: ProcessModelAvailabilitySnapshot;
2516
+ /** @internal */
2517
+ readonly startKind?: TurnStartKind;
2518
+ /** True only when selecting the first turn of a persisted process. @internal */
2519
+ readonly initialSelection?: boolean;
2520
+ /** @internal */
2521
+ readonly modelOverride?: string | null;
2522
+ } | {
2523
+ /** @internal */
2524
+ readonly kind: "launch_plan_turn";
2525
+ /** @internal */
2526
+ readonly plan: ProcessLaunchPlan;
2527
+ /** @internal */
2528
+ readonly turnId: string;
2529
+ /** @internal */
2530
+ readonly availability: ProcessModelAvailabilitySnapshot;
2531
+ } | {
2532
+ /** @internal */
2533
+ readonly kind: "runtime_selection";
2534
+ /** @internal */
2535
+ readonly processId: string;
2536
+ /** @internal */
2537
+ readonly selection: DurableModelSelection | null;
2538
+ /** @internal */
2539
+ readonly availability: ProcessModelAvailabilitySnapshot;
2540
+ } | {
2541
+ /** @internal */
2542
+ readonly kind: "preparation_recovery";
2543
+ /** @internal */
2544
+ readonly cause: "availability_transition" | "startup_reconciliation";
2545
+ /** @internal */
2546
+ readonly process: ProcessInstance;
2547
+ /** @internal */
2548
+ readonly currentStart: TurnStartRecord;
2549
+ /** @internal */
2550
+ readonly availability: ProcessModelAvailabilitySnapshot;
2551
+ };
2552
+ /** @internal */
2553
+ type ProcessModelPolicyProjectionSubject = {
2554
+ /** @internal */
2555
+ readonly kind: "profile_options";
2556
+ /** @internal */
2557
+ readonly processId: string;
2558
+ /** @internal */
2559
+ readonly availability: ProcessModelAvailabilitySnapshot;
2560
+ } | {
2561
+ /** @internal */
2562
+ readonly kind: "compatible_profiles";
2563
+ /** @internal */
2564
+ readonly processId: string;
2565
+ /** @internal */
2566
+ readonly providerId: string;
2567
+ /** @internal */
2568
+ readonly modelId: string;
2569
+ /** @internal */
2570
+ readonly availability: ProcessModelAvailabilitySnapshot;
2571
+ } | {
2572
+ /** @internal */
2573
+ readonly kind: "launcher_schema";
2574
+ /** @internal */
2575
+ readonly processId: string;
2576
+ /** @internal */
2577
+ readonly availability?: ProcessModelAvailabilitySnapshot;
2578
+ } | {
2579
+ /** @internal */
2580
+ readonly kind: "launcher_preview";
2581
+ /** @internal */
2582
+ readonly processId: string;
2583
+ /** @internal */
2584
+ readonly modelConfig: LaunchModelConfigInput;
2585
+ /** @internal */
2586
+ readonly availability: ProcessModelAvailabilitySnapshot;
2587
+ } | {
2588
+ /** @internal */
2589
+ readonly kind: "process_configuration";
2590
+ /** @internal */
2591
+ readonly process: ProcessInstance;
2592
+ /** @internal */
2593
+ readonly availability: ProcessModelAvailabilitySnapshot;
2594
+ };
2595
+ /** @internal */
2596
+ type ProcessModelPolicyProjectionKind = ProcessModelPolicyProjectionSubject["kind"];
2597
+ /** @internal */
2598
+ type ProcessModelPolicyProjectionSubjectFor<K extends ProcessModelPolicyProjectionKind> = Extract<ProcessModelPolicyProjectionSubject, {
2599
+ /** @internal */
2600
+ readonly kind: K;
2601
+ }>;
2602
+ /** @internal */
2603
+ interface ProcessModelPolicyFingerprintSubject {
2604
+ /** @internal */
2605
+ readonly process: ProcessInstance;
2606
+ /** @internal */
2607
+ readonly currentStart: TurnStartRecord;
2608
+ }
2609
+ /** @internal */
2610
+ interface PrepareLaunchPlanOptions {
2611
+ /** @internal */
2612
+ readonly modelConfig?: LaunchModelConfigInput;
2613
+ /** @internal */
2614
+ readonly replaceModelConfig?: boolean;
2615
+ /** @internal */
2616
+ readonly invalidModelConfig?: "reject" | "omit";
2617
+ }
2618
+ /** @internal */
2619
+ interface ServerProcessModelPolicy {
2620
+ /** @internal */
2621
+ prepareLaunchPlan(launchPlan: ProcessLaunchPlan, opts?: PrepareLaunchPlanOptions): LaunchPlanPreparationResultLike;
2622
+ /** @internal */
2623
+ inspectPersistedState(process: ProcessInstance): PersistedModelIntegrity;
2624
+ /** @internal */
2625
+ evaluate(request: ProcessModelPolicyEvaluationSubject): ProcessModelPolicyEvaluation;
2626
+ /** @internal */
2627
+ project<K extends ProcessModelPolicyProjectionKind>(request: ProcessModelPolicyProjectionSubjectFor<K>): ProcessModelPolicyProjectionByKind[K];
2628
+ /** @internal */
2629
+ fingerprint(request: ProcessModelPolicyFingerprintSubject): string;
2630
+ }
2631
+
2632
+ /** @internal */
2633
+ interface WsClientLike {
2634
+ /** @internal */
2635
+ readyState: number;
2636
+ /** @internal */
2637
+ send(data: string): void;
2638
+ /** @internal */
2639
+ on(event: string, handler: () => void): void;
2640
+ }
2641
+
2642
+ /** @internal */
2643
+ declare function createBroadcaster(): {
2644
+ /** @internal */
2645
+ addClient: (ws: WsClientLike) => void;
2646
+ /** @internal */
2647
+ broadcast: (frame: WsFrame) => void;
2648
+ /** @internal */
2649
+ sendDurable: <T extends KnownDurableWsFrameType>(type: T, payload: WsPayloadByType[T], instanceId?: string) => void;
2650
+ /** @internal */
2651
+ sendEphemeral: <T extends KnownEphemeralWsFrameType>(type: T, payload: WsPayloadByType[T], instanceId?: string) => void;
2652
+ };
2653
+ /** @internal */
2654
+ type Broadcaster = ReturnType<typeof createBroadcaster>;
2655
+
2656
+ /** @internal */
2657
+ interface ProcessOperationCoordinator {
2658
+ /** @internal */
2659
+ runExclusive<T>(instanceId: string, operation: () => Promise<T> | T): Promise<T>;
2660
+ }
2661
+
2662
+ /** @internal */
2663
+ type ProcessQuestionRepos = Pick<RepositoryBundle, "events" | "leases" | "processes" | "questionRequests" | "transaction" | "turnRecords">;
2664
+ /** @internal */
2665
+ type SubmitAnswersResult = {
2666
+ /** @internal */
2667
+ ok: true;
2668
+ /** @internal */
2669
+ request: ProcessQuestionRequest;
2670
+ } | {
2671
+ /** @internal */
2672
+ ok: false;
2673
+ /** @internal */
2674
+ code: "not_found" | "invalid";
2675
+ /** @internal */
2676
+ message: string;
2677
+ } | {
2678
+ /** @internal */
2679
+ ok: false;
2680
+ /** @internal */
2681
+ code: "not_current";
2682
+ /** @internal */
2683
+ message: string;
2684
+ /** @internal */
2685
+ request: ProcessQuestionRequest;
2686
+ };
2687
+ /** @internal */
2688
+ declare function createProcessQuestionService(input: {
2689
+ /** @internal */
2690
+ repos: ProcessQuestionRepos;
2691
+ /** @internal */
2692
+ processOperations: ProcessOperationCoordinator;
2693
+ /** @internal */
2694
+ broadcaster: Broadcaster;
2695
+ /** @internal */
2696
+ getWorkerId: (instanceId: string) => string | null;
2697
+ /** @internal */
2698
+ sendQuestionResponse: (instanceId: string, workerId: string, payload: WorkerQuestionResponsePayload) => void;
2699
+ /** @internal */
2700
+ emitQuestionRequested?: (request: ProcessQuestionRequest) => void | Promise<void>;
2701
+ }): {
2702
+ /** @internal */
2703
+ listOpen: (instanceId?: string) => ProcessQuestionRequest[];
2704
+ /** @internal */
2705
+ handleWorkerRequest(instanceId: string, workerLeaseId: string, workerId: string, payload: WorkerQuestionRequestedPayload): Promise<void>;
2706
+ /** @internal */
2707
+ submitAnswers(instanceId: string, requestId: string, draftInput: readonly QuestionAnswerDraft[], actor: Actor): Promise<SubmitAnswersResult>;
2708
+ };
2709
+ /** @internal */
2710
+ type ProcessQuestionService = ReturnType<typeof createProcessQuestionService>;
2711
+
2712
+ /** @internal */
2713
+ interface WorkerEventLogEntry {
2714
+ /** @internal */
2715
+ instanceId: string;
2716
+ /** @internal */
2717
+ workerId: string;
2718
+ /** @internal */
2719
+ eventType: string;
2720
+ /** @internal */
2721
+ selectedTurnId: string | null;
2722
+ /** @internal */
2723
+ timestamp: string;
2724
+ /** @internal */
2725
+ serverObservedAt: string;
2726
+ /** @internal */
2727
+ serverObservedLatencyMs: number | null;
2728
+ /** @internal */
2729
+ turnRecordId: string | null;
2730
+ /** @internal */
2731
+ data: Record<string, unknown>;
2732
+ }
2733
+
2734
+ /** @internal */
2735
+ interface WorkerTurnIpcRecorderCallbacks {
2736
+ /** @internal */
2737
+ onTurnOutcomeRecorded?: (instanceId: string, turnId: string, outcome: string, params: Record<string, unknown>) => void;
2738
+ /** @internal */
2739
+ onTurnTerminalRecorded?: (instanceId: string, workerId: string, turnRecordId: string) => void;
2740
+ /** @internal */
2741
+ onTurnFailedRecorded?: (input: {
2742
+ /** @internal */
2743
+ instanceId: string;
2744
+ /** @internal */
2745
+ workerId: string;
2746
+ /** @internal */
2747
+ turnRecordId: string;
2748
+ /** @internal */
2749
+ turnId: string;
2750
+ /** @internal */
2751
+ turnType: WorkerTurnFailedPayload["turnType"];
2752
+ /** @internal */
2753
+ errorSummary: string;
2754
+ /** @internal */
2755
+ errorClass?: WorkerTurnFailedPayload["errorClass"];
2756
+ /** @internal */
2757
+ failureCode?: WorkerTurnFailedPayload["failureCode"];
2758
+ }) => void;
2759
+ /** @internal */
2760
+ onTurnTerminalRecordingFailed?: (input: {
2761
+ /** @internal */
2762
+ instanceId: string;
2763
+ /** @internal */
2764
+ workerId: string;
2765
+ /** @internal */
2766
+ turnRecordId: string;
2767
+ /** @internal */
2768
+ terminalType: "outcome" | "failure";
2769
+ /** @internal */
2770
+ code: string;
2771
+ /** @internal */
2772
+ message: string;
2773
+ }) => void;
2774
+ }
2775
+
2776
+ /** @internal */
2777
+ interface IpcHandlerDeps extends Pick<RepositoryBundle, "processes" | "projects" | "inputs" | "events" | "leases" | "turnRecords"> {
2778
+ /** @internal */
2779
+ startupObservations?: RepositoryBundle["startupObservations"];
2780
+ /** @internal */
2781
+ getLaunchCoordinator?: () => LaunchCoordinator | undefined;
2782
+ /** @internal */
2783
+ processQuestions?: ProcessQuestionService;
2784
+ /** @internal */
2785
+ broadcaster: Broadcaster;
2786
+ /** @internal */
2787
+ commands: ProcessEngine;
2788
+ /** @internal */
2789
+ workerEventLogger?: (entry: WorkerEventLogEntry) => void;
2790
+ /** @internal */
2791
+ appendDiagnosticTrace?: (instanceId: string, text: string) => void;
2792
+ /** @internal */
2793
+ updateCredential?: (input: {
2794
+ /** @internal */
2795
+ providerId: string;
2796
+ /** @internal */
2797
+ expectedRevision: number;
2798
+ /** @internal */
2799
+ values: Record<string, string>;
2800
+ }) => {
2801
+ /** @internal */
2802
+ accepted: boolean;
2803
+ /** @internal */
2804
+ currentRevision: number | null;
2805
+ /** @internal */
2806
+ safeReason?: string;
2807
+ };
2808
+ /** @internal */
2809
+ handleIntegrationToolRequest?: (instanceId: string, payload: WorkerIntegrationToolRequestPayload) => Promise<WorkerIntegrationToolResultPayload>;
2810
+ /** @internal */
2811
+ handleIntegrationToolCancel?: (instanceId: string, payload: WorkerIntegrationToolCancelPayload) => void;
2812
+ }
2813
+ /** @internal */
2814
+ interface IpcHandlerCallbacks extends WorkerTurnIpcRecorderCallbacks {
2815
+ /** @internal */
2816
+ onWorkerReady?: (instanceId: string, workerId: string) => void;
2817
+ /** @internal */
2818
+ onWorkerFailed?: (instanceId: string, workerId: string, error: string) => void;
2819
+ /** @internal */
2820
+ onWorkerExited?: (instanceId: string, workerId: string) => void;
2821
+ /** @internal */
2822
+ onCleanupCompleted?: (instanceId: string, workerId: string) => void;
2823
+ /** @internal */
2824
+ onWorkerTurnStartAccepted?: (instanceId: string, workerId: string, payload: WorkerTurnStartAcceptedPayload) => void;
2825
+ /** @internal */
2826
+ onCredentialUpdateResult?: (instanceId: string, workerId: string, payload: WorkerCredentialUpdateResultPayload) => void;
2827
+ /** @internal */
2828
+ onIntegrationToolResult?: (instanceId: string, workerId: string, payload: WorkerIntegrationToolResultPayload) => void;
2829
+ }
2830
+ /** @internal */
2831
+ declare function createIpcHandler(deps: IpcHandlerDeps, callbacks: IpcHandlerCallbacks): {
2832
+ /** @internal */
2833
+ handleMessage(envelope: IpcEnvelope): void;
2834
+ };
2835
+ /** @internal */
2836
+ type IpcHandler = ReturnType<typeof createIpcHandler>;
2837
+
2838
+ /** @internal */
2839
+ interface WorkerWebSocketLike {
2840
+ /** @internal */
2841
+ readyState: number;
2842
+ /** @internal */
2843
+ send(data: string): void;
2844
+ /** @internal */
2845
+ close(code?: number, reason?: string): void;
2846
+ /** @internal */
2847
+ on(event: "message", handler: (raw: Buffer | string | ArrayBuffer | Buffer[]) => void): void;
2848
+ /** @internal */
2849
+ on(event: "close", handler: (event?: {
2850
+ /** @internal */
2851
+ code?: number;
2852
+ /** @internal */
2853
+ reason?: string;
2854
+ }) => void): void;
2855
+ /** @internal */
2856
+ on(event: "error", handler: (error: unknown) => void): void;
2857
+ }
2858
+ /** @internal */
2859
+ interface WorkerWebSocketCallbacks {
2860
+ /** @internal */
2861
+ onEnvelope(envelope: IpcEnvelope): void;
2862
+ /** @internal */
2863
+ onInvalidOutput(): void;
2864
+ /** @internal */
2865
+ onRuntimeError(error: unknown): void;
2866
+ }
2867
+ /** @internal */
2868
+ declare function createWorkerWebSocketIpcManager(options?: {
2869
+ /** @internal */
2870
+ authTimeoutMs?: number;
2871
+ /** @internal */
2872
+ maxBufferedMessages?: number;
2873
+ }): {
2874
+ /** @internal */
2875
+ setUnknownWorkerConnectionsRetryable(enabled: boolean): void;
2876
+ /** @internal */
2877
+ verifyWorkerToken({ instanceId, workerId, token, }: {
2878
+ /** @internal */
2879
+ instanceId: string;
2880
+ /** @internal */
2881
+ workerId: string;
2882
+ /** @internal */
2883
+ token: string;
2884
+ }): boolean;
2885
+ /** @internal */
2886
+ registerWorker({ instanceId, workerId, callbacks, tokenHash, }: {
2887
+ /** @internal */
2888
+ instanceId: string;
2889
+ /** @internal */
2890
+ workerId: string;
2891
+ /** @internal */
2892
+ callbacks: WorkerWebSocketCallbacks;
2893
+ /** @internal */
2894
+ tokenHash: string;
2895
+ }): void;
2896
+ /** @internal */
2897
+ bindSocket({ instanceId, workerId, socket, }: {
2898
+ /** @internal */
2899
+ instanceId: string;
2900
+ /** @internal */
2901
+ workerId: string;
2902
+ /** @internal */
2903
+ socket: WorkerWebSocketLike;
2904
+ }): {
2905
+ /** @internal */
2906
+ ok: true;
2907
+ } | {
2908
+ /** @internal */
2909
+ ok: false;
2910
+ /** @internal */
2911
+ error: string;
2912
+ /** @internal */
2913
+ code: number;
2914
+ };
2915
+ /** @internal */
2916
+ send(instanceId: string, workerId: string, message: ServerToWorkerMessage): void;
2917
+ /** @internal */
2918
+ unregister(instanceId: string, workerId: string, reason: string): void;
2919
+ };
2920
+ /** @internal */
2921
+ type WorkerWebSocketIpcManager = ReturnType<typeof createWorkerWebSocketIpcManager>;
2922
+
2923
+ /** @public */
2924
+ interface WorkerHandle {
2925
+ /** @internal */
2926
+ workerId: string;
2927
+ /** @internal */
2928
+ instanceId: string;
2929
+ /** Runtime-specific handle id when known; used to distinguish duplicate units during adoption scans. @internal */
2930
+ unitId?: string;
2931
+ /** @internal */
2932
+ namespace?: string;
2933
+ /** @internal */
2934
+ send(message: ServerToWorkerMessage): void;
2935
+ /** @internal */
2936
+ kill(signal?: NodeJS.Signals | number): void;
2937
+ /** Stops the physical runtime and rejects if disappearance cannot be confirmed. @internal */
2938
+ killAndWait?(signal?: NodeJS.Signals | number): Promise<void>;
2939
+ /** @internal */
2940
+ detach(reason: string): void;
2941
+ /** @internal */
2942
+ onceExit(listener: () => void): void;
2943
+ }
2944
+ /** @public */
2945
+ interface WorkerSupervisor {
2946
+ /** Returns undefined when accepted into the capacity queue. @internal */
2947
+ spawnWorker(instanceId: string): Promise<WorkerHandle | undefined>;
2948
+ /** @internal */
2949
+ stopWorker(instanceId: string, reason: string): Promise<void>;
2950
+ /** @internal */
2951
+ abortTurn(instanceId: string, reason: string): void;
2952
+ /** @internal */
2953
+ deliverInputs(instanceId: string, inputs: InputDelivery[]): void;
2954
+ /** @internal */
2955
+ acceptTurnStart(instanceId: string, workerId: string, startRecordId: string, turnRecordId: string): void;
2956
+ /** @internal */
2957
+ reconcileAcceptedTurnStart(instanceId: string, workerId: string): boolean;
2958
+ /** @internal */
2959
+ acknowledgeTurnTerminal(instanceId: string, workerId: string, payload: WorkerTurnTerminalRecordedPayload): void;
2960
+ /** @internal */
2961
+ questionResponse(instanceId: string, workerId: string, payload: WorkerQuestionResponsePayload): void;
2962
+ /** @internal */
2963
+ credentialUpdateResult(instanceId: string, workerId: string, payload: WorkerCredentialUpdateResultPayload): void;
2964
+ /** @internal */
2965
+ integrationToolResult(instanceId: string, workerId: string, payload: WorkerIntegrationToolResultPayload): void;
2966
+ /** @public */
2967
+ getWorker(instanceId: string): WorkerHandle | undefined;
2968
+ /** @internal */
2969
+ isAdoptionPending(instanceId: string): boolean;
2970
+ /** @internal */
2971
+ adoptRegisteredWorkers(): Promise<void>;
2972
+ /** @internal */
2973
+ detachAll(reason: string): Promise<void>;
2974
+ /** @public */
2975
+ shutdownAll(reason: string): Promise<void>;
2976
+ }
2977
+
2978
+ /** @internal */
2979
+ interface QueuedProcessInput extends QueuedProcessInputLike {
2980
+ }
2981
+
2982
+ /** @internal */
2983
+ interface PiSessionTreeNode {
2984
+ /** @internal */
2985
+ entry: SessionEntry;
2986
+ /** @internal */
2987
+ children: PiSessionTreeNode[];
2988
+ /** @internal */
2989
+ label?: string;
2990
+ }
2991
+ /** @internal */
2992
+ interface ReadonlyPiSessionTree {
2993
+ /** Identifier of the parsed source (instance id or file path). @internal */
2994
+ treeFile: string;
2995
+ /** @internal */
2996
+ header: SessionHeader | null;
2997
+ /** @internal */
2998
+ entries: SessionEntry[];
2999
+ /** @internal */
3000
+ leafId: string | null;
3001
+ /** @internal */
3002
+ getEntry(id: string): SessionEntry | undefined;
3003
+ /** @internal */
3004
+ getChildren(parentId: string): SessionEntry[];
3005
+ /** @internal */
3006
+ getBranch(fromId?: string): SessionEntry[];
3007
+ /** @internal */
3008
+ getTree(): PiSessionTreeNode[];
3009
+ }
3010
+
3011
+ /** @internal */
3012
+ interface ParsedInstanceTree {
3013
+ /** @internal */
3014
+ entriesById: Map<string, PrimaryPathEntrySnapshot>;
3015
+ /** @internal */
3016
+ labelsByEntryId: Map<string, string>;
3017
+ }
3018
+
3019
+ /**
3020
+ * A handle to a process session payload that exposes a change `signature`
3021
+ * before the reader pays the cost of parsing the full content.
3022
+ *
3023
+ * The two-step shape lets the reader skip re-parsing whenever the signature is
3024
+ * unchanged. Sources may capture content while producing a handle so its
3025
+ * signature and payload come from the same storage generation.
3026
+ */
3027
+ /** @internal */
3028
+ interface ProcessSessionSnapshotHandle {
3029
+ /** Opaque value that changes whenever the underlying session content changes. @internal */
3030
+ signature: string;
3031
+ /** Loads the raw session JSONL content captured by this handle. @internal */
3032
+ load(): Promise<string>;
3033
+ }
3034
+ /**
3035
+ * Provides raw process session content without committing the server to a
3036
+ * particular storage location.
3037
+ *
3038
+ * Production read models use a server-owned latest-snapshot store fed by the
3039
+ * worker session-snapshot HTTP exchange. The store may be file-backed, but it
3040
+ * represents the server copy of the session JSONL rather than a requirement to
3041
+ * mount or inspect worker volumes.
3042
+ */
3043
+ /** @internal */
3044
+ interface ProcessSessionSource {
3045
+ /** Returns a handle for the instance, or `null` when no session exists yet. @internal */
3046
+ readSnapshotHandle(instanceId: string): Promise<ProcessSessionSnapshotHandle | null>;
3047
+ }
3048
+ /** @internal */
3049
+ interface ProcessSessionTreeReadResult {
3050
+ /** @internal */
3051
+ signature: string | null;
3052
+ /** @internal */
3053
+ piTree: ReadonlyPiSessionTree;
3054
+ /** @internal */
3055
+ parsedTree: ParsedInstanceTree;
3056
+ }
3057
+ /**
3058
+ * Reads and caches parsed process session state from a {@link ProcessSessionSource}.
3059
+ *
3060
+ * All server read paths (primary-path snapshots, diagnostics, leaf-outcome
3061
+ * capture and failed-turn continuation) go through this seam so
3062
+ * the server never reads worker filesystems directly.
3063
+ */
3064
+ /** @internal */
3065
+ declare class ProcessSessionReader {
3066
+ private readonly source;
3067
+ private readonly sessionTreeCache;
3068
+ private readonly inFlightReads;
3069
+ /** @internal */
3070
+ constructor(source: ProcessSessionSource);
3071
+ /** @internal */
3072
+ readSessionTree(instanceId: string): Promise<ProcessSessionTreeReadResult>;
3073
+ /** @internal */
3074
+ readInstanceTree(instanceId: string): Promise<ParsedInstanceTree>;
3075
+ /** @internal */
3076
+ readPiSessionTree(instanceId: string): Promise<ReadonlyPiSessionTree>;
3077
+ private readCachedSessionTree;
3078
+ /** Returns the raw session JSONL, or `null` when no session exists yet. @internal */
3079
+ readRawContent(instanceId: string): Promise<string | null>;
3080
+ }
3081
+
3082
+ /** @internal */
3083
+ interface ProcessUiRegistry {
3084
+ /** @internal */
3085
+ getLeafOutcomeDefinition(processId: string): ProcessLeafOutcomeDefinition | undefined;
3086
+ }
3087
+
3088
+ /** @internal */
3089
+ type ProcessProductRefPatch = Record<string, ProcessProductRef | null | undefined>;
3090
+
3091
+ /** @internal */
3092
+ type EntryRefPatch = Record<string, {
3093
+ /** @internal */
3094
+ entryId: string;
3095
+ /** @internal */
3096
+ turnRecordId?: string | null;
3097
+ } | null | undefined>;
3098
+
3099
+ /** @internal */
3100
+ type ProcessSemanticEntryRefPatch = Partial<Record<ProcessSemanticEntryRefKey, EntryRefPatch[string]>>;
3101
+
3102
+ /** @internal */
3103
+ type DeferredProcessExtensionEvent = {
3104
+ [K in ServerExtensionEventName]: {
3105
+ /** @internal */
3106
+ type: K;
3107
+ /** @internal */
3108
+ payload: ServerExtensionEventMap[K];
3109
+ };
3110
+ }[ServerExtensionEventName];
3111
+
3112
+ /** @internal */
3113
+ type FutureExecutionTransitionPlan = {
3114
+ /** @internal */
3115
+ kind: "consume";
3116
+ /** @internal */
3117
+ futureExecutionId: string;
3118
+ /** @internal */
3119
+ expectedKind: FutureExecution["kind"];
3120
+ /** @internal */
3121
+ expectedNextRunAt: string;
3122
+ } | {
3123
+ /** @internal */
3124
+ kind: "advance";
3125
+ /** @internal */
3126
+ futureExecutionId: string;
3127
+ /** @internal */
3128
+ expectedKind: FutureExecution["kind"];
3129
+ /** @internal */
3130
+ expectedNextRunAt: string;
3131
+ /** @internal */
3132
+ nextRunAt: string;
3133
+ } | {
3134
+ /** @internal */
3135
+ kind: "block";
3136
+ /** @internal */
3137
+ futureExecutionId: string;
3138
+ /** @internal */
3139
+ expectedKind: FutureExecution["kind"];
3140
+ /** @internal */
3141
+ expectedNextRunAt: string;
3142
+ /** @internal */
3143
+ blockedReason: FutureExecutionBlockReason;
3144
+ /** @internal */
3145
+ modelSelection: DurableModelSelection | null;
3146
+ /** @internal */
3147
+ nextRunAt?: string;
3148
+ } | {
3149
+ /** @internal */
3150
+ kind: "retry";
3151
+ /** @internal */
3152
+ futureExecutionId: string;
3153
+ /** @internal */
3154
+ expectedKind: FutureExecution["kind"];
3155
+ /** @internal */
3156
+ expectedNextRunAt: string;
3157
+ /** @internal */
3158
+ nextRunAt: string;
3159
+ } | {
3160
+ /** @internal */
3161
+ kind: "cancel_action";
3162
+ /** @internal */
3163
+ futureExecutionId: string;
3164
+ /** @internal */
3165
+ expectedInstanceId: string;
3166
+ };
3167
+
3168
+ /** @internal */
3169
+ type DurableBroadcast = DurableWsFrameInput;
3170
+ /** @internal */
3171
+ type TurnRecordWrite = {
3172
+ /** @internal */
3173
+ kind: "create";
3174
+ /** @internal */
3175
+ input: CreateProcessTurnRecordInput;
3176
+ } | {
3177
+ /** @internal */
3178
+ kind: "update";
3179
+ /** @internal */
3180
+ id: string;
3181
+ /** @internal */
3182
+ input: UpdateProcessTurnRecordInput;
3183
+ };
3184
+ /** @internal */
3185
+ type TurnStartWrite = {
3186
+ /** @internal */
3187
+ kind: "create";
3188
+ /** @internal */
3189
+ input: Omit<TurnStartRecord, "id" | "createdAt" | "updatedAt"> & {
3190
+ /** @internal */
3191
+ id?: string;
3192
+ };
3193
+ } | {
3194
+ /** @internal */
3195
+ kind: "cas_state";
3196
+ /** @internal */
3197
+ id: string;
3198
+ /** @internal */
3199
+ expectedKind: TurnStartRecord["state"]["kind"];
3200
+ /** @internal */
3201
+ state: TurnStartRecord["state"];
3202
+ };
3203
+ /** @internal */
3204
+ type TurnAnnotationWrite = {
3205
+ /** @internal */
3206
+ kind: "create";
3207
+ /** @internal */
3208
+ input: CreateProcessTurnAnnotationInput;
3209
+ } | {
3210
+ /** @internal */
3211
+ kind: "update";
3212
+ /** @internal */
3213
+ id: string;
3214
+ /** @internal */
3215
+ input: UpdateProcessTurnAnnotationInput;
3216
+ } | {
3217
+ /** @internal */
3218
+ kind: "delete";
3219
+ /** @internal */
3220
+ id: string;
3221
+ };
3222
+ /** @internal */
3223
+ type LeafOutcomeSnapshotWrite = {
3224
+ /** @internal */
3225
+ kind: "create";
3226
+ /** @internal */
3227
+ input: CreateProcessLeafOutcomeSnapshotInput;
3228
+ };
3229
+ /** @internal */
3230
+ type WorkerIntent = {
3231
+ /** @internal */
3232
+ kind: "reconcile";
3233
+ } | {
3234
+ /** @internal */
3235
+ kind: "restart_worker";
3236
+ } | {
3237
+ /** @internal */
3238
+ kind: "start_if_needed";
3239
+ } | {
3240
+ /** @internal */
3241
+ kind: "abort_turn";
3242
+ /** @internal */
3243
+ reason: string;
3244
+ } | {
3245
+ /** @internal */
3246
+ kind: "stop_with_reason";
3247
+ /** @internal */
3248
+ reason: string;
3249
+ };
3250
+ /** @internal */
3251
+ type PendingExternalSourceFireWrite = {
3252
+ /** @internal */
3253
+ kind: "create";
3254
+ /** @internal */
3255
+ input: CreatePendingExternalSourceFireInput;
3256
+ } | {
3257
+ /** @internal */
3258
+ kind: "update";
3259
+ /** @internal */
3260
+ id: string;
3261
+ /** @internal */
3262
+ input: UpdatePendingExternalSourceFireInput;
3263
+ } | {
3264
+ /** @internal */
3265
+ kind: "delete";
3266
+ /** @internal */
3267
+ id: string;
3268
+ };
3269
+ /** @internal */
3270
+ interface DecisionMetadata {
3271
+ /** @internal */
3272
+ nextTurnModelProfileId?: string | null;
3273
+ /** @internal */
3274
+ providerOptions?: Readonly<Record<string, string>>;
3275
+ }
3276
+ /** @internal */
3277
+ interface Writes {
3278
+ /** @internal */
3279
+ processPatch: UpdateProcessInstanceInput;
3280
+ /** @internal */
3281
+ changedFields: string[];
3282
+ /** @internal */
3283
+ projectWrite?: {
3284
+ /** @internal */
3285
+ id: string;
3286
+ /** @internal */
3287
+ input: UpdateProcessProjectInput;
3288
+ };
3289
+ /** @internal */
3290
+ turnRecordWrites: TurnRecordWrite[];
3291
+ /** @internal */
3292
+ turnStartWrites: TurnStartWrite[];
3293
+ /** @internal */
3294
+ turnAnnotationWrites: TurnAnnotationWrite[];
3295
+ /** @internal */
3296
+ leafOutcomeSnapshotWrites: LeafOutcomeSnapshotWrite[];
3297
+ /** @internal */
3298
+ events: CreateProcessEventInput[];
3299
+ /** @internal */
3300
+ broadcasts: DurableBroadcast[];
3301
+ /** @internal */
3302
+ queuedInputs: QueuedProcessInput[];
3303
+ /** @internal */
3304
+ extensionEvents: DeferredProcessExtensionEvent[];
3305
+ /** @internal */
3306
+ futureExecutionPlans: FutureExecutionTransitionPlan[];
3307
+ /** @internal */
3308
+ pendingExternalSourceFireWrites: PendingExternalSourceFireWrite[];
3309
+ /** @internal */
3310
+ workerIntent?: WorkerIntent;
3311
+ }
3312
+
3313
+ /** @internal */
3314
+ interface RecordCommit {
3315
+ /** @internal */
3316
+ turnEventSequences?: Record<string, number>;
3317
+ /** @internal */
3318
+ instanceId: string;
3319
+ /** @internal */
3320
+ processBefore: ProcessInstance | null;
3321
+ /** @internal */
3322
+ processAfter: ProcessInstance | null;
3323
+ /** @internal */
3324
+ committedProject: ProcessProject | null;
3325
+ /** @internal */
3326
+ committedTurnRecords: ProcessTurnRecord[];
3327
+ /** @internal */
3328
+ committedLeafOutcomeSnapshots: ProcessLeafOutcomeSnapshot[];
3329
+ /** @internal */
3330
+ committedAnnotationChanges: Array<{
3331
+ /** @internal */
3332
+ change: "created" | "updated";
3333
+ /** @internal */
3334
+ annotation: ProcessTurnAnnotation;
3335
+ }>;
3336
+ /** @internal */
3337
+ persistedInputs: ProcessInput[];
3338
+ /** @internal */
3339
+ extensionEvents: DeferredProcessExtensionEvent[];
3340
+ /** @internal */
3341
+ workerIntent?: WorkerIntent;
3342
+ }
3343
+
3344
+ /** @internal */
3345
+ interface Decision<TData = void> {
3346
+ /** @internal */
3347
+ ok: true;
3348
+ /** @internal */
3349
+ writes: Writes;
3350
+ /** @internal */
3351
+ data: TData;
3352
+ /** @internal */
3353
+ metadata?: DecisionMetadata;
3354
+ /**
3355
+ * Used when operation data is only known after the durable commit. For example,
3356
+ * queued inputs receive durable sequence numbers while recording.
3357
+ */
3358
+ /** @internal */
3359
+ deriveData?: (commit: RecordCommit) => TData;
3360
+ }
3361
+ /** @internal */
3362
+ interface RejectedDecision<TData = unknown> {
3363
+ /** @internal */
3364
+ ok: false;
3365
+ /** @internal */
3366
+ code: EngineErrorCode;
3367
+ /** @internal */
3368
+ message: string;
3369
+ /** @internal */
3370
+ data?: TData;
3371
+ }
3372
+ /** @internal */
3373
+ type DecideResult<TData> = Decision<TData> | RejectedDecision<TData>;
3374
+
3375
+ /** @internal */
3376
+ interface OperationInputBase {
3377
+ /** @internal */
3378
+ instanceId: string;
3379
+ }
3380
+ /** @internal */
3381
+ interface OperationMessages {
3382
+ /** @internal */
3383
+ dispatchErrorMessage?: string;
3384
+ /** @internal */
3385
+ reconcileErrorMessage?: string;
3386
+ }
3387
+ /** @internal */
3388
+ type DecideFunction<TInput extends OperationInputBase, TData> = {
3389
+ /** @internal */
3390
+ bivarianceHack(ctx: DecideContext, input: TInput): Promise<DecideResult<TData>> | DecideResult<TData>;
3391
+ }["bivarianceHack"];
3392
+ /** @internal */
3393
+ type MessageResolver<TInput extends OperationInputBase> = {
3394
+ /** @internal */
3395
+ bivarianceHack(input: TInput): OperationMessages;
3396
+ }["bivarianceHack"];
3397
+ /** @internal */
3398
+ type BestEffortFailureReportingResolver<TInput extends OperationInputBase> = {
3399
+ /** @internal */
3400
+ bivarianceHack(input: TInput): boolean;
3401
+ }["bivarianceHack"];
3402
+ /** @internal */
3403
+ type AfterRecordFunction<TInput extends OperationInputBase, TData> = {
3404
+ /** @internal */
3405
+ bivarianceHack(input: TInput, data: TData): void;
3406
+ }["bivarianceHack"];
3407
+ /** @internal */
3408
+ interface OperationSpec<TKind extends string, TInput extends OperationInputBase, TData> {
3409
+ /** @internal */
3410
+ kind: TKind;
3411
+ /** @internal */
3412
+ label?: string;
3413
+ /** Reject this operation while another subsystem has reserved new-turn admission. @internal */
3414
+ admission?: "new_turn";
3415
+ /**
3416
+ * Operation decisions are pure with respect to process-owned durable state and
3417
+ * the outside world: they may read repositories and prepare writes/reactions,
3418
+ * but they must not commit state, broadcast, dispatch inputs, control workers,
3419
+ * or emit extension events.
3420
+ */
3421
+ /** @internal */
3422
+ decide: DecideFunction<TInput, TData>;
3423
+ /** Runs after the transaction and process lock complete, before reactions are dispatched. @internal */
3424
+ afterRecord?: AfterRecordFunction<TInput, TData>;
3425
+ /** @internal */
3426
+ messages?: OperationMessages | MessageResolver<TInput>;
3427
+ /** @internal */
3428
+ reportBestEffortFailures?: boolean | BestEffortFailureReportingResolver<TInput>;
3429
+ }
3430
+ /** @internal */
3431
+ type OperationInput<TOp> = TOp extends OperationSpec<string, infer TInput, unknown> ? TInput : never;
3432
+ /** @internal */
3433
+ type OperationData<TOp> = TOp extends OperationSpec<string, OperationInputBase, infer TData> ? TData : never;
3434
+
3435
+ /** @internal */
3436
+ interface ParkProcessLifecyclePayload {
3437
+ /** @internal */
3438
+ selectedTurnId?: string | null;
3439
+ /** @internal */
3440
+ reason?: string;
3441
+ /** @internal */
3442
+ errorClass?: WorkerErrorClass;
3443
+ }
3444
+ /** @internal */
3445
+ interface ProcessEngineLogger {
3446
+ /** @internal */
3447
+ error(payload: Record<string, unknown>, message?: string): void;
3448
+ }
3449
+ /** @internal */
3450
+ interface ProcessEngineDeps extends Pick<RepositoryBundle, "processes" | "events" | "futureExecutions" | "inputs" | "projects" | "pendingExternalSourceFires" | "leafOutcomeSnapshots" | "questionRequests" | "turnRecords" | "turnStarts" | "leases" | "turnAnnotations" | "transaction"> {
3451
+ /** @internal */
3452
+ processOperations: ProcessOperationCoordinator;
3453
+ /** @internal */
3454
+ broadcaster: Broadcaster;
3455
+ /** @internal */
3456
+ config?: LeitwerkConfig;
3457
+ /** @internal */
3458
+ toastTtlMs?: number;
3459
+ /** @internal */
3460
+ getSupervisor: () => WorkerSupervisor | undefined;
3461
+ /** @internal */
3462
+ extensionHost?: ExtensionHost;
3463
+ /** @internal */
3464
+ processGraphs: ProcessGraphRegistry;
3465
+ /** @internal */
3466
+ sessionReader?: ProcessSessionReader;
3467
+ /** @internal */
3468
+ getProcessActionRegistry?: () => ProcessActionRegistry | undefined;
3469
+ /** @internal */
3470
+ getProcessUiRegistry?: () => ProcessUiRegistry | undefined;
3471
+ /** @internal */
3472
+ logger?: ProcessEngineLogger;
3473
+ /** Required by the server-owned engine; embedded callers adapt at construction. @internal */
3474
+ processModelPolicy: ServerProcessModelPolicy;
3475
+ /** @internal */
3476
+ getModelAvailabilitySnapshot: () => ModelStatusCacheSnapshot;
3477
+ /** @internal */
3478
+ afterRecord?: (process: ProcessInstance) => void | Promise<void>;
3479
+ /** @internal */
3480
+ afterSuccessHooks?: Set<(instanceId: string) => void | Promise<void>>;
3481
+ /** @internal */
3482
+ isNewTurnBlocked?: (instanceId: string) => boolean;
3483
+ /** @internal */
3484
+ prepareTurnStarts?: (process: ProcessInstance, writes: Writes, providerOptions?: Readonly<Record<string, string>>, availabilitySnapshot?: ModelStatusCacheSnapshot) => Promise<{
3485
+ /** @internal */
3486
+ ok: true;
3487
+ } | {
3488
+ /** @internal */
3489
+ ok: false;
3490
+ /** @internal */
3491
+ code: string;
3492
+ /** @internal */
3493
+ message: string;
3494
+ }>;
3495
+ }
3496
+ /** @internal */
3497
+ interface DecideContext {
3498
+ /** @internal */
3499
+ deps: ProcessEngineDeps;
3500
+ /** @internal */
3501
+ instanceId: string;
3502
+ /** @internal */
3503
+ process: ProcessInstance;
3504
+ }
3505
+ /** @internal */
3506
+ interface ProcessTurnSelectionChange {
3507
+ /** @internal */
3508
+ fromTurnId: string | null;
3509
+ /** @internal */
3510
+ toTurnId: string | null;
3511
+ /** @internal */
3512
+ fromLifecycleStatus: ProcessLifecycleStatus;
3513
+ /** @internal */
3514
+ toLifecycleStatus: ProcessLifecycleStatus;
3515
+ }
3516
+ /** @internal */
3517
+ type EngineErrorCode = "process_not_found" | "operation_failed" | "record_failed" | "post_commit_failed" | "approval_conflict" | "external_publish_failed" | "input_dispatch_failed" | "worker_reconcile_failed" | "retry_target_missing" | (string & {});
3518
+ /** @internal */
3519
+ type EngineFailureStage = "pre_commit" | "post_commit";
3520
+ /** @internal */
3521
+ interface EngineSuccess<T> {
3522
+ /** @internal */
3523
+ ok: true;
3524
+ /** @internal */
3525
+ process: ProcessInstance;
3526
+ /** @internal */
3527
+ data: T;
3528
+ /** @internal */
3529
+ turnSelectionChange?: ProcessTurnSelectionChange;
3530
+ }
3531
+ /** @internal */
3532
+ interface EngineFailure<T> {
3533
+ /** @internal */
3534
+ ok: false;
3535
+ /** @internal */
3536
+ code: EngineErrorCode;
3537
+ /** @internal */
3538
+ message: string;
3539
+ /** @internal */
3540
+ process?: ProcessInstance | null;
3541
+ /** @internal */
3542
+ data?: T;
3543
+ /** @internal */
3544
+ turnSelectionChange?: ProcessTurnSelectionChange;
3545
+ /** @internal */
3546
+ stage?: EngineFailureStage;
3547
+ }
3548
+ /** @internal */
3549
+ type EngineResult<T = undefined> = EngineSuccess<T> | EngineFailure<T>;
3550
+ /** @internal */
3551
+ type ActionExecutionResult = ActionExecutionResultLike;
3552
+ /** @internal */
3553
+ interface ProcessEngine {
3554
+ /** @internal */
3555
+ getDeferredProcessActivationSnapshots(query: DeferredProcessActivationSnapshotQuery): DeferredProcessActivationSnapshotResult;
3556
+ /** @internal */
3557
+ activateDeferredProcess(instanceId: string, prepared: PreparedDeferredProcessActivation): Promise<EngineResult<{
3558
+ /** @internal */
3559
+ outcome: DeferredProcessActivationOutcome;
3560
+ }>>;
3561
+ /** @internal */
3562
+ parkDeferredProcessActivationFailure(instanceId: string, failure: DeferredProcessActivationFailure): Promise<EngineResult<{
3563
+ /** @internal */
3564
+ outcome: "parked" | "stale" | "not_applicable" | "project_not_found";
3565
+ }>>;
3566
+ /** @internal */
3567
+ run<TOp extends OperationSpec<string, OperationInputBase, unknown>>(operation: TOp, input: OperationInput<TOp>): Promise<EngineResult<OperationData<TOp>>>;
3568
+ /** @internal */
3569
+ startProcess(instanceId: string, startTurnId: TurnId, opts?: {
3570
+ /** @internal */
3571
+ actor?: Actor;
3572
+ }): Promise<EngineResult<void>>;
3573
+ /** @internal */
3574
+ abortProcess(instanceId: string, opts?: {
3575
+ /** @internal */
3576
+ actor?: Actor;
3577
+ /** @internal */
3578
+ expectedTurnRecordId?: string;
3579
+ }): Promise<EngineResult<void>>;
3580
+ /** @internal */
3581
+ abortTurn(instanceId: string, opts?: {
3582
+ /** @internal */
3583
+ reason?: string;
3584
+ /** @internal */
3585
+ actor?: Actor;
3586
+ }): Promise<EngineResult<void>>;
3587
+ /** @internal */
3588
+ retryProcess(instanceId: string, opts?: {
3589
+ /** @internal */
3590
+ nextTurnModelProfileId?: string | null;
3591
+ /** @internal */
3592
+ providerOptions?: Readonly<Record<string, string>>;
3593
+ /** @internal */
3594
+ actor?: Actor;
3595
+ }): Promise<EngineResult<void>>;
3596
+ /** @internal */
3597
+ retryStartup(instanceId: string, startRecordId: string, opts?: {
3598
+ /** @internal */
3599
+ nextTurnModelProfileId?: string | null;
3600
+ /** @internal */
3601
+ providerOptions?: Readonly<Record<string, string>>;
3602
+ }): Promise<EngineResult<{
3603
+ /** @internal */
3604
+ startRecordId: string;
3605
+ }>>;
3606
+ /** @internal */
3607
+ continueFailedTurn(instanceId: string, turnRecordId: string, options?: {
3608
+ /** @internal */
3609
+ prompt?: string | null;
3610
+ /** @internal */
3611
+ nextTurnModelProfileId?: string | null;
3612
+ /** @internal */
3613
+ providerOptions?: Readonly<Record<string, string>>;
3614
+ /** @internal */
3615
+ actor?: Actor;
3616
+ }): Promise<EngineResult<void>>;
3617
+ /** @internal */
3618
+ parkProcessLifecycle(instanceId: string, payload: ParkProcessLifecyclePayload): Promise<EngineResult<void>>;
3619
+ /** @internal */
3620
+ recordWorkerFailure(instanceId: string, payload: {
3621
+ /** @internal */
3622
+ errorCode: string;
3623
+ /** @internal */
3624
+ message: string;
3625
+ /** @internal */
3626
+ errorClass?: WorkerErrorClass;
3627
+ /** @internal */
3628
+ workerLeaseId?: string | null;
3629
+ /** @internal */
3630
+ resultPiEntryId?: string | null;
3631
+ /** @internal */
3632
+ recoveryContext?: TurnFailedPayload["recoveryContext"];
3633
+ }): Promise<EngineResult<void>>;
3634
+ /** @internal */
3635
+ acceptWorkerTurnStart(instanceId: string, input: {
3636
+ /** @internal */
3637
+ startRecordId: string;
3638
+ /** @internal */
3639
+ proposedTurnRecordId: string;
3640
+ /** @internal */
3641
+ workerLeaseId: string;
3642
+ }): Promise<EngineResult<{
3643
+ /** @internal */
3644
+ turnRecordId: string;
3645
+ }>>;
3646
+ /** @internal */
3647
+ recordTurnOutcome(instanceId: string, payload: TurnOutcomePayload, options?: {
3648
+ /** @internal */
3649
+ onRecorded?: () => void;
3650
+ }): Promise<EngineResult<void>>;
3651
+ /** @internal */
3652
+ recordTurnFailed(instanceId: string, payload: TurnFailedPayload, options?: {
3653
+ /** @internal */
3654
+ onRecorded?: () => void;
3655
+ }): Promise<EngineResult<void>>;
3656
+ /** @internal */
3657
+ updateSemanticEntryRefs(instanceId: string, patch: ProcessSemanticEntryRefPatch): Promise<EngineResult<void>>;
3658
+ /** @internal */
3659
+ updateProductRefs(instanceId: string, patch: ProcessProductRefPatch): Promise<EngineResult<void>>;
3660
+ /** @internal */
3661
+ queueInputs(instanceId: string, queued: QueuedProcessInput[], opts?: {
3662
+ /** @internal */
3663
+ dispatchErrorMessage?: string;
3664
+ /** @internal */
3665
+ actor?: Actor;
3666
+ }): Promise<EngineResult<ProcessInput[]>>;
3667
+ /** @internal */
3668
+ dispatchExternalTurnTrigger(instanceId: string, actionId: string, input: Record<string, unknown>): Promise<ActionExecutionResult | {
3669
+ /** @internal */
3670
+ ok: true;
3671
+ /** @internal */
3672
+ process: null;
3673
+ /** @internal */
3674
+ data: {
3675
+ /** @internal */
3676
+ ignored: true;
3677
+ };
3678
+ }>;
3679
+ /** @internal */
3680
+ executeProcessAction(instanceId: string, actionId: string, input: Record<string, unknown>, opts?: NonNullable<Parameters<ProcessActionServiceLike["executeAction"]>[3]> & {
3681
+ /** @internal */
3682
+ scheduledExecutionId?: string;
3683
+ /** @internal */
3684
+ consumeScheduledExecutionOnSuccess?: boolean;
3685
+ }): Promise<ActionExecutionResult>;
3686
+ }
3687
+
3688
+ /** @internal */
3689
+ type PostCommitEffectFailureCode = "input_dispatch_failed" | "worker_reconcile_failed" | "broadcast_failed" | "extension_event_failed" | "queue_process_title_failed" | "queue_future_execution_title_failed";
3690
+
3691
+ /** @internal */
3692
+ type LaunchStageFailure<TFailure> = {
3693
+ /** @internal */
3694
+ safeSummary: string;
3695
+ /** @internal */
3696
+ value: TFailure;
3697
+ };
3698
+ /** @internal */
3699
+ type LaunchResolution<TResolved, TFailure> = {
3700
+ /** @internal */
3701
+ kind: "resolved";
3702
+ /** @internal */
3703
+ value: TResolved;
3704
+ } | {
3705
+ /** @internal */
3706
+ kind: "skipped";
3707
+ } | {
3708
+ /** @internal */
3709
+ kind: "failed";
3710
+ /** @internal */
3711
+ failure: LaunchStageFailure<TFailure>;
3712
+ };
3713
+ /** @internal */
3714
+ interface LaunchPipelineCheck {
3715
+ /** @internal */
3716
+ id: string;
3717
+ /** @internal */
3718
+ label: string;
3719
+ /** @internal */
3720
+ run(input: {
3721
+ /** @internal */
3722
+ signal: AbortSignal;
3723
+ /** @internal */
3724
+ logger: {
3725
+ /** @internal */
3726
+ info(message: string): void;
3727
+ /** @internal */
3728
+ warn(message: string): void;
3729
+ };
3730
+ }): Promise<void>;
3731
+ }
3732
+ /** @internal */
3733
+ type LaunchCommit<TResult, TFailure> = {
3734
+ /** @internal */
3735
+ kind: "committed";
3736
+ /** @internal */
3737
+ result: TResult;
3738
+ /** @internal */
3739
+ process: ProcessInstance;
3740
+ /** @internal */
3741
+ startTurnId: string | null;
3742
+ /** @internal */
3743
+ reused: boolean;
3744
+ } | {
3745
+ /** @internal */
3746
+ kind: "committed_with_reaction_error";
3747
+ /** @internal */
3748
+ result: TResult;
3749
+ /** @internal */
3750
+ process: ProcessInstance;
3751
+ /** @internal */
3752
+ startTurnId: string | null;
3753
+ /** @internal */
3754
+ safeSummary: string;
3755
+ } | {
3756
+ /** @internal */
3757
+ kind: "failed";
3758
+ /** @internal */
3759
+ failure: LaunchStageFailure<TFailure>;
3760
+ };
3761
+ /** @internal */
3762
+ interface LaunchAdapter<TResolved, TPrepared, TResult, TFailure> {
3763
+ /** @internal */
3764
+ resolve(): Promise<LaunchResolution<TResolved, TFailure>>;
3765
+ /** @internal */
3766
+ preparationChecks?(resolved: TResolved): readonly LaunchPipelineCheck[];
3767
+ /** @internal */
3768
+ preparationCheckFailure?(error: unknown, safeSummary: string): TFailure;
3769
+ /** @internal */
3770
+ prepare(resolved: TResolved): Promise<{
3771
+ /** @internal */
3772
+ ok: true;
3773
+ /** @internal */
3774
+ value: TPrepared;
3775
+ } | {
3776
+ /** @internal */
3777
+ ok: false;
3778
+ /** @internal */
3779
+ failure: LaunchStageFailure<TFailure>;
3780
+ }>;
3781
+ /** @internal */
3782
+ commit(prepared: TPrepared, ctx: {
3783
+ /** @internal */
3784
+ launchRunId: string;
3785
+ }): Promise<LaunchCommit<TResult, TFailure>>;
3786
+ /** @internal */
3787
+ unexpectedFailure?(error: unknown): LaunchStageFailure<TFailure>;
3788
+ }
3789
+ /** @internal */
3790
+ type LaunchPipelineRunResult<TResult, TFailure> = {
3791
+ /** @internal */
3792
+ kind: "skipped";
3793
+ } | {
3794
+ /** @internal */
3795
+ kind: "failed";
3796
+ /** @internal */
3797
+ failure: LaunchStageFailure<TFailure>;
3798
+ } | {
3799
+ /** @internal */
3800
+ kind: "committed" | "committed_with_reaction_error";
3801
+ /** @internal */
3802
+ result: TResult;
3803
+ /** @internal */
3804
+ process: ProcessInstance;
3805
+ /** @internal */
3806
+ reused: boolean;
3807
+ };
3808
+ /** @internal */
3809
+ interface LaunchPipeline {
3810
+ /** @internal */
3811
+ open(input: {
3812
+ /** @internal */
3813
+ launcherId: string | null;
3814
+ /** @internal */
3815
+ idempotencyKey?: string | null;
3816
+ /** @internal */
3817
+ origin: LaunchRun["origin"];
3818
+ /** @internal */
3819
+ broadcast?: boolean;
3820
+ }): {
3821
+ /** @internal */
3822
+ launchRunId: string;
3823
+ /** @internal */
3824
+ existing: boolean;
3825
+ };
3826
+ /** @internal */
3827
+ update(id: string, fn: (run: LaunchRun) => LaunchRun): LaunchRun;
3828
+ /** @internal */
3829
+ run<TResolved, TPrepared, TResult, TFailure>(launchRunId: string, adapter: LaunchAdapter<TResolved, TPrepared, TResult, TFailure>): Promise<LaunchPipelineRunResult<TResult, TFailure>>;
3830
+ }
3831
+
3832
+ /** @internal */
3833
+ interface LauncherRecentValuesService {
3834
+ /** @internal */
3835
+ list(launcherId: string): Record<string, readonly string[]>;
3836
+ /** @internal */
3837
+ record(launcherId: string, launcherInput: Record<string, unknown>): void;
3838
+ }
3839
+
3840
+ /** @internal */
3841
+ type ProcessLaunchRelationInput = Omit<ProcessRelation, "kind" | "childInstanceId" | "createdAt">;
3842
+
3843
+ /** @internal */
3844
+ type FutureModelSelectionState = Pick<FutureExecution, "modelSelection" | "blockedReason">;
3845
+ /** @internal */
3846
+ declare function projectLaunchPlanModelState(plan: ProcessLaunchPlan, input: {
3847
+ /** @internal */
3848
+ policy: ServerProcessModelPolicy;
3849
+ /** @internal */
3850
+ availability: ModelStatusCacheSnapshot;
3851
+ /** @internal */
3852
+ detectedAt?: string;
3853
+ /** @internal */
3854
+ existingBlockedReason?: FutureExecutionBlockReason | null;
3855
+ }): FutureModelSelectionState;
3856
+
3857
+ /** @internal */
3858
+ interface FutureExecutionIssue extends LauncherValidationError {
3859
+ }
3860
+ /** @internal */
3861
+ type LaunchFailure = {
3862
+ /** @internal */
3863
+ kind: "invalid";
3864
+ /** @internal */
3865
+ issues: readonly FutureExecutionIssue[];
3866
+ } | {
3867
+ /** @internal */
3868
+ kind: "not_found";
3869
+ /** @internal */
3870
+ target: "future_execution" | "launch" | "action" | "process";
3871
+ } | {
3872
+ /** @internal */
3873
+ kind: "conflict";
3874
+ /** @internal */
3875
+ issue: FutureExecutionIssue;
3876
+ } | {
3877
+ /** @internal */
3878
+ kind: "unavailable";
3879
+ /** @internal */
3880
+ reason: string;
3881
+ } | {
3882
+ /** @internal */
3883
+ kind: "failed";
3884
+ /** @internal */
3885
+ issue: FutureExecutionIssue;
3886
+ };
3887
+ /** @internal */
3888
+ type LaunchMutationOutcome = {
3889
+ /** @internal */
3890
+ kind: "scheduled";
3891
+ /** @internal */
3892
+ execution: FutureExecution;
3893
+ /** @internal */
3894
+ operation: "created" | "updated";
3895
+ } | {
3896
+ /** @internal */
3897
+ kind: "launched";
3898
+ /** @internal */
3899
+ process: ProcessInstance;
3900
+ /** @internal */
3901
+ projects: ProcessProject[];
3902
+ /** @internal */
3903
+ operation: "created" | "updated";
3904
+ } | {
3905
+ /** @internal */
3906
+ kind: "committed_with_reaction_error";
3907
+ /** @internal */
3908
+ process: ProcessInstance;
3909
+ /** @internal */
3910
+ projects: ProcessProject[];
3911
+ /** @internal */
3912
+ error: string;
3913
+ /** @internal */
3914
+ code?: string;
3915
+ } | {
3916
+ /** @internal */
3917
+ kind: "committed_with_reaction_error";
3918
+ /** @internal */
3919
+ execution: FutureExecution;
3920
+ /** @internal */
3921
+ operation: "created" | "updated";
3922
+ /** @internal */
3923
+ error: string;
3924
+ /** @internal */
3925
+ code: string;
3926
+ } | LaunchFailure;
3927
+ /** @internal */
3928
+ interface NormalizedScheduledLaunchInput extends ParsedLauncherRequestBody {
3929
+ }
3930
+ /** @internal */
3931
+ type ValidatedLaunchSchedule = {
3932
+ /** @internal */
3933
+ mode: "now";
3934
+ /** @internal */
3935
+ nextRunAt: null;
3936
+ /** @internal */
3937
+ cronExpression: null;
3938
+ } | {
3939
+ /** @internal */
3940
+ mode: "once";
3941
+ /** @internal */
3942
+ nextRunAt: string;
3943
+ /** @internal */
3944
+ cronExpression: null;
3945
+ } | {
3946
+ /** @internal */
3947
+ mode: "cron";
3948
+ /** @internal */
3949
+ nextRunAt: string;
3950
+ /** @internal */
3951
+ cronExpression: string;
3952
+ };
3953
+ /** @internal */
3954
+ interface PreparedLaunch {
3955
+ /** @internal */
3956
+ processId: string;
3957
+ /** @internal */
3958
+ launcherId: string;
3959
+ /** @internal */
3960
+ launcherInput: Record<string, unknown>;
3961
+ /** @internal */
3962
+ modelConfig: LauncherModelConfigDefaults;
3963
+ /** @internal */
3964
+ launchPlan: ProcessLaunchPlan;
3965
+ /** @internal */
3966
+ selectedSkillIds: readonly string[];
3967
+ /** @internal */
3968
+ resourceSelections: readonly SkillSelection[];
3969
+ /** @internal */
3970
+ modelState: ReturnType<typeof projectLaunchPlanModelState>;
3971
+ /** @internal */
3972
+ schedule: ValidatedLaunchSchedule;
3973
+ }
3974
+ /** @internal */
3975
+ type PreparedLaunchResult = {
3976
+ /** @internal */
3977
+ ok: true;
3978
+ /** @internal */
3979
+ prepared: PreparedLaunch;
3980
+ } | {
3981
+ /** @internal */
3982
+ ok: false;
3983
+ /** @internal */
3984
+ outcome: LaunchMutationOutcome;
3985
+ };
3986
+
3987
+ /** @internal */
3988
+ interface FutureExecutionExecutorDeps extends Pick<RepositoryBundle, "futureExecutions" | "processes" | "projects" | "processRelations" | "processSkills" | "skills" | "handoffDedupKeys" | "transaction"> {
3989
+ /** @internal */
3990
+ turnRecords?: RepositoryBundle["turnRecords"];
3991
+ /** @internal */
3992
+ broadcaster: Broadcaster;
3993
+ /** @internal */
3994
+ commands: ProcessEngine;
3995
+ /** @internal */
3996
+ processOperations: ProcessOperationCoordinator;
3997
+ /** @internal */
3998
+ processTitles?: ProcessTitleGenerator;
3999
+ /** @internal */
4000
+ extensionHost?: ExtensionHost;
4001
+ /** @internal */
4002
+ processGraphs?: ProcessGraphRegistry;
4003
+ /** @internal */
4004
+ processActionRegistry?: ProcessActionRegistry;
4005
+ /** Required for every server-owned scheduled execution. @internal */
4006
+ processModelPolicy: ServerProcessModelPolicy;
4007
+ /** @internal */
4008
+ launchPlans: ProcessLaunchPlanServiceLike;
4009
+ /** @internal */
4010
+ modelStatusCache: Pick<ModelStatusCache, "snapshot">;
4011
+ /** @internal */
4012
+ launchPipeline: LaunchPipeline;
4013
+ /** @internal */
4014
+ logger?: ProcessEngineLogger;
4015
+ }
4016
+ /** @internal */
4017
+ type FutureExecutionItemOutcome = {
4018
+ /** @internal */
4019
+ kind: "no_work";
4020
+ } | {
4021
+ /** @internal */
4022
+ kind: "blocked";
4023
+ } | {
4024
+ /** @internal */
4025
+ kind: "retry_scheduled";
4026
+ } | {
4027
+ /** @internal */
4028
+ kind: "occurrence_advanced";
4029
+ } | {
4030
+ /** @internal */
4031
+ kind: "terminal_invalid_removed";
4032
+ } | {
4033
+ /** @internal */
4034
+ kind: "durable_work_committed";
4035
+ } | {
4036
+ /** @internal */
4037
+ kind: "durable_work_committed_with_reaction_error";
4038
+ /** @internal */
4039
+ error: string;
4040
+ };
4041
+
4042
+ /** @internal */
4043
+ interface FutureExecutionLifecycleDeps extends FutureExecutionExecutorDeps {
4044
+ /** @internal */
4045
+ turnRecords: RepositoryBundle["turnRecords"];
4046
+ /** @internal */
4047
+ launcherService?: ProcessLauncherService;
4048
+ /** @internal */
4049
+ launcherRecentValues?: LauncherRecentValuesService;
4050
+ /** @internal */
4051
+ assertRuntimeAvailable?: (processId: string) => Promise<void>;
4052
+ }
4053
+ /** @internal */
4054
+ interface FutureExecutionLifecycleOptions {
4055
+ /** @internal */
4056
+ now?: () => Date;
4057
+ }
4058
+ /** @internal */
4059
+ type LifecycleFailure = {
4060
+ /** @internal */
4061
+ kind: "invalid";
4062
+ /** @internal */
4063
+ issues: readonly FutureExecutionIssue[];
4064
+ } | {
4065
+ /** @internal */
4066
+ kind: "not_found";
4067
+ /** @internal */
4068
+ target: "future_execution" | "launch" | "action" | "process";
4069
+ } | {
4070
+ /** @internal */
4071
+ kind: "conflict";
4072
+ /** @internal */
4073
+ issue: FutureExecutionIssue;
4074
+ } | {
4075
+ /** @internal */
4076
+ kind: "unavailable";
4077
+ /** @internal */
4078
+ reason: string;
4079
+ } | {
4080
+ /** @internal */
4081
+ kind: "failed";
4082
+ /** @internal */
4083
+ issue: FutureExecutionIssue;
4084
+ };
4085
+ /** @internal */
4086
+ type ActionMutationOutcome = {
4087
+ /** @internal */
4088
+ kind: "scheduled";
4089
+ /** @internal */
4090
+ execution: FutureExecution;
4091
+ /** @internal */
4092
+ instanceId: string;
4093
+ /** @internal */
4094
+ operation: "created" | "updated";
4095
+ } | {
4096
+ /** @internal */
4097
+ kind: "executed";
4098
+ /** @internal */
4099
+ process: ProcessInstance;
4100
+ /** @internal */
4101
+ data?: Record<string, unknown>;
4102
+ } | {
4103
+ /** @internal */
4104
+ kind: "committed_with_reaction_error";
4105
+ /** @internal */
4106
+ process: ProcessInstance;
4107
+ /** @internal */
4108
+ error: string;
4109
+ /** @internal */
4110
+ code?: string;
4111
+ } | {
4112
+ /** @internal */
4113
+ kind: "committed_with_reaction_error";
4114
+ /** @internal */
4115
+ execution: FutureExecution;
4116
+ /** @internal */
4117
+ instanceId: string;
4118
+ /** @internal */
4119
+ operation: "created" | "updated";
4120
+ /** @internal */
4121
+ error: string;
4122
+ /** @internal */
4123
+ code: string;
4124
+ } | LifecycleFailure;
4125
+ /** @internal */
4126
+ type CancelFutureExecutionOutcome = {
4127
+ /** @internal */
4128
+ kind: "canceled";
4129
+ /** @internal */
4130
+ execution: FutureExecution;
4131
+ } | {
4132
+ /** @internal */
4133
+ kind: "committed_with_reaction_error";
4134
+ /** @internal */
4135
+ execution: FutureExecution;
4136
+ /** @internal */
4137
+ error: string;
4138
+ /** @internal */
4139
+ code: string;
4140
+ } | {
4141
+ /** @internal */
4142
+ kind: "not_found";
4143
+ /** @internal */
4144
+ target: "future_execution";
4145
+ };
4146
+ /** @internal */
4147
+ interface FutureExecutionDueItemOutcome {
4148
+ /** @internal */
4149
+ futureExecutionId: string;
4150
+ /** @internal */
4151
+ kind: FutureExecutionItemOutcome["kind"] | "unexpected_error";
4152
+ /** @internal */
4153
+ error?: string;
4154
+ }
4155
+ /** @internal */
4156
+ interface FutureExecutionDueBatchOutcome {
4157
+ /** @internal */
4158
+ kind: "batch_completed";
4159
+ /** @internal */
4160
+ asOf: string;
4161
+ /** @internal */
4162
+ items: FutureExecutionDueItemOutcome[];
4163
+ }
4164
+ /** @internal */
4165
+ interface NormalizedScheduledActionInput extends ParsedActionRequestBody {
4166
+ }
4167
+ /** @internal */
4168
+ declare function createFutureExecutionLifecycle(deps: FutureExecutionLifecycleDeps, _options?: FutureExecutionLifecycleOptions): {
4169
+ /** @internal */
4170
+ prepareLaunch: (launcherId: string, request: NormalizedScheduledLaunchInput, opts?: {
4171
+ /** @internal */
4172
+ resolvedLauncher?: _leitwerk_dev_process_sdk.ResolvedProcessLauncher;
4173
+ }) => Promise<PreparedLaunchResult>;
4174
+ /** @internal */
4175
+ commitPreparedLaunch: (prepared: PreparedLaunch, opts?: {
4176
+ /** @internal */
4177
+ actor?: Actor;
4178
+ /** @internal */
4179
+ launchRunId?: string;
4180
+ }) => Promise<LaunchMutationOutcome>;
4181
+ /** @internal */
4182
+ reviseScheduledLaunch: (futureExecutionId: string, request: NormalizedScheduledLaunchInput, opts?: {
4183
+ /** @internal */
4184
+ actor?: Actor;
4185
+ }) => Promise<LaunchMutationOutcome>;
4186
+ /** @internal */
4187
+ scheduleAction(process: ProcessInstance, actionId: string, request: NormalizedScheduledActionInput, opts?: {
4188
+ /** @internal */
4189
+ actor?: Actor;
4190
+ }): Promise<ActionMutationOutcome>;
4191
+ /** @internal */
4192
+ reviseScheduledAction(futureExecutionId: string, request: NormalizedScheduledActionInput, opts?: {
4193
+ /** @internal */
4194
+ actor?: Actor;
4195
+ }): Promise<ActionMutationOutcome>;
4196
+ /** @internal */
4197
+ cancel(futureExecutionId: string): Promise<CancelFutureExecutionOutcome>;
4198
+ /** @internal */
4199
+ applyGeneratedFutureLaunchTitleIfUnchanged: (input: {
4200
+ /** @internal */
4201
+ futureExecutionId: string;
4202
+ /** @internal */
4203
+ expectedPayloadJson: string;
4204
+ /** @internal */
4205
+ title: string;
4206
+ }) => Promise<{
4207
+ /** @internal */
4208
+ kind: "applied";
4209
+ /** @internal */
4210
+ execution: FutureExecution;
4211
+ } | {
4212
+ /** @internal */
4213
+ kind: "applied_with_reaction_error";
4214
+ /** @internal */
4215
+ execution: FutureExecution;
4216
+ /** @internal */
4217
+ error: string;
4218
+ /** @internal */
4219
+ code: string;
4220
+ } | {
4221
+ /** @internal */
4222
+ kind: "superseded";
4223
+ } | {
4224
+ /** @internal */
4225
+ kind: "failed";
4226
+ /** @internal */
4227
+ error: string;
4228
+ }>;
4229
+ /** @internal */
4230
+ reconcileModelAvailability(input: {
4231
+ /** @internal */
4232
+ availability: ModelStatusCacheSnapshot;
4233
+ /** @internal */
4234
+ profileIds?: ReadonlySet<string>;
4235
+ /** @internal */
4236
+ asOf?: string;
4237
+ }): Promise<{
4238
+ /** @internal */
4239
+ kind: string;
4240
+ /** @internal */
4241
+ changed: number;
4242
+ /** @internal */
4243
+ asOf: string;
4244
+ /** @internal */
4245
+ error?: undefined;
4246
+ /** @internal */
4247
+ code?: undefined;
4248
+ } | {
4249
+ /** @internal */
4250
+ kind: string;
4251
+ /** @internal */
4252
+ changed: number;
4253
+ /** @internal */
4254
+ asOf: string;
4255
+ /** @internal */
4256
+ error: string;
4257
+ /** @internal */
4258
+ code: PostCommitEffectFailureCode;
4259
+ }>;
4260
+ /** @internal */
4261
+ reconcileMissedScheduleOccurrences(asOf: string): Promise<{
4262
+ /** @internal */
4263
+ kind: "occurrences_advanced";
4264
+ /** @internal */
4265
+ asOf: string;
4266
+ }>;
4267
+ /** @internal */
4268
+ runDueWork(asOf: string): Promise<FutureExecutionDueBatchOutcome>;
4269
+ };
4270
+ /** @internal */
4271
+ type FutureExecutionLifecycle = ReturnType<typeof createFutureExecutionLifecycle>;
4272
+
4273
+ /** @internal */
4274
+ interface StartLaunchRequest {
4275
+ /** @internal */
4276
+ launcherId: string;
4277
+ /** @internal */
4278
+ idempotencyKey?: string | null;
4279
+ /** @internal */
4280
+ request: NormalizedScheduledLaunchInput;
4281
+ /** @internal */
4282
+ actor: Actor;
4283
+ /** @internal */
4284
+ processMetadata?: Record<string, unknown>;
4285
+ }
4286
+ /** @internal */
4287
+ interface PreparedPlanLaunchRequest {
4288
+ /** @internal */
4289
+ launchPlan: ProcessLaunchPlan;
4290
+ /** @internal */
4291
+ idempotencyKey: string;
4292
+ /** @internal */
4293
+ actor: Actor;
4294
+ /** @internal */
4295
+ origin: LaunchRun["origin"];
4296
+ /** @internal */
4297
+ relation?: ProcessLaunchRelationInput;
4298
+ }
4299
+ /** @internal */
4300
+ interface LaunchCoordinator {
4301
+ /** @internal */
4302
+ start(request: StartLaunchRequest): Promise<{
4303
+ /** @internal */
4304
+ launchRunId: string;
4305
+ }>;
4306
+ /** @internal */
4307
+ startPreparedPlan(request: PreparedPlanLaunchRequest): Promise<{
4308
+ /** @internal */
4309
+ launchRunId: string;
4310
+ /** @internal */
4311
+ process: ProcessInstance | null;
4312
+ /** @internal */
4313
+ error: string | null;
4314
+ }>;
4315
+ /** @internal */
4316
+ startProgrammatic(request: ProgrammaticLaunchRequestLike, opts: {
4317
+ /** @internal */
4318
+ idempotencyKey: string;
4319
+ /** @internal */
4320
+ actor: Actor;
4321
+ }): Promise<ProgrammaticLaunchResultLike>;
4322
+ /** @internal */
4323
+ startWatcher<TConfig, TEvent>(watcher: RegisteredProcessWatcherLike<TConfig, TEvent>, event: TEvent, request: {
4324
+ /** @internal */
4325
+ idempotencyKey: string;
4326
+ /** @internal */
4327
+ actor: Actor;
4328
+ }): Promise<{
4329
+ /** @internal */
4330
+ launchRunId: string;
4331
+ /** @internal */
4332
+ process: ProcessInstance | null;
4333
+ /** @internal */
4334
+ error: string | null;
4335
+ }>;
4336
+ /** @internal */
4337
+ retryStartup(instanceId: string, actor: Actor): Promise<{
4338
+ /** @internal */
4339
+ launchRunId: string;
4340
+ }>;
4341
+ /** @internal */
4342
+ get(launchRunId: string): LaunchRun | null;
4343
+ /** @internal */
4344
+ refresh(instanceId: string): LaunchRun | null;
4345
+ /** @internal */
4346
+ reconcileIncomplete(): Promise<void>;
4347
+ }
4348
+
4349
+ /** @internal */
4350
+ interface ProcessTitleGenerator {
4351
+ /** @internal */
4352
+ start?(): Promise<void>;
4353
+ /** @internal */
4354
+ queueProcessTitleGeneration(input: {
4355
+ /** @internal */
4356
+ processId: string;
4357
+ /** @internal */
4358
+ launchPlan: ProcessLaunchPlan;
4359
+ /** @internal */
4360
+ launchRunId?: string;
4361
+ }): void;
4362
+ /** @internal */
4363
+ queueFutureExecutionTitleGeneration(input: {
4364
+ /** @internal */
4365
+ futureExecutionId: string;
4366
+ /** @internal */
4367
+ launchPlan: ProcessLaunchPlan;
4368
+ /** @internal */
4369
+ expectedPayloadJson?: string;
4370
+ }): void;
4371
+ /** @internal */
4372
+ close?(): Promise<void>;
4373
+ }
4374
+
4375
+ /** @internal */
4376
+ interface ProjectMutationService {
4377
+ /** @internal */
4378
+ create(input: CreateProcessProjectInput): ProcessProject;
4379
+ /** @internal */
4380
+ update(id: string, input: UpdateProcessProjectInput): ProcessProject | null;
4381
+ /** @internal */
4382
+ getById(id: string): ProcessProject | null;
4383
+ /** @internal */
4384
+ getByInstanceAndKey(instanceId: string, key: string): ProcessProject | null;
4385
+ /** @internal */
4386
+ listByInstance(instanceId: string): ProcessProject[];
4387
+ }
4388
+
4389
+ /** @public */
4390
+ interface ExternalSourceService extends ExternalSourceServiceLike {
4391
+ /** @internal */
4392
+ currentGenerations(instanceId: string): Array<{
4393
+ /** @internal */
4394
+ id: string;
4395
+ /** @internal */
4396
+ generation: string;
4397
+ }>;
4398
+ /** @internal */
4399
+ drainQueued(instanceId: string): Promise<void>;
4400
+ /** @internal */
4401
+ invalidateArmings(instanceId: string): void;
4402
+ /** @internal */
4403
+ reconcileArmings(instanceId: string): Promise<void>;
4404
+ /** @internal */
4405
+ reconcileAllArmings(): Promise<void>;
4406
+ }
4407
+
4408
+ /** @internal */
4409
+ declare function createSessionTransferHelperRelays(deps: {
4410
+ /** @internal */
4411
+ repos: Pick<RepositoryBundle, "sessionTransfers">;
4412
+ /** @internal */
4413
+ limits: SessionTransferLimits;
4414
+ /** @internal */
4415
+ now?: () => Date;
4416
+ }): {
4417
+ /** @internal */
4418
+ create(input: {
4419
+ /** @internal */
4420
+ instanceId: string;
4421
+ /** @internal */
4422
+ manifest: LeitwerkTransferManifestV1;
4423
+ }): ProcessStateExportHelperRelay;
4424
+ /** @internal */
4425
+ sweep(): void;
4426
+ /** @internal */
4427
+ stop(): void;
4428
+ /** @internal */
4429
+ helperSpec(input: {
4430
+ /** @internal */
4431
+ exportId: string;
4432
+ /** @internal */
4433
+ credential: string;
4434
+ }): {
4435
+ /** @internal */
4436
+ manifest: LeitwerkTransferManifestV1;
4437
+ /** @internal */
4438
+ limits: SessionTransferLimits;
4439
+ } | null;
4440
+ /** @internal */
4441
+ reportHelperPreflight(input: {
4442
+ /** @internal */
4443
+ exportId: string;
4444
+ /** @internal */
4445
+ credential: string;
4446
+ /** @internal */
4447
+ report: unknown;
4448
+ /** @internal */
4449
+ signal?: AbortSignal;
4450
+ }): Promise<boolean>;
4451
+ /** @internal */
4452
+ acceptHelperStream(input: {
4453
+ /** @internal */
4454
+ exportId: string;
4455
+ /** @internal */
4456
+ credential: string;
4457
+ /** @internal */
4458
+ stream: Readable;
4459
+ }): boolean;
4460
+ };
4461
+ /** @internal */
4462
+ type SessionTransferHelperRelays = ReturnType<typeof createSessionTransferHelperRelays>;
4463
+
4464
+ /** @internal */
4465
+ type AttemptAuth = Parameters<RepositoryBundle["sessionTransfers"]["verifyAttempt"]>[0];
4466
+ /** @internal */
4467
+ declare function createSessionTransferService(deps: {
4468
+ /** @internal */
4469
+ repos: Pick<RepositoryBundle, "processes" | "projects" | "leases" | "sessionTransfers" | "transaction">;
4470
+ /** @internal */
4471
+ processOperations: ProcessOperationCoordinator;
4472
+ /** @internal */
4473
+ supervisor: WorkerSupervisor;
4474
+ /** @internal */
4475
+ exporter: ProcessStateExporter;
4476
+ /** @internal */
4477
+ helperRelays: SessionTransferHelperRelays;
4478
+ /** @internal */
4479
+ sessionSource: ProcessSessionSource;
4480
+ /** @internal */
4481
+ config: LeitwerkConfig;
4482
+ /** @internal */
4483
+ limits?: SessionTransferLimits;
4484
+ /** @internal */
4485
+ now?: () => Date;
4486
+ /** @internal */
4487
+ logger?: {
4488
+ /** @internal */
4489
+ warn(details: unknown, message: string): void;
4490
+ };
4491
+ /** @internal */
4492
+ onUpdated?: (attempt: SessionTransferAttempt) => void;
4493
+ /** @internal */
4494
+ isDeletionPending?: (instanceId: string) => boolean;
4495
+ }): {
4496
+ /** @internal */
4497
+ createGrant(instanceId: string): Promise<{
4498
+ /** @internal */
4499
+ kind: "deletion_pending";
4500
+ /** @internal */
4501
+ grantId?: undefined;
4502
+ /** @internal */
4503
+ rawToken?: undefined;
4504
+ /** @internal */
4505
+ expiresAt?: undefined;
4506
+ } | {
4507
+ /** @internal */
4508
+ kind: "not_found";
4509
+ /** @internal */
4510
+ grantId?: undefined;
4511
+ /** @internal */
4512
+ rawToken?: undefined;
4513
+ /** @internal */
4514
+ expiresAt?: undefined;
4515
+ } | {
4516
+ /** @internal */
4517
+ kind: "created";
4518
+ /** @internal */
4519
+ grantId: string;
4520
+ /** @internal */
4521
+ rawToken: string;
4522
+ /** @internal */
4523
+ expiresAt: string;
4524
+ }>;
4525
+ /** @internal */
4526
+ startAttempt(input: {
4527
+ /** @internal */
4528
+ instanceId: string;
4529
+ /** @internal */
4530
+ grantId: string;
4531
+ /** @internal */
4532
+ token: string;
4533
+ }): {
4534
+ /** @internal */
4535
+ kind: "created";
4536
+ /** @internal */
4537
+ attempt: SessionTransferAttempt;
4538
+ } | {
4539
+ /** @internal */
4540
+ kind: "not_found";
4541
+ } | {
4542
+ /** @internal */
4543
+ kind: "busy";
4544
+ };
4545
+ /** @internal */
4546
+ heartbeat(input: AttemptAuth): SessionTransferAttempt | null;
4547
+ /** @internal */
4548
+ openStream(input: AttemptAuth): Transform;
4549
+ /** @internal */
4550
+ cancel(input: AttemptAuth & {
4551
+ /** @internal */
4552
+ code?: string;
4553
+ }): SessionTransferAttempt | null;
4554
+ /** @internal */
4555
+ cancelForWeb(instanceId: string, attemptId: string): SessionTransferAttempt | null;
4556
+ /** @internal */
4557
+ acknowledge(input: AttemptAuth): SessionTransferAttempt | null;
4558
+ /** @internal */
4559
+ activeForProcess(instanceId: string): SessionTransferAttempt | null;
4560
+ /** @internal */
4561
+ revokeProcess(instanceId: string): void;
4562
+ /** @internal */
4563
+ reconcile(): Promise<void>;
4564
+ /** @internal */
4565
+ start(): void;
4566
+ /** @internal */
4567
+ stop(): Promise<void>;
4568
+ /** @internal */
4569
+ helperSpec: (input: {
4570
+ /** @internal */
4571
+ exportId: string;
4572
+ /** @internal */
4573
+ credential: string;
4574
+ }) => {
4575
+ /** @internal */
4576
+ manifest: LeitwerkTransferManifestV1;
4577
+ /** @internal */
4578
+ limits: SessionTransferLimits;
4579
+ } | null;
4580
+ /** @internal */
4581
+ reportHelperPreflight: (input: {
4582
+ /** @internal */
4583
+ exportId: string;
4584
+ /** @internal */
4585
+ credential: string;
4586
+ /** @internal */
4587
+ report: unknown;
4588
+ /** @internal */
4589
+ signal?: AbortSignal;
4590
+ }) => Promise<boolean>;
4591
+ /** @internal */
4592
+ acceptHelperStream: (input: {
4593
+ /** @internal */
4594
+ exportId: string;
4595
+ /** @internal */
4596
+ credential: string;
4597
+ /** @internal */
4598
+ stream: node_stream.Readable;
4599
+ }) => boolean;
4600
+ };
4601
+ /** @internal */
4602
+ type SessionTransferService = ReturnType<typeof createSessionTransferService>;
4603
+
4604
+ /** @internal */
4605
+ type ProcessDeletionResult = {
4606
+ /** @internal */
4607
+ ok: true;
4608
+ } | {
4609
+ /** @internal */
4610
+ ok: false;
4611
+ /** @internal */
4612
+ kind: "not_found";
4613
+ } | {
4614
+ /** @internal */
4615
+ ok: false;
4616
+ /** @internal */
4617
+ kind: "abort_failed";
4618
+ /** @internal */
4619
+ failure: EngineFailure<void>;
4620
+ } | {
4621
+ /** @internal */
4622
+ ok: false;
4623
+ /** @internal */
4624
+ kind: "cleanup_failed";
4625
+ /** @internal */
4626
+ message: string;
4627
+ };
4628
+ /** @internal */
4629
+ interface ProcessDeletionService {
4630
+ /** @internal */
4631
+ deleteProcess(instanceId: string, actor: Actor): Promise<ProcessDeletionResult>;
4632
+ }
4633
+
4634
+ /** @internal */
4635
+ interface SkillCatalogService {
4636
+ /** @internal */
4637
+ refresh(): Promise<SkillsCatalogResponseBody>;
4638
+ /** @internal */
4639
+ list(): SkillsCatalogResponseBody;
4640
+ /** @internal */
4641
+ detail(repositoryId: string, skillId: string): SkillCatalogDetail | null;
4642
+ /** @internal */
4643
+ installedDetail(skillId: string): InstalledSkillCatalogDetail | null;
4644
+ /** @internal */
4645
+ register(repositoryId: string, skillId: string): string;
4646
+ /** @internal */
4647
+ remove(skillId: string): boolean;
4648
+ }
4649
+
4650
+ /** @internal */
4651
+ type ToolApprovalDecision = {
4652
+ /** @internal */
4653
+ kind: "accepted";
4654
+ } | {
4655
+ /** @internal */
4656
+ kind: "feedback";
4657
+ /** @internal */
4658
+ feedback: string;
4659
+ } | {
4660
+ /** @internal */
4661
+ kind: "declined";
4662
+ };
4663
+ /** @internal */
4664
+ type ToolApprovalRepos = Pick<RepositoryBundle, "processes" | "turnRecords" | "turnStarts" | "toolApprovalRequests" | "transaction">;
4665
+ /** @internal */
4666
+ declare function createToolApprovalGate(input: {
4667
+ /** @internal */
4668
+ repos: ToolApprovalRepos;
4669
+ /** @internal */
4670
+ processOperations: ProcessOperationCoordinator;
4671
+ }): {
4672
+ /** @internal */
4673
+ reconcile: (instanceId: string) => void;
4674
+ /** @internal */
4675
+ review(requestInput: {
4676
+ /** @internal */
4677
+ instanceId: string;
4678
+ /** @internal */
4679
+ turnRecordId: string;
4680
+ /** @internal */
4681
+ toolCallId: string;
4682
+ /** @internal */
4683
+ toolName: string;
4684
+ /** @internal */
4685
+ arguments: Record<string, unknown>;
4686
+ /** @internal */
4687
+ destination?: ProcessToolApprovalDestination;
4688
+ }): Promise<ToolApprovalDecision>;
4689
+ /** @internal */
4690
+ listOpen(instanceId?: string): ProcessToolApprovalRequest[];
4691
+ /** @internal */
4692
+ resolve(instanceId: string, requestId: string, decision: ToolApprovalDecision, actor: Actor): Promise<ProcessToolApprovalRequest | null>;
4693
+ /** @internal */
4694
+ cancelTurn(instanceId: string, turnRecordId: string): number;
4695
+ };
4696
+ /** @internal */
4697
+ type ToolApprovalGate = ReturnType<typeof createToolApprovalGate>;
4698
+
4699
+ interface TokenAuditContext {
4700
+ operation: string;
4701
+ tokenId?: string;
4702
+ actor?: Actor;
4703
+ ownerKind?: "user" | "anonymous";
4704
+ count?: number;
4705
+ }
4706
+ declare module "fastify" {
4707
+ interface FastifyRequest {
4708
+ actor?: Actor;
4709
+ tokenAudit?: TokenAuditContext;
4710
+ }
4711
+ }
4712
+
4713
+ /** @public */
4714
+ interface RouteDeps extends Pick<RepositoryBundle, "processes" | "launchRuns" | "projects" | "inputs" | "events" | "turnSummaries" | "futureExecutions" | "skills" | "processSkills" | "handoffDedupKeys" | "leafOutcomeSnapshots" | "questionRequests" | "processRelations" | "toolApprovalRequests" | "turnRecords" | "turnStarts" | "turnAnnotations" | "leases" | "externalWrites" | "transaction"> {
4715
+ /** @internal */
4716
+ startupObservations?: RepositoryBundle["startupObservations"];
4717
+ /** @public */
4718
+ externalSourceService?: Pick<ExternalSourceService, "currentGenerations">;
4719
+ /** @internal */
4720
+ broadcaster: Broadcaster;
4721
+ /** @internal */
4722
+ processOperations: ProcessOperationCoordinator;
4723
+ /** @internal */
4724
+ processQuestions: ProcessQuestionService;
4725
+ /** @internal */
4726
+ toolApprovalGate: ToolApprovalGate;
4727
+ /** @internal */
4728
+ processGraphs: ProcessGraphRegistry;
4729
+ /** @internal */
4730
+ supervisor?: WorkerSupervisor;
4731
+ /** @internal */
4732
+ processEngine: ProcessEngine;
4733
+ /** @internal */
4734
+ processDeletion: ProcessDeletionService;
4735
+ /** @internal */
4736
+ processActionRegistry?: ProcessActionRegistry;
4737
+ /** @internal */
4738
+ processUiRegistry?: ProcessUiRegistry;
4739
+ /** @internal */
4740
+ extensionHost?: ExtensionHost;
4741
+ /** @internal */
4742
+ launcherService: ProcessLauncherService;
4743
+ /** @internal */
4744
+ launchCoordinator: LaunchCoordinator;
4745
+ /** @internal */
4746
+ launcherRecentValues: LauncherRecentValuesService;
4747
+ /** @internal */
4748
+ launchPlans: ProcessLaunchPlanServiceLike;
4749
+ /** @internal */
4750
+ processTitles?: ProcessTitleGenerator;
4751
+ /** @internal */
4752
+ toolRenderers?: ReadonlyMap<string, ToolCallRendererDefinition>;
4753
+ /** @internal */
4754
+ config?: LeitwerkConfig;
4755
+ /** @internal */
4756
+ sessionReader: ProcessSessionReader;
4757
+ /** @internal */
4758
+ futureExecutionLifecycle: FutureExecutionLifecycle;
4759
+ /** @internal */
4760
+ modelProviderRegistry?: ModelProviderRegistry;
4761
+ /** @internal */
4762
+ modelProviderCredentialStatus?: ModelProviderCredentialStatusResolver;
4763
+ /** @internal */
4764
+ modelStatusCache: ModelStatusCache;
4765
+ /** @internal */
4766
+ processModelPolicy: ServerProcessModelPolicy;
4767
+ /** @internal */
4768
+ processModelSelection: ProcessModelSelectionServiceLike;
4769
+ /** @internal */
4770
+ skillCatalog?: SkillCatalogService;
4771
+ /** @internal */
4772
+ sessionTransferService?: SessionTransferService;
4773
+ }
4774
+
4775
+ /** @public */
4776
+ interface AppOptions {
4777
+ /** @public */
4778
+ config?: LeitwerkConfig;
4779
+ /** @internal */
4780
+ db?: LeitwerkDb;
4781
+ /** @internal */
4782
+ logger?: boolean;
4783
+ /** @internal */
4784
+ extensionCatalog?: ExtensionCatalog | Promise<ExtensionCatalog>;
4785
+ /** @internal */
4786
+ resolvedExtensionEntries?: readonly DiscoveredExtensionEntry[];
4787
+ /** @public */
4788
+ extensionLoadingStartDir?: string;
4789
+ /** Runtime lane override for extension UI assets. @internal */
4790
+ extensionUiRuntimeLane?: LeitwerkRuntimeLane;
4791
+ /** Pre-provided capabilities injected before extensions are set up (e.g. fake adapters for testing). @internal */
4792
+ preProvidedCapabilities?: readonly ProvidedCapability[];
4793
+ /** @internal */
4794
+ processTitleGenerator?: ProcessTitleGenerator;
4795
+ /** Test/custom seam for supplying a concrete container runner implementation. @internal */
4796
+ workerRunnerRuntime?: {
4797
+ /** @internal */
4798
+ runner: WorkerRunner;
4799
+ /** @internal */
4800
+ volume?: ProcessVolume;
4801
+ /** @internal */
4802
+ exporter: ProcessStateExporter;
4803
+ /** @internal */
4804
+ webSocketIpc?: WorkerWebSocketIpcManager;
4805
+ };
4806
+ /** Local runner spawn seam for tests/dev only. @public */
4807
+ localWorkerSpawnImpl?: typeof spawn;
4808
+ /** Test seam shared by local Docker admission and worker startup. @public */
4809
+ localWorkerDockerPreflightImpl?: (timeoutMs: number) => Promise<void>;
4810
+ /** Credential-store seam. Declared credential providers default unavailable until it is wired. @internal */
4811
+ modelProviderCredentialStatus?: ModelProviderCredentialStatusResolver;
4812
+ }
4813
+ /** @public */
4814
+ interface ServerListenOptions {
4815
+ /** @public */
4816
+ host?: string;
4817
+ /** @public */
4818
+ port?: number;
4819
+ /** Only for unauthenticated loopback fixtures. @public */
4820
+ useBoundAddressAsBaseUrl?: boolean;
4821
+ }
4822
+ /** @public */
4823
+ interface ServerListenResult {
4824
+ /** @public */
4825
+ address: string;
4826
+ /** @public */
4827
+ port: number;
4828
+ }
4829
+ /** @public */
4830
+ interface AppContext {
4831
+ /** @public */
4832
+ app: FastifyInstance;
4833
+ /** @internal */
4834
+ db: LeitwerkDb;
4835
+ /** @internal */
4836
+ broadcaster: Broadcaster;
4837
+ /** @internal */
4838
+ config: LeitwerkConfig;
4839
+ /** @public */
4840
+ deps: RouteDeps;
4841
+ /** @internal */
4842
+ modelProviderRegistry: ModelProviderRegistry;
4843
+ /** @internal */
4844
+ modelProviderServerAdapters: ModelProviderServerAdapterRegistry;
4845
+ /** @internal */
4846
+ modelStatusCache: ModelStatusCache;
4847
+ /** @internal */
4848
+ extensionUiCatalog: ExtensionUiCatalog;
4849
+ /** @internal */
4850
+ processGraphs: ProcessGraphRegistry;
4851
+ /** @internal */
4852
+ extensionHost: ExtensionHost;
4853
+ /** @internal */
4854
+ projectMutations: ProjectMutationService;
4855
+ /** @internal */
4856
+ ipcHandler: IpcHandler;
4857
+ /** @public */
4858
+ supervisor: WorkerSupervisor;
4859
+ /** @public */
4860
+ listen(options?: ServerListenOptions): Promise<ServerListenResult>;
4861
+ /** @public */
4862
+ close(): Promise<void>;
4863
+ /** @internal */
4864
+ isReady(): boolean;
4865
+ }
4866
+ /** @public */
4867
+ declare function createAppContext(opts?: AppOptions): Promise<AppContext>;
4868
+
4869
+ export { type AppContext as A, type Broadcaster as B, type LeitwerkConfig as L, type ModelStatusCacheSnapshot as M, type ReadonlyPiSessionTree as R, type SessionSummary as S, type AppOptions as a, type RepositoryBundle as b, createAppContext as c, type LeitwerkDb as d, type ServerProcessModelPolicy as e };