feat: agent routing engine — cost/capability matrix (P2-003)

Add RoutingService that selects optimal LLM model based on task type,
cost tier, capability requirements (reasoning, image, context window),
and provider preference. Scoring algorithm ranks all available models.

- RoutingService: route() for best match, rank() for scored list
- POST /api/providers/route and /api/providers/rank endpoints
- Routing types in @mosaic/types (CostTier, TaskType, RoutingCriteria)
- Cost tier classification: cheap (<$1/M), standard (<$10/M), premium

Closes #21

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 22:13:29 -05:00
parent 95f95f54cf
commit 0c29acda14
5 changed files with 208 additions and 4 deletions

View File

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

View File

@@ -0,0 +1,25 @@
/** Cost tier for model selection */
export type CostTier = 'cheap' | 'standard' | 'premium';
/** Task type hint for routing */
export type TaskType = 'chat' | 'coding' | 'analysis' | 'summarization' | 'general';
/** Routing criteria for model selection */
export interface RoutingCriteria {
taskType?: TaskType;
costTier?: CostTier;
requireReasoning?: boolean;
requireImageInput?: boolean;
minContextWindow?: number;
preferredProvider?: string;
preferredModel?: string;
}
/** Result of a routing decision */
export interface RoutingResult {
provider: string;
modelId: string;
modelName: string;
score: number;
reasoning: string;
}