@namzu/sdk 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1503) hide show
  1. package/CHANGELOG.md +2265 -0
  2. package/README.md +49 -53
  3. package/dist/__tests__/default-path-conformance.test.d.ts +2 -0
  4. package/dist/__tests__/default-path-conformance.test.d.ts.map +1 -0
  5. package/dist/__tests__/default-path-conformance.test.js +262 -0
  6. package/dist/__tests__/default-path-conformance.test.js.map +1 -0
  7. package/dist/__tests__/shipped-defaults.test.d.ts +2 -0
  8. package/dist/__tests__/shipped-defaults.test.d.ts.map +1 -0
  9. package/dist/__tests__/shipped-defaults.test.js +97 -0
  10. package/dist/__tests__/shipped-defaults.test.js.map +1 -0
  11. package/dist/advisory/__tests__/budget-enforcement.test.d.ts +2 -0
  12. package/dist/advisory/__tests__/budget-enforcement.test.d.ts.map +1 -0
  13. package/dist/advisory/__tests__/budget-enforcement.test.js +159 -0
  14. package/dist/advisory/__tests__/budget-enforcement.test.js.map +1 -0
  15. package/dist/advisory/__tests__/structured-response.test.d.ts +2 -0
  16. package/dist/advisory/__tests__/structured-response.test.d.ts.map +1 -0
  17. package/dist/advisory/__tests__/structured-response.test.js +99 -0
  18. package/dist/advisory/__tests__/structured-response.test.js.map +1 -0
  19. package/dist/advisory/budget.d.ts +15 -0
  20. package/dist/advisory/budget.d.ts.map +1 -0
  21. package/dist/advisory/budget.js +21 -0
  22. package/dist/advisory/budget.js.map +1 -0
  23. package/dist/advisory/context.d.ts +2 -0
  24. package/dist/advisory/context.d.ts.map +1 -1
  25. package/dist/advisory/context.js +16 -0
  26. package/dist/advisory/context.js.map +1 -1
  27. package/dist/advisory/executor.d.ts +14 -11
  28. package/dist/advisory/executor.d.ts.map +1 -1
  29. package/dist/advisory/executor.js +36 -24
  30. package/dist/advisory/executor.js.map +1 -1
  31. package/dist/advisory/executor.test.d.ts +8 -6
  32. package/dist/advisory/executor.test.d.ts.map +1 -1
  33. package/dist/advisory/executor.test.js +12 -8
  34. package/dist/advisory/executor.test.js.map +1 -1
  35. package/dist/advisory/index.d.ts +2 -0
  36. package/dist/advisory/index.d.ts.map +1 -1
  37. package/dist/advisory/index.js +2 -0
  38. package/dist/advisory/index.js.map +1 -1
  39. package/dist/advisory/parse.d.ts +23 -0
  40. package/dist/advisory/parse.d.ts.map +1 -0
  41. package/dist/advisory/parse.js +56 -0
  42. package/dist/advisory/parse.js.map +1 -0
  43. package/dist/agents/AbstractAgent.d.ts +48 -0
  44. package/dist/agents/AbstractAgent.d.ts.map +1 -1
  45. package/dist/agents/AbstractAgent.js +77 -0
  46. package/dist/agents/AbstractAgent.js.map +1 -1
  47. package/dist/agents/PipelineAgent.d.ts +10 -0
  48. package/dist/agents/PipelineAgent.d.ts.map +1 -1
  49. package/dist/agents/PipelineAgent.js +12 -0
  50. package/dist/agents/PipelineAgent.js.map +1 -1
  51. package/dist/agents/ReactiveAgent.d.ts +10 -0
  52. package/dist/agents/ReactiveAgent.d.ts.map +1 -1
  53. package/dist/agents/ReactiveAgent.js +40 -0
  54. package/dist/agents/ReactiveAgent.js.map +1 -1
  55. package/dist/agents/RouterAgent.d.ts +10 -0
  56. package/dist/agents/RouterAgent.d.ts.map +1 -1
  57. package/dist/agents/RouterAgent.js +23 -2
  58. package/dist/agents/RouterAgent.js.map +1 -1
  59. package/dist/agents/SupervisorAgent.d.ts +11 -1
  60. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  61. package/dist/agents/SupervisorAgent.js +23 -1
  62. package/dist/agents/SupervisorAgent.js.map +1 -1
  63. package/dist/agents/__tests__/idempotency-key.test.d.ts +2 -0
  64. package/dist/agents/__tests__/idempotency-key.test.d.ts.map +1 -0
  65. package/dist/agents/__tests__/idempotency-key.test.js +149 -0
  66. package/dist/agents/__tests__/idempotency-key.test.js.map +1 -0
  67. package/dist/agents/__tests__/invocation-lock.test.d.ts +2 -0
  68. package/dist/agents/__tests__/invocation-lock.test.d.ts.map +1 -0
  69. package/dist/agents/__tests__/invocation-lock.test.js +126 -0
  70. package/dist/agents/__tests__/invocation-lock.test.js.map +1 -0
  71. package/dist/agents/__tests__/reachability.test.d.ts +2 -0
  72. package/dist/agents/__tests__/reachability.test.d.ts.map +1 -0
  73. package/dist/agents/__tests__/reachability.test.js +173 -0
  74. package/dist/agents/__tests__/reachability.test.js.map +1 -0
  75. package/dist/agents/__tests__/supervisor-ledger.test.js +1 -1
  76. package/dist/agents/__tests__/supervisor-ledger.test.js.map +1 -1
  77. package/dist/agents/index.d.ts +1 -1
  78. package/dist/agents/index.d.ts.map +1 -1
  79. package/dist/agents/lock.d.ts +0 -1
  80. package/dist/agents/lock.d.ts.map +1 -1
  81. package/dist/agents/lock.js.map +1 -1
  82. package/dist/bridge/a2a/late-events.test.d.ts +2 -0
  83. package/dist/bridge/a2a/late-events.test.d.ts.map +1 -0
  84. package/dist/bridge/a2a/late-events.test.js +70 -0
  85. package/dist/bridge/a2a/late-events.test.js.map +1 -0
  86. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  87. package/dist/bridge/a2a/mapper.js +55 -3
  88. package/dist/bridge/a2a/mapper.js.map +1 -1
  89. package/dist/bridge/a2a/mapper.test.js +1 -1
  90. package/dist/bridge/a2a/mapper.test.js.map +1 -1
  91. package/dist/bridge/a2a/message.d.ts.map +1 -1
  92. package/dist/bridge/a2a/message.js +5 -1
  93. package/dist/bridge/a2a/message.js.map +1 -1
  94. package/dist/bridge/sse/late-events.test.d.ts +2 -0
  95. package/dist/bridge/sse/late-events.test.d.ts.map +1 -0
  96. package/dist/bridge/sse/late-events.test.js +163 -0
  97. package/dist/bridge/sse/late-events.test.js.map +1 -0
  98. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  99. package/dist/bridge/sse/mapper.js +100 -0
  100. package/dist/bridge/sse/mapper.js.map +1 -1
  101. package/dist/compaction/__tests__/cleared-result-recovery.test.d.ts +2 -0
  102. package/dist/compaction/__tests__/cleared-result-recovery.test.d.ts.map +1 -0
  103. package/dist/compaction/__tests__/cleared-result-recovery.test.js +101 -0
  104. package/dist/compaction/__tests__/cleared-result-recovery.test.js.map +1 -0
  105. package/dist/compaction/__tests__/context-window.test.d.ts +2 -0
  106. package/dist/compaction/__tests__/context-window.test.d.ts.map +1 -0
  107. package/dist/compaction/__tests__/context-window.test.js +62 -0
  108. package/dist/compaction/__tests__/context-window.test.js.map +1 -0
  109. package/dist/compaction/__tests__/dangling.test.js +16 -5
  110. package/dist/compaction/__tests__/dangling.test.js.map +1 -1
  111. package/dist/compaction/__tests__/lossiness.test.d.ts +2 -0
  112. package/dist/compaction/__tests__/lossiness.test.d.ts.map +1 -0
  113. package/dist/compaction/__tests__/lossiness.test.js +163 -0
  114. package/dist/compaction/__tests__/lossiness.test.js.map +1 -0
  115. package/dist/compaction/__tests__/state-across-resume.test.d.ts +2 -0
  116. package/dist/compaction/__tests__/state-across-resume.test.d.ts.map +1 -0
  117. package/dist/compaction/__tests__/state-across-resume.test.js +88 -0
  118. package/dist/compaction/__tests__/state-across-resume.test.js.map +1 -0
  119. package/dist/compaction/__tests__/tool-result-editing.test.d.ts +2 -0
  120. package/dist/compaction/__tests__/tool-result-editing.test.d.ts.map +1 -0
  121. package/dist/compaction/__tests__/tool-result-editing.test.js +184 -0
  122. package/dist/compaction/__tests__/tool-result-editing.test.js.map +1 -0
  123. package/dist/compaction/__tests__/trim-opens-on-user.test.d.ts +2 -0
  124. package/dist/compaction/__tests__/trim-opens-on-user.test.d.ts.map +1 -0
  125. package/dist/compaction/__tests__/trim-opens-on-user.test.js +109 -0
  126. package/dist/compaction/__tests__/trim-opens-on-user.test.js.map +1 -0
  127. package/dist/compaction/__tests__/verifier-model.test.d.ts +2 -0
  128. package/dist/compaction/__tests__/verifier-model.test.d.ts.map +1 -0
  129. package/dist/compaction/__tests__/verifier-model.test.js +58 -0
  130. package/dist/compaction/__tests__/verifier-model.test.js.map +1 -0
  131. package/dist/compaction/context-window.d.ts +44 -0
  132. package/dist/compaction/context-window.d.ts.map +1 -0
  133. package/dist/compaction/context-window.js +97 -0
  134. package/dist/compaction/context-window.js.map +1 -0
  135. package/dist/compaction/dangling.js +48 -1
  136. package/dist/compaction/dangling.js.map +1 -1
  137. package/dist/compaction/extractor.d.ts.map +1 -1
  138. package/dist/compaction/extractor.js +55 -1
  139. package/dist/compaction/extractor.js.map +1 -1
  140. package/dist/compaction/index.d.ts +5 -0
  141. package/dist/compaction/index.d.ts.map +1 -1
  142. package/dist/compaction/index.js +3 -0
  143. package/dist/compaction/index.js.map +1 -1
  144. package/dist/compaction/manager.d.ts +25 -0
  145. package/dist/compaction/manager.d.ts.map +1 -1
  146. package/dist/compaction/manager.js +42 -8
  147. package/dist/compaction/manager.js.map +1 -1
  148. package/dist/compaction/managers/structured.d.ts.map +1 -1
  149. package/dist/compaction/managers/structured.js +7 -3
  150. package/dist/compaction/managers/structured.js.map +1 -1
  151. package/dist/compaction/retention.d.ts +15 -0
  152. package/dist/compaction/retention.d.ts.map +1 -0
  153. package/dist/compaction/retention.js +89 -0
  154. package/dist/compaction/retention.js.map +1 -0
  155. package/dist/compaction/serializer.d.ts.map +1 -1
  156. package/dist/compaction/serializer.js +28 -11
  157. package/dist/compaction/serializer.js.map +1 -1
  158. package/dist/compaction/tool-result-editing.d.ts +54 -0
  159. package/dist/compaction/tool-result-editing.d.ts.map +1 -0
  160. package/dist/compaction/tool-result-editing.js +164 -0
  161. package/dist/compaction/tool-result-editing.js.map +1 -0
  162. package/dist/compaction/types.d.ts +10 -0
  163. package/dist/compaction/types.d.ts.map +1 -1
  164. package/dist/compaction/verifier.d.ts +20 -1
  165. package/dist/compaction/verifier.d.ts.map +1 -1
  166. package/dist/compaction/verifier.js +11 -2
  167. package/dist/compaction/verifier.js.map +1 -1
  168. package/dist/compaction/wire.d.ts +54 -0
  169. package/dist/compaction/wire.d.ts.map +1 -0
  170. package/dist/compaction/wire.js +45 -0
  171. package/dist/compaction/wire.js.map +1 -0
  172. package/dist/config/runtime.d.ts +161 -45
  173. package/dist/config/runtime.d.ts.map +1 -1
  174. package/dist/config/runtime.js +61 -19
  175. package/dist/config/runtime.js.map +1 -1
  176. package/dist/connector/builtins/http.d.ts.map +1 -1
  177. package/dist/connector/builtins/http.js +14 -1
  178. package/dist/connector/builtins/http.js.map +1 -1
  179. package/dist/connector/builtins/http.test.js +12 -0
  180. package/dist/connector/builtins/http.test.js.map +1 -1
  181. package/dist/connector/mcp/__tests__/discovery-policy.test.d.ts +2 -0
  182. package/dist/connector/mcp/__tests__/discovery-policy.test.d.ts.map +1 -0
  183. package/dist/connector/mcp/__tests__/discovery-policy.test.js +109 -0
  184. package/dist/connector/mcp/__tests__/discovery-policy.test.js.map +1 -0
  185. package/dist/connector/mcp/__tests__/list-pagination.test.d.ts +2 -0
  186. package/dist/connector/mcp/__tests__/list-pagination.test.d.ts.map +1 -0
  187. package/dist/connector/mcp/__tests__/list-pagination.test.js +81 -0
  188. package/dist/connector/mcp/__tests__/list-pagination.test.js.map +1 -0
  189. package/dist/connector/mcp/__tests__/policy.test.d.ts +2 -0
  190. package/dist/connector/mcp/__tests__/policy.test.d.ts.map +1 -0
  191. package/dist/connector/mcp/__tests__/policy.test.js +86 -0
  192. package/dist/connector/mcp/__tests__/policy.test.js.map +1 -0
  193. package/dist/connector/mcp/__tests__/protocol-negotiation.test.d.ts +2 -0
  194. package/dist/connector/mcp/__tests__/protocol-negotiation.test.d.ts.map +1 -0
  195. package/dist/connector/mcp/__tests__/protocol-negotiation.test.js +81 -0
  196. package/dist/connector/mcp/__tests__/protocol-negotiation.test.js.map +1 -0
  197. package/dist/connector/mcp/__tests__/schema-fidelity.test.d.ts +2 -0
  198. package/dist/connector/mcp/__tests__/schema-fidelity.test.d.ts.map +1 -0
  199. package/dist/connector/mcp/__tests__/schema-fidelity.test.js +206 -0
  200. package/dist/connector/mcp/__tests__/schema-fidelity.test.js.map +1 -0
  201. package/dist/connector/mcp/__tests__/structured-result.test.d.ts +2 -0
  202. package/dist/connector/mcp/__tests__/structured-result.test.d.ts.map +1 -0
  203. package/dist/connector/mcp/__tests__/structured-result.test.js +112 -0
  204. package/dist/connector/mcp/__tests__/structured-result.test.js.map +1 -0
  205. package/dist/connector/mcp/adapter.d.ts +14 -0
  206. package/dist/connector/mcp/adapter.d.ts.map +1 -1
  207. package/dist/connector/mcp/adapter.js +292 -18
  208. package/dist/connector/mcp/adapter.js.map +1 -1
  209. package/dist/connector/mcp/client.d.ts +38 -0
  210. package/dist/connector/mcp/client.d.ts.map +1 -1
  211. package/dist/connector/mcp/client.js +138 -12
  212. package/dist/connector/mcp/client.js.map +1 -1
  213. package/dist/connector/mcp/client.test.d.ts +2 -0
  214. package/dist/connector/mcp/client.test.d.ts.map +1 -0
  215. package/dist/connector/mcp/client.test.js +105 -0
  216. package/dist/connector/mcp/client.test.js.map +1 -0
  217. package/dist/connector/mcp/discovery.d.ts +32 -1
  218. package/dist/connector/mcp/discovery.d.ts.map +1 -1
  219. package/dist/connector/mcp/discovery.js +41 -4
  220. package/dist/connector/mcp/discovery.js.map +1 -1
  221. package/dist/connector/mcp/http-sse.d.ts.map +1 -1
  222. package/dist/connector/mcp/http-sse.js +15 -1
  223. package/dist/connector/mcp/http-sse.js.map +1 -1
  224. package/dist/connector/mcp/index.d.ts +3 -0
  225. package/dist/connector/mcp/index.d.ts.map +1 -1
  226. package/dist/connector/mcp/index.js +1 -0
  227. package/dist/connector/mcp/index.js.map +1 -1
  228. package/dist/connector/mcp/policy.d.ts +57 -0
  229. package/dist/connector/mcp/policy.d.ts.map +1 -0
  230. package/dist/connector/mcp/policy.js +84 -0
  231. package/dist/connector/mcp/policy.js.map +1 -0
  232. package/dist/connector/mcp/schema-refs.d.ts +26 -0
  233. package/dist/connector/mcp/schema-refs.d.ts.map +1 -0
  234. package/dist/connector/mcp/schema-refs.js +111 -0
  235. package/dist/connector/mcp/schema-refs.js.map +1 -0
  236. package/dist/constants/agent/index.d.ts.map +1 -1
  237. package/dist/constants/agent/index.js +3 -0
  238. package/dist/constants/agent/index.js.map +1 -1
  239. package/dist/constants/compaction/index.js +1 -1
  240. package/dist/constants/compaction/index.js.map +1 -1
  241. package/dist/constants/continuation.d.ts +4 -4
  242. package/dist/constants/continuation.js +4 -4
  243. package/dist/constants/mcp/index.d.ts +31 -0
  244. package/dist/constants/mcp/index.d.ts.map +1 -1
  245. package/dist/constants/mcp/index.js +31 -0
  246. package/dist/constants/mcp/index.js.map +1 -1
  247. package/dist/constants/plugin/index.d.ts +23 -2
  248. package/dist/constants/plugin/index.d.ts.map +1 -1
  249. package/dist/constants/plugin/index.js +23 -2
  250. package/dist/constants/plugin/index.js.map +1 -1
  251. package/dist/constants/sandbox/index.d.ts +2 -3
  252. package/dist/constants/sandbox/index.d.ts.map +1 -1
  253. package/dist/constants/sandbox/index.js +6 -5
  254. package/dist/constants/sandbox/index.js.map +1 -1
  255. package/dist/constants/telemetry/index.d.ts +7 -0
  256. package/dist/constants/telemetry/index.d.ts.map +1 -1
  257. package/dist/constants/telemetry/index.js +7 -0
  258. package/dist/constants/telemetry/index.js.map +1 -1
  259. package/dist/constants/tools/index.d.ts +16 -0
  260. package/dist/constants/tools/index.d.ts.map +1 -1
  261. package/dist/constants/tools/index.js +16 -0
  262. package/dist/constants/tools/index.js.map +1 -1
  263. package/dist/contracts/a2a.d.ts +94 -94
  264. package/dist/contracts/api.d.ts +40 -2
  265. package/dist/contracts/api.d.ts.map +1 -1
  266. package/dist/contracts/run-status.d.ts +17 -0
  267. package/dist/contracts/run-status.d.ts.map +1 -0
  268. package/dist/contracts/run-status.js +41 -0
  269. package/dist/contracts/run-status.js.map +1 -0
  270. package/dist/contracts/schemas.d.ts +6 -6
  271. package/dist/eval/__tests__/case-deadline.test.d.ts +2 -0
  272. package/dist/eval/__tests__/case-deadline.test.d.ts.map +1 -0
  273. package/dist/eval/__tests__/case-deadline.test.js +128 -0
  274. package/dist/eval/__tests__/case-deadline.test.js.map +1 -0
  275. package/dist/eval/__tests__/end-to-end.test.d.ts +2 -0
  276. package/dist/eval/__tests__/end-to-end.test.d.ts.map +1 -0
  277. package/dist/eval/__tests__/end-to-end.test.js +223 -0
  278. package/dist/eval/__tests__/end-to-end.test.js.map +1 -0
  279. package/dist/eval/__tests__/harness-honesty.test.d.ts +2 -0
  280. package/dist/eval/__tests__/harness-honesty.test.d.ts.map +1 -0
  281. package/dist/eval/__tests__/harness-honesty.test.js +85 -0
  282. package/dist/eval/__tests__/harness-honesty.test.js.map +1 -0
  283. package/dist/eval/__tests__/harness.test.d.ts +2 -0
  284. package/dist/eval/__tests__/harness.test.d.ts.map +1 -0
  285. package/dist/eval/__tests__/harness.test.js +207 -0
  286. package/dist/eval/__tests__/harness.test.js.map +1 -0
  287. package/dist/eval/__tests__/judge.test.d.ts +2 -0
  288. package/dist/eval/__tests__/judge.test.d.ts.map +1 -0
  289. package/dist/eval/__tests__/judge.test.js +255 -0
  290. package/dist/eval/__tests__/judge.test.js.map +1 -0
  291. package/dist/eval/__tests__/scorer-gates.test.d.ts +2 -0
  292. package/dist/eval/__tests__/scorer-gates.test.d.ts.map +1 -0
  293. package/dist/eval/__tests__/scorer-gates.test.js +136 -0
  294. package/dist/eval/__tests__/scorer-gates.test.js.map +1 -0
  295. package/dist/eval/experiment.d.ts +54 -0
  296. package/dist/eval/experiment.d.ts.map +1 -0
  297. package/dist/eval/experiment.js +263 -0
  298. package/dist/eval/experiment.js.map +1 -0
  299. package/dist/eval/from-run.d.ts +30 -0
  300. package/dist/eval/from-run.d.ts.map +1 -0
  301. package/dist/eval/from-run.js +46 -0
  302. package/dist/eval/from-run.js.map +1 -0
  303. package/dist/eval/index.d.ts +8 -0
  304. package/dist/eval/index.d.ts.map +1 -0
  305. package/dist/eval/index.js +5 -0
  306. package/dist/eval/index.js.map +1 -0
  307. package/dist/eval/judge.d.ts +63 -0
  308. package/dist/eval/judge.d.ts.map +1 -0
  309. package/dist/eval/judge.js +136 -0
  310. package/dist/eval/judge.js.map +1 -0
  311. package/dist/eval/scorers.d.ts +40 -0
  312. package/dist/eval/scorers.d.ts.map +1 -0
  313. package/dist/eval/scorers.js +151 -0
  314. package/dist/eval/scorers.js.map +1 -0
  315. package/dist/eval/types.d.ts +150 -0
  316. package/dist/eval/types.d.ts.map +1 -0
  317. package/dist/eval/types.js +2 -0
  318. package/dist/eval/types.js.map +1 -0
  319. package/dist/execution/local.d.ts.map +1 -1
  320. package/dist/execution/local.js +6 -1
  321. package/dist/execution/local.js.map +1 -1
  322. package/dist/execution/local.test.d.ts +2 -0
  323. package/dist/execution/local.test.d.ts.map +1 -0
  324. package/dist/execution/local.test.js +37 -0
  325. package/dist/execution/local.test.js.map +1 -0
  326. package/dist/gateway/__tests__/list-survives-eviction.test.d.ts +2 -0
  327. package/dist/gateway/__tests__/list-survives-eviction.test.d.ts.map +1 -0
  328. package/dist/gateway/__tests__/list-survives-eviction.test.js +102 -0
  329. package/dist/gateway/__tests__/list-survives-eviction.test.js.map +1 -0
  330. package/dist/gateway/local.d.ts +42 -2
  331. package/dist/gateway/local.d.ts.map +1 -1
  332. package/dist/gateway/local.js +110 -3
  333. package/dist/gateway/local.js.map +1 -1
  334. package/dist/manager/agent/__tests__/dispose-cancels.test.d.ts +2 -0
  335. package/dist/manager/agent/__tests__/dispose-cancels.test.d.ts.map +1 -0
  336. package/dist/manager/agent/__tests__/dispose-cancels.test.js +88 -0
  337. package/dist/manager/agent/__tests__/dispose-cancels.test.js.map +1 -0
  338. package/dist/manager/agent/__tests__/lifecycle.test.js +230 -0
  339. package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -1
  340. package/dist/manager/agent/lifecycle.d.ts +35 -0
  341. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  342. package/dist/manager/agent/lifecycle.js +117 -7
  343. package/dist/manager/agent/lifecycle.js.map +1 -1
  344. package/dist/manager/run/persistence.d.ts +90 -1
  345. package/dist/manager/run/persistence.d.ts.map +1 -1
  346. package/dist/manager/run/persistence.js +120 -0
  347. package/dist/manager/run/persistence.js.map +1 -1
  348. package/dist/plugin/__tests__/enable-contributions.test.js +3 -3
  349. package/dist/plugin/__tests__/enable-contributions.test.js.map +1 -1
  350. package/dist/plugin/__tests__/hook-ordering.test.d.ts +2 -0
  351. package/dist/plugin/__tests__/hook-ordering.test.d.ts.map +1 -0
  352. package/dist/plugin/__tests__/hook-ordering.test.js +227 -0
  353. package/dist/plugin/__tests__/hook-ordering.test.js.map +1 -0
  354. package/dist/plugin/__tests__/install-time-refusal.test.d.ts +2 -0
  355. package/dist/plugin/__tests__/install-time-refusal.test.d.ts.map +1 -0
  356. package/dist/plugin/__tests__/install-time-refusal.test.js +49 -0
  357. package/dist/plugin/__tests__/install-time-refusal.test.js.map +1 -0
  358. package/dist/plugin/__tests__/lifecycle.test.js +95 -68
  359. package/dist/plugin/__tests__/lifecycle.test.js.map +1 -1
  360. package/dist/plugin/lifecycle.d.ts +15 -1
  361. package/dist/plugin/lifecycle.d.ts.map +1 -1
  362. package/dist/plugin/lifecycle.js +67 -20
  363. package/dist/plugin/lifecycle.js.map +1 -1
  364. package/dist/plugin/loader.d.ts +15 -0
  365. package/dist/plugin/loader.d.ts.map +1 -1
  366. package/dist/plugin/loader.js +33 -1
  367. package/dist/plugin/loader.js.map +1 -1
  368. package/dist/probe/registry.d.ts.map +1 -1
  369. package/dist/probe/registry.js +19 -1
  370. package/dist/probe/registry.js.map +1 -1
  371. package/dist/probe/registry.test.d.ts +9 -3
  372. package/dist/probe/registry.test.d.ts.map +1 -1
  373. package/dist/probe/registry.test.js +44 -6
  374. package/dist/probe/registry.test.js.map +1 -1
  375. package/dist/provider/__tests__/mock-script.test.d.ts +2 -0
  376. package/dist/provider/__tests__/mock-script.test.d.ts.map +1 -0
  377. package/dist/provider/__tests__/mock-script.test.js +151 -0
  378. package/dist/provider/__tests__/mock-script.test.js.map +1 -0
  379. package/dist/provider/__tests__/retry-visibility.test.d.ts +2 -0
  380. package/dist/provider/__tests__/retry-visibility.test.d.ts.map +1 -0
  381. package/dist/provider/__tests__/retry-visibility.test.js +137 -0
  382. package/dist/provider/__tests__/retry-visibility.test.js.map +1 -0
  383. package/dist/provider/__tests__/retry.test.d.ts +2 -0
  384. package/dist/provider/__tests__/retry.test.d.ts.map +1 -0
  385. package/dist/provider/__tests__/retry.test.js +259 -0
  386. package/dist/provider/__tests__/retry.test.js.map +1 -0
  387. package/dist/provider/capabilities.d.ts +1 -0
  388. package/dist/provider/capabilities.d.ts.map +1 -1
  389. package/dist/provider/capabilities.js +2 -0
  390. package/dist/provider/capabilities.js.map +1 -1
  391. package/dist/provider/collect.d.ts +1 -1
  392. package/dist/provider/collect.js +1 -1
  393. package/dist/provider/collect.test.d.ts +1 -1
  394. package/dist/provider/collect.test.js +1 -1
  395. package/dist/provider/index.d.ts +3 -0
  396. package/dist/provider/index.d.ts.map +1 -1
  397. package/dist/provider/index.js +2 -0
  398. package/dist/provider/index.js.map +1 -1
  399. package/dist/provider/mock-register.d.ts.map +1 -1
  400. package/dist/provider/mock-register.js +5 -2
  401. package/dist/provider/mock-register.js.map +1 -1
  402. package/dist/provider/mock.d.ts +35 -5
  403. package/dist/provider/mock.d.ts.map +1 -1
  404. package/dist/provider/mock.js +104 -32
  405. package/dist/provider/mock.js.map +1 -1
  406. package/dist/provider/retry.d.ts +42 -0
  407. package/dist/provider/retry.d.ts.map +1 -0
  408. package/dist/provider/retry.js +161 -0
  409. package/dist/provider/retry.js.map +1 -0
  410. package/dist/public-runtime.d.ts +26 -7
  411. package/dist/public-runtime.d.ts.map +1 -1
  412. package/dist/public-runtime.js +50 -7
  413. package/dist/public-runtime.js.map +1 -1
  414. package/dist/public-types.d.ts +5 -1
  415. package/dist/public-types.d.ts.map +1 -1
  416. package/dist/rag/__tests__/retrieval-math.test.d.ts +2 -0
  417. package/dist/rag/__tests__/retrieval-math.test.d.ts.map +1 -0
  418. package/dist/rag/__tests__/retrieval-math.test.js +46 -0
  419. package/dist/rag/__tests__/retrieval-math.test.js.map +1 -0
  420. package/dist/rag/chunking.d.ts +12 -0
  421. package/dist/rag/chunking.d.ts.map +1 -1
  422. package/dist/rag/chunking.js +32 -1
  423. package/dist/rag/chunking.js.map +1 -1
  424. package/dist/rag/embedding.d.ts +4 -4
  425. package/dist/rag/embedding.d.ts.map +1 -1
  426. package/dist/rag/embedding.js +23 -3
  427. package/dist/rag/embedding.js.map +1 -1
  428. package/dist/rag/embedding.test.d.ts +1 -1
  429. package/dist/rag/embedding.test.js +59 -10
  430. package/dist/rag/embedding.test.js.map +1 -1
  431. package/dist/rag/index.d.ts +1 -1
  432. package/dist/rag/index.d.ts.map +1 -1
  433. package/dist/rag/index.js +1 -1
  434. package/dist/rag/index.js.map +1 -1
  435. package/dist/rag/retriever.d.ts +0 -1
  436. package/dist/rag/retriever.d.ts.map +1 -1
  437. package/dist/rag/retriever.js +75 -22
  438. package/dist/rag/retriever.js.map +1 -1
  439. package/dist/rag/vector-store.test.d.ts +1 -1
  440. package/dist/rag/vector-store.test.js +2 -2
  441. package/dist/rag/vector-store.test.js.map +1 -1
  442. package/dist/registry/ManagedRegistry.test.d.ts +1 -1
  443. package/dist/registry/ManagedRegistry.test.js +1 -1
  444. package/dist/registry/Registry.test.d.ts +1 -1
  445. package/dist/registry/Registry.test.js +1 -1
  446. package/dist/registry/connector/definitions.test.d.ts +1 -1
  447. package/dist/registry/connector/definitions.test.js +1 -1
  448. package/dist/registry/tool/__tests__/schema.test.d.ts +2 -0
  449. package/dist/registry/tool/__tests__/schema.test.d.ts.map +1 -0
  450. package/dist/registry/tool/__tests__/schema.test.js +176 -0
  451. package/dist/registry/tool/__tests__/schema.test.js.map +1 -0
  452. package/dist/registry/tool/__tests__/tool-name-validation.test.d.ts +2 -0
  453. package/dist/registry/tool/__tests__/tool-name-validation.test.d.ts.map +1 -0
  454. package/dist/registry/tool/__tests__/tool-name-validation.test.js +70 -0
  455. package/dist/registry/tool/__tests__/tool-name-validation.test.js.map +1 -0
  456. package/dist/registry/tool/execute.d.ts +37 -0
  457. package/dist/registry/tool/execute.d.ts.map +1 -1
  458. package/dist/registry/tool/execute.js +91 -21
  459. package/dist/registry/tool/execute.js.map +1 -1
  460. package/dist/registry/tool/schema.d.ts +26 -0
  461. package/dist/registry/tool/schema.d.ts.map +1 -0
  462. package/dist/registry/tool/schema.js +77 -0
  463. package/dist/registry/tool/schema.js.map +1 -0
  464. package/dist/registry/toolset/catalog.d.ts.map +1 -1
  465. package/dist/registry/toolset/catalog.js +0 -1
  466. package/dist/registry/toolset/catalog.js.map +1 -1
  467. package/dist/registry/toolset/catalog.test.js +0 -1
  468. package/dist/registry/toolset/catalog.test.js.map +1 -1
  469. package/dist/run/reporter.d.ts.map +1 -1
  470. package/dist/run/reporter.js +76 -0
  471. package/dist/run/reporter.js.map +1 -1
  472. package/dist/runtime/bidi/__tests__/session.test.d.ts +2 -0
  473. package/dist/runtime/bidi/__tests__/session.test.d.ts.map +1 -0
  474. package/dist/runtime/bidi/__tests__/session.test.js +201 -0
  475. package/dist/runtime/bidi/__tests__/session.test.js.map +1 -0
  476. package/dist/runtime/bidi/index.d.ts +5 -0
  477. package/dist/runtime/bidi/index.d.ts.map +1 -0
  478. package/dist/runtime/bidi/index.js +3 -0
  479. package/dist/runtime/bidi/index.js.map +1 -0
  480. package/dist/runtime/bidi/mock.d.ts +34 -0
  481. package/dist/runtime/bidi/mock.d.ts.map +1 -0
  482. package/dist/runtime/bidi/mock.js +60 -0
  483. package/dist/runtime/bidi/mock.js.map +1 -0
  484. package/dist/runtime/bidi/session.d.ts +44 -0
  485. package/dist/runtime/bidi/session.d.ts.map +1 -0
  486. package/dist/runtime/bidi/session.js +154 -0
  487. package/dist/runtime/bidi/session.js.map +1 -0
  488. package/dist/runtime/decision/parser.d.ts.map +1 -1
  489. package/dist/runtime/decision/parser.js +8 -1
  490. package/dist/runtime/decision/parser.js.map +1 -1
  491. package/dist/runtime/decision/parser.test.d.ts +2 -0
  492. package/dist/runtime/decision/parser.test.d.ts.map +1 -0
  493. package/dist/runtime/decision/parser.test.js +37 -0
  494. package/dist/runtime/decision/parser.test.js.map +1 -0
  495. package/dist/runtime/query/__tests__/answer-review.test.d.ts +2 -0
  496. package/dist/runtime/query/__tests__/answer-review.test.d.ts.map +1 -0
  497. package/dist/runtime/query/__tests__/answer-review.test.js +141 -0
  498. package/dist/runtime/query/__tests__/answer-review.test.js.map +1 -0
  499. package/dist/runtime/query/__tests__/capability-negotiation.test.js +24 -111
  500. package/dist/runtime/query/__tests__/capability-negotiation.test.js.map +1 -1
  501. package/dist/runtime/query/__tests__/checkpoint-store.test.js +12 -44
  502. package/dist/runtime/query/__tests__/checkpoint-store.test.js.map +1 -1
  503. package/dist/runtime/query/__tests__/checkpoint.test.js +2 -10
  504. package/dist/runtime/query/__tests__/checkpoint.test.js.map +1 -1
  505. package/dist/runtime/query/__tests__/citations.test.d.ts +2 -0
  506. package/dist/runtime/query/__tests__/citations.test.d.ts.map +1 -0
  507. package/dist/runtime/query/__tests__/citations.test.js +85 -0
  508. package/dist/runtime/query/__tests__/citations.test.js.map +1 -0
  509. package/dist/runtime/query/__tests__/content-budget.test.d.ts +2 -0
  510. package/dist/runtime/query/__tests__/content-budget.test.d.ts.map +1 -0
  511. package/dist/runtime/query/__tests__/content-budget.test.js +69 -0
  512. package/dist/runtime/query/__tests__/content-budget.test.js.map +1 -0
  513. package/dist/runtime/query/__tests__/context.test.js +3 -2
  514. package/dist/runtime/query/__tests__/context.test.js.map +1 -1
  515. package/dist/runtime/query/__tests__/deferred-tools.test.js +21 -130
  516. package/dist/runtime/query/__tests__/deferred-tools.test.js.map +1 -1
  517. package/dist/runtime/query/__tests__/delegation-resume.test.d.ts +2 -0
  518. package/dist/runtime/query/__tests__/delegation-resume.test.d.ts.map +1 -0
  519. package/dist/runtime/query/__tests__/delegation-resume.test.js +111 -0
  520. package/dist/runtime/query/__tests__/delegation-resume.test.js.map +1 -0
  521. package/dist/runtime/query/__tests__/document-attachments.test.d.ts +2 -0
  522. package/dist/runtime/query/__tests__/document-attachments.test.d.ts.map +1 -0
  523. package/dist/runtime/query/__tests__/document-attachments.test.js +92 -0
  524. package/dist/runtime/query/__tests__/document-attachments.test.js.map +1 -0
  525. package/dist/runtime/query/__tests__/durable-park-and-trace.test.d.ts +2 -0
  526. package/dist/runtime/query/__tests__/durable-park-and-trace.test.d.ts.map +1 -0
  527. package/dist/runtime/query/__tests__/durable-park-and-trace.test.js +194 -0
  528. package/dist/runtime/query/__tests__/durable-park-and-trace.test.js.map +1 -0
  529. package/dist/runtime/query/__tests__/durable-question-park.test.d.ts +2 -0
  530. package/dist/runtime/query/__tests__/durable-question-park.test.d.ts.map +1 -0
  531. package/dist/runtime/query/__tests__/durable-question-park.test.js +253 -0
  532. package/dist/runtime/query/__tests__/durable-question-park.test.js.map +1 -0
  533. package/dist/runtime/query/__tests__/durable-run-state.test.d.ts +2 -0
  534. package/dist/runtime/query/__tests__/durable-run-state.test.d.ts.map +1 -0
  535. package/dist/runtime/query/__tests__/durable-run-state.test.js +158 -0
  536. package/dist/runtime/query/__tests__/durable-run-state.test.js.map +1 -0
  537. package/dist/runtime/query/__tests__/executor-plugin-hooks.test.js +24 -20
  538. package/dist/runtime/query/__tests__/executor-plugin-hooks.test.js.map +1 -1
  539. package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.d.ts +2 -0
  540. package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.d.ts.map +1 -0
  541. package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.js +187 -0
  542. package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.js.map +1 -0
  543. package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.d.ts +2 -0
  544. package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.d.ts.map +1 -0
  545. package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.js +95 -0
  546. package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.js.map +1 -0
  547. package/dist/runtime/query/__tests__/guardrails-e2e.test.d.ts +2 -0
  548. package/dist/runtime/query/__tests__/guardrails-e2e.test.d.ts.map +1 -0
  549. package/dist/runtime/query/__tests__/guardrails-e2e.test.js +132 -0
  550. package/dist/runtime/query/__tests__/guardrails-e2e.test.js.map +1 -0
  551. package/dist/runtime/query/__tests__/guardrails.test.d.ts +2 -0
  552. package/dist/runtime/query/__tests__/guardrails.test.d.ts.map +1 -0
  553. package/dist/runtime/query/__tests__/guardrails.test.js +163 -0
  554. package/dist/runtime/query/__tests__/guardrails.test.js.map +1 -0
  555. package/dist/runtime/query/__tests__/hook-model-visibility.test.d.ts +2 -0
  556. package/dist/runtime/query/__tests__/hook-model-visibility.test.d.ts.map +1 -0
  557. package/dist/runtime/query/__tests__/hook-model-visibility.test.js +119 -0
  558. package/dist/runtime/query/__tests__/hook-model-visibility.test.js.map +1 -0
  559. package/dist/runtime/query/__tests__/long-document-flow.test.js +9 -2
  560. package/dist/runtime/query/__tests__/long-document-flow.test.js.map +1 -1
  561. package/dist/runtime/query/__tests__/memory-promotion.test.d.ts +2 -0
  562. package/dist/runtime/query/__tests__/memory-promotion.test.d.ts.map +1 -0
  563. package/dist/runtime/query/__tests__/memory-promotion.test.js +119 -0
  564. package/dist/runtime/query/__tests__/memory-promotion.test.js.map +1 -0
  565. package/dist/runtime/query/__tests__/orphan-task-turn-end.test.js +5 -27
  566. package/dist/runtime/query/__tests__/orphan-task-turn-end.test.js.map +1 -1
  567. package/dist/runtime/query/__tests__/overflow-relief.test.d.ts +2 -0
  568. package/dist/runtime/query/__tests__/overflow-relief.test.d.ts.map +1 -0
  569. package/dist/runtime/query/__tests__/overflow-relief.test.js +119 -0
  570. package/dist/runtime/query/__tests__/overflow-relief.test.js.map +1 -0
  571. package/dist/runtime/query/__tests__/partial-batch-resume.test.d.ts +2 -0
  572. package/dist/runtime/query/__tests__/partial-batch-resume.test.d.ts.map +1 -0
  573. package/dist/runtime/query/__tests__/partial-batch-resume.test.js +205 -0
  574. package/dist/runtime/query/__tests__/partial-batch-resume.test.js.map +1 -0
  575. package/dist/runtime/query/__tests__/plugin-hooks.test.js +0 -1
  576. package/dist/runtime/query/__tests__/plugin-hooks.test.js.map +1 -1
  577. package/dist/runtime/query/__tests__/prepare-step-chain.test.d.ts +2 -0
  578. package/dist/runtime/query/__tests__/prepare-step-chain.test.d.ts.map +1 -0
  579. package/dist/runtime/query/__tests__/prepare-step-chain.test.js +104 -0
  580. package/dist/runtime/query/__tests__/prepare-step-chain.test.js.map +1 -0
  581. package/dist/runtime/query/__tests__/prepare-step.test.d.ts +2 -0
  582. package/dist/runtime/query/__tests__/prepare-step.test.d.ts.map +1 -0
  583. package/dist/runtime/query/__tests__/prepare-step.test.js +194 -0
  584. package/dist/runtime/query/__tests__/prepare-step.test.js.map +1 -0
  585. package/dist/runtime/query/__tests__/probe-veto-is-error.test.d.ts +2 -0
  586. package/dist/runtime/query/__tests__/probe-veto-is-error.test.d.ts.map +1 -0
  587. package/dist/runtime/query/__tests__/probe-veto-is-error.test.js +111 -0
  588. package/dist/runtime/query/__tests__/probe-veto-is-error.test.js.map +1 -0
  589. package/dist/runtime/query/__tests__/prompt.test.js +1 -1
  590. package/dist/runtime/query/__tests__/prompt.test.js.map +1 -1
  591. package/dist/runtime/query/__tests__/provider-fault-pauses.test.d.ts +2 -0
  592. package/dist/runtime/query/__tests__/provider-fault-pauses.test.d.ts.map +1 -0
  593. package/dist/runtime/query/__tests__/provider-fault-pauses.test.js +86 -0
  594. package/dist/runtime/query/__tests__/provider-fault-pauses.test.js.map +1 -0
  595. package/dist/runtime/query/__tests__/reasoning-stream.test.d.ts +2 -0
  596. package/dist/runtime/query/__tests__/reasoning-stream.test.d.ts.map +1 -0
  597. package/dist/runtime/query/__tests__/reasoning-stream.test.js +146 -0
  598. package/dist/runtime/query/__tests__/reasoning-stream.test.js.map +1 -0
  599. package/dist/runtime/query/__tests__/recoverable-settle.test.d.ts +2 -0
  600. package/dist/runtime/query/__tests__/recoverable-settle.test.d.ts.map +1 -0
  601. package/dist/runtime/query/__tests__/recoverable-settle.test.js +119 -0
  602. package/dist/runtime/query/__tests__/recoverable-settle.test.js.map +1 -0
  603. package/dist/runtime/query/__tests__/resume-budget.test.d.ts +2 -0
  604. package/dist/runtime/query/__tests__/resume-budget.test.d.ts.map +1 -0
  605. package/dist/runtime/query/__tests__/resume-budget.test.js +130 -0
  606. package/dist/runtime/query/__tests__/resume-budget.test.js.map +1 -0
  607. package/dist/runtime/query/__tests__/resume-pending.test.d.ts +2 -0
  608. package/dist/runtime/query/__tests__/resume-pending.test.d.ts.map +1 -0
  609. package/dist/runtime/query/__tests__/resume-pending.test.js +226 -0
  610. package/dist/runtime/query/__tests__/resume-pending.test.js.map +1 -0
  611. package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.d.ts +2 -0
  612. package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.d.ts.map +1 -0
  613. package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.js +89 -0
  614. package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.js.map +1 -0
  615. package/dist/runtime/query/__tests__/stop-condition.test.d.ts +2 -0
  616. package/dist/runtime/query/__tests__/stop-condition.test.d.ts.map +1 -0
  617. package/dist/runtime/query/__tests__/stop-condition.test.js +205 -0
  618. package/dist/runtime/query/__tests__/stop-condition.test.js.map +1 -0
  619. package/dist/runtime/query/__tests__/structured-output.test.d.ts +2 -0
  620. package/dist/runtime/query/__tests__/structured-output.test.d.ts.map +1 -0
  621. package/dist/runtime/query/__tests__/structured-output.test.js +219 -0
  622. package/dist/runtime/query/__tests__/structured-output.test.js.map +1 -0
  623. package/dist/runtime/query/__tests__/structured-run-failure.test.d.ts +2 -0
  624. package/dist/runtime/query/__tests__/structured-run-failure.test.d.ts.map +1 -0
  625. package/dist/runtime/query/__tests__/structured-run-failure.test.js +117 -0
  626. package/dist/runtime/query/__tests__/structured-run-failure.test.js.map +1 -0
  627. package/dist/runtime/query/__tests__/terminal-tool.test.d.ts +2 -0
  628. package/dist/runtime/query/__tests__/terminal-tool.test.d.ts.map +1 -0
  629. package/dist/runtime/query/__tests__/terminal-tool.test.js +119 -0
  630. package/dist/runtime/query/__tests__/terminal-tool.test.js.map +1 -0
  631. package/dist/runtime/query/__tests__/tool-grants.test.d.ts +2 -0
  632. package/dist/runtime/query/__tests__/tool-grants.test.d.ts.map +1 -0
  633. package/dist/runtime/query/__tests__/tool-grants.test.js +85 -0
  634. package/dist/runtime/query/__tests__/tool-grants.test.js.map +1 -0
  635. package/dist/runtime/query/__tests__/tool-output-budget.test.d.ts +2 -0
  636. package/dist/runtime/query/__tests__/tool-output-budget.test.d.ts.map +1 -0
  637. package/dist/runtime/query/__tests__/tool-output-budget.test.js +0 -0
  638. package/dist/runtime/query/__tests__/tool-output-budget.test.js.map +1 -0
  639. package/dist/runtime/query/__tests__/tool-pause.test.d.ts +2 -0
  640. package/dist/runtime/query/__tests__/tool-pause.test.d.ts.map +1 -0
  641. package/dist/runtime/query/__tests__/tool-pause.test.js +165 -0
  642. package/dist/runtime/query/__tests__/tool-pause.test.js.map +1 -0
  643. package/dist/runtime/query/__tests__/tool-progress.test.d.ts +2 -0
  644. package/dist/runtime/query/__tests__/tool-progress.test.d.ts.map +1 -0
  645. package/dist/runtime/query/__tests__/tool-progress.test.js +122 -0
  646. package/dist/runtime/query/__tests__/tool-progress.test.js.map +1 -0
  647. package/dist/runtime/query/__tests__/tool-repair-retry.test.d.ts +2 -0
  648. package/dist/runtime/query/__tests__/tool-repair-retry.test.d.ts.map +1 -0
  649. package/dist/runtime/query/__tests__/tool-repair-retry.test.js +196 -0
  650. package/dist/runtime/query/__tests__/tool-repair-retry.test.js.map +1 -0
  651. package/dist/runtime/query/__tests__/tool-result-wire.test.d.ts +2 -0
  652. package/dist/runtime/query/__tests__/tool-result-wire.test.d.ts.map +1 -0
  653. package/dist/runtime/query/__tests__/tool-result-wire.test.js +106 -0
  654. package/dist/runtime/query/__tests__/tool-result-wire.test.js.map +1 -0
  655. package/dist/runtime/query/__tests__/tool-timeout.test.d.ts +2 -0
  656. package/dist/runtime/query/__tests__/tool-timeout.test.d.ts.map +1 -0
  657. package/dist/runtime/query/__tests__/tool-timeout.test.js +184 -0
  658. package/dist/runtime/query/__tests__/tool-timeout.test.js.map +1 -0
  659. package/dist/runtime/query/__tests__/trace-parenting.test.d.ts +2 -0
  660. package/dist/runtime/query/__tests__/trace-parenting.test.d.ts.map +1 -0
  661. package/dist/runtime/query/__tests__/trace-parenting.test.js +111 -0
  662. package/dist/runtime/query/__tests__/trace-parenting.test.js.map +1 -0
  663. package/dist/runtime/query/__tests__/wiring-seams.test.d.ts +2 -0
  664. package/dist/runtime/query/__tests__/wiring-seams.test.d.ts.map +1 -0
  665. package/dist/runtime/query/__tests__/wiring-seams.test.js +237 -0
  666. package/dist/runtime/query/__tests__/wiring-seams.test.js.map +1 -0
  667. package/dist/runtime/query/checkpoint.d.ts +124 -6
  668. package/dist/runtime/query/checkpoint.d.ts.map +1 -1
  669. package/dist/runtime/query/checkpoint.js +207 -6
  670. package/dist/runtime/query/checkpoint.js.map +1 -1
  671. package/dist/runtime/query/events.js +2 -2
  672. package/dist/runtime/query/events.js.map +1 -1
  673. package/dist/runtime/query/executor.d.ts +224 -7
  674. package/dist/runtime/query/executor.d.ts.map +1 -1
  675. package/dist/runtime/query/executor.js +662 -35
  676. package/dist/runtime/query/executor.js.map +1 -1
  677. package/dist/runtime/query/guard.d.ts +18 -0
  678. package/dist/runtime/query/guard.d.ts.map +1 -1
  679. package/dist/runtime/query/guard.js +16 -1
  680. package/dist/runtime/query/guard.js.map +1 -1
  681. package/dist/runtime/query/guardrail-presets.d.ts +36 -0
  682. package/dist/runtime/query/guardrail-presets.d.ts.map +1 -0
  683. package/dist/runtime/query/guardrail-presets.js +96 -0
  684. package/dist/runtime/query/guardrail-presets.js.map +1 -0
  685. package/dist/runtime/query/guardrails.d.ts +35 -0
  686. package/dist/runtime/query/guardrails.d.ts.map +1 -0
  687. package/dist/runtime/query/guardrails.js +102 -0
  688. package/dist/runtime/query/guardrails.js.map +1 -0
  689. package/dist/runtime/query/index.d.ts +213 -2
  690. package/dist/runtime/query/index.d.ts.map +1 -1
  691. package/dist/runtime/query/index.js +458 -10
  692. package/dist/runtime/query/index.js.map +1 -1
  693. package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.d.ts +2 -0
  694. package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.d.ts.map +1 -0
  695. package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.js +131 -0
  696. package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.js.map +1 -0
  697. package/dist/runtime/query/iteration/index.d.ts +76 -1
  698. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  699. package/dist/runtime/query/iteration/index.js +577 -34
  700. package/dist/runtime/query/iteration/index.js.map +1 -1
  701. package/dist/runtime/query/iteration/phases/advisory.d.ts.map +1 -1
  702. package/dist/runtime/query/iteration/phases/advisory.js +14 -2
  703. package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
  704. package/dist/runtime/query/iteration/phases/advisory.test.d.ts +1 -1
  705. package/dist/runtime/query/iteration/phases/advisory.test.js +4 -1
  706. package/dist/runtime/query/iteration/phases/advisory.test.js.map +1 -1
  707. package/dist/runtime/query/iteration/phases/checkpoint.js +2 -2
  708. package/dist/runtime/query/iteration/phases/checkpoint.js.map +1 -1
  709. package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.js +1 -1
  710. package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.js.map +1 -1
  711. package/dist/runtime/query/iteration/phases/compaction.d.ts +22 -1
  712. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  713. package/dist/runtime/query/iteration/phases/compaction.js +297 -64
  714. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  715. package/dist/runtime/query/iteration/phases/context-measurement.test.d.ts +21 -0
  716. package/dist/runtime/query/iteration/phases/context-measurement.test.d.ts.map +1 -0
  717. package/dist/runtime/query/iteration/phases/context-measurement.test.js +161 -0
  718. package/dist/runtime/query/iteration/phases/context-measurement.test.js.map +1 -0
  719. package/dist/runtime/query/iteration/phases/context.d.ts +62 -2
  720. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  721. package/dist/runtime/query/iteration/phases/context.js +87 -0
  722. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  723. package/dist/runtime/query/iteration/phases/hitl-answer-question.test.js +3 -1
  724. package/dist/runtime/query/iteration/phases/hitl-answer-question.test.js.map +1 -1
  725. package/dist/runtime/query/iteration/phases/overflow-escalation.test.d.ts +15 -0
  726. package/dist/runtime/query/iteration/phases/overflow-escalation.test.d.ts.map +1 -0
  727. package/dist/runtime/query/iteration/phases/overflow-escalation.test.js +130 -0
  728. package/dist/runtime/query/iteration/phases/overflow-escalation.test.js.map +1 -0
  729. package/dist/runtime/query/iteration/phases/plan.d.ts.map +1 -1
  730. package/dist/runtime/query/iteration/phases/plan.js +8 -2
  731. package/dist/runtime/query/iteration/phases/plan.js.map +1 -1
  732. package/dist/runtime/query/iteration/phases/retained-messages.test.d.ts +2 -0
  733. package/dist/runtime/query/iteration/phases/retained-messages.test.d.ts.map +1 -0
  734. package/dist/runtime/query/iteration/phases/retained-messages.test.js +180 -0
  735. package/dist/runtime/query/iteration/phases/retained-messages.test.js.map +1 -0
  736. package/dist/runtime/query/iteration/phases/tool-review-denials.test.d.ts +2 -0
  737. package/dist/runtime/query/iteration/phases/tool-review-denials.test.d.ts.map +1 -0
  738. package/dist/runtime/query/iteration/phases/tool-review-denials.test.js +224 -0
  739. package/dist/runtime/query/iteration/phases/tool-review-denials.test.js.map +1 -0
  740. package/dist/runtime/query/iteration/phases/tool-review.d.ts +29 -1
  741. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  742. package/dist/runtime/query/iteration/phases/tool-review.js +114 -44
  743. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  744. package/dist/runtime/query/iteration/phases/working-memory-compaction.test.js +20 -9
  745. package/dist/runtime/query/iteration/phases/working-memory-compaction.test.js.map +1 -1
  746. package/dist/runtime/query/iteration/stream-turn.d.ts +2 -26
  747. package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
  748. package/dist/runtime/query/iteration/stream-turn.js +254 -16
  749. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  750. package/dist/runtime/query/plugin-hooks.d.ts.map +1 -1
  751. package/dist/runtime/query/plugin-hooks.js +6 -2
  752. package/dist/runtime/query/plugin-hooks.js.map +1 -1
  753. package/dist/runtime/query/prompt.d.ts.map +1 -1
  754. package/dist/runtime/query/prompt.js +25 -1
  755. package/dist/runtime/query/prompt.js.map +1 -1
  756. package/dist/runtime/query/question-park.d.ts +85 -0
  757. package/dist/runtime/query/question-park.d.ts.map +1 -0
  758. package/dist/runtime/query/question-park.js +71 -0
  759. package/dist/runtime/query/question-park.js.map +1 -0
  760. package/dist/runtime/query/result.d.ts +9 -0
  761. package/dist/runtime/query/result.d.ts.map +1 -1
  762. package/dist/runtime/query/result.js +49 -0
  763. package/dist/runtime/query/result.js.map +1 -1
  764. package/dist/runtime/query/resume-pending.d.ts +106 -0
  765. package/dist/runtime/query/resume-pending.d.ts.map +1 -0
  766. package/dist/runtime/query/resume-pending.js +312 -0
  767. package/dist/runtime/query/resume-pending.js.map +1 -0
  768. package/dist/runtime/query/run-state.d.ts +52 -0
  769. package/dist/runtime/query/run-state.d.ts.map +1 -0
  770. package/dist/runtime/query/run-state.js +87 -0
  771. package/dist/runtime/query/run-state.js.map +1 -0
  772. package/dist/runtime/query/tool-grants.d.ts +44 -0
  773. package/dist/runtime/query/tool-grants.d.ts.map +1 -0
  774. package/dist/runtime/query/tool-grants.js +63 -0
  775. package/dist/runtime/query/tool-grants.js.map +1 -0
  776. package/dist/runtime/query/tool-output-budget.d.ts +83 -0
  777. package/dist/runtime/query/tool-output-budget.d.ts.map +1 -0
  778. package/dist/runtime/query/tool-output-budget.js +147 -0
  779. package/dist/runtime/query/tool-output-budget.js.map +1 -0
  780. package/dist/runtime/query/tool-pause.d.ts +41 -0
  781. package/dist/runtime/query/tool-pause.d.ts.map +1 -0
  782. package/dist/runtime/query/tool-pause.js +94 -0
  783. package/dist/runtime/query/tool-pause.js.map +1 -0
  784. package/dist/runtime/query/tooling.d.ts +10 -1
  785. package/dist/runtime/query/tooling.d.ts.map +1 -1
  786. package/dist/runtime/query/tooling.js +13 -0
  787. package/dist/runtime/query/tooling.js.map +1 -1
  788. package/dist/sandbox/__tests__/isolation.test.d.ts +2 -0
  789. package/dist/sandbox/__tests__/isolation.test.d.ts.map +1 -0
  790. package/dist/sandbox/__tests__/isolation.test.js +139 -0
  791. package/dist/sandbox/__tests__/isolation.test.js.map +1 -0
  792. package/dist/sandbox/__tests__/output-truncation.test.d.ts +2 -0
  793. package/dist/sandbox/__tests__/output-truncation.test.d.ts.map +1 -0
  794. package/dist/sandbox/__tests__/output-truncation.test.js +88 -0
  795. package/dist/sandbox/__tests__/output-truncation.test.js.map +1 -0
  796. package/dist/sandbox/__tests__/resource-limits.test.d.ts +2 -0
  797. package/dist/sandbox/__tests__/resource-limits.test.d.ts.map +1 -0
  798. package/dist/sandbox/__tests__/resource-limits.test.js +86 -0
  799. package/dist/sandbox/__tests__/resource-limits.test.js.map +1 -0
  800. package/dist/sandbox/factory.js +1 -1
  801. package/dist/sandbox/factory.js.map +1 -1
  802. package/dist/sandbox/index.d.ts +2 -0
  803. package/dist/sandbox/index.d.ts.map +1 -1
  804. package/dist/sandbox/index.js +1 -0
  805. package/dist/sandbox/index.js.map +1 -1
  806. package/dist/sandbox/isolation.d.ts +15 -0
  807. package/dist/sandbox/isolation.d.ts.map +1 -0
  808. package/dist/sandbox/isolation.js +53 -0
  809. package/dist/sandbox/isolation.js.map +1 -0
  810. package/dist/sandbox/provider/local.d.ts +51 -2
  811. package/dist/sandbox/provider/local.d.ts.map +1 -1
  812. package/dist/sandbox/provider/local.js +139 -69
  813. package/dist/sandbox/provider/local.js.map +1 -1
  814. package/dist/session/__tests__/integration/spawn-rollback.test.d.ts +1 -1
  815. package/dist/session/__tests__/integration/spawn-rollback.test.js +1 -1
  816. package/dist/session/handoff/broadcast.js +3 -3
  817. package/dist/session/handoff/broadcast.js.map +1 -1
  818. package/dist/session/migration/__tests__/filesystem.test.js +5 -1
  819. package/dist/session/migration/__tests__/filesystem.test.js.map +1 -1
  820. package/dist/session/migration/filesystem.d.ts.map +1 -1
  821. package/dist/session/migration/filesystem.js +7 -13
  822. package/dist/session/migration/filesystem.js.map +1 -1
  823. package/dist/session/migration/marker.d.ts.map +1 -1
  824. package/dist/session/migration/marker.js +5 -10
  825. package/dist/session/migration/marker.js.map +1 -1
  826. package/dist/session/retention/disk-backend.d.ts.map +1 -1
  827. package/dist/session/retention/disk-backend.js +5 -12
  828. package/dist/session/retention/disk-backend.js.map +1 -1
  829. package/dist/session/workspace/__tests__/git-worktree.test.js +6 -2
  830. package/dist/session/workspace/__tests__/git-worktree.test.js.map +1 -1
  831. package/dist/session/workspace/__tests__/shared-run.test.js +15 -0
  832. package/dist/session/workspace/__tests__/shared-run.test.js.map +1 -1
  833. package/dist/session/workspace/shared-run.js +8 -1
  834. package/dist/session/workspace/shared-run.js.map +1 -1
  835. package/dist/skills/__tests__/frontmatter.test.d.ts +2 -0
  836. package/dist/skills/__tests__/frontmatter.test.d.ts.map +1 -0
  837. package/dist/skills/__tests__/frontmatter.test.js +106 -0
  838. package/dist/skills/__tests__/frontmatter.test.js.map +1 -0
  839. package/dist/skills/loader.d.ts.map +1 -1
  840. package/dist/skills/loader.js +42 -3
  841. package/dist/skills/loader.js.map +1 -1
  842. package/dist/store/__tests__/checkpoint-integrity.test.d.ts +2 -0
  843. package/dist/store/__tests__/checkpoint-integrity.test.d.ts.map +1 -0
  844. package/dist/store/__tests__/checkpoint-integrity.test.js +112 -0
  845. package/dist/store/__tests__/checkpoint-integrity.test.js.map +1 -0
  846. package/dist/store/__tests__/checkpoint-versioning.test.d.ts +2 -0
  847. package/dist/store/__tests__/checkpoint-versioning.test.d.ts.map +1 -0
  848. package/dist/store/__tests__/checkpoint-versioning.test.js +151 -0
  849. package/dist/store/__tests__/checkpoint-versioning.test.js.map +1 -0
  850. package/dist/store/__tests__/schema-adoption.test.d.ts +2 -0
  851. package/dist/store/__tests__/schema-adoption.test.d.ts.map +1 -0
  852. package/dist/store/__tests__/schema-adoption.test.js +90 -0
  853. package/dist/store/__tests__/schema-adoption.test.js.map +1 -0
  854. package/dist/store/__tests__/schema.test.d.ts +2 -0
  855. package/dist/store/__tests__/schema.test.d.ts.map +1 -0
  856. package/dist/store/__tests__/schema.test.js +93 -0
  857. package/dist/store/__tests__/schema.test.js.map +1 -0
  858. package/dist/store/memory/disk.d.ts.map +1 -1
  859. package/dist/store/memory/disk.js +16 -16
  860. package/dist/store/memory/disk.js.map +1 -1
  861. package/dist/store/run/disk.d.ts +23 -0
  862. package/dist/store/run/disk.d.ts.map +1 -1
  863. package/dist/store/run/disk.js +148 -23
  864. package/dist/store/run/disk.js.map +1 -1
  865. package/dist/store/schema.d.ts +73 -0
  866. package/dist/store/schema.d.ts.map +1 -0
  867. package/dist/store/schema.js +103 -0
  868. package/dist/store/schema.js.map +1 -0
  869. package/dist/store/session/disk.d.ts.map +1 -1
  870. package/dist/store/session/disk.js +25 -13
  871. package/dist/store/session/disk.js.map +1 -1
  872. package/dist/store/task/__tests__/lookup-across-runs.test.d.ts +2 -0
  873. package/dist/store/task/__tests__/lookup-across-runs.test.d.ts.map +1 -0
  874. package/dist/store/task/__tests__/lookup-across-runs.test.js +60 -0
  875. package/dist/store/task/__tests__/lookup-across-runs.test.js.map +1 -0
  876. package/dist/store/task/disk.d.ts +18 -0
  877. package/dist/store/task/disk.d.ts.map +1 -1
  878. package/dist/store/task/disk.js +61 -16
  879. package/dist/store/task/disk.js.map +1 -1
  880. package/dist/store/thread/disk.d.ts.map +1 -1
  881. package/dist/store/thread/disk.js +20 -11
  882. package/dist/store/thread/disk.js.map +1 -1
  883. package/dist/streaming/coalesce.d.ts +1 -1
  884. package/dist/streaming/coalesce.js +1 -1
  885. package/dist/telemetry/__tests__/latency-instruments.test.d.ts +2 -0
  886. package/dist/telemetry/__tests__/latency-instruments.test.d.ts.map +1 -0
  887. package/dist/telemetry/__tests__/latency-instruments.test.js +82 -0
  888. package/dist/telemetry/__tests__/latency-instruments.test.js.map +1 -0
  889. package/dist/telemetry/__tests__/metrics.test.d.ts +2 -0
  890. package/dist/telemetry/__tests__/metrics.test.d.ts.map +1 -0
  891. package/dist/telemetry/__tests__/metrics.test.js +112 -0
  892. package/dist/telemetry/__tests__/metrics.test.js.map +1 -0
  893. package/dist/telemetry/__tests__/span-hierarchy.test.d.ts +2 -0
  894. package/dist/telemetry/__tests__/span-hierarchy.test.d.ts.map +1 -0
  895. package/dist/telemetry/__tests__/span-hierarchy.test.js +84 -0
  896. package/dist/telemetry/__tests__/span-hierarchy.test.js.map +1 -0
  897. package/dist/telemetry/attributes.d.ts +44 -0
  898. package/dist/telemetry/attributes.d.ts.map +1 -1
  899. package/dist/telemetry/attributes.js +80 -0
  900. package/dist/telemetry/attributes.js.map +1 -1
  901. package/dist/telemetry/metrics.d.ts +41 -0
  902. package/dist/telemetry/metrics.d.ts.map +1 -0
  903. package/dist/telemetry/metrics.js +160 -0
  904. package/dist/telemetry/metrics.js.map +1 -0
  905. package/dist/test-setup.d.ts +3 -3
  906. package/dist/test-setup.js +3 -3
  907. package/dist/test-support/paths.d.ts +14 -0
  908. package/dist/test-support/paths.d.ts.map +1 -0
  909. package/dist/test-support/paths.js +16 -0
  910. package/dist/test-support/paths.js.map +1 -0
  911. package/dist/tools/__tests__/path-containment.test.d.ts +2 -0
  912. package/dist/tools/__tests__/path-containment.test.d.ts.map +1 -0
  913. package/dist/tools/__tests__/path-containment.test.js +133 -0
  914. package/dist/tools/__tests__/path-containment.test.js.map +1 -0
  915. package/dist/tools/__tests__/posix-path.test.d.ts +2 -0
  916. package/dist/tools/__tests__/posix-path.test.d.ts.map +1 -0
  917. package/dist/tools/__tests__/posix-path.test.js +67 -0
  918. package/dist/tools/__tests__/posix-path.test.js.map +1 -0
  919. package/dist/tools/__tests__/sandboxed-search.test.d.ts +2 -0
  920. package/dist/tools/__tests__/sandboxed-search.test.d.ts.map +1 -0
  921. package/dist/tools/__tests__/sandboxed-search.test.js +114 -0
  922. package/dist/tools/__tests__/sandboxed-search.test.js.map +1 -0
  923. package/dist/tools/builtins/__tests__/computer-use.test.js +12 -2
  924. package/dist/tools/builtins/__tests__/computer-use.test.js.map +1 -1
  925. package/dist/tools/builtins/__tests__/edit.test.js +10 -216
  926. package/dist/tools/builtins/__tests__/edit.test.js.map +1 -1
  927. package/dist/tools/builtins/__tests__/payload-budget.test.js +16 -30
  928. package/dist/tools/builtins/__tests__/payload-budget.test.js.map +1 -1
  929. package/dist/tools/builtins/__tests__/read-file.test.js +23 -1
  930. package/dist/tools/builtins/__tests__/read-file.test.js.map +1 -1
  931. package/dist/tools/builtins/__tests__/write-file.test.js +13 -37
  932. package/dist/tools/builtins/__tests__/write-file.test.js.map +1 -1
  933. package/dist/tools/builtins/bash.d.ts.map +1 -1
  934. package/dist/tools/builtins/bash.js +33 -4
  935. package/dist/tools/builtins/bash.js.map +1 -1
  936. package/dist/tools/builtins/computer-use.d.ts +22 -22
  937. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  938. package/dist/tools/builtins/computer-use.js +7 -1
  939. package/dist/tools/builtins/computer-use.js.map +1 -1
  940. package/dist/tools/builtins/edit.d.ts +5 -2
  941. package/dist/tools/builtins/edit.d.ts.map +1 -1
  942. package/dist/tools/builtins/edit.js +125 -105
  943. package/dist/tools/builtins/edit.js.map +1 -1
  944. package/dist/tools/builtins/glob.d.ts +1 -1
  945. package/dist/tools/builtins/glob.d.ts.map +1 -1
  946. package/dist/tools/builtins/glob.js +63 -6
  947. package/dist/tools/builtins/glob.js.map +1 -1
  948. package/dist/tools/builtins/grep.d.ts.map +1 -1
  949. package/dist/tools/builtins/grep.js +61 -8
  950. package/dist/tools/builtins/grep.js.map +1 -1
  951. package/dist/tools/builtins/index.js +6 -6
  952. package/dist/tools/builtins/index.js.map +1 -1
  953. package/dist/tools/builtins/ls.d.ts.map +1 -1
  954. package/dist/tools/builtins/ls.js +4 -2
  955. package/dist/tools/builtins/ls.js.map +1 -1
  956. package/dist/tools/builtins/read-file.d.ts +1 -1
  957. package/dist/tools/builtins/read-file.d.ts.map +1 -1
  958. package/dist/tools/builtins/read-file.js +38 -4
  959. package/dist/tools/builtins/read-file.js.map +1 -1
  960. package/dist/tools/builtins/write-file.d.ts +2 -1
  961. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  962. package/dist/tools/builtins/write-file.js +40 -66
  963. package/dist/tools/builtins/write-file.js.map +1 -1
  964. package/dist/tools/coordinator/__tests__/agent.test.d.ts +1 -1
  965. package/dist/tools/coordinator/__tests__/agent.test.js +2 -2
  966. package/dist/tools/coordinator/__tests__/agent.test.js.map +1 -1
  967. package/dist/tools/coordinator/agent.d.ts +20 -9
  968. package/dist/tools/coordinator/agent.d.ts.map +1 -1
  969. package/dist/tools/coordinator/agent.js +2 -1
  970. package/dist/tools/coordinator/agent.js.map +1 -1
  971. package/dist/tools/coordinator/index.d.ts +20 -0
  972. package/dist/tools/coordinator/index.d.ts.map +1 -1
  973. package/dist/tools/coordinator/index.js +80 -32
  974. package/dist/tools/coordinator/index.js.map +1 -1
  975. package/dist/tools/defineTool.d.ts +16 -0
  976. package/dist/tools/defineTool.d.ts.map +1 -1
  977. package/dist/tools/defineTool.js +4 -0
  978. package/dist/tools/defineTool.js.map +1 -1
  979. package/dist/tools/glob-match.d.ts +18 -0
  980. package/dist/tools/glob-match.d.ts.map +1 -0
  981. package/dist/tools/glob-match.js +50 -0
  982. package/dist/tools/glob-match.js.map +1 -0
  983. package/dist/tools/paths.d.ts +20 -0
  984. package/dist/tools/paths.d.ts.map +1 -0
  985. package/dist/tools/paths.js +41 -0
  986. package/dist/tools/paths.js.map +1 -0
  987. package/dist/tools/posix-path.d.ts +24 -0
  988. package/dist/tools/posix-path.d.ts.map +1 -0
  989. package/dist/tools/posix-path.js +67 -0
  990. package/dist/tools/posix-path.js.map +1 -0
  991. package/dist/types/advisory/config.d.ts +21 -3
  992. package/dist/types/advisory/config.d.ts.map +1 -1
  993. package/dist/types/advisory/result.d.ts +12 -10
  994. package/dist/types/advisory/result.d.ts.map +1 -1
  995. package/dist/types/agent/base.d.ts +20 -2
  996. package/dist/types/agent/base.d.ts.map +1 -1
  997. package/dist/types/agent/factory.d.ts +15 -9
  998. package/dist/types/agent/factory.d.ts.map +1 -1
  999. package/dist/types/agent/gateway.d.ts +18 -0
  1000. package/dist/types/agent/gateway.d.ts.map +1 -1
  1001. package/dist/types/agent/manager.d.ts +19 -0
  1002. package/dist/types/agent/manager.d.ts.map +1 -1
  1003. package/dist/types/agent/reactive.d.ts +48 -0
  1004. package/dist/types/agent/reactive.d.ts.map +1 -1
  1005. package/dist/types/agent/router.d.ts +11 -0
  1006. package/dist/types/agent/router.d.ts.map +1 -1
  1007. package/dist/types/agent/supervisor.d.ts +2 -2
  1008. package/dist/types/agent/task.d.ts +24 -0
  1009. package/dist/types/agent/task.d.ts.map +1 -1
  1010. package/dist/types/bidi/index.d.ts +140 -0
  1011. package/dist/types/bidi/index.d.ts.map +1 -0
  1012. package/dist/types/bidi/index.js +2 -0
  1013. package/dist/types/bidi/index.js.map +1 -0
  1014. package/dist/types/common/__tests__/numeric-correctness.test.d.ts +2 -0
  1015. package/dist/types/common/__tests__/numeric-correctness.test.d.ts.map +1 -0
  1016. package/dist/types/common/__tests__/numeric-correctness.test.js +108 -0
  1017. package/dist/types/common/__tests__/numeric-correctness.test.js.map +1 -0
  1018. package/dist/types/common/index.d.ts +1 -1
  1019. package/dist/types/common/index.d.ts.map +1 -1
  1020. package/dist/types/common/index.js +15 -4
  1021. package/dist/types/common/index.js.map +1 -1
  1022. package/dist/types/connector/mcp.d.ts +29 -0
  1023. package/dist/types/connector/mcp.d.ts.map +1 -1
  1024. package/dist/types/errors/__tests__/catalog.test.d.ts +2 -0
  1025. package/dist/types/errors/__tests__/catalog.test.d.ts.map +1 -0
  1026. package/dist/types/errors/__tests__/catalog.test.js +106 -0
  1027. package/dist/types/errors/__tests__/catalog.test.js.map +1 -0
  1028. package/dist/types/errors/__tests__/errors.test.d.ts +2 -0
  1029. package/dist/types/errors/__tests__/errors.test.d.ts.map +1 -0
  1030. package/dist/types/errors/__tests__/errors.test.js +104 -0
  1031. package/dist/types/errors/__tests__/errors.test.js.map +1 -0
  1032. package/dist/types/errors/catalog.d.ts +83 -0
  1033. package/dist/types/errors/catalog.d.ts.map +1 -0
  1034. package/dist/types/errors/catalog.js +148 -0
  1035. package/dist/types/errors/catalog.js.map +1 -0
  1036. package/dist/types/errors/index.d.ts +73 -0
  1037. package/dist/types/errors/index.d.ts.map +1 -0
  1038. package/dist/types/errors/index.js +70 -0
  1039. package/dist/types/errors/index.js.map +1 -0
  1040. package/dist/types/guardrail/index.d.ts +57 -0
  1041. package/dist/types/guardrail/index.d.ts.map +1 -0
  1042. package/dist/types/guardrail/index.js +2 -0
  1043. package/dist/types/guardrail/index.js.map +1 -0
  1044. package/dist/types/hitl/index.d.ts +97 -14
  1045. package/dist/types/hitl/index.d.ts.map +1 -1
  1046. package/dist/types/hitl/index.js.map +1 -1
  1047. package/dist/types/ids/index.d.ts +2 -2
  1048. package/dist/types/message/content.d.ts +22 -0
  1049. package/dist/types/message/content.d.ts.map +1 -0
  1050. package/dist/types/message/content.js +49 -0
  1051. package/dist/types/message/content.js.map +1 -0
  1052. package/dist/types/message/index.d.ts +193 -8
  1053. package/dist/types/message/index.d.ts.map +1 -1
  1054. package/dist/types/message/index.js +19 -4
  1055. package/dist/types/message/index.js.map +1 -1
  1056. package/dist/types/plugin/index.d.ts +78 -3
  1057. package/dist/types/plugin/index.d.ts.map +1 -1
  1058. package/dist/types/plugin/index.js +0 -1
  1059. package/dist/types/plugin/index.js.map +1 -1
  1060. package/dist/types/provider/__tests__/cause-chain.test.d.ts +2 -0
  1061. package/dist/types/provider/__tests__/cause-chain.test.d.ts.map +1 -0
  1062. package/dist/types/provider/__tests__/cause-chain.test.js +108 -0
  1063. package/dist/types/provider/__tests__/cause-chain.test.js.map +1 -0
  1064. package/dist/types/provider/__tests__/declared-retryable.test.d.ts +2 -0
  1065. package/dist/types/provider/__tests__/declared-retryable.test.d.ts.map +1 -0
  1066. package/dist/types/provider/__tests__/declared-retryable.test.js +70 -0
  1067. package/dist/types/provider/__tests__/declared-retryable.test.js.map +1 -0
  1068. package/dist/types/provider/__tests__/overflow-classification.test.d.ts +2 -0
  1069. package/dist/types/provider/__tests__/overflow-classification.test.d.ts.map +1 -0
  1070. package/dist/types/provider/__tests__/overflow-classification.test.js +80 -0
  1071. package/dist/types/provider/__tests__/overflow-classification.test.js.map +1 -0
  1072. package/dist/types/provider/chat.d.ts +27 -1
  1073. package/dist/types/provider/chat.d.ts.map +1 -1
  1074. package/dist/types/provider/config.d.ts +83 -2
  1075. package/dist/types/provider/config.d.ts.map +1 -1
  1076. package/dist/types/provider/errors.d.ts +102 -0
  1077. package/dist/types/provider/errors.d.ts.map +1 -0
  1078. package/dist/types/provider/errors.js +393 -0
  1079. package/dist/types/provider/errors.js.map +1 -0
  1080. package/dist/types/provider/index.d.ts +3 -2
  1081. package/dist/types/provider/index.d.ts.map +1 -1
  1082. package/dist/types/provider/stream.d.ts +59 -3
  1083. package/dist/types/provider/stream.d.ts.map +1 -1
  1084. package/dist/types/rag/embedding.d.ts +11 -2
  1085. package/dist/types/rag/embedding.d.ts.map +1 -1
  1086. package/dist/types/run/__tests__/step.test.d.ts +2 -0
  1087. package/dist/types/run/__tests__/step.test.d.ts.map +1 -0
  1088. package/dist/types/run/__tests__/step.test.js +107 -0
  1089. package/dist/types/run/__tests__/step.test.js.map +1 -0
  1090. package/dist/types/run/answer-review.d.ts +46 -0
  1091. package/dist/types/run/answer-review.d.ts.map +1 -0
  1092. package/dist/types/run/answer-review.js +2 -0
  1093. package/dist/types/run/answer-review.js.map +1 -0
  1094. package/dist/types/run/config.d.ts +33 -0
  1095. package/dist/types/run/config.d.ts.map +1 -1
  1096. package/dist/types/run/derive-status.d.ts +29 -0
  1097. package/dist/types/run/derive-status.d.ts.map +1 -0
  1098. package/dist/types/run/derive-status.js +49 -0
  1099. package/dist/types/run/derive-status.js.map +1 -0
  1100. package/dist/types/run/entity.d.ts +16 -0
  1101. package/dist/types/run/entity.d.ts.map +1 -1
  1102. package/dist/types/run/events.d.ts +228 -4
  1103. package/dist/types/run/events.d.ts.map +1 -1
  1104. package/dist/types/run/events.js +7 -0
  1105. package/dist/types/run/events.js.map +1 -1
  1106. package/dist/types/run/index.d.ts +5 -0
  1107. package/dist/types/run/index.d.ts.map +1 -1
  1108. package/dist/types/run/index.js +3 -0
  1109. package/dist/types/run/index.js.map +1 -1
  1110. package/dist/types/run/memory-promotion.d.ts +90 -0
  1111. package/dist/types/run/memory-promotion.d.ts.map +1 -0
  1112. package/dist/types/run/memory-promotion.js +38 -0
  1113. package/dist/types/run/memory-promotion.js.map +1 -0
  1114. package/dist/types/run/prepare-step.d.ts +100 -0
  1115. package/dist/types/run/prepare-step.d.ts.map +1 -0
  1116. package/dist/types/run/prepare-step.js +2 -0
  1117. package/dist/types/run/prepare-step.js.map +1 -0
  1118. package/dist/types/run/state.d.ts +85 -0
  1119. package/dist/types/run/state.d.ts.map +1 -0
  1120. package/dist/types/run/state.js +33 -0
  1121. package/dist/types/run/state.js.map +1 -0
  1122. package/dist/types/run/step.d.ts +77 -0
  1123. package/dist/types/run/step.d.ts.map +1 -0
  1124. package/dist/types/run/step.js +26 -0
  1125. package/dist/types/run/step.js.map +1 -0
  1126. package/dist/types/run/stop-reason.d.ts +31 -3
  1127. package/dist/types/run/stop-reason.d.ts.map +1 -1
  1128. package/dist/types/sandbox/index.d.ts +82 -10
  1129. package/dist/types/sandbox/index.d.ts.map +1 -1
  1130. package/dist/types/sandbox/index.js +13 -1
  1131. package/dist/types/sandbox/index.js.map +1 -1
  1132. package/dist/types/structured-output/index.d.ts +6 -5
  1133. package/dist/types/structured-output/index.d.ts.map +1 -1
  1134. package/dist/types/thread/entity.d.ts +2 -3
  1135. package/dist/types/thread/entity.d.ts.map +1 -1
  1136. package/dist/types/tool/index.d.ts +193 -1
  1137. package/dist/types/tool/index.d.ts.map +1 -1
  1138. package/dist/types/tool/index.js +1 -1
  1139. package/dist/types/tool/index.js.map +1 -1
  1140. package/dist/types/tool/repair.d.ts +49 -0
  1141. package/dist/types/tool/repair.d.ts.map +1 -0
  1142. package/dist/types/tool/repair.js +2 -0
  1143. package/dist/types/tool/repair.js.map +1 -0
  1144. package/dist/types/toolset/index.d.ts +2 -5
  1145. package/dist/types/toolset/index.d.ts.map +1 -1
  1146. package/dist/utils/__tests__/atomic-write.test.d.ts +2 -0
  1147. package/dist/utils/__tests__/atomic-write.test.d.ts.map +1 -0
  1148. package/dist/utils/__tests__/atomic-write.test.js +91 -0
  1149. package/dist/utils/__tests__/atomic-write.test.js.map +1 -0
  1150. package/dist/utils/__tests__/shell-compress.test.d.ts +2 -0
  1151. package/dist/utils/__tests__/shell-compress.test.d.ts.map +1 -0
  1152. package/dist/utils/__tests__/shell-compress.test.js +41 -0
  1153. package/dist/utils/__tests__/shell-compress.test.js.map +1 -0
  1154. package/dist/utils/atomic-write.d.ts +10 -0
  1155. package/dist/utils/atomic-write.d.ts.map +1 -0
  1156. package/dist/utils/atomic-write.js +83 -0
  1157. package/dist/utils/atomic-write.js.map +1 -0
  1158. package/dist/utils/shell-compress.d.ts.map +1 -1
  1159. package/dist/utils/shell-compress.js +12 -1
  1160. package/dist/utils/shell-compress.js.map +1 -1
  1161. package/dist/verification/presets.d.ts +6 -3
  1162. package/dist/verification/presets.d.ts.map +1 -1
  1163. package/dist/verification/presets.js +6 -3
  1164. package/dist/verification/presets.js.map +1 -1
  1165. package/package.json +3 -3
  1166. package/src/__tests__/default-path-conformance.test.ts +306 -0
  1167. package/src/__tests__/shipped-defaults.test.ts +111 -0
  1168. package/src/advisory/__tests__/budget-enforcement.test.ts +208 -0
  1169. package/src/advisory/__tests__/structured-response.test.ts +128 -0
  1170. package/src/advisory/budget.ts +27 -0
  1171. package/src/advisory/context.ts +19 -0
  1172. package/src/advisory/executor.test.ts +12 -8
  1173. package/src/advisory/executor.ts +37 -25
  1174. package/src/advisory/index.ts +2 -0
  1175. package/src/advisory/parse.ts +63 -0
  1176. package/src/agents/AbstractAgent.ts +82 -0
  1177. package/src/agents/PipelineAgent.ts +19 -0
  1178. package/src/agents/ReactiveAgent.ts +47 -0
  1179. package/src/agents/RouterAgent.ts +32 -2
  1180. package/src/agents/SupervisorAgent.ts +31 -1
  1181. package/src/agents/__tests__/idempotency-key.test.ts +177 -0
  1182. package/src/agents/__tests__/invocation-lock.test.ts +154 -0
  1183. package/src/agents/__tests__/reachability.test.ts +224 -0
  1184. package/src/agents/__tests__/supervisor-ledger.test.ts +1 -1
  1185. package/src/agents/index.ts +1 -1
  1186. package/src/agents/lock.ts +0 -2
  1187. package/src/bridge/a2a/late-events.test.ts +84 -0
  1188. package/src/bridge/a2a/mapper.test.ts +1 -1
  1189. package/src/bridge/a2a/mapper.ts +70 -5
  1190. package/src/bridge/a2a/message.ts +5 -1
  1191. package/src/bridge/sse/late-events.test.ts +182 -0
  1192. package/src/bridge/sse/mapper.ts +109 -0
  1193. package/src/compaction/__tests__/cleared-result-recovery.test.ts +118 -0
  1194. package/src/compaction/__tests__/context-window.test.ts +77 -0
  1195. package/src/compaction/__tests__/dangling.test.ts +16 -6
  1196. package/src/compaction/__tests__/lossiness.test.ts +187 -0
  1197. package/src/compaction/__tests__/state-across-resume.test.ts +99 -0
  1198. package/src/compaction/__tests__/tool-result-editing.test.ts +213 -0
  1199. package/src/compaction/__tests__/trim-opens-on-user.test.ts +118 -0
  1200. package/src/compaction/__tests__/verifier-model.test.ts +83 -0
  1201. package/src/compaction/context-window.ts +107 -0
  1202. package/src/compaction/dangling.ts +48 -1
  1203. package/src/compaction/extractor.ts +56 -1
  1204. package/src/compaction/index.ts +16 -0
  1205. package/src/compaction/manager.ts +53 -8
  1206. package/src/compaction/managers/structured.ts +7 -6
  1207. package/src/compaction/retention.ts +89 -0
  1208. package/src/compaction/serializer.ts +42 -11
  1209. package/src/compaction/tool-result-editing.ts +229 -0
  1210. package/src/compaction/types.ts +10 -0
  1211. package/src/compaction/verifier.ts +24 -1
  1212. package/src/compaction/wire.ts +91 -0
  1213. package/src/config/runtime.ts +63 -19
  1214. package/src/connector/builtins/http.test.ts +13 -0
  1215. package/src/connector/builtins/http.ts +15 -1
  1216. package/src/connector/mcp/__tests__/discovery-policy.test.ts +133 -0
  1217. package/src/connector/mcp/__tests__/list-pagination.test.ts +98 -0
  1218. package/src/connector/mcp/__tests__/policy.test.ts +100 -0
  1219. package/src/connector/mcp/__tests__/protocol-negotiation.test.ts +105 -0
  1220. package/src/connector/mcp/__tests__/schema-fidelity.test.ts +250 -0
  1221. package/src/connector/mcp/__tests__/structured-result.test.ts +143 -0
  1222. package/src/connector/mcp/adapter.ts +306 -19
  1223. package/src/connector/mcp/client.test.ts +159 -0
  1224. package/src/connector/mcp/client.ts +160 -13
  1225. package/src/connector/mcp/discovery.ts +74 -5
  1226. package/src/connector/mcp/http-sse.ts +16 -1
  1227. package/src/connector/mcp/index.ts +4 -0
  1228. package/src/connector/mcp/policy.ts +134 -0
  1229. package/src/connector/mcp/schema-refs.ts +126 -0
  1230. package/src/constants/agent/index.ts +3 -0
  1231. package/src/constants/compaction/index.ts +1 -1
  1232. package/src/constants/continuation.ts +4 -4
  1233. package/src/constants/mcp/index.ts +34 -0
  1234. package/src/constants/plugin/index.ts +24 -2
  1235. package/src/constants/sandbox/index.ts +6 -5
  1236. package/src/constants/telemetry/index.ts +8 -0
  1237. package/src/constants/tools/index.ts +20 -0
  1238. package/src/contracts/api.ts +40 -0
  1239. package/src/contracts/run-status.ts +43 -0
  1240. package/src/eval/__tests__/case-deadline.test.ts +147 -0
  1241. package/src/eval/__tests__/end-to-end.test.ts +259 -0
  1242. package/src/eval/__tests__/harness-honesty.test.ts +99 -0
  1243. package/src/eval/__tests__/harness.test.ts +249 -0
  1244. package/src/eval/__tests__/judge.test.ts +306 -0
  1245. package/src/eval/__tests__/scorer-gates.test.ts +156 -0
  1246. package/src/eval/experiment.ts +335 -0
  1247. package/src/eval/from-run.ts +48 -0
  1248. package/src/eval/index.ts +21 -0
  1249. package/src/eval/judge.ts +240 -0
  1250. package/src/eval/scorers.ts +169 -0
  1251. package/src/eval/types.ts +157 -0
  1252. package/src/execution/local.test.ts +46 -0
  1253. package/src/execution/local.ts +6 -1
  1254. package/src/gateway/__tests__/list-survives-eviction.test.ts +124 -0
  1255. package/src/gateway/local.ts +117 -3
  1256. package/src/manager/agent/__tests__/dispose-cancels.test.ts +104 -0
  1257. package/src/manager/agent/__tests__/lifecycle.test.ts +297 -0
  1258. package/src/manager/agent/lifecycle.ts +127 -7
  1259. package/src/manager/run/persistence.ts +132 -1
  1260. package/src/plugin/__tests__/enable-contributions.test.ts +3 -3
  1261. package/src/plugin/__tests__/hook-ordering.test.ts +252 -0
  1262. package/src/plugin/__tests__/install-time-refusal.test.ts +68 -0
  1263. package/src/plugin/__tests__/lifecycle.test.ts +95 -73
  1264. package/src/plugin/lifecycle.ts +76 -22
  1265. package/src/plugin/loader.ts +37 -1
  1266. package/src/probe/registry.test.ts +49 -6
  1267. package/src/probe/registry.ts +21 -1
  1268. package/src/provider/__tests__/mock-script.test.ts +179 -0
  1269. package/src/provider/__tests__/registry.test.ts +1 -1
  1270. package/src/provider/__tests__/retry-visibility.test.ts +160 -0
  1271. package/src/provider/__tests__/retry.test.ts +296 -0
  1272. package/src/provider/capabilities.ts +4 -0
  1273. package/src/provider/collect.test.ts +1 -1
  1274. package/src/provider/collect.ts +1 -1
  1275. package/src/provider/index.ts +8 -0
  1276. package/src/provider/mock-register.ts +5 -2
  1277. package/src/provider/mock.ts +117 -34
  1278. package/src/provider/retry.ts +199 -0
  1279. package/src/public-runtime.ts +111 -7
  1280. package/src/public-types.ts +5 -1
  1281. package/src/rag/__tests__/retrieval-math.test.ts +54 -0
  1282. package/src/rag/chunking.ts +32 -1
  1283. package/src/rag/embedding.test.ts +65 -10
  1284. package/src/rag/embedding.ts +26 -5
  1285. package/src/rag/index.ts +1 -1
  1286. package/src/rag/retriever.ts +92 -21
  1287. package/src/rag/vector-store.test.ts +2 -2
  1288. package/src/registry/ManagedRegistry.test.ts +1 -1
  1289. package/src/registry/Registry.test.ts +1 -1
  1290. package/src/registry/connector/definitions.test.ts +1 -1
  1291. package/src/registry/tool/__tests__/schema.test.ts +208 -0
  1292. package/src/registry/tool/__tests__/tool-name-validation.test.ts +88 -0
  1293. package/src/registry/tool/execute.ts +104 -22
  1294. package/src/registry/tool/schema.ts +80 -0
  1295. package/src/registry/toolset/catalog.test.ts +0 -1
  1296. package/src/registry/toolset/catalog.ts +0 -1
  1297. package/src/run/reporter.ts +84 -0
  1298. package/src/runtime/bidi/__tests__/session.test.ts +232 -0
  1299. package/src/runtime/bidi/index.ts +4 -0
  1300. package/src/runtime/bidi/mock.ts +90 -0
  1301. package/src/runtime/bidi/session.ts +205 -0
  1302. package/src/runtime/decision/parser.test.ts +46 -0
  1303. package/src/runtime/decision/parser.ts +8 -1
  1304. package/src/runtime/query/__tests__/answer-review.test.ts +172 -0
  1305. package/src/runtime/query/__tests__/capability-negotiation.test.ts +25 -129
  1306. package/src/runtime/query/__tests__/checkpoint-store.test.ts +13 -50
  1307. package/src/runtime/query/__tests__/checkpoint.test.ts +2 -10
  1308. package/src/runtime/query/__tests__/citations.test.ts +111 -0
  1309. package/src/runtime/query/__tests__/content-budget.test.ts +83 -0
  1310. package/src/runtime/query/__tests__/context.test.ts +3 -2
  1311. package/src/runtime/query/__tests__/deferred-tools.test.ts +23 -148
  1312. package/src/runtime/query/__tests__/delegation-resume.test.ts +159 -0
  1313. package/src/runtime/query/__tests__/document-attachments.test.ts +125 -0
  1314. package/src/runtime/query/__tests__/durable-park-and-trace.test.ts +245 -0
  1315. package/src/runtime/query/__tests__/durable-question-park.test.ts +305 -0
  1316. package/src/runtime/query/__tests__/durable-run-state.test.ts +194 -0
  1317. package/src/runtime/query/__tests__/executor-plugin-hooks.test.ts +24 -20
  1318. package/src/runtime/query/__tests__/finish-reason-vs-tool-calls.test.ts +206 -0
  1319. package/src/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.ts +115 -0
  1320. package/src/runtime/query/__tests__/guardrails-e2e.test.ts +164 -0
  1321. package/src/runtime/query/__tests__/guardrails.test.ts +236 -0
  1322. package/src/runtime/query/__tests__/hook-model-visibility.test.ts +143 -0
  1323. package/src/runtime/query/__tests__/long-document-flow.test.ts +9 -2
  1324. package/src/runtime/query/__tests__/memory-promotion.test.ts +148 -0
  1325. package/src/runtime/query/__tests__/orphan-task-turn-end.test.ts +5 -31
  1326. package/src/runtime/query/__tests__/overflow-relief.test.ts +139 -0
  1327. package/src/runtime/query/__tests__/partial-batch-resume.test.ts +264 -0
  1328. package/src/runtime/query/__tests__/plugin-hooks.test.ts +0 -1
  1329. package/src/runtime/query/__tests__/prepare-step-chain.test.ts +127 -0
  1330. package/src/runtime/query/__tests__/prepare-step.test.ts +233 -0
  1331. package/src/runtime/query/__tests__/probe-veto-is-error.test.ts +145 -0
  1332. package/src/runtime/query/__tests__/prompt.test.ts +1 -1
  1333. package/src/runtime/query/__tests__/provider-fault-pauses.test.ts +104 -0
  1334. package/src/runtime/query/__tests__/reasoning-stream.test.ts +177 -0
  1335. package/src/runtime/query/__tests__/recoverable-settle.test.ts +145 -0
  1336. package/src/runtime/query/__tests__/resume-budget.test.ts +158 -0
  1337. package/src/runtime/query/__tests__/resume-pending.test.ts +273 -0
  1338. package/src/runtime/query/__tests__/rich-content-budget-wiring.test.ts +109 -0
  1339. package/src/runtime/query/__tests__/stop-condition.test.ts +265 -0
  1340. package/src/runtime/query/__tests__/structured-output.test.ts +268 -0
  1341. package/src/runtime/query/__tests__/structured-run-failure.test.ts +144 -0
  1342. package/src/runtime/query/__tests__/terminal-tool.test.ts +148 -0
  1343. package/src/runtime/query/__tests__/tool-grants.test.ts +102 -0
  1344. package/src/runtime/query/__tests__/tool-output-budget.test.ts +0 -0
  1345. package/src/runtime/query/__tests__/tool-pause.test.ts +209 -0
  1346. package/src/runtime/query/__tests__/tool-progress.test.ts +154 -0
  1347. package/src/runtime/query/__tests__/tool-repair-retry.test.ts +255 -0
  1348. package/src/runtime/query/__tests__/tool-result-wire.test.ts +135 -0
  1349. package/src/runtime/query/__tests__/tool-timeout.test.ts +230 -0
  1350. package/src/runtime/query/__tests__/trace-parenting.test.ts +128 -0
  1351. package/src/runtime/query/__tests__/wiring-seams.test.ts +288 -0
  1352. package/src/runtime/query/checkpoint.ts +242 -10
  1353. package/src/runtime/query/events.ts +2 -2
  1354. package/src/runtime/query/executor.ts +847 -39
  1355. package/src/runtime/query/guard.ts +26 -1
  1356. package/src/runtime/query/guardrail-presets.ts +124 -0
  1357. package/src/runtime/query/guardrails.ts +144 -0
  1358. package/src/runtime/query/index.ts +759 -12
  1359. package/src/runtime/query/iteration/__tests__/cancel-settles-turn.test.ts +177 -0
  1360. package/src/runtime/query/iteration/index.ts +656 -40
  1361. package/src/runtime/query/iteration/phases/advisory.test.ts +4 -1
  1362. package/src/runtime/query/iteration/phases/advisory.ts +14 -2
  1363. package/src/runtime/query/iteration/phases/checkpoint.ts +2 -2
  1364. package/src/runtime/query/iteration/phases/compaction-safe-cut.test.ts +3 -1
  1365. package/src/runtime/query/iteration/phases/compaction.ts +329 -64
  1366. package/src/runtime/query/iteration/phases/context-measurement.test.ts +196 -0
  1367. package/src/runtime/query/iteration/phases/context.ts +155 -2
  1368. package/src/runtime/query/iteration/phases/hitl-answer-question.test.ts +3 -1
  1369. package/src/runtime/query/iteration/phases/overflow-escalation.test.ts +167 -0
  1370. package/src/runtime/query/iteration/phases/plan.ts +10 -2
  1371. package/src/runtime/query/iteration/phases/retained-messages.test.ts +226 -0
  1372. package/src/runtime/query/iteration/phases/tool-review-denials.test.ts +270 -0
  1373. package/src/runtime/query/iteration/phases/tool-review.ts +140 -51
  1374. package/src/runtime/query/iteration/phases/working-memory-compaction.test.ts +21 -9
  1375. package/src/runtime/query/iteration/stream-turn.ts +285 -15
  1376. package/src/runtime/query/plugin-hooks.ts +6 -2
  1377. package/src/runtime/query/prompt.ts +26 -1
  1378. package/src/runtime/query/question-park.ts +120 -0
  1379. package/src/runtime/query/result.ts +64 -0
  1380. package/src/runtime/query/resume-pending.ts +394 -0
  1381. package/src/runtime/query/run-state.ts +124 -0
  1382. package/src/runtime/query/tool-grants.ts +83 -0
  1383. package/src/runtime/query/tool-output-budget.ts +183 -0
  1384. package/src/runtime/query/tool-pause.ts +119 -0
  1385. package/src/runtime/query/tooling.ts +23 -1
  1386. package/src/sandbox/__tests__/isolation.test.ts +164 -0
  1387. package/src/sandbox/__tests__/output-truncation.test.ts +106 -0
  1388. package/src/sandbox/__tests__/resource-limits.test.ts +106 -0
  1389. package/src/sandbox/factory.ts +1 -1
  1390. package/src/sandbox/index.ts +2 -0
  1391. package/src/sandbox/isolation.ts +72 -0
  1392. package/src/sandbox/provider/local.ts +173 -74
  1393. package/src/session/__tests__/integration/spawn-rollback.test.ts +1 -1
  1394. package/src/session/handoff/broadcast.ts +3 -3
  1395. package/src/session/migration/__tests__/filesystem.test.ts +26 -19
  1396. package/src/session/migration/filesystem.ts +7 -12
  1397. package/src/session/migration/marker.ts +5 -9
  1398. package/src/session/retention/disk-backend.ts +5 -11
  1399. package/src/session/workspace/__tests__/git-worktree.test.ts +6 -2
  1400. package/src/session/workspace/__tests__/shared-run.test.ts +18 -0
  1401. package/src/session/workspace/shared-run.ts +7 -1
  1402. package/src/skills/__tests__/frontmatter.test.ts +135 -0
  1403. package/src/skills/loader.ts +47 -3
  1404. package/src/store/__tests__/checkpoint-integrity.test.ts +134 -0
  1405. package/src/store/__tests__/checkpoint-versioning.test.ts +194 -0
  1406. package/src/store/__tests__/schema-adoption.test.ts +118 -0
  1407. package/src/store/__tests__/schema.test.ts +119 -0
  1408. package/src/store/memory/disk.ts +17 -16
  1409. package/src/store/run/disk.ts +169 -22
  1410. package/src/store/schema.ts +135 -0
  1411. package/src/store/session/disk.ts +30 -21
  1412. package/src/store/task/__tests__/lookup-across-runs.test.ts +77 -0
  1413. package/src/store/task/disk.ts +59 -15
  1414. package/src/store/thread/disk.ts +21 -10
  1415. package/src/streaming/coalesce.ts +1 -1
  1416. package/src/telemetry/__tests__/latency-instruments.test.ts +120 -0
  1417. package/src/telemetry/__tests__/metrics.test.ts +160 -0
  1418. package/src/telemetry/__tests__/span-hierarchy.test.ts +94 -0
  1419. package/src/telemetry/attributes.ts +109 -0
  1420. package/src/telemetry/metrics.ts +190 -0
  1421. package/src/test-setup.ts +3 -3
  1422. package/src/test-support/paths.ts +17 -0
  1423. package/src/tools/__tests__/path-containment.test.ts +167 -0
  1424. package/src/tools/__tests__/posix-path.test.ts +83 -0
  1425. package/src/tools/__tests__/sandboxed-search.test.ts +140 -0
  1426. package/src/tools/builtins/__tests__/computer-use.test.ts +15 -2
  1427. package/src/tools/builtins/__tests__/edit.test.ts +10 -270
  1428. package/src/tools/builtins/__tests__/payload-budget.test.ts +20 -40
  1429. package/src/tools/builtins/__tests__/read-file.test.ts +29 -1
  1430. package/src/tools/builtins/__tests__/write-file.test.ts +13 -52
  1431. package/src/tools/builtins/bash.ts +34 -4
  1432. package/src/tools/builtins/computer-use.ts +7 -1
  1433. package/src/tools/builtins/edit.ts +162 -116
  1434. package/src/tools/builtins/glob.ts +71 -6
  1435. package/src/tools/builtins/grep.ts +82 -8
  1436. package/src/tools/builtins/index.ts +6 -6
  1437. package/src/tools/builtins/ls.ts +4 -2
  1438. package/src/tools/builtins/read-file.ts +40 -4
  1439. package/src/tools/builtins/write-file.ts +44 -68
  1440. package/src/tools/coordinator/__tests__/agent.test.ts +2 -2
  1441. package/src/tools/coordinator/agent.ts +23 -10
  1442. package/src/tools/coordinator/index.ts +111 -31
  1443. package/src/tools/defineTool.ts +20 -0
  1444. package/src/tools/glob-match.ts +50 -0
  1445. package/src/tools/paths.ts +44 -0
  1446. package/src/tools/posix-path.ts +73 -0
  1447. package/src/types/advisory/config.ts +21 -3
  1448. package/src/types/advisory/result.ts +12 -7
  1449. package/src/types/agent/base.ts +22 -2
  1450. package/src/types/agent/factory.ts +15 -9
  1451. package/src/types/agent/gateway.ts +20 -0
  1452. package/src/types/agent/manager.ts +19 -0
  1453. package/src/types/agent/reactive.ts +50 -0
  1454. package/src/types/agent/router.ts +11 -0
  1455. package/src/types/agent/supervisor.ts +2 -2
  1456. package/src/types/agent/task.ts +26 -0
  1457. package/src/types/bidi/index.ts +119 -0
  1458. package/src/types/common/__tests__/numeric-correctness.test.ts +123 -0
  1459. package/src/types/common/index.ts +16 -4
  1460. package/src/types/computer-use/index.ts +1 -1
  1461. package/src/types/connector/mcp.ts +29 -0
  1462. package/src/types/errors/__tests__/catalog.test.ts +130 -0
  1463. package/src/types/errors/__tests__/errors.test.ts +118 -0
  1464. package/src/types/errors/catalog.ts +211 -0
  1465. package/src/types/errors/index.ts +121 -0
  1466. package/src/types/guardrail/index.ts +62 -0
  1467. package/src/types/hitl/index.ts +102 -20
  1468. package/src/types/ids/index.ts +2 -2
  1469. package/src/types/message/content.ts +50 -0
  1470. package/src/types/message/index.ts +210 -9
  1471. package/src/types/plugin/index.ts +82 -2
  1472. package/src/types/provider/__tests__/cause-chain.test.ts +132 -0
  1473. package/src/types/provider/__tests__/declared-retryable.test.ts +85 -0
  1474. package/src/types/provider/__tests__/overflow-classification.test.ts +113 -0
  1475. package/src/types/provider/chat.ts +29 -1
  1476. package/src/types/provider/config.ts +83 -2
  1477. package/src/types/provider/errors.ts +472 -0
  1478. package/src/types/provider/index.ts +5 -0
  1479. package/src/types/provider/stream.ts +63 -3
  1480. package/src/types/rag/embedding.ts +11 -2
  1481. package/src/types/run/__tests__/step.test.ts +123 -0
  1482. package/src/types/run/answer-review.ts +51 -0
  1483. package/src/types/run/config.ts +35 -0
  1484. package/src/types/run/derive-status.ts +62 -0
  1485. package/src/types/run/entity.ts +18 -0
  1486. package/src/types/run/events.ts +230 -3
  1487. package/src/types/run/index.ts +5 -0
  1488. package/src/types/run/memory-promotion.ts +112 -0
  1489. package/src/types/run/prepare-step.ts +109 -0
  1490. package/src/types/run/state.ts +111 -0
  1491. package/src/types/run/step.ts +95 -0
  1492. package/src/types/run/stop-reason.ts +29 -1
  1493. package/src/types/sandbox/index.ts +93 -12
  1494. package/src/types/structured-output/index.ts +6 -5
  1495. package/src/types/thread/entity.ts +2 -3
  1496. package/src/types/tool/index.ts +204 -1
  1497. package/src/types/tool/repair.ts +54 -0
  1498. package/src/types/toolset/index.ts +2 -6
  1499. package/src/utils/__tests__/atomic-write.test.ts +108 -0
  1500. package/src/utils/__tests__/shell-compress.test.ts +49 -0
  1501. package/src/utils/atomic-write.ts +85 -0
  1502. package/src/utils/shell-compress.ts +12 -1
  1503. package/src/verification/presets.ts +6 -3
@@ -0,0 +1,112 @@
1
+ import type { RunId } from '../ids/index.js'
2
+
3
+ /**
4
+ * What a run learned, offered to whoever decides what is worth keeping.
5
+ *
6
+ * namzu could store a memory and could not *form* one. `MemoryStore` and
7
+ * its disk implementation have been here all along, and the only path
8
+ * into them is the model calling `save_memory` — so a run that worked out
9
+ * a durable fact and never thought to write it down lost it at settle,
10
+ * along with everything the compaction pass had already extracted and
11
+ * structured on the way.
12
+ *
13
+ * The extraction is the part that was already built: the compaction pass
14
+ * distils the transcript into decisions, discoveries, constraints and
15
+ * failures precisely because a summary of prose is worth less than a list
16
+ * of facts. That structure was serialized into one system message and
17
+ * then dropped on the floor when the run ended.
18
+ */
19
+ export interface RunMemoryCandidate {
20
+ readonly runId: RunId
21
+ /** What the run was asked to do, as the extractor recorded it. */
22
+ readonly task: string
23
+ /** Choices the run made and did not revisit. */
24
+ readonly decisions: readonly string[]
25
+ /** Things it found out — the shape of a codebase, the name of a table. */
26
+ readonly discoveries: readonly string[]
27
+ /** What the user said must hold. The most durable category of the four. */
28
+ readonly userRequirements: readonly string[]
29
+ /** Approaches that failed, so a later run does not pay for them again. */
30
+ readonly failures: readonly string[]
31
+ /** Facts about the machine, the toolchain, the environment. */
32
+ readonly environment: readonly string[]
33
+ /** Files the run touched, by path. */
34
+ readonly files: readonly string[]
35
+ /**
36
+ * How many entries each capped list dropped during the run.
37
+ *
38
+ * Carried rather than hidden: a host deciding whether this is worth
39
+ * storing should know it is looking at a truncated record.
40
+ */
41
+ readonly evicted: Readonly<Record<string, number>>
42
+ }
43
+
44
+ /**
45
+ * Decide what a finished run should leave behind.
46
+ *
47
+ * Called once, when the run settles, with everything the compaction pass
48
+ * extracted. Deliberately a callback rather than a store the runtime
49
+ * writes into: what is worth remembering is a policy question the host
50
+ * owns, and a runtime that decided it would be writing a row for every
51
+ * run whether or not anything happened.
52
+ *
53
+ * Never blocks and never fails the run. It runs after the answer is
54
+ * settled, so a throw is logged and swallowed — a memory that failed to
55
+ * form must not retract an answer that was already produced. A host that
56
+ * needs the write to be part of the run's success should do it in its own
57
+ * code, where it can fail loudly.
58
+ */
59
+ export type PromoteMemory = (candidate: RunMemoryCandidate) => void | Promise<void>
60
+
61
+ /**
62
+ * Project the compaction pass's working state into a promotion candidate.
63
+ *
64
+ * A projection rather than the state itself, for the same reason the
65
+ * plugin hooks got one: the working state is an internal structure with
66
+ * caps, eviction counters and slot objects that exist to serve
67
+ * compaction, and handing it over would make every future field of it
68
+ * part of a host-facing contract by accident.
69
+ */
70
+ export function toMemoryCandidate(
71
+ runId: RunId,
72
+ state: {
73
+ task: string
74
+ decisions: string[]
75
+ discoveries: string[]
76
+ userRequirements: string[]
77
+ failures: string[]
78
+ environment: string[]
79
+ files: Map<string, unknown>
80
+ evicted: Record<string, number>
81
+ },
82
+ ): RunMemoryCandidate {
83
+ return {
84
+ runId,
85
+ task: state.task,
86
+ decisions: [...state.decisions],
87
+ discoveries: [...state.discoveries],
88
+ userRequirements: [...state.userRequirements],
89
+ failures: [...state.failures],
90
+ environment: [...state.environment],
91
+ files: [...state.files.keys()],
92
+ evicted: { ...state.evicted },
93
+ }
94
+ }
95
+
96
+ /**
97
+ * The candidate for this run, or `undefined` when there is nothing to
98
+ * offer.
99
+ *
100
+ * A separate function because "was anything extracted?" is a decision,
101
+ * and a decision inlined into a `try` is one a test cannot tell apart
102
+ * from the catch that swallows its failure. Without an extractor there
103
+ * is no working state, and inventing an empty candidate would ask a host
104
+ * to store a record of nothing.
105
+ */
106
+ export function memoryCandidateFor(
107
+ runId: RunId,
108
+ manager: { getState(): Parameters<typeof toMemoryCandidate>[1] } | undefined,
109
+ ): RunMemoryCandidate | undefined {
110
+ if (!manager) return undefined
111
+ return toMemoryCandidate(runId, manager.getState())
112
+ }
@@ -0,0 +1,109 @@
1
+ import type { RunId } from '../ids/index.js'
2
+ import type { Message } from '../message/index.js'
3
+ import type { StepResult } from './step.js'
4
+
5
+ /**
6
+ * What the loop knows before it calls the model again.
7
+ *
8
+ * `stopWhen` (shipped earlier) let a run DECIDE TO STOP based on what the
9
+ * steps produced. This is the other half of the same idea: deciding how
10
+ * the next step should be shaped. Without it, a run's tool surface, model
11
+ * and sampling parameters are fixed at `query()` time, so a phased agent —
12
+ * research with search tools, then write with file tools, then verify with
13
+ * a cheaper model — had to be built as three separate runs, each losing
14
+ * the prior one's context.
15
+ */
16
+ export interface PrepareStepContext {
17
+ readonly runId: RunId
18
+ /** 1-based, matching the iteration number in events and traces. */
19
+ readonly stepNumber: number
20
+ /** Full history as it stands, so a decision can read what happened. */
21
+ readonly messages: readonly Message[]
22
+ /** Every completed step, in order. */
23
+ readonly steps: readonly StepResult[]
24
+
25
+ /**
26
+ * What the stages before this one decided, when several were supplied.
27
+ *
28
+ * Empty for the first stage, and empty for a single `prepareStep`.
29
+ * Reading it is how a later stage refines an earlier one — narrowing a
30
+ * tool set that has already been narrowed, or leaving a model alone
31
+ * because something upstream had a reason to change it.
32
+ */
33
+ readonly prepared: Readonly<PrepareStepResult>
34
+ }
35
+
36
+ /**
37
+ * Overrides for the NEXT step. Every field is optional; an omitted field
38
+ * keeps the run's configured value, and returning nothing at all is the
39
+ * same as not supplying a `prepareStep`.
40
+ */
41
+ export interface PrepareStepResult {
42
+ /**
43
+ * Restrict which tools the model may call this step, by name. Names
44
+ * that are not registered are dropped with a warning rather than
45
+ * failing the run — a phase list that outlives a tool rename should
46
+ * narrow the surface, not kill the agent mid-run.
47
+ *
48
+ * **This costs a prompt-cache prefix.** Tools render at position 0, so
49
+ * changing the set between steps invalidates the cached prefix for that
50
+ * step. That is inherent to narrowing, not an implementation detail, so
51
+ * it is worth doing when a phase boundary genuinely changes what the
52
+ * agent should reach for — and not worth doing every step.
53
+ *
54
+ * Note it does NOT touch `tool_choice`. Not every provider has an `allowed_tools`
55
+ * parameter, and moving `tool_choice` invalidates cached MESSAGE blocks
56
+ * as well — a strictly worse trade for the same effect.
57
+ */
58
+ readonly activeTools?: readonly string[]
59
+
60
+ /** Use a different model for this step. */
61
+ readonly model?: string
62
+
63
+ /**
64
+ * Guidance for this step ONLY, appended as a system message that is not
65
+ * retained afterwards.
66
+ *
67
+ * Kept separate from the run's system prompt on purpose: the prompt is
68
+ * the cached prefix, and rewriting it per step would bust the cache on
69
+ * every iteration for what is usually one sentence of phase direction.
70
+ */
71
+ readonly system?: string
72
+
73
+ readonly temperature?: number
74
+ readonly maxResponseTokens?: number
75
+ }
76
+
77
+ /**
78
+ * Called before each model call, with everything the run has produced so
79
+ * far.
80
+ *
81
+ * A throw fails OPEN — the step proceeds with the run's configured values.
82
+ * Same reasoning as `stopWhen` and deliberately opposite to a guardrail: a
83
+ * broken step-shaping hook should not kill an otherwise healthy run, and
84
+ * unlike a safety check, nothing unsafe gets through when it is skipped.
85
+ */
86
+ export type PrepareStep = (
87
+ context: PrepareStepContext,
88
+ ) => PrepareStepResult | undefined | Promise<PrepareStepResult | undefined>
89
+
90
+ /**
91
+ * One shaping stage, or several applied in order.
92
+ *
93
+ * A single slot is enough for one concern and no help with two. A host
94
+ * with a per-tenant system prefix AND a cost-based model downgrade had to
95
+ * hand-compose them into one callback, which puts the ordering in the
96
+ * host's code where nothing can see it and makes each concern's failure
97
+ * the other's problem.
98
+ *
99
+ * An ARRAY is ordered by declaration, not by registration. That
100
+ * distinction is the whole reason this is safe where a plugin-style
101
+ * fan-out would not be: the author writes the order down, so "who wins"
102
+ * is a line of their code rather than an accident of install history.
103
+ * Each stage sees what the ones before it decided, and a later stage
104
+ * overrides a field an earlier one set — last writer wins, visibly.
105
+ *
106
+ * A stage that throws is skipped and the rest still run, so one broken
107
+ * concern cannot silently disable the others.
108
+ */
109
+ export type PrepareStepChain = PrepareStep | readonly PrepareStep[]
@@ -0,0 +1,111 @@
1
+ import type { AgentStatus, CostInfo, TokenUsage } from '../common/index.js'
2
+ import type { CheckpointId, PendingDecision } from '../hitl/index.js'
3
+ import type { RunId, SessionId, TenantId } from '../ids/index.js'
4
+ import type { Message } from '../message/index.js'
5
+ import type { ProjectId, ThreadId } from '../session/ids.js'
6
+ import type { StopReason } from './stop-reason.js'
7
+
8
+ /**
9
+ * Everything needed to pick a run back up in a DIFFERENT process.
10
+ *
11
+ * A run's live state was spread across objects that only exist in memory —
12
+ * `RunPersistence`, `GuardCoordinator`, the suspended `await` inside a HITL
13
+ * gate. `IterationCheckpoint` carries the history and the budgets, but it
14
+ * is keyed by a store scope the reader has to already know, and it says
15
+ * nothing about the run's status or why it stopped. So "resume this run"
16
+ * meant "the original process is still alive and holding it".
17
+ *
18
+ * That is the constraint this removes. `RunState` is a flat, JSON-safe
19
+ * snapshot: a serverless handler writes one when a run parks, returns, and
20
+ * a later invocation — a different container — reads it back and continues.
21
+ *
22
+ * It is a SNAPSHOT, not a live handle. Nothing in it points at a socket, a
23
+ * sandbox, a provider client, or an open file. Re-establishing those is the
24
+ * host's job on the way back in, which is exactly why they are absent.
25
+ */
26
+ export interface RunState {
27
+ /**
28
+ * Schema version. Bumped when the shape changes incompatibly, so a
29
+ * host that stored a snapshot with an older SDK gets a clear failure
30
+ * from {@link parseRunState} instead of a partial restore.
31
+ */
32
+ readonly version: 1
33
+
34
+ readonly runId: RunId
35
+ readonly sessionId: SessionId
36
+ readonly threadId: ThreadId
37
+ readonly projectId: ProjectId
38
+ readonly tenantId: TenantId
39
+ /** Present for sub-runs, so a hierarchical store can key the snapshot. */
40
+ readonly parentRunId?: RunId
41
+
42
+ readonly agentId?: string
43
+ readonly agentName?: string
44
+
45
+ readonly status: AgentStatus
46
+ readonly stopReason?: StopReason
47
+ readonly lastError?: string
48
+
49
+ readonly messages: Message[]
50
+ readonly tokenUsage: TokenUsage
51
+ readonly costInfo: CostInfo
52
+ readonly currentIteration: number
53
+ readonly startedAt: number
54
+ /**
55
+ * Wall-clock the run has already consumed. Restored into the guard so a
56
+ * resumed run does not get a fresh timeout budget — the timeout is a
57
+ * property of the RUN, not of the process hosting it.
58
+ */
59
+ readonly elapsedMs: number
60
+
61
+ /**
62
+ * The checkpoint this snapshot corresponds to, when one was written.
63
+ * Pass it as `resumeFromCheckpoint`.
64
+ */
65
+ readonly checkpointId?: CheckpointId
66
+
67
+ /**
68
+ * The decision the run is parked on, if any. A host reads this to know
69
+ * what to ask a human, and feeds the answer back as
70
+ * `QueryParams.pendingDecision`.
71
+ */
72
+ readonly pending?: PendingDecision
73
+
74
+ readonly capturedAt: number
75
+ }
76
+
77
+ /** Thrown by {@link parseRunState} when a snapshot cannot be trusted. */
78
+ export class RunStateVersionError extends Error {
79
+ constructor(
80
+ readonly found: unknown,
81
+ readonly expected: number,
82
+ ) {
83
+ super(
84
+ `RunState version mismatch: snapshot declares ${JSON.stringify(found)}, this SDK reads ${expected}. Restoring across an incompatible version would silently drop fields; re-run instead.`,
85
+ )
86
+ this.name = 'RunStateVersionError'
87
+ }
88
+ }
89
+
90
+ export const RUN_STATE_VERSION = 1 as const
91
+
92
+ /**
93
+ * Parse a serialized snapshot, refusing anything this SDK cannot fully
94
+ * restore.
95
+ *
96
+ * The version guard is the point. A snapshot is written by one deployment
97
+ * and read by another, possibly weeks later and possibly after an SDK
98
+ * upgrade; a silent partial restore there produces a run that looks healthy
99
+ * and has lost its budgets. Failing loudly is the only honest option.
100
+ */
101
+ export function parseRunState(json: string | unknown): RunState {
102
+ const raw: unknown = typeof json === 'string' ? JSON.parse(json) : json
103
+ if (typeof raw !== 'object' || raw === null) {
104
+ throw new RunStateVersionError(raw, RUN_STATE_VERSION)
105
+ }
106
+ const version = (raw as { version?: unknown }).version
107
+ if (version !== RUN_STATE_VERSION) {
108
+ throw new RunStateVersionError(version, RUN_STATE_VERSION)
109
+ }
110
+ return raw as RunState
111
+ }
@@ -0,0 +1,95 @@
1
+ import type { CostInfo, TokenUsage } from '../common/index.js'
2
+ import type { MessageId } from '../ids/index.js'
3
+ import type { ToolCall } from '../message/index.js'
4
+
5
+ /**
6
+ * What one iteration of the agent loop did.
7
+ *
8
+ * None of this was reachable before. `Run` and `BaseAgentResult` have no
9
+ * `steps[]`, so a host that persisted the returned `Run` — the natural
10
+ * thing — permanently lost per-step attribution: answering "which step
11
+ * cost the most" meant correlating raw `RunEvent`s by iteration number and
12
+ * diffing cumulative counters, and per-tool duration was never emitted at
13
+ * all. Every field here was already computed somewhere in the loop.
14
+ */
15
+ export interface StepResult {
16
+ /** 1-based, matching `iteration` on the run events. */
17
+ stepNumber: number
18
+ model: string
19
+ messageId: MessageId
20
+ /** Assistant text for this step, if any. */
21
+ content: string | null
22
+ toolCalls: readonly ToolCall[]
23
+ /** Tool outcomes, in the same order as `toolCalls`. */
24
+ toolResults: readonly StepToolResult[]
25
+ finishReason: 'stop' | 'tool_calls' | 'length' | 'content_filter'
26
+ /** Usage for THIS step, not the run's cumulative total. */
27
+ usage: TokenUsage
28
+ /** Cost delta attributable to this step. Zero without a pricing table. */
29
+ costDelta: CostInfo
30
+ startedAt: number
31
+ /** Wall-clock for the whole step, including tool execution. */
32
+ durationMs: number
33
+ /** Portion of `durationMs` spent inside tools. */
34
+ toolExecutionMs: number
35
+ }
36
+
37
+ export interface StepToolResult {
38
+ toolCallId: string
39
+ toolName: string
40
+ /** Text form, after the model-visible output budget was applied. */
41
+ output: string
42
+ isError: boolean
43
+ durationMs: number
44
+ }
45
+
46
+ /**
47
+ * A programmable halt condition, evaluated after each step's tools have
48
+ * run.
49
+ *
50
+ * `GuardCoordinator` — the only halt before this — consumes
51
+ * `{aborted, totalTokens, totalCost, currentIteration, startTime}` and
52
+ * never sees messages, tool calls or results. So "stop after three steps
53
+ * with no progress" and "stop once the plan is complete" were
54
+ * inexpressible, and a terminal `submit_answer` tool could not end the
55
+ * run: the model had to be prompt-begged to stop, with `maxIterations:
56
+ * 200` as the only backstop.
57
+ *
58
+ * Returning `true` ends the run with `stop_reason: 'stop_condition'`.
59
+ */
60
+ export type StopCondition = (state: StopConditionState) => boolean | Promise<boolean>
61
+
62
+ export interface StopConditionState {
63
+ /** Every step so far, most recent last. */
64
+ readonly steps: readonly StepResult[]
65
+ readonly latestStep: StepResult
66
+ readonly totalUsage: TokenUsage
67
+ readonly totalCost: CostInfo
68
+ }
69
+
70
+ /** Stop once `n` steps have completed. */
71
+ export function stepCountIs(n: number): StopCondition {
72
+ return ({ steps }) => steps.length >= n
73
+ }
74
+
75
+ /**
76
+ * Stop when the latest step called any of `names`.
77
+ *
78
+ * The tool still executes and its result is still recorded — the run ends
79
+ * after, not instead. That is what makes a `submit_answer` / `verify` tool
80
+ * usable as a terminator without losing its output.
81
+ */
82
+ export function hasToolCall(...names: string[]): StopCondition {
83
+ const wanted = new Set(names)
84
+ return ({ latestStep }) => latestStep.toolCalls.some((tc) => wanted.has(tc.function.name))
85
+ }
86
+
87
+ /** Stop when any of the given conditions does. */
88
+ export function anyOf(...conditions: StopCondition[]): StopCondition {
89
+ return async (state) => {
90
+ for (const condition of conditions) {
91
+ if (await condition(state)) return true
92
+ }
93
+ return false
94
+ }
95
+ }
@@ -6,13 +6,31 @@ export type StopReason =
6
6
  | 'max_iterations'
7
7
  | 'cancelled'
8
8
  | 'plan_rejected'
9
+ /** A caller-supplied `stopWhen` predicate returned true. */
10
+ | 'stop_condition'
11
+ /** The model never produced a valid structured output within its retries. */
12
+ | 'structured_output_failed'
13
+ /**
14
+ * A host reviewer kept rejecting the answer and the run ran out of
15
+ * attempts.
16
+ *
17
+ * Distinct from a budget stop on purpose: without it the run would end
18
+ * on `max_iterations` or a token cap, naming the resource it exhausted
19
+ * rather than the judgement that exhausted it — and the reader would go
20
+ * looking for a loop instead of at the reviewer.
21
+ */
22
+ | 'answer_rejected'
23
+ /** An input guardrail refused the run before it started. */
24
+ | 'input_guardrail'
25
+ /** An output guardrail refused the produced result. */
26
+ | 'output_guardrail'
9
27
  | 'paused'
10
28
  | 'error'
11
29
 
12
30
  /**
13
31
  * Per-LLM-message stop reason — distinct from the run-level {@link StopReason}.
14
32
  *
15
- * Mirrors the union of Anthropic and OpenAI finish reasons normalised into a
33
+ * The union of the finish reasons providers report, normalised into a
16
34
  * provider-agnostic vocabulary. `forced_finalize` is a Namzu-specific value
17
35
  * emitted by the orchestrator when iteration limits force a final response
18
36
  * without a model-issued stop reason.
@@ -25,3 +43,13 @@ export type MessageStopReason =
25
43
  | 'pause_turn'
26
44
  | 'refusal'
27
45
  | 'forced_finalize'
46
+ /**
47
+ * The turn was cancelled mid-stream.
48
+ *
49
+ * Also Namzu-specific, and added because the cancel path had no way to
50
+ * close the message it had opened: it re-threw from inside the chunk
51
+ * loop, so the terminal event never fired and a host consuming the
52
+ * message lifecycle saw a message begin and never end. A turn that
53
+ * stops is still a turn that finished streaming, whatever stopped it.
54
+ */
55
+ | 'cancelled'
@@ -32,6 +32,32 @@ export function assertSandboxStatus(status: SandboxStatus): void {
32
32
 
33
33
  export type SandboxEnvironment = 'linux-namespace' | 'macos-seatbelt' | 'basic'
34
34
 
35
+ /**
36
+ * A security control a sandbox tier either provides or does not.
37
+ *
38
+ * The environment name alone does not say what a caller actually gets:
39
+ * one tier denies the network outright while another leaves the host
40
+ * filesystem fully visible, and both used to answer to the same provider
41
+ * name. A caller that turned isolation on for a reason needs to state
42
+ * which control it is relying on, so a host that cannot supply it can
43
+ * refuse instead of quietly handing back less.
44
+ *
45
+ * - `filesystem` — the spawned process cannot read or write outside the
46
+ * sandbox root.
47
+ * - `network` — the spawned process cannot reach the network.
48
+ * - `process` — the spawned process cannot see or signal host processes.
49
+ */
50
+ export type SandboxIsolationControl = 'filesystem' | 'network' | 'process'
51
+
52
+ export const SANDBOX_ISOLATION_CONTROLS: readonly SandboxIsolationControl[] = [
53
+ 'filesystem',
54
+ 'network',
55
+ 'process',
56
+ ]
57
+
58
+ /** What a tier actually enforces, per control. */
59
+ export type SandboxIsolationReport = Readonly<Record<SandboxIsolationControl, boolean>>
60
+
35
61
  export function assertSandboxEnvironment(env: SandboxEnvironment): void {
36
62
  switch (env) {
37
63
  case 'linux-namespace':
@@ -56,6 +82,17 @@ export interface SandboxExecResult {
56
82
  readonly signal?: string
57
83
  readonly timedOut: boolean
58
84
  readonly durationMs: number
85
+ /**
86
+ * Set when the backend clipped the stream at its output cap.
87
+ *
88
+ * The firecracker protocol already computed these, but they had no slot
89
+ * in this contract, so they were dropped at the type boundary and the
90
+ * model saw a complete-looking result that had silently lost its tail —
91
+ * against the kernel's own convention that it does not truncate
92
+ * silently.
93
+ */
94
+ readonly stdoutTruncated?: boolean
95
+ readonly stderrTruncated?: boolean
59
96
  }
60
97
 
61
98
  // ---------------------------------------------------------------------------
@@ -66,6 +103,15 @@ export interface SandboxExecOptions {
66
103
  readonly timeout?: number
67
104
  readonly env?: Record<string, string>
68
105
  readonly cwd?: string
106
+ /**
107
+ * Cancellation for the command. A backend that honours it kills the
108
+ * process; one that does not simply ignores it, so this is additive.
109
+ *
110
+ * Without it a Stop (or a per-tool deadline) could only ever abandon
111
+ * the *wait* — the sandboxed process kept running after the host
112
+ * believed the run had been cancelled.
113
+ */
114
+ readonly signal?: AbortSignal
69
115
  }
70
116
 
71
117
  // ---------------------------------------------------------------------------
@@ -87,16 +133,44 @@ export interface SandboxFileEntry {
87
133
  // Sandbox interface — the core abstraction
88
134
  // ---------------------------------------------------------------------------
89
135
 
136
+ /**
137
+ * A network policy applied to a LIVE sandbox.
138
+ *
139
+ * The whole point is that it can change mid-life. The common shape —
140
+ * "fetch the repository with a token, then drop to deny-all before running
141
+ * anything the repository contains" — was not expressible at all: the
142
+ * policy was frozen at provider construction, so a host had to build a
143
+ * second provider and a second sandbox, copying the work across.
144
+ */
145
+ export interface SandboxNetworkPolicy {
146
+ /**
147
+ * Hosts the sandbox may reach. Empty denies everything.
148
+ *
149
+ * `api.example.com` matches that host; `.example.com` matches the
150
+ * domain and its subdomains. Substring matching is deliberately not
151
+ * offered — `example.com` as a substring would admit
152
+ * `example.com.attacker.net`.
153
+ */
154
+ readonly allowedHosts: readonly string[]
155
+ }
156
+
90
157
  export interface Sandbox {
91
158
  readonly id: SandboxId
92
159
  readonly status: SandboxStatus
93
160
  readonly rootDir: string
94
161
  readonly environment: SandboxEnvironment
95
162
  exec(command: string, args?: string[], opts?: SandboxExecOptions): Promise<SandboxExecResult>
163
+
96
164
  /**
97
- * Atomically replace the destination body: readers must observe either the
98
- * previous complete body or the new complete body, never a truncated file.
165
+ * Narrow or widen what this sandbox can reach, while it is running.
166
+ *
167
+ * Optional, and a backend that cannot enforce it must **throw** rather
168
+ * than accept and ignore. A network policy that is accepted and not
169
+ * applied is worse than one that was never offered: the caller stops
170
+ * looking, and the run proceeds believing it is confined. That is the
171
+ * same rule the tiered sandbox provider follows, for the same reason.
99
172
  */
173
+ setNetworkPolicy?(policy: SandboxNetworkPolicy): Promise<void>
100
174
  writeFile(path: string, content: string | Buffer): Promise<void>
101
175
  readFile(path: string): Promise<Buffer>
102
176
  /**
@@ -128,10 +202,10 @@ export interface Sandbox {
128
202
  //
129
203
  // Why the `Container` prefix on these types: the layout shape encodes
130
204
  // container-tier semantics (bind-mount sources, `/mnt/...` container
131
- // paths, RW outputs surface). MicroVM tiers (e2b, fly-machines,
132
- // firecracker-containerd) carry layout-equivalent state that does
133
- // not map onto bind-mount flags managed snapshots, attached
134
- // volumes, registry-pulled rootfs. Naming the public type
205
+ // paths, RW outputs surface). A microVM tier carries
206
+ // layout-equivalent state that does not map onto bind-mount flags —
207
+ // snapshots, attached volumes, a rootfs pulled from a registry.
208
+ // Naming the public type
135
209
  // `SandboxLayout` would either (a) make every future microVM adapter
136
210
  // pretend its volume model fits a bind-mount shape, or (b) force a
137
211
  // breaking rename when we add `MicroVMSandboxLayout` later. Naming
@@ -203,9 +277,9 @@ export interface ContainerSandboxLayoutMount {
203
277
  }
204
278
 
205
279
  /**
206
- * Declarative multi-mount taxonomy for a CONTAINER sandbox. Mirrors
207
- * the layout Anthropic's container architecture exposes to the model
208
- * (Claude container blueprint, Code Interpreter, "skills"):
280
+ * Declarative multi-mount taxonomy for a CONTAINER sandbox. A container
281
+ * needs one place the user will see and several the user will not, and
282
+ * the difference has to be legible to the model from the path alone:
209
283
  *
210
284
  * - `outputs` — RW bind. User-visible output surface that the
211
285
  * user consumes after the run. Default container path
@@ -248,7 +322,7 @@ export interface ContainerSandboxLayout {
248
322
  * not a child of it: the output collector / output watcher
249
323
  * scans `outputs` only, so anything the agent writes under
250
324
  * `scratch` is invisible to the user by construction. Mirrors the
251
- * Anthropic Cowork pattern (`/home/claude` as scratch vs.
325
+ * separation between scratch space (invisible to the collector) and
252
326
  * `/mnt/user-data/outputs` as the user-visible output area).
253
327
  * Hosts that don't need a separate scratch mount may omit this.
254
328
  */
@@ -312,7 +386,7 @@ export interface SandboxCreateConfig {
312
386
  * Putting layout on `SandboxCreateConfig` would let the SDK runtime
313
387
  * (`drainQuery`) call `provider.create()` without it and trigger a
314
388
  * runtime validation failure that the type system cannot catch — a
315
- * trap Codex flagged in the second review round. Hosts spawning a
389
+ * trap flagged in the second review round. Hosts spawning a
316
390
  * sandbox per task construct one provider per task too; the same
317
391
  * closure that knows the per-task `hostPath`s is the one that calls
318
392
  * `createSandboxProvider`.
@@ -339,7 +413,14 @@ export const SandboxConfigSchema = z.object({
339
413
  timeoutMs: z.number().positive().default(SANDBOX_DEFAULT_TIMEOUT_MS),
340
414
  memoryLimitMb: z.number().positive().default(SANDBOX_DEFAULT_MEMORY_LIMIT_MB),
341
415
  maxProcesses: z.number().positive().default(SANDBOX_DEFAULT_MAX_PROCESSES),
342
- cleanupOnDestroy: z.boolean().default(true),
416
+ /**
417
+ * Controls the run depends on. Provider construction throws when the
418
+ * host cannot enforce one of them. Empty by default, which keeps
419
+ * best-effort behaviour for callers that never asked for a guarantee —
420
+ * but a caller that did ask now gets it or gets an error, never a
421
+ * quiet downgrade.
422
+ */
423
+ requireIsolation: z.array(z.enum(['filesystem', 'network', 'process'])).default([]),
343
424
  })
344
425
 
345
426
  export type SandboxConfig = z.infer<typeof SandboxConfigSchema>
@@ -14,12 +14,13 @@ export interface StructuredOutputConfig<TSchema extends z.ZodType = z.ZodType> {
14
14
  schema: TSchema
15
15
 
16
16
  /**
17
- * Whether to force the model to use the structured_output tool.
18
- * When true, sets tool_choice to force the tool.
19
- * When false, the model may choose to call it or not.
20
- * Default: true
17
+ * Turns spent re-prompting when the model answers in prose or fails
18
+ * validation. Defaults to {@link DEFAULT_STRUCTURED_OUTPUT_RETRIES}.
19
+ *
20
+ * Bounded so a model that cannot satisfy the schema fails loudly rather
21
+ * than iterating against `maxIterations`.
21
22
  */
22
- enforceToolChoice?: boolean
23
+ maxRetries?: number
23
24
  }
24
25
 
25
26
  /**
@@ -44,9 +44,8 @@ export type ThreadStatus = 'open' | 'archived'
44
44
  * - **Sessions are the immediate work unit.** A user or agent enters a
45
45
  * Thread and opens/resumes Sessions for the concrete interval of work.
46
46
  *
47
- * This is the mental model ses_001 ratified (Phase 0, 2026-04-18). Industry
48
- * frameworks (OpenAI Responses, LangGraph, Claude Agent SDK, Temporal) do
49
- * not have an exact analogue for the Thread layer — it is Namzu's answer to
47
+ * This is the mental model ses_001 ratified (Phase 0, 2026-04-18). The
48
+ * Thread layer has no counterpart elsewhere it is Namzu's answer to
50
49
  * the question "how do you expose a multi-session topic to A2A without
51
50
  * coupling it to the Project's filesystem identity?".
52
51
  *