From e1f1a24a37f7c6f0f7c45b9792755fef400d2fb6 Mon Sep 17 00:00:00 2001 From: ansible Date: Tue, 7 Apr 2026 21:01:39 +0000 Subject: [PATCH] =?UTF-8?q?Add=20!logs=20command=20=E2=80=94=20tail=20agen?= =?UTF-8?q?t=20log=20via=20SSH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/overseer.ts | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/overseer.ts b/src/overseer.ts index 2acf99f..2223701 100644 --- a/src/overseer.ts +++ b/src/overseer.ts @@ -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 [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