From 90cfa5728ee5bebdb42edd95f3d6779cb58585c0 Mon Sep 17 00:00:00 2001 From: Rui Liang Date: Wed, 4 Nov 2026 14:58:34 +0800 Subject: [PATCH 1/4] fix(ai): refresh upstream text and image model catalogs --- packages/ai/CHANGELOG.md | 4 + packages/ai/src/image-models.generated.ts | 18 +- .../providers/cloudflare-ai-gateway.models.ts | 2 +- packages/ai/src/providers/mistral.models.ts | 23 +- .../ai/src/providers/opencode-go.models.ts | 2 +- packages/ai/src/providers/opencode.models.ts | 36 ++ .../ai/src/providers/openrouter.models.ts | 380 +++++++++--------- .../src/providers/vercel-ai-gateway.models.ts | 149 +++---- 8 files changed, 318 insertions(+), 296 deletions(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 47ddcc4..9cac129 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Changed + +- Refreshed generated provider and image model catalogs from upstream during MCP release preparation. + ## [1.2.0] - 2026-10-29 ## [1.1.2] - 2026-10-27 diff --git a/packages/ai/src/image-models.generated.ts b/packages/ai/src/image-models.generated.ts index 31b49fe..9046645 100644 --- a/packages/ai/src/image-models.generated.ts +++ b/packages/ai/src/image-models.generated.ts @@ -905,9 +905,9 @@ export const IMAGE_MODELS = { cacheWrite: 0, }, } satisfies ImagesModel<"openrouter-images">, - "tencent/hy-image-v3.5-preview": { - id: "tencent/hy-image-v3.5-preview", - name: "Tencent: Hy Image 3.5 Preview", + "sourceful/riverflow-v2.6-pro": { + id: "sourceful/riverflow-v2.6-pro", + name: "Sourceful: Riverflow V2.6 Pro", api: "openrouter-images", provider: "openrouter", baseUrl: "https://openrouter.ai/api/v1", @@ -920,9 +920,9 @@ export const IMAGE_MODELS = { cacheWrite: 0, }, } satisfies ImagesModel<"openrouter-images">, - "x-ai/grok-imagine-image-2.0": { - id: "x-ai/grok-imagine-image-2.0", - name: "xAI: Grok Imagine Image 2.0", + "tencent/hy-image-v3.5-preview": { + id: "tencent/hy-image-v3.5-preview", + name: "Tencent: Hy Image 3.5 Preview", api: "openrouter-images", provider: "openrouter", baseUrl: "https://openrouter.ai/api/v1", @@ -935,9 +935,9 @@ export const IMAGE_MODELS = { cacheWrite: 0, }, } satisfies ImagesModel<"openrouter-images">, - "x-ai/grok-imagine-image-quality": { - id: "x-ai/grok-imagine-image-quality", - name: "SpaceXAI: Grok Imagine Image Quality", + "x-ai/grok-imagine-image-2.0": { + id: "x-ai/grok-imagine-image-2.0", + name: "xAI: Grok Imagine Image 2.0", api: "openrouter-images", provider: "openrouter", baseUrl: "https://openrouter.ai/api/v1", diff --git a/packages/ai/src/providers/cloudflare-ai-gateway.models.ts b/packages/ai/src/providers/cloudflare-ai-gateway.models.ts index 9f63069..8114a04 100644 --- a/packages/ai/src/providers/cloudflare-ai-gateway.models.ts +++ b/packages/ai/src/providers/cloudflare-ai-gateway.models.ts @@ -258,7 +258,7 @@ export const CLOUDFLARE_AI_GATEWAY_MODELS = { cost: { input: 2, output: 10, - cacheRead: 0.2, + cacheRead: 0.1, cacheWrite: 2.5, }, contextWindow: 1000000, diff --git a/packages/ai/src/providers/mistral.models.ts b/packages/ai/src/providers/mistral.models.ts index c45fc60..a7c4c14 100644 --- a/packages/ai/src/providers/mistral.models.ts +++ b/packages/ai/src/providers/mistral.models.ts @@ -285,9 +285,26 @@ export const MISTRAL_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 1.36, - output: 4.18, - cacheRead: 0.14, + input: 0.7, + output: 2.1, + cacheRead: 0.07, + cacheWrite: 0, + }, + contextWindow: 1048576, + maxTokens: 262144, + } satisfies Model<"mistral-conversations">, + "mistral-large-4-0-8": { + id: "mistral-large-4-0-8", + name: "Mistral Large 4.0.8", + api: "mistral-conversations", + provider: "mistral", + baseUrl: "https://api.mistral.ai", + reasoning: true, + input: ["text", "image"], + cost: { + input: 0.7, + output: 2.1, + cacheRead: 0.07, cacheWrite: 0, }, contextWindow: 1048576, diff --git a/packages/ai/src/providers/opencode-go.models.ts b/packages/ai/src/providers/opencode-go.models.ts index 48082d0..c637a07 100644 --- a/packages/ai/src/providers/opencode-go.models.ts +++ b/packages/ai/src/providers/opencode-go.models.ts @@ -41,7 +41,7 @@ export const OPENCODE_GO_MODELS = { } satisfies Model<"anthropic-messages">, "deepseek-v4-pro": { id: "deepseek-v4-pro", - name: "DeepSeek V4 Pro (New)", + name: "DeepSeek V4 Pro", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", diff --git a/packages/ai/src/providers/opencode.models.ts b/packages/ai/src/providers/opencode.models.ts index 94349a0..41b5371 100644 --- a/packages/ai/src/providers/opencode.models.ts +++ b/packages/ai/src/providers/opencode.models.ts @@ -294,6 +294,24 @@ export const OPENCODE_MODELS = { contextWindow: 1000000, maxTokens: 128000, } satisfies Model<"anthropic-messages">, + "crouton-alpha-free": { + id: "crouton-alpha-free", + name: "Crouton Alpha Free", + api: "openai-completions", + provider: "opencode", + baseUrl: "https://opencode.ai/zen/v1", + compat: {"supportsStore":false,"supportsDeveloperRole":false,"maxTokensField":"max_tokens"}, + reasoning: true, + input: ["text", "image"], + cost: { + input: 0, + output: 0, + cacheRead: 0, + cacheWrite: 0, + }, + contextWindow: 1048576, + maxTokens: 270000, + } satisfies Model<"openai-completions">, "deepseek-v4-pro": { id: "deepseek-v4-pro", name: "DeepSeek V4 Pro", @@ -1349,6 +1367,24 @@ export const OPENCODE_MODELS = { contextWindow: 1048576, maxTokens: 131072, } satisfies Model<"openai-completions">, + "pulse-alpha-free": { + id: "pulse-alpha-free", + name: "Pulse Alpha Free", + api: "openai-completions", + provider: "opencode", + baseUrl: "https://opencode.ai/zen/v1", + compat: {"supportsStore":false,"supportsDeveloperRole":false,"maxTokensField":"max_tokens"}, + reasoning: true, + input: ["text", "image"], + cost: { + input: 0, + output: 0, + cacheRead: 0, + cacheWrite: 0, + }, + contextWindow: 1048576, + maxTokens: 131072, + } satisfies Model<"openai-completions">, "qwen3.5-plus": { id: "qwen3.5-plus", name: "Qwen3.5 Plus", diff --git a/packages/ai/src/providers/openrouter.models.ts b/packages/ai/src/providers/openrouter.models.ts index 1c5778c..078ca61 100644 --- a/packages/ai/src/providers/openrouter.models.ts +++ b/packages/ai/src/providers/openrouter.models.ts @@ -1034,13 +1034,13 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text"], cost: { - input: 0.28, - output: 0.42, - cacheRead: 0.028, + input: 0.26, + output: 0.38, + cacheRead: 0.13, cacheWrite: 0, }, - contextWindow: 131072, - maxTokens: 65536, + contextWindow: 163840, + maxTokens: 147456, } satisfies Model<"openai-completions">, "deepseek/deepseek-v3.2-exp": { id: "deepseek/deepseek-v3.2-exp", @@ -1090,9 +1090,9 @@ export const OPENROUTER_MODELS = { thinkingLevelMap: {"minimal":null,"low":null,"medium":null,"high":"high","max":null,"xhigh":"xhigh"}, input: ["text"], cost: { - input: 0.119, - output: 0.238, - cacheRead: 0.0238, + input: 0.059, + output: 0.3, + cacheRead: 0.035, cacheWrite: 0, }, contextWindow: 1048576, @@ -1128,13 +1128,13 @@ export const OPENROUTER_MODELS = { thinkingLevelMap: {"minimal":null,"low":null,"medium":null,"high":"high","max":null,"xhigh":"xhigh"}, input: ["text"], cost: { - input: 0.894012, - output: 1.788024, - cacheRead: 0.074501, + input: 1.6, + output: 3.2, + cacheRead: 0.135, cacheWrite: 0, }, - contextWindow: 1024000, - maxTokens: 384000, + contextWindow: 1048576, + maxTokens: 393216, } satisfies Model<"openai-completions">, "deepseek/deepseek-v4-pro-0813": { id: "deepseek/deepseek-v4-pro-0813", @@ -1147,13 +1147,13 @@ export const OPENROUTER_MODELS = { thinkingLevelMap: {"minimal":null,"low":null,"medium":null,"high":"high","max":null,"xhigh":"xhigh"}, input: ["text"], cost: { - input: 0.66, - output: 1.98, - cacheRead: 0.022, + input: 0.115, + output: 4.6, + cacheRead: 0.11, cacheWrite: 0, }, contextWindow: 1048576, - maxTokens: 393216, + maxTokens: 943718, } satisfies Model<"openai-completions">, "deepseek/deepseek-v4.1-flash": { id: "deepseek/deepseek-v4.1-flash", @@ -1168,7 +1168,7 @@ export const OPENROUTER_MODELS = { cost: { input: 0.045, output: 0.5, - cacheRead: 0.006, + cacheRead: 0.018, cacheWrite: 0, }, contextWindow: 1048576, @@ -1185,9 +1185,9 @@ export const OPENROUTER_MODELS = { thinkingLevelMap: {"minimal":null,"low":null,"medium":null,"high":"high","max":null,"xhigh":"xhigh"}, input: ["text", "image"], cost: { - input: 0.15, - output: 0.6, - cacheRead: 0.003, + input: 0.3, + output: 1.2, + cacheRead: 0.006, cacheWrite: 0, }, contextWindow: 1048576, @@ -1780,13 +1780,13 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.09, - output: 0.3, - cacheRead: 0.05, + input: 0.094, + output: 0.281, + cacheRead: 0.047, cacheWrite: 0, }, contextWindow: 262144, - maxTokens: 235929, + maxTokens: 32768, } satisfies Model<"openai-completions">, "google/gemma-4-26b-a4b-it:free": { id: "google/gemma-4-26b-a4b-it:free", @@ -1853,7 +1853,7 @@ export const OPENROUTER_MODELS = { input: ["text"], cost: { input: 0.06, - output: 0.15, + output: 0.25, cacheRead: 0.015, cacheWrite: 0, }, @@ -2042,24 +2042,6 @@ export const OPENROUTER_MODELS = { contextWindow: 1048756, maxTokens: 262144, } satisfies Model<"openai-completions">, - "meta-llama/llama-3.1-70b-instruct": { - id: "meta-llama/llama-3.1-70b-instruct", - name: "Meta: Llama 3.1 70B Instruct", - api: "openai-completions", - provider: "openrouter", - baseUrl: "https://openrouter.ai/api/v1", - compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, - reasoning: false, - input: ["text"], - cost: { - input: 0.4, - output: 0.4, - cacheRead: 0, - cacheWrite: 0, - }, - contextWindow: 131072, - maxTokens: 16384, - } satisfies Model<"openai-completions">, "meta-llama/llama-3.1-8b-instruct": { id: "meta-llama/llama-3.1-8b-instruct", name: "Meta: Llama 3.1 8B Instruct", @@ -2256,7 +2238,7 @@ export const OPENROUTER_MODELS = { cacheWrite: 0, }, contextWindow: 1048576, - maxTokens: 131072, + maxTokens: 943718, } satisfies Model<"openai-completions">, "meta/muse-wonder": { id: "meta/muse-wonder", @@ -2340,13 +2322,13 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text"], cost: { - input: 0.3, - output: 1.2, + input: 0.27, + output: 0.95, cacheRead: 0.03, cacheWrite: 0, }, - contextWindow: 204800, - maxTokens: 131072, + contextWindow: 198000, + maxTokens: 32768, } satisfies Model<"openai-completions">, "minimax/minimax-m2.7": { id: "minimax/minimax-m2.7", @@ -2556,9 +2538,9 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 1.36, - output: 4.18, - cacheRead: 0.14, + input: 0.7, + output: 2.1, + cacheRead: 0.07, cacheWrite: 0, }, contextWindow: 1048576, @@ -2862,8 +2844,8 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.56, - output: 3.1, + input: 0.6, + output: 3.5, cacheRead: 0.15, cacheWrite: 0, }, @@ -2880,9 +2862,9 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.239, - output: 10.8, - cacheRead: 0.21, + input: 0.2, + output: 16, + cacheRead: 0.19, cacheWrite: 0, }, contextWindow: 1048576, @@ -3083,8 +3065,8 @@ export const OPENROUTER_MODELS = { cacheRead: 0.02, cacheWrite: 0, }, - contextWindow: 262144, - maxTokens: 235929, + contextWindow: 1048576, + maxTokens: 943718, } satisfies Model<"openai-completions">, "nvidia/nemotron-3.5-super-vl:free": { id: "nvidia/nemotron-3.5-super-vl:free", @@ -4711,13 +4693,13 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text"], cost: { - input: 0.018, - output: 0.09, - cacheRead: 0.009, + input: 0.03, + output: 0.13, + cacheRead: 0.03, cacheWrite: 0, }, contextWindow: 131072, - maxTokens: 32768, + maxTokens: 117964, } satisfies Model<"openai-completions">, "openai/gpt-oss-20b:batch": { id: "openai/gpt-oss-20b:batch", @@ -4879,7 +4861,7 @@ export const OPENROUTER_MODELS = { cacheWrite: 0, }, contextWindow: 2000000, - maxTokens: 4096, + maxTokens: 65536, } satisfies Model<"openai-completions">, "openrouter/free": { id: "openrouter/free", @@ -4945,9 +4927,9 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.25, - output: 1, - cacheRead: 0.03, + input: 0.05, + output: 0.5, + cacheRead: 0.003, cacheWrite: 0, }, contextWindow: 1048576, @@ -4971,78 +4953,6 @@ export const OPENROUTER_MODELS = { contextWindow: 36864, maxTokens: 8192, } satisfies Model<"openai-completions">, - "poolside/laguna-s-2.1": { - id: "poolside/laguna-s-2.1", - name: "Poolside: Laguna S 2.1", - api: "openai-completions", - provider: "openrouter", - baseUrl: "https://openrouter.ai/api/v1", - compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, - reasoning: true, - input: ["text"], - cost: { - input: 0.09, - output: 0.18, - cacheRead: 0.009, - cacheWrite: 0, - }, - contextWindow: 1048576, - maxTokens: 131072, - } satisfies Model<"openai-completions">, - "poolside/laguna-s-2.1:free": { - id: "poolside/laguna-s-2.1:free", - name: "Poolside: Laguna S 2.1 (free)", - api: "openai-completions", - provider: "openrouter", - baseUrl: "https://openrouter.ai/api/v1", - compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, - reasoning: true, - input: ["text"], - cost: { - input: 0, - output: 0, - cacheRead: 0, - cacheWrite: 0, - }, - contextWindow: 262144, - maxTokens: 32768, - } satisfies Model<"openai-completions">, - "poolside/laguna-xs-2.1": { - id: "poolside/laguna-xs-2.1", - name: "Poolside: Laguna XS 2.1", - api: "openai-completions", - provider: "openrouter", - baseUrl: "https://openrouter.ai/api/v1", - compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, - reasoning: true, - input: ["text"], - cost: { - input: 0.06, - output: 0.12, - cacheRead: 0.03, - cacheWrite: 0, - }, - contextWindow: 262144, - maxTokens: 32768, - } satisfies Model<"openai-completions">, - "poolside/laguna-xs-2.1:free": { - id: "poolside/laguna-xs-2.1:free", - name: "Poolside: Laguna XS 2.1 (free)", - api: "openai-completions", - provider: "openrouter", - baseUrl: "https://openrouter.ai/api/v1", - compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, - reasoning: true, - input: ["text"], - cost: { - input: 0, - output: 0, - cacheRead: 0, - cacheWrite: 0, - }, - contextWindow: 262144, - maxTokens: 32768, - } satisfies Model<"openai-completions">, "prism-ml/ternary-bonsai-2-27b": { id: "prism-ml/ternary-bonsai-2-27b", name: "PrismML: Ternary Bonsai 2 27B", @@ -5161,13 +5071,13 @@ export const OPENROUTER_MODELS = { reasoning: false, input: ["text"], cost: { - input: 0.09, - output: 0.55, - cacheRead: 0, + input: 0.14, + output: 0.8, + cacheRead: 0.05, cacheWrite: 0, }, - contextWindow: 262144, - maxTokens: 16384, + contextWindow: 131072, + maxTokens: 117964, } satisfies Model<"openai-completions">, "qwen/qwen3-235b-a22b-thinking-2507": { id: "qwen/qwen3-235b-a22b-thinking-2507", @@ -5269,8 +5179,8 @@ export const OPENROUTER_MODELS = { reasoning: false, input: ["text"], cost: { - input: 0.07, - output: 0.28, + input: 0.15, + output: 0.6, cacheRead: 0, cacheWrite: 0, }, @@ -5323,13 +5233,13 @@ export const OPENROUTER_MODELS = { reasoning: false, input: ["text"], cost: { - input: 0.09, + input: 0.1, output: 1.1, - cacheRead: 0, + cacheRead: 0.07, cacheWrite: 0, }, contextWindow: 262144, - maxTokens: 16384, + maxTokens: 235929, } satisfies Model<"openai-completions">, "qwen/qwen3-vl-235b-a22b-instruct": { id: "qwen/qwen3-vl-235b-a22b-instruct", @@ -5706,8 +5616,8 @@ export const OPENROUTER_MODELS = { cacheRead: 0.25, cacheWrite: 0, }, - contextWindow: 1010000, - maxTokens: 909000, + contextWindow: 1000000, + maxTokens: 131072, } satisfies Model<"openai-completions">, "qwen/qwen3.8-27b": { id: "qwen/qwen3.8-27b", @@ -5719,13 +5629,13 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.039, - output: 1.25, - cacheRead: 0.0039, + input: 0.15, + output: 1.875, + cacheRead: 0.0375, cacheWrite: 0, }, contextWindow: 262144, - maxTokens: 65536, + maxTokens: 235929, } satisfies Model<"openai-completions">, "qwen/qwen3.8-flash": { id: "qwen/qwen3.8-flash", @@ -5943,6 +5853,24 @@ export const OPENROUTER_MODELS = { contextWindow: 262144, maxTokens: 65536, } satisfies Model<"openai-completions">, + "stealth/crouton-alpha": { + id: "stealth/crouton-alpha", + name: "Crouton Alpha", + api: "openai-completions", + provider: "openrouter", + baseUrl: "https://openrouter.ai/api/v1", + compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, + reasoning: true, + input: ["text", "image"], + cost: { + input: 0, + output: 0, + cacheRead: 0, + cacheWrite: 0, + }, + contextWindow: 1048576, + maxTokens: 943718, + } satisfies Model<"openai-completions">, "stepfun/step-3.5-flash": { id: "stepfun/step-3.5-flash", name: "StepFun: Step 3.5 Flash", @@ -6033,6 +5961,24 @@ export const OPENROUTER_MODELS = { contextWindow: 262144, maxTokens: 235929, } satisfies Model<"openai-completions">, + "tencent/hy4": { + id: "tencent/hy4", + name: "Tencent: Hy4", + api: "openai-completions", + provider: "openrouter", + baseUrl: "https://openrouter.ai/api/v1", + compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, + reasoning: true, + input: ["text", "image"], + cost: { + input: 0.417, + output: 1.2505, + cacheRead: 0.021, + cacheWrite: 0, + }, + contextWindow: 1048576, + maxTokens: 65536, + } satisfies Model<"openai-completions">, "tencent/hy4-preview": { id: "tencent/hy4-preview", name: "Tencent: Hy4 preview", @@ -6139,7 +6085,7 @@ export const OPENROUTER_MODELS = { cacheWrite: 0, }, contextWindow: 1000000, - maxTokens: 64000, + maxTokens: 65536, } satisfies Model<"openai-completions">, "unbiased/pareto-26.10": { id: "unbiased/pareto-26.10", @@ -6195,24 +6141,6 @@ export const OPENROUTER_MODELS = { contextWindow: 524288, maxTokens: 131072, } satisfies Model<"openai-completions">, - "upstage/solar-pro-3": { - id: "upstage/solar-pro-3", - name: "Upstage: Solar Pro 3", - api: "openai-completions", - provider: "openrouter", - baseUrl: "https://openrouter.ai/api/v1", - compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, - reasoning: true, - input: ["text"], - cost: { - input: 0.15, - output: 0.6, - cacheRead: 0.015, - cacheWrite: 0, - }, - contextWindow: 131072, - maxTokens: 117964, - } satisfies Model<"openai-completions">, "upstage/solar-pro4": { id: "upstage/solar-pro4", name: "Upstage: Solar Pro 4", @@ -6321,6 +6249,24 @@ export const OPENROUTER_MODELS = { contextWindow: 500000, maxTokens: 450000, } satisfies Model<"openai-completions">, + "x-ai/grok-4.6:batch": { + id: "x-ai/grok-4.6:batch", + name: "SpaceXAI: Grok 4.6 (batch)", + api: "openai-completions", + provider: "openrouter", + baseUrl: "https://openrouter.ai/api/v1", + compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, + reasoning: true, + input: ["text", "image"], + cost: { + input: 1.6, + output: 4.8, + cacheRead: 0.4, + cacheWrite: 0, + }, + contextWindow: 500000, + maxTokens: 450000, + } satisfies Model<"openai-completions">, "x-ai/grok-4.7": { id: "x-ai/grok-4.7", name: "SpaceXAI: Grok 4.7", @@ -6339,6 +6285,24 @@ export const OPENROUTER_MODELS = { contextWindow: 500000, maxTokens: 450000, } satisfies Model<"openai-completions">, + "x-ai/grok-4.7:batch": { + id: "x-ai/grok-4.7:batch", + name: "SpaceXAI: Grok 4.7 (batch)", + api: "openai-completions", + provider: "openrouter", + baseUrl: "https://openrouter.ai/api/v1", + compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, + reasoning: true, + input: ["text", "image"], + cost: { + input: 1.6, + output: 4.8, + cacheRead: 0.4, + cacheWrite: 0, + }, + contextWindow: 500000, + maxTokens: 450000, + } satisfies Model<"openai-completions">, "x-ai/grok-build-0.1": { id: "x-ai/grok-build-0.1", name: "SpaceXAI: Grok Build 0.1", @@ -6549,7 +6513,7 @@ export const OPENROUTER_MODELS = { cost: { input: 0.3, output: 0.9, - cacheRead: 0.05, + cacheRead: 0.055, cacheWrite: 0, }, contextWindow: 131072, @@ -6565,12 +6529,12 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text"], cost: { - input: 0.54, - output: 1.98, - cacheRead: 0.099, + input: 0.6, + output: 2.2, + cacheRead: 0.11, cacheWrite: 0, }, - contextWindow: 204800, + contextWindow: 202752, maxTokens: 131072, } satisfies Model<"openai-completions">, "z-ai/glm-4.7-flash": { @@ -6657,7 +6621,7 @@ export const OPENROUTER_MODELS = { input: ["text"], cost: { input: 0.006, - output: 7, + output: 6.8, cacheRead: 0.005, cacheWrite: 0, }, @@ -6674,9 +6638,9 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text"], cost: { - input: 0.0699, - output: 1.4, - cacheRead: 0.0689, + input: 0.08, + output: 3.6, + cacheRead: 0.076, cacheWrite: 0, }, contextWindow: 1048576, @@ -6692,9 +6656,9 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.0457, - output: 0.0742, - cacheRead: 0.03, + input: 0.0269, + output: 0.0996, + cacheRead: 0.0269, cacheWrite: 0, }, contextWindow: 1048576, @@ -6730,7 +6694,25 @@ export const OPENROUTER_MODELS = { cost: { input: 0.37, output: 1.25, - cacheRead: 0.09, + cacheRead: 0.075, + cacheWrite: 0, + }, + contextWindow: 1048576, + maxTokens: 131072, + } satisfies Model<"openai-completions">, + "z-ai/glm-5.3-flashx-legal": { + id: "z-ai/glm-5.3-flashx-legal", + name: "Z.ai: GLM 5.3 FlashX Legal", + api: "openai-completions", + provider: "openrouter", + baseUrl: "https://openrouter.ai/api/v1", + compat: {"supportsDeveloperRole":false,"thinkingFormat":"openrouter"}, + reasoning: true, + input: ["text", "image"], + cost: { + input: 0.37, + output: 1.25, + cacheRead: 0.075, cacheWrite: 0, }, contextWindow: 1048576, @@ -6872,9 +6854,9 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.0309, - output: 1.8, - cacheRead: 0.0306, + input: 0.0333, + output: 0.475, + cacheRead: 0.00475, cacheWrite: 0, }, contextWindow: 1048576, @@ -6909,9 +6891,9 @@ export const OPENROUTER_MODELS = { thinkingLevelMap: {"minimal":null,"low":null,"medium":null,"high":"high","max":null,"xhigh":"xhigh"}, input: ["text"], cost: { - input: 0.0509, - output: 0.1415, - cacheRead: 0.028, + input: 0.059, + output: 0.3, + cacheRead: 0.035, cacheWrite: 0, }, contextWindow: 1048576, @@ -6963,9 +6945,9 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.1824, - output: 9.3388, - cacheRead: 0.18, + input: 0.19, + output: 8.94, + cacheRead: 0.19, cacheWrite: 0, }, contextWindow: 1048576, @@ -7107,9 +7089,9 @@ export const OPENROUTER_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.0457, - output: 0.0742, - cacheRead: 0.03, + input: 0.0269, + output: 0.0996, + cacheRead: 0.0269, cacheWrite: 0, }, contextWindow: 1048576, diff --git a/packages/ai/src/providers/vercel-ai-gateway.models.ts b/packages/ai/src/providers/vercel-ai-gateway.models.ts index 1100e34..8141ea2 100644 --- a/packages/ai/src/providers/vercel-ai-gateway.models.ts +++ b/packages/ai/src/providers/vercel-ai-gateway.models.ts @@ -1058,23 +1058,6 @@ export const VERCEL_AI_GATEWAY_MODELS = { contextWindow: 1000000, maxTokens: 128000, } satisfies Model<"anthropic-messages">, - "arcee-ai/trinity-large-thinking": { - id: "arcee-ai/trinity-large-thinking", - name: "Trinity Large Thinking", - api: "anthropic-messages", - provider: "vercel-ai-gateway", - baseUrl: "https://ai-gateway.vercel.sh", - reasoning: true, - input: ["text"], - cost: { - input: 0.25, - output: 0.8, - cacheRead: 0.06, - cacheWrite: 0, - }, - contextWindow: 262100, - maxTokens: 80000, - } satisfies Model<"anthropic-messages">, "bytedance/seed-1.6": { id: "bytedance/seed-1.6", name: "Seed 1.6", @@ -1322,9 +1305,9 @@ export const VERCEL_AI_GATEWAY_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.075, - output: 0.3, - cacheRead: 0.0015, + input: 0.3, + output: 1.2, + cacheRead: 0.007, cacheWrite: 0, }, contextWindow: 1048576, @@ -1339,13 +1322,13 @@ export const VERCEL_AI_GATEWAY_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 0.075, - output: 0.3, - cacheRead: 0.0015, + input: 0.3, + output: 1.2, + cacheRead: 0.007, cacheWrite: 0, }, contextWindow: 1048576, - maxTokens: 1048576, + maxTokens: 262144, } satisfies Model<"anthropic-messages">, "deepseek/deepseek-v4.1-flash-1017-fast": { id: "deepseek/deepseek-v4.1-flash-1017-fast", @@ -1959,6 +1942,23 @@ export const VERCEL_AI_GATEWAY_MODELS = { contextWindow: 262144, maxTokens: 32768, } satisfies Model<"anthropic-messages">, + "inclusionai/ling-3.1-flash-1019": { + id: "inclusionai/ling-3.1-flash-1019", + name: "Ling 3.1 Flash 1019", + api: "anthropic-messages", + provider: "vercel-ai-gateway", + baseUrl: "https://ai-gateway.vercel.sh", + reasoning: true, + input: ["text"], + cost: { + input: 0.3, + output: 0.9, + cacheRead: 0.06, + cacheWrite: 0, + }, + contextWindow: 1000000, + maxTokens: 262144, + } satisfies Model<"anthropic-messages">, "interfaze/interfaze-beta": { id: "interfaze/interfaze-beta", name: "Interfaze Beta", @@ -1993,9 +1993,9 @@ export const VERCEL_AI_GATEWAY_MODELS = { contextWindow: 128000, maxTokens: 8200, } satisfies Model<"anthropic-messages">, - "meituan/longcat-2.5-preview": { - id: "meituan/longcat-2.5-preview", - name: "LongCat 2.5 Preview", + "meituan/longcat-2.5": { + id: "meituan/longcat-2.5", + name: "LongCat 2.5", api: "anthropic-messages", provider: "vercel-ai-gateway", baseUrl: "https://ai-gateway.vercel.sh", @@ -2478,12 +2478,12 @@ export const VERCEL_AI_GATEWAY_MODELS = { reasoning: true, input: ["text", "image"], cost: { - input: 1.36, - output: 4.18, - cacheRead: 0.14, + input: 0.7, + output: 2.1, + cacheRead: 0.07, cacheWrite: 0, }, - contextWindow: 524288, + contextWindow: 1048576, maxTokens: 262144, } satisfies Model<"anthropic-messages">, "mistral/mistral-medium-3.5": { @@ -4318,23 +4318,6 @@ export const VERCEL_AI_GATEWAY_MODELS = { contextWindow: 1000000, maxTokens: 131072, } satisfies Model<"anthropic-messages">, - "poolside/laguna-s-2.1-free": { - id: "poolside/laguna-s-2.1-free", - name: "Laguna S 2.1 Free", - api: "anthropic-messages", - provider: "vercel-ai-gateway", - baseUrl: "https://ai-gateway.vercel.sh", - reasoning: true, - input: ["text"], - cost: { - input: 0, - output: 0, - cacheRead: 0, - cacheWrite: 0, - }, - contextWindow: 256000, - maxTokens: 32768, - } satisfies Model<"anthropic-messages">, "quiverai/arrow-2": { id: "quiverai/arrow-2", name: "Arrow 2", @@ -4796,7 +4779,7 @@ export const VERCEL_AI_GATEWAY_MODELS = { } satisfies Model<"anthropic-messages">, "tencent/hy3": { id: "tencent/hy3", - name: "Hy3", + name: "Tencent Hy3", api: "anthropic-messages", provider: "vercel-ai-gateway", baseUrl: "https://ai-gateway.vercel.sh", @@ -4811,6 +4794,23 @@ export const VERCEL_AI_GATEWAY_MODELS = { contextWindow: 262144, maxTokens: 262144, } satisfies Model<"anthropic-messages">, + "tencent/hy4": { + id: "tencent/hy4", + name: "Tencent Hy4", + api: "anthropic-messages", + provider: "vercel-ai-gateway", + baseUrl: "https://ai-gateway.vercel.sh", + reasoning: true, + input: ["text", "image"], + cost: { + input: 0.417, + output: 1.2505, + cacheRead: 0.021, + cacheWrite: 0, + }, + contextWindow: 1024000, + maxTokens: 64000, + } satisfies Model<"anthropic-messages">, "tencent/hy4-preview": { id: "tencent/hy4-preview", name: "Tencent Hy4 Preview", @@ -4862,40 +4862,6 @@ export const VERCEL_AI_GATEWAY_MODELS = { contextWindow: 1000000, maxTokens: 1000000, } satisfies Model<"anthropic-messages">, - "xiaomi/mimo-v2.5": { - id: "xiaomi/mimo-v2.5", - name: "MiMo M2.5", - api: "anthropic-messages", - provider: "vercel-ai-gateway", - baseUrl: "https://ai-gateway.vercel.sh", - reasoning: true, - input: ["text", "image"], - cost: { - input: 0.119, - output: 0.238, - cacheRead: 0.0025, - cacheWrite: 0, - }, - contextWindow: 1050000, - maxTokens: 131100, - } satisfies Model<"anthropic-messages">, - "xiaomi/mimo-v2.5-pro": { - id: "xiaomi/mimo-v2.5-pro", - name: "MiMo V2.5 Pro", - api: "anthropic-messages", - provider: "vercel-ai-gateway", - baseUrl: "https://ai-gateway.vercel.sh", - reasoning: true, - input: ["text"], - cost: { - input: 0.3045, - output: 0.609, - cacheRead: 0.0028, - cacheWrite: 0, - }, - contextWindow: 1050000, - maxTokens: 131000, - } satisfies Model<"anthropic-messages">, "xiaomi/mimo-v2.6-flash": { id: "xiaomi/mimo-v2.6-flash", name: "MiMo V2.6 Flash", @@ -5219,6 +5185,23 @@ export const VERCEL_AI_GATEWAY_MODELS = { contextWindow: 1000000, maxTokens: 131072, } satisfies Model<"anthropic-messages">, + "zai/glm-5.3-flashx-legal": { + id: "zai/glm-5.3-flashx-legal", + name: "GLM 5.3 FlashX Legal", + api: "anthropic-messages", + provider: "vercel-ai-gateway", + baseUrl: "https://ai-gateway.vercel.sh", + reasoning: true, + input: ["text", "image"], + cost: { + input: 0.37, + output: 1.25, + cacheRead: 0.075, + cacheWrite: 0, + }, + contextWindow: 1000000, + maxTokens: 131072, + } satisfies Model<"anthropic-messages">, "zai/glm-5v-turbo": { id: "zai/glm-5v-turbo", name: "GLM 5V Turbo", From 90277353acbfe1dd9d869c14d4f20deef797b4f4 Mon Sep 17 00:00:00 2001 From: Rui Liang Date: Wed, 4 Nov 2026 14:58:50 +0800 Subject: [PATCH 2/4] feat(coding-agent): add built-in MCP tools, OAuth, SDK and RPC support --- .github/workflows/mcp-conformance.yml | 31 + NOTICE | 1 + package-lock.json | 13 + package.json | 1 + packages/agent/CHANGELOG.md | 4 + packages/agent/src/agent-loop.ts | 7 +- packages/agent/src/types.ts | 18 +- packages/coding-agent/CHANGELOG.md | 26 + packages/coding-agent/NOTICE | 1 + packages/coding-agent/README.md | 18 +- packages/coding-agent/docs/docs.json | 4 + packages/coding-agent/docs/index.md | 3 + packages/coding-agent/docs/mcp.md | 376 +++++ packages/coding-agent/docs/rpc.md | 17 + packages/coding-agent/docs/sdk.md | 12 +- packages/coding-agent/docs/security.md | 2 + .../coding-agent/examples/sdk/01-minimal.ts | 2 +- .../examples/sdk/02-custom-model.ts | 2 +- .../coding-agent/examples/sdk/04-skills.ts | 2 +- .../examples/sdk/06-extensions.ts | 3 +- .../examples/sdk/07-context-files.ts | 2 +- .../examples/sdk/08-prompt-templates.ts | 2 +- .../examples/sdk/12-full-control.ts | 2 +- .../install-lock/package-lock.json | 13 + packages/coding-agent/npm-shrinkwrap.json | 13 + packages/coding-agent/package.json | 1 + packages/coding-agent/src/cli/args.ts | 7 +- .../src/core/agent-session-runtime.ts | 4 +- .../coding-agent/src/core/agent-session.ts | 197 ++- .../src/core/export-html/tool-renderer.ts | 6 +- .../coding-agent/src/core/extensions/index.ts | 7 + .../src/core/extensions/loader.ts | 55 +- .../src/core/extensions/runner.ts | 65 +- .../coding-agent/src/core/extensions/types.ts | 169 ++- packages/coding-agent/src/core/mcp-servers.ts | 344 +++++ .../coding-agent/src/core/resource-loader.ts | 51 +- packages/coding-agent/src/core/sdk.ts | 6 +- .../coding-agent/src/core/session-manager.ts | 69 + .../coding-agent/src/core/system-prompt.ts | 22 +- .../src/core/tools/render-utils.ts | 27 + .../src/core/tools/tool-definition-wrapper.ts | 2 + .../coding-agent/src/core/tools/truncate.ts | 38 + .../coding-agent/src/core/trust-manager.ts | 1 + packages/coding-agent/src/extensions/index.ts | 10 + .../coding-agent/src/extensions/mcp/cli.ts | 627 ++++++++ .../coding-agent/src/extensions/mcp/config.ts | 249 ++++ .../coding-agent/src/extensions/mcp/index.ts | 1320 +++++++++++++++++ .../coding-agent/src/extensions/mcp/log.ts | 115 ++ .../coding-agent/src/extensions/mcp/oauth.ts | 616 ++++++++ .../src/extensions/mcp/resources.ts | 339 +++++ .../src/extensions/mcp/runtime.ts | 578 ++++++++ .../coding-agent/src/extensions/mcp/status.ts | 39 + .../coding-agent/src/extensions/mcp/tools.ts | 386 +++++ .../coding-agent/src/extensions/mcp/ui.ts | 291 ++++ .../src/extensions/tool-search/index.ts | 17 + .../src/extensions/tool-search/tool.ts | 334 +++++ packages/coding-agent/src/index.ts | 11 + packages/coding-agent/src/main.ts | 17 +- .../modes/interactive/components/auth-url.ts | 39 + .../interactive/components/tool-execution.ts | 6 +- .../interactive/components/visual-truncate.ts | 56 +- .../src/modes/interactive/interactive-mode.ts | 17 +- .../coding-agent/src/modes/rpc/rpc-client.ts | 6 + .../coding-agent/src/modes/rpc/rpc-mode.ts | 3 + .../coding-agent/src/modes/rpc/rpc-types.ts | 3 + .../coding-agent/src/utils/output-files.ts | 33 + packages/coding-agent/src/utils/text.ts | 9 + packages/coding-agent/test/args.test.ts | 8 + .../fixtures/mcp-exiting-parent-server.mjs | 9 + .../test/fixtures/mcp-stdio-server.mjs | 29 + .../coding-agent/test/mcp-command.test.ts | 284 ++++ .../test/mcp-conformance/README.md | 47 + .../test/mcp-conformance/baseline.json | 413 ++++++ .../test/mcp-conformance/client.ts | 197 +++ .../coding-agent/test/mcp-conformance/run.ts | 362 +++++ .../coding-agent/test/mcp-extension.test.ts | 914 ++++++++++++ .../test/mcp-manager-view.test.ts | 59 + .../test/mcp-oauth-refresh.test.ts | 215 +++ .../coding-agent/test/mcp-oauth-store.test.ts | 54 + .../coding-agent/test/mcp-resources.test.ts | 96 ++ .../suite/agent-session-mcp-oauth.test.ts | 299 ++++ .../test/suite/agent-session-mcp.test.ts | 938 ++++++++++++ packages/coding-agent/test/suite/harness.ts | 63 +- .../suite/mcp-lifecycle-and-status.test.ts | 260 ++++ .../test/suite/mcp-oauth-server.ts | 180 +++ .../test/suite/mcp-rpc-status.test.ts | 82 + .../10285-mcp-tool-renderers.test.ts | 71 + .../coding-agent/test/tool-search.test.ts | 185 +++ .../coding-agent/test/trust-manager.test.ts | 4 + scripts/release.mjs | 19 +- 90 files changed, 11462 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/mcp-conformance.yml create mode 100644 packages/coding-agent/docs/mcp.md create mode 100644 packages/coding-agent/src/core/mcp-servers.ts create mode 100644 packages/coding-agent/src/extensions/index.ts create mode 100644 packages/coding-agent/src/extensions/mcp/cli.ts create mode 100644 packages/coding-agent/src/extensions/mcp/config.ts create mode 100644 packages/coding-agent/src/extensions/mcp/index.ts create mode 100644 packages/coding-agent/src/extensions/mcp/log.ts create mode 100644 packages/coding-agent/src/extensions/mcp/oauth.ts create mode 100644 packages/coding-agent/src/extensions/mcp/resources.ts create mode 100644 packages/coding-agent/src/extensions/mcp/runtime.ts create mode 100644 packages/coding-agent/src/extensions/mcp/status.ts create mode 100644 packages/coding-agent/src/extensions/mcp/tools.ts create mode 100644 packages/coding-agent/src/extensions/mcp/ui.ts create mode 100644 packages/coding-agent/src/extensions/tool-search/index.ts create mode 100644 packages/coding-agent/src/extensions/tool-search/tool.ts create mode 100644 packages/coding-agent/src/modes/interactive/components/auth-url.ts create mode 100644 packages/coding-agent/src/utils/output-files.ts create mode 100644 packages/coding-agent/src/utils/text.ts create mode 100644 packages/coding-agent/test/fixtures/mcp-exiting-parent-server.mjs create mode 100644 packages/coding-agent/test/fixtures/mcp-stdio-server.mjs create mode 100644 packages/coding-agent/test/mcp-command.test.ts create mode 100644 packages/coding-agent/test/mcp-conformance/README.md create mode 100644 packages/coding-agent/test/mcp-conformance/baseline.json create mode 100644 packages/coding-agent/test/mcp-conformance/client.ts create mode 100644 packages/coding-agent/test/mcp-conformance/run.ts create mode 100644 packages/coding-agent/test/mcp-extension.test.ts create mode 100644 packages/coding-agent/test/mcp-manager-view.test.ts create mode 100644 packages/coding-agent/test/mcp-oauth-refresh.test.ts create mode 100644 packages/coding-agent/test/mcp-oauth-store.test.ts create mode 100644 packages/coding-agent/test/mcp-resources.test.ts create mode 100644 packages/coding-agent/test/suite/agent-session-mcp-oauth.test.ts create mode 100644 packages/coding-agent/test/suite/agent-session-mcp.test.ts create mode 100644 packages/coding-agent/test/suite/mcp-lifecycle-and-status.test.ts create mode 100644 packages/coding-agent/test/suite/mcp-oauth-server.ts create mode 100644 packages/coding-agent/test/suite/mcp-rpc-status.test.ts create mode 100644 packages/coding-agent/test/suite/regressions/10285-mcp-tool-renderers.test.ts create mode 100644 packages/coding-agent/test/tool-search.test.ts diff --git a/.github/workflows/mcp-conformance.yml b/.github/workflows/mcp-conformance.yml new file mode 100644 index 0000000..924da7e --- /dev/null +++ b/.github/workflows/mcp-conformance.yml @@ -0,0 +1,31 @@ +name: MCP conformance + +on: + workflow_dispatch: + pull_request: + paths: + - '.github/workflows/mcp-conformance.yml' + - 'package-lock.json' + - 'packages/coding-agent/src/core/**' + - 'packages/coding-agent/src/extensions/**' + - 'packages/coding-agent/test/mcp-conformance/**' + +permissions: + contents: read + +jobs: + conformance: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: 22 + cache: npm + - name: Install dependencies without lifecycle scripts + run: npm ci --ignore-scripts --no-audit --no-fund + - name: Run local protocol conformance without production credentials + env: + OPENABCODE_CODING_AGENT_DIR: ${{ runner.temp }}/openabcode-mcp-agent + run: npm run test:mcp-conformance diff --git a/NOTICE b/NOTICE index f2a393a..3dcd2ed 100644 --- a/NOTICE +++ b/NOTICE @@ -2,6 +2,7 @@ Portions of this software are derived from Pi (pi-mono) (https://github.com/earendil-works/pi). Copyright (c) 2025 Mario Zechner and Pi contributors +Copyright (c) 2024 Anthropic, PBC (portions of @earendil-works/pi-mcp derived from @modelcontextprotocol/sdk) Licensed under the MIT License. The full text of the MIT License: diff --git a/package-lock.json b/package-lock.json index 41999a4..2cd72c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -782,6 +782,18 @@ "node": ">=18.17" } }, + "node_modules/@earendil-works/pi-mcp": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@earendil-works/pi-mcp/-/pi-mcp-1.5.0.tgz", + "integrity": "sha512-DURw3IwHCTMHV8CzUJWVp9css27NowsCWfXt4xg2r09IZ+P1O/Uq58hp0hb9WJO0dbkaKGXKBIkV4LVXcu2nlg==", + "license": "MIT", + "dependencies": { + "cross-spawn": "7.0.6" + }, + "engines": { + "node": ">=22.19.0" + } + }, "node_modules/@emnapi/core": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz", @@ -5777,6 +5789,7 @@ "version": "1.2.0", "license": "AGPL-3.0", "dependencies": { + "@earendil-works/pi-mcp": "1.5.0", "@openabcode/agent-core": "^1.2.0", "@openabcode/ai": "^1.2.0", "@openabcode/tui": "^1.2.0", diff --git a/package.json b/package.json index ed423d6..388b6f0 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "profile:tui": "node scripts/profile-coding-agent-node.mjs --mode tui", "profile:rpc": "node scripts/profile-coding-agent-node.mjs --mode rpc", "test": "npm run test --workspaces --if-present", + "test:mcp-conformance": "node packages/coding-agent/test/mcp-conformance/run.ts", "version:patch": "npm version patch -ws --no-git-tag-version && node scripts/sync-versions.js && npm install --package-lock-only --ignore-scripts", "version:minor": "npm version minor -ws --no-git-tag-version && node scripts/sync-versions.js && npm install --package-lock-only --ignore-scripts", "version:major": "npm version major -ws --no-git-tag-version && node scripts/sync-versions.js && npm install --package-lock-only --ignore-scripts", diff --git a/packages/agent/CHANGELOG.md b/packages/agent/CHANGELOG.md index 3dbc993..e665c4e 100644 --- a/packages/agent/CHANGELOG.md +++ b/packages/agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- Added `isError` and `structuredContent` support on `AgentToolResult` and `AfterToolCallResult`, and `outputSchema` on `AgentTool`. + ## [1.2.0] - 2026-10-29 ## [1.1.2] - 2026-10-27 diff --git a/packages/agent/src/agent-loop.ts b/packages/agent/src/agent-loop.ts index 29a8a56..230d9ad 100644 --- a/packages/agent/src/agent-loop.ts +++ b/packages/agent/src/agent-loop.ts @@ -695,7 +695,7 @@ async function executePreparedToolCall( ); acceptingUpdates = false; await Promise.all(updateEvents); - return { result, isError: false }; + return { result, isError: result.isError === true }; } catch (error) { acceptingUpdates = false; await Promise.all(updateEvents); @@ -733,11 +733,16 @@ async function finalizeExecutedToolCall( signal, ); if (afterResult) { + const structuredContent = + afterResult.structuredContent ?? (afterResult.content ? undefined : result.structuredContent); result = { + ...result, content: afterResult.content ?? result.content, details: afterResult.details ?? result.details, terminate: afterResult.terminate ?? result.terminate, }; + if (structuredContent === undefined) delete result.structuredContent; + else result.structuredContent = structuredContent; isError = afterResult.isError ?? isError; } } catch (error) { diff --git a/packages/agent/src/types.ts b/packages/agent/src/types.ts index e2103e1..b67dacd 100644 --- a/packages/agent/src/types.ts +++ b/packages/agent/src/types.ts @@ -77,6 +77,7 @@ export interface BeforeToolCallResult { export interface AfterToolCallResult { content?: (TextContent | ImageContent)[]; details?: unknown; + structuredContent?: unknown; isError?: boolean; /** * Hint that the agent should stop after the current tool batch. @@ -352,6 +353,16 @@ export interface AgentToolResult { content: (TextContent | ImageContent)[]; /** Arbitrary structured details for logs or UI rendering. */ details: T; + /** + * Machine-readable result matching the tool's `outputSchema`, for programmatic callers. Not sent + * to the model; `content` remains the model-facing result. + */ + structuredContent?: unknown; + /** + * Report a failure without throwing. The model sees `content` as an error result, like a thrown + * error, but `details` and `structuredContent` are kept for the UI and programmatic callers. + */ + isError?: boolean; /** * Hint that the agent should stop after the current tool batch. * Early termination only happens when every finalized tool result in the batch sets this to true. @@ -376,7 +387,12 @@ export interface AgentTool Static; - /** Execute the tool call. Throw on failure instead of encoding errors in `content`. */ + /** + * JSON Schema of `structuredContent` in successful results. Tools that declare it should always + * set `structuredContent`. + */ + outputSchema?: TSchema; + /** Execute the tool call. Throw on failure, or return a result with `isError: true`. */ execute: ( toolCallId: string, params: Static, diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 1fe4286..592011b 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,32 @@ ## [Unreleased] +### New Features + +- **Built-in MCP support**: connect local stdio and Streamable HTTP servers, configure them at user/project scope, and manage connections with `/mcp` or `openabcode mcp`. See the [MCP setup tutorial](docs/mcp.md#quick-setup). +- **On-demand tool discovery**: find tools with `tool_search`, control direct/deferred/hidden exposure, and keep loaded tools across session branches and reloads. See [tool exposure](docs/mcp.md#control-tool-exposure). +- **OAuth, resources, and programmatic integration**: sign in to remote MCP servers, read resources, and use credential-free status snapshots through SDK/RPC. See [OAuth](docs/mcp.md#authenticate-with-oauth), [resources](docs/mcp.md#use-resources), and [SDK integration](docs/mcp.md#use-mcp-from-the-sdk). + +### Breaking Changes + +- `AgentSession.dispose()` now returns `Promise`; await it to finish extension shutdown and MCP process cleanup. + +### Added + +- Added built-in MCP client integration (`createMcpExtension()`) supporting `stdio` and Streamable HTTP transports, user (`~/.openabcode/agent/mcp.json`) and project (`.openabcode/mcp.json`) configurations, `/mcp` interactive manager, and `openabcode mcp ` CLI commands, plus `--no-mcp` to disable built-in MCP. +- Added `deferred` (default), `direct`, and `hidden` tool exposure modes with per-tool `toolExposure` overrides, BM25-based `tool_search` (`createToolSearchExtension()`), `` system prompt summaries, `notifications/tools/list_changed` dynamic updates, and branch-aware session restoration across resume, fork, `/tree`, and `/reload`. +- Added MCP OAuth 2.1 authentication (PKCE, dynamic client registration, pre-registered client credentials, cross-process locked token refresh, scope step-up, and SSH redirect URL paste) and MCP resource tools (`list_mcp_resources`, `list_mcp_resource_templates`, `read_mcp_resource`). +- Added `registerMcpServer()`, `unregisterMcpServer()`, `getMcpServers()`, `mcp_servers_change`, and `registerToolRenderer()` on `ExtensionAPI`. +- Added credential-free `getMcpStatus()` snapshots for SDK/extensions, RPC `get_mcp_status`, streamed `mcp_status_change` events, and dedicated protocol conformance CI. +- Preserve tool-returned `isError`, `structuredContent`, and declared `outputSchema` through the agent pipeline, including MCP results and extension hooks. + +### Fixed + +- Revalidate MCP tool availability and current arguments after reconnect/session-expiry retry; withdrawn tools cannot execute through an older request snapshot. +- Await idempotent SDK extension shutdown on disposal and restart MCP after headless `/reload`; document required extension binding. +- Redact secrets from MCP stderr, connection errors, status reports, and log notifications. +- Apply shared project-trust rules to MCP shell commands and avoid reading untrusted project files for removal suggestions. + ## [1.2.0] - 2026-10-29 ### Added diff --git a/packages/coding-agent/NOTICE b/packages/coding-agent/NOTICE index f2a393a..3dcd2ed 100644 --- a/packages/coding-agent/NOTICE +++ b/packages/coding-agent/NOTICE @@ -2,6 +2,7 @@ Portions of this software are derived from Pi (pi-mono) (https://github.com/earendil-works/pi). Copyright (c) 2025 Mario Zechner and Pi contributors +Copyright (c) 2024 Anthropic, PBC (portions of @earendil-works/pi-mcp derived from @modelcontextprotocol/sdk) Licensed under the MIT License. The full text of the MIT License: diff --git a/packages/coding-agent/README.md b/packages/coding-agent/README.md index 4c6cf07..83dbaa5 100644 --- a/packages/coding-agent/README.md +++ b/packages/coding-agent/README.md @@ -37,6 +37,7 @@ OpenABCode runs in four modes: interactive, print or JSON, RPC for process integ - [Customization](#customization) - [Prompt Templates](#prompt-templates) - [Skills](#skills) + - [MCP Servers](#mcp-servers) - [Extensions](#extensions) - [Themes](#themes) - [OpenABCode Packages](#openabcode-packages) @@ -186,6 +187,7 @@ Type `/` in the editor to trigger commands. [Extensions](#extensions) can regist | Command | Description | |---------|-------------| | `/login`, `/logout` | OAuth authentication | +| `/mcp` | Manage MCP servers: sign in, reconnect, enable or disable, and change exposure | | `/model` | Switch models | | `/route [on\|off\|status]` | Open the Route dashboard, or toggle/inspect task routing directly | | `/scoped-models` | Enable/disable models for Ctrl+P cycling | @@ -371,6 +373,18 @@ Use this skill when the user asks about X. Place in `~/.openabcode/agent/skills/`, `~/.agents/skills/`, `.openabcode/skills/`, or `.agents/skills/` (from `cwd` up through parent directories) or a [openabcode package](#openabcode-packages) to share with others. See [docs/skills.md](docs/skills.md). +### MCP Servers + +Connect local `stdio` or remote Streamable HTTP [Model Context Protocol](https://modelcontextprotocol.io) servers: + +```bash +openabcode mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem . +openabcode mcp add docs --url https://example.com/mcp --bearer-token-env-var DOCS_TOKEN +openabcode mcp list +``` + +Servers are configured in `~/.openabcode/agent/mcp.json` (user) or `.openabcode/mcp.json` (trusted project). By default (`"exposure": "deferred"`), MCP tools are discovered on demand with `tool_search` so large servers do not bloat initial context; set `"exposure": "direct"` to declare tools upfront. Remote servers without an `Authorization` header support OAuth sign-in via `/mcp` or `openabcode mcp login `. See [docs/mcp.md](docs/mcp.md). + ### Extensions

Doom Extension

@@ -501,8 +515,6 @@ See [docs/rpc.md](docs/rpc.md) for the protocol. OpenABCode is aggressively extensible so it doesn't have to dictate your workflow. Features that other tools bake in can be built with [extensions](#extensions), [skills](#skills), or installed from third-party [openabcode packages](#openabcode-packages). This keeps the core minimal while letting you shape openabcode to fit how you work. -**No MCP.** Build CLI tools with READMEs (see [Skills](#skills)), or build an extension that adds MCP support. [Why?](https://mariozechner.at/posts/2025-11-02-what-if-you-dont-need-mcp/) - **No sub-agents.** There's many ways to do this. Spawn openabcode instances via tmux, or build your own with [extensions](#extensions), or install a package that does it your way. **No permission popups.** Run in a container, or build your own confirmation flow with [extensions](#extensions) inline with your environment and security requirements. @@ -537,6 +549,7 @@ openabcode update --self --force # Reinstall openabcode even if current openabcode update --extension # Update one package openabcode list # List installed packages openabcode config # Enable/disable package resources +openabcode mcp [add|remove|list|login|logout] # Configure and manage MCP servers ``` `openabcode config` and project package commands accept `--approve`/`--no-approve` to trust or ignore project-local settings for one command. `openabcode update` never prompts for project trust. @@ -597,6 +610,7 @@ Available built-in tools: `read`, `bash`, `edit`, `write`, `grep`, `find`, `ls` |--------|-------------| | `-e`, `--extension ` | Load extension from path, npm, or git (repeatable) | | `--no-extensions` | Disable extension discovery | +| `--no-mcp` | Disable built-in MCP server integration | | `--skill ` | Load skill (repeatable) | | `--no-skills` | Disable skill discovery | | `--prompt-template ` | Load prompt template (repeatable) | diff --git a/packages/coding-agent/docs/docs.json b/packages/coding-agent/docs/docs.json index 95ae5d3..fd1f36e 100644 --- a/packages/coding-agent/docs/docs.json +++ b/packages/coding-agent/docs/docs.json @@ -52,6 +52,10 @@ "title": "Extensions", "path": "extensions.md" }, + { + "title": "MCP Servers", + "path": "mcp.md" + }, { "title": "Skills", "path": "skills.md" diff --git a/packages/coding-agent/docs/index.md b/packages/coding-agent/docs/index.md index b219bbd..64449b5 100644 --- a/packages/coding-agent/docs/index.md +++ b/packages/coding-agent/docs/index.md @@ -42,6 +42,8 @@ Authenticate with `/login` for subscription providers, or set an API key such as For the full first-run flow, see [Quickstart](quickstart.md). +To connect external tools and data, follow the [MCP tutorial](mcp.md#quick-setup): add a local or remote server, verify the connection, and use its tools in your first session. + ## Start here - [Quickstart](quickstart.md) - install, authenticate, and run a first session. @@ -57,6 +59,7 @@ For the full first-run flow, see [Quickstart](quickstart.md). ## Customization - [Extensions](extensions.md) - TypeScript modules for tools, commands, events, and custom UI. +- [MCP servers](mcp.md) - step-by-step setup, first tool call, project configuration, OAuth, resources, and SDK/RPC usage. - [Skills](skills.md) - Agent Skills for reusable on-demand capabilities. - [Prompt templates](prompt-templates.md) - reusable prompts that expand from slash commands. - [Themes](themes.md) - built-in and custom terminal themes. diff --git a/packages/coding-agent/docs/mcp.md b/packages/coding-agent/docs/mcp.md new file mode 100644 index 0000000..67b6907 --- /dev/null +++ b/packages/coding-agent/docs/mcp.md @@ -0,0 +1,376 @@ +# MCP Servers + +OpenABCode connects to [Model Context Protocol](https://modelcontextprotocol.io) servers over stdio or streamable HTTP and makes their tools and resources available to the model. + +## Support matrix + +| Area | Supported | Not supported | +|---|---|---| +| Protocol versions | `2025-03-26`, `2025-06-18`, `2025-11-25` | `2026-07-28` (stateless protocol) | +| Transports | `stdio`, Streamable HTTP (`http` / `streamable-http`) | Legacy SSE (`sse`) | +| Server capabilities | `tools` (`tools/list`, `tools/call`, `notifications/tools/list_changed`), `resources` (`resources/list`, `resources/templates/list`, `resources/read`), `logging` (`notifications/message`) | `prompts`, `sampling`, `elicitation`, `tasks`, MCP Apps (`ui://` / `profile=mcp-app`) | +| Authentication | Custom headers (`${ENV_VAR}`), OAuth 2.1 with PKCE, dynamic client registration (`dcr`), pre-registered client credentials, token refresh, scope step-up | Automatic forwarding of OpenABCode or model provider credentials (`auth.provider`), `pi.dev` Client ID Metadata Documents | +| Tool exposure | `deferred` (default, loaded on demand via `tool_search`), `direct`, `hidden`, per-tool `toolExposure` | `codemode` | + +## Quick setup + +This walkthrough connects a filesystem server and uses it in a first session. You need a working [OpenABCode installation and model login](quickstart.md), plus Node.js and `npx` for this example. Other stdio servers may require Python and `uvx` instead. + +> **Availability:** This guide describes the built-in MCP integration. If `openabcode mcp help` is not available in your installation, use a release or development build that includes MCP support. + +### 1. Add a local server + +Run these commands from the project directory you want the server to access: + +```bash +cd /path/to/project +openabcode mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem "$PWD" +``` + +`"$PWD"` supplies an absolute allowed directory, so the server keeps the same scope if you later start OpenABCode elsewhere. Choose a narrow directory rather than your home directory or filesystem root. This example uses a POSIX shell; in PowerShell, replace `"$PWD"` with `(Get-Location).Path`. + +The entry is saved to `~/.openabcode/agent/mcp.json`. `npx -y` downloads and runs the server package: review the package before launching it, and pin a reviewed package version for repeatable setups. MCP servers are not sandboxed automatically. + +### 2. Verify the connection + +```bash +openabcode mcp list +``` + +Find `filesystem` with a connected state and at least one offered tool. The command starts the server, discovers its capabilities, then closes the connection. It does not require a model request. If it fails, check that Node.js and `npx` are on `PATH` and the allowed directory exists; see [connection troubleshooting](#diagnose-connection-problems). + +For machine-readable output: + +```bash +openabcode mcp list --json +``` + +### 3. Use an MCP tool in a session + +```bash +openabcode +``` + +Run `/mcp` to inspect the session's connection and tools, then enter a prompt such as: + +```text +Use the filesystem MCP server to list its allowed directories, then list the files in this project. Do not edit or delete anything. +``` + +By default, tools use `deferred` exposure: the model uses `tool_search` to discover the appropriate MCP tool, then calls it. You do not need to paste tool schemas into the prompt, run `tool_search` in your shell, or use a `/tool_search` command. Successful tool calls appear in the conversation with names such as `mcp__filesystem__list_directory`. + +In `/mcp`, select the server to inspect tools, reconnect, change exposure, or enable and disable it. Run `/reload` after adding, removing, or changing configuration outside a running session. + +### 4. Share configuration with a project + +Use `--local` or `-l` to save the entry to `.openabcode/mcp.json` instead: + +```bash +openabcode mcp add --local filesystem -- npx -y @modelcontextprotocol/server-filesystem . +``` + +Here `.` resolves relative to the session's working directory rather than storing one machine's absolute project path. Review the command before trusting the project. Start `openabcode` in that project and approve project trust, or explicitly inspect it for one shell command: + +```bash +openabcode mcp list --approve +``` + +`--approve` applies only to that command; it does not persist a trust decision. Without trust, project configuration is ignored. Commit only configuration intended for collaborators, never tokens or credentials. A project entry takes precedence over a user-level entry with the same server name. + +### 5. Connect a remote server + +For an HTTP server with a bearer token, replace the example endpoint and set the token in the same terminal that starts OpenABCode: + +```bash +export DOCS_TOKEN='replace-with-your-server-token' +openabcode mcp add docs --url https://example.com/mcp --bearer-token-env-var DOCS_TOKEN +openabcode mcp list +openabcode +``` + +The configuration stores `Bearer ${DOCS_TOKEN}`, not the token value. The endpoint must support Streamable HTTP; a legacy `/sse` endpoint is not supported. MCP requests go directly from your local CLI to the configured server, not through the OpenABCode hosted gateway. + +For an OAuth server, no bearer-token setting is needed: + +```bash +openabcode mcp add sentry --url https://mcp.sentry.dev/mcp +openabcode mcp login sentry +openabcode mcp list +``` + +Approve access in the browser. If it opens on another machine, paste the redirected URL back into the sign-in prompt. See [OAuth setup](#authenticate-with-oauth) for pre-registered clients and callback options. MCP sign-in is separate from OpenABCode `/login`. + +### 6. Disable or remove a server + +Use `/mcp` to disable a server while keeping its configuration. To remove it permanently: + +```bash +openabcode mcp remove filesystem +# Remove a project entry instead: +openabcode mcp remove --local filesystem +``` + +Use `openabcode --no-mcp` to start one session without built-in MCP integration. Removing configuration does not immediately stop a server in another running session; run `/reload` there. + +## Configure servers + +OpenABCode reads user-level servers from `~/.openabcode/agent/mcp.json` and project servers from `.openabcode/mcp.json`. Project configuration is read only after [project trust](security.md) is granted. A project entry replaces a user-level entry with the same name. + +> **Security note:** Project trust only gates whether `.openabcode/mcp.json` is loaded; it is not an OS sandbox. Local `stdio` MCP servers run as child processes with the operating system permissions of the user running `openabcode`. Only trust projects and MCP servers whose commands you have reviewed. + +A project entry without `command`, `url`, or `type` overrides only `enabled`, `exposure`, and `toolExposure` of the user-level server with the same name and keeps the rest, including `env`, `headers`, and `oauth`. For example, this turns off a user-level server in one project: + +```json +{ + "mcpServers": { + "internal-tools": { "enabled": false } + } +} +``` + +The format matches other MCP clients: + +```json +{ + "mcpServers": { + "filesystem": { + "command": "npx", + "args": ["-y", "@modelcontextprotocol/server-filesystem", "."] + }, + "docs": { + "url": "https://example.com/mcp", + "headers": { "Authorization": "Bearer ${DOCS_TOKEN}" }, + "description": "Search and read the product documentation" + } + } +} +``` + +Stdio servers use `command`, `args`, `env`, and `cwd`. Relative `cwd` values resolve against the session working directory. A leading `~/` in `command`, an argument, or `cwd` names the home directory. + +HTTP servers use `url`, `headers`, and `oauth` (see [Authenticate with OAuth](#authenticate-with-oauth)). The legacy SSE transport is not supported; use the server's Streamable HTTP endpoint (typically `/mcp` instead of `/sse`). + +Both server types support: + +- `timeout`: per-request timeout in seconds (default 60). Progress notifications reset it. +- `enabled: false`: keep the entry without connecting to it. +- `exposure` and `toolExposure`: control how tools reach the model (see [Control tool exposure](#control-tool-exposure)). +- `description`: what the server offers, in a sentence. It lists the server in the system prompt and helps `tool_search` rank the server's tools. Without it, the first line of the server instructions is used once the server connects. + +### Configuration rules + +- Server names may contain only letters, digits, `_`, and `-`. Tools are named `mcp____`, with every character other than letters, digits, and `_` replaced by `_`; tools of a server whose names then collide or exceed 64 characters get a hash suffix. Server names that differ only in `-` and `_` count as the same server: a second one is rejected, and an `mcp.json` server overrides a registered one. +- `type` is optional. A `command` selects stdio and a `url` selects streamable HTTP. When present, `type` must be `stdio`, `http`, or `streamable-http`. +- `sse` is rejected. Servers that document an SSE endpoint often also provide streamable HTTP, commonly at `/mcp` instead of `/sse`. +- `command` is one executable and `args` contains its arguments. It is not a shell command string. +- `env` and `headers` values can reference environment variables such as `${GITHUB_TOKEN}`. +- Invalid entries are reported and skipped without preventing other servers from connecting. + +### Inspect or change a server + +`/mcp` lists configured servers with their state, tool count, exposure, and configuration source. Servers that need attention appear first. Select a server to inspect its tools and connection details, reconnect, sign in or out, change exposure, or enable and disable it. + +Exposure and enabled-state changes are saved atomically to the file that defines the server without replacing unrelated content. In a trusted project, "Enable in this project" and "Disable in this project" add a project override for a user-level server; later changes to that server are saved to the override. Disabled servers remain listed. Outside the interactive TUI, `/mcp` prints server status; `/mcp login `, `/mcp logout `, and `/mcp reconnect ` perform those actions directly. + +Shell commands work without a session: `openabcode mcp add`, `openabcode mcp remove`, `openabcode mcp list [--json]`, `openabcode mcp login`, and `openabcode mcp logout`. Shell commands do not load extensions. They use the same saved project-trust decision and global `defaultProjectTrust` (`ask`, `always`, or `never`) as sessions. Non-interactive `ask` ignores untrusted project configuration. Use `--approve` to trust it for one command or `--no-approve` to ignore it; neither flag persists a decision. Flags after the stdio separator `--` are server arguments, not OpenABCode trust flags. + +### Diagnose connection problems + +Run `openabcode mcp list` to connect to every enabled server and print its state, tools, and errors. It exits with status 1 when an entry is invalid or an enabled server is not connected. `/mcp` shows the connection error and the tail of stderr from a failed stdio server. Logs, CLI/TUI diagnostics, and SDK/RPC status redact authorization credentials, configured secrets, and stored access/refresh tokens. Servers can still emit sensitive data in tool results; diagnostics redaction is not a replacement for reviewing server output. + +OpenABCode reports configuration errors, failed connections, and required sign-ins once after startup. Server logging notifications are appended to `~/.openabcode/agent/mcp.log` as `