@namzu/cli 26.3.0 → 28.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. package/CHANGELOG.md +271 -0
  2. package/README.md +67 -46
  3. package/dist/bin.js +7 -0
  4. package/dist/bin.js.map +1 -1
  5. package/dist/checkpoints/store.d.ts +17 -4
  6. package/dist/checkpoints/store.d.ts.map +1 -1
  7. package/dist/checkpoints/store.js +20 -5
  8. package/dist/checkpoints/store.js.map +1 -1
  9. package/dist/cli.d.ts +2 -0
  10. package/dist/cli.d.ts.map +1 -1
  11. package/dist/cli.js +124 -14
  12. package/dist/cli.js.map +1 -1
  13. package/dist/commands/acp.d.ts +23 -1
  14. package/dist/commands/acp.d.ts.map +1 -1
  15. package/dist/commands/acp.js +41 -2
  16. package/dist/commands/acp.js.map +1 -1
  17. package/dist/commands/drain.d.ts +69 -2
  18. package/dist/commands/drain.d.ts.map +1 -1
  19. package/dist/commands/drain.js +216 -136
  20. package/dist/commands/drain.js.map +1 -1
  21. package/dist/commands/eval.js +1 -1
  22. package/dist/commands/eval.js.map +1 -1
  23. package/dist/commands/{run-flags.d.ts → exec-flags.d.ts} +36 -28
  24. package/dist/commands/exec-flags.d.ts.map +1 -0
  25. package/dist/commands/{run-flags.js → exec-flags.js} +35 -27
  26. package/dist/commands/exec-flags.js.map +1 -0
  27. package/dist/commands/exec-json.d.ts +75 -0
  28. package/dist/commands/exec-json.d.ts.map +1 -0
  29. package/dist/commands/exec-json.js +473 -0
  30. package/dist/commands/exec-json.js.map +1 -0
  31. package/dist/commands/exec.d.ts +42 -0
  32. package/dist/commands/exec.d.ts.map +1 -0
  33. package/dist/commands/exec.js +683 -0
  34. package/dist/commands/exec.js.map +1 -0
  35. package/dist/commands/host-queries.d.ts +12 -0
  36. package/dist/commands/host-queries.d.ts.map +1 -0
  37. package/dist/commands/host-queries.js +149 -0
  38. package/dist/commands/host-queries.js.map +1 -0
  39. package/dist/commands/prior-messages.js +1 -1
  40. package/dist/commands/prior-messages.js.map +1 -1
  41. package/dist/commands/provider-wait.d.ts +5 -5
  42. package/dist/commands/provider-wait.d.ts.map +1 -1
  43. package/dist/commands/provider-wait.js +2 -2
  44. package/dist/commands/registry.d.ts.map +1 -1
  45. package/dist/commands/registry.js +2 -0
  46. package/dist/commands/registry.js.map +1 -1
  47. package/dist/commands/resident-flags.d.ts +2 -2
  48. package/dist/commands/resident-flags.d.ts.map +1 -1
  49. package/dist/commands/resident-flags.js +4 -2
  50. package/dist/commands/resident-flags.js.map +1 -1
  51. package/dist/commands/resident-learning.js +1 -1
  52. package/dist/commands/resident-learning.js.map +1 -1
  53. package/dist/commands/resident.d.ts.map +1 -1
  54. package/dist/commands/resident.js +3 -2
  55. package/dist/commands/resident.js.map +1 -1
  56. package/dist/commands/serve.js +2 -2
  57. package/dist/commands/serve.js.map +1 -1
  58. package/dist/commands/skills.js +1 -1
  59. package/dist/commands/skills.js.map +1 -1
  60. package/dist/commands/state.js +8 -8
  61. package/dist/commands/state.js.map +1 -1
  62. package/dist/commands/stdin.d.ts +5 -5
  63. package/dist/commands/stdin.js +5 -5
  64. package/dist/commands/types.d.ts +2 -0
  65. package/dist/commands/types.d.ts.map +1 -1
  66. package/dist/config/load.d.ts +1 -1
  67. package/dist/config/load.d.ts.map +1 -1
  68. package/dist/config/load.js +36 -5
  69. package/dist/config/load.js.map +1 -1
  70. package/dist/config/schema.d.ts +59 -20
  71. package/dist/config/schema.d.ts.map +1 -1
  72. package/dist/config/schema.js.map +1 -1
  73. package/dist/config/tool-result-screens.js +1 -1
  74. package/dist/config/turn-guards.d.ts +23 -0
  75. package/dist/config/turn-guards.d.ts.map +1 -0
  76. package/dist/config/turn-guards.js +46 -0
  77. package/dist/config/turn-guards.js.map +1 -0
  78. package/dist/context/directories.d.ts +37 -0
  79. package/dist/context/directories.d.ts.map +1 -0
  80. package/dist/context/directories.js +69 -0
  81. package/dist/context/directories.js.map +1 -0
  82. package/dist/context/environment.d.ts +55 -0
  83. package/dist/context/environment.d.ts.map +1 -1
  84. package/dist/context/environment.js +96 -0
  85. package/dist/context/environment.js.map +1 -1
  86. package/dist/context/project-tracker.d.ts +3 -3
  87. package/dist/context/project-tracker.d.ts.map +1 -1
  88. package/dist/context/project-tracker.js +3 -3
  89. package/dist/context/project-tracker.js.map +1 -1
  90. package/dist/context/project.d.ts +2 -2
  91. package/dist/context/project.js +2 -2
  92. package/dist/context/sandbox.d.ts +22 -3
  93. package/dist/context/sandbox.d.ts.map +1 -1
  94. package/dist/context/sandbox.js +42 -4
  95. package/dist/context/sandbox.js.map +1 -1
  96. package/dist/doctor/checks/chain.d.ts +1 -1
  97. package/dist/doctor/checks/chain.js +7 -7
  98. package/dist/doctor/checks/chain.js.map +1 -1
  99. package/dist/doctor/checks/invariants.d.ts +2 -2
  100. package/dist/doctor/checks/invariants.js +5 -5
  101. package/dist/doctor/checks/invariants.js.map +1 -1
  102. package/dist/doctor/checks/logging.js +1 -1
  103. package/dist/doctor/checks/logging.js.map +1 -1
  104. package/dist/doctor/checks/sandbox.js +1 -1
  105. package/dist/doctor/checks/sandbox.js.map +1 -1
  106. package/dist/doctor/checks/session-export.d.ts +1 -1
  107. package/dist/doctor/checks/session-export.js +2 -2
  108. package/dist/doctor/checks/session-export.js.map +1 -1
  109. package/dist/doctor/checks/telemetry.d.ts +1 -1
  110. package/dist/doctor/checks/telemetry.js +1 -1
  111. package/dist/doctor/registry.js +2 -2
  112. package/dist/doctor/registry.js.map +1 -1
  113. package/dist/exit-codes.d.ts +2 -2
  114. package/dist/exit-codes.js +2 -2
  115. package/dist/integrations/mcp/servers.d.ts +1 -1
  116. package/dist/integrations/providers/access.d.ts +4 -1
  117. package/dist/integrations/providers/access.d.ts.map +1 -1
  118. package/dist/integrations/providers/access.js +6 -3
  119. package/dist/integrations/providers/access.js.map +1 -1
  120. package/dist/integrations/providers/chain-capabilities.d.ts +6 -6
  121. package/dist/integrations/providers/chain-capabilities.js +8 -8
  122. package/dist/integrations/providers/chain-capabilities.js.map +1 -1
  123. package/dist/integrations/providers/register.d.ts +1 -1
  124. package/dist/integrations/providers/register.js +1 -1
  125. package/dist/integrations/providers/registry.d.ts +1 -1
  126. package/dist/integrations/providers/zen-catalogue.d.ts +100 -0
  127. package/dist/integrations/providers/zen-catalogue.d.ts.map +1 -0
  128. package/dist/integrations/providers/zen-catalogue.js +196 -0
  129. package/dist/integrations/providers/zen-catalogue.js.map +1 -0
  130. package/dist/integrations/resident/inspection.d.ts +4 -1
  131. package/dist/integrations/resident/inspection.d.ts.map +1 -1
  132. package/dist/integrations/resident/inspection.js +53 -34
  133. package/dist/integrations/resident/inspection.js.map +1 -1
  134. package/dist/integrations/resident/learning-storage.d.ts +7 -2
  135. package/dist/integrations/resident/learning-storage.d.ts.map +1 -1
  136. package/dist/integrations/resident/learning-storage.js +12 -8
  137. package/dist/integrations/resident/learning-storage.js.map +1 -1
  138. package/dist/integrations/resident/runner-launch.d.ts +3 -3
  139. package/dist/integrations/resident/runner-launch.d.ts.map +1 -1
  140. package/dist/integrations/resident/runner-store.d.ts +1 -1
  141. package/dist/integrations/resident/runner-store.d.ts.map +1 -1
  142. package/dist/integrations/resident/runner-store.js +5 -2
  143. package/dist/integrations/resident/runner-store.js.map +1 -1
  144. package/dist/integrations/resident/runner-worker.js +23 -0
  145. package/dist/integrations/resident/runner-worker.js.map +1 -1
  146. package/dist/integrations/resident/session-log-reads.d.ts +37 -0
  147. package/dist/integrations/resident/session-log-reads.d.ts.map +1 -0
  148. package/dist/integrations/resident/session-log-reads.js +125 -0
  149. package/dist/integrations/resident/session-log-reads.js.map +1 -0
  150. package/dist/integrations/resident/session-step.d.ts +4 -2
  151. package/dist/integrations/resident/session-step.d.ts.map +1 -1
  152. package/dist/integrations/resident/session-step.js +16 -14
  153. package/dist/integrations/resident/session-step.js.map +1 -1
  154. package/dist/integrations/resident/storage.d.ts +23 -1
  155. package/dist/integrations/resident/storage.d.ts.map +1 -1
  156. package/dist/integrations/resident/storage.js +60 -17
  157. package/dist/integrations/resident/storage.js.map +1 -1
  158. package/dist/integrations/resident/tool-evidence.d.ts +4 -2
  159. package/dist/integrations/resident/tool-evidence.d.ts.map +1 -1
  160. package/dist/integrations/resident/tool-evidence.js +36 -30
  161. package/dist/integrations/resident/tool-evidence.js.map +1 -1
  162. package/dist/integrations/resident/verification.d.ts +2 -2
  163. package/dist/integrations/resident/verification.d.ts.map +1 -1
  164. package/dist/integrations/resident/verification.js +4 -4
  165. package/dist/integrations/resident/verification.js.map +1 -1
  166. package/dist/integrations/sessions/checkpoint-view.d.ts +13 -0
  167. package/dist/integrations/sessions/checkpoint-view.d.ts.map +1 -0
  168. package/dist/integrations/sessions/checkpoint-view.js +48 -0
  169. package/dist/integrations/sessions/checkpoint-view.js.map +1 -0
  170. package/dist/integrations/sessions/context-inventory.js +1 -1
  171. package/dist/integrations/sessions/context-inventory.js.map +1 -1
  172. package/dist/integrations/sessions/conversation-search.d.ts +16 -20
  173. package/dist/integrations/sessions/conversation-search.d.ts.map +1 -1
  174. package/dist/integrations/sessions/conversation-search.js +305 -731
  175. package/dist/integrations/sessions/conversation-search.js.map +1 -1
  176. package/dist/integrations/sessions/evidence-page-validation.d.ts +4 -4
  177. package/dist/integrations/sessions/evidence-page-validation.d.ts.map +1 -1
  178. package/dist/integrations/sessions/evidence-page-validation.js +1 -1
  179. package/dist/integrations/sessions/evidence-page-validation.js.map +1 -1
  180. package/dist/integrations/sessions/evidence-recall.d.ts +40 -2
  181. package/dist/integrations/sessions/evidence-recall.d.ts.map +1 -1
  182. package/dist/integrations/sessions/evidence-recall.js +41 -97
  183. package/dist/integrations/sessions/evidence-recall.js.map +1 -1
  184. package/dist/integrations/sessions/store.d.ts +153 -85
  185. package/dist/integrations/sessions/store.d.ts.map +1 -1
  186. package/dist/integrations/sessions/store.js +414 -484
  187. package/dist/integrations/sessions/store.js.map +1 -1
  188. package/dist/integrations/sessions/task-context.d.ts +15 -2
  189. package/dist/integrations/sessions/task-context.d.ts.map +1 -1
  190. package/dist/integrations/sessions/task-context.js +34 -11
  191. package/dist/integrations/sessions/task-context.js.map +1 -1
  192. package/dist/integrations/sessions/transcript-export.d.ts +13 -6
  193. package/dist/integrations/sessions/transcript-export.d.ts.map +1 -1
  194. package/dist/integrations/sessions/transcript-export.js +148 -263
  195. package/dist/integrations/sessions/transcript-export.js.map +1 -1
  196. package/dist/integrations/state/home.d.ts +4 -16
  197. package/dist/integrations/state/home.d.ts.map +1 -1
  198. package/dist/integrations/state/home.js +6 -42
  199. package/dist/integrations/state/home.js.map +1 -1
  200. package/dist/integrations/state/project.d.ts +6 -7
  201. package/dist/integrations/state/project.d.ts.map +1 -1
  202. package/dist/integrations/state/project.js +7 -9
  203. package/dist/integrations/state/project.js.map +1 -1
  204. package/dist/integrations/state/report.d.ts +27 -41
  205. package/dist/integrations/state/report.d.ts.map +1 -1
  206. package/dist/integrations/state/report.js +172 -464
  207. package/dist/integrations/state/report.js.map +1 -1
  208. package/dist/integrations/state/retention.d.ts +18 -0
  209. package/dist/integrations/state/retention.d.ts.map +1 -0
  210. package/dist/integrations/state/retention.js +18 -0
  211. package/dist/integrations/state/retention.js.map +1 -0
  212. package/dist/integrations/subagents/activity.d.ts +36 -31
  213. package/dist/integrations/subagents/activity.d.ts.map +1 -1
  214. package/dist/integrations/subagents/activity.js +27 -23
  215. package/dist/integrations/subagents/activity.js.map +1 -1
  216. package/dist/integrations/subagents/batches.d.ts +91 -0
  217. package/dist/integrations/subagents/batches.d.ts.map +1 -0
  218. package/dist/integrations/subagents/batches.js +172 -0
  219. package/dist/integrations/subagents/batches.js.map +1 -0
  220. package/dist/integrations/subagents/parent.d.ts +26 -11
  221. package/dist/integrations/subagents/parent.d.ts.map +1 -1
  222. package/dist/integrations/subagents/parent.js +13 -28
  223. package/dist/integrations/subagents/parent.js.map +1 -1
  224. package/dist/integrations/subagents/policy.d.ts +2 -2
  225. package/dist/integrations/subagents/policy.d.ts.map +1 -1
  226. package/dist/integrations/subagents/policy.js +2 -2
  227. package/dist/integrations/subagents/policy.js.map +1 -1
  228. package/dist/integrations/subagents/replay.d.ts +91 -26
  229. package/dist/integrations/subagents/replay.d.ts.map +1 -1
  230. package/dist/integrations/subagents/replay.js +216 -114
  231. package/dist/integrations/subagents/replay.js.map +1 -1
  232. package/dist/integrations/subagents/runtime.d.ts +50 -26
  233. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  234. package/dist/integrations/subagents/runtime.js +132 -126
  235. package/dist/integrations/subagents/runtime.js.map +1 -1
  236. package/dist/integrations/subagents/saved-agents.d.ts +57 -0
  237. package/dist/integrations/subagents/saved-agents.d.ts.map +1 -0
  238. package/dist/integrations/subagents/saved-agents.js +102 -0
  239. package/dist/integrations/subagents/saved-agents.js.map +1 -0
  240. package/dist/integrations/subagents/slash.d.ts +55 -0
  241. package/dist/integrations/subagents/slash.d.ts.map +1 -0
  242. package/dist/integrations/subagents/slash.js +45 -0
  243. package/dist/integrations/subagents/slash.js.map +1 -0
  244. package/dist/integrations/telemetry/session-export.d.ts +6 -6
  245. package/dist/integrations/telemetry/session-export.d.ts.map +1 -1
  246. package/dist/integrations/telemetry/session-export.js +2 -2
  247. package/dist/integrations/web/search.d.ts +1 -1
  248. package/dist/logging.d.ts +5 -5
  249. package/dist/logging.js +6 -6
  250. package/dist/memory/presentation.d.ts +11 -0
  251. package/dist/memory/presentation.d.ts.map +1 -1
  252. package/dist/memory/presentation.js +25 -0
  253. package/dist/memory/presentation.js.map +1 -1
  254. package/dist/memory/store.d.ts +13 -7
  255. package/dist/memory/store.d.ts.map +1 -1
  256. package/dist/memory/store.js +37 -11
  257. package/dist/memory/store.js.map +1 -1
  258. package/dist/memory/typed.d.ts +116 -0
  259. package/dist/memory/typed.d.ts.map +1 -0
  260. package/dist/memory/typed.js +336 -0
  261. package/dist/memory/typed.js.map +1 -0
  262. package/dist/permissions/checks.d.ts +1 -1
  263. package/dist/permissions/checks.js +1 -1
  264. package/dist/permissions/headless-trust.d.ts +4 -4
  265. package/dist/permissions/headless-trust.d.ts.map +1 -1
  266. package/dist/permissions/headless-trust.js +6 -6
  267. package/dist/permissions/headless-trust.js.map +1 -1
  268. package/dist/permissions/mode.d.ts +4 -4
  269. package/dist/permissions/mode.js +1 -1
  270. package/dist/permissions/rules.d.ts +1 -1
  271. package/dist/permissions/rules.js +1 -1
  272. package/dist/termination.d.ts +75 -0
  273. package/dist/termination.d.ts.map +1 -0
  274. package/dist/termination.js +143 -0
  275. package/dist/termination.js.map +1 -0
  276. package/dist/tui/AgentExplorer.d.ts +2 -2
  277. package/dist/tui/AgentExplorer.js +4 -4
  278. package/dist/tui/AgentExplorer.js.map +1 -1
  279. package/dist/tui/App.d.ts +9 -1
  280. package/dist/tui/App.d.ts.map +1 -1
  281. package/dist/tui/App.js +456 -307
  282. package/dist/tui/App.js.map +1 -1
  283. package/dist/tui/LiveActivity.d.ts +1 -1
  284. package/dist/tui/LiveActivity.d.ts.map +1 -1
  285. package/dist/tui/PermissionOverlay.d.ts +8 -0
  286. package/dist/tui/PermissionOverlay.d.ts.map +1 -1
  287. package/dist/tui/PermissionOverlay.js +25 -2
  288. package/dist/tui/PermissionOverlay.js.map +1 -1
  289. package/dist/tui/Picker.js +1 -1
  290. package/dist/tui/agent.d.ts +211 -135
  291. package/dist/tui/agent.d.ts.map +1 -1
  292. package/dist/tui/agent.js +535 -316
  293. package/dist/tui/agent.js.map +1 -1
  294. package/dist/tui/conversation-evidence-view.js +3 -3
  295. package/dist/tui/conversation-evidence-view.js.map +1 -1
  296. package/dist/tui/conversation-history.d.ts +4 -21
  297. package/dist/tui/conversation-history.d.ts.map +1 -1
  298. package/dist/tui/conversation-history.js +4 -28
  299. package/dist/tui/conversation-history.js.map +1 -1
  300. package/dist/tui/index.d.ts.map +1 -1
  301. package/dist/tui/index.js +27 -1
  302. package/dist/tui/index.js.map +1 -1
  303. package/dist/tui/log-pane.js +1 -1
  304. package/dist/tui/markdownParser.d.ts +1 -1
  305. package/dist/tui/markdownParser.js +1 -1
  306. package/dist/tui/permission-review.d.ts +16 -0
  307. package/dist/tui/permission-review.d.ts.map +1 -1
  308. package/dist/tui/permission-review.js +25 -2
  309. package/dist/tui/permission-review.js.map +1 -1
  310. package/dist/tui/slashCommands.d.ts +30 -41
  311. package/dist/tui/slashCommands.d.ts.map +1 -1
  312. package/dist/tui/slashCommands.js +75 -66
  313. package/dist/tui/slashCommands.js.map +1 -1
  314. package/dist/tui/status-panel-layout.js +1 -1
  315. package/dist/tui/status-panel-layout.js.map +1 -1
  316. package/dist/tui/{run-interruption.d.ts → turn-interruption.d.ts} +4 -4
  317. package/dist/tui/turn-interruption.d.ts.map +1 -0
  318. package/dist/tui/{run-interruption.js → turn-interruption.js} +20 -20
  319. package/dist/tui/turn-interruption.js.map +1 -0
  320. package/dist/tui/turn-limits-settings.d.ts +39 -0
  321. package/dist/tui/turn-limits-settings.d.ts.map +1 -0
  322. package/dist/tui/{run-limits-settings.js → turn-limits-settings.js} +18 -18
  323. package/dist/tui/turn-limits-settings.js.map +1 -0
  324. package/dist/tui/types.d.ts +3 -3
  325. package/dist/tui/types.d.ts.map +1 -1
  326. package/dist/user-commands/store.d.ts +4 -4
  327. package/dist/user-commands/store.js +5 -5
  328. package/dist/user-commands/store.js.map +1 -1
  329. package/package.json +6 -6
  330. package/dist/commands/run-flags.d.ts.map +0 -1
  331. package/dist/commands/run-flags.js.map +0 -1
  332. package/dist/commands/run-stream.d.ts +0 -65
  333. package/dist/commands/run-stream.d.ts.map +0 -1
  334. package/dist/commands/run-stream.js +0 -603
  335. package/dist/commands/run-stream.js.map +0 -1
  336. package/dist/commands/run.d.ts +0 -39
  337. package/dist/commands/run.d.ts.map +0 -1
  338. package/dist/commands/run.js +0 -533
  339. package/dist/commands/run.js.map +0 -1
  340. package/dist/config/run-limits.d.ts +0 -11
  341. package/dist/config/run-limits.d.ts.map +0 -1
  342. package/dist/config/run-limits.js +0 -64
  343. package/dist/config/run-limits.js.map +0 -1
  344. package/dist/integrations/sessions/compaction-evidence.d.ts +0 -5
  345. package/dist/integrations/sessions/compaction-evidence.d.ts.map +0 -1
  346. package/dist/integrations/sessions/compaction-evidence.js +0 -59
  347. package/dist/integrations/sessions/compaction-evidence.js.map +0 -1
  348. package/dist/integrations/sessions/database.d.ts +0 -5
  349. package/dist/integrations/sessions/database.d.ts.map +0 -1
  350. package/dist/integrations/sessions/database.js +0 -34
  351. package/dist/integrations/sessions/database.js.map +0 -1
  352. package/dist/integrations/sessions/paths.d.ts +0 -7
  353. package/dist/integrations/sessions/paths.d.ts.map +0 -1
  354. package/dist/integrations/sessions/paths.js +0 -14
  355. package/dist/integrations/sessions/paths.js.map +0 -1
  356. package/dist/integrations/sessions/run-discovery.d.ts +0 -24
  357. package/dist/integrations/sessions/run-discovery.d.ts.map +0 -1
  358. package/dist/integrations/sessions/run-discovery.js +0 -142
  359. package/dist/integrations/sessions/run-discovery.js.map +0 -1
  360. package/dist/integrations/sessions/turn-evidence.d.ts +0 -129
  361. package/dist/integrations/sessions/turn-evidence.d.ts.map +0 -1
  362. package/dist/integrations/sessions/turn-evidence.js +0 -517
  363. package/dist/integrations/sessions/turn-evidence.js.map +0 -1
  364. package/dist/integrations/subagents/history.d.ts +0 -26
  365. package/dist/integrations/subagents/history.d.ts.map +0 -1
  366. package/dist/integrations/subagents/history.js +0 -76
  367. package/dist/integrations/subagents/history.js.map +0 -1
  368. package/dist/integrations/subagents/runs.d.ts +0 -72
  369. package/dist/integrations/subagents/runs.d.ts.map +0 -1
  370. package/dist/integrations/subagents/runs.js +0 -155
  371. package/dist/integrations/subagents/runs.js.map +0 -1
  372. package/dist/tui/run-interruption.d.ts.map +0 -1
  373. package/dist/tui/run-interruption.js.map +0 -1
  374. package/dist/tui/run-limits-settings.d.ts +0 -39
  375. package/dist/tui/run-limits-settings.d.ts.map +0 -1
  376. package/dist/tui/run-limits-settings.js.map +0 -1
@@ -11,26 +11,29 @@
11
11
  * Unlike the earlier `chatStream()`-only adapter, this drives the full
12
12
  * tool-execution loop: the model can call tools, their results are fed
13
13
  * back, and the loop iterates until the turn settles. We translate the
14
- * SDK's `RunEvent` stream into the TUI's smaller `AgentEvent` vocabulary
14
+ * SDK's `SessionEvent` stream into the TUI's smaller `AgentEvent` vocabulary
15
15
  * (text deltas + tool start/end + done/error).
16
16
  *
17
- * The TUI owns conversation history and passes the full `Message[]` on
18
- * every turn (stateless session). Empty / partial states (no
17
+ * The TUI holds the conversation it renders and passes the full `Message[]`
18
+ * on every turn; the session's log, which the kernel appends to while the
19
+ * turn runs, is what a later resume folds back. Empty / partial states (no
19
20
  * credentials, no preferences, no matching detected provider) return an
20
21
  * `emptySession()` whose `send()` yields a single error event so the UI
21
22
  * renders an actionable hint rather than crashing.
22
23
  */
23
- import { type AuthorizationRule, type BackgroundJob, type CheckpointStore, type CompactionResult, type CostInfo, type DurableRunEntry, type FencingToken, type GoalRoundAuthority, type LLMProvider, type Message, type ModelInfo, type PrepareStep, type ProjectId, type ReasoningEffort, type ResidentHistorySource, type ResidentStepPromptOptions, type ResidentToolEvidenceSource, type ResumeHandler, type ResumeOutcome, type ReviewAnswer, type RunEvent, type RunId, type SessionGoalStore, type SessionId, type StopReason, type StructuredOutputConfig, type TaskStore, type TenantId, type TokenBudgetSummary, type ToolCallView, type ToolPresenter, ToolRegistry, type ToolResultView, type ToolReviewAnswer, type ToolReviewPrompt, type ToolReviewRequest, type TopicId, batchNeedsReview } from '@namzu/sdk';
24
+ import { type AuthorizationRule, type BackgroundJob, type CompactionResult, type CostInfo, type GoalRoundAuthority, type LLMProvider, type MemoryType, type Message, type ModelInfo, type Origin, type PrepareStep, type ProjectId, type ReasoningEffort, type RenderedMemoryIndex, type ResidentHistorySource, type ResidentStepPromptOptions, type ResidentToolEvidenceSource, type ResumeHandler, type ResumeOutcome, type ReviewAnswer, type SessionCheckpointStore, type SessionEvent, type SessionGoalStore, type SessionId, type SessionLease, type SessionLog, type SessionStartedRecord, type SessionTokenBudgetSummary, type StopReason, type StructuredOutputConfig, type TaskStore, type TenantId, type ToolCallEscalation, type ToolCallView, type ToolPresenter, ToolRegistry, type ToolResultView, type ToolReviewAnswer, type ToolReviewPrompt, type ToolReviewRequest, type TopicId, type TurnId, batchNeedsReview } from '@namzu/sdk';
24
25
  import { FileCheckpointStore } from '../checkpoints/store.js';
25
- import type { CompactionCliConfig, HooksConfig, MemoryCliConfig, PluginConfig, RunLimitsConfig, SandboxConfig, WebConfig } from '../config/schema.js';
26
+ import type { CompactionCliConfig, HooksConfig, MemoryCliConfig, PluginConfig, SandboxConfig, TurnLimitsConfig, WebConfig } from '../config/schema.js';
26
27
  import { type ToolResultScreenConfig } from '../config/tool-result-screens.js';
28
+ import { type SessionDirectories } from '../context/directories.js';
27
29
  import { type SandboxSummary } from '../context/sandbox.js';
28
30
  import { type ConnectedMcpServer, type FailedMcpServer, type McpServersConfig } from '../integrations/mcp/servers.js';
29
31
  import { type CliPluginRuntime } from '../integrations/plugins/runtime.js';
30
32
  import { type DetectedProvider, type Preferences, type ProviderId } from '../integrations/providers/index.js';
31
- import type { ConversationContext } from '../integrations/sessions/store.js';
33
+ import { type ConversationContext } from '../integrations/sessions/store.js';
32
34
  import type { SubagentActivity, SubagentActivitySource } from '../integrations/subagents/activity.js';
33
- import { type OrchestrationRun } from '../integrations/subagents/runs.js';
35
+ import { type Batch } from '../integrations/subagents/batches.js';
36
+ import { type TypedNoteResult } from '../memory/typed.js';
34
37
  import type { PermissionMode } from '../permissions/mode.js';
35
38
  import { type ModelSwitchOutcome } from './model-switch-tool.js';
36
39
  import { type ModelSwitchRequest } from './model-switch.js';
@@ -48,15 +51,15 @@ export type AgentEvent = {
48
51
  * way to name the answer it was looking at.
49
52
  */
50
53
  readonly messageId?: string;
51
- /** The run that produced it — a rating names both. */
52
- readonly runId?: string;
54
+ /** The turn that produced it — a rating names both. */
55
+ readonly turnId?: string;
53
56
  } | {
54
57
  readonly kind: 'tool-start';
55
58
  readonly activity?: 'exploration';
56
59
  /** Exact task identity for host-owned wait presentation. */
57
60
  readonly taskId?: string;
58
- /** Run-scopes provider tool ids, which are not globally unique. */
59
- readonly runId?: string;
61
+ /** Turn-scopes provider tool ids, which are not globally unique. */
62
+ readonly turnId?: string;
60
63
  /** SDK tool-use id — stable across this call's start/end (for tracking). */
61
64
  readonly toolUseId: string;
62
65
  readonly toolName: string;
@@ -67,7 +70,7 @@ export type AgentEvent = {
67
70
  readonly detail?: readonly string[];
68
71
  } | {
69
72
  readonly kind: 'tool-progress';
70
- readonly runId?: string;
73
+ readonly turnId?: string;
71
74
  readonly toolUseId: string;
72
75
  readonly toolName: string;
73
76
  /** Bounded latest-state text from the executing tool. */
@@ -77,7 +80,7 @@ export type AgentEvent = {
77
80
  readonly kind: 'tool-end';
78
81
  /** Verbatim retained output, before terminal preview projection. */
79
82
  readonly output?: string;
80
- readonly runId?: string;
83
+ readonly turnId?: string;
81
84
  readonly toolUseId: string;
82
85
  readonly toolName: string;
83
86
  readonly isError: boolean;
@@ -101,9 +104,12 @@ export type AgentEvent = {
101
104
  readonly done?: boolean;
102
105
  } | {
103
106
  readonly kind: 'usage';
107
+ /** The session and turn this spend belongs to. */
108
+ readonly sessionId?: string;
109
+ readonly turnId?: string;
104
110
  /** Parent and all descendants, reported separately from own usage. */
105
- readonly budget?: TokenBudgetSummary;
106
- /** CUMULATIVE run spend. Grows every turn; never a context size. */
111
+ readonly budget?: SessionTokenBudgetSummary;
112
+ /** CUMULATIVE turn spend. Never a context size. */
107
113
  readonly totalTokens: number;
108
114
  /**
109
115
  * The kernel's cost record, carried whole.
@@ -111,7 +117,7 @@ export type AgentEvent = {
111
117
  * This was `costUsd: number`, narrowed from the same object at the
112
118
  * mapping site, and the number on its own cannot answer the
113
119
  * question the screen asks. A total of zero means two different
114
- * things — the run cost nothing, or nobody could price it — and
120
+ * things — the turn cost nothing, or nobody could price it — and
115
121
  * `unpricedTokens` is what separates them. Passing only the total
116
122
  * left every surface downstream to guess, and both of them guessed
117
123
  * "free".
@@ -131,7 +137,7 @@ export type AgentEvent = {
131
137
  * cannot mark an estimated numerator honestly while silently
132
138
  * treating an assumed window as measured.
133
139
  *
134
- * All four absent when the run resolved no window — then there is
140
+ * All four absent when the turn resolved no window — then there is
135
141
  * no proportion to show, only the spend.
136
142
  */
137
143
  readonly contextTokens?: number;
@@ -142,8 +148,8 @@ export type AgentEvent = {
142
148
  /**
143
149
  * Context was discarded, or an attempt to discard it declined.
144
150
  *
145
- * Everything else this session fixed was the run quietly not doing what the
146
- * operator asked. This is the same class with the opposite sign: the run
151
+ * Everything else this session fixed was the turn quietly not doing what the
152
+ * operator asked. This is the same class with the opposite sign: the turn
147
153
  * quietly doing something they did not ask for. Compaction deletes messages
148
154
  * irrecoverably, and the first time a user learned it existed was when the
149
155
  * agent had forgotten something they were relying on — which reads as the
@@ -185,16 +191,16 @@ export type AgentEvent = {
185
191
  readonly text: string;
186
192
  } | {
187
193
  readonly kind: 'capability-warning';
188
- readonly capability: Extract<RunEvent, {
194
+ readonly capability: Extract<SessionEvent, {
189
195
  type: 'capability_warning';
190
196
  }>['capability'];
191
- readonly contentSource?: Extract<RunEvent, {
197
+ readonly contentSource?: Extract<SessionEvent, {
192
198
  type: 'capability_warning';
193
199
  }>['contentSource'];
194
200
  readonly text: string;
195
201
  } | {
196
202
  readonly kind: 'history-repair';
197
- readonly source: Extract<RunEvent, {
203
+ readonly source: Extract<SessionEvent, {
198
204
  type: 'message_history_repaired';
199
205
  }>['source'];
200
206
  readonly text: string;
@@ -218,45 +224,58 @@ export type AgentEvent = {
218
224
  * no reader anywhere in this package. The name was also wrong for what is
219
225
  * needed here: a "finish reason" in this codebase is `MessageStopReason`,
220
226
  * reported per model message, while the question a caller has at the end of
221
- * a turn is the run-level `StopReason` — did it answer, or did it run out
227
+ * a turn is the turn-level `StopReason` — did it answer, or did it run out
222
228
  * of budget, iterations, time, or permission to say what it produced.
223
229
  */
224
230
  | {
225
231
  readonly kind: 'done';
232
+ /** The session and turn that settled. */
233
+ readonly sessionId?: string;
234
+ readonly turnId?: string;
226
235
  /** Settled kernel result, including an intentionally empty guarded result. */
227
236
  readonly text?: string;
228
237
  readonly stopReason?: StopReason;
229
- readonly budget?: TokenBudgetSummary;
238
+ readonly budget?: SessionTokenBudgetSummary;
230
239
  } | {
231
- /** A recoverable run stopped with an addressable checkpoint. */
240
+ /** A recoverable turn stopped with an addressable checkpoint. */
232
241
  readonly kind: 'paused';
233
- readonly budget?: TokenBudgetSummary;
234
- /** The run that paused: with the checkpoint, what `resumePaused` needs. */
235
- readonly runId: string;
242
+ readonly budget?: SessionTokenBudgetSummary;
243
+ /** The turn that paused: with the checkpoint, what `resumePaused` needs. */
244
+ readonly turnId: string;
236
245
  readonly checkpointId: string;
237
246
  readonly reason: string;
238
- readonly failure?: Extract<RunEvent, {
239
- type: 'run_paused';
247
+ readonly failure?: Extract<SessionEvent, {
248
+ type: 'turn_paused';
240
249
  }>['failure'];
241
- readonly providerError?: Extract<RunEvent, {
242
- type: 'run_paused';
250
+ readonly providerError?: Extract<SessionEvent, {
251
+ type: 'turn_paused';
243
252
  }>['providerError'];
244
- readonly explanation?: Extract<RunEvent, {
245
- type: 'run_paused';
253
+ readonly explanation?: Extract<SessionEvent, {
254
+ type: 'turn_paused';
246
255
  }>['explanation'];
247
256
  } | {
248
257
  readonly kind: 'error';
249
- readonly budget?: TokenBudgetSummary;
258
+ readonly budget?: SessionTokenBudgetSummary;
250
259
  readonly message: string;
251
- readonly failure?: Extract<RunEvent, {
252
- type: 'run_failed';
260
+ readonly failure?: Extract<SessionEvent, {
261
+ type: 'turn_failed';
253
262
  }>['failure'];
254
- readonly providerError?: Extract<RunEvent, {
255
- type: 'run_failed';
263
+ readonly providerError?: Extract<SessionEvent, {
264
+ type: 'turn_failed';
256
265
  }>['providerError'];
257
- readonly explanation?: Extract<RunEvent, {
258
- type: 'run_failed';
266
+ readonly explanation?: Extract<SessionEvent, {
267
+ type: 'turn_failed';
259
268
  }>['explanation'];
269
+ /**
270
+ * The conversation already has an active turn, so this one was not
271
+ * started (`TurnInProgressError`). A paused turn is left to
272
+ * `resumePaused` or `abandonTurn`; nothing is closed implicitly.
273
+ */
274
+ readonly turnInProgress?: {
275
+ readonly sessionId: string;
276
+ readonly activeTurnId: string;
277
+ readonly state: 'running' | 'paused' | 'interrupted';
278
+ };
260
279
  };
261
280
  /** A single tool the model wants to run, surfaced to the user for approval. */
262
281
  export interface PermissionToolCall {
@@ -265,6 +284,8 @@ export interface PermissionToolCall {
265
284
  /** Exact detached input the kernel prepared and the approval covers. */
266
285
  readonly input: unknown;
267
286
  readonly isDestructive: boolean;
287
+ /** What the call reaches past the turn's boundary; see `ToolCallSummary.escalation`. */
288
+ readonly escalation?: ToolCallEscalation;
268
289
  }
269
290
  /** The batch a person is asked about — the kernel's `ToolReviewRequest`. */
270
291
  export type PermissionRequest = ToolReviewRequest;
@@ -290,8 +311,8 @@ export type QuestionAnswer = {
290
311
  };
291
312
  export type QuestionFn = (question: UserQuestion) => Promise<QuestionAnswer>;
292
313
  export interface SendOptions {
293
- /** Overrides for this new run and its built-in children; does not change a parked run. */
294
- readonly limits?: RunLimitsConfig;
314
+ /** Overrides for this new turn and its built-in children; does not change a parked turn. */
315
+ readonly limits?: TurnLimitsConfig;
295
316
  readonly signal?: AbortSignal;
296
317
  /**
297
318
  * Who answers `ask_user_question` this turn. Absent means nobody: the
@@ -326,10 +347,22 @@ export interface SendOptions {
326
347
  * Overrides the session default for this turn only.
327
348
  */
328
349
  readonly permissionMode?: PermissionMode;
329
- /** Caller-reserved identity used to correlate this turn before it starts. */
330
- readonly runId?: RunId;
331
- /** Exact durable admission that makes goal tools visible for this one run. */
350
+ /**
351
+ * Caller-reserved identity for this new turn, for a host that has to name
352
+ * the turn before it starts (a resident step's verifier). Absent: the
353
+ * kernel mints one, and the session learns it from the turn's first event.
354
+ */
355
+ readonly turnId?: TurnId;
356
+ /** Why this turn exists (a prompt, a goal round, a resident step), recorded on `turn_started`. */
357
+ readonly origin?: Origin;
358
+ /** Exact durable admission that makes goal tools visible for this one turn. */
332
359
  readonly goalRound?: GoalRoundAuthority;
360
+ /**
361
+ * Close an `interrupted` active turn (its process is gone) before this one
362
+ * begins, as `turn_failed{ interrupted }`. The interactive TUI passes it: it
363
+ * never resumed an interrupted turn. A paused turn is never closed this way.
364
+ */
365
+ readonly abandonInterrupted?: boolean;
333
366
  /**
334
367
  * Called before a batch of non-read-only tools runs. Resolves with the
335
368
  * user's decision. When omitted, prompt mode auto-approves because nobody
@@ -348,7 +381,7 @@ export interface SendOptions {
348
381
  * Receives the settled conversation projection exactly as the kernel will
349
382
  * replay it on a later turn.
350
383
  *
351
- * Kept out of `AgentEvent`: `run-stream` writes every event to NDJSON, while
384
+ * Kept out of `AgentEvent`: `exec --json` writes every event to NDJSON, while
352
385
  * this history may contain opaque reasoning signatures/encrypted blocks that
353
386
  * belong in provider context and durable state, never a rendered stream.
354
387
  */
@@ -356,31 +389,33 @@ export interface SendOptions {
356
389
  }
357
390
  /** What {@link AgentSession.resumeDurable} needs that the session does not hold. */
358
391
  export interface ResumeDurableParams {
392
+ /** The paused or interrupted turn to continue, and the session it belongs to. */
393
+ readonly entry: {
394
+ readonly tenantId: TenantId;
395
+ readonly projectId: ProjectId;
396
+ readonly sessionId: SessionId;
397
+ readonly turnId: TurnId;
398
+ };
399
+ /** The session's log; the resumed turn appends to it. */
400
+ readonly sessionLog: SessionLog;
401
+ /** Where the turn's checkpoints are. Absent: `<session-id>/checkpoints/` beside the log. */
402
+ readonly checkpointStore?: SessionCheckpointStore;
359
403
  /**
360
- * The run to continue, straight out of a durable listing.
361
- *
362
- * A `DurableRunEntry` IS an addressable run scope, which is why it can be
363
- * passed here unreassembled — and why there is no chance of assembling it
364
- * wrong.
365
- */
366
- readonly entry: DurableRunEntry;
367
- /** The backend the entry came from. */
368
- readonly checkpointStore: CheckpointStore;
369
- /**
370
- * The fence of the claim this process holds on the run.
371
- *
372
- * Omit it only for a single-writer host. Present, it rides every durable
373
- * write the resumed run makes, so a worker that stalled past its lease
374
- * cannot overwrite the record of whoever took the run over.
404
+ * The lease this process holds on the session (`claimSession`). Present,
405
+ * every record the resumed turn appends carries its fence, so a worker that
406
+ * stalled past its lease cannot write over whoever took the session over.
375
407
  */
376
- readonly claimFence?: FencingToken;
408
+ readonly lease?: SessionLease;
377
409
  readonly signal?: AbortSignal;
378
410
  }
379
411
  export interface ResumePausedParams {
380
- /** The run the `paused` event named. */
381
- readonly runId: string;
382
- /** The checkpoint the `paused` event named. */
383
- readonly checkpointId: string;
412
+ /** The turn the `paused` event named. */
413
+ readonly turnId: string;
414
+ /**
415
+ * The checkpoint the `paused` event named. Absent: the one an open
416
+ * decision references, else the newest.
417
+ */
418
+ readonly checkpointId?: string;
384
419
  readonly signal?: AbortSignal;
385
420
  }
386
421
  export interface AgentSession {
@@ -393,7 +428,7 @@ export interface AgentSession {
393
428
  *
394
429
  * Carried on the session rather than re-resolved by whoever asks, because
395
430
  * resolving builds a provider — and a second one would answer about a
396
- * different sandbox than the one the run is using.
431
+ * different sandbox than the one the turn is using.
397
432
  */
398
433
  readonly sandbox: SandboxSummary;
399
434
  readonly providerSummary: string | null;
@@ -526,15 +561,15 @@ export interface AgentSession {
526
561
  * the runtime to find out.
527
562
  */
528
563
  readonly agentIds: readonly string[];
529
- /** Actual task store of this conversation's current/latest run; absent before a run starts. */
564
+ /** Task store of this conversation (`<session-id>/tasks/`); absent before a turn starts. */
530
565
  readonly currentTaskStore?: () => TaskStore | undefined;
531
- /** Forget the selected run when the operator leaves its conversation. Does not delete tasks. */
566
+ /** Forget the selected store when the operator leaves its conversation. Does not delete tasks. */
532
567
  readonly resetTaskStore?: () => void;
533
568
  /** Children created in this process, available for the TUI's observational view. */
534
569
  readonly subagents?: SubagentActivitySource;
535
570
  /**
536
- * Children of this conversation's earlier runs, rebuilt from the evidence
537
- * they left on disk.
571
+ * Children of this conversation's earlier turns, rebuilt from their own
572
+ * session logs.
538
573
  *
539
574
  * The counterpart of {@link subagents}, which only ever holds what THIS
540
575
  * process launched and only until its eighty-agent bound evicts it. Both
@@ -549,17 +584,13 @@ export interface AgentSession {
549
584
  */
550
585
  readonly savedChildren?: () => Promise<readonly SubagentActivity[]>;
551
586
  /**
552
- * Finished parent turns this conversation delegated work under, read from
553
- * disk — the counterpart of {@link savedChildren} for `/agents runs`,
554
- * grouped by parent run rather than flattened to one row per child.
555
- *
556
- * A run still in flight is never reported here: it belongs to
557
- * `liveOrchestrationRuns` over the live monitor's own snapshot instead, the
558
- * same split {@link savedChildren} draws against `subagents`. Optional for
559
- * the same reason that one is — an embedded session with no evidence on
560
- * disk has none to offer.
587
+ * Batches of delegated work this conversation's turns launched, read from
588
+ * the session index — the counterpart of {@link savedChildren} for
589
+ * `/agents batches`, grouped by parent turn rather than flattened to one row
590
+ * per child. The live half comes from the monitor; `agentsSlashCommand`
591
+ * merges the two. Optional because a session with no durable log has none.
561
592
  */
562
- readonly listOrchestrationRuns?: () => Promise<readonly OrchestrationRun[]>;
593
+ readonly listSavedBatches?: () => Promise<readonly Batch[]>;
563
594
  /**
564
595
  * Things about this session's configuration the operator must be told, every
565
596
  * launch — today, an accepted capability disagreement in the provider chain,
@@ -572,6 +603,29 @@ export interface AgentSession {
572
603
  * shown.
573
604
  */
574
605
  readonly configNotices: readonly string[];
606
+ /**
607
+ * Save an operator note (`#note`, `/memory add`) as a typed memory file in
608
+ * this session's stored memory, default type `project`. Absent on a session
609
+ * with no store, where notes go to the curated project file as before.
610
+ */
611
+ readonly rememberNote?: (text: string, type?: MemoryType) => Promise<TypedNoteResult>;
612
+ /**
613
+ * Copy the project's curated bullets into stored memory
614
+ * (`/memory import-notes`), returning the operator's report. The curated
615
+ * file is never changed.
616
+ */
617
+ readonly importCuratedNotes?: () => Promise<string>;
618
+ /**
619
+ * What `/memory` shows of stored memory, and where the files are: `index`,
620
+ * the always-loaded index uncapped — every active memory someone chose to
621
+ * keep — and `derived`, the active records runs recorded on their own (the
622
+ * run promoter, consolidation), which the prompt's index leaves out.
623
+ */
624
+ readonly storedMemoryIndex?: () => Promise<{
625
+ readonly directory: string;
626
+ readonly index: RenderedMemoryIndex;
627
+ readonly derived: RenderedMemoryIndex;
628
+ }>;
575
629
  /**
576
630
  * Whether "approve all" has been chosen at a prompt during this session.
577
631
  *
@@ -605,41 +659,42 @@ export interface AgentSession {
605
659
  readonly promptExemptTools: () => readonly string[];
606
660
  send(messages: readonly Message[], opts?: SendOptions): AsyncIterable<AgentEvent>;
607
661
  /**
608
- * Continue a run some OTHER process started, from its durable state.
662
+ * Continue a turn some OTHER process started, from its session log.
609
663
  *
610
- * The kernel could always do this — `resumeRun` joins a checkpoint back
611
- * to a running loop — and nothing in this package could reach it, because
612
- * the half a snapshot cannot carry (the provider client, the tool
613
- * registry, the working directory) lives inside this session and had no
614
- * way out. So `namzu` could produce durable runs and never pick one up.
664
+ * The half a checkpoint cannot carry (the provider client, the tool
665
+ * registry, the working directory) lives inside this session, so this is
666
+ * the way a drainer continues a parked turn: the SAME session and the SAME
667
+ * `turnId`, through the kernel's `resumeSession`.
615
668
  *
616
- * Returns the outcome rather than a stream: `resumeRun` drains the loop
617
- * and hands back a settled run, so there is nothing to render as it
618
- * happens. A parked run comes back as `awaiting-decision` and is NOT
619
- * resumed past — the answer is a human's, not a drainer's.
669
+ * Returns the outcome rather than a stream: the resumed turn is drained to
670
+ * settlement. A turn parked on a decision comes back as
671
+ * `awaiting-decision` and is NOT resumed past — the answer is a human's,
672
+ * not a drainer's.
620
673
  */
621
674
  resumeDurable(params: ResumeDurableParams): Promise<ResumeOutcome>;
622
675
  /**
623
- * Continue THIS session's own run after the provider paused it, from the
624
- * checkpoint the pause named, streaming events as the resumed run makes
625
- * them.
676
+ * Continue THIS session's own turn after the provider paused it, from the
677
+ * checkpoint the pause named, streaming events as the resumed turn makes
678
+ * them — the same turn id, the same session log.
626
679
  *
627
- * `resumeDurable` is for a run some other process started and takes the
628
- * listing and the store the caller found it in. A pause inside this
629
- * session already knows both: the run's scope is this session's and its
630
- * checkpoints are in the store the turn wrote to. What a headless caller
631
- * lacked was a way to say "wait, then go on" — it could only exit and be
632
- * re-prompted from whatever notes the run left behind, losing the run's
633
- * own context. A run parked on a human decision is not resumed past: it
634
- * comes back as an error naming the fact, because the answer is a
635
- * person's.
680
+ * What a headless caller lacked was a way to say "wait, then go on" — it
681
+ * could only exit and be re-prompted from whatever notes the turn left
682
+ * behind, losing its own context. A turn parked on a human decision is not
683
+ * resumed past: it comes back as an error naming the fact, because the
684
+ * answer is a person's.
636
685
  */
637
686
  resumePaused(params: ResumePausedParams): AsyncIterable<AgentEvent>;
687
+ /**
688
+ * Close this conversation's paused or interrupted turn without resuming it
689
+ * (`turn_failed{ error.code: 'abandoned' }`), so the next prompt can begin a
690
+ * turn. What `/abandon` does. A running turn is refused by the kernel.
691
+ */
692
+ abandonTurn?(turnId: TurnId, reason: string): Promise<void>;
638
693
  /**
639
694
  * Cancel and settle live sends, compactions and durable resumes, then release
640
695
  * what the session holds — today, the external tool servers.
641
696
  *
642
- * A stdio server is a CHILD PROCESS, and closing it while a live run still
697
+ * A stdio server is a CHILD PROCESS, and closing it while a live turn still
643
698
  * owns one of its tools is a use-after-close race. Idempotent, waits for the
644
699
  * operations it cancelled, and safe to call on a session that connected
645
700
  * nothing. Calls made after close refuse before provider work starts.
@@ -659,7 +714,7 @@ export interface AgentSessionContext {
659
714
  *
660
715
  * - the TUI routes into the picker, where the operator can enter a
661
716
  * credential or choose something else;
662
- * - `run`, `run-stream` and `drain` do `probe.preferences ?? defaultPrefs(...)`,
717
+ * - `exec`, `exec --json` and `drain` do `probe.preferences ?? defaultPrefs(...)`,
663
718
  * so nulling preferences here would silently move a scripted run onto
664
719
  * whatever else happened to be detected — the opposite of a refusal;
665
720
  * - `createAgentSession` refuses again on its own, which is what keeps those
@@ -717,8 +772,25 @@ export interface AgentSessionOptions {
717
772
  * registry and does not restore this fork's activation snapshot.
718
773
  */
719
774
  readonly toolLoading?: 'eager' | 'deferred';
720
- /** Session/thread/project/tenant identity for this run. Minted when absent. */
721
- readonly scope?: RunScope;
775
+ /**
776
+ * Session/topic/project/tenant identity for this session's turns. Minted
777
+ * when absent, with the project the working directory's checkout stands
778
+ * for (`projects/<slug>/project.json`), so the same directory keeps the
779
+ * same project across sessions.
780
+ */
781
+ readonly scope?: SessionScope;
782
+ /**
783
+ * The session this agent's turns are recorded into when {@link scope} is
784
+ * absent: a protocol gateway (ACP) resolves its client's id to a session
785
+ * first and hands the result here. Ignored when `scope` is given.
786
+ */
787
+ readonly sessionId?: SessionId;
788
+ /**
789
+ * Who started the session, written into its `session_started` record the
790
+ * first time a turn runs in it: the protocol and, for a gateway, the
791
+ * client's own id for it. Absent: `{ protocol: 'cli' }`.
792
+ */
793
+ readonly origin?: SessionStartedRecord['origin'];
722
794
  /**
723
795
  * The directory the agent works in: what every filesystem tool resolves a
724
796
  * relative path against and where sub-agents run. Generated task and memory
@@ -727,25 +799,34 @@ export interface AgentSessionOptions {
727
799
  * Taken as an argument rather than read from `process.cwd()` at each of
728
800
  * those four points, which is what let `--cwd` reach the session store and
729
801
  * the skill search and stop there: the caller parsed a directory, the agent
730
- * globbed a different one, and the run reported finding nothing rather than
802
+ * globbed a different one, and the turn reported finding nothing rather than
731
803
  * having looked in the wrong place.
732
804
  */
733
805
  readonly cwd?: string;
734
806
  /**
735
- * Injected SDK hierarchy root for this host session. When present, runs use
736
- * this exact path builder and generated memory/tasks live inside the scoped
737
- * Project. Absent preserves the embedded API's historical cwd-local layout.
807
+ * The application home (`NAMZU_HOME`) this session files its state under:
808
+ * `projects/<slug>/` for the working directory's checkout. Absent means
809
+ * `resolveNamzuHome()`. Never the working directory.
738
810
  */
739
811
  readonly stateRoot?: string;
740
- /** Host-owned durable conversations, for run-scoped original evidence retrieval. */
812
+ /**
813
+ * Host-owned durable conversations: the layout and index the session's
814
+ * logs live in, for turn-scoped original evidence retrieval and the
815
+ * delegation views. Absent: the layout of the working directory's project
816
+ * under {@link stateRoot}.
817
+ */
741
818
  readonly conversationSessions?: ConversationContext;
819
+ /**
820
+ * Keep every turn in memory: an in-memory session log per send, nothing
821
+ * written under `NAMZU_HOME`. For a stateless host (`exec --json` without
822
+ * `--session`), whose history arrives with each call.
823
+ */
824
+ readonly ephemeral?: boolean;
742
825
  /** Earlier settled steps of one resident pursuit, bound before this session starts. */
743
826
  readonly residentHistory?: ResidentHistorySource;
744
827
  readonly residentToolEvidence?: ResidentToolEvidenceSource;
745
828
  /** Host-bound to this resident admission; fresh sends only, never checkpoint resume. */
746
829
  readonly residentEvidenceRecall?: PrepareStep;
747
- /** False when an enclosing host owns signals and must drain before exiting. */
748
- readonly emergencySave?: boolean;
749
830
  /**
750
831
  * Operator-authored tool rules, already compiled to the kernel's vocabulary.
751
832
  *
@@ -768,12 +849,12 @@ export interface AgentSessionOptions {
768
849
  * feedback when it is not good enough.
769
850
  *
770
851
  * A SESSION option rather than a `SendOptions` one, because a gate is a
771
- * standing condition on the run — "don't finish until the build passes" —
852
+ * standing condition on the turn — "don't finish until the build passes" —
772
853
  * not a property of one message. Absent leaves the loop byte-identical.
773
854
  */
774
855
  readonly reviewAnswer?: ReviewAnswer;
775
856
  /**
776
- * Rejections the reviewer is allowed before the run stops with
857
+ * Rejections the reviewer is allowed before the turn stops with
777
858
  * `answer_rejected`. Absent uses the kernel's default.
778
859
  */
779
860
  readonly maxAnswerReviews?: number;
@@ -811,22 +892,22 @@ export interface AgentSessionOptions {
811
892
  /** See `NamzuCliConfig.compaction`. Absent means the kernel's structured strategy. */
812
893
  readonly compaction?: CompactionCliConfig;
813
894
  readonly memory?: MemoryCliConfig;
814
- /** See `NamzuCliConfig.limits`: how many model calls and tokens one run may spend. */
815
- readonly limits?: RunLimitsConfig;
895
+ /** See `NamzuCliConfig.limits`: how many model calls and tokens one turn may spend. */
896
+ readonly limits?: TurnLimitsConfig;
816
897
  /**
817
- * Where this session's run events are recorded, if anywhere.
898
+ * Where this session's events are recorded, if anywhere.
818
899
  *
819
900
  * A listener rather than a config: the CLI resolves `@namzu/telemetry`,
820
901
  * builds the sink and the redaction chain, and hands the result here
821
902
  * already assembled — so this file has no opinion about optional
822
903
  * packages, redactors, or what a destination is.
823
904
  */
824
- readonly onRunEvent?: (event: RunEvent) => void;
905
+ readonly onSessionEvent?: (event: SessionEvent) => void;
825
906
  /** Durable goal authority for the main TUI session; omitted on headless surfaces. */
826
907
  readonly sessionGoals?: SessionGoalStore;
827
908
  /**
828
909
  * Mount host desktop control for a surface that owns an interactive
829
- * permission callback. False by default: `run`, `run-stream` and `drain`
910
+ * permission callback. False by default: `exec`, `exec --json` and `drain`
830
911
  * have no human prompt to guard pointer/keyboard input and must not inherit
831
912
  * this capability merely because the package is installed.
832
913
  */
@@ -921,7 +1002,7 @@ export declare function listProviderModels(id: ProviderId, det: DetectedProvider
921
1002
  id: string;
922
1003
  name: string;
923
1004
  }>>;
924
- export interface RunScope {
1005
+ export interface SessionScope {
925
1006
  /**
926
1007
  * The active conversation. Chosen before the conversation is written
927
1008
  * and never replaced by a provisional value; it changes only when the
@@ -934,14 +1015,7 @@ export interface RunScope {
934
1015
  readonly tenantId: TenantId;
935
1016
  }
936
1017
  /** What `/add-dir` talks to. */
937
- export interface SessionDirectories {
938
- list(): readonly string[];
939
- add(path: string): Promise<{
940
- readonly added: boolean;
941
- readonly path: string;
942
- readonly reason?: string;
943
- }>;
944
- }
1018
+ export type { SessionDirectories } from '../context/directories.js';
945
1019
  /**
946
1020
  * The kernel's review policy with the TUI's prompt behind it.
947
1021
  *
@@ -951,7 +1025,9 @@ export interface SessionDirectories {
951
1025
  */
952
1026
  export declare function makeResumeHandler(approval: {
953
1027
  all: boolean;
954
- }, onPermission: PermissionFn | undefined, mode?: PermissionMode, exempt?: (name: string, input: unknown) => boolean): ResumeHandler;
1028
+ }, onPermission: PermissionFn | undefined, mode?: PermissionMode, exempt?: (name: string, input: unknown) => boolean, escapePolicy?: {
1029
+ readonly unattendedSandboxEscape?: 'refuse' | 'allow';
1030
+ }): ResumeHandler;
955
1031
  /**
956
1032
  * Whether a call runs without asking. The kernel's rule: a trusted read-only
957
1033
  * declaration or a named bookkeeping write, never a fetch, never a tool the
@@ -963,11 +1039,11 @@ export declare function promptExemptToolNames(registry: ToolRegistry): readonly
963
1039
  /** A batch needs explicit approval when any call mutates state. */
964
1040
  export declare const batchNeedsPrompt: typeof batchNeedsReview;
965
1041
  /**
966
- * Translate one SDK `RunEvent` into the TUI's `AgentEvent` vocabulary, or
1042
+ * Translate one SDK `SessionEvent` into the TUI's `AgentEvent` vocabulary, or
967
1043
  * `null` for events the chat surface doesn't render (iteration markers,
968
- * token usage, checkpoints, plan/task lifecycle, …). Pure — unit-tested.
1044
+ * checkpoints, plan lifecycle, …). Pure — unit-tested.
969
1045
  */
970
- export declare function toAgentEvent(event: RunEvent, presenter: ToolPresenter): AgentEvent | null;
1046
+ export declare function toAgentEvent(event: SessionEvent, presenter: ToolPresenter): AgentEvent | null;
971
1047
  /**
972
1048
  * The one presentation function this host keeps.
973
1049
  *