@namzu/sdk 35.0.0 → 37.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 (360) hide show
  1. package/CHANGELOG.md +218 -0
  2. package/README.md +68 -41
  3. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  4. package/dist/bridge/a2a/mapper.js +2 -0
  5. package/dist/bridge/a2a/mapper.js.map +1 -1
  6. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  7. package/dist/bridge/sse/mapper.js +2 -0
  8. package/dist/bridge/sse/mapper.js.map +1 -1
  9. package/dist/compaction/extractor.d.ts +1 -1
  10. package/dist/compaction/extractor.d.ts.map +1 -1
  11. package/dist/compaction/extractor.js +15 -7
  12. package/dist/compaction/extractor.js.map +1 -1
  13. package/dist/compaction/manager.d.ts +2 -0
  14. package/dist/compaction/manager.d.ts.map +1 -1
  15. package/dist/compaction/manager.js +12 -1
  16. package/dist/compaction/manager.js.map +1 -1
  17. package/dist/compaction/verifier.d.ts.map +1 -1
  18. package/dist/compaction/verifier.js +82 -15
  19. package/dist/compaction/verifier.js.map +1 -1
  20. package/dist/contracts/schemas.d.ts +10 -10
  21. package/dist/eval/harness-verification.d.ts +63 -0
  22. package/dist/eval/harness-verification.d.ts.map +1 -0
  23. package/dist/eval/harness-verification.js +165 -0
  24. package/dist/eval/harness-verification.js.map +1 -0
  25. package/dist/eval/index.d.ts +2 -0
  26. package/dist/eval/index.d.ts.map +1 -1
  27. package/dist/eval/index.js +1 -0
  28. package/dist/eval/index.js.map +1 -1
  29. package/dist/execution/code-runtime/json-value.d.ts +10 -0
  30. package/dist/execution/code-runtime/json-value.d.ts.map +1 -0
  31. package/dist/execution/code-runtime/json-value.js +89 -0
  32. package/dist/execution/code-runtime/json-value.js.map +1 -0
  33. package/dist/execution/code-runtime/worker-program.d.ts +8 -0
  34. package/dist/execution/code-runtime/worker-program.d.ts.map +1 -0
  35. package/dist/execution/code-runtime/worker-program.js +240 -0
  36. package/dist/execution/code-runtime/worker-program.js.map +1 -0
  37. package/dist/execution/code-runtime/worker.d.ts +22 -0
  38. package/dist/execution/code-runtime/worker.d.ts.map +1 -1
  39. package/dist/execution/code-runtime/worker.js +148 -111
  40. package/dist/execution/code-runtime/worker.js.map +1 -1
  41. package/dist/manager/agent/lifecycle.d.ts +12 -0
  42. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  43. package/dist/manager/agent/lifecycle.js +306 -37
  44. package/dist/manager/agent/lifecycle.js.map +1 -1
  45. package/dist/manager/run/persistence.d.ts +2 -0
  46. package/dist/manager/run/persistence.d.ts.map +1 -1
  47. package/dist/manager/run/persistence.js +6 -0
  48. package/dist/manager/run/persistence.js.map +1 -1
  49. package/dist/provider/capabilities.d.ts +3 -1
  50. package/dist/provider/capabilities.d.ts.map +1 -1
  51. package/dist/provider/capabilities.js +13 -0
  52. package/dist/provider/capabilities.js.map +1 -1
  53. package/dist/provider/fallback.d.ts.map +1 -1
  54. package/dist/provider/fallback.js +2 -0
  55. package/dist/provider/fallback.js.map +1 -1
  56. package/dist/provider/token-budget.d.ts.map +1 -1
  57. package/dist/provider/token-budget.js +56 -8
  58. package/dist/provider/token-budget.js.map +1 -1
  59. package/dist/public-runtime.d.ts +5 -3
  60. package/dist/public-runtime.d.ts.map +1 -1
  61. package/dist/public-runtime.js +3 -2
  62. package/dist/public-runtime.js.map +1 -1
  63. package/dist/public-tools.d.ts +1 -1
  64. package/dist/public-tools.d.ts.map +1 -1
  65. package/dist/public-tools.js +1 -1
  66. package/dist/public-tools.js.map +1 -1
  67. package/dist/public-types.d.ts +1 -0
  68. package/dist/public-types.d.ts.map +1 -1
  69. package/dist/registry/tool/execute.d.ts +3 -0
  70. package/dist/registry/tool/execute.d.ts.map +1 -1
  71. package/dist/registry/tool/execute.js +11 -80
  72. package/dist/registry/tool/execute.js.map +1 -1
  73. package/dist/run/command-gate.d.ts.map +1 -1
  74. package/dist/run/command-gate.js +65 -12
  75. package/dist/run/command-gate.js.map +1 -1
  76. package/dist/run/index.d.ts +2 -0
  77. package/dist/run/index.d.ts.map +1 -1
  78. package/dist/run/index.js +1 -0
  79. package/dist/run/index.js.map +1 -1
  80. package/dist/run/memory-promoter.d.ts +3 -35
  81. package/dist/run/memory-promoter.d.ts.map +1 -1
  82. package/dist/run/memory-promoter.js +32 -40
  83. package/dist/run/memory-promoter.js.map +1 -1
  84. package/dist/run/memory-recall.d.ts +25 -0
  85. package/dist/run/memory-recall.d.ts.map +1 -0
  86. package/dist/run/memory-recall.js +228 -0
  87. package/dist/run/memory-recall.js.map +1 -0
  88. package/dist/run/reporter.d.ts.map +1 -1
  89. package/dist/run/reporter.js +1 -0
  90. package/dist/run/reporter.js.map +1 -1
  91. package/dist/run/token-budget.d.ts +2 -0
  92. package/dist/run/token-budget.d.ts.map +1 -1
  93. package/dist/run/token-budget.js +4 -0
  94. package/dist/run/token-budget.js.map +1 -1
  95. package/dist/run/workspace-fingerprint.d.ts +10 -3
  96. package/dist/run/workspace-fingerprint.d.ts.map +1 -1
  97. package/dist/run/workspace-fingerprint.js +17 -8
  98. package/dist/run/workspace-fingerprint.js.map +1 -1
  99. package/dist/runtime/query/checkpoint.d.ts +14 -0
  100. package/dist/runtime/query/checkpoint.d.ts.map +1 -1
  101. package/dist/runtime/query/checkpoint.js +82 -1
  102. package/dist/runtime/query/checkpoint.js.map +1 -1
  103. package/dist/runtime/query/executor.d.ts +6 -0
  104. package/dist/runtime/query/executor.d.ts.map +1 -1
  105. package/dist/runtime/query/executor.js +120 -24
  106. package/dist/runtime/query/executor.js.map +1 -1
  107. package/dist/runtime/query/index.d.ts +12 -8
  108. package/dist/runtime/query/index.d.ts.map +1 -1
  109. package/dist/runtime/query/index.js +55 -7
  110. package/dist/runtime/query/index.js.map +1 -1
  111. package/dist/runtime/query/iteration/index.d.ts +13 -3
  112. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  113. package/dist/runtime/query/iteration/index.js +356 -42
  114. package/dist/runtime/query/iteration/index.js.map +1 -1
  115. package/dist/runtime/query/iteration/native-output.d.ts +10 -0
  116. package/dist/runtime/query/iteration/native-output.d.ts.map +1 -0
  117. package/dist/runtime/query/iteration/native-output.js +32 -0
  118. package/dist/runtime/query/iteration/native-output.js.map +1 -0
  119. package/dist/runtime/query/iteration/phases/advisory.d.ts.map +1 -1
  120. package/dist/runtime/query/iteration/phases/advisory.js +18 -13
  121. package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
  122. package/dist/runtime/query/iteration/phases/compaction.d.ts +2 -0
  123. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  124. package/dist/runtime/query/iteration/phases/compaction.js +32 -11
  125. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  126. package/dist/runtime/query/iteration/phases/context.d.ts +11 -0
  127. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  128. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  129. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  130. package/dist/runtime/query/iteration/phases/tool-review.js +1 -1
  131. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  132. package/dist/runtime/query/iteration/phases/working-memory.d.ts +1 -1
  133. package/dist/runtime/query/iteration/phases/working-memory.d.ts.map +1 -1
  134. package/dist/runtime/query/iteration/phases/working-memory.js +23 -6
  135. package/dist/runtime/query/iteration/phases/working-memory.js.map +1 -1
  136. package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
  137. package/dist/runtime/query/iteration/stream-turn.js +12 -5
  138. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  139. package/dist/runtime/query/prompt.d.ts.map +1 -1
  140. package/dist/runtime/query/prompt.js +14 -4
  141. package/dist/runtime/query/prompt.js.map +1 -1
  142. package/dist/runtime/query/steering.d.ts +6 -2
  143. package/dist/runtime/query/steering.d.ts.map +1 -1
  144. package/dist/runtime/query/steering.js +17 -2
  145. package/dist/runtime/query/steering.js.map +1 -1
  146. package/dist/runtime/query/tool-call-budget.d.ts +19 -0
  147. package/dist/runtime/query/tool-call-budget.d.ts.map +1 -0
  148. package/dist/runtime/query/tool-call-budget.js +110 -0
  149. package/dist/runtime/query/tool-call-budget.js.map +1 -0
  150. package/dist/runtime/query/tooling.d.ts +2 -0
  151. package/dist/runtime/query/tooling.d.ts.map +1 -1
  152. package/dist/runtime/query/tooling.js +4 -0
  153. package/dist/runtime/query/tooling.js.map +1 -1
  154. package/dist/sandbox/file-walk-program.d.ts +3 -0
  155. package/dist/sandbox/file-walk-program.d.ts.map +1 -0
  156. package/dist/sandbox/file-walk-program.js +94 -0
  157. package/dist/sandbox/file-walk-program.js.map +1 -0
  158. package/dist/sandbox/file-walk.d.ts +12 -0
  159. package/dist/sandbox/file-walk.d.ts.map +1 -0
  160. package/dist/sandbox/file-walk.js +429 -0
  161. package/dist/sandbox/file-walk.js.map +1 -0
  162. package/dist/sandbox/index.d.ts +2 -0
  163. package/dist/sandbox/index.d.ts.map +1 -1
  164. package/dist/sandbox/index.js +1 -0
  165. package/dist/sandbox/index.js.map +1 -1
  166. package/dist/sandbox/provider/local.d.ts.map +1 -1
  167. package/dist/sandbox/provider/local.js +9 -0
  168. package/dist/sandbox/provider/local.js.map +1 -1
  169. package/dist/scheduler/completion-inbox.d.ts +3 -2
  170. package/dist/scheduler/completion-inbox.d.ts.map +1 -1
  171. package/dist/scheduler/completion-inbox.js +29 -15
  172. package/dist/scheduler/completion-inbox.js.map +1 -1
  173. package/dist/scheduler/local.d.ts.map +1 -1
  174. package/dist/scheduler/local.js +1 -0
  175. package/dist/scheduler/local.js.map +1 -1
  176. package/dist/session/handoff/capacity.d.ts +2 -2
  177. package/dist/session/handoff/capacity.d.ts.map +1 -1
  178. package/dist/session/handoff/capacity.js +3 -2
  179. package/dist/session/handoff/capacity.js.map +1 -1
  180. package/dist/store/memory/disk.d.ts +6 -2
  181. package/dist/store/memory/disk.d.ts.map +1 -1
  182. package/dist/store/memory/disk.js +42 -25
  183. package/dist/store/memory/disk.js.map +1 -1
  184. package/dist/store/memory/index.d.ts +4 -0
  185. package/dist/store/memory/index.d.ts.map +1 -1
  186. package/dist/store/memory/index.js +55 -19
  187. package/dist/store/memory/index.js.map +1 -1
  188. package/dist/store/memory/memory.d.ts +3 -2
  189. package/dist/store/memory/memory.d.ts.map +1 -1
  190. package/dist/store/memory/memory.js +11 -2
  191. package/dist/store/memory/memory.js.map +1 -1
  192. package/dist/store/memory/operation-lock.d.ts +11 -0
  193. package/dist/store/memory/operation-lock.d.ts.map +1 -0
  194. package/dist/store/memory/operation-lock.js +94 -0
  195. package/dist/store/memory/operation-lock.js.map +1 -0
  196. package/dist/tools/builtins/bash.d.ts.map +1 -1
  197. package/dist/tools/builtins/bash.js +215 -59
  198. package/dist/tools/builtins/bash.js.map +1 -1
  199. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  200. package/dist/tools/builtins/computer-use.js +60 -10
  201. package/dist/tools/builtins/computer-use.js.map +1 -1
  202. package/dist/tools/builtins/glob.d.ts +2 -1
  203. package/dist/tools/builtins/glob.d.ts.map +1 -1
  204. package/dist/tools/builtins/glob.js +95 -103
  205. package/dist/tools/builtins/glob.js.map +1 -1
  206. package/dist/tools/builtins/grep.d.ts.map +1 -1
  207. package/dist/tools/builtins/grep.js +155 -111
  208. package/dist/tools/builtins/grep.js.map +1 -1
  209. package/dist/tools/builtins/ls.js +2 -2
  210. package/dist/tools/builtins/ls.js.map +1 -1
  211. package/dist/tools/builtins/run-code.d.ts +6 -0
  212. package/dist/tools/builtins/run-code.d.ts.map +1 -1
  213. package/dist/tools/builtins/run-code.js +15 -4
  214. package/dist/tools/builtins/run-code.js.map +1 -1
  215. package/dist/tools/builtins/search-tools.d.ts.map +1 -1
  216. package/dist/tools/builtins/search-tools.js +14 -2
  217. package/dist/tools/builtins/search-tools.js.map +1 -1
  218. package/dist/tools/defineTool.d.ts +2 -0
  219. package/dist/tools/defineTool.d.ts.map +1 -1
  220. package/dist/tools/defineTool.js +3 -0
  221. package/dist/tools/defineTool.js.map +1 -1
  222. package/dist/tools/memory/delete.d.ts +4 -0
  223. package/dist/tools/memory/delete.d.ts.map +1 -0
  224. package/dist/tools/memory/delete.js +26 -0
  225. package/dist/tools/memory/delete.js.map +1 -0
  226. package/dist/tools/memory/index.d.ts +2 -0
  227. package/dist/tools/memory/index.d.ts.map +1 -1
  228. package/dist/tools/memory/index.js +6 -0
  229. package/dist/tools/memory/index.js.map +1 -1
  230. package/dist/tools/memory/save.d.ts.map +1 -1
  231. package/dist/tools/memory/save.js +3 -2
  232. package/dist/tools/memory/save.js.map +1 -1
  233. package/dist/tools/memory/search.d.ts.map +1 -1
  234. package/dist/tools/memory/search.js +12 -5
  235. package/dist/tools/memory/search.js.map +1 -1
  236. package/dist/tools/memory/update.d.ts +4 -0
  237. package/dist/tools/memory/update.d.ts.map +1 -0
  238. package/dist/tools/memory/update.js +47 -0
  239. package/dist/tools/memory/update.js.map +1 -0
  240. package/dist/types/agent/scheduler.d.ts +5 -0
  241. package/dist/types/agent/scheduler.d.ts.map +1 -1
  242. package/dist/types/agent/task.d.ts +10 -0
  243. package/dist/types/agent/task.d.ts.map +1 -1
  244. package/dist/types/computer-use/index.d.ts +6 -0
  245. package/dist/types/computer-use/index.d.ts.map +1 -1
  246. package/dist/types/computer-use/index.js.map +1 -1
  247. package/dist/types/errors/catalog.js +1 -1
  248. package/dist/types/errors/catalog.js.map +1 -1
  249. package/dist/types/hitl/index.d.ts +11 -1
  250. package/dist/types/hitl/index.d.ts.map +1 -1
  251. package/dist/types/hitl/index.js.map +1 -1
  252. package/dist/types/memory/index.d.ts +14 -1
  253. package/dist/types/memory/index.d.ts.map +1 -1
  254. package/dist/types/project/entity.d.ts +1 -0
  255. package/dist/types/project/entity.d.ts.map +1 -1
  256. package/dist/types/provider/config.d.ts +2 -0
  257. package/dist/types/provider/config.d.ts.map +1 -1
  258. package/dist/types/provider/model.d.ts +4 -0
  259. package/dist/types/provider/model.d.ts.map +1 -1
  260. package/dist/types/run/answer-review.d.ts +2 -0
  261. package/dist/types/run/answer-review.d.ts.map +1 -1
  262. package/dist/types/run/events.d.ts +9 -0
  263. package/dist/types/run/events.d.ts.map +1 -1
  264. package/dist/types/run/events.js.map +1 -1
  265. package/dist/types/run/prepare-step.d.ts +19 -1
  266. package/dist/types/run/prepare-step.d.ts.map +1 -1
  267. package/dist/types/sandbox/index.d.ts +20 -0
  268. package/dist/types/sandbox/index.d.ts.map +1 -1
  269. package/dist/types/sandbox/index.js.map +1 -1
  270. package/dist/types/structured-output/index.d.ts +8 -2
  271. package/dist/types/structured-output/index.d.ts.map +1 -1
  272. package/dist/types/tool/index.d.ts +15 -0
  273. package/dist/types/tool/index.d.ts.map +1 -1
  274. package/dist/types/tool/index.js.map +1 -1
  275. package/dist/utils/json-snapshot.d.ts +3 -0
  276. package/dist/utils/json-snapshot.d.ts.map +1 -0
  277. package/dist/utils/json-snapshot.js +79 -0
  278. package/dist/utils/json-snapshot.js.map +1 -0
  279. package/package.json +8 -1
  280. package/src/bridge/a2a/mapper.ts +2 -0
  281. package/src/bridge/sse/mapper.ts +2 -0
  282. package/src/compaction/extractor.ts +21 -8
  283. package/src/compaction/manager.ts +11 -1
  284. package/src/compaction/verifier.ts +80 -18
  285. package/src/eval/harness-verification.ts +270 -0
  286. package/src/eval/index.ts +10 -0
  287. package/src/execution/code-runtime/json-value.ts +82 -0
  288. package/src/execution/code-runtime/worker-program.ts +239 -0
  289. package/src/execution/code-runtime/worker.ts +164 -111
  290. package/src/manager/agent/lifecycle.ts +340 -45
  291. package/src/manager/run/persistence.ts +7 -0
  292. package/src/provider/capabilities.ts +25 -1
  293. package/src/provider/fallback.ts +2 -0
  294. package/src/provider/token-budget.ts +52 -8
  295. package/src/public-runtime.ts +6 -1
  296. package/src/public-tools.ts +5 -1
  297. package/src/public-types.ts +1 -0
  298. package/src/registry/tool/execute.ts +17 -79
  299. package/src/run/command-gate.ts +61 -13
  300. package/src/run/index.ts +2 -0
  301. package/src/run/memory-promoter.ts +32 -40
  302. package/src/run/memory-recall.ts +254 -0
  303. package/src/run/reporter.ts +1 -0
  304. package/src/run/token-budget.ts +4 -0
  305. package/src/run/workspace-fingerprint.ts +17 -8
  306. package/src/runtime/query/checkpoint.ts +96 -2
  307. package/src/runtime/query/executor.ts +131 -28
  308. package/src/runtime/query/index.ts +81 -16
  309. package/src/runtime/query/iteration/index.ts +406 -53
  310. package/src/runtime/query/iteration/native-output.ts +35 -0
  311. package/src/runtime/query/iteration/phases/advisory.ts +21 -11
  312. package/src/runtime/query/iteration/phases/compaction.ts +36 -14
  313. package/src/runtime/query/iteration/phases/context.ts +11 -0
  314. package/src/runtime/query/iteration/phases/tool-review.ts +5 -1
  315. package/src/runtime/query/iteration/phases/working-memory.ts +23 -5
  316. package/src/runtime/query/iteration/stream-turn.ts +11 -5
  317. package/src/runtime/query/prompt.ts +21 -4
  318. package/src/runtime/query/steering.ts +19 -2
  319. package/src/runtime/query/tool-call-budget.ts +115 -0
  320. package/src/runtime/query/tooling.ts +6 -0
  321. package/src/sandbox/file-walk-program.ts +93 -0
  322. package/src/sandbox/file-walk.ts +463 -0
  323. package/src/sandbox/index.ts +2 -0
  324. package/src/sandbox/provider/local.ts +13 -0
  325. package/src/scheduler/completion-inbox.ts +29 -19
  326. package/src/scheduler/local.ts +1 -0
  327. package/src/session/handoff/capacity.ts +7 -3
  328. package/src/store/memory/disk.ts +52 -30
  329. package/src/store/memory/index.ts +75 -27
  330. package/src/store/memory/memory.ts +18 -6
  331. package/src/store/memory/operation-lock.ts +99 -0
  332. package/src/tools/builtins/bash.ts +230 -58
  333. package/src/tools/builtins/computer-use.ts +61 -7
  334. package/src/tools/builtins/glob.ts +104 -122
  335. package/src/tools/builtins/grep.ts +166 -132
  336. package/src/tools/builtins/ls.ts +2 -2
  337. package/src/tools/builtins/run-code.ts +24 -5
  338. package/src/tools/builtins/search-tools.ts +18 -3
  339. package/src/tools/defineTool.ts +5 -0
  340. package/src/tools/memory/delete.ts +29 -0
  341. package/src/tools/memory/index.ts +6 -0
  342. package/src/tools/memory/save.ts +4 -2
  343. package/src/tools/memory/search.ts +12 -5
  344. package/src/tools/memory/update.ts +50 -0
  345. package/src/types/agent/scheduler.ts +6 -0
  346. package/src/types/agent/task.ts +13 -0
  347. package/src/types/computer-use/index.ts +6 -0
  348. package/src/types/errors/catalog.ts +1 -1
  349. package/src/types/hitl/index.ts +11 -1
  350. package/src/types/memory/index.ts +16 -1
  351. package/src/types/project/entity.ts +1 -0
  352. package/src/types/provider/config.ts +2 -0
  353. package/src/types/provider/model.ts +4 -0
  354. package/src/types/run/answer-review.ts +2 -0
  355. package/src/types/run/events.ts +10 -0
  356. package/src/types/run/prepare-step.ts +19 -1
  357. package/src/types/sandbox/index.ts +21 -0
  358. package/src/types/structured-output/index.ts +15 -2
  359. package/src/types/tool/index.ts +16 -0
  360. package/src/utils/json-snapshot.ts +76 -0
@@ -49,6 +49,12 @@ export interface RunCodeToolOptions {
49
49
  readonly runtime?: CodeRuntime
50
50
  readonly timeoutMs?: number
51
51
  readonly maxOutputBytes?: number
52
+ /**
53
+ * What a successful `call()` resolves to. Default: `text` (ToolResult.output).
54
+ * `structured` returns `{ output, data? }`, preserving JSON tool data for
55
+ * local filtering. Failures still reject; authority and dispatch are unchanged.
56
+ */
57
+ readonly toolResultMode?: 'text' | 'structured'
52
58
  }
53
59
 
54
60
  const DEFAULT_TIMEOUT_MS = 30_000
@@ -59,8 +65,11 @@ export function buildRunCodeTool(options: RunCodeToolOptions = {}) {
59
65
 
60
66
  return defineTool({
61
67
  name: RUN_CODE_TOOL_NAME,
62
- description:
63
- "Runs a short JavaScript program that can call this run's own tools in a loop. Use it when the same tool would otherwise be called many times in a row — filtering, retrying, fanning out — and not for a single call.",
68
+ description: `Runs a short JavaScript program that can call this run's own tools in a loop. Use it when the same tool would otherwise be called many times in a row — filtering, retrying, fanning out — and not for a single call. ${
69
+ options.toolResultMode === 'structured'
70
+ ? 'Each successful call() returns { output: string, data?: JSON value }. Filter data locally and return only the needed result. Failed calls reject.'
71
+ : 'Each successful call() returns the tool output string. Failed calls reject.'
72
+ }`,
64
73
  inputSchema,
65
74
  category: 'custom',
66
75
  permissions: [],
@@ -108,9 +117,19 @@ export function buildRunCodeTool(options: RunCodeToolOptions = {}) {
108
117
  signal: operation.signal,
109
118
  runtimeToolCallId: operation.runtimeToolCallId,
110
119
  })
111
- return toolResult.success
112
- ? { ok: true, value: toolResult.output }
113
- : { ok: false, error: toolResult.error ?? 'the tool failed' }
120
+ if (!toolResult.success) {
121
+ return { ok: false, error: toolResult.error ?? 'the tool failed' }
122
+ }
123
+ return {
124
+ ok: true,
125
+ value:
126
+ options.toolResultMode === 'structured'
127
+ ? {
128
+ output: toolResult.output,
129
+ ...(toolResult.data !== undefined ? { data: toolResult.data } : {}),
130
+ }
131
+ : toolResult.output,
132
+ }
114
133
  } catch (err) {
115
134
  return {
116
135
  ok: false,
@@ -38,8 +38,7 @@ export const SearchToolsTool = defineTool({
38
38
  }
39
39
  }
40
40
 
41
- const allowed =
42
- context.allowedTools && context.allowedTools.length > 0 ? new Set(context.allowedTools) : null
41
+ const allowed = context.allowedTools !== undefined ? new Set(context.allowedTools) : null
43
42
  // `searchDeferred` returns a ranked list (score-descending), so slicing
44
43
  // the head is a true top-k activation, not an arbitrary subset.
45
44
  const ranked = context.toolRegistry
@@ -47,9 +46,25 @@ export const SearchToolsTool = defineTool({
47
46
  .filter((tool) => !allowed || allowed.has(tool.name))
48
47
 
49
48
  if (ranked.length === 0) {
49
+ const active = context.toolRegistry
50
+ .searchActive?.(input.query)
51
+ .filter(
52
+ (tool) =>
53
+ (!allowed || allowed.has(tool.name)) &&
54
+ context.toolRegistry?.getAvailability(tool.name) === 'active',
55
+ )
56
+ const activeReceipt =
57
+ active === undefined
58
+ ? 'This registry cannot search active tools.'
59
+ : active.length === 0
60
+ ? 'No matching active tools were found.'
61
+ : `Already active matching tools (up to ${ACTIVATION_TOP_K}):\n${active
62
+ .slice(0, ACTIVATION_TOP_K)
63
+ .map((tool) => `- ${tool.name}`)
64
+ .join('\n')}`
50
65
  return {
51
66
  success: true,
52
- output: `No deferred tools matching "${input.query}". All matching tools are already active.`,
67
+ output: `No deferred tools matching "${input.query}". ${activeReceipt}`,
53
68
  }
54
69
  }
55
70
 
@@ -20,6 +20,8 @@ export interface DefineToolOptions<S extends z.ZodType> {
20
20
  readOnly: boolean
21
21
  destructive: boolean | ((input: z.infer<S>) => boolean)
22
22
  concurrencySafe: boolean
23
+ /** Batch ordering boundary; see {@link ToolDefinition.executionBarrier}. */
24
+ executionBarrier?: boolean
23
25
  tier?: string
24
26
  /**
25
27
  * How this tool's call and result should be shown; see
@@ -81,6 +83,9 @@ export function defineTool<S extends z.ZodType>(
81
83
  ...(options.presentResult ? { presentResult: options.presentResult } : {}),
82
84
  ...(options.outputSchema !== undefined ? { outputSchema: options.outputSchema } : {}),
83
85
  ...(options.terminal !== undefined ? { terminal: options.terminal } : {}),
86
+ ...(options.executionBarrier !== undefined
87
+ ? { executionBarrier: options.executionBarrier }
88
+ : {}),
84
89
  category: options.category,
85
90
  permissions: options.permissions,
86
91
  isReadOnly: () => options.readOnly,
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod'
2
+ import type { MemoryStore } from '../../types/memory/index.js'
3
+ import type { ToolDefinition } from '../../types/tool/index.js'
4
+ import { asMemoryId } from '../../utils/id.js'
5
+ import { defineTool } from '../defineTool.js'
6
+
7
+ export function buildDeleteMemoryTool(store: MemoryStore): ToolDefinition {
8
+ return defineTool({
9
+ name: 'delete_memory',
10
+ description:
11
+ 'Permanently delete a stored memory by ID. Use update_memory with status archived when the record should remain available for inspection. Deletion does not erase past conversation transcripts.',
12
+ inputSchema: z.object({
13
+ id: z.string().describe('Memory ID to permanently delete'),
14
+ }),
15
+ category: 'custom',
16
+ permissions: [],
17
+ readOnly: false,
18
+ destructive: true,
19
+ concurrencySafe: true,
20
+ async execute({ id }) {
21
+ const removed = await store.delete(asMemoryId(id))
22
+ return {
23
+ success: removed,
24
+ output: removed ? `Memory deleted: ${id}.` : `Memory ${id} not found.`,
25
+ ...(removed ? {} : { error: 'Memory not found' }),
26
+ }
27
+ },
28
+ })
29
+ }
@@ -1,8 +1,10 @@
1
1
  import type { MemoryIndex, MemoryStore } from '../../types/memory/index.js'
2
2
  import type { ToolDefinition } from '../../types/tool/index.js'
3
+ import { buildDeleteMemoryTool } from './delete.js'
3
4
  import { buildReadMemoryTool } from './read.js'
4
5
  import { buildSaveMemoryTool } from './save.js'
5
6
  import { buildSearchMemoryTool, buildStoreSearchMemoryTool } from './search.js'
7
+ import { buildUpdateMemoryTool } from './update.js'
6
8
 
7
9
  /**
8
10
  * Build memory tools over one authoritative store.
@@ -28,9 +30,13 @@ export function buildMemoryTools(store: MemoryStore, index?: MemoryIndex): ToolD
28
30
  index ? buildSearchMemoryTool(index) : buildStoreSearchMemoryTool(store),
29
31
  buildReadMemoryTool(store),
30
32
  buildSaveMemoryTool(store),
33
+ buildUpdateMemoryTool(store),
34
+ buildDeleteMemoryTool(store),
31
35
  ]
32
36
  }
33
37
 
34
38
  export { buildSearchMemoryTool } from './search.js'
35
39
  export { buildReadMemoryTool } from './read.js'
36
40
  export { buildSaveMemoryTool } from './save.js'
41
+ export { buildUpdateMemoryTool } from './update.js'
42
+ export { buildDeleteMemoryTool } from './delete.js'
@@ -6,7 +6,8 @@ import { defineTool } from '../defineTool.js'
6
6
  export function buildSaveMemoryTool(store: MemoryStore): ToolDefinition {
7
7
  return defineTool({
8
8
  name: 'save_memory',
9
- description: 'Save a new memory with title, summary, and full content for future reference.',
9
+ description:
10
+ 'Save a new historical claim for future reference. Include the actual useful fact and its evidence in the summary and content. For corrections to an existing record use update_memory instead of creating contradictory duplicates.',
10
11
  inputSchema: z.object({
11
12
  title: z.string().min(1).describe('Short descriptive title'),
12
13
  summary: z.string().min(1).describe('Brief summary (1-2 sentences)'),
@@ -18,12 +19,13 @@ export function buildSaveMemoryTool(store: MemoryStore): ToolDefinition {
18
19
  readOnly: false,
19
20
  destructive: false,
20
21
  concurrencySafe: true,
21
- async execute({ title, summary, content, tags }) {
22
+ async execute({ title, summary, content, tags }, context) {
22
23
  const { entry } = await store.create({
23
24
  title,
24
25
  summary,
25
26
  content,
26
27
  tags,
28
+ metadata: { source: 'agent-memory', runId: context.runId },
27
29
  })
28
30
 
29
31
  return {
@@ -14,19 +14,26 @@ function defineSearchMemoryTool(search: SearchMemory): ToolDefinition {
14
14
  return defineTool({
15
15
  name: 'search_memory',
16
16
  description:
17
- 'Search stored memories by query, tags, or status. Returns titles and summaries only — use read_memory for full content.',
17
+ 'Search active stored memories by relevant words or tags. The built-in store ranks matches in titles, summaries and full content. Returns titles and summaries; use read_memory for evidence. Set status to archived to inspect obsolete records.',
18
18
  inputSchema: z.object({
19
- query: z.string().optional().describe('Search query to match against titles and summaries'),
19
+ query: z.string().optional().describe('Relevant words or identifiers to search'),
20
20
  tags: z.array(z.string()).optional().describe('Filter by tags (all must match)'),
21
- limit: z.number().positive().default(10).describe('Maximum results to return'),
21
+ status: z.enum(['active', 'archived']).default('active'),
22
+ limit: z
23
+ .number()
24
+ .int()
25
+ .min(1)
26
+ .max(50)
27
+ .default(10)
28
+ .describe('Maximum results to return (1–50)'),
22
29
  }),
23
30
  category: 'analysis',
24
31
  permissions: [],
25
32
  readOnly: true,
26
33
  destructive: false,
27
34
  concurrencySafe: true,
28
- async execute({ query, tags, limit }) {
29
- const result = await search({ query, tags, limit })
35
+ async execute({ query, tags, status, limit }) {
36
+ const result = await search({ query, tags, status, limit })
30
37
 
31
38
  if (result.entries.length === 0) {
32
39
  return {
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod'
2
+ import type { MemoryStore } from '../../types/memory/index.js'
3
+ import type { ToolDefinition } from '../../types/tool/index.js'
4
+ import { asMemoryId } from '../../utils/id.js'
5
+ import { defineTool } from '../defineTool.js'
6
+
7
+ export function buildUpdateMemoryTool(store: MemoryStore): ToolDefinition {
8
+ return defineTool({
9
+ name: 'update_memory',
10
+ description:
11
+ 'Correct an existing memory in place, or archive an obsolete claim so it is no longer recalled. Use the ID from search_memory; current evidence should determine corrections.',
12
+ inputSchema: z.object({
13
+ id: z.string().describe('Memory ID to correct or archive'),
14
+ title: z.string().min(1).optional(),
15
+ summary: z.string().min(1).optional(),
16
+ content: z.string().min(1).optional(),
17
+ tags: z.array(z.string()).optional(),
18
+ status: z.enum(['active', 'archived']).optional(),
19
+ }),
20
+ category: 'custom',
21
+ permissions: [],
22
+ readOnly: false,
23
+ destructive: false,
24
+ concurrencySafe: true,
25
+ async execute({ id, ...updates }) {
26
+ if (Object.values(updates).every((value) => value === undefined)) {
27
+ return {
28
+ success: false,
29
+ output: 'Provide a correction or status to update.',
30
+ error: 'No memory update supplied',
31
+ }
32
+ }
33
+ const memoryId = asMemoryId(id)
34
+ // Patch only requested fields in one store operation. A read/merge of
35
+ // provenance here would overwrite metadata from a concurrent writer.
36
+ const entry = await store.update(memoryId, updates)
37
+ if (!entry)
38
+ return {
39
+ success: false,
40
+ output: `Memory ${id} no longer exists.`,
41
+ error: 'Memory not found',
42
+ }
43
+ return {
44
+ success: true,
45
+ output: `Memory updated: ${id} — ${entry.title} (${entry.status}).`,
46
+ data: { id, status: entry.status },
47
+ }
48
+ },
49
+ })
50
+ }
@@ -29,6 +29,12 @@ export interface TaskHandle {
29
29
  export type SiblingFailurePolicy = 'continue' | 'cancel-siblings'
30
30
 
31
31
  export interface CreateTaskOptions {
32
+ /**
33
+ * Revalidate host authority at actual admission, including after a capacity wait.
34
+ * Queue retries may invoke this more than once; checks must tolerate repeated calls.
35
+ */
36
+ readonly beforeStart?: () => Promise<void>
37
+
32
38
  /**
33
39
  * Observe events from this one delegated run when the scheduler can expose
34
40
  * them.
@@ -122,6 +122,7 @@ export interface AgentTask {
122
122
  agentId: string
123
123
  agent: Agent<BaseAgentConfig, BaseAgentResult>
124
124
  childAbortController: AbortController
125
+ /** While pending admission this is the submitting authority; admitted tasks receive child scope. */
125
126
  context: AgentTaskContext
126
127
  state: AgentTaskState
127
128
  result?: BaseAgentResult
@@ -142,6 +143,12 @@ export interface AgentTask {
142
143
  * WorkspaceRef triple atomically on every spawn.
143
144
  */
144
145
  export interface SendMessageOptions {
146
+ /**
147
+ * Revalidate host authority before admission, including after a capacity wait.
148
+ * Queue retries may invoke this more than once; checks must tolerate repeated calls.
149
+ */
150
+ readonly beforeStart?: () => Promise<void>
151
+
145
152
  /** See {@link import('./scheduler.js').CreateTaskOptions.toolScope}. Deny-only. */
146
153
  readonly toolScope?: { readonly deny: readonly string[] }
147
154
  /** See {@link import('./scheduler.js').CreateTaskOptions.personaOverride}. */
@@ -179,6 +186,12 @@ export interface SendMessageOptions {
179
186
  }
180
187
 
181
188
  export interface AgentManagerConfig {
189
+ /** Reject a full parent immediately (default), or retain bounded pending task handles. */
190
+ capacityBehavior?: 'reject' | 'queue'
191
+
192
+ /** Maximum tasks awaiting admission across this manager. Defaults to 128. */
193
+ maxPendingTasks?: number
194
+
182
195
  maxDepth: number
183
196
 
184
197
  evictionMs: number
@@ -30,6 +30,12 @@ export interface ComputerUseCapabilities {
30
30
  readonly keyboard: boolean
31
31
  readonly cursorPosition: boolean
32
32
  readonly clipboard: boolean
33
+ /** Exact action subset when known. Refines the broad flags; absent retains their legacy interpretation. */
34
+ readonly supportedActions?: readonly ComputerUseAction['type'][]
35
+ /** Supported click buttons; absent leaves button admission to the host. */
36
+ readonly mouseClickButtons?: readonly MouseButton[]
37
+ /** Supported drag buttons; absent leaves button admission to the host. */
38
+ readonly mouseDragButtons?: readonly MouseButton[]
33
39
  /**
34
40
  * Why every flag above is false, when a host loaded but the desktop did
35
41
  * not answer — a WSL process with PowerShell and no interactive Windows
@@ -157,7 +157,7 @@ export const DEFAULT_ERROR_RULES: readonly ErrorCatalogRule[] = [
157
157
  id: 'provider.rate_limit',
158
158
  when: (facts) => facts.code === 'rate_limit' || facts.status === 429,
159
159
  message: 'The provider is rate limiting this run.',
160
- hint: 'Automatic retries with backoff have already been exhausted. Lower concurrency, or wait for the quota window to reset before resuming.',
160
+ hint: 'Respect the provider retry delay when reported. Lower concurrency, or wait for the quota window to reset before resuming.',
161
161
  },
162
162
  {
163
163
  id: 'provider.context_overflow',
@@ -2,7 +2,7 @@ import type { WorkingStateSnapshot } from '../../compaction/wire.js'
2
2
  import type { SerializedSpanContext } from '../../telemetry/attributes.js'
3
3
  import type { CostInfo, TokenUsage } from '../common/index.js'
4
4
  import type { CheckpointId, PlanId, RunId } from '../ids/index.js'
5
- import type { Message } from '../message/index.js'
5
+ import type { Message, UserMessage } from '../message/index.js'
6
6
  import type { PlanStatus } from '../plan/index.js'
7
7
  import type { TokenBudgetBinding } from '../run/token-budget-store.js'
8
8
 
@@ -212,6 +212,16 @@ export interface IterationCheckpoint {
212
212
  runId: RunId
213
213
  iteration: number
214
214
  messages: Message[]
215
+ /**
216
+ * Current operator/goal/steering text and provenance, independent of
217
+ * compacted history. Attachments are not duplicated here. Older
218
+ * checkpoints omit this field and use surviving history on resume.
219
+ */
220
+ latestUserMessage?: UserMessage
221
+ /** Structured host-review rejections consumed at this checkpoint, independent of compacted messages. */
222
+ structuredReviewAttempts?: number
223
+ /** Native structured-output corrections consumed independently of message history. */
224
+ nativeStructuredAttempts?: number
215
225
  tokenUsage: TokenUsage
216
226
  costInfo: CostInfo
217
227
  /**
@@ -31,11 +31,19 @@ export interface MemoryContent {
31
31
  readonly metadata?: Record<string, unknown>
32
32
  }
33
33
 
34
+ /** Metadata and body observed together at one store read boundary. */
35
+ export interface MemoryRecord {
36
+ readonly entry: MemoryIndexEntry
37
+ readonly content: MemoryContent
38
+ }
39
+
34
40
  export interface MemorySearchParams {
35
41
  readonly query?: string
36
42
  readonly tags?: string[]
37
43
  readonly status?: MemoryStatus
38
44
  readonly limit?: number
45
+ /** Match at least one exact normalized word token before limiting results. Empty means no constraint. */
46
+ readonly requiredIdentifiers?: readonly string[]
39
47
  }
40
48
 
41
49
  export interface MemorySearchResult {
@@ -52,10 +60,17 @@ export interface CreateMemoryParams {
52
60
  readonly metadata?: Record<string, unknown>
53
61
  }
54
62
 
63
+ /** Change a memory's content or explicitly archive/reactivate it. */
64
+ export interface UpdateMemoryParams extends Partial<CreateMemoryParams> {
65
+ readonly status?: MemoryStatus
66
+ }
67
+
55
68
  export interface MemoryStore {
56
69
  create(params: CreateMemoryParams): Promise<{ entry: MemoryIndexEntry; content: MemoryContent }>
57
70
  get(id: MemoryId): Promise<MemoryContent | undefined>
58
- update(id: MemoryId, updates: Partial<CreateMemoryParams>): Promise<MemoryIndexEntry | undefined>
71
+ /** Current metadata/body snapshot; supports rechecking status after search. */
72
+ getRecord?(id: MemoryId): Promise<MemoryRecord | undefined>
73
+ update(id: MemoryId, updates: UpdateMemoryParams): Promise<MemoryIndexEntry | undefined>
59
74
  delete(id: MemoryId): Promise<boolean>
60
75
  list(params?: MemorySearchParams): Promise<MemorySearchResult>
61
76
  }
@@ -18,6 +18,7 @@ import type { ProjectId } from '../session/ids.js'
18
18
  */
19
19
  export interface ProjectConfig {
20
20
  maxDelegationDepth: number
21
+ /** Maximum pending or active direct delegations; completed history does not consume capacity. */
21
22
  maxDelegationWidth: number
22
23
  maxInterventionDepth: number
23
24
  sharedMemoryStores?: readonly MemoryStoreRef[]
@@ -121,6 +121,8 @@ export interface MockProviderConfig extends MockScript {
121
121
  * degradation is loud instead of silent.
122
122
  */
123
123
  export interface ProviderCapabilities {
124
+ /** Native JSON Schema response-format mapping. Absent means unsupported. */
125
+ supportsNativeStructuredOutput?: boolean
124
126
  supportsTools: boolean
125
127
  supportsStreaming: boolean
126
128
  supportsFunctionCalling: boolean
@@ -14,6 +14,10 @@ export interface ModelInfo {
14
14
  * the answer; it must not be read as text-only.
15
15
  */
16
16
  inputModalities?: readonly ModelInputModality[]
17
+ /** Exact selectable effort levels for this model and route. Absent means unknown; [] means unsupported. */
18
+ reasoningEffortLevels?: readonly import('./chat.js').ReasoningEffort[]
19
+ /** Published default, when established; must belong to reasoningEffortLevels when both are present. */
20
+ reasoningEffortDefault?: import('./chat.js').ReasoningEffort
17
21
  /**
18
22
  * Tokens the model's context holds, when the driver knows.
19
23
  *
@@ -29,6 +29,8 @@ export type AnswerReview =
29
29
  export interface AnswerReviewContext {
30
30
  readonly runId: RunId
31
31
  readonly iteration: number
32
+ /** Run cancellation; reviewers should forward it to verification operations. */
33
+ readonly signal?: AbortSignal
32
34
  /** The full history, so a reviewer can see how the answer was reached. */
33
35
  readonly messages: readonly Message[]
34
36
  }
@@ -101,6 +101,16 @@ interface RunEventEnvelope {
101
101
  }
102
102
 
103
103
  type CoreRunEvent =
104
+ | {
105
+ type: 'tool_calls_admitted'
106
+ runId: RunId
107
+ kind: 'initialize' | 'batch' | 'nested' | 'retry'
108
+ /** Newly reserved attempts; zero only for ledger initialization. */
109
+ count: number
110
+ /** Cumulative reserved attempts, including abandoned reservations. */
111
+ used: number
112
+ limit: number
113
+ }
104
114
  | { type: 'run_started'; runId: RunId; systemPrompt?: string }
105
115
  | { type: 'iteration_started'; runId: RunId; iteration: number }
106
116
  /**
@@ -1,5 +1,5 @@
1
1
  import type { RunId } from '../ids/index.js'
2
- import type { Message } from '../message/index.js'
2
+ import type { Message, UserMessage } from '../message/index.js'
3
3
  import type { ToolChoice } from '../provider/chat.js'
4
4
  import type { Skill } from '../skills/index.js'
5
5
  import type { StepResult } from './step.js'
@@ -21,6 +21,24 @@ export interface PrepareStepContext {
21
21
  readonly stepNumber: number
22
22
  /** Full history as it stands, so a decision can read what happened. */
23
23
  readonly messages: readonly Message[]
24
+ /**
25
+ * Latest operator, goal-round, or steering input accepted by this run,
26
+ * retained even when compaction removes it from `messages`. Project
27
+ * instructions and task-completion context do not replace operator intent.
28
+ */
29
+ readonly latestUserMessage?: UserMessage
30
+ /** The run's cancellation signal, for bounded asynchronous preparation. */
31
+ readonly signal?: AbortSignal
32
+ /**
33
+ * Estimated room for additional step context after existing messages,
34
+ * earlier stages' system/skills, and a response reserve. Recomputed for
35
+ * each stage and its selected model; not a billing limit or fit guarantee.
36
+ * `beforeStep` observes its existing boundary before compaction runs.
37
+ */
38
+ readonly contextBudget?: {
39
+ readonly remainingTokens: number
40
+ readonly windowTokens: number
41
+ }
24
42
  /** Every completed step, in order. */
25
43
  readonly steps: readonly StepResult[]
26
44
 
@@ -181,6 +181,20 @@ export interface SandboxFileEntry {
181
181
  readonly size: number
182
182
  }
183
183
 
184
+ /** A bounded search; patterns and depth are relative to the requested root. */
185
+ export interface SandboxWalkFilesOptions {
186
+ readonly pattern?: string
187
+ readonly signal?: AbortSignal
188
+ /** Direct children have depth 1. Omitted means no additional depth bound. */
189
+ readonly maxDepth?: number
190
+ /** Positive safe integer bounding emitted matching files. */
191
+ readonly maxEntries: number
192
+ /** Positive safe integer bounding examined directory entries; defaults to 20,000. */
193
+ readonly maxVisitedEntries?: number
194
+ /** Match hidden names through wildcards; explicit dotfile patterns always work. Defaults to false. */
195
+ readonly includeHidden?: boolean
196
+ }
197
+
184
198
  // ---------------------------------------------------------------------------
185
199
  // Sandbox interface — the core abstraction
186
200
  // ---------------------------------------------------------------------------
@@ -294,6 +308,13 @@ export interface Sandbox {
294
308
  * MAY throw for other I/O failures.
295
309
  */
296
310
  listFiles(rootPath: string): Promise<readonly SandboxFileEntry[]>
311
+ /**
312
+ * Lazily enumerate regular files as absolute paths, without following symlinks.
313
+ * Cancellation and iterator return stop traversal. Exceeding the examined-entry
314
+ * budget throws an error with code `ERR_FILE_WALK_LIMIT`; it is not an empty or
315
+ * complete listing. Hosts requiring bounded search must refuse an absent method.
316
+ */
317
+ walkFiles?(rootPath: string, options: SandboxWalkFilesOptions): AsyncIterable<SandboxFileEntry>
297
318
  /**
298
319
  * Release every resource owned by this sandbox.
299
320
  *
@@ -1,10 +1,10 @@
1
1
  import type { z } from 'zod'
2
2
 
3
3
  /**
4
- * Configuration for structured output via tool constraint.
4
+ * Configuration for validated output via tool constraint or native JSON Schema.
5
5
  *
6
6
  * This configuration allows an agent to produce validated, typed output by
7
- * presenting the output schema as a special tool that the model must call.
7
+ * presenting the output schema as a tool by default, or as a native response format.
8
8
  */
9
9
  export interface StructuredOutputConfig<TSchema extends z.ZodType = z.ZodType> {
10
10
  /**
@@ -13,6 +13,9 @@ export interface StructuredOutputConfig<TSchema extends z.ZodType = z.ZodType> {
13
13
  */
14
14
  schema: TSchema
15
15
 
16
+ /** Default tool constraint, or native JSON schema on an explicitly capable driver. */
17
+ mode?: 'tool' | 'native'
18
+
16
19
  /**
17
20
  * Turns spent re-prompting when the model answers in prose or fails
18
21
  * validation. Defaults to {@link DEFAULT_STRUCTURED_OUTPUT_RETRIES}.
@@ -21,6 +24,16 @@ export interface StructuredOutputConfig<TSchema extends z.ZodType = z.ZodType> {
21
24
  * than iterating against `maxIterations`.
22
25
  */
23
26
  maxRetries?: number
27
+
28
+ /** Review the JSON-decoded result before settlement. Narrow the value before use: serialization may change schema output types. Exceptions fail the run; cancellation is propagated. */
29
+ review?: (
30
+ output: unknown,
31
+ context: import('../run/answer-review.js').AnswerReviewContext,
32
+ ) =>
33
+ | import('../run/answer-review.js').AnswerReview
34
+ | Promise<import('../run/answer-review.js').AnswerReview>
35
+ /** Corrections allowed after host rejection, separate from schema retries. Default 3; zero allows no correction. */
36
+ maxReviews?: number
24
37
  }
25
38
 
26
39
  /**
@@ -14,6 +14,8 @@ import type { ToolPresentation } from './presentation.js'
14
14
 
15
15
  export interface ToolRegistryRef {
16
16
  searchDeferred(query: string): ToolDefinition[]
17
+ /** Ranked active matches, when this registry supports active-tool discovery. */
18
+ searchActive?(query: string): ToolDefinition[]
17
19
  activate(names: string[]): void
18
20
  getAvailability(name: string): ToolAvailability
19
21
  }
@@ -633,6 +635,18 @@ export interface ToolDefinition<TInput = unknown> extends ToolPresentation<TInpu
633
635
  isDestructive?(input: TInput): boolean
634
636
  isConcurrencySafe?(input: TInput): boolean
635
637
 
638
+ /**
639
+ * Opt-in ordering boundary in a direct model tool-call batch. Earlier
640
+ * calls settle before this call starts; later calls wait for this call
641
+ * to settle (including failed results). Defaults to false. Independent
642
+ * calls between barriers retain their existing concurrency-safe behavior.
643
+ * Nested dispatch is owned by its enclosing call, not separately queued;
644
+ * mark the enclosing tool as a barrier to isolate its nested operations.
645
+ * Deadlines still abandon uncooperative tools: settlement does not prove
646
+ * their external effects have stopped, and does not imply success.
647
+ */
648
+ executionBarrier?: boolean
649
+
636
650
  /**
637
651
  * Where this tool came from, when it did not come from here.
638
652
  *
@@ -763,6 +777,8 @@ export interface ToolRegistryContract {
763
777
  suspendAll(): void
764
778
  hasSuspended(): boolean
765
779
  searchDeferred(query: string): ToolDefinition[]
780
+ /** Ranked active matches, when this registry supports active-tool discovery. */
781
+ searchActive?(query: string): ToolDefinition[]
766
782
  getCallableTools(toolNames?: string[]): ToolDefinition[]
767
783
 
768
784
  /**