Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix: keep the test suite off the developer's macOS keychain
JoaoPec12829befa2f3
diff --git a/server/drivers/acp/mistral-vibe.test.ts b/server/drivers/acp/mistral-vibe.test.tsindex 32fa8c3616..8350fb4203 100644--- a/server/drivers/acp/mistral-vibe.test.ts+++ b/server/drivers/acp/mistral-vibe.test.ts@@ -9,7 +9,7 @@ import type { ProviderInstance } from "../../contracts.ts";import { removeTempDir } from "../../testing/cleanup.ts";import { recordEvents, type EventRecorder } from "../../testing/events.ts";import { BUILT_IN_DRIVERS } from "../builtIn.ts";-import { MistralVibeAgentDriver, removeMistralVibeSignIn, resolveMistralVibeModels, vibeSignedIn } from "./mistral-vibe.ts";+import { keychain, MistralVibeAgentDriver, removeMistralVibeSignIn, resolveMistralVibeModels, vibeSignedIn } from "./mistral-vibe.ts";const FAKE_CLI = join(dirname(fileURLToPath(import.meta.url)), "../../testing/fake-acp-cli.ts");const MODELS = "mistral-medium-3.5,zai-glm-5-3-flash,Mistral Large,Codestral";@@ -134,6 +134,16 @@ describe("Mistral (Vibe) ACP driver", () => {});describe("sign-out cleanup of Vibe's fallback .env", () => {+ const originalDelete = keychain.delete;+ let deletedServices: string[];++ beforeEach(() => {+ // a developer's real `vibe` / `vibe-acp` login items stay put while the filesystem cleanup stays real+ deletedServices = [];+ keychain.delete = (service: string) => { deletedServices.push(service); return Promise.resolve(); };+ });++ afterEach(() => { keychain.delete = originalDelete; });it("strips bare and exported MISTRAL_API_KEY lines and keeps unrelated ones", async () => {const home = join(scratch, "vibe-home");mkdirSync(home, { recursive: true });@@ -141,6 +151,9 @@ describe("Mistral (Vibe) ACP driver", () => {writeFileSync(envFile, ["ONE=1", "MISTRAL_API_KEY='fixture'", 'export MISTRAL_API_KEY="second"', "TWO=2"].join("\n"));await removeMistralVibeSignIn({ VIBE_HOME: home });expect(readFileSync(envFile, "utf8")).toBe(["ONE=1", "TWO=2"].join("\n"));+ expect(deletedServices.sort()).toEqual(+ process.platform === "darwin" ? ["ai.mistral.vibe", "vibe"] : [],+ );});it("resolves without a .env and rejects when one cannot be rewritten", async () => {diff --git a/server/drivers/acp/mistral-vibe.ts b/server/drivers/acp/mistral-vibe.tsindex 0533d682f2..0c75408604 100644--- a/server/drivers/acp/mistral-vibe.ts+++ b/server/drivers/acp/mistral-vibe.ts@@ -91,6 +91,19 @@ function offeredModels(sessionConfig: unknown): { values: string[]; current?: st* see vibe's utils/keyring.py). A keyring entry the CLI stored through its own backends on Linux or* Windows has no portable command-line delete, so the marker files here are what this app can honestly* clear there. A pasted plan key in Connections is not touched. */+/** One level of indirection over `security delete-generic-password` so tests keep a developer's real+ * login items out of the way while the filesystem cleanup stays real. */+export const keychain = {+ delete: (service: string): Promise<void> =>+ new Promise<void>((resolve, reject) => {+ execFile("security", ["delete-generic-password", "-s", service], { timeout: 5_000, windowsHide: true }, (error) => {+ // "The specified item could not be found" is exit 44: already gone, which is the goal met.+ if (!error || (error as { code?: string | number }).code === 44) return resolve();+ reject(Object.assign(new Error(`The macOS keychain refused to remove the ${service} entry: ${error.message}`), { cause: error }));+ });+ }),+};+export async function removeMistralVibeSignIn(env: Record<string, string | undefined>): Promise<void> {const home = vibeHome(env);try { rmSync(join(home, "whoami_cache.json"), { force: true }); } catch {}@@ -102,13 +115,7 @@ export async function removeMistralVibeSignIn(env: Record<string, string | undef}if (process.platform !== "darwin") return;const service = env.VIBE_KEYCHAIN_SERVICE || MISTRAL_VIBE_KEYCHAIN_SERVICE;- await Promise.all([service, "vibe"].map((name) => new Promise<void>((resolve, reject) => {- execFile("security", ["delete-generic-password", "-s", name], { timeout: 5_000, windowsHide: true }, (error) => {- // "The specified item could not be found" is exit 44: already gone, which is the goal met.- if (!error || (error as { code?: string | number }).code === 44) return resolve();- reject(Object.assign(new Error(`The macOS keychain refused to remove the ${name} entry: ${error.message}`), { cause: error }));- });- })));+ await Promise.all([service, "vibe"].map((name) => keychain.delete(name)));}