@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
@@ -0,0 +1,56 @@
1
+ /**
2
+ * MCP server (stdio, newline-delimited JSON-RPC) that an ACP agent starts for an A2A session: the hand-back of a
3
+ * taken-over session, and the executor's ticket tools. It holds no authority of its own: each call is forwarded to
4
+ * the DSH host bound to this session.
5
+ */
6
+ import { createInterface } from 'node:readline';
7
+ import { SUBMIT_DESCRIPTION, SUBMIT_TOOL, SUMMARY_DESCRIPTION } from './review.js';
8
+ import { TICKET_TOOLS } from './ticket-spec.js';
9
+ const url = process.env.ONEAGENTS_REVIEW_URL, ticketUrl = process.env.ONEAGENTS_TICKET_URL, session = process.env.ONEAGENTS_REVIEW_SESSION, token = process.env.ONEAGENTS_REVIEW_TOKEN;
10
+ const tools = [{ name: SUBMIT_TOOL, description: SUBMIT_DESCRIPTION,
11
+ inputSchema: { type: 'object', properties: { summary: { type: 'string', description: SUMMARY_DESCRIPTION } }, required: ['summary'], additionalProperties: false } },
12
+ ...(ticketUrl ? TICKET_TOOLS.map(spec => ({ name: spec.name, description: spec.description,
13
+ inputSchema: { type: 'object', properties: spec.parameters, required: Object.keys(spec.parameters), additionalProperties: false } })) : [])];
14
+ const write = (message) => process.stdout.write(`${JSON.stringify(message)}\n`);
15
+ async function call(name, args) {
16
+ const summary = args?.summary;
17
+ if (name === SUBMIT_TOOL && (typeof summary !== 'string' || !summary.trim()))
18
+ return { content: [{ type: 'text', text: 'summary is required' }], isError: true };
19
+ const target = name === SUBMIT_TOOL ? url : ticketUrl;
20
+ if (!target || !session || !token)
21
+ return { content: [{ type: 'text', text: 'This MCP server was started without its DSH session binding' }], isError: true };
22
+ try {
23
+ const response = await fetch(target, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}`, 'X-Oneagents-Session': session },
24
+ body: JSON.stringify(name === SUBMIT_TOOL ? { summary } : { tool: name, arguments: args ?? {} }), signal: AbortSignal.timeout(120_000) });
25
+ const body = await response.json();
26
+ return response.ok ? { content: [{ type: 'text', text: body.text ?? '' }] } : { content: [{ type: 'text', text: body.error ?? `HTTP ${response.status}` }], isError: true };
27
+ }
28
+ catch (error) {
29
+ return { content: [{ type: 'text', text: `DSH host unreachable: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
30
+ }
31
+ }
32
+ createInterface({ input: process.stdin }).on('line', line => {
33
+ let message;
34
+ try {
35
+ message = JSON.parse(line);
36
+ }
37
+ catch {
38
+ return;
39
+ }
40
+ const { id, method, params } = message;
41
+ if (id === undefined)
42
+ return; // notifications
43
+ const result = (value) => write({ jsonrpc: '2.0', id, result: value });
44
+ if (method === 'initialize')
45
+ return result({ protocolVersion: params?.protocolVersion ?? '2025-06-18', capabilities: { tools: {} }, serverInfo: { name: 'oneagents-review', version: '1.0.0' } });
46
+ if (method === 'ping')
47
+ return result({});
48
+ if (method === 'tools/list')
49
+ return result({ tools });
50
+ if (method === 'tools/call') {
51
+ if (!tools.some(tool => tool.name === params?.name))
52
+ return write({ jsonrpc: '2.0', id, error: { code: -32602, message: `Unknown tool: ${params?.name}` } });
53
+ return void call(params.name, params.arguments).then(result);
54
+ }
55
+ write({ jsonrpc: '2.0', id, error: { code: -32601, message: `Method not found: ${method}` } });
56
+ });
@@ -0,0 +1,30 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import type { McpServerStdio } from '@agentclientprotocol/sdk';
3
+ import type { A2AHostControls } from './a2a.js';
4
+ import { type TicketTool } from './ticket-spec.js';
5
+ export declare const SUBMIT_TOOL = "submit_to_review";
6
+ export declare const SUBMIT_DESCRIPTION = "\u4EC5\u7528\u4E8E\u4ECE A2A \u5DE5\u4F5C\u53F0\u63A5\u7BA1\u7684\u4F1A\u8BDD\uFF1A\u7528\u6237\u660E\u786E\u786E\u8BA4\u6210\u679C\u6CA1\u95EE\u9898\u540E\u8C03\u7528\uFF0C\u628A\u672C\u4F1A\u8BDD A2A \u4EFB\u52A1\u7684\u4EA4\u4ED8\u603B\u7ED3\u4E0E\u4F5C\u4E1A\u76EE\u5F55 artifacts.json \u6E05\u5355\u4E2D\u7684\u4EA7\u7269\u91CD\u65B0\u63D0\u4EA4\u56DE\u5DE5\u4F5C\u6D41\uFF0C\u751F\u6210\u65B0\u7684\u7ED3\u679C\u7248\u672C\u5E76\u8FDB\u5165\u4E1A\u52A1\u9A8C\u6536\u3002\u8C03\u7528\u524D\u5148\u628A\u4EA7\u7269\u5199\u5165\u4F5C\u4E1A\u76EE\u5F55\u5E76\u66F4\u65B0\u6E05\u5355\uFF1B\u7528\u6237\u672A\u786E\u8BA4\u65F6\u4E0D\u8981\u8C03\u7528\u3002";
7
+ export declare const SUMMARY_DESCRIPTION = "\u4EA4\u4ED8\u603B\u7ED3\uFF1A\u672C\u6B21\u4EBA\u5DE5\u63A5\u7BA1\u505A\u4E86\u54EA\u4E9B\u4FEE\u6539\u3001\u6700\u7EC8\u4EA7\u7269\u662F\u4EC0\u4E48\u3002";
8
+ export declare const REVIEW_SUBMIT_PATH = "/1agents-acp/review-submit";
9
+ export declare class ReviewHandBack {
10
+ private readonly secret;
11
+ private readonly workbench?;
12
+ /** Set while the A2A host is mounted. */
13
+ host?: A2AHostControls;
14
+ private constructor();
15
+ static open(secretFile: string, workbench?: {
16
+ url: string;
17
+ token?: string;
18
+ }): Promise<ReviewHandBack>;
19
+ /** Hand the session's task back and let the gateway read it now; returns the agent-facing outcome. */
20
+ submit(sessionId: string, summary: string): Promise<string>;
21
+ private token;
22
+ /** The stdio MCP server an ACP agent starts for one session; the token only acts for that session. */
23
+ mcpServer(sessionId: string, origin: string): McpServerStdio;
24
+ /** A loopback call from the MCP server, checked against its session's token; replies itself and returns nothing when refused. */
25
+ private authorized;
26
+ /** Loopback callback from the MCP server. */
27
+ readonly handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
28
+ /** The MCP server's ticket tools for its session; `run` is the same call DSH's native tools make. */
29
+ ticketHandler(run: (sessionId: string, tool: TicketTool, args: Record<string, unknown>) => Promise<string>): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
30
+ }
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Manual takeover hand-back. A person finishes an A2A task in its DSH session; when they are satisfied the
3
+ * agent calls submit_to_review, the host re-verifies the job's artifacts and the gateway records a new result
4
+ * revision awaiting business acceptance. Native DSH agents get a tool; ACP agents get a stdio MCP server whose
5
+ * calls come back here over loopback, each bound to its own session by an HMAC token. The same server carries the
6
+ * executor's ticket tools for an A2A task session, so an ACP executor handles its ticket like a native one.
7
+ */
8
+ import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
9
+ import { constants } from 'node:fs';
10
+ import { mkdir, open, readFile } from 'node:fs/promises';
11
+ import { dirname } from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+ import { TICKET_PATH, TICKET_TOOLS } from './ticket-spec.js';
14
+ export const SUBMIT_TOOL = 'submit_to_review';
15
+ export const SUBMIT_DESCRIPTION = '仅用于从 A2A 工作台接管的会话:用户明确确认成果没问题后调用,把本会话 A2A 任务的交付总结与作业目录 artifacts.json 清单中的产物重新提交回工作流,生成新的结果版本并进入业务验收。调用前先把产物写入作业目录并更新清单;用户未确认时不要调用。';
16
+ export const SUMMARY_DESCRIPTION = '交付总结:本次人工接管做了哪些修改、最终产物是什么。';
17
+ export const REVIEW_SUBMIT_PATH = '/1agents-acp/review-submit';
18
+ const MCP_SCRIPT = fileURLToPath(new URL('./review-mcp.js', import.meta.url));
19
+ async function hostSecret(file) {
20
+ try {
21
+ const value = Buffer.from((await readFile(file, 'utf8')).trim(), 'base64url');
22
+ if (value.length === 32)
23
+ return value;
24
+ }
25
+ catch (error) {
26
+ if (error.code !== 'ENOENT')
27
+ throw error;
28
+ }
29
+ // Persisted so an ACP agent process that outlives a DSH restart keeps a valid token.
30
+ await mkdir(dirname(file), { recursive: true, mode: 0o700 });
31
+ const value = randomBytes(32), handle = await open(file, constants.O_WRONLY | constants.O_CREAT | constants.O_TRUNC | constants.O_NOFOLLOW, 0o600);
32
+ try {
33
+ await handle.writeFile(value.toString('base64url'));
34
+ }
35
+ finally {
36
+ await handle.close();
37
+ }
38
+ return value;
39
+ }
40
+ const loopback = (address) => address === '127.0.0.1' || address === '::1' || address === '::ffff:127.0.0.1';
41
+ export class ReviewHandBack {
42
+ secret;
43
+ workbench;
44
+ /** Set while the A2A host is mounted. */
45
+ host;
46
+ constructor(secret, workbench) {
47
+ this.secret = secret;
48
+ this.workbench = workbench;
49
+ }
50
+ static async open(secretFile, workbench) {
51
+ return new ReviewHandBack(await hostSecret(secretFile), workbench);
52
+ }
53
+ /** Hand the session's task back and let the gateway read it now; returns the agent-facing outcome. */
54
+ async submit(sessionId, summary) {
55
+ if (!this.host)
56
+ throw new Error('A2A is not enabled on this DSH host');
57
+ const result = await this.host.resubmit({ sessionId, summary });
58
+ let refreshed = false;
59
+ if (this.workbench && result.jobId) {
60
+ // A webhook may already be on its way; this read only makes the new revision visible at once.
61
+ const headers = this.workbench.token?.trim() ? { Authorization: `Bearer ${this.workbench.token}` } : {};
62
+ try {
63
+ const response = await fetch(new URL(`/workbench/tasks/${encodeURIComponent(result.jobId)}/refresh`, new URL(this.workbench.url).origin), { method: 'POST', headers, signal: AbortSignal.timeout(10_000) });
64
+ await response.body?.cancel();
65
+ refreshed = response.ok;
66
+ }
67
+ catch { /* The stored snapshot stays authoritative. */ }
68
+ }
69
+ return `已提交回工作流:任务 ${result.jobId ?? result.taskId} 生成新的结果版本,等待业务验收;作业目录清单中的 ${result.artifacts.length} 个产物已重新校验 sha256。`
70
+ + (refreshed ? '' : '工作台会在网关收到回调后更新。');
71
+ }
72
+ token(sessionId) { return createHmac('sha256', this.secret).update(sessionId).digest('base64url'); }
73
+ /** The stdio MCP server an ACP agent starts for one session; the token only acts for that session. */
74
+ mcpServer(sessionId, origin) {
75
+ // Inside DSH process.execPath is the Electron app; without this it would start the app instead of the script.
76
+ return { name: 'oneagents-review', command: process.execPath, args: [MCP_SCRIPT], env: [
77
+ { name: 'ELECTRON_RUN_AS_NODE', value: '1' },
78
+ { name: 'ONEAGENTS_REVIEW_URL', value: new URL(REVIEW_SUBMIT_PATH, origin).href },
79
+ { name: 'ONEAGENTS_TICKET_URL', value: new URL(TICKET_PATH, origin).href },
80
+ { name: 'ONEAGENTS_REVIEW_SESSION', value: sessionId },
81
+ { name: 'ONEAGENTS_REVIEW_TOKEN', value: this.token(sessionId) },
82
+ ] };
83
+ }
84
+ /** A loopback call from the MCP server, checked against its session's token; replies itself and returns nothing when refused. */
85
+ async authorized(req, reply) {
86
+ if (req.method !== 'POST')
87
+ return void reply(405, { error: 'Method not allowed' });
88
+ if (!loopback(req.socket.remoteAddress) || req.headers.origin)
89
+ return void reply(403, { error: 'Forbidden' });
90
+ const sessionId = req.headers['x-oneagents-session'], authorization = req.headers.authorization;
91
+ if (typeof sessionId !== 'string' || !sessionId || sessionId.length > 256 || !authorization?.startsWith('Bearer '))
92
+ return void reply(401, { error: 'Unauthorized' });
93
+ const expected = Buffer.from(this.token(sessionId)), given = Buffer.from(authorization.slice(7));
94
+ if (expected.length !== given.length || !timingSafeEqual(expected, given))
95
+ return void reply(401, { error: 'Unauthorized' });
96
+ try {
97
+ let body = '';
98
+ for await (const chunk of req) {
99
+ body += String(chunk);
100
+ if (body.length > 96 * 1024)
101
+ throw new Error('too large');
102
+ }
103
+ const parsed = JSON.parse(body);
104
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
105
+ throw new Error('not an object');
106
+ return { sessionId, body: parsed };
107
+ }
108
+ catch {
109
+ return void reply(400, { error: 'Invalid request' });
110
+ }
111
+ }
112
+ /** Loopback callback from the MCP server. */
113
+ handler = async (req, res) => {
114
+ const reply = replier(res), call = await this.authorized(req, reply);
115
+ if (!call)
116
+ return;
117
+ const { sessionId } = call, summary = call.body.summary;
118
+ if (typeof summary !== 'string')
119
+ return reply(400, { error: 'summary must be a string' });
120
+ try {
121
+ reply(200, { text: await this.submit(sessionId, summary) });
122
+ }
123
+ catch (error) {
124
+ const code = error.code;
125
+ reply(typeof code === 'string' ? 409 : 500, { error: error instanceof Error ? error.message : String(error), ...(typeof code === 'string' ? { code } : {}) });
126
+ }
127
+ };
128
+ /** The MCP server's ticket tools for its session; `run` is the same call DSH's native tools make. */
129
+ ticketHandler(run) {
130
+ return async (req, res) => {
131
+ const reply = replier(res), call = await this.authorized(req, reply);
132
+ if (!call)
133
+ return;
134
+ const tool = TICKET_TOOLS.find(spec => spec.name === call.body.tool)?.name, args = call.body.arguments ?? {};
135
+ if (!tool || typeof args !== 'object' || Array.isArray(args))
136
+ return reply(400, { error: 'Unknown ticket tool or invalid arguments' });
137
+ try {
138
+ reply(200, { text: await run(call.sessionId, tool, args) });
139
+ }
140
+ catch (error) {
141
+ reply(409, { error: error instanceof Error ? error.message : String(error) });
142
+ }
143
+ };
144
+ }
145
+ }
146
+ const replier = (res) => (status, body) => {
147
+ res.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-store' });
148
+ res.end(JSON.stringify(body));
149
+ };
@@ -0,0 +1,34 @@
1
+ export interface PinnedAcpOption {
2
+ id: string;
3
+ value: string;
4
+ /** Model selections are replayed before other options. Each set_config_option returns a new catalog. */
5
+ model?: true;
6
+ }
7
+ export interface PinnedAcpSettings {
8
+ cwd: string;
9
+ agent: string;
10
+ modeId?: string;
11
+ options: PinnedAcpOption[];
12
+ }
13
+ /** Remembers values an Agent has already accepted. It does not store the advertised catalog. */
14
+ export declare class AgentSessionSettings {
15
+ private readonly directory;
16
+ constructor(directory: string);
17
+ get(cwd: string, agent: string): PinnedAcpSettings | undefined;
18
+ remember(cwd: string, agent: string, update: {
19
+ modeId?: string;
20
+ option?: PinnedAcpOption;
21
+ }): void;
22
+ private path;
23
+ private load;
24
+ private save;
25
+ }
26
+ /** Model selections stay ahead of the other accepted values. Relative order inside each group is unchanged. */
27
+ export declare function replayPinnedOptions(options: readonly PinnedAcpOption[]): PinnedAcpOption[];
28
+ export declare function pinnedOptionError(agent: string, pinned: PinnedAcpOption, advertised: readonly {
29
+ id?: string;
30
+ options?: readonly unknown[];
31
+ }[] | undefined): string | undefined;
32
+ export declare function pinnedModeError(agent: string, modeId: string, modes: readonly {
33
+ id?: string;
34
+ }[] | undefined): string | undefined;
@@ -0,0 +1,114 @@
1
+ /** Accepted ACP settings, one record per workspace and Agent. Grok Build and Codex do not share a catalog. */
2
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
3
+ import { randomUUID } from 'node:crypto';
4
+ import { isAbsolute, join, resolve } from 'node:path';
5
+ const fileName = 'agent-session-settings.json';
6
+ /** Remembers values an Agent has already accepted. It does not store the advertised catalog. */
7
+ export class AgentSessionSettings {
8
+ directory;
9
+ constructor(directory) {
10
+ this.directory = directory;
11
+ }
12
+ get(cwd, agent) {
13
+ const found = this.load().find(entry => entry.cwd === resolve(cwd) && entry.agent === agent);
14
+ return found ? structuredClone(found) : undefined;
15
+ }
16
+ remember(cwd, agent, update) {
17
+ const key = { cwd: resolve(cwd), agent };
18
+ if (!isAbsolute(key.cwd) || !agent)
19
+ throw new Error('ACP session settings require an absolute workspace and an Agent name');
20
+ const entries = this.load().filter(entry => !(entry.cwd === key.cwd && entry.agent === key.agent));
21
+ const current = this.load().find(entry => entry.cwd === key.cwd && entry.agent === key.agent) ?? { ...key, options: [] };
22
+ const next = { cwd: key.cwd, agent, ...(update.modeId ? { modeId: update.modeId } : current.modeId ? { modeId: current.modeId } : {}), options: current.options.map(option => ({ ...option })) };
23
+ if (update.option) {
24
+ if (!update.option.id || !update.option.value)
25
+ throw new Error('ACP session settings require an option id and value');
26
+ const option = { id: update.option.id, value: update.option.value, ...(update.option.model ? { model: true } : {}) };
27
+ const index = next.options.findIndex(item => item.id === option.id);
28
+ if (index < 0)
29
+ next.options.push(option);
30
+ else
31
+ next.options[index] = option;
32
+ }
33
+ entries.push(next);
34
+ this.save(entries);
35
+ }
36
+ path() { return join(this.directory, fileName); }
37
+ load() {
38
+ let parsed;
39
+ try {
40
+ parsed = JSON.parse(readFileSync(this.path(), 'utf8'));
41
+ }
42
+ catch (error) {
43
+ if (error.code === 'ENOENT')
44
+ return [];
45
+ throw error;
46
+ }
47
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
48
+ throw new Error('Invalid ACP session settings');
49
+ const body = parsed;
50
+ if (body.version !== 1 || !Array.isArray(body.entries))
51
+ throw new Error('Invalid ACP session settings');
52
+ return body.entries.map(decodeEntry);
53
+ }
54
+ save(entries) {
55
+ mkdirSync(this.directory, { recursive: true, mode: 0o700 });
56
+ const path = this.path(), temp = path + '.' + randomUUID();
57
+ writeFileSync(temp, JSON.stringify({ version: 1, entries }) + '\n', { flag: 'wx', mode: 0o600 });
58
+ renameSync(temp, path);
59
+ }
60
+ }
61
+ /** Model selections stay ahead of the other accepted values. Relative order inside each group is unchanged. */
62
+ export function replayPinnedOptions(options) {
63
+ return [...options.filter(option => option.model), ...options.filter(option => !option.model)].map(option => ({ ...option }));
64
+ }
65
+ export function pinnedOptionError(agent, pinned, advertised) {
66
+ const option = advertised?.find(item => item.id === pinned.id);
67
+ if (!option)
68
+ return `Pinned ACP option "${pinned.id}" is not advertised by ${agent}`;
69
+ if (!optionValues(option).includes(pinned.value))
70
+ return `Pinned ACP option "${pinned.id}" value "${pinned.value}" is not advertised by ${agent}`;
71
+ }
72
+ export function pinnedModeError(agent, modeId, modes) {
73
+ if (!modes?.some(mode => mode.id === modeId))
74
+ return `Pinned ACP mode "${modeId}" is not advertised by ${agent}`;
75
+ }
76
+ function optionValues(option) {
77
+ const values = [];
78
+ for (const item of option.options ?? []) {
79
+ if (!item || typeof item !== 'object')
80
+ continue;
81
+ const record = item;
82
+ if (typeof record.value === 'string' && record.value)
83
+ values.push(record.value);
84
+ if (!Array.isArray(record.options))
85
+ continue;
86
+ for (const child of record.options) {
87
+ if (child && typeof child === 'object' && typeof child.value === 'string' && child.value)
88
+ values.push(child.value);
89
+ }
90
+ }
91
+ return values;
92
+ }
93
+ function decodeEntry(value) {
94
+ if (!value || typeof value !== 'object' || Array.isArray(value))
95
+ throw new Error('Invalid ACP session settings');
96
+ const entry = value;
97
+ if (typeof entry.cwd !== 'string' || !isAbsolute(entry.cwd) || typeof entry.agent !== 'string' || !entry.agent)
98
+ throw new Error('Invalid ACP session settings');
99
+ if (entry.modeId !== undefined && (typeof entry.modeId !== 'string' || !entry.modeId))
100
+ throw new Error('Invalid ACP session settings');
101
+ if (!Array.isArray(entry.options))
102
+ throw new Error('Invalid ACP session settings');
103
+ const options = entry.options.map(option => {
104
+ if (!option || typeof option !== 'object' || Array.isArray(option))
105
+ throw new Error('Invalid ACP session settings');
106
+ const item = option;
107
+ if (typeof item.id !== 'string' || !item.id || typeof item.value !== 'string' || !item.value)
108
+ throw new Error('Invalid ACP session settings');
109
+ if (item.model !== undefined && item.model !== true)
110
+ throw new Error('Invalid ACP session settings');
111
+ return { id: item.id, value: item.value, ...(item.model ? { model: true } : {}) };
112
+ });
113
+ return { cwd: entry.cwd, agent: entry.agent, ...(typeof entry.modeId === 'string' ? { modeId: entry.modeId } : {}), options };
114
+ }
@@ -0,0 +1,30 @@
1
+ /** Names, descriptions and parameters of the executor's ticket tools, the same for DSH's native tools and the ACP agents' MCP server. */
2
+ export declare const TICKET_TOOLS: readonly [{
3
+ readonly name: "ticket_show";
4
+ readonly description: "查看本会话 A2A 任务的任务单上待处理的意见:编号、轻重、位置、问题、建议、证据,以及重开意见上一次的说明。";
5
+ readonly parameters: {};
6
+ }, {
7
+ readonly name: "ticket_mark";
8
+ readonly description: "把任务单上一条 open 或 reopened 的意见标为 done(已改)或 disputed(不同意),并写说明。只在被打回修改时可用。";
9
+ readonly parameters: {
10
+ readonly id: {
11
+ readonly type: "string";
12
+ readonly description: "意见编号,如 P1-P2、Q1-3。";
13
+ };
14
+ readonly state: {
15
+ readonly type: "string";
16
+ readonly enum: readonly ["done", "disputed"];
17
+ readonly description: "done:已改;disputed:不同意。";
18
+ };
19
+ readonly note: {
20
+ readonly type: "string";
21
+ readonly description: "怎么改的(改了哪一页、改成了什么),或者不同意的理由和依据的文件。";
22
+ };
23
+ };
24
+ }, {
25
+ readonly name: "ticket_submit";
26
+ readonly description: "任务单上的意见全部处理完后提交,交给宿主检查。还有待处理的意见时会被拒绝。";
27
+ readonly parameters: {};
28
+ }];
29
+ export type TicketTool = typeof TICKET_TOOLS[number]['name'];
30
+ export declare const TICKET_PATH = "/1agents-acp/ticket";
@@ -0,0 +1,10 @@
1
+ /** Names, descriptions and parameters of the executor's ticket tools, the same for DSH's native tools and the ACP agents' MCP server. */
2
+ export const TICKET_TOOLS = [
3
+ { name: 'ticket_show', description: '查看本会话 A2A 任务的任务单上待处理的意见:编号、轻重、位置、问题、建议、证据,以及重开意见上一次的说明。', parameters: {} },
4
+ { name: 'ticket_mark', description: '把任务单上一条 open 或 reopened 的意见标为 done(已改)或 disputed(不同意),并写说明。只在被打回修改时可用。',
5
+ parameters: { id: { type: 'string', description: '意见编号,如 P1-P2、Q1-3。' },
6
+ state: { type: 'string', enum: ['done', 'disputed'], description: 'done:已改;disputed:不同意。' },
7
+ note: { type: 'string', description: '怎么改的(改了哪一页、改成了什么),或者不同意的理由和依据的文件。' } } },
8
+ { name: 'ticket_submit', description: '任务单上的意见全部处理完后提交,交给宿主检查。还有待处理的意见时会被拒绝。', parameters: {} },
9
+ ];
10
+ export const TICKET_PATH = '/1agents-acp/ticket';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The executor's tools for its task ticket, which lives in the gateway's execution ledger on the executor's job.
3
+ * Each call resolves the calling session to the job and attempt it is running, as bound by the A2A executor from the
4
+ * gateway's own dispatch metadata, so the system decides whose ticket it is and that the caller acts as its executor.
5
+ * The gateway re-checks that the attempt is current and unfinished and, once the host reported it, that it runs in
6
+ * this session; it cannot tell this plugin from another local caller holding the same IDs (not defended in the MVP).
7
+ */
8
+ import { type ExecutorTicketArgs } from '@1agents/acp-service/a2a';
9
+ import { type TicketTool } from './ticket-spec.js';
10
+ export interface TicketGateway {
11
+ invoke(method: string, params: Record<string, unknown>): Promise<unknown>;
12
+ }
13
+ export type { TicketTool };
14
+ /** The gateway's /invoke route on the workbench origin this host is configured with. */
15
+ export declare function createTicketGateway(options: {
16
+ url: string;
17
+ token?: string;
18
+ }): TicketGateway;
19
+ /** Runs one tool for a session; a rule the gateway enforces comes back as text for the agent. */
20
+ export declare function runTicketTool(gateway: TicketGateway, sessionId: string, tool: TicketTool, args?: ExecutorTicketArgs, via?: 'dsh' | 'mcp'): Promise<string>;
21
+ export declare function ticketTools(gateway: TicketGateway): import("@deepseek-ai/dsh-tools").ToolDefinition[];
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The executor's tools for its task ticket, which lives in the gateway's execution ledger on the executor's job.
3
+ * Each call resolves the calling session to the job and attempt it is running, as bound by the A2A executor from the
4
+ * gateway's own dispatch metadata, so the system decides whose ticket it is and that the caller acts as its executor.
5
+ * The gateway re-checks that the attempt is current and unfinished and, once the host reported it, that it runs in
6
+ * this session; it cannot tell this plugin from another local caller holding the same IDs (not defended in the MVP).
7
+ */
8
+ import { currentA2AExecution, runExecutorTicket } from '@1agents/acp-service/a2a';
9
+ import { TICKET_TOOLS } from './ticket-spec.js';
10
+ import { defineTool } from '@deepseek-ai/dsh-tools';
11
+ /** The gateway's /invoke route on the workbench origin this host is configured with. */
12
+ export function createTicketGateway(options) {
13
+ const endpoint = new URL('/invoke', new URL(options.url).origin);
14
+ const headers = { 'Content-Type': 'application/json', ...(options.token?.trim() ? { Authorization: `Bearer ${options.token}` } : {}) };
15
+ return {
16
+ async invoke(method, params) {
17
+ const response = await fetch(endpoint, { method: 'POST', headers, redirect: 'error', signal: AbortSignal.timeout(10_000), body: JSON.stringify({ method, params }) });
18
+ const body = await response.json().catch(() => ({}));
19
+ if (!response.ok)
20
+ throw new Error(typeof body.error === 'string' ? body.error : `网关返回 ${response.status}`);
21
+ return body;
22
+ },
23
+ };
24
+ }
25
+ /** Runs one tool for a session; a rule the gateway enforces comes back as text for the agent. */
26
+ export async function runTicketTool(gateway, sessionId, tool, args = {}, via = 'dsh') {
27
+ const execution = currentA2AExecution(sessionId);
28
+ if (!execution)
29
+ throw new Error('本会话不是正在执行的 A2A 任务会话,没有任务单。');
30
+ return (await runExecutorTicket((method, params) => gateway.invoke(method, params), { jobId: execution.jobId, attemptId: execution.attemptId, sessionId }, via, tool, args)).text;
31
+ }
32
+ const output = { schema: { type: 'object', additionalProperties: false, properties: { message: { type: 'string', required: true } } },
33
+ render: (_args, value) => [{ type: 'text', text: value.message }] };
34
+ export function ticketTools(gateway) {
35
+ return TICKET_TOOLS.map(spec => defineTool({ name: spec.name, description: spec.description, output,
36
+ // Every parameter is required in DSH's own schema form.
37
+ parameters: Object.fromEntries(Object.entries(spec.parameters).map(([key, value]) => [key, { ...value, required: true }])),
38
+ execute: (args, exec) => {
39
+ if (!exec.agent)
40
+ throw new Error(`${spec.name} requires an owning agent session`);
41
+ return runTicketTool(gateway, exec.agent.id, spec.name, args).then(message => ({ message }));
42
+ } }));
43
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The gateway's task workbench page, served by DSH at the same path so the page needs no change. DSH's own
3
+ * browser login stands in for the workbench login: every API call must be admitted as the owner, and the
4
+ * plugin forwards it to the gateway's bearer API with a token the browser never sees.
5
+ */
6
+ import type { IncomingMessage, ServerResponse } from 'node:http';
7
+ import type { Context } from '@deepseek-ai/cordis';
8
+ import type { A2AHostControls } from './a2a.js';
9
+ export interface WorkbenchProxyOptions {
10
+ /** Gateway origin, bearer token and page relay secret (the same as a2a.workbench). */
11
+ workbench?: {
12
+ url: string;
13
+ token?: string;
14
+ pageRelaySecret?: string;
15
+ };
16
+ host: () => A2AHostControls | undefined;
17
+ }
18
+ export declare function workbenchHandler(ctx: Context, options: WorkbenchProxyOptions): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
@@ -0,0 +1,91 @@
1
+ import { WORKBENCH_UI_PATH, isAgentRequest, serveWorkbenchPage } from '@1agents/acp-service/a2a';
2
+ import { inspectSession } from './a2a-executor.js';
3
+ const API = `${WORKBENCH_UI_PATH}/api`;
4
+ const BODY_LIMIT = 1024 * 1024;
5
+ const PASSED_HEADERS = ['content-type', 'content-disposition', 'content-security-policy', 'x-content-type-options', 'cache-control'];
6
+ function json(res, status, body) {
7
+ res.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff' });
8
+ res.end(JSON.stringify(body));
9
+ }
10
+ async function bounded(req) {
11
+ const chunks = [];
12
+ let size = 0;
13
+ for await (const chunk of req) {
14
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
15
+ size += buffer.length;
16
+ if (size > BODY_LIMIT)
17
+ throw new Error('Request body too large');
18
+ chunks.push(buffer);
19
+ }
20
+ return Buffer.concat(chunks);
21
+ }
22
+ export function workbenchHandler(ctx, options) {
23
+ const gateway = options.workbench ? new URL(options.workbench.url).origin : undefined;
24
+ return async (req, res) => {
25
+ const url = new URL(req.url ?? '/', 'http://localhost');
26
+ if (url.pathname !== API && !url.pathname.startsWith(`${API}/`))
27
+ return serveWorkbenchPage(req, res, url.pathname, { frameAncestors: "'self'" });
28
+ const admission = ctx.connection.admit(req);
29
+ if ('rejection' in admission)
30
+ return json(res, admission.rejection, { error: admission.rejection === 401 ? 'login_required' : 'forbidden' });
31
+ // Hosts with delegated principals admit non-owners too; earlier hosts admit only the owner's browser.
32
+ const principal = admission.peer.principal;
33
+ if (principal && principal.kind !== 'owner')
34
+ return json(res, 403, { error: 'forbidden' });
35
+ // The reviewer is the person in the browser, never an agent or tool reusing the cookie.
36
+ if (isAgentRequest(req))
37
+ return json(res, 403, { error: 'browser_action_required' });
38
+ if (req.method !== 'GET' && req.method !== 'HEAD' && req.headers['sec-fetch-site'] !== 'same-origin')
39
+ return json(res, 403, { error: 'browser_action_required' });
40
+ const route = url.pathname.slice(API.length);
41
+ if (route === '/session')
42
+ return json(res, 200, { authenticated: true, loginRequired: false });
43
+ // The gateway records only the A2A task ID; this host knows which of its sessions ran it.
44
+ const task = /^\/dsh\/tasks\/([^/]+)$/.exec(route);
45
+ if (task) {
46
+ if (req.method !== 'GET')
47
+ return json(res, 405, { error: 'Method not allowed' });
48
+ const taskId = decodeURIComponent(task[1]);
49
+ if (taskId.length > 256)
50
+ return json(res, 400, { error: 'Invalid task id' });
51
+ const host = options.host(), sessionId = host?.taskSession(taskId);
52
+ const available = sessionId !== undefined && await inspectSession(ctx, sessionId).then(found => found != null, () => false);
53
+ if (!available)
54
+ return json(res, 200, { available: false });
55
+ const current = host.sessionTask(sessionId);
56
+ return json(res, 200, { available, sessionId, ...(current ? { task: current } : {}) });
57
+ }
58
+ if (!gateway)
59
+ return json(res, 503, { error: 'workbench_not_configured', message: '未配置 a2a.workbench,无法连接任务网关。' });
60
+ // As on the gateway page, only the execution host opens process requests.
61
+ if (req.method === 'POST' && /^\/tasks\/[^/]+\/process-requests$/.test(route))
62
+ return json(res, 403, { error: 'browser_action_required' });
63
+ let body;
64
+ try {
65
+ body = req.method === 'GET' || req.method === 'HEAD' ? undefined : await bounded(req);
66
+ }
67
+ catch {
68
+ return json(res, 413, { error: 'Request body too large' });
69
+ }
70
+ // The relay secret tells the gateway this request comes from the person on this page, so it may publish and decide reviews.
71
+ const headers = { ...(options.workbench.token?.trim() ? { Authorization: `Bearer ${options.workbench.token}` } : {}),
72
+ ...(options.workbench.pageRelaySecret ? { 'X-Workbench-Page-Relay': options.workbench.pageRelaySecret } : {}),
73
+ ...(body ? { 'Content-Type': String(req.headers['content-type'] ?? 'application/json') } : {}) };
74
+ let response;
75
+ try {
76
+ response = await fetch(new URL(`/workbench${route}${url.search}`, gateway), { method: req.method, headers, ...(body ? { body: new Uint8Array(body) } : {}),
77
+ redirect: 'error', signal: AbortSignal.timeout(60_000) });
78
+ }
79
+ catch {
80
+ return json(res, 502, { error: 'gateway_unreachable', message: '任务网关不可达。' });
81
+ }
82
+ const passed = {};
83
+ for (const name of PASSED_HEADERS) {
84
+ const value = response.headers.get(name);
85
+ if (value)
86
+ passed[name] = value;
87
+ }
88
+ res.writeHead(response.status, passed);
89
+ res.end(Buffer.from(await response.arrayBuffer()));
90
+ };
91
+ }
@@ -1,13 +1,15 @@
1
- # acpx 🤝 — Agents talking to agents, minus the terminal séance
1
+ # agent-workflow runtime
2
+
3
+ The agent-workflow runtime, based on [acpx](https://github.com/openclaw/acpx): agents talking to agents, minus the terminal séance. Copyright (c) 2025 OpenClaw Team, MIT; the full text is in [LICENSE](LICENSE). The npm package name remains `@scottzx/1acp`. The `1acp` and `acpx` commands stay. In this repository the runtime is private source embedded in `@1agents/acp-service`.
2
4
 
3
5
  <p align="center">
4
6
  <img src="acpx_banner.svg" alt="acpx banner" width="100%" />
5
7
  </p>
6
8
 
7
- [![CI](https://img.shields.io/github/actions/workflow/status/scottzx/1acp/ci.yml?branch=main&style=flat-square&label=ci)](https://github.com/scottzx/1acp/actions/workflows/ci.yml)
9
+ [![CI](https://img.shields.io/github/actions/workflow/status/scottzx/agent-workflow/ci.yml?branch=main&style=flat-square&label=ci)](https://github.com/scottzx/agent-workflow/actions/workflows/ci.yml)
8
10
  [![npm](https://img.shields.io/npm/v/%40scottzx%2F1acp?style=flat-square)](https://www.npmjs.com/package/@scottzx/1acp)
9
11
  [![Node.js](https://img.shields.io/node/v/%40scottzx%2F1acp?style=flat-square)](https://nodejs.org/)
10
- [![License](https://img.shields.io/github/license/scottzx/1acp?style=flat-square)](LICENSE)
12
+ [![License](https://img.shields.io/github/license/scottzx/agent-workflow?style=flat-square)](LICENSE)
11
13
  [![npm downloads](https://img.shields.io/npm/dm/%40scottzx%2F1acp?style=flat-square)](https://www.npmjs.com/package/@scottzx/1acp)
12
14
 
13
15
  `acpx` is a headless command-line client for the [Agent Client Protocol (ACP)](https://agentclientprotocol.com). It gives agents, orchestrators, and developers one structured interface for persistent sessions, one-shot runs, permissions, and machine-readable output across ACP-compatible coding agents.
@@ -112,4 +114,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution and review guidance.
112
114
 
113
115
  ## License
114
116
 
115
- MIT. See [LICENSE](LICENSE).
117
+ MIT. Copyright (c) 2025 OpenClaw Team. See [LICENSE](LICENSE). Repository attribution for this derived runtime is in the workspace [NOTICE](../../NOTICE).