@ynhcj/xiaoyi 2.0.3 → 2.0.5

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 (2) hide show
  1. package/dist/channel.js +32 -5
  2. package/package.json +1 -1
package/dist/channel.js CHANGED
@@ -241,8 +241,9 @@ exports.xiaoyiPlugin = {
241
241
  ctx: msgContext,
242
242
  cfg: config,
243
243
  dispatcherOptions: {
244
- send: async (text) => {
245
- // Send response back through WebSocket
244
+ deliver: async (payload) => {
245
+ console.log("XiaoYi: Delivering final response:", payload);
246
+ // Send final response back through WebSocket
246
247
  const taskId = runtime.getTaskIdForSession(message.sessionId) || `task_${Date.now()}`;
247
248
  const response = {
248
249
  sessionId: message.sessionId,
@@ -256,17 +257,43 @@ exports.xiaoyiPlugin = {
256
257
  },
257
258
  content: {
258
259
  type: "text",
259
- text: text,
260
+ text: payload.text || "",
260
261
  },
261
262
  status: "success",
262
263
  };
263
264
  const conn = runtime.getConnection();
264
265
  if (conn) {
265
266
  await conn.sendResponse(response, taskId, message.sessionId);
267
+ console.log("XiaoYi: Final response sent successfully");
266
268
  }
267
269
  },
268
- sendTyping: async () => {
269
- // XiaoYi A2A protocol doesn't have typing indicators
270
+ },
271
+ replyOptions: {
272
+ // Enable streaming responses through onPartialReply callback
273
+ onPartialReply: async (payload) => {
274
+ console.log("XiaoYi: Streaming partial response:", payload.text?.substring(0, 50));
275
+ // Send partial response back through WebSocket
276
+ const taskId = runtime.getTaskIdForSession(message.sessionId) || `task_${Date.now()}`;
277
+ const partialResponse = {
278
+ sessionId: message.sessionId,
279
+ messageId: `partial_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
280
+ timestamp: Date.now(),
281
+ agentId: resolvedAccount.config.agentId,
282
+ sender: {
283
+ id: resolvedAccount.config.agentId,
284
+ name: "OpenClaw Agent",
285
+ type: "agent",
286
+ },
287
+ content: {
288
+ type: "text",
289
+ text: payload.text || "",
290
+ },
291
+ status: "processing",
292
+ };
293
+ const conn = runtime.getConnection();
294
+ if (conn) {
295
+ await conn.sendResponse(partialResponse, taskId, message.sessionId);
296
+ }
270
297
  },
271
298
  },
272
299
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "XiaoYi channel plugin for OpenClaw",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",