@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
@@ -0,0 +1,103 @@
1
+ /**
2
+ * How a host runs the commands a skill's text holds, through the machinery it
3
+ * already has.
4
+ *
5
+ * - {@link skillShellHookVerdict} reads what `pre_skill_shell_command` hooks
6
+ * answered into one verdict for one command.
7
+ * - {@link createSkillShellHook} asks those hooks, and answers `undefined`
8
+ * when none is attached so nothing is asked of nobody.
9
+ * - {@link createPreToolUseShellHook} asks the `pre_tool_use` hooks the shell
10
+ * tool's own calls are asked, for a load that has no turn to ask them in.
11
+ * - {@link createToolSkillShellHost} runs a command as a nested call of the
12
+ * shell tool from inside another tool (the `skill` tool): the same
13
+ * authorization gate, the same sandbox and the same tool a model's own call
14
+ * goes through, and no second executor.
15
+ * - {@link skillShellAllow} turns a skill's `allowed-tools` into a
16
+ * pre-approval that holds for the one expansion.
17
+ */
18
+ import type { PluginLifecycleManager } from '../plugin/lifecycle.js';
19
+ import type { PluginHookResult, PluginSkillShellInfo } from '../types/plugin/index.js';
20
+ import type { ToolContext, ToolDispatchOptions } from '../types/tool/index.js';
21
+ import { type InlineShellHookVerdict, type InlineShellHost, type InlineShellOutcome } from './inline-shell.js';
22
+ /** The tool a skill's commands run in. */
23
+ export declare const SKILL_SHELL_TOOL_NAME = "bash";
24
+ /** The event a host fires before each command, after permission allowed it. */
25
+ export declare const PRE_SKILL_SHELL_COMMAND_EVENT = "pre_skill_shell_command";
26
+ /** The event the shell tool's own calls are checked by; a load outside a turn asks it too. */
27
+ export declare const PRE_TOOL_USE_EVENT = "pre_tool_use";
28
+ type HookManager = Pick<PluginLifecycleManager, 'executeHooks' | 'listHooks'>;
29
+ /**
30
+ * One command's verdict from every hook's answer.
31
+ *
32
+ * - A stop (`halt`) outranks a refusal, which outranks everything else.
33
+ * - A `skip` refuses this command and nothing else.
34
+ * - An in-process hook that asks for approval, or rewrites the command, is
35
+ * refused: a load cannot wait for a person and never runs a changed command.
36
+ * - A hook that did not answer, that crashed or that ran out of time refuses
37
+ * the command: nothing says it is safe. This is how a `pre_tool_use` hook that
38
+ * times out treats the shell tool's own call.
39
+ */
40
+ export declare function skillShellHookVerdict(results: readonly PluginHookResult[], attached: number): InlineShellHookVerdict;
41
+ export interface SkillShellHookOptions {
42
+ readonly manager: HookManager | undefined;
43
+ readonly sessionId: string;
44
+ readonly turnId?: string;
45
+ readonly signal?: AbortSignal;
46
+ /** The skill or command, where it came from, and who asked for it. */
47
+ readonly info: PluginSkillShellInfo;
48
+ /** The tool name the hook is told. Default `bash`. */
49
+ readonly toolName?: string;
50
+ }
51
+ /**
52
+ * Ask the hooks about one command. `undefined` when the manager has none for
53
+ * the event, so a session with no such hook pays nothing and fires nothing.
54
+ */
55
+ export declare function createSkillShellHook(options: SkillShellHookOptions): ((command: string, toolUseId: string) => Promise<InlineShellHookVerdict>) | undefined;
56
+ export interface PreToolUseShellHookOptions {
57
+ readonly manager: HookManager | undefined;
58
+ readonly sessionId: string;
59
+ readonly turnId?: string;
60
+ readonly signal?: AbortSignal;
61
+ /** The tool name the hook is told. Default `bash`. */
62
+ readonly toolName?: string;
63
+ }
64
+ /**
65
+ * Ask the session's `pre_tool_use` hooks about one command, as they are asked
66
+ * about the shell tool's own call. Inside a turn the executor does it for a
67
+ * nested call; a load outside a turn (a typed command, a headless prompt, a
68
+ * preload) has no executor, so the host asks here. A refusal, a stop, a request
69
+ * for approval, a rewrite, a timeout or a crash all refuse the command: a load
70
+ * cannot wait for a person and never runs a changed command. `undefined` when
71
+ * no such hook is attached.
72
+ */
73
+ export declare function createPreToolUseShellHook(options: PreToolUseShellHookOptions): ((command: string, toolUseId: string) => Promise<InlineShellHookVerdict>) | undefined;
74
+ /**
75
+ * The pre-approval a skill's `allowed-tools` gives to its own commands, for
76
+ * one expansion. Only entries for the shell tool count; any other entry is
77
+ * not read here. Absent when the skill grants the shell tool nothing.
78
+ */
79
+ export declare function skillShellAllow(allowedTools: readonly string[] | undefined, options?: {
80
+ readonly skillDirectory?: string;
81
+ readonly toolName?: string;
82
+ }): ToolDispatchOptions['allow'] | undefined;
83
+ export interface ToolSkillShellHostOptions {
84
+ readonly context: ToolContext;
85
+ readonly allow?: ToolDispatchOptions['allow'];
86
+ readonly toolName?: string;
87
+ }
88
+ /**
89
+ * A host that runs each command by dispatching the shell tool from inside the
90
+ * tool that is loading the text. A command a rule does not allow is refused
91
+ * with the rule's reason, because a person cannot be asked from inside
92
+ * another tool's call.
93
+ */
94
+ export declare function createToolSkillShellHost(options: ToolSkillShellHostOptions): InlineShellHost;
95
+ /** A shell tool result as the host's outcome of one command. */
96
+ export declare function outcomeOf(result: {
97
+ readonly success: boolean;
98
+ readonly output: string;
99
+ readonly error?: string;
100
+ readonly data?: unknown;
101
+ }): InlineShellOutcome;
102
+ export {};
103
+ //# sourceMappingURL=inline-shell-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-shell-host.d.ts","sourceRoot":"","sources":["../../src/skills/inline-shell-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACtF,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC9E,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAEvB,MAAM,mBAAmB,CAAA;AAE1B,0CAA0C;AAC1C,eAAO,MAAM,qBAAqB,SAAS,CAAA;AAE3C,+EAA+E;AAC/E,eAAO,MAAM,6BAA6B,4BAA4B,CAAA;AAEtE,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAKhD,KAAK,WAAW,GAAG,IAAI,CAAC,sBAAsB,EAAE,cAAc,GAAG,WAAW,CAAC,CAAA;AAE7E;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,QAAQ,EAAE,MAAM,GACd,sBAAsB,CAyCxB;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CAAA;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAA;IACnC,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAA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AAED,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,MAAM,EAAE;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,kBAAkB,CA2BrB"}
@@ -0,0 +1,238 @@
1
+ /**
2
+ * How a host runs the commands a skill's text holds, through the machinery it
3
+ * already has.
4
+ *
5
+ * - {@link skillShellHookVerdict} reads what `pre_skill_shell_command` hooks
6
+ * answered into one verdict for one command.
7
+ * - {@link createSkillShellHook} asks those hooks, and answers `undefined`
8
+ * when none is attached so nothing is asked of nobody.
9
+ * - {@link createPreToolUseShellHook} asks the `pre_tool_use` hooks the shell
10
+ * tool's own calls are asked, for a load that has no turn to ask them in.
11
+ * - {@link createToolSkillShellHost} runs a command as a nested call of the
12
+ * shell tool from inside another tool (the `skill` tool): the same
13
+ * authorization gate, the same sandbox and the same tool a model's own call
14
+ * goes through, and no second executor.
15
+ * - {@link skillShellAllow} turns a skill's `allowed-tools` into a
16
+ * pre-approval that holds for the one expansion.
17
+ */
18
+ import { SkillGrantSet, compileSkillGrant } from '../authorization/skill-grant.js';
19
+ import { INLINE_SHELL_REASON_CHARS, splitShellToolOutput, } from './inline-shell.js';
20
+ /** The tool a skill's commands run in. */
21
+ export const SKILL_SHELL_TOOL_NAME = 'bash';
22
+ /** The event a host fires before each command, after permission allowed it. */
23
+ export const PRE_SKILL_SHELL_COMMAND_EVENT = 'pre_skill_shell_command';
24
+ /** The event the shell tool's own calls are checked by; a load outside a turn asks it too. */
25
+ export const PRE_TOOL_USE_EVENT = 'pre_tool_use';
26
+ /** The deadline the lifecycle manager gives a hook before it counts as timed out. */
27
+ const MANAGER_TIMEOUT_MESSAGE = 'Hook timeout';
28
+ /**
29
+ * One command's verdict from every hook's answer.
30
+ *
31
+ * - A stop (`halt`) outranks a refusal, which outranks everything else.
32
+ * - A `skip` refuses this command and nothing else.
33
+ * - An in-process hook that asks for approval, or rewrites the command, is
34
+ * refused: a load cannot wait for a person and never runs a changed command.
35
+ * - A hook that did not answer, that crashed or that ran out of time refuses
36
+ * the command: nothing says it is safe. This is how a `pre_tool_use` hook that
37
+ * times out treats the shell tool's own call.
38
+ */
39
+ export function skillShellHookVerdict(results, attached) {
40
+ if (attached > 0 && results.length === 0) {
41
+ return { kind: 'refuse', reason: "the hook didn't answer" };
42
+ }
43
+ const warnings = [];
44
+ const refusals = [];
45
+ let stop;
46
+ for (const result of results) {
47
+ const notice = 'notice' in result ? result.notice : undefined;
48
+ if (notice)
49
+ warnings.push(notice);
50
+ switch (result.action) {
51
+ case 'skip':
52
+ refusals.push(result.reason);
53
+ break;
54
+ case 'continue':
55
+ if (result.halt !== undefined && stop === undefined)
56
+ stop = result.halt.reason;
57
+ if (result.permission?.decision === 'ask') {
58
+ refusals.push("the hook asked for approval, which a skill can't wait for");
59
+ }
60
+ break;
61
+ case 'modify':
62
+ refusals.push("the hook changed the command, which isn't supported here");
63
+ break;
64
+ case 'error':
65
+ refusals.push(result.message === MANAGER_TIMEOUT_MESSAGE
66
+ ? 'the hook timed out'
67
+ : "the hook couldn't run");
68
+ break;
69
+ default:
70
+ break;
71
+ }
72
+ }
73
+ const warning = warnings.length > 0 ? warnings.join('\n') : undefined;
74
+ if (stop !== undefined)
75
+ return { kind: 'stop', reason: stop };
76
+ if (refusals.length > 0) {
77
+ const reason = refusals.join('; ').slice(0, INLINE_SHELL_REASON_CHARS * 2);
78
+ return { kind: 'refuse', reason, ...(warning ? { warning } : {}) };
79
+ }
80
+ return { kind: 'run', ...(warning ? { warning } : {}) };
81
+ }
82
+ /**
83
+ * Ask the hooks about one command. `undefined` when the manager has none for
84
+ * the event, so a session with no such hook pays nothing and fires nothing.
85
+ */
86
+ export function createSkillShellHook(options) {
87
+ return createShellEventHook(PRE_SKILL_SHELL_COMMAND_EVENT, options, {
88
+ skillShell: options.info,
89
+ });
90
+ }
91
+ /**
92
+ * Ask the session's `pre_tool_use` hooks about one command, as they are asked
93
+ * about the shell tool's own call. Inside a turn the executor does it for a
94
+ * nested call; a load outside a turn (a typed command, a headless prompt, a
95
+ * preload) has no executor, so the host asks here. A refusal, a stop, a request
96
+ * for approval, a rewrite, a timeout or a crash all refuse the command: a load
97
+ * cannot wait for a person and never runs a changed command. `undefined` when
98
+ * no such hook is attached.
99
+ */
100
+ export function createPreToolUseShellHook(options) {
101
+ return createShellEventHook(PRE_TOOL_USE_EVENT, options, {});
102
+ }
103
+ function createShellEventHook(event, options, extra) {
104
+ const manager = options.manager;
105
+ if (manager === undefined)
106
+ return undefined;
107
+ const countAttached = () => manager.listHooks().filter((hook) => hook.event === event).length;
108
+ if (countAttached() === 0)
109
+ return undefined;
110
+ const toolName = options.toolName ?? SKILL_SHELL_TOOL_NAME;
111
+ return async (command, toolUseId) => {
112
+ // Read again for each command: a hook a skill attaches while it loads counts.
113
+ const attached = countAttached();
114
+ if (attached === 0)
115
+ return { kind: 'run' };
116
+ try {
117
+ const results = await manager.executeHooks(event, {
118
+ sessionId: options.sessionId,
119
+ ...(options.turnId !== undefined ? { turnId: options.turnId } : {}),
120
+ toolName,
121
+ toolInput: { command },
122
+ toolCallId: toolUseId,
123
+ ...extra,
124
+ ...(options.signal ? { signal: options.signal } : {}),
125
+ });
126
+ return skillShellHookVerdict(results, attached);
127
+ }
128
+ catch (error) {
129
+ if (options.signal?.aborted)
130
+ throw error;
131
+ return { kind: 'refuse', reason: "the hook couldn't run" };
132
+ }
133
+ };
134
+ }
135
+ /**
136
+ * The pre-approval a skill's `allowed-tools` gives to its own commands, for
137
+ * one expansion. Only entries for the shell tool count; any other entry is
138
+ * not read here. Absent when the skill grants the shell tool nothing.
139
+ */
140
+ export function skillShellAllow(allowedTools, options = {}) {
141
+ if (allowedTools === undefined || allowedTools.length === 0)
142
+ return undefined;
143
+ const toolName = options.toolName ?? SKILL_SHELL_TOOL_NAME;
144
+ const compiled = compileSkillGrant(allowedTools, {
145
+ resolveTool: (name) => name.toLowerCase() === toolName ? { name: toolName, commandArgument: 'command' } : undefined,
146
+ ...(options.skillDirectory ? { skillDirectory: options.skillDirectory } : {}),
147
+ });
148
+ if (compiled.entries.length === 0)
149
+ return undefined;
150
+ const held = new SkillGrantSet();
151
+ held.grant('inline-shell', compiled);
152
+ return (call) => held.coveringSkill(call) !== undefined;
153
+ }
154
+ /** Strip the tool's closing `Error: ...` line off a failed result's text. */
155
+ function withoutErrorLine(text) {
156
+ const at = text.lastIndexOf('\n\nError: ');
157
+ if (at !== -1)
158
+ return text.slice(0, at);
159
+ return text.startsWith('Error: ') ? '' : text;
160
+ }
161
+ /**
162
+ * A host that runs each command by dispatching the shell tool from inside the
163
+ * tool that is loading the text. A command a rule does not allow is refused
164
+ * with the rule's reason, because a person cannot be asked from inside
165
+ * another tool's call.
166
+ */
167
+ export function createToolSkillShellHost(options) {
168
+ const toolName = options.toolName ?? SKILL_SHELL_TOOL_NAME;
169
+ const dispatch = options.context.dispatchTool;
170
+ return {
171
+ async run(command, beforeRun) {
172
+ if (dispatch === undefined) {
173
+ return {
174
+ kind: 'denied',
175
+ reason: 'this turn cannot run a tool from inside another one',
176
+ };
177
+ }
178
+ let hook;
179
+ let result;
180
+ try {
181
+ result = await dispatch(toolName, { command }, {
182
+ ...(options.allow ? { allow: options.allow } : {}),
183
+ beforeRun: async () => {
184
+ const verdict = await beforeRun();
185
+ if (verdict.kind === 'run')
186
+ return undefined;
187
+ hook = verdict;
188
+ return 'refused by a hook';
189
+ },
190
+ });
191
+ }
192
+ catch (error) {
193
+ if (options.context.abortSignal.aborted) {
194
+ return { kind: 'ran', stdout: '', stderr: '', exitCode: null, interrupted: true };
195
+ }
196
+ throw error;
197
+ }
198
+ if (hook !== undefined)
199
+ return { kind: 'hook', verdict: hook };
200
+ return outcomeOf(result);
201
+ },
202
+ };
203
+ }
204
+ /** A shell tool result as the host's outcome of one command. */
205
+ export function outcomeOf(result) {
206
+ const data = result.data !== null && typeof result.data === 'object'
207
+ ? result.data
208
+ : undefined;
209
+ const exitCode = typeof data?.exitCode === 'number' ? data.exitCode : undefined;
210
+ const ran = data !== undefined && ('exitCode' in data || 'timedOut' in data);
211
+ if (!ran && !result.success) {
212
+ return { kind: 'denied', reason: deniedReason(result.error ?? result.output) };
213
+ }
214
+ // Through a nested dispatch a failure's text is in `error` (output and the closing line
215
+ // joined); from the tool itself it is in `output`, with the closing line in `error`.
216
+ const text = result.success
217
+ ? result.output
218
+ : result.output !== ''
219
+ ? result.output
220
+ : withoutErrorLine(result.error ?? '');
221
+ const { stdout, stderr } = splitShellToolOutput(text);
222
+ if (result.success) {
223
+ return { kind: 'ran', stdout, stderr, exitCode: exitCode ?? 0 };
224
+ }
225
+ return {
226
+ kind: 'ran',
227
+ stdout,
228
+ stderr,
229
+ exitCode: exitCode ?? null,
230
+ };
231
+ }
232
+ /** The words after `Tool "x" was not executed.` when that is how the refusal begins. */
233
+ function deniedReason(text) {
234
+ const trimmed = text.replace(/^Error:\s*/, '');
235
+ const match = /^Tool "[^"]*" was not executed\.\s*/.exec(trimmed);
236
+ return (match ? trimmed.slice(match[0].length) : trimmed).trim() || 'refused';
237
+ }
238
+ //# sourceMappingURL=inline-shell-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-shell-host.js","sourceRoot":"","sources":["../../src/skills/inline-shell-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAKlF,OAAO,EACN,yBAAyB,EAIzB,oBAAoB,GACpB,MAAM,mBAAmB,CAAA;AAE1B,0CAA0C;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAA;AAE3C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,6BAA6B,GAAG,yBAAyB,CAAA;AAEtE,8FAA8F;AAC9F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,KAAK,IAAI,EAAE,CAAC,CAAA;IACxC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;IACrD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,IAAI,CAAC,EAAE,CAAA;IAChE,CAAC;IACD,OAAO;QACN,IAAI,EAAE,KAAK;QACX,MAAM;QACN,MAAM;QACN,QAAQ,EAAE,QAAQ,IAAI,IAAI;KAC1B,CAAA;AACF,CAAC;AAED,wFAAwF;AACxF,SAAS,YAAY,CAAC,IAAY;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;IAC9C,MAAM,KAAK,GAAG,qCAAqC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACjE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,SAAS,CAAA;AAC9E,CAAC"}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Shell commands written inside a skill or a custom command, run while the
3
+ * text loads.
4
+ *
5
+ * Two forms, both read by {@link findInlineShell}:
6
+ *
7
+ * - A fenced block opened by a line that is three backticks and a bang, closed
8
+ * by a line of three backticks. Everything between is ONE command, so a
9
+ * multi-line script runs as a single shell call.
10
+ * - Inline: a bang and a backtick span, `!` then a backtick, the command, a
11
+ * backtick, where the bang starts the text or follows whitespace.
12
+ *
13
+ * An ordinary backtick span and an ordinary fence are masked first, so the
14
+ * documentation a skill shows (a command in code font, an example block)
15
+ * never runs. An unterminated shell fence is plain text.
16
+ *
17
+ * This file reads no permission and no file; the one thing it asks of the process is which
18
+ * shell reads a command, when a value lands inside one. {@link expandInlineShell}
19
+ * takes the host's way of running one command (permission check, the hook, the
20
+ * shell tool) and decides everything around it: limits, placeholders, how the
21
+ * output replaces the marker, what fails the load.
22
+ *
23
+ * ## A value never becomes a command
24
+ *
25
+ * The order is: substitute `$ARGUMENTS` and the variables, then read the
26
+ * commands. A value a person typed (or a model sent), and any path or name the
27
+ * host wrote into the text, is therefore text that the reader sees, so
28
+ * {@link substituteEscaped} does two things. Outside a command it rewrites the
29
+ * shapes that would begin one. Inside a command it quotes the value for the
30
+ * shell, one word at a time, so it is read as arguments and never as shell
31
+ * syntax. It refuses the load if a value managed to add a command anyway.
32
+ */
33
+ import type { ShellDialect } from '../types/tool/index.js';
34
+ /** Most commands one expansion may run. */
35
+ export declare const INLINE_SHELL_MAX_COMMANDS = 256;
36
+ /** Longest command text, in characters. */
37
+ export declare const INLINE_SHELL_MAX_COMMAND_CHARS = 32768;
38
+ /** Most characters of command output one expansion may put into the text. */
39
+ export declare const INLINE_SHELL_MAX_OUTPUT_CHARS = 4000000;
40
+ /** The longest reason from a hook that is shown. */
41
+ export declare const INLINE_SHELL_REASON_CHARS = 500;
42
+ /** The longest command shown in a warning. */
43
+ export declare const INLINE_SHELL_COMMAND_SHOWN_CHARS = 80;
44
+ export type InlineShellKind = 'fence' | 'inline';
45
+ /** One command found in a text: the marker as written, and where it sits. */
46
+ export interface InlineShellMarker {
47
+ readonly kind: InlineShellKind;
48
+ /** Offset of the first character of the marker, in the normalised text. */
49
+ readonly start: number;
50
+ /** Offset just past the last character of the marker. */
51
+ readonly end: number;
52
+ /** The command, trimmed. */
53
+ readonly command: string;
54
+ /** The marker as written. */
55
+ readonly raw: string;
56
+ }
57
+ /** The text with line endings as `\n`, which is the text every offset refers to. */
58
+ export declare function normalizeInlineShellText(text: string): string;
59
+ /**
60
+ * Every command in the text, in order. Offsets refer to
61
+ * {@link normalizeInlineShellText} of the text; {@link expandInlineShell} does
62
+ * that first, and a caller that splices by hand must do the same.
63
+ */
64
+ export declare function findInlineShell(text: string): InlineShellMarker[];
65
+ /**
66
+ * A value made safe to put into a text that is read for commands afterwards:
67
+ * the shapes that open a command are broken by a space, and a leading bang is
68
+ * escaped so the template's own backtick after it cannot complete one.
69
+ */
70
+ export declare function escapeInlineShell(value: string): string;
71
+ /** A load that cannot go on: the reason is the message, and what to do about it is in it. */
72
+ export declare class InlineShellError extends Error {
73
+ readonly reason: 'failed' | 'interrupted' | 'permission' | 'limit' | 'stopped' | 'injection';
74
+ constructor(message: string, reason: 'failed' | 'interrupted' | 'permission' | 'limit' | 'stopped' | 'injection');
75
+ }
76
+ /**
77
+ * Put values into a template, each escaped, and prove no value added a
78
+ * command. `values` maps the token written in the text (`$ARGUMENTS`) to its
79
+ * value.
80
+ *
81
+ * A value outside a command is rewritten so that no shape of it begins one
82
+ * ({@link escapeInlineShell}). A value inside a command is quoted so the shell
83
+ * reads it as data ({@link quoteForCommand}), by where it sits: a person's
84
+ * `-n 5` stays two arguments, and `x; touch f #` stays words of an argument
85
+ * list. Throws {@link InlineShellError} when a value cannot be made safe, or the
86
+ * substituted text holds more commands than the template does.
87
+ */
88
+ export declare function substituteEscaped(template: string, values: Readonly<Record<string, string>>, options?: {
89
+ readonly dialect?: ShellDialect;
90
+ }): string;
91
+ export declare const SHELL_OFF_PLACEHOLDER = "[shell commands are turned off (disableSkillShellExecution), so this command was not run]";
92
+ export declare const SHELL_REMOTE_PLACEHOLDER = "[shell commands are not run in text that comes from a tool server or another remote source, so this command was not run]";
93
+ export declare const SHELL_UNTRUSTED_PLACEHOLDER = "[shell commands are not run until this folder is trusted, so this command was not run]";
94
+ export declare const SHELL_PRELOAD_PLACEHOLDER = "[shell commands in a skill preloaded into an agent are not run when the agent is set up, so this command was not run]";
95
+ /** Why a command in this text may not run at all, before any is tried. */
96
+ export type InlineShellBlock = 'off' | 'remote' | 'untrusted' | 'preload';
97
+ /** What a hook said about one command. */
98
+ export type InlineShellHookVerdict = {
99
+ readonly kind: 'run';
100
+ readonly warning?: string;
101
+ }
102
+ /** Not this command; the rest of the text loads. */
103
+ | {
104
+ readonly kind: 'refuse';
105
+ readonly reason?: string;
106
+ readonly warning?: string;
107
+ }
108
+ /** The whole load stops. */
109
+ | {
110
+ readonly kind: 'stop';
111
+ readonly reason: string;
112
+ };
113
+ /** How the host ended one command. */
114
+ export type InlineShellOutcome =
115
+ /** The permission rules said no, or would have asked a person who is not there. */
116
+ {
117
+ readonly kind: 'denied';
118
+ readonly reason: string;
119
+ }
120
+ /** The hook, which runs after permission and before the shell, refused or stopped. */
121
+ | {
122
+ readonly kind: 'hook';
123
+ readonly verdict: Exclude<InlineShellHookVerdict, {
124
+ kind: 'run';
125
+ }>;
126
+ } | {
127
+ readonly kind: 'ran';
128
+ readonly stdout: string;
129
+ readonly stderr: string;
130
+ /** Zero is success. `null` when the command did not report one. */
131
+ readonly exitCode: number | null;
132
+ readonly interrupted?: boolean;
133
+ };
134
+ export interface InlineShellHost {
135
+ /**
136
+ * Run one command: check permission, then call `beforeRun`, then start it.
137
+ * `beforeRun` must be called exactly when the permission check has allowed
138
+ * the command and the command has not started, and a verdict other than
139
+ * `run` must end the call with `{ kind: 'hook', verdict }`.
140
+ */
141
+ run(command: string, beforeRun: () => Promise<InlineShellHookVerdict>): Promise<InlineShellOutcome>;
142
+ }
143
+ export interface InlineShellOptions {
144
+ readonly host: InlineShellHost;
145
+ /** The skill or command, for the line a warning names. */
146
+ readonly commandName: string;
147
+ /** Set when no command may run; each is replaced by the matching placeholder. */
148
+ readonly block?: InlineShellBlock;
149
+ /** Absent when no hook is attached for the event: nothing is asked. */
150
+ readonly hook?: (command: string) => Promise<InlineShellHookVerdict>;
151
+ /** A line for the person, for a refused command and a warning from a hook. */
152
+ readonly warn?: (line: string) => void;
153
+ readonly signal?: AbortSignal;
154
+ }
155
+ /** Trimmed standard output, then a `[stderr]` block when there is any standard error. */
156
+ export declare function shapeShellOutput(stdout: string, stderr: string): string;
157
+ /**
158
+ * Run every command in `text` and put each one's output where it was written.
159
+ *
160
+ * Commands run one after another, in order. A load fails (throws
161
+ * {@link InlineShellError}) on: more than 256 commands, a command over 32 KB,
162
+ * more than 4 MB of output in all, a permission refusal, a non-zero exit, an
163
+ * interrupt, or a hook's request to stop. A hook that refuses one command
164
+ * leaves `[not run: blocked by hook: <reason>]` in its place and loads the rest.
165
+ */
166
+ export declare function expandInlineShell(text: string, options: InlineShellOptions): Promise<string>;
167
+ /**
168
+ * Turn the text of a bash tool result into its two streams. The tool labels
169
+ * them `STDOUT:` and `STDERR:`; a result with neither label is all standard
170
+ * output, and `(no output)` is nothing.
171
+ */
172
+ export declare function splitShellToolOutput(output: string): {
173
+ stdout: string;
174
+ stderr: string;
175
+ };
176
+ //# sourceMappingURL=inline-shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-shell.d.ts","sourceRoot":"","sources":["../../src/skills/inline-shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1D,2CAA2C;AAC3C,eAAO,MAAM,yBAAyB,MAAM,CAAA;AAC5C,2CAA2C;AAC3C,eAAO,MAAM,8BAA8B,QAAS,CAAA;AACpD,6EAA6E;AAC7E,eAAO,MAAM,6BAA6B,UAAY,CAAA;AACtD,oDAAoD;AACpD,eAAO,MAAM,yBAAyB,MAAM,CAAA;AAC5C,8CAA8C;AAC9C,eAAO,MAAM,gCAAgC,KAAK,CAAA;AAElD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEhD,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,yDAAyD;IACzD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,QAAQ,CAAC,OAAO,EAAE,MA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