@ynhcj/xiaoyi-channel 0.0.2 → 0.0.3

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.
@@ -107,7 +107,7 @@ export async function sendCommand(params) {
107
107
  const runtime = getXYRuntime();
108
108
  const log = runtime?.log ?? console.log;
109
109
  const error = runtime?.error ?? console.error;
110
- // Build artifact update with command
110
+ // Build artifact update with command as data
111
111
  const artifact = {
112
112
  taskId,
113
113
  kind: "artifact-update",
@@ -118,8 +118,8 @@ export async function sendCommand(params) {
118
118
  artifactId: uuidv4(),
119
119
  parts: [
120
120
  {
121
- kind: "command",
122
- command,
121
+ kind: "data",
122
+ data: command,
123
123
  },
124
124
  ],
125
125
  },
@@ -7,6 +7,7 @@ import type { XYChannelConfig, OutboundWebSocketMessage } from "./types.js";
7
7
  *
8
8
  * Events:
9
9
  * - 'message': (message: A2AJsonRpcRequest, sessionId: string, serverId: ServerIdentifier) => void
10
+ * - 'data-event': (event: A2ADataEvent) => void
10
11
  * - 'connected': (serverId: ServerIdentifier) => void
11
12
  * - 'disconnected': (serverId: ServerIdentifier) => void
12
13
  * - 'error': (error: Error, serverId: ServerIdentifier) => void
@@ -10,6 +10,7 @@ import { sessionManager } from "./utils/session.js";
10
10
  *
11
11
  * Events:
12
12
  * - 'message': (message: A2AJsonRpcRequest, sessionId: string, serverId: ServerIdentifier) => void
13
+ * - 'data-event': (event: A2ADataEvent) => void
13
14
  * - 'connected': (serverId: ServerIdentifier) => void
14
15
  * - 'disconnected': (serverId: ServerIdentifier) => void
15
16
  * - 'error': (error: Error, serverId: ServerIdentifier) => void
@@ -295,7 +296,34 @@ export class XYWebSocketManager extends EventEmitter {
295
296
  sessionManager.bind(sessionId, serverId);
296
297
  console.log(`[XY-${serverId}] Bound session ${sessionId} to ${serverId}`);
297
298
  }
298
- // Emit message event
299
+ // Check if message contains only data parts (tool results)
300
+ const dataParts = a2aRequest.params?.message?.parts?.filter((p) => p.kind === "data");
301
+ const hasOnlyDataParts = dataParts && dataParts.length > 0 &&
302
+ dataParts.length === a2aRequest.params?.message?.parts?.length;
303
+ if (hasOnlyDataParts) {
304
+ // This is a data-only message (e.g., intent execution result)
305
+ // Only emit data-event, don't send to openclaw
306
+ console.log(`[XY-${serverId}] Message contains only data parts, processing as tool result`);
307
+ for (const dataPart of dataParts) {
308
+ const dataArray = dataPart.data;
309
+ if (Array.isArray(dataArray)) {
310
+ for (const item of dataArray) {
311
+ // Check if it's an UploadExeResult (intent execution result)
312
+ if (item.header?.name === "UploadExeResult" && item.payload?.intentName) {
313
+ const dataEvent = {
314
+ intentName: item.payload.intentName,
315
+ outputs: item.payload.outputs || {},
316
+ status: "success",
317
+ };
318
+ console.log(`[XY-${serverId}] Emitting data-event:`, dataEvent);
319
+ this.emit("data-event", dataEvent);
320
+ }
321
+ }
322
+ }
323
+ }
324
+ return; // Don't emit message event
325
+ }
326
+ // Emit message event for non-data-only messages
299
327
  this.emit("message", a2aRequest, sessionId, serverId);
300
328
  return;
301
329
  }
@@ -303,10 +331,41 @@ export class XYWebSocketManager extends EventEmitter {
303
331
  const inboundMsg = parsed;
304
332
  console.log(`[XY-${serverId}] Message type: Wrapped, msgType: ${inboundMsg.msgType}`);
305
333
  // Skip heartbeat responses
306
- if (inboundMsg.msgType === "heartbeat" || inboundMsg.msgType === "data") {
334
+ if (inboundMsg.msgType === "heartbeat") {
307
335
  console.log(`[XY-${serverId}] Skipping ${inboundMsg.msgType} message`);
308
336
  return;
309
337
  }
338
+ // Handle data messages (e.g., intent execution results)
339
+ if (inboundMsg.msgType === "data") {
340
+ console.log(`[XY-${serverId}] Processing data message`);
341
+ try {
342
+ const a2aRequest = JSON.parse(inboundMsg.msgDetail);
343
+ const dataParts = a2aRequest.params?.message?.parts?.filter((p) => p.kind === "data");
344
+ if (dataParts && dataParts.length > 0) {
345
+ for (const dataPart of dataParts) {
346
+ const dataArray = dataPart.data;
347
+ if (Array.isArray(dataArray)) {
348
+ for (const item of dataArray) {
349
+ // Check if it's an UploadExeResult (intent execution result)
350
+ if (item.header?.name === "UploadExeResult" && item.payload?.intentName) {
351
+ const dataEvent = {
352
+ intentName: item.payload.intentName,
353
+ outputs: item.payload.outputs || {},
354
+ status: "success",
355
+ };
356
+ console.log(`[XY-${serverId}] Emitting data-event:`, dataEvent);
357
+ this.emit("data-event", dataEvent);
358
+ }
359
+ }
360
+ }
361
+ }
362
+ }
363
+ }
364
+ catch (error) {
365
+ console.error(`[XY-${serverId}] Failed to process data message:`, error);
366
+ }
367
+ return;
368
+ }
310
369
  // Parse msgDetail as A2AJsonRpcRequest
311
370
  const a2aRequest = JSON.parse(inboundMsg.msgDetail);
312
371
  console.log(`[XY-${serverId}] Parsed A2A request, method: ${a2aRequest.method}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",