clinkx 0.2.3 → 1.0.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 (574) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +10 -0
  3. package/README.md +113 -18
  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/citation-check.d.ts +40 -0
  12. package/clinkx-workflows/dist/citation-check.js +348 -0
  13. package/clinkx-workflows/dist/citation-check.js.map +1 -0
  14. package/clinkx-workflows/dist/clink-client.d.ts +2 -1
  15. package/clinkx-workflows/dist/clink-client.js +17 -4
  16. package/clinkx-workflows/dist/clink-client.js.map +1 -1
  17. package/clinkx-workflows/dist/config.d.ts +145 -16
  18. package/clinkx-workflows/dist/config.js +384 -26
  19. package/clinkx-workflows/dist/config.js.map +1 -1
  20. package/clinkx-workflows/dist/contained-file.d.ts +172 -0
  21. package/clinkx-workflows/dist/contained-file.js +483 -0
  22. package/clinkx-workflows/dist/contained-file.js.map +1 -0
  23. package/clinkx-workflows/dist/context-builder-lifecycle-contract.d.ts +416 -0
  24. package/clinkx-workflows/dist/context-builder-lifecycle-contract.js +328 -0
  25. package/clinkx-workflows/dist/context-builder-lifecycle-contract.js.map +1 -0
  26. package/clinkx-workflows/dist/context-builder-lifecycle-router.d.ts +24 -0
  27. package/clinkx-workflows/dist/context-builder-lifecycle-router.js +39 -0
  28. package/clinkx-workflows/dist/context-builder-lifecycle-router.js.map +1 -0
  29. package/clinkx-workflows/dist/context-cache-key.d.ts +53 -0
  30. package/clinkx-workflows/dist/context-cache-key.js +91 -0
  31. package/clinkx-workflows/dist/context-cache-key.js.map +1 -0
  32. package/clinkx-workflows/dist/context-mode-resolver.d.ts +27 -0
  33. package/clinkx-workflows/dist/context-mode-resolver.js +126 -0
  34. package/clinkx-workflows/dist/context-mode-resolver.js.map +1 -0
  35. package/clinkx-workflows/dist/context-preflight.d.ts +184 -0
  36. package/clinkx-workflows/dist/context-preflight.js +91 -0
  37. package/clinkx-workflows/dist/context-preflight.js.map +1 -0
  38. package/clinkx-workflows/dist/council-expander.d.ts +1 -1
  39. package/clinkx-workflows/dist/council-expander.js +2 -1
  40. package/clinkx-workflows/dist/council-expander.js.map +1 -1
  41. package/clinkx-workflows/dist/dashboard/activity-contract.d.ts +165 -0
  42. package/clinkx-workflows/dist/dashboard/activity-contract.js +105 -0
  43. package/clinkx-workflows/dist/dashboard/activity-contract.js.map +1 -0
  44. package/clinkx-workflows/dist/dashboard/activity-lease.d.ts +25 -0
  45. package/clinkx-workflows/dist/dashboard/activity-lease.js +34 -0
  46. package/clinkx-workflows/dist/dashboard/activity-lease.js.map +1 -0
  47. package/clinkx-workflows/dist/dashboard/activity-reader.d.ts +86 -0
  48. package/clinkx-workflows/dist/dashboard/activity-reader.js +480 -0
  49. package/clinkx-workflows/dist/dashboard/activity-reader.js.map +1 -0
  50. package/clinkx-workflows/dist/dashboard/api-routes.d.ts +36 -0
  51. package/clinkx-workflows/dist/dashboard/api-routes.js +1047 -0
  52. package/clinkx-workflows/dist/dashboard/api-routes.js.map +1 -0
  53. package/clinkx-workflows/dist/dashboard/artifact-index.d.ts +37 -0
  54. package/clinkx-workflows/dist/dashboard/artifact-index.js +145 -0
  55. package/clinkx-workflows/dist/dashboard/artifact-index.js.map +1 -0
  56. package/clinkx-workflows/dist/dashboard/auth/challenge-store.d.ts +31 -0
  57. package/clinkx-workflows/dist/dashboard/auth/challenge-store.js +65 -0
  58. package/clinkx-workflows/dist/dashboard/auth/challenge-store.js.map +1 -0
  59. package/clinkx-workflows/dist/dashboard/auth/controller.d.ts +26 -0
  60. package/clinkx-workflows/dist/dashboard/auth/controller.js +596 -0
  61. package/clinkx-workflows/dist/dashboard/auth/controller.js.map +1 -0
  62. package/clinkx-workflows/dist/dashboard/auth/credential-store.d.ts +60 -0
  63. package/clinkx-workflows/dist/dashboard/auth/credential-store.js +776 -0
  64. package/clinkx-workflows/dist/dashboard/auth/credential-store.js.map +1 -0
  65. package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.d.ts +9 -0
  66. package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.js +44 -0
  67. package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.js.map +1 -0
  68. package/clinkx-workflows/dist/dashboard/auth/session-store.d.ts +17 -0
  69. package/clinkx-workflows/dist/dashboard/auth/session-store.js +77 -0
  70. package/clinkx-workflows/dist/dashboard/auth/session-store.js.map +1 -0
  71. package/clinkx-workflows/dist/dashboard/auth/webauthn-service.d.ts +25 -0
  72. package/clinkx-workflows/dist/dashboard/auth/webauthn-service.js +71 -0
  73. package/clinkx-workflows/dist/dashboard/auth/webauthn-service.js.map +1 -0
  74. package/clinkx-workflows/dist/dashboard/context-run-liveness.d.ts +37 -0
  75. package/clinkx-workflows/dist/dashboard/context-run-liveness.js +49 -0
  76. package/clinkx-workflows/dist/dashboard/context-run-liveness.js.map +1 -0
  77. package/clinkx-workflows/dist/dashboard/context-run-reader.d.ts +222 -0
  78. package/clinkx-workflows/dist/dashboard/context-run-reader.js +1178 -0
  79. package/clinkx-workflows/dist/dashboard/context-run-reader.js.map +1 -0
  80. package/clinkx-workflows/dist/dashboard/contracts.d.ts +8936 -0
  81. package/clinkx-workflows/dist/dashboard/contracts.js +1157 -0
  82. package/clinkx-workflows/dist/dashboard/contracts.js.map +1 -0
  83. package/clinkx-workflows/dist/dashboard/generation.d.ts +14 -0
  84. package/clinkx-workflows/dist/dashboard/generation.js +41 -0
  85. package/clinkx-workflows/dist/dashboard/generation.js.map +1 -0
  86. package/clinkx-workflows/dist/dashboard/index.d.ts +28 -0
  87. package/clinkx-workflows/dist/dashboard/index.js +16 -0
  88. package/clinkx-workflows/dist/dashboard/index.js.map +1 -0
  89. package/clinkx-workflows/dist/dashboard/lazy-content.d.ts +101 -0
  90. package/clinkx-workflows/dist/dashboard/lazy-content.js +748 -0
  91. package/clinkx-workflows/dist/dashboard/lazy-content.js.map +1 -0
  92. package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +303 -0
  93. package/clinkx-workflows/dist/dashboard/progress-report-contract.js +221 -0
  94. package/clinkx-workflows/dist/dashboard/progress-report-contract.js.map +1 -0
  95. package/clinkx-workflows/dist/dashboard/progress-report-reader.d.ts +50 -0
  96. package/clinkx-workflows/dist/dashboard/progress-report-reader.js +581 -0
  97. package/clinkx-workflows/dist/dashboard/progress-report-reader.js.map +1 -0
  98. package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.d.ts +89 -0
  99. package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.js +71 -0
  100. package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.js.map +1 -0
  101. package/clinkx-workflows/dist/dashboard/progress-report-status-store.d.ts +28 -0
  102. package/clinkx-workflows/dist/dashboard/progress-report-status-store.js +110 -0
  103. package/clinkx-workflows/dist/dashboard/progress-report-status-store.js.map +1 -0
  104. package/clinkx-workflows/dist/dashboard/read-model.d.ts +86 -0
  105. package/clinkx-workflows/dist/dashboard/read-model.js +440 -0
  106. package/clinkx-workflows/dist/dashboard/read-model.js.map +1 -0
  107. package/clinkx-workflows/dist/dashboard/request-admission.d.ts +31 -0
  108. package/clinkx-workflows/dist/dashboard/request-admission.js +126 -0
  109. package/clinkx-workflows/dist/dashboard/request-admission.js.map +1 -0
  110. package/clinkx-workflows/dist/dashboard/scanner.d.ts +75 -0
  111. package/clinkx-workflows/dist/dashboard/scanner.js +1110 -0
  112. package/clinkx-workflows/dist/dashboard/scanner.js.map +1 -0
  113. package/clinkx-workflows/dist/dashboard/server-factory.d.ts +50 -0
  114. package/clinkx-workflows/dist/dashboard/server-factory.js +431 -0
  115. package/clinkx-workflows/dist/dashboard/server-factory.js.map +1 -0
  116. package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +2611 -0
  117. package/clinkx-workflows/dist/dashboard/session-log-contract.js +480 -0
  118. package/clinkx-workflows/dist/dashboard/session-log-contract.js.map +1 -0
  119. package/clinkx-workflows/dist/dashboard/session-log-identity.d.ts +21 -0
  120. package/clinkx-workflows/dist/dashboard/session-log-identity.js +101 -0
  121. package/clinkx-workflows/dist/dashboard/session-log-identity.js.map +1 -0
  122. package/clinkx-workflows/dist/dashboard/session-log-journal.d.ts +43 -0
  123. package/clinkx-workflows/dist/dashboard/session-log-journal.js +522 -0
  124. package/clinkx-workflows/dist/dashboard/session-log-journal.js.map +1 -0
  125. package/clinkx-workflows/dist/dashboard/session-log-reader.d.ts +61 -0
  126. package/clinkx-workflows/dist/dashboard/session-log-reader.js +378 -0
  127. package/clinkx-workflows/dist/dashboard/session-log-reader.js.map +1 -0
  128. package/clinkx-workflows/dist/dashboard/session-log-redaction.d.ts +6 -0
  129. package/clinkx-workflows/dist/dashboard/session-log-redaction.js +367 -0
  130. package/clinkx-workflows/dist/dashboard/session-log-redaction.js.map +1 -0
  131. package/clinkx-workflows/dist/dashboard/session-log-retention.d.ts +23 -0
  132. package/clinkx-workflows/dist/dashboard/session-log-retention.js +212 -0
  133. package/clinkx-workflows/dist/dashboard/session-log-retention.js.map +1 -0
  134. package/clinkx-workflows/dist/dashboard/static-responses.d.ts +10 -0
  135. package/clinkx-workflows/dist/dashboard/static-responses.js +94 -0
  136. package/clinkx-workflows/dist/dashboard/static-responses.js.map +1 -0
  137. package/clinkx-workflows/dist/dashboard/worker-lock-observer.d.ts +28 -0
  138. package/clinkx-workflows/dist/dashboard/worker-lock-observer.js +241 -0
  139. package/clinkx-workflows/dist/dashboard/worker-lock-observer.js.map +1 -0
  140. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  141. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  142. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  143. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  144. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  145. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
  146. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  147. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
  148. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
  149. package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  150. package/clinkx-workflows/dist/dashboard-ui/assets/index-DOkMXTfB.js +25 -0
  151. package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  152. package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  153. package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
  154. package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
  155. package/clinkx-workflows/dist/dashboard-ui/assets/style-ChJsn0KD.css +1 -0
  156. package/clinkx-workflows/dist/dashboard-ui/contracts/council-plan-review-input-v1.json +158 -0
  157. package/clinkx-workflows/dist/dashboard-ui/index.html +15 -0
  158. package/clinkx-workflows/dist/dashboard-ui/licenses/IBM-Plex-Mono-OFL.txt +93 -0
  159. package/clinkx-workflows/dist/dashboard-ui/licenses/IBM-Plex-Sans-OFL.txt +93 -0
  160. package/clinkx-workflows/dist/dashboard-ui/licenses/JetBrains-Mono-OFL.txt +93 -0
  161. package/clinkx-workflows/dist/dashboard-ui/licenses/NOTICE.md +32 -0
  162. package/clinkx-workflows/dist/dashboard-ui/theme-init.js +8 -0
  163. package/clinkx-workflows/dist/definition-normalizer.d.ts +19 -0
  164. package/clinkx-workflows/dist/definition-normalizer.js.map +1 -1
  165. package/clinkx-workflows/dist/delegate-validate.d.ts +78 -0
  166. package/clinkx-workflows/dist/delegate-validate.js +97 -0
  167. package/clinkx-workflows/dist/delegate-validate.js.map +1 -0
  168. package/clinkx-workflows/dist/engine.d.ts +141 -0
  169. package/clinkx-workflows/dist/engine.js +882 -28
  170. package/clinkx-workflows/dist/engine.js.map +1 -1
  171. package/clinkx-workflows/dist/errors.d.ts +2 -0
  172. package/clinkx-workflows/dist/errors.js.map +1 -1
  173. package/clinkx-workflows/dist/fingerprint.d.ts +1 -1
  174. package/clinkx-workflows/dist/fingerprint.js +1 -1
  175. package/clinkx-workflows/dist/index.d.ts +19 -0
  176. package/clinkx-workflows/dist/index.js +15 -0
  177. package/clinkx-workflows/dist/index.js.map +1 -1
  178. package/clinkx-workflows/dist/loader.d.ts +9 -3
  179. package/clinkx-workflows/dist/loader.js +92 -21
  180. package/clinkx-workflows/dist/loader.js.map +1 -1
  181. package/clinkx-workflows/dist/plan-review/admission.d.ts +160 -0
  182. package/clinkx-workflows/dist/plan-review/admission.js +290 -0
  183. package/clinkx-workflows/dist/plan-review/admission.js.map +1 -0
  184. package/clinkx-workflows/dist/plan-review/context-policy.d.ts +55 -0
  185. package/clinkx-workflows/dist/plan-review/context-policy.js +146 -0
  186. package/clinkx-workflows/dist/plan-review/context-policy.js.map +1 -0
  187. package/clinkx-workflows/dist/plan-review/contract.d.ts +763 -0
  188. package/clinkx-workflows/dist/plan-review/contract.js +289 -0
  189. package/clinkx-workflows/dist/plan-review/contract.js.map +1 -0
  190. package/clinkx-workflows/dist/plan-review/digest.d.ts +68 -0
  191. package/clinkx-workflows/dist/plan-review/digest.js +241 -0
  192. package/clinkx-workflows/dist/plan-review/digest.js.map +1 -0
  193. package/clinkx-workflows/dist/plan-review/discovery.d.ts +45 -0
  194. package/clinkx-workflows/dist/plan-review/discovery.js +36 -0
  195. package/clinkx-workflows/dist/plan-review/discovery.js.map +1 -0
  196. package/clinkx-workflows/dist/plan-review/execution-contract.d.ts +298 -0
  197. package/clinkx-workflows/dist/plan-review/execution-contract.js +194 -0
  198. package/clinkx-workflows/dist/plan-review/execution-contract.js.map +1 -0
  199. package/clinkx-workflows/dist/plan-review/expander.d.ts +48 -0
  200. package/clinkx-workflows/dist/plan-review/expander.js +243 -0
  201. package/clinkx-workflows/dist/plan-review/expander.js.map +1 -0
  202. package/clinkx-workflows/dist/plan-review/projector.d.ts +126 -0
  203. package/clinkx-workflows/dist/plan-review/projector.js +437 -0
  204. package/clinkx-workflows/dist/plan-review/projector.js.map +1 -0
  205. package/clinkx-workflows/dist/plan-review/publication.d.ts +95 -0
  206. package/clinkx-workflows/dist/plan-review/publication.js +182 -0
  207. package/clinkx-workflows/dist/plan-review/publication.js.map +1 -0
  208. package/clinkx-workflows/dist/plan-review/ranking-reducer.d.ts +34 -0
  209. package/clinkx-workflows/dist/plan-review/ranking-reducer.js +139 -0
  210. package/clinkx-workflows/dist/plan-review/ranking-reducer.js.map +1 -0
  211. package/clinkx-workflows/dist/plan-review/resume.d.ts +38 -0
  212. package/clinkx-workflows/dist/plan-review/resume.js +122 -0
  213. package/clinkx-workflows/dist/plan-review/resume.js.map +1 -0
  214. package/clinkx-workflows/dist/plan-review/rubric.d.ts +7 -0
  215. package/clinkx-workflows/dist/plan-review/rubric.js +24 -0
  216. package/clinkx-workflows/dist/plan-review/rubric.js.map +1 -0
  217. package/clinkx-workflows/dist/plan-review/run-state.d.ts +398 -0
  218. package/clinkx-workflows/dist/plan-review/run-state.js +183 -0
  219. package/clinkx-workflows/dist/plan-review/run-state.js.map +1 -0
  220. package/clinkx-workflows/dist/plan-review/runtime-policy.d.ts +74 -0
  221. package/clinkx-workflows/dist/plan-review/runtime-policy.js +186 -0
  222. package/clinkx-workflows/dist/plan-review/runtime-policy.js.map +1 -0
  223. package/clinkx-workflows/dist/plan-review/snapshot.d.ts +81 -0
  224. package/clinkx-workflows/dist/plan-review/snapshot.js +170 -0
  225. package/clinkx-workflows/dist/plan-review/snapshot.js.map +1 -0
  226. package/clinkx-workflows/dist/plan-review/stage-error.d.ts +19 -0
  227. package/clinkx-workflows/dist/plan-review/stage-error.js +20 -0
  228. package/clinkx-workflows/dist/plan-review/stage-error.js.map +1 -0
  229. package/clinkx-workflows/dist/post-processors/index.d.ts +20 -0
  230. package/clinkx-workflows/dist/post-processors/index.js +21 -0
  231. package/clinkx-workflows/dist/post-processors/index.js.map +1 -0
  232. package/clinkx-workflows/dist/prompt-budget.d.ts +7 -0
  233. package/clinkx-workflows/dist/prompt-budget.js +7 -1
  234. package/clinkx-workflows/dist/prompt-budget.js.map +1 -1
  235. package/clinkx-workflows/dist/reducers/index.js +2 -0
  236. package/clinkx-workflows/dist/reducers/index.js.map +1 -1
  237. package/clinkx-workflows/dist/run-lock-heartbeat.d.ts +2 -0
  238. package/clinkx-workflows/dist/run-lock-heartbeat.js +3 -0
  239. package/clinkx-workflows/dist/run-lock-heartbeat.js.map +1 -0
  240. package/clinkx-workflows/dist/run-summary/cards/council-plan-review.d.ts +34 -0
  241. package/clinkx-workflows/dist/run-summary/cards/council-plan-review.js +74 -0
  242. package/clinkx-workflows/dist/run-summary/cards/council-plan-review.js.map +1 -0
  243. package/clinkx-workflows/dist/run-summary/cards/index.js +5 -0
  244. package/clinkx-workflows/dist/run-summary/cards/index.js.map +1 -1
  245. package/clinkx-workflows/dist/run-summary.d.ts +13 -0
  246. package/clinkx-workflows/dist/run-summary.js +29 -1
  247. package/clinkx-workflows/dist/run-summary.js.map +1 -1
  248. package/clinkx-workflows/dist/schema.d.ts +76 -21
  249. package/clinkx-workflows/dist/schema.js +10 -1
  250. package/clinkx-workflows/dist/schema.js.map +1 -1
  251. package/clinkx-workflows/dist/seed-terms.d.ts +30 -0
  252. package/clinkx-workflows/dist/seed-terms.js +176 -0
  253. package/clinkx-workflows/dist/seed-terms.js.map +1 -0
  254. package/clinkx-workflows/dist/server.d.ts +5 -2
  255. package/clinkx-workflows/dist/server.js +82 -52
  256. package/clinkx-workflows/dist/server.js.map +1 -1
  257. package/clinkx-workflows/dist/shutdown.d.ts +18 -20
  258. package/clinkx-workflows/dist/shutdown.js +43 -61
  259. package/clinkx-workflows/dist/shutdown.js.map +1 -1
  260. package/clinkx-workflows/dist/state-schema.d.ts +38 -0
  261. package/clinkx-workflows/dist/state.d.ts +170 -3
  262. package/clinkx-workflows/dist/state.js +1275 -28
  263. package/clinkx-workflows/dist/state.js.map +1 -1
  264. package/clinkx-workflows/dist/transport.d.ts +15 -0
  265. package/clinkx-workflows/dist/transport.js +19 -10
  266. package/clinkx-workflows/dist/transport.js.map +1 -1
  267. package/clinkx-workflows/dist/types.d.ts +14 -2
  268. package/clinkx-workflows/dist/validators/council.d.ts +318 -85
  269. package/clinkx-workflows/dist/validators/council.js +52 -13
  270. package/clinkx-workflows/dist/validators/council.js.map +1 -1
  271. package/clinkx-workflows/dist/validators/index.d.ts +1 -0
  272. package/clinkx-workflows/dist/validators/index.js +3 -0
  273. package/clinkx-workflows/dist/validators/index.js.map +1 -1
  274. package/clinkx-workflows/dist/validators/plan-review.d.ts +398 -0
  275. package/clinkx-workflows/dist/validators/plan-review.js +316 -0
  276. package/clinkx-workflows/dist/validators/plan-review.js.map +1 -0
  277. package/clinkx-workflows/dist/workflow-receipt.js +188 -4
  278. package/clinkx-workflows/dist/workflow-receipt.js.map +1 -1
  279. package/clinkx-workflows/dist/workflow-tools.d.ts +48 -3
  280. package/clinkx-workflows/dist/workflow-tools.js +1402 -59
  281. package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
  282. package/clinkx-workflows/dist/workspace-signature.d.ts +16 -0
  283. package/clinkx-workflows/dist/workspace-signature.js +388 -0
  284. package/clinkx-workflows/dist/workspace-signature.js.map +1 -0
  285. package/clinkx-workflows/templates/council/answer-specialist.txt +2 -1
  286. package/clinkx-workflows/templates/council/code-review-chairman.txt +13 -0
  287. package/clinkx-workflows/templates/council/code-review-cross-reviewer.txt +4 -1
  288. package/clinkx-workflows/templates/council/code-review-reviewer.txt +19 -3
  289. package/clinkx-workflows/templates/council/debug-debugger.txt +2 -1
  290. package/clinkx-workflows/templates/council/discover-analyst.txt +2 -1
  291. package/clinkx-workflows/templates/council/member.txt +2 -1
  292. package/clinkx-workflows/templates/council/plan-review-chairman.txt +68 -0
  293. package/clinkx-workflows/templates/council/plan-review-cross-reviewer.txt +51 -0
  294. package/clinkx-workflows/templates/council/plan-review-reviewer.txt +60 -0
  295. package/clinkx-workflows/templates/plan-review/chairman.txt +48 -0
  296. package/clinkx-workflows/templates/plan-review/cross-review.txt +52 -0
  297. package/clinkx-workflows/templates/plan-review/ranking.txt +16 -0
  298. package/clinkx-workflows/templates/plan-review/reviewer.txt +57 -0
  299. package/clinkx-workflows/workflows/council-answer.yaml +97 -8
  300. package/clinkx-workflows/workflows/council-code-review.yaml +103 -8
  301. package/clinkx-workflows/workflows/council-debug.yaml +97 -8
  302. package/clinkx-workflows/workflows/council-default.yaml +97 -8
  303. package/clinkx-workflows/workflows/council-discover.yaml +97 -8
  304. package/clinkx-workflows/workflows/council-plan-review.yaml +250 -0
  305. package/clinkx-workflows/workflows/plan-review-receipts.yaml +230 -0
  306. package/conf/adapters/agy.json +49 -0
  307. package/conf/adapters/claude.json +5 -0
  308. package/conf/adapters/codex-app-server.json +44 -0
  309. package/conf/adapters/codex.json +7 -2
  310. package/conf/adapters/glm.json +5 -0
  311. package/conf/adapters/grok.json +60 -0
  312. package/conf/adapters/hapi/agy.json +52 -0
  313. package/conf/adapters/hapi/claude.json +5 -0
  314. package/conf/adapters/hapi/codex.json +7 -2
  315. package/conf/adapters/hapi/glm.json +5 -0
  316. package/conf/prompts/json-codereviewer.txt +1 -0
  317. package/conf/prompts/json.txt +1 -0
  318. package/dist/activity-journal.d.ts +42 -0
  319. package/dist/activity-journal.js +381 -0
  320. package/dist/activity-journal.js.map +1 -0
  321. package/dist/allowed-roots.d.ts +53 -0
  322. package/dist/allowed-roots.js +216 -0
  323. package/dist/allowed-roots.js.map +1 -0
  324. package/dist/codex/activity-session-log.d.ts +14 -0
  325. package/dist/codex/activity-session-log.js +206 -0
  326. package/dist/codex/activity-session-log.js.map +1 -0
  327. package/dist/codex/agent-tools.d.ts +23 -0
  328. package/dist/codex/agent-tools.js +1270 -0
  329. package/dist/codex/agent-tools.js.map +1 -0
  330. package/dist/codex/app-server-client.d.ts +76 -0
  331. package/dist/codex/app-server-client.js +582 -0
  332. package/dist/codex/app-server-client.js.map +1 -0
  333. package/dist/codex/app-server-registry.d.ts +389 -0
  334. package/dist/codex/app-server-registry.js +1407 -0
  335. package/dist/codex/app-server-registry.js.map +1 -0
  336. package/dist/codex/client-types.d.ts +109 -0
  337. package/dist/codex/client-types.js +2 -0
  338. package/dist/codex/client-types.js.map +1 -0
  339. package/dist/codex/protocol.d.ts +5375 -0
  340. package/dist/codex/protocol.js +614 -0
  341. package/dist/codex/protocol.js.map +1 -0
  342. package/dist/codex/session.d.ts +263 -0
  343. package/dist/codex/session.js +466 -0
  344. package/dist/codex/session.js.map +1 -0
  345. package/dist/config.d.ts +185 -19
  346. package/dist/config.js +82 -16
  347. package/dist/config.js.map +1 -1
  348. package/dist/context-builder/anchors.d.ts +12 -0
  349. package/dist/context-builder/anchors.js +22 -0
  350. package/dist/context-builder/anchors.js.map +1 -0
  351. package/dist/context-builder/bundle.d.ts +109 -0
  352. package/dist/context-builder/bundle.js +1498 -0
  353. package/dist/context-builder/bundle.js.map +1 -0
  354. package/dist/context-builder/codemap.d.ts +22 -0
  355. package/dist/context-builder/codemap.js +675 -0
  356. package/dist/context-builder/codemap.js.map +1 -0
  357. package/dist/context-builder/config.d.ts +61 -0
  358. package/dist/context-builder/config.js +216 -0
  359. package/dist/context-builder/config.js.map +1 -0
  360. package/dist/context-builder/context-run-catalog.d.ts +17 -0
  361. package/dist/context-builder/context-run-catalog.js +99 -0
  362. package/dist/context-builder/context-run-catalog.js.map +1 -0
  363. package/dist/context-builder/delegate-packet.d.ts +219 -0
  364. package/dist/context-builder/delegate-packet.js +1190 -0
  365. package/dist/context-builder/delegate-packet.js.map +1 -0
  366. package/dist/context-builder/delegate-reconstruction.d.ts +13 -0
  367. package/dist/context-builder/delegate-reconstruction.js +220 -0
  368. package/dist/context-builder/delegate-reconstruction.js.map +1 -0
  369. package/dist/context-builder/delegate-validation.d.ts +27 -0
  370. package/dist/context-builder/delegate-validation.js +479 -0
  371. package/dist/context-builder/delegate-validation.js.map +1 -0
  372. package/dist/context-builder/delegate.d.ts +26 -0
  373. package/dist/context-builder/delegate.js +134 -0
  374. package/dist/context-builder/delegate.js.map +1 -0
  375. package/dist/context-builder/diagnostics.d.ts +36 -0
  376. package/dist/context-builder/diagnostics.js +107 -0
  377. package/dist/context-builder/diagnostics.js.map +1 -0
  378. package/dist/context-builder/discovery.d.ts +146 -0
  379. package/dist/context-builder/discovery.js +2129 -0
  380. package/dist/context-builder/discovery.js.map +1 -0
  381. package/dist/context-builder/globs.d.ts +14 -0
  382. package/dist/context-builder/globs.js +175 -0
  383. package/dist/context-builder/globs.js.map +1 -0
  384. package/dist/context-builder/handler.d.ts +41 -0
  385. package/dist/context-builder/handler.js +2590 -0
  386. package/dist/context-builder/handler.js.map +1 -0
  387. package/dist/context-builder/lifecycle-contract.d.ts +424 -0
  388. package/dist/context-builder/lifecycle-contract.js +523 -0
  389. package/dist/context-builder/lifecycle-contract.js.map +1 -0
  390. package/dist/context-builder/lifecycle-journal.d.ts +62 -0
  391. package/dist/context-builder/lifecycle-journal.js +88 -0
  392. package/dist/context-builder/lifecycle-journal.js.map +1 -0
  393. package/dist/context-builder/lifecycle-observer.d.ts +102 -0
  394. package/dist/context-builder/lifecycle-observer.js +258 -0
  395. package/dist/context-builder/lifecycle-observer.js.map +1 -0
  396. package/dist/context-builder/lifecycle-reconcile.d.ts +32 -0
  397. package/dist/context-builder/lifecycle-reconcile.js +191 -0
  398. package/dist/context-builder/lifecycle-reconcile.js.map +1 -0
  399. package/dist/context-builder/lifecycle-recovery.d.ts +2 -0
  400. package/dist/context-builder/lifecycle-recovery.js +14 -0
  401. package/dist/context-builder/lifecycle-recovery.js.map +1 -0
  402. package/dist/context-builder/path-signals.d.ts +7 -0
  403. package/dist/context-builder/path-signals.js +70 -0
  404. package/dist/context-builder/path-signals.js.map +1 -0
  405. package/dist/context-builder/paths.d.ts +30 -0
  406. package/dist/context-builder/paths.js +153 -0
  407. package/dist/context-builder/paths.js.map +1 -0
  408. package/dist/context-builder/progress.d.ts +17 -0
  409. package/dist/context-builder/progress.js +93 -0
  410. package/dist/context-builder/progress.js.map +1 -0
  411. package/dist/context-builder/receipt.d.ts +91 -0
  412. package/dist/context-builder/receipt.js +180 -0
  413. package/dist/context-builder/receipt.js.map +1 -0
  414. package/dist/context-builder/refine-handler.d.ts +14 -0
  415. package/dist/context-builder/refine-handler.js +790 -0
  416. package/dist/context-builder/refine-handler.js.map +1 -0
  417. package/dist/context-builder/review-coverage.d.ts +84 -0
  418. package/dist/context-builder/review-coverage.js +437 -0
  419. package/dist/context-builder/review-coverage.js.map +1 -0
  420. package/dist/context-builder/run-id.d.ts +7 -0
  421. package/dist/context-builder/run-id.js +31 -0
  422. package/dist/context-builder/run-id.js.map +1 -0
  423. package/dist/context-builder/schema.d.ts +669 -0
  424. package/dist/context-builder/schema.js +399 -0
  425. package/dist/context-builder/schema.js.map +1 -0
  426. package/dist/context-builder/secrets.d.ts +41 -0
  427. package/dist/context-builder/secrets.js +1651 -0
  428. package/dist/context-builder/secrets.js.map +1 -0
  429. package/dist/context-builder/selection.d.ts +56 -0
  430. package/dist/context-builder/selection.js +1111 -0
  431. package/dist/context-builder/selection.js.map +1 -0
  432. package/dist/context-builder/session-log-identity.d.ts +1 -0
  433. package/dist/context-builder/session-log-identity.js +66 -0
  434. package/dist/context-builder/session-log-identity.js.map +1 -0
  435. package/dist/context-builder/slice-range-math.d.ts +16 -0
  436. package/dist/context-builder/slice-range-math.js +137 -0
  437. package/dist/context-builder/slice-range-math.js.map +1 -0
  438. package/dist/context-builder/status.d.ts +66 -0
  439. package/dist/context-builder/status.js +160 -0
  440. package/dist/context-builder/status.js.map +1 -0
  441. package/dist/context-builder/storage.d.ts +118 -0
  442. package/dist/context-builder/storage.js +1003 -0
  443. package/dist/context-builder/storage.js.map +1 -0
  444. package/dist/context-builder/token-estimate.d.ts +19 -0
  445. package/dist/context-builder/token-estimate.js +90 -0
  446. package/dist/context-builder/token-estimate.js.map +1 -0
  447. package/dist/context-builder/versions.d.ts +29 -0
  448. package/dist/context-builder/versions.js +30 -0
  449. package/dist/context-builder/versions.js.map +1 -0
  450. package/dist/context-builder/workflow-runner.d.ts +69 -0
  451. package/dist/context-builder/workflow-runner.js +1051 -0
  452. package/dist/context-builder/workflow-runner.js.map +1 -0
  453. package/dist/context-builder/write-watchdog.d.ts +14 -0
  454. package/dist/context-builder/write-watchdog.js +38 -0
  455. package/dist/context-builder/write-watchdog.js.map +1 -0
  456. package/dist/dashboard-adapter-catalog.d.ts +9 -0
  457. package/dist/dashboard-adapter-catalog.js +46 -0
  458. package/dist/dashboard-adapter-catalog.js.map +1 -0
  459. package/dist/dashboard-cli.d.ts +79 -0
  460. package/dist/dashboard-cli.js +585 -0
  461. package/dist/dashboard-cli.js.map +1 -0
  462. package/dist/dashboard-companion/client.d.ts +36 -0
  463. package/dist/dashboard-companion/client.js +210 -0
  464. package/dist/dashboard-companion/client.js.map +1 -0
  465. package/dist/dashboard-companion/config.d.ts +8 -0
  466. package/dist/dashboard-companion/config.js +52 -0
  467. package/dist/dashboard-companion/config.js.map +1 -0
  468. package/dist/dashboard-companion/http-proxy.d.ts +10 -0
  469. package/dist/dashboard-companion/http-proxy.js +234 -0
  470. package/dist/dashboard-companion/http-proxy.js.map +1 -0
  471. package/dist/dashboard-companion/protocol.d.ts +80 -0
  472. package/dist/dashboard-companion/protocol.js +455 -0
  473. package/dist/dashboard-companion/protocol.js.map +1 -0
  474. package/dist/dashboard-companion/standalone-assets.d.ts +12 -0
  475. package/dist/dashboard-companion/standalone-assets.js +72 -0
  476. package/dist/dashboard-companion/standalone-assets.js.map +1 -0
  477. package/dist/dashboard-companion/standalone-entry.d.ts +1 -0
  478. package/dist/dashboard-companion/standalone-entry.js +17 -0
  479. package/dist/dashboard-companion/standalone-entry.js.map +1 -0
  480. package/dist/dashboard-gateway/config.d.ts +9 -0
  481. package/dist/dashboard-gateway/config.js +44 -0
  482. package/dist/dashboard-gateway/config.js.map +1 -0
  483. package/dist/dashboard-gateway/index.d.ts +11 -0
  484. package/dist/dashboard-gateway/index.js +755 -0
  485. package/dist/dashboard-gateway/index.js.map +1 -0
  486. package/dist/dashboard-gateway/main.d.ts +1 -0
  487. package/dist/dashboard-gateway/main.js +25 -0
  488. package/dist/dashboard-gateway/main.js.map +1 -0
  489. package/dist/dashboard-pairing-token.d.ts +1 -0
  490. package/dist/dashboard-pairing-token.js +5 -0
  491. package/dist/dashboard-pairing-token.js.map +1 -0
  492. package/dist/elaris/client.d.ts +73 -0
  493. package/dist/elaris/client.js +825 -0
  494. package/dist/elaris/client.js.map +1 -0
  495. package/dist/elaris/config.d.ts +18 -0
  496. package/dist/elaris/config.js +75 -0
  497. package/dist/elaris/config.js.map +1 -0
  498. package/dist/elaris/errors.d.ts +41 -0
  499. package/dist/elaris/errors.js +205 -0
  500. package/dist/elaris/errors.js.map +1 -0
  501. package/dist/elaris/github-repo.d.ts +18 -0
  502. package/dist/elaris/github-repo.js +89 -0
  503. package/dist/elaris/github-repo.js.map +1 -0
  504. package/dist/elaris/index.d.ts +10 -0
  505. package/dist/elaris/index.js +11 -0
  506. package/dist/elaris/index.js.map +1 -0
  507. package/dist/elaris/redact.d.ts +89 -0
  508. package/dist/elaris/redact.js +423 -0
  509. package/dist/elaris/redact.js.map +1 -0
  510. package/dist/elaris/run-id.d.ts +5 -0
  511. package/dist/elaris/run-id.js +20 -0
  512. package/dist/elaris/run-id.js.map +1 -0
  513. package/dist/elaris/status.d.ts +45 -0
  514. package/dist/elaris/status.js +122 -0
  515. package/dist/elaris/status.js.map +1 -0
  516. package/dist/elaris/tool-schemas.d.ts +314 -0
  517. package/dist/elaris/tool-schemas.js +208 -0
  518. package/dist/elaris/tool-schemas.js.map +1 -0
  519. package/dist/elaris/tools.d.ts +73 -0
  520. package/dist/elaris/tools.js +1065 -0
  521. package/dist/elaris/tools.js.map +1 -0
  522. package/dist/elaris/types.d.ts +1541 -0
  523. package/dist/elaris/types.js +252 -0
  524. package/dist/elaris/types.js.map +1 -0
  525. package/dist/errors.d.ts +16 -0
  526. package/dist/errors.js +19 -0
  527. package/dist/errors.js.map +1 -1
  528. package/dist/handler.d.ts +4 -0
  529. package/dist/handler.js +10 -1
  530. package/dist/handler.js.map +1 -1
  531. package/dist/index.d.ts +2 -1
  532. package/dist/index.js +13 -3
  533. package/dist/index.js.map +1 -1
  534. package/dist/local-clink-backend.d.ts +3 -0
  535. package/dist/local-clink-backend.js +4 -0
  536. package/dist/local-clink-backend.js.map +1 -1
  537. package/dist/package-info.d.ts +2 -0
  538. package/dist/package-info.js +18 -0
  539. package/dist/package-info.js.map +1 -0
  540. package/dist/parsers/codex-jsonl.js +48 -3
  541. package/dist/parsers/codex-jsonl.js.map +1 -1
  542. package/dist/parsers/extract.d.ts +10 -1
  543. package/dist/parsers/extract.js +11 -3
  544. package/dist/parsers/extract.js.map +1 -1
  545. package/dist/paths.d.ts +8 -0
  546. package/dist/paths.js +31 -43
  547. package/dist/paths.js.map +1 -1
  548. package/dist/pipeline.d.ts +51 -3
  549. package/dist/pipeline.js +264 -47
  550. package/dist/pipeline.js.map +1 -1
  551. package/dist/run-dir.d.ts +24 -0
  552. package/dist/run-dir.js +201 -2
  553. package/dist/run-dir.js.map +1 -1
  554. package/dist/runner.d.ts +13 -0
  555. package/dist/runner.js +184 -15
  556. package/dist/runner.js.map +1 -1
  557. package/dist/safety.d.ts +4 -4
  558. package/dist/safety.js +4 -4
  559. package/dist/schema.d.ts +7 -7
  560. package/dist/server.d.ts +2 -0
  561. package/dist/server.js +396 -24
  562. package/dist/server.js.map +1 -1
  563. package/dist/session-log-stream.d.ts +18 -0
  564. package/dist/session-log-stream.js +319 -0
  565. package/dist/session-log-stream.js.map +1 -0
  566. package/package.json +47 -5
  567. package/conf/adapters/gemini.json +0 -44
  568. package/conf/adapters/hapi/gemini.json +0 -47
  569. package/dist/artifacts.d.ts +0 -9
  570. package/dist/artifacts.js +0 -24
  571. package/dist/artifacts.js.map +0 -1
  572. package/dist/parsers/gemini-json.d.ts +0 -2
  573. package/dist/parsers/gemini-json.js +0 -72
  574. package/dist/parsers/gemini-json.js.map +0 -1
@@ -0,0 +1,466 @@
1
+ import { limitOutput } from "../pipeline.js";
2
+ import { CODEX_EVENT_AGENT_MESSAGE_DELTA, CODEX_EVENT_ITEM_COMPLETED, CODEX_EVENT_ITEM_PLAN_DELTA, CODEX_EVENT_ITEM_STARTED, CODEX_EVENT_TURN_DIFF_UPDATED, CODEX_EVENT_TURN_PLAN_UPDATED, } from "./protocol.js";
3
+ /** Bound the retained plan so a runaway plan stream cannot blow the budget. */
4
+ const MAX_PLAN_STEPS = 64;
5
+ const MAX_PLAN_STATUS_CHARS = 64;
6
+ function cloneBreakdown(value) {
7
+ return value == null ? null : { ...value };
8
+ }
9
+ function isRecord(value) {
10
+ return typeof value === "object" && value !== null && !Array.isArray(value);
11
+ }
12
+ function extractScope(params) {
13
+ if (!isRecord(params))
14
+ return { threadId: undefined, turnId: undefined };
15
+ const threadId = typeof params["threadId"] === "string" ? params["threadId"] : undefined;
16
+ const turnId = typeof params["turnId"] === "string" ? params["turnId"] : undefined;
17
+ return { threadId, turnId };
18
+ }
19
+ /**
20
+ * Cap large TEXT payloads before insertion into the ring.
21
+ *
22
+ * Review fix (2-5): a count cap alone does not bound memory — a single
23
+ * multi-megabyte delta would blow the budget. We cap the high-volume text
24
+ * fields (`delta`, `item.text`) at store time, independent of the finalText
25
+ * truncation applied on the SessionRecord.
26
+ */
27
+ function capPayload(method, params, maxTextChars) {
28
+ if (!isRecord(params))
29
+ return params;
30
+ const clone = { ...params };
31
+ if (method === CODEX_EVENT_AGENT_MESSAGE_DELTA &&
32
+ typeof clone["delta"] === "string" &&
33
+ clone["delta"].length > maxTextChars) {
34
+ clone["delta"] = limitOutput(clone["delta"], maxTextChars);
35
+ }
36
+ if ((method === CODEX_EVENT_ITEM_COMPLETED ||
37
+ method === CODEX_EVENT_ITEM_STARTED) &&
38
+ isRecord(clone["item"])) {
39
+ const item = { ...clone["item"] };
40
+ if (typeof item["text"] === "string" && item["text"].length > maxTextChars) {
41
+ item["text"] = limitOutput(item["text"], maxTextChars);
42
+ }
43
+ clone["item"] = item;
44
+ }
45
+ if (method === CODEX_EVENT_TURN_DIFF_UPDATED &&
46
+ typeof clone["diff"] === "string" &&
47
+ clone["diff"].length > maxTextChars) {
48
+ clone["diff"] = limitOutput(clone["diff"], maxTextChars);
49
+ }
50
+ if (method === CODEX_EVENT_ITEM_PLAN_DELTA &&
51
+ typeof clone["delta"] === "string" &&
52
+ clone["delta"].length > maxTextChars) {
53
+ clone["delta"] = limitOutput(clone["delta"], maxTextChars);
54
+ }
55
+ if (method === CODEX_EVENT_TURN_PLAN_UPDATED) {
56
+ // Ring caps use the event-text budget (`maxTextChars`); the snapshot copy
57
+ // in setLatestPlan uses the larger final-text budget. Same intentional
58
+ // per-channel asymmetry as the diff path (TURN_DIFF_UPDATED vs setLatestDiff).
59
+ if (Array.isArray(clone["plan"])) {
60
+ clone["plan"] = clone["plan"]
61
+ .slice(0, MAX_PLAN_STEPS)
62
+ .map((entry) => {
63
+ if (!isRecord(entry))
64
+ return entry;
65
+ const next = { ...entry };
66
+ if (typeof next["step"] === "string") {
67
+ next["step"] = limitOutput(next["step"], maxTextChars);
68
+ }
69
+ if (typeof next["status"] === "string") {
70
+ next["status"] = limitOutput(next["status"], MAX_PLAN_STATUS_CHARS);
71
+ }
72
+ return next;
73
+ });
74
+ }
75
+ if (typeof clone["explanation"] === "string" &&
76
+ clone["explanation"].length > maxTextChars) {
77
+ clone["explanation"] = limitOutput(clone["explanation"], maxTextChars);
78
+ }
79
+ }
80
+ return clone;
81
+ }
82
+ /**
83
+ * Bounded per-session event ring with a monotonic sequence cursor (2-5).
84
+ *
85
+ * - `seq` is monotonic and never reused; the cursor returned by {@link read}
86
+ * is a sequence number, not an array index.
87
+ * - On overflow the oldest entry is dropped and the floor advances.
88
+ * - A read whose cursor points behind the floor returns `truncated: true`
89
+ * (NOT an error) and resumes from the floor.
90
+ */
91
+ export class SessionEventRing {
92
+ capacity;
93
+ maxTextChars;
94
+ /**
95
+ * Fixed-size backing store used as a circular buffer. `head` is the slot of
96
+ * the oldest retained event; `count` is how many slots are live. Append
97
+ * writes at the tail and, on overflow, OVERWRITES the head slot then advances
98
+ * head — amortized O(1), no per-drop `shift()` (F7). Slots are typed nullable
99
+ * only to satisfy strict indexing; within `[head, head+count)` they are live.
100
+ */
101
+ buffer;
102
+ head = 0;
103
+ count = 0;
104
+ nextSeq = 0;
105
+ floorSeq = 0;
106
+ constructor(capacity, maxTextChars) {
107
+ this.capacity = capacity;
108
+ this.maxTextChars = maxTextChars;
109
+ this.buffer = new Array(Math.max(0, capacity));
110
+ }
111
+ append(event, atMs) {
112
+ const seq = this.nextSeq++;
113
+ const params = event.params;
114
+ const scope = extractScope(params);
115
+ const stored = {
116
+ seq,
117
+ method: event.method,
118
+ threadId: scope.threadId,
119
+ turnId: scope.turnId,
120
+ payload: capPayload(event.method, params, this.maxTextChars),
121
+ atMs,
122
+ };
123
+ if (this.capacity <= 0) {
124
+ // Degenerate ring: nothing is retained; the floor tracks the live cursor
125
+ // so any read reports the next sequence and flags stale cursors.
126
+ this.floorSeq = this.nextSeq;
127
+ return stored;
128
+ }
129
+ if (this.count < this.capacity) {
130
+ const tail = (this.head + this.count) % this.capacity;
131
+ this.buffer[tail] = stored;
132
+ this.count++;
133
+ }
134
+ else {
135
+ // Full: overwrite the oldest slot and advance head; floor follows the new
136
+ // oldest entry. This is the O(1) replacement for the old `shift()` drain.
137
+ this.buffer[this.head] = stored;
138
+ this.head = (this.head + 1) % this.capacity;
139
+ }
140
+ this.floorSeq = this.buffer[this.head]?.seq ?? this.nextSeq;
141
+ return stored;
142
+ }
143
+ read(cursor, limit) {
144
+ const requested = cursor ?? this.floorSeq;
145
+ const truncated = requested < this.floorSeq;
146
+ const from = truncated ? this.floorSeq : requested;
147
+ const selected = [];
148
+ for (let i = 0; i < this.count; i++) {
149
+ const entry = this.buffer[(this.head + i) % this.capacity];
150
+ if (entry === undefined)
151
+ continue;
152
+ if (entry.seq < from)
153
+ continue;
154
+ if (limit != null && limit >= 0 && selected.length >= limit)
155
+ break;
156
+ selected.push(entry);
157
+ }
158
+ const last = selected[selected.length - 1];
159
+ const nextCursor = last != null ? last.seq + 1 : Math.max(from, this.nextSeq);
160
+ return {
161
+ events: selected,
162
+ nextCursor,
163
+ truncated,
164
+ floor: this.floorSeq,
165
+ capacity: this.capacity,
166
+ };
167
+ }
168
+ get size() {
169
+ return this.count;
170
+ }
171
+ }
172
+ /**
173
+ * Serializable record of a single Codex app-server session.
174
+ *
175
+ * Holds the durable per-session state (config, status, token accounting,
176
+ * pending approvals, capped final text) plus the bounded event ring. All
177
+ * mutating helpers take an injected `nowMs` so the registry's clock drives
178
+ * every timestamp deterministically.
179
+ */
180
+ export class SessionRecord {
181
+ sessionId;
182
+ threadId;
183
+ activeTurnId = undefined;
184
+ status = "running";
185
+ cwd;
186
+ model;
187
+ sandbox;
188
+ approval;
189
+ origin;
190
+ depth;
191
+ pendingApprovals = new Map();
192
+ finalText = undefined;
193
+ /** Set when the most recent finalText assignment was capped by the registry. */
194
+ finalTextTruncated = false;
195
+ /** Running per-turn assistant preview (most-recent chars, bounded). */
196
+ latestAssistantPreview = null;
197
+ latestAssistantPreviewTruncated = false;
198
+ /**
199
+ * Turn id the running preview belongs to. Lets {@link beginTurn} distinguish
200
+ * "establishing the SAME turn whose early deltas already landed" (preserve the
201
+ * preview) from "starting a genuinely different turn" (reset it). Without this,
202
+ * a delta arriving before turn/start was established was erased by beginTurn.
203
+ */
204
+ latestAssistantPreviewTurnId = null;
205
+ failureReason = undefined;
206
+ latestDiff = null;
207
+ latestPlan = null;
208
+ planExplanation = null;
209
+ tokenUsage = {
210
+ baselineTotal: null,
211
+ lastUsage: null,
212
+ deltaUsage: null,
213
+ cumulativeTotal: null,
214
+ incomplete: false,
215
+ };
216
+ events;
217
+ createdAtMs;
218
+ updatedAtMs;
219
+ lastActivityAtMs;
220
+ maxFinalTextChars;
221
+ /** Cap for the running assistant preview; shares the event-text budget. */
222
+ maxPreviewChars;
223
+ constructor(init) {
224
+ this.sessionId = init.sessionId;
225
+ this.threadId = init.threadId;
226
+ this.cwd = init.cwd;
227
+ this.model = init.model;
228
+ this.sandbox = init.sandbox;
229
+ this.approval = init.approval;
230
+ this.origin = init.origin;
231
+ this.depth = init.depth;
232
+ this.createdAtMs = init.createdAtMs;
233
+ this.updatedAtMs = init.createdAtMs;
234
+ this.lastActivityAtMs = init.createdAtMs;
235
+ this.maxFinalTextChars = init.maxFinalTextChars;
236
+ this.maxPreviewChars = init.maxEventTextChars;
237
+ this.events = new SessionEventRing(init.eventBuffer, init.maxEventTextChars);
238
+ }
239
+ /** Begin (or resume into) a new active turn. Carries the cumulative token baseline forward. */
240
+ beginTurn(turnId, nowMs) {
241
+ this.activeTurnId = turnId;
242
+ this.status = "running";
243
+ this.pendingApprovals.clear();
244
+ this.finalText = undefined;
245
+ this.finalTextTruncated = false;
246
+ // Reset the preview trio ONLY when starting a genuinely different turn.
247
+ // Early deltas (arriving before turn/start was established) already tagged
248
+ // the preview with THIS turn id; preserving them keeps the first streaming
249
+ // chunk instead of erasing it at establishment. All the OTHER resets below
250
+ // stay unconditional — they are not turn-provisional like the preview is.
251
+ if (this.latestAssistantPreviewTurnId !== turnId) {
252
+ this.latestAssistantPreview = null;
253
+ this.latestAssistantPreviewTruncated = false;
254
+ this.latestAssistantPreviewTurnId = null;
255
+ }
256
+ this.failureReason = undefined;
257
+ this.latestDiff = null;
258
+ this.latestPlan = null;
259
+ this.planExplanation = null;
260
+ this.tokenUsage.baselineTotal = cloneBreakdown(this.tokenUsage.cumulativeTotal);
261
+ this.tokenUsage.deltaUsage = null;
262
+ this.tokenUsage.incomplete = false;
263
+ this.touch(nowMs);
264
+ }
265
+ recordTokenUsage(usage, nowMs) {
266
+ // Per-turn delta is the protocol `last` slice TAKEN DIRECTLY — subtracting
267
+ // `total - baseline` over-counts on a resumed thread (null baseline). `total`
268
+ // remains authoritative as the cumulative figure (set, not accumulated).
269
+ this.tokenUsage.lastUsage = { ...usage.last };
270
+ this.tokenUsage.cumulativeTotal = { ...usage.total };
271
+ this.tokenUsage.deltaUsage = { ...usage.last };
272
+ this.touch(nowMs);
273
+ }
274
+ appendEvent(event, nowMs) {
275
+ this.events.append(event, nowMs);
276
+ this.touch(nowMs);
277
+ }
278
+ setPendingApproval(approval, nowMs) {
279
+ this.pendingApprovals.set(approval.id, approval);
280
+ this.touch(nowMs);
281
+ }
282
+ getPendingApproval(id) {
283
+ return this.pendingApprovals.get(id);
284
+ }
285
+ clearPendingApproval(id, nowMs) {
286
+ const deleted = this.pendingApprovals.delete(id);
287
+ if (deleted)
288
+ this.touch(nowMs);
289
+ return deleted;
290
+ }
291
+ clearPendingApprovals(nowMs) {
292
+ if (this.pendingApprovals.size === 0)
293
+ return;
294
+ this.pendingApprovals.clear();
295
+ this.touch(nowMs);
296
+ }
297
+ /** Cache the latest unified diff for the active turn, capped to bound memory. */
298
+ setLatestDiff(diff, nowMs) {
299
+ this.latestDiff = limitOutput(diff, this.maxFinalTextChars);
300
+ this.touch(nowMs);
301
+ }
302
+ /**
303
+ * Cache the latest plan steps (and optional explanation) for the active turn.
304
+ * Steps are count-capped and each field length-capped, and copied into FRESH
305
+ * objects so a later mutation of the source array cannot alter stored state.
306
+ */
307
+ setLatestPlan(plan, explanation, nowMs) {
308
+ this.latestPlan = plan.slice(0, MAX_PLAN_STEPS).map((s) => ({
309
+ step: limitOutput(s.step, this.maxFinalTextChars),
310
+ status: limitOutput(s.status, MAX_PLAN_STATUS_CHARS),
311
+ }));
312
+ this.planExplanation =
313
+ explanation != null
314
+ ? limitOutput(explanation, this.maxFinalTextChars)
315
+ : null;
316
+ this.touch(nowMs);
317
+ }
318
+ /**
319
+ * Cache the latest final-answer text, capped at assignment so that failure/
320
+ * kill paths which finalize WITHOUT passing finalText still expose a bounded
321
+ * value (review fix 7). completeTurn re-applies the same cap idempotently.
322
+ */
323
+ setFinalText(text) {
324
+ this.applyFinalText(text);
325
+ }
326
+ /**
327
+ * Accumulate a streaming assistant delta into the running preview. Bounded by
328
+ * keeping the MOST RECENT `maxPreviewChars` (a live preview wants the latest
329
+ * text, unlike finalText which keeps the head); drops to the tail flag
330
+ * `latestAssistantPreviewTruncated` once older chars are shed.
331
+ *
332
+ * `turnId` tags the running preview so {@link beginTurn} can tell whether a
333
+ * subsequent establishment is for THIS turn (preserve) or a new one (reset).
334
+ * It may be undefined when the wire event omitted a turn id — but the wire
335
+ * schema requires it (AgentMessageDeltaNotificationSchema.turnId: z.string()),
336
+ * so the undefined branch is defense-only and leaves the tag untouched.
337
+ *
338
+ * Defense-in-depth ordering guard: correctness must not rely on `turn/started`
339
+ * always preceding that turn's first delta. We never blindly concatenate
340
+ * across a turn boundary:
341
+ * - Drop a delta whose `turnId` belongs to a DIFFERENT in-flight turn
342
+ * (`turnId != activeTurnId` while `activeTurnId != null`). This discards a
343
+ * stale, out-of-order cross-turn delta instead of corrupting the current
344
+ * turn's preview. The establishment path is preserved because the early
345
+ * delta arrives while `activeTurnId` is still null (beginTurn not yet run),
346
+ * so it is NOT dropped.
347
+ * - If the delta is accepted but its `turnId` differs from the preview's
348
+ * current tag, start a fresh preview for it (reset before appending). On
349
+ * the establishment path this is a no-op reset of an already-empty preview,
350
+ * so the result is identical to a plain append onto null — it cannot
351
+ * regress the early-delta (Issue-1) fix.
352
+ */
353
+ appendAssistantDelta(delta, turnId, nowMs) {
354
+ if (delta.length === 0)
355
+ return;
356
+ if (turnId != null &&
357
+ this.activeTurnId != null &&
358
+ turnId !== this.activeTurnId) {
359
+ // Stale delta from a different turn arrived after the active turn began.
360
+ return;
361
+ }
362
+ if (turnId != null && turnId !== this.latestAssistantPreviewTurnId) {
363
+ this.latestAssistantPreview = null;
364
+ this.latestAssistantPreviewTruncated = false;
365
+ }
366
+ if (turnId != null)
367
+ this.latestAssistantPreviewTurnId = turnId;
368
+ const combined = (this.latestAssistantPreview ?? "") + delta;
369
+ if (combined.length > this.maxPreviewChars) {
370
+ this.latestAssistantPreview = combined.slice(combined.length - this.maxPreviewChars);
371
+ this.latestAssistantPreviewTruncated = true;
372
+ }
373
+ else {
374
+ this.latestAssistantPreview = combined;
375
+ }
376
+ this.touch(nowMs);
377
+ }
378
+ /** Cap finalText and record whether the cap actually truncated the value. */
379
+ applyFinalText(text) {
380
+ const capped = limitOutput(text, this.maxFinalTextChars);
381
+ // Sticky within a turn: completeTurn re-applies finalText with the ALREADY-
382
+ // capped value (registry passes record.finalText back), so a fresh
383
+ // `capped !== text` would be false and clobber a prior truncation flag. OR
384
+ // preserves it; beginTurn resets the flag at turn start, so it can't bleed.
385
+ this.finalTextTruncated = this.finalTextTruncated || capped !== text;
386
+ this.finalText = capped;
387
+ }
388
+ /**
389
+ * Mark the active turn terminal. `finalText` is capped via `limitOutput`
390
+ * AT STORE TIME (2-2). Non-`completed` terminal states flag the token delta
391
+ * incomplete so resume/retry does not double-count (2-2).
392
+ */
393
+ completeTurn(status, opts, nowMs) {
394
+ this.status = status;
395
+ this.activeTurnId = undefined;
396
+ this.pendingApprovals.clear();
397
+ if (opts.finalText != null) {
398
+ this.applyFinalText(opts.finalText);
399
+ }
400
+ if (opts.failureReason != null) {
401
+ this.failureReason = opts.failureReason;
402
+ }
403
+ if (status !== "completed") {
404
+ this.tokenUsage.incomplete = true;
405
+ }
406
+ this.touch(nowMs);
407
+ }
408
+ isIdle() {
409
+ return this.status !== "running";
410
+ }
411
+ /** A resumable record retains a valid threadId (the on-disk rollout survives). */
412
+ isResumable() {
413
+ return this.threadId.length > 0;
414
+ }
415
+ touch(nowMs) {
416
+ this.updatedAtMs = nowMs;
417
+ this.lastActivityAtMs = nowMs;
418
+ }
419
+ snapshot() {
420
+ return {
421
+ sessionId: this.sessionId,
422
+ threadId: this.threadId,
423
+ activeTurnId: this.activeTurnId ?? null,
424
+ status: this.status,
425
+ cwd: this.cwd ?? null,
426
+ model: this.model ?? null,
427
+ sandbox: this.sandbox,
428
+ approval: this.approval,
429
+ origin: this.origin,
430
+ depth: this.depth,
431
+ pendingApprovals: [...this.pendingApprovals.values()].map((approval) => ({
432
+ id: approval.id,
433
+ type: approval.type,
434
+ requestedAtMs: approval.requestedAtMs,
435
+ reason: approval.reason,
436
+ ...(approval.command !== undefined ? { command: approval.command } : {}),
437
+ ...(approval.cwd !== undefined ? { cwd: approval.cwd } : {}),
438
+ ...(approval.grantRoot !== undefined ? { grantRoot: approval.grantRoot } : {}),
439
+ ...(approval.networkApprovalContext !== undefined
440
+ ? { networkApprovalContext: approval.networkApprovalContext }
441
+ : {}),
442
+ })),
443
+ finalText: this.finalText ?? null,
444
+ finalTextTruncated: this.finalTextTruncated,
445
+ latestAssistantPreview: this.latestAssistantPreview,
446
+ latestAssistantPreviewTruncated: this.latestAssistantPreviewTruncated,
447
+ failureReason: this.failureReason ?? null,
448
+ latestDiff: this.latestDiff,
449
+ latestPlan: this.latestPlan?.map((s) => ({ step: s.step, status: s.status })) ??
450
+ null,
451
+ planExplanation: this.planExplanation,
452
+ tokenUsage: {
453
+ baselineTotal: cloneBreakdown(this.tokenUsage.baselineTotal),
454
+ lastUsage: cloneBreakdown(this.tokenUsage.lastUsage),
455
+ deltaUsage: cloneBreakdown(this.tokenUsage.deltaUsage),
456
+ cumulativeTotal: cloneBreakdown(this.tokenUsage.cumulativeTotal),
457
+ incomplete: this.tokenUsage.incomplete,
458
+ },
459
+ eventCount: this.events.size,
460
+ createdAtMs: this.createdAtMs,
461
+ updatedAtMs: this.updatedAtMs,
462
+ lastActivityAtMs: this.lastActivityAtMs,
463
+ };
464
+ }
465
+ }
466
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/codex/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,6BAA6B,EAC7B,6BAA6B,GAK9B,MAAM,eAAe,CAAC;AA0EvB,+EAA+E;AAC/E,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,SAAS,cAAc,CACrB,KAAiC;IAEjC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;AAC7C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,YAAY,CAAC,MAAe;IAInC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACzE,MAAM,QAAQ,GACZ,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,QAAQ,CAAC,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