@namzu/sdk 65.2.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 (571) hide show
  1. package/CHANGELOG.md +161 -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 +98 -8
  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/browser/index.d.ts +12 -0
  402. package/dist/types/browser/index.d.ts.map +1 -1
  403. package/dist/types/hitl/index.d.ts +10 -0
  404. package/dist/types/hitl/index.d.ts.map +1 -1
  405. package/dist/types/hitl/index.js.map +1 -1
  406. package/dist/types/message/index.d.ts +56 -1
  407. package/dist/types/message/index.d.ts.map +1 -1
  408. package/dist/types/message/index.js +2 -1
  409. package/dist/types/message/index.js.map +1 -1
  410. package/dist/types/permission/index.d.ts +14 -0
  411. package/dist/types/permission/index.d.ts.map +1 -1
  412. package/dist/types/permission/index.js +14 -0
  413. package/dist/types/permission/index.js.map +1 -1
  414. package/dist/types/plugin/index.d.ts +148 -1
  415. package/dist/types/plugin/index.d.ts.map +1 -1
  416. package/dist/types/plugin/index.js +9 -0
  417. package/dist/types/plugin/index.js.map +1 -1
  418. package/dist/types/provider/index.d.ts +1 -0
  419. package/dist/types/provider/index.d.ts.map +1 -1
  420. package/dist/types/provider/interface.d.ts +12 -0
  421. package/dist/types/provider/interface.d.ts.map +1 -1
  422. package/dist/types/provider/limits.d.ts +33 -0
  423. package/dist/types/provider/limits.d.ts.map +1 -0
  424. package/dist/types/provider/limits.js +7 -0
  425. package/dist/types/provider/limits.js.map +1 -0
  426. package/dist/types/tool/index.d.ts +30 -0
  427. package/dist/types/tool/index.d.ts.map +1 -1
  428. package/dist/types/tool/index.js.map +1 -1
  429. package/dist/types/tool/presentation.d.ts +4 -0
  430. package/dist/types/tool/presentation.d.ts.map +1 -1
  431. package/dist/utils/file-lock.d.ts +88 -0
  432. package/dist/utils/file-lock.d.ts.map +1 -0
  433. package/dist/utils/file-lock.js +281 -0
  434. package/dist/utils/file-lock.js.map +1 -0
  435. package/dist/utils/state-backup.d.ts +87 -0
  436. package/dist/utils/state-backup.d.ts.map +1 -0
  437. package/dist/utils/state-backup.js +272 -0
  438. package/dist/utils/state-backup.js.map +1 -0
  439. package/dist/utils/temp-sweep.d.ts +66 -0
  440. package/dist/utils/temp-sweep.d.ts.map +1 -0
  441. package/dist/utils/temp-sweep.js +311 -0
  442. package/dist/utils/temp-sweep.js.map +1 -0
  443. package/dist/utils/temp.d.ts +14 -0
  444. package/dist/utils/temp.d.ts.map +1 -1
  445. package/dist/utils/temp.js +70 -2
  446. package/dist/utils/temp.js.map +1 -1
  447. package/package.json +1 -1
  448. package/src/account/lock.ts +13 -133
  449. package/src/account/registry.ts +75 -21
  450. package/src/account/types.ts +8 -9
  451. package/src/authorization/dangerous-commands.ts +542 -0
  452. package/src/authorization/gate.ts +19 -5
  453. package/src/authorization/protected-paths.ts +13 -8
  454. package/src/authorization/readonly-commands.ts +35 -1
  455. package/src/authorization/removal.ts +7 -7
  456. package/src/authorization/rules.ts +75 -15
  457. package/src/authorization/shell-lexer.ts +19 -0
  458. package/src/bridge/acp/permission.ts +2 -0
  459. package/src/bridge/acp/server.ts +66 -6
  460. package/src/compaction/context-breakdown.ts +53 -11
  461. package/src/compaction/dangling.ts +2 -0
  462. package/src/compaction/extractor.ts +9 -1
  463. package/src/compaction/index.ts +1 -0
  464. package/src/compaction/managers/structured.ts +2 -2
  465. package/src/compaction/manual.ts +11 -3
  466. package/src/compaction/model-summary.ts +8 -1
  467. package/src/compaction/summary.ts +54 -7
  468. package/src/constants/tools/index.ts +30 -16
  469. package/src/manager/session/turn-recorder.ts +37 -1
  470. package/src/network/audit.ts +113 -0
  471. package/src/network/clock.ts +62 -0
  472. package/src/network/discovery-mdns.ts +485 -0
  473. package/src/network/discovery.ts +210 -0
  474. package/src/network/fingerprint.ts +241 -0
  475. package/src/network/identity.ts +98 -0
  476. package/src/network/index.ts +134 -0
  477. package/src/network/join.ts +177 -0
  478. package/src/network/mail-policy.ts +199 -0
  479. package/src/network/membership.ts +290 -0
  480. package/src/network/roster.ts +165 -0
  481. package/src/network/service.ts +2304 -0
  482. package/src/network/store.ts +261 -0
  483. package/src/network/transport.ts +445 -0
  484. package/src/network/wire.ts +250 -0
  485. package/src/network/x509.ts +114 -0
  486. package/src/pals/activity/causality.ts +16 -2
  487. package/src/peers/endpoint.ts +6 -0
  488. package/src/peers/envelope.ts +82 -5
  489. package/src/peers/index.ts +10 -2
  490. package/src/peers/mode-word.ts +18 -0
  491. package/src/peers/protocol.ts +24 -1
  492. package/src/peers/record.ts +5 -0
  493. package/src/plugin/session-hook-env.ts +25 -2
  494. package/src/plugin/shell-hook.ts +208 -14
  495. package/src/prompt/coding-agent-doctrine.ts +33 -38
  496. package/src/public-runtime.ts +107 -1
  497. package/src/public-tools.ts +11 -0
  498. package/src/public-types.ts +67 -1
  499. package/src/runtime/jobs/registry.ts +93 -3
  500. package/src/runtime/query/auto-review/classifier.ts +76 -14
  501. package/src/runtime/query/auto-review/feedback.ts +50 -0
  502. package/src/runtime/query/auto-review/git-status.ts +437 -0
  503. package/src/runtime/query/auto-review/index.ts +7 -2
  504. package/src/runtime/query/auto-review/prompt.ts +6 -1
  505. package/src/runtime/query/auto-review/transcript.ts +67 -4
  506. package/src/runtime/query/executor/tool-call-admission.ts +49 -3
  507. package/src/runtime/query/executor.ts +104 -21
  508. package/src/runtime/query/index.ts +66 -17
  509. package/src/runtime/query/iteration/index.ts +24 -3
  510. package/src/runtime/query/iteration/phases/compaction.ts +4 -0
  511. package/src/runtime/query/iteration/phases/context.ts +5 -0
  512. package/src/runtime/query/iteration/phases/per-call-review.ts +8 -13
  513. package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
  514. package/src/runtime/query/pasted-frames.ts +119 -0
  515. package/src/runtime/query/path-escalation.ts +27 -3
  516. package/src/runtime/query/request-interrupted-turns.ts +47 -0
  517. package/src/runtime/query/review-policy.ts +125 -22
  518. package/src/runtime/query/turn/outcome-ledger.ts +99 -6
  519. package/src/runtime/query/unanswered.ts +35 -0
  520. package/src/runtime/system-events.ts +2 -0
  521. package/src/session/workspace/git-worktree.ts +34 -3
  522. package/src/store/evidence/source-kind.ts +1 -1
  523. package/src/store/session-index/sqlite.ts +40 -3
  524. package/src/store/session-log/disk.ts +1 -1
  525. package/src/store/session-log/lease.ts +3 -2
  526. package/src/tools/admit-facts.ts +2 -0
  527. package/src/tools/builtins/bash.ts +62 -19
  528. package/src/tools/builtins/browser-local.ts +504 -0
  529. package/src/tools/builtins/browser.ts +121 -8
  530. package/src/tools/builtins/computer-use-window-id.ts +50 -0
  531. package/src/tools/builtins/computer-use.ts +460 -68
  532. package/src/tools/builtins/content-fingerprint.ts +8 -1
  533. package/src/tools/builtins/edit.ts +93 -7
  534. package/src/tools/builtins/file-write-result.ts +2 -1
  535. package/src/tools/builtins/grep.ts +1 -1
  536. package/src/tools/builtins/job.ts +4 -2
  537. package/src/tools/builtins/monitor.ts +6 -1
  538. package/src/tools/builtins/search-tools.ts +196 -21
  539. package/src/tools/builtins/shell-read-credit.ts +97 -33
  540. package/src/tools/builtins/wait-for-job.ts +13 -3
  541. package/src/tools/builtins/web-guidance.ts +6 -0
  542. package/src/tools/builtins/web.ts +2 -1
  543. package/src/tools/builtins/write-file.ts +31 -3
  544. package/src/tools/command-shell.ts +6 -8
  545. package/src/tools/defineTool.ts +20 -1
  546. package/src/tools/schedules/index.ts +11 -0
  547. package/src/tools/schedules/loop-tool.ts +10 -6
  548. package/src/tools/schedules/present.ts +1 -1
  549. package/src/tools/schedules/timer-tools.ts +258 -0
  550. package/src/tools/schedules/types.ts +72 -3
  551. package/src/tools/task/create.ts +2 -0
  552. package/src/toolsets/manager.ts +262 -46
  553. package/src/turn/evidence-query.ts +183 -42
  554. package/src/turn/evidence-recall.ts +96 -19
  555. package/src/turn/history-shed.ts +30 -0
  556. package/src/types/acp/index.ts +24 -0
  557. package/src/types/authorization/index.ts +20 -3
  558. package/src/types/browser/index.ts +9 -0
  559. package/src/types/hitl/index.ts +10 -0
  560. package/src/types/message/index.ts +65 -0
  561. package/src/types/permission/index.ts +18 -0
  562. package/src/types/plugin/index.ts +205 -26
  563. package/src/types/provider/index.ts +1 -0
  564. package/src/types/provider/interface.ts +13 -0
  565. package/src/types/provider/limits.ts +35 -0
  566. package/src/types/tool/index.ts +30 -2
  567. package/src/types/tool/presentation.ts +4 -0
  568. package/src/utils/file-lock.ts +328 -0
  569. package/src/utils/state-backup.ts +318 -0
  570. package/src/utils/temp-sweep.ts +327 -0
  571. package/src/utils/temp.ts +73 -2
@@ -51,7 +51,7 @@ export function unreadEditShownError(path: string, content: string): string | un
51
51
  if (lines.length > 1 && lines[lines.length - 1] === '') lines.pop()
52
52
  if (lines.length > UNREAD_EDIT_SHOWN_MAX_LINES) return undefined
53
53
  const numbered = lines.map((line, i) => `${i + 1}\t${line}`).join('\n')
54
- return `${path} had not been read in this session, so this edit was not applied. It has now been read for you; its current contents follow. Repeat the edit against them. Nothing was written.\n\n${numbered}`
54
+ return `${path} had not been read in this session, so this edit was not applied. It has now been read for you; its current contents follow. Repeat the edit against them, without reading the file again. Nothing was written.\n\n${numbered}`
55
55
  }
56
56
 
57
57
  /** What `edit` tells the agent when the file was never read and is too large to hand over. */
@@ -78,3 +78,10 @@ export function movedSinceRead(
78
78
  const seen = tracker.fingerprint?.(key)
79
79
  return seen !== undefined && seen !== fingerprintContent(current)
80
80
  }
81
+
82
+ /**
83
+ * Said after a write or an edit went through. A model that is told only "done"
84
+ * reads the file back to be sure, which costs a request and shows it what it
85
+ * just wrote; the result already is the proof.
86
+ */
87
+ export const CURRENT_ON_DISK = 'The file on disk is now exactly this; no need to read it back.'
@@ -8,6 +8,7 @@ import { resolveWithinAnyReal, toolRoots } from '../paths.js'
8
8
  import { atomicWriteFile } from './atomic-write-file.js'
9
9
  import { clip, describeChange } from './classifier-input.js'
10
10
  import {
11
+ CURRENT_ON_DISK,
11
12
  fingerprintContent,
12
13
  staleFileError,
13
14
  unreadEditShownError,
@@ -408,16 +409,23 @@ function recordDrift(context: ToolContext, key: string): void {
408
409
 
409
410
  type EditAdmission =
410
411
  | { success: false; output: ''; error: string; facts: ToolFacts }
411
- | { success: true; result: ReturnType<typeof applyEdit> }
412
+ | { success: true; result: ReturnType<typeof applyEdit>; unreadNote?: string }
413
+
414
+ /** Appended to the result of an edit that was applied to a file the session had not read. */
415
+ const UNREAD_APPLIED_NOTE = '(file was not read before; the edit matched exactly and was applied)'
412
416
 
413
417
  /**
414
418
  * Decide whether this edit may run against the body now on disk, and apply it.
415
419
  *
416
420
  * Two rules, in this order:
417
421
  *
418
- * 1. A file the session never read is refused. The model is about to rewrite
419
- * text it has not seen, which is the commonest source of a wrong patch. A
420
- * host that supplies no tracker has no ledger to ask and is not refused.
422
+ * 1. A file the session never read is read here. When every replacement in the
423
+ * call matches the body exactly (once, or at least once under `replace_all`)
424
+ * the model plainly knew the text, from a shell print or a search, so the
425
+ * edit is applied and the read is credited. Otherwise (no match, an
426
+ * ambiguous match, an insertion, or a body that is not text) the edit is
427
+ * refused and, for a small file, the contents are handed back. A host that
428
+ * supplies no tracker has no ledger to ask and is not refused.
421
429
  * 2. A file that moved since the read is refused, whatever the operations are.
422
430
  * There is no recovery: a replacement that "still applies" to the moved body
423
431
  * can apply somewhere the model never meant (the read said `a = 1`, the file
@@ -434,6 +442,13 @@ function admitAgainstRead(
434
442
  ): EditAdmission {
435
443
  const tracker = context.fileReadTracker
436
444
  if (tracker && !tracker.hasRead(key)) {
445
+ if (!content.includes('\u0000') && operations.every((op) => op.operation === 'replace')) {
446
+ const applied = applyEdit(content, operations)
447
+ if (applied.success) {
448
+ tracker.recordRead(key, content)
449
+ return { success: true, result: applied, unreadNote: UNREAD_APPLIED_NOTE }
450
+ }
451
+ }
437
452
  // The file is already in hand, so a small one is shown and the read that
438
453
  // showing amounts to is credited: the repeat is one call and is admitted.
439
454
  const shown = unreadEditShownError(key, content)
@@ -495,6 +510,77 @@ function refusedEdit(result: EditApplyFailure, path: string) {
495
510
  }
496
511
  }
497
512
 
513
+ /**
514
+ * The refusals `execute` would give that need no person's answer, asked before
515
+ * a reviewer is: arguments that name no change, a file the session never read
516
+ * whose text the call does not match, a file that moved since the read, and
517
+ * replacements that do not apply. The text is the one `execute` gives, so the
518
+ * model sees the same words with or without a dialog. It says nothing when it
519
+ * cannot tell (an unreadable or missing file, a path outside the roots); those
520
+ * keep their own answers at run time.
521
+ */
522
+ async function refuseEditBeforeReview(
523
+ input: EditInput,
524
+ context: ToolContext,
525
+ ): Promise<{ readonly error: string; readonly facts?: ToolFacts } | undefined> {
526
+ const parsed = inputSchema.safeParse(input)
527
+ if (!parsed.success) return undefined
528
+ const normalized = normalizeEditInput(parsed.data)
529
+ if (!normalized.success) return { error: normalized.error }
530
+ const noOp = normalized.operations.findIndex(
531
+ (operation) => operation.operation === 'replace' && operation.oldString === operation.newString,
532
+ )
533
+ if (noOp >= 0) {
534
+ return {
535
+ error:
536
+ normalized.operations.length === 1
537
+ ? 'old_string/oldStr and new_string/newStr are identical — no change needed'
538
+ : `edits[${noOp}]: old_string and new_string are identical — no change needed. Nothing was written.`,
539
+ }
540
+ }
541
+ // In a sandbox only the moved-since-read check runs here, as before; the
542
+ // unread-file refusals are given when the call runs there, so a guest that is
543
+ // not admitted yet, or that holds a file the host has never seen, is not
544
+ // judged from a read made before anyone approved the call.
545
+ if (context.sandbox) return staleBeforeReview(context, parsed.data.path, 'edit')
546
+ let key: string
547
+ let content: string
548
+ try {
549
+ key = await resolveWithinAnyReal(toolRoots(context), parsed.data.path)
550
+ content = await readFile(key, 'utf-8')
551
+ } catch {
552
+ return undefined
553
+ }
554
+ const tracker = context.fileReadTracker
555
+ if (tracker && !tracker.hasRead(key)) {
556
+ // An unread file is edited when every replacement matches it exactly.
557
+ if (
558
+ !content.includes('\u0000') &&
559
+ normalized.operations.every((op) => op.operation === 'replace')
560
+ ) {
561
+ if (applyEdit(content, normalized.operations).success) return undefined
562
+ }
563
+ const shown = unreadEditShownError(key, content)
564
+ if (shown !== undefined) tracker.recordRead(key, content)
565
+ return {
566
+ error: shown ?? unreadEditTooLargeError(key),
567
+ facts: { kind: 'failure', reason: 'not_read', subject: key },
568
+ }
569
+ }
570
+ const stale = await staleBeforeReview(context, parsed.data.path, 'edit')
571
+ if (stale) return stale
572
+ const applied = applyEdit(content, normalized.operations)
573
+ if (!applied.success) {
574
+ return {
575
+ error: applied.error,
576
+ ...(applied.reason
577
+ ? { facts: { kind: 'failure' as const, reason: applied.reason, subject: key } }
578
+ : {}),
579
+ }
580
+ }
581
+ return undefined
582
+ }
583
+
498
584
  export const EditTool = defineTool({
499
585
  name: 'edit',
500
586
  description:
@@ -516,7 +602,7 @@ export const EditTool = defineTool({
516
602
  pathArgument: 'path',
517
603
  // A file that moved since the read is refused whatever the replacement is,
518
604
  // so the person is not asked to approve one that cannot run.
519
- refuseBeforeReview: (input: EditInput, context) => staleBeforeReview(context, input.path, 'edit'),
605
+ refuseBeforeReview: refuseEditBeforeReview,
520
606
  // The classifier judges which file changes and in what way, in a line.
521
607
  classifierInput: (input: EditInput) => {
522
608
  if (input.edits !== undefined && input.edits.length > 0) {
@@ -639,7 +725,7 @@ export const EditTool = defineTool({
639
725
  const changed = editFacts(parsed.data.path, result.replacements, content, result.content)
640
726
  return {
641
727
  success: true as const,
642
- output: `Edited ${parsed.data.path}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed}) [sandboxed]`,
728
+ output: `Edited ${parsed.data.path}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed}) [sandboxed]${admitted.unreadNote ? ` ${admitted.unreadNote}` : ''}. ${CURRENT_ON_DISK}`,
643
729
  data: {
644
730
  path: parsed.data.path,
645
731
  replacements: result.replacements,
@@ -670,7 +756,7 @@ export const EditTool = defineTool({
670
756
  const changed = editFacts(hostPath, result.replacements, content, result.content)
671
757
  return {
672
758
  success: true as const,
673
- output: `Edited ${hostPath}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed})`,
759
+ output: `Edited ${hostPath}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed})${admitted.unreadNote ? ` ${admitted.unreadNote}` : ''}. ${CURRENT_ON_DISK}`,
674
760
  data: { path: hostPath, replacements: result.replacements },
675
761
  facts: changed.facts,
676
762
  }
@@ -1,5 +1,6 @@
1
1
  import { createHash } from 'node:crypto'
2
2
  import type { ToolDiffHunk, ToolResult } from '../../types/tool/index.js'
3
+ import { CURRENT_ON_DISK } from './content-fingerprint.js'
3
4
  import { lineDiff } from './line-diff.js'
4
5
 
5
6
  /** One side of a change, context included: the rows that exist before (`-`) or after (`+`). */
@@ -44,7 +45,7 @@ export function fileWriteResult(
44
45
  const summary = `${label} ${path}${before === null ? '' : ` (+${diff.added} -${diff.removed})`}${newlineChanged ? ' · final newline changed' : ''}`
45
46
  return {
46
47
  success: true,
47
- output: `${summary} · ${bytes} bytes`,
48
+ output: `${summary} · ${bytes} bytes. ${CURRENT_ON_DISK}`,
48
49
  facts: {
49
50
  kind: 'write',
50
51
  path,
@@ -382,7 +382,7 @@ export const GrepTool = defineTool({
382
382
  return {
383
383
  success: false,
384
384
  output: '',
385
- error: `Invalid regex pattern: ${err instanceof Error ? err.message : String(err)}`,
385
+ error: `Invalid regex pattern: ${err instanceof Error ? err.message : String(err)}. Patterns are JavaScript regular expressions with no inline flags such as (?i); for a case-insensitive search set \`case_sensitive: false\`.`,
386
386
  }
387
387
  }
388
388
 
@@ -83,7 +83,7 @@ export const JobTool = defineTool({
83
83
  if (all.length === 0) return { success: true, output: 'No background jobs.' }
84
84
  const now = Date.now()
85
85
  const lines = all.map((job) => {
86
- const label = job.kind === 'monitor' ? (job.description ?? job.command) : job.command
86
+ const label = job.description ?? job.command
87
87
  if (job.startedAt === undefined) {
88
88
  return `${job.id} ${job.status.padEnd(8)} ${job.kind === 'monitor' ? `monitor · ${label}` : label}`
89
89
  }
@@ -160,14 +160,16 @@ export const JobTool = defineTool({
160
160
  ? `failed to start: ${read.error}`
161
161
  : `${read.status}${read.exitCode === undefined ? '' : ` with code ${read.exitCode}`}`
162
162
 
163
+ const outputFile = jobs.get(input.id)?.outputFile
163
164
  return {
164
165
  success: true,
165
- output: `${notice}${read.chunk || '(no new output)'}\n\n[job ${input.id} is ${status}; next_offset ${read.nextOffset}]`,
166
+ output: `${notice}${read.chunk || '(no new output)'}\n\n[job ${input.id} is ${status}; next_offset ${read.nextOffset}${outputFile === undefined ? '' : `; the whole output is in ${outputFile}`}]`,
166
167
  data: {
167
168
  jobId: input.id,
168
169
  status: read.status,
169
170
  nextOffset: read.nextOffset,
170
171
  droppedBytes: read.droppedBytes,
172
+ ...(outputFile === undefined ? {} : { outputFile }),
171
173
  ...(read.exitCode === undefined ? {} : { exitCode: read.exitCode }),
172
174
  ...(read.error === undefined ? {} : { error: read.error }),
173
175
  },
@@ -349,7 +349,12 @@ export function createMonitorTool(options: MonitorToolOptions = {}) {
349
349
  success: true,
350
350
  output: `Monitor started (job ${job.id}, expires in ${formatMonitorDuration(timeoutMs)} unless the command ends first; you get one notice at expiry — start it again if you still need the watch). Each line the command prints to stdout reaches you as an event while you keep working; do not poll or sleep. Stop it with job {"action":"kill","id":"${job.id}"}. An event may arrive while you are waiting for the user — it is not their reply.`,
351
351
  data: { jobId: job.id, monitor: true, timeoutMs },
352
- facts: { kind: 'command', command: input.command as string, background: true },
352
+ facts: {
353
+ kind: 'command',
354
+ command: input.command as string,
355
+ background: true,
356
+ jobId: job.id,
357
+ },
353
358
  }
354
359
  } catch (err) {
355
360
  // The per-owner cap, most likely; naming the limit is actionable.
@@ -1,16 +1,35 @@
1
1
  import { z } from 'zod'
2
2
  import { toolDiscoveryHint } from '../../registry/tool/execute.js'
3
+ import type { ToolDefinition } from '../../types/tool/index.js'
3
4
  import { defineTool } from '../defineTool.js'
4
5
 
6
+ /** The most names one `select:` list loads. */
7
+ export const MAX_SELECT_NAMES = 64
8
+
9
+ /**
10
+ * Results a search loads when `max_results` is not given. Top-5 is the
11
+ * literature's sweet spot (retrieval at k=5 matches oracle toolsets) and
12
+ * bounds how much schema weight a single search can add to every later
13
+ * iteration; each activation also busts the prompt-cache prefix once.
14
+ */
15
+ export const DEFAULT_MAX_RESULTS = 5
16
+
5
17
  const inputSchema = z.object({
6
- query: z.string().describe('Tool name or capability keyword to search for'),
18
+ query: z
19
+ .string()
20
+ .describe(
21
+ '"select:name1,name2" to load exactly those tools by name, or keywords to search, or "+term" words that every result must contain',
22
+ ),
23
+ max_results: z
24
+ .number()
25
+ .int()
26
+ .min(1)
27
+ .max(MAX_SELECT_NAMES)
28
+ .optional()
29
+ .describe(`Most tools a keyword search loads (default ${DEFAULT_MAX_RESULTS})`),
7
30
  })
8
31
 
9
- // Activate only the best-ranked matches. Top-5 is the literature's sweet
10
- // spot (retrieval at k=5 matches oracle toolsets) and bounds how much
11
- // schema weight a single search can add to every subsequent iteration —
12
- // each activation also busts the prompt-cache prefix once.
13
- const ACTIVATION_TOP_K = 5
32
+ const SELECT_PREFIX = /^select:(.*)$/is
14
33
 
15
34
  // Near-misses are reported name+hint WITHOUT activating, so a retrieval
16
35
  // miss becomes one cheap re-query instead of a dead end (the fixed-top-k
@@ -20,8 +39,13 @@ const NEAR_MISS_LIMIT = 5
20
39
  export const SearchToolsTool = defineTool({
21
40
  name: 'search_tools',
22
41
  description:
23
- 'Search and load available tools by name or capability. ' +
24
- 'Use this only when a needed deferred tool schema is absent from the current runtime tools parameter. If its schema is already visible, call the tool directly without searching again.',
42
+ 'Load deferred tools so they can be called. ' +
43
+ 'Use this only when a needed deferred tool schema is absent from the current runtime tools parameter. If its schema is already visible, call the tool directly without searching again.\n\n' +
44
+ 'Query forms:\n' +
45
+ '- "select:read_memory,save_memory" loads exactly those tools by name. Use it when you know the names.\n' +
46
+ '- "notebook jupyter" searches by keywords. A word in a tool\'s name ranks far above a word in its description. Loads the best matches, up to max_results (default 5).\n' +
47
+ '- "+slack send" requires "slack" in the result and ranks by the rest.\n' +
48
+ "A query that is exactly one tool's name loads that tool and no other match, plus any companions it declares.",
25
49
  inputSchema,
26
50
  category: 'analysis',
27
51
  permissions: [],
@@ -37,26 +61,135 @@ export const SearchToolsTool = defineTool({
37
61
  error: 'Tool registry not available in this context.',
38
62
  }
39
63
  }
40
-
64
+ const registry = context.toolRegistry
41
65
  const allowed = context.allowedTools !== undefined ? new Set(context.allowedTools) : null
66
+ const permitted = (name: string) => !allowed || allowed.has(name)
67
+
68
+ const select = SELECT_PREFIX.exec(input.query.trim())
69
+ if (select) {
70
+ const requested = (select[1] ?? '')
71
+ .split(',')
72
+ .map((name) => name.trim())
73
+ .filter((name) => name.length > 0)
74
+ const names = requested.slice(0, MAX_SELECT_NAMES)
75
+ const dropped = requested.slice(MAX_SELECT_NAMES)
76
+ const picked = registry.select
77
+ ? registry.select(names)
78
+ : selectByName(registry.searchDeferred.bind(registry), registry.has.bind(registry), names)
79
+ const found = picked.found.filter((tool) => permitted(tool.name))
80
+ const refused = picked.found.filter((tool) => !permitted(tool.name)).map((tool) => tool.name)
81
+ const sections: string[] = []
82
+ if (found.length > 0) sections.push(describeLoaded(found, new Map()))
83
+ const companions = found.flatMap((tool) =>
84
+ (tool.loadsWith ?? []).filter(
85
+ (name) => !found.some((other) => other.name === name) && permitted(name),
86
+ ),
87
+ )
88
+ if (companions.length > 0) {
89
+ sections.push(
90
+ `Related tools that are not loaded: ${[...new Set(companions)].join(', ')}. Select them too if you need them.`,
91
+ )
92
+ }
93
+ // A short MCP name that matched several tools loads all of them; say so,
94
+ // so the model is not surprised by tools it did not name in full.
95
+ const ambiguous = names.flatMap((name) => {
96
+ const suffix = `__${name.toLowerCase()}`
97
+ const hits = found.filter(
98
+ (tool) =>
99
+ tool.name.toLowerCase() !== name.toLowerCase() &&
100
+ tool.name.toLowerCase().endsWith(suffix),
101
+ )
102
+ return hits.length > 1 ? [`${name} (${hits.map((tool) => tool.name).join(', ')})`] : []
103
+ })
104
+ if (ambiguous.length > 0) {
105
+ sections.push(
106
+ `A short name matched more than one tool, and all of them are loaded: ${ambiguous.join('; ')}. Use the full name to load one.`,
107
+ )
108
+ }
109
+ if (dropped.length > 0) {
110
+ sections.push(
111
+ `Not loaded, because one select takes at most ${MAX_SELECT_NAMES} names: ${dropped.join(', ')}. Select them in another call.`,
112
+ )
113
+ }
114
+ if (picked.available.length > 0) {
115
+ sections.push(`Already loaded, call directly: ${picked.available.join(', ')}.`)
116
+ }
117
+ const missing = [...picked.missing, ...refused]
118
+ if (missing.length > 0) {
119
+ sections.push(
120
+ `No tool named: ${missing.join(', ')}. A name must be exact; search by keywords to find it.`,
121
+ )
122
+ }
123
+ if (sections.length === 0) {
124
+ return { success: true, output: 'No tool names given after "select:".' }
125
+ }
126
+ return {
127
+ success: true,
128
+ output: sections.join('\n\n'),
129
+ reveals: found.map((tool) => tool.name),
130
+ data: {
131
+ activated: found.map((tool) => tool.name),
132
+ count: found.length,
133
+ ...(picked.available.length > 0 ? { alreadyLoaded: picked.available } : {}),
134
+ ...(missing.length > 0 ? { missing } : {}),
135
+ ...(dropped.length > 0 ? { notSelected: dropped } : {}),
136
+ },
137
+ }
138
+ }
139
+
140
+ const limit = input.max_results ?? DEFAULT_MAX_RESULTS
42
141
  // `searchDeferred` returns a ranked list (score-descending), so slicing
43
142
  // the head is a true top-k reveal, not an arbitrary subset.
44
- const ranked = context.toolRegistry
45
- .searchDeferred(input.query)
46
- .filter((tool) => !allowed || allowed.has(tool.name))
143
+ const ranked = registry.searchDeferred(input.query).filter((tool) => permitted(tool.name))
47
144
 
48
145
  if (ranked.length === 0) {
146
+ // One sentence for three different states read as "this tool does not exist", and a model
147
+ // that had just used the tool went looking for its own words on disk. Say which state it is.
148
+ const asked = input.query.trim()
149
+ if (registry.has(asked)) {
150
+ if (!permitted(asked)) {
151
+ return {
152
+ success: true,
153
+ output: `${asked} is not available in this session. Carry on without it.`,
154
+ }
155
+ }
156
+ if (registry.availability(asked) === 'active') {
157
+ return { success: true, output: `${asked} is already loaded: call it directly.` }
158
+ }
159
+ }
49
160
  return {
50
161
  success: true,
51
- output: `No deferred tools matching "${input.query}".`,
162
+ output: `No deferred tools matching "${input.query}". A tool whose schema you can already see is loaded: call it directly. Only names listed under deferred_tools can be loaded; a tool that is not listed there does not exist in this session, so carry on without it.`,
52
163
  }
53
164
  }
54
165
 
55
- const activated = ranked.slice(0, ACTIVATION_TOP_K)
56
- const nearMisses = ranked.slice(ACTIVATION_TOP_K, ACTIVATION_TOP_K + NEAR_MISS_LIMIT)
166
+ const activated = ranked.slice(0, limit)
167
+ const nearMisses = ranked.slice(limit, limit + NEAR_MISS_LIMIT)
57
168
 
58
- const descriptions = activated.map((t) => `- ${t.name}: ${t.description}`).join('\n')
59
- const sections = [`Activated ${activated.length} tool(s):\n${descriptions}`]
169
+ // A tool may declare companions that are needed right after it. They
170
+ // load in this same call, from the deferred roster and inside the same
171
+ // allow-list, so the model does not pay a second search for them.
172
+ // Names already activated or already loaded are skipped; one level only.
173
+ const activatedNames = new Set(activated.map((t) => t.name))
174
+ const companions: ToolDefinition[] = []
175
+ for (const tool of activated) {
176
+ for (const name of tool.loadsWith ?? []) {
177
+ if (activatedNames.has(name)) continue
178
+ const companion = registry
179
+ .searchDeferred(name)
180
+ .find((candidate) => candidate.name === name && permitted(name))
181
+ if (!companion) continue
182
+ activatedNames.add(name)
183
+ companions.push(companion)
184
+ }
185
+ }
186
+ const loaded = [...activated, ...companions]
187
+ const companionOf = new Map<string, string>()
188
+ for (const tool of activated) {
189
+ for (const name of tool.loadsWith ?? []) companionOf.set(name, tool.name)
190
+ }
191
+
192
+ const sections = [describeLoaded(loaded, companionOf, companions)]
60
193
 
61
194
  if (nearMisses.length > 0) {
62
195
  const hints = nearMisses
@@ -66,7 +199,7 @@ export const SearchToolsTool = defineTool({
66
199
  })
67
200
  .join('\n')
68
201
  sections.push(
69
- `Also matched but NOT loaded (search again with a more specific query, e.g. the tool name, to load one of these):\n${hints}`,
202
+ `Also matched but NOT loaded (select one by exact name, "select:<name>", or raise max_results):\n${hints}`,
70
203
  )
71
204
  }
72
205
 
@@ -77,12 +210,54 @@ export const SearchToolsTool = defineTool({
77
210
  // tool message REVEALS (`ToolResult.reveals`, persisted as
78
211
  // `ToolMessage.revealedTools`), not from a mutation made here. See
79
212
  // `toolsets/manager.ts`'s `availability()`.
80
- reveals: activated.map((t) => t.name),
213
+ reveals: loaded.map((t) => t.name),
81
214
  data: {
82
- activated: activated.map((t) => t.name),
83
- count: activated.length,
215
+ activated: loaded.map((t) => t.name),
216
+ count: loaded.length,
84
217
  nearMisses: nearMisses.map((t) => t.name),
218
+ ...(companions.length > 0 ? { companions: companions.map((t) => t.name) } : {}),
85
219
  },
86
220
  }
87
221
  },
88
222
  })
223
+
224
+ function describeLoaded(
225
+ loaded: readonly ToolDefinition[],
226
+ companionOf: ReadonlyMap<string, string>,
227
+ companions: readonly ToolDefinition[] = [],
228
+ ): string {
229
+ const lines = loaded
230
+ .map((t) => {
231
+ const owner = companionOf.get(t.name)
232
+ const note = companions.includes(t) && owner ? ` (loaded with ${owner})` : ''
233
+ return `- ${t.name}${note}: ${t.description}`
234
+ })
235
+ .join('\n')
236
+ return `Activated ${loaded.length} tool(s):\n${lines}`
237
+ }
238
+
239
+ /**
240
+ * `select:` against a view that has no `select` of its own: an exact-name
241
+ * match over the deferred search. Only full names match here; the MCP
242
+ * short-name form needs the manager's own `select`.
243
+ */
244
+ function selectByName(
245
+ search: (query: string) => readonly ToolDefinition[],
246
+ has: (name: string) => boolean,
247
+ names: readonly string[],
248
+ ): {
249
+ readonly found: readonly ToolDefinition[]
250
+ readonly available: readonly string[]
251
+ readonly missing: readonly string[]
252
+ } {
253
+ const found: ToolDefinition[] = []
254
+ const available: string[] = []
255
+ const missing: string[] = []
256
+ for (const name of names) {
257
+ const hit = search(name).find((tool) => tool.name.toLowerCase() === name.toLowerCase())
258
+ if (hit) found.push(hit)
259
+ else if (has(name)) available.push(name)
260
+ else missing.push(name)
261
+ }
262
+ return { found, available, missing }
263
+ }