hvip-mcp-server 0.2.55 → 0.2.56
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/index.js +48 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37023,11 +37023,55 @@ var AgentHub = class {
|
|
|
37023
37023
|
rooms = /* @__PURE__ */ new Map();
|
|
37024
37024
|
heartbeatTimer = null;
|
|
37025
37025
|
version = "0.0.0";
|
|
37026
|
+
port = 0;
|
|
37026
37027
|
// ── 启动 ──
|
|
37027
37028
|
start(port, host = "0.0.0.0", version2 = "0.0.0") {
|
|
37028
37029
|
this.version = version2;
|
|
37029
|
-
|
|
37030
|
-
|
|
37030
|
+
const startWss = (p) => {
|
|
37031
|
+
return new Promise((resolve2) => {
|
|
37032
|
+
const wss = new import_websocket_server.default({ port: p, host });
|
|
37033
|
+
let resolved = false;
|
|
37034
|
+
const done = (ok) => {
|
|
37035
|
+
if (!resolved) {
|
|
37036
|
+
resolved = true;
|
|
37037
|
+
resolve2(ok);
|
|
37038
|
+
}
|
|
37039
|
+
};
|
|
37040
|
+
wss.on("listening", () => {
|
|
37041
|
+
this.wss = wss;
|
|
37042
|
+
this.port = p;
|
|
37043
|
+
done(true);
|
|
37044
|
+
});
|
|
37045
|
+
wss.on("error", () => {
|
|
37046
|
+
try {
|
|
37047
|
+
wss.close();
|
|
37048
|
+
} catch {
|
|
37049
|
+
}
|
|
37050
|
+
done(false);
|
|
37051
|
+
});
|
|
37052
|
+
setTimeout(() => done(false), 1e3);
|
|
37053
|
+
});
|
|
37054
|
+
};
|
|
37055
|
+
const ports = [port, port + 1, port + 2];
|
|
37056
|
+
startWss(ports[0]).then((ok) => {
|
|
37057
|
+
if (!ok) return startWss(ports[1]);
|
|
37058
|
+
return true;
|
|
37059
|
+
}).then((ok) => {
|
|
37060
|
+
if (!ok) return startWss(ports[2]);
|
|
37061
|
+
return ok === true ? true : false;
|
|
37062
|
+
}).then((ok) => {
|
|
37063
|
+
if (!ok) {
|
|
37064
|
+
process.stderr.write(`[AgentHub] WS Hub \u8DF3\u8FC7\uFF08\u7AEF\u53E3 ${ports.join("/")} \u4E0D\u53EF\u7528\uFF09
|
|
37065
|
+
`);
|
|
37066
|
+
return;
|
|
37067
|
+
}
|
|
37068
|
+
process.stderr.write(`[AgentHub] WS Hub v${version2} ws://${host}:${this.port}
|
|
37069
|
+
`);
|
|
37070
|
+
this.setupHub();
|
|
37071
|
+
});
|
|
37072
|
+
}
|
|
37073
|
+
setupHub() {
|
|
37074
|
+
if (!this.wss) return;
|
|
37031
37075
|
this.ensureRoom("#lobby");
|
|
37032
37076
|
this.ensureRoom("#review");
|
|
37033
37077
|
this.wss.on("connection", (ws) => {
|
|
@@ -37052,7 +37096,7 @@ var AgentHub = class {
|
|
|
37052
37096
|
if (now - a.lastSeen > 12e4) {
|
|
37053
37097
|
a.ws.close();
|
|
37054
37098
|
this.agents.delete(id);
|
|
37055
|
-
console.log(
|
|
37099
|
+
console.log("[AgentHub] Agent \u5FC3\u8DF3\u8D85\u65F6: " + id);
|
|
37056
37100
|
}
|
|
37057
37101
|
}
|
|
37058
37102
|
}, 3e4);
|
|
@@ -38212,7 +38256,7 @@ async function startStdio(server, version2, auth, readOnly, skipped, skipLog) {
|
|
|
38212
38256
|
await server.connect(transport);
|
|
38213
38257
|
}
|
|
38214
38258
|
async function main() {
|
|
38215
|
-
const VERSION = "0.2.
|
|
38259
|
+
const VERSION = "0.2.56";
|
|
38216
38260
|
const argv = process.argv.slice(2);
|
|
38217
38261
|
if (argv.includes("--help") || argv.includes("-h")) printHelpAndExit(VERSION);
|
|
38218
38262
|
if (argv.includes("--version") || argv.includes("-v")) {
|
package/package.json
CHANGED