@ynhcj/xiaoyi-channel 0.0.59-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
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.
|
|
@@ -16,7 +17,7 @@ import { registerTaskId, decrementTaskIdRef, lockTaskId, unlockTaskId, hasActive
|
|
|
16
17
|
* Runtime is expected to be validated before calling this function.
|
|
17
18
|
*/
|
|
18
19
|
export async function handleXYMessage(params) {
|
|
19
|
-
const { cfg, runtime, message, accountId } = params;
|
|
20
|
+
const { cfg, runtime, message, accountId, webSocketSessionId } = params;
|
|
20
21
|
const log = runtime?.log ?? console.log;
|
|
21
22
|
const error = runtime?.error ?? console.error;
|
|
22
23
|
// 每次收到消息时更新缓存,供 steer 注入使用
|
|
@@ -125,6 +126,13 @@ 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(webSocketSessionId || parsed.sessionId, // SESSION_ID (WebSocket 层级,如果没有则 fallback)
|
|
131
|
+
parsed.sessionId, // CONVERSATION_ID (param 里的 sessionId)
|
|
132
|
+
parsed.taskId // TASK_ID (param.id)
|
|
133
|
+
).catch((err) => {
|
|
134
|
+
error(`[BOT] Failed to save runtime info:`, err);
|
|
135
|
+
});
|
|
128
136
|
// Resolve configuration (needed for status updates)
|
|
129
137
|
const config = resolveXYConfig(cfg);
|
|
130
138
|
// ✅ Resolve agent route (following feishu pattern)
|
package/dist/src/monitor.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 保存 runtime 信息到 .xiaoyiruntime 文件
|
|
3
|
+
* @param webSocketSessionId - WebSocket 层级的 sessionId (SESSION_ID)
|
|
4
|
+
* @param conversationId - param 里的 sessionId (CONVERSATION_ID)
|
|
5
|
+
* @param taskId - 任务 ID (param.id)
|
|
6
|
+
*/
|
|
7
|
+
export declare function saveRuntimeInfo(webSocketSessionId: string, conversationId: string, taskId: string): Promise<void>;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 webSocketSessionId - WebSocket 层级的 sessionId (SESSION_ID)
|
|
21
|
+
* @param conversationId - param 里的 sessionId (CONVERSATION_ID)
|
|
22
|
+
* @param taskId - 任务 ID (param.id)
|
|
23
|
+
*/
|
|
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}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
await ensureDirectoryExists(RUNTIME_FILE);
|
|
31
|
+
const content = `SESSION_ID=${webSocketSessionId}\nCONVERSATION_ID=${conversationId}\nTASK_ID=${taskId}\n`;
|
|
32
|
+
await fs.writeFile(RUNTIME_FILE, content, "utf-8");
|
|
33
|
+
logger.log(`[RuntimeManager] ✅ Saved runtime info to .xiaoyiruntime`);
|
|
34
|
+
logger.log(`[RuntimeManager] - SESSION_ID: ${webSocketSessionId}`);
|
|
35
|
+
logger.log(`[RuntimeManager] - CONVERSATION_ID: ${conversationId}`);
|
|
36
|
+
logger.log(`[RuntimeManager] - TASK_ID: ${taskId}`);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
logger.error(`[RuntimeManager] Failed to save runtime info:`, error);
|
|
40
|
+
// 不抛出异常,避免影响主流程
|
|
41
|
+
}
|
|
42
|
+
}
|