@namzu/sdk 65.3.0 → 67.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 (568) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/dist/account/lock.d.ts +4 -12
  3. package/dist/account/lock.d.ts.map +1 -1
  4. package/dist/account/lock.js +5 -140
  5. package/dist/account/lock.js.map +1 -1
  6. package/dist/account/registry.d.ts.map +1 -1
  7. package/dist/account/registry.js +50 -6
  8. package/dist/account/registry.js.map +1 -1
  9. package/dist/account/types.d.ts +7 -5
  10. package/dist/account/types.d.ts.map +1 -1
  11. package/dist/account/types.js +6 -7
  12. package/dist/account/types.js.map +1 -1
  13. package/dist/authorization/dangerous-commands.d.ts +64 -0
  14. package/dist/authorization/dangerous-commands.d.ts.map +1 -0
  15. package/dist/authorization/dangerous-commands.js +479 -0
  16. package/dist/authorization/dangerous-commands.js.map +1 -0
  17. package/dist/authorization/gate.d.ts.map +1 -1
  18. package/dist/authorization/gate.js +19 -5
  19. package/dist/authorization/gate.js.map +1 -1
  20. package/dist/authorization/protected-paths.d.ts +11 -6
  21. package/dist/authorization/protected-paths.d.ts.map +1 -1
  22. package/dist/authorization/protected-paths.js +13 -8
  23. package/dist/authorization/protected-paths.js.map +1 -1
  24. package/dist/authorization/readonly-commands.d.ts +6 -1
  25. package/dist/authorization/readonly-commands.d.ts.map +1 -1
  26. package/dist/authorization/readonly-commands.js +35 -1
  27. package/dist/authorization/readonly-commands.js.map +1 -1
  28. package/dist/authorization/removal.d.ts +10 -0
  29. package/dist/authorization/removal.d.ts.map +1 -1
  30. package/dist/authorization/removal.js +7 -7
  31. package/dist/authorization/removal.js.map +1 -1
  32. package/dist/authorization/rules.d.ts +10 -0
  33. package/dist/authorization/rules.d.ts.map +1 -1
  34. package/dist/authorization/rules.js +60 -14
  35. package/dist/authorization/rules.js.map +1 -1
  36. package/dist/authorization/shell-lexer.d.ts +10 -0
  37. package/dist/authorization/shell-lexer.d.ts.map +1 -1
  38. package/dist/authorization/shell-lexer.js +15 -0
  39. package/dist/authorization/shell-lexer.js.map +1 -1
  40. package/dist/bridge/acp/permission.d.ts +5 -0
  41. package/dist/bridge/acp/permission.d.ts.map +1 -1
  42. package/dist/bridge/acp/permission.js.map +1 -1
  43. package/dist/bridge/acp/server.d.ts +8 -1
  44. package/dist/bridge/acp/server.d.ts.map +1 -1
  45. package/dist/bridge/acp/server.js +48 -6
  46. package/dist/bridge/acp/server.js.map +1 -1
  47. package/dist/compaction/context-breakdown.d.ts +25 -6
  48. package/dist/compaction/context-breakdown.d.ts.map +1 -1
  49. package/dist/compaction/context-breakdown.js +27 -7
  50. package/dist/compaction/context-breakdown.js.map +1 -1
  51. package/dist/compaction/dangling.d.ts.map +1 -1
  52. package/dist/compaction/dangling.js +2 -0
  53. package/dist/compaction/dangling.js.map +1 -1
  54. package/dist/compaction/extractor.d.ts +7 -1
  55. package/dist/compaction/extractor.d.ts.map +1 -1
  56. package/dist/compaction/extractor.js +8 -1
  57. package/dist/compaction/extractor.js.map +1 -1
  58. package/dist/compaction/index.d.ts +1 -1
  59. package/dist/compaction/index.d.ts.map +1 -1
  60. package/dist/compaction/index.js +1 -1
  61. package/dist/compaction/index.js.map +1 -1
  62. package/dist/compaction/managers/structured.js +2 -2
  63. package/dist/compaction/managers/structured.js.map +1 -1
  64. package/dist/compaction/manual.d.ts.map +1 -1
  65. package/dist/compaction/manual.js +11 -6
  66. package/dist/compaction/manual.js.map +1 -1
  67. package/dist/compaction/model-summary.d.ts.map +1 -1
  68. package/dist/compaction/model-summary.js +7 -1
  69. package/dist/compaction/model-summary.js.map +1 -1
  70. package/dist/compaction/summary.d.ts +13 -2
  71. package/dist/compaction/summary.d.ts.map +1 -1
  72. package/dist/compaction/summary.js +46 -3
  73. package/dist/compaction/summary.js.map +1 -1
  74. package/dist/constants/tools/index.d.ts +18 -1
  75. package/dist/constants/tools/index.d.ts.map +1 -1
  76. package/dist/constants/tools/index.js +28 -16
  77. package/dist/constants/tools/index.js.map +1 -1
  78. package/dist/manager/session/turn-recorder.d.ts +6 -0
  79. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  80. package/dist/manager/session/turn-recorder.js +29 -1
  81. package/dist/manager/session/turn-recorder.js.map +1 -1
  82. package/dist/network/audit.d.ts +49 -0
  83. package/dist/network/audit.d.ts.map +1 -0
  84. package/dist/network/audit.js +84 -0
  85. package/dist/network/audit.js.map +1 -0
  86. package/dist/network/clock.d.ts +21 -0
  87. package/dist/network/clock.d.ts.map +1 -0
  88. package/dist/network/clock.js +51 -0
  89. package/dist/network/clock.js.map +1 -0
  90. package/dist/network/discovery-mdns.d.ts +120 -0
  91. package/dist/network/discovery-mdns.d.ts.map +1 -0
  92. package/dist/network/discovery-mdns.js +442 -0
  93. package/dist/network/discovery-mdns.js.map +1 -0
  94. package/dist/network/discovery.d.ts +63 -0
  95. package/dist/network/discovery.d.ts.map +1 -0
  96. package/dist/network/discovery.js +163 -0
  97. package/dist/network/discovery.js.map +1 -0
  98. package/dist/network/fingerprint.d.ts +73 -0
  99. package/dist/network/fingerprint.d.ts.map +1 -0
  100. package/dist/network/fingerprint.js +208 -0
  101. package/dist/network/fingerprint.js.map +1 -0
  102. package/dist/network/identity.d.ts +38 -0
  103. package/dist/network/identity.d.ts.map +1 -0
  104. package/dist/network/identity.js +71 -0
  105. package/dist/network/identity.js.map +1 -0
  106. package/dist/network/index.d.ts +39 -0
  107. package/dist/network/index.d.ts.map +1 -0
  108. package/dist/network/index.js +25 -0
  109. package/dist/network/index.js.map +1 -0
  110. package/dist/network/join.d.ts +69 -0
  111. package/dist/network/join.d.ts.map +1 -0
  112. package/dist/network/join.js +136 -0
  113. package/dist/network/join.js.map +1 -0
  114. package/dist/network/mail-policy.d.ts +97 -0
  115. package/dist/network/mail-policy.d.ts.map +1 -0
  116. package/dist/network/mail-policy.js +147 -0
  117. package/dist/network/mail-policy.js.map +1 -0
  118. package/dist/network/membership.d.ts +76 -0
  119. package/dist/network/membership.d.ts.map +1 -0
  120. package/dist/network/membership.js +225 -0
  121. package/dist/network/membership.js.map +1 -0
  122. package/dist/network/roster.d.ts +59 -0
  123. package/dist/network/roster.d.ts.map +1 -0
  124. package/dist/network/roster.js +120 -0
  125. package/dist/network/roster.js.map +1 -0
  126. package/dist/network/service.d.ts +303 -0
  127. package/dist/network/service.d.ts.map +1 -0
  128. package/dist/network/service.js +1891 -0
  129. package/dist/network/service.js.map +1 -0
  130. package/dist/network/store.d.ts +141 -0
  131. package/dist/network/store.d.ts.map +1 -0
  132. package/dist/network/store.js +198 -0
  133. package/dist/network/store.js.map +1 -0
  134. package/dist/network/transport.d.ts +96 -0
  135. package/dist/network/transport.d.ts.map +1 -0
  136. package/dist/network/transport.js +342 -0
  137. package/dist/network/transport.js.map +1 -0
  138. package/dist/network/wire.d.ts +345 -0
  139. package/dist/network/wire.d.ts.map +1 -0
  140. package/dist/network/wire.js +212 -0
  141. package/dist/network/wire.js.map +1 -0
  142. package/dist/network/x509.d.ts +28 -0
  143. package/dist/network/x509.d.ts.map +1 -0
  144. package/dist/network/x509.js +84 -0
  145. package/dist/network/x509.js.map +1 -0
  146. package/dist/pals/activity/causality.d.ts.map +1 -1
  147. package/dist/pals/activity/causality.js +14 -2
  148. package/dist/pals/activity/causality.js.map +1 -1
  149. package/dist/peers/endpoint.d.ts.map +1 -1
  150. package/dist/peers/endpoint.js +6 -0
  151. package/dist/peers/endpoint.js.map +1 -1
  152. package/dist/peers/envelope.d.ts +18 -0
  153. package/dist/peers/envelope.d.ts.map +1 -1
  154. package/dist/peers/envelope.js +68 -5
  155. package/dist/peers/envelope.js.map +1 -1
  156. package/dist/peers/index.d.ts +5 -4
  157. package/dist/peers/index.d.ts.map +1 -1
  158. package/dist/peers/index.js +3 -2
  159. package/dist/peers/index.js.map +1 -1
  160. package/dist/peers/mode-word.d.ts +10 -0
  161. package/dist/peers/mode-word.d.ts.map +1 -0
  162. package/dist/peers/mode-word.js +19 -0
  163. package/dist/peers/mode-word.js.map +1 -0
  164. package/dist/peers/protocol.d.ts +42 -0
  165. package/dist/peers/protocol.d.ts.map +1 -1
  166. package/dist/peers/protocol.js +22 -1
  167. package/dist/peers/protocol.js.map +1 -1
  168. package/dist/peers/record.d.ts +8 -0
  169. package/dist/peers/record.d.ts.map +1 -1
  170. package/dist/peers/record.js +5 -0
  171. package/dist/peers/record.js.map +1 -1
  172. package/dist/plugin/session-hook-env.d.ts.map +1 -1
  173. package/dist/plugin/session-hook-env.js +22 -2
  174. package/dist/plugin/session-hook-env.js.map +1 -1
  175. package/dist/plugin/shell-hook.d.ts +16 -2
  176. package/dist/plugin/shell-hook.d.ts.map +1 -1
  177. package/dist/plugin/shell-hook.js +183 -14
  178. package/dist/plugin/shell-hook.js.map +1 -1
  179. package/dist/prompt/coding-agent-doctrine.d.ts +4 -2
  180. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  181. package/dist/prompt/coding-agent-doctrine.js +33 -38
  182. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  183. package/dist/public-runtime.d.ts +14 -6
  184. package/dist/public-runtime.d.ts.map +1 -1
  185. package/dist/public-runtime.js +22 -5
  186. package/dist/public-runtime.js.map +1 -1
  187. package/dist/public-tools.d.ts +3 -2
  188. package/dist/public-tools.d.ts.map +1 -1
  189. package/dist/public-tools.js +2 -2
  190. package/dist/public-tools.js.map +1 -1
  191. package/dist/public-types.d.ts +7 -2
  192. package/dist/public-types.d.ts.map +1 -1
  193. package/dist/runtime/jobs/registry.d.ts +29 -1
  194. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  195. package/dist/runtime/jobs/registry.js +64 -0
  196. package/dist/runtime/jobs/registry.js.map +1 -1
  197. package/dist/runtime/query/auto-review/classifier.d.ts +30 -6
  198. package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
  199. package/dist/runtime/query/auto-review/classifier.js +40 -12
  200. package/dist/runtime/query/auto-review/classifier.js.map +1 -1
  201. package/dist/runtime/query/auto-review/feedback.d.ts +37 -0
  202. package/dist/runtime/query/auto-review/feedback.d.ts.map +1 -0
  203. package/dist/runtime/query/auto-review/feedback.js +45 -0
  204. package/dist/runtime/query/auto-review/feedback.js.map +1 -0
  205. package/dist/runtime/query/auto-review/git-status.d.ts +59 -0
  206. package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -0
  207. package/dist/runtime/query/auto-review/git-status.js +379 -0
  208. package/dist/runtime/query/auto-review/git-status.js.map +1 -0
  209. package/dist/runtime/query/auto-review/index.d.ts +3 -3
  210. package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
  211. package/dist/runtime/query/auto-review/index.js +2 -2
  212. package/dist/runtime/query/auto-review/index.js.map +1 -1
  213. package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -1
  214. package/dist/runtime/query/auto-review/prompt.js +6 -1
  215. package/dist/runtime/query/auto-review/prompt.js.map +1 -1
  216. package/dist/runtime/query/auto-review/transcript.d.ts +14 -1
  217. package/dist/runtime/query/auto-review/transcript.d.ts.map +1 -1
  218. package/dist/runtime/query/auto-review/transcript.js +48 -2
  219. package/dist/runtime/query/auto-review/transcript.js.map +1 -1
  220. package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
  221. package/dist/runtime/query/executor/tool-call-admission.js +40 -3
  222. package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
  223. package/dist/runtime/query/executor.d.ts +32 -10
  224. package/dist/runtime/query/executor.d.ts.map +1 -1
  225. package/dist/runtime/query/executor.js +78 -17
  226. package/dist/runtime/query/executor.js.map +1 -1
  227. package/dist/runtime/query/index.d.ts +9 -0
  228. package/dist/runtime/query/index.d.ts.map +1 -1
  229. package/dist/runtime/query/index.js +54 -17
  230. package/dist/runtime/query/index.js.map +1 -1
  231. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  232. package/dist/runtime/query/iteration/index.js +17 -3
  233. package/dist/runtime/query/iteration/index.js.map +1 -1
  234. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  235. package/dist/runtime/query/iteration/phases/compaction.js +5 -2
  236. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  237. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  238. package/dist/runtime/query/iteration/phases/context.js +5 -0
  239. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  240. package/dist/runtime/query/iteration/phases/per-call-review.d.ts +1 -2
  241. package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
  242. package/dist/runtime/query/iteration/phases/per-call-review.js +2 -5
  243. package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
  244. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  245. package/dist/runtime/query/iteration/phases/tool-review.js +6 -1
  246. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  247. package/dist/runtime/query/pasted-frames.d.ts +34 -0
  248. package/dist/runtime/query/pasted-frames.d.ts.map +1 -0
  249. package/dist/runtime/query/pasted-frames.js +108 -0
  250. package/dist/runtime/query/pasted-frames.js.map +1 -0
  251. package/dist/runtime/query/path-escalation.d.ts +6 -0
  252. package/dist/runtime/query/path-escalation.d.ts.map +1 -1
  253. package/dist/runtime/query/path-escalation.js +15 -3
  254. package/dist/runtime/query/path-escalation.js.map +1 -1
  255. package/dist/runtime/query/request-interrupted-turns.d.ts +20 -0
  256. package/dist/runtime/query/request-interrupted-turns.d.ts.map +1 -0
  257. package/dist/runtime/query/request-interrupted-turns.js +43 -0
  258. package/dist/runtime/query/request-interrupted-turns.js.map +1 -0
  259. package/dist/runtime/query/review-policy.d.ts +16 -6
  260. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  261. package/dist/runtime/query/review-policy.js +111 -15
  262. package/dist/runtime/query/review-policy.js.map +1 -1
  263. package/dist/runtime/query/turn/outcome-ledger.d.ts +9 -0
  264. package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
  265. package/dist/runtime/query/turn/outcome-ledger.js +94 -6
  266. package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
  267. package/dist/runtime/query/unanswered.d.ts +19 -0
  268. package/dist/runtime/query/unanswered.d.ts.map +1 -0
  269. package/dist/runtime/query/unanswered.js +25 -0
  270. package/dist/runtime/query/unanswered.js.map +1 -0
  271. package/dist/runtime/system-events.d.ts +4 -4
  272. package/dist/runtime/system-events.d.ts.map +1 -1
  273. package/dist/runtime/system-events.js +2 -0
  274. package/dist/runtime/system-events.js.map +1 -1
  275. package/dist/session/workspace/git-worktree.d.ts +8 -0
  276. package/dist/session/workspace/git-worktree.d.ts.map +1 -1
  277. package/dist/session/workspace/git-worktree.js +21 -3
  278. package/dist/session/workspace/git-worktree.js.map +1 -1
  279. package/dist/store/evidence/source-kind.d.ts +1 -1
  280. package/dist/store/evidence/source-kind.d.ts.map +1 -1
  281. package/dist/store/evidence/source-kind.js +1 -1
  282. package/dist/store/evidence/source-kind.js.map +1 -1
  283. package/dist/store/session-index/sqlite.d.ts.map +1 -1
  284. package/dist/store/session-index/sqlite.js +42 -3
  285. package/dist/store/session-index/sqlite.js.map +1 -1
  286. package/dist/store/session-log/disk.js +1 -1
  287. package/dist/store/session-log/disk.js.map +1 -1
  288. package/dist/store/session-log/lease.d.ts.map +1 -1
  289. package/dist/store/session-log/lease.js +3 -2
  290. package/dist/store/session-log/lease.js.map +1 -1
  291. package/dist/tools/admit-facts.d.ts.map +1 -1
  292. package/dist/tools/admit-facts.js +2 -0
  293. package/dist/tools/admit-facts.js.map +1 -1
  294. package/dist/tools/builtins/bash.d.ts +10 -2
  295. package/dist/tools/builtins/bash.d.ts.map +1 -1
  296. package/dist/tools/builtins/bash.js +56 -17
  297. package/dist/tools/builtins/bash.js.map +1 -1
  298. package/dist/tools/builtins/browser-local.d.ts +117 -0
  299. package/dist/tools/builtins/browser-local.d.ts.map +1 -0
  300. package/dist/tools/builtins/browser-local.js +437 -0
  301. package/dist/tools/builtins/browser-local.js.map +1 -0
  302. package/dist/tools/builtins/browser.d.ts +18 -1
  303. package/dist/tools/builtins/browser.d.ts.map +1 -1
  304. package/dist/tools/builtins/browser.js +84 -6
  305. package/dist/tools/builtins/browser.js.map +1 -1
  306. package/dist/tools/builtins/computer-use-window-id.d.ts +16 -0
  307. package/dist/tools/builtins/computer-use-window-id.d.ts.map +1 -0
  308. package/dist/tools/builtins/computer-use-window-id.js +52 -0
  309. package/dist/tools/builtins/computer-use-window-id.js.map +1 -0
  310. package/dist/tools/builtins/computer-use.d.ts +65 -7
  311. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  312. package/dist/tools/builtins/computer-use.js +384 -71
  313. package/dist/tools/builtins/computer-use.js.map +1 -1
  314. package/dist/tools/builtins/content-fingerprint.d.ts +6 -0
  315. package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
  316. package/dist/tools/builtins/content-fingerprint.js +7 -1
  317. package/dist/tools/builtins/content-fingerprint.js.map +1 -1
  318. package/dist/tools/builtins/edit.d.ts.map +1 -1
  319. package/dist/tools/builtins/edit.js +89 -7
  320. package/dist/tools/builtins/edit.js.map +1 -1
  321. package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
  322. package/dist/tools/builtins/file-write-result.js +2 -1
  323. package/dist/tools/builtins/file-write-result.js.map +1 -1
  324. package/dist/tools/builtins/grep.js +1 -1
  325. package/dist/tools/builtins/grep.js.map +1 -1
  326. package/dist/tools/builtins/job.d.ts.map +1 -1
  327. package/dist/tools/builtins/job.js +4 -2
  328. package/dist/tools/builtins/job.js.map +1 -1
  329. package/dist/tools/builtins/monitor.d.ts.map +1 -1
  330. package/dist/tools/builtins/monitor.js +6 -1
  331. package/dist/tools/builtins/monitor.js.map +1 -1
  332. package/dist/tools/builtins/search-tools.d.ts +12 -1
  333. package/dist/tools/builtins/search-tools.d.ts.map +1 -1
  334. package/dist/tools/builtins/search-tools.js +166 -20
  335. package/dist/tools/builtins/search-tools.js.map +1 -1
  336. package/dist/tools/builtins/shell-read-credit.d.ts +18 -6
  337. package/dist/tools/builtins/shell-read-credit.d.ts.map +1 -1
  338. package/dist/tools/builtins/shell-read-credit.js +95 -27
  339. package/dist/tools/builtins/shell-read-credit.js.map +1 -1
  340. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  341. package/dist/tools/builtins/wait-for-job.js +14 -3
  342. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  343. package/dist/tools/builtins/web-guidance.d.ts +6 -0
  344. package/dist/tools/builtins/web-guidance.d.ts.map +1 -1
  345. package/dist/tools/builtins/web-guidance.js +6 -0
  346. package/dist/tools/builtins/web-guidance.js.map +1 -1
  347. package/dist/tools/builtins/web.d.ts.map +1 -1
  348. package/dist/tools/builtins/web.js +2 -1
  349. package/dist/tools/builtins/web.js.map +1 -1
  350. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  351. package/dist/tools/builtins/write-file.js +32 -2
  352. package/dist/tools/builtins/write-file.js.map +1 -1
  353. package/dist/tools/command-shell.d.ts +1 -1
  354. package/dist/tools/command-shell.d.ts.map +1 -1
  355. package/dist/tools/command-shell.js +6 -8
  356. package/dist/tools/command-shell.js.map +1 -1
  357. package/dist/tools/defineTool.d.ts +2 -0
  358. package/dist/tools/defineTool.d.ts.map +1 -1
  359. package/dist/tools/defineTool.js +17 -1
  360. package/dist/tools/defineTool.js.map +1 -1
  361. package/dist/tools/schedules/index.d.ts +1 -0
  362. package/dist/tools/schedules/index.d.ts.map +1 -1
  363. package/dist/tools/schedules/index.js +1 -0
  364. package/dist/tools/schedules/index.js.map +1 -1
  365. package/dist/tools/schedules/loop-tool.d.ts.map +1 -1
  366. package/dist/tools/schedules/loop-tool.js +8 -6
  367. package/dist/tools/schedules/loop-tool.js.map +1 -1
  368. package/dist/tools/schedules/present.js +1 -1
  369. package/dist/tools/schedules/present.js.map +1 -1
  370. package/dist/tools/schedules/timer-tools.d.ts +36 -0
  371. package/dist/tools/schedules/timer-tools.d.ts.map +1 -0
  372. package/dist/tools/schedules/timer-tools.js +234 -0
  373. package/dist/tools/schedules/timer-tools.js.map +1 -0
  374. package/dist/tools/schedules/types.d.ts +68 -3
  375. package/dist/tools/schedules/types.d.ts.map +1 -1
  376. package/dist/tools/task/create.d.ts.map +1 -1
  377. package/dist/tools/task/create.js +2 -0
  378. package/dist/tools/task/create.js.map +1 -1
  379. package/dist/toolsets/manager.d.ts +49 -7
  380. package/dist/toolsets/manager.d.ts.map +1 -1
  381. package/dist/toolsets/manager.js +239 -40
  382. package/dist/toolsets/manager.js.map +1 -1
  383. package/dist/turn/evidence-query.d.ts +18 -1
  384. package/dist/turn/evidence-query.d.ts.map +1 -1
  385. package/dist/turn/evidence-query.js +177 -35
  386. package/dist/turn/evidence-query.js.map +1 -1
  387. package/dist/turn/evidence-recall.d.ts +8 -1
  388. package/dist/turn/evidence-recall.d.ts.map +1 -1
  389. package/dist/turn/evidence-recall.js +82 -22
  390. package/dist/turn/evidence-recall.js.map +1 -1
  391. package/dist/turn/history-shed.d.ts +15 -0
  392. package/dist/turn/history-shed.d.ts.map +1 -0
  393. package/dist/turn/history-shed.js +23 -0
  394. package/dist/turn/history-shed.js.map +1 -0
  395. package/dist/types/acp/index.d.ts +26 -0
  396. package/dist/types/acp/index.d.ts.map +1 -1
  397. package/dist/types/authorization/index.d.ts +9 -1
  398. package/dist/types/authorization/index.d.ts.map +1 -1
  399. package/dist/types/authorization/index.js +11 -2
  400. package/dist/types/authorization/index.js.map +1 -1
  401. package/dist/types/hitl/index.d.ts +10 -0
  402. package/dist/types/hitl/index.d.ts.map +1 -1
  403. package/dist/types/hitl/index.js.map +1 -1
  404. package/dist/types/message/index.d.ts +56 -1
  405. package/dist/types/message/index.d.ts.map +1 -1
  406. package/dist/types/message/index.js +2 -1
  407. package/dist/types/message/index.js.map +1 -1
  408. package/dist/types/permission/index.d.ts +14 -0
  409. package/dist/types/permission/index.d.ts.map +1 -1
  410. package/dist/types/permission/index.js +14 -0
  411. package/dist/types/permission/index.js.map +1 -1
  412. package/dist/types/plugin/index.d.ts +148 -1
  413. package/dist/types/plugin/index.d.ts.map +1 -1
  414. package/dist/types/plugin/index.js +9 -0
  415. package/dist/types/plugin/index.js.map +1 -1
  416. package/dist/types/provider/index.d.ts +1 -0
  417. package/dist/types/provider/index.d.ts.map +1 -1
  418. package/dist/types/provider/interface.d.ts +12 -0
  419. package/dist/types/provider/interface.d.ts.map +1 -1
  420. package/dist/types/provider/limits.d.ts +33 -0
  421. package/dist/types/provider/limits.d.ts.map +1 -0
  422. package/dist/types/provider/limits.js +7 -0
  423. package/dist/types/provider/limits.js.map +1 -0
  424. package/dist/types/tool/index.d.ts +30 -0
  425. package/dist/types/tool/index.d.ts.map +1 -1
  426. package/dist/types/tool/index.js.map +1 -1
  427. package/dist/types/tool/presentation.d.ts +4 -0
  428. package/dist/types/tool/presentation.d.ts.map +1 -1
  429. package/dist/utils/file-lock.d.ts +88 -0
  430. package/dist/utils/file-lock.d.ts.map +1 -0
  431. package/dist/utils/file-lock.js +281 -0
  432. package/dist/utils/file-lock.js.map +1 -0
  433. package/dist/utils/state-backup.d.ts +87 -0
  434. package/dist/utils/state-backup.d.ts.map +1 -0
  435. package/dist/utils/state-backup.js +272 -0
  436. package/dist/utils/state-backup.js.map +1 -0
  437. package/dist/utils/temp-sweep.d.ts +66 -0
  438. package/dist/utils/temp-sweep.d.ts.map +1 -0
  439. package/dist/utils/temp-sweep.js +311 -0
  440. package/dist/utils/temp-sweep.js.map +1 -0
  441. package/dist/utils/temp.d.ts +14 -0
  442. package/dist/utils/temp.d.ts.map +1 -1
  443. package/dist/utils/temp.js +70 -2
  444. package/dist/utils/temp.js.map +1 -1
  445. package/package.json +1 -1
  446. package/src/account/lock.ts +13 -133
  447. package/src/account/registry.ts +75 -21
  448. package/src/account/types.ts +8 -9
  449. package/src/authorization/dangerous-commands.ts +542 -0
  450. package/src/authorization/gate.ts +19 -5
  451. package/src/authorization/protected-paths.ts +13 -8
  452. package/src/authorization/readonly-commands.ts +35 -1
  453. package/src/authorization/removal.ts +7 -7
  454. package/src/authorization/rules.ts +75 -15
  455. package/src/authorization/shell-lexer.ts +19 -0
  456. package/src/bridge/acp/permission.ts +2 -0
  457. package/src/bridge/acp/server.ts +66 -6
  458. package/src/compaction/context-breakdown.ts +53 -11
  459. package/src/compaction/dangling.ts +2 -0
  460. package/src/compaction/extractor.ts +9 -1
  461. package/src/compaction/index.ts +1 -0
  462. package/src/compaction/managers/structured.ts +2 -2
  463. package/src/compaction/manual.ts +11 -3
  464. package/src/compaction/model-summary.ts +8 -1
  465. package/src/compaction/summary.ts +54 -7
  466. package/src/constants/tools/index.ts +30 -16
  467. package/src/manager/session/turn-recorder.ts +37 -1
  468. package/src/network/audit.ts +113 -0
  469. package/src/network/clock.ts +62 -0
  470. package/src/network/discovery-mdns.ts +485 -0
  471. package/src/network/discovery.ts +210 -0
  472. package/src/network/fingerprint.ts +241 -0
  473. package/src/network/identity.ts +98 -0
  474. package/src/network/index.ts +134 -0
  475. package/src/network/join.ts +177 -0
  476. package/src/network/mail-policy.ts +199 -0
  477. package/src/network/membership.ts +290 -0
  478. package/src/network/roster.ts +165 -0
  479. package/src/network/service.ts +2304 -0
  480. package/src/network/store.ts +261 -0
  481. package/src/network/transport.ts +445 -0
  482. package/src/network/wire.ts +250 -0
  483. package/src/network/x509.ts +114 -0
  484. package/src/pals/activity/causality.ts +16 -2
  485. package/src/peers/endpoint.ts +6 -0
  486. package/src/peers/envelope.ts +82 -5
  487. package/src/peers/index.ts +10 -2
  488. package/src/peers/mode-word.ts +18 -0
  489. package/src/peers/protocol.ts +24 -1
  490. package/src/peers/record.ts +5 -0
  491. package/src/plugin/session-hook-env.ts +25 -2
  492. package/src/plugin/shell-hook.ts +208 -14
  493. package/src/prompt/coding-agent-doctrine.ts +33 -38
  494. package/src/public-runtime.ts +107 -1
  495. package/src/public-tools.ts +11 -0
  496. package/src/public-types.ts +67 -1
  497. package/src/runtime/jobs/registry.ts +93 -3
  498. package/src/runtime/query/auto-review/classifier.ts +76 -14
  499. package/src/runtime/query/auto-review/feedback.ts +50 -0
  500. package/src/runtime/query/auto-review/git-status.ts +437 -0
  501. package/src/runtime/query/auto-review/index.ts +7 -2
  502. package/src/runtime/query/auto-review/prompt.ts +6 -1
  503. package/src/runtime/query/auto-review/transcript.ts +67 -4
  504. package/src/runtime/query/executor/tool-call-admission.ts +49 -3
  505. package/src/runtime/query/executor.ts +104 -21
  506. package/src/runtime/query/index.ts +66 -17
  507. package/src/runtime/query/iteration/index.ts +24 -3
  508. package/src/runtime/query/iteration/phases/compaction.ts +4 -0
  509. package/src/runtime/query/iteration/phases/context.ts +5 -0
  510. package/src/runtime/query/iteration/phases/per-call-review.ts +8 -13
  511. package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
  512. package/src/runtime/query/pasted-frames.ts +119 -0
  513. package/src/runtime/query/path-escalation.ts +27 -3
  514. package/src/runtime/query/request-interrupted-turns.ts +47 -0
  515. package/src/runtime/query/review-policy.ts +125 -22
  516. package/src/runtime/query/turn/outcome-ledger.ts +99 -6
  517. package/src/runtime/query/unanswered.ts +35 -0
  518. package/src/runtime/system-events.ts +2 -0
  519. package/src/session/workspace/git-worktree.ts +34 -3
  520. package/src/store/evidence/source-kind.ts +1 -1
  521. package/src/store/session-index/sqlite.ts +40 -3
  522. package/src/store/session-log/disk.ts +1 -1
  523. package/src/store/session-log/lease.ts +3 -2
  524. package/src/tools/admit-facts.ts +2 -0
  525. package/src/tools/builtins/bash.ts +62 -19
  526. package/src/tools/builtins/browser-local.ts +504 -0
  527. package/src/tools/builtins/browser.ts +108 -6
  528. package/src/tools/builtins/computer-use-window-id.ts +50 -0
  529. package/src/tools/builtins/computer-use.ts +460 -68
  530. package/src/tools/builtins/content-fingerprint.ts +8 -1
  531. package/src/tools/builtins/edit.ts +93 -7
  532. package/src/tools/builtins/file-write-result.ts +2 -1
  533. package/src/tools/builtins/grep.ts +1 -1
  534. package/src/tools/builtins/job.ts +4 -2
  535. package/src/tools/builtins/monitor.ts +6 -1
  536. package/src/tools/builtins/search-tools.ts +196 -21
  537. package/src/tools/builtins/shell-read-credit.ts +97 -33
  538. package/src/tools/builtins/wait-for-job.ts +13 -3
  539. package/src/tools/builtins/web-guidance.ts +6 -0
  540. package/src/tools/builtins/web.ts +2 -1
  541. package/src/tools/builtins/write-file.ts +31 -3
  542. package/src/tools/command-shell.ts +6 -8
  543. package/src/tools/defineTool.ts +20 -1
  544. package/src/tools/schedules/index.ts +11 -0
  545. package/src/tools/schedules/loop-tool.ts +10 -6
  546. package/src/tools/schedules/present.ts +1 -1
  547. package/src/tools/schedules/timer-tools.ts +258 -0
  548. package/src/tools/schedules/types.ts +72 -3
  549. package/src/tools/task/create.ts +2 -0
  550. package/src/toolsets/manager.ts +262 -46
  551. package/src/turn/evidence-query.ts +183 -42
  552. package/src/turn/evidence-recall.ts +96 -19
  553. package/src/turn/history-shed.ts +30 -0
  554. package/src/types/acp/index.ts +24 -0
  555. package/src/types/authorization/index.ts +20 -3
  556. package/src/types/hitl/index.ts +10 -0
  557. package/src/types/message/index.ts +65 -0
  558. package/src/types/permission/index.ts +18 -0
  559. package/src/types/plugin/index.ts +205 -26
  560. package/src/types/provider/index.ts +1 -0
  561. package/src/types/provider/interface.ts +13 -0
  562. package/src/types/provider/limits.ts +35 -0
  563. package/src/types/tool/index.ts +30 -2
  564. package/src/types/tool/presentation.ts +4 -0
  565. package/src/utils/file-lock.ts +328 -0
  566. package/src/utils/state-backup.ts +318 -0
  567. package/src/utils/temp-sweep.ts +327 -0
  568. package/src/utils/temp.ts +73 -2
@@ -41,10 +41,16 @@ import {
41
41
  type ToolCall,
42
42
  type ToolMessage,
43
43
  type ToolResultContent,
44
+ type ToolResultOutcome,
44
45
  type ToolRevealReceipt,
45
46
  createToolMessage,
46
47
  } from '../../types/message/index.js'
47
- import type { PermissionMode } from '../../types/permission/index.js'
48
+ import {
49
+ PLAN_MODE_REFUSAL,
50
+ PLAN_MODE_REFUSAL_WITH_PLAN_FILE,
51
+ type PermissionMode,
52
+ STRICT_MODE_REFUSAL,
53
+ } from '../../types/permission/index.js'
48
54
  import type { PluginHookPermission, PluginHookResult } from '../../types/plugin/index.js'
49
55
  import type { ChatCompletionResponse } from '../../types/provider/index.js'
50
56
  import type { Sandbox } from '../../types/sandbox/index.js'
@@ -78,12 +84,18 @@ import { compressShellOutput } from '../../utils/shell-compress.js'
78
84
  import { parseStructuredResultJson } from '../../utils/structured-result-json.js'
79
85
  import { ensureScratchpadDirectory } from '../../utils/temp.js'
80
86
  import { type BackgroundJobRegistry, type JobProcess, bindOwner } from '../jobs/registry.js'
87
+ import {
88
+ AUTO_REVIEW_BLOCKED_PREFIX,
89
+ AUTO_REVIEW_UNAVAILABLE_PREFIX,
90
+ } from './auto-review/feedback.js'
91
+ import { gitStatusForLine } from './auto-review/git-status.js'
81
92
  import {
82
93
  type ScriptEvidence,
83
94
  analyzeLaunches,
84
95
  changedSinceRead,
85
96
  readLaunchedScripts,
86
97
  } from './auto-review/script-evidence.js'
98
+ import { DECLINED_TOOL_CALL_FEEDBACK } from './declined.js'
87
99
  import { type BatchDetach, stillRunningResult } from './detached-calls.js'
88
100
  import {
89
101
  type ToolAdmissionHost,
@@ -115,6 +127,7 @@ import {
115
127
  fitResultsToMessageBudget,
116
128
  measureContentBytes,
117
129
  } from './tool-output-budget.js'
130
+ import { APPROVAL_NOT_COMPLETED, UNANSWERED_REFUSALS } from './unanswered.js'
118
131
 
119
132
  export type { EmitEvent } from './events.js'
120
133
  import type { EmitEvent, SessionEventDraft } from './events.js'
@@ -386,10 +399,10 @@ export interface ToolExecutorConfig {
386
399
  /** See `ToolContext.additionalDirectories`. */
387
400
  additionalDirectories?: readonly string[]
388
401
  /**
389
- * Where this session's own scratch folder is (it need not exist). It becomes
390
- * a root of the file tools, and a write inside it needs no review, once a call
391
- * names it and the folder has been made and checked. Unset on a sandboxed
392
- * turn and on a session with no layout on disk.
402
+ * Where this session's own scratch folder is. It becomes a root of the file
403
+ * tools once it has been made and checked, a write inside it needs no review,
404
+ * and background jobs keep their output files in its `jobs` folder. Unset on a
405
+ * sandboxed turn and when the folder could not be made.
393
406
  */
394
407
  scratchpadDirectory?: string
395
408
  /** See `QueryParams.outsideRootAccess`. Default `'refuse'`. */
@@ -641,6 +654,11 @@ export interface ToolCallOutcome {
641
654
  * a mutable map.
642
655
  */
643
656
  revealedTools?: readonly ToolRevealReceipt[]
657
+ /**
658
+ * Why the call did not simply run, as the executor knows it where it made
659
+ * this result; carried onto `ToolMessage.outcome`. Absent: it ran.
660
+ */
661
+ outcome?: ToolResultOutcome
644
662
  }
645
663
 
646
664
  /** What the per-call review decided about one call that reached the front of the walk. */
@@ -767,6 +785,38 @@ function refusalNote(reason: string | undefined): string | undefined {
767
785
  : sentence
768
786
  }
769
787
 
788
+ /** How every refusal of a call that a refusal elsewhere in its batch stopped begins. */
789
+ const TURN_STOPPED_REFUSAL = 'An earlier call in this batch was refused and the turn was stopped'
790
+
791
+ /** The refusals a session's mode writes for a call it does not run (plan mode, `strict`). */
792
+ const MODE_REFUSALS: readonly string[] = [
793
+ PLAN_MODE_REFUSAL,
794
+ PLAN_MODE_REFUSAL_WITH_PLAN_FILE,
795
+ STRICT_MODE_REFUSAL,
796
+ ]
797
+
798
+ /**
799
+ * How a refused call ended, from who refused it. `reason` is the review's or
800
+ * the gate's own text, never a tool's: a person's no is told by `declined`
801
+ * (or by the words a person's no carries when the host gave none of its
802
+ * own), the auto mode's two kinds by the prefixes its policy writes, a
803
+ * refusal that only followed a stopped turn or a question nobody answered by
804
+ * its own words, a refusal by plan mode or `strict` by theirs, and everything
805
+ * else is a rule, a hook or another guard.
806
+ */
807
+ export function denialOutcome(
808
+ reason: string,
809
+ declined: ToolCallDeclined | undefined,
810
+ ): ToolResultOutcome {
811
+ if (declined !== undefined || reason === DECLINED_TOOL_CALL_FEEDBACK) return 'rejected'
812
+ if (reason.startsWith(AUTO_REVIEW_BLOCKED_PREFIX)) return 'blocked_by_auto_mode'
813
+ if (reason.startsWith(AUTO_REVIEW_UNAVAILABLE_PREFIX)) return 'auto_mode_unavailable'
814
+ if (reason.startsWith(TURN_STOPPED_REFUSAL) || UNANSWERED_REFUSALS.includes(reason))
815
+ return 'interrupted'
816
+ if (MODE_REFUSALS.includes(reason)) return 'refused_by_mode'
817
+ return 'blocked_by_permissions'
818
+ }
819
+
770
820
  export function deniedToolOutput(toolName: string, reason: string): string {
771
821
  return `Error: Tool "${toolName}" was not executed. ${reason}`
772
822
  }
@@ -914,22 +964,15 @@ export class ToolExecutor {
914
964
  }
915
965
 
916
966
  /**
917
- * Make the session's scratch folder a root when a call names it. Lazy: a
918
- * session that never uses it leaves nothing on disk. The folder must be
919
- * inside the private temporary root with no link on the way; otherwise it
920
- * stays outside the roots and a path in it is asked about like any other.
967
+ * Make the session's scratch folder a root of the file tools. The turn made
968
+ * it when it started; this checks it again (no link on the way, ours) before
969
+ * the first call trusts it, and leaves it outside the roots when it fails,
970
+ * so a path in it is asked about like any other.
921
971
  */
922
972
  private admitScratchpad(call: PreparedSafetyCall): void {
923
973
  const directory = this.config.scratchpadDirectory
924
974
  if (directory === undefined || this.scratchpadReady !== undefined || this.sandboxed) return
925
975
  if (call.kind === 'synthetic') return
926
- let named = false
927
- try {
928
- named = JSON.stringify(call.input)?.includes(JSON.stringify(directory).slice(1, -1)) === true
929
- } catch {
930
- // An input that cannot be serialised names nothing.
931
- }
932
- if (!named) return
933
976
  try {
934
977
  this.scratchpadReady = ensureScratchpadDirectory(directory)
935
978
  } catch (error) {
@@ -1095,6 +1138,24 @@ export class ToolExecutor {
1095
1138
  return evidence.scripts
1096
1139
  }
1097
1140
 
1141
+ /**
1142
+ * The working tree's short status where a shell line runs a destructive git
1143
+ * command, read now for the auto-mode classifier; undefined for any other
1144
+ * line, inside a sandbox (its files are not this host's), or when git does
1145
+ * not answer. See `auto-review/git-status.ts`.
1146
+ */
1147
+ async gitStatusForReview(line: string, dialect: ShellDialect): Promise<string | undefined> {
1148
+ if (this.sandboxed) return undefined
1149
+ return gitStatusForLine(
1150
+ line,
1151
+ dialect,
1152
+ effectiveBashWorkingDirectory(this.config.sessionId, this.config.workingDirectory, {
1153
+ sandboxed: false,
1154
+ }),
1155
+ { signal: this.config.abortSignal },
1156
+ )
1157
+ }
1158
+
1098
1159
  /** The whole of the evidence as one text, from the same ledger. No filesystem I/O. */
1099
1160
  describeFileEvidence(messages: readonly Message[]): string | undefined {
1100
1161
  return describeVisibleFileEvidence(
@@ -1563,6 +1624,9 @@ export class ToolExecutor {
1563
1624
  roots,
1564
1625
  ...(shellCwd !== undefined ? { cwd: shellCwd } : {}),
1565
1626
  reviewOutside: this.config.outsideRootAccess === 'review' && !sandboxed,
1627
+ ...(this.scratchpadReady !== undefined && !sandboxed
1628
+ ? { scratchpadDirectory: this.scratchpadReady }
1629
+ : {}),
1566
1630
  topLevel: this.config.outsideRootAccess === 'review' && !sandboxed,
1567
1631
  })
1568
1632
  protectedPaths.push(...found.protectedPaths)
@@ -2030,7 +2094,7 @@ export class ToolExecutor {
2030
2094
  // so the failure signal and any image block were structurally lost at
2031
2095
  // the last possible moment.
2032
2096
  const messages: Message[] = results.map((r) =>
2033
- createToolMessage(r.content ?? r.output, r.toolCallId, r.isError, r.revealedTools),
2097
+ createToolMessage(r.content ?? r.output, r.toolCallId, r.isError, r.revealedTools, r.outcome),
2034
2098
  )
2035
2099
 
2036
2100
  return { messages, results, observations }
@@ -2058,8 +2122,7 @@ export class ToolExecutor {
2058
2122
  // before it has settled, so the transcript lists the calls in the order the
2059
2123
  // model wrote them: the declined call before the ones refused unasked.
2060
2124
  const settledUnits = new Map<number, Promise<void>>()
2061
- const refusedAfterEnd =
2062
- 'An earlier call in this batch was refused and the turn was stopped, so this call was not run.'
2125
+ const refusedAfterEnd = `${TURN_STOPPED_REFUSAL}, so this call was not run.`
2063
2126
  await new Promise<void>((resolve) => {
2064
2127
  const start = (unit: ReviewUnit): void => {
2065
2128
  inFlight.add(unit)
@@ -2079,7 +2142,7 @@ export class ToolExecutor {
2079
2142
  // An answer that could not be obtained is not a yes.
2080
2143
  admission = {
2081
2144
  run: false,
2082
- reason: 'The approval for this call could not be completed, so it was not run.',
2145
+ reason: APPROVAL_NOT_COMPLETED,
2083
2146
  }
2084
2147
  }
2085
2148
  if (admission.run && !review.ended.aborted) {
@@ -2627,6 +2690,11 @@ export class ToolExecutor {
2627
2690
  this.config.backgroundJobs,
2628
2691
  this.config.backgroundJobOwner ?? this.config.turnId,
2629
2692
  {
2693
+ // Every job's output is also saved to a file the model is told
2694
+ // about, so it has no reason to redirect it into the project.
2695
+ ...(this.config.scratchpadDirectory !== undefined && !this.sandboxed
2696
+ ? { outputDirectory: join(this.config.scratchpadDirectory, 'jobs') }
2697
+ : {}),
2630
2698
  workingDirectory: this.config.workingDirectory,
2631
2699
  env: this.config.env,
2632
2700
  ...(this.config.sandbox?.spawnDetached
@@ -3145,6 +3213,11 @@ export class ToolExecutor {
3145
3213
  ...(result.launched === true && !effectiveIsError ? { launched: true as const } : {}),
3146
3214
  ...(revealedTools !== undefined ? { revealedTools } : {}),
3147
3215
  ...(result.facts !== undefined && !postOverride ? { facts: result.facts } : {}),
3216
+ // A call that failed while the turn was being stopped was cut short, not
3217
+ // a tool that failed on its own.
3218
+ ...(effectiveIsError && this.config.abortSignal.aborted
3219
+ ? { outcome: 'interrupted' as const }
3220
+ : {}),
3148
3221
  }
3149
3222
  }
3150
3223
 
@@ -3704,7 +3777,14 @@ export class ToolExecutor {
3704
3777
  isError: true,
3705
3778
  })
3706
3779
 
3707
- return { toolCallId: toolCall.id, toolName, output, isError: true, notRun: true }
3780
+ return {
3781
+ toolCallId: toolCall.id,
3782
+ toolName,
3783
+ output,
3784
+ isError: true,
3785
+ notRun: true,
3786
+ outcome: denialOutcome(reason, declined),
3787
+ }
3708
3788
  }
3709
3789
 
3710
3790
  /**
@@ -3757,6 +3837,7 @@ export class ToolExecutor {
3757
3837
  kind: 'error',
3758
3838
  notRun: true,
3759
3839
  output: `Tool "${toolName}" was not started because the turn was cancelled${reason ? `: ${reason}` : '.'}`,
3840
+ outcome: 'interrupted',
3760
3841
  })
3761
3842
  }
3762
3843
 
@@ -3771,6 +3852,7 @@ export class ToolExecutor {
3771
3852
  skipped?: true
3772
3853
  notRun?: true
3773
3854
  facts?: ToolFacts
3855
+ outcome?: ToolResultOutcome
3774
3856
  },
3775
3857
  ): Promise<ToolCallOutcome> {
3776
3858
  const activity = this.activityStore.create({
@@ -3815,6 +3897,7 @@ export class ToolExecutor {
3815
3897
  ...(outcome.inputFailure ? { inputFailure: outcome.inputFailure } : {}),
3816
3898
  ...(outcome.skipped ? { skipped: true as const } : {}),
3817
3899
  ...(outcome.notRun ? { notRun: true as const } : {}),
3900
+ ...(outcome.outcome ? { outcome: outcome.outcome } : {}),
3818
3901
  }
3819
3902
  }
3820
3903
 
@@ -20,7 +20,7 @@ import { childSessionLog } from '../../manager/agent/child-session.js'
20
20
  import { type TurnRecorder, recordedTurnStart } from '../../manager/session/turn-recorder.js'
21
21
  import { frameOperatorHookContext } from '../../plugin/hook-context.js'
22
22
  import { PromptContributionRegistry } from '../../prompt/contributions.js'
23
- import { resolveProviderCapabilities } from '../../provider/capabilities.js'
23
+ import { modelReadsImages, resolveProviderCapabilities } from '../../provider/capabilities.js'
24
24
  import type { ProviderChainMember } from '../../provider/fallback.js'
25
25
  import { withStreamIdleTimeout } from '../../provider/idle-timeout.js'
26
26
  import type { ProviderRetryConfig } from '../../provider/retry.js'
@@ -110,6 +110,7 @@ import type { ModelPricing } from '../../utils/cost.js'
110
110
  import { toErrorMessage } from '../../utils/error.js'
111
111
  import { errorAttributes } from '../../utils/log/exception.js'
112
112
  import type { Logger } from '../../utils/logger.js'
113
+ import { NAMZU_SCRATCH_ENV, ensureScratchpadDirectory, scratchpadAlias } from '../../utils/temp.js'
113
114
  import { AwaitedJobs } from '../jobs/awaited-jobs.js'
114
115
  import type { BackgroundJobRegistry } from '../jobs/registry.js'
115
116
  import { catchUpFromCursor, settlePreStartCancellation } from './cancelled-before-start.js'
@@ -1045,6 +1046,16 @@ export interface QueryParams {
1045
1046
 
1046
1047
  sandboxProvider?: SandboxProvider
1047
1048
 
1049
+ /**
1050
+ * The session's scratch folder, for a host whose session state is not on
1051
+ * disk (an ephemeral run), where {@link paths} cannot name one. It must lie
1052
+ * inside the per-user private temporary folder (`privateTempRootPath()`);
1053
+ * anything else is refused and the turn runs without a scratch folder. With
1054
+ * `paths` and no value here, the folder is `paths.scratchpadPath(sessionId)`
1055
+ * (the parent's, for a delegated turn).
1056
+ */
1057
+ scratchpadDirectory?: string
1058
+
1048
1059
  /**
1049
1060
  * Maximum time the turn waits for sandbox teardown, in milliseconds.
1050
1061
  *
@@ -1313,7 +1324,11 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1313
1324
  // would be a `ToolsetConflictError` naming both sources for a name
1314
1325
  // query() itself introduced, not the caller's honest collision.
1315
1326
  const callerHasDeferredToolset = params.toolsets.some(
1316
- (ts) => (ts.availability ?? 'active') === 'deferred' && ts.tools().length > 0,
1327
+ // A live toolset that has no tools yet still counts: the ones it gains
1328
+ // later (a server that connects after the turn began) arrive deferred.
1329
+ (ts) =>
1330
+ (ts.availability ?? 'active') === 'deferred' &&
1331
+ (ts.tools().length > 0 || ts.onChange !== undefined),
1317
1332
  )
1318
1333
  const callerSearchToolset = params.toolsets.find((ts) =>
1319
1334
  ts.tools().some((tool) => tool.name === SearchToolsTool.name),
@@ -1391,12 +1406,26 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1391
1406
  const carries = (m: (typeof params.messages)[number], kind: 'image' | 'document') =>
1392
1407
  m.role === 'user' && (m.attachments ?? []).some((a) => (a.type ?? 'image') === kind)
1393
1408
 
1394
- const attachmentMessageCount = capabilities.supportsVision
1395
- ? 0
1396
- : params.messages.filter((m) => carries(m, 'image')).length
1397
- const documentMessageCount = capabilities.supportsDocuments
1398
- ? 0
1399
- : params.messages.filter((m) => carries(m, 'document')).length
1409
+ // The warning is for the message this run answers: a picture sent three
1410
+ // replies ago was warned about then, and repeating it before every later
1411
+ // reply would say the same thing again about something the person did once.
1412
+ // Strict mode is a refusal, not a warning, so it keeps looking at the whole
1413
+ // history: a picture the driver would drop anywhere in it still throws.
1414
+ const latestUser = [...params.messages].reverse().find((m) => m.role === 'user')
1415
+ const countCarrying = (kind: 'image' | 'document'): number =>
1416
+ params.strictCapabilities
1417
+ ? params.messages.filter((m) => carries(m, kind)).length
1418
+ : latestUser !== undefined && carries(latestUser, kind)
1419
+ ? 1
1420
+ : 0
1421
+ // A driver that maps images can still serve a model its own catalogue lists
1422
+ // as text-only; that model's requests leave the picture out just the same,
1423
+ // so the person is told about it the same way, naming the model.
1424
+ const textOnlyModel =
1425
+ capabilities.supportsVision && !modelReadsImages(params.provider, turnConfig.model)
1426
+ const attachmentMessageCount =
1427
+ capabilities.supportsVision && !textOnlyModel ? 0 : countCarrying('image')
1428
+ const documentMessageCount = capabilities.supportsDocuments ? 0 : countCarrying('document')
1400
1429
 
1401
1430
  if (stripToolSurfaces) {
1402
1431
  const message = `Provider '${params.provider.id}' declares supportsTools: false but ${registeredToolCount} tool(s) are registered — stripping all tool surfaces from the prompt and request so the model is never told about tools it cannot call. Pass strictCapabilities: true to fail instead, or use a tools-capable provider.`
@@ -1419,7 +1448,9 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1419
1448
  }
1420
1449
 
1421
1450
  if (attachmentMessageCount > 0) {
1422
- const message = `Provider '${params.provider.id}' declares supportsVision: false but ${attachmentMessageCount} user message(s) carry image attachments — the driver will not map them, so the model never sees the images. Pass strictCapabilities: true to fail instead, or use a vision-capable provider.`
1451
+ const message = textOnlyModel
1452
+ ? `Model '${turnConfig.model}' on provider '${params.provider.id}' reads text only but ${attachmentMessageCount} user message(s) carry image attachments — they are left out of its requests, so the model never sees the images. Pass strictCapabilities: true to fail instead, or use a model that reads images.`
1453
+ : `Provider '${params.provider.id}' declares supportsVision: false but ${attachmentMessageCount} user message(s) carry image attachments — the driver will not map them, so the model never sees the images. Pass strictCapabilities: true to fail instead, or use a vision-capable provider.`
1423
1454
  if (params.strictCapabilities) {
1424
1455
  throw new NamzuError({
1425
1456
  code: 'capability_unavailable',
@@ -1601,15 +1632,24 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1601
1632
  // pre-approves ends with the turn. Shared by the executor, where the
1602
1633
  // `skill` tool records a grant, and the review phase, which reads it.
1603
1634
  const skillGrants = new SkillGrantSet()
1604
- // The session's own scratch folder, a root of the file tools once a call
1605
- // names it. Not for a sandboxed turn (it is not mounted there), and not
1606
- // for a session whose state is not on disk.
1635
+ // The session's own scratch folder: made now, owner-only, and a root of the
1636
+ // file tools from the first call. A host that keeps no session state on
1637
+ // disk names one itself (`scratchpadDirectory`). A delegated turn uses its
1638
+ // parent's, so the files a team of agents leaves are in one place. Not for
1639
+ // a sandboxed turn (it is not mounted there). A folder that cannot be made
1640
+ // or is not safe stays unused, and the turn goes on without it.
1607
1641
  let scratchpadDirectory: string | undefined
1608
1642
  if (!params.sandboxProvider) {
1609
1643
  try {
1610
- scratchpadDirectory = ctx.storage.paths?.scratchpadPath(ctx.sessionId)
1611
- } catch {
1644
+ scratchpadDirectory =
1645
+ params.scratchpadDirectory ??
1646
+ ctx.storage.paths?.scratchpadPath(params.parentSessionId ?? ctx.sessionId)
1647
+ if (scratchpadDirectory !== undefined) ensureScratchpadDirectory(scratchpadDirectory)
1648
+ } catch (error) {
1612
1649
  scratchpadDirectory = undefined
1650
+ ctx.log.warn('The session scratch folder could not be made, so the turn runs without it', {
1651
+ 'exception.message': error instanceof Error ? error.message : String(error),
1652
+ })
1613
1653
  }
1614
1654
  }
1615
1655
  const toolExecutor = ToolingBootstrap.init(
@@ -1630,7 +1670,13 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1630
1670
  ...(params.outsideRootRefusal ? { outsideRootRefusal: params.outsideRootRefusal } : {}),
1631
1671
  ...(params.sandboxEscape ? { sandboxEscape: params.sandboxEscape } : {}),
1632
1672
  permissionMode: () => ctx.permissionMode.current,
1633
- env: turnConfig.env ?? {},
1673
+ env: {
1674
+ // A short path for the scratch folder, so a command need not type the long one.
1675
+ ...(scratchpadDirectory
1676
+ ? { [NAMZU_SCRATCH_ENV]: scratchpadAlias(scratchpadDirectory) }
1677
+ : {}),
1678
+ ...(turnConfig.env ?? {}),
1679
+ },
1634
1680
  abortSignal: ctx.abortController.signal,
1635
1681
  allowedTools: effectiveAllowedTools,
1636
1682
  invocationState: params.invocationState,
@@ -2547,7 +2593,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
2547
2593
  let isFirstUserMessage = true
2548
2594
  for (const message of initialMessages) {
2549
2595
  if (!isOperatorUserMessage(message) || !message.content.trim()) continue
2550
- extractFromUserMessage(workingStateManager, message.content, isFirstUserMessage)
2596
+ extractFromUserMessage(workingStateManager, message, isFirstUserMessage)
2551
2597
  isFirstUserMessage = false
2552
2598
  }
2553
2599
  }
@@ -2642,7 +2688,10 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
2642
2688
  turnId: ctx.recorder.turnId,
2643
2689
  capability: 'vision',
2644
2690
  providerId: params.provider.id,
2645
- message: `Provider '${params.provider.id}' does not support vision — image attachments on ${attachmentMessageCount} user message(s) will not reach the model.`,
2691
+ ...(textOnlyModel ? { model: turnConfig.model } : {}),
2692
+ message: textOnlyModel
2693
+ ? `Model '${turnConfig.model}' on provider '${params.provider.id}' reads text only — image attachments on ${attachmentMessageCount} user message(s) will not reach the model.`
2694
+ : `Provider '${params.provider.id}' does not support vision — image attachments on ${attachmentMessageCount} user message(s) will not reach the model.`,
2646
2695
  })
2647
2696
  yield* eventTranslator.drainPending()
2648
2697
  }
@@ -72,12 +72,14 @@ import { SandboxAcquisitionStopped } from '../deferred-sandbox.js'
72
72
  import { deliverDurableInbound } from '../durable-inbound.js'
73
73
  import type { ToolCallOutcome } from '../executor.js'
74
74
  import { projectObservationContext } from '../observation-context.js'
75
+ import { framePastedMessages } from '../pasted-frames.js'
75
76
  import { applyLifecycleHookResults, lastAssistantMessageField } from '../plugin-hooks.js'
76
77
  import {
77
78
  type RequestContextSnapshot,
78
79
  diffRequestContext,
79
80
  snapshotRequestContext,
80
81
  } from '../request-context.js'
82
+ import { withInterruptedRequestsMarked } from '../request-interrupted-turns.js'
81
83
  import {
82
84
  type RequestImageIdentity,
83
85
  markProviderRejectedImage,
@@ -907,6 +909,19 @@ export class IterationOrchestrator {
907
909
  // Render request-only contributions once before preparation. Their
908
910
  // estimated cost reduces every stage's headroom, and the same text
909
911
  // reaches the provider even if a stage changes external state.
912
+ // A live toolset may have gained or lost tools since the catalogue was
913
+ // written at the start of the run (an MCP server that connected late).
914
+ // Say so in the conversation, once, instead of leaving them invisible.
915
+ const toolChange = this.ctx.tools.refresh?.()
916
+ if (toolChange) {
917
+ const change = this.ctx.tools.describeChange(toolChange)
918
+ if (change)
919
+ appendRecordedContext(
920
+ recorder,
921
+ [{ key: 'tools-changed', text: change }],
922
+ this.ctx.log,
923
+ )
924
+ }
910
925
  const contextSections =
911
926
  this.ctx.promptContributions?.render('context', { iteration: iterationNum }) ?? []
912
927
  const deferredMcpHints =
@@ -1065,7 +1080,13 @@ export class IterationOrchestrator {
1065
1080
  // and a mode change would re-key the whole conversation.
1066
1081
  if (policyNotice) requestHistory.push(stepContextMessage(policyNotice))
1067
1082
  const projected = projectRequestRichContent(
1068
- withoutVoidAssistantTurns(this.projectObservations(requestHistory)),
1083
+ // After the empty entries are dropped: an interrupted turn can leave
1084
+ // one behind, and it answered nothing.
1085
+ withInterruptedRequestsMarked(
1086
+ withoutVoidAssistantTurns(
1087
+ this.projectObservations(framePastedMessages(requestHistory)),
1088
+ ),
1089
+ ),
1069
1090
  this.richContentBudget(),
1070
1091
  { imagesReadable: this.modelReadsImages(stepModel) },
1071
1092
  )
@@ -2723,7 +2744,7 @@ export class IterationOrchestrator {
2723
2744
  // tool result can be shed. Initial history was already extracted at seed.
2724
2745
  const manager = this.ctx.workingStateManager
2725
2746
  if (arriving && manager) {
2726
- extractFromUserMessage(manager, message.content, !manager.getState().task)
2747
+ extractFromUserMessage(manager, message, !manager.getState().task)
2727
2748
  }
2728
2749
  }
2729
2750
 
@@ -3804,7 +3825,7 @@ export class IterationOrchestrator {
3804
3825
  ...(workingMemory.context ? [workingMemory.context] : []),
3805
3826
  ]
3806
3827
  const finalMessages = projectRequestRichContent(
3807
- withoutVoidAssistantTurns(this.projectObservations(finalHistory)),
3828
+ withoutVoidAssistantTurns(this.projectObservations(framePastedMessages(finalHistory))),
3808
3829
  this.richContentBudget(),
3809
3830
  { imagesReadable: this.modelReadsImages(model) },
3810
3831
  )
@@ -27,6 +27,7 @@ import { serializeState } from '../../../../compaction/serializer.js'
27
27
  import {
28
28
  COMPACTION_RECOVERY_NOTE,
29
29
  buildCompactionMessage,
30
+ collectRevealedTools,
30
31
  isCompactionMessage,
31
32
  } from '../../../../compaction/summary.js'
32
33
  import { estimateMessagesTokens } from '../../../../compaction/token-estimate.js'
@@ -1282,6 +1283,9 @@ async function runCompactionCheckInner(
1282
1283
  mounted.has('search_conversation') && mounted.has('read_conversation')
1283
1284
  ? COMPACTION_RECOVERY_NOTE
1284
1285
  : undefined,
1286
+ // The tools the model had loaded stay loaded: the messages that loaded
1287
+ // them are what this pass cuts.
1288
+ collectRevealedTools(messages),
1285
1289
  )
1286
1290
 
1287
1291
  const newMessages = [...preservedSystem, compactionMessage, ...retainedOlder, ...recentMessages]
@@ -477,6 +477,11 @@ function resumeContextOf(ctx: IterationContext, scope?: AskScope): ResumeContext
477
477
  ctx.toolExecutor.launchedScripts(callId, line, dialect),
478
478
  }
479
479
  : {}),
480
+ ...(typeof ctx.toolExecutor?.gitStatusForReview === 'function'
481
+ ? {
482
+ gitStatus: (line, dialect) => ctx.toolExecutor.gitStatusForReview(line, dialect),
483
+ }
484
+ : {}),
480
485
  }
481
486
  }
482
487
 
@@ -9,25 +9,20 @@ import { DECLINED_TOOL_CALL_FEEDBACK } from '../../declined.js'
9
9
  import type { CallAdmission, ReviewedExecution } from '../../executor.js'
10
10
  import { DECLINED_NOTE_MAX_CHARS } from '../../executor.js'
11
11
  import { supersededByRecovery } from '../../resume-pending.js'
12
+ import {
13
+ EDIT_NOT_OFFERED,
14
+ NOT_THIS_QUESTION,
15
+ PAUSED_CALL,
16
+ UNANSWERED_CALL,
17
+ } from '../../unanswered.js'
18
+
19
+ export { UNANSWERED_CALL } from '../../unanswered.js'
12
20
  import { type IterationContext, awaitDecisionDurably } from './context.js'
13
21
 
14
22
  /** What a call is told when a refusal elsewhere in its batch ended the turn before it started. */
15
23
  export const REFUSED_WITH_THE_TURN =
16
24
  'An earlier call in this batch was refused and the turn was stopped, so this call was not run. Wait for the user.'
17
25
 
18
- /** What a call is told when the answer to it could not be taken. */
19
- export const UNANSWERED_CALL =
20
- 'No answer was given for this call, so it was not run. Ask again if it is still needed.'
21
-
22
- const EDIT_NOT_OFFERED =
23
- 'Editing a call while it is asked about is not offered, so this call was not run. Ask again with the input you want.'
24
-
25
- const PAUSED_CALL =
26
- 'The turn was asked to wait before this call could be answered, so it was not run. Ask again if it is still needed.'
27
-
28
- const NOT_THIS_QUESTION =
29
- 'That answer was not an answer to a question about a tool call, so this call was not run.'
30
-
31
26
  /** The audit trail keeps a person's reason, cut short and without control characters. */
32
27
  /**
33
28
  * Whether a tool result is the answer to a call that never ran because the
@@ -662,7 +662,13 @@ export async function* runToolReview(
662
662
  for (const gr of gateResults) {
663
663
  // Before the overrides below: only a rule that was WRITTEN to ask a
664
664
  // person, not an allow demoted to a question, is an ask rule.
665
- const ruleAsked = gr.gateResult.decision === 'review' && gr.gateResult.matchedRule !== null
665
+ // The dangerous-command floor's questions (`sudo`, `ssh user@host`, …)
666
+ // are not ask rules: nobody wrote one to be kept in every mode, so
667
+ // bypass and auto lift them like any other review.
668
+ const ruleAsked =
669
+ gr.gateResult.decision === 'review' &&
670
+ gr.gateResult.matchedRule !== null &&
671
+ gr.gateResult.matchedRule.type !== 'deny_dangerous_patterns'
666
672
  // An `allow` rule was written about a tool, not about a path outside
667
673
  // the working directory or a command outside the sandbox, which
668
674
  // were refused outright when it was written. So an escalated call