@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,60 @@
1
+ /**
2
+ * Failure descriptor returned (or synthesized) by an agent adapter. Part of the
3
+ * session contract (S1 spec section 4.2, port 2); `context/engine` re-exports it.
4
+ *
5
+ * The runner uses this to decide between escalation (quality) and agent
6
+ * fallback (availability), and passes it to `rebuildForAgent()` so the new
7
+ * bundle carries a failure-note chunk.
8
+ *
9
+ * See: docs/specs/SPEC-context-engine-v2.md §Availability fallback
10
+ */
11
+ export interface AdapterFailure {
12
+ /**
13
+ * "availability" — vendor quota, rate-limit, service down, auth error.
14
+ * Triggers agent fallback (same tier, different agent).
15
+ * "quality" — review/verify rejected output.
16
+ * Triggers tier escalation by default; agent fallback is opt-in.
17
+ */
18
+ category: "availability" | "quality";
19
+ /**
20
+ * Machine-readable outcome code.
21
+ * availability: fail-quota | fail-service-down | fail-auth | fail-rate-limit | fail-aborted | fail-stale
22
+ * quality: fail-timeout | fail-adapter-error | fail-quality | fail-unknown | fail-spin | fail-incomplete
23
+ *
24
+ * `fail-aborted` — the run was cancelled via AgentRunOptions.abortSignal
25
+ * (shutdown in progress). Not retriable; fallback chains should not fire.
26
+ * `fail-stale` — either (a) the idle watchdog cancelled due to no stream activity
27
+ * within the configured idle timeout, or (b) the agent finished cleanly with empty
28
+ * output. The `reason` field distinguishes: "idle-watchdog" vs "empty-output".
29
+ * Retriable up to maxRetryAttempts.
30
+ * `fail-spin` — the spin breaker ended the turn: the model kept issuing tool
31
+ * calls whose shape it had already issued, with no new work between them
32
+ * (nax#2013). Distinct from `fail-timeout` on purpose — both mean "no usable
33
+ * answer within the budget", but only this one is measurable as a spin, and
34
+ * #2013 exists because the failure mode was invisible. Retriable: the retry
35
+ * opens a fresh session, so the repetition is not carried forward.
36
+ * `fail-incomplete` — the turn ended with tool calls outstanding (transport's
37
+ * `turnIncomplete` fact), reachable through `normalizeHopOutput` even when the
38
+ * turn carries prose (nax#2054). Distinct from `fail-quality` on purpose: that
39
+ * outcome's policy is sameAgentRetry "none" + swap "quality-gated", which would
40
+ * hard-fail with no retry or swap when `agent.fallback.onQualityFailure` is off.
41
+ * Retriable on the timeout lane, same as `fail-spin`.
42
+ * `fail-invalid-tool-call` — the invalid-call budget ended the turn (nax#2047);
43
+ * not a timeout, so the retry names the rejected call (nax#2200). Timeout lane.
44
+ */
45
+ outcome: "fail-quota" | "fail-service-down" | "fail-auth" | "fail-rate-limit" | "fail-aborted" | "fail-stale" | "fail-timeout" | "fail-adapter-error" | "fail-quality" | "fail-unknown" | "fail-spin" | "fail-incomplete" | "fail-invalid-tool-call";
46
+ /** Human-readable description (≤500 chars) for the failure-note chunk */
47
+ message: string;
48
+ /** True when the same agent/tier could succeed on immediate retry */
49
+ retriable: boolean;
50
+ /** Seconds to wait before retrying (for rate-limit failures) */
51
+ retryAfterSeconds?: number;
52
+ /**
53
+ * Observability tag — distinguishes outcome subtypes. No semantic effect on retry/swap.
54
+ * Examples: "idle-watchdog" (fail-stale from idle watchdog cancellation),
55
+ * "empty-output" (fail-stale synthesized when agent returned no output).
56
+ */
57
+ reason?: string;
58
+ /** The rejected call behind a `fail-invalid-tool-call`, for the retry prompt. */
59
+ invalidToolCall?: import("./session-types.ts").InvalidToolCallDetail;
60
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Failure descriptor returned (or synthesized) by an agent adapter. Part of the
3
+ * session contract (S1 spec section 4.2, port 2); `context/engine` re-exports it.
4
+ *
5
+ * The runner uses this to decide between escalation (quality) and agent
6
+ * fallback (availability), and passes it to `rebuildForAgent()` so the new
7
+ * bundle carries a failure-note chunk.
8
+ *
9
+ * See: docs/specs/SPEC-context-engine-v2.md §Availability fallback
10
+ */
11
+ export {};
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Agent stream events: what an adapter reports while a call runs. Part of the
3
+ * session contract (S1 spec section 4.2, port 2). `runtime/agent-stream-events`
4
+ * re-exports these and keeps the bus.
5
+ */
6
+ export interface AgentStreamEventBase {
7
+ /**
8
+ * Stream-local UUID minted per turn by the emitting adapter
9
+ * (`native/session-adapter.ts` `randomUUID()`, mirrored by ACP per prompt).
10
+ * It is the watchdog's and `onActiveCall`'s handle and is NOT a durable join key.
11
+ */
12
+ readonly callId: string;
13
+ readonly runId: string;
14
+ readonly agentName: string;
15
+ readonly sessionName: string;
16
+ readonly storyId?: string;
17
+ /** Pipeline stage label. A plain string: the contract does not know nax's stage union. */
18
+ readonly stage?: string;
19
+ readonly pid?: number;
20
+ readonly timestamp: number;
21
+ /**
22
+ * The exact join key for this dispatch: the same value as the transcript's
23
+ * `owner` and the cost ledger's `scopeId`. Native only, because only native
24
+ * carries a `transcriptOwner` (ACP ignores it). It is deliberately NOT the
25
+ * sibling `callId`, which is a stream-local UUID — joining on `callId` is the
26
+ * mistake that produced nax#2045's 0-of-1,940 match rate.
27
+ *
28
+ * Absent means "unknown", never a coerced `""` and never the `callId`. An
29
+ * absent key must not be joined on; a present-but-wrong key would silently
30
+ * corrupt the join.
31
+ */
32
+ readonly scopeId?: string;
33
+ }
34
+ export interface AgentCallStartedEvent extends AgentStreamEventBase {
35
+ readonly kind: "agent.call_started";
36
+ readonly model: string;
37
+ readonly timeoutSeconds: number;
38
+ }
39
+ export interface AgentMessageUpdateEvent extends AgentStreamEventBase {
40
+ readonly kind: "agent.message_update";
41
+ readonly deltaBytes?: number;
42
+ }
43
+ export interface AgentThinkingUpdateEvent extends AgentStreamEventBase {
44
+ readonly kind: "agent.thinking_update";
45
+ readonly deltaBytes?: number;
46
+ }
47
+ export interface AgentUsageUpdateEvent extends AgentStreamEventBase {
48
+ readonly kind: "agent.usage_update";
49
+ readonly inputTokens?: number;
50
+ readonly outputTokens?: number;
51
+ readonly costUsd?: number;
52
+ /**
53
+ * Set when this usage report IS one round trip, which is the native
54
+ * transport's cadence: `turn-loop.ts` emits exactly one per `complete()`.
55
+ *
56
+ * The idle watchdog reads it to classify the event as tool-call-tier
57
+ * activity rather than semantic progress. Without it, a spinning native
58
+ * session reset `lastNonToolCallActivityAt` on every iteration and
59
+ * `toolCallOnlyIdleTimeoutSeconds` — the timer built for exactly that shape
60
+ * — could never expire (nax#2013).
61
+ *
62
+ * Absent on ACP, whose loop is separately bounded by `maxInteractions` and
63
+ * whose usage cadence is the agent's, not nax's.
64
+ */
65
+ readonly perRoundTrip?: true;
66
+ /** Cache-read tokens the provider served from its prompt cache. Absent when
67
+ * the round trip reported no cache data — never coerced to 0, so "no cache
68
+ * data" and "zero cache tokens" stay distinguishable. */
69
+ readonly cacheRead?: number;
70
+ /** Cache-creation (write) tokens the round trip billed. Absent when unknown,
71
+ * for the same reason as `cacheRead`. */
72
+ readonly cacheWrite?: number;
73
+ /** Native only: 1-based index of the round trip this usage covers, within the turn.
74
+ * Absent on a compaction-summary or retry beat, which are not round-trip boundaries. */
75
+ readonly roundTrip?: number;
76
+ /** Whose cadence this report follows. "round-trip" is nax's own loop (native);
77
+ * "agent" is the delegated agent's, which is not a nax turn marker (ACP). */
78
+ readonly cadence?: "round-trip" | "agent";
79
+ }
80
+ export interface AgentToolCallUpdateEvent extends AgentStreamEventBase {
81
+ readonly kind: "agent.tool_call_update";
82
+ readonly toolName?: string;
83
+ }
84
+ export interface AgentProcessUpdateEvent extends AgentStreamEventBase {
85
+ readonly kind: "agent.process_update";
86
+ readonly status: "spawned" | "stderr" | "cancelled" | "exited";
87
+ readonly exitCode?: number;
88
+ }
89
+ export interface AgentCallEndedEvent extends AgentStreamEventBase {
90
+ readonly kind: "agent.call_ended";
91
+ readonly status: "success" | "error" | "cancelled" | "timeout";
92
+ readonly exitCode?: number;
93
+ }
94
+ /**
95
+ * US-004: the native turn is waiting on a human approval prompt. Emitted as
96
+ * activity from the turn loop while a prompt is pending so the idle watchdog
97
+ * does not read legitimate human waiting as idleness. Carries no payload — the
98
+ * timestamp is all the watchdog reads.
99
+ */
100
+ export interface AgentAwaitingHumanEvent extends AgentStreamEventBase {
101
+ readonly kind: "agent.awaiting_human";
102
+ }
103
+ export type AgentStreamEvent = AgentCallStartedEvent | AgentMessageUpdateEvent | AgentThinkingUpdateEvent | AgentUsageUpdateEvent | AgentToolCallUpdateEvent | AgentProcessUpdateEvent | AgentCallEndedEvent | AgentAwaitingHumanEvent;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Agent stream events: what an adapter reports while a call runs. Part of the
3
+ * session contract (S1 spec section 4.2, port 2). `runtime/agent-stream-events`
4
+ * re-exports these and keeps the bus.
5
+ */
6
+ export {};
@@ -0,0 +1,53 @@
1
+ export type AdapterInteraction = {
2
+ kind: "context-tool";
3
+ name: string;
4
+ input?: unknown;
5
+ error?: string;
6
+ } | {
7
+ kind: "question";
8
+ text: string;
9
+ } | {
10
+ kind: "coding-tool";
11
+ name: string;
12
+ input?: Record<string, unknown>;
13
+ /** Turn context, for the audit ledger. Native only. */
14
+ turnId?: string;
15
+ roundTrips?: number;
16
+ toolCallId?: string;
17
+ /** Native shapes the final post-handler result at its loop chokepoint. */
18
+ deferModelTruncation?: boolean;
19
+ /**
20
+ * The turn's single abort signal (US-002). Native only, sent on every
21
+ * coding-tool request; the handler forwards it into the tool's
22
+ * `ToolCallContext` so an in-flight Bash/Exec can SIGKILL its process
23
+ * group when the turn is cancelled. Absent on the other kinds, which
24
+ * never run a tool.
25
+ */
26
+ signal?: AbortSignal;
27
+ /**
28
+ * Notifies the wiring layer that the tool is about to WAIT on something
29
+ * external (e.g. a human approval) (US-002). Native only; forwarded by
30
+ * the handler into the tool's `ToolCallContext`.
31
+ */
32
+ onWaiting?: () => void;
33
+ };
34
+ export interface AdapterInteractionResponse {
35
+ answer: string;
36
+ /** Completes deferred coding-tool audit with the final model-facing content. */
37
+ finalizeAudit?: (content: string) => void;
38
+ /**
39
+ * Present only when the permission policy refused the call.
40
+ *
41
+ * Structural rather than a string convention: `{ answer }` alone cannot
42
+ * distinguish "refused, and here is why" from "here is your file", and
43
+ * conflating the two is exactly what ADR-029 section 5 forbids.
44
+ */
45
+ denied?: {
46
+ reason: string;
47
+ breach: boolean;
48
+ };
49
+ }
50
+ export interface InteractionHandler {
51
+ onInteraction(request: AdapterInteraction): Promise<AdapterInteractionResponse | null>;
52
+ }
53
+ export declare const NO_OP_INTERACTION_HANDLER: InteractionHandler;
@@ -0,0 +1,2 @@
1
+ import { NO_OP_INTERACTION_HANDLER as RUNTIME_NO_OP_INTERACTION_HANDLER } from "#src/session/no-op-interaction-handler";
2
+ export const NO_OP_INTERACTION_HANDLER = RUNTIME_NO_OP_INTERACTION_HANDLER;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared no-op interaction handler singleton.
3
+ *
4
+ * Kept in runtime so both agent/session layers can reuse the same object
5
+ * identity without importing each other's modules.
6
+ */
7
+ export declare const NO_OP_INTERACTION_HANDLER: {
8
+ onInteraction(): Promise<null>;
9
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Shared no-op interaction handler singleton.
3
+ *
4
+ * Kept in runtime so both agent/session layers can reuse the same object
5
+ * identity without importing each other's modules.
6
+ */
7
+ export const NO_OP_INTERACTION_HANDLER = {
8
+ async onInteraction() {
9
+ return null;
10
+ },
11
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared protocol identifiers captured from adapter-backed sessions.
3
+ *
4
+ * Kept in runtime so agent/session subsystems can depend on a neutral type
5
+ * without importing each other.
6
+ */
7
+ export interface ProtocolIds {
8
+ /** Stable protocol record ID for a logical session. */
9
+ recordId: string | null;
10
+ /** Volatile physical session ID (changes on reconnect). */
11
+ sessionId: string | null;
12
+ }
@@ -0,0 +1 @@
1
+ export {};