Files
PaperClipAI/server/src/lib/agent-runner-platform.ts
T
DottaandPaperclip cc96c9f832 fix(server): probe libc asynchronously before serving requests (#16335)
Linux runner qualification generated a full Node diagnostic report to read one libc version field. Reverse DNS on open sockets could stop the event loop for minutes.

Replace report generation with a one-time asynchronous getconf probe during module initialization. Bound it to one second and 1 KiB of output, cache the measured facts, and preserve unknown-libc failure behavior.

Verification: 149 focused tests, repository typecheck and build, full CI, and fresh Greptile 5/5 with no comments. A timed-out local heartbeat fixture passed when rerun alone.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-14 17:46:50 -05:00

43 lines
1.4 KiB
TypeScript

import { execFile } from "node:child_process";
import { paperclipRunnerSupportsPlatform } from "@paperclipai/shared";
type LocalRunnerTarget = {
driver: "local";
platform: NodeJS.Platform;
architecture: string;
libc?: "glibc" | "unknown";
glibcVersion?: string;
};
async function detectLocalRunnerTarget(): Promise<LocalRunnerTarget> {
const target: LocalRunnerTarget = {
driver: "local", platform: process.platform, architecture: process.arch,
};
if (target.platform !== "linux") return target;
target.libc = "unknown";
try {
const stdout = await new Promise<string>((resolve, reject) => {
execFile("getconf", ["GNU_LIBC_VERSION"], {
encoding: "utf8", timeout: 1_000, killSignal: "SIGKILL", maxBuffer: 1_024,
}, (error, output) => error ? reject(error) : resolve(output));
});
const version = /^glibc\s+(\d+\.\d+(?:\.\d+)?)$/.exec(stdout.trim())?.[1];
if (version) {
target.libc = "glibc";
target.glibcVersion = version;
}
} catch {}
return target;
}
const localTarget = await detectLocalRunnerTarget();
export function localAgentRunnerTarget(): LocalRunnerTarget {
return { ...localTarget };
}
export function localPaperclipRunnerSupported(): boolean {
const target = localAgentRunnerTarget();
return paperclipRunnerSupportsPlatform("codex_local", target.platform, target.architecture, target.libc, target.glibcVersion);
}