Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(engines): keep an ACP engine's model list when its effort reads run out of time (#6999)
Milind Soni5c9b9087a4f4
diff --git a/server/contracts.ts b/server/contracts.tsindex 714e40662b..abdf22096b 100644--- a/server/contracts.ts+++ b/server/contracts.ts@@ -522,6 +522,9 @@ export interface ModelCatalog {}>;}+/** Why an engine's model list could not be read: it refused the sign-in, it took too long, or anything else. */+export type ModelListProblem = "signedOut" | "timedOut" | "failed";+/** "gpt-5.4-mini" → "Gpt 5.4 Mini", splitting on the caller's word breaks. */export function titleCaseModelId(id: string, wordBreaks: RegExp): string {return id@@ -589,6 +592,8 @@ export interface ProviderInstance {readonly models: ModelCatalog;/** True while the catalog is the driver's fixed list or a failed read's leftover, not a list the engine gave. */readonly modelsUnconfirmed?: boolean;+ /** Set with modelsUnconfirmed when the engine's last read of its list failed: why, for the picker to say. */+ readonly modelsUnreadable?: ModelListProblem;/** False while the sign-in can refuse a model its catalog lists (Codex on a ChatGPT account): a short message and background text then stay on the bot's own model. */readonly quickModelsUsable?: () => boolean;/** Refresh a live catalog without recreating the provider instance. */diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.tsindex 308a82b600..f163f26b07 100644--- a/server/drivers/acp/core.ts+++ b/server/drivers/acp/core.ts@@ -14,6 +14,7 @@ import { createHash } from "node:crypto";import { PROVIDER_CREDENTIAL_ENV, stripControlPlaneEnv, WORKSPACE_CREDENTIAL_ENV } from "../../config.ts";import { openStartupModelCatalog } from "../../startup-model-catalog.ts";import { acpModelCatalog } from "./model-catalog.ts";+import { acpDiscoveryProblem } from "./custom-model-catalog.ts";import { decodeInjectId } from "../local-inject.ts";import { DeviceAuthController, deviceAuthInstanceSurface, type DeviceSignIn } from "../device-auth.ts";import { AcpBrowserAuth, acpBrowserAuthInstanceSurface, type AcpBrowserSignInSpec } from "./browser-auth.ts";@@ -350,7 +351,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>fixed: support.models,startFromSaved: Boolean(support.resolveModels) && support.resolveModelsOnCreate === false,resolve: support.resolveModels && ((fresh) => { const env = childEnv(); return support.resolveModels!(env, config, instanceId, fresh, instanceEnvNames(input.environment, env)); }),- });+ explain: (error) => acpDiscoveryProblem(error, support.classifyError) });const refreshModels = (fresh?: boolean) => catalog.refresh(fresh);let startupModelRefresh: Promise<void> | null = null;if (support.resolveModels && support.resolveModelsOnCreate !== false) {@@ -1558,9 +1559,8 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>get models() {return catalog.models;},- get modelsUnconfirmed() {- return catalog.unconfirmed;- },+ get modelsUnconfirmed() { return catalog.unconfirmed; },+ get modelsUnreadable() { return catalog.unreadable; },refreshModels: support.resolveModels ? () => refreshModels(true) : undefined,...(startupModelRefresh ? { startupModelRefresh } : {}),...(support.deviceSignIn && deviceSignIn ? deviceAuthInstanceSurface(deviceSignIn, support.deviceSignIn) : {}), ...(support.browserSignIn && browserSignIn ? acpBrowserAuthInstanceSurface(browserSignIn, support.browserSignIn) : {}),diff --git a/server/drivers/acp/custom-model-catalog.test.ts b/server/drivers/acp/custom-model-catalog.test.tsindex f486a85340..01a86ffa55 100644--- a/server/drivers/acp/custom-model-catalog.test.ts+++ b/server/drivers/acp/custom-model-catalog.test.ts@@ -1,8 +1,15 @@import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";import { tmpdir } from "node:os";-import { basename, join } from "node:path";+import { basename, dirname, join } from "node:path";+import { fileURLToPath } from "node:url";import { afterEach, describe, expect, it, vi } from "vitest";-import { DISCOVERY_CLIENT_NAME, discoverAcpModels, resolveCustomAcpModels } from "./custom-model-catalog.ts";+import {+ acpDiscoveryProblem, AcpDiscoveryRpcError, AcpDiscoveryTimeoutError, DISCOVERY_CLIENT_NAME, discoverAcpModels, discoveryCutShort,+ resolveCustomAcpModels,+} from "./custom-model-catalog.ts";+import { classifyDevinError } from "./devin.ts";++const FAKE_ACP_CLI = join(dirname(fileURLToPath(import.meta.url)), "../../testing/fake-acp-cli.ts");/** Lets a test see a process that reports it would not stop; the real stop still runs. */const stop = vi.hoisted(() => ({ refuses: false }));@@ -215,3 +222,68 @@ describe("custom ACP catalog discovery (isolated fake CLI)", () => {]);});});++describe("a model list whose per-model effort reads are cut short (shared fake ACP CLI)", () => {+ const MODELS = Array.from({ length: 6 }, (_, index) => `fixture-model-${index}`);+ const EFFORTS = [{ value: "low", name: "Low" }, { value: "high", name: "High" }];+ const env = (extra: Record<string, string>) => ({+ ...process.env, FAKE_ACP_MODELS: MODELS.join(","),+ FAKE_ACP_VARIANTS: JSON.stringify(Object.fromEntries(MODELS.map((model) => [model, { currentValue: "low", options: EFFORTS }]))),+ ...extra,+ });+ // As Devin's driver reads it: its own default first, then each model with the efforts it offers.+ const DEVIN_LIKE = { passthrough: { id: "agent-default", label: "Default" }, variantLimit: 128, maxModels: 4096 };+ const withEfforts = (catalog: { options: Array<{ id: string; variants?: unknown[] }> }) =>+ catalog.options.filter((option) => option.variants?.length).map((option) => option.id);++ it("keeps every listed model when the whole read runs out of time, with efforts only for the models it reached", async () => {+ const catalog = await discoverAcpModels(env({ FAKE_ACP_HANG_ON_MODEL: MODELS[3] }), FAKE_ACP_CLI, [], { ...DEVIN_LIKE, timeoutMs: 5_000 });+ expect(catalog.default).toBe("agent-default");+ expect(catalog.options.map((option) => option.id)).toEqual(["agent-default", ...MODELS]);+ expect(withEfforts(catalog)).toEqual(MODELS.slice(0, 3));+ expect(catalog.options.find((option) => option.id === MODELS[1])?.variants).toEqual([{ id: "low", label: "Low" }, { id: "high", label: "High" }]);+ expect(discoveryCutShort(catalog)).toBe(true);+ }, 20_000);++ it("keeps every listed model, and reads the rest, when one switch takes longer than a request may", async () => {+ const catalog = await discoverAcpModels(env({ FAKE_ACP_HANG_ON_MODEL: MODELS[2] }), FAKE_ACP_CLI, [], { ...DEVIN_LIKE, requestTimeoutMs: 5_000 });+ expect(catalog.options.map((option) => option.id)).toEqual(["agent-default", ...MODELS]);+ expect(withEfforts(catalog)).toEqual(MODELS.filter((model) => model !== MODELS[2]));+ expect(discoveryCutShort(catalog)).toBe(true);+ }, 20_000);++ it("keeps every listed model when the agent exits partway through the switches", async () => {+ const catalog = await discoverAcpModels(env({ FAKE_ACP_EXIT_ON_MODEL: MODELS[3] }), FAKE_ACP_CLI, [], DEVIN_LIKE);+ expect(catalog.options.map((option) => option.id)).toEqual(["agent-default", ...MODELS]);+ expect(withEfforts(catalog)).toEqual(MODELS.slice(0, 3));+ expect(discoveryCutShort(catalog)).toBe(true);+ });++ it("marks nothing when every switch answered, or when a model was refused", async () => {+ const catalog = await discoverAcpModels(env({}), FAKE_ACP_CLI, [], DEVIN_LIKE);+ expect(withEfforts(catalog)).toEqual(MODELS);+ expect(discoveryCutShort(catalog)).toBe(false);+ const fixture = await fake();+ const refused = await resolveCustomAcpModels(fixture.env, fixture.config);+ expect(discoveryCutShort(refused)).toBe(false);+ });++ it("still fails when time runs out before the agent has listed its models, and names it a timeout", async () => {+ const dir = await mkdtemp(join(tmpdir(), "omb-catalog-silent-"));+ scratch.push(dir);+ const cli = join(dir, "silent.mjs");+ await writeFile(cli, "process.stdin.resume();\n");+ const error = await discoverAcpModels(process.env, `${JSON.stringify(process.execPath)} ${JSON.stringify(cli)}`, [], { requestTimeoutMs: 500 })+ .then(() => undefined, (failure: unknown) => failure);+ expect(error).toBeInstanceOf(AcpDiscoveryTimeoutError);+ expect(acpDiscoveryProblem(error)).toBe("timedOut");+ }, 20_000);++ it("names a refused sign-in only when the engine's own classifier reads it as one", () => {+ const loggedOut = new AcpDiscoveryRpcError(-32000, "Please log in to use Devin. Use `/login` to authenticate again.");+ expect(acpDiscoveryProblem(loggedOut, classifyDevinError)).toBe("signedOut");+ expect(acpDiscoveryProblem(loggedOut)).toBe("failed");+ expect(acpDiscoveryProblem(new AcpDiscoveryRpcError(-32603, "Internal error"), classifyDevinError)).toBe("failed");+ expect(acpDiscoveryProblem(new Error("ACP agent closed during model discovery."), classifyDevinError)).toBe("failed");+ });+});diff --git a/server/drivers/acp/custom-model-catalog.ts b/server/drivers/acp/custom-model-catalog.tsindex 2eeeb6ceb5..19df5c3911 100644--- a/server/drivers/acp/custom-model-catalog.ts+++ b/server/drivers/acp/custom-model-catalog.ts@@ -3,7 +3,7 @@ import { tmpdir } from "node:os";import { join } from "node:path";import { StringDecoder } from "node:string_decoder";-import type { ModelCatalog } from "../../contracts.ts";+import type { ModelCatalog, ModelListProblem, ProviderErrorCode } from "../../contracts.ts";import type { AcpConfig } from "./core.ts";import { killCliTree, spawnCli } from "../../procs.ts";import { acpModelOption, acpVariantOption } from "./config-options.ts";@@ -39,6 +39,9 @@ export interface AcpDiscoveryOptions {exitGraceMs?: number;/** Remove what the agent kept of the discovery session, once its process has stopped, when session/delete did not. */forgetSession?(session: { sessionId: string; cwd: string; env: Record<string, string | undefined> }): Promise<void>;+ /** Tests shorten the whole read's limit and each request's. */+ timeoutMs?: number;+ requestTimeoutMs?: number;}/** The agent answered a discovery request with a JSON-RPC error, so it is reachable. Its own text stays@@ -53,6 +56,23 @@ export class AcpDiscoveryRpcError extends Error {}}+/** A discovery request, or the whole read, ran out of time. */+export class AcpDiscoveryTimeoutError extends Error {}++/** Catalogs whose per-model effort reads stopped early: every listed model is there, some without their efforts. */+const cutShort = new WeakSet<ModelCatalog>();++export function discoveryCutShort(catalog: ModelCatalog): boolean {+ return cutShort.has(catalog);+}++/** Why a model list could not be read, in words the picker can say: never the agent's own text. */+export function acpDiscoveryProblem(error: unknown, classify?: (error: unknown) => ProviderErrorCode | undefined): ModelListProblem {+ if (error instanceof AcpDiscoveryTimeoutError) return "timedOut";+ return error instanceof AcpDiscoveryRpcError && classify?.({ code: error.code, message: error.rpcMessage }) === "invalid_credentials"+ ? "signedOut" : "failed";+}+function record(value: unknown): Record<string, unknown> | undefined {return value !== null && typeof value === "object" && !Array.isArray(value)? value as Record<string, unknown> : undefined;@@ -123,8 +143,8 @@ export async function discoverAcpModels(const decoder = new StringDecoder("utf8");let catalog: ModelCatalog | undefined;let thrown: unknown;- const fail = (message: string) => {- failure ??= new Error(message);+ const fail = (message: string, timedOut = false) => {+ failure ??= timedOut ? new AcpDiscoveryTimeoutError(message) : new Error(message);for (const entry of pending.values()) { clearTimeout(entry.timer); entry.reject(failure); }pending.clear();};@@ -171,8 +191,8 @@ export async function discoverAcpModels(return new Promise((resolve, reject) => {const timer = setTimeout(() => {pending.delete(id);- reject(new Error("ACP model discovery request timed out."));- }, REQUEST_TIMEOUT_MS);+ reject(new AcpDiscoveryTimeoutError("ACP model discovery request timed out."));+ }, discovery.requestTimeoutMs ?? REQUEST_TIMEOUT_MS);pending.set(id, { resolve, reject, timer });send({ jsonrpc: "2.0", id, method, params });});@@ -194,7 +214,7 @@ export async function discoverAcpModels(if (Buffer.byteLength(buffer) > MAX_LINE_BYTES) fail("ACP model discovery exceeded its line limit.");});child.stderr.on("data", (chunk: Buffer) => { count(chunk); });- globalTimer = setTimeout(() => fail("ACP model discovery timed out."), DISCOVERY_TIMEOUT_MS);+ globalTimer = setTimeout(() => fail("ACP model discovery timed out.", true), discovery.timeoutMs ?? DISCOVERY_TIMEOUT_MS);initialized = await request("initialize", {protocolVersion: 1,clientInfo: { name: DISCOVERY_CLIENT_NAME, version: "1" },@@ -215,15 +235,20 @@ export async function discoverAcpModels(const { passthrough } = discovery;const options: ModelCatalog["options"] = passthrough ? [{ ...passthrough, ...mark }] : [];let discovered = 0;+ // From here the list is in hand: running out of time, or an agent that stops answering, ends only the per-model+ // effort reads, and every listed model is kept, the ones not reached without their efforts.+ let stoppedEarly = false;for (const model of modelOption.options) {if (model.id === passthrough?.id) continue;- if (failure) throw failure;if (!usableDiscoveredId(model.id)) continue;discovered++;let confirmed: unknown;+ const switches = discovery.variants !== false && modelOption.options.length <= (discovery.variantLimit ?? Number.POSITIVE_INFINITY);if (model.id === modelOption.currentValue) {confirmed = initial;- } else if (discovery.variants !== false && modelOption.options.length <= (discovery.variantLimit ?? Number.POSITIVE_INFINITY)) {+ } else if (switches && failure) {+ stoppedEarly = true;+ } else if (switches) {const previousUpdate = updateSequence;try {const response = modelOption.configId@@ -231,8 +256,8 @@ export async function discoverAcpModels(: await request("session/set_model", { sessionId, modelId: model.id });if (acpModelOption(response)?.currentValue === model.id) confirmed = response;else if (updateSequence > previousUpdate && acpModelOption(latestUpdate)?.currentValue === model.id) confirmed = latestUpdate;- } catch {- if (failure) throw failure;+ } catch (error) {+ if (failure || error instanceof AcpDiscoveryTimeoutError) stoppedEarly = true;}}const variants = confirmed ? acpVariantOption(confirmed)?.options.flatMap((variant) => usableDiscoveredId(variant.id)@@ -247,13 +272,13 @@ export async function discoverAcpModels(...(variants?.length ? { variants } : {}),});}- if (failure) throw failure;// Only the passthrough default left means every advertised model was unusable: keeping the previous catalog// beats replacing it with a picker that has lost its models.if (!discovered) throw new Error("The ACP agent did not advertise any usable models. The previous catalog was kept.");const preferred = discovery.default && options.some((option) => option.id === discovery.default) ? discovery.default : undefined;const current = usableDiscoveredId(modelOption.currentValue) ? modelOption.currentValue : undefined;catalog = { default: passthrough?.id ?? preferred ?? current ?? options[0].id, options };+ if (stoppedEarly) cutShort.add(catalog);} catch (error) {thrown = error;} finally {diff --git a/server/drivers/acp/devin.test.ts b/server/drivers/acp/devin.test.tsindex 1db92096c2..f7cf5ae7a5 100644--- a/server/drivers/acp/devin.test.ts+++ b/server/drivers/acp/devin.test.ts@@ -196,6 +196,14 @@ describe("Devin ACP driver", () => {expect(JSON.parse(readFileSync(rpc, "utf8"))).not.toContain("session/set_config_option");});+ it("says in the picker why its model list could not be read", async () => {+ const { instance } = await create({ FAKE_ACP_MODELS: "" });+ await instance.refreshModels!();+ expect(instance.modelsUnconfirmed).toBe(true);+ expect(instance.modelsUnreadable).toBe("failed");+ expect(instance.models.options.map((option) => option.id)).toEqual(["agent-default"]);+ });+it("starts nothing when the instance is created", async () => {await create();expect(existsSync(join(scratch, "launch.json"))).toBe(false);diff --git a/server/drivers/acp/model-catalog.test.ts b/server/drivers/acp/model-catalog.test.tsnew file mode 100644index 0000000000..68808fb645--- /dev/null+++ b/server/drivers/acp/model-catalog.test.ts@@ -0,0 +1,70 @@+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";+import { describe, expect, it } from "vitest";++import type { ModelCatalog } from "../../contracts.ts";+import { readStartupModelCacheEntry } from "../../startup-model-catalog.ts";+import { acpDiscoveryProblem, AcpDiscoveryTimeoutError, discoverAcpModels } from "./custom-model-catalog.ts";+import { acpModelCatalog } from "./model-catalog.ts";++const FAKE_ACP_CLI = join(dirname(fileURLToPath(import.meta.url)), "../../testing/fake-acp-cli.ts");+const MODELS = Array.from({ length: 5 }, (_, index) => `fixture-model-${index}`);+const FIXED: ModelCatalog = { default: "agent-default", options: [{ id: "agent-default", label: "Default" }] };+const efforts = (value: string) => ({ currentValue: value, options: [{ value, name: value }] });++function read(variant: string, extra: Record<string, string> = {}): Promise<ModelCatalog> {+ return discoverAcpModels({+ ...process.env, FAKE_ACP_MODELS: MODELS.join(","),+ FAKE_ACP_VARIANTS: JSON.stringify(Object.fromEntries(MODELS.map((model) => [model, efforts(variant)]))), ...extra,+ }, FAKE_ACP_CLI, [], { passthrough: FIXED.options[0], variantLimit: 128 });+}++const effortsOf = (catalog: ModelCatalog) => Object.fromEntries(catalog.options.map((option) => [option.id, option.variants?.map((variant) => variant.id)]));++describe("ACP model catalog reads", () => {+ it("keeps an earlier read's efforts for the models a cut-short read did not reach, and reads again at the next start", async () => {+ const instanceId = `catalog-cut-${Math.random().toString(36).slice(2)}`;+ let next = () => read("high");+ const catalog = acpModelCatalog({ instanceId, fixed: FIXED, startFromSaved: true, resolve: () => next() });+ await catalog.refresh(true);+ expect(readStartupModelCacheEntry(instanceId)?.checkedAt).toBeGreaterThan(0);++ next = () => read("low", { FAKE_ACP_EXIT_ON_MODEL: MODELS[2] });+ await catalog.refresh(true);+ expect(catalog.models.options.map((option) => option.id)).toEqual(["agent-default", ...MODELS]);+ expect(effortsOf(catalog.models)).toEqual({+ "agent-default": undefined,+ [MODELS[0]]: ["low"], [MODELS[1]]: ["low"], [MODELS[2]]: ["high"], [MODELS[3]]: ["high"], [MODELS[4]]: ["high"],+ });+ expect(catalog.unconfirmed).toBe(false);+ expect(catalog.unreadable).toBeUndefined();+ expect(readStartupModelCacheEntry(instanceId)?.checkedAt).toBe(0);+ });++ it("says why a read failed while the list is unconfirmed, and forgets it once a read succeeds", async () => {+ let next: () => Promise<ModelCatalog> = () => Promise.reject(new AcpDiscoveryTimeoutError("ACP model discovery timed out."));+ const catalog = acpModelCatalog({+ instanceId: `catalog-why-${Math.random().toString(36).slice(2)}`, fixed: FIXED, startFromSaved: false,+ resolve: () => next(), explain: (error) => acpDiscoveryProblem(error),+ });+ await catalog.refresh(true);+ expect(catalog.models).toEqual(FIXED);+ expect(catalog.unconfirmed).toBe(true);+ expect(catalog.unreadable).toBe("timedOut");++ next = () => Promise.reject(new Error("ACP agent closed during model discovery."));+ await catalog.refresh(true);+ expect(catalog.unreadable).toBe("failed");++ next = () => read("high");+ await catalog.refresh(true);+ expect(catalog.unconfirmed).toBe(false);+ expect(catalog.unreadable).toBeUndefined();++ // A failure after a good read leaves that read's list standing, with nothing to explain.+ next = () => Promise.reject(new AcpDiscoveryTimeoutError("ACP model discovery timed out."));+ await catalog.refresh(true);+ expect(catalog.models.options).toHaveLength(MODELS.length + 1);+ expect(catalog.unreadable).toBeUndefined();+ });+});diff --git a/server/drivers/acp/model-catalog.ts b/server/drivers/acp/model-catalog.tsindex 643dbdc857..1218190aaf 100644--- a/server/drivers/acp/model-catalog.ts+++ b/server/drivers/acp/model-catalog.ts@@ -1,5 +1,6 @@-import type { ModelCatalog } from "../../contracts.ts";+import type { ModelCatalog, ModelListProblem } from "../../contracts.ts";import { readStartupModelCacheEntry, unconfirmedModelCatalog, writeStartupModelCache } from "../../startup-model-catalog.ts";+import { discoveryCutShort } from "./custom-model-catalog.ts";export interface AcpModelCatalog {models: ModelCatalog;@@ -8,6 +9,8 @@ export interface AcpModelCatalog {/** True while this process has not been given the list by the engine: the driver's fixed one, a saved stand-in,* or a failed read's leftover. */readonly unconfirmed: boolean;+ /** While unconfirmed after a failed read: why it failed. */+ readonly unreadable: ModelListProblem | undefined;/** A read already under way is shared; a fresh one waits for a cached one under way, then reads again. */refresh(fresh?: boolean): Promise<void>;}@@ -17,6 +20,8 @@ export function acpModelCatalog(input: {fixed: ModelCatalog;startFromSaved: boolean;resolve?: (fresh: boolean) => ModelCatalog | Promise<ModelCatalog>;+ /** Names why a read failed; without it a failure is "failed". */+ explain?: (error: unknown) => ModelListProblem;}): AcpModelCatalog {const { instanceId, resolve } = input;const saved = resolve ? readStartupModelCacheEntry(instanceId) : null;@@ -25,17 +30,26 @@ export function acpModelCatalog(input: {let readFromEngine = false;let accountModels: ReadonlySet<string> | null = saved?.checkedAt ? idsOf(saved.catalog) : null;let current: { fresh: boolean; done: Promise<void> } | null = null;+ let problem: ModelListProblem | undefined;const read = async (fresh: boolean) => {if (!resolve) return;try {const resolved = await resolve(fresh);if (resolved.options.length) {- models = resolved;+ // A read whose effort lookups stopped early keeps the efforts an earlier read found, and is read again at the+ // next start instead of standing for hours.+ const cut = discoveryCutShort(resolved);+ models = cut ? withEarlierVariants(resolved, models) : resolved;+ if (cut) unconfirmedModelCatalog(models);readFromEngine = true;accountModels = idsOf(resolved);+ problem = undefined;} else unconfirmedModelCatalog(models);- } catch { unconfirmedModelCatalog(models); }+ } catch (error) {+ unconfirmedModelCatalog(models);+ try { problem = input.explain?.(error) ?? "failed"; } catch { problem = "failed"; }+ }try { writeStartupModelCache(instanceId, models); } catch {}};@@ -45,6 +59,7 @@ export function acpModelCatalog(input: {get accountModels() { return accountModels; },set accountModels(ids) { accountModels = ids; },get unconfirmed() { return Boolean(resolve) && !readFromEngine; },+ get unreadable() { return Boolean(resolve) && !readFromEngine ? problem : undefined; },refresh(fresh = false) {if (current && (current.fresh || !fresh)) return current.done;const next = { fresh, done: (current?.done ?? Promise.resolve()).then(() => read(fresh)) };@@ -55,6 +70,14 @@ export function acpModelCatalog(input: {};}+function withEarlierVariants(catalog: ModelCatalog, earlier: ModelCatalog): ModelCatalog {+ const variants = new Map(earlier.options.flatMap((option) => option.variants?.length ? [[option.id, option.variants] as const] : []));+ return {+ ...catalog,+ options: catalog.options.map((option) => option.variants?.length || !variants.has(option.id) ? option : { ...option, variants: variants.get(option.id) }),+ };+}+function idsOf(catalog: ModelCatalog): ReadonlySet<string> {return new Set(catalog.options.map((option) => option.id));}diff --git a/server/drivers/antigravity.ts b/server/drivers/antigravity.tsindex a43dbfe1fe..327967f0ea 100644--- a/server/drivers/antigravity.ts+++ b/server/drivers/antigravity.ts@@ -253,6 +253,9 @@ export const AntigravityDriver: ProviderDriver<AcpConfig> = {get modelsUnconfirmed() {return base.modelsUnconfirmed;},+ get modelsUnreadable() {+ return base.modelsUnreadable;+ },snapshot: async () => {const snapshot = await base.snapshot();if (snapshot.state === "available") installFailure = undefined;diff --git a/server/harness/registry.ts b/server/harness/registry.tsindex 3ffc373130..be5f6c45ec 100644--- a/server/harness/registry.ts+++ b/server/harness/registry.ts@@ -538,7 +538,7 @@ export class ProviderRegistry {displayName: inst.displayName ?? inst.driverKind,snapshot,models: inst.models,- ...(inst.modelsUnconfirmed ? { modelsUnconfirmed: true } : {}),+ ...(inst.modelsUnconfirmed ? { modelsUnconfirmed: true, ...(inst.modelsUnreadable ? { modelsUnreadable: inst.modelsUnreadable } : {}) } : {}),capabilities: {computerMcp: inst.adapter.capabilities.computerMcp === true,agentsMcp: inst.adapter.capabilities.agentsMcp === true,diff --git a/server/testing/fake-acp-cli.ts b/server/testing/fake-acp-cli.tsindex 77745b8f97..85fc072203 100755--- a/server/testing/fake-acp-cli.ts+++ b/server/testing/fake-acp-cli.ts@@ -74,6 +74,8 @@// FAKE_ACP_OMIT_MODEL_VALUE when the live model equals this id, the model option has no currentValue// (Copilot CLI 1.0.105 does this for auto)// FAKE_ACP_EXIT_ON_MODEL the process exits when set_config_option selects this model+// FAKE_ACP_HANG_ON_MODEL set_config_option never answers a switch to this model, as a stuck account can; other requests+// are still answered// FAKE_ACP_VARIANTS JSON map model -> {id?, currentValue?, options} of ACP select values// FAKE_ACP_CONFIG_UPDATES JSON [{after, sessionId?, configOptions, replay?}] emitted after the named response// FAKE_ACP_USAGE_ROOT usage at the prompt result's root, as opencode 1.18.18 sends it@@ -1269,6 +1271,7 @@ function handle(msg: any) {break;}if (configId === "model" && value === process.env.FAKE_ACP_EXIT_ON_MODEL) process.exit(4);+ if (configId === "model" && value === process.env.FAKE_ACP_HANG_ON_MODEL) break;if (configId !== "model" || !models.includes(value)) {out({jsonrpc: "2.0",diff --git a/src/components/EngineSetup.tsx b/src/components/EngineSetup.tsxindex 7bb76932fb..95b957fd58 100644--- a/src/components/EngineSetup.tsx+++ b/src/components/EngineSetup.tsx@@ -464,6 +464,8 @@ export function ApiKeyHint({ instance }: { instance: InstanceInfo }) {);}+const UNREADABLE_NOTE = { failed: "model.unreadable.failed", signedOut: "model.unreadable.signedOut", timedOut: "model.unreadable.timedOut" } as const;+export function InstanceAccountNotes({ instance, listsModels }: { instance: InstanceInfo; listsModels: boolean }) {const account = instance.snapshot.authenticated && instance.snapshot.account? [instance.snapshot.account.email, instance.snapshot.account.organization].filter(Boolean).join(" · ")@@ -473,7 +475,7 @@ export function InstanceAccountNotes({ instance, listsModels }: { instance: Inst{account !== null && <p className="mt-1 truncate text-[12px] leading-4 text-ink-tertiary" title={account}>{account}</p>}{instance.modelsUnconfirmed && listsModels && (<p data-models-unconfirmed className="mt-1 text-[12px] leading-4 text-ink-tertiary">- {t("model.unconfirmed", { name: instance.displayName })}+ {t(instance.modelsUnreadable ? UNREADABLE_NOTE[instance.modelsUnreadable] : "model.unconfirmed", { name: instance.displayName })}</p>)}</>diff --git a/src/locales/en.json b/src/locales/en.jsonindex 445bdf6a90..4ab6cc9053 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -3321,6 +3321,9 @@"model.refresh": "Refresh {name} models","model.refreshTitle": "Refresh models","model.unconfirmed": "{name} hasn't listed its models yet. These may be out of date.",+ "model.unreadable.failed": "{name}'s model list could not be read. These may be out of date.",+ "model.unreadable.signedOut": "{name} isn't signed in, so its model list could not be read.",+ "model.unreadable.timedOut": "{name} took too long to list its models. These may be out of date.","model.localModels": "Local models","model.local.noTools": "No tools","model.favorite.add": "Add {name} to favorites",diff --git a/src/locales/es.json b/src/locales/es.jsonindex dfe3761be7..fb9913dfe3 100644--- a/src/locales/es.json+++ b/src/locales/es.json@@ -2290,6 +2290,9 @@"model.refresh": "Actualizar los modelos de {name}","model.refreshTitle": "Actualizar los modelos","model.unconfirmed": "{name} todavía no confirmó sus modelos. Puede que esta lista esté desactualizada.",+ "model.unreadable.failed": "No se pudo leer la lista de modelos de {name}. Puede que esta lista esté desactualizada.",+ "model.unreadable.signedOut": "{name} no tiene la sesión iniciada, así que no se pudo leer su lista de modelos.",+ "model.unreadable.timedOut": "{name} tardó demasiado en mostrar sus modelos. Puede que esta lista esté desactualizada.","model.localModels": "Modelos locales","model.localHint": "Ejecuta este agente con un modelo que ya tienes en el equipo.","model.chooseHint": "Elige un modelo para este bot.",diff --git a/src/locales/ja.json b/src/locales/ja.jsonindex 521c9ff6b0..31ff6ed551 100644--- a/src/locales/ja.json+++ b/src/locales/ja.json@@ -2752,6 +2752,9 @@"model.refresh": "{name} のモデルを更新","model.refreshTitle": "モデルを更新","model.unconfirmed": "{name} はまだモデルの一覧を返していません。表示中のモデルは古い可能性があります。",+ "model.unreadable.failed": "{name} のモデル一覧を読み込めませんでした。表示中のモデルは古い可能性があります。",+ "model.unreadable.signedOut": "{name} にサインインしていないため、モデル一覧を読み込めませんでした。",+ "model.unreadable.timedOut": "{name} のモデル一覧の取得に時間がかかりすぎました。表示中のモデルは古い可能性があります。","model.localModels": "ローカルモデル","model.localHint": "このエージェントを、すでに手元にあるモデルで動かします。","model.apiKeyHint": "自分の API キーで動きます。使用した分の料金はプロバイダーから請求されます。",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex b5d377f15b..58acbdaf31 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -3134,6 +3134,9 @@"model.refresh": "Atualizar os modelos de {name}","model.refreshTitle": "Atualizar os modelos","model.unconfirmed": "{name} ainda não informou quais modelos oferece. Esta lista pode estar desatualizada.",+ "model.unreadable.failed": "Não foi possível ler a lista de modelos do {name}. Esta lista pode estar desatualizada.",+ "model.unreadable.signedOut": "O {name} não está conectado, então não foi possível ler a lista de modelos dele.",+ "model.unreadable.timedOut": "O {name} demorou demais para listar os modelos. Esta lista pode estar desatualizada.","model.localModels": "Modelos locais","model.local.noTools": "Sem ferramentas","model.favorite.add": "Adicionar {name} aos favoritos",diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.jsonindex 4ef91ab3b4..7e45ff466d 100644--- a/src/locales/zh-tw.json+++ b/src/locales/zh-tw.json@@ -2938,6 +2938,9 @@"model.refresh": "重新整理 {name} 模型","model.refreshTitle": "重新整理模型","model.unconfirmed": "{name} 尚未列出它的模型。這些可能已過時。",+ "model.unreadable.failed": "無法讀取 {name} 的模型列表。這些可能已過時。",+ "model.unreadable.signedOut": "{name} 尚未登入,因此無法讀取它的模型列表。",+ "model.unreadable.timedOut": "{name} 列出模型的時間太長。這些可能已過時。","model.localModels": "本機模型","model.localHint": "使用你電腦上已有的模型執行此機器人。","model.apiKeyHint": "使用你的 API 金鑰執行。供應商會依用量向你計費。",diff --git a/src/locales/zh.json b/src/locales/zh.jsonindex a45e7ce044..fa1aa21aa7 100644--- a/src/locales/zh.json+++ b/src/locales/zh.json@@ -8651,6 +8651,9 @@"model.reasoningNextTurn": "推理等级从下一条消息起生效","model.customSwitchOnHost": "这个对话使用“自定义”审批。请在主机电脑的应用中切换它的模型,这样退出“自定义”时可以在那里确认。","model.unconfirmed": "{name} 还没有列出它的模型。这些可能已经过时。",+ "model.unreadable.failed": "无法读取 {name} 的模型列表。这些可能已经过时。",+ "model.unreadable.signedOut": "{name} 未登录,因此无法读取它的模型列表。",+ "model.unreadable.timedOut": "{name} 列出模型的时间太长。这些可能已经过时。","model.section.installationDefault": "新机器人会从这个安装的默认模型开始,除非你在这里另选。想在这个模型达到使用上限时自动切换,请在下方添加备用模型。","engineSetup.cloudCantInstall": "{name} 还无法安装在 Cloud 上。请在模型选择器中选择其他 AI。","settings.browser.serverSites": "在这台服务器上打开网站",diff --git a/src/state/store.tsx b/src/state/store.tsxindex 16f48ff253..ba0abb46b7 100644--- a/src/state/store.tsx+++ b/src/state/store.tsx@@ -461,7 +461,7 @@ export interface InstanceInfo extends InstanceEndpointInfo {cliDefault?: string;cliCandidates?: string[];claudeAccount?: { configDir: string; signInCommand: string; signInShell: "powershell" | "sh"; isDefault: boolean };- freeUpSpace?: boolean; replyWaitMinutes?: number; modelsUnconfirmed?: true; /** The app updated its own copy of this engine to this version lately. */ autoUpdated?: { version: string; at: number };+ freeUpSpace?: boolean; replyWaitMinutes?: number; modelsUnconfirmed?: true; /** Why the engine's last read of its list failed. */ modelsUnreadable?: "signedOut" | "timedOut" | "failed"; /** The app updated its own copy of this engine to this version lately. */ autoUpdated?: { version: string; at: number };}/** A Settings page (`SettingsPageId`) or an older page name that `settings-index.ts` sends to its new page and section. */