Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge #5104: Find Ollama by itself and add it in one click
milind-soni83bfd870f8a4
diff --cc server/drivers/modelgo.tsindex a2fed5e5d8,0000000000..8785f6df55mode 100644,000000..100644--- a/server/drivers/modelgo.ts+++ b/server/drivers/modelgo.ts@@@ -1,123 -1,0 +1,123 @@@+import { z } from "zod";+import { MODELGO_URL } from "../../shared/modelgo.ts";+import type { ModelCatalog, ProviderDriver } from "../contracts.ts";+import { createOpenAIChatRuntime } from "./openai-chat.ts";++// POST /v1/chat/completions with a Bearer key, tools and tool_choice in the OpenAI shape, SSE ending in [DONE] with a usage+// frame whose `choices` is empty: https://modelgo.ai/docs/models/text/chat-completions and+// /docs/models/text/model-protocol-parameters, read 2026-11-10.+const DEFAULT_URL = "https://api.modelgo.ai/v1";+// No built-in models: the public catalog (https://modelgo.ai/models) showed no model data when read on 2026-11-10, and every+// id must come from it or from GET /models. Until a key is saved the list is empty.+const NO_MODELS: ModelCatalog = { default: "", options: [] };+const configSchema = z.object({+ url: z.string().trim().url().default(DEFAULT_URL),+ model: z.string().trim().min(1).optional(),+ tools: z.boolean().optional(),+});+type ModelgoConfig = z.output<typeof configSchema>;++function decodeConfig(raw: unknown): ModelgoConfig {+ const config = configSchema.parse(raw ?? {});+ config.url = config.url.replace(/\/+$/, "");+ const url = new URL(config.url);+ if (url.protocol !== "https:" && !(url.protocol === "http:" &&+ ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) {+ throw new Error("ModelGo requires HTTPS, except for a local test endpoint.");+ }+ return config;+}++// GET /models, measured 2026-11-10: rows carry id, context_length, input_modalities and output_modalities, with no field for+// tool support, and the list mixes in image, video and speech models.+const modelCard = z.object({+ id: z.string().trim().min(1),+ context_length: z.number().int().positive().optional(),+ input_modalities: z.array(z.string()).optional(),+ output_modalities: z.array(z.string()).optional(),+});+type ModelCard = z.output<typeof modelCard>;++const writesText = (model: ModelCard) => model.output_modalities?.includes("text") === true;++// ModelGo's documented refusals (https://modelgo.ai/docs/quickstart/errors, read 2026-11-10): the code may sit in error.code,+// error.type or error.metadata, so the whole body is searched. "billing" keeps a 402 classified as a quota failure.+const REFUSALS = [+ { status: 402, code: "billing_insufficient", sentence: "Your ModelGo balance has run out, so billing stopped this request. Top up in the ModelGo console, then run it again." },+ { status: 403, code: "first_recharge_required", sentence: "ModelGo's free models need a first top-up on your account. Top up in the ModelGo console, then run it again." },+] as const;+const plainRefusal = (status: number, body: string) =>+ REFUSALS.find((refusal) => refusal.status === status && body.includes(refusal.code))?.sentence;++export const ModelgoDriver: ProviderDriver<ModelgoConfig> = {+ driverKind: "modelgo",+ metadata: { displayName: "ModelGo (API)", supportsMultipleInstances: true, access: "api" },+ models: NO_MODELS,+ install: {+ docsUrl: MODELGO_URL,+ settings: "connections",+ signInCommand: "Save a ModelGo API key in Settings → API keys, or set MODELGO_API_KEY on the server.",+ },+ decodeConfig,+ defaultConfig: () => decodeConfig({}),+ async create(input) {+ const { config } = input;+ // A custom host must bring its own credential; the workspace key goes only to ModelGo.+ const apiKey = (input.environment.MODELGO_API_KEY ??+ (config.url === DEFAULT_URL ? process.env.MODELGO_API_KEY : undefined) ?? "").trim();+ const withConfiguredModel = (options: ModelCatalog["options"]): ModelCatalog => {+ if (config.model && !options.some((option) => option.id === config.model)) {+ options = [{ id: config.model, label: config.model }, ...options];+ }+ return { default: config.model ?? options[0]?.id ?? "", options };+ };+ let catalog = withConfiguredModel(NO_MODELS.options);+ let imageModels = new Set<string>();+ const refreshModels = async () => {+ if (!apiKey) return;+ try {+ const response = await fetch(`${config.url}/models`, {+ headers: { authorization: `Bearer ${apiKey}` }, redirect: "error",+ signal: AbortSignal.timeout(8_000),+ });+ if (!response.ok) return;+ const rows = z.object({ data: z.array(z.unknown()) }).parse(await response.json()).data;+ const options: ModelCatalog["options"] = [];+ const images = new Set<string>();+ for (const row of rows) {+ const parsed = modelCard.safeParse(row);+ if (!parsed.success || !writesText(parsed.data) || options.some((option) => option.id === parsed.data.id)) continue;+ const model = parsed.data;+ options.push({ id: model.id, label: model.id, ...(model.context_length ? { contextWindow: model.context_length } : {}) });+ if (model.input_modalities?.includes("image")) images.add(model.id);+ }+ if (options.length) {+ catalog = withConfiguredModel(options);+ imageModels = images;+ }+ } catch {}+ };+ const firstRefresh = refreshModels();+ return createOpenAIChatRuntime({+ input, driverKind: "modelgo", apiKey, apiUrl: config.url,+ tools: config.tools, models: () => catalog, refreshModels, reasoning: true,+ computerUse: true, imageInput: (model) => imageModels.has(model),+ nudgeAnnouncedAction: true,+ requestBody: (model, messages, stream) => ({ model, messages, stream }),+ httpErrorLabel: "ModelGo",+ plainRefusal,+ missingKeyError: "Save a ModelGo API key in Settings → API keys, or set MODELGO_API_KEY.",+ unavailableReason: "No ModelGo API key — open Settings → API keys.",+ serverUnavailable: async () => {+ await firstRefresh;- return apiKey && !catalog.options.length ? "ModelGo listed no models for this key. Check the key in the ModelGo console, then check again." : null;++ return apiKey && !catalog.options.length ? { reason: "ModelGo listed no models for this key. Check the key in the ModelGo console, then check again." } : null;+ },+ timeoutMs: 180_000, billing: "metered", includeUsageInCompleted: true,+ nativeLog: {+ source: "modelgo.chat.completions",+ outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),+ incoming: ({ text, reasoning, usage }) => ({ textLength: text.length, reasoningLength: reasoning.length, usage }),+ },+ });+ },+};diff --cc src/components/SettingsModal.tsxindex 4c649672be,b934c03544..11bdd28842--- a/src/components/SettingsModal.tsx+++ b/src/components/SettingsModal.tsx@@@ -91,10 -90,10 +91,10 @@@ export const SECTIONS: Array<keywords: string[];}> = [{ id: "general", group: "you", labelKey: "settings.section.general", icon: User, keywords: ["profile", "pinned panels", "web panel", "dashboard", "pin a page", "name", "email", "about me", "about", "suggestions", "suggested", "memory", "analytics", "updates", "product updates", "newsletter", "email updates", "effort", "new bots", "reasoning", "threads", "parallel", "concurrency", "cleanup", "retention", "attachments", "clear attachments", "event log", "event-log", "log size", "automatic recovery", "backup model", "fallback", "routines", "conversation", "schedule", "usage", "limit", "plan", "upgrade", "cloud desktop hours", "storage", "saved steps", "repeat", "replay", "computer tasks", "without ai", "forget", ...talkShortcutKeywords()] },- { id: "appearance", group: "you", labelKey: "settings.section.appearance", icon: Palette, keywords: ["skin", "theme", "appearance", "chat width", "width", "wide", "full width", "bubble", "bubbles", "tools", "tool calls", "threads", "show threads", "hide threads", "sidebar", "display", "run", "this run", "run card", "commands", "notifications", "sound", "sounds", "mute", "silent", "chime", "pinned", "circles", "universal", "groups", "top", "send", "enter", "return", "shift+enter", "ctrl+enter", "cmd+enter", "⌘+enter", "new line", "keyboard", "ime", "japanese", "message color", "my messages", "toolbar", "tools layout", "footer", "routines", "triggers", "team map", "color", "colour", "cloud color", "server color", "tint", "sidebar color", "sidebar picture", "picture", "image", "banner", "background", "computers", "your computers", "rail", "strip", "frame", "window frame", "title bar"] },+ { id: "appearance", group: "you", labelKey: "settings.section.appearance", icon: Palette, keywords: ["skin", "theme", "appearance", "font", "typeface", "chat width", "width", "wide", "full width", "bubble", "bubbles", "tools", "tool calls", "threads", "show threads", "hide threads", "sidebar", "display", "run", "this run", "run card", "commands", "notifications", "sound", "sounds", "mute", "silent", "chime", "pinned", "circles", "universal", "groups", "top", "send", "enter", "return", "shift+enter", "ctrl+enter", "cmd+enter", "⌘+enter", "new line", "keyboard", "ime", "japanese", "message color", "my messages", "toolbar", "tools layout", "footer", "routines", "triggers", "team map", "color", "colour", "cloud color", "server color", "tint", "sidebar color", "sidebar picture", "picture", "image", "banner", "background", "computers", "your computers", "rail", "strip", "frame", "window frame", "title bar"] },{ id: "companion", group: "you", labelKey: "settings.section.companion", icon: TabletSmartphone, keywords: ["companion", "device", "phone", "desktop", "client", "host", "pair", "pairing", "mobile", "https", "secure", "tailscale", "wifi", "remote", "advanced", "domain", "dns", "self-hosted", "server", "caddy"] },{ id: "engines", group: "ai", labelKey: "settings.section.engines", icon: Terminal, keywords: ["models", "model providers", "engines", "claude", "codex", "grok", "providers", "cli", "sign in", "subscription"] },- { id: "connections", group: "ai", labelKey: "settings.section.connections", icon: KeyRound, keywords: ["keys", "api", "api key", "api keys", "connections", "composio", "box", "xai", "mistral", "cerebras", "meta", "muse", "vps", "router", "openrouter", "base url", "openai", "anthropic", "groq", "greenference", "modelgo", "opencode", "deepseek", "provider", "lm studio", "lmstudio", "llm studio", "llmstudio", "bionic"] },- { id: "connections", group: "ai", labelKey: "settings.section.connections", icon: KeyRound, keywords: ["keys", "api", "api key", "api keys", "connections", "composio", "box", "xai", "mistral", "cerebras", "meta", "muse", "vps", "router", "openrouter", "base url", "openai", "anthropic", "groq", "greenference", "opencode", "deepseek", "provider", "ollama", "lm studio", "lmstudio", "llm studio", "llmstudio", "bionic"] },++ { id: "connections", group: "ai", labelKey: "settings.section.connections", icon: KeyRound, keywords: ["keys", "api", "api key", "api keys", "connections", "composio", "box", "xai", "mistral", "cerebras", "meta", "muse", "vps", "router", "openrouter", "base url", "openai", "anthropic", "groq", "greenference", "modelgo", "opencode", "deepseek", "provider", "ollama", "lm studio", "lmstudio", "llm studio", "llmstudio", "bionic"] },{ id: "decisionModel", group: "ai", labelKey: "settings.section.decisionModel", icon: Zap, keywords: ["decision", "extraction", "jev", "typesafe", "cloudflare", "workers ai", "clef", "clairic", "email", "routing", "auto", "rooms", "who answers"] },{ id: "imageGeneration", group: "ai", labelKey: "settings.section.imageGeneration", icon: ImagePlus, keywords: ["image", "images", "picture", "generate", "avatar", "gpt image", "grok imagine", "gemini", "nano banana", "openrouter", "flux", "backup"] },{ id: "skills", group: "ai", labelKey: "settings.section.skills", icon: BookOpen, keywords: ["skills", "library", "assign", "agent skills", "skill md"] },diff --cc src/components/keys/key-catalog.tsindex 10cfdfc255,a672553590..11dca1b735--- a/src/components/keys/key-catalog.ts+++ b/src/components/keys/key-catalog.ts@@@ -45,8 -39,8 +45,8 @@@ export interface KeyTarget}export type KeyId =- | "openai" | "anthropic" | "xai" | "openrouter" | "mistral" | "cerebras" | "groq" | "greenference" | "meta" | "deepseek" | "opencodeGo" | "opencodeProviders"+ | "openai" | "anthropic" | "xai" | "openrouter" | "mistral" | "cerebras" | "groq" | "greenference" | "modelgo" | "meta" | "deepseek" | "opencodeGo" | "opencodeProviders"- | "lmStudio" | "openaiCompat" | "liveCalls" | "liveKey" | "elevenlabs" | "fishAudio" | "geminiTts" | "box" | "vps" | "onePassword" | "composio" | "treg" | "postiz"+ | "ollama" | "lmStudio" | "openaiCompat" | "liveCalls" | "liveKey" | "elevenlabs" | "fishAudio" | "geminiTts" | "box" | "vps" | "onePassword" | "composio" | "treg" | "postiz"| "jev" | "openrouterHelper" | "workersAi" | "imageOpenai" | "imageGemini" | "imageCustom";export type KeyMark = { driverKind: string; preset?: ProviderIconPreset } | { icon: LucideIcon };@@@ -128,8 -119,8 +130,8 @@@ export const KEY_CATALOG: readonly KeyE{ id: "lmStudio", section: "servers", labelKey: "lmStudio.title", purposeKey: "keys.purpose.lmStudio", name: "LM Studio", env: [],words: ["lm studio", "lmstudio", "llm studio", "local", "bionic"], mark: { icon: Server }, kind: "panel" },{ id: "openaiCompat", section: "servers", labelKey: "keys.openaiCompat.label", purposeKey: "keys.purpose.openaiCompat", name: "OpenAI-compatible", env: ["OPENAI_COMPAT_API_KEY", "OPENAI_COMPAT_URL"],- words: ["openai-compatible", "openai compatible", "ollama", "together", "gemini", "google ai studio", "base url", "server", "endpoint"], mark: { icon: Server }, kind: "key",+ words: ["openai-compatible", "openai compatible", "together", "gemini", "google ai studio", "base url", "server", "endpoint"], mark: { icon: Server }, kind: "key",- target: { patch: (value) => ({ openaiCompat: { key: value } }), saved: (config) => flag(config.openaiCompat), placeholder: "…", placeholderKey: "keys.openaiCompat.placeholder",+ target: { patch: (value) => ({ openaiCompat: { key: value } }), slot: "openaiCompatApiKey", saved: (config) => flag(config.openaiCompat), placeholder: "…", placeholderKey: "keys.openaiCompat.placeholder",href: "https://platform.openai.com/docs/api-reference", test: "openaiCompat", analytics: "openai_compat" } },{ id: "liveCalls", section: "voice", labelKey: "call.live.key", purposeKey: "keys.purpose.liveCalls", name: "OpenAI", env: [],words: ["openai", "live calls", "calls", "voice", "talk", "gpt-live", "read aloud", "speech", "tts"], mark: { icon: Phone }, kind: "uses", uses: "openai" },