clinkx 0.3.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (669) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/LICENSE +10 -0
  3. package/README.md +154 -26
  4. package/clinkx-workflows/dist/allowed-roots.d.ts +1 -0
  5. package/clinkx-workflows/dist/allowed-roots.js +5 -0
  6. package/clinkx-workflows/dist/allowed-roots.js.map +1 -0
  7. package/clinkx-workflows/dist/artifacts.d.ts +20 -1
  8. package/clinkx-workflows/dist/artifacts.js +38 -9
  9. package/clinkx-workflows/dist/artifacts.js.map +1 -1
  10. package/clinkx-workflows/dist/backend.d.ts +4 -0
  11. package/clinkx-workflows/dist/chairman-knobs.d.ts +24 -0
  12. package/clinkx-workflows/dist/chairman-knobs.js +27 -0
  13. package/clinkx-workflows/dist/chairman-knobs.js.map +1 -0
  14. package/clinkx-workflows/dist/citation-check.d.ts +40 -0
  15. package/clinkx-workflows/dist/citation-check.js +348 -0
  16. package/clinkx-workflows/dist/citation-check.js.map +1 -0
  17. package/clinkx-workflows/dist/clink-client.d.ts +12 -1
  18. package/clinkx-workflows/dist/clink-client.js +56 -5
  19. package/clinkx-workflows/dist/clink-client.js.map +1 -1
  20. package/clinkx-workflows/dist/config.d.ts +173 -16
  21. package/clinkx-workflows/dist/config.js +417 -26
  22. package/clinkx-workflows/dist/config.js.map +1 -1
  23. package/clinkx-workflows/dist/contained-file.d.ts +172 -0
  24. package/clinkx-workflows/dist/contained-file.js +483 -0
  25. package/clinkx-workflows/dist/contained-file.js.map +1 -0
  26. package/clinkx-workflows/dist/context-builder-lifecycle-contract.d.ts +416 -0
  27. package/clinkx-workflows/dist/context-builder-lifecycle-contract.js +328 -0
  28. package/clinkx-workflows/dist/context-builder-lifecycle-contract.js.map +1 -0
  29. package/clinkx-workflows/dist/context-builder-lifecycle-router.d.ts +24 -0
  30. package/clinkx-workflows/dist/context-builder-lifecycle-router.js +39 -0
  31. package/clinkx-workflows/dist/context-builder-lifecycle-router.js.map +1 -0
  32. package/clinkx-workflows/dist/context-cache-key.d.ts +53 -0
  33. package/clinkx-workflows/dist/context-cache-key.js +91 -0
  34. package/clinkx-workflows/dist/context-cache-key.js.map +1 -0
  35. package/clinkx-workflows/dist/context-mode-resolver.d.ts +27 -0
  36. package/clinkx-workflows/dist/context-mode-resolver.js +126 -0
  37. package/clinkx-workflows/dist/context-mode-resolver.js.map +1 -0
  38. package/clinkx-workflows/dist/context-preflight.d.ts +189 -0
  39. package/clinkx-workflows/dist/context-preflight.js +91 -0
  40. package/clinkx-workflows/dist/context-preflight.js.map +1 -0
  41. package/clinkx-workflows/dist/council-execution-policy.d.ts +68 -0
  42. package/clinkx-workflows/dist/council-execution-policy.js +110 -0
  43. package/clinkx-workflows/dist/council-execution-policy.js.map +1 -0
  44. package/clinkx-workflows/dist/council-expander.d.ts +10 -9
  45. package/clinkx-workflows/dist/council-expander.js +20 -10
  46. package/clinkx-workflows/dist/council-expander.js.map +1 -1
  47. package/clinkx-workflows/dist/dashboard/activity-contract.d.ts +5718 -0
  48. package/clinkx-workflows/dist/dashboard/activity-contract.js +157 -0
  49. package/clinkx-workflows/dist/dashboard/activity-contract.js.map +1 -0
  50. package/clinkx-workflows/dist/dashboard/activity-lease.d.ts +25 -0
  51. package/clinkx-workflows/dist/dashboard/activity-lease.js +34 -0
  52. package/clinkx-workflows/dist/dashboard/activity-lease.js.map +1 -0
  53. package/clinkx-workflows/dist/dashboard/activity-reader.d.ts +90 -0
  54. package/clinkx-workflows/dist/dashboard/activity-reader.js +493 -0
  55. package/clinkx-workflows/dist/dashboard/activity-reader.js.map +1 -0
  56. package/clinkx-workflows/dist/dashboard/api-routes.d.ts +40 -0
  57. package/clinkx-workflows/dist/dashboard/api-routes.js +1155 -0
  58. package/clinkx-workflows/dist/dashboard/api-routes.js.map +1 -0
  59. package/clinkx-workflows/dist/dashboard/artifact-index.d.ts +37 -0
  60. package/clinkx-workflows/dist/dashboard/artifact-index.js +145 -0
  61. package/clinkx-workflows/dist/dashboard/artifact-index.js.map +1 -0
  62. package/clinkx-workflows/dist/dashboard/auth/challenge-store.d.ts +31 -0
  63. package/clinkx-workflows/dist/dashboard/auth/challenge-store.js +65 -0
  64. package/clinkx-workflows/dist/dashboard/auth/challenge-store.js.map +1 -0
  65. package/clinkx-workflows/dist/dashboard/auth/controller.d.ts +26 -0
  66. package/clinkx-workflows/dist/dashboard/auth/controller.js +596 -0
  67. package/clinkx-workflows/dist/dashboard/auth/controller.js.map +1 -0
  68. package/clinkx-workflows/dist/dashboard/auth/credential-store.d.ts +60 -0
  69. package/clinkx-workflows/dist/dashboard/auth/credential-store.js +776 -0
  70. package/clinkx-workflows/dist/dashboard/auth/credential-store.js.map +1 -0
  71. package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.d.ts +9 -0
  72. package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.js +44 -0
  73. package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.js.map +1 -0
  74. package/clinkx-workflows/dist/dashboard/auth/session-store.d.ts +17 -0
  75. package/clinkx-workflows/dist/dashboard/auth/session-store.js +77 -0
  76. package/clinkx-workflows/dist/dashboard/auth/session-store.js.map +1 -0
  77. package/clinkx-workflows/dist/dashboard/auth/webauthn-service.d.ts +25 -0
  78. package/clinkx-workflows/dist/dashboard/auth/webauthn-service.js +71 -0
  79. package/clinkx-workflows/dist/dashboard/auth/webauthn-service.js.map +1 -0
  80. package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.d.ts +3865 -0
  81. package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.js +69 -0
  82. package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.js.map +1 -0
  83. package/clinkx-workflows/dist/dashboard/context-run-liveness.d.ts +37 -0
  84. package/clinkx-workflows/dist/dashboard/context-run-liveness.js +49 -0
  85. package/clinkx-workflows/dist/dashboard/context-run-liveness.js.map +1 -0
  86. package/clinkx-workflows/dist/dashboard/context-run-reader.d.ts +256 -0
  87. package/clinkx-workflows/dist/dashboard/context-run-reader.js +1301 -0
  88. package/clinkx-workflows/dist/dashboard/context-run-reader.js.map +1 -0
  89. package/clinkx-workflows/dist/dashboard/contracts.d.ts +28483 -0
  90. package/clinkx-workflows/dist/dashboard/contracts.js +1284 -0
  91. package/clinkx-workflows/dist/dashboard/contracts.js.map +1 -0
  92. package/clinkx-workflows/dist/dashboard/generation.d.ts +14 -0
  93. package/clinkx-workflows/dist/dashboard/generation.js +41 -0
  94. package/clinkx-workflows/dist/dashboard/generation.js.map +1 -0
  95. package/clinkx-workflows/dist/dashboard/index.d.ts +32 -0
  96. package/clinkx-workflows/dist/dashboard/index.js +20 -0
  97. package/clinkx-workflows/dist/dashboard/index.js.map +1 -0
  98. package/clinkx-workflows/dist/dashboard/invocation-contract.d.ts +786 -0
  99. package/clinkx-workflows/dist/dashboard/invocation-contract.js +201 -0
  100. package/clinkx-workflows/dist/dashboard/invocation-contract.js.map +1 -0
  101. package/clinkx-workflows/dist/dashboard/lazy-content.d.ts +114 -0
  102. package/clinkx-workflows/dist/dashboard/lazy-content.js +799 -0
  103. package/clinkx-workflows/dist/dashboard/lazy-content.js.map +1 -0
  104. package/clinkx-workflows/dist/dashboard/native-transcript/contract.d.ts +90 -0
  105. package/clinkx-workflows/dist/dashboard/native-transcript/contract.js +31 -0
  106. package/clinkx-workflows/dist/dashboard/native-transcript/contract.js.map +1 -0
  107. package/clinkx-workflows/dist/dashboard/native-transcript/projection.d.ts +12 -0
  108. package/clinkx-workflows/dist/dashboard/native-transcript/projection.js +286 -0
  109. package/clinkx-workflows/dist/dashboard/native-transcript/projection.js.map +1 -0
  110. package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +446 -0
  111. package/clinkx-workflows/dist/dashboard/progress-report-contract.js +221 -0
  112. package/clinkx-workflows/dist/dashboard/progress-report-contract.js.map +1 -0
  113. package/clinkx-workflows/dist/dashboard/progress-report-reader.d.ts +50 -0
  114. package/clinkx-workflows/dist/dashboard/progress-report-reader.js +529 -0
  115. package/clinkx-workflows/dist/dashboard/progress-report-reader.js.map +1 -0
  116. package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.d.ts +89 -0
  117. package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.js +71 -0
  118. package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.js.map +1 -0
  119. package/clinkx-workflows/dist/dashboard/progress-report-status-store.d.ts +29 -0
  120. package/clinkx-workflows/dist/dashboard/progress-report-status-store.js +111 -0
  121. package/clinkx-workflows/dist/dashboard/progress-report-status-store.js.map +1 -0
  122. package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.d.ts +194 -0
  123. package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.js +89 -0
  124. package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.js.map +1 -0
  125. package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.d.ts +26 -0
  126. package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.js +102 -0
  127. package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.js.map +1 -0
  128. package/clinkx-workflows/dist/dashboard/read-model.d.ts +86 -0
  129. package/clinkx-workflows/dist/dashboard/read-model.js +440 -0
  130. package/clinkx-workflows/dist/dashboard/read-model.js.map +1 -0
  131. package/clinkx-workflows/dist/dashboard/request-admission.d.ts +31 -0
  132. package/clinkx-workflows/dist/dashboard/request-admission.js +130 -0
  133. package/clinkx-workflows/dist/dashboard/request-admission.js.map +1 -0
  134. package/clinkx-workflows/dist/dashboard/scanner.d.ts +78 -0
  135. package/clinkx-workflows/dist/dashboard/scanner.js +1154 -0
  136. package/clinkx-workflows/dist/dashboard/scanner.js.map +1 -0
  137. package/clinkx-workflows/dist/dashboard/server-factory.d.ts +63 -0
  138. package/clinkx-workflows/dist/dashboard/server-factory.js +483 -0
  139. package/clinkx-workflows/dist/dashboard/server-factory.js.map +1 -0
  140. package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +2778 -0
  141. package/clinkx-workflows/dist/dashboard/session-log-contract.js +506 -0
  142. package/clinkx-workflows/dist/dashboard/session-log-contract.js.map +1 -0
  143. package/clinkx-workflows/dist/dashboard/session-log-identity.d.ts +21 -0
  144. package/clinkx-workflows/dist/dashboard/session-log-identity.js +101 -0
  145. package/clinkx-workflows/dist/dashboard/session-log-identity.js.map +1 -0
  146. package/clinkx-workflows/dist/dashboard/session-log-journal.d.ts +43 -0
  147. package/clinkx-workflows/dist/dashboard/session-log-journal.js +529 -0
  148. package/clinkx-workflows/dist/dashboard/session-log-journal.js.map +1 -0
  149. package/clinkx-workflows/dist/dashboard/session-log-reader.d.ts +61 -0
  150. package/clinkx-workflows/dist/dashboard/session-log-reader.js +378 -0
  151. package/clinkx-workflows/dist/dashboard/session-log-reader.js.map +1 -0
  152. package/clinkx-workflows/dist/dashboard/session-log-redaction.d.ts +14 -0
  153. package/clinkx-workflows/dist/dashboard/session-log-redaction.js +1101 -0
  154. package/clinkx-workflows/dist/dashboard/session-log-redaction.js.map +1 -0
  155. package/clinkx-workflows/dist/dashboard/session-log-retention.d.ts +23 -0
  156. package/clinkx-workflows/dist/dashboard/session-log-retention.js +212 -0
  157. package/clinkx-workflows/dist/dashboard/session-log-retention.js.map +1 -0
  158. package/clinkx-workflows/dist/dashboard/static-responses.d.ts +10 -0
  159. package/clinkx-workflows/dist/dashboard/static-responses.js +94 -0
  160. package/clinkx-workflows/dist/dashboard/static-responses.js.map +1 -0
  161. package/clinkx-workflows/dist/dashboard/worker-lock-observer.d.ts +28 -0
  162. package/clinkx-workflows/dist/dashboard/worker-lock-observer.js +241 -0
  163. package/clinkx-workflows/dist/dashboard/worker-lock-observer.js.map +1 -0
  164. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  165. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  166. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  167. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  168. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  169. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
  170. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  171. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
  172. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
  173. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  174. package/clinkx-workflows/dist/dashboard-ui/assets/index-JPHQVtn9.js +106 -0
  175. package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  176. package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  177. package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
  178. package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
  179. package/clinkx-workflows/dist/dashboard-ui/assets/style-DOMHk-j6.css +1 -0
  180. package/clinkx-workflows/dist/dashboard-ui/contracts/council-plan-review-input-v1.json +158 -0
  181. package/clinkx-workflows/dist/dashboard-ui/index.html +15 -0
  182. package/clinkx-workflows/dist/dashboard-ui/licenses/IBM-Plex-Mono-OFL.txt +93 -0
  183. package/clinkx-workflows/dist/dashboard-ui/licenses/IBM-Plex-Sans-OFL.txt +93 -0
  184. package/clinkx-workflows/dist/dashboard-ui/licenses/JetBrains-Mono-OFL.txt +93 -0
  185. package/clinkx-workflows/dist/dashboard-ui/licenses/NOTICE.md +32 -0
  186. package/clinkx-workflows/dist/dashboard-ui/theme-init.js +8 -0
  187. package/clinkx-workflows/dist/definition-normalizer.d.ts +19 -0
  188. package/clinkx-workflows/dist/definition-normalizer.js.map +1 -1
  189. package/clinkx-workflows/dist/delegate-finalizer-policy.d.ts +26 -0
  190. package/clinkx-workflows/dist/delegate-finalizer-policy.js +72 -0
  191. package/clinkx-workflows/dist/delegate-finalizer-policy.js.map +1 -0
  192. package/clinkx-workflows/dist/delegate-signature.d.ts +14 -0
  193. package/clinkx-workflows/dist/delegate-signature.js +14 -0
  194. package/clinkx-workflows/dist/delegate-signature.js.map +1 -0
  195. package/clinkx-workflows/dist/delegate-validate.d.ts +108 -0
  196. package/clinkx-workflows/dist/delegate-validate.js +148 -0
  197. package/clinkx-workflows/dist/delegate-validate.js.map +1 -0
  198. package/clinkx-workflows/dist/engine.d.ts +251 -0
  199. package/clinkx-workflows/dist/engine.js +1342 -92
  200. package/clinkx-workflows/dist/engine.js.map +1 -1
  201. package/clinkx-workflows/dist/errors.d.ts +24 -2
  202. package/clinkx-workflows/dist/errors.js +30 -2
  203. package/clinkx-workflows/dist/errors.js.map +1 -1
  204. package/clinkx-workflows/dist/fidelity.d.ts +47 -1
  205. package/clinkx-workflows/dist/fidelity.js +54 -1
  206. package/clinkx-workflows/dist/fidelity.js.map +1 -1
  207. package/clinkx-workflows/dist/fingerprint.d.ts +25 -7
  208. package/clinkx-workflows/dist/fingerprint.js +33 -10
  209. package/clinkx-workflows/dist/fingerprint.js.map +1 -1
  210. package/clinkx-workflows/dist/index.d.ts +19 -0
  211. package/clinkx-workflows/dist/index.js +68 -1
  212. package/clinkx-workflows/dist/index.js.map +1 -1
  213. package/clinkx-workflows/dist/loader.d.ts +9 -3
  214. package/clinkx-workflows/dist/loader.js +92 -21
  215. package/clinkx-workflows/dist/loader.js.map +1 -1
  216. package/clinkx-workflows/dist/logger.d.ts +1 -1
  217. package/clinkx-workflows/dist/logger.js +17 -3
  218. package/clinkx-workflows/dist/logger.js.map +1 -1
  219. package/clinkx-workflows/dist/monotonic-clock.d.ts +19 -0
  220. package/clinkx-workflows/dist/monotonic-clock.js +22 -0
  221. package/clinkx-workflows/dist/monotonic-clock.js.map +1 -0
  222. package/clinkx-workflows/dist/plan-review/admission.d.ts +160 -0
  223. package/clinkx-workflows/dist/plan-review/admission.js +290 -0
  224. package/clinkx-workflows/dist/plan-review/admission.js.map +1 -0
  225. package/clinkx-workflows/dist/plan-review/context-policy.d.ts +55 -0
  226. package/clinkx-workflows/dist/plan-review/context-policy.js +146 -0
  227. package/clinkx-workflows/dist/plan-review/context-policy.js.map +1 -0
  228. package/clinkx-workflows/dist/plan-review/contract.d.ts +763 -0
  229. package/clinkx-workflows/dist/plan-review/contract.js +289 -0
  230. package/clinkx-workflows/dist/plan-review/contract.js.map +1 -0
  231. package/clinkx-workflows/dist/plan-review/digest.d.ts +68 -0
  232. package/clinkx-workflows/dist/plan-review/digest.js +241 -0
  233. package/clinkx-workflows/dist/plan-review/digest.js.map +1 -0
  234. package/clinkx-workflows/dist/plan-review/discovery.d.ts +45 -0
  235. package/clinkx-workflows/dist/plan-review/discovery.js +36 -0
  236. package/clinkx-workflows/dist/plan-review/discovery.js.map +1 -0
  237. package/clinkx-workflows/dist/plan-review/execution-contract.d.ts +298 -0
  238. package/clinkx-workflows/dist/plan-review/execution-contract.js +194 -0
  239. package/clinkx-workflows/dist/plan-review/execution-contract.js.map +1 -0
  240. package/clinkx-workflows/dist/plan-review/expander.d.ts +48 -0
  241. package/clinkx-workflows/dist/plan-review/expander.js +243 -0
  242. package/clinkx-workflows/dist/plan-review/expander.js.map +1 -0
  243. package/clinkx-workflows/dist/plan-review/projector.d.ts +126 -0
  244. package/clinkx-workflows/dist/plan-review/projector.js +437 -0
  245. package/clinkx-workflows/dist/plan-review/projector.js.map +1 -0
  246. package/clinkx-workflows/dist/plan-review/publication.d.ts +95 -0
  247. package/clinkx-workflows/dist/plan-review/publication.js +182 -0
  248. package/clinkx-workflows/dist/plan-review/publication.js.map +1 -0
  249. package/clinkx-workflows/dist/plan-review/ranking-reducer.d.ts +34 -0
  250. package/clinkx-workflows/dist/plan-review/ranking-reducer.js +139 -0
  251. package/clinkx-workflows/dist/plan-review/ranking-reducer.js.map +1 -0
  252. package/clinkx-workflows/dist/plan-review/resume.d.ts +38 -0
  253. package/clinkx-workflows/dist/plan-review/resume.js +122 -0
  254. package/clinkx-workflows/dist/plan-review/resume.js.map +1 -0
  255. package/clinkx-workflows/dist/plan-review/rubric.d.ts +7 -0
  256. package/clinkx-workflows/dist/plan-review/rubric.js +24 -0
  257. package/clinkx-workflows/dist/plan-review/rubric.js.map +1 -0
  258. package/clinkx-workflows/dist/plan-review/run-state.d.ts +398 -0
  259. package/clinkx-workflows/dist/plan-review/run-state.js +183 -0
  260. package/clinkx-workflows/dist/plan-review/run-state.js.map +1 -0
  261. package/clinkx-workflows/dist/plan-review/runtime-policy.d.ts +74 -0
  262. package/clinkx-workflows/dist/plan-review/runtime-policy.js +186 -0
  263. package/clinkx-workflows/dist/plan-review/runtime-policy.js.map +1 -0
  264. package/clinkx-workflows/dist/plan-review/snapshot.d.ts +81 -0
  265. package/clinkx-workflows/dist/plan-review/snapshot.js +170 -0
  266. package/clinkx-workflows/dist/plan-review/snapshot.js.map +1 -0
  267. package/clinkx-workflows/dist/plan-review/stage-error.d.ts +19 -0
  268. package/clinkx-workflows/dist/plan-review/stage-error.js +20 -0
  269. package/clinkx-workflows/dist/plan-review/stage-error.js.map +1 -0
  270. package/clinkx-workflows/dist/post-processors/index.d.ts +20 -0
  271. package/clinkx-workflows/dist/post-processors/index.js +21 -0
  272. package/clinkx-workflows/dist/post-processors/index.js.map +1 -0
  273. package/clinkx-workflows/dist/prompt-budget.d.ts +7 -0
  274. package/clinkx-workflows/dist/prompt-budget.js +7 -1
  275. package/clinkx-workflows/dist/prompt-budget.js.map +1 -1
  276. package/clinkx-workflows/dist/reducers/index.js +2 -0
  277. package/clinkx-workflows/dist/reducers/index.js.map +1 -1
  278. package/clinkx-workflows/dist/roster-contract.d.ts +889 -0
  279. package/clinkx-workflows/dist/roster-contract.js +180 -0
  280. package/clinkx-workflows/dist/roster-contract.js.map +1 -0
  281. package/clinkx-workflows/dist/rosters.d.ts +14 -0
  282. package/clinkx-workflows/dist/rosters.js +169 -0
  283. package/clinkx-workflows/dist/rosters.js.map +1 -0
  284. package/clinkx-workflows/dist/run-health.d.ts +7 -0
  285. package/clinkx-workflows/dist/run-health.js +25 -0
  286. package/clinkx-workflows/dist/run-health.js.map +1 -0
  287. package/clinkx-workflows/dist/run-lock-heartbeat.d.ts +2 -0
  288. package/clinkx-workflows/dist/run-lock-heartbeat.js +3 -0
  289. package/clinkx-workflows/dist/run-lock-heartbeat.js.map +1 -0
  290. package/clinkx-workflows/dist/run-summary/cards/council-plan-review.d.ts +34 -0
  291. package/clinkx-workflows/dist/run-summary/cards/council-plan-review.js +74 -0
  292. package/clinkx-workflows/dist/run-summary/cards/council-plan-review.js.map +1 -0
  293. package/clinkx-workflows/dist/run-summary/cards/index.js +5 -0
  294. package/clinkx-workflows/dist/run-summary/cards/index.js.map +1 -1
  295. package/clinkx-workflows/dist/run-summary.d.ts +13 -0
  296. package/clinkx-workflows/dist/run-summary.js +29 -1
  297. package/clinkx-workflows/dist/run-summary.js.map +1 -1
  298. package/clinkx-workflows/dist/schema.d.ts +140 -21
  299. package/clinkx-workflows/dist/schema.js +34 -1
  300. package/clinkx-workflows/dist/schema.js.map +1 -1
  301. package/clinkx-workflows/dist/seed-terms.d.ts +30 -0
  302. package/clinkx-workflows/dist/seed-terms.js +176 -0
  303. package/clinkx-workflows/dist/seed-terms.js.map +1 -0
  304. package/clinkx-workflows/dist/server.d.ts +5 -2
  305. package/clinkx-workflows/dist/server.js +84 -52
  306. package/clinkx-workflows/dist/server.js.map +1 -1
  307. package/clinkx-workflows/dist/shutdown.d.ts +29 -18
  308. package/clinkx-workflows/dist/shutdown.js +90 -64
  309. package/clinkx-workflows/dist/shutdown.js.map +1 -1
  310. package/clinkx-workflows/dist/state-schema.d.ts +61 -0
  311. package/clinkx-workflows/dist/state.d.ts +175 -3
  312. package/clinkx-workflows/dist/state.js +1398 -44
  313. package/clinkx-workflows/dist/state.js.map +1 -1
  314. package/clinkx-workflows/dist/stdio-watchdog.d.ts +52 -0
  315. package/clinkx-workflows/dist/stdio-watchdog.js +212 -0
  316. package/clinkx-workflows/dist/stdio-watchdog.js.map +1 -0
  317. package/clinkx-workflows/dist/transport.d.ts +15 -0
  318. package/clinkx-workflows/dist/transport.js +19 -10
  319. package/clinkx-workflows/dist/transport.js.map +1 -1
  320. package/clinkx-workflows/dist/types.d.ts +20 -2
  321. package/clinkx-workflows/dist/validators/council.d.ts +334 -101
  322. package/clinkx-workflows/dist/validators/council.js +52 -13
  323. package/clinkx-workflows/dist/validators/council.js.map +1 -1
  324. package/clinkx-workflows/dist/validators/index.d.ts +1 -0
  325. package/clinkx-workflows/dist/validators/index.js +3 -0
  326. package/clinkx-workflows/dist/validators/index.js.map +1 -1
  327. package/clinkx-workflows/dist/validators/plan-review.d.ts +398 -0
  328. package/clinkx-workflows/dist/validators/plan-review.js +316 -0
  329. package/clinkx-workflows/dist/validators/plan-review.js.map +1 -0
  330. package/clinkx-workflows/dist/workflow-receipt.js +188 -4
  331. package/clinkx-workflows/dist/workflow-receipt.js.map +1 -1
  332. package/clinkx-workflows/dist/workflow-tools.d.ts +118 -3
  333. package/clinkx-workflows/dist/workflow-tools.js +2110 -175
  334. package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
  335. package/clinkx-workflows/dist/workspace-signature.d.ts +16 -0
  336. package/clinkx-workflows/dist/workspace-signature.js +388 -0
  337. package/clinkx-workflows/dist/workspace-signature.js.map +1 -0
  338. package/clinkx-workflows/templates/council/answer-chairman.txt +3 -0
  339. package/clinkx-workflows/templates/council/answer-cross-reviewer.txt +3 -0
  340. package/clinkx-workflows/templates/council/answer-specialist.txt +5 -1
  341. package/clinkx-workflows/templates/council/chairman.txt +3 -0
  342. package/clinkx-workflows/templates/council/code-review-chairman.txt +16 -0
  343. package/clinkx-workflows/templates/council/code-review-cross-reviewer.txt +7 -1
  344. package/clinkx-workflows/templates/council/code-review-reviewer.txt +22 -3
  345. package/clinkx-workflows/templates/council/debug-chairman.txt +3 -0
  346. package/clinkx-workflows/templates/council/debug-cross-reviewer.txt +3 -0
  347. package/clinkx-workflows/templates/council/debug-debugger.txt +5 -1
  348. package/clinkx-workflows/templates/council/discover-analyst.txt +5 -1
  349. package/clinkx-workflows/templates/council/discover-chairman.txt +3 -0
  350. package/clinkx-workflows/templates/council/discover-cross-reviewer.txt +3 -0
  351. package/clinkx-workflows/templates/council/member.txt +5 -1
  352. package/clinkx-workflows/templates/council/plan-review-chairman.txt +71 -0
  353. package/clinkx-workflows/templates/council/plan-review-cross-reviewer.txt +54 -0
  354. package/clinkx-workflows/templates/council/plan-review-reviewer.txt +63 -0
  355. package/clinkx-workflows/templates/council/reviewer.txt +3 -0
  356. package/clinkx-workflows/templates/plan-review/chairman.txt +48 -0
  357. package/clinkx-workflows/templates/plan-review/cross-review.txt +52 -0
  358. package/clinkx-workflows/templates/plan-review/ranking.txt +16 -0
  359. package/clinkx-workflows/templates/plan-review/reviewer.txt +57 -0
  360. package/clinkx-workflows/workflows/council-answer.yaml +100 -8
  361. package/clinkx-workflows/workflows/council-code-review.yaml +106 -8
  362. package/clinkx-workflows/workflows/council-debug.yaml +100 -8
  363. package/clinkx-workflows/workflows/council-default.yaml +104 -8
  364. package/clinkx-workflows/workflows/council-discover.yaml +100 -8
  365. package/clinkx-workflows/workflows/council-plan-review.yaml +253 -0
  366. package/clinkx-workflows/workflows/plan-review-receipts.yaml +230 -0
  367. package/conf/adapters/agy.json +56 -0
  368. package/conf/adapters/claude.json +12 -0
  369. package/conf/adapters/codex-app-server.json +44 -0
  370. package/conf/adapters/codex.json +14 -2
  371. package/conf/adapters/glm.json +24 -3
  372. package/conf/adapters/grok.json +67 -0
  373. package/conf/adapters/hapi/agy.json +59 -0
  374. package/conf/adapters/hapi/claude.json +12 -0
  375. package/conf/adapters/hapi/codex.json +14 -2
  376. package/conf/adapters/hapi/glm.json +25 -4
  377. package/conf/rosters/default-council.json +21 -0
  378. package/dist/activity-journal.d.ts +56 -0
  379. package/dist/activity-journal.js +706 -0
  380. package/dist/activity-journal.js.map +1 -0
  381. package/dist/allowed-roots.d.ts +41 -0
  382. package/dist/allowed-roots.js +125 -3
  383. package/dist/allowed-roots.js.map +1 -1
  384. package/dist/codex/activity-session-log.d.ts +14 -0
  385. package/dist/codex/activity-session-log.js +206 -0
  386. package/dist/codex/activity-session-log.js.map +1 -0
  387. package/dist/codex/agent-tools.d.ts +23 -0
  388. package/dist/codex/agent-tools.js +1306 -0
  389. package/dist/codex/agent-tools.js.map +1 -0
  390. package/dist/codex/app-server-client.d.ts +79 -0
  391. package/dist/codex/app-server-client.js +593 -0
  392. package/dist/codex/app-server-client.js.map +1 -0
  393. package/dist/codex/app-server-registry.d.ts +407 -0
  394. package/dist/codex/app-server-registry.js +1493 -0
  395. package/dist/codex/app-server-registry.js.map +1 -0
  396. package/dist/codex/client-types.d.ts +115 -0
  397. package/dist/codex/client-types.js +2 -0
  398. package/dist/codex/client-types.js.map +1 -0
  399. package/dist/codex/protocol.d.ts +5375 -0
  400. package/dist/codex/protocol.js +614 -0
  401. package/dist/codex/protocol.js.map +1 -0
  402. package/dist/codex/session.d.ts +263 -0
  403. package/dist/codex/session.js +466 -0
  404. package/dist/codex/session.js.map +1 -0
  405. package/dist/config.d.ts +386 -23
  406. package/dist/config.js +184 -15
  407. package/dist/config.js.map +1 -1
  408. package/dist/context-builder/anchors.d.ts +1 -0
  409. package/dist/context-builder/anchors.js +3 -0
  410. package/dist/context-builder/anchors.js.map +1 -1
  411. package/dist/context-builder/bundle.d.ts +48 -2
  412. package/dist/context-builder/bundle.js +388 -2417
  413. package/dist/context-builder/bundle.js.map +1 -1
  414. package/dist/context-builder/codemap.d.ts +5 -0
  415. package/dist/context-builder/codemap.js +387 -13
  416. package/dist/context-builder/codemap.js.map +1 -1
  417. package/dist/context-builder/config.d.ts +1 -0
  418. package/dist/context-builder/config.js +12 -0
  419. package/dist/context-builder/config.js.map +1 -1
  420. package/dist/context-builder/context-run-catalog.d.ts +17 -0
  421. package/dist/context-builder/context-run-catalog.js +99 -0
  422. package/dist/context-builder/context-run-catalog.js.map +1 -0
  423. package/dist/context-builder/delegate-finalizer-effective.d.ts +33 -0
  424. package/dist/context-builder/delegate-finalizer-effective.js +82 -0
  425. package/dist/context-builder/delegate-finalizer-effective.js.map +1 -0
  426. package/dist/context-builder/delegate-packet.d.ts +55 -0
  427. package/dist/context-builder/delegate-packet.js +430 -74
  428. package/dist/context-builder/delegate-packet.js.map +1 -1
  429. package/dist/context-builder/delegate-reconstruction.d.ts +29 -0
  430. package/dist/context-builder/delegate-reconstruction.js +110 -41
  431. package/dist/context-builder/delegate-reconstruction.js.map +1 -1
  432. package/dist/context-builder/delegate-validation.d.ts +41 -1
  433. package/dist/context-builder/delegate-validation.js +237 -48
  434. package/dist/context-builder/delegate-validation.js.map +1 -1
  435. package/dist/context-builder/delegate.d.ts +11 -0
  436. package/dist/context-builder/delegate.js +210 -58
  437. package/dist/context-builder/delegate.js.map +1 -1
  438. package/dist/context-builder/diagnostics.d.ts +11 -2
  439. package/dist/context-builder/diagnostics.js +39 -6
  440. package/dist/context-builder/diagnostics.js.map +1 -1
  441. package/dist/context-builder/discovery-progress.d.ts +25 -0
  442. package/dist/context-builder/discovery-progress.js +64 -0
  443. package/dist/context-builder/discovery-progress.js.map +1 -0
  444. package/dist/context-builder/discovery-watchdog.d.ts +15 -0
  445. package/dist/context-builder/discovery-watchdog.js +39 -0
  446. package/dist/context-builder/discovery-watchdog.js.map +1 -0
  447. package/dist/context-builder/discovery.d.ts +36 -1
  448. package/dist/context-builder/discovery.js +584 -172
  449. package/dist/context-builder/discovery.js.map +1 -1
  450. package/dist/context-builder/external-gaps.d.ts +73 -0
  451. package/dist/context-builder/external-gaps.js +248 -0
  452. package/dist/context-builder/external-gaps.js.map +1 -0
  453. package/dist/context-builder/globs.d.ts +1 -0
  454. package/dist/context-builder/globs.js +25 -10
  455. package/dist/context-builder/globs.js.map +1 -1
  456. package/dist/context-builder/handler.d.ts +67 -2
  457. package/dist/context-builder/handler.js +1810 -2440
  458. package/dist/context-builder/handler.js.map +1 -1
  459. package/dist/context-builder/invocation-sidecar.d.ts +41 -0
  460. package/dist/context-builder/invocation-sidecar.js +189 -0
  461. package/dist/context-builder/invocation-sidecar.js.map +1 -0
  462. package/dist/context-builder/lifecycle-contract.d.ts +424 -0
  463. package/dist/context-builder/lifecycle-contract.js +523 -0
  464. package/dist/context-builder/lifecycle-contract.js.map +1 -0
  465. package/dist/context-builder/lifecycle-journal.d.ts +62 -0
  466. package/dist/context-builder/lifecycle-journal.js +88 -0
  467. package/dist/context-builder/lifecycle-journal.js.map +1 -0
  468. package/dist/context-builder/lifecycle-observer.d.ts +102 -0
  469. package/dist/context-builder/lifecycle-observer.js +258 -0
  470. package/dist/context-builder/lifecycle-observer.js.map +1 -0
  471. package/dist/context-builder/lifecycle-reconcile.d.ts +32 -0
  472. package/dist/context-builder/lifecycle-reconcile.js +191 -0
  473. package/dist/context-builder/lifecycle-reconcile.js.map +1 -0
  474. package/dist/context-builder/lifecycle-recovery.d.ts +2 -0
  475. package/dist/context-builder/lifecycle-recovery.js +14 -0
  476. package/dist/context-builder/lifecycle-recovery.js.map +1 -0
  477. package/dist/context-builder/mutation-lock.d.ts +32 -0
  478. package/dist/context-builder/mutation-lock.js +321 -0
  479. package/dist/context-builder/mutation-lock.js.map +1 -0
  480. package/dist/context-builder/path-signals.js +9 -5
  481. package/dist/context-builder/path-signals.js.map +1 -1
  482. package/dist/context-builder/progress.d.ts +3 -1
  483. package/dist/context-builder/progress.js +23 -0
  484. package/dist/context-builder/progress.js.map +1 -1
  485. package/dist/context-builder/receipt.d.ts +6 -4
  486. package/dist/context-builder/receipt.js +12 -1
  487. package/dist/context-builder/receipt.js.map +1 -1
  488. package/dist/context-builder/refine-handler.d.ts +14 -0
  489. package/dist/context-builder/refine-handler.js +790 -0
  490. package/dist/context-builder/refine-handler.js.map +1 -0
  491. package/dist/context-builder/review-coverage.d.ts +116 -0
  492. package/dist/context-builder/review-coverage.js +544 -0
  493. package/dist/context-builder/review-coverage.js.map +1 -0
  494. package/dist/context-builder/schema.d.ts +315 -2
  495. package/dist/context-builder/schema.js +133 -7
  496. package/dist/context-builder/schema.js.map +1 -1
  497. package/dist/context-builder/secrets.d.ts +59 -0
  498. package/dist/context-builder/secrets.js +2255 -44
  499. package/dist/context-builder/secrets.js.map +1 -1
  500. package/dist/context-builder/selection.d.ts +7 -3
  501. package/dist/context-builder/selection.js +200 -738
  502. package/dist/context-builder/selection.js.map +1 -1
  503. package/dist/context-builder/session-log-identity.d.ts +1 -0
  504. package/dist/context-builder/session-log-identity.js +66 -0
  505. package/dist/context-builder/session-log-identity.js.map +1 -0
  506. package/dist/context-builder/slice-range-math.d.ts +16 -0
  507. package/dist/context-builder/slice-range-math.js +137 -0
  508. package/dist/context-builder/slice-range-math.js.map +1 -0
  509. package/dist/context-builder/status.d.ts +23 -2
  510. package/dist/context-builder/status.js +60 -4
  511. package/dist/context-builder/status.js.map +1 -1
  512. package/dist/context-builder/storage.d.ts +59 -2
  513. package/dist/context-builder/storage.js +500 -168
  514. package/dist/context-builder/storage.js.map +1 -1
  515. package/dist/context-builder/token-estimate.d.ts +13 -2
  516. package/dist/context-builder/token-estimate.js +77 -4
  517. package/dist/context-builder/token-estimate.js.map +1 -1
  518. package/dist/context-builder/versions.d.ts +44 -0
  519. package/dist/context-builder/versions.js +45 -0
  520. package/dist/context-builder/versions.js.map +1 -0
  521. package/dist/context-builder/workflow-runner.d.ts +75 -0
  522. package/dist/context-builder/workflow-runner.js +1241 -0
  523. package/dist/context-builder/workflow-runner.js.map +1 -0
  524. package/dist/context-builder/write-watchdog.d.ts +14 -0
  525. package/dist/context-builder/write-watchdog.js +38 -0
  526. package/dist/context-builder/write-watchdog.js.map +1 -0
  527. package/dist/dashboard-adapter-catalog.d.ts +9 -0
  528. package/dist/dashboard-adapter-catalog.js +53 -0
  529. package/dist/dashboard-adapter-catalog.js.map +1 -0
  530. package/dist/dashboard-cli.d.ts +81 -0
  531. package/dist/dashboard-cli.js +623 -0
  532. package/dist/dashboard-cli.js.map +1 -0
  533. package/dist/dashboard-companion/client.d.ts +37 -0
  534. package/dist/dashboard-companion/client.js +229 -0
  535. package/dist/dashboard-companion/client.js.map +1 -0
  536. package/dist/dashboard-companion/config.d.ts +8 -0
  537. package/dist/dashboard-companion/config.js +52 -0
  538. package/dist/dashboard-companion/config.js.map +1 -0
  539. package/dist/dashboard-companion/http-proxy.d.ts +10 -0
  540. package/dist/dashboard-companion/http-proxy.js +234 -0
  541. package/dist/dashboard-companion/http-proxy.js.map +1 -0
  542. package/dist/dashboard-companion/protocol.d.ts +80 -0
  543. package/dist/dashboard-companion/protocol.js +458 -0
  544. package/dist/dashboard-companion/protocol.js.map +1 -0
  545. package/dist/dashboard-companion/standalone-assets.d.ts +12 -0
  546. package/dist/dashboard-companion/standalone-assets.js +72 -0
  547. package/dist/dashboard-companion/standalone-assets.js.map +1 -0
  548. package/dist/dashboard-companion/standalone-entry.d.ts +1 -0
  549. package/dist/dashboard-companion/standalone-entry.js +17 -0
  550. package/dist/dashboard-companion/standalone-entry.js.map +1 -0
  551. package/dist/dashboard-gateway/config.d.ts +9 -0
  552. package/dist/dashboard-gateway/config.js +44 -0
  553. package/dist/dashboard-gateway/config.js.map +1 -0
  554. package/dist/dashboard-gateway/index.d.ts +12 -0
  555. package/dist/dashboard-gateway/index.js +786 -0
  556. package/dist/dashboard-gateway/index.js.map +1 -0
  557. package/dist/dashboard-gateway/main.d.ts +1 -0
  558. package/dist/dashboard-gateway/main.js +25 -0
  559. package/dist/dashboard-gateway/main.js.map +1 -0
  560. package/dist/dashboard-pairing-token.d.ts +1 -0
  561. package/dist/dashboard-pairing-token.js +5 -0
  562. package/dist/dashboard-pairing-token.js.map +1 -0
  563. package/dist/elaris/client.d.ts +73 -0
  564. package/dist/elaris/client.js +825 -0
  565. package/dist/elaris/client.js.map +1 -0
  566. package/dist/elaris/config.d.ts +18 -0
  567. package/dist/elaris/config.js +75 -0
  568. package/dist/elaris/config.js.map +1 -0
  569. package/dist/elaris/errors.d.ts +41 -0
  570. package/dist/elaris/errors.js +205 -0
  571. package/dist/elaris/errors.js.map +1 -0
  572. package/dist/elaris/github-repo.d.ts +18 -0
  573. package/dist/elaris/github-repo.js +89 -0
  574. package/dist/elaris/github-repo.js.map +1 -0
  575. package/dist/elaris/index.d.ts +10 -0
  576. package/dist/elaris/index.js +11 -0
  577. package/dist/elaris/index.js.map +1 -0
  578. package/dist/elaris/redact.d.ts +89 -0
  579. package/dist/elaris/redact.js +423 -0
  580. package/dist/elaris/redact.js.map +1 -0
  581. package/dist/elaris/run-id.d.ts +5 -0
  582. package/dist/elaris/run-id.js +20 -0
  583. package/dist/elaris/run-id.js.map +1 -0
  584. package/dist/elaris/status.d.ts +45 -0
  585. package/dist/elaris/status.js +122 -0
  586. package/dist/elaris/status.js.map +1 -0
  587. package/dist/elaris/tool-schemas.d.ts +314 -0
  588. package/dist/elaris/tool-schemas.js +208 -0
  589. package/dist/elaris/tool-schemas.js.map +1 -0
  590. package/dist/elaris/tools.d.ts +73 -0
  591. package/dist/elaris/tools.js +1065 -0
  592. package/dist/elaris/tools.js.map +1 -0
  593. package/dist/elaris/types.d.ts +1541 -0
  594. package/dist/elaris/types.js +252 -0
  595. package/dist/elaris/types.js.map +1 -0
  596. package/dist/errors.d.ts +16 -0
  597. package/dist/errors.js +19 -0
  598. package/dist/errors.js.map +1 -1
  599. package/dist/handler.d.ts +4 -0
  600. package/dist/handler.js +15 -2
  601. package/dist/handler.js.map +1 -1
  602. package/dist/index.d.ts +20 -2
  603. package/dist/index.js +154 -6
  604. package/dist/index.js.map +1 -1
  605. package/dist/local-clink-backend.d.ts +3 -0
  606. package/dist/local-clink-backend.js +4 -0
  607. package/dist/local-clink-backend.js.map +1 -1
  608. package/dist/logger.d.ts +1 -1
  609. package/dist/logger.js +18 -3
  610. package/dist/logger.js.map +1 -1
  611. package/dist/package-info.d.ts +2 -0
  612. package/dist/package-info.js +18 -0
  613. package/dist/package-info.js.map +1 -0
  614. package/dist/parsers/agy-stream-json.d.ts +14 -0
  615. package/dist/parsers/agy-stream-json.js +172 -0
  616. package/dist/parsers/agy-stream-json.js.map +1 -0
  617. package/dist/parsers/codex-jsonl.js +48 -3
  618. package/dist/parsers/codex-jsonl.js.map +1 -1
  619. package/dist/parsers/extract.d.ts +10 -1
  620. package/dist/parsers/extract.js +16 -4
  621. package/dist/parsers/extract.js.map +1 -1
  622. package/dist/parsers/observed-invocation.d.ts +20 -0
  623. package/dist/parsers/observed-invocation.js +42 -0
  624. package/dist/parsers/observed-invocation.js.map +1 -0
  625. package/dist/pipeline.d.ts +17 -0
  626. package/dist/pipeline.js +181 -10
  627. package/dist/pipeline.js.map +1 -1
  628. package/dist/progress-report/lock.d.ts +74 -0
  629. package/dist/progress-report/lock.js +343 -0
  630. package/dist/progress-report/lock.js.map +1 -0
  631. package/dist/progress-report/schema.d.ts +808 -0
  632. package/dist/progress-report/schema.js +119 -0
  633. package/dist/progress-report/schema.js.map +1 -0
  634. package/dist/progress-report/store.d.ts +66 -0
  635. package/dist/progress-report/store.js +766 -0
  636. package/dist/progress-report/store.js.map +1 -0
  637. package/dist/progress-report/tools.d.ts +20 -0
  638. package/dist/progress-report/tools.js +141 -0
  639. package/dist/progress-report/tools.js.map +1 -0
  640. package/dist/prompt-mode.d.ts +1 -1
  641. package/dist/prompt-mode.js +7 -2
  642. package/dist/prompt-mode.js.map +1 -1
  643. package/dist/run-dir.d.ts +24 -0
  644. package/dist/run-dir.js +201 -2
  645. package/dist/run-dir.js.map +1 -1
  646. package/dist/runner.d.ts +20 -0
  647. package/dist/runner.js +192 -16
  648. package/dist/runner.js.map +1 -1
  649. package/dist/safety.d.ts +54 -4
  650. package/dist/safety.js +186 -5
  651. package/dist/safety.js.map +1 -1
  652. package/dist/schema.d.ts +15 -7
  653. package/dist/schema.js +20 -0
  654. package/dist/schema.js.map +1 -1
  655. package/dist/server.d.ts +7 -1
  656. package/dist/server.js +451 -23
  657. package/dist/server.js.map +1 -1
  658. package/dist/session-log-stream.d.ts +18 -0
  659. package/dist/session-log-stream.js +566 -0
  660. package/dist/session-log-stream.js.map +1 -0
  661. package/dist/stdio-activity.d.ts +28 -0
  662. package/dist/stdio-activity.js +72 -0
  663. package/dist/stdio-activity.js.map +1 -0
  664. package/package.json +47 -5
  665. package/conf/adapters/gemini.json +0 -44
  666. package/conf/adapters/hapi/gemini.json +0 -47
  667. package/dist/parsers/gemini-json.d.ts +0 -2
  668. package/dist/parsers/gemini-json.js +0 -72
  669. package/dist/parsers/gemini-json.js.map +0 -1
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Deterministic seed-term synthesis (Plan Phase 5, tasks 5-1/5-2/5-3).
3
+ *
4
+ * Pure function: no clock, no RNG, no LLM, no I/O. Identical input always
5
+ * yields a byte-identical array (verified by tests/seed-terms.test.ts).
6
+ *
7
+ * Used to seed context_builder discovery when a workflow runs preflight in
8
+ * `full`/`deterministic` mode but the caller supplied neither focus paths nor
9
+ * search terms (wiring lives in Phase 3 — not here).
10
+ *
11
+ * Algorithm (pinned in plan task 5-3, authoritative):
12
+ * 1. Preserve quoted phrases, then camelCase/snake_case/dotted identifiers as
13
+ * WHOLE terms before any prose splitting (5-2).
14
+ * 2. Lowercase and split the remaining prose; drop the fixed 21-word stop set
15
+ * and tokens shorter than 3 chars (5-3).
16
+ * 3. Dedupe case-insensitively; rank by `score = frequency + lengthBonus`
17
+ * with a first-seen tie-break; cap at 12 terms (5-3).
18
+ */
19
+ /** Fixed stop-word set — exactly the 21 words pinned in plan task 5-3. */
20
+ const STOP_WORDS = new Set([
21
+ "the", "a", "an", "of", "to", "and", "or", "is", "are", "for", "with",
22
+ "on", "in", "this", "that", "please", "add", "fix", "make", "use", "run",
23
+ ]);
24
+ const MIN_TERM_LENGTH = 3;
25
+ const MAX_TERMS = 12;
26
+ export const MAX_SEED_SOURCE_CHARACTERS = 4000;
27
+ export const MAX_CONTEXT_SEARCH_TERMS = 20;
28
+ export const MAX_CONTEXT_SEARCH_TERM_CODE_POINTS = 256;
29
+ export const MAX_CONTEXT_SEARCH_TERMS_UTF8_BYTES = 4_096;
30
+ /** Resolve the workflow context task using the runner's nonblank cb_task rule. */
31
+ export function resolveSeedSource(cbTask, userRequest) {
32
+ return cbTask != null && cbTask.trim() !== "" ? cbTask : userRequest ?? "";
33
+ }
34
+ /** Match the root task schema's trim-before-max character bound. */
35
+ export function seedSourceExceedsLimit(seedSource) {
36
+ return seedSource.trim().length > MAX_SEED_SOURCE_CHARACTERS;
37
+ }
38
+ /** Match the root NonBlankStringSchema + post-parse task bound. */
39
+ export function contextSeedSourceValidationError(seedSource) {
40
+ const normalized = seedSource.trim();
41
+ if (normalized.length === 0) {
42
+ return "Context seed source must be nonblank after trimming";
43
+ }
44
+ if (normalized.length > MAX_SEED_SOURCE_CHARACTERS) {
45
+ return `Context seed source must be at most ${String(MAX_SEED_SOURCE_CHARACTERS)} characters`;
46
+ }
47
+ return undefined;
48
+ }
49
+ export function contextSearchTermsValidationError(searchTerms) {
50
+ if (searchTerms.length > MAX_CONTEXT_SEARCH_TERMS) {
51
+ return `context_builder search_terms must contain at most ${String(MAX_CONTEXT_SEARCH_TERMS)} terms`;
52
+ }
53
+ let aggregateBytes = 0;
54
+ for (const [index, rawTerm] of searchTerms.entries()) {
55
+ const term = rawTerm.trim();
56
+ if (term.length === 0) {
57
+ return `context_builder search_terms[${String(index)}] must be nonblank after trimming`;
58
+ }
59
+ if (countCodePoints(term) > MAX_CONTEXT_SEARCH_TERM_CODE_POINTS) {
60
+ return `context_builder search_terms[${String(index)}] must be <= ${String(MAX_CONTEXT_SEARCH_TERM_CODE_POINTS)} characters`;
61
+ }
62
+ aggregateBytes += Buffer.byteLength(term, "utf8");
63
+ }
64
+ if (aggregateBytes > MAX_CONTEXT_SEARCH_TERMS_UTF8_BYTES) {
65
+ return `context_builder search_terms must total <= ${String(MAX_CONTEXT_SEARCH_TERMS_UTF8_BYTES)} UTF-8 bytes after trimming`;
66
+ }
67
+ return undefined;
68
+ }
69
+ function countCodePoints(value) {
70
+ let count = 0;
71
+ for (const _character of value) {
72
+ count += 1;
73
+ }
74
+ return count;
75
+ }
76
+ function termFitsPublicChannel(term) {
77
+ return countCodePoints(term.trim()) <= MAX_CONTEXT_SEARCH_TERM_CODE_POINTS;
78
+ }
79
+ /**
80
+ * Pinned, pure length bonus in [0, 1]: monotonic non-decreasing in length,
81
+ * saturating at 12 chars. Fixed rational of the term length — no clock/RNG —
82
+ * which keeps scoring (and therefore ordering) byte-deterministic.
83
+ */
84
+ function lengthBonus(term) {
85
+ return Math.min(term.length, 12) / 12;
86
+ }
87
+ /**
88
+ * A token qualifies as a preservable identifier when it contains an internal
89
+ * underscore (snake_case), an internal dot (dotted identifier), or a
90
+ * lower→upper transition (camelCase / PascalCase). "Internal" means an
91
+ * alphanumeric on both sides, so a trailing sentence dot does not qualify.
92
+ */
93
+ function isPreservableIdentifier(token) {
94
+ if (/[A-Za-z0-9]_[A-Za-z0-9]/.test(token))
95
+ return true;
96
+ if (/[A-Za-z0-9]\.[A-Za-z0-9]/.test(token))
97
+ return true;
98
+ if (/[a-z][A-Z]/.test(token))
99
+ return true;
100
+ return false;
101
+ }
102
+ export function synthesizeSeedTerms(text) {
103
+ if (typeof text !== "string" || text.trim() === "") {
104
+ return [];
105
+ }
106
+ // First-seen-ordered accumulation. `order` holds dedup keys in the order they
107
+ // first appear; `firstForm` records the surface form to emit; `freq` counts
108
+ // case-insensitive occurrences for scoring.
109
+ const order = [];
110
+ const firstForm = new Map();
111
+ const freq = new Map();
112
+ const consider = (term) => {
113
+ const key = term.toLowerCase();
114
+ const current = freq.get(key);
115
+ if (current === undefined) {
116
+ freq.set(key, 1);
117
+ firstForm.set(key, term);
118
+ order.push(key);
119
+ }
120
+ else {
121
+ freq.set(key, current + 1);
122
+ }
123
+ };
124
+ // 5-2: preserve quoted phrases as whole terms, then blank them out so the
125
+ // identifier/prose passes never re-split their contents.
126
+ let working = text.replace(/"([^"]+)"|'([^']+)'/g, (_match, dq, sq) => {
127
+ const phrase = (dq ?? sq ?? "").trim();
128
+ if (phrase === "")
129
+ return " ";
130
+ consider(phrase);
131
+ return termFitsPublicChannel(phrase) ? " " : ` ${phrase} `;
132
+ });
133
+ // 5-2: preserve camelCase/snake_case/dotted identifiers as whole terms,
134
+ // blanking only the ones we preserve so plain words flow to the prose pass.
135
+ working = working.replace(/[A-Za-z0-9_.]+/g, (token) => {
136
+ if (isPreservableIdentifier(token)) {
137
+ consider(token);
138
+ return termFitsPublicChannel(token) ? " " : token;
139
+ }
140
+ return token;
141
+ });
142
+ // 5-3: lowercase the remaining prose, split into alphanumeric tokens, drop
143
+ // stop words and sub-3-char tokens.
144
+ const proseTokens = working.toLowerCase().match(/[a-z0-9]+/g) ?? [];
145
+ for (const token of proseTokens) {
146
+ if (token.length < MIN_TERM_LENGTH)
147
+ continue;
148
+ if (STOP_WORDS.has(token))
149
+ continue;
150
+ consider(token);
151
+ }
152
+ // 5-3: rank by score = frequency + lengthBonus, first-seen tie-break, cap 12.
153
+ const ranked = order.map((key, idx) => {
154
+ const term = firstForm.get(key);
155
+ return { term, idx, score: freq.get(key) + lengthBonus(term) };
156
+ });
157
+ ranked.sort((a, b) => (b.score !== a.score ? b.score - a.score : a.idx - b.idx));
158
+ const selected = [];
159
+ let aggregateBytes = 0;
160
+ for (const { term } of ranked) {
161
+ if (selected.length >= MAX_TERMS) {
162
+ break;
163
+ }
164
+ if (!termFitsPublicChannel(term)) {
165
+ continue;
166
+ }
167
+ const termBytes = Buffer.byteLength(term.trim(), "utf8");
168
+ if (aggregateBytes + termBytes > MAX_CONTEXT_SEARCH_TERMS_UTF8_BYTES) {
169
+ continue;
170
+ }
171
+ selected.push(term);
172
+ aggregateBytes += termBytes;
173
+ }
174
+ return selected;
175
+ }
176
+ //# sourceMappingURL=seed-terms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed-terms.js","sourceRoot":"","sources":["../src/seed-terms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,0EAA0E;AAC1E,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC;IAC9C,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM;IACrE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CACzE,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAC/C,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,CAAC;AACvD,MAAM,CAAC,MAAM,mCAAmC,GAAG,KAAK,CAAC;AAEzD,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAC/B,MAA0B,EAC1B,WAA+B;IAE/B,OAAO,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC;AAC7E,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,sBAAsB,CAAC,UAAkB;IACvD,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC,MA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SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;QACzD,IAAI,cAAc,GAAG,SAAS,GAAG,mCAAmC,EAAE,CAAC;YACrE,SAAS;QACX,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,cAAc,IAAI,SAAS,CAAC;IAC9B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -9,7 +9,8 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
9
9
  /**
10
10
  * Create the clinkx-workflows MCP server.
11
11
  *
12
- * Registers three tools: run_workflow, resume_workflow, list_workflows.
12
+ * Registers five tools: run_workflow, resume_workflow, list_workflows,
13
+ * workflow_run_status, cancel_workflow.
13
14
  * Uses ClinkSession (child process) as the backend.
14
15
  * Does NOT connect transport — caller is responsible.
15
16
  *
@@ -18,6 +19,8 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
18
19
  * standalone server schema enum injection and parse-time validation
19
20
  * without requiring the caller to wire discovery manually.
20
21
  */
22
+ export type WorkflowServer = Server;
21
23
  export declare function createWorkflowServer(options?: {
22
24
  availableCliNames?: readonly string[];
23
- }): Server;
25
+ asyncAdmissionCap?: number;
26
+ }): WorkflowServer;
@@ -8,52 +8,45 @@
8
8
  import { readdirSync, readFileSync, statSync } from "node:fs";
9
9
  import { join, extname } from "node:path";
10
10
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
11
- import { getChildConfigPath } from "./config.js";
11
+ import { getChildConfigPath, getRunsDir, hasExplicitWorkspaceRoot, resolveWorkspaceRoot, } from "./config.js";
12
12
  import { logger } from "./logger.js";
13
- import { ClinkSession } from "./transport.js";
13
+ import { reconcileStaleRunDirectories } from "./state.js";
14
+ import { ClinkSession, resolveClinkChildRuntime } from "./transport.js";
14
15
  import { registerWorkflowTools } from "./workflow-tools.js";
15
- // ---------------------------------------------------------------------------
16
- // Adapter name discovery
17
- // ---------------------------------------------------------------------------
18
- /**
19
- * Best-effort adapter name discovery from child config path.
20
- *
21
- * Reads CLINKX_WORKFLOWS_CHILD_CONFIG_PATH — supports both directory
22
- * (scan for .json files) and single-file paths, mirroring the path-
23
- * resolution behavior of AdapterRegistry.loadFromPath.
24
- *
25
- * This performs lightweight structural validation (requires `name` +
26
- * `command` fields) rather than full CliAdapterConfigSchema parsing,
27
- * which lives in the root package and cannot be imported without
28
- * creating a circular dependency. Runtime validation in the child
29
- * process remains the authoritative gate. Returns undefined when no
30
- * config path is set or no valid adapters are found.
31
- */
32
- function discoverChildAdapterNames() {
16
+ import { createRosterLoader, resolveRosterLoaderOptionsFromEnv } from "./rosters.js";
17
+ function discoverChildAdapters() {
33
18
  const configPath = getChildConfigPath();
34
19
  if (configPath == null)
35
20
  return undefined;
36
21
  try {
37
22
  const stat = statSync(configPath);
38
- const names = [];
23
+ const cliNames = [];
24
+ const planReviewCliNames = [];
25
+ const record = (entry) => {
26
+ if (entry == null)
27
+ return;
28
+ if (!cliNames.includes(entry.name))
29
+ cliNames.push(entry.name);
30
+ if (entry.hasJsonRole && !planReviewCliNames.includes(entry.name)) {
31
+ planReviewCliNames.push(entry.name);
32
+ }
33
+ };
39
34
  if (stat.isFile()) {
40
35
  // Single-file config path
41
- const name = extractAdapterName(configPath);
42
- if (name != null)
43
- names.push(name);
36
+ record(extractAdapter(configPath));
44
37
  }
45
38
  else if (stat.isDirectory()) {
46
39
  // Directory config path — scan for .json files
47
- const files = readdirSync(configPath).filter((f) => extname(f) === ".json");
40
+ const files = readdirSync(configPath)
41
+ .filter((f) => extname(f) === ".json")
42
+ .sort();
48
43
  for (const file of files) {
49
- const name = extractAdapterName(join(configPath, file));
50
- if (name != null)
51
- names.push(name);
44
+ record(extractAdapter(join(configPath, file)));
52
45
  }
53
46
  }
54
- if (names.length > 0) {
55
- logger.debug({ names, configPath }, "discovered child adapter names for standalone server");
56
- return names;
47
+ if (cliNames.length > 0) {
48
+ logger.debug({ names: cliNames, planReviewNames: planReviewCliNames, configPath }, "discovered child adapter names for standalone server");
49
+ return { cliNames, planReviewCliNames };
57
50
  }
58
51
  }
59
52
  catch (err) {
@@ -62,19 +55,35 @@ function discoverChildAdapterNames() {
62
55
  return undefined;
63
56
  }
64
57
  /**
65
- * Extract the adapter name from a config JSON file.
58
+ * Extract adapter name (+ plan-review role eligibility) from a config JSON file.
66
59
  *
67
60
  * Requires both `name` (string) and `command` (string) fields to be
68
61
  * present — the two mandatory fields in any valid adapter config.
69
62
  * Skips files that don't meet this minimum bar.
63
+ *
64
+ * `backend: "app_server"` adapters are EXCLUDED. They are driven exclusively by
65
+ * the async `clink_agent_run` / `clink_agent_manage` tools; the synchronous
66
+ * pipeline every workflow seat runs through rejects them with `-32602`. Naming
67
+ * one in a workflow enum would advertise a seat that can only fail at dispatch.
68
+ * The root server filters these already; this is the standalone path, which the
69
+ * removal of the `eligible:false` bit left unguarded.
70
+ *
71
+ * Plan-review eligibility is presence of a `roles` object with a `"json"` key
72
+ * (raw JSON field read only — no AdapterRegistry import, no dependency cycle).
70
73
  */
71
- function extractAdapterName(filePath) {
74
+ function extractAdapter(filePath) {
72
75
  try {
73
76
  const raw = readFileSync(filePath, "utf-8");
74
77
  const parsed = JSON.parse(raw);
75
78
  if (typeof parsed["name"] === "string" && parsed["name"] !== "" &&
76
- typeof parsed["command"] === "string" && parsed["command"] !== "") {
77
- return parsed["name"];
79
+ typeof parsed["command"] === "string" && parsed["command"] !== "" &&
80
+ parsed["backend"] !== "app_server") {
81
+ const roles = parsed["roles"];
82
+ const hasJsonRole = roles != null &&
83
+ typeof roles === "object" &&
84
+ !Array.isArray(roles) &&
85
+ Object.prototype.hasOwnProperty.call(roles, "json");
86
+ return { name: parsed["name"], hasJsonRole };
78
87
  }
79
88
  }
80
89
  catch {
@@ -82,21 +91,6 @@ function extractAdapterName(filePath) {
82
91
  }
83
92
  return undefined;
84
93
  }
85
- // ---------------------------------------------------------------------------
86
- // Server factory
87
- // ---------------------------------------------------------------------------
88
- /**
89
- * Create the clinkx-workflows MCP server.
90
- *
91
- * Registers three tools: run_workflow, resume_workflow, list_workflows.
92
- * Uses ClinkSession (child process) as the backend.
93
- * Does NOT connect transport — caller is responsible.
94
- *
95
- * When `availableCliNames` is not explicitly provided, attempts to
96
- * discover adapter names from the child config path. This gives the
97
- * standalone server schema enum injection and parse-time validation
98
- * without requiring the caller to wire discovery manually.
99
- */
100
94
  export function createWorkflowServer(options) {
101
95
  const server = new Server({ name: "clinkx-workflows", version: "0.1.0" }, {
102
96
  capabilities: { tools: {} },
@@ -104,15 +98,53 @@ export function createWorkflowServer(options) {
104
98
  "Use run_workflow to start a new workflow, resume_workflow to continue a failed run, " +
105
99
  "or list_workflows to see available workflows.",
106
100
  });
101
+ // `resolveWorkspaceRoot()` silently falls back to process.cwd(), and an MCP
102
+ // server's cwd is chosen by the client — so the same request can pass or fail
103
+ // purely on where the client happened to spawn us. Surface the implicit root
104
+ // instead of leaving it invisible (config.ts cannot log: logger imports it).
105
+ if (!hasExplicitWorkspaceRoot()) {
106
+ logger.warn({
107
+ env_var: "CLINKX_WORKFLOWS_WORKSPACE_ROOT",
108
+ workspace_root: resolveWorkspaceRoot(),
109
+ cwd: process.cwd(),
110
+ }, "CLINKX_WORKFLOWS_WORKSPACE_ROOT is not set; defaulting the workflows workspace root to process.cwd(). " +
111
+ "This root governs plan_file containment and the workflow child process cwd, so workflow behavior " +
112
+ "depends on the cwd the MCP client spawned this server with. Set CLINKX_WORKFLOWS_WORKSPACE_ROOT explicitly.");
113
+ }
114
+ // One-time startup reconcile of runs frozen as running/pending with no live
115
+ // worker (fire-and-forget: bounded, idempotent, never blocks startup).
116
+ try {
117
+ void reconcileStaleRunDirectories(getRunsDir()).catch((err) => {
118
+ logger.warn({ err: err instanceof Error ? err.message : String(err) }, "startup stale workflow run reconcile failed");
119
+ });
120
+ }
121
+ catch (err) {
122
+ logger.warn({ err: err instanceof Error ? err.message : String(err) }, "startup stale workflow run reconcile could not be scheduled");
123
+ }
124
+ const childRuntime = resolveClinkChildRuntime();
107
125
  // Normalize empty arrays to undefined — an empty list would suppress schema
108
126
  // hints while still enabling validation (rejecting all adapter names).
109
127
  const explicit = options?.availableCliNames;
128
+ const discovered = explicit != null && explicit.length > 0
129
+ ? undefined
130
+ : discoverChildAdapters();
110
131
  const cliNames = (explicit != null && explicit.length > 0)
111
132
  ? explicit
112
- : discoverChildAdapterNames();
133
+ : discovered?.cliNames;
134
+ // When the caller supplies availableCliNames explicitly, they own filtering
135
+ // (or accept the availableCliNames fallback in workflow-tools). Auto-discovery
136
+ // always supplies the roles.json-filtered plan-review set.
137
+ const planReviewCliNames = discovered?.planReviewCliNames;
113
138
  registerWorkflowTools(server, {
114
- createBackend: (runId) => new ClinkSession({ runId }),
139
+ createBackend: (runId) => new ClinkSession({ runId, runtime: childRuntime }),
115
140
  ...(cliNames != null ? { availableCliNames: cliNames } : {}),
141
+ ...(planReviewCliNames != null
142
+ ? { planReviewAvailableCliNames: planReviewCliNames }
143
+ : {}),
144
+ ...(options?.asyncAdmissionCap != null
145
+ ? { asyncAdmissionCap: options.asyncAdmissionCap }
146
+ : {}),
147
+ rosterLoader: createRosterLoader(resolveRosterLoaderOptionsFromEnv()),
116
148
  });
117
149
  return server;
118
150
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,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I,IAAI,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACxD,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC;IACzB,4EAA4E;IAC5E,+EAA+E;IAC/E,2DAA2D;IAC3D,MAAM,kBAAkB,GAAG,UAAU,EAAE,kBAAkB,CAAC;IAE1D,qBAAqB,CAAC,MAAM,EAAE;QAC5B,aAAa,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QACpF,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,GAAG,CAAC,kBAAkB,IAAI,IAAI;YAC5B,CAAC,CAAC,EAAE,2BAA2B,EAAE,kBAAkB,EAAE;YACrD,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,OAAO,EAAE,iBAAiB,IAAI,IAAI;YACpC,CAAC,CAAC,EAAE,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE;YAClD,CAAC,CAAC,EAAE,CAAC;QACP,YAAY,EAAE,kBAAkB,CAAC,iCAAiC,EAAE,CAAC;KACtE,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -11,39 +11,50 @@
11
11
  */
12
12
  import type { ClinkBackend } from "./backend.js";
13
13
  type StatePersister = () => Promise<void>;
14
+ /** Opaque handle returned by register(); identifies a single run's entry. */
15
+ export type ShutdownHandle = number;
14
16
  /**
15
17
  * Manages graceful shutdown across signal handlers and MCP cancellation.
18
+ *
19
+ * Keyed registry: each run registers its own entry so concurrent runs (cap > 1)
20
+ * never clobber each other. Shutdown/cancel iterate over ALL registered entries.
16
21
  */
17
22
  export declare class ShutdownCoordinator {
18
- private state;
23
+ private readonly entries;
24
+ private nextHandle;
19
25
  private shuttingDown;
26
+ private shutdownDrain;
27
+ private shutdownSignal;
20
28
  /**
21
- * Register the active session and abort controller for this run.
22
- * Call at the start of each workflow run.
23
- */
24
- register(session: ClinkBackend, controller: AbortController, persistState: StatePersister): void;
25
- /**
26
- * Unregister the current run (on normal completion).
29
+ * Synchronously latch shutdown admission and abort every entry currently
30
+ * owned by the coordinator. The asynchronous persistence/termination drain
31
+ * is deliberately separate so no awaited cleanup for one entry can let
32
+ * another registered run continue dispatching work.
27
33
  */
28
- unregister(): void;
34
+ beginShutdown(signal: string): void;
35
+ /** Internal admission guard used by workflow-tools before acquiring a slot. */
36
+ isShuttingDown(): boolean;
29
37
  /**
30
- * Get the AbortSignal for the current run.
31
- * Use this to propagate cancellation to in-flight calls.
38
+ * Register a run's session and abort controller. Returns an opaque handle
39
+ * to be passed to unregister(). Each call adds a new entry; existing entries
40
+ * are never clobbered. Setup may supply a lazy terminate-only session and a
41
+ * completion fence covering its entire cleanup. Such runs own persistence
42
+ * themselves and pass a no-op persistState callback.
32
43
  */
33
- get signal(): AbortSignal | undefined;
44
+ register(session: Pick<ClinkBackend, "terminate">, controller: AbortController, persistState: StatePersister, completion?: Promise<void>): ShutdownHandle;
34
45
  /**
35
- * Cancel the current run (e.g., from MCP notifications/cancelled).
36
- * Aborts in-flight calls, persists state, terminates child.
37
- * Does NOT call process.exit — caller decides response behavior.
46
+ * Unregister a single run (on normal completion). Deletes only this handle's
47
+ * entry; other registered runs remain.
38
48
  */
39
- cancelRun(): Promise<void>;
49
+ unregister(handle: ShutdownHandle): void;
40
50
  /**
41
51
  * Handle process shutdown.
42
- * Cancel, persist, and terminate. The entrypoint owns process.exit.
52
+ * Cancel, persist, and terminate all registered runs. The entrypoint owns
53
+ * process.exit.
43
54
  */
44
55
  shutdown(signal: string): Promise<void>;
45
- private safePersistState;
46
- private safeTerminateSession;
56
+ /** Abort, persist, and terminate every registered entry (best-effort). */
57
+ private handleAll;
47
58
  }
48
59
  /** Singleton shutdown coordinator. */
49
60
  export declare const shutdownCoordinator: ShutdownCoordinator;