From 6d77f8b03db1745c08e319a300737afa7845a86f Mon Sep 17 00:00:00 2001 From: SaladDay <92240037+SaladDay@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:27:34 +0800 Subject: [PATCH] feat(agent): add MiniMax-M4 to agent setup --- src/agent/configurator.ts | 39 +++++++++++++++++++-------------- src/agent/types.ts | 16 ++++++++++++++ test/agent/configurator.test.ts | 28 ++++++++++++++++++----- test/agent/zed.test.ts | 4 ++-- 4 files changed, 63 insertions(+), 24 deletions(-) diff --git a/src/agent/configurator.ts b/src/agent/configurator.ts index 729c3bf4..bbf5c2f7 100644 --- a/src/agent/configurator.ts +++ b/src/agent/configurator.ts @@ -48,7 +48,7 @@ function minimaxModel(modelId: MiniMaxModelId) { } function claudeModelId(modelId: MiniMaxModelId): string { - return modelId === 'MiniMax-M3.1-Flash' || modelId === 'MiniMax-M3' + return modelId === 'MiniMax-M4' || modelId === 'MiniMax-M3.1-Flash' || modelId === 'MiniMax-M3' ? `${modelId}[1m]` : modelId; } @@ -781,7 +781,7 @@ function prepareOpenCode(options: AgentSetupOptions, path: string): PreparedAgen `OpenCode model definition for ${model.id} modalities must be an object.`, ); } - if (model.id === 'MiniMax-M3.1-Flash') { + if (model.id !== 'MiniMax-M3') { const variants = (configuredModel as Record | undefined)?.variants; if (variants !== undefined) { assertObject(variants, `OpenCode model definition for ${model.id} variants must be an object.`); @@ -818,17 +818,19 @@ function prepareOpenCode(options: AgentSetupOptions, path: string): PreparedAgen }, ]; }); - const m31Path = ['provider', 'minimax', 'models', 'MiniMax-M3.1-Flash']; - const m31Updates = [ - { path: [...m31Path, 'interleaved'], value: { field: 'reasoning_content' } }, - { path: [...m31Path, 'variants', 'none', 'disabled'], value: true }, - { path: [...m31Path, 'variants', 'thinking', 'disabled'], value: true }, - { path: [...m31Path, 'variants', 'default', 'reasoningEffort'], value: 'max' }, - ...(['low', 'medium', 'high', 'xhigh', 'max'] as const).map(effort => ({ - path: [...m31Path, 'variants', effort, 'reasoningEffort'], - value: effort, - })), - ]; + const alwaysThinkingUpdates = (['MiniMax-M4', 'MiniMax-M3.1-Flash'] as const).flatMap((id) => { + const modelPath = ['provider', 'minimax', 'models', id]; + return [ + { path: [...modelPath, 'interleaved'], value: { field: 'reasoning_content' } }, + { path: [...modelPath, 'variants', 'none', 'disabled'], value: true }, + { path: [...modelPath, 'variants', 'thinking', 'disabled'], value: true }, + { path: [...modelPath, 'variants', 'default', 'reasoningEffort'], value: 'max' }, + ...(['low', 'medium', 'high', 'xhigh', 'max'] as const).map(effort => ({ + path: [...modelPath, 'variants', effort, 'reasoningEffort'], + value: effort, + })), + ]; + }); return [{ agent: 'opencode', path, @@ -840,7 +842,7 @@ function prepareOpenCode(options: AgentSetupOptions, path: string): PreparedAgen { path: ['provider', 'minimax', 'options', 'apiKey'], value: options.apiKey }, { path: ['provider', 'minimax', 'options', 'setCacheKey'], value: undefined }, ...modelUpdates, - ...m31Updates, + ...alwaysThinkingUpdates, { path: ['model'], value: `minimax/${options.model}` }, ]), }]; @@ -982,6 +984,9 @@ function preparePi(options: AgentSetupOptions, paths: string[]): PreparedAgentFi after: updateJsonc(settings.before, 'Pi settings.json', [ { path: ['defaultProvider'], value: providerId }, { path: ['defaultModel'], value: options.model }, + ...(options.model === 'MiniMax-M4' + ? [{ path: ['defaultThinkingLevel'], value: 'max' }] + : []), ]), }, ]; @@ -1028,7 +1033,7 @@ function prepareOhMyPi(options: AgentSetupOptions, paths: string[]): PreparedAge input: [...model.input], contextWindow: model.contextWindow, maxTokens: model.maxTokens, - ...(model.id === 'MiniMax-M3.1-Flash' ? { + ...(model.id !== 'MiniMax-M3' ? { thinking: { mode: 'anthropic-adaptive', efforts: ['low', 'medium', 'high', 'xhigh', 'max'], @@ -1048,7 +1053,7 @@ function prepareOhMyPi(options: AgentSetupOptions, paths: string[]): PreparedAge } } else { if (root.modelRoles !== undefined) assertObject(root.modelRoles, `${label} modelRoles must be an object.`); - const effort = options.model === 'MiniMax-M3.1-Flash' ? ':max' : ''; + const effort = options.model !== 'MiniMax-M3' ? ':max' : ''; document.setIn(['modelRoles', 'default'], `${providerId}/${options.model}${effort}`); } return { agent: 'oh-my-pi', path, ...existing, after: document.toString() }; @@ -1087,7 +1092,7 @@ function prepareZed(options: AgentSetupOptions, path: string): PreparedAgentFile } // Thinking is always on for MiniMax models; Zed treats "none" as thinking disabled. - const effortFor = (modelId: MiniMaxModelId) => modelId === 'MiniMax-M3.1-Flash' ? 'max' : 'high'; + const effortFor = (modelId: MiniMaxModelId) => modelId !== 'MiniMax-M3' ? 'max' : 'high'; const prefix = ['language_models', 'openai_compatible', 'minimax']; const definitions = MINIMAX_MODELS.map(model => ({ name: model.id, diff --git a/src/agent/types.ts b/src/agent/types.ts index 932a960d..7c2a2888 100644 --- a/src/agent/types.ts +++ b/src/agent/types.ts @@ -31,6 +31,22 @@ export const MINIMAX_MODELS = [ ], }, }, + { + id: 'MiniMax-M4', + contextWindow: 1_000_000, + maxTokens: 131072, + input: ['text', 'image'], + codex: { + defaultReasoningLevel: 'max', + supportedReasoningLevels: [ + { effort: 'low', description: 'Low' }, + { effort: 'medium', description: 'Medium' }, + { effort: 'high', description: 'High' }, + { effort: 'xhigh', description: 'Extra high' }, + { effort: 'max', description: 'Maximum' }, + ], + }, + }, { id: 'MiniMax-M3', contextWindow: 1_000_000, diff --git a/test/agent/configurator.test.ts b/test/agent/configurator.test.ts index b79039e5..1fb93f46 100644 --- a/test/agent/configurator.test.ts +++ b/test/agent/configurator.test.ts @@ -163,6 +163,7 @@ describe('agent configurator', () => { label: 'MiniMax-M3.1-Flash', description: '1M supported', }, + { model: 'MiniMax-M4[1m]', label: 'MiniMax-M4', description: '1M supported' }, { model: 'MiniMax-M3[1m]', label: 'MiniMax-M3', description: '1M supported ยท 1M compact' }, ], replaceBuiltInOptions: false, @@ -182,7 +183,7 @@ describe('agent configurator', () => { readFileSync(join(home, '.codex', 'mmx-model-catalog.json'), 'utf8'), ); expect(codexCatalog._managed_by).toBe('mmx agent setup'); - expect(codexCatalog.models).toHaveLength(2); + expect(codexCatalog.models).toHaveLength(3); expect(codexCatalog.models[0]).toMatchObject({ slug: 'MiniMax-M3.1-Flash', description: 'MiniMax M3.1 Flash', @@ -212,9 +213,16 @@ describe('agent configurator', () => { input_modalities: ['text', 'image'], }); expect(codexCatalog.models[1]).toMatchObject({ - slug: 'MiniMax-M3', + slug: 'MiniMax-M4', description: 'MiniMax', priority: 1, + default_reasoning_level: 'max', + context_window: 1_000_000, + }); + expect(codexCatalog.models[2]).toMatchObject({ + slug: 'MiniMax-M3', + description: 'MiniMax', + priority: 2, base_instructions: 'You are Codex, a coding agent based on MiniMax-M3. ' + "You and the user share the same workspace and collaborate to achieve the user's goals.", shell_type: 'shell_command', @@ -228,8 +236,8 @@ describe('agent configurator', () => { { effort: 'high', description: 'Deep' }, ], }); - expect(codexCatalog.models).toHaveLength(2); - expect(codexCatalog.models[1].apply_patch_tool_type).toBe('freeform'); + expect(codexCatalog.models).toHaveLength(3); + expect(codexCatalog.models[2].apply_patch_tool_type).toBe('freeform'); const m31Home = join(tmpdir(), `mmx-agent-config-m31-${process.pid}-${Date.now()}`); mkdirSync(join(m31Home, '.codex'), { recursive: true }); @@ -275,8 +283,11 @@ describe('agent configurator', () => { for (const effort of ['low', 'medium', 'high', 'xhigh', 'max']) { expect(m31OpenCode.variants[effort].reasoningEffort).toBe(effort); } + expect(openCode.provider.minimax.models['MiniMax-M4'].variants) + .toEqual({ ...m31OpenCode.variants, default: { reasoningEffort: 'max' } }); + expect(openCode.provider.minimax.models['MiniMax-M4'].limit).toEqual({ context: 1_000_000, output: 131072 }); expect(Object.keys(openCode.provider.minimax.models).sort()) - .toEqual(['MiniMax-M3', 'MiniMax-M3.1-Flash', 'keep-model']); + .toEqual(['MiniMax-M3', 'MiniMax-M3.1-Flash', 'MiniMax-M4', 'keep-model']); const hermes = parseYaml(readFileSync(join(home, '.hermes', 'config.yaml'), 'utf8')); expect(hermes.model.provider).toBe('minimax-cn'); @@ -286,6 +297,7 @@ describe('agent configurator', () => { expect(Object.keys(hermes.model_overrides['minimax-cn'])) .toEqual([ 'MiniMax-M3.1-Flash', + 'MiniMax-M4', 'MiniMax-M3', ]); expect(hermes.model_overrides['minimax-cn']['MiniMax-M3'].context_window) @@ -323,8 +335,13 @@ describe('agent configurator', () => { 'keep-model', 'MiniMax-M3', 'MiniMax-M3.1-Flash', + 'MiniMax-M4', ]); expect(piSettings).toMatchObject({ defaultProvider: 'minimax-cn', defaultModel: 'MiniMax-M3' }); + const m4Home = join(tmpdir(), `mmx-agent-config-m4-pi-${process.pid}-${Date.now()}`); + applyAgentConfigurations(prepareAgentConfigurations(setupOptions(['pi'], { homeDir: m4Home, model: 'MiniMax-M4' }))); + expect(JSON.parse(readFileSync(join(m4Home, '.pi', 'agent', 'settings.json'), 'utf8')).defaultThinkingLevel).toBe('max'); + rmSync(m4Home, { recursive: true, force: true }); for (const file of result) { expect(statSync(file.path).mode & 0o777).toBe(0o600); @@ -512,6 +529,7 @@ describe('agent configurator', () => { expect(configured.providers.minimax.models.map((model: { id: string }) => model.id)) .toEqual([ 'MiniMax-M3.1-Flash', + 'MiniMax-M4', 'MiniMax-M3', ]); expect(configured.providers.minimax.models[0]).toMatchObject({ diff --git a/test/agent/zed.test.ts b/test/agent/zed.test.ts index a3f7f6ac..a2308166 100644 --- a/test/agent/zed.test.ts +++ b/test/agent/zed.test.ts @@ -45,7 +45,7 @@ describe('Zed configuration', () => { expect(JSON.stringify(settings)).not.toContain(options.apiKey); const models = provider.available_models; expect(models.map((model: { name: string }) => model.name)) - .toEqual(['keep-model', 'MiniMax-M3', 'MiniMax-M3.1-Flash']); + .toEqual(['keep-model', 'MiniMax-M3', 'MiniMax-M3.1-Flash', 'MiniMax-M4']); expect(models[2]).toMatchObject({ max_tokens: 524288, max_output_tokens: 128000, reasoning_effort: 'max', capabilities: { tools: true, images: true, interleaved_reasoning: true, chat_completions: true }, @@ -68,7 +68,7 @@ describe('Zed configuration', () => { expect(file?.path).toBe(join(xdg, 'zed', 'settings.json')); const settings = parse(file!.after); expect(settings.agent.default_model).toMatchObject({ model: 'MiniMax-M3', effort: 'high' }); - expect(settings.language_models.openai_compatible.minimax.available_models).toHaveLength(2); + expect(settings.language_models.openai_compatible.minimax.available_models).toHaveLength(3); }); it('uses the 1M Flash window when selected', () => {