export type ProviderType = 'openai' | 'anthropic' | 'response-api'; export * from './lib/password.js'; export * from './lib/paths.js'; export * from './privacy/types.js'; /** * 模型使用限制配置 */ export interface ModelLimit { type: 'requests' | 'input_tokens' | 'cost'; period: 'day' | 'hours' | 'week' | 'month'; periodValue?: number; max: number; } export interface ApiKey { id: string; name: string; key: string; createdAt: number; updatedAt: number; } export interface ProviderConfig { customModel: string; realModel: string; apiKey: string; baseUrl: string; provider: ProviderType; desc?: string; inputPricePer1M?: number; outputPricePer1M?: number; cachedPricePer1M?: number; limits?: ModelLimit[]; hidden?: boolean; maxContextLength?: number; defaultParams?: Record; proxy?: string; } /** * 用户 API Key 配置 */ export interface UserApiKey { name: string; apikey: string; desc?: string; /** 允许使用的模型列表(customModel 名称)。空或 undefined 表示不限制 */ allowedModels?: string[]; } /** * 模型组配置 */ export interface ModelGroup { name: string; models: string[]; desc?: string; } /** * Privacy protection settings */ export interface PrivacySettings { enabled: boolean; stripUserField: boolean; sanitizeFilePaths: boolean; pathPlaceholder: string; whitelistFilter: boolean; } /** * UI 配置设置 */ export interface UiSettings { enabled?: boolean; announcementMarkdown?: string; } export interface ProxyConfig { models: ProviderConfig[]; modelGroups?: ModelGroup[]; adminPassword?: string; apiKeys?: ApiKey[]; userApiKeys?: UserApiKey[]; privacySettings?: PrivacySettings; uiSettings?: UiSettings; detailLogEnabled?: boolean; } /** * 加载并验证配置文件(返回 models 数组) */ export declare function loadConfig(configPath: string): ProviderConfig[]; /** * 加载完整配置(包括 adminPassword) */ export declare function loadFullConfig(configPath: string): ProxyConfig; /** * 根据 customModel 查找 provider */ export declare function findProvider(config: ProviderConfig[], model: string): ProviderConfig | null; /** * 保存配置到文件 */ export declare function saveConfig(config: ProxyConfig, configPath: string): void; /** * 保存配置到文件(旧版本,保持向后兼容) * @deprecated 请使用 saveConfig(config, configPath) */ export declare function saveConfigLegacy(configPath: string, config: ProviderConfig[], adminPassword?: string, apiKeys?: ApiKey[]): void; /** * 创建默认空配置 */ export declare function createDefaultConfig(configPath: string): void; /** * 更新配置项 */ export declare function updateConfigEntry(config: ProviderConfig[], oldCustomModel: string, newEntry: ProviderConfig): ProviderConfig[]; /** * 删除配置项 */ export declare function deleteConfigEntry(config: ProviderConfig[], customModel: string): ProviderConfig[]; /** * 添加 API Key */ export declare function addApiKey(config: ApiKey[], name: string, key: string): ApiKey; /** * 更新 API Key */ export declare function updateApiKey(config: ApiKey[], id: string, updates: Partial>): ApiKey[]; /** * 删除 API Key */ export declare function deleteApiKey(config: ApiKey[], id: string): ApiKey[]; /** * 获取单个 API Key */ export declare function getApiKey(config: ApiKey[], id: string): ApiKey | null; /** * API Key 列表/选项展示类型(不返回 key 明文,只返回脱敏提示) */ export interface ApiKeyOption extends Omit { keyHint: string; } /** * 脱敏显示 API Key:前面显示 *****,只露出最后 4 位 */ export declare function maskApiKey(key: string): string; /** * 获取下拉选项/列表展示(不返回 key 本身,只返回 keyHint 脱敏提示) */ export declare function getApiKeyOptions(config: ApiKey[]): ApiKeyOption[]; export declare function isApiKeyRef(apiKey: string): boolean; export declare function getApiKeyRefName(apiKey: string): string | null; export declare function resolveApiKey(apiKey: string, apiKeys: ApiKey[]): string; //# sourceMappingURL=config.d.ts.map