@namzu/sdk 30.2.0 → 31.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 (712) hide show
  1. package/CHANGELOG.md +556 -0
  2. package/README.md +43 -2
  3. package/dist/advisory/executor.d.ts +2 -1
  4. package/dist/advisory/executor.d.ts.map +1 -1
  5. package/dist/advisory/executor.js +4 -1
  6. package/dist/advisory/executor.js.map +1 -1
  7. package/dist/agents/ReactiveAgent.d.ts.map +1 -1
  8. package/dist/agents/ReactiveAgent.js +12 -0
  9. package/dist/agents/ReactiveAgent.js.map +1 -1
  10. package/dist/agents/RouterAgent.d.ts.map +1 -1
  11. package/dist/agents/RouterAgent.js +21 -3
  12. package/dist/agents/RouterAgent.js.map +1 -1
  13. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  14. package/dist/agents/SupervisorAgent.js +34 -11
  15. package/dist/agents/SupervisorAgent.js.map +1 -1
  16. package/dist/agents/runAgent.d.ts +12 -0
  17. package/dist/agents/runAgent.d.ts.map +1 -1
  18. package/dist/agents/runAgent.js +26 -2
  19. package/dist/agents/runAgent.js.map +1 -1
  20. package/dist/authorization/command-line.d.ts +81 -0
  21. package/dist/authorization/command-line.d.ts.map +1 -0
  22. package/dist/authorization/command-line.js +347 -0
  23. package/dist/authorization/command-line.js.map +1 -0
  24. package/dist/authorization/rules.d.ts.map +1 -1
  25. package/dist/authorization/rules.js +22 -1
  26. package/dist/authorization/rules.js.map +1 -1
  27. package/dist/bridge/a2a/client.d.ts +23 -5
  28. package/dist/bridge/a2a/client.d.ts.map +1 -1
  29. package/dist/bridge/a2a/client.js +320 -73
  30. package/dist/bridge/a2a/client.js.map +1 -1
  31. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  32. package/dist/bridge/a2a/mapper.js +4 -0
  33. package/dist/bridge/a2a/mapper.js.map +1 -1
  34. package/dist/bridge/acp/server.d.ts +13 -1
  35. package/dist/bridge/acp/server.d.ts.map +1 -1
  36. package/dist/bridge/acp/server.js +150 -44
  37. package/dist/bridge/acp/server.js.map +1 -1
  38. package/dist/bridge/mcp/connector/adapter.d.ts +3 -2
  39. package/dist/bridge/mcp/connector/adapter.d.ts.map +1 -1
  40. package/dist/bridge/mcp/connector/adapter.js +17 -21
  41. package/dist/bridge/mcp/connector/adapter.js.map +1 -1
  42. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  43. package/dist/bridge/sse/mapper.js +3 -0
  44. package/dist/bridge/sse/mapper.js.map +1 -1
  45. package/dist/compaction/dangling.d.ts +29 -2
  46. package/dist/compaction/dangling.d.ts.map +1 -1
  47. package/dist/compaction/dangling.js +172 -35
  48. package/dist/compaction/dangling.js.map +1 -1
  49. package/dist/compaction/index.d.ts +3 -2
  50. package/dist/compaction/index.d.ts.map +1 -1
  51. package/dist/compaction/index.js +1 -1
  52. package/dist/compaction/index.js.map +1 -1
  53. package/dist/compaction/manual.d.ts +11 -1
  54. package/dist/compaction/manual.d.ts.map +1 -1
  55. package/dist/compaction/manual.js +89 -14
  56. package/dist/compaction/manual.js.map +1 -1
  57. package/dist/compaction/plan.d.ts +19 -6
  58. package/dist/compaction/plan.d.ts.map +1 -1
  59. package/dist/compaction/plan.js +18 -4
  60. package/dist/compaction/plan.js.map +1 -1
  61. package/dist/compaction/retention.d.ts +10 -7
  62. package/dist/compaction/retention.d.ts.map +1 -1
  63. package/dist/compaction/retention.js +26 -8
  64. package/dist/compaction/retention.js.map +1 -1
  65. package/dist/compaction/summary.d.ts +4 -4
  66. package/dist/compaction/summary.js +4 -4
  67. package/dist/compaction/verifier.d.ts +19 -1
  68. package/dist/compaction/verifier.d.ts.map +1 -1
  69. package/dist/compaction/verifier.js +20 -1
  70. package/dist/compaction/verifier.js.map +1 -1
  71. package/dist/config/runtime.d.ts +6 -6
  72. package/dist/connector/BaseConnector.d.ts +6 -4
  73. package/dist/connector/BaseConnector.d.ts.map +1 -1
  74. package/dist/connector/BaseConnector.js +8 -2
  75. package/dist/connector/BaseConnector.js.map +1 -1
  76. package/dist/connector/builtins/http.d.ts +16 -4
  77. package/dist/connector/builtins/http.d.ts.map +1 -1
  78. package/dist/connector/builtins/http.js +177 -44
  79. package/dist/connector/builtins/http.js.map +1 -1
  80. package/dist/connector/builtins/webhook.d.ts +15 -4
  81. package/dist/connector/builtins/webhook.d.ts.map +1 -1
  82. package/dist/connector/builtins/webhook.js +165 -45
  83. package/dist/connector/builtins/webhook.js.map +1 -1
  84. package/dist/connector/execution-contract.d.ts +11 -0
  85. package/dist/connector/execution-contract.d.ts.map +1 -0
  86. package/dist/connector/execution-contract.js +14 -0
  87. package/dist/connector/execution-contract.js.map +1 -0
  88. package/dist/connector/http-operation.d.ts +48 -0
  89. package/dist/connector/http-operation.d.ts.map +1 -0
  90. package/dist/connector/http-operation.js +205 -0
  91. package/dist/connector/http-operation.js.map +1 -0
  92. package/dist/connector/mcp/adapter.d.ts.map +1 -1
  93. package/dist/connector/mcp/adapter.js +8 -3
  94. package/dist/connector/mcp/adapter.js.map +1 -1
  95. package/dist/connector/mcp/client.d.ts +14 -8
  96. package/dist/connector/mcp/client.d.ts.map +1 -1
  97. package/dist/connector/mcp/client.js +160 -44
  98. package/dist/connector/mcp/client.js.map +1 -1
  99. package/dist/connector/mcp/http-sse.d.ts +8 -2
  100. package/dist/connector/mcp/http-sse.d.ts.map +1 -1
  101. package/dist/connector/mcp/http-sse.js +70 -17
  102. package/dist/connector/mcp/http-sse.js.map +1 -1
  103. package/dist/connector/mcp/prompt-adapter.d.ts.map +1 -1
  104. package/dist/connector/mcp/prompt-adapter.js +9 -2
  105. package/dist/connector/mcp/prompt-adapter.js.map +1 -1
  106. package/dist/connector/mcp/stdio.d.ts +2 -2
  107. package/dist/connector/mcp/stdio.d.ts.map +1 -1
  108. package/dist/connector/mcp/stdio.js +14 -50
  109. package/dist/connector/mcp/stdio.js.map +1 -1
  110. package/dist/connector/mcp/streamable-http.d.ts +7 -2
  111. package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
  112. package/dist/connector/mcp/streamable-http.js +66 -18
  113. package/dist/connector/mcp/streamable-http.js.map +1 -1
  114. package/dist/connector/tools/adapter.d.ts +2 -2
  115. package/dist/connector/tools/adapter.d.ts.map +1 -1
  116. package/dist/connector/tools/adapter.js +23 -14
  117. package/dist/connector/tools/adapter.js.map +1 -1
  118. package/dist/connector/tools/definitions.d.ts.map +1 -1
  119. package/dist/connector/tools/definitions.js +5 -2
  120. package/dist/connector/tools/definitions.js.map +1 -1
  121. package/dist/connector/tools/result.d.ts +4 -0
  122. package/dist/connector/tools/result.d.ts.map +1 -0
  123. package/dist/connector/tools/result.js +20 -0
  124. package/dist/connector/tools/result.js.map +1 -0
  125. package/dist/connector/web/guarded-fetch.d.ts +4 -2
  126. package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
  127. package/dist/connector/web/guarded-fetch.js +157 -43
  128. package/dist/connector/web/guarded-fetch.js.map +1 -1
  129. package/dist/constants/sandbox/index.d.ts +3 -2
  130. package/dist/constants/sandbox/index.d.ts.map +1 -1
  131. package/dist/constants/sandbox/index.js +3 -2
  132. package/dist/constants/sandbox/index.js.map +1 -1
  133. package/dist/contracts/api.d.ts +2 -0
  134. package/dist/contracts/api.d.ts.map +1 -1
  135. package/dist/contracts/schemas.d.ts +38 -12
  136. package/dist/contracts/schemas.d.ts.map +1 -1
  137. package/dist/contracts/schemas.js +7 -0
  138. package/dist/contracts/schemas.js.map +1 -1
  139. package/dist/directory/derive-supervisor.d.ts.map +1 -1
  140. package/dist/directory/derive-supervisor.js +8 -0
  141. package/dist/directory/derive-supervisor.js.map +1 -1
  142. package/dist/directory/derive.d.ts.map +1 -1
  143. package/dist/directory/derive.js +8 -0
  144. package/dist/directory/derive.js.map +1 -1
  145. package/dist/directory/load.d.ts.map +1 -1
  146. package/dist/directory/load.js +2 -0
  147. package/dist/directory/load.js.map +1 -1
  148. package/dist/directory/types.d.ts +4 -0
  149. package/dist/directory/types.d.ts.map +1 -1
  150. package/dist/eval/experiment.d.ts +10 -10
  151. package/dist/eval/experiment.d.ts.map +1 -1
  152. package/dist/eval/experiment.js +121 -91
  153. package/dist/eval/experiment.js.map +1 -1
  154. package/dist/eval/judge.d.ts +6 -0
  155. package/dist/eval/judge.d.ts.map +1 -1
  156. package/dist/eval/judge.js +7 -2
  157. package/dist/eval/judge.js.map +1 -1
  158. package/dist/eval/types.d.ts +7 -1
  159. package/dist/eval/types.d.ts.map +1 -1
  160. package/dist/manager/agent/lifecycle.d.ts +12 -10
  161. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  162. package/dist/manager/agent/lifecycle.js +16 -3
  163. package/dist/manager/agent/lifecycle.js.map +1 -1
  164. package/dist/manager/connector/environment.d.ts +2 -2
  165. package/dist/manager/connector/environment.d.ts.map +1 -1
  166. package/dist/manager/connector/environment.js +2 -2
  167. package/dist/manager/connector/environment.js.map +1 -1
  168. package/dist/manager/connector/lifecycle.d.ts +10 -2
  169. package/dist/manager/connector/lifecycle.d.ts.map +1 -1
  170. package/dist/manager/connector/lifecycle.js +273 -24
  171. package/dist/manager/connector/lifecycle.js.map +1 -1
  172. package/dist/manager/connector/tenant.d.ts +5 -4
  173. package/dist/manager/connector/tenant.d.ts.map +1 -1
  174. package/dist/manager/connector/tenant.js +47 -22
  175. package/dist/manager/connector/tenant.js.map +1 -1
  176. package/dist/manager/goal/activation.d.ts +23 -0
  177. package/dist/manager/goal/activation.d.ts.map +1 -0
  178. package/dist/manager/goal/activation.js +41 -0
  179. package/dist/manager/goal/activation.js.map +1 -0
  180. package/dist/manager/index.d.ts +3 -2
  181. package/dist/manager/index.d.ts.map +1 -1
  182. package/dist/manager/index.js.map +1 -1
  183. package/dist/manager/run/persistence.d.ts +2 -0
  184. package/dist/manager/run/persistence.d.ts.map +1 -1
  185. package/dist/manager/run/persistence.js +5 -1
  186. package/dist/manager/run/persistence.js.map +1 -1
  187. package/dist/manager/topic/dependency.d.ts +24 -0
  188. package/dist/manager/topic/dependency.d.ts.map +1 -0
  189. package/dist/manager/topic/dependency.js +13 -0
  190. package/dist/manager/topic/dependency.js.map +1 -0
  191. package/dist/manager/topic/lifecycle.d.ts +9 -21
  192. package/dist/manager/topic/lifecycle.d.ts.map +1 -1
  193. package/dist/manager/topic/lifecycle.js +17 -29
  194. package/dist/manager/topic/lifecycle.js.map +1 -1
  195. package/dist/plugin/index.d.ts +1 -0
  196. package/dist/plugin/index.d.ts.map +1 -1
  197. package/dist/plugin/index.js.map +1 -1
  198. package/dist/plugin/lifecycle.d.ts +15 -0
  199. package/dist/plugin/lifecycle.d.ts.map +1 -1
  200. package/dist/plugin/lifecycle.js +144 -38
  201. package/dist/plugin/lifecycle.js.map +1 -1
  202. package/dist/plugin/loader.d.ts +3 -3
  203. package/dist/plugin/loader.d.ts.map +1 -1
  204. package/dist/plugin/loader.js +58 -12
  205. package/dist/plugin/loader.js.map +1 -1
  206. package/dist/provider/collect-chat-completion.d.ts.map +1 -1
  207. package/dist/provider/collect-chat-completion.js +4 -0
  208. package/dist/provider/collect-chat-completion.js.map +1 -1
  209. package/dist/provider/fallback.d.ts +3 -1
  210. package/dist/provider/fallback.d.ts.map +1 -1
  211. package/dist/provider/fallback.js +62 -10
  212. package/dist/provider/fallback.js.map +1 -1
  213. package/dist/provider/idle-timeout.d.ts +4 -0
  214. package/dist/provider/idle-timeout.d.ts.map +1 -1
  215. package/dist/provider/idle-timeout.js +131 -15
  216. package/dist/provider/idle-timeout.js.map +1 -1
  217. package/dist/provider/index.d.ts +2 -0
  218. package/dist/provider/index.d.ts.map +1 -1
  219. package/dist/provider/index.js +1 -0
  220. package/dist/provider/index.js.map +1 -1
  221. package/dist/provider/instrumentation.d.ts.map +1 -1
  222. package/dist/provider/instrumentation.js +1 -0
  223. package/dist/provider/instrumentation.js.map +1 -1
  224. package/dist/provider/retry.d.ts.map +1 -1
  225. package/dist/provider/retry.js +13 -1
  226. package/dist/provider/retry.js.map +1 -1
  227. package/dist/public-runtime.d.ts +57 -24
  228. package/dist/public-runtime.d.ts.map +1 -1
  229. package/dist/public-runtime.js +42 -35
  230. package/dist/public-runtime.js.map +1 -1
  231. package/dist/public-tools.d.ts +1 -0
  232. package/dist/public-tools.d.ts.map +1 -1
  233. package/dist/public-tools.js +5 -0
  234. package/dist/public-tools.js.map +1 -1
  235. package/dist/public-types.d.ts +33 -12
  236. package/dist/public-types.d.ts.map +1 -1
  237. package/dist/rag/embedding.d.ts +8 -3
  238. package/dist/rag/embedding.d.ts.map +1 -1
  239. package/dist/rag/embedding.js +120 -9
  240. package/dist/rag/embedding.js.map +1 -1
  241. package/dist/rag/index.d.ts +1 -1
  242. package/dist/rag/index.d.ts.map +1 -1
  243. package/dist/rag/index.js +1 -1
  244. package/dist/rag/index.js.map +1 -1
  245. package/dist/rag/ingestion.d.ts +2 -2
  246. package/dist/rag/ingestion.d.ts.map +1 -1
  247. package/dist/rag/ingestion.js +15 -3
  248. package/dist/rag/ingestion.js.map +1 -1
  249. package/dist/rag/knowledge-base.d.ts +3 -3
  250. package/dist/rag/knowledge-base.d.ts.map +1 -1
  251. package/dist/rag/knowledge-base.js +8 -4
  252. package/dist/rag/knowledge-base.js.map +1 -1
  253. package/dist/rag/operation.d.ts +10 -0
  254. package/dist/rag/operation.d.ts.map +1 -0
  255. package/dist/rag/operation.js +26 -0
  256. package/dist/rag/operation.js.map +1 -0
  257. package/dist/rag/rag-tool.d.ts.map +1 -1
  258. package/dist/rag/rag-tool.js +6 -3
  259. package/dist/rag/rag-tool.js.map +1 -1
  260. package/dist/rag/retriever.d.ts +2 -2
  261. package/dist/rag/retriever.d.ts.map +1 -1
  262. package/dist/rag/retriever.js +31 -15
  263. package/dist/rag/retriever.js.map +1 -1
  264. package/dist/rag/vector-store.d.ts +3 -3
  265. package/dist/rag/vector-store.d.ts.map +1 -1
  266. package/dist/rag/vector-store.js +4 -2
  267. package/dist/rag/vector-store.js.map +1 -1
  268. package/dist/registry/command/kernel-commands.d.ts +16 -4
  269. package/dist/registry/command/kernel-commands.d.ts.map +1 -1
  270. package/dist/registry/command/kernel-commands.js +171 -0
  271. package/dist/registry/command/kernel-commands.js.map +1 -1
  272. package/dist/run/reporter.d.ts.map +1 -1
  273. package/dist/run/reporter.js +9 -0
  274. package/dist/run/reporter.js.map +1 -1
  275. package/dist/run-query/index.d.ts +15 -1
  276. package/dist/run-query/index.d.ts.map +1 -1
  277. package/dist/run-query/index.js +69 -15
  278. package/dist/run-query/index.js.map +1 -1
  279. package/dist/runtime/query/context.d.ts.map +1 -1
  280. package/dist/runtime/query/context.js +10 -3
  281. package/dist/runtime/query/context.js.map +1 -1
  282. package/dist/runtime/query/executor.d.ts +3 -0
  283. package/dist/runtime/query/executor.d.ts.map +1 -1
  284. package/dist/runtime/query/executor.js +80 -18
  285. package/dist/runtime/query/executor.js.map +1 -1
  286. package/dist/runtime/query/guard.d.ts +9 -0
  287. package/dist/runtime/query/guard.d.ts.map +1 -1
  288. package/dist/runtime/query/guard.js +11 -0
  289. package/dist/runtime/query/guard.js.map +1 -1
  290. package/dist/runtime/query/index.d.ts +30 -1
  291. package/dist/runtime/query/index.d.ts.map +1 -1
  292. package/dist/runtime/query/index.js +548 -95
  293. package/dist/runtime/query/index.js.map +1 -1
  294. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  295. package/dist/runtime/query/iteration/index.js +74 -14
  296. package/dist/runtime/query/iteration/index.js.map +1 -1
  297. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  298. package/dist/runtime/query/iteration/phases/compaction.js +94 -53
  299. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  300. package/dist/runtime/query/iteration/phases/context.d.ts +3 -0
  301. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  302. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  303. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  304. package/dist/runtime/query/iteration/phases/tool-review.js +21 -0
  305. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  306. package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
  307. package/dist/runtime/query/iteration/stream-turn.js +4 -0
  308. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  309. package/dist/runtime/query/project-instructions.d.ts +69 -0
  310. package/dist/runtime/query/project-instructions.d.ts.map +1 -0
  311. package/dist/runtime/query/project-instructions.js +137 -0
  312. package/dist/runtime/query/project-instructions.js.map +1 -0
  313. package/dist/runtime/query/request-rich-content.d.ts +22 -0
  314. package/dist/runtime/query/request-rich-content.d.ts.map +1 -0
  315. package/dist/runtime/query/request-rich-content.js +122 -0
  316. package/dist/runtime/query/request-rich-content.js.map +1 -0
  317. package/dist/runtime/query/result.d.ts.map +1 -1
  318. package/dist/runtime/query/result.js +12 -1
  319. package/dist/runtime/query/result.js.map +1 -1
  320. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  321. package/dist/runtime/query/resume-pending.js +19 -20
  322. package/dist/runtime/query/resume-pending.js.map +1 -1
  323. package/dist/runtime/query/resume-run.d.ts.map +1 -1
  324. package/dist/runtime/query/resume-run.js +54 -8
  325. package/dist/runtime/query/resume-run.js.map +1 -1
  326. package/dist/runtime/query/run-state.d.ts +5 -0
  327. package/dist/runtime/query/run-state.d.ts.map +1 -1
  328. package/dist/runtime/query/run-state.js +6 -1
  329. package/dist/runtime/query/run-state.js.map +1 -1
  330. package/dist/runtime/query/sandbox-lifecycle.d.ts +54 -0
  331. package/dist/runtime/query/sandbox-lifecycle.d.ts.map +1 -0
  332. package/dist/runtime/query/sandbox-lifecycle.js +167 -0
  333. package/dist/runtime/query/sandbox-lifecycle.js.map +1 -0
  334. package/dist/sandbox/isolation.d.ts.map +1 -1
  335. package/dist/sandbox/isolation.js +9 -0
  336. package/dist/sandbox/isolation.js.map +1 -1
  337. package/dist/sandbox/provider/local.d.ts +56 -6
  338. package/dist/sandbox/provider/local.d.ts.map +1 -1
  339. package/dist/sandbox/provider/local.js +181 -76
  340. package/dist/sandbox/provider/local.js.map +1 -1
  341. package/dist/sandbox/terminal.d.ts +13 -5
  342. package/dist/sandbox/terminal.d.ts.map +1 -1
  343. package/dist/sandbox/terminal.js +11 -3
  344. package/dist/sandbox/terminal.js.map +1 -1
  345. package/dist/session/errors.d.ts +28 -29
  346. package/dist/session/errors.d.ts.map +1 -1
  347. package/dist/session/errors.js +28 -29
  348. package/dist/session/errors.js.map +1 -1
  349. package/dist/session/handoff/broadcast.d.ts +5 -8
  350. package/dist/session/handoff/broadcast.d.ts.map +1 -1
  351. package/dist/session/handoff/broadcast.js +16 -6
  352. package/dist/session/handoff/broadcast.js.map +1 -1
  353. package/dist/session/handoff/single.d.ts +5 -8
  354. package/dist/session/handoff/single.d.ts.map +1 -1
  355. package/dist/session/handoff/single.js +7 -4
  356. package/dist/session/handoff/single.js.map +1 -1
  357. package/dist/store/attachment/index.d.ts +11 -3
  358. package/dist/store/attachment/index.d.ts.map +1 -1
  359. package/dist/store/attachment/index.js +49 -4
  360. package/dist/store/attachment/index.js.map +1 -1
  361. package/dist/store/feedback/conformance.d.ts.map +1 -1
  362. package/dist/store/feedback/conformance.js +32 -0
  363. package/dist/store/feedback/conformance.js.map +1 -1
  364. package/dist/store/feedback/disk.d.ts +8 -6
  365. package/dist/store/feedback/disk.d.ts.map +1 -1
  366. package/dist/store/feedback/disk.js +111 -76
  367. package/dist/store/feedback/disk.js.map +1 -1
  368. package/dist/store/goal/index.d.ts +111 -0
  369. package/dist/store/goal/index.d.ts.map +1 -0
  370. package/dist/store/goal/index.js +436 -0
  371. package/dist/store/goal/index.js.map +1 -0
  372. package/dist/store/index.d.ts +1 -1
  373. package/dist/store/index.d.ts.map +1 -1
  374. package/dist/store/index.js +1 -1
  375. package/dist/store/index.js.map +1 -1
  376. package/dist/store/kv/revision-record-store.d.ts +70 -0
  377. package/dist/store/kv/revision-record-store.d.ts.map +1 -0
  378. package/dist/store/kv/revision-record-store.js +290 -0
  379. package/dist/store/kv/revision-record-store.js.map +1 -0
  380. package/dist/store/memory/disk.d.ts +9 -7
  381. package/dist/store/memory/disk.d.ts.map +1 -1
  382. package/dist/store/memory/disk.js +256 -98
  383. package/dist/store/memory/disk.js.map +1 -1
  384. package/dist/store/run/disk.d.ts +10 -2
  385. package/dist/store/run/disk.d.ts.map +1 -1
  386. package/dist/store/run/disk.js +70 -4
  387. package/dist/store/run/disk.js.map +1 -1
  388. package/dist/store/run/memory.d.ts +4 -2
  389. package/dist/store/run/memory.d.ts.map +1 -1
  390. package/dist/store/run/memory.js +15 -1
  391. package/dist/store/run/memory.js.map +1 -1
  392. package/dist/store/session/disk.d.ts +9 -0
  393. package/dist/store/session/disk.d.ts.map +1 -1
  394. package/dist/store/session/disk.js +57 -5
  395. package/dist/store/session/disk.js.map +1 -1
  396. package/dist/store/session/memory.d.ts +1 -0
  397. package/dist/store/session/memory.d.ts.map +1 -1
  398. package/dist/store/session/memory.js +14 -0
  399. package/dist/store/session/memory.js.map +1 -1
  400. package/dist/store/topic/memory.d.ts +1 -2
  401. package/dist/store/topic/memory.d.ts.map +1 -1
  402. package/dist/store/topic/memory.js +4 -5
  403. package/dist/store/topic/memory.js.map +1 -1
  404. package/dist/store/topic/objective.d.ts +8 -4
  405. package/dist/store/topic/objective.d.ts.map +1 -1
  406. package/dist/store/topic/objective.js +185 -100
  407. package/dist/store/topic/objective.js.map +1 -1
  408. package/dist/store/topic/state.d.ts +1 -2
  409. package/dist/store/topic/state.d.ts.map +1 -1
  410. package/dist/store/topic/state.js +50 -62
  411. package/dist/store/topic/state.js.map +1 -1
  412. package/dist/tools/builtins/bash.d.ts.map +1 -1
  413. package/dist/tools/builtins/bash.js +20 -0
  414. package/dist/tools/builtins/bash.js.map +1 -1
  415. package/dist/tools/builtins/computer-use.d.ts +9 -1
  416. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  417. package/dist/tools/builtins/computer-use.js.map +1 -1
  418. package/dist/tools/builtins/content-fingerprint.d.ts +8 -7
  419. package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
  420. package/dist/tools/builtins/content-fingerprint.js +9 -10
  421. package/dist/tools/builtins/content-fingerprint.js.map +1 -1
  422. package/dist/tools/builtins/edit.d.ts +6 -1
  423. package/dist/tools/builtins/edit.d.ts.map +1 -1
  424. package/dist/tools/builtins/edit.js +166 -27
  425. package/dist/tools/builtins/edit.js.map +1 -1
  426. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  427. package/dist/tools/builtins/write-file.js +45 -19
  428. package/dist/tools/builtins/write-file.js.map +1 -1
  429. package/dist/tools/command-arguments.d.ts +43 -0
  430. package/dist/tools/command-arguments.d.ts.map +1 -0
  431. package/dist/tools/command-arguments.js +52 -0
  432. package/dist/tools/command-arguments.js.map +1 -0
  433. package/dist/tools/coordinator/index.d.ts +2 -0
  434. package/dist/tools/coordinator/index.d.ts.map +1 -1
  435. package/dist/tools/coordinator/index.js +3 -1
  436. package/dist/tools/coordinator/index.js.map +1 -1
  437. package/dist/tools/defineTool.d.ts +10 -0
  438. package/dist/tools/defineTool.d.ts.map +1 -1
  439. package/dist/tools/defineTool.js +1 -0
  440. package/dist/tools/defineTool.js.map +1 -1
  441. package/dist/tools/env-scrub.d.ts +7 -5
  442. package/dist/tools/env-scrub.d.ts.map +1 -1
  443. package/dist/tools/env-scrub.js +7 -5
  444. package/dist/tools/env-scrub.js.map +1 -1
  445. package/dist/tools/goal/index.d.ts +20 -0
  446. package/dist/tools/goal/index.d.ts.map +1 -0
  447. package/dist/tools/goal/index.js +104 -0
  448. package/dist/tools/goal/index.js.map +1 -0
  449. package/dist/tools/memory/index.d.ts +16 -0
  450. package/dist/tools/memory/index.d.ts.map +1 -1
  451. package/dist/tools/memory/index.js +6 -2
  452. package/dist/tools/memory/index.js.map +1 -1
  453. package/dist/tools/memory/search.d.ts +4 -1
  454. package/dist/tools/memory/search.d.ts.map +1 -1
  455. package/dist/tools/memory/search.js +10 -2
  456. package/dist/tools/memory/search.js.map +1 -1
  457. package/dist/types/agent/base.d.ts +11 -3
  458. package/dist/types/agent/base.d.ts.map +1 -1
  459. package/dist/types/agent/factory.d.ts +2 -0
  460. package/dist/types/agent/factory.d.ts.map +1 -1
  461. package/dist/types/agent/reactive.d.ts +2 -0
  462. package/dist/types/agent/reactive.d.ts.map +1 -1
  463. package/dist/types/agent/supervisor.d.ts +6 -0
  464. package/dist/types/agent/supervisor.d.ts.map +1 -1
  465. package/dist/types/agent/task.d.ts +6 -2
  466. package/dist/types/agent/task.d.ts.map +1 -1
  467. package/dist/types/connector/core.d.ts +13 -8
  468. package/dist/types/connector/core.d.ts.map +1 -1
  469. package/dist/types/connector/definition.d.ts +37 -18
  470. package/dist/types/connector/definition.d.ts.map +1 -1
  471. package/dist/types/connector/http.d.ts +6 -0
  472. package/dist/types/connector/http.d.ts.map +1 -1
  473. package/dist/types/connector/mcp.d.ts +24 -6
  474. package/dist/types/connector/mcp.d.ts.map +1 -1
  475. package/dist/types/connector/tenant.d.ts +17 -7
  476. package/dist/types/connector/tenant.d.ts.map +1 -1
  477. package/dist/types/connector/webhook.d.ts +6 -0
  478. package/dist/types/connector/webhook.d.ts.map +1 -1
  479. package/dist/types/goal/index.d.ts +46 -0
  480. package/dist/types/goal/index.d.ts.map +1 -0
  481. package/dist/types/goal/index.js +2 -0
  482. package/dist/types/goal/index.js.map +1 -0
  483. package/dist/types/ids/index.d.ts +2 -0
  484. package/dist/types/ids/index.d.ts.map +1 -1
  485. package/dist/types/ids/index.js.map +1 -1
  486. package/dist/types/message/index.d.ts +75 -10
  487. package/dist/types/message/index.d.ts.map +1 -1
  488. package/dist/types/message/index.js +49 -3
  489. package/dist/types/message/index.js.map +1 -1
  490. package/dist/types/plugin/index.d.ts +7 -5
  491. package/dist/types/plugin/index.d.ts.map +1 -1
  492. package/dist/types/plugin/index.js.map +1 -1
  493. package/dist/types/provider/chat.d.ts +27 -4
  494. package/dist/types/provider/chat.d.ts.map +1 -1
  495. package/dist/types/provider/interface.d.ts +18 -7
  496. package/dist/types/provider/interface.d.ts.map +1 -1
  497. package/dist/types/provider/stream.d.ts +6 -0
  498. package/dist/types/provider/stream.d.ts.map +1 -1
  499. package/dist/types/rag/embedding.d.ts +15 -2
  500. package/dist/types/rag/embedding.d.ts.map +1 -1
  501. package/dist/types/rag/ingestion.d.ts +2 -2
  502. package/dist/types/rag/ingestion.d.ts.map +1 -1
  503. package/dist/types/rag/knowledge-base.d.ts +3 -3
  504. package/dist/types/rag/knowledge-base.d.ts.map +1 -1
  505. package/dist/types/rag/retrieval.d.ts +2 -2
  506. package/dist/types/rag/retrieval.d.ts.map +1 -1
  507. package/dist/types/rag/scope.d.ts +4 -0
  508. package/dist/types/rag/scope.d.ts.map +1 -1
  509. package/dist/types/rag/vector.d.ts +5 -2
  510. package/dist/types/rag/vector.d.ts.map +1 -1
  511. package/dist/types/run/config.d.ts +20 -0
  512. package/dist/types/run/config.d.ts.map +1 -1
  513. package/dist/types/run/events.d.ts +25 -1
  514. package/dist/types/run/events.d.ts.map +1 -1
  515. package/dist/types/run/events.js.map +1 -1
  516. package/dist/types/run/metadata.d.ts +2 -0
  517. package/dist/types/run/metadata.d.ts.map +1 -1
  518. package/dist/types/run/step.d.ts +2 -6
  519. package/dist/types/run/step.d.ts.map +1 -1
  520. package/dist/types/run/step.js.map +1 -1
  521. package/dist/types/run/store.d.ts +55 -2
  522. package/dist/types/run/store.d.ts.map +1 -1
  523. package/dist/types/sandbox/index.d.ts +47 -6
  524. package/dist/types/sandbox/index.d.ts.map +1 -1
  525. package/dist/types/sandbox/index.js +23 -10
  526. package/dist/types/sandbox/index.js.map +1 -1
  527. package/dist/types/session/store.d.ts +13 -0
  528. package/dist/types/session/store.d.ts.map +1 -1
  529. package/dist/types/tool/index.d.ts +33 -11
  530. package/dist/types/tool/index.d.ts.map +1 -1
  531. package/dist/types/tool/index.js.map +1 -1
  532. package/dist/types/topic/entity.d.ts +3 -4
  533. package/dist/types/topic/entity.d.ts.map +1 -1
  534. package/dist/types/topic/store.d.ts +3 -3
  535. package/dist/utils/id.d.ts +3 -1
  536. package/dist/utils/id.d.ts.map +1 -1
  537. package/dist/utils/id.js +4 -0
  538. package/dist/utils/id.js.map +1 -1
  539. package/dist/utils/process-environment.d.ts +26 -0
  540. package/dist/utils/process-environment.d.ts.map +1 -0
  541. package/dist/utils/process-environment.js +78 -0
  542. package/dist/utils/process-environment.js.map +1 -0
  543. package/dist/vault/InMemoryCredentialVault.d.ts +2 -0
  544. package/dist/vault/InMemoryCredentialVault.d.ts.map +1 -1
  545. package/dist/vault/InMemoryCredentialVault.js +24 -4
  546. package/dist/vault/InMemoryCredentialVault.js.map +1 -1
  547. package/dist/vault/instrumentation.d.ts.map +1 -1
  548. package/dist/vault/instrumentation.js +15 -0
  549. package/dist/vault/instrumentation.js.map +1 -1
  550. package/package.json +1 -1
  551. package/src/advisory/executor.ts +4 -1
  552. package/src/agents/ReactiveAgent.ts +12 -0
  553. package/src/agents/RouterAgent.ts +25 -3
  554. package/src/agents/SupervisorAgent.ts +33 -11
  555. package/src/agents/runAgent.ts +38 -2
  556. package/src/authorization/command-line.ts +390 -0
  557. package/src/authorization/rules.ts +22 -1
  558. package/src/bridge/a2a/client.ts +384 -97
  559. package/src/bridge/a2a/mapper.ts +5 -0
  560. package/src/bridge/acp/server.ts +184 -42
  561. package/src/bridge/mcp/connector/adapter.ts +28 -20
  562. package/src/bridge/sse/mapper.ts +3 -0
  563. package/src/compaction/dangling.ts +203 -38
  564. package/src/compaction/index.ts +9 -2
  565. package/src/compaction/manual.ts +125 -18
  566. package/src/compaction/plan.ts +42 -11
  567. package/src/compaction/retention.ts +23 -8
  568. package/src/compaction/summary.ts +4 -4
  569. package/src/compaction/verifier.ts +66 -0
  570. package/src/connector/BaseConnector.ts +19 -4
  571. package/src/connector/builtins/http.ts +236 -46
  572. package/src/connector/builtins/webhook.ts +207 -47
  573. package/src/connector/execution-contract.ts +27 -0
  574. package/src/connector/http-operation.ts +238 -0
  575. package/src/connector/mcp/adapter.ts +8 -3
  576. package/src/connector/mcp/client.ts +207 -58
  577. package/src/connector/mcp/http-sse.ts +91 -23
  578. package/src/connector/mcp/prompt-adapter.ts +8 -2
  579. package/src/connector/mcp/stdio.ts +21 -46
  580. package/src/connector/mcp/streamable-http.ts +86 -22
  581. package/src/connector/tools/adapter.ts +23 -14
  582. package/src/connector/tools/definitions.ts +5 -2
  583. package/src/connector/tools/result.ts +21 -0
  584. package/src/connector/web/guarded-fetch.ts +188 -48
  585. package/src/constants/sandbox/index.ts +3 -2
  586. package/src/contracts/api.ts +2 -0
  587. package/src/contracts/schemas.ts +7 -0
  588. package/src/directory/derive-supervisor.ts +8 -0
  589. package/src/directory/derive.ts +8 -0
  590. package/src/directory/load.ts +2 -0
  591. package/src/directory/types.ts +4 -0
  592. package/src/eval/experiment.ts +160 -111
  593. package/src/eval/judge.ts +13 -2
  594. package/src/eval/types.ts +7 -1
  595. package/src/manager/agent/lifecycle.ts +28 -12
  596. package/src/manager/connector/environment.ts +3 -1
  597. package/src/manager/connector/lifecycle.ts +364 -24
  598. package/src/manager/connector/tenant.ts +56 -23
  599. package/src/manager/goal/activation.ts +52 -0
  600. package/src/manager/index.ts +10 -2
  601. package/src/manager/run/persistence.ts +6 -1
  602. package/src/manager/topic/dependency.ts +39 -0
  603. package/src/manager/topic/lifecycle.ts +19 -31
  604. package/src/plugin/index.ts +1 -0
  605. package/src/plugin/lifecycle.ts +180 -39
  606. package/src/plugin/loader.ts +70 -13
  607. package/src/provider/collect-chat-completion.ts +3 -0
  608. package/src/provider/fallback.ts +79 -11
  609. package/src/provider/idle-timeout.ts +143 -17
  610. package/src/provider/index.ts +2 -0
  611. package/src/provider/instrumentation.ts +1 -0
  612. package/src/provider/retry.ts +16 -1
  613. package/src/public-runtime.ts +190 -32
  614. package/src/public-tools.ts +5 -0
  615. package/src/public-types.ts +85 -11
  616. package/src/rag/embedding.ts +147 -19
  617. package/src/rag/index.ts +1 -1
  618. package/src/rag/ingestion.ts +16 -2
  619. package/src/rag/knowledge-base.ts +13 -4
  620. package/src/rag/operation.ts +28 -0
  621. package/src/rag/rag-tool.ts +6 -3
  622. package/src/rag/retriever.ts +62 -11
  623. package/src/rag/vector-store.ts +8 -2
  624. package/src/registry/command/kernel-commands.ts +223 -4
  625. package/src/run/reporter.ts +10 -0
  626. package/src/run-query/index.ts +84 -15
  627. package/src/runtime/query/context.ts +13 -3
  628. package/src/runtime/query/executor.ts +90 -17
  629. package/src/runtime/query/guard.ts +12 -0
  630. package/src/runtime/query/index.ts +652 -103
  631. package/src/runtime/query/iteration/index.ts +89 -13
  632. package/src/runtime/query/iteration/phases/compaction.ts +120 -55
  633. package/src/runtime/query/iteration/phases/context.ts +4 -0
  634. package/src/runtime/query/iteration/phases/tool-review.ts +28 -0
  635. package/src/runtime/query/iteration/stream-turn.ts +3 -0
  636. package/src/runtime/query/project-instructions.ts +212 -0
  637. package/src/runtime/query/request-rich-content.ts +153 -0
  638. package/src/runtime/query/result.ts +12 -1
  639. package/src/runtime/query/resume-pending.ts +20 -18
  640. package/src/runtime/query/resume-run.ts +52 -8
  641. package/src/runtime/query/run-state.ts +11 -1
  642. package/src/runtime/query/sandbox-lifecycle.ts +210 -0
  643. package/src/sandbox/isolation.ts +9 -0
  644. package/src/sandbox/provider/local.ts +255 -90
  645. package/src/sandbox/terminal.ts +13 -5
  646. package/src/session/errors.ts +68 -42
  647. package/src/session/handoff/broadcast.ts +20 -14
  648. package/src/session/handoff/single.ts +14 -13
  649. package/src/store/attachment/index.ts +65 -3
  650. package/src/store/feedback/conformance.ts +39 -0
  651. package/src/store/feedback/disk.ts +128 -82
  652. package/src/store/goal/index.ts +594 -0
  653. package/src/store/index.ts +1 -1
  654. package/src/store/kv/revision-record-store.ts +346 -0
  655. package/src/store/memory/disk.ts +288 -113
  656. package/src/store/run/disk.ts +96 -5
  657. package/src/store/run/memory.ts +22 -2
  658. package/src/store/session/disk.ts +93 -6
  659. package/src/store/session/memory.ts +22 -0
  660. package/src/store/topic/memory.ts +4 -5
  661. package/src/store/topic/objective.ts +215 -100
  662. package/src/store/topic/state.ts +100 -63
  663. package/src/tools/builtins/bash.ts +21 -0
  664. package/src/tools/builtins/computer-use.ts +9 -1
  665. package/src/tools/builtins/content-fingerprint.ts +9 -12
  666. package/src/tools/builtins/edit.ts +190 -27
  667. package/src/tools/builtins/write-file.ts +55 -19
  668. package/src/tools/command-arguments.ts +54 -0
  669. package/src/tools/coordinator/index.ts +4 -1
  670. package/src/tools/defineTool.ts +11 -0
  671. package/src/tools/env-scrub.ts +7 -5
  672. package/src/tools/goal/index.ts +129 -0
  673. package/src/tools/memory/index.ts +26 -3
  674. package/src/tools/memory/search.ts +20 -3
  675. package/src/types/agent/base.ts +12 -3
  676. package/src/types/agent/factory.ts +2 -0
  677. package/src/types/agent/reactive.ts +2 -0
  678. package/src/types/agent/supervisor.ts +6 -0
  679. package/src/types/agent/task.ts +6 -2
  680. package/src/types/connector/core.ts +13 -8
  681. package/src/types/connector/definition.ts +54 -20
  682. package/src/types/connector/http.ts +7 -0
  683. package/src/types/connector/mcp.ts +27 -6
  684. package/src/types/connector/tenant.ts +21 -7
  685. package/src/types/connector/webhook.ts +7 -0
  686. package/src/types/goal/index.ts +50 -0
  687. package/src/types/ids/index.ts +2 -0
  688. package/src/types/message/index.ts +143 -9
  689. package/src/types/plugin/index.ts +7 -5
  690. package/src/types/provider/chat.ts +35 -4
  691. package/src/types/provider/interface.ts +22 -7
  692. package/src/types/provider/stream.ts +6 -0
  693. package/src/types/rag/embedding.ts +16 -2
  694. package/src/types/rag/ingestion.ts +2 -1
  695. package/src/types/rag/knowledge-base.ts +7 -3
  696. package/src/types/rag/retrieval.ts +2 -1
  697. package/src/types/rag/scope.ts +5 -0
  698. package/src/types/rag/vector.ts +5 -2
  699. package/src/types/run/config.ts +20 -0
  700. package/src/types/run/events.ts +28 -3
  701. package/src/types/run/metadata.ts +2 -0
  702. package/src/types/run/step.ts +2 -7
  703. package/src/types/run/store.ts +60 -2
  704. package/src/types/sandbox/index.ts +57 -14
  705. package/src/types/session/store.ts +18 -0
  706. package/src/types/tool/index.ts +33 -11
  707. package/src/types/topic/entity.ts +3 -4
  708. package/src/types/topic/store.ts +3 -3
  709. package/src/utils/id.ts +6 -0
  710. package/src/utils/process-environment.ts +101 -0
  711. package/src/vault/InMemoryCredentialVault.ts +29 -4
  712. package/src/vault/instrumentation.ts +24 -0
@@ -1,10 +1,11 @@
1
- import { access, mkdir } from 'node:fs/promises'
1
+ import { mkdir, readFile } from 'node:fs/promises'
2
2
  import { dirname } from 'node:path'
3
3
  import { z } from 'zod'
4
4
  import type { ToolContext, ToolResult } from '../../types/tool/index.js'
5
5
  import { defineTool } from '../defineTool.js'
6
6
  import { resolveWithinReal } from '../paths.js'
7
7
  import { atomicWriteFile } from './atomic-write-file.js'
8
+ import { fingerprintContent, staleFileError } from './content-fingerprint.js'
8
9
  import { withFileMutationLock } from './file-mutation-lock.js'
9
10
 
10
11
  const inputSchema = z
@@ -144,13 +145,16 @@ export const WriteFileTool = defineTool({
144
145
 
145
146
  return withFileMutationLock(lockKey, async () => {
146
147
  if (context.sandbox) {
147
- const sandboxExists = await sandboxFileExists(context, valid.path)
148
- if (sandboxExists) {
149
- const guard = enforceReadBeforeOverwrite(context, valid.path)
148
+ const current = await readSandboxFileIfPresent(context, valid.path)
149
+ if (current !== undefined) {
150
+ const guard = enforceFreshOverwrite(context, valid.path, current.toString('utf-8'))
150
151
  if (guard) return guard
151
152
  }
152
153
  await context.sandbox.writeFile(valid.path, content)
153
- context.fileReadTracker?.recordRead(valid.path)
154
+ // This write is now the runtime's newest observation. Recording only
155
+ // the boolean would leave an older content fingerprint in place and
156
+ // make the next same-run write refuse its own predecessor as drift.
157
+ context.fileReadTracker?.recordRead(valid.path, content)
154
158
  return {
155
159
  success: true as const,
156
160
  output: `File written successfully: ${valid.path} (${content.length} chars) [sandboxed]`,
@@ -159,9 +163,9 @@ export const WriteFileTool = defineTool({
159
163
  }
160
164
 
161
165
  const hostPath = filePath as string
162
- const localExists = await pathExists(hostPath)
163
- if (localExists) {
164
- const guard = enforceReadBeforeOverwrite(context, hostPath)
166
+ const current = await readHostFileIfPresent(hostPath)
167
+ if (current !== undefined) {
168
+ const guard = enforceFreshOverwrite(context, hostPath, current)
165
169
  if (guard) return guard
166
170
  }
167
171
 
@@ -170,7 +174,7 @@ export const WriteFileTool = defineTool({
170
174
  // leaves the destination truncated — and this tool overwrites a
171
175
  // whole file, so the truncation is the user's previous work.
172
176
  await atomicWriteFile(hostPath, content)
173
- context.fileReadTracker?.recordRead(hostPath)
177
+ context.fileReadTracker?.recordRead(hostPath, content)
174
178
 
175
179
  return {
176
180
  success: true as const,
@@ -194,21 +198,53 @@ function enforceReadBeforeOverwrite(
194
198
  }
195
199
  }
196
200
 
197
- async function pathExists(hostPath: string): Promise<boolean> {
201
+ function enforceFreshOverwrite(
202
+ context: ToolContext,
203
+ key: string,
204
+ currentContent: string,
205
+ ): { success: false; output: ''; error: string } | null {
206
+ const unread = enforceReadBeforeOverwrite(context, key)
207
+ if (unread) return unread
208
+
209
+ // Optional forever: older hosts only tracked the boolean read-before-write
210
+ // fact. They retain their old behavior rather than being refused on a
211
+ // fingerprint the host never promised to capture.
212
+ const observed = context.fileReadTracker?.fingerprint?.(key)
213
+ if (observed !== undefined && observed !== fingerprintContent(currentContent)) {
214
+ return { success: false, output: '', error: staleFileError(key, 'write') }
215
+ }
216
+ return null
217
+ }
218
+
219
+ async function readHostFileIfPresent(hostPath: string): Promise<string | undefined> {
198
220
  try {
199
- await access(hostPath)
200
- return true
201
- } catch {
202
- return false
221
+ return await readFile(hostPath, 'utf-8')
222
+ } catch (error) {
223
+ if (isMissingFileError(error)) return undefined
224
+ throw error
203
225
  }
204
226
  }
205
227
 
206
- async function sandboxFileExists(context: ToolContext, path: string): Promise<boolean> {
207
- if (!context.sandbox) return false
228
+ function isMissingFileError(error: unknown): boolean {
229
+ return (
230
+ typeof error === 'object' &&
231
+ error !== null &&
232
+ 'code' in error &&
233
+ (error as { code?: unknown }).code === 'ENOENT'
234
+ )
235
+ }
236
+
237
+ async function readSandboxFileIfPresent(
238
+ context: ToolContext,
239
+ path: string,
240
+ ): Promise<Buffer | undefined> {
241
+ if (!context.sandbox) return undefined
208
242
  try {
209
- await context.sandbox.readFile(path)
210
- return true
243
+ return await context.sandbox.readFile(path)
211
244
  } catch {
212
- return false
245
+ // `Sandbox` currently has no typed missing-file result. Preserve the
246
+ // existing create behavior for all backends; when a read succeeds, the
247
+ // exact body above is still a real admission-time freshness check.
248
+ return undefined
213
249
  }
214
250
  }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Which argument of a tool holds a shell command line.
3
+ *
4
+ * ## Why a host needs this
5
+ *
6
+ * A host that compiles operator config into gate rules has a tool NAME and a
7
+ * pattern, and needs an argument to attach the pattern to. Without one it can
8
+ * only reach for `custom_pattern`, whose subject is `JSON.stringify(input)` —
9
+ * and matching a glob against a serialised object costs both halves of what an
10
+ * operator meant. The pattern can match the start of any argument's value
11
+ * rather than the one they had in mind, and it stays open on the right, so
12
+ * `bash = { "git status*" = "allow" }` compiled to a rule that also approved
13
+ * `git status && rm -rf ~`.
14
+ *
15
+ * `argument_pattern` has neither problem, and it reads the value as the
16
+ * commands it runs. Reaching it needs exactly one fact this function supplies.
17
+ *
18
+ * ## Why it is derived rather than written down
19
+ *
20
+ * A list of "tools whose first argument is a command" maintained beside the
21
+ * tools is a list that drifts from them, and this repository has now gated
22
+ * that same shape four times. So the fact lives on the tool as
23
+ * {@link ToolDefinition.commandArgument} and this reads it back.
24
+ *
25
+ * A host with its own tools should ask {@link commandArgumentOf} with the
26
+ * definition it already holds. {@link builtinCommandArguments} exists for the
27
+ * case where only the name is available — permission config is compiled before
28
+ * any tool is constructed — and answers for the builtin set alone. An unknown
29
+ * name gets `undefined`, which is a host falling back to what it did before
30
+ * rather than a wrong answer.
31
+ */
32
+
33
+ import type { ToolDefinition } from '../types/tool/index.js'
34
+ import { getBuiltinTools } from './builtins/index.js'
35
+
36
+ /** The argument holding a command line, or undefined when the tool has none. */
37
+ export function commandArgumentOf(tool: ToolDefinition): string | undefined {
38
+ return tool.commandArgument
39
+ }
40
+
41
+ /**
42
+ * The builtin tools that take a command line, by tool name.
43
+ *
44
+ * Computed on each call rather than cached at module load: a frozen snapshot
45
+ * taken at import time is a copy of the registry, and a copy is the thing this
46
+ * module exists to avoid.
47
+ */
48
+ export function builtinCommandArguments(): ReadonlyMap<string, string> {
49
+ const byName = new Map<string, string>()
50
+ for (const tool of getBuiltinTools()) {
51
+ if (tool.commandArgument !== undefined) byName.set(tool.name, tool.commandArgument)
52
+ }
53
+ return byName
54
+ }
@@ -107,6 +107,9 @@ export interface CoordinatorToolsOptions {
107
107
  pendingAnswers?: PendingAnswers
108
108
  }
109
109
 
110
+ /** Internal identity shared by the builder and the agent authority boundary. */
111
+ export const ASK_USER_QUESTION_TOOL_NAME = 'ask_user_question' as const
112
+
110
113
  const approvePlanStepSchema = z.object({
111
114
  description: z.string().describe('What this step does'),
112
115
  agent_id: z
@@ -1472,7 +1475,7 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
1472
1475
  const parkRunId = runId
1473
1476
  const parkHandler = resumeHandler
1474
1477
  const askUserQuestion = defineTool({
1475
- name: 'ask_user_question',
1478
+ name: ASK_USER_QUESTION_TOOL_NAME,
1476
1479
  description:
1477
1480
  'Ask the user ONE question ONLY when you are blocked on a decision that is genuinely theirs to make — one you cannot resolve from their request, your tools, the files you can read, or sensible defaults. The question must be the genuinely undecidable thing in THIS task. Never ask for information a tool can discover (do not ask what you can read, list, or search), never re-ask what the conversation already answers, and never ask meta-questions like "Shall I proceed?" — plan ratification goes through approve_plan. Provide 2-4 genuinely distinct options derived from the actual context — concrete paths, never generic placeholders (for example, asked to prepare a presentation, ask "Who is the audience?" with options like Board / Engineering team / Customer); keep labels short (1-5 words) and give each option a one-line description of what practically changes if it is chosen. Put your recommended option FIRST and append " (Recommended)" to its label. Set multiSelect: true only when several options can apply at once. A free-text "Something else" escape hatch is always shown automatically — do not add your own "Other" option. Ask ONE question per call and prefer at most one question per assistant turn; if several decisions block you, ask only the ones that materially change your next actions, in sequence — most work needs at most 2-3 questions, so prefer proceeding on stated defaults over interrogating the user. Never invent answers or synthetic content on the user\'s behalf unless they explicitly asked for a random/test scenario. The answer arrives as this tool\'s result; if the result says the user did not answer, do not ask this or any other question again — proceed on your best judgment without assuming consent.',
1478
1481
  inputSchema: z
@@ -48,6 +48,16 @@ export interface DefineToolOptions<S extends z.ZodType> {
48
48
  outputSchema?: Record<string, unknown>
49
49
  /** Settle the run with this tool's output; see {@link ToolDefinition.terminal}. */
50
50
  terminal?: boolean
51
+ /**
52
+ * The argument holding a shell command line; see
53
+ * {@link ToolDefinition.commandArgument}.
54
+ *
55
+ * Here as well as on the definition for the reason `maxRetries` and
56
+ * `presentCall` are: this builder is the sanctioned way to author a tool,
57
+ * and a field a host reads that the builder cannot set is a field only
58
+ * hand-written definitions can use.
59
+ */
60
+ commandArgument?: string
51
61
  execute(input: z.infer<S>, context: ToolContext): Promise<ToolResult>
52
62
  }
53
63
 
@@ -66,6 +76,7 @@ export function defineTool<S extends z.ZodType>(
66
76
  tier: options.tier,
67
77
  ...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),
68
78
  ...(options.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),
79
+ ...(options.commandArgument !== undefined ? { commandArgument: options.commandArgument } : {}),
69
80
  ...(options.presentCall ? { presentCall: options.presentCall } : {}),
70
81
  ...(options.presentResult ? { presentResult: options.presentResult } : {}),
71
82
  ...(options.outputSchema !== undefined ? { outputSchema: options.outputSchema } : {}),
@@ -20,11 +20,13 @@
20
20
  * still reach the command.
21
21
  *
22
22
  * The actual boundary is the sandbox, where the inherited set is an allowlist
23
- * (`SANDBOX_SAFE_ENV_KEYS`, seven keys) rather than a denylist. An allowlist
24
- * is correct there because a sandbox is a fresh environment; it is wrong on
25
- * the host path, where the same agent is expected to run `pnpm test`, `make`
26
- * and `docker build`, all of which need far more than seven variables. So the
27
- * host path gets the weaker control on purpose, and says so.
23
+ * (the local sandbox's bounded core-process keys) rather than a denylist. Its
24
+ * Windows branch includes the system-root, command-interpreter and profile
25
+ * plumbing a working Windows child needs; it still carries no ambient
26
+ * credential keys. An allowlist is correct there because a sandbox is a fresh
27
+ * environment; it is wrong on the host path, where the same agent is expected
28
+ * to run `pnpm test`, `make` and `docker build`, all of which need far more
29
+ * variables. So the host path gets the weaker control on purpose, and says so.
28
30
  *
29
31
  * ## Why this exists at all
30
32
  *
@@ -0,0 +1,129 @@
1
+ import { z } from 'zod'
2
+
3
+ import { GoalNotFoundError, type SessionGoalStore, StaleGoalError } from '../../store/goal/index.js'
4
+ import type { GoalRoundAuthority, SessionGoal } from '../../types/goal/index.js'
5
+ import type { RunId } from '../../types/ids/index.js'
6
+ import type { ToolDefinition } from '../../types/tool/index.js'
7
+ import { defineTool } from '../defineTool.js'
8
+
9
+ export const SESSION_GOAL_TOOL_NAMES = ['get_goal', 'update_goal'] as const
10
+ export const MIN_GOAL_BLOCK_ROUND = 3
11
+
12
+ /** Resolve authority captured for one caller-reserved run id. */
13
+ export type ResolveGoalRoundAuthority = (runId: RunId) => GoalRoundAuthority | null | undefined
14
+
15
+ /** A goal tool was reached outside the one run whose admission authorized it. */
16
+ export class GoalRoundAuthorityError extends Error {
17
+ constructor(runId: RunId) {
18
+ super(`Run ${runId} has no admitted goal-round authority.`)
19
+ this.name = 'GoalRoundAuthorityError'
20
+ }
21
+ }
22
+
23
+ async function currentGoal(
24
+ store: SessionGoalStore,
25
+ authority: GoalRoundAuthority,
26
+ ): Promise<SessionGoal> {
27
+ const goal = await store.getGoal(authority.sessionId, authority.tenantId)
28
+ if (!goal) throw new GoalNotFoundError(authority.sessionId)
29
+ if (goal.id !== authority.id || goal.revision !== authority.revision) {
30
+ throw new StaleGoalError({
31
+ sessionId: authority.sessionId,
32
+ expectedRevision: authority.revision,
33
+ actualRevision: goal.revision,
34
+ })
35
+ }
36
+ return goal
37
+ }
38
+
39
+ function authorityFor(
40
+ resolveAuthority: ResolveGoalRoundAuthority,
41
+ runId: RunId,
42
+ ): GoalRoundAuthority {
43
+ const authority = resolveAuthority(runId)
44
+ if (!authority) throw new GoalRoundAuthorityError(runId)
45
+ return authority
46
+ }
47
+
48
+ /**
49
+ * Run-scoped tools for an admitted SessionGoal round.
50
+ *
51
+ * Registration is not authorization. A host must also withhold these names
52
+ * from every non-goal provider request and executor allow-list.
53
+ */
54
+ export function buildSessionGoalTools(
55
+ store: SessionGoalStore,
56
+ resolveAuthority: ResolveGoalRoundAuthority,
57
+ ): ToolDefinition[] {
58
+ const getGoal = defineTool({
59
+ name: 'get_goal',
60
+ description:
61
+ 'Read the exact completion goal and admitted-round budget that authorized this automatic turn.',
62
+ inputSchema: z.object({}),
63
+ category: 'analysis',
64
+ permissions: [],
65
+ readOnly: true,
66
+ destructive: false,
67
+ concurrencySafe: true,
68
+ async execute(_input, context) {
69
+ const authority = authorityFor(resolveAuthority, context.runId)
70
+ const goal = await currentGoal(store, authority)
71
+ return {
72
+ success: true,
73
+ output: JSON.stringify({
74
+ id: goal.id,
75
+ objective: goal.objective,
76
+ phase: goal.phase,
77
+ round: authority.round,
78
+ maxGoalRounds: goal.maxGoalRounds,
79
+ roundsAdmitted: goal.roundsAdmitted,
80
+ }),
81
+ data: goal,
82
+ }
83
+ },
84
+ })
85
+
86
+ const updateGoal = defineTool({
87
+ name: 'update_goal',
88
+ description:
89
+ 'Mark this admitted goal complete, or blocked after at least three admitted rounds. This does not end the turn; explain the final state to the operator afterward.',
90
+ inputSchema: z.object({
91
+ status: z.enum(['complete', 'blocked']),
92
+ reasonCode: z
93
+ .string()
94
+ .optional()
95
+ .describe('Lower-kebab-case reason code; required when status is blocked.'),
96
+ reason: z.string().optional().describe('Operator-readable reason; required when blocked.'),
97
+ }),
98
+ category: 'custom',
99
+ permissions: [],
100
+ readOnly: false,
101
+ destructive: false,
102
+ concurrencySafe: false,
103
+ async execute({ status, reasonCode, reason }, context) {
104
+ const authority = authorityFor(resolveAuthority, context.runId)
105
+ await currentGoal(store, authority)
106
+ const ref = { id: authority.id, revision: authority.revision }
107
+ if (status === 'complete') {
108
+ const goal = await store.completeGoal(authority.sessionId, authority.tenantId, ref)
109
+ return { success: true, output: 'Goal marked complete.', data: goal }
110
+ }
111
+
112
+ if (authority.round < MIN_GOAL_BLOCK_ROUND) {
113
+ throw new Error(
114
+ `A goal cannot be marked blocked before admitted round ${MIN_GOAL_BLOCK_ROUND}; this is round ${authority.round}.`,
115
+ )
116
+ }
117
+ if (!reasonCode || !reason) {
118
+ throw new TypeError('Blocked goal updates require reasonCode and reason.')
119
+ }
120
+ const goal = await store.blockGoal(authority.sessionId, authority.tenantId, ref, {
121
+ code: reasonCode,
122
+ message: reason,
123
+ })
124
+ return { success: true, output: 'Goal marked blocked.', data: goal }
125
+ },
126
+ })
127
+
128
+ return [getGoal, updateGoal]
129
+ }
@@ -2,10 +2,33 @@ import type { MemoryIndex, MemoryStore } from '../../types/memory/index.js'
2
2
  import type { ToolDefinition } from '../../types/tool/index.js'
3
3
  import { buildReadMemoryTool } from './read.js'
4
4
  import { buildSaveMemoryTool } from './save.js'
5
- import { buildSearchMemoryTool } from './search.js'
5
+ import { buildSearchMemoryTool, buildStoreSearchMemoryTool } from './search.js'
6
6
 
7
- export function buildMemoryTools(store: MemoryStore, index: MemoryIndex): ToolDefinition[] {
8
- return [buildSearchMemoryTool(index), buildReadMemoryTool(store), buildSaveMemoryTool(store)]
7
+ /**
8
+ * Build memory tools over one authoritative store.
9
+ *
10
+ * This is the safe default for asynchronous or lazy stores: `search_memory`
11
+ * crosses the store's own `list()` boundary, so a fresh disk-backed instance
12
+ * loads its durable index before answering the first search.
13
+ */
14
+ export function buildMemoryTools(store: MemoryStore): ToolDefinition[]
15
+
16
+ /**
17
+ * Build memory tools with a caller-owned search index.
18
+ *
19
+ * The index is deliberately authoritative in this form. It may be remote,
20
+ * pre-populated or otherwise unrelated to the content store, so searching it
21
+ * must not first call `store.list()` and invent a readiness dependency that
22
+ * this contract never promised.
23
+ */
24
+ export function buildMemoryTools(store: MemoryStore, index: MemoryIndex): ToolDefinition[]
25
+
26
+ export function buildMemoryTools(store: MemoryStore, index?: MemoryIndex): ToolDefinition[] {
27
+ return [
28
+ index ? buildSearchMemoryTool(index) : buildStoreSearchMemoryTool(store),
29
+ buildReadMemoryTool(store),
30
+ buildSaveMemoryTool(store),
31
+ ]
9
32
  }
10
33
 
11
34
  export { buildSearchMemoryTool } from './search.js'
@@ -1,9 +1,16 @@
1
1
  import { z } from 'zod'
2
- import type { MemoryIndex } from '../../types/memory/index.js'
2
+ import type {
3
+ MemoryIndex,
4
+ MemorySearchParams,
5
+ MemorySearchResult,
6
+ MemoryStore,
7
+ } from '../../types/memory/index.js'
3
8
  import type { ToolDefinition } from '../../types/tool/index.js'
4
9
  import { defineTool } from '../defineTool.js'
5
10
 
6
- export function buildSearchMemoryTool(index: MemoryIndex): ToolDefinition {
11
+ type SearchMemory = (params: MemorySearchParams) => MemorySearchResult | Promise<MemorySearchResult>
12
+
13
+ function defineSearchMemoryTool(search: SearchMemory): ToolDefinition {
7
14
  return defineTool({
8
15
  name: 'search_memory',
9
16
  description:
@@ -19,7 +26,7 @@ export function buildSearchMemoryTool(index: MemoryIndex): ToolDefinition {
19
26
  destructive: false,
20
27
  concurrencySafe: true,
21
28
  async execute({ query, tags, limit }) {
22
- const result = index.search({ query, tags, limit })
29
+ const result = await search({ query, tags, limit })
23
30
 
24
31
  if (result.entries.length === 0) {
25
32
  return {
@@ -50,3 +57,13 @@ export function buildSearchMemoryTool(index: MemoryIndex): ToolDefinition {
50
57
  },
51
58
  })
52
59
  }
60
+
61
+ /** Build search over a caller-owned, already-ready synchronous index. */
62
+ export function buildSearchMemoryTool(index: MemoryIndex): ToolDefinition {
63
+ return defineSearchMemoryTool((params) => index.search(params))
64
+ }
65
+
66
+ /** Build search over the store's authoritative asynchronous read boundary. */
67
+ export function buildStoreSearchMemoryTool(store: MemoryStore): ToolDefinition {
68
+ return defineSearchMemoryTool((params) => store.list(params))
69
+ }
@@ -1,3 +1,4 @@
1
+ import type { ProjectInstructionContext } from '../../runtime/query/project-instructions.js'
1
2
  import type { Logger } from '../../utils/logger.js'
2
3
  import type { CostInfo, RunExecutionStatus, TokenUsage } from '../common/index.js'
3
4
  import type { ResumeHandler } from '../hitl/index.js'
@@ -18,6 +19,10 @@ export interface BaseAgentConfig {
18
19
  model: string
19
20
  tokenBudget: number
20
21
  timeoutMs: number
22
+ /** See {@link import('../run/config.js').AgentRunConfig.streamIdleTimeoutMs}. */
23
+ streamIdleTimeoutMs?: number
24
+ /** See {@link import('../run/config.js').AgentRunConfig.maxRequestRichContentBytes}. */
25
+ maxRequestRichContentBytes?: number
21
26
  maxIterations?: number
22
27
  temperature?: number
23
28
  maxResponseTokens?: number
@@ -57,6 +62,9 @@ export interface BaseAgentConfig {
57
62
  */
58
63
  inboundMessages?: () => import('../message/index.js').Message[]
59
64
 
65
+ /** Live project policy, flushed independently of human continuation text. */
66
+ projectInstructionContext?: ProjectInstructionContext
67
+
60
68
  allowedTools?: readonly string[]
61
69
 
62
70
  /**
@@ -184,7 +192,7 @@ export interface BaseAgentConfig {
184
192
 
185
193
  /**
186
194
  * Where this agent takes a decision it cannot make alone — a tool that
187
- * needs approval, a question for a human, a plan to sign off.
195
+ * needs approval, a root-agent question for a human, a plan to sign off.
188
196
  *
189
197
  * Declared HERE, on the base config, rather than only on the agent
190
198
  * shapes that happened to want it. `AgentManager` builds a child as a
@@ -203,8 +211,9 @@ export interface BaseAgentConfig {
203
211
  * had a human review `write` at the top level and never see the same
204
212
  * `write` issued one hop down.
205
213
  *
206
- * Absent still means auto-approve, so a host that never wired one is
207
- * unaffected.
214
+ * A delegated agent inherits this channel for review but does not gain the
215
+ * root-only `ask_user_question` tool. Absent still means auto-approve, so a
216
+ * host that never wired one is unaffected.
208
217
  */
209
218
  resumeHandler?: ResumeHandler
210
219
  }
@@ -46,6 +46,8 @@ export interface AgentFactoryOptions {
46
46
  workingDirectory?: string
47
47
  tokenBudget?: number
48
48
  timeoutMs?: number
49
+ streamIdleTimeoutMs?: number
50
+ maxRequestRichContentBytes?: number
49
51
  temperature?: number
50
52
  maxResponseTokens?: number
51
53
  env?: Record<string, string>
@@ -64,6 +64,8 @@ export interface ReactiveAgentConfig extends BaseAgentConfig {
64
64
  * on top of the provider keeps the underlying container alive.
65
65
  */
66
66
  sandboxProvider?: SandboxProvider
67
+ /** See {@link QueryParams.sandboxTeardownTimeoutMs}. */
68
+ sandboxTeardownTimeoutMs?: number
67
69
 
68
70
  /**
69
71
  * Optional structured-compaction config. Omitted ⇒ byte-identical run path
@@ -138,6 +138,10 @@ export interface SupervisorAgentConfig extends BaseAgentConfig {
138
138
  * handler that surfaces the `tool_review_requested` RunEvent to
139
139
  * the user and resolves the returned promise once the user
140
140
  * approves, rejects, or modifies the call.
141
+ *
142
+ * The root supervisor also uses this channel for `ask_user_question`.
143
+ * Delegated supervisors keep the review channel but do not publish that
144
+ * interactive tool; their root owns operator questions.
141
145
  */
142
146
  resumeHandler?: ResumeHandler
143
147
 
@@ -173,6 +177,8 @@ export interface SupervisorAgentConfig extends BaseAgentConfig {
173
177
  * + children share one ephemeral container per task.
174
178
  */
175
179
  sandboxProvider?: SandboxProvider
180
+ /** See {@link import('../../runtime/query/index.js').QueryParams.sandboxTeardownTimeoutMs}. */
181
+ sandboxTeardownTimeoutMs?: number
176
182
 
177
183
  /**
178
184
  * Optional structured-compaction config. When omitted, `query()` never
@@ -42,8 +42,12 @@ export interface AgentTaskContext {
42
42
  factoryOptions?: AgentFactoryOptions
43
43
 
44
44
  /**
45
- * The parent's channel to whoever can answer a decision it cannot make
46
- * alone, handed down so a child asks the same person.
45
+ * The parent's channel to whoever reviews decisions it cannot make alone,
46
+ * handed down so a child's REVIEW-tier tool calls reach the same person.
47
+ * This does not grant a delegated agent the `ask_user_question` tool:
48
+ * interactive questions are a root-agent capability, while authorization
49
+ * review must remain inherited to avoid unattended auto-approval below the
50
+ * root.
47
51
  *
48
52
  * Passed as the function itself, which works because delegation is
49
53
  * in-process: `LocalTaskScheduler` is the only `TaskScheduler` in the tree.
@@ -29,14 +29,9 @@ export interface ConnectorMethod<TInput = unknown, TOutput = unknown> {
29
29
  description: string
30
30
  inputSchema: z.ZodType<TInput, z.ZodTypeDef, unknown>
31
31
  /**
32
- * **Not consulted.** Neither in-tree connector declares one, and nothing
33
- * validates a result against it or shows it to a model.
34
- *
35
- * The tool layer solved the same problem already: a remote tool's output
36
- * schema is appended to its description by `describeWithOutput`, because
37
- * no provider's tool wire format has a slot for one. A connector method
38
- * that reaches a model through that bridge should take the same route
39
- * rather than growing a second mechanism.
32
+ * Canonical output contract for this method. ConnectorManager validates a
33
+ * successful implementation result before publishing it and exposes the
34
+ * rendered schema to tool and MCP consumers.
40
35
  */
41
36
  outputSchema?: z.ZodType<TOutput, z.ZodTypeDef, unknown>
42
37
  }
@@ -64,6 +59,11 @@ export interface ConnectorMethod<TInput = unknown, TOutput = unknown> {
64
59
  * in-process dedupe seam and names the cross-process half as its known
65
60
  * gap, and `EditOwnershipTracker.claim` is the claim/refuse shape with
66
61
  * same-owner idempotency already worked out.
62
+ *
63
+ * @deprecated The SDK does not subscribe to or dispatch connector triggers.
64
+ * Keep inbound subscription metadata in a host-owned type and store. This
65
+ * declaration remains for one migration release because a host may already
66
+ * use `ConnectorRegistry` as its own metadata table.
67
67
  */
68
68
  export interface ConnectorTrigger {
69
69
  name: string
@@ -72,6 +72,11 @@ export interface ConnectorTrigger {
72
72
  configSchema?: z.ZodType
73
73
  }
74
74
 
75
+ /**
76
+ * @deprecated The SDK does not emit inbound connector events. Define the
77
+ * event envelope at the host boundary that owns subscription, de-duplication,
78
+ * delivery, and run admission.
79
+ */
75
80
  export interface ConnectorEvent {
76
81
  connectorId: ConnectorId
77
82
  instanceId: ConnectorInstanceId