@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
@@ -1,39 +0,0 @@
1
- /**
2
- * `namzu run "<prompt>"` — headless one-shot. Runs a single prompt through
3
- * the same agent the TUI uses and prints the reply to stdout, for scripts
4
- * and CI. The prompt comes from
5
- * the arguments, or from stdin when piped. Status lines go to stderr (info,
6
- * suppressed by `--quiet`); only the answer hits stdout.
7
- *
8
- * Non-interactive, so there's no approval prompt — tools auto-run, but the
9
- * safety gate still hard-denies catastrophic commands. One-shots use an
10
- * ephemeral session and are not added to `/resume` history.
11
- *
12
- * Options are parsed, not spoken: this command joined every argument into the
13
- * prompt, so the flags its streaming sibling accepts — `--cwd` above all —
14
- * were read aloud to the model while the run used this directory anyway. Both
15
- * commands now share one parser (`./run-flags.js`), because they are the same
16
- * one-shot differing only in how they print.
17
- */
18
- import type { CommandDef } from './types.js';
19
- /**
20
- * The prompt, from the arguments and the pipe together.
21
- *
22
- * Piped input used to be read only when there was no argument prompt, so
23
- *
24
- * cat notes.txt | namzu run "summarise this"
25
- *
26
- * sent the model three words and silently dropped the file. Nothing reported
27
- * it: the run succeeded, and the answer was about nothing. A pipe and a
28
- * question are the ordinary way to ask about a document, and taking only one
29
- * of the two is the worst reading of that command.
30
- *
31
- * The piped text is fenced in a tag so the model can tell the instruction from
32
- * the material it is about — without a boundary, a long paste runs into the
33
- * question and the last line of a file reads as part of the request.
34
- *
35
- * Pure so it can be tested without a pipe; the reading happens in the handler.
36
- */
37
- export declare function composePrompt(fromArgs: string, piped: string): string;
38
- export declare const runCommand: CommandDef;
39
- //# sourceMappingURL=run.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAkCH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMrE;AAaD,eAAO,MAAM,UAAU,EAAE,UAyexB,CAAA"}
@@ -1,533 +0,0 @@
1
- /**
2
- * `namzu run "<prompt>"` — headless one-shot. Runs a single prompt through
3
- * the same agent the TUI uses and prints the reply to stdout, for scripts
4
- * and CI. The prompt comes from
5
- * the arguments, or from stdin when piped. Status lines go to stderr (info,
6
- * suppressed by `--quiet`); only the answer hits stdout.
7
- *
8
- * Non-interactive, so there's no approval prompt — tools auto-run, but the
9
- * safety gate still hard-denies catastrophic commands. One-shots use an
10
- * ephemeral session and are not added to `/resume` history.
11
- *
12
- * Options are parsed, not spoken: this command joined every argument into the
13
- * prompt, so the flags its streaming sibling accepts — `--cwd` above all —
14
- * were read aloud to the model while the run used this directory anyway. Both
15
- * commands now share one parser (`./run-flags.js`), because they are the same
16
- * one-shot differing only in how they print.
17
- */
18
- import { relative } from 'node:path';
19
- import { BOOT_EVENT_NAMES, EVENT_NAME_ATTRIBUTE, asSessionId, generateSessionId } from '@namzu/sdk';
20
- import { resolveTrustedProjectContext } from '../config/trusted-project-context.js';
21
- import { EXIT_UNTRUSTED, EXIT_USAGE } from '../exit-codes.js';
22
- import { openSessions } from '../integrations/sessions/store.js';
23
- import { attachSessionExport, } from '../integrations/telemetry/session-export.js';
24
- import { cliLogger, contextLogging, createStderrSink, installCliLogging } from '../logging.js';
25
- import { decideHeadlessTrust } from '../permissions/headless-trust.js';
26
- import { resolvePermissionMode } from '../permissions/mode.js';
27
- import { compilePermissions } from '../permissions/rules.js';
28
- import { describeRunInterruption, retryAfterMs } from '../tui/run-interruption.js';
29
- import { hostCommandNames } from '../tui/slashCommands.js';
30
- import { expandHeadlessCommand } from '../user-commands/store.js';
31
- import { duration, pauseWait } from './provider-wait.js';
32
- import { resolveResume } from './resume.js';
33
- import { applyProviderFlags, buildGate, loadSkillsContext, parseRunFlags, resolveWorkingDirectory, unknownOptionMessage, } from './run-flags.js';
34
- import { readStdin } from './stdin.js';
35
- /**
36
- * The prompt, from the arguments and the pipe together.
37
- *
38
- * Piped input used to be read only when there was no argument prompt, so
39
- *
40
- * cat notes.txt | namzu run "summarise this"
41
- *
42
- * sent the model three words and silently dropped the file. Nothing reported
43
- * it: the run succeeded, and the answer was about nothing. A pipe and a
44
- * question are the ordinary way to ask about a document, and taking only one
45
- * of the two is the worst reading of that command.
46
- *
47
- * The piped text is fenced in a tag so the model can tell the instruction from
48
- * the material it is about — without a boundary, a long paste runs into the
49
- * question and the last line of a file reads as part of the request.
50
- *
51
- * Pure so it can be tested without a pipe; the reading happens in the handler.
52
- */
53
- export function composePrompt(fromArgs, piped) {
54
- const question = fromArgs.trim();
55
- const material = piped.trim();
56
- if (!question)
57
- return material;
58
- if (!material)
59
- return question;
60
- return `${question}\n\n<stdin>\n${material}\n</stdin>`;
61
- }
62
- function defaultPrefs(detected) {
63
- const first = detected[0];
64
- return first
65
- ? {
66
- version: 3,
67
- providers: [{ id: first.entry.id }],
68
- subagents: { active: [] },
69
- }
70
- : null;
71
- }
72
- export const runCommand = {
73
- name: 'run',
74
- description: 'Run a single prompt headlessly and print the reply (for scripts/CI)',
75
- passThrough: true,
76
- help: [
77
- 'Usage: namzu run [options] <prompt...>',
78
- ' echo "<prompt>" | namzu run',
79
- ' cat file.txt | namzu run "summarise this"',
80
- '',
81
- 'Run a single prompt headlessly and print the reply. Everything that is',
82
- 'not an option is the prompt.',
83
- '',
84
- 'Piped input is used too, not discarded: with no prompt argument it IS',
85
- 'the prompt, and alongside one it is appended as material the question',
86
- 'is about. `namzu run -` reads the prompt from stdin explicitly.',
87
- '',
88
- 'Options (the same ones run-stream takes):',
89
- ' --cwd <path> Directory the agent works in (default: this one)',
90
- ' --provider <id> Provider to answer with',
91
- ' --model <id> Model to answer with',
92
- ' --skills <a,b,c> Load these skills as context for the turn',
93
- ' --continue, -c Resume the most recent conversation here',
94
- ' --resume <id> Resume that conversation, and no other',
95
- ' --gate <command> Verify proposed answers with this command; repeatable',
96
- ' --gate-retries <n> Fix attempts a failing gate allows (default 3)',
97
- ' --max-iterations <n> Main-loop iteration limit (default 50; 0 unlimited)',
98
- ' --token-budget <n> Tree token limit (default unlimited; 0 removes a configured cap)',
99
- ' --effort <level> Explicit reasoning effort (supported levels depend on the model)',
100
- ' --wait-for-provider <d> Wait out provider pauses (a rate limit, an outage)',
101
- ' for up to this long in total — 90s, 30m, 2h — resuming',
102
- ' from the checkpoint each time (default: none; exit 75)',
103
- ' --permission-mode <m> prompt | accept-edits | auto | strict | plan —',
104
- ' what happens to a call no [permissions] rule',
105
- ' decided (default: auto)',
106
- ' --trust Accept this folder for THIS run',
107
- ' -- End of options; the rest is the prompt verbatim',
108
- '',
109
- 'A folder has to be trusted before namzu will work in it, because namzu',
110
- 'reads its files, runs commands in it and executes its code. Run `namzu`',
111
- 'here once and accept the prompt to trust it permanently, or pass --trust',
112
- 'to accept it for one run. --trust does not remember; that is the point.',
113
- '',
114
- '--yolo does NOT imply --trust: one is about which tools may run inside a',
115
- 'folder, the other about the folder.',
116
- '',
117
- 'By default tools run without asking, because there is nobody to ask, and',
118
- 'the safety gate still refuses catastrophic commands. Use --permission-mode',
119
- 'strict for an unattended run that must refuse anything no rule allowed.',
120
- '',
121
- 'A mode only decides calls no rule decided: it can never reopen a deny.',
122
- '',
123
- '--gate checks proposed answers with operator-supplied commands. Every',
124
- 'command must complete successfully; a failure returns diagnostics to the',
125
- 'model for correction. Repeat the flag to check several commands in order.',
126
- 'Budget exhaustion or cancellation may stop a run before verification.',
127
- '',
128
- 'A failed gate may skip a retry when its Git change detector is unchanged.',
129
- 'The attempt still counts. Exhausted review attempts stop the run with',
130
- 'answer_rejected and a non-zero exit.',
131
- '',
132
- "The working directory's AGENTS.md files — that directory and every one up",
133
- 'to the repository root — are loaded as standing instructions for the run,',
134
- 'and the ones that were loaded are named on stderr.',
135
- '',
136
- '--continue and --resume refuse when the conversation cannot be reopened,',
137
- 'and say why. Neither ever falls back to starting a new one: run with no',
138
- 'flag if that is what you want.',
139
- '',
140
- 'Needs a provider. Set a credential in the environment, or run namzu',
141
- 'once to pick one interactively.',
142
- '',
143
- 'A run the provider pauses keeps a checkpoint. Without --wait-for-provider',
144
- 'it exits 75 at once and a wrapper decides when to run again; with it, the',
145
- "run waits the provider's own delay when it named one (otherwise a minute,",
146
- 'doubling, at most fifteen) and resumes from the checkpoint in this process,',
147
- 'until the budget is spent. The `limits.waitForProviderMs` config key sets',
148
- 'the same budget for every run in the folder.',
149
- '',
150
- 'Exit codes: 0 on a reply, 1 on a failed or unfinished run, 2 when no',
151
- 'prompt was supplied, 64 when an argument is wrong, 75 when the provider',
152
- 'paused the run (a rate limit or an outage) and a checkpoint was kept —',
153
- 'wait, then run again — and 77 when the folder has not been trusted and',
154
- 'nothing ran.',
155
- ].join('\n'),
156
- handler: async ({ ctx: bootstrapCtx, rawArgs }) => {
157
- let ctx = bootstrapCtx;
158
- const flags = parseRunFlags(rawArgs);
159
- // The run's leash: the config file's limits, with a flag overriding each.
160
- const limitsFromFlags = {
161
- ...(flags.maxIterations !== null ? { maxIterations: flags.maxIterations } : {}),
162
- ...(flags.tokenBudget !== null ? { tokenBudget: flags.tokenBudget } : {}),
163
- };
164
- if (flags.unknown.length > 0) {
165
- // A shell caller learns about a bad argument from `$?`, so this is 64
166
- // rather than the in-band error event the streaming sibling emits.
167
- ctx.formatter.error({ message: unknownOptionMessage(flags.unknown) });
168
- return EXIT_USAGE;
169
- }
170
- // `-` on its own means "the prompt is on stdin", the usual spelling for
171
- // it. Before, it was sent to the model as a one-character question.
172
- const fromArgs = flags.rest.join(' ').trim() === '-' ? '' : flags.rest.join(' ').trim();
173
- // With no prompt argument, piped input IS the prompt and is waited for
174
- // as long as it takes — that is the existing contract for `echo … |
175
- // namzu run` and for the `-` sentinel. Alongside a prompt it is extra
176
- // material, so it gets the first-byte deadline instead: a caller who
177
- // asked a complete question should never be left waiting on a pipe
178
- // they did not mean to open.
179
- const piped = await readStdin({ deadline: Boolean(fromArgs) });
180
- const prompt = composePrompt(fromArgs, piped);
181
- if (!prompt) {
182
- ctx.formatter.error({
183
- message: 'no prompt — pass it as an argument or pipe it via stdin',
184
- });
185
- return 2;
186
- }
187
- const resolved = resolveWorkingDirectory(flags.cwd);
188
- if ('error' in resolved) {
189
- ctx.formatter.error({ message: resolved.error });
190
- return EXIT_USAGE;
191
- }
192
- // Before anything is read, run or constructed in that directory. The
193
- // order is the gate: a check that happens after the session is built has
194
- // already opened stores and walked the tree it was meant to protect.
195
- const trust = decideHeadlessTrust({
196
- cwd: resolved.cwd,
197
- trustFlag: flags.trust,
198
- });
199
- if (!trust.allowed) {
200
- ctx.formatter.error({ message: trust.message ?? 'folder not trusted' });
201
- return EXIT_UNTRUSTED;
202
- }
203
- const cwd = trust.cwd;
204
- ctx = resolveTrustedProjectContext(bootstrapCtx, cwd);
205
- // Project commands are code-like launch authority: discover and expand
206
- // them only after the target folder has crossed the same trust boundary
207
- // as its config and instructions.
208
- const expansion = expandHeadlessCommand(prompt, {
209
- cwd,
210
- builtins: hostCommandNames(),
211
- });
212
- if (expansion.kind === 'refused') {
213
- ctx.formatter.error({ message: expansion.reason });
214
- return EXIT_USAGE;
215
- }
216
- const finalPrompt = expansion.kind === 'expanded' ? expansion.prompt : prompt;
217
- // The CLI owns stderr, not the kernel it drives (LOG-05) — a live sink
218
- // at the level --verbose/--quiet/NAMZU_LOG_LEVEL named, instead of
219
- // forcing the level to `silent` via `configureLogger`, which threw
220
- // every diagnostic away regardless of what anyone asked for.
221
- // `{ replace: true }`: a real invocation calls this once, but this
222
- // package's own test suite calls a command's handler more than once
223
- // per process, which a refusing second install would break for
224
- // reasons that have nothing to do with what those tests are about.
225
- const logging = contextLogging(ctx);
226
- installCliLogging(createStderrSink(logging.format), logging.level);
227
- const { probeAgentSession, createAgentSession } = await import('../tui/agent.js');
228
- const probe = await probeAgentSession();
229
- let prefs = probe.preferences ?? defaultPrefs(probe.detected);
230
- if (!prefs) {
231
- ctx.formatter.error({
232
- message: 'no LLM provider available — set a credential (e.g. ANTHROPIC_API_KEY) or run `namzu` to pick one',
233
- });
234
- return 1;
235
- }
236
- prefs = applyProviderFlags(prefs, flags);
237
- // A permission the operator wrote and which was silently dropped is the
238
- // worst outcome available here: they believe a control is in force and it
239
- // is not. So a bad line is reported and the rest still load.
240
- const modeResult = resolvePermissionMode({
241
- flag: flags.permissionMode,
242
- skipPermissions: flags.skipPermissions,
243
- // A headless run has nobody to ask, so `prompt` here would silently
244
- // become `auto`. Resolving it as `auto` says so instead.
245
- interactive: false,
246
- });
247
- if ('error' in modeResult) {
248
- ctx.formatter.error({ message: modeResult.error });
249
- return EXIT_USAGE;
250
- }
251
- const permissions = compilePermissions(ctx.config.permissions, ctx.config.permissionChecks);
252
- for (const d of permissions.diagnostics) {
253
- const where = d.pattern ? `permissions.${d.tool}."${d.pattern}"` : `permissions.${d.tool}`;
254
- ctx.formatter.error({ message: `${where}: ${d.message}` });
255
- }
256
- const gate = buildGate(flags, cwd);
257
- // Attached BEFORE the session, and its failure is fatal. An operator who
258
- // configured `telemetry.sessionExport` asked for this run to be
259
- // recorded; continuing without it means the run happens and the record
260
- // they were counting on does not exist, which is a failure they only
261
- // discover when they go looking for a session that was never written.
262
- let sessionExport;
263
- if (ctx.config.telemetry?.sessionExport) {
264
- try {
265
- sessionExport = await attachSessionExport({
266
- config: ctx.config.telemetry.sessionExport,
267
- });
268
- // Under the same event name the boot narrative used for the
269
- // boolean. This is the half that names the destination and the
270
- // redactors, and it is emitted HERE because it describes what
271
- // actually resolved rather than what was configured.
272
- cliLogger().info(sessionExport.disclosure, {
273
- [EVENT_NAME_ATTRIBUTE]: BOOT_EVENT_NAMES.TELEMETRY_STATUS,
274
- 'namzu.telemetry.session_export': true,
275
- });
276
- }
277
- catch (err) {
278
- ctx.formatter.error({
279
- message: err instanceof Error ? err.message : String(err),
280
- });
281
- return 1;
282
- }
283
- }
284
- let sessions;
285
- try {
286
- sessions = await openSessions(cwd);
287
- }
288
- catch (error) {
289
- await sessionExport?.shutdown();
290
- ctx.formatter.error({
291
- message: `workspace state is unavailable: ${error instanceof Error ? error.message : String(error)}`,
292
- });
293
- return 1;
294
- }
295
- const resume = await resolveResume(sessions, { continueLast: flags.continueLast, sessionId: flags.resume }, cwd);
296
- if (resume.kind === 'error') {
297
- ctx.formatter.error({ message: resume.message });
298
- await sessionExport?.shutdown();
299
- return EXIT_USAGE;
300
- }
301
- const prior = resume.kind === 'resumed' ? resume.messages : [];
302
- const session = await createAgentSession(prefs, probe.detected, {
303
- cwd,
304
- scope: {
305
- sessionId: resume.kind === 'resumed' ? asSessionId(resume.sessionId) : generateSessionId(),
306
- topicId: sessions.topicId,
307
- projectId: sessions.projectId,
308
- tenantId: sessions.tenantId,
309
- },
310
- stateRoot: sessions.root,
311
- ...(resume.kind === 'resumed' ? { conversationSessions: sessions } : {}),
312
- rules: permissions.rules,
313
- ...(sessionExport ? { onRunEvent: sessionExport.listener } : {}),
314
- // The operator's --gate commands, as a standing condition on the
315
- // answer. Spread rather than passed as undefined so a run without
316
- // gates is byte-identical to the one that shipped before them.
317
- ...(gate ?? {}),
318
- permissionMode: modeResult.mode,
319
- ...(ctx.config.mcpServers ? { mcpServers: ctx.config.mcpServers } : {}),
320
- ...(ctx.config.plugins ? { plugins: ctx.config.plugins } : {}),
321
- ...(ctx.config.web ? { web: ctx.config.web } : {}),
322
- ...(ctx.config.hooks ? { hooks: ctx.config.hooks } : {}),
323
- ...(ctx.config.compaction ? { compaction: ctx.config.compaction } : {}),
324
- ...(ctx.config.memory ? { memory: ctx.config.memory } : {}),
325
- ...(Object.keys({ ...ctx.config.limits, ...limitsFromFlags }).length > 0
326
- ? { limits: { ...ctx.config.limits, ...limitsFromFlags } }
327
- : {}),
328
- ...(ctx.config.sandbox ? { sandbox: ctx.config.sandbox } : {}),
329
- // `!== undefined`, not truthiness: an empty list is the operator
330
- // turning the default screen OFF, and a falsy check would drop it.
331
- ...(ctx.config.toolResultScreens !== undefined
332
- ? { toolResultScreens: ctx.config.toolResultScreens }
333
- : {}),
334
- });
335
- if (!session.hasProvider) {
336
- await session.close();
337
- await sessionExport?.shutdown();
338
- ctx.formatter.error({
339
- message: session.errorHint ?? 'agent is not ready',
340
- });
341
- return 1;
342
- }
343
- // A configured tool server that is not here means the run cannot do what
344
- // the operator set it up to do, and there is nobody watching to notice.
345
- // The TUI reports and carries on, because a person can read the line and
346
- // decide; a script has no such reader, so it refuses. Same principle as
347
- // the permission mode resolving differently when `interactive` is false.
348
- if (session.mcpFailed.length > 0) {
349
- for (const f of session.mcpFailed) {
350
- ctx.formatter.error({
351
- message: `tool server "${f.name}" is not available: ${f.reason}`,
352
- });
353
- }
354
- await session.close();
355
- await sessionExport?.shutdown();
356
- return 1;
357
- }
358
- // "Printed on every launch" has to mean every launch, not every launch of
359
- // the TUI. A scripted run under an accepted capability limitation is
360
- // exactly the case where nobody is watching, so the line has to be in the
361
- // output the script keeps.
362
- for (const notice of session.configNotices) {
363
- ctx.formatter.info(notice);
364
- }
365
- for (const s of session.mcpConnected) {
366
- ctx.formatter.info(`tool server ${s.name} · ${s.toolCount} tools`);
367
- }
368
- ctx.formatter.info(`namzu · ${session.providerSummary}${session.modelSummary ? ` · ${session.modelSummary}` : ''}`);
369
- // stderr like every other status line, so a caller piping the answer is
370
- // unaffected and a person watching can still tell which instructions the
371
- // run is bound by. A script that reads AGENTS.md aloud is not a script
372
- // whose output changed.
373
- if (session.instructionFiles.length > 0) {
374
- ctx.formatter.info(`project instructions: ${session.instructionFiles
375
- .map((p) => relative(cwd, p) || p)
376
- .join(', ')}`);
377
- }
378
- // A refusal that says nothing is indistinguishable from a project that
379
- // declared nothing, and the two want opposite responses from the reader.
380
- for (const skip of session.skippedInstructionFiles) {
381
- ctx.formatter.error({
382
- message: `skipped ${relative(cwd, skip.path) || skip.path}: ${skip.reason}`,
383
- });
384
- }
385
- const extraSystem = await loadSkillsContext(cwd, flags.skills);
386
- if (resume.kind === 'resumed') {
387
- ctx.formatter.info(`resuming ${resume.sessionId} · ${prior.length} messages`);
388
- }
389
- let text = '';
390
- const measured = {};
391
- const jsonResult = (value) => ({
392
- text: value,
393
- ...(measured.usage
394
- ? {
395
- usage: {
396
- totalTokens: measured.usage.totalTokens,
397
- cost: measured.usage.cost,
398
- },
399
- }
400
- : {}),
401
- ...(measured.budget ? { budget: measured.budget } : {}),
402
- });
403
- let stopReason;
404
- // Written from inside `consume`, so held on an object: a `let` assigned
405
- // only in a closure is `null` as far as the type checker can see, and
406
- // every read after the loop would narrow it to `never`.
407
- const stop = {
408
- failed: null,
409
- paused: null,
410
- };
411
- const consume = async (stream) => {
412
- stop.failed = null;
413
- stop.paused = null;
414
- for await (const event of stream) {
415
- if (event.kind === 'delta')
416
- text += event.text;
417
- else if (event.kind === 'tool-start')
418
- ctx.formatter.info(`⏺ ${event.toolName} ${event.summary}`);
419
- // stderr, like every other status line, so it reaches a person
420
- // watching without contaminating the answer a caller piped.
421
- else if (event.kind === 'context')
422
- ctx.formatter.info(event.text);
423
- else if (event.kind === 'error' || event.kind === 'paused') {
424
- if (event.budget)
425
- measured.budget = event.budget;
426
- stop.failed = describeRunInterruption(event);
427
- if (event.kind === 'paused')
428
- stop.paused = event;
429
- }
430
- else if (event.kind === 'usage') {
431
- measured.usage = event;
432
- if (event.budget)
433
- measured.budget = event.budget;
434
- }
435
- else if (event.kind === 'done') {
436
- // Deltas include preliminary and rejected answers. Settlement
437
- // supplies the final result after review and output guardrails;
438
- // an explicit empty result must also replace earlier text.
439
- if (event.text !== undefined)
440
- text = event.text;
441
- stopReason = event.stopReason;
442
- if (event.budget)
443
- measured.budget = event.budget;
444
- }
445
- }
446
- };
447
- await consume(session.send([...prior, { role: 'user', content: finalPrompt, timestamp: Date.now() }], extraSystem || flags.effort !== null
448
- ? {
449
- ...(extraSystem ? { extraSystem } : {}),
450
- ...(flags.effort !== null ? { effort: flags.effort } : {}),
451
- }
452
- : undefined));
453
- // A provider pause is answered by waiting, when the caller gave time to
454
- // wait with. The kernel kept a checkpoint; the run resumes from it in
455
- // this process, with its own context, rather than being re-prompted from
456
- // notes by a wrapper that saw exit 75. A pause with no provider behind
457
- // it is not waited on: that is a run parked on something else.
458
- const waitBudgetMs = flags.waitForProviderMs ?? ctx.config.limits?.waitForProviderMs ?? 0;
459
- let waits = 0;
460
- let waitedMs = 0;
461
- while (stop.paused && waitBudgetMs > 0 && (stop.paused.providerError || stop.paused.failure)) {
462
- const paused = stop.paused;
463
- const asked = retryAfterMs(paused);
464
- const decision = pauseWait({
465
- waited: waits,
466
- ...(asked !== undefined ? { retryAfterMs: asked } : {}),
467
- waitedMs,
468
- budgetMs: waitBudgetMs,
469
- });
470
- if (decision.kind === 'stop') {
471
- stop.failed = `${stop.failed}\nNot resumed: ${decision.reason}.`;
472
- break;
473
- }
474
- waits += 1;
475
- ctx.formatter.info(`provider paused the run: waiting ${duration(decision.delayMs)}, then resuming from ${paused.checkpointId} (wait ${waits}, ${duration(waitedMs)} of ${duration(waitBudgetMs)} spent)`);
476
- await new Promise((resolve) => setTimeout(resolve, decision.delayMs));
477
- waitedMs += decision.delayMs;
478
- await consume(session.resumePaused({
479
- runId: paused.runId,
480
- checkpointId: paused.checkpointId,
481
- }));
482
- }
483
- const failed = stop.failed;
484
- const paused = stop.paused !== null;
485
- // Every exit below this point releases the session first. A stdio tool
486
- // server is a child process, and a `run` that returns without closing
487
- // leaves it behind.
488
- await session.close();
489
- // Drained with the session, not at process exit: a buffering sink that
490
- // only flushed on `beforeExit` loses its tail whenever the CLI is
491
- // interrupted, which is exactly the run somebody wanted the record of.
492
- await sessionExport?.shutdown();
493
- if (measured.budget) {
494
- ctx.formatter.info(`Tokens: ${measured.budget.ownTokens} own · ${measured.budget.treeTokens} including descendants`);
495
- }
496
- if (failed) {
497
- // A provider can pause or fail after producing useful text. The TUI
498
- // keeps that partial answer and a shell caller deserves the same bytes;
499
- // the non-zero verdict is what prevents it being mistaken for complete.
500
- const partial = text.trim();
501
- if (partial) {
502
- ctx.formatter.print(ctx.formatter.name === 'json' ? jsonResult(partial) : partial);
503
- }
504
- ctx.formatter.error({
505
- message: `${failed}${partial ? ' — the output above is partial' : ''}`,
506
- });
507
- // A pause is not a failure: the provider said "not now" (a rate
508
- // limit, an outage) and the kernel kept a checkpoint. A wrapper that
509
- // re-runs on 1 would hammer a limited provider and give up on a
510
- // finished-looking failure alike; 75 (EX_TEMPFAIL, the sysexits
511
- // convention for "try again later") lets it back off instead.
512
- return paused ? 75 : 1;
513
- }
514
- // The text prints either way. Partial output is real output, and a
515
- // caller who piped it wants what there is — but `$?` has to be able to
516
- // tell them it is partial, which it could not: `run_failed` is emitted
517
- // only from the throw path, so a run stopped by its token budget, its
518
- // timeout, its iteration cap, a cancellation, or a blocking output
519
- // guardrail all arrived as `run_completed` and exited 0. Measured: a
520
- // `max_iterations` stop reports `status: 'completed'`. The sharp case is
521
- // the guardrail — a REFUSED answer exited 0 with empty text, so
522
- // `namzu run … > out.txt && deploy` proceeded on the empty file.
523
- ctx.formatter.print(ctx.formatter.name === 'json' ? jsonResult(text.trim()) : text.trim());
524
- if (stopReason && stopReason !== 'end_turn') {
525
- ctx.formatter.error({
526
- message: `run did not finish normally: ${stopReason}${text.trim() ? ' — the output above is partial' : ''}`,
527
- });
528
- return 1;
529
- }
530
- return 0;
531
- },
532
- };
533
- //# sourceMappingURL=run.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAInG,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA;AACnF,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,OAAO,EAEN,mBAAmB,GACnB,MAAM,6CAA6C,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB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E;QACnE,uEAAuE;QACvE,uEAAuE;QACvE,sEAAsE;QACtE,mEAAmE;QACnE,qEAAqE;QACrE,yEAAyE;QACzE,gEAAgE;QAChE,iEAAiE;QACjE,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC1F,IAAI,UAAU,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;YAC7C,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC;gBACnB,OAAO,EAAE,gCAAgC,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,EAAE,EAAE;aAC3G,CAAC,CAAA;YACF,OAAO,CAAC,CAAA;QACT,CAAC;QACD,OAAO,CAAC,CAAA;IACT,CAAC;CACD,CAAA"}
@@ -1,11 +0,0 @@
1
- import type { CheckpointRunScope } from '@namzu/sdk';
2
- import type { RunLimitsConfig } from './schema.js';
3
- export type RunGuardKey = 'tokenBudget' | 'maxIterations' | 'timeoutMs';
4
- export type RunGuards = {
5
- -readonly [K in RunGuardKey]: number;
6
- };
7
- /** CLI policy; independent of the SDK's defaults for embedding hosts. */
8
- export declare function resolveRunGuards(...layers: readonly (RunLimitsConfig | undefined)[]): RunGuards;
9
- /** Restore the run's own settings, including overrides made before a provider pause. */
10
- export declare function readStoredRunGuards(path: string, scope: CheckpointRunScope): Promise<RunGuards | undefined>;
11
- //# sourceMappingURL=run-limits.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-limits.d.ts","sourceRoot":"","sources":["../../src/config/run-limits.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,eAAe,GAAG,WAAW,CAAA;AACvE,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,UAAU,CAAC,IAAI,WAAW,GAAG,MAAM;CAAE,CAAA;AAEhE,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,GAAG,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,EAAE,GAAG,SAAS,CAkB/F;AAED,wFAAwF;AACxF,wBAAsB,mBAAmB,CACxC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,kBAAkB,GACvB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAiDhC"}