Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Train fix (#8032): the unlinked Codex home fallback is logged, not said in the chat
milind-soni19250eabb9f2
diff --git a/server/drivers/codex-shared-home.test.ts b/server/drivers/codex-shared-home.test.tsindex 3af0c622f6..100df16275 100644--- a/server/drivers/codex-shared-home.test.ts+++ b/server/drivers/codex-shared-home.test.ts@@ -19,7 +19,7 @@ vi.mock("node:fs", async (importOriginal) => {};});-import { codexHomeFallbackNotice, keepChatsOutOfCodexHistory, linkSharedCodexHome } from "./codex-shared-home.ts";+import { keepChatsOutOfCodexHistory, linkSharedCodexHome } from "./codex-shared-home.ts";let root: string;let shared: string;@@ -321,7 +321,7 @@ describe("keepChatsOutOfCodexHistory", () => {const env: Record<string, string | undefined> = { HOME: join(root, "person") };const placement = keepChatsOutOfCodexHistory(env, "codex", data());- // The turn still runs, in the person's own home: its chats reach their Codex history, so the caller is told.+ // The turn still runs, in the person's own home: its chats reach their Codex history, and the log says so.expect(placement).toBe("unlinked");expect(env.CODEX_HOME).toBeUndefined();expect(env.CODEX_SQLITE_HOME).toBeUndefined();@@ -330,7 +330,6 @@ describe("keepChatsOutOfCodexHistory", () => {expect(existsSync(join(home, "auth.json"))).toBe(false);expect(existsSync(join(home, "config.toml"))).toBe(false);expect(vi.mocked(console.error).mock.calls.map((call) => String(call[0])).join(" ")).toContain('could not link "auth.json"');- expect(codexHomeFallbackNotice()).toContain("Developer Mode");});it("keeps the person's home, and the turn going, when MausBot's Codex home cannot be made", () => {diff --git a/server/drivers/codex-shared-home.ts b/server/drivers/codex-shared-home.tsindex adbec25259..a859dc5fa8 100644--- a/server/drivers/codex-shared-home.ts+++ b/server/drivers/codex-shared-home.ts@@ -167,9 +167,3 @@ export function keepChatsOutOfCodexHistory(env: Record<string, string | undefineenv.CODEX_SQLITE_HOME = home;return "isolated";}--/** What a turn says when its chats cannot be kept out of the person's own Codex history. */-export function codexHomeFallbackNotice(): string {- return `MausBot could not make a Codex home of its own that uses your sign-in, so this chat runs in your own Codex home and appears in your Codex history.${- process.platform === "win32" ? " On Windows, turn on Developer Mode so MausBot can link your sign-in into its own home." : ""}`;-}diff --git a/server/drivers/codex.test.ts b/server/drivers/codex.test.tsindex d895669c91..8576684f4a 100644--- a/server/drivers/codex.test.ts+++ b/server/drivers/codex.test.ts@@ -31,7 +31,6 @@ import { removeTempDir } from "../testing/cleanup.ts";import { TEAM_TOOLS_FAILED } from "./team-tools.ts";import { unsupportedCallsNotice } from "./codex-unsupported-calls.ts";import { busySessionNotice, instructionsOverflowNotice, rebuiltSessionNotice } from "../resume-recovery.ts";-import { codexHomeFallbackNotice } from "./codex-shared-home.ts";import { startFakeHttpMcp, type FakeHttpMcp } from "../testing/fake-http-mcp-server.ts";import { OWN_MCP_HTTP_ENV } from "./own-mcp-http.ts";import { ownMcpHttpRoutes } from "../routes/own-mcp-http.ts";@@ -1377,7 +1376,7 @@ process.stdout.write(JSON.stringify({jsonrpc:'2.0',id:m.id,result})+'\\n');});`)return personHome;};- it("keeps a turn going in the person's own Codex home when its login cannot be shared, and says so once", async () => {+ it("keeps a turn going in the person's own Codex home when its login cannot be shared, with no notice in the chat", async () => {const instanceId = "codex-test-person-home";const personHome = unlinkedHome(instanceId);const dump = join(scratch, "unlinked-home.json");@@ -1392,7 +1391,7 @@ process.stdout.write(JSON.stringify({jsonrpc:'2.0',id:m.id,result})+'\\n');});`)const second = await instance.adapter.sendTurn({ threadId: "t-unlinked-home", text: "again" });await recorder.until((e) => e.type === "turn.completed" && e.turnId === second.turnId);- expect(recorder.events.filter((e) => e.type === "runtime.notice" && e.message === codexHomeFallbackNotice())).toHaveLength(1);+ expect(recorder.events.filter((e) => e.type === "runtime.notice" && /Codex home/.test((e as { message: string }).message))).toHaveLength(0);});it("rebuilds the conversation from the chat when another Codex app holds its thread, instead of the writer-lock error", async () => {diff --git a/server/drivers/codex.ts b/server/drivers/codex.tsindex ffb727ea1b..2346b060f9 100644--- a/server/drivers/codex.ts+++ b/server/drivers/codex.ts@@ -53,7 +53,7 @@ import { volatileContextNote, withContextNote } from "./prompt-split.ts";import type { ApprovalMode } from "../../shared/approval-mode.ts";import { CodexDeviceAuthController } from "./codex-device-auth.ts"; import { messageItem } from "../harness/text-items.ts";import { codexAccountEmail, codexHome } from "./codex-identity.ts";-import { codexHomeFallbackNotice, keepChatsOutOfCodexHistory, linkSharedCodexHome } from "./codex-shared-home.ts";+import { keepChatsOutOfCodexHistory, linkSharedCodexHome } from "./codex-shared-home.ts";import { mcpAppApprovalForm, mcpAppApprovalText, mcpElicitationDeclined, plainRecord } from "./codex-app-approval.ts";import { archivedNativeCodexThread, CODEX_MISSING_CREDENTIALS, CODEX_SIGN_IN_EXPIRED, CodexRpcError, codexLimitFacts, codexNotSignedIn, codexPlanModelRefused, codexPlanUnsupportedInput, codexResumeRebuild, codexSignInExpired, codexSignInRefused, codexUserError, codexUserFailure, type CodexRoute } from "./codex-errors.ts";import { codexTierOf } from "./codex-tier.ts"; import { codexLoginCheck, keptCodexLogin, readCodexLogin, storedCodexLogin } from "./codex-login.ts";@@ -331,7 +331,6 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {}const active = new Map<string, Turn>();const warm = codexWarmSessions<{ initialized: any; approvalParams: CodexApprovalParams; rolloutPath: unknown }>(instanceId);- let homeFallbackNoticed = false;const emit = (event: RuntimeEvent) => {for (const l of Array.from(listeners)) l(event);@@ -433,8 +432,7 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {};const launchAttempt = async (attempt: number): Promise<void> => {const env = childEnv();- const launchedLogin = chatgptTurn ? storedCodexLogin(env) : null;- const placement = ownLogin ? keepChatsOutOfCodexHistory(env, instanceId) : "isolated";+ const launchedLogin = chatgptTurn ? storedCodexLogin(env) : null; if (ownLogin) keepChatsOutOfCodexHistory(env, instanceId);if (authBridge) Object.assign(env, authBridge.env); else if (planToken) env.OPENMAUSBOT_CHATGPT_TOKEN = planToken;const appServerArgs = ["app-server", ...(plan ? chatgptPlanCodexArgs(!!authBridge) : config.endpoint ? endpointCodexArgs(config.endpoint) : config.managed ? managedCodexArgs(config.managed) : codexSelectedProviderArgs(env, turn.model)), ...codexToolSurfaceArgs(),// Native shell snapshots can restore variables the shell policy removed.@@ -1170,7 +1168,6 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {active.set(threadId, { stop, turnId, asks, steer: steerActiveTurn, pid: child.pid });if (attempt === 0 && !announced) emit({ ...base(threadId, turnId), type: "turn.started" });- if (placement === "unlinked" && !homeFallbackNoticed) { homeFallbackNoticed = true; emit({ ...base(threadId, turnId), type: "runtime.notice", message: codexHomeFallbackNotice() }); }try {const initialized = reused ? reused.carried.initialized : await request("initialize", {