feat: multi-provider support — Anthropic + Ollama (P2-002)

Add ProviderService wrapping Pi SDK's ModelRegistry for multi-provider
LLM support. Built-in providers (Anthropic, OpenAI, Google, xAI, etc.)
auto-discovered; Ollama registered via OLLAMA_BASE_URL env var;
custom providers via MOSAIC_CUSTOM_PROVIDERS JSON env var.

- ProviderService: wraps ModelRegistry, manages provider lifecycle
- ProvidersController: GET /api/providers, GET /api/providers/models
- AgentService: accepts provider/model params on session creation
- ChatGateway: passes optional provider/modelId from chat messages
- @mosaic/types: new provider/model type definitions

Closes #20

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 22:10:18 -05:00
parent aa9ee75a2a
commit 94d6624c01
9 changed files with 287 additions and 11 deletions

View File

@@ -2,3 +2,4 @@ export const VERSION = '0.0.0';
export * from './chat/index.js';
export * from './agent/index.js';
export * from './provider/index.js';

View File

@@ -0,0 +1,54 @@
/** Known built-in LLM provider identifiers */
export type KnownProvider =
| 'anthropic'
| 'openai'
| 'google'
| 'ollama'
| 'xai'
| 'groq'
| 'openrouter'
| 'zai'
| 'mistral';
/** Provider identifier — known providers or custom string */
export type ProviderId = KnownProvider | string;
/** Describes an available LLM model */
export interface ModelInfo {
id: string;
provider: ProviderId;
name: string;
reasoning: boolean;
contextWindow: number;
maxTokens: number;
inputTypes: ('text' | 'image')[];
cost: {
input: number;
output: number;
cacheRead: number;
cacheWrite: number;
};
}
/** Describes an available provider */
export interface ProviderInfo {
id: ProviderId;
name: string;
available: boolean;
models: ModelInfo[];
}
/** Configuration for a custom (non-built-in) provider */
export interface CustomProviderConfig {
id: string;
name: string;
baseUrl: string;
apiKey?: string;
models: Array<{
id: string;
name: string;
reasoning?: boolean;
contextWindow?: number;
maxTokens?: number;
}>;
}