@ynhcj/xiaoyi-channel 0.0.206-beta → 0.0.208-beta

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.
@@ -126,14 +126,27 @@ export const xyPlugin = {
126
126
  ? { conversationId, matchPriority: 2 }
127
127
  : null;
128
128
  },
129
- resolveCommandConversation: ({ accountId }) => {
129
+ resolveCommandConversation: ({ accountId, sessionKey }) => {
130
130
  // xiaoyi-channel: the A2A sessionId IS the conversationId.
131
- // Read from the current ALS session context.
131
+ // 1. Prefer the current ALS session context (works when the command
132
+ // is processed inside an active A2A message-handling turn).
132
133
  const ctx = getCurrentSessionContext();
133
- const sessionId = ctx?.sessionId?.trim();
134
- if (!sessionId)
135
- return null;
136
- return { conversationId: sessionId };
134
+ const alsSessionId = ctx?.sessionId?.trim();
135
+ if (alsSessionId)
136
+ return { conversationId: alsSessionId };
137
+ // 2. Fall back to parsing the session key. For xiaoyi-channel the
138
+ // session key has the form:
139
+ // agent:<agentId>:xiaoyi-channel:<accountId>:<sessionId>
140
+ // The last `:`-delimited segment is the A2A sessionId.
141
+ if (sessionKey) {
142
+ const lastColon = sessionKey.lastIndexOf(":");
143
+ if (lastColon >= 0) {
144
+ const sessionId = sessionKey.slice(lastColon + 1).trim();
145
+ if (sessionId)
146
+ return { conversationId: sessionId };
147
+ }
148
+ }
149
+ return null;
137
150
  },
138
151
  },
139
152
  reload: {
@@ -3,6 +3,9 @@
3
3
  */
4
4
  import fs from 'fs';
5
5
  import path from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
6
9
  import { CONFIG_FILE_NAME, ENV_FILE_PATH, REQUIRED_ENV_VARS } from './constants.js';
7
10
  import { logger } from '../utils/logger.js';
8
11
  let cachedConfig = null;
@@ -430,15 +430,16 @@ export function createXYReplyDispatcher(params) {
430
430
  }
431
431
  else {
432
432
  // 新文本不以已累积内容为前缀(如工具调用后模型重新开始生成),
433
- // 更新 accumulatedText 为当前文本,后续基于此新前缀做去重
433
+ // 重置 accumulatedText 为当前文本,后续基于此新前缀做去重
434
434
  const wasFirstRound = accumulatedText.length === 0;
435
- accumulatedText = "";
436
435
  // 新一轮输出前加换行分隔(第一轮除外)
437
436
  if (sendText.length > 0 && !wasFirstRound) {
438
437
  sendText = "\n" + sendText;
439
438
  }
440
439
  }
441
- accumulatedText += sendText;
440
+ // 始终追踪模型的原始输出文本,避免注入的 "\n" 前缀污染 accumulatedText
441
+ // 导致下一轮 startsWith 永久匹配失败
442
+ accumulatedText = text;
442
443
  hasSentResponse = true;
443
444
  if (sendText.length > 0) {
444
445
  await sendA2AResponse({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.206-beta",
3
+ "version": "0.0.208-beta",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",