${esc(title)}
${esc(text)}
// Devin subscriptions for OpenCode and magpie: the devin CLI's own sign-in // (a PKCE round through app.devin.ai to a callback on 127.0.0.1), and each // chat completion sent whole to the API the CLI talks to, Windsurf's // GetChatMessage (a Connect RPC in protobuf), its reply streamed back as // chat completion chunks. Ported from magpie's built-in Devin account // (internal/provider/devin*.go, internal/gateway/devin.go). import { createHash, randomBytes, randomUUID } from "node:crypto" import { createServer } from "node:http" import { gunzipSync } from "node:zlib" import { spawn } from "node:child_process" import { existsSync, statSync } from "node:fs" import { mkdir, readFile, writeFile } from "node:fs/promises" import { homedir } from "node:os" import { join } from "node:path" const ID = "devin" const CHAT = "@ai-sdk/openai-compatible" const SERVER = "https://server.codeium.com" const AUTHORIZE = "https://app.devin.ai/auth/cli/continue" const EXCHANGE = "/exa.seat_management_pb.SeatManagementService/ExchangeDevinCLIPKCECode" const CHAT_RPC = "/exa.api_server_pb.ApiServerService/GetChatMessage" // the CLI the requests say they come from const CLI_VERSION = "3000.11.3" // the AI SDK is given a chat completions URL; the loader's fetch answers // every request itself, so nothing is ever sent here const BASE = SERVER + "/devin/v1" const SIGN_IN_TIMEOUT = 10 * 60 * 1000 // how long the CLI's model list is kept, and how long a failed read waits const FRESH = 5 * 60 * 1000 const RETRY = 60 * 1000 // ---- models --------------------------------------------------------------------- // Devin's list as `devin models list --format json` gave it (2026-09-30), // less Adaptive and Fusion, which route between models inside Devin's own // agent and aren't served by the API: family id, label, aliases, and each // variant's id, label, context and output. The CLI's list, when the CLI is // installed, replaces it. const SNAPSHOT = [ ["swe-2","SWE-2",["swe"],[["swe-2-high","SWE-2 High",262000,128000],["swe-2-medium","SWE-2 Medium",262000,128000],["swe-2-max","SWE-2 Max",262000,128000]]], ["swe-1.7-lightning","SWE-1.7 Lightning",[],[["swe-1-7-lightning","SWE-1.7 Lightning Max",202752,96000],["swe-1-7-lightning-medium","SWE-1.7 Lightning Medium",202752,96000]]], ["claude-fable-5-1","Claude Fable 5.1",["fable"],[["claude-fable-5-1-medium","Claude Fable 5.1 Medium",1000000,128000],["claude-fable-5-1-low","Claude Fable 5.1 Low",1000000,128000],["claude-fable-5-1-high","Claude Fable 5.1 High",1000000,128000],["claude-fable-5-1-xhigh","Claude Fable 5.1 XHigh",1000000,128000],["claude-fable-5-1-max","Claude Fable 5.1 Max",1000000,128000]]], ["claude-opus-5-5","Claude Opus 5.5",[],[["claude-opus-5-5-medium","Claude Opus 5.5 Medium",1000000,128000],["claude-opus-5-5-low","Claude Opus 5.5 Low",1000000,128000],["claude-opus-5-5-high","Claude Opus 5.5 High",1000000,128000],["claude-opus-5-5-xhigh","Claude Opus 5.5 XHigh",1000000,128000],["claude-opus-5-5-max","Claude Opus 5.5 Max",1000000,128000],["claude-opus-5-5-low-fast","Claude Opus 5.5 Low Fast",1000000,128000],["claude-opus-5-5-medium-fast","Claude Opus 5.5 Medium Fast",1000000,128000],["claude-opus-5-5-high-fast","Claude Opus 5.5 High Fast",1000000,128000],["claude-opus-5-5-xhigh-fast","Claude Opus 5.5 XHigh Fast",1000000,128000],["claude-opus-5-5-max-fast","Claude Opus 5.5 Max Fast",1000000,128000]]], ["gpt-6-astra","GPT-6 Astra",[],[["gpt-6-astra-medium","GPT-6 Astra Medium Thinking",1000000,128000],["gpt-6-astra-low","GPT-6 Astra Low Thinking",1000000,128000],["gpt-6-astra-high","GPT-6 Astra High Thinking",1000000,128000],["gpt-6-astra-xhigh","GPT-6 Astra XHigh Thinking",1000000,128000],["gpt-6-astra-max","GPT-6 Astra Max Thinking",1000000,128000],["gpt-6-astra-low-priority","GPT-6 Astra Low Thinking Fast",1000000,128000],["gpt-6-astra-medium-priority","GPT-6 Astra Medium Thinking Fast",1000000,128000],["gpt-6-astra-high-priority","GPT-6 Astra High Thinking Fast",1000000,128000],["gpt-6-astra-xhigh-priority","GPT-6 Astra XHigh Thinking Fast",1000000,128000],["gpt-6-astra-max-priority","GPT-6 Astra Max Thinking Fast",1000000,128000]]], ["gpt-6-sol","GPT-6 Sol",[],[["gpt-6-sol-medium","GPT-6 Sol Medium Thinking",1000000,128000],["gpt-6-sol-none","GPT-6 Sol No Thinking",1000000,128000],["gpt-6-sol-low","GPT-6 Sol Low Thinking",1000000,128000],["gpt-6-sol-high","GPT-6 Sol High Thinking",1000000,128000],["gpt-6-sol-xhigh","GPT-6 Sol XHigh Thinking",1000000,128000],["gpt-6-sol-max","GPT-6 Sol Max Thinking",1000000,128000],["gpt-6-sol-none-priority","GPT-6 Sol No Thinking Fast",1000000,128000],["gpt-6-sol-low-priority","GPT-6 Sol Low Thinking Fast",1000000,128000],["gpt-6-sol-medium-priority","GPT-6 Sol Medium Thinking Fast",1000000,128000],["gpt-6-sol-high-priority","GPT-6 Sol High Thinking Fast",1000000,128000],["gpt-6-sol-xhigh-priority","GPT-6 Sol XHigh Thinking Fast",1000000,128000],["gpt-6-sol-max-priority","GPT-6 Sol Max Thinking Fast",1000000,128000]]], ["gpt-6-luna","GPT-6 Luna",[],[["gpt-6-luna-medium","GPT-6 Luna Medium Thinking",1000000,128000],["gpt-6-luna-none","GPT-6 Luna No Thinking",1000000,128000],["gpt-6-luna-low","GPT-6 Luna Low Thinking",1000000,128000],["gpt-6-luna-high","GPT-6 Luna High Thinking",1000000,128000],["gpt-6-luna-xhigh","GPT-6 Luna XHigh Thinking",1000000,128000],["gpt-6-luna-max","GPT-6 Luna Max Thinking",1000000,128000],["gpt-6-luna-none-priority","GPT-6 Luna No Thinking Fast",1000000,128000],["gpt-6-luna-low-priority","GPT-6 Luna Low Thinking Fast",1000000,128000],["gpt-6-luna-medium-priority","GPT-6 Luna Medium Thinking Fast",1000000,128000],["gpt-6-luna-high-priority","GPT-6 Luna High Thinking Fast",1000000,128000],["gpt-6-luna-xhigh-priority","GPT-6 Luna XHigh Thinking Fast",1000000,128000],["gpt-6-luna-max-priority","GPT-6 Luna Max Thinking Fast",1000000,128000]]], ["kimi-k3","Kimi K3",[],[["kimi-k3-high","Kimi K3 High",1048576,131072],["kimi-k3-low","Kimi K3 Low",1048576,131072],["kimi-k3-max","Kimi K3 Max",1048576,131072]]], ["glm-5.2","GLM-5.2",[],[["glm-5-2","GLM-5.2 High",200000,128000],["glm-5-2-max","GLM-5.2 Max",200000,128000],["glm-5-2-1m","GLM-5.2 High 1M",1000000,128000],["glm-5-2-max-1m","GLM-5.2 Max 1M",1000000,128000],["glm-5-2-none","GLM-5.2 No Thinking",200000,128000],["glm-5-2-none-1m","GLM-5.2 No Thinking 1M",1000000,128000]]], ["glm-5-3","GLM-5.3",[],[["glm-5-3-low","GLM-5.3 Low",1048576,128000],["glm-5-3-high","GLM-5.3 High",1048576,128000],["glm-5-3-max","GLM-5.3 Max",1048576,128000]]], ["claude-sonnet-5-5","Claude Sonnet 5.5",[],[["claude-sonnet-5-5-medium","Claude Sonnet 5.5 Medium",1000000,128000],["claude-sonnet-5-5-low","Claude Sonnet 5.5 Low",1000000,128000],["claude-sonnet-5-5-high","Claude Sonnet 5.5 High",1000000,128000],["claude-sonnet-5-5-xhigh","Claude Sonnet 5.5 XHigh",1000000,128000],["claude-sonnet-5-5-max","Claude Sonnet 5.5 Max",1000000,128000]]], ["gemini-3-8-flash","Gemini 3.8 Flash",["gemini"],[["gemini-3-8-flash-medium","Gemini 3.8 Flash Medium",1048576,65535],["gemini-3-8-flash-low","Gemini 3.8 Flash Low",1048576,65535],["gemini-3-8-flash-high","Gemini 3.8 Flash High",1048576,65535]]], ["claude-opus-4.7","Claude Opus 4.7",[],[["claude-opus-4-7-medium","Claude Opus 4.7 Medium",1000000,128000],["claude-opus-4-7-low","Claude Opus 4.7 Low",1000000,128000],["claude-opus-4-7-high","Claude Opus 4.7 High",1000000,128000],["claude-opus-4-7-xhigh","Claude Opus 4.7 XHigh",1000000,128000],["claude-opus-4-7-max","Claude Opus 4.7 Max",1000000,128000]]], ["claude-opus-4.8","Claude Opus 4.8",[],[["claude-opus-4-8-medium","Claude Opus 4.8 Medium",1000000,128000],["claude-opus-4-8-low","Claude Opus 4.8 Low",1000000,128000],["claude-opus-4-8-high","Claude Opus 4.8 High",1000000,128000],["claude-opus-4-8-xhigh","Claude Opus 4.8 XHigh",1000000,128000],["claude-opus-4-8-max","Claude Opus 4.8 Max",1000000,128000],["claude-opus-4-8-low-fast","Claude Opus 4.8 Low Fast",1000000,128000],["claude-opus-4-8-medium-fast","Claude Opus 4.8 Medium Fast",1000000,128000],["claude-opus-4-8-high-fast","Claude Opus 4.8 High Fast",1000000,128000],["claude-opus-4-8-xhigh-fast","Claude Opus 4.8 XHigh Fast",1000000,128000],["claude-opus-4-8-max-fast","Claude Opus 4.8 Max Fast",1000000,128000]]], ["claude-opus-5","Claude Opus 5",["opus"],[["claude-opus-5-medium","Claude Opus 5 Medium",1000000,128000],["claude-opus-5-low","Claude Opus 5 Low",1000000,128000],["claude-opus-5-high","Claude Opus 5 High",1000000,128000],["claude-opus-5-xhigh","Claude Opus 5 XHigh",1000000,128000],["claude-opus-5-max","Claude Opus 5 Max",1000000,128000],["claude-opus-5-low-fast","Claude Opus 5 Low Fast",1000000,128000],["claude-opus-5-medium-fast","Claude Opus 5 Medium Fast",1000000,128000],["claude-opus-5-high-fast","Claude Opus 5 High Fast",1000000,128000],["claude-opus-5-xhigh-fast","Claude Opus 5 XHigh Fast",1000000,128000],["claude-opus-5-max-fast","Claude Opus 5 Max Fast",1000000,128000]]], ["claude-5-fable","Claude Fable 5",[],[["claude-5-fable-low","Claude Fable 5 Low",1000000,128000],["claude-5-fable-medium","Claude Fable 5 Medium",1000000,128000],["claude-5-fable-high","Claude Fable 5 High",1000000,128000],["claude-5-fable-xhigh","Claude Fable 5 XHigh",1000000,128000],["claude-5-fable-max","Claude Fable 5 Max",1000000,128000]]], ["claude-sonnet-5","Claude Sonnet 5",["claude","sonnet"],[["claude-sonnet-5-low","Claude Sonnet 5 Low",1000000,128000],["claude-sonnet-5-medium","Claude Sonnet 5 Medium",1000000,128000],["claude-sonnet-5-high","Claude Sonnet 5 High",1000000,128000],["claude-sonnet-5-xhigh","Claude Sonnet 5 XHigh",1000000,128000],["claude-sonnet-5-max","Claude Sonnet 5 Max",1000000,128000]]], ["gemini-3.5-flash","Gemini 3.5 Flash",[],[["gemini-3-5-flash-minimal","Gemini 3.5 Flash Minimal",1048576,65535],["gemini-3-5-flash-low","Gemini 3.5 Flash Low",1048576,65535],["gemini-3-5-flash-medium","Gemini 3.5 Flash Medium",1048576,65535],["gemini-3-5-flash-high","Gemini 3.5 Flash High",1048576,65535]]], ["gemini-3.6-flash","Gemini 3.6 Flash",[],[["gemini-3-6-flash-minimal","Gemini 3.6 Flash Minimal",1048576,65535],["gemini-3-6-flash-low","Gemini 3.6 Flash Low",1048576,65535],["gemini-3-6-flash-medium","Gemini 3.6 Flash Medium",1048576,65535],["gemini-3-6-flash-high","Gemini 3.6 Flash High",1048576,65535]]], ["gemini-3-7-flash","Gemini 3.7 Flash",[],[["gemini-3-7-flash-low","Gemini 3.7 Flash Low",1048576,65535],["gemini-3-7-flash-medium","Gemini 3.7 Flash Medium",1048576,65535],["gemini-3-7-flash-high","Gemini 3.7 Flash High",1048576,65535]]], ["gpt-5.6-sol","GPT-5.6 Sol",[],[["gpt-5-6-sol-none","GPT-5.6 Sol No Thinking",1000000,128000],["gpt-5-6-sol-low","GPT-5.6 Sol Low Thinking",1000000,128000],["gpt-5-6-sol-medium","GPT-5.6 Sol Medium Thinking",1000000,128000],["gpt-5-6-sol-high","GPT-5.6 Sol High Thinking",1000000,128000],["gpt-5-6-sol-xhigh","GPT-5.6 Sol XHigh Thinking",1000000,128000],["gpt-5-6-sol-max","GPT-5.6 Sol Max Thinking",1000000,128000],["gpt-5-6-sol-none-priority","GPT-5.6 Sol No Thinking Fast",1000000,128000],["gpt-5-6-sol-low-priority","GPT-5.6 Sol Low Thinking Fast",1000000,128000],["gpt-5-6-sol-medium-priority","GPT-5.6 Sol Medium Thinking Fast",1000000,128000],["gpt-5-6-sol-high-priority","GPT-5.6 Sol High Thinking Fast",1000000,128000],["gpt-5-6-sol-xhigh-priority","GPT-5.6 Sol XHigh Thinking Fast",1000000,128000],["gpt-5-6-sol-max-priority","GPT-5.6 Sol Max Thinking Fast",1000000,128000]]], ["gpt-5.6-terra","GPT-5.6 Terra",[],[["gpt-5-6-terra-none","GPT-5.6 Terra No Thinking",1000000,128000],["gpt-5-6-terra-low","GPT-5.6 Terra Low Thinking",1000000,128000],["gpt-5-6-terra-medium","GPT-5.6 Terra Medium Thinking",1000000,128000],["gpt-5-6-terra-high","GPT-5.6 Terra High Thinking",1000000,128000],["gpt-5-6-terra-xhigh","GPT-5.6 Terra XHigh Thinking",1000000,128000],["gpt-5-6-terra-max","GPT-5.6 Terra Max Thinking",1000000,128000],["gpt-5-6-terra-none-priority","GPT-5.6 Terra No Thinking Fast",1000000,128000],["gpt-5-6-terra-low-priority","GPT-5.6 Terra Low Thinking Fast",1000000,128000],["gpt-5-6-terra-medium-priority","GPT-5.6 Terra Medium Thinking Fast",1000000,128000],["gpt-5-6-terra-high-priority","GPT-5.6 Terra High Thinking Fast",1000000,128000],["gpt-5-6-terra-xhigh-priority","GPT-5.6 Terra XHigh Thinking Fast",1000000,128000],["gpt-5-6-terra-max-priority","GPT-5.6 Terra Max Thinking Fast",1000000,128000]]], ["gpt-5.6-luna","GPT-5.6 Luna",[],[["gpt-5-6-luna-none","GPT-5.6 Luna No Thinking",1000000,128000],["gpt-5-6-luna-low","GPT-5.6 Luna Low Thinking",1000000,128000],["gpt-5-6-luna-medium","GPT-5.6 Luna Medium Thinking",1000000,128000],["gpt-5-6-luna-high","GPT-5.6 Luna High Thinking",1000000,128000],["gpt-5-6-luna-xhigh","GPT-5.6 Luna XHigh Thinking",1000000,128000],["gpt-5-6-luna-max","GPT-5.6 Luna Max Thinking",1000000,128000],["gpt-5-6-luna-none-priority","GPT-5.6 Luna No Thinking Fast",1000000,128000],["gpt-5-6-luna-low-priority","GPT-5.6 Luna Low Thinking Fast",1000000,128000],["gpt-5-6-luna-medium-priority","GPT-5.6 Luna Medium Thinking Fast",1000000,128000],["gpt-5-6-luna-high-priority","GPT-5.6 Luna High Thinking Fast",1000000,128000],["gpt-5-6-luna-xhigh-priority","GPT-5.6 Luna XHigh Thinking Fast",1000000,128000],["gpt-5-6-luna-max-priority","GPT-5.6 Luna Max Thinking Fast",1000000,128000]]], ["gpt-6-1-sol","GPT-6.1 Sol",[],[["gpt-6-1-sol-low","GPT-6.1 Sol Low Thinking",1000000,128000],["gpt-6-1-sol-medium","GPT-6.1 Sol Medium Thinking",1000000,128000],["gpt-6-1-sol-high","GPT-6.1 Sol High Thinking",1000000,128000],["gpt-6-1-sol-xhigh","GPT-6.1 Sol XHigh Thinking",1000000,128000],["gpt-6-1-sol-max","GPT-6.1 Sol Max Thinking",1000000,128000],["gpt-6-1-sol-low-priority","GPT-6.1 Sol Low Thinking Fast",1000000,128000],["gpt-6-1-sol-medium-priority","GPT-6.1 Sol Medium Thinking Fast",1000000,128000],["gpt-6-1-sol-high-priority","GPT-6.1 Sol High Thinking Fast",1000000,128000],["gpt-6-1-sol-xhigh-priority","GPT-6.1 Sol XHigh Thinking Fast",1000000,128000],["gpt-6-1-sol-max-priority","GPT-6.1 Sol Max Thinking Fast",1000000,128000]]], ["grok-4.5","Grok 4.5",[],[["grok-4-5-low","Grok 4.5 Low",500000,100000],["grok-4-5-medium","Grok 4.5 Medium",500000,100000],["grok-4-5-high","Grok 4.5 High",500000,100000]]], ["grok-4-6","Grok 4.6",[],[["grok-4-6-low","Grok 4.6 Low",500000,100000],["grok-4-6-medium","Grok 4.6 Medium",500000,100000],["grok-4-6-high","Grok 4.6 High",500000,100000],["grok-4-6-xhigh","Grok 4.6 XHigh",500000,100000]]], ["grok-4-7","Grok 4.7",[],[["grok-4-7-low","Grok 4.7 Low",500000,100000],["grok-4-7-medium","Grok 4.7 Medium",500000,100000],["grok-4-7-high","Grok 4.7 High",500000,100000],["grok-4-7-xhigh","Grok 4.7 XHigh",500000,100000]]], ["inkling","Inkling",[],[["inkling-none","Inkling None",1048576,131072],["inkling-low","Inkling Low",1048576,131072],["inkling-medium","Inkling Medium",1048576,131072],["inkling-high","Inkling High",1048576,131072],["inkling-xhigh","Inkling X-High",1048576,131072],["inkling-max","Inkling Max",1048576,131072]]], ["glm-5-3-flash","GLM-5.3 Flash",[],[["glm-5-3-flash-low","GLM-5.3 Flash Low",1000000,128000],["glm-5-3-flash-high","GLM-5.3 Flash High",1000000,128000],["glm-5-3-flash-max","GLM-5.3 Flash Max",1000000,128000]]], ["deepseek-v4-flash","DeepSeek V4 Flash",[],[["deepseek-v4-flash-high","DeepSeek V4 Flash High",1048576,384000],["deepseek-v4-flash-max","DeepSeek V4 Flash Max",1048576,384000]]], ["deepseek-v4-1-flash","DeepSeek V4.1 Flash",[],[["deepseek-v4-1-flash-high","DeepSeek V4.1 Flash High",1048576,384000],["deepseek-v4-1-flash-max","DeepSeek V4.1 Flash Max",1048576,384000]]], ["swe-1.7","SWE-1.7",[],[["swe-1-7","SWE-1.7 Max",262000,128000],["swe-1-7-medium","SWE-1.7 Medium",262000,128000]]], ["claude-opus-4.6","Claude Opus 4.6",[],[["claude-opus-4-6","Claude Opus 4.6",200000,128000],["claude-opus-4-6-thinking","Claude Opus 4.6 Thinking",200000,128000],["claude-opus-4-6-1m","Claude Opus 4.6 1M",1000000,128000],["claude-opus-4-6-thinking-1m","Claude Opus 4.6 Thinking 1M",1000000,128000]]], ["gpt-5.4","GPT-5.4",[],[["gpt-5-4-none","GPT-5.4 No Thinking",272000,128000],["gpt-5-4-low","GPT-5.4 Low Thinking",272000,128000],["gpt-5-4-medium","GPT-5.4 Medium Thinking",272000,128000],["gpt-5-4-high","GPT-5.4 High Thinking",272000,128000],["gpt-5-4-xhigh","GPT-5.4 XHigh Thinking",272000,128000],["gpt-5-4-none-priority","GPT-5.4 No Thinking Fast",272000,128000],["gpt-5-4-low-priority","GPT-5.4 Low Thinking Fast",272000,128000],["gpt-5-4-medium-priority","GPT-5.4 Medium Thinking Fast",272000,128000],["gpt-5-4-high-priority","GPT-5.4 High Thinking Fast",272000,128000],["gpt-5-4-xhigh-priority","GPT-5.4 XHigh Thinking Fast",272000,128000]]], ["gpt-5.5","GPT-5.5",["gpt"],[["gpt-5-5-none","GPT-5.5 No Thinking",272000,128000],["gpt-5-5-low","GPT-5.5 Low Thinking",272000,128000],["gpt-5-5-medium","GPT-5.5 Medium Thinking",272000,128000],["gpt-5-5-high","GPT-5.5 High Thinking",272000,128000],["gpt-5-5-xhigh","GPT-5.5 XHigh Thinking",272000,128000],["gpt-5-5-none-priority","GPT-5.5 No Thinking Fast",272000,128000],["gpt-5-5-low-priority","GPT-5.5 Low Thinking Fast",272000,128000],["gpt-5-5-medium-priority","GPT-5.5 Medium Thinking Fast",272000,128000],["gpt-5-5-high-priority","GPT-5.5 High Thinking Fast",272000,128000],["gpt-5-5-xhigh-priority","GPT-5.5 XHigh Thinking Fast",272000,128000]]], ["gpt-5.4-mini","GPT-5.4 Mini",[],[["gpt-5-4-mini-low","GPT-5.4 Mini Low Thinking",400000,128000],["gpt-5-4-mini-medium","GPT-5.4 Mini Medium Thinking",400000,128000],["gpt-5-4-mini-high","GPT-5.4 Mini High Thinking",400000,128000],["gpt-5-4-mini-xhigh","GPT-5.4 Mini XHigh Thinking",400000,128000]]], ["claude-sonnet-4.6","Claude Sonnet 4.6",[],[["claude-sonnet-4-6","Claude Sonnet 4.6",200000,128000],["claude-sonnet-4-6-thinking","Claude Sonnet 4.6 Thinking",200000,128000],["claude-sonnet-4-6-1m","Claude Sonnet 4.6 1M",1000000,128000],["claude-sonnet-4-6-thinking-1m","Claude Sonnet 4.6 Thinking 1M",1000000,128000]]], ["gpt-5.2","GPT-5.2",[],[["MODEL_GPT_5_2_LOW","GPT-5.2 Low Thinking",384000,128000],["MODEL_GPT_5_2_MEDIUM","GPT-5.2 Medium Thinking",384000,128000],["MODEL_GPT_5_2_NONE","GPT-5.2 No Thinking",384000,128000],["MODEL_GPT_5_2_HIGH","GPT-5.2 High Thinking",384000,128000],["MODEL_GPT_5_2_XHIGH","GPT-5.2 XHigh Thinking",384000,128000]]], ["claude-opus-4.5","Claude Opus 4.5",[],[["MODEL_CLAUDE_4_5_OPUS","Claude Opus 4.5",200000,64000],["MODEL_CLAUDE_4_5_OPUS_THINKING","Claude Opus 4.5 Thinking",200000,64000]]], ["Claude Haiku 4.5","Claude Haiku 4.5",[],[["MODEL_PRIVATE_11","Claude Haiku 4.5",200000,64000]]], ["claude-sonnet-4.5","Claude Sonnet 4.5",[],[["MODEL_PRIVATE_2","Claude Sonnet 4.5",200000,64000],["MODEL_PRIVATE_3","Claude Sonnet 4.5 Thinking",200000,64000]]], ["GPT-4.1","GPT-4.1",[],[["MODEL_CHAT_GPT_4_1_2025_04_14","GPT-4.1",1047576,32768]]], ["gpt-5.1","GPT-5.1",[],[["MODEL_PRIVATE_12","GPT-5.1 No Thinking",272000,128000],["MODEL_PRIVATE_13","GPT-5.1 Low Thinking",272000,128000],["MODEL_PRIVATE_14","GPT-5.1 Medium Thinking",272000,128000],["MODEL_PRIVATE_15","GPT-5.1 High Thinking",272000,128000]]], ["gpt-5.3-codex","GPT-5.3-Codex",["codex"],[["gpt-5-3-codex-low","GPT-5.3-Codex Low",400000,128000],["gpt-5-3-codex-medium","GPT-5.3-Codex Medium",400000,128000],["gpt-5-3-codex-high","GPT-5.3-Codex High",400000,128000],["gpt-5-3-codex-xhigh","GPT-5.3-Codex X-High",400000,128000],["gpt-5-3-codex-low-priority","GPT-5.3-Codex Low Fast",400000,128000],["gpt-5-3-codex-medium-priority","GPT-5.3-Codex Medium Fast",400000,128000],["gpt-5-3-codex-high-priority","GPT-5.3-Codex High Fast",400000,128000],["gpt-5-3-codex-xhigh-priority","GPT-5.3-Codex XHigh Fast",400000,128000]]], ["kimi-k2.6","Kimi K2.6",[],[["kimi-k2-6","Kimi K2.6",262144,8192]]], ["kimi-k2.7","Kimi K2.7",[],[["kimi-k2-7","Kimi K2.7",262144,16000]]], ["nemotron-3-ultra","Nemotron 3 Ultra",[],[["nemotron-3-ultra-none","Nemotron 3 Ultra None",1000000,32768],["nemotron-3-ultra-medium","Nemotron 3 Ultra Medium",1000000,32768],["nemotron-3-ultra-high","Nemotron 3 Ultra High",1000000,32768]]], ["swe-1.6","SWE-1.6",[],[["swe-1-6","SWE-1.6",200000,128000]]], ["swe-1.6-fast","SWE-1.6 Fast",[],[["swe-1-6-fast","SWE-1.6 Fast",200000,128000]]], ["gemini-3.1-pro","Gemini 3.1 Pro",[],[["gemini-3-1-pro-low","Gemini 3.1 Pro Low Thinking",1048576,65535],["gemini-3-1-pro-high","Gemini 3.1 Pro High Thinking",1048576,65535]]], ["gemini-3.0-flash","Gemini 3 Flash",[],[["MODEL_GOOGLE_GEMINI_3_0_FLASH_MINIMAL","Gemini 3 Flash Minimal",1048576,65535],["MODEL_GOOGLE_GEMINI_3_0_FLASH_LOW","Gemini 3 Flash Low",1048576,65535],["MODEL_GOOGLE_GEMINI_3_0_FLASH_MEDIUM","Gemini 3 Flash Medium",1048576,65535],["MODEL_GOOGLE_GEMINI_3_0_FLASH_HIGH","Gemini 3 Flash High",1048576,65535]]], ["deepseek-v4-pro","DeepSeek V4 Pro",[],[["deepseek-v4-pro-high","DeepSeek V4 Pro High",1048576,384000],["deepseek-v4-pro-max","DeepSeek V4 Pro Max",1048576,384000]]] ] const familiesOf = (rows) => rows.map(([uid, label, aliases, vs]) => ({ uid, label, aliases, models: vs.map(([id, name, context, output]) => ({ id, name, context, output })) })) // parseFamilies reads `devin models list --format json`. function parseFamilies(text) { let list try { list = JSON.parse(text) } catch { return [] } const out = [] for (const f of list?.families ?? []) { if (!f?.family_uid) continue const low = String(f.family_uid).toLowerCase() if (low === "adaptive" || low === "fusion") continue out.push({ uid: f.family_uid, label: f.family_label || f.family_uid, aliases: f.aliases ?? [], models: (f.variants ?? []) .filter((v) => v?.model_uid) .map((v) => ({ id: v.model_uid, name: v.label || v.model_uid, context: v.max_context_tokens || 0, output: v.max_output_tokens || 0 })), }) } return out } const LEVEL_RANK = ["none", "minimal", "low", "medium", "high", "xhigh", "max"] // the effort words Devin's variant ids end in (swe-2-high, …_HIGH, // gpt-6-sol-none), and the level each is const LEVELS = [["none", "none"], ["xhigh", "xhigh"], ["minimal", "minimal"], ["min", "minimal"], ["low", "low"], ["medium", "medium"], ["high", "high"], ["max", "max"]] // the words a variant id may end in after its effort, for a quicker run of // the same model at it (claude-opus-5-5-high-fast) const TIERS = [["fast", "Fast"], ["priority", "Priority"]] // levelOf is the effort an id says it runs at, "" when it says none. function levelOf(id) { const low = id.toLowerCase() for (const [word, level] of LEVELS) if (low.endsWith("-" + word) || low.endsWith("_" + word)) return level return "" } // tierOf is the tier an id is in and its effort: claude-opus-5-5-high-fast // is ["fast", "high"], swe-2-high ["", "high"]; a tier word with no effort // before it (swe-1-6-fast) is no tier. function tierOf(id) { const low = id.toLowerCase() for (const [word] of TIERS) for (const sep of ["-", "_"]) if (low.endsWith(sep + word)) { const l = levelOf(low.slice(0, -(sep + word).length)) if (l) return [word, l] } return ["", levelOf(id)] } const named = (f, id) => f.uid === id || f.aliases.includes(id) // byLevel is the family's variant at each effort, in the tier, the first // at each. function byLevel(f, tier) { const out = {} for (const m of f.models) { const [t, l] = tierOf(m.id) if (t === tier && l && m.id !== f.uid && !out[l]) out[l] = m.id } return out } const efforts = (f, tier) => { const by = byLevel(f, tier) return LEVEL_RANK.filter((l) => by[l]) } const tiers = (f) => TIERS.map(([w]) => w).filter((t) => Object.keys(byLevel(f, t)).length > 0) // defaultLevel is the effort of the variant the family's id asks for when // none is asked (its first), medium when that names none. function defaultLevel(f) { if (f.models.length) { const [t, l] = tierOf(f.models[0].id) if (!t && l) return l } return "medium" } // nearest is the one of levels nearest the one asked for, a tie going up. function nearest(want, levels) { const at = LEVEL_RANK.indexOf(want) if (at < 0 || !levels.length || levels.includes(want)) return want let best = want let dist = LEVEL_RANK.length for (const l of levels) { const i = LEVEL_RANK.indexOf(l) const d = Math.abs(i - at) if (d < dist || (d === dist && i > at)) [best, dist] = [l, d] } return best } // variantFor is the model to ask the API for: a family's id follows its // newest model, which the API takes only as one of its variants — the one // at the effort asked for, or the nearest the family has; with none asked, // the family's default. A family's fast run is its fast variant at that // effort. Any other id (a variant's own) goes as it is. function variantFor(families, model, effort) { for (const f of families) { if (!named(f, model) || !f.models.length) continue if (effort) { const id = byLevel(f, "")[nearest(effort, efforts(f, ""))] if (id) return id } return f.models[0].id } for (const f of families) for (const tier of tiers(f)) { if (!model.endsWith("-" + tier) || !named(f, model.slice(0, -(tier.length + 1)))) continue const by = byLevel(f, tier) const levels = efforts(f, tier) return by[nearest(effort || defaultLevel(f), levels)] || by[levels[0]] } return model } // listed is Devin's list as it is offered: each family one model, with // the efforts its variants are at (picked as any model's effort is, and // turned into the variant by variantFor), its fast run likewise, and the // variants at no effort (glm-5-2-1m); a family's only variant is its id. function listed(families) { const out = [] const seen = new Set() const add = (m) => { if (seen.has(m.id)) return seen.add(m.id) out.push(m) } for (const f of families) { const context = f.models.find((m) => m.context)?.context ?? 0 const output = f.models.find((m) => m.output)?.output ?? 0 add({ id: f.uid, name: f.label, context, output, efforts: efforts(f, "") }) for (const t of tiers(f)) { const id = f.uid + "-" + t if (families.some((g) => named(g, id))) continue add({ id, name: f.label + " " + TIERS.find(([w]) => w === t)[1], context, output, efforts: efforts(f, t) }) } if (f.models.length === 1) continue for (const m of f.models) { if (m.id === f.uid || tierOf(m.id)[1]) continue add({ id: m.id, name: m.name, context: m.context || context, output: m.output || output, efforts: [] }) } } return out } function configModel(m) { return { id: m.id, name: m.name, tool_call: true, reasoning: m.efforts.length > 0, attachment: true, temperature: true, modalities: { input: ["text", "image"], output: ["text"] }, limit: { context: m.context, output: m.output }, ...(m.efforts.length ? { variants: Object.fromEntries(m.efforts.map((e) => [e, { reasoningEffort: e }])) } : {}), } } function runtimeModel(m) { return { id: m.id, providerID: ID, name: m.name, api: { id: m.id, url: BASE, npm: CHAT }, status: "active", headers: {}, options: {}, cost: { input: 0, output: 0, cache: { read: 0, write: 0 } }, limit: { context: m.context, output: m.output }, capabilities: { temperature: true, reasoning: m.efforts.length > 0, attachment: true, toolcall: true, input: { text: true, image: true, audio: false, video: false, pdf: false }, output: { text: true, image: false, audio: false, video: false, pdf: false }, interleaved: false, }, release_date: "", variants: Object.fromEntries(m.efforts.map((e) => [e, { reasoningEffort: e }])), } } // ---- the devin CLI ----------------------------------------------------------------- // cliPath finds the devin CLI, "" without one. function cliPath() { const exe = process.platform === "win32" ? "devin.exe" : "devin" for (const dir of (process.env.PATH ?? "").split(process.platform === "win32" ? ";" : ":")) if (dir && isFile(join(dir, exe))) return join(dir, exe) for (const p of [join(homedir(), ".local", "bin", "devin"), "/usr/local/bin/devin", "/opt/homebrew/bin/devin"]) if (isFile(p)) return p return "" } function isFile(p) { try { return statSync(p).isFile() } catch { return false } } // cliCredentialsPath is where the CLI keeps its own sign-in. function cliCredentialsPath() { if (process.platform === "win32" && process.env.APPDATA) return join(process.env.APPDATA, "devin", "credentials.toml") return join(process.env.XDG_DATA_HOME || join(homedir(), ".local", "share"), "devin", "credentials.toml") } const tomlString = (s) => '"' + String(s).replaceAll("\\", "\\\\").replaceAll('"', '\\"') + '"' // credentials is credentials.toml as `devin auth login` writes it. function credentials(key, server, webapp, api) { return [ ["windsurf_api_key", key], ["api_server_url", server || SERVER], ["devin_webapp_host", webapp || "app.devin.ai"], ["devin_api_url", api || "https://api.devin.ai"], ] .map(([k, v]) => `${k} = ${tomlString(v)}\n`) .join("") } // readCredentials reads the keys of a credentials.toml the CLI wrote. function readCredentials(text) { const out = {} for (const line of text.split(/\r?\n/)) { const m = /^\s*([A-Za-z0-9_]+)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|'([^']*)')\s*$/.exec(line) if (m) out[m[1]] = m[2] !== undefined ? m[2].replace(/\\(.)/g, "$1") : m[3] } return out } // homeFor is a data folder of this plugin's own, laid out as the CLI's, // with the account's credentials in it: the CLI run with it as its data // folder answers for that account, and its own sign-in is never touched. async function homeFor(key, server) { const base = join(process.env.XDG_CACHE_HOME || join(homedir(), ".cache"), "opencode-devin-auth") const home = join(base, createHash("sha256").update(key).digest("hex").slice(0, 16)) const file = join(home, "devin", "credentials.toml") if (!existsSync(file)) { await mkdir(join(home, "devin"), { recursive: true, mode: 0o700 }) await writeFile(file, credentials(key, server), { mode: 0o600 }) } return home } // runCLI runs the devin CLI, for the account in home ("" for its own), // with its output; it asks Devin's servers, so it has 30 seconds. function runCLI(home, ...args) { const path = cliPath() if (!path) return Promise.reject(new Error("devin is not installed")) const env = { ...process.env } if (home) { for (const k of Object.keys(env)) if (["XDG_DATA_HOME", "APPDATA"].includes(k.toUpperCase())) delete env[k] env.XDG_DATA_HOME = home env.APPDATA = home } return new Promise((resolve, reject) => { const p = spawn(path, args, { env, stdio: ["ignore", "pipe", "ignore"] }) let out = "" p.stdout.on("data", (b) => (out += b)) const timer = setTimeout(() => p.kill(), 30_000) p.on("error", (e) => { clearTimeout(timer) reject(e) }) p.on("close", (code) => { clearTimeout(timer) resolve({ out, code }) }) }) } // signedOut says the CLI's report is one of nobody signed in: it says so, // or Devin's servers refused the account's token. const signedOut = (out) => ["Not logged in", "Authentication required", "Invalid token", "try logging out and logging in again"].some((s) => out.includes(s)) // parseStatus reads `devin auth status`'s report: its User's Email (or // Name), its Account's Tier (or Plan). function parseStatus(out) { if (!out.includes("Logged in")) return null const field = (key) => { for (const l of out.split("\n")) { const t = l.trim() if (t.startsWith(key + ":")) return t.slice(key.length + 1).trim() } return "" } return { user: field("Email") || field("Name"), plan: field("Tier") || field("Plan") } } // identity is who the CLI says is signed in in home: {user, plan}, null // when it says nobody is, undefined when it can't tell (no CLI, no answer). async function identity(home) { try { const { out } = await runCLI(home, "auth", "status") const st = parseStatus(out) if (st?.user) return st if (signedOut(out)) return null } catch {} return undefined } // Each account's model list as the CLI last gave it, kept FRESH; one past // its time is served while it is read again, one that failed is asked // again after RETRY. const lists = new Map() async function familiesFor(key, server, wait = true) { let c = lists.get(key) if (!c) lists.set(key, (c = { families: null, at: 0, failed: 0, asking: null })) const ask = () => (c.asking ??= (async () => { try { const { out } = await runCLI(await homeFor(key, server), "models", "list", "--format", "json") const fams = parseFamilies(out) if (!fams.length) throw new Error("devin models list: no models") Object.assign(c, { families: fams, at: Date.now(), failed: 0 }) } catch { c.failed = Date.now() } finally { c.asking = null } })()) if (c.families) { if (Date.now() - c.at >= FRESH && Date.now() - c.failed >= RETRY && cliPath()) ask() return c.families } if (cliPath() && Date.now() - c.failed >= RETRY) { const p = ask() if (wait) await p } return c.families ?? familiesOf(SNAPSHOT) } // ---- signing in ---------------------------------------------------------------------- function page(ok, title, text) { const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]) return `
${esc(text)}