feat(models): add minimax and moonshot providers
This commit is contained in:
@@ -384,6 +384,68 @@ models:
|
||||
}
|
||||
});
|
||||
|
||||
it('reports WARN when MiniMax has no available API key sources', async () => {
|
||||
const originalKey = process.env.MINIMAX_API_KEY;
|
||||
delete process.env.MINIMAX_API_KEY;
|
||||
|
||||
try {
|
||||
mkdirSync(testDir, { recursive: true });
|
||||
const configPath = join(testDir, 'minimax-missing.yaml');
|
||||
writeFileSync(configPath, `
|
||||
telegram:
|
||||
bot_token: "test-token"
|
||||
allowed_chat_ids: [123]
|
||||
models:
|
||||
default:
|
||||
provider: minimax
|
||||
model: MiniMax-M1
|
||||
`);
|
||||
|
||||
const ctx: DoctorContext = { configPath, dataDir: testDir };
|
||||
const results = await runChecks(ctx);
|
||||
const modelCheck = results.find(r => r.label.includes('Model connectivity')) as CheckResult | undefined;
|
||||
expect(modelCheck?.status).toBe('warn');
|
||||
expect(modelCheck?.detail).toContain('MINIMAX_API_KEY');
|
||||
} finally {
|
||||
if (originalKey) {
|
||||
process.env.MINIMAX_API_KEY = originalKey;
|
||||
} else {
|
||||
delete process.env.MINIMAX_API_KEY;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('reports WARN when Moonshot has no available API key sources', async () => {
|
||||
const originalKey = process.env.MOONSHOT_API_KEY;
|
||||
delete process.env.MOONSHOT_API_KEY;
|
||||
|
||||
try {
|
||||
mkdirSync(testDir, { recursive: true });
|
||||
const configPath = join(testDir, 'moonshot-missing.yaml');
|
||||
writeFileSync(configPath, `
|
||||
telegram:
|
||||
bot_token: "test-token"
|
||||
allowed_chat_ids: [123]
|
||||
models:
|
||||
default:
|
||||
provider: moonshot
|
||||
model: moonshot-v1-8k
|
||||
`);
|
||||
|
||||
const ctx: DoctorContext = { configPath, dataDir: testDir };
|
||||
const results = await runChecks(ctx);
|
||||
const modelCheck = results.find(r => r.label.includes('Model connectivity')) as CheckResult | undefined;
|
||||
expect(modelCheck?.status).toBe('warn');
|
||||
expect(modelCheck?.detail).toContain('MOONSHOT_API_KEY');
|
||||
} finally {
|
||||
if (originalKey) {
|
||||
process.env.MOONSHOT_API_KEY = originalKey;
|
||||
} else {
|
||||
delete process.env.MOONSHOT_API_KEY;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('reports FAIL when Anthropic auth_mode=oauth has no available auth token sources', async () => {
|
||||
const originalHome = process.env.HOME;
|
||||
const originalToken = process.env.ANTHROPIC_AUTH_TOKEN;
|
||||
|
||||
+3
-1
@@ -304,13 +304,15 @@ const checkModelConnectivity: Check = async (ctx) => {
|
||||
}
|
||||
|
||||
// Providers with API-key style auth (no auth store integration yet)
|
||||
const needsKey = ['gemini', 'openrouter', 'vercel', 'xai', 'github'];
|
||||
const needsKey = ['gemini', 'openrouter', 'vercel', 'xai', 'minimax', 'moonshot', 'github'];
|
||||
if (needsKey.includes(provider)) {
|
||||
const envVarMap: Record<string, string> = {
|
||||
gemini: 'GEMINI_API_KEY',
|
||||
openrouter: 'OPENROUTER_API_KEY',
|
||||
vercel: 'AI_GATEWAY_API_KEY',
|
||||
xai: 'XAI_API_KEY',
|
||||
minimax: 'MINIMAX_API_KEY',
|
||||
moonshot: 'MOONSHOT_API_KEY',
|
||||
github: 'GITHUB_TOKEN',
|
||||
};
|
||||
const envVar = envVarMap[provider];
|
||||
|
||||
@@ -75,4 +75,18 @@ describe('setupProviders', () => {
|
||||
expect(config.models.default.endpoint).toBe('https://ai-gateway.vercel.sh/v1');
|
||||
expect(config.models.default.model).toBe('openai/gpt-4.1');
|
||||
});
|
||||
|
||||
it('configures minimax as default provider (second tier)', async () => {
|
||||
// Pick "More providers..." then pick "MiniMax".
|
||||
// Prompts: api key, endpoint, model, then confirm fast tier.
|
||||
const rl = mockReadline(['4', '6', 'sk-minimax-test123', '', '', 'n']);
|
||||
const p = createPrompter(rl);
|
||||
const builder = new ConfigBuilder();
|
||||
await setupProviders(p, builder);
|
||||
const config = builder.build();
|
||||
expect(config.models.default.provider).toBe('minimax');
|
||||
expect(config.models.default.api_key).toBe('sk-minimax-test123');
|
||||
expect(config.models.default.endpoint).toBe('https://api.minimax.io/v1');
|
||||
expect(config.models.default.model).toBe('MiniMax-M1');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,6 +24,8 @@ const SECOND_TIER: ProviderDef[] = [
|
||||
{ name: 'Vercel AI Gateway', provider: 'vercel', defaultModel: 'openai/gpt-4.1', fastModel: 'openai/gpt-4.1-mini', needsApiKey: true, needsEndpoint: true, defaultEndpoint: 'https://ai-gateway.vercel.sh/v1', apiKeyLabel: 'Vercel AI Gateway API key' },
|
||||
{ name: 'Z.AI (GLM)', provider: 'zhipuai', defaultModel: 'glm-4.7', needsApiKey: true, needsEndpoint: true, defaultEndpoint: 'https://api.z.ai/api/paas/v4', apiKeyLabel: 'Z.AI API key' },
|
||||
{ name: 'xAI (Grok)', provider: 'xai', defaultModel: 'grok-3', fastModel: 'grok-3-mini', needsApiKey: true, needsEndpoint: false, apiKeyLabel: 'xAI API key' },
|
||||
{ name: 'MiniMax', provider: 'minimax', defaultModel: 'MiniMax-M1', needsApiKey: true, needsEndpoint: true, defaultEndpoint: 'https://api.minimax.io/v1', apiKeyLabel: 'MiniMax API key' },
|
||||
{ name: 'Moonshot (Kimi)', provider: 'moonshot', defaultModel: 'moonshot-v1-8k', needsApiKey: true, needsEndpoint: true, defaultEndpoint: 'https://api.moonshot.cn/v1', apiKeyLabel: 'Moonshot API key' },
|
||||
{ name: 'Amazon Bedrock', provider: 'bedrock', defaultModel: 'anthropic.claude-sonnet-4-20250514-v1:0', needsApiKey: false, needsEndpoint: false },
|
||||
{ name: 'GitHub Models', provider: 'github', defaultModel: 'claude-sonnet-4-20250514', needsApiKey: false, needsEndpoint: false },
|
||||
];
|
||||
@@ -37,6 +39,8 @@ const PROVIDER_HELP: Record<string, string> = {
|
||||
vercel: 'Vercel AI Gateway uses an API key (AI_GATEWAY_API_KEY) and an OpenAI-compatible base URL (default: https://ai-gateway.vercel.sh/v1)',
|
||||
zhipuai: 'Get your API key at https://z.ai/manage-apikey/apikey-list (Coding Plan endpoint: https://api.z.ai/api/coding/paas/v4)',
|
||||
xai: 'Get your API key at https://console.x.ai',
|
||||
minimax: 'Set MINIMAX_API_KEY (or paste it here) and optionally override endpoint if your deployment uses a custom host',
|
||||
moonshot: 'Set MOONSHOT_API_KEY (or paste it here) and optionally override endpoint if your deployment uses a custom host',
|
||||
bedrock: 'Uses AWS credentials from environment (~/.aws/credentials or IAM role)',
|
||||
github: 'Uses GitHub Copilot — authenticate via OAuth device flow on first use',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user