Merges FN-3396's full Cursor CLI provider integration (Steps 1–4): defines a CLI-backed provider contract, adds the `fusion-plugin-cursor-runtime` plugin package with process management and runtime probes, wires dashboard auth flows and UI (ProviderCard, onboarding modal, settings), and bundles the Fusion-Task-Id: FN-3396
26 lines
932 B
TypeScript
26 lines
932 B
TypeScript
import { spawn } from "node:child_process";
|
|
|
|
export async function runCursorCommand(binary: string, args: string[], timeoutMs: number): Promise<{ code: number | null; stdout: string; stderr: string }> {
|
|
return new Promise((resolve) => {
|
|
const child = spawn(binary, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
let stdout = "";
|
|
let stderr = "";
|
|
const timer = setTimeout(() => {
|
|
try { child.kill("SIGKILL"); } catch {
|
|
// best effort
|
|
}
|
|
resolve({ code: 124, stdout, stderr });
|
|
}, timeoutMs);
|
|
child.stdout?.on("data", (c: Buffer) => { stdout += c.toString("utf-8"); });
|
|
child.stderr?.on("data", (c: Buffer) => { stderr += c.toString("utf-8"); });
|
|
child.once("error", () => {
|
|
clearTimeout(timer);
|
|
resolve({ code: 127, stdout, stderr });
|
|
});
|
|
child.once("close", (code) => {
|
|
clearTimeout(timer);
|
|
resolve({ code, stdout, stderr });
|
|
});
|
|
});
|
|
}
|