@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
@@ -32,7 +32,7 @@ export const SearchToolsTool = defineTool({
32
32
  description: 'Load deferred tools so they can be called. ' +
33
33
  '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' +
34
34
  'Query forms:\n' +
35
- '- "select:read_memory,save_memory" loads exactly those tools by name. Use it when you know the names.\n' +
35
+ '- "select:read_memory,save_memory" loads exactly those tools by name. Use it when you know the names. Load every tool you will need in one call: list all the names, comma-separated, instead of one search per tool.\n' +
36
36
  '- "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' +
37
37
  '- "+slack send" requires "slack" in the result and ranks by the rest.\n' +
38
38
  "A query that is exactly one tool's name loads that tool and no other match, plus any companions it declares.",
@@ -42,6 +42,13 @@ export const SearchToolsTool = defineTool({
42
42
  readOnly: true,
43
43
  destructive: false,
44
44
  concurrencySafe: true,
45
+ // One plain line for a person: the names that were loaded, never the
46
+ // descriptions the model reads. A call that loaded nothing says so.
47
+ presentCall: () => ({ kind: 'generic', label: 'Loading tools', presentation: 'activity' }),
48
+ presentResult: (_input, result) => ({
49
+ kind: 'generic',
50
+ label: loadedToolsLabel(result.output ?? ''),
51
+ }),
45
52
  async execute(input, context) {
46
53
  if (!context.toolRegistry) {
47
54
  return {
@@ -188,12 +195,39 @@ export const SearchToolsTool = defineTool({
188
195
  };
189
196
  },
190
197
  });
198
+ /**
199
+ * The one line a person reads for a finished `search_tools` call, read from
200
+ * the text the model got (a host holds only that text): `Loaded tools: a, b`.
201
+ * A call that loaded nothing says that instead.
202
+ *
203
+ * `describeLoaded` indents every continuation line of a description, so a
204
+ * name starts a line at column zero only where this call really loaded it,
205
+ * and only as many names as the header counts are taken.
206
+ */
207
+ export function loadedToolsLabel(output) {
208
+ const head = /^Activated (\d+) tool\(s\):$/m.exec(output);
209
+ if (head?.[1] !== undefined) {
210
+ const count = Number(head[1]);
211
+ const rest = output.slice(head.index + head[0].length);
212
+ const names = [...rest.matchAll(/^- ([A-Za-z0-9_.-]+)(?: \(loaded with [^)]+\))?: /gm)]
213
+ .slice(0, count)
214
+ .map((match) => match[1]);
215
+ if (names.length > 0)
216
+ return `Loaded tools: ${names.join(', ')}`;
217
+ }
218
+ const already = /^Already loaded, call directly: (.+?)\.?$/m.exec(output);
219
+ if (already?.[1])
220
+ return `Already loaded: ${already[1]}`;
221
+ const none = /^(?:No tool named|No deferred tools matching)/m.test(output);
222
+ return none ? 'No matching tools' : 'Loaded tools';
223
+ }
191
224
  function describeLoaded(loaded, companionOf, companions = []) {
192
225
  const lines = loaded
193
226
  .map((t) => {
194
227
  const owner = companionOf.get(t.name);
195
228
  const note = companions.includes(t) && owner ? ` (loaded with ${owner})` : '';
196
- return `- ${t.name}${note}: ${t.description}`;
229
+ // Continuation lines are indented so none can pass for another entry.
230
+ return `- ${t.name}${note}: ${t.description.replace(/\r?\n/g, '\n ')}`;
197
231
  })
198
232
  .join('\n');
199
233
  return `Activated ${loaded.length} tool(s):\n${lines}`;
@@ -1 +1 @@
1
- {"version":3,"file":"search-tools.js","sourceRoot":"","sources":["../../../src/tools/builtins/search-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,+CAA+C;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAElC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAEpC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,KAAK,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,CACR,kIAAkI,CAClI;IACF,WAAW,EAAE,CAAC;SACZ,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,gBAAgB,CAAC;SACrB,QAAQ,EAAE;SACV,QAAQ,CAAC,8CAA8C,mBAAmB,GAAG,CAAC;CAChF,CAAC,CAAA;AAEF,MAAM,aAAa,GAAG,iBAAiB,CAAA;AAEvC,wEAAwE;AACxE,yEAAyE;AACzE,2DAA2D;AAC3D,MAAM,eAAe,GAAG,CAAC,CAAA;AAEzB,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;IACzC,IAAI,EAAE,cAAc;IACpB,WAAW,EACV,6CAA6C;QAC7C,4LAA4L;QAC5L,gBAAgB;QAChB,yGAAyG;QACzG,yKAAyK;QACzK,yE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,EAAE,CAAA;AACvD,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CACpB,MAAoD,EACpD,GAA8B,EAC9B,KAAwB;IAMxB,MAAM,KAAK,GAAqB,EAAE,CAAA;IAClC,MAAM,SAAS,GAAa,EAAE,CAAA;IAC9B,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;QACvF,IAAI,GAAG;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;aACnB,IAAI,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;;YACnC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA;AACrC,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import { parseAllowedTools } from '../../authorization/skill-grant.js';
2
+ import { type SkillShellHookOptions } from '../../skills/inline-shell-host.js';
3
+ import { type InlineShellBlock } from '../../skills/inline-shell.js';
2
4
  import type { Sandbox } from '../../types/sandbox/index.js';
3
5
  export { parseAllowedTools };
4
6
  /**
@@ -64,6 +66,35 @@ export interface SkillToolOptions {
64
66
  * given. The skill is still LOADED from the registry's own path.
65
67
  */
66
68
  readonly resolveModelDirectory?: SkillDirectoryResolver;
69
+ /**
70
+ * Run the shell commands a skill's text holds (`!`cmd`` and a fenced block
71
+ * opened with three backticks and a bang) while the skill loads. Absent, the
72
+ * text is handed over as written and nothing runs.
73
+ */
74
+ readonly shell?: SkillToolShellOptions;
75
+ }
76
+ /** What the host says about the shell commands inside a skill's text. */
77
+ export interface SkillToolShellOptions {
78
+ /** True while commands in skill text must not run; read at each load. */
79
+ readonly disabled?: () => boolean;
80
+ /**
81
+ * Where a skill came from, as the label a hook is told (`user`, `project`,
82
+ * `plugin`, `system`), and whether its commands may run at all: a skill from
83
+ * a tool server or other remote source, or a project's before its folder is
84
+ * trusted, gets `block` and its commands become a placeholder. A host that
85
+ * gives this function and answers `undefined` for a skill has not placed it,
86
+ * and that skill's commands do not run either.
87
+ */
88
+ readonly sourceOf?: (skill: string) => {
89
+ readonly source?: string;
90
+ readonly block?: InlineShellBlock;
91
+ } | undefined;
92
+ /** The hook manager of the session; absent, no hook is asked. */
93
+ readonly hooks?: () => SkillShellHookOptions['manager'];
94
+ /** The session's id, as a hook is told it. */
95
+ readonly sessionId?: () => string;
96
+ /** A line for the person: a refused command, a hook's own message. */
97
+ readonly warn?: (line: string) => void;
67
98
  }
68
99
  export declare const SKILL_TOOL_NAME = "skill";
69
100
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/skill.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAEtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAK3D,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,2DAA2D;AAC3D,MAAM,WAAW,qBAAqB;IACrC,sFAAsF;IACtF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CACtC;AAED,6DAA6D;AAC7D,MAAM,WAAW,qBAAqB;IACrC,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACpC,KAAK,EAAE,qBAAqB,EAC5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ErD,MAAM,WAAW,gBAAgB;IAChC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,sBAAsB,CAAA;IACvD;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,qBAAqB,CAAA;CACtC;AAED,yEAAyE;AACzE,MAAM,WAAW,qBAAqB;IACrC,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAA;IACjC;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAC/B;QACA,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;QACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAA;KAChC,GACD,SAAS,CAAA;IACZ,iEAAiE;IACjE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,qBAAqB,CAAC,SAAS,CAAC,CAAA;IACvD,8CAA8C;IAC9C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,MAAM,CAAA;IACjC,sEAAsE;IACtE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CACtC;AAyOD,eAAO,MAAM,eAAe,UAAU,CAAA;AAgBtC;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB;;;;GA6b7D;AA6DD,4FAA4F;AAC5F,eAAO,MAAM,SAAS;;;;EAAoB,CAAA"}
@@ -2,6 +2,8 @@ import { createHash } from 'node:crypto';
2
2
  import { z } from 'zod';
3
3
  import { parseAllowedTools } from '../../authorization/skill-grant.js';
4
4
  import { forkedSkillReportNote } from '../../compaction/loaded-skills.js';
5
+ import { createSkillShellHook, createToolSkillShellHost, skillShellAllow, } from '../../skills/inline-shell-host.js';
6
+ import { InlineShellError, expandInlineShell, findInlineShell, substituteEscaped, } from '../../skills/inline-shell.js';
5
7
  import { isInvocableBy, skillInvocation } from '../../types/skills/index.js';
6
8
  import { defineTool } from '../defineTool.js';
7
9
  export { parseAllowedTools };
@@ -166,6 +168,18 @@ function pageSkillBody(input) {
166
168
  return undefined;
167
169
  }
168
170
  export const SKILL_TOOL_NAME = 'skill';
171
+ /**
172
+ * A skill that could not load because a command in it failed, was refused or
173
+ * was stopped, as the tool's own failure. `undefined` for anything else,
174
+ * including the turn's own cancellation, which belongs to the turn.
175
+ */
176
+ function shellLoadFailure(error, context) {
177
+ if (context.abortSignal.aborted)
178
+ return undefined;
179
+ if (!(error instanceof InlineShellError))
180
+ return undefined;
181
+ return { success: false, output: '', error: error.message };
182
+ }
169
183
  /** The tool a skill that sets `context: fork` is handed to. */
170
184
  const DELEGATION_TOOL_NAME = 'Agent';
171
185
  /**
@@ -174,6 +188,63 @@ const DELEGATION_TOOL_NAME = 'Agent';
174
188
  */
175
189
  export function createSkillTool(options = {}) {
176
190
  const resolveModelDirectory = options.resolveModelDirectory;
191
+ // A load that ran commands is read again for each page of a long skill, and
192
+ // must not run them again: the first load's text is kept for its pages.
193
+ const expanded = new Map();
194
+ const expandShell = async (input) => {
195
+ const shell = options.shell;
196
+ if (shell === undefined || findInlineShell(input.body).length === 0)
197
+ return input.body;
198
+ const key = `${input.name}\u0000${input.body}`;
199
+ const kept = input.reuse ? expanded.get(key) : undefined;
200
+ if (kept !== undefined)
201
+ return kept;
202
+ const where = shell.sourceOf?.(input.name);
203
+ // A host that answers where skills come from, and has no answer for this one, has not
204
+ // placed it: its commands do not run.
205
+ const block = shell.disabled?.() === true
206
+ ? 'off'
207
+ : shell.sourceOf !== undefined && where === undefined
208
+ ? 'remote'
209
+ : where?.block;
210
+ const values = { $ARGUMENTS: input.args?.trim() ?? '' };
211
+ if (input.directory !== undefined) {
212
+ values['${CLAUDE_SKILL_DIR}'] = input.directory;
213
+ values['${NAMZU_SKILL_DIR}'] = input.directory;
214
+ }
215
+ const text = substituteEscaped(input.body, values);
216
+ const hook = createSkillShellHook({
217
+ manager: shell.hooks?.(),
218
+ sessionId: shell.sessionId?.() ?? String(input.context.sessionId),
219
+ ...(input.context.turnId !== undefined ? { turnId: String(input.context.turnId) } : {}),
220
+ signal: input.context.abortSignal,
221
+ info: {
222
+ commandName: input.name,
223
+ ...(where?.source !== undefined ? { commandSource: where.source } : {}),
224
+ invokedBy: input.invokedBy,
225
+ },
226
+ });
227
+ const allow = skillShellAllow(input.allowedTools, {
228
+ ...(input.directory !== undefined ? { skillDirectory: input.directory } : {}),
229
+ });
230
+ const result = await expandInlineShell(text, {
231
+ host: createToolSkillShellHost({
232
+ context: input.context,
233
+ ...(allow ? { allow } : {}),
234
+ }),
235
+ commandName: input.name,
236
+ ...(block !== undefined ? { block } : {}),
237
+ ...(hook
238
+ ? { hook: (command) => hook(command, `skillshell_${crypto.randomUUID()}`) }
239
+ : {}),
240
+ ...(shell.warn ? { warn: shell.warn } : {}),
241
+ signal: input.context.abortSignal,
242
+ });
243
+ if (expanded.size >= 8)
244
+ expanded.delete(expanded.keys().next().value);
245
+ expanded.set(key, result);
246
+ return result;
247
+ };
177
248
  return defineTool({
178
249
  name: SKILL_TOOL_NAME,
179
250
  description: 'Lists model-invocable skills when called without a name, or loads one skill by its exact listed name. Long lists and bodies return an opaque continuation cursor; keep calling in the same mode with that cursor until no continuation remains. The manifest carries only names and descriptions. Returns the list of skills, or the instructions of the named skill.',
@@ -328,17 +399,41 @@ export function createSkillTool(options = {}) {
328
399
  const forkHeader = resolveModelDirectory
329
400
  ? directoryHeader(nonEmpty(await resolveModelDirectory({ name: input.name, directory: skill.dirPath }, directoryContextOf(context.sandbox))))
330
401
  : '';
331
- // The delegated prompt is known before the agent starts: the host
332
- // recognises the agent that receives it, among any others that
333
- // start at the same time, and binds the skill's hooks to that one.
334
- const forkPrompt = forkedPrompt(forkHeader, argsLine, skill.body);
335
- const forkHooks = hooksPlanFor(skill, context, true, forkPrompt);
402
+ // The skill's hooks are read once, before any command runs: the same plan
403
+ // decides what its `allowed-tools` may pre-approve for its own commands as
404
+ // on an inline load. The delegated prompt is not known yet, so the host is
405
+ // told it when the hooks attach, and recognises the agent that receives it,
406
+ // among any others that start at the same time.
407
+ const forkHooks = hooksPlanFor(skill, context, true);
408
+ let forkBody = skill.body;
409
+ if (forkBody !== undefined) {
410
+ try {
411
+ forkBody = await expandShell({
412
+ name: input.name,
413
+ body: forkBody,
414
+ args: input.args,
415
+ directory: skill.dirPath,
416
+ allowedTools: grantedTools(skill, forkHooks),
417
+ invokedBy: 'model',
418
+ context,
419
+ reuse: false,
420
+ });
421
+ }
422
+ catch (error) {
423
+ const failed = shellLoadFailure(error, context);
424
+ if (failed)
425
+ return failed;
426
+ throw error;
427
+ }
428
+ }
429
+ const forkPrompt = forkedPrompt(forkHeader, argsLine, forkBody);
336
430
  const forkResult = await runForkedSkill({
337
431
  name: input.name,
338
432
  skill,
339
433
  prompt: forkPrompt,
340
434
  dispatch: context.dispatchTool,
341
435
  hooks: forkHooks,
436
+ hooksPrompt: forkPrompt,
342
437
  });
343
438
  return forkHooks?.notice
344
439
  ? { ...forkResult, output: `[${forkHooks.notice}]\n\n${forkResult.output}` }
@@ -351,108 +446,157 @@ export function createSkillTool(options = {}) {
351
446
  // that guards its work cannot be loaded, the skill's pre-approval is
352
447
  // withheld, whatever else it says.
353
448
  const hooksPlan = hooksPlanFor(skill, context, false);
354
- const allowed = hooksPlan?.withholdGrants
355
- ? undefined
356
- : parseAllowedTools(skill.metadata.allowedTools);
449
+ const allowed = grantedTools(skill, hooksPlan);
357
450
  // Asked on every call, first page or continuation: the digest binds
358
451
  // the answer, so a mount that changed between pages is a stale cursor
359
452
  // rather than a second half written for a different directory.
360
453
  const modelDirectory = resolveModelDirectory
361
454
  ? nonEmpty(await resolveModelDirectory({ name: input.name, directory: skill.dirPath }, directoryContextOf(context.sandbox)))
362
455
  : undefined;
363
- const snapshot = {
364
- name: input.name,
365
- body: skill.body ?? '(this skill has no body)',
366
- allowedTools: allowed,
367
- // The model's path when the host gave one: `${CLAUDE_SKILL_DIR}` in a
368
- // pattern is matched against a command line the model writes, and it
369
- // writes the path it was told.
370
- skillDirectory: resolveModelDirectory ? modelDirectory : skill.dirPath,
371
- header: forkUnavailable + (resolveModelDirectory ? directoryHeader(modelDirectory) : ''),
372
- invocation,
373
- };
374
- const digest = snapshotDigest(snapshot);
375
- let start = 0;
376
- if (input.cursor !== undefined) {
377
- const parsed = parseCursor(input.cursor);
378
- if (!parsed ||
379
- parsed.digest !== digest ||
380
- parsed.offset >= snapshot.body.length ||
381
- !isCodePointBoundary(snapshot.body, parsed.offset)) {
456
+ let loadedBody = skill.body ?? '(this skill has no body)';
457
+ // A skill's own hooks guard its own load-time commands, so a skill that holds
458
+ // commands attaches them first and takes them off again when the load fails.
459
+ // Any other skill keeps the rule that they go live once its instructions
460
+ // were delivered.
461
+ const attachedEarly = skill.body !== undefined &&
462
+ options.shell !== undefined &&
463
+ findInlineShell(skill.body).length > 0
464
+ ? hooksPlan?.attach()
465
+ : undefined;
466
+ let delivered = false;
467
+ try {
468
+ if (skill.body !== undefined) {
469
+ try {
470
+ loadedBody = await expandShell({
471
+ name: input.name,
472
+ body: skill.body,
473
+ args: input.args,
474
+ directory: resolveModelDirectory ? modelDirectory : skill.dirPath,
475
+ allowedTools: allowed,
476
+ invokedBy: 'model',
477
+ context,
478
+ reuse: input.cursor !== undefined,
479
+ });
480
+ }
481
+ catch (error) {
482
+ const failed = shellLoadFailure(error, context);
483
+ if (failed)
484
+ return failed;
485
+ throw error;
486
+ }
487
+ }
488
+ const snapshot = {
489
+ name: input.name,
490
+ body: loadedBody,
491
+ allowedTools: allowed,
492
+ // The model's path when the host gave one: `${CLAUDE_SKILL_DIR}` in a
493
+ // pattern is matched against a command line the model writes, and it
494
+ // writes the path it was told.
495
+ skillDirectory: resolveModelDirectory ? modelDirectory : skill.dirPath,
496
+ header: forkUnavailable + (resolveModelDirectory ? directoryHeader(modelDirectory) : ''),
497
+ invocation,
498
+ };
499
+ const digest = snapshotDigest(snapshot);
500
+ let start = 0;
501
+ if (input.cursor !== undefined) {
502
+ const parsed = parseCursor(input.cursor);
503
+ if (!parsed ||
504
+ parsed.digest !== digest ||
505
+ parsed.offset >= snapshot.body.length ||
506
+ !isCodePointBoundary(snapshot.body, parsed.offset)) {
507
+ return {
508
+ success: false,
509
+ output: '',
510
+ error: `The continuation cursor for "${input.name}" is stale or invalid. Call skill again without a cursor to read the current instructions.`,
511
+ };
512
+ }
513
+ start = parsed.offset;
514
+ }
515
+ // Compiled before paging so the notice can say what the grant is, and
516
+ // committed only after paging succeeded: a load that fails here gave
517
+ // the model no instructions, so it must not have approved anything.
518
+ // Idempotent: a continuation call grants the same entries again, and
519
+ // the turn's set keeps one copy.
520
+ let grant;
521
+ if (allowed !== undefined && allowed.length > 0 && context.grantSkillTools) {
522
+ grant = context.grantSkillTools({
523
+ skill: skill.metadata.name,
524
+ allowedTools: allowed,
525
+ ...(snapshot.skillDirectory ? { skillDirectory: snapshot.skillDirectory } : {}),
526
+ });
527
+ }
528
+ const notice = (hooksPlan?.notice ? `\n\n[${hooksPlan.notice}]` : '') +
529
+ grantNotice(allowed, grant, context.grantSkillTools !== undefined);
530
+ const page = pageSkillBody({
531
+ snapshot: start === 0 && argsLine
532
+ ? { ...snapshot, header: argsLine + snapshot.header }
533
+ : snapshot,
534
+ digest,
535
+ start,
536
+ notice,
537
+ maxChars: context.maxToolOutputChars,
538
+ });
539
+ if (!page) {
382
540
  return {
383
541
  success: false,
384
542
  output: '',
385
- error: `The continuation cursor for "${input.name}" is stale or invalid. Call skill again without a cursor to read the current instructions.`,
543
+ error: `The model-visible tool-output budget is too small to read "${input.name}" safely. Increase maxToolOutputChars and retry.`,
386
544
  };
387
545
  }
388
- start = parsed.offset;
389
- }
390
- // Compiled before paging so the notice can say what the grant is, and
391
- // committed only after paging succeeded: a load that fails here gave
392
- // the model no instructions, so it must not have approved anything.
393
- // Idempotent: a continuation call grants the same entries again, and
394
- // the turn's set keeps one copy.
395
- let grant;
396
- if (allowed !== undefined && allowed.length > 0 && context.grantSkillTools) {
397
- grant = context.grantSkillTools({
398
- skill: skill.metadata.name,
399
- allowedTools: allowed,
400
- ...(snapshot.skillDirectory ? { skillDirectory: snapshot.skillDirectory } : {}),
401
- });
402
- }
403
- const notice = (hooksPlan?.notice ? `\n\n[${hooksPlan.notice}]` : '') +
404
- grantNotice(allowed, grant, context.grantSkillTools !== undefined);
405
- const page = pageSkillBody({
406
- snapshot: start === 0 && argsLine ? { ...snapshot, header: argsLine + snapshot.header } : snapshot,
407
- digest,
408
- start,
409
- notice,
410
- maxChars: context.maxToolOutputChars,
411
- });
412
- if (!page) {
546
+ grant?.commit();
547
+ // Live only now that the instructions were delivered, like the grant (a skill
548
+ // that holds commands attached them before it ran them).
549
+ delivered = true;
550
+ if (attachedEarly === undefined)
551
+ hooksPlan?.attach();
552
+ // Kept with the conversation, so a host that continues it later can
553
+ // attach the same hooks again. Once, on the first page of a load.
554
+ let output = page.output;
555
+ if (hooksPlan?.resumable === true && start === 0 && skill.dirPath !== undefined) {
556
+ const kept = context.recordSkillHooks
557
+ ? await context
558
+ .recordSkillHooks({
559
+ skill: skill.metadata.name,
560
+ directory: skill.dirPath,
561
+ grantsWithheld: hooksPlan.withholdGrants,
562
+ ...(context.toolUseId !== undefined ? { toolCallId: context.toolUseId } : {}),
563
+ })
564
+ .catch(() => false)
565
+ : false;
566
+ if (!kept) {
567
+ output += `\n\n[${SKILL_HOOKS_NOT_KEPT}]`;
568
+ }
569
+ }
413
570
  return {
414
- success: false,
415
- output: '',
416
- error: `The model-visible tool-output budget is too small to read "${input.name}" safely. Increase maxToolOutputChars and retry.`,
571
+ success: true,
572
+ output,
573
+ data: {
574
+ skill: skill.metadata.name,
575
+ ...(modelDirectory === undefined ? {} : { directory: modelDirectory }),
576
+ ...(allowed === undefined ? {} : { allowedTools: allowed }),
577
+ ...(grant ? { granted: grant.granted, ignored: grant.ignored } : {}),
578
+ ...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }),
579
+ },
417
580
  };
418
581
  }
419
- grant?.commit();
420
- // Live only now that the instructions were delivered, like the grant.
421
- hooksPlan?.attach();
422
- // Kept with the conversation, so a host that continues it later can
423
- // attach the same hooks again. Once, on the first page of a load.
424
- let output = page.output;
425
- if (hooksPlan?.resumable === true && start === 0 && skill.dirPath !== undefined) {
426
- const kept = context.recordSkillHooks
427
- ? await context
428
- .recordSkillHooks({
429
- skill: skill.metadata.name,
430
- directory: skill.dirPath,
431
- grantsWithheld: hooksPlan.withholdGrants,
432
- ...(context.toolUseId !== undefined ? { toolCallId: context.toolUseId } : {}),
433
- })
434
- .catch(() => false)
435
- : false;
436
- if (!kept) {
437
- output += `\n\n[${SKILL_HOOKS_NOT_KEPT}]`;
438
- }
582
+ finally {
583
+ if (!delivered)
584
+ attachedEarly?.remove();
439
585
  }
440
- return {
441
- success: true,
442
- output,
443
- data: {
444
- skill: skill.metadata.name,
445
- ...(modelDirectory === undefined ? {} : { directory: modelDirectory }),
446
- ...(allowed === undefined ? {} : { allowedTools: allowed }),
447
- ...(grant ? { granted: grant.granted, ignored: grant.ignored } : {}),
448
- ...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }),
449
- },
450
- };
451
586
  },
452
587
  });
453
588
  }
454
589
  /** Said to the model when a skill's hooks could not be written into the conversation's record. */
455
590
  const SKILL_HOOKS_NOT_KEPT = "This conversation could not keep a record of this skill's hooks, so if it is continued later they will not be attached again: load the skill again then.";
591
+ /**
592
+ * What a skill's `allowed-tools` may pre-approve, for its own commands and its
593
+ * grant alike: nothing when the host withheld the pre-approval (a hook that
594
+ * guards its work could not be loaded, or hooks cannot be attached here). One
595
+ * decision, for the inline load and the delegated one.
596
+ */
597
+ function grantedTools(skill, plan) {
598
+ return plan?.withholdGrants ? undefined : parseAllowedTools(skill.metadata.allowedTools);
599
+ }
456
600
  /**
457
601
  * What the host says of the hooks a skill carries, or `undefined` for a skill
458
602
  * that carries none. A registry that cannot read hooks answers with a plan
@@ -545,7 +689,7 @@ function forkedPrompt(header, argsLine, body) {
545
689
  */
546
690
  async function runForkedSkill(input) {
547
691
  const { metadata } = input.skill;
548
- const attached = input.hooks?.attach();
692
+ const attached = input.hooks?.attach(input.hooksPrompt !== undefined ? { prompt: input.hooksPrompt } : undefined);
549
693
  let ended = false;
550
694
  const end = () => {
551
695
  if (ended)