@namzu/sdk 70.0.0 → 71.0.1

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 (409) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/dist/authorization/bare-repository.d.ts +21 -0
  3. package/dist/authorization/bare-repository.d.ts.map +1 -0
  4. package/dist/authorization/bare-repository.js +62 -0
  5. package/dist/authorization/bare-repository.js.map +1 -0
  6. package/dist/authorization/command-line.d.ts.map +1 -1
  7. package/dist/authorization/command-line.js +10 -3
  8. package/dist/authorization/command-line.js.map +1 -1
  9. package/dist/authorization/gate.d.ts +7 -0
  10. package/dist/authorization/gate.d.ts.map +1 -1
  11. package/dist/authorization/gate.js +4 -0
  12. package/dist/authorization/gate.js.map +1 -1
  13. package/dist/authorization/protected-paths.d.ts.map +1 -1
  14. package/dist/authorization/protected-paths.js +46 -1
  15. package/dist/authorization/protected-paths.js.map +1 -1
  16. package/dist/authorization/readonly-commands.d.ts +17 -5
  17. package/dist/authorization/readonly-commands.d.ts.map +1 -1
  18. package/dist/authorization/readonly-commands.js +77 -6
  19. package/dist/authorization/readonly-commands.js.map +1 -1
  20. package/dist/authorization/readonly-flags.d.ts.map +1 -1
  21. package/dist/authorization/readonly-flags.js +98 -0
  22. package/dist/authorization/readonly-flags.js.map +1 -1
  23. package/dist/authorization/shell-lexer.d.ts +15 -0
  24. package/dist/authorization/shell-lexer.d.ts.map +1 -1
  25. package/dist/authorization/shell-lexer.js +108 -3
  26. package/dist/authorization/shell-lexer.js.map +1 -1
  27. package/dist/authorization/shell-paths.d.ts.map +1 -1
  28. package/dist/authorization/shell-paths.js +276 -0
  29. package/dist/authorization/shell-paths.js.map +1 -1
  30. package/dist/authorization/shell-session-state.d.ts +47 -0
  31. package/dist/authorization/shell-session-state.d.ts.map +1 -0
  32. package/dist/authorization/shell-session-state.js +70 -0
  33. package/dist/authorization/shell-session-state.js.map +1 -0
  34. package/dist/authorization/shell-session.d.ts +9 -0
  35. package/dist/authorization/shell-session.d.ts.map +1 -0
  36. package/dist/authorization/shell-session.js +19 -0
  37. package/dist/authorization/shell-session.js.map +1 -0
  38. package/dist/authorization/skill-grant.d.ts.map +1 -1
  39. package/dist/authorization/skill-grant.js +1 -0
  40. package/dist/authorization/skill-grant.js.map +1 -1
  41. package/dist/compaction/extractor.d.ts.map +1 -1
  42. package/dist/compaction/extractor.js +2 -0
  43. package/dist/compaction/extractor.js.map +1 -1
  44. package/dist/compaction/hooks.d.ts +16 -0
  45. package/dist/compaction/hooks.d.ts.map +1 -1
  46. package/dist/compaction/hooks.js +26 -1
  47. package/dist/compaction/hooks.js.map +1 -1
  48. package/dist/compaction/manual.d.ts.map +1 -1
  49. package/dist/compaction/manual.js +6 -1
  50. package/dist/compaction/manual.js.map +1 -1
  51. package/dist/compaction/restore.d.ts.map +1 -1
  52. package/dist/compaction/restore.js +3 -2
  53. package/dist/compaction/restore.js.map +1 -1
  54. package/dist/config/runtime.d.ts +2 -0
  55. package/dist/config/runtime.d.ts.map +1 -1
  56. package/dist/config/runtime.js +7 -0
  57. package/dist/config/runtime.js.map +1 -1
  58. package/dist/connector/mcp/client.d.ts +7 -0
  59. package/dist/connector/mcp/client.d.ts.map +1 -1
  60. package/dist/connector/mcp/client.js +54 -4
  61. package/dist/connector/mcp/client.js.map +1 -1
  62. package/dist/connector/web/types.d.ts +8 -0
  63. package/dist/connector/web/types.d.ts.map +1 -1
  64. package/dist/constants/compaction/index.d.ts.map +1 -1
  65. package/dist/constants/compaction/index.js +1 -1
  66. package/dist/constants/compaction/index.js.map +1 -1
  67. package/dist/execution/code-runtime/worker-program.d.ts +1 -1
  68. package/dist/execution/code-runtime/worker-program.d.ts.map +1 -1
  69. package/dist/execution/code-runtime/worker-program.js +9 -5
  70. package/dist/execution/code-runtime/worker-program.js.map +1 -1
  71. package/dist/execution/local.d.ts.map +1 -1
  72. package/dist/execution/local.js +6 -1
  73. package/dist/execution/local.js.map +1 -1
  74. package/dist/peers/index.d.ts +2 -2
  75. package/dist/peers/index.d.ts.map +1 -1
  76. package/dist/peers/index.js +1 -1
  77. package/dist/peers/index.js.map +1 -1
  78. package/dist/peers/record.d.ts +74 -0
  79. package/dist/peers/record.d.ts.map +1 -1
  80. package/dist/peers/record.js +41 -1
  81. package/dist/peers/record.js.map +1 -1
  82. package/dist/peers/registry.d.ts.map +1 -1
  83. package/dist/peers/registry.js +20 -3
  84. package/dist/peers/registry.js.map +1 -1
  85. package/dist/plugin/bin-path.d.ts +41 -0
  86. package/dist/plugin/bin-path.d.ts.map +1 -0
  87. package/dist/plugin/bin-path.js +146 -0
  88. package/dist/plugin/bin-path.js.map +1 -0
  89. package/dist/plugin/common-layout/read.js +1 -1
  90. package/dist/plugin/common-layout/read.js.map +1 -1
  91. package/dist/plugin/common-layout-names.d.ts.map +1 -1
  92. package/dist/plugin/common-layout-names.js +0 -1
  93. package/dist/plugin/common-layout-names.js.map +1 -1
  94. package/dist/plugin/hook-module/scan.d.ts +16 -0
  95. package/dist/plugin/hook-module/scan.d.ts.map +1 -1
  96. package/dist/plugin/hook-module/scan.js +67 -2
  97. package/dist/plugin/hook-module/scan.js.map +1 -1
  98. package/dist/plugin/hook-module/worker-source.d.ts.map +1 -1
  99. package/dist/plugin/hook-module/worker-source.js +56 -0
  100. package/dist/plugin/hook-module/worker-source.js.map +1 -1
  101. package/dist/plugin/lifecycle.d.ts +21 -0
  102. package/dist/plugin/lifecycle.d.ts.map +1 -1
  103. package/dist/plugin/lifecycle.js +64 -0
  104. package/dist/plugin/lifecycle.js.map +1 -1
  105. package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -1
  106. package/dist/plugin/shell-hook-tool-names.js +1 -0
  107. package/dist/plugin/shell-hook-tool-names.js.map +1 -1
  108. package/dist/plugin/shell-hook.d.ts +1 -1
  109. package/dist/plugin/shell-hook.d.ts.map +1 -1
  110. package/dist/plugin/shell-hook.js +22 -4
  111. package/dist/plugin/shell-hook.js.map +1 -1
  112. package/dist/public-runtime.d.ts +8 -6
  113. package/dist/public-runtime.d.ts.map +1 -1
  114. package/dist/public-runtime.js +8 -5
  115. package/dist/public-runtime.js.map +1 -1
  116. package/dist/public-tools.d.ts +6 -2
  117. package/dist/public-tools.d.ts.map +1 -1
  118. package/dist/public-tools.js +6 -2
  119. package/dist/public-tools.js.map +1 -1
  120. package/dist/public-types.d.ts +2 -2
  121. package/dist/public-types.d.ts.map +1 -1
  122. package/dist/runtime/jobs/monitor-stream.d.ts +9 -1
  123. package/dist/runtime/jobs/monitor-stream.d.ts.map +1 -1
  124. package/dist/runtime/jobs/monitor-stream.js +13 -4
  125. package/dist/runtime/jobs/monitor-stream.js.map +1 -1
  126. package/dist/runtime/jobs/registry.d.ts +4 -0
  127. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  128. package/dist/runtime/jobs/registry.js +12 -2
  129. package/dist/runtime/jobs/registry.js.map +1 -1
  130. package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -1
  131. package/dist/runtime/query/auto-review/git-status.js +3 -2
  132. package/dist/runtime/query/auto-review/git-status.js.map +1 -1
  133. package/dist/runtime/query/executor.d.ts +16 -6
  134. package/dist/runtime/query/executor.d.ts.map +1 -1
  135. package/dist/runtime/query/executor.js +60 -5
  136. package/dist/runtime/query/executor.js.map +1 -1
  137. package/dist/runtime/query/index.d.ts.map +1 -1
  138. package/dist/runtime/query/index.js +2 -2
  139. package/dist/runtime/query/index.js.map +1 -1
  140. package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
  141. package/dist/runtime/query/iteration/outstanding-work.js +14 -4
  142. package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
  143. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  144. package/dist/runtime/query/iteration/phases/compaction.js +11 -1
  145. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  146. package/dist/runtime/query/iteration/phases/tool-review.d.ts +2 -0
  147. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  148. package/dist/runtime/query/iteration/phases/tool-review.js +19 -8
  149. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  150. package/dist/runtime/query/path-escalation.d.ts +6 -0
  151. package/dist/runtime/query/path-escalation.d.ts.map +1 -1
  152. package/dist/runtime/query/path-escalation.js +58 -4
  153. package/dist/runtime/query/path-escalation.js.map +1 -1
  154. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  155. package/dist/runtime/query/review-policy.js +4 -2
  156. package/dist/runtime/query/review-policy.js.map +1 -1
  157. package/dist/runtime/query/steering.d.ts +11 -2
  158. package/dist/runtime/query/steering.d.ts.map +1 -1
  159. package/dist/runtime/query/steering.js +18 -4
  160. package/dist/runtime/query/steering.js.map +1 -1
  161. package/dist/sandbox/provider/local.d.ts.map +1 -1
  162. package/dist/sandbox/provider/local.js +3 -1
  163. package/dist/sandbox/provider/local.js.map +1 -1
  164. package/dist/schedules/describe.d.ts.map +1 -1
  165. package/dist/schedules/describe.js +2 -0
  166. package/dist/schedules/describe.js.map +1 -1
  167. package/dist/schedules/evaluate.d.ts +4 -0
  168. package/dist/schedules/evaluate.d.ts.map +1 -1
  169. package/dist/schedules/evaluate.js +26 -1
  170. package/dist/schedules/evaluate.js.map +1 -1
  171. package/dist/schedules/index.d.ts +3 -1
  172. package/dist/schedules/index.d.ts.map +1 -1
  173. package/dist/schedules/index.js +2 -1
  174. package/dist/schedules/index.js.map +1 -1
  175. package/dist/schedules/next-fire.d.ts.map +1 -1
  176. package/dist/schedules/next-fire.js +10 -0
  177. package/dist/schedules/next-fire.js.map +1 -1
  178. package/dist/schedules/spec.d.ts +9 -0
  179. package/dist/schedules/spec.d.ts.map +1 -1
  180. package/dist/schedules/spec.js +33 -0
  181. package/dist/schedules/spec.js.map +1 -1
  182. package/dist/schedules/types.d.ts +32 -4
  183. package/dist/schedules/types.d.ts.map +1 -1
  184. package/dist/schedules/types.js +3 -2
  185. package/dist/schedules/types.js.map +1 -1
  186. package/dist/schedules/watch.d.ts +23 -0
  187. package/dist/schedules/watch.d.ts.map +1 -0
  188. package/dist/schedules/watch.js +46 -0
  189. package/dist/schedules/watch.js.map +1 -0
  190. package/dist/session/workspace/git-worktree.d.ts.map +1 -1
  191. package/dist/session/workspace/git-worktree.js +2 -1
  192. package/dist/session/workspace/git-worktree.js.map +1 -1
  193. package/dist/skills/arguments.d.ts +58 -0
  194. package/dist/skills/arguments.d.ts.map +1 -0
  195. package/dist/skills/arguments.js +208 -0
  196. package/dist/skills/arguments.js.map +1 -0
  197. package/dist/skills/index.d.ts +3 -1
  198. package/dist/skills/index.d.ts.map +1 -1
  199. package/dist/skills/index.js +1 -0
  200. package/dist/skills/index.js.map +1 -1
  201. package/dist/skills/inline-shell.d.ts +17 -0
  202. package/dist/skills/inline-shell.d.ts.map +1 -1
  203. package/dist/skills/inline-shell.js +1232 -14
  204. package/dist/skills/inline-shell.js.map +1 -1
  205. package/dist/store/session-index/index.d.ts +5 -0
  206. package/dist/store/session-index/index.d.ts.map +1 -1
  207. package/dist/store/session-index/index.js +5 -1
  208. package/dist/store/session-index/index.js.map +1 -1
  209. package/dist/store/session-index/rebuild.d.ts +18 -0
  210. package/dist/store/session-index/rebuild.d.ts.map +1 -1
  211. package/dist/store/session-index/rebuild.js +79 -5
  212. package/dist/store/session-index/rebuild.js.map +1 -1
  213. package/dist/store/session-index/sqlite.d.ts +8 -0
  214. package/dist/store/session-index/sqlite.d.ts.map +1 -1
  215. package/dist/store/session-index/sqlite.js +23 -1
  216. package/dist/store/session-index/sqlite.js.map +1 -1
  217. package/dist/tools/builtins/bash-cwd.d.ts.map +1 -1
  218. package/dist/tools/builtins/bash-cwd.js +2 -0
  219. package/dist/tools/builtins/bash-cwd.js.map +1 -1
  220. package/dist/tools/builtins/bash.d.ts.map +1 -1
  221. package/dist/tools/builtins/bash.js +79 -11
  222. package/dist/tools/builtins/bash.js.map +1 -1
  223. package/dist/tools/builtins/exit-semantics.d.ts +6 -0
  224. package/dist/tools/builtins/exit-semantics.d.ts.map +1 -1
  225. package/dist/tools/builtins/exit-semantics.js +10 -0
  226. package/dist/tools/builtins/exit-semantics.js.map +1 -1
  227. package/dist/tools/builtins/glob.d.ts.map +1 -1
  228. package/dist/tools/builtins/glob.js +68 -13
  229. package/dist/tools/builtins/glob.js.map +1 -1
  230. package/dist/tools/builtins/grep.d.ts.map +1 -1
  231. package/dist/tools/builtins/grep.js +37 -12
  232. package/dist/tools/builtins/grep.js.map +1 -1
  233. package/dist/tools/builtins/index.d.ts +11 -0
  234. package/dist/tools/builtins/index.d.ts.map +1 -1
  235. package/dist/tools/builtins/index.js +14 -0
  236. package/dist/tools/builtins/index.js.map +1 -1
  237. package/dist/tools/builtins/job.js +1 -1
  238. package/dist/tools/builtins/job.js.map +1 -1
  239. package/dist/tools/builtins/monitor.d.ts +1 -1
  240. package/dist/tools/builtins/monitor.d.ts.map +1 -1
  241. package/dist/tools/builtins/monitor.js +4 -2
  242. package/dist/tools/builtins/monitor.js.map +1 -1
  243. package/dist/tools/builtins/notebook-cells.d.ts +31 -0
  244. package/dist/tools/builtins/notebook-cells.d.ts.map +1 -0
  245. package/dist/tools/builtins/notebook-cells.js +160 -0
  246. package/dist/tools/builtins/notebook-cells.js.map +1 -0
  247. package/dist/tools/builtins/notebook-edit.d.ts +8 -0
  248. package/dist/tools/builtins/notebook-edit.d.ts.map +1 -0
  249. package/dist/tools/builtins/notebook-edit.js +249 -0
  250. package/dist/tools/builtins/notebook-edit.js.map +1 -0
  251. package/dist/tools/builtins/notebook-guard.d.ts.map +1 -1
  252. package/dist/tools/builtins/notebook-guard.js +2 -1
  253. package/dist/tools/builtins/notebook-guard.js.map +1 -1
  254. package/dist/tools/builtins/push-notification.d.ts +49 -0
  255. package/dist/tools/builtins/push-notification.d.ts.map +1 -0
  256. package/dist/tools/builtins/push-notification.js +107 -0
  257. package/dist/tools/builtins/push-notification.js.map +1 -0
  258. package/dist/tools/builtins/read-file.d.ts.map +1 -1
  259. package/dist/tools/builtins/read-file.js +8 -3
  260. package/dist/tools/builtins/read-file.js.map +1 -1
  261. package/dist/tools/builtins/read-media.d.ts.map +1 -1
  262. package/dist/tools/builtins/read-media.js +2 -1
  263. package/dist/tools/builtins/read-media.js.map +1 -1
  264. package/dist/tools/builtins/read-render.d.ts.map +1 -1
  265. package/dist/tools/builtins/read-render.js +5 -3
  266. package/dist/tools/builtins/read-render.js.map +1 -1
  267. package/dist/tools/builtins/search-support.d.ts +6 -4
  268. package/dist/tools/builtins/search-support.d.ts.map +1 -1
  269. package/dist/tools/builtins/search-support.js +15 -3
  270. package/dist/tools/builtins/search-support.js.map +1 -1
  271. package/dist/tools/builtins/skill.d.ts.map +1 -1
  272. package/dist/tools/builtins/skill.js +28 -8
  273. package/dist/tools/builtins/skill.js.map +1 -1
  274. package/dist/tools/builtins/sleep-guard.d.ts +20 -0
  275. package/dist/tools/builtins/sleep-guard.d.ts.map +1 -1
  276. package/dist/tools/builtins/sleep-guard.js +125 -1
  277. package/dist/tools/builtins/sleep-guard.js.map +1 -1
  278. package/dist/tools/builtins/wait-for-job.js +1 -1
  279. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  280. package/dist/tools/builtins/web.d.ts +2 -0
  281. package/dist/tools/builtins/web.d.ts.map +1 -1
  282. package/dist/tools/builtins/web.js +97 -3
  283. package/dist/tools/builtins/web.js.map +1 -1
  284. package/dist/tools/command-shell.d.ts +50 -0
  285. package/dist/tools/command-shell.d.ts.map +1 -1
  286. package/dist/tools/command-shell.js +145 -0
  287. package/dist/tools/command-shell.js.map +1 -1
  288. package/dist/tools/env-scrub.d.ts +2 -0
  289. package/dist/tools/env-scrub.d.ts.map +1 -1
  290. package/dist/tools/env-scrub.js +15 -1
  291. package/dist/tools/env-scrub.js.map +1 -1
  292. package/dist/tools/git-config-env.d.ts +55 -0
  293. package/dist/tools/git-config-env.d.ts.map +1 -0
  294. package/dist/tools/git-config-env.js +130 -0
  295. package/dist/tools/git-config-env.js.map +1 -0
  296. package/dist/tools/schedules/schedule-tool.d.ts +7 -0
  297. package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
  298. package/dist/tools/schedules/schedule-tool.js +72 -3
  299. package/dist/tools/schedules/schedule-tool.js.map +1 -1
  300. package/dist/tools/schedules/types.d.ts +38 -2
  301. package/dist/tools/schedules/types.d.ts.map +1 -1
  302. package/dist/types/connector/mcp.d.ts +24 -0
  303. package/dist/types/connector/mcp.d.ts.map +1 -1
  304. package/dist/types/message/index.d.ts +21 -1
  305. package/dist/types/message/index.d.ts.map +1 -1
  306. package/dist/types/message/index.js +37 -2
  307. package/dist/types/message/index.js.map +1 -1
  308. package/dist/types/plugin/index.d.ts +10 -2
  309. package/dist/types/plugin/index.d.ts.map +1 -1
  310. package/dist/types/plugin/index.js.map +1 -1
  311. package/dist/types/tool/index.d.ts +6 -0
  312. package/dist/types/tool/index.d.ts.map +1 -1
  313. package/dist/types/tool/index.js.map +1 -1
  314. package/dist/utils/plain-terminal-text.d.ts +21 -0
  315. package/dist/utils/plain-terminal-text.d.ts.map +1 -0
  316. package/dist/utils/plain-terminal-text.js +156 -0
  317. package/dist/utils/plain-terminal-text.js.map +1 -0
  318. package/package.json +1 -1
  319. package/src/authorization/bare-repository.ts +70 -0
  320. package/src/authorization/command-line.ts +18 -4
  321. package/src/authorization/gate.ts +11 -0
  322. package/src/authorization/protected-paths.ts +45 -1
  323. package/src/authorization/readonly-commands.ts +75 -6
  324. package/src/authorization/readonly-flags.ts +103 -0
  325. package/src/authorization/shell-lexer.ts +126 -3
  326. package/src/authorization/shell-paths.ts +386 -0
  327. package/src/authorization/shell-session-state.ts +97 -0
  328. package/src/authorization/shell-session.ts +23 -0
  329. package/src/authorization/skill-grant.ts +1 -0
  330. package/src/compaction/extractor.ts +1 -0
  331. package/src/compaction/hooks.ts +43 -1
  332. package/src/compaction/manual.ts +6 -0
  333. package/src/compaction/restore.ts +3 -2
  334. package/src/config/runtime.ts +7 -0
  335. package/src/connector/mcp/client.ts +61 -4
  336. package/src/connector/web/types.ts +8 -0
  337. package/src/constants/compaction/index.ts +1 -1
  338. package/src/execution/code-runtime/worker-program.ts +9 -5
  339. package/src/execution/local.ts +6 -1
  340. package/src/peers/index.ts +8 -2
  341. package/src/peers/record.ts +45 -1
  342. package/src/peers/registry.ts +21 -5
  343. package/src/plugin/bin-path.ts +149 -0
  344. package/src/plugin/common-layout/read.ts +1 -1
  345. package/src/plugin/common-layout-names.ts +0 -1
  346. package/src/plugin/hook-module/scan.ts +74 -2
  347. package/src/plugin/hook-module/worker-source.ts +56 -0
  348. package/src/plugin/lifecycle.ts +67 -0
  349. package/src/plugin/shell-hook-tool-names.ts +1 -0
  350. package/src/plugin/shell-hook.ts +23 -4
  351. package/src/public-runtime.ts +21 -0
  352. package/src/public-tools.ts +32 -1
  353. package/src/public-types.ts +3 -1
  354. package/src/runtime/jobs/monitor-stream.ts +18 -4
  355. package/src/runtime/jobs/registry.ts +22 -2
  356. package/src/runtime/query/auto-review/git-status.ts +3 -2
  357. package/src/runtime/query/executor.ts +79 -5
  358. package/src/runtime/query/index.ts +5 -2
  359. package/src/runtime/query/iteration/outstanding-work.ts +22 -4
  360. package/src/runtime/query/iteration/phases/compaction.ts +14 -1
  361. package/src/runtime/query/iteration/phases/tool-review.ts +24 -7
  362. package/src/runtime/query/path-escalation.ts +52 -4
  363. package/src/runtime/query/review-policy.ts +5 -2
  364. package/src/runtime/query/steering.ts +32 -4
  365. package/src/sandbox/provider/local.ts +3 -1
  366. package/src/schedules/describe.ts +2 -0
  367. package/src/schedules/evaluate.ts +29 -1
  368. package/src/schedules/index.ts +9 -1
  369. package/src/schedules/next-fire.ts +9 -0
  370. package/src/schedules/spec.ts +42 -0
  371. package/src/schedules/types.ts +33 -3
  372. package/src/schedules/watch.ts +71 -0
  373. package/src/session/workspace/git-worktree.ts +3 -1
  374. package/src/skills/arguments.ts +250 -0
  375. package/src/skills/index.ts +10 -0
  376. package/src/skills/inline-shell.ts +1268 -14
  377. package/src/store/session-index/index.ts +10 -1
  378. package/src/store/session-index/rebuild.ts +81 -5
  379. package/src/store/session-index/sqlite.ts +30 -1
  380. package/src/tools/builtins/bash-cwd.ts +2 -0
  381. package/src/tools/builtins/bash.ts +93 -13
  382. package/src/tools/builtins/exit-semantics.ts +10 -0
  383. package/src/tools/builtins/glob.ts +79 -15
  384. package/src/tools/builtins/grep.ts +37 -10
  385. package/src/tools/builtins/index.ts +15 -0
  386. package/src/tools/builtins/job.ts +1 -1
  387. package/src/tools/builtins/monitor.ts +4 -2
  388. package/src/tools/builtins/notebook-cells.ts +196 -0
  389. package/src/tools/builtins/notebook-edit.ts +280 -0
  390. package/src/tools/builtins/notebook-guard.ts +2 -1
  391. package/src/tools/builtins/push-notification.ts +138 -0
  392. package/src/tools/builtins/read-file.ts +9 -3
  393. package/src/tools/builtins/read-media.ts +2 -1
  394. package/src/tools/builtins/read-render.ts +5 -3
  395. package/src/tools/builtins/search-support.ts +17 -3
  396. package/src/tools/builtins/skill.ts +27 -7
  397. package/src/tools/builtins/sleep-guard.ts +128 -1
  398. package/src/tools/builtins/wait-for-job.ts +1 -1
  399. package/src/tools/builtins/web.ts +100 -3
  400. package/src/tools/command-shell.ts +166 -0
  401. package/src/tools/env-scrub.ts +13 -1
  402. package/src/tools/git-config-env.ts +143 -0
  403. package/src/tools/schedules/schedule-tool.ts +79 -3
  404. package/src/tools/schedules/types.ts +47 -9
  405. package/src/types/connector/mcp.ts +25 -0
  406. package/src/types/message/index.ts +53 -1
  407. package/src/types/plugin/index.ts +10 -2
  408. package/src/types/tool/index.ts +6 -0
  409. package/src/utils/plain-terminal-text.ts +142 -0
@@ -0,0 +1,149 @@
1
+ import { existsSync, lstatSync, readdirSync, realpathSync } from 'node:fs'
2
+ import { delimiter, isAbsolute, join, relative } from 'node:path'
3
+ import { readEnvironmentEntry, setEnvironmentEntry } from '../utils/process-environment.js'
4
+
5
+ /** What a plugin's `bin/` folder came to: a folder to put on PATH, or the reason it is not. */
6
+ export type PluginBinResolution =
7
+ | { readonly dir: string }
8
+ | { readonly dir?: undefined; readonly refused: string }
9
+
10
+ function inside(root: string, candidate: string): boolean {
11
+ const rel = relative(root, candidate)
12
+ return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel)
13
+ }
14
+
15
+ // A folder whose name could be read by a shell as more than a path is left off.
16
+ const UNSAFE_PATH_CHARACTERS = /[:"'$`\\\n\r;]/u
17
+
18
+ /**
19
+ * The folder of a plugin's programs, when it is safe to put on a shell's PATH.
20
+ *
21
+ * Nothing here reads a file's contents. A plugin without a `bin/` folder is
22
+ * simply absent (undefined). A `bin/` that is a link leaving the plugin, or
23
+ * that holds a link leaving the plugin, is refused whole: PATH lookup follows
24
+ * links, so one such entry would run a program the install never listed.
25
+ */
26
+ export function resolvePluginBinDirectory(rootDir: string): PluginBinResolution | undefined {
27
+ let realRoot: string
28
+ let bin: string
29
+ try {
30
+ realRoot = realpathSync(rootDir)
31
+ const lexical = join(realRoot, 'bin')
32
+ try {
33
+ lstatSync(lexical)
34
+ } catch {
35
+ return undefined
36
+ }
37
+ bin = realpathSync(lexical)
38
+ } catch {
39
+ return undefined
40
+ }
41
+ if (!inside(realRoot, bin)) return { refused: 'bin/ resolves outside the plugin folder' }
42
+ try {
43
+ if (!lstatSync(bin).isDirectory()) return undefined
44
+ } catch {
45
+ return undefined
46
+ }
47
+ if (UNSAFE_PATH_CHARACTERS.test(bin) || bin.includes(delimiter)) {
48
+ return { refused: 'the folder name holds a character a shell could read as more than a path' }
49
+ }
50
+ let entries: import('node:fs').Dirent[]
51
+ try {
52
+ entries = readdirSync(bin, { withFileTypes: true })
53
+ } catch {
54
+ return undefined
55
+ }
56
+ for (const entry of entries) {
57
+ if (!entry.isSymbolicLink()) continue
58
+ let target: string
59
+ try {
60
+ target = realpathSync(join(bin, entry.name))
61
+ } catch {
62
+ // A dangling link runs nothing now; refusing it keeps the rule simple.
63
+ return { refused: `bin/${entry.name} is a link that does not resolve` }
64
+ }
65
+ if (!inside(realRoot, target)) {
66
+ return { refused: `bin/${entry.name} is a link that leaves the plugin folder` }
67
+ }
68
+ }
69
+ return { dir: bin }
70
+ }
71
+
72
+ /**
73
+ * Add folders to the END of an environment's PATH, so a program already on
74
+ * PATH (a system command a permission rule or the read-only list names) always
75
+ * wins over a plugin's program of the same name. Folders already on PATH are
76
+ * not added twice. An environment without PATH is returned unchanged.
77
+ */
78
+ export function appendDirsToPath(
79
+ env: Record<string, string>,
80
+ dirs: readonly string[],
81
+ platform: NodeJS.Platform = process.platform,
82
+ ): Record<string, string> {
83
+ if (dirs.length === 0) return env
84
+ const entry = readEnvironmentEntry(env, 'PATH', platform)
85
+ if (!entry) return env
86
+ const [name, value] = entry
87
+ const sep = platform === 'win32' ? ';' : ':'
88
+ const present = new Set(value.split(sep))
89
+ const added = dirs.filter((dir) => !dir.includes(sep) && !present.has(dir))
90
+ if (added.length === 0) return env
91
+ setEnvironmentEntry(env, name, [value, ...added].filter(Boolean).join(sep), platform)
92
+ return env
93
+ }
94
+
95
+ type BinSource = { enabledBinDirs(): readonly string[] }
96
+ const binSources = new Set<WeakRef<BinSource>>()
97
+
98
+ /**
99
+ * Record where the enabled plugins' bin folders come from, so a check that has
100
+ * no turn context (the read-only command list) can ask whether a plugin
101
+ * supplies a program. Held weakly: a manager that is dropped drops out.
102
+ */
103
+ export function registerPluginBinSource(source: BinSource): void {
104
+ binSources.add(new WeakRef(source))
105
+ }
106
+
107
+ /**
108
+ * Whether an enabled plugin's bin folder holds a program called `name`. The
109
+ * folders sit at the end of PATH, so on a machine that lacks a command the
110
+ * read-only list names (`rg`, `tree`, `jq`) the plugin's file is what runs;
111
+ * such a name must not be treated as read-only.
112
+ */
113
+ export function pluginSuppliesProgram(
114
+ name: string,
115
+ platform: NodeJS.Platform = process.platform,
116
+ ): boolean {
117
+ if (binSources.size === 0) return false
118
+ for (const ref of [...binSources]) {
119
+ const source = ref.deref()
120
+ if (source === undefined) {
121
+ binSources.delete(ref)
122
+ continue
123
+ }
124
+ let dirs: readonly string[]
125
+ try {
126
+ dirs = source.enabledBinDirs()
127
+ } catch {
128
+ // A source that cannot say is not trusted to say "none".
129
+ return true
130
+ }
131
+ for (const dir of dirs) {
132
+ try {
133
+ if (platform === 'win32') {
134
+ const want = name.toLowerCase()
135
+ for (const file of readdirSync(dir)) {
136
+ const lower = file.toLowerCase()
137
+ const dot = lower.lastIndexOf('.')
138
+ if (lower === want || (dot > 0 && lower.slice(0, dot) === want)) return true
139
+ }
140
+ } else if (existsSync(join(dir, name))) {
141
+ return true
142
+ }
143
+ } catch {
144
+ return true
145
+ }
146
+ }
147
+ }
148
+ return false
149
+ }
@@ -1080,7 +1080,7 @@ async function readMerged(
1080
1080
  code: 'component-unsupported',
1081
1081
  field: dir,
1082
1082
  path: dir,
1083
- message: `${dir}/ (${count}) is not used by Namzu.${dir === 'bin' ? ' Programs in bin/ are not put on your path.' : ''}`,
1083
+ message: `${dir}/ (${count}) is not used by Namzu.`,
1084
1084
  })
1085
1085
  }
1086
1086
  }
@@ -36,7 +36,6 @@ export const COMMON_UNUSED_DIRS: readonly string[] = [
36
36
  'themes',
37
37
  'monitors',
38
38
  'workflows',
39
- 'bin',
40
39
  ]
41
40
 
42
41
  /**
@@ -831,6 +831,66 @@ interface Edit {
831
831
  * file's neighbours, exports become assignments, and nothing else changes, so a
832
832
  * line number in an error is the line in the author's file.
833
833
  */
834
+ /** The wrapper the worker compiles around a file's text, character for character. */
835
+ export const WORKER_WRAPPER_HEAD = '(function (__exports, __import) {"use strict";'
836
+ export const WORKER_WRAPPER_TAIL = '\n})'
837
+
838
+ type Spans = { type: string; start: number; end: number }[]
839
+
840
+ /**
841
+ * The tokens the parser itself consumed, not the standalone tokenizer's: the
842
+ * tokenizer guesses whether `/` opens a regular expression from the token
843
+ * before it, and the parser reads it again where the grammar says an expression
844
+ * starts, so the two disagree after `)`, `}` and a few keywords. Throws when the
845
+ * text does not parse as the given kind.
846
+ */
847
+ function tokenSpans(text: string, sourceType: 'module' | 'script'): Spans {
848
+ const spans: Spans = []
849
+ acorn.parse(text, {
850
+ ecmaVersion: 'latest',
851
+ sourceType,
852
+ onToken: (token) => {
853
+ spans.push({ type: token.type.label, start: token.start, end: token.end })
854
+ },
855
+ })
856
+ return spans
857
+ }
858
+
859
+ /**
860
+ * The scan parses a module; the worker compiles a script, and a script reads
861
+ * `<!--` and a line-start `-->` as comments. Read the exact text the worker
862
+ * compiles both ways: where the two token lists differ, something is code to
863
+ * one reader and a comment to the other. Returns the line of the first
864
+ * difference, 0 for none, and -1 when the text cannot be tokenized.
865
+ */
866
+ export function htmlCommentDivergence(source: string): number {
867
+ const text = WORKER_WRAPPER_HEAD + source + WORKER_WRAPPER_TAIL
868
+ let asModule: Spans
869
+ let asScript: Spans
870
+ try {
871
+ asModule = tokenSpans(text, 'module')
872
+ asScript = tokenSpans(text, 'script')
873
+ } catch {
874
+ return -1
875
+ }
876
+ const length = Math.min(asModule.length, asScript.length)
877
+ let at = -1
878
+ for (let i = 0; i < length; i++) {
879
+ const a = asModule[i] as Spans[number]
880
+ const b = asScript[i] as Spans[number]
881
+ if (a.type !== b.type || a.start !== b.start || a.end !== b.end) {
882
+ at = Math.min(a.start, b.start)
883
+ break
884
+ }
885
+ }
886
+ if (at === -1 && asModule.length === asScript.length) return 0
887
+ if (at === -1) {
888
+ const longer = asModule.length > asScript.length ? asModule : asScript
889
+ at = (longer[length] as Spans[number]).start
890
+ }
891
+ return text.slice(0, at).split('\n').length
892
+ }
893
+
834
894
  function rewrite(code: string, ast: AnyNode, resolved: ReadonlyMap<string, string>): string {
835
895
  const edits: Edit[] = []
836
896
  const prelude: string[] = []
@@ -979,9 +1039,21 @@ export function scanHookModule(root: string, entry: string): HookModuleScan {
979
1039
  const target = resolveImport(state, rel, item.specifier)
980
1040
  if (target !== undefined) resolved.set(item.specifier, target)
981
1041
  }
982
- files[rel] = rewrite(analysis.code, analysis.ast, resolved)
1042
+ const text = rewrite(analysis.code, analysis.ast, resolved)
1043
+ const divergence = htmlCommentDivergence(text)
1044
+ if (divergence !== 0) {
1045
+ refuse(
1046
+ state,
1047
+ rel,
1048
+ Math.max(divergence, 1),
1049
+ divergence < 0
1050
+ ? `${rel}: the text cannot be read the way it will run.`
1051
+ : `${rel}: a <!-- or --> that the module reads as code and the runtime reads as a comment (line ${divergence}).`,
1052
+ )
1053
+ }
1054
+ files[rel] = text
983
1055
  }
984
- program = { entry: entryRel, files }
1056
+ if (state.refusals.length === 0) program = { entry: entryRel, files }
985
1057
  }
986
1058
  const calls = state.calls.map((call, index) => {
987
1059
  const at = state.callStarts[index]
@@ -603,6 +603,54 @@ for (const key of ['prepareStackTrace', 'stackTraceLimit']) {
603
603
  }
604
604
  }
605
605
 
606
+ // A rejected import() hands the module an error the engine made in the worker's realm. The scan refuses
607
+ // import() in a module, so it is a second line of defence: freeze that realm's shared prototypes, so
608
+ // nothing set on an error's chain reaches the next dispatch.
609
+ {
610
+ const shared = [
611
+ Object,
612
+ Function,
613
+ Array,
614
+ Error,
615
+ TypeError,
616
+ RangeError,
617
+ SyntaxError,
618
+ ReferenceError,
619
+ EvalError,
620
+ URIError,
621
+ Promise,
622
+ Symbol,
623
+ Object.getPrototypeOf(Uint8Array),
624
+ ]
625
+ for (const item of shared) {
626
+ for (const target of [item, item.prototype]) {
627
+ try {
628
+ if (target !== undefined && target !== null) Object.freeze(target)
629
+ } catch (error) {
630
+ // Already fixed, or not ours to fix: nothing more to do.
631
+ }
632
+ }
633
+ }
634
+ }
635
+
636
+ // The error the engine makes for a refused import() has a class prototype of its own, below the ones above.
637
+ // Make one in a throwaway context and freeze its whole chain; the rejection settles before any message.
638
+ {
639
+ const scratch = vm.createContext(Object.create(null))
640
+ new vm.Script('import("node:fs")').runInContext(scratch).then(
641
+ () => {},
642
+ (error) => {
643
+ for (let at = error; at !== null && at !== undefined; at = Object.getPrototypeOf(at)) {
644
+ try {
645
+ Object.freeze(at)
646
+ } catch (inner) {
647
+ // Not ours to fix: nothing more to do.
648
+ }
649
+ }
650
+ },
651
+ )
652
+ }
653
+
606
654
  const send = (json) => {
607
655
  try {
608
656
  parentPort.postMessage(JSON.parse(json))
@@ -618,10 +666,13 @@ const messageOf = (error) =>
618
666
 
619
667
  // Source text in, a function of the context out; a failure comes back as its message, never as an object.
620
668
  let context
669
+ let refuseImport
621
670
  const evaluate = (rel, source) => {
622
671
  try {
623
672
  const script = new vm.Script('(function (__exports, __import) {"use strict";' + source + '\n})', {
624
673
  filename: 'plugin:' + rel,
674
+ // Made inside the context, so what an import() would call is not a worker-realm function.
675
+ importModuleDynamically: refuseImport,
625
676
  })
626
677
  return script.runInContext(context)
627
678
  } catch (error) {
@@ -648,6 +699,11 @@ function start() {
648
699
  codeGeneration: { strings: false, wasm: false },
649
700
  })
650
701
  prepareContext()
702
+ refuseImport = vm.runInContext(
703
+ "'use strict'; (function () { throw new Error('import() is not available in a hooks module') })",
704
+ context,
705
+ { filename: 'plugin:import' },
706
+ )
651
707
  receive = vm.runInContext(BOOTSTRAP, context, { filename: 'plugin:bootstrap' })(send, evaluate)
652
708
  freezeIntrinsics()
653
709
  }
@@ -45,6 +45,7 @@ import { toErrorMessage } from '../utils/error.js'
45
45
  import { generatePluginId } from '../utils/id.js'
46
46
  import { SCOPE_ATTRIBUTE } from '../utils/log/types.js'
47
47
  import type { Logger } from '../utils/logger.js'
48
+ import { registerPluginBinSource, resolvePluginBinDirectory } from './bin-path.js'
48
49
  import type { LayoutFinding } from './common-layout/types.js'
49
50
  import { type DefinedPlugin, definePlugin } from './define.js'
50
51
  import { assertEnableable, loadPluginManifestWithFindings } from './loader.js'
@@ -75,6 +76,8 @@ interface PluginAdmission {
75
76
 
76
77
  const DEFAULT_PLUGIN_MCP_CONNECT_TIMEOUT_MS = 10_000
77
78
  const PLUGIN_MCP_CLOSE_TIMEOUT_MS = 5_000
79
+ /** Sessions whose post-compaction hook text is kept at once; older ones are let go. */
80
+ const MAX_COMPACTION_CONTEXT_SESSIONS = 16
78
81
 
79
82
  /** One deadline across handshake and all initial discovery requests. */
80
83
  async function beforePluginMcpDeadline<T>(
@@ -403,6 +406,7 @@ export class PluginLifecycleManager {
403
406
  private readonly skillRegistry: SkillRegistry | undefined
404
407
 
405
408
  constructor(config: PluginLifecycleManagerConfig) {
409
+ registerPluginBinSource(this)
406
410
  this.pluginRegistry = config.pluginRegistry
407
411
  this.skillRegistry = config.skillRegistry
408
412
  this.scopeRoots = Object.freeze({ ...config.scopeRoots })
@@ -604,6 +608,39 @@ export class PluginLifecycleManager {
604
608
  }
605
609
  }
606
610
 
611
+ private readonly compactionContext = new Map<string, string>()
612
+
613
+ /**
614
+ * Keep what the `session_start` hooks said after a compaction pass (source
615
+ * `compact`) of one session, for the host to put in front of the model on
616
+ * that session's next turn. Keyed by session, so a sub-agent that shares
617
+ * this manager and compacts does not hand its text to its parent. A later
618
+ * pass of the same session replaces it.
619
+ */
620
+ noteCompactionContext(sessionId: string, text: string): void {
621
+ // Only the host's own session ever takes its text; a child session's entry
622
+ // is never taken, so the map is bounded and the oldest entry leaves first.
623
+ this.compactionContext.delete(sessionId)
624
+ this.compactionContext.set(sessionId, text)
625
+ while (this.compactionContext.size > MAX_COMPACTION_CONTEXT_SESSIONS) {
626
+ const oldest = this.compactionContext.keys().next().value
627
+ if (oldest === undefined) break
628
+ this.compactionContext.delete(oldest)
629
+ }
630
+ }
631
+
632
+ /** The text {@link noteCompactionContext} kept for a session, handed over once. */
633
+ takeCompactionContext(sessionId: string): string | undefined {
634
+ const text = this.compactionContext.get(sessionId)
635
+ this.compactionContext.delete(sessionId)
636
+ return text
637
+ }
638
+
639
+ /** Drop what a session kept, for a conversation that ended before its next turn. */
640
+ dropCompactionContext(sessionId: string): void {
641
+ this.compactionContext.delete(sessionId)
642
+ }
643
+
607
644
  private notifyHooksChanged(): void {
608
645
  for (const listener of [...this.hooksChangedListeners]) {
609
646
  try {
@@ -1295,6 +1332,36 @@ export class PluginLifecycleManager {
1295
1332
  }
1296
1333
  }
1297
1334
 
1335
+ /**
1336
+ * The `bin/` folders of the plugins that are enabled right now, for the end
1337
+ * of a shell command's PATH. Read each call, so turning a plugin off takes
1338
+ * its programs off the next command. A folder that is not safe (see
1339
+ * {@link resolvePluginBinDirectory}) is left out and said once per plugin.
1340
+ */
1341
+ enabledBinDirs(): readonly string[] {
1342
+ const dirs: string[] = []
1343
+ for (const pluginId of this.pluginContributions.keys()) {
1344
+ const admission = this.pluginAdmissions.get(pluginId)
1345
+ if (!admission || admission.inCode) continue
1346
+ const found = resolvePluginBinDirectory(admission.rootDir)
1347
+ if (found === undefined) continue
1348
+ if (found.dir === undefined) {
1349
+ if (!this.binRefusalsSaid.has(pluginId)) {
1350
+ this.binRefusalsSaid.add(pluginId)
1351
+ this.log.warn('Plugin bin/ left off PATH', {
1352
+ 'namzu.plugin.name': admission.manifest.name,
1353
+ 'exception.message': found.refused,
1354
+ })
1355
+ }
1356
+ continue
1357
+ }
1358
+ dirs.push(found.dir)
1359
+ }
1360
+ return dirs
1361
+ }
1362
+
1363
+ private readonly binRefusalsSaid = new Set<PluginId>()
1364
+
1298
1365
  disable(pluginId: PluginId): Promise<void> {
1299
1366
  return this.serializeLifecycle(pluginId, () => this.disableOwned(pluginId))
1300
1367
  }
@@ -26,6 +26,7 @@ export const SHELL_HOOK_WRITTEN_TOOL_NAMES: Readonly<Record<string, string>> = O
26
26
  ls: 'LS',
27
27
  lsp: 'LSP',
28
28
  monitor: 'Monitor',
29
+ notebook_edit: 'NotebookEdit',
29
30
  read: 'Read',
30
31
  search_tools: 'ToolSearch',
31
32
  skill: 'Skill',
@@ -24,7 +24,7 @@
24
24
  * same facts as `NAMZU_HOOK_EVENT`, `NAMZU_SESSION_ID`, `NAMZU_TURN_ID`,
25
25
  * `NAMZU_TOOL_NAME` and, when the input names a file, `NAMZU_TOOL_PATH`;
26
26
  * `NAMZU_PROJECT_DIR` is the folder the session was started for.
27
- * `session_start` also sends `source` (`startup`, `resume` or `clear`) and
27
+ * `session_start` also sends `source` (`startup`, `resume`, `clear`, `fork` or `compact`) and
28
28
  * `session_end` `reason` (`exit`, `replaced` or `clear`).
29
29
  *
30
30
  * `session_start` and `session_end` run outside any turn, so they carry no
@@ -121,6 +121,7 @@ import {
121
121
  } from '../authorization/skill-grant.js'
122
122
  import { withSessionChildMarker } from '../process/session-child.js'
123
123
  import { spawnHostShell } from '../tools/command-shell.js'
124
+ import { withSafeGitConfig } from '../tools/git-config-env.js'
124
125
  import type { PluginId } from '../types/ids/index.js'
125
126
  import type {
126
127
  PluginCompactionInfo,
@@ -376,6 +377,7 @@ const WRITTEN_TOOL_NAMES: Readonly<Record<string, string>> = Object.freeze({
376
377
  write: 'Write',
377
378
  edit: 'Edit',
378
379
  multiedit: 'MultiEdit',
380
+ notebookedit: 'NotebookEdit',
379
381
  bash: 'Bash',
380
382
  grep: 'Grep',
381
383
  glob: 'Glob',
@@ -1087,13 +1089,14 @@ export function runShellHook(
1087
1089
  ? // The exec form: no shell reads `command` or any argument.
1088
1090
  spawn(placed.command, [...placed.args], {
1089
1091
  cwd: input.cwd,
1090
- env: withSessionChildMarker(env),
1092
+ env: withSessionChildMarker(withSafeGitConfig(env)),
1091
1093
  stdio: ['pipe', 'pipe', 'pipe'],
1092
1094
  detached,
1093
1095
  })
1094
1096
  : spawnHostShell(placed.command, {
1095
1097
  cwd: input.cwd,
1096
- env,
1098
+ // A hook's own `git status` in a planted folder must not run its program.
1099
+ env: withSafeGitConfig(env),
1097
1100
  stdio: ['pipe', 'pipe', 'pipe'],
1098
1101
  detached,
1099
1102
  // A hook has always run under `sh`, whatever shell the `bash` tool
@@ -1262,7 +1265,7 @@ function readRewrittenInput(
1262
1265
  function pathOf(toolInput: unknown): string | undefined {
1263
1266
  if (toolInput === null || typeof toolInput !== 'object') return undefined
1264
1267
  const record = toolInput as Record<string, unknown>
1265
- for (const key of ['path', 'file_path', 'filePath']) {
1268
+ for (const key of ['path', 'file_path', 'filePath', 'notebook_path']) {
1266
1269
  const value = record[key]
1267
1270
  if (typeof value === 'string' && value.length > 0) return value
1268
1271
  }
@@ -1323,6 +1326,8 @@ interface ShellHookReading {
1323
1326
  watchPaths?: readonly string[]
1324
1327
  /** On `elicitation` and `elicitation_result`: the answer the hook gave. */
1325
1328
  elicitation?: PluginElicitationAnswer
1329
+ /** On `permission_denied`: the hook said the call may be tried again. */
1330
+ retry?: boolean
1326
1331
  /** Why the JSON was set aside, when it was. */
1327
1332
  invalid?: string
1328
1333
  }
@@ -1495,6 +1500,12 @@ function readShellHookJson(
1495
1500
  }
1496
1501
  const additional = optionalString('additionalContext', specific)
1497
1502
  if (additional && additional.trim().length > 0) reading.context = additional.trim()
1503
+ if (event === 'permission_denied' && specific.retry !== undefined) {
1504
+ if (typeof specific.retry !== 'boolean') {
1505
+ return { invalid: 'hookSpecificOutput: `retry` must be true or false' }
1506
+ }
1507
+ if (specific.retry) reading.retry = true
1508
+ }
1498
1509
 
1499
1510
  if (event === 'elicitation' || event === 'elicitation_result') {
1500
1511
  const action = specific.action
@@ -1997,6 +2008,14 @@ export function shellHookVerdict(
1997
2008
  ...(reading.permission ? { permission: reading.permission } : {}),
1998
2009
  }
1999
2010
  }
2011
+ case 'permission_denied':
2012
+ // The refusal stands; the hook can only say the call may be tried again.
2013
+ return {
2014
+ action: 'continue',
2015
+ ...(reading.retry ? { retryable: true } : {}),
2016
+ ...(reading.halt ? { halt: reading.halt } : {}),
2017
+ ...(reading.notice ? { notice: reading.notice } : {}),
2018
+ }
2000
2019
  default:
2001
2020
  // Nothing here can be changed by a verdict, but a stop request still
2002
2021
  // can end the turn, and a warning still reaches the operator.
@@ -257,6 +257,8 @@ export {
257
257
  // can assert its variables are ones the host-bash scrub will withhold —
258
258
  // the check that stops the two tables drifting apart.
259
259
  export { isCredentialEnvKey } from './constants/credential-env-keys.js'
260
+ // Names the host wrote on purpose (the user's settings `env` block): the host-bash scrub keeps them.
261
+ export { setDeliberateEnvKeys } from './tools/env-scrub.js'
260
262
 
261
263
  export {
262
264
  createToolPresenter,
@@ -309,6 +311,7 @@ export {
309
311
  } from './utils/shell-compress.js'
310
312
  export { createChildAbortController } from './utils/abort.js'
311
313
  export { memoizeAsync } from './utils/memoize.js'
314
+ export { plainTerminalText } from './utils/plain-terminal-text.js'
312
315
  export {
313
316
  NAMZU_TMPDIR_ENV,
314
317
  type PrivateTempRootOptions,
@@ -407,6 +410,7 @@ export {
407
410
  SteeringBinding,
408
411
  attachSteering,
409
412
  capMonitorNotifications,
413
+ formatJobExitNotice,
410
414
  formatMonitorEnd,
411
415
  formatMonitorEvent,
412
416
  formatSteeringNote,
@@ -590,6 +594,11 @@ export {
590
594
  shapeShellOutput,
591
595
  splitShellToolOutput,
592
596
  substituteEscaped,
597
+ SKILL_ARGUMENTS_LINE_LABEL,
598
+ SKILL_ARGUMENTS_SHELL_READ_MAX_CHARS,
599
+ fillArguments,
600
+ splitSkillArguments,
601
+ takesSkillArguments,
593
602
  PRE_SKILL_SHELL_COMMAND_EVENT,
594
603
  SKILL_SHELL_TOOL_NAME,
595
604
  createPreToolUseShellHook,
@@ -607,6 +616,9 @@ export type {
607
616
  InlineShellMarker,
608
617
  InlineShellOptions,
609
618
  InlineShellOutcome,
619
+ FillArgumentsOptions,
620
+ PlaceholderRead,
621
+ PlaceholderReader,
610
622
  PreToolUseShellHookOptions,
611
623
  SkillShellHookOptions,
612
624
  ToolSkillShellHostOptions,
@@ -952,10 +964,16 @@ export {
952
964
  nextFireTime,
953
965
  parseCronExpression,
954
966
  parseDuration,
967
+ parseScheduleExpiry,
955
968
  parseScheduleSpec,
969
+ parseWatchSpec,
956
970
  previousFireTime,
957
971
  SCHEDULE_CATCH_UP_WINDOW_MS,
958
972
  SCHEDULE_LATE_GRACE_MS,
973
+ SCHEDULE_WATCH_DEFAULT_INTERVAL_MS,
974
+ SCHEDULE_WATCH_DEFAULT_MAX_EVENTS_PER_HOUR,
975
+ SCHEDULE_WATCH_MAX_EVENTS_PER_HOUR,
976
+ SCHEDULE_WATCH_MIN_INTERVAL_MS,
959
977
  ScheduleValidationError,
960
978
  upcomingFireTimes,
961
979
  validateTimeZone,
@@ -1503,6 +1521,8 @@ export {
1503
1521
  createUserMessage,
1504
1522
  isProjectInstructionMessageSource,
1505
1523
  isRuntimeContextMessageSource,
1524
+ isRuntimeContextOrigin,
1525
+ RUNTIME_CONTEXT_ORIGIN_KINDS,
1506
1526
  isModelContentOmission,
1507
1527
  MAX_PROJECT_INSTRUCTION_SOURCE_FILES,
1508
1528
  RUNTIME_CONTEXT_MESSAGE_KINDS,
@@ -2181,6 +2201,7 @@ export {
2181
2201
  OUTSTANDING_EXPIRY_MS,
2182
2202
  PEER_PROTOCOL_VERSION,
2183
2203
  PEER_RECORD_VERSION,
2204
+ PEER_AGENTS_MAX,
2184
2205
  PEER_TRAIL_MAX,
2185
2206
  PeerAddressError,
2186
2207
  PeerClient,
@@ -50,7 +50,7 @@ export type { UntrustedEnvelope, WrapUntrustedOptions } from './tools/untrusted-
50
50
  export { UnsafeWritePathError, atomicWriteFile } from './tools/builtins/atomic-write-file.js'
51
51
  export type { AtomicWriteOptions } from './tools/builtins/atomic-write-file.js'
52
52
 
53
- export { getBuiltinTools } from './tools/builtins/index.js'
53
+ export { getBuiltinTools, getNotebookTools } from './tools/builtins/index.js'
54
54
  // A host compiling operator permissions has a tool name and needs an argument
55
55
  // to attach a pattern to. Without one it can only match against the serialised
56
56
  // input, which is how an `allow` for `git status*` came to approve
@@ -63,11 +63,19 @@ export { builtinCommandArguments, commandArgumentOf } from './tools/command-argu
63
63
  export {
64
64
  type CommandShell,
65
65
  type CommandShellProbe,
66
+ type ScriptShellName,
66
67
  WINDOWS_BASH_GUIDANCE,
67
68
  WINDOWS_CMD_FALLBACK_NOTICE,
68
69
  findCommandShell,
69
70
  findCommandShellForDialect,
70
71
  findGitBash,
72
+ findScriptShell,
73
+ defaultScriptShellName,
74
+ hostDefaultScriptShellName,
75
+ installedScriptShell,
76
+ powershellArgs,
77
+ POWERSHELL_MAX_SCRIPT_CHARS,
78
+ windowsShellOverrideProblem,
71
79
  hostCommandShell,
72
80
  isWindowsBash,
73
81
  rewriteWindowsNullRedirect,
@@ -78,9 +86,21 @@ export {
78
86
  spawnHostShell,
79
87
  withoutBashStartup,
80
88
  } from './tools/command-shell.js'
89
+ // The settings every git a session starts carries, so a host that runs git itself uses the same ones.
90
+ export {
91
+ type GitConfigEntry,
92
+ SAFE_GIT_CONFIG,
93
+ hostGitConfig,
94
+ hostGitEnv,
95
+ isGitProgram,
96
+ withGitConfig,
97
+ withHostGitConfig,
98
+ withSafeGitConfig,
99
+ } from './tools/git-config-env.js'
81
100
  export { ReadFileTool } from './tools/builtins/read-file.js'
82
101
  export { WriteFileTool } from './tools/builtins/write-file.js'
83
102
  export { EditTool, dryRunEdit } from './tools/builtins/edit.js'
103
+ export { NotebookEditTool } from './tools/builtins/notebook-edit.js'
84
104
  export {
85
105
  BashTool,
86
106
  type ExecHostShellProgress,
@@ -183,6 +203,17 @@ export type { RunCodeToolOptions } from './tools/builtins/run-code.js'
183
203
  export { LsTool } from './tools/builtins/ls.js'
184
204
  export { SearchToolsTool } from './tools/builtins/search-tools.js'
185
205
  export { PresentFileTool } from './tools/builtins/present-file.js'
206
+ export {
207
+ createPushNotificationTool,
208
+ PUSH_NOTIFICATION_MAX_CHARS,
209
+ PUSH_NOTIFICATION_MIN_INTERVAL_MS,
210
+ PUSH_NOTIFICATION_TOOL_NAME,
211
+ pushNotificationLine,
212
+ } from './tools/builtins/push-notification.js'
213
+ export type {
214
+ PushNotificationOutcome,
215
+ PushNotificationToolOptions,
216
+ } from './tools/builtins/push-notification.js'
186
217
  export { VerifyOutputsTool } from './tools/builtins/verify-outputs.js'
187
218
  export {
188
219
  ViewImageTool,