INNER CODE UNIT · TypeScript
isClawdInstance
AmrDab/clawdcursor · src/surface/cli.ts:120
async function isClawdInstance(port: number): Promise<boolean> {
try {
const res = await fetch(`http://127.0.0.1:${port}/health`, { signal: AbortSignal.timeout(2000) });
const data = await res.json() as any;
return data.status === 'ok' && typeof data.version === 'string';
} catch {
return false;
}
}
async function forceKillPort(port: number): Promise<boolean> {
const { execSync } = await import('child_process');
const os = await import('os');
// #114: only ever kill processes that are plausibly OURS. The port is
// configurable and ports get reused — blindly SIGKILLing whatever listens on
// it can take down an unrelated app (dev server, another tool). clawdcursor
// always runs under node, so a listener with any other image name is not