Add !logs command — tail agent log via SSH

This commit is contained in:
2026-04-07 21:01:39 +00:00
parent 185cda575e
commit e1f1a24a37

View File

@@ -195,6 +195,39 @@ export async function runOverseer(config: OverseerConfig) {
break;
}
case "!logs": {
const name = parts[1];
const n = parseInt(parts[2] || "10");
if (!name) {
bot.say(event.target, "Usage: !logs <name> [lines]");
return;
}
const agents = listAgents();
const agent = agents.find((a) => a.name === name);
if (!agent) {
bot.say(event.target, `Agent "${name}" not found.`);
return;
}
try {
const { execFileSync } = await import("node:child_process");
const { sshKeyPath } = (await import("./config.js")).CONFIG;
const logs = execFileSync("ssh", [
"-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "ConnectTimeout=3",
"-i", sshKeyPath,
`root@${agent.ip}`,
`tail -n ${n} /workspace/agent.log 2>/dev/null || echo '[no logs yet]'`,
], { encoding: "utf-8", timeout: 5_000 }).trim();
for (const line of logs.split("\n")) {
bot.say(event.target, line);
}
} catch {
bot.say(event.target, `Could not read logs for "${name}".`);
}
break;
}
case "!persona": {
const name = parts[1];
if (!name) {
@@ -233,7 +266,7 @@ export async function runOverseer(config: OverseerConfig) {
}
case "!help": {
bot.say(event.target, "Commands: !invoke <template> [name] | !destroy <name> | !list | !model <name> <model> | !models | !templates | !persona <name> [text] | !status | !help");
bot.say(event.target, "Commands: !invoke <template> [name] | !destroy <name> | !list | !model <name> <model> | !models | !templates | !persona <name> [text] | !logs <name> [n] | !status | !help");
break;
}
}