aixyz 0.23.0 → 0.24.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/app/plugins/a2a.ts +34 -6
- package/package.json +4 -4
package/app/plugins/a2a.ts
CHANGED
|
@@ -200,13 +200,41 @@ export class A2APlugin<TOOLS extends ToolSet = ToolSet> extends BasePlugin {
|
|
|
200
200
|
const body = await request.json();
|
|
201
201
|
const result = await jsonRpcTransport.handle(body);
|
|
202
202
|
|
|
203
|
-
// If result is an AsyncGenerator (streaming),
|
|
203
|
+
// If result is an AsyncGenerator (streaming), return as SSE
|
|
204
204
|
if (Symbol.asyncIterator in Object(result)) {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
const stream = result as AsyncGenerator;
|
|
206
|
+
const readable = new ReadableStream({
|
|
207
|
+
async start(controller) {
|
|
208
|
+
const encoder = new TextEncoder();
|
|
209
|
+
try {
|
|
210
|
+
for await (const event of stream) {
|
|
211
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(event)}\n\n`));
|
|
212
|
+
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
const errorResponse = {
|
|
215
|
+
jsonrpc: "2.0",
|
|
216
|
+
id: body?.id ?? null,
|
|
217
|
+
error: {
|
|
218
|
+
code: -32603,
|
|
219
|
+
message: error instanceof Error ? error.message : "Streaming error.",
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
controller.enqueue(encoder.encode(`event: error\ndata: ${JSON.stringify(errorResponse)}\n\n`));
|
|
223
|
+
} finally {
|
|
224
|
+
controller.close();
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
cancel() {
|
|
228
|
+
stream.return?.(undefined);
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
return new Response(readable, {
|
|
232
|
+
headers: {
|
|
233
|
+
"Content-Type": "text/event-stream",
|
|
234
|
+
"Cache-Control": "no-cache",
|
|
235
|
+
"X-Accel-Buffering": "no",
|
|
236
|
+
},
|
|
237
|
+
});
|
|
210
238
|
}
|
|
211
239
|
|
|
212
240
|
return Response.json(result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aixyz",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Payment-native SDK for AI Agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@a2a-js/sdk": "^0.3.10",
|
|
39
|
-
"@aixyz/cli": "0.
|
|
40
|
-
"@aixyz/config": "0.
|
|
41
|
-
"@aixyz/erc-8004": "0.
|
|
39
|
+
"@aixyz/cli": "0.24.0",
|
|
40
|
+
"@aixyz/config": "0.24.0",
|
|
41
|
+
"@aixyz/erc-8004": "0.24.0",
|
|
42
42
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
43
43
|
"@next/env": "^16.1.6",
|
|
44
44
|
"@x402/core": "^2.3.1",
|