Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge origin/main into train/nov8-reapply-c
milind-soni4e42420acba0
diff --cc server/drivers/acp/core.tsindex d20f216666,7729389cc0..1916cbe4b9--- a/server/drivers/acp/core.ts+++ b/server/drivers/acp/core.ts@@@ -223,8 -223,7 +223,9 @@@ export interface AcpSupportrequireAuthenticationBeforeSpawn?: boolean;/** Classify provider-native failures without coupling the core to messages. */classifyError?(error: unknown): ProviderErrorCode | undefined;+ /** A session/prompt error saying the agent never reached its model; startup recovery then holds the ACK for it. */+ promptUnreachedModel?(error: unknown): boolean;+ /** How far a usage limit the engine reports reaches: its whole account, or one allowance its models share (OpenCode's free models), with the models that allowance holds. */ limitFacts?(text: string, model?: string): { limit: "engine" | "model"; limitModels?: string[] };/** Plain words for an account failure (bad key, no credit, a used-up* quota, no subscription) in place of the provider's raw RPC text. */describeAccountError?(code: AccountErrorCode, model?: string): string;diff --cc server/drivers/acp/opencode-go.test.tsindex 80e8a1b3a5,5f1943e92c..88d1abadfd--- a/server/drivers/acp/opencode-go.test.ts+++ b/server/drivers/acp/opencode-go.test.ts@@@ -17,8 -17,8 +17,9 @@@ importdescribeOpenCodeAccountError,discoverOpenCodeModels,openCodeFreeFallback,+ openCodeLimitFacts,openCodeOwnedDirectories,+ openCodePromptUnreachedModel,OpenCodeDriver,openCodeProviderKeysAllowed,openMausOwnsWorkingFolder,@@@ -325,26 -327,33 +328,53 @@@ describe("OpenCode catalog", () =>expect(classifyOpenCodeError(apiError(message))).toBeUndefined();});+ it.each([+ // opencode 1.19.4, then 1.18.27, with the model server's port closed+ "Internal error: Cannot connect to API: ECONNREFUSED: Unable to connect. Is the computer able to access the url?",+ "Internal error: Cannot connect to API: Unable to connect. Is the computer able to access the url?",+ "Internal error: ConnectionRefused: Unable to connect. Is the computer able to access the url?",+ ])("knows a prompt that never reached its model: %s", (message) => {+ expect(openCodePromptUnreachedModel(apiError(message))).toBe(true);+ });++ it.each([+ apiError("Internal error: Invalid API key."),+ apiError("Internal error: socket hang up"),+ // Only OpenCode's refusal wording is proven; other connect failures stay ordinary errors+ apiError("Internal error: Cannot connect to API: Connect Timeout Error"),+ Object.assign(new Error("Cannot connect to API: ECONNREFUSED"), { code: -32602 }),+ new Error("ECONNREFUSED"),+ ])("does not take another prompt error as unreached: %s", (error) => {+ expect(openCodePromptUnreachedModel(error)).toBe(false);+ });++ // A Go subscriber can still run out of Zen's free models: the paid Go and Zen models on the same login keep working,+ // so that refusal holds only the free model, never the whole OpenCode account.+ it.each([+ ['AI_APICallError: Free usage limit reached. Free models work in OpenCode (https://opencode.ai); subscribe to OpenCode Go to keep going: https://opencode.ai/go', "model"],+ ["Internal error: FreeUsageLimitError: free models are limited today", "model"],+ ['OpenCode reached a usage limit (“Free usage limit reached. Free models work in OpenCode”) and is waiting it out without replying, so this turn was stopped.', "model"],+ ["Internal error: Monthly usage limit reached for this key", "engine"],+ ["Internal error: GoUsageLimitError: the Go allowance is used up", "engine"],+ ["GoUsageLimitError: usage limit reached", "engine"],+ ] as const)("reads how far the usage limit reaches: %s", (message, expected) => {+ expect(openCodeLimitFacts(message).limit).toBe(expected);+ });++ it("holds a provider's free models together, never a paid Go model", () => {+ // The catalog reports Zen's free models at cost 0; a Go model is paid.+ parseOpenCodeModelsOutput([+ "opencode/big-pickle", JSON.stringify({ cost: { input: 0, output: 0 } }),+ "opencode-go/deepseek-v4.1-flash", JSON.stringify({ cost: { input: 1, output: 2 } }),+ ].join("\n"));+ const said = 'AI_APICallError: Free usage limit reached. Free models work in OpenCode (https://opencode.ai); subscribe to OpenCode Go to keep going: https://opencode.ai/go';+ const facts = openCodeLimitFacts(said, "opencode/deepseek-v4.1-flash-free");+ expect(facts.limit).toBe("model");+ expect(facts.limitModels).toEqual(expect.arrayContaining(["opencode/deepseek-v4.1-flash-free", "opencode/big-pickle"]));+ expect(facts.limitModels).not.toContain("opencode-go/deepseek-v4.1-flash");+ expect(openCodeLimitFacts(said), "a refusal that names no model holds just the model scope").toEqual({ limit: "model" });+ });+it("classifies OpenCode 2's authentication refusal and leaves real internal errors alone", () => {expect(classifyOpenCodeError({ code: -32000, message: "Authentication required: provider authentication required", data: {} })).toBe("invalid_credentials");diff --cc server/drivers/acp/opencode-go.tsindex 244dcebfa4,0e3c371da0..2037463254--- a/server/drivers/acp/opencode-go.ts+++ b/server/drivers/acp/opencode-go.ts@@@ -717,7 -912,7 +717,8 @@@ const support =|| await canRunOpenCode(env, config.cli, loadCatalog);},classifyError: classifyOpenCodeError,+ promptUnreachedModel: openCodePromptUnreachedModel,+ limitFacts: openCodeLimitFacts,describeAccountError: describeOpenCodeAccountError,resolveModels: async (environment, config, instanceId, fresh) => {if (fresh) markOpenCodeCatalogRefreshed(instanceId, (sources.now ?? Date.now)());