@namzu/sdk 27.1.0 → 29.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 (1427) hide show
  1. package/CHANGELOG.md +1757 -0
  2. package/README.md +45 -42
  3. package/dist/advisory/executor.d.ts.map +1 -1
  4. package/dist/advisory/executor.js +14 -12
  5. package/dist/advisory/executor.js.map +1 -1
  6. package/dist/advisory/registry.d.ts +2 -2
  7. package/dist/advisory/registry.d.ts.map +1 -1
  8. package/dist/advisory/registry.js +2 -2
  9. package/dist/advisory/registry.js.map +1 -1
  10. package/dist/agents/AbstractAgent.d.ts +44 -2
  11. package/dist/agents/AbstractAgent.d.ts.map +1 -1
  12. package/dist/agents/AbstractAgent.js +62 -13
  13. package/dist/agents/AbstractAgent.js.map +1 -1
  14. package/dist/agents/PipelineAgent.d.ts +29 -1
  15. package/dist/agents/PipelineAgent.d.ts.map +1 -1
  16. package/dist/agents/PipelineAgent.js +33 -4
  17. package/dist/agents/PipelineAgent.js.map +1 -1
  18. package/dist/agents/ReactiveAgent.d.ts +2 -1
  19. package/dist/agents/ReactiveAgent.d.ts.map +1 -1
  20. package/dist/agents/ReactiveAgent.js +15 -6
  21. package/dist/agents/ReactiveAgent.js.map +1 -1
  22. package/dist/agents/RouterAgent.d.ts +2 -1
  23. package/dist/agents/RouterAgent.d.ts.map +1 -1
  24. package/dist/agents/RouterAgent.js +21 -13
  25. package/dist/agents/RouterAgent.js.map +1 -1
  26. package/dist/agents/SupervisorAgent.d.ts +3 -2
  27. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  28. package/dist/agents/SupervisorAgent.js +29 -16
  29. package/dist/agents/SupervisorAgent.js.map +1 -1
  30. package/dist/agents/handle.d.ts +85 -0
  31. package/dist/agents/handle.d.ts.map +1 -0
  32. package/dist/agents/handle.js +79 -0
  33. package/dist/agents/handle.js.map +1 -0
  34. package/dist/agents/runAgent.d.ts +10 -5
  35. package/dist/agents/runAgent.d.ts.map +1 -1
  36. package/dist/agents/runAgent.js +3 -2
  37. package/dist/agents/runAgent.js.map +1 -1
  38. package/dist/{verification → authorization}/gate.d.ts +4 -4
  39. package/dist/authorization/gate.d.ts.map +1 -0
  40. package/dist/{verification → authorization}/gate.js +31 -24
  41. package/dist/authorization/gate.js.map +1 -0
  42. package/dist/authorization/index.d.ts +6 -0
  43. package/dist/authorization/index.d.ts.map +1 -0
  44. package/dist/authorization/index.js +14 -0
  45. package/dist/authorization/index.js.map +1 -0
  46. package/dist/authorization/permission-presets.d.ts +119 -0
  47. package/dist/authorization/permission-presets.d.ts.map +1 -0
  48. package/dist/authorization/permission-presets.js +137 -0
  49. package/dist/authorization/permission-presets.js.map +1 -0
  50. package/dist/{verification → authorization}/presets.d.ts +3 -3
  51. package/dist/authorization/presets.d.ts.map +1 -0
  52. package/dist/{verification → authorization}/presets.js +12 -0
  53. package/dist/authorization/presets.js.map +1 -0
  54. package/dist/authorization/rules.d.ts +4 -0
  55. package/dist/authorization/rules.d.ts.map +1 -0
  56. package/dist/{verification → authorization}/rules.js +14 -1
  57. package/dist/authorization/rules.js.map +1 -0
  58. package/dist/bridge/a2a/client.d.ts +107 -0
  59. package/dist/bridge/a2a/client.d.ts.map +1 -0
  60. package/dist/bridge/a2a/client.js +275 -0
  61. package/dist/bridge/a2a/client.js.map +1 -0
  62. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  63. package/dist/bridge/a2a/mapper.js +16 -0
  64. package/dist/bridge/a2a/mapper.js.map +1 -1
  65. package/dist/bridge/acp/filesystem.d.ts +33 -0
  66. package/dist/bridge/acp/filesystem.d.ts.map +1 -0
  67. package/dist/bridge/acp/filesystem.js +30 -0
  68. package/dist/bridge/acp/filesystem.js.map +1 -0
  69. package/dist/bridge/acp/index.d.ts +8 -0
  70. package/dist/bridge/acp/index.d.ts.map +1 -0
  71. package/dist/bridge/acp/index.js +5 -0
  72. package/dist/bridge/acp/index.js.map +1 -0
  73. package/dist/bridge/acp/permission.d.ts +51 -0
  74. package/dist/bridge/acp/permission.d.ts.map +1 -0
  75. package/dist/bridge/acp/permission.js +37 -0
  76. package/dist/bridge/acp/permission.js.map +1 -0
  77. package/dist/bridge/acp/server.d.ts +163 -0
  78. package/dist/bridge/acp/server.d.ts.map +1 -0
  79. package/dist/bridge/acp/server.js +312 -0
  80. package/dist/bridge/acp/server.js.map +1 -0
  81. package/dist/bridge/acp/update.d.ts +13 -0
  82. package/dist/bridge/acp/update.d.ts.map +1 -0
  83. package/dist/bridge/acp/update.js +94 -0
  84. package/dist/bridge/acp/update.js.map +1 -0
  85. package/dist/bridge/mcp/connector/adapter.d.ts +2 -0
  86. package/dist/bridge/mcp/connector/adapter.d.ts.map +1 -1
  87. package/dist/bridge/mcp/connector/adapter.js +7 -3
  88. package/dist/bridge/mcp/connector/adapter.js.map +1 -1
  89. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  90. package/dist/bridge/sse/mapper.js +27 -0
  91. package/dist/bridge/sse/mapper.js.map +1 -1
  92. package/dist/bus/breaker.d.ts.map +1 -1
  93. package/dist/bus/breaker.js +15 -10
  94. package/dist/bus/breaker.js.map +1 -1
  95. package/dist/bus/index.d.ts.map +1 -1
  96. package/dist/bus/index.js +10 -8
  97. package/dist/bus/index.js.map +1 -1
  98. package/dist/bus/lock.d.ts.map +1 -1
  99. package/dist/bus/lock.js +36 -19
  100. package/dist/bus/lock.js.map +1 -1
  101. package/dist/bus/ownership.d.ts.map +1 -1
  102. package/dist/bus/ownership.js +17 -9
  103. package/dist/bus/ownership.js.map +1 -1
  104. package/dist/compaction/context-window.d.ts +18 -2
  105. package/dist/compaction/context-window.d.ts.map +1 -1
  106. package/dist/compaction/context-window.js +15 -1
  107. package/dist/compaction/context-window.js.map +1 -1
  108. package/dist/compaction/index.d.ts +3 -0
  109. package/dist/compaction/index.d.ts.map +1 -1
  110. package/dist/compaction/index.js +4 -0
  111. package/dist/compaction/index.js.map +1 -1
  112. package/dist/compaction/manual.d.ts +58 -0
  113. package/dist/compaction/manual.d.ts.map +1 -0
  114. package/dist/compaction/manual.js +104 -0
  115. package/dist/compaction/manual.js.map +1 -0
  116. package/dist/compaction/plan.d.ts +92 -0
  117. package/dist/compaction/plan.d.ts.map +1 -0
  118. package/dist/compaction/plan.js +149 -0
  119. package/dist/compaction/plan.js.map +1 -0
  120. package/dist/compaction/summary.d.ts +23 -0
  121. package/dist/compaction/summary.d.ts.map +1 -0
  122. package/dist/compaction/summary.js +27 -0
  123. package/dist/compaction/summary.js.map +1 -0
  124. package/dist/compaction/verifier.js +2 -2
  125. package/dist/compaction/verifier.js.map +1 -1
  126. package/dist/config/registry.d.ts +104 -0
  127. package/dist/config/registry.d.ts.map +1 -0
  128. package/dist/config/registry.js +105 -0
  129. package/dist/config/registry.js.map +1 -0
  130. package/dist/config/runtime.d.ts +107 -36
  131. package/dist/config/runtime.d.ts.map +1 -1
  132. package/dist/config/runtime.js +27 -0
  133. package/dist/config/runtime.js.map +1 -1
  134. package/dist/connector/BaseConnector.d.ts +1 -1
  135. package/dist/connector/BaseConnector.d.ts.map +1 -1
  136. package/dist/connector/BaseConnector.js +8 -3
  137. package/dist/connector/BaseConnector.js.map +1 -1
  138. package/dist/connector/builtins/http.d.ts +1 -1
  139. package/dist/connector/builtins/http.d.ts.map +1 -1
  140. package/dist/connector/builtins/http.js +11 -2
  141. package/dist/connector/builtins/http.js.map +1 -1
  142. package/dist/connector/builtins/webhook.d.ts +1 -1
  143. package/dist/connector/builtins/webhook.d.ts.map +1 -1
  144. package/dist/connector/builtins/webhook.js +5 -2
  145. package/dist/connector/builtins/webhook.js.map +1 -1
  146. package/dist/connector/index.d.ts +4 -15
  147. package/dist/connector/index.d.ts.map +1 -1
  148. package/dist/connector/index.js +12 -12
  149. package/dist/connector/index.js.map +1 -1
  150. package/dist/connector/mcp/client.d.ts.map +1 -1
  151. package/dist/connector/mcp/client.js +31 -20
  152. package/dist/connector/mcp/client.js.map +1 -1
  153. package/dist/connector/mcp/discovery.d.ts.map +1 -1
  154. package/dist/connector/mcp/discovery.js +31 -20
  155. package/dist/connector/mcp/discovery.js.map +1 -1
  156. package/dist/connector/mcp/http-sse.d.ts +2 -1
  157. package/dist/connector/mcp/http-sse.d.ts.map +1 -1
  158. package/dist/connector/mcp/http-sse.js +9 -6
  159. package/dist/connector/mcp/http-sse.js.map +1 -1
  160. package/dist/connector/mcp/index.d.ts +2 -3
  161. package/dist/connector/mcp/index.d.ts.map +1 -1
  162. package/dist/connector/mcp/index.js +5 -4
  163. package/dist/connector/mcp/index.js.map +1 -1
  164. package/dist/connector/mcp/reconnect.d.ts +123 -0
  165. package/dist/connector/mcp/reconnect.d.ts.map +1 -0
  166. package/dist/connector/mcp/reconnect.js +121 -0
  167. package/dist/connector/mcp/reconnect.js.map +1 -0
  168. package/dist/connector/mcp/server/index.d.ts +28 -0
  169. package/dist/connector/mcp/server/index.d.ts.map +1 -0
  170. package/dist/connector/mcp/server/index.js +27 -0
  171. package/dist/connector/mcp/server/index.js.map +1 -0
  172. package/dist/connector/mcp/{server-stdio.d.ts → server/server-stdio.d.ts} +3 -2
  173. package/dist/connector/mcp/server/server-stdio.d.ts.map +1 -0
  174. package/dist/connector/mcp/{server-stdio.js → server/server-stdio.js} +4 -3
  175. package/dist/connector/mcp/server/server-stdio.js.map +1 -0
  176. package/dist/connector/mcp/{server.d.ts → server/server.d.ts} +5 -4
  177. package/dist/connector/mcp/server/server.d.ts.map +1 -0
  178. package/dist/connector/mcp/{server.js → server/server.js} +14 -9
  179. package/dist/connector/mcp/server/server.js.map +1 -0
  180. package/dist/connector/mcp/stdio.d.ts +2 -1
  181. package/dist/connector/mcp/stdio.d.ts.map +1 -1
  182. package/dist/connector/mcp/stdio.js +15 -7
  183. package/dist/connector/mcp/stdio.js.map +1 -1
  184. package/dist/connector/mcp/streamable-http.d.ts +2 -1
  185. package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
  186. package/dist/connector/mcp/streamable-http.js +5 -4
  187. package/dist/connector/mcp/streamable-http.js.map +1 -1
  188. package/dist/{bridge/tools/connector → connector/tools}/adapter.d.ts +4 -4
  189. package/dist/connector/tools/adapter.d.ts.map +1 -0
  190. package/dist/{bridge/tools/connector → connector/tools}/adapter.js +1 -1
  191. package/dist/connector/tools/adapter.js.map +1 -0
  192. package/dist/{bridge/tools/connector → connector/tools}/definitions.d.ts +2 -2
  193. package/dist/connector/tools/definitions.d.ts.map +1 -0
  194. package/dist/{bridge/tools/connector → connector/tools}/definitions.js +2 -2
  195. package/dist/connector/tools/definitions.js.map +1 -0
  196. package/dist/connector/tools/index.d.ts.map +1 -0
  197. package/dist/connector/tools/index.js.map +1 -0
  198. package/dist/{bridge/tools/connector → connector/tools}/router.d.ts +4 -2
  199. package/dist/connector/tools/router.d.ts.map +1 -0
  200. package/dist/{bridge/tools/connector → connector/tools}/router.js +14 -7
  201. package/dist/connector/tools/router.js.map +1 -0
  202. package/dist/connector/web/guarded-fetch.d.ts +60 -0
  203. package/dist/connector/web/guarded-fetch.d.ts.map +1 -0
  204. package/dist/connector/web/guarded-fetch.js +233 -0
  205. package/dist/connector/web/guarded-fetch.js.map +1 -0
  206. package/dist/connector/web/index.d.ts +5 -0
  207. package/dist/connector/web/index.d.ts.map +1 -0
  208. package/dist/connector/web/index.js +7 -0
  209. package/dist/connector/web/index.js.map +1 -0
  210. package/dist/connector/web/types.d.ts +87 -0
  211. package/dist/connector/web/types.d.ts.map +1 -0
  212. package/dist/connector/web/types.js +25 -0
  213. package/dist/connector/web/types.js.map +1 -0
  214. package/dist/constants/acp/index.d.ts +97 -0
  215. package/dist/constants/acp/index.d.ts.map +1 -0
  216. package/dist/constants/acp/index.js +96 -0
  217. package/dist/constants/acp/index.js.map +1 -0
  218. package/dist/constants/authorization/index.d.ts.map +1 -0
  219. package/dist/constants/authorization/index.js.map +1 -0
  220. package/dist/constants/credential-env-keys.d.ts +36 -0
  221. package/dist/constants/credential-env-keys.d.ts.map +1 -0
  222. package/dist/constants/credential-env-keys.js +62 -0
  223. package/dist/constants/credential-env-keys.js.map +1 -0
  224. package/dist/constants/index.d.ts +3 -1
  225. package/dist/constants/index.d.ts.map +1 -1
  226. package/dist/constants/index.js +3 -1
  227. package/dist/constants/index.js.map +1 -1
  228. package/dist/constants/secret-patterns.d.ts +78 -0
  229. package/dist/constants/secret-patterns.d.ts.map +1 -0
  230. package/dist/constants/secret-patterns.js +99 -0
  231. package/dist/constants/secret-patterns.js.map +1 -0
  232. package/dist/constants/telemetry/index.d.ts +42 -0
  233. package/dist/constants/telemetry/index.d.ts.map +1 -1
  234. package/dist/constants/telemetry/index.js +87 -0
  235. package/dist/constants/telemetry/index.js.map +1 -1
  236. package/dist/contracts/a2a.d.ts +46 -46
  237. package/dist/contracts/api.d.ts +12 -1
  238. package/dist/contracts/api.d.ts.map +1 -1
  239. package/dist/eval/judge.js +2 -2
  240. package/dist/eval/judge.js.map +1 -1
  241. package/dist/execution/base.d.ts +1 -1
  242. package/dist/execution/base.d.ts.map +1 -1
  243. package/dist/execution/base.js +18 -7
  244. package/dist/execution/base.js.map +1 -1
  245. package/dist/execution/code-runtime/types.d.ts +114 -0
  246. package/dist/execution/code-runtime/types.d.ts.map +1 -0
  247. package/dist/execution/code-runtime/types.js +40 -0
  248. package/dist/execution/code-runtime/types.js.map +1 -0
  249. package/dist/execution/code-runtime/worker.d.ts +6 -0
  250. package/dist/execution/code-runtime/worker.d.ts.map +1 -0
  251. package/dist/execution/code-runtime/worker.js +248 -0
  252. package/dist/execution/code-runtime/worker.js.map +1 -0
  253. package/dist/{connector/execution → execution}/factory.d.ts +3 -3
  254. package/dist/execution/factory.d.ts.map +1 -0
  255. package/dist/{connector/execution → execution}/factory.js +1 -1
  256. package/dist/execution/factory.js.map +1 -0
  257. package/dist/{connector/execution → execution}/hybrid.d.ts +5 -3
  258. package/dist/execution/hybrid.d.ts.map +1 -0
  259. package/dist/{connector/execution → execution}/hybrid.js +10 -4
  260. package/dist/execution/hybrid.js.map +1 -0
  261. package/dist/execution/index.d.ts +23 -0
  262. package/dist/execution/index.d.ts.map +1 -1
  263. package/dist/execution/index.js +21 -0
  264. package/dist/execution/index.js.map +1 -1
  265. package/dist/execution/local.d.ts +2 -0
  266. package/dist/execution/local.d.ts.map +1 -1
  267. package/dist/execution/local.js +2 -2
  268. package/dist/execution/local.js.map +1 -1
  269. package/dist/{connector/execution → execution}/remote.d.ts +4 -2
  270. package/dist/execution/remote.d.ts.map +1 -0
  271. package/dist/{connector/execution → execution}/remote.js +12 -5
  272. package/dist/execution/remote.js.map +1 -0
  273. package/dist/index.d.ts +2 -0
  274. package/dist/index.d.ts.map +1 -1
  275. package/dist/index.js +4 -0
  276. package/dist/index.js.map +1 -1
  277. package/dist/invariants/index.d.ts +111 -0
  278. package/dist/invariants/index.d.ts.map +1 -0
  279. package/dist/invariants/index.js +138 -0
  280. package/dist/invariants/index.js.map +1 -0
  281. package/dist/manager/agent/lifecycle.d.ts +29 -7
  282. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  283. package/dist/manager/agent/lifecycle.js +140 -50
  284. package/dist/manager/agent/lifecycle.js.map +1 -1
  285. package/dist/manager/connector/environment.d.ts +2 -0
  286. package/dist/manager/connector/environment.d.ts.map +1 -1
  287. package/dist/manager/connector/environment.js +20 -9
  288. package/dist/manager/connector/environment.js.map +1 -1
  289. package/dist/manager/connector/lifecycle.d.ts +10 -0
  290. package/dist/manager/connector/lifecycle.d.ts.map +1 -1
  291. package/dist/manager/connector/lifecycle.js +21 -11
  292. package/dist/manager/connector/lifecycle.js.map +1 -1
  293. package/dist/manager/connector/tenant.d.ts +9 -0
  294. package/dist/manager/connector/tenant.d.ts.map +1 -1
  295. package/dist/manager/connector/tenant.js +24 -10
  296. package/dist/manager/connector/tenant.js.map +1 -1
  297. package/dist/manager/index.d.ts +6 -2
  298. package/dist/manager/index.d.ts.map +1 -1
  299. package/dist/manager/index.js +7 -1
  300. package/dist/manager/index.js.map +1 -1
  301. package/dist/manager/project/lifecycle.d.ts +1 -1
  302. package/dist/manager/project/lifecycle.js +1 -1
  303. package/dist/manager/run/emergency.d.ts.map +1 -1
  304. package/dist/manager/run/emergency.js +9 -7
  305. package/dist/manager/run/emergency.js.map +1 -1
  306. package/dist/manager/run/persistence.d.ts +46 -4
  307. package/dist/manager/run/persistence.d.ts.map +1 -1
  308. package/dist/manager/run/persistence.js +102 -7
  309. package/dist/manager/run/persistence.js.map +1 -1
  310. package/dist/manager/topic/lifecycle.d.ts +123 -0
  311. package/dist/manager/topic/lifecycle.d.ts.map +1 -0
  312. package/dist/manager/{thread → topic}/lifecycle.js +79 -61
  313. package/dist/manager/topic/lifecycle.js.map +1 -0
  314. package/dist/manager/topic/objective.d.ts +77 -0
  315. package/dist/manager/topic/objective.d.ts.map +1 -0
  316. package/dist/manager/topic/objective.js +133 -0
  317. package/dist/manager/topic/objective.js.map +1 -0
  318. package/dist/model-router/task-router.d.ts.map +1 -0
  319. package/dist/model-router/task-router.js.map +1 -0
  320. package/dist/persona/assembler.d.ts +1 -1
  321. package/dist/persona/assembler.d.ts.map +1 -1
  322. package/dist/persona/assembler.js +14 -2
  323. package/dist/persona/assembler.js.map +1 -1
  324. package/dist/plugin/lifecycle.d.ts +24 -0
  325. package/dist/plugin/lifecycle.d.ts.map +1 -1
  326. package/dist/plugin/lifecycle.js +112 -20
  327. package/dist/plugin/lifecycle.js.map +1 -1
  328. package/dist/plugin/loader.d.ts +17 -2
  329. package/dist/plugin/loader.d.ts.map +1 -1
  330. package/dist/plugin/loader.js +46 -26
  331. package/dist/plugin/loader.js.map +1 -1
  332. package/dist/probe/index.d.ts +1 -0
  333. package/dist/probe/index.d.ts.map +1 -1
  334. package/dist/probe/registry.d.ts +34 -1
  335. package/dist/probe/registry.d.ts.map +1 -1
  336. package/dist/probe/registry.js +5 -4
  337. package/dist/probe/registry.js.map +1 -1
  338. package/dist/process/kill-tree.d.ts +40 -0
  339. package/dist/process/kill-tree.d.ts.map +1 -0
  340. package/dist/process/kill-tree.js +54 -0
  341. package/dist/process/kill-tree.js.map +1 -0
  342. package/dist/prompt/contributions.d.ts +138 -0
  343. package/dist/prompt/contributions.d.ts.map +1 -0
  344. package/dist/prompt/contributions.js +78 -0
  345. package/dist/prompt/contributions.js.map +1 -0
  346. package/dist/prompt/index.d.ts +3 -0
  347. package/dist/prompt/index.d.ts.map +1 -0
  348. package/dist/prompt/index.js +6 -0
  349. package/dist/prompt/index.js.map +1 -0
  350. package/dist/provider/attribution.d.ts +45 -0
  351. package/dist/provider/attribution.d.ts.map +1 -0
  352. package/dist/provider/attribution.js +23 -0
  353. package/dist/provider/attribution.js.map +1 -0
  354. package/dist/provider/{collect.d.ts → collect-chat-completion.d.ts} +3 -3
  355. package/dist/provider/collect-chat-completion.d.ts.map +1 -0
  356. package/dist/provider/{collect.js → collect-chat-completion.js} +3 -3
  357. package/dist/provider/collect-chat-completion.js.map +1 -0
  358. package/dist/provider/conformance.d.ts +93 -0
  359. package/dist/provider/conformance.d.ts.map +1 -0
  360. package/dist/provider/conformance.js +124 -0
  361. package/dist/provider/conformance.js.map +1 -0
  362. package/dist/provider/errors.d.ts +29 -0
  363. package/dist/provider/errors.d.ts.map +1 -1
  364. package/dist/provider/errors.js +27 -10
  365. package/dist/provider/errors.js.map +1 -1
  366. package/dist/provider/fallback.d.ts +1 -1
  367. package/dist/provider/fallback.d.ts.map +1 -1
  368. package/dist/provider/fallback.js +27 -9
  369. package/dist/provider/fallback.js.map +1 -1
  370. package/dist/provider/idle-timeout.d.ts +47 -0
  371. package/dist/provider/idle-timeout.d.ts.map +1 -0
  372. package/dist/provider/idle-timeout.js +61 -0
  373. package/dist/provider/idle-timeout.js.map +1 -0
  374. package/dist/provider/instrumentation.d.ts +3 -2
  375. package/dist/provider/instrumentation.d.ts.map +1 -1
  376. package/dist/provider/instrumentation.js.map +1 -1
  377. package/dist/provider/retry.d.ts.map +1 -1
  378. package/dist/provider/retry.js +58 -21
  379. package/dist/provider/retry.js.map +1 -1
  380. package/dist/public-runtime.d.ts +77 -15
  381. package/dist/public-runtime.d.ts.map +1 -1
  382. package/dist/public-runtime.js +168 -17
  383. package/dist/public-runtime.js.map +1 -1
  384. package/dist/public-tools.d.ts +8 -1
  385. package/dist/public-tools.d.ts.map +1 -1
  386. package/dist/public-tools.js +29 -1
  387. package/dist/public-tools.js.map +1 -1
  388. package/dist/public-types.d.ts +21 -4
  389. package/dist/public-types.d.ts.map +1 -1
  390. package/dist/rag/rag-tool.d.ts.map +1 -1
  391. package/dist/rag/rag-tool.js +4 -1
  392. package/dist/rag/rag-tool.js.map +1 -1
  393. package/dist/read-model/index.d.ts +5 -0
  394. package/dist/read-model/index.d.ts.map +1 -0
  395. package/dist/read-model/index.js +7 -0
  396. package/dist/read-model/index.js.map +1 -0
  397. package/dist/read-model/registry.d.ts +112 -0
  398. package/dist/read-model/registry.d.ts.map +1 -0
  399. package/dist/read-model/registry.js +105 -0
  400. package/dist/read-model/registry.js.map +1 -0
  401. package/dist/read-model/run-status.d.ts +43 -0
  402. package/dist/read-model/run-status.d.ts.map +1 -0
  403. package/dist/read-model/run-status.js +89 -0
  404. package/dist/read-model/run-status.js.map +1 -0
  405. package/dist/registry/{Registry.d.ts → BaseRegistry.d.ts} +2 -2
  406. package/dist/registry/BaseRegistry.d.ts.map +1 -0
  407. package/dist/registry/{Registry.js → BaseRegistry.js} +2 -2
  408. package/dist/registry/BaseRegistry.js.map +1 -0
  409. package/dist/registry/ManagedRegistry.d.ts +2 -2
  410. package/dist/registry/ManagedRegistry.d.ts.map +1 -1
  411. package/dist/registry/ManagedRegistry.js +26 -9
  412. package/dist/registry/ManagedRegistry.js.map +1 -1
  413. package/dist/registry/command/index-exports.d.ts +3 -0
  414. package/dist/registry/command/index-exports.d.ts.map +1 -0
  415. package/dist/registry/command/index-exports.js +5 -0
  416. package/dist/registry/command/index-exports.js.map +1 -0
  417. package/dist/registry/command/index.d.ts +53 -0
  418. package/dist/registry/command/index.d.ts.map +1 -0
  419. package/dist/registry/command/index.js +87 -0
  420. package/dist/registry/command/index.js.map +1 -0
  421. package/dist/registry/command/kernel-commands.d.ts +32 -0
  422. package/dist/registry/command/kernel-commands.d.ts.map +1 -0
  423. package/dist/registry/command/kernel-commands.js +78 -0
  424. package/dist/registry/command/kernel-commands.js.map +1 -0
  425. package/dist/registry/connector/scoped.d.ts +2 -1
  426. package/dist/registry/connector/scoped.d.ts.map +1 -1
  427. package/dist/registry/connector/scoped.js +6 -5
  428. package/dist/registry/connector/scoped.js.map +1 -1
  429. package/dist/registry/index.d.ts +4 -1
  430. package/dist/registry/index.d.ts.map +1 -1
  431. package/dist/registry/index.js +5 -1
  432. package/dist/registry/index.js.map +1 -1
  433. package/dist/registry/tool/execute.d.ts.map +1 -1
  434. package/dist/registry/tool/execute.js +15 -12
  435. package/dist/registry/tool/execute.js.map +1 -1
  436. package/dist/registry/tool/presentation.d.ts +32 -0
  437. package/dist/registry/tool/presentation.d.ts.map +1 -0
  438. package/dist/registry/tool/presentation.js +92 -0
  439. package/dist/registry/tool/presentation.js.map +1 -0
  440. package/dist/registry/tool/screen.d.ts.map +1 -1
  441. package/dist/registry/tool/screen.js +12 -11
  442. package/dist/registry/tool/screen.js.map +1 -1
  443. package/dist/run/drain.d.ts +13 -3
  444. package/dist/run/drain.d.ts.map +1 -1
  445. package/dist/run/drain.js +10 -0
  446. package/dist/run/drain.js.map +1 -1
  447. package/dist/run/reporter.d.ts.map +1 -1
  448. package/dist/run/reporter.js +203 -149
  449. package/dist/run/reporter.js.map +1 -1
  450. package/dist/run-query/index.d.ts +74 -0
  451. package/dist/run-query/index.d.ts.map +1 -0
  452. package/dist/run-query/index.js +73 -0
  453. package/dist/run-query/index.js.map +1 -0
  454. package/dist/runtime/bidi/session.d.ts.map +1 -1
  455. package/dist/runtime/bidi/session.js +7 -2
  456. package/dist/runtime/bidi/session.js.map +1 -1
  457. package/dist/runtime/decision/fallback.d.ts.map +1 -1
  458. package/dist/runtime/decision/fallback.js +6 -3
  459. package/dist/runtime/decision/fallback.js.map +1 -1
  460. package/dist/runtime/decision/parser.d.ts.map +1 -1
  461. package/dist/runtime/decision/parser.js +10 -9
  462. package/dist/runtime/decision/parser.js.map +1 -1
  463. package/dist/runtime/jobs/registry.d.ts +147 -0
  464. package/dist/runtime/jobs/registry.d.ts.map +1 -0
  465. package/dist/runtime/jobs/registry.js +242 -0
  466. package/dist/runtime/jobs/registry.js.map +1 -0
  467. package/dist/runtime/query/approval-policy.d.ts +22 -0
  468. package/dist/runtime/query/approval-policy.d.ts.map +1 -0
  469. package/dist/runtime/query/approval-policy.js +61 -0
  470. package/dist/runtime/query/approval-policy.js.map +1 -0
  471. package/dist/runtime/query/checkpoint.d.ts +3 -3
  472. package/dist/runtime/query/checkpoint.d.ts.map +1 -1
  473. package/dist/runtime/query/checkpoint.js +2 -2
  474. package/dist/runtime/query/checkpoint.js.map +1 -1
  475. package/dist/runtime/query/context.d.ts +85 -15
  476. package/dist/runtime/query/context.d.ts.map +1 -1
  477. package/dist/runtime/query/context.js +57 -14
  478. package/dist/runtime/query/context.js.map +1 -1
  479. package/dist/runtime/query/events.d.ts +5 -4
  480. package/dist/runtime/query/events.d.ts.map +1 -1
  481. package/dist/runtime/query/events.js +9 -6
  482. package/dist/runtime/query/events.js.map +1 -1
  483. package/dist/runtime/query/executor.d.ts +113 -4
  484. package/dist/runtime/query/executor.d.ts.map +1 -1
  485. package/dist/runtime/query/executor.js +228 -62
  486. package/dist/runtime/query/executor.js.map +1 -1
  487. package/dist/runtime/query/guardrail-presets.d.ts.map +1 -1
  488. package/dist/runtime/query/guardrail-presets.js +11 -14
  489. package/dist/runtime/query/guardrail-presets.js.map +1 -1
  490. package/dist/runtime/query/guardrails.d.ts.map +1 -1
  491. package/dist/runtime/query/guardrails.js +16 -12
  492. package/dist/runtime/query/guardrails.js.map +1 -1
  493. package/dist/runtime/query/index.d.ts +124 -16
  494. package/dist/runtime/query/index.d.ts.map +1 -1
  495. package/dist/runtime/query/index.js +372 -76
  496. package/dist/runtime/query/index.js.map +1 -1
  497. package/dist/runtime/query/iteration/index.d.ts +32 -0
  498. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  499. package/dist/runtime/query/iteration/index.js +256 -88
  500. package/dist/runtime/query/iteration/index.js.map +1 -1
  501. package/dist/runtime/query/iteration/phases/advisory.d.ts.map +1 -1
  502. package/dist/runtime/query/iteration/phases/advisory.js +17 -16
  503. package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
  504. package/dist/runtime/query/iteration/phases/compaction.d.ts +1 -8
  505. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  506. package/dist/runtime/query/iteration/phases/compaction.js +202 -178
  507. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  508. package/dist/runtime/query/iteration/phases/context.d.ts +52 -6
  509. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  510. package/dist/runtime/query/iteration/phases/context.js +26 -17
  511. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  512. package/dist/runtime/query/iteration/phases/tool-review.d.ts +2 -2
  513. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  514. package/dist/runtime/query/iteration/phases/tool-review.js +27 -7
  515. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  516. package/dist/runtime/query/iteration/phases/working-memory.d.ts.map +1 -1
  517. package/dist/runtime/query/iteration/phases/working-memory.js +3 -2
  518. package/dist/runtime/query/iteration/phases/working-memory.js.map +1 -1
  519. package/dist/runtime/query/iteration/stream-turn.js +14 -14
  520. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  521. package/dist/runtime/query/{context-cache.d.ts → prompt-cache.d.ts} +6 -4
  522. package/dist/runtime/query/prompt-cache.d.ts.map +1 -0
  523. package/dist/runtime/query/{context-cache.js → prompt-cache.js} +20 -2
  524. package/dist/runtime/query/prompt-cache.js.map +1 -0
  525. package/dist/runtime/query/prompt.d.ts +50 -0
  526. package/dist/runtime/query/prompt.d.ts.map +1 -1
  527. package/dist/runtime/query/prompt.js +83 -4
  528. package/dist/runtime/query/prompt.js.map +1 -1
  529. package/dist/runtime/query/repeat-call.d.ts +42 -0
  530. package/dist/runtime/query/repeat-call.d.ts.map +1 -0
  531. package/dist/runtime/query/repeat-call.js +107 -0
  532. package/dist/runtime/query/repeat-call.js.map +1 -0
  533. package/dist/runtime/query/replay/mutate.js +8 -1
  534. package/dist/runtime/query/replay/mutate.js.map +1 -1
  535. package/dist/runtime/query/result.d.ts +7 -0
  536. package/dist/runtime/query/result.d.ts.map +1 -1
  537. package/dist/runtime/query/result.js +38 -10
  538. package/dist/runtime/query/result.js.map +1 -1
  539. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  540. package/dist/runtime/query/resume-pending.js +19 -17
  541. package/dist/runtime/query/resume-pending.js.map +1 -1
  542. package/dist/runtime/query/resume-run.d.ts +2 -2
  543. package/dist/runtime/query/resume-run.d.ts.map +1 -1
  544. package/dist/runtime/query/run-state.d.ts +3 -3
  545. package/dist/runtime/query/run-state.d.ts.map +1 -1
  546. package/dist/runtime/query/run-state.js +2 -2
  547. package/dist/runtime/query/run-state.js.map +1 -1
  548. package/dist/runtime/query/tool-grants.d.ts +7 -0
  549. package/dist/runtime/query/tool-grants.d.ts.map +1 -1
  550. package/dist/runtime/query/tool-grants.js +1 -1
  551. package/dist/runtime/query/tool-grants.js.map +1 -1
  552. package/dist/runtime/query/tool-output-budget.js +34 -3
  553. package/dist/runtime/query/tool-output-budget.js.map +1 -1
  554. package/dist/runtime/query/tool-pause.d.ts.map +1 -1
  555. package/dist/runtime/query/tool-pause.js +2 -1
  556. package/dist/runtime/query/tool-pause.js.map +1 -1
  557. package/dist/runtime/query/tooling.d.ts +10 -2
  558. package/dist/runtime/query/tooling.d.ts.map +1 -1
  559. package/dist/runtime/query/tooling.js +3 -0
  560. package/dist/runtime/query/tooling.js.map +1 -1
  561. package/dist/sandbox/provider/local.d.ts +10 -0
  562. package/dist/sandbox/provider/local.d.ts.map +1 -1
  563. package/dist/sandbox/provider/local.js +77 -23
  564. package/dist/sandbox/provider/local.js.map +1 -1
  565. package/dist/sandbox/terminal.d.ts +130 -0
  566. package/dist/sandbox/terminal.d.ts.map +1 -0
  567. package/dist/sandbox/terminal.js +119 -0
  568. package/dist/sandbox/terminal.js.map +1 -0
  569. package/dist/{gateway → scheduler}/completion-inbox.d.ts +12 -5
  570. package/dist/scheduler/completion-inbox.d.ts.map +1 -0
  571. package/dist/{gateway → scheduler}/completion-inbox.js +19 -7
  572. package/dist/scheduler/completion-inbox.js.map +1 -0
  573. package/dist/scheduler/delegating.d.ts +90 -0
  574. package/dist/scheduler/delegating.d.ts.map +1 -0
  575. package/dist/scheduler/delegating.js +230 -0
  576. package/dist/scheduler/delegating.js.map +1 -0
  577. package/dist/{gateway → scheduler}/local.d.ts +10 -2
  578. package/dist/scheduler/local.d.ts.map +1 -0
  579. package/dist/{gateway → scheduler}/local.js +20 -11
  580. package/dist/scheduler/local.js.map +1 -0
  581. package/dist/session/actor-scope.d.ts +52 -0
  582. package/dist/session/actor-scope.d.ts.map +1 -0
  583. package/dist/session/actor-scope.js +112 -0
  584. package/dist/session/actor-scope.js.map +1 -0
  585. package/dist/session/errors.d.ts +31 -8
  586. package/dist/session/errors.d.ts.map +1 -1
  587. package/dist/session/errors.js +21 -1
  588. package/dist/session/errors.js.map +1 -1
  589. package/dist/session/handoff/assignment.d.ts +5 -5
  590. package/dist/session/handoff/assignment.d.ts.map +1 -1
  591. package/dist/session/handoff/broadcast.d.ts +8 -4
  592. package/dist/session/handoff/broadcast.d.ts.map +1 -1
  593. package/dist/session/handoff/broadcast.js +8 -9
  594. package/dist/session/handoff/broadcast.js.map +1 -1
  595. package/dist/session/handoff/index.d.ts +1 -1
  596. package/dist/session/handoff/index.d.ts.map +1 -1
  597. package/dist/session/handoff/index.js +1 -1
  598. package/dist/session/handoff/index.js.map +1 -1
  599. package/dist/session/handoff/single.d.ts +11 -7
  600. package/dist/session/handoff/single.d.ts.map +1 -1
  601. package/dist/session/handoff/single.js +5 -11
  602. package/dist/session/handoff/single.js.map +1 -1
  603. package/dist/session/migration/filesystem.d.ts +28 -0
  604. package/dist/session/migration/filesystem.d.ts.map +1 -1
  605. package/dist/session/migration/filesystem.js +44 -2
  606. package/dist/session/migration/filesystem.js.map +1 -1
  607. package/dist/session/migration/id-prefix.d.ts +39 -19
  608. package/dist/session/migration/id-prefix.d.ts.map +1 -1
  609. package/dist/session/migration/id-prefix.js +43 -22
  610. package/dist/session/migration/id-prefix.js.map +1 -1
  611. package/dist/session/migration/index.d.ts +6 -2
  612. package/dist/session/migration/index.d.ts.map +1 -1
  613. package/dist/session/migration/index.js +6 -2
  614. package/dist/session/migration/index.js.map +1 -1
  615. package/dist/session/migration/marker.d.ts.map +1 -1
  616. package/dist/session/migration/marker.js +21 -4
  617. package/dist/session/migration/marker.js.map +1 -1
  618. package/dist/session/retention/archive.d.ts.map +1 -1
  619. package/dist/session/retention/archive.js +13 -11
  620. package/dist/session/retention/archive.js.map +1 -1
  621. package/dist/session/workspace/git-worktree.d.ts.map +1 -1
  622. package/dist/session/workspace/git-worktree.js +17 -8
  623. package/dist/session/workspace/git-worktree.js.map +1 -1
  624. package/dist/skills/loader.d.ts +4 -2
  625. package/dist/skills/loader.d.ts.map +1 -1
  626. package/dist/skills/loader.js +36 -9
  627. package/dist/skills/loader.js.map +1 -1
  628. package/dist/skills/registry.d.ts +59 -1
  629. package/dist/skills/registry.d.ts.map +1 -1
  630. package/dist/skills/registry.js +154 -20
  631. package/dist/skills/registry.js.map +1 -1
  632. package/dist/store/attachment/index.d.ts +111 -0
  633. package/dist/store/attachment/index.d.ts.map +1 -0
  634. package/dist/store/attachment/index.js +94 -0
  635. package/dist/store/attachment/index.js.map +1 -0
  636. package/dist/store/config/index.d.ts +43 -0
  637. package/dist/store/config/index.d.ts.map +1 -0
  638. package/dist/store/config/index.js +51 -0
  639. package/dist/store/config/index.js.map +1 -0
  640. package/dist/store/feedback/conformance.d.ts +44 -0
  641. package/dist/store/feedback/conformance.d.ts.map +1 -0
  642. package/dist/store/feedback/conformance.js +127 -0
  643. package/dist/store/feedback/conformance.js.map +1 -0
  644. package/dist/store/feedback/disk.d.ts +46 -0
  645. package/dist/store/feedback/disk.d.ts.map +1 -0
  646. package/dist/store/feedback/disk.js +141 -0
  647. package/dist/store/feedback/disk.js.map +1 -0
  648. package/dist/store/feedback/index.d.ts +9 -0
  649. package/dist/store/feedback/index.d.ts.map +1 -0
  650. package/dist/store/feedback/index.js +5 -0
  651. package/dist/store/feedback/index.js.map +1 -0
  652. package/dist/store/feedback/memory.d.ts +33 -0
  653. package/dist/store/feedback/memory.d.ts.map +1 -0
  654. package/dist/store/feedback/memory.js +0 -0
  655. package/dist/store/feedback/memory.js.map +1 -0
  656. package/dist/store/feedback/types.d.ts +95 -0
  657. package/dist/store/feedback/types.d.ts.map +1 -0
  658. package/dist/store/feedback/types.js +27 -0
  659. package/dist/store/feedback/types.js.map +1 -0
  660. package/dist/store/index.d.ts +1 -0
  661. package/dist/store/index.d.ts.map +1 -1
  662. package/dist/store/index.js +4 -0
  663. package/dist/store/index.js.map +1 -1
  664. package/dist/store/kv/record-store.d.ts +54 -0
  665. package/dist/store/kv/record-store.d.ts.map +1 -0
  666. package/dist/store/kv/record-store.js +94 -0
  667. package/dist/store/kv/record-store.js.map +1 -0
  668. package/dist/store/memory/disk.d.ts +2 -0
  669. package/dist/store/memory/disk.d.ts.map +1 -1
  670. package/dist/store/memory/disk.js +36 -30
  671. package/dist/store/memory/disk.js.map +1 -1
  672. package/dist/store/run/checkpoint-disk.d.ts +4 -4
  673. package/dist/store/run/checkpoint-disk.d.ts.map +1 -1
  674. package/dist/store/run/checkpoint-disk.js +22 -1
  675. package/dist/store/run/checkpoint-disk.js.map +1 -1
  676. package/dist/store/run/checkpoint-memory.d.ts +4 -4
  677. package/dist/store/run/checkpoint-memory.d.ts.map +1 -1
  678. package/dist/store/run/checkpoint-memory.js.map +1 -1
  679. package/dist/store/run/claim-disk.d.ts +5 -5
  680. package/dist/store/run/claim-disk.d.ts.map +1 -1
  681. package/dist/store/run/claim-disk.js +20 -0
  682. package/dist/store/run/claim-disk.js.map +1 -1
  683. package/dist/store/run/conformance.d.ts.map +1 -1
  684. package/dist/store/run/conformance.js +10 -9
  685. package/dist/store/run/conformance.js.map +1 -1
  686. package/dist/store/run/disk.d.ts +3 -1
  687. package/dist/store/run/disk.d.ts.map +1 -1
  688. package/dist/store/run/disk.js +73 -4
  689. package/dist/store/run/disk.js.map +1 -1
  690. package/dist/store/run/listing.d.ts +4 -4
  691. package/dist/store/run/listing.d.ts.map +1 -1
  692. package/dist/store/run/listing.js.map +1 -1
  693. package/dist/store/run/memory.d.ts +5 -0
  694. package/dist/store/run/memory.d.ts.map +1 -1
  695. package/dist/store/run/memory.js +20 -1
  696. package/dist/store/run/memory.js.map +1 -1
  697. package/dist/store/session/canonical-path.d.ts +32 -0
  698. package/dist/store/session/canonical-path.d.ts.map +1 -0
  699. package/dist/store/session/canonical-path.js +46 -0
  700. package/dist/store/session/canonical-path.js.map +1 -0
  701. package/dist/store/session/disk.d.ts +46 -2
  702. package/dist/store/session/disk.d.ts.map +1 -1
  703. package/dist/store/session/disk.js +191 -205
  704. package/dist/store/session/disk.js.map +1 -1
  705. package/dist/store/session/memory.d.ts +10 -2
  706. package/dist/store/session/memory.d.ts.map +1 -1
  707. package/dist/store/session/memory.js +36 -4
  708. package/dist/store/session/memory.js.map +1 -1
  709. package/dist/store/task/disk.d.ts.map +1 -1
  710. package/dist/store/task/disk.js +76 -68
  711. package/dist/store/task/disk.js.map +1 -1
  712. package/dist/store/topic/index.d.ts +6 -0
  713. package/dist/store/topic/index.d.ts.map +1 -0
  714. package/dist/store/topic/index.js +20 -0
  715. package/dist/store/topic/index.js.map +1 -0
  716. package/dist/store/topic/memory.d.ts +30 -0
  717. package/dist/store/topic/memory.d.ts.map +1 -0
  718. package/dist/store/topic/memory.js +97 -0
  719. package/dist/store/topic/memory.js.map +1 -0
  720. package/dist/store/topic/objective.d.ts +104 -0
  721. package/dist/store/topic/objective.d.ts.map +1 -0
  722. package/dist/store/topic/objective.js +195 -0
  723. package/dist/store/topic/objective.js.map +1 -0
  724. package/dist/store/topic/state.d.ts +60 -0
  725. package/dist/store/topic/state.d.ts.map +1 -0
  726. package/dist/store/topic/state.js +128 -0
  727. package/dist/store/topic/state.js.map +1 -0
  728. package/dist/streaming/coalesce.d.ts +19 -6
  729. package/dist/streaming/coalesce.d.ts.map +1 -1
  730. package/dist/streaming/coalesce.js +13 -4
  731. package/dist/streaming/coalesce.js.map +1 -1
  732. package/dist/telemetry/runtime-accessors.d.ts +27 -1
  733. package/dist/telemetry/runtime-accessors.d.ts.map +1 -1
  734. package/dist/telemetry/runtime-accessors.js +45 -1
  735. package/dist/telemetry/runtime-accessors.js.map +1 -1
  736. package/dist/test-support/ids.d.ts +68 -0
  737. package/dist/test-support/ids.d.ts.map +1 -0
  738. package/dist/test-support/ids.js +70 -0
  739. package/dist/test-support/ids.js.map +1 -0
  740. package/dist/testing.d.ts +24 -0
  741. package/dist/testing.d.ts.map +1 -0
  742. package/dist/testing.js +22 -0
  743. package/dist/testing.js.map +1 -0
  744. package/dist/tools/builtins/bash.d.ts +1 -0
  745. package/dist/tools/builtins/bash.d.ts.map +1 -1
  746. package/dist/tools/builtins/bash.js +77 -3
  747. package/dist/tools/builtins/bash.js.map +1 -1
  748. package/dist/tools/builtins/edit.d.ts +1 -1
  749. package/dist/tools/builtins/edit.d.ts.map +1 -1
  750. package/dist/tools/builtins/edit.js +34 -0
  751. package/dist/tools/builtins/edit.js.map +1 -1
  752. package/dist/tools/builtins/index.d.ts +6 -0
  753. package/dist/tools/builtins/index.d.ts.map +1 -1
  754. package/dist/tools/builtins/index.js +24 -1
  755. package/dist/tools/builtins/index.js.map +1 -1
  756. package/dist/tools/builtins/job.d.ts +6 -0
  757. package/dist/tools/builtins/job.d.ts.map +1 -0
  758. package/dist/tools/builtins/job.js +114 -0
  759. package/dist/tools/builtins/job.js.map +1 -0
  760. package/dist/tools/builtins/lsp.d.ts +21 -0
  761. package/dist/tools/builtins/lsp.d.ts.map +1 -0
  762. package/dist/tools/builtins/lsp.js +186 -0
  763. package/dist/tools/builtins/lsp.js.map +1 -0
  764. package/dist/tools/builtins/run-code.d.ts +13 -0
  765. package/dist/tools/builtins/run-code.d.ts.map +1 -0
  766. package/dist/tools/builtins/run-code.js +126 -0
  767. package/dist/tools/builtins/run-code.js.map +1 -0
  768. package/dist/tools/builtins/skill.d.ts +14 -0
  769. package/dist/tools/builtins/skill.d.ts.map +1 -0
  770. package/dist/tools/builtins/skill.js +120 -0
  771. package/dist/tools/builtins/skill.js.map +1 -0
  772. package/dist/tools/builtins/web-guidance.d.ts +31 -0
  773. package/dist/tools/builtins/web-guidance.d.ts.map +1 -0
  774. package/dist/tools/builtins/web-guidance.js +42 -0
  775. package/dist/tools/builtins/web-guidance.js.map +1 -0
  776. package/dist/tools/builtins/web.d.ts +10 -0
  777. package/dist/tools/builtins/web.d.ts.map +1 -0
  778. package/dist/tools/builtins/web.js +137 -0
  779. package/dist/tools/builtins/web.js.map +1 -0
  780. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  781. package/dist/tools/builtins/write-file.js +35 -0
  782. package/dist/tools/builtins/write-file.js.map +1 -1
  783. package/dist/tools/coordinator/agent.d.ts +2 -2
  784. package/dist/tools/coordinator/agent.d.ts.map +1 -1
  785. package/dist/tools/coordinator/index.d.ts +13 -4
  786. package/dist/tools/coordinator/index.d.ts.map +1 -1
  787. package/dist/tools/coordinator/index.js +125 -38
  788. package/dist/tools/coordinator/index.js.map +1 -1
  789. package/dist/tools/coordinator/outcome.d.ts +2 -2
  790. package/dist/tools/coordinator/outcome.d.ts.map +1 -1
  791. package/dist/tools/coordinator/outcome.js +1 -1
  792. package/dist/tools/coordinator/wait-with-idle-bound.d.ts +3 -3
  793. package/dist/tools/coordinator/wait-with-idle-bound.d.ts.map +1 -1
  794. package/dist/tools/coordinator/wait-with-idle-bound.js.map +1 -1
  795. package/dist/tools/defineTool.d.ts +12 -0
  796. package/dist/tools/defineTool.d.ts.map +1 -1
  797. package/dist/tools/defineTool.js +2 -0
  798. package/dist/tools/defineTool.js.map +1 -1
  799. package/dist/tools/env-scrub.d.ts +66 -0
  800. package/dist/tools/env-scrub.d.ts.map +1 -0
  801. package/dist/tools/env-scrub.js +68 -0
  802. package/dist/tools/env-scrub.js.map +1 -0
  803. package/dist/tools/memory/read.d.ts.map +1 -1
  804. package/dist/tools/memory/read.js +5 -1
  805. package/dist/tools/memory/read.js.map +1 -1
  806. package/dist/tools/task/create.d.ts.map +1 -1
  807. package/dist/tools/task/create.js +2 -1
  808. package/dist/tools/task/create.js.map +1 -1
  809. package/dist/tools/task/update.d.ts.map +1 -1
  810. package/dist/tools/task/update.js +7 -3
  811. package/dist/tools/task/update.js.map +1 -1
  812. package/dist/types/acp/index.d.ts +161 -0
  813. package/dist/types/acp/index.d.ts.map +1 -0
  814. package/dist/types/acp/index.js +2 -0
  815. package/dist/types/acp/index.js.map +1 -0
  816. package/dist/types/agent/base.d.ts +62 -5
  817. package/dist/types/agent/base.d.ts.map +1 -1
  818. package/dist/types/agent/delegate.d.ts +102 -0
  819. package/dist/types/agent/delegate.d.ts.map +1 -0
  820. package/dist/types/agent/delegate.js +2 -0
  821. package/dist/types/agent/delegate.js.map +1 -0
  822. package/dist/types/agent/index.d.ts +1 -1
  823. package/dist/types/agent/index.d.ts.map +1 -1
  824. package/dist/types/agent/index.js +1 -1
  825. package/dist/types/agent/index.js.map +1 -1
  826. package/dist/types/agent/manager.d.ts +7 -1
  827. package/dist/types/agent/manager.d.ts.map +1 -1
  828. package/dist/types/agent/reactive.d.ts +19 -3
  829. package/dist/types/agent/reactive.d.ts.map +1 -1
  830. package/dist/types/agent/{gateway.d.ts → scheduler.d.ts} +31 -5
  831. package/dist/types/agent/scheduler.d.ts.map +1 -0
  832. package/dist/types/agent/scheduler.js +2 -0
  833. package/dist/types/agent/scheduler.js.map +1 -0
  834. package/dist/types/agent/supervisor.d.ts +13 -5
  835. package/dist/types/agent/supervisor.d.ts.map +1 -1
  836. package/dist/types/agent/task.d.ts +31 -9
  837. package/dist/types/agent/task.d.ts.map +1 -1
  838. package/dist/types/agent/working-memory.d.ts +1 -1
  839. package/dist/types/{verification → authorization}/index.d.ts +68 -12
  840. package/dist/types/authorization/index.d.ts.map +1 -0
  841. package/dist/types/authorization/index.js +99 -0
  842. package/dist/types/authorization/index.js.map +1 -0
  843. package/dist/types/bus/index.d.ts +24 -1
  844. package/dist/types/bus/index.d.ts.map +1 -1
  845. package/dist/types/code-navigation/index.d.ts +112 -0
  846. package/dist/types/code-navigation/index.d.ts.map +1 -0
  847. package/dist/types/code-navigation/index.js +17 -0
  848. package/dist/types/code-navigation/index.js.map +1 -0
  849. package/dist/types/command/index.d.ts +74 -0
  850. package/dist/types/command/index.d.ts.map +1 -0
  851. package/dist/types/command/index.js +18 -0
  852. package/dist/types/command/index.js.map +1 -0
  853. package/dist/types/common/index.d.ts +11 -2
  854. package/dist/types/common/index.d.ts.map +1 -1
  855. package/dist/types/common/index.js.map +1 -1
  856. package/dist/types/connector/mcp.d.ts +8 -0
  857. package/dist/types/connector/mcp.d.ts.map +1 -1
  858. package/dist/types/guardrail/index.d.ts +1 -1
  859. package/dist/types/hitl/policy.d.ts +79 -0
  860. package/dist/types/hitl/policy.d.ts.map +1 -0
  861. package/dist/types/hitl/policy.js +2 -0
  862. package/dist/types/hitl/policy.js.map +1 -0
  863. package/dist/types/ids/brand.d.ts +55 -0
  864. package/dist/types/ids/brand.d.ts.map +1 -0
  865. package/dist/types/ids/brand.js +45 -0
  866. package/dist/types/ids/brand.js.map +1 -0
  867. package/dist/types/ids/index.d.ts +83 -39
  868. package/dist/types/ids/index.d.ts.map +1 -1
  869. package/dist/types/ids/index.js +5 -1
  870. package/dist/types/ids/index.js.map +1 -1
  871. package/dist/types/message/index.d.ts +24 -1
  872. package/dist/types/message/index.d.ts.map +1 -1
  873. package/dist/types/message/index.js.map +1 -1
  874. package/dist/types/plugin/index.d.ts +8 -8
  875. package/dist/types/project/entity.d.ts +22 -2
  876. package/dist/types/project/entity.d.ts.map +1 -1
  877. package/dist/types/provider/interface.d.ts +43 -2
  878. package/dist/types/provider/interface.d.ts.map +1 -1
  879. package/dist/types/provider/model.d.ts +16 -2
  880. package/dist/types/provider/model.d.ts.map +1 -1
  881. package/dist/types/run/audit.d.ts +150 -0
  882. package/dist/types/run/audit.d.ts.map +1 -0
  883. package/dist/types/run/audit.js +39 -0
  884. package/dist/types/run/audit.js.map +1 -0
  885. package/dist/types/run/cancel-cause.d.ts +49 -0
  886. package/dist/types/run/cancel-cause.d.ts.map +1 -0
  887. package/dist/types/run/cancel-cause.js +39 -0
  888. package/dist/types/run/cancel-cause.js.map +1 -0
  889. package/dist/types/run/checkpoint-store.d.ts +23 -11
  890. package/dist/types/run/checkpoint-store.d.ts.map +1 -1
  891. package/dist/types/run/config.d.ts +24 -4
  892. package/dist/types/run/config.d.ts.map +1 -1
  893. package/dist/types/run/derive-status.d.ts +3 -3
  894. package/dist/types/run/derive-status.d.ts.map +1 -1
  895. package/dist/types/run/derive-status.js +1 -1
  896. package/dist/types/run/entity.d.ts +2 -3
  897. package/dist/types/run/entity.d.ts.map +1 -1
  898. package/dist/types/run/event-cursor.d.ts +3 -3
  899. package/dist/types/run/event-cursor.d.ts.map +1 -1
  900. package/dist/types/run/events.d.ts +159 -4
  901. package/dist/types/run/events.d.ts.map +1 -1
  902. package/dist/types/run/events.js.map +1 -1
  903. package/dist/types/run/index.d.ts +2 -0
  904. package/dist/types/run/index.d.ts.map +1 -1
  905. package/dist/types/run/index.js +2 -0
  906. package/dist/types/run/index.js.map +1 -1
  907. package/dist/types/run/metadata.d.ts +2 -2
  908. package/dist/types/run/metadata.d.ts.map +1 -1
  909. package/dist/types/run/prepare-step.d.ts +29 -0
  910. package/dist/types/run/prepare-step.d.ts.map +1 -1
  911. package/dist/types/run/state.d.ts +33 -10
  912. package/dist/types/run/state.d.ts.map +1 -1
  913. package/dist/types/run/state.js +60 -3
  914. package/dist/types/run/state.js.map +1 -1
  915. package/dist/types/run/stop-reason.d.ts +9 -0
  916. package/dist/types/run/stop-reason.d.ts.map +1 -1
  917. package/dist/types/run/store.d.ts +38 -0
  918. package/dist/types/run/store.d.ts.map +1 -1
  919. package/dist/types/sandbox/index.d.ts +38 -0
  920. package/dist/types/sandbox/index.d.ts.map +1 -1
  921. package/dist/types/sandbox/index.js +21 -0
  922. package/dist/types/sandbox/index.js.map +1 -1
  923. package/dist/types/session/actor.d.ts +2 -2
  924. package/dist/types/session/actor.d.ts.map +1 -1
  925. package/dist/types/session/entity.d.ts +9 -7
  926. package/dist/types/session/entity.d.ts.map +1 -1
  927. package/dist/types/session/ids.d.ts +1 -1
  928. package/dist/types/session/ids.d.ts.map +1 -1
  929. package/dist/types/session/index.d.ts +2 -2
  930. package/dist/types/session/index.d.ts.map +1 -1
  931. package/dist/types/session/store.d.ts +51 -22
  932. package/dist/types/session/store.d.ts.map +1 -1
  933. package/dist/types/session/sub-session.d.ts +44 -5
  934. package/dist/types/session/sub-session.d.ts.map +1 -1
  935. package/dist/types/skills/index.d.ts +41 -0
  936. package/dist/types/skills/index.d.ts.map +1 -1
  937. package/dist/types/skills/index.js +17 -1
  938. package/dist/types/skills/index.js.map +1 -1
  939. package/dist/types/tool/index.d.ts +175 -1
  940. package/dist/types/tool/index.d.ts.map +1 -1
  941. package/dist/types/tool/index.js.map +1 -1
  942. package/dist/types/tool/presentation.d.ts +53 -0
  943. package/dist/types/tool/presentation.d.ts.map +1 -0
  944. package/dist/types/tool/presentation.js +2 -0
  945. package/dist/types/tool/presentation.js.map +1 -0
  946. package/dist/types/{thread → topic}/entity.d.ts +34 -26
  947. package/dist/types/topic/entity.d.ts.map +1 -0
  948. package/dist/types/{thread → topic}/entity.js.map +1 -1
  949. package/dist/types/topic/index.d.ts +5 -0
  950. package/dist/types/topic/index.d.ts.map +1 -0
  951. package/dist/types/topic/index.js +11 -0
  952. package/dist/types/topic/index.js.map +1 -0
  953. package/dist/types/topic/objective.d.ts +86 -0
  954. package/dist/types/topic/objective.d.ts.map +1 -0
  955. package/dist/types/topic/objective.js +10 -0
  956. package/dist/types/topic/objective.js.map +1 -0
  957. package/dist/types/topic/state.d.ts +56 -0
  958. package/dist/types/topic/state.d.ts.map +1 -0
  959. package/dist/types/topic/state.js +10 -0
  960. package/dist/types/topic/state.js.map +1 -0
  961. package/dist/types/topic/store.d.ts +95 -0
  962. package/dist/types/topic/store.d.ts.map +1 -0
  963. package/dist/types/topic/store.js +29 -0
  964. package/dist/types/topic/store.js.map +1 -0
  965. package/dist/types/workspace/ref.d.ts +7 -0
  966. package/dist/types/workspace/ref.d.ts.map +1 -1
  967. package/dist/utils/abort.d.ts.map +1 -1
  968. package/dist/utils/abort.js +13 -1
  969. package/dist/utils/abort.js.map +1 -1
  970. package/dist/utils/hash.d.ts +10 -0
  971. package/dist/utils/hash.d.ts.map +1 -1
  972. package/dist/utils/hash.js +15 -0
  973. package/dist/utils/hash.js.map +1 -1
  974. package/dist/utils/id.d.ts +82 -2
  975. package/dist/utils/id.d.ts.map +1 -1
  976. package/dist/utils/id.js +104 -4
  977. package/dist/utils/id.js.map +1 -1
  978. package/dist/utils/log/attributes.d.ts +17 -0
  979. package/dist/utils/log/attributes.d.ts.map +1 -0
  980. package/dist/utils/log/attributes.js +2 -0
  981. package/dist/utils/log/attributes.js.map +1 -0
  982. package/dist/utils/log/caps.d.ts +27 -0
  983. package/dist/utils/log/caps.d.ts.map +1 -0
  984. package/dist/utils/log/caps.js +107 -0
  985. package/dist/utils/log/caps.js.map +1 -0
  986. package/dist/utils/log/create-logger.d.ts +28 -0
  987. package/dist/utils/log/create-logger.d.ts.map +1 -0
  988. package/dist/utils/log/create-logger.js +168 -0
  989. package/dist/utils/log/create-logger.js.map +1 -0
  990. package/dist/utils/log/exception.d.ts +11 -0
  991. package/dist/utils/log/exception.d.ts.map +1 -0
  992. package/dist/utils/log/exception.js +108 -0
  993. package/dist/utils/log/exception.js.map +1 -0
  994. package/dist/utils/log/index.d.ts +7 -0
  995. package/dist/utils/log/index.d.ts.map +1 -0
  996. package/dist/utils/log/index.js +15 -0
  997. package/dist/utils/log/index.js.map +1 -0
  998. package/dist/utils/log/process-sink.d.ts +28 -0
  999. package/dist/utils/log/process-sink.d.ts.map +1 -0
  1000. package/dist/utils/log/process-sink.js +56 -0
  1001. package/dist/utils/log/process-sink.js.map +1 -0
  1002. package/dist/utils/log/redact.d.ts +3 -0
  1003. package/dist/utils/log/redact.d.ts.map +1 -0
  1004. package/dist/utils/log/redact.js +71 -0
  1005. package/dist/utils/log/redact.js.map +1 -0
  1006. package/dist/utils/log/sinks.d.ts +43 -0
  1007. package/dist/utils/log/sinks.d.ts.map +1 -0
  1008. package/dist/utils/log/sinks.js +184 -0
  1009. package/dist/utils/log/sinks.js.map +1 -0
  1010. package/dist/utils/log/templates.d.ts +63 -0
  1011. package/dist/utils/log/templates.d.ts.map +1 -0
  1012. package/dist/utils/log/templates.js +119 -0
  1013. package/dist/utils/log/templates.js.map +1 -0
  1014. package/dist/utils/log/types.d.ts +183 -0
  1015. package/dist/utils/log/types.d.ts.map +1 -0
  1016. package/dist/utils/log/types.js +55 -0
  1017. package/dist/utils/log/types.js.map +1 -0
  1018. package/dist/utils/logger.d.ts +44 -0
  1019. package/dist/utils/logger.d.ts.map +1 -1
  1020. package/dist/utils/logger.js +102 -2
  1021. package/dist/utils/logger.js.map +1 -1
  1022. package/dist/utils/renamed-field.d.ts +19 -0
  1023. package/dist/utils/renamed-field.d.ts.map +1 -0
  1024. package/dist/utils/renamed-field.js +29 -0
  1025. package/dist/utils/renamed-field.js.map +1 -0
  1026. package/dist/vault/CredentialProvider.d.ts +89 -0
  1027. package/dist/vault/CredentialProvider.d.ts.map +1 -0
  1028. package/dist/vault/CredentialProvider.js +64 -0
  1029. package/dist/vault/CredentialProvider.js.map +1 -0
  1030. package/dist/vault/InMemoryCredentialVault.d.ts +2 -1
  1031. package/dist/vault/InMemoryCredentialVault.d.ts.map +1 -1
  1032. package/dist/vault/InMemoryCredentialVault.js +15 -5
  1033. package/dist/vault/InMemoryCredentialVault.js.map +1 -1
  1034. package/dist/vault/index.d.ts +3 -0
  1035. package/dist/vault/index.d.ts.map +1 -1
  1036. package/dist/vault/index.js +5 -0
  1037. package/dist/vault/index.js.map +1 -1
  1038. package/dist/vault/instrumentation.d.ts +18 -2
  1039. package/dist/vault/instrumentation.d.ts.map +1 -1
  1040. package/dist/vault/instrumentation.js +47 -0
  1041. package/dist/vault/instrumentation.js.map +1 -1
  1042. package/package.json +4 -4
  1043. package/src/advisory/executor.ts +14 -12
  1044. package/src/advisory/registry.ts +2 -2
  1045. package/src/agents/AGENTS.md +91 -0
  1046. package/src/agents/AbstractAgent.ts +67 -14
  1047. package/src/agents/PipelineAgent.ts +46 -12
  1048. package/src/agents/ReactiveAgent.ts +27 -14
  1049. package/src/agents/RouterAgent.ts +33 -21
  1050. package/src/agents/SupervisorAgent.ts +46 -28
  1051. package/src/agents/handle.ts +149 -0
  1052. package/src/agents/runAgent.ts +14 -7
  1053. package/src/{verification → authorization}/gate.ts +39 -32
  1054. package/src/authorization/index.ts +26 -0
  1055. package/src/authorization/permission-presets.ts +215 -0
  1056. package/src/{verification → authorization}/presets.ts +15 -3
  1057. package/src/{verification → authorization}/rules.ts +16 -3
  1058. package/src/bridge/a2a/client.ts +369 -0
  1059. package/src/bridge/a2a/mapper.ts +17 -0
  1060. package/src/bridge/acp/filesystem.ts +63 -0
  1061. package/src/bridge/acp/index.ts +11 -0
  1062. package/src/bridge/acp/permission.ts +71 -0
  1063. package/src/bridge/acp/server.ts +500 -0
  1064. package/src/bridge/acp/update.ts +109 -0
  1065. package/src/bridge/mcp/connector/adapter.ts +8 -4
  1066. package/src/bridge/sse/mapper.ts +30 -0
  1067. package/src/bus/breaker.ts +15 -10
  1068. package/src/bus/index.ts +10 -8
  1069. package/src/bus/lock.ts +36 -19
  1070. package/src/bus/ownership.ts +17 -9
  1071. package/src/compaction/context-window.ts +23 -1
  1072. package/src/compaction/index.ts +6 -0
  1073. package/src/compaction/manual.ts +177 -0
  1074. package/src/compaction/plan.ts +226 -0
  1075. package/src/compaction/summary.ts +31 -0
  1076. package/src/compaction/verifier.ts +2 -2
  1077. package/src/config/registry.ts +208 -0
  1078. package/src/config/runtime.ts +27 -0
  1079. package/src/connector/BaseConnector.ts +8 -3
  1080. package/src/connector/builtins/http.ts +12 -2
  1081. package/src/connector/builtins/webhook.ts +6 -2
  1082. package/src/connector/index.ts +45 -29
  1083. package/src/connector/mcp/client.ts +32 -20
  1084. package/src/connector/mcp/discovery.ts +31 -20
  1085. package/src/connector/mcp/http-sse.ts +12 -6
  1086. package/src/connector/mcp/index.ts +8 -7
  1087. package/src/connector/mcp/reconnect.ts +194 -0
  1088. package/src/connector/mcp/server/index.ts +32 -0
  1089. package/src/connector/mcp/{server-stdio.ts → server/server-stdio.ts} +5 -4
  1090. package/src/connector/mcp/{server.ts → server/server.ts} +17 -11
  1091. package/src/connector/mcp/stdio.ts +18 -9
  1092. package/src/connector/mcp/streamable-http.ts +8 -4
  1093. package/src/{bridge/tools/connector → connector/tools}/adapter.ts +5 -5
  1094. package/src/{bridge/tools/connector → connector/tools}/definitions.ts +4 -4
  1095. package/src/{bridge/tools/connector → connector/tools}/router.ts +17 -9
  1096. package/src/connector/web/guarded-fetch.ts +288 -0
  1097. package/src/connector/web/index.ts +17 -0
  1098. package/src/connector/web/types.ts +99 -0
  1099. package/src/constants/acp/index.ts +104 -0
  1100. package/src/constants/credential-env-keys.ts +63 -0
  1101. package/src/constants/index.ts +3 -1
  1102. package/src/constants/secret-patterns.ts +102 -0
  1103. package/src/constants/telemetry/index.ts +98 -0
  1104. package/src/contracts/api.ts +11 -0
  1105. package/src/eval/judge.ts +2 -2
  1106. package/src/execution/base.ts +18 -7
  1107. package/src/execution/code-runtime/types.ts +116 -0
  1108. package/src/execution/code-runtime/worker.ts +266 -0
  1109. package/src/{connector/execution → execution}/factory.ts +3 -3
  1110. package/src/{connector/execution → execution}/hybrid.ts +13 -7
  1111. package/src/execution/index.ts +24 -0
  1112. package/src/execution/local.ts +4 -2
  1113. package/src/{connector/execution → execution}/remote.ts +15 -8
  1114. package/src/index.ts +17 -0
  1115. package/src/invariants/index.ts +201 -0
  1116. package/src/manager/agent/lifecycle.ts +172 -58
  1117. package/src/manager/connector/environment.ts +22 -11
  1118. package/src/manager/connector/lifecycle.ts +30 -11
  1119. package/src/manager/connector/tenant.ts +33 -14
  1120. package/src/manager/index.ts +15 -2
  1121. package/src/manager/project/lifecycle.ts +1 -1
  1122. package/src/manager/run/emergency.ts +9 -7
  1123. package/src/manager/run/persistence.ts +110 -8
  1124. package/src/manager/topic/lifecycle.ts +235 -0
  1125. package/src/manager/topic/objective.ts +203 -0
  1126. package/src/persona/assembler.ts +14 -3
  1127. package/src/plugin/lifecycle.ts +156 -20
  1128. package/src/plugin/loader.ts +67 -16
  1129. package/src/probe/index.ts +1 -0
  1130. package/src/probe/registry.ts +41 -5
  1131. package/src/process/kill-tree.ts +52 -0
  1132. package/src/prompt/contributions.ts +173 -0
  1133. package/src/prompt/index.ts +15 -0
  1134. package/src/provider/attribution.ts +57 -0
  1135. package/src/provider/{collect.ts → collect-chat-completion.ts} +4 -2
  1136. package/src/provider/conformance.ts +189 -0
  1137. package/src/provider/errors.ts +27 -12
  1138. package/src/provider/fallback.ts +32 -10
  1139. package/src/provider/idle-timeout.ts +112 -0
  1140. package/src/provider/instrumentation.ts +4 -2
  1141. package/src/provider/retry.ts +63 -21
  1142. package/src/public-runtime.ts +371 -18
  1143. package/src/public-tools.ts +41 -1
  1144. package/src/public-types.ts +101 -4
  1145. package/src/rag/rag-tool.ts +4 -2
  1146. package/src/read-model/index.ts +14 -0
  1147. package/src/read-model/registry.ts +152 -0
  1148. package/src/read-model/run-status.ts +127 -0
  1149. package/src/registry/{Registry.ts → BaseRegistry.ts} +1 -1
  1150. package/src/registry/ManagedRegistry.ts +26 -9
  1151. package/src/registry/command/index-exports.ts +4 -0
  1152. package/src/registry/command/index.ts +105 -0
  1153. package/src/registry/command/kernel-commands.ts +110 -0
  1154. package/src/registry/connector/scoped.ts +6 -5
  1155. package/src/registry/index.ts +7 -1
  1156. package/src/registry/tool/execute.ts +15 -12
  1157. package/src/registry/tool/presentation.ts +116 -0
  1158. package/src/registry/tool/screen.ts +12 -11
  1159. package/src/run/drain.ts +13 -3
  1160. package/src/run/reporter.ts +208 -153
  1161. package/src/run-query/index.ts +108 -0
  1162. package/src/runtime/bidi/session.ts +7 -2
  1163. package/src/runtime/decision/fallback.ts +6 -3
  1164. package/src/runtime/decision/parser.ts +10 -9
  1165. package/src/runtime/jobs/registry.ts +346 -0
  1166. package/src/runtime/query/approval-policy.ts +78 -0
  1167. package/src/runtime/query/checkpoint.ts +6 -6
  1168. package/src/runtime/query/context.ts +120 -30
  1169. package/src/runtime/query/events.ts +19 -11
  1170. package/src/runtime/query/executor.ts +287 -66
  1171. package/src/runtime/query/guardrail-presets.ts +11 -14
  1172. package/src/runtime/query/guardrails.ts +16 -12
  1173. package/src/runtime/query/index.ts +539 -96
  1174. package/src/runtime/query/iteration/index.ts +269 -87
  1175. package/src/runtime/query/iteration/phases/advisory.ts +17 -16
  1176. package/src/runtime/query/iteration/phases/compaction.ts +235 -187
  1177. package/src/runtime/query/iteration/phases/context.ts +82 -21
  1178. package/src/runtime/query/iteration/phases/tool-review.ts +28 -9
  1179. package/src/runtime/query/iteration/phases/working-memory.ts +3 -2
  1180. package/src/runtime/query/iteration/stream-turn.ts +14 -14
  1181. package/src/runtime/query/{context-cache.ts → prompt-cache.ts} +23 -3
  1182. package/src/runtime/query/prompt.ts +104 -4
  1183. package/src/runtime/query/repeat-call.ts +130 -0
  1184. package/src/runtime/query/replay/mutate.ts +6 -0
  1185. package/src/runtime/query/result.ts +47 -10
  1186. package/src/runtime/query/resume-pending.ts +19 -17
  1187. package/src/runtime/query/resume-run.ts +2 -2
  1188. package/src/runtime/query/run-state.ts +5 -5
  1189. package/src/runtime/query/tool-grants.ts +1 -1
  1190. package/src/runtime/query/tool-output-budget.ts +36 -3
  1191. package/src/runtime/query/tool-pause.ts +2 -1
  1192. package/src/runtime/query/tooling.ts +17 -2
  1193. package/src/sandbox/provider/local.ts +94 -21
  1194. package/src/sandbox/terminal.ts +197 -0
  1195. package/src/{gateway → scheduler}/completion-inbox.ts +20 -10
  1196. package/src/scheduler/delegating.ts +297 -0
  1197. package/src/{gateway → scheduler}/local.ts +24 -15
  1198. package/src/session/actor-scope.ts +121 -0
  1199. package/src/session/errors.ts +30 -8
  1200. package/src/session/handoff/assignment.ts +5 -5
  1201. package/src/session/handoff/broadcast.ts +16 -12
  1202. package/src/session/handoff/index.ts +1 -1
  1203. package/src/session/handoff/single.ts +16 -17
  1204. package/src/session/migration/filesystem.ts +46 -2
  1205. package/src/session/migration/id-prefix.ts +47 -22
  1206. package/src/session/migration/index.ts +5 -2
  1207. package/src/session/migration/marker.ts +19 -4
  1208. package/src/session/retention/archive.ts +19 -12
  1209. package/src/session/workspace/git-worktree.ts +17 -8
  1210. package/src/skills/loader.ts +39 -9
  1211. package/src/skills/registry.ts +177 -20
  1212. package/src/store/attachment/index.ts +182 -0
  1213. package/src/store/config/index.ts +74 -0
  1214. package/src/store/feedback/conformance.ts +193 -0
  1215. package/src/store/feedback/disk.ts +184 -0
  1216. package/src/store/feedback/index.ts +13 -0
  1217. package/src/store/feedback/memory.ts +0 -0
  1218. package/src/store/feedback/types.ts +107 -0
  1219. package/src/store/index.ts +5 -0
  1220. package/src/store/kv/record-store.ts +91 -0
  1221. package/src/store/memory/disk.ts +35 -32
  1222. package/src/store/run/checkpoint-disk.ts +27 -6
  1223. package/src/store/run/checkpoint-memory.ts +8 -8
  1224. package/src/store/run/claim-disk.ts +58 -13
  1225. package/src/store/run/conformance.ts +11 -10
  1226. package/src/store/run/disk.ts +77 -5
  1227. package/src/store/run/listing.ts +6 -6
  1228. package/src/store/run/memory.ts +24 -1
  1229. package/src/store/session/canonical-path.ts +45 -0
  1230. package/src/store/session/disk.ts +216 -191
  1231. package/src/store/session/memory.ts +43 -5
  1232. package/src/store/task/disk.ts +77 -67
  1233. package/src/store/topic/index.ts +33 -0
  1234. package/src/store/topic/memory.ts +111 -0
  1235. package/src/store/topic/objective.ts +290 -0
  1236. package/src/store/topic/state.ts +204 -0
  1237. package/src/streaming/coalesce.ts +19 -5
  1238. package/src/telemetry/runtime-accessors.ts +45 -1
  1239. package/src/test-support/ids.ts +117 -0
  1240. package/src/testing.ts +40 -0
  1241. package/src/tools/builtins/bash.ts +82 -3
  1242. package/src/tools/builtins/edit.ts +36 -0
  1243. package/src/tools/builtins/index.ts +29 -1
  1244. package/src/tools/builtins/job.ts +133 -0
  1245. package/src/tools/builtins/lsp.ts +214 -0
  1246. package/src/tools/builtins/run-code.ts +154 -0
  1247. package/src/tools/builtins/skill.ts +134 -0
  1248. package/src/tools/builtins/web-guidance.ts +46 -0
  1249. package/src/tools/builtins/web.ts +156 -0
  1250. package/src/tools/builtins/write-file.ts +37 -1
  1251. package/src/tools/coordinator/agent.ts +2 -2
  1252. package/src/tools/coordinator/index.ts +144 -40
  1253. package/src/tools/coordinator/outcome.ts +2 -2
  1254. package/src/tools/coordinator/wait-with-idle-bound.ts +3 -3
  1255. package/src/tools/defineTool.ts +14 -0
  1256. package/src/tools/env-scrub.ts +91 -0
  1257. package/src/tools/memory/read.ts +5 -2
  1258. package/src/tools/task/create.ts +2 -1
  1259. package/src/tools/task/update.ts +7 -4
  1260. package/src/types/acp/index.ts +163 -0
  1261. package/src/types/agent/base.ts +67 -5
  1262. package/src/types/agent/delegate.ts +110 -0
  1263. package/src/types/agent/index.ts +1 -1
  1264. package/src/types/agent/manager.ts +7 -1
  1265. package/src/types/agent/reactive.ts +22 -3
  1266. package/src/types/agent/{gateway.ts → scheduler.ts} +30 -4
  1267. package/src/types/agent/supervisor.ts +15 -5
  1268. package/src/types/agent/task.ts +31 -9
  1269. package/src/types/agent/working-memory.ts +1 -1
  1270. package/src/types/{verification → authorization}/index.ts +69 -10
  1271. package/src/types/bus/index.ts +30 -1
  1272. package/src/types/code-navigation/index.ts +99 -0
  1273. package/src/types/command/index.ts +68 -0
  1274. package/src/types/common/index.ts +17 -2
  1275. package/src/types/connector/mcp.ts +8 -0
  1276. package/src/types/guardrail/index.ts +1 -1
  1277. package/src/types/hitl/policy.ts +83 -0
  1278. package/src/types/ids/brand.ts +58 -0
  1279. package/src/types/ids/index.ts +94 -42
  1280. package/src/types/message/index.ts +25 -1
  1281. package/src/types/project/entity.ts +22 -2
  1282. package/src/types/provider/interface.ts +45 -2
  1283. package/src/types/provider/model.ts +16 -2
  1284. package/src/types/run/audit.ts +164 -0
  1285. package/src/types/run/cancel-cause.ts +60 -0
  1286. package/src/types/run/checkpoint-store.ts +24 -11
  1287. package/src/types/run/config.ts +25 -4
  1288. package/src/types/run/derive-status.ts +3 -3
  1289. package/src/types/run/entity.ts +2 -4
  1290. package/src/types/run/event-cursor.ts +3 -3
  1291. package/src/types/run/events.ts +165 -6
  1292. package/src/types/run/index.ts +2 -0
  1293. package/src/types/run/metadata.ts +2 -2
  1294. package/src/types/run/prepare-step.ts +33 -0
  1295. package/src/types/run/state.ts +78 -11
  1296. package/src/types/run/stop-reason.ts +9 -0
  1297. package/src/types/run/store.ts +40 -0
  1298. package/src/types/sandbox/index.ts +37 -0
  1299. package/src/types/session/actor.ts +10 -2
  1300. package/src/types/session/entity.ts +9 -7
  1301. package/src/types/session/ids.ts +1 -1
  1302. package/src/types/session/index.ts +1 -1
  1303. package/src/types/session/store.ts +53 -22
  1304. package/src/types/session/sub-session.ts +45 -16
  1305. package/src/types/skills/index.ts +50 -0
  1306. package/src/types/tool/index.ts +156 -1
  1307. package/src/types/tool/presentation.ts +48 -0
  1308. package/src/types/{thread → topic}/entity.ts +34 -26
  1309. package/src/types/topic/index.ts +23 -0
  1310. package/src/types/topic/objective.ts +93 -0
  1311. package/src/types/topic/state.ts +60 -0
  1312. package/src/types/topic/store.ts +101 -0
  1313. package/src/types/workspace/ref.ts +7 -0
  1314. package/src/utils/abort.ts +16 -1
  1315. package/src/utils/hash.ts +16 -0
  1316. package/src/utils/id.ts +163 -12
  1317. package/src/utils/log/attributes.ts +47 -0
  1318. package/src/utils/log/caps.ts +118 -0
  1319. package/src/utils/log/create-logger.ts +198 -0
  1320. package/src/utils/log/exception.ts +124 -0
  1321. package/src/utils/log/index.ts +24 -0
  1322. package/src/utils/log/process-sink.ts +76 -0
  1323. package/src/utils/log/redact.ts +77 -0
  1324. package/src/utils/log/sinks.ts +205 -0
  1325. package/src/utils/log/templates.ts +161 -0
  1326. package/src/utils/log/types.ts +195 -0
  1327. package/src/utils/logger.ts +121 -2
  1328. package/src/utils/renamed-field.ts +35 -0
  1329. package/src/vault/CredentialProvider.ts +147 -0
  1330. package/src/vault/InMemoryCredentialVault.ts +16 -5
  1331. package/src/vault/index.ts +16 -0
  1332. package/src/vault/instrumentation.ts +63 -2
  1333. package/dist/bridge/tools/connector/adapter.d.ts.map +0 -1
  1334. package/dist/bridge/tools/connector/adapter.js.map +0 -1
  1335. package/dist/bridge/tools/connector/definitions.d.ts.map +0 -1
  1336. package/dist/bridge/tools/connector/definitions.js.map +0 -1
  1337. package/dist/bridge/tools/connector/index.d.ts.map +0 -1
  1338. package/dist/bridge/tools/connector/index.js.map +0 -1
  1339. package/dist/bridge/tools/connector/router.d.ts.map +0 -1
  1340. package/dist/bridge/tools/connector/router.js.map +0 -1
  1341. package/dist/connector/execution/factory.d.ts.map +0 -1
  1342. package/dist/connector/execution/factory.js.map +0 -1
  1343. package/dist/connector/execution/hybrid.d.ts.map +0 -1
  1344. package/dist/connector/execution/hybrid.js.map +0 -1
  1345. package/dist/connector/execution/index.d.ts +0 -6
  1346. package/dist/connector/execution/index.d.ts.map +0 -1
  1347. package/dist/connector/execution/index.js +0 -4
  1348. package/dist/connector/execution/index.js.map +0 -1
  1349. package/dist/connector/execution/remote.d.ts.map +0 -1
  1350. package/dist/connector/execution/remote.js.map +0 -1
  1351. package/dist/connector/mcp/server-stdio.d.ts.map +0 -1
  1352. package/dist/connector/mcp/server-stdio.js.map +0 -1
  1353. package/dist/connector/mcp/server.d.ts.map +0 -1
  1354. package/dist/connector/mcp/server.js.map +0 -1
  1355. package/dist/constants/verification/index.d.ts.map +0 -1
  1356. package/dist/constants/verification/index.js.map +0 -1
  1357. package/dist/gateway/completion-inbox.d.ts.map +0 -1
  1358. package/dist/gateway/completion-inbox.js.map +0 -1
  1359. package/dist/gateway/local.d.ts.map +0 -1
  1360. package/dist/gateway/local.js.map +0 -1
  1361. package/dist/manager/thread/lifecycle.d.ts +0 -105
  1362. package/dist/manager/thread/lifecycle.d.ts.map +0 -1
  1363. package/dist/manager/thread/lifecycle.js.map +0 -1
  1364. package/dist/provider/collect.d.ts.map +0 -1
  1365. package/dist/provider/collect.js.map +0 -1
  1366. package/dist/registry/Registry.d.ts.map +0 -1
  1367. package/dist/registry/Registry.js.map +0 -1
  1368. package/dist/router/task-router.d.ts.map +0 -1
  1369. package/dist/router/task-router.js.map +0 -1
  1370. package/dist/runtime/query/context-cache.d.ts.map +0 -1
  1371. package/dist/runtime/query/context-cache.js.map +0 -1
  1372. package/dist/store/thread/disk.d.ts +0 -41
  1373. package/dist/store/thread/disk.d.ts.map +0 -1
  1374. package/dist/store/thread/disk.js +0 -238
  1375. package/dist/store/thread/disk.js.map +0 -1
  1376. package/dist/store/thread/index.d.ts +0 -4
  1377. package/dist/store/thread/index.d.ts.map +0 -1
  1378. package/dist/store/thread/index.js +0 -6
  1379. package/dist/store/thread/index.js.map +0 -1
  1380. package/dist/store/thread/memory.d.ts +0 -23
  1381. package/dist/store/thread/memory.d.ts.map +0 -1
  1382. package/dist/store/thread/memory.js +0 -90
  1383. package/dist/store/thread/memory.js.map +0 -1
  1384. package/dist/types/agent/gateway.d.ts.map +0 -1
  1385. package/dist/types/agent/gateway.js +0 -2
  1386. package/dist/types/agent/gateway.js.map +0 -1
  1387. package/dist/types/thread/entity.d.ts.map +0 -1
  1388. package/dist/types/thread/index.d.ts +0 -3
  1389. package/dist/types/thread/index.d.ts.map +0 -1
  1390. package/dist/types/thread/index.js +0 -5
  1391. package/dist/types/thread/index.js.map +0 -1
  1392. package/dist/types/thread/store.d.ts +0 -86
  1393. package/dist/types/thread/store.d.ts.map +0 -1
  1394. package/dist/types/thread/store.js +0 -22
  1395. package/dist/types/thread/store.js.map +0 -1
  1396. package/dist/types/verification/index.d.ts.map +0 -1
  1397. package/dist/types/verification/index.js +0 -53
  1398. package/dist/types/verification/index.js.map +0 -1
  1399. package/dist/verification/gate.d.ts.map +0 -1
  1400. package/dist/verification/gate.js.map +0 -1
  1401. package/dist/verification/index.d.ts +0 -4
  1402. package/dist/verification/index.d.ts.map +0 -1
  1403. package/dist/verification/index.js +0 -4
  1404. package/dist/verification/index.js.map +0 -1
  1405. package/dist/verification/presets.d.ts.map +0 -1
  1406. package/dist/verification/presets.js.map +0 -1
  1407. package/dist/verification/rules.d.ts +0 -4
  1408. package/dist/verification/rules.d.ts.map +0 -1
  1409. package/dist/verification/rules.js.map +0 -1
  1410. package/src/connector/execution/index.ts +0 -5
  1411. package/src/manager/thread/lifecycle.ts +0 -217
  1412. package/src/store/thread/disk.ts +0 -272
  1413. package/src/store/thread/index.ts +0 -7
  1414. package/src/store/thread/memory.ts +0 -104
  1415. package/src/types/thread/index.ts +0 -6
  1416. package/src/types/thread/store.ts +0 -92
  1417. package/src/verification/index.ts +0 -3
  1418. /package/dist/{bridge/tools/connector → connector/tools}/index.d.ts +0 -0
  1419. /package/dist/{bridge/tools/connector → connector/tools}/index.js +0 -0
  1420. /package/dist/constants/{verification → authorization}/index.d.ts +0 -0
  1421. /package/dist/constants/{verification → authorization}/index.js +0 -0
  1422. /package/dist/{router → model-router}/task-router.d.ts +0 -0
  1423. /package/dist/{router → model-router}/task-router.js +0 -0
  1424. /package/dist/types/{thread → topic}/entity.js +0 -0
  1425. /package/src/{bridge/tools/connector → connector/tools}/index.ts +0 -0
  1426. /package/src/constants/{verification → authorization}/index.ts +0 -0
  1427. /package/src/{router → model-router}/task-router.ts +0 -0
@@ -6,6 +6,8 @@ import {
6
6
  TriggerEvaluator,
7
7
  assertBudgetEnforceable,
8
8
  } from '../../advisory/index.js'
9
+ import { drainQueuedMessages } from '../../agents/handle.js'
10
+ import { AuthorizationGate } from '../../authorization/gate.js'
9
11
  import { findDanglingMessages, removeDanglingMessages } from '../../compaction/dangling.js'
10
12
  import { extractFromUserMessage } from '../../compaction/extractor.js'
11
13
  import { WorkingStateManager } from '../../compaction/manager.js'
@@ -13,6 +15,7 @@ import type { ContextReducer } from '../../compaction/reducer.js'
13
15
  import { serializeState as serializeWorkingState } from '../../compaction/serializer.js'
14
16
  import { restoreWorkingState, snapshotWorkingState } from '../../compaction/wire.js'
15
17
  import type { CompactionConfig } from '../../config/runtime.js'
18
+ import { BOOT_EVENT_NAMES } from '../../constants/telemetry/index.js'
16
19
  import { TOOL_OUTPUT_DIR_NAME } from '../../constants/tools/index.js'
17
20
  import { EmergencySaveManager } from '../../manager/run/emergency.js'
18
21
  import type { RunPersistence } from '../../manager/run/persistence.js'
@@ -24,7 +27,9 @@ import {
24
27
  withProviderFallback,
25
28
  } from '../../provider/fallback.js'
26
29
  import { type ProviderRetryConfig, withProviderRetry } from '../../provider/retry.js'
30
+ import { DefaultFilesystemMigrator, loggingMigrationSink } from '../../session/migration/index.js'
27
31
  import type { PathBuilder } from '../../session/workspace/path-builder.js'
32
+ import { resolveAttachments } from '../../store/attachment/index.js'
28
33
  import {
29
34
  GENAI,
30
35
  NAMZU,
@@ -45,6 +50,7 @@ import type { AdvisoryConfig } from '../../types/advisory/index.js'
45
50
  import type { AgentRuntimeContext, RuntimeToolOverrides } from '../../types/agent/base.js'
46
51
  import type { AgentContextLevel } from '../../types/agent/factory.js'
47
52
  import type { WorkingMemoryProvider } from '../../types/agent/working-memory.js'
53
+ import type { AuthorizationGateConfig } from '../../types/authorization/index.js'
48
54
  import { NamzuError } from '../../types/errors/index.js'
49
55
  import type { InputGuardrailSpec, OutputGuardrailSpec } from '../../types/guardrail/index.js'
50
56
  import {
@@ -60,11 +66,12 @@ import type { AgentPersona } from '../../types/persona/index.js'
60
66
  import type { LLMProvider } from '../../types/provider/index.js'
61
67
  import type { TaskRouterConfig } from '../../types/router/index.js'
62
68
  import type { ReviewAnswer } from '../../types/run/answer-review.js'
63
- import type { CheckpointStore, ClaimFence } from '../../types/run/checkpoint-store.js'
69
+ import type { CheckpointStore, FencingToken } from '../../types/run/checkpoint-store.js'
64
70
  import type { RunEventCursor, RunEventReplay } from '../../types/run/event-cursor.js'
65
71
  import { resolveRunEventReplay } from '../../types/run/event-cursor.js'
66
72
  import type {
67
73
  AgentRunConfig,
74
+ BeforeStep,
68
75
  PrepareStepChain,
69
76
  Run,
70
77
  RunEvent,
@@ -76,19 +83,22 @@ import type { PromoteMemory } from '../../types/run/memory-promotion.js'
76
83
  import { memoryCandidateFor } from '../../types/run/memory-promotion.js'
77
84
  import type { RunStore } from '../../types/run/store.js'
78
85
  import type { Sandbox, SandboxProvider } from '../../types/sandbox/index.js'
79
- import type { ProjectId, ThreadId } from '../../types/session/ids.js'
86
+ import type { ProjectId, TopicId } from '../../types/session/ids.js'
80
87
  import type { Skill } from '../../types/skills/index.js'
81
88
  import type { StructuredOutputConfig } from '../../types/structured-output/index.js'
82
89
  import type { TaskStore } from '../../types/task/index.js'
83
90
  import type { ToolRegistryContract } from '../../types/tool/index.js'
84
91
  import type { RepairToolCall } from '../../types/tool/repair.js'
85
- import type { VerificationGateConfig } from '../../types/verification/index.js'
86
92
  import type { BackoffPolicy } from '../../utils/backoff.js'
87
93
  import type { ModelPricing } from '../../utils/cost.js'
88
- import { getRootLogger } from '../../utils/logger.js'
89
- import { VerificationGate } from '../../verification/gate.js'
94
+ import { toErrorMessage } from '../../utils/error.js'
95
+ import { generateRunId } from '../../utils/id.js'
96
+ import { errorAttributes } from '../../utils/log/exception.js'
97
+ import { EVENT_NAME_ATTRIBUTE } from '../../utils/log/types.js'
98
+ import type { Logger } from '../../utils/logger.js'
99
+ import type { BackgroundJobRegistry } from '../jobs/registry.js'
100
+ import { AUTO_APPROVE_POLICY_NAME, createRunApprovalPolicy } from './approval-policy.js'
90
101
  import { CheckpointManager } from './checkpoint.js'
91
- import type { ContextCache } from './context-cache.js'
92
102
  import { RunContextFactory } from './context.js'
93
103
  import { EventTranslator } from './events.js'
94
104
  import { GuardCoordinator } from './guard.js'
@@ -97,9 +107,11 @@ import { IterationOrchestrator } from './iteration/index.js'
97
107
  import { isCompactionMessage } from './iteration/phases/compaction.js'
98
108
  import { isWorkingMemoryMessage } from './iteration/phases/working-memory.js'
99
109
  import { applyLifecycleHookResults } from './plugin-hooks.js'
110
+ import type { PromptCache } from './prompt-cache.js'
100
111
  import { PromptBuilder } from './prompt.js'
101
112
  import type { PromptSegments } from './prompt.js'
102
113
  import { PendingAnswers, QuestionParkBinding } from './question-park.js'
114
+ import { RepeatCallTracker } from './repeat-call.js'
103
115
  import { ResultAssembler } from './result.js'
104
116
  import {
105
117
  type PendingResumePlan,
@@ -115,6 +127,22 @@ import { createToolPause } from './tool-pause.js'
115
127
  import { ToolingBootstrap } from './tooling.js'
116
128
 
117
129
  export interface QueryParams {
130
+ /**
131
+ * Notice when the model issues the identical tool call repeatedly, and
132
+ * say so on the next `tool_result`. Defaults on.
133
+ *
134
+ * `false` removes the tracker entirely rather than gating a branch, so
135
+ * an opted-out run produces byte-identical messages to one from before
136
+ * this existed.
137
+ */
138
+ repeatCallAdvisory?: boolean
139
+
140
+ /**
141
+ * Tool names this run may not use, subtracted from its effective list.
142
+ * See {@link import('../../types/agent/base.js').BaseAgentConfig.deniedTools}.
143
+ */
144
+ deniedTools?: readonly string[]
145
+
118
146
  systemPrompt?: string
119
147
  persona?: AgentPersona
120
148
  skills?: Skill[]
@@ -209,6 +237,54 @@ export interface QueryParams {
209
237
 
210
238
  /** Default per-tool execution deadline. See {@link ToolDefinition.timeoutMs}. */
211
239
  toolTimeoutMs?: number
240
+ /**
241
+ * Where background jobs this run starts are held, and killed.
242
+ *
243
+ * Host-owned so it can outlive one run — a registry built per run could
244
+ * never be the thing that kills a run's jobs when the run is already
245
+ * gone. This run's jobs are torn down in the `finally` below; another
246
+ * run's are untouched.
247
+ */
248
+ backgroundJobs?: BackgroundJobRegistry
249
+
250
+ /**
251
+ * What else goes in this run's prompt.
252
+ *
253
+ * `static` and `dynamic` contributions reach the system prompt through
254
+ * `PromptBuilder`; `turn` contributions reach the ephemeral trailing
255
+ * message once per iteration. A host registers once and the placement
256
+ * decides where it lands.
257
+ */
258
+ promptContributions?: import('../../prompt/contributions.js').PromptContributionRegistry
259
+
260
+ /**
261
+ * Where the `skill` tool loads from.
262
+ *
263
+ * Separate from `skills`, which is the LIST that goes in the prompt
264
+ * manifest. A run can have the manifest without the tool — that is what
265
+ * every run did before the tool existed — and the two are wired
266
+ * independently on purpose: a host may want the guidance visible without
267
+ * granting a way to pull bodies in mid-run.
268
+ */
269
+ skillRegistry?: import('../../types/tool/index.js').SkillRegistryRef
270
+
271
+ /**
272
+ * Where a message's stored attachments are resolved from.
273
+ *
274
+ * Absent is fine for every run whose attachments are inline, which is
275
+ * every run that existed before this. A message carrying a ref with no
276
+ * store REFUSES rather than dropping the attachment.
277
+ */
278
+ attachmentStore?: import('../../store/attachment/index.js').AttachmentStore
279
+
280
+ /**
281
+ * How this run reaches the web.
282
+ *
283
+ * `fetch` and `search` are independent, and this kernel ships only the
284
+ * first — see `connector/web` for why choosing a search backend here
285
+ * would choose it for every consumer.
286
+ */
287
+ web?: import('../../types/tool/index.js').ToolContext['web']
212
288
 
213
289
  /**
214
290
  * Wait between in-loop retries of a failed tool call, with full jitter.
@@ -317,6 +393,11 @@ export interface QueryParams {
317
393
  * Fails open — a throw leaves the step with the run's configuration.
318
394
  */
319
395
  prepareStep?: PrepareStepChain
396
+ /**
397
+ * Refuse the next model call before it is made. See {@link BeforeStep}.
398
+ * A throw fails CLOSED, opposite to `prepareStep` beside it.
399
+ */
400
+ beforeStep?: BeforeStep
320
401
 
321
402
  /**
322
403
  * Force the run to finish by calling a schema-validated tool, and land
@@ -406,13 +487,13 @@ export interface QueryParams {
406
487
  sessionId: SessionId
407
488
 
408
489
  /**
409
- * Topic the Session lives under. Required in 0.3.0 — every run carries
410
- * the full five-layer scope (Tenant → Project → Thread → Session →
411
- * Run). Denormalized from `session.threadId`; callers build this
412
- * alongside `sessionId` so the query pipeline never needs a second
413
- * SessionStore round-trip to recover it.
490
+ * Topic the Session lives under. Required — every run carries the full
491
+ * five-layer scope (Tenant → Project → Topic → Session → Run).
492
+ * Denormalized from `session.topicId`; callers build this alongside
493
+ * `sessionId` so the query pipeline never needs a second SessionStore
494
+ * round-trip to recover it.
414
495
  */
415
- threadId: ThreadId
496
+ topicId: TopicId
416
497
 
417
498
  /** Long-lived goal scope for the run. Required. */
418
499
  projectId: ProjectId
@@ -455,7 +536,7 @@ export interface QueryParams {
455
536
  * takes no fence, so two workers that both took one run still overwrite
456
537
  * each other's run record, transcript and report — see the changeset.
457
538
  */
458
- claimFence?: ClaimFence
539
+ claimFence?: FencingToken
459
540
 
460
541
  /**
461
542
  * Where this run records its own evidence — the run record, its messages,
@@ -511,7 +592,7 @@ export interface QueryParams {
511
592
 
512
593
  depth?: number
513
594
 
514
- contextCache?: ContextCache
595
+ promptCache?: PromptCache
515
596
 
516
597
  contextLevel?: AgentContextLevel
517
598
 
@@ -523,7 +604,54 @@ export interface QueryParams {
523
604
 
524
605
  runtimeContext?: AgentRuntimeContext
525
606
 
526
- taskGateway?: import('../../types/agent/gateway.js').TaskGateway
607
+ taskScheduler?: import('../../types/agent/scheduler.js').TaskScheduler
608
+
609
+ /**
610
+ * Text queued for this run since its last turn, drained at the boundary.
611
+ *
612
+ * A callback because the queue belongs to whoever accepts the messages,
613
+ * and an array captured here would be whatever was queued before the run
614
+ * started. See `BaseAgentConfig.inboundMessages` for what it closes.
615
+ */
616
+ inboundMessages?: () => import('../../types/message/index.js').Message[]
617
+
618
+ /**
619
+ * Where this conversation's durable state lives.
620
+ *
621
+ * Supplies the permission mode when `runConfig.permissionMode` names
622
+ * none, and receives the flip when a plan is approved. Absent is the
623
+ * ordinary case: a run with no topic state behaves exactly as it did.
624
+ */
625
+ topicStateStore?: import('../../store/topic/state.js').TopicStateStore
626
+
627
+ /**
628
+ * The live permission-mode box, when the caller holds one too.
629
+ *
630
+ * Whoever builds the coordinator tools needs to flip this from the
631
+ * approval hook, and that is not this function. Sharing the object is
632
+ * what lets an approved plan leave plan mode in the SAME run.
633
+ */
634
+ permissionModeRef?: { current: import('../../types/permission/index.js').PermissionMode }
635
+
636
+ /**
637
+ * A name for the policy `resumeHandler` implements.
638
+ *
639
+ * Only ever written to the durable log and shown to an operator, so it
640
+ * costs nothing to omit — but omitting it means every entry about who
641
+ * approved something says `host`, which is the answer that helps least.
642
+ */
643
+ approvalPolicyName?: string
644
+
645
+ /**
646
+ * Receive this run's approval-policy box, so it can be swapped mid-run.
647
+ *
648
+ * The box is built HERE rather than passed in, unlike
649
+ * {@link permissionModeRef}, because changing the policy emits a durable
650
+ * event and only the run holds the emitter. A host that constructed its
651
+ * own box would be able to change the policy without recording it, which
652
+ * is the one thing this must not allow.
653
+ */
654
+ onApprovalPolicy?: (policy: import('../../types/hitl/policy.js').RunApprovalPolicy) => void
527
655
 
528
656
  /**
529
657
  * Where a worker completion goes when no tool call is waiting for it.
@@ -533,7 +661,7 @@ export interface QueryParams {
533
661
  * and the loop delivers what is left. Omitted, the loop drains nothing and
534
662
  * the behaviour is exactly what it was before the inbox existed.
535
663
  */
536
- completionInbox?: import('../../gateway/completion-inbox.js').CompletionInbox
664
+ completionInbox?: import('../../scheduler/completion-inbox.js').CompletionInbox
537
665
 
538
666
  onContextCreated?: (ctx: {
539
667
  planManager: import('../../manager/plan/lifecycle.js').PlanManager
@@ -566,7 +694,7 @@ export interface QueryParams {
566
694
 
567
695
  agentBus?: import('../../bus/index.js').AgentBus
568
696
 
569
- verificationGate?: VerificationGateConfig
697
+ authorizationGate?: AuthorizationGateConfig
570
698
 
571
699
  pluginManager?: import('../../plugin/lifecycle.js').PluginLifecycleManager
572
700
 
@@ -667,14 +795,102 @@ function assertBudgetIsMeasurable(params: QueryParams): void {
667
795
  })
668
796
  }
669
797
 
798
+ /**
799
+ * Ask the driver what this model's window is, and never let the answer
800
+ * cost the run.
801
+ *
802
+ * Three outcomes collapse to two here on purpose. No member and a resolved
803
+ * `undefined` both mean "no answer" — the distinction matters to a driver
804
+ * author, not to a caller about to fall through to the table. A rejection
805
+ * is the third, and it is logged rather than propagated: a run that would
806
+ * have worked on the table must not fail because a listing endpoint was
807
+ * down.
808
+ */
809
+ async function resolveProviderContextWindow(
810
+ provider: LLMProvider,
811
+ model: string | undefined,
812
+ signal: AbortSignal | undefined,
813
+ log: Logger,
814
+ ): Promise<number | undefined> {
815
+ if (!provider.resolveContextWindow || !model) return undefined
816
+ try {
817
+ const reported = await provider.resolveContextWindow(model, signal)
818
+ return typeof reported === 'number' && reported > 0 ? reported : undefined
819
+ } catch (err) {
820
+ log.debug('Provider could not report a context window; using the table', {
821
+ 'namzu.model.id': model,
822
+ 'namzu.error.message': toErrorMessage(err),
823
+ })
824
+ return undefined
825
+ }
826
+ }
827
+
670
828
  export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run> {
829
+ // Resolved at the DOOR, before a run id exists or a logger is built.
830
+ // A caller who set both spellings of a renamed field has a config bug,
831
+ // and refusing it here costs them nothing; refusing it at the read site
832
+ // deep in the loop turns the same bug into a mid-run failure, after a
833
+ // provider call has been paid for and a partial transcript written.
834
+ const promptCache = params.promptCache
835
+ const taskScheduler = params.taskScheduler
836
+
837
+ // The run's one correlated logger, built before anything below needs
838
+ // one — the migration check, the retry/fallback wrappers and `ctx`
839
+ // itself all read this SAME object, so a retry warning and the run
840
+ // record it retried for carry the identical `namzu.run.id` instead of
841
+ // three separate `getRootLogger()` reads that happened to agree by
842
+ // accident. `runId` is resolved here, once, rather than left to
843
+ // `build`'s own `config.runId ?? generateRunId()` fallback —
844
+ // generating it twice would silently hand the log and the run two
845
+ // different ids.
846
+ const runId = params.runId ?? generateRunId()
847
+ const log = RunContextFactory.buildLogger({
848
+ agentName: params.agentName,
849
+ runConfig: params.runConfig,
850
+ runId,
851
+ parentRunId: params.parentRunId,
852
+ sessionId: params.sessionId,
853
+ topicId: params.topicId,
854
+ projectId: params.projectId,
855
+ tenantId: params.tenantId,
856
+ })
857
+
671
858
  // Boot-time filesystem migration (session-hierarchy.md §13.4.1). First
672
859
  // call per process per root actually runs; subsequent calls short-circuit
673
860
  // via the in-memory guard in `context.ts`. Kept here rather than inside
674
861
  // the synchronous `RunContextFactory.build` so the factory signature stays
675
862
  // sync for tests / non-async call sites.
863
+ //
864
+ // The migrator built here — not `ensureMigrated`'s own default — is what
865
+ // turns the migration facts `DefaultFilesystemMigrator` already computes
866
+ // into a `namzu.migration.completed` record instead of discarding them.
867
+ // `ensureMigrated`'s default parameter stays
868
+ // `NOOP_FILESYSTEM_MIGRATION_SINK` (see `context.ts`), so any other path
869
+ // that reaches `ensureMigrated` keeps today's silent behaviour.
676
870
  const cwdForMigration = params.workingDirectory ?? process.cwd()
677
- await RunContextFactory.ensureMigrated(`${cwdForMigration}/.namzu`)
871
+ const migrationResult = await RunContextFactory.ensureMigrated(
872
+ `${cwdForMigration}/.namzu`,
873
+ new DefaultFilesystemMigrator(loggingMigrationSink(log)),
874
+ )
875
+ // `loggingMigrationSink` only ever hears about `kind: 'migrated'` — the
876
+ // only outcome `DefaultFilesystemMigrator` ever hands its sink (see the
877
+ // module doc on `FilesystemMigrationSink`). The other two are logged
878
+ // here, straight off the resolved result, rather than by widening
879
+ // `FilesystemMigrationEvent` to carry them: a wider union would need a
880
+ // new arm in every exhaustive switch already written over it — a major —
881
+ // for two outcomes `migrationResult.kind` already fully describes.
882
+ if (migrationResult.kind !== 'migrated') {
883
+ log.debug('filesystem migration: nothing to do', {
884
+ [EVENT_NAME_ATTRIBUTE]: BOOT_EVENT_NAMES.MIGRATION_COMPLETED,
885
+ // `namzu.migration.*`, matching `loggingMigrationSink` — the OTHER
886
+ // emitter of this same event name. Two emitters of one event writing
887
+ // two namespaces for the same fact is precisely the collision the
888
+ // namespaced-key rule exists to stop, and a per-module derivation is
889
+ // how it would be reintroduced.
890
+ 'namzu.migration.kind': migrationResult.kind,
891
+ 'namzu.migration.marker_path': migrationResult.markerPath,
892
+ })
893
+ }
678
894
 
679
895
  // Every model call in the run — the loop's turns, the forced-final
680
896
  // summary, advisory and compaction side calls — goes through this one
@@ -701,9 +917,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
701
917
  assertCostIsAttributable(chain, params.pricing)
702
918
  assertBudgetIsMeasurable(params)
703
919
  const withRetry = (provider: LLMProvider): LLMProvider =>
704
- params.retry === false
705
- ? provider
706
- : withProviderRetry(provider, { config: params.retry, log: getRootLogger() })
920
+ params.retry === false ? provider : withProviderRetry(provider, { config: params.retry, log })
707
921
  // Who is serving right now, for the run RECORD rather than for the request.
708
922
  //
709
923
  // It starts at the head and moves only when the chain does, which is the
@@ -717,7 +931,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
717
931
  const resilientProvider = withProviderFallback(
718
932
  chain.map((member) => ({ ...member, provider: withRetry(member.provider) })),
719
933
  {
720
- log: getRootLogger(),
934
+ log,
721
935
  onSwap: (to) => {
722
936
  serving.current = to
723
937
  // `ctx` is declared below and is initialized before anything can
@@ -728,7 +942,74 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
728
942
  },
729
943
  )
730
944
 
945
+ // Asked ONCE, here, before the loop exists. Both readers are synchronous
946
+ // and hot, so this can never move inside the iteration — and a driver
947
+ // that rejects, or one that hangs until the run is cancelled, must not
948
+ // take down a run the table could have served perfectly well. That is
949
+ // why the failure path is a swallow with a log rather than a throw: the
950
+ // window is an optimisation over a working default, not a prerequisite.
951
+ const providerContextWindow = await resolveProviderContextWindow(
952
+ resilientProvider,
953
+ params.runConfig.model,
954
+ params.signal,
955
+ log,
956
+ )
957
+
958
+ // The mode this conversation was left in, when the run config names none.
959
+ // Read once, before the loop exists, for the same reason the context
960
+ // window is: the executor's resolver is synchronous and hot.
961
+ //
962
+ // A store that throws is not a run failure — the run falls back to the
963
+ // config's answer, which is exactly what it did before this existed.
964
+ const topicState = params.topicStateStore
965
+ ? await params.topicStateStore
966
+ .getState(params.topicId, params.tenantId)
967
+ .catch((err: unknown) => {
968
+ log.debug('Could not read the topic state; using the run config', {
969
+ 'namzu.topic.id': params.topicId,
970
+ 'namzu.error.message': toErrorMessage(err),
971
+ })
972
+ return null
973
+ })
974
+ : null
975
+
976
+ // Whatever a host left for "the next run", taken and cleared in one
977
+ // compare-and-set write. Prepended to the messages this run starts from,
978
+ // so it is in the FIRST request rather than arriving a turn late.
979
+ //
980
+ // Cleared as it is read: a queue read and cleared separately re-delivers
981
+ // on a crash between the two, and "start with this" arriving twice is a
982
+ // different instruction from the one that was left.
983
+ const queuedForThisRun: readonly Message[] = params.topicStateStore
984
+ ? await drainQueuedMessages(params.topicStateStore, params.topicId, params.tenantId).catch(
985
+ (err: unknown) => {
986
+ log.debug('Could not drain the topic queue; starting without it', {
987
+ 'namzu.topic.id': params.topicId,
988
+ 'namzu.error.message': toErrorMessage(err),
989
+ })
990
+ return []
991
+ },
992
+ )
993
+ : []
994
+
995
+ // One effective list, used everywhere the run is seeded from. Three
996
+ // branches below push from it, and computing it at each would be three
997
+ // places to forget the queue.
998
+ //
999
+ // Stored attachments are resolved HERE, once, before the messages reach
1000
+ // the run record. Resolving later — at the provider boundary — would put
1001
+ // refs in the durable transcript and in every checkpoint, and a run
1002
+ // resumed against a store that had since forgotten a ref would fail
1003
+ // replaying its own history rather than at the moment somebody asked for
1004
+ // the bytes. Every failure refuses: a message that silently lost its
1005
+ // image is a model answering about a picture it never saw.
1006
+ const seeded: Message[] =
1007
+ queuedForThisRun.length > 0 ? [...queuedForThisRun, ...params.messages] : params.messages
1008
+ const initialMessages: Message[] = [...(await resolveAttachments(seeded, params.attachmentStore))]
1009
+
731
1010
  const ctx = RunContextFactory.build({
1011
+ ...(topicState ? { topicPermissionMode: topicState.permissionMode } : {}),
1012
+ ...(params.permissionModeRef ? { permissionModeRef: params.permissionModeRef } : {}),
732
1013
  agentId: params.agentId,
733
1014
  agentName: params.agentName,
734
1015
  runConfig: params.runConfig,
@@ -736,22 +1017,52 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
736
1017
  workingDirectory: params.workingDirectory,
737
1018
  pricing: params.pricing,
738
1019
  enableActivityTracking: params.enableActivityTracking,
739
- messages: params.messages,
1020
+ messages: initialMessages,
740
1021
  signal: params.signal,
741
1022
  sessionId: params.sessionId,
742
- threadId: params.threadId,
1023
+ topicId: params.topicId,
743
1024
  projectId: params.projectId,
744
1025
  tenantId: params.tenantId,
745
1026
  pathBuilder: params.pathBuilder,
746
1027
  checkpointStore: params.checkpointStore,
747
1028
  runStore: params.runStore,
748
- runId: params.runId,
1029
+ runId,
749
1030
  parentRunId: params.parentRunId,
750
1031
  depth: params.depth,
1032
+ log,
1033
+ })
1034
+
1035
+ // Built here because the plan-approval closure below captures it, and
1036
+ // its `emit` resolves `eventTranslator` at CALL time — the translator is
1037
+ // a `const` some lines further down.
1038
+ //
1039
+ // The HANDOUT is therefore deliberately NOT here. A host given the box
1040
+ // at this point can call `set` synchronously, `emit` reaches
1041
+ // `eventTranslator` inside its temporal dead zone, and the run dies
1042
+ // before it starts. That is not hypothetical: it is what the first
1043
+ // version of this did, and the test that hands out the box and
1044
+ // immediately swaps the policy is the one that found it.
1045
+ const approvalPolicy = createRunApprovalPolicy({
1046
+ runId: ctx.runId,
1047
+ initial: {
1048
+ // By identity against the default, not by presence. `resumeHandler`
1049
+ // is REQUIRED on `QueryParams` — `drainQuery` substitutes
1050
+ // `autoApproveHandler` before calling here — so "is it set" is
1051
+ // always yes and would name every run `host`, including the ones
1052
+ // approving everything unattended. Identity is what actually
1053
+ // separates the two.
1054
+ name:
1055
+ params.approvalPolicyName ??
1056
+ (params.resumeHandler === autoApproveHandler ? AUTO_APPROVE_POLICY_NAME : 'host'),
1057
+ handler: params.resumeHandler,
1058
+ },
1059
+ emit: (event) => eventTranslator.emitEvent(event),
751
1060
  })
752
1061
 
753
1062
  ctx.planManager.setApprovalHandler(async (request) => {
754
- const decision = await params.resumeHandler({
1063
+ // `.current.handler`, never a captured `params.resumeHandler`. That
1064
+ // capture is what made changing the policy mean ending the run.
1065
+ const decision = await approvalPolicy.current.handler({
755
1066
  type: 'plan_approval',
756
1067
  runId: ctx.runId,
757
1068
  checkpointId: `cp_plan_${request.planId}` as import('../../types/ids/index.js').CheckpointId,
@@ -788,7 +1099,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
788
1099
  return { approved: false, feedback: `Action: ${decision.action}` }
789
1100
  })
790
1101
 
791
- const eventTranslator = new EventTranslator(ctx.runMgr)
1102
+ const eventTranslator = new EventTranslator(ctx.runMgr, undefined, ctx.log)
792
1103
  eventTranslator.wireActivityStore(ctx.activityStore, ctx.runId)
793
1104
  eventTranslator.wirePlanManager(ctx.planManager, ctx.runId)
794
1105
  const unsubscribeTaskStore = params.taskStore
@@ -853,9 +1164,10 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
853
1164
  details: { providerId: params.provider.id, capability: 'tools', registeredToolCount },
854
1165
  })
855
1166
  }
856
- ctx.log.warn(`CAPABILITY MISMATCH: ${message}`, {
857
- providerId: params.provider.id,
858
- registeredToolCount,
1167
+ ctx.log.warn('Capability mismatch: the provider declares no tool support', {
1168
+ 'namzu.capability.detail': message,
1169
+ [GENAI.SYSTEM]: params.provider.id,
1170
+ 'namzu.runtime.registered_tool_count': registeredToolCount,
859
1171
  })
860
1172
  }
861
1173
 
@@ -868,9 +1180,10 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
868
1180
  details: { providerId: params.provider.id, capability: 'vision', attachmentMessageCount },
869
1181
  })
870
1182
  }
871
- ctx.log.warn(`CAPABILITY MISMATCH: ${message}`, {
872
- providerId: params.provider.id,
873
- attachmentMessageCount,
1183
+ ctx.log.warn('Capability mismatch: the provider declares no vision support', {
1184
+ 'namzu.capability.detail': message,
1185
+ [GENAI.SYSTEM]: params.provider.id,
1186
+ 'namzu.runtime.attachment_message_count': attachmentMessageCount,
874
1187
  })
875
1188
  }
876
1189
 
@@ -883,15 +1196,32 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
883
1196
  details: { providerId: params.provider.id, capability: 'documents', documentMessageCount },
884
1197
  })
885
1198
  }
886
- ctx.log.warn(`CAPABILITY MISMATCH: ${message}`, {
887
- providerId: params.provider.id,
888
- documentMessageCount,
1199
+ ctx.log.warn('Capability mismatch: the provider declares no document support', {
1200
+ 'namzu.capability.detail': message,
1201
+ [GENAI.SYSTEM]: params.provider.id,
1202
+ 'namzu.runtime.document_message_count': documentMessageCount,
889
1203
  })
890
1204
  }
891
1205
 
892
- const effectiveAllowedTools = stripToolSurfaces
1206
+ // Denied names are subtracted LAST, after the allow-list is resolved
1207
+ // against the registry — so a deny reaches a run that named no
1208
+ // allow-list at all, which is the ordinary case for a delegated child.
1209
+ // Applied to `effectiveAllowedTools`, which `query()` binds to both the
1210
+ // request tool list AND the `ToolExecutor`: narrowing only the request
1211
+ // shows the model fewer tools and lets it call any of them by name.
1212
+ const allowedBeforeDenial = stripToolSurfaces
893
1213
  ? []
894
1214
  : withDeferredDiscoveryTool(params.tools, params.allowedTools)
1215
+ const denied = new Set(params.deniedTools ?? [])
1216
+ const effectiveAllowedTools: string[] | undefined =
1217
+ denied.size === 0
1218
+ ? allowedBeforeDenial
1219
+ : // An absent allow-list means "every registered tool", so a deny
1220
+ // with no allow-list has to be resolved against the registry
1221
+ // here — otherwise the subtraction would be from an empty list
1222
+ // and would deny nothing, which is the shape a delegated child
1223
+ // arrives in.
1224
+ [...(allowedBeforeDenial ?? params.tools.listNames())].filter((name) => !denied.has(name))
895
1225
 
896
1226
  // The two halves of a durable pause, owned by the RUN when the host
897
1227
  // does not own them.
@@ -922,12 +1252,18 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
922
1252
  tools: params.tools,
923
1253
  runId: ctx.runId,
924
1254
  workingDirectory: ctx.cwd,
925
- permissionMode: ctx.permissionMode,
1255
+ permissionMode: () => ctx.permissionMode.current,
926
1256
  env: params.runConfig.env ?? {},
927
1257
  abortSignal: ctx.abortController.signal,
928
1258
  allowedTools: effectiveAllowedTools,
929
1259
  invocationState: params.invocationState,
930
1260
  pluginManager: params.pluginManager,
1261
+ ...(params.backgroundJobs ? { backgroundJobs: params.backgroundJobs } : {}),
1262
+ // The `skill` tool's registry. Threaded from the run rather than
1263
+ // held by the tool, because a tool that reached for a module-level
1264
+ // registry would answer about whatever the last run configured.
1265
+ ...(params.skillRegistry ? { skills: params.skillRegistry } : {}),
1266
+ ...(params.web ? { web: params.web } : {}),
931
1267
  ...(params.toolTimeoutMs !== undefined ? { toolTimeoutMs: params.toolTimeoutMs } : {}),
932
1268
  ...(params.toolRetryBackoff !== undefined
933
1269
  ? { toolRetryBackoff: params.toolRetryBackoff }
@@ -955,7 +1291,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
955
1291
  createToolPause({
956
1292
  runId: ctx.runId,
957
1293
  toolUseId,
958
- parkHandler: params.resumeHandler,
1294
+ parkHandler: (request) => approvalPolicy.current.handler(request),
959
1295
  recorder: questionParks,
960
1296
  pendingAnswers,
961
1297
  }),
@@ -979,6 +1315,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
979
1315
  tools: params.tools,
980
1316
  allowedTools: effectiveAllowedTools,
981
1317
  runtimeContext: params.runtimeContext,
1318
+ ...(params.promptContributions ? { contributions: params.promptContributions } : {}),
982
1319
  })
983
1320
 
984
1321
  const guard = new GuardCoordinator({
@@ -1013,6 +1350,10 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1013
1350
  // Read at settle time, not now: checkpoints are written per
1014
1351
  // iteration, so the answer changes as the run proceeds.
1015
1352
  resumeCheckpointId: () => checkpointMgr.lastCheckpointId,
1353
+ // Read only to recover WHY a cancellation happened. The run loop
1354
+ // already knows THAT it was cancelled; the origin lives on the abort
1355
+ // reason and nothing else carries it this far.
1356
+ signal: ctx.abortController.signal,
1016
1357
  })
1017
1358
 
1018
1359
  let advisoryCtx: AdvisoryContext | undefined
@@ -1072,8 +1413,10 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1072
1413
  }
1073
1414
  }
1074
1415
 
1075
- const verificationGate = params.verificationGate?.enabled
1076
- ? new VerificationGate(params.verificationGate, ctx.log)
1416
+ const gateConfig = params.authorizationGate
1417
+
1418
+ const verificationGate = gateConfig?.enabled
1419
+ ? new AuthorizationGate(gateConfig, ctx.log)
1077
1420
  : undefined
1078
1421
 
1079
1422
  const iterationOrchestrator = new IterationOrchestrator({
@@ -1082,6 +1425,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1082
1425
  runConfig: params.runConfig,
1083
1426
  ...(params.stopWhen ? { stopWhen: params.stopWhen } : {}),
1084
1427
  ...(params.prepareStep ? { prepareStep: params.prepareStep } : {}),
1428
+ ...(params.beforeStep ? { beforeStep: params.beforeStep } : {}),
1085
1429
  ...(params.onStepFinish ? { onStepFinish: params.onStepFinish } : {}),
1086
1430
  ...(params.reviewAnswer ? { reviewAnswer: params.reviewAnswer } : {}),
1087
1431
  ...(params.maxAnswerReviews !== undefined ? { maxAnswerReviews: params.maxAnswerReviews } : {}),
@@ -1099,17 +1443,27 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1099
1443
  drainPending: () => eventTranslator.drainPending(),
1100
1444
  abortController: ctx.abortController,
1101
1445
  log: ctx.log,
1102
- resumeHandler: params.resumeHandler,
1446
+ // Read through the box on every call, so a swap lands on the next
1447
+ // question rather than the next run.
1448
+ resumeHandler: (request) => approvalPolicy.current.handler(request),
1449
+ takeApprovalPolicyChange: () => approvalPolicy.takeUnannouncedChange(),
1450
+ ...(params.promptContributions ? { promptContributions: params.promptContributions } : {}),
1103
1451
  ...(params.steering ? { steering: params.steering } : {}),
1104
1452
  checkpointMgr,
1105
1453
  planManager: ctx.planManager,
1106
- taskGateway: params.taskGateway,
1454
+ taskGateway: taskScheduler,
1107
1455
  completionInbox: params.completionInbox,
1108
1456
  taskStore: params.taskStore,
1109
1457
  // Run-scoped. An approval is a statement about this run's work;
1110
1458
  // carrying one into a later run would be reuse nobody agreed to.
1111
1459
  toolGrants: new ToolGrantSet(),
1460
+ // Run-scoped for the same reason. A repeat count carried into a later
1461
+ // run is a claim about work nobody repeated, and a module-level map
1462
+ // would leak exactly that way.
1463
+ ...(params.repeatCallAdvisory === false ? {} : { repeatCalls: new RepeatCallTracker() }),
1112
1464
  compactionConfig: params.compactionConfig,
1465
+ ...(params.inboundMessages ? { inboundMessages: params.inboundMessages } : {}),
1466
+ ...(providerContextWindow !== undefined ? { providerContextWindow } : {}),
1113
1467
  workingStateManager,
1114
1468
  taskRouter: params.taskRouter,
1115
1469
  contextReducer: params.contextReducer,
@@ -1196,9 +1550,9 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1196
1550
  // because a host building an approval queue from durable
1197
1551
  // state will not see this question.
1198
1552
  ctx.log.error('Failed to record a question park — it is not resumable', {
1199
- runId: ctx.runMgr.id,
1200
- questionId: question.questionId,
1201
- error: err instanceof Error ? err.message : String(err),
1553
+ [NAMZU.RUN_ID]: ctx.runMgr.id,
1554
+ 'namzu.runtime.question_id': question.questionId,
1555
+ 'exception.message': err instanceof Error ? err.message : String(err),
1202
1556
  })
1203
1557
  return null
1204
1558
  }
@@ -1206,9 +1560,9 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1206
1560
  resolve: async (checkpointId, decision) => {
1207
1561
  await checkpointMgr.unpark(checkpointId, decision).catch((err: unknown) => {
1208
1562
  ctx.log.error('Failed to clear a recorded question park', {
1209
- runId: ctx.runMgr.id,
1210
- checkpointId,
1211
- error: err instanceof Error ? err.message : String(err),
1563
+ [NAMZU.RUN_ID]: ctx.runMgr.id,
1564
+ 'namzu.checkpoint.id': checkpointId,
1565
+ 'exception.message': err instanceof Error ? err.message : String(err),
1212
1566
  })
1213
1567
  return null
1214
1568
  })
@@ -1272,13 +1626,13 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1272
1626
  params.onContextCreated?.({ planManager: ctx.planManager })
1273
1627
 
1274
1628
  ctx.log.info('Starting query', {
1275
- runId: ctx.runMgr.id,
1276
- agent: params.agentName,
1277
- model: params.runConfig.model,
1278
- tokenBudget: params.runConfig.tokenBudget,
1279
- activityTracking: ctx.activityStore.enabled,
1280
- permissionMode: ctx.permissionMode,
1281
- resumeFromCheckpoint: params.resumeFromCheckpoint ?? null,
1629
+ [NAMZU.RUN_ID]: ctx.runMgr.id,
1630
+ 'namzu.runtime.agent': params.agentName,
1631
+ [GENAI.REQUEST_MODEL]: params.runConfig.model,
1632
+ 'namzu.runtime.token_budget': params.runConfig.tokenBudget,
1633
+ 'namzu.runtime.activity_tracking': ctx.activityStore.enabled,
1634
+ 'namzu.runtime.permission_mode': ctx.permissionMode.current,
1635
+ 'namzu.runtime.resume_from_checkpoint': params.resumeFromCheckpoint ?? null,
1282
1636
  })
1283
1637
 
1284
1638
  const contextLevel = params.contextLevel ?? 'full'
@@ -1290,19 +1644,16 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1290
1644
  tools: params.tools,
1291
1645
  allowedTools: effectiveAllowedTools,
1292
1646
  runtimeContext: params.runtimeContext,
1647
+ ...(params.promptContributions ? { contributions: params.promptContributions } : {}),
1293
1648
  }
1294
1649
 
1295
- const segments: PromptSegments = params.contextCache
1296
- ? params.contextCache.getSystemPromptSegmented(
1297
- cacheInput,
1298
- contextLevel,
1299
- params.workingDirectory,
1300
- )
1650
+ const segments: PromptSegments = promptCache
1651
+ ? promptCache.getSystemPromptSegmented(cacheInput, contextLevel, params.workingDirectory)
1301
1652
  : promptBuilder.buildSegmented(contextLevel, params.workingDirectory)
1302
1653
 
1303
1654
  ctx.log.info('Prompt segments assembled', {
1304
- staticLength: segments.static.length,
1305
- dynamicLength: segments.dynamic.length,
1655
+ 'namzu.runtime.static_length': segments.static.length,
1656
+ 'namzu.runtime.dynamic_length': segments.dynamic.length,
1306
1657
  })
1307
1658
 
1308
1659
  const pushSystemMessages = (): void => {
@@ -1345,18 +1696,18 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1345
1696
  const revived = restoreWorkingState(checkpoint.workingState, params.compactionConfig)
1346
1697
  workingStateManager.replaceState(revived.getState())
1347
1698
  ctx.log.info('Restored compaction working state from checkpoint', {
1348
- runId: ctx.runMgr.id,
1349
- checkpointId: checkpoint.id,
1350
- slots: workingStateManager.slotCount(),
1699
+ [NAMZU.RUN_ID]: ctx.runMgr.id,
1700
+ 'namzu.checkpoint.id': checkpoint.id,
1701
+ 'namzu.runtime.slots': workingStateManager.slotCount(),
1351
1702
  })
1352
1703
  }
1353
1704
  ctx.log.info('Restored budgets from checkpoint', {
1354
- runId: ctx.runMgr.id,
1355
- checkpointId: checkpoint.id,
1356
- totalTokens: checkpoint.tokenUsage.totalTokens,
1357
- totalCost: checkpoint.costInfo.totalCost,
1358
- iteration: checkpoint.guardState.iterationCount,
1359
- elapsedMs: checkpoint.guardState.elapsedMs,
1705
+ [NAMZU.RUN_ID]: ctx.runMgr.id,
1706
+ 'namzu.checkpoint.id': checkpoint.id,
1707
+ 'namzu.usage.total_tokens': checkpoint.tokenUsage.totalTokens,
1708
+ 'namzu.runtime.total_cost': checkpoint.costInfo.totalCost,
1709
+ [NAMZU.ITERATION]: checkpoint.guardState.iterationCount,
1710
+ 'namzu.runtime.elapsed_ms': checkpoint.guardState.elapsedMs,
1360
1711
  })
1361
1712
 
1362
1713
  pushSystemMessages()
@@ -1409,11 +1760,12 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1409
1760
  : removeDanglingMessages(checkpoint.messages)
1410
1761
  if (!dangling.isValid && !pendingResume) {
1411
1762
  ctx.log.warn('Checkpoint contained unanswered tool calls — repaired on restore', {
1412
- runId: ctx.runMgr.id,
1413
- checkpointId: checkpoint.id,
1414
- unansweredAssistantTurns: dangling.assistantsWithUnmatchedCalls.length,
1415
- orphanedToolMessages: dangling.orphanedToolMessages.length,
1416
- removed: checkpoint.messages.length - restoredMessages.length,
1763
+ [NAMZU.RUN_ID]: ctx.runMgr.id,
1764
+ 'namzu.checkpoint.id': checkpoint.id,
1765
+ 'namzu.runtime.unanswered_assistant_turns':
1766
+ dangling.assistantsWithUnmatchedCalls.length,
1767
+ 'namzu.runtime.orphaned_tool_messages': dangling.orphanedToolMessages.length,
1768
+ 'namzu.runtime.removed': checkpoint.messages.length - restoredMessages.length,
1417
1769
  })
1418
1770
  }
1419
1771
 
@@ -1432,14 +1784,24 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1432
1784
  }
1433
1785
  ctx.runMgr.pushMessage(msg)
1434
1786
  }
1787
+
1788
+ // The queue, on the resume path too. It is drained
1789
+ // unconditionally above, so leaving this out would take a
1790
+ // host's "start with this" off the record and deliver it
1791
+ // nowhere — the one outcome a durable queue must not have.
1792
+ //
1793
+ // AFTER the restored history rather than before it: on a
1794
+ // resume the conversation already exists, and a message left
1795
+ // for "the next run" is the newest thing said, not the oldest.
1796
+ for (const queued of queuedForThisRun) ctx.runMgr.pushMessage(queued)
1435
1797
  } else if (params.continuationMode) {
1436
- for (const msg of params.messages) {
1798
+ for (const msg of initialMessages) {
1437
1799
  ctx.runMgr.pushMessage(msg)
1438
1800
  }
1439
1801
  } else {
1440
1802
  pushSystemMessages()
1441
1803
  let isFirstUserMessage = true
1442
- for (const msg of params.messages) {
1804
+ for (const msg of initialMessages) {
1443
1805
  if (msg.role === 'system') continue
1444
1806
  ctx.runMgr.pushMessage(msg)
1445
1807
 
@@ -1463,6 +1825,23 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1463
1825
  })
1464
1826
  yield* eventTranslator.drainPending()
1465
1827
 
1828
+ // The box is handed out HERE, after `run_started`, and the position
1829
+ // is load-bearing rather than tidy. It moved twice:
1830
+ //
1831
+ // 1. Beside the box's construction — a host that called `set`
1832
+ // synchronously reached `eventTranslator` inside its temporal
1833
+ // dead zone and killed the run before it started.
1834
+ // 2. Beside the translator's construction — the translator existed,
1835
+ // but the run directory did not, so the durable append hit
1836
+ // ENOENT on `transcript.jsonl`.
1837
+ //
1838
+ // Both were found by the test that takes the box and immediately
1839
+ // swaps the policy, which is not an exotic host: it is the shape of
1840
+ // "start unattended" wiring. A policy change is durably recorded
1841
+ // before it takes effect, so the handout cannot precede the run
1842
+ // being writable.
1843
+ params.onApprovalPolicy?.(approvalPolicy)
1844
+
1466
1845
  // Surface capability degradation to the host as run events —
1467
1846
  // explicit, not silent (the log.warn above fires at setup time;
1468
1847
  // this is the machine-readable channel).
@@ -1499,7 +1878,27 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1499
1878
 
1500
1879
  // --- Sandbox lifecycle: create before iteration loop ---
1501
1880
  if (params.sandboxProvider) {
1881
+ const rootAtCwd = params.runConfig.sandbox?.workspace === 'working-directory'
1882
+ // Checked against what the CALLER passed, not against `ctx.cwd`.
1883
+ // `ctx.cwd` falls back to `process.cwd()`, so reading it here
1884
+ // would silently root the sandbox at whatever directory the
1885
+ // host process happens to be in — which is not the directory
1886
+ // anybody asked to confine, and is worse than the temp dir the
1887
+ // caller declined. Refused before the sandbox exists, and not
1888
+ // downgraded to ephemeral: a caller who asked for confinement
1889
+ // of a specific tree and quietly got an empty one has been
1890
+ // told their files are protected by something that is not
1891
+ // looking at them.
1892
+ if (rootAtCwd && params.workingDirectory === undefined) {
1893
+ throw new NamzuError({
1894
+ code: 'invalid_config',
1895
+ message:
1896
+ "sandbox.workspace is 'working-directory' but this run has no workingDirectory. Pass one, or use the default 'ephemeral' — the kernel will not fall back to a temp directory, because that would confine a directory you did not name.",
1897
+ details: { workspace: 'working-directory' },
1898
+ })
1899
+ }
1502
1900
  sandbox = await params.sandboxProvider.create({
1901
+ ...(rootAtCwd ? { workingDirectory: ctx.cwd } : {}),
1503
1902
  timeoutMs: params.runConfig.sandbox?.timeoutMs,
1504
1903
  memoryLimitMb: params.runConfig.sandbox?.memoryLimitMb,
1505
1904
  maxProcesses: params.runConfig.sandbox?.maxProcesses,
@@ -1515,9 +1914,9 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1515
1914
  yield* eventTranslator.drainPending()
1516
1915
 
1517
1916
  ctx.log.info('Sandbox created for run', {
1518
- sandboxId: sandbox.id,
1519
- environment: sandbox.environment,
1520
- rootDir: sandbox.rootDir,
1917
+ 'namzu.sandbox.id': sandbox.id,
1918
+ 'namzu.execution.environment': sandbox.environment,
1919
+ 'namzu.runtime.root_dir': sandbox.rootDir,
1521
1920
  })
1522
1921
  }
1523
1922
 
@@ -1531,7 +1930,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1531
1930
  } else {
1532
1931
  ctx.log.warn(
1533
1932
  'emergencySave requested but the run has no output directory — crash dumps disabled',
1534
- { runId: ctx.runId },
1933
+ { [NAMZU.RUN_ID]: ctx.runId },
1535
1934
  )
1536
1935
  }
1537
1936
  }
@@ -1559,6 +1958,15 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1559
1958
  ...(inputVerdict.reason ? { reason: inputVerdict.reason } : {}),
1560
1959
  })
1561
1960
  yield* eventTranslator.drainPending()
1961
+ // A guardrail block is a refusal — first-class in the audit trail
1962
+ // (LOG-14, design §5), not merely a RunEvent a host happens to be
1963
+ // subscribed to when it fires.
1964
+ await ctx.runMgr.recordAudit({
1965
+ what: { action: 'guardrail:input', resource: inputVerdict.name },
1966
+ outcome: 'refused',
1967
+ reason: inputVerdict.reason ?? 'blocked by an input guardrail',
1968
+ ...(params.persona?.identity.role ? { persona: params.persona.identity.role } : {}),
1969
+ })
1562
1970
  ctx.runMgr.setStopReason('input_guardrail')
1563
1971
  ctx.runMgr.setLastError(inputVerdict.reason ?? 'blocked by an input guardrail')
1564
1972
  yield* resultAssembler.completeRun(rootSpan)
@@ -1570,9 +1978,11 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1570
1978
  // tool that needs one gets it.
1571
1979
  if (pendingResume) {
1572
1980
  ctx.log.info('Applying a pending HITL decision to the checkpointed tool calls', {
1573
- runId: ctx.runId,
1574
- tools: pendingResume.response.message.toolCalls?.map((tc) => tc.function.name),
1575
- denied: pendingResume.denials.size,
1981
+ [NAMZU.RUN_ID]: ctx.runId,
1982
+ 'namzu.tool.names': pendingResume.response.message.toolCalls?.map(
1983
+ (tc) => tc.function.name,
1984
+ ),
1985
+ 'namzu.runtime.denied': pendingResume.denials.size,
1576
1986
  })
1577
1987
  // Hand the recorded answer to the already-built tool. The tool
1578
1988
  // closed over its registry when the agent was constructed,
@@ -1598,9 +2008,9 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1598
2008
  .unpark(resolvedCheckpointId, params.pendingDecision)
1599
2009
  .catch((err: unknown) => {
1600
2010
  ctx.log.error('Applied a pending decision but failed to clear the park', {
1601
- runId: ctx.runId,
1602
- checkpointId: resolvedCheckpointId,
1603
- error: err instanceof Error ? err.message : String(err),
2011
+ [NAMZU.RUN_ID]: ctx.runId,
2012
+ 'namzu.checkpoint.id': resolvedCheckpointId,
2013
+ 'exception.message': err instanceof Error ? err.message : String(err),
1604
2014
  })
1605
2015
  return null
1606
2016
  })
@@ -1651,6 +2061,13 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1651
2061
  ...(outputVerdict.reason ? { reason: outputVerdict.reason } : {}),
1652
2062
  })
1653
2063
  yield* eventTranslator.drainPending()
2064
+ // Same reasoning as the input-guardrail branch above.
2065
+ await ctx.runMgr.recordAudit({
2066
+ what: { action: 'guardrail:output', resource: outputVerdict.name },
2067
+ outcome: 'refused',
2068
+ reason: outputVerdict.reason ?? 'blocked by an output guardrail',
2069
+ ...(params.persona?.identity.role ? { persona: params.persona.identity.role } : {}),
2070
+ })
1654
2071
  ctx.runMgr.setStopReason('output_guardrail')
1655
2072
  ctx.runMgr.setLastError(outputVerdict.reason ?? 'blocked by an output guardrail')
1656
2073
  ctx.runMgr.setResult('')
@@ -1680,6 +2097,30 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1680
2097
  // process's life.
1681
2098
  emergencyManager?.detach()
1682
2099
 
2100
+ // A background job outlives the tool call that started it — that
2101
+ // is what it is for — so nothing but this stops it outliving the
2102
+ // RUN. Scoped to this run's id: a shared registry serving several
2103
+ // runs must not have one of them tear down another's work.
2104
+ //
2105
+ // Awaited, and its failure swallowed. A job that would not die is
2106
+ // worth a log line, and is not worth retracting a run's answer.
2107
+ if (params.backgroundJobs) {
2108
+ try {
2109
+ const stopped = await params.backgroundJobs.killOwner(ctx.runId)
2110
+ if (stopped.length > 0) {
2111
+ ctx.log.info('Background jobs stopped with the run', {
2112
+ [NAMZU.RUN_ID]: ctx.runId,
2113
+ 'namzu.jobs.stopped': stopped.length,
2114
+ })
2115
+ }
2116
+ } catch (jobErr) {
2117
+ ctx.log.error('A background job did not stop cleanly', {
2118
+ [NAMZU.RUN_ID]: ctx.runId,
2119
+ ...errorAttributes(jobErr),
2120
+ })
2121
+ }
2122
+ }
2123
+
1683
2124
  // Same reasoning for the question channel: the tools outlive the
1684
2125
  // run that bound them, so leaving it attached would have a later
1685
2126
  // run's question written into this run's checkpoint store.
@@ -1697,8 +2138,9 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1697
2138
  await params.promoteMemory(candidate)
1698
2139
  } catch (promoteErr) {
1699
2140
  ctx.log.error('Memory promotion threw — the run is unaffected', {
1700
- runId: ctx.runId,
1701
- error: promoteErr instanceof Error ? promoteErr.message : String(promoteErr),
2141
+ [NAMZU.RUN_ID]: ctx.runId,
2142
+ 'exception.message':
2143
+ promoteErr instanceof Error ? promoteErr.message : String(promoteErr),
1702
2144
  })
1703
2145
  }
1704
2146
  }
@@ -1713,11 +2155,12 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
1713
2155
  runId: ctx.runId,
1714
2156
  sandboxId,
1715
2157
  })
1716
- ctx.log.info('Sandbox destroyed', { sandboxId })
2158
+ ctx.log.info('Sandbox destroyed', { 'namzu.sandbox.id': sandboxId })
1717
2159
  } catch (destroyErr) {
1718
2160
  ctx.log.error('Sandbox destroy failed', {
1719
- sandboxId,
1720
- error: destroyErr instanceof Error ? destroyErr.message : String(destroyErr),
2161
+ 'namzu.sandbox.id': sandboxId,
2162
+ 'exception.message':
2163
+ destroyErr instanceof Error ? destroyErr.message : String(destroyErr),
1721
2164
  })
1722
2165
  }
1723
2166
  }
@@ -1749,7 +2192,7 @@ async function* catchUpFromCursor(
1749
2192
  runMgr: RunPersistence,
1750
2193
  cursor: RunEventCursor,
1751
2194
  onEventReplay: ((replay: RunEventReplay) => void) | undefined,
1752
- generation: ClaimFence | undefined,
2195
+ generation: FencingToken | undefined,
1753
2196
  ): AsyncGenerator<RunEvent, void> {
1754
2197
  const missed = await runMgr.getRunStore().readEvents({ sinceSeq: cursor.sinceSeq })
1755
2198
  const replay = resolveRunEventReplay(