@1agents/acp-service 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -13
- package/dist/bin/a2a.js +6 -2
- package/dist/bin/acp-service.js +24 -0
- package/dist/bin/process.d.ts +4 -0
- package/dist/bin/process.js +57 -0
- package/dist/bin/rsi.d.ts +3 -0
- package/dist/bin/rsi.js +114 -0
- package/dist/bin/ticket.d.ts +13 -0
- package/dist/bin/ticket.js +97 -0
- package/dist/bin/trail.d.ts +4 -0
- package/dist/bin/trail.js +62 -0
- package/dist/src/a2a/artifact-content.d.ts +9 -0
- package/dist/src/a2a/artifact-content.js +45 -0
- package/dist/src/a2a/desktop-notify.d.ts +1 -0
- package/dist/src/a2a/desktop-notify.js +12 -0
- package/dist/src/a2a/execution-binding.d.ts +9 -0
- package/dist/src/a2a/execution-binding.js +19 -0
- package/dist/src/a2a/executor.d.ts +6 -0
- package/dist/src/a2a/executor.js +112 -12
- package/dist/src/a2a/gateway.d.ts +537 -2
- package/dist/src/a2a/gateway.js +1014 -87
- package/dist/src/a2a/index.d.ts +8 -1
- package/dist/src/a2a/index.js +4 -0
- package/dist/src/a2a/job-directory.d.ts +6 -0
- package/dist/src/a2a/job-directory.js +19 -0
- package/dist/src/a2a/preflight.js +16 -1
- package/dist/src/a2a/resubmit.d.ts +46 -0
- package/dist/src/a2a/resubmit.js +82 -0
- package/dist/src/a2a/result-metadata.d.ts +3 -0
- package/dist/src/a2a/result-metadata.js +23 -5
- package/dist/src/a2a/server.d.ts +10 -0
- package/dist/src/a2a/server.js +125 -1
- package/dist/src/a2a/session-lifecycle.d.ts +40 -0
- package/dist/src/a2a/session-lifecycle.js +54 -0
- package/dist/src/a2a/store.d.ts +4 -0
- package/dist/src/a2a/store.js +70 -1
- package/dist/src/a2a/types.d.ts +45 -0
- package/dist/src/a2a/workbench-ui.d.ts +28 -0
- package/dist/src/a2a/workbench-ui.js +182 -0
- package/dist/src/acp-connection.js +27 -3
- package/dist/src/bridge.d.ts +1 -0
- package/dist/src/bridge.js +191 -39
- package/dist/src/capacity-queue.d.ts +35 -0
- package/dist/src/capacity-queue.js +139 -2
- package/dist/src/capacity.d.ts +25 -0
- package/dist/src/capacity.js +48 -9
- package/dist/src/dsh.js +1 -1
- package/dist/src/execution/agent-files.d.ts +25 -0
- package/dist/src/execution/agent-files.js +90 -0
- package/dist/src/execution/agent-registry.d.ts +164 -0
- package/dist/src/execution/agent-registry.js +275 -0
- package/dist/src/execution/human-review.d.ts +2 -0
- package/dist/src/execution/human-review.js +3 -1
- package/dist/src/execution/ledger.d.ts +52 -0
- package/dist/src/execution/ledger.js +83 -5
- package/dist/src/execution/process-request.d.ts +151 -0
- package/dist/src/execution/process-request.js +177 -0
- package/dist/src/execution/targets.d.ts +15 -0
- package/dist/src/execution/targets.js +22 -3
- package/dist/src/execution/ticket-executor.d.ts +25 -0
- package/dist/src/execution/ticket-executor.js +27 -0
- package/dist/src/execution/ticket.d.ts +326 -0
- package/dist/src/execution/ticket.js +301 -0
- package/dist/src/execution/workbench-chat.d.ts +25 -0
- package/dist/src/execution/workbench-chat.js +54 -0
- package/dist/src/execution/workbench.d.ts +32 -1
- package/dist/src/execution/workbench.js +113 -22
- package/dist/src/rsi/gate.d.ts +25 -0
- package/dist/src/rsi/gate.js +59 -0
- package/dist/src/rsi/outline-run.d.ts +107 -0
- package/dist/src/rsi/outline-run.js +443 -0
- package/dist/workbench-ui/app.css +453 -0
- package/dist/workbench-ui/app.js +13 -0
- package/dist/workbench-ui/chunk-23JHGYT3.js +1 -0
- package/dist/workbench-ui/chunk-3H6STGPV.js +1 -0
- package/dist/workbench-ui/chunk-3SNBBMGH.js +1 -0
- package/dist/workbench-ui/chunk-3XJZ6DIE.js +1 -0
- package/dist/workbench-ui/chunk-44KDLLKJ.js +1 -0
- package/dist/workbench-ui/chunk-46H7FU5Y.js +7 -0
- package/dist/workbench-ui/chunk-4N44QPL7.js +1 -0
- package/dist/workbench-ui/chunk-4YN4BS7I.js +1 -0
- package/dist/workbench-ui/chunk-53EG4IVQ.js +96 -0
- package/dist/workbench-ui/chunk-5FIPUNR4.js +1 -0
- package/dist/workbench-ui/chunk-6DWWYA6G.js +2 -0
- package/dist/workbench-ui/chunk-6FU3T633.js +99 -0
- package/dist/workbench-ui/chunk-6XKIHRA4.js +1 -0
- package/dist/workbench-ui/chunk-7GIX43Y5.js +1 -0
- package/dist/workbench-ui/chunk-7Q4WBGX6.js +4 -0
- package/dist/workbench-ui/chunk-A3BQM7HR.js +1 -0
- package/dist/workbench-ui/chunk-AFCFDDOP.js +24 -0
- package/dist/workbench-ui/chunk-AG67EUYD.js +89 -0
- package/dist/workbench-ui/chunk-AGJHMMTN.js +1 -0
- package/dist/workbench-ui/chunk-AO6JUBV6.js +41 -0
- package/dist/workbench-ui/chunk-AUSLTP43.js +72 -0
- package/dist/workbench-ui/chunk-AVZL46TT.js +1 -0
- package/dist/workbench-ui/chunk-AZRIGIV2.js +168 -0
- package/dist/workbench-ui/chunk-B2LIVH37.js +1 -0
- package/dist/workbench-ui/chunk-B7YX5TR5.js +1 -0
- package/dist/workbench-ui/chunk-BCB4X4XX.js +1 -0
- package/dist/workbench-ui/chunk-BCRQUL2A.js +88 -0
- package/dist/workbench-ui/chunk-BI6UHHQP.js +1 -0
- package/dist/workbench-ui/chunk-BLSLQ4AQ.js +120 -0
- package/dist/workbench-ui/chunk-C3QSRS6E.js +1 -0
- package/dist/workbench-ui/chunk-CK7M2PJ3.js +62 -0
- package/dist/workbench-ui/chunk-CM6LZ7TU.js +1 -0
- package/dist/workbench-ui/chunk-CP63H27F.js +36 -0
- package/dist/workbench-ui/chunk-CPUMMIS2.js +70 -0
- package/dist/workbench-ui/chunk-CSEIBI5U.js +2 -0
- package/dist/workbench-ui/chunk-CUS65DKZ.js +161 -0
- package/dist/workbench-ui/chunk-CVQY7TNC.js +1 -0
- package/dist/workbench-ui/chunk-D6S3XBIX.js +106 -0
- package/dist/workbench-ui/chunk-E253Y562.js +1 -0
- package/dist/workbench-ui/chunk-EADDJUDC.js +1 -0
- package/dist/workbench-ui/chunk-EBGJ3YXG.js +206 -0
- package/dist/workbench-ui/chunk-EKPVZ3WY.js +8 -0
- package/dist/workbench-ui/chunk-EQDCEAFY.js +1 -0
- package/dist/workbench-ui/chunk-ES3SSDJY.js +40 -0
- package/dist/workbench-ui/chunk-ESFD2H7N.js +231 -0
- package/dist/workbench-ui/chunk-FVOHPMS6.js +1 -0
- package/dist/workbench-ui/chunk-FXMQAGVT.js +1 -0
- package/dist/workbench-ui/chunk-GGTADRXD.js +24 -0
- package/dist/workbench-ui/chunk-GHIVPGNQ.js +1 -0
- package/dist/workbench-ui/chunk-GLU2YQV2.js +1 -0
- package/dist/workbench-ui/chunk-GOCKBYSM.js +1 -0
- package/dist/workbench-ui/chunk-H2KMMTJB.js +1 -0
- package/dist/workbench-ui/chunk-HGVLDNPP.js +39 -0
- package/dist/workbench-ui/chunk-HSAVC5GY.js +1 -0
- package/dist/workbench-ui/chunk-HSEAD2JH.js +1 -0
- package/dist/workbench-ui/chunk-HSIHOBTY.js +1 -0
- package/dist/workbench-ui/chunk-IZXOKUGG.js +67 -0
- package/dist/workbench-ui/chunk-JFT2LC2T.js +1 -0
- package/dist/workbench-ui/chunk-JHL3ZDYK.js +3 -0
- package/dist/workbench-ui/chunk-JMORLCZG.js +257 -0
- package/dist/workbench-ui/chunk-JR4SIX7A.js +1 -0
- package/dist/workbench-ui/chunk-K23HAGEH.js +30 -0
- package/dist/workbench-ui/chunk-K43JDCBH.js +1 -0
- package/dist/workbench-ui/chunk-KINKFJY7.js +1 -0
- package/dist/workbench-ui/chunk-KKQSA4LI.js +2 -0
- package/dist/workbench-ui/chunk-KOUZX3UX.js +1 -0
- package/dist/workbench-ui/chunk-KR4DRHW2.js +78 -0
- package/dist/workbench-ui/chunk-KT4DJNOR.js +1 -0
- package/dist/workbench-ui/chunk-KTPNKRRZ.js +292 -0
- package/dist/workbench-ui/chunk-LFHIPGSU.js +7 -0
- package/dist/workbench-ui/chunk-LWDL4HZB.js +125 -0
- package/dist/workbench-ui/chunk-MVYC3CY4.js +1 -0
- package/dist/workbench-ui/chunk-NWUPALCY.js +129 -0
- package/dist/workbench-ui/chunk-NY7C662Z.js +1 -0
- package/dist/workbench-ui/chunk-O76WTHWP.js +1 -0
- package/dist/workbench-ui/chunk-OTF7YHRE.js +162 -0
- package/dist/workbench-ui/chunk-P6TKKRKP.js +1 -0
- package/dist/workbench-ui/chunk-PFHOOWV3.js +1 -0
- package/dist/workbench-ui/chunk-PUQLANIM.js +1 -0
- package/dist/workbench-ui/chunk-PZCGBYVO.js +1 -0
- package/dist/workbench-ui/chunk-QOHUZGP4.js +1 -0
- package/dist/workbench-ui/chunk-QSEG3OFF.js +1 -0
- package/dist/workbench-ui/chunk-QYPOXZIA.js +84 -0
- package/dist/workbench-ui/chunk-R6SOF3JC.js +1 -0
- package/dist/workbench-ui/chunk-RCLOYU5F.js +1 -0
- package/dist/workbench-ui/chunk-RSRUP64S.js +1 -0
- package/dist/workbench-ui/chunk-RVAIT6JW.js +1 -0
- package/dist/workbench-ui/chunk-S2CCN3II.js +1 -0
- package/dist/workbench-ui/chunk-S2Q52W46.js +1 -0
- package/dist/workbench-ui/chunk-S2W5THJ5.js +1 -0
- package/dist/workbench-ui/chunk-S6ZQZNOX.js +1 -0
- package/dist/workbench-ui/chunk-S74PLMMS.js +1 -0
- package/dist/workbench-ui/chunk-S7C4HKEY.js +1 -0
- package/dist/workbench-ui/chunk-SDTB3Q65.js +1 -0
- package/dist/workbench-ui/chunk-SLPRGYUV.js +32 -0
- package/dist/workbench-ui/chunk-SQE76S5B.js +1 -0
- package/dist/workbench-ui/chunk-SSDZPVPW.js +1 -0
- package/dist/workbench-ui/chunk-SVI7DGIE.js +1 -0
- package/dist/workbench-ui/chunk-T6QKLZ4H.js +62 -0
- package/dist/workbench-ui/chunk-TJNRPTFL.js +1 -0
- package/dist/workbench-ui/chunk-TP6U4EDH.js +2 -0
- package/dist/workbench-ui/chunk-TYAAT3GQ.js +1 -0
- package/dist/workbench-ui/chunk-U6OCY4ZH.js +1 -0
- package/dist/workbench-ui/chunk-UAN3NLRF.js +1 -0
- package/dist/workbench-ui/chunk-UMLU3FIX.js +1 -0
- package/dist/workbench-ui/chunk-URIY2OTM.js +1 -0
- package/dist/workbench-ui/chunk-V2NUKAA7.js +38 -0
- package/dist/workbench-ui/chunk-V4QLL4TE.js +139 -0
- package/dist/workbench-ui/chunk-VASHXUK4.js +2 -0
- package/dist/workbench-ui/chunk-VJLIWNIU.js +1 -0
- package/dist/workbench-ui/chunk-VQNQFBID.js +1 -0
- package/dist/workbench-ui/chunk-VSIWU7XA.js +3 -0
- package/dist/workbench-ui/chunk-VSJASPUZ.js +321 -0
- package/dist/workbench-ui/chunk-VXPNUNUX.js +3 -0
- package/dist/workbench-ui/chunk-WBKLDCV6.js +1 -0
- package/dist/workbench-ui/chunk-WOKJM3FY.js +1 -0
- package/dist/workbench-ui/chunk-X3U3NA3X.js +34 -0
- package/dist/workbench-ui/chunk-XBYU7M4J.js +1 -0
- package/dist/workbench-ui/chunk-XBZAO4ID.js +10 -0
- package/dist/workbench-ui/chunk-XLLPZ2WO.js +1 -0
- package/dist/workbench-ui/chunk-YFVL4NJL.js +1 -0
- package/dist/workbench-ui/chunk-YRFQENM4.js +1 -0
- package/dist/workbench-ui/chunk-YUADQVB2.js +1 -0
- package/dist/workbench-ui/chunk-Z3TCAKM5.js +1 -0
- package/dist/workbench-ui/chunk-Z6QR6FRE.js +10 -0
- package/dist/workbench-ui/chunk-ZJPSORPP.js +3 -0
- package/dist/workbench-ui/chunk-ZLGCSTR2.js +15 -0
- package/dist/workbench-ui/chunk-ZLR4SG5X.js +1 -0
- package/dist/workbench-ui/chunk-ZND3TTGF.js +1 -0
- package/dist/workbench-ui/chunk-ZOP3ZYH7.js +2 -0
- package/dist/workbench-ui/index.html +14 -0
- package/package.json +19 -8
- package/skills/acp-service/SKILL.md +3 -1
- package/skills/acp-service/references/a2a.md +17 -5
- package/skills/acp-service/references/dsh.md +2 -0
- package/skills/acp-service/references/roles-and-tasks.md +1 -1
- package/skills/rsi-coach/SKILL.md +134 -0
- package/vendor/dsh/README.md +10 -6
- package/vendor/dsh/a2a-executor.d.ts +56 -2
- package/vendor/dsh/a2a-executor.js +163 -17
- package/vendor/dsh/a2a.d.ts +12 -2
- package/vendor/dsh/a2a.js +9 -2
- package/vendor/dsh/adapter.d.ts +52 -3
- package/vendor/dsh/adapter.js +297 -30
- package/vendor/dsh/client.js +67 -11
- package/vendor/dsh/index.js +55 -3
- package/vendor/dsh/native-approvals.d.ts +4 -0
- package/vendor/dsh/native-approvals.js +44 -0
- package/vendor/dsh/preset-route.d.ts +49 -0
- package/vendor/dsh/preset-route.js +51 -0
- package/vendor/dsh/preset.js +10 -3
- package/vendor/dsh/process-admission.d.ts +25 -0
- package/vendor/dsh/process-admission.js +87 -0
- package/vendor/dsh/process-requests.d.ts +57 -0
- package/vendor/dsh/process-requests.js +49 -0
- package/vendor/dsh/review-mcp.d.ts +1 -0
- package/vendor/dsh/review-mcp.js +56 -0
- package/vendor/dsh/review.d.ts +30 -0
- package/vendor/dsh/review.js +149 -0
- package/vendor/dsh/session-settings.d.ts +34 -0
- package/vendor/dsh/session-settings.js +114 -0
- package/vendor/dsh/ticket-spec.d.ts +30 -0
- package/vendor/dsh/ticket-spec.js +10 -0
- package/vendor/dsh/ticket-tools.d.ts +21 -0
- package/vendor/dsh/ticket-tools.js +43 -0
- package/vendor/dsh/workbench.d.ts +18 -0
- package/vendor/dsh/workbench.js +91 -0
- package/vendor/runtime/README.md +6 -4
- package/vendor/runtime/dist/docs-site/CLI.html +2 -2
- package/vendor/runtime/dist/docs-site/VISION.html +2 -2
- package/vendor/runtime/dist/docs-site/agents.html +2 -2
- package/vendor/runtime/dist/docs-site/compare.html +2 -2
- package/vendor/runtime/dist/docs-site/config.html +2 -2
- package/vendor/runtime/dist/docs-site/custom-agents.html +2 -2
- package/vendor/runtime/dist/docs-site/exit-codes.html +2 -2
- package/vendor/runtime/dist/docs-site/flows.html +2 -2
- package/vendor/runtime/dist/docs-site/index.html +1 -1
- package/vendor/runtime/dist/docs-site/install.html +2 -2
- package/vendor/runtime/dist/docs-site/llms.txt +1 -1
- package/vendor/runtime/dist/docs-site/output-formats.html +2 -2
- package/vendor/runtime/dist/docs-site/permissions.html +2 -2
- package/vendor/runtime/dist/docs-site/prompting.html +2 -2
- package/vendor/runtime/dist/docs-site/quickstart.html +2 -2
- package/vendor/runtime/dist/docs-site/releasing.html +2 -2
- package/vendor/runtime/dist/docs-site/runtime-environment.html +2 -2
- package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +2 -2
- package/vendor/runtime/dist/docs-site/safe-errors.html +2 -2
- package/vendor/runtime/dist/docs-site/session-control.html +2 -2
- package/vendor/runtime/dist/docs-site/session-watch.html +2 -2
- package/vendor/runtime/dist/docs-site/sessions.html +2 -2
- package/vendor/runtime/dist/docs-site/shared-sessions.html +2 -2
- package/vendor/runtime/package.json +6 -4
- 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
|
+
}
|
|
@@ -44,6 +44,9 @@ export declare const executionTargetBindingSchema: z.ZodObject<{
|
|
|
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;
|
|
@@ -76,6 +79,9 @@ export declare const executionTargetConfigSchema: z.ZodObject<{
|
|
|
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<{
|
|
@@ -109,6 +115,9 @@ export declare const executionTargetSchema: z.ZodObject<{
|
|
|
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;
|
|
@@ -245,6 +254,9 @@ export declare const TARGET_METHODS: {
|
|
|
245
254
|
flowId: z.ZodOptional<z.ZodString>;
|
|
246
255
|
flowVersion: z.ZodOptional<z.ZodString>;
|
|
247
256
|
driver: z.ZodOptional<z.ZodLiteral<"ppt_delivery">>;
|
|
257
|
+
agentFile: z.ZodOptional<z.ZodString>;
|
|
258
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
259
|
+
model: z.ZodOptional<z.ZodString>;
|
|
248
260
|
}, z.core.$strict>>;
|
|
249
261
|
}, z.core.$strict>>;
|
|
250
262
|
};
|
|
@@ -283,6 +295,9 @@ export declare const TARGET_METHODS: {
|
|
|
283
295
|
flowId: z.ZodOptional<z.ZodString>;
|
|
284
296
|
flowVersion: z.ZodOptional<z.ZodString>;
|
|
285
297
|
driver: z.ZodOptional<z.ZodLiteral<"ppt_delivery">>;
|
|
298
|
+
agentFile: z.ZodOptional<z.ZodString>;
|
|
299
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
300
|
+
model: z.ZodOptional<z.ZodString>;
|
|
286
301
|
}, z.core.$strict>>;
|
|
287
302
|
}, z.core.$strict>;
|
|
288
303
|
}, z.core.$strict>>;
|
|
@@ -30,6 +30,10 @@ export const executionTargetBindingSchema = z.object({
|
|
|
30
30
|
allowedDirectories: z.array(absolutePath).min(1).max(100).optional(),
|
|
31
31
|
allowedPresets: z.array(id).min(1).max(100).optional(),
|
|
32
32
|
flowId: id.optional(), flowVersion: text.optional(), driver: z.literal('ppt_delivery').optional(),
|
|
33
|
+
// A path agent: an agent_host fixed to cwd and preset whose role is this agents/*.md file inside cwd.
|
|
34
|
+
agentFile: absolutePath.optional(),
|
|
35
|
+
// A path agent on a DSH-native preset may fix its model; both are passed together and checked against the host catalog.
|
|
36
|
+
provider: id.optional(), model: text.optional(),
|
|
33
37
|
}).strict();
|
|
34
38
|
export const executionTargetConfigSchema = z.object({
|
|
35
39
|
targetId: id, kind: z.enum(['agent_host', 'resident_agent', 'workflow']), name: text,
|
|
@@ -246,7 +250,20 @@ export class TargetDirectory {
|
|
|
246
250
|
throw new Error('Agent targets cannot bind a workflow');
|
|
247
251
|
if (target.kind === 'resident_agent' && (!binding.cwd || !binding.agentPreset || !binding.roleId))
|
|
248
252
|
throw new Error('resident_agent requires fixed cwd, agentPreset and roleId');
|
|
249
|
-
if (
|
|
253
|
+
if (binding.agentFile) {
|
|
254
|
+
if (target.kind !== 'agent_host' || !binding.cwd || !binding.agentPreset || binding.roleId || binding.driver)
|
|
255
|
+
throw new Error('A path agent is an agent_host with fixed cwd and agentPreset and no roleId or driver');
|
|
256
|
+
const relative = path.posix.relative(path.posix.normalize(binding.cwd), path.posix.normalize(binding.agentFile));
|
|
257
|
+
if (!relative || relative.startsWith('../') || relative === '..' || path.posix.isAbsolute(relative) || !relative.endsWith('.md'))
|
|
258
|
+
throw new Error('agentFile must be a .md file inside cwd');
|
|
259
|
+
if ((binding.provider === undefined) !== (binding.model === undefined))
|
|
260
|
+
throw new Error('provider and model must be fixed together');
|
|
261
|
+
if (binding.provider && binding.agentPreset.startsWith('oneagents-acp-'))
|
|
262
|
+
throw new Error('provider and model apply only to DSH-native presets');
|
|
263
|
+
}
|
|
264
|
+
else if (binding.provider || binding.model)
|
|
265
|
+
throw new Error('Only a path agent can fix provider and model');
|
|
266
|
+
else if (target.kind === 'agent_host' && (binding.cwd || binding.agentPreset || binding.roleId || binding.driver))
|
|
250
267
|
throw new Error('agent_host takes cwd and preset per task, not a fixed role binding');
|
|
251
268
|
if (binding.cwd && binding.allowedDirectories)
|
|
252
269
|
this.checkDirectory(binding.cwd, binding.allowedDirectories);
|
|
@@ -279,10 +296,12 @@ export class TargetDirectory {
|
|
|
279
296
|
if (resolvedInput.remote !== undefined || resolvedInput.connectionId !== undefined || resolvedInput.targetId !== undefined)
|
|
280
297
|
throw new Error('Input cannot override target or connection binding');
|
|
281
298
|
let cwd, agentPreset;
|
|
282
|
-
if (target.kind === 'resident_agent') {
|
|
299
|
+
if (target.kind === 'resident_agent' || target.binding.agentFile) {
|
|
283
300
|
// Even an identical value is not an allowed caller override; the binding is authoritative.
|
|
284
301
|
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
|
|
302
|
+
throw new Error(`${target.binding.agentFile ? 'A path agent' : 'resident_agent'} input cannot override its fixed cwd, preset, role or driver`);
|
|
303
|
+
if (target.binding.provider && (resolvedInput.provider !== undefined || resolvedInput.model !== undefined))
|
|
304
|
+
throw new Error('A path agent input cannot override its fixed provider and model');
|
|
286
305
|
cwd = target.binding.cwd;
|
|
287
306
|
agentPreset = target.binding.agentPreset;
|
|
288
307
|
}
|
|
@@ -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
|
+
}
|