diff --git a/src/overseer.ts b/src/overseer.ts index ae0fdba..d7d6a79 100644 --- a/src/overseer.ts +++ b/src/overseer.ts @@ -9,6 +9,14 @@ import { reloadAgent, type AgentInfo, } from "./agent-manager.js"; +import { CONFIG } from "./config.js"; + +const SSH_OPTS = [ + "-o", "StrictHostKeyChecking=no", + "-o", "UserKnownHostsFile=/dev/null", + "-o", "ConnectTimeout=3", + "-i", CONFIG.sshKeyPath, +]; interface OverseerConfig { server: string; @@ -210,12 +218,8 @@ export async function runOverseer(config: OverseerConfig) { } 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, + ...SSH_OPTS, `root@${agent.ip}`, `tail -n ${n} /workspace/agent.log 2>/dev/null || echo '[no logs yet]'`, ], { encoding: "utf-8", timeout: 5_000 }).trim(); @@ -248,12 +252,8 @@ export async function runOverseer(config: OverseerConfig) { } try { const { execFileSync } = await import("node:child_process"); - const { sshKeyPath } = (await import("./config.js")).CONFIG; const persona = execFileSync("ssh", [ - "-o", "StrictHostKeyChecking=no", - "-o", "UserKnownHostsFile=/dev/null", - "-o", "ConnectTimeout=3", - "-i", sshKeyPath, + ...SSH_OPTS, `root@${agent.ip}`, "cat /etc/agent/persona.md", ], { encoding: "utf-8", timeout: 5_000 }).trim();