@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
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,
|
|
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)
|
package/dist/src/monitor.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 保存 runtime 信息到 .xiaoyiruntime 文件
|
|
3
|
-
* @param
|
|
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(
|
|
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
|
|
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(
|
|
24
|
-
if (!
|
|
25
|
-
logger.warn(`[RuntimeManager] Invalid
|
|
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=${
|
|
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: ${
|
|
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) {
|