/** * Provider V2 配置接口 * * 定义统一的配置接口,确保与V1配置兼容 */ import type { ModuleConfig } from '../../../modules/pipeline/interfaces/pipeline-interfaces.js'; import type { ProviderType } from './provider-types.js'; import type { DeepSeekProviderRuntimeOptions } from '../contracts/deepseek-provider-contract.js'; /** * 统一Provider配置接口 (与V1 ModuleConfig兼容) */ export interface OpenAIStandardConfig extends ModuleConfig { /** * Provider 模块类型 * * - 'openai-standard' : 兼容老配置的统一 Provider * - 'openai-http-provider' : OpenAI Chat 协议族专用 HTTP Provider * - 'responses-http-provider' : OpenAI Responses 协议族专用 HTTP Provider * - 'anthropic-http-provider' : Anthropic Messages 协议族专用 HTTP Provider * * 说明:为了保持 V1 兼容性,旧路径仍使用 'openai-standard',新装配器会根据 * providerType 选择具体的 *-http-provider 类型。 */ type: 'openai-standard' | 'openai-http-provider' | 'responses-http-provider' | 'anthropic-http-provider' | 'gemini-http-provider' | 'deepseek-http-provider' | 'mimoweb-provider' | 'mock-provider'; config: { providerType: ProviderType; runtimeKey?: string; providerId?: string; baseUrl?: string; timeout?: number; maxRetries?: number; auth: ApiKeyAuth | OAuthAuth; overrides?: ServiceOverrides; extensions?: Record & { deepseek?: Partial; }; }; } /** * API Key认证配置 */ export interface ApiKeyAuth { type: 'apikey'; apiKey: string; headerName?: string; prefix?: string; tokenFile?: string; rawType?: string; mobile?: string; password?: string; accountFile?: string; accountAlias?: string; entries?: Array<{ alias?: string; apiKey?: string; env?: string; secretRef?: string; headerName?: string; prefix?: string; }>; } /** * OAuth认证类型 */ export type OAuthAuthType = 'oauth' | 'gemini-cli-oauth' | `${string}-oauth`; /** * OAuth认证配置 */ export interface OAuthAuth { type: OAuthAuthType; clientId?: string; clientSecret?: string; tokenUrl?: string; deviceCodeUrl?: string; scopes?: string[]; tokenFile?: string; refreshUrl?: string; pkce?: boolean; authorizationUrl?: string; userInfoUrl?: string; } /** * 服务特定覆盖配置 */ export interface ServiceOverrides { baseUrl?: string; defaultModel?: string; headers?: Record; endpoint?: string; timeout?: number; maxRetries?: number; streamIdleTimeoutMs?: number; streamHeadersTimeoutMs?: number; } export interface DeepSeekProviderOverrides extends DeepSeekProviderRuntimeOptions { mobile?: string; password?: string; accountFile?: string; accountAlias?: string; } /** * 认证凭证类型 */ export type AuthCredentials = ApiKeyAuth | OAuthAuth; /** * 服务预设配置 */ export interface ServiceProfile { defaultBaseUrl: string; defaultEndpoint: string; defaultModel: string; requiredAuth: Array<'apikey' | 'oauth'>; optionalAuth: Array<'apikey' | 'oauth'>; headers?: Record; timeout?: number; maxRetries?: number; } /** * 配置验证结果 */ export interface ValidationResult { isValid: boolean; errors: string[]; warnings: string[]; }