Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(pi): give Pi its TERM grace before the kill, so Stop ends the tool processes it started
milind-soni6c486ad71164
diff --git a/server/drivers/pi-lifecycle.test.ts b/server/drivers/pi-lifecycle.test.tsindex 5df72b007e..c1be72d966 100644--- a/server/drivers/pi-lifecycle.test.ts+++ b/server/drivers/pi-lifecycle.test.ts@@ -61,6 +61,7 @@ it.each(["interrupt", "stopAll", "dispose"])("keeps ownership through %s until texpect(ownedWhileStopping).toBe(true);expect(() => process.kill(pid, 0)).toThrow();expect(runningAtCompletion).toBe(false);+ expect(readFileSync(join(dir, "rpc.jsonl"), "utf8")).toContain('"terminated":true');expect(events.events.filter((event) => event.type === "turn.completed")).toMatchObject([{ ok: true, stopReason: "cancelled" },]);diff --git a/server/drivers/pi.ts b/server/drivers/pi.tsindex db99a4cb70..118d932cbb 100644--- a/server/drivers/pi.ts+++ b/server/drivers/pi.ts@@ -562,7 +562,8 @@ export const PiDriver: ProviderDriver<PiConfig> = {child.stdin.end();} catch {}completion = (async () => {- if (!await killCliTree(child, process.platform === "win32" ? 5_000 : 0)) throw new Error("Pi process termination could not be confirmed");+ // The TERM grace lets Pi end the detached tool processes it started; a CLI that ignores TERM is killed after it.+ if (!await killCliTree(child)) throw new Error("Pi process termination could not be confirmed");rejectWaiters(new Error("pi turn ended"));try {rmSync(mcpTempDir, { recursive: true, force: true });diff --git a/server/testing/fake-pi-lifecycle.mjs b/server/testing/fake-pi-lifecycle.mjsindex 35e386d6df..2b1bd46478 100755--- a/server/testing/fake-pi-lifecycle.mjs+++ b/server/testing/fake-pi-lifecycle.mjs@@ -7,7 +7,8 @@ const send = (frame) => process.stdout.write(JSON.stringify(frame) + "\n");const reply = (command, data) => send({ type: "response", command, success: true, data });const model = { provider: "fixture", id: "default" };-process.on("SIGTERM", () => {});+// Like Pi, ends its own tool processes on TERM, which takes a moment, then exits.+process.on("SIGTERM", () => setTimeout(() => { dump({ terminated: true }); process.exit(143); }, 100));setInterval(() => {}, 1_000);createInterface({ input: process.stdin }).on("line", (line) => {const cmd = JSON.parse(line);