@namzu/sdk 68.0.1 → 69.1.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 (492) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/dist/agents/QueryAgent.d.ts.map +1 -1
  3. package/dist/agents/QueryAgent.js +2 -0
  4. package/dist/agents/QueryAgent.js.map +1 -1
  5. package/dist/authorization/skill-grant.d.ts.map +1 -1
  6. package/dist/authorization/skill-grant.js +1 -0
  7. package/dist/authorization/skill-grant.js.map +1 -1
  8. package/dist/bridge/acp/permission.d.ts +10 -0
  9. package/dist/bridge/acp/permission.d.ts.map +1 -1
  10. package/dist/bridge/acp/permission.js.map +1 -1
  11. package/dist/bridge/acp/server.d.ts +12 -0
  12. package/dist/bridge/acp/server.d.ts.map +1 -1
  13. package/dist/bridge/acp/server.js +21 -0
  14. package/dist/bridge/acp/server.js.map +1 -1
  15. package/dist/compaction/context-window.d.ts +8 -0
  16. package/dist/compaction/context-window.d.ts.map +1 -1
  17. package/dist/compaction/context-window.js +14 -0
  18. package/dist/compaction/context-window.js.map +1 -1
  19. package/dist/compaction/loaded-skills.d.ts +10 -0
  20. package/dist/compaction/loaded-skills.d.ts.map +1 -1
  21. package/dist/compaction/loaded-skills.js +45 -1
  22. package/dist/compaction/loaded-skills.js.map +1 -1
  23. package/dist/compaction/manager.d.ts +8 -0
  24. package/dist/compaction/manager.d.ts.map +1 -1
  25. package/dist/compaction/manager.js +31 -0
  26. package/dist/compaction/manager.js.map +1 -1
  27. package/dist/compaction/manual.d.ts.map +1 -1
  28. package/dist/compaction/manual.js +7 -1
  29. package/dist/compaction/manual.js.map +1 -1
  30. package/dist/compaction/model-summary.js +2 -2
  31. package/dist/compaction/model-summary.js.map +1 -1
  32. package/dist/compaction/restore.d.ts +8 -0
  33. package/dist/compaction/restore.d.ts.map +1 -1
  34. package/dist/compaction/restore.js +65 -0
  35. package/dist/compaction/restore.js.map +1 -1
  36. package/dist/compaction/salience/working-set.d.ts.map +1 -1
  37. package/dist/compaction/salience/working-set.js +2 -2
  38. package/dist/compaction/salience/working-set.js.map +1 -1
  39. package/dist/compaction/tool-result-editing.d.ts +6 -0
  40. package/dist/compaction/tool-result-editing.d.ts.map +1 -1
  41. package/dist/compaction/tool-result-editing.js +7 -1
  42. package/dist/compaction/tool-result-editing.js.map +1 -1
  43. package/dist/compaction/types.d.ts +2 -0
  44. package/dist/compaction/types.d.ts.map +1 -1
  45. package/dist/compaction/wire.d.ts.map +1 -1
  46. package/dist/compaction/wire.js +4 -0
  47. package/dist/compaction/wire.js.map +1 -1
  48. package/dist/connector/index.d.ts +2 -2
  49. package/dist/connector/index.d.ts.map +1 -1
  50. package/dist/connector/index.js +1 -1
  51. package/dist/connector/index.js.map +1 -1
  52. package/dist/connector/mcp/client.d.ts +29 -0
  53. package/dist/connector/mcp/client.d.ts.map +1 -1
  54. package/dist/connector/mcp/client.js +59 -2
  55. package/dist/connector/mcp/client.js.map +1 -1
  56. package/dist/connector/mcp/errors.d.ts +7 -0
  57. package/dist/connector/mcp/errors.d.ts.map +1 -1
  58. package/dist/connector/mcp/errors.js +14 -0
  59. package/dist/connector/mcp/errors.js.map +1 -1
  60. package/dist/connector/mcp/index.d.ts +5 -1
  61. package/dist/connector/mcp/index.d.ts.map +1 -1
  62. package/dist/connector/mcp/index.js +3 -1
  63. package/dist/connector/mcp/index.js.map +1 -1
  64. package/dist/connector/mcp/skill-source.d.ts +144 -0
  65. package/dist/connector/mcp/skill-source.d.ts.map +1 -0
  66. package/dist/connector/mcp/skill-source.js +375 -0
  67. package/dist/connector/mcp/skill-source.js.map +1 -0
  68. package/dist/connector/mcp/skills.d.ts +137 -0
  69. package/dist/connector/mcp/skills.d.ts.map +1 -0
  70. package/dist/connector/mcp/skills.js +303 -0
  71. package/dist/connector/mcp/skills.js.map +1 -0
  72. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  73. package/dist/manager/session/turn-recorder.js +23 -1
  74. package/dist/manager/session/turn-recorder.js.map +1 -1
  75. package/dist/network/audit.d.ts +1 -1
  76. package/dist/network/audit.d.ts.map +1 -1
  77. package/dist/network/audit.js +2 -0
  78. package/dist/network/audit.js.map +1 -1
  79. package/dist/network/computer.d.ts +107 -0
  80. package/dist/network/computer.d.ts.map +1 -0
  81. package/dist/network/computer.js +250 -0
  82. package/dist/network/computer.js.map +1 -0
  83. package/dist/network/index.d.ts +2 -0
  84. package/dist/network/index.d.ts.map +1 -1
  85. package/dist/network/index.js +1 -0
  86. package/dist/network/index.js.map +1 -1
  87. package/dist/network/join.d.ts +13 -1
  88. package/dist/network/join.d.ts.map +1 -1
  89. package/dist/network/join.js +21 -3
  90. package/dist/network/join.js.map +1 -1
  91. package/dist/network/roster.d.ts +5 -0
  92. package/dist/network/roster.d.ts.map +1 -1
  93. package/dist/network/roster.js.map +1 -1
  94. package/dist/network/service.d.ts +12 -2
  95. package/dist/network/service.d.ts.map +1 -1
  96. package/dist/network/service.js +539 -60
  97. package/dist/network/service.js.map +1 -1
  98. package/dist/network/store.d.ts +33 -1
  99. package/dist/network/store.d.ts.map +1 -1
  100. package/dist/network/store.js +48 -4
  101. package/dist/network/store.js.map +1 -1
  102. package/dist/network/transport.d.ts +1 -1
  103. package/dist/network/transport.js +1 -1
  104. package/dist/network/wire.d.ts +14 -0
  105. package/dist/network/wire.d.ts.map +1 -1
  106. package/dist/network/wire.js +17 -1
  107. package/dist/network/wire.js.map +1 -1
  108. package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -1
  109. package/dist/plugin/shell-hook-tool-names.js +1 -0
  110. package/dist/plugin/shell-hook-tool-names.js.map +1 -1
  111. package/dist/plugin/shell-hook.d.ts +8 -3
  112. package/dist/plugin/shell-hook.d.ts.map +1 -1
  113. package/dist/plugin/shell-hook.js +132 -7
  114. package/dist/plugin/shell-hook.js.map +1 -1
  115. package/dist/prompt/coding-agent-doctrine.d.ts +4 -4
  116. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  117. package/dist/prompt/coding-agent-doctrine.js +7 -2
  118. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  119. package/dist/provider/fallback.d.ts.map +1 -1
  120. package/dist/provider/fallback.js +9 -0
  121. package/dist/provider/fallback.js.map +1 -1
  122. package/dist/provider/idle-timeout.d.ts.map +1 -1
  123. package/dist/provider/idle-timeout.js +8 -0
  124. package/dist/provider/idle-timeout.js.map +1 -1
  125. package/dist/provider/instrumentation.d.ts.map +1 -1
  126. package/dist/provider/instrumentation.js +10 -0
  127. package/dist/provider/instrumentation.js.map +1 -1
  128. package/dist/provider/model-window-suffix.d.ts.map +1 -1
  129. package/dist/provider/model-window-suffix.js +2 -0
  130. package/dist/provider/model-window-suffix.js.map +1 -1
  131. package/dist/provider/retry.d.ts.map +1 -1
  132. package/dist/provider/retry.js +8 -0
  133. package/dist/provider/retry.js.map +1 -1
  134. package/dist/public-runtime.d.ts +10 -7
  135. package/dist/public-runtime.d.ts.map +1 -1
  136. package/dist/public-runtime.js +12 -5
  137. package/dist/public-runtime.js.map +1 -1
  138. package/dist/public-tools.d.ts +7 -4
  139. package/dist/public-tools.d.ts.map +1 -1
  140. package/dist/public-tools.js +9 -3
  141. package/dist/public-tools.js.map +1 -1
  142. package/dist/public-types.d.ts +4 -1
  143. package/dist/public-types.d.ts.map +1 -1
  144. package/dist/registry/tool/presentation.d.ts +8 -1
  145. package/dist/registry/tool/presentation.d.ts.map +1 -1
  146. package/dist/registry/tool/presentation.js +14 -5
  147. package/dist/registry/tool/presentation.js.map +1 -1
  148. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  149. package/dist/runtime/jobs/registry.js +2 -1
  150. package/dist/runtime/jobs/registry.js.map +1 -1
  151. package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
  152. package/dist/runtime/query/auto-review/classifier.js +19 -3
  153. package/dist/runtime/query/auto-review/classifier.js.map +1 -1
  154. package/dist/runtime/query/auto-review/failure.d.ts +12 -0
  155. package/dist/runtime/query/auto-review/failure.d.ts.map +1 -0
  156. package/dist/runtime/query/auto-review/failure.js +46 -0
  157. package/dist/runtime/query/auto-review/failure.js.map +1 -0
  158. package/dist/runtime/query/auto-review/index.d.ts +1 -0
  159. package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
  160. package/dist/runtime/query/auto-review/index.js +1 -0
  161. package/dist/runtime/query/auto-review/index.js.map +1 -1
  162. package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
  163. package/dist/runtime/query/executor/tool-call-admission.js +10 -1
  164. package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
  165. package/dist/runtime/query/executor.d.ts +12 -0
  166. package/dist/runtime/query/executor.d.ts.map +1 -1
  167. package/dist/runtime/query/executor.js +43 -9
  168. package/dist/runtime/query/executor.js.map +1 -1
  169. package/dist/runtime/query/file-evidence-replay.d.ts.map +1 -1
  170. package/dist/runtime/query/file-evidence-replay.js +6 -6
  171. package/dist/runtime/query/file-evidence-replay.js.map +1 -1
  172. package/dist/runtime/query/index.d.ts +4 -0
  173. package/dist/runtime/query/index.d.ts.map +1 -1
  174. package/dist/runtime/query/index.js +40 -1
  175. package/dist/runtime/query/index.js.map +1 -1
  176. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  177. package/dist/runtime/query/iteration/index.js +2 -0
  178. package/dist/runtime/query/iteration/index.js.map +1 -1
  179. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  180. package/dist/runtime/query/iteration/phases/compaction.js +21 -3
  181. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  182. package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
  183. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  184. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  185. package/dist/runtime/query/iteration/phases/per-call-review.d.ts +6 -2
  186. package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
  187. package/dist/runtime/query/iteration/phases/per-call-review.js +24 -9
  188. package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
  189. package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
  190. package/dist/runtime/query/iteration/step-shaping.js +4 -0
  191. package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
  192. package/dist/runtime/query/prepare-turn.d.ts +5 -1
  193. package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
  194. package/dist/runtime/query/prepare-turn.js +13 -3
  195. package/dist/runtime/query/prepare-turn.js.map +1 -1
  196. package/dist/runtime/query/review-policy.d.ts +15 -4
  197. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  198. package/dist/runtime/query/review-policy.js +15 -4
  199. package/dist/runtime/query/review-policy.js.map +1 -1
  200. package/dist/runtime/query/shell-line-escalation.d.ts +24 -0
  201. package/dist/runtime/query/shell-line-escalation.d.ts.map +1 -0
  202. package/dist/runtime/query/shell-line-escalation.js +38 -0
  203. package/dist/runtime/query/shell-line-escalation.js.map +1 -0
  204. package/dist/runtime/query/tooling.d.ts +7 -0
  205. package/dist/runtime/query/tooling.d.ts.map +1 -1
  206. package/dist/runtime/query/tooling.js +2 -0
  207. package/dist/runtime/query/tooling.js.map +1 -1
  208. package/dist/runtime/query/turn/outcome-ledger.d.ts +4 -0
  209. package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
  210. package/dist/runtime/query/turn/outcome-ledger.js +47 -1
  211. package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
  212. package/dist/sandbox/provider/local.d.ts.map +1 -1
  213. package/dist/sandbox/provider/local.js +3 -1
  214. package/dist/sandbox/provider/local.js.map +1 -1
  215. package/dist/scheduler/local.d.ts.map +1 -1
  216. package/dist/scheduler/local.js +3 -1
  217. package/dist/scheduler/local.js.map +1 -1
  218. package/dist/skills/index.d.ts +4 -0
  219. package/dist/skills/index.d.ts.map +1 -1
  220. package/dist/skills/index.js +2 -0
  221. package/dist/skills/index.js.map +1 -1
  222. package/dist/skills/inline-shell-host.d.ts +103 -0
  223. package/dist/skills/inline-shell-host.d.ts.map +1 -0
  224. package/dist/skills/inline-shell-host.js +238 -0
  225. package/dist/skills/inline-shell-host.js.map +1 -0
  226. package/dist/skills/inline-shell.d.ts +176 -0
  227. package/dist/skills/inline-shell.d.ts.map +1 -0
  228. package/dist/skills/inline-shell.js +646 -0
  229. package/dist/skills/inline-shell.js.map +1 -0
  230. package/dist/store/index.d.ts +2 -0
  231. package/dist/store/index.d.ts.map +1 -1
  232. package/dist/store/index.js +1 -0
  233. package/dist/store/index.js.map +1 -1
  234. package/dist/store/task/file.d.ts +124 -0
  235. package/dist/store/task/file.d.ts.map +1 -0
  236. package/dist/store/task/file.js +498 -0
  237. package/dist/store/task/file.js.map +1 -0
  238. package/dist/teams/backend.d.ts +28 -0
  239. package/dist/teams/backend.d.ts.map +1 -0
  240. package/dist/teams/backend.js +2 -0
  241. package/dist/teams/backend.js.map +1 -0
  242. package/dist/teams/fs-sync.d.ts +19 -0
  243. package/dist/teams/fs-sync.d.ts.map +1 -0
  244. package/dist/teams/fs-sync.js +81 -0
  245. package/dist/teams/fs-sync.js.map +1 -0
  246. package/dist/teams/index.d.ts +14 -0
  247. package/dist/teams/index.d.ts.map +1 -0
  248. package/dist/teams/index.js +11 -0
  249. package/dist/teams/index.js.map +1 -0
  250. package/dist/teams/names.d.ts +15 -0
  251. package/dist/teams/names.d.ts.map +1 -0
  252. package/dist/teams/names.js +43 -0
  253. package/dist/teams/names.js.map +1 -0
  254. package/dist/teams/store.d.ts +133 -0
  255. package/dist/teams/store.d.ts.map +1 -0
  256. package/dist/teams/store.js +536 -0
  257. package/dist/teams/store.js.map +1 -0
  258. package/dist/teams/types.d.ts +97 -0
  259. package/dist/teams/types.d.ts.map +1 -0
  260. package/dist/teams/types.js +70 -0
  261. package/dist/teams/types.js.map +1 -0
  262. package/dist/tools/admit-facts.d.ts.map +1 -1
  263. package/dist/tools/admit-facts.js +28 -0
  264. package/dist/tools/admit-facts.js.map +1 -1
  265. package/dist/tools/builtins/bash.d.ts.map +1 -1
  266. package/dist/tools/builtins/bash.js +5 -2
  267. package/dist/tools/builtins/bash.js.map +1 -1
  268. package/dist/tools/builtins/browser.js +1 -1
  269. package/dist/tools/builtins/browser.js.map +1 -1
  270. package/dist/tools/builtins/computer-use.d.ts +60 -2
  271. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  272. package/dist/tools/builtins/computer-use.js +695 -80
  273. package/dist/tools/builtins/computer-use.js.map +1 -1
  274. package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
  275. package/dist/tools/builtins/content-fingerprint.js +2 -1
  276. package/dist/tools/builtins/content-fingerprint.js.map +1 -1
  277. package/dist/tools/builtins/edit-apply.d.ts +1 -0
  278. package/dist/tools/builtins/edit-apply.d.ts.map +1 -1
  279. package/dist/tools/builtins/edit-apply.js +108 -21
  280. package/dist/tools/builtins/edit-apply.js.map +1 -1
  281. package/dist/tools/builtins/edit-match.d.ts +37 -0
  282. package/dist/tools/builtins/edit-match.d.ts.map +1 -1
  283. package/dist/tools/builtins/edit-match.js +193 -0
  284. package/dist/tools/builtins/edit-match.js.map +1 -1
  285. package/dist/tools/builtins/edit.d.ts.map +1 -1
  286. package/dist/tools/builtins/edit.js +14 -7
  287. package/dist/tools/builtins/edit.js.map +1 -1
  288. package/dist/tools/builtins/exit-semantics.d.ts +8 -0
  289. package/dist/tools/builtins/exit-semantics.d.ts.map +1 -1
  290. package/dist/tools/builtins/exit-semantics.js +19 -0
  291. package/dist/tools/builtins/exit-semantics.js.map +1 -1
  292. package/dist/tools/builtins/index.d.ts +3 -1
  293. package/dist/tools/builtins/index.d.ts.map +1 -1
  294. package/dist/tools/builtins/index.js +1 -0
  295. package/dist/tools/builtins/index.js.map +1 -1
  296. package/dist/tools/builtins/present-file.d.ts +24 -0
  297. package/dist/tools/builtins/present-file.d.ts.map +1 -0
  298. package/dist/tools/builtins/present-file.js +116 -0
  299. package/dist/tools/builtins/present-file.js.map +1 -0
  300. package/dist/tools/builtins/read-file.js +1 -1
  301. package/dist/tools/builtins/read-file.js.map +1 -1
  302. package/dist/tools/builtins/read-render.d.ts +12 -1
  303. package/dist/tools/builtins/read-render.d.ts.map +1 -1
  304. package/dist/tools/builtins/read-render.js +16 -3
  305. package/dist/tools/builtins/read-render.js.map +1 -1
  306. package/dist/tools/builtins/search-tools.d.ts +10 -0
  307. package/dist/tools/builtins/search-tools.d.ts.map +1 -1
  308. package/dist/tools/builtins/search-tools.js +36 -2
  309. package/dist/tools/builtins/search-tools.js.map +1 -1
  310. package/dist/tools/builtins/skill.d.ts +31 -0
  311. package/dist/tools/builtins/skill.d.ts.map +1 -1
  312. package/dist/tools/builtins/skill.js +232 -88
  313. package/dist/tools/builtins/skill.js.map +1 -1
  314. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  315. package/dist/tools/builtins/wait-for-job.js +5 -0
  316. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  317. package/dist/tools/builtins/web.d.ts.map +1 -1
  318. package/dist/tools/builtins/web.js +13 -2
  319. package/dist/tools/builtins/web.js.map +1 -1
  320. package/dist/tools/task/create.d.ts.map +1 -1
  321. package/dist/tools/task/create.js +13 -4
  322. package/dist/tools/task/create.js.map +1 -1
  323. package/dist/tools/task/get.d.ts +8 -0
  324. package/dist/tools/task/get.d.ts.map +1 -0
  325. package/dist/tools/task/get.js +51 -0
  326. package/dist/tools/task/get.js.map +1 -0
  327. package/dist/tools/task/index.d.ts +7 -0
  328. package/dist/tools/task/index.d.ts.map +1 -1
  329. package/dist/tools/task/index.js +10 -2
  330. package/dist/tools/task/index.js.map +1 -1
  331. package/dist/tools/task/list.d.ts.map +1 -1
  332. package/dist/tools/task/list.js +10 -2
  333. package/dist/tools/task/list.js.map +1 -1
  334. package/dist/tools/task/number.d.ts +13 -0
  335. package/dist/tools/task/number.d.ts.map +1 -0
  336. package/dist/tools/task/number.js +30 -0
  337. package/dist/tools/task/number.js.map +1 -0
  338. package/dist/tools/task/present.d.ts.map +1 -1
  339. package/dist/tools/task/present.js +17 -3
  340. package/dist/tools/task/present.js.map +1 -1
  341. package/dist/tools/task/update.d.ts +2 -1
  342. package/dist/tools/task/update.d.ts.map +1 -1
  343. package/dist/tools/task/update.js +87 -20
  344. package/dist/tools/task/update.js.map +1 -1
  345. package/dist/types/acp/index.d.ts +10 -0
  346. package/dist/types/acp/index.d.ts.map +1 -1
  347. package/dist/types/agent/base.d.ts +4 -0
  348. package/dist/types/agent/base.d.ts.map +1 -1
  349. package/dist/types/agent/scheduler.d.ts +9 -0
  350. package/dist/types/agent/scheduler.d.ts.map +1 -1
  351. package/dist/types/computer-use/index.d.ts +7 -0
  352. package/dist/types/computer-use/index.d.ts.map +1 -1
  353. package/dist/types/computer-use/index.js.map +1 -1
  354. package/dist/types/connector/mcp.d.ts +10 -0
  355. package/dist/types/connector/mcp.d.ts.map +1 -1
  356. package/dist/types/permission/index.d.ts +20 -0
  357. package/dist/types/permission/index.d.ts.map +1 -1
  358. package/dist/types/permission/index.js +25 -0
  359. package/dist/types/permission/index.js.map +1 -1
  360. package/dist/types/plugin/index.d.ts +47 -3
  361. package/dist/types/plugin/index.d.ts.map +1 -1
  362. package/dist/types/plugin/index.js +4 -0
  363. package/dist/types/plugin/index.js.map +1 -1
  364. package/dist/types/provider/chat.d.ts +8 -0
  365. package/dist/types/provider/chat.d.ts.map +1 -1
  366. package/dist/types/provider/interface.d.ts +16 -0
  367. package/dist/types/provider/interface.d.ts.map +1 -1
  368. package/dist/types/provider/model.d.ts +6 -0
  369. package/dist/types/provider/model.d.ts.map +1 -1
  370. package/dist/types/provider/stream.d.ts +2 -0
  371. package/dist/types/provider/stream.d.ts.map +1 -1
  372. package/dist/types/tool/index.d.ts +28 -2
  373. package/dist/types/tool/index.d.ts.map +1 -1
  374. package/dist/types/tool/index.js.map +1 -1
  375. package/dist/types/tool/presentation.d.ts +15 -0
  376. package/dist/types/tool/presentation.d.ts.map +1 -1
  377. package/dist/utils/node-on-path.d.ts +27 -0
  378. package/dist/utils/node-on-path.d.ts.map +1 -0
  379. package/dist/utils/node-on-path.js +70 -0
  380. package/dist/utils/node-on-path.js.map +1 -0
  381. package/package.json +1 -1
  382. package/src/agents/QueryAgent.ts +2 -0
  383. package/src/authorization/skill-grant.ts +1 -0
  384. package/src/bridge/acp/permission.ts +11 -1
  385. package/src/bridge/acp/server.ts +26 -0
  386. package/src/compaction/context-window.ts +18 -0
  387. package/src/compaction/loaded-skills.ts +42 -1
  388. package/src/compaction/manager.ts +28 -0
  389. package/src/compaction/manual.ts +9 -1
  390. package/src/compaction/model-summary.ts +2 -2
  391. package/src/compaction/restore.ts +69 -0
  392. package/src/compaction/salience/working-set.ts +6 -2
  393. package/src/compaction/tool-result-editing.ts +8 -1
  394. package/src/compaction/types.ts +2 -0
  395. package/src/compaction/wire.ts +4 -0
  396. package/src/connector/index.ts +27 -0
  397. package/src/connector/mcp/client.ts +71 -2
  398. package/src/connector/mcp/errors.ts +14 -0
  399. package/src/connector/mcp/index.ts +36 -0
  400. package/src/connector/mcp/skill-source.ts +499 -0
  401. package/src/connector/mcp/skills.ts +367 -0
  402. package/src/manager/session/turn-recorder.ts +24 -1
  403. package/src/network/audit.ts +2 -0
  404. package/src/network/computer.ts +347 -0
  405. package/src/network/index.ts +20 -0
  406. package/src/network/join.ts +21 -2
  407. package/src/network/roster.ts +5 -0
  408. package/src/network/service.ts +674 -84
  409. package/src/network/store.ts +57 -4
  410. package/src/network/transport.ts +1 -1
  411. package/src/network/wire.ts +18 -1
  412. package/src/plugin/shell-hook-tool-names.ts +1 -0
  413. package/src/plugin/shell-hook.ts +144 -7
  414. package/src/prompt/coding-agent-doctrine.ts +7 -2
  415. package/src/provider/fallback.ts +10 -0
  416. package/src/provider/idle-timeout.ts +9 -0
  417. package/src/provider/instrumentation.ts +12 -0
  418. package/src/provider/model-window-suffix.ts +2 -0
  419. package/src/provider/retry.ts +9 -0
  420. package/src/public-runtime.ts +100 -0
  421. package/src/public-tools.ts +18 -0
  422. package/src/public-types.ts +29 -0
  423. package/src/registry/tool/presentation.ts +14 -4
  424. package/src/runtime/jobs/registry.ts +2 -1
  425. package/src/runtime/query/auto-review/classifier.ts +19 -3
  426. package/src/runtime/query/auto-review/failure.ts +50 -0
  427. package/src/runtime/query/auto-review/index.ts +1 -0
  428. package/src/runtime/query/executor/tool-call-admission.ts +10 -1
  429. package/src/runtime/query/executor.ts +57 -8
  430. package/src/runtime/query/file-evidence-replay.ts +6 -5
  431. package/src/runtime/query/index.ts +62 -0
  432. package/src/runtime/query/iteration/index.ts +2 -0
  433. package/src/runtime/query/iteration/phases/compaction.ts +25 -2
  434. package/src/runtime/query/iteration/phases/context.ts +4 -0
  435. package/src/runtime/query/iteration/phases/per-call-review.ts +24 -7
  436. package/src/runtime/query/iteration/step-shaping.ts +4 -0
  437. package/src/runtime/query/prepare-turn.ts +20 -2
  438. package/src/runtime/query/review-policy.ts +31 -5
  439. package/src/runtime/query/shell-line-escalation.ts +49 -0
  440. package/src/runtime/query/tooling.ts +6 -0
  441. package/src/runtime/query/turn/outcome-ledger.ts +56 -1
  442. package/src/sandbox/provider/local.ts +3 -1
  443. package/src/scheduler/local.ts +3 -1
  444. package/src/skills/index.ts +43 -0
  445. package/src/skills/inline-shell-host.ts +303 -0
  446. package/src/skills/inline-shell.ts +765 -0
  447. package/src/store/index.ts +8 -0
  448. package/src/store/task/file.ts +641 -0
  449. package/src/teams/backend.ts +29 -0
  450. package/src/teams/fs-sync.ts +91 -0
  451. package/src/teams/index.ts +47 -0
  452. package/src/teams/names.ts +49 -0
  453. package/src/teams/store.ts +607 -0
  454. package/src/teams/types.ts +102 -0
  455. package/src/tools/admit-facts.ts +26 -0
  456. package/src/tools/builtins/bash.ts +5 -2
  457. package/src/tools/builtins/browser.ts +1 -1
  458. package/src/tools/builtins/computer-use.ts +799 -86
  459. package/src/tools/builtins/content-fingerprint.ts +2 -1
  460. package/src/tools/builtins/edit-apply.ts +124 -24
  461. package/src/tools/builtins/edit-match.ts +200 -0
  462. package/src/tools/builtins/edit.ts +16 -7
  463. package/src/tools/builtins/exit-semantics.ts +23 -0
  464. package/src/tools/builtins/index.ts +3 -0
  465. package/src/tools/builtins/present-file.ts +127 -0
  466. package/src/tools/builtins/read-file.ts +1 -1
  467. package/src/tools/builtins/read-render.ts +18 -3
  468. package/src/tools/builtins/search-tools.ts +36 -2
  469. package/src/tools/builtins/skill.ts +291 -95
  470. package/src/tools/builtins/wait-for-job.ts +5 -0
  471. package/src/tools/builtins/web.ts +15 -2
  472. package/src/tools/task/create.ts +13 -4
  473. package/src/tools/task/get.ts +53 -0
  474. package/src/tools/task/index.ts +14 -2
  475. package/src/tools/task/list.ts +10 -2
  476. package/src/tools/task/number.ts +32 -0
  477. package/src/tools/task/present.ts +18 -3
  478. package/src/tools/task/update.ts +94 -20
  479. package/src/types/acp/index.ts +11 -1
  480. package/src/types/agent/base.ts +6 -0
  481. package/src/types/agent/scheduler.ts +9 -0
  482. package/src/types/computer-use/index.ts +7 -0
  483. package/src/types/connector/mcp.ts +10 -0
  484. package/src/types/permission/index.ts +29 -0
  485. package/src/types/plugin/index.ts +95 -39
  486. package/src/types/provider/chat.ts +9 -0
  487. package/src/types/provider/interface.ts +18 -0
  488. package/src/types/provider/model.ts +6 -0
  489. package/src/types/provider/stream.ts +2 -0
  490. package/src/types/tool/index.ts +23 -2
  491. package/src/types/tool/presentation.ts +14 -0
  492. package/src/utils/node-on-path.ts +81 -0
@@ -835,6 +835,12 @@ export interface QueryParams {
835
835
 
836
836
  taskStore?: TaskStore
837
837
 
838
+ /** The member name the task tools claim under when `taskStore` is a list a team shares. */
839
+ taskMember?: string
840
+
841
+ /** The team a teammate belongs to; with `taskMember` it names the teammate on the task hooks. */
842
+ taskTeam?: string
843
+
838
844
  runtimeToolOverrides?: RuntimeToolOverrides
839
845
 
840
846
  runtimeContext?: AgentRuntimeContext
@@ -1173,7 +1179,9 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1173
1179
  resilientProvider,
1174
1180
  serving,
1175
1181
  providerContextWindow,
1182
+ providerAutoCompactLimit,
1176
1183
  modelContextWindows,
1184
+ modelAutoCompactLimits,
1177
1185
  approvalPolicy,
1178
1186
  eventTranslator,
1179
1187
  executeUserInterruptHooks,
@@ -1299,6 +1307,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1299
1307
  const taskTools = buildTaskTools(params.taskStore, {
1300
1308
  sessionId: ctx.sessionId,
1301
1309
  turnId: ctx.turnId,
1310
+ ...(params.taskMember !== undefined ? { member: params.taskMember } : {}),
1302
1311
  // A resumed turn began when its `turn_started` was recorded, maybe
1303
1312
  // in another process: tasks it closed before the pause are still
1304
1313
  // "closed in this turn".
@@ -1447,6 +1456,36 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1447
1456
  })
1448
1457
  }
1449
1458
 
1459
+ // The person's own picture, on a model known to read text only, is refused
1460
+ // before anything is sent: leaving it out would answer a question about a
1461
+ // picture the model never saw, with nothing on screen to say so. Images a
1462
+ // tool returned are another matter (they are left out quietly beside the
1463
+ // text the tool gave), and so is a driver that declares no vision at all.
1464
+ // Only when that message is the last one: a run continuing after it (a
1465
+ // resume past an approval pause) answers with the picture already left
1466
+ // out, and refusing there would block a turn the person did not start.
1467
+ if (
1468
+ textOnlyModel &&
1469
+ latestUser !== undefined &&
1470
+ latestUser === params.messages[params.messages.length - 1] &&
1471
+ carries(latestUser, 'image')
1472
+ ) {
1473
+ const alternative = params.provider.imageModelFor?.(turnConfig.model)
1474
+ throw new NamzuError({
1475
+ code: 'capability_unavailable',
1476
+ message: `Model '${turnConfig.model}' does not accept image input. ${
1477
+ alternative
1478
+ ? `Select '${alternative}' or remove the images.`
1479
+ : 'Select a model that reads images or remove the images.'
1480
+ }`,
1481
+ details: {
1482
+ providerId: params.provider.id,
1483
+ capability: 'vision',
1484
+ model: turnConfig.model,
1485
+ },
1486
+ })
1487
+ }
1488
+
1450
1489
  if (attachmentMessageCount > 0) {
1451
1490
  const message = textOnlyModel
1452
1491
  ? `Model '${turnConfig.model}' on provider '${params.provider.id}' reads text only but ${attachmentMessageCount} user message(s) carry image attachments — they are left out of its requests, so the model never sees the images. Pass strictCapabilities: true to fail instead, or use a model that reads images.`
@@ -1655,6 +1694,9 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1655
1694
  const toolExecutor = ToolingBootstrap.init(
1656
1695
  {
1657
1696
  skillGrants,
1697
+ // A host names its approval policy for the mode it implements, so the name is
1698
+ // the live mode; a name that is not a mode says nothing about nested calls.
1699
+ reviewMode: () => approvalPolicy.current.name,
1658
1700
  tools: toolManager,
1659
1701
  ...(params.structuredOutput?.toolResultRetention === 'durable' && structuredOutputTool
1660
1702
  ? { durableStructuredOutputTool: structuredOutputTool }
@@ -1681,6 +1723,9 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
1681
1723
  allowedTools: effectiveAllowedTools,
1682
1724
  invocationState: params.invocationState,
1683
1725
  pluginManager: params.pluginManager,
1726
+ ...(params.taskTeam !== undefined && params.taskMember !== undefined
1727
+ ? { teammate: { name: params.taskMember, team: params.taskTeam } }
1728
+ : {}),
1684
1729
  ...(params.backgroundJobs ? { backgroundJobs: params.backgroundJobs } : {}),
1685
1730
  ...(params.backgroundJobOwner ? { backgroundJobOwner: params.backgroundJobOwner } : {}),
1686
1731
  ...(awaitedJobs ? { onJobAwaited: (id: string) => awaitedJobs.expect(id) } : {}),
@@ -2063,6 +2108,23 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
2063
2108
  ? { compactionSummaryRoute: params.compactionSummaryRoute }
2064
2109
  : {}),
2065
2110
  ...(providerContextWindow !== undefined ? { providerContextWindow } : {}),
2111
+ ...(providerAutoCompactLimit !== undefined ? { providerAutoCompactLimit } : {}),
2112
+ resolveModelAutoCompactLimit: async (model) => {
2113
+ if (!modelAutoCompactLimits.has(model)) {
2114
+ modelAutoCompactLimits.set(
2115
+ model,
2116
+ await resolveProviderContextWindow(
2117
+ resilientProvider,
2118
+ model,
2119
+ ctx.abortController.signal,
2120
+ turnConfig.timeoutMs,
2121
+ log,
2122
+ 'resolveAutoCompactLimit',
2123
+ ),
2124
+ )
2125
+ }
2126
+ return modelAutoCompactLimits.get(model)
2127
+ },
2066
2128
  resolveModelContextWindow: async (model) => {
2067
2129
  if (!modelContextWindows.has(model)) {
2068
2130
  modelContextWindows.set(
@@ -1335,6 +1335,7 @@ export class IterationOrchestrator {
1335
1335
  maxTokens:
1336
1336
  outputCapOverride ?? step.maxResponseTokens ?? turnConfig.maxResponseTokens,
1337
1337
  cacheControl: { type: 'auto' },
1338
+ cacheKey: recorder.sessionId,
1338
1339
  ...(turnConfig.thinking ? { thinking: turnConfig.thinking } : {}),
1339
1340
  ...(stepEffort ? { effort: stepEffort } : {}),
1340
1341
  ...(turnConfig.speed ? { speed: turnConfig.speed } : {}),
@@ -3866,6 +3867,7 @@ export class IterationOrchestrator {
3866
3867
  temperature: this.ctx.turnConfig.temperature,
3867
3868
  maxTokens: this.ctx.turnConfig.maxResponseTokens,
3868
3869
  cacheControl: { type: 'auto' },
3870
+ cacheKey: this.ctx.recorder.sessionId,
3869
3871
  ...(this.ctx.turnConfig.thinking ? { thinking: this.ctx.turnConfig.thinking } : {}),
3870
3872
  // This turn is a hand-maintained duplicate of the one above, which
3871
3873
  // is exactly the shape a field goes missing from — so it is tested
@@ -1,4 +1,5 @@
1
1
  import {
2
+ providerTriggerFraction,
2
3
  resolveContextWindow,
3
4
  resolveTriggerThreshold,
4
5
  } from '../../../../compaction/context-window.js'
@@ -21,7 +22,7 @@ import {
21
22
  } from '../../../../compaction/plan.js'
22
23
  import type { ContextReducer, ContextReduction } from '../../../../compaction/reducer.js'
23
24
  import { createSlidingWindowReducer } from '../../../../compaction/reducer.js'
24
- import { renderRestoredContext } from '../../../../compaction/restore.js'
25
+ import { carriedWorkingCommands, renderRestoredContext } from '../../../../compaction/restore.js'
25
26
  import { findRetainedIndices } from '../../../../compaction/retention.js'
26
27
  import { serializeState } from '../../../../compaction/serializer.js'
27
28
  import {
@@ -188,6 +189,10 @@ async function emitToolResultClear(
188
189
  */
189
190
  function adoptLoadedSkills(ctx: IterationContext): void {
190
191
  ctx.workingStateManager?.adoptSkillBodies(adoptableSkills(ctx.recorder.messages))
192
+ for (const message of ctx.recorder.messages) {
193
+ if (message.role === 'system' && typeof message.content === 'string')
194
+ ctx.workingStateManager?.adoptWorkingCommands(carriedWorkingCommands(message.content))
195
+ }
191
196
  }
192
197
 
193
198
  /**
@@ -836,7 +841,7 @@ async function runCompactionCheckInner(
836
841
  const configured = ctx.compactionConfig
837
842
  if (!configured) return
838
843
  if (configured.strategy === 'disabled') return
839
- const config = options?.deeper ? deepenConfig(configured, ctx.recorder.messages) : configured
844
+ const deepened = options?.deeper ? deepenConfig(configured, ctx.recorder.messages) : configured
840
845
 
841
846
  const measured = measureContext(ctx)
842
847
  const estimatedTokens = measured.tokens
@@ -851,6 +856,24 @@ async function runCompactionCheckInner(
851
856
  const window = activeContextWindow(ctx)
852
857
  const budget = window.tokens
853
858
 
859
+ // The provider's own compaction limit, when its service stated one, is the trigger:
860
+ // min(limit, 90% of the window). A host that set a threshold or an auto-compact window
861
+ // keeps what it set. Folding it into the config means the planners below read the same
862
+ // trigger this pass does.
863
+ const model = ctx.contextModel ?? ctx.turnConfig.model
864
+ const providerLimit =
865
+ model === ctx.turnConfig.model
866
+ ? ctx.providerAutoCompactLimit
867
+ : ctx.activeProviderAutoCompactLimit
868
+ const providerFraction =
869
+ deepened.triggerThreshold === undefined &&
870
+ deepened.autoCompactWindowTokens === undefined &&
871
+ window.source !== 'config'
872
+ ? providerTriggerFraction(providerLimit, budget)
873
+ : undefined
874
+ const config =
875
+ providerFraction !== undefined ? { ...deepened, triggerThreshold: providerFraction } : deepened
876
+
854
877
  const usage = estimatedTokens / budget
855
878
 
856
879
  // A forced pass skips the threshold: it runs because the provider
@@ -242,6 +242,10 @@ export interface IterationContext {
242
242
  * through to the table.
243
243
  */
244
244
  readonly providerContextWindow?: number
245
+ /** What the driver's service says compaction starts at, in tokens; asked once at the start of the turn. */
246
+ readonly providerAutoCompactLimit?: number
247
+ activeProviderAutoCompactLimit?: number
248
+ readonly resolveModelAutoCompactLimit?: (model: string) => Promise<number | undefined>
245
249
  /** Selected request model; its window must not reuse another model's metadata. */
246
250
  contextModel?: string
247
251
  activeProviderContextWindow?: number
@@ -81,6 +81,8 @@ interface Interpreted {
81
81
  readonly verdicts: Map<string, Verdict>
82
82
  /** The calls were refused and the refusal ends the turn. */
83
83
  readonly endsTurn: boolean
84
+ /** The refusal was a person's own No, not the safety check's. */
85
+ readonly byPerson?: boolean
84
86
  /** The decision was the host stopping the turn outright. */
85
87
  readonly cancelled: boolean
86
88
  /** The decision was a request to wait: the park it recorded must not stay open. */
@@ -135,8 +137,12 @@ export interface PerCallReviewDeps {
135
137
  * - An answer that grants something (a remembered approval, a changed rule or
136
138
  * mode on the host's side) re-checks the questions still open, and any call
137
139
  * the new state covers is let through unasked. A re-check never refuses.
138
- * - A plain refusal ends the turn: the questions still open close, calls not
139
- * yet started are refused without being asked, calls in flight are cancelled.
140
+ * - A refusal that ends the turn closes the questions still open and refuses,
141
+ * without asking, the calls that would have needed one. When the safety
142
+ * check refused, calls that need no review (a read, a search, a call a rule
143
+ * already allowed) still run and calls already running finish: the refusal
144
+ * is about the call it answered. A person's own No, and the host stopping
145
+ * the turn (`cancelled`), cancel what is running and start nothing more.
140
146
  * - Every refusal and every call that could not be matched to a reviewed
141
147
  * summary is a refusal. Nothing is approved by the absence of an answer.
142
148
  */
@@ -266,6 +272,10 @@ export class PerCallReview implements ReviewedExecution {
266
272
  })
267
273
  return { run: true }
268
274
  }
275
+ // A refusal ended the turn while this call waited its turn: nobody is asked
276
+ // about it any more. It is refused here; a call that needed no question was
277
+ // let through above.
278
+ if (this.#endsTurn) return { run: false, reason: REFUSED_WITH_THE_TURN }
269
279
  const interpreted = await this.#ask([summary], leave)
270
280
  this.#noteEnd(interpreted)
271
281
  const verdict = interpreted.verdicts.get(summary.id) ?? {
@@ -361,10 +371,10 @@ export class PerCallReview implements ReviewedExecution {
361
371
 
362
372
  #noteEnd(interpreted: Interpreted): void {
363
373
  if (!interpreted.endsTurn && !interpreted.cancelled) return
364
- this.#end(interpreted.cancelled)
374
+ this.#end(interpreted.cancelled, interpreted.byPerson === true)
365
375
  }
366
376
 
367
- #end(cancelled: boolean): void {
377
+ #end(cancelled: boolean, byPerson = false): void {
368
378
  if (this.#endsTurn) return
369
379
  this.#endsTurn = true
370
380
  this.#cancelled = cancelled
@@ -372,7 +382,10 @@ export class PerCallReview implements ReviewedExecution {
372
382
  ask.closedBy ??= 'ended'
373
383
  ask.controller.abort()
374
384
  }
375
- this.#endController.abort(new Error('the user stopped the turn'))
385
+ // A person's No, and the host stopping the turn, cancel what is running
386
+ // and start nothing more. A refusal by the safety check is about the call
387
+ // it answered: what is running and what needs no review carries on.
388
+ if (cancelled || byPerson) this.#endController.abort(new Error('the user stopped the turn'))
376
389
  }
377
390
 
378
391
  /** One request to the handler about `calls`, and what its answer means for each. */
@@ -481,6 +494,7 @@ export class PerCallReview implements ReviewedExecution {
481
494
  interpreted.endsTurn,
482
495
  interpreted.cancelled,
483
496
  interpreted.paused,
497
+ interpreted.byPerson === true,
484
498
  )
485
499
  }
486
500
 
@@ -492,6 +506,7 @@ export class PerCallReview implements ReviewedExecution {
492
506
  endsTurn: boolean,
493
507
  cancelled: boolean,
494
508
  paused: boolean,
509
+ byPerson = false,
495
510
  ): Promise<Interpreted> {
496
511
  const { ctx } = this.#deps
497
512
  const denials = new Map<string, string>()
@@ -534,7 +549,7 @@ export class PerCallReview implements ReviewedExecution {
534
549
  })
535
550
  }
536
551
  }
537
- return { verdicts: result, endsTurn, cancelled, paused }
552
+ return { verdicts: result, endsTurn, byPerson, cancelled, paused }
538
553
  }
539
554
 
540
555
  #interpret(decision: HITLResumeDecision, calls: readonly ToolCallSummary[]): Interpreted {
@@ -545,6 +560,7 @@ export class PerCallReview implements ReviewedExecution {
545
560
  let endsTurn = false
546
561
  let cancelled = false
547
562
  let paused = false
563
+ let byPerson = false
548
564
  switch (decision.action) {
549
565
  case 'approve_tools':
550
566
  case 'continue':
@@ -562,6 +578,7 @@ export class PerCallReview implements ReviewedExecution {
562
578
  ...(decision.declined ? { declined: note ? { note } : {} } : {}),
563
579
  })
564
580
  endsTurn = decision.endTurn === true
581
+ byPerson = decision.declined !== undefined
565
582
  break
566
583
  }
567
584
  case 'modify_tools': {
@@ -600,7 +617,7 @@ export class PerCallReview implements ReviewedExecution {
600
617
  })
601
618
  refuseAll({ run: false, reason: NOT_THIS_QUESTION })
602
619
  }
603
- return { verdicts, endsTurn, cancelled, paused }
620
+ return { verdicts, endsTurn, byPerson, cancelled, paused }
604
621
  }
605
622
  }
606
623
 
@@ -330,4 +330,8 @@ export async function selectContextModel(
330
330
  model && model !== ctx.turnConfig.model && !ctx.compactionConfig?.contextWindowTokens
331
331
  ? await ctx.resolveModelContextWindow?.(model)
332
332
  : undefined
333
+ ctx.activeProviderAutoCompactLimit =
334
+ model && model !== ctx.turnConfig.model && !ctx.compactionConfig?.contextWindowTokens
335
+ ? await ctx.resolveModelAutoCompactLimit?.(model)
336
+ : undefined
333
337
  }
@@ -86,7 +86,9 @@ export interface PreparedTurn {
86
86
  readonly resilientProvider: LLMProvider
87
87
  readonly serving: { current: ServingMember }
88
88
  readonly providerContextWindow: number | undefined
89
+ readonly providerAutoCompactLimit: number | undefined
89
90
  readonly modelContextWindows: Map<string, number | undefined>
91
+ readonly modelAutoCompactLimits: Map<string, number | undefined>
90
92
  readonly approvalPolicy: SessionApprovalPolicy
91
93
  readonly eventTranslator: EventTranslator
92
94
  readonly executeUserInterruptHooks: (terminalError: unknown) => Promise<void>
@@ -224,8 +226,11 @@ export async function resolveProviderContextWindow(
224
226
  signal: AbortSignal | undefined,
225
227
  timeoutMs: number,
226
228
  log: Logger,
229
+ /** Which of the driver's two optional limit lookups to ask; both share one bounded, swallowed path. */
230
+ member: 'resolveContextWindow' | 'resolveAutoCompactLimit' = 'resolveContextWindow',
227
231
  ): Promise<number | undefined> {
228
- if (!provider.resolveContextWindow || !model) return undefined
232
+ const lookup = provider[member]
233
+ if (!lookup || !model) return undefined
229
234
  if (signal?.aborted) return undefined
230
235
 
231
236
  // The resolver is an optional optimisation that runs before TurnContext
@@ -253,7 +258,7 @@ export async function resolveProviderContextWindow(
253
258
  }, deadlineMs)
254
259
 
255
260
  try {
256
- const resolution = provider.resolveContextWindow(model, resolverSignal)
261
+ const resolution = lookup.call(provider, model, resolverSignal)
257
262
  const reported = await Promise.race([resolution, interruption])
258
263
  if (reported === interrupted) {
259
264
  if (deadline.signal.aborted) {
@@ -499,6 +504,17 @@ export async function prepareTurn(params: QueryParams): Promise<PreparedTurn> {
499
504
  )
500
505
  const modelContextWindows = new Map<string, number | undefined>()
501
506
  if (turnConfig.model) modelContextWindows.set(turnConfig.model, providerContextWindow)
507
+ // The same lookup, for the threshold the driver's own service says compaction starts at.
508
+ const providerAutoCompactLimit = await resolveProviderContextWindow(
509
+ resilientProvider,
510
+ turnConfig.model,
511
+ params.signal,
512
+ turnConfig.timeoutMs,
513
+ log,
514
+ 'resolveAutoCompactLimit',
515
+ )
516
+ const modelAutoCompactLimits = new Map<string, number | undefined>()
517
+ if (turnConfig.model) modelAutoCompactLimits.set(turnConfig.model, providerAutoCompactLimit)
502
518
 
503
519
  // The mode this conversation was left in, when the turn config names none.
504
520
  // Read once, before the loop exists, for the same reason the context
@@ -880,7 +896,9 @@ export async function prepareTurn(params: QueryParams): Promise<PreparedTurn> {
880
896
  resilientProvider,
881
897
  serving,
882
898
  providerContextWindow,
899
+ providerAutoCompactLimit,
883
900
  modelContextWindows,
901
+ modelAutoCompactLimits,
884
902
  approvalPolicy,
885
903
  eventTranslator,
886
904
  executeUserInterruptHooks,
@@ -50,6 +50,7 @@ import {
50
50
  PLAN_MODE_REFUSAL,
51
51
  PLAN_MODE_REFUSAL_WITH_PLAN_FILE,
52
52
  STRICT_MODE_REFUSAL,
53
+ nestedCallModeRefusal,
53
54
  } from '../../types/permission/index.js'
54
55
  import type { AutoReviewClassifier, AutoReviewDecision } from './auto-review/classifier.js'
55
56
  import {
@@ -149,7 +150,12 @@ export function isReviewMode(value: unknown): value is ReviewMode {
149
150
  return typeof value === 'string' && (REVIEW_MODES as readonly string[]).includes(value)
150
151
  }
151
152
 
152
- export { PLAN_MODE_REFUSAL, PLAN_MODE_REFUSAL_WITH_PLAN_FILE, STRICT_MODE_REFUSAL }
153
+ export {
154
+ PLAN_MODE_REFUSAL,
155
+ PLAN_MODE_REFUSAL_WITH_PLAN_FILE,
156
+ STRICT_MODE_REFUSAL,
157
+ nestedCallModeRefusal,
158
+ }
153
159
 
154
160
  /** The tools `accept-edits` approves without asking. Everything else prompts. */
155
161
  export const ACCEPT_EDITS_TOOLS: ReadonlySet<string> = new Set(['edit', 'write'])
@@ -949,11 +955,20 @@ export interface ReviewPolicyOptions {
949
955
  /**
950
956
  * Called when the classifier has given no verdict several times in a row
951
957
  * (`AutoReviewLimits.noVerdict`): it could not be reached, or its answers
952
- * could not be read. The policy refuses the batch and ends the turn, with a
953
- * person to ask or without one, rather than hold back call after call; this
958
+ * could not be read. With nobody to ask, the policy refuses the batch and
959
+ * ends the turn rather than hold back call after call; with a person to ask,
960
+ * the person is asked instead and this is not called. This
954
961
  * is where a host says so in its own words. `reason` is the last block's.
955
962
  */
956
963
  readonly onClassifierUnavailable?: (event: { readonly reason: string }) => void
964
+ /**
965
+ * Called when the classifier could not complete a check (or gave an answer
966
+ * that was not a verdict) and a person was asked about the call instead.
967
+ * Only with a `prompt`; without one the call is refused and
968
+ * {@link onClassifierUnavailable} is how a run of them is reported.
969
+ * `reason` names the class of failure.
970
+ */
971
+ readonly onClassifierFellBack?: (event: { readonly reason: string }) => void
957
972
  }
958
973
 
959
974
  /**
@@ -1370,8 +1385,19 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
1370
1385
  return askPerson(escapes)
1371
1386
  }
1372
1387
  transcriptTooLong = false
1373
- // A check that keeps giving no verdict ends the turn, person or not:
1374
- // holding calls back one at a time against it gets nowhere, and
1388
+ // A check that could not be completed says nothing about the call,
1389
+ // so with a person to ask the person is asked, as for a call the
1390
+ // classifier was never going to judge. This is not a refusal and it
1391
+ // does not count toward ending the turn. The host hears why, so it
1392
+ // can say the check is down.
1393
+ if (decision.cause === 'unavailable' || decision.cause === 'unreadable') {
1394
+ if (prompt) {
1395
+ options.onClassifierFellBack?.({ reason: decision.reason })
1396
+ return askPerson(escapes)
1397
+ }
1398
+ }
1399
+ // With nobody to ask, a check that keeps giving no verdict ends the
1400
+ // turn: holding calls back one at a time against it gets nowhere, and
1375
1401
  // nothing is run unchecked.
1376
1402
  if (decision.noVerdictLimitReached === true) {
1377
1403
  options.onClassifierUnavailable?.({ reason: decision.reason })
@@ -0,0 +1,49 @@
1
+ /**
2
+ * What a shell line reaches that no rule and no skill grant may approve in
3
+ * advance, asked outside a turn. The executor asks the same questions of a
4
+ * nested call (`escalationOf`); a host that runs a command without an
5
+ * executor (a command a person typed, a headless prompt) asks them here, so
6
+ * the two routes refuse the same lines.
7
+ */
8
+
9
+ import { unknownProgramInLine } from '../../authorization/program.js'
10
+ import type { ShellDialect } from '../../authorization/shell-lexer.js'
11
+ import { shellEscalations } from './path-escalation.js'
12
+
13
+ export interface ShellLineEscalationContext {
14
+ /** The working directory first, then the added directories. */
15
+ readonly roots: readonly string[]
16
+ /** Where the line starts, when that is not the first root. */
17
+ readonly cwd?: string
18
+ /** Whether the line runs in a sandbox (paths there are the guest's). */
19
+ readonly sandboxed: boolean
20
+ readonly dialect?: ShellDialect
21
+ }
22
+
23
+ /**
24
+ * The reason a shell line must go to a person, or `undefined` when it reaches
25
+ * nothing past the roots. A check that throws is answered as an unfinished
26
+ * check, never as "nothing found".
27
+ */
28
+ export async function shellLineEscalation(
29
+ line: string,
30
+ context: ShellLineEscalationContext,
31
+ ): Promise<string | undefined> {
32
+ const dialect = context.dialect ?? 'sh'
33
+ try {
34
+ const found = await shellEscalations(line, dialect, {
35
+ roots: context.roots,
36
+ ...(context.cwd !== undefined ? { cwd: context.cwd } : {}),
37
+ reviewOutside: !context.sandboxed,
38
+ topLevel: !context.sandboxed,
39
+ })
40
+ if (found.protectedPaths.length > 0) return 'it writes to a protected path'
41
+ if (found.dangerousRemoval !== undefined) return 'it removes more than a command may'
42
+ if (found.outsidePaths.length > 0) return 'it reaches outside the working folders'
43
+ if (unknownProgramInLine(line, dialect) !== undefined)
44
+ return 'it runs a program Namzu cannot read'
45
+ return undefined
46
+ } catch {
47
+ return 'the safety checks did not finish'
48
+ }
49
+ }
@@ -48,6 +48,8 @@ export interface ToolingBootstrapConfig {
48
48
  allowedTools?: readonly string[]
49
49
  invocationState?: InvocationState
50
50
  pluginManager?: PluginLifecycleManager
51
+ /** Set for a teammate's turn: the task hooks name it. */
52
+ teammate?: { readonly name: string; readonly team: string }
51
53
  toolTimeoutMs?: number
52
54
  /** Host-owned and shared; the executor binds it to this turn. */
53
55
  backgroundJobs?: BackgroundJobRegistry
@@ -92,6 +94,8 @@ export interface ToolingBootstrapConfig {
92
94
  toolPause?: (toolUseId: string) => RequestToolPause
93
95
  /** The turn's skill pre-approvals; see the executor's own field. */
94
96
  skillGrants?: SkillGrantSet
97
+ /** See `ExecutorConfig.reviewMode`. */
98
+ reviewMode?: () => string | undefined
95
99
  }
96
100
 
97
101
  export class ToolingBootstrap {
@@ -126,6 +130,7 @@ export class ToolingBootstrap {
126
130
  invocationState: config.invocationState,
127
131
  captureSessionEvidence: config.captureSessionEvidence,
128
132
  pluginManager: config.pluginManager,
133
+ ...(config.teammate ? { teammate: config.teammate } : {}),
129
134
  ...(config.backgroundJobs ? { backgroundJobs: config.backgroundJobs } : {}),
130
135
  ...(config.backgroundJobOwner ? { backgroundJobOwner: config.backgroundJobOwner } : {}),
131
136
  ...(config.onJobAwaited ? { onJobAwaited: config.onJobAwaited } : {}),
@@ -178,6 +183,7 @@ export class ToolingBootstrap {
178
183
  : {}),
179
184
  ...(config.toolPause !== undefined ? { toolPause: config.toolPause } : {}),
180
185
  ...(config.skillGrants !== undefined ? { skillGrants: config.skillGrants } : {}),
186
+ ...(config.reviewMode !== undefined ? { reviewMode: config.reviewMode } : {}),
181
187
  },
182
188
  activityStore,
183
189
  emitEvent,
@@ -140,6 +140,8 @@ export interface OutcomeLedgerSnapshot {
140
140
  readonly unseen?: boolean
141
141
  /** Absent in a snapshot written before it existed. */
142
142
  readonly pathless?: number
143
+ /** Background jobs that run a recognised check: job id and command. Absent in an older snapshot. */
144
+ readonly jobs?: readonly (readonly [string, string])[]
143
145
  readonly checks: readonly {
144
146
  readonly key: string
145
147
  readonly command: string
@@ -357,6 +359,14 @@ function runsRecognisedCheck(line: string, hostIsCheck?: (command: string) => bo
357
359
  return false
358
360
  }
359
361
 
362
+ /** Tools that only write to the task list or to the mail between agents. */
363
+ const COORDINATION_TOOLS: ReadonlySet<string> = new Set([
364
+ 'task_create',
365
+ 'task_update',
366
+ 'send_message',
367
+ 'stop_task',
368
+ ])
369
+
360
370
  export class OutcomeLedger {
361
371
  private readonly config: TurnOutcomeConfig
362
372
  private started = false
@@ -369,6 +379,8 @@ export class OutcomeLedger {
369
379
  private couldHaveChangedUnseen = false
370
380
  private writes = 0
371
381
  private readonly checks = new Map<string, CheckState>()
382
+ /** Background jobs that run a recognised check, by job id: the command they run. */
383
+ private readonly jobChecks = new Map<string, string>()
372
384
  private unrecorded = false
373
385
  private settled: TurnOutcome | undefined
374
386
 
@@ -403,6 +415,8 @@ export class OutcomeLedger {
403
415
  this.writes = parsed.writes
404
416
  this.pathless = parsed.pathless ?? 0
405
417
  this.couldHaveChangedUnseen = parsed.unseen === true
418
+ this.jobChecks.clear()
419
+ for (const [id, command] of parsed.jobs ?? []) this.jobChecks.set(id, command)
406
420
  this.checks.clear()
407
421
  for (const check of parsed.checks) {
408
422
  this.checks.set(check.key, { ...check, fingerprint: check.fingerprint })
@@ -419,6 +433,7 @@ export class OutcomeLedger {
419
433
  writes: this.writes,
420
434
  unseen: this.couldHaveChangedUnseen,
421
435
  pathless: this.pathless,
436
+ jobs: [...this.jobChecks.entries()].slice(-MAX_REMEMBERED_CHECKS),
422
437
  checks: [...this.checks.values()].map((check) => ({
423
438
  key: check.key,
424
439
  command: check.command,
@@ -439,6 +454,9 @@ export class OutcomeLedger {
439
454
  */
440
455
  private couldChange(call: PendingOutcomeCall): boolean {
441
456
  if (call.readOnly === true) return false
457
+ // These keep the plan and the team's mail: they write to the task list and the mailboxes, never to
458
+ // the workspace, so a turn that only used them has nothing it could have changed unseen.
459
+ if (COORDINATION_TOOLS.has(call.toolName)) return false
442
460
  if (call.toolName === 'bash') {
443
461
  const command = commandOf(call.input)
444
462
  if (command !== undefined && isReadOnlyCommandLine(command)) return false
@@ -486,6 +504,21 @@ export class OutcomeLedger {
486
504
  // answers for exactly the state they left.
487
505
  let pending: CheckState[] = []
488
506
  for (const call of calls) {
507
+ // A check started as a background job is not a result yet; the wait that
508
+ // reads its exit is. Remember which command the job runs.
509
+ // A foreground check the time limit moved to the background is a job too,
510
+ // though the call was not marked `launched`.
511
+ if (
512
+ call.toolName === 'bash' &&
513
+ call.facts?.kind === 'command' &&
514
+ call.facts.jobId !== undefined &&
515
+ (call.launched === true || call.facts.background === true)
516
+ ) {
517
+ const started = commandOf(call.input)
518
+ if (started !== undefined && runsRecognisedCheck(started, this.config.isCheck)) {
519
+ this.jobChecks.set(call.facts.jobId, started)
520
+ }
521
+ }
489
522
  // A call that did not run, or only started work elsewhere, changed nothing here.
490
523
  if (call.skipped === true || call.notRun === true || call.launched === true) continue
491
524
  const written = WRITING_TOOLS.has(call.toolName)
@@ -498,7 +531,16 @@ export class OutcomeLedger {
498
531
  continue
499
532
  }
500
533
  if (written) continue
501
- const command = call.toolName === 'bash' ? commandOf(call.input) : undefined
534
+ // The exit of a background check, read by `wait_for_job`, is that check's
535
+ // result: the job's own command, with the exit code the wait reported.
536
+ const jobCommand =
537
+ call.toolName === 'wait_for_job' &&
538
+ call.facts?.kind === 'command' &&
539
+ call.facts.jobId !== undefined &&
540
+ call.facts.exitCode !== undefined
541
+ ? this.jobChecks.get(call.facts.jobId)
542
+ : undefined
543
+ const command = call.toolName === 'bash' ? commandOf(call.input) : jobCommand
502
544
  if (command !== undefined && runsRecognisedCheck(command, this.config.isCheck)) {
503
545
  this.afterEveryCheck('other')
504
546
  for (const check of pending) check.fingerprint = null
@@ -720,6 +762,19 @@ function parseSnapshot(value: unknown): OutcomeLedgerSnapshot | undefined {
720
762
  ) {
721
763
  return undefined
722
764
  }
765
+ if (
766
+ snap.jobs !== undefined &&
767
+ (!Array.isArray(snap.jobs) ||
768
+ !snap.jobs.every(
769
+ (j) =>
770
+ Array.isArray(j) &&
771
+ j.length === 2 &&
772
+ typeof j[0] === 'string' &&
773
+ typeof j[1] === 'string',
774
+ ))
775
+ ) {
776
+ return undefined
777
+ }
723
778
  if (!Array.isArray(snap.checks)) return undefined
724
779
  const results = new Set<string>(['passed', 'failed', 'masked', 'unsettled'])
725
780
  for (const raw of snap.checks) {
@@ -49,6 +49,7 @@ import type {
49
49
  import { subscribeToAbort } from '../../utils/abort.js'
50
50
  import { generateSandboxId } from '../../utils/id.js'
51
51
  import type { Logger } from '../../utils/logger.js'
52
+ import { withNodeOnPath } from '../../utils/node-on-path.js'
52
53
  import {
53
54
  WINDOWS_CORE_ENV_KEYS,
54
55
  applyEnvironmentOverrides,
@@ -603,7 +604,8 @@ export function buildSafeEnv(
603
604
  // Last: a command in a sandbox is still a command a session started.
604
605
  setEnvironmentEntry(env, SESSION_CHILD_ENV, '1')
605
606
 
606
- return env
607
+ // A shell inside the sandbox can run `node` when the user's PATH has none.
608
+ return withNodeOnPath(env)
607
609
  }
608
610
 
609
611
  /**