@1agents/acp-service 0.8.3 → 0.9.1

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 (302) hide show
  1. package/README.md +25 -13
  2. package/dist/bin/a2a.js +16 -4
  3. package/dist/bin/acp-service.js +30 -0
  4. package/dist/bin/process.d.ts +4 -0
  5. package/dist/bin/process.js +57 -0
  6. package/dist/bin/roles.d.ts +1 -0
  7. package/dist/bin/roles.js +24 -0
  8. package/dist/bin/rsi.d.ts +3 -0
  9. package/dist/bin/rsi.js +114 -0
  10. package/dist/bin/ticket.d.ts +13 -0
  11. package/dist/bin/ticket.js +97 -0
  12. package/dist/bin/trail.d.ts +4 -0
  13. package/dist/bin/trail.js +62 -0
  14. package/dist/src/a2a/artifact-content.d.ts +9 -0
  15. package/dist/src/a2a/artifact-content.js +45 -0
  16. package/dist/src/a2a/desktop-notify.d.ts +1 -0
  17. package/dist/src/a2a/desktop-notify.js +12 -0
  18. package/dist/src/a2a/execution-binding.d.ts +9 -0
  19. package/dist/src/a2a/execution-binding.js +19 -0
  20. package/dist/src/a2a/executor.d.ts +22 -1
  21. package/dist/src/a2a/executor.js +308 -22
  22. package/dist/src/a2a/gateway.d.ts +613 -1
  23. package/dist/src/a2a/gateway.js +1337 -88
  24. package/dist/src/a2a/index.d.ts +14 -1
  25. package/dist/src/a2a/index.js +8 -0
  26. package/dist/src/a2a/job-directory.d.ts +6 -0
  27. package/dist/src/a2a/job-directory.js +19 -0
  28. package/dist/src/a2a/preflight.js +16 -1
  29. package/dist/src/a2a/resubmit.d.ts +46 -0
  30. package/dist/src/a2a/resubmit.js +82 -0
  31. package/dist/src/a2a/result-metadata.d.ts +6 -0
  32. package/dist/src/a2a/result-metadata.js +25 -6
  33. package/dist/src/a2a/server.d.ts +10 -0
  34. package/dist/src/a2a/server.js +127 -2
  35. package/dist/src/a2a/session-lifecycle.d.ts +40 -0
  36. package/dist/src/a2a/session-lifecycle.js +54 -0
  37. package/dist/src/a2a/store.d.ts +4 -0
  38. package/dist/src/a2a/store.js +76 -1
  39. package/dist/src/a2a/types.d.ts +77 -1
  40. package/dist/src/a2a/types.js +11 -1
  41. package/dist/src/a2a/workbench-ui.d.ts +28 -0
  42. package/dist/src/a2a/workbench-ui.js +182 -0
  43. package/dist/src/acp-connection.js +119 -14
  44. package/dist/src/bridge.d.ts +1 -0
  45. package/dist/src/bridge.js +312 -37
  46. package/dist/src/capacity-lifecycle.d.ts +5 -0
  47. package/dist/src/capacity-lifecycle.js +57 -0
  48. package/dist/src/capacity-queue.d.ts +58 -0
  49. package/dist/src/capacity-queue.js +388 -0
  50. package/dist/src/capacity.d.ts +101 -0
  51. package/dist/src/capacity.js +416 -0
  52. package/dist/src/dsh.js +1 -1
  53. package/dist/src/execution/agent-files.d.ts +25 -0
  54. package/dist/src/execution/agent-files.js +90 -0
  55. package/dist/src/execution/agent-registry.d.ts +164 -0
  56. package/dist/src/execution/agent-registry.js +275 -0
  57. package/dist/src/execution/human-review.d.ts +105 -0
  58. package/dist/src/execution/human-review.js +89 -0
  59. package/dist/src/execution/ledger.d.ts +57 -0
  60. package/dist/src/execution/ledger.js +122 -13
  61. package/dist/src/execution/ppt-delivery.d.ts +36 -3
  62. package/dist/src/execution/ppt-delivery.js +243 -53
  63. package/dist/src/execution/process-request.d.ts +151 -0
  64. package/dist/src/execution/process-request.js +177 -0
  65. package/dist/src/execution/project-discovery.d.ts +56 -0
  66. package/dist/src/execution/project-discovery.js +429 -0
  67. package/dist/src/execution/report-review.d.ts +60 -0
  68. package/dist/src/execution/report-review.js +173 -0
  69. package/dist/src/execution/targets.d.ts +20 -0
  70. package/dist/src/execution/targets.js +23 -3
  71. package/dist/src/execution/ticket-executor.d.ts +25 -0
  72. package/dist/src/execution/ticket-executor.js +27 -0
  73. package/dist/src/execution/ticket.d.ts +326 -0
  74. package/dist/src/execution/ticket.js +301 -0
  75. package/dist/src/execution/workbench-chat.d.ts +25 -0
  76. package/dist/src/execution/workbench-chat.js +54 -0
  77. package/dist/src/execution/workbench.d.ts +162 -0
  78. package/dist/src/execution/workbench.js +356 -0
  79. package/dist/src/index.d.ts +4 -0
  80. package/dist/src/index.js +3 -0
  81. package/dist/src/roles/index.d.ts +1 -0
  82. package/dist/src/roles/index.js +1 -0
  83. package/dist/src/roles/skills.d.ts +71 -0
  84. package/dist/src/roles/skills.js +427 -0
  85. package/dist/src/rsi/gate.d.ts +25 -0
  86. package/dist/src/rsi/gate.js +59 -0
  87. package/dist/src/rsi/outline-run.d.ts +107 -0
  88. package/dist/src/rsi/outline-run.js +443 -0
  89. package/dist/workbench-ui/app.css +453 -0
  90. package/dist/workbench-ui/app.js +13 -0
  91. package/dist/workbench-ui/chunk-23JHGYT3.js +1 -0
  92. package/dist/workbench-ui/chunk-3H6STGPV.js +1 -0
  93. package/dist/workbench-ui/chunk-3SNBBMGH.js +1 -0
  94. package/dist/workbench-ui/chunk-3XJZ6DIE.js +1 -0
  95. package/dist/workbench-ui/chunk-44KDLLKJ.js +1 -0
  96. package/dist/workbench-ui/chunk-46H7FU5Y.js +7 -0
  97. package/dist/workbench-ui/chunk-4N44QPL7.js +1 -0
  98. package/dist/workbench-ui/chunk-4YN4BS7I.js +1 -0
  99. package/dist/workbench-ui/chunk-53EG4IVQ.js +96 -0
  100. package/dist/workbench-ui/chunk-5FIPUNR4.js +1 -0
  101. package/dist/workbench-ui/chunk-6DWWYA6G.js +2 -0
  102. package/dist/workbench-ui/chunk-6FU3T633.js +99 -0
  103. package/dist/workbench-ui/chunk-6XKIHRA4.js +1 -0
  104. package/dist/workbench-ui/chunk-7GIX43Y5.js +1 -0
  105. package/dist/workbench-ui/chunk-7Q4WBGX6.js +4 -0
  106. package/dist/workbench-ui/chunk-A3BQM7HR.js +1 -0
  107. package/dist/workbench-ui/chunk-AFCFDDOP.js +24 -0
  108. package/dist/workbench-ui/chunk-AG67EUYD.js +89 -0
  109. package/dist/workbench-ui/chunk-AGJHMMTN.js +1 -0
  110. package/dist/workbench-ui/chunk-AO6JUBV6.js +41 -0
  111. package/dist/workbench-ui/chunk-AUSLTP43.js +72 -0
  112. package/dist/workbench-ui/chunk-AVZL46TT.js +1 -0
  113. package/dist/workbench-ui/chunk-AZRIGIV2.js +168 -0
  114. package/dist/workbench-ui/chunk-B2LIVH37.js +1 -0
  115. package/dist/workbench-ui/chunk-B7YX5TR5.js +1 -0
  116. package/dist/workbench-ui/chunk-BCB4X4XX.js +1 -0
  117. package/dist/workbench-ui/chunk-BCRQUL2A.js +88 -0
  118. package/dist/workbench-ui/chunk-BI6UHHQP.js +1 -0
  119. package/dist/workbench-ui/chunk-BLSLQ4AQ.js +120 -0
  120. package/dist/workbench-ui/chunk-C3QSRS6E.js +1 -0
  121. package/dist/workbench-ui/chunk-CK7M2PJ3.js +62 -0
  122. package/dist/workbench-ui/chunk-CM6LZ7TU.js +1 -0
  123. package/dist/workbench-ui/chunk-CP63H27F.js +36 -0
  124. package/dist/workbench-ui/chunk-CPUMMIS2.js +70 -0
  125. package/dist/workbench-ui/chunk-CSEIBI5U.js +2 -0
  126. package/dist/workbench-ui/chunk-CUS65DKZ.js +161 -0
  127. package/dist/workbench-ui/chunk-CVQY7TNC.js +1 -0
  128. package/dist/workbench-ui/chunk-D6S3XBIX.js +106 -0
  129. package/dist/workbench-ui/chunk-E253Y562.js +1 -0
  130. package/dist/workbench-ui/chunk-EADDJUDC.js +1 -0
  131. package/dist/workbench-ui/chunk-EBGJ3YXG.js +206 -0
  132. package/dist/workbench-ui/chunk-EKPVZ3WY.js +8 -0
  133. package/dist/workbench-ui/chunk-EQDCEAFY.js +1 -0
  134. package/dist/workbench-ui/chunk-ES3SSDJY.js +40 -0
  135. package/dist/workbench-ui/chunk-ESFD2H7N.js +231 -0
  136. package/dist/workbench-ui/chunk-FVOHPMS6.js +1 -0
  137. package/dist/workbench-ui/chunk-FXMQAGVT.js +1 -0
  138. package/dist/workbench-ui/chunk-GGTADRXD.js +24 -0
  139. package/dist/workbench-ui/chunk-GHIVPGNQ.js +1 -0
  140. package/dist/workbench-ui/chunk-GLU2YQV2.js +1 -0
  141. package/dist/workbench-ui/chunk-GOCKBYSM.js +1 -0
  142. package/dist/workbench-ui/chunk-H2KMMTJB.js +1 -0
  143. package/dist/workbench-ui/chunk-HGVLDNPP.js +39 -0
  144. package/dist/workbench-ui/chunk-HSAVC5GY.js +1 -0
  145. package/dist/workbench-ui/chunk-HSEAD2JH.js +1 -0
  146. package/dist/workbench-ui/chunk-HSIHOBTY.js +1 -0
  147. package/dist/workbench-ui/chunk-IZXOKUGG.js +67 -0
  148. package/dist/workbench-ui/chunk-JFT2LC2T.js +1 -0
  149. package/dist/workbench-ui/chunk-JHL3ZDYK.js +3 -0
  150. package/dist/workbench-ui/chunk-JMORLCZG.js +257 -0
  151. package/dist/workbench-ui/chunk-JR4SIX7A.js +1 -0
  152. package/dist/workbench-ui/chunk-K23HAGEH.js +30 -0
  153. package/dist/workbench-ui/chunk-K43JDCBH.js +1 -0
  154. package/dist/workbench-ui/chunk-KINKFJY7.js +1 -0
  155. package/dist/workbench-ui/chunk-KKQSA4LI.js +2 -0
  156. package/dist/workbench-ui/chunk-KOUZX3UX.js +1 -0
  157. package/dist/workbench-ui/chunk-KR4DRHW2.js +78 -0
  158. package/dist/workbench-ui/chunk-KT4DJNOR.js +1 -0
  159. package/dist/workbench-ui/chunk-KTPNKRRZ.js +292 -0
  160. package/dist/workbench-ui/chunk-LFHIPGSU.js +7 -0
  161. package/dist/workbench-ui/chunk-LWDL4HZB.js +125 -0
  162. package/dist/workbench-ui/chunk-MVYC3CY4.js +1 -0
  163. package/dist/workbench-ui/chunk-NWUPALCY.js +129 -0
  164. package/dist/workbench-ui/chunk-NY7C662Z.js +1 -0
  165. package/dist/workbench-ui/chunk-O76WTHWP.js +1 -0
  166. package/dist/workbench-ui/chunk-OTF7YHRE.js +162 -0
  167. package/dist/workbench-ui/chunk-P6TKKRKP.js +1 -0
  168. package/dist/workbench-ui/chunk-PFHOOWV3.js +1 -0
  169. package/dist/workbench-ui/chunk-PUQLANIM.js +1 -0
  170. package/dist/workbench-ui/chunk-PZCGBYVO.js +1 -0
  171. package/dist/workbench-ui/chunk-QOHUZGP4.js +1 -0
  172. package/dist/workbench-ui/chunk-QSEG3OFF.js +1 -0
  173. package/dist/workbench-ui/chunk-QYPOXZIA.js +84 -0
  174. package/dist/workbench-ui/chunk-R6SOF3JC.js +1 -0
  175. package/dist/workbench-ui/chunk-RCLOYU5F.js +1 -0
  176. package/dist/workbench-ui/chunk-RSRUP64S.js +1 -0
  177. package/dist/workbench-ui/chunk-RVAIT6JW.js +1 -0
  178. package/dist/workbench-ui/chunk-S2CCN3II.js +1 -0
  179. package/dist/workbench-ui/chunk-S2Q52W46.js +1 -0
  180. package/dist/workbench-ui/chunk-S2W5THJ5.js +1 -0
  181. package/dist/workbench-ui/chunk-S6ZQZNOX.js +1 -0
  182. package/dist/workbench-ui/chunk-S74PLMMS.js +1 -0
  183. package/dist/workbench-ui/chunk-S7C4HKEY.js +1 -0
  184. package/dist/workbench-ui/chunk-SDTB3Q65.js +1 -0
  185. package/dist/workbench-ui/chunk-SLPRGYUV.js +32 -0
  186. package/dist/workbench-ui/chunk-SQE76S5B.js +1 -0
  187. package/dist/workbench-ui/chunk-SSDZPVPW.js +1 -0
  188. package/dist/workbench-ui/chunk-SVI7DGIE.js +1 -0
  189. package/dist/workbench-ui/chunk-T6QKLZ4H.js +62 -0
  190. package/dist/workbench-ui/chunk-TJNRPTFL.js +1 -0
  191. package/dist/workbench-ui/chunk-TP6U4EDH.js +2 -0
  192. package/dist/workbench-ui/chunk-TYAAT3GQ.js +1 -0
  193. package/dist/workbench-ui/chunk-U6OCY4ZH.js +1 -0
  194. package/dist/workbench-ui/chunk-UAN3NLRF.js +1 -0
  195. package/dist/workbench-ui/chunk-UMLU3FIX.js +1 -0
  196. package/dist/workbench-ui/chunk-URIY2OTM.js +1 -0
  197. package/dist/workbench-ui/chunk-V2NUKAA7.js +38 -0
  198. package/dist/workbench-ui/chunk-V4QLL4TE.js +139 -0
  199. package/dist/workbench-ui/chunk-VASHXUK4.js +2 -0
  200. package/dist/workbench-ui/chunk-VJLIWNIU.js +1 -0
  201. package/dist/workbench-ui/chunk-VQNQFBID.js +1 -0
  202. package/dist/workbench-ui/chunk-VSIWU7XA.js +3 -0
  203. package/dist/workbench-ui/chunk-VSJASPUZ.js +321 -0
  204. package/dist/workbench-ui/chunk-VXPNUNUX.js +3 -0
  205. package/dist/workbench-ui/chunk-WBKLDCV6.js +1 -0
  206. package/dist/workbench-ui/chunk-WOKJM3FY.js +1 -0
  207. package/dist/workbench-ui/chunk-X3U3NA3X.js +34 -0
  208. package/dist/workbench-ui/chunk-XBYU7M4J.js +1 -0
  209. package/dist/workbench-ui/chunk-XBZAO4ID.js +10 -0
  210. package/dist/workbench-ui/chunk-XLLPZ2WO.js +1 -0
  211. package/dist/workbench-ui/chunk-YFVL4NJL.js +1 -0
  212. package/dist/workbench-ui/chunk-YRFQENM4.js +1 -0
  213. package/dist/workbench-ui/chunk-YUADQVB2.js +1 -0
  214. package/dist/workbench-ui/chunk-Z3TCAKM5.js +1 -0
  215. package/dist/workbench-ui/chunk-Z6QR6FRE.js +10 -0
  216. package/dist/workbench-ui/chunk-ZJPSORPP.js +3 -0
  217. package/dist/workbench-ui/chunk-ZLGCSTR2.js +15 -0
  218. package/dist/workbench-ui/chunk-ZLR4SG5X.js +1 -0
  219. package/dist/workbench-ui/chunk-ZND3TTGF.js +1 -0
  220. package/dist/workbench-ui/chunk-ZOP3ZYH7.js +2 -0
  221. package/dist/workbench-ui/index.html +14 -0
  222. package/package.json +23 -8
  223. package/skills/acp-service/SKILL.md +24 -8
  224. package/skills/acp-service/references/a2a.md +24 -8
  225. package/skills/acp-service/references/async-caller.md +48 -0
  226. package/skills/acp-service/references/dsh.md +2 -0
  227. package/skills/acp-service/references/roles-and-tasks.md +120 -0
  228. package/skills/acp-service/scripts/a2a-caller.py +242 -0
  229. package/skills/rsi-coach/SKILL.md +134 -0
  230. package/vendor/dsh/README.md +11 -5
  231. package/vendor/dsh/a2a-executor.d.ts +60 -3
  232. package/vendor/dsh/a2a-executor.js +208 -18
  233. package/vendor/dsh/a2a.d.ts +12 -2
  234. package/vendor/dsh/a2a.js +9 -2
  235. package/vendor/dsh/adapter.d.ts +61 -2
  236. package/vendor/dsh/adapter.js +354 -23
  237. package/vendor/dsh/client.js +67 -11
  238. package/vendor/dsh/index.js +57 -4
  239. package/vendor/dsh/native-approvals.d.ts +4 -0
  240. package/vendor/dsh/native-approvals.js +44 -0
  241. package/vendor/dsh/preset-route.d.ts +49 -0
  242. package/vendor/dsh/preset-route.js +51 -0
  243. package/vendor/dsh/preset.js +10 -3
  244. package/vendor/dsh/process-admission.d.ts +25 -0
  245. package/vendor/dsh/process-admission.js +87 -0
  246. package/vendor/dsh/process-requests.d.ts +57 -0
  247. package/vendor/dsh/process-requests.js +49 -0
  248. package/vendor/dsh/review-mcp.d.ts +1 -0
  249. package/vendor/dsh/review-mcp.js +56 -0
  250. package/vendor/dsh/review.d.ts +30 -0
  251. package/vendor/dsh/review.js +149 -0
  252. package/vendor/dsh/session-settings.d.ts +34 -0
  253. package/vendor/dsh/session-settings.js +114 -0
  254. package/vendor/dsh/ticket-spec.d.ts +30 -0
  255. package/vendor/dsh/ticket-spec.js +10 -0
  256. package/vendor/dsh/ticket-tools.d.ts +21 -0
  257. package/vendor/dsh/ticket-tools.js +43 -0
  258. package/vendor/dsh/workbench.d.ts +18 -0
  259. package/vendor/dsh/workbench.js +91 -0
  260. package/vendor/runtime/README.md +6 -4
  261. package/vendor/runtime/dist/{cli-DeOpE2Xz.js → cli-DXmYwv3U.js} +4 -4
  262. package/vendor/runtime/dist/{cli-DeOpE2Xz.js.map → cli-DXmYwv3U.js.map} +1 -1
  263. package/vendor/runtime/dist/cli.js +7 -7
  264. package/vendor/runtime/dist/client-VQsqcIOJ.d.ts.map +1 -1
  265. package/vendor/runtime/dist/docs-site/CLI.html +2 -2
  266. package/vendor/runtime/dist/docs-site/VISION.html +2 -2
  267. package/vendor/runtime/dist/docs-site/agents.html +2 -2
  268. package/vendor/runtime/dist/docs-site/compare.html +2 -2
  269. package/vendor/runtime/dist/docs-site/config.html +2 -2
  270. package/vendor/runtime/dist/docs-site/custom-agents.html +2 -2
  271. package/vendor/runtime/dist/docs-site/exit-codes.html +2 -2
  272. package/vendor/runtime/dist/docs-site/flows.html +2 -2
  273. package/vendor/runtime/dist/docs-site/index.html +1 -1
  274. package/vendor/runtime/dist/docs-site/install.html +2 -2
  275. package/vendor/runtime/dist/docs-site/llms.txt +1 -1
  276. package/vendor/runtime/dist/docs-site/output-formats.html +2 -2
  277. package/vendor/runtime/dist/docs-site/permissions.html +2 -2
  278. package/vendor/runtime/dist/docs-site/prompting.html +2 -2
  279. package/vendor/runtime/dist/docs-site/quickstart.html +2 -2
  280. package/vendor/runtime/dist/docs-site/releasing.html +2 -2
  281. package/vendor/runtime/dist/docs-site/runtime-environment.html +2 -2
  282. package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +3 -2
  283. package/vendor/runtime/dist/docs-site/safe-errors.html +2 -2
  284. package/vendor/runtime/dist/docs-site/session-control.html +2 -2
  285. package/vendor/runtime/dist/docs-site/session-watch.html +2 -2
  286. package/vendor/runtime/dist/docs-site/sessions.html +2 -2
  287. package/vendor/runtime/dist/docs-site/shared-sessions.html +2 -2
  288. package/vendor/runtime/dist/{flows-oaBGn31w.js → flows-DJ17ajbw.js} +3 -3
  289. package/vendor/runtime/dist/{flows-oaBGn31w.js.map → flows-DJ17ajbw.js.map} +1 -1
  290. package/vendor/runtime/dist/flows.js +1 -1
  291. package/vendor/runtime/dist/{invocation-options-CUDEE8vW.js → invocation-options-PBfCgrdi.js} +3 -3
  292. package/vendor/runtime/dist/{invocation-options-CUDEE8vW.js.map → invocation-options-PBfCgrdi.js.map} +1 -1
  293. package/vendor/runtime/dist/{output-CFv3jcOQ.js → output-B3MDn7kv.js} +2 -2
  294. package/vendor/runtime/dist/{output-CFv3jcOQ.js.map → output-B3MDn7kv.js.map} +1 -1
  295. package/vendor/runtime/dist/{queue-owner-runtime-DvMJiGbP.js → queue-owner-runtime-DXCVngwU.js} +15 -8
  296. package/vendor/runtime/dist/queue-owner-runtime-DXCVngwU.js.map +1 -0
  297. package/vendor/runtime/dist/runtime.js +1 -1
  298. package/vendor/runtime/dist/{session-watch-Di-wIdCH.js → session-watch-DURyCw31.js} +2 -2
  299. package/vendor/runtime/dist/{session-watch-Di-wIdCH.js.map → session-watch-DURyCw31.js.map} +1 -1
  300. package/vendor/runtime/package.json +6 -4
  301. package/vendor/runtime/skills/acpx/SKILL.md +2 -0
  302. package/vendor/runtime/dist/queue-owner-runtime-DvMJiGbP.js.map +0 -1
@@ -53,14 +53,14 @@ ${item.newText}` }];
53
53
  if (content.length || tool.rawOutput == null) return content;
54
54
  return [{ type: "text", text: typeof tool.rawOutput === "string" ? tool.rawOutput : JSON.stringify(tool.rawOutput, null, 2) }];
55
55
  }
56
- function rootOf(state, location) {
56
+ function rootOf(state, location2) {
57
57
  const { tool, requestId, turn, step } = state.data;
58
58
  const name = tool.name && tool.name !== "Tool" ? tool.name : names[tool.kind] ?? tool.title ?? tool.name ?? "Tool";
59
59
  const input = tool.rawInput ?? (tool.locations?.[0]?.path ? { path: tool.locations[0].path } : tool.title ? { description: tool.title } : {});
60
60
  const argsRaw = JSON.stringify(input);
61
61
  const head = { callId: `${requestId}:${tool.toolCallId}`, name, argsRaw, turn, step, time: state.time, subCalls: [] };
62
62
  const settled = tool.status === "completed" || tool.status === "failed";
63
- const closed = location?.kind === "step" && location.step.status === "closed" ? location.step.end : (location?.kind === "step" || location?.kind === "turn") && location.turn.status === "closed" ? location.turn.end : void 0;
63
+ const closed = location2?.kind === "step" && location2.step.status === "closed" ? location2.step.end : (location2?.kind === "step" || location2?.kind === "turn") && location2.turn.status === "closed" ? location2.turn.end : void 0;
64
64
  if (!settled && !closed) return { ...head, phase: "start" };
65
65
  return {
66
66
  kind: "tool-result",
@@ -137,10 +137,10 @@ var toolConversationDefinition = {
137
137
  buildViewNode: (context) => {
138
138
  const state = context.state;
139
139
  if (!state?.acp) return null;
140
- const location = context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" };
140
+ const location2 = context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" };
141
141
  const parts = [];
142
142
  for (const [index, block] of [...state.blocks].sort(([a], [b]) => a - b)) {
143
- if (block.kind === "tool") parts.push({ kind: "tool", root: rootOf(state.tools.get(block.id), location) });
143
+ if (block.kind === "tool") parts.push({ kind: "tool", root: rootOf(state.tools.get(block.id), location2) });
144
144
  else if (block.text.trim()) {
145
145
  const last = parts.at(-1);
146
146
  if (last?.kind === block.kind) last.text += block.text;
@@ -148,7 +148,7 @@ var toolConversationDefinition = {
148
148
  }
149
149
  }
150
150
  if (!parts.length) return null;
151
- const status = state.final ? "settled" : location.kind === "step" && location.step.status === "closed" ? "interrupted" : "running";
151
+ const status = state.final ? "settled" : location2.kind === "step" && location2.step.status === "closed" ? "interrupted" : "running";
152
152
  const turn = context.matches[0].event.data.turn, step = context.matches[0].event.data.step;
153
153
  const text = parts.filter((part) => part.kind === "text").map((part) => part.text).join("\n");
154
154
  const blocks = [{ kind: "text", text: text || parts.filter((part) => part.kind === "tool").map((part) => part.root.name ?? part.root.call.name).join(", ") || "ACP" }];
@@ -158,7 +158,7 @@ var toolConversationDefinition = {
158
158
  kind: "assistant-step",
159
159
  target: "chat",
160
160
  anchorSeq: state.seq,
161
- location,
161
+ location: location2,
162
162
  visibility: "visible",
163
163
  data: {
164
164
  status,
@@ -264,10 +264,11 @@ function installTranscriptView(ctx) {
264
264
  }
265
265
 
266
266
  // src/client.js
267
- var inject = ["slots", "sessions", "commandUi", "remote", "remote.session", "locale", "uiConversation", "conversation"];
267
+ var inject = ["slots", "sessions", "commandUi", "remote", "remote.session", "locale", "uiConversation", "conversation", "uiWorkspace"];
268
+ var WORKBENCH_PANEL = "oneagents-a2a-workbench";
268
269
  var dictionaries = {
269
- zh: { toolGroup: "\u5DF2\u8C03\u7528 {count} \u4E2A\u5DE5\u5177", model: "\u6A21\u578B", choose: "\u9009\u62E9\u6A21\u578B", loading: "\u6B63\u5728\u8FDE\u63A5 Agent\u2026", loadingModels: "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u2026", retry: "\u91CD\u8BD5", mode: "\u6A21\u5F0F", command: "Agent \u6307\u4EE4", effort: "\u601D\u8003\u5F3A\u5EA6", unsupported: "Agent \u672A\u63D0\u4F9B\u53EF\u5207\u6362\u7684\u6A21\u578B", description: "\u9009\u62E9\u5F53\u524D Agent \u7684\u6A21\u578B", error: "\u8FDE\u63A5\u5931\u8D25", noCommands: "Agent \u5C1A\u672A\u63D0\u4F9B\u6307\u4EE4", native: "ACP \u8BBE\u7F6E", activeWriter: "\u539F\u4F1A\u8BDD\u6B63\u5728\u5176\u4ED6\u5BA2\u6237\u7AEF\u8FD0\u884C\uFF0C\u53EF\u67E5\u770B\u5386\u53F2\uFF1B\u5360\u7528\u89E3\u9664\u540E\u81EA\u52A8\u6062\u590D\u8F93\u5165\u3002" },
270
- en: { toolGroup: "{count} tool calls", model: "Model", choose: "Select model", loading: "Connecting to Agent\u2026", loadingModels: "Loading models\u2026", retry: "Retry", mode: "Mode", command: "Agent commands", effort: "Reasoning effort", unsupported: "This Agent does not advertise model selection", description: "Select this Agent\u2019s model", error: "Connection failed", noCommands: "No commands advertised", native: "ACP settings", activeWriter: "The original session is running in another client. History is available; input resumes when it is released." }
270
+ zh: { toolGroup: "\u5DF2\u8C03\u7528 {count} \u4E2A\u5DE5\u5177", model: "\u6A21\u578B", choose: "\u9009\u62E9\u6A21\u578B", loading: "\u6B63\u5728\u8FDE\u63A5 Agent\u2026", loadingModels: "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u2026", retry: "\u91CD\u8BD5", mode: "\u6A21\u5F0F", command: "Agent \u6307\u4EE4", effort: "\u601D\u8003\u5F3A\u5EA6", unsupported: "Agent \u672A\u63D0\u4F9B\u53EF\u5207\u6362\u7684\u6A21\u578B", description: "\u9009\u62E9\u5F53\u524D Agent \u7684\u6A21\u578B", error: "\u8FDE\u63A5\u5931\u8D25", noCommands: "Agent \u5C1A\u672A\u63D0\u4F9B\u6307\u4EE4", native: "ACP \u8BBE\u7F6E", activeWriter: "\u539F\u4F1A\u8BDD\u6B63\u5728\u5176\u4ED6\u5BA2\u6237\u7AEF\u8FD0\u884C\uFF0C\u53EF\u67E5\u770B\u5386\u53F2\uFF1B\u5360\u7528\u89E3\u9664\u540E\u81EA\u52A8\u6062\u590D\u8F93\u5165\u3002", workbench: "A2A \u5DE5\u4F5C\u53F0", a2aRunning: "A2A \u4EFB\u52A1\u6B63\u5728\u6B64\u4F1A\u8BDD\u6267\u884C\uFF0C\u7ED3\u675F\u540E\u53EF\u4EBA\u5DE5\u63A5\u7BA1\u3002" },
271
+ en: { toolGroup: "{count} tool calls", model: "Model", choose: "Select model", loading: "Connecting to Agent\u2026", loadingModels: "Loading models\u2026", retry: "Retry", mode: "Mode", command: "Agent commands", effort: "Reasoning effort", unsupported: "This Agent does not advertise model selection", description: "Select this Agent\u2019s model", error: "Connection failed", noCommands: "No commands advertised", native: "ACP settings", activeWriter: "The original session is running in another client. History is available; input resumes when it is released.", workbench: "A2A Workbench", a2aRunning: "An A2A task is running in this session; you can take over once it ends." }
271
272
  };
272
273
  function choices(option) {
273
274
  return (option.options ?? []).flatMap((item) => "group" in item ? item.options.map((value) => ({ ...value, group: item.name ?? item.group })) : [item]);
@@ -317,12 +318,26 @@ function apply(ctx) {
317
318
  return selected;
318
319
  };
319
320
  const isAcp = (id) => String(presetOf(id) ?? "").startsWith("oneagents-acp-");
320
- const block = (id, reason) => {
321
- if (disposed || !reason && !blockedSessions.has(id)) return;
321
+ const acpBlocks = /* @__PURE__ */ new Map();
322
+ const a2aBlocks = /* @__PURE__ */ new Map();
323
+ const applyBlock = (id) => {
324
+ const reason = acpBlocks.get(id) ?? a2aBlocks.get(id);
322
325
  if (reason) blockedSessions.add(id);
323
326
  else blockedSessions.delete(id);
324
327
  ctx.conversation.blocks.set(id, reason ? { reason } : void 0);
325
328
  };
329
+ const block = (id, reason) => {
330
+ if (disposed || !reason && !blockedSessions.has(id)) return;
331
+ if (reason) acpBlocks.set(id, reason);
332
+ else acpBlocks.delete(id);
333
+ applyBlock(id);
334
+ };
335
+ const blockA2A = (id, reason) => {
336
+ if (disposed || reason === a2aBlocks.get(id)) return;
337
+ if (reason) a2aBlocks.set(id, reason);
338
+ else a2aBlocks.delete(id);
339
+ applyBlock(id);
340
+ };
326
341
  const notify = (id) => {
327
342
  for (const fn of listeners.get(id) ?? []) fn();
328
343
  };
@@ -446,6 +461,24 @@ function apply(ctx) {
446
461
  }, 5e3);
447
462
  return () => clearInterval(timer);
448
463
  }, [external, sessionId, presetId]);
464
+ (0, import_react2.useEffect)(() => {
465
+ let live = true, timer;
466
+ const check = () => fetch(`/workbench/ui/api/dsh/sessions/${encodeURIComponent(sessionId)}`, { credentials: "same-origin" }).then((response) => response.ok ? response.json() : void 0).then((value) => {
467
+ if (!live) return;
468
+ const task = value?.task;
469
+ blockA2A(sessionId, task?.running ? t("a2aRunning") : void 0);
470
+ if (task && timer === void 0) timer = setInterval(() => {
471
+ if (document.visibilityState === "visible") void check();
472
+ }, 5e3);
473
+ }, () => {
474
+ });
475
+ void check();
476
+ return () => {
477
+ live = false;
478
+ if (timer !== void 0) clearInterval(timer);
479
+ blockA2A(sessionId, void 0);
480
+ };
481
+ }, [sessionId]);
449
482
  const change = async (action) => {
450
483
  const operation = ++changeSequence.current;
451
484
  const revision = revisionOf(sessionId);
@@ -491,6 +524,29 @@ function apply(ctx) {
491
524
  return (0, import_react2.createElement)("div", { "data-oneagents-acp-controls": external ? "acp" : "dsh", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 8 } }, controls);
492
525
  }
493
526
  ctx.slots.inject("conversation.input.model", () => ctx.slots.register({ name: "conversation.input.model", inject: (sessionId) => ({ sessionId }) }, ModelControls));
527
+ function WorkbenchPanel() {
528
+ const frame = (0, import_react2.useRef)(null);
529
+ (0, import_react2.useEffect)(() => {
530
+ const onMessage = (event) => {
531
+ if (event.origin !== location.origin || event.source !== frame.current?.contentWindow) return;
532
+ const { type, sessionId } = event.data ?? {};
533
+ if (type === "1agents:open-session" && typeof sessionId === "string" && sessionId) ctx.uiWorkspace.openSession(sessionId);
534
+ };
535
+ window.addEventListener("message", onMessage);
536
+ return () => window.removeEventListener("message", onMessage);
537
+ }, []);
538
+ return (0, import_react2.createElement)("iframe", { ref: frame, src: "/workbench/ui/", title: t("workbench"), style: { display: "block", width: "100%", height: "100%", border: 0 } });
539
+ }
540
+ function WorkbenchIcon({ size }) {
541
+ return (0, import_react2.createElement)(
542
+ "svg",
543
+ { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
544
+ (0, import_react2.createElement)("rect", { x: 3, y: 4, width: 18, height: 16, rx: 2 }),
545
+ (0, import_react2.createElement)("path", { d: "M9 4v16M13 9h5M13 13h5" })
546
+ );
547
+ }
548
+ ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: WORKBENCH_PANEL }, WorkbenchPanel));
549
+ ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({ name: "sidebar.panellist", id: WORKBENCH_PANEL, order: 20, label: () => t("workbench") }, WorkbenchIcon));
494
550
  ctx.effect(() => ctx.commandUi.register({
495
551
  name: "model",
496
552
  description: () => t("description"),
@@ -2,11 +2,20 @@
2
2
  import { homedir } from 'node:os';
3
3
  import { join, resolve } from 'node:path';
4
4
  import { openDiagnostics } from './diagnostics.js';
5
- import { AcpAdapter } from './adapter.js';
5
+ import { AcpAdapter, validateSessionPolicies } from './adapter.js';
6
6
  import { discoverPresets } from './discovery.js';
7
7
  import { NativeSessions } from './imports.js';
8
8
  import { acquireService, resolveServiceOptions } from './service-process.js';
9
9
  import { mountDshA2A } from './a2a.js';
10
+ import { createWorkbenchProcessClient } from './process-requests.js';
11
+ import { selectAcpRoute } from './preset-route.js';
12
+ import { registerNativeApprovals } from './native-approvals.js';
13
+ import { defineTool } from '@deepseek-ai/dsh-tools';
14
+ import { WORKBENCH_UI_PATH } from '@1agents/acp-service/a2a';
15
+ import { REVIEW_SUBMIT_PATH, ReviewHandBack, SUBMIT_DESCRIPTION, SUBMIT_TOOL, SUMMARY_DESCRIPTION } from './review.js';
16
+ import { workbenchHandler } from './workbench.js';
17
+ import { createTicketGateway, runTicketTool, ticketTools } from './ticket-tools.js';
18
+ import { TICKET_PATH } from './ticket-spec.js';
10
19
  export { name, inject } from '@1agents/acp-service';
11
20
  export async function apply(ctx, input = {}) {
12
21
  const homePath = ctx.get('dshHomePath');
@@ -21,6 +30,7 @@ export async function apply(ctx, input = {}) {
21
30
  serviceUrl, agents: presets.map(preset => preset.id),
22
31
  stateDirectory: input.stateDirectory ?? join(home, 'plugins', '1agents-acp', 'sessions'),
23
32
  reconnectAttempts: input.reconnectAttempts ?? 5, reconnectDelayMs: input.reconnectDelayMs ?? 1000,
33
+ sessionPolicies: validateSessionPolicies(input.sessionPolicies),
24
34
  };
25
35
  if (config.agents.some(a => !/^[a-z0-9_-]+$/i.test(a)))
26
36
  throw new Error('agents must contain ACP registry names');
@@ -29,8 +39,12 @@ export async function apply(ctx, input = {}) {
29
39
  const diagnosticOwner = await openDiagnostics(resolve(input.diagnosticsDirectory ?? join(config.stateDirectory, 'diagnostics')));
30
40
  const { diagnostics } = diagnosticOwner;
31
41
  let closeA2A;
32
- const adapter = new AcpAdapter(ctx, config, diagnostics);
42
+ const processRequests = input.a2a?.workbench ? createWorkbenchProcessClient(input.a2a.workbench) : undefined;
43
+ const adapter = new AcpAdapter(ctx, config, diagnostics, processRequests);
33
44
  ctx.effect(() => ctx.llm.registerAdapter(['1agents-acp'], adapter));
45
+ // A Cordis listener is released with this plugin's fiber.
46
+ if (processRequests)
47
+ registerNativeApprovals(ctx, processRequests);
34
48
  const nativeSessions = new NativeSessions(ctx, adapter, config);
35
49
  ctx.provide('oneagentsAcpSessions', nativeSessions);
36
50
  ctx.effect(() => async () => {
@@ -94,6 +108,45 @@ export async function apply(ctx, input = {}) {
94
108
  });
95
109
  ctx.effect(() => dispose);
96
110
  }
97
- if (input.a2a)
98
- closeA2A = await mountDshA2A(ctx, input.a2a, join(home, 'plugins', '1agents-acp', 'a2a'), diagnostics);
111
+ // A preset chosen on a session that is already running is composed onto its
112
+ // live agent instead of creating one, so the route the preset proposes is
113
+ // never recorded and the next step rejects it. Record it here.
114
+ ctx.on('agent-preset/selected', (sessionId, agentPreset) => {
115
+ void selectAcpRoute(ctx, sessionId, agentPreset, presets.map(preset => preset.id));
116
+ });
117
+ if (input.a2a) {
118
+ const review = await ReviewHandBack.open(join(home, 'plugins', '1agents-acp', 'review.secret'), input.a2a.workbench);
119
+ ctx.effect(() => ctx.webServer.register({ kind: 'prefix', path: WORKBENCH_UI_PATH, handler: workbenchHandler(ctx, { workbench: input.a2a.workbench, host: () => review.host }) }));
120
+ ctx.effect(() => ctx.webServer.register({ kind: 'exact', path: REVIEW_SUBMIT_PATH, handler: review.handler }));
121
+ ctx.effect(() => ctx.tools.register(defineTool({
122
+ name: SUBMIT_TOOL, description: SUBMIT_DESCRIPTION,
123
+ parameters: { summary: { type: 'string', required: true, description: SUMMARY_DESCRIPTION } },
124
+ output: { schema: { type: 'object', additionalProperties: false, properties: { message: { type: 'string', required: true } } },
125
+ render: (_args, value) => [{ type: 'text', text: value.message }] },
126
+ async execute(args, exec) {
127
+ if (!exec.agent)
128
+ throw new Error(`${SUBMIT_TOOL} requires an owning agent session`);
129
+ return { message: await review.submit(exec.agent.id, args.summary) };
130
+ },
131
+ })));
132
+ // The executor's task ticket lives on the gateway; native agents handle it through these tools.
133
+ if (input.a2a.workbench) {
134
+ const gateway = createTicketGateway(input.a2a.workbench);
135
+ for (const tool of ticketTools(gateway))
136
+ ctx.effect(() => ctx.tools.register(tool));
137
+ // ACP agents call the same tools through their session's MCP server, which comes back here.
138
+ ctx.effect(() => ctx.webServer.register({ kind: 'exact', path: TICKET_PATH,
139
+ handler: review.ticketHandler((sessionId, tool, args) => runTicketTool(gateway, sessionId, tool, args, 'mcp')) }));
140
+ }
141
+ // ACP agents reach the same hand-back and ticket tools through a per-session MCP server. It is offered to every ACP
142
+ // session: the connection is opened once and reused, often before a turn binds the session to its A2A task or a
143
+ // person takes it over, so the tools themselves refuse a session that has no task.
144
+ const origin = `${ctx.webServer.protocol ?? 'http:'}//127.0.0.1:${ctx.webServer.port}`;
145
+ adapter.mcpServersFor = sessionId => review.host ? [review.mcpServer(sessionId, origin)] : [];
146
+ closeA2A = await mountDshA2A(ctx, input.a2a, join(home, 'plugins', '1agents-acp', 'a2a'), diagnostics, {
147
+ release: sessionId => adapter.releaseSession(sessionId),
148
+ delete: sessionId => adapter.deleteSession(sessionId),
149
+ status: sessionId => adapter.sessionStatus(sessionId),
150
+ }, host => { review.host = host; });
151
+ }
99
152
  }
@@ -0,0 +1,4 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { ProcessRequestClient } from './process-requests.js';
3
+ /** Runs ahead of the host UI answerer for every agent; agents outside an A2A task pass straight through. */
4
+ export declare function registerNativeApprovals(ctx: Context, client: ProcessRequestClient): () => void;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * DSH's own tool approvals inside an A2A task go to the gateway workbench as process requests, like ACP tool
3
+ * approvals. The workbench is the only place to answer them: the host UI keeps its prompt for the request's
4
+ * whole lifetime and could not withdraw it once the workbench answered. Without a reachable workbench, the
5
+ * host UI answers as before.
6
+ */
7
+ import { createHash, randomUUID } from 'node:crypto';
8
+ import { currentA2AExecution } from '@1agents/acp-service/a2a';
9
+ function outcomeOf(view) {
10
+ if (view.status !== 'answered')
11
+ return 'cancelled';
12
+ return view.answer?.outcome === 'approved' ? 'allowed-once' : view.answer?.outcome === 'rejected' ? 'rejected' : 'cancelled';
13
+ }
14
+ /** Runs ahead of the host UI answerer for every agent; agents outside an A2A task pass straight through. */
15
+ export function registerNativeApprovals(ctx, client) {
16
+ return ctx.on('approval/request', async (req, next) => {
17
+ const binding = currentA2AExecution(req.agent.id);
18
+ // ACP presets open their own request in the adapter, and that request's host-UI answer passes through here.
19
+ if (!binding || String(req.agent.session.header.agentPreset ?? '').startsWith('oneagents-acp-'))
20
+ return next();
21
+ const signal = req.signal ?? new AbortController().signal;
22
+ const reason = req.reason ?? req.displayReason?.en ?? '';
23
+ // The call id keeps each call its own request; without one, a later identical command must not reuse an earlier answer.
24
+ const body = [req.callId ?? randomUUID(), req.toolName, reason];
25
+ const requestId = `prc-${createHash('sha256').update(JSON.stringify([binding.jobId, binding.attemptId, 'permission', body])).digest('hex').slice(0, 32)}`;
26
+ let opened;
27
+ try {
28
+ opened = await client.open({ requestId, jobId: binding.jobId, attemptId: binding.attemptId, sessionId: req.agent.id,
29
+ kind: 'permission', toolTitle: req.toolName.slice(0, 500), toolDetail: reason.slice(0, 16 * 1024) });
30
+ }
31
+ catch {
32
+ return next();
33
+ }
34
+ try {
35
+ return outcomeOf(await client.wait({ jobId: binding.jobId, requestId: opened.requestId, signal }));
36
+ }
37
+ catch (error) {
38
+ void client.report({ jobId: binding.jobId, requestId: opened.requestId, clientRequestId: `dsh-cancel:${opened.requestId}`, outcome: 'cancelled' }).catch(() => { });
39
+ if (signal.aborted)
40
+ return 'cancelled';
41
+ throw error;
42
+ }
43
+ }, { prepend: true });
44
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The route a session records to run its ACP Agent.
3
+ *
4
+ * A session that starts with an ACP preset gets this route when its agent is
5
+ * created (see preset.ts). A session that only later switches to an ACP preset
6
+ * is recomposed instead: its agent already exists, so the creation event never
7
+ * fires and the route stays unrecorded. The next step then prepares the
8
+ * default model and rejects the ACP route the preset proposes.
9
+ */
10
+ import type { Context } from '@deepseek-ai/cordis';
11
+ import type { SessionId } from '@deepseek-ai/dsh-session';
12
+ /** The provider a session runs its ACP Agent under. */
13
+ export declare const ACP_PROVIDER = "1agents-acp";
14
+ /** One recorded model choice. */
15
+ export interface ModelSelection {
16
+ provider: string;
17
+ model: string;
18
+ }
19
+ /** The part of an agent that records a model selection. */
20
+ export interface ModelSelectionApi {
21
+ select(selection: ModelSelection): void;
22
+ }
23
+ /**
24
+ * The model selection API of a live agent, when the host provides one.
25
+ *
26
+ * Current DSH records the route on the agent; older DSH agents have no such
27
+ * API and take the route from the request waterfall instead. The host's own
28
+ * types do not declare the API, so it is read structurally.
29
+ */
30
+ export declare function modelSelectionOf(agent: unknown): ModelSelectionApi | undefined;
31
+ /**
32
+ * The ACP Agent a preset id names, when this plugin registered that preset.
33
+ * @param agentPreset - Selected preset id.
34
+ * @param known - ACP Agent names this plugin registered presets for.
35
+ * @returns The ACP Agent name, or undefined for another plugin's preset.
36
+ */
37
+ export declare function acpAgentOf(agentPreset: string, known: readonly string[]): string | undefined;
38
+ /**
39
+ * Record the ACP route of a session whose preset was just selected.
40
+ *
41
+ * The route is written after the preset event settles, so the session is not
42
+ * written while its own event is still being dispatched.
43
+ * @param ctx - Host context.
44
+ * @param sessionId - Session whose preset changed.
45
+ * @param agentPreset - Selected preset id.
46
+ * @param known - ACP Agent names this plugin registered presets for.
47
+ * @returns Whether the route was recorded.
48
+ */
49
+ export declare function selectAcpRoute(ctx: Context, sessionId: SessionId, agentPreset: string, known: readonly string[]): Promise<boolean>;
@@ -0,0 +1,51 @@
1
+ /** The provider a session runs its ACP Agent under. */
2
+ export const ACP_PROVIDER = '1agents-acp';
3
+ /**
4
+ * The model selection API of a live agent, when the host provides one.
5
+ *
6
+ * Current DSH records the route on the agent; older DSH agents have no such
7
+ * API and take the route from the request waterfall instead. The host's own
8
+ * types do not declare the API, so it is read structurally.
9
+ */
10
+ export function modelSelectionOf(agent) {
11
+ const model = agent?.model;
12
+ if (!model || typeof model.select !== 'function')
13
+ return undefined;
14
+ return { select: (selection) => model.select(selection) };
15
+ }
16
+ /**
17
+ * The ACP Agent a preset id names, when this plugin registered that preset.
18
+ * @param agentPreset - Selected preset id.
19
+ * @param known - ACP Agent names this plugin registered presets for.
20
+ * @returns The ACP Agent name, or undefined for another plugin's preset.
21
+ */
22
+ export function acpAgentOf(agentPreset, known) {
23
+ return known.find(name => agentPreset === `oneagents-acp-${name}`);
24
+ }
25
+ /** The live agent of a session, without resuming or creating one. */
26
+ function liveAgent(ctx, sessionId) {
27
+ const agents = ctx.agents;
28
+ return agents?.get?.(sessionId);
29
+ }
30
+ /**
31
+ * Record the ACP route of a session whose preset was just selected.
32
+ *
33
+ * The route is written after the preset event settles, so the session is not
34
+ * written while its own event is still being dispatched.
35
+ * @param ctx - Host context.
36
+ * @param sessionId - Session whose preset changed.
37
+ * @param agentPreset - Selected preset id.
38
+ * @param known - ACP Agent names this plugin registered presets for.
39
+ * @returns Whether the route was recorded.
40
+ */
41
+ export async function selectAcpRoute(ctx, sessionId, agentPreset, known) {
42
+ const acpAgent = acpAgentOf(agentPreset, known);
43
+ if (acpAgent === undefined)
44
+ return false;
45
+ const model = modelSelectionOf(liveAgent(ctx, sessionId));
46
+ if (model === undefined)
47
+ return false;
48
+ await new Promise(resolve => setTimeout(resolve, 0));
49
+ model.select({ provider: ACP_PROVIDER, model: acpAgent });
50
+ return true;
51
+ }
@@ -1,10 +1,17 @@
1
+ import { ACP_PROVIDER, modelSelectionOf } from './preset-route.js';
1
2
  export const name = 'oneagents-acp-preset';
2
3
  export const inject = ['agents', 'llm'];
3
4
  export function apply(ctx, config) {
4
5
  if (!/^[a-z0-9_-]+$/i.test(config.agent))
5
6
  throw new Error('Invalid ACP Agent name');
6
- ctx.on('agent/request', async (_event, next) => {
7
- await next();
8
- return { provider: '1agents-acp', model: config.agent };
7
+ const route = { provider: ACP_PROVIDER, model: config.agent };
8
+ // Current DSH fixes each step's model before agent/request and rejects a later swap,
9
+ // so the route is recorded through agent.model.select() when the agent is created or resumed.
10
+ ctx.on('agent/created', ({ agent }) => {
11
+ modelSelectionOf(agent)?.select(route);
12
+ return undefined;
9
13
  });
14
+ // Older DSH has no agent.model and still takes the route from agent/request; on current DSH
15
+ // the proposal already carries the selected route, so this keeps it and its other controls unchanged.
16
+ ctx.on('agent/request', async (_event, next) => ({ ...await next(), ...route }));
10
17
  }
@@ -0,0 +1,25 @@
1
+ /** Retry a process-slot probe without charging queue time against the handshake budget. */
2
+ export interface ProcessCapacityPending {
3
+ position: number;
4
+ waitedMs: number;
5
+ }
6
+ export declare function noteProcessCapacity(sessionId: string, value: ProcessCapacityPending | undefined): void;
7
+ export declare function noteProcessReady(sessionId: string): void;
8
+ export declare function readProcessCapacity(sessionId: string): ProcessCapacityPending | undefined;
9
+ export declare function consumeProcessReady(sessionId: string): boolean;
10
+ export declare function noteSessionRestore(sessionId: string, method: 'session/load' | 'session/resume'): void;
11
+ export declare function readSessionRestore(sessionId: string): 'session/load' | 'session/resume' | undefined;
12
+ export declare function capacityPendingOf(error: unknown): ProcessCapacityPending | undefined;
13
+ /**
14
+ * Each pending probe returns immediately and does not start handshakeMs.
15
+ * A non-pending result is the attempt that owns the handshake budget.
16
+ */
17
+ export declare function requestWhenAdmitted<T>(options: {
18
+ request: () => Promise<T>;
19
+ signal: AbortSignal;
20
+ isPending: (error: unknown) => ProcessCapacityPending | undefined;
21
+ onPending?: (pending: ProcessCapacityPending) => void;
22
+ cancel?: () => Promise<void>;
23
+ sleep?: (ms: number, signal: AbortSignal) => Promise<void>;
24
+ pollMs?: number;
25
+ }): Promise<T>;
@@ -0,0 +1,87 @@
1
+ /** Retry a process-slot probe without charging queue time against the handshake budget. */
2
+ const noted = new Map();
3
+ const ready = new Set();
4
+ export function noteProcessCapacity(sessionId, value) {
5
+ if (!value)
6
+ noted.delete(sessionId);
7
+ else
8
+ noted.set(sessionId, value);
9
+ }
10
+ export function noteProcessReady(sessionId) {
11
+ noted.delete(sessionId);
12
+ ready.add(sessionId);
13
+ }
14
+ export function readProcessCapacity(sessionId) {
15
+ const value = noted.get(sessionId);
16
+ return value ? { ...value } : undefined;
17
+ }
18
+ export function consumeProcessReady(sessionId) {
19
+ return ready.delete(sessionId);
20
+ }
21
+ const restores = new Map();
22
+ export function noteSessionRestore(sessionId, method) {
23
+ restores.set(sessionId, method);
24
+ }
25
+ export function readSessionRestore(sessionId) {
26
+ return restores.get(sessionId);
27
+ }
28
+ export function capacityPendingOf(error) {
29
+ if (!error || typeof error !== 'object')
30
+ return;
31
+ const value = error;
32
+ if (value.code !== -32010 && value.message !== 'CAPACITY_PENDING')
33
+ return;
34
+ const data = value.data;
35
+ if (!data || typeof data !== 'object')
36
+ return;
37
+ const pending = data;
38
+ if (typeof pending.position !== 'number' || !Number.isSafeInteger(pending.position) || pending.position < 1)
39
+ return;
40
+ if (typeof pending.waitedMs !== 'number' || !Number.isFinite(pending.waitedMs) || pending.waitedMs < 0)
41
+ return;
42
+ return { position: pending.position, waitedMs: pending.waitedMs };
43
+ }
44
+ /**
45
+ * Each pending probe returns immediately and does not start handshakeMs.
46
+ * A non-pending result is the attempt that owns the handshake budget.
47
+ */
48
+ export async function requestWhenAdmitted(options) {
49
+ const sleep = options.sleep ?? ((ms, signal) => new Promise((resolve, reject) => {
50
+ const timer = setTimeout(() => { signal.removeEventListener('abort', onAbort); resolve(); }, ms);
51
+ const onAbort = () => { clearTimeout(timer); reject(signal.reason); };
52
+ if (signal.aborted)
53
+ onAbort();
54
+ else
55
+ signal.addEventListener('abort', onAbort, { once: true });
56
+ }));
57
+ const pollMs = options.pollMs ?? 750;
58
+ let queued = false;
59
+ for (;;) {
60
+ options.signal.throwIfAborted();
61
+ try {
62
+ return await options.request();
63
+ }
64
+ catch (error) {
65
+ const pending = options.isPending(error);
66
+ if (!pending) {
67
+ // A queue entry left behind by an earlier pending attempt would block every later launch at the FIFO head.
68
+ if (queued)
69
+ await options.cancel?.().catch(() => undefined);
70
+ throw error;
71
+ }
72
+ queued = true;
73
+ options.onPending?.(pending);
74
+ if (options.signal.aborted) {
75
+ await options.cancel?.().catch(() => undefined);
76
+ options.signal.throwIfAborted();
77
+ }
78
+ try {
79
+ await sleep(pollMs, options.signal);
80
+ }
81
+ catch (sleepError) {
82
+ await options.cancel?.().catch(() => undefined);
83
+ throw sleepError;
84
+ }
85
+ }
86
+ }
87
+ }
@@ -0,0 +1,57 @@
1
+ export interface ProcessQuestionInput {
2
+ id: string;
3
+ question: string;
4
+ header?: string;
5
+ options?: {
6
+ label: string;
7
+ description?: string;
8
+ }[];
9
+ multiSelect?: boolean;
10
+ }
11
+ export interface ProcessRequestOpenInput {
12
+ requestId: string;
13
+ jobId: string;
14
+ attemptId: string;
15
+ sessionId: string;
16
+ kind: 'question' | 'plan' | 'permission';
17
+ questions?: ProcessQuestionInput[];
18
+ planContent?: string;
19
+ toolTitle?: string;
20
+ toolDetail?: string;
21
+ }
22
+ export interface ProcessRequestView {
23
+ requestId: string;
24
+ jobId: string;
25
+ kind: 'question' | 'plan' | 'permission';
26
+ status: 'pending' | 'answered' | 'cancelled' | 'expired';
27
+ deadlineAt: string;
28
+ answer?: {
29
+ clientRequestId: string;
30
+ outcome: string;
31
+ answers?: Record<string, string | string[]>;
32
+ };
33
+ }
34
+ export interface ProcessRequestClient {
35
+ open(input: ProcessRequestOpenInput): Promise<{
36
+ requestId: string;
37
+ deadlineAt: string;
38
+ status: string;
39
+ }>;
40
+ wait(input: {
41
+ jobId: string;
42
+ requestId: string;
43
+ signal: AbortSignal;
44
+ }): Promise<ProcessRequestView>;
45
+ report(input: {
46
+ jobId: string;
47
+ requestId: string;
48
+ clientRequestId: string;
49
+ outcome: string;
50
+ answers?: Record<string, string | string[]>;
51
+ }): Promise<void>;
52
+ }
53
+ export declare function createWorkbenchProcessClient(options: {
54
+ url: string;
55
+ token?: string;
56
+ pollMs?: number;
57
+ }): ProcessRequestClient;
@@ -0,0 +1,49 @@
1
+ /** Polls the gateway workbench for a question, plan or tool permission answer. The token stays in plugin config. */
2
+ import { setTimeout as delay } from 'node:timers/promises';
3
+ export function createWorkbenchProcessClient(options) {
4
+ const url = new URL(options.url);
5
+ if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password)
6
+ throw new Error('a2a.workbench.url must be an HTTP(S) URL without credentials');
7
+ const origin = url.origin;
8
+ const pollMs = options.pollMs ?? 200;
9
+ const endpoint = (path) => new URL(path, origin);
10
+ // A gateway without a workbench token (trusted network) accepts requests without a bearer.
11
+ const headers = { 'Content-Type': 'application/json', ...(options.token?.trim() ? { Authorization: `Bearer ${options.token}` } : {}) };
12
+ async function send(path, method, signal, body) {
13
+ const response = await fetch(endpoint(path), { method, headers, signal, ...(body === undefined ? {} : { body: JSON.stringify(body) }) });
14
+ if (!response.ok)
15
+ throw new Error(`Process request ${method} failed (${response.status})`);
16
+ return response;
17
+ }
18
+ return {
19
+ async open(input) {
20
+ const response = await send(`/workbench/tasks/${encodeURIComponent(input.jobId)}/process-requests`, 'POST', AbortSignal.timeout(5_000), input);
21
+ const body = await response.json();
22
+ if (typeof body.requestId !== 'string' || typeof body.deadlineAt !== 'string')
23
+ throw new Error('Process request record is incomplete');
24
+ return { requestId: body.requestId, deadlineAt: body.deadlineAt, status: typeof body.status === 'string' ? body.status : 'pending' };
25
+ },
26
+ async wait(input) {
27
+ for (;;) {
28
+ input.signal.throwIfAborted();
29
+ const response = await send(`/workbench/tasks/${encodeURIComponent(input.jobId)}/process-requests/${encodeURIComponent(input.requestId)}`, 'GET', input.signal);
30
+ const view = await response.json();
31
+ if (view.status !== 'pending')
32
+ return view;
33
+ if (Date.parse(view.deadlineAt) <= Date.now())
34
+ return { ...view, status: 'expired' };
35
+ await delay(pollMs, undefined, { signal: input.signal });
36
+ }
37
+ },
38
+ async report(input) {
39
+ const response = await fetch(endpoint(`/workbench/tasks/${encodeURIComponent(input.jobId)}/process-requests/${encodeURIComponent(input.requestId)}/answers`), {
40
+ method: 'POST', headers, signal: AbortSignal.timeout(5_000),
41
+ body: JSON.stringify({ clientRequestId: input.clientRequestId, outcome: input.outcome, ...(input.answers ? { answers: input.answers } : {}) }),
42
+ });
43
+ if (response.status === 409)
44
+ return;
45
+ if (!response.ok)
46
+ throw new Error(`Process request answer was not recorded (${response.status})`);
47
+ },
48
+ };
49
+ }
@@ -0,0 +1 @@
1
+ export {};