@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/src/commands.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `/a2a` command surface: status, server
|
|
3
|
-
* and task control —
|
|
2
|
+
* The `/a2a` command surface: status, inbound/outbound server CRUD +
|
|
3
|
+
* enable/disable, and task control — a text backup to the GUI (the settings
|
|
4
|
+
* panel is the primary surface). All operations delegate to the same
|
|
5
|
+
* `A2AServiceImpl` facade as the dashboard API.
|
|
4
6
|
* @module dsh-a2a/commands
|
|
5
7
|
*/
|
|
6
8
|
|
|
@@ -11,55 +13,67 @@ import type { A2AServiceImpl } from './service.ts'
|
|
|
11
13
|
export function buildA2aCommand(impl: A2AServiceImpl): CommandDefinition {
|
|
12
14
|
return {
|
|
13
15
|
name: 'a2a',
|
|
14
|
-
description: 'Manage the A2A plugin: status,
|
|
16
|
+
description: 'Manage the A2A plugin: status, inbound/outbound servers, tasks.',
|
|
15
17
|
handler: async (invocation: CommandInvocation): Promise<CommandResult> => {
|
|
16
18
|
const [verb, ...rest] = invocation.rawInput.trim().split(/\s+/)
|
|
17
19
|
switch (verb ?? '') {
|
|
18
|
-
case '':
|
|
19
|
-
const status = impl.status() as { server?: unknown; client?: unknown }
|
|
20
|
-
return success(`A2A status\n${JSON.stringify(status, null, 2)}`)
|
|
21
|
-
}
|
|
20
|
+
case '':
|
|
22
21
|
case 'status':
|
|
23
22
|
return success(JSON.stringify(impl.status(), null, 2))
|
|
24
|
-
case '
|
|
25
|
-
return
|
|
26
|
-
case '
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
case 'presets':
|
|
24
|
+
return success(JSON.stringify(await impl.presets(), null, 2))
|
|
25
|
+
case 'inbound': {
|
|
26
|
+
const [action, id, ...args] = rest
|
|
27
|
+
switch (action ?? '') {
|
|
28
|
+
case 'list':
|
|
29
|
+
return success(JSON.stringify(impl.listInboundServers(), null, 2))
|
|
30
|
+
case 'create': {
|
|
31
|
+
const name = args[0]
|
|
32
|
+
if (!name) return error('usage: /a2a inbound create <name> [preset] [description]')
|
|
33
|
+
const preset = args[1]
|
|
34
|
+
return outcome(await impl.createInboundServer({
|
|
35
|
+
name,
|
|
36
|
+
description: args[2] ?? 'An A2A inbound server',
|
|
37
|
+
version: '1.0.0',
|
|
38
|
+
...(preset && preset !== 'default' ? { preset } : {}),
|
|
39
|
+
}))
|
|
40
|
+
}
|
|
41
|
+
case 'remove':
|
|
42
|
+
return id ? outcome(await impl.removeInboundServer(id)) : error('usage: /a2a inbound remove <id>')
|
|
43
|
+
case 'enable':
|
|
44
|
+
return id ? outcome(await impl.setInboundServerEnabled(id, true)) : error('usage: /a2a inbound enable <id>')
|
|
45
|
+
case 'disable':
|
|
46
|
+
return id ? outcome(await impl.setInboundServerEnabled(id, false)) : error('usage: /a2a inbound disable <id>')
|
|
47
|
+
default:
|
|
48
|
+
return error('usage: /a2a inbound list|create|remove|enable|disable ...')
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
case 'outbound': {
|
|
52
|
+
const [action, id, ...args] = rest
|
|
34
53
|
switch (action ?? '') {
|
|
35
|
-
case '
|
|
54
|
+
case 'list':
|
|
55
|
+
return success(JSON.stringify(impl.listOutboundServers(), null, 2))
|
|
56
|
+
case 'create': {
|
|
36
57
|
const url = args[0]
|
|
37
|
-
if (!url) return error('usage: /a2a
|
|
58
|
+
if (!url) return error('usage: /a2a outbound create <agentCardUrl> [name] [preset]')
|
|
38
59
|
const name = args[1] ?? url
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
case 'enable': {
|
|
47
|
-
const id = args[0]
|
|
48
|
-
if (!id) return error('usage: /a2a agent enable <id>')
|
|
49
|
-
return outcome(await impl.setAgentEnabled(id, true))
|
|
50
|
-
}
|
|
51
|
-
case 'disable': {
|
|
52
|
-
const id = args[0]
|
|
53
|
-
if (!id) return error('usage: /a2a agent disable <id>')
|
|
54
|
-
return outcome(await impl.setAgentEnabled(id, false))
|
|
55
|
-
}
|
|
56
|
-
case 'refresh': {
|
|
57
|
-
const id = args[0]
|
|
58
|
-
if (!id) return error('usage: /a2a agent refresh <id>')
|
|
59
|
-
return outcome(await impl.refreshAgentCard(id))
|
|
60
|
+
const preset = args[2]
|
|
61
|
+
return outcome(await impl.createOutboundServer({
|
|
62
|
+
name,
|
|
63
|
+
agentCardUrl: url,
|
|
64
|
+
...(preset && preset !== 'default' ? { preset } : {}),
|
|
65
|
+
}))
|
|
60
66
|
}
|
|
67
|
+
case 'remove':
|
|
68
|
+
return id ? outcome(await impl.removeOutboundServer(id)) : error('usage: /a2a outbound remove <id>')
|
|
69
|
+
case 'enable':
|
|
70
|
+
return id ? outcome(await impl.setOutboundServerEnabled(id, true)) : error('usage: /a2a outbound enable <id>')
|
|
71
|
+
case 'disable':
|
|
72
|
+
return id ? outcome(await impl.setOutboundServerEnabled(id, false)) : error('usage: /a2a outbound disable <id>')
|
|
73
|
+
case 'refresh':
|
|
74
|
+
return id ? outcome(await impl.refreshOutboundServer(id)) : error('usage: /a2a outbound refresh <id>')
|
|
61
75
|
default:
|
|
62
|
-
return error('usage: /a2a
|
|
76
|
+
return error('usage: /a2a outbound list|create|remove|enable|disable|refresh ...')
|
|
63
77
|
}
|
|
64
78
|
}
|
|
65
79
|
case 'tasks':
|
|
@@ -70,8 +84,10 @@ export function buildA2aCommand(impl: A2AServiceImpl): CommandDefinition {
|
|
|
70
84
|
if (action === 'cancel' && id) return outcome(await impl.cancelTask(id))
|
|
71
85
|
return error('usage: /a2a task get|cancel <taskId>')
|
|
72
86
|
}
|
|
87
|
+
case 'peers':
|
|
88
|
+
return success(JSON.stringify(impl.inbounds(), null, 2))
|
|
73
89
|
case 'help':
|
|
74
|
-
return success('a2a
|
|
90
|
+
return success('a2a: status | presets | inbound list/create/remove/enable/disable | outbound list/create/remove/enable/disable/refresh | tasks | task get/cancel <id> | peers | help')
|
|
75
91
|
default:
|
|
76
92
|
return error(`unknown a2a verb "${verb}" (try /a2a help)`)
|
|
77
93
|
}
|
|
@@ -89,4 +105,4 @@ function error(text: string): CommandResult {
|
|
|
89
105
|
|
|
90
106
|
function outcome(result: { readonly ok: boolean; readonly message: string }): CommandResult {
|
|
91
107
|
return result.ok ? success(result.message) : error(result.message)
|
|
92
|
-
}
|
|
108
|
+
}
|
package/src/events.ts
CHANGED
|
@@ -25,15 +25,22 @@ export interface InboundTaskDecision {
|
|
|
25
25
|
/** The facade other plugins read as `ctx.a2a`. */
|
|
26
26
|
export interface A2AServiceLike {
|
|
27
27
|
status(): unknown
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
presets(): Promise<Array<{ id: string; name?: string; description?: string }>>
|
|
29
|
+
listInboundServers(): unknown
|
|
30
|
+
createInboundServer(input: unknown): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
31
|
+
removeInboundServer(id: string): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
32
|
+
setInboundServerEnabled(id: string, enabled: boolean): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
33
|
+
updateInboundServer(id: string, patch: unknown): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
34
|
+
listOutboundServers(): unknown
|
|
35
|
+
createOutboundServer(input: unknown): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
36
|
+
removeOutboundServer(id: string): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
37
|
+
setOutboundServerEnabled(id: string, enabled: boolean): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
38
|
+
refreshOutboundServer(id: string): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
30
39
|
getTask(taskId: string): unknown
|
|
40
|
+
listTasks(): unknown
|
|
31
41
|
cancelTask(taskId: string): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
removeAgent(id: string): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
35
|
-
setAgentEnabled(id: string, enabled: boolean): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
36
|
-
refreshAgentCard(id: string): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
42
|
+
inbounds(): unknown
|
|
43
|
+
closeInbound(peerId: string): Promise<{ readonly ok: boolean; readonly message: string }>
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
declare module '@deepseek-ai/cordis' {
|