@ynhcj/xiaoyi 2.0.4 → 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 +31 -3
  2. package/package.json +1 -1
package/dist/channel.js CHANGED
@@ -242,8 +242,8 @@ exports.xiaoyiPlugin = {
242
242
  cfg: config,
243
243
  dispatcherOptions: {
244
244
  deliver: async (payload) => {
245
- console.log("XiaoYi: Delivering response:", payload);
246
- // Send response back through WebSocket
245
+ console.log("XiaoYi: Delivering final response:", payload);
246
+ // Send final response back through WebSocket
247
247
  const taskId = runtime.getTaskIdForSession(message.sessionId) || `task_${Date.now()}`;
248
248
  const response = {
249
249
  sessionId: message.sessionId,
@@ -264,7 +264,35 @@ exports.xiaoyiPlugin = {
264
264
  const conn = runtime.getConnection();
265
265
  if (conn) {
266
266
  await conn.sendResponse(response, taskId, message.sessionId);
267
- console.log("XiaoYi: Response sent successfully");
267
+ console.log("XiaoYi: Final response sent successfully");
268
+ }
269
+ },
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);
268
296
  }
269
297
  },
270
298
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi",
3
- "version": "2.0.4",
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",