mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-04-18 19:41:31 +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.
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import type {
|
|
FetchHistoryOptions,
|
|
FetchHistoryResult,
|
|
LLMProvider,
|
|
McpScope,
|
|
McpTransport,
|
|
NormalizedMessage,
|
|
ProviderMcpServer,
|
|
UpsertProviderMcpServerInput,
|
|
} from '@/shared/types.js';
|
|
|
|
|
|
/**
|
|
* MCP runtime contract for one provider.
|
|
*/
|
|
export interface IProviderMcpRuntime {
|
|
listServers(options?: { workspacePath?: string }): Promise<Record<McpScope, ProviderMcpServer[]>>;
|
|
listServersForScope(scope: McpScope, options?: { workspacePath?: string }): Promise<ProviderMcpServer[]>;
|
|
upsertServer(input: UpsertProviderMcpServerInput): Promise<ProviderMcpServer>;
|
|
removeServer(
|
|
input: { name: string; scope?: McpScope; workspacePath?: string },
|
|
): Promise<{ removed: boolean; provider: LLMProvider; name: string; scope: McpScope }>;
|
|
runServer(
|
|
input: { name: string; scope?: McpScope; workspacePath?: string },
|
|
): Promise<{
|
|
provider: LLMProvider;
|
|
name: string;
|
|
scope: McpScope;
|
|
transport: McpTransport;
|
|
reachable: boolean;
|
|
statusCode?: number;
|
|
error?: string;
|
|
}>;
|
|
}
|
|
|
|
/**
|
|
* Main provider contract for CLI and SDK integrations.
|
|
*
|
|
* Each concrete provider owns its MCP runtime plus the provider-specific logic
|
|
* for converting native events/history into the app's normalized message shape.
|
|
*/
|
|
export interface IProvider {
|
|
readonly id: LLMProvider;
|
|
readonly mcp: IProviderMcpRuntime;
|
|
|
|
normalizeMessage(raw: unknown, sessionId: string | null): NormalizedMessage[];
|
|
fetchHistory(sessionId: string, options?: FetchHistoryOptions): Promise<FetchHistoryResult>;
|
|
}
|