import { execFile } from 'node:child_process'; export interface ShellResult { stdout: string; stderr: string; } export function run(cmd: string, args: string[], timeoutMs = 120000): Promise { return new Promise((resolve, reject) => { execFile(cmd, args, { timeout: timeoutMs, maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => { if (error) { const err = new Error(`Command failed: ${cmd} ${args.join(' ')}\n${stderr || error.message}`); (err as any).stdout = stdout; (err as any).stderr = stderr; reject(err); return; } resolve({ stdout, stderr }); }); }); }