Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

Merge PR #89: add LM Studio provider (neerajdad123-byte)

Salman Qureshidc954808e814
diff --cc .env.example
index 10607578,3d7ec568..d367b6f3
--- a/.env.example
+++ b/.env.example
@@@ -63,9 -53,14 +63,14 @@@ MIMO_MODEL=mimo-v2.5-pr
MIMO_TOKEN_PLAN_API_KEY=
MIMO_TOKEN_PLAN_BASE_URL=https://token-plan-cn.xiaomimimo.com/v1
MIMO_TOKEN_PLAN_MODEL=mimo-v2.5-pro
+
+ # LM Studio (local desktop app, no API key required)
+ LM_STUDIO_BASE_URL=http://127.0.0.1:1234/v1
+ LM_STUDIO_MODEL=
+ LM_STUDIO_ENABLED=false
MIMO_TOKEN_PLAN_ENABLED=false
- # Default provider: deepseek | openai | anthropic | grok | atlascloud | aimlapi | ollamaCloud | ollamaLocal | openaiCompat | mimo | mimoTokenPlan
-# Default provider: deepseek | openai | anthropic | grok | ollamaCloud | ollamaLocal | openaiCompat | mimo | mimoTokenPlan
++# Default provider: deepseek | openai | anthropic | grok | atlascloud | aimlapi | mercuryCloud | ollamaCloud | ollamaLocal | openaiCompat | litellm | lmStudio | mimo | mimoTokenPlan
DEFAULT_PROVIDER=deepseek
# ── Telegram ──
diff --cc src/providers/registry.ts
index 0ef185d4,18495a6f..5a6db3b2
--- a/src/providers/registry.ts
+++ b/src/providers/registry.ts
@@@ -21,12 -18,7 +21,12 @@@ export async function createProvider(pc
// this entirely.
const { OpenAICompatProvider } = await import('./openai-compat.js');
return new OpenAICompatProvider(pc, { useChatApi: true });
- } else if (pc.name === 'ollamaCloud' || pc.name === 'openaiCompat' || pc.name === 'lmStudio') {
+ } else if (pc.name === 'aimlapi') {
+ // OpenAI-compatible gateway. Chat Completions rather than Responses: the
+ // 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') {
++ } else if (pc.name === 'atlascloud' || 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') {
diff --cc src/utils/config.ts
index ba844398,1a9d3818..c9a74b21
--- a/src/utils/config.ts
+++ b/src/utils/config.ts
@@@ -67,21 -57,9 +67,22 @@@ export type ProviderName
| 'openaiCompat'
| 'mimo'
| 'mimoTokenPlan'
+ | 'lmStudio'
| 'chatgptWeb'
- | 'githubCopilot';
+ | 'githubCopilot'
+ | 'litellm';
+
+export interface CloudConfig {
+ enabled: boolean;
+ apiUrl: string;
+ wsUrl: string;
+ jwt: string;
+ refreshToken: string;
+ agentId: string;
+ tier: string;
+ agentApiKey: string;
+ accessKey?: string;
+}
export interface MercuryConfig {
identity: {
@@@ -104,9 -78,9 +105,10 @@@
openaiCompat: ProviderConfig;
mimo: ProviderConfig;
mimoTokenPlan: ProviderConfig;
+ lmStudio: ProviderConfig;
chatgptWeb: ProviderConfig;
githubCopilot: ProviderConfig;
+ litellm: ProviderConfig;
};
channels: {
telegram: {
@@@ -672,12 -461,12 +681,15 @@@ export function isProviderConfigured(pr
if (provider.name === 'ollamaCloud') {
return provider.apiKey.length > 0 && provider.baseUrl.length > 0;
}
- if (provider.name === 'openaiCompat') {
+ if (provider.name === 'atlascloud') {
+ return provider.apiKey.length > 0 && provider.baseUrl.length > 0 && provider.model.length > 0;
+ }
+ if (provider.name === 'openaiCompat' || provider.name === 'litellm') {
return provider.baseUrl.length > 0 && provider.model.length > 0;
}
+ if (provider.name === 'lmStudio') {
+ return provider.baseUrl.length > 0 && provider.model.length > 0;
+ }
if (provider.name === 'chatgptWeb') {
// ChatGPT Web uses browser session auth, not API keys.
// Considered "configured" if enabled with a model selected.
diff --cc src/utils/provider-models.test.ts
index 6295a57d,3ad20f9f..738acda4
--- a/src/utils/provider-models.test.ts
+++ b/src/utils/provider-models.test.ts
@@@ -125,28 -116,24 +125,48 @@@ describe('buildModelCatalog', () =>
expect(catalog.recommendedModel).toBe('model-a');
});
+
+ it('uses the first model as recommended for LM Studio when no preferred list exists', () => {
+ const catalog = buildModelCatalog(
+ 'lmStudio',
+ ['llama-3.2-3b-instruct', 'mistral-7b-instruct-v0.3'],
+ );
+
+ expect(catalog.recommendedModel).toBe('llama-3.2-3b-instruct');
+ expect(catalog.models).toContain('mistral-7b-instruct-v0.3');
+ });
+
+ it('falls back to the current model for LM Studio when no preferred list exists', () => {
+ const catalog = buildModelCatalog(
+ 'lmStudio',
+ ['qwen2.5-7b-instruct'],
+ 'qwen2.5-7b-instruct',
+ );
+
+ expect(catalog.recommendedModel).toBe('qwen2.5-7b-instruct');
+ });
});
+
+describe('fetchProviderModelCatalog', () => {
+ it('excludes non-text Atlas Cloud models using output modality metadata', async () => {
+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response(JSON.stringify({
+ data: [
+ { id: 'qwen/qwen3.5-flash', output_modalities: ['text'] },
+ { id: 'another-chat-model', output_modalities: ['text'] },
+ { id: 'black-forest-labs/flux-kontext-pro', output_modalities: ['image'] },
+ ],
+ }), { status: 200 })));
+
+ const catalog = await fetchProviderModelCatalog('atlascloud', {
+ name: 'atlascloud',
+ apiKey: 'test-key',
+ baseUrl: 'https://api.atlascloud.ai/v1',
+ model: 'qwen/qwen3.5-flash',
+ enabled: true,
+ });
+
+ expect(catalog.recommendedModel).toBe('qwen/qwen3.5-flash');
+ expect(catalog.models).toContain('another-chat-model');
+ expect(catalog.models).not.toContain('black-forest-labs/flux-kontext-pro');
+ });
+});
diff --cc src/utils/provider-models.ts
index f8ccc545,3ac34bec..b3e8e72e
--- a/src/utils/provider-models.ts
+++ b/src/utils/provider-models.ts
@@@ -88,13 -72,14 +88,14 @@@ const MIMO_PREFERRED_MODELS =
const MIMO_TOKEN_PLAN_PREFERRED_MODELS = MIMO_PREFERRED_MODELS;
const OPENAI_COMPAT_PREFERRED_MODELS = [] as const;
+ const LM_STUDIO_PREFERRED_MODELS = [] as const;
const CHATGPT_WEB_PREFERRED_MODELS = [
+ 'gpt-5.6-sol',
+ 'gpt-5.6-terra',
'gpt-5.5',
- 'gpt-5.4',
- 'gpt-5.4-mini',
- 'gpt-5.3-codex',
- 'gpt-5.2',
+ 'gpt-6-astra',
+ 'gpt-5.6-luna',
] as const;
const GITHUB_COPILOT_PREFERRED_MODELS = [
@@@ -124,45 -100,10 +125,46 @@@ export class ProviderModelFetchError ex
}
}
+export function getPreferredModelsForProvider(provider: ProviderName): string[] {
+ const preferredByProvider: Record<ProviderName, readonly string[]> = {
+ mercuryCloud: MERCURY_CLOUD_PREFERRED_MODELS,
+ aimlapi: AIMLAPI_PREFERRED_MODELS,
+ deepseek: DEEPSEEK_PREFERRED_MODELS,
+ openai: OPENAI_PREFERRED_MODELS,
+ anthropic: ANTHROPIC_PREFERRED_MODELS,
+ grok: GROK_PREFERRED_MODELS,
+ atlascloud: ATLASCLOUD_PREFERRED_MODELS,
+ ollamaCloud: OLLAMA_CLOUD_PREFERRED_MODELS,
+ ollamaLocal: OLLAMA_LOCAL_PREFERRED_MODELS,
+ openaiCompat: OPENAI_COMPAT_PREFERRED_MODELS,
+ litellm: OPENAI_COMPAT_PREFERRED_MODELS,
++ lmStudio: LM_STUDIO_PREFERRED_MODELS,
+ mimo: MIMO_PREFERRED_MODELS,
+ mimoTokenPlan: MIMO_TOKEN_PLAN_PREFERRED_MODELS,
+ chatgptWeb: CHATGPT_WEB_PREFERRED_MODELS,
+ githubCopilot: GITHUB_COPILOT_PREFERRED_MODELS,
+ };
+
+ return [...preferredByProvider[provider]];
+}
+
interface OpenAIModelResponse {
- data?: Array<{ id?: string }>;
+ data?: Array<{ id?: string; output_modalities?: string[]; type?: string }>;
}
+/**
+ * AI/ML API lists every surface it serves — chat, images, video, speech,
+ * batches — as separate rows, and the same model id appears once per surface.
+ * `type` names the surface, so the chat set is the rows that carry the
+ * OpenAI-compatible one; `uniq` in `buildModelCatalog` collapses the repeats.
+ *
+ * Filtering by id text the way `isOpenAIChatModel` does cannot work here: ids
+ * are namespaced by lab (`anthropic/claude-sonnet-4.6`, `deepseek/...`), so a
+ * `gpt-`/`o<digit>` rule discards all 353 chat models and the catalogue comes
+ * back empty.
+ */
+const AIMLAPI_CHAT_SURFACE = 'openai/chat-completions';
+
interface AnthropicModelResponse {
data?: Array<{ id?: string }>;
}
@@@ -262,8 -200,8 +264,9 @@@ function chooseRecommendedModel
mimo: MIMO_PREFERRED_MODELS,
mimoTokenPlan: MIMO_TOKEN_PLAN_PREFERRED_MODELS,
chatgptWeb: CHATGPT_WEB_PREFERRED_MODELS,
+ lmStudio: LM_STUDIO_PREFERRED_MODELS,
githubCopilot: GITHUB_COPILOT_PREFERRED_MODELS,
+ litellm: OPENAI_COMPAT_PREFERRED_MODELS,
};
for (const candidate of preferredByProvider[provider]) {
@@@ -305,7 -240,7 +308,8 @@@ export function buildModelCatalog
mimoTokenPlan: MIMO_TOKEN_PLAN_PREFERRED_MODELS,
chatgptWeb: CHATGPT_WEB_PREFERRED_MODELS,
githubCopilot: GITHUB_COPILOT_PREFERRED_MODELS,
+ litellm: OPENAI_COMPAT_PREFERRED_MODELS,
+ lmStudio: LM_STUDIO_PREFERRED_MODELS,
};
const withoutRecommended = filtered.filter((model) => model !== recommendedModel);
diff --cc src/web/api/providers.ts
index 69b1bd2e,8a9d3006..ffc5e933
--- a/src/web/api/providers.ts
+++ b/src/web/api/providers.ts
@@@ -33,7 -26,7 +33,7 @@@ providers.post('/api/providers/:name',
const body = await c.req.json();
const config = loadConfig();
- const validNames: ProviderName[] = ['aimlapi', 'mercuryCloud', 'openai', 'anthropic', 'deepseek', 'grok', 'atlascloud', 'ollamaCloud', 'ollamaLocal', 'openaiCompat', 'litellm', 'mimo', 'mimoTokenPlan'];
- const validNames: ProviderName[] = ['openai', 'anthropic', 'deepseek', 'grok', 'ollamaCloud', 'ollamaLocal'];
++ const validNames: ProviderName[] = ['aimlapi', 'mercuryCloud', 'openai', 'anthropic', 'deepseek', 'grok', 'atlascloud', 'ollamaCloud', 'ollamaLocal', 'openaiCompat', 'litellm', 'lmStudio', 'mimo', 'mimoTokenPlan'];
if (!validNames.includes(providerName)) {
return c.json({ error: 'Unknown provider' }, 400);
}
@@@ -53,18 -46,9 +53,18 @@@ providers.post('/api/providers/:name/te
const config = loadConfig();
const p = config.providers[providerName];
- if (!p || !p.apiKey) {
+ if (!p) {
+ return c.json({ error: 'Provider not found' }, 400);
+ }
+
- // LiteLLM proxies can be keyless - only require baseUrl
- const needsKey = providerName !== 'litellm' && providerName !== 'ollamaLocal';
++ // LiteLLM proxies, local Ollama, and LM Studio are keyless - only require baseUrl
++ const needsKey = providerName !== 'litellm' && providerName !== 'ollamaLocal' && providerName !== 'lmStudio';
+ if (needsKey && !p.apiKey) {
return c.json({ error: 'No API key configured' }, 400);
}
+ if (!needsKey && !p.baseUrl) {
+ return c.json({ error: 'No base URL configured' }, 400);
+ }
try {
const { fetchProviderModelCatalog } = await import('../../utils/provider-models.js');