From e68b7fb27193d4b4325c8e28a97b89f68936e053 Mon Sep 17 00:00:00 2001 From: PR Bot Date: Thu, 12 Mar 2026 15:37:50 +0800 Subject: [PATCH 1/4] feat: add MiniMax as a new LLM provider Add MiniMax M2.5 models as a first-class provider using the OpenAI-compatible adapter (@ai-sdk/openai-compatible), following the same pattern as the existing Z.AI integration. Changes: - Register 'minimax' in SupportedProvider enum and BuiltinProvider type - Add createOpenAICompatible cases in both factory.ts and registry.ts - Add 'MiniMax-' prefix to MODEL_PROVIDER_MAP for auto-detection - Add MiniMax-M2.5 and MiniMax-M2.5-highspeed to model catalog - Add provider presets (auto/balanced/quick) and model equivalences - Add PROVIDER_REGISTRY entry for settings UI - Add MiniMax detection test in factory.test.ts MiniMax API: https://api.minimax.io/v1 (OpenAI-compatible) Models: MiniMax-M2.5 (204K context), MiniMax-M2.5-highspeed (204K) Env var: MINIMAX_API_KEY --- apps/desktop/src/main/ai/config/types.ts | 1 + .../ai/providers/__tests__/factory.test.ts | 4 ++++ apps/desktop/src/main/ai/providers/factory.ts | 8 +++++++ .../desktop/src/main/ai/providers/registry.ts | 8 +++++++ apps/desktop/src/main/ai/providers/types.ts | 1 + apps/desktop/src/shared/constants/models.ts | 21 +++++++++++++++++++ .../desktop/src/shared/constants/providers.ts | 6 ++++++ .../src/shared/types/provider-account.ts | 2 +- 8 files changed, 50 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/main/ai/config/types.ts b/apps/desktop/src/main/ai/config/types.ts index b32fce7c1c..0141acce05 100644 --- a/apps/desktop/src/main/ai/config/types.ts +++ b/apps/desktop/src/main/ai/config/types.ts @@ -147,6 +147,7 @@ export const MODEL_PROVIDER_MAP: Record = { 'llama-': 'groq', 'grok-': 'xai', 'glm-': 'zai', + 'MiniMax-': 'minimax', } as const; // ============================================ diff --git a/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts b/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts index f79ed22047..cc5881c91b 100644 --- a/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts +++ b/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts @@ -163,6 +163,10 @@ describe('detectProviderFromModel', () => { expect(detectProviderFromModel('grok-2')).toBe('xai'); }); + it('detects MiniMax from MiniMax- prefix', () => { + expect(detectProviderFromModel('MiniMax-M2.5')).toBe('minimax'); + }); + it('returns undefined for unknown model', () => { expect(detectProviderFromModel('unknown-model')).toBeUndefined(); }); diff --git a/apps/desktop/src/main/ai/providers/factory.ts b/apps/desktop/src/main/ai/providers/factory.ts index f4fc6e9ee4..60b1c3f505 100644 --- a/apps/desktop/src/main/ai/providers/factory.ts +++ b/apps/desktop/src/main/ai/providers/factory.ts @@ -141,6 +141,14 @@ function createProviderInstance(config: ProviderConfig) { headers, }); + case SupportedProvider.MiniMax: + return createOpenAICompatible({ + name: 'minimax', + apiKey, + baseURL: baseURL ?? 'https://api.minimax.io/v1', + headers, + }); + case SupportedProvider.Ollama: { // Account settings store the base Ollama URL (e.g., 'http://localhost:11434') // but the OpenAI-compatible SDK needs the /v1 path appended. diff --git a/apps/desktop/src/main/ai/providers/registry.ts b/apps/desktop/src/main/ai/providers/registry.ts index e67222c06b..dec8a48b5a 100644 --- a/apps/desktop/src/main/ai/providers/registry.ts +++ b/apps/desktop/src/main/ai/providers/registry.ts @@ -86,6 +86,14 @@ function createProviderSDKInstance( headers, }); + case SupportedProvider.MiniMax: + return createOpenAICompatible({ + name: 'minimax', + apiKey, + baseURL: baseURL ?? 'https://api.minimax.io/v1', + headers, + }); + case SupportedProvider.Ollama: { // Account settings store the base Ollama URL (e.g., 'http://localhost:11434') // but the OpenAI-compatible SDK needs the /v1 path appended. diff --git a/apps/desktop/src/main/ai/providers/types.ts b/apps/desktop/src/main/ai/providers/types.ts index d8021c78b4..17e067e3e4 100644 --- a/apps/desktop/src/main/ai/providers/types.ts +++ b/apps/desktop/src/main/ai/providers/types.ts @@ -20,6 +20,7 @@ export const SupportedProvider = { XAI: 'xai', OpenRouter: 'openrouter', ZAI: 'zai', + MiniMax: 'minimax', Ollama: 'ollama', } as const; diff --git a/apps/desktop/src/shared/constants/models.ts b/apps/desktop/src/shared/constants/models.ts index 1e93992846..fd71dd3701 100644 --- a/apps/desktop/src/shared/constants/models.ts +++ b/apps/desktop/src/shared/constants/models.ts @@ -66,6 +66,9 @@ export const ALL_AVAILABLE_MODELS: ModelOption[] = [ { value: 'grok-4-0709', label: 'Grok 4', provider: 'xai', description: 'Flagship', capabilities: { thinking: true, tools: true, vision: true, contextWindow: 256000 } }, { value: 'grok-3', label: 'Grok 3', provider: 'xai', description: 'Text', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 131072 } }, { value: 'grok-3-mini', label: 'Grok 3 Mini', provider: 'xai', description: 'Fast reasoning', capabilities: { thinking: true, tools: true, vision: false, contextWindow: 131072 } }, + // MiniMax + { value: 'MiniMax-M2.5', label: 'MiniMax M2.5', provider: 'minimax', description: 'Peak performance', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, + { value: 'MiniMax-M2.5-highspeed', label: 'MiniMax M2.5 High Speed', provider: 'minimax', description: 'Fast and agile', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, // Z.AI (Zhipu) { value: 'glm-5', label: 'GLM-5', provider: 'zai', description: 'Flagship', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 128000 } }, { value: 'glm-4.7', label: 'GLM-4.7', provider: 'zai', description: 'Previous flagship', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 128000 } }, @@ -316,6 +319,11 @@ export const PROVIDER_PRESET_DEFINITIONS: Partial Date: Thu, 12 Mar 2026 16:58:24 +0800 Subject: [PATCH 2/4] fix: use lowercase minimax model IDs and add auth entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address PR review feedback: - Change all MiniMax model IDs from PascalCase to lowercase ('MiniMax-M2.5' → 'minimax-m2.5', 'MiniMax-M2.5-highspeed' → 'minimax-m2.5-highspeed') for consistency with other providers - Update MODEL_PROVIDER_MAP prefix from 'MiniMax-' to 'minimax-' - Add missing 'minimax' entries to PROVIDER_ENV_VARS and PROVIDER_SETTINGS_KEY in auth/types.ts (critical for API key resolution) - Update all preset definitions and equivalence mappings - Update factory detection test to use lowercase model name Co-Authored-By: Claude Opus 4.6 --- apps/desktop/src/main/ai/auth/types.ts | 2 ++ apps/desktop/src/main/ai/config/types.ts | 2 +- .../ai/providers/__tests__/factory.test.ts | 4 ++-- apps/desktop/src/shared/constants/models.ts | 24 +++++++++---------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/apps/desktop/src/main/ai/auth/types.ts b/apps/desktop/src/main/ai/auth/types.ts index da5b7be1f7..3d8349b331 100644 --- a/apps/desktop/src/main/ai/auth/types.ts +++ b/apps/desktop/src/main/ai/auth/types.ts @@ -79,6 +79,7 @@ export const PROVIDER_ENV_VARS: Record = xai: 'XAI_API_KEY', openrouter: 'OPENROUTER_API_KEY', zai: 'ZHIPU_API_KEY', + minimax: 'MINIMAX_API_KEY', ollama: undefined, // No auth required for local Ollama } as const; @@ -96,6 +97,7 @@ export const PROVIDER_SETTINGS_KEY: Partial> = azure: 'globalAzureApiKey', openrouter: 'globalOpenRouterApiKey', zai: 'globalZAIApiKey', + minimax: 'globalMiniMaxApiKey', } as const; /** diff --git a/apps/desktop/src/main/ai/config/types.ts b/apps/desktop/src/main/ai/config/types.ts index 0141acce05..be1ffa1cb8 100644 --- a/apps/desktop/src/main/ai/config/types.ts +++ b/apps/desktop/src/main/ai/config/types.ts @@ -147,7 +147,7 @@ export const MODEL_PROVIDER_MAP: Record = { 'llama-': 'groq', 'grok-': 'xai', 'glm-': 'zai', - 'MiniMax-': 'minimax', + 'minimax-': 'minimax', } as const; // ============================================ diff --git a/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts b/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts index cc5881c91b..6c1b338525 100644 --- a/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts +++ b/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts @@ -163,8 +163,8 @@ describe('detectProviderFromModel', () => { expect(detectProviderFromModel('grok-2')).toBe('xai'); }); - it('detects MiniMax from MiniMax- prefix', () => { - expect(detectProviderFromModel('MiniMax-M2.5')).toBe('minimax'); + it('detects MiniMax from minimax- prefix', () => { + expect(detectProviderFromModel('minimax-m2.5')).toBe('minimax'); }); it('returns undefined for unknown model', () => { diff --git a/apps/desktop/src/shared/constants/models.ts b/apps/desktop/src/shared/constants/models.ts index fd71dd3701..f9c32e9526 100644 --- a/apps/desktop/src/shared/constants/models.ts +++ b/apps/desktop/src/shared/constants/models.ts @@ -67,8 +67,8 @@ export const ALL_AVAILABLE_MODELS: ModelOption[] = [ { value: 'grok-3', label: 'Grok 3', provider: 'xai', description: 'Text', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 131072 } }, { value: 'grok-3-mini', label: 'Grok 3 Mini', provider: 'xai', description: 'Fast reasoning', capabilities: { thinking: true, tools: true, vision: false, contextWindow: 131072 } }, // MiniMax - { value: 'MiniMax-M2.5', label: 'MiniMax M2.5', provider: 'minimax', description: 'Peak performance', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, - { value: 'MiniMax-M2.5-highspeed', label: 'MiniMax M2.5 High Speed', provider: 'minimax', description: 'Fast and agile', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, + { value: 'minimax-m2.5', label: 'MiniMax M2.5', provider: 'minimax', description: 'Peak performance', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, + { value: 'minimax-m2.5-highspeed', label: 'MiniMax M2.5 High Speed', provider: 'minimax', description: 'Fast and agile', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, // Z.AI (Zhipu) { value: 'glm-5', label: 'GLM-5', provider: 'zai', description: 'Flagship', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 128000 } }, { value: 'glm-4.7', label: 'GLM-4.7', provider: 'zai', description: 'Previous flagship', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 128000 } }, @@ -320,9 +320,9 @@ export const PROVIDER_PRESET_DEFINITIONS: Partial Date: Sat, 14 Mar 2026 14:16:59 +0800 Subject: [PATCH 3/4] fix: resolve critical code review issues for MiniMax provider - Add missing 'minimax' entry to BUILTIN_TO_SUPPORTED map in resolver.ts, fixing silent skip of MiniMax accounts during queue-based provider routing - Add globalMiniMaxApiKey (and globalZAIApiKey) to AppSettings interface, fixing auth settings lookup for profile-specific API keys - Differentiate model equivalence tiers: 'sonnet' tier now maps to minimax-m2.5-highspeed instead of minimax-m2.5 (which is reserved for 'opus' tier), matching the pattern used by other multi-model providers Co-Authored-By: Claude Opus 4.6 --- apps/desktop/src/main/ai/auth/resolver.ts | 1 + apps/desktop/src/shared/constants/models.ts | 2 +- apps/desktop/src/shared/types/settings.ts | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/main/ai/auth/resolver.ts b/apps/desktop/src/main/ai/auth/resolver.ts index 17e1feb1ae..b4ade1ded1 100644 --- a/apps/desktop/src/main/ai/auth/resolver.ts +++ b/apps/desktop/src/main/ai/auth/resolver.ts @@ -331,6 +331,7 @@ const BUILTIN_TO_SUPPORTED: Record = { xai: 'xai', openrouter: 'openrouter', zai: 'zai', + minimax: 'minimax', ollama: 'ollama', }; diff --git a/apps/desktop/src/shared/constants/models.ts b/apps/desktop/src/shared/constants/models.ts index f9c32e9526..58f64f76e6 100644 --- a/apps/desktop/src/shared/constants/models.ts +++ b/apps/desktop/src/shared/constants/models.ts @@ -462,7 +462,7 @@ export const DEFAULT_MODEL_EQUIVALENCES: Record Date: Wed, 18 Mar 2026 14:45:56 +0800 Subject: [PATCH 4/4] feat: add MiniMax-M2.7-highspeed model and upgrade quick preset - Add MiniMax-M2.7-highspeed to model catalog for low-latency scenarios - Upgrade quick preset from M2.5-highspeed to M2.7-highspeed - Add M2.7-highspeed model equivalence entry - Update haiku tier to map to M2.7-highspeed - Update provider detection test for M2.7-highspeed --- .../ai/providers/__tests__/factory.test.ts | 2 ++ apps/desktop/src/shared/constants/models.ts | 26 ++++++++++++++----- .../desktop/src/shared/constants/providers.ts | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts b/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts index 6c1b338525..f2011176ef 100644 --- a/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts +++ b/apps/desktop/src/main/ai/providers/__tests__/factory.test.ts @@ -164,6 +164,8 @@ describe('detectProviderFromModel', () => { }); it('detects MiniMax from minimax- prefix', () => { + expect(detectProviderFromModel('minimax-m2.7')).toBe('minimax'); + expect(detectProviderFromModel('minimax-m2.7-highspeed')).toBe('minimax'); expect(detectProviderFromModel('minimax-m2.5')).toBe('minimax'); }); diff --git a/apps/desktop/src/shared/constants/models.ts b/apps/desktop/src/shared/constants/models.ts index 58f64f76e6..d7cf61f30f 100644 --- a/apps/desktop/src/shared/constants/models.ts +++ b/apps/desktop/src/shared/constants/models.ts @@ -67,7 +67,9 @@ export const ALL_AVAILABLE_MODELS: ModelOption[] = [ { value: 'grok-3', label: 'Grok 3', provider: 'xai', description: 'Text', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 131072 } }, { value: 'grok-3-mini', label: 'Grok 3 Mini', provider: 'xai', description: 'Fast reasoning', capabilities: { thinking: true, tools: true, vision: false, contextWindow: 131072 } }, // MiniMax - { value: 'minimax-m2.5', label: 'MiniMax M2.5', provider: 'minimax', description: 'Peak performance', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, + { value: 'minimax-m2.7', label: 'MiniMax M2.7', provider: 'minimax', description: 'Latest flagship model with enhanced reasoning and coding', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, + { value: 'minimax-m2.7-highspeed', label: 'MiniMax M2.7 High Speed', provider: 'minimax', description: 'High-speed version of M2.7 for low-latency scenarios', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, + { value: 'minimax-m2.5', label: 'MiniMax M2.5', provider: 'minimax', description: 'Previous generation', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, { value: 'minimax-m2.5-highspeed', label: 'MiniMax M2.5 High Speed', provider: 'minimax', description: 'Fast and agile', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 204800 } }, // Z.AI (Zhipu) { value: 'glm-5', label: 'GLM-5', provider: 'zai', description: 'Flagship', capabilities: { thinking: false, tools: true, vision: false, contextWindow: 128000 } }, @@ -320,9 +322,9 @@ export const PROVIDER_PRESET_DEFINITIONS: Partial