@ynhcj/xiaoyi-channel 0.0.159-next → 0.0.160-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.
@@ -118,6 +118,8 @@ export function createXYReplyDispatcher(params) {
118
118
  let accumulatedText = "";
119
119
  let accumulatedReasoningHistory = "";
120
120
  let lastReasoningText = "";
121
+ let accumulatedReplyHistory = "";
122
+ let lastReplyText = "";
121
123
  const initialRunCrossTaskContext = getCurrentSessionContext()?.runCrossTaskContext;
122
124
  const getRunCrossTaskContext = () => {
123
125
  return getCurrentSessionContext()?.runCrossTaskContext ?? initialRunCrossTaskContext;
@@ -441,17 +443,31 @@ export function createXYReplyDispatcher(params) {
441
443
  }
442
444
  const currentTaskId = getActiveTaskId();
443
445
  const currentMessageId = getActiveMessageId();
444
- const text = payload.text ?? "";
446
+ let text = payload.text ?? "";
445
447
  try {
446
448
  if (text.length > 0) {
449
+ // 🔑 检测是否是新一轮回复:当前text比上一次短,或不以上次内容开头
450
+ const isNewRound = lastReplyText.length > 0 &&
451
+ (text.length < lastReplyText.length || !text.startsWith(lastReplyText));
452
+ if (isNewRound) {
453
+ // 将上一轮回复追加到历史
454
+ accumulatedReplyHistory += (accumulatedReplyHistory ? "\n\n" : "") + lastReplyText;
455
+ }
456
+ // 更新当前轮最后一次text
457
+ lastReplyText = text;
458
+ // 🔑 拼接历史 + 当前轮内容
459
+ const fullText = accumulatedReplyHistory
460
+ ? accumulatedReplyHistory + "\n\n" + text
461
+ : text;
447
462
  accumulatedText += text;
448
463
  hasSentResponse = true;
464
+ // 🔑 流式文本通过 A2A text 通道发送(而非 reasoningText)
449
465
  await sendA2AResponse({
450
466
  config,
451
467
  sessionId,
452
468
  taskId: currentTaskId,
453
469
  messageId: currentMessageId,
454
- text,
470
+ text: fullText,
455
471
  append: false,
456
472
  final: false,
457
473
  log: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.159-next",
3
+ "version": "0.0.160-next",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",