mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-30 05:02:58 +00:00
* fix(providers): launch plugin CLIs on Windows and tolerate Muse startup Plugin providers bypassed the core Windows launcher and the plugin host exposed an empty server SDK module. Share the launcher through the SDK and bind it in the host. Give Muse initialization its own deadline because native startup traverses session history before answering MSP. * fix(providers): terminate Windows launcher process trees A command-script launcher leaves the CLI behind cmd.exe. Expose forced process-tree termination in the server SDK, use it for Muse and SDK ACP teardown, and bound Muse closing so inherited streams cannot leave callers waiting forever. * test(muse): keep platform setup outside the teardown assertion * refactor(plugin): expose process capabilities without quoting helpers * fix(providers): close process trees on uncorrelated protocol errors
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { execCommand } from "@getpaseo/plugin/server";
|
|
|
|
interface SignalOptions {
|
|
platform: NodeJS.Platform;
|
|
pid: number;
|
|
signal: NodeJS.Signals;
|
|
}
|
|
|
|
type SignalPlan =
|
|
| { type: "group"; pid: number; signal: NodeJS.Signals }
|
|
| { type: "tree"; command: "taskkill"; args: string[] };
|
|
|
|
export function signalPlan(options: SignalOptions): SignalPlan {
|
|
if (options.platform === "win32") {
|
|
return { type: "tree", command: "taskkill", args: ["/PID", String(options.pid), "/T", "/F"] };
|
|
}
|
|
return { type: "group", pid: -options.pid, signal: options.signal };
|
|
}
|
|
|
|
export function signalProcess(options: SignalOptions): void | Promise<void> {
|
|
const plan = signalPlan(options);
|
|
if (plan.type === "tree") return killTree(plan);
|
|
try {
|
|
process.kill(plan.pid, plan.signal);
|
|
} catch (error) {
|
|
if (!(error instanceof Error && "code" in error && error.code === "ESRCH")) throw error;
|
|
}
|
|
}
|
|
|
|
async function killTree(plan: Extract<SignalPlan, { type: "tree" }>): Promise<void> {
|
|
try {
|
|
await execCommand(plan.command, plan.args, { shell: false });
|
|
} catch (error) {
|
|
// taskkill reports an already-exited PID with exit code 128.
|
|
if (!(error instanceof Error && "code" in error && error.code === 128)) throw error;
|
|
}
|
|
}
|