2846 Commits

Author SHA1 Message Date
Luis Pater
3a13865db8 refactor(home): relocate and rename home plugin status reporting logic
- Moved `reportHomePluginStatus` from `cmd/server` to `internal/home` as `ReportPluginStatus`.
- Updated interface and variable names for consistency.
- Adjusted imports and references in `main.go` and test files to align with the changes.
- Improved code structure for better modularity and reuse.
v7.2.33
2026-06-23 23:27:11 +08:00
Luis Pater
70053beadb feat(auth): refactor credential kind detection and add dynamic source classification
- Introduced `AuthKind` and `AuthSourceKind` methods for improved credential type and source classification.
- Replaced legacy fallback logic with normalized attribute-based handling in `AuthKind`.
- Consolidated metadata inspection for both API key and OAuth attributes.
- Updated calls to replace direct `AccountInfo` usage with `AuthKind` and `AuthSourceKind`.
- Enhanced unit tests to validate explicit and fallback credential resolution scenarios.
2026-06-23 23:21:33 +08:00
Luis Pater
b89c594aac Merge pull request #3973 from router-for-me/home
feat(home): enhance plugin management and synchronization
v7.2.32
2026-06-23 21:59:41 +08:00
hkfires
e9a11db7b9 feat(home): enhance plugin management and synchronization
- Added NodeID field to HomeConfig for better identification.
- Updated ConfigFromJWT to populate NodeID from claims.
- Introduced new Redis keys for managing plugin status and tasks.
- Implemented RPushPluginStatus and GetPluginTasks methods in the client for handling plugin-related data.
- Enhanced Sync functionality to include detailed reporting on plugin installation and deletion tasks.
- Added error handling and reporting for plugin synchronization failures.
- Created tests for new plugin synchronization and management features.
- Improved the overall structure and readability of the plugin synchronization logic.
2026-06-23 20:42:33 +08:00
sususu98
05d1792d43 feat(xai): replay Grok reasoning for Claude messages (#3962)
Add Grok-native reasoning replay for Claude-sourced xAI Responses requests. Replay state is scoped by model and session, normalized to reasoning/function_call/custom_tool_call items, and injected with the same tool-call alignment semantics used by Codex.

Include the minimal Grok encrypted_content validator needed on upstream/dev so replay cache entries cannot accept Codex/GPT, Gemini, or Claude signature shapes. Cache completed output items from HTTP, streaming, and WebSocket xAI responses.

Cover two-turn Claude replay, tool_result continuity, valid Grok cache storage, and rejection of Codex-shaped encrypted_content.
v7.2.31
2026-06-23 14:57:53 +08:00
sususu98
53a21dfb0b [codex] Drop foreign encrypted_content before xAI Grok upstream (#3961)
* Drop foreign encrypted_content before xAI Grok upstream

xAI Grok accepts provider-native encrypted_content as opaque replay state, but GPT/Codex reasoning signatures, Gemini thoughtSignature blobs, and Claude thinking signatures can all travel through OpenAI Responses-style reasoning.encrypted_content while remaining incompatible with xAI. Forwarding those foreign blobs to Grok causes upstream validation failures, especially when the foreign value is high-entropy enough to look ciphertext-like.

Add a Grok encrypted_content transport validator that stays conservative and shape-oriented:

- require unpadded standard base64 with no foreign characters
- reject obvious GPT/Codex gAAAA reasoning signatures before decode
- reject strict Claude thinking signatures in both official E-form and Antigravity R-form
- reject known Gemini thoughtSignature envelopes by reusing the central Gemini validator, covering Gemini 2.5 field-1 and Gemini 3.x field-2 shapes
- require decoded payloads to be long enough and high-entropy enough to look like native Grok ciphertext
- avoid decrypting, protobuf-parsing, or otherwise interpreting native Grok payloads on the hot path

Wire the validator into the xAI Responses request preparation path for reasoning and compaction input items. Invalid encrypted_content fields are deleted before the request is sent upstream, while the surrounding item is preserved and debug logging records only redacted metadata.

Extend coverage with native Grok corpus preservation, Gemini field-1/field-2 rejection, Claude E-form and R-form rejection, invalid-blob sanitizer tests, and compact/websocket replay preservation. The foreign-provider checks are deliberately narrow so high-entropy Grok blobs are not rejected merely because they look random.

* fix(xai): harden encrypted content sanitizer
2026-06-23 14:33:27 +08:00
Luis Pater
f1ed8912bb feat(translator): wrap message-level system roles as user-visible reminders
- Added `ClaudeMessageSystemReminderText` to convert system content into user-readable reminder text.
- Updated translators (Antigravity, Gemini, Codex, OpenAI) to wrap `system` roles as reminders with `<system-reminder>` tags.
- Adjusted related test cases to validate reminder wrapping logic.
v7.2.30
2026-06-23 13:43:14 +08:00
Luis Pater
7c390a7a2e feat(runtime): add Claude Code session handling with caching and tests
- Introduced `ClaudeCodeSessionID` resolution logic, preferring headers over payload metadata.
- Added `ClaudeCodePromptCache` to map sessions to stable prompt cache keys.
- Refactored existing logic to integrate `ClaudeCodePromptCache` for session-based handling.
- Included extensive unit tests to validate session ID extraction, cache reuse, and header prioritization.
2026-06-23 13:19:13 +08:00
Luis Pater
bd646819ed test(translator, runtime): ensure empty text parts are skipped without null values
- Added tests for `ConvertOpenAIRequestToAntigravity` and `ConvertOpenAIRequestToGemini` to verify skipping of empty text parts while maintaining non-null structure.
- Refactored part index logic to correctly handle placement of replay parts in `antigravity_reasoning_replay`.
- Introduced helper functions `antigravityExistingReplayPartPath` and `antigravityReplayPartWritePath` for consistent replay part path management.
v7.2.29
2026-06-23 08:07:03 +08:00
Luis Pater
5d9ea1667b Merge pull request #3963 from router-for-me/home
feat(plugins): sync home plugin manifests
v7.2.28
2026-06-22 22:39:15 +08:00
hkfires
c58da381c7 feat(plugins): sync home plugin manifests 2026-06-22 22:25:44 +08:00
Luis Pater
290f421f9f Merge pull request #3959 from fdreamsu/codex/fix-codex-ws-prefix
Fix Codex WebSocket payload model prefix rewrite / 修复 Codex WebSocket 请求体模型前缀改写
2026-06-22 21:34:12 +08:00
fdreamsu
36ed0e5c9c fix(codex): strip model prefix for websocket payloads
* fix(codex): strip model prefix before sending upstream websocket payloads

* test(codex): assert prefixed downstream models are rewritten for websocket sends
2026-06-22 18:11:06 +08:00
Luis Pater
079ec51f50 feat(cliproxy): optimize API key alias rebuild with deferred execution and caching
- Added `RefreshAPIKeyModelAlias` for explicit alias table rebuilds.
- Introduced deferred rebuild support with `WithDeferredAPIKeyModelAliasRebuild` and context flag validation.
- Implemented `openAICompatibilityRegistrationCache` to streamline OpenAI compatibility model registrations.
- Updated executor and model registration workflows to utilize cached compatibility data, improving efficiency in batch operations.
- Adjusted max worker limits dynamically based on model categories.

Closes: #3953
2026-06-22 08:41:52 +08:00
sususu98
1f2504ebcc fix(claude): bypass signature sanitizer for non-Claude models (#3946)
* fix(claude): bypass signature sanitizer for non-Claude models

* test(claude): use subtests for sanitizer gate model cases
v7.2.27
2026-06-21 23:06:38 +08:00
Luis Pater
369e560f1d feat(api): refactor provider key logic for API key usage and add test for compatibility grouping
- Extracted provider key determination into `apiKeyUsageProviderKey` for reuse and better readability.
- Updated `GetAPIKeyUsage` to utilize the new function.
- Added a new test case to validate compatibility grouping logic via `compat_name` attribute.

Closes: #3940 #3941
v7.2.26
2026-06-21 11:37:52 +08:00
Luis Pater
babef2a1ef feat(cliproxy): add unregisterOpenAICompatExecutor and sync runtime configuration
- Implemented `unregisterOpenAICompatExecutor` to remove OpenAI-compatible executors dynamically.
- Updated `ensureExecutorsForAuth` to unregister incompatible executors while handling plugin candidates.
- Adjusted runtime configuration logic to ensure proper synchronization during updates with `syncPluginModelRuntime`.
v7.2.25
2026-06-21 11:21:05 +08:00
Luis Pater
5bc0c68284 feat(pluginhost): improve error handling with HTTP status codes for plugin calls
- Added `rpcPluginError` to encapsulate plugin errors with HTTP status codes.
- Enhanced `decodeEnvelopeResult` to preserve and return detailed plugin errors with status codes.
- Introduced `isPluginErrorEnvelope` to identify plugin error envelopes.
- Updated plugin call logic in Unix and Windows loaders to differentiate plugin errors from system errors.
- Added unit tests to verify error handling and status code preservation.
v7.2.24
2026-06-21 10:12:10 +08:00
Luis Pater
31549af180 fix(watcher): update Gemini provider name to "gemini-cli" in file synthesizer logic 2026-06-21 09:38:10 +08:00
Luis Pater
1f21f946ba feat(api): implement support for multi-auth expansion in plugin systems
- Added logic to expand single auth JSON payloads into multiple plugin virtual auth records.
- Updated related API endpoints such as `PatchAuthFileStatus` and `DeleteAuthFile` to handle plugin virtual auths with rollback mechanisms.
- Introduced `NormalizePluginOAuthCallbackProvider` and other normalization functions for better handling of OAuth callbacks.
- Enhanced tests to validate multi-auth parsing, rollback behavior, and API response consistency.
v7.2.23
2026-06-21 07:24:29 +08:00
Luis Pater
9a8098d2d5 feat(api): prioritize non-template Codex client models and adjust priority calculation logic
- Added `applyCodexClientNonTemplatePriorities` to assign higher priorities to non-template Codex client models dynamically.
- Implemented `maxCodexClientTemplatePriority` to set base priority for non-template models relative to template models.
- Updated unit tests to validate priority calculation for custom models.
2026-06-21 00:10:03 +08:00
Luis Pater
bb414de33f feat(api): add "max" reasoning depth and service_tiers to Codex client models
- Introduced a new "max" level for reasoning depth in Codex client model configuration, providing maximum problem-solving capability.
- Added `service_tiers` field to model responses for better tier categorization.
- Updated unit tests to validate the inclusion and default behavior of `service_tiers` and the new "max" reasoning depth.
2026-06-20 22:49:43 +08:00
Luis Pater
eb8d0d0684 Merge pull request #3900 from sususu98/fix/antigravity-replay-fc-order-upstream-dev
fix(antigravity): HOME Gemini replay and functionCall ordering before functionResponse
2026-06-20 14:55:48 +08:00
Luis Pater
35c3d80ab9 feat(translator): add support for handling video URLs in Gemini requests
- Updated `ConvertOpenAIRequestToGemini` to process `video_url` message types, extracting and embedding video metadata (MIME type and base64 data) into Gemini request parts.
- Added corresponding unit tests to validate `video_url` handling, ensuring proper extraction and data preservation.

Closes: #3920
v7.2.22
2026-06-20 14:46:39 +08:00
Luis Pater
09179a707f feat(registry): add "max" level and remove deprecated Gemini models
- Added a new "max" level to model `thinking.levels` for enhanced customization.
- Removed deprecated Gemini 3 Pro (High/Low) models and associated fields from the registry.
- Simplified `thinking` attribute structure for `grok-build-0.1` and `grok-composer-2.5-fast` models.

Closes: #3901
2026-06-20 14:22:29 +08:00
Luis Pater
57e1bf97a5 feat(translator): ensure preservation of tool and call IDs in Gemini request and response translations
- Updated `ConvertGeminiRequestToClaude`, `ConvertGeminiRequestToCodex`, and their respective response counterparts to include logic for retaining and using tool/call IDs when present from gateway-provided inputs.
- Enhanced pairing logic between function calls and responses to handle custom and auto-generated IDs consistently.
- Introduced tests validating ID preservation and proper behavior in both streaming and non-streaming flows.

Closes: #3878
2026-06-20 14:12:14 +08:00
Luis Pater
011ffe1dd5 feat(translator): enforce FIFO order in tool call ID consumption for Gemini requests
- Updated `ConvertGeminiRequestToOpenAI` to consume `tool_call_id`s in FIFO order, ensuring consistent mapping between calls and responses.
- Added fallback logic for unmatched or extra function responses to generate unique `tool_call_id`s with a `call_` prefix.
- Introduced comprehensive unit tests to validate order enforcement, distinct ID assignment, and fallback behavior.

Closes: #3874
2026-06-20 14:01:50 +08:00
Luis Pater
5771abbc81 feat(management): add ResetQuota endpoint and auth manager quota reset functionality
- Introduced a new `/reset-quota` API endpoint in the management handler to clear quota and cooldown state for auth records.
- Implemented `ResetQuota` method in the auth manager to handle runtime and registry state resets for affected models.
- Added tests to validate quota reset behavior, including proper state updates and registry consistency.
- Refactored utility functions to support deduplication and registered models handling in quota resets.

Closes: #3866
2026-06-20 13:49:40 +08:00
Luis Pater
b4bec344f6 feat(translator): sanitize parametersJsonSchema in OpenAI to Gemini request handling
- Applied `CleanJSONSchemaForGemini` to ensure compatibility by removing unsupported fields and cleaning schema requirements.
- Added test cases to validate schema transformation, ensuring only necessary `required` fields are retained.
- Enhanced both request and response flows to consistently clean and sanitize tool parameter schemas.

Closes: #3863
2026-06-20 13:34:05 +08:00
Luis Pater
a79ae80f6e feat(registry): improve model fallback logic and refactor Claude model handling
- Replaced internal model-specific constants with exported defaults (`DefaultClaudeMaxInputTokens`, `DefaultClaudeMaxOutputTokens`).
- Refactored Claude model formatting to centralize schema application in `formatHomeClaudeModel`, with fields like `type`, `display_name`, and token limits.
- Added new unit tests for fallback behavior, metadata fields, and token handling in Claude and Gemini models.
- Removed deprecated test coverage for Amp provider model routes.

Closes: #3833
2026-06-20 13:09:44 +08:00
Luis Pater
b0ca3794ad Merge pull request #3834 from dcrdev/main 2026-06-20 12:56:25 +08:00
Luis Pater
790ec307f9 feat(config): add support for rebuild_mid_system_message configuration
- Introduced `RebuildMidSystemMessage` field in config to move system messages into the top-level Claude system field.
- Updated executor to handle mid-system message rebuilding when enabled via config or auth attributes.
- Added unit tests to verify rebuilding behavior and default behavior when disabled.
- Updated configuration example and API handlers to support the new field.

Closes: #3792
2026-06-20 12:15:06 +08:00
Luis Pater
f66376f0b9 feat(auth): add per-auth OAuth model alias support
- Introduced `SetOAuthModelAliasesAttribute` and `OAuthModelAliasesFromAttributes` for managing per-auth model aliases.
- Enhanced OAuth model resolution logic to prioritize per-auth aliases over global aliases.
- Updated metadata handling to extract and sanitize per-account model aliases.
- Added tests to validate alias precedence, empty attributes, and conflict scenarios.

Closes: #3764
2026-06-20 11:31:57 +08:00
Luis Pater
379167c992 feat(translator): add benchmarking for convertSystemRoleToDeveloper with large inputs
- Introduced `BenchmarkConvertSystemRoleToDeveloperLargeInput` to evaluate performance on various input sizes and configurations.
- Improved `convertSystemRoleToDeveloper` logic to optimize JSON rebuilding and reduce unnecessary operations.
- Created helper `makeLargeResponsesInputForBenchmark` to generate test data for performance scenarios.

Closes: #3751
2026-06-20 11:10:53 +08:00
Luis Pater
28e2f9798c feat(executor): add session isolation for grok-composer models
- Introduced `xaiRequiresIsolatedConversation` to enforce session ID generation for `grok-composer` models.
- Updated request preparation logic to handle isolated conversations by setting `prompt_cache_key` and `x-grok-conv-id`.
- Added unit tests with coverage for session isolation, stateless models, and explicit `prompt_cache_key` scenarios.

Closes: #3750
2026-06-20 10:54:16 +08:00
Luis Pater
bc652c7bf0 feat(translator): add support for text.format conversion in OpenAI to Gemini requests
- Implemented `applyOpenAIResponsesTextFormatToGemini` to handle `json_object` and `json_schema` formats.
- Updated generation config to set appropriate `responseMimeType` and optional `responseJsonSchema`.
- Introduced unit tests to validate correct handling of `text.format` conversion scenarios.

Closes: #3721
2026-06-20 10:14:39 +08:00
Luis Pater
75fa62653f feat(executor): normalize parallel_tool_calls based on tools presence
- Added `normalizeCodexParallelToolCallsForTools` to conditionally remove `parallel_tool_calls` when `tools` are missing or empty.
- Integrated normalization into Codex executor workflows for improved request handling.
- Introduced unit tests to validate behavior across different tool scenarios.

Closes: #3903
2026-06-20 09:47:45 +08:00
Luis Pater
4c78e40da4 feat(auth): unify provider key handling with OpenAI compatibility support
- Replaced direct `strings.ToLower` usage with `util.OpenAICompatibleProviderKey` for generating provider keys.
- Updated auth and executor workflows to use namespaced keys for OpenAI-compatible providers.
- Adjusted tests to validate namespaced key handling, including new test cases for provider registration and execution logic.
- Added `OpenAICompatibleProviderKey` helper in `util` for consistent key transformations.

Closes: #3600
v7.2.21
2026-06-20 00:58:20 +08:00
Luis Pater
c44d4fcc7c feat(schema): add removal of $comment and enumDescriptions in JSON schema processing
- Updated JSON schema handling to remove `$comment` and `enumDescriptions` fields during schema transformations.
- Adjusted test cases to validate the removal of these fields both at root and nested levels.
- Expanded unsupported schema keywords to include `$comment` and `enumDescriptions` for Gemini compatibility.

Closes: #3512
2026-06-20 00:22:08 +08:00
Luis Pater
34639c3cf9 feat(translator): defer Codex function call starts until function name is available
- Updated `ConvertCodexResponseToClaude` to delay emitting `function_call` start events until the `name` field is resolved.
- Introduced `pendingCodexFunctionCall` for buffering incomplete function calls.
- Added tests to ensure proper behavior for deferred starts, including argument buffering and finalization.

Closes: #3471
2026-06-20 00:11:12 +08:00
Luis Pater
51aa5ba925 feat(translator): preserve input_audio fields in OpenAI request conversions
- Updated `ConvertOpenAIRequestToGemini` and `ConvertOpenAIRequestToCodex` to handle `input_audio`, retaining `data` and `format` fields.
- Added helper `openAIInputAudioMimeType` for determining MIME types from audio formats.
- Introduced unit tests to validate correct preservation of `input_audio` data and format.

Closes: #3447
2026-06-20 00:03:54 +08:00
Luis Pater
1581700646 chore(deps): bump github.com/jackc/pgx/v5 from v5.7.6 to v5.9.2
Closes: #3420
2026-06-19 23:50:48 +08:00
Luis Pater
1b849b6d8f feat(translator): attach reasoning_content to assistant and tool messages in OpenAI response conversion
- Enhanced `ConvertOpenAIResponsesRequestToOpenAIChatCompletions` to include `reasoning_content` in assistant and tool call messages.
- Introduced `collectOpenAIResponsesReasoningContent` for aggregating reasoning summaries.
- Added tests to validate reasoning attachment in various scenarios, including empty reasoning, tool calls, and reasoning followed by user messages.

Closes: #3397
2026-06-19 21:36:55 +08:00
Luis Pater
041a065b2f Merge branch 'remove-gemini-cli' into dev
# Conflicts:
#	internal/api/handlers/management/auth_files.go
#	internal/thinking/provider/geminicli/apply.go
v7.2.20
2026-06-19 14:40:29 +08:00
Luis Pater
aa2ad995a5 feat(translator): preserve input_image details in OpenAI response conversion
- Updated handling in `ConvertOpenAIResponsesRequestToOpenAIChatCompletions` to retain `input_image` detail fields such as `image_url` and `detail`.
- Added `TestConvertOpenAIResponsesRequestToOpenAIChatCompletions_PreservesInputImageDetail` to verify preservation of image details during transformation.

Closes: #3385
2026-06-19 05:56:25 +08:00
Luis Pater
aed54adbea feat(translator): preserve structured tool_choice in OpenAI response conversions
- Updated `ConvertOpenAIResponsesRequestToOpenAIChatCompletions` to retain `tool_choice` with raw byte handling.
- Added `TestConvertOpenAIResponsesRequestToOpenAIChatCompletions_PreservesStructuredToolChoice` to ensure function and type fields are preserved in transformations.

Closes: #3384
2026-06-19 05:48:57 +08:00
Luis Pater
07c297a51b feat(auth): add persistent cooldown state management with file-backed store
- Introduced `CooldownStateStore` interface for managing independent cooldown state persistence.
- Implemented `FileCooldownStateStore` for storing cooldown states as per-auth `.cds` files with atomic writes and stale file cleanup.
- Enhanced `Manager` to support restoring state from `CooldownStateStore` and persisting state changes during auth updates.
- Updated tests to validate cooldown state saving, loading, concurrency handling, and error scenarios.

Closes: #3368
v7.2.19
2026-06-19 05:34:44 +08:00
Luis Pater
d33ac5e1e9 feat(auth): add transient error cooldown configuration and adjust retry logic
- Introduced `SetTransientErrorCooldownSeconds` to enable configurable cooldowns for transient errors (e.g., 408/500/502/503/504).
- Updated retry scheduling logic to use the new `nextTransientErrorRetryAfter` function.
- Modified config parsing to include `transient-error-cooldown-seconds` with support for disabling or defaulting to legacy behavior.
- Expanded tests to validate transient cooldown logic with various configurations and edge cases.

Closes: #3315
2026-06-19 04:26:04 +08:00
Luis Pater
4926630a60 feat(translator): support namespace tools in OpenAI response transformations
- Added `convertResponsesToolToOpenAIChatTools` and helper methods to handle namespace tools during request conversions.
- Enhanced response handling to restore namespace context for function calls using `applyResponsesFunctionCallNamespaceFields` and related utilities.
- Updated tests to validate namespace flattening, function call restoration, and non-stream response handling.

Closes: #3298
2026-06-19 04:12:51 +08:00
Luis Pater
893412e965 feat(translator): normalize service_tier in Codex requests and add tests
- Added `normalizeCodexServiceTier` to standardize `service_tier` values (`fast` to `priority`, omit unsupported tiers).
- Updated `ConvertClaudeRequestToCodex` to apply normalization logic.
- Introduced `TestConvertClaudeRequestToCodex_ServiceTier` to validate behavior across various `service_tier` inputs.

Closes: #3276 #3294
2026-06-19 03:58:55 +08:00