mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-04-21 04:51:31 +00:00
Move provider authentication status logic out of the CLI auth route so auth checks live with the provider implementations that understand each provider's install and credential model. Add provider-specific auth runtime classes for Claude, Codex, Cursor, and Gemini, and expose them through the shared provider contract as `provider.auth`. Add a provider auth service that resolves providers through the registry and delegates status checks via `auth.getStatus()`. Keep the existing `/api/cli/<provider>/status` endpoints, but make them thin route adapters over the new provider auth service. This removes duplicated route-local credential parsing and makes auth status a first-class provider capability beside MCP and message handling.
32 lines
889 B
TypeScript
32 lines
889 B
TypeScript
import type { IProvider, IProviderAuthRuntime, IProviderMcpRuntime } from '@/shared/interfaces.js';
|
|
import type {
|
|
FetchHistoryOptions,
|
|
FetchHistoryResult,
|
|
LLMProvider,
|
|
NormalizedMessage,
|
|
} from '@/shared/types.js';
|
|
|
|
/**
|
|
* Shared provider base.
|
|
*
|
|
* Concrete providers must expose auth/MCP runtimes and implement message
|
|
* normalization/history loading because those behaviors depend on native
|
|
* SDK/CLI formats.
|
|
*/
|
|
export abstract class AbstractProvider implements IProvider {
|
|
readonly id: LLMProvider;
|
|
abstract readonly mcp: IProviderMcpRuntime;
|
|
abstract readonly auth: IProviderAuthRuntime;
|
|
|
|
protected constructor(id: LLMProvider) {
|
|
this.id = id;
|
|
}
|
|
|
|
abstract normalizeMessage(raw: unknown, sessionId: string | null): NormalizedMessage[];
|
|
|
|
abstract fetchHistory(
|
|
sessionId: string,
|
|
options?: FetchHistoryOptions,
|
|
): Promise<FetchHistoryResult>;
|
|
}
|