@namzu/sdk 0.4.0 → 0.4.2

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 (480) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/dist/__tests__/replay-public-surface.test.d.ts +2 -0
  3. package/dist/__tests__/replay-public-surface.test.d.ts.map +1 -0
  4. package/dist/__tests__/replay-public-surface.test.js +45 -0
  5. package/dist/__tests__/replay-public-surface.test.js.map +1 -0
  6. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  7. package/dist/agents/SupervisorAgent.js.map +1 -1
  8. package/dist/bridge/a2a/task.d.ts +2 -2
  9. package/dist/bridge/a2a/task.d.ts.map +1 -1
  10. package/dist/bridge/a2a/task.js.map +1 -1
  11. package/dist/config/runtime.d.ts +24 -25
  12. package/dist/config/runtime.d.ts.map +1 -1
  13. package/dist/config/runtime.js.map +1 -1
  14. package/dist/contracts/api.d.ts +2 -2
  15. package/dist/contracts/api.d.ts.map +1 -1
  16. package/dist/contracts/index.d.ts +1 -2
  17. package/dist/contracts/index.d.ts.map +1 -1
  18. package/dist/contracts/index.js.map +1 -1
  19. package/dist/contracts/schemas.d.ts +10 -10
  20. package/dist/index.d.ts +3 -103
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +9 -89
  23. package/dist/index.js.map +1 -1
  24. package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -1
  25. package/dist/manager/agent/lifecycle.d.ts +1 -1
  26. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  27. package/dist/manager/agent/lifecycle.js +1 -1
  28. package/dist/manager/agent/lifecycle.js.map +1 -1
  29. package/dist/manager/run/persistence.d.ts +3 -3
  30. package/dist/manager/run/persistence.d.ts.map +1 -1
  31. package/dist/manager/run/persistence.js.map +1 -1
  32. package/dist/manager/thread/__tests__/lifecycle.test.js.map +1 -1
  33. package/dist/manager/thread/lifecycle.d.ts +1 -1
  34. package/dist/manager/thread/lifecycle.d.ts.map +1 -1
  35. package/dist/plugin/loader.d.ts +0 -5
  36. package/dist/plugin/loader.d.ts.map +1 -1
  37. package/dist/plugin/loader.js +1 -13
  38. package/dist/plugin/loader.js.map +1 -1
  39. package/dist/public-runtime.d.ts +70 -0
  40. package/dist/public-runtime.d.ts.map +1 -0
  41. package/dist/public-runtime.js +108 -0
  42. package/dist/public-runtime.js.map +1 -0
  43. package/dist/public-tools.d.ts +19 -0
  44. package/dist/public-tools.d.ts.map +1 -0
  45. package/dist/public-tools.js +34 -0
  46. package/dist/public-tools.js.map +1 -0
  47. package/dist/public-types.d.ts +55 -0
  48. package/dist/public-types.d.ts.map +1 -0
  49. package/dist/public-types.js +14 -0
  50. package/dist/public-types.js.map +1 -0
  51. package/dist/rag/rag-tool.d.ts +1 -1
  52. package/dist/run/LimitChecker.d.ts +0 -1
  53. package/dist/run/LimitChecker.d.ts.map +1 -1
  54. package/dist/run/LimitChecker.js +0 -6
  55. package/dist/run/LimitChecker.js.map +1 -1
  56. package/dist/run/reporter.d.ts +2 -2
  57. package/dist/run/reporter.d.ts.map +1 -1
  58. package/dist/run/reporter.js.map +1 -1
  59. package/dist/runtime/query/__tests__/checkpoint.test.d.ts +2 -0
  60. package/dist/runtime/query/__tests__/checkpoint.test.d.ts.map +1 -0
  61. package/dist/runtime/query/__tests__/checkpoint.test.js +150 -0
  62. package/dist/runtime/query/__tests__/checkpoint.test.js.map +1 -0
  63. package/dist/runtime/query/checkpoint.d.ts +23 -0
  64. package/dist/runtime/query/checkpoint.d.ts.map +1 -1
  65. package/dist/runtime/query/checkpoint.js +49 -0
  66. package/dist/runtime/query/checkpoint.js.map +1 -1
  67. package/dist/runtime/query/context.d.ts +0 -2
  68. package/dist/runtime/query/context.d.ts.map +1 -1
  69. package/dist/runtime/query/context.js +0 -4
  70. package/dist/runtime/query/context.js.map +1 -1
  71. package/dist/runtime/query/index.d.ts +3 -3
  72. package/dist/runtime/query/index.d.ts.map +1 -1
  73. package/dist/runtime/query/replay/__tests__/mutate.test.d.ts +2 -0
  74. package/dist/runtime/query/replay/__tests__/mutate.test.d.ts.map +1 -0
  75. package/dist/runtime/query/replay/__tests__/mutate.test.js +123 -0
  76. package/dist/runtime/query/replay/__tests__/mutate.test.js.map +1 -0
  77. package/dist/runtime/query/replay/__tests__/prepare.test.d.ts +2 -0
  78. package/dist/runtime/query/replay/__tests__/prepare.test.d.ts.map +1 -0
  79. package/dist/runtime/query/replay/__tests__/prepare.test.js +171 -0
  80. package/dist/runtime/query/replay/__tests__/prepare.test.js.map +1 -0
  81. package/dist/runtime/query/replay/list.d.ts +24 -0
  82. package/dist/runtime/query/replay/list.d.ts.map +1 -0
  83. package/dist/runtime/query/replay/list.js +21 -0
  84. package/dist/runtime/query/replay/list.js.map +1 -0
  85. package/dist/runtime/query/replay/mutate.d.ts +17 -0
  86. package/dist/runtime/query/replay/mutate.d.ts.map +1 -0
  87. package/dist/runtime/query/replay/mutate.js +62 -0
  88. package/dist/runtime/query/replay/mutate.js.map +1 -0
  89. package/dist/runtime/query/replay/prepare.d.ts +56 -0
  90. package/dist/runtime/query/replay/prepare.d.ts.map +1 -0
  91. package/dist/runtime/query/replay/prepare.js +65 -0
  92. package/dist/runtime/query/replay/prepare.js.map +1 -0
  93. package/dist/runtime/query/result.d.ts +2 -2
  94. package/dist/runtime/query/result.d.ts.map +1 -1
  95. package/dist/session/__tests__/integration/_fixtures.d.ts +4 -4
  96. package/dist/session/__tests__/integration/_fixtures.d.ts.map +1 -1
  97. package/dist/session/__tests__/integration/_fixtures.js.map +1 -1
  98. package/dist/session/__tests__/integration/archive-gate.test.js.map +1 -1
  99. package/dist/session/__tests__/integration/capacity-caps.test.js.map +1 -1
  100. package/dist/session/__tests__/integration/e2e-spawn.test.js.map +1 -1
  101. package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js.map +1 -1
  102. package/dist/session/__tests__/integration/handoff-single-e2e.test.js.map +1 -1
  103. package/dist/session/__tests__/integration/prev-artifact-dag.test.js.map +1 -1
  104. package/dist/session/__tests__/integration/retention-archive.test.js.map +1 -1
  105. package/dist/session/__tests__/integration/spawn-rollback.test.js.map +1 -1
  106. package/dist/session/__tests__/integration/summary-materialization-e2e.test.js +1 -1
  107. package/dist/session/__tests__/integration/summary-materialization-e2e.test.js.map +1 -1
  108. package/dist/session/errors.d.ts +1 -1
  109. package/dist/session/errors.d.ts.map +1 -1
  110. package/dist/session/events/index.d.ts +3 -3
  111. package/dist/session/events/index.d.ts.map +1 -1
  112. package/dist/session/events/index.js +3 -2
  113. package/dist/session/events/index.js.map +1 -1
  114. package/dist/session/handoff/__tests__/broadcast.test.js.map +1 -1
  115. package/dist/session/handoff/__tests__/capacity.test.js.map +1 -1
  116. package/dist/session/handoff/__tests__/single.test.js.map +1 -1
  117. package/dist/session/handoff/assignment.d.ts +1 -1
  118. package/dist/session/handoff/assignment.d.ts.map +1 -1
  119. package/dist/session/handoff/broadcast.d.ts.map +1 -1
  120. package/dist/session/handoff/broadcast.js.map +1 -1
  121. package/dist/session/handoff/single.d.ts.map +1 -1
  122. package/dist/session/handoff/single.js.map +1 -1
  123. package/dist/session/index.d.ts +0 -1
  124. package/dist/session/index.d.ts.map +1 -1
  125. package/dist/session/index.js +7 -6
  126. package/dist/session/index.js.map +1 -1
  127. package/dist/session/intervention/__tests__/prev-artifact.test.js.map +1 -1
  128. package/dist/session/intervention/prev-artifact.d.ts +1 -1
  129. package/dist/session/intervention/prev-artifact.d.ts.map +1 -1
  130. package/dist/session/retention/__tests__/archive.test.js.map +1 -1
  131. package/dist/session/retention/__tests__/disk-backend.test.js.map +1 -1
  132. package/dist/session/retention/archive.d.ts +1 -1
  133. package/dist/session/retention/archive.d.ts.map +1 -1
  134. package/dist/session/retention/backend.d.ts +4 -4
  135. package/dist/session/retention/backend.d.ts.map +1 -1
  136. package/dist/session/retention/disk-backend.d.ts +1 -1
  137. package/dist/session/retention/disk-backend.d.ts.map +1 -1
  138. package/dist/session/retention/index.d.ts +3 -3
  139. package/dist/session/retention/index.d.ts.map +1 -1
  140. package/dist/session/retention/index.js +4 -2
  141. package/dist/session/retention/index.js.map +1 -1
  142. package/dist/session/status/__tests__/derive.test.d.ts +2 -0
  143. package/dist/session/status/__tests__/derive.test.d.ts.map +1 -0
  144. package/dist/session/{hierarchy/__tests__/session.test.js → status/__tests__/derive.test.js} +2 -2
  145. package/dist/session/status/__tests__/derive.test.js.map +1 -0
  146. package/dist/session/status/derive.d.ts +33 -0
  147. package/dist/session/status/derive.d.ts.map +1 -0
  148. package/dist/session/{hierarchy/session.js → status/derive.js} +6 -1
  149. package/dist/session/status/derive.js.map +1 -0
  150. package/dist/session/summary/__tests__/materialize.test.js +2 -1
  151. package/dist/session/summary/__tests__/materialize.test.js.map +1 -1
  152. package/dist/session/summary/errors.d.ts +43 -0
  153. package/dist/session/summary/errors.d.ts.map +1 -0
  154. package/dist/session/summary/errors.js +37 -0
  155. package/dist/session/summary/errors.js.map +1 -0
  156. package/dist/session/summary/index.d.ts +4 -3
  157. package/dist/session/summary/index.d.ts.map +1 -1
  158. package/dist/session/summary/index.js +5 -4
  159. package/dist/session/summary/index.js.map +1 -1
  160. package/dist/session/summary/materialize.d.ts +2 -2
  161. package/dist/session/summary/materialize.d.ts.map +1 -1
  162. package/dist/session/summary/materialize.js +2 -1
  163. package/dist/session/summary/materialize.js.map +1 -1
  164. package/dist/session/workspace/__tests__/git-worktree.test.js.map +1 -1
  165. package/dist/session/workspace/driver.d.ts +2 -2
  166. package/dist/session/workspace/driver.d.ts.map +1 -1
  167. package/dist/session/workspace/git-worktree.d.ts +1 -1
  168. package/dist/session/workspace/git-worktree.d.ts.map +1 -1
  169. package/dist/session/workspace/git-worktree.js.map +1 -1
  170. package/dist/session/workspace/index.d.ts +1 -1
  171. package/dist/session/workspace/index.d.ts.map +1 -1
  172. package/dist/session/workspace/index.js +3 -2
  173. package/dist/session/workspace/index.js.map +1 -1
  174. package/dist/store/run/disk.d.ts +4 -4
  175. package/dist/store/run/disk.d.ts.map +1 -1
  176. package/dist/store/run/disk.js.map +1 -1
  177. package/dist/store/session/__tests__/disk.test.js.map +1 -1
  178. package/dist/store/session/__tests__/memory.test.js.map +1 -1
  179. package/dist/store/session/disk.d.ts +6 -6
  180. package/dist/store/session/disk.d.ts.map +1 -1
  181. package/dist/store/session/disk.js +1 -1
  182. package/dist/store/session/disk.js.map +1 -1
  183. package/dist/store/session/index.d.ts +1 -1
  184. package/dist/store/session/index.d.ts.map +1 -1
  185. package/dist/store/session/index.js +2 -1
  186. package/dist/store/session/index.js.map +1 -1
  187. package/dist/store/session/linkage.d.ts +1 -1
  188. package/dist/store/session/linkage.d.ts.map +1 -1
  189. package/dist/store/session/memory.d.ts +5 -5
  190. package/dist/store/session/memory.d.ts.map +1 -1
  191. package/dist/store/session/memory.js +1 -1
  192. package/dist/store/session/memory.js.map +1 -1
  193. package/dist/store/thread/disk.d.ts +1 -1
  194. package/dist/store/thread/disk.d.ts.map +1 -1
  195. package/dist/store/thread/memory.d.ts +1 -1
  196. package/dist/store/thread/memory.d.ts.map +1 -1
  197. package/dist/telemetry/attributes.d.ts +0 -1
  198. package/dist/telemetry/attributes.d.ts.map +1 -1
  199. package/dist/telemetry/attributes.js +0 -3
  200. package/dist/telemetry/attributes.js.map +1 -1
  201. package/dist/telemetry/runtime-accessors.d.ts +1 -2
  202. package/dist/telemetry/runtime-accessors.d.ts.map +1 -1
  203. package/dist/telemetry/runtime-accessors.js +1 -4
  204. package/dist/telemetry/runtime-accessors.js.map +1 -1
  205. package/dist/tools/builtins/bash.d.ts +1 -1
  206. package/dist/tools/builtins/computer-use.d.ts +4 -4
  207. package/dist/tools/builtins/edit.d.ts +1 -1
  208. package/dist/tools/builtins/glob.d.ts +1 -1
  209. package/dist/tools/builtins/grep.d.ts +1 -1
  210. package/dist/tools/builtins/ls.d.ts +1 -1
  211. package/dist/tools/builtins/read-file.d.ts +1 -1
  212. package/dist/tools/builtins/search-tools.d.ts +1 -1
  213. package/dist/tools/builtins/write-file.d.ts +1 -1
  214. package/dist/types/agent/task.d.ts +2 -2
  215. package/dist/types/agent/task.d.ts.map +1 -1
  216. package/dist/{session/hierarchy/project.d.ts → types/project/entity.d.ts} +4 -4
  217. package/dist/types/project/entity.d.ts.map +1 -0
  218. package/dist/types/project/entity.js +2 -0
  219. package/dist/types/project/entity.js.map +1 -0
  220. package/dist/types/project/index.d.ts +2 -0
  221. package/dist/types/project/index.d.ts.map +1 -0
  222. package/dist/types/project/index.js +4 -0
  223. package/dist/types/project/index.js.map +1 -0
  224. package/dist/types/retention/archive-backend-ref.d.ts.map +1 -0
  225. package/dist/types/retention/archive-backend-ref.js.map +1 -0
  226. package/dist/types/retention/index.d.ts +4 -0
  227. package/dist/types/retention/index.d.ts.map +1 -0
  228. package/dist/types/retention/index.js +4 -0
  229. package/dist/types/retention/index.js.map +1 -0
  230. package/dist/types/retention/policy.d.ts.map +1 -0
  231. package/dist/types/retention/policy.js.map +1 -0
  232. package/dist/types/run/entity.d.ts +56 -0
  233. package/dist/types/run/entity.d.ts.map +1 -0
  234. package/dist/types/run/entity.js +2 -0
  235. package/dist/types/run/entity.js.map +1 -0
  236. package/dist/types/run/events.d.ts +2 -2
  237. package/dist/types/run/events.d.ts.map +1 -1
  238. package/dist/types/run/index.d.ts +7 -1
  239. package/dist/types/run/index.d.ts.map +1 -1
  240. package/dist/types/run/index.js +8 -9
  241. package/dist/types/run/index.js.map +1 -1
  242. package/dist/{session/hierarchy → types/run}/lineage.d.ts +1 -1
  243. package/dist/types/run/lineage.d.ts.map +1 -0
  244. package/dist/types/run/lineage.js.map +1 -0
  245. package/dist/types/run/replay.d.ts +53 -0
  246. package/dist/types/run/replay.d.ts.map +1 -0
  247. package/dist/types/run/replay.js +15 -0
  248. package/dist/types/run/replay.js.map +1 -0
  249. package/dist/types/run/schema-version.d.ts.map +1 -0
  250. package/dist/types/run/schema-version.js.map +1 -0
  251. package/dist/{session/events/types.d.ts → types/run/subsession-events.d.ts} +5 -5
  252. package/dist/types/run/subsession-events.d.ts.map +1 -0
  253. package/dist/types/run/subsession-events.js +2 -0
  254. package/dist/types/run/subsession-events.js.map +1 -0
  255. package/dist/{session/hierarchy → types/session}/actor.d.ts +1 -1
  256. package/dist/types/session/actor.d.ts.map +1 -0
  257. package/dist/{session/hierarchy → types/session}/actor.js.map +1 -1
  258. package/dist/types/session/entity.d.ts +51 -0
  259. package/dist/types/session/entity.d.ts.map +1 -0
  260. package/dist/types/session/entity.js +2 -0
  261. package/dist/types/session/entity.js.map +1 -0
  262. package/dist/types/session/index.d.ts +4 -0
  263. package/dist/types/session/index.d.ts.map +1 -1
  264. package/dist/{store → types}/session/messages.d.ts +2 -2
  265. package/dist/{store → types}/session/messages.d.ts.map +1 -1
  266. package/dist/types/session/messages.js.map +1 -0
  267. package/dist/types/session/store.d.ts +6 -6
  268. package/dist/types/session/store.d.ts.map +1 -1
  269. package/dist/{session/hierarchy → types/session}/sub-session.d.ts +9 -9
  270. package/dist/types/session/sub-session.d.ts.map +1 -0
  271. package/dist/types/session/sub-session.js.map +1 -0
  272. package/dist/{session → types}/summary/deliverable.d.ts +2 -2
  273. package/dist/types/summary/deliverable.d.ts.map +1 -0
  274. package/dist/types/summary/deliverable.js.map +1 -0
  275. package/dist/types/summary/index.d.ts +4 -0
  276. package/dist/types/summary/index.d.ts.map +1 -0
  277. package/dist/types/summary/index.js +4 -0
  278. package/dist/types/summary/index.js.map +1 -0
  279. package/dist/{session → types}/summary/ref.d.ts +9 -36
  280. package/dist/types/summary/ref.d.ts.map +1 -0
  281. package/dist/types/summary/ref.js +28 -0
  282. package/dist/types/summary/ref.js.map +1 -0
  283. package/dist/{session/hierarchy/tenant.d.ts → types/tenant/entity.d.ts} +2 -2
  284. package/dist/types/tenant/entity.d.ts.map +1 -0
  285. package/dist/types/tenant/entity.js +2 -0
  286. package/dist/types/tenant/entity.js.map +1 -0
  287. package/dist/types/tenant/index.d.ts +2 -0
  288. package/dist/types/tenant/index.d.ts.map +1 -0
  289. package/dist/types/tenant/index.js +4 -0
  290. package/dist/types/tenant/index.js.map +1 -0
  291. package/dist/{session/hierarchy/thread.d.ts → types/thread/entity.d.ts} +31 -7
  292. package/dist/types/thread/entity.d.ts.map +1 -0
  293. package/dist/types/thread/entity.js +2 -0
  294. package/dist/types/thread/entity.js.map +1 -0
  295. package/dist/types/thread/index.d.ts +1 -0
  296. package/dist/types/thread/index.d.ts.map +1 -1
  297. package/dist/types/thread/store.d.ts +1 -1
  298. package/dist/types/thread/store.d.ts.map +1 -1
  299. package/dist/types/workspace/index.d.ts +2 -0
  300. package/dist/types/workspace/index.d.ts.map +1 -0
  301. package/dist/types/workspace/index.js +7 -0
  302. package/dist/types/workspace/index.js.map +1 -0
  303. package/dist/{session → types}/workspace/ref.d.ts +1 -1
  304. package/dist/types/workspace/ref.d.ts.map +1 -0
  305. package/dist/types/workspace/ref.js.map +1 -0
  306. package/package.json +1 -1
  307. package/src/__tests__/replay-public-surface.test.ts +54 -0
  308. package/src/agents/SupervisorAgent.ts +1 -1
  309. package/src/bridge/a2a/task.ts +4 -4
  310. package/src/config/runtime.ts +0 -2
  311. package/src/contracts/api.ts +2 -2
  312. package/src/contracts/index.ts +1 -3
  313. package/src/index.ts +11 -362
  314. package/src/manager/agent/__tests__/lifecycle.test.ts +2 -2
  315. package/src/manager/agent/lifecycle.ts +5 -5
  316. package/src/manager/run/persistence.ts +4 -4
  317. package/src/manager/thread/__tests__/lifecycle.test.ts +1 -1
  318. package/src/manager/thread/lifecycle.ts +2 -2
  319. package/src/plugin/loader.ts +0 -16
  320. package/src/public-runtime.ts +373 -0
  321. package/src/public-tools.ts +63 -0
  322. package/src/public-types.ts +156 -0
  323. package/src/run/LimitChecker.ts +0 -9
  324. package/src/run/reporter.ts +3 -3
  325. package/src/runtime/query/__tests__/checkpoint.test.ts +169 -0
  326. package/src/runtime/query/checkpoint.ts +54 -0
  327. package/src/runtime/query/context.ts +0 -5
  328. package/src/runtime/query/index.ts +4 -4
  329. package/src/runtime/query/replay/__tests__/mutate.test.ts +134 -0
  330. package/src/runtime/query/replay/__tests__/prepare.test.ts +207 -0
  331. package/src/runtime/query/replay/list.ts +32 -0
  332. package/src/runtime/query/replay/mutate.ts +76 -0
  333. package/src/runtime/query/replay/prepare.ts +114 -0
  334. package/src/runtime/query/result.ts +2 -2
  335. package/src/session/__tests__/integration/_fixtures.ts +2 -2
  336. package/src/session/__tests__/integration/archive-gate.test.ts +1 -1
  337. package/src/session/__tests__/integration/capacity-caps.test.ts +1 -1
  338. package/src/session/__tests__/integration/e2e-spawn.test.ts +1 -1
  339. package/src/session/__tests__/integration/handoff-broadcast-e2e.test.ts +1 -1
  340. package/src/session/__tests__/integration/handoff-single-e2e.test.ts +1 -1
  341. package/src/session/__tests__/integration/prev-artifact-dag.test.ts +4 -1
  342. package/src/session/__tests__/integration/retention-archive.test.ts +1 -1
  343. package/src/session/__tests__/integration/spawn-rollback.test.ts +2 -2
  344. package/src/session/__tests__/integration/summary-materialization-e2e.test.ts +1 -1
  345. package/src/session/errors.ts +1 -1
  346. package/src/session/events/index.ts +5 -4
  347. package/src/session/handoff/__tests__/broadcast.test.ts +1 -1
  348. package/src/session/handoff/__tests__/capacity.test.ts +1 -1
  349. package/src/session/handoff/__tests__/single.test.ts +1 -1
  350. package/src/session/handoff/assignment.ts +1 -1
  351. package/src/session/handoff/broadcast.ts +2 -2
  352. package/src/session/handoff/single.ts +2 -2
  353. package/src/session/index.ts +7 -6
  354. package/src/session/intervention/__tests__/prev-artifact.test.ts +4 -1
  355. package/src/session/intervention/prev-artifact.ts +1 -1
  356. package/src/session/retention/__tests__/archive.test.ts +3 -3
  357. package/src/session/retention/__tests__/disk-backend.test.ts +4 -4
  358. package/src/session/retention/archive.ts +2 -2
  359. package/src/session/retention/backend.ts +4 -4
  360. package/src/session/retention/disk-backend.ts +4 -4
  361. package/src/session/retention/index.ts +6 -4
  362. package/src/session/{hierarchy/__tests__/session.test.ts → status/__tests__/derive.test.ts} +3 -2
  363. package/src/session/{hierarchy/session.ts → status/derive.ts} +9 -55
  364. package/src/session/summary/__tests__/materialize.test.ts +4 -7
  365. package/src/session/summary/errors.ts +51 -0
  366. package/src/session/summary/index.ts +7 -10
  367. package/src/session/summary/materialize.ts +4 -5
  368. package/src/session/workspace/__tests__/git-worktree.test.ts +1 -1
  369. package/src/session/workspace/driver.ts +2 -2
  370. package/src/session/workspace/git-worktree.ts +1 -1
  371. package/src/session/workspace/index.ts +7 -6
  372. package/src/store/run/disk.ts +4 -4
  373. package/src/store/session/__tests__/disk.test.ts +2 -2
  374. package/src/store/session/__tests__/memory.test.ts +2 -2
  375. package/src/store/session/disk.ts +12 -12
  376. package/src/store/session/index.ts +3 -2
  377. package/src/store/session/linkage.ts +1 -1
  378. package/src/store/session/memory.ts +6 -6
  379. package/src/store/thread/disk.ts +1 -1
  380. package/src/store/thread/memory.ts +1 -1
  381. package/src/telemetry/attributes.ts +0 -4
  382. package/src/telemetry/runtime-accessors.ts +1 -5
  383. package/src/types/agent/task.ts +2 -2
  384. package/src/{session/hierarchy/project.ts → types/project/entity.ts} +3 -3
  385. package/src/types/project/index.ts +4 -0
  386. package/src/types/retention/index.ts +6 -0
  387. package/src/types/run/entity.ts +63 -0
  388. package/src/types/run/events.ts +6 -6
  389. package/src/types/run/index.ts +16 -9
  390. package/src/{session/hierarchy → types/run}/lineage.ts +1 -1
  391. package/src/types/run/replay.ts +61 -0
  392. package/src/{session/events/types.ts → types/run/subsession-events.ts} +4 -4
  393. package/src/{session/hierarchy → types/session}/actor.ts +1 -1
  394. package/src/types/session/entity.ts +59 -0
  395. package/src/types/session/index.ts +15 -0
  396. package/src/{store → types}/session/messages.ts +2 -2
  397. package/src/types/session/store.ts +6 -6
  398. package/src/{session/hierarchy → types/session}/sub-session.ts +9 -9
  399. package/src/{session → types}/summary/deliverable.ts +2 -2
  400. package/src/types/summary/index.ts +18 -0
  401. package/src/{session → types}/summary/ref.ts +9 -44
  402. package/src/{session/hierarchy/tenant.ts → types/tenant/entity.ts} +1 -1
  403. package/src/types/tenant/index.ts +4 -0
  404. package/src/{session/hierarchy/thread.ts → types/thread/entity.ts} +30 -6
  405. package/src/types/thread/index.ts +1 -0
  406. package/src/types/thread/store.ts +1 -1
  407. package/src/types/workspace/index.ts +12 -0
  408. package/src/{session → types}/workspace/ref.ts +1 -1
  409. package/dist/contracts/ids.d.ts +0 -2
  410. package/dist/contracts/ids.d.ts.map +0 -1
  411. package/dist/contracts/ids.js +0 -2
  412. package/dist/contracts/ids.js.map +0 -1
  413. package/dist/session/events/schema-version.d.ts.map +0 -1
  414. package/dist/session/events/schema-version.js.map +0 -1
  415. package/dist/session/events/types.d.ts.map +0 -1
  416. package/dist/session/events/types.js +0 -2
  417. package/dist/session/events/types.js.map +0 -1
  418. package/dist/session/hierarchy/__tests__/session.test.d.ts +0 -2
  419. package/dist/session/hierarchy/__tests__/session.test.d.ts.map +0 -1
  420. package/dist/session/hierarchy/__tests__/session.test.js.map +0 -1
  421. package/dist/session/hierarchy/actor.d.ts.map +0 -1
  422. package/dist/session/hierarchy/index.d.ts +0 -9
  423. package/dist/session/hierarchy/index.d.ts.map +0 -1
  424. package/dist/session/hierarchy/index.js +0 -4
  425. package/dist/session/hierarchy/index.js.map +0 -1
  426. package/dist/session/hierarchy/lineage.d.ts.map +0 -1
  427. package/dist/session/hierarchy/lineage.js.map +0 -1
  428. package/dist/session/hierarchy/project.d.ts.map +0 -1
  429. package/dist/session/hierarchy/project.js +0 -2
  430. package/dist/session/hierarchy/project.js.map +0 -1
  431. package/dist/session/hierarchy/session.d.ts +0 -71
  432. package/dist/session/hierarchy/session.d.ts.map +0 -1
  433. package/dist/session/hierarchy/session.js.map +0 -1
  434. package/dist/session/hierarchy/sub-session.d.ts.map +0 -1
  435. package/dist/session/hierarchy/sub-session.js.map +0 -1
  436. package/dist/session/hierarchy/tenant.d.ts.map +0 -1
  437. package/dist/session/hierarchy/tenant.js +0 -2
  438. package/dist/session/hierarchy/tenant.js.map +0 -1
  439. package/dist/session/hierarchy/thread.d.ts.map +0 -1
  440. package/dist/session/hierarchy/thread.js +0 -2
  441. package/dist/session/hierarchy/thread.js.map +0 -1
  442. package/dist/session/retention/archive-backend-ref.d.ts.map +0 -1
  443. package/dist/session/retention/archive-backend-ref.js.map +0 -1
  444. package/dist/session/retention/policy.d.ts.map +0 -1
  445. package/dist/session/retention/policy.js.map +0 -1
  446. package/dist/session/summary/deliverable.d.ts.map +0 -1
  447. package/dist/session/summary/deliverable.js.map +0 -1
  448. package/dist/session/summary/ref.d.ts.map +0 -1
  449. package/dist/session/summary/ref.js +0 -51
  450. package/dist/session/summary/ref.js.map +0 -1
  451. package/dist/session/workspace/ref.d.ts.map +0 -1
  452. package/dist/session/workspace/ref.js.map +0 -1
  453. package/dist/store/session/messages.js.map +0 -1
  454. package/dist/tools/builtins/__tests__/structuredOutput.example.d.ts +0 -140
  455. package/dist/tools/builtins/__tests__/structuredOutput.example.d.ts.map +0 -1
  456. package/dist/tools/builtins/__tests__/structuredOutput.example.js +0 -183
  457. package/dist/tools/builtins/__tests__/structuredOutput.example.js.map +0 -1
  458. package/dist/types/run/state.d.ts +0 -30
  459. package/dist/types/run/state.d.ts.map +0 -1
  460. package/dist/types/run/state.js +0 -2
  461. package/dist/types/run/state.js.map +0 -1
  462. package/src/contracts/ids.ts +0 -1
  463. package/src/session/hierarchy/index.ts +0 -18
  464. package/src/tools/builtins/__tests__/structuredOutput.example.ts +0 -221
  465. package/src/types/run/state.ts +0 -35
  466. /package/dist/{session → types}/retention/archive-backend-ref.d.ts +0 -0
  467. /package/dist/{session → types}/retention/archive-backend-ref.js +0 -0
  468. /package/dist/{session → types}/retention/policy.d.ts +0 -0
  469. /package/dist/{session → types}/retention/policy.js +0 -0
  470. /package/dist/{session/hierarchy → types/run}/lineage.js +0 -0
  471. /package/dist/{session/events → types/run}/schema-version.d.ts +0 -0
  472. /package/dist/{session/events → types/run}/schema-version.js +0 -0
  473. /package/dist/{session/hierarchy → types/session}/actor.js +0 -0
  474. /package/dist/{store → types}/session/messages.js +0 -0
  475. /package/dist/{session/hierarchy → types/session}/sub-session.js +0 -0
  476. /package/dist/{session → types}/summary/deliverable.js +0 -0
  477. /package/dist/{session → types}/workspace/ref.js +0 -0
  478. /package/src/{session → types}/retention/archive-backend-ref.ts +0 -0
  479. /package/src/{session → types}/retention/policy.ts +0 -0
  480. /package/src/{session/events → types/run}/schema-version.ts +0 -0
@@ -0,0 +1,76 @@
1
+ import type { ToolCallId } from '../../../types/ids/index.js'
2
+ import {
3
+ type AssistantMessage,
4
+ type Message,
5
+ type ToolCall,
6
+ createToolMessage,
7
+ } from '../../../types/message/index.js'
8
+ import { type Mutation, MutationNotApplicableError } from '../../../types/run/replay.js'
9
+
10
+ /**
11
+ * Returns the tool calls on the most recent assistant message that do not
12
+ * yet have a matching {@link import('../../../types/message/index.js').ToolMessage}
13
+ * response further down the message list. These are the fork-point "pending"
14
+ * tool calls that mutations may target.
15
+ */
16
+ function findPendingToolCalls(messages: readonly Message[]): ToolCall[] {
17
+ let lastAssistantIdx = -1
18
+ for (let i = messages.length - 1; i >= 0; i--) {
19
+ const msg = messages[i]
20
+ if (msg && msg.role === 'assistant' && (msg.toolCalls?.length ?? 0) > 0) {
21
+ lastAssistantIdx = i
22
+ break
23
+ }
24
+ }
25
+ if (lastAssistantIdx === -1) return []
26
+
27
+ const assistant = messages[lastAssistantIdx] as AssistantMessage
28
+ const satisfied = new Set<string>()
29
+ for (let i = lastAssistantIdx + 1; i < messages.length; i++) {
30
+ const msg = messages[i]
31
+ if (msg && msg.role === 'tool') {
32
+ satisfied.add(msg.toolCallId)
33
+ }
34
+ }
35
+ return (assistant.toolCalls ?? []).filter((tc) => !satisfied.has(tc.id))
36
+ }
37
+
38
+ /**
39
+ * Apply an ordered list of {@link Mutation} to a checkpoint's message
40
+ * history at the fork point, producing a new message array that the
41
+ * resumed iteration loop consumes. Pure function; does not touch the run
42
+ * store, does not emit events.
43
+ *
44
+ * Throws {@link MutationNotApplicableError} when an `injectToolResponse`
45
+ * mutation targets a tool call id that is not pending at the fork point —
46
+ * the error payload carries the list of ids that *are* pending so the
47
+ * caller can recover without guessing.
48
+ *
49
+ * See ses_005-deterministic-replay design §3.3.
50
+ */
51
+ export function applyMutations(
52
+ messages: readonly Message[],
53
+ mutations: readonly Mutation[],
54
+ ): Message[] {
55
+ let current: Message[] = [...messages]
56
+ for (const m of mutations) {
57
+ current = applyOne(current, m)
58
+ }
59
+ return current
60
+ }
61
+
62
+ function applyOne(messages: Message[], mutation: Mutation): Message[] {
63
+ switch (mutation.type) {
64
+ case 'injectToolResponse': {
65
+ const pending = findPendingToolCalls(messages)
66
+ const match = pending.find((tc) => tc.id === mutation.toolCallId)
67
+ if (!match) {
68
+ throw new MutationNotApplicableError(
69
+ `No pending tool call ${mutation.toolCallId} at fork point`,
70
+ pending.map((tc) => tc.id as ToolCallId),
71
+ )
72
+ }
73
+ return [...messages, createToolMessage(mutation.response.output, mutation.toolCallId)]
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,114 @@
1
+ import { join } from 'node:path'
2
+ import { EmergencySaveManager } from '../../../manager/run/emergency.js'
3
+ import { RunDiskStore } from '../../../store/run/disk.js'
4
+ import type { CheckpointId, IterationCheckpoint } from '../../../types/hitl/index.js'
5
+ import type { RunId } from '../../../types/ids/index.js'
6
+ import type { Message } from '../../../types/message/index.js'
7
+ import type { Mutation, ReplayAttribution } from '../../../types/run/replay.js'
8
+ import type { Logger } from '../../../utils/logger.js'
9
+ import { projectEmergencyToCheckpoint } from '../checkpoint.js'
10
+ import { applyMutations } from './mutate.js'
11
+
12
+ export type CheckpointSelector = CheckpointId | 'latest' | 'emergency'
13
+
14
+ export interface PrepareReplayInput {
15
+ /** Directory that contains `<runId>/` for the source run. */
16
+ baseDir: string
17
+ /** Source run to fork from. */
18
+ runId: RunId
19
+ /** Which checkpoint to fork at. */
20
+ fromCheckpoint: CheckpointSelector
21
+ /** Optional mutations applied at the fork point before the caller hands state to `query()`. */
22
+ mutate?: Mutation[]
23
+ /**
24
+ * Directory that holds emergency dumps. Required only when `fromCheckpoint`
25
+ * is `'emergency'`; conventionally sibling of `baseDir` (the `.namzu/emergency`
26
+ * folder), but left explicit so callers with non-default layouts can redirect.
27
+ */
28
+ emergencyDir?: string
29
+ logger?: Logger
30
+ }
31
+
32
+ export interface PreparedReplayState {
33
+ /**
34
+ * Message history at the fork point, with mutations applied. Seed this
35
+ * as the new run's initial messages and pass `sourceCheckpoint.id` as
36
+ * `resumeFromCheckpoint` when you call `query()`.
37
+ */
38
+ messages: Message[]
39
+ /** The checkpoint the replay forks from (already projected if emergency). */
40
+ sourceCheckpoint: IterationCheckpoint
41
+ /**
42
+ * Attribution to stamp on the replay run once it is created. The caller
43
+ * sets `Run.replayOf = buildAttribution(prepared, replayedAt)` on the
44
+ * new `RunPersistence` before persisting the first time.
45
+ */
46
+ attribution: ReplayAttribution
47
+ }
48
+
49
+ /**
50
+ * Produce the state materials needed to execute a replay run — the mutated
51
+ * message history, the resolved source checkpoint, and the replay
52
+ * attribution record. Pure read; does not touch the run store beyond
53
+ * reading the source run's checkpoint files.
54
+ *
55
+ * This is the state-preparation half of the replay primitive. The
56
+ * caller is expected to thread the returned `messages` +
57
+ * `sourceCheckpoint.id` into `query({ resumeFromCheckpoint, messages,
58
+ * ... })` and stamp `Run.replayOf = prepared.attribution` on the resulting
59
+ * run. The end-to-end `replay()` entry that does all of this in one call
60
+ * is a follow-up session (`ReplayEnvironment` shape).
61
+ *
62
+ * See `ses_005-deterministic-replay/design.md` §3.1.
63
+ */
64
+ export async function prepareReplayState(input: PrepareReplayInput): Promise<PreparedReplayState> {
65
+ const sourceCheckpoint = await resolveCheckpoint(input)
66
+ const mutations = input.mutate ?? []
67
+ const messages = applyMutations(sourceCheckpoint.messages, mutations)
68
+
69
+ const attribution: ReplayAttribution = {
70
+ sourceRunId: input.runId,
71
+ fromCheckpointId: sourceCheckpoint.id,
72
+ mutations,
73
+ replayedAt: Date.now(),
74
+ }
75
+
76
+ return { messages, sourceCheckpoint, attribution }
77
+ }
78
+
79
+ async function resolveCheckpoint(input: PrepareReplayInput): Promise<IterationCheckpoint> {
80
+ if (input.fromCheckpoint === 'emergency') {
81
+ return resolveEmergency(input)
82
+ }
83
+ const store = new RunDiskStore({ baseDir: input.baseDir, logger: input.logger })
84
+ await store.initRun(input.runId)
85
+
86
+ if (input.fromCheckpoint === 'latest') {
87
+ const all = await store.listCheckpoints()
88
+ if (all.length === 0) {
89
+ throw new Error(`No checkpoints found for run ${input.runId} in ${input.baseDir}`)
90
+ }
91
+ return [...all].sort((a, b) => b.iteration - a.iteration)[0] as IterationCheckpoint
92
+ }
93
+
94
+ const checkpoint = await store.readCheckpoint(input.fromCheckpoint)
95
+ if (!checkpoint) {
96
+ throw new Error(`Checkpoint ${input.fromCheckpoint} not found for run ${input.runId}`)
97
+ }
98
+ return checkpoint
99
+ }
100
+
101
+ async function resolveEmergency(input: PrepareReplayInput): Promise<IterationCheckpoint> {
102
+ if (!input.emergencyDir) {
103
+ throw new Error(
104
+ "fromCheckpoint: 'emergency' requires an `emergencyDir` — conventionally sibling of baseDir",
105
+ )
106
+ }
107
+ const path = join(input.emergencyDir, `${input.runId}.json`)
108
+ try {
109
+ const dump = EmergencySaveManager.loadSave(path)
110
+ return projectEmergencyToCheckpoint(dump)
111
+ } catch (err) {
112
+ throw new Error(`No emergency dump found for run ${input.runId} at ${path}`, { cause: err })
113
+ }
114
+ }
@@ -3,7 +3,7 @@ import type { PlanManager } from '../../manager/plan/lifecycle.js'
3
3
  import type { RunPersistence } from '../../manager/run/persistence.js'
4
4
  import type { ActivityStore } from '../../store/activity/memory.js'
5
5
  import { GENAI, NAMZU } from '../../telemetry/attributes.js'
6
- import type { AgentRun, RunEvent } from '../../types/run/index.js'
6
+ import type { Run, RunEvent } from '../../types/run/index.js'
7
7
  import { toErrorMessage } from '../../utils/error.js'
8
8
  import type { Logger } from '../../utils/logger.js'
9
9
  import type { EmitEvent } from './events.js'
@@ -87,7 +87,7 @@ export class ResultAssembler {
87
87
  })
88
88
  }
89
89
 
90
- async finalize(): Promise<AgentRun> {
90
+ async finalize(): Promise<Run> {
91
91
  await this.config.runMgr.persist()
92
92
  return this.config.runMgr.getRun()
93
93
  }
@@ -30,11 +30,11 @@ import type { AgentDefinition } from '../../../types/agent/factory.js'
30
30
  import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/task.js'
31
31
  import type { AgentId, RunId, SessionId, TenantId, UserId } from '../../../types/ids/index.js'
32
32
  import { createAssistantMessage } from '../../../types/message/index.js'
33
+ import type { ActorRef } from '../../../types/session/actor.js'
34
+ import type { Session } from '../../../types/session/entity.js'
33
35
  import type { ProjectId, SummaryId, ThreadId } from '../../../types/session/ids.js'
34
36
  import { ZERO_COST } from '../../../utils/cost.js'
35
37
  import { DefaultCapacityValidator } from '../../handoff/capacity.js'
36
- import type { ActorRef } from '../../hierarchy/actor.js'
37
- import type { Session } from '../../hierarchy/session.js'
38
38
  import { SessionSummaryMaterializer } from '../../summary/materialize.js'
39
39
  import type { ExecFile, ExecFileResult } from '../../workspace/git-worktree.js'
40
40
  import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
@@ -17,6 +17,7 @@ import { ThreadManager } from '../../../manager/thread/lifecycle.js'
17
17
  import { InMemorySessionStore } from '../../../store/session/memory.js'
18
18
  import { InMemoryThreadStore } from '../../../store/thread/memory.js'
19
19
  import type { AgentId, RunId, UserId } from '../../../types/ids/index.js'
20
+ import type { ActorRef } from '../../../types/session/actor.js'
20
21
  import { generateHandoffId } from '../../../utils/id.js'
21
22
  import { ThreadClosedError } from '../../errors.js'
22
23
  import type { HandoffAssignment } from '../../handoff/assignment.js'
@@ -24,7 +25,6 @@ import { type BroadcastHandoffDeps, executeBroadcastHandoff } from '../../handof
24
25
  import { DefaultCapacityValidator } from '../../handoff/capacity.js'
25
26
  import type { HandoffEventSink } from '../../handoff/events.js'
26
27
  import { type SingleHandoffDeps, executeSingleHandoff } from '../../handoff/single.js'
27
- import type { ActorRef } from '../../hierarchy/actor.js'
28
28
  import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
29
29
  import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
30
30
  import {
@@ -11,8 +11,8 @@
11
11
  */
12
12
 
13
13
  import { describe, expect, it } from 'vitest'
14
+ import type { ActorRef } from '../../../types/session/actor.js'
14
15
  import { DelegationCapacityExceeded } from '../../handoff/capacity.js'
15
- import type { ActorRef } from '../../hierarchy/actor.js'
16
16
  import {
17
17
  DEFAULT_TENANT,
18
18
  agentActor,
@@ -34,10 +34,10 @@ import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/
34
34
  import type { RunId, TenantId, UserId } from '../../../types/ids/index.js'
35
35
  import { createAssistantMessage } from '../../../types/message/index.js'
36
36
  import type { RunEvent } from '../../../types/run/events.js'
37
+ import type { ActorRef } from '../../../types/session/actor.js'
37
38
  import type { SummaryId } from '../../../types/session/ids.js'
38
39
  import { ZERO_COST } from '../../../utils/cost.js'
39
40
  import { DefaultCapacityValidator } from '../../handoff/capacity.js'
40
- import type { ActorRef } from '../../hierarchy/actor.js'
41
41
  import { SessionSummaryMaterializer } from '../../summary/materialize.js'
42
42
  import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
43
43
 
@@ -14,13 +14,13 @@ import { ThreadManager } from '../../../manager/thread/lifecycle.js'
14
14
  import { InMemorySessionStore } from '../../../store/session/memory.js'
15
15
  import { InMemoryThreadStore } from '../../../store/thread/memory.js'
16
16
  import type { SessionId } from '../../../types/ids/index.js'
17
+ import type { ActorRef } from '../../../types/session/actor.js'
17
18
  import type { ProjectId, ThreadId } from '../../../types/session/ids.js'
18
19
  import { generateHandoffId } from '../../../utils/id.js'
19
20
  import type { HandoffAssignment } from '../../handoff/assignment.js'
20
21
  import { type BroadcastHandoffDeps, executeBroadcastHandoff } from '../../handoff/broadcast.js'
21
22
  import { DefaultCapacityValidator } from '../../handoff/capacity.js'
22
23
  import type { HandoffEventSink } from '../../handoff/events.js'
23
- import type { ActorRef } from '../../hierarchy/actor.js'
24
24
  import type { ExecFile } from '../../workspace/git-worktree.js'
25
25
  import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
26
26
  import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
@@ -17,13 +17,13 @@ import { ThreadManager } from '../../../manager/thread/lifecycle.js'
17
17
  import { InMemorySessionStore } from '../../../store/session/memory.js'
18
18
  import { InMemoryThreadStore } from '../../../store/thread/memory.js'
19
19
  import type { TenantId } from '../../../types/ids/index.js'
20
+ import type { Session } from '../../../types/session/entity.js'
20
21
  import { generateHandoffId } from '../../../utils/id.js'
21
22
  import { TenantIsolationError } from '../../errors.js'
22
23
  import type { HandoffAssignment } from '../../handoff/assignment.js'
23
24
  import { DefaultCapacityValidator } from '../../handoff/capacity.js'
24
25
  import type { HandoffEventSink } from '../../handoff/events.js'
25
26
  import { type SingleHandoffDeps, executeSingleHandoff } from '../../handoff/single.js'
26
- import type { Session } from '../../hierarchy/session.js'
27
27
  import { GitWorktreeDriver } from '../../workspace/git-worktree.js'
28
28
  import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
29
29
  import { DEFAULT_TENANT, OTHER_TENANT, okExec, stubLogger, userActor } from './_fixtures.js'
@@ -20,13 +20,16 @@ import type {
20
20
  SummaryId,
21
21
  ThreadId,
22
22
  } from '../../../types/session/ids.js'
23
+ import type {
24
+ DeliverableRef,
25
+ SessionSummaryDeliverable,
26
+ } from '../../../types/summary/deliverable.js'
23
27
  import {
24
28
  ArtifactRefCycleError,
25
29
  type InterventionChainLoader,
26
30
  InterventionDepthExceeded,
27
31
  validatePrevArtifactChain,
28
32
  } from '../../intervention/prev-artifact.js'
29
- import type { DeliverableRef, SessionSummaryDeliverable } from '../../summary/deliverable.js'
30
33
  import { DEFAULT_TENANT, agentActor, userActor } from './_fixtures.js'
31
34
 
32
35
  const TEST_THREAD_ID = 'thd_test' as ThreadId
@@ -16,9 +16,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
16
16
  import { InMemorySessionStore } from '../../../store/session/memory.js'
17
17
  import { createUserMessage } from '../../../types/message/index.js'
18
18
  import type { ThreadId, WorkspaceId } from '../../../types/session/ids.js'
19
+ import type { WorkspaceRef } from '../../../types/workspace/ref.js'
19
20
  import { ArchivalManager, ArchiveNotConfiguredError } from '../../retention/archive.js'
20
21
  import { DiskArchiveBackend } from '../../retention/disk-backend.js'
21
- import type { WorkspaceRef } from '../../workspace/ref.js'
22
22
  import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
23
23
  import { DEFAULT_TENANT, agentActor, userActor } from './_fixtures.js'
24
24
 
@@ -41,10 +41,11 @@ import type { AgentDefinition } from '../../../types/agent/factory.js'
41
41
  import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/task.js'
42
42
  import type { RunId, TenantId, UserId } from '../../../types/ids/index.js'
43
43
  import { createAssistantMessage } from '../../../types/message/index.js'
44
+ import type { ActorRef } from '../../../types/session/actor.js'
44
45
  import type { SummaryId } from '../../../types/session/ids.js'
46
+ import type { WorkspaceRef } from '../../../types/workspace/ref.js'
45
47
  import { ZERO_COST } from '../../../utils/cost.js'
46
48
  import { DefaultCapacityValidator } from '../../handoff/capacity.js'
47
- import type { ActorRef } from '../../hierarchy/actor.js'
48
49
  import { SessionSummaryMaterializer } from '../../summary/materialize.js'
49
50
  import type {
50
51
  BranchWorkspaceParams,
@@ -52,7 +53,6 @@ import type {
52
53
  WorkspaceBackendDriver,
53
54
  WorkspaceInspection,
54
55
  } from '../../workspace/driver.js'
55
- import type { WorkspaceRef } from '../../workspace/ref.js'
56
56
  import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
57
57
 
58
58
  const tenant = 'tnt_alpha' as TenantId
@@ -19,8 +19,8 @@ import { describe, expect, it } from 'vitest'
19
19
  import { InMemorySessionStore } from '../../../store/session/memory.js'
20
20
  import type { SessionId } from '../../../types/ids/index.js'
21
21
  import type { SummaryId, ThreadId } from '../../../types/session/ids.js'
22
+ import { SessionAlreadySummarizedError } from '../../summary/errors.js'
22
23
  import { SessionSummaryMaterializer } from '../../summary/materialize.js'
23
- import { SessionAlreadySummarizedError } from '../../summary/ref.js'
24
24
  import { DEFAULT_TENANT, agentActor } from './_fixtures.js'
25
25
 
26
26
  const TEST_THREAD_ID = 'thd_test' as ThreadId
@@ -8,8 +8,8 @@
8
8
  */
9
9
 
10
10
  import type { SessionId, TenantId } from '../types/ids/index.js'
11
+ import type { SessionStatus } from '../types/session/entity.js'
11
12
  import type { ThreadId } from '../types/session/ids.js'
12
- import type { SessionStatus } from './hierarchy/session.js'
13
13
  import type { WorkspaceBackendKind } from './workspace/driver.js'
14
14
 
15
15
  /**
@@ -1,16 +1,17 @@
1
1
  // Sub-barrel for session-hierarchy run-event surface.
2
- // Convention #4: concrete types live in sibling files; re-export them here.
2
+ // Shape types live under `types/run/` (subsession-events.ts + schema-version.ts);
3
+ // this barrel only re-exports them. No runtime emitter lives here today.
3
4
  //
4
5
  // Phase 2 scope is limited to the sub-session lifecycle variants that are
5
6
  // spliced into `RunEvent`. A dedicated `SessionHierarchyEvent` top-level
6
7
  // union lands in a later phase (see session-hierarchy.md §10.2).
7
8
 
8
- export { RUN_EVENT_SCHEMA_VERSION } from './schema-version.js'
9
- export type { RunEventSchemaVersion } from './schema-version.js'
9
+ export { RUN_EVENT_SCHEMA_VERSION } from '../../types/run/schema-version.js'
10
+ export type { RunEventSchemaVersion } from '../../types/run/schema-version.js'
10
11
 
11
12
  export type {
12
13
  SubsessionSpawnedEvent,
13
14
  SubsessionMessagedEvent,
14
15
  SubsessionIdledEvent,
15
16
  SubsessionLifecycleEvent,
16
- } from './types.js'
17
+ } from '../../types/run/subsession-events.js'
@@ -1,6 +1,5 @@
1
1
  import { beforeEach, describe, expect, it, vi } from 'vitest'
2
2
  import { ThreadManager } from '../../../manager/thread/lifecycle.js'
3
- import type { ActorRef } from '../../../session/hierarchy/actor.js'
4
3
  import {
5
4
  type ExecFile,
6
5
  type ExecFileResult,
@@ -10,6 +9,7 @@ import { WorkspaceBackendRegistry } from '../../../session/workspace/registry.js
10
9
  import { InMemorySessionStore } from '../../../store/session/memory.js'
11
10
  import { InMemoryThreadStore } from '../../../store/thread/memory.js'
12
11
  import type { SessionId, TenantId, UserId } from '../../../types/ids/index.js'
12
+ import type { ActorRef } from '../../../types/session/actor.js'
13
13
  import type { ProjectId } from '../../../types/session/ids.js'
14
14
  import { generateHandoffId } from '../../../utils/id.js'
15
15
  import type { HandoffAssignment } from '../assignment.js'
@@ -1,8 +1,8 @@
1
1
  import { describe, expect, it } from 'vitest'
2
- import type { ActorRef } from '../../../session/hierarchy/actor.js'
3
2
  import { InMemorySessionStore } from '../../../store/session/memory.js'
4
3
  import { InMemoryThreadStore } from '../../../store/thread/memory.js'
5
4
  import type { AgentId, SessionId, TenantId, UserId } from '../../../types/ids/index.js'
5
+ import type { ActorRef } from '../../../types/session/actor.js'
6
6
  import type { ProjectId, ThreadId } from '../../../types/session/ids.js'
7
7
  import { DefaultCapacityValidator, DelegationCapacityExceeded } from '../capacity.js'
8
8
 
@@ -1,7 +1,6 @@
1
1
  import { beforeEach, describe, expect, it, vi } from 'vitest'
2
2
  import { ThreadManager } from '../../../manager/thread/lifecycle.js'
3
3
  import { TenantIsolationError } from '../../../session/errors.js'
4
- import type { ActorRef } from '../../../session/hierarchy/actor.js'
5
4
  import {
6
5
  type ExecFile,
7
6
  type ExecFileResult,
@@ -11,6 +10,7 @@ import { WorkspaceBackendRegistry } from '../../../session/workspace/registry.js
11
10
  import { InMemorySessionStore } from '../../../store/session/memory.js'
12
11
  import { InMemoryThreadStore } from '../../../store/thread/memory.js'
13
12
  import type { AgentId, SessionId, TenantId, UserId } from '../../../types/ids/index.js'
13
+ import type { ActorRef } from '../../../types/session/actor.js'
14
14
  import { generateHandoffId } from '../../../utils/id.js'
15
15
  import type { HandoffAssignment } from '../assignment.js'
16
16
  import { DefaultCapacityValidator } from '../capacity.js'
@@ -9,8 +9,8 @@
9
9
  */
10
10
 
11
11
  import type { SessionId, TenantId } from '../../types/ids/index.js'
12
+ import type { ActorRef } from '../../types/session/actor.js'
12
13
  import type { HandoffId, ProjectId, ThreadId, WorkspaceId } from '../../types/session/ids.js'
13
- import type { ActorRef } from '../hierarchy/actor.js'
14
14
 
15
15
  /**
16
16
  * Handoff mode discriminator. `single` transfers ownership of the source
@@ -23,12 +23,12 @@
23
23
 
24
24
  import type { ThreadManager } from '../../manager/thread/lifecycle.js'
25
25
  import type { SessionId, TenantId } from '../../types/ids/index.js'
26
+ import type { Session } from '../../types/session/entity.js'
26
27
  import type { SubSessionId } from '../../types/session/ids.js'
27
28
  import type { SessionStore } from '../../types/session/store.js'
29
+ import type { WorkspaceRef } from '../../types/workspace/ref.js'
28
30
  import { TenantIsolationError } from '../errors.js'
29
- import type { Session } from '../hierarchy/session.js'
30
31
  import type { WorkspaceBackendDriver } from '../workspace/driver.js'
31
- import type { WorkspaceRef } from '../workspace/ref.js'
32
32
  import type { WorkspaceBackendRegistry } from '../workspace/registry.js'
33
33
  import type { HandoffAssignment, HandoffOutcome } from './assignment.js'
34
34
  import type { CapacityValidator } from './capacity.js'
@@ -22,11 +22,11 @@
22
22
 
23
23
  import type { ThreadManager } from '../../manager/thread/lifecycle.js'
24
24
  import type { SessionId, TenantId } from '../../types/ids/index.js'
25
+ import type { Session } from '../../types/session/entity.js'
25
26
  import type { SessionStore } from '../../types/session/store.js'
27
+ import type { WorkspaceRef } from '../../types/workspace/ref.js'
26
28
  import { TenantIsolationError } from '../errors.js'
27
- import type { Session } from '../hierarchy/session.js'
28
29
  import type { WorkspaceBackendDriver } from '../workspace/driver.js'
29
- import type { WorkspaceRef } from '../workspace/ref.js'
30
30
  import type { WorkspaceBackendRegistry } from '../workspace/registry.js'
31
31
  import type { HandoffAssignment, HandoffOutcome } from './assignment.js'
32
32
  import type { CapacityValidator } from './capacity.js'
@@ -1,10 +1,11 @@
1
- // Top-level barrel for the session hierarchy module.
2
- // Phase 1 populates `hierarchy/`; Phase 2 adds `events/`; Phase 3 adds
3
- // `workspace/` + `errors.ts`; Phase 4 adds `handoff/`; Phase 5 adds
4
- // `summary/` + `intervention/`; Phase 7 adds `migration/`; Phase 8 adds
5
- // `retention/`.
1
+ // Top-level barrel for the session module.
2
+ // Shape types (Project / Thread / Session / SubSession / Actor / Lineage /
3
+ // Tenant) live under `types/` as of ses_010 (2026-04-21); this barrel
4
+ // re-exports only the runtime machinery that lives under `session/*/`
5
+ // (events, workspace, handoff, summary, intervention, migration, retention,
6
+ // status). Consumers of `@namzu/sdk` reach entity shapes through the root
7
+ // barrel directly.
6
8
 
7
- export * from './hierarchy/index.js'
8
9
  export * from './events/index.js'
9
10
  export * from './workspace/index.js'
10
11
  export * from './handoff/index.js'
@@ -1,7 +1,10 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
  import type { SessionId } from '../../../types/ids/index.js'
3
3
  import type { DeliverableId, SubSessionId, SummaryId } from '../../../types/session/ids.js'
4
- import type { DeliverableRef, SessionSummaryDeliverable } from '../../summary/deliverable.js'
4
+ import type {
5
+ DeliverableRef,
6
+ SessionSummaryDeliverable,
7
+ } from '../../../types/summary/deliverable.js'
5
8
  import {
6
9
  ArtifactRefCycleError,
7
10
  type InterventionChainLoader,
@@ -17,7 +17,7 @@
17
17
 
18
18
  import type { SessionId } from '../../types/ids/index.js'
19
19
  import type { SubSessionId } from '../../types/session/ids.js'
20
- import type { DeliverableRef } from '../summary/deliverable.js'
20
+ import type { DeliverableRef } from '../../types/summary/deliverable.js'
21
21
 
22
22
  /**
23
23
  * Minimal record the validator needs to step ancestrally from one
@@ -2,15 +2,15 @@ import { mkdtempSync, rmSync } from 'node:fs'
2
2
  import { tmpdir } from 'node:os'
3
3
  import { join } from 'node:path'
4
4
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
5
- import type { ActorRef } from '../../../session/hierarchy/actor.js'
6
- import type { SubSession } from '../../../session/hierarchy/sub-session.js'
7
5
  import { type ExecFile, GitWorktreeDriver } from '../../../session/workspace/git-worktree.js'
8
- import type { WorkspaceRef } from '../../../session/workspace/ref.js'
9
6
  import { WorkspaceBackendRegistry } from '../../../session/workspace/registry.js'
10
7
  import { InMemorySessionStore } from '../../../store/session/memory.js'
11
8
  import type { AgentId, TenantId, UserId } from '../../../types/ids/index.js'
12
9
  import { createUserMessage } from '../../../types/message/index.js'
10
+ import type { ActorRef } from '../../../types/session/actor.js'
13
11
  import type { ThreadId, WorkspaceId } from '../../../types/session/ids.js'
12
+ import type { SubSession } from '../../../types/session/sub-session.js'
13
+ import type { WorkspaceRef } from '../../../types/workspace/ref.js'
14
14
  import {
15
15
  ArchivalManager,
16
16
  ArchiveNotConfiguredError,
@@ -3,13 +3,13 @@ import { readFile, readdir } from 'node:fs/promises'
3
3
  import { tmpdir } from 'node:os'
4
4
  import { join } from 'node:path'
5
5
  import { afterEach, beforeEach, describe, expect, it } from 'vitest'
6
- import type { SessionMessage } from '../../../store/session/messages.js'
7
6
  import type { MessageId, SessionId, TenantId } from '../../../types/ids/index.js'
8
7
  import { createUserMessage } from '../../../types/message/index.js'
8
+ import type { ArchiveBackendRef } from '../../../types/retention/archive-backend-ref.js'
9
9
  import type { SubSessionId, SummaryId, WorkspaceId } from '../../../types/session/ids.js'
10
- import type { SessionSummaryRef } from '../../summary/ref.js'
11
- import type { WorkspaceRef } from '../../workspace/ref.js'
12
- import type { ArchiveBackendRef } from '../archive-backend-ref.js'
10
+ import type { SessionMessage } from '../../../types/session/messages.js'
11
+ import type { SessionSummaryRef } from '../../../types/summary/ref.js'
12
+ import type { WorkspaceRef } from '../../../types/workspace/ref.js'
13
13
  import { DiskArchiveBackend } from '../disk-backend.js'
14
14
 
15
15
  const tenantA = 'tnt_alpha' as TenantId
@@ -28,8 +28,8 @@
28
28
  import type { SessionId, SubSessionId, TenantId } from '../../types/ids/index.js'
29
29
  import type { WorkspaceId } from '../../types/session/ids.js'
30
30
  import type { SessionStore } from '../../types/session/store.js'
31
- import type { SubSession, SubSessionStatus } from '../hierarchy/sub-session.js'
32
- import type { WorkspaceRef } from '../workspace/ref.js'
31
+ import type { SubSession, SubSessionStatus } from '../../types/session/sub-session.js'
32
+ import type { WorkspaceRef } from '../../types/workspace/ref.js'
33
33
  import type { WorkspaceBackendRegistry } from '../workspace/registry.js'
34
34
  import type { ArchiveBackend, SubSessionTombstone } from './backend.js'
35
35
 
@@ -12,12 +12,12 @@
12
12
  * `SessionStore` is the Store it mutates.
13
13
  */
14
14
 
15
- import type { SessionMessage } from '../../store/session/messages.js'
16
15
  import type { SessionId, SubSessionId, TenantId } from '../../types/ids/index.js'
16
+ import type { ArchiveBackendRef } from '../../types/retention/archive-backend-ref.js'
17
17
  import type { SummaryId } from '../../types/session/ids.js'
18
- import type { SessionSummaryRef } from '../summary/ref.js'
19
- import type { WorkspaceRef } from '../workspace/ref.js'
20
- import type { ArchiveBackendRef } from './archive-backend-ref.js'
18
+ import type { SessionMessage } from '../../types/session/messages.js'
19
+ import type { SessionSummaryRef } from '../../types/summary/ref.js'
20
+ import type { WorkspaceRef } from '../../types/workspace/ref.js'
21
21
 
22
22
  /**
23
23
  * Output of a successful {@link ArchiveBackend.store} call. `archiveRef` is
@@ -29,11 +29,11 @@
29
29
  import { randomBytes } from 'node:crypto'
30
30
  import { mkdir, readFile, readdir, rename, unlink, writeFile } from 'node:fs/promises'
31
31
  import { join } from 'node:path'
32
- import type { SessionMessage } from '../../store/session/messages.js'
33
32
  import type { SessionId, SubSessionId, TenantId } from '../../types/ids/index.js'
34
- import type { SessionSummaryRef } from '../summary/ref.js'
35
- import type { WorkspaceRef } from '../workspace/ref.js'
36
- import type { ArchiveBackendRef } from './archive-backend-ref.js'
33
+ import type { ArchiveBackendRef } from '../../types/retention/archive-backend-ref.js'
34
+ import type { SessionMessage } from '../../types/session/messages.js'
35
+ import type { SessionSummaryRef } from '../../types/summary/ref.js'
36
+ import type { WorkspaceRef } from '../../types/workspace/ref.js'
37
37
  import type { ArchiveBackend, ArchiveInput, ArchiveOutput } from './backend.js'
38
38
 
39
39
  /**