@namzu/sdk 69.4.0 → 71.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (436) hide show
  1. package/CHANGELOG.md +161 -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 +24 -6
  14. package/dist/authorization/protected-paths.d.ts.map +1 -1
  15. package/dist/authorization/protected-paths.js +83 -10
  16. package/dist/authorization/protected-paths.js.map +1 -1
  17. package/dist/authorization/readonly-commands.d.ts +17 -5
  18. package/dist/authorization/readonly-commands.d.ts.map +1 -1
  19. package/dist/authorization/readonly-commands.js +77 -6
  20. package/dist/authorization/readonly-commands.js.map +1 -1
  21. package/dist/authorization/readonly-flags.d.ts.map +1 -1
  22. package/dist/authorization/readonly-flags.js +98 -0
  23. package/dist/authorization/readonly-flags.js.map +1 -1
  24. package/dist/authorization/shell-lexer.d.ts +15 -0
  25. package/dist/authorization/shell-lexer.d.ts.map +1 -1
  26. package/dist/authorization/shell-lexer.js +370 -2
  27. package/dist/authorization/shell-lexer.js.map +1 -1
  28. package/dist/authorization/shell-paths.d.ts.map +1 -1
  29. package/dist/authorization/shell-paths.js +276 -0
  30. package/dist/authorization/shell-paths.js.map +1 -1
  31. package/dist/authorization/shell-session-state.d.ts +47 -0
  32. package/dist/authorization/shell-session-state.d.ts.map +1 -0
  33. package/dist/authorization/shell-session-state.js +70 -0
  34. package/dist/authorization/shell-session-state.js.map +1 -0
  35. package/dist/authorization/shell-session.d.ts +9 -0
  36. package/dist/authorization/shell-session.d.ts.map +1 -0
  37. package/dist/authorization/shell-session.js +19 -0
  38. package/dist/authorization/shell-session.js.map +1 -0
  39. package/dist/authorization/skill-grant.d.ts.map +1 -1
  40. package/dist/authorization/skill-grant.js +1 -0
  41. package/dist/authorization/skill-grant.js.map +1 -1
  42. package/dist/compaction/extractor.d.ts.map +1 -1
  43. package/dist/compaction/extractor.js +2 -0
  44. package/dist/compaction/extractor.js.map +1 -1
  45. package/dist/compaction/hooks.d.ts +16 -0
  46. package/dist/compaction/hooks.d.ts.map +1 -1
  47. package/dist/compaction/hooks.js +26 -1
  48. package/dist/compaction/hooks.js.map +1 -1
  49. package/dist/compaction/manual.d.ts.map +1 -1
  50. package/dist/compaction/manual.js +6 -1
  51. package/dist/compaction/manual.js.map +1 -1
  52. package/dist/compaction/restore.d.ts.map +1 -1
  53. package/dist/compaction/restore.js +3 -2
  54. package/dist/compaction/restore.js.map +1 -1
  55. package/dist/config/runtime.d.ts +2 -0
  56. package/dist/config/runtime.d.ts.map +1 -1
  57. package/dist/config/runtime.js +7 -0
  58. package/dist/config/runtime.js.map +1 -1
  59. package/dist/connector/mcp/client.d.ts +7 -0
  60. package/dist/connector/mcp/client.d.ts.map +1 -1
  61. package/dist/connector/mcp/client.js +54 -4
  62. package/dist/connector/mcp/client.js.map +1 -1
  63. package/dist/connector/web/guarded-fetch.d.ts +30 -0
  64. package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
  65. package/dist/connector/web/guarded-fetch.js +85 -0
  66. package/dist/connector/web/guarded-fetch.js.map +1 -1
  67. package/dist/connector/web/index.d.ts +1 -1
  68. package/dist/connector/web/index.d.ts.map +1 -1
  69. package/dist/connector/web/index.js +1 -1
  70. package/dist/connector/web/index.js.map +1 -1
  71. package/dist/connector/web/types.d.ts +8 -0
  72. package/dist/connector/web/types.d.ts.map +1 -1
  73. package/dist/constants/compaction/index.d.ts.map +1 -1
  74. package/dist/constants/compaction/index.js +1 -1
  75. package/dist/constants/compaction/index.js.map +1 -1
  76. package/dist/execution/code-runtime/worker-program.d.ts +1 -1
  77. package/dist/execution/code-runtime/worker-program.d.ts.map +1 -1
  78. package/dist/execution/code-runtime/worker-program.js +9 -5
  79. package/dist/execution/code-runtime/worker-program.js.map +1 -1
  80. package/dist/execution/local.d.ts.map +1 -1
  81. package/dist/execution/local.js +6 -1
  82. package/dist/execution/local.js.map +1 -1
  83. package/dist/peers/index.d.ts +2 -2
  84. package/dist/peers/index.d.ts.map +1 -1
  85. package/dist/peers/index.js +1 -1
  86. package/dist/peers/index.js.map +1 -1
  87. package/dist/peers/record.d.ts +74 -0
  88. package/dist/peers/record.d.ts.map +1 -1
  89. package/dist/peers/record.js +41 -1
  90. package/dist/peers/record.js.map +1 -1
  91. package/dist/peers/registry.d.ts.map +1 -1
  92. package/dist/peers/registry.js +20 -3
  93. package/dist/peers/registry.js.map +1 -1
  94. package/dist/plugin/bin-path.d.ts +41 -0
  95. package/dist/plugin/bin-path.d.ts.map +1 -0
  96. package/dist/plugin/bin-path.js +146 -0
  97. package/dist/plugin/bin-path.js.map +1 -0
  98. package/dist/plugin/common-layout/read.js +3 -3
  99. package/dist/plugin/common-layout/read.js.map +1 -1
  100. package/dist/plugin/common-layout-names.d.ts.map +1 -1
  101. package/dist/plugin/common-layout-names.js +0 -1
  102. package/dist/plugin/common-layout-names.js.map +1 -1
  103. package/dist/plugin/hook-module/capabilities.d.ts +12 -0
  104. package/dist/plugin/hook-module/capabilities.d.ts.map +1 -1
  105. package/dist/plugin/hook-module/capabilities.js +82 -10
  106. package/dist/plugin/hook-module/capabilities.js.map +1 -1
  107. package/dist/plugin/hook-module/consent.d.ts +11 -0
  108. package/dist/plugin/hook-module/consent.d.ts.map +1 -1
  109. package/dist/plugin/hook-module/consent.js +31 -0
  110. package/dist/plugin/hook-module/consent.js.map +1 -1
  111. package/dist/plugin/hook-module/host.d.ts.map +1 -1
  112. package/dist/plugin/hook-module/host.js +69 -23
  113. package/dist/plugin/hook-module/host.js.map +1 -1
  114. package/dist/plugin/hook-module/index.d.ts +1 -1
  115. package/dist/plugin/hook-module/index.d.ts.map +1 -1
  116. package/dist/plugin/hook-module/index.js +1 -1
  117. package/dist/plugin/hook-module/index.js.map +1 -1
  118. package/dist/plugin/hook-module/scan.d.ts +16 -0
  119. package/dist/plugin/hook-module/scan.d.ts.map +1 -1
  120. package/dist/plugin/hook-module/scan.js +68 -3
  121. package/dist/plugin/hook-module/scan.js.map +1 -1
  122. package/dist/plugin/hook-module/worker-source.d.ts +5 -4
  123. package/dist/plugin/hook-module/worker-source.d.ts.map +1 -1
  124. package/dist/plugin/hook-module/worker-source.js +254 -28
  125. package/dist/plugin/hook-module/worker-source.js.map +1 -1
  126. package/dist/plugin/lifecycle.d.ts +21 -0
  127. package/dist/plugin/lifecycle.d.ts.map +1 -1
  128. package/dist/plugin/lifecycle.js +64 -0
  129. package/dist/plugin/lifecycle.js.map +1 -1
  130. package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -1
  131. package/dist/plugin/shell-hook-tool-names.js +1 -0
  132. package/dist/plugin/shell-hook-tool-names.js.map +1 -1
  133. package/dist/plugin/shell-hook.d.ts +1 -1
  134. package/dist/plugin/shell-hook.d.ts.map +1 -1
  135. package/dist/plugin/shell-hook.js +22 -4
  136. package/dist/plugin/shell-hook.js.map +1 -1
  137. package/dist/public-runtime.d.ts +11 -9
  138. package/dist/public-runtime.d.ts.map +1 -1
  139. package/dist/public-runtime.js +11 -8
  140. package/dist/public-runtime.js.map +1 -1
  141. package/dist/public-tools.d.ts +7 -3
  142. package/dist/public-tools.d.ts.map +1 -1
  143. package/dist/public-tools.js +7 -3
  144. package/dist/public-tools.js.map +1 -1
  145. package/dist/public-types.d.ts +2 -2
  146. package/dist/public-types.d.ts.map +1 -1
  147. package/dist/runtime/jobs/monitor-stream.d.ts +9 -1
  148. package/dist/runtime/jobs/monitor-stream.d.ts.map +1 -1
  149. package/dist/runtime/jobs/monitor-stream.js +13 -4
  150. package/dist/runtime/jobs/monitor-stream.js.map +1 -1
  151. package/dist/runtime/jobs/registry.d.ts +4 -0
  152. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  153. package/dist/runtime/jobs/registry.js +12 -2
  154. package/dist/runtime/jobs/registry.js.map +1 -1
  155. package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -1
  156. package/dist/runtime/query/auto-review/git-status.js +3 -2
  157. package/dist/runtime/query/auto-review/git-status.js.map +1 -1
  158. package/dist/runtime/query/executor.d.ts +16 -6
  159. package/dist/runtime/query/executor.d.ts.map +1 -1
  160. package/dist/runtime/query/executor.js +135 -15
  161. package/dist/runtime/query/executor.js.map +1 -1
  162. package/dist/runtime/query/index.d.ts.map +1 -1
  163. package/dist/runtime/query/index.js +2 -2
  164. package/dist/runtime/query/index.js.map +1 -1
  165. package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
  166. package/dist/runtime/query/iteration/outstanding-work.js +14 -4
  167. package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
  168. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  169. package/dist/runtime/query/iteration/phases/compaction.js +11 -1
  170. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  171. package/dist/runtime/query/iteration/phases/tool-review.d.ts +2 -0
  172. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  173. package/dist/runtime/query/iteration/phases/tool-review.js +19 -8
  174. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  175. package/dist/runtime/query/path-escalation.d.ts +6 -0
  176. package/dist/runtime/query/path-escalation.d.ts.map +1 -1
  177. package/dist/runtime/query/path-escalation.js +58 -4
  178. package/dist/runtime/query/path-escalation.js.map +1 -1
  179. package/dist/runtime/query/review-policy.d.ts +21 -3
  180. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  181. package/dist/runtime/query/review-policy.js +39 -21
  182. package/dist/runtime/query/review-policy.js.map +1 -1
  183. package/dist/runtime/query/steering.d.ts +11 -2
  184. package/dist/runtime/query/steering.d.ts.map +1 -1
  185. package/dist/runtime/query/steering.js +18 -4
  186. package/dist/runtime/query/steering.js.map +1 -1
  187. package/dist/sandbox/provider/local.d.ts.map +1 -1
  188. package/dist/sandbox/provider/local.js +3 -1
  189. package/dist/sandbox/provider/local.js.map +1 -1
  190. package/dist/schedules/describe.d.ts.map +1 -1
  191. package/dist/schedules/describe.js +2 -0
  192. package/dist/schedules/describe.js.map +1 -1
  193. package/dist/schedules/evaluate.d.ts +4 -0
  194. package/dist/schedules/evaluate.d.ts.map +1 -1
  195. package/dist/schedules/evaluate.js +26 -1
  196. package/dist/schedules/evaluate.js.map +1 -1
  197. package/dist/schedules/index.d.ts +3 -1
  198. package/dist/schedules/index.d.ts.map +1 -1
  199. package/dist/schedules/index.js +2 -1
  200. package/dist/schedules/index.js.map +1 -1
  201. package/dist/schedules/next-fire.d.ts.map +1 -1
  202. package/dist/schedules/next-fire.js +10 -0
  203. package/dist/schedules/next-fire.js.map +1 -1
  204. package/dist/schedules/spec.d.ts +9 -0
  205. package/dist/schedules/spec.d.ts.map +1 -1
  206. package/dist/schedules/spec.js +33 -0
  207. package/dist/schedules/spec.js.map +1 -1
  208. package/dist/schedules/types.d.ts +32 -4
  209. package/dist/schedules/types.d.ts.map +1 -1
  210. package/dist/schedules/types.js +3 -2
  211. package/dist/schedules/types.js.map +1 -1
  212. package/dist/schedules/watch.d.ts +23 -0
  213. package/dist/schedules/watch.d.ts.map +1 -0
  214. package/dist/schedules/watch.js +46 -0
  215. package/dist/schedules/watch.js.map +1 -0
  216. package/dist/session/workspace/git-worktree.d.ts.map +1 -1
  217. package/dist/session/workspace/git-worktree.js +2 -1
  218. package/dist/session/workspace/git-worktree.js.map +1 -1
  219. package/dist/skills/arguments.d.ts +58 -0
  220. package/dist/skills/arguments.d.ts.map +1 -0
  221. package/dist/skills/arguments.js +208 -0
  222. package/dist/skills/arguments.js.map +1 -0
  223. package/dist/skills/index.d.ts +3 -1
  224. package/dist/skills/index.d.ts.map +1 -1
  225. package/dist/skills/index.js +1 -0
  226. package/dist/skills/index.js.map +1 -1
  227. package/dist/skills/inline-shell-host.d.ts +6 -0
  228. package/dist/skills/inline-shell-host.d.ts.map +1 -1
  229. package/dist/skills/inline-shell-host.js +8 -0
  230. package/dist/skills/inline-shell-host.js.map +1 -1
  231. package/dist/skills/inline-shell.d.ts +26 -1
  232. package/dist/skills/inline-shell.d.ts.map +1 -1
  233. package/dist/skills/inline-shell.js +1308 -22
  234. package/dist/skills/inline-shell.js.map +1 -1
  235. package/dist/tools/builtins/bash-cwd.d.ts.map +1 -1
  236. package/dist/tools/builtins/bash-cwd.js +2 -0
  237. package/dist/tools/builtins/bash-cwd.js.map +1 -1
  238. package/dist/tools/builtins/bash.d.ts.map +1 -1
  239. package/dist/tools/builtins/bash.js +79 -11
  240. package/dist/tools/builtins/bash.js.map +1 -1
  241. package/dist/tools/builtins/exit-semantics.d.ts +6 -0
  242. package/dist/tools/builtins/exit-semantics.d.ts.map +1 -1
  243. package/dist/tools/builtins/exit-semantics.js +10 -0
  244. package/dist/tools/builtins/exit-semantics.js.map +1 -1
  245. package/dist/tools/builtins/glob.d.ts.map +1 -1
  246. package/dist/tools/builtins/glob.js +68 -13
  247. package/dist/tools/builtins/glob.js.map +1 -1
  248. package/dist/tools/builtins/grep.d.ts.map +1 -1
  249. package/dist/tools/builtins/grep.js +37 -12
  250. package/dist/tools/builtins/grep.js.map +1 -1
  251. package/dist/tools/builtins/index.d.ts +11 -0
  252. package/dist/tools/builtins/index.d.ts.map +1 -1
  253. package/dist/tools/builtins/index.js +14 -0
  254. package/dist/tools/builtins/index.js.map +1 -1
  255. package/dist/tools/builtins/job.js +1 -1
  256. package/dist/tools/builtins/job.js.map +1 -1
  257. package/dist/tools/builtins/monitor.d.ts +1 -1
  258. package/dist/tools/builtins/monitor.d.ts.map +1 -1
  259. package/dist/tools/builtins/monitor.js +4 -2
  260. package/dist/tools/builtins/monitor.js.map +1 -1
  261. package/dist/tools/builtins/notebook-cells.d.ts +31 -0
  262. package/dist/tools/builtins/notebook-cells.d.ts.map +1 -0
  263. package/dist/tools/builtins/notebook-cells.js +160 -0
  264. package/dist/tools/builtins/notebook-cells.js.map +1 -0
  265. package/dist/tools/builtins/notebook-edit.d.ts +8 -0
  266. package/dist/tools/builtins/notebook-edit.d.ts.map +1 -0
  267. package/dist/tools/builtins/notebook-edit.js +249 -0
  268. package/dist/tools/builtins/notebook-edit.js.map +1 -0
  269. package/dist/tools/builtins/notebook-guard.d.ts.map +1 -1
  270. package/dist/tools/builtins/notebook-guard.js +2 -1
  271. package/dist/tools/builtins/notebook-guard.js.map +1 -1
  272. package/dist/tools/builtins/push-notification.d.ts +49 -0
  273. package/dist/tools/builtins/push-notification.d.ts.map +1 -0
  274. package/dist/tools/builtins/push-notification.js +107 -0
  275. package/dist/tools/builtins/push-notification.js.map +1 -0
  276. package/dist/tools/builtins/read-file.d.ts.map +1 -1
  277. package/dist/tools/builtins/read-file.js +8 -3
  278. package/dist/tools/builtins/read-file.js.map +1 -1
  279. package/dist/tools/builtins/read-media.d.ts.map +1 -1
  280. package/dist/tools/builtins/read-media.js +2 -1
  281. package/dist/tools/builtins/read-media.js.map +1 -1
  282. package/dist/tools/builtins/read-render.d.ts.map +1 -1
  283. package/dist/tools/builtins/read-render.js +5 -3
  284. package/dist/tools/builtins/read-render.js.map +1 -1
  285. package/dist/tools/builtins/search-support.d.ts +6 -4
  286. package/dist/tools/builtins/search-support.d.ts.map +1 -1
  287. package/dist/tools/builtins/search-support.js +15 -3
  288. package/dist/tools/builtins/search-support.js.map +1 -1
  289. package/dist/tools/builtins/skill.d.ts.map +1 -1
  290. package/dist/tools/builtins/skill.js +30 -8
  291. package/dist/tools/builtins/skill.js.map +1 -1
  292. package/dist/tools/builtins/sleep-guard.d.ts +20 -0
  293. package/dist/tools/builtins/sleep-guard.d.ts.map +1 -1
  294. package/dist/tools/builtins/sleep-guard.js +125 -1
  295. package/dist/tools/builtins/sleep-guard.js.map +1 -1
  296. package/dist/tools/builtins/wait-for-job.js +1 -1
  297. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  298. package/dist/tools/builtins/web.d.ts +2 -0
  299. package/dist/tools/builtins/web.d.ts.map +1 -1
  300. package/dist/tools/builtins/web.js +97 -3
  301. package/dist/tools/builtins/web.js.map +1 -1
  302. package/dist/tools/command-shell.d.ts +50 -0
  303. package/dist/tools/command-shell.d.ts.map +1 -1
  304. package/dist/tools/command-shell.js +145 -0
  305. package/dist/tools/command-shell.js.map +1 -1
  306. package/dist/tools/env-scrub.d.ts +2 -0
  307. package/dist/tools/env-scrub.d.ts.map +1 -1
  308. package/dist/tools/env-scrub.js +15 -1
  309. package/dist/tools/env-scrub.js.map +1 -1
  310. package/dist/tools/git-config-env.d.ts +55 -0
  311. package/dist/tools/git-config-env.d.ts.map +1 -0
  312. package/dist/tools/git-config-env.js +130 -0
  313. package/dist/tools/git-config-env.js.map +1 -0
  314. package/dist/tools/schedules/schedule-tool.d.ts +7 -0
  315. package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
  316. package/dist/tools/schedules/schedule-tool.js +72 -3
  317. package/dist/tools/schedules/schedule-tool.js.map +1 -1
  318. package/dist/tools/schedules/types.d.ts +38 -2
  319. package/dist/tools/schedules/types.d.ts.map +1 -1
  320. package/dist/types/connector/mcp.d.ts +24 -0
  321. package/dist/types/connector/mcp.d.ts.map +1 -1
  322. package/dist/types/message/index.d.ts +21 -1
  323. package/dist/types/message/index.d.ts.map +1 -1
  324. package/dist/types/message/index.js +37 -2
  325. package/dist/types/message/index.js.map +1 -1
  326. package/dist/types/permission/index.d.ts +11 -2
  327. package/dist/types/permission/index.d.ts.map +1 -1
  328. package/dist/types/permission/index.js +12 -2
  329. package/dist/types/permission/index.js.map +1 -1
  330. package/dist/types/plugin/index.d.ts +10 -2
  331. package/dist/types/plugin/index.d.ts.map +1 -1
  332. package/dist/types/plugin/index.js.map +1 -1
  333. package/dist/types/tool/index.d.ts +13 -0
  334. package/dist/types/tool/index.d.ts.map +1 -1
  335. package/dist/types/tool/index.js.map +1 -1
  336. package/dist/utils/plain-terminal-text.d.ts +21 -0
  337. package/dist/utils/plain-terminal-text.d.ts.map +1 -0
  338. package/dist/utils/plain-terminal-text.js +156 -0
  339. package/dist/utils/plain-terminal-text.js.map +1 -0
  340. package/package.json +1 -1
  341. package/src/authorization/bare-repository.ts +70 -0
  342. package/src/authorization/command-line.ts +18 -4
  343. package/src/authorization/gate.ts +11 -0
  344. package/src/authorization/protected-paths.ts +89 -10
  345. package/src/authorization/readonly-commands.ts +75 -6
  346. package/src/authorization/readonly-flags.ts +103 -0
  347. package/src/authorization/shell-lexer.ts +367 -2
  348. package/src/authorization/shell-paths.ts +386 -0
  349. package/src/authorization/shell-session-state.ts +97 -0
  350. package/src/authorization/shell-session.ts +23 -0
  351. package/src/authorization/skill-grant.ts +1 -0
  352. package/src/compaction/extractor.ts +1 -0
  353. package/src/compaction/hooks.ts +43 -1
  354. package/src/compaction/manual.ts +6 -0
  355. package/src/compaction/restore.ts +3 -2
  356. package/src/config/runtime.ts +7 -0
  357. package/src/connector/mcp/client.ts +61 -4
  358. package/src/connector/web/guarded-fetch.ts +92 -0
  359. package/src/connector/web/index.ts +6 -1
  360. package/src/connector/web/types.ts +8 -0
  361. package/src/constants/compaction/index.ts +1 -1
  362. package/src/execution/code-runtime/worker-program.ts +9 -5
  363. package/src/execution/local.ts +6 -1
  364. package/src/peers/index.ts +8 -2
  365. package/src/peers/record.ts +45 -1
  366. package/src/peers/registry.ts +21 -5
  367. package/src/plugin/bin-path.ts +149 -0
  368. package/src/plugin/common-layout/read.ts +3 -3
  369. package/src/plugin/common-layout-names.ts +0 -1
  370. package/src/plugin/hook-module/capabilities.ts +94 -10
  371. package/src/plugin/hook-module/consent.ts +36 -0
  372. package/src/plugin/hook-module/host.ts +72 -21
  373. package/src/plugin/hook-module/index.ts +2 -0
  374. package/src/plugin/hook-module/scan.ts +76 -4
  375. package/src/plugin/hook-module/worker-source.ts +255 -28
  376. package/src/plugin/lifecycle.ts +67 -0
  377. package/src/plugin/shell-hook-tool-names.ts +1 -0
  378. package/src/plugin/shell-hook.ts +23 -4
  379. package/src/public-runtime.ts +27 -0
  380. package/src/public-tools.ts +36 -2
  381. package/src/public-types.ts +3 -1
  382. package/src/runtime/jobs/monitor-stream.ts +18 -4
  383. package/src/runtime/jobs/registry.ts +22 -2
  384. package/src/runtime/query/auto-review/git-status.ts +3 -2
  385. package/src/runtime/query/executor.ts +153 -12
  386. package/src/runtime/query/index.ts +5 -2
  387. package/src/runtime/query/iteration/outstanding-work.ts +22 -4
  388. package/src/runtime/query/iteration/phases/compaction.ts +14 -1
  389. package/src/runtime/query/iteration/phases/tool-review.ts +24 -7
  390. package/src/runtime/query/path-escalation.ts +52 -4
  391. package/src/runtime/query/review-policy.ts +47 -15
  392. package/src/runtime/query/steering.ts +32 -4
  393. package/src/sandbox/provider/local.ts +3 -1
  394. package/src/schedules/describe.ts +2 -0
  395. package/src/schedules/evaluate.ts +29 -1
  396. package/src/schedules/index.ts +9 -1
  397. package/src/schedules/next-fire.ts +9 -0
  398. package/src/schedules/spec.ts +42 -0
  399. package/src/schedules/types.ts +33 -3
  400. package/src/schedules/watch.ts +71 -0
  401. package/src/session/workspace/git-worktree.ts +3 -1
  402. package/src/skills/arguments.ts +250 -0
  403. package/src/skills/index.ts +10 -0
  404. package/src/skills/inline-shell-host.ts +16 -0
  405. package/src/skills/inline-shell.ts +1358 -22
  406. package/src/tools/builtins/bash-cwd.ts +2 -0
  407. package/src/tools/builtins/bash.ts +93 -13
  408. package/src/tools/builtins/exit-semantics.ts +10 -0
  409. package/src/tools/builtins/glob.ts +79 -15
  410. package/src/tools/builtins/grep.ts +37 -10
  411. package/src/tools/builtins/index.ts +15 -0
  412. package/src/tools/builtins/job.ts +1 -1
  413. package/src/tools/builtins/monitor.ts +4 -2
  414. package/src/tools/builtins/notebook-cells.ts +196 -0
  415. package/src/tools/builtins/notebook-edit.ts +280 -0
  416. package/src/tools/builtins/notebook-guard.ts +2 -1
  417. package/src/tools/builtins/push-notification.ts +138 -0
  418. package/src/tools/builtins/read-file.ts +9 -3
  419. package/src/tools/builtins/read-media.ts +2 -1
  420. package/src/tools/builtins/read-render.ts +5 -3
  421. package/src/tools/builtins/search-support.ts +17 -3
  422. package/src/tools/builtins/skill.ts +29 -7
  423. package/src/tools/builtins/sleep-guard.ts +128 -1
  424. package/src/tools/builtins/wait-for-job.ts +1 -1
  425. package/src/tools/builtins/web.ts +100 -3
  426. package/src/tools/command-shell.ts +166 -0
  427. package/src/tools/env-scrub.ts +13 -1
  428. package/src/tools/git-config-env.ts +143 -0
  429. package/src/tools/schedules/schedule-tool.ts +79 -3
  430. package/src/tools/schedules/types.ts +47 -9
  431. package/src/types/connector/mcp.ts +25 -0
  432. package/src/types/message/index.ts +53 -1
  433. package/src/types/permission/index.ts +20 -3
  434. package/src/types/plugin/index.ts +10 -2
  435. package/src/types/tool/index.ts +13 -0
  436. package/src/utils/plain-terminal-text.ts +142 -0
@@ -19,10 +19,11 @@
19
19
  * is made from a sandbox with no prototype and with code generation from
20
20
  * strings off, and the worker's own function constructors are replaced by ones
21
21
  * that throw, so a reference that still leaked would not reach `process`. It is
22
- * a worker thread, not a process boundary, and a hostile module is not
23
- * contained against a flaw in V8 itself; a module runs only after the person
24
- * has been told what it does, and what it calls on `$` is checked before it
25
- * runs.
22
+ * a worker thread, not a process boundary, and it runs with the permissions of
23
+ * the user who runs Namzu: these are layers that make an escape hard, not a
24
+ * sandbox, and a hostile module is not contained against a flaw in V8 itself. A
25
+ * module runs only after the person has been told what it does, and what it
26
+ * calls on `$` is checked before it runs.
26
27
  *
27
28
  * Messages to the worker: `load`, `dispatch`, `overrun`, `grace-over`, `abort`,
28
29
  * `call-result`. Messages from it: `loaded`, `result`, `call`, `log`.
@@ -30,9 +31,75 @@
30
31
 
31
32
  /** Runs inside the module's context, and is the only code there besides the module. */
32
33
  const BOOTSTRAP_SOURCE = String.raw`
33
- (function (send, evaluate) {
34
+ (function (hostSend, hostEvaluate) {
34
35
  'use strict'
35
36
  const MAX_LOG = 4000
37
+ const freeze = Object.freeze
38
+ const setPrototypeOf = Object.setPrototypeOf
39
+ const getPrototypeOf = Object.getPrototypeOf
40
+ const objectPrototype = Object.prototype
41
+
42
+ // What reaches module code from outside this realm is a frozen object with no prototype, never the object
43
+ // itself: an error made in the worker's realm has that realm's Function behind its constructor, and a stack
44
+ // that names its frames.
45
+ const seal = (name, message) => {
46
+ const line = name + ': ' + message
47
+ const toStr = () => line
48
+ setPrototypeOf(toStr, null)
49
+ freeze(toStr)
50
+ return freeze({ __proto__: null, name, message, stack: line, toString: toStr })
51
+ }
52
+ const SENTINEL = seal('Error', 'a call to the host failed (details unavailable)')
53
+
54
+ // True only for an object whose prototype chain reaches this realm's Object.prototype within 64 hops: a
55
+ // foreign, null-terminated, throwing or over-long chain is not this realm's.
56
+ const ownRealm = (value) => {
57
+ let proto = value
58
+ for (let i = 0; i < 64; i++) {
59
+ proto = getPrototypeOf(proto)
60
+ if (proto === objectPrototype) return true
61
+ if (proto === null) return false
62
+ }
63
+ return false
64
+ }
65
+ const launder = (error) => {
66
+ if (error === null || (typeof error !== 'object' && typeof error !== 'function')) return error
67
+ try {
68
+ if (ownRealm(error)) return error
69
+ } catch (inner) {
70
+ // Not readable: sealed below.
71
+ }
72
+ let name = 'Error'
73
+ let message = ''
74
+ try {
75
+ if (typeof error.name === 'string') name = error.name
76
+ } catch (inner) {
77
+ // Keep the default.
78
+ }
79
+ try {
80
+ if (typeof error.message === 'string') message = error.message
81
+ } catch (inner) {
82
+ // Keep the default.
83
+ }
84
+ return seal(name, message)
85
+ }
86
+ // Every function the worker hands in is called through this: what it throws is laundered, and nothing is
87
+ // called or allocated between a failed launder and the throw.
88
+ const guarded = (hostFn) => (...args) => {
89
+ try {
90
+ return hostFn(...args)
91
+ } catch (error) {
92
+ let reason = SENTINEL
93
+ try {
94
+ reason = launder(error)
95
+ } catch (inner) {
96
+ // The sentinel stands.
97
+ }
98
+ throw reason
99
+ }
100
+ }
101
+ const send = guarded(hostSend)
102
+ const evaluate = guarded(hostEvaluate)
36
103
 
37
104
  const post = (message) => {
38
105
  try {
@@ -83,7 +150,7 @@ function call(noun, method, args) {
83
150
  pendingCalls.set(id, { resolve, reject })
84
151
  if (!post({ t: 'call', cid: id, noun, method, args })) {
85
152
  pendingCalls.delete(id)
86
- reject(new Error('the arguments of $.' + noun + '.' + method + ' are not plain data'))
153
+ reject(seal('TypeError', 'the arguments of $.' + noun + '.' + method + ' are not plain data'))
87
154
  }
88
155
  })
89
156
  }
@@ -218,7 +285,14 @@ function loadProgram(program) {
218
285
  cache.set(rel, exports)
219
286
  const source = program.files[rel]
220
287
  if (typeof source !== 'string') throw new Error('no such file in the module: ' + rel)
221
- const compiled = evaluate(rel, source)
288
+ // The worker's evaluate is outside this realm: whatever it throws (a RangeError from a stack that ran
289
+ // out is made in its realm) is turned into a message here, so no object of that realm is caught by a module.
290
+ let compiled
291
+ try {
292
+ compiled = evaluate(rel, source)
293
+ } catch (error) {
294
+ compiled = 'the module could not be compiled'
295
+ }
222
296
  if (typeof compiled === 'string') throw new Error(compiled)
223
297
  compiled(exports, load)
224
298
  return exports
@@ -385,7 +459,7 @@ function receive(json) {
385
459
  if (pending === undefined) return
386
460
  pendingCalls.delete(message.cid)
387
461
  if (message.ok) pending.resolve(message.value)
388
- else pending.reject(new Error(message.message))
462
+ else pending.reject(seal('Error', typeof message.message === 'string' ? message.message : 'the call failed'))
389
463
  return
390
464
  }
391
465
  }
@@ -395,13 +469,119 @@ return receive
395
469
  })
396
470
  `
397
471
 
472
+ // Run in the context before anything else is made there: the module's Error gets no way to read frames, and
473
+ // the globals a plain context should not have are gone.
474
+ const PREPARE_SOURCE = String.raw`(function () {
475
+ 'use strict'
476
+ Object.defineProperty(Error, 'prepareStackTrace', {
477
+ value: function () { return '' },
478
+ writable: false,
479
+ configurable: false,
480
+ })
481
+ // A stack that overflows is made by the engine, not by prepareStackTrace: with no frames kept it has none to read.
482
+ Object.defineProperty(Error, 'stackTraceLimit', { value: 0, writable: false, configurable: false })
483
+ for (const name of ['ShadowRealm', 'WebAssembly', 'FinalizationRegistry', 'WeakRef', 'Atomics',
484
+ 'SharedArrayBuffer', 'queueMicrotask', '$vm', 'gc', 'edenGC', 'fullGC', 'print', 'readFile', 'Loader']) {
485
+ delete globalThis[name]
486
+ }
487
+ })()`
488
+
489
+ // Run in the context once the bootstrap has made what the module is handed.
490
+ const FREEZE_SOURCE = String.raw`(function () {
491
+ 'use strict'
492
+ // A frozen prototype makes the data properties on it read-only, so "this.name = x" in an Error subclass
493
+ // would throw: those become accessors whose setter defines the property on the receiver instead.
494
+ function enableOverride(proto, key) {
495
+ const d = Object.getOwnPropertyDescriptor(proto, key)
496
+ if (!d || 'get' in d) return
497
+ const v = d.value
498
+ Object.defineProperty(proto, key, {
499
+ get() { return v },
500
+ set(nv) {
501
+ if (this === proto) return
502
+ Object.defineProperty(this, key, { value: nv, writable: true, enumerable: true, configurable: true })
503
+ },
504
+ enumerable: d.enumerable,
505
+ configurable: true,
506
+ })
507
+ }
508
+ const errorCtors = [Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError,
509
+ globalThis.AggregateError, globalThis.SuppressedError].filter(Boolean)
510
+ for (const [proto, keys] of [
511
+ [Object.prototype, Object.getOwnPropertyNames(Object.prototype)],
512
+ [Function.prototype, ['toString', 'constructor', 'name', 'length']],
513
+ [Array.prototype, ['toString', 'constructor']],
514
+ [Date.prototype, ['toString', 'toLocaleString', 'valueOf', 'constructor']],
515
+ ...errorCtors.map((C) => [C.prototype, ['name', 'message', 'toString', 'constructor']]),
516
+ ]) for (const key of keys) enableOverride(proto, key)
517
+ const freezeBoth = (C) => {
518
+ Object.freeze(C)
519
+ if (C.prototype) Object.freeze(C.prototype)
520
+ }
521
+ for (const C of [Promise, Object, Array, Function, globalThis.Iterator, Map, Set, WeakMap, WeakSet,
522
+ String, Number, Boolean, Symbol, BigInt, Date, RegExp, ArrayBuffer, DataView, ...errorCtors,
523
+ globalThis.DisposableStack, globalThis.AsyncDisposableStack, globalThis.Intl].filter(Boolean)) freezeBoth(C)
524
+ for (const C of [Object.getPrototypeOf(Int8Array), Int8Array, Uint8Array, Uint8ClampedArray, Int16Array,
525
+ Uint16Array, Int32Array, Uint32Array, globalThis.Float16Array, Float32Array, Float64Array,
526
+ BigInt64Array, BigUint64Array].filter(Boolean)) freezeBoth(C)
527
+ // The constructors of async, generator and async generator functions are reached only from an instance.
528
+ for (const f of [async () => {}, function* () {}, async function* () {}]) {
529
+ Object.freeze(f.constructor)
530
+ Object.freeze(f.constructor.prototype)
531
+ }
532
+ for (const namespace of [JSON, Math, Reflect, Proxy]) Object.freeze(namespace)
533
+ if (typeof Intl !== 'undefined') {
534
+ for (const key of Object.getOwnPropertyNames(Intl)) {
535
+ const C = Intl[key]
536
+ if (typeof C === 'function') freezeBoth(C)
537
+ }
538
+ }
539
+ const iterators = [
540
+ [][Symbol.iterator](), ''[Symbol.iterator](), new Map()[Symbol.iterator](), new Set()[Symbol.iterator](),
541
+ 'a'.matchAll(/a/g), (function* () {})(), (async function* () {})(),
542
+ ]
543
+ if (typeof Iterator !== 'undefined' && Iterator.from) {
544
+ iterators.push([].values().map((x) => x), Iterator.from({ next: () => ({ done: true }) }))
545
+ }
546
+ try {
547
+ if (typeof Intl !== 'undefined' && Intl.Segmenter) {
548
+ const segments = new Intl.Segmenter().segment('a')
549
+ iterators.push(segments, segments[Symbol.iterator]())
550
+ }
551
+ } catch (error) {
552
+ // No segmenter here: nothing to freeze.
553
+ }
554
+ for (const it of iterators) {
555
+ for (let p = Object.getPrototypeOf(it); p; p = Object.getPrototypeOf(p)) Object.freeze(p)
556
+ }
557
+ Object.defineProperty(globalThis, 'then', { value: undefined, writable: false, configurable: false })
558
+ for (const key of Reflect.ownKeys(globalThis)) {
559
+ const d = Object.getOwnPropertyDescriptor(globalThis, key)
560
+ if (d && d.configurable && 'value' in d) {
561
+ Object.defineProperty(globalThis, key, { value: d.value, writable: false, configurable: false, enumerable: d.enumerable })
562
+ }
563
+ }
564
+ })()`
565
+
398
566
  export const HOOK_WORKER_SOURCE =
399
- `const BOOTSTRAP = ${JSON.stringify('(' + BOOTSTRAP_SOURCE.trim() + ')')}\n` +
567
+ // 'use strict' is the first statement: a directive after any other statement is only an expression, so
568
+ // it must come before the BOOTSTRAP constant for the worker's own realm to be strict.
569
+ `'use strict'\nconst BOOTSTRAP = ${JSON.stringify('(' + BOOTSTRAP_SOURCE.trim() + ')')}\n` +
570
+ `const PREPARE_SOURCE = ${JSON.stringify(PREPARE_SOURCE)}\nconst FREEZE_SOURCE = ${JSON.stringify(FREEZE_SOURCE)}\n` +
400
571
  String.raw`
401
- 'use strict'
402
572
  const { parentPort } = require('node:worker_threads')
403
573
  const vm = require('node:vm')
404
574
 
575
+ // The worker's own realm gives a script nothing to read its stack with: a stack that overflows or throws
576
+ // is made of call sites, and a call site reaches the function that was running.
577
+ for (const key of ['prepareStackTrace', 'stackTraceLimit']) {
578
+ Object.defineProperty(Error, key, {
579
+ value: key === 'stackTraceLimit' ? 0 : undefined,
580
+ writable: false,
581
+ configurable: false,
582
+ })
583
+ }
584
+
405
585
  // Whatever of the worker's own realm might still be reached must not be able to make code: its
406
586
  // function constructors throw.
407
587
  {
@@ -423,6 +603,54 @@ const vm = require('node:vm')
423
603
  }
424
604
  }
425
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
+
426
654
  const send = (json) => {
427
655
  try {
428
656
  parentPort.postMessage(JSON.parse(json))
@@ -438,10 +666,13 @@ const messageOf = (error) =>
438
666
 
439
667
  // Source text in, a function of the context out; a failure comes back as its message, never as an object.
440
668
  let context
669
+ let refuseImport
441
670
  const evaluate = (rel, source) => {
442
671
  try {
443
672
  const script = new vm.Script('(function (__exports, __import) {"use strict";' + source + '\n})', {
444
673
  filename: 'plugin:' + rel,
674
+ // Made inside the context, so what an import() would call is not a worker-realm function.
675
+ importModuleDynamically: refuseImport,
445
676
  })
446
677
  return script.runInContext(context)
447
678
  } catch (error) {
@@ -449,34 +680,30 @@ const evaluate = (rel, source) => {
449
680
  }
450
681
  }
451
682
 
683
+ function prepareContext() {
684
+ // 'use strict' first, then the one Error the module has loses captureStackTrace.
685
+ vm.runInContext("'use strict'; delete Error.captureStackTrace", context)
686
+ vm.runInContext(PREPARE_SOURCE, context, { filename: 'plugin:prepare' })
687
+ }
688
+
452
689
  function freezeIntrinsics() {
453
- vm.runInContext(
454
- '(function () {' +
455
- 'const keep = new Set(["Object", "Error"]);' +
456
- 'for (const name of ["Object", "Array", "Function", "String", "Number", "Boolean", "Symbol", "Promise", "RegExp", "Date", "Map", "Set", "WeakMap", "WeakSet", "Error", "TypeError", "RangeError", "SyntaxError", "BigInt", "ArrayBuffer", "Uint8Array"]) {' +
457
- 'const ctor = globalThis[name];' +
458
- 'if (!ctor) continue;' +
459
- 'if (ctor.prototype && !keep.has(name)) Object.freeze(ctor.prototype);' +
460
- 'Object.freeze(ctor);' +
461
- '}' +
462
- 'for (const name of ["JSON", "Math", "Reflect"]) { if (globalThis[name]) Object.freeze(globalThis[name]); }' +
463
- 'for (const key of Reflect.ownKeys(globalThis)) {' +
464
- 'const d = Object.getOwnPropertyDescriptor(globalThis, key);' +
465
- 'if (d && d.configurable && "value" in d) Object.defineProperty(globalThis, key, { value: d.value, writable: false, configurable: false, enumerable: d.enumerable });' +
466
- '}' +
467
- '})()',
468
- context,
469
- )
690
+ vm.runInContext(FREEZE_SOURCE, context, { filename: 'plugin:freeze' })
470
691
  }
471
692
 
472
693
  let receive
473
694
 
474
695
  function start() {
475
- // No prototype on the sandbox, so nothing of the worker's realm is found through the global.
696
+ // No prototype on the context's global, so nothing of the worker's realm is found through the global.
476
697
  context = vm.createContext(Object.create(null), {
477
698
  name: 'plugin',
478
699
  codeGeneration: { strings: false, wasm: false },
479
700
  })
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
+ )
480
707
  receive = vm.runInContext(BOOTSTRAP, context, { filename: 'plugin:bootstrap' })(send, evaluate)
481
708
  freezeIntrinsics()
482
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,
@@ -856,6 +868,8 @@ export {
856
868
  readCommonLayout,
857
869
  hookModuleConsentEntry,
858
870
  hookModuleConsentLines,
871
+ hookModuleRecovery,
872
+ withHookModuleRecovery,
859
873
  locateHookModule,
860
874
  scanHookModule,
861
875
  startHookModule,
@@ -950,10 +964,16 @@ export {
950
964
  nextFireTime,
951
965
  parseCronExpression,
952
966
  parseDuration,
967
+ parseScheduleExpiry,
953
968
  parseScheduleSpec,
969
+ parseWatchSpec,
954
970
  previousFireTime,
955
971
  SCHEDULE_CATCH_UP_WINDOW_MS,
956
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,
957
977
  ScheduleValidationError,
958
978
  upcomingFireTimes,
959
979
  validateTimeZone,
@@ -1501,6 +1521,8 @@ export {
1501
1521
  createUserMessage,
1502
1522
  isProjectInstructionMessageSource,
1503
1523
  isRuntimeContextMessageSource,
1524
+ isRuntimeContextOrigin,
1525
+ RUNTIME_CONTEXT_ORIGIN_KINDS,
1504
1526
  isModelContentOmission,
1505
1527
  MAX_PROJECT_INSTRUCTION_SOURCE_FILES,
1506
1528
  RUNTIME_CONTEXT_MESSAGE_KINDS,
@@ -1792,6 +1814,7 @@ export {
1792
1814
  ASK_RULE_UNATTENDED_REFUSAL,
1793
1815
  CLASSIFIER_SAFE_TOOLS,
1794
1816
  CLASSIFIER_TRANSCRIPT_TOO_LONG_FEEDBACK,
1817
+ CLASSIFY_NESTED_REFUSAL,
1795
1818
  OUTSIDE_ROOTS_UNATTENDED_REFUSAL,
1796
1819
  PLAN_MODE_REFUSAL,
1797
1820
  PLAN_MODE_REFUSAL_WITH_PLAN_FILE,
@@ -1802,6 +1825,7 @@ export {
1802
1825
  SCREEN_CONSENT_UNATTENDED_REFUSAL,
1803
1826
  STRICT_MODE_REFUSAL,
1804
1827
  UNFINISHED_CHECK_UNATTENDED_REFUSAL,
1828
+ allowedCallTooWide,
1805
1829
  batchNeedsReview,
1806
1830
  createReviewHandler,
1807
1831
  createReviewPolicy,
@@ -1868,6 +1892,8 @@ export {
1868
1892
  GuardedFetchProvider,
1869
1893
  WebFetchRefusedError,
1870
1894
  isPrivateAddress,
1895
+ privateAddressProblem,
1896
+ proxyConfigured,
1871
1897
  } from './connector/web/index.js'
1872
1898
 
1873
1899
  // Where an attachment's bytes live when the message does not carry them.
@@ -2175,6 +2201,7 @@ export {
2175
2201
  OUTSTANDING_EXPIRY_MS,
2176
2202
  PEER_PROTOCOL_VERSION,
2177
2203
  PEER_RECORD_VERSION,
2204
+ PEER_AGENTS_MAX,
2178
2205
  PEER_TRAIL_MAX,
2179
2206
  PeerAddressError,
2180
2207
  PeerClient,