UNPKG

openai-cli-unofficial

Version:

A powerful OpenAI CLI Coding Agent built with TypeScript

202 lines 5.33 kB
import { Language } from '../types/language'; export interface ApiConfig { baseUrl?: string; apiKey?: string; model?: string; contextTokens?: number; maxConcurrency?: number; role?: string; maxToolCalls?: number; terminalSensitiveWords?: string[]; } export type ConfigChangeListener = (config: ApiConfig) => void; export interface McpFunctionConfirmationConfig { [functionName: string]: boolean; } export interface McpServer { url?: string; command?: string; args?: string[]; transport?: string; env?: Record<string, string>; [key: string]: any; } export interface McpConfig { mcpServers: Record<string, McpServer>; } /** * 配置存储服务 * 处理用户偏好设置的持久化 */ export declare class StorageService { private static readonly CONFIG_DIR; private static readonly CONFIG_FILE; private static configChangeListeners; /** * 添加配置变更监听器 */ static onConfigChange(listener: ConfigChangeListener): void; /** * 移除配置变更监听器 */ static removeConfigChangeListener(listener: ConfigChangeListener): void; /** * 通知所有监听器配置已变更 */ private static notifyConfigChange; /** * 确保配置目录存在 */ private static ensureConfigDir; /** * 读取配置文件 */ private static readConfig; /** * 写入配置文件 */ private static writeConfig; /** * 初始化配置文件 * 如果配置文件不存在,则创建一个包含默认值的配置文件 */ static initializeConfig(): void; /** * 获取保存的语言设置 */ static getSavedLanguage(): Language | null; /** * 保存语言设置 */ static saveLanguage(language: Language): void; /** * 获取API配置 */ static getApiConfig(): ApiConfig; /** * 保存API基础地址 */ static saveBaseUrl(baseUrl: string): void; /** * 保存API密钥 */ static saveApiKey(apiKey: string): void; /** * 保存模型 */ static saveModel(model: string): void; /** * 保存上下文token数量 */ static saveContextTokens(contextTokens: number): void; /** * 保存最大并发数 */ static saveMaxConcurrency(maxConcurrency: number): void; /** * 保存最大工具调用次数 */ static saveMaxToolCalls(maxToolCalls: number): void; /** * 保存角色 */ static saveRole(role: string): void; /** * 保存终端敏感词 */ static saveTerminalSensitiveWords(words: string[]): void; /** * 获取MCP配置 */ static getMcpConfig(): McpConfig; /** * 确保系统自带的MCP服务存在 */ private static ensureBuiltInMcpServices; /** * 保存MCP配置 */ static saveMcpConfig(mcpConfig: McpConfig): void; /** * 获取MCP配置的JSON字符串(用于编辑) */ static getMcpConfigJson(): string; /** * 从JSON字符串保存MCP配置 */ static saveMcpConfigFromJson(jsonString: string): void; /** * 批量保存API配置 */ static saveApiConfig(apiConfig: ApiConfig): void; /** * 获取所有配置 */ static getConfig(): Record<string, any>; /** * 设置配置项 */ static setConfig(key: string, value: any): void; /** * 清除所有配置 */ static clearConfig(): void; /** * 检查配置是否存在 */ static hasConfig(): boolean; /** * 验证API配置完整性 */ static validateApiConfig(): { isValid: boolean; missing: string[]; }; /** * 强制更新MCP配置(修复旧配置) */ static updateMcpConfig(): void; /** * 获取系统内置MCP服务列表 */ static getBuiltInMcpServices(): Record<string, McpServer>; /** * 检查并恢复缺失的系统MCP服务 * @param userMcpConfig 用户编辑的MCP配置 * @returns 包含系统服务的完整配置和是否有更新 */ static validateAndRestoreSystemMcpServices(userMcpConfig: McpConfig): { config: McpConfig; hasUpdates: boolean; restoredServices: string[]; }; /** * 检查MCP配置中是否包含受保护的系统服务 * @param mcpConfigJson 用户提供的JSON字符串 * @returns 验证结果 */ static validateMcpConfigJson(mcpConfigJson: string): { isValid: boolean; error?: string; parsedConfig?: McpConfig; hasSystemUpdates?: boolean; restoredServices?: string[]; }; /** * 获取MCP函数确认配置 */ static getMcpFunctionConfirmationConfig(): McpFunctionConfirmationConfig; /** * 保存MCP函数确认配置 */ static saveMcpFunctionConfirmationConfig(confirmationConfig: McpFunctionConfirmationConfig): void; /** * 检查指定函数是否需要确认 */ static isFunctionConfirmationRequired(functionName: string): boolean; /** * 设置指定函数的确认状态 */ static setFunctionConfirmationRequired(functionName: string, required: boolean): void; } //# sourceMappingURL=storage.d.ts.map