@ynhcj/xiaoyi-channel 0.0.59-beta → 0.0.60-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.js CHANGED
@@ -9,6 +9,7 @@ import { registerSession, unregisterSession, runWithSessionContext } from "./too
9
9
  import { configManager } from "./utils/config-manager.js";
10
10
  import { addPushId } from "./utils/pushid-manager.js";
11
11
  import { getPushDataById } from "./utils/pushdata-manager.js";
12
+ import { saveRuntimeInfo } from "./utils/runtime-manager.js";
12
13
  import { registerTaskId, decrementTaskIdRef, lockTaskId, unlockTaskId, hasActiveTask, } from "./task-manager.js";
13
14
  /**
14
15
  * Handle an incoming A2A message.
@@ -125,6 +126,10 @@ export async function handleXYMessage(params) {
125
126
  else {
126
127
  log(`[BOT] ℹ️ No push_id found in message, will use config default`);
127
128
  }
129
+ // 保存 runtime 信息到 .xiaoyiruntime 文件(异步,不阻塞主流程)
130
+ saveRuntimeInfo(parsed.sessionId, parsed.taskId).catch((err) => {
131
+ error(`[BOT] Failed to save runtime info:`, err);
132
+ });
128
133
  // Resolve configuration (needed for status updates)
129
134
  const config = resolveXYConfig(cfg);
130
135
  // ✅ Resolve agent route (following feishu pattern)
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 保存 runtime 信息到 .xiaoyiruntime 文件
3
+ * @param sessionId - 会话 ID
4
+ * @param taskId - 任务 ID (param.id)
5
+ */
6
+ export declare function saveRuntimeInfo(sessionId: string, taskId: string): Promise<void>;
@@ -0,0 +1,40 @@
1
+ // xiaoyi runtime 持久化管理器
2
+ import { promises as fs } from "fs";
3
+ import * as path from "path";
4
+ import { logger } from "./logger.js";
5
+ const RUNTIME_FILE = "/home/sandbox/.openclaw/.xiaoyiruntime";
6
+ /**
7
+ * 确保目录存在
8
+ */
9
+ async function ensureDirectoryExists(filePath) {
10
+ const dir = path.dirname(filePath);
11
+ try {
12
+ await fs.mkdir(dir, { recursive: true });
13
+ }
14
+ catch (error) {
15
+ logger.error(`[RuntimeManager] Failed to create directory ${dir}:`, error);
16
+ }
17
+ }
18
+ /**
19
+ * 保存 runtime 信息到 .xiaoyiruntime 文件
20
+ * @param sessionId - 会话 ID
21
+ * @param taskId - 任务 ID (param.id)
22
+ */
23
+ export async function saveRuntimeInfo(sessionId, taskId) {
24
+ if (!sessionId || !taskId) {
25
+ logger.warn(`[RuntimeManager] Invalid sessionId or taskId: sessionId=${sessionId}, taskId=${taskId}`);
26
+ return;
27
+ }
28
+ try {
29
+ await ensureDirectoryExists(RUNTIME_FILE);
30
+ const content = `SESSION_ID=${sessionId}\nTASK_ID=${taskId}\n`;
31
+ await fs.writeFile(RUNTIME_FILE, content, "utf-8");
32
+ logger.log(`[RuntimeManager] ✅ Saved runtime info to .xiaoyiruntime`);
33
+ logger.log(`[RuntimeManager] - SESSION_ID: ${sessionId}`);
34
+ logger.log(`[RuntimeManager] - TASK_ID: ${taskId}`);
35
+ }
36
+ catch (error) {
37
+ logger.error(`[RuntimeManager] Failed to save runtime info:`, error);
38
+ // 不抛出异常,避免影响主流程
39
+ }
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.59-beta",
3
+ "version": "0.0.60-beta",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",