Commit Graph
1979 Commits
Author SHA1 Message Date
Luis Pater bbef8da454 feat(videos): add video authentication binding and update handler behavior
- Introduced `videoAuthBindingStore` for managing mappings of video IDs to credentials with TTL support.
- Updated video creation and retrieval handlers to bind and utilize credentials for authentication.
- Enhanced response models to include upstream models and adjusted request preparation logic.
- Added test coverage for video auth binding, TTL configuration, and expiration handling.
2026-06-15 13:38:40 +08:00
Luis Pater f85768eef3 feat(auth): add config API key exclusion management with tests
- Implemented helper methods `IsConfigAPIKeyAuth` and `toggleConfigAPIKeyExcludedAll` for managing config API key exclusions.
- Updated API request handling to support enabling/disabling config API key exclusion patterns.
- Added test coverage to validate exclusion toggling logic and persistence behavior.
- Refactored duplicate code for identifying config API key auth entries into reusable utilities.
2026-06-15 11:14:05 +08:00
Luis Pater f33bc56bb9 feat(websockets): add transcript state tracking and compaction trigger support
- Added methods for managing and tracking WebSocket transcript state, including recording, prepending, and replacing transcript inputs.
- Implemented `executeCompactionTriggerFromWebsocketContext` to support compaction triggers using recorded transcript context.
- Enhanced upstream-downstream ID mapping with additional utilities and state synchronization.
- Expanded test coverage to validate transcript state management, compaction payload generation, and WebSocket response handling.
2026-06-15 10:41:35 +08:00
Luis Pater ea90ab6f77 feat(websockets): implement XAIWebsocketsExecutor with enhanced execution and ID mapping
- Developed `XAIWebsocketsExecutor` for handling xAI Responses via WebSocket transport.
- Introduced session and state management with `codexWebsocketSessionStore` and `xaiWebsocketIDStateStore`.
- Added robust ID mapping for upstream and downstream request/response sequences.
- Enhanced error propagation and handling of WebSocket terminal events.
- Included utility methods for WebSocket request preparation, connection management, and state tracking.
- Added foundational support for compact and streamed responses via enhanced session tracking.
2026-06-15 08:22:07 +08:00
Luis Pater 7de9757c82 feat: add OpenAI video support with improved error handling and response normalization
- Introduced `/openai/v1/videos` endpoint to support OpenAI-specific video generation.
- Added error normalization and handling for OpenAI video resources, including detailed error propagation.
- Enhanced response structure to include OpenAI-specific fields for status, progress, and model mappings.
- Implemented new handlers for video content retrieval and error scenarios.
- Expanded test coverage to validate OpenAI video support, error handling, and backend compatibility.
2026-06-15 01:53:52 +08:00
Supra4E8C ea4e978c60 Merge pull request #3848 from router-for-me/feat/Community_Plugins
Feat/community plugins
2026-06-15 01:22:55 +08:00
LTbinglingfeng 6f3bd7641b feat(pluginstore): improve nil checks in pluginStoreSnapshot function 2026-06-15 01:21:07 +08:00
Luis Pater 3b96119050 feat(websockets): handle terminal events and improve error propagation
- Enhanced Codex Websockets Executor to capture `response.done` as a terminal event, alongside `response.completed` and `error`.
- Improved error propagation for upstream websocket errors with comprehensive message handling.
- Introduced utility functions for recognizing terminal events and extracting error messages.
- Expanded tests to validate new websocket event logic, including terminal event handling and upstream error propagation.
2026-06-15 01:03:19 +08:00
LTbinglingfeng 239d7ee0b0 feat(pluginstore): refactor plugin store source handling to use string URLs 2026-06-15 00:54:32 +08:00
LTbinglingfeng 303c0f2f53 feat(pluginstore): add support for third-party plugin store sources and enhance plugin management 2026-06-15 00:50:22 +08:00
Luis Pater 529d9e92c9 feat(executor): add support for compact response handling in XAIExecutor
- Introduced `executeCompact` to handle non-streaming compact responses via the `/responses/compact` endpoint.
- Added `executeCompactionTriggerStream` for streaming responses triggered by `compaction_trigger`.
- Enhanced request preparation with `prepareResponsesRequestTo` for dynamic response formats.
- Updated logic to bypass streaming for `/responses/compact` and added fallback behaviors.
- Added comprehensive tests for compact response handling and event streaming validations.
2026-06-15 00:29:38 +08:00
Luis Pater 6f923a28f7 feat(pluginhost): implement host authentication callbacks and add tests
- Introduced `auth_callbacks` for handling host authentication list, get, runtime, and save operations.
- Added extensive unit tests to validate functionality, including disk fallback and runtime-specific cases.
- Created example implementation in Go to demonstrate host callback integrations.
2026-06-14 23:51:40 +08:00
hkfires b5da088767 fix(home): forward credentials for home models 2026-06-14 22:09:29 +08:00
Luis Pater 2a050dc95d feat: enhance fault tolerance for kv-based caching and introduce additional tests
- Updated Antigravity Credits fallback to handle KV store unavailability as a service error.
- Enhanced signature caching mechanisms with request-time KV access and sliding expiration.
- Added and improved tests for KV client interactions, including error handling and expiration behaviors.
- Introduced `CacheSignatureBestEffort` for non-critical signature caching and clarified function flows with required context.
- Ensured consistent error reporting for missing or unavailable KV stores in various scenarios.
- Replaced direct `homekv` calls with injectable KV client interfaces for `antigravity` and `codex_reasoning_replay` modules.
- Improved error reporting and handling for KV operations, including `KVGet`, `KVSet`, `KVDel`, and `KVExpire`.
- Introduced dedicated fake KV clients for expanded and granular test coverage.
- Added new unit tests to validate KV client behaviors and error scenarios, ensuring robustness and sliding expiration functionality.
2026-06-14 21:11:35 +08:00
hkfires 79db0e54be refactor(api): remove deprecated route module interfaces 2026-06-14 20:45:23 +08:00
hkfires b4054e185e refactor(config): remove legacy migration code 2026-06-14 20:36:54 +08:00
hkfires 8122b9fe4b feat!: remove amp integration support
BREAKING CHANGE: ampcode configuration, management endpoints, provider
routing, and X-Amp-Thread-Id session affinity are no longer supported
2026-06-14 20:31:00 +08:00
Luis Pater 964e86f612 Merge pull request #3827 from iamkhalidbashir/add-kimi-k2.7-code
feat: add Kimi K2.7 Code model (kimi-k2.7-code)
2026-06-14 05:43:53 +08:00
Luis Pater eebb873b8a Merge pull request #3832 from haowang02/feat/disable-image-generation-passthrough
feat(config): add "passthrough" mode for disable-image-generation
2026-06-14 05:21:44 +08:00
Luis Pater 6d472d7b4f feat(models): increase context_length for Composer 2.5 Fast to 200,000 2026-06-14 02:27:08 +08:00
Hao WangandClaude Opus 4.8 8d4a7f1f2e feat(config): add "passthrough" mode for disable-image-generation
Adds a fourth value for the disable-image-generation setting:

- false:       inject image_generation (unchanged)
- true:        strip everywhere + 404 on /v1/images/* (unchanged)
- chat:        strip on non-images endpoints, keep /v1/images/* (unchanged)
- passthrough: never inject and never strip on non-images endpoints
               (the client payload is forwarded unchanged); behaves like
               "chat" on /v1/images/* endpoints.

image_generation injection (codex executors) is already gated on the Off
mode, and the /v1/images/* 404 gate is already gated on the All mode, so
passthrough only required a change to the payload strip logic in
payload_helpers.go, now expressed via shouldStripImageGeneration().

Closes #3831

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-13 22:41:15 +08:00
LTbinglingfeng 9cdb18e1d6 refactor(plugin): remove timeout handling from plugin installation logic 2026-06-13 21:14:06 +08:00
LTbinglingfeng b39ee66250 Add plugin store install timeout 2026-06-13 20:56:49 +08:00
LTbinglingfeng c5cfdb15e5 Add plugin delete management endpoint 2026-06-13 20:52:07 +08:00
Luis Pater d6c4fc2d82 feat(translator): consolidate mid-conversation system messages into initial system content
- Updated `ConvertClaudeRequestToOpenAI` to move mid-conversation `system` messages to the initial system content.
- Added a new test case `TestConvertClaudeRequestToOpenAI_MidConversationSystemMessagesMoveToInitialSystem` to validate functionality.
- Refactored logic for appending system message content for improved readability and maintainability.

Closes: #3815
2026-06-13 16:17:36 +08:00
Khalid Bashir 82235202fb feat: add Kimi K2.7 Code model (kimi-k2.7-code)
Add kimi-k2.7-code to the model registry with:
- 262K context length, 65K max completion tokens
- Thinking support (dynamic, 1024-32000 budget)
- zero_allowed=false (K2.7 Code does not support non-thinking mode)

Closes #3826
2026-06-13 13:14:16 +05:00
sususu98 48dcadd9ef feat(antigravity): bridge Claude WebSearch to native googleSearch
Add a native Antigravity WebSearch path for Claude typed WebSearch requests.

Detect Claude Messages requests whose tools are only typed WebSearch tools
(web_search_20250305 / web_search_20260209), and convert them into an
Antigravity requestType=web_search payload instead of sending the request
through the normal tool-calling path.

Preserve the user's requested model. The native path is enabled only when that
Antigravity model is known to support Google Search. Capability data fetched
from Antigravity model info is used only as an enhancement to the local model
registry, not as a replacement for the existing registry fallback behavior.
Unsupported models keep the existing Antigravity request behavior and are not
silently rerouted to another web-search-capable model.

Translate Claude WebSearch request options to the verified Antigravity
googleSearch shape:
- max_uses -> googleSearch.enhancedContent.imageSearch.maxResultCount
- allowed_domains -> googleSearch.includedDomains

Leave blocked_domains and user_location unmapped because the Antigravity
googleSearch request shape has no verified equivalent for them. This avoids
sending speculative fields or pretending unsupported Claude WebSearch options
are enforced upstream.

Translate Antigravity web-search responses back into Claude-compatible output:
server_tool_use blocks, web_search_tool_result blocks, cited text blocks,
grounding URLs, and usage-compatible stream/non-stream responses.

Cover the behavior with tests for request conversion, response conversion,
grounding URL resolution, domain filter mapping, fetched capability hints,
excluded-model handling, and unsupported-model behavior.
2026-06-13 10:07:48 +08:00
LTbinglingfeng 7cd5b15c9b fix: precompute exposed CORS headers 2026-06-13 05:59:18 +08:00
LTbinglingfeng 2659e490a8 fix: expose plugin support header for CORS 2026-06-13 05:53:19 +08:00
LTbinglingfeng 4f5f1b8f2b fix(plugins): guard config read with mutex 2026-06-13 05:05:49 +08:00
LTbinglingfeng b60ec43944 fix(plugins): expose saved plugin config 2026-06-13 04:51:07 +08:00
LTbinglingfeng b2b5d10b75 feat(pluginstore): make registry version field optional
The latest release is now the source of truth for plugin versions, so
the registry version only serves as a display fallback. Validate its
format only when present.
2026-06-13 04:10:11 +08:00
LTbinglingfeng 220b4e5bbd feat(management): resolve plugin store versions from latest releases
List entries now show each plugin's latest release version and compute
update availability against it, falling back to the registry version
when the lookup fails. Lookups run concurrently and are cached per
repository with a short failure TTL to respect API rate limits.
2026-06-13 04:05:09 +08:00
LTbinglingfeng 40f4b8b856 feat(pluginstore): fetch and install plugins from latest release
Replace the tag-pinned release lookup with the repository latest
release endpoint. Derive the plugin version from the release tag,
validate it, and attach an optional token to API requests to raise
the rate limit.
2026-06-13 04:00:05 +08:00
Luis Pater 44d3066a9c feat(htmlsanitize): add HTML and JSON sanitization utilities with integration across plugins and APIs
- Introduced `htmlsanitize` package for escaping HTML and handling JSON body sanitization to prevent XSS vulnerabilities.
- Integrated sanitization functions into plugin store, plugin host, and API management handlers to ensure all user-facing content is escaped.
- Added unit tests to verify proper escaping of HTML strings, JSON bodies, and nested data structures.
- Updated existing management and plugin-related tests to validate sanitization implementations.
2026-06-13 01:10:27 +08:00
Luis Pater 60f6a54282 feat(pluginstore, pluginhost): add plugin unload handling and preserve config during plugin updates
- Introduced logic to handle plugin unloading during updates to prevent conflicts with loaded plugins.
- Preserved existing plugin configurations during updates, ensuring seamless transitions and maintaining custom fields.
- Added support for reloading the configuration after management saves changes.
- Enhanced unit tests to validate unloading, configuration preservation, and reloading behaviors.
2026-06-13 00:33:21 +08:00
Luis Pater 049ced5c3f feat(pluginhost, api): add support for "X-CPA-SUPPORT-PLUGIN" header with CGO detection
- Introduced `SupportPluginHeaderValue` to indicate CGO build status (`1` for enabled, `0` for disabled).
- Updated API response headers in `handler.go` to include "X-CPA-SUPPORT-PLUGIN".
- Added unit tests to verify proper header behavior under varying conditions.
2026-06-12 23:54:26 +08:00
Luis Pater 69b7462860 refactor(translator): update test strings to use English for consistency
- Replaced Chinese test strings in `claude_openai-responses_response_test.go` with English equivalents (e.g., "**对比竞品**" -> "**Compare competitors**").
- Updated comments in `config.example.yaml` to English to align with project language standards.
2026-06-12 23:44:57 +08:00
Luis Pater 0626b22e61 Merge pull request #3818 from router-for-me/Plugin-stone
feat(pluginstore): add lightweight plugin store installer APIs
2026-06-12 23:36:44 +08:00
LTbinglingfeng e38ba28db5 feat(pluginstore): add plugin store support 2026-06-12 23:15:00 +08:00
Luis Pater 9dbf4cd07e feat(translator): add usage token details for cache input/output aggregation
- Introduced `claudeResponsesUsageTokens` to manage detailed token statistics, including input, output, cache read, and cache creation tokens.
- Updated aggregation logic to include cached tokens in total usage calculations.
- Refactored usage processing to simplify token merging and ensure consistent handling across streaming and non-streaming responses.
- Added unit tests (`TestConvertClaudeResponseToOpenAIResponses_ReportsCacheTokens`) to verify correct cache token inclusion in usage metrics.

Closes: #3807
2026-06-12 21:03:39 +08:00
Luis Pater 538e3416db feat(plugin, api): prevent plugin recursion on host model callbacks, enable targeted interceptor skipping
- Updated host model callback logic to skip originating plugin's interceptors during nested model executions.
- Added `SkipInterceptorPluginID` field to plugin API structs for controlling interceptor bypass behavior.
- Introduced supporting logic in host API handlers, plugin host registry, and callback contexts to identify and skip specific plugins.
- Enhanced unit tests across plugin host, API handlers, and execution paths to verify interceptor skipping behavior and plugin isolation.
- Revised documentation to clarify non-recursive behavior of host model callbacks and the use of `SkipInterceptorPluginID`.
2026-06-12 02:38:51 +08:00
Luis Pater 8e39db2ec7 feat(plugin, api): introduce host model callback support with Go example and API handlers
- Added an example plugin `host-model-callback` in Go to summarize host model callbacks.
- Implemented `cliproxy_plugin_init`, `cliproxyPluginCall`, and other plugin functions for callback handling.
- Introduced API handlers for `ModelExecution` and `ModelExecutionStream` with support for both streaming and non-streaming requests.
- Included unit tests (`model_execution_test.go`) to validate execution logic and streaming responses.
2026-06-12 02:22:23 +08:00
Luis Pater ac4017ea0e Merge branch 'dev' of github.com:router-for-me/CLIProxyAPI into dev 2026-06-11 10:38:16 +08:00
Luis Pater 030c4a9385 Merge pull request #3795 from router-for-me/webui
feat(auto-updater): refactor skip logic and add unit tests for autoUpdateSkipReason
2026-06-11 10:31:58 +08:00
Luis Pater 9985976ebd feat(translator, pluginhost): add stream-specific response transformation support
- Introduced `HasStreamResponseTransformer` and `HasNonStreamResponseTransformer` to handle streaming and non-streaming transformations.
- Updated `executorResponseTranslatorExists` logic to correctly validate stream-specific transformers.
- Enhanced `TranslateStream` to suppress raw fallback when registered native transformers return empty output.
- Added comprehensive tests (`TestHasResponseTransformerChecksConcreteResponseKinds`, `TestHasResponseTransformerIgnoresEmptyRegistration`) for stream and non-stream transformer validation.
2026-06-11 10:16:58 +08:00
Luis Pater dc04d8be52 feat(translator): enhance response aggregation and annotation handling
- Implemented logic to aggregate text blocks until `message_stop` for improved consistency.
- Introduced support for message annotations like `citations_delta` in content responses.
- Added methods (`finalizeAssistantMessage`, `appendMessageAnnotation`) to handle message grouping and annotation appending cleanly.
- Updated unit tests to verify message aggregation, annotation handling, and suppression of unwanted native events.

Closes: #3801
2026-06-11 03:14:03 +08:00
Luis Pater 58bf645e66 feat(translator): ensure correct finish_reason handling for all response chunks
- Added tests (`TestCliFinishReasonOnlyOnFinalChunk`, `TestGeminiFinishReasonOnlyOnFinalChunk`) to validate correct `finish_reason` and `native_finish_reason` assignment.
- Refactored Gemini and CLI translators to track `SawToolCall` and `UpstreamFinishReason` for accurate final-chunk determination.
- Improved response parsing logic to align with upstream metadata and provide consistent reasoning on chunk outputs.
2026-06-11 00:17:45 +08:00
Luis Pater 1ca048abdc feat(auth, interceptor, jshandler): add post-auth request interceptors and enhance format handling
- Introduced `applyRequestAfterAuthInterceptor` to modify requests after credential selection and before executor translation.
- Added `InterceptRequestAfterAuth` method across plugin adapters with corresponding tests for context validation.
- Enhanced format resolution logic (`requestToFormat`) to support additional providers and formats.
- Updated JavaScript handler to include a new `on_after_auth_request` hook for post-auth request handling.
- Refactored interceptor methods for clarity and better encapsulation of request/response lifecycles.
2026-06-10 20:58:59 +08:00
hkfires 3c773b6d92 feat(auto-updater): refactor skip logic and add unit tests for autoUpdateSkipReason 2026-06-10 16:15:33 +08:00