Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
feat(providers): add Runcrate OpenAI-compatible provider preset (#246)
Nirupam Bhowmickbd80329cef9a
diff --git a/.env.example b/.env.exampleindex d367b6f3..15b18ddf 100644--- a/.env.example+++ b/.env.example@@ -33,6 +33,11 @@ ATLASCLOUD_API_KEY=ATLASCLOUD_BASE_URL=https://api.atlascloud.ai/v1ATLASCLOUD_MODEL=qwen/qwen3.5-flash+# Runcrate (OpenAI-compatible API)+RUNCRATE_API_KEY=+RUNCRATE_BASE_URL=https://api.runcrate.ai/v1+RUNCRATE_MODEL=deepseek-ai/DeepSeek-V4.1-Flash+# AI/ML API (OpenAI-compatible API)AIMLAPI_API_KEY=AIMLAPI_BASE_URL=https://api.aimlapi.com/v1@@ -70,7 +75,7 @@ LM_STUDIO_MODEL=LM_STUDIO_ENABLED=falseMIMO_TOKEN_PLAN_ENABLED=false-# Default provider: deepseek | openai | anthropic | grok | atlascloud | aimlapi | mercuryCloud | ollamaCloud | ollamaLocal | openaiCompat | litellm | lmStudio | mimo | mimoTokenPlan+# Default provider: deepseek | openai | anthropic | grok | atlascloud | runcrate | aimlapi | mercuryCloud | ollamaCloud | ollamaLocal | openaiCompat | litellm | lmStudio | mimo | mimoTokenPlanDEFAULT_PROVIDER=deepseek# ── Telegram ──diff --git a/README.md b/README.mdindex 0145cc62..da4d9527 100644--- a/README.md+++ b/README.md@@ -242,6 +242,7 @@ Mercury tries your default provider first and falls back to the others if it fai| Anthropic | `claude-sonnet-4` | `ANTHROPIC_API_KEY` || Grok (xAI) | `grok-4` | `GROK_API_KEY` || Atlas Cloud | `qwen/qwen3.5-flash` | `ATLASCLOUD_API_KEY` |+| Runcrate | `deepseek-ai/DeepSeek-V4.1-Flash` | `RUNCRATE_API_KEY` || AI/ML API | `anthropic/claude-sonnet-4.6` | `AIMLAPI_API_KEY` || MiMo (Xiaomi) | `mimo-v2.5-pro` | `MIMO_API_KEY` || Ollama Cloud | `gpt-oss:120b` | `OLLAMA_CLOUD_API_KEY` |diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 62954515..a0758cd7 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -242,6 +242,7 @@ Mercury 优先使用默认提供方,失败时自动切换到其他提供方。| Anthropic | `claude-sonnet-4` | `ANTHROPIC_API_KEY` || Grok (xAI) | `grok-4` | `GROK_API_KEY` || Atlas Cloud | `qwen/qwen3.5-flash` | `ATLASCLOUD_API_KEY` |+| Runcrate | `deepseek-ai/DeepSeek-V4.1-Flash` | `RUNCRATE_API_KEY` || AI/ML API | `anthropic/claude-sonnet-4.6` | `AIMLAPI_API_KEY` || MiMo(小米) | `mimo-v2.5-pro` | `MIMO_API_KEY` || Ollama Cloud | `gpt-oss:120b` | `OLLAMA_CLOUD_API_KEY` |diff --git a/src/capabilities/mcp/config.ts b/src/capabilities/mcp/config.tsindex 07718589..090edaea 100644--- a/src/capabilities/mcp/config.ts+++ b/src/capabilities/mcp/config.ts@@ -77,7 +77,7 @@ const MERCURY_OWN_SECRETS = new Set(['DISCORD_BOT_TOKEN', 'GEMINI_API_KEY', 'GOOGLE_API_KEY', 'GROK_API_KEY', 'LITELLM_API_KEY', 'LM_STUDIO_API_KEY','MERCURY_CLOUD_ACCESS_KEY', 'MERCURY_CLOUD_AGENT_API_KEY', 'MERCURY_CLOUD_REFRESH_TOKEN', 'MIMO_API_KEY','MIMO_TOKEN_PLAN_API_KEY', 'OLLAMA_CLOUD_API_KEY', 'OPENAI_API_KEY', 'OPENAI_COMPAT_API_KEY', 'OPENROUTER_API_KEY',- 'SLACK_APP_TOKEN', 'SLACK_BOT_TOKEN', 'SPOTIFY_CLIENT_SECRET', 'TELEGRAM_BOT_TOKEN',+ 'RUNCRATE_API_KEY', 'SLACK_APP_TOKEN', 'SLACK_BOT_TOKEN', 'SPOTIFY_CLIENT_SECRET', 'TELEGRAM_BOT_TOKEN',]);function ownSecretWarnings(id: string, server: McpServerConfig): string[] {diff --git a/src/cloud/pairing-flow.ts b/src/cloud/pairing-flow.tsindex 38105198..3952040b 100644--- a/src/cloud/pairing-flow.ts+++ b/src/cloud/pairing-flow.ts@@ -414,7 +414,7 @@ function isProviderConfiguredSafe(p: import('../utils/config.js').ProviderConfigif (!p.enabled) return false;if (p.name === 'ollamaLocal') return p.baseUrl.length > 0 && p.model.length > 0;if (p.name === 'ollamaCloud') return p.apiKey.length > 0 && p.baseUrl.length > 0;- if (p.name === 'atlascloud') return p.apiKey.length > 0 && p.baseUrl.length > 0 && p.model.length > 0;+ if (p.name === 'atlascloud' || p.name === 'runcrate') return p.apiKey.length > 0 && p.baseUrl.length > 0 && p.model.length > 0;if (p.name === 'openaiCompat') return p.baseUrl.length > 0 && p.model.length > 0;if (p.name === 'chatgptWeb' || p.name === 'githubCopilot') return p.model.length > 0;return p.apiKey.length > 0;diff --git a/src/index.ts b/src/index.tsindex 384dce67..666d4f85 100644--- a/src/index.ts+++ b/src/index.ts@@ -203,6 +203,7 @@ const PROVIDER_OPTIONS: Array<{ key: ProviderName; label: string }> = [{ key: 'githubCopilot', label: 'GitHub Copilot' },{ key: 'grok', label: 'Grok (xAI)' },{ key: 'atlascloud', label: 'Atlas Cloud' },+ { key: 'runcrate', label: 'Runcrate' },{ key: 'ollamaCloud', label: 'Ollama Cloud' },{ key: 'ollamaLocal', label: 'Ollama Local' },{ key: 'atomicChat', label: 'Atomic Chat' },@@ -1496,6 +1497,23 @@ async function configure(existingConfig?: MercuryConfig): Promise<void> {continue;}+ if (provider === 'runcrate') {+ const mask = isReconfig && config.providers.runcrate.apiKey ? ` [${maskKey(config.providers.runcrate.apiKey)}]` : '';+ const result = await promptApiKeyWithModelSelection(+ config,+ 'runcrate',+ 'Runcrate',+ chalk.white(` Runcrate API key${mask}${isReconfig ? '' : ' (Enter to skip)'}: `),+ isReconfig,+ );+ if (!result.skipped && result.apiKey && result.model) {+ config.providers.runcrate.apiKey = result.apiKey;+ config.providers.runcrate.model = result.model;+ config.providers.runcrate.enabled = true;+ }+ continue;+ }+if (provider === 'ollamaCloud') {const mask = isReconfig && config.providers.ollamaCloud.apiKey ? ` [${maskKey(config.providers.ollamaCloud.apiKey)}]` : '';const result = await promptApiKeyWithModelSelection(diff --git a/src/providers/provider-meta.ts b/src/providers/provider-meta.tsindex 87d56384..734b8372 100644--- a/src/providers/provider-meta.ts+++ b/src/providers/provider-meta.ts@@ -33,6 +33,7 @@ export const PROVIDER_META: Record<ProviderName, ProviderMeta> = {deepseek: { label: 'DeepSeek', kind: 'cloud', blurb: 'DeepSeek chat and reasoning models.', needsKey: true, needsBaseUrl: false, keyUrl: 'https://platform.deepseek.com/api_keys', keyHint: 'sk-…' },grok: { label: 'Grok (xAI)', kind: 'cloud', blurb: 'Grok models. The same key powers Grok voice.', needsKey: true, needsBaseUrl: false, keyUrl: 'https://console.x.ai', keyHint: 'xai-…' },atlascloud: { label: 'Atlas Cloud', kind: 'gateway', blurb: 'Open models (Qwen, DeepSeek, Llama) on one key.', needsKey: true, needsBaseUrl: false, keyUrl: 'https://www.atlascloud.ai' },+ runcrate: { label: 'Runcrate', kind: 'gateway', blurb: 'Open models (DeepSeek, GLM, Qwen, Kimi) on one key.', needsKey: true, needsBaseUrl: false, keyUrl: 'https://www.runcrate.ai/dashboard/api-keys' },ollamaCloud: { label: 'Ollama Cloud', kind: 'cloud', blurb: 'Large open models hosted by Ollama.', needsKey: true, needsBaseUrl: false, keyUrl: 'https://ollama.com/settings/keys' },ollamaLocal: { label: 'Ollama (this computer)', kind: 'local', blurb: 'Models you run yourself with Ollama. Free and private.', needsKey: false, needsBaseUrl: false },lmStudio: { label: 'LM Studio', kind: 'local', blurb: 'Models served by LM Studio on this computer.', needsKey: false, needsBaseUrl: false },diff --git a/src/providers/registry.ts b/src/providers/registry.tsindex 56ab3868..90f27d95 100644--- a/src/providers/registry.ts+++ b/src/providers/registry.ts@@ -26,7 +26,7 @@ export async function createProvider(pc: ProviderConfig, tokenStore?: import('..// catalogue is mostly third-party models reached through that surface.const { OpenAICompatProvider } = await import('./openai-compat.js');return new OpenAICompatProvider(pc, { useChatApi: true });- } else if (pc.name === 'atlascloud' || pc.name === 'ollamaCloud' || pc.name === 'openaiCompat' || pc.name === 'litellm' || pc.name === 'lmStudio') {+ } else if (pc.name === 'atlascloud' || pc.name === 'runcrate' || pc.name === 'ollamaCloud' || pc.name === 'openaiCompat' || pc.name === 'litellm' || pc.name === 'lmStudio') {const { OpenAICompatProvider } = await import('./openai-compat.js');return new OpenAICompatProvider(pc, { useChatApi: true });} else if (pc.name === 'mimo' || pc.name === 'mimoTokenPlan') {@@ -75,6 +75,7 @@ export class ProviderRegistry {config.providers.anthropic,config.providers.grok,config.providers.atlascloud,+ config.providers.runcrate,config.providers.ollamaCloud,config.providers.ollamaLocal,config.providers.atomicChat,diff --git a/src/utils/config.ts b/src/utils/config.tsindex 52be5691..aa7f5bf9 100644--- a/src/utils/config.ts+++ b/src/utils/config.ts@@ -71,6 +71,7 @@ export type ProviderName =| 'deepseek'| 'grok'| 'atlascloud'+ | 'runcrate'| 'ollamaCloud'| 'ollamaLocal'| 'atomicChat'@@ -115,6 +116,7 @@ export interface MercuryConfig {deepseek: ProviderConfig;grok: ProviderConfig;atlascloud: ProviderConfig;+ runcrate: ProviderConfig;ollamaCloud: ProviderConfig;ollamaLocal: ProviderConfig;atomicChat: ProviderConfig;@@ -396,6 +398,13 @@ export function getDefaultConfig(): MercuryConfig {model: getEnv('ATLASCLOUD_MODEL', 'qwen/qwen3.5-flash'),enabled: getEnvBool('ATLASCLOUD_ENABLED', true),},+ runcrate: {+ name: 'runcrate',+ apiKey: getEnv('RUNCRATE_API_KEY', ''),+ baseUrl: getEnv('RUNCRATE_BASE_URL', 'https://api.runcrate.ai/v1'),+ model: getEnv('RUNCRATE_MODEL', 'deepseek-ai/DeepSeek-V4.1-Flash'),+ enabled: getEnvBool('RUNCRATE_ENABLED', true),+ },ollamaCloud: {name: 'ollamaCloud',apiKey: getEnv('OLLAMA_CLOUD_API_KEY', ''),@@ -815,7 +824,7 @@ export function isProviderConfigured(provider: ProviderConfig): boolean {if (provider.name === 'ollamaCloud') {return provider.apiKey.length > 0 && provider.baseUrl.length > 0;}- if (provider.name === 'atlascloud') {+ if (provider.name === 'atlascloud' || provider.name === 'runcrate') {return provider.apiKey.length > 0 && provider.baseUrl.length > 0 && provider.model.length > 0;}if (provider.name === 'openaiCompat' || provider.name === 'litellm') {diff --git a/src/utils/model-prefs.ts b/src/utils/model-prefs.tsindex 55ae48ce..3a637cbb 100644--- a/src/utils/model-prefs.ts+++ b/src/utils/model-prefs.ts@@ -185,6 +185,7 @@ const PROVIDER_LABELS: Record<string, string> = {litellm: 'LiteLLM',aimlapi: 'AI/ML API',atlascloud: 'Atlas Cloud',+ runcrate: 'Runcrate',mimo: 'MiMo',mimoTokenPlan: 'MiMo Token Plan',githubCopilot: 'GitHub Copilot',diff --git a/src/utils/provider-models.test.ts b/src/utils/provider-models.test.tsindex 38ded914..30b03f17 100644--- a/src/utils/provider-models.test.ts+++ b/src/utils/provider-models.test.ts@@ -96,6 +96,20 @@ describe('buildModelCatalog', () => {expect(catalog.models).toContain('another-chat-model');});+ it('prefers the Runcrate DeepSeek V4.1 Flash model when available', () => {+ const catalog = buildModelCatalog('runcrate', [+ 'moonshotai/Kimi-K2.6',+ 'deepseek-ai/DeepSeek-V4.1-Flash',+ 'zai-org/GLM-5.3-Flash',+ 'another-chat-model',+ ]);++ expect(catalog.recommendedModel).toBe('deepseek-ai/DeepSeek-V4.1-Flash');+ expect(catalog.models[0]).toBe('zai-org/GLM-5.3-Flash');+ expect(catalog.models).toContain('moonshotai/Kimi-K2.6');+ expect(catalog.models).toContain('another-chat-model');+ });+it('falls back to the current Ollama Cloud model when no preferred default is available', () => {const catalog = buildModelCatalog('ollamaCloud',@@ -179,6 +193,33 @@ describe('fetchProviderModelCatalog', () => {expect(catalog.models).toContain('another-chat-model');expect(catalog.models).not.toContain('black-forest-labs/flux-kontext-pro');});++ it('keeps only text-output Runcrate models and sends the key as a bearer token', async () => {+ const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({+ data: [+ { id: 'deepseek-ai/DeepSeek-V4.1-Flash', output_modalities: ['text'] },+ { id: 'zai-org/GLM-5.3-Flash', output_modalities: ['text'] },+ { id: 'Qwen/Qwen-Image', output_modalities: ['image'] },+ { id: 'BAAI/bge-m3', output_modalities: ['embeddings'] },+ { id: 'hexgrad/Kokoro-82M', output_modalities: ['audio'] },+ ],+ }), { status: 200 }));+ vi.stubGlobal('fetch', fetchMock);++ const catalog = await fetchProviderModelCatalog('runcrate', {+ name: 'runcrate',+ apiKey: 'rc_live_test',+ baseUrl: 'https://api.runcrate.ai/v1/',+ model: 'deepseek-ai/DeepSeek-V4.1-Flash',+ enabled: true,+ });++ const [url, init] = fetchMock.mock.calls[0];+ expect(url).toBe('https://api.runcrate.ai/v1/models');+ expect(init.headers).toMatchObject({ Authorization: 'Bearer rc_live_test' });+ expect(catalog.recommendedModel).toBe('deepseek-ai/DeepSeek-V4.1-Flash');+ expect(catalog.models).toEqual(['zai-org/GLM-5.3-Flash']);+ });});describe('chat models only', () => {diff --git a/src/utils/provider-models.ts b/src/utils/provider-models.tsindex 6b8b78b0..2e058b92 100644--- a/src/utils/provider-models.ts+++ b/src/utils/provider-models.ts@@ -59,6 +59,14 @@ const ATLASCLOUD_PREFERRED_MODELS = ['deepseek-ai/deepseek-v4-pro',] as const;+const RUNCRATE_PREFERRED_MODELS = [+ 'deepseek-ai/DeepSeek-V4.1-Flash',+ 'zai-org/GLM-5.3-Flash',+ 'zai-org/GLM-5.3',+ 'Qwen/Qwen3.8-Flash',+ 'moonshotai/Kimi-K2.6',+] as const;+const OLLAMA_CLOUD_PREFERRED_MODELS = ['gpt-oss:120b','gpt-oss:120b-cloud',@@ -136,6 +144,7 @@ export function getPreferredModelsForProvider(provider: ProviderName): string[]anthropic: ANTHROPIC_PREFERRED_MODELS,grok: GROK_PREFERRED_MODELS,atlascloud: ATLASCLOUD_PREFERRED_MODELS,+ runcrate: RUNCRATE_PREFERRED_MODELS,ollamaCloud: OLLAMA_CLOUD_PREFERRED_MODELS,ollamaLocal: OLLAMA_LOCAL_PREFERRED_MODELS,atomicChat: ATOMIC_CHAT_PREFERRED_MODELS,@@ -264,6 +273,7 @@ function chooseRecommendedModel(anthropic: ANTHROPIC_PREFERRED_MODELS,grok: GROK_PREFERRED_MODELS,atlascloud: ATLASCLOUD_PREFERRED_MODELS,+ runcrate: RUNCRATE_PREFERRED_MODELS,ollamaCloud: OLLAMA_CLOUD_PREFERRED_MODELS,ollamaLocal: OLLAMA_LOCAL_PREFERRED_MODELS,atomicChat: ATOMIC_CHAT_PREFERRED_MODELS,@@ -314,6 +324,7 @@ export function buildModelCatalog(anthropic: ANTHROPIC_PREFERRED_MODELS,grok: GROK_PREFERRED_MODELS,atlascloud: ATLASCLOUD_PREFERRED_MODELS,+ runcrate: RUNCRATE_PREFERRED_MODELS,ollamaCloud: OLLAMA_CLOUD_PREFERRED_MODELS,ollamaLocal: OLLAMA_LOCAL_PREFERRED_MODELS,atomicChat: ATOMIC_CHAT_PREFERRED_MODELS,@@ -346,6 +357,8 @@ async function fetchOpenAICompatModels(provider: ProviderName, config: ProviderCerrorMessage = 'Mercury could not fetch models for this Grok key. Please re-enter it.';} else if (provider === 'atlascloud') {errorMessage = 'Mercury could not fetch models for this Atlas Cloud key. Please re-enter it.';+ } else if (provider === 'runcrate') {+ errorMessage = 'Mercury could not fetch models for this Runcrate key. Please re-enter it.';} else if (provider === 'deepseek') {errorMessage = 'Mercury could not fetch models for this DeepSeek key. Please re-enter it.';} else if (provider === 'aimlapi') {@@ -391,6 +404,11 @@ async function fetchOpenAICompatModels(provider: ProviderName, config: ProviderC&& !lower.includes('tts')&& !lower.includes('whisper');}+ if (provider === 'runcrate') {+ // Runcrate lists image, video, audio and embedding models on the same+ // endpoint; each row says what it outputs.+ return id.length > 0 && (outputModalities ?? []).includes('text');+ }return isOpenAIChatModel(id);}).map(({ id }) => id);