Skip to content

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

Setup wizard: connect Kimi, Gemini and DeepSeek

David6d103270c28d
diff --git a/server/cli-setup.test.ts b/server/cli-setup.test.ts
index d003e3f35a..47cfcbba51 100644
--- a/server/cli-setup.test.ts
+++ b/server/cli-setup.test.ts
@@ -128,7 +128,7 @@ describe("native provider onboarding", () => {
persist({ instances: { workClaude: original } });
const deps = dependencies();
deps.inspect.mockResolvedValueOnce({ snapshot: { state: "available", authenticated: false }, models });
- const ui = prompts({ choices: [3, 0], confirms: [true] });
+ const ui = prompts({ choices: [6, 0], confirms: [true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(deps.runCli).toHaveBeenCalledWith("/fixture/bin/claude", ["auth", "login"], original.environment);
expect(loadConfig().instances?.workClaude).toEqual({ ...original, enabled: true });
@@ -171,9 +171,9 @@ describe("native provider onboarding", () => {
it("keeps the saved native model selected when setup is run again", async () => {
persist({ instances: { codex: { driver: "codex" } }, defaultModelSelection: { instanceId: "codex", model: "fixture-selected" } });
- const ui = prompts({ choices: [3, 0], confirms: [true] });
+ const ui = prompts({ choices: [6, 0], confirms: [true] });
expect(await runSetup(options, ui.io, dependencies())).toBe(true);
- expect(ui.io.choose.mock.calls[0]?.[2]).toBe(3);
+ expect(ui.io.choose.mock.calls[0]?.[2]).toBe(6);
expect(ui.io.choose.mock.calls[1]?.[2]).toBe(0);
expect(ui.io.choose.mock.calls[1]?.[1][0]).toBe("Fixture selected");
expect(loadConfig().defaultModelSelection).toEqual({ instanceId: "codex", model: "fixture-selected" });
@@ -212,6 +212,62 @@ describe("native provider onboarding", () => {
expectLeaseReleased();
});
+ it("offers Kimi, Gemini and DeepSeek after Codex and Claude, before the API key route", async () => {
+ const ui = prompts({ choices: [0, 0], confirms: [true] });
+ expect(await runSetup(options, ui.io, dependencies())).toBe(true);
+ expect(ui.io.choose.mock.calls[0]?.[1].slice(0, 6)).toEqual([
+ "ChatGPT / Codex — sign in with your account",
+ "Claude Code — sign in with your account",
+ "Kimi Code — sign in with your Kimi account",
+ "Gemini CLI — Gemini API key",
+ "DeepSeek Harness — DeepSeek API key",
+ "API key — OpenAI, OpenRouter, Groq or a compatible service (chat only)",
+ ]);
+ });
+
+ it("installs Kimi on confirmation and runs its device-code login", async () => {
+ const deps = dependencies();
+ deps.inspect
+ .mockResolvedValueOnce({ snapshot: { state: "unavailable", reason: "missing fixture CLI" }, models })
+ .mockResolvedValueOnce({ snapshot: { state: "available", authenticated: false }, models });
+ const ui = prompts({ choices: [2, 0], confirms: [true, true] });
+ expect(await runSetup(options, ui.io, deps)).toBe(true);
+ expect(deps.runCli.mock.calls).toEqual([
+ ["npm", ["install", "-g", "@moonshot-ai/kimi-code"]],
+ ["kimi", ["login"], undefined],
+ ]);
+ expect(loadConfig().instances?.kimi).toEqual({ driver: "kimiAgent", enabled: true });
+ expect(loadConfig().defaultModelSelection).toEqual({ instanceId: "kimi", model: "fixture-default" });
+ ui.assertConsumed();
+ });
+
+ it.each([
+ { choice: 3, id: "gemini", driver: "geminiAgent", env: "GEMINI_API_KEY" },
+ { choice: 4, id: "deepseek", driver: "deepseekAgent", env: "DEEPSEEK_API_KEY" },
+ ])("saves a $id API key on its own instance without starting a login", async ({ choice, id, driver, env }) => {
+ const deps = dependencies();
+ deps.inspect.mockResolvedValueOnce({ snapshot: { state: "available", authenticated: false }, models });
+ const ui = prompts({ choices: [choice, 0], secrets: [" fixture-engine-key "], confirms: [true] });
+ expect(await runSetup(options, ui.io, deps)).toBe(true);
+ expect(deps.runCli).not.toHaveBeenCalled();
+ expect(deps.inspect).toHaveBeenLastCalledWith(id, { driver, enabled: true, environment: { [env]: "fixture-engine-key" } });
+ expect(loadConfig().instances?.[id]).toEqual({ driver, enabled: true, environment: { [env]: "fixture-engine-key" } });
+ expect(loadConfig().defaultModelSelection).toEqual({ instanceId: id, model: "fixture-default" });
+ expect(ui.lines.join("\n")).not.toContain("fixture-engine-key");
+ ui.assertConsumed();
+ });
+
+ it("saves nothing when an engine API key is left empty", async () => {
+ const original = persist({ profile: { name: "Keep" } });
+ const deps = dependencies();
+ deps.inspect.mockResolvedValue({ snapshot: { state: "available", authenticated: false }, models });
+ const ui = prompts({ choices: [4, 2], secrets: [" "] });
+ expect(await runSetup(options, ui.io, deps)).toBe(false);
+ expect(ui.lines.join("\n")).toContain("An API key is required");
+ expect(readFileSync(configPath, "utf8")).toBe(original);
+ expectLeaseReleased();
+ });
+
it("does not overwrite an instance that repurposed a native provider ID", async () => {
const existing = { driver: "customAcp", displayName: "Keep this connection", config: { cli: "/fixture/other" } };
persist({ instances: { codex: existing } });
@@ -266,7 +322,7 @@ describe("API onboarding", () => {
};
persist({ instances: { existing: original } });
const deps = dependencies();
- const ui = prompts({ choices: [3, 0], confirms: [true, true] });
+ const ui = prompts({ choices: [6, 0], confirms: [true, true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(deps.models).toHaveBeenCalledWith("https://api.example.test/v1", expected);
expect(deps.verify).toHaveBeenCalledWith("https://api.example.test/v1", expected, "fixture-default");
@@ -281,7 +337,7 @@ describe("API onboarding", () => {
instances: { routed: { driver: "openai-compat", config: { url: "https://openrouter.ai/api/v1", key: "fixture-key" } } },
});
const deps = dependencies();
- const ui = prompts({ choices: [3, 0], confirms: [true, true] });
+ const ui = prompts({ choices: [6, 0], confirms: [true, true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(deps.verify).toHaveBeenCalledWith("https://openrouter.ai/api/v1", "fixture-key", "fixture-default", "fireworks");
expect(loadConfig().instances?.routed.config).toEqual({ url: "https://openrouter.ai/api/v1", key: "fixture-key", model: "fixture-default" });
@@ -292,7 +348,7 @@ describe("API onboarding", () => {
persist({ openaiCompat: { provider: "workspace-provider" } });
vi.stubEnv("OPENAI_COMPAT_PROVIDER", "environment-provider");
const deps = dependencies();
- const ui = prompts({ choices: [2, 1, 0], secrets: ["fixture-new-key"], confirms: [true, true] });
+ const ui = prompts({ choices: [5, 1, 0], secrets: ["fixture-new-key"], confirms: [true, true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(deps.verify).toHaveBeenCalledWith("https://openrouter.ai/api/v1", "fixture-new-key", "fixture-default");
const saved = loadConfig();
@@ -310,7 +366,7 @@ describe("API onboarding", () => {
};
persist({ instances: { pinned: original } });
const deps = dependencies();
- const ui = prompts({ choices: [3, 0], secrets: ["fixture-new-key"], confirms: [true, true] });
+ const ui = prompts({ choices: [6, 0], secrets: ["fixture-new-key"], confirms: [true, true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(ui.io.secret).toHaveBeenCalledTimes(1);
expect(deps.verify).toHaveBeenCalledWith("https://openrouter.ai/api/v1", "fixture-new-key", "fixture-default", "fireworks");
@@ -338,7 +394,7 @@ describe("API onboarding", () => {
writeFileSync(join(DATA_DIR, "bots.json"), sentinel);
writeFileSync(join(DATA_DIR, "messages-existing-thread.json"), transcript);
const deps = dependencies();
- const ui = prompts({ choices: [2, 0, 1], secrets: [" new-fixture-secret "], confirms: [true, true] });
+ const ui = prompts({ choices: [5, 0, 1], secrets: [" new-fixture-secret "], confirms: [true, true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(deps.models).toHaveBeenCalledWith("https://api.openai.com/v1", "new-fixture-secret");
@@ -367,7 +423,7 @@ describe("API onboarding", () => {
async ({ confirms, verified }) => {
const original = persist({ profile: { name: "Keep" } });
const deps = dependencies();
- const ui = prompts({ choices: [2, 1, 0], secrets: ["fixture-key"], confirms });
+ const ui = prompts({ choices: [5, 1, 0], secrets: ["fixture-key"], confirms });
expect(await runSetup(options, ui.io, deps)).toBe(false);
expect(deps.verify).toHaveBeenCalledTimes(verified ? 1 : 0);
expect(readFileSync(configPath, "utf8")).toBe(original);
@@ -379,7 +435,7 @@ describe("API onboarding", () => {
const original = persist({ profile: { name: "Keep" }, defaultModelSelection: { instanceId: "codex", model: "original" } });
const deps = dependencies();
deps.verify.mockRejectedValue(new Error("API returned HTTP 401. Check the API key."));
- const ui = prompts({ choices: [2, 2, 0, 2], secrets: ["fixture-key"], confirms: [true] });
+ const ui = prompts({ choices: [5, 2, 0, 2], secrets: ["fixture-key"], confirms: [true] });
expect(await runSetup(options, ui.io, deps)).toBe(false);
expect(ui.lines.join("\n")).toContain("HTTP 401");
expect(readFileSync(configPath, "utf8")).toBe(original);
@@ -388,7 +444,7 @@ describe("API onboarding", () => {
it("cancels hidden key entry without saving or contacting the provider", async () => {
const deps = dependencies();
- const ui = prompts({ choices: [2, 0], secrets: [new SetupCancelled()] });
+ const ui = prompts({ choices: [5, 0], secrets: [new SetupCancelled()] });
expect(await runSetup(options, ui.io, deps)).toBe(false);
expect(deps.models).not.toHaveBeenCalled();
expect(deps.verify).not.toHaveBeenCalled();
@@ -399,7 +455,7 @@ describe("API onboarding", () => {
it("allows an exact model ID after a catalog failure and verifies it before saving", async () => {
const deps = dependencies();
deps.models.mockRejectedValue(new Error("The catalog is unavailable"));
- const ui = prompts({ choices: [2, 0, 0], secrets: ["fixture-key"], answers: [" manual-chat-model "], confirms: [true, true, true] });
+ const ui = prompts({ choices: [5, 0, 0], secrets: ["fixture-key"], answers: [" manual-chat-model "], confirms: [true, true, true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(deps.verify).toHaveBeenCalledWith("https://api.openai.com/v1", "fixture-key", "manual-chat-model");
expect(loadConfig().defaultModelSelection?.model).toBe("manual-chat-model");
@@ -409,7 +465,7 @@ describe("API onboarding", () => {
it("keeps custom API setup after the built-in endpoints", async () => {
const deps = dependencies();
const ui = prompts({
- choices: [2, 4, 0], answers: ["https://custom.example.test/v1"],
+ choices: [5, 4, 0], answers: ["https://custom.example.test/v1"],
secrets: ["fixture-custom-key"], confirms: [true, true],
});
expect(await runSetup(options, ui.io, deps)).toBe(true);
@@ -426,16 +482,14 @@ describe("API onboarding", () => {
it("reuses an API connection without changing its endpoint or key and preselects the saved model", async () => {
const deps = dependencies();
- const first = prompts({ choices: [2, 0, 1], secrets: ["fixture-first-key"], confirms: [true, true] });
+ const first = prompts({ choices: [5, 0, 1], secrets: ["fixture-first-key"], confirms: [true, true] });
expect(await runSetup(options, first.io, deps)).toBe(true);
const before = loadConfig();
const priorId = before.defaultModelSelection!.instanceId;
const prior = before.instances![priorId]!;
- // The explicit saved fleet has Codex, Claude, OpenAI-compatible, then
- // this newly added API connection in the existing-connections list.
const existingIds = Object.entries(before.instances!).filter(([, entry]) =>
- ["codex", "claudeAgent", "openai-compat"].includes(entry.driver) && entry.enabled !== false).map(([id]) => id);
- const chosen = existingIds.indexOf(priorId) + 3;
+ ["codex", "claudeAgent", "kimiAgent", "geminiAgent", "deepseekAgent", "openai-compat"].includes(entry.driver) && entry.enabled !== false).map(([id]) => id);
+ const chosen = existingIds.indexOf(priorId) + 6;
const second = prompts({ choices: [chosen, 1], confirms: [true, true] });
expect(await runSetup(options, second.io, deps)).toBe(true);
expect(second.io.choose.mock.calls[0]?.[2]).toBe(chosen);
@@ -455,7 +509,7 @@ describe("API onboarding", () => {
const deps = dependencies();
const catalog = Array.from({ length: 25 }, (_, index) => ({ id: `fixture-model-${index}`, label: `Model ${index}` }));
deps.models.mockResolvedValue(catalog);
- const ui = prompts({ choices: [2, 0, 20, 0], secrets: ["fixture-key"], answers: ["fixture-model-24"], confirms: [true, true] });
+ const ui = prompts({ choices: [5, 0, 20, 0], secrets: ["fixture-key"], answers: ["fixture-model-24"], confirms: [true, true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(deps.verify).toHaveBeenCalledWith("https://api.openai.com/v1", "fixture-key", "fixture-model-24");
expect(loadConfig().defaultModelSelection?.model).toBe("fixture-model-24");
@@ -472,7 +526,7 @@ describe("API onboarding", () => {
deps.models.mockResolvedValue(Array.from({ length: 25 }, (_, index) => ({ id: `fixture-model-${index}`, label: `Model ${index}` })));
const ui = prompts({ confirms: [true, true] });
ui.io.choose.mockImplementation(async (question, available, defaultIndex) => {
- if (question === "Choose your AI connection") return 3;
+ if (question === "Choose your AI connection") return 6;
expect(defaultIndex).toBeDefined();
expect(available[defaultIndex!]).toBe("Model 24");
return defaultIndex!;
@@ -492,7 +546,7 @@ describe("API onboarding", () => {
defaultModelSelection: { instanceId: "primary", model: "fixture-selected" },
});
const deps = dependencies();
- const ui = prompts({ choices: [4, 0], confirms: [true, true] });
+ const ui = prompts({ choices: [7, 0], confirms: [true, true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(ui.io.choose.mock.calls[1]?.[2]).toBe(0);
expect(deps.verify).toHaveBeenCalledWith("https://secondary.example.test/v1", "secondary-key", "fixture-default");
@@ -566,7 +620,7 @@ describe("connection recovery", () => {
throw new Error("API returned HTTP 401. Check the API key.");
});
const ui = prompts({
- choices: [2, 2, 0, 0, 2, 0],
+ choices: [5, 2, 0, 0, 2, 0],
secrets: ["fixture-wrong-key", "fixture-replacement-key"], confirms: [true, true, true],
});
expect(await runSetup(options, ui.io, deps)).toBe(true);
@@ -588,7 +642,7 @@ describe("connection recovery", () => {
it("can leave a failing API route for a native account without saving the key", async () => {
const deps = dependencies();
deps.verify.mockRejectedValue(new Error("API returned HTTP 429. Check limits."));
- const ui = prompts({ choices: [2, 0, 0, 1, 1, 0], secrets: ["fixture-unused-key"], confirms: [true, true] });
+ const ui = prompts({ choices: [5, 0, 0, 1, 1, 0], secrets: ["fixture-unused-key"], confirms: [true, true] });
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(loadConfig().defaultModelSelection).toEqual({ instanceId: "claude", model: "fixture-default" });
expect(readFileSync(configPath, "utf8")).not.toContain("fixture-unused-key");
@@ -601,7 +655,7 @@ describe("connection recovery", () => {
const deps = dependencies();
deps.models.mockRejectedValueOnce(new Error("The model list timed out."));
const ui = prompts({
- choices: [2, 0, 0, 0, 0], secrets: ["fixture-key", "fixture-key"], confirms: [false, true, true],
+ choices: [5, 0, 0, 0, 0], secrets: ["fixture-key", "fixture-key"], confirms: [false, true, true],
});
expect(await runSetup(options, ui.io, deps)).toBe(true);
expect(deps.models).toHaveBeenCalledTimes(2);
diff --git a/server/cli-setup.ts b/server/cli-setup.ts
index 66bd8cb5c3..dbfeccc5c1 100644
--- a/server/cli-setup.ts
+++ b/server/cli-setup.ts
@@ -121,17 +121,47 @@ async function chooseModel(io: SetupIo, models: ModelCatalog): Promise<string> {
}
}
-const NATIVE = [
- { id: "codex", driver: "codex", label: "ChatGPT / Codex — sign in with your account", cli: "codex", pkg: "@openai/codex" },
- { id: "claude", driver: "claudeAgent", label: "Claude Code — sign in with your account", cli: "claude", pkg: "@anthropic-ai/claude-code" },
-] as const;
+interface NativeChoice {
+ id: string;
+ driver: string;
+ label: string;
+ cli: string;
+ pkg: string;
+ login?: readonly string[];
+ key?: { env: string; url: string };
+ note?: string;
+}
+
+const NATIVE: readonly NativeChoice[] = [
+ { id: "codex", driver: "codex", label: "ChatGPT / Codex — sign in with your account", cli: "codex", pkg: "@openai/codex", login: ["login"] },
+ { id: "claude", driver: "claudeAgent", label: "Claude Code — sign in with your account", cli: "claude", pkg: "@anthropic-ai/claude-code", login: ["auth", "login"] },
+ {
+ id: "kimi", driver: "kimiAgent", label: "Kimi Code — sign in with your Kimi account", cli: "kimi", pkg: "@moonshot-ai/kimi-code",
+ login: ["login"], note: "Kimi shows a code and a link; open the link in any browser and approve the sign-in.",
+ },
+ {
+ id: "gemini", driver: "geminiAgent", label: "Gemini CLI — Gemini API key", cli: "gemini", pkg: "@google/gemini-cli",
+ key: { env: "GEMINI_API_KEY", url: "https://aistudio.google.com/apikey" },
+ // Google stopped serving Gemini CLI to consumer Google sign-ins on 2026-06-18.
+ note: "Gemini CLI no longer accepts personal Google sign-ins; use a Gemini API key. For a Google account, use the Antigravity engine in the app.",
+ },
+ {
+ id: "deepseek", driver: "deepseekAgent", label: "DeepSeek Harness — DeepSeek API key", cli: "dsh", pkg: "@deepseek-ai/dsh",
+ key: { env: "DEEPSEEK_API_KEY", url: "https://platform.deepseek.com/api_keys" },
+ },
+];
+
+const NATIVE_DRIVERS = new Set(NATIVE.map((n) => n.driver));
async function connectNative(
- choice: typeof NATIVE[number], id: string, entry: InstanceConfig, io: SetupIo, deps: SetupDependencies,
+ choice: NativeChoice, id: string, entry: InstanceConfig, io: SetupIo, deps: SetupDependencies,
): Promise<ModelCatalog> {
const cli = typeof rawObject(entry.config).cli === "string" ? rawObject(entry.config).cli as string : choice.cli;
io.log("Connecting your account…");
- io.log("Sign-in stays with your provider. Its account limits apply; OpenMausBot never asks for your password.");
+ io.log(choice.key
+ ? "Your API key goes only to this engine. Usage is billed to your API account."
+ : "Sign-in stays with your provider. Its account limits apply; OpenMausBot never asks for your password.");
+ if (choice.note) io.log(choice.note);
let state = await deps.inspect(id, entry);
if (state.snapshot.state !== "available") {
if (cli !== choice.cli) throw new Error("Your custom CLI path is unavailable. Fix that path in Settings before running setup again.");
@@ -141,15 +171,23 @@ async function connectNative(
if (state.snapshot.state !== "available") throw new Error(`${choice.cli} is still unavailable. Check the installation output and try again.`);
}
if (!state.snapshot.authenticated) {
- let args = ["auth", "login"];
- if (choice.id === "codex") {
- const method = await io.choose("How would you like to sign in?", [
- "Open a browser on this computer", "Use a device code (SSH / remote server)",
- ], process.env.SSH_CONNECTION ? 1 : 0);
- args = method === 1 ? ["login", "--device-auth"] : ["login"];
+ if (choice.key) {
+ io.log(`Create a key: ${choice.key.url}`);
+ const key = (await io.secret(`${choice.key.env} (hidden): `)).trim();
+ if (!key) throw new Error("An API key is required. Nothing was saved.");
+ entry.environment = { ...entry.environment, [choice.key.env]: key };
+ io.log("The key will be stored in your private config.json (plaintext, owner-only permissions on Unix). Never share this file.");
+ } else {
+ let args = [...(choice.login ?? [])];
+ if (choice.id === "codex") {
+ const method = await io.choose("How would you like to sign in?", [
+ "Open a browser on this computer", "Use a device code (SSH / remote server)",
+ ], process.env.SSH_CONNECTION ? 1 : 0);
+ if (method === 1) args = ["login", "--device-auth"];
+ }
+ if (args.includes("--device-auth")) io.log("Enable device-code login in ChatGPT security settings if your account requests it.");
+ await deps.runCli(cli, args, entry.environment);
}
- if (args.includes("--device-auth")) io.log("Enable device-code login in ChatGPT security settings if your account requests it.");
- await deps.runCli(cli, args, entry.environment);
state = await deps.inspect(id, entry);
if (state.snapshot.state !== "available" || !state.snapshot.authenticated) {
throw new Error("Sign-in was not confirmed. Your OpenMausBot settings are unchanged; complete provider sign-in and try again.");
@@ -174,11 +212,12 @@ export async function runSetup(
const cfg = loadConfig();
const runtime = instanceConfigs(cfg);
const existing = Object.entries(runtime).filter(([id, entry]) =>
- !!cfg.instances?.[id] && ["codex", "claudeAgent", "openai-compat"].includes(entry.driver) && entry.enabled !== false);
+ !!cfg.instances?.[id] && (NATIVE_DRIVERS.has(entry.driver) || entry.driver === "openai-compat") && entry.enabled !== false);
io.log("\nWelcome to OpenMausBot\n");
io.log("Let's connect your AI. Choose a provider, then a model.");
io.log("Existing bots and conversations stay untouched. Ctrl-C cancels.");
io.log("You can add integrations and change settings later.\n");
+ const existingStart = NATIVE.length + 1;
const existingDefault = existing.findIndex(([id]) => id === cfg.defaultModelSelection?.instanceId);
const providerOptions = [
...NATIVE.map((n) => n.label),
@@ -191,9 +230,9 @@ export async function runSetup(
let entry: InstanceConfig;
let model: string;
for (;;) {
- pick ??= await io.choose("Choose your AI connection", providerOptions, existingDefault < 0 ? 0 : existingDefault + 3);
- const prior = pick >= 3 ? existing[pick - 3] : undefined;
- const native = pick < 2 ? NATIVE[pick] : NATIVE.find((n) => n.driver === prior?.[1].driver);
+ pick ??= await io.choose("Choose your AI connection", providerOptions, existingDefault < 0 ? 0 : existingDefault + existingStart);
+ const prior = pick >= existingStart ? existing[pick - existingStart] : undefined;
+ const native = pick < NATIVE.length ? NATIVE[pick] : NATIVE.find((n) => n.driver === prior?.[1].driver);
try {
if (native) {
// Reuse native provider settings; an ID the user repurposed keeps its connection.