Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
list_models: say why each engine can't run and how it is connected (#7344)
Milind Soni16740ff1133a
diff --git a/apps/docs/content/docs/features/chat-and-teams.mdx b/apps/docs/content/docs/features/chat-and-teams.mdxindex f4ec3efc8f..0f90a28511 100644--- a/apps/docs/content/docs/features/chat-and-teams.mdx+++ b/apps/docs/content/docs/features/chat-and-teams.mdx@@ -112,7 +112,7 @@ Bots can hand work to other bots, in any department. Delegated runs carry explicA bot doesn't need a teammate to get work done on another model. It can open a thread of its own on any model you have connected, from another provider too, and have the result come back to it: for example three reviews of one change, each on a different model, with no review bots to set up. The bot reads the models it can use with `list_models` and opens each thread with `start_thread`, a `model_selection` and `report_back`. `list_models` gives a short list per provider, with the model the bot is on first, and finds any other model by name, so a provider with hundreds of models doesn't flood the conversation. You see "Opened thread #Review: GPT" where it went out and "#Review: GPT replied" when the answer comes back, and the bot then carries on with every result in hand. The thread is a row under the bot like any other, so you can open it and read the whole review.-A provider that is signed out or unavailable shows in `list_models` with the reason, and a thread on it is refused when it is opened, so a second opinion never quietly comes from the bot's own model. These threads can't be opened from a group chat, and a thread opened this way can't open more of its own.+A provider that is signed out or unavailable shows in `list_models` with the reason and how you connect it (for example "sign in with your Google account in Settings → AI → Providers; no API key"), so the bot can tell you instead of guessing, and a thread on it is refused when it is opened, so a second opinion never quietly comes from the bot's own model. These threads can't be opened from a group chat, and a thread opened this way can't open more of its own.### Work that is checked before it reaches youdiff --git a/server/contracts.ts b/server/contracts.tsindex 58ca3fdd36..dbefbf8ffa 100644--- a/server/contracts.ts+++ b/server/contracts.ts@@ -663,6 +663,8 @@ export interface ProviderDriver<Config = unknown> {displayName: string;supportsMultipleInstances?: boolean;access?: EngineAccess;+ /** Set when the app's sign-in uses a subscription on this account (Google, ChatGPT, Claude): bots may say no API key is needed. */+ signInAccount?: string;/** What the engine's own CLI answers to `--version`; another answer means the CLI path runs another program. */cliVersion?: RegExp;};diff --git a/server/drivers/agents-catalog-goldens/full.tools-list.json b/server/drivers/agents-catalog-goldens/full.tools-list.jsonindex f4c03948e0..89e949ef89 100644--- a/server/drivers/agents-catalog-goldens/full.tools-list.json+++ b/server/drivers/agents-catalog-goldens/full.tools-list.json@@ -528,7 +528,7 @@},{"name": "list_models",- "description": "The ids start_thread's model_selection takes, a short list per engine; current is yours. more counts what search finds. unusable says why not; unavailable engines can't run now. Copy ids exactly.",+ "description": "The ids start_thread's model_selection takes, a short list per engine; current is yours. more counts what search finds. unusable says why not; unavailable says why and how to connect. Copy ids exactly.","inputSchema": {"type": "object","additionalProperties": false,diff --git a/server/drivers/agents-catalog-goldens/profiles.json b/server/drivers/agents-catalog-goldens/profiles.jsonindex a6cb649c9d..8e1d8c7f46 100644--- a/server/drivers/agents-catalog-goldens/profiles.json+++ b/server/drivers/agents-catalog-goldens/profiles.json@@ -1,7 +1,7 @@{"default": {- "bytes": 61780,- "sha256": "5353e3480141af03546a70926574ff3111efff3d9171497264a081aa61cd6e0b",+ "bytes": 61786,+ "sha256": "8fef28ec7f165f998038c3a8527d918f90451428fddde67b0ae99e27b0e1da81","tools": ["tool_result_read","list_room_targets",@@ -61,8 +61,8 @@]},"voice": {- "bytes": 62561,- "sha256": "c0a7e4a6f4c449bfd38295de5c5916ccc2742edb645158b4b7a81e06383b7ce4",+ "bytes": 62567,+ "sha256": "1948ed35962d65c153fc7b70fc10edfecc1bbe9656cb4936290a24ff4d778e8e","tools": ["tool_result_read","list_room_targets",@@ -123,8 +123,8 @@]},"shared": {- "bytes": 64045,- "sha256": "83fee17adbf6e3fd0c9902b3949606016b18b5c20187dcda96bc69a2b9120d09",+ "bytes": 64051,+ "sha256": "5fee3bb2f5bd2d4bd3bab89f271d6ace0974e079123e4f170a33e14601996658","tools": ["tool_result_read","list_shared_computers",@@ -186,8 +186,8 @@]},"shared+voice": {- "bytes": 64826,- "sha256": "ce561a1dfaef6be8194696833f765b002552778468462529c78d305ca6e54690",+ "bytes": 64832,+ "sha256": "039c3f04aadb4effcfd6b64d78ecd9a36af2e225510946ba209d63cbdd59b78c","tools": ["tool_result_read","list_shared_computers",@@ -250,8 +250,8 @@]},"skills": {- "bytes": 64101,- "sha256": "0160213db9032f21882dc39b401ffe1fb21dda54199f95f1531d1571dada1e2f",+ "bytes": 64107,+ "sha256": "0ad12e265ac85405907bd6d6104c5c20f9092214825bcb2dde2c0422a669909c","tools": ["tool_result_read","list_room_targets",@@ -313,8 +313,8 @@]},"skills+voice": {- "bytes": 64882,- "sha256": "800c931994abae759bc15ab5ca830a8a6e6be80f5d2eebf8361a6f89ad14626c",+ "bytes": 64888,+ "sha256": "e84aeed89ce0cdd04ea43737a998c0b55d8db4e7d9733aa5e27bb32b47b057e0","tools": ["tool_result_read","list_room_targets",@@ -377,8 +377,8 @@]},"skills+shared": {- "bytes": 66366,- "sha256": "5d7009e528e0d4cb00606397b6b63a1de22369f34be95e47d3fccbeaecde2813",+ "bytes": 66372,+ "sha256": "e25daba241a351ae01af6302b5145e040aa671826ea9ef385cf5009298599d0c","tools": ["tool_result_read","list_shared_computers",@@ -442,8 +442,8 @@]},"skills+shared+voice": {- "bytes": 67147,- "sha256": "c5f5f299fdbfcf00c047a39d2b041b5ed23bb7a61017ac005fa9927beb70a23d",+ "bytes": 67153,+ "sha256": "caa48eaf2e1f91de824d9557dba3fe3f9cc25ccc59f4a8ae8c1228c7ff413299","tools": ["tool_result_read","list_shared_computers",@@ -508,8 +508,8 @@]},"non-chief": {- "bytes": 53232,- "sha256": "4ba546f1959718024a9d678eafa74f5ecf8cf45c1a41c6d1db33f997482048d5",+ "bytes": 53238,+ "sha256": "11dcbe1b650b5594fcb8dee761821311d641a4f764db68d2359a6a516b1d753b","tools": ["tool_result_read","list_room_targets",@@ -562,8 +562,8 @@]},"voice+non-chief": {- "bytes": 54013,- "sha256": "36249970141a6011c49bda3361f452535d8ff753fcd423c08522ac76ed8aed3c",+ "bytes": 54019,+ "sha256": "fd0da22b8fb6e5bbb75598c4f4a95c948ce62afd002141633d019cbc18d318ff","tools": ["tool_result_read","list_room_targets",@@ -617,8 +617,8 @@]},"shared+non-chief": {- "bytes": 55497,- "sha256": "d10510cbb5d0fabc7aaef9957b5381522ac111333f49de334450028d1c8ed427",+ "bytes": 55503,+ "sha256": "00c4719ede4cffa7021c6c0b0c3b46bcc9608039273d09771ec889eb26e07509","tools": ["tool_result_read","list_shared_computers",@@ -673,8 +673,8 @@]},"shared+voice+non-chief": {- "bytes": 56278,- "sha256": "e0d62e2fb532aee3098214ebd300b1e074a2aec18b3b87d88f5f5da987a037b2",+ "bytes": 56284,+ "sha256": "7d92acda7ea804a5d65e19091a344fb4b344281e0effc820fbaf90e7362bc876","tools": ["tool_result_read","list_shared_computers",@@ -730,8 +730,8 @@]},"skills+non-chief": {- "bytes": 55553,- "sha256": "5d2597438c2458d5022cac328cbe131e1d7e0100f16534a5954291c052a7fcec",+ "bytes": 55559,+ "sha256": "9d0db5a1281674176c149076c3ad9588c9f92c16d090a0f6a7506a5fe2a79fd4","tools": ["tool_result_read","list_room_targets",@@ -786,8 +786,8 @@]},"skills+voice+non-chief": {- "bytes": 56334,- "sha256": "5a3c6e314f4a87b3ecc648235ecf006234126abe853eb2fb12088d058bdf8015",+ "bytes": 56340,+ "sha256": "bd714c1109b6f44e247357e3b8ec3670d92e733284d4c0571f839d6f227a7cdc","tools": ["tool_result_read","list_room_targets",@@ -843,8 +843,8 @@]},"skills+shared+non-chief": {- "bytes": 57818,- "sha256": "730a87897f3e29eb56d0701be4a91b865784083054f88724fbc3ca0432023aee",+ "bytes": 57824,+ "sha256": "40fcc5d467598658d14d0bc02680aedcf87feccc5c6359dfcd3f129b7a204377","tools": ["tool_result_read","list_shared_computers",@@ -901,8 +901,8 @@]},"skills+shared+voice+non-chief": {- "bytes": 58599,- "sha256": "4a3fc1361cd73cfc0f38efde9bc05d91674ccaaecb2721a43a948c750f90b1e9",+ "bytes": 58605,+ "sha256": "9ff1c2fedb12487eafbf081e52952d011fa1242e3cb1f1767d40742d9db5a50c","tools": ["tool_result_read","list_shared_computers",@@ -960,8 +960,8 @@]},"skills+shared+voice+cloud-home": {- "bytes": 66903,- "sha256": "07f381781a3cbfa8dbb9d097bb2c75f859540b4381cc4d024fb687166de26b66",+ "bytes": 66909,+ "sha256": "aac499d8fa351c6c1b5fbd0cb7eef61f0266d61b7e733b20fb029da40276e4f0","tools": ["tool_result_read","list_shared_computers",@@ -1026,8 +1026,8 @@]},"skills+shared+voice+non-chief+cloud-home": {- "bytes": 58355,- "sha256": "046a03225d28d71c57ae5d492808a2f4d14753e13b9830fc80c7c147e0710b33",+ "bytes": 58361,+ "sha256": "ad318559aa2da3aa0a99ea8cdc203cdbf7dabfe6959872d601d1ef972c6b29e8","tools": ["tool_result_read","list_shared_computers",@@ -1085,8 +1085,8 @@]},"skills+shared+voice+x": {- "bytes": 70986,- "sha256": "e65cfaf1222643add8a1aa10cbcfd8dce4c557655656dad1a403e8bc445e8b47",+ "bytes": 70992,+ "sha256": "62150dcc25e64723a1134bd24c7369b500a2c15d9d3250fb61f3ba6a50c1d42f","tools": ["tool_result_read","list_shared_computers",@@ -1155,8 +1155,8 @@]},"skills+shared+voice+x+team": {- "bytes": 70986,- "sha256": "e65cfaf1222643add8a1aa10cbcfd8dce4c557655656dad1a403e8bc445e8b47",+ "bytes": 70992,+ "sha256": "62150dcc25e64723a1134bd24c7369b500a2c15d9d3250fb61f3ba6a50c1d42f","tools": ["tool_result_read","list_shared_computers",@@ -1225,8 +1225,8 @@]},"skills+shared+voice+x+team+images": {- "bytes": 72933,- "sha256": "6b6b7d35f7c99593183ec3e5e698e78079e93bb28b2e1e1436e26d70d7c1cfd7",+ "bytes": 72939,+ "sha256": "1be4ad6cd3468c16fec6620a13cb13e7f5f812714312eac507d574866f08fcbf","tools": ["tool_result_read","list_shared_computers",@@ -1297,8 +1297,8 @@]},"default+legacy-switches": {- "bytes": 61780,- "sha256": "5353e3480141af03546a70926574ff3111efff3d9171497264a081aa61cd6e0b",+ "bytes": 61786,+ "sha256": "8fef28ec7f165f998038c3a8527d918f90451428fddde67b0ae99e27b0e1da81","tools": ["tool_result_read","list_room_targets",@@ -1358,8 +1358,8 @@]},"default+mausbot": {- "bytes": 62431,- "sha256": "b05b5035504324b64d9c60c9a4050270c8a9a71db55631e7f009776b6ea88d27",+ "bytes": 62437,+ "sha256": "e71818d3b029d88915f275d033efd65824bf856f10a42d416d70cb72deca109a","tools": ["tool_result_read","list_room_targets",@@ -1421,8 +1421,8 @@]},"skills+shared+voice+mausbot": {- "bytes": 67798,- "sha256": "5387028d23473fb0e1f1e5506a3f0577e8ad933e1cd813e34117130746ae1abd",+ "bytes": 67804,+ "sha256": "cbc3d1a39e3f96cf3bcadc25091882f1380143ba2e3489678f8eb9eeb53e1b73","tools": ["tool_result_read","list_shared_computers",@@ -1489,8 +1489,8 @@]},"default+no-computer-pick": {- "bytes": 60568,- "sha256": "75e59e2d235337d12355d02d61b95d93d9ec74b18670437fe92245511aceda69",+ "bytes": 60574,+ "sha256": "caea065b9d1c1136843b9af9e3262b0d1cb2e7577a7a73ce1ab1868e8fdae7b9","tools": ["tool_result_read","list_room_targets",@@ -1549,8 +1549,8 @@]},"default+room": {- "bytes": 57128,- "sha256": "787e8410ad2ab4f9a4bd54602f5330724dd405161fcd2f83ad1a11977471f909",+ "bytes": 57134,+ "sha256": "6bcd18bc424e26a4992a36104fcc0a4287b8aea9cefe41bb789a9ce30ac2c3aa","tools": ["tool_result_read","list_room_targets",@@ -1603,8 +1603,8 @@]},"non-chief+room": {- "bytes": 48580,- "sha256": "01766e477e23dc5804654ddcd066e993531bdef2af25e312ecb53b88bc7c0771",+ "bytes": 48586,+ "sha256": "6860a81c1fa3c8531e621ee23ad0ee1e9a516a62f59327c9522b01c88ddb1f0d","tools": ["tool_result_read","list_room_targets",@@ -1650,8 +1650,8 @@]},"default+images": {- "bytes": 63727,- "sha256": "7f0f54a9820180dbb8807a92cda57f5e4e6ffbca5d8cd14e85cb37c730e68715",+ "bytes": 63733,+ "sha256": "55363deedcadebbfe935019cd4ffddb73fd9fa21bcc84eb4387e4fa106f8cbcd","tools": ["tool_result_read","list_room_targets",@@ -1713,8 +1713,8 @@]},"skills+shared+voice+x+team+images+hosting": {- "bytes": 74796,- "sha256": "8e0d1588e714acbf4660a60b934171badab4b6dd7be9e4aca346c4070ebd65d8",+ "bytes": 74802,+ "sha256": "9b730076edcabd4b5b2a1faaa4a17fb89e1e1b627bb519a7d27acf934abd20b4","tools": ["tool_result_read","list_shared_computers",@@ -1787,8 +1787,8 @@]},"default+hosting": {- "bytes": 63643,- "sha256": "a70b4cefd101f9d84f826b2bb01f48dfab0dcdf59d949303132a1f3f872a4a90",+ "bytes": 63649,+ "sha256": "08f24e6b0483ffbe58c4b106a223d42df13a00e2765457e988eb5a2ea8c64e13","tools": ["tool_result_read","list_room_targets",@@ -1850,8 +1850,8 @@]},"default+tools-off": {- "bytes": 57463,- "sha256": "047fcbe315f9f968dd5b1f35a1ba11aefa8816bfa95daba6aacf80050de4c8db",+ "bytes": 57469,+ "sha256": "1ff600e1d65c11cae40425671f6e35324a78c7eb7b8f74663ed8633c1ef03f6e","tools": ["tool_result_read","list_room_targets",diff --git a/server/drivers/agents-catalog.ts b/server/drivers/agents-catalog.tsindex 5c065c70a6..22ee6c2741 100644--- a/server/drivers/agents-catalog.ts+++ b/server/drivers/agents-catalog.ts@@ -294,7 +294,7 @@ const TOOL_DEFINITIONS = [},{name: "list_models",- description: "The ids start_thread's model_selection takes, a short list per engine; current is yours. more counts what search finds. unusable says why not; unavailable engines can't run now. Copy ids exactly.",+ description: "The ids start_thread's model_selection takes, a short list per engine; current is yours. more counts what search finds. unusable says why not; unavailable says why and how to connect. Copy ids exactly.",inputSchema: {type: "object",additionalProperties: false,diff --git a/server/drivers/antigravity.ts b/server/drivers/antigravity.tsindex 9c7d0aa33c..fd1dbb18e0 100644--- a/server/drivers/antigravity.ts+++ b/server/drivers/antigravity.ts@@ -334,6 +334,7 @@ const AcpAntigravityDriver = createAcpDriver(support);export const AntigravityDriver: ProviderDriver<AcpConfig> = {...AcpAntigravityDriver,+ metadata: { ...AcpAntigravityDriver.metadata, signInAccount: "Google" },async create(input: DriverCreateInput<AcpConfig>): Promise<ProviderInstance> {// A rebuilt instance may run another CLI, or the same one after a sign-in made outside MausBot.nativeSignIn.forget(input.instanceId);diff --git a/server/drivers/claude.ts b/server/drivers/claude.tsindex 975c4e37ae..7325002e34 100644--- a/server/drivers/claude.ts+++ b/server/drivers/claude.ts@@ -691,7 +691,7 @@ function diagnosticClaudeUserMessage(message: ClaudeUserMessage): ClaudeUserMessexport const ClaudeDriver: ProviderDriver<ClaudeConfig> = {driverKind: DRIVER_KIND,- metadata: { displayName: "Claude", supportsMultipleInstances: true },+ metadata: { displayName: "Claude", supportsMultipleInstances: true, signInAccount: "Claude" },install: {command: {darwin: "npm install -g @anthropic-ai/claude-code",diff --git a/server/drivers/codex.ts b/server/drivers/codex.tsindex 86ed245a97..6c6be62c5d 100644--- a/server/drivers/codex.ts+++ b/server/drivers/codex.ts@@ -196,7 +196,7 @@ export function codexNativeIncomingLogMessage(export const CodexDriver: ProviderDriver<CodexConfig> = {driverKind: DRIVER_KIND,- metadata: { displayName: "Codex", supportsMultipleInstances: true },+ metadata: { displayName: "Codex", supportsMultipleInstances: true, signInAccount: "ChatGPT" },install: {command: {darwin: "npm install -g @openai/codex",diff --git a/server/harness/registry.ts b/server/harness/registry.tsindex be5f6c45ec..9e2993166a 100644--- a/server/harness/registry.ts+++ b/server/harness/registry.ts@@ -48,6 +48,20 @@ function withServerInstall(install: AnyProviderDriver["install"], npmPresent: boreturn { ...clientInstall(install), platform, ...(server ? { server } : {}), ...(appCopy ? { signInCommand: undefined, appCopy: true } : {}) };}+/** How Settings signs this engine in, when the app can: what its provider card shows, and what list_models tells a bot. */+export function signInOf(inst: ProviderInstance) {+ return inst.startAuthentication+ ? {+ method: inst.authenticationMethod ?? (inst.getAuthentication && inst.completeAuthentication+ ? "paste-code" as const // a link to open, then a code pasted back (Claude)+ : inst.getAuthentication+ ? "device-code" as const // a code to enter at the provider's page (Codex)+ : "callback-url" as const), // a link and a callback URL (managed engines)+ signOut: inst.signOut !== undefined,+ }+ : undefined;+}+type InstallStandalone = (release: StandaloneRelease, options: { baseDir?: string }) => Promise<StandaloneInstalled>;/** Installed; `useCli` when the copy this engine's CLI finds does not start and it should run the app's own copy instead. */@@ -311,6 +325,13 @@ export class ProviderRegistry {return this.byId.get(instanceId)?.live ? this.lastSnapshots.get(instanceId) : undefined;}+ /** How this engine is installed and signed in, from what its provider card is built from; no status read. */+ connection(instanceId: InstanceId) {+ const entry = this.byId.get(instanceId);+ const driver = entry && this.driversByKind.get(entry.shadow?.driverKind ?? entry.live!.driverKind);+ return { install: clientInstall(driver?.install), signIn: entry?.live && signInOf(entry.live), account: driver?.metadata.signInAccount };+ }+access(instanceId: InstanceId): EngineAccess | undefined {const entry = this.byId.get(instanceId);return entry ? this.driversByKind.get(entry.shadow?.driverKind ?? entry.live!.driverKind)?.metadata.access ?? "subscription" : undefined;@@ -558,16 +579,7 @@ export class ProviderRegistry {},access: driver?.metadata.access ?? "subscription",install: withServerInstall(driver?.install, npmPresent, this.appStandaloneCopy(driver, cli ?? cliDefaultOf(driver))),- authentication: inst.startAuthentication- ? {- method: inst.authenticationMethod ?? (inst.getAuthentication && inst.completeAuthentication- ? "paste-code" as const // a link to open, then a code pasted back (Claude)- : inst.getAuthentication- ? "device-code" as const // a code to enter at the provider's page (Codex)- : "callback-url" as const), // a link and a callback URL (managed engines)- signOut: inst.signOut !== undefined,- }- : undefined,+ authentication: signInOf(inst),cli,cliDefault: cliDefaultOf(driver),cliCandidates: candidatesFor(driver),diff --git a/server/host/engine-hints.test.ts b/server/host/engine-hints.test.tsnew file mode 100644index 0000000000..2220698a97--- /dev/null+++ b/server/host/engine-hints.test.ts@@ -0,0 +1,173 @@+import { describe, expect, it } from "vitest";++import type { EngineInstall, ProviderSnapshot } from "../contracts.ts";+import { BUILT_IN_DRIVERS } from "../drivers/builtIn.ts";+import { DEFAULT_FLEET } from "../instance-fleets.ts";+import { modelMenu, type MenuEngine } from "../routes/internal-models.ts";+import { botPersona } from "../system-prompt.ts";+import { createEngineHints, engineHint, type EngineHint, type EngineHintInput } from "./engine-hints.ts";++const PROVIDERS = "Settings → AI → Providers";+const KEYS = "Settings → AI → Other services";+const notInstalled: ProviderSnapshot = { state: "unavailable", reason: "agy: command not found" };+const signedOut: ProviderSnapshot = { state: "available", authenticated: false };+const driver = (kind: string) => BUILT_IN_DRIVERS.find((one) => one.driverKind === kind)!;+const managed: EngineInstall = { managed: { label: "Antigravity", downloadBytes: 1 } };+const hint = (input: Partial<EngineHintInput>) => engineHint({+ name: "Engine", driverKind: "x", enabled: true, access: undefined, snapshot: undefined, install: undefined, signIn: undefined, ...input,+});++describe("engineHint", () => {+ it("says Google's engine signs in with a Google account, not an API key, whether it is set up yet or only signed out", () => {+ const antigravity = { name: "Google Gemini (Antigravity)", driverKind: "antigravityAgent", access: "subscription" as const,+ account: driver("antigravityAgent").metadata.signInAccount, signIn: { method: "callback-url" } };+ expect(antigravity.account).toBe("Google");+ const fresh = hint({ ...antigravity, snapshot: notInstalled, install: managed });+ expect(fresh).toEqual({ why: "not set up yet",+ connect: `sign in with your Google account in ${PROVIDERS}; a subscription on that account covers it, no API key (the app installs it first)` });+ expect(hint({ ...antigravity, snapshot: signedOut, install: managed })).toEqual({ why: "not signed in",+ connect: `sign in with your Google account in ${PROVIDERS}; a subscription on that account covers it, no API key` });+ // On a platform with no runtime to download it is installed first, then signed in the same way.+ expect(hint({ ...antigravity, snapshot: notInstalled }).connect).toBe(`install it in ${PROVIDERS}, then sign in there with that provider's account (no API key)`);+ });++ it("sends a key-only engine to the key, billed to it, and never claims a plan covers it", () => {+ const mistral = { name: "Mistral (API)", driverKind: "mistral", access: "api" as const, install: driver("mistral").install };+ expect(hint({ ...mistral, snapshot: { state: "unavailable", reason: "No API key" } })).toEqual({ why: "no API key saved",+ connect: `save its API key in ${KEYS} (use is billed to that key)` });+ expect(hint({ ...mistral, snapshot: { state: "available", authenticated: false } }).why).toBe("no working API key saved");+ // Claude's API-key instance once Claude Code is installed, as the card decides it.+ const claudeKey = { name: "Claude (API key)", driverKind: "claudeAgent", access: "api" as const, install: driver("claudeAgent").install };+ expect(hint({ ...claudeKey, snapshot: { state: "available", authenticated: false, version: "2.1.0" } }).connect).toMatch(/^save its API key/u);+ // Before Claude Code is installed the card offers the install; the key still follows, never "no API key".+ expect(hint({ ...claudeKey, signIn: { method: "paste-code" }, snapshot: notInstalled }).connect).toBe(`install it in ${PROVIDERS}, then save its API key in ${KEYS} (use is billed to that key)`);+ expect(hint({ ...claudeKey, signIn: { method: "paste-code" }, snapshot: { state: "available", authenticated: false } }).connect).not.toMatch(/no API key/u);+ // A key engine with its own program is installed first, then given the key.+ expect(hint({ name: "DeepSeek Harness", driverKind: "deepseekAgent", access: "subscription", install: driver("deepseekAgent").install, snapshot: notInstalled }).connect)+ .toBe(`install it in ${PROVIDERS}, then save its API key in ${KEYS} (use is billed to that key)`);+ // A company's key is the company's: no key of the person's own is asked for.+ expect(hint({ ...mistral, managed: true, snapshot: { state: "available", authenticated: false } }).connect).not.toMatch(/API key/u);+ });++ it("names the account and the terminal step of an engine signed in outside the app", () => {+ expect(hint({ name: "Codex", driverKind: "codex", account: "ChatGPT", signIn: { method: "device-code" }, snapshot: signedOut }).connect)+ .toBe(`sign in with your ChatGPT account in ${PROVIDERS}; a subscription on that account covers it, no API key`);+ expect(hint({ name: "Kiro", driverKind: "kiroAgent", install: driver("kiroAgent").install, snapshot: signedOut }).connect)+ .toBe(`run \`kiro-cli login\` in a terminal on the computer the bots run on, or follow ${PROVIDERS}`);+ // Nothing known about how it signs in: no claim either way.+ expect(hint({ name: "Gemini", driverKind: "geminiAgent", access: "subscription", install: driver("geminiAgent").install, snapshot: notInstalled }).connect)+ .toBe(`install it in ${PROVIDERS}; it then shows how it signs in`);+ });++ it("gives each other reason its own line", () => {+ const cases: Array<[Partial<EngineHintInput>, EngineHint]> = [+ [{ enabled: false, snapshot: signedOut }, { why: "turned off", connect: `turn it on in ${PROVIDERS}` }],+ [{ policy: "Acme does not allow the Engine engine on this computer. Choose another model for this bot." },+ { why: "not allowed by the organization", connect: "Acme does not allow the Engine engine on this computer. Choose another model for this bot." }],+ [{ offered: false }, { why: "not offered on this server", connect: "its admin chooses which AIs it offers" }],+ [{ snapshot: { ...notInstalled, installing: true } }, { why: "being installed now", connect: "nothing to do: it is ready in a few minutes" }],+ [{ snapshot: { state: "available", notEngineCli: true } }, { why: "its program path runs another program", connect: `reset the path in ${PROVIDERS}` }],+ [{ snapshot: { state: "unavailable", ollama: { state: "not-running", url: "http://127.0.0.1:11434" } } },+ { why: "its Ollama server is not answering", connect: `start Ollama and pull a model, or change its address in ${PROVIDERS}` }],+ [{ snapshot: { ...signedOut, authenticationUnavailableReason: "Sign-in needs the desktop app." } }, { why: "can't be signed in here", connect: "Sign-in needs the desktop app." }],+ [{ broken: true }, { why: "its saved settings can't be read", connect: `fix or remove it in ${PROVIDERS}` }],+ [{ snapshot: { state: "available", authenticated: true } }, { why: "can't run now", connect: `${PROVIDERS} shows why` }],+ [{ snapshot: { state: "unavailable", version: "1.0.0", reason: "The CLI exited." } }, { why: "can't run now", connect: `${PROVIDERS} shows why` }],+ ];+ for (const [input, expected] of cases) expect(hint(input)).toEqual(expected);+ });++ it("reads an installed engine's own refusal instead of calling it not installed (the drivers' real snapshots)", () => {+ // Codex on a ChatGPT plan where the plan can't sign in (codex.ts): the driver's reason, not "install it".+ const plan = "ChatGPT plan sign-in is not available on this Cloud. Choose a Company model, or use an API key.";+ expect(hint({ name: "ChatGPT plan", driverKind: "codex", account: "ChatGPT", signIn: { method: "browser-pkce" }, install: driver("codex").install,+ snapshot: { state: "unavailable", authenticated: false, chatgptPlan: true, reason: plan, authenticationUnavailableReason: plan } }))+ .toEqual({ why: "can't be signed in here", connect: plan });+ // Muse Code installed, signed out (muse-code.ts).+ expect(hint({ name: "Muse Code", driverKind: "museCode", access: "subscription", install: driver("museCode").install,+ snapshot: { state: "unavailable", reason: "Sign in to Muse Code: run `muse login` in a terminal.", authenticated: false, version: "1.2.0" } }))+ .toEqual({ why: "not signed in", connect: `run \`muse login\` in a terminal on the computer the bots run on, or follow ${PROVIDERS}` });+ // Muse Code not installed (no version) is the install step.+ expect(hint({ name: "Muse Code", driverKind: "museCode", access: "subscription", install: driver("museCode").install,+ snapshot: { state: "unavailable", reason: "Muse Code isn't installed on this computer.", authenticated: false } }).why).toBe("not installed");+ // Claude's API-key instance, Claude Code installed, no key saved (claude.ts).+ expect(hint({ name: "Claude (API key)", driverKind: "claudeAgent", access: "api", account: "Claude", signIn: { method: "paste-code" }, install: driver("claudeAgent").install,+ snapshot: { state: "unavailable", version: "2.1.300", reason: "Add an Anthropic API key." } }))+ .toEqual({ why: "no working API key saved", connect: `save its API key in ${KEYS} (use is billed to that key)` });+ });++ it("says what the app's own sign-in is for engines without a named subscription, and no more (core.ts snapshots)", () => {+ const acpSignedOut: ProviderSnapshot = { state: "available", version: "1.0.0", authenticated: false };+ const lines = Object.fromEntries(["cursorAgent", "kimiAgent", "grokAgent", "mistralVibeAgent"].map((kind) => [kind, hint({+ name: driver(kind).metadata.displayName, driverKind: kind, access: driver(kind).metadata.access, install: driver(kind).install,+ signIn: { method: kind === "mistralVibeAgent" ? "browser" : "device-code" }, snapshot: acpSignedOut,+ })]));+ expect(lines).toEqual({+ cursorAgent: { why: "not signed in", connect: `sign in with your Cursor account in ${PROVIDERS}; no API key needed` },+ kimiAgent: { why: "not signed in", connect: `sign in with your Kimi account in ${PROVIDERS}; no API key needed` },+ grokAgent: { why: "not signed in", connect: `sign in with your Grok account in ${PROVIDERS}; no API key needed` },+ mistralVibeAgent: { why: "not signed in", connect: `sign in with your Mistral account in ${PROVIDERS}; no API key needed` },+ });+ for (const line of Object.values(lines)) expect(line.connect).not.toMatch(/subscription|plan/u);+ });++ it("leaves no engine without why and how to connect, whatever stops it", () => {+ const snapshots: Array<ProviderSnapshot | undefined> = [undefined, notInstalled, signedOut, { state: "available", authenticated: true }, { ...notInstalled, installing: true }];+ for (const one of BUILT_IN_DRIVERS) {+ for (const snapshot of snapshots) {+ for (const signIn of [undefined, { method: "device-code" }]) {+ for (const access of [one.metadata.access, "api" as const]) {+ const line = hint({ name: one.metadata.displayName, driverKind: one.driverKind, access, install: one.install, signIn, snapshot,+ ...(one.metadata.signInAccount ? { account: one.metadata.signInAccount } : {}) });+ expect(line.why.trim(), one.driverKind).not.toBe("");+ expect(line.connect.trim(), one.driverKind).not.toBe("");+ }+ }+ }+ }+ });+});++describe("what the hints cost", () => {+ it("costs nothing outside the list_models call: no prompt line about engines rides every turn", () => {+ expect(botPersona({ name: "MausBot", defaultBot: {} })).not.toMatch(/list_models|API key|sign in/u);+ });+});++describe("list_models on a fresh install with nothing set up", () => {+ const registry = (snapshot: (kind: string) => ProviderSnapshot) => {+ const live = Object.entries(DEFAULT_FLEET).map(([instanceId, entry]) => {+ const kind = driver(entry.driver);+ return { instanceId, driverKind: entry.driver, displayName: entry.displayName ?? kind.metadata.displayName, enabled: true, access: entry.access ?? kind.metadata.access,+ models: kind.models, adapter: { capabilities: {} }, account: kind.metadata.signInAccount,+ // Pinned: whether Google publishes a runtime to download depends on the platform the test runs on.+ install: entry.driver === "antigravityAgent" ? managed : kind.install,+ signIn: ["antigravityAgent", "codex", "claudeAgent", "kimiAgent", "grokAgent", "cursorAgent"].includes(entry.driver) ? { method: "browser" } : undefined };+ });+ const byId = new Map(live.map((one) => [one.instanceId, one]));+ const hints = createEngineHints({+ registry: {+ get: (id) => byId.get(id) ?? null, knownSnapshot: (id) => snapshot(byId.get(id)!.driverKind),+ connection: (id) => ({ install: byId.get(id)!.install, signIn: byId.get(id)!.signIn, account: byId.get(id)!.account }), entries: () => [],+ },+ access: (id) => byId.get(id)?.access, managed: () => false, policy: () => undefined,+ });+ return { live: live as unknown as MenuEngine[], hints };+ };++ it("names every engine with why and how, grouped, in a few hundred bytes more than the names alone", () => {+ const { live, hints } = registry(() => notInstalled);+ const current = { instanceId: "claude", model: "" };+ const menu = modelMenu({ engines: live, current, pinned: [], refusal: () => null, down: (engine) => hints.hint(engine.instanceId) });+ const named = menu.unavailable!.flatMap((group) => group.engines);+ expect(named.toSorted()).toEqual(live.map((engine) => engine.displayName!).toSorted());+ for (const group of menu.unavailable!) expect(group.why && group.connect).toBeTruthy();+ const google = menu.unavailable!.find((group) => group.engines.includes("Google Gemini (Antigravity)"))!;+ expect(google.connect).toMatch(/Google account.*no API key/u);+ // Before: the names alone. The lines repeat once per group, not once per engine.+ const before = JSON.stringify({ current, engines: [], unavailable: named });+ const added = JSON.stringify(menu).length - before.length;+ expect(menu.unavailable!.length).toBeLessThanOrEqual(7);+ expect(added).toBeLessThan(1_000);+ });+});diff --git a/server/host/engine-hints.ts b/server/host/engine-hints.tsnew file mode 100644index 0000000000..d4e26d6210--- /dev/null+++ b/server/host/engine-hints.ts@@ -0,0 +1,120 @@+// Why an engine can't run now and how the person connects it, for list_models. A bot once read "unavailable" next to+// Google's engine and told someone it needed a paid API key; it signs in with a Google account. So every engine a bot+// sees as unusable carries both, built from what Settings' provider card is built from: the engine's status, its+// install descriptor, its sign-in method and whether it takes only an API key (shared/engine-sign-in.ts).+import { keyOnlyEngine } from "../../shared/engine-sign-in.ts";+import { placePath } from "../app-settings/places.ts";+import type { EngineAccess, EngineInstall, ProviderSnapshot } from "../contracts.ts";++export interface EngineHint {+ /** Why it can't run now. */+ why: string;+ /** What the person does to connect it, and where. */+ connect: string;+}++export interface EngineHintInput {+ name: string;+ driverKind: string;+ enabled: boolean;+ access: EngineAccess | undefined;+ /** The last status read; none yet reads as nothing known. */+ snapshot: ProviderSnapshot | undefined;+ install: EngineInstall | undefined;+ /** How the app signs it in, when it can (the provider card's sign-in button). */+ signIn: { method: string } | undefined;+ /** The account whose subscription that sign-in uses (driver metadata signInAccount). */+ account?: string;+ /** The organization's rule that turns it off here. */+ policy?: string;+ /** False when this server does not offer it. */+ offered?: boolean;+ /** Its saved settings could not be read. */+ broken?: true;+ /** Set up by a company: never a key of the person's own. */+ managed?: true;+}++const REASON_CHARS = 160;+const clip = (text: string) => {+ const line = text.replace(/\s+/g, " ").trim();+ return line.length > REASON_CHARS ? `${line.slice(0, REASON_CHARS - 1)}…` : line;+};++export function engineHint(engine: EngineHintInput): EngineHint {+ const providers = placePath("providers");+ const key = `save its API key in ${placePath("keys")} (use is billed to that key)`;+ const snapshot = engine.snapshot;+ const keyOnly = keyOnlyEngine({ ...engine, snapshot: snapshot ?? {} }) || engine.install?.settings === "connections";+ // A named account is a subscription sign-in (Google, ChatGPT, Claude); any other app sign-in only replaces a key.+ const signIn = engine.account+ ? `sign in with your ${engine.account} account in ${providers}; a subscription on that account covers it, no API key`+ : `sign in with your ${engine.name.replace(/\s*\(.*\)$/u, "")} account in ${providers}; no API key needed`;+ if (engine.broken) return { why: "its saved settings can't be read", connect: `fix or remove it in ${providers}` };+ if (!engine.enabled) return { why: "turned off", connect: `turn it on in ${providers}` };+ if (engine.policy) return { why: "not allowed by the organization", connect: clip(engine.policy) };+ if (engine.offered === false) return { why: "not offered on this server", connect: "its admin chooses which AIs it offers" };+ if (engine.managed) return { why: snapshot?.authenticated === false ? "not signed in" : "can't run now", connect: "the company that manages it fixes this: ask its admin" };+ if (snapshot?.installing) return { why: "being installed now", connect: "nothing to do: it is ready in a few minutes" };+ if (snapshot?.notEngineCli) return { why: "its program path runs another program", connect: `reset the path in ${providers}` };+ if (snapshot?.ollama) {+ const why = snapshot.ollama.state === "no-models" ? "its Ollama has no models yet" : "its Ollama server is not answering";+ return { why, connect: `start Ollama and pull a model, or change its address in ${providers}` };+ }+ // The driver's own reason it can't sign in here wins (a ChatGPT plan on a Cloud says what to use instead).+ if (snapshot?.authenticationUnavailableReason) return { why: "can't be signed in here", connect: clip(snapshot.authenticationUnavailableReason) };+ const installed = snapshot?.state === "available" || Boolean(snapshot?.version);+ if (installed && snapshot?.authenticated === false) {+ if (keyOnly) return { why: "no working API key saved", connect: key };+ if (engine.signIn && engine.access !== "api") return { why: "not signed in", connect: signIn };+ const command = engine.install?.signInCommand;+ return { why: "not signed in", connect: command ? `run \`${clip(command)}\` in a terminal on the computer the bots run on, or follow ${providers}` : `sign in from ${providers}` };+ }+ if (snapshot?.state === "unavailable" && !snapshot.version) {+ // The app downloads a managed runtime as part of its sign-in: nothing to install first.+ if (engine.install?.managed && engine.signIn) return { why: "not set up yet", connect: `${signIn} (the app installs it first)` };+ if (keyOnly && !engine.install?.command && !engine.install?.server) return { why: "no API key saved", connect: key };+ // Claude's API-key instance has a sign-in too: an "api" engine is never said to need no key.+ const then = keyOnly || engine.access === "api" ? `, then ${key}` : engine.signIn ? ", then sign in there with that provider's account (no API key)" : "; it then shows how it signs in";+ return { why: "not installed", connect: `install it in ${providers}${then}` };+ }+ // Installed but refused for its own reason (a key it needs, a check that failed): the key when it takes only one.+ if (snapshot?.state === "unavailable" && keyOnly) return { why: "no working API key saved", connect: key };+ return { why: "can't run now", connect: `${providers} shows why` };+}++/** The hints for a running server: the registry holds the status and how each engine connects, read without probing. */+export function createEngineHints(deps: {+ registry: {+ get(instanceId: string): { driverKind: string; displayName: string | undefined; enabled: boolean; models: { default: string } } | null;+ knownSnapshot(instanceId: string): ProviderSnapshot | undefined;+ connection(instanceId: string): { install: EngineInstall | undefined; signIn: { method: string } | undefined; account: string | undefined };+ entries(): ReadonlyArray<{ shadow?: { driverKind: string; displayName: string | undefined } }>;+ };+ /** The engine's access as Settings has it (a saved override, else its driver's). */+ access(instanceId: string): EngineAccess | undefined;+ /** Set up by a company, not by the person. */+ managed(instanceId: string): boolean;+ policy(instance: { instanceId: string; driverKind: string }): string | undefined;+ offered?(selection: { instanceId: string; model: string }): boolean;+}) {+ const providers = () => placePath("providers");+ return {+ hint(instanceId: string): EngineHint {+ const live = deps.registry.get(instanceId);+ if (!live) return { why: "not set up", connect: `add it in ${providers()}` };+ const { install, signIn, account } = deps.registry.connection(instanceId);+ const policy = deps.policy({ instanceId, driverKind: live.driverKind });+ return engineHint({+ name: live.displayName || live.driverKind, driverKind: live.driverKind, enabled: live.enabled, access: deps.access(instanceId),+ snapshot: deps.registry.knownSnapshot(instanceId), install, signIn, ...(account ? { account } : {}),+ ...(deps.managed(instanceId) ? { managed: true as const } : {}),+ ...(policy ? { policy } : {}),+ ...(deps.offered && !deps.offered({ instanceId, model: live.models.default }) ? { offered: false } : {}),+ });+ },+ broken: () => deps.registry.entries().flatMap(({ shadow }) => shadow+ ? [{ name: shadow.displayName || shadow.driverKind, hint: engineHint({ name: "", driverKind: shadow.driverKind, enabled: true, access: undefined, snapshot: undefined, install: undefined, signIn: undefined, broken: true }) }]+ : []),+ };+}diff --git a/server/host/own-threads.ts b/server/host/own-threads.tsindex ae8b2516c4..aff4c91bc5 100644--- a/server/host/own-threads.ts+++ b/server/host/own-threads.ts@@ -5,6 +5,7 @@ import { modelMenu, type MenuEngine, type ModelMenu } from "../routes/internal-mimport type { BotRecord, Store } from "../store.ts";import type { NewThreadLevel } from "../task-record.ts";import type { ThreadModelFallback } from "../thread-model.ts";+import type { EngineHint } from "./engine-hints.ts";import { createSpawnLevel, type SpawnLevelDeps } from "./spawn-level.ts";type Placed = { botId: string; threadId: string; groupId?: string };@@ -20,6 +21,10 @@ export function createOwnThreads(deps: Pick<SpawnLevelDeps, "sourceLevel" | "may/** Why turn start would run a thread chosen on `selection` on the bot's own model instead. */givesWay(selection: ModelSelection, botModel: ModelSelection): ThreadModelFallback | null;modelName(selection: ModelSelection): string;+ /** Why an engine can't run now and how the person connects it (engine-hints.ts). */+ hint(instanceId: string): EngineHint;+ /** Engines whose saved settings could not be read. */+ broken?(): ReadonlyArray<{ name: string; hint: EngineHint }>;}) {const { store } = deps;/** The level a new thread opened from a conversation starts at (spawn-level.ts). */@@ -76,7 +81,9 @@ export function createOwnThreads(deps: Pick<SpawnLevelDeps, "sourceLevel" | "mayif (!bot) return null;const current = deps.current(botId, threadId) ?? bot.modelSelection;return modelMenu({ engines: deps.registry.instances(), current, pinned: [bot.modelSelection], refusal: (selection) => refusal(selection, bot),- down: (engine) => deps.givesWay({ instanceId: engine.instanceId, model: engine.models.default }, bot.modelSelection) === "unavailable", search });+ down: (engine) => deps.givesWay({ instanceId: engine.instanceId, model: engine.models.default }, bot.modelSelection) === "unavailable" ? deps.hint(engine.instanceId) : null,+ signedOut: (engine) => deps.givesWay({ instanceId: engine.instanceId, model: engine.models.default }, bot.modelSelection) === "signed-out" ? deps.hint(engine.instanceId) : null,+ broken: deps.broken?.() ?? [], search });},};}diff --git a/server/host/spawn-level.test.ts b/server/host/spawn-level.test.tsindex 4d6d18cac4..24cb112d39 100644--- a/server/host/spawn-level.test.ts+++ b/server/host/spawn-level.test.ts@@ -17,7 +17,7 @@ function host(options: { floored?: Set<string>; owner?: boolean } = {}) {const store = new Store(claude);const own = createOwnThreads({store, registry: { instances: () => [], cliTarget: (id) => ({ driverKind: drivers[id]! }) }, node: () => undefined,- current: () => undefined, proposalRefusal: () => null, givesWay: () => null, modelName: (one) => one.model,+ current: () => undefined, proposalRefusal: () => null, givesWay: () => null, modelName: (one) => one.model, hint: () => ({ why: "", connect: "" }),// sourceApprovalMode: a guest's or a fenced turn (`floored`) and a Bot API thread run at Ask, whatever the thread says.sourceLevel: (botId, threadId) => options.floored?.has(threadId) || store.taskByThread(botId, threadId)?.botApi? "ask" : approvalModeFor(store.projectBotForTask(botId, threadId)!),diff --git a/server/index.ts b/server/index.tsindex a91036467f..51bc477fac 100644--- a/server/index.ts+++ b/server/index.ts@@ -598,7 +598,7 @@ import { createTrustAnswers } from "./host/trust-answers.ts";import { createInternalThreadRoutes } from "./routes/internal-threads.ts";import { createBrowserEvidenceRoutes } from "./routes/browser-evidence.ts";import { createSignInCardRoutes } from "./routes/sign-in-cards.ts";-import { createInternalChiefTeamRoutes } from "./routes/internal-chief-team.ts"; import { createInternalModelRoutes } from "./routes/internal-models.ts"; import { createOwnThreads } from "./host/own-threads.ts"; import { burstDefaultModel, burstProposalRefusal, createBurstHost } from "./host/burst-host.ts"; import { expandBurstTurnText } from "./burst/command.ts"; import { createBurstProposalRoutes, createBurstRoutes } from "./routes/burst.ts"; import { createCheckBacks } from "./host/check-backs.ts"; import { writeCheckBackLine } from "./host/check-back-host.ts"; import { checkBackRefusal, createCheckBackRoutes, createCheckBackToolRoutes } from "./routes/check-backs.ts"; import { createHandoffStatus } from "./host/handoff-status.ts";+import { createInternalChiefTeamRoutes } from "./routes/internal-chief-team.ts"; import { createInternalModelRoutes } from "./routes/internal-models.ts"; import { createOwnThreads } from "./host/own-threads.ts"; import { createEngineHints } from "./host/engine-hints.ts"; import { burstDefaultModel, burstProposalRefusal, createBurstHost } from "./host/burst-host.ts"; import { expandBurstTurnText } from "./burst/command.ts"; import { createBurstProposalRoutes, createBurstRoutes } from "./routes/burst.ts"; import { createCheckBacks } from "./host/check-backs.ts"; import { writeCheckBackLine } from "./host/check-back-host.ts"; import { checkBackRefusal, createCheckBackRoutes, createCheckBackToolRoutes } from "./routes/check-backs.ts"; import { createHandoffStatus } from "./host/handoff-status.ts";import { createRoomHoldRoutes } from "./routes/room-holds.ts";import { checkedGroupResponder, createGroupRoutes } from "./routes/groups.ts";import { createChannelRoutes } from "./routes/channels.ts";@@ -9070,7 +9070,7 @@ const validateModelProposal = (selection: ModelSelection, current?: BotRecord):}return null;};-const ownThreads = createOwnThreads({ store, registry, node: (id) => coordinator.node(id), current: turnSelection, proposalRefusal: validateModelProposal, givesWay: modelGivesWay, modelName, sourceLevel: sourceApprovalMode, mayRaise: (threadId) => !outsideLineage.handsNoLevel(threadId) && (!CLOUD_HOME || cloudOwnerPerson(threadPersonKey(threadId))) && (!HOSTED_WORKSPACE || sharedWorkspaceFullAccessEnabled()) }); const burst = createBurstHost({ dataDir: DATA_DIR, cloudHome: Boolean(CLOUD_HOME), tier: () => cloudPlanTier.tier(), maxParallel: () => cfg.burst?.maxParallel, hasRoom: () => engineMemory.laneHasRoom(), store, language: (threadId) => threadLanguage(threadId), startTurn: (botId, text, opts) => startTurn(botId, text, opts), stop: (botId, threadId, cause) => { void interruptDirectThread(botId, threadId, cause).catch(() => {}); }, threadBusy, opened: (threadId, parent) => threadStarters.set(threadId, openerFrom(parent)), origin: (run) => withPerson({ kind: "user", request: quoteInNote(run.task, 400) }, threadPersonKey(run.threadId)), approval: ownThreads.approvalFor, defaultModel: (bot, threadId) => burstDefaultModel({ own: store.taskByThread(bot.id, threadId)?.modelSelection ?? bot.modelSelection, catalog: (id) => registry.get(id)?.models, refused: (id) => quickFallback.refused(id), usable: (selection) => ownThreads.refusal(selection, bot) === null }), modelName, route: (notification) => teamMessages.route(notification, { routine: true }), announce: (notification) => { broadcast({ kind: "notify", notification: logNotification(notification) }); } });+const engineHints = createEngineHints({ registry, access: (id) => providerConfigs()[id]?.access ?? registry.access(id), managed: (id) => managedDesktop.owns(id), policy: policyModelRefusal, ...(hostedModels ? { offered: (selection) => hostedModels!.allows(selection) } : {}) }); const ownThreads = createOwnThreads({ store, registry, node: (id) => coordinator.node(id), current: turnSelection, proposalRefusal: validateModelProposal, givesWay: modelGivesWay, modelName, hint: engineHints.hint, broken: engineHints.broken, sourceLevel: sourceApprovalMode, mayRaise: (threadId) => !outsideLineage.handsNoLevel(threadId) && (!CLOUD_HOME || cloudOwnerPerson(threadPersonKey(threadId))) && (!HOSTED_WORKSPACE || sharedWorkspaceFullAccessEnabled()) }); const burst = createBurstHost({ dataDir: DATA_DIR, cloudHome: Boolean(CLOUD_HOME), tier: () => cloudPlanTier.tier(), maxParallel: () => cfg.burst?.maxParallel, hasRoom: () => engineMemory.laneHasRoom(), store, language: (threadId) => threadLanguage(threadId), startTurn: (botId, text, opts) => startTurn(botId, text, opts), stop: (botId, threadId, cause) => { void interruptDirectThread(botId, threadId, cause).catch(() => {}); }, threadBusy, opened: (threadId, parent) => threadStarters.set(threadId, openerFrom(parent)), origin: (run) => withPerson({ kind: "user", request: quoteInNote(run.task, 400) }, threadPersonKey(run.threadId)), approval: ownThreads.approvalFor, defaultModel: (bot, threadId) => burstDefaultModel({ own: store.taskByThread(bot.id, threadId)?.modelSelection ?? bot.modelSelection, catalog: (id) => registry.get(id)?.models, refused: (id) => quickFallback.refused(id), usable: (selection) => ownThreads.refusal(selection, bot) === null }), modelName, route: (notification) => teamMessages.route(notification, { routine: true }), announce: (notification) => { broadcast({ kind: "notify", notification: logNotification(notification) }); } });const teamMemory = new TeamMemory(join(DATA_DIR, "team-memory.json"));const teamMemoryRequests = createTeamMemoryRequests({ teamMemory, store, sectionKey: sectionContextKey, decide: (row) => appendDecision(DATA_DIR, row) });const outsideWrites = createOutsideWrites({ store, notify, language: (threadId) => threadLanguage(threadId), decide: (row) => appendDecision(DATA_DIR, row),diff --git a/server/routes/internal-models.test.ts b/server/routes/internal-models.test.tsindex 95da1ba4d9..42d75cb279 100644--- a/server/routes/internal-models.test.ts+++ b/server/routes/internal-models.test.ts@@ -1,6 +1,7 @@import { describe, expect, it, vi } from "vitest";import type { ModelSelection } from "../../shared/wire.ts";+import type { EngineHint } from "../host/engine-hints.ts";import { MENU_FOUND, MENU_SHORT, modelMenu as menuOf, type MenuEngine } from "./internal-models.ts";const engine = (instanceId: string, ids: readonly string[], extra: Partial<MenuEngine> = {}): MenuEngine => ({@@ -11,7 +12,8 @@ const engine = (instanceId: string, ids: readonly string[], extra: Partial<MenuE});const current: ModelSelection = { instanceId: "claude", model: "claude-sonnet-5" };const opens = () => null;-const modelMenu = (input: Omit<Parameters<typeof menuOf>[0], "down"> & { down?: (engine: MenuEngine) => boolean }) => menuOf({ down: () => false, ...input });+const modelMenu = (input: Omit<Parameters<typeof menuOf>[0], "down"> & { down?: (engine: MenuEngine) => EngineHint | null }) => menuOf({ down: () => null, ...input });+const notInstalled: EngineHint = { why: "not installed", connect: "install it in Settings → AI → Providers" };describe("modelMenu", () => {it("keeps a 2,000-model catalog to a short list, its current model first, and counts the rest", () => {@@ -93,9 +95,10 @@ describe("modelMenu", () => {it("marks an engine unusable with start_thread's own reason after a few refusals, without checking the rest of a big catalog", () => {const grok = engine("grok", Array.from({ length: 500 }, (_, i) => `grok-${i}`));const refusal = vi.fn((selection: ModelSelection) => selection.instanceId === "grok" ? "Grok · grok-0 can't run now: it is signed out." : null);- const menu = modelMenu({ engines: [grok, engine("claude", ["claude-sonnet-5"])], current, pinned: [], refusal });+ const signedOut = (row: MenuEngine) => row.instanceId === "grok" ? { why: "not signed in", connect: "sign in with your Grok account in Settings → AI → Providers" } : null;+ const menu = modelMenu({ engines: [grok, engine("claude", ["claude-sonnet-5"])], current, pinned: [], refusal, signedOut });expect(menu.engines).toEqual([- { instanceId: "grok", name: "Grok", unusable: "Grok · grok-0 can't run now: it is signed out." },+ { instanceId: "grok", name: "Grok", unusable: "Grok · grok-0 can't run now: it is signed out.", connect: "sign in with your Grok account in Settings → AI → Providers" },{ instanceId: "claude", name: "Claude", models: ["claude-sonnet-5"] },]);expect(refusal.mock.calls.filter(([selection]) => selection.instanceId === "grok")).toHaveLength(3);@@ -112,12 +115,27 @@ describe("modelMenu", () => {it("names engines that can't run anything in one list instead of a row each, and search finds them by name", () => {const engines = [engine("claude", ["claude-sonnet-5"]), engine("cursor", ["auto"]), engine("mistral", ["mistral-large"])];- const down = (row: MenuEngine) => row.instanceId !== "claude";+ const down = (row: MenuEngine) => row.instanceId !== "claude" ? notInstalled : null;const refusal = vi.fn((_selection: ModelSelection) => null);expect(modelMenu({ engines, current, pinned: [], refusal, down })).toEqual({ current,- engines: [{ instanceId: "claude", name: "Claude", models: ["claude-sonnet-5"] }], unavailable: ["Cursor", "Mistral"] });+ engines: [{ instanceId: "claude", name: "Claude", models: ["claude-sonnet-5"] }], unavailable: [{ engines: ["Cursor", "Mistral"], ...notInstalled }] });expect(refusal.mock.calls.every(([selection]) => selection.instanceId === "claude")).toBe(true);- expect(modelMenu({ engines, current, pinned: [], refusal: opens, down, search: "mistral" })).toEqual({ current, engines: [], unavailable: ["Mistral"] });+ expect(modelMenu({ engines, current, pinned: [], refusal: opens, down, search: "mistral" })).toEqual({ current, engines: [], unavailable: [{ engines: ["Mistral"], ...notInstalled }] });+ });++ it("names an engine with no models yet and one whose settings can't be read, each with why and how to connect", () => {+ const signIn: EngineHint = { why: "not signed in", connect: "sign in with your Google account in Settings → AI → Providers" };+ const engines = [engine("claude", ["claude-sonnet-5"]), engine("antigravity", []), engine("kimi", [])];+ const down = (row: MenuEngine) => row.instanceId === "antigravity" ? signIn : row.instanceId === "kimi" ? notInstalled : null;+ const broken = [{ name: "Mine", hint: { why: "its saved settings can't be read", connect: "fix or remove it in Settings → AI → Providers" } }];+ expect(modelMenu({ engines, current, pinned: [], refusal: opens, down, broken }).unavailable).toEqual([+ { engines: ["Antigravity"], ...signIn }, { engines: ["Kimi"], ...notInstalled }, { engines: ["Mine"], ...broken[0]!.hint },+ ]);+ expect(modelMenu({ engines, current, pinned: [], refusal: opens, down, broken, search: "kimi" }).unavailable).toEqual([{ engines: ["Kimi"], ...notInstalled }]);+ // An engine that can run but has nothing to list stays out, as before; signed out, it is named with why.+ expect(modelMenu({ engines: [engine("kimi", [])], current, pinned: [], refusal: opens })).toEqual({ current, engines: [] });+ const signIn2 = { why: "not signed in", connect: "run `kimi login` in a terminal" };+ expect(modelMenu({ engines: [engine("kimi", [])], current, pinned: [], refusal: opens, signedOut: () => signIn2 }).unavailable).toEqual([{ engines: ["Kimi"], ...signIn2 }]);});it("leaves out a single model start_thread would refuse and keeps the engine", () => {diff --git a/server/routes/internal-models.ts b/server/routes/internal-models.tsindex 1c02130237..456d458367 100644--- a/server/routes/internal-models.ts+++ b/server/routes/internal-models.ts@@ -1,4 +1,5 @@import { EFFORT_LEVELS, type ModelSelection } from "../../shared/wire.ts";+import type { EngineHint } from "../host/engine-hints.ts";import { PASS, type RouteHandler } from "./table.ts";/** Per engine without `search`, as in t3code's orchestrator_capabilities: one call lands whole in the bot's context. */@@ -32,15 +33,20 @@ export interface MenuRow {efforts?: readonly string[];/** Why no thread can run on this engine now; it then lists no models. */unusable?: string;+ /** How the person connects it again, when it is signed out. */+ connect?: string;/** Models the engine has but won't run until something changes, with what: the bot can say so instead of calling them gone. */blocked?: Array<{ id: string; why: string }>;}+/** Engines that can't run now for the same reason, fixed the same way: one entry each would repeat the line. */+export type UnavailableGroup = { engines: string[] } & EngineHint;+export interface ModelMenu {current: ModelSelection;engines: MenuRow[];- /** Engines that can't run anything now (not set up, turned off, unreachable), by name: a row each would cost more than they say. */- unavailable?: string[];+ /** Engines that can't run anything now (not set up, turned off, unreachable), by why and how to connect. */+ unavailable?: UnavailableGroup[];}const squash = (text: string) => text.toLowerCase().replace(/[^a-z0-9]/g, "");@@ -52,12 +58,24 @@ export function modelMenu(input: {current: ModelSelection;pinned: readonly ModelSelection[];refusal(selection: ModelSelection): string | null;- down(engine: MenuEngine): boolean;+ /** Why `engine` can't run now and how it is connected; null while it can. */+ down(engine: MenuEngine): EngineHint | null;+ /** A signed-out engine's hint: its row keeps start_thread's own refusal as the reason and adds how to connect. */+ signedOut?(engine: MenuEngine): EngineHint | null;+ /** Engines whose saved settings could not be read, with the same. */+ broken?: ReadonlyArray<{ name: string; hint: EngineHint }>;search?: string;}): ModelMenu {const terms = input.search?.toLowerCase().split(/\s+/).filter(Boolean) ?? [];let room = MENU_FOUND;- const engines: MenuRow[] = [], unavailable: string[] = [];+ const engines: MenuRow[] = [], groups = new Map<string, UnavailableGroup>();+ const nameMatches = (name: string) => terms.every((term) => name.toLowerCase().includes(term));+ const unavailable = (name: string, hint: EngineHint) => {+ const key = `${hint.why}\n${hint.connect}`;+ const group = groups.get(key);+ if (group) group.engines.push(name);+ else groups.set(key, { engines: [name], ...hint });+ };for (const engine of input.engines) {const { instanceId } = engine;const name = engine.displayName || engine.driverKind;@@ -68,12 +86,19 @@ export function modelMenu(input: {const matching = ids.filter((id) => matches(id, labels.get(id)));const blocked = engine.models.options.filter((option) => (option.orgBlocked || option.needsCliUpdate) && matches(option.id, option.label)).slice(0, MENU_SHORT).map((option) => ({ id: option.id, why: option.orgBlocked ? "turned off by this account's organization" : `needs ${name} CLI ${option.needsCliUpdate} or newer: update it` }));- if (!matching.length && !blocked.length && !(terms.length && terms.every((term) => name.toLowerCase().includes(term)))) continue;- if (input.down(engine)) {- unavailable.push(name);+ // An engine not set up often has no models to match yet: without a search it is still named, with why.+ if (!matching.length && !blocked.length && !nameMatches(name)) continue;+ const down = input.down(engine);+ if (down) {+ unavailable(name, down);+ continue;+ }+ if (!matching.length && !blocked.length) {+ // Signed out with no models to try: named with why, like an engine that is down.+ const signedOut = nameMatches(name) ? input.signedOut?.(engine) : null;+ if (signedOut) unavailable(name, signedOut);continue;}- if (!matching.length && !blocked.length) continue;const cap = terms.length ? room : matching.length <= MENU_WHOLE ? matching.length : MENU_SHORT;const listed: string[] = [];let examined = 0, refusedInRow = 0, why: string | null = null;@@ -91,7 +116,8 @@ export function modelMenu(input: {}const more = matching.length - examined;if (!listed.length && why) {- engines.push({ instanceId, name, unusable: why, ...(blocked.length ? { blocked } : {}) });+ const connect = input.signedOut?.(engine)?.connect;+ engines.push({ instanceId, name, unusable: why, ...(connect ? { connect } : {}), ...(blocked.length ? { blocked } : {}) });continue;}room -= listed.length;@@ -112,7 +138,8 @@ export function modelMenu(input: {...(blocked.length ? { blocked } : {}),});}- return { current: input.current, engines, ...(unavailable.length ? { unavailable } : {}) };+ for (const { name, hint } of input.broken ?? []) if (nameMatches(name)) unavailable(name, hint);+ return { current: input.current, engines, ...(groups.size ? { unavailable: [...groups.values()] } : {}) };}/** Only dispatch inside the internal capability gate: the menu is the calling bot's own. */diff --git a/server/task-record.test.ts b/server/task-record.test.tsindex af44d6f1c5..384fadf0a8 100644--- a/server/task-record.test.ts+++ b/server/task-record.test.ts@@ -103,7 +103,7 @@ describe("a thread a bot opens while a level change is being confirmed", () => {store.patchBot(bot.id, { approvalGrant: { requestId: REQUEST, mode: "full", phase: "prepared", threadId: bot.threadId, threadOnly: true } });const drivers: Record<string, string> = { claude: "claudeAgent", codex: "codex" };const own = createOwnThreads({ store, registry: { instances: () => [], cliTarget: (id) => ({ driverKind: drivers[id]! }) }, node: () => undefined,- current: () => undefined, proposalRefusal: () => null, givesWay: () => null, modelName: (one) => one.model,+ current: () => undefined, proposalRefusal: () => null, givesWay: () => null, modelName: (one) => one.model, hint: () => ({ why: "", connect: "" }),sourceLevel: (botId, threadId) => approvalModeFor(store.projectBotForTask(botId, threadId)!), mayRaise: () => true });// Auto-accept edits does not exist on Codex, so a burst child or an own thread there starts at Ask, as without a grant.diff --git a/server/thread-aware-bots.e2e.test.ts b/server/thread-aware-bots.e2e.test.tsindex 4f9e0e72a9..95e5a636f4 100644--- a/server/thread-aware-bots.e2e.test.ts+++ b/server/thread-aware-bots.e2e.test.ts@@ -449,7 +449,8 @@ describe("start_thread on another model, reporting back", () => {const token = await heldTurn(pm, "Ask a different engine.");const listed = (await api("GET", "/api/internal/models", undefined, token)).body;const row = (instanceId: string) => listed.engines.find((engine: any) => engine.instanceId === instanceId);- expect(row("curious")).toEqual({ instanceId: "curious", name: "Curious fixture", unusable: expect.stringContaining("can't run now: it is signed out") });+ expect(row("curious")).toEqual({ instanceId: "curious", name: "Curious fixture", unusable: expect.stringContaining("can't run now: it is signed out"),+ connect: expect.stringContaining("Settings → AI → Providers") });const { instances } = (await api("GET", "/api/instances")).body;const pick = (instanceId: string) => {const engine = instances.find((instance: any) => instance.instanceId === instanceId);diff --git a/shared/engine-sign-in.ts b/shared/engine-sign-in.tsnew file mode 100644index 0000000000..92a0765368--- /dev/null+++ b/shared/engine-sign-in.ts@@ -0,0 +1,14 @@+// How an engine is connected, as Settings' provider card decides it: the card (src/components/EngineSetup.tsx) and what a+// bot reads in list_models (server/host/engine-hints.ts) ask the same question here, so the two never disagree.++/** The engine signs in only with an API key saved in the app. Claude's API-key instance counts once Claude Code is+ * installed: until then the card offers the install, not the key. A company-managed engine is set up by its company. */+export function keyOnlyEngine(instance: {+ access?: string;+ managed?: unknown;+ driverKind: string;+ snapshot: { version?: string | null };+}): boolean {+ if (instance.access !== "api" || instance.managed) return false;+ return instance.driverKind !== "claudeAgent" || Boolean(instance.snapshot.version);+}diff --git a/skills/openmausbot-docs/SKILL.md b/skills/openmausbot-docs/SKILL.mdindex eeb1e3b843..78b98b2674 100644--- a/skills/openmausbot-docs/SKILL.md+++ b/skills/openmausbot-docs/SKILL.md@@ -25,6 +25,10 @@ describe a setting from memory: read the setting, the file, or the page.page explains why something is built that way and what happens if.- When the two disagree the app wins, and say which one you checked. Whenneither has the setting, say it does not exist instead of inventing a name.+- Which AI engines work here, why one can't run and how it is connected (a+ subscription sign-in, a device code, an API key or a local program):+ `list_models` says, per engine. Repeat what it says; if you have not checked,+ say so rather than guessing about sign-in or billing.## The data folderdiff --git a/src/components/EngineSetup.tsx b/src/components/EngineSetup.tsxindex 2f4fc828dd..23dd0874a4 100644--- a/src/components/EngineSetup.tsx+++ b/src/components/EngineSetup.tsx@@ -18,6 +18,7 @@ import { keyEntry, keyForInstance, type KeyId } from "./keys/key-catalog";import { openKeySettings } from "./keys/key-focus";import { KeyRow, SavedKeyLine } from "./keys/KeyRow";import { OllamaStatusLine } from "./OllamaStatusLine";+import { keyOnlyEngine } from "../../shared/engine-sign-in";export function needsSignIn(instance: InstanceInfo | undefined): boolean {return instance?.snapshot.state === "available" && instance.snapshot.authenticated === false;@@ -470,8 +471,7 @@ function ManagedEngineSetup({ instance, signInOnly }: { instance: InstanceInfo;}export function isApiKeyEngine(instance: InstanceInfo | undefined): boolean {- if (!instance || instance.access !== "api" || instance.managed) return false;- return instance.driverKind !== "claudeAgent" || Boolean(instance.snapshot.version);+ return Boolean(instance && keyOnlyEngine(instance));}export function hasSavedApiKey(instance: InstanceInfo): boolean {