@namzu/sdk 0.1.8 → 0.3.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 (626) hide show
  1. package/CHANGELOG.md +69 -2
  2. package/dist/agents/ReactiveAgent.d.ts.map +1 -1
  3. package/dist/agents/ReactiveAgent.js +5 -2
  4. package/dist/agents/ReactiveAgent.js.map +1 -1
  5. package/dist/agents/RouterAgent.d.ts.map +1 -1
  6. package/dist/agents/RouterAgent.js +3 -0
  7. package/dist/agents/RouterAgent.js.map +1 -1
  8. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  9. package/dist/agents/SupervisorAgent.js +21 -5
  10. package/dist/agents/SupervisorAgent.js.map +1 -1
  11. package/dist/bridge/a2a/index.d.ts +1 -1
  12. package/dist/bridge/a2a/index.d.ts.map +1 -1
  13. package/dist/bridge/a2a/index.js +1 -1
  14. package/dist/bridge/a2a/index.js.map +1 -1
  15. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  16. package/dist/bridge/a2a/mapper.js +6 -0
  17. package/dist/bridge/a2a/mapper.js.map +1 -1
  18. package/dist/bridge/a2a/message.d.ts +0 -2
  19. package/dist/bridge/a2a/message.d.ts.map +1 -1
  20. package/dist/bridge/a2a/message.js +0 -26
  21. package/dist/bridge/a2a/message.js.map +1 -1
  22. package/dist/bridge/a2a/task.d.ts +5 -4
  23. package/dist/bridge/a2a/task.d.ts.map +1 -1
  24. package/dist/bridge/a2a/task.js +4 -4
  25. package/dist/bridge/a2a/task.js.map +1 -1
  26. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  27. package/dist/bridge/sse/mapper.js +6 -0
  28. package/dist/bridge/sse/mapper.js.map +1 -1
  29. package/dist/constants/a2a/index.d.ts +2 -2
  30. package/dist/constants/a2a/index.d.ts.map +1 -1
  31. package/dist/constants/a2a/index.js.map +1 -1
  32. package/dist/contracts/api.d.ts +14 -27
  33. package/dist/contracts/api.d.ts.map +1 -1
  34. package/dist/contracts/ids.d.ts +1 -1
  35. package/dist/contracts/ids.d.ts.map +1 -1
  36. package/dist/contracts/index.d.ts +3 -3
  37. package/dist/contracts/index.d.ts.map +1 -1
  38. package/dist/contracts/index.js +1 -1
  39. package/dist/contracts/index.js.map +1 -1
  40. package/dist/contracts/schemas.d.ts +1 -31
  41. package/dist/contracts/schemas.d.ts.map +1 -1
  42. package/dist/contracts/schemas.js +1 -7
  43. package/dist/contracts/schemas.js.map +1 -1
  44. package/dist/gateway/local.d.ts.map +1 -1
  45. package/dist/gateway/local.js +6 -0
  46. package/dist/gateway/local.js.map +1 -1
  47. package/dist/index.d.ts +6 -3
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +6 -3
  50. package/dist/index.js.map +1 -1
  51. package/dist/manager/agent/__tests__/lifecycle.test.d.ts +2 -0
  52. package/dist/manager/agent/__tests__/lifecycle.test.d.ts.map +1 -0
  53. package/dist/manager/agent/__tests__/lifecycle.test.js +316 -0
  54. package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -0
  55. package/dist/manager/agent/lifecycle.d.ts +67 -3
  56. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  57. package/dist/manager/agent/lifecycle.js +375 -14
  58. package/dist/manager/agent/lifecycle.js.map +1 -1
  59. package/dist/manager/index.d.ts +2 -0
  60. package/dist/manager/index.d.ts.map +1 -1
  61. package/dist/manager/index.js +1 -0
  62. package/dist/manager/index.js.map +1 -1
  63. package/dist/manager/run/persistence.d.ts +10 -1
  64. package/dist/manager/run/persistence.d.ts.map +1 -1
  65. package/dist/manager/run/persistence.js +20 -0
  66. package/dist/manager/run/persistence.js.map +1 -1
  67. package/dist/manager/thread/__tests__/lifecycle.test.d.ts +2 -0
  68. package/dist/manager/thread/__tests__/lifecycle.test.d.ts.map +1 -0
  69. package/dist/manager/thread/__tests__/lifecycle.test.js +216 -0
  70. package/dist/manager/thread/__tests__/lifecycle.test.js.map +1 -0
  71. package/dist/manager/thread/lifecycle.d.ts +105 -0
  72. package/dist/manager/thread/lifecycle.d.ts.map +1 -0
  73. package/dist/manager/thread/lifecycle.js +186 -0
  74. package/dist/manager/thread/lifecycle.js.map +1 -0
  75. package/dist/rag/retriever.js +2 -2
  76. package/dist/run/reporter.d.ts.map +1 -1
  77. package/dist/run/reporter.js +25 -0
  78. package/dist/run/reporter.js.map +1 -1
  79. package/dist/runtime/query/__tests__/context.test.d.ts +2 -0
  80. package/dist/runtime/query/__tests__/context.test.d.ts.map +1 -0
  81. package/dist/runtime/query/__tests__/context.test.js +85 -0
  82. package/dist/runtime/query/__tests__/context.test.js.map +1 -0
  83. package/dist/runtime/query/context-cache.d.ts +3 -3
  84. package/dist/runtime/query/context-cache.d.ts.map +1 -1
  85. package/dist/runtime/query/context-cache.js +2 -2
  86. package/dist/runtime/query/context-cache.js.map +1 -1
  87. package/dist/runtime/query/context.d.ts +45 -1
  88. package/dist/runtime/query/context.d.ts.map +1 -1
  89. package/dist/runtime/query/context.js +50 -8
  90. package/dist/runtime/query/context.js.map +1 -1
  91. package/dist/runtime/query/events.d.ts.map +1 -1
  92. package/dist/runtime/query/events.js +8 -0
  93. package/dist/runtime/query/events.js.map +1 -1
  94. package/dist/runtime/query/index.d.ts +22 -1
  95. package/dist/runtime/query/index.d.ts.map +1 -1
  96. package/dist/runtime/query/index.js +11 -0
  97. package/dist/runtime/query/index.js.map +1 -1
  98. package/dist/session/__tests__/integration/_fixtures.d.ts +122 -0
  99. package/dist/session/__tests__/integration/_fixtures.d.ts.map +1 -0
  100. package/dist/session/__tests__/integration/_fixtures.js +215 -0
  101. package/dist/session/__tests__/integration/_fixtures.js.map +1 -0
  102. package/dist/session/__tests__/integration/archive-gate.test.d.ts +15 -0
  103. package/dist/session/__tests__/integration/archive-gate.test.d.ts.map +1 -0
  104. package/dist/session/__tests__/integration/archive-gate.test.js +214 -0
  105. package/dist/session/__tests__/integration/archive-gate.test.js.map +1 -0
  106. package/dist/session/__tests__/integration/capacity-caps.test.d.ts +13 -0
  107. package/dist/session/__tests__/integration/capacity-caps.test.d.ts.map +1 -0
  108. package/dist/session/__tests__/integration/capacity-caps.test.js +123 -0
  109. package/dist/session/__tests__/integration/capacity-caps.test.js.map +1 -0
  110. package/dist/session/__tests__/integration/e2e-spawn.test.d.ts +18 -0
  111. package/dist/session/__tests__/integration/e2e-spawn.test.d.ts.map +1 -0
  112. package/dist/session/__tests__/integration/e2e-spawn.test.js +238 -0
  113. package/dist/session/__tests__/integration/e2e-spawn.test.js.map +1 -0
  114. package/dist/session/__tests__/integration/event-stream-ordering.test.d.ts +15 -0
  115. package/dist/session/__tests__/integration/event-stream-ordering.test.d.ts.map +1 -0
  116. package/dist/session/__tests__/integration/event-stream-ordering.test.js +330 -0
  117. package/dist/session/__tests__/integration/event-stream-ordering.test.js.map +1 -0
  118. package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.d.ts +12 -0
  119. package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.d.ts.map +1 -0
  120. package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js +182 -0
  121. package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js.map +1 -0
  122. package/dist/session/__tests__/integration/handoff-illegal-transition.test.d.ts +18 -0
  123. package/dist/session/__tests__/integration/handoff-illegal-transition.test.d.ts.map +1 -0
  124. package/dist/session/__tests__/integration/handoff-illegal-transition.test.js +156 -0
  125. package/dist/session/__tests__/integration/handoff-illegal-transition.test.js.map +1 -0
  126. package/dist/session/__tests__/integration/handoff-single-e2e.test.d.ts +15 -0
  127. package/dist/session/__tests__/integration/handoff-single-e2e.test.d.ts.map +1 -0
  128. package/dist/session/__tests__/integration/handoff-single-e2e.test.js +179 -0
  129. package/dist/session/__tests__/integration/handoff-single-e2e.test.js.map +1 -0
  130. package/dist/session/__tests__/integration/hierarchy-lifecycle.test.d.ts +12 -0
  131. package/dist/session/__tests__/integration/hierarchy-lifecycle.test.d.ts.map +1 -0
  132. package/dist/session/__tests__/integration/hierarchy-lifecycle.test.js +158 -0
  133. package/dist/session/__tests__/integration/hierarchy-lifecycle.test.js.map +1 -0
  134. package/dist/session/__tests__/integration/migration-filesystem.test.d.ts +11 -0
  135. package/dist/session/__tests__/integration/migration-filesystem.test.d.ts.map +1 -0
  136. package/dist/session/__tests__/integration/migration-filesystem.test.js +140 -0
  137. package/dist/session/__tests__/integration/migration-filesystem.test.js.map +1 -0
  138. package/dist/session/__tests__/integration/migration-id-prefix.test.d.ts +13 -0
  139. package/dist/session/__tests__/integration/migration-id-prefix.test.d.ts.map +1 -0
  140. package/dist/session/__tests__/integration/migration-id-prefix.test.js +84 -0
  141. package/dist/session/__tests__/integration/migration-id-prefix.test.js.map +1 -0
  142. package/dist/session/__tests__/integration/prev-artifact-dag.test.d.ts +14 -0
  143. package/dist/session/__tests__/integration/prev-artifact-dag.test.d.ts.map +1 -0
  144. package/dist/session/__tests__/integration/prev-artifact-dag.test.js +242 -0
  145. package/dist/session/__tests__/integration/prev-artifact-dag.test.js.map +1 -0
  146. package/dist/session/__tests__/integration/retention-archive.test.d.ts +12 -0
  147. package/dist/session/__tests__/integration/retention-archive.test.d.ts.map +1 -0
  148. package/dist/session/__tests__/integration/retention-archive.test.js +187 -0
  149. package/dist/session/__tests__/integration/retention-archive.test.js.map +1 -0
  150. package/dist/session/__tests__/integration/spawn-rollback.test.d.ts +26 -0
  151. package/dist/session/__tests__/integration/spawn-rollback.test.d.ts.map +1 -0
  152. package/dist/session/__tests__/integration/spawn-rollback.test.js +236 -0
  153. package/dist/session/__tests__/integration/spawn-rollback.test.js.map +1 -0
  154. package/dist/session/__tests__/integration/summary-materialization-e2e.test.d.ts +18 -0
  155. package/dist/session/__tests__/integration/summary-materialization-e2e.test.d.ts.map +1 -0
  156. package/dist/session/__tests__/integration/summary-materialization-e2e.test.js +201 -0
  157. package/dist/session/__tests__/integration/summary-materialization-e2e.test.js.map +1 -0
  158. package/dist/session/__tests__/integration/tenant-isolation.test.d.ts +14 -0
  159. package/dist/session/__tests__/integration/tenant-isolation.test.d.ts.map +1 -0
  160. package/dist/session/__tests__/integration/tenant-isolation.test.js +189 -0
  161. package/dist/session/__tests__/integration/tenant-isolation.test.js.map +1 -0
  162. package/dist/session/errors.d.ts +139 -0
  163. package/dist/session/errors.d.ts.map +1 -0
  164. package/dist/session/errors.js +107 -0
  165. package/dist/session/errors.js.map +1 -0
  166. package/dist/session/events/index.d.ts +4 -0
  167. package/dist/session/events/index.d.ts.map +1 -0
  168. package/dist/session/events/index.js +8 -0
  169. package/dist/session/events/index.js.map +1 -0
  170. package/dist/session/events/schema-version.d.ts +13 -0
  171. package/dist/session/events/schema-version.d.ts.map +1 -0
  172. package/dist/session/events/schema-version.js +12 -0
  173. package/dist/session/events/schema-version.js.map +1 -0
  174. package/dist/session/events/types.d.ts +64 -0
  175. package/dist/session/events/types.d.ts.map +1 -0
  176. package/dist/session/events/types.js +2 -0
  177. package/dist/session/events/types.js.map +1 -0
  178. package/dist/session/handoff/__tests__/broadcast.test.d.ts +2 -0
  179. package/dist/session/handoff/__tests__/broadcast.test.d.ts.map +1 -0
  180. package/dist/session/handoff/__tests__/broadcast.test.js +261 -0
  181. package/dist/session/handoff/__tests__/broadcast.test.js.map +1 -0
  182. package/dist/session/handoff/__tests__/capacity.test.d.ts +2 -0
  183. package/dist/session/handoff/__tests__/capacity.test.d.ts.map +1 -0
  184. package/dist/session/handoff/__tests__/capacity.test.js +103 -0
  185. package/dist/session/handoff/__tests__/capacity.test.js.map +1 -0
  186. package/dist/session/handoff/__tests__/single.test.d.ts +2 -0
  187. package/dist/session/handoff/__tests__/single.test.d.ts.map +1 -0
  188. package/dist/session/handoff/__tests__/single.test.js +239 -0
  189. package/dist/session/handoff/__tests__/single.test.js.map +1 -0
  190. package/dist/session/handoff/assignment.d.ts +71 -0
  191. package/dist/session/handoff/assignment.d.ts.map +1 -0
  192. package/dist/session/handoff/assignment.js +11 -0
  193. package/dist/session/handoff/assignment.js.map +1 -0
  194. package/dist/session/handoff/broadcast.d.ts +54 -0
  195. package/dist/session/handoff/broadcast.d.ts.map +1 -0
  196. package/dist/session/handoff/broadcast.js +311 -0
  197. package/dist/session/handoff/broadcast.js.map +1 -0
  198. package/dist/session/handoff/capacity.d.ts +66 -0
  199. package/dist/session/handoff/capacity.d.ts.map +1 -0
  200. package/dist/session/handoff/capacity.js +60 -0
  201. package/dist/session/handoff/capacity.js.map +1 -0
  202. package/dist/session/handoff/events.d.ts +66 -0
  203. package/dist/session/handoff/events.d.ts.map +1 -0
  204. package/dist/session/handoff/events.js +13 -0
  205. package/dist/session/handoff/events.js.map +1 -0
  206. package/dist/session/handoff/index.d.ts +12 -0
  207. package/dist/session/handoff/index.d.ts.map +1 -0
  208. package/dist/session/handoff/index.js +9 -0
  209. package/dist/session/handoff/index.js.map +1 -0
  210. package/dist/session/handoff/single.d.ts +69 -0
  211. package/dist/session/handoff/single.d.ts.map +1 -0
  212. package/dist/session/handoff/single.js +229 -0
  213. package/dist/session/handoff/single.js.map +1 -0
  214. package/dist/session/handoff/version.d.ts +52 -0
  215. package/dist/session/handoff/version.d.ts.map +1 -0
  216. package/dist/session/handoff/version.js +36 -0
  217. package/dist/session/handoff/version.js.map +1 -0
  218. package/dist/session/hierarchy/__tests__/session.test.d.ts +2 -0
  219. package/dist/session/hierarchy/__tests__/session.test.d.ts.map +1 -0
  220. package/dist/session/hierarchy/__tests__/session.test.js +69 -0
  221. package/dist/session/hierarchy/__tests__/session.test.js.map +1 -0
  222. package/dist/session/hierarchy/actor.d.ts +26 -0
  223. package/dist/session/hierarchy/actor.d.ts.map +1 -0
  224. package/dist/session/hierarchy/actor.js +2 -0
  225. package/dist/session/hierarchy/actor.js.map +1 -0
  226. package/dist/session/hierarchy/index.d.ts +9 -0
  227. package/dist/session/hierarchy/index.d.ts.map +1 -0
  228. package/dist/session/hierarchy/index.js +4 -0
  229. package/dist/session/hierarchy/index.js.map +1 -0
  230. package/dist/session/hierarchy/lineage.d.ts +15 -0
  231. package/dist/session/hierarchy/lineage.d.ts.map +1 -0
  232. package/dist/session/hierarchy/lineage.js +2 -0
  233. package/dist/session/hierarchy/lineage.js.map +1 -0
  234. package/dist/session/hierarchy/project.d.ts +40 -0
  235. package/dist/session/hierarchy/project.d.ts.map +1 -0
  236. package/dist/session/hierarchy/project.js +2 -0
  237. package/dist/session/hierarchy/project.js.map +1 -0
  238. package/dist/session/hierarchy/session.d.ts +71 -0
  239. package/dist/session/hierarchy/session.d.ts.map +1 -0
  240. package/dist/session/hierarchy/session.js +51 -0
  241. package/dist/session/hierarchy/session.js.map +1 -0
  242. package/dist/session/hierarchy/sub-session.d.ts +76 -0
  243. package/dist/session/hierarchy/sub-session.d.ts.map +1 -0
  244. package/dist/session/hierarchy/sub-session.js +2 -0
  245. package/dist/session/hierarchy/sub-session.js.map +1 -0
  246. package/dist/session/hierarchy/tenant.d.ts +13 -0
  247. package/dist/session/hierarchy/tenant.d.ts.map +1 -0
  248. package/dist/session/hierarchy/tenant.js +2 -0
  249. package/dist/session/hierarchy/tenant.js.map +1 -0
  250. package/dist/session/hierarchy/thread.d.ts +54 -0
  251. package/dist/session/hierarchy/thread.d.ts.map +1 -0
  252. package/dist/session/hierarchy/thread.js +2 -0
  253. package/dist/session/hierarchy/thread.js.map +1 -0
  254. package/dist/session/index.d.ts +10 -0
  255. package/dist/session/index.d.ts.map +1 -0
  256. package/dist/session/index.js +15 -0
  257. package/dist/session/index.js.map +1 -0
  258. package/dist/session/intervention/__tests__/prev-artifact.test.d.ts +2 -0
  259. package/dist/session/intervention/__tests__/prev-artifact.test.d.ts.map +1 -0
  260. package/dist/session/intervention/__tests__/prev-artifact.test.js +179 -0
  261. package/dist/session/intervention/__tests__/prev-artifact.test.js.map +1 -0
  262. package/dist/session/intervention/index.d.ts +3 -0
  263. package/dist/session/intervention/index.d.ts.map +1 -0
  264. package/dist/session/intervention/index.js +8 -0
  265. package/dist/session/intervention/index.js.map +1 -0
  266. package/dist/session/intervention/prev-artifact.d.ts +103 -0
  267. package/dist/session/intervention/prev-artifact.d.ts.map +1 -0
  268. package/dist/session/intervention/prev-artifact.js +112 -0
  269. package/dist/session/intervention/prev-artifact.js.map +1 -0
  270. package/dist/session/migration/__tests__/filesystem.test.d.ts +2 -0
  271. package/dist/session/migration/__tests__/filesystem.test.d.ts.map +1 -0
  272. package/dist/session/migration/__tests__/filesystem.test.js +188 -0
  273. package/dist/session/migration/__tests__/filesystem.test.js.map +1 -0
  274. package/dist/session/migration/__tests__/id-prefix.test.d.ts +2 -0
  275. package/dist/session/migration/__tests__/id-prefix.test.d.ts.map +1 -0
  276. package/dist/session/migration/__tests__/id-prefix.test.js +83 -0
  277. package/dist/session/migration/__tests__/id-prefix.test.js.map +1 -0
  278. package/dist/session/migration/__tests__/marker.test.d.ts +2 -0
  279. package/dist/session/migration/__tests__/marker.test.d.ts.map +1 -0
  280. package/dist/session/migration/__tests__/marker.test.js +75 -0
  281. package/dist/session/migration/__tests__/marker.test.js.map +1 -0
  282. package/dist/session/migration/errors.d.ts +26 -0
  283. package/dist/session/migration/errors.d.ts.map +1 -0
  284. package/dist/session/migration/errors.js +22 -0
  285. package/dist/session/migration/errors.js.map +1 -0
  286. package/dist/session/migration/filesystem.d.ts +94 -0
  287. package/dist/session/migration/filesystem.d.ts.map +1 -0
  288. package/dist/session/migration/filesystem.js +319 -0
  289. package/dist/session/migration/filesystem.js.map +1 -0
  290. package/dist/session/migration/id-prefix.d.ts +93 -0
  291. package/dist/session/migration/id-prefix.d.ts.map +1 -0
  292. package/dist/session/migration/id-prefix.js +111 -0
  293. package/dist/session/migration/id-prefix.js.map +1 -0
  294. package/dist/session/migration/index.d.ts +8 -0
  295. package/dist/session/migration/index.d.ts.map +1 -0
  296. package/dist/session/migration/index.js +8 -0
  297. package/dist/session/migration/index.js.map +1 -0
  298. package/dist/session/migration/marker.d.ts +57 -0
  299. package/dist/session/migration/marker.d.ts.map +1 -0
  300. package/dist/session/migration/marker.js +111 -0
  301. package/dist/session/migration/marker.js.map +1 -0
  302. package/dist/session/retention/__tests__/archive.test.d.ts +2 -0
  303. package/dist/session/retention/__tests__/archive.test.d.ts.map +1 -0
  304. package/dist/session/retention/__tests__/archive.test.js +253 -0
  305. package/dist/session/retention/__tests__/archive.test.js.map +1 -0
  306. package/dist/session/retention/__tests__/disk-backend.test.d.ts +2 -0
  307. package/dist/session/retention/__tests__/disk-backend.test.d.ts.map +1 -0
  308. package/dist/session/retention/__tests__/disk-backend.test.js +154 -0
  309. package/dist/session/retention/__tests__/disk-backend.test.js.map +1 -0
  310. package/dist/session/retention/archive-backend-ref.d.ts +18 -0
  311. package/dist/session/retention/archive-backend-ref.d.ts.map +1 -0
  312. package/dist/session/retention/archive-backend-ref.js +2 -0
  313. package/dist/session/retention/archive-backend-ref.js.map +1 -0
  314. package/dist/session/retention/archive.d.ts +130 -0
  315. package/dist/session/retention/archive.d.ts.map +1 -0
  316. package/dist/session/retention/archive.js +203 -0
  317. package/dist/session/retention/archive.js.map +1 -0
  318. package/dist/session/retention/backend.d.ts +101 -0
  319. package/dist/session/retention/backend.d.ts.map +1 -0
  320. package/dist/session/retention/backend.js +15 -0
  321. package/dist/session/retention/backend.js.map +1 -0
  322. package/dist/session/retention/disk-backend.d.ts +59 -0
  323. package/dist/session/retention/disk-backend.d.ts.map +1 -0
  324. package/dist/session/retention/disk-backend.js +236 -0
  325. package/dist/session/retention/disk-backend.js.map +1 -0
  326. package/dist/session/retention/index.d.ts +9 -0
  327. package/dist/session/retention/index.d.ts.map +1 -0
  328. package/dist/session/retention/index.js +6 -0
  329. package/dist/session/retention/index.js.map +1 -0
  330. package/dist/session/retention/policy.d.ts +49 -0
  331. package/dist/session/retention/policy.d.ts.map +1 -0
  332. package/dist/session/retention/policy.js +21 -0
  333. package/dist/session/retention/policy.js.map +1 -0
  334. package/dist/session/summary/__tests__/materialize.test.d.ts +2 -0
  335. package/dist/session/summary/__tests__/materialize.test.d.ts.map +1 -0
  336. package/dist/session/summary/__tests__/materialize.test.js +270 -0
  337. package/dist/session/summary/__tests__/materialize.test.js.map +1 -0
  338. package/dist/session/summary/deliverable.d.ts +74 -0
  339. package/dist/session/summary/deliverable.d.ts.map +1 -0
  340. package/dist/session/summary/deliverable.js +20 -0
  341. package/dist/session/summary/deliverable.js.map +1 -0
  342. package/dist/session/summary/index.d.ts +6 -0
  343. package/dist/session/summary/index.d.ts.map +1 -0
  344. package/dist/session/summary/index.js +9 -0
  345. package/dist/session/summary/index.js.map +1 -0
  346. package/dist/session/summary/materialize.d.ts +82 -0
  347. package/dist/session/summary/materialize.d.ts.map +1 -0
  348. package/dist/session/summary/materialize.js +117 -0
  349. package/dist/session/summary/materialize.js.map +1 -0
  350. package/dist/session/summary/ref.d.ts +91 -0
  351. package/dist/session/summary/ref.d.ts.map +1 -0
  352. package/dist/session/summary/ref.js +51 -0
  353. package/dist/session/summary/ref.js.map +1 -0
  354. package/dist/session/workspace/__tests__/git-worktree.test.d.ts +2 -0
  355. package/dist/session/workspace/__tests__/git-worktree.test.d.ts.map +1 -0
  356. package/dist/session/workspace/__tests__/git-worktree.test.js +244 -0
  357. package/dist/session/workspace/__tests__/git-worktree.test.js.map +1 -0
  358. package/dist/session/workspace/__tests__/path-builder.test.d.ts +2 -0
  359. package/dist/session/workspace/__tests__/path-builder.test.d.ts.map +1 -0
  360. package/dist/session/workspace/__tests__/path-builder.test.js +37 -0
  361. package/dist/session/workspace/__tests__/path-builder.test.js.map +1 -0
  362. package/dist/session/workspace/driver.d.ts +55 -0
  363. package/dist/session/workspace/driver.d.ts.map +1 -0
  364. package/dist/session/workspace/driver.js +12 -0
  365. package/dist/session/workspace/driver.js.map +1 -0
  366. package/dist/session/workspace/git-worktree.d.ts +65 -0
  367. package/dist/session/workspace/git-worktree.d.ts.map +1 -0
  368. package/dist/session/workspace/git-worktree.js +156 -0
  369. package/dist/session/workspace/git-worktree.js.map +1 -0
  370. package/dist/session/workspace/index.d.ts +8 -0
  371. package/dist/session/workspace/index.d.ts.map +1 -0
  372. package/dist/session/workspace/index.js +7 -0
  373. package/dist/session/workspace/index.js.map +1 -0
  374. package/dist/session/workspace/path-builder.d.ts +50 -0
  375. package/dist/session/workspace/path-builder.d.ts.map +1 -0
  376. package/dist/session/workspace/path-builder.js +50 -0
  377. package/dist/session/workspace/path-builder.js.map +1 -0
  378. package/dist/session/workspace/ref.d.ts +46 -0
  379. package/dist/session/workspace/ref.d.ts.map +1 -0
  380. package/dist/session/workspace/ref.js +11 -0
  381. package/dist/session/workspace/ref.js.map +1 -0
  382. package/dist/session/workspace/registry.d.ts +26 -0
  383. package/dist/session/workspace/registry.d.ts.map +1 -0
  384. package/dist/session/workspace/registry.js +35 -0
  385. package/dist/session/workspace/registry.js.map +1 -0
  386. package/dist/store/index.d.ts +0 -2
  387. package/dist/store/index.d.ts.map +1 -1
  388. package/dist/store/index.js +0 -1
  389. package/dist/store/index.js.map +1 -1
  390. package/dist/store/session/__tests__/disk.test.d.ts +2 -0
  391. package/dist/store/session/__tests__/disk.test.d.ts.map +1 -0
  392. package/dist/store/session/__tests__/disk.test.js +267 -0
  393. package/dist/store/session/__tests__/disk.test.js.map +1 -0
  394. package/dist/store/session/__tests__/memory.test.d.ts +2 -0
  395. package/dist/store/session/__tests__/memory.test.d.ts.map +1 -0
  396. package/dist/store/session/__tests__/memory.test.js +258 -0
  397. package/dist/store/session/__tests__/memory.test.js.map +1 -0
  398. package/dist/store/session/disk.d.ts +86 -0
  399. package/dist/store/session/disk.d.ts.map +1 -0
  400. package/dist/store/session/disk.js +818 -0
  401. package/dist/store/session/disk.js.map +1 -0
  402. package/dist/store/session/index.d.ts +7 -0
  403. package/dist/store/session/index.d.ts.map +1 -0
  404. package/dist/store/session/index.js +10 -0
  405. package/dist/store/session/index.js.map +1 -0
  406. package/dist/store/session/linkage.d.ts +38 -0
  407. package/dist/store/session/linkage.d.ts.map +1 -0
  408. package/dist/store/session/linkage.js +64 -0
  409. package/dist/store/session/linkage.js.map +1 -0
  410. package/dist/store/session/memory.d.ts +49 -0
  411. package/dist/store/session/memory.d.ts.map +1 -0
  412. package/dist/store/session/memory.js +335 -0
  413. package/dist/store/session/memory.js.map +1 -0
  414. package/dist/store/session/messages.d.ts +20 -0
  415. package/dist/store/session/messages.d.ts.map +1 -0
  416. package/dist/store/session/messages.js +12 -0
  417. package/dist/store/session/messages.js.map +1 -0
  418. package/dist/store/thread/disk.d.ts +41 -0
  419. package/dist/store/thread/disk.d.ts.map +1 -0
  420. package/dist/store/thread/disk.js +229 -0
  421. package/dist/store/thread/disk.js.map +1 -0
  422. package/dist/store/thread/index.d.ts +4 -0
  423. package/dist/store/thread/index.d.ts.map +1 -0
  424. package/dist/store/thread/index.js +6 -0
  425. package/dist/store/thread/index.js.map +1 -0
  426. package/dist/store/thread/memory.d.ts +23 -0
  427. package/dist/store/thread/memory.d.ts.map +1 -0
  428. package/dist/store/thread/memory.js +90 -0
  429. package/dist/store/thread/memory.js.map +1 -0
  430. package/dist/tools/builtins/__tests__/structuredOutput.example.d.ts +1 -1
  431. package/dist/types/agent/base.d.ts +24 -1
  432. package/dist/types/agent/base.d.ts.map +1 -1
  433. package/dist/types/agent/factory.d.ts +8 -2
  434. package/dist/types/agent/factory.d.ts.map +1 -1
  435. package/dist/types/agent/task.d.ts +57 -2
  436. package/dist/types/agent/task.d.ts.map +1 -1
  437. package/dist/types/agent/task.js.map +1 -1
  438. package/dist/types/ids/index.d.ts +22 -3
  439. package/dist/types/ids/index.d.ts.map +1 -1
  440. package/dist/types/ids/index.js +8 -1
  441. package/dist/types/ids/index.js.map +1 -1
  442. package/dist/types/invocation/__tests__/state.test.js +36 -29
  443. package/dist/types/invocation/__tests__/state.test.js.map +1 -1
  444. package/dist/types/invocation/index.d.ts +20 -4
  445. package/dist/types/invocation/index.d.ts.map +1 -1
  446. package/dist/types/invocation/index.js +10 -7
  447. package/dist/types/invocation/index.js.map +1 -1
  448. package/dist/types/rag/retrieval.d.ts +4 -3
  449. package/dist/types/rag/retrieval.d.ts.map +1 -1
  450. package/dist/types/run/config.d.ts +12 -1
  451. package/dist/types/run/config.d.ts.map +1 -1
  452. package/dist/types/run/events.d.ts +26 -1
  453. package/dist/types/run/events.d.ts.map +1 -1
  454. package/dist/types/run/index.d.ts.map +1 -1
  455. package/dist/types/run/index.js +8 -0
  456. package/dist/types/run/index.js.map +1 -1
  457. package/dist/types/run/metadata.d.ts +12 -2
  458. package/dist/types/run/metadata.d.ts.map +1 -1
  459. package/dist/types/run/status.d.ts +26 -0
  460. package/dist/types/run/status.d.ts.map +1 -0
  461. package/dist/types/run/status.js +2 -0
  462. package/dist/types/run/status.js.map +1 -0
  463. package/dist/types/session/ids.d.ts +9 -0
  464. package/dist/types/session/ids.d.ts.map +1 -0
  465. package/dist/types/session/ids.js +9 -0
  466. package/dist/types/session/ids.js.map +1 -0
  467. package/dist/types/session/index.d.ts +3 -0
  468. package/dist/types/session/index.d.ts.map +1 -0
  469. package/dist/types/session/index.js +5 -0
  470. package/dist/types/session/index.js.map +1 -0
  471. package/dist/types/session/store.d.ts +210 -0
  472. package/dist/types/session/store.d.ts.map +1 -0
  473. package/dist/types/session/store.js +9 -0
  474. package/dist/types/session/store.js.map +1 -0
  475. package/dist/types/thread/index.d.ts +2 -0
  476. package/dist/types/thread/index.d.ts.map +1 -0
  477. package/dist/types/thread/index.js +5 -0
  478. package/dist/types/thread/index.js.map +1 -0
  479. package/dist/types/thread/store.d.ts +86 -0
  480. package/dist/types/thread/store.d.ts.map +1 -0
  481. package/dist/types/thread/store.js +22 -0
  482. package/dist/types/thread/store.js.map +1 -0
  483. package/dist/utils/id.d.ts +8 -2
  484. package/dist/utils/id.d.ts.map +1 -1
  485. package/dist/utils/id.js +22 -4
  486. package/dist/utils/id.js.map +1 -1
  487. package/package.json +6 -11
  488. package/src/agents/ReactiveAgent.ts +7 -2
  489. package/src/agents/RouterAgent.ts +5 -0
  490. package/src/agents/SupervisorAgent.ts +29 -6
  491. package/src/bridge/a2a/index.ts +0 -1
  492. package/src/bridge/a2a/mapper.ts +7 -0
  493. package/src/bridge/a2a/message.ts +0 -32
  494. package/src/bridge/a2a/task.ts +9 -8
  495. package/src/bridge/sse/mapper.ts +8 -1
  496. package/src/constants/a2a/index.ts +2 -2
  497. package/src/contracts/api.ts +14 -30
  498. package/src/contracts/ids.ts +1 -1
  499. package/src/contracts/index.ts +3 -7
  500. package/src/contracts/schemas.ts +1 -8
  501. package/src/gateway/local.ts +6 -0
  502. package/src/index.ts +14 -4
  503. package/src/manager/agent/__tests__/lifecycle.test.ts +473 -0
  504. package/src/manager/agent/lifecycle.ts +515 -21
  505. package/src/manager/index.ts +3 -0
  506. package/src/manager/run/persistence.ts +26 -1
  507. package/src/manager/thread/__tests__/lifecycle.test.ts +286 -0
  508. package/src/manager/thread/lifecycle.ts +217 -0
  509. package/src/rag/retriever.ts +2 -2
  510. package/src/run/reporter.ts +28 -0
  511. package/src/runtime/query/__tests__/context.test.ts +102 -0
  512. package/src/runtime/query/context-cache.ts +4 -4
  513. package/src/runtime/query/context.ts +98 -9
  514. package/src/runtime/query/events.ts +8 -0
  515. package/src/runtime/query/index.ts +38 -1
  516. package/src/session/__tests__/integration/_fixtures.ts +310 -0
  517. package/src/session/__tests__/integration/archive-gate.test.ts +288 -0
  518. package/src/session/__tests__/integration/capacity-caps.test.ts +171 -0
  519. package/src/session/__tests__/integration/e2e-spawn.test.ts +296 -0
  520. package/src/session/__tests__/integration/event-stream-ordering.test.ts +410 -0
  521. package/src/session/__tests__/integration/handoff-broadcast-e2e.test.ts +271 -0
  522. package/src/session/__tests__/integration/handoff-illegal-transition.test.ts +214 -0
  523. package/src/session/__tests__/integration/handoff-single-e2e.test.ts +251 -0
  524. package/src/session/__tests__/integration/hierarchy-lifecycle.test.ts +240 -0
  525. package/src/session/__tests__/integration/migration-filesystem.test.ts +209 -0
  526. package/src/session/__tests__/integration/migration-id-prefix.test.ts +101 -0
  527. package/src/session/__tests__/integration/prev-artifact-dag.test.ts +325 -0
  528. package/src/session/__tests__/integration/retention-archive.test.ts +233 -0
  529. package/src/session/__tests__/integration/spawn-rollback.test.ts +313 -0
  530. package/src/session/__tests__/integration/summary-materialization-e2e.test.ts +239 -0
  531. package/src/session/__tests__/integration/tenant-isolation.test.ts +292 -0
  532. package/src/session/errors.ts +159 -0
  533. package/src/session/events/index.ts +16 -0
  534. package/src/session/events/schema-version.ts +13 -0
  535. package/src/session/events/types.ts +71 -0
  536. package/src/session/handoff/__tests__/broadcast.test.ts +378 -0
  537. package/src/session/handoff/__tests__/capacity.test.ts +129 -0
  538. package/src/session/handoff/__tests__/single.test.ts +333 -0
  539. package/src/session/handoff/assignment.ts +74 -0
  540. package/src/session/handoff/broadcast.ts +406 -0
  541. package/src/session/handoff/capacity.ts +121 -0
  542. package/src/session/handoff/events.ts +72 -0
  543. package/src/session/handoff/index.ts +29 -0
  544. package/src/session/handoff/single.ts +310 -0
  545. package/src/session/handoff/version.ts +59 -0
  546. package/src/session/hierarchy/__tests__/session.test.ts +100 -0
  547. package/src/session/hierarchy/actor.ts +17 -0
  548. package/src/session/hierarchy/index.ts +18 -0
  549. package/src/session/hierarchy/lineage.ts +15 -0
  550. package/src/session/hierarchy/project.ts +41 -0
  551. package/src/session/hierarchy/session.ts +109 -0
  552. package/src/session/hierarchy/sub-session.ts +92 -0
  553. package/src/session/hierarchy/tenant.ts +13 -0
  554. package/src/session/hierarchy/thread.ts +55 -0
  555. package/src/session/index.ts +15 -0
  556. package/src/session/intervention/__tests__/prev-artifact.test.ts +234 -0
  557. package/src/session/intervention/index.ts +16 -0
  558. package/src/session/intervention/prev-artifact.ts +180 -0
  559. package/src/session/migration/__tests__/filesystem.test.ts +263 -0
  560. package/src/session/migration/__tests__/id-prefix.test.ts +101 -0
  561. package/src/session/migration/__tests__/marker.test.ts +84 -0
  562. package/src/session/migration/errors.ts +23 -0
  563. package/src/session/migration/filesystem.ts +401 -0
  564. package/src/session/migration/id-prefix.ts +141 -0
  565. package/src/session/migration/index.ts +38 -0
  566. package/src/session/migration/marker.ts +131 -0
  567. package/src/session/retention/__tests__/archive.test.ts +318 -0
  568. package/src/session/retention/__tests__/disk-backend.test.ts +180 -0
  569. package/src/session/retention/archive-backend-ref.ts +17 -0
  570. package/src/session/retention/archive.ts +281 -0
  571. package/src/session/retention/backend.ts +107 -0
  572. package/src/session/retention/disk-backend.ts +304 -0
  573. package/src/session/retention/index.ts +16 -0
  574. package/src/session/retention/policy.ts +53 -0
  575. package/src/session/summary/__tests__/materialize.test.ts +343 -0
  576. package/src/session/summary/deliverable.ts +84 -0
  577. package/src/session/summary/index.ts +31 -0
  578. package/src/session/summary/materialize.ts +169 -0
  579. package/src/session/summary/ref.ts +104 -0
  580. package/src/session/workspace/__tests__/git-worktree.test.ts +258 -0
  581. package/src/session/workspace/__tests__/path-builder.test.ts +51 -0
  582. package/src/session/workspace/driver.ts +60 -0
  583. package/src/session/workspace/git-worktree.ts +209 -0
  584. package/src/session/workspace/index.ts +25 -0
  585. package/src/session/workspace/path-builder.ts +71 -0
  586. package/src/session/workspace/ref.ts +50 -0
  587. package/src/session/workspace/registry.ts +42 -0
  588. package/src/store/index.ts +0 -3
  589. package/src/store/session/__tests__/disk.test.ts +397 -0
  590. package/src/store/session/__tests__/memory.test.ts +402 -0
  591. package/src/store/session/disk.ts +976 -0
  592. package/src/store/session/index.ts +13 -0
  593. package/src/store/session/linkage.ts +80 -0
  594. package/src/store/session/memory.ts +412 -0
  595. package/src/store/session/messages.ts +21 -0
  596. package/src/store/thread/disk.ts +261 -0
  597. package/src/store/thread/index.ts +7 -0
  598. package/src/store/thread/memory.ts +104 -0
  599. package/src/types/agent/base.ts +27 -1
  600. package/src/types/agent/factory.ts +8 -3
  601. package/src/types/agent/task.ts +66 -2
  602. package/src/types/ids/index.ts +34 -3
  603. package/src/types/invocation/__tests__/state.test.ts +37 -29
  604. package/src/types/invocation/index.ts +26 -10
  605. package/src/types/rag/retrieval.ts +4 -3
  606. package/src/types/run/config.ts +13 -1
  607. package/src/types/run/events.ts +36 -1
  608. package/src/types/run/index.ts +8 -0
  609. package/src/types/run/metadata.ts +12 -2
  610. package/src/types/run/status.ts +33 -0
  611. package/src/types/session/ids.ts +23 -0
  612. package/src/types/session/index.ts +27 -0
  613. package/src/types/session/store.ts +252 -0
  614. package/src/types/thread/index.ts +5 -0
  615. package/src/types/thread/store.ts +92 -0
  616. package/src/utils/id.ts +34 -4
  617. package/dist/store/conversation/memory.d.ts +0 -21
  618. package/dist/store/conversation/memory.d.ts.map +0 -1
  619. package/dist/store/conversation/memory.js +0 -86
  620. package/dist/store/conversation/memory.js.map +0 -1
  621. package/dist/types/conversation/index.d.ts +0 -7
  622. package/dist/types/conversation/index.d.ts.map +0 -1
  623. package/dist/types/conversation/index.js +0 -2
  624. package/dist/types/conversation/index.js.map +0 -1
  625. package/src/store/conversation/memory.ts +0 -121
  626. package/src/types/conversation/index.ts +0 -8
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Shared test fixtures for the Task 10 integration coverage matrix.
3
+ *
4
+ * Factors out the `AgentManager` + `SessionStore` + `WorkspaceBackendRegistry`
5
+ * + `SessionSummaryMaterializer` + `DefaultCapacityValidator` wiring that
6
+ * every integration test rebuilds. Keeping this in an underscore-prefixed
7
+ * internal module (Convention #4: `_fixtures.ts` does not bleed into any
8
+ * barrel) lets the 11 integration files focus on invariant assertions rather
9
+ * than boilerplate.
10
+ *
11
+ * DO NOT export from `src/session/index.ts` or any other public barrel.
12
+ * This module is test-only and has no runtime consumers.
13
+ */
14
+
15
+ import { vi } from 'vitest'
16
+ import { EMPTY_TOKEN_USAGE } from '../../../constants/limits.js'
17
+ import { AgentManager } from '../../../manager/agent/lifecycle.js'
18
+ import { ThreadManager } from '../../../manager/thread/lifecycle.js'
19
+ import { AgentRegistry } from '../../../registry/agent/definitions.js'
20
+ import { InMemorySessionStore } from '../../../store/session/memory.js'
21
+ import { InMemoryThreadStore } from '../../../store/thread/memory.js'
22
+ import type {
23
+ AgentCapabilities,
24
+ AgentInput,
25
+ BaseAgentConfig,
26
+ BaseAgentResult,
27
+ } from '../../../types/agent/base.js'
28
+ import type { Agent } from '../../../types/agent/core.js'
29
+ import type { AgentDefinition } from '../../../types/agent/factory.js'
30
+ import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/task.js'
31
+ import type { AgentId, RunId, SessionId, TenantId, UserId } from '../../../types/ids/index.js'
32
+ import { createAssistantMessage } from '../../../types/message/index.js'
33
+ import type { ProjectId, SummaryId, ThreadId } from '../../../types/session/ids.js'
34
+ import { ZERO_COST } from '../../../utils/cost.js'
35
+ import { DefaultCapacityValidator } from '../../handoff/capacity.js'
36
+ import type { ActorRef } from '../../hierarchy/actor.js'
37
+ import type { Session } from '../../hierarchy/session.js'
38
+ import { SessionSummaryMaterializer } from '../../summary/materialize.js'
39
+ import type { ExecFile, ExecFileResult } from '../../workspace/git-worktree.js'
40
+ import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
41
+ import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
42
+
43
+ export const DEFAULT_TENANT = 'tnt_alpha' as TenantId
44
+ export const OTHER_TENANT = 'tnt_beta' as TenantId
45
+
46
+ export function stubLogger() {
47
+ return {
48
+ debug: vi.fn(),
49
+ info: vi.fn(),
50
+ warn: vi.fn(),
51
+ error: vi.fn(),
52
+ child() {
53
+ return stubLogger()
54
+ },
55
+ }
56
+ }
57
+
58
+ export function okExec(stdout = '', stderr = ''): ExecFileResult {
59
+ return { stdout, stderr }
60
+ }
61
+
62
+ export function userActor(userId: string, tenantId: TenantId = DEFAULT_TENANT): ActorRef {
63
+ return { kind: 'user', userId: userId as UserId, tenantId }
64
+ }
65
+
66
+ export function agentActor(agentId: string, tenantId: TenantId = DEFAULT_TENANT): ActorRef {
67
+ return { kind: 'agent', agentId: agentId as AgentId, tenantId }
68
+ }
69
+
70
+ const BASE_CAPABILITIES: AgentCapabilities = {
71
+ supportsTools: false,
72
+ supportsStreaming: false,
73
+ supportsConcurrency: false,
74
+ supportsSubAgents: false,
75
+ }
76
+
77
+ /**
78
+ * Builds a minimal {@link Agent} whose `run` produces a deterministic
79
+ * assistant message. Tests that need custom output shape override via
80
+ * {@link buildAgentCustom}.
81
+ */
82
+ export function buildAgent(
83
+ id: string,
84
+ result = 'child did the work',
85
+ ): Agent<BaseAgentConfig, BaseAgentResult> {
86
+ return {
87
+ type: 'reactive',
88
+ metadata: {
89
+ type: 'reactive',
90
+ id,
91
+ name: id,
92
+ version: '1.0.0',
93
+ category: 'test',
94
+ description: id,
95
+ capabilities: BASE_CAPABILITIES,
96
+ },
97
+ run: async (_input: AgentInput, _config: BaseAgentConfig): Promise<BaseAgentResult> => ({
98
+ runId: `run_${id}_result` as RunId,
99
+ status: 'completed',
100
+ usage: { ...EMPTY_TOKEN_USAGE },
101
+ cost: { ...ZERO_COST },
102
+ iterations: 1,
103
+ durationMs: 1,
104
+ messages: [createAssistantMessage(result)],
105
+ result,
106
+ }),
107
+ cancel: async () => undefined,
108
+ getCapabilities: () => BASE_CAPABILITIES,
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Builds an agent with a caller-supplied `run`. Useful for tests that need
114
+ * to simulate failures or spawn cascading agents.
115
+ */
116
+ export function buildAgentCustom(
117
+ id: string,
118
+ run: Agent<BaseAgentConfig, BaseAgentResult>['run'],
119
+ ): Agent<BaseAgentConfig, BaseAgentResult> {
120
+ return {
121
+ type: 'reactive',
122
+ metadata: {
123
+ type: 'reactive',
124
+ id,
125
+ name: id,
126
+ version: '1.0.0',
127
+ category: 'test',
128
+ description: id,
129
+ capabilities: BASE_CAPABILITIES,
130
+ },
131
+ run,
132
+ cancel: async () => undefined,
133
+ getCapabilities: () => BASE_CAPABILITIES,
134
+ }
135
+ }
136
+
137
+ export function buildDefinition(agent: Agent<BaseAgentConfig, BaseAgentResult>): AgentDefinition {
138
+ return {
139
+ info: {
140
+ id: agent.metadata.id,
141
+ name: agent.metadata.name,
142
+ version: agent.metadata.version,
143
+ category: agent.metadata.category,
144
+ description: agent.metadata.description,
145
+ tools: [],
146
+ defaults: { model: 'test', tokenBudget: 1_000 },
147
+ },
148
+ typedAgent: agent,
149
+ }
150
+ }
151
+
152
+ export interface IntegrationHarness {
153
+ readonly store: InMemorySessionStore
154
+ readonly threadStore: InMemoryThreadStore
155
+ readonly threadManager: ThreadManager
156
+ readonly registry: AgentRegistry
157
+ readonly manager: AgentManager
158
+ readonly materializer: SessionSummaryMaterializer
159
+ readonly workspaceRegistry: WorkspaceBackendRegistry
160
+ readonly capacity: DefaultCapacityValidator
161
+ readonly tenantId: TenantId
162
+ }
163
+
164
+ export interface IntegrationHarnessOptions {
165
+ readonly tenantId?: TenantId
166
+ /** Pass `true` to register a no-op stubbed git-worktree driver. */
167
+ readonly withWorktreeDriver?: boolean
168
+ readonly execFile?: ExecFile
169
+ /**
170
+ * Deterministic summary ID generator — defaults to `sum_test_<n>`. Tests
171
+ * asserting on the exact id should override.
172
+ */
173
+ readonly summaryIdGenerator?: () => SummaryId
174
+ }
175
+
176
+ /**
177
+ * Builds a full AgentManager + SessionStore + Materializer harness wired with
178
+ * real components (not mocks). The `GitWorktreeDriver` uses a stubbed
179
+ * `execFile` that returns empty stdout by default — tests exercising failure
180
+ * modes inject a real {@link ExecFile}.
181
+ */
182
+ export function buildHarness(options: IntegrationHarnessOptions = {}): IntegrationHarness {
183
+ const tenantId = options.tenantId ?? DEFAULT_TENANT
184
+ const store = new InMemorySessionStore()
185
+ const threadStore = new InMemoryThreadStore()
186
+
187
+ const workspaceRegistry = new WorkspaceBackendRegistry()
188
+ if (options.withWorktreeDriver !== false) {
189
+ const exec: ExecFile = options.execFile ?? (async () => okExec())
190
+ const driver = new GitWorktreeDriver({
191
+ repoRoot: '/repo',
192
+ logger: stubLogger(),
193
+ execFile: exec,
194
+ })
195
+ workspaceRegistry.register(driver)
196
+ }
197
+
198
+ let counter = 0
199
+ const generateSummaryId =
200
+ options.summaryIdGenerator ?? (() => `sum_test_${++counter}` as SummaryId)
201
+
202
+ const materializer = new SessionSummaryMaterializer({
203
+ store,
204
+ generateSummaryId,
205
+ })
206
+
207
+ const capacity = new DefaultCapacityValidator(store)
208
+ const threadManager = new ThreadManager({ threadStore, sessionStore: store })
209
+ const registry = new AgentRegistry()
210
+ const manager = new AgentManager(registry, undefined, {
211
+ sessionStore: store,
212
+ summaryMaterializer: materializer,
213
+ workspaceRegistry,
214
+ capacity,
215
+ threadManager,
216
+ })
217
+
218
+ return {
219
+ store,
220
+ threadStore,
221
+ threadManager,
222
+ registry,
223
+ manager,
224
+ materializer,
225
+ workspaceRegistry,
226
+ capacity,
227
+ tenantId,
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Seeds a Tenant → Project → Thread → Session quadruple and flips the session
233
+ * into `active` so it is a legal spawn parent. Returns the project, thread,
234
+ * and active session for the caller to drive spawns against.
235
+ */
236
+ export async function seedActiveParent(
237
+ harness: IntegrationHarness,
238
+ options?: {
239
+ actor?: ActorRef
240
+ projectName?: string
241
+ tenantId?: TenantId
242
+ threadTitle?: string
243
+ },
244
+ ) {
245
+ const tenantId = options?.tenantId ?? harness.tenantId
246
+ const actor: ActorRef = options?.actor ?? userActor('usr_root', tenantId)
247
+ const project = await harness.store.createProject(
248
+ { tenantId, name: options?.projectName ?? 'integration-project' },
249
+ tenantId,
250
+ )
251
+ const thread = await harness.threadStore.createThread(
252
+ { projectId: project.id, title: options?.threadTitle ?? 'default' },
253
+ tenantId,
254
+ )
255
+ const session = await harness.store.createSession(
256
+ { threadId: thread.id, projectId: project.id, currentActor: actor },
257
+ tenantId,
258
+ )
259
+ await harness.store.updateSession({ ...session, status: 'active' as Session['status'] }, tenantId)
260
+ return { project, thread, session, actor }
261
+ }
262
+
263
+ /**
264
+ * Constructs a fully populated {@link AgentTaskContext} bound to the supplied
265
+ * parent session + actor. Tests override individual fields (depth, budget)
266
+ * by merging.
267
+ */
268
+ export function buildTaskContext(params: {
269
+ sessionId: SessionId
270
+ projectId: ProjectId
271
+ threadId: ThreadId
272
+ tenantId: TenantId
273
+ parentActor: ActorRef
274
+ depth?: number
275
+ budget?: number
276
+ parentRunId?: RunId
277
+ }): AgentTaskContext {
278
+ return {
279
+ parentRunId: params.parentRunId ?? ('run_parent' as RunId),
280
+ parentAgentId: 'supervisor',
281
+ parentAbortController: new AbortController(),
282
+ depth: params.depth ?? 0,
283
+ budgetTracker: {
284
+ total: params.budget ?? 100_000,
285
+ remaining: params.budget ?? 100_000,
286
+ },
287
+ tenantId: params.tenantId,
288
+ threadId: params.threadId,
289
+ sessionId: params.sessionId,
290
+ projectId: params.projectId,
291
+ parentActor: params.parentActor,
292
+ }
293
+ }
294
+
295
+ export function buildSendMessageOptions(params: {
296
+ agentId: string
297
+ parentSessionId: SessionId
298
+ projectId: ProjectId
299
+ tenantId: TenantId
300
+ parentActor: ActorRef
301
+ }): SendMessageOptions {
302
+ return {
303
+ agentId: params.agentId,
304
+ input: { messages: [], workingDirectory: '/tmp' },
305
+ parentSessionId: params.parentSessionId,
306
+ tenantId: params.tenantId,
307
+ projectId: params.projectId,
308
+ parentActor: params.parentActor,
309
+ }
310
+ }
@@ -0,0 +1,288 @@
1
+ /**
2
+ * Integration — Thread archive gate enforced at session-creation ingress
3
+ * sites (Phase 2.6).
4
+ *
5
+ * The Phase 2.5 commit flagged this as a known gap:
6
+ * > spawn and handoff paths do not yet invoke `ThreadManager.requireOpen`
7
+ * > before creating a child session. Until they do, the archive invariant
8
+ * > is best-effort.
9
+ *
10
+ * Phase 2.6 wires `requireOpen` into `AgentManager.provisionSpawn` + both
11
+ * handoff flows. These tests drive the archived-thread-then-attempt-creation
12
+ * scenarios end-to-end against the real stack.
13
+ */
14
+
15
+ import { describe, expect, it, vi } from 'vitest'
16
+ import { ThreadManager } from '../../../manager/thread/lifecycle.js'
17
+ import { InMemorySessionStore } from '../../../store/session/memory.js'
18
+ import { InMemoryThreadStore } from '../../../store/thread/memory.js'
19
+ import type { AgentId, RunId, UserId } from '../../../types/ids/index.js'
20
+ import { generateHandoffId } from '../../../utils/id.js'
21
+ import { ThreadClosedError } from '../../errors.js'
22
+ import type { HandoffAssignment } from '../../handoff/assignment.js'
23
+ import { type BroadcastHandoffDeps, executeBroadcastHandoff } from '../../handoff/broadcast.js'
24
+ import { DefaultCapacityValidator } from '../../handoff/capacity.js'
25
+ import type { HandoffEventSink } from '../../handoff/events.js'
26
+ import { type SingleHandoffDeps, executeSingleHandoff } from '../../handoff/single.js'
27
+ import type { ActorRef } from '../../hierarchy/actor.js'
28
+ import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
29
+ import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
30
+ import {
31
+ DEFAULT_TENANT,
32
+ buildAgent,
33
+ buildDefinition,
34
+ buildHarness,
35
+ buildSendMessageOptions,
36
+ buildTaskContext,
37
+ okExec,
38
+ seedActiveParent,
39
+ stubLogger,
40
+ userActor,
41
+ } from './_fixtures.js'
42
+
43
+ describe('Integration — archive gate (Phase 2.6)', () => {
44
+ it('AgentManager spawn: rejects with ThreadClosedError when parent thread is archived', async () => {
45
+ const harness = buildHarness()
46
+ const { project, thread, session, actor } = await seedActiveParent(harness)
47
+
48
+ // Archive the thread via the manager so the invariant is enforced — no
49
+ // in-flight sessions under this thread, so archive succeeds.
50
+ await harness.store.updateSession({ ...session, status: 'idle' }, DEFAULT_TENANT)
51
+ await harness.threadManager.archive(thread.id, DEFAULT_TENANT)
52
+ // Flip session back to active so the spawn's capacity path reaches
53
+ // provisionSpawn (the archive gate should still reject).
54
+ await harness.store.updateSession({ ...session, status: 'active' }, DEFAULT_TENANT)
55
+
56
+ harness.registry.register(buildDefinition(buildAgent('worker')))
57
+
58
+ await expect(
59
+ harness.manager.sendMessage(
60
+ buildSendMessageOptions({
61
+ agentId: 'worker',
62
+ parentSessionId: session.id,
63
+ projectId: project.id,
64
+ tenantId: DEFAULT_TENANT,
65
+ parentActor: actor,
66
+ }),
67
+ buildTaskContext({
68
+ sessionId: session.id,
69
+ projectId: project.id,
70
+ threadId: thread.id,
71
+ tenantId: DEFAULT_TENANT,
72
+ parentActor: actor,
73
+ }),
74
+ ),
75
+ ).rejects.toBeInstanceOf(ThreadClosedError)
76
+
77
+ // Archive invariant held: no new child sessions under the archived thread.
78
+ const underThread = await harness.store.listSessions(thread.id, DEFAULT_TENANT)
79
+ expect(underThread).toHaveLength(1)
80
+ expect(underThread[0]?.id).toBe(session.id)
81
+ })
82
+
83
+ it('Single handoff: rejects with ThreadClosedError when thread is archived (before CAS lock)', async () => {
84
+ const store = new InMemorySessionStore()
85
+ const threadStore = new InMemoryThreadStore()
86
+ const project = await store.createProject(
87
+ { tenantId: DEFAULT_TENANT, name: 'archive-single' },
88
+ DEFAULT_TENANT,
89
+ )
90
+ const thread = await threadStore.createThread(
91
+ { projectId: project.id, title: 'archive-single' },
92
+ DEFAULT_TENANT,
93
+ )
94
+ const sourceActor: ActorRef = {
95
+ kind: 'user',
96
+ userId: 'usr_source' as UserId,
97
+ tenantId: DEFAULT_TENANT,
98
+ }
99
+ const session = await store.createSession(
100
+ { threadId: thread.id, projectId: project.id, currentActor: sourceActor },
101
+ DEFAULT_TENANT,
102
+ )
103
+
104
+ // Archive the thread directly — session is idle, so archive precondition
105
+ // holds via listSessions.
106
+ const threadManager = new ThreadManager({ threadStore, sessionStore: store })
107
+ await threadManager.archive(thread.id, DEFAULT_TENANT)
108
+
109
+ const driver = new GitWorktreeDriver({
110
+ repoRoot: '/repo',
111
+ logger: stubLogger(),
112
+ execFile: async () => okExec(),
113
+ })
114
+ const workspaceRegistry = new WorkspaceBackendRegistry()
115
+ workspaceRegistry.register(driver)
116
+
117
+ const events: HandoffEventSink = {
118
+ onLocked: vi.fn(),
119
+ onUnlocked: vi.fn(),
120
+ onCommitted: vi.fn(),
121
+ onBroadcastRollback: vi.fn(),
122
+ }
123
+ const deps: SingleHandoffDeps = {
124
+ store,
125
+ workspaceRegistry,
126
+ capacity: new DefaultCapacityValidator(store),
127
+ events,
128
+ threadManager,
129
+ }
130
+
131
+ const assignment: HandoffAssignment = {
132
+ id: generateHandoffId(),
133
+ mode: 'single',
134
+ sourceSessionId: session.id,
135
+ tenantId: DEFAULT_TENANT,
136
+ threadId: thread.id,
137
+ projectId: project.id,
138
+ sourceActor,
139
+ recipientActor: userActor('usr_target'),
140
+ expectedOwnerVersion: 0,
141
+ createdAt: new Date('2026-04-19'),
142
+ }
143
+
144
+ await expect(executeSingleHandoff(deps, assignment, DEFAULT_TENANT)).rejects.toBeInstanceOf(
145
+ ThreadClosedError,
146
+ )
147
+
148
+ // Critical: source session must still be idle (lock never acquired).
149
+ const reloaded = await store.getSession(session.id, DEFAULT_TENANT)
150
+ expect(reloaded?.status).toBe('idle')
151
+ expect(reloaded?.ownerVersion).toBe(0)
152
+ expect(events.onLocked).not.toHaveBeenCalled()
153
+ })
154
+
155
+ it('Broadcast handoff: rejects with ThreadClosedError when thread is archived (no CAS, no worktrees)', async () => {
156
+ const store = new InMemorySessionStore()
157
+ const threadStore = new InMemoryThreadStore()
158
+ const project = await store.createProject(
159
+ { tenantId: DEFAULT_TENANT, name: 'archive-bc' },
160
+ DEFAULT_TENANT,
161
+ )
162
+ const thread = await threadStore.createThread(
163
+ { projectId: project.id, title: 'archive-bc' },
164
+ DEFAULT_TENANT,
165
+ )
166
+ const source = await store.createSession(
167
+ { threadId: thread.id, projectId: project.id, currentActor: userActor('usr_source') },
168
+ DEFAULT_TENANT,
169
+ )
170
+
171
+ const threadManager = new ThreadManager({ threadStore, sessionStore: store })
172
+ await threadManager.archive(thread.id, DEFAULT_TENANT)
173
+
174
+ let worktreeAdds = 0
175
+ const driver = new GitWorktreeDriver({
176
+ repoRoot: '/repo',
177
+ logger: stubLogger(),
178
+ execFile: async (_file, args) => {
179
+ if (args.includes('add')) worktreeAdds += 1
180
+ return okExec()
181
+ },
182
+ })
183
+ const workspaceRegistry = new WorkspaceBackendRegistry()
184
+ workspaceRegistry.register(driver)
185
+
186
+ const events: HandoffEventSink = {
187
+ onLocked: vi.fn(),
188
+ onUnlocked: vi.fn(),
189
+ onCommitted: vi.fn(),
190
+ onBroadcastRollback: vi.fn(),
191
+ }
192
+ const deps: BroadcastHandoffDeps = {
193
+ store,
194
+ workspaceRegistry,
195
+ capacity: new DefaultCapacityValidator(store),
196
+ events,
197
+ threadManager,
198
+ }
199
+
200
+ const assignments: HandoffAssignment[] = [userActor('usr_b'), userActor('usr_c')].map(
201
+ (recipientActor) => ({
202
+ id: generateHandoffId(),
203
+ mode: 'broadcast' as const,
204
+ sourceSessionId: source.id,
205
+ tenantId: DEFAULT_TENANT,
206
+ threadId: thread.id,
207
+ projectId: project.id,
208
+ sourceActor: userActor('usr_source'),
209
+ recipientActor,
210
+ expectedOwnerVersion: 0,
211
+ broadcastId: 'bc_archive',
212
+ createdAt: new Date('2026-04-19'),
213
+ }),
214
+ )
215
+
216
+ await expect(executeBroadcastHandoff(deps, assignments, DEFAULT_TENANT)).rejects.toBeInstanceOf(
217
+ ThreadClosedError,
218
+ )
219
+
220
+ // Source never locked, no worktrees provisioned, no rollback event —
221
+ // the archive gate short-circuited before any side-effect landed.
222
+ const reloaded = await store.getSession(source.id, DEFAULT_TENANT)
223
+ expect(reloaded?.status).toBe('idle')
224
+ expect(reloaded?.ownerVersion).toBe(0)
225
+ expect(events.onLocked).not.toHaveBeenCalled()
226
+ expect(events.onBroadcastRollback).not.toHaveBeenCalled()
227
+ expect(worktreeAdds).toBe(0)
228
+ })
229
+
230
+ it('Phase 2.6 closure: post-archive spawn via AgentManager rejects (kernel ingress path gated)', async () => {
231
+ // End-to-end proof that the production ingress path honors the
232
+ // archive status. Direct `SessionStore.createSession` / `updateSession`
233
+ // remain ungated at the store layer (by design — the store has no
234
+ // cross-store awareness), so this test exercises the manager path,
235
+ // not the store boundary.
236
+ const harness = buildHarness()
237
+ const { project, thread, session } = await seedActiveParent(harness)
238
+
239
+ await harness.store.updateSession({ ...session, status: 'idle' }, DEFAULT_TENANT)
240
+ await harness.threadManager.archive(thread.id, DEFAULT_TENANT)
241
+
242
+ // Attempt to spawn directly via context threading (bypass the fixture
243
+ // builder to prove the gate trips from AgentManager, not from the
244
+ // fixture).
245
+ harness.registry.register(buildDefinition(buildAgent('leaker')))
246
+
247
+ const childActor: ActorRef = {
248
+ kind: 'agent',
249
+ agentId: 'leaker' as AgentId,
250
+ tenantId: DEFAULT_TENANT,
251
+ }
252
+
253
+ // Flip session to active again so capacity checks pass and the
254
+ // archive-gate is what fails — not an earlier guard.
255
+ await harness.store.updateSession({ ...session, status: 'active' }, DEFAULT_TENANT)
256
+
257
+ await expect(
258
+ harness.manager.sendMessage(
259
+ {
260
+ agentId: 'leaker',
261
+ input: { messages: [], workingDirectory: '/tmp' },
262
+ parentSessionId: session.id,
263
+ tenantId: DEFAULT_TENANT,
264
+ projectId: project.id,
265
+ parentActor: childActor,
266
+ },
267
+ {
268
+ parentRunId: 'run_post_archive' as RunId,
269
+ parentAgentId: 'supervisor',
270
+ parentAbortController: new AbortController(),
271
+ depth: 0,
272
+ budgetTracker: { total: 10_000, remaining: 10_000 },
273
+ tenantId: DEFAULT_TENANT,
274
+ threadId: thread.id,
275
+ sessionId: session.id,
276
+ projectId: project.id,
277
+ parentActor: childActor,
278
+ },
279
+ ),
280
+ ).rejects.toBeInstanceOf(ThreadClosedError)
281
+
282
+ // The gate tripped before any observable side effect — listSessions
283
+ // still shows only the original seeded session, not a smuggled child.
284
+ const underThread = await harness.store.listSessions(thread.id, DEFAULT_TENANT)
285
+ expect(underThread).toHaveLength(1)
286
+ expect(underThread[0]?.id).toBe(session.id)
287
+ })
288
+ })