@leitwerk-dev/server 0.2.0 → 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 (392) hide show
  1. package/dist/app-7PKX73TU.js +8 -0
  2. package/dist/{app-D4XHIbwA.d.ts → app-WfwKzrVk.d.ts} +2029 -410
  3. package/dist/app.d.ts +55 -12
  4. package/dist/app.d.ts.map +1 -1
  5. package/dist/{chunk-XTXH6623.js → chunk-CNITOV76.js} +1359 -991
  6. package/dist/chunk-CNITOV76.js.map +1 -0
  7. package/dist/{chunk-AGC2ND53.js → chunk-ZSKM25SD.js} +588 -667
  8. package/dist/chunk-ZSKM25SD.js.map +1 -0
  9. package/dist/config/config-loader.d.ts +11 -0
  10. package/dist/config/config-loader.d.ts.map +1 -1
  11. package/dist/config/config-types.d.ts +152 -51
  12. package/dist/config/config-types.d.ts.map +1 -1
  13. package/dist/db/api-token-repo.d.ts +24 -0
  14. package/dist/db/api-token-repo.d.ts.map +1 -1
  15. package/dist/db/auth-repo.d.ts +30 -0
  16. package/dist/db/auth-repo.d.ts.map +1 -1
  17. package/dist/db/credential-cipher.d.ts +8 -3
  18. package/dist/db/credential-cipher.d.ts.map +1 -1
  19. package/dist/db/database.d.ts +19 -1
  20. package/dist/db/database.d.ts.map +1 -1
  21. package/dist/db/external-write-log-repo.d.ts +6 -1
  22. package/dist/db/external-write-log-repo.d.ts.map +1 -1
  23. package/dist/db/future-execution-repo.d.ts +47 -0
  24. package/dist/db/future-execution-repo.d.ts.map +1 -1
  25. package/dist/db/launch-run-repo.d.ts +17 -0
  26. package/dist/db/launch-run-repo.d.ts.map +1 -1
  27. package/dist/db/launcher-recent-value-repo.d.ts +15 -0
  28. package/dist/db/launcher-recent-value-repo.d.ts.map +1 -1
  29. package/dist/db/pending-external-source-fire-repo.d.ts +33 -0
  30. package/dist/db/pending-external-source-fire-repo.d.ts.map +1 -1
  31. package/dist/db/process-event-repo.d.ts +17 -0
  32. package/dist/db/process-event-repo.d.ts.map +1 -1
  33. package/dist/db/process-handoff-dedup-key-repo.d.ts +8 -0
  34. package/dist/db/process-handoff-dedup-key-repo.d.ts.map +1 -1
  35. package/dist/db/process-input-repo.d.ts +15 -0
  36. package/dist/db/process-input-repo.d.ts.map +1 -1
  37. package/dist/db/process-instance-repo.d.ts +49 -0
  38. package/dist/db/process-instance-repo.d.ts.map +1 -1
  39. package/dist/db/process-leaf-outcome-snapshot-repo.d.ts +18 -0
  40. package/dist/db/process-leaf-outcome-snapshot-repo.d.ts.map +1 -1
  41. package/dist/db/process-project-repo.d.ts +20 -0
  42. package/dist/db/process-project-repo.d.ts.map +1 -1
  43. package/dist/db/process-question-request-repo.d.ts +19 -0
  44. package/dist/db/process-question-request-repo.d.ts.map +1 -1
  45. package/dist/db/process-relation-repo.d.ts +5 -0
  46. package/dist/db/process-relation-repo.d.ts.map +1 -1
  47. package/dist/db/process-skill-repo.d.ts +4 -0
  48. package/dist/db/process-skill-repo.d.ts.map +1 -1
  49. package/dist/db/process-title-job-repo.d.ts +22 -0
  50. package/dist/db/process-title-job-repo.d.ts.map +1 -1
  51. package/dist/db/process-tool-approval-request-repo.d.ts +20 -0
  52. package/dist/db/process-tool-approval-request-repo.d.ts.map +1 -1
  53. package/dist/db/process-turn-annotation-repo.d.ts +22 -2
  54. package/dist/db/process-turn-annotation-repo.d.ts.map +1 -1
  55. package/dist/db/process-turn-record-repo.d.ts +27 -0
  56. package/dist/db/process-turn-record-repo.d.ts.map +1 -1
  57. package/dist/db/provider-credential-repo.d.ts +16 -0
  58. package/dist/db/provider-credential-repo.d.ts.map +1 -1
  59. package/dist/db/repositories.d.ts +33 -0
  60. package/dist/db/repositories.d.ts.map +1 -1
  61. package/dist/db/session-transfer-repo.d.ts +49 -1
  62. package/dist/db/session-transfer-repo.d.ts.map +1 -1
  63. package/dist/db/skill-repo.d.ts +20 -0
  64. package/dist/db/skill-repo.d.ts.map +1 -1
  65. package/dist/db/startup-observation-repo.d.ts +3 -0
  66. package/dist/db/startup-observation-repo.d.ts.map +1 -1
  67. package/dist/db/ticket-destination-recent-repo.d.ts +14 -0
  68. package/dist/db/ticket-destination-recent-repo.d.ts.map +1 -1
  69. package/dist/db/turn-start-record-repo.d.ts +9 -0
  70. package/dist/db/turn-start-record-repo.d.ts.map +1 -1
  71. package/dist/db/turn-summary-repo.d.ts +18 -0
  72. package/dist/db/turn-summary-repo.d.ts.map +1 -1
  73. package/dist/db/worker-lease-repo.d.ts +31 -1
  74. package/dist/db/worker-lease-repo.d.ts.map +1 -1
  75. package/dist/effects/post-commit-effect.d.ts +29 -0
  76. package/dist/effects/post-commit-effect.d.ts.map +1 -1
  77. package/dist/effects/post-commit-runner.d.ts +1 -0
  78. package/dist/effects/post-commit-runner.d.ts.map +1 -1
  79. package/dist/entry-ref-patch.d.ts +3 -0
  80. package/dist/entry-ref-patch.d.ts.map +1 -1
  81. package/dist/extension-ui/catalog.d.ts +15 -0
  82. package/dist/extension-ui/catalog.d.ts.map +1 -1
  83. package/dist/extensions/extension-host.d.ts +6 -0
  84. package/dist/extensions/extension-host.d.ts.map +1 -1
  85. package/dist/external-source-service.d.ts +8 -0
  86. package/dist/external-source-service.d.ts.map +1 -1
  87. package/dist/future-execution/execution.d.ts +23 -1
  88. package/dist/future-execution/execution.d.ts.map +1 -1
  89. package/dist/future-execution/launch-lifecycle.d.ts +76 -0
  90. package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
  91. package/dist/future-execution/lifecycle.d.ts +99 -0
  92. package/dist/future-execution/lifecycle.d.ts.map +1 -1
  93. package/dist/future-execution/model-projection.d.ts +6 -0
  94. package/dist/future-execution/model-projection.d.ts.map +1 -1
  95. package/dist/future-execution/transition-planner.d.ts +25 -0
  96. package/dist/future-execution/transition-planner.d.ts.map +1 -1
  97. package/dist/future-execution-scheduler.d.ts +1 -1
  98. package/dist/future-execution-scheduler.d.ts.map +1 -1
  99. package/dist/index.d.ts +3 -30
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +5 -239
  102. package/dist/index.js.map +1 -1
  103. package/dist/instance-tree.d.ts +3 -0
  104. package/dist/instance-tree.d.ts.map +1 -1
  105. package/dist/integration-tool-registry.d.ts +4 -1
  106. package/dist/integration-tool-registry.d.ts.map +1 -1
  107. package/dist/launch-coordinator.d.ts +33 -0
  108. package/dist/launch-coordinator.d.ts.map +1 -1
  109. package/dist/launch-pipeline.d.ts +60 -0
  110. package/dist/launch-pipeline.d.ts.map +1 -1
  111. package/dist/launcher-recent-values-service.d.ts +3 -0
  112. package/dist/launcher-recent-values-service.d.ts.map +1 -1
  113. package/dist/main.js +7 -14
  114. package/dist/main.js.map +1 -1
  115. package/dist/model-providers/builtin-server-adapter.d.ts +1 -0
  116. package/dist/model-providers/builtin-server-adapter.d.ts.map +1 -1
  117. package/dist/model-providers/credentials.d.ts +17 -0
  118. package/dist/model-providers/credentials.d.ts.map +1 -1
  119. package/dist/model-providers/model-status-cache.d.ts +30 -1
  120. package/dist/model-providers/model-status-cache.d.ts.map +1 -1
  121. package/dist/model-providers/provider-options.d.ts +21 -1
  122. package/dist/model-providers/provider-options.d.ts.map +1 -1
  123. package/dist/model-providers/registry.d.ts +22 -2
  124. package/dist/model-providers/registry.d.ts.map +1 -1
  125. package/dist/model-providers/server-adapters.d.ts +19 -0
  126. package/dist/model-providers/server-adapters.d.ts.map +1 -1
  127. package/dist/pi-resources/assemble.d.ts +24 -4
  128. package/dist/pi-resources/assemble.d.ts.map +1 -1
  129. package/dist/pi-resources/bundle-cache.d.ts +20 -1
  130. package/dist/pi-resources/bundle-cache.d.ts.map +1 -1
  131. package/dist/pi-resources/bundle-pin-lifecycle.d.ts +5 -1
  132. package/dist/pi-resources/bundle-pin-lifecycle.d.ts.map +1 -1
  133. package/dist/pi-resources/resource-collector.d.ts +11 -0
  134. package/dist/pi-resources/resource-collector.d.ts.map +1 -1
  135. package/dist/pi-session-tree.d.ts +13 -1
  136. package/dist/pi-session-tree.d.ts.map +1 -1
  137. package/dist/process-action-registry.d.ts +47 -0
  138. package/dist/process-action-registry.d.ts.map +1 -1
  139. package/dist/process-deletion-service.d.ts +12 -0
  140. package/dist/process-deletion-service.d.ts.map +1 -1
  141. package/dist/process-engine/decision.d.ts +12 -0
  142. package/dist/process-engine/decision.d.ts.map +1 -1
  143. package/dist/process-engine/engine.d.ts +1 -0
  144. package/dist/process-engine/engine.d.ts.map +1 -1
  145. package/dist/process-engine/operation.d.ts +23 -2
  146. package/dist/process-engine/operation.d.ts.map +1 -1
  147. package/dist/process-engine/startup-reconciliation.d.ts +14 -0
  148. package/dist/process-engine/startup-reconciliation.d.ts.map +1 -1
  149. package/dist/process-engine/types.d.ts +112 -1
  150. package/dist/process-engine/types.d.ts.map +1 -1
  151. package/dist/process-engine/writes/build-process-park-writes.d.ts +3 -0
  152. package/dist/process-engine/writes/build-process-park-writes.d.ts.map +1 -1
  153. package/dist/process-engine/writes/build-recovery-start-writes.d.ts +4 -0
  154. package/dist/process-engine/writes/build-recovery-start-writes.d.ts.map +1 -1
  155. package/dist/process-engine/writes/build-retry-writes.d.ts +3 -0
  156. package/dist/process-engine/writes/build-retry-writes.d.ts.map +1 -1
  157. package/dist/process-engine/writes/build-turn-failed-writes.d.ts +6 -0
  158. package/dist/process-engine/writes/build-turn-failed-writes.d.ts.map +1 -1
  159. package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +8 -0
  160. package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
  161. package/dist/process-engine/writes/build-turn-selection-writes.d.ts +8 -0
  162. package/dist/process-engine/writes/build-turn-selection-writes.d.ts.map +1 -1
  163. package/dist/process-engine/writes/commit-writes.d.ts +14 -0
  164. package/dist/process-engine/writes/commit-writes.d.ts.map +1 -1
  165. package/dist/process-engine/writes/deferred-extension-events.d.ts +4 -0
  166. package/dist/process-engine/writes/deferred-extension-events.d.ts.map +1 -1
  167. package/dist/process-engine/writes/writes.d.ts +67 -0
  168. package/dist/process-engine/writes/writes.d.ts.map +1 -1
  169. package/dist/process-graph.d.ts +1 -1
  170. package/dist/process-graph.d.ts.map +1 -1
  171. package/dist/process-input-dispatch.d.ts +1 -0
  172. package/dist/process-input-dispatch.d.ts.map +1 -1
  173. package/dist/process-launch-executor.d.ts +1 -0
  174. package/dist/process-launch-executor.d.ts.map +1 -1
  175. package/dist/process-model-policy/types.d.ts +157 -1
  176. package/dist/process-model-policy/types.d.ts.map +1 -1
  177. package/dist/process-operation-coordinator.d.ts +3 -0
  178. package/dist/process-operation-coordinator.d.ts.map +1 -1
  179. package/dist/process-question-service.d.ts +36 -20
  180. package/dist/process-question-service.d.ts.map +1 -1
  181. package/dist/process-runtime-availability.d.ts +2 -1
  182. package/dist/process-runtime-availability.d.ts.map +1 -1
  183. package/dist/process-session-store.d.ts +15 -4
  184. package/dist/process-session-store.d.ts.map +1 -1
  185. package/dist/process-title-generator.d.ts +53 -0
  186. package/dist/process-title-generator.d.ts.map +1 -1
  187. package/dist/process-turn-navigation.d.ts +1 -30
  188. package/dist/process-turn-navigation.d.ts.map +1 -1
  189. package/dist/process-turn-trace.d.ts +7 -0
  190. package/dist/process-turn-trace.d.ts.map +1 -1
  191. package/dist/process-ui-registry.d.ts +2 -0
  192. package/dist/process-ui-registry.d.ts.map +1 -1
  193. package/dist/process-ui-snapshot-presenter.d.ts +68 -1
  194. package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
  195. package/dist/process-watcher-registry.d.ts +5 -0
  196. package/dist/process-watcher-registry.d.ts.map +1 -1
  197. package/dist/product-ref-state.d.ts +1 -0
  198. package/dist/product-ref-state.d.ts.map +1 -1
  199. package/dist/project-mutation-service.d.ts +19 -0
  200. package/dist/project-mutation-service.d.ts.map +1 -1
  201. package/dist/result-image-store.d.ts +20 -0
  202. package/dist/result-image-store.d.ts.map +1 -1
  203. package/dist/routes/process-route-helpers.d.ts +30 -0
  204. package/dist/routes/process-route-helpers.d.ts.map +1 -1
  205. package/dist/routes/ui-renderers.d.ts +4 -0
  206. package/dist/routes/ui-renderers.d.ts.map +1 -1
  207. package/dist/routes/watchers.d.ts +3 -0
  208. package/dist/routes/watchers.d.ts.map +1 -1
  209. package/dist/semantic-entry-ref-state.d.ts +1 -0
  210. package/dist/semantic-entry-ref-state.d.ts.map +1 -1
  211. package/dist/server-bootstrap/app-lifecycle.d.ts +24 -0
  212. package/dist/server-bootstrap/app-lifecycle.d.ts.map +1 -0
  213. package/dist/server-bootstrap/build-host-capabilities.d.ts +5 -1
  214. package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
  215. package/dist/server-topology.d.ts +8 -1
  216. package/dist/server-topology.d.ts.map +1 -1
  217. package/dist/session-transfer-helper-relays.d.ts +24 -0
  218. package/dist/session-transfer-helper-relays.d.ts.map +1 -1
  219. package/dist/session-transfer-service.d.ts +63 -1
  220. package/dist/session-transfer-service.d.ts.map +1 -1
  221. package/dist/skills/catalog-service.d.ts +7 -0
  222. package/dist/skills/catalog-service.d.ts.map +1 -1
  223. package/dist/skills/source-importer.d.ts +8 -0
  224. package/dist/skills/source-importer.d.ts.map +1 -1
  225. package/dist/startup-evidence.d.ts.map +1 -1
  226. package/dist/supervisor/ipc-handler.d.ts +28 -0
  227. package/dist/supervisor/ipc-handler.d.ts.map +1 -1
  228. package/dist/supervisor/worker-event-ingestor.d.ts +10 -0
  229. package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
  230. package/dist/supervisor/worker-start-payload-builder.d.ts +13 -0
  231. package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
  232. package/dist/supervisor/worker-storage-layout.d.ts +12 -0
  233. package/dist/supervisor/worker-storage-layout.d.ts.map +1 -1
  234. package/dist/supervisor/worker-supervisor.d.ts +47 -3
  235. package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
  236. package/dist/supervisor/worker-turn-ipc-recorder.d.ts +19 -0
  237. package/dist/supervisor/worker-turn-ipc-recorder.d.ts.map +1 -1
  238. package/dist/supervisor/worker-unit-reclaimer.d.ts +3 -0
  239. package/dist/supervisor/worker-unit-reclaimer.d.ts.map +1 -1
  240. package/dist/supervisor/worker-websocket-ipc.d.ts +37 -0
  241. package/dist/supervisor/worker-websocket-ipc.d.ts.map +1 -1
  242. package/dist/test-helpers/accepted-turn-start.d.ts +17 -0
  243. package/dist/test-helpers/accepted-turn-start.d.ts.map +1 -1
  244. package/dist/test-helpers/session-snapshot-fixtures.d.ts +1 -1
  245. package/dist/test-helpers/session-snapshot-fixtures.d.ts.map +1 -1
  246. package/dist/test-helpers/turn-start-preflight-fixtures.d.ts +8 -1
  247. package/dist/test-helpers/turn-start-preflight-fixtures.d.ts.map +1 -1
  248. package/dist/test-helpers/unit-deps.d.ts +8 -0
  249. package/dist/test-helpers/unit-deps.d.ts.map +1 -1
  250. package/dist/testing.d.ts +4 -7
  251. package/dist/testing.d.ts.map +1 -1
  252. package/dist/testing.js +2 -53
  253. package/dist/testing.js.map +1 -1
  254. package/dist/tool-approval-gate.d.ts +21 -0
  255. package/dist/tool-approval-gate.d.ts.map +1 -1
  256. package/dist/turn-result-markdown.d.ts +2 -0
  257. package/dist/turn-result-markdown.d.ts.map +1 -1
  258. package/dist/worker-runtime-profile-selection.d.ts +20 -4
  259. package/dist/worker-runtime-profile-selection.d.ts.map +1 -1
  260. package/dist/ws/broadcast.d.ts +10 -0
  261. package/dist/ws/broadcast.d.ts.map +1 -1
  262. package/package.json +11 -11
  263. package/src/app.ts +916 -892
  264. package/src/config/config-loader.ts +12 -0
  265. package/src/config/config-types.ts +166 -66
  266. package/src/db/api-token-repo.ts +35 -2
  267. package/src/db/auth-repo.ts +35 -1
  268. package/src/db/credential-cipher.ts +8 -3
  269. package/src/db/database.ts +14 -0
  270. package/src/db/external-write-log-repo.ts +6 -1
  271. package/src/db/future-execution-repo.ts +51 -1
  272. package/src/db/launch-run-repo.ts +17 -0
  273. package/src/db/launcher-recent-value-repo.ts +15 -0
  274. package/src/db/pending-external-source-fire-repo.ts +33 -0
  275. package/src/db/process-event-repo.ts +21 -1
  276. package/src/db/process-handoff-dedup-key-repo.ts +8 -0
  277. package/src/db/process-input-repo.ts +15 -0
  278. package/src/db/process-instance-repo.ts +57 -2
  279. package/src/db/process-leaf-outcome-snapshot-repo.ts +18 -0
  280. package/src/db/process-project-repo.ts +20 -0
  281. package/src/db/process-question-request-repo.ts +19 -0
  282. package/src/db/process-relation-repo.ts +8 -1
  283. package/src/db/process-skill-repo.ts +4 -0
  284. package/src/db/process-title-job-repo.ts +30 -2
  285. package/src/db/process-tool-approval-request-repo.ts +24 -1
  286. package/src/db/process-turn-annotation-repo.ts +22 -2
  287. package/src/db/process-turn-record-repo.ts +27 -0
  288. package/src/db/provider-credential-repo.ts +20 -1
  289. package/src/db/repositories.ts +36 -1
  290. package/src/db/session-transfer-repo.ts +71 -9
  291. package/src/db/skill-repo.ts +24 -1
  292. package/src/db/startup-observation-repo.ts +3 -0
  293. package/src/db/ticket-destination-recent-repo.ts +14 -0
  294. package/src/db/turn-start-record-repo.ts +12 -1
  295. package/src/db/turn-summary-repo.ts +29 -2
  296. package/src/db/worker-lease-repo.ts +31 -1
  297. package/src/deployment-preflight.ts +1 -1
  298. package/src/effects/post-commit-effect.ts +42 -3
  299. package/src/effects/post-commit-runner.ts +1 -0
  300. package/src/entry-ref-patch.ts +9 -1
  301. package/src/extension-ui/catalog.ts +15 -0
  302. package/src/extensions/extension-host.ts +6 -0
  303. package/src/external-source-service.ts +12 -1
  304. package/src/future-execution/execution.ts +45 -8
  305. package/src/future-execution/launch-lifecycle.ts +145 -17
  306. package/src/future-execution/lifecycle.ts +124 -13
  307. package/src/future-execution/model-projection.ts +6 -0
  308. package/src/future-execution/transition-planner.ts +25 -0
  309. package/src/future-execution-scheduler.ts +7 -6
  310. package/src/index.ts +5 -153
  311. package/src/instance-tree.ts +3 -0
  312. package/src/integration-tool-registry.ts +17 -8
  313. package/src/launch-coordinator.ts +55 -5
  314. package/src/launch-pipeline.ts +103 -12
  315. package/src/launcher-recent-values-service.ts +3 -0
  316. package/src/main.ts +3 -10
  317. package/src/model-providers/builtin-server-adapter.ts +1 -0
  318. package/src/model-providers/credentials.ts +17 -0
  319. package/src/model-providers/model-status-cache.ts +30 -1
  320. package/src/model-providers/provider-options.ts +25 -2
  321. package/src/model-providers/registry.ts +22 -2
  322. package/src/model-providers/server-adapters.ts +19 -0
  323. package/src/pi-resources/assemble.ts +24 -4
  324. package/src/pi-resources/bundle-cache.ts +20 -1
  325. package/src/pi-resources/bundle-pin-lifecycle.ts +8 -2
  326. package/src/pi-resources/resource-collector.ts +11 -0
  327. package/src/pi-session-tree.ts +13 -1
  328. package/src/process-action-registry.ts +53 -1
  329. package/src/process-deletion-service.ts +29 -4
  330. package/src/process-engine/decision.ts +12 -0
  331. package/src/process-engine/engine.ts +1 -0
  332. package/src/process-engine/operation.ts +23 -2
  333. package/src/process-engine/startup-reconciliation.ts +14 -0
  334. package/src/process-engine/types.ts +176 -14
  335. package/src/process-engine/writes/build-process-park-writes.ts +3 -0
  336. package/src/process-engine/writes/build-recovery-start-writes.ts +4 -0
  337. package/src/process-engine/writes/build-retry-writes.ts +3 -0
  338. package/src/process-engine/writes/build-turn-failed-writes.ts +6 -0
  339. package/src/process-engine/writes/build-turn-outcome-writes.ts +8 -0
  340. package/src/process-engine/writes/build-turn-selection-writes.ts +8 -0
  341. package/src/process-engine/writes/commit-writes.ts +14 -0
  342. package/src/process-engine/writes/deferred-extension-events.ts +4 -0
  343. package/src/process-engine/writes/writes.ts +104 -10
  344. package/src/process-graph.ts +0 -3
  345. package/src/process-input-dispatch.ts +1 -0
  346. package/src/process-launch-executor.ts +1 -0
  347. package/src/process-model-policy/types.ts +195 -11
  348. package/src/process-operation-coordinator.ts +3 -0
  349. package/src/process-question-service.ts +53 -11
  350. package/src/process-runtime-availability.ts +4 -3
  351. package/src/process-session-store.ts +15 -4
  352. package/src/process-title-generator.ts +71 -5
  353. package/src/process-turn-navigation.ts +4 -1
  354. package/src/process-turn-trace.ts +7 -0
  355. package/src/process-ui-registry.ts +2 -0
  356. package/src/process-ui-snapshot-presenter.ts +75 -3
  357. package/src/process-watcher-registry.ts +5 -0
  358. package/src/product-ref-state.ts +1 -0
  359. package/src/project-mutation-service.ts +22 -1
  360. package/src/result-image-store.ts +27 -2
  361. package/src/routes/process-route-helpers.ts +30 -0
  362. package/src/routes/ui-renderers.ts +4 -0
  363. package/src/routes/watchers.ts +3 -0
  364. package/src/semantic-entry-ref-state.ts +1 -0
  365. package/src/server-bootstrap/app-lifecycle.ts +150 -0
  366. package/src/server-topology.ts +8 -1
  367. package/src/session-transfer-helper-relays.ts +33 -2
  368. package/src/session-transfer-service.ts +75 -7
  369. package/src/skills/catalog-service.ts +7 -0
  370. package/src/skills/source-importer.ts +8 -0
  371. package/src/startup-evidence.ts +23 -41
  372. package/src/supervisor/ipc-handler.ts +33 -1
  373. package/src/supervisor/worker-event-ingestor.ts +10 -0
  374. package/src/supervisor/worker-start-payload-builder.ts +16 -1
  375. package/src/supervisor/worker-storage-layout.ts +12 -0
  376. package/src/supervisor/worker-supervisor.ts +119 -133
  377. package/src/supervisor/worker-turn-ipc-recorder.ts +19 -0
  378. package/src/supervisor/worker-unit-reclaimer.ts +3 -0
  379. package/src/supervisor/worker-websocket-ipc.ts +57 -3
  380. package/src/test-helpers/accepted-turn-start.ts +28 -2
  381. package/src/test-helpers/session-snapshot-fixtures.ts +1 -1
  382. package/src/test-helpers/turn-start-preflight-fixtures.ts +8 -1
  383. package/src/test-helpers/unit-deps.ts +13 -1
  384. package/src/testing.ts +4 -23
  385. package/src/tool-approval-gate.ts +32 -3
  386. package/src/turn-result-markdown.ts +2 -0
  387. package/src/worker-runtime-profile-selection.ts +24 -5
  388. package/src/ws/broadcast.ts +20 -1
  389. package/dist/app-I4QQUL5B.js +0 -10
  390. package/dist/chunk-AGC2ND53.js.map +0 -1
  391. package/dist/chunk-XTXH6623.js.map +0 -1
  392. /package/dist/{app-I4QQUL5B.js.map → app-7PKX73TU.js.map} +0 -0
@@ -4,19 +4,37 @@ import type { LeitwerkDb } from "./database.js";
4
4
  import { generateId, now } from "./repo-helpers.js";
5
5
  import * as s from "./schema.js";
6
6
 
7
+ /** @internal */
7
8
  export type ProcessTitleJob = typeof s.processTitleJobs.$inferSelect;
8
9
 
10
+ /** @internal */
9
11
  export type EnqueueProcessTitleJobInput = {
12
+ /** @internal */
10
13
  processDefinitionId: string;
14
+ /** @internal */
11
15
  modelProfileId: string;
16
+ /** @internal */
12
17
  prompt: string;
18
+ /** @internal */
13
19
  maxAttempts: number;
20
+ /** @internal */
14
21
  nextRunAt: string;
15
22
  } & (
16
- | { processInstanceId: string; launchRunId?: string | null }
17
- | { futureExecutionId: string; expectedPayloadJson: string }
23
+ | {
24
+ /** @internal */
25
+ processInstanceId: string;
26
+ /** @internal */
27
+ launchRunId?: string | null;
28
+ }
29
+ | {
30
+ /** @internal */
31
+ futureExecutionId: string;
32
+ /** @internal */
33
+ expectedPayloadJson: string;
34
+ }
18
35
  );
19
36
 
37
+ /** @internal */
20
38
  export function createProcessTitleJobRepo(db: LeitwerkDb) {
21
39
  function transition(
22
40
  id: string,
@@ -34,6 +52,7 @@ export function createProcessTitleJobRepo(db: LeitwerkDb) {
34
52
  }
35
53
 
36
54
  return {
55
+ /** @internal */
37
56
  enqueue(input: EnqueueProcessTitleJobInput): ProcessTitleJob {
38
57
  const ts = now();
39
58
  const target =
@@ -77,11 +96,13 @@ export function createProcessTitleJobRepo(db: LeitwerkDb) {
77
96
  .get();
78
97
  },
79
98
 
99
+ /** @internal */
80
100
  getById(id: string): ProcessTitleJob | null {
81
101
  const row = db.select().from(s.processTitleJobs).where(eq(s.processTitleJobs.id, id)).get();
82
102
  return row ?? null;
83
103
  },
84
104
 
105
+ /** @internal */
85
106
  listByProcessInstance(processInstanceId: string): ProcessTitleJob[] {
86
107
  return db
87
108
  .select()
@@ -91,6 +112,7 @@ export function createProcessTitleJobRepo(db: LeitwerkDb) {
91
112
  .all();
92
113
  },
93
114
 
115
+ /** @internal */
94
116
  listAll(): ProcessTitleJob[] {
95
117
  return db
96
118
  .select()
@@ -99,6 +121,7 @@ export function createProcessTitleJobRepo(db: LeitwerkDb) {
99
121
  .all();
100
122
  },
101
123
 
124
+ /** @internal */
102
125
  listDuePending(asOf: string, limit: number): ProcessTitleJob[] {
103
126
  return db
104
127
  .select()
@@ -111,6 +134,7 @@ export function createProcessTitleJobRepo(db: LeitwerkDb) {
111
134
  .all();
112
135
  },
113
136
 
137
+ /** @internal */
114
138
  markRunning(id: string): ProcessTitleJob | null {
115
139
  return transition(id, ["pending"], {
116
140
  status: "running",
@@ -119,18 +143,22 @@ export function createProcessTitleJobRepo(db: LeitwerkDb) {
119
143
  });
120
144
  },
121
145
 
146
+ /** @internal */
122
147
  reschedule(id: string, nextRunAt: string, lastError: string): ProcessTitleJob | null {
123
148
  return transition(id, ["running"], { status: "pending", nextRunAt, lastError });
124
149
  },
125
150
 
151
+ /** @internal */
126
152
  markCompleted(id: string): ProcessTitleJob | null {
127
153
  return transition(id, ["running"], { status: "completed", lastError: null });
128
154
  },
129
155
 
156
+ /** @internal */
130
157
  markFailed(id: string, lastError: string): ProcessTitleJob | null {
131
158
  return transition(id, ["running"], { status: "failed", lastError });
132
159
  },
133
160
 
161
+ /** @internal */
134
162
  markSuperseded(id: string): ProcessTitleJob | null {
135
163
  return transition(id, ["pending", "running"], { status: "superseded" });
136
164
  },
@@ -36,6 +36,7 @@ function map(row: typeof s.processToolApprovalRequests.$inferSelect): ProcessToo
36
36
  };
37
37
  }
38
38
 
39
+ /** @internal */
39
40
  export function createProcessToolApprovalRequestRepo(db: LeitwerkDb) {
40
41
  const list = (instanceId?: string, openOnly = false): ProcessToolApprovalRequest[] => {
41
42
  const filters = [
@@ -51,17 +52,32 @@ export function createProcessToolApprovalRequestRepo(db: LeitwerkDb) {
51
52
  .map(map);
52
53
  };
53
54
  return {
55
+ /** @internal */
54
56
  listByInstance: (instanceId: string) => list(instanceId),
57
+ /** @internal */
55
58
  listOpen: (instanceId?: string) => list(instanceId, true),
59
+ /** @internal */
56
60
  createIdempotent(input: {
61
+ /** @internal */
57
62
  instanceId: string;
63
+ /** @internal */
58
64
  turnRecordId: string;
65
+ /** @internal */
59
66
  toolCallId: string;
67
+ /** @internal */
60
68
  toolName: string;
69
+ /** @internal */
61
70
  arguments: Record<string, unknown>;
71
+ /** @internal */
62
72
  destination?: ProcessToolApprovalDestination;
73
+ /** @internal */
63
74
  requestedAt?: string;
64
- }): { kind: "created" | "replay"; request: ProcessToolApprovalRequest } {
75
+ }): {
76
+ /** @internal */
77
+ kind: "created" | "replay";
78
+ /** @internal */
79
+ request: ProcessToolApprovalRequest;
80
+ } {
65
81
  const existing = db
66
82
  .select()
67
83
  .from(s.processToolApprovalRequests)
@@ -100,11 +116,17 @@ export function createProcessToolApprovalRequestRepo(db: LeitwerkDb) {
100
116
  .get();
101
117
  return { kind: "created", request: map(row) };
102
118
  },
119
+ /** @internal */
103
120
  resolve(input: {
121
+ /** @internal */
104
122
  id: string;
123
+ /** @internal */
105
124
  status: Exclude<ToolApprovalStatus, "open" | "cancelled">;
125
+ /** @internal */
106
126
  actor: Actor;
127
+ /** @internal */
107
128
  feedback?: string;
129
+ /** @internal */
108
130
  resolvedAt?: string;
109
131
  }): ProcessToolApprovalRequest | null {
110
132
  if (input.status === "feedback" && !input.feedback?.trim())
@@ -127,6 +149,7 @@ export function createProcessToolApprovalRequestRepo(db: LeitwerkDb) {
127
149
  .get();
128
150
  return row ? map(row) : null;
129
151
  },
152
+ /** @internal */
130
153
  cancelOpenByTurn(instanceId: string, turnRecordId: string): number {
131
154
  const result = db
132
155
  .update(s.processToolApprovalRequests)
@@ -6,24 +6,37 @@ import type { LeitwerkDb } from "./database.js";
6
6
  import { generateId, now, parseJsonRecord } from "./repo-helpers.js";
7
7
  import * as s from "./schema.js";
8
8
 
9
+ /** @internal */
9
10
  export interface CreateProcessTurnAnnotationInput {
11
+ /** @internal */
10
12
  id?: string;
13
+ /** @internal */
11
14
  instanceId: string;
15
+ /** @internal */
12
16
  annotationType: string;
13
- /** Null means append-only and therefore not addressable via upsert key. */
17
+ /** Null means append-only and therefore not addressable via upsert key. @internal */
14
18
  annotationKey?: string | null;
19
+ /** @internal */
15
20
  references?: readonly TurnAnnotationReference[];
21
+ /** @internal */
16
22
  payload?: Record<string, unknown>;
23
+ /** @internal */
17
24
  createdAt?: string;
25
+ /** @internal */
18
26
  updatedAt?: string;
19
27
  }
20
28
 
29
+ /** @internal */
21
30
  export interface UpdateProcessTurnAnnotationInput {
31
+ /** @internal */
22
32
  annotationType?: string;
23
- /** Null means append-only and therefore not addressable via upsert key. */
33
+ /** Null means append-only and therefore not addressable via upsert key. @internal */
24
34
  annotationKey?: string | null;
35
+ /** @internal */
25
36
  references?: readonly TurnAnnotationReference[];
37
+ /** @internal */
26
38
  payload?: Record<string, unknown>;
39
+ /** @internal */
27
40
  updatedAt?: string;
28
41
  }
29
42
 
@@ -50,8 +63,10 @@ function rowToProcessTurnAnnotation(
50
63
  };
51
64
  }
52
65
 
66
+ /** @internal */
53
67
  export function createProcessTurnAnnotationRepo(db: LeitwerkDb) {
54
68
  return {
69
+ /** @internal */
55
70
  create(input: CreateProcessTurnAnnotationInput): ProcessTurnAnnotation {
56
71
  const id = input.id ?? generateId("tan");
57
72
  const createdAt = input.createdAt ?? now();
@@ -70,11 +85,13 @@ export function createProcessTurnAnnotationRepo(db: LeitwerkDb) {
70
85
  return rowToProcessTurnAnnotation(values);
71
86
  },
72
87
 
88
+ /** @internal */
73
89
  getById(id: string): ProcessTurnAnnotation | null {
74
90
  const row = db.select().from(s.turnAnnotations).where(eq(s.turnAnnotations.id, id)).get();
75
91
  return row ? rowToProcessTurnAnnotation(row) : null;
76
92
  },
77
93
 
94
+ /** @internal */
78
95
  findByKey(instanceId: string, annotationKey: string): ProcessTurnAnnotation | null {
79
96
  const key = annotationKey.trim();
80
97
  if (key.length === 0) {
@@ -93,6 +110,7 @@ export function createProcessTurnAnnotationRepo(db: LeitwerkDb) {
93
110
  return row ? rowToProcessTurnAnnotation(row) : null;
94
111
  },
95
112
 
113
+ /** @internal */
96
114
  listByInstance(instanceId: string): ProcessTurnAnnotation[] {
97
115
  return db
98
116
  .select()
@@ -103,6 +121,7 @@ export function createProcessTurnAnnotationRepo(db: LeitwerkDb) {
103
121
  .map(rowToProcessTurnAnnotation);
104
122
  },
105
123
 
124
+ /** @internal */
106
125
  update(id: string, input: UpdateProcessTurnAnnotationInput): ProcessTurnAnnotation | null {
107
126
  const setValues: SQLiteUpdateSetSource<typeof s.turnAnnotations> = {
108
127
  updatedAt: input.updatedAt ?? now(),
@@ -117,6 +136,7 @@ export function createProcessTurnAnnotationRepo(db: LeitwerkDb) {
117
136
  return this.getById(id);
118
137
  },
119
138
 
139
+ /** @internal */
120
140
  delete(id: string): boolean {
121
141
  const result = db.delete(s.turnAnnotations).where(eq(s.turnAnnotations.id, id)).run();
122
142
  return result.changes > 0;
@@ -13,28 +13,49 @@ import type { LeitwerkDb } from "./database.js";
13
13
  import { generateId, now } from "./repo-helpers.js";
14
14
  import * as s from "./schema.js";
15
15
 
16
+ /** @internal */
16
17
  export interface CreateProcessTurnRecordInput extends UpdateProcessTurnRecordInput {
18
+ /** @internal */
17
19
  id?: string;
20
+ /** @internal */
18
21
  instanceId: string;
22
+ /** @internal */
19
23
  turnId: TurnId;
24
+ /** @internal */
20
25
  pathType?: ProcessTurnRecordPathType;
26
+ /** @internal */
21
27
  startedAt?: string;
22
28
  }
23
29
 
30
+ /** @internal */
24
31
  export interface UpdateProcessTurnRecordInput {
32
+ /** @internal */
25
33
  turnType?: ProcessTurnType;
34
+ /** @internal */
26
35
  status?: ProcessTurnRecordStatus;
36
+ /** @internal */
27
37
  attemptNumber?: number;
38
+ /** @internal */
28
39
  parentTurnRecordId?: string | null;
40
+ /** @internal */
29
41
  turnStartRecordId?: string | null;
42
+ /** @internal */
30
43
  acceptedWorkerLeaseId?: string | null;
44
+ /** @internal */
31
45
  forkPiEntryId?: string | null;
46
+ /** @internal */
32
47
  resultPiEntryId?: string | null;
48
+ /** @internal */
33
49
  modelProfileId?: string | null;
50
+ /** @internal */
34
51
  modelSelectionProvenance?: ModelSelectionProvenance | null;
52
+ /** @internal */
35
53
  turnResultMarkdown?: string | null;
54
+ /** @internal */
36
55
  errorSummary?: string | null;
56
+ /** @internal */
37
57
  errorClass?: WorkerErrorClass | null;
58
+ /** @internal */
38
59
  endedAt?: string | null;
39
60
  }
40
61
 
@@ -68,8 +89,10 @@ function rowToProcessTurnRecord(row: typeof s.turnRecords.$inferSelect): Process
68
89
  };
69
90
  }
70
91
 
92
+ /** @public */
71
93
  export function createProcessTurnRecordRepo(db: LeitwerkDb) {
72
94
  return {
95
+ /** @internal */
73
96
  create(input: CreateProcessTurnRecordInput): ProcessTurnRecord {
74
97
  const id = input.id ?? generateId("trn");
75
98
  const values = {
@@ -98,11 +121,13 @@ export function createProcessTurnRecordRepo(db: LeitwerkDb) {
98
121
  return rowToProcessTurnRecord(values);
99
122
  },
100
123
 
124
+ /** @internal */
101
125
  getById(id: string): ProcessTurnRecord | null {
102
126
  const row = db.select().from(s.turnRecords).where(eq(s.turnRecords.id, id)).get();
103
127
  return row ? rowToProcessTurnRecord(row) : null;
104
128
  },
105
129
 
130
+ /** @public */
106
131
  listByInstance(instanceId: string): ProcessTurnRecord[] {
107
132
  return db
108
133
  .select()
@@ -113,6 +138,7 @@ export function createProcessTurnRecordRepo(db: LeitwerkDb) {
113
138
  .map(rowToProcessTurnRecord);
114
139
  },
115
140
 
141
+ /** @internal */
116
142
  getLatestSucceededPrimaryByInstance(instanceId: string): ProcessTurnRecord | null {
117
143
  const row = db
118
144
  .select()
@@ -131,6 +157,7 @@ export function createProcessTurnRecordRepo(db: LeitwerkDb) {
131
157
  return row ?? null;
132
158
  },
133
159
 
160
+ /** @internal */
134
161
  update(id: string, input: UpdateProcessTurnRecordInput): ProcessTurnRecord | null {
135
162
  const setValues: SQLiteUpdateSetSource<typeof s.turnRecords> = {
136
163
  turnType: input.turnType,
@@ -4,14 +4,21 @@ import type { LeitwerkDb } from "./database.js";
4
4
  import { now } from "./repo-helpers.js";
5
5
  import * as s from "./schema.js";
6
6
 
7
+ /** @internal */
7
8
  export interface ProviderCredentialRecord {
9
+ /** @internal */
8
10
  providerId: string;
11
+ /** @internal */
9
12
  revision: number;
13
+ /** @internal */
10
14
  payload: string;
15
+ /** @internal */
11
16
  createdAt: string;
17
+ /** @internal */
12
18
  updatedAt: string;
13
19
  }
14
20
 
21
+ /** @internal */
15
22
  export function createProviderCredentialRepo(db: LeitwerkDb, cipher: CredentialCipher) {
16
23
  const row = (value: typeof s.providerCredentials.$inferSelect): ProviderCredentialRecord => ({
17
24
  providerId: value.providerId,
@@ -21,9 +28,11 @@ export function createProviderCredentialRepo(db: LeitwerkDb, cipher: CredentialC
21
28
  updatedAt: value.updatedAt,
22
29
  });
23
30
  return {
31
+ /** @internal */
24
32
  count(): number {
25
33
  return db.select({ value: count() }).from(s.providerCredentials).get()?.value ?? 0;
26
34
  },
35
+ /** @internal */
27
36
  get(providerId: string): ProviderCredentialRecord | null {
28
37
  const value = db
29
38
  .select()
@@ -32,7 +41,13 @@ export function createProviderCredentialRepo(db: LeitwerkDb, cipher: CredentialC
32
41
  .get();
33
42
  return value ? row(value) : null;
34
43
  },
35
- create(input: { providerId: string; payload: string }): ProviderCredentialRecord {
44
+ /** @internal */
45
+ create(input: {
46
+ /** @internal */
47
+ providerId: string;
48
+ /** @internal */
49
+ payload: string;
50
+ }): ProviderCredentialRecord {
36
51
  const ts = now();
37
52
  const value = {
38
53
  ...input,
@@ -50,9 +65,13 @@ export function createProviderCredentialRepo(db: LeitwerkDb, cipher: CredentialC
50
65
  updatedAt: ts,
51
66
  };
52
67
  },
68
+ /** @internal */
53
69
  compareAndSet(input: {
70
+ /** @internal */
54
71
  providerId: string;
72
+ /** @internal */
55
73
  expectedRevision: number;
74
+ /** @internal */
56
75
  payload: string;
57
76
  }): ProviderCredentialRecord | null {
58
77
  const ts = now();
@@ -62,42 +62,77 @@ import { createWorkerLeaseRepo } from "./worker-lease-repo.js";
62
62
 
63
63
  // ── Repository bundle ──
64
64
 
65
+ /** @public */
65
66
  export interface RepositoryBundle {
67
+ /** @internal */
66
68
  startupObservations: ReturnType<typeof createStartupObservationRepo>;
69
+ /** @internal */
67
70
  turnSummaries: ReturnType<typeof createTurnSummaryRepo>;
71
+ /** @public */
68
72
  processes: ReturnType<typeof createProcessInstanceRepo>;
73
+ /** @public */
69
74
  projects: ReturnType<typeof createProcessProjectRepo>;
75
+ /** @internal */
70
76
  questionRequests: ReturnType<typeof createProcessQuestionRequestRepo>;
77
+ /** @internal */
71
78
  processRelations: ReturnType<typeof createProcessRelationRepo>;
79
+ /** @internal */
72
80
  toolApprovalRequests: ReturnType<typeof createProcessToolApprovalRequestRepo>;
81
+ /** @internal */
73
82
  inputs: ReturnType<typeof createProcessInputRepo>;
83
+ /** @internal */
74
84
  events: ReturnType<typeof createProcessEventRepo>;
85
+ /** @internal */
75
86
  handoffDedupKeys: ReturnType<typeof createProcessHandoffDedupKeyRepo>;
87
+ /** @internal */
76
88
  futureExecutions: ReturnType<typeof createFutureExecutionRepo>;
89
+ /** @internal */
77
90
  launcherRecentValues: ReturnType<typeof createLauncherRecentValueRepo>;
91
+ /** @internal */
78
92
  ticketDestinationRecents: ReturnType<typeof createTicketDestinationRecentRepo>;
93
+ /** @internal */
79
94
  launchRuns: ReturnType<typeof createLaunchRunRepo>;
95
+ /** @internal */
80
96
  titleJobs: ReturnType<typeof createProcessTitleJobRepo>;
97
+ /** @internal */
81
98
  pendingExternalSourceFires: ReturnType<typeof createPendingExternalSourceFireRepo>;
99
+ /** @internal */
82
100
  leafOutcomeSnapshots: ReturnType<typeof createProcessLeafOutcomeSnapshotRepo>;
101
+ /** @public */
83
102
  turnRecords: ReturnType<typeof createProcessTurnRecordRepo>;
103
+ /** @internal */
84
104
  turnStarts: ReturnType<typeof createTurnStartRecordRepo>;
105
+ /** @internal */
85
106
  turnAnnotations: ReturnType<typeof createProcessTurnAnnotationRepo>;
107
+ /** @internal */
86
108
  leases: ReturnType<typeof createWorkerLeaseRepo>;
109
+ /** @internal */
87
110
  providerCredentials: ReturnType<typeof createProviderCredentialRepo>;
111
+ /** @public */
88
112
  externalWrites: ReturnType<typeof createExternalWriteLogRepo>;
113
+ /** @internal */
89
114
  sessionTransfers: ReturnType<typeof createSessionTransferRepo>;
115
+ /** @internal */
90
116
  skills: ReturnType<typeof createSkillRepo>;
117
+ /** @internal */
91
118
  processSkills: ReturnType<typeof createProcessSkillRepo>;
119
+ /** @internal */
92
120
  apiTokens: ReturnType<typeof createApiTokenRepo>;
121
+ /** @internal */
93
122
  authSessions: ReturnType<typeof createAuthSessionRepo>;
123
+ /** @internal */
94
124
  authLoginFlows: ReturnType<typeof createAuthLoginFlowRepo>;
125
+ /** @internal */
95
126
  transaction<T>(fn: (repos: RepositoryBundle) => T): T;
96
127
  }
97
128
 
129
+ /** @internal */
98
130
  export function createAllRepos(
99
131
  db: LeitwerkDb,
100
- options: { credentialCipher?: CredentialCipher } = {},
132
+ options: {
133
+ /** @internal */
134
+ credentialCipher?: CredentialCipher;
135
+ } = {},
101
136
  ): RepositoryBundle {
102
137
  const credentialCipher = options.credentialCipher ?? createUnavailableCredentialCipher();
103
138
  const bundle: RepositoryBundle = {
@@ -9,23 +9,31 @@ import type { LeitwerkDb } from "./database.js";
9
9
  import { generateId } from "./repo-helpers.js";
10
10
  import * as s from "./schema.js";
11
11
 
12
- export type {
13
- SessionTransferAttemptState,
14
- SessionTransferPhase,
15
- } from "@leitwerk-dev/session-transfer";
12
+ export type { SessionTransferPhase } from "@leitwerk-dev/session-transfer";
16
13
 
14
+ /** @internal */
17
15
  export interface SessionTransferGrant {
16
+ /** @internal */
18
17
  id: string;
18
+ /** @internal */
19
19
  instanceId: string;
20
+ /** @internal */
20
21
  tokenHash: string;
22
+ /** @internal */
21
23
  createdAt: string;
24
+ /** @internal */
22
25
  expiresAt: string;
26
+ /** @internal */
23
27
  consumedAt: string | null;
28
+ /** @internal */
24
29
  tombstoneUntil: string | null;
25
30
  }
26
31
 
32
+ /** @internal */
27
33
  export interface SessionTransferAttempt extends SessionTransferAttemptWire {
34
+ /** @internal */
28
35
  createdAt: string;
36
+ /** @internal */
29
37
  completedAt: string | null;
30
38
  }
31
39
 
@@ -44,6 +52,7 @@ function isActivePhase(phase: SessionTransferPhase): boolean {
44
52
  return ACTIVE_PHASES.includes(phase);
45
53
  }
46
54
 
55
+ /** @internal */
47
56
  export function createSessionTransferRepo(db: LeitwerkDb) {
48
57
  const toAttempt = (
49
58
  row: typeof s.sessionTransferAttempts.$inferSelect | undefined,
@@ -56,8 +65,18 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
56
65
  : null;
57
66
 
58
67
  return {
59
- createGrant(input: { instanceId: string; now: Date; lifetimeMs: number }): {
68
+ /** @internal */
69
+ createGrant(input: {
70
+ /** @internal */
71
+ instanceId: string;
72
+ /** @internal */
73
+ now: Date;
74
+ /** @internal */
75
+ lifetimeMs: number;
76
+ }): {
77
+ /** @internal */
60
78
  grant: SessionTransferGrant;
79
+ /** @internal */
61
80
  rawToken: string;
62
81
  } {
63
82
  const rawToken = createOpaqueToken();
@@ -74,6 +93,7 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
74
93
  return { grant: this.getGrant(values.id) as SessionTransferGrant, rawToken };
75
94
  },
76
95
 
96
+ /** @internal */
77
97
  getGrant(id: string): SessionTransferGrant | null {
78
98
  return (
79
99
  db.select().from(s.sessionTransferGrants).where(eq(s.sessionTransferGrants.id, id)).get() ??
@@ -81,6 +101,7 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
81
101
  );
82
102
  },
83
103
 
104
+ /** @internal */
84
105
  getAttempt(id: string): SessionTransferAttempt | null {
85
106
  return toAttempt(
86
107
  db
@@ -91,6 +112,7 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
91
112
  );
92
113
  },
93
114
 
115
+ /** @internal */
94
116
  getActiveByInstance(instanceId: string): SessionTransferAttempt | null {
95
117
  return toAttempt(
96
118
  db
@@ -106,6 +128,7 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
106
128
  );
107
129
  },
108
130
 
131
+ /** @internal */
109
132
  listActive(): SessionTransferAttempt[] {
110
133
  return db
111
134
  .select()
@@ -115,17 +138,35 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
115
138
  .map((row) => toAttempt(row) as SessionTransferAttempt);
116
139
  },
117
140
 
141
+ /** @internal */
118
142
  startAttempt(input: {
143
+ /** @internal */
119
144
  instanceId: string;
145
+ /** @internal */
120
146
  grantId: string;
147
+ /** @internal */
121
148
  token: string;
149
+ /** @internal */
122
150
  now: Date;
151
+ /** @internal */
123
152
  leaseMs: number;
153
+ /** @internal */
124
154
  hardDeadlineMs: number;
125
155
  }):
126
- | { kind: "created"; attempt: SessionTransferAttempt }
127
- | { kind: "not_found" }
128
- | { kind: "busy" } {
156
+ | {
157
+ /** @internal */
158
+ kind: "created";
159
+ /** @internal */
160
+ attempt: SessionTransferAttempt;
161
+ }
162
+ | {
163
+ /** @internal */
164
+ kind: "not_found";
165
+ }
166
+ | {
167
+ /** @internal */
168
+ kind: "busy";
169
+ } {
129
170
  const grant = this.getGrant(input.grantId);
130
171
  if (
131
172
  !grant ||
@@ -165,10 +206,15 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
165
206
  };
166
207
  },
167
208
 
209
+ /** @internal */
168
210
  verifyAttempt(input: {
211
+ /** @internal */
169
212
  instanceId: string;
213
+ /** @internal */
170
214
  grantId: string;
215
+ /** @internal */
171
216
  attemptId: string;
217
+ /** @internal */
172
218
  token: string;
173
219
  }): SessionTransferAttempt | null {
174
220
  const grant = this.getGrant(input.grantId);
@@ -184,6 +230,7 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
184
230
  return verifyOpaqueToken(input.token, grant.tokenHash, "hex") ? attempt : null;
185
231
  },
186
232
 
233
+ /** @internal */
187
234
  updateAttempt(
188
235
  id: string,
189
236
  patch: Partial<
@@ -197,7 +244,16 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
197
244
  return this.getAttempt(id);
198
245
  },
199
246
 
200
- renew(id: string, input: { now: Date; leaseMs: number }): SessionTransferAttempt | null {
247
+ /** @internal */
248
+ renew(
249
+ id: string,
250
+ input: {
251
+ /** @internal */
252
+ now: Date;
253
+ /** @internal */
254
+ leaseMs: number;
255
+ },
256
+ ): SessionTransferAttempt | null {
201
257
  const attempt = this.getAttempt(id);
202
258
  if (!attempt || !isActivePhase(attempt.phase)) return attempt;
203
259
  const nextLease = Math.min(
@@ -207,9 +263,13 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
207
263
  return this.updateAttempt(id, { leaseUntil: new Date(nextLease).toISOString() });
208
264
  },
209
265
 
266
+ /** @internal */
210
267
  acknowledge(input: {
268
+ /** @internal */
211
269
  attemptId: string;
270
+ /** @internal */
212
271
  now: Date;
272
+ /** @internal */
213
273
  tombstoneMs: number;
214
274
  }): SessionTransferAttempt | null {
215
275
  const attempt = this.getAttempt(input.attemptId);
@@ -246,12 +306,14 @@ export function createSessionTransferRepo(db: LeitwerkDb) {
246
306
  return this.getAttempt(attempt.id);
247
307
  },
248
308
 
309
+ /** @internal */
249
310
  revokeProcess(instanceId: string): void {
250
311
  db.delete(s.sessionTransferGrants)
251
312
  .where(eq(s.sessionTransferGrants.instanceId, instanceId))
252
313
  .run();
253
314
  },
254
315
 
316
+ /** @internal */
255
317
  cleanup(now: Date): void {
256
318
  const cutoff = now.toISOString();
257
319
  db.delete(s.sessionTransferGrants)