@hanphone/dsh-a2a 0.1.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.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +196 -0
  3. package/README.zh.md +195 -0
  4. package/cordis.patch.yml +11 -0
  5. package/lib/client.js +166 -0
  6. package/lib/index.js +2073 -0
  7. package/lib/tsconfig.client.tsbuildinfo +1 -0
  8. package/lib/tsconfig.tsbuildinfo +1 -0
  9. package/lib/types/api.d.ts +41 -0
  10. package/lib/types/api.d.ts.map +1 -0
  11. package/lib/types/api.js +86 -0
  12. package/lib/types/api.js.map +1 -0
  13. package/lib/types/client/index.d.ts +35 -0
  14. package/lib/types/client/index.d.ts.map +1 -0
  15. package/lib/types/client/index.js +155 -0
  16. package/lib/types/client/index.js.map +1 -0
  17. package/lib/types/commands.d.ts +10 -0
  18. package/lib/types/commands.d.ts.map +1 -0
  19. package/lib/types/commands.js +93 -0
  20. package/lib/types/commands.js.map +1 -0
  21. package/lib/types/events.d.ts +74 -0
  22. package/lib/types/events.d.ts.map +1 -0
  23. package/lib/types/events.js +10 -0
  24. package/lib/types/events.js.map +1 -0
  25. package/lib/types/index.d.ts +54 -0
  26. package/lib/types/index.d.ts.map +1 -0
  27. package/lib/types/index.js +296 -0
  28. package/lib/types/index.js.map +1 -0
  29. package/lib/types/jsonrpc.d.ts +20 -0
  30. package/lib/types/jsonrpc.d.ts.map +1 -0
  31. package/lib/types/jsonrpc.js +48 -0
  32. package/lib/types/jsonrpc.js.map +1 -0
  33. package/lib/types/outbound/calls.d.ts +37 -0
  34. package/lib/types/outbound/calls.d.ts.map +1 -0
  35. package/lib/types/outbound/calls.js +120 -0
  36. package/lib/types/outbound/calls.js.map +1 -0
  37. package/lib/types/outbound/registry.d.ts +102 -0
  38. package/lib/types/outbound/registry.d.ts.map +1 -0
  39. package/lib/types/outbound/registry.js +249 -0
  40. package/lib/types/outbound/registry.js.map +1 -0
  41. package/lib/types/outbound/tools.d.ts +30 -0
  42. package/lib/types/outbound/tools.d.ts.map +1 -0
  43. package/lib/types/outbound/tools.js +86 -0
  44. package/lib/types/outbound/tools.js.map +1 -0
  45. package/lib/types/protocol.d.ts +194 -0
  46. package/lib/types/protocol.d.ts.map +1 -0
  47. package/lib/types/protocol.js +78 -0
  48. package/lib/types/protocol.js.map +1 -0
  49. package/lib/types/server/a2a-server.d.ts +98 -0
  50. package/lib/types/server/a2a-server.d.ts.map +1 -0
  51. package/lib/types/server/a2a-server.js +397 -0
  52. package/lib/types/server/a2a-server.js.map +1 -0
  53. package/lib/types/server/card.d.ts +48 -0
  54. package/lib/types/server/card.d.ts.map +1 -0
  55. package/lib/types/server/card.js +75 -0
  56. package/lib/types/server/card.js.map +1 -0
  57. package/lib/types/server/exec/agent-runtime.d.ts +126 -0
  58. package/lib/types/server/exec/agent-runtime.d.ts.map +1 -0
  59. package/lib/types/server/exec/agent-runtime.js +138 -0
  60. package/lib/types/server/exec/agent-runtime.js.map +1 -0
  61. package/lib/types/server/exec/session.d.ts +11 -0
  62. package/lib/types/server/exec/session.d.ts.map +1 -0
  63. package/lib/types/server/exec/session.js +22 -0
  64. package/lib/types/server/exec/session.js.map +1 -0
  65. package/lib/types/server/exec/subagent.d.ts +39 -0
  66. package/lib/types/server/exec/subagent.d.ts.map +1 -0
  67. package/lib/types/server/exec/subagent.js +44 -0
  68. package/lib/types/server/exec/subagent.js.map +1 -0
  69. package/lib/types/server/executor.d.ts +63 -0
  70. package/lib/types/server/executor.d.ts.map +1 -0
  71. package/lib/types/server/executor.js +38 -0
  72. package/lib/types/server/executor.js.map +1 -0
  73. package/lib/types/server/routes.d.ts +32 -0
  74. package/lib/types/server/routes.d.ts.map +1 -0
  75. package/lib/types/server/routes.js +131 -0
  76. package/lib/types/server/routes.js.map +1 -0
  77. package/lib/types/server/store.d.ts +157 -0
  78. package/lib/types/server/store.d.ts.map +1 -0
  79. package/lib/types/server/store.js +239 -0
  80. package/lib/types/server/store.js.map +1 -0
  81. package/lib/types/service.d.ts +49 -0
  82. package/lib/types/service.d.ts.map +1 -0
  83. package/lib/types/service.js +46 -0
  84. package/lib/types/service.js.map +1 -0
  85. package/package.json +82 -0
  86. package/src/api.ts +115 -0
  87. package/src/client/index.ts +293 -0
  88. package/src/commands.ts +92 -0
  89. package/src/events.ts +58 -0
  90. package/src/index.ts +353 -0
  91. package/src/jsonrpc.ts +61 -0
  92. package/src/outbound/calls.ts +145 -0
  93. package/src/outbound/registry.ts +290 -0
  94. package/src/outbound/tools.ts +118 -0
  95. package/src/protocol.ts +212 -0
  96. package/src/server/a2a-server.ts +455 -0
  97. package/src/server/card.ts +106 -0
  98. package/src/server/exec/agent-runtime.ts +197 -0
  99. package/src/server/exec/session.ts +25 -0
  100. package/src/server/exec/subagent.ts +67 -0
  101. package/src/server/executor.ts +73 -0
  102. package/src/server/routes.ts +156 -0
  103. package/src/server/store.ts +320 -0
  104. package/src/service.ts +78 -0
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Shared agent machinery for the inbound executors: one DSH agent session per
3
+ * A2A context (create, or resume a persisted one), serialized turns, and
4
+ * optional agent-preset composition so a spawned session actually carries
5
+ * tools. Adapted from the createDshAgentExecutor pattern pioneered by
6
+ * dsh-a2a (MIT).
7
+ * @module dsh-a2a/server/exec/agent-runtime
8
+ */
9
+ import type { Context } from '@deepseek-ai/cordis';
10
+ /** The slice of a live DSH `Agent` this runtime drives (structural mirror). */
11
+ export interface LiveAgent {
12
+ readonly session: {
13
+ deriveMessages(): readonly AgentMessage[];
14
+ };
15
+ send(message: AgentUserMessage, target: 'next-turn', wakeup: boolean): void;
16
+ whenIdle(): Promise<void>;
17
+ cancel(cause: string): void;
18
+ }
19
+ /** One derived history message. */
20
+ export interface AgentMessage {
21
+ readonly role: 'user' | 'assistant';
22
+ readonly content: readonly {
23
+ readonly type: string;
24
+ readonly text?: string;
25
+ }[];
26
+ }
27
+ /** One user message handed to the agent. */
28
+ export interface AgentUserMessage {
29
+ readonly id: string;
30
+ readonly role: 'user';
31
+ readonly content: readonly {
32
+ readonly type: 'text';
33
+ readonly text: string;
34
+ }[];
35
+ readonly source: {
36
+ readonly kind: 'plugin';
37
+ readonly plugin: string;
38
+ };
39
+ }
40
+ /** Owned agent plus its capability disposer (structural mirror of AgentHandle). */
41
+ export interface AgentHandle {
42
+ readonly agent: LiveAgent;
43
+ dispose(): Promise<void>;
44
+ }
45
+ /** Structural slice of `ctx.agents` this runtime calls. */
46
+ export interface AgentRegistryLike {
47
+ create(options: {
48
+ readonly sessionId: string;
49
+ readonly meta?: {
50
+ readonly cwd?: string;
51
+ readonly agentPreset?: string;
52
+ };
53
+ readonly agentOptions?: {
54
+ readonly provider?: string;
55
+ readonly model?: string;
56
+ readonly maxTokens?: number;
57
+ };
58
+ readonly setup?: (agentCtx: unknown) => void | Promise<void>;
59
+ }): Promise<AgentHandle>;
60
+ resume(options: {
61
+ readonly resumeSessionId: string;
62
+ readonly agentOptions?: {
63
+ readonly provider?: string;
64
+ readonly model?: string;
65
+ readonly maxTokens?: number;
66
+ };
67
+ readonly setup?: (agentCtx: unknown) => void | Promise<void>;
68
+ }): Promise<AgentHandle>;
69
+ }
70
+ /** Structural slice of `ctx.agentPresets` (preset roster). */
71
+ export interface AgentPresetsLike {
72
+ resolve(id?: string): Promise<{
73
+ readonly id: string;
74
+ }>;
75
+ mount(agentCtx: unknown, id: string): Promise<unknown>;
76
+ }
77
+ /** Runtime options shared by the executors. */
78
+ export interface AgentRuntimeOptions {
79
+ /** Absolute cwd frozen into each spawned session's durable header. */
80
+ readonly cwd: string;
81
+ /** Optional per-task model resolution (reads the deployment default). */
82
+ readonly resolveAgentOptions?: () => {
83
+ readonly provider?: string;
84
+ readonly model?: string;
85
+ readonly maxTokens?: number;
86
+ } | undefined;
87
+ /** Preset roster; when present every spawned session joins the default preset. */
88
+ readonly agentPresets?: AgentPresetsLike;
89
+ /** Once-per-context hook after the first prompt lands (cosmetic naming). */
90
+ readonly onSessionOpened?: (info: {
91
+ readonly sessionId: string;
92
+ readonly contextId: string;
93
+ readonly firstPrompt: string;
94
+ }) => void | Promise<void>;
95
+ }
96
+ /**
97
+ * Per-context session pool: one live DSH agent per A2A contextId, created or
98
+ * resumed through the registry, turns serialized per context, every session
99
+ * disposeable on teardown.
100
+ */
101
+ export declare class ContextSessionPool {
102
+ private readonly agents;
103
+ private readonly opts;
104
+ private readonly handles;
105
+ private readonly tails;
106
+ constructor(agents: AgentRegistryLike, opts: AgentRuntimeOptions);
107
+ /** Session id derived from the A2A context id (stable across restarts). */
108
+ static sessionIdFor(contextId: string): string;
109
+ /** Get or open the live agent for a context; errors propagate. */
110
+ agentFor(contextId: string): Promise<{
111
+ readonly agent: LiveAgent;
112
+ readonly sessionId: string;
113
+ readonly justOpened: boolean;
114
+ }>;
115
+ /** Run one turn on a context's session, serialized behind its tail. */
116
+ runTurn(contextId: string, prompt: string, signal: AbortSignal): Promise<string>;
117
+ /** Dispose every live per-context session (called on plugin unload). */
118
+ disposeAll(): Promise<void>;
119
+ }
120
+ /**
121
+ * Probe for a readable service method via the reflection layer WITHOUT taking
122
+ * an inject dependency (optional services). Returns undefined when the service
123
+ * is absent or the method missing.
124
+ */
125
+ export declare function probeService(ctx: Context, name: string, method: string): unknown;
126
+ //# sourceMappingURL=agent-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-runtime.d.ts","sourceRoot":"","sources":["../../../../src/server/exec/agent-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,+EAA+E;AAC/E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE;QAAE,cAAc,IAAI,SAAS,YAAY,EAAE,CAAA;KAAE,CAAA;IAC/D,IAAI,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;IA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AAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAShF"}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Shared agent machinery for the inbound executors: one DSH agent session per
3
+ * A2A context (create, or resume a persisted one), serialized turns, and
4
+ * optional agent-preset composition so a spawned session actually carries
5
+ * tools. Adapted from the createDshAgentExecutor pattern pioneered by
6
+ * dsh-a2a (MIT).
7
+ * @module dsh-a2a/server/exec/agent-runtime
8
+ */
9
+ /**
10
+ * Per-context session pool: one live DSH agent per A2A contextId, created or
11
+ * resumed through the registry, turns serialized per context, every session
12
+ * disposeable on teardown.
13
+ */
14
+ export class ContextSessionPool {
15
+ agents;
16
+ opts;
17
+ handles = new Map();
18
+ tails = new Map();
19
+ constructor(agents, opts) {
20
+ this.agents = agents;
21
+ this.opts = opts;
22
+ }
23
+ /** Session id derived from the A2A context id (stable across restarts). */
24
+ static sessionIdFor(contextId) {
25
+ return `a2a-${contextId}`;
26
+ }
27
+ /** Get or open the live agent for a context; errors propagate. */
28
+ async agentFor(contextId) {
29
+ const sessionId = ContextSessionPool.sessionIdFor(contextId);
30
+ const existing = this.handles.get(contextId);
31
+ if (existing !== undefined)
32
+ return { agent: existing.agent, sessionId, justOpened: false };
33
+ const agentOptions = this.opts.resolveAgentOptions?.();
34
+ const withModel = agentOptions ? { agentOptions } : {};
35
+ const presets = this.opts.agentPresets;
36
+ let presetId;
37
+ let setup;
38
+ if (presets !== undefined) {
39
+ presetId = (await presets.resolve()).id;
40
+ setup = async (agentCtx) => {
41
+ await presets.mount(agentCtx, presetId);
42
+ };
43
+ }
44
+ const meta = presetId
45
+ ? { cwd: this.opts.cwd, agentPreset: presetId }
46
+ : { cwd: this.opts.cwd };
47
+ const createOptions = {
48
+ sessionId,
49
+ meta,
50
+ ...withModel,
51
+ ...(setup ? { setup } : {}),
52
+ };
53
+ let handle;
54
+ try {
55
+ handle = await this.agents.create(createOptions);
56
+ }
57
+ catch (err) {
58
+ if (/already (has|owns)|persisted/i.test(err.message)) {
59
+ handle = await this.agents.resume({ resumeSessionId: sessionId, ...withModel, ...(setup ? { setup } : {}) });
60
+ }
61
+ else {
62
+ throw err;
63
+ }
64
+ }
65
+ this.handles.set(contextId, handle);
66
+ return { agent: handle.agent, sessionId, justOpened: true };
67
+ }
68
+ /** Run one turn on a context's session, serialized behind its tail. */
69
+ async runTurn(contextId, prompt, signal) {
70
+ const { agent, sessionId, justOpened } = await this.agentFor(contextId);
71
+ const onAbort = () => agent.cancel('a2a-canceled');
72
+ if (signal.aborted)
73
+ onAbort();
74
+ else
75
+ signal.addEventListener('abort', onAbort, { once: true });
76
+ const userMessage = {
77
+ id: crypto.randomUUID(),
78
+ role: 'user',
79
+ content: [{ type: 'text', text: prompt }],
80
+ source: { kind: 'plugin', plugin: 'a2a' },
81
+ };
82
+ agent.send(userMessage, 'next-turn', true);
83
+ if (justOpened) {
84
+ try {
85
+ await this.opts.onSessionOpened?.({ sessionId, contextId, firstPrompt: prompt });
86
+ }
87
+ catch {
88
+ // Cosmetic naming must never fail the task.
89
+ }
90
+ }
91
+ await agent.whenIdle();
92
+ return lastAssistantText(agent);
93
+ }
94
+ /** Dispose every live per-context session (called on plugin unload). */
95
+ async disposeAll() {
96
+ const live = [...this.handles.values()];
97
+ const pending = [...this.tails.values()];
98
+ this.handles.clear();
99
+ this.tails.clear();
100
+ await Promise.allSettled(pending);
101
+ await Promise.allSettled(live.map((h) => h.dispose()));
102
+ }
103
+ }
104
+ /** Read the last assistant message's text off the derived history. */
105
+ function lastAssistantText(agent) {
106
+ const history = agent.session.deriveMessages();
107
+ for (let i = history.length - 1; i >= 0; i--) {
108
+ const message = history[i];
109
+ if (message === undefined)
110
+ continue;
111
+ if (message.role === 'assistant') {
112
+ return message.content
113
+ .map((b) => ('text' in b && typeof b.text === 'string' ? (b.text ?? '') : ''))
114
+ .filter(Boolean)
115
+ .join('\n')
116
+ .trim();
117
+ }
118
+ }
119
+ return '';
120
+ }
121
+ /**
122
+ * Probe for a readable service method via the reflection layer WITHOUT taking
123
+ * an inject dependency (optional services). Returns undefined when the service
124
+ * is absent or the method missing.
125
+ */
126
+ export function probeService(ctx, name, method) {
127
+ try {
128
+ const reflect = ctx.reflect;
129
+ const svc = reflect?.get(name, true);
130
+ if (svc !== undefined && svc !== null && typeof svc[method] === 'function')
131
+ return svc;
132
+ }
133
+ catch {
134
+ // reflection unavailable or resolution threw — treat as absent
135
+ }
136
+ return undefined;
137
+ }
138
+ //# sourceMappingURL=agent-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-runtime.js","sourceRoot":"","sources":["../../../../src/server/exec/agent-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiEH;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAKV;IACA;IALF,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAA;IACxC,KAAK,GAAG,IAAI,GAAG,EAA4B,CAAA;IAE5D,YACmB,MAAyB,EACzB,IAAyB;QADzB,WAAM,GAAN,MAAM,CAAmB;QACzB,SAAI,GAAJ,IAAI,CAAqB;IACzC,CAAC;IAEJ,2EAA2E;IAC3E,MAAM,CAAC,YAAY,CAAC,SAAiB;QACnC,OAAO,OAAO,SAAS,EAAE,CAAA;IAC3B,CAAC;IAED,kEAAkE;IAClE,KAAK,CAAC,QAAQ,CAAC,SAAiB;QAC9B,MAAM,SAAS,GAAG,kBAAkB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC5C,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;QAC1F,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,CAAA;QACtD,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,CAAC,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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;iBAC7E,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,IAAI,CAAC;iBACV,IAAI,EAAE,CAAA;QACX,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAY,EAAE,IAAY,EAAE,MAAc;IACrE,IAAI,CAAC;QACH,MAAM,OAAO,GAAI,GAA8E,CAAC,OAAO,CAAA;QACvG,MAAM,GAAG,GAAG,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACpC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,OAAQ,GAA+B,CAAC,MAAM,CAAC,KAAK,UAAU;YAAE,OAAO,GAAG,CAAA;IACrH,CAAC;IAAC,MAAM,CAAC;QACP,+DAA+D;IACjE,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The `session` executor: one inbound task is one turn on the context's DSH
3
+ * agent session; reply text becomes the task's output part. Works on any
4
+ * composition with an agent loop (the `chat` skill and the default path).
5
+ * @module dsh-a2a/server/exec/session
6
+ */
7
+ import type { A2aExecutor } from '../executor.ts';
8
+ import { ContextSessionPool } from './agent-runtime.ts';
9
+ /** Build the session executor over a context session pool. */
10
+ export declare function createSessionExecutor(pool: ContextSessionPool): A2aExecutor;
11
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/server/exec/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAuC,MAAM,gBAAgB,CAAA;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,8DAA8D;AAC9D,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,GAAG,WAAW,CAa3E"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The `session` executor: one inbound task is one turn on the context's DSH
3
+ * agent session; reply text becomes the task's output part. Works on any
4
+ * composition with an agent loop (the `chat` skill and the default path).
5
+ * @module dsh-a2a/server/exec/session
6
+ */
7
+ /** Build the session executor over a context session pool. */
8
+ export function createSessionExecutor(pool) {
9
+ return {
10
+ name: 'session',
11
+ async execute(input) {
12
+ if (!input.prompt) {
13
+ return { parts: [{ text: 'No prompt provided.' }] };
14
+ }
15
+ const reply = await pool.runTurn(input.contextId, input.prompt, input.signal);
16
+ const text = (input.signal.aborted && !reply ? '(canceled)' : reply) || '(no reply)';
17
+ return { parts: [{ text }] };
18
+ },
19
+ disposeAll: () => pool.disposeAll(),
20
+ };
21
+ }
22
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/server/exec/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,8DAA8D;AAC9D,MAAM,UAAU,qBAAqB,CAAC,IAAwB;IAC5D,OAAO;QACL,IAAI,EAAE,SAAS;QACf,KAAK,CAAC,OAAO,CAAC,KAAuB;YACnC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBAClB,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAA;YACrD,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;YAC7E,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,CAAA;YACpF,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;QAC9B,CAAC;QACD,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE;KACpC,CAAA;AACH,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The `subagent` executor: one inbound task is delegated to a named one-shot
3
+ * subagent under the context's parent session. The child runs with the
4
+ * composition's own tools and the delegation boundary; its output becomes the
5
+ * task's artifact. The subagent seam must be mounted, else the skill binding
6
+ * fails loudly at resolution time.
7
+ * @module dsh-a2a/server/exec/subagent
8
+ */
9
+ import type { A2aExecutor } from '../executor.ts';
10
+ import { ContextSessionPool } from './agent-runtime.ts';
11
+ /** Structural slice of `ctx.subagents` this executor calls. */
12
+ export interface SubagentsLike {
13
+ start(name: string, request: {
14
+ readonly label?: string;
15
+ readonly prompt: readonly {
16
+ readonly type: 'text';
17
+ readonly text: string;
18
+ }[];
19
+ readonly parent: unknown;
20
+ readonly signal: AbortSignal;
21
+ }): Promise<{
22
+ readonly result: Promise<{
23
+ readonly output: readonly {
24
+ readonly type: string;
25
+ readonly text?: string;
26
+ }[];
27
+ }>;
28
+ dispose(): Promise<void>;
29
+ }>;
30
+ }
31
+ export interface SubagentExecutorOptions {
32
+ readonly pool: ContextSessionPool;
33
+ readonly subagents: SubagentsLike;
34
+ /** Provider name (e.g. 'in-process'); configurable per deployment. */
35
+ readonly provider: string;
36
+ }
37
+ /** Build a subagent executor delegating inbound tasks to one-shot children. */
38
+ export declare function createSubagentExecutor(opts: SubagentExecutorOptions): A2aExecutor;
39
+ //# sourceMappingURL=subagent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../../../src/server/exec/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAuC,MAAM,gBAAgB,CAAA;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,KAAK,CACH,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QACP,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;QACvB,QAAQ,CAAC,MAAM,EAAE,SAAS;YAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;QAC5E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;QACxB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;KAC7B,GACA,OAAO,CAAC;QAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;YAAE,QAAQ,CAAC,MAAM,EAAE,SAAS;gBAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,CAAC,CAAC;QAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAA;CACtJ;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;IACjC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAA;IACjC,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,uBAAuB,GAAG,WAAW,CAiCjF"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The `subagent` executor: one inbound task is delegated to a named one-shot
3
+ * subagent under the context's parent session. The child runs with the
4
+ * composition's own tools and the delegation boundary; its output becomes the
5
+ * task's artifact. The subagent seam must be mounted, else the skill binding
6
+ * fails loudly at resolution time.
7
+ * @module dsh-a2a/server/exec/subagent
8
+ */
9
+ /** Build a subagent executor delegating inbound tasks to one-shot children. */
10
+ export function createSubagentExecutor(opts) {
11
+ const { pool, subagents, provider } = opts;
12
+ return {
13
+ name: 'subagent',
14
+ async execute(input, execCtx) {
15
+ if (!input.prompt) {
16
+ return { parts: [{ text: 'No prompt provided.' }] };
17
+ }
18
+ const { agent } = await pool.agentFor(input.contextId);
19
+ const run = await subagents.start(provider, {
20
+ label: `a2a:${input.skill}`,
21
+ prompt: [{ type: 'text', text: input.prompt }],
22
+ parent: agent,
23
+ signal: input.signal,
24
+ });
25
+ const result = await run.result;
26
+ const text = result.output
27
+ .filter((b) => typeof b.text === 'string')
28
+ .map((b) => b.text)
29
+ .filter(Boolean)
30
+ .join('\n')
31
+ .trim();
32
+ execCtx.onEvent({
33
+ type: 'artifact',
34
+ artifactId: 'result',
35
+ parts: [{ text: text || '(subagent returned no output)' }],
36
+ name: input.skill,
37
+ lastChunk: true,
38
+ });
39
+ return { parts: [{ text: text || '(subagent returned no output)' }] };
40
+ },
41
+ disposeAll: () => pool.disposeAll(),
42
+ };
43
+ }
44
+ //# sourceMappingURL=subagent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent.js","sourceRoot":"","sources":["../../../../src/server/exec/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAyBH,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CAAC,IAA6B;IAClE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;IAC1C,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,KAAK,CAAC,OAAO,CAAC,KAAuB,EAAE,OAAO;YAC5C,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBAClB,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAA;YACrD,CAAC;YACD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;YACtD,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE;gBAC1C,KAAK,EAAE,OAAO,KAAK,CAAC,KAAK,EAAE;gBAC3B,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC9C,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAA;YACF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAA;YAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM;iBACvB,MAAM,CAAC,CAAC,CAAC,EAAyD,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;iBAChG,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAClB,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,IAAI,CAAC;iBACV,IAAI,EAAE,CAAA;YACT,OAAO,CAAC,OAAO,CAAC;gBACd,IAAI,EAAE,UAAU;gBAChB,UAAU,EAAE,QAAQ;gBACpB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,+BAA+B,EAAE,CAAC;gBAC1D,IAAI,EAAE,KAAK,CAAC,KAAK;gBACjB,SAAS,EAAE,IAAI;aAChB,CAAC,CAAA;YACF,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,+BAA+B,EAAE,CAAC,EAAE,CAAA;QACvE,CAAC;QACD,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE;KACpC,CAAA;AACH,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Executor abstraction for inbound tasks: an executor turns one task into
3
+ * output parts while reporting status and artifact updates. The registry is
4
+ * INTERNAL (built by the plugin from config) — public registration was cut:
5
+ * there is no external caller yet, so the seam stays an interface with two
6
+ * built-in implementations (session, subagent).
7
+ * @module dsh-a2a/server/executor
8
+ */
9
+ import type { Part, TaskState } from '../protocol.ts';
10
+ /** One update from a running executor. */
11
+ export type A2aExecutorEvent = {
12
+ readonly type: 'status';
13
+ readonly state: TaskState;
14
+ readonly message?: string;
15
+ } | {
16
+ readonly type: 'artifact';
17
+ readonly artifactId: string;
18
+ readonly parts: readonly Part[];
19
+ readonly name?: string;
20
+ readonly lastChunk?: boolean;
21
+ };
22
+ /** Input a task executor receives. */
23
+ export interface A2aExecutorInput {
24
+ readonly taskId: string;
25
+ readonly contextId: string;
26
+ readonly skill: string;
27
+ readonly prompt: string;
28
+ readonly signal: AbortSignal;
29
+ }
30
+ /** Output contract of one executor run. */
31
+ export interface A2aExecutorOutput {
32
+ readonly parts: readonly Part[];
33
+ }
34
+ /** One inbound task executor. */
35
+ export interface A2aExecutor {
36
+ /** Stable kind name ('session' | 'subagent'). */
37
+ readonly name: string;
38
+ /**
39
+ * Run one task. The executor reports progress through `opts.onEvent` and
40
+ * must honor `opts.signal` (cancel = abort remaining work).
41
+ */
42
+ execute(input: A2aExecutorInput, opts: {
43
+ readonly onEvent: (ev: A2aExecutorEvent) => void;
44
+ }): Promise<A2aExecutorOutput>;
45
+ /** Dispose resources owned by the executor (sessions, children). */
46
+ disposeAll?(): Promise<void>;
47
+ }
48
+ /** Executor kind names configurable per skill. */
49
+ export type ExecutorKind = 'session' | 'subagent';
50
+ /**
51
+ * Skill → executor resolution. The subagent executor is absent on
52
+ * compositions without the subagent seam; resolving a skill bound to a
53
+ * missing kind fails loudly with a readable message.
54
+ */
55
+ export declare class ExecutorSet {
56
+ private readonly bySkill;
57
+ private readonly session;
58
+ private readonly subagent;
59
+ constructor(bySkill: Readonly<Record<string, ExecutorKind>>, session: A2aExecutor, subagent: A2aExecutor | undefined);
60
+ resolve(skill: string): A2aExecutor;
61
+ disposeAll(): Promise<void>;
62
+ }
63
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/server/executor.ts"],"names":[],"m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IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B;AAED,kDAAkD;AAClD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,CAAA;AAEjD;;;;GAIG;AACH,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAFR,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,EAC/C,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,WAAW,GAAG,SAAS;IAGpD,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAU7B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAIlC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Executor abstraction for inbound tasks: an executor turns one task into
3
+ * output parts while reporting status and artifact updates. The registry is
4
+ * INTERNAL (built by the plugin from config) — public registration was cut:
5
+ * there is no external caller yet, so the seam stays an interface with two
6
+ * built-in implementations (session, subagent).
7
+ * @module dsh-a2a/server/executor
8
+ */
9
+ /**
10
+ * Skill → executor resolution. The subagent executor is absent on
11
+ * compositions without the subagent seam; resolving a skill bound to a
12
+ * missing kind fails loudly with a readable message.
13
+ */
14
+ export class ExecutorSet {
15
+ bySkill;
16
+ session;
17
+ subagent;
18
+ constructor(bySkill, session, subagent) {
19
+ this.bySkill = bySkill;
20
+ this.session = session;
21
+ this.subagent = subagent;
22
+ }
23
+ resolve(skill) {
24
+ const kind = this.bySkill[skill] ?? 'session';
25
+ if (kind === 'session')
26
+ return this.session;
27
+ const subagent = this.subagent;
28
+ if (subagent === undefined) {
29
+ throw new Error(`a2a: skill "${skill}" is bound to the subagent executor but no subagent seam is mounted`);
30
+ }
31
+ return subagent;
32
+ }
33
+ async disposeAll() {
34
+ await this.session.disposeAll?.();
35
+ await this.subagent?.disposeAll?.();
36
+ }
37
+ }
38
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/server/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAuCH;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAEH;IACA;IACA;IAHnB,YACmB,OAA+C,EAC/C,OAAoB,EACpB,QAAiC;QAFjC,YAAO,GAAP,OAAO,CAAwC;QAC/C,YAAO,GAAP,OAAO,CAAa;QACpB,aAAQ,GAAR,QAAQ,CAAyB;IACjD,CAAC;IAEJ,OAAO,CAAC,KAAa;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,SAAS,CAAA;QAC7C,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,OAAO,CAAA;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,eAAe,KAAK,qEAAqE,CAAC,CAAA;QAC5G,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAA;QACjC,MAAM,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAA;IACrC,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * HTTP binding for the inbound server: registers the AgentCard route and the
3
+ * JSON-RPC / SSE endpoint on a structural webServer (normally
4
+ * `@deepseek-ai/dsh-host-webserver`), with runtime enable/disable.
5
+ * @module dsh-a2a/server/routes
6
+ */
7
+ import type { IncomingMessage, ServerResponse } from 'node:http';
8
+ import type { A2AServer } from './a2a-server.ts';
9
+ /** Structural slice of `ctx.webServer` this module registers on. */
10
+ export interface WebServerLike {
11
+ register(route: {
12
+ readonly kind: 'exact' | 'prefix';
13
+ readonly path: string;
14
+ handler(req: IncomingMessage, res: ServerResponse): void | Promise<void>;
15
+ }): () => void;
16
+ }
17
+ /** Runtime-registered HTTP routes for one A2A server. */
18
+ export declare class A2aRoutes {
19
+ private readonly webServer;
20
+ private readonly server;
21
+ private disposers;
22
+ private registered;
23
+ constructor(webServer: WebServerLike, server: A2AServer);
24
+ get active(): boolean;
25
+ /** Register the AgentCard + endpoint routes (idempotent). */
26
+ enable(): void;
27
+ /** Unregister the routes (idempotent). */
28
+ disable(): void;
29
+ dispose(): void;
30
+ private onRequest;
31
+ }
32
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/server/routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAA;QACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;QACrB,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;KACzE,GAAG,MAAM,IAAI,CAAA;CACf;AAID,yDAAyD;AACzD,qBAAa,SAAS;IAKlB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,UAAU,CAAQ;gBAGP,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,SAAS;IAGpC,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,6DAA6D;IAC7D,MAAM,IAAI,IAAI;IAsBd,0CAA0C;IAC1C,OAAO,IAAI,IAAI;IAKf,OAAO,IAAI,IAAI;YAID,SAAS;CAuCxB"}