@cleocode/core 2026.3.74 → 2026.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/agent-schema.d.ts.map +1 -1
  3. package/dist/agents/retry.js +26 -21
  4. package/dist/agents/retry.js.map +1 -1
  5. package/dist/cant/approval.d.ts +110 -0
  6. package/dist/cant/approval.d.ts.map +1 -0
  7. package/dist/cant/approval.js +185 -0
  8. package/dist/cant/approval.js.map +1 -0
  9. package/dist/cant/context-builder.d.ts +79 -0
  10. package/dist/cant/context-builder.d.ts.map +1 -0
  11. package/dist/cant/context-builder.js +117 -0
  12. package/dist/cant/context-builder.js.map +1 -0
  13. package/dist/cant/discretion.d.ts +95 -0
  14. package/dist/cant/discretion.d.ts.map +1 -0
  15. package/dist/cant/discretion.js +116 -0
  16. package/dist/cant/discretion.js.map +1 -0
  17. package/dist/cant/index.d.ts +25 -0
  18. package/dist/cant/index.d.ts.map +1 -0
  19. package/dist/cant/index.js +23 -0
  20. package/dist/cant/index.js.map +1 -0
  21. package/dist/cant/parallel-runner.d.ts +38 -0
  22. package/dist/cant/parallel-runner.d.ts.map +1 -0
  23. package/dist/cant/parallel-runner.js +173 -0
  24. package/dist/cant/parallel-runner.js.map +1 -0
  25. package/dist/cant/types.d.ts +127 -0
  26. package/dist/cant/types.d.ts.map +1 -0
  27. package/dist/cant/types.js +11 -0
  28. package/dist/cant/types.js.map +1 -0
  29. package/dist/cant/workflow-executor.d.ts +105 -0
  30. package/dist/cant/workflow-executor.d.ts.map +1 -0
  31. package/dist/cant/workflow-executor.js +440 -0
  32. package/dist/cant/workflow-executor.js.map +1 -0
  33. package/dist/cleo.js +21 -1
  34. package/dist/cleo.js.map +1 -1
  35. package/dist/code/index.d.ts +10 -0
  36. package/dist/code/index.d.ts.map +1 -0
  37. package/dist/code/outline.d.ts +51 -0
  38. package/dist/code/outline.d.ts.map +1 -0
  39. package/dist/code/parser.d.ts +30 -0
  40. package/dist/code/parser.d.ts.map +1 -0
  41. package/dist/code/search.d.ts +42 -0
  42. package/dist/code/search.d.ts.map +1 -0
  43. package/dist/code/unfold.d.ts +44 -0
  44. package/dist/code/unfold.d.ts.map +1 -0
  45. package/dist/conduit/conduit-client.d.ts +35 -0
  46. package/dist/conduit/conduit-client.d.ts.map +1 -0
  47. package/dist/conduit/conduit-client.js +94 -0
  48. package/dist/conduit/conduit-client.js.map +1 -0
  49. package/dist/conduit/factory.d.ts +15 -0
  50. package/dist/conduit/factory.d.ts.map +1 -0
  51. package/dist/conduit/factory.js +35 -0
  52. package/dist/conduit/factory.js.map +1 -0
  53. package/dist/conduit/http-transport.d.ts +44 -0
  54. package/dist/conduit/http-transport.d.ts.map +1 -0
  55. package/dist/conduit/http-transport.js +165 -0
  56. package/dist/conduit/http-transport.js.map +1 -0
  57. package/dist/conduit/index.d.ts +15 -0
  58. package/dist/conduit/index.d.ts.map +1 -0
  59. package/dist/conduit/index.js +12 -0
  60. package/dist/conduit/index.js.map +1 -0
  61. package/dist/conduit/local-transport.d.ts +91 -0
  62. package/dist/conduit/local-transport.d.ts.map +1 -0
  63. package/dist/conduit/sse-transport.d.ts +68 -0
  64. package/dist/conduit/sse-transport.d.ts.map +1 -0
  65. package/dist/config.js +4 -3
  66. package/dist/config.js.map +1 -1
  67. package/dist/crypto/credentials.d.ts +40 -0
  68. package/dist/crypto/credentials.d.ts.map +1 -0
  69. package/dist/crypto/credentials.js +144 -0
  70. package/dist/crypto/credentials.js.map +1 -0
  71. package/dist/engine-result.d.ts +1 -1
  72. package/dist/engine-result.d.ts.map +1 -1
  73. package/dist/error-catalog.d.ts +1 -1
  74. package/dist/error-catalog.d.ts.map +1 -1
  75. package/dist/error-registry.d.ts +1 -1
  76. package/dist/error-registry.d.ts.map +1 -1
  77. package/dist/errors.d.ts +1 -1
  78. package/dist/errors.d.ts.map +1 -1
  79. package/dist/hooks/handlers/agent-hooks.d.ts.map +1 -1
  80. package/dist/hooks/handlers/agent-hooks.js +106 -0
  81. package/dist/hooks/handlers/agent-hooks.js.map +1 -0
  82. package/dist/hooks/handlers/context-hooks.d.ts.map +1 -1
  83. package/dist/hooks/handlers/context-hooks.js +111 -0
  84. package/dist/hooks/handlers/context-hooks.js.map +1 -0
  85. package/dist/hooks/handlers/error-hooks.d.ts +14 -5
  86. package/dist/hooks/handlers/error-hooks.d.ts.map +1 -1
  87. package/dist/hooks/handlers/error-hooks.js +15 -6
  88. package/dist/hooks/handlers/error-hooks.js.map +1 -1
  89. package/dist/hooks/handlers/file-hooks.d.ts.map +1 -1
  90. package/dist/hooks/handlers/file-hooks.js +35 -11
  91. package/dist/hooks/handlers/file-hooks.js.map +1 -1
  92. package/dist/hooks/handlers/handler-helpers.d.ts +41 -0
  93. package/dist/hooks/handlers/handler-helpers.d.ts.map +1 -0
  94. package/dist/hooks/handlers/handler-helpers.js +61 -0
  95. package/dist/hooks/handlers/handler-helpers.js.map +1 -0
  96. package/dist/hooks/handlers/index.js +10 -1
  97. package/dist/hooks/handlers/index.js.map +1 -1
  98. package/dist/hooks/handlers/mcp-hooks.d.ts.map +1 -1
  99. package/dist/hooks/handlers/mcp-hooks.js +88 -21
  100. package/dist/hooks/handlers/mcp-hooks.js.map +1 -1
  101. package/dist/hooks/handlers/session-hooks.d.ts.map +1 -1
  102. package/dist/hooks/handlers/session-hooks.js +5 -10
  103. package/dist/hooks/handlers/session-hooks.js.map +1 -1
  104. package/dist/hooks/handlers/task-hooks.d.ts.map +1 -1
  105. package/dist/hooks/handlers/task-hooks.js +5 -10
  106. package/dist/hooks/handlers/task-hooks.js.map +1 -1
  107. package/dist/hooks/handlers/work-capture-hooks.d.ts.map +1 -1
  108. package/dist/hooks/handlers/work-capture-hooks.js +165 -0
  109. package/dist/hooks/handlers/work-capture-hooks.js.map +1 -0
  110. package/dist/hooks/payload-schemas.js +83 -26
  111. package/dist/hooks/payload-schemas.js.map +1 -1
  112. package/dist/hooks/provider-hooks.js +37 -5
  113. package/dist/hooks/provider-hooks.js.map +1 -1
  114. package/dist/hooks/registry.js +76 -23
  115. package/dist/hooks/registry.js.map +1 -1
  116. package/dist/hooks/types.js +17 -13
  117. package/dist/hooks/types.js.map +1 -1
  118. package/dist/index.d.ts +4 -1
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +6452 -3371
  121. package/dist/index.js.map +4 -4
  122. package/dist/init.d.ts.map +1 -1
  123. package/dist/init.js +12 -0
  124. package/dist/init.js.map +1 -1
  125. package/dist/internal.d.ts +11 -1
  126. package/dist/internal.d.ts.map +1 -1
  127. package/dist/internal.js +10 -0
  128. package/dist/internal.js.map +1 -1
  129. package/dist/lib/index.d.ts +1 -0
  130. package/dist/lib/index.d.ts.map +1 -1
  131. package/dist/lib/tree-sitter-languages.d.ts +29 -0
  132. package/dist/lib/tree-sitter-languages.d.ts.map +1 -0
  133. package/dist/memory/brain-links.d.ts.map +1 -1
  134. package/dist/memory/brain-maintenance.d.ts +13 -0
  135. package/dist/memory/brain-maintenance.d.ts.map +1 -1
  136. package/dist/memory/brain-retrieval.d.ts +3 -0
  137. package/dist/memory/brain-retrieval.d.ts.map +1 -1
  138. package/dist/memory/brain-retrieval.js +5 -0
  139. package/dist/memory/brain-retrieval.js.map +1 -1
  140. package/dist/memory/decisions.d.ts.map +1 -1
  141. package/dist/mvi-helpers.d.ts +52 -0
  142. package/dist/mvi-helpers.d.ts.map +1 -0
  143. package/dist/mvi-helpers.js +74 -0
  144. package/dist/mvi-helpers.js.map +1 -0
  145. package/dist/nexus/index.js +2 -0
  146. package/dist/nexus/index.js.map +1 -1
  147. package/dist/nexus/workspace.d.ts.map +1 -1
  148. package/dist/nexus/workspace.js +355 -0
  149. package/dist/nexus/workspace.js.map +1 -0
  150. package/dist/orchestration/hierarchy.d.ts +32 -0
  151. package/dist/orchestration/hierarchy.d.ts.map +1 -0
  152. package/dist/orchestration/index.d.ts +1 -0
  153. package/dist/orchestration/index.d.ts.map +1 -1
  154. package/dist/output.d.ts +2 -2
  155. package/dist/output.d.ts.map +1 -1
  156. package/dist/output.js +40 -8
  157. package/dist/output.js.map +1 -1
  158. package/dist/pagination.d.ts +1 -1
  159. package/dist/pagination.d.ts.map +1 -1
  160. package/dist/sessions/find.d.ts +3 -0
  161. package/dist/sessions/find.d.ts.map +1 -1
  162. package/dist/sessions/find.js +3 -1
  163. package/dist/sessions/find.js.map +1 -1
  164. package/dist/sessions/index.d.ts.map +1 -1
  165. package/dist/sessions/index.js +11 -4
  166. package/dist/sessions/index.js.map +1 -1
  167. package/dist/sessions/snapshot.js +213 -0
  168. package/dist/sessions/snapshot.js.map +1 -0
  169. package/dist/store/agent-registry-accessor.d.ts +31 -0
  170. package/dist/store/agent-registry-accessor.d.ts.map +1 -0
  171. package/dist/store/agent-registry-accessor.js +169 -0
  172. package/dist/store/agent-registry-accessor.js.map +1 -0
  173. package/dist/store/converters.d.ts.map +1 -1
  174. package/dist/store/converters.js +2 -0
  175. package/dist/store/converters.js.map +1 -1
  176. package/dist/store/cross-db-cleanup.d.ts +34 -0
  177. package/dist/store/cross-db-cleanup.d.ts.map +1 -1
  178. package/dist/store/db-helpers.d.ts.map +1 -1
  179. package/dist/store/db-helpers.js +1 -0
  180. package/dist/store/db-helpers.js.map +1 -1
  181. package/dist/store/json.js +2 -2
  182. package/dist/store/safety-data-accessor.d.ts +7 -0
  183. package/dist/store/safety-data-accessor.d.ts.map +1 -1
  184. package/dist/store/safety-data-accessor.js +14 -0
  185. package/dist/store/safety-data-accessor.js.map +1 -1
  186. package/dist/store/signaldock-sqlite.d.ts +48 -0
  187. package/dist/store/signaldock-sqlite.d.ts.map +1 -0
  188. package/dist/store/signaldock-sqlite.js +178 -0
  189. package/dist/store/signaldock-sqlite.js.map +1 -0
  190. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  191. package/dist/store/sqlite-data-accessor.js +50 -0
  192. package/dist/store/sqlite-data-accessor.js.map +1 -1
  193. package/dist/store/sqlite.d.ts.map +1 -1
  194. package/dist/store/sqlite.js +30 -1
  195. package/dist/store/sqlite.js.map +1 -1
  196. package/dist/store/task-store.d.ts.map +1 -1
  197. package/dist/store/task-store.js +2 -0
  198. package/dist/store/task-store.js.map +1 -1
  199. package/dist/store/tasks-schema.d.ts +16 -0
  200. package/dist/store/tasks-schema.d.ts.map +1 -1
  201. package/dist/store/tasks-schema.js +33 -0
  202. package/dist/store/tasks-schema.js.map +1 -1
  203. package/dist/store/validation-schemas.d.ts +32 -0
  204. package/dist/store/validation-schemas.d.ts.map +1 -1
  205. package/dist/system/health.d.ts +1 -1
  206. package/dist/system/health.d.ts.map +1 -1
  207. package/dist/system/health.js +35 -0
  208. package/dist/system/health.js.map +1 -1
  209. package/dist/task-work/index.d.ts.map +1 -1
  210. package/dist/task-work/index.js +8 -4
  211. package/dist/task-work/index.js.map +1 -1
  212. package/dist/tasks/complete.js +5 -2
  213. package/dist/tasks/complete.js.map +1 -1
  214. package/dist/tasks/find.d.ts +3 -0
  215. package/dist/tasks/find.d.ts.map +1 -1
  216. package/dist/tasks/find.js +7 -1
  217. package/dist/tasks/find.js.map +1 -1
  218. package/dist/tasks/list.d.ts +5 -2
  219. package/dist/tasks/list.d.ts.map +1 -1
  220. package/dist/tasks/list.js +9 -2
  221. package/dist/tasks/list.js.map +1 -1
  222. package/dist/tasks/show.d.ts +3 -0
  223. package/dist/tasks/show.d.ts.map +1 -1
  224. package/dist/tasks/show.js +2 -0
  225. package/dist/tasks/show.js.map +1 -1
  226. package/dist/upgrade.d.ts.map +1 -1
  227. package/dist/upgrade.js +15 -0
  228. package/dist/upgrade.js.map +1 -1
  229. package/migrations/drizzle-tasks/20260324000000_assignee-column/migration.sql +6 -0
  230. package/migrations/drizzle-tasks/20260324000000_assignee-column/snapshot.json +9 -0
  231. package/migrations/drizzle-tasks/20260327000000_agent-credentials/migration.sql +23 -0
  232. package/package.json +17 -7
  233. package/src/__tests__/cli-parity.test.js +11 -1
  234. package/src/__tests__/cli-parity.test.js.map +1 -1
  235. package/src/__tests__/cli-parity.test.ts +17 -1
  236. package/src/__tests__/human-output.test.js +11 -1
  237. package/src/__tests__/human-output.test.js.map +1 -1
  238. package/src/__tests__/human-output.test.ts +18 -1
  239. package/src/__tests__/injection-chain.test.js +3 -2
  240. package/src/__tests__/injection-chain.test.js.map +1 -1
  241. package/src/__tests__/injection-mvi-tiers.test.d.ts +2 -2
  242. package/src/__tests__/injection-mvi-tiers.test.js +15 -15
  243. package/src/__tests__/injection-mvi-tiers.test.js.map +1 -1
  244. package/src/__tests__/lafs-conformance.test.d.ts +1 -1
  245. package/src/__tests__/lafs-conformance.test.js +2 -2
  246. package/src/__tests__/sharing.test.js +19 -0
  247. package/src/__tests__/sharing.test.js.map +1 -1
  248. package/src/agents/__tests__/agent-registry.test.d.ts +12 -0
  249. package/src/agents/__tests__/agent-registry.test.d.ts.map +1 -0
  250. package/src/agents/__tests__/agent-registry.test.js +262 -0
  251. package/src/agents/__tests__/agent-registry.test.js.map +1 -0
  252. package/src/agents/__tests__/execution-learning.test.d.ts +14 -0
  253. package/src/agents/__tests__/execution-learning.test.d.ts.map +1 -0
  254. package/src/agents/__tests__/execution-learning.test.js +533 -0
  255. package/src/agents/__tests__/execution-learning.test.js.map +1 -0
  256. package/src/agents/__tests__/health-monitor.test.d.ts +10 -0
  257. package/src/agents/__tests__/health-monitor.test.d.ts.map +1 -0
  258. package/src/agents/__tests__/health-monitor.test.js +259 -0
  259. package/src/agents/__tests__/health-monitor.test.js.map +1 -0
  260. package/src/agents/__tests__/registry.test.js +27 -2
  261. package/src/agents/__tests__/registry.test.js.map +1 -1
  262. package/src/agents/agent-schema.ts +2 -5
  263. package/src/cant/__tests__/cant-agent-parse.test.ts +94 -0
  264. package/src/cant/approval.ts +218 -0
  265. package/src/cant/context-builder.ts +135 -0
  266. package/src/cant/discretion.ts +149 -0
  267. package/src/cant/index.ts +58 -0
  268. package/src/cant/parallel-runner.ts +205 -0
  269. package/src/cant/types.ts +158 -0
  270. package/src/cant/workflow-executor.ts +618 -0
  271. package/src/code/index.ts +10 -0
  272. package/src/code/outline.ts +214 -0
  273. package/src/code/parser.ts +299 -0
  274. package/src/code/search.ts +173 -0
  275. package/src/code/unfold.ts +204 -0
  276. package/src/conduit/__tests__/dual-api-e2e.test.ts +212 -0
  277. package/src/conduit/__tests__/local-credential-flow.test.ts +230 -0
  278. package/src/conduit/__tests__/local-transport.test.ts +320 -0
  279. package/src/conduit/__tests__/sse-transport.test.ts +344 -0
  280. package/src/conduit/conduit-client.ts +123 -0
  281. package/src/conduit/factory.ts +49 -0
  282. package/src/conduit/http-transport.ts +201 -0
  283. package/src/conduit/index.ts +15 -0
  284. package/src/conduit/local-transport.ts +309 -0
  285. package/src/conduit/sse-transport.ts +382 -0
  286. package/src/crypto/credentials.ts +166 -0
  287. package/src/engine-result.ts +1 -1
  288. package/src/error-catalog.ts +1 -1
  289. package/src/error-registry.ts +1 -1
  290. package/src/errors.ts +1 -1
  291. package/src/hooks/handlers/__tests__/hook-automation-e2e.test.d.ts +13 -0
  292. package/src/hooks/handlers/__tests__/hook-automation-e2e.test.d.ts.map +1 -0
  293. package/src/hooks/handlers/__tests__/hook-automation-e2e.test.js +501 -0
  294. package/src/hooks/handlers/__tests__/hook-automation-e2e.test.js.map +1 -0
  295. package/src/hooks/handlers/agent-hooks.ts +1 -30
  296. package/src/hooks/handlers/context-hooks.ts +1 -30
  297. package/src/hooks/handlers/error-hooks.ts +14 -5
  298. package/src/hooks/handlers/file-hooks.ts +1 -6
  299. package/src/hooks/handlers/handler-helpers.ts +62 -0
  300. package/src/hooks/handlers/mcp-hooks.ts +2 -14
  301. package/src/hooks/handlers/session-hooks.ts +1 -6
  302. package/src/hooks/handlers/task-hooks.ts +1 -6
  303. package/src/hooks/handlers/work-capture-hooks.ts +1 -10
  304. package/src/index.ts +12 -1
  305. package/src/init.ts +12 -0
  306. package/src/intelligence/__tests__/adaptive-validation.test.d.ts +11 -0
  307. package/src/intelligence/__tests__/adaptive-validation.test.d.ts.map +1 -0
  308. package/src/intelligence/__tests__/adaptive-validation.test.js +517 -0
  309. package/src/intelligence/__tests__/adaptive-validation.test.js.map +1 -0
  310. package/src/intelligence/__tests__/impact.test.d.ts +1 -0
  311. package/src/intelligence/__tests__/impact.test.d.ts.map +1 -1
  312. package/src/intelligence/__tests__/impact.test.js +132 -1
  313. package/src/intelligence/__tests__/impact.test.js.map +1 -1
  314. package/src/internal.ts +22 -0
  315. package/src/lib/__tests__/retry.test.d.ts +7 -0
  316. package/src/lib/__tests__/retry.test.d.ts.map +1 -0
  317. package/src/lib/__tests__/retry.test.js +225 -0
  318. package/src/lib/__tests__/retry.test.js.map +1 -0
  319. package/src/lib/index.ts +8 -0
  320. package/src/lib/tree-sitter-languages.ts +88 -0
  321. package/src/lifecycle/__tests__/chain-store.test.js +6 -0
  322. package/src/lifecycle/__tests__/chain-store.test.js.map +1 -1
  323. package/src/lifecycle/__tests__/tessera-engine.test.js +52 -0
  324. package/src/lifecycle/__tests__/tessera-engine.test.js.map +1 -1
  325. package/src/memory/__tests__/brain-automation.test.d.ts +11 -0
  326. package/src/memory/__tests__/brain-automation.test.d.ts.map +1 -0
  327. package/src/memory/__tests__/brain-automation.test.js +730 -0
  328. package/src/memory/__tests__/brain-automation.test.js.map +1 -0
  329. package/src/memory/__tests__/brain-links.test.ts +14 -0
  330. package/src/memory/__tests__/brain-retrieval.test.ts +10 -0
  331. package/src/memory/__tests__/session-memory.test.ts +17 -0
  332. package/src/memory/brain-links.ts +17 -0
  333. package/src/memory/brain-maintenance.ts +33 -1
  334. package/src/memory/brain-retrieval.ts +27 -2
  335. package/src/memory/decisions.ts +18 -2
  336. package/src/mvi-helpers.ts +81 -0
  337. package/src/nexus/workspace.ts +19 -7
  338. package/src/orchestration/hierarchy.ts +202 -0
  339. package/src/orchestration/index.ts +1 -0
  340. package/src/output.ts +43 -10
  341. package/src/pagination.ts +1 -1
  342. package/src/sessions/__tests__/session-edge-cases.test.js +20 -1
  343. package/src/sessions/__tests__/session-edge-cases.test.js.map +1 -1
  344. package/src/sessions/__tests__/session-find.test.js +1 -1
  345. package/src/sessions/__tests__/session-find.test.js.map +1 -1
  346. package/src/sessions/__tests__/session-find.test.ts +1 -1
  347. package/src/sessions/find.ts +6 -1
  348. package/src/sessions/index.ts +9 -0
  349. package/src/store/__tests__/migration-safety.test.js +3 -0
  350. package/src/store/__tests__/migration-safety.test.js.map +1 -1
  351. package/src/store/__tests__/session-store.test.js +128 -1
  352. package/src/store/__tests__/session-store.test.js.map +1 -1
  353. package/src/store/__tests__/task-store.test.js +18 -1
  354. package/src/store/__tests__/task-store.test.js.map +1 -1
  355. package/src/store/__tests__/test-db-helper.d.ts.map +1 -1
  356. package/src/store/__tests__/test-db-helper.js +12 -0
  357. package/src/store/__tests__/test-db-helper.js.map +1 -1
  358. package/src/store/agent-registry-accessor.ts +375 -0
  359. package/src/store/converters.ts +2 -0
  360. package/src/store/cross-db-cleanup.ts +175 -1
  361. package/src/store/db-helpers.ts +1 -0
  362. package/src/store/safety-data-accessor.ts +23 -0
  363. package/src/store/signaldock-sqlite.ts +429 -0
  364. package/src/store/sqlite-data-accessor.ts +72 -0
  365. package/src/store/sqlite.ts +4 -1
  366. package/src/store/task-store.ts +9 -1
  367. package/src/store/tasks-schema.ts +7 -0
  368. package/src/system/__tests__/health.test.ts +2 -2
  369. package/src/system/health.ts +54 -2
  370. package/src/task-work/index.ts +5 -0
  371. package/src/tasks/__tests__/add.test.js +19 -1
  372. package/src/tasks/__tests__/add.test.js.map +1 -1
  373. package/src/tasks/__tests__/assignee.test.d.ts +14 -0
  374. package/src/tasks/__tests__/assignee.test.d.ts.map +1 -0
  375. package/src/tasks/__tests__/assignee.test.js +125 -0
  376. package/src/tasks/__tests__/assignee.test.js.map +1 -0
  377. package/src/tasks/__tests__/assignee.test.ts +162 -0
  378. package/src/tasks/__tests__/complete-unblocks.test.js +13 -1
  379. package/src/tasks/__tests__/complete-unblocks.test.js.map +1 -1
  380. package/src/tasks/__tests__/complete.test.js +28 -7
  381. package/src/tasks/__tests__/complete.test.js.map +1 -1
  382. package/src/tasks/__tests__/epic-enforcement.test.d.ts +15 -0
  383. package/src/tasks/__tests__/epic-enforcement.test.d.ts.map +1 -0
  384. package/src/tasks/__tests__/epic-enforcement.test.js +669 -0
  385. package/src/tasks/__tests__/epic-enforcement.test.js.map +1 -0
  386. package/src/tasks/__tests__/hierarchy-policy.test.js +5 -0
  387. package/src/tasks/__tests__/hierarchy-policy.test.js.map +1 -1
  388. package/src/tasks/__tests__/minimal-test.test.d.ts +2 -0
  389. package/src/tasks/__tests__/minimal-test.test.d.ts.map +1 -0
  390. package/src/tasks/__tests__/minimal-test.test.js +25 -0
  391. package/src/tasks/__tests__/minimal-test.test.js.map +1 -0
  392. package/src/tasks/__tests__/pipeline-stage.test.d.ts +14 -0
  393. package/src/tasks/__tests__/pipeline-stage.test.d.ts.map +1 -0
  394. package/src/tasks/__tests__/pipeline-stage.test.js +277 -0
  395. package/src/tasks/__tests__/pipeline-stage.test.js.map +1 -0
  396. package/src/tasks/__tests__/update.test.js +43 -6
  397. package/src/tasks/__tests__/update.test.js.map +1 -1
  398. package/src/tasks/find.ts +11 -1
  399. package/src/tasks/list.ts +14 -3
  400. package/src/tasks/show.ts +6 -0
  401. package/src/upgrade.ts +16 -0
  402. package/dist/tasks/reparent.d.ts +0 -38
  403. package/dist/tasks/reparent.d.ts.map +0 -1
  404. package/dist/ui/injection-legacy.d.ts +0 -26
  405. package/dist/ui/injection-legacy.d.ts.map +0 -1
  406. package/dist/ui/injection-legacy.js +0 -42
  407. package/dist/ui/injection-legacy.js.map +0 -1
  408. package/src/signaldock/__tests__/claude-code-transport.test.d.ts +0 -7
  409. package/src/signaldock/__tests__/claude-code-transport.test.d.ts.map +0 -1
  410. package/src/signaldock/__tests__/claude-code-transport.test.js +0 -147
  411. package/src/signaldock/__tests__/claude-code-transport.test.js.map +0 -1
  412. package/src/signaldock/__tests__/claude-code-transport.test.ts +0 -180
  413. package/src/signaldock/__tests__/factory.test.d.ts +0 -7
  414. package/src/signaldock/__tests__/factory.test.d.ts.map +0 -1
  415. package/src/signaldock/__tests__/factory.test.js +0 -55
  416. package/src/signaldock/__tests__/factory.test.js.map +0 -1
  417. package/src/signaldock/__tests__/factory.test.ts +0 -61
  418. package/src/signaldock/__tests__/signaldock-transport.test.d.ts +0 -9
  419. package/src/signaldock/__tests__/signaldock-transport.test.d.ts.map +0 -1
  420. package/src/signaldock/__tests__/signaldock-transport.test.js +0 -321
  421. package/src/signaldock/__tests__/signaldock-transport.test.js.map +0 -1
  422. package/src/signaldock/__tests__/signaldock-transport.test.ts +0 -421
  423. package/src/signaldock/claude-code-transport.ts +0 -137
  424. package/src/signaldock/factory.ts +0 -39
  425. package/src/signaldock/index.ts +0 -28
  426. package/src/signaldock/signaldock-transport.ts +0 -194
  427. package/src/signaldock/transport.ts +0 -78
  428. package/src/signaldock/types.ts +0 -100
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Parallel arm execution for CANT workflow parallel blocks.
3
+ *
4
+ * Supports three join strategies:
5
+ * - `all` (default): Wait for ALL arms. Fail if any arm fails.
6
+ * - `race`: Return when the FIRST arm completes. Cancel remaining.
7
+ * - `settle`: Wait for ALL arms. Collect successes and failures.
8
+ *
9
+ * @see docs/specs/CANT-DSL-SPEC.md Section 7.5 (Parallel Execution)
10
+ */
11
+
12
+ import type { JoinStrategy, SettleResult, StepResult } from './types.js';
13
+
14
+ /** A single parallel arm to execute. */
15
+ export interface ParallelArm {
16
+ /** The arm name (used for binding results to scope). */
17
+ name: string;
18
+ /** The async function that executes the arm's body. */
19
+ execute: () => Promise<unknown>;
20
+ }
21
+
22
+ /** Result of a parallel block execution. */
23
+ export interface ParallelResult {
24
+ /** Whether the parallel block succeeded according to its join strategy. */
25
+ success: boolean;
26
+ /** Per-arm results mapped by arm name. */
27
+ results: Record<string, unknown>;
28
+ /** Step results for audit/logging. */
29
+ steps: StepResult[];
30
+ /** Settle-mode detailed breakdown (only for `settle` strategy). */
31
+ settleResult?: SettleResult;
32
+ }
33
+
34
+ /**
35
+ * Executes parallel arms according to the specified join strategy.
36
+ *
37
+ * @param arms - The arms to execute concurrently.
38
+ * @param strategy - The join strategy (default: 'all').
39
+ * @returns Parallel execution result.
40
+ */
41
+ export async function executeParallel(
42
+ arms: ParallelArm[],
43
+ strategy: JoinStrategy = 'all',
44
+ ): Promise<ParallelResult> {
45
+ switch (strategy) {
46
+ case 'race':
47
+ return executeRace(arms);
48
+ case 'settle':
49
+ return executeSettle(arms);
50
+ default: // 'all' or any other value
51
+ return executeAll(arms);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Execute all arms concurrently. Fail if any arm fails.
57
+ */
58
+ async function executeAll(arms: ParallelArm[]): Promise<ParallelResult> {
59
+ const startTimes = new Map<string, number>();
60
+ const promises = arms.map(async (arm) => {
61
+ const start = Date.now();
62
+ startTimes.set(arm.name, start);
63
+ const result = await arm.execute();
64
+ return { name: arm.name, result, duration: Date.now() - start };
65
+ });
66
+
67
+ try {
68
+ const outcomes = await Promise.all(promises);
69
+ const results: Record<string, unknown> = {};
70
+ const steps: StepResult[] = [];
71
+
72
+ for (const outcome of outcomes) {
73
+ results[outcome.name] = outcome.result;
74
+ steps.push({
75
+ name: outcome.name,
76
+ type: 'parallel',
77
+ success: true,
78
+ output: outcome.result,
79
+ duration: outcome.duration,
80
+ });
81
+ }
82
+
83
+ return { success: true, results, steps };
84
+ } catch (err) {
85
+ const error = err instanceof Error ? err.message : String(err);
86
+ return {
87
+ success: false,
88
+ results: {},
89
+ steps: [
90
+ {
91
+ name: 'parallel:all',
92
+ type: 'parallel',
93
+ success: false,
94
+ error,
95
+ duration: 0,
96
+ },
97
+ ],
98
+ };
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Execute all arms concurrently. Return on first completion.
104
+ */
105
+ async function executeRace(arms: ParallelArm[]): Promise<ParallelResult> {
106
+ const promises = arms.map(async (arm) => {
107
+ const start = Date.now();
108
+ const result = await arm.execute();
109
+ return { name: arm.name, result, duration: Date.now() - start };
110
+ });
111
+
112
+ try {
113
+ const winner = await Promise.race(promises);
114
+ return {
115
+ success: true,
116
+ results: { [winner.name]: winner.result },
117
+ steps: [
118
+ {
119
+ name: winner.name,
120
+ type: 'parallel',
121
+ success: true,
122
+ output: winner.result,
123
+ duration: winner.duration,
124
+ },
125
+ ],
126
+ };
127
+ } catch (err) {
128
+ const error = err instanceof Error ? err.message : String(err);
129
+ return {
130
+ success: false,
131
+ results: {},
132
+ steps: [
133
+ {
134
+ name: 'parallel:race',
135
+ type: 'parallel',
136
+ success: false,
137
+ error,
138
+ duration: 0,
139
+ },
140
+ ],
141
+ };
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Execute all arms concurrently. Collect all successes and failures.
147
+ */
148
+ async function executeSettle(arms: ParallelArm[]): Promise<ParallelResult> {
149
+ const promises = arms.map(async (arm) => {
150
+ const start = Date.now();
151
+ try {
152
+ const result = await arm.execute();
153
+ return {
154
+ name: arm.name,
155
+ status: 'fulfilled' as const,
156
+ result,
157
+ duration: Date.now() - start,
158
+ };
159
+ } catch (err) {
160
+ return {
161
+ name: arm.name,
162
+ status: 'rejected' as const,
163
+ error: err instanceof Error ? err.message : String(err),
164
+ duration: Date.now() - start,
165
+ };
166
+ }
167
+ });
168
+
169
+ const outcomes = await Promise.all(promises);
170
+
171
+ const successes: SettleResult['successes'] = [];
172
+ const failures: SettleResult['failures'] = [];
173
+ const results: Record<string, unknown> = {};
174
+ const steps: StepResult[] = [];
175
+
176
+ for (const outcome of outcomes) {
177
+ if (outcome.status === 'fulfilled') {
178
+ successes.push({ name: outcome.name, result: outcome.result });
179
+ results[outcome.name] = outcome.result;
180
+ steps.push({
181
+ name: outcome.name,
182
+ type: 'parallel',
183
+ success: true,
184
+ output: outcome.result,
185
+ duration: outcome.duration,
186
+ });
187
+ } else {
188
+ failures.push({ name: outcome.name, error: outcome.error });
189
+ steps.push({
190
+ name: outcome.name,
191
+ type: 'parallel',
192
+ success: false,
193
+ error: outcome.error,
194
+ duration: outcome.duration,
195
+ });
196
+ }
197
+ }
198
+
199
+ return {
200
+ success: failures.length === 0,
201
+ results,
202
+ steps,
203
+ settleResult: { successes, failures },
204
+ };
205
+ }
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Runtime types for the CANT DSL workflow executor.
3
+ *
4
+ * These types are used by the TypeScript workflow execution layer to
5
+ * represent execution results, step outcomes, discretion evaluation
6
+ * contexts, and approval tokens.
7
+ *
8
+ * @see docs/specs/CANT-DSL-SPEC.md Section 7 (Runtime) and Section 8 (Approval Tokens)
9
+ */
10
+
11
+ // ---------------------------------------------------------------------------
12
+ // Execution Results
13
+ // ---------------------------------------------------------------------------
14
+
15
+ /** The aggregate result of executing a CANT workflow. */
16
+ export interface ExecutionResult {
17
+ /** Whether the workflow completed without errors. */
18
+ success: boolean;
19
+ /** Output bindings from `output name = expr` statements. */
20
+ outputs: Record<string, unknown>;
21
+ /** Results for each executed step in order. */
22
+ steps: StepResult[];
23
+ /** Total wall-clock execution duration in milliseconds. */
24
+ duration: number;
25
+ }
26
+
27
+ /** The result of a single workflow statement execution. */
28
+ export interface StepResult {
29
+ /** The step or statement name. */
30
+ name: string;
31
+ /** The type of statement that was executed. */
32
+ type:
33
+ | 'session'
34
+ | 'pipeline'
35
+ | 'parallel'
36
+ | 'conditional'
37
+ | 'loop'
38
+ | 'approval'
39
+ | 'binding'
40
+ | 'directive'
41
+ | 'output';
42
+ /** Whether this step completed successfully. */
43
+ success: boolean;
44
+ /** The output value produced by this step, if any. */
45
+ output?: unknown;
46
+ /** Error message if the step failed. */
47
+ error?: string;
48
+ /** Wall-clock execution duration in milliseconds. */
49
+ duration: number;
50
+ }
51
+
52
+ // ---------------------------------------------------------------------------
53
+ // Discretion Evaluation
54
+ // ---------------------------------------------------------------------------
55
+
56
+ /** Context provided to a discretion evaluator for AI-judged conditions. */
57
+ export interface DiscretionContext {
58
+ /** The current session identifier. */
59
+ sessionId: string;
60
+ /** Task references currently in scope. */
61
+ taskRefs: string[];
62
+ /** The agent performing the evaluation. */
63
+ agentId: string;
64
+ /** All variables in the current workflow scope. */
65
+ variables: Record<string, unknown>;
66
+ /** The raw discretion condition text (between `**` delimiters). */
67
+ condition: string;
68
+ /** Output from preceding pipeline steps or session results. */
69
+ precedingResults: Record<string, unknown>;
70
+ }
71
+
72
+ // ---------------------------------------------------------------------------
73
+ // Approval Tokens (Section 8 of CANT-DSL-SPEC.md)
74
+ // ---------------------------------------------------------------------------
75
+
76
+ /** Valid states for an approval token. */
77
+ export type ApprovalTokenStatus = 'pending' | 'approved' | 'rejected' | 'expired';
78
+
79
+ /**
80
+ * An approval token for human-in-the-loop workflow gates.
81
+ *
82
+ * Tokens are bound to a specific session and workflow. The `workflowHash`
83
+ * provides TOCTOU protection: if the workflow is modified between token
84
+ * creation and approval, the token is invalidated.
85
+ *
86
+ * Security invariants:
87
+ * - Token values MUST NOT appear in audit logs, summaries, or error messages.
88
+ * - `approvalTokensJson` is NEVER included in handoff/debrief serialization.
89
+ * - Status transitions use atomic CAS (pending -> approved|rejected|expired only).
90
+ */
91
+ export interface ApprovalToken {
92
+ /** UUID v4 generated via CSPRNG (crypto.randomUUID). */
93
+ token: string;
94
+ /** The session that generated this token. Token is bound to this session. */
95
+ sessionId: string;
96
+ /** The workflow that contains the approval gate. */
97
+ workflowName: string;
98
+ /** The name label of the specific approval gate. */
99
+ gateName: string;
100
+ /**
101
+ * SHA-256 hash of the workflow definition text at the time the token was
102
+ * created. Used for TOCTOU protection.
103
+ */
104
+ workflowHash: string;
105
+ /** The message displayed to the approver. */
106
+ message: string;
107
+ /** ISO 8601 timestamp of token creation. */
108
+ createdAt: string;
109
+ /** ISO 8601 timestamp of token expiration. REQUIRED. Default 24h. */
110
+ expiresAt: string;
111
+ /** Current token state. */
112
+ status: ApprovalTokenStatus;
113
+ /** Identifier of the actor who approved/rejected (informational). */
114
+ approvedBy?: string;
115
+ /** ISO 8601 timestamp of the approval/rejection action. */
116
+ approvedAt?: string;
117
+ /** ISO 8601 timestamp of when the token was consumed by the runtime. */
118
+ usedAt?: string;
119
+ /** Identifier of the agent/workflow that requested approval. */
120
+ requestedBy: string;
121
+ }
122
+
123
+ /** Result of validating an approval token. */
124
+ export interface TokenValidation {
125
+ /** Whether the token is valid and can be consumed. */
126
+ valid: boolean;
127
+ /** If invalid, the reason for rejection. */
128
+ reason?: 'not_found' | 'wrong_session' | 'not_pending' | 'expired' | 'hash_mismatch';
129
+ /** The token object if found. */
130
+ token?: ApprovalToken;
131
+ }
132
+
133
+ // ---------------------------------------------------------------------------
134
+ // Parallel Execution
135
+ // ---------------------------------------------------------------------------
136
+
137
+ /** Join strategy for parallel block execution. */
138
+ export type JoinStrategy = 'all' | 'race' | 'settle';
139
+
140
+ /** Result of a parallel block execution with the settle strategy. */
141
+ export interface SettleResult {
142
+ /** Arms that completed successfully. */
143
+ successes: Array<{ name: string; result: unknown }>;
144
+ /** Arms that failed. */
145
+ failures: Array<{ name: string; error: string }>;
146
+ }
147
+
148
+ // ---------------------------------------------------------------------------
149
+ // Execution Scope
150
+ // ---------------------------------------------------------------------------
151
+
152
+ /** Variable scope for workflow execution. */
153
+ export interface ExecutionScope {
154
+ /** Variable bindings in the current scope. */
155
+ variables: Record<string, unknown>;
156
+ /** Parent scope for nested blocks (parallel arms, loops, etc.). */
157
+ parent?: ExecutionScope;
158
+ }