Files
mcpctl/.taskmaster/tasks/task_072.md

50 lines
1.6 KiB
Markdown
Raw Normal View History

# Task ID: 72
**Title:** Implement LLMProvider Adapter
**Status:** done
**Dependencies:** 71 ✓
**Priority:** high
**Description:** Create an adapter that wraps the existing ProviderRegistry to implement the StageContext.llm interface, providing stages with a simplified LLM access API.
**Details:**
Create `src/mcplocal/src/proxymodel/llm-adapter.ts`:
```typescript
import type { LLMProvider } from './types';
import type { ProviderRegistry } from '../providers/registry';
export function createLLMAdapter(registry: ProviderRegistry, projectName: string): LLMProvider {
return {
async complete(prompt: string, options?: { system?: string; maxTokens?: number }): Promise<string> {
const provider = registry.getProvider('heavy');
if (!provider) throw new Error('No LLM provider configured');
const messages = options?.system
? [{ role: 'system', content: options.system }, { role: 'user', content: prompt }]
: [{ role: 'user', content: prompt }];
const result = await provider.complete({
messages,
maxTokens: options?.maxTokens ?? 1000,
});
return result.content;
},
available(): boolean {
return registry.getProvider('heavy') !== null;
}
};
}
```
This adapter uses the 'heavy' tier from the existing registry, preserving the project-level LLM configuration.
**Test Strategy:**
Unit test with mocked ProviderRegistry verifying complete() calls are delegated correctly. Test available() returns false when no provider is configured. Integration test with a real provider.