@1agents/acp-service 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/README.md +19 -13
  2. package/dist/bin/a2a.js +6 -2
  3. package/dist/bin/acp-service.js +25 -1
  4. package/dist/bin/process.d.ts +4 -0
  5. package/dist/bin/process.js +57 -0
  6. package/dist/bin/roles.js +21 -18
  7. package/dist/bin/rsi.d.ts +3 -0
  8. package/dist/bin/rsi.js +114 -0
  9. package/dist/bin/ticket.d.ts +13 -0
  10. package/dist/bin/ticket.js +97 -0
  11. package/dist/bin/trail.d.ts +4 -0
  12. package/dist/bin/trail.js +62 -0
  13. package/dist/src/a2a/artifact-content.d.ts +9 -0
  14. package/dist/src/a2a/artifact-content.js +45 -0
  15. package/dist/src/a2a/desktop-notify.d.ts +1 -0
  16. package/dist/src/a2a/desktop-notify.js +12 -0
  17. package/dist/src/a2a/execution-binding.d.ts +9 -0
  18. package/dist/src/a2a/execution-binding.js +19 -0
  19. package/dist/src/a2a/executor.d.ts +7 -2
  20. package/dist/src/a2a/executor.js +127 -60
  21. package/dist/src/a2a/gateway.d.ts +581 -10
  22. package/dist/src/a2a/gateway.js +1018 -95
  23. package/dist/src/a2a/index.d.ts +8 -1
  24. package/dist/src/a2a/index.js +4 -0
  25. package/dist/src/a2a/job-directory.d.ts +6 -0
  26. package/dist/src/a2a/job-directory.js +19 -0
  27. package/dist/src/a2a/preflight.js +16 -1
  28. package/dist/src/a2a/resubmit.d.ts +46 -0
  29. package/dist/src/a2a/resubmit.js +82 -0
  30. package/dist/src/a2a/result-metadata.d.ts +3 -0
  31. package/dist/src/a2a/result-metadata.js +27 -5
  32. package/dist/src/a2a/server.d.ts +10 -0
  33. package/dist/src/a2a/server.js +125 -1
  34. package/dist/src/a2a/session-lifecycle.d.ts +40 -0
  35. package/dist/src/a2a/session-lifecycle.js +54 -0
  36. package/dist/src/a2a/store.d.ts +4 -0
  37. package/dist/src/a2a/store.js +70 -1
  38. package/dist/src/a2a/types.d.ts +46 -6
  39. package/dist/src/a2a/types.js +4 -6
  40. package/dist/src/a2a/workbench-ui.d.ts +28 -0
  41. package/dist/src/a2a/workbench-ui.js +182 -0
  42. package/dist/src/acp-connection.js +27 -3
  43. package/dist/src/bridge.d.ts +1 -0
  44. package/dist/src/bridge.js +191 -39
  45. package/dist/src/capacity-queue.d.ts +35 -0
  46. package/dist/src/capacity-queue.js +139 -2
  47. package/dist/src/capacity.d.ts +25 -0
  48. package/dist/src/capacity.js +48 -9
  49. package/dist/src/dsh.js +1 -1
  50. package/dist/src/execution/agent-files.d.ts +25 -0
  51. package/dist/src/execution/agent-files.js +90 -0
  52. package/dist/src/execution/agent-registry.d.ts +164 -0
  53. package/dist/src/execution/agent-registry.js +275 -0
  54. package/dist/src/execution/human-review.d.ts +2 -0
  55. package/dist/src/execution/human-review.js +3 -1
  56. package/dist/src/execution/ledger.d.ts +52 -0
  57. package/dist/src/execution/ledger.js +83 -5
  58. package/dist/src/execution/ppt-delivery.d.ts +0 -5
  59. package/dist/src/execution/ppt-delivery.js +0 -26
  60. package/dist/src/execution/process-request.d.ts +151 -0
  61. package/dist/src/execution/process-request.js +177 -0
  62. package/dist/src/execution/targets.d.ts +64 -5
  63. package/dist/src/execution/targets.js +58 -7
  64. package/dist/src/execution/ticket-executor.d.ts +25 -0
  65. package/dist/src/execution/ticket-executor.js +27 -0
  66. package/dist/src/execution/ticket.d.ts +326 -0
  67. package/dist/src/execution/ticket.js +301 -0
  68. package/dist/src/execution/workbench-chat.d.ts +25 -0
  69. package/dist/src/execution/workbench-chat.js +54 -0
  70. package/dist/src/execution/workbench.d.ts +32 -1
  71. package/dist/src/execution/workbench.js +113 -22
  72. package/dist/src/roles/index.d.ts +1 -1
  73. package/dist/src/roles/index.js +1 -1
  74. package/dist/src/roles/skills.d.ts +27 -58
  75. package/dist/src/roles/skills.js +89 -404
  76. package/dist/src/rsi/gate.d.ts +25 -0
  77. package/dist/src/rsi/gate.js +59 -0
  78. package/dist/src/rsi/outline-run.d.ts +107 -0
  79. package/dist/src/rsi/outline-run.js +443 -0
  80. package/dist/workbench-ui/app.css +453 -0
  81. package/dist/workbench-ui/app.js +13 -0
  82. package/dist/workbench-ui/chunk-23JHGYT3.js +1 -0
  83. package/dist/workbench-ui/chunk-3H6STGPV.js +1 -0
  84. package/dist/workbench-ui/chunk-3SNBBMGH.js +1 -0
  85. package/dist/workbench-ui/chunk-3XJZ6DIE.js +1 -0
  86. package/dist/workbench-ui/chunk-44KDLLKJ.js +1 -0
  87. package/dist/workbench-ui/chunk-46H7FU5Y.js +7 -0
  88. package/dist/workbench-ui/chunk-4N44QPL7.js +1 -0
  89. package/dist/workbench-ui/chunk-4YN4BS7I.js +1 -0
  90. package/dist/workbench-ui/chunk-53EG4IVQ.js +96 -0
  91. package/dist/workbench-ui/chunk-5FIPUNR4.js +1 -0
  92. package/dist/workbench-ui/chunk-6DWWYA6G.js +2 -0
  93. package/dist/workbench-ui/chunk-6FU3T633.js +99 -0
  94. package/dist/workbench-ui/chunk-6XKIHRA4.js +1 -0
  95. package/dist/workbench-ui/chunk-7GIX43Y5.js +1 -0
  96. package/dist/workbench-ui/chunk-7Q4WBGX6.js +4 -0
  97. package/dist/workbench-ui/chunk-A3BQM7HR.js +1 -0
  98. package/dist/workbench-ui/chunk-AFCFDDOP.js +24 -0
  99. package/dist/workbench-ui/chunk-AG67EUYD.js +89 -0
  100. package/dist/workbench-ui/chunk-AGJHMMTN.js +1 -0
  101. package/dist/workbench-ui/chunk-AO6JUBV6.js +41 -0
  102. package/dist/workbench-ui/chunk-AUSLTP43.js +72 -0
  103. package/dist/workbench-ui/chunk-AVZL46TT.js +1 -0
  104. package/dist/workbench-ui/chunk-AZRIGIV2.js +168 -0
  105. package/dist/workbench-ui/chunk-B2LIVH37.js +1 -0
  106. package/dist/workbench-ui/chunk-B7YX5TR5.js +1 -0
  107. package/dist/workbench-ui/chunk-BCB4X4XX.js +1 -0
  108. package/dist/workbench-ui/chunk-BCRQUL2A.js +88 -0
  109. package/dist/workbench-ui/chunk-BI6UHHQP.js +1 -0
  110. package/dist/workbench-ui/chunk-BLSLQ4AQ.js +120 -0
  111. package/dist/workbench-ui/chunk-C3QSRS6E.js +1 -0
  112. package/dist/workbench-ui/chunk-CK7M2PJ3.js +62 -0
  113. package/dist/workbench-ui/chunk-CM6LZ7TU.js +1 -0
  114. package/dist/workbench-ui/chunk-CP63H27F.js +36 -0
  115. package/dist/workbench-ui/chunk-CPUMMIS2.js +70 -0
  116. package/dist/workbench-ui/chunk-CSEIBI5U.js +2 -0
  117. package/dist/workbench-ui/chunk-CUS65DKZ.js +161 -0
  118. package/dist/workbench-ui/chunk-CVQY7TNC.js +1 -0
  119. package/dist/workbench-ui/chunk-D6S3XBIX.js +106 -0
  120. package/dist/workbench-ui/chunk-E253Y562.js +1 -0
  121. package/dist/workbench-ui/chunk-EADDJUDC.js +1 -0
  122. package/dist/workbench-ui/chunk-EBGJ3YXG.js +206 -0
  123. package/dist/workbench-ui/chunk-EKPVZ3WY.js +8 -0
  124. package/dist/workbench-ui/chunk-EQDCEAFY.js +1 -0
  125. package/dist/workbench-ui/chunk-ES3SSDJY.js +40 -0
  126. package/dist/workbench-ui/chunk-ESFD2H7N.js +231 -0
  127. package/dist/workbench-ui/chunk-FVOHPMS6.js +1 -0
  128. package/dist/workbench-ui/chunk-FXMQAGVT.js +1 -0
  129. package/dist/workbench-ui/chunk-GGTADRXD.js +24 -0
  130. package/dist/workbench-ui/chunk-GHIVPGNQ.js +1 -0
  131. package/dist/workbench-ui/chunk-GLU2YQV2.js +1 -0
  132. package/dist/workbench-ui/chunk-GOCKBYSM.js +1 -0
  133. package/dist/workbench-ui/chunk-H2KMMTJB.js +1 -0
  134. package/dist/workbench-ui/chunk-HGVLDNPP.js +39 -0
  135. package/dist/workbench-ui/chunk-HSAVC5GY.js +1 -0
  136. package/dist/workbench-ui/chunk-HSEAD2JH.js +1 -0
  137. package/dist/workbench-ui/chunk-HSIHOBTY.js +1 -0
  138. package/dist/workbench-ui/chunk-IZXOKUGG.js +67 -0
  139. package/dist/workbench-ui/chunk-JFT2LC2T.js +1 -0
  140. package/dist/workbench-ui/chunk-JHL3ZDYK.js +3 -0
  141. package/dist/workbench-ui/chunk-JMORLCZG.js +257 -0
  142. package/dist/workbench-ui/chunk-JR4SIX7A.js +1 -0
  143. package/dist/workbench-ui/chunk-K23HAGEH.js +30 -0
  144. package/dist/workbench-ui/chunk-K43JDCBH.js +1 -0
  145. package/dist/workbench-ui/chunk-KINKFJY7.js +1 -0
  146. package/dist/workbench-ui/chunk-KKQSA4LI.js +2 -0
  147. package/dist/workbench-ui/chunk-KOUZX3UX.js +1 -0
  148. package/dist/workbench-ui/chunk-KR4DRHW2.js +78 -0
  149. package/dist/workbench-ui/chunk-KT4DJNOR.js +1 -0
  150. package/dist/workbench-ui/chunk-KTPNKRRZ.js +292 -0
  151. package/dist/workbench-ui/chunk-LFHIPGSU.js +7 -0
  152. package/dist/workbench-ui/chunk-LWDL4HZB.js +125 -0
  153. package/dist/workbench-ui/chunk-MVYC3CY4.js +1 -0
  154. package/dist/workbench-ui/chunk-NWUPALCY.js +129 -0
  155. package/dist/workbench-ui/chunk-NY7C662Z.js +1 -0
  156. package/dist/workbench-ui/chunk-O76WTHWP.js +1 -0
  157. package/dist/workbench-ui/chunk-OTF7YHRE.js +162 -0
  158. package/dist/workbench-ui/chunk-P6TKKRKP.js +1 -0
  159. package/dist/workbench-ui/chunk-PFHOOWV3.js +1 -0
  160. package/dist/workbench-ui/chunk-PUQLANIM.js +1 -0
  161. package/dist/workbench-ui/chunk-PZCGBYVO.js +1 -0
  162. package/dist/workbench-ui/chunk-QOHUZGP4.js +1 -0
  163. package/dist/workbench-ui/chunk-QSEG3OFF.js +1 -0
  164. package/dist/workbench-ui/chunk-QYPOXZIA.js +84 -0
  165. package/dist/workbench-ui/chunk-R6SOF3JC.js +1 -0
  166. package/dist/workbench-ui/chunk-RCLOYU5F.js +1 -0
  167. package/dist/workbench-ui/chunk-RSRUP64S.js +1 -0
  168. package/dist/workbench-ui/chunk-RVAIT6JW.js +1 -0
  169. package/dist/workbench-ui/chunk-S2CCN3II.js +1 -0
  170. package/dist/workbench-ui/chunk-S2Q52W46.js +1 -0
  171. package/dist/workbench-ui/chunk-S2W5THJ5.js +1 -0
  172. package/dist/workbench-ui/chunk-S6ZQZNOX.js +1 -0
  173. package/dist/workbench-ui/chunk-S74PLMMS.js +1 -0
  174. package/dist/workbench-ui/chunk-S7C4HKEY.js +1 -0
  175. package/dist/workbench-ui/chunk-SDTB3Q65.js +1 -0
  176. package/dist/workbench-ui/chunk-SLPRGYUV.js +32 -0
  177. package/dist/workbench-ui/chunk-SQE76S5B.js +1 -0
  178. package/dist/workbench-ui/chunk-SSDZPVPW.js +1 -0
  179. package/dist/workbench-ui/chunk-SVI7DGIE.js +1 -0
  180. package/dist/workbench-ui/chunk-T6QKLZ4H.js +62 -0
  181. package/dist/workbench-ui/chunk-TJNRPTFL.js +1 -0
  182. package/dist/workbench-ui/chunk-TP6U4EDH.js +2 -0
  183. package/dist/workbench-ui/chunk-TYAAT3GQ.js +1 -0
  184. package/dist/workbench-ui/chunk-U6OCY4ZH.js +1 -0
  185. package/dist/workbench-ui/chunk-UAN3NLRF.js +1 -0
  186. package/dist/workbench-ui/chunk-UMLU3FIX.js +1 -0
  187. package/dist/workbench-ui/chunk-URIY2OTM.js +1 -0
  188. package/dist/workbench-ui/chunk-V2NUKAA7.js +38 -0
  189. package/dist/workbench-ui/chunk-V4QLL4TE.js +139 -0
  190. package/dist/workbench-ui/chunk-VASHXUK4.js +2 -0
  191. package/dist/workbench-ui/chunk-VJLIWNIU.js +1 -0
  192. package/dist/workbench-ui/chunk-VQNQFBID.js +1 -0
  193. package/dist/workbench-ui/chunk-VSIWU7XA.js +3 -0
  194. package/dist/workbench-ui/chunk-VSJASPUZ.js +321 -0
  195. package/dist/workbench-ui/chunk-VXPNUNUX.js +3 -0
  196. package/dist/workbench-ui/chunk-WBKLDCV6.js +1 -0
  197. package/dist/workbench-ui/chunk-WOKJM3FY.js +1 -0
  198. package/dist/workbench-ui/chunk-X3U3NA3X.js +34 -0
  199. package/dist/workbench-ui/chunk-XBYU7M4J.js +1 -0
  200. package/dist/workbench-ui/chunk-XBZAO4ID.js +10 -0
  201. package/dist/workbench-ui/chunk-XLLPZ2WO.js +1 -0
  202. package/dist/workbench-ui/chunk-YFVL4NJL.js +1 -0
  203. package/dist/workbench-ui/chunk-YRFQENM4.js +1 -0
  204. package/dist/workbench-ui/chunk-YUADQVB2.js +1 -0
  205. package/dist/workbench-ui/chunk-Z3TCAKM5.js +1 -0
  206. package/dist/workbench-ui/chunk-Z6QR6FRE.js +10 -0
  207. package/dist/workbench-ui/chunk-ZJPSORPP.js +3 -0
  208. package/dist/workbench-ui/chunk-ZLGCSTR2.js +15 -0
  209. package/dist/workbench-ui/chunk-ZLR4SG5X.js +1 -0
  210. package/dist/workbench-ui/chunk-ZND3TTGF.js +1 -0
  211. package/dist/workbench-ui/chunk-ZOP3ZYH7.js +2 -0
  212. package/dist/workbench-ui/index.html +14 -0
  213. package/package.json +19 -8
  214. package/skills/acp-service/SKILL.md +4 -2
  215. package/skills/acp-service/references/a2a.md +18 -6
  216. package/skills/acp-service/references/dsh.md +2 -0
  217. package/skills/acp-service/references/roles-and-tasks.md +10 -10
  218. package/skills/rsi-coach/SKILL.md +134 -0
  219. package/vendor/dsh/README.md +10 -6
  220. package/vendor/dsh/a2a-executor.d.ts +56 -2
  221. package/vendor/dsh/a2a-executor.js +163 -17
  222. package/vendor/dsh/a2a.d.ts +12 -2
  223. package/vendor/dsh/a2a.js +9 -2
  224. package/vendor/dsh/adapter.d.ts +52 -3
  225. package/vendor/dsh/adapter.js +297 -30
  226. package/vendor/dsh/client.js +67 -11
  227. package/vendor/dsh/index.js +55 -3
  228. package/vendor/dsh/native-approvals.d.ts +4 -0
  229. package/vendor/dsh/native-approvals.js +44 -0
  230. package/vendor/dsh/preset-route.d.ts +49 -0
  231. package/vendor/dsh/preset-route.js +51 -0
  232. package/vendor/dsh/preset.js +10 -3
  233. package/vendor/dsh/process-admission.d.ts +25 -0
  234. package/vendor/dsh/process-admission.js +87 -0
  235. package/vendor/dsh/process-requests.d.ts +57 -0
  236. package/vendor/dsh/process-requests.js +49 -0
  237. package/vendor/dsh/review-mcp.d.ts +1 -0
  238. package/vendor/dsh/review-mcp.js +56 -0
  239. package/vendor/dsh/review.d.ts +30 -0
  240. package/vendor/dsh/review.js +149 -0
  241. package/vendor/dsh/session-settings.d.ts +34 -0
  242. package/vendor/dsh/session-settings.js +114 -0
  243. package/vendor/dsh/ticket-spec.d.ts +30 -0
  244. package/vendor/dsh/ticket-spec.js +10 -0
  245. package/vendor/dsh/ticket-tools.d.ts +21 -0
  246. package/vendor/dsh/ticket-tools.js +43 -0
  247. package/vendor/dsh/workbench.d.ts +18 -0
  248. package/vendor/dsh/workbench.js +91 -0
  249. package/vendor/runtime/README.md +6 -4
  250. package/vendor/runtime/dist/docs-site/CLI.html +2 -2
  251. package/vendor/runtime/dist/docs-site/VISION.html +2 -2
  252. package/vendor/runtime/dist/docs-site/agents.html +2 -2
  253. package/vendor/runtime/dist/docs-site/compare.html +2 -2
  254. package/vendor/runtime/dist/docs-site/config.html +2 -2
  255. package/vendor/runtime/dist/docs-site/custom-agents.html +2 -2
  256. package/vendor/runtime/dist/docs-site/exit-codes.html +2 -2
  257. package/vendor/runtime/dist/docs-site/flows.html +2 -2
  258. package/vendor/runtime/dist/docs-site/index.html +1 -1
  259. package/vendor/runtime/dist/docs-site/install.html +2 -2
  260. package/vendor/runtime/dist/docs-site/llms.txt +1 -1
  261. package/vendor/runtime/dist/docs-site/output-formats.html +2 -2
  262. package/vendor/runtime/dist/docs-site/permissions.html +2 -2
  263. package/vendor/runtime/dist/docs-site/prompting.html +2 -2
  264. package/vendor/runtime/dist/docs-site/quickstart.html +2 -2
  265. package/vendor/runtime/dist/docs-site/releasing.html +2 -2
  266. package/vendor/runtime/dist/docs-site/runtime-environment.html +2 -2
  267. package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +2 -2
  268. package/vendor/runtime/dist/docs-site/safe-errors.html +2 -2
  269. package/vendor/runtime/dist/docs-site/session-control.html +2 -2
  270. package/vendor/runtime/dist/docs-site/session-watch.html +2 -2
  271. package/vendor/runtime/dist/docs-site/sessions.html +2 -2
  272. package/vendor/runtime/dist/docs-site/shared-sessions.html +2 -2
  273. package/vendor/runtime/package.json +6 -4
  274. package/vendor/runtime/skills/acpx/SKILL.md +2 -0
@@ -0,0 +1,45 @@
1
+ /** Serve back only files the host already verified for a task; the receipt, not the caller, names what may be read. */
2
+ import { createHash } from 'node:crypto';
3
+ import { constants } from 'node:fs';
4
+ import { open, realpath } from 'node:fs/promises';
5
+ export const ARTIFACT_CONTENT_LIMIT = 32 * 1024 * 1024;
6
+ export class ArtifactContentError extends Error {
7
+ status;
8
+ code;
9
+ constructor(status, code) {
10
+ super(code);
11
+ this.status = status;
12
+ this.code = code;
13
+ }
14
+ }
15
+ /** The bytes must still match the receipt: a file edited or swapped after verification is refused, not served. */
16
+ export async function readVerifiedArtifact(artifacts, path, sha256) {
17
+ const artifact = artifacts.find(item => item.path === path && item.sha256 === sha256);
18
+ if (!artifact)
19
+ throw new ArtifactContentError(404, 'artifact-not-registered');
20
+ if (artifact.size > ARTIFACT_CONTENT_LIMIT)
21
+ throw new ArtifactContentError(413, 'artifact-too-large');
22
+ let file;
23
+ try {
24
+ if (await realpath(path) !== path)
25
+ throw new ArtifactContentError(409, 'artifact-changed');
26
+ file = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
27
+ }
28
+ catch (error) {
29
+ if (error instanceof ArtifactContentError)
30
+ throw error;
31
+ throw new ArtifactContentError(409, 'artifact-unavailable');
32
+ }
33
+ try {
34
+ const info = await file.stat();
35
+ if (!info.isFile() || info.size !== artifact.size)
36
+ throw new ArtifactContentError(409, 'artifact-changed');
37
+ const content = await file.readFile();
38
+ if (createHash('sha256').update(content).digest('hex') !== sha256)
39
+ throw new ArtifactContentError(409, 'artifact-changed');
40
+ return content;
41
+ }
42
+ finally {
43
+ await file.close();
44
+ }
45
+ }
@@ -0,0 +1 @@
1
+ export declare function notifyDesktop(title: string, message: string, url?: string): void;
@@ -0,0 +1,12 @@
1
+ /** macOS banner for a new workbench request. terminal-notifier opens the page on click; osascript only shows the banner. Failures are ignored. */
2
+ import { execFile } from 'node:child_process';
3
+ export function notifyDesktop(title, message, url) {
4
+ if (process.platform !== 'darwin')
5
+ return;
6
+ execFile('terminal-notifier', ['-title', title, '-message', message, ...(url ? ['-open', url] : [])], error => {
7
+ if (!error)
8
+ return;
9
+ // argv keeps the text out of the AppleScript source.
10
+ execFile('osascript', ['-e', 'on run argv', '-e', 'display notification (item 2 of argv) with title (item 1 of argv)', '-e', 'end run', title, message], () => { });
11
+ });
12
+ }
@@ -0,0 +1,9 @@
1
+ /** Session-scoped link from the DSH prompt to the gateway job that is waiting on it. */
2
+ export interface A2AExecutionRef {
3
+ jobId: string;
4
+ attemptId: string;
5
+ }
6
+ export declare function bindA2AExecution(sessionId: string, execution: A2AExecutionRef): void;
7
+ export declare function currentA2AExecution(sessionId: string): A2AExecutionRef | undefined;
8
+ /** Clears the binding only when it still belongs to this attempt. */
9
+ export declare function unbindA2AExecution(sessionId: string, execution?: A2AExecutionRef): void;
@@ -0,0 +1,19 @@
1
+ const bindings = new Map();
2
+ export function bindA2AExecution(sessionId, execution) {
3
+ if (!sessionId.trim() || !execution.jobId.trim() || !execution.attemptId.trim())
4
+ throw new Error('A2A execution binding requires a session, job, and attempt');
5
+ bindings.set(sessionId, { jobId: execution.jobId, attemptId: execution.attemptId });
6
+ }
7
+ export function currentA2AExecution(sessionId) {
8
+ const value = bindings.get(sessionId);
9
+ return value ? { ...value } : undefined;
10
+ }
11
+ /** Clears the binding only when it still belongs to this attempt. */
12
+ export function unbindA2AExecution(sessionId, execution) {
13
+ const current = bindings.get(sessionId);
14
+ if (!current)
15
+ return;
16
+ if (execution && (current.jobId !== execution.jobId || current.attemptId !== execution.attemptId))
17
+ return;
18
+ bindings.delete(sessionId);
19
+ }
@@ -10,9 +10,8 @@ export interface A2AExecutionOptions {
10
10
  defaultCwd?: string;
11
11
  defaultAgentPreset?: string;
12
12
  workspaces?: Record<string, string>;
13
- /** Profiles and the writable cache root are controlled by the execution host. */
13
+ /** Role profiles are controlled by the execution host; the skills themselves are read from the session's `.agents/skills`. */
14
14
  roleSkills?: {
15
- cacheRoot: string;
16
15
  profiles: Record<string, string>;
17
16
  /** Optional compatibility binding for fresh fixed-preset contexts only. */
18
17
  presetRoles?: Record<string, string>;
@@ -25,6 +24,10 @@ export declare function parseA2AInput(request: SendMessageRequest, options: A2AE
25
24
  prompt: string;
26
25
  input: A2APrepareInput;
27
26
  resultContract?: A2AResultContract;
27
+ execution?: {
28
+ jobId: string;
29
+ attemptId: string;
30
+ };
28
31
  };
29
32
  /** SDK owns the execution lifetime; an HTTP disconnect never aborts this signal. */
30
33
  export declare class A2ASessionExecutor implements AgentExecutor {
@@ -40,6 +43,8 @@ export declare class A2ASessionExecutor implements AgentExecutor {
40
43
  private roleIdFor;
41
44
  private roleFor;
42
45
  isRunning(taskId: string): boolean;
46
+ /** A person took the session over: the pending question is no longer answered through A2A. */
47
+ releaseInput(taskId: string): void;
43
48
  execute(context: RequestContext, bus: ExecutionEventBus): Promise<void>;
44
49
  cancelTask(taskId: string, bus: ExecutionEventBus): Promise<void>;
45
50
  close(): Promise<void>;
@@ -1,14 +1,13 @@
1
1
  /** Official A2A executor with durable DSH context bindings and independent turns. */
2
- import { createHash, randomUUID } from 'node:crypto';
3
- import { lstat, mkdir, readFile, realpath } from 'node:fs/promises';
4
- import { isAbsolute, join, relative, sep } from 'node:path';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { isAbsolute } from 'node:path';
5
4
  import { Role, Task, TaskState, Message } from '@a2a-js/sdk';
6
5
  import { ContentTypeNotSupportedError, RequestMalformedError, UnsupportedOperationError } from '@a2a-js/sdk/errors';
7
6
  import { AgentEvent, resolveUserScope } from '@a2a-js/sdk/server';
8
7
  import { a2aRequestId } from './request-id.js';
9
8
  import { toSafeError } from '@1agents/acp-service/runtime';
10
- import { a2aRoleSkillsSchema } from './types.js';
11
- import { resolveRoleSkills } from '../roles/index.js';
9
+ import { loadRoleSkills } from '../roles/index.js';
10
+ import { agentPromptPrefix, readAgentFile } from '../execution/agent-files.js';
12
11
  import { A2APreflightError, a2aPreflightRequirementsSchema } from './preflight.js';
13
12
  import { a2aResultContractSchema, A2AResultValidationError, createA2AResultMetadata, saveA2AResultMetadata } from './result-metadata.js';
14
13
  import { CapacityGovernor, CapacityError } from '../capacity.js';
@@ -29,11 +28,10 @@ export function validateA2AExecutionOptions(options) {
29
28
  const roles = options.roleSkills;
30
29
  if (roles === undefined)
31
30
  return;
32
- if (!roles || typeof roles !== 'object' || typeof roles.cacheRoot !== 'string' || !isAbsolute(roles.cacheRoot) || roles.cacheRoot.includes('\0')
33
- || !roles.profiles || typeof roles.profiles !== 'object' || Array.isArray(roles.profiles)
31
+ if (!roles || typeof roles !== 'object' || !roles.profiles || typeof roles.profiles !== 'object' || Array.isArray(roles.profiles)
34
32
  || Object.entries(roles.profiles).some(([id, path]) => !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/.test(id)
35
33
  || typeof path !== 'string' || !isAbsolute(path) || path.includes('\0')))
36
- throw new Error('Role skills require host-owned absolute cache and profile paths');
34
+ throw new Error('Role skills require host-owned absolute profile paths');
37
35
  if (roles.presetRoles !== undefined && (!roles.presetRoles || typeof roles.presetRoles !== 'object' || Array.isArray(roles.presetRoles)
38
36
  || Object.entries(roles.presetRoles).some(([preset, roleId]) => !preset.trim() || preset.length > 256 || preset.includes('\0')
39
37
  || typeof roleId !== 'string' || !Object.hasOwn(roles.profiles, roleId))))
@@ -42,6 +40,27 @@ export function validateA2AExecutionOptions(options) {
42
40
  class RoleSkillLoadingError extends Error {
43
41
  constructor(cause) { super('Role skills could not be loaded or verified; the model was not started', { cause }); }
44
42
  }
43
+ const sessionFailureCodes = new Set(['SESSION_NOT_FOUND', 'SESSION_DELETED', 'SESSION_CLOSED', 'SESSION_CONFLICT', 'SESSION_ATTACH_IN_PROGRESS', 'MODEL_UNAVAILABLE', 'MODEL_SELECTION_UNSUPPORTED']);
44
+ function sessionFailureCode(error) {
45
+ const seen = new Set();
46
+ const queue = [error];
47
+ while (queue.length) {
48
+ const current = queue.shift();
49
+ if (!current || typeof current !== 'object' || seen.has(current))
50
+ continue;
51
+ seen.add(current);
52
+ const record = current;
53
+ if (typeof record.code === 'string' && sessionFailureCodes.has(record.code))
54
+ return record.code;
55
+ if (record.code === -32003 || record.message === 'Session was deleted')
56
+ return 'SESSION_DELETED';
57
+ if (typeof record.message === 'string' && /cwd conflicts|preset conflicts|identity conflicts/.test(record.message))
58
+ return 'SESSION_CONFLICT';
59
+ if (record.cause !== undefined)
60
+ queue.push(record.cause);
61
+ }
62
+ return undefined;
63
+ }
45
64
  async function waitForPreparation(previous, signal) {
46
65
  signal.throwIfAborted();
47
66
  let abort;
@@ -72,18 +91,19 @@ export function parseA2AInput(request, options) {
72
91
  throw new RequestMalformedError('metadata.1agents must be an object');
73
92
  const value = (metadata ?? {});
74
93
  for (const key of Object.keys(value))
75
- if (!['cwd', 'agentPreset', 'workspace', 'preflight', 'resultContract', 'roleId', 'roleLockPath'].includes(key))
94
+ if (!['cwd', 'agentPreset', 'workspace', 'preflight', 'resultContract', 'roleId', 'agentFile', 'provider', 'model', 'execution'].includes(key))
76
95
  throw new RequestMalformedError(`Unknown metadata.1agents field: ${key}`);
77
- for (const key of ['cwd', 'agentPreset', 'workspace', 'roleId', 'roleLockPath']) {
96
+ for (const key of ['cwd', 'agentPreset', 'workspace', 'roleId', 'agentFile', 'provider', 'model']) {
78
97
  if (value[key] !== undefined && (typeof value[key] !== 'string' || !value[key].trim()))
79
98
  throw new RequestMalformedError(`${key} must be a nonempty string`);
80
99
  }
100
+ if ((value.provider === undefined) !== (value.model === undefined))
101
+ throw new RequestMalformedError('provider and model must be passed together');
81
102
  if (value.roleId !== undefined && (!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/.test(value.roleId)
82
103
  || !options.roleSkills || !Object.hasOwn(options.roleSkills.profiles, value.roleId)))
83
104
  throw new RequestMalformedError('Unknown host role');
84
- if (value.roleLockPath !== undefined && (!options.roleSkills || !isAbsolute(value.roleLockPath)
85
- || value.roleLockPath.includes('\0')))
86
- throw new RequestMalformedError('Invalid role lock path');
105
+ if (value.agentFile !== undefined && (!isAbsolute(value.agentFile) || value.agentFile.includes('\0')))
106
+ throw new RequestMalformedError('agentFile must be an absolute path');
87
107
  if (value.cwd && value.workspace)
88
108
  throw new RequestMalformedError('Use cwd or workspace, not both');
89
109
  let cwd = value.cwd;
@@ -98,11 +118,30 @@ export function parseA2AInput(request, options) {
98
118
  const resultContract = value.resultContract === undefined ? undefined : a2aResultContractSchema.safeParse(value.resultContract);
99
119
  if (resultContract && !resultContract.success)
100
120
  throw new RequestMalformedError('Invalid result contract');
121
+ const execution = executionOf(value.execution);
101
122
  return { prompt, input: { cwd, agentPreset: value.agentPreset,
102
123
  ...(preflight?.success ? { preflight: preflight.data } : {}),
103
124
  ...(value.roleId ? { roleId: value.roleId } : {}),
104
- ...(value.roleLockPath ? { roleLockPath: value.roleLockPath } : {}) },
105
- ...(resultContract?.success ? { resultContract: resultContract.data } : {}) };
125
+ ...(value.agentFile ? { agentFile: value.agentFile } : {}),
126
+ ...(value.provider ? { provider: value.provider, model: value.model } : {}) },
127
+ ...(resultContract?.success ? { resultContract: resultContract.data } : {}),
128
+ ...(execution ? { execution } : {}) };
129
+ }
130
+ function executionOf(value) {
131
+ if (value === undefined)
132
+ return undefined;
133
+ if (!value || typeof value !== 'object' || Array.isArray(value))
134
+ throw new RequestMalformedError('execution must be an object');
135
+ const record = value;
136
+ for (const key of Object.keys(record))
137
+ if (key !== 'jobId' && key !== 'attemptId')
138
+ throw new RequestMalformedError(`Unknown metadata.1agents.execution field: ${key}`);
139
+ for (const key of ['jobId', 'attemptId']) {
140
+ const item = record[key];
141
+ if (typeof item !== 'string' || !item.trim() || item.length > 512 || item.includes('\0'))
142
+ throw new RequestMalformedError(`execution.${key} must be a nonempty string`);
143
+ }
144
+ return { jobId: record.jobId.trim(), attemptId: record.attemptId.trim() };
106
145
  }
107
146
  /** SDK owns the execution lifetime; an HTTP disconnect never aborts this signal. */
108
147
  export class A2ASessionExecutor {
@@ -131,52 +170,31 @@ export class A2ASessionExecutor {
131
170
  const preset = input.agentPreset ?? this.options.defaultAgentPreset, bindings = this.options.roleSkills?.presetRoles;
132
171
  return preset && bindings && Object.hasOwn(bindings, preset) ? bindings[preset] : undefined;
133
172
  }
134
- async roleFor(input, saved, contextKey, signal) {
173
+ async roleFor(input, saved) {
135
174
  const roleId = this.roleIdFor(input, saved);
136
- if (!roleId) {
137
- if (input.roleLockPath)
138
- throw new Error('A role lock requires a role identity');
175
+ if (!roleId)
139
176
  return undefined;
140
- }
141
177
  if (saved && (!saved.roleSkills || saved.roleId !== roleId))
142
178
  throw new Error('An existing context cannot change its role');
143
179
  const configuration = this.options.roleSkills;
144
180
  if (!configuration || !Object.hasOwn(configuration.profiles, roleId))
145
181
  throw new Error('The saved role is no longer configured on this host');
146
- await mkdir(join(configuration.cacheRoot, 'locks'), { recursive: true, mode: 0o700 });
147
- const lockRootInfo = await lstat(join(configuration.cacheRoot, 'locks'));
148
- if (!lockRootInfo.isDirectory() || lockRootInfo.isSymbolicLink())
149
- throw new Error('The host role locks directory must be a real directory');
150
- const lockRoot = await realpath(join(configuration.cacheRoot, 'locks'));
151
- const existingPath = saved?.roleSkills?.lockPath ?? input.roleLockPath;
152
- let lockPath;
153
- if (existingPath) {
154
- const info = await lstat(existingPath);
155
- const actual = await realpath(existingPath), tail = relative(lockRoot, actual);
156
- if (!info.isFile() || info.isSymbolicLink() || tail === '' || tail === '..' || tail.startsWith(`..${sep}`) || isAbsolute(tail))
157
- throw new Error('Role lock must be an existing regular file inside the host locks directory');
158
- // Preserve a saved summary byte-for-byte when a migrated cache retains
159
- // the old root as a compatible alias. Fresh contexts use canonical paths.
160
- lockPath = saved?.roleSkills?.lockPath ?? actual;
161
- if (saved?.roleSkills && input.roleLockPath && await realpath(input.roleLockPath) !== actual)
162
- throw new Error('An existing context cannot change its role lock');
163
- }
164
- else {
165
- lockPath = join(lockRoot, `a2a-${createHash('sha256').update(contextKey).digest('hex')}.json`);
166
- }
167
- const lock = await resolveRoleSkills({ profilePath: configuration.profiles[roleId], cacheRoot: configuration.cacheRoot, lockPath, signal });
168
- const summary = a2aRoleSkillsSchema.parse({ roleId: lock.roleId, roleVersion: lock.roleVersion, lockPath,
169
- roleDirectory: lock.roleDirectory, ...(lock.entryGuidePath ? { entryGuidePath: lock.entryGuidePath } : {}),
170
- skills: lock.skills.map(({ key, skillId, sourceId, name, revision, directory, guidePath }) => ({ key, skillId, sourceId, name, revision, directory, guidePath })) });
171
- if (saved?.roleSkills && JSON.stringify(saved.roleSkills) !== JSON.stringify(summary))
172
- throw new Error('Saved role skill identity differs from its verified lock');
173
- const instructions = lock.instructionsPath ? await readFile(lock.instructionsPath, 'utf8') : '';
174
- if (Buffer.byteLength(instructions) > 65536)
182
+ const cwd = input.cwd ?? saved?.cwd ?? this.options.defaultCwd;
183
+ if (!cwd)
184
+ throw new Error('A role needs a working directory that holds its skills');
185
+ // Skills are read from the working directory as they are; a continuation sees the current files, not a pinned copy.
186
+ const loaded = await loadRoleSkills({ profilePath: configuration.profiles[roleId], cwd });
187
+ const summary = { roleId: loaded.roleId, roleVersion: loaded.roleVersion, roleDirectory: loaded.roleDirectory,
188
+ ...(loaded.entryGuidePath ? { entryGuidePath: loaded.entryGuidePath } : {}),
189
+ skills: loaded.skills.map(({ key, name, directory, guidePath }) => ({ key, name, directory, guidePath })) };
190
+ if (Buffer.byteLength(loaded.instructions) > 65536)
175
191
  throw new Error('Role instructions exceed the host prompt budget');
176
- const guides = summary.skills.map(skill => `- ${skill.key}: ${skill.guidePath} (revision=${skill.revision})`).join('\n');
177
- return { roleId, summary, promptPrefix: `宿主已加载角色 ${roleId},本任务技能锁:${lockPath}。仅使用此锁及下列缓存技能,不重新检索或切换版本;续派和恢复沿用同一锁。先读取适用指南及其配套资源。\n${guides}\n${instructions}\n\n上游任务:\n` };
192
+ const guides = summary.skills.map(skill => `- ${skill.key}: ${skill.guidePath}`).join('\n');
193
+ return { roleId, summary, promptPrefix: `宿主已加载角色 ${roleId}。本会话工作目录 ${cwd} 的 .agents/skills 提供下列技能,先读取适用指南及其配套资源;不要重新检索或安装技能。\n${guides}\n${loaded.instructions}\n\n上游任务:\n` };
178
194
  }
179
195
  isRunning(taskId) { return this.active.has(taskId); }
196
+ /** A person took the session over: the pending question is no longer answered through A2A. */
197
+ releaseInput(taskId) { this.awaitingInput.delete(taskId); }
180
198
  async execute(context, bus) {
181
199
  if (this.stopped)
182
200
  throw new UnsupportedOperationError('A2A host is stopping');
@@ -199,12 +217,14 @@ export class A2ASessionExecutor {
199
217
  // DSH deduplicates prompts by rpcId across the whole session. A Task can
200
218
  // have several input-required turns, each with its own message identity.
201
219
  const requestId = a2aRequestId(context.taskId, context.userMessage.messageId);
202
- const status = (state, text, error) => {
220
+ const status = (state, text, error, capacity, slots) => {
203
221
  bus.publish(AgentEvent.statusUpdate({ taskId: context.taskId, contextId: context.contextId,
204
222
  status: { state, timestamp: new Date().toISOString(), message: text ? Message.fromJSON({
205
223
  messageId: randomUUID(), role: 'ROLE_AGENT', contextId: context.contextId, taskId: context.taskId, parts: [{ text }],
206
- }) : undefined }, metadata: target || error || resultMetadata ? { '1agents': {
224
+ }) : undefined }, metadata: target || error || resultMetadata || capacity || slots ? { '1agents': {
207
225
  ...target, ...(resultMetadata ? { result: resultMetadata } : {}), ...(error ? { error } : {}),
226
+ ...(capacity ? { capacity } : {}),
227
+ ...(slots ? { taskSlot: slots.taskSlot, processSlot: slots.processSlot } : {}),
208
228
  } } : undefined }));
209
229
  };
210
230
  const submitted = (text) => {
@@ -244,7 +264,9 @@ export class A2ASessionExecutor {
244
264
  }
245
265
  }
246
266
  signal.throwIfAborted();
247
- status(TaskState.TASK_STATE_WORKING);
267
+ // ACP process admission is still ahead of this call. Stay submitted until the slot is held.
268
+ if (!target?.agentPreset?.startsWith('oneagents-acp-'))
269
+ status(TaskState.TASK_STATE_WORKING);
248
270
  };
249
271
  try {
250
272
  const parsed = parseA2AInput(context.request, this.options);
@@ -273,31 +295,56 @@ export class A2ASessionExecutor {
273
295
  await waitForPreparation(previous, controller.signal);
274
296
  controller.signal.throwIfAborted();
275
297
  const saved = this.store.loadTarget(context.contextId, context.context);
298
+ if (saved?.state === 'deleted')
299
+ throw Object.assign(new Error('Session was deleted'), { code: 'SESSION_DELETED' });
276
300
  if (saved?.roleSkills)
277
301
  submitted();
278
302
  let role;
279
303
  try {
280
- role = await this.roleFor(input, saved, key, controller.signal);
304
+ role = await this.roleFor(input, saved);
281
305
  }
282
306
  catch (error) {
283
307
  throw new RoleSkillLoadingError(error);
284
308
  }
285
309
  controller.signal.throwIfAborted();
310
+ const agentPreset = input.agentPreset ?? saved?.agentPreset ?? this.options.defaultAgentPreset;
311
+ // ACP Agents publish their own model options through session/set_config_option.
312
+ if (input.provider && agentPreset?.startsWith('oneagents-acp-'))
313
+ throw Object.assign(new Error('provider and model apply only to standard presets'), { code: 'MODEL_SELECTION_UNSUPPORTED' });
286
314
  // ACP session preparation can itself wait in the process FIFO.
287
- if ((input.agentPreset ?? saved?.agentPreset ?? this.options.defaultAgentPreset)?.startsWith('oneagents-acp-'))
315
+ if (agentPreset?.startsWith('oneagents-acp-'))
288
316
  pendingCapacity();
289
317
  // Acquire only after context/role waits, immediately before session creation.
290
318
  capacityLease = await acquireCapacity();
291
319
  controller.signal.throwIfAborted();
292
320
  target = await this.backend.prepare({ sessionId: saved?.sessionId,
293
321
  cwd: input.cwd ?? saved?.cwd ?? this.options.defaultCwd,
294
- agentPreset: input.agentPreset ?? saved?.agentPreset ?? this.options.defaultAgentPreset,
295
- ...(input.preflight ? { preflight: input.preflight } : {}) }, { signal: controller.signal });
322
+ agentPreset,
323
+ ...(input.preflight ? { preflight: input.preflight } : {}),
324
+ ...(input.provider ? { provider: input.provider, model: input.model } : {}) }, { signal: controller.signal });
325
+ if (input.provider && !target.provider)
326
+ throw Object.assign(new Error('The host did not apply the requested model'), { code: 'MODEL_UNAVAILABLE' });
327
+ // The DSH session keeps its earlier selection; report it until a new value is passed.
328
+ if (!target.provider && saved?.provider) {
329
+ target.provider = saved.provider;
330
+ target.model = saved.model;
331
+ }
296
332
  if (role) {
297
333
  target.roleId = role.roleId;
298
334
  target.roleSkills = role.summary;
299
335
  promptPrefix = role.promptPrefix;
300
336
  }
337
+ // A path agent's role is read on this host, inside the session's real cwd. A continuation already carries it in its history.
338
+ if (input.agentFile && !saved?.sessionId) {
339
+ let agent;
340
+ try {
341
+ agent = await readAgentFile(input.agentFile, target.cwd ?? '');
342
+ }
343
+ catch (error) {
344
+ throw Object.assign(new Error(`Cannot load path agent: ${error instanceof Error ? error.message : String(error)}`), { code: 'AGENT_FILE_INVALID' });
345
+ }
346
+ promptPrefix += agentPromptPrefix(agent);
347
+ }
301
348
  this.store.saveTarget(context.contextId, target, context.context);
302
349
  }
303
350
  finally {
@@ -308,7 +355,27 @@ export class A2ASessionExecutor {
308
355
  // Preparation can include I/O or a cold ACP handshake. Never start the
309
356
  // model using a memory observation taken before that work.
310
357
  await beforeStart();
311
- const result = await this.backend.run(target, promptPrefix + prompt, { requestId, signal: controller.signal, beforeStart });
358
+ const onCapacity = (pending) => {
359
+ if (!target?.agentPreset?.startsWith('oneagents-acp-'))
360
+ return;
361
+ void this.capacity.slotView().then(slots => {
362
+ if (pending) {
363
+ submitted();
364
+ status(TaskState.TASK_STATE_SUBMITTED, 'CAPACITY_PENDING', undefined, pending, slots);
365
+ }
366
+ else
367
+ status(TaskState.TASK_STATE_WORKING, undefined, undefined, undefined, slots);
368
+ }).catch(() => {
369
+ if (pending) {
370
+ submitted();
371
+ status(TaskState.TASK_STATE_SUBMITTED, 'CAPACITY_PENDING', undefined, pending);
372
+ }
373
+ else
374
+ status(TaskState.TASK_STATE_WORKING);
375
+ });
376
+ };
377
+ const result = await this.backend.run(target, promptPrefix + prompt, { requestId, signal: controller.signal, beforeStart, onCapacity,
378
+ ...(parsed.execution ? { execution: parsed.execution } : {}) });
312
379
  returnedError = result.outcome === 'failed' && result.error !== undefined
313
380
  ? toSafeError(result.error, { origin: 'a2a', operationId: requestId }) : undefined;
314
381
  returnedFailureMessage = result.outcome === 'failed' && typeof result.failureReason === 'string' && Object.hasOwn(FAILURE_MESSAGES, result.failureReason)
@@ -353,7 +420,7 @@ export class A2ASessionExecutor {
353
420
  });
354
421
  resultMetadata = await createA2AResultMetadata({ taskId: context.taskId, contextId: context.contextId,
355
422
  requestId, startedAt, outcome: controller.signal.aborted ? 'canceled' : 'failed', target, contract: resultContract,
356
- validationCode: capacityFailure?.code ?? (error instanceof A2AResultValidationError ? error.code : error instanceof RoleSkillLoadingError ? 'role-skills-unavailable' : undefined),
423
+ validationCode: capacityFailure?.code ?? sessionFailureCode(error) ?? (error instanceof A2AResultValidationError ? error.code : error instanceof RoleSkillLoadingError ? 'role-skills-unavailable' : undefined),
357
424
  ...(error instanceof A2APreflightError ? { preflight: error.report } : {}) });
358
425
  try {
359
426
  await saveA2AResultMetadata(resultMetadata, target);