@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,151 @@
1
+ import { z } from 'zod';
2
+ export declare const processQuestionSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ question: z.ZodPipe<z.ZodString, z.ZodString>;
5
+ header: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
6
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
7
+ label: z.ZodPipe<z.ZodString, z.ZodString>;
8
+ description: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
9
+ }, z.core.$strict>>>;
10
+ multiSelect: z.ZodOptional<z.ZodBoolean>;
11
+ }, z.core.$strict>;
12
+ export type ProcessQuestion = z.infer<typeof processQuestionSchema>;
13
+ export declare const processRequestAnswerSchema: z.ZodObject<{
14
+ clientRequestId: z.ZodString;
15
+ outcome: z.ZodEnum<{
16
+ cancelled: "cancelled";
17
+ abandoned: "abandoned";
18
+ accepted: "accepted";
19
+ rejected: "rejected";
20
+ approved: "approved";
21
+ }>;
22
+ answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
23
+ note: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
24
+ decidedBy: z.ZodOptional<z.ZodObject<{
25
+ kind: z.ZodEnum<{
26
+ person: "person";
27
+ coach: "coach";
28
+ }>;
29
+ agent: z.ZodOptional<z.ZodString>;
30
+ sessionId: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strict>>;
32
+ stopTask: z.ZodOptional<z.ZodLiteral<true>>;
33
+ }, z.core.$strict>;
34
+ export type ProcessRequestAnswerInput = z.infer<typeof processRequestAnswerSchema>;
35
+ type ProcessKind = 'question' | 'plan' | 'permission';
36
+ export declare const processRequestCreateSchema: z.ZodObject<{
37
+ requestId: z.ZodOptional<z.ZodString>;
38
+ jobId: z.ZodString;
39
+ attemptId: z.ZodString;
40
+ sessionId: z.ZodString;
41
+ kind: z.ZodEnum<{
42
+ plan: "plan";
43
+ permission: "permission";
44
+ question: "question";
45
+ }>;
46
+ questions: z.ZodOptional<z.ZodArray<z.ZodObject<{
47
+ id: z.ZodString;
48
+ question: z.ZodPipe<z.ZodString, z.ZodString>;
49
+ header: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
50
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
51
+ label: z.ZodPipe<z.ZodString, z.ZodString>;
52
+ description: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
53
+ }, z.core.$strict>>>;
54
+ multiSelect: z.ZodOptional<z.ZodBoolean>;
55
+ }, z.core.$strict>>>;
56
+ planContent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
57
+ toolTitle: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
58
+ toolDetail: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strict>;
60
+ export type ProcessRequestCreateInput = z.infer<typeof processRequestCreateSchema>;
61
+ export declare const PROCESS_REQUEST_TTL_MS: number;
62
+ export type ProcessRequestStatus = 'pending' | 'answered' | 'cancelled' | 'expired';
63
+ export interface ProcessRequestAnswer extends ProcessRequestAnswerInput {
64
+ at: string;
65
+ }
66
+ export interface ProcessRequest {
67
+ requestId: string;
68
+ jobId: string;
69
+ attemptId: string;
70
+ sessionId: string;
71
+ kind: ProcessKind;
72
+ questions?: ProcessQuestion[];
73
+ planContent?: string;
74
+ toolTitle?: string;
75
+ toolDetail?: string;
76
+ status: ProcessRequestStatus;
77
+ createdAt: string;
78
+ deadlineAt: string;
79
+ updatedAt: string;
80
+ answer?: ProcessRequestAnswer;
81
+ }
82
+ export declare const processRequestSchema: z.ZodObject<{
83
+ requestId: z.ZodString;
84
+ jobId: z.ZodString;
85
+ attemptId: z.ZodString;
86
+ sessionId: z.ZodString;
87
+ kind: z.ZodEnum<{
88
+ plan: "plan";
89
+ permission: "permission";
90
+ question: "question";
91
+ }>;
92
+ questions: z.ZodOptional<z.ZodArray<z.ZodObject<{
93
+ id: z.ZodString;
94
+ question: z.ZodPipe<z.ZodString, z.ZodString>;
95
+ header: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
96
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
97
+ label: z.ZodPipe<z.ZodString, z.ZodString>;
98
+ description: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
99
+ }, z.core.$strict>>>;
100
+ multiSelect: z.ZodOptional<z.ZodBoolean>;
101
+ }, z.core.$strict>>>;
102
+ planContent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
103
+ toolTitle: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
104
+ toolDetail: z.ZodOptional<z.ZodString>;
105
+ status: z.ZodEnum<{
106
+ pending: "pending";
107
+ cancelled: "cancelled";
108
+ answered: "answered";
109
+ expired: "expired";
110
+ }>;
111
+ createdAt: z.ZodString;
112
+ deadlineAt: z.ZodString;
113
+ updatedAt: z.ZodString;
114
+ answer: z.ZodOptional<z.ZodObject<{
115
+ clientRequestId: z.ZodString;
116
+ outcome: z.ZodEnum<{
117
+ cancelled: "cancelled";
118
+ abandoned: "abandoned";
119
+ accepted: "accepted";
120
+ rejected: "rejected";
121
+ approved: "approved";
122
+ }>;
123
+ answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
124
+ note: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
125
+ decidedBy: z.ZodOptional<z.ZodObject<{
126
+ kind: z.ZodEnum<{
127
+ person: "person";
128
+ coach: "coach";
129
+ }>;
130
+ agent: z.ZodOptional<z.ZodString>;
131
+ sessionId: z.ZodOptional<z.ZodString>;
132
+ }, z.core.$strict>>;
133
+ stopTask: z.ZodOptional<z.ZodLiteral<true>>;
134
+ at: z.ZodString;
135
+ }, z.core.$strict>>;
136
+ }, z.core.$strict>;
137
+ export declare class ProcessRequestError extends Error {
138
+ readonly code: 'forbidden' | 'expired' | 'already_decided' | 'idempotency_conflict' | 'not_found' | 'invalid';
139
+ constructor(code: 'forbidden' | 'expired' | 'already_decided' | 'idempotency_conflict' | 'not_found' | 'invalid', message: string);
140
+ }
141
+ export declare function sameProcessRequest(record: ProcessRequest, input: ProcessRequestCreateInput): boolean;
142
+ export declare function createProcessRequest(input: ProcessRequestCreateInput, at?: Date, ttlMs?: number): ProcessRequest;
143
+ /** A repeated clientRequestId returns the recorded answer. A late answer does not change an expired request. */
144
+ export declare function answerProcessRequest(request: ProcessRequest, input: ProcessRequestAnswerInput, at?: Date): {
145
+ request: ProcessRequest;
146
+ idempotent: boolean;
147
+ };
148
+ export declare function expireProcessRequest(request: ProcessRequest, at?: Date): ProcessRequest;
149
+ /** Reading a pending request past its deadline shows expired and does not change the stored record. */
150
+ export declare function projectProcessRequest(request: ProcessRequest, now?: number): ProcessRequest;
151
+ export {};
@@ -0,0 +1,177 @@
1
+ /** Live ACP questions, plan approvals and tool permissions. Callers persist each returned value before the waiting call resumes. */
2
+ import { randomUUID } from 'node:crypto';
3
+ import { z } from 'zod';
4
+ const id = z.string().trim().min(1).max(512);
5
+ const control = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
6
+ const plain = (max) => z.string().max(max).refine(value => !control.test(value), 'Control characters are not allowed');
7
+ const optionSchema = z.object({
8
+ label: plain(500).pipe(z.string().trim().min(1)),
9
+ description: plain(2000).pipe(z.string().trim().min(1)).optional(),
10
+ }).strict();
11
+ export const processQuestionSchema = z.object({
12
+ id: z.string().trim().min(1).max(64),
13
+ question: plain(4000).pipe(z.string().trim().min(1)),
14
+ header: plain(200).pipe(z.string().trim().min(1)).optional(),
15
+ options: z.array(optionSchema).max(20).optional(),
16
+ multiSelect: z.boolean().optional(),
17
+ }).strict();
18
+ const answerValue = z.union([plain(8000), z.array(plain(8000)).max(20)]);
19
+ export const processRequestAnswerSchema = z.object({
20
+ clientRequestId: id,
21
+ outcome: z.enum(['accepted', 'cancelled', 'approved', 'rejected', 'abandoned']),
22
+ answers: z.record(z.string().trim().min(1).max(4000), answerValue).optional(),
23
+ /** Why it was decided so: a person's reason for a rejection, or the coach's for either. Shown on the page and, when the task is stopped, in the notice to the origin session. */
24
+ note: plain(2000).pipe(z.string().trim().min(1)).optional(),
25
+ /** Who decided. The page answers as a person; the coach answers through the gateway and names its agent session. */
26
+ decidedBy: z.object({ kind: z.enum(['person', 'coach']), agent: id.optional(), sessionId: id.optional() }).strict()
27
+ .refine(by => by.kind === 'coach' || (!by.agent && !by.sessionId), 'Only a coach names an agent session').optional(),
28
+ /** Reject and cancel the task, so the agent cannot retry the tool another way. */
29
+ stopTask: z.literal(true).optional(),
30
+ }).strict();
31
+ const processKind = z.enum(['question', 'plan', 'permission']);
32
+ /** The tool name and the arguments a person approves. Tool output never enters the record. */
33
+ const toolTitle = plain(500).pipe(z.string().trim().min(1));
34
+ const toolDetail = plain(16 * 1024);
35
+ function assertBody(input, ctx) {
36
+ if (input.kind === 'question' && !input.questions?.length)
37
+ ctx.addIssue({ code: 'custom', path: ['questions'], message: 'A question request needs questions' });
38
+ if (input.kind === 'plan' && !input.planContent)
39
+ ctx.addIssue({ code: 'custom', path: ['planContent'], message: 'A plan request needs plan text' });
40
+ if (input.kind === 'permission' && !input.toolTitle)
41
+ ctx.addIssue({ code: 'custom', path: ['toolTitle'], message: 'A permission request needs the tool title' });
42
+ if (input.kind !== 'plan' && input.planContent)
43
+ ctx.addIssue({ code: 'custom', path: ['planContent'], message: 'Only a plan request has plan text' });
44
+ if (input.kind !== 'question' && input.questions)
45
+ ctx.addIssue({ code: 'custom', path: ['questions'], message: 'Only a question request has questions' });
46
+ if (input.kind !== 'permission' && (input.toolTitle || input.toolDetail))
47
+ ctx.addIssue({ code: 'custom', path: ['toolTitle'], message: 'Only a permission request names a tool' });
48
+ }
49
+ export const processRequestCreateSchema = z.object({
50
+ requestId: id.optional(),
51
+ jobId: id,
52
+ attemptId: id,
53
+ sessionId: id,
54
+ kind: processKind,
55
+ questions: z.array(processQuestionSchema).min(1).max(20).optional(),
56
+ planContent: plain(64 * 1024).pipe(z.string().trim().min(1)).optional(),
57
+ toolTitle: toolTitle.optional(),
58
+ toolDetail: toolDetail.optional(),
59
+ }).strict().superRefine(assertBody);
60
+ export const PROCESS_REQUEST_TTL_MS = 5 * 60 * 1000;
61
+ export const processRequestSchema = z.object({
62
+ requestId: id,
63
+ jobId: id,
64
+ attemptId: id,
65
+ sessionId: id,
66
+ kind: processKind,
67
+ questions: z.array(processQuestionSchema).min(1).max(20).optional(),
68
+ planContent: plain(64 * 1024).pipe(z.string().trim().min(1)).optional(),
69
+ toolTitle: toolTitle.optional(),
70
+ toolDetail: toolDetail.optional(),
71
+ status: z.enum(['pending', 'answered', 'cancelled', 'expired']),
72
+ createdAt: z.string().datetime(),
73
+ deadlineAt: z.string().datetime(),
74
+ updatedAt: z.string().datetime(),
75
+ answer: processRequestAnswerSchema.extend({ at: z.string().datetime() }).optional(),
76
+ }).strict().superRefine(assertBody);
77
+ export class ProcessRequestError extends Error {
78
+ code;
79
+ constructor(code, message) {
80
+ super(message);
81
+ this.code = code;
82
+ }
83
+ }
84
+ function stable(value) {
85
+ if (Array.isArray(value))
86
+ return `[${value.map(stable).join(',')}]`;
87
+ if (value && typeof value === 'object') {
88
+ const record = value;
89
+ return `{${Object.keys(record).sort().map(key => `${JSON.stringify(key)}:${stable(record[key])}`).join(',')}}`;
90
+ }
91
+ return JSON.stringify(value) ?? 'null';
92
+ }
93
+ export function sameProcessRequest(record, input) {
94
+ return record.jobId === input.jobId && record.attemptId === input.attemptId && record.sessionId === input.sessionId
95
+ && record.kind === input.kind && stable(record.questions ?? null) === stable(input.questions ?? null)
96
+ && (record.planContent ?? '') === (input.planContent ?? '')
97
+ && (record.toolTitle ?? '') === (input.toolTitle ?? '') && (record.toolDetail ?? '') === (input.toolDetail ?? '');
98
+ }
99
+ export function createProcessRequest(input, at = new Date(), ttlMs = PROCESS_REQUEST_TTL_MS) {
100
+ const parsed = processRequestCreateSchema.parse(input);
101
+ const createdAt = at.toISOString();
102
+ return {
103
+ requestId: parsed.requestId ?? randomUUID(), jobId: parsed.jobId, attemptId: parsed.attemptId, sessionId: parsed.sessionId, kind: parsed.kind,
104
+ ...(parsed.questions ? { questions: parsed.questions } : {}), ...(parsed.planContent ? { planContent: parsed.planContent } : {}),
105
+ ...(parsed.toolTitle ? { toolTitle: parsed.toolTitle } : {}), ...(parsed.toolDetail ? { toolDetail: parsed.toolDetail } : {}),
106
+ status: 'pending', createdAt, updatedAt: createdAt, deadlineAt: new Date(at.getTime() + ttlMs).toISOString(),
107
+ };
108
+ }
109
+ function assertAnswer(request, input) {
110
+ if (input.stopTask && input.outcome !== 'rejected')
111
+ throw new ProcessRequestError('invalid', 'Only a rejection stops the task');
112
+ if (input.note && input.outcome !== 'rejected' && input.decidedBy?.kind !== 'coach')
113
+ throw new ProcessRequestError('invalid', 'Only a rejection, or the coach, gives a reason');
114
+ if (request.kind === 'question') {
115
+ if (input.outcome !== 'accepted' && input.outcome !== 'cancelled')
116
+ throw new ProcessRequestError('invalid', 'Question answers must be accepted or cancelled');
117
+ if (input.outcome === 'cancelled' && input.answers && Object.keys(input.answers).length)
118
+ throw new ProcessRequestError('invalid', 'A cancelled question has no answers');
119
+ if (input.outcome === 'accepted') {
120
+ const expected = request.questions?.map(question => question.question) ?? [];
121
+ const answers = input.answers ?? {};
122
+ if (expected.length !== Object.keys(answers).length || expected.some(question => !Object.hasOwn(answers, question))) {
123
+ throw new ProcessRequestError('invalid', 'Answers must address the recorded questions');
124
+ }
125
+ }
126
+ return;
127
+ }
128
+ if (request.kind === 'permission') {
129
+ if (!['approved', 'rejected', 'cancelled'].includes(input.outcome))
130
+ throw new ProcessRequestError('invalid', 'Permission answers must be approved, rejected, or cancelled');
131
+ if (input.answers)
132
+ throw new ProcessRequestError('invalid', 'A permission answer has no question answers');
133
+ return;
134
+ }
135
+ if (!['approved', 'rejected', 'abandoned'].includes(input.outcome))
136
+ throw new ProcessRequestError('invalid', 'Plan answers must be approved, rejected, or abandoned');
137
+ if (input.answers)
138
+ throw new ProcessRequestError('invalid', 'A plan answer has no question answers');
139
+ }
140
+ /** A repeated clientRequestId returns the recorded answer. A late answer does not change an expired request. */
141
+ export function answerProcessRequest(request, input, at = new Date()) {
142
+ const parsed = processRequestAnswerSchema.parse(input);
143
+ assertAnswer(request, parsed);
144
+ if (request.answer?.clientRequestId === parsed.clientRequestId) {
145
+ if (request.answer.outcome !== parsed.outcome || stable(request.answer.answers ?? null) !== stable(parsed.answers ?? null)
146
+ || (request.answer.note ?? '') !== (parsed.note ?? '') || Boolean(request.answer.stopTask) !== Boolean(parsed.stopTask)) {
147
+ throw new ProcessRequestError('idempotency_conflict', 'clientRequestId conflicts with a recorded answer');
148
+ }
149
+ return { request: structuredClone(request), idempotent: true };
150
+ }
151
+ if (request.status === 'expired')
152
+ throw new ProcessRequestError('expired', 'This process request has expired');
153
+ if (request.answer || request.status !== 'pending')
154
+ throw new ProcessRequestError('already_decided', 'This process request is no longer pending');
155
+ if (Date.parse(request.deadlineAt) <= at.getTime())
156
+ throw new ProcessRequestError('expired', 'This process request has expired');
157
+ const next = structuredClone(request);
158
+ next.status = parsed.outcome === 'cancelled' || parsed.outcome === 'abandoned' ? 'cancelled' : 'answered';
159
+ next.answer = { ...parsed, at: at.toISOString() };
160
+ next.updatedAt = next.answer.at;
161
+ return { request: next, idempotent: false };
162
+ }
163
+ export function expireProcessRequest(request, at = new Date()) {
164
+ const next = structuredClone(request);
165
+ if (next.status === 'pending') {
166
+ next.status = 'expired';
167
+ next.updatedAt = at.toISOString();
168
+ }
169
+ return next;
170
+ }
171
+ /** Reading a pending request past its deadline shows expired and does not change the stored record. */
172
+ export function projectProcessRequest(request, now = Date.now()) {
173
+ const next = structuredClone(request);
174
+ if (next.status === 'pending' && Date.parse(next.deadlineAt) <= now)
175
+ next.status = 'expired';
176
+ return next;
177
+ }
@@ -38,12 +38,15 @@ export declare const executionTargetBindingSchema: z.ZodObject<{
38
38
  agentPreset: z.ZodOptional<z.ZodString>;
39
39
  roleId: z.ZodOptional<z.ZodString>;
40
40
  skillRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
41
- skillPolicy: z.ZodOptional<z.ZodLiteral<"network_pinned">>;
41
+ loadRole: z.ZodOptional<z.ZodLiteral<true>>;
42
42
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
43
43
  allowedPresets: z.ZodOptional<z.ZodArray<z.ZodString>>;
44
44
  flowId: z.ZodOptional<z.ZodString>;
45
45
  flowVersion: z.ZodOptional<z.ZodString>;
46
46
  driver: z.ZodOptional<z.ZodLiteral<"ppt_delivery">>;
47
+ agentFile: z.ZodOptional<z.ZodString>;
48
+ provider: z.ZodOptional<z.ZodString>;
49
+ model: z.ZodOptional<z.ZodString>;
47
50
  }, z.core.$strict>;
48
51
  export declare const executionTargetConfigSchema: z.ZodObject<{
49
52
  targetId: z.ZodString;
@@ -70,12 +73,15 @@ export declare const executionTargetConfigSchema: z.ZodObject<{
70
73
  agentPreset: z.ZodOptional<z.ZodString>;
71
74
  roleId: z.ZodOptional<z.ZodString>;
72
75
  skillRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
- skillPolicy: z.ZodOptional<z.ZodLiteral<"network_pinned">>;
76
+ loadRole: z.ZodOptional<z.ZodLiteral<true>>;
74
77
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
75
78
  allowedPresets: z.ZodOptional<z.ZodArray<z.ZodString>>;
76
79
  flowId: z.ZodOptional<z.ZodString>;
77
80
  flowVersion: z.ZodOptional<z.ZodString>;
78
81
  driver: z.ZodOptional<z.ZodLiteral<"ppt_delivery">>;
82
+ agentFile: z.ZodOptional<z.ZodString>;
83
+ provider: z.ZodOptional<z.ZodString>;
84
+ model: z.ZodOptional<z.ZodString>;
79
85
  }, z.core.$strict>>;
80
86
  }, z.core.$strict>;
81
87
  export declare const executionTargetSchema: z.ZodObject<{
@@ -103,12 +109,15 @@ export declare const executionTargetSchema: z.ZodObject<{
103
109
  agentPreset: z.ZodOptional<z.ZodString>;
104
110
  roleId: z.ZodOptional<z.ZodString>;
105
111
  skillRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
106
- skillPolicy: z.ZodOptional<z.ZodLiteral<"network_pinned">>;
112
+ loadRole: z.ZodOptional<z.ZodLiteral<true>>;
107
113
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
108
114
  allowedPresets: z.ZodOptional<z.ZodArray<z.ZodString>>;
109
115
  flowId: z.ZodOptional<z.ZodString>;
110
116
  flowVersion: z.ZodOptional<z.ZodString>;
111
117
  driver: z.ZodOptional<z.ZodLiteral<"ppt_delivery">>;
118
+ agentFile: z.ZodOptional<z.ZodString>;
119
+ provider: z.ZodOptional<z.ZodString>;
120
+ model: z.ZodOptional<z.ZodString>;
112
121
  }, z.core.$strict>>;
113
122
  configVersion: z.ZodNumber;
114
123
  createdAt: z.ZodString;
@@ -147,6 +156,8 @@ export declare const targetHealthSchema: z.ZodObject<{
147
156
  }>>;
148
157
  }, z.core.$strict>;
149
158
  export type TargetHealth = z.output<typeof targetHealthSchema>;
159
+ /** The preset a fixed role runs on when its binding names none. */
160
+ export declare const DEFAULT_RESIDENT_PRESET = "standard";
150
161
  export declare const TARGET_METHODS: {
151
162
  execution_connection_list: {
152
163
  description: string;
@@ -239,12 +250,15 @@ export declare const TARGET_METHODS: {
239
250
  agentPreset: z.ZodOptional<z.ZodString>;
240
251
  roleId: z.ZodOptional<z.ZodString>;
241
252
  skillRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
242
- skillPolicy: z.ZodOptional<z.ZodLiteral<"network_pinned">>;
253
+ loadRole: z.ZodOptional<z.ZodLiteral<true>>;
243
254
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
244
255
  allowedPresets: z.ZodOptional<z.ZodArray<z.ZodString>>;
245
256
  flowId: z.ZodOptional<z.ZodString>;
246
257
  flowVersion: z.ZodOptional<z.ZodString>;
247
258
  driver: z.ZodOptional<z.ZodLiteral<"ppt_delivery">>;
259
+ agentFile: z.ZodOptional<z.ZodString>;
260
+ provider: z.ZodOptional<z.ZodString>;
261
+ model: z.ZodOptional<z.ZodString>;
248
262
  }, z.core.$strict>>;
249
263
  }, z.core.$strict>>;
250
264
  };
@@ -277,12 +291,15 @@ export declare const TARGET_METHODS: {
277
291
  agentPreset: z.ZodOptional<z.ZodString>;
278
292
  roleId: z.ZodOptional<z.ZodString>;
279
293
  skillRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
280
- skillPolicy: z.ZodOptional<z.ZodLiteral<"network_pinned">>;
294
+ loadRole: z.ZodOptional<z.ZodLiteral<true>>;
281
295
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
282
296
  allowedPresets: z.ZodOptional<z.ZodArray<z.ZodString>>;
283
297
  flowId: z.ZodOptional<z.ZodString>;
284
298
  flowVersion: z.ZodOptional<z.ZodString>;
285
299
  driver: z.ZodOptional<z.ZodLiteral<"ppt_delivery">>;
300
+ agentFile: z.ZodOptional<z.ZodString>;
301
+ provider: z.ZodOptional<z.ZodString>;
302
+ model: z.ZodOptional<z.ZodString>;
286
303
  }, z.core.$strict>>;
287
304
  }, z.core.$strict>;
288
305
  }, z.core.$strict>>;
@@ -294,6 +311,48 @@ export declare const TARGET_METHODS: {
294
311
  expectedConfigVersion: z.ZodOptional<z.ZodNumber>;
295
312
  }, z.core.$strict>>;
296
313
  };
314
+ execution_target_fork: {
315
+ description: string;
316
+ parameters: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
317
+ targetId: z.ZodString;
318
+ newTargetId: z.ZodString;
319
+ patch: z.ZodOptional<z.ZodObject<{
320
+ kind: z.ZodOptional<z.ZodEnum<{
321
+ agent_host: "agent_host";
322
+ resident_agent: "resident_agent";
323
+ workflow: "workflow";
324
+ }>>;
325
+ name: z.ZodOptional<z.ZodString>;
326
+ description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
327
+ connectionId: z.ZodOptional<z.ZodString>;
328
+ inputSchema: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
329
+ outputSchema: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
330
+ capabilities: z.ZodOptional<z.ZodOptional<z.ZodObject<{
331
+ query: z.ZodDefault<z.ZodBoolean>;
332
+ cancel: z.ZodDefault<z.ZodBoolean>;
333
+ continue: z.ZodDefault<z.ZodBoolean>;
334
+ reconcile: z.ZodDefault<z.ZodBoolean>;
335
+ }, z.core.$strict>>>;
336
+ enabled: z.ZodOptional<z.ZodBoolean>;
337
+ binding: z.ZodOptional<z.ZodObject<{
338
+ remote: z.ZodOptional<z.ZodOptional<z.ZodString>>;
339
+ cwd: z.ZodOptional<z.ZodOptional<z.ZodString>>;
340
+ agentPreset: z.ZodOptional<z.ZodOptional<z.ZodString>>;
341
+ roleId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
342
+ skillRefs: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
343
+ loadRole: z.ZodOptional<z.ZodOptional<z.ZodLiteral<true>>>;
344
+ allowedDirectories: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
345
+ allowedPresets: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
346
+ flowId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
347
+ flowVersion: z.ZodOptional<z.ZodOptional<z.ZodString>>;
348
+ driver: z.ZodOptional<z.ZodOptional<z.ZodLiteral<"ppt_delivery">>>;
349
+ agentFile: z.ZodOptional<z.ZodOptional<z.ZodString>>;
350
+ provider: z.ZodOptional<z.ZodOptional<z.ZodString>>;
351
+ model: z.ZodOptional<z.ZodOptional<z.ZodString>>;
352
+ }, z.core.$strict>>;
353
+ }, z.core.$strict>>;
354
+ }, z.core.$strict>>;
355
+ };
297
356
  execution_target_probe: {
298
357
  description: string;
299
358
  parameters: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
@@ -26,10 +26,15 @@ export const executionConnectionSchema = executionConnectionConfigSchema.extend(
26
26
  export const executionTargetBindingSchema = z.object({
27
27
  remote: id.optional(), cwd: absolutePath.optional(), agentPreset: id.optional(),
28
28
  roleId: id.optional(), skillRefs: z.array(text).max(100).optional(),
29
- skillPolicy: z.literal('network_pinned').optional(),
29
+ // Forward roleId to the host so it loads that role and the skills in cwd/.agents/skills. Without it roleId is only a label.
30
+ loadRole: z.literal(true).optional(),
30
31
  allowedDirectories: z.array(absolutePath).min(1).max(100).optional(),
31
32
  allowedPresets: z.array(id).min(1).max(100).optional(),
32
33
  flowId: id.optional(), flowVersion: text.optional(), driver: z.literal('ppt_delivery').optional(),
34
+ // A path agent: an agent_host fixed to cwd and preset whose role is this agents/*.md file inside cwd.
35
+ agentFile: absolutePath.optional(),
36
+ // A path agent on a DSH-native preset may fix its model; both are passed together and checked against the host catalog.
37
+ provider: id.optional(), model: text.optional(),
33
38
  }).strict();
34
39
  export const executionTargetConfigSchema = z.object({
35
40
  targetId: id, kind: z.enum(['agent_host', 'resident_agent', 'workflow']), name: text,
@@ -68,6 +73,15 @@ const connectionUpdate = z.object({ connectionId: id, expectedConnectionVersion:
68
73
  provider: z.enum(['a2a', 'activepieces']).optional(), enabled: z.boolean().optional(),
69
74
  }).strict() }).strict();
70
75
  const targetDelete = targetRef.extend({ expectedConfigVersion: version.optional() });
76
+ /** Copy a target under a new ID. `patch.binding` is merged into the copied binding, so only the fields being changed are given. */
77
+ const targetFork = z.object({ targetId: id, newTargetId: id,
78
+ patch: targetUpdate.shape.patch.extend({ binding: executionTargetBindingSchema.partial().optional() }).strict().optional() }).strict();
79
+ /** The preset a fixed role runs on when its binding names none. */
80
+ export const DEFAULT_RESIDENT_PRESET = 'standard';
81
+ function withDefaults(target) {
82
+ return target.kind === 'resident_agent' && !target.binding.agentPreset
83
+ ? { ...target, binding: { ...target.binding, agentPreset: DEFAULT_RESIDENT_PRESET } } : target;
84
+ }
71
85
  const connectionDelete = connectionRef.extend({ expectedConnectionVersion: version.optional() });
72
86
  export const TARGET_METHODS = {
73
87
  execution_connection_list: { description: '列出人工登记的执行连接及派生端点,不返回凭据。', parameters: z.toJSONSchema(empty) },
@@ -80,6 +94,7 @@ export const TARGET_METHODS = {
80
94
  execution_target_create: { description: '登记通用宿主、固定角色或工作流,不部署或运行能力。仅可信本机管理入口可调用。', parameters: z.toJSONSchema(executionTargetConfigSchema) },
81
95
  execution_target_update: { description: '修改或启停执行目标并递增配置版本。仅可信本机管理入口可调用。', parameters: z.toJSONSchema(targetUpdate) },
82
96
  execution_target_delete: { description: '删除目标且不取消历史任务,编号永久保留。仅可信本机管理入口可调用。', parameters: z.toJSONSchema(targetDelete) },
97
+ execution_target_fork: { description: '把已有目标复制成新编号的副本,可同时修改名称、默认预设或默认模型等;patch.binding 只写要改的字段。原目标不变。仅可信本机管理入口可调用。', parameters: z.toJSONSchema(targetFork) },
83
98
  execution_target_probe: { description: '读取只读探测要求和当前健康视图;调用方适配器可执行 agent-card/preflight 检查,目录自身不调用模型。', parameters: z.toJSONSchema(targetRef) },
84
99
  };
85
100
  const stateSchema = z.object({ version: z.literal(1), connections: z.array(executionConnectionSchema),
@@ -245,8 +260,28 @@ export class TargetDirectory {
245
260
  if (binding.flowId || binding.flowVersion)
246
261
  throw new Error('Agent targets cannot bind a workflow');
247
262
  if (target.kind === 'resident_agent' && (!binding.cwd || !binding.agentPreset || !binding.roleId))
248
- throw new Error('resident_agent requires fixed cwd, agentPreset and roleId');
249
- if (target.kind === 'agent_host' && (binding.cwd || binding.agentPreset || binding.roleId || binding.driver))
263
+ throw new Error('resident_agent requires fixed cwd and roleId');
264
+ if (binding.agentFile) {
265
+ if (target.kind !== 'agent_host' || !binding.cwd || !binding.agentPreset || binding.roleId || binding.driver)
266
+ throw new Error('A path agent is an agent_host with fixed cwd and agentPreset and no roleId or driver');
267
+ const relative = path.posix.relative(path.posix.normalize(binding.cwd), path.posix.normalize(binding.agentFile));
268
+ if (!relative || relative.startsWith('../') || relative === '..' || path.posix.isAbsolute(relative) || !relative.endsWith('.md'))
269
+ throw new Error('agentFile must be a .md file inside cwd');
270
+ if ((binding.provider === undefined) !== (binding.model === undefined))
271
+ throw new Error('provider and model must be fixed together');
272
+ if (binding.provider && binding.agentPreset.startsWith('oneagents-acp-'))
273
+ throw new Error('provider and model apply only to DSH-native presets');
274
+ }
275
+ else if (binding.provider || binding.model) {
276
+ // A fixed role may name a default model; each task can still pass its own provider and model.
277
+ if (target.kind !== 'resident_agent')
278
+ throw new Error('Only a path agent or a fixed role can set provider and model');
279
+ if ((binding.provider === undefined) !== (binding.model === undefined))
280
+ throw new Error('provider and model must be set together');
281
+ if (binding.agentPreset.startsWith('oneagents-acp-'))
282
+ throw new Error('provider and model apply only to DSH-native presets');
283
+ }
284
+ else if (target.kind === 'agent_host' && (binding.cwd || binding.agentPreset || binding.roleId || binding.driver))
250
285
  throw new Error('agent_host takes cwd and preset per task, not a fixed role binding');
251
286
  if (binding.cwd && binding.allowedDirectories)
252
287
  this.checkDirectory(binding.cwd, binding.allowedDirectories);
@@ -279,10 +314,13 @@ export class TargetDirectory {
279
314
  if (resolvedInput.remote !== undefined || resolvedInput.connectionId !== undefined || resolvedInput.targetId !== undefined)
280
315
  throw new Error('Input cannot override target or connection binding');
281
316
  let cwd, agentPreset;
282
- if (target.kind === 'resident_agent') {
317
+ if (target.kind === 'resident_agent' || target.binding.agentFile) {
283
318
  // Even an identical value is not an allowed caller override; the binding is authoritative.
284
319
  if (resolvedInput.cwd !== undefined || resolvedInput.agentPreset !== undefined || resolvedInput.roleId !== undefined || resolvedInput.driver !== undefined)
285
- throw new Error('resident_agent input cannot override its fixed cwd, preset, role or driver');
320
+ throw new Error(`${target.binding.agentFile ? 'A path agent' : 'resident_agent'} input cannot override its fixed cwd, preset, role or driver`);
321
+ // A path agent's model is part of the agent; a fixed role's model is only a default that a task may replace.
322
+ if (target.binding.agentFile && target.binding.provider && (resolvedInput.provider !== undefined || resolvedInput.model !== undefined))
323
+ throw new Error('A path agent input cannot override its fixed provider and model');
286
324
  cwd = target.binding.cwd;
287
325
  agentPreset = target.binding.agentPreset;
288
326
  }
@@ -386,7 +424,7 @@ export class TargetDirectory {
386
424
  return { deleted: true, connectionId };
387
425
  }
388
426
  if (method === 'execution_target_create') {
389
- const config = executionTargetConfigSchema.parse(params);
427
+ const config = withDefaults(executionTargetConfigSchema.parse(params));
390
428
  if (next.usedTargetIds.includes(config.targetId))
391
429
  throw new Error('Target ID already used; deleted IDs cannot be reused');
392
430
  const target = { ...config, configVersion: 1, createdAt: now, updatedAt: now };
@@ -400,7 +438,7 @@ export class TargetDirectory {
400
438
  const { targetId, patch, expectedConfigVersion } = targetUpdate.parse(params), previous = this.getTarget(targetId);
401
439
  if (expectedConfigVersion !== undefined && previous.configVersion !== expectedConfigVersion)
402
440
  throw new Error('Target version conflict');
403
- const candidate = executionTargetSchema.parse({ ...previous, ...patch, configVersion: previous.configVersion + 1, updatedAt: now });
441
+ const candidate = withDefaults(executionTargetSchema.parse({ ...previous, ...patch, configVersion: previous.configVersion + 1, updatedAt: now }));
404
442
  this.validateTarget(candidate, this.getConnection(candidate.connectionId));
405
443
  if (Object.entries(patch).every(([key, value]) => JSON.stringify(previous[key]) === JSON.stringify(value)))
406
444
  return previous;
@@ -408,6 +446,19 @@ export class TargetDirectory {
408
446
  this.commit(next);
409
447
  return clone(candidate);
410
448
  }
449
+ if (method === 'execution_target_fork') {
450
+ const { targetId, newTargetId, patch = {} } = targetFork.parse(params), previous = this.getTarget(targetId);
451
+ if (next.usedTargetIds.includes(newTargetId))
452
+ throw new Error('Target ID already used; deleted IDs cannot be reused');
453
+ const { configVersion: _version, createdAt: _created, updatedAt: _updated, ...config } = previous;
454
+ const target = withDefaults(executionTargetSchema.parse({ ...config, ...patch, targetId: newTargetId,
455
+ binding: { ...previous.binding, ...patch.binding }, configVersion: 1, createdAt: now, updatedAt: now }));
456
+ this.validateTarget(target, this.getConnection(target.connectionId));
457
+ next.targets.push(target);
458
+ next.usedTargetIds.push(target.targetId);
459
+ this.commit(next);
460
+ return clone(target);
461
+ }
411
462
  if (method === 'execution_target_delete') {
412
463
  const { targetId, expectedConfigVersion } = targetDelete.parse(params), previous = this.getTarget(targetId);
413
464
  if (expectedConfigVersion !== undefined && previous.configVersion !== expectedConfigVersion)
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The executor's three ticket operations and the text the agent reads back, shared by the three ways an executor
3
+ * reaches its ticket: DSH's native tools, the MCP server DSH offers ACP agents (Grok, Codex), and the
4
+ * `acp-service ticket` CLI in the executor's own shell. Each caller says which it is; the gateway records it.
5
+ */
6
+ export type ExecutorTicketTool = 'ticket_show' | 'ticket_mark' | 'ticket_submit';
7
+ export type ExecutorTicketChannel = 'dsh' | 'mcp' | 'cli';
8
+ /** The tools name the running attempt and session; the CLI names only the job. */
9
+ export type ExecutorTicketScope = {
10
+ jobId: string;
11
+ attemptId: string;
12
+ sessionId: string;
13
+ } | {
14
+ jobId: string;
15
+ };
16
+ export interface ExecutorTicketArgs {
17
+ id?: string;
18
+ state?: string;
19
+ note?: string;
20
+ }
21
+ /** Runs one operation; a rule the gateway enforces comes back as text for the agent, marked refused. */
22
+ export declare function runExecutorTicket(invoke: (method: string, params: Record<string, unknown>) => Promise<unknown>, scope: ExecutorTicketScope, via: ExecutorTicketChannel, tool: ExecutorTicketTool, args?: ExecutorTicketArgs): Promise<{
23
+ text: string;
24
+ refused?: true;
25
+ }>;
@@ -0,0 +1,27 @@
1
+ const pending = (ticket) => ticket.items.filter(item => item.state === 'open' || item.state === 'reopened');
2
+ function pendingText(ticket) {
3
+ const lines = pending(ticket).flatMap(item => {
4
+ const last = item.state === 'reopened' ? item.log.filter(entry => entry.note).at(-1) : undefined;
5
+ return [`${item.id} [${item.severity === 'must' ? '必须改' : '建议改'}] ${item.where}:${item.problem}`,
6
+ ...(item.suggestion ? [` 建议:${item.suggestion}`] : []),
7
+ ...(item.evidence?.length ? [` 证据:${JSON.stringify(item.evidence)}`] : []),
8
+ ...(last ? [` 上一次:${last.by} ${last.action}:${last.note}`] : [])];
9
+ });
10
+ return [...lines, `待处理 ${pending(ticket).length} 条,任务单状态 ${ticket.status},第 ${ticket.round} 轮`].join('\n');
11
+ }
12
+ /** Runs one operation; a rule the gateway enforces comes back as text for the agent, marked refused. */
13
+ export async function runExecutorTicket(invoke, scope, via, tool, args = {}) {
14
+ const params = { ...scope, via, ...(tool === 'ticket_mark' ? { itemId: args.id, state: args.state, note: args.note } : {}) };
15
+ let ticket;
16
+ try {
17
+ ticket = await invoke(tool, params);
18
+ }
19
+ catch (error) {
20
+ return { text: `任务单操作被拒绝:${error instanceof Error ? error.message : String(error)}`, refused: true };
21
+ }
22
+ if (tool === 'ticket_show')
23
+ return { text: pendingText(ticket) };
24
+ if (tool === 'ticket_mark')
25
+ return { text: `${args.id} 已标为 ${args.state},还剩 ${pending(ticket).length} 条待处理。` };
26
+ return { text: `任务单已提交(第 ${ticket.round} 轮),等待宿主检查。` };
27
+ }