- New service: tools bridge (port 37147) registry + Carbonyl/PageIndex/Chandra POST jobs - config/services.local.env.example and gitignore for services.local.env - .env.example for repos-devtools, regex-search, ia-dev-gateway, orchestrator, claw proxy, langextract - Orchestrator intents: tools.registry, tools.carbonyl.plan, tools.pageindex.run, tools.chandra.ocr - Docs: API + repo service fiche, architecture index; do not commit dist/
36 lines
992 B
TypeScript
36 lines
992 B
TypeScript
import { spawn } from "node:child_process";
|
|
|
|
export const runProcess = (
|
|
command: string,
|
|
args: string[],
|
|
options: { cwd: string; timeoutMs: number },
|
|
): Promise<{ code: number | null; stdout: string; stderr: string }> => {
|
|
return new Promise((resolve, reject) => {
|
|
const child = spawn(command, args, {
|
|
cwd: options.cwd,
|
|
env: process.env,
|
|
stdio: ["ignore", "pipe", "pipe"],
|
|
});
|
|
let stdout = "";
|
|
let stderr = "";
|
|
const t = setTimeout(() => {
|
|
child.kill("SIGTERM");
|
|
reject(new Error(`Process timeout after ${options.timeoutMs}ms`));
|
|
}, options.timeoutMs);
|
|
child.stdout?.on("data", (d: Buffer) => {
|
|
stdout += d.toString("utf-8");
|
|
});
|
|
child.stderr?.on("data", (d: Buffer) => {
|
|
stderr += d.toString("utf-8");
|
|
});
|
|
child.on("close", (code) => {
|
|
clearTimeout(t);
|
|
resolve({ code, stdout, stderr });
|
|
});
|
|
child.on("error", (e) => {
|
|
clearTimeout(t);
|
|
reject(e);
|
|
});
|
|
});
|
|
};
|