Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(pi): mount the turn MCP configuration in Bot Box

leonongoinge3bbc689144a
diff --git a/server/drivers/pi-lifecycle.test.ts b/server/drivers/pi-lifecycle.test.ts
index 7288425aa7..29b0e33173 100644
--- a/server/drivers/pi-lifecycle.test.ts
+++ b/server/drivers/pi-lifecycle.test.ts
@@ -1,10 +1,11 @@
-import { chmodSync, existsSync, mkdtempSync, readFileSync } from "node:fs";
+import { chmodSync, existsSync, mkdtempSync, readFileSync, statSync } from "node:fs";
import type { ChildProcess } from "node:child_process";
import { once } from "node:events";
import { tmpdir } from "node:os";
-import { join } from "node:path";
+import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import { botBox } from "../bot-box/box.ts";
import { ensureDirs } from "../config.ts";
import type { ProviderInstance } from "../contracts.ts";
import { removeTempDir } from "../testing/cleanup.ts";
@@ -158,6 +159,25 @@ it("preserves cancellation when the CLI closes after termination timed out", asy
}
});
+it("makes the private turn MCP configuration available inside the bot box", async () => {
+ const wrap = vi.spyOn(botBox, "wrap").mockReturnValue(null);
+ try {
+ await instance.adapter.sendTurn({ threadId: "boxed-mcp", text: "wait" });
+ await events.until((event) => event.type === "item.started");
+ const request = wrap.mock.calls.map(([request]) => request).find(({ env }) => env.OMB_MCP_CONFIG);
+ const configPath = request?.env.OMB_MCP_CONFIG;
+ expect(configPath).toBeDefined();
+ expect(request?.rw).toEqual([dirname(configPath!)]);
+ expect(JSON.parse(readFileSync(configPath!, "utf8"))).toMatchObject({ askUser: true, mcpServers: {} });
+ if (process.platform !== "win32") expect(statSync(configPath!).mode & 0o777).toBe(0o600);
+ await instance.adapter.interruptTurn("boxed-mcp");
+ await events.until((event) => event.type === "turn.completed");
+ expect(existsSync(dirname(configPath!))).toBe(false);
+ } finally {
+ wrap.mockRestore();
+ }
+});
+
it("fails a refused model change without sending the prompt", async () => {
await instance.adapter.sendTurn({ threadId: "refused-model", text: "hello", model: "fixture/refused" });
const completed = await events.until((event) => event.type === "turn.completed");
diff --git a/server/drivers/pi.ts b/server/drivers/pi.ts
index 20c3a83609..8f69d91697 100644
--- a/server/drivers/pi.ts
+++ b/server/drivers/pi.ts
@@ -481,7 +481,7 @@ export const PiDriver: ProviderDriver<PiConfig> = {
// spawnCli can throw synchronously, before settle() could remove the credential file.
const child = (() => {
try {
- return spawnCli(config.cli, childArgs, {
+ return spawnCli(config.cli, childArgs, { box: { rw: [mcpTempDir] },
stdio: ["pipe", "pipe", "pipe"],
cwd: turn.cwd,
env: piEnvironment({