mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-04-19 12:01:28 +00:00
Move provider-specific normalizeMessage and fetchHistory logic out of the legacy server/providers adapters and into the refactored provider classes so callers can depend on the main provider contract instead of parallel adapter plumbing. Add a providers service to resolve concrete providers through the registry and delegate message normalization/history loading from realtime handlers and the unified messages route. Add shared TypeScript message/history types and normalized message helpers so provider implementations and callers use the same contract. Remove the old adapter registry/files now that Claude, Codex, Cursor, and Gemini implement the required behavior directly.
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { providerRegistry } from '@/modules/providers/provider.registry.js';
|
|
import type {
|
|
FetchHistoryOptions,
|
|
FetchHistoryResult,
|
|
LLMProvider,
|
|
NormalizedMessage,
|
|
} from '@/shared/types.js';
|
|
|
|
/**
|
|
* Application service for provider message operations.
|
|
*
|
|
* Callers pass a provider id and this service resolves the concrete provider
|
|
* class, keeping normalization/history call sites decoupled from implementation
|
|
* file layout.
|
|
*/
|
|
export const providersService = {
|
|
listProviderIds(): LLMProvider[] {
|
|
return providerRegistry.listProviders().map((provider) => provider.id);
|
|
},
|
|
|
|
normalizeMessage(
|
|
providerName: string,
|
|
raw: unknown,
|
|
sessionId: string | null,
|
|
): NormalizedMessage[] {
|
|
return providerRegistry.resolveProvider(providerName).normalizeMessage(raw, sessionId);
|
|
},
|
|
|
|
fetchHistory(
|
|
providerName: string,
|
|
sessionId: string,
|
|
options?: FetchHistoryOptions,
|
|
): Promise<FetchHistoryResult> {
|
|
return providerRegistry.resolveProvider(providerName).fetchHistory(sessionId, options);
|
|
},
|
|
};
|