Commit Graph

16 Commits

  • Fixed: #172
    feat(runtime): add Brotli and Zstd compression support, improve response handling
    
    - Implemented Brotli and Zstd decompression handling in `FileRequestLogger` and executor logic for enhanced compatibility.
    - Added `decodeResponseBody` utility for streamlined multi-encoding support (Gzip, Deflate, Brotli, Zstd).
    - Improved resource cleanup with composite readers for proper closure under all conditions.
    - Updated dependencies in `go.mod` and `go.sum` to include Brotli and Zstd libraries.
  • feat: add websocket routing and executor unregister API
    - Introduce Server.AttachWebsocketRoute(path, handler) to mount websocket
      upgrade handlers on the Gin engine.
    - Track registered WS paths via wsRoutes with wsRouteMu to prevent
      duplicate registrations; initialize in NewServer and import sync.
    - Add Manager.UnregisterExecutor(provider) for clean executor lifecycle
      management.
    - Add github.com/gorilla/websocket v1.5.3 dependency and update go.sum.
    
    Motivation: enable services to expose WS endpoints through the core server
    and allow removing auth executors dynamically while avoiding duplicate
    route setup. No breaking changes.
  • Fixed: #140 #133 #80
    feat(translator): add token counting functionality for Gemini, Claude, and CLI
    
    - Introduced `TokenCount` handling across various Codex translators (Gemini, Claude, CLI) with respective implementations.
    - Added utility methods for token counting and formatting responses.
    - Integrated `tiktoken-go/tokenizer` library for tokenization.
    - Updated CodexExecutor with token counting logic to support multiple models including GPT-5 variants.
    - Refined go.mod and go.sum to include new dependencies.
    
    feat(runtime): add token counting functionality across executors
    
    - Implemented token counting in OpenAICompatExecutor, QwenExecutor, and IFlowExecutor.
    - Added utilities for token counting and response formatting using `tiktoken-go/tokenizer`.
    - Integrated token counting into translators for Gemini, Claude, and Gemini CLI.
    - Enhanced multiple model support, including GPT-5 variants, for token counting.
    
    docs: update environment variable instructions for multi-model support
    
    - Added details for setting `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` for version 2.x.x.
    - Clarified usage of `ANTHROPIC_MODEL` and `ANTHROPIC_SMALL_FAST_MODEL` for version 1.x.x.
    - Expanded examples for setting environment variables across different models including Gemini, GPT-5, Claude, and Qwen3.
  • feat(store): introduce GitTokenStore for token persistence via Git backend
    - Added `GitTokenStore` to handle token storage and metadata using Git as a backing storage.
    - Implemented methods for initialization, save, retrieval, listing, and deletion of auth files.
    - Updated `go.mod` and `go.sum` to include new dependencies for Git integration.
    - Integrated support for Git-backed configuration via `GitTokenStore`.
    - Updated server logic to clone, initialize, and manage configurations from Git repositories.
    - Added helper functions for verifying and synchronizing configuration files.
    - Improved error handling and contextual logging for Git operations.
    - Modified Dockerfile to include `config.example.yaml` for initial setup.
    - Added `gitCommitter` interface to handle Git-based commit and push operations.
    - Configured `Watcher` to detect and leverage Git-backed token stores.
    - Implemented `commitConfigAsync` and `commitAuthAsync` methods for asynchronous change synchronization.
    - Enhanced `GitTokenStore` with `CommitPaths` method to support selective file commits.
  • feat(claude-executor): add ZSTD decoding support for Claude executor responses
    - Integrated ZSTD decompression via `github.com/klauspost/compress` for responses with "zstd" content-encoding.
    - Added helper `hasZSTDEcoding` to detect ZSTD-encoded responses.
    - Updated response handling logic to initialize and use a ZSTD decoder when necessary.
    
    refactor(api-handlers): split streaming and non-streaming response handling
    
    - Introduced `handleNonStreamingResponse` for processing non-streaming requests in `ClaudeCodeAPIHandler`.
    - Improved code clarity by separating streaming and non-streaming logic.
    
    fix(service): remove redundant token refresh interval assignment logic in `cliproxy` service.
  • feat(logging): integrate logrus with custom Gin middleware for enhanced request logging and recovery
    - Added `GinLogrusLogger` for structured request logging using Logrus.
    - Implemented `GinLogrusRecovery` to handle panics and log stack traces.
    - Configured log rotation using Lumberjack for efficient log management.
    - Replaced Gin's default logger and recovery middleware with the custom implementations.
  • 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`.
  • Refactor translator packages for OpenAI Chat Completions
    - Renamed `openai` packages to `chat_completions` across translator modules.
    - Introduced `openai_responses_handlers` with handlers for `/v1/models` and OpenAI-compatible chat completions endpoints.
    - Updated constants and registry identifiers for OpenAI response type.
    - Simplified request/response conversions and added detailed retry/error handling.
    - Added `golang.org/x/crypto` for additional cryptographic functions.
  • 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.