@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
@@ -64,10 +64,29 @@ export interface GitWorktreeDriverConfig {
64
64
  */
65
65
  worktreesDir?: string
66
66
  logger: Logger
67
+ /**
68
+ * The first part of every branch this driver makes: `<branchPrefix>/<label>`.
69
+ * One safe component (letters, digits, `.`, `_`, `-`; at most 40 characters).
70
+ * Defaults to `namzu`. A worktree made under another prefix is still owned
71
+ * and still found, because Git, not the prefix, vouches for the branch.
72
+ */
73
+ branchPrefix?: string
67
74
  /** Test-seam: inject a stub `execFile` implementation. */
68
75
  execFile?: ExecFile
69
76
  }
70
77
 
78
+ const DEFAULT_BRANCH_PREFIX = 'namzu'
79
+
80
+ /** One safe branch component: no slash, no leading dot or hyphen, no Git syntax. */
81
+ function isBranchPrefix(value: string): boolean {
82
+ return (
83
+ /^[A-Za-z0-9_][A-Za-z0-9._-]{0,39}$/.test(value) &&
84
+ !value.endsWith('.') &&
85
+ !value.includes('..') &&
86
+ !value.endsWith('.lock')
87
+ )
88
+ }
89
+
71
90
  export class GitWorktreeDriver implements WorkspaceBackendDriver {
72
91
  readonly kind = 'git-worktree' as const
73
92
 
@@ -75,12 +94,20 @@ export class GitWorktreeDriver implements WorkspaceBackendDriver {
75
94
  private readonly worktreesDir: string
76
95
  private readonly log: Logger
77
96
  private readonly exec: ExecFile
97
+ private readonly branchPrefix: string
78
98
 
79
99
  constructor(config: GitWorktreeDriverConfig) {
80
100
  this.repoRoot = resolve(config.repoRoot)
81
101
  this.worktreesDir = resolve(config.worktreesDir ?? defaultWorktreesDir(config.repoRoot))
82
102
  this.log = config.logger.child({ [SCOPE_ATTRIBUTE]: 'session/workspace/git-worktree' })
83
103
  this.exec = config.execFile ?? defaultExecFile
104
+ const prefix = config.branchPrefix ?? DEFAULT_BRANCH_PREFIX
105
+ if (!isBranchPrefix(prefix)) {
106
+ throw new Error(
107
+ 'A worktree branch prefix must be 1 to 40 letters, digits, dots, underscores or hyphens, and must not start with a dot or hyphen.',
108
+ )
109
+ }
110
+ this.branchPrefix = prefix
84
111
  }
85
112
 
86
113
  async create(params: CreateWorkspaceParams): Promise<WorkspaceRef> {
@@ -112,7 +139,7 @@ export class GitWorktreeDriver implements WorkspaceBackendDriver {
112
139
  }
113
140
 
114
141
  const relativePath = relative(worktreesDir, worktreePath).split(sep).join('/')
115
- const branch = `namzu/${relativePath}`
142
+ const branch = `${this.branchPrefix}/${relativePath}`
116
143
 
117
144
  // `--` belongs before caller-controlled positional arguments. Without it,
118
145
  // a base ref such as `--no-checkout` is accepted as a Git option and the
@@ -349,8 +376,12 @@ export class GitWorktreeDriver implements WorkspaceBackendDriver {
349
376
  }
350
377
 
351
378
  const label = relative(worktreesDir, worktreePath).split(sep).join('/')
352
- const branch = `namzu/${label}`
353
- if (ref.meta.branch !== branch) {
379
+ // The prefix is whatever the host chose when the worktree was made, so
380
+ // it may differ from the one set now. Ownership rests on the path and
381
+ // on Git registering exactly this branch there, not on the prefix.
382
+ const branch = ref.meta.branch
383
+ const suffix = `/${label}`
384
+ if (!branch.endsWith(suffix) || !isBranchPrefix(branch.slice(0, -suffix.length))) {
354
385
  throw new Error('Workspace reference branch does not match its managed path')
355
386
  }
356
387
 
@@ -33,4 +33,4 @@ export function classifyEvidenceSource(source: string): EvidenceRecordKind {
33
33
 
34
34
  /** Shared model-facing interpretation for hosts projecting recorded evidence. */
35
35
  export const EVIDENCE_RECORD_GUIDANCE =
36
- 'Producer kinds do not establish truth or independence. assistant_message is a prior model claim, not proof of observed state or successful action. Attribute it as a claim unless supported by the original observation; tool results may themselves quote claims.'
36
+ 'Producer kinds do not establish truth or independence. assistant_message is what the assistant itself said earlier in this conversation. For a question about what you said or why, it is the record: quote it and answer from it. For a question about what is true now, a prior claim is not proof of observed state or successful action; attribute it as a claim unless supported by the original observation, and re-check only the current state. Tool results may themselves quote claims.'
@@ -1,5 +1,5 @@
1
- import { existsSync, statSync } from 'node:fs'
2
- import { mkdir, readdir, rename, rm, stat } from 'node:fs/promises'
1
+ import { chmodSync, existsSync, lstatSync, statSync } from 'node:fs'
2
+ import { mkdir, open, readdir, rename, rm, stat } from 'node:fs/promises'
3
3
  import { createRequire } from 'node:module'
4
4
  import { basename, dirname, join } from 'node:path'
5
5
  import type { DatabaseSync, SQLInputValue, StatementSync } from 'node:sqlite'
@@ -43,6 +43,36 @@ import type { ExternalRefClaim, ExternalRefKind, ExternalRefTarget } from './ref
43
43
  /** `PRAGMA user_version` of an index this module writes. Any other version is rebuilt, never migrated. */
44
44
  export const SESSION_INDEX_VERSION = 1
45
45
 
46
+ /**
47
+ * The index holds every prompt's opening text and the full text of tool
48
+ * results and replies, so it is the owner's alone, like the session logs it is
49
+ * derived from. Its folder, when this module creates it, is too.
50
+ */
51
+ const INDEX_FILE_MODE = 0o600
52
+ const INDEX_DIRECTORY_MODE = 0o700
53
+
54
+ /**
55
+ * Narrow the index at `path`, and any journal SQLite keeps beside it, to its
56
+ * owner. An index written before this rule kept the umask's mode (0644 on most
57
+ * systems), which let other users of the machine read it. A file this process
58
+ * does not own, a link, or a platform without POSIX modes is left as it is:
59
+ * the change is a tightening, never a reason to fail the open.
60
+ */
61
+ function restrictIndexFiles(path: string): void {
62
+ if (process.platform === 'win32') return
63
+ const uid = process.getuid?.()
64
+ for (const file of [path, `${path}-journal`, `${path}-wal`, `${path}-shm`]) {
65
+ try {
66
+ const entry = lstatSync(file)
67
+ if (!entry.isFile() || (entry.mode & 0o077) === 0) continue
68
+ if (uid !== undefined && entry.uid !== uid) continue
69
+ chmodSync(file, INDEX_FILE_MODE)
70
+ } catch {
71
+ // Absent, or not ours to change.
72
+ }
73
+ }
74
+ }
75
+
46
76
  type SqliteModule = typeof import('node:sqlite')
47
77
 
48
78
  let sqliteModule: SqliteModule | null | undefined
@@ -677,10 +707,14 @@ export class SqliteSessionIndex extends SessionIndexBase {
677
707
  /** See {@link rebuildSqliteSessionIndex}. */
678
708
  static async rebuild(options: RebuildSqliteSessionIndexOptions): Promise<boolean> {
679
709
  const { DatabaseSync } = requireSqlite()
680
- await mkdir(dirname(options.path), { recursive: true })
710
+ await mkdir(dirname(options.path), { recursive: true, mode: INDEX_DIRECTORY_MODE })
681
711
  await sweepAbandonedRebuilds(options.path)
682
712
  const temporary = `${options.path}.tmp-${process.pid}-${uuidv7()}`
683
713
  try {
714
+ // Every index file starts as this temporary one, so creating it owner-only
715
+ // here is what makes the renamed index owner-only. SQLite opens an empty
716
+ // file as an empty database, and gives its journal the file's mode.
717
+ await (await open(temporary, 'wx', INDEX_FILE_MODE)).close()
684
718
  const db = new DatabaseSync(temporary)
685
719
  const index = new SqliteSessionIndex(db)
686
720
  try {
@@ -714,6 +748,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
714
748
  } else {
715
749
  await sweepAbandonedRebuilds(options.path)
716
750
  }
751
+ restrictIndexFiles(options.path)
717
752
  const db = new DatabaseSync(options.path)
718
753
  try {
719
754
  configure(db)
@@ -742,6 +777,8 @@ export class SqliteSessionIndex extends SessionIndexBase {
742
777
  const identity = fileIdentity(path)
743
778
  if (identity === undefined || (!force && identity === this.#identity)) return
744
779
  const { DatabaseSync } = requireSqlite()
780
+ // A peer on an older version may have renamed its own, wider file in.
781
+ restrictIndexFiles(path)
745
782
  const db = new DatabaseSync(path)
746
783
  try {
747
784
  configure(db)
@@ -119,7 +119,7 @@ export class DiskLogMedium implements LogMedium {
119
119
  }
120
120
 
121
121
  async append(bytes: Uint8Array, expectedOffset: number, sync: boolean): Promise<void> {
122
- await mkdir(dirname(this.file), { recursive: true })
122
+ await mkdir(dirname(this.file), { recursive: true, mode: 0o700 })
123
123
  const handle = await open(this.file, 'a', 0o600)
124
124
  try {
125
125
  const before = (await handle.stat()).size
@@ -215,7 +215,8 @@ export class DiskSessionLeaseStore implements SessionLeaseStore {
215
215
  /** Write `body` and make it visible at `fence`, whole or not at all. Throws `EEXIST` on a lost race. */
216
216
  async #publish(fence: number, body: LeaseBody): Promise<void> {
217
217
  const temporary = join(this.sessionDir, tempName(fence))
218
- await writeFile(temporary, JSON.stringify(body), { flag: 'wx' })
218
+ // Owner-only, like the log it guards.
219
+ await writeFile(temporary, JSON.stringify(body), { flag: 'wx', mode: 0o600 })
219
220
  try {
220
221
  await link(temporary, join(this.sessionDir, `lease.${fence}.json`))
221
222
  } finally {
@@ -239,7 +240,7 @@ export class DiskSessionLeaseStore implements SessionLeaseStore {
239
240
  context: LeaseClaimContext = {},
240
241
  ): Promise<SessionLease | null> {
241
242
  const now = options.now ?? Date.now()
242
- await mkdir(this.sessionDir, { recursive: true })
243
+ await mkdir(this.sessionDir, { recursive: true, mode: 0o700 })
243
244
  for (let attempt = 0; attempt < 8; attempt++) {
244
245
  const held = await this.current()
245
246
  const decision = decideClaim(held, options, context, now)
@@ -119,6 +119,8 @@ export function admitToolFacts(value: unknown): ToolFacts | undefined {
119
119
  : undefined,
120
120
  background: flag(value.background),
121
121
  continued: flag(value.continued),
122
+ jobId: text(value.jobId),
123
+ timeLimitMs: count(value.timeLimitMs),
122
124
  })
123
125
  case 'read': {
124
126
  const path = text(value.path)
@@ -1,8 +1,8 @@
1
1
  import { rm } from 'node:fs/promises'
2
2
  import { z } from 'zod'
3
+ import { findDangerousCommand } from '../../authorization/dangerous-commands.js'
3
4
  import { isReadOnlyCommandLine } from '../../authorization/readonly-commands.js'
4
5
  import { SANDBOX_KILL_GRACE_MS } from '../../constants/sandbox/index.js'
5
- import { DANGEROUS_PATTERNS, dangerousCommandReason } from '../../constants/tools/index.js'
6
6
  import { killTree } from '../../process/kill-tree.js'
7
7
  import { genericLabel } from '../../registry/tool/presentation.js'
8
8
  import { cancelCauseOf } from '../../types/session/cancel-cause.js'
@@ -98,9 +98,12 @@ function startsWithSleep(command: string): boolean {
98
98
  * moved to the background instead of being stopped. Exported so the test
99
99
  * states the same words.
100
100
  */
101
+ export const COMMAND_HAS_NO_INPUT =
102
+ 'Stdin is closed and there is no terminal, so a prompt for input or a password cannot be answered: use a non-interactive flag, put the answer in the command, or ask the person.'
103
+
101
104
  export function movedToBackgroundMessage(jobId: string, timeoutMs: number): string {
102
105
  const seconds = Math.max(1, Math.round(timeoutMs / 1000))
103
- return `Command did not complete within its ${seconds}s timeout and was moved to the background as job ${jobId}; it was not stopped. You will be told when it ends. Its output so far is above.`
106
+ return `Command did not complete within its ${seconds}s timeout and was moved to the background as job ${jobId}; it was not stopped. You will be told when it ends. Its output so far is above. ${COMMAND_HAS_NO_INPUT}`
104
107
  }
105
108
 
106
109
  /**
@@ -122,7 +125,7 @@ export function handedOffMessage(jobId: string, reason: 'user' | 'message' | 'in
122
125
  : reason === 'message'
123
126
  ? 'so a message from the person could reach you'
124
127
  : 'because the person interrupted the turn'
125
- return `Command was moved to the background as job ${jobId} ${why}; it was not stopped. You will be told when it ends. Its output so far is above.`
128
+ return `Command was moved to the background as job ${jobId} ${why}; it was not stopped. You will be told when it ends. Its output so far is above. ${COMMAND_HAS_NO_INPUT}`
126
129
  }
127
130
 
128
131
  const inputSchema = z.object({
@@ -150,6 +153,13 @@ const inputSchema = z.object({
150
153
  .describe(
151
154
  `Command timeout in milliseconds. Default: ${DEFAULT_BASH_TIMEOUT_MS}, maximum: ${MAX_BASH_TIMEOUT_MS}. For work that legitimately runs longer than the maximum, set run_in_background and await it with \`wait_for_job\`, rather than holding the turn open. A foreground command still running when the timeout elapses is moved to a background job (and reported as such) instead of being stopped, where the host has background jobs.`,
152
155
  ),
156
+ description: z
157
+ .string()
158
+ .max(200)
159
+ .optional()
160
+ .describe(
161
+ 'A short label in plain words (about 5 to 10) for what this command does, such as "Run the full test suite". The person sees it for a background job instead of the command line.',
162
+ ),
153
163
  run_in_background: z
154
164
  .boolean()
155
165
  .optional()
@@ -531,16 +541,20 @@ export function execHostShell(
531
541
  })
532
542
  }
533
543
 
534
- export { dangerousCommandReason }
535
-
536
- /** A reason as a sentence a person reads under a row: first letter up. */
537
- function sentence(reason: string): string {
538
- return reason ? `${reason.charAt(0).toUpperCase()}${reason.slice(1)}` : reason
544
+ /**
545
+ * Why `command` is one this tool refuses to run, or `undefined`. Only the
546
+ * irreversible acts the gate refuses in every mode: a command the gate let
547
+ * through as a question (`sudo`, `ssh user@host`) was a person's call, and this
548
+ * check must not take it back.
549
+ */
550
+ export function dangerousCommandReason(command: string): string | undefined {
551
+ const found = findDangerousCommand(command)
552
+ return found?.tier === 'stop' ? found.reason : undefined
539
553
  }
540
554
 
541
555
  /** The dangerous-pattern check `bash` applies, shared so the `monitor` tool refuses the same lines. */
542
556
  export function isDangerousCommand(command: string): boolean {
543
- return DANGEROUS_PATTERNS.some((pattern) => pattern.test(command))
557
+ return dangerousCommandReason(command) !== undefined
544
558
  }
545
559
 
546
560
  /** The refusal when a sandbox cannot host a detached process; exported so the test states the same words. */
@@ -554,8 +568,7 @@ export const SANDBOX_CANNOT_DETACH =
554
568
  export const SANDBOX_ESCAPE_NOT_APPROVED =
555
569
  'dangerously_disable_sandbox was not approved for this call, so the command did not run. Leaving the sandbox needs the user to confirm it each time, and this turn either cannot ask or does not allow it. Run the command inside the sandbox, or tell the user what it needs and let them run it.'
556
570
 
557
- const BASH_DESCRIPTION =
558
- 'Executes a command line using the execution shell disclosed in the system context and returns stdout/stderr output. The working directory persists between calls, but shell state does not. Command timeout is configurable. Read and search with `read`, `grep` and `glob`, not shell loops: a file read through the shell earns no read credit, so its next edit is refused once. Run a check on its own, not piped: its output is already trimmed, and a pipe hides the exit status.'
571
+ const BASH_DESCRIPTION = `Executes a command line using the execution shell disclosed in the system context and returns stdout/stderr output. The working directory persists between calls, but shell state does not. Command timeout is configurable. Read and search with \`read\`, \`grep\` and \`glob\`, not shell loops: a file read through the shell earns no read credit, so its next edit is refused once. Run a check on its own, not piped: its output is already trimmed, and a pipe hides the exit status. Output too long for the result and the output of a background job are saved to a file whose path you are given: do not redirect output into files of your own. ${COMMAND_HAS_NO_INPUT}`
559
572
 
560
573
  const BashToolBase = defineTool({
561
574
  name: 'bash',
@@ -582,12 +595,22 @@ const BashToolBase = defineTool({
582
595
  // The kernel reviews a call that sets it under a sandbox every time and
583
596
  // confirms it only by id; see `ToolDefinition.sandboxEscapeArgument`.
584
597
  sandboxEscapeArgument: 'dangerously_disable_sandbox',
598
+ // A long leading sleep is refused when the command runs, with the better
599
+ // ways to wait. The same answer is given here, before a person is asked to
600
+ // approve a command that would be blocked the moment they said yes.
601
+ refuseBeforeReview: async (input: BashInput, context) => {
602
+ if (input.run_in_background || !context.backgroundJobs || backgroundTasksDisabled()) {
603
+ return undefined
604
+ }
605
+ const longSleep = leadingLongSleep(input.command)
606
+ return longSleep === null ? undefined : { error: longSleepRefusal(longSleep) }
607
+ },
585
608
  permissions: ['shell_execute'],
586
609
  // A line made only of vetted read-only commands (`ls`, `cat`, `git status`,
587
610
  // `git diff`, ...) needs no prompt and may run beside other reads; see
588
611
  // `authorization/readonly-commands.ts`. Anything else is not read-only.
589
612
  readOnly: (input: BashInput) => bashInputIsReadOnly(input),
590
- destructive: (input: BashInput) => isDangerousCommand(input.command),
613
+ destructive: (input: BashInput) => findDangerousCommand(input.command) !== undefined,
591
614
  concurrencySafe: (input: BashInput) => bashInputIsReadOnly(input),
592
615
  // Above the ceiling the input schema accepts, so the executor's deadline
593
616
  // is a backstop rather than a second clock racing this tool's own. It used
@@ -609,16 +632,17 @@ const BashToolBase = defineTool({
609
632
 
610
633
  async execute(input, context) {
611
634
  const startDirectory = bashWorkingDirectoryForExecution(context)
612
- if (isDangerousCommand(input.command)) {
635
+ const refused = dangerousCommandReason(input.command)
636
+ if (refused !== undefined) {
613
637
  return {
614
638
  success: false,
615
639
  output: '',
616
- error: `Dangerous command blocked: "${input.command}". Why: ${dangerousCommandReason(input.command)}. Nothing ran. Use a narrower command that avoids it, or ask the user to run this one.`,
640
+ error: `Dangerous command blocked: "${input.command}". Why: ${refused}. Nothing ran. Do not retry it or a reworded form; tell the user what you were trying to do and let them run it or decide.`,
617
641
  facts: {
618
642
  kind: 'failure',
619
643
  reason: 'blocked',
620
644
  subject: 'bash',
621
- note: sentence(dangerousCommandReason(input.command)),
645
+ note: `This command ${refused.replace(/^it /, '')}.`,
622
646
  },
623
647
  }
624
648
  }
@@ -689,10 +713,12 @@ const BashToolBase = defineTool({
689
713
  'run_in_background was requested, but this host provides no background job registry. Run the command in the foreground, or raise `timeout` up to the tool maximum.',
690
714
  }
691
715
  }
716
+ const jobLabel = input.description?.replace(/\s+/gu, ' ').trim() || undefined
692
717
  try {
693
718
  const job = context.backgroundJobs.start({
694
719
  command: input.command,
695
720
  workingDirectory: startDirectory,
721
+ ...(jobLabel !== undefined ? { description: jobLabel } : {}),
696
722
  })
697
723
  // `start` returns before the process exists, and a spawn that
698
724
  // fails (no such shell, bad directory) reports a tick later.
@@ -709,9 +735,17 @@ const BashToolBase = defineTool({
709
735
  }
710
736
  return {
711
737
  success: true,
712
- output: `Started background job ${job.id}; state: running.`,
713
- data: { jobId: job.id, background: true },
714
- facts: { kind: 'command', command: input.command, background: true },
738
+ output: `Started background job ${job.id}; state: running.${
739
+ job.outputFile === undefined
740
+ ? ''
741
+ : ` Its output is saved to ${job.outputFile}; do not redirect it into a file of your own. Use wait_for_job to wait for it to finish and job to read it.`
742
+ }`,
743
+ data: {
744
+ jobId: job.id,
745
+ background: true,
746
+ ...(job.outputFile === undefined ? {} : { outputFile: job.outputFile }),
747
+ },
748
+ facts: { kind: 'command', command: input.command, background: true, jobId: job.id },
715
749
  }
716
750
  } catch (err) {
717
751
  // The per-owner cap, most likely. A refusal that names the limit
@@ -832,6 +866,7 @@ const BashToolBase = defineTool({
832
866
  // registry, a sandboxed turn, a one-off sandbox escape, a plain wait)
833
867
  // is there anything to hand the process to, so those keep the kill.
834
868
  const adopt = context.backgroundJobs?.adopt?.bind(context.backgroundJobs)
869
+ const adoptLabel = input.description?.replace(/\s+/gu, ' ').trim() || undefined
835
870
  const canHandOff =
836
871
  adopt !== undefined && context.sandbox === undefined && !backgroundTasksDisabled()
837
872
  const canMoveOnTimeout = canHandOff && !startsWithSleep(input.command)
@@ -841,6 +876,7 @@ const BashToolBase = defineTool({
841
876
  }) =>
842
877
  adopt?.({
843
878
  command: input.command,
879
+ ...(adoptLabel !== undefined ? { description: adoptLabel } : {}),
844
880
  child: running.child,
845
881
  workingDirectory: context.workingDirectory,
846
882
  initialOutput: running.initialOutput,
@@ -920,7 +956,14 @@ const BashToolBase = defineTool({
920
956
  movedToBackground: true,
921
957
  ...(backgroundedBy ? { backgroundedBy } : {}),
922
958
  },
923
- facts: { kind: 'command', command: input.command, background: true, continued: true },
959
+ facts: {
960
+ kind: 'command',
961
+ command: input.command,
962
+ background: true,
963
+ continued: true,
964
+ jobId: backgroundedJobId,
965
+ ...(timedOut || backgroundedBy === undefined ? { timeLimitMs: input.timeout } : {}),
966
+ },
924
967
  }
925
968
  }
926
969
  const reset = await settle()