Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Add Command Code as a built-in ACP engine
milind-sonif0deee247cac
diff --git a/apps/docs/content/docs/providers/index.mdx b/apps/docs/content/docs/providers/index.mdxindex 2770bd2eaf..cd68b19387 100644--- a/apps/docs/content/docs/providers/index.mdx+++ b/apps/docs/content/docs/providers/index.mdx@@ -17,6 +17,7 @@ OpenMausBot does not proxy every message through its own model account. It start| Grok | Grok CLI login | ACP-based local model catalog and session support || Cursor | Cursor Agent CLI login or API key | ACP driver with live model discovery || GitHub Copilot | `copilot login`, or `COPILOT_GITHUB_TOKEN` | ACP driver with the plan's live models, each labelled with its premium request multiplier |+| Command Code | `cmd login`, or `COMMAND_CODE_API_KEY` | ACP driver with the account's live models and their effort levels || Kimi | Kimi CLI login | ACP integration || Droid | Factory Droid CLI login | ACP integration || Antigravity | Google account through the official ACP server | Managed install, isolated accounts, live models, and approval cards |@@ -29,6 +30,8 @@ Additional driver instances can be declared in local configuration. UnavailableGitHub Copilot runs the official Copilot CLI (`npm install -g @github/copilot`) in its ACP mode and bills the signed-in Copilot plan, unless the CLI is set up to bring its own key: `COPILOT_PROVIDER_*` variables in the `githubCopilot` instance's `environment`, or a `providers.json` in the Copilot CLI home (`~/.copilot`, or `COPILOT_HOME`), send model requests to that provider, which bills them. A `GH_TOKEN` or `GITHUB_TOKEN` in OpenMausBot's own environment never reaches it, because either would take precedence over the CLI's login; put one in the `githubCopilot` instance's `environment` to use it. `COPILOT_ALLOW_ALL` is always removed, so tool approvals stay with OpenMausBot.+Command Code runs the official Command Code CLI (`npm install -g command-code`, Node.js 22 or newer) in its ACP mode (`command-code acp`) and bills the Command Code account `cmd login` signed in, or the key in `COMMAND_CODE_API_KEY`. Its picker lists every model the account offers, plus **Command Code default**, which keeps the model picked in Command Code itself. Ask runs Command Code's Standard mode, so each change it makes waits for approval in the app; Full access runs its Bypass Permissions mode.+To use OpenRouter, Fireworks AI, DeepSeek, Cline, or your own OpenAI- or Anthropic-compatible service, see [Other model providers](./model-providers.mdx).Codex models come from the signed-in CLI's live model list. If that list cannot be read, the picker shows an offline fallback that includes GPT-6 Astra, Sol, and Luna with availability marked unverified. An older CLI may not expose newer models; OpenMausBot checks for a newer stable Codex release and offers an update command for the configured executable. Updating the CLI does not grant model access to an account.diff --git a/apps/docs/content/docs/security/analytics.mdx b/apps/docs/content/docs/security/analytics.mdxindex 8c5a200875..46e8ce8a6a 100644--- a/apps/docs/content/docs/security/analytics.mdx+++ b/apps/docs/content/docs/security/analytics.mdx@@ -54,7 +54,7 @@ Properties are counts, `true` or `false`, or words from fixed lists in the app's| List | Values || --- | --- || Key provider | `anthropic`, `openai`, `openrouter`, `openai_compat`, `xai`, `mistral`, `cerebras`, `groq`, `greenference`, `meta`, `boat`, `composio`, `opencode_go`, `custom_endpoint`, `elevenlabs`, `fish_audio`, `jev`, `openrouter_decider`, `openai_image`, `custom_image`, `openai_live`, `onepassword`, `treg`, `postiz` |-| Engine | `claude`, `codex`, `gemini`, `cursor`, `opencode`, `qwen`, `hermes`, `cline`, `custom_acp`, `pi`, `openai_compat`, `grok`, `grok_api`, `kimi`, `droid`, `antigravity`, `minimax`, `mistral`, `cerebras`, `groq`, `greenference`, `meta`, `muse_code`, `deepseek`, `copilot` |+| Engine | `claude`, `codex`, `gemini`, `cursor`, `opencode`, `qwen`, `hermes`, `cline`, `custom_acp`, `pi`, `openai_compat`, `grok`, `grok_api`, `kimi`, `droid`, `antigravity`, `minimax`, `mistral`, `cerebras`, `groq`, `greenference`, `meta`, `muse_code`, `deepseek`, `copilot`, `command_code` || App | The 24 apps Connected apps lists by default: `slack`, `github`, `gmail`, `googlecalendar`, `googlesheets`, `googledocs`, `googledrive`, `notion`, `linear`, `sentry`, `posthog`, `discord`, `twitter`, `reddit`, `zapier`, `hubspot`, `salesforce`, `jira`, `asana`, `trello`, `dropbox`, `airtable`, `figma`, `stripe`. Every other app is `other`. || Starting role | `assistant`, `inbox`, `research`, `coder`, `community`, `ops` || Cloud plan | `starter`, `personal`, `pro`, `max` |diff --git a/docs/analytics.md b/docs/analytics.mdindex 38478cef9c..6a5e0ee23c 100644--- a/docs/analytics.md+++ b/docs/analytics.md@@ -50,7 +50,7 @@ Properties are counts, `true` or `false`, or words from fixed lists in the app's| List | Values || --- | --- || Key provider | `anthropic`, `openai`, `openrouter`, `openai_compat`, `xai`, `mistral`, `cerebras`, `groq`, `greenference`, `meta`, `boat`, `composio`, `opencode_go`, `custom_endpoint`, `elevenlabs`, `fish_audio`, `jev`, `openrouter_decider`, `openai_image`, `custom_image`, `openai_live`, `onepassword`, `treg`, `postiz` |-| Engine | `claude`, `codex`, `gemini`, `cursor`, `opencode`, `qwen`, `hermes`, `cline`, `custom_acp`, `pi`, `openai_compat`, `grok`, `grok_api`, `kimi`, `droid`, `antigravity`, `minimax`, `mistral`, `cerebras`, `groq`, `greenference`, `meta`, `muse_code`, `deepseek`, `copilot` |+| Engine | `claude`, `codex`, `gemini`, `cursor`, `opencode`, `qwen`, `hermes`, `cline`, `custom_acp`, `pi`, `openai_compat`, `grok`, `grok_api`, `kimi`, `droid`, `antigravity`, `minimax`, `mistral`, `cerebras`, `groq`, `greenference`, `meta`, `muse_code`, `deepseek`, `copilot`, `command_code` || App | The 24 apps Connected apps lists by default: `slack`, `github`, `gmail`, `googlecalendar`, `googlesheets`, `googledocs`, `googledrive`, `notion`, `linear`, `sentry`, `posthog`, `discord`, `twitter`, `reddit`, `zapier`, `hubspot`, `salesforce`, `jira`, `asana`, `trello`, `dropbox`, `airtable`, `figma`, `stripe`. Every other app is `other`. || Starting role | `assistant`, `inbox`, `research`, `coder`, `community`, `ops` || Cloud plan | `starter`, `personal`, `pro`, `max` |diff --git a/scripts/verify-engines-ui.ts b/scripts/verify-engines-ui.tsindex 135b3edee9..74fc1c91ad 100644--- a/scripts/verify-engines-ui.ts+++ b/scripts/verify-engines-ui.ts@@ -33,6 +33,7 @@ const instances: InstanceInfo[] = [["pi", "piAgent", "Pi", false, ""],["deepseek", "deepseekAgent", "DeepSeek Harness", false, ""],["githubCopilot", "copilotAgent", "GitHub Copilot", true, "1.0.103"],+ ["commandCode", "commandCodeAgent", "Command Code", true, "1.88.4"],].map(([id, driver, name, ready, version]) => ({instanceId: String(id), driverKind: String(driver), displayName: String(name),cliDefault: String(id),diff --git a/server/chat-notices.ts b/server/chat-notices.tsindex 8185d1364e..807540d19c 100644--- a/server/chat-notices.ts+++ b/server/chat-notices.ts@@ -92,6 +92,7 @@ export const CHAT_NOTICE = {"chat.notice.codexUnsupportedMore": "Codex could not run the tools {tools} and {count} more (\"unsupported call\"): the AI provider sent the call back without the tool's app name, so it never reached the tool. Pick a model for this bot whose provider handles tool calls fully.","chat.notice.copilotAccountRefused": "GitHub Copilot refused this request for the signed-in account. Check its Copilot plan and premium request allowance, then try again.",+ "chat.notice.commandCodeAccountRefused": "Command Code refused this request for the signed-in account. Check its plan and credits on commandcode.ai, then try again.","chat.notice.acpQuietUsageLimit": "{name} reached a usage limit{said} and is waiting it out without replying, so this turn was stopped.","chat.notice.acpQuietStuck": "{name} sent nothing for {quiet} with no tool running, no open request to its model and no CPU use, so the turn was stopped as stuck. Send the message again to retry.","chat.notice.acpModelRequestFailed": "{name}'s model request failed: \"{message}\" {name} may retry or stop; no reply for {quiet} so far.",diff --git a/server/drivers/acp/command-code.test.ts b/server/drivers/acp/command-code.test.tsnew file mode 100644index 0000000000..2cd90f8fb9--- /dev/null+++ b/server/drivers/acp/command-code.test.ts@@ -0,0 +1,166 @@+import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";+import { afterEach, beforeEach, describe, expect, it } from "vitest";++import { ensureDirs, instanceConfigs } from "../../config.ts";+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 {+ classifyCommandCodeError, CommandCodeAgentDriver, commandCodeAuthFile, commandCodeSignedIn, forgetCommandCodeDiscoverySession,+ resolveCommandCodeModels,+} from "./command-code.ts";++const FAKE_CLI = join(dirname(fileURLToPath(import.meta.url)), "../../testing/fake-acp-cli.ts");+// The session opens on the person's own default (command-code 1.88.4 opened on a DeepSeek model), not the list's first.+const MODELS = "deepseek/deepseek-v4.1-flash,claude-sonnet-5-5,gpt-6.1-sol";+const MODES = "default,auto-accept,plan,dont-ask,bypass";+const VARIANTS = JSON.stringify({+ "claude-sonnet-5-5": { id: "effort", currentValue: "medium", options: [{ value: "low", name: "Low" }, { value: "medium", name: "Medium" }, { value: "high", name: "High" }] },+});+const homeVar = process.platform === "win32" ? "USERPROFILE" : "HOME";++describe("Command Code ACP driver", () => {+ let scratch: string;+ let instance: ProviderInstance | undefined;+ let recorder: EventRecorder | undefined;++ beforeEach(() => {+ ensureDirs();+ scratch = mkdtempSync(join(tmpdir(), "omb-command-code-contract-"));+ });+ afterEach(async () => {+ recorder?.stop();+ await instance?.dispose();+ instance = undefined;+ recorder = undefined;+ await removeTempDir(scratch);+ });++ async function create(environment: Record<string, string> = {}) {+ instance = await CommandCodeAgentDriver.create({+ instanceId: `command-code-contract-${Math.random().toString(36).slice(2)}`, displayName: "Command Code", enabled: true,+ environment: { FAKE_ACP_MODELS: MODELS, FAKE_ACP_MODES: MODES, FAKE_ACP_VARIANTS: VARIANTS,+ FAKE_ACP_DUMP: join(scratch, "launch.json"), ...environment },+ config: { cli: FAKE_CLI, fullAuto: false },+ });+ recorder = recordEvents(instance.adapter);+ return { instance, recorder };+ }++ const prompts = () => readFileSync(join(scratch, "launch.json.prompts.jsonl"), "utf8").trim().split("\n").map((line) => JSON.parse(line));+ const configCalls = () => JSON.parse(readFileSync(join(scratch, "launch.json.config.json"), "utf8")) as Array<{ method: string; params: any }>;+ const signIn = (home: string, file: string, contents: string) => {+ mkdirSync(join(home, ".commandcode"), { recursive: true });+ writeFileSync(join(home, ".commandcode", file), contents);+ };++ it("is a built-in engine in fresh and existing fleets, beside a person's own custom Command Code instance", () => {+ expect(BUILT_IN_DRIVERS.some((driver) => driver.driverKind === "commandCodeAgent")).toBe(true);+ expect(instanceConfigs({}).commandCode?.driver).toBe("commandCodeAgent");+ const existing = instanceConfigs({ instances: {+ claude: { driver: "claudeAgent" },+ cmd: { driver: "customAcp", config: { cli: "cmd acp" } },+ } });+ expect(existing.commandCode?.driver).toBe("commandCodeAgent");+ expect(existing.cmd?.driver).toBe("customAcp");+ expect(CommandCodeAgentDriver.metadata.access).toBe("subscription");+ expect(CommandCodeAgentDriver.models).toEqual({ default: "agent-default", options: [{ id: "agent-default", label: "Command Code default" }] });+ });++ it("is signed in by the key `cmd login` stored or by COMMAND_CODE_API_KEY, and by nothing else", () => {+ const home = join(scratch, "home");+ expect(commandCodeSignedIn({ [homeVar]: home })).toBe(false);+ signIn(home, "auth.json", "{\"userName\":\"someone\"}");+ expect(commandCodeSignedIn({ [homeVar]: home })).toBe(false);+ signIn(home, "auth.json", "not json");+ expect(commandCodeSignedIn({ [homeVar]: home })).toBe(false);+ signIn(home, "auth.json", JSON.stringify({ apiKey: "fixture-key", userName: "someone" }));+ expect(commandCodeSignedIn({ [homeVar]: home })).toBe(true);+ // COMMANDCODE_API_ENV picks another account file, as the CLI does.+ expect(commandCodeAuthFile({ [homeVar]: home, COMMANDCODE_API_ENV: "staging" })).toBe(join(home, ".commandcode", "auth.staging.json"));+ expect(commandCodeSignedIn({ [homeVar]: home, COMMANDCODE_API_ENV: "staging" })).toBe(false);+ expect(commandCodeSignedIn({ [homeVar]: join(scratch, "empty"), COMMAND_CODE_API_KEY: "fixture-key" })).toBe(true);+ expect(commandCodeSignedIn({ [homeVar]: join(scratch, "empty"), COMMAND_CODE_API_KEY: " " })).toBe(false);+ });++ it("lists the advertised models after Command Code's own default, each with its effort levels, without a prompt", async () => {+ const catalog = await resolveCommandCodeModels(+ { ...process.env, FAKE_ACP_MODELS: MODELS, FAKE_ACP_VARIANTS: VARIANTS }, { cli: FAKE_CLI });+ expect(catalog.default).toBe("agent-default");+ expect(catalog.options.map((option) => option.id)).toEqual(["agent-default", ...MODELS.split(",")]);+ expect(catalog.options.some((option) => option.custom)).toBe(false);+ expect(catalog.options.find((option) => option.id === "claude-sonnet-5-5")?.variants).toEqual([+ { id: "low", label: "Low" }, { id: "medium", label: "Medium" }, { id: "high", label: "High" },+ ]);+ });++ it("removes only the files the discovery session itself left in Command Code's projects", async () => {+ const home = join(scratch, "forget-home");+ const projects = join(home, ".commandcode", "projects");+ const file = (folder: string, name: string) => {+ mkdirSync(join(projects, folder), { recursive: true });+ writeFileSync(join(projects, folder, name), "{\"model\":\"gpt-6.1-sol\"}");+ return join(projects, folder, name);+ };+ // The folder names are command-code 1.88.4's slugs of the discovery's temporary cwd and of a real project.+ const ours = file("private-var-folders-t-omb-acp-models-1kng-q5", "c7b01536.meta.json");+ const sibling = file("private-var-folders-t-omb-acp-models-zz", "other.meta.json");+ const project = file("users-someone-code-app", "c7b01536.meta.json");+ await forgetCommandCodeDiscoverySession({ sessionId: "c7b01536", env: { [homeVar]: home } });+ expect(existsSync(ours)).toBe(false);+ expect(existsSync(join(projects, "private-var-folders-t-omb-acp-models-1kng-q5"))).toBe(false);+ expect([existsSync(sibling), existsSync(project)]).toEqual([true, true]);+ await forgetCommandCodeDiscoverySession({ sessionId: "../../x", env: { [homeVar]: home } });+ await forgetCommandCodeDiscoverySession({ sessionId: "c7b01536", env: { [homeVar]: join(scratch, "no-home") } });+ });++ it("reads -32000 as a missing login only when Command Code says so", () => {+ expect(classifyCommandCodeError({ code: -32000, message: "Not authenticated. Run `cmd login` in a terminal first." })).toBe("invalid_credentials");+ expect(classifyCommandCodeError({ code: -32000, message: "Not authenticated. Run `cmd login` in a terminal, then retry." })).toBe("invalid_credentials");+ expect(classifyCommandCodeError({ code: -32000, message: "session already active" })).toBeUndefined();+ expect(classifyCommandCodeError({ code: -32603, message: "Not authenticated" })).toBeUndefined();+ expect(classifyCommandCodeError(null)).toBeUndefined();+ });++ it("starts nothing when the instance is created, so a `command-code` on PATH costs no launch", async () => {+ await create();+ expect(existsSync(join(scratch, "launch.json"))).toBe(false);+ expect(instance!.models.default).toBe("agent-default");+ });++ it("runs `command-code acp` on the picked model, through ACP, in the mode that leaves approvals to the app", async () => {+ const { instance, recorder } = await create({ COMMAND_CODE_API_KEY: "engine-fixture-key" });+ const { turnId } = await instance.adapter.sendTurn({ threadId: "command-code-chat", text: "hello", model: "claude-sonnet-5-5", approvalMode: "ask" });+ await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);+ expect(recorder.events.every((event) => event.provider === "commandCodeAgent")).toBe(true);+ const launch = JSON.parse(readFileSync(join(scratch, "launch.json"), "utf8"));+ expect(launch.argv.at(-1)).toBe("acp");+ expect(launch.env.COMMAND_CODE_API_KEY).toBe("engine-fixture-key");+ expect(configCalls().filter((call) => call.method === "session/set_mode").map((call) => call.params.modeId)).toEqual(["default"]);+ expect(prompts().at(-1)).toMatchObject({ model: "claude-sonnet-5-5" });+ });++ it("leaves Command Code on its own default model, and runs Bypass Permissions only under Full access", async () => {+ const { instance, recorder } = await create();+ const { turnId } = await instance.adapter.sendTurn({ threadId: "command-code-full", text: "hello", model: "agent-default", approvalMode: "full" });+ await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);+ expect(configCalls().some((call) => call.method === "session/set_config_option" && call.params.configId === "model")).toBe(false);+ expect(configCalls().filter((call) => call.method === "session/set_mode").map((call) => call.params.modeId)).toEqual(["bypass"]);+ expect(prompts().at(-1)).toMatchObject({ model: "deepseek/deepseek-v4.1-flash" });+ });++ it("turns Command Code's session/request_permission into an approval card and answers with the person's choice", async () => {+ const answer = join(scratch, "permission.txt");+ const { instance, recorder } = await create({ FAKE_ACP_MODE: "permission", FAKE_ACP_PERMISSION_ANSWER: answer });+ const { turnId } = await instance.adapter.sendTurn({ threadId: "command-code-permission", text: "edit", model: "agent-default", approvalMode: "ask" });+ const ask = await recorder.until((event) => event.type === "request.opened");+ expect(ask.provider).toBe("commandCodeAgent");+ expect(await instance.adapter.respondToRequest("command-code-permission", ask.requestId!, { behavior: "deny" })).toBe("rejected");+ await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);+ expect(readFileSync(answer, "utf8")).toBe("reject");+ });+});diff --git a/server/drivers/acp/command-code.ts b/server/drivers/acp/command-code.tsnew file mode 100644index 0000000000..19c93f09fd--- /dev/null+++ b/server/drivers/acp/command-code.ts@@ -0,0 +1,120 @@+// Command Code over ACP (`command-code acp`), billed to the Command Code account `cmd login` stored.+// Checked against command-code 1.88.4 (npm `command-code`, which installs the same program as `cmd`, `cmdc`,+// `commandcode` and `command-code`; the app runs `command-code` because `cmd` is the Windows shell). Its ACP+// initialize offers one auth method, `command-code-cli`, which only points at `cmd login`; session/new refuses a+// missing login with -32000 "Not authenticated. Run `cmd login` in a terminal first.". A session advertises its+// whole catalog as the `model` config option (95 models in 1.88.4, opening on the person's own default) and each model's+// effort as `effort`; session/set_config_option confirms both. Its modes are default (asks), auto-accept, plan,+// dont-ask and bypass. A session's model lives in `~/.commandcode/projects/<cwd slug>/<session id>.meta.json`;+// picking one there never changes the default the next session opens on.+import { readFileSync } from "node:fs";+import { readdir, rm, rmdir } from "node:fs/promises";+import { join } from "node:path";++import type { ModelCatalog, ProviderErrorCode } from "../../contracts.ts";+import { userHome } from "../../env-path.ts";+import { createAcpDriver, type AccountErrorCode, type AcpConfig, type AcpSupport } from "./core.ts";+import { discoverAcpModels, type AcpDiscoveryOptions } from "./custom-model-catalog.ts";++/** Leaves the session on the model the person picked in Command Code itself. */+const AGENT_DEFAULT = { id: "agent-default", label: "Command Code default" };+const MODELS: ModelCatalog = { default: AGENT_DEFAULT.id, options: [AGENT_DEFAULT] };+const SPAWN_ARGS = ["acp"];+const SIGN_IN = "cmd login";+const API_KEY_ENV = "COMMAND_CODE_API_KEY";+const LOGIN_NOTE = `Command Code is not signed in. Run ${SIGN_IN} in a terminal, or set ${API_KEY_ENV}, then check again.`;+// Set every turn: a person's own default mode must never skip the app's approvals.+const MODE_ASK = "default";+const MODE_FULL = "bypass";+/** `COMMANDCODE_API_ENV` picks the account file the CLI reads (1.88.4: getCommandAuthFileName). */+const AUTH_FILES: Record<string, string> = { prod: "auth.json", staging: "auth.staging.json", local: "auth.local.json" };++/** The account file `cmd login` writes: `<home>/.commandcode/auth.json`, holding `{apiKey, userName}`. */+export function commandCodeAuthFile(env: Record<string, string | undefined>): string {+ return join(userHome(env), ".commandcode", AUTH_FILES[env.COMMANDCODE_API_ENV ?? ""] ?? AUTH_FILES.prod);+}++/** The CLI takes `COMMAND_CODE_API_KEY` before the stored login, as either one signs it in. */+export function commandCodeSignedIn(env: Record<string, string | undefined>): boolean {+ if (env[API_KEY_ENV]?.trim()) return true;+ try {+ const stored = JSON.parse(readFileSync(commandCodeAuthFile(env), "utf8")) as { apiKey?: unknown } | null;+ return typeof stored?.apiKey === "string" && stored.apiKey.trim() !== "";+ } catch {+ return false;+ }+}++/** Discovery switches its session through every model, which Command Code records under the discovery's own+ * temporary folder's project; only that session's files, and then its emptied project folder, are removed. */+export async function forgetCommandCodeDiscoverySession({ sessionId, env }: { sessionId: string; env: Record<string, string | undefined> }): Promise<void> {+ if (!/^[\w-]{1,128}$/.test(sessionId)) return;+ const projects = join(userHome(env), ".commandcode", "projects");+ const folders = await readdir(projects).catch(() => [] as string[]);+ for (const folder of folders.filter((name) => name.includes("omb-acp-models-"))) {+ const files = await readdir(join(projects, folder)).catch(() => [] as string[]);+ const ours = files.filter((name) => name.startsWith(`${sessionId}.`));+ if (!ours.length) continue;+ await Promise.all(ours.map((name) => rm(join(projects, folder, name), { force: true })));+ await rmdir(join(projects, folder)).catch(() => {});+ }+}++const DISCOVERY: AcpDiscoveryOptions = { passthrough: AGENT_DEFAULT, exitGraceMs: 1_000, forgetSession: forgetCommandCodeDiscoverySession };++export function resolveCommandCodeModels(env: Record<string, string | undefined>, config: Pick<AcpConfig, "cli">): Promise<ModelCatalog> {+ return discoverAcpModels(env, config.cli, SPAWN_ARGS, DISCOVERY);+}++/** ACP's -32000 is `auth_required`; only the login refusal's own words make it one. */+export function classifyCommandCodeError(error: unknown): ProviderErrorCode | undefined {+ const value = error !== null && typeof error === "object" ? error as { code?: unknown; message?: unknown } : undefined;+ const text = typeof value?.message === "string" ? value.message.toLowerCase() : "";+ return value?.code === -32000 && /\bnot authenticated\b|\bcmd login\b/.test(text) ? "invalid_credentials" : undefined;+}++export function describeCommandCodeAccountError(code: AccountErrorCode): string {+ return code === "invalid_credentials" ? LOGIN_NOTE+ : "Command Code refused this request for the signed-in account. Check its plan and credits on commandcode.ai, then try again.";+}++const SUPPORT: AcpSupport = {+ driverKind: "commandCodeAgent",+ displayName: "Command Code",+ models: MODELS,+ defaultCli: "command-code",+ nativeSource: "command-code.acp",+ images: true,+ loginNote: LOGIN_NOTE,+ install: {+ command: { darwin: "npm install -g command-code", linux: "npm install -g command-code", win32: "npm install -g command-code" },+ needsNode: true,+ docsUrl: "https://commandcode.ai/docs/acp",+ signInCommand: SIGN_IN,+ },+ spawnArgs: () => SPAWN_ARGS,+ credentialEnv: [API_KEY_ENV],+ resolveModels: (env, config) => resolveCommandCodeModels(env, config),+ // Every fleet has this instance: the catalog comes from the startup cache and refreshes when the engine is picked.+ resolveModelsOnCreate: false,+ selectModel: { configId: "model", agentDefault: AGENT_DEFAULT.id },+ modelVariants: true,+ // The OS keeps no login the CLI could be walked through over ACP; `cmd login` opens a browser.+ pickAuthMethod: () => null,+ authFailure: "continue",+ isAuthenticated: (env) => commandCodeSignedIn(env),+ classifyError: classifyCommandCodeError,+ describeAccountError: describeCommandCodeAccountError,+ accountErrorText: (code) => code === "invalid_credentials" ? undefined : { key: "chat.notice.commandCodeAccountRefused" },+ async configureSession({ request, sessionId, config }) {+ const modeId = config.fullAuto ? MODE_FULL : MODE_ASK;+ try {+ await request("session/set_mode", { sessionId, modeId });+ } catch (error) {+ throw new Error(`Command Code rejected permission mode "${modeId}": ${(error as Error).message}`);+ }+ },+ buildPromptText: (turn) => (turn.system ? `${turn.system}\n\n${turn.text}` : turn.text),+};++export const CommandCodeAgentDriver = createAcpDriver(SUPPORT);diff --git a/server/drivers/builtIn.ts b/server/drivers/builtIn.tsindex 1509b28dd1..3f957722e2 100644--- a/server/drivers/builtIn.ts+++ b/server/drivers/builtIn.ts@@ -15,6 +15,7 @@ import { HermesAgentDriver } from "./acp/hermes.ts";import { DeepSeekAgentDriver } from "./acp/deepseek.ts";import { ClineAgentDriver } from "./acp/cline.ts";import { CopilotAgentDriver } from "./acp/copilot.ts";+import { CommandCodeAgentDriver } from "./acp/command-code.ts";import { OpenAICompatDriver } from "./openai-compat.ts";import { PiDriver } from "./pi.ts";import { MistralDriver } from "./mistral.ts";@@ -37,6 +38,7 @@ export const BUILT_IN_DRIVERS: readonly AnyProviderDriver[] = [HermesAgentDriver,ClineAgentDriver,CopilotAgentDriver,+ CommandCodeAgentDriver,CustomAcpDriver,PiDriver,OpenAICompatDriver,diff --git a/server/engine-memory.ts b/server/engine-memory.tsindex 7edcb84be5..f31737b92a 100644--- a/server/engine-memory.ts+++ b/server/engine-memory.ts@@ -29,7 +29,7 @@ const STALL_PERCENT = 20;const MINUTE_MS = 60_000, DAY_MINUTES = 24 * 60;/** Engines that run each thread's turns in processes of their own. */export const ENGINE_PROCESS_KINDS: ReadonlySet<string> = new Set(["claudeAgent", "codex", "opencodeGo", "grokAgent", "geminiAgent", "kimiAgent",- "droidAgent", "cursorAgent", "qwenAgent", "hermesAgent", "clineAgent", "copilotAgent", "customAcp", "piAgent", "antigravityAgent"]);+ "droidAgent", "cursorAgent", "qwenAgent", "hermesAgent", "clineAgent", "copilotAgent", "commandCodeAgent", "customAcp", "piAgent", "antigravityAgent"]);export interface HostMemory { totalBytes: number; availableBytes: number; swapFreeBytes: number; oomKills: number | null; fullStall10: number | null }diff --git a/server/instance-fleets.ts b/server/instance-fleets.tsindex f7cddb197f..bd7f622dc2 100644--- a/server/instance-fleets.ts+++ b/server/instance-fleets.ts@@ -30,6 +30,7 @@ export const DEFAULT_FLEET: InstanceConfigMap = {droid: { driver: "droidAgent" },cursor: { driver: "cursorAgent" },githubCopilot: { driver: "copilotAgent" },+ commandCode: { driver: "commandCodeAgent" },claude: { driver: "claudeAgent" },codex: { driver: "codex" },chatgpt: { driver: "codex", displayName: "ChatGPT plan", config: { authMode: "chatgpt-plan" } },@@ -62,6 +63,7 @@ export const PRODUCT_FLEET_ADDITIONS = {chatgpt: { driver: "codex", displayName: "ChatGPT plan", config: { authMode: "chatgpt-plan" } },cursor: { driver: "cursorAgent" },githubCopilot: { driver: "copilotAgent" },+ commandCode: { driver: "commandCodeAgent" },openaiCompat: { driver: "openai-compat" },mistral: { driver: "mistral" },cerebras: { driver: "cerebras" },diff --git a/server/runtime/capabilities.test.ts b/server/runtime/capabilities.test.tsindex ee20220370..97c34f676e 100644--- a/server/runtime/capabilities.test.ts+++ b/server/runtime/capabilities.test.ts@@ -27,6 +27,7 @@ const EXPECTED: Record<string, EngineCapabilities> = {deepseekAgent: bare,clineAgent: { resume: true, nativeReviewer: false, full: true, edits: false, subagents: false },copilotAgent: bare,+ commandCodeAgent: bare,customAcp: bare,"openai-compat": chat,grok: chat,diff --git a/server/runtime/capabilities.ts b/server/runtime/capabilities.tsindex 6e03336eda..f1c95c4e35 100644--- a/server/runtime/capabilities.ts+++ b/server/runtime/capabilities.ts@@ -34,6 +34,7 @@ const ENGINES: Readonly<Record<string, EngineRow>> = {deepseekAgent: { resume: true },clineAgent: { resume: true },copilotAgent: { resume: true },+ commandCodeAgent: { resume: true },customAcp: { resume: true },"openai-compat": CHAT_ROW,grok: CHAT_ROW,diff --git a/server/testing/fake-acp-cli.ts b/server/testing/fake-acp-cli.tsindex 2be32aa7eb..bc0b038b73 100755--- a/server/testing/fake-acp-cli.ts+++ b/server/testing/fake-acp-cli.ts@@ -253,6 +253,7 @@ const dumpEnv = Object.fromEntries("COPILOT_GITHUB_TOKEN","GH_TOKEN","GITHUB_TOKEN",+ "COMMAND_CODE_API_KEY",].flatMap((key) => (process.env[key] === undefined ? [] : [[key, process.env[key]]] as const)),);const dumpState: Record<string, unknown> = { argv, env: dumpEnv, pid: process.pid };diff --git a/shared/tool-scope-support.ts b/shared/tool-scope-support.tsindex 73bb0b4857..9a1571eebd 100644--- a/shared/tool-scope-support.ts+++ b/shared/tool-scope-support.ts@@ -5,7 +5,7 @@ export const TOOL_SCOPE_SUPPORT = {grok: "native-and-mcp", grokAgent: "native-and-mcp", piAgent: "native-and-mcp","openai-compat": "native-and-mcp", mistral: "native-and-mcp", minimax: "native-and-mcp", cerebras: "native-and-mcp", groq: "native-and-mcp", greenference: "native-and-mcp", meta: "native-and-mcp",claudeAgent: "mcp", codex: "mcp", geminiAgent: "mcp", kimiAgent: "mcp", droidAgent: "mcp",- cursorAgent: "mcp", opencodeGo: "mcp", qwenAgent: "mcp", hermesAgent: "mcp", clineAgent: "mcp", copilotAgent: "mcp", deepseekAgent: "mcp", customAcp: "mcp", antigravityAgent: "mcp", museCode: "mcp",+ cursorAgent: "mcp", opencodeGo: "mcp", qwenAgent: "mcp", hermesAgent: "mcp", clineAgent: "mcp", copilotAgent: "mcp", commandCodeAgent: "mcp", deepseekAgent: "mcp", customAcp: "mcp", antigravityAgent: "mcp", museCode: "mcp",} as const;export function assertToolScopeSupported(engine: string, value: unknown): ToolScope | undefined {diff --git a/src/components/EngineLibrary.tsx b/src/components/EngineLibrary.tsxindex 18e7daf4bd..c749510034 100644--- a/src/components/EngineLibrary.tsx+++ b/src/components/EngineLibrary.tsx@@ -17,7 +17,7 @@ const providers: Record<string, string> = {claudeAgent: "Anthropic", codex: "OpenAI", grok: "xAI", grokAgent: "xAI",kimiAgent: "Moonshot AI", droidAgent: "Factory", cursorAgent: "Cursor",antigravityAgent: "Google", opencodeGo: "OpenCode", qwenAgent: "Qwen",- hermesAgent: "Nous Research", clineAgent: "Cline", copilotAgent: "GitHub", piAgent: "pi.dev", mistral: "Mistral AI", cerebras: "Cerebras", groq: "Groq", greenference: "Greenference", meta: "Meta", museCode: "Meta", deepseekAgent: "DeepSeek",+ hermesAgent: "Nous Research", clineAgent: "Cline", copilotAgent: "GitHub", commandCodeAgent: "Command Code", piAgent: "pi.dev", mistral: "Mistral AI", cerebras: "Cerebras", groq: "Groq", greenference: "Greenference", meta: "Meta", museCode: "Meta", deepseekAgent: "DeepSeek",};export function providerName(instance: InstanceInfo): string {diff --git a/src/components/ProviderIcons.tsx b/src/components/ProviderIcons.tsxindex 1ffefe5f14..b70919d1cc 100644--- a/src/components/ProviderIcons.tsx+++ b/src/components/ProviderIcons.tsx@@ -127,6 +127,15 @@ export function CopilotMark({ size = 16, className }: IconProps) {return <svg width={size} height={size} viewBox="0 0 24 24" className={className} aria-hidden="true"><path fill="var(--color-ink)" d="M23.922 16.997C23.061 18.492 18.063 22.02 12 22.02 5.937 22.02.939 18.492.078 16.997A.641.641 0 0 1 0 16.741v-2.869a.883.883 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.098 10.098 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952C7.255 2.937 9.248 1.98 11.978 1.98c2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.841.841 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256Zm-11.75-5.992h-.344a4.359 4.359 0 0 1-.355.508c-.77.947-1.918 1.492-3.508 1.492-1.725 0-2.989-.359-3.782-1.259a2.137 2.137 0 0 1-.085-.104L4 11.746v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.359 4.359 0 0 1-.355-.508Zm2.328 3.25c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm-5 0c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm3.313-6.185c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z" /></svg>;}+export function CommandCodeMark({ size = 16, className }: IconProps) {+ // Command Code's tile: the ⌘ sign (Lucide's `command`, ISC) on a rounded square in ink.+ return <svg width={size} height={size} viewBox="0 0 24 24" className={className} aria-hidden="true">+ <rect width="24" height="24" rx="6" fill="var(--color-ink)" />+ <path stroke="var(--color-panel)" strokeWidth={2.5} strokeLinecap="round" strokeLinejoin="round" fill="none"+ transform="translate(4.8 4.8) scale(0.6)" d="M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3" />+ </svg>;+}+export function GreenferenceMark({ size = 16, className }: IconProps) {// Greenference's site icon (greenference.com/assets/favicon.svg) without its tile, in a teal from its logo that reads on light and dark.return <svg width={size} height={size} viewBox="4 2 24 24" className={className} aria-hidden="true">@@ -169,6 +178,8 @@ export function ProviderMark({ driverKind, size, className }: IconProps & { drivreturn <PiMark size={size} className={className} />;case "copilotAgent":return <CopilotMark size={size} className={className} />;+ case "commandCodeAgent":+ return <CommandCodeMark size={size} className={className} />;case "greenference":return <GreenferenceMark size={size} className={className} />;default:diff --git a/src/lib/analytics-allowlist.ts b/src/lib/analytics-allowlist.tsindex fb5c93bfb4..02e0bf4c53 100644--- a/src/lib/analytics-allowlist.ts+++ b/src/lib/analytics-allowlist.ts@@ -32,7 +32,7 @@ export function credentialProvider(target: unknown): KeyProvider | "other" {export const ENGINE = ["claude", "codex", "gemini", "cursor", "opencode", "qwen", "hermes", "cline", "custom_acp", "pi", "openai_compat", "grok",- "grok_api", "kimi", "droid", "antigravity", "minimax", "mistral", "cerebras", "groq", "greenference", "meta", "muse_code", "deepseek", "copilot",+ "grok_api", "kimi", "droid", "antigravity", "minimax", "mistral", "cerebras", "groq", "greenference", "meta", "muse_code", "deepseek", "copilot", "command_code",] as const;export type Engine = (typeof ENGINE)[number];@@ -41,7 +41,7 @@ const ENGINE_BY_DRIVER = new Map<string, Engine>(Object.entries({qwenAgent: "qwen", hermesAgent: "hermes", clineAgent: "cline", customAcp: "custom_acp", piAgent: "pi","openai-compat": "openai_compat", grokAgent: "grok", grok: "grok_api", kimiAgent: "kimi", droidAgent: "droid",antigravityAgent: "antigravity", minimax: "minimax", mistral: "mistral", cerebras: "cerebras", groq: "groq", greenference: "greenference",- meta: "meta", museCode: "muse_code", deepseekAgent: "deepseek", copilotAgent: "copilot",+ meta: "meta", museCode: "muse_code", deepseekAgent: "deepseek", copilotAgent: "copilot", commandCodeAgent: "command_code",} satisfies Record<string, Engine>));export function engineForDriver(driverKind: unknown): Engine | "other" {diff --git a/src/lib/built-in-instances.ts b/src/lib/built-in-instances.tsindex dfc64e341a..12941cb554 100644--- a/src/lib/built-in-instances.ts+++ b/src/lib/built-in-instances.ts@@ -1,6 +1,6 @@/** The server's default instances by id, with their driver kinds, plus `gemini`, which an enterprise licence restores. */export const BUILT_IN_INSTANCE_DRIVERS: Readonly<Record<string, string>> = {- grok: "grokAgent", kimi: "kimiAgent", droid: "droidAgent", cursor: "cursorAgent", githubCopilot: "copilotAgent", claude: "claudeAgent", codex: "codex",+ grok: "grokAgent", kimi: "kimiAgent", droid: "droidAgent", cursor: "cursorAgent", githubCopilot: "copilotAgent", commandCode: "commandCodeAgent", claude: "claudeAgent", codex: "codex",chatgpt: "codex", antigravity: "antigravityAgent", opencodeGo: "opencodeGo", openaiCompat: "openai-compat",mistral: "mistral", cerebras: "cerebras", groq: "groq", greenference: "greenference", meta: "meta", museCode: "museCode", deepseek: "deepseekAgent", openai: "openai-compat",claudeApi: "claudeAgent", xaiApi: "grok", openrouter: "openai-compat", qwen: "qwenAgent", hermes: "hermesAgent",diff --git a/src/locales/en.json b/src/locales/en.jsonindex eba521b983..40d85a8e5d 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -9241,6 +9241,7 @@"serverError.computer.notReadyDetail": "OpenMausBot can't use this computer yet — {reason}","serverError.computer.notReadyMacPermission": "OpenMausBot can't use this computer yet — {reason}. Relaunch OpenMausBot after granting the missing macOS permission.","chat.notice.copilotAccountRefused": "GitHub Copilot refused this request for the signed-in account. Check its Copilot plan and premium request allowance, then try again.",+ "chat.notice.commandCodeAccountRefused": "Command Code refused this request for the signed-in account. Check its plan and credits on commandcode.ai, then try again.","chat.notice.acpQuietUsageLimit": "{name} reached a usage limit{said} and is waiting it out without replying, so this turn was stopped.","chat.notice.acpQuietStuck": "{name} sent nothing for {quiet} with no tool running, no open request to its model and no CPU use, so the turn was stopped as stuck. Send the message again to retry.","chat.notice.acpModelRequestFailed": "{name}'s model request failed: \"{message}\" {name} may retry or stop; no reply for {quiet} so far.",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 010a5410a7..720060c5f4 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -9222,6 +9222,7 @@"serverError.computer.notReadyDetail": "O OpenMausBot ainda não consegue usar este computador. Motivo: {reason}","serverError.computer.notReadyMacPermission": "O OpenMausBot ainda não consegue usar este computador. Motivo: {reason}. Abra o OpenMausBot novamente depois de conceder a permissão do macOS que falta.","chat.notice.copilotAccountRefused": "O GitHub Copilot recusou este pedido para a conta conectada. Confira o plano do Copilot e a franquia de pedidos premium e tente novamente.",+ "chat.notice.commandCodeAccountRefused": "O Command Code recusou este pedido para a conta conectada. Confira o plano e os créditos em commandcode.ai e tente novamente.","chat.notice.acpQuietUsageLimit": "{name} atingiu um limite de uso{said} e está esperando a restrição acabar, sem responder. Por isso, esta sessão foi interrompida.","chat.notice.acpQuietStuck": "{name} ficou {quiet} sem enviar nada. Não havia ferramenta em execução, pedido aberto ao modelo nem uso de CPU, então a sessão foi interrompida por estar travada. Envie a mensagem de novo para tentar novamente.","chat.notice.acpModelRequestFailed": "O pedido de {name} ao modelo falhou: “{message}”. {name} pode tentar novamente ou parar. Sem resposta há {quiet}.",