Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const http = require("http");
const fs = require("fs");
const path = require("path");
const { execSync, exec } = require("child_process");

Check warning on line 10 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (22.x)

'exec' is assigned a value but never used

Check warning on line 10 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (24.x)

'exec' is assigned a value but never used

Check warning on line 10 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

'exec' is assigned a value but never used
const { handleJobsRequest, isJobsRoute } = require("./jobs");
const { CONFIG } = require("./config");

Expand Down Expand Up @@ -151,7 +151,7 @@
avatar: operator?.avatar || null,
};
}
} catch (e) {}

Check warning on line 154 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (22.x)

Empty block statement

Check warning on line 154 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (24.x)

Empty block statement

Check warning on line 154 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Empty block statement
}

return null;
Expand Down Expand Up @@ -392,7 +392,7 @@
});
vitals.cpu.pCores = parseInt(perfCores.trim(), 10) || null;
vitals.cpu.eCores = parseInt(effCores.trim(), 10) || null;
} catch (e) {}

Check warning on line 395 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (22.x)

Empty block statement

Check warning on line 395 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (24.x)

Empty block statement

Check warning on line 395 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Empty block statement

// Get CPU brand
try {
Expand All @@ -400,7 +400,7 @@
encoding: "utf8",
}).trim();
if (brand) vitals.cpu.brand = brand;
} catch (e) {}

Check warning on line 403 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (22.x)

Empty block statement

Check warning on line 403 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (24.x)

Empty block statement

Check warning on line 403 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Empty block statement

// Get chip name for Apple Silicon
try {
Expand All @@ -409,8 +409,8 @@
{ encoding: "utf8" },
).trim();
if (chip) vitals.cpu.chip = chip;
} catch (e) {}

Check warning on line 412 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (22.x)

Empty block statement

Check warning on line 412 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (24.x)

Empty block statement

Check warning on line 412 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Empty block statement
} catch (e) {}

Check warning on line 413 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (22.x)

Empty block statement

Check warning on line 413 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (24.x)

Empty block statement

Check warning on line 413 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Empty block statement

// Get CPU usage breakdown (user/sys/idle) from top
try {
Expand All @@ -429,7 +429,7 @@
if (vitals.cpu.userPercent !== null && vitals.cpu.sysPercent !== null) {
vitals.cpu.usage = Math.round(vitals.cpu.userPercent + vitals.cpu.sysPercent);
}
} catch (e) {}

Check warning on line 432 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (22.x)

Empty block statement

Check warning on line 432 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (24.x)

Empty block statement

Check warning on line 432 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Empty block statement

// Disk usage (macOS df - use ~ to get Data volume, not read-only system volume)
try {
Expand All @@ -444,7 +444,7 @@
vitals.disk.free = freeKb * 1024;
vitals.disk.percent = Math.round((usedKb / totalKb) * 100);
}
} catch (e) {}

Check warning on line 447 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (22.x)

Empty block statement

Check warning on line 447 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (24.x)

Empty block statement

Check warning on line 447 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Empty block statement

// Disk I/O stats (macOS iostat) - IOPS, throughput, transfer size
try {
Expand Down Expand Up @@ -480,7 +480,7 @@
const wiredMatch = vmStatRaw.match(/Pages wired down:\s+(\d+)/);
const compressedMatch = vmStatRaw.match(/Pages occupied by compressor:\s+(\d+)/);

const freePages = freeMatch ? parseInt(freeMatch[1], 10) : 0;

Check warning on line 483 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (22.x)

'freePages' is assigned a value but never used

Check warning on line 483 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (24.x)

'freePages' is assigned a value but never used

Check warning on line 483 in lib/server.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

'freePages' is assigned a value but never used
const activePages = activeMatch ? parseInt(activeMatch[1], 10) : 0;
const inactivePages = inactiveMatch ? parseInt(inactiveMatch[1], 10) : 0;
const wiredPages = wiredMatch ? parseInt(wiredMatch[1], 10) : 0;
Expand Down Expand Up @@ -572,15 +572,17 @@

// Helper to run openclaw commands
function runOpenClaw(args) {
const profile = process.env.OPENCLAW_PROFILE || "";
const profileFlag = profile ? ` --profile ${profile}` : "";
try {
const result = execSync(`openclaw ${args}`, {
const result = execSync(`openclaw${profileFlag} ${args}`, {
encoding: "utf8",
timeout: 10000,
env: { ...process.env, NO_COLOR: "1" },
});
return result;
} catch (e) {
console.error(`openclaw ${args} failed:`, e.message);
console.error(`openclaw${profileFlag} ${args} failed:`, e.message);
return null;
}
}
Expand Down Expand Up @@ -1102,7 +1104,9 @@
// Query active sessions via openclaw CLI
try {
// Use openclaw sessions list which actually works (gateway /api/sessions doesn't exist)
const response = execSync("openclaw sessions list --json 2>/dev/null", {
const profile = process.env.OPENCLAW_PROFILE || "";
const profileFlag = profile ? ` --profile ${profile}` : "";
const response = execSync(`openclaw${profileFlag} sessions list --json 2>/dev/null`, {
timeout: 5000,
encoding: "utf8",
});
Expand Down
Loading