Commit Graph

23 Commits

  • Refactor executor error handling and usage reporting
    - Updated the Execute methods in various executors (GeminiCLIExecutor, GeminiExecutor, IFlowExecutor, OpenAICompatExecutor, QwenExecutor) to return a response and error as named return values for improved clarity.
    - Enhanced error handling by deferring failure tracking in usage reporters, ensuring that failures are reported correctly.
    - Improved response body handling by ensuring proper closure and error logging for HTTP responses across all executors.
    - Added failure tracking and reporting in the usage reporter to capture unsuccessful requests.
    - Updated the usage logging structure to include a 'Failed' field for better tracking of request outcomes.
    - Adjusted the logic in the RequestStatistics and Record methods to accommodate the new failure tracking mechanism.
  • Enhance logging for API requests and responses across executors
    - Added detailed logging of upstream request metadata including URL, method, headers, and body for Codex, Gemini, IFlow, OpenAI Compat, and Qwen executors.
    - Implemented error logging for API response failures to capture errors during HTTP requests.
    - Introduced structured logging for authentication details (AuthID, AuthLabel, AuthType, AuthValue) to improve traceability.
    - Updated response logging to include status codes and headers for better debugging.
    - Ensured that all executors consistently log API interactions to facilitate monitoring and troubleshooting.
  • Feature: #103
    feat(gemini): add Gemini thinking configuration support and metadata normalization
    
    - Introduced logic to parse and apply `thinkingBudget` and `include_thoughts` configurations from metadata.
    - Enhanced request handling to include normalized Gemini model metadata, preserving the original model identifier.
    - Updated Gemini and Gemini-CLI executors to apply thinking configuration based on metadata overrides.
    - Refactored handlers to support metadata extraction and cloning during request preparation.
  • feat(registry, executor, util): add support for gemini-2.5-flash-image-preview and improve aspect ratio handling
    - Introduced `gemini-2.5-flash-image-preview` model to the registry with updated definitions.
    - Enhanced Gemini CLI and API executors to handle image aspect ratio adjustments for the new model.
    - Added utility function to create base64 white image placeholders based on aspect ratio configurations.
  • feat(registry/runtime): add Gemini 2.5 model and increase buffer sizes
    - Added new "Gemini 2.5 Flash Image Preview" model definition, with enhanced image generation capabilities.
    - Increased scanner buffer size to 20,971,520 bytes across executors and translators to handle larger payloads.
  • feat(runtime): introduce newProxyAwareHTTPClient for enhanced proxy handling
    - Added `newProxyAwareHTTPClient` to centralize proxy configuration with priority on `auth.ProxyURL` and `cfg.ProxyURL`.
    - Integrated enhanced proxy support across executors for HTTP, HTTPS, and SOCKS5 protocols.
    - Refactored redundant HTTP client initialization to use `newProxyAwareHTTPClient` for consistent behavior.
  • 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.
  • chore(docs): add and refine package-level comments across modules
    - Added detailed package-level comments to improve documentation coverage.
    - Clarified parameter descriptions, return types, and functionality of exported methods across packages.
    - Enhanced overall code readability and API documentation consistency.
  • fix(gemini): handle "[DONE]" chunk, trim "data:" prefix, and remove session_id from requests
    - Adjusted stream handling to skip "[DONE]" chunks.
    - Ensured "data:" prefix is trimmed for non-prefixed input in translation.
    - Removed `session_id` from request bodies before processing.
  • refactor(executor): remove ClientAdapter and legacy fallback logic
    - Deleted `ClientAdapter` implementation and associated fallback methods.
    - Removed legacy executor logic from `codex`, `claude`, `gemini`, and `qwen` executors.
    - Simplified `handlers` by eliminating `UnwrapError` handling and related dependencies.
    - Cleaned up `model_registry` by removing logic associated with suspended clients.
    - Updated `.gitignore` to ignore `.serena/` directory.
  • feat(translators): add token counting support for Claude and Gemini responses
    - Implemented `TokenCount` transform method across translators to calculate token usage.
    - Integrated token counting logic into executor pipelines for Claude, Gemini, and CLI translators.
    - Added corresponding API endpoints and handlers (`/messages/count_tokens`) for token usage retrieval.
    - Enhanced translation registry to support `TokenCount` functionality alongside existing response types.
  • feat(usage): implement usage tracking infrastructure across executors
    - Added `LoggerPlugin` to log usage metrics for observability.
    - Introduced a new `Manager` to handle usage record queuing and plugin registration.
    - Integrated new usage reporter and detailed metrics parsing into executors, covering providers like OpenAI, Codex, Claude, and Gemini.
    - Improved token usage breakdown across streaming and non-streaming responses.
  • feat(gemini-executor): implement CountTokens method with request translation and API integration
    - Added `CountTokens` for token counting requests in Gemini executor.
    - Integrated request translation via `sdktranslator` and response handling.
    - Improved error handling, logging, and API request configuration with headers.
  • feat(executor): add CountTokens support across all executors
    - Introduced `CountTokens` method to Codex, Claude, Gemini, Qwen, OpenAI-compatible, and other executors.
    - Implemented `ExecuteCount` in `AuthManager` for token counting via provider round-robin.
    - Updated handlers to leverage `ExecuteCountWithAuthManager` for streamlined token counting.
    - Added fallback and error handling logic for token counting requests.
  • chore(executor): add debug logging for API request errors
    - Added detailed debug logs in all executors (Codex, Claude, Gemini, Qwen, OpenAI-compatible) to capture HTTP status and response body for failed API requests.
  • chore(logging): add debug logs for executor Refresh methods
    - Introduced `logrus` for structured debugging across all executors.
    - Added debug log messages in `Refresh` methods for better traceability.
    - Updated `Manager` to log additional details during refresh checks.
  • feat: implement token refresh support for executors
    - Added `Refresh` method implementations for Codex, Claude, Gemini, and Qwen executors.
    - Introduced OAuth-based token handling for Gemini and Qwen with support for refresh tokens.
    - Updated Codex and Claude to use new internal auth services.
    - Enhanced metadata structure and consistency for token storage across all executors.
  • refactor: standardize constant naming and improve file-based auth handling
    - Renamed constants from uppercase to CamelCase for consistency.
    - Replaced redundant file-based auth handling logic with the new `util.CountAuthFiles` helper.
    - Fixed various error-handling inconsistencies and enhanced robustness in file operations.
    - Streamlined auth client reload logic in server and watcher components.
    - Applied minor code readability improvements across multiple packages.