@ynhcj/xiaoyi-channel 1.1.13 → 1.1.15

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.
@@ -15,6 +15,8 @@ export interface SendA2AResponseParams {
15
15
  fileType: string;
16
16
  fileId: string;
17
17
  }>;
18
+ errorCode?: number | string;
19
+ errorMessage?: string;
18
20
  }
19
21
  /**
20
22
  * Send an A2A artifact update response.
@@ -6,10 +6,10 @@ import { getXYRuntime } from "./runtime.js";
6
6
  * Send an A2A artifact update response.
7
7
  */
8
8
  export async function sendA2AResponse(params) {
9
- const { config, sessionId, taskId, messageId, text, append, final, files } = params;
9
+ const { config, sessionId, taskId, messageId, text, append, final, files, errorCode, errorMessage } = params;
10
10
  const runtime = getXYRuntime();
11
11
  const log = runtime?.log ?? console.log;
12
- const error = runtime?.error ?? console.error;
12
+ const errorFn = runtime?.error ?? console.error;
13
13
  // Build artifact update event
14
14
  const artifact = {
15
15
  taskId,
@@ -42,6 +42,14 @@ export async function sendA2AResponse(params) {
42
42
  id: messageId,
43
43
  result: artifact,
44
44
  };
45
+ // 🔑 添加 error 字段(仅当提供 errorCode 时)
46
+ if (errorCode !== undefined) {
47
+ jsonRpcResponse.error = {
48
+ code: errorCode,
49
+ message: errorMessage ?? "任务执行异常,请重试",
50
+ };
51
+ log(`[A2A_RESPONSE] ⚠️ Including error code: ${errorCode}`);
52
+ }
45
53
  // Send via WebSocket
46
54
  const wsManager = getXYWebSocketManager(config);
47
55
  const outboundMessage = {
@@ -235,9 +235,11 @@ export function createXYReplyDispatcher(params) {
235
235
  text: "任务执行异常,请重试~",
236
236
  append: false,
237
237
  final: true,
238
+ errorCode: 99921111,
239
+ errorMessage: "任务执行异常,请重试",
238
240
  });
239
241
  finalSent = true;
240
- log(`[ON_IDLE] ✅ Sent error response`);
242
+ log(`[ON_IDLE] ✅ Sent error response with code: 99921111`);
241
243
  }
242
244
  catch (err) {
243
245
  error(`[ON_IDLE] Failed to send error response:`, err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",