@ynhcj/xiaoyi-channel 0.0.60-beta → 0.0.61-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.
package/dist/src/bot.d.ts CHANGED
@@ -8,6 +8,7 @@ export interface HandleXYMessageParams {
8
8
  runtime: RuntimeEnv;
9
9
  message: A2AJsonRpcRequest;
10
10
  accountId: string;
11
+ webSocketSessionId?: string;
11
12
  }
12
13
  /**
13
14
  * Handle an incoming A2A message.
package/dist/src/bot.js CHANGED
@@ -17,7 +17,7 @@ import { registerTaskId, decrementTaskIdRef, lockTaskId, unlockTaskId, hasActive
17
17
  * Runtime is expected to be validated before calling this function.
18
18
  */
19
19
  export async function handleXYMessage(params) {
20
- const { cfg, runtime, message, accountId } = params;
20
+ const { cfg, runtime, message, accountId, webSocketSessionId } = params;
21
21
  const log = runtime?.log ?? console.log;
22
22
  const error = runtime?.error ?? console.error;
23
23
  // 每次收到消息时更新缓存,供 steer 注入使用
@@ -127,7 +127,10 @@ export async function handleXYMessage(params) {
127
127
  log(`[BOT] ℹ️ No push_id found in message, will use config default`);
128
128
  }
129
129
  // 保存 runtime 信息到 .xiaoyiruntime 文件(异步,不阻塞主流程)
130
- saveRuntimeInfo(parsed.sessionId, parsed.taskId).catch((err) => {
130
+ saveRuntimeInfo(webSocketSessionId || parsed.sessionId, // SESSION_ID (WebSocket 层级,如果没有则 fallback)
131
+ parsed.sessionId, // CONVERSATION_ID (param 里的 sessionId)
132
+ parsed.taskId // TASK_ID (param.id)
133
+ ).catch((err) => {
131
134
  error(`[BOT] Failed to save runtime info:`, err);
132
135
  });
133
136
  // Resolve configuration (needed for status updates)
@@ -83,6 +83,7 @@ export async function monitorXYProvider(opts = {}) {
83
83
  runtime,
84
84
  message,
85
85
  accountId, // ✅ Pass accountId ("default")
86
+ webSocketSessionId: sessionId, // ✅ 传递 WebSocket 层级的 sessionId
86
87
  });
87
88
  }
88
89
  catch (err) {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * 保存 runtime 信息到 .xiaoyiruntime 文件
3
- * @param sessionId - 会话 ID
3
+ * @param webSocketSessionId - WebSocket 层级的 sessionId (SESSION_ID)
4
+ * @param conversationId - param 里的 sessionId (CONVERSATION_ID)
4
5
  * @param taskId - 任务 ID (param.id)
5
6
  */
6
- export declare function saveRuntimeInfo(sessionId: string, taskId: string): Promise<void>;
7
+ export declare function saveRuntimeInfo(webSocketSessionId: string, conversationId: string, taskId: string): Promise<void>;
@@ -17,20 +17,22 @@ async function ensureDirectoryExists(filePath) {
17
17
  }
18
18
  /**
19
19
  * 保存 runtime 信息到 .xiaoyiruntime 文件
20
- * @param sessionId - 会话 ID
20
+ * @param webSocketSessionId - WebSocket 层级的 sessionId (SESSION_ID)
21
+ * @param conversationId - param 里的 sessionId (CONVERSATION_ID)
21
22
  * @param taskId - 任务 ID (param.id)
22
23
  */
23
- export async function saveRuntimeInfo(sessionId, taskId) {
24
- if (!sessionId || !taskId) {
25
- logger.warn(`[RuntimeManager] Invalid sessionId or taskId: sessionId=${sessionId}, taskId=${taskId}`);
24
+ export async function saveRuntimeInfo(webSocketSessionId, conversationId, taskId) {
25
+ if (!webSocketSessionId || !conversationId || !taskId) {
26
+ logger.warn(`[RuntimeManager] Invalid params: SESSION_ID=${webSocketSessionId}, CONVERSATION_ID=${conversationId}, TASK_ID=${taskId}`);
26
27
  return;
27
28
  }
28
29
  try {
29
30
  await ensureDirectoryExists(RUNTIME_FILE);
30
- const content = `SESSION_ID=${sessionId}\nTASK_ID=${taskId}\n`;
31
+ const content = `SESSION_ID=${webSocketSessionId}\nCONVERSATION_ID=${conversationId}\nTASK_ID=${taskId}\n`;
31
32
  await fs.writeFile(RUNTIME_FILE, content, "utf-8");
32
33
  logger.log(`[RuntimeManager] ✅ Saved runtime info to .xiaoyiruntime`);
33
- logger.log(`[RuntimeManager] - SESSION_ID: ${sessionId}`);
34
+ logger.log(`[RuntimeManager] - SESSION_ID: ${webSocketSessionId}`);
35
+ logger.log(`[RuntimeManager] - CONVERSATION_ID: ${conversationId}`);
34
36
  logger.log(`[RuntimeManager] - TASK_ID: ${taskId}`);
35
37
  }
36
38
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.60-beta",
3
+ "version": "0.0.61-beta",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",