@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,91 @@
1
+ /**
2
+ * @nathapp/nax-agent/internal: what nax reaches below the public entry -- shared
3
+ * helpers, NaxError, deep modules and the _*Deps test seams.
4
+ *
5
+ * NAX-ONLY AND OUTSIDE SEMVER. Nothing here is a supported API for any other
6
+ * consumer: names, shapes and behaviour change in any release, patch included.
7
+ * It exists because nax bundles this package and its tests patch the seams. It
8
+ * re-exports the same module instances, so patching a seam here patches the
9
+ * object the agent reads. `.` exports no "_" name; every seam and reset hook
10
+ * lives here (S2 spec section 5.3).
11
+ *
12
+ * Written by the S1-5 move script; maintained by hand from here on.
13
+ */
14
+ export * from "#src/coding-tools/coding-tool-bash";
15
+ export * from "#src/coding-tools/coding-tool-sandbox";
16
+ export * from "#src/coding-tools/coding-tool-support";
17
+ export * as codingToolSupportModule from "#src/coding-tools/coding-tool-support";
18
+ export * from "#src/coding-tools/universal-coding-tools";
19
+ export * from "#src/command-interceptor/index";
20
+ export { _commandShadowDeps } from "#src/command-safety/shadow";
21
+ export { _systemOneClientDeps } from "#src/command-safety/systemone-client";
22
+ export * from "#src/config/bash-approval";
23
+ export * from "#src/config/catalog-overrides";
24
+ export * from "#src/config/native-agent/index";
25
+ export * from "#src/config/schemas-sandbox";
26
+ export * as coreModule from "#src/cost/core/index";
27
+ export * from "#src/infra/errors";
28
+ export * from "#src/infra/index";
29
+ export * as infraModule from "#src/infra/index";
30
+ export * from "#src/infra/spin-breaker/index";
31
+ export * from "#src/internal/agent-output-env";
32
+ export * from "#src/internal/argv-exec";
33
+ export * from "#src/internal/command-spec/index";
34
+ export * from "#src/internal/file-lock";
35
+ export * from "#src/internal/git-add";
36
+ export * from "#src/internal/git-env";
37
+ export * from "#src/internal/git-exec";
38
+ export * as gitExecModule from "#src/internal/git-exec";
39
+ export * from "#src/internal/path-file-lock";
40
+ export * from "#src/internal/process-alive";
41
+ export * from "#src/internal/process-kill";
42
+ export * from "#src/internal/realpath";
43
+ export * from "#src/internal/redact";
44
+ export * from "#src/internal/shell-quote";
45
+ export * from "#src/internal/sort";
46
+ export * from "#src/internal/strip-control-chars";
47
+ export * from "#src/internal/thenable";
48
+ export * from "#src/native/adapter-deps";
49
+ export * from "#src/native/auth";
50
+ export * from "#src/native/client";
51
+ export * from "#src/native/credentials/chained-store";
52
+ export * from "#src/native/credentials/change-guard";
53
+ export * from "#src/native/credentials/exec-source";
54
+ export * from "#src/native/credentials/fingerprint";
55
+ export * from "#src/native/credentials/index";
56
+ export * from "#src/native/errors";
57
+ export * from "#src/native/model-resolver";
58
+ export * from "#src/native/models";
59
+ export * from "#src/native/session/compaction";
60
+ export * from "#src/native/session/loop-events/external-handler";
61
+ export * from "#src/native/session/loop-events/index";
62
+ export * from "#src/native/session/loop-events/types";
63
+ export * from "#src/native/session/session";
64
+ export * as sessionModule from "#src/native/session/session";
65
+ export * from "#src/native/session/tool-mapping";
66
+ export * from "#src/native/session/transcript-store";
67
+ export * as transcriptStoreModule from "#src/native/session/transcript-store";
68
+ export * from "#src/native/session/turn-accumulator";
69
+ export * from "#src/native/session/turn-complete-step";
70
+ export * from "#src/native/session/turn-events";
71
+ export * from "#src/native/session/turn-loop";
72
+ export * from "#src/native/session/turn-retry";
73
+ export * from "#src/native/session/turn-types";
74
+ export * from "#src/native/session-affinity";
75
+ export * from "#src/permissions/index";
76
+ export * from "#src/sandbox/index";
77
+ export * as policyInputsModule from "#src/sandbox/policy-inputs";
78
+ export * from "#src/tools/git";
79
+ export * from "#src/tools/git-commit";
80
+ export * from "#src/tools/grep";
81
+ export * from "#src/tools/index";
82
+ export * from "#src/tools/package-managers";
83
+ export * from "#src/tools/policy";
84
+ export * from "#src/tools/provider-grants";
85
+ export * as readFileModule from "#src/tools/read-file";
86
+ export * from "#src/tools/registry";
87
+ export * from "#src/tools/run-command";
88
+ export * from "#src/tools/run-command-exec";
89
+ export * from "#src/tools/runtime";
90
+ export * from "#src/tools/tool-audit";
91
+ export * as truncateModule from "#src/tools/truncate";
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @nathapp/nax-agent/internal: what nax reaches below the public entry -- shared
3
+ * helpers, NaxError, deep modules and the _*Deps test seams.
4
+ *
5
+ * NAX-ONLY AND OUTSIDE SEMVER. Nothing here is a supported API for any other
6
+ * consumer: names, shapes and behaviour change in any release, patch included.
7
+ * It exists because nax bundles this package and its tests patch the seams. It
8
+ * re-exports the same module instances, so patching a seam here patches the
9
+ * object the agent reads. `.` exports no "_" name; every seam and reset hook
10
+ * lives here (S2 spec section 5.3).
11
+ *
12
+ * Written by the S1-5 move script; maintained by hand from here on.
13
+ */
14
+ export * from "#src/coding-tools/coding-tool-bash";
15
+ export * from "#src/coding-tools/coding-tool-sandbox";
16
+ export * from "#src/coding-tools/coding-tool-support";
17
+ export * as codingToolSupportModule from "#src/coding-tools/coding-tool-support";
18
+ export * from "#src/coding-tools/universal-coding-tools";
19
+ export * from "#src/command-interceptor/index";
20
+ export { _commandShadowDeps } from "#src/command-safety/shadow";
21
+ export { _systemOneClientDeps } from "#src/command-safety/systemone-client";
22
+ export * from "#src/config/bash-approval";
23
+ export * from "#src/config/catalog-overrides";
24
+ export * from "#src/config/native-agent/index";
25
+ export * from "#src/config/schemas-sandbox";
26
+ export * as coreModule from "#src/cost/core/index";
27
+ export * from "#src/infra/errors";
28
+ export * from "#src/infra/index";
29
+ export * as infraModule from "#src/infra/index";
30
+ export * from "#src/infra/spin-breaker/index";
31
+ export * from "#src/internal/agent-output-env";
32
+ export * from "#src/internal/argv-exec";
33
+ export * from "#src/internal/command-spec/index";
34
+ export * from "#src/internal/file-lock";
35
+ export * from "#src/internal/git-add";
36
+ export * from "#src/internal/git-env";
37
+ export * from "#src/internal/git-exec";
38
+ export * as gitExecModule from "#src/internal/git-exec";
39
+ export * from "#src/internal/path-file-lock";
40
+ export * from "#src/internal/process-alive";
41
+ export * from "#src/internal/process-kill";
42
+ export * from "#src/internal/realpath";
43
+ export * from "#src/internal/redact";
44
+ export * from "#src/internal/shell-quote";
45
+ export * from "#src/internal/sort";
46
+ export * from "#src/internal/strip-control-chars";
47
+ export * from "#src/internal/thenable";
48
+ export * from "#src/native/adapter-deps";
49
+ export * from "#src/native/auth";
50
+ export * from "#src/native/client";
51
+ export * from "#src/native/credentials/chained-store";
52
+ export * from "#src/native/credentials/change-guard";
53
+ export * from "#src/native/credentials/exec-source";
54
+ export * from "#src/native/credentials/fingerprint";
55
+ export * from "#src/native/credentials/index";
56
+ export * from "#src/native/errors";
57
+ export * from "#src/native/model-resolver";
58
+ export * from "#src/native/models";
59
+ export * from "#src/native/session/compaction";
60
+ export * from "#src/native/session/loop-events/external-handler";
61
+ export * from "#src/native/session/loop-events/index";
62
+ export * from "#src/native/session/loop-events/types";
63
+ export * from "#src/native/session/session";
64
+ export * as sessionModule from "#src/native/session/session";
65
+ export * from "#src/native/session/tool-mapping";
66
+ export * from "#src/native/session/transcript-store";
67
+ export * as transcriptStoreModule from "#src/native/session/transcript-store";
68
+ export * from "#src/native/session/turn-accumulator";
69
+ export * from "#src/native/session/turn-complete-step";
70
+ export * from "#src/native/session/turn-events";
71
+ export * from "#src/native/session/turn-loop";
72
+ export * from "#src/native/session/turn-retry";
73
+ export * from "#src/native/session/turn-types";
74
+ export * from "#src/native/session-affinity";
75
+ export * from "#src/permissions/index";
76
+ export * from "#src/sandbox/index";
77
+ export * as policyInputsModule from "#src/sandbox/policy-inputs";
78
+ export * from "#src/tools/git";
79
+ export * from "#src/tools/git-commit";
80
+ export * from "#src/tools/grep";
81
+ export * from "#src/tools/index";
82
+ export * from "#src/tools/package-managers";
83
+ export * from "#src/tools/policy";
84
+ export * from "#src/tools/provider-grants";
85
+ export * as readFileModule from "#src/tools/read-file";
86
+ export * from "#src/tools/registry";
87
+ export * from "#src/tools/run-command";
88
+ export * from "#src/tools/run-command-exec";
89
+ export * from "#src/tools/runtime";
90
+ export * from "#src/tools/tool-audit";
91
+ export * as truncateModule from "#src/tools/truncate";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Seams and small helpers shared by the native session adapter and
3
+ * `nativeComplete` (S1 port 2). `_adapterDeps` is the test seam the adapter
4
+ * tests patch; both callers read it from here, so one patch reaches both.
5
+ */
6
+ import type { AuthStamp } from "#src/session/session-types";
7
+ import { anyAmbientCredential, listStoredProviders } from "./auth.ts";
8
+ import { authSourceIsExec, servedAuth } from "./credentials/index.ts";
9
+ export declare function isProtocolStreamError(err: unknown): err is {
10
+ protocolError: {
11
+ kind: string;
12
+ message: string;
13
+ };
14
+ };
15
+ /** Test seam, following the _clientDeps precedent. */
16
+ export declare const _adapterDeps: {
17
+ listStoredProviders: typeof listStoredProviders;
18
+ anyAmbientCredential: typeof anyAmbientCredential;
19
+ /**
20
+ * US-004: whether the global auth config points at an exec helper. Injectable
21
+ * so a test can pin the credential-source decision without writing
22
+ * `~/.nax/config.json`.
23
+ */
24
+ authSourceIsExec: typeof authSourceIsExec;
25
+ /** US-006: the identity the store observed for a provider — injectable like its siblings. */
26
+ servedAuth: typeof servedAuth;
27
+ /**
28
+ * Injectable timer pair — lets the whole-turn deadline test (US-002 AC12)
29
+ * drive the abort off a virtual clock instead of waiting the schema
30
+ * minimum. Mirrors `_heartbeatDeps` / `_idleWatchdogDeps` / `_authDeps`.
31
+ *
32
+ * @internal
33
+ */
34
+ setTimeout: (fn: () => void, ms: number) => unknown;
35
+ clearTimeout: (id: unknown) => void;
36
+ };
37
+ /**
38
+ * US-006: `{ auth }` for the identity the credential store observed for
39
+ * `provider`, `{}` otherwise — so the key stays absent, never `undefined`. A
40
+ * helper because `sendTurn` cannot carry another branch on the complexity
41
+ * ratchet; it reads the `_adapterDeps` seam so a unit test can pin the stamp
42
+ * without assembling a real store.
43
+ */
44
+ export declare function authFields(provider: string): {
45
+ auth?: AuthStamp;
46
+ };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Seams and small helpers shared by the native session adapter and
3
+ * `nativeComplete` (S1 port 2). `_adapterDeps` is the test seam the adapter
4
+ * tests patch; both callers read it from here, so one patch reaches both.
5
+ */
6
+ import { anyAmbientCredential, listStoredProviders } from "./auth.js";
7
+ import { authSourceIsExec, servedAuth } from "./credentials/index.js";
8
+ export function isProtocolStreamError(err) {
9
+ return typeof err === "object" && err !== null && "protocolError" in err;
10
+ }
11
+ /** Test seam, following the _clientDeps precedent. */
12
+ export const _adapterDeps = {
13
+ listStoredProviders,
14
+ anyAmbientCredential,
15
+ /**
16
+ * US-004: whether the global auth config points at an exec helper. Injectable
17
+ * so a test can pin the credential-source decision without writing
18
+ * `~/.nax/config.json`.
19
+ */
20
+ authSourceIsExec,
21
+ /** US-006: the identity the store observed for a provider — injectable like its siblings. */
22
+ servedAuth,
23
+ /**
24
+ * Injectable timer pair — lets the whole-turn deadline test (US-002 AC12)
25
+ * drive the abort off a virtual clock instead of waiting the schema
26
+ * minimum. Mirrors `_heartbeatDeps` / `_idleWatchdogDeps` / `_authDeps`.
27
+ *
28
+ * @internal
29
+ */
30
+ setTimeout: ((fn, ms) => setTimeout(fn, ms)),
31
+ clearTimeout: ((id) => clearTimeout(id)),
32
+ };
33
+ /**
34
+ * US-006: `{ auth }` for the identity the credential store observed for
35
+ * `provider`, `{}` otherwise — so the key stays absent, never `undefined`. A
36
+ * helper because `sendTurn` cannot carry another branch on the complexity
37
+ * ratchet; it reads the `_adapterDeps` seam so a unit test can pin the stamp
38
+ * without assembling a real store.
39
+ */
40
+ export function authFields(provider) {
41
+ const auth = _adapterDeps.servedAuth(provider);
42
+ return auth === undefined ? {} : { auth };
43
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * nax's own login vocabulary.
3
+ *
4
+ * A deliberate mirror of nax-ai's LoginInteraction family. It exists so the
5
+ * CLI can implement a terminal interaction without importing nax-ai, which
6
+ * packages/repo-tooling/scripts/check-nax-ai-imports.ts confines to this directory. The mapper in
7
+ * auth.ts is the only translation point, so a rename upstream is a one-file
8
+ * change here.
9
+ *
10
+ * This module imports nothing. That is what keeps it a leaf, so the barrel can
11
+ * re-export it without creating an import cycle.
12
+ */
13
+ export type AuthMethod = "api-key" | "oauth";
14
+ export interface AuthOption {
15
+ id: string;
16
+ label: string;
17
+ description?: string;
18
+ }
19
+ export type AuthPrompt = {
20
+ signal?: AbortSignal;
21
+ } & ({
22
+ type: "text";
23
+ message: string;
24
+ placeholder?: string;
25
+ } | {
26
+ type: "secret";
27
+ message: string;
28
+ placeholder?: string;
29
+ } | {
30
+ type: "select";
31
+ message: string;
32
+ options: readonly AuthOption[];
33
+ } | {
34
+ type: "manual-code";
35
+ message: string;
36
+ placeholder?: string;
37
+ });
38
+ export interface AuthLink {
39
+ url: string;
40
+ label?: string;
41
+ }
42
+ export type AuthEvent = {
43
+ type: "info";
44
+ message: string;
45
+ links?: readonly AuthLink[];
46
+ } | {
47
+ type: "auth-url";
48
+ url: string;
49
+ instructions?: string;
50
+ } | {
51
+ type: "device-code";
52
+ userCode: string;
53
+ verificationUri: string;
54
+ intervalSeconds?: number;
55
+ expiresInSeconds?: number;
56
+ } | {
57
+ type: "progress";
58
+ message: string;
59
+ };
60
+ /** `prompt` returns the entered text, or for `select` the chosen option id. Reject to cancel. */
61
+ export interface AuthInteraction {
62
+ prompt(prompt: AuthPrompt): Promise<string>;
63
+ notify(event: AuthEvent): void;
64
+ }
65
+ /** Metadata only. The credential is written to the store and never returned. */
66
+ export interface AuthResult {
67
+ providerId: string;
68
+ method: AuthMethod;
69
+ kind: "api-key" | "oauth";
70
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * nax's own login vocabulary.
3
+ *
4
+ * A deliberate mirror of nax-ai's LoginInteraction family. It exists so the
5
+ * CLI can implement a terminal interaction without importing nax-ai, which
6
+ * packages/repo-tooling/scripts/check-nax-ai-imports.ts confines to this directory. The mapper in
7
+ * auth.ts is the only translation point, so a rename upstream is a one-file
8
+ * change here.
9
+ *
10
+ * This module imports nothing. That is what keeps it a leaf, so the barrel can
11
+ * re-export it without creating an import cycle.
12
+ */
13
+ export {};
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Obtaining and managing credentials, in nax's vocabulary.
3
+ *
4
+ * This file and its siblings are the only place in src/ permitted to import
5
+ * nax-ai (packages/repo-tooling/scripts/check-nax-ai-imports.ts). Nothing it exports carries a
6
+ * nax-ai type, so src/cli/auth.ts can consume it without breaching that gate.
7
+ */
8
+ import { ambientAuthAvailable, type LoginInteraction, login } from "@nathapp/nax-ai";
9
+ import type { AuthInteraction, AuthMethod, AuthResult } from "./auth-types.ts";
10
+ import { type StoredEntry } from "./credentials/index.ts";
11
+ /**
12
+ * Deliberately dumb: the two vocabularies are one-for-one by design, so this
13
+ * is a rename boundary rather than a translation with opinions. Both sides use
14
+ * kebab-case, so the names pass straight through.
15
+ */
16
+ export declare function toLoginInteraction(interaction: AuthInteraction): LoginInteraction;
17
+ /**
18
+ * Cancellation is not a failure, and the CLI needs to tell them apart to exit
19
+ * 130 silently. A marker class rather than a code match: an exit status should
20
+ * not depend on message text.
21
+ */
22
+ export declare class AuthCancelledError extends Error {
23
+ readonly providerId: string;
24
+ constructor(providerId: string);
25
+ }
26
+ /** Test seam, following the _clientDeps precedent. */
27
+ export declare const _authDeps: {
28
+ login: typeof login;
29
+ ambientAuthAvailable: typeof ambientAuthAvailable;
30
+ providerIds: () => Promise<string[]>;
31
+ /**
32
+ * Injectable timer pair — lets tests drive `anyAmbientCredential`'s
33
+ * expiry branch off a virtual clock instead of waiting the full 2s
34
+ * production timeout. Mirrors `_heartbeatDeps` / `_idleWatchdogDeps`.
35
+ *
36
+ * @internal
37
+ */
38
+ setTimeout: (fn: () => void, ms: number) => unknown;
39
+ clearTimeout: (id: unknown) => void;
40
+ };
41
+ /**
42
+ * Obtain a credential and write it to the store.
43
+ *
44
+ * `method` is forwarded, not interpreted: nax-ai owns the table of what each
45
+ * provider offers and rejects an unavailable choice itself. Omitted, it runs
46
+ * its own selection prompt. Deciding here is how the two drift apart.
47
+ *
48
+ * The result is reported exactly as returned. kind is never derived from
49
+ * method — M5's design predicted openrouter would report kind "api-key" and
50
+ * its live run reported "oauth".
51
+ */
52
+ export declare function runLogin(providerId: string, interaction: AuthInteraction, method?: AuthMethod): Promise<AuthResult>;
53
+ export declare const DEFAULT_PI_AUTH_PATH: string;
54
+ export interface ImportOutcome {
55
+ providerId: string;
56
+ status: "imported" | "skipped" | "unsupported";
57
+ }
58
+ /**
59
+ * Bring pi's credentials across.
60
+ *
61
+ * Existing entries are skipped rather than overwritten: import plausibly runs
62
+ * after a fresh login, and silently replacing a credential just obtained would
63
+ * be the worst kind of quiet data loss.
64
+ *
65
+ * The presence check happens inside modify()'s callback, not before it: that
66
+ * is what holds the store's cross-process lock across the whole
67
+ * read-modify-write. Deciding "already present" from a separate, unlocked
68
+ * read would race a concurrent login completing between the two calls.
69
+ */
70
+ export declare function importPiCredentials(options?: {
71
+ from?: string;
72
+ force?: boolean;
73
+ }): Promise<ImportOutcome[]>;
74
+ export declare function listStoredProviders(): Promise<StoredEntry[]>;
75
+ /**
76
+ * Removal, not revocation. pi has no revocation anywhere — its own types
77
+ * define logout as deletion — so the provider-side token stays live until it
78
+ * expires. Callers must not describe this as logging out.
79
+ */
80
+ export declare function removeStoredProvider(providerId: string): Promise<void>;
81
+ export declare function authImportOutcomeLabel(status: ImportOutcome["status"]): string;
82
+ /**
83
+ * Of these providers, which would ambient auth satisfy on its own?
84
+ *
85
+ * A stored credential owns its provider in pi's resolution order, so any
86
+ * provider named here has a working environment variable that the stored
87
+ * credential is shadowing. This only ever decorates a diagnostic, so a failing
88
+ * probe reports nothing rather than breaking the command around it.
89
+ */
90
+ export declare function ambientShadows(providerIds: readonly string[]): Promise<string[]>;
91
+ /**
92
+ * Of these providers, which have NO credential at all — neither stored nor
93
+ * ambient?
94
+ *
95
+ * Asked for the providers the default native tier map names, so an install
96
+ * whose only credential belongs to another provider fails before a billed call
97
+ * rather than at the first request.
98
+ *
99
+ * What counts as "has a credential": a credential the assembled store serves
100
+ * for that provider, or nax-ai's ambient probe answering true. That probe
101
+ * swallows its own check/resolve errors and answers false, so a provider whose
102
+ * resolution fails IS reported missing — the caller must exclude providers it
103
+ * knows authenticate some other way (catalog overrides). The two cases here
104
+ * that do not guess "no" are the ones this function can see: an unreadable
105
+ * store, and a sweep that outlives AMBIENT_PROBE_TIMEOUT_MS (pi's resolve()
106
+ * "may execute commands") — both report nothing missing.
107
+ *
108
+ * US-004: "has a stored credential" is a read through `naxCredentialStore()`,
109
+ * per provider, rather than a listing of the file. With an exec helper
110
+ * configured only the store knows which source serves a provider, and a helper
111
+ * failure (CREDENTIAL_HELPER_FAILED, CREDENTIAL_HELPER_INVALID) or a refused
112
+ * change (CREDENTIAL_CHANGED) is a run-level fault, not a missing credential —
113
+ * it propagates and refuses the run. The reads also record each provider's
114
+ * baseline (`credential.resolved`) before any story starts, which is what the
115
+ * guard later compares against. They happen before, and outside, the ambient
116
+ * sweep's race below, so a helper slower than the sweep's timeout is still
117
+ * asked — and they are issued as one batch, so N helper-served providers cost
118
+ * the slowest helper rather than the sum of all of them.
119
+ */
120
+ export declare function providersWithoutCredentials(providerIds: readonly string[]): Promise<string[]>;
121
+ /**
122
+ * Is ANY provider satisfied by ambient auth alone?
123
+ *
124
+ * Deliberately not "is provider X satisfied": the caller
125
+ * (NativeAgentAdapter.hasCredentials) has no provider to ask about, because
126
+ * the model — and so the provider — is chosen per request.
127
+ *
128
+ * Expiry resolves TRUE, not false. Pruning an agent that would have worked
129
+ * kills a run; reporting one that cannot authenticate costs a single
130
+ * request-time auth error that is already mapped and handled. Where this
131
+ * cannot answer, it must not guess "no".
132
+ */
133
+ export declare function anyAmbientCredential(): Promise<boolean>;