Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Restart Antigravity when its MCP bearer changes
koeriabe32e53f6a1e
diff --git a/server/drivers/antigravity.test.ts b/server/drivers/antigravity.test.tsindex 3f041e37af..c6a04d561d 100644--- a/server/drivers/antigravity.test.ts+++ b/server/drivers/antigravity.test.ts@@ -1454,7 +1454,7 @@ describe("Antigravity driver over shared ACP", () => {});});- it("runs each turn of a pooled, resumed session under that turn's own permission mode", async () => {+ it("runs each turn of a pooled session under that turn's own permission mode", async () => {ensureDirs();const fake = fakeRuntime();const dump = join(fake.directory, "dump.json");@@ -1494,17 +1494,62 @@ describe("Antigravity driver over shared ACP", () => {approvalMode,model: "gemini-3.8-flash-high",cwd: fake.directory,- // The harness mints fresh MCP credentials every turn, so later turns resume on the pooled process.+ // A rotated MCP bearer starts a fresh process; this test keeps one bearer so it can exercise a pooled resume....(index ? { resumeCursor: "fake-acp-session" } : {}),- integrations: { agents: { command: "agents-mcp", args: [], env: { TOKEN: `turn-${index}` } } },+ integrations: { agents: { command: "agents-mcp", args: [], env: { TOKEN: "stable-token" } } },});expect(await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId)).toMatchObject({ ok: true });expect(promptModes()).toHaveLength(index + 1);expect([approvalMode, promptModes().at(-1)]).toEqual([approvalMode, native]);}expect(Number(readFileSync(launches, "utf8"))).toBe(1);+ // Same bearer keeps the live session, so later turns do not go through session/resume.expect((JSON.parse(readFileSync(rpcDump, "utf8")) as string[]).filter((method) => method === "session/resume"))- .toHaveLength(sequence.length - 1);+ .toHaveLength(0);+ });++ it("starts a fresh Antigravity process when the app's MCP bearer changes, since a live session/resume keeps the old one", async () => {+ ensureDirs();+ const fake = fakeRuntime();+ const launches = join(fake.directory, "launches");+ const instanceId = "antigravity-mcp-bearer";+ const tokenDirectory = join(antigravityProfileDirectory(instanceId), "antigravity-acp");+ mkdirSync(tokenDirectory, { recursive: true });+ writeFileSync(join(tokenDirectory, "acp_token.json"), "{}", { mode: 0o600 });+ instance = await AntigravityDriver.create({+ instanceId,+ displayName: "Antigravity",+ environment: {+ FAKE_ACP_AUTH_METHOD: "oauth-personal",+ FAKE_ACP_MODELS: "gemini-3.8-flash-high",+ FAKE_ACP_MODES: "default,yolo",+ FAKE_ACP_LAUNCH_COUNT_FILE: launches,+ },+ enabled: true,+ config: { cli: fake.executable, fullAuto: false },+ });+ await instance.startupModelRefresh;+ rmSync(launches, { force: true });+ recorder = recordEvents(instance.adapter);+ const agents = (token: string) => ({ command: "agents-mcp", args: [], env: { TOKEN: token } });+ const turn = async (text: string, token: string, resume: boolean) => {+ const { turnId } = await instance!.adapter.sendTurn({+ threadId: "thread-mcp-bearer",+ text,+ approvalMode: "ask",+ model: "gemini-3.8-flash-high",+ cwd: fake.directory,+ ...(resume ? { resumeCursor: "fake-acp-session" } : {}),+ integrations: { agents: agents(token) },+ });+ expect(await recorder!.until((event) => event.type === "turn.completed" && event.turnId === turnId)).toMatchObject({ ok: true });+ };+ await turn("open the portal", "token-one", false);+ const afterFirst = Number(readFileSync(launches, "utf8"));+ await turn("signed in, carry on", "token-two", true);+ expect(Number(readFileSync(launches, "utf8"))).toBe(afterFirst + 1);+ await turn("same bearer", "token-two", true);+ expect(Number(readFileSync(launches, "utf8"))).toBe(afterFirst + 1);});it.each(["empty", "error"] as const)(diff --git a/server/drivers/antigravity.ts b/server/drivers/antigravity.tsindex ce87389660..fda0506eac 100644--- a/server/drivers/antigravity.ts+++ b/server/drivers/antigravity.ts@@ -199,6 +199,9 @@ const support: AcpSupport = {sessionModelEnv: "AGY_ACP_DEFAULT_MODEL",sessionScopedApproval: true,resumeMethod: "resume",+ // session/resume in a live process keeps the MCP registrations it opened first, so a rotated+ // app bearer is still sent (HTTP 401) alongside the new one until the process is replaced.+ restartOnMcpChange: true,// The packaged runtime unpacks and loads a ~1 GB Python bundle before it answers initialize (STARTUP_TIMEOUT_MS).coldStartCost: "expensive",// The startup model read is a second runtime process and a thinking-level survey: a saved list stands in for it.