From a85751209ce9eb002f95436e216cf1051c04d123 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 6 Aug 2026 20:19:50 -0400 Subject: [PATCH 001/795] feat(catalog): define ClinePass wire contracts --- packages/catalog/src/cline-pass-model-id.ts | 11 +++++++++++ packages/catalog/src/types.ts | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 packages/catalog/src/cline-pass-model-id.ts diff --git a/packages/catalog/src/cline-pass-model-id.ts b/packages/catalog/src/cline-pass-model-id.ts new file mode 100644 index 000000000000..394bef88f52b --- /dev/null +++ b/packages/catalog/src/cline-pass-model-id.ts @@ -0,0 +1,11 @@ +const CLINEPASS_WIRE_PREFIX = "cline-pass/"; + +/** Convert a public ClinePass catalog id to the gateway's wire id. */ +export function toClinePassWireModelId(modelId: string): string { + return modelId.startsWith(CLINEPASS_WIRE_PREFIX) ? modelId : `${CLINEPASS_WIRE_PREFIX}${modelId}`; +} + +/** Convert a gateway ClinePass wire id to the public catalog id. */ +export function toClinePassPublicModelId(modelId: string): string { + return modelId.startsWith(CLINEPASS_WIRE_PREFIX) ? modelId.slice(CLINEPASS_WIRE_PREFIX.length) : modelId; +} diff --git a/packages/catalog/src/types.ts b/packages/catalog/src/types.ts index 4e289759e666..ea8edee92831 100644 --- a/packages/catalog/src/types.ts +++ b/packages/catalog/src/types.ts @@ -155,6 +155,7 @@ export type OpenAIReasoningFormat = "openai" | "openrouter" | "zai" | "kimi" | " export type OpenAIReasoningDisableMode = | "omit" | "lowest-effort" + | "reasoning-effort-none" | "openrouter-enabled-false" | "zai-thinking-disabled" | "qwen-enable-thinking-false" @@ -618,7 +619,7 @@ export interface ResolvedOpenAISharedCompat { enableGeminiThinkingLoopGuard?: boolean; openRouterRouting?: OpenAICompat["openRouterRouting"]; /** Provider-specific wire model-id transform applied to the base id. */ - wireModelIdMode: "raw" | "firepass" | "fireworks" | "openrouter"; + wireModelIdMode: "raw" | "cline-pass" | "firepass" | "fireworks" | "openrouter"; /** See {@link OpenAICompat.toolSchemaFlavor}. Read by both wire paths when converting tools. */ toolSchemaFlavor?: OpenAICompat["toolSchemaFlavor"]; } From f28aa54f7fc5ccb3ceea96d2ce12c5870a9b03ec Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 6 Aug 2026 20:19:58 -0400 Subject: [PATCH 002/795] feat(catalog): add live ClinePass model discovery --- .../catalog/scripts/generated-policies.ts | 1 + packages/catalog/src/compat/openai.ts | 52 +- packages/catalog/src/model-thinking.ts | 3 +- packages/catalog/src/models.json | 491 ++++++++++++++++++ .../src/provider-models/descriptors.ts | 10 + .../src/provider-models/openai-compat.ts | 113 ++++ .../catalog/test/cline-pass-compat.test.ts | 126 +++++ 7 files changed, 777 insertions(+), 19 deletions(-) create mode 100644 packages/catalog/test/cline-pass-compat.test.ts diff --git a/packages/catalog/scripts/generated-policies.ts b/packages/catalog/scripts/generated-policies.ts index b68004971cef..b98408a92f06 100644 --- a/packages/catalog/scripts/generated-policies.ts +++ b/packages/catalog/scripts/generated-policies.ts @@ -173,6 +173,7 @@ export function applyGeneratedModelPolicies(models: ModelSpec[]): void { export function rebakeModelThinking(model: ModelSpec): void { if (isVariantCollapsedSpec(model)) return; if (model.provider === "alibaba-token-plan" && model.id === "qwen3.8-max-preview" && model.thinking) return; + if (model.provider === "cline-pass" && model.thinking) return; const requiresProviderAuthoredEffort = model.provider === "umans" && (model.thinking?.requiresEffort === true || model.id === "umans-kimi-k2.7"); const thinking = resolveModelThinking({ ...model, thinking: undefined }, buildCompat(model)); diff --git a/packages/catalog/src/compat/openai.ts b/packages/catalog/src/compat/openai.ts index c7f97b4e186f..31fcac4dcae1 100644 --- a/packages/catalog/src/compat/openai.ts +++ b/packages/catalog/src/compat/openai.ts @@ -173,6 +173,15 @@ const KIMI_K3_REASONING_EFFORT_MAP: NonNullable = { + minimal: "none", + low: "low", + medium: "medium", + high: "high", + xhigh: "xhigh", + max: "max", +}; + const MIMO_REASONING_EFFORT_MAP: NonNullable = { minimal: "low", xhigh: "high", @@ -435,16 +444,20 @@ export function buildOpenAICompat(spec: ModelSpec<"openai-completions">): Resolv // namespace (`accounts/fireworks/routers/-fast`), like Fire Pass, rather // than the `models/` namespace the rest of the `fireworks` provider uses. const isFireworksFastRouter = provider === "fireworks" && isFireworksFastModelId(spec.id); + const isClinePass = provider === "cline-pass"; const wireModelIdMode: ResolvedOpenAISharedCompat["wireModelIdMode"] = provider === "firepass" || isFireworksFastRouter ? "firepass" : provider === "fireworks" ? "fireworks" - : isOpenRouter - ? "openrouter" - : "raw"; - const thinkingFormat: ResolvedOpenAISharedCompat["thinkingFormat"] = - (isMoonshotKimi && !isMoonshotKimiK3) || isZai || isZhipu || isXiaomiMimo + : isClinePass + ? "cline-pass" + : isOpenRouter + ? "openrouter" + : "raw"; + const thinkingFormat: ResolvedOpenAISharedCompat["thinkingFormat"] = isClinePass + ? "openai" + : (isMoonshotKimi && !isMoonshotKimiK3) || isZai || isZhipu || isXiaomiMimo ? "zai" : isOpenRouter ? "openrouter" @@ -472,7 +485,7 @@ export function buildOpenAICompat(spec: ModelSpec<"openai-completions">): Resolv // OpenAI proprietary reasoning models (o-series, gpt-5+) reject explicit // temperature/top_p/… with a 400 on every serving host (#5606). supportsSamplingParams: !isOpenAISamplingRestrictedModelId(spec.id), - reasoningEffortMap: {}, + reasoningEffortMap: isClinePass ? CLINEPASS_REASONING_EFFORT_MAP : {}, supportsUsageInStreaming: !isCerebras, // pi-ai's thinking-loop guard is gemini-only; default the flag from the // family classifier so OpenAI-compat proxies serving Gemini are covered. @@ -488,9 +501,9 @@ export function buildOpenAICompat(spec: ModelSpec<"openai-completions">): Resolv // Native Kimi K3 always reasons through `reasoning_effort` (never the // K2.x binary `thinking` block that #827's forced-tool-choice conflict is // about), so suppressing its effort would leave K3 in an unsupported mode. - disableReasoningOnForcedToolChoice: (isKimiModel && !isMoonshotKimiK3) || isAnthropicModel, - disableReasoningOnToolChoice: isDeepseekFamily && Boolean(spec.reasoning) && !isOpenRouter, - supportsToolChoice: !isDirectDeepseekReasoning, + disableReasoningOnForcedToolChoice: !isClinePass && ((isKimiModel && !isMoonshotKimiK3) || isAnthropicModel), + disableReasoningOnToolChoice: !isClinePass && isDeepseekFamily && Boolean(spec.reasoning) && !isOpenRouter, + supportsToolChoice: isClinePass || !isDirectDeepseekReasoning, // DeepSeek reasoning models on OpenCode Zen/Go 400 with // "Thinking mode does not support this tool_choice" when a specific // function is forced while the gateway's default thinking mode is active. @@ -513,14 +526,15 @@ export function buildOpenAICompat(spec: ModelSpec<"openai-completions">): Resolv // (issue #2299). thinkingFormat, kimiApiFormat: undefined, - reasoningDisableMode: resolveReasoningDisableMode(thinkingFormat), + reasoningDisableMode: isClinePass ? "reasoning-effort-none" : resolveReasoningDisableMode(thinkingFormat), omitReasoningEffort: false, includeEncryptedReasoning: true, filterReasoningHistory: isOpenRouter && isAnthropicModel, thinkingKeep: usesMoonshotKimiPreservedThinking ? "all" : undefined, - reasoningContentField: "reasoning_content", - // Backends that 400 follow-up requests when prior assistant tool-call turns lack `reasoning_content`: - // - Kimi: documented invariant on its native API. + reasoningContentField: isClinePass ? "reasoning" : "reasoning_content", + // Backends that reject follow-up requests when prior assistant tool-call + // turns lack their reasoning replay field: + // - ClinePass streams `reasoning`; native Kimi uses `reasoning_content`. // - DeepSeek-family reasoning models, including aliased OpenCode Zen models // like `big-pickle`, validate exact thinking-mode replay. // - Xiaomi MiMo models require exact `reasoning_content` replay on @@ -617,11 +631,13 @@ export function buildOpenAICompat(spec: ModelSpec<"openai-completions">): Resolv compat.extraBody = Object.keys(extraBody).length > 0 ? extraBody : undefined; } if (spec.compat?.reasoningDisableMode === undefined) { - compat.reasoningDisableMode = requiresEnabledThinking - ? "omit" - : isDirectDeepseekReasoning - ? "zai-thinking-disabled" - : resolveReasoningDisableMode(compat.thinkingFormat); + compat.reasoningDisableMode = isClinePass + ? "reasoning-effort-none" + : requiresEnabledThinking + ? "omit" + : isDirectDeepseekReasoning + ? "zai-thinking-disabled" + : resolveReasoningDisableMode(compat.thinkingFormat); } if (spec.compat?.omitReasoningEffort === undefined && !compat.supportsReasoningEffort) { compat.omitReasoningEffort = true; diff --git a/packages/catalog/src/model-thinking.ts b/packages/catalog/src/model-thinking.ts index db098106f6b8..505d5f169fc3 100644 --- a/packages/catalog/src/model-thinking.ts +++ b/packages/catalog/src/model-thinking.ts @@ -166,7 +166,8 @@ function fillThinkingWireDefaults( thinking: ThinkingConfig, ): ThinkingConfig { const parsed = parseKnownModel(spec.id); - const normalizedEfforts = getModelDefinedEfforts(spec, compat) ?? thinking.efforts; + const normalizedEfforts = + spec.provider === "cline-pass" ? thinking.efforts : (getModelDefinedEfforts(spec, compat) ?? thinking.efforts); const effortsChanged = !sameEffortList(normalizedEfforts, thinking.efforts); const effortMap = thinking.effortMap === undefined || effortsChanged diff --git a/packages/catalog/src/models.json b/packages/catalog/src/models.json index 99910f6063a9..44452f48202e 100644 --- a/packages/catalog/src/models.json +++ b/packages/catalog/src/models.json @@ -14164,6 +14164,497 @@ } } }, + "cline-pass": { + "deepseek-v4-flash": { + "id": "deepseek-v4-flash", + "name": "DeepSeek V4 Flash", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 384000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "deepseek-v4-pro": { + "id": "deepseek-v4-pro", + "name": "DeepSeek V4 Pro", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 384000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "glm-5.2": { + "id": "glm-5.2", + "name": "GLM-5.2", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 131072, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "kimi-k2.6": { + "id": "kimi-k2.6", + "name": "Kimi K2.6", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 262144, + "maxTokens": 262144, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "kimi-k2.7-code": { + "id": "kimi-k2.7-code", + "name": "Kimi K2.7 Code", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 262144, + "maxTokens": 262144, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "kimi-k3": { + "id": "kimi-k3", + "name": "Kimi K3", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 131072, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + }, + "defaultLevel": "max", + "requiresEffort": true + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "mimo-v2.5": { + "id": "mimo-v2.5", + "name": "MiMo-V2.5", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 131072, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "mimo-v2.5-pro": { + "id": "mimo-v2.5-pro", + "name": "MiMo-V2.5-Pro", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 131072, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "minimax-m3": { + "id": "minimax-m3", + "name": "MiniMax-M3", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 512000, + "maxTokens": 128000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "qwen3.7-max": { + "id": "qwen3.7-max", + "name": "Qwen3.7 Max", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 65536, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "qwen3.7-plus": { + "id": "qwen3.7-plus", + "name": "Qwen3.7 Plus", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "qwen3.8-max": { + "id": "qwen3.8-max", + "name": "Qwen3.8 Max", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 128000, + "maxTokens": 8192, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + } + }, "cloudflare-ai-gateway": { "anthropic/claude-3-5-haiku": { "id": "anthropic/claude-3-5-haiku", diff --git a/packages/catalog/src/provider-models/descriptors.ts b/packages/catalog/src/provider-models/descriptors.ts index 20af095aa43e..e8e6fcd33a50 100644 --- a/packages/catalog/src/provider-models/descriptors.ts +++ b/packages/catalog/src/provider-models/descriptors.ts @@ -17,6 +17,7 @@ import { basetenModelManagerOptions, bedrockMantleModelManagerOptions, cerebrasModelManagerOptions, + clinePassModelManagerOptions, cloudflareAiGatewayModelManagerOptions, coreWeaveModelManagerOptions, deepseekModelManagerOptions, @@ -165,6 +166,15 @@ export const CATALOG_PROVIDERS = [ dynamicModelsAuthoritative: true, catalogDiscovery: { label: "Devin", envVars: ["DEVIN_API_KEY"], oauthProvider: "devin" }, }, + { + id: "cline-pass", + defaultModel: "kimi-k3", + envVars: ["CLINE_API_KEY"], + createModelManagerOptions: (config: ModelManagerConfig) => clinePassModelManagerOptions(config), + allowUnauthenticated: true, + dynamicModelsAuthoritative: true, + catalogDiscovery: { label: "ClinePass", allowUnauthenticated: true }, + }, { id: "firepass", defaultModel: "kimi-k2.6-turbo", diff --git a/packages/catalog/src/provider-models/openai-compat.ts b/packages/catalog/src/provider-models/openai-compat.ts index d6a948bdaf49..76f7bdd05f8d 100644 --- a/packages/catalog/src/provider-models/openai-compat.ts +++ b/packages/catalog/src/provider-models/openai-compat.ts @@ -1,5 +1,6 @@ import { VERSION } from "@oh-my-pi/pi-utils"; import * as logger from "@oh-my-pi/pi-utils/logger"; +import { toClinePassPublicModelId } from "../cline-pass-model-id"; import { fetchOpenAICompatibleModels, type OpenAICompatibleModelMapperContext, @@ -65,6 +66,7 @@ export interface ModelsDevModel { name?: string; tool_call?: boolean; reasoning?: boolean; + reasoning_options?: Array<{ type?: string; values?: string[] }>; limit?: { context?: number; output?: number; @@ -2145,6 +2147,72 @@ export function firepassModelManagerOptions( }; } +const CLINEPASS_API_BASE_URL = "https://api.cline.bot/api/v1"; +const CLINEPASS_MODELS_URL = "https://api.cline.bot/api/v1/ai/cline/recommended-models"; +const CLINEPASS_FALLBACK_CONTEXT_WINDOW = 128_000; +const CLINEPASS_FALLBACK_MAX_TOKENS = 8_192; + +function buildClinePassFallbackModel(id: string): ModelSpec<"openai-completions"> { + return { + id, + name: id, + api: "openai-completions", + provider: "cline-pass", + baseUrl: CLINEPASS_API_BASE_URL, + reasoning: true, + input: ["text"], + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + contextWindow: CLINEPASS_FALLBACK_CONTEXT_WINDOW, + maxTokens: CLINEPASS_FALLBACK_MAX_TOKENS, + thinking: buildClinePassThinking({}), + }; +} + +async function fetchClinePassModels( + fetchImpl: FetchImpl, + references: ReadonlyMap>, +): Promise[]> { + const response = await withCatalogDiscoveryTimeout(5_000, signal => fetchImpl(CLINEPASS_MODELS_URL, { signal })); + if (!response.ok) { + throw new Error(`Failed to fetch ClinePass models: HTTP ${response.status}`); + } + const payload: unknown = await response.json(); + if (!isRecord(payload) || !Array.isArray(payload.clinePass)) { + throw new Error("ClinePass model catalog response is missing clinePass"); + } + + const models = new Map>(); + for (const entry of payload.clinePass) { + if (!isRecord(entry) || typeof entry.id !== "string" || !entry.id.startsWith("cline-pass/")) { + continue; + } + const id = toClinePassPublicModelId(entry.id); + models.set(id, references.get(id) ?? buildClinePassFallbackModel(id)); + } + if (models.size === 0) { + throw new Error("ClinePass model catalog contains no valid model IDs"); + } + return [...models.values()]; +} + +/** + * Cline's OpenAI-compatible `/models` route is absent, but its public + * recommended-models endpoint is the authoritative ClinePass roster. Bundled + * metadata enriches known ids; conservative defaults keep newly added ids + * usable immediately and the bundled catalog remains the offline fallback. + */ +export function clinePassModelManagerOptions(config?: ModelManagerConfig): ModelManagerOptions<"openai-completions"> { + const references = new Map( + (getBundledModels("cline-pass") as Model<"openai-completions">[]).map(model => [model.id, toModelSpec(model)]), + ); + const fetchImpl = discoveryFetch(config?.fetch); + return { + providerId: "cline-pass", + dynamicModelsAuthoritative: true, + fetchDynamicModels: () => fetchClinePassModels(fetchImpl, references), + }; +} + // --------------------------------------------------------------------------- // 7.7 Wafer Serverless // --------------------------------------------------------------------------- @@ -5635,6 +5703,40 @@ const MODELS_DEV_PROVIDER_DESCRIPTORS_BEDROCK: readonly ModelsDevProviderDescrip }, ]; +const CLINEPASS_DEFAULT_EFFORTS: readonly Effort[] = [ + Effort.Minimal, + Effort.Low, + Effort.Medium, + Effort.High, + Effort.XHigh, + Effort.Max, +]; + +const CLINEPASS_WIRE_EFFORT: Readonly> = { + [Effort.Minimal]: "none", + [Effort.Low]: "low", + [Effort.Medium]: "medium", + [Effort.High]: "high", + [Effort.XHigh]: "xhigh", + [Effort.Max]: "max", +}; + +function resolveClinePassEfforts(raw: ModelsDevModel): Effort[] { + const wireValues = raw.reasoning_options?.find(option => option.type === "effort")?.values; + if (!wireValues) return [...CLINEPASS_DEFAULT_EFFORTS]; + const efforts = CLINEPASS_DEFAULT_EFFORTS.filter(effort => wireValues.includes(CLINEPASS_WIRE_EFFORT[effort])); + return efforts.length > 0 ? efforts : [...CLINEPASS_DEFAULT_EFFORTS]; +} + +function buildClinePassThinking(raw: ModelsDevModel): ThinkingConfig { + const efforts = resolveClinePassEfforts(raw); + return { + mode: "effort", + efforts, + effortMap: Object.fromEntries(efforts.map(effort => [effort, CLINEPASS_WIRE_EFFORT[effort]])), + }; +} + const MODELS_DEV_PROVIDER_DESCRIPTORS_CORE: readonly ModelsDevProviderDescriptor[] = [ // --- Anthropic --- anthropicMessagesDescriptor("anthropic", "anthropic", "https://api.anthropic.com", { @@ -5663,6 +5765,17 @@ const MODELS_DEV_PROVIDER_DESCRIPTORS_CORE: readonly ModelsDevProviderDescriptor openAiCompletionsDescriptor("groq", "groq", "https://api.groq.com/openai/v1"), // --- Cerebras --- openAiCompletionsDescriptor("cerebras", "cerebras", "https://api.cerebras.ai/v1"), + // --- ClinePass --- + openAiCompletionsDescriptor("cline-pass", "cline-pass", "https://api.cline.bot/api/v1", { + transformModel: (model, modelId, raw) => ({ + ...model, + id: toClinePassPublicModelId(modelId), + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + ...(model.reasoning && { + thinking: buildClinePassThinking(raw), + }), + }), + }), // --- Together --- openAiCompletionsDescriptor("togetherai", "together", "https://api.together.xyz/v1"), // --- CoreWeave Serverless Inference --- diff --git a/packages/catalog/test/cline-pass-compat.test.ts b/packages/catalog/test/cline-pass-compat.test.ts new file mode 100644 index 000000000000..8b17d189a67f --- /dev/null +++ b/packages/catalog/test/cline-pass-compat.test.ts @@ -0,0 +1,126 @@ +import { describe, expect, it } from "bun:test"; +import { toClinePassPublicModelId, toClinePassWireModelId } from "@oh-my-pi/pi-catalog/cline-pass-model-id"; +import { buildOpenAICompat } from "@oh-my-pi/pi-catalog/compat/openai"; +import { Effort } from "@oh-my-pi/pi-catalog/effort"; +import { getBundledModel, getBundledModels } from "@oh-my-pi/pi-catalog/models"; +import { DEFAULT_MODEL_PER_PROVIDER } from "@oh-my-pi/pi-catalog/provider-models"; +import { toModelSpec } from "@oh-my-pi/pi-catalog/provider-models/bundled-references"; +import { clinePassModelManagerOptions } from "@oh-my-pi/pi-catalog/provider-models/openai-compat"; + +describe("ClinePass catalog", () => { + it("bundles an offline subscription fallback under stable public IDs", () => { + const models = getBundledModels("cline-pass"); + + expect(models.map(model => model.id)).toEqual([ + "deepseek-v4-flash", + "deepseek-v4-pro", + "glm-5.2", + "kimi-k2.6", + "kimi-k2.7-code", + "kimi-k3", + "mimo-v2.5", + "mimo-v2.5-pro", + "minimax-m3", + "qwen3.7-max", + "qwen3.7-plus", + "qwen3.8-max", + ]); + expect(DEFAULT_MODEL_PER_PROVIDER["cline-pass"]).toBe("kimi-k3"); + expect(models.every(model => model.cost.input === 0 && model.cost.output === 0)).toBe(true); + }); + + it("preserves Cline's full reasoning ladder and published Kimi K3 limits", () => { + const model = getBundledModel<"openai-completions">("cline-pass", "kimi-k3"); + + expect(model.contextWindow).toBe(1_048_576); + expect(model.maxTokens).toBe(131_072); + expect(model.input).toEqual(["text", "image"]); + expect(model.thinking?.mode).toBe("effort"); + expect(model.thinking?.efforts).toEqual([ + Effort.Minimal, + Effort.Low, + Effort.Medium, + Effort.High, + Effort.XHigh, + Effort.Max, + ]); + expect(model.thinking?.defaultLevel).toBe(Effort.Max); + }); + + it("uses the Cline wire namespace without exposing it in model selection", () => { + expect(toClinePassPublicModelId("cline-pass/kimi-k3")).toBe("kimi-k3"); + expect(toClinePassPublicModelId("kimi-k3")).toBe("kimi-k3"); + expect(toClinePassWireModelId("kimi-k3")).toBe("cline-pass/kimi-k3"); + expect(toClinePassWireModelId("cline-pass/kimi-k3")).toBe("cline-pass/kimi-k3"); + }); + + it("applies the verified Cline gateway request and reasoning compatibility", () => { + const model = getBundledModel<"openai-completions">("cline-pass", "kimi-k3"); + const compat = buildOpenAICompat(toModelSpec(model)); + + expect(compat.wireModelIdMode).toBe("cline-pass"); + expect(compat.maxTokensField).toBe("max_completion_tokens"); + expect(compat.thinkingFormat).toBe("openai"); + expect(compat.reasoningDisableMode).toBe("reasoning-effort-none"); + expect(compat.reasoningEffortMap).toEqual({ + minimal: "none", + low: "low", + medium: "medium", + high: "high", + xhigh: "xhigh", + max: "max", + }); + expect(compat.reasoningContentField).toBe("reasoning"); + expect(compat.requiresReasoningContentForToolCalls).toBe(true); + expect(compat.supportsDeveloperRole).toBe(false); + expect(compat.supportsStore).toBe(true); + expect(compat.disableReasoningOnForcedToolChoice).toBe(false); + }); + + it("discovers the authoritative roster without credentials and supports new model IDs", async () => { + const requests: string[] = []; + const options = clinePassModelManagerOptions({ + fetch: async input => { + requests.push(String(input)); + return new Response( + JSON.stringify({ + clinePass: [ + { id: "cline-pass/kimi-k3", name: "cline-pass/kimi-k3" }, + { id: "cline-pass/future-model", name: "cline-pass/future-model" }, + ], + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ); + }, + }); + + expect(options.providerId).toBe("cline-pass"); + expect(options.dynamicModelsAuthoritative).toBe(true); + expect(options.fetchDynamicModels).toBeFunction(); + + const models = await options.fetchDynamicModels?.(); + expect(requests).toEqual(["https://api.cline.bot/api/v1/ai/cline/recommended-models"]); + expect(models?.map(model => model.id)).toEqual(["kimi-k3", "future-model"]); + expect(models?.[0]?.maxTokens).toBe(131_072); + expect(models?.[1]).toMatchObject({ + id: "future-model", + provider: "cline-pass", + contextWindow: 128_000, + maxTokens: 8_192, + reasoning: true, + thinking: { mode: "effort" }, + }); + }); + + it("rejects an empty authoritative roster so the bundled fallback remains available", async () => { + const options = clinePassModelManagerOptions({ + fetch: async () => + new Response(JSON.stringify({ clinePass: [] }), { + status: 200, + headers: { "Content-Type": "application/json" }, + }), + }); + + await expect(options.fetchDynamicModels?.()).rejects.toThrow("contains no valid model IDs"); + }); +}); From 5ec3a2cf9aaa21f09c889aaf3d803a6e72bf66c1 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 6 Aug 2026 20:20:06 -0400 Subject: [PATCH 003/795] feat(ai): add ClinePass API-key login --- packages/ai/src/registry/api-key-login.ts | 4 +++ .../ai/src/registry/api-key-validation.ts | 4 ++- packages/ai/src/registry/cline-pass.ts | 25 +++++++++++++ packages/ai/src/registry/registry.ts | 2 ++ packages/ai/test/cline-pass-login.test.ts | 35 +++++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 packages/ai/src/registry/cline-pass.ts create mode 100644 packages/ai/test/cline-pass-login.test.ts diff --git a/packages/ai/src/registry/api-key-login.ts b/packages/ai/src/registry/api-key-login.ts index f202eab632f9..0a3574e40b20 100644 --- a/packages/ai/src/registry/api-key-login.ts +++ b/packages/ai/src/registry/api-key-login.ts @@ -19,6 +19,8 @@ type ChatCompletionsValidation = { provider: string; baseUrl: string; model: string; + maxTokensField?: "max_tokens" | "max_completion_tokens"; + maxTokens?: number; }; type AnthropicMessagesValidation = { @@ -83,6 +85,8 @@ export function createApiKeyLogin(config: ApiKeyLoginConfig): (options: OAuthCon apiKey: trimmed, baseUrl: config.validation.baseUrl, model: config.validation.model, + maxTokensField: config.validation.maxTokensField, + maxTokens: config.validation.maxTokens, signal: options.signal, fetch: options.fetch, }); diff --git a/packages/ai/src/registry/api-key-validation.ts b/packages/ai/src/registry/api-key-validation.ts index e858cba608a1..7341e02a7f5b 100644 --- a/packages/ai/src/registry/api-key-validation.ts +++ b/packages/ai/src/registry/api-key-validation.ts @@ -6,6 +6,8 @@ type OpenAICompatibleValidationOptions = { apiKey: string; baseUrl: string; model: string; + maxTokensField?: "max_tokens" | "max_completion_tokens"; + maxTokens?: number; signal?: AbortSignal; fetch?: FetchImpl; }; @@ -73,7 +75,7 @@ export async function validateOpenAICompatibleApiKey(options: OpenAICompatibleVa body: JSON.stringify({ model: options.model, messages: [{ role: "user", content: "ping" }], - max_tokens: 1, + [options.maxTokensField ?? "max_tokens"]: options.maxTokens ?? 1, temperature: 0, }), signal, diff --git a/packages/ai/src/registry/cline-pass.ts b/packages/ai/src/registry/cline-pass.ts new file mode 100644 index 000000000000..ff167210d527 --- /dev/null +++ b/packages/ai/src/registry/cline-pass.ts @@ -0,0 +1,25 @@ +import { createApiKeyLogin } from "./api-key-login"; +import type { OAuthLoginCallbacks } from "./oauth/types"; +import type { ProviderDefinition } from "./types"; + +export const loginClinePass = createApiKeyLogin({ + providerLabel: "ClinePass", + authUrl: "https://app.cline.bot/dashboard/account", + instructions: "Create an API key in the Cline dashboard under Settings → API Keys", + promptMessage: "Paste your Cline API key", + placeholder: "sk_...", + validation: { + kind: "chat-completions", + provider: "ClinePass", + baseUrl: "https://api.cline.bot/api/v1", + model: "cline-pass/kimi-k3", + maxTokensField: "max_completion_tokens", + maxTokens: 16, + }, +}); + +export const clinePassProvider = { + id: "cline-pass", + name: "ClinePass", + login: (callbacks: OAuthLoginCallbacks) => loginClinePass(callbacks), +} as const satisfies ProviderDefinition; diff --git a/packages/ai/src/registry/registry.ts b/packages/ai/src/registry/registry.ts index ce70e33ca5f0..3d1d5746cf2e 100644 --- a/packages/ai/src/registry/registry.ts +++ b/packages/ai/src/registry/registry.ts @@ -9,6 +9,7 @@ import { azureProvider } from "./azure"; import { basetenProvider } from "./baseten"; import { bedrockMantleProvider } from "./bedrock-mantle"; import { cerebrasProvider } from "./cerebras"; +import { clinePassProvider } from "./cline-pass"; import { cloudflareAiGatewayProvider } from "./cloudflare-ai-gateway"; import { coreWeaveProvider } from "./coreweave"; import { cursorProvider } from "./cursor"; @@ -116,6 +117,7 @@ const ALL = [ xiaomiTokenPlanAmsProvider, xiaomiTokenPlanCnProvider, firepassProvider, + clinePassProvider, deepseekProvider, metaProvider, moonshotProvider, diff --git a/packages/ai/test/cline-pass-login.test.ts b/packages/ai/test/cline-pass-login.test.ts new file mode 100644 index 000000000000..8823e32dc8a4 --- /dev/null +++ b/packages/ai/test/cline-pass-login.test.ts @@ -0,0 +1,35 @@ +import { describe, expect, it } from "bun:test"; +import { loginClinePass } from "@oh-my-pi/pi-ai/registry/cline-pass"; +import type { FetchImpl } from "@oh-my-pi/pi-ai/types"; + +describe("ClinePass login", () => { + it("opens the dashboard and validates the API key against the subscription chat route", async () => { + const authUrls: string[] = []; + let authorization = ""; + let requestUrl = ""; + let requestBody: Record = {}; + const fetchMock: FetchImpl = async (input, init) => { + requestUrl = String(input); + authorization = String((init?.headers as Record | undefined)?.Authorization); + requestBody = JSON.parse(String(init?.body)) as Record; + return Response.json({ choices: [] }); + }; + + const result = await loginClinePass({ + onAuth: info => authUrls.push(info.url), + onPrompt: async () => " sk_test ", + fetch: fetchMock, + }); + + expect(result).toBe("sk_test"); + expect(authUrls).toEqual(["https://app.cline.bot/dashboard/account"]); + expect(requestUrl).toBe("https://api.cline.bot/api/v1/chat/completions"); + expect(authorization).toBe("Bearer sk_test"); + expect(requestBody).toEqual({ + model: "cline-pass/kimi-k3", + messages: [{ role: "user", content: "ping" }], + max_completion_tokens: 16, + temperature: 0, + }); + }); +}); From 73b3739546967a39ff792d47dbb2e1bc516108c7 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 6 Aug 2026 20:20:13 -0400 Subject: [PATCH 004/795] feat(ai): preserve ClinePass inference semantics --- packages/ai/src/providers/openai-shared.ts | 15 ++- packages/ai/test/cline-pass-transport.test.ts | 94 +++++++++++++++++++ 2 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 packages/ai/test/cline-pass-transport.test.ts diff --git a/packages/ai/src/providers/openai-shared.ts b/packages/ai/src/providers/openai-shared.ts index b964e5643040..a3118aad53ad 100644 --- a/packages/ai/src/providers/openai-shared.ts +++ b/packages/ai/src/providers/openai-shared.ts @@ -1,3 +1,4 @@ +import { toClinePassWireModelId } from "@oh-my-pi/pi-catalog/cline-pass-model-id"; import type { Effort } from "@oh-my-pi/pi-catalog/effort"; import { toFirepassWireModelId, toFireworksWireModelId } from "@oh-my-pi/pi-catalog/fireworks-model-id"; import { isGlm52ReasoningEffortModelId, isKimiK3ModelId } from "@oh-my-pi/pi-catalog/identity"; @@ -552,6 +553,8 @@ export function applyWireModelIdTransform( openrouterVariant?: string, ): string { switch (mode) { + case "cline-pass": + return toClinePassWireModelId(baseId); case "firepass": return toFirepassWireModelId(baseId); case "fireworks": @@ -954,6 +957,9 @@ function encodeChatCompletionsDisabledReasoning( ): void { delete params.reasoning_effort; switch (disableMode) { + case "reasoning-effort-none": + params.reasoning_effort = "none"; + break; case "zai-thinking-disabled": params.thinking = { type: "disabled" }; break; @@ -1117,14 +1123,17 @@ function isZaiReasoningEffortDialect(model: Model<"openai-completions">, compat: * Provider-specific Chat Completions output clamp. * * Most OpenAI-compatible endpoints retain the conservative 64k ceiling from - * {@link resolveOpenAIOutputTokenParam}. Z.AI/GLM-5.2 reasoning and native - * Moonshot K3 explicitly accept their full advertised model caps, so those - * routes clamp to `model.maxTokens` instead. + * {@link resolveOpenAIOutputTokenParam}. ClinePass, Z.AI/GLM-5.2 reasoning, + * and native Moonshot K3 explicitly accept their full advertised model caps, + * so those routes clamp to `model.maxTokens` instead. */ export function resolveOpenAICompletionsOutputClamp( model: Model<"openai-completions">, compat: ResolvedOpenAICompat, ): number | undefined { + if (model.provider === "cline-pass") { + return model.maxTokens ?? OPENAI_MAX_OUTPUT_TOKENS; + } if (isZaiReasoningEffortDialect(model, compat)) { return model.maxTokens ?? OPENAI_MAX_OUTPUT_TOKENS; } diff --git a/packages/ai/test/cline-pass-transport.test.ts b/packages/ai/test/cline-pass-transport.test.ts new file mode 100644 index 000000000000..5daed14af3c5 --- /dev/null +++ b/packages/ai/test/cline-pass-transport.test.ts @@ -0,0 +1,94 @@ +import { describe, expect, it } from "bun:test"; +import { streamOpenAICompletions } from "@oh-my-pi/pi-ai/providers/openai-completions"; +import type { Context, FetchImpl, Model, Tool } from "@oh-my-pi/pi-ai/types"; +import { Effort } from "@oh-my-pi/pi-catalog/effort"; +import { getBundledModel } from "@oh-my-pi/pi-catalog/models"; + +const markerTool: Tool = { + name: "get_marker", + description: "Return a marker", + parameters: { + type: "object", + properties: { value: { type: "number" } }, + required: ["value"], + } as Tool["parameters"], +}; + +const context: Context = { + systemPrompt: ["Use the provided tool."], + messages: [{ role: "user", content: "Get marker 42", timestamp: 0 }], + tools: [markerTool], +}; + +function completionResponse(model: string): Response { + const events = [ + { + id: "cline-pass-test", + object: "chat.completion.chunk", + created: 0, + model, + choices: [{ index: 0, delta: { content: "ok" } }], + }, + { + id: "cline-pass-test", + object: "chat.completion.chunk", + created: 0, + model, + choices: [{ index: 0, delta: {}, finish_reason: "stop" }], + }, + "[DONE]", + ]; + return new Response( + `${events.map(event => `data: ${typeof event === "string" ? event : JSON.stringify(event)}`).join("\n\n")}\n\n`, + { headers: { "content-type": "text/event-stream" } }, + ); +} + +async function capturePayload(options: { + reasoning?: Effort; + disableReasoning?: boolean; + toolChoice?: { type: "tool"; name: string }; +}): Promise> { + const model = getBundledModel<"openai-completions">("cline-pass", "kimi-k3") as Model<"openai-completions">; + let payload: Record | undefined; + const fetchMock: FetchImpl = Object.assign( + async (_input: string | URL | Request, init?: RequestInit): Promise => { + payload = JSON.parse(typeof init?.body === "string" ? init.body : "{}") as Record; + return completionResponse(model.id); + }, + { preconnect: fetch.preconnect }, + ); + await streamOpenAICompletions(model, context, { + apiKey: "test-key", + fetch: fetchMock, + maxTokens: 64, + reasoning: options.reasoning, + disableReasoning: options.disableReasoning, + toolChoice: options.toolChoice, + }).result(); + if (!payload) throw new Error("Expected ClinePass request payload"); + return payload; +} + +describe("ClinePass OpenAI transport", () => { + it("sends Cline's wire model ID, token field, max effort, and forced tool choice", async () => { + const payload = await capturePayload({ + reasoning: Effort.Max, + toolChoice: { type: "tool", name: "get_marker" }, + }); + + expect(payload.model).toBe("cline-pass/kimi-k3"); + expect(payload.max_completion_tokens).toBe(64); + expect(payload.max_tokens).toBeUndefined(); + expect(payload.reasoning_effort).toBe("max"); + expect(payload.thinking).toBeUndefined(); + expect(payload.tool_choice).toEqual({ type: "function", function: { name: "get_marker" } }); + }); + + it("disables ClinePass reasoning with the gateway's none effort", async () => { + const payload = await capturePayload({ disableReasoning: true }); + + expect(payload.reasoning_effort).toBe("none"); + expect(payload.model).toBe("cline-pass/kimi-k3"); + }); +}); From 74f63234cd519017f2de3e145f734e6d01a317e3 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 6 Aug 2026 20:20:22 -0400 Subject: [PATCH 005/795] feat(ai): report ClinePass quota usage --- packages/ai/src/auth-storage.ts | 2 + packages/ai/src/usage/cline-pass.ts | 165 ++++++++++++++++++++++ packages/ai/test/cline-pass-usage.test.ts | 146 +++++++++++++++++++ 3 files changed, 313 insertions(+) create mode 100644 packages/ai/src/usage/cline-pass.ts create mode 100644 packages/ai/test/cline-pass-usage.test.ts diff --git a/packages/ai/src/auth-storage.ts b/packages/ai/src/auth-storage.ts index 9344aefc4803..229ef77abca8 100644 --- a/packages/ai/src/auth-storage.ts +++ b/packages/ai/src/auth-storage.ts @@ -51,6 +51,7 @@ import type { import { resolveUsedFraction } from "./usage"; import { alibabaTokenPlanRankingStrategy, alibabaTokenPlanUsageProvider } from "./usage/alibaba-token-plan"; import { claudeRankingStrategy, claudeUsageProvider } from "./usage/claude"; +import { clinePassUsageProvider } from "./usage/cline-pass"; import { cursorUsageProvider } from "./usage/cursor"; import { googleGeminiCliUsageProvider } from "./usage/gemini"; import { githubCopilotUsageProvider } from "./usage/github-copilot"; @@ -669,6 +670,7 @@ const DEFAULT_USAGE_PROVIDERS: UsageProvider[] = [ ollamaUsageProvider, ollamaCloudUsageProvider, claudeUsageProvider, + clinePassUsageProvider, zaiUsageProvider, umansUsageProvider, opencodeGoUsageProvider, diff --git a/packages/ai/src/usage/cline-pass.ts b/packages/ai/src/usage/cline-pass.ts new file mode 100644 index 000000000000..bbd4492e9957 --- /dev/null +++ b/packages/ai/src/usage/cline-pass.ts @@ -0,0 +1,165 @@ +import { ProviderHttpError } from "../error"; +import type { + UsageFetchContext, + UsageFetchParams, + UsageLimit, + UsageProvider, + UsageReport, + UsageStatus, +} from "../usage"; +import { isRecord } from "../utils"; + +const PROVIDER = "cline-pass"; +const DEFAULT_BASE_URL = "https://api.cline.bot/api/v1"; +// Dashboard quota route. It accepts the same API key as inference; account OAuth is not required. +const USAGE_LIMITS_PATH = "/users/me/plan/usage-limits"; +const ACCOUNT_PATH = "/users/me"; + +const WINDOW_CONFIG = { + five_hour: { id: "5h", label: "5 Hour", durationMs: 5 * 60 * 60 * 1_000 }, + weekly: { id: "7d", label: "Weekly", durationMs: 7 * 24 * 60 * 60 * 1_000 }, + monthly: { id: "30d", label: "Monthly", durationMs: 30 * 24 * 60 * 60 * 1_000 }, +} as const; + +type WindowType = keyof typeof WINDOW_CONFIG; + +function parseResetTime(value: unknown): number | undefined { + if (typeof value !== "string") return undefined; + const timestamp = Date.parse(value); + return Number.isFinite(timestamp) ? timestamp : undefined; +} + +function usageStatus(usedFraction: number): UsageStatus { + if (usedFraction >= 1) return "exhausted"; + if (usedFraction >= 0.9) return "warning"; + return "ok"; +} + +function parseLimit(raw: unknown, provider: UsageFetchParams["provider"]): UsageLimit | null { + if (!isRecord(raw) || typeof raw.type !== "string" || !(raw.type in WINDOW_CONFIG)) return null; + if (typeof raw.percentUsed !== "number" || !Number.isFinite(raw.percentUsed)) return null; + + const config = WINDOW_CONFIG[raw.type as WindowType]; + const used = Math.max(0, raw.percentUsed); + const usedFraction = used / 100; + const resetsAt = parseResetTime(raw.resetsAt); + + return { + id: `${PROVIDER}:${config.id}`, + label: "ClinePass", + scope: { provider, windowId: config.id, shared: true }, + window: { + id: config.id, + label: config.label, + durationMs: config.durationMs, + ...(resetsAt !== undefined ? { resetsAt } : {}), + }, + amount: { + used, + limit: 100, + remaining: Math.max(0, 100 - used), + usedFraction, + remainingFraction: Math.max(0, 1 - usedFraction), + unit: "percent", + }, + status: usageStatus(usedFraction), + }; +} + +interface AccountIdentity { + email?: string; + accountId?: string; +} + +function nonEmptyString(value: unknown): string | undefined { + return typeof value === "string" && value.trim() ? value.trim() : undefined; +} + +async function fetchAccountIdentity( + url: string, + headers: Record, + params: UsageFetchParams, + ctx: UsageFetchContext, +): Promise { + if (params.credential.email || params.credential.accountId) { + return { + email: params.credential.email, + accountId: params.credential.accountId, + }; + } + try { + const response = await ctx.fetch(url, { headers, signal: params.signal }); + if (!response.ok) return {}; + const payload: unknown = await response.json(); + if (!isRecord(payload)) return {}; + const data = isRecord(payload.data) ? payload.data : payload; + return { + email: nonEmptyString(data.email), + accountId: nonEmptyString(data.id), + }; + } catch (error) { + ctx.logger?.debug("ClinePass account identity fetch failed", { error: String(error) }); + return {}; + } +} + +async function fetchClinePassUsage(params: UsageFetchParams, ctx: UsageFetchContext): Promise { + if (params.provider !== PROVIDER) return null; + const credential = params.credential; + if (credential.type !== "api_key" || !credential.apiKey) return null; + + const baseUrl = (params.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, ""); + const usageUrl = `${baseUrl}${USAGE_LIMITS_PATH}`; + const headers = { + Accept: "application/json", + Authorization: `Bearer ${credential.apiKey}`, + }; + let payload: unknown; + try { + const response = await ctx.fetch(usageUrl, { headers, signal: params.signal }); + if (!response.ok) { + if (response.status === 401 || response.status === 403) { + throw new ProviderHttpError( + `ClinePass usage endpoint returned ${response.status} ${response.statusText}`.trim(), + response.status, + ); + } + ctx.logger?.warn("ClinePass usage fetch failed", { + status: response.status, + statusText: response.statusText, + }); + return null; + } + payload = await response.json(); + } catch (error) { + if (error instanceof ProviderHttpError) throw error; + ctx.logger?.warn("ClinePass usage fetch error", { error: String(error) }); + return null; + } + + if (!isRecord(payload)) return null; + const data = isRecord(payload.data) ? payload.data : payload; + if (!Array.isArray(data.limits)) return null; + + const limits = data.limits + .map(limit => parseLimit(limit, params.provider)) + .filter((limit): limit is UsageLimit => limit !== null); + if (limits.length === 0) return null; + + const identity = await fetchAccountIdentity(`${baseUrl}${ACCOUNT_PATH}`, headers, params, ctx); + + return { + provider: params.provider, + fetchedAt: Date.now(), + limits, + metadata: { endpoint: usageUrl, ...identity }, + raw: payload, + }; +} + +export const clinePassUsageProvider: UsageProvider = { + id: PROVIDER, + fetchUsage: fetchClinePassUsage, + supports: params => params.provider === PROVIDER && params.credential.type === "api_key", + validatesCredentials: true, +}; diff --git a/packages/ai/test/cline-pass-usage.test.ts b/packages/ai/test/cline-pass-usage.test.ts new file mode 100644 index 000000000000..be7a86e2934a --- /dev/null +++ b/packages/ai/test/cline-pass-usage.test.ts @@ -0,0 +1,146 @@ +import { describe, expect, it } from "bun:test"; +import type { FetchImpl } from "@oh-my-pi/pi-ai/types"; +import type { UsageFetchContext, UsageFetchParams } from "@oh-my-pi/pi-ai/usage"; +import { clinePassUsageProvider } from "@oh-my-pi/pi-ai/usage/cline-pass"; + +const CREDENTIAL: UsageFetchParams["credential"] = { + type: "api_key", + apiKey: "cline-test-key", +}; + +const USAGE_PAYLOAD = { + success: true, + data: { + limits: [ + { type: "five_hour", percentUsed: 1, resetsAt: "2026-08-07T02:50:50.492Z" }, + { type: "weekly", percentUsed: 92, resetsAt: "2026-08-13T21:50:50.494Z" }, + { type: "monthly", percentUsed: 100, resetsAt: "2026-09-05T21:50:50.497Z" }, + ], + }, +}; + +const IDENTITY_PAYLOAD = { + success: true, + data: { + id: "usr-test", + email: "user@example.com", + displayName: "Cline User", + }, +}; + +function makeContext( + payload: unknown, + status = 200, + requests: Array<{ url: string; init?: RequestInit }> = [], + identityPayload: unknown = IDENTITY_PAYLOAD, + identityStatus = 200, +): UsageFetchContext { + const fetch: FetchImpl = async (input, init) => { + const url = String(input); + requests.push({ url, init }); + const isIdentityRequest = url.endsWith("/users/me"); + return new Response(JSON.stringify(isIdentityRequest ? identityPayload : payload), { + status: isIdentityRequest ? identityStatus : status, + headers: { "Content-Type": "application/json" }, + }); + }; + return { fetch }; +} + +function makeParams(overrides: Partial = {}): UsageFetchParams { + return { + provider: "cline-pass", + credential: CREDENTIAL, + ...overrides, + }; +} + +describe("ClinePass usage provider", () => { + it("fetches and normalizes the subscription's rolling quota windows with an API key", async () => { + const requests: Array<{ url: string; init?: RequestInit }> = []; + const report = await clinePassUsageProvider.fetchUsage(makeParams(), makeContext(USAGE_PAYLOAD, 200, requests)); + + expect(requests).toHaveLength(2); + expect(requests.map(request => request.url)).toEqual([ + "https://api.cline.bot/api/v1/users/me/plan/usage-limits", + "https://api.cline.bot/api/v1/users/me", + ]); + expect(new Headers(requests[0]?.init?.headers).get("Authorization")).toBe("Bearer cline-test-key"); + expect(report?.provider).toBe("cline-pass"); + expect(report?.metadata).toMatchObject({ email: "user@example.com", accountId: "usr-test" }); + expect(report?.limits.map(limit => limit.scope.windowId)).toEqual(["5h", "7d", "30d"]); + expect(report?.limits.map(limit => limit.window?.label)).toEqual(["5 Hour", "Weekly", "Monthly"]); + expect(report?.limits.map(limit => limit.amount.usedFraction)).toEqual([0.01, 0.92, 1]); + expect(report?.limits.map(limit => limit.status)).toEqual(["ok", "warning", "exhausted"]); + expect(report?.limits[0]?.amount).toMatchObject({ + used: 1, + limit: 100, + remaining: 99, + remainingFraction: 0.99, + unit: "percent", + }); + expect(report?.limits[0]?.window?.resetsAt).toBe(Date.parse("2026-08-07T02:50:50.492Z")); + }); + + it("uses a configured provider base URL", async () => { + const requests: Array<{ url: string; init?: RequestInit }> = []; + await clinePassUsageProvider.fetchUsage( + makeParams({ baseUrl: "https://cline.example/api/v1/" }), + makeContext(USAGE_PAYLOAD, 200, requests), + ); + + expect(requests.map(request => request.url)).toEqual([ + "https://cline.example/api/v1/users/me/plan/usage-limits", + "https://cline.example/api/v1/users/me", + ]); + }); + + it("ignores malformed and unknown quota windows", async () => { + const report = await clinePassUsageProvider.fetchUsage( + makeParams(), + makeContext({ + data: { + limits: [ + { type: "daily", percentUsed: 25 }, + { type: "weekly", percentUsed: "25" }, + { type: "monthly", percentUsed: 7 }, + ], + }, + }), + ); + + expect(report?.limits).toHaveLength(1); + expect(report?.limits[0]?.scope.windowId).toBe("30d"); + }); + + it("keeps quota reporting available when optional account identity lookup fails", async () => { + const report = await clinePassUsageProvider.fetchUsage( + makeParams(), + makeContext(USAGE_PAYLOAD, 200, [], { error: "unavailable" }, 500), + ); + + expect(report?.limits).toHaveLength(3); + expect(report?.metadata?.email).toBeUndefined(); + expect(report?.metadata?.accountId).toBeUndefined(); + }); + + it("returns no report when the response contains no usable limits", async () => { + const report = await clinePassUsageProvider.fetchUsage(makeParams(), makeContext({ data: { limits: [] } })); + expect(report).toBeNull(); + }); + + it("surfaces authentication failures for credential health checks", async () => { + await expect( + clinePassUsageProvider.fetchUsage(makeParams(), makeContext({ error: "unauthorized" }, 401)), + ).rejects.toThrow("ClinePass usage endpoint returned 401"); + }); + + it("supports only ClinePass API-key credentials", () => { + expect(clinePassUsageProvider.supports?.(makeParams())).toBe(true); + expect(clinePassUsageProvider.supports?.(makeParams({ provider: "openai" }))).toBe(false); + expect( + clinePassUsageProvider.supports?.(makeParams({ credential: { type: "oauth", accessToken: "token" } })), + ).toBe(false); + expect(clinePassUsageProvider.validatesCredentials).toBe(true); + }); +}); From b424ca6e58a3c0543af5de34d8281e51eff95786 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 6 Aug 2026 20:20:39 -0400 Subject: [PATCH 006/795] docs: document native ClinePass support --- docs/environment-variables.md | 1 + docs/provider-endpoint-constraints.md | 11 ++++++++-- docs/providers.md | 3 +++ packages/ai/CHANGELOG.md | 24 ++++++++++++--------- packages/catalog/CHANGELOG.md | 4 ++++ packages/coding-agent/src/cli/help-extra.ts | 1 + 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/docs/environment-variables.md b/docs/environment-variables.md index bdfa7cd9d456..9ac6e81470b2 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -89,6 +89,7 @@ These are consumed via `getEnvApiKey()` (`packages/ai/src/stream.ts`) unless not | `SILICONFLOW_CN_API_KEY` | SiliconFlow (China) auth | Using `siliconflow-cn` provider | | | `KILO_API_KEY` | Kilo auth | Using Kilo models | | | `OLLAMA_CLOUD_API_KEY` | Ollama Cloud auth | Using `ollama-cloud` provider | | +| `CLINE_API_KEY` | ClinePass subscription auth | Using the `cline-pass` provider | Official Cline API-key variable | | `WAFER_SERVERLESS_API_KEY` | Wafer Serverless auth | Using `wafer-serverless` provider | Pay-as-you-go Wafer SKU; validated against `https://pass.wafer.ai/v1/models` | | `GITLAB_TOKEN` | GitLab Duo auth | Using `gitlab-duo` provider | | diff --git a/docs/provider-endpoint-constraints.md b/docs/provider-endpoint-constraints.md index c26121b69554..1457e719c0c3 100644 --- a/docs/provider-endpoint-constraints.md +++ b/docs/provider-endpoint-constraints.md @@ -150,6 +150,13 @@ routing, model ids, or usage accounting. - The OpenAI-compatible path needs common Kimi headers. - It also participates in the OpenAI/Anthropic dual-surface shim. +### ClinePass + +- Catalog IDs omit the gateway's `cline-pass/` namespace; Chat Completions adds it on the wire. +- The OpenAI-compatible `/models` route is absent. Discover the authoritative roster from Cline's public `recommended-models` endpoint, with the generated catalog as an offline metadata fallback. +- Output limits use `max_completion_tokens`. Reasoning uses `reasoning_effort` (`none` through `max`) and streams through `delta.reasoning`; tool-call continuations must replay that field. +- The dashboard's `/users/me/plan/usage-limits` route accepts the inference API key and returns five-hour, weekly, and monthly utilization with reset times; `/users/me` supplies the account email label. Usage reporting does not require account OAuth. + ### Fireworks and Firepass - Wire model ids need provider-specific mapping. @@ -161,8 +168,8 @@ routing, model ids, or usage accounting. Check these before adding or forwarding a field: - **Model id.** Some models resolve a wire id from reasoning effort. - Firepass/Fireworks transform ids. OpenRouter suffix handling is path-segment - aware. + ClinePass, Firepass, and Fireworks transform ids. OpenRouter suffix handling + is path-segment aware. - **Max output tokens.** Kimi-family models may require a max-token field even when the caller did not set one. OpenRouter should omit catalog defaults unless explicit. Codex drops caller caps. Responses uses `max_output_tokens`; Chat diff --git a/docs/providers.md b/docs/providers.md index 7f5850b76743..b050f30b7e7d 100644 --- a/docs/providers.md +++ b/docs/providers.md @@ -51,6 +51,8 @@ For headless or remote setups backed by a shared auth broker, the CLI exposes `o When a model has no credentials, `omp` tells you to run `/login` or set the provider's environment variable. +For ClinePass, set `CLINE_API_KEY` or run `/login cline-pass` to open the Cline dashboard and validate a newly created API key. OMP refreshes its model roster from Cline's public recommended-models endpoint, retains generated metadata as an offline fallback, and reports the subscription's five-hour, weekly, and monthly quota windows through `omp usage`. + ### Pinning a key in `models.yml` A custom provider's `apiKey` is resolved as **environment-variable-name-or-literal**: if the value names an existing environment variable, that variable's value is used; otherwise the string itself is the key. Prefixing the value with `!` runs it as a shell command and uses the trimmed stdout (see [Model and Provider Configuration](./models.md) for the full value syntax). @@ -137,6 +139,7 @@ Each provider has one or more environment variables that supply a key when no st | `aimlapi` | `AIMLAPI_API_KEY` | | `gitlab-duo`, `gitlab-duo-agent` | `GITLAB_TOKEN` | | `opencode-zen`, `opencode-go` | `OPENCODE_API_KEY` | +| `cline-pass` | `CLINE_API_KEY` | | `firepass` | `FIREPASS_API_KEY` | | `wafer-serverless` | `WAFER_SERVERLESS_API_KEY` | | `xiaomi` | `XIAOMI_API_KEY` | diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 848026ca5f14..4876c4692489 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- Added API-key authentication for ClinePass through the official `CLINE_API_KEY` variable, including direct Chat Completions validation and rolling quota-window reporting in `omp usage`. ([#3833](https://github.com/can1357/oh-my-pi/issues/3833)) + ## [17.2.10] - 2026-08-06 ### Breaking Changes @@ -896,7 +900,7 @@ - Added a third streaming thinking-loop detection heuristic to catch "progress-lexicon stalls" where models endlessly reshuffle motivational filler without introducing new vocabulary or concrete technical references - Added branded wordmark and logo animation to authentication flow -- Added a third streaming thinking-loop detection shape — a *progress-lexicon stall* — alongside verbatim tail repetition and near-duplicate (trigram) segments. It catches reasoning-summarizer loops that reshuffle the same motivational filler ("just doing it, pushing ahead, maintaining momentum") into fresh word order every paragraph: word-trigrams never cluster, but a run of substantial segments that recycle the recent vocabulary and introduce no *new* concrete reference (path / identifier / code-span) trips the guard. Summarizer title/heading lines (`**Bold Title**`, `## Heading`) are stripped before analysis so their ever-changing wording cannot mask the stall by inflating novelty. Calibrated against 537k real non-Gemini reasoning blocks (zero false positives at novelty floor 0.2 / run length 8; the real loop sustains runs of 10+). +- Added a third streaming thinking-loop detection shape — a _progress-lexicon stall_ — alongside verbatim tail repetition and near-duplicate (trigram) segments. It catches reasoning-summarizer loops that reshuffle the same motivational filler ("just doing it, pushing ahead, maintaining momentum") into fresh word order every paragraph: word-trigrams never cluster, but a run of substantial segments that recycle the recent vocabulary and introduce no _new_ concrete reference (path / identifier / code-span) trips the guard. Summarizer title/heading lines (`**Bold Title**`, `## Heading`) are stripped before analysis so their ever-changing wording cannot mask the stall by inflating novelty. Calibrated against 537k real non-Gemini reasoning blocks (zero false positives at novelty floor 0.2 / run length 8; the real loop sustains runs of 10+). - Added CoreWeave Serverless Inference provider login support via `COREWEAVE_API_KEY` and `WANDB_API_KEY` fallback. ### Changed @@ -1040,7 +1044,7 @@ - Fixed tool call ID normalization for Anthropic-compatible models - Fixed Anthropic Messages replay sanitizing malformed tool-call IDs, including aborted native tool calls with empty IDs, so retries no longer send invalid `tool_use.id` / `tool_result.tool_use_id` pairs. - Fixed the Codex Responses WebSocket transport attributing a prior turn's output to the current one on a reused connection: a trailing/duplicate frame from a cleanly-completed previous response that slipped past the queue drain could be consumed as this request's terminal (ending the turn with empty output) or as a stale tool call. Frames are now keyed by `response.id` — a frame carrying the previous response's id is dropped, and one carrying a third id (or a regressed `sequence_number`) fails closed so the turn retries instead of mixing two responses' streams. Idless frames (deltas, the rate-limit/metadata preamble, `response.created`-less streams) still pass through, matching upstream codex-rs. -- Fixed `transformMessages` pulling an earlier, orphaned tool result onto a later tool call that reused the same id (left behind when compaction folded the originating `tool_use` into a summary). The pending-call flush now pairs each call with a result positioned *after* its assistant turn, so a reused id surfaces its own output rather than a prior turn's. +- Fixed `transformMessages` pulling an earlier, orphaned tool result onto a later tool call that reused the same id (left behind when compaction folded the originating `tool_use` into a summary). The pending-call flush now pairs each call with a result positioned _after_ its assistant turn, so a reused id surfaces its own output rather than a prior turn's. - Fixed DashScope 429 rate-limit messages that mention authorization being classified as credential failures, preventing valid API keys from being invalidated after throttling. ([#3172](https://github.com/can1357/oh-my-pi/issues/3172)) - Fixed OpenCode Go `401 Insufficient balance` quota errors being treated as unknown failures instead of usage-limit errors, restoring credential rotation and fallback chains. ([#3169](https://github.com/can1357/oh-my-pi/issues/3169)) @@ -1316,7 +1320,7 @@ - Added `wrapInbandToolStream` function to process streaming responses with in-band tool call parsing - Added `ThinkingInbandScanner` for parsing thinking/reasoning blocks across dialects - Added `OwnedStream` class for managing dialect-aware streaming with tool call events -- Added in-band thinking channels to every dialect that was missing one: `gemini` (a ```` ```thinking ```` fence mirroring ```` ```tool_code ````), `gemma` (its native `<|channel>thought…` reasoning channel), `kimi` (`…`), and `pi` (`…`). Each scanner now parses reasoning into thinking events instead of leaking chain-of-thought into the visible reply, and every dialect's `renderThinking` is a real channel that round-trips back through its scanner (no passthrough renderers). +- Added in-band thinking channels to every dialect that was missing one: `gemini` (a ` ```thinking ` fence mirroring ` ```tool_code `), `gemma` (its native `<|channel>thought…` reasoning channel), `kimi` (`…`), and `pi` (`…`). Each scanner now parses reasoning into thinking events instead of leaking chain-of-thought into the visible reply, and every dialect's `renderThinking` is a real channel that round-trips back through its scanner (no passthrough renderers). ### Changed @@ -1340,7 +1344,7 @@ ### Added -- Added the `gemini` in-band tool-call syntax with Python-style ```tool_code``` blocks and `default_api` invocations +- Added the `gemini` in-band tool-call syntax with Python-style `tool_code` blocks and `default_api` invocations - Added the `gemma` token-delimited in-band tool-call syntax using `<|tool_call>` and `<|tool_response>` blocks - Added `gemini` and `gemma` to owned stream tool-result token detection so their tool responses are recognized - Fixed truncated Gemini and Gemma tool blocks from being emitted as plain text during streaming @@ -1385,7 +1389,7 @@ - Fixed Harmony leak handling support by adding `recoverHarmonyToolCall` plus leak-detection workflows for contaminated assistant messages so recoverable tool-call arguments can be safely truncated and retried - Fixed false-positive gating in Harmony leak heuristics using signal-based checks so unrelated text containing `to=functions...` is not treated as leaked tool-call markup - Routed Kimi, DeepSeek DSML, and plain thinking markup healing through the shared in-band scanners so provider leak repair and owned tool calling parse the same wire formats. -- Fixed Cursor provider (`cursor-agent` API) streaming dropping large MCP tool-call arguments — most visibly the built-in `task` tool's `tasks` array on multi-subagent dispatches, which failed downstream schema validation with `tasks: Invalid input: expected array, received undefined`. Two upstream behaviors were fighting the stream handler in `packages/ai/src/providers/cursor.ts`: (1) `args_text_delta` carries the *cumulative* args text so far per `agent.proto`, but the handler concatenated each snapshot onto the buffer, garbling the JSON; (2) `tool_call_completed` carries an `McpArgs` map that omits oversized parameters entirely and downgrades unparsable values to their raw string fallback, but the handler unconditionally overwrote the streamed args with that map. The handler now strips the already-buffered prefix from each `args_text_delta` snapshot (falling back to append when the snapshot doesn't extend the buffer) and merges the decoded `McpArgs` map into the streamed args — preserving streamed keys the completion frame omits and the structured value when the completion frame downgrades to a string. ([#2615](https://github.com/can1357/oh-my-pi/issues/2615)) +- Fixed Cursor provider (`cursor-agent` API) streaming dropping large MCP tool-call arguments — most visibly the built-in `task` tool's `tasks` array on multi-subagent dispatches, which failed downstream schema validation with `tasks: Invalid input: expected array, received undefined`. Two upstream behaviors were fighting the stream handler in `packages/ai/src/providers/cursor.ts`: (1) `args_text_delta` carries the _cumulative_ args text so far per `agent.proto`, but the handler concatenated each snapshot onto the buffer, garbling the JSON; (2) `tool_call_completed` carries an `McpArgs` map that omits oversized parameters entirely and downgrades unparsable values to their raw string fallback, but the handler unconditionally overwrote the streamed args with that map. The handler now strips the already-buffered prefix from each `args_text_delta` snapshot (falling back to append when the snapshot doesn't extend the buffer) and merges the decoded `McpArgs` map into the streamed args — preserving streamed keys the completion frame omits and the structured value when the completion frame downgrades to a string. ([#2615](https://github.com/can1357/oh-my-pi/issues/2615)) - Fixed Codex Responses stream mis-routing interleaved `function_call_arguments.delta` events when more than one tool call was open concurrently. The runtime tracked a singleton `currentItem`/`currentBlock`, so every delta — regardless of `item_id` — was appended to whichever item was most recently added, and `output_item.done` for the earlier call then overwrote a sibling's stored arguments (visible as `tasks: Invalid input: expected array, received undefined` on the `task` tool). Open items are now keyed by `item_id` with `output_index` fallback; deltas/done events route to the matching block, late deltas whose item already closed are dropped instead of corrupting a sibling, and `toolcall_*` stream events emit the right `contentIndex` per call ([#2619](https://github.com/can1357/oh-my-pi/issues/2619)). ## [15.13.1] - 2026-06-15 @@ -1594,7 +1598,7 @@ ### Breaking Changes -- The model catalog moved to the new `@oh-my-pi/pi-catalog` package. Deep subpath exports `@oh-my-pi/pi-ai/models.json`, `/models`, `/model-cache`, `/model-manager`, `/model-thinking`, `/effort`, `/provider-models*`, `/utils/discovery*`, `/providers/openai-codex/constants`, `/providers/google-gemini-headers`, and `/providers/openai-completions-compat` are gone — import the `@oh-my-pi/pi-catalog` equivalents (`/models.json`, `/models`, `/model-cache`, `/model-manager`, `/model-thinking`, `/effort`, `/provider-models*`, `/discovery*`, `/wire/codex`, `/wire/gemini-headers`, `/compat/openai`). The pi-ai root barrel re-exports only the model/effort *types* its own signatures use (`Model`, `Api`, `ThinkingConfig`, `Effort`, `Usage`, compat interfaces) — catalog *values* (`getBundledModel(s)`, `calculateCost`, `modelsAreEqual`, `clampThinkingLevelForModel`, `DEFAULT_MODEL_PER_PROVIDER`, …) must be imported from `@oh-my-pi/pi-catalog`. +- The model catalog moved to the new `@oh-my-pi/pi-catalog` package. Deep subpath exports `@oh-my-pi/pi-ai/models.json`, `/models`, `/model-cache`, `/model-manager`, `/model-thinking`, `/effort`, `/provider-models*`, `/utils/discovery*`, `/providers/openai-codex/constants`, `/providers/google-gemini-headers`, and `/providers/openai-completions-compat` are gone — import the `@oh-my-pi/pi-catalog` equivalents (`/models.json`, `/models`, `/model-cache`, `/model-manager`, `/model-thinking`, `/effort`, `/provider-models*`, `/discovery*`, `/wire/codex`, `/wire/gemini-headers`, `/compat/openai`). The pi-ai root barrel re-exports only the model/effort _types_ its own signatures use (`Model`, `Api`, `ThinkingConfig`, `Effort`, `Usage`, compat interfaces) — catalog _values_ (`getBundledModel(s)`, `calculateCost`, `modelsAreEqual`, `clampThinkingLevelForModel`, `DEFAULT_MODEL_PER_PROVIDER`, …) must be imported from `@oh-my-pi/pi-catalog`. - `ProviderDefinition` is now auth-only: `defaultModel`, `createModelManagerOptions`, `catalogDiscovery`, `dynamicModelsAuthoritative`, `allowUnauthenticated`, and `specialModelManager` moved to pi-catalog's `CATALOG_PROVIDERS` table, and `KnownProviderId` was replaced by pi-catalog's `KnownProvider` (registry completeness is enforced by a compile-time check against that union). The pure GitHub Copilot key/endpoint helpers moved from `registry/oauth/github-copilot` to `@oh-my-pi/pi-catalog/wire/github-copilot`. ### Added @@ -1683,7 +1687,7 @@ - Fixed `AnthropicMessagesClient` spreading `fetchOptions` after the core request fields, letting a caller-supplied `signal`/`method`/`body` silently disconnect the timeout controller or corrupt the request. Transport extras (TLS) still pass through; core fields now always win. - Fixed Foundry mTLS/CA material being cached for the process lifetime when the env vars point at files: the cache key now folds in the file mtime so on-disk certificate rotation takes effect. - Fixed the Claude Code fingerprint version drifting across surfaces: the usage endpoint (`claude-cli/2.1.160`) and OAuth bootstrap (`claude-code/2.1.160`) pinned a stale version while `/v1/messages` reported 2.1.165; both now derive from `claudeCodeVersion`. -- Fixed a system prompt that merely *mentions* `x-anthropic-billing-header:` mid-text suppressing the entire Claude Code system-block injection (billing header, instruction, and cch attestation); the resumed-session guard now anchors with `startsWith`. +- Fixed a system prompt that merely _mentions_ `x-anthropic-billing-header:` mid-text suppressing the entire Claude Code system-block injection (billing header, instruction, and cch attestation); the resumed-session guard now anchors with `startsWith`. - Fixed lone surrogates in cross-API tool-call arguments reaching Anthropic's strict UTF-8 validation: replayed OpenAI/Google-origin `tool_use.input` string leaves are now deep-sanitized with `toWellFormed()`, while same-API Anthropic arguments stay byte-identical to keep prompt-cache prefixes stable. - Bounded the many-image resize fan-out to 4 concurrent decodes (it previously decoded every oversized image at once, two encode pipelines each — multi-GB transient memory at the 20+-image threshold that activates the feature). - Fixed `mergeHeaders` merging case-sensitively on the Copilot/client-options path, where a miscased user-configured header (e.g. `authorization` next to the synthesized `Authorization`) survived as two keys that the `Headers` constructor joins comma-separated on the wire. @@ -1744,7 +1748,7 @@ - Fixed `AnthropicMessagesClient` spreading `fetchOptions` after the core request fields, letting a caller-supplied `signal`/`method`/`body` silently disconnect the timeout controller or corrupt the request. Transport extras (TLS) still pass through; core fields now always win. - Fixed Foundry mTLS/CA material being cached for the process lifetime when the env vars point at files: the cache key now folds in the file mtime so on-disk certificate rotation takes effect. - Fixed the Claude Code fingerprint version drifting across surfaces: the usage endpoint (`claude-cli/2.1.160`) and OAuth bootstrap (`claude-code/2.1.160`) pinned a stale version while `/v1/messages` reported 2.1.165; both now derive from `claudeCodeVersion`. -- Fixed a system prompt that merely *mentions* `x-anthropic-billing-header:` mid-text suppressing the entire Claude Code system-block injection (billing header, instruction, and cch attestation); the resumed-session guard now anchors with `startsWith`. +- Fixed a system prompt that merely _mentions_ `x-anthropic-billing-header:` mid-text suppressing the entire Claude Code system-block injection (billing header, instruction, and cch attestation); the resumed-session guard now anchors with `startsWith`. - Fixed lone surrogates in cross-API tool-call arguments reaching Anthropic's strict UTF-8 validation: replayed OpenAI/Google-origin `tool_use.input` string leaves are now deep-sanitized with `toWellFormed()`, while same-API Anthropic arguments stay byte-identical to keep prompt-cache prefixes stable. - Bounded the many-image resize fan-out to 4 concurrent decodes (it previously decoded every oversized image at once, two encode pipelines each — multi-GB transient memory at the 20+-image threshold that activates the feature). - Fixed `mergeHeaders` merging case-sensitively on the Copilot/client-options path, where a miscased user-configured header (e.g. `authorization` next to the synthesized `Authorization`) survived as two keys that the `Headers` constructor joins comma-separated on the wire. @@ -1777,7 +1781,7 @@ ### Fixed - Fixed a degenerate OpenAI Codex stream (the model emits whitespace-only `function_call_arguments.delta` frames forever — commonly seen right after a `todo` tool call) terminating the turn with an error instead of recovering. The whitespace-loop circuit-breaker now (a) stops aborting the shared per-request `AbortController` — `requestSignal` is an `AbortSignal.any` over it, so aborting latched it and made every reopen on the reused `requestSetup` impossible — and (b) drops the half-built junk tool call and replays the request from scratch, bounded by `CODEX_WHITESPACE_LOOP_RETRY_LIMIT` (2). Sampling nondeterminism usually clears the loop on a fresh attempt; once the budget is exhausted the error is surfaced as before, but without the junk tool call polluting the message. -- Capped requested output tokens at 64k (`OPENAI_MAX_OUTPUT_TOKENS`, mirroring Anthropic's `CLAUDE_CODE_MAX_OUTPUT_TOKENS`) on OpenAI-family wires with a known upstream output cap — the `openai-completions` request builder (non-OpenRouter) and the shared responses sampling helper (`openai-responses`, `azure-openai-responses`). A model's catalog `maxTokens` often tracks its context window rather than the upstream's per-request output cap, so requesting the full ceiling 400'd (e.g. `z-ai/glm-4.7` asking for 131072 output exceeded the upstream's 131072-token *total* context). Output is now `min(requested, model.maxTokens, 64000)`. +- Capped requested output tokens at 64k (`OPENAI_MAX_OUTPUT_TOKENS`, mirroring Anthropic's `CLAUDE_CODE_MAX_OUTPUT_TOKENS`) on OpenAI-family wires with a known upstream output cap — the `openai-completions` request builder (non-OpenRouter) and the shared responses sampling helper (`openai-responses`, `azure-openai-responses`). A model's catalog `maxTokens` often tracks its context window rather than the upstream's per-request output cap, so requesting the full ceiling 400'd (e.g. `z-ai/glm-4.7` asking for 131072 output exceeded the upstream's 131072-token _total_ context). Output is now `min(requested, model.maxTokens, 64000)`. - Stopped sending `max_tokens`/`max_completion_tokens` on OpenRouter (`openrouter.ai`) completions requests. OpenRouter filters out any upstream whose advertised output cap is below the requested `max_tokens`, so a value derived from the catalog (which reflects the highest-cap provider) silently excluded lower-cap upstreams — `provider.order: ["cerebras"]` for `z-ai/glm-4.7` fell through to DeepInfra because Cerebras's ~40k output cap is below the request, while `only: ["cerebras"]` (no fallback target) bypassed the filter and worked. Omitting the field lets each upstream self-cap and keeps provider routing (`only`/`order`) honored. Kimi via OpenRouter stays exempt — it derives TPM rate limits from `max_tokens`. ## [15.10.7] - 2026-06-08 @@ -1975,7 +1979,7 @@ - Reasoning models now append `effort-2025-11-24` to the per-request `Anthropic-Beta` header (matches Claude Code). - `buildAnthropicSystemBlocks` (CC-instruction mode) now emits the same 3-block layout as Claude Code: billing header (never cached), system instruction (cached), all user content merged into one block with `\n\n` (cached). Previously emitted one block per item with cache only on the last, which fingerprinted the caller by block count. - `applyPromptCaching` now matches Claude Code's breakpoint layout: 2 system (instruction + merged content) + 2 message, with no tool breakpoint. The tool breakpoint was redundant — tools follow system in the token sequence, so when system changes the tool cache prefix also changes. The instruction block (system[1]) is stable across every request and now gets its own guaranteed-hit breakpoint. -- `applyPromptCaching` now caches the last two messages regardless of role instead of the last two *user* messages. The penultimate assistant message (tool calls + response from the previous turn) is larger and more recently created than the penultimate user message, making it the higher-value cache target. +- `applyPromptCaching` now caches the last two messages regardless of role instead of the last two _user_ messages. The penultimate assistant message (tool calls + response from the previous turn) is larger and more recently created than the penultimate user message, making it the higher-value cache target. - OAuth scope set expanded: added `user:sessions:claude_code`, `user:mcp_servers`, `user:file_upload`. `AUTHORIZE_URL` stays at `claude.ai/oauth/authorize` and `TOKEN_URL` stays at `api.anthropic.com/v1/oauth/token` — the `platform.claude.com` equivalents are CC's console-credential flow and do not grant `user:inference`, which OMP requires for direct OAuth-token inference. - Token refresh POST now sends `anthropic-beta: oauth-2025-04-20` and `User-Agent: anthropic-sdk-typescript/0.94.0 userOAuthProvider` (CC sends these on refresh but not on the initial code exchange). diff --git a/packages/catalog/CHANGELOG.md b/packages/catalog/CHANGELOG.md index bd4631460512..25e03aa24086 100644 --- a/packages/catalog/CHANGELOG.md +++ b/packages/catalog/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- Added the native `cline-pass` provider with live roster discovery, generated offline metadata, concise public model IDs, and verified output-token and reasoning-effort request shaping. ([#3833](https://github.com/can1357/oh-my-pi/issues/3833)) + ## [17.2.10] - 2026-08-06 ### Changed diff --git a/packages/coding-agent/src/cli/help-extra.ts b/packages/coding-agent/src/cli/help-extra.ts index 765eb0c1f7ab..4b0dd625c6c6 100644 --- a/packages/coding-agent/src/cli/help-extra.ts +++ b/packages/coding-agent/src/cli/help-extra.ts @@ -32,6 +32,7 @@ export function getExtraHelpText(): string { MINIMAX_API_KEY - MiniMax models OPENCODE_API_KEY - OpenCode Zen/OpenCode Go models CURSOR_ACCESS_TOKEN - Cursor AI models + CLINE_API_KEY - ClinePass subscription models AI_GATEWAY_API_KEY - Vercel AI Gateway WAFER_SERVERLESS_API_KEY - Wafer Serverless (pay-as-you-go) From 0e7319005f5e8a038d22c6b1e171210cf812318d Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 6 Aug 2026 20:22:11 -0400 Subject: [PATCH 007/795] docs(ai,catalog): credit ClinePass integration --- packages/ai/CHANGELOG.md | 2 +- packages/catalog/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 4876c4692489..e8211f97c611 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- Added API-key authentication for ClinePass through the official `CLINE_API_KEY` variable, including direct Chat Completions validation and rolling quota-window reporting in `omp usage`. ([#3833](https://github.com/can1357/oh-my-pi/issues/3833)) +- Added API-key authentication for ClinePass through the official `CLINE_API_KEY` variable, including direct Chat Completions validation and rolling quota-window reporting in `omp usage` ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). ## [17.2.10] - 2026-08-06 diff --git a/packages/catalog/CHANGELOG.md b/packages/catalog/CHANGELOG.md index 25e03aa24086..a7c73ca85414 100644 --- a/packages/catalog/CHANGELOG.md +++ b/packages/catalog/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- Added the native `cline-pass` provider with live roster discovery, generated offline metadata, concise public model IDs, and verified output-token and reasoning-effort request shaping. ([#3833](https://github.com/can1357/oh-my-pi/issues/3833)) +- Added the native `cline-pass` provider with live roster discovery, generated offline metadata, concise public model IDs, and verified output-token and reasoning-effort request shaping ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). ## [17.2.10] - 2026-08-06 From 0a0c7c6cc34d64a3e2b4dcb3bf228dcdcfc04efc Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 6 Aug 2026 21:01:37 -0400 Subject: [PATCH 008/795] fix(catalog): harden ClinePass runtime discovery --- docs/provider-endpoint-constraints.md | 2 +- packages/ai/CHANGELOG.md | 20 +-- packages/ai/test/cline-pass-transport.test.ts | 102 +++++++++++- packages/catalog/src/compat/openai.ts | 18 +- .../src/provider-models/descriptors.ts | 1 - .../src/provider-models/openai-compat.ts | 11 +- .../catalog/test/cline-pass-compat.test.ts | 155 ++++++++++++------ packages/coding-agent/CHANGELOG.md | 4 + .../model-registry-runtime-provider.test.ts | 19 ++- 9 files changed, 260 insertions(+), 72 deletions(-) diff --git a/docs/provider-endpoint-constraints.md b/docs/provider-endpoint-constraints.md index 1457e719c0c3..ba07a930c0dc 100644 --- a/docs/provider-endpoint-constraints.md +++ b/docs/provider-endpoint-constraints.md @@ -154,7 +154,7 @@ routing, model ids, or usage accounting. - Catalog IDs omit the gateway's `cline-pass/` namespace; Chat Completions adds it on the wire. - The OpenAI-compatible `/models` route is absent. Discover the authoritative roster from Cline's public `recommended-models` endpoint, with the generated catalog as an offline metadata fallback. -- Output limits use `max_completion_tokens`. Reasoning uses `reasoning_effort` (`none` through `max`) and streams through `delta.reasoning`; tool-call continuations must replay that field. +- Output limits use `max_completion_tokens`. Reasoning uses `reasoning_effort` (`none` through `max`) and streams through `delta.reasoning`; continuations replay it only for model families whose compatibility policy requires reasoning history. - The dashboard's `/users/me/plan/usage-limits` route accepts the inference API key and returns five-hour, weekly, and monthly utilization with reset times; `/users/me` supplies the account email label. Usage reporting does not require account OAuth. ### Fireworks and Firepass diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index e8211f97c611..b3e91c345d96 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -900,7 +900,7 @@ - Added a third streaming thinking-loop detection heuristic to catch "progress-lexicon stalls" where models endlessly reshuffle motivational filler without introducing new vocabulary or concrete technical references - Added branded wordmark and logo animation to authentication flow -- Added a third streaming thinking-loop detection shape — a _progress-lexicon stall_ — alongside verbatim tail repetition and near-duplicate (trigram) segments. It catches reasoning-summarizer loops that reshuffle the same motivational filler ("just doing it, pushing ahead, maintaining momentum") into fresh word order every paragraph: word-trigrams never cluster, but a run of substantial segments that recycle the recent vocabulary and introduce no _new_ concrete reference (path / identifier / code-span) trips the guard. Summarizer title/heading lines (`**Bold Title**`, `## Heading`) are stripped before analysis so their ever-changing wording cannot mask the stall by inflating novelty. Calibrated against 537k real non-Gemini reasoning blocks (zero false positives at novelty floor 0.2 / run length 8; the real loop sustains runs of 10+). +- Added a third streaming thinking-loop detection shape — a *progress-lexicon stall* — alongside verbatim tail repetition and near-duplicate (trigram) segments. It catches reasoning-summarizer loops that reshuffle the same motivational filler ("just doing it, pushing ahead, maintaining momentum") into fresh word order every paragraph: word-trigrams never cluster, but a run of substantial segments that recycle the recent vocabulary and introduce no *new* concrete reference (path / identifier / code-span) trips the guard. Summarizer title/heading lines (`**Bold Title**`, `## Heading`) are stripped before analysis so their ever-changing wording cannot mask the stall by inflating novelty. Calibrated against 537k real non-Gemini reasoning blocks (zero false positives at novelty floor 0.2 / run length 8; the real loop sustains runs of 10+). - Added CoreWeave Serverless Inference provider login support via `COREWEAVE_API_KEY` and `WANDB_API_KEY` fallback. ### Changed @@ -1044,7 +1044,7 @@ - Fixed tool call ID normalization for Anthropic-compatible models - Fixed Anthropic Messages replay sanitizing malformed tool-call IDs, including aborted native tool calls with empty IDs, so retries no longer send invalid `tool_use.id` / `tool_result.tool_use_id` pairs. - Fixed the Codex Responses WebSocket transport attributing a prior turn's output to the current one on a reused connection: a trailing/duplicate frame from a cleanly-completed previous response that slipped past the queue drain could be consumed as this request's terminal (ending the turn with empty output) or as a stale tool call. Frames are now keyed by `response.id` — a frame carrying the previous response's id is dropped, and one carrying a third id (or a regressed `sequence_number`) fails closed so the turn retries instead of mixing two responses' streams. Idless frames (deltas, the rate-limit/metadata preamble, `response.created`-less streams) still pass through, matching upstream codex-rs. -- Fixed `transformMessages` pulling an earlier, orphaned tool result onto a later tool call that reused the same id (left behind when compaction folded the originating `tool_use` into a summary). The pending-call flush now pairs each call with a result positioned _after_ its assistant turn, so a reused id surfaces its own output rather than a prior turn's. +- Fixed `transformMessages` pulling an earlier, orphaned tool result onto a later tool call that reused the same id (left behind when compaction folded the originating `tool_use` into a summary). The pending-call flush now pairs each call with a result positioned *after* its assistant turn, so a reused id surfaces its own output rather than a prior turn's. - Fixed DashScope 429 rate-limit messages that mention authorization being classified as credential failures, preventing valid API keys from being invalidated after throttling. ([#3172](https://github.com/can1357/oh-my-pi/issues/3172)) - Fixed OpenCode Go `401 Insufficient balance` quota errors being treated as unknown failures instead of usage-limit errors, restoring credential rotation and fallback chains. ([#3169](https://github.com/can1357/oh-my-pi/issues/3169)) @@ -1320,7 +1320,7 @@ - Added `wrapInbandToolStream` function to process streaming responses with in-band tool call parsing - Added `ThinkingInbandScanner` for parsing thinking/reasoning blocks across dialects - Added `OwnedStream` class for managing dialect-aware streaming with tool call events -- Added in-band thinking channels to every dialect that was missing one: `gemini` (a ` ```thinking ` fence mirroring ` ```tool_code `), `gemma` (its native `<|channel>thought…` reasoning channel), `kimi` (`…`), and `pi` (`…`). Each scanner now parses reasoning into thinking events instead of leaking chain-of-thought into the visible reply, and every dialect's `renderThinking` is a real channel that round-trips back through its scanner (no passthrough renderers). +- Added in-band thinking channels to every dialect that was missing one: `gemini` (a ```` ```thinking ```` fence mirroring ```` ```tool_code ````), `gemma` (its native `<|channel>thought…` reasoning channel), `kimi` (`…`), and `pi` (`…`). Each scanner now parses reasoning into thinking events instead of leaking chain-of-thought into the visible reply, and every dialect's `renderThinking` is a real channel that round-trips back through its scanner (no passthrough renderers). ### Changed @@ -1344,7 +1344,7 @@ ### Added -- Added the `gemini` in-band tool-call syntax with Python-style `tool_code` blocks and `default_api` invocations +- Added the `gemini` in-band tool-call syntax with Python-style ```tool_code``` blocks and `default_api` invocations - Added the `gemma` token-delimited in-band tool-call syntax using `<|tool_call>` and `<|tool_response>` blocks - Added `gemini` and `gemma` to owned stream tool-result token detection so their tool responses are recognized - Fixed truncated Gemini and Gemma tool blocks from being emitted as plain text during streaming @@ -1389,7 +1389,7 @@ - Fixed Harmony leak handling support by adding `recoverHarmonyToolCall` plus leak-detection workflows for contaminated assistant messages so recoverable tool-call arguments can be safely truncated and retried - Fixed false-positive gating in Harmony leak heuristics using signal-based checks so unrelated text containing `to=functions...` is not treated as leaked tool-call markup - Routed Kimi, DeepSeek DSML, and plain thinking markup healing through the shared in-band scanners so provider leak repair and owned tool calling parse the same wire formats. -- Fixed Cursor provider (`cursor-agent` API) streaming dropping large MCP tool-call arguments — most visibly the built-in `task` tool's `tasks` array on multi-subagent dispatches, which failed downstream schema validation with `tasks: Invalid input: expected array, received undefined`. Two upstream behaviors were fighting the stream handler in `packages/ai/src/providers/cursor.ts`: (1) `args_text_delta` carries the _cumulative_ args text so far per `agent.proto`, but the handler concatenated each snapshot onto the buffer, garbling the JSON; (2) `tool_call_completed` carries an `McpArgs` map that omits oversized parameters entirely and downgrades unparsable values to their raw string fallback, but the handler unconditionally overwrote the streamed args with that map. The handler now strips the already-buffered prefix from each `args_text_delta` snapshot (falling back to append when the snapshot doesn't extend the buffer) and merges the decoded `McpArgs` map into the streamed args — preserving streamed keys the completion frame omits and the structured value when the completion frame downgrades to a string. ([#2615](https://github.com/can1357/oh-my-pi/issues/2615)) +- Fixed Cursor provider (`cursor-agent` API) streaming dropping large MCP tool-call arguments — most visibly the built-in `task` tool's `tasks` array on multi-subagent dispatches, which failed downstream schema validation with `tasks: Invalid input: expected array, received undefined`. Two upstream behaviors were fighting the stream handler in `packages/ai/src/providers/cursor.ts`: (1) `args_text_delta` carries the *cumulative* args text so far per `agent.proto`, but the handler concatenated each snapshot onto the buffer, garbling the JSON; (2) `tool_call_completed` carries an `McpArgs` map that omits oversized parameters entirely and downgrades unparsable values to their raw string fallback, but the handler unconditionally overwrote the streamed args with that map. The handler now strips the already-buffered prefix from each `args_text_delta` snapshot (falling back to append when the snapshot doesn't extend the buffer) and merges the decoded `McpArgs` map into the streamed args — preserving streamed keys the completion frame omits and the structured value when the completion frame downgrades to a string. ([#2615](https://github.com/can1357/oh-my-pi/issues/2615)) - Fixed Codex Responses stream mis-routing interleaved `function_call_arguments.delta` events when more than one tool call was open concurrently. The runtime tracked a singleton `currentItem`/`currentBlock`, so every delta — regardless of `item_id` — was appended to whichever item was most recently added, and `output_item.done` for the earlier call then overwrote a sibling's stored arguments (visible as `tasks: Invalid input: expected array, received undefined` on the `task` tool). Open items are now keyed by `item_id` with `output_index` fallback; deltas/done events route to the matching block, late deltas whose item already closed are dropped instead of corrupting a sibling, and `toolcall_*` stream events emit the right `contentIndex` per call ([#2619](https://github.com/can1357/oh-my-pi/issues/2619)). ## [15.13.1] - 2026-06-15 @@ -1598,7 +1598,7 @@ ### Breaking Changes -- The model catalog moved to the new `@oh-my-pi/pi-catalog` package. Deep subpath exports `@oh-my-pi/pi-ai/models.json`, `/models`, `/model-cache`, `/model-manager`, `/model-thinking`, `/effort`, `/provider-models*`, `/utils/discovery*`, `/providers/openai-codex/constants`, `/providers/google-gemini-headers`, and `/providers/openai-completions-compat` are gone — import the `@oh-my-pi/pi-catalog` equivalents (`/models.json`, `/models`, `/model-cache`, `/model-manager`, `/model-thinking`, `/effort`, `/provider-models*`, `/discovery*`, `/wire/codex`, `/wire/gemini-headers`, `/compat/openai`). The pi-ai root barrel re-exports only the model/effort _types_ its own signatures use (`Model`, `Api`, `ThinkingConfig`, `Effort`, `Usage`, compat interfaces) — catalog _values_ (`getBundledModel(s)`, `calculateCost`, `modelsAreEqual`, `clampThinkingLevelForModel`, `DEFAULT_MODEL_PER_PROVIDER`, …) must be imported from `@oh-my-pi/pi-catalog`. +- The model catalog moved to the new `@oh-my-pi/pi-catalog` package. Deep subpath exports `@oh-my-pi/pi-ai/models.json`, `/models`, `/model-cache`, `/model-manager`, `/model-thinking`, `/effort`, `/provider-models*`, `/utils/discovery*`, `/providers/openai-codex/constants`, `/providers/google-gemini-headers`, and `/providers/openai-completions-compat` are gone — import the `@oh-my-pi/pi-catalog` equivalents (`/models.json`, `/models`, `/model-cache`, `/model-manager`, `/model-thinking`, `/effort`, `/provider-models*`, `/discovery*`, `/wire/codex`, `/wire/gemini-headers`, `/compat/openai`). The pi-ai root barrel re-exports only the model/effort *types* its own signatures use (`Model`, `Api`, `ThinkingConfig`, `Effort`, `Usage`, compat interfaces) — catalog *values* (`getBundledModel(s)`, `calculateCost`, `modelsAreEqual`, `clampThinkingLevelForModel`, `DEFAULT_MODEL_PER_PROVIDER`, …) must be imported from `@oh-my-pi/pi-catalog`. - `ProviderDefinition` is now auth-only: `defaultModel`, `createModelManagerOptions`, `catalogDiscovery`, `dynamicModelsAuthoritative`, `allowUnauthenticated`, and `specialModelManager` moved to pi-catalog's `CATALOG_PROVIDERS` table, and `KnownProviderId` was replaced by pi-catalog's `KnownProvider` (registry completeness is enforced by a compile-time check against that union). The pure GitHub Copilot key/endpoint helpers moved from `registry/oauth/github-copilot` to `@oh-my-pi/pi-catalog/wire/github-copilot`. ### Added @@ -1687,7 +1687,7 @@ - Fixed `AnthropicMessagesClient` spreading `fetchOptions` after the core request fields, letting a caller-supplied `signal`/`method`/`body` silently disconnect the timeout controller or corrupt the request. Transport extras (TLS) still pass through; core fields now always win. - Fixed Foundry mTLS/CA material being cached for the process lifetime when the env vars point at files: the cache key now folds in the file mtime so on-disk certificate rotation takes effect. - Fixed the Claude Code fingerprint version drifting across surfaces: the usage endpoint (`claude-cli/2.1.160`) and OAuth bootstrap (`claude-code/2.1.160`) pinned a stale version while `/v1/messages` reported 2.1.165; both now derive from `claudeCodeVersion`. -- Fixed a system prompt that merely _mentions_ `x-anthropic-billing-header:` mid-text suppressing the entire Claude Code system-block injection (billing header, instruction, and cch attestation); the resumed-session guard now anchors with `startsWith`. +- Fixed a system prompt that merely *mentions* `x-anthropic-billing-header:` mid-text suppressing the entire Claude Code system-block injection (billing header, instruction, and cch attestation); the resumed-session guard now anchors with `startsWith`. - Fixed lone surrogates in cross-API tool-call arguments reaching Anthropic's strict UTF-8 validation: replayed OpenAI/Google-origin `tool_use.input` string leaves are now deep-sanitized with `toWellFormed()`, while same-API Anthropic arguments stay byte-identical to keep prompt-cache prefixes stable. - Bounded the many-image resize fan-out to 4 concurrent decodes (it previously decoded every oversized image at once, two encode pipelines each — multi-GB transient memory at the 20+-image threshold that activates the feature). - Fixed `mergeHeaders` merging case-sensitively on the Copilot/client-options path, where a miscased user-configured header (e.g. `authorization` next to the synthesized `Authorization`) survived as two keys that the `Headers` constructor joins comma-separated on the wire. @@ -1748,7 +1748,7 @@ - Fixed `AnthropicMessagesClient` spreading `fetchOptions` after the core request fields, letting a caller-supplied `signal`/`method`/`body` silently disconnect the timeout controller or corrupt the request. Transport extras (TLS) still pass through; core fields now always win. - Fixed Foundry mTLS/CA material being cached for the process lifetime when the env vars point at files: the cache key now folds in the file mtime so on-disk certificate rotation takes effect. - Fixed the Claude Code fingerprint version drifting across surfaces: the usage endpoint (`claude-cli/2.1.160`) and OAuth bootstrap (`claude-code/2.1.160`) pinned a stale version while `/v1/messages` reported 2.1.165; both now derive from `claudeCodeVersion`. -- Fixed a system prompt that merely _mentions_ `x-anthropic-billing-header:` mid-text suppressing the entire Claude Code system-block injection (billing header, instruction, and cch attestation); the resumed-session guard now anchors with `startsWith`. +- Fixed a system prompt that merely *mentions* `x-anthropic-billing-header:` mid-text suppressing the entire Claude Code system-block injection (billing header, instruction, and cch attestation); the resumed-session guard now anchors with `startsWith`. - Fixed lone surrogates in cross-API tool-call arguments reaching Anthropic's strict UTF-8 validation: replayed OpenAI/Google-origin `tool_use.input` string leaves are now deep-sanitized with `toWellFormed()`, while same-API Anthropic arguments stay byte-identical to keep prompt-cache prefixes stable. - Bounded the many-image resize fan-out to 4 concurrent decodes (it previously decoded every oversized image at once, two encode pipelines each — multi-GB transient memory at the 20+-image threshold that activates the feature). - Fixed `mergeHeaders` merging case-sensitively on the Copilot/client-options path, where a miscased user-configured header (e.g. `authorization` next to the synthesized `Authorization`) survived as two keys that the `Headers` constructor joins comma-separated on the wire. @@ -1781,7 +1781,7 @@ ### Fixed - Fixed a degenerate OpenAI Codex stream (the model emits whitespace-only `function_call_arguments.delta` frames forever — commonly seen right after a `todo` tool call) terminating the turn with an error instead of recovering. The whitespace-loop circuit-breaker now (a) stops aborting the shared per-request `AbortController` — `requestSignal` is an `AbortSignal.any` over it, so aborting latched it and made every reopen on the reused `requestSetup` impossible — and (b) drops the half-built junk tool call and replays the request from scratch, bounded by `CODEX_WHITESPACE_LOOP_RETRY_LIMIT` (2). Sampling nondeterminism usually clears the loop on a fresh attempt; once the budget is exhausted the error is surfaced as before, but without the junk tool call polluting the message. -- Capped requested output tokens at 64k (`OPENAI_MAX_OUTPUT_TOKENS`, mirroring Anthropic's `CLAUDE_CODE_MAX_OUTPUT_TOKENS`) on OpenAI-family wires with a known upstream output cap — the `openai-completions` request builder (non-OpenRouter) and the shared responses sampling helper (`openai-responses`, `azure-openai-responses`). A model's catalog `maxTokens` often tracks its context window rather than the upstream's per-request output cap, so requesting the full ceiling 400'd (e.g. `z-ai/glm-4.7` asking for 131072 output exceeded the upstream's 131072-token _total_ context). Output is now `min(requested, model.maxTokens, 64000)`. +- Capped requested output tokens at 64k (`OPENAI_MAX_OUTPUT_TOKENS`, mirroring Anthropic's `CLAUDE_CODE_MAX_OUTPUT_TOKENS`) on OpenAI-family wires with a known upstream output cap — the `openai-completions` request builder (non-OpenRouter) and the shared responses sampling helper (`openai-responses`, `azure-openai-responses`). A model's catalog `maxTokens` often tracks its context window rather than the upstream's per-request output cap, so requesting the full ceiling 400'd (e.g. `z-ai/glm-4.7` asking for 131072 output exceeded the upstream's 131072-token *total* context). Output is now `min(requested, model.maxTokens, 64000)`. - Stopped sending `max_tokens`/`max_completion_tokens` on OpenRouter (`openrouter.ai`) completions requests. OpenRouter filters out any upstream whose advertised output cap is below the requested `max_tokens`, so a value derived from the catalog (which reflects the highest-cap provider) silently excluded lower-cap upstreams — `provider.order: ["cerebras"]` for `z-ai/glm-4.7` fell through to DeepInfra because Cerebras's ~40k output cap is below the request, while `only: ["cerebras"]` (no fallback target) bypassed the filter and worked. Omitting the field lets each upstream self-cap and keeps provider routing (`only`/`order`) honored. Kimi via OpenRouter stays exempt — it derives TPM rate limits from `max_tokens`. ## [15.10.7] - 2026-06-08 @@ -1979,7 +1979,7 @@ - Reasoning models now append `effort-2025-11-24` to the per-request `Anthropic-Beta` header (matches Claude Code). - `buildAnthropicSystemBlocks` (CC-instruction mode) now emits the same 3-block layout as Claude Code: billing header (never cached), system instruction (cached), all user content merged into one block with `\n\n` (cached). Previously emitted one block per item with cache only on the last, which fingerprinted the caller by block count. - `applyPromptCaching` now matches Claude Code's breakpoint layout: 2 system (instruction + merged content) + 2 message, with no tool breakpoint. The tool breakpoint was redundant — tools follow system in the token sequence, so when system changes the tool cache prefix also changes. The instruction block (system[1]) is stable across every request and now gets its own guaranteed-hit breakpoint. -- `applyPromptCaching` now caches the last two messages regardless of role instead of the last two _user_ messages. The penultimate assistant message (tool calls + response from the previous turn) is larger and more recently created than the penultimate user message, making it the higher-value cache target. +- `applyPromptCaching` now caches the last two messages regardless of role instead of the last two *user* messages. The penultimate assistant message (tool calls + response from the previous turn) is larger and more recently created than the penultimate user message, making it the higher-value cache target. - OAuth scope set expanded: added `user:sessions:claude_code`, `user:mcp_servers`, `user:file_upload`. `AUTHORIZE_URL` stays at `claude.ai/oauth/authorize` and `TOKEN_URL` stays at `api.anthropic.com/v1/oauth/token` — the `platform.claude.com` equivalents are CC's console-credential flow and do not grant `user:inference`, which OMP requires for direct OAuth-token inference. - Token refresh POST now sends `anthropic-beta: oauth-2025-04-20` and `User-Agent: anthropic-sdk-typescript/0.94.0 userOAuthProvider` (CC sends these on refresh but not on the initial code exchange). diff --git a/packages/ai/test/cline-pass-transport.test.ts b/packages/ai/test/cline-pass-transport.test.ts index 5daed14af3c5..e5af034acd81 100644 --- a/packages/ai/test/cline-pass-transport.test.ts +++ b/packages/ai/test/cline-pass-transport.test.ts @@ -44,12 +44,56 @@ function completionResponse(model: string): Response { ); } +function toolCompletionResponse(model: string): Response { + const events = [ + { + id: "cline-pass-tool-test", + object: "chat.completion.chunk", + created: 0, + model, + choices: [ + { + index: 0, + delta: { + reasoning: "Inspect the marker.", + tool_calls: [ + { + index: 0, + id: "call_marker", + type: "function", + function: { name: "get_marker", arguments: '{"value":42}' }, + }, + ], + }, + }, + ], + }, + { + id: "cline-pass-tool-test", + object: "chat.completion.chunk", + created: 0, + model, + choices: [{ index: 0, delta: {}, finish_reason: "tool_calls" }], + }, + "[DONE]", + ]; + return new Response( + `${events.map(event => `data: ${typeof event === "string" ? event : JSON.stringify(event)}`).join("\n\n")}\n\n`, + { headers: { "content-type": "text/event-stream" } }, + ); +} + async function capturePayload(options: { + modelId?: string; + context?: Context; reasoning?: Effort; disableReasoning?: boolean; toolChoice?: { type: "tool"; name: string }; }): Promise> { - const model = getBundledModel<"openai-completions">("cline-pass", "kimi-k3") as Model<"openai-completions">; + const model = getBundledModel<"openai-completions">( + "cline-pass", + options.modelId ?? "kimi-k3", + ) as Model<"openai-completions">; let payload: Record | undefined; const fetchMock: FetchImpl = Object.assign( async (_input: string | URL | Request, init?: RequestInit): Promise => { @@ -58,7 +102,7 @@ async function capturePayload(options: { }, { preconnect: fetch.preconnect }, ); - await streamOpenAICompletions(model, context, { + await streamOpenAICompletions(model, options.context ?? context, { apiKey: "test-key", fetch: fetchMock, maxTokens: 64, @@ -91,4 +135,58 @@ describe("ClinePass OpenAI transport", () => { expect(payload.reasoning_effort).toBe("none"); expect(payload.model).toBe("cline-pass/kimi-k3"); }); + + it("downgrades a forced ClinePass Qwen tool choice to auto while preserving reasoning", async () => { + const payload = await capturePayload({ + modelId: "qwen3.7-max", + reasoning: Effort.Low, + toolChoice: { type: "tool", name: "get_marker" }, + }); + + expect(payload.model).toBe("cline-pass/qwen3.7-max"); + expect(payload.reasoning_effort).toBe("low"); + expect(payload.tool_choice).toBe("auto"); + }); + + it("serializes a Qwen tool continuation without requiring reasoning replay", async () => { + const model = getBundledModel<"openai-completions">("cline-pass", "qwen3.7-max") as Model<"openai-completions">; + const firstFetch: FetchImpl = Object.assign(async () => toolCompletionResponse(model.id), { + preconnect: fetch.preconnect, + }); + const assistant = await streamOpenAICompletions(model, context, { + apiKey: "test-key", + fetch: firstFetch, + maxTokens: 64, + reasoning: Effort.Low, + }).result(); + const payload = await capturePayload({ + modelId: "qwen3.7-max", + context: { + ...context, + messages: [ + ...context.messages, + assistant, + { + role: "toolResult", + toolCallId: "call_marker", + toolName: "get_marker", + content: [{ type: "text", text: "42" }], + isError: false, + timestamp: 1, + }, + ], + }, + reasoning: Effort.Low, + }); + const messages = payload.messages as Array>; + const wireAssistant = messages.find(message => message.role === "assistant"); + + expect(assistant.content).toContainEqual({ + type: "thinking", + thinking: "Inspect the marker.", + thinkingSignature: "reasoning", + }); + expect(wireAssistant?.tool_calls).toBeArray(); + expect(wireAssistant?.reasoning).toBeUndefined(); + }); }); diff --git a/packages/catalog/src/compat/openai.ts b/packages/catalog/src/compat/openai.ts index 31fcac4dcae1..db2875be2781 100644 --- a/packages/catalog/src/compat/openai.ts +++ b/packages/catalog/src/compat/openai.ts @@ -285,6 +285,7 @@ export function buildOpenAICompat(spec: ModelSpec<"openai-completions">): Resolv const provider = spec.provider; const baseUrl = spec.baseUrl; const hostModel = { provider, baseUrl }; + const isClinePass = provider === "cline-pass"; const isCerebras = modelMatchesHost(hostModel, "cerebras"); const isZai = modelMatchesHost(hostModel, "zai"); @@ -444,7 +445,6 @@ export function buildOpenAICompat(spec: ModelSpec<"openai-completions">): Resolv // namespace (`accounts/fireworks/routers/-fast`), like Fire Pass, rather // than the `models/` namespace the rest of the `fireworks` provider uses. const isFireworksFastRouter = provider === "fireworks" && isFireworksFastModelId(spec.id); - const isClinePass = provider === "cline-pass"; const wireModelIdMode: ResolvedOpenAISharedCompat["wireModelIdMode"] = provider === "firepass" || isFireworksFastRouter ? "firepass" @@ -504,12 +504,12 @@ export function buildOpenAICompat(spec: ModelSpec<"openai-completions">): Resolv disableReasoningOnForcedToolChoice: !isClinePass && ((isKimiModel && !isMoonshotKimiK3) || isAnthropicModel), disableReasoningOnToolChoice: !isClinePass && isDeepseekFamily && Boolean(spec.reasoning) && !isOpenRouter, supportsToolChoice: isClinePass || !isDirectDeepseekReasoning, - // DeepSeek reasoning models on OpenCode Zen/Go 400 with - // "Thinking mode does not support this tool_choice" when a specific - // function is forced while the gateway's default thinking mode is active. - // Downgrade only on those gateways: other hosts can turn thinking off via - // disableReasoningOnToolChoice and must retain hard tool selection. - supportsForcedToolChoice: !requiresEnabledThinking && !(isOpenCodeHost && isDeepseekReasoning), + // DeepSeek reasoning models on OpenCode Zen/Go and Qwen models on + // ClinePass reject a specific function choice while the gateway's + // default thinking mode is active. Downgrade only on those gateways: + // other hosts can turn thinking off and retain hard tool selection. + supportsForcedToolChoice: + !requiresEnabledThinking && !(isOpenCodeHost && isDeepseekReasoning) && !(isClinePass && isQwen), supportsNamedToolChoice: STRING_ONLY_NAMED_TOOL_CHOICE_PROVIDERS[provider] !== true, maxTokensField: useMaxTokens ? "max_tokens" : "max_completion_tokens", requiresToolResultName: isMistral, @@ -534,9 +534,9 @@ export function buildOpenAICompat(spec: ModelSpec<"openai-completions">): Resolv reasoningContentField: isClinePass ? "reasoning" : "reasoning_content", // Backends that reject follow-up requests when prior assistant tool-call // turns lack their reasoning replay field: - // - ClinePass streams `reasoning`; native Kimi uses `reasoning_content`. + // - ClinePass names the field `reasoning`; only the family predicates + // below decide whether a Cline-hosted model requires replay. // - DeepSeek-family reasoning models, including aliased OpenCode Zen models - // like `big-pickle`, validate exact thinking-mode replay. // - Xiaomi MiMo models require exact `reasoning_content` replay on // thinking-mode tool-call continuations across standard and Token Plan hosts. // - Any reasoning-capable model reached through OpenRouter can enforce this diff --git a/packages/catalog/src/provider-models/descriptors.ts b/packages/catalog/src/provider-models/descriptors.ts index e8e6fcd33a50..b64e41317fc2 100644 --- a/packages/catalog/src/provider-models/descriptors.ts +++ b/packages/catalog/src/provider-models/descriptors.ts @@ -171,7 +171,6 @@ export const CATALOG_PROVIDERS = [ defaultModel: "kimi-k3", envVars: ["CLINE_API_KEY"], createModelManagerOptions: (config: ModelManagerConfig) => clinePassModelManagerOptions(config), - allowUnauthenticated: true, dynamicModelsAuthoritative: true, catalogDiscovery: { label: "ClinePass", allowUnauthenticated: true }, }, diff --git a/packages/catalog/src/provider-models/openai-compat.ts b/packages/catalog/src/provider-models/openai-compat.ts index 76f7bdd05f8d..bf98f506f82c 100644 --- a/packages/catalog/src/provider-models/openai-compat.ts +++ b/packages/catalog/src/provider-models/openai-compat.ts @@ -2183,10 +2183,17 @@ async function fetchClinePassModels( const models = new Map>(); for (const entry of payload.clinePass) { - if (!isRecord(entry) || typeof entry.id !== "string" || !entry.id.startsWith("cline-pass/")) { + if (!isRecord(entry) || typeof entry.id !== "string") { + continue; + } + const wireId = entry.id.trim(); + if (!wireId.startsWith("cline-pass/")) { + continue; + } + const id = toClinePassPublicModelId(wireId).trim(); + if (!id) { continue; } - const id = toClinePassPublicModelId(entry.id); models.set(id, references.get(id) ?? buildClinePassFallbackModel(id)); } if (models.size === 0) { diff --git a/packages/catalog/test/cline-pass-compat.test.ts b/packages/catalog/test/cline-pass-compat.test.ts index 8b17d189a67f..238f7c438098 100644 --- a/packages/catalog/test/cline-pass-compat.test.ts +++ b/packages/catalog/test/cline-pass-compat.test.ts @@ -2,49 +2,97 @@ import { describe, expect, it } from "bun:test"; import { toClinePassPublicModelId, toClinePassWireModelId } from "@oh-my-pi/pi-catalog/cline-pass-model-id"; import { buildOpenAICompat } from "@oh-my-pi/pi-catalog/compat/openai"; import { Effort } from "@oh-my-pi/pi-catalog/effort"; -import { getBundledModel, getBundledModels } from "@oh-my-pi/pi-catalog/models"; -import { DEFAULT_MODEL_PER_PROVIDER } from "@oh-my-pi/pi-catalog/provider-models"; -import { toModelSpec } from "@oh-my-pi/pi-catalog/provider-models/bundled-references"; +import { + DEFAULT_MODEL_PER_PROVIDER, + MODELS_DEV_PROVIDER_DESCRIPTORS, + mapModelsDevToModels, + PROVIDER_DESCRIPTORS, +} from "@oh-my-pi/pi-catalog/provider-models"; import { clinePassModelManagerOptions } from "@oh-my-pi/pi-catalog/provider-models/openai-compat"; +import type { ModelSpec } from "@oh-my-pi/pi-catalog/types"; +const CLINEPASS_MODELS_DEV_FIXTURE = { + "cline-pass": { + models: { + "cline-pass/kimi-k3": { + id: "cline-pass/kimi-k3", + name: "Kimi K3", + tool_call: true, + reasoning: true, + modalities: { input: ["text", "image"] }, + limit: { context: 1_048_576, output: 131_072 }, + cost: { input: 9, output: 12 }, + reasoning_options: [{ type: "effort", values: ["none", "low", "medium", "high", "xhigh", "max"] }], + }, + "cline-pass/qwen3.7-max": { + id: "cline-pass/qwen3.7-max", + name: "Qwen3.7 Max", + tool_call: true, + reasoning: true, + modalities: { input: ["text"] }, + limit: { context: 1_000_000, output: 384_000 }, + cost: { input: 5, output: 10 }, + }, + }, + }, +}; + +const sourceModels = mapModelsDevToModels(CLINEPASS_MODELS_DEV_FIXTURE, MODELS_DEV_PROVIDER_DESCRIPTORS).filter( + model => model.provider === "cline-pass", +); + +function sourceModel(id: string): ModelSpec<"openai-completions"> { + const model = sourceModels.find(candidate => candidate.id === id); + if (model?.api !== "openai-completions") { + throw new Error(`Missing ClinePass source fixture model: ${id}`); + } + return model as ModelSpec<"openai-completions">; +} describe("ClinePass catalog", () => { - it("bundles an offline subscription fallback under stable public IDs", () => { - const models = getBundledModels("cline-pass"); - - expect(models.map(model => model.id)).toEqual([ - "deepseek-v4-flash", - "deepseek-v4-pro", - "glm-5.2", - "kimi-k2.6", - "kimi-k2.7-code", - "kimi-k3", - "mimo-v2.5", - "mimo-v2.5-pro", - "minimax-m3", - "qwen3.7-max", - "qwen3.7-plus", - "qwen3.8-max", - ]); + it("maps source metadata into the subscription catalog contract", () => { + const model = sourceModel("kimi-k3"); + const descriptor = PROVIDER_DESCRIPTORS.find(candidate => candidate.providerId === "cline-pass"); + expect(DEFAULT_MODEL_PER_PROVIDER["cline-pass"]).toBe("kimi-k3"); - expect(models.every(model => model.cost.input === 0 && model.cost.output === 0)).toBe(true); + expect(descriptor).toMatchObject({ + providerId: "cline-pass", + dynamicModelsAuthoritative: true, + catalogDiscovery: { + label: "ClinePass", + envVars: ["CLINE_API_KEY"], + allowUnauthenticated: true, + }, + }); + expect(descriptor?.allowUnauthenticated).toBeUndefined(); + expect(model).toMatchObject({ + id: "kimi-k3", + name: "Kimi K3", + api: "openai-completions", + provider: "cline-pass", + baseUrl: "https://api.cline.bot/api/v1", + reasoning: true, + input: ["text", "image"], + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + contextWindow: 1_048_576, + maxTokens: 131_072, + }); }); - it("preserves Cline's full reasoning ladder and published Kimi K3 limits", () => { - const model = getBundledModel<"openai-completions">("cline-pass", "kimi-k3"); - - expect(model.contextWindow).toBe(1_048_576); - expect(model.maxTokens).toBe(131_072); - expect(model.input).toEqual(["text", "image"]); - expect(model.thinking?.mode).toBe("effort"); - expect(model.thinking?.efforts).toEqual([ - Effort.Minimal, - Effort.Low, - Effort.Medium, - Effort.High, - Effort.XHigh, - Effort.Max, - ]); - expect(model.thinking?.defaultLevel).toBe(Effort.Max); + it("maps Cline's full reasoning ladder from source metadata", () => { + const model = sourceModel("kimi-k3"); + + expect(model.thinking).toEqual({ + mode: "effort", + efforts: [Effort.Minimal, Effort.Low, Effort.Medium, Effort.High, Effort.XHigh, Effort.Max], + effortMap: { + minimal: "none", + low: "low", + medium: "medium", + high: "high", + xhigh: "xhigh", + max: "max", + }, + }); }); it("uses the Cline wire namespace without exposing it in model selection", () => { @@ -55,8 +103,8 @@ describe("ClinePass catalog", () => { }); it("applies the verified Cline gateway request and reasoning compatibility", () => { - const model = getBundledModel<"openai-completions">("cline-pass", "kimi-k3"); - const compat = buildOpenAICompat(toModelSpec(model)); + const model = sourceModel("kimi-k3"); + const compat = buildOpenAICompat(model); expect(compat.wireModelIdMode).toBe("cline-pass"); expect(compat.maxTokensField).toBe("max_completion_tokens"); @@ -77,7 +125,15 @@ describe("ClinePass catalog", () => { expect(compat.disableReasoningOnForcedToolChoice).toBe(false); }); - it("discovers the authoritative roster without credentials and supports new model IDs", async () => { + it("downgrades forced tools for ClinePass Qwen without requiring reasoning replay", () => { + const compat = buildOpenAICompat(sourceModel("qwen3.7-max")); + + expect(compat.supportsForcedToolChoice).toBe(false); + expect(compat.reasoningContentField).toBe("reasoning"); + expect(compat.requiresReasoningContentForToolCalls).toBe(false); + }); + + it("discovers the authoritative public roster and supports new model IDs", async () => { const requests: string[] = []; const options = clinePassModelManagerOptions({ fetch: async input => { @@ -86,7 +142,7 @@ describe("ClinePass catalog", () => { JSON.stringify({ clinePass: [ { id: "cline-pass/kimi-k3", name: "cline-pass/kimi-k3" }, - { id: "cline-pass/future-model", name: "cline-pass/future-model" }, + { id: " cline-pass/future-model ", name: "cline-pass/future-model" }, ], }), { status: 200, headers: { "Content-Type": "application/json" } }, @@ -112,13 +168,20 @@ describe("ClinePass catalog", () => { }); }); - it("rejects an empty authoritative roster so the bundled fallback remains available", async () => { + it("rejects an empty or malformed authoritative roster so the bundled fallback remains available", async () => { const options = clinePassModelManagerOptions({ fetch: async () => - new Response(JSON.stringify({ clinePass: [] }), { - status: 200, - headers: { "Content-Type": "application/json" }, - }), + new Response( + JSON.stringify({ + clinePass: [ + { id: "cline-pass/" }, + { id: "cline-pass/ " }, + { id: " " }, + { id: "other-provider/model" }, + ], + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ), }); await expect(options.fetchDynamicModels?.()).rejects.toThrow("contains no valid model IDs"); diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index bd81a6f64bea..d8417d4905c5 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- Added `CLINE_API_KEY` to the CLI environment help for native ClinePass subscription inference ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). + ## [17.2.10] - 2026-08-06 ### Breaking Changes diff --git a/packages/coding-agent/test/model-registry-runtime-provider.test.ts b/packages/coding-agent/test/model-registry-runtime-provider.test.ts index f7280e48c08e..72ef01b03dae 100644 --- a/packages/coding-agent/test/model-registry-runtime-provider.test.ts +++ b/packages/coding-agent/test/model-registry-runtime-provider.test.ts @@ -22,6 +22,7 @@ describe("ModelRegistry runtime provider registration", () => { let modelsJsonPath: string; let authStorage: AuthStorage; let registry: ModelRegistry; + let fetchRequests: string[]; const sourceIds = ["ext://atomic", "ext://runtime", "ext://oauth"]; @@ -29,9 +30,13 @@ describe("ModelRegistry runtime provider registration", () => { // online discovery path with deterministic, instant failures instead of real // network. Provider fetches (dynamic + stencil.so) are caught and swallowed, // leaving the registry with its bundled catalog plus runtime overlays. - const offlineFetch: FetchImpl = () => Promise.reject(new Error("network disabled in model-registry runtime test")); + const offlineFetch: FetchImpl = input => { + fetchRequests.push(String(input)); + return Promise.reject(new Error("network disabled in model-registry runtime test")); + }; beforeEach(async () => { + fetchRequests = []; tempDir = path.join(os.tmpdir(), `pi-test-model-registry-runtime-${Snowflake.next()}`); fs.mkdirSync(tempDir, { recursive: true }); modelsJsonPath = path.join(tempDir, "models.json"); @@ -120,6 +125,18 @@ describe("ModelRegistry runtime provider registration", () => { expect(registry.find(providerName, modelId)?.headers?.[headerName]).toBe(headerValue); } + test("does not discover ClinePass without credentials", async () => { + const peek = vi.spyOn(authStorage, "peekApiKey").mockResolvedValue(undefined); + try { + await registry.refresh("online"); + } finally { + peek.mockRestore(); + } + + expect(fetchRequests).not.toContain("https://api.cline.bot/api/v1/ai/cline/recommended-models"); + expect(registry.find("cline-pass", "kimi-k3")).toBeDefined(); + }); + test("validates provider config before mutating custom API state", () => { const beforeAnthropicCount = registry.getAll().filter(model => model.provider === "anthropic").length; From f6986c9b346e3bbd0f15aa477e95b923635fbb98 Mon Sep 17 00:00:00 2001 From: roboomp Date: Sat, 8 Aug 2026 03:54:26 +0000 Subject: [PATCH 009/795] fix(ai): retried replay-safe openai stream failures - Added bounded pre-output retries for transient OpenAI-family stream errors. - Reused the shared provider classifier for socket-close failures. - Preserved replay guards once text, thinking, image, or tool output commits. Fixes #7979 --- packages/ai/CHANGELOG.md | 4 + packages/ai/src/providers/anthropic.ts | 13 +- .../src/providers/azure-openai-responses.ts | 14 +- packages/ai/src/providers/ollama.ts | 6 +- .../src/providers/openai-codex-responses.ts | 6 +- .../ai/src/providers/openai-completions.ts | 14 +- packages/ai/src/providers/openai-responses.ts | 16 +- .../ai/src/utils/empty-completion-retry.ts | 108 ++++--- .../ai/test/empty-completion-retry.test.ts | 178 ++++++++--- .../test/openai-stream-socket-retry.test.ts | 277 ++++++++++++++++++ 10 files changed, 526 insertions(+), 110 deletions(-) create mode 100644 packages/ai/test/openai-stream-socket-retry.test.ts diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 7d56710924f9..fe8ed4fd013f 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Retried transient mid-stream socket closures for OpenAI Responses, Chat Completions, Azure OpenAI Responses, and Codex SSE when no replay-unsafe output was emitted ([#7979](https://github.com/can1357/oh-my-pi/issues/7979)). + ## [17.2.11] - 2026-08-07 ### Breaking Changes diff --git a/packages/ai/src/providers/anthropic.ts b/packages/ai/src/providers/anthropic.ts index f83d7e39da51..3a494afcfa30 100644 --- a/packages/ai/src/providers/anthropic.ts +++ b/packages/ai/src/providers/anthropic.ts @@ -54,7 +54,7 @@ import { kStreamingLastParseLen, kStreamingPartialJson, } from "../utils/block-symbols"; -import { withEmptyCompletionRetry } from "../utils/empty-completion-retry"; +import { withReplaySafeStreamRetry } from "../utils/empty-completion-retry"; import { AssistantMessageEventStream } from "../utils/event-stream"; import { isFoundryEnabled } from "../utils/foundry"; import { finalizeErrorMessage, type RawHttpRequestDump } from "../utils/http-inspector"; @@ -2795,14 +2795,13 @@ const streamAnthropicOnce = ( }; /** - * Public entry: wrap the single-attempt streamer with bounded empty-completion - * retries (a benign terminal stop carrying no content/usage would otherwise - * stall the agent loop). The inner attempt keeps its own provider-failure retry - * loop; this layer only re-issues a fresh request on an empty success. Shared - * with the OpenAI-completions provider via `withEmptyCompletionRetry`. + * Public entry: retry benign empty completions before they reach the agent + * loop. The inner attempt owns Anthropic provider-failure retries. */ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (model, context, options) => - withEmptyCompletionRetry(model, context, options, streamAnthropicOnce); + withReplaySafeStreamRetry(model, context, options, streamAnthropicOnce, { + retryEmptyCompletion: true, + }); export type AnthropicSystemBlock = { type: "text"; diff --git a/packages/ai/src/providers/azure-openai-responses.ts b/packages/ai/src/providers/azure-openai-responses.ts index 332e37d2c006..2a7a8d9c2f07 100644 --- a/packages/ai/src/providers/azure-openai-responses.ts +++ b/packages/ai/src/providers/azure-openai-responses.ts @@ -13,6 +13,7 @@ import type { } from "../types"; import { resolveCacheRetention } from "../utils"; import { createAbortSourceTracker } from "../utils/abort"; +import { withReplaySafeStreamRetry } from "../utils/empty-completion-retry"; import { AssistantMessageEventStream } from "../utils/event-stream"; import type { RawHttpRequestDump } from "../utils/http-inspector"; import { @@ -75,10 +76,8 @@ type AzureOpenAIResponsesSamplingParams = ResponseCreateParamsStreaming & { repetition_penalty?: number; }; -/** - * Generate function for Azure OpenAI Responses API - */ -export const streamAzureOpenAIResponses: StreamFunction<"azure-openai-responses"> = ( +/** Runs one Azure OpenAI Responses request and decodes its event stream. */ +const streamAzureOpenAIResponsesOnce = ( model: Model<"azure-openai-responses">, context: Context, options?: AzureOpenAIResponsesOptions, @@ -264,6 +263,13 @@ export const streamAzureOpenAIResponses: StreamFunction<"azure-openai-responses" return stream; }; +/** Retries transient Azure stream failures only before assistant output commits the attempt. */ +export const streamAzureOpenAIResponses: StreamFunction<"azure-openai-responses"> = (model, context, options) => + withReplaySafeStreamRetry(model, context, options, streamAzureOpenAIResponsesOnce, { + retryProviderErrors: true, + maxProviderErrorRetries: 1, + }); + function resolveAzureConfig( model: Model<"azure-openai-responses">, options?: AzureOpenAIResponsesOptions, diff --git a/packages/ai/src/providers/ollama.ts b/packages/ai/src/providers/ollama.ts index f6e0b1e7d968..ddf23c7fee26 100644 --- a/packages/ai/src/providers/ollama.ts +++ b/packages/ai/src/providers/ollama.ts @@ -16,7 +16,7 @@ import type { } from "../types"; import { normalizeSystemPrompts } from "../utils"; import { clearStreamingPartialJson, kStreamingPartialJson } from "../utils/block-symbols"; -import { withEmptyCompletionRetry } from "../utils/empty-completion-retry"; +import { withReplaySafeStreamRetry } from "../utils/empty-completion-retry"; import { AssistantMessageEventStream } from "../utils/event-stream"; import type { CapturedHttpErrorResponse, RawHttpRequestDump } from "../utils/http-inspector"; import { @@ -773,4 +773,6 @@ const streamOllamaOnce = ( /** Retry EOS-only Ollama completions before the agent loop sees an empty stop. */ export const streamOllama: StreamFunction<"ollama-chat"> = (model, context, options) => - withEmptyCompletionRetry(model, context, options, streamOllamaOnce); + withReplaySafeStreamRetry(model, context, options, streamOllamaOnce, { + retryEmptyCompletion: true, + }); diff --git a/packages/ai/src/providers/openai-codex-responses.ts b/packages/ai/src/providers/openai-codex-responses.ts index 9e320b70c129..52c0c5b3ce67 100644 --- a/packages/ai/src/providers/openai-codex-responses.ts +++ b/packages/ai/src/providers/openai-codex-responses.ts @@ -2722,8 +2722,12 @@ class CodexStreamProcessor { } async #tryRetryProviderError(error: unknown): Promise { + const retryable = + error instanceof CodexProviderStreamError + ? error.retryable + : AIError.isProviderRetryableError(error, { provider: this.model.provider }); if ( - !(error instanceof CodexProviderStreamError && error.retryable) || + !retryable || this.output.content.length > 0 || this.runtime.providerRetryAttempt >= CODEX_MAX_RETRIES || this.options?.signal?.aborted diff --git a/packages/ai/src/providers/openai-completions.ts b/packages/ai/src/providers/openai-completions.ts index d60c1004cc54..c26be1693fe4 100644 --- a/packages/ai/src/providers/openai-completions.ts +++ b/packages/ai/src/providers/openai-completions.ts @@ -30,7 +30,7 @@ import type { import { normalizeSystemPrompts, resolveCacheRetention } from "../utils"; import { createAbortSourceTracker } from "../utils/abort"; import { isDemotedThinking, kStreamingLastParseLen } from "../utils/block-symbols"; -import { hasVisibleAssistantContent, withEmptyCompletionRetry } from "../utils/empty-completion-retry"; +import { hasVisibleAssistantContent, withReplaySafeStreamRetry } from "../utils/empty-completion-retry"; import { AssistantMessageEventStream } from "../utils/event-stream"; import type { RawHttpRequestDump } from "../utils/http-inspector"; import { @@ -1382,13 +1382,15 @@ const streamOpenAICompletionsOnce = ( }; /** - * Public entry: wrap the single-attempt streamer with bounded empty-completion - * retries — flaky gateways occasionally 200 with `delta: {}` + `finish_reason: - * "stop"` and no usage, which would otherwise stall the agent loop. Shared with - * the Anthropic provider via `withEmptyCompletionRetry`. + * Retries benign empty completions and transient provider failures only before + * assistant output commits the attempt. */ export const streamOpenAICompletions: StreamFunction<"openai-completions"> = (model, context, options) => - withEmptyCompletionRetry(model, context, options, streamOpenAICompletionsOnce); + withReplaySafeStreamRetry(model, context, options, streamOpenAICompletionsOnce, { + retryEmptyCompletion: true, + retryProviderErrors: true, + maxProviderErrorRetries: 1, + }); function createRequestSetup( model: Model<"openai-completions">, diff --git a/packages/ai/src/providers/openai-responses.ts b/packages/ai/src/providers/openai-responses.ts index ed659a49a18b..c6ef0ebcd5d0 100644 --- a/packages/ai/src/providers/openai-responses.ts +++ b/packages/ai/src/providers/openai-responses.ts @@ -24,7 +24,7 @@ import { sanitizeOpenAIResponsesAssistantHistoryItemsForReplay, } from "../utils"; import { createAbortSourceTracker } from "../utils/abort"; -import { withEmptyCompletionRetry } from "../utils/empty-completion-retry"; +import { withReplaySafeStreamRetry } from "../utils/empty-completion-retry"; import { AssistantMessageEventStream } from "../utils/event-stream"; import type { RawHttpRequestDump } from "../utils/http-inspector"; import { @@ -186,7 +186,8 @@ function isOpenAIResponsesReplayUnsafeEvent(event: ResponseStreamEvent): boolean function isRetryableOpenAIResponsesStreamFailure(error: unknown): boolean { return ( AIError.isTransientStreamParseError(error) || - (error instanceof AIError.ProviderResponseError && error.kind === "incomplete-stream") + (error instanceof AIError.ProviderResponseError && error.kind === "incomplete-stream") || + AIError.isProviderRetryableError(error) ); } @@ -881,13 +882,14 @@ const streamOpenAIResponsesOnce = ( }; /** - * Public entry: wrap the single-attempt Responses streamer with bounded - * empty-completion retries — a `response.completed` carrying no content/usage - * would otherwise stall the agent loop. Shared with the OpenAI-completions and - * Anthropic providers via `withEmptyCompletionRetry`. + * Public entry: retry benign empty completions before they reach the agent + * loop. Transient stream failures are retried inside the attempt so stateful + * Responses request metadata remains stable. */ export const streamOpenAIResponses: StreamFunction<"openai-responses"> = (model, context, options) => - withEmptyCompletionRetry(model, context, options, streamOpenAIResponsesOnce); + withReplaySafeStreamRetry(model, context, options, streamOpenAIResponsesOnce, { + retryEmptyCompletion: true, + }); function isOfficialOpenAIResponsesEndpoint(model: Model<"openai-responses">): boolean { if (model.provider !== "openai") return false; diff --git a/packages/ai/src/utils/empty-completion-retry.ts b/packages/ai/src/utils/empty-completion-retry.ts index 3af9337e5a6d..c5b19c7d9fdc 100644 --- a/packages/ai/src/utils/empty-completion-retry.ts +++ b/packages/ai/src/utils/empty-completion-retry.ts @@ -1,23 +1,18 @@ /** - * Bounded retries for an empty assistant completion. + * Replay-safe retries for provider streams. * - * Some providers — and especially flaky OpenAI-/Anthropic-compatible gateways — - * intermittently return a benign terminal stop carrying no content and no usage - * (e.g. a single OpenAI `delta: {}` + `finish_reason: "stop"` chunk). Delivered - * as-is the agent loop has nothing to act on and silently halts mid-task, so the - * request must be retried instead of surfaced. + * A provider attempt can be discarded only until meaningful assistant output is + * emitted. Pre-output markers are buffered so transient transport failures and + * benign empty completions can re-issue a fresh request without duplicating + * content; the first text, thinking, image, or tool event commits the attempt + * and restores live streaming. * - * This wraps a single-attempt provider stream and re-invokes it (a fresh request - * with its own message state) when an attempt produces no meaningful content. - * Only a stream that streamed nothing meaningful is retried: the moment any - * text/thinking/tool delta is forwarded the attempt is committed, so live - * streaming (including thinking) is never delayed, retried, or duplicated. - * - * Mirrors the Gemini empty-response policy in `google-shared` (which keeps its - * own integrated loop) and is shared by the OpenAI-completions and - * Anthropic-messages providers. + * Empty-completion retries remain opt-in because a normal empty stop can be a + * valid provider result. Transient-error retries use the shared provider error + * classifier and are separately bounded by the caller's policy. */ import { scheduler } from "node:timers/promises"; +import * as AIError from "../error"; import type { AssistantMessage, AssistantMessageEvent, Context } from "../types"; import { AssistantMessageEventStream } from "./event-stream"; @@ -60,26 +55,49 @@ function isMeaningfulCompletionEvent(event: AssistantMessageEvent): boolean { } } -interface EmptyCompletionRetryOptions { +interface StreamRetryOptions { signal?: AbortSignal; providerRetryWait?: (delayMs: number, signal?: AbortSignal) => Promise; } +/** Controls which replay-safe provider results may issue a fresh request. */ +export interface ReplaySafeStreamRetryPolicy { + /** Retry benign terminal stops that contain no visible output. */ + retryEmptyCompletion?: boolean; + /** Retry transient provider errors before output is committed. */ + retryProviderErrors?: boolean; + /** Maximum transient provider-error retries; empty completions keep their shared fixed budget. */ + maxProviderErrorRetries?: number; +} + +class FinalizedProviderStreamError extends Error { + readonly status?: number; + + constructor(message: string, status: number | undefined) { + super(message); + this.name = "FinalizedProviderStreamError"; + this.status = status; + } +} + /** - * Wrap a single-attempt provider stream with bounded empty-completion retries. - * `attempt` MUST create a fresh request (and its own output message) on each - * call so a retry never inherits stale metadata from an empty attempt. + * Re-issues a fresh provider request only while the current attempt remains + * replay-safe. Buffered pre-output events from discarded attempts never reach + * consumers. */ -export function withEmptyCompletionRetry( +export function withReplaySafeStreamRetry( model: M, context: Context, options: O | undefined, attempt: (model: M, context: Context, options?: O) => AssistantMessageEventStream, + policy: ReplaySafeStreamRetryPolicy, ): AssistantMessageEventStream { const outer = new AssistantMessageEventStream(); const signal = options?.signal; void (async () => { - for (let emptyAttempt = 0; ; emptyAttempt++) { + let emptyRetries = 0; + let providerErrorRetries = 0; + while (true) { const inner = attempt(model, context, options); const buffered: AssistantMessageEvent[] = []; let committed = false; @@ -94,8 +112,6 @@ export function withEmptyCompletionRetry { +describe("withReplaySafeStreamRetry", () => { it("retries past empty attempts and delivers the first non-empty one", async () => { let attempts = 0; const waits: number[] = []; - const stream = withEmptyCompletionRetry({}, CTX, { providerRetryWait: async ms => void waits.push(ms) }, () => { - attempts++; - return attempts <= MAX_EMPTY_COMPLETION_RETRIES ? emptyAttempt() : contentAttempt(); - }); + const stream = withReplaySafeStreamRetry( + {}, + CTX, + { providerRetryWait: async ms => void waits.push(ms) }, + () => { + attempts++; + return attempts <= MAX_EMPTY_COMPLETION_RETRIES ? emptyAttempt() : contentAttempt(); + }, + { retryEmptyCompletion: true }, + ); const events = await drain(stream); const result = await stream.result(); @@ -103,10 +107,16 @@ describe("withEmptyCompletionRetry", () => { it("retries an EOS-only empty stop that reports one output token", async () => { let attempts = 0; const waits: number[] = []; - const stream = withEmptyCompletionRetry({}, CTX, { providerRetryWait: async ms => void waits.push(ms) }, () => { - attempts++; - return attempts === 1 ? eosOnlyAttempt() : contentAttempt(); - }); + const stream = withReplaySafeStreamRetry( + {}, + CTX, + { providerRetryWait: async ms => void waits.push(ms) }, + () => { + attempts++; + return attempts === 1 ? eosOnlyAttempt() : contentAttempt(); + }, + { retryEmptyCompletion: true }, + ); const events = await drain(stream); const result = await stream.result(); @@ -120,10 +130,16 @@ describe("withEmptyCompletionRetry", () => { it("delivers the empty result after exhausting the retry cap", async () => { let attempts = 0; const waits: number[] = []; - const stream = withEmptyCompletionRetry({}, CTX, { providerRetryWait: async ms => void waits.push(ms) }, () => { - attempts++; - return emptyAttempt(); - }); + const stream = withReplaySafeStreamRetry( + {}, + CTX, + { providerRetryWait: async ms => void waits.push(ms) }, + () => { + attempts++; + return emptyAttempt(); + }, + { retryEmptyCompletion: true }, + ); const events = await drain(stream); const result = await stream.result(); @@ -138,7 +154,7 @@ describe("withEmptyCompletionRetry", () => { it("does not retry when the first attempt streams content", async () => { let attempts = 0; let waited = false; - const stream = withEmptyCompletionRetry( + const stream = withReplaySafeStreamRetry( {}, CTX, { @@ -150,6 +166,7 @@ describe("withEmptyCompletionRetry", () => { attempts++; return contentAttempt(); }, + { retryEmptyCompletion: true }, ); await drain(stream); @@ -160,15 +177,21 @@ describe("withEmptyCompletionRetry", () => { it("commits on streamed thinking and does not retry a thinking-only stop", async () => { let attempts = 0; - const stream = withEmptyCompletionRetry({}, CTX, {}, () => { - attempts++; - const message = assistant(); // no visible content; only thinking streams - return streamFromEvents([ - { type: "start", partial: message }, - { type: "thinking_delta", contentIndex: 0, delta: "pondering", partial: message }, - { type: "done", reason: "stop", message }, - ] as unknown as AssistantMessageEvent[]); - }); + const stream = withReplaySafeStreamRetry( + {}, + CTX, + {}, + () => { + attempts++; + const message = assistant(); // no visible content; only thinking streams + return streamFromEvents([ + { type: "start", partial: message }, + { type: "thinking_delta", contentIndex: 0, delta: "pondering", partial: message }, + { type: "done", reason: "stop", message }, + ] as unknown as AssistantMessageEvent[]); + }, + { retryEmptyCompletion: true }, + ); const events = await drain(stream); @@ -177,7 +200,7 @@ describe("withEmptyCompletionRetry", () => { }); it("propagates a non-abort backoff failure instead of masking the empty result", async () => { - const stream = withEmptyCompletionRetry( + const stream = withReplaySafeStreamRetry( {}, CTX, { @@ -186,6 +209,7 @@ describe("withEmptyCompletionRetry", () => { }, }, () => emptyAttempt(), + { retryEmptyCompletion: true }, ); let caught: unknown; @@ -200,7 +224,7 @@ describe("withEmptyCompletionRetry", () => { it("delivers the empty result when aborted during backoff", async () => { const controller = new AbortController(); let attempts = 0; - const stream = withEmptyCompletionRetry( + const stream = withReplaySafeStreamRetry( {}, CTX, { @@ -214,6 +238,7 @@ describe("withEmptyCompletionRetry", () => { attempts++; return emptyAttempt(); }, + { retryEmptyCompletion: true }, ); const events = await drain(stream); @@ -226,18 +251,24 @@ describe("withEmptyCompletionRetry", () => { it("discards buffered pre-content markers from a retried empty attempt", async () => { let attempts = 0; - const stream = withEmptyCompletionRetry({}, CTX, { providerRetryWait: async () => {} }, () => { - attempts++; - if (attempts === 1) { - const message = assistant(); - return streamFromEvents([ - { type: "start", partial: message }, - { type: "thinking_start", contentIndex: 0, partial: message }, - { type: "done", reason: "stop", message }, - ] as unknown as AssistantMessageEvent[]); - } - return contentAttempt(); - }); + const stream = withReplaySafeStreamRetry( + {}, + CTX, + { providerRetryWait: async () => {} }, + () => { + attempts++; + if (attempts === 1) { + const message = assistant(); + return streamFromEvents([ + { type: "start", partial: message }, + { type: "thinking_start", contentIndex: 0, partial: message }, + { type: "done", reason: "stop", message }, + ] as unknown as AssistantMessageEvent[]); + } + return contentAttempt(); + }, + { retryEmptyCompletion: true }, + ); const events = await drain(stream); @@ -253,7 +284,7 @@ describe("withEmptyCompletionRetry", () => { let waited = false; const message = assistant(["streamed"]); const inner = new AssistantMessageEventStream(); - const stream = withEmptyCompletionRetry( + const stream = withReplaySafeStreamRetry( {}, CTX, { @@ -262,6 +293,7 @@ describe("withEmptyCompletionRetry", () => { }, }, () => inner, + { retryEmptyCompletion: true }, ); const iterator = stream[Symbol.asyncIterator](); @@ -283,4 +315,62 @@ describe("withEmptyCompletionRetry", () => { expect((await iterator.next()).value?.type).toBe("done"); expect(waited).toBe(false); }); + + it("retries a transient provider error before output commits", async () => { + let attempts = 0; + const stream = withReplaySafeStreamRetry( + {}, + CTX, + { providerRetryWait: async () => {} }, + () => { + attempts++; + if (attempts > 1) return contentAttempt(); + const message = assistant(); + message.stopReason = "error"; + message.errorMessage = "The socket connection was closed unexpectedly"; + return streamFromEvents([ + { type: "start", partial: message }, + { type: "error", reason: "error", error: message }, + ]); + }, + { retryProviderErrors: true, maxProviderErrorRetries: 1 }, + ); + + const events = await drain(stream); + const result = await stream.result(); + + expect(attempts).toBe(2); + expect(events.filter(event => event.type === "start")).toHaveLength(1); + expect(result.content).toEqual([{ type: "text", text: "hello" }]); + }); + + it("does not retry a transient provider error after output commits", async () => { + let attempts = 0; + const message = assistant(["partial"]); + message.stopReason = "error"; + message.errorMessage = "The socket connection was closed unexpectedly"; + const stream = withReplaySafeStreamRetry( + {}, + CTX, + { providerRetryWait: async () => {} }, + () => { + attempts++; + return streamFromEvents([ + { type: "start", partial: message }, + { type: "text_start", contentIndex: 0, partial: message }, + { type: "text_delta", contentIndex: 0, delta: "partial", partial: message }, + { type: "error", reason: "error", error: message }, + ]); + }, + { retryProviderErrors: true, maxProviderErrorRetries: 1 }, + ); + + const events = await drain(stream); + const result = await stream.result(); + + expect(attempts).toBe(1); + expect(events.at(-1)?.type).toBe("error"); + expect(result.stopReason).toBe("error"); + expect(result.content).toEqual([{ type: "text", text: "partial" }]); + }); }); diff --git a/packages/ai/test/openai-stream-socket-retry.test.ts b/packages/ai/test/openai-stream-socket-retry.test.ts new file mode 100644 index 000000000000..6b5e4a87673f --- /dev/null +++ b/packages/ai/test/openai-stream-socket-retry.test.ts @@ -0,0 +1,277 @@ +import { afterEach, describe, expect, it, vi } from "bun:test"; +import { scheduler } from "node:timers/promises"; +import { streamAzureOpenAIResponses } from "@oh-my-pi/pi-ai/providers/azure-openai-responses"; +import { streamOpenAICodexResponses } from "@oh-my-pi/pi-ai/providers/openai-codex-responses"; +import { streamOpenAICompletions } from "@oh-my-pi/pi-ai/providers/openai-completions"; +import { streamOpenAIResponses } from "@oh-my-pi/pi-ai/providers/openai-responses"; +import type { Context, FetchImpl, Model, ModelSpec } from "@oh-my-pi/pi-ai/types"; +import { buildModel } from "@oh-my-pi/pi-catalog/build"; + +const SOCKET_CLOSE_MESSAGE = + "The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()"; +const context: Context = { + messages: [{ role: "user", content: "Say hello", timestamp: 1_000 }], +}; + +const modelDefaults: Pick = { + id: "gpt-test", + name: "GPT test", + reasoning: false, + input: ["text"], + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + contextWindow: 128_000, + maxTokens: 16_384, +}; + +const completionsModel: Model<"openai-completions"> = buildModel({ + ...modelDefaults, + api: "openai-completions", + provider: "openai", + baseUrl: "https://api.openai.test/v1", +}); + +const responsesModel: Model<"openai-responses"> = buildModel({ + ...modelDefaults, + api: "openai-responses", + provider: "openai", + baseUrl: "https://api.openai.test/v1", +}); + +const azureModel: Model<"azure-openai-responses"> = buildModel({ + ...modelDefaults, + api: "azure-openai-responses", + provider: "azure", + baseUrl: "https://example.openai.azure.com/openai/v1", +}); + +const codexModel: Model<"openai-codex-responses"> = buildModel({ + ...modelDefaults, + api: "openai-codex-responses", + provider: "openai-codex", + baseUrl: "https://chatgpt.com/backend-api", + preferWebsockets: false, +}); + +function createSseResponse(events: unknown[], done = false): Response { + const frames = events.map(event => `data: ${JSON.stringify(event)}`); + if (done) frames.push("data: [DONE]"); + return new Response(`${frames.join("\n\n")}\n\n`, { + status: 200, + headers: { "content-type": "text/event-stream" }, + }); +} + +function createSocketCloseResponse(events: unknown[]): Response { + const bytes = new TextEncoder().encode(`${events.map(event => `data: ${JSON.stringify(event)}`).join("\n\n")}\n\n`); + let sentPrefix = false; + return new Response( + new ReadableStream( + { + pull(controller) { + if (!sentPrefix) { + sentPrefix = true; + controller.enqueue(bytes); + return; + } + controller.error(new TypeError(SOCKET_CLOSE_MESSAGE)); + }, + }, + { highWaterMark: 0 }, + ), + { status: 200, headers: { "content-type": "text/event-stream" } }, + ); +} + +function completedResponsesSse(text: string): Response { + return createSseResponse([ + { type: "response.created", response: { id: "resp_recovered", status: "in_progress" } }, + { + type: "response.output_item.added", + output_index: 0, + item: { type: "message", id: "msg_recovered", role: "assistant", status: "in_progress", content: [] }, + }, + { type: "response.output_text.delta", output_index: 0, item_id: "msg_recovered", delta: text }, + { + type: "response.output_item.done", + output_index: 0, + item: { + type: "message", + id: "msg_recovered", + role: "assistant", + status: "completed", + content: [{ type: "output_text", text }], + }, + }, + { + type: "response.completed", + response: { + id: "resp_recovered", + status: "completed", + usage: { input_tokens: 5, output_tokens: 2, total_tokens: 7, input_tokens_details: { cached_tokens: 0 } }, + }, + }, + ]); +} + +function completedCompletionsSse(text: string): Response { + return createSseResponse( + [ + { id: "chatcmpl_recovered", choices: [{ index: 0, delta: { content: text }, finish_reason: null }] }, + { + id: "chatcmpl_recovered", + choices: [{ index: 0, delta: {}, finish_reason: "stop" }], + usage: { prompt_tokens: 5, completion_tokens: 2, total_tokens: 7 }, + }, + ], + true, + ); +} + +function completedCodexSse(text: string): Response { + return createSseResponse([ + { + type: "response.output_item.added", + item: { type: "message", id: "msg_recovered", role: "assistant", status: "in_progress", content: [] }, + }, + { type: "response.content_part.added", part: { type: "output_text", text: "" } }, + { type: "response.output_text.delta", delta: text }, + { + type: "response.output_item.done", + item: { + type: "message", + id: "msg_recovered", + role: "assistant", + status: "completed", + content: [{ type: "output_text", text }], + }, + }, + { + type: "response.completed", + response: { + status: "completed", + usage: { input_tokens: 5, output_tokens: 2, total_tokens: 7, input_tokens_details: { cached_tokens: 0 } }, + }, + }, + ]); +} + +afterEach(() => { + vi.restoreAllMocks(); +}); + +describe("OpenAI-family mid-stream socket-close retry", () => { + it("retries OpenAI Responses before replay-unsafe output", async () => { + let requests = 0; + const fetchMock: FetchImpl = vi.fn(async () => { + requests++; + return requests === 1 + ? createSocketCloseResponse([ + { type: "response.created", response: { id: "resp_failed", status: "in_progress" } }, + ]) + : completedResponsesSse("responses recovered"); + }); + + const result = await streamOpenAIResponses(responsesModel, context, { + apiKey: "test-key", + fetch: fetchMock, + providerRetryWait: async () => {}, + }).result(); + + expect(requests).toBe(2); + expect(result.stopReason).toBe("stop"); + expect(result.content.find(block => block.type === "text")?.text).toBe("responses recovered"); + }); + + it("retries OpenAI Completions before replay-unsafe output", async () => { + let requests = 0; + const fetchMock: FetchImpl = vi.fn(async () => { + requests++; + return requests === 1 + ? createSocketCloseResponse([ + { id: "chatcmpl_failed", choices: [{ index: 0, delta: { role: "assistant" }, finish_reason: null }] }, + ]) + : completedCompletionsSse("completions recovered"); + }); + + const result = await streamOpenAICompletions(completionsModel, context, { + apiKey: "test-key", + fetch: fetchMock, + providerRetryWait: async () => {}, + }).result(); + + expect(requests).toBe(2); + expect(result.stopReason).toBe("stop"); + expect(result.content.find(block => block.type === "text")?.text).toBe("completions recovered"); + }); + + it("retries Azure OpenAI Responses before replay-unsafe output", async () => { + let requests = 0; + const fetchMock: FetchImpl = vi.fn(async () => { + requests++; + return requests === 1 + ? createSocketCloseResponse([ + { type: "response.created", response: { id: "resp_failed", status: "in_progress" } }, + ]) + : completedResponsesSse("azure recovered"); + }); + + const result = await streamAzureOpenAIResponses(azureModel, context, { + apiKey: "test-key", + azureBaseUrl: azureModel.baseUrl, + azureApiVersion: "v1", + fetch: fetchMock, + providerRetryWait: async () => {}, + }).result(); + + expect(requests).toBe(2); + expect(result.stopReason).toBe("stop"); + expect(result.content.find(block => block.type === "text")?.text).toBe("azure recovered"); + }); + + it("retries Codex SSE before replay-unsafe output", async () => { + vi.spyOn(scheduler, "wait").mockResolvedValue(undefined); + let requests = 0; + const fetchMock: FetchImpl = vi.fn(async () => { + requests++; + return requests === 1 + ? createSocketCloseResponse([ + { type: "response.created", response: { id: "resp_failed", status: "in_progress" } }, + ]) + : completedCodexSse("codex recovered"); + }); + + const result = await streamOpenAICodexResponses(codexModel, context, { + apiKey: "test-key", + fetch: fetchMock, + }).result(); + + expect(requests).toBe(2); + expect(result.stopReason).toBe("stop"); + expect(result.content.find(block => block.type === "text")?.text).toBe("codex recovered"); + }); + + it("does not retry Codex SSE after text output commits", async () => { + vi.spyOn(scheduler, "wait").mockResolvedValue(undefined); + let requests = 0; + const fetchMock: FetchImpl = vi.fn(async () => { + requests++; + return createSocketCloseResponse([ + { + type: "response.output_item.added", + item: { type: "message", id: "msg_partial", role: "assistant", status: "in_progress", content: [] }, + }, + { type: "response.content_part.added", part: { type: "output_text", text: "" } }, + { type: "response.output_text.delta", delta: "partial" }, + ]); + }); + + const result = await streamOpenAICodexResponses(codexModel, context, { + apiKey: "test-key", + fetch: fetchMock, + }).result(); + + expect(requests).toBe(1); + expect(result.stopReason).toBe("error"); + expect(result.content.find(block => block.type === "text")?.text).toBe("partial"); + }); +}); From 7f4003eb1c1dd3f7bee126f19dd6beeacfc65fc6 Mon Sep 17 00:00:00 2001 From: roboomp Date: Sat, 8 Aug 2026 04:01:43 +0000 Subject: [PATCH 010/795] fix(ai): surfaced synchronous stream attempt throws - Moved the attempt factory call inside the wrapper's try so a synchronous throw fails the outer stream instead of leaking an unhandled rejection. - Added a regression asserting a throwing attempt settles result() as rejected. Fixes #7979 --- packages/ai/src/utils/empty-completion-retry.ts | 6 +++++- packages/ai/test/empty-completion-retry.test.ts | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/ai/src/utils/empty-completion-retry.ts b/packages/ai/src/utils/empty-completion-retry.ts index c5b19c7d9fdc..42faf363f9e9 100644 --- a/packages/ai/src/utils/empty-completion-retry.ts +++ b/packages/ai/src/utils/empty-completion-retry.ts @@ -98,7 +98,6 @@ export function withReplaySafeStreamRetry( let emptyRetries = 0; let providerErrorRetries = 0; while (true) { - const inner = attempt(model, context, options); const buffered: AssistantMessageEvent[] = []; let committed = false; let terminal: AssistantMessageEvent | undefined; @@ -106,7 +105,12 @@ export function withReplaySafeStreamRetry( for (const event of buffered) outer.push(event); buffered.length = 0; }; + let inner: AssistantMessageEventStream; try { + // The attempt factory can throw synchronously (e.g. a config error + // raised before it creates its stream); surface it on the outer stream + // rather than leaking an unhandled rejection that never settles. + inner = attempt(model, context, options); for await (const event of inner) { if (event.type === "done" || event.type === "error") { terminal = event; diff --git a/packages/ai/test/empty-completion-retry.test.ts b/packages/ai/test/empty-completion-retry.test.ts index 84635c19d513..c0460d6f756d 100644 --- a/packages/ai/test/empty-completion-retry.test.ts +++ b/packages/ai/test/empty-completion-retry.test.ts @@ -373,4 +373,19 @@ describe("withReplaySafeStreamRetry", () => { expect(result.stopReason).toBe("error"); expect(result.content).toEqual([{ type: "text", text: "partial" }]); }); + + it("settles the outer stream when the attempt factory throws synchronously", async () => { + const configError = new Error("explicit prompt caching is unsupported"); + const stream = withReplaySafeStreamRetry( + {}, + CTX, + { providerRetryWait: async () => {} }, + () => { + throw configError; + }, + { retryProviderErrors: true, maxProviderErrorRetries: 1 }, + ); + + await expect(stream.result()).rejects.toBe(configError); + }); }); From 3649e28935b5bd7be523063e320fa577a1e84a0f Mon Sep 17 00:00:00 2001 From: roboomp Date: Sat, 8 Aug 2026 04:05:20 +0000 Subject: [PATCH 011/795] fix(ai): gated codex retry on committed output not empty blocks - Replaced the output.content.length replay guard in #tryRetryProviderError with hasVisibleAssistantContent so a pre-delta socket close after an opened empty block still retries, while committed text/tool output does not. - Kept canSafelyReplayWebsocketOverSse as the completed-tool-call guard. - Added a regression covering the empty-opened-block socket close. Fixes #7979 --- .../src/providers/openai-codex-responses.ts | 8 +++++- .../test/openai-stream-socket-retry.test.ts | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/packages/ai/src/providers/openai-codex-responses.ts b/packages/ai/src/providers/openai-codex-responses.ts index 52c0c5b3ce67..2e149e47c671 100644 --- a/packages/ai/src/providers/openai-codex-responses.ts +++ b/packages/ai/src/providers/openai-codex-responses.ts @@ -54,6 +54,7 @@ import { stripOpenAIResponsesComputerLinkedReasoningIdsForReplay, } from "../utils"; import { clearStreamingPartialJson, kStreamingLastParseLen, kStreamingPartialJson } from "../utils/block-symbols"; +import { hasVisibleAssistantContent } from "../utils/empty-completion-retry"; import { AssistantMessageEventStream } from "../utils/event-stream"; import { escapeHarmonyControlTokens, isHarmonyDialectModel } from "../utils/harmony-leak"; import type { RawHttpRequestDump } from "../utils/http-inspector"; @@ -2728,7 +2729,12 @@ class CodexStreamProcessor { : AIError.isProviderRetryableError(error, { provider: this.model.provider }); if ( !retryable || - this.output.content.length > 0 || + // A leading `response.output_item.added` opens an empty block and emits + // only a `*_start` before any delta; that is replay-safe. Gate on + // actually-committed visible output, not an open-but-empty block, or a + // pre-delta socket close would be misclassified as committed. + hasVisibleAssistantContent(this.output) || + !this.runtime.canSafelyReplayWebsocketOverSse || this.runtime.providerRetryAttempt >= CODEX_MAX_RETRIES || this.options?.signal?.aborted ) { diff --git a/packages/ai/test/openai-stream-socket-retry.test.ts b/packages/ai/test/openai-stream-socket-retry.test.ts index 6b5e4a87673f..1759895547ae 100644 --- a/packages/ai/test/openai-stream-socket-retry.test.ts +++ b/packages/ai/test/openai-stream-socket-retry.test.ts @@ -250,6 +250,34 @@ describe("OpenAI-family mid-stream socket-close retry", () => { expect(result.content.find(block => block.type === "text")?.text).toBe("codex recovered"); }); + it("retries Codex SSE when a socket close follows an empty opened block", async () => { + vi.spyOn(scheduler, "wait").mockResolvedValue(undefined); + let requests = 0; + const fetchMock: FetchImpl = vi.fn(async () => { + requests++; + // First attempt opens a message block (emits text_start) but closes the + // socket before any output_text delta — replay-safe, must retry. + return requests === 1 + ? createSocketCloseResponse([ + { + type: "response.output_item.added", + item: { type: "message", id: "msg_empty", role: "assistant", status: "in_progress", content: [] }, + }, + { type: "response.content_part.added", part: { type: "output_text", text: "" } }, + ]) + : completedCodexSse("codex recovered after empty block"); + }); + + const result = await streamOpenAICodexResponses(codexModel, context, { + apiKey: "test-key", + fetch: fetchMock, + }).result(); + + expect(requests).toBe(2); + expect(result.stopReason).toBe("stop"); + expect(result.content.find(block => block.type === "text")?.text).toBe("codex recovered after empty block"); + }); + it("does not retry Codex SSE after text output commits", async () => { vi.spyOn(scheduler, "wait").mockResolvedValue(undefined); let requests = 0; From 46225be3c73e92092ec15546163725fc9dc7d7b8 Mon Sep 17 00:00:00 2001 From: roboomp Date: Sat, 8 Aug 2026 04:10:45 +0000 Subject: [PATCH 012/795] fix(ai): blocked codex retry after streamed thinking - Treated a non-empty streamed thinking block as committed in #tryRetryProviderError so replaying cannot duplicate/reorder already-emitted thinking_delta events or drop them from the reset message. - Added a regression covering a socket close after a reasoning delta. Fixes #7979 --- .../src/providers/openai-codex-responses.ts | 13 +++++++---- .../test/openai-stream-socket-retry.test.ts | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/ai/src/providers/openai-codex-responses.ts b/packages/ai/src/providers/openai-codex-responses.ts index 2e149e47c671..1f871f8724f9 100644 --- a/packages/ai/src/providers/openai-codex-responses.ts +++ b/packages/ai/src/providers/openai-codex-responses.ts @@ -2727,13 +2727,18 @@ class CodexStreamProcessor { error instanceof CodexProviderStreamError ? error.retryable : AIError.isProviderRetryableError(error, { provider: this.model.provider }); + // A leading `response.output_item.added` opens an empty block and emits only + // a `*_start` before any delta; that is replay-safe. But once a visible + // text/tool block or any non-empty thinking delta has streamed, replaying + // would duplicate/reorder those already-delivered events (and drop the + // streamed thinking from the reset message), so treat that as committed. + const streamedThinking = this.output.content.some( + block => block.type === "thinking" && block.thinking.length > 0, + ); if ( !retryable || - // A leading `response.output_item.added` opens an empty block and emits - // only a `*_start` before any delta; that is replay-safe. Gate on - // actually-committed visible output, not an open-but-empty block, or a - // pre-delta socket close would be misclassified as committed. hasVisibleAssistantContent(this.output) || + streamedThinking || !this.runtime.canSafelyReplayWebsocketOverSse || this.runtime.providerRetryAttempt >= CODEX_MAX_RETRIES || this.options?.signal?.aborted diff --git a/packages/ai/test/openai-stream-socket-retry.test.ts b/packages/ai/test/openai-stream-socket-retry.test.ts index 1759895547ae..cedf05cb1db1 100644 --- a/packages/ai/test/openai-stream-socket-retry.test.ts +++ b/packages/ai/test/openai-stream-socket-retry.test.ts @@ -302,4 +302,27 @@ describe("OpenAI-family mid-stream socket-close retry", () => { expect(result.stopReason).toBe("error"); expect(result.content.find(block => block.type === "text")?.text).toBe("partial"); }); + + it("does not retry Codex SSE after thinking output commits", async () => { + vi.spyOn(scheduler, "wait").mockResolvedValue(undefined); + let requests = 0; + const fetchMock: FetchImpl = vi.fn(async () => { + requests++; + // A reasoning delta already reached the consumer as thinking_delta; + // replaying would duplicate it, so the socket close must surface. + return createSocketCloseResponse([ + { type: "response.output_item.added", item: { type: "reasoning", id: "rs_partial", summary: [] } }, + { type: "response.reasoning_text.delta", item_id: "rs_partial", delta: "deliberating" }, + ]); + }); + + const result = await streamOpenAICodexResponses(codexModel, context, { + apiKey: "test-key", + fetch: fetchMock, + }).result(); + + expect(requests).toBe(1); + expect(result.stopReason).toBe("error"); + expect(result.content.find(block => block.type === "thinking")?.thinking).toBe("deliberating"); + }); }); From d4c6ca1ab267f0145c95213a4a7b51e465f1fe77 Mon Sep 17 00:00:00 2001 From: roboomp Date: Sat, 8 Aug 2026 06:49:46 +0000 Subject: [PATCH 013/795] fix(eval): read python runner stdin serially to unblock numpy on windows The runner spawned a daemon thread parked in a blocking `for raw_line in stdin` readline for the entire duration of every cell. Under a pipe-backed subprocess this is the exact concurrent-stdin-reader condition that deadlocks native-extension imports (NumPy in particular) on Windows during DLL load (numpy#24290), leaving the eval request stuck in-flight until the watchdog kills the kernel. Dispatch requests serially on the asyncio event loop, reading each control line via `run_in_executor`. The stdin read now happens only between cells; once a request arrives the reader returns, so no thread is reading stdin while user code imports a native extension. Per-kernel execution is already serial (shared namespace + process-global cwd/sys.path), so this changes no observable behavior. Fixes #7985 --- packages/coding-agent/CHANGELOG.md | 4 + packages/coding-agent/src/eval/py/runner.py | 96 ++++++++-------- .../test/eval/py/runner-stdin-reader.test.ts | 103 ++++++++++++++++++ 3 files changed, 152 insertions(+), 51 deletions(-) create mode 100644 packages/coding-agent/test/eval/py/runner-stdin-reader.test.ts diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 1cb7c55d044e..05075ec2ca60 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed `import numpy` (and other native-extension imports) hanging indefinitely in the Python eval tool on Windows by reading the runner's stdin control channel serially on the event loop instead of from an always-on background reader thread ([#7985](https://github.com/can1357/oh-my-pi/issues/7985)). + ## [17.2.11] - 2026-08-07 ### Added diff --git a/packages/coding-agent/src/eval/py/runner.py b/packages/coding-agent/src/eval/py/runner.py index a87f6ab71dc2..975f66777ed3 100644 --- a/packages/coding-agent/src/eval/py/runner.py +++ b/packages/coding-agent/src/eval/py/runner.py @@ -1347,26 +1347,25 @@ def _emit_error(rid: str, exc: BaseException) -> None: # --------------------------------------------------------------------------- -def _read_stdin(loop: asyncio.AbstractEventLoop, queue: asyncio.Queue, stdin) -> None: - for raw_line in stdin: - line = raw_line.strip() - if not line: - continue - try: - req = json.loads(line) - except json.JSONDecodeError as exc: - _emit( - { - "type": "error", - "id": "", - "ename": "ProtocolError", - "evalue": f"Invalid JSON request: {exc}", - "traceback": [], - } - ) - continue - loop.call_soon_threadsafe(queue.put_nowait, req) - loop.call_soon_threadsafe(queue.put_nowait, {"type": "exit"}) +def _parse_request(line: str) -> dict | None: + """Parse one NDJSON control line, or ``None`` when it should be skipped. + + Emits a ``ProtocolError`` frame for malformed JSON so the host sees the + same diagnostic the previous reader thread produced. + """ + try: + return json.loads(line) + except json.JSONDecodeError as exc: + _emit( + { + "type": "error", + "id": "", + "ename": "ProtocolError", + "evalue": f"Invalid JSON request: {exc}", + "traceback": [], + } + ) + return None async def _main_async() -> None: @@ -1382,39 +1381,34 @@ async def _main_async() -> None: loop = asyncio.get_running_loop() _STATE.loop = loop - queue: asyncio.Queue = asyncio.Queue() - reader = threading.Thread( - target=_read_stdin, - args=(loop, queue, stdin), - name="omp-stdin-reader", - daemon=True, - ) - reader.start() - - tasks: set[asyncio.Task] = set() - def _task_done(task: asyncio.Task) -> None: - tasks.discard(task) + # Read the control channel one line at a time on the event loop rather than + # from an always-on reader thread. A thread perpetually parked in a + # blocking ``sys.stdin`` read deadlocks native-extension imports (NumPy in + # particular) under a pipe-backed subprocess on Windows: the native DLL + # load and the concurrent stdin read wedge each other (numpy#24290). + # Reading via ``run_in_executor`` confines the stdin read to the gap + # *between* requests -- once a line arrives the reader returns, so no + # thread is reading stdin while the cell (and its imports) run. Per-kernel + # execution is serial anyway (shared namespace + process-global + # cwd/sys.path), so handling requests one at a time changes no observable + # behavior. + while True: + raw_line = await loop.run_in_executor(None, stdin.readline) + if not raw_line: + break # EOF: the host closed the control channel. + line = raw_line.strip() + if not line: + continue + req = _parse_request(line) + if req is None: + continue + if req.get("type") == "exit": + break try: - exc = task.exception() - except asyncio.CancelledError: - return - if exc is not None: - _emit_error("", exc) - - try: - while True: - req = await queue.get() - if req.get("type") == "exit": - break - task = asyncio.create_task(_handle_request_async(req)) - tasks.add(task) - task.add_done_callback(_task_done) - finally: - for task in tasks: - task.cancel() - if tasks: - await asyncio.gather(*tasks, return_exceptions=True) + await _handle_request_async(req) + except BaseException as exc: # noqa: BLE001 - one bad request must not wedge the loop + _emit_error(str(req.get("id", "")), exc) def main() -> None: diff --git a/packages/coding-agent/test/eval/py/runner-stdin-reader.test.ts b/packages/coding-agent/test/eval/py/runner-stdin-reader.test.ts new file mode 100644 index 000000000000..839363c75386 --- /dev/null +++ b/packages/coding-agent/test/eval/py/runner-stdin-reader.test.ts @@ -0,0 +1,103 @@ +import { describe, expect, it } from "bun:test"; +import * as path from "node:path"; +import { $which } from "@oh-my-pi/pi-utils"; + +interface RunnerFrame { + type?: string; + id?: string; + data?: string; + status?: string; +} + +const pythonPath = Bun.env.PYTHON ?? ($which("python3") ? "python3" : "python"); +const runnerPath = path.resolve(import.meta.dir, "../../../src/eval/py/runner.py"); +const repoRoot = path.resolve(import.meta.dir, "../../../../.."); +const encoder = new TextEncoder(); + +async function runCell(code: string): Promise { + const proc = Bun.spawn([pythonPath, "-u", runnerPath], { + cwd: repoRoot, + stdin: "pipe", + stdout: "pipe", + stderr: "pipe", + env: { ...process.env, PYTHONUNBUFFERED: "1", PYTHONIOENCODING: "utf-8" }, + }); + const stderr = new Response(proc.stderr).text(); + const reader = proc.stdout.getReader(); + const decoder = new TextDecoder(); + let pending = ""; + const frames: RunnerFrame[] = []; + + async function readFrame(): Promise { + while (true) { + const newline = pending.indexOf("\n"); + if (newline >= 0) { + const line = pending.slice(0, newline); + pending = pending.slice(newline + 1); + return JSON.parse(line) as RunnerFrame; + } + const { value, done } = await reader.read(); + if (done) throw new Error(`Python runner exited before done frame: ${await stderr}`); + pending += decoder.decode(value, { stream: true }); + } + } + + try { + proc.stdin.write(encoder.encode(`${JSON.stringify({ id: "r1", code })}\n`)); + proc.stdin.flush(); + while (true) { + const frame = await readFrame(); + frames.push(frame); + if (frame.type === "done") break; + } + proc.stdin.write(encoder.encode(`${JSON.stringify({ type: "exit" })}\n`)); + proc.stdin.end(); + const exitCode = await proc.exited; + if (exitCode !== 0) throw new Error(`Python runner exited ${exitCode}: ${await stderr}`); + return frames; + } finally { + try { + reader.releaseLock(); + } catch { + // Reader may already be released by stream closure. + } + try { + proc.kill("SIGKILL"); + } catch { + // Process already exited. + } + } +} + +// A thread perpetually parked in a blocking `sys.stdin` read deadlocks native +// extension imports (NumPy) under a pipe-backed subprocess on Windows +// (numpy#24290, issue #7985). The runner must therefore never keep a +// concurrent control-channel reader alive while a cell (and its imports) run. +describe("Python runner stdin control channel", () => { + it("has no background thread parked in a stdin read while a cell executes", async () => { + const inspect = [ + "import sys, threading", + "main_id = threading.main_thread().ident", + "readers = []", + "for th in threading.enumerate():", + " if th.ident == main_id:", + " continue", + " fr = sys._current_frames().get(th.ident)", + " names = []", + " while fr is not None:", + " names.append(fr.f_code.co_name)", + " fr = fr.f_back", + ' if th.name == "omp-stdin-reader" or "_read_stdin" in names:', + " readers.append(th.name)", + 'print("STDIN_READERS=" + repr(sorted(readers)))', + ].join("\n"); + const frames = await runCell(inspect); + const stdout = frames + .filter(frame => frame.type === "stdout") + .map(frame => frame.data) + .join(""); + + expect(stdout).toContain("STDIN_READERS=[]"); + expect(frames.at(-1)?.status).toBe("ok"); + }); +}); From 1e01ccd89ce832adaf6fae45759b26a0ad596f7d Mon Sep 17 00:00:00 2001 From: roboomp Date: Sat, 8 Aug 2026 07:00:43 +0000 Subject: [PATCH 014/795] fix(eval): keep concurrent request dispatch on posix python runner The prior fix serialized stdin dispatch on every platform, which regressed concurrency: eval sessions are shared across concurrent agents (subagents inherit the parent's eval session id, per executor-base.ts), so multiple requests interleave on one kernel and a cell parked on a top-level await must not block siblings. Fork the request loop by platform. POSIX keeps the original background reader thread + one task per request (interleaving unchanged). Windows uses the serial run_in_executor loop so no thread is ever parked in a blocking sys.stdin read while user code imports a native extension (numpy#24290) -- the deadlock is Windows-only, and concurrent imports already hung there, so serial dispatch is a strict improvement. Replaced the thread-presence test with a dispatch test asserting a fast request interleaves past a slow await-parked one on POSIX. Fixes #7985 --- packages/coding-agent/CHANGELOG.md | 2 +- packages/coding-agent/src/eval/py/runner.py | 118 +++++++++++++---- .../eval/py/runner-request-dispatch.test.ts | 120 ++++++++++++++++++ .../test/eval/py/runner-stdin-reader.test.ts | 103 --------------- 4 files changed, 216 insertions(+), 127 deletions(-) create mode 100644 packages/coding-agent/test/eval/py/runner-request-dispatch.test.ts delete mode 100644 packages/coding-agent/test/eval/py/runner-stdin-reader.test.ts diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 05075ec2ca60..618687bdcb2f 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixed -- Fixed `import numpy` (and other native-extension imports) hanging indefinitely in the Python eval tool on Windows by reading the runner's stdin control channel serially on the event loop instead of from an always-on background reader thread ([#7985](https://github.com/can1357/oh-my-pi/issues/7985)). +- Fixed `import numpy` (and other native-extension imports) hanging indefinitely in the Python eval tool on Windows, where the runner's always-on background stdin reader deadlocked native DLL loading; Windows now reads the control channel serially between requests while POSIX keeps concurrent request dispatch ([#7985](https://github.com/can1357/oh-my-pi/issues/7985)). ## [17.2.11] - 2026-08-07 diff --git a/packages/coding-agent/src/eval/py/runner.py b/packages/coding-agent/src/eval/py/runner.py index 975f66777ed3..cdd41045cc54 100644 --- a/packages/coding-agent/src/eval/py/runner.py +++ b/packages/coding-agent/src/eval/py/runner.py @@ -1351,7 +1351,7 @@ def _parse_request(line: str) -> dict | None: """Parse one NDJSON control line, or ``None`` when it should be skipped. Emits a ``ProtocolError`` frame for malformed JSON so the host sees the - same diagnostic the previous reader thread produced. + same diagnostic the reader has always produced. """ try: return json.loads(line) @@ -1368,31 +1368,83 @@ def _parse_request(line: str) -> dict | None: return None -async def _main_async() -> None: - sys.stdout = _StreamProxy("stdout") - sys.stderr = _StreamProxy("stderr") - _install_idle_sigint() - _start_parent_watchdog() - _start_capture_drain() +def _read_stdin(loop: asyncio.AbstractEventLoop, queue: asyncio.Queue, stdin) -> None: + """Feed control-channel requests to the event loop from a reader thread. - stdin = sys.__stdin__ - if stdin is None: - return + POSIX only -- see ``_serve_windows`` for why Windows cannot run a + perpetually blocked stdin reader. + """ + for raw_line in stdin: + line = raw_line.strip() + if not line: + continue + req = _parse_request(line) + if req is None: + continue + loop.call_soon_threadsafe(queue.put_nowait, req) + loop.call_soon_threadsafe(queue.put_nowait, {"type": "exit"}) - loop = asyncio.get_running_loop() - _STATE.loop = loop - # Read the control channel one line at a time on the event loop rather than - # from an always-on reader thread. A thread perpetually parked in a - # blocking ``sys.stdin`` read deadlocks native-extension imports (NumPy in - # particular) under a pipe-backed subprocess on Windows: the native DLL - # load and the concurrent stdin read wedge each other (numpy#24290). - # Reading via ``run_in_executor`` confines the stdin read to the gap - # *between* requests -- once a line arrives the reader returns, so no - # thread is reading stdin while the cell (and its imports) run. Per-kernel - # execution is serial anyway (shared namespace + process-global - # cwd/sys.path), so handling requests one at a time changes no observable - # behavior. +async def _serve_posix(loop: asyncio.AbstractEventLoop, stdin) -> None: + """Dispatch requests concurrently, one asyncio task per request. + + A background thread reads stdin and enqueues requests so a cell parked on + a top-level ``await`` (an ``await agent(...)`` bridge call, say) does not + block sibling requests: eval sessions are shared across concurrent agents + (subagents inherit the parent's eval session id), so multiple requests can + be in flight on one kernel at once. The reader thread stays blocked in a + ``sys.stdin`` read for its whole life, which is safe on POSIX but wedges + native-extension imports on Windows (see ``_serve_windows``). + """ + queue: asyncio.Queue = asyncio.Queue() + reader = threading.Thread( + target=_read_stdin, + args=(loop, queue, stdin), + name="omp-stdin-reader", + daemon=True, + ) + reader.start() + + tasks: set[asyncio.Task] = set() + + def _task_done(task: asyncio.Task) -> None: + tasks.discard(task) + try: + exc = task.exception() + except asyncio.CancelledError: + return + if exc is not None: + _emit_error("", exc) + + try: + while True: + req = await queue.get() + if req.get("type") == "exit": + break + task = asyncio.create_task(_handle_request_async(req)) + tasks.add(task) + task.add_done_callback(_task_done) + finally: + for task in tasks: + task.cancel() + if tasks: + await asyncio.gather(*tasks, return_exceptions=True) + + +async def _serve_windows(loop: asyncio.AbstractEventLoop, stdin) -> None: + """Dispatch requests serially, reading each control line on demand. + + A thread perpetually parked in a blocking ``sys.stdin`` read deadlocks + native-extension imports (NumPy in particular) under a pipe-backed + subprocess on Windows: the native DLL load and the concurrent stdin read + wedge each other (numpy#24290, issue #7985). Reading each line via + ``run_in_executor`` confines the stdin read to the gap *between* requests + -- once a line arrives the reader returns, so no thread is reading stdin + while a cell (and its imports) run. The trade-off is that requests are + handled one at a time instead of interleaved; on Windows that is strictly + better than the alternative, since any concurrent reader deadlocks the + import outright. + """ while True: raw_line = await loop.run_in_executor(None, stdin.readline) if not raw_line: @@ -1411,6 +1463,26 @@ async def _main_async() -> None: _emit_error(str(req.get("id", "")), exc) +async def _main_async() -> None: + sys.stdout = _StreamProxy("stdout") + sys.stderr = _StreamProxy("stderr") + _install_idle_sigint() + _start_parent_watchdog() + _start_capture_drain() + + stdin = sys.__stdin__ + if stdin is None: + return + + loop = asyncio.get_running_loop() + _STATE.loop = loop + + if os.name == "nt": + await _serve_windows(loop, stdin) + else: + await _serve_posix(loop, stdin) + + def main() -> None: asyncio.run(_main_async()) diff --git a/packages/coding-agent/test/eval/py/runner-request-dispatch.test.ts b/packages/coding-agent/test/eval/py/runner-request-dispatch.test.ts new file mode 100644 index 000000000000..1dc45a42b532 --- /dev/null +++ b/packages/coding-agent/test/eval/py/runner-request-dispatch.test.ts @@ -0,0 +1,120 @@ +import { describe, expect, it } from "bun:test"; +import * as path from "node:path"; +import { $which } from "@oh-my-pi/pi-utils"; + +interface RunnerFrame { + type?: string; + id?: string; + data?: string; + status?: string; +} + +const pythonPath = Bun.env.PYTHON ?? ($which("python3") ? "python3" : "python"); +const runnerPath = path.resolve(import.meta.dir, "../../../src/eval/py/runner.py"); +const repoRoot = path.resolve(import.meta.dir, "../../../../.."); +const encoder = new TextEncoder(); + +interface Runner { + send(req: Record): void; + nextFrame(): Promise; + dispose(): Promise; +} + +function spawnRunner(): Runner { + const proc = Bun.spawn([pythonPath, "-u", runnerPath], { + cwd: repoRoot, + stdin: "pipe", + stdout: "pipe", + stderr: "pipe", + env: { ...process.env, PYTHONUNBUFFERED: "1", PYTHONIOENCODING: "utf-8" }, + }); + const stderr = new Response(proc.stderr).text(); + const reader = proc.stdout.getReader(); + const decoder = new TextDecoder(); + let pending = ""; + + return { + send(req) { + proc.stdin.write(encoder.encode(`${JSON.stringify(req)}\n`)); + proc.stdin.flush(); + }, + async nextFrame() { + while (true) { + const newline = pending.indexOf("\n"); + if (newline >= 0) { + const line = pending.slice(0, newline); + pending = pending.slice(newline + 1); + return JSON.parse(line) as RunnerFrame; + } + const { value, done } = await reader.read(); + if (done) throw new Error(`Python runner exited before frame: ${await stderr}`); + pending += decoder.decode(value, { stream: true }); + } + }, + async dispose() { + try { + proc.stdin.write(encoder.encode(`${JSON.stringify({ type: "exit" })}\n`)); + proc.stdin.end(); + } catch { + // stdin may already be closed. + } + try { + reader.releaseLock(); + } catch { + // Reader may already be released. + } + try { + proc.kill("SIGKILL"); + } catch { + // Process already exited. + } + }, + }; +} + +async function collectDoneOrder(runner: Runner, ids: Set): Promise { + const dones: RunnerFrame[] = []; + const seen = new Set(); + while (seen.size < ids.size) { + const frame = await runner.nextFrame(); + if (frame.type === "done" && frame.id && ids.has(frame.id) && !seen.has(frame.id)) { + seen.add(frame.id); + dones.push(frame); + } + } + return dones; +} + +// Eval sessions are shared across concurrent agents (subagents inherit the +// parent's eval session id, per executor-base.ts), so multiple requests can be +// in flight on one kernel at once. The runner must keep dispatching sibling +// requests while a cell is parked on a top-level await instead of blocking the +// control channel until it finishes -- the regression that a naive fix for the +// Windows numpy import hang (#7985) would introduce. +describe("Python runner request dispatch", () => { + it("interleaves a fast request past a slow one parked on a top-level await", async () => { + if (process.platform === "win32") return; // Windows dispatches serially by design; see _serve_windows. + const runner = spawnRunner(); + try { + runner.send({ id: "slow", code: "import asyncio\nawait asyncio.sleep(0.5)\nprint('slow-done')" }); + runner.send({ id: "fast", code: "print('fast-done')" }); + const dones = await collectDoneOrder(runner, new Set(["slow", "fast"])); + expect(dones.map(frame => frame.id)).toEqual(["fast", "slow"]); + expect(dones.every(frame => frame.status === "ok")).toBe(true); + } finally { + await runner.dispose(); + } + }); + + it("settles every request and exits cleanly", async () => { + const runner = spawnRunner(); + try { + runner.send({ id: "a", code: "print(1 + 1)" }); + runner.send({ id: "b", code: "print('two')" }); + const dones = await collectDoneOrder(runner, new Set(["a", "b"])); + expect(dones.map(frame => frame.status).sort()).toEqual(["ok", "ok"]); + } finally { + await runner.dispose(); + } + }); +}); diff --git a/packages/coding-agent/test/eval/py/runner-stdin-reader.test.ts b/packages/coding-agent/test/eval/py/runner-stdin-reader.test.ts deleted file mode 100644 index 839363c75386..000000000000 --- a/packages/coding-agent/test/eval/py/runner-stdin-reader.test.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { describe, expect, it } from "bun:test"; -import * as path from "node:path"; -import { $which } from "@oh-my-pi/pi-utils"; - -interface RunnerFrame { - type?: string; - id?: string; - data?: string; - status?: string; -} - -const pythonPath = Bun.env.PYTHON ?? ($which("python3") ? "python3" : "python"); -const runnerPath = path.resolve(import.meta.dir, "../../../src/eval/py/runner.py"); -const repoRoot = path.resolve(import.meta.dir, "../../../../.."); -const encoder = new TextEncoder(); - -async function runCell(code: string): Promise { - const proc = Bun.spawn([pythonPath, "-u", runnerPath], { - cwd: repoRoot, - stdin: "pipe", - stdout: "pipe", - stderr: "pipe", - env: { ...process.env, PYTHONUNBUFFERED: "1", PYTHONIOENCODING: "utf-8" }, - }); - const stderr = new Response(proc.stderr).text(); - const reader = proc.stdout.getReader(); - const decoder = new TextDecoder(); - let pending = ""; - const frames: RunnerFrame[] = []; - - async function readFrame(): Promise { - while (true) { - const newline = pending.indexOf("\n"); - if (newline >= 0) { - const line = pending.slice(0, newline); - pending = pending.slice(newline + 1); - return JSON.parse(line) as RunnerFrame; - } - const { value, done } = await reader.read(); - if (done) throw new Error(`Python runner exited before done frame: ${await stderr}`); - pending += decoder.decode(value, { stream: true }); - } - } - - try { - proc.stdin.write(encoder.encode(`${JSON.stringify({ id: "r1", code })}\n`)); - proc.stdin.flush(); - while (true) { - const frame = await readFrame(); - frames.push(frame); - if (frame.type === "done") break; - } - proc.stdin.write(encoder.encode(`${JSON.stringify({ type: "exit" })}\n`)); - proc.stdin.end(); - const exitCode = await proc.exited; - if (exitCode !== 0) throw new Error(`Python runner exited ${exitCode}: ${await stderr}`); - return frames; - } finally { - try { - reader.releaseLock(); - } catch { - // Reader may already be released by stream closure. - } - try { - proc.kill("SIGKILL"); - } catch { - // Process already exited. - } - } -} - -// A thread perpetually parked in a blocking `sys.stdin` read deadlocks native -// extension imports (NumPy) under a pipe-backed subprocess on Windows -// (numpy#24290, issue #7985). The runner must therefore never keep a -// concurrent control-channel reader alive while a cell (and its imports) run. -describe("Python runner stdin control channel", () => { - it("has no background thread parked in a stdin read while a cell executes", async () => { - const inspect = [ - "import sys, threading", - "main_id = threading.main_thread().ident", - "readers = []", - "for th in threading.enumerate():", - " if th.ident == main_id:", - " continue", - " fr = sys._current_frames().get(th.ident)", - " names = []", - " while fr is not None:", - " names.append(fr.f_code.co_name)", - " fr = fr.f_back", - ' if th.name == "omp-stdin-reader" or "_read_stdin" in names:', - " readers.append(th.name)", - 'print("STDIN_READERS=" + repr(sorted(readers)))', - ].join("\n"); - const frames = await runCell(inspect); - const stdout = frames - .filter(frame => frame.type === "stdout") - .map(frame => frame.data) - .join(""); - - expect(stdout).toContain("STDIN_READERS=[]"); - expect(frames.at(-1)?.status).toBe("ok"); - }); -}); From aac93624a78ca7bae87abb125df732a06bddff1b Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 14 Aug 2026 01:18:38 +0200 Subject: [PATCH 015/795] feat(catalog): surface ClinePass free tier with three-tier metadata enrichment - Overlay the recommended-models free bucket after the validated subscription roster; free ids keep their full OpenRouter-style wire form via a bucket-derived raw tag (new spec-level wireModelIdMode) - Enrich metadata in three tiers mirroring the official client: bundled upstream reference, then OpenRouter's public catalog live for ids the bundle has no real upstream entry for, then conservative defaults - Subscription models carry upstream list prices (API-equivalent display, the codex/github-copilot policy); free tier stays genuinely $0 - Skip the models.dev global overlay for manager-complete free entries so bundle and runtime agree --- packages/catalog/CHANGELOG.md | 3 + packages/catalog/scripts/generate-models.ts | 14 ++ .../src/provider-models/openai-compat.ts | 213 ++++++++++++++++- packages/catalog/src/types.ts | 8 + packages/catalog/src/wire/cline-pass.ts | 34 +++ .../catalog/test/cline-pass-compat.test.ts | 217 +++++++++++++++++- 6 files changed, 479 insertions(+), 10 deletions(-) create mode 100644 packages/catalog/src/wire/cline-pass.ts diff --git a/packages/catalog/CHANGELOG.md b/packages/catalog/CHANGELOG.md index a7c73ca85414..c0565805cf3f 100644 --- a/packages/catalog/CHANGELOG.md +++ b/packages/catalog/CHANGELOG.md @@ -5,6 +5,9 @@ ### Added - Added the native `cline-pass` provider with live roster discovery, generated offline metadata, concise public model IDs, and verified output-token and reasoning-effort request shaping ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). +- ClinePass roster discovery now also surfaces Cline's free-tier models: the `free` bucket of the recommended-models endpoint is overlaid after the subscription roster (which remains the required, independently validated anchor), free IDs keep their full OpenRouter-style form on the wire via a bucket-derived raw wire tag, and known free models self-enrich from the bundled upstream reference with a `(free)` name marker ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). +- ClinePass subscription models now surface upstream list prices (resolved from the bundled reference) so cost display reads as API-equivalent spend, matching the Codex/GitHub Copilot policy; only the free tier renders as $0 ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). +- ClinePass roster metadata now falls through to OpenRouter's public catalog live for ids the bundled reference does not know — the same enrichment source the official Cline client uses — so newly added models get real limits and pricing immediately instead of riding conservative defaults until the next bundle regeneration ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). ## [17.2.10] - 2026-08-06 diff --git a/packages/catalog/scripts/generate-models.ts b/packages/catalog/scripts/generate-models.ts index 1088c17082c6..5610e7929e22 100644 --- a/packages/catalog/scripts/generate-models.ts +++ b/packages/catalog/scripts/generate-models.ts @@ -212,6 +212,20 @@ function applyGlobalModelsDevFallback( ) { return model; } + // ClinePass free-tier entries arrive manager-complete: enriched from the + // bundled upstream reference and carrying a tier-marked name. The same-id + // overlay would overwrite their names with the reference's display name + // (dropping the "(free)" marker) and flip reasoning from unrelated + // same-id data, diverging the bundle from the runtime roster. Their raw + // wire tag marks them as manager-complete. (`.api` equality narrows the + // generic, making the compat field access sound.) + if ( + model.provider === "cline-pass" && + model.api === "openai-completions" && + (model as ModelSpec<"openai-completions">).compat?.wireModelIdMode === "raw" + ) { + return model; + } const reference = globalReferences.get(model.id); if (!reference) { return model; diff --git a/packages/catalog/src/provider-models/openai-compat.ts b/packages/catalog/src/provider-models/openai-compat.ts index bf98f506f82c..62a18764a171 100644 --- a/packages/catalog/src/provider-models/openai-compat.ts +++ b/packages/catalog/src/provider-models/openai-compat.ts @@ -23,6 +23,7 @@ import { getBundledModels } from "../models"; import type { Api, FetchImpl, Model, ModelSpec, OpenAICompat, Provider, ThinkingConfig } from "../types"; import { discoveryFetch, isAnthropicOAuthToken, isRecord, toBoolean, toNumber, toPositiveNumber } from "../utils"; import { ALIBABA_TOKEN_PLAN_BASE_URL, parseAlibabaTokenPlanCredential } from "../wire/alibaba-token-plan"; +import { CLINEPASS_API_BASE_URL, clinePassClientHeaders } from "../wire/cline-pass"; import { coreWeaveProjectHeaders } from "../wire/coreweave"; import { COPILOT_API_HEADERS, @@ -2147,8 +2148,7 @@ export function firepassModelManagerOptions( }; } -const CLINEPASS_API_BASE_URL = "https://api.cline.bot/api/v1"; -const CLINEPASS_MODELS_URL = "https://api.cline.bot/api/v1/ai/cline/recommended-models"; +const CLINEPASS_MODELS_URL = `${CLINEPASS_API_BASE_URL}/ai/cline/recommended-models`; const CLINEPASS_FALLBACK_CONTEXT_WINDOW = 128_000; const CLINEPASS_FALLBACK_MAX_TOKENS = 8_192; @@ -2168,11 +2168,184 @@ function buildClinePassFallbackModel(id: string): ModelSpec<"openai-completions" }; } +/** + * Live reference catalog mirroring Cline's own client enrichment: the official + * CLI fills roster metadata from OpenRouter's public `/models` catalog (their + * gateway routes through it), keyed by full id and by slug. We consult it only + * for models the bundled reference has no real upstream entry for — the bundle + * stays authoritative for known ids, and unknown ids ride fresh live data + * instead of the conservative constants until the next regen. + */ +interface ClinePassLiveCatalogEntry { + name?: string; + contextWindow?: number; + maxTokens?: number; + cost?: ModelSpec<"openai-completions">["cost"]; + reasoning?: boolean; + input?: ("text" | "image")[]; +} + +interface ClinePassLiveCatalog { + byId: ReadonlyMap; + bySlug: ReadonlyMap; +} + +const CLINE_PASS_LIVE_CATALOG_URL = "https://openrouter.ai/api/v1/models"; + +/** Enrichment tier, never authoritative: any failure degrades to the bundled path. */ +async function fetchClinePassLiveCatalog(fetchImpl: FetchImpl): Promise { + try { + const response = await withCatalogDiscoveryTimeout(5_000, signal => + fetchImpl(CLINE_PASS_LIVE_CATALOG_URL, { signal }), + ); + if (!response.ok) return undefined; + const payload: unknown = await response.json(); + if (!isRecord(payload) || !Array.isArray(payload.data)) return undefined; + const byId = new Map(); + const bySlug = new Map(); + for (const raw of payload.data) { + if (!isRecord(raw) || typeof raw.id !== "string" || !raw.id) continue; + const pricing = isRecord(raw.pricing) ? raw.pricing : undefined; + const topProvider = isRecord(raw.top_provider) ? raw.top_provider : undefined; + const params = Array.isArray(raw.supported_parameters) ? raw.supported_parameters : undefined; + const modality = String(isRecord(raw.architecture) ? (raw.architecture.modality ?? "") : ""); + const contextWindow = toPositiveNumber(raw.context_length, 0); + const maxTokens = toPositiveNumber(topProvider?.max_completion_tokens, 0); + const entry: ClinePassLiveCatalogEntry = { + ...(typeof raw.name === "string" && raw.name ? { name: raw.name.replace(/^[^:]+:\s*/, "") } : {}), + ...(contextWindow > 0 ? { contextWindow } : {}), + ...(maxTokens > 0 ? { maxTokens } : {}), + ...(pricing + ? { + cost: { + input: parseFloat(String(pricing.prompt ?? "0")) * 1_000_000, + output: parseFloat(String(pricing.completion ?? "0")) * 1_000_000, + cacheRead: parseFloat(String(pricing.input_cache_read ?? "0")) * 1_000_000, + cacheWrite: parseFloat(String(pricing.input_cache_write ?? "0")) * 1_000_000, + }, + } + : {}), + ...(params ? { reasoning: params.includes("reasoning") } : {}), + ...(modality ? { input: modality.includes("image") ? (["text", "image"] as const) : (["text"] as const) } : {}), + }; + byId.set(raw.id, entry); + // Cline's `buildModelsNameMap` algorithm: roster ids are lab-less slugs + // ("glm-5.2"), so the catalog is also keyed by its last id segment. + const slug = raw.id.split("/").at(-1); + if (slug) bySlug.set(slug, entry); + } + return byId.size > 0 ? { byId, bySlug } : undefined; + } catch { + return undefined; + } +} + +/** Zero legs mean "unpriced upstream", not "free" — pass models bill quota regardless. */ +function hasClinePassBillableCost(cost: ModelSpec<"openai-completions">["cost"] | undefined): boolean { + return cost !== undefined && (cost.input > 0 || cost.output > 0); +} + +/** + * Subscription models bill against plan quota, not per token — but the catalog still + * carries the upstream list price so cost display reads as API-equivalent spend. Same + * policy as the codex/antigravity generator fixups and the zai PAYG descriptor swap + * (issue #5598: an all-$0 roster surfaces every model as "free" in the picker, which + * was treated as a bug there). The price comes from the bundled upstream reference, + * so it works offline and survives roster refreshes (`preferDiscoveryCost` never lets + * a zero overwrite it). Ids with no upstream reference keep the honest zero until + * models.dev prices them. + */ +function buildClinePassSubscriptionModel( + id: string, + references: ReadonlyMap>, + liveCatalog?: ClinePassLiveCatalog, +): ModelSpec<"openai-completions"> { + const base = references.get(id) ?? buildClinePassFallbackModel(id); + const reference = resolveModelReference(id, getBundledModelReferenceIndex()); + // A reference pointing back at our own bundle means the last regen knew + // nothing about the id and encoded fallback constants — treat as no reference. + const upstream = reference && reference.provider !== "cline-pass" ? reference : undefined; + if (upstream) { + // Known to the bundle: overlay the list price only. Missed by the bundle + // (brand-new roster id): full enrichment, like the free-tier path. + return references.has(id) + ? { ...base, cost: upstream.cost } + : { + ...base, + name: upstream.name, + reasoning: upstream.reasoning, + input: upstream.input, + cost: upstream.cost, + contextWindow: upstream.contextWindow, + maxTokens: upstream.maxTokens, + ...(upstream.reasoning ? {} : { thinking: undefined }), + }; + } + const live = liveCatalog?.bySlug.get(id); + if (!live) return base; + return { + ...base, + ...(live.name ? { name: live.name } : {}), + ...(live.contextWindow ? { contextWindow: live.contextWindow } : {}), + ...(live.maxTokens ? { maxTokens: live.maxTokens } : {}), + ...(hasClinePassBillableCost(live.cost) ? { cost: live.cost } : {}), + ...(live.reasoning !== undefined ? { reasoning: live.reasoning } : {}), + ...(live.input ? { input: live.input } : {}), + ...(live.reasoning === false ? { thinking: undefined } : {}), + }; +} + +/** + * Free-tier entries arrive as full OpenRouter-style ids (`deepseek/deepseek-v4-flash`, + * `poolside/laguna-s-2.1:free`) and ride usage billing at $0 outside the subscription + * quota — their cost is genuinely zero, unlike the subscription roster's list-price + * display. Limits and modalities resolve through the bundled upstream reference (its + * candidate expansion treats provider prefixes and trailing `:free`-style markers as + * identity-preserving), so known models self-enrich offline. Compat and thinking are + * deliberately NOT inherited: those describe the reference's native host, while the + * Cline gateway dialect is resolved per provider/family. The raw wire tag is + * bucket-derived — the gateway already namespaces these ids, so the cline-pass prefix + * transform must never apply to them. + */ +function buildClinePassFreeModel(id: string, liveCatalog?: ClinePassLiveCatalog): ModelSpec<"openai-completions"> { + const reference = resolveModelReference(id, getBundledModelReferenceIndex()); + const upstream = reference && reference.provider !== "cline-pass" ? reference : undefined; + // Free ids are OpenRouter-native, so the live catalog matches by full id + // before falling back to the slug — the official client's own lookup order. + const live = liveCatalog?.byId.get(id) ?? liveCatalog?.bySlug.get(id.split("/").at(-1) ?? id); + // References can carry their own free markers (e.g. OpenRouter-style + // "Laguna S 2.1 (free)"); strip before applying our single tier suffix. + const baseName = (upstream?.name ?? live?.name ?? id.split("/").at(-1) ?? id) + .replace(/\s*\(free\)\s*$/i, "") + .replace(/:free$/i, "") + .trim(); + const fallback = buildClinePassFallbackModel(id); + const reasoning = upstream?.reasoning ?? live?.reasoning ?? fallback.reasoning; + return { + ...fallback, + name: `${baseName || id} (free)`, + reasoning, + input: upstream?.input ?? live?.input ?? fallback.input, + contextWindow: upstream?.contextWindow ?? live?.contextWindow ?? fallback.contextWindow, + maxTokens: upstream?.maxTokens ?? live?.maxTokens ?? fallback.maxTokens, + // A non-reasoning reference must not carry the Cline effort ladder. + ...(reasoning ? {} : { thinking: undefined }), + compat: { wireModelIdMode: "raw" }, + }; +} + async function fetchClinePassModels( fetchImpl: FetchImpl, references: ReadonlyMap>, ): Promise[]> { - const response = await withCatalogDiscoveryTimeout(5_000, signal => fetchImpl(CLINEPASS_MODELS_URL, { signal })); + // The roster is authoritative for ids; the live reference catalog is a pure + // enrichment tier fetched alongside and tolerated away (offline → bundle). + const [response, liveCatalog] = await Promise.all([ + withCatalogDiscoveryTimeout(5_000, signal => + fetchImpl(CLINEPASS_MODELS_URL, { signal, headers: clinePassClientHeaders() }), + ), + fetchClinePassLiveCatalog(fetchImpl), + ]); if (!response.ok) { throw new Error(`Failed to fetch ClinePass models: HTTP ${response.status}`); } @@ -2194,19 +2367,42 @@ async function fetchClinePassModels( if (!id) { continue; } - models.set(id, references.get(id) ?? buildClinePassFallbackModel(id)); + models.set(id, buildClinePassSubscriptionModel(id, references, liveCatalog)); } if (models.size === 0) { throw new Error("ClinePass model catalog contains no valid model IDs"); } + + // Free tier rides the same key and gateway at $0 outside the subscription + // quota. Optional overlay: entries validate individually, a cline-pass/-shaped + // entry belongs to the pass bucket, pass ids win any collision, and pass-first + // insertion order keeps the registry's first-available fallback on a + // subscription model. + const freeEntries = Array.isArray(payload.free) ? payload.free : []; + for (const entry of freeEntries) { + if (!isRecord(entry) || typeof entry.id !== "string") { + continue; + } + const id = entry.id.trim(); + if (!id || id.startsWith("cline-pass/") || models.has(id)) { + continue; + } + models.set(id, buildClinePassFreeModel(id, liveCatalog)); + } return [...models.values()]; } /** * Cline's OpenAI-compatible `/models` route is absent, but its public - * recommended-models endpoint is the authoritative ClinePass roster. Bundled - * metadata enriches known ids; conservative defaults keep newly added ids - * usable immediately and the bundled catalog remains the offline fallback. + * recommended-models endpoint is the authoritative ClinePass roster: the + * `clinePass` bucket lists subscription models and the optional `free` bucket + * adds $0 usage-billing models selectable with the same key. Metadata resolves + * in three tiers, mirroring the official client's enrichment: bundled upstream + * reference first, then OpenRouter's public catalog live (tolerated away + * offline), then conservative defaults — so newly added ids are fully usable + * before the next bundle regen. Subscription models surface their upstream list + * price (API-equivalent spend, like codex and github-copilot); only the free + * tier is genuinely $0. */ export function clinePassModelManagerOptions(config?: ModelManagerConfig): ModelManagerOptions<"openai-completions"> { const references = new Map( @@ -5773,11 +5969,12 @@ const MODELS_DEV_PROVIDER_DESCRIPTORS_CORE: readonly ModelsDevProviderDescriptor // --- Cerebras --- openAiCompletionsDescriptor("cerebras", "cerebras", "https://api.cerebras.ai/v1"), // --- ClinePass --- + // Upstream list prices pass through: billing is subscription quota, but cost + // display reads as API-equivalent spend (same policy as codex/antigravity). openAiCompletionsDescriptor("cline-pass", "cline-pass", "https://api.cline.bot/api/v1", { transformModel: (model, modelId, raw) => ({ ...model, id: toClinePassPublicModelId(modelId), - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, ...(model.reasoning && { thinking: buildClinePassThinking(raw), }), diff --git a/packages/catalog/src/types.ts b/packages/catalog/src/types.ts index ea8edee92831..74abbd6dded8 100644 --- a/packages/catalog/src/types.ts +++ b/packages/catalog/src/types.ts @@ -303,6 +303,14 @@ export interface OpenAICompat { openRouterRouting?: OpenRouterRouting; /** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */ vercelGatewayRouting?: VercelGatewayRouting; + /** + * Provider-specific wire model-id transform applied to the base id, overriding + * the provider-detected default. Discovery layers set this per model when the + * upstream roster declares the id's namespace (e.g. ClinePass free-tier models + * arrive pre-namespaced and use `"raw"`), so wire form follows data rather + * than id shape. + */ + wireModelIdMode?: "raw" | "cline-pass" | "firepass" | "fireworks" | "openrouter"; /** Extra fields to include in request body (e.g. gateway routing hints for OpenClaw-style proxies). */ extraBody?: Record; /** Request-session header that should mirror the normalized prompt-cache key. Default: unset. */ diff --git a/packages/catalog/src/wire/cline-pass.ts b/packages/catalog/src/wire/cline-pass.ts new file mode 100644 index 000000000000..e06f6b68b411 --- /dev/null +++ b/packages/catalog/src/wire/cline-pass.ts @@ -0,0 +1,34 @@ +/** + * Cline API base shared by ClinePass subscription inference, free-tier models, + * roster discovery, login validation, and usage reporting. One constant so a + * host migration touches a single module. + */ +export const CLINEPASS_API_BASE_URL = "https://api.cline.bot/api/v1"; + +/** + * Client-identity headers mirroring the official Cline CLI's request layer + * (sdk/packages/llms/src/providers/request-headers.ts). Cline's gateway gates + * some roster entries — certain free-tier models — to Cline product surfaces, + * and this is the contract that identifies a Cline client. Mirrored with Cline's + * blessing for a native integration. + * + * The gate accepted an arbitrary version string when probed (0.0.1 passed on + * 2026-08-13), so the pinned versions are mirror fidelity, not a minimum — but + * the full set is sent deliberately: partial mirrors are one gateway change + * away from a 403. `X-Task-ID` (the CLI's per-session id) is omitted: the gate + * does not require it and a per-request random value would be a worse signal + * than none. + */ +export function clinePassClientHeaders(): Record { + return { + "HTTP-Referer": "https://cline.bot", + "X-Title": "Cline", + "X-IS-MULTIROOT": "false", + "X-CLIENT-TYPE": "cline-cli", + "User-Agent": "Cline/3.0.54", + "X-CLIENT-VERSION": "3.0.54", + "X-PLATFORM": process.platform, + "X-PLATFORM-VERSION": "3.0.54", + "X-CORE-VERSION": "0.0.74", + }; +} diff --git a/packages/catalog/test/cline-pass-compat.test.ts b/packages/catalog/test/cline-pass-compat.test.ts index 238f7c438098..20353d30f42a 100644 --- a/packages/catalog/test/cline-pass-compat.test.ts +++ b/packages/catalog/test/cline-pass-compat.test.ts @@ -72,7 +72,9 @@ describe("ClinePass catalog", () => { baseUrl: "https://api.cline.bot/api/v1", reasoning: true, input: ["text", "image"], - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + // Upstream list prices pass through: billing is subscription quota, but + // cost display reads as API-equivalent spend (codex/github-copilot policy). + cost: { input: 9, output: 12, cacheRead: 0, cacheWrite: 0 }, contextWindow: 1_048_576, maxTokens: 131_072, }); @@ -155,12 +157,25 @@ describe("ClinePass catalog", () => { expect(options.fetchDynamicModels).toBeFunction(); const models = await options.fetchDynamicModels?.(); - expect(requests).toEqual(["https://api.cline.bot/api/v1/ai/cline/recommended-models"]); + expect(requests).toEqual([ + "https://api.cline.bot/api/v1/ai/cline/recommended-models", + // The live reference catalog is fetched alongside and tolerated away: + // this mock returns the roster payload for it, which fails the catalog + // shape check, so the bundled/fallback path below is what is asserted. + "https://openrouter.ai/api/v1/models", + ]); expect(models?.map(model => model.id)).toEqual(["kimi-k3", "future-model"]); expect(models?.[0]?.maxTokens).toBe(131_072); + // A reference-backed subscription id surfaces the upstream list price so the + // picker does not render it as "free" (issue #5598 policy); exact numbers + // track upstream catalog data, so assert the contract, not the digits. + expect(models?.[0]?.cost.input).toBeGreaterThan(0); + expect(models?.[0]?.cost.output).toBeGreaterThan(0); expect(models?.[1]).toMatchObject({ id: "future-model", provider: "cline-pass", + // No upstream reference yet: the honest zero stays until priced upstream. + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, contextWindow: 128_000, maxTokens: 8_192, reasoning: true, @@ -168,6 +183,95 @@ describe("ClinePass catalog", () => { }); }); + it("fills ids the bundle has no upstream reference for from the live catalog", async () => { + // Mirrors the official client's enrichment: when neither the bundle nor + // its upstream reference knows a roster id (brand-new model between + // regens), the live catalog supplies limits and list price instead of the + // conservative constants. + const options = clinePassModelManagerOptions({ + fetch: async input => + String(input).includes("openrouter") + ? new Response( + JSON.stringify({ + data: [ + { + id: "acme/future-model-x", + name: "Acme: Future Model X", + context_length: 500_000, + top_provider: { max_completion_tokens: 64_000 }, + pricing: { prompt: "0.000001", completion: "0.000004" }, + supported_parameters: ["tools", "reasoning"], + architecture: { modality: "text+image->text" }, + }, + ], + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ) + : new Response( + JSON.stringify({ + clinePass: [ + { id: "cline-pass/kimi-k3", name: "cline-pass/kimi-k3" }, + { id: "cline-pass/future-model-x", name: "cline-pass/future-model-x" }, + ], + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ), + }); + + const models = await options.fetchDynamicModels?.(); + expect(models?.map(model => model.id)).toEqual(["kimi-k3", "future-model-x"]); + // Slug-matched (lab-less roster id → lab-prefixed catalog id), vendor + // prefix stripped from the display name. + expect(models?.[1]).toMatchObject({ + id: "future-model-x", + name: "Future Model X", + contextWindow: 500_000, + maxTokens: 64_000, + cost: { input: 1, output: 4, cacheRead: 0, cacheWrite: 0 }, + reasoning: true, + input: ["text", "image"], + }); + }); + + it("keeps free-tier cost at zero even when the live catalog prices the id", async () => { + const options = clinePassModelManagerOptions({ + fetch: async input => + String(input).includes("openrouter") + ? new Response( + JSON.stringify({ + data: [ + { + id: "acme/future-free:free", + name: "Acme: Future Free", + context_length: 300_000, + top_provider: { max_completion_tokens: 32_000 }, + pricing: { prompt: "0.000002", completion: "0.000008" }, + }, + ], + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ) + : new Response( + JSON.stringify({ + clinePass: [{ id: "cline-pass/kimi-k3", name: "cline-pass/kimi-k3" }], + free: [{ id: "acme/future-free:free", name: "future-free:free" }], + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ), + }); + + const models = await options.fetchDynamicModels?.(); + // Full-id match for free entries (the official client's lookup order); + // limits enrich but the tier's $0 is deliberate, never the catalog price. + expect(models?.[1]).toMatchObject({ + id: "acme/future-free:free", + name: "Future Free (free)", + contextWindow: 300_000, + maxTokens: 32_000, + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + }); + }); + it("rejects an empty or malformed authoritative roster so the bundled fallback remains available", async () => { const options = clinePassModelManagerOptions({ fetch: async () => @@ -186,4 +290,113 @@ describe("ClinePass catalog", () => { await expect(options.fetchDynamicModels?.()).rejects.toThrow("contains no valid model IDs"); }); + + it("rejects a malformed pass bucket even when free entries are present", async () => { + const options = clinePassModelManagerOptions({ + fetch: async () => + new Response( + JSON.stringify({ + clinePass: [{ id: "cline-pass/" }, { id: "other-provider/model" }], + free: [{ id: "deepseek/deepseek-v4-flash", name: "deepseek-v4-flash" }], + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ), + }); + + // Free entries must never substitute for the subscription roster: without + // bucket independence this payload would prune every bundled pass model. + await expect(options.fetchDynamicModels?.()).rejects.toThrow("contains no valid model IDs"); + }); + + it("surfaces free-tier models with raw wire ids and bundled upstream enrichment", async () => { + const options = clinePassModelManagerOptions({ + fetch: async () => + new Response( + JSON.stringify({ + clinePass: [{ id: "cline-pass/kimi-k3", name: "cline-pass/kimi-k3" }], + free: [ + { id: "deepseek/deepseek-v4-flash", name: "deepseek-v4-flash" }, + { id: "poolside/laguna-s-2.1:free", name: "laguna-s-2.1:free" }, + { id: "acme/future-model-x:free", name: "future-model-x:free" }, + { id: "cline-free/nemotron-3.5-lightning", name: "nemotron-3.5-lightning" }, + ], + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ), + }); + + const models = await options.fetchDynamicModels?.(); + expect(models?.map(model => model.id)).toEqual([ + "kimi-k3", + "deepseek/deepseek-v4-flash", + "poolside/laguna-s-2.1:free", + "acme/future-model-x:free", + "cline-free/nemotron-3.5-lightning", + ]); + + // Bundled upstream limits/modalities flow through the reference — beating + // the conservative fallback — while identity, pricing, and provider stay + // ClinePass-local. (Exact limits track the largest bundled variant by + // design; pinning them would couple this test to unrelated catalog data.) + const enriched = models?.[1] as ModelSpec<"openai-completions">; + expect(enriched).toMatchObject({ + id: "deepseek/deepseek-v4-flash", + provider: "cline-pass", + name: "DeepSeek V4 Flash (free)", + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + }); + expect(enriched.contextWindow).toBeGreaterThan(128_000); + expect(enriched.maxTokens).toBeGreaterThan(8_192); + // …but the reference's native-host dialect does not: the gateway keeps the + // cline-pass `reasoning` field with family-scoped replay (DeepSeek requires + // it), and the bucket-derived raw tag keeps the id unprefixed on the wire. + const enrichedCompat = buildOpenAICompat(enriched); + expect(enrichedCompat.wireModelIdMode).toBe("raw"); + expect(enrichedCompat.reasoningContentField).toBe("reasoning"); + expect(enrichedCompat.requiresReasoningContentForToolCalls).toBe(true); + + // References that already carry a free marker (the bundled Laguna entry is + // "Laguna S 2.1 (free)") get exactly one tier suffix, never two. + const laguna = models?.[2] as ModelSpec<"openai-completions">; + expect(laguna.name.endsWith("(free)")).toBe(true); + expect(laguna.name).not.toContain("(free) (free)"); + expect(laguna.name).not.toContain(":free"); + + // Unknown free ids ride conservative defaults with a slug-derived name and + // a single tier suffix (`:free` stripped from the slug first). + expect(models?.[3]).toMatchObject({ + id: "acme/future-model-x:free", + name: "future-model-x (free)", + contextWindow: 128_000, + maxTokens: 8_192, + }); + // The cline-free/ shape Cline's SDK reserves passes through raw as well. + expect(buildOpenAICompat(models?.[4] as ModelSpec<"openai-completions">).wireModelIdMode).toBe("raw"); + }); + + it("skips malformed free entries without touching the pass roster", async () => { + const options = clinePassModelManagerOptions({ + fetch: async () => + new Response( + JSON.stringify({ + clinePass: [{ id: "cline-pass/kimi-k3", name: "cline-pass/kimi-k3" }], + free: [ + { id: " " }, + { id: "cline-pass/kimi-k3" }, + { id: "kimi-k3" }, + { name: "no-id" }, + "not-an-object", + { id: "nvidia/nemotron-3.5-lightning", name: "nemotron-3.5-lightning" }, + ], + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ), + }); + + const models = await options.fetchDynamicModels?.(); + expect(models?.map(model => model.id)).toEqual(["kimi-k3", "nvidia/nemotron-3.5-lightning"]); + // The pass entry keeps its enriched bundled metadata and cline-pass wire mode. + expect(models?.[0]?.maxTokens).toBe(131_072); + expect(buildOpenAICompat(models?.[0] as ModelSpec<"openai-completions">).wireModelIdMode).toBe("cline-pass"); + }); }); From 9ab8068a414e88c70f78fa2da4ec1449bdd40565 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 14 Aug 2026 01:18:45 +0200 Subject: [PATCH 016/795] feat(ai): mirror Cline CLI client identity and harden ClinePass errors - Send the official Cline CLI client-identity header set on every api.cline.bot call (inference, roster, account routes) with Cline's blessing; unlocks roster entries gated to Cline product surfaces, e.g. free-tier deepseek/deepseek-v4-flash - Validate login against /users/me instead of a probe completion: roster-agnostic and quota-free - Classify subscription-window and free-tier limit markers as usage limits (fail fast, rotate siblings); rewrite not-subscribed, org-account, roster-rotation, and surface-gate failures with recovery guidance - Exempt the client-surface-gate 403 from credential rotation: per-model client policy, not a credential problem --- packages/ai/CHANGELOG.md | 5 +- packages/ai/src/error/auth-classify.ts | 5 +- packages/ai/src/error/flags.ts | 12 ++ packages/ai/src/error/format.ts | 4 + packages/ai/src/error/rate-limit.ts | 10 +- .../ai/src/providers/openai-completions.ts | 11 +- packages/ai/src/registry/cline-pass.ts | 12 +- packages/ai/src/usage/cline-pass.ts | 7 +- packages/ai/src/utils/http-inspector.ts | 40 ++++++ packages/ai/test/auth-retry.test.ts | 10 ++ packages/ai/test/cline-pass-login.test.ts | 22 ++-- packages/ai/test/cline-pass-transport.test.ts | 123 ++++++++++++++++-- packages/ai/test/http-inspector.test.ts | 55 ++++++++ packages/ai/test/rate-limit-utils.test.ts | 22 ++++ 14 files changed, 307 insertions(+), 31 deletions(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index b3e91c345d96..7ed0e93a11d9 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -4,7 +4,10 @@ ### Added -- Added API-key authentication for ClinePass through the official `CLINE_API_KEY` variable, including direct Chat Completions validation and rolling quota-window reporting in `omp usage` ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). +- Added API-key authentication for ClinePass through the official `CLINE_API_KEY` variable, including account-route validation and rolling quota-window reporting in `omp usage` ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). +- ClinePass login now validates the API key against the `/users/me` account identity route instead of a probe chat completion, so roster churn cannot break sign-in and validation no longer consumes subscription quota ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). +- ClinePass failures now surface actionable messages: subscription-window and free-tier limit markers classify as usage limits (fail fast, rotate sibling credentials), while not-subscribed, organization-account, and roster-rotation `model not found` responses are rewritten with recovery guidance ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). +- ClinePass requests now mirror the official Cline CLI's client-identity headers (with Cline's blessing), unlocking roster entries the gateway restricts to Cline product surfaces — including free-tier `deepseek/deepseek-v4-flash`. A surface-gate 403 is classified as per-model client policy rather than a credential failure, so it no longer rotates sibling keys ([#7863](https://github.com/can1357/oh-my-pi/pull/7863) by [@will-bogusz](https://github.com/will-bogusz)). ## [17.2.10] - 2026-08-06 diff --git a/packages/ai/src/error/auth-classify.ts b/packages/ai/src/error/auth-classify.ts index a253b0ad88cc..9639ceed10d9 100644 --- a/packages/ai/src/error/auth-classify.ts +++ b/packages/ai/src/error/auth-classify.ts @@ -1,5 +1,5 @@ import { extractHttpStatusFromError } from "@oh-my-pi/pi-utils"; -import { isOAuthExpiry, isUsageLimit } from "./flags"; +import { isClinePassSurfaceGateMessage, isOAuthExpiry, isUsageLimit } from "./flags"; import { isConcurrencyCapExclusion, isUsageLimitOutcome } from "./rate-limit"; /** @@ -42,6 +42,9 @@ export function isAuthRetryableError(error: unknown): boolean { const embeddedStatus = message ? extractHttpStatusFromError({ message }) : undefined; const status = httpStatus ?? embeddedStatus; if (isConcurrencyCapExclusion(status, message)) return false; + // A Cline surface-gate 403 is per-model client policy, not a credential + // problem: sibling keys fail identically, so rotation only burns them. + if (isClinePassSurfaceGateMessage(message)) return false; if (status === 401 || status === 403) return true; return isUsageLimitOutcome(status, message); } diff --git a/packages/ai/src/error/flags.ts b/packages/ai/src/error/flags.ts index c72ba90748e1..97e919483b15 100644 --- a/packages/ai/src/error/flags.ts +++ b/packages/ai/src/error/flags.ts @@ -512,6 +512,18 @@ function providerErrorCode(error: object): string | undefined { return undefined; } +const CLINE_PASS_SURFACE_GATE_PATTERN = /only available via cline product surfaces/i; + +/** + * Cline's gateway gates some roster entries (certain free-tier models) to its + * own product surfaces with a 403. The API key is valid — the restriction is + * per-model client policy — so it must neither rotate sibling credentials (they + * fail identically) nor surface as an auth failure. + */ +export function isClinePassSurfaceGateMessage(errorMessage: string | undefined): boolean { + return errorMessage !== undefined && CLINE_PASS_SURFACE_GATE_PATTERN.test(errorMessage); +} + /** * GitHub Copilot 400 rejecting a model its own `/models` catalog advertises — * transient fleet skew, not a malformed request. Reads the structural `code` diff --git a/packages/ai/src/error/format.ts b/packages/ai/src/error/format.ts index 58360712fae9..42d53467c903 100644 --- a/packages/ai/src/error/format.ts +++ b/packages/ai/src/error/format.ts @@ -2,6 +2,7 @@ import { type CapturedHttpErrorResponse, finalizeErrorMessage, type RawHttpRequestDump, + rewriteClinePassError, rewriteCopilotError, } from "../utils/http-inspector"; import { formatErrorMessageWithRetryAfter } from "../utils/retry-after"; @@ -38,6 +39,9 @@ export async function formatMessage(error: unknown, opts: FormatMessageOptions = if (opts.provider === "github-copilot") { message = rewriteCopilotError(message, error, opts.provider); } + if (opts.provider === "cline-pass") { + message = rewriteClinePassError(message, opts.provider); + } if (opts.provider === "ollama") { message = rewriteOllamaToolCallJsonError(message); } diff --git a/packages/ai/src/error/rate-limit.ts b/packages/ai/src/error/rate-limit.ts index 972a533ec19f..ef795ae7f83e 100644 --- a/packages/ai/src/error/rate-limit.ts +++ b/packages/ai/src/error/rate-limit.ts @@ -23,6 +23,10 @@ const ACCOUNT_RATE_LIMIT_PATTERN = const INSUFFICIENT_BALANCE_PATTERN = /insufficient.?balance/i; const SPEND_LIMIT_PATTERN = /spend.?limit/i; const OPENROUTER_DAILY_FREE_LIMIT_PATTERN = /\bfree[-_ ]models[-_ ]per[-_ ]day\b/i; +// ClinePass subscription-window exhaustion ("clinepass limit …") and free-tier +// model caps ("free limit reached on model … try again in …") are account-local +// quota exhaustion, not per-minute rate limiting. +const CLINE_PASS_QUOTA_PATTERN = /clinepass limit|free limit reached on model/i; // gRPC/Connect end-streams carry the status as its name (`resource_exhausted`), // while HTTP bodies use the phrase ("resource exhausted"). Strip either form // before classifying explicit details; an otherwise opaque status is transient @@ -84,6 +88,10 @@ export function parseRateLimitReason(errorMessage: string): RateLimitReason { return "QUOTA_EXHAUSTED"; } + if (CLINE_PASS_QUOTA_PATTERN.test(errorMessage)) { + return "QUOTA_EXHAUSTED"; + } + if ( lower.includes("per minute") || lower.includes("rate limit") || @@ -142,7 +150,7 @@ export function calculateRateLimitBackoffMs(reason: RateLimitReason): number { /** Detect usage/quota limit errors in error messages (persistent, requires credential switch). */ const USAGE_LIMIT_PATTERN = - /usage.?limit|usage_limit_reached|usage_not_included|limit_reached|quota.?(?:exceeded|reached|insufficient)|额度不足|额度耗尽|resource.?exhausted|exhausted your capacity|quota will reset|insufficient.?(?:balance|quota)|balance.?exhausted|run out of credits|out of credits|spending[- _]?limit|personal-team-blocked/i; + /usage.?limit|usage_limit_reached|usage_not_included|limit_reached|quota.?(?:exceeded|reached|insufficient)|额度不足|额度耗尽|resource.?exhausted|exhausted your capacity|quota will reset|insufficient.?(?:balance|quota)|balance.?exhausted|run out of credits|out of credits|spending[- _]?limit|personal-team-blocked|clinepass limit|free limit reached on model/i; /** * HTTP status codes that, absent richer body classification, represent an diff --git a/packages/ai/src/providers/openai-completions.ts b/packages/ai/src/providers/openai-completions.ts index d60c1004cc54..4e7a66a7d27f 100644 --- a/packages/ai/src/providers/openai-completions.ts +++ b/packages/ai/src/providers/openai-completions.ts @@ -2,6 +2,7 @@ import type { Effort } from "@oh-my-pi/pi-catalog/effort"; import { isKimiModelId } from "@oh-my-pi/pi-catalog/identity"; import { resolveWireModelId } from "@oh-my-pi/pi-catalog/model-thinking"; import { calculateCost } from "@oh-my-pi/pi-catalog/models"; +import { clinePassClientHeaders } from "@oh-my-pi/pi-catalog/wire/cline-pass"; import type { ResolvedOpenAICompat } from "@oh-my-pi/pi-catalog/types"; import { $env, parseStreamingJson, parseStreamingJsonThrottled } from "@oh-my-pi/pi-utils"; import { renderDemotedThinking } from "../dialect/demotion"; @@ -1410,7 +1411,15 @@ function createRequestSetup( // Provider auth/header overlay: Kimi-code hosts require shared client // attribution headers prepended before caller headers. Kept here (not in // the shared helper) because it is provider-specific request setup. - prependHeaders: model.provider === "kimi-code" ? getKimiCommonHeaders : undefined, + // ClinePass mirrors the official Cline CLI's client-identity headers: the + // gateway gates parts of the roster (some free-tier models) to Cline + // product surfaces, and this is the contract that identifies one. + prependHeaders: + model.provider === "kimi-code" + ? getKimiCommonHeaders + : model.provider === "cline-pass" + ? clinePassClientHeaders + : undefined, alibabaCodingPlanAuth: true, azureChatCompletions: { apiVersion, deploymentName }, }); diff --git a/packages/ai/src/registry/cline-pass.ts b/packages/ai/src/registry/cline-pass.ts index ff167210d527..1beddea3a25c 100644 --- a/packages/ai/src/registry/cline-pass.ts +++ b/packages/ai/src/registry/cline-pass.ts @@ -1,3 +1,4 @@ +import { CLINEPASS_API_BASE_URL, clinePassClientHeaders } from "@oh-my-pi/pi-catalog/wire/cline-pass"; import { createApiKeyLogin } from "./api-key-login"; import type { OAuthLoginCallbacks } from "./oauth/types"; import type { ProviderDefinition } from "./types"; @@ -8,13 +9,14 @@ export const loginClinePass = createApiKeyLogin({ instructions: "Create an API key in the Cline dashboard under Settings → API Keys", promptMessage: "Paste your Cline API key", placeholder: "sk_...", + // Validate against the account identity route, not a probe completion: login + // must not couple to any roster model (roster churn can retire the probe's + // target) and must not consume subscription quota on a ping. validation: { - kind: "chat-completions", + kind: "models-endpoint", provider: "ClinePass", - baseUrl: "https://api.cline.bot/api/v1", - model: "cline-pass/kimi-k3", - maxTokensField: "max_completion_tokens", - maxTokens: 16, + modelsUrl: `${CLINEPASS_API_BASE_URL}/users/me`, + headers: clinePassClientHeaders, }, }); diff --git a/packages/ai/src/usage/cline-pass.ts b/packages/ai/src/usage/cline-pass.ts index bbd4492e9957..5fc20e6fd239 100644 --- a/packages/ai/src/usage/cline-pass.ts +++ b/packages/ai/src/usage/cline-pass.ts @@ -1,3 +1,4 @@ +import { CLINEPASS_API_BASE_URL, clinePassClientHeaders } from "@oh-my-pi/pi-catalog/wire/cline-pass"; import { ProviderHttpError } from "../error"; import type { UsageFetchContext, @@ -10,7 +11,7 @@ import type { import { isRecord } from "../utils"; const PROVIDER = "cline-pass"; -const DEFAULT_BASE_URL = "https://api.cline.bot/api/v1"; +const DEFAULT_BASE_URL = CLINEPASS_API_BASE_URL; // Dashboard quota route. It accepts the same API key as inference; account OAuth is not required. const USAGE_LIMITS_PATH = "/users/me/plan/usage-limits"; const ACCOUNT_PATH = "/users/me"; @@ -111,6 +112,10 @@ async function fetchClinePassUsage(params: UsageFetchParams, ctx: UsageFetchCont const baseUrl = (params.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, ""); const usageUrl = `${baseUrl}${USAGE_LIMITS_PATH}`; const headers = { + // The CLI's client identity rides every api.cline.bot call, not just + // inference: a uniform mirror keeps account routes working if the + // gateway ever extends its client-surface gating beyond model traffic. + ...clinePassClientHeaders(), Accept: "application/json", Authorization: `Bearer ${credential.apiKey}`, }; diff --git a/packages/ai/src/utils/http-inspector.ts b/packages/ai/src/utils/http-inspector.ts index b62e0f5fd4e5..f8d701c53f10 100644 --- a/packages/ai/src/utils/http-inspector.ts +++ b/packages/ai/src/utils/http-inspector.ts @@ -119,6 +119,46 @@ export function rewriteCopilotError(errorMessage: string, error: unknown, provid return errorMessage; } +const CLINE_PASS_NOT_SUBSCRIBED_PATTERN = + /not subscribed to required model plan|no access to clinepass subscription models/i; +const CLINE_PASS_ORG_ACCOUNT_PATTERN = /organization accounts cannot use individual model inference subscriptions/i; +const CLINE_PASS_MODEL_NOT_FOUND_PATTERN = /model not found/i; + +/** + * Rewrite error messages for ClinePass request failures. Gated to the + * cline-pass provider: the "model not found" marker is too generic to match + * for other hosts. + * + * not-subscribed (400) = the key is valid but the account has no ClinePass + * subscription; free-tier models remain usable on the same key. + * org restriction (400) = organization accounts cannot use individual + * inference subscriptions; a personal-account key is required. + * model-not-found (400) = roster rotation removed the model since selection; + * the fix is reselection, not retry. (Quota windows — "clinepass + * limit", "free limit reached on model" — are classified upstream in + * error/rate-limit and need no rewrite.) + * surface-gate (403) = the model is restricted to Cline's official clients. + * Requests carry the mirrored CLI identity headers, so reaching this + * means Cline's gate policy changed; the classifier exempts it from + * credential rotation (sibling keys fail identically). + */ +export function rewriteClinePassError(errorMessage: string, provider: string): string { + if (provider !== "cline-pass") return errorMessage; + if (CLINE_PASS_NOT_SUBSCRIBED_PATTERN.test(errorMessage)) { + return 'This model requires a ClinePass subscription. Free-tier models (marked "(free)" in the picker) work with any Cline account.'; + } + if (CLINE_PASS_ORG_ACCOUNT_PATTERN.test(errorMessage)) { + return "ClinePass is unavailable for organization accounts: individual inference subscriptions are personal-plan only. Log in with a personal Cline API key."; + } + if (AIError.isClinePassSurfaceGateMessage(errorMessage)) { + return "Cline restricts this model to its official product surfaces and the mirrored CLI client identity was not accepted. Pick another model with /model and report the regression — the header mirror may need updating."; + } + if (CLINE_PASS_MODEL_NOT_FOUND_PATTERN.test(errorMessage)) { + return "Cline removed this model from the roster since it was selected. Pick another with /model — the roster refreshes automatically while your API key is configured."; + } + return errorMessage; +} + function sanitizeDump(dump: RawHttpRequestDump): RawHttpRequestDump { return { ...dump, diff --git a/packages/ai/test/auth-retry.test.ts b/packages/ai/test/auth-retry.test.ts index e438dcf04231..2dc9bdf66e63 100644 --- a/packages/ai/test/auth-retry.test.ts +++ b/packages/ai/test/auth-retry.test.ts @@ -87,6 +87,16 @@ describe("isAuthRetryableError", () => { // sibling account may not share the restriction, so rotate. expect(isAuthRetryableError(authError(403))).toBe(true); expect(isAuthRetryableError("Error: 403 forbidden")).toBe(true); + // Cline's client-surface gate (403) is per-model client policy, not a + // credential problem: sibling keys fail identically, so rotation would + // only burn them. + expect( + isAuthRetryableError( + new Error( + "Error 403: deepseek/deepseek-v4-flash is only available via Cline product surfaces. If you are using an old version of Cline, please update to the latest version", + ), + ), + ).toBe(false); expect(isAuthRetryableError(authError(500))).toBe(false); expect(isAuthRetryableError(new Error("network blip"))).toBe(false); expect(isAuthRetryableError(undefined)).toBe(false); diff --git a/packages/ai/test/cline-pass-login.test.ts b/packages/ai/test/cline-pass-login.test.ts index 8823e32dc8a4..ff12678606be 100644 --- a/packages/ai/test/cline-pass-login.test.ts +++ b/packages/ai/test/cline-pass-login.test.ts @@ -3,16 +3,18 @@ import { loginClinePass } from "@oh-my-pi/pi-ai/registry/cline-pass"; import type { FetchImpl } from "@oh-my-pi/pi-ai/types"; describe("ClinePass login", () => { - it("opens the dashboard and validates the API key against the subscription chat route", async () => { + it("opens the dashboard and validates the key against the account identity route", async () => { const authUrls: string[] = []; let authorization = ""; let requestUrl = ""; - let requestBody: Record = {}; + let requestMethod = ""; + let hasBody = false; const fetchMock: FetchImpl = async (input, init) => { requestUrl = String(input); + requestMethod = init?.method ?? "GET"; authorization = String((init?.headers as Record | undefined)?.Authorization); - requestBody = JSON.parse(String(init?.body)) as Record; - return Response.json({ choices: [] }); + hasBody = init?.body !== undefined; + return Response.json({ email: "user@example.com" }); }; const result = await loginClinePass({ @@ -23,13 +25,11 @@ describe("ClinePass login", () => { expect(result).toBe("sk_test"); expect(authUrls).toEqual(["https://app.cline.bot/dashboard/account"]); - expect(requestUrl).toBe("https://api.cline.bot/api/v1/chat/completions"); + // Account identity route, not a probe completion: login stays decoupled + // from roster churn and never burns subscription quota on validation. + expect(requestUrl).toBe("https://api.cline.bot/api/v1/users/me"); + expect(requestMethod).toBe("GET"); expect(authorization).toBe("Bearer sk_test"); - expect(requestBody).toEqual({ - model: "cline-pass/kimi-k3", - messages: [{ role: "user", content: "ping" }], - max_completion_tokens: 16, - temperature: 0, - }); + expect(hasBody).toBe(false); }); }); diff --git a/packages/ai/test/cline-pass-transport.test.ts b/packages/ai/test/cline-pass-transport.test.ts index e5af034acd81..77aa4f751846 100644 --- a/packages/ai/test/cline-pass-transport.test.ts +++ b/packages/ai/test/cline-pass-transport.test.ts @@ -1,9 +1,35 @@ import { describe, expect, it } from "bun:test"; import { streamOpenAICompletions } from "@oh-my-pi/pi-ai/providers/openai-completions"; import type { Context, FetchImpl, Model, Tool } from "@oh-my-pi/pi-ai/types"; +import { buildModel } from "@oh-my-pi/pi-catalog/build"; import { Effort } from "@oh-my-pi/pi-catalog/effort"; import { getBundledModel } from "@oh-my-pi/pi-catalog/models"; +/** + * Mirrors what `fetchClinePassModels` produces for a free-bucket entry with a + * bundled upstream reference: full OpenRouter-style id, raw wire mode, Cline + * effort ladder. Synthetic so the transport contract is pinned independently + * of the current bundled roster. + */ +const freeTierDeepseek = buildModel({ + id: "deepseek/deepseek-v4-flash", + name: "DeepSeek V4 Flash (free)", + api: "openai-completions", + provider: "cline-pass", + baseUrl: "https://api.cline.bot/api/v1", + reasoning: true, + input: ["text"], + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + contextWindow: 1_048_576, + maxTokens: 393_216, + thinking: { + mode: "effort", + efforts: [Effort.Minimal, Effort.Low, Effort.Medium, Effort.High, Effort.XHigh, Effort.Max], + effortMap: { minimal: "none", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, + }, + compat: { wireModelIdMode: "raw" }, +}) as Model<"openai-completions">; + const markerTool: Tool = { name: "get_marker", description: "Return a marker", @@ -85,19 +111,24 @@ function toolCompletionResponse(model: string): Response { async function capturePayload(options: { modelId?: string; + model?: Model<"openai-completions">; context?: Context; reasoning?: Effort; disableReasoning?: boolean; toolChoice?: { type: "tool"; name: string }; -}): Promise> { - const model = getBundledModel<"openai-completions">( - "cline-pass", - options.modelId ?? "kimi-k3", - ) as Model<"openai-completions">; +}): Promise<{ payload: Record; headers: Record }> { + const model = + options.model ?? + (getBundledModel<"openai-completions">( + "cline-pass", + options.modelId ?? "kimi-k3", + ) as Model<"openai-completions">); let payload: Record | undefined; + let headers: Record = {}; const fetchMock: FetchImpl = Object.assign( async (_input: string | URL | Request, init?: RequestInit): Promise => { payload = JSON.parse(typeof init?.body === "string" ? init.body : "{}") as Record; + headers = Object.fromEntries(new Headers(init?.headers).entries()); return completionResponse(model.id); }, { preconnect: fetch.preconnect }, @@ -111,12 +142,12 @@ async function capturePayload(options: { toolChoice: options.toolChoice, }).result(); if (!payload) throw new Error("Expected ClinePass request payload"); - return payload; + return { payload, headers }; } describe("ClinePass OpenAI transport", () => { it("sends Cline's wire model ID, token field, max effort, and forced tool choice", async () => { - const payload = await capturePayload({ + const { payload } = await capturePayload({ reasoning: Effort.Max, toolChoice: { type: "tool", name: "get_marker" }, }); @@ -130,14 +161,86 @@ describe("ClinePass OpenAI transport", () => { }); it("disables ClinePass reasoning with the gateway's none effort", async () => { - const payload = await capturePayload({ disableReasoning: true }); + const { payload } = await capturePayload({ disableReasoning: true }); expect(payload.reasoning_effort).toBe("none"); expect(payload.model).toBe("cline-pass/kimi-k3"); }); + it("mirrors the Cline CLI client-identity headers", async () => { + // The gateway gates part of the roster (some free-tier models) to Cline + // product surfaces; this header set is the contract that identifies a Cline + // client (sdk/packages/llms/src/providers/request-headers.ts). Sent on + // every ClinePass request, mirrored with Cline's blessing. + const { headers } = await capturePayload({ model: freeTierDeepseek }); + + expect(headers).toMatchObject({ + "http-referer": "https://cline.bot", + "x-title": "Cline", + "x-is-multiroot": "false", + "x-client-type": "cline-cli", + "x-client-version": expect.stringMatching(/^\d+\.\d+\.\d+$/), + "x-platform": process.platform, + "x-platform-version": expect.stringMatching(/^\d+\.\d+\.\d+$/), + "x-core-version": expect.stringMatching(/^\d+\.\d+\.\d+$/), + "user-agent": expect.stringMatching(/^Cline\/\d+\.\d+\.\d+$/), + }); + expect(headers.authorization).toBe("Bearer test-key"); + }); + + it("sends free-tier ids unprefixed on the wire", async () => { + // Free models ride usage billing under full OpenRouter-style ids; the + // bucket-derived raw wire tag keeps the cline-pass prefix off them. Built + // as a synthetic spec so the test pins the transport contract, not the + // current bundle contents. + const { payload } = await capturePayload({ model: freeTierDeepseek, reasoning: Effort.Low }); + + expect(payload.model).toBe("deepseek/deepseek-v4-flash"); + expect(payload.reasoning_effort).toBe("low"); + expect(payload.max_completion_tokens).toBe(64); + }); + + it("replays reasoning on free-tier DeepSeek tool continuations with the gateway field", async () => { + const firstFetch: FetchImpl = Object.assign(async () => toolCompletionResponse(freeTierDeepseek.id), { + preconnect: fetch.preconnect, + }); + const assistant = await streamOpenAICompletions(freeTierDeepseek, context, { + apiKey: "test-key", + fetch: firstFetch, + maxTokens: 64, + reasoning: Effort.Low, + }).result(); + const { payload } = await capturePayload({ + model: freeTierDeepseek, + context: { + ...context, + messages: [ + ...context.messages, + assistant, + { + role: "toolResult", + toolCallId: "call_marker", + toolName: "get_marker", + content: [{ type: "text", text: "42" }], + isError: false, + timestamp: 1, + }, + ], + }, + reasoning: Effort.Low, + }); + const messages = payload.messages as Array>; + const wireAssistant = messages.find(message => message.role === "assistant"); + + expect(payload.model).toBe("deepseek/deepseek-v4-flash"); + // DeepSeek family requires reasoning replay on tool continuations even on + // the free tier; the gateway field is `reasoning`, not `reasoning_content`. + expect(wireAssistant?.reasoning).toBe("Inspect the marker."); + expect(wireAssistant?.reasoning_content).toBeUndefined(); + }); + it("downgrades a forced ClinePass Qwen tool choice to auto while preserving reasoning", async () => { - const payload = await capturePayload({ + const { payload } = await capturePayload({ modelId: "qwen3.7-max", reasoning: Effort.Low, toolChoice: { type: "tool", name: "get_marker" }, @@ -159,7 +262,7 @@ describe("ClinePass OpenAI transport", () => { maxTokens: 64, reasoning: Effort.Low, }).result(); - const payload = await capturePayload({ + const { payload } = await capturePayload({ modelId: "qwen3.7-max", context: { ...context, diff --git a/packages/ai/test/http-inspector.test.ts b/packages/ai/test/http-inspector.test.ts index 5763d2689a4d..e46cdfa2b67a 100644 --- a/packages/ai/test/http-inspector.test.ts +++ b/packages/ai/test/http-inspector.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "bun:test"; import { buildHttp400DumpPayload, type RawHttpRequestDump, + rewriteClinePassError, shouldDumpRejectedRequest, } from "@oh-my-pi/pi-ai/utils/http-inspector"; @@ -67,3 +68,57 @@ describe("shouldDumpRejectedRequest", () => { expect(shouldDumpRejectedRequest(new Error("network reset"))).toBe(false); }); }); + +describe("rewriteClinePassError", () => { + it("rewrites not-subscribed into free-tier guidance", () => { + const rewritten = rewriteClinePassError("the user is not subscribed to required model plan", "cline-pass"); + expect(rewritten).toContain("requires a ClinePass subscription"); + expect(rewritten).toContain("free"); + }); + + it("rewrites the alternate not-subscribed phrasing", () => { + const rewritten = rewriteClinePassError( + "No access to ClinePass subscription models yet. Subscribe to ClinePass", + "cline-pass", + ); + expect(rewritten).toContain("requires a ClinePass subscription"); + }); + + it("rewrites organization-account restriction", () => { + const rewritten = rewriteClinePassError( + "organization accounts cannot use individual model inference subscriptions", + "cline-pass", + ); + expect(rewritten).toContain("organization accounts"); + expect(rewritten).toContain("personal Cline API key"); + }); + + it("rewrites roster-rotation model-not-found into reselection guidance", () => { + const rewritten = rewriteClinePassError("model not found", "cline-pass"); + expect(rewritten).toContain("removed this model from the roster"); + expect(rewritten).toContain("/model"); + }); + + it("rewrites the client-surface gate into actionable guidance", () => { + const rewritten = rewriteClinePassError( + "Error 403: deepseek/deepseek-v4-flash is only available via Cline product surfaces. If you are using an old version of Cline, please update to the latest version", + "cline-pass", + ); + expect(rewritten).toContain("official product surfaces"); + expect(rewritten).toContain("/model"); + }); + + it("does not let the surface-gate rewrite swallow model-not-found", () => { + // Marker independence: the surface-gate pattern must not match the + // roster-rotation phrasing and vice versa. + expect(rewriteClinePassError("model not found", "cline-pass")).toContain("removed this model"); + }); + + it("leaves other providers untouched — the marker is too generic for them", () => { + expect(rewriteClinePassError("model not found", "openrouter")).toBe("model not found"); + }); + + it("leaves unrelated cline-pass errors untouched", () => { + expect(rewriteClinePassError("500 internal server error", "cline-pass")).toBe("500 internal server error"); + }); +}); diff --git a/packages/ai/test/rate-limit-utils.test.ts b/packages/ai/test/rate-limit-utils.test.ts index 15e5b9bab075..87ae250f03c4 100644 --- a/packages/ai/test/rate-limit-utils.test.ts +++ b/packages/ai/test/rate-limit-utils.test.ts @@ -16,6 +16,20 @@ describe("parseRateLimitReason", () => { ).toBe("QUOTA_EXHAUSTED"); }); + // ClinePass subscription windows and free-tier caps are account-local quota + // exhaustion (markers from Cline's own error classifier), not rate limiting. + it("classifies ClinePass subscription-window limits as QUOTA_EXHAUSTED", () => { + expect(parseRateLimitReason("clinepass limit reached for this window. please try again later.")).toBe( + "QUOTA_EXHAUSTED", + ); + }); + + it("classifies Cline free-tier model caps as QUOTA_EXHAUSTED", () => { + expect( + parseRateLimitReason("free limit reached on model deepseek/deepseek-v4-flash. try again in 42 minutes"), + ).toBe("QUOTA_EXHAUSTED"); + }); + // "Resource has been exhausted (e.g. check quota)" is a quota/daily-limit error — long wait. // Only the literal phrase "resource exhausted" (gRPC status name) is MODEL_CAPACITY. it("classifies 'Resource has been exhausted (e.g. check quota)' as QUOTA_EXHAUSTED", () => { @@ -246,6 +260,14 @@ describe("isUsageLimitOutcome", () => { } }); + it("rotates on ClinePass limit markers regardless of status", () => { + expect(isUsageLimitOutcome(429, "clinepass limit reached for this window. please try again later.")).toBe(true); + expect(isUsageLimitOutcome(undefined, "clinepass limit reached for this window. please try again later.")).toBe( + true, + ); + expect(isUsageLimitOutcome(undefined, "free limit reached on model x/y. try again in 5 minutes")).toBe(true); + }); + it("keeps informative transient 429s in the upstream-backoff lane", () => { // RATE_LIMIT_EXCEEDED — generic throttling. expect(isUsageLimitOutcome(429, "Cloud Code Assist API error (429): Too many requests")).toBe(false); From 60281c40bf2113af6a379ce6ec8524c34e9df2e4 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 14 Aug 2026 01:19:04 +0200 Subject: [PATCH 017/795] docs: document ClinePass free tier, pricing, and CLI mirror --- docs/environment-variables.md | 2 +- docs/provider-endpoint-constraints.md | 8 ++++++-- docs/providers.md | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/environment-variables.md b/docs/environment-variables.md index 9ac6e81470b2..050a2cd2c305 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -89,7 +89,7 @@ These are consumed via `getEnvApiKey()` (`packages/ai/src/stream.ts`) unless not | `SILICONFLOW_CN_API_KEY` | SiliconFlow (China) auth | Using `siliconflow-cn` provider | | | `KILO_API_KEY` | Kilo auth | Using Kilo models | | | `OLLAMA_CLOUD_API_KEY` | Ollama Cloud auth | Using `ollama-cloud` provider | | -| `CLINE_API_KEY` | ClinePass subscription auth | Using the `cline-pass` provider | Official Cline API-key variable | +| `CLINE_API_KEY` | ClinePass subscription + free-tier auth | Using the `cline-pass` provider | Official Cline API-key variable | | `WAFER_SERVERLESS_API_KEY` | Wafer Serverless auth | Using `wafer-serverless` provider | Pay-as-you-go Wafer SKU; validated against `https://pass.wafer.ai/v1/models` | | `GITLAB_TOKEN` | GitLab Duo auth | Using `gitlab-duo` provider | | diff --git a/docs/provider-endpoint-constraints.md b/docs/provider-endpoint-constraints.md index ba07a930c0dc..60fdf65f7aa3 100644 --- a/docs/provider-endpoint-constraints.md +++ b/docs/provider-endpoint-constraints.md @@ -152,9 +152,13 @@ routing, model ids, or usage accounting. ### ClinePass -- Catalog IDs omit the gateway's `cline-pass/` namespace; Chat Completions adds it on the wire. -- The OpenAI-compatible `/models` route is absent. Discover the authoritative roster from Cline's public `recommended-models` endpoint, with the generated catalog as an offline metadata fallback. +- Requests carry the official Cline CLI's client-identity header set (`X-CLIENT-TYPE`, `X-CLIENT-VERSION`, `X-PLATFORM`, `X-CORE-VERSION`, `HTTP-Referer`, `X-Title`, `User-Agent: Cline/`), mirrored from `sdk/packages/llms/src/providers/request-headers.ts` with Cline's blessing. The gateway gates parts of the roster (some free-tier models) to Cline product surfaces with a 403; the mirror is the supported identification contract. Version values are not minimum-checked (probed 2026-08-13). +- Catalog IDs omit the gateway's `cline-pass/` namespace; Chat Completions adds it on the wire. Free-tier models are the exception: they keep their full OpenRouter-style IDs (e.g. `deepseek/deepseek-v4-flash`), which the gateway already namespaces, so they go on the wire unprefixed via a per-model raw wire tag set at discovery time (bucket-derived, not ID-shape-derived). +- The OpenAI-compatible `/models` route is absent. Discover the authoritative roster from Cline's public `recommended-models` endpoint: the `clinePass` bucket is the subscription roster (required; a malformed bucket is rejected so the bundled fallback survives), and the optional `free` bucket overlays $0 usage-billing models that work on any Cline account, subscription or not. Metadata resolves in three tiers mirroring the official client's enrichment: bundled upstream reference, then OpenRouter's public `/models` catalog live (fetched in parallel, tolerated away offline — keyed by full id for free entries, slug for pass entries), then conservative defaults. The generated catalog is the offline fallback. +- Billing is subscription quota, but subscription models carry the upstream list price (resolved from the bundled reference at discovery time) so cost display reads as API-equivalent spend — the codex/github-copilot policy. Only the free tier is genuinely $0; ids with no upstream reference stay zero until models.dev prices them. - Output limits use `max_completion_tokens`. Reasoning uses `reasoning_effort` (`none` through `max`) and streams through `delta.reasoning`; continuations replay it only for model families whose compatibility policy requires reasoning history. +- Login validates the key against `/users/me` rather than a probe completion, so roster churn cannot lock out sign-in and validation never consumes subscription quota. +- Subscription-window exhaustion (`clinepass limit`) and free-tier caps (`free limit reached on model …`) classify as usage limits (fail fast, rotate sibling credentials). A not-subscribed response on a subscription model is rewritten to point at the free tier; a `model not found` response after roster rotation is rewritten to suggest reselection. - The dashboard's `/users/me/plan/usage-limits` route accepts the inference API key and returns five-hour, weekly, and monthly utilization with reset times; `/users/me` supplies the account email label. Usage reporting does not require account OAuth. ### Fireworks and Firepass diff --git a/docs/providers.md b/docs/providers.md index b050f30b7e7d..a7137dcefe60 100644 --- a/docs/providers.md +++ b/docs/providers.md @@ -51,7 +51,7 @@ For headless or remote setups backed by a shared auth broker, the CLI exposes `o When a model has no credentials, `omp` tells you to run `/login` or set the provider's environment variable. -For ClinePass, set `CLINE_API_KEY` or run `/login cline-pass` to open the Cline dashboard and validate a newly created API key. OMP refreshes its model roster from Cline's public recommended-models endpoint, retains generated metadata as an offline fallback, and reports the subscription's five-hour, weekly, and monthly quota windows through `omp usage`. +For ClinePass, set `CLINE_API_KEY` or run `/login cline-pass` to open the Cline dashboard and validate a newly created API key. OMP refreshes its model roster from Cline's public recommended-models endpoint, retains generated metadata as an offline fallback, and reports the subscription's five-hour, weekly, and monthly quota windows through `omp usage`. The roster also includes Cline's free-tier models (marked `(free)`): they ride the same key at $0 outside the subscription quota, so they work on any Cline account even without a ClinePass subscription. Subscription models show their upstream list price in the model picker and session cost as an API-equivalent reference (matching Codex and GitHub Copilot); only the `(free)` tier is actually $0. The integration mirrors the official Cline CLI's client behavior throughout — client-identity headers, roster interpretation, and OpenRouter-based metadata enrichment for models the bundled catalog has not priced yet — with Cline's blessing for a native integration. ### Pinning a key in `models.yml` From 08d359258a33594de9e4f69a6b246cc233bc9a1e Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 14 Aug 2026 01:31:37 +0200 Subject: [PATCH 018/795] fix(catalog): heal degenerate ClinePass bundle limits from upstream reference A bundled entry carrying the exact fallback limit pair was written by a regen that had no upstream data for the id; when a real upstream reference later exists, take its limits instead of trusting the stale fallback (qwen3.8-max 128k/8k -> 1M/131072). --- .../catalog/src/provider-models/openai-compat.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/catalog/src/provider-models/openai-compat.ts b/packages/catalog/src/provider-models/openai-compat.ts index 0d5d5b7f4803..1211bfde77db 100644 --- a/packages/catalog/src/provider-models/openai-compat.ts +++ b/packages/catalog/src/provider-models/openai-compat.ts @@ -2315,14 +2315,18 @@ function buildClinePassSubscriptionModel( // A reference pointing back at our own bundle means the last regen knew // nothing about the id and encoded fallback constants — treat as no reference. const upstream = reference && reference.provider !== "cline-pass" ? reference : undefined; + // Same degeneracy on the bundle side: a bundled entry whose limits are the + // fallback pair was written by a regen that had no upstream data for the id. + const baseLimitsAreFallback = + base.contextWindow === CLINEPASS_FALLBACK_CONTEXT_WINDOW && base.maxTokens === CLINEPASS_FALLBACK_MAX_TOKENS; if (upstream) { - // Known to the bundle: overlay the list price only. Missed by the bundle - // (brand-new roster id): full enrichment, like the free-tier path. - return references.has(id) + // Known to the bundle with real limits: overlay the list price only. + // Otherwise full enrichment, like the free-tier path. + return references.has(id) && !baseLimitsAreFallback ? { ...base, cost: upstream.cost } : { ...base, - name: upstream.name, + name: references.has(id) ? base.name : upstream.name, reasoning: upstream.reasoning, input: upstream.input, cost: upstream.cost, From 2dc570b563749f6dd0901494cdbee5dfadacae8a Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 14 Aug 2026 01:31:41 +0200 Subject: [PATCH 019/795] chore(catalog): regenerate models.json Bundles the ClinePass free tier (raw-tagged, $0) and upstream list prices for the subscription roster; remainder is upstream catalog drift on merged main. --- packages/catalog/src/models.json | 3012 ++++++++++++++++++++++++++---- 1 file changed, 2680 insertions(+), 332 deletions(-) diff --git a/packages/catalog/src/models.json b/packages/catalog/src/models.json index e72c0992a3a3..45dd0104e56f 100644 --- a/packages/catalog/src/models.json +++ b/packages/catalog/src/models.json @@ -16,7 +16,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1048576, + "contextWindow": 1000000, "maxTokens": 393216, "thinking": { "mode": "effort", @@ -25,8 +25,7 @@ "high", "max" ] - }, - "supportsComputerUse": false + } }, "deepseek-ai/deepseek-v4-pro": { "id": "deepseek-ai/deepseek-v4-pro", @@ -44,7 +43,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1048576, + "contextWindow": 1000000, "maxTokens": 393216, "thinking": { "mode": "effort", @@ -53,8 +52,7 @@ "high", "max" ] - }, - "supportsComputerUse": false + } }, "google/gemma-4-31b-it": { "id": "google/gemma-4-31b-it", @@ -84,8 +82,37 @@ "high", "xhigh" ] + } + }, + "moonshotai/kimi-k2.6": { + "id": "moonshotai/kimi-k2.6", + "name": "Kimi K2.6", + "api": "openai-completions", + "provider": "aiand", + "baseUrl": "https://api.aiand.com/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0.85, + "output": 3.5, + "cacheRead": 0, + "cacheWrite": 0 }, - "supportsComputerUse": false + "contextWindow": 262144, + "maxTokens": 262144, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh" + ] + } }, "moonshotai/kimi-k2.7-code": { "id": "moonshotai/kimi-k2.7-code", @@ -115,8 +142,7 @@ "high", "xhigh" ] - }, - "supportsComputerUse": false + } }, "moonshotai/kimi-k3": { "id": "moonshotai/kimi-k3", @@ -207,8 +233,7 @@ "medium", "high" ] - }, - "supportsComputerUse": false + } }, "qwen/qwen3.6-27b": { "id": "qwen/qwen3.6-27b", @@ -222,8 +247,8 @@ "image" ], "cost": { - "input": 0.32, - "output": 3.2, + "input": 0, + "output": 0, "cacheRead": 0, "cacheWrite": 0 }, @@ -237,8 +262,36 @@ "medium", "high" ] + } + }, + "zai-org/glm-5.1": { + "id": "zai-org/glm-5.1", + "name": "GLM 5.1", + "api": "openai-completions", + "provider": "aiand", + "baseUrl": "https://api.aiand.com/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 1.4, + "output": 4.4, + "cacheRead": 0, + "cacheWrite": 0 }, - "supportsComputerUse": false + "contextWindow": 202752, + "maxTokens": 131072, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh" + ] + } }, "zai-org/glm-5.2": { "id": "zai-org/glm-5.2", @@ -256,7 +309,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1048576, + "contextWindow": 1000000, "maxTokens": 131072, "thinking": { "mode": "effort", @@ -267,8 +320,7 @@ "high", "max" ] - }, - "supportsComputerUse": false + } } }, "aimlapi": { @@ -14198,9 +14250,9 @@ "text" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 0.14, + "output": 0.28, + "cacheRead": 0.0028, "cacheWrite": 0 }, "contextWindow": 1000000, @@ -14238,9 +14290,9 @@ "text" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 0.435, + "output": 0.87, + "cacheRead": 0.003625, "cacheWrite": 0 }, "contextWindow": 1000000, @@ -14267,9 +14319,9 @@ "supportsComputerUse": false, "supportsComputerUseConfig": false }, - "glm-5.2": { - "id": "glm-5.2", - "name": "GLM-5.2", + "deepseek/deepseek-v4-flash": { + "id": "deepseek/deepseek-v4-flash", + "name": "DeepSeek V4 Flash (free)", "api": "openai-completions", "provider": "cline-pass", "baseUrl": "https://api.cline.bot/api/v1", @@ -14283,6 +14335,48 @@ "cacheRead": 0, "cacheWrite": 0 }, + "contextWindow": 1048576, + "maxTokens": 393216, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "compat": { + "wireModelIdMode": "raw" + } + }, + "glm-5.2": { + "id": "glm-5.2", + "name": "GLM-5.2", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 1.4, + "output": 4.4, + "cacheRead": 0.26, + "cacheWrite": 0 + }, "contextWindow": 1000000, "maxTokens": 131072, "thinking": { @@ -14319,9 +14413,9 @@ "image" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 0.5605, + "output": 2.36, + "cacheRead": 0.0944, "cacheWrite": 0 }, "contextWindow": 262144, @@ -14360,9 +14454,9 @@ "image" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 0.67, + "output": 3.4, + "cacheRead": 0.15, "cacheWrite": 0 }, "contextWindow": 262144, @@ -14401,9 +14495,9 @@ "image" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 3, + "output": 15, + "cacheRead": 0.3, "cacheWrite": 0 }, "contextWindow": 1048576, @@ -14444,12 +14538,12 @@ "image" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 0.14, + "output": 0.28, + "cacheRead": 0.0028, "cacheWrite": 0 }, - "contextWindow": 1048576, + "contextWindow": 1050000, "maxTokens": 131072, "thinking": { "mode": "effort", @@ -14484,12 +14578,12 @@ "text" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 0.435, + "output": 0.87, + "cacheRead": 0.0036, "cacheWrite": 0 }, - "contextWindow": 1048576, + "contextWindow": 1050000, "maxTokens": 131072, "thinking": { "mode": "effort", @@ -14525,9 +14619,9 @@ "image" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 0.4125, + "output": 1.65, + "cacheRead": 0.0875, "cacheWrite": 0 }, "contextWindow": 512000, @@ -14554,9 +14648,9 @@ "supportsComputerUse": false, "supportsComputerUseConfig": false }, - "qwen3.7-max": { - "id": "qwen3.7-max", - "name": "Qwen3.7 Max", + "nvidia/nemotron-3.5-lightning": { + "id": "nvidia/nemotron-3.5-lightning", + "name": "Nvidia Nemotron 3.5 Lightning (free)", "api": "openai-completions", "provider": "cline-pass", "baseUrl": "https://api.cline.bot/api/v1", @@ -14571,7 +14665,7 @@ "cacheWrite": 0 }, "contextWindow": 1000000, - "maxTokens": 65536, + "maxTokens": 262144, "thinking": { "mode": "effort", "efforts": [ @@ -14592,18 +14686,19 @@ } }, "supportsComputerUse": false, - "supportsComputerUseConfig": false + "compat": { + "wireModelIdMode": "raw" + } }, - "qwen3.7-plus": { - "id": "qwen3.7-plus", - "name": "Qwen3.7 Plus", + "poolside/laguna-s-2.1:free": { + "id": "poolside/laguna-s-2.1:free", + "name": "Laguna S 2.1 (free)", "api": "openai-completions", "provider": "cline-pass", "baseUrl": "https://api.cline.bot/api/v1", "reasoning": true, "input": [ - "text", - "image" + "text" ], "cost": { "input": 0, @@ -14611,8 +14706,50 @@ "cacheRead": 0, "cacheWrite": 0 }, + "contextWindow": 262144, + "maxTokens": 32768, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "compat": { + "wireModelIdMode": "raw" + } + }, + "qwen3.7-max": { + "id": "qwen3.7-max", + "name": "Qwen3.7 Max", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 2.5, + "output": 7.5, + "cacheRead": 0.5, + "cacheWrite": 3.125 + }, "contextWindow": 1000000, - "maxTokens": 64000, + "maxTokens": 65536, "thinking": { "mode": "effort", "efforts": [ @@ -14635,9 +14772,9 @@ "supportsComputerUse": false, "supportsComputerUseConfig": false }, - "qwen3.8-max": { - "id": "qwen3.8-max", - "name": "Qwen3.8 Max", + "qwen3.7-plus": { + "id": "qwen3.7-plus", + "name": "Qwen3.7 Plus", "api": "openai-completions", "provider": "cline-pass", "baseUrl": "https://api.cline.bot/api/v1", @@ -14647,13 +14784,54 @@ "image" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 + "input": 0.4, + "output": 1.6, + "cacheRead": 0.04, + "cacheWrite": 0.5 }, - "contextWindow": 128000, - "maxTokens": 8192, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortMap": { + "minimal": "none", + "low": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max" + } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "qwen3.8-max": { + "id": "qwen3.8-max", + "name": "Qwen3.8 Max", + "api": "openai-completions", + "provider": "cline-pass", + "baseUrl": "https://api.cline.bot/api/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 2, + "output": 6, + "cacheRead": 0.25, + "cacheWrite": 2.5 + }, + "contextWindow": 1000000, + "maxTokens": 131072, "thinking": { "mode": "effort", "efforts": [ @@ -21525,113 +21703,2223 @@ }, "contextWindow": 200000, "maxTokens": 64000, - "cursorMaxMode": false, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "cursorMaxMode": false, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "grok-code-fast-1": { + "id": "grok-code-fast-1", + "name": "Grok Code Fast 1", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 256000, + "maxTokens": 10000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ] + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "kimi-k2.5": { + "id": "kimi-k2.5", + "name": "Kimi K2.5", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 262144, + "maxTokens": 65536, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ] + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "kimi-k2.7-code": { + "id": "kimi-k2.7-code", + "name": "Kimi K2.7 Code", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 200000, + "maxTokens": 64000, + "cursorMaxMode": false, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ] + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "kimi-k3-high": { + "id": "kimi-k3-high", + "name": "Kimi K3 High", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "cursorMaxMode": false, + "supportsComputerUse": false, + "supportsComputerUseConfig": false, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ], + "defaultLevel": "max", + "requiresEffort": true + } + }, + "kimi-k3-low": { + "id": "kimi-k3-low", + "name": "Kimi K3 Low", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "cursorMaxMode": false, + "supportsComputerUse": false, + "supportsComputerUseConfig": false, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ], + "defaultLevel": "max", + "requiresEffort": true + } + }, + "kimi-k3-max": { + "id": "kimi-k3-max", + "name": "Kimi K3", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "cursorMaxMode": false, + "supportsComputerUse": false, + "supportsComputerUseConfig": false, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ], + "defaultLevel": "max", + "requiresEffort": true + } + } + }, + "deepseek": { + "deepseek-v4-flash": { + "id": "deepseek-v4-flash", + "name": "DeepSeek V4 Flash", + "api": "openai-completions", + "provider": "deepseek", + "baseUrl": "https://api.deepseek.com", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0.14, + "output": 0.28, + "cacheRead": 0.0028, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 384000, + "compat": { + "supportsDeveloperRole": false, + "supportsReasoningEffort": true, + "maxTokensField": "max_tokens", + "supportsToolChoice": false, + "extraBody": { + "thinking": { + "type": "enabled" + } + }, + "reasoningContentField": "reasoning_content", + "requiresReasoningContentForToolCalls": true, + "requiresAssistantContentForToolCalls": true + }, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ] + } + }, + "deepseek-v4-pro": { + "id": "deepseek-v4-pro", + "name": "DeepSeek V4 Pro", + "api": "openai-completions", + "provider": "deepseek", + "baseUrl": "https://api.deepseek.com", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0.435, + "output": 0.87, + "cacheRead": 0.003625, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 384000, + "compat": { + "supportsDeveloperRole": false, + "supportsReasoningEffort": true, + "maxTokensField": "max_tokens", + "supportsToolChoice": false, + "extraBody": { + "thinking": { + "type": "enabled" + } + }, + "reasoningContentField": "reasoning_content", + "requiresReasoningContentForToolCalls": true, + "requiresAssistantContentForToolCalls": true + }, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ] + } + } + }, + "devin": { + "claude-fable-5": { + "id": "claude-fable-5", + "name": "Claude Fable 5", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "requiresEffort": true, + "effortRouting": { + "low": "claude-5-fable-low", + "medium": "claude-5-fable-medium", + "high": "claude-5-fable-high", + "xhigh": "claude-5-fable-xhigh", + "max": "claude-5-fable-max" + } + }, + "supportsComputerUse": false, + "requestModelId": "claude-5-fable-low" + }, + "claude-opus-4-6": { + "id": "claude-opus-4-6", + "name": "Claude Opus 4.6", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 200000, + "maxTokens": 64000, + "thinking": { + "mode": "budget", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ], + "effortRouting": { + "off": "claude-opus-4-6", + "minimal": "claude-opus-4-6-thinking", + "low": "claude-opus-4-6-thinking", + "medium": "claude-opus-4-6-thinking", + "high": "claude-opus-4-6-thinking" + } + }, + "supportsComputerUse": false + }, + "claude-opus-4-6-1m": { + "id": "claude-opus-4-6-1m", + "name": "Claude Opus 4.6 1M", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "budget", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ], + "effortRouting": { + "off": "claude-opus-4-6-1m", + "minimal": "claude-opus-4-6-thinking-1m", + "low": "claude-opus-4-6-thinking-1m", + "medium": "claude-opus-4-6-thinking-1m", + "high": "claude-opus-4-6-thinking-1m" + } + }, + "supportsComputerUse": false + }, + "claude-opus-4-7": { + "id": "claude-opus-4-7", + "name": "Claude Opus 4.7", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "requiresEffort": true, + "effortRouting": { + "low": "claude-opus-4-7-low", + "medium": "claude-opus-4-7-medium", + "high": "claude-opus-4-7-high", + "xhigh": "claude-opus-4-7-xhigh", + "max": "claude-opus-4-7-max" + } + }, + "supportsComputerUse": false, + "requestModelId": "claude-opus-4-7-low" + }, + "claude-opus-4-8": { + "id": "claude-opus-4-8", + "name": "Claude Opus 4.8", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "requiresEffort": true, + "effortRouting": { + "low": "claude-opus-4-8-low", + "medium": "claude-opus-4-8-medium", + "high": "claude-opus-4-8-high", + "xhigh": "claude-opus-4-8-xhigh", + "max": "claude-opus-4-8-max" + } + }, + "supportsComputerUse": false, + "requestModelId": "claude-opus-4-8-low" + }, + "claude-opus-4-8-fast": { + "id": "claude-opus-4-8-fast", + "name": "Claude Opus 4.8 Fast", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "requiresEffort": true, + "effortRouting": { + "low": "claude-opus-4-8-low-fast", + "medium": "claude-opus-4-8-medium-fast", + "high": "claude-opus-4-8-high-fast", + "xhigh": "claude-opus-4-8-xhigh-fast", + "max": "claude-opus-4-8-max-fast" + } + }, + "supportsComputerUse": false, + "requestModelId": "claude-opus-4-8-low-fast" + }, + "claude-opus-5": { + "id": "claude-opus-5", + "name": "Claude Opus 5", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "requiresEffort": true, + "effortRouting": { + "low": "claude-opus-5-low", + "medium": "claude-opus-5-medium", + "high": "claude-opus-5-high", + "xhigh": "claude-opus-5-xhigh", + "max": "claude-opus-5-max" + } + }, + "supportsComputerUse": false, + "requestModelId": "claude-opus-5-low" + }, + "claude-opus-5-fast": { + "id": "claude-opus-5-fast", + "name": "Claude Opus 5 Fast", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "requiresEffort": true, + "effortRouting": { + "low": "claude-opus-5-low-fast", + "medium": "claude-opus-5-medium-fast", + "high": "claude-opus-5-high-fast", + "xhigh": "claude-opus-5-xhigh-fast", + "max": "claude-opus-5-max-fast" + } + }, + "supportsComputerUse": false, + "requestModelId": "claude-opus-5-low-fast" + }, + "claude-sonnet-4-6": { + "id": "claude-sonnet-4-6", + "name": "Claude Sonnet 4.6", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 200000, + "maxTokens": 64000, + "thinking": { + "mode": "budget", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ], + "effortRouting": { + "off": "claude-sonnet-4-6", + "minimal": "claude-sonnet-4-6-thinking", + "low": "claude-sonnet-4-6-thinking", + "medium": "claude-sonnet-4-6-thinking", + "high": "claude-sonnet-4-6-thinking" + } + }, + "supportsComputerUse": false + }, + "claude-sonnet-4-6-1m": { + "id": "claude-sonnet-4-6-1m", + "name": "Claude Sonnet 4.6 1M", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "budget", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ], + "effortRouting": { + "off": "claude-sonnet-4-6-1m", + "minimal": "claude-sonnet-4-6-thinking-1m", + "low": "claude-sonnet-4-6-thinking-1m", + "medium": "claude-sonnet-4-6-thinking-1m", + "high": "claude-sonnet-4-6-thinking-1m" + } + }, + "supportsComputerUse": false + }, + "claude-sonnet-5": { + "id": "claude-sonnet-5", + "name": "Claude Sonnet 5", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "requiresEffort": true, + "effortRouting": { + "low": "claude-sonnet-5-low", + "medium": "claude-sonnet-5-medium", + "high": "claude-sonnet-5-high", + "xhigh": "claude-sonnet-5-xhigh", + "max": "claude-sonnet-5-max" + } + }, + "supportsComputerUse": false, + "requestModelId": "claude-sonnet-5-low" + }, + "deepseek-v4-flash-high": { + "id": "deepseek-v4-flash-high", + "name": "DeepSeek V4 Flash High", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "deepseek-v4-flash-low": { + "id": "deepseek-v4-flash-low", + "name": "DeepSeek V4 Flash Low", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "deepseek-v4-flash-max": { + "id": "deepseek-v4-flash-max", + "name": "DeepSeek V4 Flash Max", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "deepseek-v4-pro-high": { + "id": "deepseek-v4-pro-high", + "name": "DeepSeek V4 Pro High", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "deepseek-v4-pro-low": { + "id": "deepseek-v4-pro-low", + "name": "DeepSeek V4 Pro Low", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "deepseek-v4-pro-max": { + "id": "deepseek-v4-pro-max", + "name": "DeepSeek V4 Pro Max", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "gemini-3-1-pro": { + "id": "gemini-3-1-pro", + "name": "Gemini 3.1 Pro", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high" + ], + "requiresEffort": true, + "effortRouting": { + "low": "gemini-3-1-pro-low", + "high": "gemini-3-1-pro-high" + } + }, + "supportsComputerUse": false, + "requestModelId": "gemini-3-1-pro-low" + }, + "gemini-3-5-flash": { + "id": "gemini-3-5-flash", + "name": "Gemini 3.5 Flash", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ], + "requiresEffort": true, + "effortRouting": { + "minimal": "gemini-3-5-flash-minimal", + "low": "gemini-3-5-flash-low", + "medium": "gemini-3-5-flash-medium", + "high": "gemini-3-5-flash-high" + } + }, + "supportsComputerUse": false, + "requestModelId": "gemini-3-5-flash-minimal" + }, + "gemini-3-6-flash": { + "id": "gemini-3-6-flash", + "name": "Gemini 3.6 Flash", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ], + "requiresEffort": true, + "effortRouting": { + "minimal": "gemini-3-6-flash-minimal", + "low": "gemini-3-6-flash-low", + "medium": "gemini-3-6-flash-medium", + "high": "gemini-3-6-flash-high" + } + }, + "supportsComputerUse": false, + "requestModelId": "gemini-3-6-flash-minimal" + }, + "gemini-3-7-flash-high": { + "id": "gemini-3-7-flash-high", + "name": "Gemini 3.7 Flash High", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "gemini-3-7-flash-low": { + "id": "gemini-3-7-flash-low", + "name": "Gemini 3.7 Flash Low", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "gemini-3-7-flash-medium": { + "id": "gemini-3-7-flash-medium", + "name": "Gemini 3.7 Flash Medium", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "gemini-3-7-flash-minimal": { + "id": "gemini-3-7-flash-minimal", + "name": "Gemini 3.7 Flash Minimal", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "gemini-3-flash": { + "id": "gemini-3-flash", + "name": "Gemini 3 Flash", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ], + "requiresEffort": true, + "effortRouting": { + "minimal": "MODEL_GOOGLE_GEMINI_3_0_FLASH_MINIMAL", + "low": "MODEL_GOOGLE_GEMINI_3_0_FLASH_LOW", + "medium": "MODEL_GOOGLE_GEMINI_3_0_FLASH_MEDIUM", + "high": "MODEL_GOOGLE_GEMINI_3_0_FLASH_HIGH" + } + }, + "supportsComputerUse": false, + "requestModelId": "MODEL_GOOGLE_GEMINI_3_0_FLASH_MINIMAL" + }, + "glm-5-2": { + "id": "glm-5-2", + "name": "GLM-5.2", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 200000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "high", + "xhigh" + ], + "requiresEffort": true, + "effortRouting": { + "high": "glm-5-2", + "xhigh": "glm-5-2" + } + }, + "supportsComputerUse": false + }, + "glm-5-2-1m": { + "id": "glm-5-2-1m", + "name": "GLM-5.2 High 1M", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "supportsComputerUse": false, + "requestModelId": "glm-5-2-none-1m" + }, + "gpt-5-2": { + "id": "gpt-5-2", + "name": "GPT-5.2", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 384000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh" + ], + "effortRouting": { + "off": "MODEL_GPT_5_2_NONE", + "low": "MODEL_GPT_5_2_LOW", + "medium": "MODEL_GPT_5_2_MEDIUM", + "high": "MODEL_GPT_5_2_HIGH", + "xhigh": "MODEL_GPT_5_2_XHIGH" + } + }, + "supportsComputerUse": false, + "requestModelId": "MODEL_GPT_5_2_NONE" + }, + "gpt-5-3-codex": { + "id": "gpt-5-3-codex", + "name": "GPT-5.3 Codex", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 400000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh" + ], + "requiresEffort": true, + "effortRouting": { + "low": "gpt-5-3-codex-low", + "medium": "gpt-5-3-codex-medium", + "high": "gpt-5-3-codex-high", + "xhigh": "gpt-5-3-codex-xhigh" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-3-codex-low" + }, + "gpt-5-3-codex-fast": { + "id": "gpt-5-3-codex-fast", + "name": "GPT-5.3 Codex Fast", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 400000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh" + ], + "requiresEffort": true, + "effortRouting": { + "low": "gpt-5-3-codex-low-priority", + "medium": "gpt-5-3-codex-medium-priority", + "high": "gpt-5-3-codex-high-priority", + "xhigh": "gpt-5-3-codex-xhigh-priority" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-3-codex-low-priority" + }, + "gpt-5-4": { + "id": "gpt-5-4", + "name": "GPT-5.4", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 272000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh" + ], + "effortRouting": { + "off": "gpt-5-4-none", + "low": "gpt-5-4-low", + "medium": "gpt-5-4-medium", + "high": "gpt-5-4-high", + "xhigh": "gpt-5-4-xhigh" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-4-none" + }, + "gpt-5-4-fast": { + "id": "gpt-5-4-fast", + "name": "GPT-5.4 Fast", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 272000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh" + ], + "effortRouting": { + "off": "gpt-5-4-none-priority", + "low": "gpt-5-4-low-priority", + "medium": "gpt-5-4-medium-priority", + "high": "gpt-5-4-high-priority", + "xhigh": "gpt-5-4-xhigh-priority" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-4-none-priority" + }, + "gpt-5-4-mini": { + "id": "gpt-5-4-mini", + "name": "GPT-5.4 Mini", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 400000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh" + ], + "requiresEffort": true, + "effortRouting": { + "low": "gpt-5-4-mini-low", + "medium": "gpt-5-4-mini-medium", + "high": "gpt-5-4-mini-high", + "xhigh": "gpt-5-4-mini-xhigh" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-4-mini-low" + }, + "gpt-5-5": { + "id": "gpt-5-5", + "name": "GPT-5.5", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 272000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh" + ], + "effortRouting": { + "off": "gpt-5-5-none", + "low": "gpt-5-5-low", + "medium": "gpt-5-5-medium", + "high": "gpt-5-5-high", + "xhigh": "gpt-5-5-xhigh" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-5-none" + }, + "gpt-5-5-fast": { + "id": "gpt-5-5-fast", + "name": "GPT-5.5 Fast", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 272000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh" + ], + "effortRouting": { + "off": "gpt-5-5-none-priority", + "low": "gpt-5-5-low-priority", + "medium": "gpt-5-5-medium-priority", + "high": "gpt-5-5-high-priority", + "xhigh": "gpt-5-5-xhigh-priority" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-5-none-priority" + }, + "gpt-5-6-luna": { + "id": "gpt-5-6-luna", + "name": "GPT-5.6 Luna", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortRouting": { + "off": "gpt-5-6-luna-none", + "low": "gpt-5-6-luna-low", + "medium": "gpt-5-6-luna-medium", + "high": "gpt-5-6-luna-high", + "xhigh": "gpt-5-6-luna-xhigh", + "max": "gpt-5-6-luna-max" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-6-luna-none" + }, + "gpt-5-6-luna-fast": { + "id": "gpt-5-6-luna-fast", + "name": "GPT-5.6 Luna Fast", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortRouting": { + "off": "gpt-5-6-luna-none-priority", + "low": "gpt-5-6-luna-low-priority", + "medium": "gpt-5-6-luna-medium-priority", + "high": "gpt-5-6-luna-high-priority", + "xhigh": "gpt-5-6-luna-xhigh-priority", + "max": "gpt-5-6-luna-max-priority" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-6-luna-none-priority" + }, + "gpt-5-6-sol": { + "id": "gpt-5-6-sol", + "name": "GPT-5.6 Sol", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortRouting": { + "off": "gpt-5-6-sol-none", + "low": "gpt-5-6-sol-low", + "medium": "gpt-5-6-sol-medium", + "high": "gpt-5-6-sol-high", + "xhigh": "gpt-5-6-sol-xhigh", + "max": "gpt-5-6-sol-max" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-6-sol-none" + }, + "gpt-5-6-sol-fast": { + "id": "gpt-5-6-sol-fast", + "name": "GPT-5.6 Sol Fast", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortRouting": { + "off": "gpt-5-6-sol-none-priority", + "low": "gpt-5-6-sol-low-priority", + "medium": "gpt-5-6-sol-medium-priority", + "high": "gpt-5-6-sol-high-priority", + "xhigh": "gpt-5-6-sol-xhigh-priority", + "max": "gpt-5-6-sol-max-priority" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-6-sol-none-priority" + }, + "gpt-5-6-terra": { + "id": "gpt-5-6-terra", + "name": "GPT-5.6 Terra", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortRouting": { + "off": "gpt-5-6-terra-none", + "low": "gpt-5-6-terra-low", + "medium": "gpt-5-6-terra-medium", + "high": "gpt-5-6-terra-high", + "xhigh": "gpt-5-6-terra-xhigh", + "max": "gpt-5-6-terra-max" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-6-terra-none" + }, + "gpt-5-6-terra-fast": { + "id": "gpt-5-6-terra-fast", + "name": "GPT-5.6 Terra Fast", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortRouting": { + "off": "gpt-5-6-terra-none-priority", + "low": "gpt-5-6-terra-low-priority", + "medium": "gpt-5-6-terra-medium-priority", + "high": "gpt-5-6-terra-high-priority", + "xhigh": "gpt-5-6-terra-xhigh-priority", + "max": "gpt-5-6-terra-max-priority" + } + }, + "supportsComputerUse": false, + "requestModelId": "gpt-5-6-terra-none-priority" + }, + "grok-4-5": { + "id": "grok-4-5", + "name": "Grok 4.5", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 500000, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high" + ], + "requiresEffort": true, + "effortRouting": { + "low": "grok-4-5-low", + "medium": "grok-4-5-medium", + "high": "grok-4-5-high" + } + }, + "supportsComputerUse": false, + "requestModelId": "grok-4-5-low" + }, + "grok-4-6-high": { + "id": "grok-4-6-high", + "name": "Grok 4.6 High", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 500000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "grok-4-6-low": { + "id": "grok-4-6-low", + "name": "Grok 4.6 Low", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 500000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "grok-4-6-medium": { + "id": "grok-4-6-medium", + "name": "Grok 4.6 Medium", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 500000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "grok-4-6-xhigh": { + "id": "grok-4-6-xhigh", + "name": "Grok 4.6 XHigh", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 500000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "inkling": { + "id": "inkling", + "name": "Inkling", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ], + "effortRouting": { + "off": "inkling-none", + "low": "inkling-low", + "medium": "inkling-medium", + "high": "inkling-high", + "xhigh": "inkling-xhigh", + "max": "inkling-max" + } + }, + "supportsComputerUse": false, + "requestModelId": "inkling-none" + }, + "kimi-k2-6": { + "id": "kimi-k2-6", + "name": "Kimi K2.6", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 262144, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "kimi-k2-7": { + "id": "kimi-k2-7", + "name": "Kimi K2.7", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 262144, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "kimi-k3": { + "id": "kimi-k3", + "name": "Kimi K3", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1048576, + "maxTokens": 64000, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ], + "requiresEffort": true, + "effortRouting": { + "low": "kimi-k3-low", + "high": "kimi-k3-high", + "max": "kimi-k3-max" + }, + "defaultLevel": "max" + }, + "supportsComputerUse": false, + "requestModelId": "kimi-k3-low" + }, + "MODEL_CHAT_GPT_4_1_2025_04_14": { + "id": "MODEL_CHAT_GPT_4_1_2025_04_14", + "name": "GPT-4.1", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": false, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1047576, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "MODEL_CLAUDE_4_5_OPUS": { + "id": "MODEL_CLAUDE_4_5_OPUS", + "name": "Claude Opus 4.5", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": false, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 200000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "MODEL_CLAUDE_4_5_OPUS_THINKING": { + "id": "MODEL_CLAUDE_4_5_OPUS_THINKING", + "name": "Claude Opus 4.5 Thinking", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 200000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "MODEL_PRIVATE_11": { + "id": "MODEL_PRIVATE_11", + "name": "Claude Haiku 4.5", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": false, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 200000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "MODEL_PRIVATE_12": { + "id": "MODEL_PRIVATE_12", + "name": "GPT-5.1 No Thinking", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": false, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 272000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "MODEL_PRIVATE_13": { + "id": "MODEL_PRIVATE_13", + "name": "GPT-5.1 Low Thinking", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 272000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "MODEL_PRIVATE_14": { + "id": "MODEL_PRIVATE_14", + "name": "GPT-5.1 Medium Thinking", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 272000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "MODEL_PRIVATE_15": { + "id": "MODEL_PRIVATE_15", + "name": "GPT-5.1 High Thinking", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": true, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 272000, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "MODEL_PRIVATE_2": { + "id": "MODEL_PRIVATE_2", + "name": "Claude Sonnet 4.5", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", + "reasoning": false, + "input": [ + "text", + "image" + ], + "supportsTools": true, + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 200000, + "maxTokens": 64000, + "supportsComputerUse": false }, - "grok-code-fast-1": { - "id": "grok-code-fast-1", - "name": "Grok Code Fast 1", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", + "MODEL_PRIVATE_3": { + "id": "MODEL_PRIVATE_3", + "name": "Claude Sonnet 4.5 Thinking", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", "reasoning": true, "input": [ - "text" + "text", + "image" ], + "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 256000, - "maxTokens": 10000, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "contextWindow": 200000, + "maxTokens": 64000, + "supportsComputerUse": false }, - "kimi-k2.5": { - "id": "kimi-k2.5", - "name": "Kimi K2.5", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", + "nemotron-3-ultra-high": { + "id": "nemotron-3-ultra-high", + "name": "Nemotron 3 Ultra High", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", "reasoning": true, "input": [ - "text", - "image" + "text" ], + "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 262144, - "maxTokens": 65536, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "contextWindow": 1000000, + "maxTokens": 64000, + "supportsComputerUse": false }, - "kimi-k2.7-code": { - "id": "kimi-k2.7-code", - "name": "Kimi K2.7 Code", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", + "nemotron-3-ultra-medium": { + "id": "nemotron-3-ultra-medium", + "name": "Nemotron 3 Ultra Medium", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", "reasoning": true, "input": [ - "text", - "image" + "text" ], + "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 200000, + "contextWindow": 1000000, "maxTokens": 64000, - "cursorMaxMode": false, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "supportsComputerUse": false }, - "kimi-k3-high": { - "id": "kimi-k3-high", - "name": "Kimi K3 High", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", + "nemotron-3-ultra-none": { + "id": "nemotron-3-ultra-none", + "name": "Nemotron 3 Ultra None", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", "reasoning": true, "input": [ "text" ], + "supportsTools": true, "cost": { "input": 0, "output": 0, @@ -21640,173 +23928,100 @@ }, "contextWindow": 1000000, "maxTokens": 64000, - "cursorMaxMode": false, - "supportsComputerUse": false, - "supportsComputerUseConfig": false, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ], - "defaultLevel": "max", - "requiresEffort": true - } + "supportsComputerUse": false }, - "kimi-k3-low": { - "id": "kimi-k3-low", - "name": "Kimi K3 Low", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", + "swe-1-6": { + "id": "swe-1-6", + "name": "SWE-1.6", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", "reasoning": true, "input": [ - "text" + "text", + "image" ], + "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1000000, + "contextWindow": 200000, "maxTokens": 64000, - "cursorMaxMode": false, - "supportsComputerUse": false, - "supportsComputerUseConfig": false, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ], - "defaultLevel": "max", - "requiresEffort": true - } + "supportsComputerUse": false }, - "kimi-k3-max": { - "id": "kimi-k3-max", - "name": "Kimi K3", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", + "swe-1-6-fast": { + "id": "swe-1-6-fast", + "name": "SWE-1.6 Fast", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", "reasoning": true, "input": [ - "text" + "text", + "image" ], + "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1000000, + "contextWindow": 200000, "maxTokens": 64000, - "cursorMaxMode": false, - "supportsComputerUse": false, - "supportsComputerUseConfig": false, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ], - "defaultLevel": "max", - "requiresEffort": true - } - } - }, - "deepseek": { - "deepseek-v4-flash": { - "id": "deepseek-v4-flash", - "name": "DeepSeek V4 Flash", - "api": "openai-completions", - "provider": "deepseek", - "baseUrl": "https://api.deepseek.com", + "supportsComputerUse": false + }, + "swe-1-7": { + "id": "swe-1-7", + "name": "SWE-1.7 Max", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", "reasoning": true, "input": [ - "text" + "text", + "image" ], + "supportsTools": true, "cost": { - "input": 0.14, - "output": 0.28, - "cacheRead": 0.0028, + "input": 0, + "output": 0, + "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1000000, - "maxTokens": 384000, - "compat": { - "supportsDeveloperRole": false, - "supportsReasoningEffort": true, - "maxTokensField": "max_tokens", - "supportsToolChoice": false, - "extraBody": { - "thinking": { - "type": "enabled" - } - }, - "reasoningContentField": "reasoning_content", - "requiresReasoningContentForToolCalls": true, - "requiresAssistantContentForToolCalls": true - }, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ] - } + "contextWindow": 262000, + "maxTokens": 64000, + "supportsComputerUse": false, + "requestModelId": "swe-1-7-medium" }, - "deepseek-v4-pro": { - "id": "deepseek-v4-pro", - "name": "DeepSeek V4 Pro", - "api": "openai-completions", - "provider": "deepseek", - "baseUrl": "https://api.deepseek.com", + "swe-1-7-lightning": { + "id": "swe-1-7-lightning", + "name": "SWE-1.7 Lightning Max", + "api": "devin-agent", + "provider": "devin", + "baseUrl": "https://server.codeium.com", "reasoning": true, "input": [ - "text" + "text", + "image" ], + "supportsTools": true, "cost": { - "input": 0.435, - "output": 0.87, - "cacheRead": 0.003625, + "input": 0, + "output": 0, + "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1000000, - "maxTokens": 384000, - "compat": { - "supportsDeveloperRole": false, - "supportsReasoningEffort": true, - "maxTokensField": "max_tokens", - "supportsToolChoice": false, - "extraBody": { - "thinking": { - "type": "enabled" - } - }, - "reasoningContentField": "reasoning_content", - "requiresReasoningContentForToolCalls": true, - "requiresAssistantContentForToolCalls": true - }, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ] - } - } - }, - "devin": { - "swe-1-6-slow": { - "id": "swe-1-6-slow", - "name": "SWE-1.6 Slow", + "contextWindow": 202752, + "maxTokens": 64000, + "supportsComputerUse": false + }, + "swe-1-7-lightning-medium": { + "id": "swe-1-7-lightning-medium", + "name": "SWE-1.7 Lightning Medium", "api": "devin-agent", "provider": "devin", "baseUrl": "https://server.codeium.com", @@ -21822,7 +24037,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 200000, + "contextWindow": 202752, "maxTokens": 64000, "supportsComputerUse": false } @@ -28012,6 +30227,25 @@ "contextWindow": 64000, "maxTokens": 8192 }, + "deepseek-ai/DeepSeek-V3-0324": { + "id": "deepseek-ai/DeepSeek-V3-0324", + "name": "DeepSeek V3 0324", + "api": "openai-completions", + "provider": "huggingface", + "baseUrl": "https://router.huggingface.co/v1", + "reasoning": false, + "input": [ + "text" + ], + "cost": { + "input": 0.27, + "output": 1.12, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 163840, + "maxTokens": 163840 + }, "deepseek-ai/DeepSeek-V3.1": { "id": "deepseek-ai/DeepSeek-V3.1", "name": "DeepSeek-V3.1", @@ -40189,7 +42423,7 @@ "input": 2, "output": 6, "cacheRead": 0.25, - "cacheWrite": 0 + "cacheWrite": 2.5 }, "contextWindow": 1000000, "maxTokens": 262144, @@ -78601,9 +80835,9 @@ "text" ], "cost": { - "input": 0.072, - "output": 0.144, - "cacheRead": 0.016, + "input": 0.079996, + "output": 0.252, + "cacheRead": 0.0252, "cacheWrite": 0 }, "contextWindow": 1048576, @@ -78693,13 +80927,13 @@ "image" ], "cost": { - "input": 2.4, - "output": 12, - "cacheRead": 0.24, + "input": 2.8, + "output": 14, + "cacheRead": 0.29, "cacheWrite": 0 }, "contextWindow": 1048576, - "maxTokens": 974842, + "maxTokens": 1048576, "thinking": { "mode": "effort", "efforts": [ @@ -91483,9 +93717,69 @@ } }, "synthetic": { + "hf:MiniMaxAI/MiniMax-M3": { + "id": "hf:MiniMaxAI/MiniMax-M3", + "name": "MiniMax-M3", + "api": "openai-completions", + "provider": "synthetic", + "baseUrl": "https://api.synthetic.new/openai/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0.6, + "output": 1.2, + "cacheRead": 0.6, + "cacheWrite": 0 + }, + "contextWindow": 524288, + "maxTokens": 65536, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh" + ] + } + }, + "hf:moonshotai/Kimi-K2.7-Code": { + "id": "hf:moonshotai/Kimi-K2.7-Code", + "name": "Kimi K2.7 Code", + "api": "openai-completions", + "provider": "synthetic", + "baseUrl": "https://api.synthetic.new/openai/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0.95, + "output": 4, + "cacheRead": 0.95, + "cacheWrite": 0 + }, + "contextWindow": 262144, + "maxTokens": 65536, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh" + ] + } + }, "hf:moonshotai/Kimi-K3": { "id": "hf:moonshotai/Kimi-K3", - "name": "moonshotai/Kimi-K3", + "name": "Kimi K3", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -91514,13 +93808,11 @@ "max": "max" }, "requiresEffort": true - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + } }, "hf:nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4": { "id": "hf:nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4", - "name": "nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4", + "name": "Nemotron 3 Super 120B A12B", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -91531,7 +93823,7 @@ "cost": { "input": 0.3, "output": 1, - "cacheRead": 0.06, + "cacheRead": 0.3, "cacheWrite": 0 }, "contextWindow": 262144, @@ -91545,13 +93837,11 @@ "high", "xhigh" ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + } }, "hf:openai/gpt-oss-120b": { "id": "hf:openai/gpt-oss-120b", - "name": "openai/gpt-oss-120b", + "name": "GPT OSS 120B", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -91562,11 +93852,11 @@ "cost": { "input": 0.1, "output": 0.1, - "cacheRead": 0.02, + "cacheRead": 0.1, "cacheWrite": 0 }, "contextWindow": 131072, - "maxTokens": 65536, + "maxTokens": 32768, "thinking": { "mode": "effort", "efforts": [ @@ -91574,13 +93864,11 @@ "medium", "high" ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + } }, "hf:Qwen/Qwen3.6-27B": { "id": "hf:Qwen/Qwen3.6-27B", - "name": "Qwen/Qwen3.6-27B", + "name": "Qwen3.6 27B", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -91591,8 +93879,8 @@ ], "cost": { "input": 0.45, - "output": 2.2, - "cacheRead": 0.09, + "output": 3.6, + "cacheRead": 0.45, "cacheWrite": 0 }, "contextWindow": 262144, @@ -91605,13 +93893,11 @@ "medium", "high" ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + } }, "hf:zai-org/GLM-4.7-Flash": { "id": "hf:zai-org/GLM-4.7-Flash", - "name": "zai-org/GLM-4.7-Flash", + "name": "GLM-4.7-Flash", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -91622,7 +93908,7 @@ "cost": { "input": 0.1, "output": 0.5, - "cacheRead": 0.02, + "cacheRead": 0.1, "cacheWrite": 0 }, "contextWindow": 196608, @@ -91636,13 +93922,11 @@ "high", "xhigh" ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + } }, "hf:zai-org/GLM-5.2": { "id": "hf:zai-org/GLM-5.2", - "name": "zai-org/GLM-5.2", + "name": "GLM-5.2", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -91651,9 +93935,9 @@ "text" ], "cost": { - "input": 1, - "output": 3, - "cacheRead": 0.16, + "input": 1.4, + "output": 4.4, + "cacheRead": 1.4, "cacheWrite": 0 }, "contextWindow": 524288, @@ -91667,9 +93951,7 @@ "high", "max" ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + } }, "syn:large:text": { "id": "syn:large:text", @@ -92760,6 +95042,40 @@ "escapeBuiltinToolNames": true } }, + "umans-deepseek-v4-pro-0813-lab": { + "id": "umans-deepseek-v4-pro-0813-lab", + "name": "Umans DeepSeek V4 Pro 0813 (lab)", + "api": "anthropic-messages", + "provider": "umans", + "baseUrl": "https://api.code.umans.ai", + "reasoning": true, + "thinking": { + "mode": "budget", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh" + ] + }, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 524288, + "maxTokens": 393215, + "supportsComputerUse": false, + "supportsComputerUseConfig": false, + "compat": { + "escapeBuiltinToolNames": true + } + }, "umans-flash": { "id": "umans-flash", "name": "Umans Flash", @@ -94246,6 +96562,30 @@ ] } }, + "gemini-3-7-flash": { + "id": "gemini-3-7-flash", + "name": "gemini-3-7-flash", + "api": "openai-completions", + "provider": "venice", + "baseUrl": "https://api.venice.ai/api/v1", + "reasoning": false, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 1000000, + "maxTokens": 65536, + "supportsComputerUse": false, + "supportsComputerUseConfig": false, + "compat": { + "supportsUsageInStreaming": false + } + }, "gemini-3-flash-preview": { "id": "gemini-3-flash-preview", "name": "Gemini 3 Flash Preview", @@ -95999,26 +98339,30 @@ }, "qwen-3-8-2-4t-a95b": { "id": "qwen-3-8-2-4t-a95b", - "name": "qwen-3-8-2-4t-a95b", + "name": "Qwen 3.8 2.4T", "api": "openai-completions", "provider": "venice", "baseUrl": "https://api.venice.ai/api/v1", - "reasoning": false, + "reasoning": true, "input": [ "text" ], "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 2.5, + "output": 7.5, + "cacheRead": 0.3125, "cacheWrite": 0 }, "contextWindow": 262144, - "maxTokens": null, - "supportsComputerUse": false, - "supportsComputerUseConfig": false, - "compat": { - "supportsUsageInStreaming": false + "maxTokens": 65536, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ] } }, "qwen-3-8-max": { @@ -97470,7 +99814,8 @@ "xhigh" ] }, - "supportsComputerUse": false + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "alibaba/qwen3.8-max": { "id": "alibaba/qwen3.8-max", @@ -98672,7 +101017,8 @@ "xhigh" ] }, - "supportsComputerUse": false + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "google/gemini-2.0-flash": { "id": "google/gemini-2.0-flash", @@ -99136,7 +101482,8 @@ ], "requiresEffort": true }, - "supportsComputerUse": false + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "google/gemma-4-26b-a4b-it": { "id": "google/gemma-4-26b-a4b-it", @@ -99186,7 +101533,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 262144, + "contextWindow": 256000, "maxTokens": 131072, "thinking": { "mode": "budget", @@ -99712,7 +102059,8 @@ "xhigh" ] }, - "supportsComputerUse": false + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "meta/muse-spark-1.1": { "id": "meta/muse-spark-1.1", @@ -101371,8 +103719,7 @@ "high" ] }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "supportsComputerUse": false }, "openai/gpt-5.1-thinking": { "id": "openai/gpt-5.1-thinking", @@ -101535,8 +103882,7 @@ }, "contextWindow": 128000, "maxTokens": 16384, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "supportsComputerUse": false }, "openai/gpt-5.3-codex": { "id": "openai/gpt-5.3-codex", @@ -102319,7 +104665,8 @@ "xhigh" ] }, - "supportsComputerUse": false + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "stepfun/step-3.5-flash": { "id": "stepfun/step-3.5-flash", @@ -103022,7 +105369,8 @@ "xhigh" ] }, - "supportsComputerUse": false + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "xai/grok-build-0.1": { "id": "xai/grok-build-0.1", From 825ae3ab8d94511f01658dd8f4d8610eb9b4cc21 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 14 Aug 2026 01:40:20 +0200 Subject: [PATCH 020/795] style: satisfy biome import order and formatting on merged tree --- packages/ai/src/providers/openai-completions.ts | 2 +- packages/catalog/src/provider-models/openai-compat.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/ai/src/providers/openai-completions.ts b/packages/ai/src/providers/openai-completions.ts index 4e7a66a7d27f..72da39f5a6b1 100644 --- a/packages/ai/src/providers/openai-completions.ts +++ b/packages/ai/src/providers/openai-completions.ts @@ -2,8 +2,8 @@ import type { Effort } from "@oh-my-pi/pi-catalog/effort"; import { isKimiModelId } from "@oh-my-pi/pi-catalog/identity"; import { resolveWireModelId } from "@oh-my-pi/pi-catalog/model-thinking"; import { calculateCost } from "@oh-my-pi/pi-catalog/models"; -import { clinePassClientHeaders } from "@oh-my-pi/pi-catalog/wire/cline-pass"; import type { ResolvedOpenAICompat } from "@oh-my-pi/pi-catalog/types"; +import { clinePassClientHeaders } from "@oh-my-pi/pi-catalog/wire/cline-pass"; import { $env, parseStreamingJson, parseStreamingJsonThrottled } from "@oh-my-pi/pi-utils"; import { renderDemotedThinking } from "../dialect/demotion"; import * as AIError from "../error"; diff --git a/packages/catalog/src/provider-models/openai-compat.ts b/packages/catalog/src/provider-models/openai-compat.ts index 1211bfde77db..345f1684577d 100644 --- a/packages/catalog/src/provider-models/openai-compat.ts +++ b/packages/catalog/src/provider-models/openai-compat.ts @@ -2276,7 +2276,9 @@ async function fetchClinePassLiveCatalog(fetchImpl: FetchImpl): Promise Date: Fri, 14 Aug 2026 01:46:40 +0200 Subject: [PATCH 021/795] ci: retrigger after flaky sdk-tool-activation timeout From a9b73730b2470dfc861ef121f16a169e81ef701e Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 14 Aug 2026 17:01:19 +0200 Subject: [PATCH 022/795] chore(catalog): drop unrelated regen drift from models.json The earlier regen ran with local provider keys in env, which pulled an authenticated Devin roster (including internal enum names) and unrelated upstream drift into the bundle. Keep the PR's models.json delta scoped to the cline-pass section; maintainer regens absorb upstream drift. --- packages/catalog/src/models.json | 3146 +++++------------------------- 1 file changed, 462 insertions(+), 2684 deletions(-) diff --git a/packages/catalog/src/models.json b/packages/catalog/src/models.json index 45dd0104e56f..606029b5c483 100644 --- a/packages/catalog/src/models.json +++ b/packages/catalog/src/models.json @@ -16,7 +16,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1000000, + "contextWindow": 1048576, "maxTokens": 393216, "thinking": { "mode": "effort", @@ -25,7 +25,8 @@ "high", "max" ] - } + }, + "supportsComputerUse": false }, "deepseek-ai/deepseek-v4-pro": { "id": "deepseek-ai/deepseek-v4-pro", @@ -43,7 +44,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1000000, + "contextWindow": 1048576, "maxTokens": 393216, "thinking": { "mode": "effort", @@ -52,7 +53,8 @@ "high", "max" ] - } + }, + "supportsComputerUse": false }, "google/gemma-4-31b-it": { "id": "google/gemma-4-31b-it", @@ -82,37 +84,8 @@ "high", "xhigh" ] - } - }, - "moonshotai/kimi-k2.6": { - "id": "moonshotai/kimi-k2.6", - "name": "Kimi K2.6", - "api": "openai-completions", - "provider": "aiand", - "baseUrl": "https://api.aiand.com/v1", - "reasoning": true, - "input": [ - "text", - "image" - ], - "cost": { - "input": 0.85, - "output": 3.5, - "cacheRead": 0, - "cacheWrite": 0 }, - "contextWindow": 262144, - "maxTokens": 262144, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high", - "xhigh" - ] - } + "supportsComputerUse": false }, "moonshotai/kimi-k2.7-code": { "id": "moonshotai/kimi-k2.7-code", @@ -142,7 +115,8 @@ "high", "xhigh" ] - } + }, + "supportsComputerUse": false }, "moonshotai/kimi-k3": { "id": "moonshotai/kimi-k3", @@ -233,7 +207,8 @@ "medium", "high" ] - } + }, + "supportsComputerUse": false }, "qwen/qwen3.6-27b": { "id": "qwen/qwen3.6-27b", @@ -247,8 +222,8 @@ "image" ], "cost": { - "input": 0, - "output": 0, + "input": 0.32, + "output": 3.2, "cacheRead": 0, "cacheWrite": 0 }, @@ -262,36 +237,8 @@ "medium", "high" ] - } - }, - "zai-org/glm-5.1": { - "id": "zai-org/glm-5.1", - "name": "GLM 5.1", - "api": "openai-completions", - "provider": "aiand", - "baseUrl": "https://api.aiand.com/v1", - "reasoning": true, - "input": [ - "text" - ], - "cost": { - "input": 1.4, - "output": 4.4, - "cacheRead": 0, - "cacheWrite": 0 }, - "contextWindow": 202752, - "maxTokens": 131072, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high", - "xhigh" - ] - } + "supportsComputerUse": false }, "zai-org/glm-5.2": { "id": "zai-org/glm-5.2", @@ -309,7 +256,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1000000, + "contextWindow": 1048576, "maxTokens": 131072, "thinking": { "mode": "effort", @@ -320,7 +267,8 @@ "high", "max" ] - } + }, + "supportsComputerUse": false } }, "aimlapi": { @@ -14066,178 +14014,6 @@ } } }, - "cerebras": { - "gemma-4-31b": { - "id": "gemma-4-31b", - "name": "Gemma 4 31B IT", - "api": "openai-completions", - "provider": "cerebras", - "baseUrl": "https://api.cerebras.ai/v1", - "reasoning": true, - "input": [ - "text", - "image" - ], - "cost": { - "input": 0.99, - "output": 1.49, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 131072, - "maxTokens": 40960, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high", - "xhigh" - ] - } - }, - "gpt-oss-120b": { - "id": "gpt-oss-120b", - "name": "GPT OSS 120B", - "api": "openai-completions", - "provider": "cerebras", - "baseUrl": "https://api.cerebras.ai/v1", - "reasoning": true, - "input": [ - "text" - ], - "cost": { - "input": 0.35, - "output": 0.75, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 131072, - "maxTokens": 40960, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high" - ] - } - }, - "llama3.1-8b": { - "id": "llama3.1-8b", - "name": "Llama 3.1 8B", - "api": "openai-completions", - "provider": "cerebras", - "baseUrl": "https://api.cerebras.ai/v1", - "reasoning": false, - "input": [ - "text" - ], - "cost": { - "input": 0.1, - "output": 0.1, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 32000, - "maxTokens": 8000, - "supportsComputerUse": false, - "supportsComputerUseConfig": false - }, - "qwen-3-235b-a22b-instruct-2507": { - "id": "qwen-3-235b-a22b-instruct-2507", - "name": "Qwen 3 235B Instruct", - "api": "openai-completions", - "provider": "cerebras", - "baseUrl": "https://api.cerebras.ai/v1", - "reasoning": false, - "input": [ - "text" - ], - "cost": { - "input": 0.6, - "output": 1.2, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 131000, - "maxTokens": 32000, - "supportsComputerUse": false, - "supportsComputerUseConfig": false - }, - "qwen-3-coder-480b": { - "id": "qwen-3-coder-480b", - "name": "qwen-3-coder-480b", - "api": "openai-completions", - "provider": "cerebras", - "baseUrl": "https://api.cerebras.ai/v1", - "reasoning": false, - "input": [ - "text" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 131072, - "maxTokens": 32768, - "supportsComputerUse": false, - "supportsComputerUseConfig": false - }, - "zai-glm-4.6": { - "id": "zai-glm-4.6", - "name": "zai-glm-4.6", - "api": "openai-completions", - "provider": "cerebras", - "baseUrl": "https://api.cerebras.ai/v1", - "reasoning": false, - "input": [ - "text" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 131072, - "maxTokens": 32768, - "supportsComputerUse": false, - "supportsComputerUseConfig": false - }, - "zai-glm-4.7": { - "id": "zai-glm-4.7", - "name": "Z.AI GLM-4.7", - "api": "openai-completions", - "provider": "cerebras", - "baseUrl": "https://api.cerebras.ai/v1", - "reasoning": true, - "input": [ - "text" - ], - "cost": { - "input": 2.25, - "output": 2.75, - "cacheRead": 2.25, - "cacheWrite": 0 - }, - "contextWindow": 131072, - "maxTokens": 40960, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high", - "xhigh" - ] - } - } - }, "cline-pass": { "deepseek-v4-flash": { "id": "deepseek-v4-flash", @@ -14855,6 +14631,178 @@ "supportsComputerUseConfig": false } }, + "cerebras": { + "gemma-4-31b": { + "id": "gemma-4-31b", + "name": "Gemma 4 31B IT", + "api": "openai-completions", + "provider": "cerebras", + "baseUrl": "https://api.cerebras.ai/v1", + "reasoning": true, + "input": [ + "text", + "image" + ], + "cost": { + "input": 0.99, + "output": 1.49, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 131072, + "maxTokens": 40960, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh" + ] + } + }, + "gpt-oss-120b": { + "id": "gpt-oss-120b", + "name": "GPT OSS 120B", + "api": "openai-completions", + "provider": "cerebras", + "baseUrl": "https://api.cerebras.ai/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 0.35, + "output": 0.75, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 131072, + "maxTokens": 40960, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "medium", + "high" + ] + } + }, + "llama3.1-8b": { + "id": "llama3.1-8b", + "name": "Llama 3.1 8B", + "api": "openai-completions", + "provider": "cerebras", + "baseUrl": "https://api.cerebras.ai/v1", + "reasoning": false, + "input": [ + "text" + ], + "cost": { + "input": 0.1, + "output": 0.1, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 32000, + "maxTokens": 8000, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "qwen-3-235b-a22b-instruct-2507": { + "id": "qwen-3-235b-a22b-instruct-2507", + "name": "Qwen 3 235B Instruct", + "api": "openai-completions", + "provider": "cerebras", + "baseUrl": "https://api.cerebras.ai/v1", + "reasoning": false, + "input": [ + "text" + ], + "cost": { + "input": 0.6, + "output": 1.2, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 131000, + "maxTokens": 32000, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "qwen-3-coder-480b": { + "id": "qwen-3-coder-480b", + "name": "qwen-3-coder-480b", + "api": "openai-completions", + "provider": "cerebras", + "baseUrl": "https://api.cerebras.ai/v1", + "reasoning": false, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 131072, + "maxTokens": 32768, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "zai-glm-4.6": { + "id": "zai-glm-4.6", + "name": "zai-glm-4.6", + "api": "openai-completions", + "provider": "cerebras", + "baseUrl": "https://api.cerebras.ai/v1", + "reasoning": false, + "input": [ + "text" + ], + "cost": { + "input": 0, + "output": 0, + "cacheRead": 0, + "cacheWrite": 0 + }, + "contextWindow": 131072, + "maxTokens": 32768, + "supportsComputerUse": false, + "supportsComputerUseConfig": false + }, + "zai-glm-4.7": { + "id": "zai-glm-4.7", + "name": "Z.AI GLM-4.7", + "api": "openai-completions", + "provider": "cerebras", + "baseUrl": "https://api.cerebras.ai/v1", + "reasoning": true, + "input": [ + "text" + ], + "cost": { + "input": 2.25, + "output": 2.75, + "cacheRead": 2.25, + "cacheWrite": 0 + }, + "contextWindow": 131072, + "maxTokens": 40960, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high", + "xhigh" + ] + } + } + }, "cloudflare-ai-gateway": { "anthropic/claude-3-5-haiku": { "id": "anthropic/claude-3-5-haiku", @@ -21683,2158 +21631,18 @@ "cursorMaxMode": false, "supportsComputerUse": false, "supportsComputerUseConfig": false - }, - "gpt-5.6-terra-xhigh-fast": { - "id": "gpt-5.6-terra-xhigh-fast", - "name": "GPT-5.6 Terra Extra High Fast", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", - "reasoning": false, - "input": [ - "text", - "image" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 200000, - "maxTokens": 64000, - "cursorMaxMode": false, - "supportsComputerUse": false, - "supportsComputerUseConfig": false - }, - "grok-code-fast-1": { - "id": "grok-code-fast-1", - "name": "Grok Code Fast 1", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", - "reasoning": true, - "input": [ - "text" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 256000, - "maxTokens": 10000, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false - }, - "kimi-k2.5": { - "id": "kimi-k2.5", - "name": "Kimi K2.5", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", - "reasoning": true, - "input": [ - "text", - "image" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 262144, - "maxTokens": 65536, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false - }, - "kimi-k2.7-code": { - "id": "kimi-k2.7-code", - "name": "Kimi K2.7 Code", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", - "reasoning": true, - "input": [ - "text", - "image" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 200000, - "maxTokens": 64000, - "cursorMaxMode": false, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ] - }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false - }, - "kimi-k3-high": { - "id": "kimi-k3-high", - "name": "Kimi K3 High", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", - "reasoning": true, - "input": [ - "text" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "cursorMaxMode": false, - "supportsComputerUse": false, - "supportsComputerUseConfig": false, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ], - "defaultLevel": "max", - "requiresEffort": true - } - }, - "kimi-k3-low": { - "id": "kimi-k3-low", - "name": "Kimi K3 Low", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", - "reasoning": true, - "input": [ - "text" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "cursorMaxMode": false, - "supportsComputerUse": false, - "supportsComputerUseConfig": false, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ], - "defaultLevel": "max", - "requiresEffort": true - } - }, - "kimi-k3-max": { - "id": "kimi-k3-max", - "name": "Kimi K3", - "api": "cursor-agent", - "provider": "cursor", - "baseUrl": "https://api2.cursor.sh", - "reasoning": true, - "input": [ - "text" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "cursorMaxMode": false, - "supportsComputerUse": false, - "supportsComputerUseConfig": false, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ], - "defaultLevel": "max", - "requiresEffort": true - } - } - }, - "deepseek": { - "deepseek-v4-flash": { - "id": "deepseek-v4-flash", - "name": "DeepSeek V4 Flash", - "api": "openai-completions", - "provider": "deepseek", - "baseUrl": "https://api.deepseek.com", - "reasoning": true, - "input": [ - "text" - ], - "cost": { - "input": 0.14, - "output": 0.28, - "cacheRead": 0.0028, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 384000, - "compat": { - "supportsDeveloperRole": false, - "supportsReasoningEffort": true, - "maxTokensField": "max_tokens", - "supportsToolChoice": false, - "extraBody": { - "thinking": { - "type": "enabled" - } - }, - "reasoningContentField": "reasoning_content", - "requiresReasoningContentForToolCalls": true, - "requiresAssistantContentForToolCalls": true - }, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ] - } - }, - "deepseek-v4-pro": { - "id": "deepseek-v4-pro", - "name": "DeepSeek V4 Pro", - "api": "openai-completions", - "provider": "deepseek", - "baseUrl": "https://api.deepseek.com", - "reasoning": true, - "input": [ - "text" - ], - "cost": { - "input": 0.435, - "output": 0.87, - "cacheRead": 0.003625, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 384000, - "compat": { - "supportsDeveloperRole": false, - "supportsReasoningEffort": true, - "maxTokensField": "max_tokens", - "supportsToolChoice": false, - "extraBody": { - "thinking": { - "type": "enabled" - } - }, - "reasoningContentField": "reasoning_content", - "requiresReasoningContentForToolCalls": true, - "requiresAssistantContentForToolCalls": true - }, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ] - } - } - }, - "devin": { - "claude-fable-5": { - "id": "claude-fable-5", - "name": "Claude Fable 5", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "requiresEffort": true, - "effortRouting": { - "low": "claude-5-fable-low", - "medium": "claude-5-fable-medium", - "high": "claude-5-fable-high", - "xhigh": "claude-5-fable-xhigh", - "max": "claude-5-fable-max" - } - }, - "supportsComputerUse": false, - "requestModelId": "claude-5-fable-low" - }, - "claude-opus-4-6": { - "id": "claude-opus-4-6", - "name": "Claude Opus 4.6", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 200000, - "maxTokens": 64000, - "thinking": { - "mode": "budget", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ], - "effortRouting": { - "off": "claude-opus-4-6", - "minimal": "claude-opus-4-6-thinking", - "low": "claude-opus-4-6-thinking", - "medium": "claude-opus-4-6-thinking", - "high": "claude-opus-4-6-thinking" - } - }, - "supportsComputerUse": false - }, - "claude-opus-4-6-1m": { - "id": "claude-opus-4-6-1m", - "name": "Claude Opus 4.6 1M", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "budget", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ], - "effortRouting": { - "off": "claude-opus-4-6-1m", - "minimal": "claude-opus-4-6-thinking-1m", - "low": "claude-opus-4-6-thinking-1m", - "medium": "claude-opus-4-6-thinking-1m", - "high": "claude-opus-4-6-thinking-1m" - } - }, - "supportsComputerUse": false - }, - "claude-opus-4-7": { - "id": "claude-opus-4-7", - "name": "Claude Opus 4.7", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "requiresEffort": true, - "effortRouting": { - "low": "claude-opus-4-7-low", - "medium": "claude-opus-4-7-medium", - "high": "claude-opus-4-7-high", - "xhigh": "claude-opus-4-7-xhigh", - "max": "claude-opus-4-7-max" - } - }, - "supportsComputerUse": false, - "requestModelId": "claude-opus-4-7-low" - }, - "claude-opus-4-8": { - "id": "claude-opus-4-8", - "name": "Claude Opus 4.8", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "requiresEffort": true, - "effortRouting": { - "low": "claude-opus-4-8-low", - "medium": "claude-opus-4-8-medium", - "high": "claude-opus-4-8-high", - "xhigh": "claude-opus-4-8-xhigh", - "max": "claude-opus-4-8-max" - } - }, - "supportsComputerUse": false, - "requestModelId": "claude-opus-4-8-low" - }, - "claude-opus-4-8-fast": { - "id": "claude-opus-4-8-fast", - "name": "Claude Opus 4.8 Fast", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "requiresEffort": true, - "effortRouting": { - "low": "claude-opus-4-8-low-fast", - "medium": "claude-opus-4-8-medium-fast", - "high": "claude-opus-4-8-high-fast", - "xhigh": "claude-opus-4-8-xhigh-fast", - "max": "claude-opus-4-8-max-fast" - } - }, - "supportsComputerUse": false, - "requestModelId": "claude-opus-4-8-low-fast" - }, - "claude-opus-5": { - "id": "claude-opus-5", - "name": "Claude Opus 5", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "requiresEffort": true, - "effortRouting": { - "low": "claude-opus-5-low", - "medium": "claude-opus-5-medium", - "high": "claude-opus-5-high", - "xhigh": "claude-opus-5-xhigh", - "max": "claude-opus-5-max" - } - }, - "supportsComputerUse": false, - "requestModelId": "claude-opus-5-low" - }, - "claude-opus-5-fast": { - "id": "claude-opus-5-fast", - "name": "Claude Opus 5 Fast", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "requiresEffort": true, - "effortRouting": { - "low": "claude-opus-5-low-fast", - "medium": "claude-opus-5-medium-fast", - "high": "claude-opus-5-high-fast", - "xhigh": "claude-opus-5-xhigh-fast", - "max": "claude-opus-5-max-fast" - } - }, - "supportsComputerUse": false, - "requestModelId": "claude-opus-5-low-fast" - }, - "claude-sonnet-4-6": { - "id": "claude-sonnet-4-6", - "name": "Claude Sonnet 4.6", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 200000, - "maxTokens": 64000, - "thinking": { - "mode": "budget", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ], - "effortRouting": { - "off": "claude-sonnet-4-6", - "minimal": "claude-sonnet-4-6-thinking", - "low": "claude-sonnet-4-6-thinking", - "medium": "claude-sonnet-4-6-thinking", - "high": "claude-sonnet-4-6-thinking" - } - }, - "supportsComputerUse": false - }, - "claude-sonnet-4-6-1m": { - "id": "claude-sonnet-4-6-1m", - "name": "Claude Sonnet 4.6 1M", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "budget", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ], - "effortRouting": { - "off": "claude-sonnet-4-6-1m", - "minimal": "claude-sonnet-4-6-thinking-1m", - "low": "claude-sonnet-4-6-thinking-1m", - "medium": "claude-sonnet-4-6-thinking-1m", - "high": "claude-sonnet-4-6-thinking-1m" - } - }, - "supportsComputerUse": false - }, - "claude-sonnet-5": { - "id": "claude-sonnet-5", - "name": "Claude Sonnet 5", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "requiresEffort": true, - "effortRouting": { - "low": "claude-sonnet-5-low", - "medium": "claude-sonnet-5-medium", - "high": "claude-sonnet-5-high", - "xhigh": "claude-sonnet-5-xhigh", - "max": "claude-sonnet-5-max" - } - }, - "supportsComputerUse": false, - "requestModelId": "claude-sonnet-5-low" - }, - "deepseek-v4-flash-high": { - "id": "deepseek-v4-flash-high", - "name": "DeepSeek V4 Flash High", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "deepseek-v4-flash-low": { - "id": "deepseek-v4-flash-low", - "name": "DeepSeek V4 Flash Low", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "deepseek-v4-flash-max": { - "id": "deepseek-v4-flash-max", - "name": "DeepSeek V4 Flash Max", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "deepseek-v4-pro-high": { - "id": "deepseek-v4-pro-high", - "name": "DeepSeek V4 Pro High", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "deepseek-v4-pro-low": { - "id": "deepseek-v4-pro-low", - "name": "DeepSeek V4 Pro Low", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "deepseek-v4-pro-max": { - "id": "deepseek-v4-pro-max", - "name": "DeepSeek V4 Pro Max", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "gemini-3-1-pro": { - "id": "gemini-3-1-pro", - "name": "Gemini 3.1 Pro", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high" - ], - "requiresEffort": true, - "effortRouting": { - "low": "gemini-3-1-pro-low", - "high": "gemini-3-1-pro-high" - } - }, - "supportsComputerUse": false, - "requestModelId": "gemini-3-1-pro-low" - }, - "gemini-3-5-flash": { - "id": "gemini-3-5-flash", - "name": "Gemini 3.5 Flash", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ], - "requiresEffort": true, - "effortRouting": { - "minimal": "gemini-3-5-flash-minimal", - "low": "gemini-3-5-flash-low", - "medium": "gemini-3-5-flash-medium", - "high": "gemini-3-5-flash-high" - } - }, - "supportsComputerUse": false, - "requestModelId": "gemini-3-5-flash-minimal" - }, - "gemini-3-6-flash": { - "id": "gemini-3-6-flash", - "name": "Gemini 3.6 Flash", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ], - "requiresEffort": true, - "effortRouting": { - "minimal": "gemini-3-6-flash-minimal", - "low": "gemini-3-6-flash-low", - "medium": "gemini-3-6-flash-medium", - "high": "gemini-3-6-flash-high" - } - }, - "supportsComputerUse": false, - "requestModelId": "gemini-3-6-flash-minimal" - }, - "gemini-3-7-flash-high": { - "id": "gemini-3-7-flash-high", - "name": "Gemini 3.7 Flash High", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "gemini-3-7-flash-low": { - "id": "gemini-3-7-flash-low", - "name": "Gemini 3.7 Flash Low", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "gemini-3-7-flash-medium": { - "id": "gemini-3-7-flash-medium", - "name": "Gemini 3.7 Flash Medium", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "gemini-3-7-flash-minimal": { - "id": "gemini-3-7-flash-minimal", - "name": "Gemini 3.7 Flash Minimal", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "gemini-3-flash": { - "id": "gemini-3-flash", - "name": "Gemini 3 Flash", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ], - "requiresEffort": true, - "effortRouting": { - "minimal": "MODEL_GOOGLE_GEMINI_3_0_FLASH_MINIMAL", - "low": "MODEL_GOOGLE_GEMINI_3_0_FLASH_LOW", - "medium": "MODEL_GOOGLE_GEMINI_3_0_FLASH_MEDIUM", - "high": "MODEL_GOOGLE_GEMINI_3_0_FLASH_HIGH" - } - }, - "supportsComputerUse": false, - "requestModelId": "MODEL_GOOGLE_GEMINI_3_0_FLASH_MINIMAL" - }, - "glm-5-2": { - "id": "glm-5-2", - "name": "GLM-5.2", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 200000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "high", - "xhigh" - ], - "requiresEffort": true, - "effortRouting": { - "high": "glm-5-2", - "xhigh": "glm-5-2" - } - }, - "supportsComputerUse": false - }, - "glm-5-2-1m": { - "id": "glm-5-2-1m", - "name": "GLM-5.2 High 1M", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "supportsComputerUse": false, - "requestModelId": "glm-5-2-none-1m" - }, - "gpt-5-2": { - "id": "gpt-5-2", - "name": "GPT-5.2", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 384000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh" - ], - "effortRouting": { - "off": "MODEL_GPT_5_2_NONE", - "low": "MODEL_GPT_5_2_LOW", - "medium": "MODEL_GPT_5_2_MEDIUM", - "high": "MODEL_GPT_5_2_HIGH", - "xhigh": "MODEL_GPT_5_2_XHIGH" - } - }, - "supportsComputerUse": false, - "requestModelId": "MODEL_GPT_5_2_NONE" - }, - "gpt-5-3-codex": { - "id": "gpt-5-3-codex", - "name": "GPT-5.3 Codex", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 400000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh" - ], - "requiresEffort": true, - "effortRouting": { - "low": "gpt-5-3-codex-low", - "medium": "gpt-5-3-codex-medium", - "high": "gpt-5-3-codex-high", - "xhigh": "gpt-5-3-codex-xhigh" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-3-codex-low" - }, - "gpt-5-3-codex-fast": { - "id": "gpt-5-3-codex-fast", - "name": "GPT-5.3 Codex Fast", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 400000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh" - ], - "requiresEffort": true, - "effortRouting": { - "low": "gpt-5-3-codex-low-priority", - "medium": "gpt-5-3-codex-medium-priority", - "high": "gpt-5-3-codex-high-priority", - "xhigh": "gpt-5-3-codex-xhigh-priority" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-3-codex-low-priority" - }, - "gpt-5-4": { - "id": "gpt-5-4", - "name": "GPT-5.4", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 272000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh" - ], - "effortRouting": { - "off": "gpt-5-4-none", - "low": "gpt-5-4-low", - "medium": "gpt-5-4-medium", - "high": "gpt-5-4-high", - "xhigh": "gpt-5-4-xhigh" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-4-none" - }, - "gpt-5-4-fast": { - "id": "gpt-5-4-fast", - "name": "GPT-5.4 Fast", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 272000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh" - ], - "effortRouting": { - "off": "gpt-5-4-none-priority", - "low": "gpt-5-4-low-priority", - "medium": "gpt-5-4-medium-priority", - "high": "gpt-5-4-high-priority", - "xhigh": "gpt-5-4-xhigh-priority" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-4-none-priority" - }, - "gpt-5-4-mini": { - "id": "gpt-5-4-mini", - "name": "GPT-5.4 Mini", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 400000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh" - ], - "requiresEffort": true, - "effortRouting": { - "low": "gpt-5-4-mini-low", - "medium": "gpt-5-4-mini-medium", - "high": "gpt-5-4-mini-high", - "xhigh": "gpt-5-4-mini-xhigh" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-4-mini-low" - }, - "gpt-5-5": { - "id": "gpt-5-5", - "name": "GPT-5.5", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 272000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh" - ], - "effortRouting": { - "off": "gpt-5-5-none", - "low": "gpt-5-5-low", - "medium": "gpt-5-5-medium", - "high": "gpt-5-5-high", - "xhigh": "gpt-5-5-xhigh" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-5-none" - }, - "gpt-5-5-fast": { - "id": "gpt-5-5-fast", - "name": "GPT-5.5 Fast", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 272000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh" - ], - "effortRouting": { - "off": "gpt-5-5-none-priority", - "low": "gpt-5-5-low-priority", - "medium": "gpt-5-5-medium-priority", - "high": "gpt-5-5-high-priority", - "xhigh": "gpt-5-5-xhigh-priority" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-5-none-priority" - }, - "gpt-5-6-luna": { - "id": "gpt-5-6-luna", - "name": "GPT-5.6 Luna", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "effortRouting": { - "off": "gpt-5-6-luna-none", - "low": "gpt-5-6-luna-low", - "medium": "gpt-5-6-luna-medium", - "high": "gpt-5-6-luna-high", - "xhigh": "gpt-5-6-luna-xhigh", - "max": "gpt-5-6-luna-max" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-6-luna-none" - }, - "gpt-5-6-luna-fast": { - "id": "gpt-5-6-luna-fast", - "name": "GPT-5.6 Luna Fast", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "effortRouting": { - "off": "gpt-5-6-luna-none-priority", - "low": "gpt-5-6-luna-low-priority", - "medium": "gpt-5-6-luna-medium-priority", - "high": "gpt-5-6-luna-high-priority", - "xhigh": "gpt-5-6-luna-xhigh-priority", - "max": "gpt-5-6-luna-max-priority" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-6-luna-none-priority" - }, - "gpt-5-6-sol": { - "id": "gpt-5-6-sol", - "name": "GPT-5.6 Sol", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "effortRouting": { - "off": "gpt-5-6-sol-none", - "low": "gpt-5-6-sol-low", - "medium": "gpt-5-6-sol-medium", - "high": "gpt-5-6-sol-high", - "xhigh": "gpt-5-6-sol-xhigh", - "max": "gpt-5-6-sol-max" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-6-sol-none" - }, - "gpt-5-6-sol-fast": { - "id": "gpt-5-6-sol-fast", - "name": "GPT-5.6 Sol Fast", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "effortRouting": { - "off": "gpt-5-6-sol-none-priority", - "low": "gpt-5-6-sol-low-priority", - "medium": "gpt-5-6-sol-medium-priority", - "high": "gpt-5-6-sol-high-priority", - "xhigh": "gpt-5-6-sol-xhigh-priority", - "max": "gpt-5-6-sol-max-priority" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-6-sol-none-priority" - }, - "gpt-5-6-terra": { - "id": "gpt-5-6-terra", - "name": "GPT-5.6 Terra", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "effortRouting": { - "off": "gpt-5-6-terra-none", - "low": "gpt-5-6-terra-low", - "medium": "gpt-5-6-terra-medium", - "high": "gpt-5-6-terra-high", - "xhigh": "gpt-5-6-terra-xhigh", - "max": "gpt-5-6-terra-max" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-6-terra-none" - }, - "gpt-5-6-terra-fast": { - "id": "gpt-5-6-terra-fast", - "name": "GPT-5.6 Terra Fast", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "effortRouting": { - "off": "gpt-5-6-terra-none-priority", - "low": "gpt-5-6-terra-low-priority", - "medium": "gpt-5-6-terra-medium-priority", - "high": "gpt-5-6-terra-high-priority", - "xhigh": "gpt-5-6-terra-xhigh-priority", - "max": "gpt-5-6-terra-max-priority" - } - }, - "supportsComputerUse": false, - "requestModelId": "gpt-5-6-terra-none-priority" - }, - "grok-4-5": { - "id": "grok-4-5", - "name": "Grok 4.5", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 500000, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high" - ], - "requiresEffort": true, - "effortRouting": { - "low": "grok-4-5-low", - "medium": "grok-4-5-medium", - "high": "grok-4-5-high" - } - }, - "supportsComputerUse": false, - "requestModelId": "grok-4-5-low" - }, - "grok-4-6-high": { - "id": "grok-4-6-high", - "name": "Grok 4.6 High", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 500000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "grok-4-6-low": { - "id": "grok-4-6-low", - "name": "Grok 4.6 Low", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 500000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "grok-4-6-medium": { - "id": "grok-4-6-medium", - "name": "Grok 4.6 Medium", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 500000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "grok-4-6-xhigh": { - "id": "grok-4-6-xhigh", - "name": "Grok 4.6 XHigh", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 500000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "inkling": { - "id": "inkling", - "name": "Inkling", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "medium", - "high", - "xhigh", - "max" - ], - "effortRouting": { - "off": "inkling-none", - "low": "inkling-low", - "medium": "inkling-medium", - "high": "inkling-high", - "xhigh": "inkling-xhigh", - "max": "inkling-max" - } - }, - "supportsComputerUse": false, - "requestModelId": "inkling-none" - }, - "kimi-k2-6": { - "id": "kimi-k2-6", - "name": "Kimi K2.6", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 262144, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "kimi-k2-7": { - "id": "kimi-k2-7", - "name": "Kimi K2.7", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 262144, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "kimi-k3": { - "id": "kimi-k3", - "name": "Kimi K3", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1048576, - "maxTokens": 64000, - "thinking": { - "mode": "effort", - "efforts": [ - "low", - "high", - "max" - ], - "requiresEffort": true, - "effortRouting": { - "low": "kimi-k3-low", - "high": "kimi-k3-high", - "max": "kimi-k3-max" - }, - "defaultLevel": "max" - }, - "supportsComputerUse": false, - "requestModelId": "kimi-k3-low" - }, - "MODEL_CHAT_GPT_4_1_2025_04_14": { - "id": "MODEL_CHAT_GPT_4_1_2025_04_14", - "name": "GPT-4.1", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": false, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1047576, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "MODEL_CLAUDE_4_5_OPUS": { - "id": "MODEL_CLAUDE_4_5_OPUS", - "name": "Claude Opus 4.5", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": false, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 200000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "MODEL_CLAUDE_4_5_OPUS_THINKING": { - "id": "MODEL_CLAUDE_4_5_OPUS_THINKING", - "name": "Claude Opus 4.5 Thinking", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 200000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "MODEL_PRIVATE_11": { - "id": "MODEL_PRIVATE_11", - "name": "Claude Haiku 4.5", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": false, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 200000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "MODEL_PRIVATE_12": { - "id": "MODEL_PRIVATE_12", - "name": "GPT-5.1 No Thinking", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": false, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 272000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "MODEL_PRIVATE_13": { - "id": "MODEL_PRIVATE_13", - "name": "GPT-5.1 Low Thinking", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 272000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "MODEL_PRIVATE_14": { - "id": "MODEL_PRIVATE_14", - "name": "GPT-5.1 Medium Thinking", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 272000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "MODEL_PRIVATE_15": { - "id": "MODEL_PRIVATE_15", - "name": "GPT-5.1 High Thinking", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", - "reasoning": true, - "input": [ - "text", - "image" - ], - "supportsTools": true, - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 272000, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "MODEL_PRIVATE_2": { - "id": "MODEL_PRIVATE_2", - "name": "Claude Sonnet 4.5", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", + }, + "gpt-5.6-terra-xhigh-fast": { + "id": "gpt-5.6-terra-xhigh-fast", + "name": "GPT-5.6 Terra Extra High Fast", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", "reasoning": false, "input": [ "text", "image" ], - "supportsTools": true, "cost": { "input": 0, "output": 0, @@ -23843,83 +21651,113 @@ }, "contextWindow": 200000, "maxTokens": 64000, - "supportsComputerUse": false + "cursorMaxMode": false, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, - "MODEL_PRIVATE_3": { - "id": "MODEL_PRIVATE_3", - "name": "Claude Sonnet 4.5 Thinking", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", + "grok-code-fast-1": { + "id": "grok-code-fast-1", + "name": "Grok Code Fast 1", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", "reasoning": true, "input": [ - "text", - "image" + "text" ], - "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 200000, - "maxTokens": 64000, - "supportsComputerUse": false + "contextWindow": 256000, + "maxTokens": 10000, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ] + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, - "nemotron-3-ultra-high": { - "id": "nemotron-3-ultra-high", - "name": "Nemotron 3 Ultra High", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", + "kimi-k2.5": { + "id": "kimi-k2.5", + "name": "Kimi K2.5", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", "reasoning": true, "input": [ - "text" + "text", + "image" ], - "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1000000, - "maxTokens": 64000, - "supportsComputerUse": false + "contextWindow": 262144, + "maxTokens": 65536, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ] + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, - "nemotron-3-ultra-medium": { - "id": "nemotron-3-ultra-medium", - "name": "Nemotron 3 Ultra Medium", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", + "kimi-k2.7-code": { + "id": "kimi-k2.7-code", + "name": "Kimi K2.7 Code", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", "reasoning": true, "input": [ - "text" + "text", + "image" ], - "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 1000000, + "contextWindow": 200000, "maxTokens": 64000, - "supportsComputerUse": false + "cursorMaxMode": false, + "thinking": { + "mode": "effort", + "efforts": [ + "minimal", + "low", + "medium", + "high" + ] + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, - "nemotron-3-ultra-none": { - "id": "nemotron-3-ultra-none", - "name": "Nemotron 3 Ultra None", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", + "kimi-k3-high": { + "id": "kimi-k3-high", + "name": "Kimi K3 High", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", "reasoning": true, "input": [ "text" ], - "supportsTools": true, "cost": { "input": 0, "output": 0, @@ -23928,100 +21766,173 @@ }, "contextWindow": 1000000, "maxTokens": 64000, - "supportsComputerUse": false + "cursorMaxMode": false, + "supportsComputerUse": false, + "supportsComputerUseConfig": false, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ], + "defaultLevel": "max", + "requiresEffort": true + } }, - "swe-1-6": { - "id": "swe-1-6", - "name": "SWE-1.6", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", + "kimi-k3-low": { + "id": "kimi-k3-low", + "name": "Kimi K3 Low", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", "reasoning": true, "input": [ - "text", - "image" + "text" ], - "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 200000, + "contextWindow": 1000000, "maxTokens": 64000, - "supportsComputerUse": false + "cursorMaxMode": false, + "supportsComputerUse": false, + "supportsComputerUseConfig": false, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ], + "defaultLevel": "max", + "requiresEffort": true + } }, - "swe-1-6-fast": { - "id": "swe-1-6-fast", - "name": "SWE-1.6 Fast", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", + "kimi-k3-max": { + "id": "kimi-k3-max", + "name": "Kimi K3", + "api": "cursor-agent", + "provider": "cursor", + "baseUrl": "https://api2.cursor.sh", "reasoning": true, "input": [ - "text", - "image" + "text" ], - "supportsTools": true, "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 200000, + "contextWindow": 1000000, "maxTokens": 64000, - "supportsComputerUse": false - }, - "swe-1-7": { - "id": "swe-1-7", - "name": "SWE-1.7 Max", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", + "cursorMaxMode": false, + "supportsComputerUse": false, + "supportsComputerUseConfig": false, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ], + "defaultLevel": "max", + "requiresEffort": true + } + } + }, + "deepseek": { + "deepseek-v4-flash": { + "id": "deepseek-v4-flash", + "name": "DeepSeek V4 Flash", + "api": "openai-completions", + "provider": "deepseek", + "baseUrl": "https://api.deepseek.com", "reasoning": true, "input": [ - "text", - "image" + "text" ], - "supportsTools": true, "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 0.14, + "output": 0.28, + "cacheRead": 0.0028, "cacheWrite": 0 }, - "contextWindow": 262000, - "maxTokens": 64000, - "supportsComputerUse": false, - "requestModelId": "swe-1-7-medium" + "contextWindow": 1000000, + "maxTokens": 384000, + "compat": { + "supportsDeveloperRole": false, + "supportsReasoningEffort": true, + "maxTokensField": "max_tokens", + "supportsToolChoice": false, + "extraBody": { + "thinking": { + "type": "enabled" + } + }, + "reasoningContentField": "reasoning_content", + "requiresReasoningContentForToolCalls": true, + "requiresAssistantContentForToolCalls": true + }, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ] + } }, - "swe-1-7-lightning": { - "id": "swe-1-7-lightning", - "name": "SWE-1.7 Lightning Max", - "api": "devin-agent", - "provider": "devin", - "baseUrl": "https://server.codeium.com", + "deepseek-v4-pro": { + "id": "deepseek-v4-pro", + "name": "DeepSeek V4 Pro", + "api": "openai-completions", + "provider": "deepseek", + "baseUrl": "https://api.deepseek.com", "reasoning": true, "input": [ - "text", - "image" + "text" ], - "supportsTools": true, "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, + "input": 0.435, + "output": 0.87, + "cacheRead": 0.003625, "cacheWrite": 0 }, - "contextWindow": 202752, - "maxTokens": 64000, - "supportsComputerUse": false - }, - "swe-1-7-lightning-medium": { - "id": "swe-1-7-lightning-medium", - "name": "SWE-1.7 Lightning Medium", + "contextWindow": 1000000, + "maxTokens": 384000, + "compat": { + "supportsDeveloperRole": false, + "supportsReasoningEffort": true, + "maxTokensField": "max_tokens", + "supportsToolChoice": false, + "extraBody": { + "thinking": { + "type": "enabled" + } + }, + "reasoningContentField": "reasoning_content", + "requiresReasoningContentForToolCalls": true, + "requiresAssistantContentForToolCalls": true + }, + "thinking": { + "mode": "effort", + "efforts": [ + "low", + "high", + "max" + ] + } + } + }, + "devin": { + "swe-1-6-slow": { + "id": "swe-1-6-slow", + "name": "SWE-1.6 Slow", "api": "devin-agent", "provider": "devin", "baseUrl": "https://server.codeium.com", @@ -24037,7 +21948,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 202752, + "contextWindow": 200000, "maxTokens": 64000, "supportsComputerUse": false } @@ -30227,25 +28138,6 @@ "contextWindow": 64000, "maxTokens": 8192 }, - "deepseek-ai/DeepSeek-V3-0324": { - "id": "deepseek-ai/DeepSeek-V3-0324", - "name": "DeepSeek V3 0324", - "api": "openai-completions", - "provider": "huggingface", - "baseUrl": "https://router.huggingface.co/v1", - "reasoning": false, - "input": [ - "text" - ], - "cost": { - "input": 0.27, - "output": 1.12, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 163840, - "maxTokens": 163840 - }, "deepseek-ai/DeepSeek-V3.1": { "id": "deepseek-ai/DeepSeek-V3.1", "name": "DeepSeek-V3.1", @@ -42423,7 +40315,7 @@ "input": 2, "output": 6, "cacheRead": 0.25, - "cacheWrite": 2.5 + "cacheWrite": 0 }, "contextWindow": 1000000, "maxTokens": 262144, @@ -80835,9 +78727,9 @@ "text" ], "cost": { - "input": 0.079996, - "output": 0.252, - "cacheRead": 0.0252, + "input": 0.072, + "output": 0.144, + "cacheRead": 0.016, "cacheWrite": 0 }, "contextWindow": 1048576, @@ -80927,13 +78819,13 @@ "image" ], "cost": { - "input": 2.8, - "output": 14, - "cacheRead": 0.29, + "input": 2.4, + "output": 12, + "cacheRead": 0.24, "cacheWrite": 0 }, "contextWindow": 1048576, - "maxTokens": 1048576, + "maxTokens": 974842, "thinking": { "mode": "effort", "efforts": [ @@ -93717,69 +91609,9 @@ } }, "synthetic": { - "hf:MiniMaxAI/MiniMax-M3": { - "id": "hf:MiniMaxAI/MiniMax-M3", - "name": "MiniMax-M3", - "api": "openai-completions", - "provider": "synthetic", - "baseUrl": "https://api.synthetic.new/openai/v1", - "reasoning": true, - "input": [ - "text", - "image" - ], - "cost": { - "input": 0.6, - "output": 1.2, - "cacheRead": 0.6, - "cacheWrite": 0 - }, - "contextWindow": 524288, - "maxTokens": 65536, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high", - "xhigh" - ] - } - }, - "hf:moonshotai/Kimi-K2.7-Code": { - "id": "hf:moonshotai/Kimi-K2.7-Code", - "name": "Kimi K2.7 Code", - "api": "openai-completions", - "provider": "synthetic", - "baseUrl": "https://api.synthetic.new/openai/v1", - "reasoning": true, - "input": [ - "text", - "image" - ], - "cost": { - "input": 0.95, - "output": 4, - "cacheRead": 0.95, - "cacheWrite": 0 - }, - "contextWindow": 262144, - "maxTokens": 65536, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high", - "xhigh" - ] - } - }, "hf:moonshotai/Kimi-K3": { "id": "hf:moonshotai/Kimi-K3", - "name": "Kimi K3", + "name": "moonshotai/Kimi-K3", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -93808,11 +91640,13 @@ "max": "max" }, "requiresEffort": true - } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "hf:nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4": { "id": "hf:nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4", - "name": "Nemotron 3 Super 120B A12B", + "name": "nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -93823,7 +91657,7 @@ "cost": { "input": 0.3, "output": 1, - "cacheRead": 0.3, + "cacheRead": 0.06, "cacheWrite": 0 }, "contextWindow": 262144, @@ -93837,11 +91671,13 @@ "high", "xhigh" ] - } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "hf:openai/gpt-oss-120b": { "id": "hf:openai/gpt-oss-120b", - "name": "GPT OSS 120B", + "name": "openai/gpt-oss-120b", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -93852,11 +91688,11 @@ "cost": { "input": 0.1, "output": 0.1, - "cacheRead": 0.1, + "cacheRead": 0.02, "cacheWrite": 0 }, "contextWindow": 131072, - "maxTokens": 32768, + "maxTokens": 65536, "thinking": { "mode": "effort", "efforts": [ @@ -93864,11 +91700,13 @@ "medium", "high" ] - } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "hf:Qwen/Qwen3.6-27B": { "id": "hf:Qwen/Qwen3.6-27B", - "name": "Qwen3.6 27B", + "name": "Qwen/Qwen3.6-27B", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -93879,8 +91717,8 @@ ], "cost": { "input": 0.45, - "output": 3.6, - "cacheRead": 0.45, + "output": 2.2, + "cacheRead": 0.09, "cacheWrite": 0 }, "contextWindow": 262144, @@ -93893,11 +91731,13 @@ "medium", "high" ] - } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "hf:zai-org/GLM-4.7-Flash": { "id": "hf:zai-org/GLM-4.7-Flash", - "name": "GLM-4.7-Flash", + "name": "zai-org/GLM-4.7-Flash", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -93908,7 +91748,7 @@ "cost": { "input": 0.1, "output": 0.5, - "cacheRead": 0.1, + "cacheRead": 0.02, "cacheWrite": 0 }, "contextWindow": 196608, @@ -93922,11 +91762,13 @@ "high", "xhigh" ] - } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "hf:zai-org/GLM-5.2": { "id": "hf:zai-org/GLM-5.2", - "name": "GLM-5.2", + "name": "zai-org/GLM-5.2", "api": "openai-completions", "provider": "synthetic", "baseUrl": "https://api.synthetic.new/openai/v1", @@ -93935,9 +91777,9 @@ "text" ], "cost": { - "input": 1.4, - "output": 4.4, - "cacheRead": 1.4, + "input": 1, + "output": 3, + "cacheRead": 0.16, "cacheWrite": 0 }, "contextWindow": 524288, @@ -93951,7 +91793,9 @@ "high", "max" ] - } + }, + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "syn:large:text": { "id": "syn:large:text", @@ -95042,40 +92886,6 @@ "escapeBuiltinToolNames": true } }, - "umans-deepseek-v4-pro-0813-lab": { - "id": "umans-deepseek-v4-pro-0813-lab", - "name": "Umans DeepSeek V4 Pro 0813 (lab)", - "api": "anthropic-messages", - "provider": "umans", - "baseUrl": "https://api.code.umans.ai", - "reasoning": true, - "thinking": { - "mode": "budget", - "efforts": [ - "minimal", - "low", - "medium", - "high", - "xhigh" - ] - }, - "input": [ - "text" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 524288, - "maxTokens": 393215, - "supportsComputerUse": false, - "supportsComputerUseConfig": false, - "compat": { - "escapeBuiltinToolNames": true - } - }, "umans-flash": { "id": "umans-flash", "name": "Umans Flash", @@ -96562,30 +94372,6 @@ ] } }, - "gemini-3-7-flash": { - "id": "gemini-3-7-flash", - "name": "gemini-3-7-flash", - "api": "openai-completions", - "provider": "venice", - "baseUrl": "https://api.venice.ai/api/v1", - "reasoning": false, - "input": [ - "text" - ], - "cost": { - "input": 0, - "output": 0, - "cacheRead": 0, - "cacheWrite": 0 - }, - "contextWindow": 1000000, - "maxTokens": 65536, - "supportsComputerUse": false, - "supportsComputerUseConfig": false, - "compat": { - "supportsUsageInStreaming": false - } - }, "gemini-3-flash-preview": { "id": "gemini-3-flash-preview", "name": "Gemini 3 Flash Preview", @@ -98339,30 +96125,26 @@ }, "qwen-3-8-2-4t-a95b": { "id": "qwen-3-8-2-4t-a95b", - "name": "Qwen 3.8 2.4T", + "name": "qwen-3-8-2-4t-a95b", "api": "openai-completions", "provider": "venice", "baseUrl": "https://api.venice.ai/api/v1", - "reasoning": true, + "reasoning": false, "input": [ "text" ], "cost": { - "input": 2.5, - "output": 7.5, - "cacheRead": 0.3125, + "input": 0, + "output": 0, + "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 262144, - "maxTokens": 65536, - "thinking": { - "mode": "effort", - "efforts": [ - "minimal", - "low", - "medium", - "high" - ] + "maxTokens": null, + "supportsComputerUse": false, + "supportsComputerUseConfig": false, + "compat": { + "supportsUsageInStreaming": false } }, "qwen-3-8-max": { @@ -99814,8 +97596,7 @@ "xhigh" ] }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "supportsComputerUse": false }, "alibaba/qwen3.8-max": { "id": "alibaba/qwen3.8-max", @@ -101017,8 +98798,7 @@ "xhigh" ] }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "supportsComputerUse": false }, "google/gemini-2.0-flash": { "id": "google/gemini-2.0-flash", @@ -101482,8 +99262,7 @@ ], "requiresEffort": true }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "supportsComputerUse": false }, "google/gemma-4-26b-a4b-it": { "id": "google/gemma-4-26b-a4b-it", @@ -101533,7 +99312,7 @@ "cacheRead": 0, "cacheWrite": 0 }, - "contextWindow": 256000, + "contextWindow": 262144, "maxTokens": 131072, "thinking": { "mode": "budget", @@ -102059,8 +99838,7 @@ "xhigh" ] }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "supportsComputerUse": false }, "meta/muse-spark-1.1": { "id": "meta/muse-spark-1.1", @@ -103719,7 +101497,8 @@ "high" ] }, - "supportsComputerUse": false + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "openai/gpt-5.1-thinking": { "id": "openai/gpt-5.1-thinking", @@ -103882,7 +101661,8 @@ }, "contextWindow": 128000, "maxTokens": 16384, - "supportsComputerUse": false + "supportsComputerUse": false, + "supportsComputerUseConfig": false }, "openai/gpt-5.3-codex": { "id": "openai/gpt-5.3-codex", @@ -104665,8 +102445,7 @@ "xhigh" ] }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "supportsComputerUse": false }, "stepfun/step-3.5-flash": { "id": "stepfun/step-3.5-flash", @@ -105369,8 +103148,7 @@ "xhigh" ] }, - "supportsComputerUse": false, - "supportsComputerUseConfig": false + "supportsComputerUse": false }, "xai/grok-build-0.1": { "id": "xai/grok-build-0.1", From 0b230e1d53781e2ec9235d361949bcc92301855c Mon Sep 17 00:00:00 2001 From: chuzui Date: Sun, 23 Aug 2026 12:44:44 +0800 Subject: [PATCH 023/795] fix(ai): exempt DeepSeek vision SKUs from text-only image guard --- packages/ai/CHANGELOG.md | 4 ++ packages/ai/src/providers/vision-guard.ts | 5 ++- ...nai-completions-tool-result-images.test.ts | 38 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 4d2973a947e4..b0f0a530907c 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## [Unreleased] +### Fixed + +- Fixed DeepSeek vision SKUs (`deepseek-v4-flash-vision-exp`, any `-vision-` id) losing image input after the text-only DeepSeek guard: genuinely multimodal ids now keep `image_url` parts while text-only DeepSeek endpoints still strip them. + ## [18.0.1] - 2026-08-23 diff --git a/packages/ai/src/providers/vision-guard.ts b/packages/ai/src/providers/vision-guard.ts index 7112d32adce3..eccd0ad31cfd 100644 --- a/packages/ai/src/providers/vision-guard.ts +++ b/packages/ai/src/providers/vision-guard.ts @@ -77,8 +77,11 @@ export function isDashscopeCompatibleModeTextOnlyQwen(model: Model<"openai-compl export function isTextOnlyDeepSeek(model: Model<"openai-completions">): boolean { const id = model.id.toLowerCase(); const name = (model.name ?? "").toLowerCase(); - // DeepSeek OCR is a genuinely multimodal model served by Novita. + // DeepSeek OCR and the multimodal vision SKUs (deepseek-v4-flash-vision-exp, + // future -vision- ids) genuinely accept image_url parts; same marker as the + // catalog's deepseek mapModel heuristic. if (id.includes("deepseek-ocr") || name.includes("deepseek-ocr")) return false; + if (id.includes("vision") || name.includes("vision")) return false; return ( modelMatchesHost(model, "deepseekFamily") || isDeepseekModelIdOrName(model.id) || diff --git a/packages/ai/test/openai-completions-tool-result-images.test.ts b/packages/ai/test/openai-completions-tool-result-images.test.ts index 0bb0433fb541..1fd89478a06f 100644 --- a/packages/ai/test/openai-completions-tool-result-images.test.ts +++ b/packages/ai/test/openai-completions-tool-result-images.test.ts @@ -547,4 +547,42 @@ describe("openai-completions convertMessages", () => { }, ]); }); + it("preserves image_url for the multimodal DeepSeek vision SKU", () => { + // deepseek-v4-flash-vision-exp is genuinely multimodal: the blanket + // DeepSeek text-only guard must not strip its image parts. Built inline + // because the bundled catalog does not carry the SKU yet. + const baseModel = getBundledModel("openai", "gpt-4o-mini") as Model<"openai-completions">; + const model: Model<"openai-completions"> = { + ...baseModel, + id: "deepseek-v4-flash-vision-exp", + name: "DeepSeek V4 Flash Vision Exp", + provider: "deepseek" as Model<"openai-completions">["provider"], + baseUrl: "https://api.deepseek.com", + api: "openai-completions", + input: ["text", "image"], + }; + const context: Context = { + messages: [ + { + role: "user", + content: [ + { type: "text", text: "Describe this image" }, + { type: "image", data: "ZmFrZQ==", mimeType: "image/png" }, + ], + timestamp: Date.now(), + }, + ], + }; + + const messages = convertMessages(model, context, compat); + + expect(messages).toHaveLength(1); + expect(messages[0].content).toEqual([ + { type: "text", text: "Describe this image" }, + { + type: "image_url", + image_url: { url: "data:image/png;base64,ZmFrZQ==" }, + }, + ]); + }); }); From fc1e13b3f1cabc9bcc6e1fc34e1db11cf088399e Mon Sep 17 00:00:00 2001 From: chuzui Date: Sun, 23 Aug 2026 12:50:09 +0800 Subject: [PATCH 024/795] fix(ai): match vision as a delimited token, not a substring --- packages/ai/src/providers/vision-guard.ts | 9 +++++++-- .../test/openai-completions-tool-result-images.test.ts | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/ai/src/providers/vision-guard.ts b/packages/ai/src/providers/vision-guard.ts index eccd0ad31cfd..56c1c4b2ee9b 100644 --- a/packages/ai/src/providers/vision-guard.ts +++ b/packages/ai/src/providers/vision-guard.ts @@ -4,6 +4,10 @@ import { isDeepseekModelIdOrName, isQwenModelId } from "@oh-my-pi/pi-catalog/ide import type { ImageContent, Model, TextContent } from "../types"; export const NON_VISION_IMAGE_PLACEHOLDER = "[image omitted: model does not support vision]"; +// `vision` delimited by non-alphanumerics, so `deepseek-v4-flash-vision-exp` +// and `deepseek_vision` match but `deepseek-r1-revision-0528` does not. +// Inputs are lowercased before testing. +const VISION_TOKEN = /(?, @@ -79,9 +83,10 @@ export function isTextOnlyDeepSeek(model: Model<"openai-completions">): boolean const name = (model.name ?? "").toLowerCase(); // DeepSeek OCR and the multimodal vision SKUs (deepseek-v4-flash-vision-exp, // future -vision- ids) genuinely accept image_url parts; same marker as the - // catalog's deepseek mapModel heuristic. + // catalog's deepseek mapModel heuristic. `vision` must be a bounded token: + // `revision` contains it as a substring and must stay guarded. if (id.includes("deepseek-ocr") || name.includes("deepseek-ocr")) return false; - if (id.includes("vision") || name.includes("vision")) return false; + if (VISION_TOKEN.test(id) || VISION_TOKEN.test(name)) return false; return ( modelMatchesHost(model, "deepseekFamily") || isDeepseekModelIdOrName(model.id) || diff --git a/packages/ai/test/openai-completions-tool-result-images.test.ts b/packages/ai/test/openai-completions-tool-result-images.test.ts index 1fd89478a06f..298b5228ed4f 100644 --- a/packages/ai/test/openai-completions-tool-result-images.test.ts +++ b/packages/ai/test/openai-completions-tool-result-images.test.ts @@ -450,6 +450,8 @@ describe("openai-completions convertMessages", () => { { id: "deepseek-chat", provider: "deepseek", baseUrl: "https://api.deepseek.com" }, { id: "deepseek-reasoner", provider: "deepseek", baseUrl: "https://api.deepseek.com" }, { id: "deepseek-ai/DeepSeek-V4-Pro", provider: "custom-proxy", baseUrl: "https://llm-proxy.example.com/v1" }, + // `vision` inside `revision` is a substring, not a multimodal token. + { id: "deepseek-r1-revision-0528", provider: "custom-proxy", baseUrl: "https://llm-proxy.example.com/v1" }, ]; const baseModel = getBundledModel("openai", "gpt-4o-mini") as Model<"openai-completions">; From 062f50b4408d9386438d29fa9eb8a03ac5008fee Mon Sep 17 00:00:00 2001 From: chuzui Date: Sun, 23 Aug 2026 12:55:30 +0800 Subject: [PATCH 025/795] test(ai): use bundled vision row, add provisioned substring counter-case --- ...openai-completions-tool-result-images.test.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/ai/test/openai-completions-tool-result-images.test.ts b/packages/ai/test/openai-completions-tool-result-images.test.ts index 298b5228ed4f..cf314b6aa408 100644 --- a/packages/ai/test/openai-completions-tool-result-images.test.ts +++ b/packages/ai/test/openai-completions-tool-result-images.test.ts @@ -452,6 +452,8 @@ describe("openai-completions convertMessages", () => { { id: "deepseek-ai/DeepSeek-V4-Pro", provider: "custom-proxy", baseUrl: "https://llm-proxy.example.com/v1" }, // `vision` inside `revision` is a substring, not a multimodal token. { id: "deepseek-r1-revision-0528", provider: "custom-proxy", baseUrl: "https://llm-proxy.example.com/v1" }, + // `vision` inside `provisioned` is a substring, not a multimodal token. + { id: "deepseek-v4-provisioned", provider: "custom-proxy", baseUrl: "https://llm-proxy.example.com/v1" }, ]; const baseModel = getBundledModel("openai", "gpt-4o-mini") as Model<"openai-completions">; @@ -551,18 +553,8 @@ describe("openai-completions convertMessages", () => { }); it("preserves image_url for the multimodal DeepSeek vision SKU", () => { // deepseek-v4-flash-vision-exp is genuinely multimodal: the blanket - // DeepSeek text-only guard must not strip its image parts. Built inline - // because the bundled catalog does not carry the SKU yet. - const baseModel = getBundledModel("openai", "gpt-4o-mini") as Model<"openai-completions">; - const model: Model<"openai-completions"> = { - ...baseModel, - id: "deepseek-v4-flash-vision-exp", - name: "DeepSeek V4 Flash Vision Exp", - provider: "deepseek" as Model<"openai-completions">["provider"], - baseUrl: "https://api.deepseek.com", - api: "openai-completions", - input: ["text", "image"], - }; + // DeepSeek text-only guard must not strip its image parts. + const model = getBundledModel("deepseek", "deepseek-v4-flash-vision-exp") as Model<"openai-completions">; const context: Context = { messages: [ { From 035537235da41944cf9b646a202d15af8bb9c9b8 Mon Sep 17 00:00:00 2001 From: poorpaper <43514747+poorpaper@users.noreply.github.com> Date: Sun, 23 Aug 2026 17:07:58 +0800 Subject: [PATCH 026/795] fix(coding-agent): authenticate Jina Reader requests --- packages/coding-agent/CHANGELOG.md | 1 + packages/coding-agent/src/tools/fetch.ts | 14 ++-- .../test/tools/fetch-jina-stall.test.ts | 69 +++++++++++++++++++ 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index d358159fd029..563ce62e5bec 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -14,6 +14,7 @@ - Squeezed transcript tool rows no longer render as a bare unstyled `╭─ Hub` frame: a squeezed block keeps its real render whenever it fits the allocated rows, and blocks that genuinely overflow fold to a themed frame that names the tool's activity (e.g. `Hub · send → Main`). - Python/Ruby/Julia eval cells that hit their wall-clock timeout during a `parallel()`/`agent()`/`tool.*` fan-out no longer get their kernel force-killed (losing all session state): the timeout now aborts in-flight bridge calls so the runner unwinds as a clean KeyboardInterrupt and the kernel survives. - Multi-select ask options whose labels end in `(Recommended)` now show their checked state and avoid duplicate recommendation suffixes ([#9452](https://github.com/can1357/oh-my-pi/issues/9452)). +- Jina Reader requests now use configured credentials for higher authenticated rate limits while remaining available anonymously ([#9431](https://github.com/can1357/oh-my-pi/issues/9431)). ## [18.0.2] - 2026-08-23 diff --git a/packages/coding-agent/src/tools/fetch.ts b/packages/coding-agent/src/tools/fetch.ts index bd0f8ad8fcbe..29efeb125828 100644 --- a/packages/coding-agent/src/tools/fetch.ts +++ b/packages/coding-agent/src/tools/fetch.ts @@ -3,7 +3,7 @@ import * as fs from "node:fs/promises"; import * as os from "node:os"; import * as path from "node:path"; import type { AgentToolResult } from "@oh-my-pi/pi-agent-core"; -import type { FetchImpl, ImageContent, TextContent } from "@oh-my-pi/pi-ai"; +import { type FetchImpl, getEnvApiKey, type ImageContent, type TextContent } from "@oh-my-pi/pi-ai"; import { htmlToMarkdown } from "@oh-my-pi/pi-natives"; import { type Component, Text } from "@oh-my-pi/pi-tui"; import { $which, ptree, truncate } from "@oh-my-pi/pi-utils"; @@ -25,6 +25,7 @@ import { extractWithParallel, findParallelApiKey, getParallelExtractContent } fr import type { RenderResult, SpecialHandler } from "../web/scrapers/types"; import { finalizeOutput, loadPage, looksLikeHtml, MAX_BYTES, MAX_OUTPUT_CHARS } from "../web/scrapers/types"; import { convertWithMarkit, fetchBinary } from "../web/scrapers/utils"; +import { findCredential } from "../web/search/providers/utils"; import { applyListLimit } from "./list-limit"; import { formatStyledArtifactReference, type OutputMeta } from "./output-meta"; import { isReadableUrlPath, type LineRange, parseLineRanges } from "./path-utils"; @@ -665,11 +666,14 @@ export async function renderHtmlToText( return firstDocument ? getParallelExtractContent(firstDocument) : null; }, jina: async () => { + const apiKey = findCredential(storage, getEnvApiKey("jina"), "jina"); + const headers: Record = { + Accept: "text/markdown", + "X-No-Cache": "true", + }; + if (apiKey) headers.Authorization = `Bearer ${apiKey}`; const response = await fetchImpl(`https://r.jina.ai/${url}`, { - headers: { - Accept: "text/markdown", - "X-No-Cache": "true", - }, + headers, signal: remoteSignal(), }); if (!response.ok) return null; diff --git a/packages/coding-agent/test/tools/fetch-jina-stall.test.ts b/packages/coding-agent/test/tools/fetch-jina-stall.test.ts index 9a6ef2084fce..059cccebe8a9 100644 --- a/packages/coding-agent/test/tools/fetch-jina-stall.test.ts +++ b/packages/coding-agent/test/tools/fetch-jina-stall.test.ts @@ -1,6 +1,9 @@ import { describe, expect, it } from "bun:test"; +import * as path from "node:path"; import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings"; +import { AgentStorage } from "@oh-my-pi/pi-coding-agent/session/agent-storage"; import { renderHtmlToText } from "@oh-my-pi/pi-coding-agent/tools/fetch"; +import { TempDir } from "@oh-my-pi/pi-utils"; import { asGlobalFetch } from "../helpers/fetch-mock"; /** @@ -95,6 +98,71 @@ describe("renderHtmlToText: jina stall does not starve local fallbacks (#1449)", }); describe("renderHtmlToText: Jina response validation", () => { + it("sends JINA_API_KEY as optional bearer authentication", async () => { + const originalApiKey = process.env.JINA_API_KEY; + process.env.JINA_API_KEY = "env-jina-key"; + try { + const settings = Settings.isolated({ "providers.fetch": "jina" }); + let requestHeaders: Headers | undefined; + const markdown = `# Authenticated article\n\n${"Substantive reader content. ".repeat(8)}`.trim(); + const fetchMock = asGlobalFetch((_input, init) => { + requestHeaders = new Headers(init?.headers); + return new Response(`Markdown Content:\n${markdown}`); + }); + + const result = await renderHtmlToText( + "https://example.com/article", + "short", + 1, + settings, + undefined, + null, + fetchMock, + ); + + expect(result.method).toBe("jina"); + expect(requestHeaders?.get("authorization")).toBe("Bearer env-jina-key"); + } finally { + if (originalApiKey === undefined) delete process.env.JINA_API_KEY; + else process.env.JINA_API_KEY = originalApiKey; + } + }); + + it("uses a stored Jina credential when the environment key is absent", async () => { + const originalApiKey = process.env.JINA_API_KEY; + delete process.env.JINA_API_KEY; + const tempDir = TempDir.createSync("@omp-jina-reader-auth-"); + try { + const storage = await AgentStorage.open(path.join(tempDir.path(), "agent.db")); + storage.replaceAuthCredentialsForProvider("jina", [{ type: "api_key", key: "stored-jina-key" }]); + const settings = Settings.isolated({ "providers.fetch": "jina" }); + let requestHeaders: Headers | undefined; + const markdown = `# Authenticated article\n\n${"Substantive reader content. ".repeat(8)}`.trim(); + const fetchMock = asGlobalFetch((_input, init) => { + requestHeaders = new Headers(init?.headers); + return new Response(`Markdown Content:\n${markdown}`); + }); + + const result = await renderHtmlToText( + "https://example.com/article", + "short", + 1, + settings, + undefined, + storage, + fetchMock, + ); + + expect(result.method).toBe("jina"); + expect(requestHeaders?.get("authorization")).toBe("Bearer stored-jina-key"); + } finally { + AgentStorage.resetInstance(); + await tempDir.remove().catch(() => {}); + if (originalApiKey === undefined) delete process.env.JINA_API_KEY; + else process.env.JINA_API_KEY = originalApiKey; + } + }); + it("requests fresh markdown and strips the Jina metadata preamble", async () => { const settings = Settings.isolated({ "providers.fetch": "jina" }); const markdown = `# Extracted article\n\n${"Substantive reader content. ".repeat(8)}`.trim(); @@ -117,6 +185,7 @@ describe("renderHtmlToText: Jina response validation", () => { expect(result).toEqual({ content: markdown, ok: true, method: "jina" }); expect(requestHeaders?.get("accept")).toBe("text/markdown"); expect(requestHeaders?.get("x-no-cache")).toBe("true"); + expect(requestHeaders?.get("authorization")).toBeNull(); }); for (const { label, readerBody, headers } of [ From a768d5cafd3bab0b2d865c2d26c5449b31db1b41 Mon Sep 17 00:00:00 2001 From: poorpaper <43514747+poorpaper@users.noreply.github.com> Date: Sun, 23 Aug 2026 18:32:31 +0800 Subject: [PATCH 027/795] docs(coding-agent): keep Jina fix unreleased --- packages/coding-agent/CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 563ce62e5bec..d741333658bb 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Jina Reader requests now use configured credentials for higher authenticated rate limits while remaining available anonymously ([#9431](https://github.com/can1357/oh-my-pi/issues/9431)). + ## [18.0.3] - 2026-08-23 ### Added @@ -14,7 +18,6 @@ - Squeezed transcript tool rows no longer render as a bare unstyled `╭─ Hub` frame: a squeezed block keeps its real render whenever it fits the allocated rows, and blocks that genuinely overflow fold to a themed frame that names the tool's activity (e.g. `Hub · send → Main`). - Python/Ruby/Julia eval cells that hit their wall-clock timeout during a `parallel()`/`agent()`/`tool.*` fan-out no longer get their kernel force-killed (losing all session state): the timeout now aborts in-flight bridge calls so the runner unwinds as a clean KeyboardInterrupt and the kernel survives. - Multi-select ask options whose labels end in `(Recommended)` now show their checked state and avoid duplicate recommendation suffixes ([#9452](https://github.com/can1357/oh-my-pi/issues/9452)). -- Jina Reader requests now use configured credentials for higher authenticated rate limits while remaining available anonymously ([#9431](https://github.com/can1357/oh-my-pi/issues/9431)). ## [18.0.2] - 2026-08-23 From 39ce9b85bcf6af5ff63ac1e6af00a88a778f3cb5 Mon Sep 17 00:00:00 2001 From: roboomp Date: Sun, 23 Aug 2026 21:54:30 +0000 Subject: [PATCH 028/795] fix(agent): resumed maintenance after speculative handoff Waited for an overlapping speculative handoff before resuming the skipped post-turn maintenance pass. Superseding prompts and aborts retain ownership of recovery. Added a regression covering a thinking-only length stop during handoff generation. Fixes #9529 --- packages/coding-agent/CHANGELOG.md | 4 + .../coding-agent/src/session/agent-session.ts | 27 +++++- .../src/session/session-maintenance.ts | 5 ++ ...ion-auto-compaction-progress-guard.test.ts | 83 +++++++++++++++++++ 4 files changed, 116 insertions(+), 3 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index d358159fd029..96f673d8a118 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Thinking-only length stops that overlap speculative handoff now resume compaction recovery instead of leaving the autonomous run idle. + ## [18.0.3] - 2026-08-23 ### Added diff --git a/packages/coding-agent/src/session/agent-session.ts b/packages/coding-agent/src/session/agent-session.ts index c66ab2c937e8..e24bee4530c1 100644 --- a/packages/coding-agent/src/session/agent-session.ts +++ b/packages/coding-agent/src/session/agent-session.ts @@ -667,6 +667,7 @@ export class AgentSession { // Cursor exec, TUI listeners) is held back. Without this, a client that resumes // on `agent_end` can fire its next `prompt` before #promptWithMessage's finally #promptGeneration = 0; + #promptSequence = 0; #pendingAgentEndEmit: AgentSessionEvent | undefined; #inFlightSettledCallbacks: Array<() => void | Promise> = []; #sessionStopContinuationCount = 0; @@ -2957,9 +2958,28 @@ export class AgentSession { if (this.#maintenance.skipPostTurnMaintenanceAssistantTimestamp === msg.timestamp) { this.#maintenance.skipPostTurnMaintenanceAssistantTimestamp = undefined; this.#lastSuccessfulYieldToolCallId = undefined; - maintenanceRoute("skip-post-turn-maintenance"); - await emitAgentEndNotification(); - return; + const speculationCompletion = this.#maintenance.speculationCompletion; + if (!speculationCompletion) { + maintenanceRoute("skip-post-turn-maintenance"); + await emitAgentEndNotification(); + return; + } + + const promptSequence = this.#promptSequence; + const promptGeneration = this.#promptGeneration; + maintenanceRoute("await-speculative-compaction"); + await speculationCompletion; + if ( + this.#isDisposed || + this.#abortInProgress || + this.#promptGeneration !== promptGeneration || + this.#promptSequence !== promptSequence + ) { + maintenanceRoute("skip-superseded-speculative-maintenance"); + await emitAgentEndNotification(); + return; + } + maintenanceRoute("resume-post-turn-maintenance"); } const activeGoal = this.#goalModeState?.enabled === true && this.#goalModeState.goal.status === "active"; @@ -5702,6 +5722,7 @@ export class AgentSession { // the typed text back to the host instead of losing it. this.#beginInFlight(); const generation = this.#promptGeneration; + this.#promptSequence++; try { await this.#recovery.maybeRestoreRetryFallbackPrimary(); if (!(await this.#runUsageAwarePreflightForNextModelCall())) return false; diff --git a/packages/coding-agent/src/session/session-maintenance.ts b/packages/coding-agent/src/session/session-maintenance.ts index 8cab7dc98a1b..0f57d3a23242 100644 --- a/packages/coding-agent/src/session/session-maintenance.ts +++ b/packages/coding-agent/src/session/session-maintenance.ts @@ -370,6 +370,11 @@ export class SessionMaintenance { return run.armed ? "armed" : "running"; } + /** Completion of the current speculative pass, used to resume maintenance skipped during its handoff. */ + get speculationCompletion(): Promise | undefined { + return this.#speculation?.promise; + } + /** Abort and discard any in-flight or armed speculative compaction. */ cancelSpeculation(): void { const run = this.#speculation; diff --git a/packages/coding-agent/test/agent-session-auto-compaction-progress-guard.test.ts b/packages/coding-agent/test/agent-session-auto-compaction-progress-guard.test.ts index a226cc052c98..fed21ba8961f 100644 --- a/packages/coding-agent/test/agent-session-auto-compaction-progress-guard.test.ts +++ b/packages/coding-agent/test/agent-session-auto-compaction-progress-guard.test.ts @@ -1,4 +1,5 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "bun:test"; +import { scheduler } from "node:timers/promises"; import { Agent } from "@oh-my-pi/pi-agent-core"; import * as compactionModule from "@oh-my-pi/pi-agent-core/compaction"; import { type CompactionPreparation, resolveThresholdTokens, shouldCompact } from "@oh-my-pi/pi-agent-core/compaction"; @@ -936,6 +937,88 @@ describe("AgentSession auto-compaction progress guard", () => { ); }); + it("resumes a thinking-only length stop after an overlapping speculative handoff", async () => { + session.settings.set("compaction.methodOrder", ["handoff"]); + session.settings.set("compaction.enabled", true); + session.settings.set("compaction.asyncEnabled", true); + session.settings.set("compaction.thresholdTokens", 150_000); + session.settings.set("compaction.keepRecentTokens", 1); + session.settings.set("contextPromotion.enabled", false); + compactHookEnabled = false; + const continueSpy = vi.spyOn(session.agent, "continue").mockResolvedValue(); + const handoffStarted = Promise.withResolvers(); + const handoffResult = Promise.withResolvers(); + vi.spyOn(compactionModule, "generateHandoffFromContext").mockImplementation(async () => { + handoffStarted.resolve(); + return handoffResult.promise; + }); + + const speculativeTrigger = { + role: "assistant" as const, + content: [{ type: "text" as const, text: "working" }], + api: "anthropic-messages" as const, + provider: "anthropic" as const, + model: "claude-sonnet-4-5", + stopReason: "stop" as const, + usage: { + input: 143_000, + output: 1_000, + cacheRead: 0, + cacheWrite: 0, + totalTokens: 144_000, + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }, + }, + timestamp: Date.now(), + }; + sessionManager.appendMessage(speculativeTrigger); + session.agent.emitExternalEvent({ type: "message_end", message: speculativeTrigger }); + session.agent.emitExternalEvent({ type: "agent_end", messages: [speculativeTrigger] }); + await handoffStarted.promise; + expect(session.compactionSpeculation).toBe("running"); + + await session.waitForIdle(); + const lengthStop = { + role: "assistant" as const, + content: [{ type: "thinking" as const, thinking: "unfinished reasoning" }], + api: "anthropic-messages" as const, + provider: "anthropic" as const, + model: "claude-sonnet-4-5", + stopReason: "length" as const, + usage: { + input: 150_000, + output: 50_000, + cacheRead: 0, + cacheWrite: 0, + totalTokens: 200_000, + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }, + }, + timestamp: speculativeTrigger.timestamp + 1, + }; + sessionManager.appendMessage(lengthStop); + session.agent.emitExternalEvent({ type: "message_end", message: lengthStop }); + await scheduler.yield(); + session.agent.emitExternalEvent({ type: "agent_end", messages: [lengthStop] }); + await scheduler.yield(); + + handoffResult.resolve("speculative handoff"); + await session.waitForIdle(); + + expect(continueSpy).toHaveBeenCalledTimes(1); + expect(sessionManager.getBranch().at(-1)).toMatchObject({ + type: "compaction", + summary: "speculative handoff", + }); + expect(sessionManager.getBranch()).not.toContainEqual( + expect.objectContaining({ + type: "message", + message: expect.objectContaining({ + role: "assistant", + stopReason: "length", + }), + }), + ); + }); + it("retries a small-window overflow when the reserve exceeds the model window", async () => { // Bundled 4k/8k models can be smaller than the absolute reserve (16,384, // explicit or defaulted). Retry fit must clamp that reserve; otherwise the From 7b185d121799553f11cf6a5dabfef4cf9460a869 Mon Sep 17 00:00:00 2001 From: roboomp Date: Sun, 23 Aug 2026 22:01:17 +0000 Subject: [PATCH 029/795] fix(agent): limited speculative handoff wait Kept ordinary successful stops on the immediate settle path while retaining the handoff completion wait for same-model length and context-overflow recovery. Extended the overlap regression to prove a successful stop settles before the handoff resolves. --- .../coding-agent/src/session/agent-session.ts | 11 ++++++- ...ion-auto-compaction-progress-guard.test.ts | 32 +++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/coding-agent/src/session/agent-session.ts b/packages/coding-agent/src/session/agent-session.ts index e24bee4530c1..52f6fb8bf756 100644 --- a/packages/coding-agent/src/session/agent-session.ts +++ b/packages/coding-agent/src/session/agent-session.ts @@ -2958,7 +2958,16 @@ export class AgentSession { if (this.#maintenance.skipPostTurnMaintenanceAssistantTimestamp === msg.timestamp) { this.#maintenance.skipPostTurnMaintenanceAssistantTimestamp = undefined; this.#lastSuccessfulYieldToolCallId = undefined; - const speculationCompletion = this.#maintenance.speculationCompletion; + const model = this.model; + const requiresSpeculativeRecovery = + model !== undefined && + msg.provider === model.provider && + msg.model === model.id && + (msg.stopReason === "length" || + (msg.stopReason === "error" && AIError.isContextOverflow(msg, model.contextWindow ?? 0))); + const speculationCompletion = requiresSpeculativeRecovery + ? this.#maintenance.speculationCompletion + : undefined; if (!speculationCompletion) { maintenanceRoute("skip-post-turn-maintenance"); await emitAgentEndNotification(); diff --git a/packages/coding-agent/test/agent-session-auto-compaction-progress-guard.test.ts b/packages/coding-agent/test/agent-session-auto-compaction-progress-guard.test.ts index fed21ba8961f..f3e2d9d7e1c2 100644 --- a/packages/coding-agent/test/agent-session-auto-compaction-progress-guard.test.ts +++ b/packages/coding-agent/test/agent-session-auto-compaction-progress-guard.test.ts @@ -937,7 +937,7 @@ describe("AgentSession auto-compaction progress guard", () => { ); }); - it("resumes a thinking-only length stop after an overlapping speculative handoff", async () => { + it("settles an overlapping successful stop but resumes a thinking-only length stop", async () => { session.settings.set("compaction.methodOrder", ["handoff"]); session.settings.set("compaction.enabled", true); session.settings.set("compaction.asyncEnabled", true); @@ -977,6 +977,34 @@ describe("AgentSession auto-compaction progress guard", () => { expect(session.compactionSpeculation).toBe("running"); await session.waitForIdle(); + const ordinaryStop = { + role: "assistant" as const, + content: [{ type: "text" as const, text: "finished" }], + api: "anthropic-messages" as const, + provider: "anthropic" as const, + model: "claude-sonnet-4-5", + stopReason: "stop" as const, + usage: { + input: 143_000, + output: 2_000, + cacheRead: 0, + cacheWrite: 0, + totalTokens: 145_000, + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }, + }, + timestamp: speculativeTrigger.timestamp + 1, + }; + const ordinaryAgentEnd = Promise.withResolvers(); + session.subscribe(event => { + if (event.type === "agent_end") ordinaryAgentEnd.resolve(); + }); + sessionManager.appendMessage(ordinaryStop); + session.agent.emitExternalEvent({ type: "message_end", message: ordinaryStop }); + await scheduler.yield(); + session.agent.emitExternalEvent({ type: "agent_end", messages: [ordinaryStop] }); + await ordinaryAgentEnd.promise; + expect(session.compactionSpeculation).toBe("running"); + const lengthStop = { role: "assistant" as const, content: [{ type: "thinking" as const, thinking: "unfinished reasoning" }], @@ -992,7 +1020,7 @@ describe("AgentSession auto-compaction progress guard", () => { totalTokens: 200_000, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }, }, - timestamp: speculativeTrigger.timestamp + 1, + timestamp: speculativeTrigger.timestamp + 2, }; sessionManager.appendMessage(lengthStop); session.agent.emitExternalEvent({ type: "message_end", message: lengthStop }); From 6f488bb0bf766839760414760fdf5a99a329b8dd Mon Sep 17 00:00:00 2001 From: roboomp Date: Sun, 23 Aug 2026 23:31:26 +0000 Subject: [PATCH 030/795] fix(browsers): extract managed chrome past 64 MiB member cap The first-use Chrome-for-Testing install ran extractArchive() with the default archive limits, whose 64 MiB per-member ceiling guards against attacker-controlled archives. The trusted chrome binary (~269 MB) blew past it, so extraction aborted and the browser tool stayed unusable without a manual PUPPETEER_EXECUTABLE_PATH override. Extract the trusted managed download with a member/in-memory ceiling sized for the browser binary (1 GiB). Fixes #9534 --- packages/utils/CHANGELOG.md | 4 ++++ packages/utils/src/browsers.ts | 16 ++++++++++++++-- packages/utils/test/browsers.test.ts | 23 +++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 836bcf9608b3..eea1a32fe890 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Managed Chrome-for-Testing installs no longer fail extracting the ~269 MB `chrome` binary against the default 64 MiB archive-member cap; the trusted browser download now extracts with a ceiling sized for it. ([#9534](https://github.com/can1357/oh-my-pi/issues/9534)) + ## [18.0.1] - 2026-08-23 ### Fixed diff --git a/packages/utils/src/browsers.ts b/packages/utils/src/browsers.ts index 474e80072cd8..af00fd24611b 100644 --- a/packages/utils/src/browsers.ts +++ b/packages/utils/src/browsers.ts @@ -4,11 +4,23 @@ import type * as fs from "node:fs"; import * as fsp from "node:fs/promises"; import * as os from "node:os"; import * as path from "node:path"; -import { extractArchive } from "./ar"; +import { type ArchiveLimits, extractArchive } from "./ar"; const CHROME_FOR_TESTING_BASE_URL = "https://storage.googleapis.com/chrome-for-testing-public"; const CHROME_METADATA_BASE_URL = "https://googlechromelabs.github.io/chrome-for-testing"; +/** + * Archive ceilings for the managed browser download. The default archive + * limits (64 MiB per member / 256 MiB in memory) guard against attacker- + * controlled archives, but the Chrome-for-Testing binary is a trusted + * first-party download whose `chrome` executable already exceeds both + * (~269 MB and growing), so extraction gets a ceiling sized for it. + */ +const BROWSER_ARCHIVE_LIMITS: Partial = { + maxMemberSize: 1024 * 1024 * 1024, + maxInMemorySize: 1024 * 1024 * 1024, +}; + /** Supported browser products. */ export enum Browser { CHROME = "chrome", @@ -242,7 +254,7 @@ export async function install(options: InstallOptions): Promise { + // Regression for #9534: the managed Chrome-for-Testing binary (~269 MB) + // exceeds DEFAULT_ARCHIVE_LIMITS.maxMemberSize (64 MiB), so install() must + // extract with a ceiling sized for the trusted download. + const root = await makeRoot(); + const bigSize = 65 * 1024 * 1024; // > 64 MiB default member cap + const zip = await encodeArchive("zip", [["chrome-linux64/chrome", new Uint8Array(bigSize)]]); + const server = Bun.serve({ port: 0, fetch: () => new Response(new Blob([zip])) }); + try { + const installed = await install({ + browser: Browser.CHROME, + platform: BrowserPlatform.LINUX, + buildId: BUILD_ID, + cacheDir: root, + baseUrl: String(server.url), + }); + expect((await fs.stat(installed.executablePath)).size).toBe(bigSize); + } finally { + server.stop(true); + } +}); + test("install rejects archive traversal", async () => { const root = await makeRoot(); const fixture = Bun.file(path.join(import.meta.dir, "fixtures/browsers/traversal.zip")); From f112e37dbb74b05d22cb91eb234e7c11d68462b4 Mon Sep 17 00:00:00 2001 From: roboomp Date: Sun, 23 Aug 2026 23:37:11 +0000 Subject: [PATCH 031/795] fix(browser): guarded handle actions fail fast instead of stalling the cell Handles from tab.id()/tab.ref()/tab.waitFor() returned raw puppeteer ElementHandles whose inherited click()/type()/etc. ran in user code outside the #runOp guard, so a stalled (await tab.id(n)).click() had no per-op deadline and consumed the whole 30s browser cell. toActionableHandle now accepts a per-op guard; #createTabApi routes every interactive handle method through the same fail-fast wrapper as tab.click(selector), surfacing a named error like `handle.click() timed out after 8000ms`. The guarded fill() uses the raw typer so it stays a single op rather than re-entering the guard. Fixes #9535 --- packages/coding-agent/CHANGELOG.md | 4 + .../src/tools/browser/tab-worker.ts | 81 ++++++++++++++--- .../test/tools/browser-run-output.test.ts | 86 ++++++++++++++++++- 3 files changed, 157 insertions(+), 14 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index d358159fd029..d3e017cda65b 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Browser handles from `tab.id()`/`tab.ref()`/`tab.waitFor()` now fail fast with a named per-op error (e.g. `handle.click() timed out after 8000ms`) instead of letting a stalled `(await tab.id(n)).click()` consume the whole browser cell ([#9535](https://github.com/can1357/oh-my-pi/issues/9535)). + ## [18.0.3] - 2026-08-23 ### Added diff --git a/packages/coding-agent/src/tools/browser/tab-worker.ts b/packages/coding-agent/src/tools/browser/tab-worker.ts index d355a79f332f..7eb71a827ea3 100644 --- a/packages/coding-agent/src/tools/browser/tab-worker.ts +++ b/packages/coding-agent/src/tools/browser/tab-worker.ts @@ -320,18 +320,70 @@ function asElementHandle(handle: unknown): ElementHandle | null { export type ActionableHandle = ElementHandle & { fill(value: string): Promise }; /** - * Attach `fill()` to a puppeteer ElementHandle before handing it to user code. - * Puppeteer handles expose `type()` but no `fill()`; the semantics mirror the - * selector-based `tab.fill()`: focus, clear any existing value, then type. + * A named per-op guard: runs `fn` inside the active run's fail-fast deadline and + * in-flight tracking (the same wrapper `tab.click(selector)` uses), so a stalled + * handle action rejects with a named error before the cell budget instead of + * hanging on puppeteer's protocol timeout. */ -export function toActionableHandle(handle: ElementHandle): ActionableHandle { +export type HandleOpGuard = (label: string, fn: (signal: AbortSignal) => Promise) => Promise; + +/** + * Interactive `ElementHandle` methods that dispatch input or navigation and can + * stall on a busy page. When {@link toActionableHandle} is given a guard, each is + * routed through the per-op fail-fast wrapper; without it the inherited puppeteer + * method runs outside the op map and a stall consumes the whole cell (issue #9535). + */ +const GUARDED_HANDLE_METHODS = [ + "click", + "type", + "hover", + "tap", + "focus", + "press", + "select", + "uploadFile", + "scrollIntoView", +] as const satisfies readonly (keyof ElementHandle)[]; + +/** + * Attach `fill()` to a puppeteer ElementHandle before handing it to user code and, + * when a `guard` is supplied, route every interactive method ({@link GUARDED_HANDLE_METHODS}) + * through the same fail-fast per-op wrapper as the selector-based helpers — so + * `(await tab.id(n)).click()` fails fast with `handle.click() timed out after …ms` + * instead of stalling until the whole browser cell expires. Puppeteer handles expose + * `type()` but no `fill()`; the `fill()` semantics mirror the selector-based + * `tab.fill()`: focus, clear any existing value, then type. + */ +export function toActionableHandle(handle: ElementHandle, guard?: HandleOpGuard): ActionableHandle { const enriched = handle as ActionableHandle; - enriched.fill = value => fillViaHandle(enriched, value); + if (!guard) { + enriched.fill = value => fillViaHandle(enriched, value); + return enriched; + } + // Capture the raw typer before shadowing so the guarded fill runs as a single op + // rather than re-entering the guard through the now-wrapped `type`. + const rawType = enriched.type.bind(enriched); + const methods = enriched as unknown as Record Promise>; + for (const method of GUARDED_HANDLE_METHODS) { + const raw = methods[method]; + if (typeof raw !== "function") continue; + const bound = raw.bind(enriched); + methods[method] = (...args) => guard(`handle.${method}()`, signal => untilAborted(signal, () => bound(...args))); + } + enriched.fill = value => + guard("handle.fill()", signal => + fillViaHandle(enriched, value, signal, text => rawType(text, { delay: 0 })), + ); return enriched; } /** Focus, clear any existing value, then retype — shared by `tab.fill(aria-ref)` and enriched handles. */ -async function fillViaHandle(handle: ElementHandle, value: string, signal?: AbortSignal): Promise { +async function fillViaHandle( + handle: ElementHandle, + value: string, + signal?: AbortSignal, + type: (text: string) => Promise = text => handle.type(text, { delay: 0 }), +): Promise { await untilAborted(signal, () => handle.evaluate(el => { const node = el as unknown as { value?: string; focus?: () => void }; @@ -339,7 +391,7 @@ async function fillViaHandle(handle: ElementHandle, value: string, signal?: Abor if ("value" in node) node.value = ""; }), ); - await untilAborted(signal, () => handle.type(value, { delay: 0 })); + await untilAborted(signal, () => type(value)); } /** @@ -1352,6 +1404,10 @@ export class WorkerCore { fn: (sig: AbortSignal) => Promise, selectorOpts?: { selector?: string; zeroMatchAfterMs?: number }, ): Promise => markHandled(this.#runOp(active, label, signal, perOpMs, fn, selectorOpts)); + // Hand user-facing handles the fail-fast per-op guard so their interactive + // methods (`.click()`, `.type()`, …) can't outrun the cell budget (issue #9535). + const enrich = (handle: ElementHandle): ActionableHandle => + toActionableHandle(handle, (label, fn) => op(label, actionOpMs, fn)); return { name, page, @@ -1506,7 +1562,7 @@ export class WorkerCore { return op( `tab.waitFor(${JSON.stringify(selector)})`, w, - async sig => toActionableHandle(await this.#resolveActionHandle(selector, w, sig)), + async sig => enrich(await this.#resolveActionHandle(selector, w, sig)), { selector, zeroMatchAfterMs: opts?.timeout === undefined ? ZERO_MATCH_FAIL_FAST_MS : undefined }, ); }, @@ -1516,8 +1572,7 @@ export class WorkerCore { `tab.waitForSelector(${JSON.stringify(selector)})`, w, async sig => { - if (parseAriaRefSelector(selector) !== null) - return toActionableHandle(await this.#resolveAriaRef(selector)); + if (parseAriaRefSelector(selector) !== null) return enrich(await this.#resolveAriaRef(selector)); const handle = (await untilAborted(sig, () => page.waitForSelector(normalizeSelector(selector), { timeout: w, @@ -1526,7 +1581,7 @@ export class WorkerCore { signal: sig, }), )) as ElementHandle | null; - return handle ? toActionableHandle(handle) : null; + return handle ? enrich(handle) : null; }, { selector, @@ -1597,8 +1652,8 @@ export class WorkerCore { const w = waitMs(opts?.timeout); return op("tab.waitForResponse()", w, sig => this.#waitForResponse(pattern, w, sig)); }, - id: async id => toActionableHandle(await this.#resolveCachedHandle(id)), - ref: async id => toActionableHandle(await this.#resolveAriaRef(id)), + id: async id => enrich(await this.#resolveCachedHandle(id)), + ref: async id => enrich(await this.#resolveAriaRef(id)), }; } diff --git a/packages/coding-agent/test/tools/browser-run-output.test.ts b/packages/coding-agent/test/tools/browser-run-output.test.ts index b91c6268de23..e508fc94cebb 100644 --- a/packages/coding-agent/test/tools/browser-run-output.test.ts +++ b/packages/coding-agent/test/tools/browser-run-output.test.ts @@ -1,6 +1,10 @@ import { describe, expect, it } from "bun:test"; import { RunOutput } from "@oh-my-pi/pi-coding-agent/tools/browser/run-output"; -import { formatSelectorMatchHint, toActionableHandle } from "@oh-my-pi/pi-coding-agent/tools/browser/tab-worker"; +import { + formatSelectorMatchHint, + type HandleOpGuard, + toActionableHandle, +} from "@oh-my-pi/pi-coding-agent/tools/browser/tab-worker"; import type { ElementHandle } from "puppeteer-core"; // Regression coverage for the invisible-output failure mode: `display("string")`, @@ -84,6 +88,86 @@ describe("browser handle enrichment — fill()", () => { }); }); +// Regression (#9535): handles from tab.id()/tab.ref()/tab.waitFor() used to return raw +// puppeteer methods that ran outside the per-op guard, so a stalled `(await tab.id(n)).click()` +// consumed the whole 30s cell instead of failing fast with a named per-op error. A guard now +// routes each interactive method through the same fail-fast wrapper as tab.click(selector). +describe("browser handle enrichment — guarded actions", () => { + // Minimal stand-in for #runOp: names the op, installs a per-op deadline, and rewrites an + // abort into the same `