@hanphone/dsh-a2a 0.2.0 → 0.3.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 +101 -106
- package/README.zh.md +50 -74
- package/cordis.patch.yml +4 -7
- package/lib/client.js +217 -73
- package/lib/index.js +1258 -867
- package/lib/types/api.d.ts +40 -23
- package/lib/types/api.d.ts.map +1 -1
- package/lib/types/api.js +58 -23
- package/lib/types/api.js.map +1 -1
- package/lib/types/client/index.d.ts +50 -19
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/commands.d.ts +4 -2
- package/lib/types/commands.d.ts.map +1 -1
- package/lib/types/commands.js +59 -46
- package/lib/types/commands.js.map +1 -1
- package/lib/types/events.d.ts +32 -9
- package/lib/types/events.d.ts.map +1 -1
- package/lib/types/index.d.ts +21 -32
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +173 -272
- package/lib/types/index.js.map +1 -1
- package/lib/types/outbound/calls.d.ts.map +1 -1
- package/lib/types/outbound/calls.js +8 -6
- package/lib/types/outbound/calls.js.map +1 -1
- package/lib/types/protocol.d.ts +174 -109
- package/lib/types/protocol.d.ts.map +1 -1
- package/lib/types/protocol.js +58 -34
- package/lib/types/protocol.js.map +1 -1
- package/lib/types/server/a2a-server.d.ts +4 -0
- package/lib/types/server/a2a-server.d.ts.map +1 -1
- package/lib/types/server/a2a-server.js +6 -2
- package/lib/types/server/a2a-server.js.map +1 -1
- package/lib/types/server/card.d.ts +6 -30
- package/lib/types/server/card.d.ts.map +1 -1
- package/lib/types/server/card.js +13 -49
- package/lib/types/server/card.js.map +1 -1
- package/lib/types/server/exec/agent-runtime.d.ts +3 -0
- package/lib/types/server/exec/agent-runtime.d.ts.map +1 -1
- package/lib/types/server/exec/agent-runtime.js +2 -1
- package/lib/types/server/exec/agent-runtime.js.map +1 -1
- package/lib/types/server/routes.d.ts +5 -1
- package/lib/types/server/routes.d.ts.map +1 -1
- package/lib/types/server/routes.js +9 -5
- package/lib/types/server/routes.js.map +1 -1
- package/lib/types/server/store.d.ts +35 -1
- package/lib/types/server/store.d.ts.map +1 -1
- package/lib/types/server/store.js +10 -0
- package/lib/types/server/store.js.map +1 -1
- package/lib/types/servers/inbound-manager.d.ts +131 -0
- package/lib/types/servers/inbound-manager.d.ts.map +1 -0
- package/lib/types/servers/inbound-manager.js +312 -0
- package/lib/types/servers/inbound-manager.js.map +1 -0
- package/lib/types/servers/outbound-manager.d.ts +129 -0
- package/lib/types/servers/outbound-manager.d.ts.map +1 -0
- package/lib/types/servers/outbound-manager.js +238 -0
- package/lib/types/servers/outbound-manager.js.map +1 -0
- package/lib/types/service.d.ts +106 -40
- package/lib/types/service.d.ts.map +1 -1
- package/lib/types/service.js +36 -27
- package/lib/types/service.js.map +1 -1
- package/package.json +2 -2
- package/src/api.ts +67 -53
- package/src/client/index.ts +309 -148
- package/src/commands.ts +59 -43
- package/src/events.ts +14 -7
- package/src/index.ts +199 -310
- package/src/outbound/calls.ts +8 -6
- package/src/protocol.ts +204 -95
- package/src/server/a2a-server.ts +9 -2
- package/src/server/card.ts +13 -62
- package/src/server/exec/agent-runtime.ts +5 -2
- package/src/server/routes.ts +6 -4
- package/src/server/store.ts +45 -4
- package/src/servers/inbound-manager.ts +385 -0
- package/src/servers/outbound-manager.ts +289 -0
- package/src/service.ts +125 -40
- package/lib/tsconfig.client.tsbuildinfo +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
package/lib/types/service.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `ctx.a2a` service facade: the thin read/control surface commands
|
|
3
|
-
* other plugins use. Registered as a Cordis Service so the key
|
|
4
|
-
* with the plugin fiber.
|
|
2
|
+
* The `ctx.a2a` service facade: the thin read/control surface commands, the
|
|
3
|
+
* GUI API, and other plugins use. Registered as a Cordis Service so the key
|
|
4
|
+
* disappears with the plugin fiber.
|
|
5
5
|
* @module dsh-a2a/service
|
|
6
6
|
*/
|
|
7
7
|
import { Service } from '@deepseek-ai/cordis';
|
|
@@ -15,44 +15,53 @@ export class A2AService extends Service {
|
|
|
15
15
|
status() {
|
|
16
16
|
return this.impl.status();
|
|
17
17
|
}
|
|
18
|
-
async
|
|
19
|
-
return this.impl.
|
|
18
|
+
async presets() {
|
|
19
|
+
return this.impl.presets();
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
return this.impl.
|
|
21
|
+
listInboundServers() {
|
|
22
|
+
return this.impl.listInboundServers();
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
return this.impl.
|
|
24
|
+
async createInboundServer(input) {
|
|
25
|
+
return this.impl.createInboundServer(input);
|
|
26
26
|
}
|
|
27
|
-
async
|
|
28
|
-
return this.impl.
|
|
27
|
+
async removeInboundServer(id) {
|
|
28
|
+
return this.impl.removeInboundServer(id);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
return this.impl.
|
|
30
|
+
async setInboundServerEnabled(id, enabled) {
|
|
31
|
+
return this.impl.setInboundServerEnabled(id, enabled);
|
|
32
32
|
}
|
|
33
|
-
async
|
|
34
|
-
return this.impl.
|
|
33
|
+
async updateInboundServer(id, patch) {
|
|
34
|
+
return this.impl.updateInboundServer(id, patch);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
return this.impl.
|
|
36
|
+
listOutboundServers() {
|
|
37
|
+
return this.impl.listOutboundServers();
|
|
38
38
|
}
|
|
39
|
-
async
|
|
40
|
-
return this.impl.
|
|
39
|
+
async createOutboundServer(input) {
|
|
40
|
+
return this.impl.createOutboundServer(input);
|
|
41
41
|
}
|
|
42
|
-
async
|
|
43
|
-
return this.impl.
|
|
42
|
+
async removeOutboundServer(id) {
|
|
43
|
+
return this.impl.removeOutboundServer(id);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
return this.impl.
|
|
45
|
+
async setOutboundServerEnabled(id, enabled) {
|
|
46
|
+
return this.impl.setOutboundServerEnabled(id, enabled);
|
|
47
47
|
}
|
|
48
|
-
async
|
|
49
|
-
return this.impl.
|
|
48
|
+
async refreshOutboundServer(id) {
|
|
49
|
+
return this.impl.refreshOutboundServer(id);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
return this.impl.
|
|
51
|
+
getTask(taskId) {
|
|
52
|
+
return this.impl.getTask(taskId);
|
|
53
|
+
}
|
|
54
|
+
listTasks() {
|
|
55
|
+
return this.impl.listTasks();
|
|
56
|
+
}
|
|
57
|
+
async cancelTask(taskId) {
|
|
58
|
+
return this.impl.cancelTask(taskId);
|
|
53
59
|
}
|
|
54
60
|
inbounds() {
|
|
55
61
|
return this.impl.inbounds();
|
|
56
62
|
}
|
|
63
|
+
async closeInbound(peerId) {
|
|
64
|
+
return this.impl.closeInbound(peerId);
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
67
|
//# sourceMappingURL=service.js.map
|
package/lib/types/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAgB,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAgB,MAAM,qBAAqB,CAAA;AAsG3D,mDAAmD;AACnD,MAAM,OAAO,UAAW,SAAQ,OAAO;IAGlB;IAFnB,YACE,GAAY,EACK,IAAoB;QAErC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAFA,SAAI,GAAJ,IAAI,CAAgB;IAGvC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;IAC5B,CAAC;IAED,kBAAkB;QAChB,OA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O,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAA;IAC9B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACrC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAc;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;IACvC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanphone/dsh-a2a",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Agent2Agent (A2A) v1.0 dual-end plugin for DeepSeek Harness:
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Agent2Agent (A2A) v1.0.1 dual-end plugin for DeepSeek Harness: multiple inbound servers (per-instance agent presets, creator-declared skill advertisements), multiple outbound connections, GUI-managed instance lifecycle.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
package/src/api.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* GUI control API for the A2A settings dashboard: one `GET /a2a/api`
|
|
3
|
-
* snapshot plus `POST /a2a/api` control actions (server
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* snapshot plus `POST /a2a/api` control actions (inbound/outbound server
|
|
4
|
+
* CRUD + enable/disable, task view/cancel) and `GET /a2a/api/presets` for the
|
|
5
|
+
* preset roster the pickers need. The browser half talks only to this route;
|
|
6
|
+
* it carries no protocol knowledge. Loopback-only by default so the dashboard
|
|
7
|
+
* cannot be driven from the wire.
|
|
7
8
|
*
|
|
8
9
|
* The route body is bound to the same `A2AServiceImpl` facade the `/a2a`
|
|
9
10
|
* command surface uses, so GUI actions and commands cannot disagree.
|
|
@@ -15,27 +16,19 @@ import type { A2AServiceImpl } from './service.ts'
|
|
|
15
16
|
|
|
16
17
|
/** Control actions the dashboard can issue. */
|
|
17
18
|
export type ApiAction =
|
|
18
|
-
| { readonly action: '
|
|
19
|
-
| { readonly action: '
|
|
20
|
-
| { readonly action: '
|
|
19
|
+
| { readonly action: 'inbound.create'; readonly name: string; readonly description: string; readonly version: string; readonly endpointPath?: string; readonly preset?: string; readonly authTokenEnv?: string; readonly skills?: readonly { id: string; name: string; description?: string }[]; readonly enabled?: boolean }
|
|
20
|
+
| { readonly action: 'inbound.remove' | 'inbound.enable' | 'inbound.disable' | 'inbound.update'; readonly id: string; readonly name?: string; readonly description?: string; readonly version?: string; readonly endpointPath?: string; readonly preset?: string; readonly authTokenEnv?: string; readonly skills?: readonly { id: string; name: string; description?: string }[] }
|
|
21
|
+
| { readonly action: 'outbound.create'; readonly name: string; readonly agentCardUrl: string; readonly bearerTokenEnv?: string; readonly preset?: string; readonly enabled?: boolean; readonly timeoutMs?: number }
|
|
22
|
+
| { readonly action: 'outbound.remove' | 'outbound.enable' | 'outbound.disable' | 'outbound.refresh'; readonly id: string }
|
|
21
23
|
| { readonly action: 'task.cancel'; readonly id: string }
|
|
22
|
-
| { readonly action: 'identity.update'; readonly name?: string; readonly description?: string; readonly version?: string }
|
|
23
24
|
| { readonly action: 'inbound.close'; readonly id: string }
|
|
24
25
|
|
|
25
26
|
/** One snapshot of the whole plugin for the dashboard. */
|
|
26
27
|
export interface ApiSnapshot {
|
|
27
|
-
readonly server: {
|
|
28
|
-
readonly enabled: boolean
|
|
29
|
-
readonly cardUrl?: string
|
|
30
|
-
readonly skills: readonly string[]
|
|
31
|
-
readonly name?: string
|
|
32
|
-
readonly description?: string
|
|
33
|
-
readonly version?: string
|
|
34
|
-
readonly configured: boolean
|
|
35
|
-
}
|
|
36
|
-
readonly tasks: readonly unknown[]
|
|
37
|
-
readonly agents: readonly unknown[]
|
|
38
28
|
readonly inbounds: readonly unknown[]
|
|
29
|
+
readonly outbounds: readonly unknown[]
|
|
30
|
+
readonly tasks: readonly unknown[]
|
|
31
|
+
readonly peers: readonly unknown[]
|
|
39
32
|
}
|
|
40
33
|
|
|
41
34
|
function readBody(req: IncomingMessage): Promise<string> {
|
|
@@ -69,6 +62,11 @@ export async function handleApiRequest(
|
|
|
69
62
|
res.end('forbidden')
|
|
70
63
|
return
|
|
71
64
|
}
|
|
65
|
+
const path = (req.url ?? '').split('?')[0] ?? ''
|
|
66
|
+
if (req.method === 'GET' && path === '/a2a/api/presets') {
|
|
67
|
+
json(res, 200, await impl.presets())
|
|
68
|
+
return
|
|
69
|
+
}
|
|
72
70
|
if (req.method === 'GET') {
|
|
73
71
|
json(res, 200, snapshotOf(impl))
|
|
74
72
|
return
|
|
@@ -90,51 +88,67 @@ export async function handleApiRequest(
|
|
|
90
88
|
}
|
|
91
89
|
|
|
92
90
|
function snapshotOf(impl: A2AServiceImpl): ApiSnapshot {
|
|
93
|
-
const status = impl.status() as {
|
|
94
|
-
server: {
|
|
95
|
-
enabled: boolean
|
|
96
|
-
cardUrl?: string
|
|
97
|
-
skills: readonly string[]
|
|
98
|
-
name?: string
|
|
99
|
-
description?: string
|
|
100
|
-
version?: string
|
|
101
|
-
configured: boolean
|
|
102
|
-
}
|
|
103
|
-
tasks: number
|
|
104
|
-
agents: readonly unknown[]
|
|
105
|
-
inbounds: readonly unknown[]
|
|
106
|
-
}
|
|
91
|
+
const status = impl.status() as { inbounds: readonly unknown[]; outbounds: readonly unknown[]; tasks: number; peers?: readonly unknown[] }
|
|
107
92
|
return {
|
|
108
|
-
server: status.server,
|
|
109
|
-
tasks: impl.listTasks() as readonly unknown[],
|
|
110
|
-
agents: impl.agents() as readonly unknown[],
|
|
111
93
|
inbounds: status.inbounds ?? [],
|
|
94
|
+
outbounds: status.outbounds ?? [],
|
|
95
|
+
tasks: impl.listTasks() as readonly unknown[],
|
|
96
|
+
// `status()` may already carry aggregated peers; fall back to the facade.
|
|
97
|
+
peers: (status.peers ?? impl.inbounds()) as readonly unknown[],
|
|
112
98
|
}
|
|
113
99
|
}
|
|
114
100
|
|
|
115
101
|
async function dispatch(payload: ApiAction, impl: A2AServiceImpl): Promise<{ readonly ok: boolean; readonly message: string }> {
|
|
116
102
|
switch (payload.action) {
|
|
117
|
-
case '
|
|
118
|
-
return impl.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
103
|
+
case 'inbound.create':
|
|
104
|
+
return impl.createInboundServer({
|
|
105
|
+
name: payload.name,
|
|
106
|
+
description: payload.description,
|
|
107
|
+
version: payload.version,
|
|
108
|
+
...(payload.endpointPath !== undefined ? { endpointPath: payload.endpointPath } : {}),
|
|
109
|
+
...(payload.preset !== undefined ? { preset: payload.preset } : {}),
|
|
110
|
+
...(payload.authTokenEnv !== undefined ? { authTokenEnv: payload.authTokenEnv } : {}),
|
|
111
|
+
...(payload.skills !== undefined ? { skills: payload.skills } : {}),
|
|
112
|
+
...(payload.enabled !== undefined ? { enabled: payload.enabled } : {}),
|
|
113
|
+
})
|
|
114
|
+
case 'inbound.remove':
|
|
115
|
+
return impl.removeInboundServer(payload.id)
|
|
116
|
+
case 'inbound.enable':
|
|
117
|
+
return impl.setInboundServerEnabled(payload.id, true)
|
|
118
|
+
case 'inbound.disable':
|
|
119
|
+
return impl.setInboundServerEnabled(payload.id, false)
|
|
120
|
+
case 'inbound.update':
|
|
121
|
+
return impl.updateInboundServer(payload.id, {
|
|
122
|
+
...(payload.name !== undefined ? { name: payload.name } : {}),
|
|
123
|
+
...(payload.description !== undefined ? { description: payload.description } : {}),
|
|
124
|
+
...(payload.version !== undefined ? { version: payload.version } : {}),
|
|
125
|
+
...(payload.endpointPath !== undefined ? { endpointPath: payload.endpointPath } : {}),
|
|
126
|
+
...(payload.preset !== undefined ? { preset: payload.preset } : {}),
|
|
127
|
+
...(payload.authTokenEnv !== undefined ? { authTokenEnv: payload.authTokenEnv } : {}),
|
|
128
|
+
...(payload.skills !== undefined ? { skills: payload.skills } : {}),
|
|
129
|
+
})
|
|
130
|
+
case 'outbound.create':
|
|
131
|
+
return impl.createOutboundServer({
|
|
132
|
+
name: payload.name,
|
|
133
|
+
agentCardUrl: payload.agentCardUrl,
|
|
134
|
+
...(payload.bearerTokenEnv !== undefined ? { bearerTokenEnv: payload.bearerTokenEnv } : {}),
|
|
135
|
+
...(payload.preset !== undefined ? { preset: payload.preset } : {}),
|
|
136
|
+
...(payload.enabled !== undefined ? { enabled: payload.enabled } : {}),
|
|
137
|
+
...(payload.timeoutMs !== undefined ? { timeoutMs: payload.timeoutMs } : {}),
|
|
138
|
+
})
|
|
139
|
+
case 'outbound.remove':
|
|
140
|
+
return impl.removeOutboundServer(payload.id)
|
|
141
|
+
case 'outbound.enable':
|
|
142
|
+
return impl.setOutboundServerEnabled(payload.id, true)
|
|
143
|
+
case 'outbound.disable':
|
|
144
|
+
return impl.setOutboundServerEnabled(payload.id, false)
|
|
145
|
+
case 'outbound.refresh':
|
|
146
|
+
return impl.refreshOutboundServer(payload.id)
|
|
131
147
|
case 'task.cancel':
|
|
132
148
|
return impl.cancelTask(payload.id)
|
|
133
|
-
case 'identity.update':
|
|
134
|
-
return impl.updateIdentity({ ...(payload.name !== undefined ? { name: payload.name } : {}), ...(payload.description !== undefined ? { description: payload.description } : {}), ...(payload.version !== undefined ? { version: payload.version } : {}) })
|
|
135
149
|
case 'inbound.close':
|
|
136
150
|
return impl.closeInbound(payload.id)
|
|
137
151
|
default:
|
|
138
152
|
return { ok: false, message: `unknown action ${String((payload as { action?: unknown }).action)}` }
|
|
139
153
|
}
|
|
140
|
-
}
|
|
154
|
+
}
|