Commit Graph

16 Commits

  • fix(watcher): improve client reload logic and prevent redundant updates
    - replace debounce timing with content-based change detection using SHA256 hashes
    - skip client reload when auth file content is unchanged
    - handle empty auth files gracefully by ignoring them
    - ensure hash cache is updated only on successful client creation
    - clean up hash cache when clients are removed
  • refactor(watcher): restructure client management and API key handling
    - separate file-based and API key-based clients in watcher
    - improve client reloading logic with better locking and error handling
    - add dedicated functions for building API key clients and loading file clients
    - update combined client map generation to include cached API key clients
    - enhance logging and debugging information during client reloads
    - fix potential race conditions in client updates and removals
  • Refactor client map construction to include all client types and enhance callback updates
    - Added `buildCombinedClientMap` to merge file-based clients with API key and compatibility clients.
    - Updated callbacks to use the combined client map for consistency.
    - Improved error logging and variable naming for clarity in client creation logic.
  • Add support for Codex API key authentication
    - Introduced functionality to handle Codex API keys, including initialization and management via new endpoints in the management API.
    - Updated Codex client to support both OAuth and API key authentication.
    - Documented Codex API key configuration in both English and Chinese README files.
    - Enhanced logging to distinguish between API key and OAuth usage scenarios.
  • Add management API handlers for config and auth file management
    - Implemented CRUD operations for authentication files.
    - Added endpoints for managing API keys, quotas, proxy settings, and other configurations.
    - Enhanced management access with robust validation, remote access control, and persistence support.
    - Updated README with new configuration details.
    
    Fixed OpenAI Chat Completions for codex
  • Enhance client reload process with new OpenAI compatibility support
    - Added handling for OpenAI-compatible providers during client reload.
    - Implemented client unregistration for old clients during reload.
    - Improved logging for detailed client reload insights.
    
    Expand `AuthDir` handling to support tilde (`~`) for home directory resolution
    
    - Added logic to replace `~` with the user's home directory in `AuthDir`.
    - Prevents errors when using `~` in configuration paths.
  • Refactor API handlers to implement retry mechanism with configurable limits and improved error handling
    - Introduced retry counter with a configurable ` RequestRetry ` limit in all handlers.
    - Enhanced error handling with specific HTTP status codes for switching clients.
    - Standardized response forwarding for non-retriable errors.
    - Improved logging for quota and client switch scenarios.
  • 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.
  • Add file watcher for dynamic configuration and client reloading
    - Introduced `Watcher` for monitoring updates to the configuration file and authentication directory.
    - Integrated file watching into `StartService` to handle dynamic changes without restarting.
    - Enhanced API server and handlers to support client and configuration updates.
    - Updated `.gitignore` to include `docs/` directory.
    - Modified go dependencies to include `fsnotify` for the file watcher.