@namzu/sdk 30.2.0 → 31.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (712) hide show
  1. package/CHANGELOG.md +556 -0
  2. package/README.md +43 -2
  3. package/dist/advisory/executor.d.ts +2 -1
  4. package/dist/advisory/executor.d.ts.map +1 -1
  5. package/dist/advisory/executor.js +4 -1
  6. package/dist/advisory/executor.js.map +1 -1
  7. package/dist/agents/ReactiveAgent.d.ts.map +1 -1
  8. package/dist/agents/ReactiveAgent.js +12 -0
  9. package/dist/agents/ReactiveAgent.js.map +1 -1
  10. package/dist/agents/RouterAgent.d.ts.map +1 -1
  11. package/dist/agents/RouterAgent.js +21 -3
  12. package/dist/agents/RouterAgent.js.map +1 -1
  13. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  14. package/dist/agents/SupervisorAgent.js +34 -11
  15. package/dist/agents/SupervisorAgent.js.map +1 -1
  16. package/dist/agents/runAgent.d.ts +12 -0
  17. package/dist/agents/runAgent.d.ts.map +1 -1
  18. package/dist/agents/runAgent.js +26 -2
  19. package/dist/agents/runAgent.js.map +1 -1
  20. package/dist/authorization/command-line.d.ts +81 -0
  21. package/dist/authorization/command-line.d.ts.map +1 -0
  22. package/dist/authorization/command-line.js +347 -0
  23. package/dist/authorization/command-line.js.map +1 -0
  24. package/dist/authorization/rules.d.ts.map +1 -1
  25. package/dist/authorization/rules.js +22 -1
  26. package/dist/authorization/rules.js.map +1 -1
  27. package/dist/bridge/a2a/client.d.ts +23 -5
  28. package/dist/bridge/a2a/client.d.ts.map +1 -1
  29. package/dist/bridge/a2a/client.js +320 -73
  30. package/dist/bridge/a2a/client.js.map +1 -1
  31. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  32. package/dist/bridge/a2a/mapper.js +4 -0
  33. package/dist/bridge/a2a/mapper.js.map +1 -1
  34. package/dist/bridge/acp/server.d.ts +13 -1
  35. package/dist/bridge/acp/server.d.ts.map +1 -1
  36. package/dist/bridge/acp/server.js +150 -44
  37. package/dist/bridge/acp/server.js.map +1 -1
  38. package/dist/bridge/mcp/connector/adapter.d.ts +3 -2
  39. package/dist/bridge/mcp/connector/adapter.d.ts.map +1 -1
  40. package/dist/bridge/mcp/connector/adapter.js +17 -21
  41. package/dist/bridge/mcp/connector/adapter.js.map +1 -1
  42. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  43. package/dist/bridge/sse/mapper.js +3 -0
  44. package/dist/bridge/sse/mapper.js.map +1 -1
  45. package/dist/compaction/dangling.d.ts +29 -2
  46. package/dist/compaction/dangling.d.ts.map +1 -1
  47. package/dist/compaction/dangling.js +172 -35
  48. package/dist/compaction/dangling.js.map +1 -1
  49. package/dist/compaction/index.d.ts +3 -2
  50. package/dist/compaction/index.d.ts.map +1 -1
  51. package/dist/compaction/index.js +1 -1
  52. package/dist/compaction/index.js.map +1 -1
  53. package/dist/compaction/manual.d.ts +11 -1
  54. package/dist/compaction/manual.d.ts.map +1 -1
  55. package/dist/compaction/manual.js +89 -14
  56. package/dist/compaction/manual.js.map +1 -1
  57. package/dist/compaction/plan.d.ts +19 -6
  58. package/dist/compaction/plan.d.ts.map +1 -1
  59. package/dist/compaction/plan.js +18 -4
  60. package/dist/compaction/plan.js.map +1 -1
  61. package/dist/compaction/retention.d.ts +10 -7
  62. package/dist/compaction/retention.d.ts.map +1 -1
  63. package/dist/compaction/retention.js +26 -8
  64. package/dist/compaction/retention.js.map +1 -1
  65. package/dist/compaction/summary.d.ts +4 -4
  66. package/dist/compaction/summary.js +4 -4
  67. package/dist/compaction/verifier.d.ts +19 -1
  68. package/dist/compaction/verifier.d.ts.map +1 -1
  69. package/dist/compaction/verifier.js +20 -1
  70. package/dist/compaction/verifier.js.map +1 -1
  71. package/dist/config/runtime.d.ts +6 -6
  72. package/dist/connector/BaseConnector.d.ts +6 -4
  73. package/dist/connector/BaseConnector.d.ts.map +1 -1
  74. package/dist/connector/BaseConnector.js +8 -2
  75. package/dist/connector/BaseConnector.js.map +1 -1
  76. package/dist/connector/builtins/http.d.ts +16 -4
  77. package/dist/connector/builtins/http.d.ts.map +1 -1
  78. package/dist/connector/builtins/http.js +177 -44
  79. package/dist/connector/builtins/http.js.map +1 -1
  80. package/dist/connector/builtins/webhook.d.ts +15 -4
  81. package/dist/connector/builtins/webhook.d.ts.map +1 -1
  82. package/dist/connector/builtins/webhook.js +165 -45
  83. package/dist/connector/builtins/webhook.js.map +1 -1
  84. package/dist/connector/execution-contract.d.ts +11 -0
  85. package/dist/connector/execution-contract.d.ts.map +1 -0
  86. package/dist/connector/execution-contract.js +14 -0
  87. package/dist/connector/execution-contract.js.map +1 -0
  88. package/dist/connector/http-operation.d.ts +48 -0
  89. package/dist/connector/http-operation.d.ts.map +1 -0
  90. package/dist/connector/http-operation.js +205 -0
  91. package/dist/connector/http-operation.js.map +1 -0
  92. package/dist/connector/mcp/adapter.d.ts.map +1 -1
  93. package/dist/connector/mcp/adapter.js +8 -3
  94. package/dist/connector/mcp/adapter.js.map +1 -1
  95. package/dist/connector/mcp/client.d.ts +14 -8
  96. package/dist/connector/mcp/client.d.ts.map +1 -1
  97. package/dist/connector/mcp/client.js +160 -44
  98. package/dist/connector/mcp/client.js.map +1 -1
  99. package/dist/connector/mcp/http-sse.d.ts +8 -2
  100. package/dist/connector/mcp/http-sse.d.ts.map +1 -1
  101. package/dist/connector/mcp/http-sse.js +70 -17
  102. package/dist/connector/mcp/http-sse.js.map +1 -1
  103. package/dist/connector/mcp/prompt-adapter.d.ts.map +1 -1
  104. package/dist/connector/mcp/prompt-adapter.js +9 -2
  105. package/dist/connector/mcp/prompt-adapter.js.map +1 -1
  106. package/dist/connector/mcp/stdio.d.ts +2 -2
  107. package/dist/connector/mcp/stdio.d.ts.map +1 -1
  108. package/dist/connector/mcp/stdio.js +14 -50
  109. package/dist/connector/mcp/stdio.js.map +1 -1
  110. package/dist/connector/mcp/streamable-http.d.ts +7 -2
  111. package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
  112. package/dist/connector/mcp/streamable-http.js +66 -18
  113. package/dist/connector/mcp/streamable-http.js.map +1 -1
  114. package/dist/connector/tools/adapter.d.ts +2 -2
  115. package/dist/connector/tools/adapter.d.ts.map +1 -1
  116. package/dist/connector/tools/adapter.js +23 -14
  117. package/dist/connector/tools/adapter.js.map +1 -1
  118. package/dist/connector/tools/definitions.d.ts.map +1 -1
  119. package/dist/connector/tools/definitions.js +5 -2
  120. package/dist/connector/tools/definitions.js.map +1 -1
  121. package/dist/connector/tools/result.d.ts +4 -0
  122. package/dist/connector/tools/result.d.ts.map +1 -0
  123. package/dist/connector/tools/result.js +20 -0
  124. package/dist/connector/tools/result.js.map +1 -0
  125. package/dist/connector/web/guarded-fetch.d.ts +4 -2
  126. package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
  127. package/dist/connector/web/guarded-fetch.js +157 -43
  128. package/dist/connector/web/guarded-fetch.js.map +1 -1
  129. package/dist/constants/sandbox/index.d.ts +3 -2
  130. package/dist/constants/sandbox/index.d.ts.map +1 -1
  131. package/dist/constants/sandbox/index.js +3 -2
  132. package/dist/constants/sandbox/index.js.map +1 -1
  133. package/dist/contracts/api.d.ts +2 -0
  134. package/dist/contracts/api.d.ts.map +1 -1
  135. package/dist/contracts/schemas.d.ts +38 -12
  136. package/dist/contracts/schemas.d.ts.map +1 -1
  137. package/dist/contracts/schemas.js +7 -0
  138. package/dist/contracts/schemas.js.map +1 -1
  139. package/dist/directory/derive-supervisor.d.ts.map +1 -1
  140. package/dist/directory/derive-supervisor.js +8 -0
  141. package/dist/directory/derive-supervisor.js.map +1 -1
  142. package/dist/directory/derive.d.ts.map +1 -1
  143. package/dist/directory/derive.js +8 -0
  144. package/dist/directory/derive.js.map +1 -1
  145. package/dist/directory/load.d.ts.map +1 -1
  146. package/dist/directory/load.js +2 -0
  147. package/dist/directory/load.js.map +1 -1
  148. package/dist/directory/types.d.ts +4 -0
  149. package/dist/directory/types.d.ts.map +1 -1
  150. package/dist/eval/experiment.d.ts +10 -10
  151. package/dist/eval/experiment.d.ts.map +1 -1
  152. package/dist/eval/experiment.js +121 -91
  153. package/dist/eval/experiment.js.map +1 -1
  154. package/dist/eval/judge.d.ts +6 -0
  155. package/dist/eval/judge.d.ts.map +1 -1
  156. package/dist/eval/judge.js +7 -2
  157. package/dist/eval/judge.js.map +1 -1
  158. package/dist/eval/types.d.ts +7 -1
  159. package/dist/eval/types.d.ts.map +1 -1
  160. package/dist/manager/agent/lifecycle.d.ts +12 -10
  161. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  162. package/dist/manager/agent/lifecycle.js +16 -3
  163. package/dist/manager/agent/lifecycle.js.map +1 -1
  164. package/dist/manager/connector/environment.d.ts +2 -2
  165. package/dist/manager/connector/environment.d.ts.map +1 -1
  166. package/dist/manager/connector/environment.js +2 -2
  167. package/dist/manager/connector/environment.js.map +1 -1
  168. package/dist/manager/connector/lifecycle.d.ts +10 -2
  169. package/dist/manager/connector/lifecycle.d.ts.map +1 -1
  170. package/dist/manager/connector/lifecycle.js +273 -24
  171. package/dist/manager/connector/lifecycle.js.map +1 -1
  172. package/dist/manager/connector/tenant.d.ts +5 -4
  173. package/dist/manager/connector/tenant.d.ts.map +1 -1
  174. package/dist/manager/connector/tenant.js +47 -22
  175. package/dist/manager/connector/tenant.js.map +1 -1
  176. package/dist/manager/goal/activation.d.ts +23 -0
  177. package/dist/manager/goal/activation.d.ts.map +1 -0
  178. package/dist/manager/goal/activation.js +41 -0
  179. package/dist/manager/goal/activation.js.map +1 -0
  180. package/dist/manager/index.d.ts +3 -2
  181. package/dist/manager/index.d.ts.map +1 -1
  182. package/dist/manager/index.js.map +1 -1
  183. package/dist/manager/run/persistence.d.ts +2 -0
  184. package/dist/manager/run/persistence.d.ts.map +1 -1
  185. package/dist/manager/run/persistence.js +5 -1
  186. package/dist/manager/run/persistence.js.map +1 -1
  187. package/dist/manager/topic/dependency.d.ts +24 -0
  188. package/dist/manager/topic/dependency.d.ts.map +1 -0
  189. package/dist/manager/topic/dependency.js +13 -0
  190. package/dist/manager/topic/dependency.js.map +1 -0
  191. package/dist/manager/topic/lifecycle.d.ts +9 -21
  192. package/dist/manager/topic/lifecycle.d.ts.map +1 -1
  193. package/dist/manager/topic/lifecycle.js +17 -29
  194. package/dist/manager/topic/lifecycle.js.map +1 -1
  195. package/dist/plugin/index.d.ts +1 -0
  196. package/dist/plugin/index.d.ts.map +1 -1
  197. package/dist/plugin/index.js.map +1 -1
  198. package/dist/plugin/lifecycle.d.ts +15 -0
  199. package/dist/plugin/lifecycle.d.ts.map +1 -1
  200. package/dist/plugin/lifecycle.js +144 -38
  201. package/dist/plugin/lifecycle.js.map +1 -1
  202. package/dist/plugin/loader.d.ts +3 -3
  203. package/dist/plugin/loader.d.ts.map +1 -1
  204. package/dist/plugin/loader.js +58 -12
  205. package/dist/plugin/loader.js.map +1 -1
  206. package/dist/provider/collect-chat-completion.d.ts.map +1 -1
  207. package/dist/provider/collect-chat-completion.js +4 -0
  208. package/dist/provider/collect-chat-completion.js.map +1 -1
  209. package/dist/provider/fallback.d.ts +3 -1
  210. package/dist/provider/fallback.d.ts.map +1 -1
  211. package/dist/provider/fallback.js +62 -10
  212. package/dist/provider/fallback.js.map +1 -1
  213. package/dist/provider/idle-timeout.d.ts +4 -0
  214. package/dist/provider/idle-timeout.d.ts.map +1 -1
  215. package/dist/provider/idle-timeout.js +131 -15
  216. package/dist/provider/idle-timeout.js.map +1 -1
  217. package/dist/provider/index.d.ts +2 -0
  218. package/dist/provider/index.d.ts.map +1 -1
  219. package/dist/provider/index.js +1 -0
  220. package/dist/provider/index.js.map +1 -1
  221. package/dist/provider/instrumentation.d.ts.map +1 -1
  222. package/dist/provider/instrumentation.js +1 -0
  223. package/dist/provider/instrumentation.js.map +1 -1
  224. package/dist/provider/retry.d.ts.map +1 -1
  225. package/dist/provider/retry.js +13 -1
  226. package/dist/provider/retry.js.map +1 -1
  227. package/dist/public-runtime.d.ts +57 -24
  228. package/dist/public-runtime.d.ts.map +1 -1
  229. package/dist/public-runtime.js +42 -35
  230. package/dist/public-runtime.js.map +1 -1
  231. package/dist/public-tools.d.ts +1 -0
  232. package/dist/public-tools.d.ts.map +1 -1
  233. package/dist/public-tools.js +5 -0
  234. package/dist/public-tools.js.map +1 -1
  235. package/dist/public-types.d.ts +33 -12
  236. package/dist/public-types.d.ts.map +1 -1
  237. package/dist/rag/embedding.d.ts +8 -3
  238. package/dist/rag/embedding.d.ts.map +1 -1
  239. package/dist/rag/embedding.js +120 -9
  240. package/dist/rag/embedding.js.map +1 -1
  241. package/dist/rag/index.d.ts +1 -1
  242. package/dist/rag/index.d.ts.map +1 -1
  243. package/dist/rag/index.js +1 -1
  244. package/dist/rag/index.js.map +1 -1
  245. package/dist/rag/ingestion.d.ts +2 -2
  246. package/dist/rag/ingestion.d.ts.map +1 -1
  247. package/dist/rag/ingestion.js +15 -3
  248. package/dist/rag/ingestion.js.map +1 -1
  249. package/dist/rag/knowledge-base.d.ts +3 -3
  250. package/dist/rag/knowledge-base.d.ts.map +1 -1
  251. package/dist/rag/knowledge-base.js +8 -4
  252. package/dist/rag/knowledge-base.js.map +1 -1
  253. package/dist/rag/operation.d.ts +10 -0
  254. package/dist/rag/operation.d.ts.map +1 -0
  255. package/dist/rag/operation.js +26 -0
  256. package/dist/rag/operation.js.map +1 -0
  257. package/dist/rag/rag-tool.d.ts.map +1 -1
  258. package/dist/rag/rag-tool.js +6 -3
  259. package/dist/rag/rag-tool.js.map +1 -1
  260. package/dist/rag/retriever.d.ts +2 -2
  261. package/dist/rag/retriever.d.ts.map +1 -1
  262. package/dist/rag/retriever.js +31 -15
  263. package/dist/rag/retriever.js.map +1 -1
  264. package/dist/rag/vector-store.d.ts +3 -3
  265. package/dist/rag/vector-store.d.ts.map +1 -1
  266. package/dist/rag/vector-store.js +4 -2
  267. package/dist/rag/vector-store.js.map +1 -1
  268. package/dist/registry/command/kernel-commands.d.ts +16 -4
  269. package/dist/registry/command/kernel-commands.d.ts.map +1 -1
  270. package/dist/registry/command/kernel-commands.js +171 -0
  271. package/dist/registry/command/kernel-commands.js.map +1 -1
  272. package/dist/run/reporter.d.ts.map +1 -1
  273. package/dist/run/reporter.js +9 -0
  274. package/dist/run/reporter.js.map +1 -1
  275. package/dist/run-query/index.d.ts +15 -1
  276. package/dist/run-query/index.d.ts.map +1 -1
  277. package/dist/run-query/index.js +69 -15
  278. package/dist/run-query/index.js.map +1 -1
  279. package/dist/runtime/query/context.d.ts.map +1 -1
  280. package/dist/runtime/query/context.js +10 -3
  281. package/dist/runtime/query/context.js.map +1 -1
  282. package/dist/runtime/query/executor.d.ts +3 -0
  283. package/dist/runtime/query/executor.d.ts.map +1 -1
  284. package/dist/runtime/query/executor.js +80 -18
  285. package/dist/runtime/query/executor.js.map +1 -1
  286. package/dist/runtime/query/guard.d.ts +9 -0
  287. package/dist/runtime/query/guard.d.ts.map +1 -1
  288. package/dist/runtime/query/guard.js +11 -0
  289. package/dist/runtime/query/guard.js.map +1 -1
  290. package/dist/runtime/query/index.d.ts +30 -1
  291. package/dist/runtime/query/index.d.ts.map +1 -1
  292. package/dist/runtime/query/index.js +548 -95
  293. package/dist/runtime/query/index.js.map +1 -1
  294. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  295. package/dist/runtime/query/iteration/index.js +74 -14
  296. package/dist/runtime/query/iteration/index.js.map +1 -1
  297. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  298. package/dist/runtime/query/iteration/phases/compaction.js +94 -53
  299. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  300. package/dist/runtime/query/iteration/phases/context.d.ts +3 -0
  301. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  302. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  303. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  304. package/dist/runtime/query/iteration/phases/tool-review.js +21 -0
  305. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  306. package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
  307. package/dist/runtime/query/iteration/stream-turn.js +4 -0
  308. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  309. package/dist/runtime/query/project-instructions.d.ts +69 -0
  310. package/dist/runtime/query/project-instructions.d.ts.map +1 -0
  311. package/dist/runtime/query/project-instructions.js +137 -0
  312. package/dist/runtime/query/project-instructions.js.map +1 -0
  313. package/dist/runtime/query/request-rich-content.d.ts +22 -0
  314. package/dist/runtime/query/request-rich-content.d.ts.map +1 -0
  315. package/dist/runtime/query/request-rich-content.js +122 -0
  316. package/dist/runtime/query/request-rich-content.js.map +1 -0
  317. package/dist/runtime/query/result.d.ts.map +1 -1
  318. package/dist/runtime/query/result.js +12 -1
  319. package/dist/runtime/query/result.js.map +1 -1
  320. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  321. package/dist/runtime/query/resume-pending.js +19 -20
  322. package/dist/runtime/query/resume-pending.js.map +1 -1
  323. package/dist/runtime/query/resume-run.d.ts.map +1 -1
  324. package/dist/runtime/query/resume-run.js +54 -8
  325. package/dist/runtime/query/resume-run.js.map +1 -1
  326. package/dist/runtime/query/run-state.d.ts +5 -0
  327. package/dist/runtime/query/run-state.d.ts.map +1 -1
  328. package/dist/runtime/query/run-state.js +6 -1
  329. package/dist/runtime/query/run-state.js.map +1 -1
  330. package/dist/runtime/query/sandbox-lifecycle.d.ts +54 -0
  331. package/dist/runtime/query/sandbox-lifecycle.d.ts.map +1 -0
  332. package/dist/runtime/query/sandbox-lifecycle.js +167 -0
  333. package/dist/runtime/query/sandbox-lifecycle.js.map +1 -0
  334. package/dist/sandbox/isolation.d.ts.map +1 -1
  335. package/dist/sandbox/isolation.js +9 -0
  336. package/dist/sandbox/isolation.js.map +1 -1
  337. package/dist/sandbox/provider/local.d.ts +56 -6
  338. package/dist/sandbox/provider/local.d.ts.map +1 -1
  339. package/dist/sandbox/provider/local.js +181 -76
  340. package/dist/sandbox/provider/local.js.map +1 -1
  341. package/dist/sandbox/terminal.d.ts +13 -5
  342. package/dist/sandbox/terminal.d.ts.map +1 -1
  343. package/dist/sandbox/terminal.js +11 -3
  344. package/dist/sandbox/terminal.js.map +1 -1
  345. package/dist/session/errors.d.ts +28 -29
  346. package/dist/session/errors.d.ts.map +1 -1
  347. package/dist/session/errors.js +28 -29
  348. package/dist/session/errors.js.map +1 -1
  349. package/dist/session/handoff/broadcast.d.ts +5 -8
  350. package/dist/session/handoff/broadcast.d.ts.map +1 -1
  351. package/dist/session/handoff/broadcast.js +16 -6
  352. package/dist/session/handoff/broadcast.js.map +1 -1
  353. package/dist/session/handoff/single.d.ts +5 -8
  354. package/dist/session/handoff/single.d.ts.map +1 -1
  355. package/dist/session/handoff/single.js +7 -4
  356. package/dist/session/handoff/single.js.map +1 -1
  357. package/dist/store/attachment/index.d.ts +11 -3
  358. package/dist/store/attachment/index.d.ts.map +1 -1
  359. package/dist/store/attachment/index.js +49 -4
  360. package/dist/store/attachment/index.js.map +1 -1
  361. package/dist/store/feedback/conformance.d.ts.map +1 -1
  362. package/dist/store/feedback/conformance.js +32 -0
  363. package/dist/store/feedback/conformance.js.map +1 -1
  364. package/dist/store/feedback/disk.d.ts +8 -6
  365. package/dist/store/feedback/disk.d.ts.map +1 -1
  366. package/dist/store/feedback/disk.js +111 -76
  367. package/dist/store/feedback/disk.js.map +1 -1
  368. package/dist/store/goal/index.d.ts +111 -0
  369. package/dist/store/goal/index.d.ts.map +1 -0
  370. package/dist/store/goal/index.js +436 -0
  371. package/dist/store/goal/index.js.map +1 -0
  372. package/dist/store/index.d.ts +1 -1
  373. package/dist/store/index.d.ts.map +1 -1
  374. package/dist/store/index.js +1 -1
  375. package/dist/store/index.js.map +1 -1
  376. package/dist/store/kv/revision-record-store.d.ts +70 -0
  377. package/dist/store/kv/revision-record-store.d.ts.map +1 -0
  378. package/dist/store/kv/revision-record-store.js +290 -0
  379. package/dist/store/kv/revision-record-store.js.map +1 -0
  380. package/dist/store/memory/disk.d.ts +9 -7
  381. package/dist/store/memory/disk.d.ts.map +1 -1
  382. package/dist/store/memory/disk.js +256 -98
  383. package/dist/store/memory/disk.js.map +1 -1
  384. package/dist/store/run/disk.d.ts +10 -2
  385. package/dist/store/run/disk.d.ts.map +1 -1
  386. package/dist/store/run/disk.js +70 -4
  387. package/dist/store/run/disk.js.map +1 -1
  388. package/dist/store/run/memory.d.ts +4 -2
  389. package/dist/store/run/memory.d.ts.map +1 -1
  390. package/dist/store/run/memory.js +15 -1
  391. package/dist/store/run/memory.js.map +1 -1
  392. package/dist/store/session/disk.d.ts +9 -0
  393. package/dist/store/session/disk.d.ts.map +1 -1
  394. package/dist/store/session/disk.js +57 -5
  395. package/dist/store/session/disk.js.map +1 -1
  396. package/dist/store/session/memory.d.ts +1 -0
  397. package/dist/store/session/memory.d.ts.map +1 -1
  398. package/dist/store/session/memory.js +14 -0
  399. package/dist/store/session/memory.js.map +1 -1
  400. package/dist/store/topic/memory.d.ts +1 -2
  401. package/dist/store/topic/memory.d.ts.map +1 -1
  402. package/dist/store/topic/memory.js +4 -5
  403. package/dist/store/topic/memory.js.map +1 -1
  404. package/dist/store/topic/objective.d.ts +8 -4
  405. package/dist/store/topic/objective.d.ts.map +1 -1
  406. package/dist/store/topic/objective.js +185 -100
  407. package/dist/store/topic/objective.js.map +1 -1
  408. package/dist/store/topic/state.d.ts +1 -2
  409. package/dist/store/topic/state.d.ts.map +1 -1
  410. package/dist/store/topic/state.js +50 -62
  411. package/dist/store/topic/state.js.map +1 -1
  412. package/dist/tools/builtins/bash.d.ts.map +1 -1
  413. package/dist/tools/builtins/bash.js +20 -0
  414. package/dist/tools/builtins/bash.js.map +1 -1
  415. package/dist/tools/builtins/computer-use.d.ts +9 -1
  416. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  417. package/dist/tools/builtins/computer-use.js.map +1 -1
  418. package/dist/tools/builtins/content-fingerprint.d.ts +8 -7
  419. package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
  420. package/dist/tools/builtins/content-fingerprint.js +9 -10
  421. package/dist/tools/builtins/content-fingerprint.js.map +1 -1
  422. package/dist/tools/builtins/edit.d.ts +6 -1
  423. package/dist/tools/builtins/edit.d.ts.map +1 -1
  424. package/dist/tools/builtins/edit.js +166 -27
  425. package/dist/tools/builtins/edit.js.map +1 -1
  426. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  427. package/dist/tools/builtins/write-file.js +45 -19
  428. package/dist/tools/builtins/write-file.js.map +1 -1
  429. package/dist/tools/command-arguments.d.ts +43 -0
  430. package/dist/tools/command-arguments.d.ts.map +1 -0
  431. package/dist/tools/command-arguments.js +52 -0
  432. package/dist/tools/command-arguments.js.map +1 -0
  433. package/dist/tools/coordinator/index.d.ts +2 -0
  434. package/dist/tools/coordinator/index.d.ts.map +1 -1
  435. package/dist/tools/coordinator/index.js +3 -1
  436. package/dist/tools/coordinator/index.js.map +1 -1
  437. package/dist/tools/defineTool.d.ts +10 -0
  438. package/dist/tools/defineTool.d.ts.map +1 -1
  439. package/dist/tools/defineTool.js +1 -0
  440. package/dist/tools/defineTool.js.map +1 -1
  441. package/dist/tools/env-scrub.d.ts +7 -5
  442. package/dist/tools/env-scrub.d.ts.map +1 -1
  443. package/dist/tools/env-scrub.js +7 -5
  444. package/dist/tools/env-scrub.js.map +1 -1
  445. package/dist/tools/goal/index.d.ts +20 -0
  446. package/dist/tools/goal/index.d.ts.map +1 -0
  447. package/dist/tools/goal/index.js +104 -0
  448. package/dist/tools/goal/index.js.map +1 -0
  449. package/dist/tools/memory/index.d.ts +16 -0
  450. package/dist/tools/memory/index.d.ts.map +1 -1
  451. package/dist/tools/memory/index.js +6 -2
  452. package/dist/tools/memory/index.js.map +1 -1
  453. package/dist/tools/memory/search.d.ts +4 -1
  454. package/dist/tools/memory/search.d.ts.map +1 -1
  455. package/dist/tools/memory/search.js +10 -2
  456. package/dist/tools/memory/search.js.map +1 -1
  457. package/dist/types/agent/base.d.ts +11 -3
  458. package/dist/types/agent/base.d.ts.map +1 -1
  459. package/dist/types/agent/factory.d.ts +2 -0
  460. package/dist/types/agent/factory.d.ts.map +1 -1
  461. package/dist/types/agent/reactive.d.ts +2 -0
  462. package/dist/types/agent/reactive.d.ts.map +1 -1
  463. package/dist/types/agent/supervisor.d.ts +6 -0
  464. package/dist/types/agent/supervisor.d.ts.map +1 -1
  465. package/dist/types/agent/task.d.ts +6 -2
  466. package/dist/types/agent/task.d.ts.map +1 -1
  467. package/dist/types/connector/core.d.ts +13 -8
  468. package/dist/types/connector/core.d.ts.map +1 -1
  469. package/dist/types/connector/definition.d.ts +37 -18
  470. package/dist/types/connector/definition.d.ts.map +1 -1
  471. package/dist/types/connector/http.d.ts +6 -0
  472. package/dist/types/connector/http.d.ts.map +1 -1
  473. package/dist/types/connector/mcp.d.ts +24 -6
  474. package/dist/types/connector/mcp.d.ts.map +1 -1
  475. package/dist/types/connector/tenant.d.ts +17 -7
  476. package/dist/types/connector/tenant.d.ts.map +1 -1
  477. package/dist/types/connector/webhook.d.ts +6 -0
  478. package/dist/types/connector/webhook.d.ts.map +1 -1
  479. package/dist/types/goal/index.d.ts +46 -0
  480. package/dist/types/goal/index.d.ts.map +1 -0
  481. package/dist/types/goal/index.js +2 -0
  482. package/dist/types/goal/index.js.map +1 -0
  483. package/dist/types/ids/index.d.ts +2 -0
  484. package/dist/types/ids/index.d.ts.map +1 -1
  485. package/dist/types/ids/index.js.map +1 -1
  486. package/dist/types/message/index.d.ts +75 -10
  487. package/dist/types/message/index.d.ts.map +1 -1
  488. package/dist/types/message/index.js +49 -3
  489. package/dist/types/message/index.js.map +1 -1
  490. package/dist/types/plugin/index.d.ts +7 -5
  491. package/dist/types/plugin/index.d.ts.map +1 -1
  492. package/dist/types/plugin/index.js.map +1 -1
  493. package/dist/types/provider/chat.d.ts +27 -4
  494. package/dist/types/provider/chat.d.ts.map +1 -1
  495. package/dist/types/provider/interface.d.ts +18 -7
  496. package/dist/types/provider/interface.d.ts.map +1 -1
  497. package/dist/types/provider/stream.d.ts +6 -0
  498. package/dist/types/provider/stream.d.ts.map +1 -1
  499. package/dist/types/rag/embedding.d.ts +15 -2
  500. package/dist/types/rag/embedding.d.ts.map +1 -1
  501. package/dist/types/rag/ingestion.d.ts +2 -2
  502. package/dist/types/rag/ingestion.d.ts.map +1 -1
  503. package/dist/types/rag/knowledge-base.d.ts +3 -3
  504. package/dist/types/rag/knowledge-base.d.ts.map +1 -1
  505. package/dist/types/rag/retrieval.d.ts +2 -2
  506. package/dist/types/rag/retrieval.d.ts.map +1 -1
  507. package/dist/types/rag/scope.d.ts +4 -0
  508. package/dist/types/rag/scope.d.ts.map +1 -1
  509. package/dist/types/rag/vector.d.ts +5 -2
  510. package/dist/types/rag/vector.d.ts.map +1 -1
  511. package/dist/types/run/config.d.ts +20 -0
  512. package/dist/types/run/config.d.ts.map +1 -1
  513. package/dist/types/run/events.d.ts +25 -1
  514. package/dist/types/run/events.d.ts.map +1 -1
  515. package/dist/types/run/events.js.map +1 -1
  516. package/dist/types/run/metadata.d.ts +2 -0
  517. package/dist/types/run/metadata.d.ts.map +1 -1
  518. package/dist/types/run/step.d.ts +2 -6
  519. package/dist/types/run/step.d.ts.map +1 -1
  520. package/dist/types/run/step.js.map +1 -1
  521. package/dist/types/run/store.d.ts +55 -2
  522. package/dist/types/run/store.d.ts.map +1 -1
  523. package/dist/types/sandbox/index.d.ts +47 -6
  524. package/dist/types/sandbox/index.d.ts.map +1 -1
  525. package/dist/types/sandbox/index.js +23 -10
  526. package/dist/types/sandbox/index.js.map +1 -1
  527. package/dist/types/session/store.d.ts +13 -0
  528. package/dist/types/session/store.d.ts.map +1 -1
  529. package/dist/types/tool/index.d.ts +33 -11
  530. package/dist/types/tool/index.d.ts.map +1 -1
  531. package/dist/types/tool/index.js.map +1 -1
  532. package/dist/types/topic/entity.d.ts +3 -4
  533. package/dist/types/topic/entity.d.ts.map +1 -1
  534. package/dist/types/topic/store.d.ts +3 -3
  535. package/dist/utils/id.d.ts +3 -1
  536. package/dist/utils/id.d.ts.map +1 -1
  537. package/dist/utils/id.js +4 -0
  538. package/dist/utils/id.js.map +1 -1
  539. package/dist/utils/process-environment.d.ts +26 -0
  540. package/dist/utils/process-environment.d.ts.map +1 -0
  541. package/dist/utils/process-environment.js +78 -0
  542. package/dist/utils/process-environment.js.map +1 -0
  543. package/dist/vault/InMemoryCredentialVault.d.ts +2 -0
  544. package/dist/vault/InMemoryCredentialVault.d.ts.map +1 -1
  545. package/dist/vault/InMemoryCredentialVault.js +24 -4
  546. package/dist/vault/InMemoryCredentialVault.js.map +1 -1
  547. package/dist/vault/instrumentation.d.ts.map +1 -1
  548. package/dist/vault/instrumentation.js +15 -0
  549. package/dist/vault/instrumentation.js.map +1 -1
  550. package/package.json +1 -1
  551. package/src/advisory/executor.ts +4 -1
  552. package/src/agents/ReactiveAgent.ts +12 -0
  553. package/src/agents/RouterAgent.ts +25 -3
  554. package/src/agents/SupervisorAgent.ts +33 -11
  555. package/src/agents/runAgent.ts +38 -2
  556. package/src/authorization/command-line.ts +390 -0
  557. package/src/authorization/rules.ts +22 -1
  558. package/src/bridge/a2a/client.ts +384 -97
  559. package/src/bridge/a2a/mapper.ts +5 -0
  560. package/src/bridge/acp/server.ts +184 -42
  561. package/src/bridge/mcp/connector/adapter.ts +28 -20
  562. package/src/bridge/sse/mapper.ts +3 -0
  563. package/src/compaction/dangling.ts +203 -38
  564. package/src/compaction/index.ts +9 -2
  565. package/src/compaction/manual.ts +125 -18
  566. package/src/compaction/plan.ts +42 -11
  567. package/src/compaction/retention.ts +23 -8
  568. package/src/compaction/summary.ts +4 -4
  569. package/src/compaction/verifier.ts +66 -0
  570. package/src/connector/BaseConnector.ts +19 -4
  571. package/src/connector/builtins/http.ts +236 -46
  572. package/src/connector/builtins/webhook.ts +207 -47
  573. package/src/connector/execution-contract.ts +27 -0
  574. package/src/connector/http-operation.ts +238 -0
  575. package/src/connector/mcp/adapter.ts +8 -3
  576. package/src/connector/mcp/client.ts +207 -58
  577. package/src/connector/mcp/http-sse.ts +91 -23
  578. package/src/connector/mcp/prompt-adapter.ts +8 -2
  579. package/src/connector/mcp/stdio.ts +21 -46
  580. package/src/connector/mcp/streamable-http.ts +86 -22
  581. package/src/connector/tools/adapter.ts +23 -14
  582. package/src/connector/tools/definitions.ts +5 -2
  583. package/src/connector/tools/result.ts +21 -0
  584. package/src/connector/web/guarded-fetch.ts +188 -48
  585. package/src/constants/sandbox/index.ts +3 -2
  586. package/src/contracts/api.ts +2 -0
  587. package/src/contracts/schemas.ts +7 -0
  588. package/src/directory/derive-supervisor.ts +8 -0
  589. package/src/directory/derive.ts +8 -0
  590. package/src/directory/load.ts +2 -0
  591. package/src/directory/types.ts +4 -0
  592. package/src/eval/experiment.ts +160 -111
  593. package/src/eval/judge.ts +13 -2
  594. package/src/eval/types.ts +7 -1
  595. package/src/manager/agent/lifecycle.ts +28 -12
  596. package/src/manager/connector/environment.ts +3 -1
  597. package/src/manager/connector/lifecycle.ts +364 -24
  598. package/src/manager/connector/tenant.ts +56 -23
  599. package/src/manager/goal/activation.ts +52 -0
  600. package/src/manager/index.ts +10 -2
  601. package/src/manager/run/persistence.ts +6 -1
  602. package/src/manager/topic/dependency.ts +39 -0
  603. package/src/manager/topic/lifecycle.ts +19 -31
  604. package/src/plugin/index.ts +1 -0
  605. package/src/plugin/lifecycle.ts +180 -39
  606. package/src/plugin/loader.ts +70 -13
  607. package/src/provider/collect-chat-completion.ts +3 -0
  608. package/src/provider/fallback.ts +79 -11
  609. package/src/provider/idle-timeout.ts +143 -17
  610. package/src/provider/index.ts +2 -0
  611. package/src/provider/instrumentation.ts +1 -0
  612. package/src/provider/retry.ts +16 -1
  613. package/src/public-runtime.ts +190 -32
  614. package/src/public-tools.ts +5 -0
  615. package/src/public-types.ts +85 -11
  616. package/src/rag/embedding.ts +147 -19
  617. package/src/rag/index.ts +1 -1
  618. package/src/rag/ingestion.ts +16 -2
  619. package/src/rag/knowledge-base.ts +13 -4
  620. package/src/rag/operation.ts +28 -0
  621. package/src/rag/rag-tool.ts +6 -3
  622. package/src/rag/retriever.ts +62 -11
  623. package/src/rag/vector-store.ts +8 -2
  624. package/src/registry/command/kernel-commands.ts +223 -4
  625. package/src/run/reporter.ts +10 -0
  626. package/src/run-query/index.ts +84 -15
  627. package/src/runtime/query/context.ts +13 -3
  628. package/src/runtime/query/executor.ts +90 -17
  629. package/src/runtime/query/guard.ts +12 -0
  630. package/src/runtime/query/index.ts +652 -103
  631. package/src/runtime/query/iteration/index.ts +89 -13
  632. package/src/runtime/query/iteration/phases/compaction.ts +120 -55
  633. package/src/runtime/query/iteration/phases/context.ts +4 -0
  634. package/src/runtime/query/iteration/phases/tool-review.ts +28 -0
  635. package/src/runtime/query/iteration/stream-turn.ts +3 -0
  636. package/src/runtime/query/project-instructions.ts +212 -0
  637. package/src/runtime/query/request-rich-content.ts +153 -0
  638. package/src/runtime/query/result.ts +12 -1
  639. package/src/runtime/query/resume-pending.ts +20 -18
  640. package/src/runtime/query/resume-run.ts +52 -8
  641. package/src/runtime/query/run-state.ts +11 -1
  642. package/src/runtime/query/sandbox-lifecycle.ts +210 -0
  643. package/src/sandbox/isolation.ts +9 -0
  644. package/src/sandbox/provider/local.ts +255 -90
  645. package/src/sandbox/terminal.ts +13 -5
  646. package/src/session/errors.ts +68 -42
  647. package/src/session/handoff/broadcast.ts +20 -14
  648. package/src/session/handoff/single.ts +14 -13
  649. package/src/store/attachment/index.ts +65 -3
  650. package/src/store/feedback/conformance.ts +39 -0
  651. package/src/store/feedback/disk.ts +128 -82
  652. package/src/store/goal/index.ts +594 -0
  653. package/src/store/index.ts +1 -1
  654. package/src/store/kv/revision-record-store.ts +346 -0
  655. package/src/store/memory/disk.ts +288 -113
  656. package/src/store/run/disk.ts +96 -5
  657. package/src/store/run/memory.ts +22 -2
  658. package/src/store/session/disk.ts +93 -6
  659. package/src/store/session/memory.ts +22 -0
  660. package/src/store/topic/memory.ts +4 -5
  661. package/src/store/topic/objective.ts +215 -100
  662. package/src/store/topic/state.ts +100 -63
  663. package/src/tools/builtins/bash.ts +21 -0
  664. package/src/tools/builtins/computer-use.ts +9 -1
  665. package/src/tools/builtins/content-fingerprint.ts +9 -12
  666. package/src/tools/builtins/edit.ts +190 -27
  667. package/src/tools/builtins/write-file.ts +55 -19
  668. package/src/tools/command-arguments.ts +54 -0
  669. package/src/tools/coordinator/index.ts +4 -1
  670. package/src/tools/defineTool.ts +11 -0
  671. package/src/tools/env-scrub.ts +7 -5
  672. package/src/tools/goal/index.ts +129 -0
  673. package/src/tools/memory/index.ts +26 -3
  674. package/src/tools/memory/search.ts +20 -3
  675. package/src/types/agent/base.ts +12 -3
  676. package/src/types/agent/factory.ts +2 -0
  677. package/src/types/agent/reactive.ts +2 -0
  678. package/src/types/agent/supervisor.ts +6 -0
  679. package/src/types/agent/task.ts +6 -2
  680. package/src/types/connector/core.ts +13 -8
  681. package/src/types/connector/definition.ts +54 -20
  682. package/src/types/connector/http.ts +7 -0
  683. package/src/types/connector/mcp.ts +27 -6
  684. package/src/types/connector/tenant.ts +21 -7
  685. package/src/types/connector/webhook.ts +7 -0
  686. package/src/types/goal/index.ts +50 -0
  687. package/src/types/ids/index.ts +2 -0
  688. package/src/types/message/index.ts +143 -9
  689. package/src/types/plugin/index.ts +7 -5
  690. package/src/types/provider/chat.ts +35 -4
  691. package/src/types/provider/interface.ts +22 -7
  692. package/src/types/provider/stream.ts +6 -0
  693. package/src/types/rag/embedding.ts +16 -2
  694. package/src/types/rag/ingestion.ts +2 -1
  695. package/src/types/rag/knowledge-base.ts +7 -3
  696. package/src/types/rag/retrieval.ts +2 -1
  697. package/src/types/rag/scope.ts +5 -0
  698. package/src/types/rag/vector.ts +5 -2
  699. package/src/types/run/config.ts +20 -0
  700. package/src/types/run/events.ts +28 -3
  701. package/src/types/run/metadata.ts +2 -0
  702. package/src/types/run/step.ts +2 -7
  703. package/src/types/run/store.ts +60 -2
  704. package/src/types/sandbox/index.ts +57 -14
  705. package/src/types/session/store.ts +18 -0
  706. package/src/types/tool/index.ts +33 -11
  707. package/src/types/topic/entity.ts +3 -4
  708. package/src/types/topic/store.ts +3 -3
  709. package/src/utils/id.ts +6 -0
  710. package/src/utils/process-environment.ts +101 -0
  711. package/src/vault/InMemoryCredentialVault.ts +29 -4
  712. package/src/vault/instrumentation.ts +24 -0
@@ -1,5 +1,6 @@
1
1
  import { EMPTY_TOKEN_USAGE } from '../constants/limits.js'
2
2
  import { collectChatCompletion } from '../provider/collect-chat-completion.js'
3
+ import { resolveStreamIdleTimeoutMs, withStreamIdleTimeout } from '../provider/idle-timeout.js'
3
4
  import { FallbackResolver } from '../runtime/decision/fallback.js'
4
5
  import { DecisionParser } from '../runtime/decision/parser.js'
5
6
  import type {
@@ -61,13 +62,19 @@ export class RouterAgent extends AbstractAgent<RouterAgentConfig, RouterAgentRes
61
62
  config: RouterAgentConfig,
62
63
  listener?: RunEventListener,
63
64
  ): Promise<RouterAgentResult> {
65
+ // Resolve before a run id/event exists, matching query(): malformed
66
+ // liveness policy is a caller config error, not a failed model run.
67
+ const streamIdleTimeoutMs = resolveStreamIdleTimeoutMs(config.streamIdleTimeoutMs)
68
+ const signal = input.signal
69
+ ? AbortSignal.any([input.signal, this.abortController.signal])
70
+ : this.abortController.signal
64
71
  const startTime = Date.now()
65
72
  const runId = this.createRunId()
66
73
  this.bindRun(runId, config.logger)
67
74
 
68
75
  await this.emitEvent({ type: 'run_started', runId }, listener)
69
76
 
70
- const decision = await this.route(input, config)
77
+ const decision = await this.route(input, config, streamIdleTimeoutMs, signal)
71
78
 
72
79
  let targetRoute = config.routes.find((r) => r.agentId === decision.agentId)
73
80
 
@@ -149,7 +156,12 @@ export class RouterAgent extends AbstractAgent<RouterAgentConfig, RouterAgentRes
149
156
  }
150
157
  }
151
158
 
152
- private async route(input: AgentInput, config: RouterAgentConfig): Promise<RoutingDecision> {
159
+ private async route(
160
+ input: AgentInput,
161
+ config: RouterAgentConfig,
162
+ streamIdleTimeoutMs: number,
163
+ signal: AbortSignal,
164
+ ): Promise<RoutingDecision> {
153
165
  // `this.log`, not a fresh `getRootLogger()` child — bound by `bindRun` in
154
166
  // `runExclusive` before this is called, so a routing warning below
155
167
  // carries the SAME `namzu.run.id` as the run it is routing. The old
@@ -209,15 +221,20 @@ export class RouterAgent extends AbstractAgent<RouterAgentConfig, RouterAgentRes
209
221
  // Every routing attempt is a billed model call; a fallback after
210
222
  // three failed parses still cost three calls.
211
223
  let routingUsage: TokenUsage = { ...EMPTY_TOKEN_USAGE }
224
+ const routingProvider = withStreamIdleTimeout(config.provider, {
225
+ idleTimeoutMs: streamIdleTimeoutMs,
226
+ log,
227
+ })
212
228
 
213
229
  for (let attempt = 0; attempt < maxRetries; attempt++) {
214
230
  try {
215
231
  const response = await collectChatCompletion(
216
- config.provider.chatStream({
232
+ routingProvider.chatStream({
217
233
  model: config.model,
218
234
  messages: [createSystemMessage(prompt), createUserMessage(userContent)],
219
235
  temperature: 0,
220
236
  maxTokens: 200,
237
+ signal,
221
238
  }),
222
239
  )
223
240
 
@@ -265,6 +282,11 @@ export class RouterAgent extends AbstractAgent<RouterAgentConfig, RouterAgentRes
265
282
  }
266
283
  }
267
284
  } catch (err) {
285
+ // Provider-idle expiry aborts only the wrapper's private transport
286
+ // and is eligible for the router's declared fallback. A caller or
287
+ // agent cancellation owns this fused signal and must not be
288
+ // reinterpreted as permission to start a delegate.
289
+ if (signal.aborted) throw signal.reason
268
290
  log.warn('Routing LLM call failed', {
269
291
  'namzu.router.attempt': attempt + 1,
270
292
  'exception.message': String(err),
@@ -4,7 +4,7 @@ import { drainQuery } from '../runtime/query/index.js'
4
4
  import { PendingAnswers, QuestionParkBinding } from '../runtime/query/question-park.js'
5
5
  import { CompletionInbox } from '../scheduler/completion-inbox.js'
6
6
  import { LocalTaskScheduler } from '../scheduler/local.js'
7
- import { buildCoordinatorTools } from '../tools/coordinator/index.js'
7
+ import { ASK_USER_QUESTION_TOOL_NAME, buildCoordinatorTools } from '../tools/coordinator/index.js'
8
8
  import type {
9
9
  AgentInput,
10
10
  AgentMetadata,
@@ -151,17 +151,19 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
151
151
  parentRunId: runId,
152
152
  parentAgentId: this.metadata.id,
153
153
  parentAbortController: this.abortController,
154
- depth: 0,
154
+ // This context describes the CURRENT supervisor. AgentManager owns
155
+ // the increment when it constructs the child. Resetting a delegated
156
+ // supervisor to zero here made every grandchild depth one again.
157
+ depth: config.depth ?? 0,
155
158
  budgetTracker: {
156
159
  total: config.tokenBudget,
157
160
  remaining: config.tokenBudget,
158
161
  },
159
162
  factoryOptions: mergedFactoryOptions,
160
- // The supervisor already hands this to its OWN run and its own
161
- // coordinator tools; handing it to the spawn context is what
162
- // makes a worker ask the same person the supervisor asks.
163
- // Without it the two disagreed: the supervisor paused for a
164
- // human and the workers it launched approved themselves.
163
+ // The supervisor already hands this to its OWN run. Handing it to
164
+ // the spawn context makes a worker's REVIEW-tier calls reach the
165
+ // same person. It does not grant the root-only question tool.
166
+ // Without the handler, workers silently auto-approved themselves.
165
167
  ...(config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
166
168
  tenantId,
167
169
  topicId,
@@ -210,6 +212,7 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
210
212
  // runs again — which is how a leak of one listener per run becomes a leak
211
213
  // of one per ATTEMPT.
212
214
  try {
215
+ const isRootAgent = (config.depth ?? 0) === 0
213
216
  const coordinatorToolDefs = buildCoordinatorTools({
214
217
  gateway,
215
218
  completionInbox,
@@ -224,10 +227,11 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
224
227
  taskStore: input.taskStore,
225
228
  runId,
226
229
  getPlanManager: () => planManagerRef,
227
- // With a resume handler present the coordinator surface gains
228
- // ask_user_question the model can park the run on a question
229
- // routed through the same HITL channel as plan approvals.
230
- ...(config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
230
+ // A human-question tool belongs only to the root agent. The handler
231
+ // itself still reaches `drainQuery` below: delegated REVIEW-tier
232
+ // tool calls must keep asking the operator instead of falling back
233
+ // to unattended auto-approval.
234
+ ...(isRootAgent && config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
231
235
  questionParks,
232
236
  pendingAnswers,
233
237
  ...(config.onPlanApproved ? { onPlanApproved: config.onPlanApproved } : {}),
@@ -236,6 +240,10 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
236
240
  const tools = new ToolRegistry()
237
241
  if (config.tools) {
238
242
  for (const tool of config.tools.getAll()) {
243
+ // The boundary is semantic, not an implementation detail of the
244
+ // built-in builder. A host registry containing the same capability
245
+ // must not reopen it for a delegated agent.
246
+ if (!isRootAgent && tool.name === ASK_USER_QUESTION_TOOL_NAME) continue
239
247
  tools.register(tool, config.tools.getAvailability(tool.name))
240
248
  }
241
249
  }
@@ -307,6 +315,14 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
307
315
  model: config.model,
308
316
  tokenBudget: config.tokenBudget,
309
317
  timeoutMs: config.timeoutMs,
318
+ ...(config.streamIdleTimeoutMs !== undefined
319
+ ? { streamIdleTimeoutMs: config.streamIdleTimeoutMs }
320
+ : {}),
321
+ ...(config.maxRequestRichContentBytes !== undefined
322
+ ? {
323
+ maxRequestRichContentBytes: config.maxRequestRichContentBytes,
324
+ }
325
+ : {}),
310
326
  maxIterations: config.maxIterations,
311
327
  temperature: config.temperature,
312
328
  env: config.env,
@@ -359,6 +375,9 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
359
375
  // corrected for twice.
360
376
  ...(config.steering ? { steering: config.steering } : {}),
361
377
  ...(config.inboundMessages ? { inboundMessages: config.inboundMessages } : {}),
378
+ ...(config.projectInstructionContext
379
+ ? { projectInstructionContext: config.projectInstructionContext }
380
+ : {}),
362
381
  ...(config.authorizationGate ? { authorizationGate: config.authorizationGate } : {}),
363
382
  // The one hop between the config and the tool. `drainQuery`
364
383
  // registers `structured_output` from this and the loop
@@ -366,6 +385,9 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
366
385
  // came from — only `ReactiveAgent` was passing it.
367
386
  ...(config.structuredOutput ? { structuredOutput: config.structuredOutput } : {}),
368
387
  ...(config.sandboxProvider ? { sandboxProvider: config.sandboxProvider } : {}),
388
+ ...(config.sandboxTeardownTimeoutMs !== undefined
389
+ ? { sandboxTeardownTimeoutMs: config.sandboxTeardownTimeoutMs }
390
+ : {}),
369
391
  // Working-memory / compaction seam (optional; absent => unchanged
370
392
  // run path, byte-identical for every existing consumer).
371
393
  ...(config.compactionConfig ? { compactionConfig: config.compactionConfig } : {}),
@@ -1,10 +1,12 @@
1
1
  import { ToolRegistry } from '../registry/tool/execute.js'
2
2
  import { drainQuery } from '../runtime/query/index.js'
3
+ import type { ProjectInstructionContext } from '../runtime/query/project-instructions.js'
3
4
  import type { AuthorizationGateConfig } from '../types/authorization/index.js'
4
5
  import type { ProjectId, SessionId, TenantId, TopicId } from '../types/ids/index.js'
5
6
  import type { Message } from '../types/message/index.js'
6
7
  import type { LLMProvider, ReasoningEffort, ThinkingConfig } from '../types/provider/index.js'
7
8
  import type { Run, RunEventListener } from '../types/run/index.js'
9
+ import type { SandboxProvider } from '../types/sandbox/index.js'
8
10
  import type { Skill } from '../types/skills/index.js'
9
11
  import type { StructuredOutputConfig } from '../types/structured-output/index.js'
10
12
  import type { ToolRegistryContract } from '../types/tool/index.js'
@@ -62,6 +64,10 @@ export interface RunAgentOptions extends AgentIdentity {
62
64
  model: string
63
65
 
64
66
  tools?: ToolRegistryContract
67
+ /** Execute sandbox-aware tools inside this provider's boundary. */
68
+ sandboxProvider?: SandboxProvider
69
+ /** Sandbox teardown wait; defaults to 30 seconds and `0` is unbounded. */
70
+ sandboxTeardownTimeoutMs?: number
65
71
 
66
72
  /**
67
73
  * Skills to put in front of the model.
@@ -97,6 +103,10 @@ export interface RunAgentOptions extends AgentIdentity {
97
103
  maxIterations?: number
98
104
  tokenBudget?: number
99
105
  timeoutMs?: number
106
+ /** Maximum provider-stream silence; defaults to five minutes. `0` disables. */
107
+ streamIdleTimeoutMs?: number
108
+ /** Accumulated inline image/document bytes per provider request. `0` disables. */
109
+ maxRequestRichContentBytes?: number
100
110
  temperature?: number
101
111
 
102
112
  /**
@@ -134,6 +144,8 @@ export interface RunAgentOptions extends AgentIdentity {
134
144
 
135
145
  signal?: AbortSignal
136
146
  listener?: RunEventListener
147
+ /** Live project policy for hosts that discover nested instruction scopes. */
148
+ projectInstructionContext?: ProjectInstructionContext
137
149
  }
138
150
 
139
151
  export interface RunAgentResult {
@@ -225,13 +237,23 @@ export async function runAgent(options: RunAgentOptions): Promise<RunAgentResult
225
237
 
226
238
  const messages: Message[] =
227
239
  typeof options.prompt === 'string'
228
- ? [{ role: 'user', content: options.prompt, timestamp: Date.now() } as Message]
240
+ ? [
241
+ {
242
+ role: 'user',
243
+ content: options.prompt,
244
+ timestamp: Date.now(),
245
+ } as Message,
246
+ ]
229
247
  : options.prompt
230
248
 
231
249
  const run = await drainQuery(
232
250
  {
233
251
  provider: options.provider,
234
252
  tools: options.tools ?? new ToolRegistry(),
253
+ ...(options.sandboxProvider ? { sandboxProvider: options.sandboxProvider } : {}),
254
+ ...(options.sandboxTeardownTimeoutMs !== undefined
255
+ ? { sandboxTeardownTimeoutMs: options.sandboxTeardownTimeoutMs }
256
+ : {}),
235
257
  messages,
236
258
  workingDirectory: options.workingDirectory ?? process.cwd(),
237
259
  runConfig: {
@@ -239,6 +261,12 @@ export async function runAgent(options: RunAgentOptions): Promise<RunAgentResult
239
261
  maxIterations: options.maxIterations ?? DEFAULT_MAX_ITERATIONS,
240
262
  tokenBudget: options.tokenBudget ?? DEFAULT_TOKEN_BUDGET,
241
263
  timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
264
+ ...(options.streamIdleTimeoutMs !== undefined
265
+ ? { streamIdleTimeoutMs: options.streamIdleTimeoutMs }
266
+ : {}),
267
+ ...(options.maxRequestRichContentBytes !== undefined
268
+ ? { maxRequestRichContentBytes: options.maxRequestRichContentBytes }
269
+ : {}),
242
270
  ...(options.temperature !== undefined ? { temperature: options.temperature } : {}),
243
271
  ...(options.thinking ? { thinking: options.thinking } : {}),
244
272
  ...(options.effort ? { effort: options.effort } : {}),
@@ -256,10 +284,18 @@ export async function runAgent(options: RunAgentOptions): Promise<RunAgentResult
256
284
  ...(options.verificationGate ? { verificationGate: options.verificationGate } : {}),
257
285
  ...(options.authorizationGate ? { authorizationGate: options.authorizationGate } : {}),
258
286
  ...(options.structuredOutput ? { structuredOutput: options.structuredOutput } : {}),
287
+ ...(options.projectInstructionContext
288
+ ? { projectInstructionContext: options.projectInstructionContext }
289
+ : {}),
259
290
  ...identity,
260
291
  },
261
292
  options.listener,
262
293
  )
263
294
 
264
- return { output: run.result, structuredOutput: run.structuredOutput, run, identity }
295
+ return {
296
+ output: run.result,
297
+ structuredOutput: run.structuredOutput,
298
+ run,
299
+ identity,
300
+ }
265
301
  }
@@ -0,0 +1,390 @@
1
+ /**
2
+ * Break a command line into the commands it actually runs.
3
+ *
4
+ * ## The hole this closes
5
+ *
6
+ * A pattern rule tests a regular expression against an argument's value. When
7
+ * that value is a command line, the value and the command are not the same
8
+ * thing: `git push origin main` is one command, and
9
+ * `true; git push origin main` is two, of which the second is the one the rule
10
+ * was written about. An anchored pattern sees only the first.
11
+ *
12
+ * Measured against the gate, with the rule from this repository's own
13
+ * documentation (`^git push`, deny):
14
+ *
15
+ * git push origin main -> deny
16
+ * echo hi && git push origin main -> did not match
17
+ * true; git push origin main -> did not match
18
+ * bash -c "git push origin main" -> did not match
19
+ *
20
+ * A rule that fails to match reaches the permission mode, and a run with no
21
+ * terminal resolves that to `auto`. So an operator's prohibition was bypassed
22
+ * by typing four characters in front of it, in exactly the unattended case the
23
+ * prohibition exists for. The `bash` tool's own description tells the model to
24
+ * "use `&&` / `;` chaining for compound commands", so the evading form is not
25
+ * an exotic input — it is the documented one.
26
+ *
27
+ * ## Why splitting alone would make things worse
28
+ *
29
+ * Applied naively this widens `allow` in the same motion it fixes `deny`. An
30
+ * allow rule matching `^git status` would go on matching the first segment of
31
+ * `git status && rm -rf ~` and hand back `allow` for the whole line. So the
32
+ * caller must read the two decisions differently, and {@link evaluateRule}
33
+ * does:
34
+ *
35
+ * - **deny** matches when ANY segment matches. One prohibited command poisons
36
+ * the line it rides on.
37
+ * - **allow** matches only when EVERY segment matches, and never when the line
38
+ * is {@link CommandLineDecomposition.opaque}. Permission is a claim about the
39
+ * whole line, and a claim that cannot be checked is not granted.
40
+ *
41
+ * That asymmetry is the same one `refuse-do-not-degrade` describes: when the
42
+ * analysis is uncertain, the uncertainty spends against the permissive answer.
43
+ *
44
+ * ## What `opaque` means
45
+ *
46
+ * Some lines contain text that is not the command that runs. Command
47
+ * substitution (`$(…)`, backticks, `<(…)`) executes something whose text is
48
+ * not in the line at all, and `eval` runs a string assembled at runtime. No
49
+ * decomposition of the source can be a decomposition of what ran, so the line
50
+ * is marked opaque and `allow` declines it. `deny` still tests what is visible,
51
+ * because a deny that matches too much costs a prompt and a deny that matches
52
+ * too little costs the thing it was written to prevent.
53
+ *
54
+ * ## What it deliberately does not do
55
+ *
56
+ * A value with no chain operator, no nested shell and nothing opaque comes back
57
+ * as itself, byte for byte. That keeps every rule about a non-command argument
58
+ * — a path, a number, a URL — behaving exactly as it did, and confines this
59
+ * machinery to the case that motivated it.
60
+ *
61
+ * It is a decomposition, not a shell. `xargs sh -c`, a command read from a
62
+ * file, and a shell invoked through an interpreter it does not recognise all
63
+ * pass through as ordinary text. Each of those either denies as before or, for
64
+ * an allow rule, fails to match every segment and so declines. The failure mode
65
+ * is a prompt, never a silent grant.
66
+ */
67
+
68
+ /** The commands a line runs, and whether that list can be trusted as complete. */
69
+ export interface CommandLineDecomposition {
70
+ /**
71
+ * The individual commands, in source order. Never empty: a line that
72
+ * decomposes to nothing yields the original.
73
+ */
74
+ readonly segments: readonly string[]
75
+ /**
76
+ * True when the line runs something this decomposition cannot see, so
77
+ * `segments` is a lower bound rather than the whole story.
78
+ */
79
+ readonly opaque: boolean
80
+ }
81
+
82
+ /**
83
+ * Shells whose `-c` argument is another command line.
84
+ *
85
+ * Matched on the basename, so `/bin/bash` and `bash` are the same entry. An
86
+ * interpreter absent from this list is not a hole that grants anything: its
87
+ * payload stays inside one segment, where an allow rule fails to match it.
88
+ */
89
+ const NESTED_SHELLS = new Set(['sh', 'bash', 'zsh', 'dash', 'ksh', 'ash', 'busybox'])
90
+
91
+ /** Commands whose argument is code assembled at runtime. */
92
+ const RUNTIME_EVALUATORS = new Set(['eval', 'source', '.'])
93
+
94
+ /**
95
+ * Depth and width limits.
96
+ *
97
+ * A line that exceeds either is reported opaque rather than truncated: a
98
+ * shortened list of segments would read as complete to `allow`, which is the
99
+ * one reading that must never be wrong.
100
+ */
101
+ const MAX_DEPTH = 4
102
+ const MAX_SEGMENTS = 64
103
+
104
+ export function decomposeCommandLine(command: string): CommandLineDecomposition {
105
+ const state: WalkState = { opaque: false, structured: false }
106
+ const segments = split(command, state, 0)
107
+
108
+ // The untouched-value case, kept exact. Nothing was cut and nothing was
109
+ // unpacked, so there is no decomposition to report and the value goes back
110
+ // as it arrived — which is what keeps a rule about a path or a URL seeing
111
+ // the string it always saw, punctuation and surrounding space included.
112
+ if (!state.structured) return { segments: [command], opaque: state.opaque }
113
+
114
+ if (segments.length === 0) return { segments: [command], opaque: state.opaque }
115
+ if (segments.length > MAX_SEGMENTS) {
116
+ return { segments: segments.slice(0, MAX_SEGMENTS), opaque: true }
117
+ }
118
+ return { segments, opaque: state.opaque }
119
+ }
120
+
121
+ interface WalkState {
122
+ opaque: boolean
123
+ /**
124
+ * Whether anything was cut or unpacked. False means the value is not a
125
+ * command line as far as this module can tell, and it goes back untouched.
126
+ */
127
+ structured: boolean
128
+ }
129
+
130
+ /**
131
+ * Walk the line once, quote-aware, cutting at every top-level separator.
132
+ *
133
+ * Quote tracking is the whole reason this is not a `String.split`: `echo "a &&
134
+ * b"` is one command that prints a literal, and a splitter that cannot tell
135
+ * would report a second command named `b"` — inventing a segment is as wrong as
136
+ * missing one, because `allow` requires every segment to match.
137
+ */
138
+ function split(command: string, state: WalkState, depth: number): string[] {
139
+ const segments: string[] = []
140
+ let current = ''
141
+ let quote: "'" | '"' | null = null
142
+
143
+ const cut = (): void => {
144
+ const trimmed = trimSegment(current)
145
+ current = ''
146
+ if (trimmed === '') return
147
+ for (const piece of expand(trimmed, state, depth)) segments.push(piece)
148
+ }
149
+
150
+ for (let i = 0; i < command.length; i += 1) {
151
+ const char = command[i] as string
152
+
153
+ if (quote === "'") {
154
+ // Single quotes suspend everything, including the backslash. This is
155
+ // the branch that keeps `echo 'a && b'` one command.
156
+ if (char === "'") quote = null
157
+ current += char
158
+ continue
159
+ }
160
+
161
+ if (char === '\\') {
162
+ // An escaped separator is a literal, so both characters go through
163
+ // untouched and the next loop never sees the separator as one.
164
+ current += char + (command[i + 1] ?? '')
165
+ i += 1
166
+ continue
167
+ }
168
+
169
+ if (quote === '"') {
170
+ if (char === '"') quote = null
171
+ // Substitution is live inside double quotes, which is exactly where
172
+ // it hides best.
173
+ else if (isSubstitutionStart(command, i)) state.opaque = true
174
+ current += char
175
+ continue
176
+ }
177
+
178
+ if (char === "'" || char === '"') {
179
+ quote = char
180
+ current += char
181
+ continue
182
+ }
183
+
184
+ if (isSubstitutionStart(command, i)) {
185
+ state.opaque = true
186
+ current += char
187
+ continue
188
+ }
189
+
190
+ const separator = separatorAt(command, i)
191
+ if (separator > 0) {
192
+ state.structured = true
193
+ cut()
194
+ i += separator - 1
195
+ continue
196
+ }
197
+
198
+ current += char
199
+ }
200
+
201
+ // An unterminated quote means the line does not parse. Whatever it runs is
202
+ // not what this walk saw, so the caller must not treat the result as a
203
+ // complete account.
204
+ if (quote !== null) state.opaque = true
205
+
206
+ cut()
207
+ return segments
208
+ }
209
+
210
+ /**
211
+ * Length of the separator starting at `index`, or 0.
212
+ *
213
+ * The redirection cases are why this is a function. `2>&1` and `&>log` contain
214
+ * `&` and are not separators; splitting there would manufacture a segment named
215
+ * `1`, which no allow rule matches, and a command that redirects its output
216
+ * would stop being approvable for a reason nobody could see.
217
+ */
218
+ function separatorAt(command: string, index: number): number {
219
+ const char = command[index]
220
+ const next = command[index + 1]
221
+
222
+ if (char === '\n') return 1
223
+ if (char === ';') return next === ';' ? 2 : 1
224
+ if (char === '&') {
225
+ if (next === '&') return 2
226
+ if (next === '>') return 0
227
+ if (command[index - 1] === '>') return 0
228
+ return 1
229
+ }
230
+ if (char === '|') {
231
+ if (next === '|') return 2
232
+ // `|&` pipes stderr as well; still a pipe, and both sides still run.
233
+ if (next === '&') return 2
234
+ return 1
235
+ }
236
+ return 0
237
+ }
238
+
239
+ /** Whether a command substitution opens here. */
240
+ function isSubstitutionStart(command: string, index: number): boolean {
241
+ const char = command[index]
242
+ if (char === '`') return true
243
+ if (char === '$' && command[index + 1] === '(') return true
244
+ // Process substitution: `diff <(a) <(b)` runs `a` and `b`.
245
+ if ((char === '<' || char === '>') && command[index + 1] === '(') return true
246
+ return false
247
+ }
248
+
249
+ /**
250
+ * Strip the grouping punctuation a split leaves behind.
251
+ *
252
+ * `(cd build && make)` cuts into `(cd build` and `make)`. Leaving the bracket on
253
+ * would stop an allow rule matching a command it names, and — worse — stop a
254
+ * deny rule matching one, since `^make` does not match `make)`.
255
+ */
256
+ function trimSegment(segment: string): string {
257
+ return segment
258
+ .trim()
259
+ .replace(/^[({\s]+/, '')
260
+ .replace(/[)}\s]+$/, '')
261
+ }
262
+
263
+ /**
264
+ * Turn one segment into the commands it stands for.
265
+ *
266
+ * A shell invoked with `-c` carries a whole second command line in an argument,
267
+ * and that argument is where the smuggling this module exists for is easiest:
268
+ * `bash -c "git push"` contains no separator at all, so nothing above this
269
+ * function would have looked inside it.
270
+ *
271
+ * The outer segment is kept alongside the inner ones. A rule that denies the
272
+ * interpreter itself must still fire, and for `allow` the extra segment only
273
+ * makes the requirement stricter — which is the safe direction.
274
+ */
275
+ function expand(segment: string, state: WalkState, depth: number): string[] {
276
+ const words = tokenize(segment)
277
+ const head = words[0]
278
+ if (head === undefined) return [segment]
279
+
280
+ if (RUNTIME_EVALUATORS.has(basename(head.text))) {
281
+ // The argument is source text assembled elsewhere. Even when it is a
282
+ // visible literal, what runs is decided at runtime.
283
+ state.opaque = true
284
+ return [segment]
285
+ }
286
+
287
+ if (!NESTED_SHELLS.has(basename(head.text))) return [segment]
288
+
289
+ const flag = words.findIndex(
290
+ (word, index) => index > 0 && word.quoted === null && word.text === '-c',
291
+ )
292
+ if (flag < 0) return [segment]
293
+
294
+ const payload = words[flag + 1]
295
+ if (payload === undefined) {
296
+ // `bash -c` with nothing after it is either a syntax error or an
297
+ // argument this tokenizer failed to read. Neither may be reported as
298
+ // "there is no nested command".
299
+ state.opaque = true
300
+ return [segment]
301
+ }
302
+
303
+ if (depth + 1 >= MAX_DEPTH) {
304
+ state.opaque = true
305
+ return [segment]
306
+ }
307
+
308
+ const nested = split(payload.text, state, depth + 1)
309
+ if (nested.length === 0) return [segment]
310
+ state.structured = true
311
+ return [segment, ...nested]
312
+ }
313
+
314
+ interface Word {
315
+ readonly text: string
316
+ /** The quote that wrapped it, or null when it was bare. */
317
+ readonly quoted: "'" | '"' | null
318
+ }
319
+
320
+ /**
321
+ * Split a segment into words, removing one layer of quoting.
322
+ *
323
+ * The quote is reported rather than discarded because `-c` must be the flag and
324
+ * not a literal: `echo "-c"` names no nested shell, and treating its next word
325
+ * as a command line would decompose a string that never runs.
326
+ */
327
+ function tokenize(segment: string): Word[] {
328
+ const words: Word[] = []
329
+ let current = ''
330
+ let quote: "'" | '"' | null = null
331
+ let sawQuote: "'" | '"' | null = null
332
+ let open = false
333
+
334
+ const push = (): void => {
335
+ if (open) words.push({ text: current, quoted: sawQuote })
336
+ current = ''
337
+ sawQuote = null
338
+ open = false
339
+ }
340
+
341
+ for (let i = 0; i < segment.length; i += 1) {
342
+ const char = segment[i] as string
343
+
344
+ if (quote === "'") {
345
+ // Single quotes suspend the backslash too, so this branch precedes
346
+ // the escape below rather than sharing it.
347
+ if (char === "'") quote = null
348
+ else current += char
349
+ open = true
350
+ continue
351
+ }
352
+
353
+ if (char === '\\' && i + 1 < segment.length) {
354
+ current += segment[i + 1]
355
+ i += 1
356
+ open = true
357
+ continue
358
+ }
359
+
360
+ if (quote === '"') {
361
+ if (char === '"') quote = null
362
+ else current += char
363
+ open = true
364
+ continue
365
+ }
366
+
367
+ if (char === "'" || char === '"') {
368
+ quote = char
369
+ sawQuote = char
370
+ open = true
371
+ continue
372
+ }
373
+
374
+ if (char === ' ' || char === '\t') {
375
+ push()
376
+ continue
377
+ }
378
+
379
+ current += char
380
+ open = true
381
+ }
382
+
383
+ push()
384
+ return words
385
+ }
386
+
387
+ function basename(word: string): string {
388
+ const cut = word.lastIndexOf('/')
389
+ return cut < 0 ? word : word.slice(cut + 1)
390
+ }