@ynhcj/xiaoyi-channel 0.0.181-next → 0.0.182-next

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.
@@ -418,21 +418,29 @@ export function createXYReplyDispatcher(params) {
418
418
  }
419
419
  },
420
420
  onPartialReply: async (payload) => {
421
- const text = payload.text ?? "";
421
+ let text = payload.text ?? "";
422
422
  try {
423
423
  if (text.length > 0) {
424
- accumulatedText += text;
424
+ // 模型可能返回完整文本(非纯增量),如果新文本以已累积内容开头,
425
+ // 则只取新增的后缀部分,避免 append 模式下重复拼接。
426
+ let sendText = text;
427
+ if (accumulatedText.length > 0 && text.startsWith(accumulatedText)) {
428
+ sendText = text.slice(accumulatedText.length);
429
+ }
430
+ accumulatedText += sendText;
425
431
  hasSentResponse = true;
426
- await sendA2AResponse({
427
- config,
428
- sessionId,
429
- taskId: getActiveTaskId(),
430
- messageId: getActiveMessageId(),
431
- text,
432
- append: false,
433
- final: false,
434
- log: false,
435
- });
432
+ if (sendText.length > 0) {
433
+ await sendA2AResponse({
434
+ config,
435
+ sessionId,
436
+ taskId: getActiveTaskId(),
437
+ messageId: getActiveMessageId(),
438
+ text: sendText,
439
+ append: true,
440
+ final: false,
441
+ log: false,
442
+ });
443
+ }
436
444
  }
437
445
  }
438
446
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.181-next",
3
+ "version": "0.0.182-next",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",