@1agents/acp-service 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -13
- package/dist/bin/a2a.js +6 -2
- package/dist/bin/acp-service.js +25 -1
- package/dist/bin/process.d.ts +4 -0
- package/dist/bin/process.js +57 -0
- package/dist/bin/roles.js +21 -18
- 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 +7 -2
- package/dist/src/a2a/executor.js +127 -60
- package/dist/src/a2a/gateway.d.ts +581 -10
- package/dist/src/a2a/gateway.js +1018 -95
- 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 +27 -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 +46 -6
- package/dist/src/a2a/types.js +4 -6
- 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/ppt-delivery.d.ts +0 -5
- package/dist/src/execution/ppt-delivery.js +0 -26
- 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 +64 -5
- package/dist/src/execution/targets.js +58 -7
- 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/roles/index.d.ts +1 -1
- package/dist/src/roles/index.js +1 -1
- package/dist/src/roles/skills.d.ts +27 -58
- package/dist/src/roles/skills.js +89 -404
- 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 +4 -2
- package/skills/acp-service/references/a2a.md +18 -6
- package/skills/acp-service/references/dsh.md +2 -0
- package/skills/acp-service/references/roles-and-tasks.md +10 -10
- 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
package/vendor/dsh/index.js
CHANGED
|
@@ -7,6 +7,15 @@ import { discoverPresets } from './discovery.js';
|
|
|
7
7
|
import { NativeSessions } from './imports.js';
|
|
8
8
|
import { acquireService, resolveServiceOptions } from './service-process.js';
|
|
9
9
|
import { mountDshA2A } from './a2a.js';
|
|
10
|
+
import { createWorkbenchProcessClient } from './process-requests.js';
|
|
11
|
+
import { selectAcpRoute } from './preset-route.js';
|
|
12
|
+
import { registerNativeApprovals } from './native-approvals.js';
|
|
13
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
14
|
+
import { WORKBENCH_UI_PATH } from '@1agents/acp-service/a2a';
|
|
15
|
+
import { REVIEW_SUBMIT_PATH, ReviewHandBack, SUBMIT_DESCRIPTION, SUBMIT_TOOL, SUMMARY_DESCRIPTION } from './review.js';
|
|
16
|
+
import { workbenchHandler } from './workbench.js';
|
|
17
|
+
import { createTicketGateway, runTicketTool, ticketTools } from './ticket-tools.js';
|
|
18
|
+
import { TICKET_PATH } from './ticket-spec.js';
|
|
10
19
|
export { name, inject } from '@1agents/acp-service';
|
|
11
20
|
export async function apply(ctx, input = {}) {
|
|
12
21
|
const homePath = ctx.get('dshHomePath');
|
|
@@ -30,8 +39,12 @@ export async function apply(ctx, input = {}) {
|
|
|
30
39
|
const diagnosticOwner = await openDiagnostics(resolve(input.diagnosticsDirectory ?? join(config.stateDirectory, 'diagnostics')));
|
|
31
40
|
const { diagnostics } = diagnosticOwner;
|
|
32
41
|
let closeA2A;
|
|
33
|
-
const
|
|
42
|
+
const processRequests = input.a2a?.workbench ? createWorkbenchProcessClient(input.a2a.workbench) : undefined;
|
|
43
|
+
const adapter = new AcpAdapter(ctx, config, diagnostics, processRequests);
|
|
34
44
|
ctx.effect(() => ctx.llm.registerAdapter(['1agents-acp'], adapter));
|
|
45
|
+
// A Cordis listener is released with this plugin's fiber.
|
|
46
|
+
if (processRequests)
|
|
47
|
+
registerNativeApprovals(ctx, processRequests);
|
|
35
48
|
const nativeSessions = new NativeSessions(ctx, adapter, config);
|
|
36
49
|
ctx.provide('oneagentsAcpSessions', nativeSessions);
|
|
37
50
|
ctx.effect(() => async () => {
|
|
@@ -95,6 +108,45 @@ export async function apply(ctx, input = {}) {
|
|
|
95
108
|
});
|
|
96
109
|
ctx.effect(() => dispose);
|
|
97
110
|
}
|
|
98
|
-
|
|
99
|
-
|
|
111
|
+
// A preset chosen on a session that is already running is composed onto its
|
|
112
|
+
// live agent instead of creating one, so the route the preset proposes is
|
|
113
|
+
// never recorded and the next step rejects it. Record it here.
|
|
114
|
+
ctx.on('agent-preset/selected', (sessionId, agentPreset) => {
|
|
115
|
+
void selectAcpRoute(ctx, sessionId, agentPreset, presets.map(preset => preset.id));
|
|
116
|
+
});
|
|
117
|
+
if (input.a2a) {
|
|
118
|
+
const review = await ReviewHandBack.open(join(home, 'plugins', '1agents-acp', 'review.secret'), input.a2a.workbench);
|
|
119
|
+
ctx.effect(() => ctx.webServer.register({ kind: 'prefix', path: WORKBENCH_UI_PATH, handler: workbenchHandler(ctx, { workbench: input.a2a.workbench, host: () => review.host }) }));
|
|
120
|
+
ctx.effect(() => ctx.webServer.register({ kind: 'exact', path: REVIEW_SUBMIT_PATH, handler: review.handler }));
|
|
121
|
+
ctx.effect(() => ctx.tools.register(defineTool({
|
|
122
|
+
name: SUBMIT_TOOL, description: SUBMIT_DESCRIPTION,
|
|
123
|
+
parameters: { summary: { type: 'string', required: true, description: SUMMARY_DESCRIPTION } },
|
|
124
|
+
output: { schema: { type: 'object', additionalProperties: false, properties: { message: { type: 'string', required: true } } },
|
|
125
|
+
render: (_args, value) => [{ type: 'text', text: value.message }] },
|
|
126
|
+
async execute(args, exec) {
|
|
127
|
+
if (!exec.agent)
|
|
128
|
+
throw new Error(`${SUBMIT_TOOL} requires an owning agent session`);
|
|
129
|
+
return { message: await review.submit(exec.agent.id, args.summary) };
|
|
130
|
+
},
|
|
131
|
+
})));
|
|
132
|
+
// The executor's task ticket lives on the gateway; native agents handle it through these tools.
|
|
133
|
+
if (input.a2a.workbench) {
|
|
134
|
+
const gateway = createTicketGateway(input.a2a.workbench);
|
|
135
|
+
for (const tool of ticketTools(gateway))
|
|
136
|
+
ctx.effect(() => ctx.tools.register(tool));
|
|
137
|
+
// ACP agents call the same tools through their session's MCP server, which comes back here.
|
|
138
|
+
ctx.effect(() => ctx.webServer.register({ kind: 'exact', path: TICKET_PATH,
|
|
139
|
+
handler: review.ticketHandler((sessionId, tool, args) => runTicketTool(gateway, sessionId, tool, args, 'mcp')) }));
|
|
140
|
+
}
|
|
141
|
+
// ACP agents reach the same hand-back and ticket tools through a per-session MCP server. It is offered to every ACP
|
|
142
|
+
// session: the connection is opened once and reused, often before a turn binds the session to its A2A task or a
|
|
143
|
+
// person takes it over, so the tools themselves refuse a session that has no task.
|
|
144
|
+
const origin = `${ctx.webServer.protocol ?? 'http:'}//127.0.0.1:${ctx.webServer.port}`;
|
|
145
|
+
adapter.mcpServersFor = sessionId => review.host ? [review.mcpServer(sessionId, origin)] : [];
|
|
146
|
+
closeA2A = await mountDshA2A(ctx, input.a2a, join(home, 'plugins', '1agents-acp', 'a2a'), diagnostics, {
|
|
147
|
+
release: sessionId => adapter.releaseSession(sessionId),
|
|
148
|
+
delete: sessionId => adapter.deleteSession(sessionId),
|
|
149
|
+
status: sessionId => adapter.sessionStatus(sessionId),
|
|
150
|
+
}, host => { review.host = host; });
|
|
151
|
+
}
|
|
100
152
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { ProcessRequestClient } from './process-requests.js';
|
|
3
|
+
/** Runs ahead of the host UI answerer for every agent; agents outside an A2A task pass straight through. */
|
|
4
|
+
export declare function registerNativeApprovals(ctx: Context, client: ProcessRequestClient): () => void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH's own tool approvals inside an A2A task go to the gateway workbench as process requests, like ACP tool
|
|
3
|
+
* approvals. The workbench is the only place to answer them: the host UI keeps its prompt for the request's
|
|
4
|
+
* whole lifetime and could not withdraw it once the workbench answered. Without a reachable workbench, the
|
|
5
|
+
* host UI answers as before.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
8
|
+
import { currentA2AExecution } from '@1agents/acp-service/a2a';
|
|
9
|
+
function outcomeOf(view) {
|
|
10
|
+
if (view.status !== 'answered')
|
|
11
|
+
return 'cancelled';
|
|
12
|
+
return view.answer?.outcome === 'approved' ? 'allowed-once' : view.answer?.outcome === 'rejected' ? 'rejected' : 'cancelled';
|
|
13
|
+
}
|
|
14
|
+
/** Runs ahead of the host UI answerer for every agent; agents outside an A2A task pass straight through. */
|
|
15
|
+
export function registerNativeApprovals(ctx, client) {
|
|
16
|
+
return ctx.on('approval/request', async (req, next) => {
|
|
17
|
+
const binding = currentA2AExecution(req.agent.id);
|
|
18
|
+
// ACP presets open their own request in the adapter, and that request's host-UI answer passes through here.
|
|
19
|
+
if (!binding || String(req.agent.session.header.agentPreset ?? '').startsWith('oneagents-acp-'))
|
|
20
|
+
return next();
|
|
21
|
+
const signal = req.signal ?? new AbortController().signal;
|
|
22
|
+
const reason = req.reason ?? req.displayReason?.en ?? '';
|
|
23
|
+
// The call id keeps each call its own request; without one, a later identical command must not reuse an earlier answer.
|
|
24
|
+
const body = [req.callId ?? randomUUID(), req.toolName, reason];
|
|
25
|
+
const requestId = `prc-${createHash('sha256').update(JSON.stringify([binding.jobId, binding.attemptId, 'permission', body])).digest('hex').slice(0, 32)}`;
|
|
26
|
+
let opened;
|
|
27
|
+
try {
|
|
28
|
+
opened = await client.open({ requestId, jobId: binding.jobId, attemptId: binding.attemptId, sessionId: req.agent.id,
|
|
29
|
+
kind: 'permission', toolTitle: req.toolName.slice(0, 500), toolDetail: reason.slice(0, 16 * 1024) });
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return next();
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
return outcomeOf(await client.wait({ jobId: binding.jobId, requestId: opened.requestId, signal }));
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
void client.report({ jobId: binding.jobId, requestId: opened.requestId, clientRequestId: `dsh-cancel:${opened.requestId}`, outcome: 'cancelled' }).catch(() => { });
|
|
39
|
+
if (signal.aborted)
|
|
40
|
+
return 'cancelled';
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}, { prepend: true });
|
|
44
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The route a session records to run its ACP Agent.
|
|
3
|
+
*
|
|
4
|
+
* A session that starts with an ACP preset gets this route when its agent is
|
|
5
|
+
* created (see preset.ts). A session that only later switches to an ACP preset
|
|
6
|
+
* is recomposed instead: its agent already exists, so the creation event never
|
|
7
|
+
* fires and the route stays unrecorded. The next step then prepares the
|
|
8
|
+
* default model and rejects the ACP route the preset proposes.
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
+
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
12
|
+
/** The provider a session runs its ACP Agent under. */
|
|
13
|
+
export declare const ACP_PROVIDER = "1agents-acp";
|
|
14
|
+
/** One recorded model choice. */
|
|
15
|
+
export interface ModelSelection {
|
|
16
|
+
provider: string;
|
|
17
|
+
model: string;
|
|
18
|
+
}
|
|
19
|
+
/** The part of an agent that records a model selection. */
|
|
20
|
+
export interface ModelSelectionApi {
|
|
21
|
+
select(selection: ModelSelection): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The model selection API of a live agent, when the host provides one.
|
|
25
|
+
*
|
|
26
|
+
* Current DSH records the route on the agent; older DSH agents have no such
|
|
27
|
+
* API and take the route from the request waterfall instead. The host's own
|
|
28
|
+
* types do not declare the API, so it is read structurally.
|
|
29
|
+
*/
|
|
30
|
+
export declare function modelSelectionOf(agent: unknown): ModelSelectionApi | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The ACP Agent a preset id names, when this plugin registered that preset.
|
|
33
|
+
* @param agentPreset - Selected preset id.
|
|
34
|
+
* @param known - ACP Agent names this plugin registered presets for.
|
|
35
|
+
* @returns The ACP Agent name, or undefined for another plugin's preset.
|
|
36
|
+
*/
|
|
37
|
+
export declare function acpAgentOf(agentPreset: string, known: readonly string[]): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Record the ACP route of a session whose preset was just selected.
|
|
40
|
+
*
|
|
41
|
+
* The route is written after the preset event settles, so the session is not
|
|
42
|
+
* written while its own event is still being dispatched.
|
|
43
|
+
* @param ctx - Host context.
|
|
44
|
+
* @param sessionId - Session whose preset changed.
|
|
45
|
+
* @param agentPreset - Selected preset id.
|
|
46
|
+
* @param known - ACP Agent names this plugin registered presets for.
|
|
47
|
+
* @returns Whether the route was recorded.
|
|
48
|
+
*/
|
|
49
|
+
export declare function selectAcpRoute(ctx: Context, sessionId: SessionId, agentPreset: string, known: readonly string[]): Promise<boolean>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** The provider a session runs its ACP Agent under. */
|
|
2
|
+
export const ACP_PROVIDER = '1agents-acp';
|
|
3
|
+
/**
|
|
4
|
+
* The model selection API of a live agent, when the host provides one.
|
|
5
|
+
*
|
|
6
|
+
* Current DSH records the route on the agent; older DSH agents have no such
|
|
7
|
+
* API and take the route from the request waterfall instead. The host's own
|
|
8
|
+
* types do not declare the API, so it is read structurally.
|
|
9
|
+
*/
|
|
10
|
+
export function modelSelectionOf(agent) {
|
|
11
|
+
const model = agent?.model;
|
|
12
|
+
if (!model || typeof model.select !== 'function')
|
|
13
|
+
return undefined;
|
|
14
|
+
return { select: (selection) => model.select(selection) };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The ACP Agent a preset id names, when this plugin registered that preset.
|
|
18
|
+
* @param agentPreset - Selected preset id.
|
|
19
|
+
* @param known - ACP Agent names this plugin registered presets for.
|
|
20
|
+
* @returns The ACP Agent name, or undefined for another plugin's preset.
|
|
21
|
+
*/
|
|
22
|
+
export function acpAgentOf(agentPreset, known) {
|
|
23
|
+
return known.find(name => agentPreset === `oneagents-acp-${name}`);
|
|
24
|
+
}
|
|
25
|
+
/** The live agent of a session, without resuming or creating one. */
|
|
26
|
+
function liveAgent(ctx, sessionId) {
|
|
27
|
+
const agents = ctx.agents;
|
|
28
|
+
return agents?.get?.(sessionId);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Record the ACP route of a session whose preset was just selected.
|
|
32
|
+
*
|
|
33
|
+
* The route is written after the preset event settles, so the session is not
|
|
34
|
+
* written while its own event is still being dispatched.
|
|
35
|
+
* @param ctx - Host context.
|
|
36
|
+
* @param sessionId - Session whose preset changed.
|
|
37
|
+
* @param agentPreset - Selected preset id.
|
|
38
|
+
* @param known - ACP Agent names this plugin registered presets for.
|
|
39
|
+
* @returns Whether the route was recorded.
|
|
40
|
+
*/
|
|
41
|
+
export async function selectAcpRoute(ctx, sessionId, agentPreset, known) {
|
|
42
|
+
const acpAgent = acpAgentOf(agentPreset, known);
|
|
43
|
+
if (acpAgent === undefined)
|
|
44
|
+
return false;
|
|
45
|
+
const model = modelSelectionOf(liveAgent(ctx, sessionId));
|
|
46
|
+
if (model === undefined)
|
|
47
|
+
return false;
|
|
48
|
+
await new Promise(resolve => setTimeout(resolve, 0));
|
|
49
|
+
model.select({ provider: ACP_PROVIDER, model: acpAgent });
|
|
50
|
+
return true;
|
|
51
|
+
}
|
package/vendor/dsh/preset.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { ACP_PROVIDER, modelSelectionOf } from './preset-route.js';
|
|
1
2
|
export const name = 'oneagents-acp-preset';
|
|
2
3
|
export const inject = ['agents', 'llm'];
|
|
3
4
|
export function apply(ctx, config) {
|
|
4
5
|
if (!/^[a-z0-9_-]+$/i.test(config.agent))
|
|
5
6
|
throw new Error('Invalid ACP Agent name');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const route = { provider: ACP_PROVIDER, model: config.agent };
|
|
8
|
+
// Current DSH fixes each step's model before agent/request and rejects a later swap,
|
|
9
|
+
// so the route is recorded through agent.model.select() when the agent is created or resumed.
|
|
10
|
+
ctx.on('agent/created', ({ agent }) => {
|
|
11
|
+
modelSelectionOf(agent)?.select(route);
|
|
12
|
+
return undefined;
|
|
9
13
|
});
|
|
14
|
+
// Older DSH has no agent.model and still takes the route from agent/request; on current DSH
|
|
15
|
+
// the proposal already carries the selected route, so this keeps it and its other controls unchanged.
|
|
16
|
+
ctx.on('agent/request', async (_event, next) => ({ ...await next(), ...route }));
|
|
10
17
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Retry a process-slot probe without charging queue time against the handshake budget. */
|
|
2
|
+
export interface ProcessCapacityPending {
|
|
3
|
+
position: number;
|
|
4
|
+
waitedMs: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function noteProcessCapacity(sessionId: string, value: ProcessCapacityPending | undefined): void;
|
|
7
|
+
export declare function noteProcessReady(sessionId: string): void;
|
|
8
|
+
export declare function readProcessCapacity(sessionId: string): ProcessCapacityPending | undefined;
|
|
9
|
+
export declare function consumeProcessReady(sessionId: string): boolean;
|
|
10
|
+
export declare function noteSessionRestore(sessionId: string, method: 'session/load' | 'session/resume'): void;
|
|
11
|
+
export declare function readSessionRestore(sessionId: string): 'session/load' | 'session/resume' | undefined;
|
|
12
|
+
export declare function capacityPendingOf(error: unknown): ProcessCapacityPending | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Each pending probe returns immediately and does not start handshakeMs.
|
|
15
|
+
* A non-pending result is the attempt that owns the handshake budget.
|
|
16
|
+
*/
|
|
17
|
+
export declare function requestWhenAdmitted<T>(options: {
|
|
18
|
+
request: () => Promise<T>;
|
|
19
|
+
signal: AbortSignal;
|
|
20
|
+
isPending: (error: unknown) => ProcessCapacityPending | undefined;
|
|
21
|
+
onPending?: (pending: ProcessCapacityPending) => void;
|
|
22
|
+
cancel?: () => Promise<void>;
|
|
23
|
+
sleep?: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
24
|
+
pollMs?: number;
|
|
25
|
+
}): Promise<T>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** Retry a process-slot probe without charging queue time against the handshake budget. */
|
|
2
|
+
const noted = new Map();
|
|
3
|
+
const ready = new Set();
|
|
4
|
+
export function noteProcessCapacity(sessionId, value) {
|
|
5
|
+
if (!value)
|
|
6
|
+
noted.delete(sessionId);
|
|
7
|
+
else
|
|
8
|
+
noted.set(sessionId, value);
|
|
9
|
+
}
|
|
10
|
+
export function noteProcessReady(sessionId) {
|
|
11
|
+
noted.delete(sessionId);
|
|
12
|
+
ready.add(sessionId);
|
|
13
|
+
}
|
|
14
|
+
export function readProcessCapacity(sessionId) {
|
|
15
|
+
const value = noted.get(sessionId);
|
|
16
|
+
return value ? { ...value } : undefined;
|
|
17
|
+
}
|
|
18
|
+
export function consumeProcessReady(sessionId) {
|
|
19
|
+
return ready.delete(sessionId);
|
|
20
|
+
}
|
|
21
|
+
const restores = new Map();
|
|
22
|
+
export function noteSessionRestore(sessionId, method) {
|
|
23
|
+
restores.set(sessionId, method);
|
|
24
|
+
}
|
|
25
|
+
export function readSessionRestore(sessionId) {
|
|
26
|
+
return restores.get(sessionId);
|
|
27
|
+
}
|
|
28
|
+
export function capacityPendingOf(error) {
|
|
29
|
+
if (!error || typeof error !== 'object')
|
|
30
|
+
return;
|
|
31
|
+
const value = error;
|
|
32
|
+
if (value.code !== -32010 && value.message !== 'CAPACITY_PENDING')
|
|
33
|
+
return;
|
|
34
|
+
const data = value.data;
|
|
35
|
+
if (!data || typeof data !== 'object')
|
|
36
|
+
return;
|
|
37
|
+
const pending = data;
|
|
38
|
+
if (typeof pending.position !== 'number' || !Number.isSafeInteger(pending.position) || pending.position < 1)
|
|
39
|
+
return;
|
|
40
|
+
if (typeof pending.waitedMs !== 'number' || !Number.isFinite(pending.waitedMs) || pending.waitedMs < 0)
|
|
41
|
+
return;
|
|
42
|
+
return { position: pending.position, waitedMs: pending.waitedMs };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Each pending probe returns immediately and does not start handshakeMs.
|
|
46
|
+
* A non-pending result is the attempt that owns the handshake budget.
|
|
47
|
+
*/
|
|
48
|
+
export async function requestWhenAdmitted(options) {
|
|
49
|
+
const sleep = options.sleep ?? ((ms, signal) => new Promise((resolve, reject) => {
|
|
50
|
+
const timer = setTimeout(() => { signal.removeEventListener('abort', onAbort); resolve(); }, ms);
|
|
51
|
+
const onAbort = () => { clearTimeout(timer); reject(signal.reason); };
|
|
52
|
+
if (signal.aborted)
|
|
53
|
+
onAbort();
|
|
54
|
+
else
|
|
55
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
56
|
+
}));
|
|
57
|
+
const pollMs = options.pollMs ?? 750;
|
|
58
|
+
let queued = false;
|
|
59
|
+
for (;;) {
|
|
60
|
+
options.signal.throwIfAborted();
|
|
61
|
+
try {
|
|
62
|
+
return await options.request();
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
const pending = options.isPending(error);
|
|
66
|
+
if (!pending) {
|
|
67
|
+
// A queue entry left behind by an earlier pending attempt would block every later launch at the FIFO head.
|
|
68
|
+
if (queued)
|
|
69
|
+
await options.cancel?.().catch(() => undefined);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
queued = true;
|
|
73
|
+
options.onPending?.(pending);
|
|
74
|
+
if (options.signal.aborted) {
|
|
75
|
+
await options.cancel?.().catch(() => undefined);
|
|
76
|
+
options.signal.throwIfAborted();
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
await sleep(pollMs, options.signal);
|
|
80
|
+
}
|
|
81
|
+
catch (sleepError) {
|
|
82
|
+
await options.cancel?.().catch(() => undefined);
|
|
83
|
+
throw sleepError;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface ProcessQuestionInput {
|
|
2
|
+
id: string;
|
|
3
|
+
question: string;
|
|
4
|
+
header?: string;
|
|
5
|
+
options?: {
|
|
6
|
+
label: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}[];
|
|
9
|
+
multiSelect?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ProcessRequestOpenInput {
|
|
12
|
+
requestId: string;
|
|
13
|
+
jobId: string;
|
|
14
|
+
attemptId: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
kind: 'question' | 'plan' | 'permission';
|
|
17
|
+
questions?: ProcessQuestionInput[];
|
|
18
|
+
planContent?: string;
|
|
19
|
+
toolTitle?: string;
|
|
20
|
+
toolDetail?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ProcessRequestView {
|
|
23
|
+
requestId: string;
|
|
24
|
+
jobId: string;
|
|
25
|
+
kind: 'question' | 'plan' | 'permission';
|
|
26
|
+
status: 'pending' | 'answered' | 'cancelled' | 'expired';
|
|
27
|
+
deadlineAt: string;
|
|
28
|
+
answer?: {
|
|
29
|
+
clientRequestId: string;
|
|
30
|
+
outcome: string;
|
|
31
|
+
answers?: Record<string, string | string[]>;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface ProcessRequestClient {
|
|
35
|
+
open(input: ProcessRequestOpenInput): Promise<{
|
|
36
|
+
requestId: string;
|
|
37
|
+
deadlineAt: string;
|
|
38
|
+
status: string;
|
|
39
|
+
}>;
|
|
40
|
+
wait(input: {
|
|
41
|
+
jobId: string;
|
|
42
|
+
requestId: string;
|
|
43
|
+
signal: AbortSignal;
|
|
44
|
+
}): Promise<ProcessRequestView>;
|
|
45
|
+
report(input: {
|
|
46
|
+
jobId: string;
|
|
47
|
+
requestId: string;
|
|
48
|
+
clientRequestId: string;
|
|
49
|
+
outcome: string;
|
|
50
|
+
answers?: Record<string, string | string[]>;
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
export declare function createWorkbenchProcessClient(options: {
|
|
54
|
+
url: string;
|
|
55
|
+
token?: string;
|
|
56
|
+
pollMs?: number;
|
|
57
|
+
}): ProcessRequestClient;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Polls the gateway workbench for a question, plan or tool permission answer. The token stays in plugin config. */
|
|
2
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
|
+
export function createWorkbenchProcessClient(options) {
|
|
4
|
+
const url = new URL(options.url);
|
|
5
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password)
|
|
6
|
+
throw new Error('a2a.workbench.url must be an HTTP(S) URL without credentials');
|
|
7
|
+
const origin = url.origin;
|
|
8
|
+
const pollMs = options.pollMs ?? 200;
|
|
9
|
+
const endpoint = (path) => new URL(path, origin);
|
|
10
|
+
// A gateway without a workbench token (trusted network) accepts requests without a bearer.
|
|
11
|
+
const headers = { 'Content-Type': 'application/json', ...(options.token?.trim() ? { Authorization: `Bearer ${options.token}` } : {}) };
|
|
12
|
+
async function send(path, method, signal, body) {
|
|
13
|
+
const response = await fetch(endpoint(path), { method, headers, signal, ...(body === undefined ? {} : { body: JSON.stringify(body) }) });
|
|
14
|
+
if (!response.ok)
|
|
15
|
+
throw new Error(`Process request ${method} failed (${response.status})`);
|
|
16
|
+
return response;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
async open(input) {
|
|
20
|
+
const response = await send(`/workbench/tasks/${encodeURIComponent(input.jobId)}/process-requests`, 'POST', AbortSignal.timeout(5_000), input);
|
|
21
|
+
const body = await response.json();
|
|
22
|
+
if (typeof body.requestId !== 'string' || typeof body.deadlineAt !== 'string')
|
|
23
|
+
throw new Error('Process request record is incomplete');
|
|
24
|
+
return { requestId: body.requestId, deadlineAt: body.deadlineAt, status: typeof body.status === 'string' ? body.status : 'pending' };
|
|
25
|
+
},
|
|
26
|
+
async wait(input) {
|
|
27
|
+
for (;;) {
|
|
28
|
+
input.signal.throwIfAborted();
|
|
29
|
+
const response = await send(`/workbench/tasks/${encodeURIComponent(input.jobId)}/process-requests/${encodeURIComponent(input.requestId)}`, 'GET', input.signal);
|
|
30
|
+
const view = await response.json();
|
|
31
|
+
if (view.status !== 'pending')
|
|
32
|
+
return view;
|
|
33
|
+
if (Date.parse(view.deadlineAt) <= Date.now())
|
|
34
|
+
return { ...view, status: 'expired' };
|
|
35
|
+
await delay(pollMs, undefined, { signal: input.signal });
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
async report(input) {
|
|
39
|
+
const response = await fetch(endpoint(`/workbench/tasks/${encodeURIComponent(input.jobId)}/process-requests/${encodeURIComponent(input.requestId)}/answers`), {
|
|
40
|
+
method: 'POST', headers, signal: AbortSignal.timeout(5_000),
|
|
41
|
+
body: JSON.stringify({ clientRequestId: input.clientRequestId, outcome: input.outcome, ...(input.answers ? { answers: input.answers } : {}) }),
|
|
42
|
+
});
|
|
43
|
+
if (response.status === 409)
|
|
44
|
+
return;
|
|
45
|
+
if (!response.ok)
|
|
46
|
+
throw new Error(`Process request answer was not recorded (${response.status})`);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP server (stdio, newline-delimited JSON-RPC) that an ACP agent starts for an A2A session: the hand-back of a
|
|
3
|
+
* taken-over session, and the executor's ticket tools. It holds no authority of its own: each call is forwarded to
|
|
4
|
+
* the DSH host bound to this session.
|
|
5
|
+
*/
|
|
6
|
+
import { createInterface } from 'node:readline';
|
|
7
|
+
import { SUBMIT_DESCRIPTION, SUBMIT_TOOL, SUMMARY_DESCRIPTION } from './review.js';
|
|
8
|
+
import { TICKET_TOOLS } from './ticket-spec.js';
|
|
9
|
+
const url = process.env.ONEAGENTS_REVIEW_URL, ticketUrl = process.env.ONEAGENTS_TICKET_URL, session = process.env.ONEAGENTS_REVIEW_SESSION, token = process.env.ONEAGENTS_REVIEW_TOKEN;
|
|
10
|
+
const tools = [{ name: SUBMIT_TOOL, description: SUBMIT_DESCRIPTION,
|
|
11
|
+
inputSchema: { type: 'object', properties: { summary: { type: 'string', description: SUMMARY_DESCRIPTION } }, required: ['summary'], additionalProperties: false } },
|
|
12
|
+
...(ticketUrl ? TICKET_TOOLS.map(spec => ({ name: spec.name, description: spec.description,
|
|
13
|
+
inputSchema: { type: 'object', properties: spec.parameters, required: Object.keys(spec.parameters), additionalProperties: false } })) : [])];
|
|
14
|
+
const write = (message) => process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
15
|
+
async function call(name, args) {
|
|
16
|
+
const summary = args?.summary;
|
|
17
|
+
if (name === SUBMIT_TOOL && (typeof summary !== 'string' || !summary.trim()))
|
|
18
|
+
return { content: [{ type: 'text', text: 'summary is required' }], isError: true };
|
|
19
|
+
const target = name === SUBMIT_TOOL ? url : ticketUrl;
|
|
20
|
+
if (!target || !session || !token)
|
|
21
|
+
return { content: [{ type: 'text', text: 'This MCP server was started without its DSH session binding' }], isError: true };
|
|
22
|
+
try {
|
|
23
|
+
const response = await fetch(target, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}`, 'X-Oneagents-Session': session },
|
|
24
|
+
body: JSON.stringify(name === SUBMIT_TOOL ? { summary } : { tool: name, arguments: args ?? {} }), signal: AbortSignal.timeout(120_000) });
|
|
25
|
+
const body = await response.json();
|
|
26
|
+
return response.ok ? { content: [{ type: 'text', text: body.text ?? '' }] } : { content: [{ type: 'text', text: body.error ?? `HTTP ${response.status}` }], isError: true };
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return { content: [{ type: 'text', text: `DSH host unreachable: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
createInterface({ input: process.stdin }).on('line', line => {
|
|
33
|
+
let message;
|
|
34
|
+
try {
|
|
35
|
+
message = JSON.parse(line);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const { id, method, params } = message;
|
|
41
|
+
if (id === undefined)
|
|
42
|
+
return; // notifications
|
|
43
|
+
const result = (value) => write({ jsonrpc: '2.0', id, result: value });
|
|
44
|
+
if (method === 'initialize')
|
|
45
|
+
return result({ protocolVersion: params?.protocolVersion ?? '2025-06-18', capabilities: { tools: {} }, serverInfo: { name: 'oneagents-review', version: '1.0.0' } });
|
|
46
|
+
if (method === 'ping')
|
|
47
|
+
return result({});
|
|
48
|
+
if (method === 'tools/list')
|
|
49
|
+
return result({ tools });
|
|
50
|
+
if (method === 'tools/call') {
|
|
51
|
+
if (!tools.some(tool => tool.name === params?.name))
|
|
52
|
+
return write({ jsonrpc: '2.0', id, error: { code: -32602, message: `Unknown tool: ${params?.name}` } });
|
|
53
|
+
return void call(params.name, params.arguments).then(result);
|
|
54
|
+
}
|
|
55
|
+
write({ jsonrpc: '2.0', id, error: { code: -32601, message: `Method not found: ${method}` } });
|
|
56
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import type { McpServerStdio } from '@agentclientprotocol/sdk';
|
|
3
|
+
import type { A2AHostControls } from './a2a.js';
|
|
4
|
+
import { type TicketTool } from './ticket-spec.js';
|
|
5
|
+
export declare const SUBMIT_TOOL = "submit_to_review";
|
|
6
|
+
export declare const SUBMIT_DESCRIPTION = "\u4EC5\u7528\u4E8E\u4ECE A2A \u5DE5\u4F5C\u53F0\u63A5\u7BA1\u7684\u4F1A\u8BDD\uFF1A\u7528\u6237\u660E\u786E\u786E\u8BA4\u6210\u679C\u6CA1\u95EE\u9898\u540E\u8C03\u7528\uFF0C\u628A\u672C\u4F1A\u8BDD A2A \u4EFB\u52A1\u7684\u4EA4\u4ED8\u603B\u7ED3\u4E0E\u4F5C\u4E1A\u76EE\u5F55 artifacts.json \u6E05\u5355\u4E2D\u7684\u4EA7\u7269\u91CD\u65B0\u63D0\u4EA4\u56DE\u5DE5\u4F5C\u6D41\uFF0C\u751F\u6210\u65B0\u7684\u7ED3\u679C\u7248\u672C\u5E76\u8FDB\u5165\u4E1A\u52A1\u9A8C\u6536\u3002\u8C03\u7528\u524D\u5148\u628A\u4EA7\u7269\u5199\u5165\u4F5C\u4E1A\u76EE\u5F55\u5E76\u66F4\u65B0\u6E05\u5355\uFF1B\u7528\u6237\u672A\u786E\u8BA4\u65F6\u4E0D\u8981\u8C03\u7528\u3002";
|
|
7
|
+
export declare const SUMMARY_DESCRIPTION = "\u4EA4\u4ED8\u603B\u7ED3\uFF1A\u672C\u6B21\u4EBA\u5DE5\u63A5\u7BA1\u505A\u4E86\u54EA\u4E9B\u4FEE\u6539\u3001\u6700\u7EC8\u4EA7\u7269\u662F\u4EC0\u4E48\u3002";
|
|
8
|
+
export declare const REVIEW_SUBMIT_PATH = "/1agents-acp/review-submit";
|
|
9
|
+
export declare class ReviewHandBack {
|
|
10
|
+
private readonly secret;
|
|
11
|
+
private readonly workbench?;
|
|
12
|
+
/** Set while the A2A host is mounted. */
|
|
13
|
+
host?: A2AHostControls;
|
|
14
|
+
private constructor();
|
|
15
|
+
static open(secretFile: string, workbench?: {
|
|
16
|
+
url: string;
|
|
17
|
+
token?: string;
|
|
18
|
+
}): Promise<ReviewHandBack>;
|
|
19
|
+
/** Hand the session's task back and let the gateway read it now; returns the agent-facing outcome. */
|
|
20
|
+
submit(sessionId: string, summary: string): Promise<string>;
|
|
21
|
+
private token;
|
|
22
|
+
/** The stdio MCP server an ACP agent starts for one session; the token only acts for that session. */
|
|
23
|
+
mcpServer(sessionId: string, origin: string): McpServerStdio;
|
|
24
|
+
/** A loopback call from the MCP server, checked against its session's token; replies itself and returns nothing when refused. */
|
|
25
|
+
private authorized;
|
|
26
|
+
/** Loopback callback from the MCP server. */
|
|
27
|
+
readonly handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
28
|
+
/** The MCP server's ticket tools for its session; `run` is the same call DSH's native tools make. */
|
|
29
|
+
ticketHandler(run: (sessionId: string, tool: TicketTool, args: Record<string, unknown>) => Promise<string>): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
30
|
+
}
|