11 Commits

  • refactor(proxy): improve SOCKS5 proxy authentication handling
    - Added nil check for proxy user credentials to prevent potential nil pointer dereference.
    - Enhanced authentication logic for SOCKS5 proxies in `proxy_helpers.go` and `proxy.go`.
  • refactor(config): migrate to SDKConfig and streamline proxy handling
    - Replaced `config.Config` with `config.SDKConfig` across components for simpler configuration management.
    - Updated proxy setup functions and handlers to align with `SDKConfig` improvements.
    - Reorganized handler imports to match new SDK structure.
  • Update internal module imports to use v5 package path
    - Updated all `github.com/luispater/CLIProxyAPI/internal/...` imports to point to `github.com/luispater/CLIProxyAPI/v5/internal/...`.
    - Adjusted `go.mod` to specify `module github.com/luispater/CLIProxyAPI/v5`.
  • Add dynamic log level adjustment and "type" field to auth files response
    - Introduced `SetLogLevel` utility function for unified log level management.
    - Updated dynamic log level handling across server and watcher components.
    - Extended auth files response by extracting and including the `type` field from file content.
    - Updated management API documentation with the new `type` field in auth files response.
  • Refactor API handlers organization and simplify error response handling
    - Modularized handlers into dedicated packages (`gemini`, `claude`, `cli`) for better structure.
    - Centralized `ErrorResponse` and `ErrorDetail` types under `handlers` package for reuse.
    - Updated all handlers to utilize the shared `ErrorResponse` model.
    - Introduced specialization of handler structs (`GeminiAPIHandlers`, `ClaudeCodeAPIHandlers`, `GeminiCLIAPIHandlers`) for improved clarity and separation of concerns.
    - Refactored `getClient` logic with additional properties and better state management.
    
    Refactor `translator` package by modularizing code for `claude` and `gemini`
    
    - Moved Claude-specific logic (`PrepareClaudeRequest`, `ConvertCliToClaude`) to `translator/claude/code`.
    - Moved Gemini-specific logic (`FixCLIToolResponse`) to `translator/gemini/cli` for better package structure.
    - Updated affected handler imports and method references.
    
    Add comprehensive package-level documentation across key modules
    
    - Introduced detailed package-level documentation for core modules: `auth`, `client`, `cmd`, `handlers`, `util`, `watcher`, `config`, `translator`, and `api`.
    - Enhanced code readability and maintainability by clarifying the purpose and functionality of each package.
    - Aligned documentation style and tone with existing codebase conventions.
    
    Refactor API handlers and translator modules for improved clarity and consistency
    
    - Standardized handler struct names (`GeminiAPIHandlers`, `ClaudeCodeAPIHandlers`, `GeminiCLIAPIHandlers`, `OpenAIAPIHandlers`) and updated related comments.
    - Fixed unnecessary `else` blocks in streaming logic for cleaner error handling.
    - Renamed variables for better readability (`responseIdResult` to `responseIDResult`, `activationUrl` to `activationURL`, etc.).
    - Addressed minor inconsistencies in API handler comments and SSE header initialization.
    - Improved modularization of `claude` and `gemini` translator components.
    
    Standardize configuration field naming for consistency across modules
    
    - Renamed `ProxyUrl` to `ProxyURL`, `ApiKeys` to `APIKeys`, and `ConfigQuotaExceeded` to `QuotaExceeded`.
    - Updated all relevant references and comments in `config`, `auth`, `api`, `util`, and `watcher`.
    - Ensured consistent casing for `GlAPIKey` debug logs.
  • Refactor API handlers and proxy logic
    - Centralized `getClient` logic into a dedicated function to reduce redundancy.
    - Moved proxy initialization to a new utility function `SetProxy` in `internal/util/proxy.go`.
    - Replaced `Internal` handler with `CLIHandler` in `server.go` for improved clarity and consistency.
    - Removed unused functions and redundant HTTP client setup across the codebase for better maintainability.