@@ -25,10 +25,13 @@ export const CLIPROXY_DEFAULT_PORT = 8317;
2525/** Internal API key for CCS-managed requests */
2626export const CCS_INTERNAL_API_KEY = 'ccs-internal-managed' ;
2727
28+ /** Simple secret key for Control Panel login (user-facing) */
29+ export const CCS_CONTROL_PANEL_SECRET = 'ccs' ;
30+
2831/**
2932 * Config version - bump when config format changes to trigger regeneration
3033 * v1: Initial config (port, auth-dir, api-keys only)
31- * v2: Enhanced config (quota-exceeded, request-retry, usage-statistics)
34+ * v2: Full-featured config with dashboard, quota mgmt, simplified key
3235 */
3336export const CLIPROXY_CONFIG_VERSION = 2 ;
3437
@@ -123,36 +126,64 @@ function generateUnifiedConfigContent(port: number = CLIPROXY_DEFAULT_PORT): str
123126 const config = `# CLIProxyAPI config generated by CCS v${ CLIPROXY_CONFIG_VERSION }
124127# Supports: gemini, codex, agy, qwen, iflow (concurrent usage)
125128# Generated: ${ new Date ( ) . toISOString ( ) }
126- # DO NOT EDIT - regenerated by CCS. Use 'ccs doctor' to update.
129+ #
130+ # This config is auto-managed by CCS. Manual edits may be overwritten.
131+ # Use 'ccs doctor' to regenerate with latest settings.
132+
133+ # =============================================================================
134+ # Server Settings
135+ # =============================================================================
127136
128137port: ${ port }
129138debug: false
130- logging-to-file: false
131139
132- # Usage statistics for dashboard analytics
140+ # =============================================================================
141+ # Logging
142+ # =============================================================================
143+
144+ # Write logs to file (stored in ~/.ccs/cliproxy/logs/)
145+ logging-to-file: true
146+
147+ # Log individual API requests for debugging/analytics
148+ request-log: true
149+
150+ # =============================================================================
151+ # Dashboard & Management
152+ # =============================================================================
153+
154+ # Enable usage statistics for CCS dashboard analytics
133155usage-statistics-enabled: true
134156
135- # Management API for CCS dashboard (stats, control panel)
157+ # Remote management API for CCS dashboard integration
136158remote-management:
137- allow-remote: false
138- secret-key: "${ CCS_INTERNAL_API_KEY } "
139- disable-control-panel: true
159+ allow-remote: true
160+ secret-key: "${ CCS_CONTROL_PANEL_SECRET } "
161+ disable-control-panel: false
162+
163+ # =============================================================================
164+ # Reliability & Quota Management
165+ # =============================================================================
140166
141167# Auto-retry on transient errors (403, 408, 500, 502, 503, 504)
142- request-retry: 3
143- max-retry-interval: 30
168+ request-retry: 0
169+ max-retry-interval: 0
144170
145- # Auto-switch accounts on quota exceeded (429) - killer feature for multi-account
171+ # Auto-switch accounts on quota exceeded (429)
172+ # This enables seamless multi-account rotation when rate limited
146173quota-exceeded:
147174 switch-project: true
148175 switch-preview-model: true
149176
150- # CCS internal authentication
177+ # =============================================================================
178+ # Authentication
179+ # =============================================================================
180+
181+ # API keys for CCS internal requests
151182api-keys:
152183 - "${ CCS_INTERNAL_API_KEY } "
153184
154- # OAuth tokens stored in auth/ directory
155- auth-dir: "${ authDir . replace ( / \\ / g, '/' ) } "
185+ # OAuth tokens directory (auto-discovered by CLIProxyAPI)
186+ auth-dir: "${ authDir . replace ( / \\ \\ / g, '/' ) } "
156187` ;
157188
158189 return config ;
@@ -219,7 +250,7 @@ export function regenerateConfig(port: number = CLIPROXY_DEFAULT_PORT): string {
219250}
220251
221252/**
222- * Check if config needs regeneration (version mismatch or missing required fields )
253+ * Check if config needs regeneration (version mismatch)
223254 * @returns true if config should be regenerated
224255 */
225256export function configNeedsRegeneration ( ) : boolean {
@@ -238,20 +269,7 @@ export function configNeedsRegeneration(): boolean {
238269 }
239270
240271 const configVersion = parseInt ( versionMatch [ 1 ] , 10 ) ;
241- if ( configVersion < CLIPROXY_CONFIG_VERSION ) {
242- return true ; // Outdated version
243- }
244-
245- // Check for required fields (v2 features)
246- const hasQuotaExceeded = content . includes ( 'quota-exceeded:' ) ;
247- const hasRequestRetry = content . includes ( 'request-retry:' ) ;
248- const hasUsageStats = content . includes ( 'usage-statistics-enabled: true' ) ;
249-
250- if ( ! hasQuotaExceeded || ! hasRequestRetry || ! hasUsageStats ) {
251- return true ; // Missing required fields
252- }
253-
254- return false ;
272+ return configVersion < CLIPROXY_CONFIG_VERSION ;
255273 } catch {
256274 return true ; // Error reading = regenerate
257275 }
0 commit comments