| 8 | * 返回当前可热重载的配置字段(snake_case,过滤 port/proxy/auth_tokens/fingerprint/vision) |
| 9 | */ |
| 10 | export function apiGetConfig(_req: Request, res: Response): void { |
| 11 | const cfg = getConfig(); |
| 12 | res.json({ |
| 13 | cursor_model: cfg.cursorModel, |
| 14 | timeout: cfg.timeout, |
| 15 | max_auto_continue: cfg.maxAutoContinue, |
| 16 | max_history_messages: cfg.maxHistoryMessages, |
| 17 | max_history_tokens: cfg.maxHistoryTokens, |
| 18 | thinking: cfg.thinking !== undefined ? { enabled: cfg.thinking.enabled } : null, |
| 19 | compression: { |
| 20 | enabled: cfg.compression?.enabled ?? false, |
| 21 | level: cfg.compression?.level ?? 1, |
| 22 | keep_recent: cfg.compression?.keepRecent ?? 10, |
| 23 | early_msg_max_chars: cfg.compression?.earlyMsgMaxChars ?? 4000, |
| 24 | }, |
| 25 | tools: { |
| 26 | schema_mode: cfg.tools?.schemaMode ?? 'full', |
| 27 | description_max_length: cfg.tools?.descriptionMaxLength ?? 0, |
| 28 | passthrough: cfg.tools?.passthrough ?? false, |
| 29 | disabled: cfg.tools?.disabled ?? false, |
| 30 | }, |
| 31 | sanitize_response: cfg.sanitizeEnabled, |
| 32 | refusal_patterns: cfg.refusalPatterns ?? [], |
| 33 | logging: cfg.logging ?? { file_enabled: false, dir: './logs', max_days: 7, persist_mode: 'summary', db_enabled: false, db_path: './logs/cursor2api.db' }, |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * POST /api/config |