Commit Graph

63 Commits

  • 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(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.
  • refactor(headers): centralize header logic using EnsureHeader utility
    - Introduced `EnsureHeader` in `internal/misc/header_utils.go` to streamline header setting across executors.
    - Updated Codex, Claude, and Gemini executors to utilize `EnsureHeader` for consistent header application.
    - Incorporated Gin context headers (if available) into request header manipulation for better integration.
  • refactor(executor): centralize header application logic for executors
    - Replaced repetitive header setting logic with helper methods (`applyCodexHeaders`, `applyClaudeHeaders`, `applyQwenHeaders`) in Codex, Claude, and Qwen executors.
    - Ensured consistent headers in HTTP requests across all executors.
    - Introduced UUID and additional structured headers for better traceability (e.g., session IDs, metadata).
  • 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.
  • feat(auth): standardize last_refresh metadata handling across executors
    - Added `last_refresh` timestamp to metadata for Codex, Claude, Qwen, and Gemini executors.
    - Implemented `extractLastRefreshTimestamp` utility for parsing diverse timestamp formats in management handlers.
    - Ensured consistent update and preservation of `last_refresh` in file-based auth handling.
  • 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.