Commit Graph

14 Commits

  • refactor(executor): dedupe thinking metadata helpers across Gemini executors
    Extract applyThinkingMetadata and applyThinkingMetadataCLI helpers to
    payload_helpers.go and use them across all four Gemini-based executors:
    - gemini_executor.go (Execute, ExecuteStream, CountTokens)
    - gemini_cli_executor.go (Execute, ExecuteStream, CountTokens)
    - aistudio_executor.go (translateRequest)
    - antigravity_executor.go (Execute, ExecuteStream)
    
    This eliminates code duplication introduced in the -reasoning suffix PR
    and centralizes the thinking config application logic.
    
    Net reduction: 28 lines of code.
  • **feat(util): add -reasoning suffix support for Gemini models**
    Adds support for the `-reasoning` model name suffix which enables
    thinking/reasoning mode with dynamic budget. This allows clients to
    request reasoning-enabled inference using model names like
    `gemini-2.5-flash-reasoning` without explicit configuration.
    
    The suffix is normalized to the base model (e.g., gemini-2.5-flash)
    with thinkingBudget=-1 (dynamic) and include_thoughts=true.
    
    Follows the existing pattern established by -nothinking and
    -thinking-N suffixes.
  • feat(claude): add thinking model variants and beta headers support
    - Add Claude thinking model definitions (sonnet-4-5-thinking, opus-4-5-thinking variants)
    - Add Thinking support for antigravity models with -thinking suffix
    - Add injectThinkingConfig() for automatic thinking budget based on model suffix
    - Add resolveUpstreamModel() mappings for thinking variants to actual Claude models
    - Add extractAndRemoveBetas() to convert betas array to anthropic-beta header
    - Update applyClaudeHeaders() to merge custom betas from request body
    
    Closes #324
  • **fix(executor): update antigravity executor to enhance model metadata handling**
    - Added additional metadata fields (`Name`, `Description`, `DisplayName`, `Version`) to `ModelInfo` struct initialization for better model representation.
    - Removed unnecessary whitespace in the code.
  • **fix(translator): reintroduce thoughtSignature bypass logic for model parts**
    - Restored `thoughtSignature` validator bypass for model-specific parts in Gemini content processing.
    - Removed redundant logic from the `executor` for cleaner handling.
  • **chore(executor): update default agent version and simplify const formatting**
    - Updated `defaultAntigravityAgent` to version `1.11.5`.
    - Adjusted const value formatting for improved readability.
    
    **feat(executor): introduce fallback mechanism for Antigravity base URLs**
    
    - Added retry logic with fallback order for Antigravity base URLs to handle request errors and rate limits.
    - Refactored base URL handling with `antigravityBaseURLFallbackOrder` and related utilities.
    - Enhanced error handling in non-streaming and streaming requests with retry support and improved metadata reporting.
    - Updated `buildRequest` to support dynamic base URL assignment.
  • **feat(executor, translator): enhance token handling and payload processing**
    - Improved Antigravity executor to handle `thinkingConfig` adjustments and default `thinkingBudget` when `thinkingLevel` is removed.
    - Updated translator response handling to set default values for output token counts when specific token data is missing.
  • **feat(executor): add model alias mapping and improve Antigravity payload handling**
    - Introduced `modelName2Alias` and `alias2ModelName` functions for mapping between model names and aliases.
    - Improved Antigravity payload transformation to include alias-to-model name conversion.
    - Enhanced processing for Claude Sonnet models to adjust template parameters based on schema presence.
  • **feat(translator): add Antigravity translation logic**
    - Introduced request and response translation functions to enable compatibility between OpenAI Chat Completions API and Antigravity.
    - Registered translation utilities for both streaming and non-streaming scenarios.
    - Added support for reasoning content, tool calls, and metadata handling.
    - Established request normalization and embedding for Antigravity-compatible payloads.
    - Added new fields to `Params` struct for better tracking of finish reasons, usage metadata, and tool usage.
    - Refactored handling of response transitions, final events, and state-driven logic in `ConvertAntigravityResponseToClaude`.
    - Introduced `appendFinalEvents` and `resolveStopReason` helper functions for cleaner separation of concerns.
    - Added `TotalTokenCount` field to `Params` struct for enhanced token tracking.
    - Updated token count calculations to fallback on `TotalTokenCount` when specific counts are missing.
    - Introduced `hasNonZeroUsageMetadata` function to validate presence of token data in `usage_metadata`.
  • **feat(auth, executor, cmd): add Antigravity provider integration**
    - Implemented OAuth login flow for the Antigravity provider in `auth/antigravity.go`.
    - Added `AntigravityExecutor` for handling requests and streaming via Antigravity APIs.
    - Created `antigravity_login.go` command for triggering Antigravity authentication.
    - Introduced OpenAI-to-Antigravity translation logic in `translator/antigravity/openai/chat-completions`.
    
    **refactor(translator, executor): update Gemini CLI response translation and add Antigravity payload customization**
    
    - Renamed Gemini CLI translation methods to align with response handling (`ConvertGeminiCliResponseToGemini` and `ConvertGeminiCliResponseToGeminiNonStream`).
    - Updated `init.go` to reflect these method changes.
    - Introduced `geminiToAntigravity` function to embed metadata (`model`, `userAgent`, `project`, etc.) into Antigravity payloads.
    - Added random project, request, and session ID generators for enhanced tracking.
    - Streamlined `buildRequest` to use `geminiToAntigravity` transformation before request execution.