import type { CollectorConfig, PrivacyConfig } from '../types'; import { EventType } from '../types'; /** * 默认隐私配置 */ export const DEFAULT_PRIVACY_CONFIG: PrivacyConfig = { anonymizeUser: true, obfuscateCode: true, excludePaths: ['*.secret.*', 'node_modules/', '.git/', '*.env*', '*.key', '*.pem'], maxCodeLength: 500, }; /** * 默认采集配置 */ export const DEFAULT_COLLECTOR_CONFIG: CollectorConfig = { enabled: true, samplingRate: 1.0, realtimeEnabled: false, batchSize: 50, flushIntervalSeconds: 60, apiEndpoint: 'http://localhost:8000/api/v1/events', privacy: DEFAULT_PRIVACY_CONFIG, eventsToCapture: [ EventType.CODE_COMPLETION_SHOWN, EventType.CODE_COMPLETION_ACCEPTED, EventType.CODE_COMPLETION_REJECTED, EventType.CHAT_SESSION_START, EventType.CHAT_MESSAGE_SENT, EventType.CHAT_RESPONSE_RECEIVED, EventType.CHAT_SESSION_END, ], }; /** * 支持的编程语言列表 */ export const SUPPORTED_LANGUAGES = [ 'javascript', 'typescript', 'python', 'java', 'go', 'rust', 'cpp', 'c', 'csharp', 'php', 'ruby', 'swift', 'kotlin', 'scala', 'vue', 'react', 'html', 'css', 'sql', 'shell', 'markdown', ] as const; /** * API 版本 */ export const API_VERSION = 'v1'; /** * 插件版本 */ export const PLUGIN_VERSION = '0.1.0'; /** * 本地存储键名 */ export const STORAGE_KEYS = { CONFIG: 'ide-collector-config', USER_ID: 'ide-collector-user-id', EVENT_QUEUE: 'ide-collector-event-queue', LAST_SYNC: 'ide-collector-last-sync', } as const; /** * HTTP 请求超时 (ms) */ export const HTTP_TIMEOUT_MS = 30000; /** * 最大队列长度 */ export const MAX_QUEUE_SIZE = 1000; /** * 敏感词模式 */ export const SENSITIVE_PATTERNS = [ /password\s*[:=]\s*['"][^'"]+['"]/gi, /api[_-]?key\s*[:=]\s*['"][^'"]+['"]/gi, /secret\s*[:=]\s*['"][^'"]+['"]/gi, /token\s*[:=]\s*['"][^'"]+['"]/gi, /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g, // IP 地址 /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, // Email ];