@sleep2agi/commhub-server 0.8.3-preview.0 → 0.8.3-preview.1
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/package.json +1 -1
- package/src/index.ts +26 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/commhub-server",
|
|
3
|
-
"version": "0.8.3-preview.
|
|
3
|
+
"version": "0.8.3-preview.1",
|
|
4
4
|
"description": "CommHub Server — AI Agent communication hub with MCP protocol, multi-network isolation, user auth, and 17 MCP tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -988,13 +988,38 @@ Bun.serve({
|
|
|
988
988
|
last_seen: string | null;
|
|
989
989
|
}>();
|
|
990
990
|
|
|
991
|
+
const preferDisplayIp = (current: string, next: string) => {
|
|
992
|
+
const isWeak = (ip: string) => !ip || ip === "unknown" || ip === "127.0.0.1" || ip === "::1";
|
|
993
|
+
if (isWeak(current) && !isWeak(next)) return next;
|
|
994
|
+
return current;
|
|
995
|
+
};
|
|
996
|
+
const hasHostTelemetry = (row: any) =>
|
|
997
|
+
row.cpu_load_1min != null || row.cpu_cores != null || row.mem_avail_gb != null || row.mem_used_gb != null;
|
|
998
|
+
|
|
991
999
|
for (const row of db.all<any>(sql, ...params)) {
|
|
992
1000
|
const hostname = row.hostname || "unknown";
|
|
993
1001
|
const ip = row.ip || "unknown";
|
|
994
|
-
|
|
1002
|
+
// Group primarily by hostname. A single host can report both a
|
|
1003
|
+
// routable/container IP and loopback (127.0.0.1); splitting those
|
|
1004
|
+
// into separate cards makes the dashboard show one useful load row
|
|
1005
|
+
// plus one "n/a" duplicate. Unknown hostnames still fall back to IP.
|
|
1006
|
+
const key = hostname !== "unknown" ? `host:${hostname}` : `ip:${ip}`;
|
|
995
1007
|
const existing = grouped.get(key);
|
|
996
1008
|
if (existing) {
|
|
997
1009
|
existing.agent_count += 1;
|
|
1010
|
+
existing.ip = preferDisplayIp(existing.ip, ip);
|
|
1011
|
+
if (parseSqliteTime(row.last_seen) > parseSqliteTime(existing.last_seen)) existing.last_seen = row.last_seen ?? existing.last_seen;
|
|
1012
|
+
if (hasHostTelemetry(row) && (
|
|
1013
|
+
existing.cpu_load_1min == null ||
|
|
1014
|
+
existing.cpu_cores == null ||
|
|
1015
|
+
existing.mem_avail_gb == null ||
|
|
1016
|
+
existing.mem_used_gb == null
|
|
1017
|
+
)) {
|
|
1018
|
+
existing.cpu_load_1min = row.cpu_load_1min ?? existing.cpu_load_1min;
|
|
1019
|
+
existing.cpu_cores = row.cpu_cores ?? existing.cpu_cores;
|
|
1020
|
+
existing.mem_avail_gb = row.mem_avail_gb ?? existing.mem_avail_gb;
|
|
1021
|
+
existing.mem_used_gb = row.mem_used_gb ?? existing.mem_used_gb;
|
|
1022
|
+
}
|
|
998
1023
|
continue;
|
|
999
1024
|
}
|
|
1000
1025
|
grouped.set(key, {
|