@1agents/acp-service 0.8.3 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -13
- package/dist/bin/a2a.js +16 -4
- package/dist/bin/acp-service.js +30 -0
- package/dist/bin/process.d.ts +4 -0
- package/dist/bin/process.js +57 -0
- package/dist/bin/roles.d.ts +1 -0
- package/dist/bin/roles.js +24 -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 +22 -1
- package/dist/src/a2a/executor.js +308 -22
- package/dist/src/a2a/gateway.d.ts +613 -1
- package/dist/src/a2a/gateway.js +1337 -88
- package/dist/src/a2a/index.d.ts +14 -1
- package/dist/src/a2a/index.js +8 -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 +6 -0
- package/dist/src/a2a/result-metadata.js +25 -6
- package/dist/src/a2a/server.d.ts +10 -0
- package/dist/src/a2a/server.js +127 -2
- 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 +76 -1
- package/dist/src/a2a/types.d.ts +77 -1
- package/dist/src/a2a/types.js +11 -1
- 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 +119 -14
- package/dist/src/bridge.d.ts +1 -0
- package/dist/src/bridge.js +312 -37
- package/dist/src/capacity-lifecycle.d.ts +5 -0
- package/dist/src/capacity-lifecycle.js +57 -0
- package/dist/src/capacity-queue.d.ts +58 -0
- package/dist/src/capacity-queue.js +388 -0
- package/dist/src/capacity.d.ts +101 -0
- package/dist/src/capacity.js +416 -0
- 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 +105 -0
- package/dist/src/execution/human-review.js +89 -0
- package/dist/src/execution/ledger.d.ts +57 -0
- package/dist/src/execution/ledger.js +122 -13
- package/dist/src/execution/ppt-delivery.d.ts +36 -3
- package/dist/src/execution/ppt-delivery.js +243 -53
- package/dist/src/execution/process-request.d.ts +151 -0
- package/dist/src/execution/process-request.js +177 -0
- package/dist/src/execution/project-discovery.d.ts +56 -0
- package/dist/src/execution/project-discovery.js +429 -0
- package/dist/src/execution/report-review.d.ts +60 -0
- package/dist/src/execution/report-review.js +173 -0
- package/dist/src/execution/targets.d.ts +20 -0
- package/dist/src/execution/targets.js +23 -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 +162 -0
- package/dist/src/execution/workbench.js +356 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +3 -0
- package/dist/src/roles/index.d.ts +1 -0
- package/dist/src/roles/index.js +1 -0
- package/dist/src/roles/skills.d.ts +71 -0
- package/dist/src/roles/skills.js +427 -0
- 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 +23 -8
- package/skills/acp-service/SKILL.md +24 -8
- package/skills/acp-service/references/a2a.md +24 -8
- package/skills/acp-service/references/async-caller.md +48 -0
- package/skills/acp-service/references/dsh.md +2 -0
- package/skills/acp-service/references/roles-and-tasks.md +120 -0
- package/skills/acp-service/scripts/a2a-caller.py +242 -0
- package/skills/rsi-coach/SKILL.md +134 -0
- package/vendor/dsh/README.md +11 -5
- package/vendor/dsh/a2a-executor.d.ts +60 -3
- package/vendor/dsh/a2a-executor.js +208 -18
- package/vendor/dsh/a2a.d.ts +12 -2
- package/vendor/dsh/a2a.js +9 -2
- package/vendor/dsh/adapter.d.ts +61 -2
- package/vendor/dsh/adapter.js +354 -23
- package/vendor/dsh/client.js +67 -11
- package/vendor/dsh/index.js +57 -4
- 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/{cli-DeOpE2Xz.js → cli-DXmYwv3U.js} +4 -4
- package/vendor/runtime/dist/{cli-DeOpE2Xz.js.map → cli-DXmYwv3U.js.map} +1 -1
- package/vendor/runtime/dist/cli.js +7 -7
- package/vendor/runtime/dist/client-VQsqcIOJ.d.ts.map +1 -1
- 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 +3 -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/dist/{flows-oaBGn31w.js → flows-DJ17ajbw.js} +3 -3
- package/vendor/runtime/dist/{flows-oaBGn31w.js.map → flows-DJ17ajbw.js.map} +1 -1
- package/vendor/runtime/dist/flows.js +1 -1
- package/vendor/runtime/dist/{invocation-options-CUDEE8vW.js → invocation-options-PBfCgrdi.js} +3 -3
- package/vendor/runtime/dist/{invocation-options-CUDEE8vW.js.map → invocation-options-PBfCgrdi.js.map} +1 -1
- package/vendor/runtime/dist/{output-CFv3jcOQ.js → output-B3MDn7kv.js} +2 -2
- package/vendor/runtime/dist/{output-CFv3jcOQ.js.map → output-B3MDn7kv.js.map} +1 -1
- package/vendor/runtime/dist/{queue-owner-runtime-DvMJiGbP.js → queue-owner-runtime-DXCVngwU.js} +15 -8
- package/vendor/runtime/dist/queue-owner-runtime-DXCVngwU.js.map +1 -0
- package/vendor/runtime/dist/runtime.js +1 -1
- package/vendor/runtime/dist/{session-watch-Di-wIdCH.js → session-watch-DURyCw31.js} +2 -2
- package/vendor/runtime/dist/{session-watch-Di-wIdCH.js.map → session-watch-DURyCw31.js.map} +1 -1
- package/vendor/runtime/package.json +6 -4
- package/vendor/runtime/skills/acpx/SKILL.md +2 -0
- package/vendor/runtime/dist/queue-owner-runtime-DvMJiGbP.js.map +0 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const agentOptionSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
value: z.ZodString;
|
|
5
|
+
model: z.ZodOptional<z.ZodLiteral<true>>;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export type AgentOption = z.output<typeof agentOptionSchema>;
|
|
8
|
+
/** Where a path-registered agent came from: the registered directory and its agents/*.md file. */
|
|
9
|
+
export declare const agentSourceSchema: z.ZodObject<{
|
|
10
|
+
path: z.ZodString;
|
|
11
|
+
file: z.ZodString;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export type AgentSource = z.output<typeof agentSourceSchema>;
|
|
14
|
+
export declare const agentDraftSchema: z.ZodObject<{
|
|
15
|
+
agentId: z.ZodString;
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
acpAgent: z.ZodOptional<z.ZodString>;
|
|
18
|
+
agentPreset: z.ZodOptional<z.ZodString>;
|
|
19
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
20
|
+
model: z.ZodOptional<z.ZodString>;
|
|
21
|
+
roleId: z.ZodOptional<z.ZodString>;
|
|
22
|
+
targetId: z.ZodOptional<z.ZodString>;
|
|
23
|
+
modeId: z.ZodOptional<z.ZodString>;
|
|
24
|
+
options: z.ZodArray<z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
value: z.ZodString;
|
|
27
|
+
model: z.ZodOptional<z.ZodLiteral<true>>;
|
|
28
|
+
}, z.core.$strict>>;
|
|
29
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
30
|
+
path: z.ZodString;
|
|
31
|
+
file: z.ZodString;
|
|
32
|
+
}, z.core.$strict>>;
|
|
33
|
+
description: z.ZodOptional<z.ZodString>;
|
|
34
|
+
updatedAt: z.ZodString;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
export declare const agentReleaseSchema: z.ZodObject<{
|
|
37
|
+
releaseName: z.ZodString;
|
|
38
|
+
sourceAgentId: z.ZodOptional<z.ZodString>;
|
|
39
|
+
acpAgent: z.ZodOptional<z.ZodString>;
|
|
40
|
+
agentPreset: z.ZodOptional<z.ZodString>;
|
|
41
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
42
|
+
model: z.ZodOptional<z.ZodString>;
|
|
43
|
+
roleId: z.ZodOptional<z.ZodString>;
|
|
44
|
+
targetId: z.ZodOptional<z.ZodString>;
|
|
45
|
+
modeId: z.ZodOptional<z.ZodString>;
|
|
46
|
+
options: z.ZodArray<z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
value: z.ZodString;
|
|
49
|
+
model: z.ZodOptional<z.ZodLiteral<true>>;
|
|
50
|
+
}, z.core.$strict>>;
|
|
51
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
path: z.ZodString;
|
|
53
|
+
file: z.ZodString;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
description: z.ZodOptional<z.ZodString>;
|
|
56
|
+
publishedAt: z.ZodString;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
export type AgentDraft = z.output<typeof agentDraftSchema>;
|
|
59
|
+
export type AgentRelease = z.output<typeof agentReleaseSchema>;
|
|
60
|
+
export interface DevelopmentAdmission {
|
|
61
|
+
agentId: string;
|
|
62
|
+
name: string;
|
|
63
|
+
phase: 'developing' | 'published';
|
|
64
|
+
channel: 'trial' | 'formal';
|
|
65
|
+
}
|
|
66
|
+
export interface ResidentAgentRef {
|
|
67
|
+
targetId: string;
|
|
68
|
+
name: string;
|
|
69
|
+
roleId?: string;
|
|
70
|
+
agentPreset?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface AgentTaskRef {
|
|
73
|
+
agentId?: string;
|
|
74
|
+
pendingReviewId?: string;
|
|
75
|
+
pendingProcessRequestId?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface WorkbenchAgentRow {
|
|
78
|
+
agentId: string;
|
|
79
|
+
name: string;
|
|
80
|
+
phase: 'developing' | 'published';
|
|
81
|
+
origin: 'draft' | 'release' | 'resident';
|
|
82
|
+
acpAgent?: string;
|
|
83
|
+
roleId?: string;
|
|
84
|
+
targetId?: string;
|
|
85
|
+
agentPreset?: string;
|
|
86
|
+
provider?: string;
|
|
87
|
+
model?: string;
|
|
88
|
+
modeId?: string;
|
|
89
|
+
options: AgentOption[];
|
|
90
|
+
source?: AgentSource;
|
|
91
|
+
description?: string;
|
|
92
|
+
releaseName?: string;
|
|
93
|
+
sourceAgentId?: string;
|
|
94
|
+
counterpartId?: string;
|
|
95
|
+
taskCount: number;
|
|
96
|
+
pendingCount: number;
|
|
97
|
+
}
|
|
98
|
+
export declare class AgentRegistryError extends Error {
|
|
99
|
+
readonly code: 'invalid' | 'not_found' | 'conflict';
|
|
100
|
+
constructor(message: string, code: 'invalid' | 'not_found' | 'conflict');
|
|
101
|
+
}
|
|
102
|
+
/** Model options stay ahead of the other accepted values. */
|
|
103
|
+
export declare function orderAgentOptions(options: readonly AgentOption[]): AgentOption[];
|
|
104
|
+
export declare function readDevelopment(value: unknown): DevelopmentAdmission | undefined;
|
|
105
|
+
export interface TaskDevelopment {
|
|
106
|
+
channel: 'trial' | 'formal' | 'standalone';
|
|
107
|
+
agentId?: string;
|
|
108
|
+
name?: string;
|
|
109
|
+
phase?: 'developing' | 'published';
|
|
110
|
+
}
|
|
111
|
+
/** A frozen admission wins. An unstamped resident target is already published. */
|
|
112
|
+
export declare function describeTaskDevelopment(raw: unknown, target: {
|
|
113
|
+
targetId: string;
|
|
114
|
+
resident: boolean;
|
|
115
|
+
residentName?: string;
|
|
116
|
+
}): TaskDevelopment;
|
|
117
|
+
export declare function projectWorkbenchAgents(catalog: {
|
|
118
|
+
drafts: readonly AgentDraft[];
|
|
119
|
+
releases: readonly AgentRelease[];
|
|
120
|
+
residents: readonly ResidentAgentRef[];
|
|
121
|
+
}, tasks: readonly AgentTaskRef[]): {
|
|
122
|
+
developing: WorkbenchAgentRow[];
|
|
123
|
+
published: WorkbenchAgentRow[];
|
|
124
|
+
};
|
|
125
|
+
export declare class AgentRegistry {
|
|
126
|
+
private readonly file;
|
|
127
|
+
private state;
|
|
128
|
+
constructor(directory: string);
|
|
129
|
+
snapshot(): {
|
|
130
|
+
drafts: AgentDraft[];
|
|
131
|
+
releases: AgentRelease[];
|
|
132
|
+
};
|
|
133
|
+
/** New calls use a release when one owns the target, then a draft, then an already resident role. */
|
|
134
|
+
admit(target: {
|
|
135
|
+
targetId: string;
|
|
136
|
+
kind: string;
|
|
137
|
+
name: string;
|
|
138
|
+
}): DevelopmentAdmission | undefined;
|
|
139
|
+
create(input: unknown): AgentDraft;
|
|
140
|
+
update(agentId: string, input: unknown): AgentDraft;
|
|
141
|
+
/** Copy the draft into a callable name. The draft remains, and its target moves to the release. */
|
|
142
|
+
publish(agentId: string, input: unknown): AgentRelease;
|
|
143
|
+
/** The draft registered from this agents/*.md file for this runtime: an ACP agent name or a DSH-native preset. */
|
|
144
|
+
pathDraft(file: string, runtime: string): AgentDraft | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Create or refresh the draft for one agents/*.md file on one runtime. The file and runtime identify the draft, so
|
|
147
|
+
* registering the same path again updates it in place and keeps its tasks, while another runtime gets its own draft.
|
|
148
|
+
* A different draft already using the name is a conflict.
|
|
149
|
+
*/
|
|
150
|
+
registerPathDraft(input: {
|
|
151
|
+
name: string;
|
|
152
|
+
targetId: string;
|
|
153
|
+
source: AgentSource;
|
|
154
|
+
description?: string;
|
|
155
|
+
acpAgent?: string;
|
|
156
|
+
agentPreset?: string;
|
|
157
|
+
provider?: string;
|
|
158
|
+
model?: string;
|
|
159
|
+
}): AgentDraft;
|
|
160
|
+
private draft;
|
|
161
|
+
private parse;
|
|
162
|
+
private assertUnique;
|
|
163
|
+
private commit;
|
|
164
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/** Named agent drafts and releases for the workbench. A passed review does not publish a draft. */
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
const agentIdPattern = /^agt-[a-z0-9-]{8,80}$/;
|
|
7
|
+
const callName = z.string().trim().min(1).max(80).refine(value => !/[\u0000-\u001f\u007f]/.test(value), 'Invalid agent name');
|
|
8
|
+
const acpAgentName = z.string().trim().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
9
|
+
const targetId = z.string().trim().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9.:_-]*$/);
|
|
10
|
+
const optionId = z.string().trim().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
11
|
+
const optionValue = z.string().trim().min(1).max(256).refine(value => !/[\u0000-\u001f\u007f]/.test(value), 'Invalid option value');
|
|
12
|
+
export const agentOptionSchema = z.object({
|
|
13
|
+
id: optionId,
|
|
14
|
+
value: optionValue,
|
|
15
|
+
model: z.literal(true).optional(),
|
|
16
|
+
}).strict();
|
|
17
|
+
const absolute = z.string().min(1).max(4096).refine(value => path.isAbsolute(value) && !value.includes('\0'), 'Expected an absolute local path');
|
|
18
|
+
/** Where a path-registered agent came from: the registered directory and its agents/*.md file. */
|
|
19
|
+
export const agentSourceSchema = z.object({ path: absolute, file: absolute }).strict();
|
|
20
|
+
const description = z.string().trim().min(1).max(1024);
|
|
21
|
+
export const agentDraftSchema = z.object({
|
|
22
|
+
agentId: z.string().regex(agentIdPattern),
|
|
23
|
+
name: callName,
|
|
24
|
+
// ACP drafts name their ACP agent; a path agent on a DSH-native preset names the preset (and an optional fixed model) instead.
|
|
25
|
+
acpAgent: acpAgentName.optional(),
|
|
26
|
+
agentPreset: targetId.optional(),
|
|
27
|
+
provider: targetId.optional(),
|
|
28
|
+
model: optionValue.optional(),
|
|
29
|
+
roleId: targetId.optional(),
|
|
30
|
+
targetId: targetId.optional(),
|
|
31
|
+
modeId: optionId.optional(),
|
|
32
|
+
options: z.array(agentOptionSchema).max(20),
|
|
33
|
+
source: agentSourceSchema.optional(),
|
|
34
|
+
description: description.optional(),
|
|
35
|
+
updatedAt: z.string().datetime(),
|
|
36
|
+
}).strict();
|
|
37
|
+
export const agentReleaseSchema = z.object({
|
|
38
|
+
releaseName: callName,
|
|
39
|
+
sourceAgentId: z.string().regex(agentIdPattern).optional(),
|
|
40
|
+
acpAgent: acpAgentName.optional(),
|
|
41
|
+
agentPreset: targetId.optional(),
|
|
42
|
+
provider: targetId.optional(),
|
|
43
|
+
model: optionValue.optional(),
|
|
44
|
+
roleId: targetId.optional(),
|
|
45
|
+
targetId: targetId.optional(),
|
|
46
|
+
modeId: optionId.optional(),
|
|
47
|
+
options: z.array(agentOptionSchema).max(20),
|
|
48
|
+
source: agentSourceSchema.optional(),
|
|
49
|
+
description: description.optional(),
|
|
50
|
+
publishedAt: z.string().datetime(),
|
|
51
|
+
}).strict();
|
|
52
|
+
const fileSchema = z.object({
|
|
53
|
+
version: z.literal(1),
|
|
54
|
+
drafts: z.array(agentDraftSchema),
|
|
55
|
+
releases: z.array(agentReleaseSchema),
|
|
56
|
+
}).strict();
|
|
57
|
+
const draftInputSchema = z.object({
|
|
58
|
+
name: callName,
|
|
59
|
+
acpAgent: acpAgentName,
|
|
60
|
+
roleId: targetId.optional(),
|
|
61
|
+
targetId: targetId.optional(),
|
|
62
|
+
modeId: optionId.optional(),
|
|
63
|
+
options: z.array(agentOptionSchema).max(20).default([]),
|
|
64
|
+
}).strict();
|
|
65
|
+
const draftPatchSchema = draftInputSchema.partial().strict();
|
|
66
|
+
const publishInputSchema = z.object({ releaseName: callName, replace: z.boolean().optional() }).strict();
|
|
67
|
+
export class AgentRegistryError extends Error {
|
|
68
|
+
code;
|
|
69
|
+
constructor(message, code) {
|
|
70
|
+
super(message);
|
|
71
|
+
this.code = code;
|
|
72
|
+
this.name = 'AgentRegistryError';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** Model options stay ahead of the other accepted values. */
|
|
76
|
+
export function orderAgentOptions(options) {
|
|
77
|
+
const normalized = options.map(option => ({ id: option.id, value: option.value, ...(option.model || option.id === 'model' ? { model: true } : {}) }));
|
|
78
|
+
if (new Set(normalized.map(option => option.id)).size !== normalized.length)
|
|
79
|
+
throw new AgentRegistryError('Each ACP option id can be saved once', 'invalid');
|
|
80
|
+
return [...normalized.filter(option => option.model), ...normalized.filter(option => !option.model)];
|
|
81
|
+
}
|
|
82
|
+
export function readDevelopment(value) {
|
|
83
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
84
|
+
return undefined;
|
|
85
|
+
const record = value;
|
|
86
|
+
if ((record.channel !== 'trial' && record.channel !== 'formal') || (record.phase !== 'developing' && record.phase !== 'published'))
|
|
87
|
+
return undefined;
|
|
88
|
+
if (typeof record.agentId !== 'string' || !record.agentId || record.agentId.length > 200 || typeof record.name !== 'string' || !record.name || record.name.length > 80)
|
|
89
|
+
return undefined;
|
|
90
|
+
return { agentId: record.agentId, name: record.name, phase: record.phase, channel: record.channel };
|
|
91
|
+
}
|
|
92
|
+
/** A frozen admission wins. An unstamped resident target is already published. */
|
|
93
|
+
export function describeTaskDevelopment(raw, target) {
|
|
94
|
+
const stamped = readDevelopment(raw);
|
|
95
|
+
if (stamped)
|
|
96
|
+
return stamped;
|
|
97
|
+
if (target.resident)
|
|
98
|
+
return { channel: 'formal', phase: 'published', agentId: `resident:${target.targetId}`, name: target.residentName || target.targetId };
|
|
99
|
+
return { channel: 'standalone' };
|
|
100
|
+
}
|
|
101
|
+
export function projectWorkbenchAgents(catalog, tasks) {
|
|
102
|
+
const count = (agentId) => {
|
|
103
|
+
const owned = tasks.filter(task => task.agentId === agentId);
|
|
104
|
+
return { taskCount: owned.length, pendingCount: owned.filter(task => task.pendingReviewId || task.pendingProcessRequestId).length };
|
|
105
|
+
};
|
|
106
|
+
const developing = catalog.drafts.map(draft => {
|
|
107
|
+
const release = catalog.releases.find(item => item.sourceAgentId === draft.agentId);
|
|
108
|
+
return { agentId: draft.agentId, name: draft.name, phase: 'developing', origin: 'draft', ...(draft.acpAgent ? { acpAgent: draft.acpAgent } : {}),
|
|
109
|
+
...(draft.agentPreset ? { agentPreset: draft.agentPreset } : {}), ...(draft.provider ? { provider: draft.provider, model: draft.model } : {}),
|
|
110
|
+
...(draft.roleId ? { roleId: draft.roleId } : {}), ...(draft.targetId ? { targetId: draft.targetId } : {}),
|
|
111
|
+
...(draft.modeId ? { modeId: draft.modeId } : {}), options: draft.options.map(option => ({ ...option })),
|
|
112
|
+
...(draft.source ? { source: { ...draft.source } } : {}), ...(draft.description ? { description: draft.description } : {}),
|
|
113
|
+
...(release ? { counterpartId: `release:${release.releaseName}`, releaseName: release.releaseName } : {}), ...count(draft.agentId) };
|
|
114
|
+
});
|
|
115
|
+
const publishedReleases = catalog.releases.map(release => ({
|
|
116
|
+
agentId: `release:${release.releaseName}`, name: release.releaseName, phase: 'published', origin: 'release',
|
|
117
|
+
...(release.acpAgent ? { acpAgent: release.acpAgent } : {}), ...(release.agentPreset ? { agentPreset: release.agentPreset } : {}), ...(release.provider ? { provider: release.provider, model: release.model } : {}),
|
|
118
|
+
...(release.roleId ? { roleId: release.roleId } : {}), ...(release.targetId ? { targetId: release.targetId } : {}),
|
|
119
|
+
...(release.modeId ? { modeId: release.modeId } : {}), options: release.options.map(option => ({ ...option })), releaseName: release.releaseName,
|
|
120
|
+
...(release.source ? { source: { ...release.source } } : {}), ...(release.description ? { description: release.description } : {}),
|
|
121
|
+
...(release.sourceAgentId ? { sourceAgentId: release.sourceAgentId, counterpartId: release.sourceAgentId } : {}), ...count(`release:${release.releaseName}`),
|
|
122
|
+
}));
|
|
123
|
+
const releasedTargets = new Set(catalog.releases.map(release => release.targetId).filter((id) => Boolean(id)));
|
|
124
|
+
const publishedResidents = catalog.residents.filter(resident => !releasedTargets.has(resident.targetId)).map(resident => ({
|
|
125
|
+
agentId: `resident:${resident.targetId}`, name: resident.name, phase: 'published', origin: 'resident',
|
|
126
|
+
...(resident.roleId ? { roleId: resident.roleId } : {}), targetId: resident.targetId,
|
|
127
|
+
...(resident.agentPreset ? { agentPreset: resident.agentPreset, acpAgent: resident.agentPreset.replace(/^oneagents-acp-/, '') } : {}),
|
|
128
|
+
options: [], ...count(`resident:${resident.targetId}`),
|
|
129
|
+
}));
|
|
130
|
+
return { developing, published: [...publishedReleases, ...publishedResidents] };
|
|
131
|
+
}
|
|
132
|
+
export class AgentRegistry {
|
|
133
|
+
file;
|
|
134
|
+
state;
|
|
135
|
+
constructor(directory) {
|
|
136
|
+
if (!path.isAbsolute(directory))
|
|
137
|
+
throw new Error('stateDirectory must be absolute');
|
|
138
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
139
|
+
this.file = path.join(directory, 'agent-registry.json');
|
|
140
|
+
try {
|
|
141
|
+
this.state = fileSchema.parse(JSON.parse(readFileSync(this.file, 'utf8')));
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
if (error.code !== 'ENOENT')
|
|
145
|
+
throw error;
|
|
146
|
+
this.state = { version: 1, drafts: [], releases: [] };
|
|
147
|
+
}
|
|
148
|
+
this.assertUnique();
|
|
149
|
+
}
|
|
150
|
+
snapshot() {
|
|
151
|
+
return { drafts: this.state.drafts.map(item => structuredClone(item)), releases: this.state.releases.map(item => structuredClone(item)) };
|
|
152
|
+
}
|
|
153
|
+
/** New calls use a release when one owns the target, then a draft, then an already resident role. */
|
|
154
|
+
admit(target) {
|
|
155
|
+
const release = this.state.releases.find(item => item.targetId === target.targetId);
|
|
156
|
+
if (release)
|
|
157
|
+
return { agentId: `release:${release.releaseName}`, name: release.releaseName, phase: 'published', channel: 'formal' };
|
|
158
|
+
const draft = this.state.drafts.find(item => item.targetId === target.targetId);
|
|
159
|
+
if (draft)
|
|
160
|
+
return { agentId: draft.agentId, name: draft.name, phase: 'developing', channel: 'trial' };
|
|
161
|
+
if (target.kind === 'resident_agent')
|
|
162
|
+
return { agentId: `resident:${target.targetId}`, name: target.name, phase: 'published', channel: 'formal' };
|
|
163
|
+
}
|
|
164
|
+
create(input) {
|
|
165
|
+
const parsed = this.parse(draftInputSchema, input);
|
|
166
|
+
if (this.state.drafts.some(item => item.name === parsed.name))
|
|
167
|
+
throw new AgentRegistryError('An agent draft with this name already exists', 'conflict');
|
|
168
|
+
const draft = { agentId: `agt-${randomUUID()}`, name: parsed.name, acpAgent: parsed.acpAgent, options: orderAgentOptions(parsed.options), updatedAt: new Date().toISOString(),
|
|
169
|
+
...(parsed.roleId ? { roleId: parsed.roleId } : {}), ...(parsed.targetId ? { targetId: parsed.targetId } : {}), ...(parsed.modeId ? { modeId: parsed.modeId } : {}) };
|
|
170
|
+
this.commit({ ...this.state, drafts: [...this.state.drafts, draft] });
|
|
171
|
+
return structuredClone(draft);
|
|
172
|
+
}
|
|
173
|
+
update(agentId, input) {
|
|
174
|
+
const parsed = this.parse(draftPatchSchema, input);
|
|
175
|
+
const current = this.draft(agentId);
|
|
176
|
+
const next = { ...current, ...(parsed.name ? { name: parsed.name } : {}), ...(parsed.acpAgent ? { acpAgent: parsed.acpAgent } : {}),
|
|
177
|
+
...(parsed.roleId ? { roleId: parsed.roleId } : {}), ...(parsed.targetId ? { targetId: parsed.targetId } : {}),
|
|
178
|
+
...(parsed.modeId ? { modeId: parsed.modeId } : {}), ...(parsed.options ? { options: orderAgentOptions(parsed.options) } : {}), updatedAt: new Date().toISOString() };
|
|
179
|
+
if (this.state.drafts.some(item => item.agentId !== agentId && item.name === next.name))
|
|
180
|
+
throw new AgentRegistryError('An agent draft with this name already exists', 'conflict');
|
|
181
|
+
this.commit({ ...this.state, drafts: this.state.drafts.map(item => item.agentId === agentId ? next : item) });
|
|
182
|
+
return structuredClone(next);
|
|
183
|
+
}
|
|
184
|
+
/** Copy the draft into a callable name. The draft remains, and its target moves to the release. */
|
|
185
|
+
publish(agentId, input) {
|
|
186
|
+
const parsed = this.parse(publishInputSchema, input);
|
|
187
|
+
const draft = this.draft(agentId);
|
|
188
|
+
const existing = this.state.releases.find(item => item.releaseName === parsed.releaseName);
|
|
189
|
+
if (existing && !parsed.replace)
|
|
190
|
+
throw new AgentRegistryError(`Published name "${parsed.releaseName}" already exists`, 'conflict');
|
|
191
|
+
const release = { releaseName: parsed.releaseName, sourceAgentId: draft.agentId, ...(draft.acpAgent ? { acpAgent: draft.acpAgent } : {}),
|
|
192
|
+
...(draft.agentPreset ? { agentPreset: draft.agentPreset } : {}), ...(draft.provider ? { provider: draft.provider, model: draft.model } : {}), options: orderAgentOptions(draft.options), publishedAt: new Date().toISOString(),
|
|
193
|
+
...(draft.roleId ? { roleId: draft.roleId } : {}), ...(draft.targetId ? { targetId: draft.targetId } : {}), ...(draft.modeId ? { modeId: draft.modeId } : {}),
|
|
194
|
+
...(draft.source ? { source: { ...draft.source } } : {}), ...(draft.description ? { description: draft.description } : {}) };
|
|
195
|
+
const opened = { ...draft, updatedAt: release.publishedAt };
|
|
196
|
+
delete opened.targetId;
|
|
197
|
+
this.commit({ ...this.state, drafts: this.state.drafts.map(item => item.agentId === agentId ? opened : item),
|
|
198
|
+
releases: [...this.state.releases.filter(item => item.releaseName !== parsed.releaseName), release] });
|
|
199
|
+
return structuredClone(release);
|
|
200
|
+
}
|
|
201
|
+
/** The draft registered from this agents/*.md file for this runtime: an ACP agent name or a DSH-native preset. */
|
|
202
|
+
pathDraft(file, runtime) {
|
|
203
|
+
const found = this.state.drafts.find(item => item.source?.file === file && (item.acpAgent ?? item.agentPreset) === runtime);
|
|
204
|
+
return found && structuredClone(found);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Create or refresh the draft for one agents/*.md file on one runtime. The file and runtime identify the draft, so
|
|
208
|
+
* registering the same path again updates it in place and keeps its tasks, while another runtime gets its own draft.
|
|
209
|
+
* A different draft already using the name is a conflict.
|
|
210
|
+
*/
|
|
211
|
+
registerPathDraft(input) {
|
|
212
|
+
const parsed = this.parse(z.object({ name: callName, targetId, source: agentSourceSchema, description: description.optional(),
|
|
213
|
+
acpAgent: acpAgentName.optional(), agentPreset: targetId.optional(), provider: targetId.optional(), model: optionValue.optional() }).strict()
|
|
214
|
+
.refine(value => (value.acpAgent === undefined) !== (value.agentPreset === undefined) && (value.provider === undefined) === (value.model === undefined)
|
|
215
|
+
&& !(value.acpAgent && value.provider), 'Name either an ACP agent or a DSH-native preset'), input);
|
|
216
|
+
const runtime = parsed.acpAgent ?? parsed.agentPreset;
|
|
217
|
+
const current = this.state.drafts.find(item => item.source?.file === parsed.source.file && (item.acpAgent ?? item.agentPreset) === runtime);
|
|
218
|
+
if (this.state.drafts.some(item => item !== current && item.name === parsed.name))
|
|
219
|
+
throw new AgentRegistryError(`An agent draft named "${parsed.name}" already exists`, 'conflict');
|
|
220
|
+
const { acpAgent: _acp, agentPreset: _preset, provider: _provider, model: _model, description: _description, ...kept } = current ?? { agentId: `agt-${randomUUID()}`, options: [] };
|
|
221
|
+
const next = { ...kept, name: parsed.name, targetId: parsed.targetId, source: parsed.source, updatedAt: new Date().toISOString(),
|
|
222
|
+
...(parsed.acpAgent ? { acpAgent: parsed.acpAgent } : { agentPreset: parsed.agentPreset }),
|
|
223
|
+
...(parsed.provider ? { provider: parsed.provider, model: parsed.model } : {}), ...(parsed.description ? { description: parsed.description } : {}) };
|
|
224
|
+
this.commit({ ...this.state, drafts: current ? this.state.drafts.map(item => item === current ? next : item) : [...this.state.drafts, next] });
|
|
225
|
+
return structuredClone(next);
|
|
226
|
+
}
|
|
227
|
+
draft(agentId) {
|
|
228
|
+
const found = this.state.drafts.find(item => item.agentId === agentId);
|
|
229
|
+
if (!found)
|
|
230
|
+
throw new AgentRegistryError('Agent draft not found', 'not_found');
|
|
231
|
+
return found;
|
|
232
|
+
}
|
|
233
|
+
parse(schema, input) {
|
|
234
|
+
const result = schema.safeParse(input);
|
|
235
|
+
if (!result.success)
|
|
236
|
+
throw new AgentRegistryError('Invalid agent settings', 'invalid');
|
|
237
|
+
return result.data;
|
|
238
|
+
}
|
|
239
|
+
assertUnique() {
|
|
240
|
+
for (const [label, values] of [['draft', this.state.drafts.map(item => item.agentId)], ['draft name', this.state.drafts.map(item => item.name)], ['release', this.state.releases.map(item => item.releaseName)]]) {
|
|
241
|
+
if (new Set(values).size !== values.length)
|
|
242
|
+
throw new Error(`Duplicate agent registry ${label}`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
commit(next) {
|
|
246
|
+
fileSchema.parse(next);
|
|
247
|
+
const temp = `${this.file}.${randomUUID()}.tmp`;
|
|
248
|
+
const fd = openSync(temp, 'wx', 0o600);
|
|
249
|
+
try {
|
|
250
|
+
try {
|
|
251
|
+
writeFileSync(fd, JSON.stringify(next));
|
|
252
|
+
fsyncSync(fd);
|
|
253
|
+
}
|
|
254
|
+
finally {
|
|
255
|
+
closeSync(fd);
|
|
256
|
+
}
|
|
257
|
+
renameSync(temp, this.file);
|
|
258
|
+
const dir = openSync(path.dirname(this.file), 'r');
|
|
259
|
+
try {
|
|
260
|
+
fsyncSync(dir);
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
closeSync(dir);
|
|
264
|
+
}
|
|
265
|
+
this.state = next;
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
try {
|
|
269
|
+
unlinkSync(temp);
|
|
270
|
+
}
|
|
271
|
+
catch { /* The failed temp file is already gone. */ }
|
|
272
|
+
throw error;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Upper bound for one human-reviewed slide script; the page count itself follows the frozen script (N pages). */
|
|
3
|
+
export declare const MAX_HUMAN_REVIEW_SLIDES = 200;
|
|
4
|
+
export declare const humanReviewPreviewSchema: z.ZodObject<{
|
|
5
|
+
title: z.ZodString;
|
|
6
|
+
slides: z.ZodArray<z.ZodObject<{
|
|
7
|
+
title: z.ZodString;
|
|
8
|
+
message: z.ZodString;
|
|
9
|
+
body: z.ZodArray<z.ZodString>;
|
|
10
|
+
visual: z.ZodString;
|
|
11
|
+
sources: z.ZodArray<z.ZodString>;
|
|
12
|
+
facts: z.ZodArray<z.ZodString>;
|
|
13
|
+
notes: z.ZodString;
|
|
14
|
+
}, z.core.$strict>>;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
declare const reviewPreviewSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
17
|
+
title: z.ZodString;
|
|
18
|
+
slides: z.ZodArray<z.ZodObject<{
|
|
19
|
+
title: z.ZodString;
|
|
20
|
+
message: z.ZodString;
|
|
21
|
+
body: z.ZodArray<z.ZodString>;
|
|
22
|
+
visual: z.ZodString;
|
|
23
|
+
sources: z.ZodArray<z.ZodString>;
|
|
24
|
+
facts: z.ZodArray<z.ZodString>;
|
|
25
|
+
notes: z.ZodString;
|
|
26
|
+
}, z.core.$strict>>;
|
|
27
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
28
|
+
kind: z.ZodLiteral<"markdown">;
|
|
29
|
+
title: z.ZodString;
|
|
30
|
+
markdown: z.ZodString;
|
|
31
|
+
reportPath: z.ZodString;
|
|
32
|
+
slides: z.ZodArray<z.ZodNever>;
|
|
33
|
+
}, z.core.$strict>]>;
|
|
34
|
+
export type HumanReviewPreview = z.infer<typeof reviewPreviewSchema>;
|
|
35
|
+
export declare const humanReviewActorSchema: z.ZodObject<{
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
38
|
+
source: z.ZodLiteral<"1agents-web">;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
export type HumanReviewActor = z.infer<typeof humanReviewActorSchema>;
|
|
41
|
+
export declare const humanReviewDecisionSchema: z.ZodObject<{
|
|
42
|
+
clientRequestId: z.ZodString;
|
|
43
|
+
action: z.ZodEnum<{
|
|
44
|
+
cancel: "cancel";
|
|
45
|
+
comment: "comment";
|
|
46
|
+
approve: "approve";
|
|
47
|
+
changes_requested: "changes_requested";
|
|
48
|
+
}>;
|
|
49
|
+
revision: z.ZodString;
|
|
50
|
+
digest: z.ZodString;
|
|
51
|
+
note: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strict>;
|
|
53
|
+
export type HumanReviewDecisionInput = z.infer<typeof humanReviewDecisionSchema>;
|
|
54
|
+
export type HumanReviewStatus = 'pending' | 'approved' | 'changes_requested' | 'superseded' | 'canceled';
|
|
55
|
+
export interface HumanReviewDecision extends HumanReviewDecisionInput {
|
|
56
|
+
decisionId: string;
|
|
57
|
+
actor: HumanReviewActor;
|
|
58
|
+
at: string;
|
|
59
|
+
}
|
|
60
|
+
export interface HumanReviewRequest {
|
|
61
|
+
reviewId: string;
|
|
62
|
+
jobId: string;
|
|
63
|
+
attemptId: string;
|
|
64
|
+
stage: 'summary' | 'report';
|
|
65
|
+
authorJobId: string;
|
|
66
|
+
authorAttemptId: string;
|
|
67
|
+
authorSessionId: string;
|
|
68
|
+
revision: string;
|
|
69
|
+
digest: string;
|
|
70
|
+
title: string;
|
|
71
|
+
preview: HumanReviewPreview;
|
|
72
|
+
reviewerId: string;
|
|
73
|
+
status: HumanReviewStatus;
|
|
74
|
+
createdAt: string;
|
|
75
|
+
updatedAt: string;
|
|
76
|
+
history: HumanReviewDecision[];
|
|
77
|
+
resume?: {
|
|
78
|
+
status: 'pending' | 'applied';
|
|
79
|
+
action: Exclude<HumanReviewDecisionInput['action'], 'comment'>;
|
|
80
|
+
decisionId: string;
|
|
81
|
+
appliedAt?: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export type HumanReviewCreateInput = Omit<HumanReviewRequest, 'reviewId' | 'status' | 'history' | 'resume' | 'createdAt' | 'updatedAt'> & {
|
|
85
|
+
reviewId?: string;
|
|
86
|
+
};
|
|
87
|
+
export interface HumanReviewBinding {
|
|
88
|
+
attemptId: string;
|
|
89
|
+
revision: string;
|
|
90
|
+
digest: string;
|
|
91
|
+
}
|
|
92
|
+
export declare class HumanReviewError extends Error {
|
|
93
|
+
readonly code: 'forbidden' | 'version_conflict' | 'already_decided' | 'idempotency_conflict';
|
|
94
|
+
constructor(code: 'forbidden' | 'version_conflict' | 'already_decided' | 'idempotency_conflict', message: string);
|
|
95
|
+
}
|
|
96
|
+
export declare function createHumanReview(input: HumanReviewCreateInput, at?: string): HumanReviewRequest;
|
|
97
|
+
/** A replay may acknowledge an old durable decision but cannot schedule it a second time. */
|
|
98
|
+
export declare function decideHumanReview(request: HumanReviewRequest, input: HumanReviewDecisionInput, actorInput: HumanReviewActor, current: HumanReviewBinding, at?: string): {
|
|
99
|
+
review: HumanReviewRequest;
|
|
100
|
+
decision: HumanReviewDecision;
|
|
101
|
+
idempotent: boolean;
|
|
102
|
+
};
|
|
103
|
+
export declare function markHumanReviewApplied(request: HumanReviewRequest, decisionId: string, at?: string): HumanReviewRequest;
|
|
104
|
+
export declare function supersedeHumanReview(request: HumanReviewRequest, at?: string): HumanReviewRequest;
|
|
105
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** Version-bound human decisions. Callers persist each returned value before scheduling work. */
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
const id = z.string().trim().min(1).max(512);
|
|
5
|
+
const sha256 = z.string().regex(/^[a-f0-9]{64}$/);
|
|
6
|
+
/** Upper bound for one human-reviewed slide script; the page count itself follows the frozen script (N pages). */
|
|
7
|
+
export const MAX_HUMAN_REVIEW_SLIDES = 200;
|
|
8
|
+
export const humanReviewPreviewSchema = z.object({
|
|
9
|
+
title: z.string().min(1),
|
|
10
|
+
slides: z.array(z.object({ title: z.string().min(1), message: z.string(), body: z.array(z.string()),
|
|
11
|
+
visual: z.string(), sources: z.array(z.string()).min(1), facts: z.array(z.string()).min(1), notes: z.string() }).strict()).min(1).max(MAX_HUMAN_REVIEW_SLIDES),
|
|
12
|
+
}).strict();
|
|
13
|
+
const markdownReviewPreviewSchema = z.object({
|
|
14
|
+
kind: z.literal('markdown'), title: z.string().min(1), markdown: z.string().min(1).max(256 * 1024),
|
|
15
|
+
reportPath: z.string().min(1), slides: z.array(z.never()).length(0),
|
|
16
|
+
}).strict();
|
|
17
|
+
const reviewPreviewSchema = z.union([humanReviewPreviewSchema, markdownReviewPreviewSchema]);
|
|
18
|
+
export const humanReviewActorSchema = z.object({ id, displayName: z.string().trim().min(1).max(200).optional(), source: z.literal('1agents-web') }).strict();
|
|
19
|
+
export const humanReviewDecisionSchema = z.object({
|
|
20
|
+
clientRequestId: id, action: z.enum(['comment', 'approve', 'changes_requested', 'cancel']),
|
|
21
|
+
revision: id, digest: sha256, note: z.string().trim().max(16000).optional(),
|
|
22
|
+
}).strict().superRefine((input, ctx) => {
|
|
23
|
+
if (['comment', 'changes_requested'].includes(input.action) && !input.note) {
|
|
24
|
+
ctx.addIssue({ code: 'custom', path: ['note'], message: 'Comment and changes_requested require a note' });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export class HumanReviewError extends Error {
|
|
28
|
+
code;
|
|
29
|
+
constructor(code, message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.code = code;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const timestamp = () => new Date().toISOString();
|
|
35
|
+
export function createHumanReview(input, at = timestamp()) {
|
|
36
|
+
const parsed = z.object({ reviewId: id.optional(), jobId: id, attemptId: id, stage: z.enum(['summary', 'report']),
|
|
37
|
+
authorJobId: id, authorAttemptId: id, authorSessionId: id, revision: id, digest: sha256, title: z.string().min(1),
|
|
38
|
+
preview: reviewPreviewSchema, reviewerId: id }).strict().parse(input);
|
|
39
|
+
return { ...parsed, reviewId: parsed.reviewId ?? randomUUID(), status: 'pending', createdAt: at, updatedAt: at, history: [] };
|
|
40
|
+
}
|
|
41
|
+
/** A replay may acknowledge an old durable decision but cannot schedule it a second time. */
|
|
42
|
+
export function decideHumanReview(request, input, actorInput, current, at = timestamp()) {
|
|
43
|
+
const actor = humanReviewActorSchema.parse(actorInput), decisionInput = humanReviewDecisionSchema.parse(input);
|
|
44
|
+
if (actor.id !== request.reviewerId)
|
|
45
|
+
throw new HumanReviewError('forbidden', 'Review is assigned to another person');
|
|
46
|
+
if (decisionInput.revision !== request.revision || decisionInput.digest !== request.digest) {
|
|
47
|
+
throw new HumanReviewError('version_conflict', 'Decision does not match the displayed review version');
|
|
48
|
+
}
|
|
49
|
+
const replay = request.history.find(item => item.clientRequestId === decisionInput.clientRequestId);
|
|
50
|
+
if (replay) {
|
|
51
|
+
if (replay.actor.id !== actor.id || replay.actor.source !== actor.source || replay.action !== decisionInput.action
|
|
52
|
+
|| replay.revision !== decisionInput.revision || replay.digest !== decisionInput.digest || replay.note !== decisionInput.note) {
|
|
53
|
+
throw new HumanReviewError('idempotency_conflict', 'clientRequestId conflicts with a recorded decision');
|
|
54
|
+
}
|
|
55
|
+
return { review: structuredClone(request), decision: structuredClone(replay), idempotent: true };
|
|
56
|
+
}
|
|
57
|
+
if (request.attemptId !== current.attemptId || request.revision !== current.revision || request.digest !== current.digest) {
|
|
58
|
+
throw new HumanReviewError('version_conflict', 'This review has been replaced by a newer execution or content version');
|
|
59
|
+
}
|
|
60
|
+
if (request.status !== 'pending')
|
|
61
|
+
throw new HumanReviewError('already_decided', 'This review is no longer pending');
|
|
62
|
+
const review = structuredClone(request), decision = { ...decisionInput, decisionId: randomUUID(), actor, at };
|
|
63
|
+
review.history.push(decision);
|
|
64
|
+
review.updatedAt = at;
|
|
65
|
+
if (decision.action !== 'comment') {
|
|
66
|
+
review.status = { approve: 'approved', changes_requested: 'changes_requested', cancel: 'canceled' }[decision.action];
|
|
67
|
+
review.resume = { status: 'pending', action: decision.action, decisionId: decision.decisionId };
|
|
68
|
+
}
|
|
69
|
+
return { review, decision, idempotent: false };
|
|
70
|
+
}
|
|
71
|
+
export function markHumanReviewApplied(request, decisionId, at = timestamp()) {
|
|
72
|
+
if (!request.resume || request.resume.decisionId !== decisionId)
|
|
73
|
+
throw new HumanReviewError('version_conflict', 'Continuation does not match the recorded decision');
|
|
74
|
+
const review = structuredClone(request);
|
|
75
|
+
if (review.resume.status === 'pending') {
|
|
76
|
+
review.resume.status = 'applied';
|
|
77
|
+
review.resume.appliedAt = at;
|
|
78
|
+
review.updatedAt = at;
|
|
79
|
+
}
|
|
80
|
+
return review;
|
|
81
|
+
}
|
|
82
|
+
export function supersedeHumanReview(request, at = timestamp()) {
|
|
83
|
+
const review = structuredClone(request);
|
|
84
|
+
if (review.status === 'pending') {
|
|
85
|
+
review.status = 'superseded';
|
|
86
|
+
review.updatedAt = at;
|
|
87
|
+
}
|
|
88
|
+
return review;
|
|
89
|
+
}
|