@nathapp/nax-agent 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +49 -0
  4. package/dist/coding-tools/coding-tool-bash.d.ts +46 -0
  5. package/dist/coding-tools/coding-tool-bash.js +44 -0
  6. package/dist/coding-tools/coding-tool-extras.d.ts +35 -0
  7. package/dist/coding-tools/coding-tool-extras.js +56 -0
  8. package/dist/coding-tools/coding-tool-sandbox.d.ts +74 -0
  9. package/dist/coding-tools/coding-tool-sandbox.js +215 -0
  10. package/dist/coding-tools/coding-tool-support.d.ts +132 -0
  11. package/dist/coding-tools/coding-tool-support.js +159 -0
  12. package/dist/coding-tools/universal-coding-tools.d.ts +11 -0
  13. package/dist/coding-tools/universal-coding-tools.js +5 -0
  14. package/dist/command-interceptor/index.d.ts +55 -0
  15. package/dist/command-interceptor/index.js +60 -0
  16. package/dist/command-interceptor/shell.d.ts +36 -0
  17. package/dist/command-interceptor/shell.js +137 -0
  18. package/dist/command-safety/build.d.ts +19 -0
  19. package/dist/command-safety/build.js +47 -0
  20. package/dist/command-safety/guard.d.ts +32 -0
  21. package/dist/command-safety/guard.js +179 -0
  22. package/dist/command-safety/identifiers.d.ts +24 -0
  23. package/dist/command-safety/identifiers.js +20 -0
  24. package/dist/command-safety/index.d.ts +17 -0
  25. package/dist/command-safety/index.js +11 -0
  26. package/dist/command-safety/questions.d.ts +19 -0
  27. package/dist/command-safety/questions.js +60 -0
  28. package/dist/command-safety/row.d.ts +2 -0
  29. package/dist/command-safety/row.js +14 -0
  30. package/dist/command-safety/rule-scorer.d.ts +9 -0
  31. package/dist/command-safety/rule-scorer.js +391 -0
  32. package/dist/command-safety/shadow.d.ts +33 -0
  33. package/dist/command-safety/shadow.js +188 -0
  34. package/dist/command-safety/systemone-client.d.ts +16 -0
  35. package/dist/command-safety/systemone-client.js +92 -0
  36. package/dist/command-safety/tap.d.ts +37 -0
  37. package/dist/command-safety/tap.js +77 -0
  38. package/dist/command-safety/temp-only.d.ts +6 -0
  39. package/dist/command-safety/temp-only.js +215 -0
  40. package/dist/command-safety/tmp-write.d.ts +2 -0
  41. package/dist/command-safety/tmp-write.js +112 -0
  42. package/dist/command-safety/types.d.ts +185 -0
  43. package/dist/command-safety/types.js +21 -0
  44. package/dist/config/bash-approval.d.ts +33 -0
  45. package/dist/config/bash-approval.js +30 -0
  46. package/dist/config/catalog-overrides.d.ts +94 -0
  47. package/dist/config/catalog-overrides.js +7 -0
  48. package/dist/config/native-agent/index.d.ts +8 -0
  49. package/dist/config/native-agent/index.js +8 -0
  50. package/dist/config/schemas-sandbox.d.ts +31 -0
  51. package/dist/config/schemas-sandbox.js +45 -0
  52. package/dist/cost/core/index.d.ts +8 -0
  53. package/dist/cost/core/index.js +7 -0
  54. package/dist/cost/estimate.d.ts +34 -0
  55. package/dist/cost/estimate.js +65 -0
  56. package/dist/cost/model-spec.d.ts +28 -0
  57. package/dist/cost/model-spec.js +29 -0
  58. package/dist/cost/standard-types.d.ts +9 -0
  59. package/dist/cost/standard-types.js +1 -0
  60. package/dist/cost/usage-math.d.ts +18 -0
  61. package/dist/cost/usage-math.js +46 -0
  62. package/dist/index.d.ts +26 -0
  63. package/dist/index.js +21 -0
  64. package/dist/infra/agent-logger.d.ts +22 -0
  65. package/dist/infra/agent-logger.js +19 -0
  66. package/dist/infra/credentials-config.d.ts +20 -0
  67. package/dist/infra/credentials-config.js +15 -0
  68. package/dist/infra/errors.d.ts +9 -0
  69. package/dist/infra/errors.js +11 -0
  70. package/dist/infra/index.d.ts +7 -0
  71. package/dist/infra/index.js +7 -0
  72. package/dist/infra/nax-error.d.ts +10 -0
  73. package/dist/infra/nax-error.js +16 -0
  74. package/dist/infra/spin-breaker/hash.d.ts +2 -0
  75. package/dist/infra/spin-breaker/hash.js +5 -0
  76. package/dist/infra/spin-breaker/index.d.ts +120 -0
  77. package/dist/infra/spin-breaker/index.js +340 -0
  78. package/dist/internal/agent-output-env.d.ts +44 -0
  79. package/dist/internal/agent-output-env.js +57 -0
  80. package/dist/internal/argv-exec.d.ts +58 -0
  81. package/dist/internal/argv-exec.js +224 -0
  82. package/dist/internal/bounded-io.d.ts +24 -0
  83. package/dist/internal/bounded-io.js +51 -0
  84. package/dist/internal/command-spec/index.d.ts +29 -0
  85. package/dist/internal/command-spec/index.js +36 -0
  86. package/dist/internal/describe-value-type.d.ts +8 -0
  87. package/dist/internal/describe-value-type.js +14 -0
  88. package/dist/internal/exec-framing.d.ts +18 -0
  89. package/dist/internal/exec-framing.js +22 -0
  90. package/dist/internal/file-lock.d.ts +91 -0
  91. package/dist/internal/file-lock.js +212 -0
  92. package/dist/internal/file-size.d.ts +2 -0
  93. package/dist/internal/file-size.js +12 -0
  94. package/dist/internal/git-add.d.ts +43 -0
  95. package/dist/internal/git-add.js +59 -0
  96. package/dist/internal/git-env.d.ts +59 -0
  97. package/dist/internal/git-env.js +93 -0
  98. package/dist/internal/git-exec.d.ts +58 -0
  99. package/dist/internal/git-exec.js +115 -0
  100. package/dist/internal/path-file-lock.d.ts +23 -0
  101. package/dist/internal/path-file-lock.js +25 -0
  102. package/dist/internal/process-alive.d.ts +42 -0
  103. package/dist/internal/process-alive.js +56 -0
  104. package/dist/internal/process-kill.d.ts +27 -0
  105. package/dist/internal/process-kill.js +54 -0
  106. package/dist/internal/realpath.d.ts +29 -0
  107. package/dist/internal/realpath.js +52 -0
  108. package/dist/internal/redact.d.ts +40 -0
  109. package/dist/internal/redact.js +161 -0
  110. package/dist/internal/shell-quote.d.ts +2 -0
  111. package/dist/internal/shell-quote.js +4 -0
  112. package/dist/internal/sort.d.ts +20 -0
  113. package/dist/internal/sort.js +20 -0
  114. package/dist/internal/strip-control-chars.d.ts +19 -0
  115. package/dist/internal/strip-control-chars.js +38 -0
  116. package/dist/internal/thenable.d.ts +10 -0
  117. package/dist/internal/thenable.js +15 -0
  118. package/dist/internal.d.ts +91 -0
  119. package/dist/internal.js +91 -0
  120. package/dist/native/adapter-deps.d.ts +46 -0
  121. package/dist/native/adapter-deps.js +43 -0
  122. package/dist/native/auth-types.d.ts +70 -0
  123. package/dist/native/auth-types.js +13 -0
  124. package/dist/native/auth.d.ts +133 -0
  125. package/dist/native/auth.js +362 -0
  126. package/dist/native/client.d.ts +50 -0
  127. package/dist/native/client.js +174 -0
  128. package/dist/native/complete.d.ts +33 -0
  129. package/dist/native/complete.js +88 -0
  130. package/dist/native/credentials/chained-store.d.ts +30 -0
  131. package/dist/native/credentials/chained-store.js +68 -0
  132. package/dist/native/credentials/change-guard.d.ts +51 -0
  133. package/dist/native/credentials/change-guard.js +136 -0
  134. package/dist/native/credentials/exec-source.d.ts +50 -0
  135. package/dist/native/credentials/exec-source.js +222 -0
  136. package/dist/native/credentials/fingerprint.d.ts +26 -0
  137. package/dist/native/credentials/fingerprint.js +174 -0
  138. package/dist/native/credentials/helper-process.d.ts +79 -0
  139. package/dist/native/credentials/helper-process.js +259 -0
  140. package/dist/native/credentials/helper-protocol.d.ts +36 -0
  141. package/dist/native/credentials/helper-protocol.js +79 -0
  142. package/dist/native/credentials/index.d.ts +60 -0
  143. package/dist/native/credentials/index.js +184 -0
  144. package/dist/native/errors.d.ts +34 -0
  145. package/dist/native/errors.js +109 -0
  146. package/dist/native/index.d.ts +25 -0
  147. package/dist/native/index.js +23 -0
  148. package/dist/native/model-resolver.d.ts +57 -0
  149. package/dist/native/model-resolver.js +73 -0
  150. package/dist/native/models.d.ts +116 -0
  151. package/dist/native/models.js +183 -0
  152. package/dist/native/session/ask-human.d.ts +15 -0
  153. package/dist/native/session/ask-human.js +22 -0
  154. package/dist/native/session/compaction.d.ts +94 -0
  155. package/dist/native/session/compaction.js +170 -0
  156. package/dist/native/session/handle-invalid-tool-call.d.ts +111 -0
  157. package/dist/native/session/handle-invalid-tool-call.js +159 -0
  158. package/dist/native/session/loop-events/cache-boundary.d.ts +11 -0
  159. package/dist/native/session/loop-events/cache-boundary.js +29 -0
  160. package/dist/native/session/loop-events/external-handler.d.ts +38 -0
  161. package/dist/native/session/loop-events/external-handler.js +193 -0
  162. package/dist/native/session/loop-events/index.d.ts +16 -0
  163. package/dist/native/session/loop-events/index.js +15 -0
  164. package/dist/native/session/loop-events/payload-guard.d.ts +9 -0
  165. package/dist/native/session/loop-events/payload-guard.js +31 -0
  166. package/dist/native/session/loop-events/registry.d.ts +84 -0
  167. package/dist/native/session/loop-events/registry.js +305 -0
  168. package/dist/native/session/loop-events/types.d.ts +251 -0
  169. package/dist/native/session/loop-events/types.js +14 -0
  170. package/dist/native/session/loop-handlers.d.ts +73 -0
  171. package/dist/native/session/loop-handlers.js +137 -0
  172. package/dist/native/session/nudge.d.ts +29 -0
  173. package/dist/native/session/nudge.js +35 -0
  174. package/dist/native/session/rate-provenance.d.ts +17 -0
  175. package/dist/native/session/rate-provenance.js +39 -0
  176. package/dist/native/session/session.d.ts +139 -0
  177. package/dist/native/session/session.js +208 -0
  178. package/dist/native/session/tool-input-exemplar.d.ts +2 -0
  179. package/dist/native/session/tool-input-exemplar.js +66 -0
  180. package/dist/native/session/tool-input-validation.d.ts +15 -0
  181. package/dist/native/session/tool-input-validation.js +146 -0
  182. package/dist/native/session/tool-mapping.d.ts +18 -0
  183. package/dist/native/session/tool-mapping.js +27 -0
  184. package/dist/native/session/tool-result.d.ts +37 -0
  185. package/dist/native/session/tool-result.js +25 -0
  186. package/dist/native/session/transcript-store.d.ts +77 -0
  187. package/dist/native/session/transcript-store.js +200 -0
  188. package/dist/native/session/truncation-handler.d.ts +47 -0
  189. package/dist/native/session/truncation-handler.js +83 -0
  190. package/dist/native/session/turn-accumulator.d.ts +45 -0
  191. package/dist/native/session/turn-accumulator.js +67 -0
  192. package/dist/native/session/turn-ask-human.d.ts +23 -0
  193. package/dist/native/session/turn-ask-human.js +41 -0
  194. package/dist/native/session/turn-compaction-step.d.ts +74 -0
  195. package/dist/native/session/turn-compaction-step.js +128 -0
  196. package/dist/native/session/turn-complete-step.d.ts +77 -0
  197. package/dist/native/session/turn-complete-step.js +159 -0
  198. package/dist/native/session/turn-end-event.d.ts +3 -0
  199. package/dist/native/session/turn-end-event.js +17 -0
  200. package/dist/native/session/turn-events.d.ts +63 -0
  201. package/dist/native/session/turn-events.js +48 -0
  202. package/dist/native/session/turn-loop-round-trip.d.ts +116 -0
  203. package/dist/native/session/turn-loop-round-trip.js +318 -0
  204. package/dist/native/session/turn-loop.d.ts +23 -0
  205. package/dist/native/session/turn-loop.js +250 -0
  206. package/dist/native/session/turn-result.d.ts +39 -0
  207. package/dist/native/session/turn-result.js +64 -0
  208. package/dist/native/session/turn-retry.d.ts +120 -0
  209. package/dist/native/session/turn-retry.js +182 -0
  210. package/dist/native/session/turn-tool-batch.d.ts +61 -0
  211. package/dist/native/session/turn-tool-batch.js +259 -0
  212. package/dist/native/session/turn-types.d.ts +164 -0
  213. package/dist/native/session/turn-types.js +36 -0
  214. package/dist/native/session-adapter.d.ts +56 -0
  215. package/dist/native/session-adapter.js +369 -0
  216. package/dist/native/session-affinity.d.ts +36 -0
  217. package/dist/native/session-affinity.js +43 -0
  218. package/dist/native/tier-providers.d.ts +18 -0
  219. package/dist/native/tier-providers.js +20 -0
  220. package/dist/permissions/approval-audit.d.ts +10 -0
  221. package/dist/permissions/approval-audit.js +22 -0
  222. package/dist/permissions/approvals-link.d.ts +20 -0
  223. package/dist/permissions/approvals-link.js +62 -0
  224. package/dist/permissions/approvals-store.d.ts +168 -0
  225. package/dist/permissions/approvals-store.js +259 -0
  226. package/dist/permissions/approvals-taint.d.ts +33 -0
  227. package/dist/permissions/approvals-taint.js +138 -0
  228. package/dist/permissions/ask-chain.d.ts +69 -0
  229. package/dist/permissions/ask-chain.js +32 -0
  230. package/dist/permissions/ask.d.ts +23 -0
  231. package/dist/permissions/ask.js +25 -0
  232. package/dist/permissions/bash-lex.d.ts +59 -0
  233. package/dist/permissions/bash-lex.js +279 -0
  234. package/dist/permissions/grammar.d.ts +12 -0
  235. package/dist/permissions/grammar.js +24 -0
  236. package/dist/permissions/index.d.ts +11 -0
  237. package/dist/permissions/index.js +9 -0
  238. package/dist/permissions/secret-spans.d.ts +19 -0
  239. package/dist/permissions/secret-spans.js +88 -0
  240. package/dist/permissions/types.d.ts +85 -0
  241. package/dist/permissions/types.js +1 -0
  242. package/dist/runtime/index.d.ts +3 -0
  243. package/dist/runtime/index.js +2 -0
  244. package/dist/runtime/node-glob.d.ts +3 -0
  245. package/dist/runtime/node-glob.js +83 -0
  246. package/dist/runtime/node-runtime.d.ts +3 -0
  247. package/dist/runtime/node-runtime.js +126 -0
  248. package/dist/runtime/slot.d.ts +11 -0
  249. package/dist/runtime/slot.js +17 -0
  250. package/dist/runtime/types.d.ts +51 -0
  251. package/dist/runtime/types.js +1 -0
  252. package/dist/runtime/which.d.ts +8 -0
  253. package/dist/runtime/which.js +32 -0
  254. package/dist/sandbox/argv-quote.d.ts +11 -0
  255. package/dist/sandbox/argv-quote.js +13 -0
  256. package/dist/sandbox/defaults.d.ts +27 -0
  257. package/dist/sandbox/defaults.js +47 -0
  258. package/dist/sandbox/git-guards.d.ts +64 -0
  259. package/dist/sandbox/git-guards.js +161 -0
  260. package/dist/sandbox/index.d.ts +11 -0
  261. package/dist/sandbox/index.js +10 -0
  262. package/dist/sandbox/launcher.d.ts +37 -0
  263. package/dist/sandbox/launcher.js +160 -0
  264. package/dist/sandbox/messages.d.ts +17 -0
  265. package/dist/sandbox/messages.js +46 -0
  266. package/dist/sandbox/policy-builder.d.ts +44 -0
  267. package/dist/sandbox/policy-builder.js +149 -0
  268. package/dist/sandbox/policy-inputs.d.ts +53 -0
  269. package/dist/sandbox/policy-inputs.js +76 -0
  270. package/dist/sandbox/probe.d.ts +8 -0
  271. package/dist/sandbox/probe.js +66 -0
  272. package/dist/sandbox/registry.d.ts +17 -0
  273. package/dist/sandbox/registry.js +57 -0
  274. package/dist/sandbox/session-tmp.d.ts +20 -0
  275. package/dist/sandbox/session-tmp.js +95 -0
  276. package/dist/sandbox/srt-backend.d.ts +21 -0
  277. package/dist/sandbox/srt-backend.js +99 -0
  278. package/dist/sandbox/types.d.ts +102 -0
  279. package/dist/sandbox/types.js +1 -0
  280. package/dist/session/adapter-failure.d.ts +60 -0
  281. package/dist/session/adapter-failure.js +11 -0
  282. package/dist/session/agent-stream-events.d.ts +103 -0
  283. package/dist/session/agent-stream-events.js +6 -0
  284. package/dist/session/interaction-handler.d.ts +53 -0
  285. package/dist/session/interaction-handler.js +2 -0
  286. package/dist/session/no-op-interaction-handler.d.ts +9 -0
  287. package/dist/session/no-op-interaction-handler.js +11 -0
  288. package/dist/session/protocol-types.d.ts +12 -0
  289. package/dist/session/protocol-types.js +1 -0
  290. package/dist/session/session-types.d.ts +456 -0
  291. package/dist/session/session-types.js +64 -0
  292. package/dist/session/tool-descriptor.d.ts +23 -0
  293. package/dist/session/tool-descriptor.js +5 -0
  294. package/dist/session/turn-deadline.d.ts +17 -0
  295. package/dist/session/turn-deadline.js +23 -0
  296. package/dist/tools/ask-request.d.ts +35 -0
  297. package/dist/tools/ask-request.js +57 -0
  298. package/dist/tools/bash-cwd.d.ts +82 -0
  299. package/dist/tools/bash-cwd.js +55 -0
  300. package/dist/tools/bash.d.ts +69 -0
  301. package/dist/tools/bash.js +283 -0
  302. package/dist/tools/delete.d.ts +57 -0
  303. package/dist/tools/delete.js +154 -0
  304. package/dist/tools/denial-redirect.d.ts +42 -0
  305. package/dist/tools/denial-redirect.js +266 -0
  306. package/dist/tools/deny-paths.d.ts +35 -0
  307. package/dist/tools/deny-paths.js +76 -0
  308. package/dist/tools/edit-region.d.ts +50 -0
  309. package/dist/tools/edit-region.js +90 -0
  310. package/dist/tools/edit.d.ts +25 -0
  311. package/dist/tools/edit.js +114 -0
  312. package/dist/tools/exec-allowlist-text.d.ts +18 -0
  313. package/dist/tools/exec-allowlist-text.js +24 -0
  314. package/dist/tools/exec-guard.d.ts +69 -0
  315. package/dist/tools/exec-guard.js +151 -0
  316. package/dist/tools/git-commit.d.ts +59 -0
  317. package/dist/tools/git-commit.js +220 -0
  318. package/dist/tools/git-flags/index.d.ts +10 -0
  319. package/dist/tools/git-flags/index.js +10 -0
  320. package/dist/tools/git.d.ts +88 -0
  321. package/dist/tools/git.js +397 -0
  322. package/dist/tools/glob.d.ts +29 -0
  323. package/dist/tools/glob.js +153 -0
  324. package/dist/tools/grep.d.ts +21 -0
  325. package/dist/tools/grep.js +162 -0
  326. package/dist/tools/index.d.ts +36 -0
  327. package/dist/tools/index.js +28 -0
  328. package/dist/tools/narrow-grants.d.ts +19 -0
  329. package/dist/tools/narrow-grants.js +54 -0
  330. package/dist/tools/nax-owned-writes.d.ts +135 -0
  331. package/dist/tools/nax-owned-writes.js +259 -0
  332. package/dist/tools/package-managers-table.d.ts +146 -0
  333. package/dist/tools/package-managers-table.js +325 -0
  334. package/dist/tools/package-managers-types.d.ts +36 -0
  335. package/dist/tools/package-managers-types.js +6 -0
  336. package/dist/tools/package-managers.d.ts +85 -0
  337. package/dist/tools/package-managers.js +391 -0
  338. package/dist/tools/path-list.d.ts +38 -0
  339. package/dist/tools/path-list.js +62 -0
  340. package/dist/tools/policy-bash-raw.d.ts +19 -0
  341. package/dist/tools/policy-bash-raw.js +210 -0
  342. package/dist/tools/policy-bash.d.ts +64 -0
  343. package/dist/tools/policy-bash.js +232 -0
  344. package/dist/tools/policy-command-branch.d.ts +32 -0
  345. package/dist/tools/policy-command-branch.js +63 -0
  346. package/dist/tools/policy-input.d.ts +2 -0
  347. package/dist/tools/policy-input.js +10 -0
  348. package/dist/tools/policy-match.d.ts +75 -0
  349. package/dist/tools/policy-match.js +117 -0
  350. package/dist/tools/policy-paths-branch.d.ts +97 -0
  351. package/dist/tools/policy-paths-branch.js +314 -0
  352. package/dist/tools/policy.d.ts +65 -0
  353. package/dist/tools/policy.js +232 -0
  354. package/dist/tools/protected-paths.d.ts +26 -0
  355. package/dist/tools/protected-paths.js +8 -0
  356. package/dist/tools/provider-adapt.d.ts +4 -0
  357. package/dist/tools/provider-adapt.js +32 -0
  358. package/dist/tools/provider-advertise.d.ts +39 -0
  359. package/dist/tools/provider-advertise.js +50 -0
  360. package/dist/tools/provider-grants.d.ts +36 -0
  361. package/dist/tools/provider-grants.js +72 -0
  362. package/dist/tools/provider-sanitize.d.ts +19 -0
  363. package/dist/tools/provider-sanitize.js +53 -0
  364. package/dist/tools/provider-types.d.ts +41 -0
  365. package/dist/tools/provider-types.js +26 -0
  366. package/dist/tools/read-continuation.d.ts +147 -0
  367. package/dist/tools/read-continuation.js +176 -0
  368. package/dist/tools/read-file.d.ts +32 -0
  369. package/dist/tools/read-file.js +85 -0
  370. package/dist/tools/read.d.ts +25 -0
  371. package/dist/tools/read.js +182 -0
  372. package/dist/tools/registry.d.ts +125 -0
  373. package/dist/tools/registry.js +67 -0
  374. package/dist/tools/request-capability.d.ts +13 -0
  375. package/dist/tools/request-capability.js +23 -0
  376. package/dist/tools/run-command-exec.d.ts +14 -0
  377. package/dist/tools/run-command-exec.js +161 -0
  378. package/dist/tools/run-command.d.ts +107 -0
  379. package/dist/tools/run-command.js +398 -0
  380. package/dist/tools/runtime-calltool.d.ts +146 -0
  381. package/dist/tools/runtime-calltool.js +223 -0
  382. package/dist/tools/runtime.d.ts +149 -0
  383. package/dist/tools/runtime.js +345 -0
  384. package/dist/tools/scratchpad.d.ts +20 -0
  385. package/dist/tools/scratchpad.js +197 -0
  386. package/dist/tools/spill.d.ts +81 -0
  387. package/dist/tools/spill.js +251 -0
  388. package/dist/tools/tool-audit.d.ts +171 -0
  389. package/dist/tools/tool-audit.js +183 -0
  390. package/dist/tools/truncate.d.ts +98 -0
  391. package/dist/tools/truncate.js +297 -0
  392. package/dist/tools/types.d.ts +145 -0
  393. package/dist/tools/types.js +24 -0
  394. package/dist/tools/verb-denial-argv-hint.d.ts +35 -0
  395. package/dist/tools/verb-denial-argv-hint.js +40 -0
  396. package/dist/tools/write.d.ts +9 -0
  397. package/dist/tools/write.js +45 -0
  398. package/package.json +54 -0
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Search file contents, preferring ripgrep and falling back to grep.
3
+ *
4
+ * Both branches spawn a subprocess, so this tool is NOT evidence that the
5
+ * default tool set is in-process — it is not. What makes it safe is the same
6
+ * property that makes Git safe: a fixed binary, an argv nax constructs
7
+ * entirely, and no shell, so the model supplies data and never a command.
8
+ *
9
+ * The two binaries take different flags, so the argv builder is per-binary
10
+ * rather than shared, and the fallback is tested explicitly: a machine without
11
+ * ripgrep must produce the same matches, not a silent empty result.
12
+ */
13
+ import { drainBounded } from "#src/internal/bounded-io";
14
+ import { runtimeSpawn } from "#src/runtime/index";
15
+ import { which } from "#src/runtime/which";
16
+ import { cutToByteCap, READ_CEILING } from "./truncate.js";
17
+ const GREP_TIMEOUT_MS = 15_000;
18
+ /** @internal */
19
+ const REGEX_METACHARACTERS = /[.*+?^${}()|[\]\\]/;
20
+ /**
21
+ * Returns true when the pattern contains at least one regex metacharacter.
22
+ * Used to disclose to callers that their search was performed literally.
23
+ * @internal
24
+ */
25
+ function containsRegexMetacharacter(pattern) {
26
+ return REGEX_METACHARACTERS.test(pattern);
27
+ }
28
+ /** @internal Injectable for tests — exercises the fallback without uninstalling ripgrep. */
29
+ export const _grepDeps = {
30
+ which: (name) => which(name),
31
+ spawn: runtimeSpawn,
32
+ };
33
+ export function buildGrepArgv(binary, pattern, path, patternType = "literal") {
34
+ const target = path ?? ".";
35
+ // `--` terminates flag parsing on both branches, in both modes: a pattern
36
+ // beginning with "-" is then data, not an option. Neither binary is ever
37
+ // handed a shell string.
38
+ if (binary === "rg") {
39
+ // rg's own default IS regex (its "fixed-strings" flag is what disables
40
+ // it), so the regex branch simply omits the flag rather than adding one.
41
+ const flags = patternType === "literal"
42
+ ? ["--fixed-strings", "--line-number", "--no-heading", "--color", "never"]
43
+ : ["--line-number", "--no-heading", "--color", "never"];
44
+ return ["rg", ...flags, "--", pattern, target];
45
+ }
46
+ // grep has no "regex" default to fall back to: -F is fixed-strings, and the
47
+ // nearest equivalent to rg's regex syntax is -E (POSIX ERE, e.g. `a+`, `a|b`
48
+ // with no backslash), not grep's default BRE.
49
+ const modeFlag = patternType === "literal" ? "-F" : "-E";
50
+ return ["grep", "-r", "-n", modeFlag, "--", pattern, target];
51
+ }
52
+ export const grepTool = {
53
+ name: "Grep",
54
+ description: "Search repository file contents for a literal string or a regular expression. Returns 'path:line:text' rows relative to the repository root when no subdirectory target is supplied, absolute when one is (rg prints the target as given). Defaults to a literal (fixed-string) search; set pattern_type to \"regex\" to interpret the pattern as a regular expression (ripgrep syntax, e.g. `foo|bar`, `\\d+`; on a machine without ripgrep the pattern falls back to POSIX ERE, which the result discloses).",
55
+ inputSchema: {
56
+ type: "object",
57
+ properties: {
58
+ pattern: {
59
+ type: "string",
60
+ description: 'String to search for. Interpreted literally unless pattern_type is "regex", in which case it is a regular expression.',
61
+ },
62
+ path: { type: "string", description: "Optional subdirectory, relative to the repository root" },
63
+ pattern_type: {
64
+ type: "string",
65
+ enum: ["literal", "regex"],
66
+ default: "literal",
67
+ description: '"literal" (default) matches pattern as a fixed string; "regex" interprets it as a regex.',
68
+ },
69
+ },
70
+ required: ["pattern"],
71
+ },
72
+ // The optional `path` is path-bearing and is gated exactly like Read's: the
73
+ // policy resolves it through resolveWithin, denying escapes as breaches.
74
+ // `pattern` is not a path and needs no path gating.
75
+ scope: { pathFields: ["path"] },
76
+ async run(input, ctx) {
77
+ const pattern = input.pattern;
78
+ if (typeof pattern !== "string")
79
+ return { content: "pattern must be a string", isError: true };
80
+ const patternType = input.pattern_type;
81
+ if (patternType !== undefined && patternType !== "literal" && patternType !== "regex") {
82
+ return { content: 'pattern_type must be "literal" or "regex"', isError: true };
83
+ }
84
+ const mode = patternType === "regex" ? "regex" : "literal";
85
+ const binary = _grepDeps.which("rg") ? "rg" : _grepDeps.which("grep") ? "grep" : null;
86
+ if (binary === null) {
87
+ return { content: "neither ripgrep nor grep is available on this machine", isError: true };
88
+ }
89
+ const [target] = ctx.resolvedPaths;
90
+ // The I/O ceiling, not the model-facing cap: `maxBytes` shapes what the
91
+ // model is told and belongs to the session's truncation policy, while this
92
+ // bound only keeps a search whose result is enormous from being buffered
93
+ // without limit. Bounding both the drain and the returned body at the same
94
+ // value is what lets a result in (maxBytes, readCeiling) reach that policy
95
+ // whole, and it is why the ceiling is a tool-layer constant.
96
+ const ioCeiling = ctx.readCeiling ?? READ_CEILING;
97
+ // nax-git-env-allow: not git: rg/grep search argv
98
+ const proc = _grepDeps.spawn(buildGrepArgv(binary, pattern, target, mode), {
99
+ cwd: ctx.root,
100
+ stdout: "pipe",
101
+ stderr: "pipe",
102
+ });
103
+ const timer = setTimeout(() => {
104
+ try {
105
+ proc.kill("SIGKILL");
106
+ }
107
+ catch {
108
+ // already exited
109
+ }
110
+ }, GREP_TIMEOUT_MS);
111
+ // Drain concurrently: a large result set fills the pipe buffer and would
112
+ // otherwise block the process before it can exit. Bounded, because the
113
+ // result is truncated to the same ceiling anyway -- a search matching a
114
+ // generated file could otherwise buffer far more than is ever returned,
115
+ // limited only by how much the binary emits before the timeout fires.
116
+ const stdoutText = drainBounded(proc.stdout, ioCeiling).catch(() => "");
117
+ const stderrText = drainBounded(proc.stderr, ioCeiling).catch(() => "");
118
+ const exitCode = await proc.exited;
119
+ clearTimeout(timer);
120
+ const stdout = await stdoutText;
121
+ // Two independent caveats, either of which means the search the caller
122
+ // asked for is not quite the search that ran.
123
+ //
124
+ // 1. The literal disclosure fires whenever the search was literal AND the
125
+ // pattern contained a metacharacter a regex would have treated
126
+ // specially -- regardless of whether it matched. #1876 only covered the
127
+ // zero-match case; a literal match on a pattern like "foo.bar" is the
128
+ // WORSE case (#1922): the caller has positive evidence and no cue that
129
+ // "." was never a wildcard, so a real regex match was never attempted.
130
+ //
131
+ // 2. The dialect note fires when regex mode ran through the grep fallback.
132
+ // ripgrep's Rust regex and POSIX ERE are NOT the same language: `\d`,
133
+ // `\w` and `\b` are unsupported in ERE, and whether they degrade to a
134
+ // literal or to something else differs BY PLATFORM (GNU grep treats
135
+ // `\d` as `d`; the BSD grep on macOS matches a digit). Silently
136
+ // returning a different answer depending on which binary the machine
137
+ // happens to have is exactly the failure this file's header forbids of
138
+ // the fallback, so the divergence is disclosed rather than hidden.
139
+ const notes = [];
140
+ if (mode === "literal" && containsRegexMetacharacter(pattern)) {
141
+ notes.push("The search was performed literally and regex metacharacters were not interpreted.");
142
+ }
143
+ if (mode === "regex" && binary === "grep") {
144
+ notes.push("ripgrep is not installed here, so the pattern was matched with POSIX ERE via grep: escapes such as \\d, \\w and \\b are NOT supported — use [0-9], [A-Za-z0-9_] and similar instead.");
145
+ }
146
+ const caveat = notes.join(" ");
147
+ // Both binaries exit 1 for "no matches" — a normal outcome, not a failure.
148
+ if (exitCode === 1 && stdout.trim() === "") {
149
+ const base = `no matches for "${pattern}"`;
150
+ return { content: caveat === "" ? base : `${base}. ${caveat}` };
151
+ }
152
+ if (exitCode !== 0 && stdout.trim() === "") {
153
+ return { content: (await stderrText).trim() || `${binary} exited ${exitCode}`, isError: true };
154
+ }
155
+ // The caveat leads rather than trails, and the tool's own bound is applied
156
+ // to the whole body: appended after the cap it both overran the ceiling and
157
+ // was the first thing lost on a result large enough to need the cue most.
158
+ const matches = stdout.trimEnd();
159
+ const body = caveat === "" ? matches : `${caveat}\n\n${matches}`;
160
+ return { content: cutToByteCap(body, ioCeiling) };
161
+ },
162
+ };
@@ -0,0 +1,36 @@
1
+ export { _bashToolDeps, BASH_TIMEOUT_MS, createBashTool, DEFAULT_BASH_SHELL } from "./bash.ts";
2
+ export { deleteTool } from "./delete.ts";
3
+ export { _editDeps, editTool } from "./edit.ts";
4
+ export { buildGitArgv, DEFAULT_LOG_FORMAT, DEFAULT_LOG_MAX_COUNT, GIT_ESCAPE_FLAGS, GIT_READ_VERBS, gitTool, } from "./git.ts";
5
+ export { buildCommitArgvs, gitCommitTool, partitionNaxOwnedPaths } from "./git-commit.ts";
6
+ export { _globDeps, globTool } from "./glob.ts";
7
+ export { _grepDeps, buildGrepArgv, grepTool } from "./grep.ts";
8
+ export { narrowGrants, type ToolPatternNarrowing } from "./narrow-grants.ts";
9
+ export type { ExecTarget, NormalizeInput, NormalizeResult } from "./package-managers.ts";
10
+ export { classifyExec, isKnownManager, normalizeExec, normalizeManagerBinary } from "./package-managers.ts";
11
+ export type { ToolPolicyOptions } from "./policy.ts";
12
+ export { compileToolPolicy, resolveWithin } from "./policy.ts";
13
+ export type { ProtectedPathsPolicy } from "./protected-paths.ts";
14
+ export { gitExcludePathspecsOf, gitIgnorePatternsOf } from "./protected-paths.ts";
15
+ export * from "./provider-adapt.ts";
16
+ export * from "./provider-advertise.ts";
17
+ export * from "./provider-grants.ts";
18
+ export * from "./provider-sanitize.ts";
19
+ export * from "./provider-types.ts";
20
+ export { readTool } from "./read.ts";
21
+ export { type ReadFileSliceOptions, type ReadFileSliceResult, readFileSlice } from "./read-file.ts";
22
+ export type { CodingTool, ToolResult, ToolRunContext } from "./registry.ts";
23
+ export { _resetRegistryForTest, getCodingTool, listCodingTools, RESERVED_TOOL_NAMES, registerBuiltinTool, registerCodingTool, } from "./registry.ts";
24
+ export { requestCapabilityTool } from "./request-capability.ts";
25
+ export type { DeclaredCommandRequest, DeclaredCommandResult, DeclaredCommandRunner } from "./run-command.ts";
26
+ export { createRunCommandTool, substituteCommand, substituteCommandSpec } from "./run-command.ts";
27
+ export type { CodingToolOutcome, CodingToolRuntime, ToolCallContext } from "./runtime.ts";
28
+ export { _codingToolDeps, _resetBuiltinsForTest, createCodingToolRuntime, DEFAULT_TOOL_MAX_BYTES, DEFAULT_TOOL_MAX_FILE_BYTES, registerBuiltinCodingTools, } from "./runtime.ts";
29
+ export { SCRATCHPAD_DIR, scratchpadListTool, scratchpadReadTool, scratchpadWriteTool } from "./scratchpad.ts";
30
+ export { _spillDeps, applyModelTruncationPolicy, type ModelTruncationOptions, SPILL_DIR, type SpillRequest, spillRelativePath, writeSpill, } from "./spill.ts";
31
+ export type { RegisteredSink, ToolAuditSink, ToolCallRecord } from "./tool-audit.ts";
32
+ export { createNoOpToolAuditSink, createToolAuditSink, flushOpenToolAuditSinks, registerToolAuditSink, unregisterToolAuditSink, } from "./tool-audit.ts";
33
+ export { cutBufferToByteCap, MODEL_MAX_BYTES, MODEL_MAX_LINE_CHARS, MODEL_MAX_LINES, READ_CEILING, type TruncateForModelOptions, type TruncationDirection, type TruncationResult, truncateForModel, truncationDirectionFor, } from "./truncate.ts";
34
+ export type { CodingToolName, PolicyVerdict, ToolGrant, ToolPolicy, ToolScope } from "./types.ts";
35
+ export { BASH_TOOL_NAME, EXEC_TOOL_NAME } from "./types.ts";
36
+ export { writeTool } from "./write.ts";
@@ -0,0 +1,28 @@
1
+ export { _bashToolDeps, BASH_TIMEOUT_MS, createBashTool, DEFAULT_BASH_SHELL } from "./bash.js";
2
+ export { deleteTool } from "./delete.js";
3
+ export { _editDeps, editTool } from "./edit.js";
4
+ export { buildGitArgv, DEFAULT_LOG_FORMAT, DEFAULT_LOG_MAX_COUNT, GIT_ESCAPE_FLAGS, GIT_READ_VERBS, gitTool, } from "./git.js";
5
+ export { buildCommitArgvs, gitCommitTool, partitionNaxOwnedPaths } from "./git-commit.js";
6
+ export { _globDeps, globTool } from "./glob.js";
7
+ export { _grepDeps, buildGrepArgv, grepTool } from "./grep.js";
8
+ export { narrowGrants } from "./narrow-grants.js";
9
+ export { classifyExec, isKnownManager, normalizeExec, normalizeManagerBinary } from "./package-managers.js";
10
+ export { compileToolPolicy, resolveWithin } from "./policy.js";
11
+ export { gitExcludePathspecsOf, gitIgnorePatternsOf } from "./protected-paths.js";
12
+ export * from "./provider-adapt.js";
13
+ export * from "./provider-advertise.js";
14
+ export * from "./provider-grants.js";
15
+ export * from "./provider-sanitize.js";
16
+ export * from "./provider-types.js";
17
+ export { readTool } from "./read.js";
18
+ export { readFileSlice } from "./read-file.js";
19
+ export { _resetRegistryForTest, getCodingTool, listCodingTools, RESERVED_TOOL_NAMES, registerBuiltinTool, registerCodingTool, } from "./registry.js";
20
+ export { requestCapabilityTool } from "./request-capability.js";
21
+ export { createRunCommandTool, substituteCommand, substituteCommandSpec } from "./run-command.js";
22
+ export { _codingToolDeps, _resetBuiltinsForTest, createCodingToolRuntime, DEFAULT_TOOL_MAX_BYTES, DEFAULT_TOOL_MAX_FILE_BYTES, registerBuiltinCodingTools, } from "./runtime.js";
23
+ export { SCRATCHPAD_DIR, scratchpadListTool, scratchpadReadTool, scratchpadWriteTool } from "./scratchpad.js";
24
+ export { _spillDeps, applyModelTruncationPolicy, SPILL_DIR, spillRelativePath, writeSpill, } from "./spill.js";
25
+ export { createNoOpToolAuditSink, createToolAuditSink, flushOpenToolAuditSinks, registerToolAuditSink, unregisterToolAuditSink, } from "./tool-audit.js";
26
+ export { cutBufferToByteCap, MODEL_MAX_BYTES, MODEL_MAX_LINE_CHARS, MODEL_MAX_LINES, READ_CEILING, truncateForModel, truncationDirectionFor, } from "./truncate.js";
27
+ export { BASH_TOOL_NAME, EXEC_TOOL_NAME } from "./types.js";
28
+ export { writeTool } from "./write.js";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Narrowing a grant an operation inherits.
3
+ *
4
+ * `CodingToolRuntime.advertised()` intersects tool NAMES against the policy's
5
+ * grants, so an op declaring `Write` under the `unrestricted` profile received
6
+ * that profile's `["*"]` — there was no way to say "this role may write, but
7
+ * only this one file" (nax#2013).
8
+ *
9
+ * Narrowing only. `resolvePermissions` remains the single permission authority
10
+ * (CLAUDE.md, Permission Resolution): a tool the profile did not grant has no
11
+ * grant here to narrow, so nothing in this module can widen access.
12
+ *
13
+ * Glob-set intersection is undecidable in general, so the rule is structural
14
+ * rather than semantic — see each branch below.
15
+ */
16
+ import type { CodingToolName, ToolGrant } from "./types.ts";
17
+ /** Per-tool path globs an operation asks to be held to. */
18
+ export type ToolPatternNarrowing = Partial<Record<CodingToolName, readonly string[]>>;
19
+ export declare function narrowGrants(grants: readonly ToolGrant[], narrowing: ToolPatternNarrowing | undefined): readonly ToolGrant[];
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Narrowing a grant an operation inherits.
3
+ *
4
+ * `CodingToolRuntime.advertised()` intersects tool NAMES against the policy's
5
+ * grants, so an op declaring `Write` under the `unrestricted` profile received
6
+ * that profile's `["*"]` — there was no way to say "this role may write, but
7
+ * only this one file" (nax#2013).
8
+ *
9
+ * Narrowing only. `resolvePermissions` remains the single permission authority
10
+ * (CLAUDE.md, Permission Resolution): a tool the profile did not grant has no
11
+ * grant here to narrow, so nothing in this module can widen access.
12
+ *
13
+ * Glob-set intersection is undecidable in general, so the rule is structural
14
+ * rather than semantic — see each branch below.
15
+ */
16
+ import { getSafeLogger } from "#src/infra/index";
17
+ const UNCONDITIONAL = "*";
18
+ export function narrowGrants(grants, narrowing) {
19
+ if (narrowing === undefined || Object.keys(narrowing).length === 0)
20
+ return grants;
21
+ // Indexed through a Map rather than `narrowing[grant.tool]`: `ToolGrant.tool`
22
+ // is a plain string (third parties register their own names) while the
23
+ // op-facing type is keyed on CodingToolName so a typo in an op is a compile
24
+ // error. Object.entries bridges the two without a cast.
25
+ const wanted = new Map(Object.entries(narrowing).filter((entry) => entry[1] !== undefined));
26
+ const out = [];
27
+ for (const grant of grants) {
28
+ const requested = wanted.get(grant.tool);
29
+ if (requested === undefined || requested.length === 0) {
30
+ out.push(grant);
31
+ continue;
32
+ }
33
+ // An unconditional grant is wider than any concrete list, so the op's
34
+ // patterns are unambiguously a narrowing of it.
35
+ if (grant.patterns.includes(UNCONDITIONAL)) {
36
+ out.push({ tool: grant.tool, patterns: [...requested] });
37
+ continue;
38
+ }
39
+ // A scoped grant already names specific globs. Comparing two globs for
40
+ // containment is undecidable, so admit only the ones the grant's author
41
+ // wrote verbatim — which is what a scoped profile intending this writes.
42
+ const admitted = requested.filter((pattern) => grant.patterns.includes(pattern));
43
+ if (admitted.length === 0) {
44
+ getSafeLogger()?.warn("tools", "[policy] op narrowing excluded by the scoped grant — tool withheld", {
45
+ tool: grant.tool,
46
+ requested: [...requested],
47
+ granted: [...grant.patterns],
48
+ });
49
+ continue;
50
+ }
51
+ out.push({ tool: grant.tool, patterns: admitted });
52
+ }
53
+ return out;
54
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Which paths nax refuses to let an agent touch, and to which tools.
3
+ *
4
+ * A separate file rather than an addition to src/tools/policy.ts, for the same
5
+ * reason src/tools/deny-paths.ts is one: that file carries the containment
6
+ * seam and sits at the project's file-size ratchet, while this is a narrower
7
+ * concern -- it has nothing to do with resolving or containing a path, only
8
+ * with refusing one containment would otherwise allow.
9
+ *
10
+ * Segment-exact, never a prefix or substring match: `.naxignore`,
11
+ * `docs/nax/config.json` and `.nax/mono/api/notes.md` are ordinary paths a
12
+ * tool must still reach.
13
+ */
14
+ /**
15
+ * The one top-level `.nax/` entry agents may write freely: the scratchpad.
16
+ * Must equal the last segment of SCRATCHPAD_DIR (pinned by a test; importing
17
+ * it here would close a scratchpad -> policy -> nax-owned-writes cycle).
18
+ */
19
+ export declare const NAX_SCRATCHPAD_ENTRY = "scratchpad";
20
+ /**
21
+ * Entries nax loads as human-authored input. The sandbox denies these even
22
+ * when absent, so an agent cannot create one: a new `.nax/rules/x.md` would be
23
+ * injected into every later session's prompt, and `hooks.json` / `plugins/`
24
+ * run unsandboxed on the next `nax run`. `templates/` and `prompts/` are where
25
+ * `prompts.overrides` points. nax creates none of them mid-run (CLI only).
26
+ */
27
+ export declare const NAX_ALWAYS_DENIED_ENTRIES: readonly string[];
28
+ /**
29
+ * Top-level `.nax/` entries a human opened for agent writes by listing them in
30
+ * `execution.sandbox.filesystem.allowWrite` (nax#2260). Only an exact entry
31
+ * counts -- `.nax/rules`, never `.nax/rules/a.md` -- and never the scratchpad
32
+ * (always open) or a NAX_NEVER_OPT_IN entry. Relative entries resolve against
33
+ * `root`, as the sandbox's own write roots do.
34
+ */
35
+ export declare function naxWriteOptIns(root: string, allowWrite: readonly string[]): ReadonlySet<string>;
36
+ /**
37
+ * Is `resolved` one of nax's own CONFIG files, relative to `root`?
38
+ *
39
+ * `.nax/config.json`, and `.nax/mono/<package>/config.json` in a monorepo.
40
+ *
41
+ * Why these at all: `quality.commands` and `acceptance.command` are run by key
42
+ * through a shell and never pass the permission gate -- they are trusted
43
+ * because a HUMAN wrote them. That trust rests entirely on a model being
44
+ * unable to write them. An agent holding `Write` under the default
45
+ * `unrestricted` profile could otherwise add a quality command and receive an
46
+ * ungated shell on the next run, routing around every `Bash(...)` rule, the
47
+ * lexer's construct refusals and containment itself.
48
+ *
49
+ * Refused to EVERY tool, reads included -- this is the pre-existing behaviour
50
+ * and it is deliberate.
51
+ */
52
+ export declare function isNaxConfigFile(root: string, resolved: string): boolean;
53
+ /**
54
+ * The path-bearing tools that MUTATE. Read, Grep, Glob and Git are read-only
55
+ * and are deliberately absent: an agent legitimately reads its own PRD, and
56
+ * refusing that would break ordinary work to close one hole.
57
+ *
58
+ * Bash and Exec are absent because they carry no path fields -- a shell
59
+ * redirect into `.nax/` is gated by the human-authored `Bash(...)` rules and
60
+ * the lexer, which is a different seam from this one.
61
+ */
62
+ export declare const NAX_OWNED_WRITE_TOOLS: ReadonlySet<string>;
63
+ /**
64
+ * nax's run-control files at the root: the command channel an agent could
65
+ * otherwise use to PAUSE, ABORT or SKIP stories without writing any code.
66
+ *
67
+ * `.queue.txt.processing` is the atomic-rename target the queue handler reads
68
+ * from (src/execution/queue-handler.ts), so guarding only `.queue.txt` would
69
+ * leave the same hole one rename downstream.
70
+ */
71
+ export declare const QUEUE_CONTROL_FILES: ReadonlySet<string>;
72
+ /**
73
+ * The kinds of nax-owned path the raw Bash screen refuses by name.
74
+ * `"config"` is produced by the lexical `isNaxConfigFile` pass, never by
75
+ * `naxOwnedKind` -- see that function.
76
+ */
77
+ export type NaxOwnedKind = "prd" | "queue" | "config";
78
+ /**
79
+ * Is this path one nax owns the writes to, independent of WHICH tool is asking?
80
+ *
81
+ * `naxOwnedWriteRefusal` answers the same question for the four file-writing
82
+ * tools and returns prose. This predicate is the tool-agnostic half, extracted
83
+ * so the `raw` bash screen (ADR-030) can consult exactly the same path set
84
+ * without being in `NAX_OWNED_WRITE_TOOLS`. One definition, two callers.
85
+ *
86
+ * @param rel - Path relative to the permitted root, `/`-joined.
87
+ */
88
+ export declare function isNaxOwnedWritePath(rel: string): boolean;
89
+ /**
90
+ * Which kind of nax-owned write path `rel` is, or undefined when it is not one.
91
+ *
92
+ * `/`-joined and root-relative, like `isNaxOwnedWritePath`. Never returns
93
+ * `"config"` -- nax config files are recognised by the lexical
94
+ * `isNaxConfigFile` pass, which callers (`protectedHit` in policy-bash-raw.ts)
95
+ * run FIRST. Keeping the two apart is what lets the raw screen name the kind it
96
+ * matched without duplicating the config rule here.
97
+ */
98
+ export declare function naxOwnedKind(rel: string): "prd" | "queue" | undefined;
99
+ /**
100
+ * Refusal text for a Bash command that names (verb "names") or redirects into
101
+ * (verb "redirects into") a nax-owned file.
102
+ *
103
+ * Kind-specific on purpose. The previous screen returned one modification-only
104
+ * sentence for every kind, which read as "you cannot WRITE this" -- so an agent
105
+ * that only wanted to READ a PRD retried a command it will never be allowed to
106
+ * run. Each branch now says what the file IS and what the agent can do instead.
107
+ *
108
+ * The text never spells `.nax/features/` literally: `src/tools/` is covered by
109
+ * the `check:feature-dir-ssot` gate, so the PRD branch names the token the agent
110
+ * used (`hit`) rather than the tree layout.
111
+ *
112
+ * US-002: `opts.sandboxWrapped` (an available launcher) swaps only the PRD
113
+ * sentence -- reading through Bash is then allowed, writing still is not.
114
+ * `config` and `queue` are unchanged in both modes.
115
+ */
116
+ export declare function naxOwnedBashRefusal(tool: string, kind: NaxOwnedKind, hit: string, verb: "names" | "redirects into", opts?: {
117
+ sandboxWrapped?: boolean;
118
+ }): string;
119
+ /**
120
+ * Why `tool` may not touch `rel`, or `undefined` when it may.
121
+ *
122
+ * `rel` MUST be the canonical, posix-separated, root-relative spelling the
123
+ * policy itself derived -- never the caller's own. Matching the caller's
124
+ * spelling means this guard and the policy that approved the call are reading
125
+ * different strings, and every alternate spelling ("./x", "a/../x") walks past
126
+ * the guard. Same rule, and the same reason, as `matchesDenyPaths`.
127
+ *
128
+ * The PRD defines the acceptance criteria the story is judged against. An
129
+ * agent that can rewrite it can pass any review without writing any code,
130
+ * which defeats the review layer without touching a config file.
131
+ *
132
+ * The queue file is the other half of the same concern: it is the run-control
133
+ * channel, and a write there can pause, abort or skip stories outright.
134
+ */
135
+ export declare function naxOwnedWriteRefusal(tool: string, rel: string, exemptRel?: string, optIns?: ReadonlySet<string>): string | undefined;