UNPKG

taskflow-ai

Version:

TaskFlow AI - 智能PRD文档解析与任务管理助手,支持多模型AI协同、MCP编辑器集成,专为开发团队设计的CLI工具

303 lines (302 loc) 6.28 kB
/** * 配置模式定义 - 定义TaskFlow AI的配置结构和验证规则 * 提供类型安全的配置访问和自动补全 */ import { ConfigValidation } from './config-manager'; /** * 应用配置接口 */ export interface AppConfig { name: string; version: string; environment: 'development' | 'testing' | 'staging' | 'production'; debug: boolean; timezone: string; locale: string; } /** * 服务器配置接口 */ export interface ServerConfig { port: number; host: string; timeout: number; cors: { enabled: boolean; origins: string[]; methods: string[]; credentials: boolean; }; compression: { enabled: boolean; level: number; }; ssl: { enabled: boolean; cert?: string; key?: string; }; } /** * 数据库配置接口 */ export interface DatabaseConfig { host: string; port: number; name: string; username: string; password: string; ssl: boolean; pool: { min: number; max: number; idle: number; acquire: number; }; migrations: { enabled: boolean; directory: string; }; backup: { enabled: boolean; schedule: string; retention: number; }; } /** * 日志配置接口 */ export interface LoggingConfig { level: 'error' | 'warn' | 'info' | 'debug'; format: 'json' | 'text' | 'combined'; console: { enabled: boolean; colorize: boolean; }; file: { enabled: boolean; path: string; maxSize: string; maxFiles: number; compress: boolean; }; remote: { enabled: boolean; endpoint?: string; apiKey?: string; }; } /** * AI模型配置接口 */ export interface AIModelsConfig { default: string; timeout: number; retryCount: number; providers: { [key: string]: { enabled: boolean; apiKey: string; secretKey?: string; baseUrl?: string; model: string; maxTokens: number; temperature: number; topP: number; }; }; loadBalancing: { enabled: boolean; strategy: 'round_robin' | 'least_cost' | 'least_latency' | 'random'; healthCheck: boolean; }; } /** * 缓存配置接口 */ export interface CacheConfig { enabled: boolean; type: 'memory' | 'redis' | 'memcached'; ttl: number; maxSize: number; redis?: { host: string; port: number; password?: string; db: number; }; memcached?: { servers: string[]; }; } /** * 安全配置接口 */ export interface SecurityConfig { jwt: { secret: string; expiresIn: string; algorithm: string; }; encryption: { algorithm: string; key: string; }; rateLimit: { enabled: boolean; windowMs: number; max: number; message: string; }; cors: { enabled: boolean; origins: string[]; }; helmet: { enabled: boolean; options: Record<string, any>; }; } /** * 文件存储配置接口 */ export interface StorageConfig { type: 'local' | 's3' | 'azure' | 'gcp'; local?: { uploadDir: string; maxFileSize: number; allowedTypes: string[]; }; s3?: { bucket: string; region: string; accessKeyId: string; secretAccessKey: string; }; azure?: { connectionString: string; containerName: string; }; gcp?: { projectId: string; keyFilename: string; bucketName: string; }; } /** * 通知配置接口 */ export interface NotificationConfig { email: { enabled: boolean; provider: 'smtp' | 'sendgrid' | 'ses'; smtp?: { host: string; port: number; secure: boolean; auth: { user: string; pass: string; }; }; sendgrid?: { apiKey: string; }; ses?: { region: string; accessKeyId: string; secretAccessKey: string; }; }; slack: { enabled: boolean; webhookUrl?: string; token?: string; channel?: string; }; webhook: { enabled: boolean; urls: string[]; timeout: number; }; } /** * 监控配置接口 */ export interface MonitoringConfig { metrics: { enabled: boolean; interval: number; endpoint: string; }; health: { enabled: boolean; endpoint: string; checks: string[]; }; tracing: { enabled: boolean; serviceName: string; endpoint?: string; }; alerts: { enabled: boolean; thresholds: { errorRate: number; responseTime: number; memoryUsage: number; cpuUsage: number; }; }; } /** * 完整配置接口 */ export interface TaskFlowConfig { app: AppConfig; server: ServerConfig; database: DatabaseConfig; logging: LoggingConfig; aiModels: AIModelsConfig; cache: CacheConfig; security: SecurityConfig; storage: StorageConfig; notification: NotificationConfig; monitoring: MonitoringConfig; } /** * 配置验证规则定义 */ export declare const CONFIG_VALIDATION_RULES: Record<string, ConfigValidation>; /** * 默认配置值 */ export declare const DEFAULT_CONFIG: Partial<TaskFlowConfig>; /** * 配置环境变量映射 */ export declare const ENV_MAPPING: Record<string, string>; /** * 敏感配置键列表(需要加密存储) */ export declare const SENSITIVE_CONFIG_KEYS: string[]; /** * 配置分组定义 */ export declare const CONFIG_GROUPS: { core: string[]; ai: string[]; security: string[]; integrations: string[]; monitoring: string[]; }; /** * 配置优先级定义(数字越大优先级越高) */ export declare const CONFIG_PRIORITY: { environment: number; file: number; database: number; remote: number; memory: number; };