@ynhcj/xiaoyi-channel 0.0.56-beta → 0.0.57-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/monitor.js
CHANGED
|
@@ -202,8 +202,8 @@ export async function monitorXYProvider(opts = {}) {
|
|
|
202
202
|
wsManager.on("disconnected", disconnectedHandler);
|
|
203
203
|
wsManager.on("error", errorHandler);
|
|
204
204
|
wsManager.on("trigger-event", triggerEventHandler);
|
|
205
|
-
// Start periodic health check (every
|
|
206
|
-
console.log("🏥 Starting periodic health check (every
|
|
205
|
+
// Start periodic health check (every 3 minutes)
|
|
206
|
+
console.log("🏥 Starting periodic health check (every 3 minutes)...");
|
|
207
207
|
healthCheckInterval = setInterval(() => {
|
|
208
208
|
console.log("🏥 [HEALTH CHECK] Periodic WebSocket diagnostics...");
|
|
209
209
|
diagnoseAllManagers();
|
|
@@ -214,7 +214,7 @@ export async function monitorXYProvider(opts = {}) {
|
|
|
214
214
|
}
|
|
215
215
|
// Cleanup stale temp files (older than 24 hours)
|
|
216
216
|
void cleanupStaleTempFiles();
|
|
217
|
-
},
|
|
217
|
+
}, 3 * 60 * 1000); // 3 minutes
|
|
218
218
|
// Connect to WebSocket servers
|
|
219
219
|
wsManager.connect()
|
|
220
220
|
.then(() => {
|
|
@@ -9,7 +9,7 @@ export interface CreateXYReplyDispatcherParams {
|
|
|
9
9
|
isSteerFollower?: boolean;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* 清理 /tmp/xy_channel 目录中超过
|
|
12
|
+
* 清理 /tmp/xy_channel 目录中超过 1 分钟的旧文件
|
|
13
13
|
*/
|
|
14
14
|
export declare function cleanupStaleTempFiles(tempDir?: string): Promise<void>;
|
|
15
15
|
/**
|
|
@@ -4,9 +4,9 @@ import { resolveXYConfig } from "./config.js";
|
|
|
4
4
|
import { getCurrentTaskId, getCurrentMessageId } from "./task-manager.js";
|
|
5
5
|
import fs from "fs/promises";
|
|
6
6
|
import path from "path";
|
|
7
|
-
const TEMP_FILE_TTL_MS =
|
|
7
|
+
const TEMP_FILE_TTL_MS = 60 * 1000; // 1 minute
|
|
8
8
|
/**
|
|
9
|
-
* 清理 /tmp/xy_channel 目录中超过
|
|
9
|
+
* 清理 /tmp/xy_channel 目录中超过 1 分钟的旧文件
|
|
10
10
|
*/
|
|
11
11
|
export async function cleanupStaleTempFiles(tempDir = "/tmp/xy_channel") {
|
|
12
12
|
try {
|
|
@@ -31,7 +31,7 @@ export async function cleanupStaleTempFiles(tempDir = "/tmp/xy_channel") {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
if (cleanedCount > 0) {
|
|
34
|
-
console.log(`[CLEANUP] 🧹 Cleaned ${cleanedCount} stale files (>${TEMP_FILE_TTL_MS / 1000
|
|
34
|
+
console.log(`[CLEANUP] 🧹 Cleaned ${cleanedCount} stale files (>${TEMP_FILE_TTL_MS / 1000}s) from ${tempDir}`);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
catch (err) {
|
|
@@ -90,33 +90,17 @@ export const callPhoneTool = {
|
|
|
90
90
|
clearTimeout(timeout);
|
|
91
91
|
wsManager.off("data-event", handler);
|
|
92
92
|
if (event.status === "success" && event.outputs) {
|
|
93
|
-
// Check for error code in outputs
|
|
94
|
-
const code = event.outputs.code !== undefined ? event.outputs.code : null;
|
|
95
|
-
if (code !== null && code !== 0) {
|
|
96
|
-
const errorMsg = event.outputs.errorMsg || event.outputs.errMsg || "未知错误";
|
|
97
|
-
reject(new Error(`拨打电话失败: ${errorMsg} (错误代码: ${code})`));
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
// Return the outputs directly
|
|
101
|
-
const result = {
|
|
102
|
-
success: true,
|
|
103
|
-
code: code,
|
|
104
|
-
phoneNumber: params.phoneNumber,
|
|
105
|
-
slotId: slotId,
|
|
106
|
-
message: "电话拨打成功",
|
|
107
|
-
};
|
|
108
93
|
resolve({
|
|
109
94
|
content: [
|
|
110
95
|
{
|
|
111
96
|
type: "text",
|
|
112
|
-
text: JSON.stringify(
|
|
97
|
+
text: JSON.stringify(event.outputs),
|
|
113
98
|
},
|
|
114
99
|
],
|
|
115
100
|
});
|
|
116
101
|
}
|
|
117
102
|
else {
|
|
118
|
-
|
|
119
|
-
reject(new Error(`拨打电话失败: ${errorDetail}`));
|
|
103
|
+
reject(new Error(`拨打电话失败: ${event.status}`));
|
|
120
104
|
}
|
|
121
105
|
}
|
|
122
106
|
};
|