Skip to content

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

Add GitHub Copilot CLI as a built-in ACP engine (#3740)

Fabio Nunesaf59c2ec4a7b
diff --git a/apps/docs/content/docs/providers/index.mdx b/apps/docs/content/docs/providers/index.mdx
index 85a4b446eb..2770bd2eaf 100644
--- a/apps/docs/content/docs/providers/index.mdx
+++ b/apps/docs/content/docs/providers/index.mdx
@@ -16,6 +16,7 @@ OpenMausBot does not proxy every message through its own model account. It start
| Codex | Codex CLI login | Model discovery, approvals, steering, and computer tools |
| 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 |
| 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 |
@@ -26,6 +27,8 @@ OpenMausBot does not proxy every message through its own model account. It start
Additional driver instances can be declared in local configuration. Unavailable engines remain visible with a reason instead of crashing the provider fleet.
+GitHub 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.
+
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.mdx
index 486ba6ea7e..a6aee458c9 100644
--- a/apps/docs/content/docs/security/analytics.mdx
+++ b/apps/docs/content/docs/security/analytics.mdx
@@ -61,7 +61,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`, `meta`, `boat`, `composio`, `opencode_go`, `custom_endpoint`, `elevenlabs`, `fish_audio`, `jev`, `openrouter_decider`, `openai_image`, `custom_image`, `openai_live`, `onepassword`, `treg` |
-| Engine | `claude`, `codex`, `gemini`, `cursor`, `opencode`, `qwen`, `hermes`, `cline`, `custom_acp`, `pi`, `openai_compat`, `grok`, `grok_api`, `kimi`, `droid`, `antigravity`, `minimax`, `mistral`, `cerebras`, `groq`, `meta`, `muse_code` |
+| Engine | `claude`, `codex`, `gemini`, `cursor`, `opencode`, `qwen`, `hermes`, `cline`, `custom_acp`, `pi`, `openai_compat`, `grok`, `grok_api`, `kimi`, `droid`, `antigravity`, `minimax`, `mistral`, `cerebras`, `groq`, `meta`, `muse_code`, `deepseek`, `copilot` |
| 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.md
index 9fe4ffc8da..3bfee040be 100644
--- a/docs/analytics.md
+++ b/docs/analytics.md
@@ -57,7 +57,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`, `meta`, `boat`, `composio`, `opencode_go`, `custom_endpoint`, `elevenlabs`, `fish_audio`, `jev`, `openrouter_decider`, `openai_image`, `custom_image`, `openai_live`, `onepassword`, `treg` |
-| Engine | `claude`, `codex`, `gemini`, `cursor`, `opencode`, `qwen`, `hermes`, `cline`, `custom_acp`, `pi`, `openai_compat`, `grok`, `grok_api`, `kimi`, `droid`, `antigravity`, `minimax`, `mistral`, `cerebras`, `groq`, `meta`, `muse_code` |
+| Engine | `claude`, `codex`, `gemini`, `cursor`, `opencode`, `qwen`, `hermes`, `cline`, `custom_acp`, `pi`, `openai_compat`, `grok`, `grok_api`, `kimi`, `droid`, `antigravity`, `minimax`, `mistral`, `cerebras`, `groq`, `meta`, `muse_code`, `deepseek`, `copilot` |
| 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/verification/README.md b/docs/verification/README.md
index 233688f13e..eb6a073db6 100644
--- a/docs/verification/README.md
+++ b/docs/verification/README.md
@@ -231,6 +231,10 @@ The [custom ACP model fixture](custom-acp-models.md) checks native model and
thinking choices, independent bot defaults and thread overrides, and retained
settings and catalogs after restart with an offline ACP engine.
+The [GitHub Copilot engine checks](copilot-engine.md) cover its ACP catalog,
+model and effort selection, sign-in detection, and moving a bot or conversation
+between Claude, Copilot and a custom ACP agent with fake engines.
+
The [mobile generated-image checks](mobile-generated-images.md) cover native image
attachments and message-scoped download authorization using isolated fixtures.
diff --git a/docs/verification/copilot-engine.md b/docs/verification/copilot-engine.md
new file mode 100644
index 0000000000..b297c0a2a1
--- /dev/null
+++ b/docs/verification/copilot-engine.md
@@ -0,0 +1,66 @@
+# GitHub Copilot engine
+
+```sh
+pnpm exec vitest run server/drivers/acp/copilot.test.ts server/drivers/acp/custom-model-catalog.test.ts
+pnpm exec vitest run server/copilot-engine.e2e.test.ts src/components/CopilotModelPicker.test.ts
+```
+
+The driver tests run `copilotAgent` against the repository's `fake-acp-cli.ts`.
+They cover registration in fresh and existing fleets, catalog discovery
+through `session/new` and `session/set_config_option` with per-model effort
+levels and Auto as the default even when the session opens on another model,
+the premium-request multiplier in model labels, and sign-in detection. Only an
+`auth_required` whose text names the login counts as a missing login (a
+"max tokens" or "author" message does not, nor does a missing or refused
+credential of an MCP server), a token in the environment is
+probed like a stored login and probed again when it changes, the answer is
+kept per Copilot home (`COPILOT_HOME`, else `HOME`/`USERPROFILE`), and
+concurrent or repeated checks share one probe (a refresh counts as one), with
+a missing login checked again after a minute. A caller waits at most three
+seconds on a probe: past that it gets the last answer (or "signed in" before
+any), so a `copilot` on PATH that never answers ACP cannot hold the engine
+list, and the probe still finishes in the background. Removing a discovery session
+touches only the folder whose workspace names that discovery's own cwd and
+client; the cwd matches when quoted, resolved, or (on Windows) in another
+case, and the test's workspace.yaml uses Copilot CLI 1.0.105's own fields. Only Copilot's discovery closes stdin and waits up to two seconds for
+the agent to exit before killing it; a custom ACP agent is killed at once, and
+an agent that ignores EOF is still stopped once the wait is over. The tests also cover the model applied over ACP and never on argv,
+a model switch between turns, a `session/request_permission` shown as an
+approval card and answered with the person's choice, the fallback to Auto with a notice when the plan
+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` never
+reach the child, while a token set on the engine itself does.
+
+The end-to-end test launches an isolated server with `launchVerificationServer`,
+which uses a disposable home, data directory and port pair, and fake engines
+only. It refreshes the Copilot and custom ACP catalogs, then moves one bot from
+Claude to Copilot through the picker's bot route and the strict model route,
+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 fake
+agents' prompt receipts, so a saved setting alone cannot pass.
+
+The renderer test passes the production Copilot catalog resolver's output
+(against the same fake) into the full ModelPicker. It requires the advertised
+models in the picker and the effort levels of the picked model, and requires a
+pick to save that selection. It also checks that a Claude → Copilot → custom
+ACP → Claude round trip needs no approval reset at Ask, Auto or Full.
+
+On Windows, catalog discovery used to fail on every refresh: the discovery
+child was given 500 ms to stop, but taskkill takes longer, so the cleanup
+threw and the catalog was dropped. `server/drivers/acp/custom-model-catalog.test.ts` fails without
+the longer Windows stop timeout.
+
+These checks do not establish acceptance by GitHub. A manual check against an
+installed, signed-in Copilot CLI 1.0.103 on Windows 11, through the driver with
+a throwaway `OMB_DATA_DIR`, reported `authenticated: true`. It listed 14 models,
+each with its multiplier and effort levels. It then ran one prompt on
+`claude-haiku-4.5`, which completed with the reasoning streamed apart from the
+reply. Copilot CLI 1.0.103 keeps every ACP session under
+`~/.copilot/session-state`, including an empty one closed with `session/close`.
+A refresh followed by a sign-in check against the real CLI left no discovery
+session there; two discoveries against Copilot CLI 1.0.105 did not either.
+The login refusal texts are not pinned to the real CLI: 1.0.105's session/new
+lists models even with an invalid `COPILOT_GITHUB_TOKEN`, so the probe could
+not provoke one without a prompt. GitHub documents ACP support in Copilot CLI as public preview. Its ACP
+server reference does not document model selection; the driver relies on the
+`model` config option the CLI advertises.
diff --git a/scripts/control-omb.ts b/scripts/control-omb.ts
index 6903fc5b72..69535a9ab8 100644
--- a/scripts/control-omb.ts
+++ b/scripts/control-omb.ts
@@ -252,7 +252,7 @@ export async function launchVerificationServer(
enterprise?: { dir: string; licenseKey: string },
room?: { scripted: boolean },
/** Optional repository-owned fake providers for multi-engine setup checks. */
- extraProviders: Array<"codex" | "cline"> = [],
+ extraProviders: Array<"codex" | "cline" | "copilot" | "customAcp"> = [],
/** Programmatic tests only: an owned loopback Boat provider, never a live account. */
boatFixtureApi?: string,
/** Programmatic web UI qualification against the fixture's static server. */
@@ -299,6 +299,16 @@ export async function launchVerificationServer(
environment: { CLINE_PROVIDER: "openai-compatible", CLINE_MODEL: "fixture-model", CLINE_API_KEY: "fixture-only",
FAKE_ACP_DUMP: join(dataDir, "cline-launch.json") },
} } : {}),
+ ...(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") },
+ } } : {}),
+ ...(extraProviders.includes("customAcp") ? { myAgent: {
+ driver: "customAcp", displayName: "Verification custom ACP",
+ config: { cli: fileURLToPath(new URL("../server/testing/fake-acp-cli.ts", import.meta.url)) },
+ environment: { FAKE_ACP_MODELS: "fixture-fast,fixture-deep", FAKE_ACP_DUMP: join(dataDir, "custom-acp-launch.json") },
+ } } : {}),
claude: {
driver: "claudeAgent",
displayName: "Verification fixture",
diff --git a/scripts/testing/automations-journey.ui.e2e.test.ts b/scripts/testing/automations-journey.ui.e2e.test.ts
index fa2477651c..61a8bec9c7 100644
--- a/scripts/testing/automations-journey.ui.e2e.test.ts
+++ b/scripts/testing/automations-journey.ui.e2e.test.ts
@@ -413,7 +413,7 @@ process.env.FAKE_CLAUDE_MODE ??= "happy";
await import(${JSON.stringify(pathToFileURL(join(ROOT, "server", "testing", "fake-claude-cli.ts")).href)});
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({ language: "en", instances: {
- ...Object.fromEntries(["cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli: claude }, environment: { FAKE_CLAUDE_ROOM_PLAN: planPath } },
} }));
const port = await freePortBlock([0, 1]);
diff --git a/scripts/testing/cloud-send-fixture.ts b/scripts/testing/cloud-send-fixture.ts
index c302b3f644..ad393bfada 100644
--- a/scripts/testing/cloud-send-fixture.ts
+++ b/scripts/testing/cloud-send-fixture.ts
@@ -198,7 +198,7 @@ ${engine}
await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-claude-cli.ts")).href)});
`, { mode: 0o755 });
if (!existsSync(join(dataDir, "config.json"))) writeFileSync(join(dataDir, "config.json"), JSON.stringify({ instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
} }));
const offline = `data:text/javascript,${encodeURIComponent('const real = globalThis.fetch; globalThis.fetch = async (url, init) => String(url).startsWith("http://127.0.0.1:") ? real(url, init) : new Response("offline fixture", { status: 503 });')}`;
diff --git a/scripts/testing/file-size-ratchet.test.ts b/scripts/testing/file-size-ratchet.test.ts
index e4f9d87d4d..9fc1d790da 100644
--- a/scripts/testing/file-size-ratchet.test.ts
+++ b/scripts/testing/file-size-ratchet.test.ts
@@ -27,7 +27,7 @@ const LINES: Record<string, number> = {
"server/routines.ts": 1589,
"src/components/ComputerPanel.tsx": 1823,
"src/components/RoutineCalendarPage.tsx": 1744,
- "server/config.ts": 1363,
+ "server/config.ts": 1301,
"src/components/ChatView.tsx": 1316,
"server/routine-requests.ts": 1484,
"src/components/GroupView.tsx": 1225,
diff --git a/scripts/verify-engines-ui.ts b/scripts/verify-engines-ui.ts
index c335535a87..135b3edee9 100644
--- a/scripts/verify-engines-ui.ts
+++ b/scripts/verify-engines-ui.ts
@@ -32,6 +32,7 @@ const instances: InstanceInfo[] = [
["qwen", "qwenAgent", "Qwen", false, ""],
["pi", "piAgent", "Pi", false, ""],
["deepseek", "deepseekAgent", "DeepSeek Harness", false, ""],
+ ["githubCopilot", "copilotAgent", "GitHub Copilot", true, "1.0.103"],
].map(([id, driver, name, ready, version]) => ({
instanceId: String(id), driverKind: String(driver), displayName: String(name),
cliDefault: String(id),
diff --git a/server/agents-bridge-switch.test.ts b/server/agents-bridge-switch.test.ts
index 092634f185..119e0120dd 100644
--- a/server/agents-bridge-switch.test.ts
+++ b/server/agents-bridge-switch.test.ts
@@ -135,7 +135,7 @@ describe("which engines a turn is bridged on", () => {
it.each([
// ACP agents keep their own permissions, Grok among them
- ["grokAgent"], ["geminiAgent"], ["qwenAgent"], ["kimiAgent"], ["droidAgent"], ["cursorAgent"], ["clineAgent"], ["hermesAgent"],
+ ["grokAgent"], ["geminiAgent"], ["qwenAgent"], ["kimiAgent"], ["droidAgent"], ["cursorAgent"], ["clineAgent"], ["copilotAgent"], ["hermesAgent"],
["opencodeGo"], ["antigravityAgent"], ["customAcp"],
// not shown to qualify, and anything nobody has heard of
["museCode"], ["someFutureDriver"], [""],
diff --git a/server/claude-account-api.test.ts b/server/claude-account-api.test.ts
index ee0b73e15c..48206f233b 100644
--- a/server/claude-account-api.test.ts
+++ b/server/claude-account-api.test.ts
@@ -84,7 +84,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
ghost: { driver: "not-a-real-driver", displayName: "Preserved shadow" },
// The `claude` product fleet auto-adds these IDs unless configured.
// Pin shadows so this test never probes an installed provider CLI.
- ...Object.fromEntries(["cursor", "openaiCompat", "qwen", "hermes", "pi"].map(id => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map(id => [id, { driver: "not-a-real-driver" }])),
"broken-account": {
driver: "claudeAgent", displayName: "Repairable shadow", config: { cli, configDir: "relative/saved-directory" },
},
diff --git a/server/cli-probe-env.test.ts b/server/cli-probe-env.test.ts
index aa0d94894c..60b1312c99 100644
--- a/server/cli-probe-env.test.ts
+++ b/server/cli-probe-env.test.ts
@@ -69,7 +69,7 @@ else if (args.at(-1) === "--version") console.log("9.9.9 (Claude Code)");
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
// Pin the fleet's other defaults so this never probes an installed CLI.
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "mistral", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "mistral", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli: stubCli() } },
},
}));
diff --git a/server/cloud-connected-apps.e2e.test.ts b/server/cloud-connected-apps.e2e.test.ts
index 2304c97fc6..b9db2ff99e 100644
--- a/server/cloud-connected-apps.e2e.test.ts
+++ b/server/cloud-connected-apps.e2e.test.ts
@@ -137,7 +137,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
},
}));
diff --git a/server/cloud-credit.e2e.test.ts b/server/cloud-credit.e2e.test.ts
index a5d9dc80f9..8db3bbbd37 100644
--- a/server/cloud-credit.e2e.test.ts
+++ b/server/cloud-credit.e2e.test.ts
@@ -138,7 +138,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
writeFileSync(join(data, "config.json"), JSON.stringify({
instances: {
// Pin the fleet's other defaults so this never probes an installed CLI.
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
},
}));
diff --git a/server/cloud-guest-shell.e2e.test.ts b/server/cloud-guest-shell.e2e.test.ts
index 0ab5f6b5ae..88da718912 100644
--- a/server/cloud-guest-shell.e2e.test.ts
+++ b/server/cloud-guest-shell.e2e.test.ts
@@ -88,7 +88,7 @@ process.env.FAKE_CLAUDE_VERSION = "2.1.284";
if (process.argv[2] !== "--version") { process.env.FAKE_CLAUDE_DUMP = ${JSON.stringify(home)} + "/${name}.json"; process.env.FAKE_CLAUDE_MODE = "hang"; process.env.FAKE_CLAUDE_RELEASE = ${JSON.stringify(join(home, "release"))}; }`);
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
- ...Object.fromEntries(["cursor", "openaiCompat", "qwen", "hermes", "pi", "claude"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi", "claude"].map((id) => [id, { driver: "not-a-real-driver" }])),
codex: { driver: "codex", displayName: "Codex", config: { cli: codex } },
held: { driver: "claudeAgent", displayName: "Held", config: { cli: held("claude") } },
teammate: { driver: "claudeAgent", displayName: "Teammate", config: { cli: held("teammate") } },
diff --git a/server/cloud-home-server.test.ts b/server/cloud-home-server.test.ts
index 9f8978a640..b94b443bca 100644
--- a/server/cloud-home-server.test.ts
+++ b/server/cloud-home-server.test.ts
@@ -83,7 +83,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
// Pin the fleet's other defaults so this never probes an installed CLI.
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
},
}));
diff --git a/server/cloud-lending-browser.e2e.test.ts b/server/cloud-lending-browser.e2e.test.ts
index c2ed63cfb7..3b4220f561 100644
--- a/server/cloud-lending-browser.e2e.test.ts
+++ b/server/cloud-lending-browser.e2e.test.ts
@@ -141,7 +141,7 @@ if (process.argv[2] !== "--version") { process.env.FAKE_CLAUDE_DUMP = ${JSON.str
await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-claude-cli.ts")).href)});
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({ instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
} }));
chmodSync(cli, 0o755);
diff --git a/server/cloud-lending-chrome.e2e.test.ts b/server/cloud-lending-chrome.e2e.test.ts
index 9ac2448afb..ebfc9d762d 100644
--- a/server/cloud-lending-chrome.e2e.test.ts
+++ b/server/cloud-lending-chrome.e2e.test.ts
@@ -85,7 +85,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
`, { mode: 0o755 });
chmodSync(cli, 0o755);
writeFileSync(join(dataDir, "config.json"), JSON.stringify({ instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
} }));
const port = await freePortBlock([0, 1]);
diff --git a/server/cloud-lending-memory.e2e.test.ts b/server/cloud-lending-memory.e2e.test.ts
index fcce55e764..0ae5f6285d 100644
--- a/server/cloud-lending-memory.e2e.test.ts
+++ b/server/cloud-lending-memory.e2e.test.ts
@@ -187,7 +187,7 @@ await import(${JSON.stringify(fake)});
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
memory: { captureQuietMs: 1_000 },
instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi", "claude"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi", "claude"].map((id) => [id, { driver: "not-a-real-driver" }])),
held: { driver: "claudeAgent", displayName: "Held", config: { cli: held } },
done: { driver: "claudeAgent", displayName: "Done", config: { cli: done } },
brief: { driver: "claudeAgent", displayName: "Brief", config: { cli: brief } },
diff --git a/server/cloud-lending.e2e.test.ts b/server/cloud-lending.e2e.test.ts
index 1fa4e56833..4399580f95 100644
--- a/server/cloud-lending.e2e.test.ts
+++ b/server/cloud-lending.e2e.test.ts
@@ -128,7 +128,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
`, { mode: 0o755 });
// No `features` block: the maintainer flag is off, as on every Cloud home.
writeFileSync(join(dataDir, "config.json"), JSON.stringify({ instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
// A model that uses the Mac, asks a question, and uses it again once the
// card is answered (fake-acp-cli.ts "lend-question").
diff --git a/server/cloud-onepassword.e2e.test.ts b/server/cloud-onepassword.e2e.test.ts
index 1179fa3d40..4f07306f15 100644
--- a/server/cloud-onepassword.e2e.test.ts
+++ b/server/cloud-onepassword.e2e.test.ts
@@ -144,7 +144,7 @@ if (process.argv[2] !== "--version") { process.env.FAKE_CLAUDE_DUMP = ${JSON.str
await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-claude-cli.ts")).href)});
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({ instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
} }));
const port = await freePortBlock([0, 1]);
diff --git a/server/cloud-personal.e2e.test.ts b/server/cloud-personal.e2e.test.ts
index 5711b1d045..677e3bb2dd 100644
--- a/server/cloud-personal.e2e.test.ts
+++ b/server/cloud-personal.e2e.test.ts
@@ -113,7 +113,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi", "claude"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi", "claude"].map((id) => [id, { driver: "not-a-real-driver" }])),
held: { driver: "claudeAgent", displayName: "Held", config: { cli } },
},
}));
diff --git a/server/cloud-routine-level.e2e.test.ts b/server/cloud-routine-level.e2e.test.ts
index 0bb53cfb6e..34f97e8bcb 100644
--- a/server/cloud-routine-level.e2e.test.ts
+++ b/server/cloud-routine-level.e2e.test.ts
@@ -78,7 +78,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-co
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
- ...Object.fromEntries(["cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli: claude } },
codex: { driver: "codex", displayName: "Codex", config: { cli: codex } },
},
diff --git a/server/cloud-sharing.e2e.test.ts b/server/cloud-sharing.e2e.test.ts
index 11f9460433..f61c030a61 100644
--- a/server/cloud-sharing.e2e.test.ts
+++ b/server/cloud-sharing.e2e.test.ts
@@ -142,7 +142,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
},
}));
diff --git a/server/cloud-sync.e2e.test.ts b/server/cloud-sync.e2e.test.ts
index e29759d12f..377ea10a4b 100644
--- a/server/cloud-sync.e2e.test.ts
+++ b/server/cloud-sync.e2e.test.ts
@@ -67,7 +67,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
},
}));
diff --git a/server/cloud-team-admin.e2e.test.ts b/server/cloud-team-admin.e2e.test.ts
index 5381fe9a04..1fa6122075 100644
--- a/server/cloud-team-admin.e2e.test.ts
+++ b/server/cloud-team-admin.e2e.test.ts
@@ -43,7 +43,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
},
treg: { key: "treg-key-never-shown" },
diff --git a/server/config.ts b/server/config.ts
index 5f1dba3063..8dc31c82e6 100644
--- a/server/config.ts
+++ b/server/config.ts
@@ -13,6 +13,8 @@ import { newBotDefaultsSchema, type NewBotDefaults } from "./new-bot-defaults.ts
import { replaySettings } from "./replay-settings.ts";
import { EFFORT_LEVELS, type EffortLevel } from "../shared/wire.ts";
import { isModelVariant, type InstanceConfigMap, type McpServerSpec, type ModelSelection } from "./contracts.ts";
+import { API_KEY_FLEET, DEFAULT_FLEET, OPENAI_API_INSTANCE, OPENROUTER_API_INSTANCE, CLAUDE_API_INSTANCE, PRODUCT_FLEET_ADDITIONS } from "./instance-fleets.ts";
+export { CLAUDE_API_INSTANCE, OPENAI_API_INSTANCE, OPENROUTER_API_INSTANCE, XAI_API_INSTANCE } from "./instance-fleets.ts";
import { DEFAULT_WINDOW_MINUTES, MAX_WINDOW_MINUTES } from "./cache-keepwarm.ts";
import { PROVIDER_ICON_PRESETS, providerIconError } from "../shared/provider-icon.ts";
import { helperStoredShape, type HelperConfig } from "./side-jobs.ts";
@@ -1204,71 +1206,7 @@ function injectedEnvironment(cfg: AppConfig, instanceId: string, driver: string)
return environment;
}
-export const OPENAI_API_INSTANCE = "openai";
-export const OPENROUTER_API_INSTANCE = "openrouter";
-export const XAI_API_INSTANCE = "xaiApi";
-export const CLAUDE_API_INSTANCE = "claudeApi";
-const API_KEY_FLEET: InstanceConfigMap = {
- [OPENAI_API_INSTANCE]: {
- driver: "openai-compat", displayName: "OpenAI", access: "api", icon: { kind: "preset", preset: "openai" },
- config: { url: "https://api.openai.com/v1", apiKeyEnv: "OMB_OPENAI_API_KEY", catalog: "openai" },
- },
- [CLAUDE_API_INSTANCE]: {
- driver: "claudeAgent", displayName: "Claude (API key)", access: "api", icon: { kind: "preset", preset: "anthropic" },
- config: { requireApiKey: true },
- },
- [XAI_API_INSTANCE]: { driver: "grok", displayName: "xAI", access: "api", icon: { kind: "preset", preset: "xai" } },
- [OPENROUTER_API_INSTANCE]: {
- driver: "openai-compat", displayName: "OpenRouter", access: "api", icon: { kind: "preset", preset: "openrouter" },
- config: { url: "https://openrouter.ai/api/v1", apiKeyEnv: "OMB_OPENROUTER_API_KEY" },
- },
-};
-
export function instanceConfigs(cfg: AppConfig): InstanceConfigMap {
- // Google retired Gemini CLI for the free/Pro/Ultra tiers on 2026-06-18; enterprise licences restore it with
- // `{"instances": {"gemini": {"driver": "geminiAgent"}}}`.
- const DEFAULT_FLEET: InstanceConfigMap = {
- grok: { driver: "grokAgent" },
- kimi: { driver: "kimiAgent" },
- droid: { driver: "droidAgent" },
- cursor: { driver: "cursorAgent" },
- claude: { driver: "claudeAgent" },
- codex: { driver: "codex" },
- chatgpt: { driver: "codex", displayName: "ChatGPT plan", config: { authMode: "chatgpt-plan" } },
- antigravity: { driver: "antigravityAgent" },
- opencodeGo: { driver: "opencodeGo" },
- openaiCompat: { driver: "openai-compat" },
- mistral: { driver: "mistral" },
- cerebras: { driver: "cerebras" },
- groq: { driver: "groq" },
- meta: { driver: "meta" },
- deepseek: { driver: "deepseekAgent" },
- museCode: { driver: "museCode" },
- ...API_KEY_FLEET,
- qwen: { driver: "qwenAgent" },
- hermes: { driver: "hermesAgent" },
- cline: { driver: "clineAgent" },
- pi: { driver: "piAgent" },
- };
- const CUSTOM_ONLY = {
- qwen: { driver: "qwenAgent" },
- hermes: { driver: "hermesAgent" },
- cline: { driver: "clineAgent" },
- pi: { driver: "piAgent" },
- } as const;
- const PRODUCT_FLEET_ADDITIONS = {
- chatgpt: { driver: "codex", displayName: "ChatGPT plan", config: { authMode: "chatgpt-plan" } },
- cursor: { driver: "cursorAgent" },
- openaiCompat: { driver: "openai-compat" },
- mistral: { driver: "mistral" },
- cerebras: { driver: "cerebras" },
- groq: { driver: "groq" },
- meta: { driver: "meta" },
- deepseek: { driver: "deepseekAgent" },
- museCode: { driver: "museCode" },
- ...API_KEY_FLEET,
- ...CUSTOM_ONLY,
- } as const;
const configured = cfg.instances && Object.keys(cfg.instances).length ? cfg.instances : null;
const map: InstanceConfigMap = withoutComputerEngine(configured ? { ...configured } : { ...DEFAULT_FLEET });
if (
diff --git a/server/copilot-engine.e2e.test.ts b/server/copilot-engine.e2e.test.ts
new file mode 100644
index 0000000000..45b4a454cb
--- /dev/null
+++ b/server/copilot-engine.e2e.test.ts
@@ -0,0 +1,73 @@
+import { existsSync, readFileSync } from "node:fs";
+import { join } from "node:path";
+import { expect, it } from "vitest";
+import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";
+
+it("moves one bot and one conversation between Claude, GitHub Copilot and a custom ACP agent through the picker's routes", async () => {
+ const fixture = await launchVerificationServer({}, undefined, undefined, undefined, undefined, undefined, ["copilot", "customAcp"]);
+ const { url, dataDir } = fixture.info;
+ const api = async (method: string, path: string, body?: unknown, status = 200) => {
+ 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(status);
+ return result;
+ };
+ const cli = (...args: string[]) => runControlOmb([...args, "--url", url]) as Promise<any>;
+ const prompts = (file: string) => {
+ const path = join(dataDir, `${file}.prompts.jsonl`);
+ return existsSync(path) ? readFileSync(path, "utf8").trim().split("\n").filter(Boolean).map((line) => JSON.parse(line)) : [];
+ };
+ const turn = async (botId: string, threadId: string, text: string) => {
+ await cli("send", "--bot", botId, "--task", threadId, "--text", text);
+ expect((await cli("wait", "--bot", botId, "--task", threadId, "--timeout", "25")).status).toBe("settled");
+ };
+ try {
+ const copilot = (await api("POST", "/api/instances/githubCopilot/refresh-models", {})).instances
+ .find((entry: any) => entry.instanceId === "githubCopilot");
+ expect(copilot).toMatchObject({ driverKind: "copilotAgent", access: "subscription", snapshot: { state: "available" } });
+ expect(copilot.snapshot.authenticated).toBe(true);
+ expect(copilot.models.options.map((option: any) => option.id)).toEqual(["auto", "claude-haiku-4.5", "gpt-5.6-luna"]);
+ const custom = (await api("POST", "/api/instances/myAgent/refresh-models", {})).instances
+ .find((entry: any) => entry.instanceId === "myAgent");
+ expect(custom.models.options).toEqual(expect.arrayContaining([
+ expect.objectContaining({ id: "agent-default", custom: true }), expect.objectContaining({ id: "fixture-deep", custom: true }),
+ ]));
+ for (const starter of (await api("GET", "/api/bots")).bots.filter((bot: any) => bot.chiefOfStaff)) {
+ await api("PATCH", `/api/bots/${starter.id}`, { chiefOfStaff: false });
+ }
+ const bot = (await cli("new-bot", "--name", "Engine hopper")).bot;
+ const thread: string = bot.activeTaskId ?? bot.threadId;
+ const claude = bot.modelSelection;
+ expect(claude.instanceId).toBe("claude");
+ await turn(bot.id, thread, "on claude");
+
+ // The bot's own engine, as the picker saves it with no conversation open.
+ await api("PATCH", `/api/bots/${bot.id}`, { modelSelection: { instanceId: "githubCopilot", model: "gpt-5.6-luna" } });
+ await turn(bot.id, thread, "on copilot");
+ expect(prompts("copilot-launch.json").at(-1)).toMatchObject({ model: "gpt-5.6-luna" });
+ // The strict route checks the id against the refreshed catalog.
+ await api("PATCH", `/api/bots/${bot.id}/model`, { instanceId: "githubCopilot", model: "claude-haiku-4.5" });
+ await api("PATCH", `/api/bots/${bot.id}/model`, { instanceId: "githubCopilot", model: "not-offered" }, 400);
+ await turn(bot.id, thread, "on haiku");
+ expect(prompts("copilot-launch.json").at(-1)).toMatchObject({ model: "claude-haiku-4.5" });
+
+ // One conversation, as the picker saves it with that conversation open.
+ await api("PATCH", `/api/bots/${bot.id}/tasks/${thread}`, { modelSelection: { instanceId: "myAgent", model: "fixture-deep" } });
+ await turn(bot.id, thread, "on custom");
+ expect(prompts("custom-acp-launch.json").at(-1)).toMatchObject({ model: "fixture-deep" });
+
+ await api("PATCH", `/api/bots/${bot.id}/tasks/${thread}`, { modelSelection: claude });
+ const copilotTurns = prompts("copilot-launch.json").length, customTurns = prompts("custom-acp-launch.json").length;
+ await turn(bot.id, thread, "back on claude");
+ expect(prompts("copilot-launch.json")).toHaveLength(copilotTurns);
+ expect(prompts("custom-acp-launch.json")).toHaveLength(customTurns);
+ await api("PATCH", `/api/bots/${bot.id}`, { modelSelection: claude });
+ const saved = (await api("GET", "/api/bots")).bots.find((row: any) => row.id === bot.id);
+ expect(saved.modelSelection).toMatchObject({ instanceId: "claude", model: claude.model });
+ const messages = (await api("GET", `/api/threads/${thread}/messages?limit=50`)).messages;
+ expect(messages.filter((message: any) => message.role === "bot" && message.text?.includes("hello from fake acp")).length).toBeGreaterThanOrEqual(3);
+ } finally {
+ await fixture.close();
+ }
+}, 120_000);
diff --git a/server/drivers/acp/copilot.test.ts b/server/drivers/acp/copilot.test.ts
new file mode 100644
index 0000000000..b8e3569ecf
--- /dev/null
+++ b/server/drivers/acp/copilot.test.ts
@@ -0,0 +1,293 @@
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { dirname, join, sep } from "node:path";
+import { fileURLToPath } from "node:url";
+import { afterEach, beforeEach, describe, expect, it, vi } 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 {
+ classifyCopilotError, CopilotAgentDriver, copilotModelLabel, copilotSignedIn, forgetCopilotDiscoverySession, resolveCopilotModels,
+} from "./copilot.ts";
+
+const FAKE_CLI = join(dirname(fileURLToPath(import.meta.url)), "../../testing/fake-acp-cli.ts");
+// The session opens on the first model, as Copilot CLI opens on the person's last terminal pick, not on Auto.
+const MODELS = "claude-haiku-4.5,auto,gpt-5.6-luna";
+const VARIANTS = JSON.stringify({
+ "claude-haiku-4.5": { id: "reasoning_effort", currentValue: "medium", options: [{ value: "low", name: "low" }, { value: "medium", name: "medium" }] },
+});
+const NO_TOKENS = { COPILOT_GITHUB_TOKEN: "", GH_TOKEN: "", GITHUB_TOKEN: "" };
+const PROBE_WAIT = 30_000;
+
+describe("GitHub Copilot ACP driver", () => {
+ let scratch: string;
+ let instance: ProviderInstance | undefined;
+ let recorder: EventRecorder | undefined;
+
+ beforeEach(() => {
+ ensureDirs();
+ scratch = mkdtempSync(join(tmpdir(), "omb-copilot-contract-"));
+ });
+ afterEach(async () => {
+ recorder?.stop();
+ await instance?.dispose();
+ instance = undefined;
+ recorder = undefined;
+ vi.unstubAllEnvs();
+ vi.restoreAllMocks();
+ await removeTempDir(scratch);
+ });
+
+ 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 },
+ 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));
+ /** Each probe is its own process; the fake appends one line per request with its pid. */
+ const probe = (name: string, extra: Record<string, string> = {}) => {
+ const rpc = join(scratch, `${name}.rpc.jsonl`);
+ return {
+ env: { ...process.env, ...NO_TOKENS, FAKE_ACP_MODELS: MODELS, FAKE_ACP_RPC_APPEND_FILE: rpc, COPILOT_HOME: join(scratch, name), ...extra },
+ launches: () => existsSync(rpc) ? new Set(readFileSync(rpc, "utf8").trim().split("\n").map((line) => JSON.parse(line))
+ .filter((entry) => entry.method === "initialize").map((entry) => entry.pid)).size : 0,
+ };
+ };
+
+ it("is a built-in engine in fresh and existing fleets, beside a person's own custom Copilot instance", () => {
+ expect(BUILT_IN_DRIVERS.some((driver) => driver.driverKind === "copilotAgent")).toBe(true);
+ expect(instanceConfigs({}).githubCopilot?.driver).toBe("copilotAgent");
+ const existing = instanceConfigs({ instances: {
+ claude: { driver: "claudeAgent" },
+ copilot: { driver: "customAcp", config: { cli: "copilot --acp --stdio" } },
+ } });
+ expect(existing.githubCopilot?.driver).toBe("copilotAgent");
+ expect(existing.copilot?.driver).toBe("customAcp");
+ expect(CopilotAgentDriver.metadata.access).toBe("subscription");
+ expect(CopilotAgentDriver.models).toEqual({ default: "auto", options: [{ id: "auto", label: "Auto" }] });
+ });
+
+ it("lists the advertised models with Auto as the default and each model's own effort levels, without a prompt", async () => {
+ const catalog = await resolveCopilotModels(probe("catalog", { FAKE_ACP_VARIANTS: VARIANTS }).env, { cli: FAKE_CLI });
+ expect(catalog.default).toBe("auto");
+ expect(catalog.options.map((option) => option.id)).toEqual(["claude-haiku-4.5", "auto", "gpt-5.6-luna"]);
+ expect(catalog.options.some((option) => option.custom)).toBe(false);
+ expect(catalog.options.find((option) => option.id === "claude-haiku-4.5")?.variants).toEqual([
+ { id: "low", label: "low" }, { id: "medium", label: "medium" },
+ ]);
+ });
+
+ it("labels a model with its premium request multiplier and ignores anything else in _meta", () => {
+ const sessionNew = { configOptions: [{ id: "model", type: "select", category: "model", options: [
+ { value: "claude-haiku-4.5", name: "Claude Haiku 4.5", _meta: { copilotUsage: "0.33x" } },
+ { value: "odd", name: "Odd", _meta: { copilotUsage: "<b>free</b>" } },
+ { value: "auto", name: "Auto", _meta: null },
+ ] }] };
+ expect(copilotModelLabel({ id: "claude-haiku-4.5", label: "Claude Haiku 4.5" }, sessionNew)).toBe("Claude Haiku 4.5 · 0.33x");
+ expect(copilotModelLabel({ id: "odd", label: "Odd" }, sessionNew)).toBe("Odd");
+ expect(copilotModelLabel({ id: "auto", label: "Auto" }, sessionNew)).toBe("Auto");
+ expect(copilotModelLabel({ id: "auto", label: "Auto" }, null)).toBe("Auto");
+ });
+
+ it("tells a missing login apart from a reachable agent", async () => {
+ const out = probe("signed-out", { FAKE_ACP_MODE: "auth-required" });
+ expect(await copilotSignedIn(out.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(false);
+ expect(await copilotSignedIn(probe("signed-in").env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(true);
+ // Only a refusal that names the login proves it missing; the turn reports anything else.
+ expect(await copilotSignedIn(probe("unreachable").env, { cli: join(scratch, "missing-copilot") }, PROBE_WAIT)).toBe(true);
+ const failure = join(scratch, "session-new-error.json");
+ writeFileSync(failure, JSON.stringify({ code: -32000, message: "session already active in this agent" }));
+ const busy = probe("busy", { FAKE_ACP_RPC_FAILURE_METHOD: "session/new", FAKE_ACP_RPC_FAILURE_FILE: failure });
+ expect(await copilotSignedIn(busy.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(true);
+ expect(busy.launches()).toBe(1);
+ });
+
+ it("asks the CLI about a token in the environment too, and again once the token changes", async () => {
+ const expired = probe("token", { FAKE_ACP_MODE: "auth-required", COPILOT_GITHUB_TOKEN: "expired-fixture-token" });
+ expect(await copilotSignedIn(expired.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(false);
+ expect(expired.launches()).toBe(1);
+ const renewed = { ...expired.env, FAKE_ACP_MODE: "happy", COPILOT_GITHUB_TOKEN: "renewed-fixture-token" };
+ expect(await copilotSignedIn(renewed, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(true);
+ expect(expired.launches()).toBe(2);
+ });
+
+ it("keys the sign-in answer on the Copilot home the CLI would use, HOME included", async () => {
+ const { COPILOT_HOME: _unset, ...base } = probe("by-home", { FAKE_ACP_MODE: "auth-required" }).env;
+ const homeVar = process.platform === "win32" ? "USERPROFILE" : "HOME";
+ const first = { ...base, [homeVar]: join(scratch, "home-a") };
+ expect(await copilotSignedIn(first, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(false);
+ const second = { ...base, FAKE_ACP_MODE: "happy", [homeVar]: join(scratch, "home-b") };
+ expect(await copilotSignedIn(second, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(true);
+ });
+
+ it("starts one probe for concurrent and repeated checks, and none after a catalog refresh", async () => {
+ const shared = probe("shared");
+ const answers = await Promise.all([1, 2, 3].map(() => copilotSignedIn(shared.env, { cli: FAKE_CLI }, PROBE_WAIT)));
+ expect(answers).toEqual([true, true, true]);
+ expect(await copilotSignedIn(shared.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(true);
+ expect(shared.launches()).toBe(1);
+ const refreshed = probe("refreshed");
+ await resolveCopilotModels(refreshed.env, { cli: FAKE_CLI });
+ expect(await copilotSignedIn(refreshed.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(true);
+ expect(refreshed.launches()).toBe(1);
+ });
+
+ it("checks a missing login again after a minute, not on every snapshot", async () => {
+ const out = probe("expiring", { FAKE_ACP_MODE: "auth-required" });
+ const now = Date.now();
+ const clock = vi.spyOn(Date, "now").mockReturnValue(now);
+ expect(await copilotSignedIn(out.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(false);
+ await new Promise((resolve) => setImmediate(resolve));
+ clock.mockReturnValue(now + 30_000);
+ expect(await copilotSignedIn(out.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(false);
+ expect(out.launches()).toBe(1);
+ clock.mockReturnValue(now + 61_000);
+ expect(await copilotSignedIn(out.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(false);
+ expect(out.launches()).toBe(2);
+ });
+
+ it("keeps a failure that says nothing about the login for seconds, not minutes", async () => {
+ const failure = join(scratch, "unproven-error.json");
+ writeFileSync(failure, JSON.stringify({ code: -32603, message: "internal error" }));
+ const flaky = probe("unproven", { FAKE_ACP_RPC_FAILURE_METHOD: "session/new", FAKE_ACP_RPC_FAILURE_FILE: failure });
+ const now = Date.now();
+ const clock = vi.spyOn(Date, "now").mockReturnValue(now);
+ expect(await copilotSignedIn(flaky.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(true);
+ await new Promise((resolve) => setImmediate(resolve));
+ clock.mockReturnValue(now + 10_000);
+ expect(await copilotSignedIn(flaky.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(true);
+ expect(flaky.launches()).toBe(1);
+ clock.mockReturnValue(now + 16_000);
+ expect(await copilotSignedIn(flaky.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(true);
+ expect(flaky.launches()).toBe(2);
+ });
+
+ it("answers within the wait from the last probe while a hung one runs on, and offers the engine before any answer", async () => {
+ const slow = probe("slow", { FAKE_ACP_MODE: "auth-required" });
+ const now = Date.now();
+ const clock = vi.spyOn(Date, "now").mockReturnValue(now);
+ expect(await copilotSignedIn(slow.env, { cli: FAKE_CLI }, PROBE_WAIT)).toBe(false);
+ await new Promise((resolve) => setImmediate(resolve));
+ clock.mockReturnValue(now + 61_000);
+ // The next probe never gets past initialize, as with a `copilot` on PATH that does not speak ACP.
+ const hung = { ...slow.env, FAKE_ACP_MODE: "hang-initialize" };
+ expect(await copilotSignedIn(hung, { cli: FAKE_CLI }, 50)).toBe(false);
+ expect(await copilotSignedIn(hung, { cli: FAKE_CLI }, 50)).toBe(false);
+ const never = probe("never-answered", { FAKE_ACP_MODE: "hang-initialize" });
+ expect(await copilotSignedIn(never.env, { cli: FAKE_CLI }, 50)).toBe(true);
+ await Promise.all([copilotSignedIn(hung, { cli: FAKE_CLI }, PROBE_WAIT), copilotSignedIn(never.env, { cli: FAKE_CLI }, PROBE_WAIT)]);
+ expect([slow.launches(), never.launches()]).toEqual([2, 1]);
+ }, 60_000);
+
+ it("starts nothing when the instance is created, so a `copilot` on PATH costs no launch", async () => {
+ await create();
+ expect(existsSync(join(scratch, "launch.json"))).toBe(false);
+ expect(instance!.models.default).toBe("auto");
+ });
+
+ it("removes only the session folder the discovery itself left behind", async () => {
+ const home = join(scratch, "copilot-home");
+ // The fields and their plain-scalar style are Copilot CLI 1.0.105's own workspace.yaml.
+ const session = (id: string, cwd: string, client = "openmausbot-model-discovery") => {
+ mkdirSync(join(home, "session-state", id, "checkpoints"), { recursive: true });
+ writeFileSync(join(home, "session-state", id, "workspace.yaml"), `id: ${id}\ncwd: ${cwd}\nclient_name: ${client}\nuser_named: false\n`
+ + "summary_count: 0\nfork_count: 0\ncreated_at: 2026-10-28T01:45:38.058Z\nupdated_at: 2026-10-28T01:45:38.116Z\n");
+ return join(home, "session-state", id);
+ };
+ const env = { COPILOT_HOME: home };
+ const ours = session("ours", join(scratch, "omb-acp-models-x"));
+ await forgetCopilotDiscoverySession({ sessionId: "ours", cwd: join(scratch, "omb-acp-models-x"), env });
+ expect(existsSync(ours)).toBe(false);
+ // A quoted value, a trailing separator or (on Windows) another case still names the same folder.
+ const quoted = session("quoted", JSON.stringify(join(scratch, "omb-acp-models-y")));
+ await forgetCopilotDiscoverySession({ sessionId: "quoted", cwd: join(scratch, "omb-acp-models-y"), env });
+ const spelled = session("spelled", `${process.platform === "win32" ? join(scratch, "OMB-ACP-MODELS-Z") : join(scratch, "omb-acp-models-z")}${sep}`);
+ await forgetCopilotDiscoverySession({ sessionId: "spelled", cwd: join(scratch, "omb-acp-models-z"), env });
+ expect([existsSync(quoted), existsSync(spelled)]).toEqual([false, false]);
+ const person = session("person", join(scratch, "project"), "copilot-cli");
+ await forgetCopilotDiscoverySession({ sessionId: "person", cwd: join(scratch, "project"), env });
+ const elsewhere = session("elsewhere", join(scratch, "other"));
+ await forgetCopilotDiscoverySession({ sessionId: "elsewhere", cwd: join(scratch, "omb-acp-models-x"), env });
+ await forgetCopilotDiscoverySession({ sessionId: "../copilot-home", cwd: join(scratch, "omb-acp-models-x"), env });
+ expect([existsSync(person), existsSync(elsewhere), existsSync(home)]).toEqual([true, true, true]);
+ });
+
+ it("reads -32000 as a missing login only when the agent says so", () => {
+ expect(classifyCopilotError({ code: -32000, message: "Authentication required" })).toBe("invalid_credentials");
+ expect(classifyCopilotError({ code: -32000, message: "Not logged in" })).toBe("invalid_credentials");
+ expect(classifyCopilotError({ code: -32000, message: "session already active in this agent" })).toBeUndefined();
+ expect(classifyCopilotError({ code: -32603, message: "auth service unavailable" })).toBeUndefined();
+ expect(classifyCopilotError({ code: -32000, message: "Invalid token" })).toBe("invalid_credentials");
+ expect(classifyCopilotError({ code: -32000, message: "Not signed in. Run `copilot login`." })).toBe("invalid_credentials");
+ for (const message of ["Your GitHub token has expired", "Token expired", "GitHub token is invalid", "Unauthorized", "authentication failed", "Bad credentials"]) {
+ expect(classifyCopilotError({ code: -32000, message }), message).toBe("invalid_credentials");
+ }
+ for (const message of [
+ "prompt exceeds the max tokens for this model", "context window token limit reached", "commit author unknown", "tool not authorized by policy",
+ // Another server's credentials, not the Copilot login.
+ "No token provided for MCP server github", "missing credentials for MCP server foo", "no authentication method configured for MCP server",
+ "MCP server returned 401 Unauthorized", "no auth", "missing credentials",
+ ]) {
+ expect(classifyCopilotError({ code: -32000, message }), message).toBeUndefined();
+ }
+ });
+
+ it("runs the picked model through ACP, never argv, and keeps the broker in charge of permissions", async () => {
+ vi.stubEnv("COPILOT_ALLOW_ALL", "true");
+ vi.stubEnv("GITHUB_TOKEN", "server-wide-fixture-token");
+ const { instance, recorder } = await create({ GH_TOKEN: "engine-fixture-token", copilot_allow_all: "true" });
+ const { turnId } = await instance.adapter.sendTurn({ threadId: "copilot-chat", text: "hello", model: "claude-haiku-4.5", approvalMode: "ask" });
+ 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.env.COPILOT_ALLOW_ALL).toBeUndefined();
+ expect(launch.env.GITHUB_TOKEN).toBeUndefined();
+ expect(launch.env.GH_TOKEN).toBe("engine-fixture-token");
+ expect(prompts().at(-1)).toMatchObject({ model: "claude-haiku-4.5" });
+ });
+
+ it("turns Copilot'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: "copilot-permission", text: "edit", model: "auto", approvalMode: "ask" });
+ const ask = await recorder.until((event) => event.type === "request.opened");
+ expect(ask.provider).toBe("copilotAgent");
+ expect(await instance.adapter.respondToRequest("copilot-permission", ask.requestId!, { behavior: "deny" })).toBe("rejected");
+ await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);
+ expect(readFileSync(answer, "utf8")).toBe("reject");
+ });
+
+ it("switches models between turns of one conversation", async () => {
+ const { instance, recorder } = await create();
+ for (const model of ["gpt-5.6-luna", "claude-haiku-4.5"]) {
+ const { turnId } = await instance.adapter.sendTurn({ threadId: "copilot-switch", text: `on ${model}`, model, approvalMode: "ask" });
+ await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);
+ }
+ expect(prompts().map((entry) => entry.model)).toEqual(["gpt-5.6-luna", "claude-haiku-4.5"]);
+ });
+
+ it("falls back to Auto, with a notice, when the plan no longer offers the saved model", async () => {
+ const { instance, recorder } = await create();
+ const { turnId } = await instance.adapter.sendTurn({ threadId: "copilot-gone", text: "hello", model: "retired-model", approvalMode: "ask" });
+ await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);
+ expect(prompts().at(-1)).toMatchObject({ model: "auto" });
+ expect(recorder.events.some((event) => event.type === "runtime.notice" && /no longer offers retired-model/.test(String((event as { message?: unknown }).message)))).toBe(true);
+ });
+
+ it("reports a missing login as a sign-in step, not a raw RPC error", async () => {
+ const { instance, recorder } = await create({ FAKE_ACP_MODE: "auth-required" });
+ await instance.adapter.sendTurn({ threadId: "copilot-signed-out", text: "hello", model: "auto", approvalMode: "ask" }).catch(() => undefined);
+ const error = await recorder.until((event) => event.type === "runtime.error");
+ expect(String((error as { message?: unknown }).message)).toContain("copilot login");
+ expect(existsSync(join(scratch, "launch.json.prompts.jsonl"))).toBe(false);
+ });
+});
diff --git a/server/drivers/acp/copilot.ts b/server/drivers/acp/copilot.ts
new file mode 100644
index 0000000000..1a6986f3a5
--- /dev/null
+++ b/server/drivers/acp/copilot.ts
@@ -0,0 +1,225 @@
+// GitHub Copilot CLI over ACP (`copilot --acp --stdio`), billed to the signed-in Copilot plan.
+// Copilot CLI 1.0.103 advertises its models as the `model` config option, each with `_meta.copilotUsage`
+// (the premium-request multiplier), and per-model effort as `reasoning_effort`; session/set_config_option
+// validates and confirms both. 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 { 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";
+
+const AUTO = "auto";
+const MODELS: ModelCatalog = { default: AUTO, options: [{ id: AUTO, label: "Auto" }] };
+const SPAWN_ARGS = ["--acp", "--stdio"];
+const SIGN_IN = "copilot login";
+const LOGIN_NOTE = `GitHub Copilot is not signed in. Run ${SIGN_IN} in a terminal, then check again.`;
+/** Precedence order Copilot CLI reads its token from (`copilot login --help`, 1.0.103); each beats the stored login. */
+const TOKEN_ENV = ["COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"] as const;
+const SIGNED_IN_FOR_MS = 5 * 60_000;
+const SIGNED_OUT_FOR_MS = 60_000;
+/** A probe that failed without the agent's word on the login (timeout, crash, wrong binary) proves nothing. */
+const UNPROVEN_FOR_MS = 15_000;
+/** A `copilot` on PATH that never speaks ACP (VS Code's shim) would otherwise block the sign-in check for the
+ * probe's request timeouts. */
+const SIGN_IN_WAIT_MS = 3_000;
+
+function record(value: unknown): Record<string, unknown> | undefined {
+ return value !== null && typeof value === "object" && !Array.isArray(value)
+ ? value as Record<string, unknown> : undefined;
+}
+
+/** "Claude Haiku 4.5 · 0.33x": the multiplier is what a prompt costs in premium requests. */
+export function copilotModelLabel(model: { id: string; label: string }, sessionNew: unknown): string {
+ const configOptions = record(sessionNew)?.configOptions;
+ const option = Array.isArray(configOptions)
+ ? configOptions.map(record).find((entry) => entry?.type === "select" && (entry.id === "model" || entry.category === "model"))
+ : undefined;
+ const values = Array.isArray(option?.options) ? option.options.map(record) : [];
+ const usage = record(values.find((value) => value?.value === model.id)?._meta)?.copilotUsage;
+ return typeof usage === "string" && /^\d+(?:\.\d+)?x$/.test(usage) ? `${model.label} · ${usage}` : model.label;
+}
+
+/** The folder that holds the CLI's account and session state. */
+export function copilotHome(env: Record<string, string | undefined>): string {
+ return env.COPILOT_HOME || join((process.platform === "win32" ? env.USERPROFILE : env.HOME) || homedir(), ".copilot");
+}
+
+/** A workspace.yaml scalar: plain as Copilot CLI 1.0.105 writes it, or quoted. */
+function yamlScalar(value: string): string {
+ const quoted = /^(["'])(.*)\1$/.exec(value);
+ if (!quoted) return value;
+ return quoted[1] === "'" ? quoted[2].replaceAll("''", "'") : quoted[2].replace(/\\(["\\])/g, "$1");
+}
+
+/** The CLI may record the cwd resolved (a symlinked temp dir, a long name for an 8.3 one) or, on Windows, in
+ * another case; both sides are compared in every form they resolve to. */
+async function sameFolder(recorded: string, cwd: string): Promise<boolean> {
+ const forms = async (path: string) => {
+ const all = [resolve(path)];
+ try { all.push(await realpath(path)); } catch {}
+ return all.map((form) => (process.platform === "win32" ? form.toLowerCase() : form));
+ };
+ const ours = new Set(await forms(cwd));
+ return (await forms(recorded)).some((form) => ours.has(form));
+}
+
+/** Copilot CLI 1.0.103 keeps every ACP session, even an empty one closed with session/close, under
+ * `<COPILOT_HOME>/session-state/<id>`, where it would sit in the person's `copilot --resume` list. Only a
+ * folder whose workspace.yaml names this discovery's own temporary cwd and client is removed. */
+export async function forgetCopilotDiscoverySession({ sessionId, cwd, env }: { sessionId: string; cwd: string; env: Record<string, string | undefined> }): Promise<void> {
+ if (!/^[\w-]{1,128}$/.test(sessionId)) return;
+ const folder = join(copilotHome(env), "session-state", sessionId);
+ let workspace: string;
+ try { workspace = await readFile(join(folder, "workspace.yaml"), "utf8"); } catch { return; }
+ const field = (name: string) => {
+ const value = new RegExp(`^${name}:[ \\t]*(.*?)[ \\t]*$`, "m").exec(workspace)?.[1];
+ return value === undefined ? undefined : yamlScalar(value);
+ };
+ const recorded = field("cwd");
+ if (!recorded || field("client_name") !== DISCOVERY_CLIENT_NAME || !(await sameFolder(recorded, cwd))) return;
+ await rm(folder, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
+}
+
+// Copilot CLI gets to exit on its own, releasing its session folder, before forgetSession removes that folder.
+const DISCOVERY: AcpDiscoveryOptions = {
+ default: AUTO, label: copilotModelLabel, exitGraceMs: 2_000, forgetSession: forgetCopilotDiscoverySession,
+};
+
+/** The home holds the CLI's stored login, GH_HOST picks the GitHub it signs in to, and a token in the
+ * environment outranks both; only its digest is kept. */
+const signInKey = (env: Record<string, string | undefined>, cli: string) => {
+ const tokens = createHash("sha256").update(TOKEN_ENV.map((name) => env[name]?.trim() ?? "").join("\0")).digest("hex");
+ return [cli, copilotHome(env), env.GH_HOST ?? "", tokens].join("\0");
+};
+const signIns = new Map<string, { signedIn: Promise<boolean>; until: number }>();
+const lastSignIns = new Map<string, boolean>();
+
+interface SignInAnswer { signedIn: boolean; forMs: number }
+
+/** Shares one probe between concurrent callers, then keeps its answer for as long as it holds. */
+function rememberSignIn(key: string, answer: Promise<SignInAnswer>): Promise<boolean> {
+ const signedIn = answer.then((value) => value.signedIn);
+ signIns.set(key, { signedIn, until: Number.POSITIVE_INFINITY });
+ void answer.then(({ signedIn: value, forMs }) => {
+ lastSignIns.set(key, value);
+ if (signIns.get(key)?.signedIn === signedIn) signIns.set(key, { signedIn, until: Date.now() + forMs });
+ });
+ return signedIn;
+}
+
+/** Only the refusal a turn would also report as a missing login proves one. Any other failure leaves the
+ * engine offered, so the turn reports the real error, but is asked again soon. */
+const signedInAfter = (discovery: Promise<unknown>): Promise<SignInAnswer> => discovery.then(
+ () => ({ signedIn: true, forMs: SIGNED_IN_FOR_MS }),
+ (error) => error instanceof AcpDiscoveryRpcError
+ && classifyCopilotError({ code: error.code, message: error.rpcMessage }) === "invalid_credentials"
+ ? { signedIn: false, forMs: SIGNED_OUT_FOR_MS }
+ : { signedIn: true, forMs: UNPROVEN_FOR_MS });
+
+/** A refresh also answers the sign-in question, so the snapshot after it starts nothing. */
+export function resolveCopilotModels(env: Record<string, string | undefined>, config: Pick<AcpConfig, "cli">): Promise<ModelCatalog> {
+ const catalog = discoverAcpModels(env, config.cli, SPAWN_ARGS, DISCOVERY);
+ void rememberSignIn(signInKey(env, config.cli), signedInAfter(catalog));
+ return catalog;
+}
+
+/** The login sits in the OS credential store or in a token, either of which may have expired, and only the
+ * CLI checks them, so an empty session/new (no prompt, no premium request) answers. */
+export function copilotSignedIn(
+ env: Record<string, string | undefined>, config: Pick<AcpConfig, "cli">, waitMs = SIGN_IN_WAIT_MS,
+): Promise<boolean> {
+ const key = signInKey(env, config.cli);
+ const cached = signIns.get(key);
+ const probe = cached && cached.until > Date.now() ? cached.signedIn
+ : rememberSignIn(key, signedInAfter(discoverAcpModels(env, config.cli, SPAWN_ARGS, { ...DISCOVERY, variants: false })));
+ return new Promise((done) => {
+ const timer = setTimeout(() => done(lastSignIns.get(key) ?? true), waitMs);
+ void probe.then((signedIn) => { clearTimeout(timer); done(signedIn); });
+ });
+}
+
+const QUALIFIER = "(?:github |copilot |oauth |access )";
+/** Whole login phrases: a bare "token" or "auth" would also match "max tokens exceeded" or "author". A missing
+ * credential needs the GitHub/Copilot qualifier, as an MCP server's own key can be missing too. */
+const LOGIN_REFUSAL = new RegExp([
+ String.raw`auth(?:entication|orization)? (?:is )?required`,
+ "unauthenticated",
+ "unauthorized",
+ "authentication failed",
+ String.raw`not (?:logged|signed) ?in`,
+ String.raw`(?:log|sign) ?in (?:is )?required`,
+ String.raw`(?:run|use) .?copilot login`,
+ String.raw`(?:invalid|expired|revoked) ${QUALIFIER}?(?:token|credentials?)`,
+ String.raw`(?:no|missing) ${QUALIFIER}(?:token|credentials?)`,
+ String.raw`(?:token|credentials?) (?:has |have )?expired`,
+ String.raw`(?:token|credentials?) (?:is |are )?(?:invalid|revoked)`,
+ "bad credentials",
+].map((phrase) => String.raw`\b${phrase}\b`).join("|"));
+/** A refusal about an MCP server's credentials is that server's, not the Copilot login's. */
+const MCP_SERVER = /\bmcp\b/;
+
+/** -32000 is ACP's `auth_required`, but some agents reuse it for other failures; the text must agree. */
+export function classifyCopilotError(error: unknown): ProviderErrorCode | undefined {
+ const value = record(error);
+ const text = `${typeof value?.message === "string" ? value.message : ""}`.toLowerCase();
+ return value?.code === -32000 && LOGIN_REFUSAL.test(text) && !MCP_SERVER.test(text) ? "invalid_credentials" : undefined;
+}
+
+export function describeCopilotAccountError(code: AccountErrorCode): string {
+ return code === "invalid_credentials" ? LOGIN_NOTE
+ : "GitHub Copilot refused this request for the signed-in account. Check its Copilot plan and premium request allowance, then try again.";
+}
+
+/** Names compare case-insensitively because Windows environments do. */
+function deleteEnv(env: Record<string, string | undefined>, name: string): void {
+ for (const key of Object.keys(env)) if (key.toUpperCase() === name) delete env[key];
+}
+
+const SUPPORT: AcpSupport = {
+ driverKind: "copilotAgent",
+ displayName: "GitHub Copilot",
+ models: MODELS,
+ defaultCli: "copilot",
+ nativeSource: "copilot.acp",
+ images: true,
+ loginNote: LOGIN_NOTE,
+ install: {
+ command: { darwin: "npm install -g @github/copilot", linux: "npm install -g @github/copilot", win32: "npm install -g @github/copilot" },
+ needsNode: true,
+ docsUrl: "https://docs.github.com/en/copilot/reference/acp-server",
+ signInCommand: SIGN_IN,
+ },
+ spawnArgs: () => SPAWN_ARGS,
+ transformEnv(env, _config, _instanceId, instanceEnvironment) {
+ // COPILOT_ALLOW_ALL would approve every tool without asking the broker.
+ deleteEnv(env, "COPILOT_ALLOW_ALL");
+ // A general GitHub token on the server would outrank the Copilot login; only one set on this engine counts.
+ const own = new Set(Object.keys(instanceEnvironment).map((key) => key.toUpperCase()));
+ for (const name of ["GH_TOKEN", "GITHUB_TOKEN"]) if (!own.has(name)) deleteEnv(env, name);
+ },
+ resolveModels: (env, config) => resolveCopilotModels(env, config),
+ // Every fleet has this instance, and any `copilot` on PATH (VS Code's shim included) would otherwise be started
+ // at launch: the catalog comes from the startup cache and refreshes when the engine is picked.
+ resolveModelsOnCreate: false,
+ selectModel: { configId: "model" },
+ modelVariants: true,
+ fallbackModel: (sessionConfig, catalogDefault) => {
+ const offered = offeredModels(sessionConfig, "model");
+ if (offered.includes(catalogDefault)) return catalogDefault;
+ return offered.includes(AUTO) ? AUTO : null;
+ },
+ restartOnMcpChange: true,
+ pickAuthMethod: () => null,
+ authFailure: "continue",
+ isAuthenticated: (env, config) => copilotSignedIn(env, config),
+ classifyError: classifyCopilotError,
+ describeAccountError: describeCopilotAccountError,
+ buildPromptText: (turn) => (turn.system ? `${turn.system}\n\n${turn.text}` : turn.text),
+};
+
+export const CopilotAgentDriver = createAcpDriver(SUPPORT);
diff --git a/server/drivers/acp/custom-model-catalog.test.ts b/server/drivers/acp/custom-model-catalog.test.ts
index 456946119d..c7f4d939d7 100644
--- a/server/drivers/acp/custom-model-catalog.test.ts
+++ b/server/drivers/acp/custom-model-catalog.test.ts
@@ -1,11 +1,18 @@
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
-import { join } from "node:path";
-import { afterEach, describe, expect, it } from "vitest";
-import { resolveCustomAcpModels } from "./custom-model-catalog.ts";
+import { basename, join } from "node:path";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { DISCOVERY_CLIENT_NAME, discoverAcpModels, resolveCustomAcpModels } from "./custom-model-catalog.ts";
+
+/** Lets a test see a process that reports it would not stop; the real stop still runs. */
+const stop = vi.hoisted(() => ({ refuses: false }));
+vi.mock("../../procs.ts", async (original) => {
+ const procs = await original<typeof import("../../procs.ts")>();
+ return { ...procs, killCliTree: async (...args: Parameters<typeof procs.killCliTree>) => (await procs.killCliTree(...args)) && !stop.refuses };
+});
const scratch: string[] = [];
-afterEach(async () => { await Promise.all(scratch.splice(0).map((path) => rm(path, { recursive: true, force: true }))); });
+afterEach(async () => { stop.refuses = false; await Promise.all(scratch.splice(0).map((path) => rm(path, { recursive: true, force: true }))); });
async function fake(mode = "normal") {
const cwd = await mkdtemp(join(tmpdir(), "omb-catalog-test-"));
@@ -20,6 +27,7 @@ const modelOptions=[{value:'deep',name:'Deep'},{value:'flash',name:'Flash'},{val
function result(){return {sessionId:'fake-session',configOptions:[{id:'model',type:'select',category:'model',currentValue:current,options:modelOptions},...(current==='silent'?[]:[{id:current==='flash'?'thought_level':'reasoning_effort',type:'select',category:'thought_level',currentValue:current==='flash'?'low':'max',options:[{value:current==='flash'?'low':'max',name:current==='flash'?'Low':'Max'}]}])]};}
function emit(value){process.stdout.write(JSON.stringify(value)+'\\n');}
function legacyResult(){const r=result();return {...r,models:{currentModelId:current,availableModels:modelOptions.map(x=>({modelId:x.value,name:x.name}))},configOptions:r.configOptions.filter(x=>x.id!=='model')}}
+appendFileSync(process.env.CATALOG_DUMP,JSON.stringify({cwd:process.cwd(),pid:process.pid})+'\\n');
for await(const line of createInterface({input:process.stdin})){
const msg=JSON.parse(line); appendFileSync(process.env.CATALOG_DUMP,JSON.stringify({cwd:process.cwd(),...msg})+'\\n');
if(!msg.method)continue;
@@ -42,11 +50,15 @@ for await(const line of createInterface({input:process.stdin})){
emit({jsonrpc:'2.0',id:msg.id,result:result()});continue;
}
emit({jsonrpc:'2.0',id:msg.id,error:{code:-32601,message:'unexpected method'}});
-}`);
+}
+appendFileSync(process.env.CATALOG_DUMP,JSON.stringify({eof:true})+'\\n');
+if(mode==='ignore-eof')setInterval(()=>{},1000);`);
return {
config: { cli: `${JSON.stringify(process.execPath)} ${JSON.stringify(cli)}` },
env: { ...process.env, HOME: cwd, USERPROFILE: cwd, CATALOG_MODE: mode, CATALOG_DUMP: dump },
- requests: async () => (await readFile(dump, "utf8")).trim().split("\n").map((line) => JSON.parse(line) as Record<string, any>),
+ requests: async () => (await readFile(dump, "utf8")).trim().split("\n").map((line) => JSON.parse(line) as Record<string, any>)
+ .filter((entry) => entry.pid === undefined && !entry.eof),
+ log: async () => (await readFile(dump, "utf8")).trim().split("\n").map((line) => JSON.parse(line) as Record<string, any>),
};
}
@@ -104,6 +116,43 @@ describe("custom ACP catalog discovery (isolated fake CLI)", () => {
await expect(resolveCustomAcpModels(fixture.env, fixture.config)).rejects.toThrow("did not advertise any models");
});
+ it("hands the agent's session to forgetSession once the process has stopped, and never before", async () => {
+ const fixture = await fake();
+ const forgetSession = vi.fn(async () => {});
+ await discoverAcpModels(fixture.env, fixture.config.cli, [], { forgetSession });
+ expect(forgetSession).toHaveBeenCalledOnce();
+ const [session] = forgetSession.mock.calls[0] as unknown as [{ sessionId: string; cwd: string; env: unknown }];
+ expect(session.sessionId).toBe("fake-session");
+ expect(basename(session.cwd)).toMatch(/^omb-acp-models-/);
+ // macOS reports the agent's cwd through /private; the folder name is the same either way.
+ expect(basename(session.cwd)).toBe(basename((await fixture.requests())[0].cwd));
+ expect(session.env).toBe(fixture.env);
+ expect((await fixture.requests())[0].params.clientInfo.name).toBe(DISCOVERY_CLIENT_NAME);
+
+ stop.refuses = true;
+ const stuck = vi.fn(async () => {});
+ await expect(discoverAcpModels(fixture.env, fixture.config.cli, [], { forgetSession: stuck })).rejects.toThrow("could not be stopped");
+ expect(stuck).not.toHaveBeenCalled();
+ });
+
+ it("stops a custom agent at once, and lets an agent asked to exit gracefully read EOF first", async () => {
+ const custom = await fake();
+ await resolveCustomAcpModels(custom.env, custom.config);
+ expect((await custom.log()).some((entry) => entry.eof)).toBe(false);
+ const graceful = await fake();
+ await discoverAcpModels(graceful.env, graceful.config.cli, [], { exitGraceMs: 10_000 });
+ expect((await graceful.log()).some((entry) => entry.eof)).toBe(true);
+ });
+
+ it("still stops an agent that ignores EOF, once the grace period is over", async () => {
+ const fixture = await fake("ignore-eof");
+ await discoverAcpModels(fixture.env, fixture.config.cli, [], { exitGraceMs: 50 });
+ const log = await fixture.log();
+ expect(log.some((entry) => entry.eof)).toBe(true);
+ const pid = log.find((entry) => entry.pid !== undefined)?.pid as number;
+ expect(() => process.kill(pid, 0)).toThrow();
+ }, 20_000);
+
it("bounds malformed output and still removes its isolated workspace", async () => {
const fixture = await fake("flood");
await expect(resolveCustomAcpModels(fixture.env, fixture.config)).rejects.toThrow("line limit");
diff --git a/server/drivers/acp/custom-model-catalog.ts b/server/drivers/acp/custom-model-catalog.ts
index c7c3c3096a..3accb025f0 100644
--- a/server/drivers/acp/custom-model-catalog.ts
+++ b/server/drivers/acp/custom-model-catalog.ts
@@ -13,23 +13,73 @@ const DISCOVERY_TIMEOUT_MS = 60_000;
const MAX_OUTPUT_BYTES = 8 * 1024 * 1024;
const MAX_LINE_BYTES = 1024 * 1024;
const MAX_MODELS = 128;
+/** The `clientInfo.name` every discovery session is opened with. */
+export const DISCOVERY_CLIENT_NAME = "openmausbot-model-discovery";
+
+export interface AcpDiscoveryOptions {
+ /** A saved id listed first that leaves the native session's model unchanged; it becomes the default. */
+ passthrough?: { id: string; label: string };
+ /** Mark every option `custom: true`, as a custom-only engine's picker lists only those. */
+ custom?: boolean;
+ /** Switch to each model to read its own variants. False stops after session/new. */
+ variants?: boolean;
+ /** The catalog default when the agent offers it; otherwise the session's current model. */
+ default?: string;
+ /** The picker label for an advertised model, given session/new's result verbatim. */
+ label?(model: { id: string; label: string }, sessionNew: unknown): string;
+ /** Close stdin and give the agent this many milliseconds to exit on its own, so it can release what it holds,
+ * before it is killed. Without it the agent is killed at once. */
+ exitGraceMs?: number;
+ /** Remove what the agent kept of the discovery session, once its process has stopped. */
+ forgetSession?(session: { sessionId: string; cwd: string; env: Record<string, string | undefined> }): Promise<void>;
+}
+
+/** The agent answered a discovery request with a JSON-RPC error, so it is reachable. Its own text stays
+ * off `message`, which callers may show. */
+export class AcpDiscoveryRpcError extends Error {
+ readonly code: unknown;
+ readonly rpcMessage: string;
+ constructor(code: unknown, rpcMessage: string) {
+ super("ACP model discovery request was rejected by the agent.");
+ this.code = code;
+ this.rpcMessage = rpcMessage.slice(0, 500);
+ }
+}
function record(value: unknown): Record<string, unknown> | undefined {
return value !== null && typeof value === "object" && !Array.isArray(value)
? value as Record<string, unknown> : undefined;
}
-async function closeDiscovery(child: ReturnType<typeof spawnCli> | undefined, cwd: string): Promise<void> {
- let stopped = !child;
- try { if (child) stopped = await killCliTree(child, 500); }
- finally { await rm(cwd, { recursive: true, force: true }); }
- if (!stopped) throw new Error("The ACP discovery process could not be stopped.");
+/** Stops the agent, first letting it exit on its own when asked to. Returns whether it stopped. */
+async function stopDiscovery(child: ReturnType<typeof spawnCli> | undefined, graceMs: number | undefined): Promise<boolean> {
+ if (!child) return true;
+ if (graceMs !== undefined && child.exitCode === null && child.signalCode === null) {
+ const exited = new Promise<void>((resolve) => child.once("exit", () => resolve()));
+ try { child.stdin.end(); } catch {}
+ await Promise.race([exited, new Promise<void>((resolve) => setTimeout(resolve, graceMs).unref())]);
+ }
+ // A wrapper that exits on EOF must wait for its agent (Copilot CLI 1.0.103's npm-loader does, through spawnSync): once the
+ // direct child is gone, taskkill /T cannot find the tree. Windows stops it through taskkill, which needs seconds.
+ return killCliTree(child, process.platform === "win32" ? 5_000 : 500);
}
-export async function resolveCustomAcpModels(
+const AGENT_DEFAULT = { id: "agent-default", label: "Agent default" };
+
+export function resolveCustomAcpModels(
env: Record<string, string | undefined>,
config: Pick<AcpConfig, "cli">,
_instanceId?: string,
+): Promise<ModelCatalog> {
+ return discoverAcpModels(env, config.cli, [], { passthrough: AGENT_DEFAULT, custom: true });
+}
+
+/** Reads the models an ACP agent advertises in an empty folder, without a prompt, tool, MCP server or permission. */
+export async function discoverAcpModels(
+ env: Record<string, string | undefined>,
+ cli: string,
+ args: string[],
+ discovery: AcpDiscoveryOptions = {},
): Promise<ModelCatalog> {
const cwd = await mkdtemp(join(tmpdir(), "omb-acp-models-"));
let child: ReturnType<typeof spawnCli> | undefined;
@@ -43,6 +93,8 @@ export async function resolveCustomAcpModels(
let outputBytes = 0;
let buffer = "";
const decoder = new StringDecoder("utf8");
+ let catalog: ModelCatalog | undefined;
+ let thrown: unknown;
const fail = (message: string) => {
failure ??= new Error(message);
for (const entry of pending.values()) { clearTimeout(entry.timer); entry.reject(failure); }
@@ -80,8 +132,10 @@ export async function resolveCustomAcpModels(
if (!entry) return;
pending.delete(message.id);
clearTimeout(entry.timer);
- if (message.error !== undefined) entry.reject(new Error("ACP model discovery request was rejected by the agent."));
- else entry.resolve(message.result);
+ if (message.error !== undefined) {
+ const error = record(message.error);
+ entry.reject(new AcpDiscoveryRpcError(error?.code, typeof error?.message === "string" ? error.message : ""));
+ } else entry.resolve(message.result);
};
const request = (method: string, params: unknown): Promise<unknown> => {
if (failure) return Promise.reject(failure);
@@ -96,7 +150,7 @@ export async function resolveCustomAcpModels(
});
};
try {
- child = spawnCli(config.cli, [], { cwd, env, stdio: ["pipe", "pipe", "pipe"] }, "bot");
+ child = spawnCli(cli, args, { cwd, env, stdio: ["pipe", "pipe", "pipe"] }, "bot");
child.on("error", () => fail("Could not start the ACP agent for model discovery."));
child.on("close", () => fail("ACP agent closed during model discovery."));
child.stdout.on("data", (chunk: Buffer) => {
@@ -115,7 +169,7 @@ export async function resolveCustomAcpModels(
globalTimer = setTimeout(() => fail("ACP model discovery timed out."), DISCOVERY_TIMEOUT_MS);
await request("initialize", {
protocolVersion: 1,
- clientInfo: { name: "openmausbot-model-discovery", version: "1" },
+ clientInfo: { name: DISCOVERY_CLIENT_NAME, version: "1" },
clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false },
});
const initial = await request("session/new", { cwd, mcpServers: [] });
@@ -125,14 +179,16 @@ export async function resolveCustomAcpModels(
const modelOption = acpModelOption(initial);
if (!modelOption?.options.length) throw new Error("The ACP agent did not advertise any models. The previous catalog was kept.");
if (modelOption.options.length > MAX_MODELS) throw new Error("The ACP model catalog exceeded the discovery limit.");
- const options: ModelCatalog["options"] = [{ id: "agent-default", label: "Agent default", custom: true }];
+ const mark = discovery.custom ? { custom: true } : {};
+ const { passthrough } = discovery;
+ const options: ModelCatalog["options"] = passthrough ? [{ ...passthrough, ...mark }] : [];
for (const model of modelOption.options) {
- if (model.id === "agent-default") continue;
+ if (model.id === passthrough?.id) continue;
if (failure) throw failure;
let confirmed: unknown;
if (model.id === modelOption.currentValue) {
confirmed = initial;
- } else {
+ } else if (discovery.variants !== false) {
const previousUpdate = updateSequence;
try {
const response = modelOption.configId
@@ -145,13 +201,27 @@ export async function resolveCustomAcpModels(
}
}
const variants = confirmed ? acpVariantOption(confirmed)?.options : undefined;
- options.push({ ...model, custom: true, ...(variants?.length ? { variants } : {}) });
+ const label = discovery.label ? discovery.label(model, initial) : model.label;
+ options.push({ ...model, label, ...mark, ...(variants?.length ? { variants } : {}) });
}
if (failure) throw failure;
- return { default: "agent-default", options };
+ const preferred = discovery.default && options.some((option) => option.id === discovery.default) ? discovery.default : undefined;
+ catalog = { default: passthrough?.id ?? preferred ?? modelOption.currentValue ?? options[0].id, options };
+ } catch (error) {
+ thrown = error;
} finally {
if (globalTimer) clearTimeout(globalTimer);
fail("ACP model discovery finished.");
- await closeDiscovery(child, cwd);
+ let stopped = false;
+ try {
+ stopped = await stopDiscovery(child, discovery.exitGraceMs);
+ if (stopped && sessionId) await discovery.forgetSession?.({ sessionId, cwd, env }).catch(() => undefined);
+ } finally {
+ await rm(cwd, { recursive: true, force: true });
+ }
+ // The discovery's own failure says more than a process that would not stop.
+ if (!stopped) thrown ??= new Error("The ACP discovery process could not be stopped.");
}
+ if (thrown !== undefined) throw thrown;
+ return catalog!;
}
diff --git a/server/drivers/builtIn.ts b/server/drivers/builtIn.ts
index 96ecf0900d..0c87d792a1 100644
--- a/server/drivers/builtIn.ts
+++ b/server/drivers/builtIn.ts
@@ -14,6 +14,7 @@ import { CustomAcpDriver } from "./acp/custom.ts";
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 { OpenAICompatDriver } from "./openai-compat.ts";
import { PiDriver } from "./pi.ts";
import { MistralDriver } from "./mistral.ts";
@@ -34,6 +35,7 @@ export const BUILT_IN_DRIVERS: readonly AnyProviderDriver[] = [
QwenAgentDriver,
HermesAgentDriver,
ClineAgentDriver,
+ CopilotAgentDriver,
CustomAcpDriver,
PiDriver,
OpenAICompatDriver,
diff --git a/server/engine-memory.ts b/server/engine-memory.ts
index dfcdf33515..3245aa6c42 100644
--- a/server/engine-memory.ts
+++ b/server/engine-memory.ts
@@ -22,7 +22,7 @@ const RESERVE_MS = 90_000, SETTLED_MS = 30_000;
const TICK_MS = 2_000, RELIEF_COOLDOWN_MS = 15_000, NOTICE_REPEAT_MS = 10 * 60_000, STOP_GRACE_MS = 5_000;
/** 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", "customAcp", "piAgent", "antigravityAgent"]);
+ "droidAgent", "cursorAgent", "qwenAgent", "hermesAgent", "clineAgent", "copilotAgent", "customAcp", "piAgent", "antigravityAgent"]);
export interface HostMemory { totalBytes: number; availableBytes: number; swapFreeBytes: number; oomKills: number | null; fullStall10: number | null }
diff --git a/server/first-hour.e2e.test.ts b/server/first-hour.e2e.test.ts
index 502ff5302d..e9574ae6cb 100644
--- a/server/first-hour.e2e.test.ts
+++ b/server/first-hour.e2e.test.ts
@@ -95,7 +95,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
profile: { name: "Sam Lee" },
instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Fixture", config: { cli } },
},
}));
diff --git a/server/instance-fleets.ts b/server/instance-fleets.ts
new file mode 100644
index 0000000000..fc02e06358
--- /dev/null
+++ b/server/instance-fleets.ts
@@ -0,0 +1,73 @@
+// The engine instances a fresh install starts with, and the ones an existing product fleet gains.
+// instanceConfigs (config.ts) copies every entry before it changes one.
+import type { InstanceConfigMap } from "./contracts.ts";
+
+export const OPENAI_API_INSTANCE = "openai";
+export const OPENROUTER_API_INSTANCE = "openrouter";
+export const XAI_API_INSTANCE = "xaiApi";
+export const CLAUDE_API_INSTANCE = "claudeApi";
+export const API_KEY_FLEET: InstanceConfigMap = {
+ [OPENAI_API_INSTANCE]: {
+ driver: "openai-compat", displayName: "OpenAI", access: "api", icon: { kind: "preset", preset: "openai" },
+ config: { url: "https://api.openai.com/v1", apiKeyEnv: "OMB_OPENAI_API_KEY", catalog: "openai" },
+ },
+ [CLAUDE_API_INSTANCE]: {
+ driver: "claudeAgent", displayName: "Claude (API key)", access: "api", icon: { kind: "preset", preset: "anthropic" },
+ config: { requireApiKey: true },
+ },
+ [XAI_API_INSTANCE]: { driver: "grok", displayName: "xAI", access: "api", icon: { kind: "preset", preset: "xai" } },
+ [OPENROUTER_API_INSTANCE]: {
+ driver: "openai-compat", displayName: "OpenRouter", access: "api", icon: { kind: "preset", preset: "openrouter" },
+ config: { url: "https://openrouter.ai/api/v1", apiKeyEnv: "OMB_OPENROUTER_API_KEY" },
+ },
+};
+
+// Google retired Gemini CLI for the free/Pro/Ultra tiers on 2026-06-18; enterprise licences restore it with
+// `{"instances": {"gemini": {"driver": "geminiAgent"}}}`.
+export const DEFAULT_FLEET: InstanceConfigMap = {
+ grok: { driver: "grokAgent" },
+ kimi: { driver: "kimiAgent" },
+ droid: { driver: "droidAgent" },
+ cursor: { driver: "cursorAgent" },
+ githubCopilot: { driver: "copilotAgent" },
+ claude: { driver: "claudeAgent" },
+ codex: { driver: "codex" },
+ chatgpt: { driver: "codex", displayName: "ChatGPT plan", config: { authMode: "chatgpt-plan" } },
+ antigravity: { driver: "antigravityAgent" },
+ opencodeGo: { driver: "opencodeGo" },
+ openaiCompat: { driver: "openai-compat" },
+ mistral: { driver: "mistral" },
+ cerebras: { driver: "cerebras" },
+ groq: { driver: "groq" },
+ meta: { driver: "meta" },
+ deepseek: { driver: "deepseekAgent" },
+ museCode: { driver: "museCode" },
+ ...API_KEY_FLEET,
+ qwen: { driver: "qwenAgent" },
+ hermes: { driver: "hermesAgent" },
+ cline: { driver: "clineAgent" },
+ pi: { driver: "piAgent" },
+};
+
+const CUSTOM_ONLY = {
+ qwen: { driver: "qwenAgent" },
+ hermes: { driver: "hermesAgent" },
+ cline: { driver: "clineAgent" },
+ pi: { driver: "piAgent" },
+} as const;
+
+/** Added to a saved fleet that holds a product engine (claude, grok or codex), when it lacks them. */
+export const PRODUCT_FLEET_ADDITIONS = {
+ chatgpt: { driver: "codex", displayName: "ChatGPT plan", config: { authMode: "chatgpt-plan" } },
+ cursor: { driver: "cursorAgent" },
+ githubCopilot: { driver: "copilotAgent" },
+ openaiCompat: { driver: "openai-compat" },
+ mistral: { driver: "mistral" },
+ cerebras: { driver: "cerebras" },
+ groq: { driver: "groq" },
+ meta: { driver: "meta" },
+ deepseek: { driver: "deepseekAgent" },
+ museCode: { driver: "museCode" },
+ ...API_KEY_FLEET,
+ ...CUSTOM_ONLY,
+} as const;
diff --git a/server/lent-folders.e2e.test.ts b/server/lent-folders.e2e.test.ts
index 44d7e312c8..43c3f3078a 100644
--- a/server/lent-folders.e2e.test.ts
+++ b/server/lent-folders.e2e.test.ts
@@ -73,7 +73,7 @@ await import(${JSON.stringify(pathToFileURL(join(SERVER_DIR, "testing", "fake-cl
`, { mode: 0o755 });
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
},
}));
diff --git a/server/live-call.e2e.test.ts b/server/live-call.e2e.test.ts
index 76eb6b2755..0f2c349646 100644
--- a/server/live-call.e2e.test.ts
+++ b/server/live-call.e2e.test.ts
@@ -657,7 +657,7 @@ posixOnly("Live call on the person's Cloud", () => {
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
// Pin the fleet's other defaults so this never probes an installed CLI.
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", config: { cli: FAKE_CLAUDE, permissionMode: "bypassPermissions" } },
},
}));
@@ -776,7 +776,7 @@ posixOnly("Live calls for everyone, with the person's own OpenAI key", () => {
writeFileSync(join(dataDir, "config.json"), JSON.stringify({
instances: {
// Pin the fleet's other defaults so this never probes an installed CLI.
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", config: { cli: FAKE_CLAUDE, permissionMode: "bypassPermissions" } },
},
}));
diff --git a/server/runtime/capabilities.test.ts b/server/runtime/capabilities.test.ts
index 29a9991a9c..4a573d64cb 100644
--- a/server/runtime/capabilities.test.ts
+++ b/server/runtime/capabilities.test.ts
@@ -26,6 +26,7 @@ const EXPECTED: Record<string, EngineCapabilities> = {
hermesAgent: bare,
deepseekAgent: bare,
clineAgent: { resume: true, nativeReviewer: false, full: true, edits: false, subagents: false },
+ copilotAgent: bare,
customAcp: bare,
"openai-compat": chat,
grok: chat,
diff --git a/server/runtime/capabilities.ts b/server/runtime/capabilities.ts
index 63bb242d16..65301a6ca6 100644
--- a/server/runtime/capabilities.ts
+++ b/server/runtime/capabilities.ts
@@ -33,6 +33,7 @@ const ENGINES: Readonly<Record<string, EngineRow>> = {
hermesAgent: { resume: true },
deepseekAgent: { resume: true },
clineAgent: { resume: true },
+ copilotAgent: { 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.ts
index 532d6678b8..e100d33aa9 100755
--- a/server/testing/fake-acp-cli.ts
+++ b/server/testing/fake-acp-cli.ts
@@ -231,6 +231,10 @@ const dumpEnv = Object.fromEntries(
"GEMINI_API_KEY",
"MISTRAL_API_KEY",
"OMB_ANTHROPIC_API_KEY",
+ "COPILOT_ALLOW_ALL",
+ "COPILOT_GITHUB_TOKEN",
+ "GH_TOKEN",
+ "GITHUB_TOKEN",
].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/server/use-my-mac.e2e.test.ts b/server/use-my-mac.e2e.test.ts
index 7cdcfa4ac1..ba435b7ce7 100644
--- a/server/use-my-mac.e2e.test.ts
+++ b/server/use-my-mac.e2e.test.ts
@@ -237,7 +237,7 @@ process.stdout.write(JSON.stringify({ success: true, data: args[0] === "session"
`, { mode: 0o755 });
chmodSync(join(home, "agent-browser"), 0o755);
writeFileSync(join(dataDir, "config.json"), JSON.stringify({ instances: {
- ...Object.fromEntries(["codex", "cursor", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
+ ...Object.fromEntries(["codex", "cursor", "githubCopilot", "openaiCompat", "qwen", "hermes", "pi", "grok"].map((id) => [id, { driver: "not-a-real-driver" }])),
claude: { driver: "claudeAgent", displayName: "Claude", config: { cli } },
} }));
website = createServer((req, res) => {
diff --git a/shared/tool-scope-support.ts b/shared/tool-scope-support.ts
index a19c90c103..10996adf93 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", meta: "native-and-mcp",
claudeAgent: "mcp", codex: "mcp", geminiAgent: "mcp", kimiAgent: "mcp", droidAgent: "mcp",
- cursorAgent: "mcp", opencodeGo: "mcp", qwenAgent: "mcp", hermesAgent: "mcp", clineAgent: "mcp", deepseekAgent: "mcp", customAcp: "mcp", antigravityAgent: "mcp", museCode: "mcp",
+ cursorAgent: "mcp", opencodeGo: "mcp", qwenAgent: "mcp", hermesAgent: "mcp", clineAgent: "mcp", copilotAgent: "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/CopilotModelPicker.test.ts b/src/components/CopilotModelPicker.test.ts
new file mode 100644
index 0000000000..14b92d0785
--- /dev/null
+++ b/src/components/CopilotModelPicker.test.ts
@@ -0,0 +1,125 @@
+import { mkdtemp, rm } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+import { Children, createElement, isValidElement, type ChangeEvent, type ComponentProps, type ReactElement, type ReactNode } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { afterAll, beforeAll, beforeEach, expect, it, vi } from "vitest";
+import type { AppState, Bot, InstanceInfo } from "@/state/store";
+import { modelSwitchNeedsAsk } from "../../shared/approval-mode";
+import { Select } from "./Select";
+import { resolveCopilotModels } from "../../server/drivers/acp/copilot";
+
+const fixture = vi.hoisted(() => {
+ vi.stubGlobal("window", {});
+ vi.stubGlobal("localStorage", { getItem: () => null, setItem: () => {} });
+ return { instances: [] as InstanceInfo[], modelVariantSessions: {} as AppState["modelVariantSessions"], dispatch: vi.fn(),
+ values: [] as unknown[], index: 0, own: 0 };
+});
+vi.mock("react", async (original) => ({
+ ...await original<typeof import("react")>(),
+ useState: (initial: unknown) => {
+ const index = fixture.index++;
+ if (!(index in fixture.values)) fixture.values[index] = typeof initial === "function" ? initial() : initial;
+ return [fixture.values[index], (next: unknown) => {
+ fixture.values[index] = typeof next === "function" ? next(fixture.values[index]) : next;
+ }];
+ },
+ useEffect: () => {},
+}));
+vi.mock("./MenuMotion", () => ({ useMenuMotion: (open: boolean) => ({ shown: open, closing: false, className: "" }) }));
+vi.mock("@/lib/interface-mode", () => ({ useAdvancedMode: () => false, setAdvancedMode: () => {} }));
+vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => true }));
+vi.mock("@/state/store", async (original) => ({
+ ...await original<typeof import("@/state/store")>(),
+ useStore: () => ({ state: { instances: fixture.instances, bots: [], modelVariantSessions: fixture.modelVariantSessions }, dispatch: fixture.dispatch,
+ refreshInstances: vi.fn(() => Promise.resolve()), refreshModels: vi.fn(() => Promise.resolve()) }),
+}));
+const { ModelPicker, ModelVariantRow, modelSelectionForPick } = await import("./ModelPicker");
+const { SimpleModelMenu } = await import("./SimpleModelMenu");
+
+let home: string;
+let discovered: InstanceInfo["models"];
+beforeAll(async () => {
+ home = await mkdtemp(join(tmpdir(), "omb-copilot-picker-ui-"));
+ discovered = await resolveCopilotModels({ HOME: home, USERPROFILE: home, PATH: dirname(process.execPath),
+ FAKE_ACP_MODELS: "auto,claude-haiku-4.5,gpt-5.6-luna",
+ FAKE_ACP_VARIANTS: JSON.stringify({ "gpt-5.6-luna": { id: "reasoning_effort", currentValue: "medium",
+ options: [{ value: "low", name: "low" }, { value: "high", name: "high" }] } }) },
+ { cli: fileURLToPath(new URL("../../server/testing/fake-acp-cli.ts", import.meta.url)) });
+});
+afterAll(async () => { vi.unstubAllGlobals(); if (home) await rm(home, { recursive: true, force: true }); });
+beforeEach(() => {
+ fixture.dispatch.mockClear(); fixture.modelVariantSessions = {};
+ fixture.values = []; fixture.index = 0; fixture.own = 0;
+});
+
+const copilot = (): InstanceInfo => ({
+ instanceId: "githubCopilot", displayName: "GitHub Copilot", driverKind: "copilotAgent", access: "subscription",
+ snapshot: { state: "available", authenticated: true }, capabilities: { modelVariants: true }, models: discovered,
+});
+const claude = (): InstanceInfo => ({
+ instanceId: "claude", displayName: "Claude", driverKind: "claudeAgent", access: "subscription",
+ snapshot: { state: "available", authenticated: true }, models: { default: "claude-sonnet-5", options: [{ id: "claude-sonnet-5", label: "Sonnet" }] },
+});
+const bot = (instanceId: string, model: string): Bot => ({
+ id: "bot-hopper", threadId: "thread-hopper", name: "Hopper", title: "", description: "", notifications: true,
+ color: "green", unread: false, messages: [], modelSelection: { instanceId, model },
+});
+type Element = ReactElement<Record<string, unknown> & { children?: ReactNode; onChange?: (event: ChangeEvent<HTMLSelectElement>) => void }>;
+function elements(value: ReactNode): Element[] {
+ return Children.toArray(value).flatMap((child) => isValidElement(child) ? [child as Element, ...elements((child as Element).props.children)] : []);
+}
+function renderPicker(selected: Bot) {
+ fixture.values.length = Math.min(fixture.values.length, fixture.own);
+ let tree: ReactNode = null;
+ function Capture() {
+ fixture.index = 0;
+ tree = ModelPicker({ bot: selected, threadId: selected.threadId });
+ fixture.own = fixture.index;
+ return tree;
+ }
+ return { html: renderToStaticMarkup(createElement(Capture)), nodes: elements(tree) };
+}
+function openPicker(selected: Bot) {
+ const trigger = renderPicker(selected).nodes.find((entry) => entry.props["data-tour"] === "model")!;
+ (trigger.props.onClick as () => void)();
+ return renderPicker(selected);
+}
+const menuOf = (nodes: Element[]) => nodes.find((entry) => entry.type === SimpleModelMenu) as unknown as ReactElement<ComponentProps<typeof SimpleModelMenu>>;
+
+it("lists the models Copilot advertised in the picker and saves one for the bot", () => {
+ fixture.instances = [claude(), copilot()];
+ const selected = bot("githubCopilot", "auto");
+ const menu = menuOf(openPicker(selected).nodes);
+ const listed = menu.props.menu.groups.flatMap((group) => group.body.kind === "models" ? group.body.rows.map((row) => row.option.id) : []);
+ expect(menu.props.menu.current?.instance?.instanceId).toBe("githubCopilot");
+ expect(menu.props.menu.current?.label).toBe("GitHub Copilot auto");
+ expect(listed).toEqual(expect.arrayContaining(["claude-haiku-4.5", "gpt-5.6-luna"]));
+ menu.props.onPick(copilot(), "gpt-5.6-luna");
+ expect(fixture.dispatch).toHaveBeenLastCalledWith({ type: "setModel", botId: selected.id, threadId: selected.threadId,
+ updateBotDefault: true, selection: { instanceId: "githubCopilot", model: "gpt-5.6-luna" } });
+});
+
+it("offers the picked Copilot model's own effort levels", () => {
+ fixture.instances = [copilot()];
+ const selected = bot("githubCopilot", "gpt-5.6-luna");
+ const row = ModelVariantRow({ bot: selected, threadId: selected.threadId, updateBotDefault: true, compact: true });
+ const select = elements(row).find((entry) => entry.type === Select)!;
+ select.props.onChange!({ target: { value: "1" } } as ChangeEvent<HTMLSelectElement>);
+ expect(fixture.dispatch).toHaveBeenCalledExactlyOnceWith({ type: "setModel", botId: selected.id, threadId: selected.threadId,
+ updateBotDefault: true, selection: { instanceId: "githubCopilot", model: "gpt-5.6-luna", variant: "high" } });
+});
+
+it("moves between Claude and Copilot without an approval reset", () => {
+ fixture.instances = [claude(), copilot()];
+ const toCopilot = modelSelectionForPick(bot("claude", "claude-sonnet-5").modelSelection, copilot(), "claude-haiku-4.5");
+ expect(toCopilot).toEqual({ instanceId: "githubCopilot", model: "claude-haiku-4.5" });
+ expect(modelSelectionForPick(toCopilot, claude(), "claude-sonnet-5")).toEqual({ instanceId: "claude", model: "claude-sonnet-5" });
+ for (const mode of ["ask", "auto", "full"] as const) {
+ expect(modelSwitchNeedsAsk(mode, "claudeAgent", "copilotAgent")).toBe(false);
+ expect(modelSwitchNeedsAsk(mode, "copilotAgent", "customAcp")).toBe(false);
+ expect(modelSwitchNeedsAsk(mode, "customAcp", "claudeAgent")).toBe(false);
+ expect(modelSwitchNeedsAsk(mode, "copilotAgent", "claudeAgent")).toBe(false);
+ }
+});
diff --git a/src/components/EngineLibrary.tsx b/src/components/EngineLibrary.tsx
index d64f3abd85..de6a4a6ad4 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", piAgent: "pi.dev", mistral: "Mistral AI", cerebras: "Cerebras", groq: "Groq", meta: "Meta", museCode: "Meta", deepseekAgent: "DeepSeek",
+ hermesAgent: "Nous Research", clineAgent: "Cline", copilotAgent: "GitHub", piAgent: "pi.dev", mistral: "Mistral AI", cerebras: "Cerebras", groq: "Groq", meta: "Meta", museCode: "Meta", deepseekAgent: "DeepSeek",
};
export function providerName(instance: InstanceInfo): string {
diff --git a/src/components/ProviderIcons.tsx b/src/components/ProviderIcons.tsx
index 6828406214..b412ebd81a 100644
--- a/src/components/ProviderIcons.tsx
+++ b/src/components/ProviderIcons.tsx
@@ -122,6 +122,11 @@ export function DeepSeekMark({ size = 16, className }: IconProps) {
return <svg width={size} height={size} viewBox="0 0 24 24" className={className} aria-hidden="true"><path fill="#5786FE" d="M23.748 4.651c-.254-.124-.364.113-.512.233-.423.437-.857.794-1.51.763-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.789-.347-1.077-.626-1.26-1.424-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323l-.266.833c-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-1.06-1.024-1.97-2.183-3.286-2.93-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-1.27.006-2.312.621-3.152.821a9.6 9.6 0 0 0-2.883-.101c-3.75.419-5.994 3.589-5.757 7.395.218 3.496 2.247 6.521 5.258 8.037 2.52 1.269 5.649 1.474 8.484-.924.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 2.056-2.431 3.44-5.604 3.392-7.847-.004-.171.035-.238.23-.257 2.371-.246 3.642-1.764 3.838-3.992.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-2.919-1.718-4.443-4.959-4.6-7.788-.02-.385.094-.522.477-.592 2.602-.471 5.025.581 6.997 2.736 1.652 1.807 2.631 4.049 4.682 5.785.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 1 1 .614.001.306.306 0 0 1-.614 0m3.11 1.596c-.494.199-.931.222-1.389-.094-.274-.23-.47-.358-.551-.758-.122-.602.111-.903-.223-1.315-.188-.156-.426-.199-.689-.199-.454 0-.553-.298-.368-.636.356-.422.859-.442 1.338-.29.72.294 1.319 1.129 1.706 1.743.176.264.336.536.446.848.066.194-.02.353-.25.45" /></svg>;
}
+export function CopilotMark({ size = 16, className }: IconProps) {
+ // GitHub Copilot, path from Simple Icons (CC0 1.0).
+ 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 ProviderMark({ driverKind, size, className }: IconProps & { driverKind: string }) {
switch (driverKind) {
case "grok":
@@ -154,6 +159,8 @@ export function ProviderMark({ driverKind, size, className }: IconProps & { driv
return <DeepSeekMark size={size} className={className} />;
case "piAgent":
return <PiMark size={size} className={className} />;
+ case "copilotAgent":
+ return <CopilotMark size={size} className={className} />;
default:
return (
<span className={cn("flex size-full items-center justify-center text-[10px] font-semibold tracking-tight text-ink-secondary", className)}>
diff --git a/src/lib/analytics-allowlist.ts b/src/lib/analytics-allowlist.ts
index 0c1aeabae9..f354a5db6f 100644
--- a/src/lib/analytics-allowlist.ts
+++ b/src/lib/analytics-allowlist.ts
@@ -30,7 +30,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", "meta", "muse_code", "deepseek",
+ "grok_api", "kimi", "droid", "antigravity", "minimax", "mistral", "cerebras", "groq", "meta", "muse_code", "deepseek", "copilot",
] as const;
export type Engine = (typeof ENGINE)[number];
@@ -39,7 +39,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",
- meta: "meta", museCode: "muse_code", deepseekAgent: "deepseek",
+ meta: "meta", museCode: "muse_code", deepseekAgent: "deepseek", copilotAgent: "copilot",
} 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.ts
index 093404f053..4d188da17a 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", claude: "claudeAgent", codex: "codex",
+ grok: "grokAgent", kimi: "kimiAgent", droid: "droidAgent", cursor: "cursorAgent", githubCopilot: "copilotAgent", claude: "claudeAgent", codex: "codex",
chatgpt: "codex", antigravity: "antigravityAgent", opencodeGo: "opencodeGo", openaiCompat: "openai-compat",
mistral: "mistral", cerebras: "cerebras", groq: "groq", meta: "meta", museCode: "museCode", deepseek: "deepseekAgent", openai: "openai-compat",
claudeApi: "claudeAgent", xaiApi: "grok", openrouter: "openai-compat", qwen: "qwenAgent", hermes: "hermesAgent",