Commit Graph
3043 Commits
Author SHA1 Message Date
Luis Pater f583414fd9 fix(xai): normalize image refs with special JSON keys 2026-07-17 16:13:54 +08:00
Luis Pater 70152f498d Merge commit 'refs/pull/4390/head' of github.com:router-for-me/CLIProxyAPI into dev 2026-07-17 16:13:48 +08:00
Luis Pater bb0fdbf8c2 Merge pull request #4387 from router-for-me/think
Enhance Kimi thinking configuration and tests
2026-07-17 15:59:42 +08:00
jellyfish-p f82123a3ef fix(xai): rewrite image.image_url to image.url before upstream send
Normalize OpenAI-style image refs across images, videos, and Responses so Grok receives {image:{url:...}} instead of image_url.
2026-07-17 14:42:12 +08:00
Luis Pater 050bec69ea Merge pull request #4381 from router-for-me/plugin
feat(pluginstore): implement plugin synchronization and validation
2026-07-17 14:27:48 +08:00
hkfires 255df2db3c feat(kimi): implement native thinking object extraction and update reasoning handling 2026-07-17 13:33:44 +08:00
hkfires 74a98761f6 feat(tests): enhance thinking test cases with new scenarios and model updates 2026-07-17 12:00:41 +08:00
hkfires 5243b38ab7 feat(pluginstore): implement plugin synchronization and validation
- Introduced PluginSyncRequest and PluginSyncResponse types for managing plugin synchronization.
- Added validation logic for plugin sync responses, including checks for schema version and expiration.
- Implemented functionality to clear sensitive data from plugin sync requests and responses.
- Enhanced error handling for HTTP requests related to plugin synchronization.
- Updated manifest validation to reject artifact URLs containing credentials or query parameters.
- Added tests for plugin synchronization, ensuring proper validation and error handling.
- Refactored existing code to support resolved authentication configurations for plugin downloads.
2026-07-17 08:09:05 +08:00
Luis Pater 106270bea6 feat(kimi): use dynamic version from buildinfo for API headers
- Updated `X-Msh-Version` and `User-Agent` headers in both `kimi.go` and `kimi_executor.go` to dynamically include the current version from `buildinfo`.
- Replaced hardcoded values with `buildinfo.Version` to ensure consistency with the build version.
2026-07-16 22:32:35 +08:00
Luis Pater 09da52ad50 feat(translator): improve error handling and response conversion for incomplete statuses
- Enhanced response handling to support `response.incomplete` events across translator components and executors.
- Refactored `resultErrorFromError` to centralize error conversion and consolidate repeated logic for constructing custom errors.
- Updated handling of `max_output_tokens` and similar terminal reasons in OpenAI and Gemini translator workflows.
- Introduced `IsRequestScoped` and `IsRequestScopedError` to differentiate between request-scoped and non-request-scoped errors.
- Added comprehensive test cases for incomplete responses, terminal failures, and error propagation in both streaming and non-streaming conditions.

Closes: #3055
2026-07-16 04:38:19 +08:00
Luis Pater 466cee6e16 fix: complete xAI image usage reporting 2026-07-16 02:32:56 +08:00
Luis Pater 3cb2d27d98 Merge remote-tracking branch 'origin/pr-4344' into dev 2026-07-16 02:29:45 +08:00
Luis Pater b6ce0beecd feat(executor): simplify xAI function schema handling and rejection logic
- Refactored `xaiFunctionParametersNeedSimplification` to identify schemas xAI cannot process, including those with non-object types in unions.
- Limited parameter simplifications to problematic schemas instead of specific tools or namespaces.
- Clarified and updated debug messages to reflect schema rejection and hang prevention.

Closes: #4343
2026-07-16 02:05:50 +08:00
Luis Pater 71b5beb8b9 feat(gitstore): migrate to new client options API and disable commit signing
- Updated git operations to leverage `ClientOptions` for authentication and configuration, replacing the deprecated `AuthMethod`.
- Implemented logic to disable GPG commit signing in repositories to prevent signature errors in automated workflows.
- Upgraded dependencies in `go.mod` and `go.sum` to align with the latest `github.com/go-git/go-git/v6` alpha releases.
- Added unit tests to verify commit signing is properly disabled in repositories.

Closes: #4341
2026-07-16 01:44:28 +08:00
Matt Van Horn 9f500aef7a fix: publish usage event for xAI images/generations path 2026-07-15 08:45:44 -07:00
Luis Pater 768b4c49fd feat(usage): track generate flag with backward-compatible defaults
Propagate client generate metadata through usage records while keeping
legacy callers that omit the field enabled by default. Preserve an
existing context generate=false when metadata does not set the value,
and normalize omission to true only at publishing boundaries.
2026-07-15 21:30:09 +08:00
Luis Pater 35a5f06612 feat(config): resolve plugin directory paths and handle tilde expansion
- Added `ResolvePluginsDir` to normalize plugin directory paths, including tilde (`~`) expansion.
- Integrated directory resolution into config loading, runtime setup, and plugin management flows.
- Updated tests across components to validate correct handling of unresolved and expanded plugin paths.
- Added error handling for invalid or unresolved plugin directories to prevent runtime issues.

Closes: #4313
2026-07-15 16:53:02 +08:00
Luis Pater c8803713c9 feat(translator): disambiguate and deduplicate tool names in request/response workflows
- Introduced `SanitizedFunctionNameMap` and `DisambiguatedToolNameMap` for consistent mapping between sanitized and original tool names.
- Added collision handling with deterministic hash suffixes for name disambiguation within character limits.
- Implemented logic to deduplicate and map tool and function names across translator components, including Interactions, Claude, and Gemini.
- Updated test cases to validate name restoration, deduplication, disambiguation, and mapping behaviors.

Closes: #4244
2026-07-15 04:49:30 +08:00
Luis Pater 9f62c8df28 feat(translator): enhance handling of custom tool calls and improve tool call batching logic
- Introduced support for custom tool calls in request serialization, including preservation of call IDs, input, and output.
- Enhanced tool call batching logic to handle ambiguous, missing, and reused call IDs across assistant messages.
- Updated processing of tool call outputs to ensure proper matching with pending calls and introduced synthesized IDs when necessary.
- Added extensive test cases to validate behavior for custom tool call histories, mixed call types, and edge cases with ambiguous or orphaned IDs.

Closes: #4256
2026-07-15 03:14:05 +08:00
Luis Pater e57416731a feat(logging): add deferred request body capture for error handling
- Introduced `deferredRequestBodyCapture` for spooling and retaining large error-only request bodies for improved logging.
- Enhanced `RequestLoggingMiddleware` to capture request body based on size and error criteria.
- Implemented decompression and truncation for large request bodies with Zstd encoding.
- Added support for deferred API request logging and context tracking.
- Included extensive test coverage for error-specific body capture and serialization behavior.
2026-07-14 23:35:29 +08:00
Luis Pater 3d46ede431 feat(translator): handle reasoning content and improve request serialization
- Added support for reasoning content in assistant messages with proper serialization of `thought`, `thoughtSignature`, and content parts.
- Ensured empty assistant messages and invalid function calls are skipped during request generation.
- Enhanced compatibility by adding test cases for preserving reasoning content, tool calls, and visible assistant content in `ConvertOpenAIRequestToGemini` and `ConvertOpenAIRequestToAntigravity`.

Closes: #4304
2026-07-14 22:19:07 +08:00
Luis Pater 411d7d41ee feat(auth): add SelectAuthByKind method and enhance Codex Alpha Search handling
- Implemented `SelectAuthByKind` to filter and select credentials by kind with retry logic and error handling.
- Updated Codex Alpha Search to enforce OAuth credentials and sanitize upstream request body.
- Added unit tests to validate `SelectAuthByKind` behavior across scenarios.
- Introduced `sanitizeCodexAlphaSearchBody` for removing sensitive fields from API payloads.

Closes #4289
2026-07-14 16:31:45 +08:00
Luis Pater 160a55612e feat(auth): add home force mapping logic with tests and alias result handling
- Implemented `homeForceMappingAliasResult` for handling forced alias mapping in the authentication process.
- Updated `resolveExecutionAliasResultForRequested` to incorporate home force mapping.
- Introduced new attributes (`home_force_mapping` and `home_original_alias`) for managing alias behavior.
- Extended `homeAuthDispatchResponse` with fields for force mapping and original alias.
- Added test cases to validate force mapping logic and edge cases.
2026-07-14 14:59:15 +08:00
sususu98 03d58c4402 fix(usage): collapse OpenAI service tier metadata (#4275)
* fix(usage): preserve request service tier metadata

* fix(usage): collapse request tier metadata

* fix(usage): emit only service_tier and response_service_tier

Collapse request tier to service_tier for usage records and queue payloads. Keep RequestServiceTier as a deprecated input-only alias for older plugin callers.
2026-07-14 14:19:13 +08:00
Luis Pater 6c6b16f044 feat(ui): update Kimi logo with new SVG design and dimensions 2026-07-14 12:36:24 +08:00
Luis Pater 06a4e46f69 Merge pull request #4283 from MapleMapleCat/docs/add-grok-search-mcp
docs(readme): add Grok Search MCP project entry
2026-07-14 05:20:55 +08:00
Luis Pater 2a63b27187 fix(release): rename GOARCH to TARGET_GOARCH in release workflow to resolve variable mismatch during FreeBSD builds 2026-07-14 05:12:49 +08:00
Luis Pater a9831c841a fix(xai): sync allowed_tools and prune orphaned choices for x_search inject
Normalize and drop tool_choice entries that reference tools removed by
normalizeXAITools before injecting native x_search, then allow x_search in
allowed_tools without duplicates so Grok can select the injected tool.
2026-07-14 05:03:19 +08:00
Luis Pater 423f3d5ff7 feat(xai): add xAI API key support with comprehensive handling and tests
- Introduced `xai-api-key` to configuration for supporting xAI provider integration.
- Added API key operations: creation, updates, deletion, and sanitization.
- Implemented backend enhancements for credential-specific routing, response filtering with model aliasing, and WebSocket handling for xAI services.
- Included extensive test coverage to validate configuration parsing, CRUD operations, and the new functionalities.
- Updated related modules to handle `xai-api-key`, including the watcher, management handlers, and configuration sanitizers.
2026-07-14 04:40:12 +08:00
Luis Pater a5577cc67d feat(xai): enhance response filtering with client-declared tool support to distinguish internal X Search traces
- Added `clientDeclaredTools` to `xaiInternalXSearchResponseFilter` for improved filtering precision.
- Implemented `collectXAIClientDeclaredToolKeys` to register client-declared tools with effective normalization to function calls.
- Prevented leakage of internal traces (e.g., `xs_call-*`) while preserving client-declared tools with overlapping names.
- Introduced multiple test cases to ensure filter correctness and preserve expected WebSocket response outputs.
- Enhanced completed output handling in response filtering.

Closes: #4282 / PR #4284.
2026-07-14 03:38:29 +08:00
Luis Pater 4fd81f904b Merge pull request #4284 from vvanglro/codex/fix-xai-x-search-history-4282 2026-07-14 01:30:40 +08:00
vvanglro 4651c3705d perf(xai): reuse parsed input array 2026-07-14 00:44:14 +08:00
sususu98 194fbce4b4 fix(executor): strip orphan reasoning ids when store is disabled (#4285)
* fix(executor): strip orphan reasoning ids when store is disabled

Codex backend requires store=false and treats reasoning items with an
id but no usable encrypted_content as store lookups, which 404 with
"Item with id not found". Drop those orphan ids after removing invalid
encrypted_content (and when encrypted_content is already missing),
while preserving ids when store=true.

* fix(executor): skip id delete when reasoning item has no id

Avoid sjson.Delete on encrypted_content drops that never carried an id,
matching the orphan-id path's Exists() guard.
2026-07-14 00:35:48 +08:00
vvanglro caa93a7fc6 fix(xai): filter internal X search calls 2026-07-14 00:19:49 +08:00
Dmitry R. 7f6d491e70 perf(executor): avoid O(n^2) rebuilds when sanitizing reasoning encrypted_content (#4281)
Previously each dropped encrypted_content re-ran sjson.DeleteBytes on
the whole body/array per item, causing O(n^2) work on inputs with many
reasoning items.

Now the array is walked once, editing only offending items in place
and lazily building a replacement "input" array via strings.Builder.
The builder stays nil (no allocation) when nothing needs sanitizing,
and the array is spliced back with a single SetRawBytes call.
2026-07-14 00:16:05 +08:00
vvanglro 7bb8132817 fix(xai): normalize custom tool call history 2026-07-13 23:45:44 +08:00
MapleMapleCat a9813dcc2c docs(readme): add Grok Search MCP translations
Keep the project entry consistent across the Chinese and Japanese README files.
2026-07-13 23:11:41 +08:00
MapleMapleCat cf10f25e70 docs(readme): add Grok Search MCP project entry
Document the MCP server built on CLIProxyAPI so users can discover its Grok search integration and administration features.
2026-07-13 23:04:29 +08:00
Luis Pater 7efe8b394a Merge pull request #4278 from huahai0202/fix/disable-custom-tool-search
fix(codex): 仅为有模板的纯 Codex 路由保留 tool search
2026-07-13 21:54:28 +08:00
huahai0202 e73aad2e0a fix(codex): require model template for tool search 2026-07-13 19:35:16 +08:00
huahai0202 ceaeb75d53 fix(codex): gate tool search by model providers 2026-07-13 19:22:58 +08:00
Luis Pater 6279bb8a4c feat(ui): add provider SVG logos and descriptions in multilingual README files
- Introduced logo assets (`Kimi`, `OpenAI`, `Claude`, `Gemini`, `Grok`) under `assets/logo/`.
- Updated multilingual README files (`README.md`, `README_JA.md`, `README_CN.md`) to include provider SVG logos and enhance descriptions for supported APIs.
- Improved clarity of provider details with tables for better readability.
2026-07-13 18:21:00 +08:00
sususu98 4fe2c60c51 feat(registry): remote-refresh Codex client model catalog (#4276)
Load codex_client_models.json like models.json with validation, revisioned
handler reloads, CI bake, and Home-aware updater gates so list IDs still
come from Home while templates can refresh on the edge.
2026-07-13 17:47:35 +08:00
Luis Pater e674f19129 Fix xAI allowed tool namespace choices 2026-07-13 14:58:03 +08:00
Luis Pater 19fb0f0774 Merge pull request #4251 from huahai0202/fix/xai-namespace-tool-routing 2026-07-13 14:48:55 +08:00
huahai0202 4123e27583 fix(xai): handle additional namespace tools 2026-07-13 10:39:39 +08:00
Luis Pater e0a0b5a4b7 feat(codex): add summary detection and processing for local compaction in websocket input
Closes: #4227
2026-07-13 03:22:47 +08:00
Luis Pater 5b7f2361ee Merge pull request #4190 from sususu98/pr/xai-sse-reasoning-replay
feat(xai): encrypted reasoning replay for Responses/Claude
2026-07-13 00:14:05 +08:00
sususu 18d239d567 fix(xai): clear replay after compaction 2026-07-12 23:59:39 +08:00
huahai0202 eb6d169407 fix(xai): qualify namespaced tool choices 2026-07-12 23:58:16 +08:00