Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(copilot): connect automation tools through launcher config
nickash216071c32b433
diff --git a/docs/verification/copilot-engine.md b/docs/verification/copilot-engine.mdindex 7fdc62789a..a4552851fe 100644--- a/docs/verification/copilot-engine.md+++ b/docs/verification/copilot-engine.md@@ -33,6 +33,18 @@ no longer offers a saved model, and a missing login reported as a sign-in step.They also check that `COPILOT_ALLOW_ALL` and a server-wide `GITHUB_TOKEN` neverreach the child, while a token set on the engine itself does.+Copilot CLI 1.0.105 rejects stdio servers in ACP `session/new` and+`session/load` with `Rejecting non-http/sse MCP server "agents" from client`.+The driver supplies the same scoped servers through+`--additional-mcp-config @FILE` instead. Each thread has a private temporary+file, credentials stay out of argv, changed tools or credentials restart the+process, and disposal removes the files without changing the person's Copilot+configuration. ACP permissions still go through OpenMausBot's approval broker.+The fake Copilot rejects client-supplied stdio servers too: the driver tests+require the real agents proxy's routine tools and a synthetic browser's tools+to be discoverable, and check narrowed selections, credential refresh,+revocation, thread isolation and cleanup.+The end-to-end test launches an isolated server with `launchVerificationServer`,which uses a disposable home, data directory and port pair, and fake enginesonly. It refreshes the Copilot and custom ACP catalogs, then moves one bot from@@ -41,6 +53,21 @@ moves one conversation to a custom ACP agent through the conversation route,and moves both back to Claude. Each turn's effective model is read from the fakeagents' prompt receipts, so a saved setting alone cannot pass.+A second scenario scripts Copilot's actual MCP calls to create and update a+routine through the native configuration. It requires the updated routine in+both the server response and `routines.json`, and preserves `send`, `wait` and+`messages` results at the printed `evidencePath` beside the fixture's server log.+It does not use a real Copilot account or execute a scheduled routine.++An offline Linux check against the actual Copilot CLI 1.0.105 reproduced the+stdio rejection with a disposable home and synthetic MCP server. The same+server connected through `--additional-mcp-config`. Through the production+driver, two turns with changed server environments both reported the server+connected and the server recorded `initialize` and `tools/list` with each+turn's environment. This used `COPILOT_OFFLINE=true` and a loopback-only BYOK+route, with no inference or GitHub login. These checks do not prove the+packaged Windows app or a real browser session.+The renderer test passes the production Copilot catalog resolver's output(against the same fake) into the full ModelPicker. It requires the advertisedmodels in the picker and the effort levels of the picked model, and requires adiff --git a/scripts/control-omb.ts b/scripts/control-omb.tsindex d8c2b7488e..1a125d1c97 100644--- a/scripts/control-omb.ts+++ b/scripts/control-omb.ts@@ -312,7 +312,8 @@ export async function launchVerificationServer(...(extraProviders.includes("copilot") ? { githubCopilot: {driver: "copilotAgent", displayName: "Verification Copilot",config: { cli: fileURLToPath(new URL("../server/testing/fake-acp-cli.ts", import.meta.url)) },- environment: { FAKE_ACP_MODELS: "auto,claude-haiku-4.5,gpt-5.6-luna", FAKE_ACP_DUMP: join(dataDir, "copilot-launch.json") },+ environment: { FAKE_ACP_MODELS: "auto,claude-haiku-4.5,gpt-5.6-luna", FAKE_ACP_REJECT_STDIO_MCP: "1",+ FAKE_ACP_DUMP: join(dataDir, "copilot-launch.json") },} } : {}),...(extraProviders.includes("customAcp") ? { myAgent: {driver: "customAcp", displayName: "Verification custom ACP",diff --git a/server/copilot-engine.e2e.test.ts b/server/copilot-engine.e2e.test.tsindex 45b4a454cb..a712fcf8ae 100644--- a/server/copilot-engine.e2e.test.ts+++ b/server/copilot-engine.e2e.test.ts@@ -1,4 +1,4 @@-import { existsSync, readFileSync } from "node:fs";+import { existsSync, readFileSync, writeFileSync } from "node:fs";import { join } from "node:path";import { expect, it } from "vitest";import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";@@ -71,3 +71,62 @@ it("moves one bot and one conversation between Claude, GitHub Copilot and a custawait fixture.close();}}, 120_000);++it("creates and updates a routine through Copilot's launcher-owned tools", async () => {+ const fixture = await launchVerificationServer({}, undefined, undefined, undefined, undefined, undefined, ["copilot"]);+ const { url, dataDir, logPath } = fixture.info;+ const evidence: unknown[] = [{ fixture: fixture.info }];+ const api = async (method: string, path: string, body?: unknown) => {+ const response = await fetch(url + path, { method, headers: { "content-type": "application/json", origin: url },+ ...(body === undefined ? {} : { body: JSON.stringify(body) }), signal: AbortSignal.timeout(30_000) });+ const result = await response.json() as any;+ expect(response.status, `${method} ${path}: ${JSON.stringify(result)}`).toBe(200);+ return result;+ };+ const cli = async (...args: string[]) => {+ const result = await runControlOmb([...args, "--url", url]) as any;+ evidence.push({ command: args, result });+ return result;+ };+ try {+ expect((await cli("doctor")).ok).toBe(true);+ const calls = join(dataDir, "copilot-calls.json");+ const wrapper = join(dataDir, "copilot-fixture.mjs");+ writeFileSync(wrapper, [+ "#!/usr/bin/env node",+ 'process.env.FAKE_ACP_MODE = "mcp-calls";',+ `process.env.FAKE_ACP_MCP_CALLS_FILE = ${JSON.stringify(calls)};`,+ `await import(${JSON.stringify(new URL("./testing/fake-acp-cli.ts", import.meta.url).href)});`,+ ].join("\n"), { mode: 0o700 });+ await api("PATCH", "/api/instances/githubCopilot", { cli: wrapper });+ const bot = (await cli("new-bot", "--name", "Copilot routines")).bot;+ const threadId = bot.activeTaskId;+ await api("PATCH", `/api/bots/${bot.id}`, { modelSelection: { instanceId: "githubCopilot", model: "auto" } });+ const schedule = { type: "cron", expression: "0 9 1 * *", timeZone: "UTC" };+ const turn = async (text: string, args: object) => {+ writeFileSync(calls, JSON.stringify([{ server: "agents", name: "trigger", arguments: args }]));+ await cli("send", "--bot", bot.id, "--task", threadId, "--text", text);+ expect((await cli("wait", "--bot", bot.id, "--task", threadId, "--timeout", "25")).status).toBe("settled");+ const messages = await cli("messages", "--bot", bot.id, "--task", threadId);+ const launch = JSON.parse(readFileSync(join(dataDir, "copilot-launch.json"), "utf8"));+ expect(launch.argv).toContain("--additional-mcp-config");+ expect(launch.mcpServers).toEqual([]);+ evidence.push({ messages });+ };+ await turn("Create a monthly report routine.", { action: "create", when: "schedule", name: "Copilot report",+ instructions: "Summarize synthetic fixture activity without external services.", schedule });+ const routine = (await api("GET", "/api/routines")).routines.find((routine: any) => routine.botId === bot.id);+ expect(routine).toMatchObject({ name: "Copilot report", enabled: true, schedule });+ await turn("Rename the report routine.", { action: "update", trigger_id: routine.id, name: "Updated Copilot report" });+ const saved = (await api("GET", "/api/routines")).routines.find((row: any) => row.id === routine.id);+ expect(saved).toMatchObject({ name: "Updated Copilot report", schedule });+ const persisted = JSON.parse(readFileSync(join(dataDir, "routines.json"), "utf8"));+ expect(persisted.routines.find((row: any) => row.id === routine.id)).toMatchObject({ name: "Updated Copilot report", schedule });+ evidence.push({ saved });+ } finally {+ const evidencePath = `${logPath}.copilot-tools.json`;+ writeFileSync(evidencePath, JSON.stringify(evidence, null, 2));+ console.info(JSON.stringify({ logPath, evidencePath }));+ await fixture.close();+ }+}, 90_000);diff --git a/server/drivers/acp/copilot.test.ts b/server/drivers/acp/copilot.test.tsindex 584b4501b6..917056cfea 100644--- a/server/drivers/acp/copilot.test.ts+++ b/server/drivers/acp/copilot.test.ts@@ -1,4 +1,4 @@-import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";+import { existsSync, mkdirSync, mkdtempSync, readFileSync, statSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";import { dirname, join, sep } from "node:path";import { fileURLToPath } from "node:url";@@ -9,6 +9,8 @@ import type { ProviderInstance } from "../../contracts.ts";import { recordEvents, type EventRecorder } from "../../testing/events.ts";import { removeTempDir } from "../../testing/cleanup.ts";import { BUILT_IN_DRIVERS } from "../builtIn.ts";+import { SPAWNED_PROXIES } from "../../proxy-paths.ts";+import { startFakeHttpMcp } from "../../testing/fake-http-mcp-server.ts";import {classifyCopilotError, CopilotAgentDriver, copilotModelLabel, copilotSignedIn, forgetCopilotDiscoverySession, resolveCopilotModels,} from "./copilot.ts";@@ -44,7 +46,8 @@ describe("GitHub Copilot ACP driver", () => {async function create(environment: Record<string, string> = {}) {instance = await CopilotAgentDriver.create({instanceId: `copilot-contract-${Math.random().toString(36).slice(2)}`, displayName: "GitHub Copilot", enabled: true,- environment: { FAKE_ACP_MODELS: MODELS, FAKE_ACP_VARIANTS: VARIANTS, FAKE_ACP_DUMP: join(scratch, "launch.json"), ...environment },+ environment: { FAKE_ACP_MODELS: MODELS, FAKE_ACP_VARIANTS: VARIANTS, FAKE_ACP_REJECT_STDIO_MCP: "1",+ FAKE_ACP_DUMP: join(scratch, "launch.json"), ...environment },config: { cli: FAKE_CLI, fullAuto: false },});recorder = recordEvents(instance.adapter);@@ -248,7 +251,7 @@ describe("GitHub Copilot ACP driver", () => {await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);expect(recorder.events.every((event) => event.provider === "copilotAgent")).toBe(true);const launch = JSON.parse(readFileSync(join(scratch, "launch.json"), "utf8"));- expect(launch.argv).toEqual(["--acp", "--stdio"]);+ expect(launch.argv.slice(-2)).toEqual(["--acp", "--stdio"]);expect(launch.env.COPILOT_ALLOW_ALL).toBeUndefined();expect(launch.env.GITHUB_TOKEN).toBeUndefined();expect(launch.env.GH_TOKEN).toBe("engine-fixture-token");@@ -266,6 +269,85 @@ describe("GitHub Copilot ACP driver", () => {expect(readFileSync(answer, "utf8")).toBe("reject");});+ it("connects the agents tools even when Copilot rejects ACP stdio servers", async () => {+ const { instance, recorder } = await create({ FAKE_ACP_MODE: "mcp-tools" });+ const browser = await startFakeHttpMcp({+ tools: [{ name: "agent_browser_open", inputSchema: { type: "object", properties: {} } }],+ });+ try {+ const { turnId } = await instance.adapter.sendTurn({+ threadId: "copilot-tools", text: "Which automation controls are available?", model: "auto",+ integrations: {+ agents: { command: process.execPath, args: [SPAWNED_PROXIES.agents],+ env: { OMB_HARNESS_URL: "http://127.0.0.1:1", OMB_COMMS_TOKEN: "fixture-token", OMB_BOT_ID: "fixture" } },+ browser: { command: process.execPath, args: [SPAWNED_PROXIES.mcpRemote],+ env: { OMB_REMOTE_MCP_SERVER: JSON.stringify({ type: "http", url: browser.url }) } },+ },+ });+ expect(await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId)).toMatchObject({ ok: true });+ const text = recorder.events.filter((event) => event.type === "content.delta").map((event) => event.delta).join("");+ expect(text).toContain("agents:");+ expect(text).toContain("trigger");+ expect(text).toContain("trigger_info");+ expect(text).toContain("browser: agent_browser_open");+ } finally { await browser.close(); }+ });++ it("isolates native MCP configuration by thread and refreshes scoped tools and credentials on resume", async () => {+ const launches = join(scratch, "launches.txt");+ const { instance, recorder } = await create({ FAKE_ACP_MODE: "mcp-tools", FAKE_ACP_LAUNCH_COUNT_FILE: launches });+ const agents = (token: string) => ({ agents: { command: process.execPath, args: [SPAWNED_PROXIES.agents],+ env: { OMB_HARNESS_URL: "http://127.0.0.1:1", OMB_COMMS_TOKEN: token, OMB_BOT_ID: "fixture" } } });+ const run = async (threadId: string, token: string, allow: string[], resumeCursor?: string) => {+ const { turnId } = await instance.adapter.sendTurn({+ threadId, text: "List tools", model: "auto", resumeCursor, integrations: agents(token), toolScope: { allow },+ });+ expect(await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId)).toMatchObject({ ok: true });+ const launch = JSON.parse(readFileSync(join(scratch, "launch.json"), "utf8"));+ const path = launch.argv[launch.argv.indexOf("--additional-mcp-config") + 1].slice(1) as string;+ const text = recorder.events.filter((event) => event.type === "content.delta").filter((event) => event.turnId === turnId)+ .map((event) => event.delta).join("");+ expect(JSON.stringify(launch.argv)).not.toContain(token);+ return { path, text, settings: JSON.parse(readFileSync(path, "utf8")) };+ };+ const first = await run("scoped-one", "first-token", ["native:*", "mcp:agents:list_bots"]);+ expect(first.text).toBe("agents: list_bots");+ expect(JSON.stringify(first.settings)).toContain("first-token");+ if (process.platform !== "win32") expect(statSync(first.path).mode & 0o777).toBe(0o600);+ const second = await run("scoped-two", "second-token", ["native:*", "mcp:agents:trigger_info"]);+ expect(second.text).toBe("agents: trigger_info");+ expect(second.path).not.toBe(first.path);+ expect(readFileSync(first.path, "utf8")).toContain("first-token");+ const resumed = await run("scoped-one", "refreshed-token", ["native:*", "mcp:agents:trigger_info"], "fake-acp-session");+ expect(resumed.path).toBe(first.path);+ expect(resumed.text).toBe("agents: trigger_info");+ expect(JSON.stringify(resumed.settings)).toContain("refreshed-token");+ expect(JSON.stringify(resumed.settings)).not.toContain("first-token");+ const before = Number(readFileSync(launches, "utf8"));+ const revoked = await run("scoped-one", "new-token", ["native:*"], "fake-acp-session");+ expect(revoked.path).toBe(first.path);+ expect(revoked.settings).toEqual({ mcpServers: {} });+ expect(revoked.text).toBe("No MCP servers configured.");+ expect(Number(readFileSync(launches, "utf8"))).toBe(before + 1);+ expect(JSON.parse(readFileSync(join(scratch, "launch.json.mcp.json"), "utf8"))).toEqual([]);+ await instance.dispose();+ expect(existsSync(first.path)).toBe(false);+ expect(existsSync(second.path)).toBe(false);+ });++ it("does not reuse a conversation's native MCP servers for memory upkeep", async () => {+ const { instance, recorder } = await create({ FAKE_ACP_TEXT_REPLY: "memory fixture" });+ const { turnId } = await instance.adapter.sendTurn({+ threadId: "copilot-memory", text: "hello",+ integrations: { agents: { command: "must-not-run", args: [], env: { TOKEN: "conversation-token" } } },+ });+ await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);+ expect(await instance.generateMemoryText!("summarize the fixture")).toBe("memory fixture");+ const launch = JSON.parse(readFileSync(join(scratch, "launch.json"), "utf8"));+ const path = launch.argv[launch.argv.indexOf("--additional-mcp-config") + 1].slice(1) as string;+ expect(JSON.parse(readFileSync(path, "utf8"))).toEqual({ mcpServers: {} });+ });+it("runs Auto when the session leaves the model currentValue unset, then still confirms an explicit model", async () => {const { instance, recorder } = await create({ FAKE_ACP_OMIT_MODEL_VALUE: "auto" });for (const model of ["auto", "claude-haiku-4.5"]) {diff --git a/server/drivers/acp/copilot.ts b/server/drivers/acp/copilot.tsindex cec3dd1018..23ec6e4795 100644--- a/server/drivers/acp/copilot.ts+++ b/server/drivers/acp/copilot.ts@@ -5,14 +5,15 @@// Auto (the stored id stays `auto`; the picker may show Copilot Fusion and an autoTier instead). Its own// `allow_all` option stays at its `off` default: the ACP broker answers every permission request.import { createHash } from "node:crypto";-import { readFile, realpath, rm } from "node:fs/promises";-import { homedir } from "node:os";+import { mkdtemp, readFile, realpath, rm } from "node:fs/promises";+import { homedir, tmpdir } from "node:os";import { join, resolve } from "node:path";import type { ModelCatalog, ProviderErrorCode } from "../../contracts.ts";import { createAcpDriver, type AccountErrorCode, type AcpConfig, type AcpSupport } from "./core.ts";import { AcpDiscoveryRpcError, discoverAcpModels, DISCOVERY_CLIENT_NAME, type AcpDiscoveryOptions } from "./custom-model-catalog.ts";import { offeredModels } from "./config-options.ts";+import { writeFileAtomicIfChanged } from "../../atomic.ts";const AUTO = "auto";const MODELS: ModelCatalog = { default: AUTO, options: [{ id: AUTO, label: "Auto" }] };@@ -215,6 +216,7 @@ const SUPPORT: AcpSupport = {return offered.includes(AUTO) ? AUTO : null;},restartOnMcpChange: true,+ mcpServersFromLaunch: true,pickAuthMethod: () => null,authFailure: "continue",isAuthenticated: (env, config) => copilotSignedIn(env, config),@@ -223,4 +225,39 @@ const SUPPORT: AcpSupport = {buildPromptText: (turn) => (turn.system ? `${turn.system}\n\n${turn.text}` : turn.text),};-export const CopilotAgentDriver = createAcpDriver(SUPPORT);+export const CopilotAgentDriver = {+ ...createAcpDriver(SUPPORT),+ async create(input: Parameters<ReturnType<typeof createAcpDriver>["create"]>[0]) {+ // Copilot CLI 1.0.105 rejects stdio servers from ACP clients; --additional-mcp-config accepts them from its launcher.+ const directory = await mkdtemp(join(tmpdir(), "omb-copilot-mcp-"));+ const cleanup = () => rm(directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });+ try {+ const instance = await createAcpDriver({+ ...SUPPORT,+ applyTurnEnv(env, { threadId, mcpServers }) {+ const path = join(directory, `${createHash("sha256").update(threadId).digest("hex")}.json`);+ const servers = Object.fromEntries(mcpServers.map((server) => [server.name, "command" in server+ ? { type: "local", command: server.command, args: server.args,+ env: Object.fromEntries(server.env.map(({ name, value }) => [name, value])), tools: ["*"] }+ : { type: server.type, url: server.url,+ headers: Object.fromEntries(server.headers.map(({ name, value }) => [name, value])), tools: ["*"] }]));+ writeFileAtomicIfChanged(path, JSON.stringify({ mcpServers: servers }), { mode: 0o600, durable: false });+ env.OMB_COPILOT_MCP_CONFIG = path;+ },+ resolveCommand(env, config) {+ const path = env.OMB_COPILOT_MCP_CONFIG;+ if (!path) throw new Error("GitHub Copilot's tool configuration was not prepared.");+ return Promise.resolve({ command: config.cli, args: ["--additional-mcp-config", `@${path}`] });+ },+ }).create(input);+ const dispose = instance.dispose;+ instance.dispose = async () => {+ try { await dispose(); } finally { await cleanup(); }+ };+ return instance;+ } catch (error) {+ await cleanup();+ throw error;+ }+ },+};diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.tsindex 01e581695a..2909e26f91 100644--- a/server/drivers/acp/core.ts+++ b/server/drivers/acp/core.ts@@ -170,6 +170,8 @@ export interface AcpSupport {resumeMethod?: "load" | "resume";/** Some agents acknowledge a live load without applying new MCP credentials. */restartOnMcpChange?: boolean;+ /** The turn's MCP servers are supplied through launcher-owned configuration instead of ACP session parameters. */+ mcpServersFromLaunch?: boolean;/** hermes-agent 0.22.4 re-sends a streamed reply whole under its messageId, as its `💭` reasoning block, a blank line,* then the reply; that chunk is dropped instead of appended. */resendsReasoningReply?: boolean;@@ -1054,6 +1056,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>const toolLimitKey = JSON.stringify([instanceId, resolvedModel ?? null]);const mcpServers = acpMcpServers(turn, { http: support.ownMcpOverHttp === true, engine: support.driverKind,toolBudget: mcpToolBudget(learnedToolCountLimit(toolLimitKey), support.engineTools ?? 32) });+ const clientMcpServers = support.mcpServersFromLaunch ? [] : mcpServers;support.applyTurnEnv?.(env, {model: resolvedModel, requestedModel: turn.model, fullAuto: turnConfig.fullAuto === true, botId: turn.botId, cwd, toolScope: turn.toolScope,threadId, mcpServers,@@ -1282,7 +1285,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>try {await request(support.resumeMethod === "resume" ? "session/resume" : "session/load",- { sessionId: cursor, cwd, mcpServers, ...selectionParams },+ { sessionId: cursor, cwd, mcpServers: clientMcpServers, ...selectionParams },LOAD_SESSION_TIMEOUT,(result) => {if (result) {@@ -1325,7 +1328,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>promptTurn = { ...turn, text: recovery.text };rebuiltFromReplay = recovery.replayed;}- await request("session/new", { cwd, mcpServers, ...selectionParams }, NEW_SESSION_TIMEOUT, (result) => {+ await request("session/new", { cwd, mcpServers: clientMcpServers, ...selectionParams }, NEW_SESSION_TIMEOUT, (result) => {session.sessionId = typeof result?.sessionId === "string" ? result.sessionId : null;session.sessionKey = sessionKey;receiveModelVariants(result, true);diff --git a/server/testing/fake-acp-cli.ts b/server/testing/fake-acp-cli.tsindex 01e0c68d57..434b524266 100755--- a/server/testing/fake-acp-cli.ts+++ b/server/testing/fake-acp-cli.ts@@ -406,6 +406,23 @@ type McpEntry = { command: string; args?: string[]; env?: Array<{ name: string;let agentsMcp: McpEntry | null = null;type AnyMcpEntry = { name: string; command?: string; args?: string[]; env?: Array<{ name: string; value: string }>; url?: string; headers?: Array<{ name: string; value: string }> };let sessionMcp: AnyMcpEntry[] = [];+const additionalMcp = argv.indexOf("--additional-mcp-config");+const launchMcp: AnyMcpEntry[] = additionalMcp < 0 ? [] : Object.entries(+ JSON.parse(readFileSync(argv[additionalMcp + 1].slice(1), "utf8")).mcpServers,+).map(([name, value]) => {+ const server = value as { command: string; args: string[]; env: Record<string, string> };+ return { name, command: server.command, args: server.args,+ env: Object.entries(server.env).map(([name, value]) => ({ name, value })) };+});+const acceptedMcp = (servers: AnyMcpEntry[]) => [+ ...launchMcp,+ // Copilot CLI 1.0.105 rejects client-supplied stdio servers, but accepts launcher-owned MCP configuration.+ ...servers.filter((server) => process.env.FAKE_ACP_REJECT_STDIO_MCP !== "1" || !server.command),+];+function offeredAgents(servers: AnyMcpEntry[]): McpEntry | null {+ const server = acceptedMcp(servers).find((server) => server.name === "agents");+ return server?.command ? { command: server.command, args: server.args, env: server.env } : null;+}/** grok 1.0.25's initialize (`grok mcp doctor`) */const GROK_MCP_HANDSHAKE = { protocolVersion: "2025-11-25", capabilities: { extensions: { "io.modelcontextprotocol/ui": { mimeTypes: ["text/html;profile=mcp-app"] } } }, clientInfo: { name: "grok-shell", version: "1.0.25" } };@@ -690,15 +707,15 @@ function handle(msg: any) {});break;}- const servers: McpEntry[] = Array.isArray(msg.params?.mcpServers) ? msg.params.mcpServers : [];+ const servers: AnyMcpEntry[] = Array.isArray(msg.params?.mcpServers) ? msg.params.mcpServers : [];if (process.env.FAKE_ACP_DUMP) {writeFileSync(`${process.env.FAKE_ACP_DUMP}.session.json`, JSON.stringify(msg.params));dumpState.mcpServers = servers;writeDumpAtomic(process.env.FAKE_ACP_DUMP, JSON.stringify(dumpState, null, 2));}- const offered = servers.find((s: any) => s?.name === "agents") ?? null;+ const offered = offeredAgents(servers);agentsMcp = mode === "list-peers" ? agentsMcp ?? offered : offered;- sessionMcp = servers as AnyMcpEntry[];+ sessionMcp = acceptedMcp(servers);if (process.env.FAKE_ACP_DUMP) {writeFileSync(`${process.env.FAKE_ACP_DUMP}.mcp.json`, JSON.stringify(servers, null, 2));}@@ -737,15 +754,15 @@ function handle(msg: any) {}const cachedLiveLoad = process.env.FAKE_ACP_CACHED_LIVE_LOAD === "1" && liveSession === msg.params?.sessionId;if ((mode === "safe-agent-reads" || mode === "chief-delegate" || mode === "create-peer") && !cachedLiveLoad) {- agentsMcp = (msg.params?.mcpServers ?? []).find((server: any) => server.name === "agents") ?? null;+ agentsMcp = offeredAgents(msg.params?.mcpServers ?? []);}if (mode === "list-peers") {- agentsMcp ??= (msg.params?.mcpServers ?? []).find((server: any) => server.name === "agents") ?? null;+ agentsMcp ??= offeredAgents(msg.params?.mcpServers ?? []);}if (process.env.FAKE_ACP_DUMP) {writeFileSync(`${process.env.FAKE_ACP_DUMP}.mcp.json`, JSON.stringify(msg.params?.mcpServers ?? []));}- if (!cachedLiveLoad) sessionMcp = msg.params?.mcpServers ?? [];+ if (!cachedLiveLoad) sessionMcp = acceptedMcp(msg.params?.mcpServers ?? []);const opts = configOptions();const mdls = sessionModels();liveSession = typeof msg.params?.sessionId === "string" ? msg.params.sessionId : liveSession;@@ -1141,11 +1158,27 @@ function handle(msg: any) {(tools) => `${entry.name}: ${tools.join(",")}`,(error: Error) => `${entry.name} failed: ${error.message}`,))).then((lines) => {- out({ jsonrpc: "2.0", method: "session/update", params: { update: { sessionUpdate: "agent_message_chunk", content: { text: lines.join("\n") } } } });+ out({ jsonrpc: "2.0", method: "session/update", params: { update: { sessionUpdate: "agent_message_chunk", content: { text: lines.join("\n") || "No MCP servers configured." } } } });complete();});return;}+ if (mode === "mcp-calls") {+ const calls = JSON.parse(readFileSync(process.env.FAKE_ACP_MCP_CALLS_FILE!, "utf8")) as Array<{ server: string; name: string; arguments: Record<string, unknown> }>;+ void (async () => {+ for (const call of calls) {+ const server = sessionMcp.find((entry) => entry.name === call.server);+ if (!server?.command) throw new Error(`Fixture MCP server unavailable: ${call.server}`);+ const text = await driveMcp({ command: server.command, args: server.args, env: server.env },+ [{ name: call.name, args: () => call.arguments }], true);+ out({ jsonrpc: "2.0", method: "session/update", params: { update: {+ sessionUpdate: "agent_message_chunk", content: { text: `${call.name}: ${text}\n` },+ } } });+ }+ complete();+ })().catch((error) => out({ jsonrpc: "2.0", id: msg.id, error: { code: -32000, message: String(error) } }));+ return;+ }if (mode === "ask-peer" && agentsMcp) {void driveMcp(agentsMcp, [{ name: "list_bots", args: () => ({}) },