@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
|
@@ -1,8 +1,54 @@
|
|
|
1
1
|
/** DSH session execution behind the shared A2A service's transport-independent backend. */
|
|
2
2
|
import { realpath, stat } from 'node:fs/promises';
|
|
3
3
|
import { isAbsolute } from 'node:path';
|
|
4
|
-
import { A2APreflightError, runA2APreflight } from '@1agents/acp-service/a2a';
|
|
4
|
+
import { A2APreflightError, bindA2AExecution, runA2APreflight, unbindA2AExecution } from '@1agents/acp-service/a2a';
|
|
5
5
|
import { toSafeError } from '@1agents/acp-service/runtime';
|
|
6
|
+
import { modelSelectionOf } from './preset-route.js';
|
|
7
|
+
import { consumeProcessReady, readProcessCapacity, readSessionRestore } from './process-admission.js';
|
|
8
|
+
function sessionError(code, message) {
|
|
9
|
+
const error = new Error(message);
|
|
10
|
+
error.code = code;
|
|
11
|
+
return error;
|
|
12
|
+
}
|
|
13
|
+
/** Host inspect either returns null or throws its own not-found error. Other failures stay unchanged. */
|
|
14
|
+
function isMissingSession(error, sessionId) {
|
|
15
|
+
if (!error || typeof error !== 'object')
|
|
16
|
+
return false;
|
|
17
|
+
const value = error;
|
|
18
|
+
return value.name === 'ApiSessionNotFound'
|
|
19
|
+
|| value.message === `Session ${sessionId} not found`
|
|
20
|
+
|| value.message === `session "${sessionId}" not found`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read a Session's identity without resuming it; null when it does not exist.
|
|
24
|
+
* Current DSH dropped sessionController.inspect, so this observes the stored header through sessionQuery instead.
|
|
25
|
+
*/
|
|
26
|
+
export async function inspectSession(ctx, sessionId) {
|
|
27
|
+
if (typeof ctx.sessionController.inspect === 'function')
|
|
28
|
+
return ctx.sessionController.inspect(sessionId);
|
|
29
|
+
const live = ctx.sessions?.get?.(sessionId);
|
|
30
|
+
if (live?.header)
|
|
31
|
+
return { meta: { id: live.header.id, cwd: live.header.cwd, agentPreset: live.header.agentPreset } };
|
|
32
|
+
const query = ctx.get('sessionQuery');
|
|
33
|
+
if (!query)
|
|
34
|
+
throw new Error('This DSH host offers neither sessionController.inspect nor sessionQuery');
|
|
35
|
+
let observation;
|
|
36
|
+
try {
|
|
37
|
+
observation = await query.observeSession(sessionId, { projectionMode: 'none' });
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (isMissingSession(error, sessionId))
|
|
41
|
+
return null;
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const { id, cwd, agentPreset } = observation.header;
|
|
46
|
+
return { meta: { id, ...(cwd === undefined ? {} : { cwd }), ...(agentPreset === undefined ? {} : { agentPreset }) } };
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
observation[Symbol.dispose]();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
6
52
|
function resultOf(reason, text, finalAnswerExpected, operationId, diagnostic) {
|
|
7
53
|
switch (reason.kind) {
|
|
8
54
|
case 'completed': return finalAnswerExpected && !text.trim()
|
|
@@ -54,11 +100,40 @@ async function waitForIdle(agent, signal) {
|
|
|
54
100
|
export class DshA2ABackend {
|
|
55
101
|
ctx;
|
|
56
102
|
diagnostics;
|
|
103
|
+
sessions;
|
|
57
104
|
executions = new Map();
|
|
58
105
|
/** @param ctx DSH plugin context that owns session-controller and execution event registrations. */
|
|
59
|
-
constructor(ctx, diagnostics) {
|
|
106
|
+
constructor(ctx, diagnostics, sessions) {
|
|
60
107
|
this.ctx = ctx;
|
|
61
108
|
this.diagnostics = diagnostics;
|
|
109
|
+
this.sessions = sessions;
|
|
110
|
+
}
|
|
111
|
+
async close(target) {
|
|
112
|
+
if (!target.agentPreset?.startsWith('oneagents-acp-'))
|
|
113
|
+
return { processReleased: true, acp: false };
|
|
114
|
+
if (!this.sessions) {
|
|
115
|
+
const error = new Error('Host close is not supported');
|
|
116
|
+
error.code = 'UNSUPPORTED';
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
return this.sessions.release(target.sessionId);
|
|
120
|
+
}
|
|
121
|
+
/** Non-ACP presets only drop the A2A binding; DSH session history is never deleted. */
|
|
122
|
+
async delete(target) {
|
|
123
|
+
if (!target.agentPreset?.startsWith('oneagents-acp-'))
|
|
124
|
+
return { processReleased: true, acp: false };
|
|
125
|
+
if (!this.sessions?.delete) {
|
|
126
|
+
const error = new Error('Host delete is not supported');
|
|
127
|
+
error.code = 'UNSUPPORTED';
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
return this.sessions.delete(target.sessionId);
|
|
131
|
+
}
|
|
132
|
+
async status(target) {
|
|
133
|
+
if (target.agentPreset?.startsWith('oneagents-acp-') && this.sessions)
|
|
134
|
+
return this.sessions.status(target.sessionId);
|
|
135
|
+
const found = await inspectSession(this.ctx, target.sessionId).catch(() => null);
|
|
136
|
+
return { attached: found != null, activeTurn: false };
|
|
62
137
|
}
|
|
63
138
|
/** Restart reconciliation reads the plugin domain and never dispatches another prompt. */
|
|
64
139
|
async recover(target, options) {
|
|
@@ -74,14 +149,22 @@ export class DshA2ABackend {
|
|
|
74
149
|
async prepare(input, options) {
|
|
75
150
|
const signal = options?.signal;
|
|
76
151
|
signal?.throwIfAborted();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
152
|
+
let previous;
|
|
153
|
+
if (input.sessionId !== undefined) {
|
|
154
|
+
try {
|
|
155
|
+
previous = await inspectSession(this.ctx, input.sessionId);
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
if (isMissingSession(error, input.sessionId))
|
|
159
|
+
throw sessionError('SESSION_NOT_FOUND', `Session ${input.sessionId} not found`);
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
signal?.throwIfAborted();
|
|
163
|
+
if (previous == null)
|
|
164
|
+
throw sessionError('SESSION_NOT_FOUND', `Session ${input.sessionId} not found`);
|
|
165
|
+
}
|
|
166
|
+
if (previous != null && previous.meta.id !== input.sessionId)
|
|
167
|
+
throw sessionError('SESSION_CONFLICT', 'Existing session identity conflicts');
|
|
85
168
|
const requestedCwd = input.cwd ?? previous?.meta.cwd ?? process.cwd();
|
|
86
169
|
if (!isAbsolute(requestedCwd))
|
|
87
170
|
throw new Error('A2A cwd must be an absolute directory on the DSH host');
|
|
@@ -95,24 +178,30 @@ export class DshA2ABackend {
|
|
|
95
178
|
if (!preflight.ok)
|
|
96
179
|
throw new A2APreflightError(preflight);
|
|
97
180
|
const agentPreset = input.agentPreset ?? previous?.meta.agentPreset;
|
|
98
|
-
if (input.sessionId !== undefined && previous
|
|
181
|
+
if (input.sessionId !== undefined && previous != null) {
|
|
99
182
|
if (previous.meta.cwd === undefined || await realpath(previous.meta.cwd) !== cwd)
|
|
100
|
-
throw
|
|
183
|
+
throw sessionError('SESSION_CONFLICT', 'Existing session cwd conflicts');
|
|
101
184
|
if (input.agentPreset !== undefined && input.agentPreset !== previous.meta.agentPreset)
|
|
102
|
-
throw
|
|
185
|
+
throw sessionError('SESSION_CONFLICT', 'Existing session preset conflicts');
|
|
103
186
|
// create() only reuses blank Sessions on current DSH; resolve the saved
|
|
104
187
|
// identity directly so an active or completed context keeps its queue.
|
|
105
188
|
const agent = await this.agent(input.sessionId);
|
|
106
189
|
signal?.throwIfAborted();
|
|
107
190
|
if (agent.id !== input.sessionId || agent.session.id !== input.sessionId)
|
|
108
|
-
throw
|
|
191
|
+
throw sessionError('SESSION_CONFLICT', 'Existing session identity conflicts');
|
|
109
192
|
if (agent.session.header.cwd === undefined || await realpath(agent.session.header.cwd) !== cwd)
|
|
110
|
-
throw
|
|
193
|
+
throw sessionError('SESSION_CONFLICT', 'Existing session cwd conflicts');
|
|
111
194
|
signal?.throwIfAborted();
|
|
112
195
|
if (agent.session.header.agentPreset !== previous.meta.agentPreset)
|
|
113
|
-
throw
|
|
114
|
-
|
|
196
|
+
throw sessionError('SESSION_CONFLICT', 'Existing session preset conflicts');
|
|
197
|
+
if (input.provider !== undefined)
|
|
198
|
+
await this.requireModel(input, agentPreset, signal);
|
|
199
|
+
const selected = await this.selectModel(input, input.sessionId, signal);
|
|
200
|
+
return { sessionId: input.sessionId, cwd, ...(agentPreset === undefined ? {} : { agentPreset }), preflight, ...selected };
|
|
115
201
|
}
|
|
202
|
+
// Reject an unknown model before a blank session is created for it.
|
|
203
|
+
if (input.provider !== undefined)
|
|
204
|
+
await this.requireModel(input, agentPreset, signal);
|
|
116
205
|
const created = await this.ctx.sessionController.create({
|
|
117
206
|
cwd,
|
|
118
207
|
...(agentPreset === undefined ? {} : { agentPreset }),
|
|
@@ -122,13 +211,48 @@ export class DshA2ABackend {
|
|
|
122
211
|
signal?.throwIfAborted();
|
|
123
212
|
const agent = await this.agent(created.sessionId);
|
|
124
213
|
signal?.throwIfAborted();
|
|
214
|
+
const selected = await this.selectModel(input, created.sessionId, signal);
|
|
125
215
|
return {
|
|
126
216
|
sessionId: created.sessionId,
|
|
127
217
|
cwd: agent.session.header.cwd ?? cwd,
|
|
128
218
|
...(created.agentPreset === undefined ? {} : { agentPreset: created.agentPreset }),
|
|
129
219
|
preflight,
|
|
220
|
+
...selected,
|
|
130
221
|
};
|
|
131
222
|
}
|
|
223
|
+
/** Standard presets only. The catalog must list the exact model; a miss never falls back to the host default. */
|
|
224
|
+
async requireModel(input, agentPreset, signal) {
|
|
225
|
+
if (agentPreset?.startsWith('oneagents-acp-'))
|
|
226
|
+
throw sessionError('MODEL_SELECTION_UNSUPPORTED', 'provider and model apply only to standard presets');
|
|
227
|
+
const catalog = await this.ctx.sessionController.modelCatalog();
|
|
228
|
+
signal?.throwIfAborted();
|
|
229
|
+
if (!catalog.groups.some(group => group.id === input.provider && group.models.some(model => model.id === input.model))) {
|
|
230
|
+
throw sessionError('MODEL_UNAVAILABLE', `Model ${input.provider}/${input.model} is not in the DSH model catalog`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/** Install the requested model before the first prompt and return what DSH resolved. Omitted fields leave the session unchanged. */
|
|
234
|
+
async selectModel(input, sessionId, signal) {
|
|
235
|
+
if (input.provider === undefined || input.model === undefined)
|
|
236
|
+
return {};
|
|
237
|
+
let selected = { provider: input.provider, model: input.model };
|
|
238
|
+
try {
|
|
239
|
+
const agent = await this.agent(sessionId);
|
|
240
|
+
// sessionController.selectModel also saves the choice as the host's default model.
|
|
241
|
+
// A task only chooses for its own session, so current DSH selects on the agent directly.
|
|
242
|
+
const model = modelSelectionOf(agent);
|
|
243
|
+
if (model) {
|
|
244
|
+
await this.ctx.llm.resolveCallConfig?.(selected);
|
|
245
|
+
model.select(selected);
|
|
246
|
+
}
|
|
247
|
+
else
|
|
248
|
+
({ selected } = await this.ctx.sessionController.selectModel({ sessionId, ...selected }));
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
throw Object.assign(sessionError('MODEL_UNAVAILABLE', `DSH did not select ${input.provider}/${input.model}`), { cause: error });
|
|
252
|
+
}
|
|
253
|
+
signal?.throwIfAborted();
|
|
254
|
+
return { provider: selected.provider, model: selected.model };
|
|
255
|
+
}
|
|
132
256
|
/** Admit one identified queued prompt and wait only for its own turn, independent of the HTTP connection.
|
|
133
257
|
* @param target Previously prepared DSH session.
|
|
134
258
|
* @param prompt Plain-text A2A message content.
|
|
@@ -179,6 +303,9 @@ export class DshA2ABackend {
|
|
|
179
303
|
completion.resolve(result);
|
|
180
304
|
};
|
|
181
305
|
const finishTurn = (reason) => {
|
|
306
|
+
const restoreMethod = readSessionRestore(agent.id);
|
|
307
|
+
if (restoreMethod)
|
|
308
|
+
Object.assign(target, { resumed: true, restoreMethod });
|
|
182
309
|
const start = agent.session.snapshotEvents().findLast(event => event.type === 'turn/start' && event.data.turn === turn);
|
|
183
310
|
let diagnostic;
|
|
184
311
|
try {
|
|
@@ -265,7 +392,22 @@ export class DshA2ABackend {
|
|
|
265
392
|
}
|
|
266
393
|
}));
|
|
267
394
|
options.signal.addEventListener('abort', cancel, { once: true });
|
|
395
|
+
let capacityTimer;
|
|
396
|
+
if (options.onCapacity && target.agentPreset?.startsWith('oneagents-acp-')) {
|
|
397
|
+
const tick = () => {
|
|
398
|
+
const pending = readProcessCapacity(target.sessionId);
|
|
399
|
+
if (pending)
|
|
400
|
+
options.onCapacity?.({ code: 'CAPACITY_PENDING', position: pending.position, waitedMs: pending.waitedMs });
|
|
401
|
+
else if (consumeProcessReady(target.sessionId))
|
|
402
|
+
options.onCapacity?.(undefined);
|
|
403
|
+
capacityTimer = setTimeout(tick, 50);
|
|
404
|
+
capacityTimer.unref?.();
|
|
405
|
+
};
|
|
406
|
+
tick();
|
|
407
|
+
}
|
|
268
408
|
try {
|
|
409
|
+
if (options.execution)
|
|
410
|
+
bindA2AExecution(target.sessionId, options.execution);
|
|
269
411
|
// Recheck after event registration; cancellation can arrive during Agent restoration.
|
|
270
412
|
options.signal.throwIfAborted();
|
|
271
413
|
// Native user turns do not share this backend's execution map.
|
|
@@ -293,6 +435,10 @@ export class DshA2ABackend {
|
|
|
293
435
|
return await completion.promise;
|
|
294
436
|
}
|
|
295
437
|
finally {
|
|
438
|
+
if (capacityTimer)
|
|
439
|
+
clearTimeout(capacityTimer);
|
|
440
|
+
if (options.execution)
|
|
441
|
+
unbindA2AExecution(target.sessionId, options.execution);
|
|
296
442
|
options.signal.removeEventListener('abort', cancel);
|
|
297
443
|
for (const dispose of listeners.reverse())
|
|
298
444
|
dispose();
|
package/vendor/dsh/a2a.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Mount the shared A2A implementation on the current DSH web host. */
|
|
2
|
-
import { type A2AServerOptions } from '@1agents/acp-service/a2a';
|
|
2
|
+
import { createA2AServer, type A2AServerOptions } from '@1agents/acp-service/a2a';
|
|
3
3
|
import type { Context } from '@deepseek-ai/cordis';
|
|
4
4
|
import type { Diagnostics } from './diagnostics.js';
|
|
5
|
+
import { type SessionControl } from './a2a-executor.js';
|
|
5
6
|
/** Optional host configuration; omitted configuration leaves A2A disabled. */
|
|
6
7
|
export interface DshA2AOptions extends Omit<A2AServerOptions, 'backend' | 'token' | 'stateDirectory' | 'publicUrl'> {
|
|
7
8
|
enabled?: boolean;
|
|
@@ -11,6 +12,15 @@ export interface DshA2AOptions extends Omit<A2AServerOptions, 'backend' | 'token
|
|
|
11
12
|
stateDirectory?: string;
|
|
12
13
|
/** Public DSH origin, for example its Tailscale URL. */
|
|
13
14
|
publicUrl?: string;
|
|
15
|
+
/** Gateway workbench that records questions and plan approvals for this host's A2A turns.
|
|
16
|
+
* `pageRelaySecret` matches the gateway's workbench.pageRelaySecret so this host's page can publish and decide reviews. */
|
|
17
|
+
workbench?: {
|
|
18
|
+
url: string;
|
|
19
|
+
token?: string;
|
|
20
|
+
pageRelaySecret?: string;
|
|
21
|
+
};
|
|
14
22
|
}
|
|
23
|
+
/** In-process takeover controls of the mounted host; absent while A2A is disabled or closed. */
|
|
24
|
+
export type A2AHostControls = Pick<Awaited<ReturnType<typeof createA2AServer>>, 'sessionTask' | 'taskSession' | 'resubmit'>;
|
|
15
25
|
/** Routes and in-flight turns are released with the owning Cordis plugin. */
|
|
16
|
-
export declare function mountDshA2A(ctx: Context, options: DshA2AOptions, stateDirectory: string, diagnostics?: Diagnostics): Promise<() => Promise<void>>;
|
|
26
|
+
export declare function mountDshA2A(ctx: Context, options: DshA2AOptions, stateDirectory: string, diagnostics?: Diagnostics, sessions?: SessionControl, expose?: (host: A2AHostControls | undefined) => void): Promise<() => Promise<void>>;
|
package/vendor/dsh/a2a.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createA2AServer } from '@1agents/acp-service/a2a';
|
|
3
3
|
import { DshA2ABackend } from './a2a-executor.js';
|
|
4
4
|
/** Routes and in-flight turns are released with the owning Cordis plugin. */
|
|
5
|
-
export async function mountDshA2A(ctx, options, stateDirectory, diagnostics) {
|
|
5
|
+
export async function mountDshA2A(ctx, options, stateDirectory, diagnostics, sessions, expose) {
|
|
6
6
|
if (options.enabled === false)
|
|
7
7
|
return async () => { };
|
|
8
8
|
const token = options.token ?? process.env[options.tokenEnv ?? 'DSH_A2A_TOKEN'];
|
|
@@ -10,7 +10,8 @@ export async function mountDshA2A(ctx, options, stateDirectory, diagnostics) {
|
|
|
10
10
|
throw new Error('Set DSH_A2A_TOKEN or a2a.token before enabling DSH A2A');
|
|
11
11
|
let close = async () => { };
|
|
12
12
|
await ctx.effect(async () => {
|
|
13
|
-
const
|
|
13
|
+
const { workbench: _workbench, ...serverOptions } = options;
|
|
14
|
+
const server = await createA2AServer({ ...serverOptions, token, backend: new DshA2ABackend(ctx, diagnostics, sessions),
|
|
14
15
|
stateDirectory: options.stateDirectory ?? stateDirectory,
|
|
15
16
|
publicUrl: options.publicUrl ?? `http://127.0.0.1:${ctx.webServer.port}` });
|
|
16
17
|
const routes = [];
|
|
@@ -18,6 +19,10 @@ export async function mountDshA2A(ctx, options, stateDirectory, diagnostics) {
|
|
|
18
19
|
routes.push(ctx.webServer.register({ kind: 'exact', path: '/.well-known/agent-card.json', handler: server.cardHandler }));
|
|
19
20
|
routes.push(ctx.webServer.register({ kind: 'exact', path: server.path, handler: server.handler }));
|
|
20
21
|
routes.push(ctx.webServer.register({ kind: 'exact', path: `${server.path}/preflight`, handler: server.handler }));
|
|
22
|
+
routes.push(ctx.webServer.register({ kind: 'exact', path: `${server.path}/sessions/close`, handler: server.handler }));
|
|
23
|
+
routes.push(ctx.webServer.register({ kind: 'exact', path: `${server.path}/sessions/status`, handler: server.handler }));
|
|
24
|
+
routes.push(ctx.webServer.register({ kind: 'exact', path: `${server.path}/sessions/delete`, handler: server.handler }));
|
|
25
|
+
routes.push(ctx.webServer.register({ kind: 'exact', path: `${server.path}/artifacts/content`, handler: server.handler }));
|
|
21
26
|
}
|
|
22
27
|
catch (error) {
|
|
23
28
|
for (const dispose of routes.reverse())
|
|
@@ -26,7 +31,9 @@ export async function mountDshA2A(ctx, options, stateDirectory, diagnostics) {
|
|
|
26
31
|
throw error;
|
|
27
32
|
}
|
|
28
33
|
let closing;
|
|
34
|
+
expose?.({ sessionTask: server.sessionTask, taskSession: server.taskSession, resubmit: server.resubmit });
|
|
29
35
|
close = () => closing ??= (async () => {
|
|
36
|
+
expose?.(undefined);
|
|
30
37
|
for (const dispose of routes.reverse())
|
|
31
38
|
dispose();
|
|
32
39
|
await server.close();
|
package/vendor/dsh/adapter.d.ts
CHANGED
|
@@ -2,13 +2,23 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
2
2
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
3
|
import type { LlmAdapter, GenerateOptions, StreamChunk, LlmModelInfo } from '@deepseek-ai/dsh-llm';
|
|
4
4
|
import type { Diagnostics } from './diagnostics.js';
|
|
5
|
-
import type { SessionConfigOption, SessionModeState, AvailableCommand } from '@agentclientprotocol/sdk';
|
|
5
|
+
import type { McpServer, SessionConfigOption, SessionModeState, AvailableCommand } from '@agentclientprotocol/sdk';
|
|
6
6
|
import { type Binding } from './state.js';
|
|
7
|
+
import type { ProcessRequestClient } from './process-requests.js';
|
|
8
|
+
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
9
|
+
interface SessionProjectionStateMap {
|
|
10
|
+
sandboxMode: 'read-only' | 'workspace-write' | 'danger-full-access' | null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
7
13
|
export interface SessionPolicy {
|
|
8
14
|
/** Exact workspace and ACP registry name; no global or wildcard policy. */
|
|
9
15
|
cwd: string;
|
|
10
16
|
agent: string;
|
|
11
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Accepted so older host configs still load. Not sent and not applied.
|
|
19
|
+
* Tool posture comes from ACP settings: native mode and config options.
|
|
20
|
+
*/
|
|
21
|
+
permissionMode?: 'approve-reads' | 'approve-all' | 'deny-all';
|
|
12
22
|
initialModeId?: string;
|
|
13
23
|
}
|
|
14
24
|
export interface Config {
|
|
@@ -32,6 +42,7 @@ export declare class AcpAdapter implements LlmAdapter {
|
|
|
32
42
|
private ctx;
|
|
33
43
|
private config;
|
|
34
44
|
private readonly diagnostics?;
|
|
45
|
+
private readonly processRequests?;
|
|
35
46
|
private state;
|
|
36
47
|
private initializationFailures;
|
|
37
48
|
private controllers;
|
|
@@ -44,7 +55,10 @@ export declare class AcpAdapter implements LlmAdapter {
|
|
|
44
55
|
private commandDisposers;
|
|
45
56
|
private output;
|
|
46
57
|
private lifetime;
|
|
47
|
-
|
|
58
|
+
private readonly sessionSettings;
|
|
59
|
+
/** MCP servers offered when a session is created or restored, such as the A2A hand-back tool. */
|
|
60
|
+
mcpServersFor?: (sessionId: string) => McpServer[];
|
|
61
|
+
constructor(ctx: Context, config: Config, diagnostics?: Diagnostics | undefined, processRequests?: ProcessRequestClient | undefined);
|
|
48
62
|
providerInfo(provider: string): {
|
|
49
63
|
id: string;
|
|
50
64
|
name: string;
|
|
@@ -58,6 +72,16 @@ export declare class AcpAdapter implements LlmAdapter {
|
|
|
58
72
|
jitterRatio: number;
|
|
59
73
|
};
|
|
60
74
|
imageRequestPricing(): undefined;
|
|
75
|
+
/** DSH 0.2.1 requires this. ACP Agents take text only, so keep the base class's untouched image target. */
|
|
76
|
+
imageRequestTarget(_provider: string, _model: string, image: {
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
bytes: number;
|
|
80
|
+
}): {
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
maxBytes: number;
|
|
84
|
+
};
|
|
61
85
|
listModels(provider: string): Promise<LlmModelInfo[]>;
|
|
62
86
|
resolveModel(provider: string, model: string): Promise<{
|
|
63
87
|
provider: string;
|
|
@@ -86,11 +110,36 @@ export declare class AcpAdapter implements LlmAdapter {
|
|
|
86
110
|
*/
|
|
87
111
|
importNative(name: string, cwd: string, nativeSessionId: string): Promise<Binding>;
|
|
88
112
|
private publishCommands;
|
|
113
|
+
/** Replay this Agent's own accepted values. Another Agent's catalog is never consulted. */
|
|
114
|
+
private applyPinnedSettings;
|
|
89
115
|
private connection;
|
|
90
116
|
private openConnection;
|
|
117
|
+
/** Ordinary ACP release. The binding, session id, and restore method stay. No session/delete. */
|
|
118
|
+
releaseSession(sessionId: string): Promise<{
|
|
119
|
+
processReleased: true | 'pending';
|
|
120
|
+
acp: boolean;
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Controlled delete. ACP session/delete closes the process and marks the record deleted.
|
|
124
|
+
* The DSH session and its history stay. A detached session gets a bare link, so no agent process starts.
|
|
125
|
+
*/
|
|
126
|
+
deleteSession(sessionId: string): Promise<{
|
|
127
|
+
processReleased: true | 'pending';
|
|
128
|
+
acp: boolean;
|
|
129
|
+
}>;
|
|
130
|
+
sessionStatus(sessionId: string): Promise<{
|
|
131
|
+
attached: boolean;
|
|
132
|
+
activeTurn: boolean;
|
|
133
|
+
}>;
|
|
91
134
|
stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
92
135
|
private permission;
|
|
136
|
+
private questionsOf;
|
|
137
|
+
private askQuestions;
|
|
138
|
+
private askPlan;
|
|
93
139
|
private question;
|
|
94
140
|
private plan;
|
|
141
|
+
/** The workbench answer completes this wait. A later A2A user message does not. */
|
|
142
|
+
private withProcessRequest;
|
|
143
|
+
private reportProcess;
|
|
95
144
|
private run;
|
|
96
145
|
}
|