@hazeljs/agent 0.3.0 → 0.3.1
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/coverage/clover.xml +388 -303
- package/coverage/lcov-report/index.html +44 -29
- package/coverage/lcov.info +657 -459
- package/dist/a2a/a2a.server.d.ts +92 -0
- package/dist/a2a/a2a.server.d.ts.map +1 -0
- package/dist/a2a/a2a.server.js +278 -0
- package/dist/a2a/a2a.server.js.map +1 -0
- package/dist/a2a/a2a.types.d.ts +170 -0
- package/dist/a2a/a2a.types.d.ts.map +1 -0
- package/dist/a2a/a2a.types.js +12 -0
- package/dist/a2a/a2a.types.js.map +1 -0
- package/dist/a2a/agent-card.builder.d.ts +63 -0
- package/dist/a2a/agent-card.builder.d.ts.map +1 -0
- package/dist/a2a/agent-card.builder.js +101 -0
- package/dist/a2a/agent-card.builder.js.map +1 -0
- package/dist/decorators/tool.decorator.d.ts.map +1 -1
- package/dist/decorators/tool.decorator.js +1 -0
- package/dist/decorators/tool.decorator.js.map +1 -1
- package/dist/executor/agent.executor.d.ts.map +1 -1
- package/dist/executor/agent.executor.js +44 -9
- package/dist/executor/agent.executor.js.map +1 -1
- package/dist/executor/tool.executor.d.ts.map +1 -1
- package/dist/executor/tool.executor.js +24 -0
- package/dist/executor/tool.executor.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/registry/tool.registry.d.ts.map +1 -1
- package/dist/registry/tool.registry.js +16 -0
- package/dist/registry/tool.registry.js.map +1 -1
- package/dist/types/agent.types.d.ts +6 -0
- package/dist/types/agent.types.d.ts.map +1 -1
- package/dist/types/agent.types.js +1 -0
- package/dist/types/agent.types.js.map +1 -1
- package/dist/types/tool.types.d.ts +4 -0
- package/dist/types/tool.types.d.ts.map +1 -1
- package/dist/types/tool.types.js.map +1 -1
- package/logs/combined.log +1 -1
- package/package.json +9 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/executor/agent.executor.streaming.d.ts +0 -13
- package/dist/executor/agent.executor.streaming.d.ts.map +0 -1
- package/dist/executor/agent.executor.streaming.js +0 -103
- package/dist/executor/agent.executor.streaming.js.map +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A Server Adapter
|
|
3
|
+
*
|
|
4
|
+
* Maps A2A JSON-RPC protocol methods to HazelJS AgentRuntime execution.
|
|
5
|
+
*
|
|
6
|
+
* Supported methods:
|
|
7
|
+
* tasks/send — Execute an agent and return the result
|
|
8
|
+
* tasks/get — Get task status and history
|
|
9
|
+
* tasks/cancel — Cancel a running task
|
|
10
|
+
* tasks/sendSubscribe — Stream task progress via SSE
|
|
11
|
+
*
|
|
12
|
+
* @example Express integration:
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { A2AServer, buildAgentCard } from '@hazeljs/agent';
|
|
15
|
+
*
|
|
16
|
+
* const a2a = new A2AServer(runtime, { defaultAgent: 'SupportAgent' });
|
|
17
|
+
*
|
|
18
|
+
* // Serve agent card
|
|
19
|
+
* app.get('/.well-known/agent.json', (req, res) => {
|
|
20
|
+
* res.json(buildAgentCard(runtime, { url: 'https://api.example.com/a2a' }));
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Handle A2A JSON-RPC
|
|
24
|
+
* app.post('/a2a', async (req, res) => {
|
|
25
|
+
* const result = await a2a.handleRequest(req.body);
|
|
26
|
+
* res.json(result);
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
import type { A2ATaskSendParams, A2AStreamingEvent } from './a2a.types';
|
|
31
|
+
import type { AgentExecutionResult } from '../types/agent.types';
|
|
32
|
+
/** Minimal runtime interface to avoid circular deps */
|
|
33
|
+
interface RuntimeLike {
|
|
34
|
+
execute(agentName: string, input: string, options?: Record<string, unknown>): Promise<AgentExecutionResult>;
|
|
35
|
+
cancel(executionId: string): void;
|
|
36
|
+
getContext(executionId: string): Promise<{
|
|
37
|
+
executionId: string;
|
|
38
|
+
state: string;
|
|
39
|
+
steps: unknown[];
|
|
40
|
+
} | undefined>;
|
|
41
|
+
getAgents(): string[];
|
|
42
|
+
}
|
|
43
|
+
export interface A2AServerOptions {
|
|
44
|
+
/** Default agent to use when no specific agent is targeted */
|
|
45
|
+
defaultAgent?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A2A Protocol Server — handles JSON-RPC requests per the A2A spec
|
|
49
|
+
*/
|
|
50
|
+
export declare class A2AServer {
|
|
51
|
+
private readonly runtime;
|
|
52
|
+
private readonly options;
|
|
53
|
+
/** In-memory task store. Replace with persistent store for production. */
|
|
54
|
+
private tasks;
|
|
55
|
+
/** Maps task IDs to execution IDs for cancel support */
|
|
56
|
+
private taskExecutionMap;
|
|
57
|
+
constructor(runtime: RuntimeLike, options?: A2AServerOptions);
|
|
58
|
+
handleRequest(request: {
|
|
59
|
+
jsonrpc?: string;
|
|
60
|
+
method: string;
|
|
61
|
+
id?: string | number | null;
|
|
62
|
+
params?: unknown;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
jsonrpc: '2.0';
|
|
65
|
+
id: string | number | null;
|
|
66
|
+
result?: unknown;
|
|
67
|
+
error?: unknown;
|
|
68
|
+
}>;
|
|
69
|
+
private handleTaskSend;
|
|
70
|
+
private handleTaskGet;
|
|
71
|
+
private handleTaskCancel;
|
|
72
|
+
/**
|
|
73
|
+
* Stream task execution via an async generator.
|
|
74
|
+
* The caller should convert these events to SSE format.
|
|
75
|
+
*
|
|
76
|
+
* @example Express SSE:
|
|
77
|
+
* ```ts
|
|
78
|
+
* app.post('/a2a/stream', async (req, res) => {
|
|
79
|
+
* res.setHeader('Content-Type', 'text/event-stream');
|
|
80
|
+
* for await (const event of a2a.handleTaskSendSubscribe(req.body.params)) {
|
|
81
|
+
* res.write(`data: ${JSON.stringify(event)}\n\n`);
|
|
82
|
+
* }
|
|
83
|
+
* res.end();
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
handleTaskSendSubscribe(params: A2ATaskSendParams): AsyncGenerator<A2AStreamingEvent>;
|
|
88
|
+
private extractTextFromMessage;
|
|
89
|
+
private mapAgentStateToA2A;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=a2a.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a.server.d.ts","sourceRoot":"","sources":["../../src/a2a/a2a.server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAEV,iBAAiB,EAMjB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,uDAAuD;AACvD,UAAU,WAAW;IACnB,OAAO,CACL,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACjC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,UAAU,CACR,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IACjF,SAAS,IAAI,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,SAAS;IAOlB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAP1B,0EAA0E;IAC1E,OAAO,CAAC,KAAK,CAAmC;IAChD,wDAAwD;IACxD,OAAO,CAAC,gBAAgB,CAAkC;gBAGvC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,gBAAqB;IAO3C,aAAa,CAAC,OAAO,EAAE;QAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;QAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;YAiDhF,cAAc;IA4D5B,OAAO,CAAC,aAAa;YAoBP,gBAAgB;IAoB9B;;;;;;;;;;;;;;OAcG;IACI,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,cAAc,CAAC,iBAAiB,CAAC;IA6E5F,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,kBAAkB;CAiB3B"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A2A Server Adapter
|
|
4
|
+
*
|
|
5
|
+
* Maps A2A JSON-RPC protocol methods to HazelJS AgentRuntime execution.
|
|
6
|
+
*
|
|
7
|
+
* Supported methods:
|
|
8
|
+
* tasks/send — Execute an agent and return the result
|
|
9
|
+
* tasks/get — Get task status and history
|
|
10
|
+
* tasks/cancel — Cancel a running task
|
|
11
|
+
* tasks/sendSubscribe — Stream task progress via SSE
|
|
12
|
+
*
|
|
13
|
+
* @example Express integration:
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { A2AServer, buildAgentCard } from '@hazeljs/agent';
|
|
16
|
+
*
|
|
17
|
+
* const a2a = new A2AServer(runtime, { defaultAgent: 'SupportAgent' });
|
|
18
|
+
*
|
|
19
|
+
* // Serve agent card
|
|
20
|
+
* app.get('/.well-known/agent.json', (req, res) => {
|
|
21
|
+
* res.json(buildAgentCard(runtime, { url: 'https://api.example.com/a2a' }));
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Handle A2A JSON-RPC
|
|
25
|
+
* app.post('/a2a', async (req, res) => {
|
|
26
|
+
* const result = await a2a.handleRequest(req.body);
|
|
27
|
+
* res.json(result);
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.A2AServer = void 0;
|
|
33
|
+
/**
|
|
34
|
+
* A2A Protocol Server — handles JSON-RPC requests per the A2A spec
|
|
35
|
+
*/
|
|
36
|
+
class A2AServer {
|
|
37
|
+
constructor(runtime, options = {}) {
|
|
38
|
+
this.runtime = runtime;
|
|
39
|
+
this.options = options;
|
|
40
|
+
/** In-memory task store. Replace with persistent store for production. */
|
|
41
|
+
this.tasks = new Map();
|
|
42
|
+
/** Maps task IDs to execution IDs for cancel support */
|
|
43
|
+
this.taskExecutionMap = new Map();
|
|
44
|
+
}
|
|
45
|
+
// -------------------------------------------------------------------------
|
|
46
|
+
// JSON-RPC Router
|
|
47
|
+
// -------------------------------------------------------------------------
|
|
48
|
+
async handleRequest(request) {
|
|
49
|
+
const id = request.id ?? null;
|
|
50
|
+
try {
|
|
51
|
+
switch (request.method) {
|
|
52
|
+
case 'tasks/send':
|
|
53
|
+
return {
|
|
54
|
+
jsonrpc: '2.0',
|
|
55
|
+
id,
|
|
56
|
+
result: await this.handleTaskSend(request.params),
|
|
57
|
+
};
|
|
58
|
+
case 'tasks/get':
|
|
59
|
+
return {
|
|
60
|
+
jsonrpc: '2.0',
|
|
61
|
+
id,
|
|
62
|
+
result: this.handleTaskGet(request.params),
|
|
63
|
+
};
|
|
64
|
+
case 'tasks/cancel':
|
|
65
|
+
return {
|
|
66
|
+
jsonrpc: '2.0',
|
|
67
|
+
id,
|
|
68
|
+
result: await this.handleTaskCancel(request.params),
|
|
69
|
+
};
|
|
70
|
+
default:
|
|
71
|
+
return {
|
|
72
|
+
jsonrpc: '2.0',
|
|
73
|
+
id,
|
|
74
|
+
error: { code: -32601, message: `Method not found: ${request.method}` },
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
return {
|
|
80
|
+
jsonrpc: '2.0',
|
|
81
|
+
id,
|
|
82
|
+
error: {
|
|
83
|
+
code: -32000,
|
|
84
|
+
message: err instanceof Error ? err.message : 'Internal error',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// -------------------------------------------------------------------------
|
|
90
|
+
// tasks/send
|
|
91
|
+
// -------------------------------------------------------------------------
|
|
92
|
+
async handleTaskSend(params) {
|
|
93
|
+
const taskId = params.id;
|
|
94
|
+
const input = this.extractTextFromMessage(params.message);
|
|
95
|
+
// Determine which agent to execute
|
|
96
|
+
const agentName = this.options.defaultAgent ?? this.runtime.getAgents()[0];
|
|
97
|
+
if (!agentName) {
|
|
98
|
+
throw new Error('No agent available to handle the task');
|
|
99
|
+
}
|
|
100
|
+
// Create the task record
|
|
101
|
+
const task = {
|
|
102
|
+
id: taskId,
|
|
103
|
+
sessionId: params.sessionId,
|
|
104
|
+
status: { state: 'submitted', timestamp: new Date().toISOString() },
|
|
105
|
+
history: [params.message],
|
|
106
|
+
metadata: params.metadata,
|
|
107
|
+
};
|
|
108
|
+
this.tasks.set(taskId, task);
|
|
109
|
+
// Update to working state
|
|
110
|
+
task.status = { state: 'working', timestamp: new Date().toISOString() };
|
|
111
|
+
// Execute the agent
|
|
112
|
+
const result = await this.runtime.execute(agentName, input, {
|
|
113
|
+
sessionId: params.sessionId,
|
|
114
|
+
});
|
|
115
|
+
// Store the mapping for cancel support
|
|
116
|
+
this.taskExecutionMap.set(taskId, result.executionId);
|
|
117
|
+
// Map agent result to A2A task
|
|
118
|
+
const agentMessage = {
|
|
119
|
+
role: 'agent',
|
|
120
|
+
parts: [{ type: 'text', text: result.response ?? '' }],
|
|
121
|
+
};
|
|
122
|
+
task.status = {
|
|
123
|
+
state: this.mapAgentStateToA2A(result.state),
|
|
124
|
+
message: agentMessage,
|
|
125
|
+
timestamp: new Date().toISOString(),
|
|
126
|
+
};
|
|
127
|
+
task.history = [...(task.history ?? []), agentMessage];
|
|
128
|
+
if (result.response) {
|
|
129
|
+
task.artifacts = [
|
|
130
|
+
{
|
|
131
|
+
parts: [{ type: 'text', text: result.response }],
|
|
132
|
+
lastChunk: true,
|
|
133
|
+
},
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
return task;
|
|
137
|
+
}
|
|
138
|
+
// -------------------------------------------------------------------------
|
|
139
|
+
// tasks/get
|
|
140
|
+
// -------------------------------------------------------------------------
|
|
141
|
+
handleTaskGet(params) {
|
|
142
|
+
const task = this.tasks.get(params.id);
|
|
143
|
+
if (!task) {
|
|
144
|
+
throw new Error(`Task not found: ${params.id}`);
|
|
145
|
+
}
|
|
146
|
+
// Trim history if requested
|
|
147
|
+
if (params.historyLength !== undefined && task.history) {
|
|
148
|
+
const trimmed = { ...task };
|
|
149
|
+
trimmed.history = task.history.slice(-params.historyLength);
|
|
150
|
+
return trimmed;
|
|
151
|
+
}
|
|
152
|
+
return task;
|
|
153
|
+
}
|
|
154
|
+
// -------------------------------------------------------------------------
|
|
155
|
+
// tasks/cancel
|
|
156
|
+
// -------------------------------------------------------------------------
|
|
157
|
+
async handleTaskCancel(params) {
|
|
158
|
+
const task = this.tasks.get(params.id);
|
|
159
|
+
if (!task) {
|
|
160
|
+
throw new Error(`Task not found: ${params.id}`);
|
|
161
|
+
}
|
|
162
|
+
// Cancel the underlying execution
|
|
163
|
+
const executionId = this.taskExecutionMap.get(params.id);
|
|
164
|
+
if (executionId) {
|
|
165
|
+
this.runtime.cancel(executionId);
|
|
166
|
+
}
|
|
167
|
+
task.status = { state: 'canceled', timestamp: new Date().toISOString() };
|
|
168
|
+
return task;
|
|
169
|
+
}
|
|
170
|
+
// -------------------------------------------------------------------------
|
|
171
|
+
// tasks/sendSubscribe (streaming)
|
|
172
|
+
// -------------------------------------------------------------------------
|
|
173
|
+
/**
|
|
174
|
+
* Stream task execution via an async generator.
|
|
175
|
+
* The caller should convert these events to SSE format.
|
|
176
|
+
*
|
|
177
|
+
* @example Express SSE:
|
|
178
|
+
* ```ts
|
|
179
|
+
* app.post('/a2a/stream', async (req, res) => {
|
|
180
|
+
* res.setHeader('Content-Type', 'text/event-stream');
|
|
181
|
+
* for await (const event of a2a.handleTaskSendSubscribe(req.body.params)) {
|
|
182
|
+
* res.write(`data: ${JSON.stringify(event)}\n\n`);
|
|
183
|
+
* }
|
|
184
|
+
* res.end();
|
|
185
|
+
* });
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
async *handleTaskSendSubscribe(params) {
|
|
189
|
+
const taskId = params.id;
|
|
190
|
+
const input = this.extractTextFromMessage(params.message);
|
|
191
|
+
const agentName = this.options.defaultAgent ?? this.runtime.getAgents()[0];
|
|
192
|
+
if (!agentName) {
|
|
193
|
+
throw new Error('No agent available to handle the task');
|
|
194
|
+
}
|
|
195
|
+
// Create task record
|
|
196
|
+
const task = {
|
|
197
|
+
id: taskId,
|
|
198
|
+
sessionId: params.sessionId,
|
|
199
|
+
status: { state: 'submitted', timestamp: new Date().toISOString() },
|
|
200
|
+
history: [params.message],
|
|
201
|
+
metadata: params.metadata,
|
|
202
|
+
};
|
|
203
|
+
this.tasks.set(taskId, task);
|
|
204
|
+
// Emit submitted status
|
|
205
|
+
yield {
|
|
206
|
+
type: 'status',
|
|
207
|
+
event: { id: taskId, status: task.status, final: false },
|
|
208
|
+
};
|
|
209
|
+
// Update to working
|
|
210
|
+
task.status = { state: 'working', timestamp: new Date().toISOString() };
|
|
211
|
+
yield {
|
|
212
|
+
type: 'status',
|
|
213
|
+
event: { id: taskId, status: task.status, final: false },
|
|
214
|
+
};
|
|
215
|
+
// Execute and collect result
|
|
216
|
+
const result = await this.runtime.execute(agentName, input, {
|
|
217
|
+
sessionId: params.sessionId,
|
|
218
|
+
});
|
|
219
|
+
this.taskExecutionMap.set(taskId, result.executionId);
|
|
220
|
+
// Emit artifact if there's a response
|
|
221
|
+
if (result.response) {
|
|
222
|
+
yield {
|
|
223
|
+
type: 'artifact',
|
|
224
|
+
event: {
|
|
225
|
+
id: taskId,
|
|
226
|
+
artifact: {
|
|
227
|
+
parts: [{ type: 'text', text: result.response }],
|
|
228
|
+
lastChunk: true,
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
// Emit final status
|
|
234
|
+
const finalState = this.mapAgentStateToA2A(result.state);
|
|
235
|
+
const agentMessage = {
|
|
236
|
+
role: 'agent',
|
|
237
|
+
parts: [{ type: 'text', text: result.response ?? '' }],
|
|
238
|
+
};
|
|
239
|
+
task.status = {
|
|
240
|
+
state: finalState,
|
|
241
|
+
message: agentMessage,
|
|
242
|
+
timestamp: new Date().toISOString(),
|
|
243
|
+
};
|
|
244
|
+
task.history = [...(task.history ?? []), agentMessage];
|
|
245
|
+
yield {
|
|
246
|
+
type: 'status',
|
|
247
|
+
event: { id: taskId, status: task.status, final: true },
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
// -------------------------------------------------------------------------
|
|
251
|
+
// Helpers
|
|
252
|
+
// -------------------------------------------------------------------------
|
|
253
|
+
extractTextFromMessage(message) {
|
|
254
|
+
return message.parts
|
|
255
|
+
.filter((p) => p.type === 'text')
|
|
256
|
+
.map((p) => p.text)
|
|
257
|
+
.join('\n');
|
|
258
|
+
}
|
|
259
|
+
mapAgentStateToA2A(state) {
|
|
260
|
+
switch (state) {
|
|
261
|
+
case 'completed':
|
|
262
|
+
return 'completed';
|
|
263
|
+
case 'failed':
|
|
264
|
+
return 'failed';
|
|
265
|
+
case 'waiting_for_input':
|
|
266
|
+
return 'input-required';
|
|
267
|
+
case 'waiting_for_approval':
|
|
268
|
+
return 'input-required';
|
|
269
|
+
case 'thinking':
|
|
270
|
+
case 'using_tool':
|
|
271
|
+
return 'working';
|
|
272
|
+
default:
|
|
273
|
+
return 'unknown';
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
exports.A2AServer = A2AServer;
|
|
278
|
+
//# sourceMappingURL=a2a.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a.server.js","sourceRoot":"","sources":["../../src/a2a/a2a.server.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAkCH;;GAEG;AACH,MAAa,SAAS;IAMpB,YACmB,OAAoB,EACpB,UAA4B,EAAE;QAD9B,YAAO,GAAP,OAAO,CAAa;QACpB,YAAO,GAAP,OAAO,CAAuB;QAPjD,0EAA0E;QAClE,UAAK,GAAyB,IAAI,GAAG,EAAE,CAAC;QAChD,wDAAwD;QAChD,qBAAgB,GAAwB,IAAI,GAAG,EAAE,CAAC;IAKvD,CAAC;IAEJ,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAE5E,KAAK,CAAC,aAAa,CAAC,OAKnB;QACC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC;QAE9B,IAAI,CAAC;YACH,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;gBACvB,KAAK,YAAY;oBACf,OAAO;wBACL,OAAO,EAAE,KAAK;wBACd,EAAE;wBACF,MAAM,EAAE,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,MAA2B,CAAC;qBACvE,CAAC;gBAEJ,KAAK,WAAW;oBACd,OAAO;wBACL,OAAO,EAAE,KAAK;wBACd,EAAE;wBACF,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAA0B,CAAC;qBAC/D,CAAC;gBAEJ,KAAK,cAAc;oBACjB,OAAO;wBACL,O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AC,EAAE,YAAY,CAAC,CAAC;QAEvD,MAAM;YACJ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE;SACxD,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,UAAU;IACV,4EAA4E;IAEpE,sBAAsB,CAAC,OAAmB;QAChD,OAAO,OAAO,CAAC,KAAK;aACjB,MAAM,CAAC,CAAC,CAAC,EAAoB,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;aAClD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aAClB,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAEO,kBAAkB,CAAC,KAAa;QACtC,QAAQ,KAAK,EAAE,CAAC;YACd,KAAK,WAAW;gBACd,OAAO,WAAW,CAAC;YACrB,KAAK,QAAQ;gBACX,OAAO,QAAQ,CAAC;YAClB,KAAK,mBAAmB;gBACtB,OAAO,gBAAgB,CAAC;YAC1B,KAAK,sBAAsB;gBACzB,OAAO,gBAAgB,CAAC;YAC1B,KAAK,UAAU,CAAC;YAChB,KAAK,YAAY;gBACf,OAAO,SAAS,CAAC;YACnB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AA7RD,8BA6RC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A (Agent-to-Agent) Protocol Types
|
|
3
|
+
*
|
|
4
|
+
* Implements the Google A2A protocol specification for inter-agent
|
|
5
|
+
* communication. These types define the agent discovery, task lifecycle,
|
|
6
|
+
* and message formats.
|
|
7
|
+
*
|
|
8
|
+
* Spec: https://google.github.io/A2A/
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* AgentCard is the discovery mechanism for A2A agents.
|
|
12
|
+
* Published at `/.well-known/agent.json` or returned via the agent directory.
|
|
13
|
+
*/
|
|
14
|
+
export interface A2AAgentCard {
|
|
15
|
+
/** Human-readable agent name */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Description of what the agent does */
|
|
18
|
+
description: string;
|
|
19
|
+
/** URL where the agent accepts A2A requests */
|
|
20
|
+
url: string;
|
|
21
|
+
/** Agent provider / organization info */
|
|
22
|
+
provider?: {
|
|
23
|
+
organization: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
};
|
|
26
|
+
/** Version of the agent */
|
|
27
|
+
version?: string;
|
|
28
|
+
/** Documentation URL */
|
|
29
|
+
documentationUrl?: string;
|
|
30
|
+
/** Agent capabilities */
|
|
31
|
+
capabilities: A2ACapabilities;
|
|
32
|
+
/** Authentication requirements */
|
|
33
|
+
authentication?: A2AAuthentication;
|
|
34
|
+
/** Default input modes accepted */
|
|
35
|
+
defaultInputModes?: string[];
|
|
36
|
+
/** Default output modes produced */
|
|
37
|
+
defaultOutputModes?: string[];
|
|
38
|
+
/** Skills / tasks this agent can perform */
|
|
39
|
+
skills: A2ASkill[];
|
|
40
|
+
}
|
|
41
|
+
export interface A2ACapabilities {
|
|
42
|
+
/** Whether the agent supports streaming responses */
|
|
43
|
+
streaming?: boolean;
|
|
44
|
+
/** Whether the agent supports push notifications */
|
|
45
|
+
pushNotifications?: boolean;
|
|
46
|
+
/** Whether the agent supports state transitions (multi-turn) */
|
|
47
|
+
stateTransitionHistory?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface A2AAuthentication {
|
|
50
|
+
/** Supported auth schemes */
|
|
51
|
+
schemes: string[];
|
|
52
|
+
/** Credentials (for display/docs only) */
|
|
53
|
+
credentials?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface A2ASkill {
|
|
56
|
+
/** Unique skill identifier */
|
|
57
|
+
id: string;
|
|
58
|
+
/** Human-readable skill name */
|
|
59
|
+
name: string;
|
|
60
|
+
/** Skill description */
|
|
61
|
+
description: string;
|
|
62
|
+
/** Tags for categorization */
|
|
63
|
+
tags?: string[];
|
|
64
|
+
/** Example prompts */
|
|
65
|
+
examples?: string[];
|
|
66
|
+
/** Input modes this skill accepts */
|
|
67
|
+
inputModes?: string[];
|
|
68
|
+
/** Output modes this skill produces */
|
|
69
|
+
outputModes?: string[];
|
|
70
|
+
}
|
|
71
|
+
export type A2ATaskState = 'submitted' | 'working' | 'input-required' | 'completed' | 'canceled' | 'failed' | 'unknown';
|
|
72
|
+
/**
|
|
73
|
+
* A2A Task — the core unit of work
|
|
74
|
+
*/
|
|
75
|
+
export interface A2ATask {
|
|
76
|
+
id: string;
|
|
77
|
+
sessionId?: string;
|
|
78
|
+
status: A2ATaskStatus;
|
|
79
|
+
/** Conversation history */
|
|
80
|
+
history?: A2AMessage[];
|
|
81
|
+
/** Artifacts produced by the task */
|
|
82
|
+
artifacts?: A2AArtifact[];
|
|
83
|
+
/** Additional metadata */
|
|
84
|
+
metadata?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
export interface A2ATaskStatus {
|
|
87
|
+
state: A2ATaskState;
|
|
88
|
+
message?: A2AMessage;
|
|
89
|
+
timestamp?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A2A Message — content exchanged between agents
|
|
93
|
+
*/
|
|
94
|
+
export interface A2AMessage {
|
|
95
|
+
role: 'user' | 'agent';
|
|
96
|
+
parts: A2APart[];
|
|
97
|
+
metadata?: Record<string, unknown>;
|
|
98
|
+
}
|
|
99
|
+
export type A2APart = A2ATextPart | A2AFilePart | A2ADataPart;
|
|
100
|
+
export interface A2ATextPart {
|
|
101
|
+
type: 'text';
|
|
102
|
+
text: string;
|
|
103
|
+
}
|
|
104
|
+
export interface A2AFilePart {
|
|
105
|
+
type: 'file';
|
|
106
|
+
file: {
|
|
107
|
+
name?: string;
|
|
108
|
+
mimeType?: string;
|
|
109
|
+
/** Base64-encoded content or URL */
|
|
110
|
+
bytes?: string;
|
|
111
|
+
uri?: string;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export interface A2ADataPart {
|
|
115
|
+
type: 'data';
|
|
116
|
+
data: Record<string, unknown>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A2A Artifact — outputs produced by the agent
|
|
120
|
+
*/
|
|
121
|
+
export interface A2AArtifact {
|
|
122
|
+
name?: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
parts: A2APart[];
|
|
125
|
+
index?: number;
|
|
126
|
+
append?: boolean;
|
|
127
|
+
lastChunk?: boolean;
|
|
128
|
+
metadata?: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
/** Send a task to the agent */
|
|
131
|
+
export interface A2ATaskSendParams {
|
|
132
|
+
id: string;
|
|
133
|
+
sessionId?: string;
|
|
134
|
+
message: A2AMessage;
|
|
135
|
+
acceptedOutputModes?: string[];
|
|
136
|
+
pushNotification?: {
|
|
137
|
+
url: string;
|
|
138
|
+
token?: string;
|
|
139
|
+
};
|
|
140
|
+
metadata?: Record<string, unknown>;
|
|
141
|
+
}
|
|
142
|
+
/** Get task status */
|
|
143
|
+
export interface A2ATaskGetParams {
|
|
144
|
+
id: string;
|
|
145
|
+
historyLength?: number;
|
|
146
|
+
}
|
|
147
|
+
/** Cancel a task */
|
|
148
|
+
export interface A2ATaskCancelParams {
|
|
149
|
+
id: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Streaming event for tasks/sendSubscribe
|
|
153
|
+
*/
|
|
154
|
+
export interface A2ATaskStatusUpdateEvent {
|
|
155
|
+
id: string;
|
|
156
|
+
status: A2ATaskStatus;
|
|
157
|
+
final: boolean;
|
|
158
|
+
}
|
|
159
|
+
export interface A2ATaskArtifactUpdateEvent {
|
|
160
|
+
id: string;
|
|
161
|
+
artifact: A2AArtifact;
|
|
162
|
+
}
|
|
163
|
+
export type A2AStreamingEvent = {
|
|
164
|
+
type: 'status';
|
|
165
|
+
event: A2ATaskStatusUpdateEvent;
|
|
166
|
+
} | {
|
|
167
|
+
type: 'artifact';
|
|
168
|
+
event: A2ATaskArtifactUpdateEvent;
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=a2a.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a.types.d.ts","sourceRoot":"","sources":["../../src/a2a/a2a.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB;IACzB,YAAY,EAAE,eAAe,CAAC;IAC9B,kCAAkC;IAClC,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC,mCAAmC;IACnC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,oCAAoC;IACpC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,4CAA4C;IAC5C,MAAM,EAAE,QAAQ,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gEAAgE;IAChE,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WA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oBAAoB;AACpB,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,wBAAwB,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,0BAA0B,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A2A (Agent-to-Agent) Protocol Types
|
|
4
|
+
*
|
|
5
|
+
* Implements the Google A2A protocol specification for inter-agent
|
|
6
|
+
* communication. These types define the agent discovery, task lifecycle,
|
|
7
|
+
* and message formats.
|
|
8
|
+
*
|
|
9
|
+
* Spec: https://google.github.io/A2A/
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
//# sourceMappingURL=a2a.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a.types.js","sourceRoot":"","sources":["../../src/a2a/a2a.types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A Agent Card Builder
|
|
3
|
+
*
|
|
4
|
+
* Generates an A2A-compliant AgentCard from HazelJS @Agent decorator metadata.
|
|
5
|
+
* This enables automatic discovery of HazelJS agents by other A2A-compatible
|
|
6
|
+
* systems (e.g., Google ADK, other agent frameworks).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const card = buildAgentCard(runtime, {
|
|
11
|
+
* url: 'https://api.example.com/a2a',
|
|
12
|
+
* provider: { organization: 'Acme Corp' },
|
|
13
|
+
* });
|
|
14
|
+
* // Serve at /.well-known/agent.json
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import type { A2AAgentCard, A2ACapabilities } from './a2a.types';
|
|
18
|
+
import type { AgentMetadata } from '../types/agent.types';
|
|
19
|
+
import type { ToolMetadata } from '../types/tool.types';
|
|
20
|
+
export interface AgentCardOptions {
|
|
21
|
+
/** URL where the agent accepts A2A requests */
|
|
22
|
+
url: string;
|
|
23
|
+
/** Provider / organization info */
|
|
24
|
+
provider?: {
|
|
25
|
+
organization: string;
|
|
26
|
+
url?: string;
|
|
27
|
+
};
|
|
28
|
+
/** Version string */
|
|
29
|
+
version?: string;
|
|
30
|
+
/** Documentation URL */
|
|
31
|
+
documentationUrl?: string;
|
|
32
|
+
/** Override capabilities */
|
|
33
|
+
capabilities?: Partial<A2ACapabilities>;
|
|
34
|
+
/** Default input modes */
|
|
35
|
+
defaultInputModes?: string[];
|
|
36
|
+
/** Default output modes */
|
|
37
|
+
defaultOutputModes?: string[];
|
|
38
|
+
/** Authentication requirements */
|
|
39
|
+
authentication?: {
|
|
40
|
+
schemes: string[];
|
|
41
|
+
credentials?: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Minimal runtime interface to avoid circular deps */
|
|
45
|
+
interface RuntimeLike {
|
|
46
|
+
getAgents(): string[];
|
|
47
|
+
getAgentMetadata(name: string): AgentMetadata | undefined;
|
|
48
|
+
getAgentTools(name: string): ToolMetadata[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build an A2A AgentCard from a HazelJS AgentRuntime.
|
|
52
|
+
*
|
|
53
|
+
* Scans all registered agents and their tools, converting them into
|
|
54
|
+
* A2A skills. Each agent becomes a skill, and its tools become
|
|
55
|
+
* example capabilities listed in the skill description.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildAgentCard(runtime: RuntimeLike, options: AgentCardOptions): A2AAgentCard;
|
|
58
|
+
/**
|
|
59
|
+
* Build an A2A AgentCard for a single agent (when serving one agent per endpoint).
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildSingleAgentCard(agentMeta: AgentMetadata, tools: ToolMetadata[], options: AgentCardOptions): A2AAgentCard;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=agent-card.builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-card.builder.d.ts","sourceRoot":"","sources":["../../src/a2a/agent-card.builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAY,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,mCAAmC;IACnC,QAAQ,CAAC,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4BAA4B;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACxC,0BAA0B;IAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,kCAAkC;IAClC,cAAc,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAA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