Extract SSH_OPTS constant, deduplicate SSH options

This commit is contained in:
2026-04-08 01:36:01 +00:00
parent fe162d11f7
commit 100bb98e62

View File

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