Commit Graph
2980 Commits
Author SHA1 Message Date
Luis Pater dc39f44547 fix(translator): stabilize Responses Lite tool events 2026-07-12 20:39:56 +08:00
辰ing e9d3dfbce1 fix(translator): 工具输出与 custom input 解包的健壮性改进
采纳 review 意见:responsesToolOutputText 支持纯字符串数组元素,
避免非 content-parts 形态的输出被静默丢弃;unwrapCustomToolInput
在 input 为对象/数组时以原始 JSON 解包,不再仅限字符串。

Ref #4219
2026-07-12 20:39:56 +08:00
辰ing bd2aafb8fc feat(translator): custom 工具调用以 custom_tool_call item 回放给客户端
上游模型对 custom(freeform)工具的调用经 chat completions 返回为
function call(arguments 为 {"input": ...}),但 Codex Desktop 仅
识别 custom_tool_call item 形态。

响应方向按原始请求中声明为 type=custom 的工具名(顶层 tools 与
additional_tools,流开始时缓存于状态)区分处理:

- 流式:output_item.added(type=custom_tool_call)→
  custom_tool_call_input.done → output_item.done;JSON arguments
  增量无法映射为 freeform input 增量,故 custom 工具不发
  arguments delta,完整 input 随 done 事件一次性下发
- response.completed 与非流式输出同样产出 custom_tool_call item,
  input 从 {"input": ...} 包装中解出

Ref #4219
2026-07-12 20:39:55 +08:00
辰ing bd7cc64732 feat(translator): 支持 Codex additional_tools 工具下发与 custom 工具历史回放
Codex Desktop(Responses Lite,请求头 X-Openai-Internal-Codex-Responses-Lite)
的请求顶层 tools 为 null:工具定义经 input 中的 additional_tools item
下发,历史工具调用为 custom_tool_call / custom_tool_call_output item。
原转换仅识别顶层 tools 与 message/reasoning/function_call/
function_call_output,导致发往 openai-compatibility 上游的请求既无
工具定义也无工具调用历史,模型据此答复"没有可用工具"。

请求方向:
- 工具收集合并顶层 tools 与所有 additional_tools item(function/
  namespace/custom 共用同一转换)
- custom(freeform)工具定义映射为带 {"input": string} 参数的
  function 工具,与 Codex function 形态 apply_patch 的形状一致
- custom_tool_call 回放为 assistant tool_calls,原始 input 包装为
  {"input": ...} arguments;custom_tool_call_output 回放为 tool
  消息,content-parts 数组拍平为文本,并纳入 outputCallIDs 预扫描
  以维持工具消息相邻性

同时引入响应方向所需的 responsesCustomToolNames /
unwrapCustomToolInput 辅助函数。

Ref #4219
2026-07-12 20:39:55 +08:00
辰ing 07455ecba7 fix(translator): 上游流式 tool_calls 缺少 id 时合成 call_id 保证事件链完整
部分 OpenAI 兼容上游(自建 vLLM/sglang、部分中转网关)在流式 delta 中
不携带 tool_calls[].id。原逻辑要求非空 id 才发出
response.output_item.added/done 事件链,导致 Codex 侧完全收不到
函数调用(表现为工具全部不可用)。非流式路径同样产出 call_id 为空
的残缺 item。

缺失 id 时按 call_<responseID>_<choiceIdx>_<toolIndex> 合成确定性
call_id;chat completions 上游无状态,call_id 仅需单请求内自洽,
合成 id 可安全往返。

Ref #4219
2026-07-12 20:39:54 +08:00
Luis Pater 0ba5fab529 Merge pull request #4240 from BG-QWQ/fix/xai-cli-user-agent-4233
fix(executor): identify Grok CLI OAuth requests
2026-07-12 20:27:51 +08:00
Luis Pater 042f1fea68 feat(handlers): update method names for image execution with auth manager
- Replaced `ExecuteWithAuthManager` with `ExecuteImageWithAuthManager`.
- Replaced `ExecuteStreamWithAuthManager` with `ExecuteImageStreamWithAuthManager` for improved clarity and specificity.
2026-07-12 20:15:43 +08:00
Luis Pater 6c70996e43 feat(executor): add logging for resolved xAI base URL and enhance test coverage
- Introduced `logXAIResolvedBaseURL` for consistent logging of resolved upstream base URLs.
- Added helper `xaiBaseURLSource` to classify base URL origins (default, CLI chat proxy, custom).
- Enhanced test suite with `TestXAIBaseURLSource` to cover base URL source classification logic.
2026-07-12 17:23:56 +08:00
1502538344 1a0bbe09c6 fix(executor): identify Grok CLI OAuth requests 2026-07-12 16:40:08 +08:00
Luis Pater 6fc4f0c4ef docs: add FastAIToken sponsorship details to all README translations
- Added FastAIToken sponsorship section to `README.md`, `README_CN.md`, and `README_JA.md`.
- Included promotion details, platform features, and support channels.
- Added `fastaitoken.png` to assets folder.
2026-07-12 14:42:19 +08:00
Luis Pater f35539c216 docs: add Cubence sponsorship details to all README translations
- Added Cubence sponsorship section to `README.md`, `README_CN.md`, and `README_JA.md`.
- Included promotion details and discounts for users.
- Added `cubence.png` to assets folder.
2026-07-12 14:15:15 +08:00
Luis Pater 9418054a3b Merge pull request #4230 from IQ-Director/feature/tray-powershell
docs: add CPA-Tray-Powershell project
2026-07-12 03:58:53 +08:00
Luis Pater 2075f77c8e feat(executor): enhance cache_tokens handling and extend parsing logic with alias normalization
- Added support for `cache_read_tokens` and `cache_creation_tokens` aliases across `prompt_tokens_details`, `input_tokens_details`, and other usage details.
- Updated token parsing logic to handle multiple aliases and improve fallback scenarios.
- Extended test coverage for alias normalization, including `cache_write_tokens`, `cacheCreationTokens`, and `cachedContentTokenCount`.
- Improved total token calculation by incorporating conditional read token addition logic.
2026-07-12 03:22:41 +08:00
IQ-Director 759b30ee0d docs: add CPA-Tray-Powershell project
- Add CPA-Tray-Powershell to the English README
- Add corresponding descriptions to the Chinese and Japanese READMEs
- Document background tray operation and management page access
- Document automatic updates with SHA-256 verification and rollback
- Document one-click restart and update, PID validation, and safe shutdown
2026-07-12 02:48:10 +08:00
Luis Pater e99a2056ba feat(executor): add using_api attribute support for API path toggle and enhance test coverage
- Introduced `using_api` attribute in xAI auth for toggling between official API and CLI chat-proxy paths.
- Updated `xaiChatBaseURL` and `applyXAIChatHeaders` to conditionally apply the appropriate logic based on the `using_api` value.
- Added robust handling of attribute and metadata parsing for `using_api`.
- Extended test suite to cover `using_api` scenarios, including defaults, overrides, and header behaviors.
2026-07-11 12:15:55 +08:00
Luis Pater aa05fb27f3 feat(executor, handlers): enhance websocket output restoration and compact compaction logic
- Refactored websocket output collection to restore completed events using fallback items and indexed payloads.
- Updated `CodexExecutorCompact` tests to ensure no injection of `image_generation` tools and maintain compact input order.
- Added new tests to validate sustained reasoning, proper output restoration, and compaction replay behavior.
- Improved logic to handle incremental response appends and preserved reasoning continuations.
- Enhanced test coverage for normalization, tool calls, and downstream payload restoration scenarios.

Closes: #4176
2026-07-11 11:42:51 +08:00
Supra4E8C 8c2bf2c24b Merge pull request #4202 from router-for-me/codex/issue-33-service-tier-reporting
feat(usage): report request and response service tiers
2026-07-11 03:12:02 +08:00
Luis Pater 6e819ab622 feat(oauth): refactor for device flow and cancelable sessions, extend test coverage
- Replaced PKCE-based OAuth for xAI with device authorization flow for enhanced compatibility.
- Introduced cancelable OAuth sessions with server-side invalidation to prevent token persistence on flow interruption.
- Updated OAuth polling and session tracking to handle device flow specifics, such as `user_code` and extended timeouts.
- Refactored TUI OAuth model to track polling generations, distinguish device flow, and handle session cancellation gracefully.
- Extended test cases for device flow scenarios, stale session handling, and cancelation logic.
- Streamlined xAI device flow management in handler logic and improved error handling.
2026-07-11 02:50:23 +08:00
Supra4E8C bc812e5f74 perf(usage): avoid parsing irrelevant stream chunks 2026-07-11 02:42:42 +08:00
Luis Pater dc162b938e feat(executor): refactor XAI header application logic and extend test coverage
- Extracted `applyXAIDefaultHeaders` and `applyXAICustomHeaders` for cleaner separation of concerns in API header application.
- Updated `applyXAIChatHeaders` to ensure proper header overrides for CLI chat-proxy-specific configurations.
- Added test case to validate custom headers' ability to override CLI chat-proxy defaults.
2026-07-11 02:12:57 +08:00
Luis Pater 3533484a1f feat(executor): add chat-proxy-specific headers and improve base URL handling
- Introduced `xaiChatBaseURL` helper to normalize base URLs for non-media chat requests.
- Added `applyXAIChatHeaders` to handle CLI chat-proxy-specific headers.
- Updated logic to differentiate between default, chat-proxy, and custom gateway base URLs.
- Extended test coverage to validate behavior of headers and base URL handling across scenarios.

Closes: #4182
2026-07-11 02:07:01 +08:00
Supra4E8C ea20742e77 fix(usage): retain response tier without usage 2026-07-11 01:37:39 +08:00
Supra4E8C dc4be1674a feat(usage): report request and response service tiers 2026-07-11 00:49:30 +08:00
Luis Pater 045a96428f feat(handlers): extend image-only model support with grok-imagine-image and grok-imagine-image-quality
Closes: #4201
2026-07-11 00:36:58 +08:00
Luis Pater cc2095f33c chore(docs): remove Unity2.ai sponsorship section from all README translations 2026-07-11 00:14:51 +08:00
Luis Pater abb5224880 feat(translator): add support for cache_write_tokens in Codex response usage details
- Introduced handling for `cache_write_tokens` in `input_tokens_details` and mapped to `cached_creation_tokens` in output.
- Added comprehensive tests to validate correct parsing, preservation, and omission of `cache_write_tokens` in both streaming and non-streaming responses.

Closes: #4197
2026-07-10 23:03:25 +08:00
Supra4E8C 3554b63721 Merge pull request #4192 from router-for-me/codex/fix-sol-responses-lite-image-tool
fix(executor): enhance image generation tool handling for responses-l…
2026-07-10 18:56:50 +08:00
Supra4E8C 631f7a652c fix(executor): enhance image generation tool handling for responses-lite requests 2026-07-10 18:54:31 +08:00
Supra4E8C 04109920e4 Merge pull request #4185 from router-for-me/codex/fix-p2-oauth-plugin-source
Codex/fix p2 oauth plugin source
2026-07-10 17:41:04 +08:00
Supra4E8C 7115e7e00c fix(oauth): make session completion idempotent 2026-07-10 16:20:15 +08:00
Supra4E8C d1ef06cb5e fix(oauth): hide completed sessions from legacy getter 2026-07-10 16:17:01 +08:00
Supra4E8C f081b91e57 fix(plugin-store): preserve installed source identity 2026-07-10 15:48:09 +08:00
Supra4E8C 1af2334477 fix(oauth): reject unknown completed states 2026-07-10 15:37:44 +08:00
Luis Pater f084eefae6 chore(models): remove "ultra" effort level from models.json 2026-07-10 14:31:53 +08:00
Luis Pater ca67caf087 **fix(xai): improve namespace-specific tool parameter handling and simplify Codex automation schema**
- Refined tool normalization logic to pass namespace context (`namespaceName`) to `normalizeXAITool`.
- Limited schema simplification to `codex_app.automation_update` to avoid unintended modifications to unrelated tools or namespaces.
- Updated `xaiFunctionParametersNeedSimplification` to match tools by exact namespace and name.
- Enhanced tests to validate correct schema simplification for `codex_app.automation_update` while preserving unrelated tool definitions.
2026-07-10 13:28:35 +08:00
Luis Pater bf25331c77 Merge pull request #4157 from Wraient/fix/xai-desktop-tool-schema-and-free-usage-retry 2026-07-10 13:03:59 +08:00
Luis Pater 20e61f281f Merge pull request #4160 from kogekiplay/fix/codex-client-ultra-reasoning
fix: preserve ultra reasoning effort for Codex clients
2026-07-10 12:52:24 +08:00
Luis Pater 35dba9b412 chore(models): update default client version and user agent, revise GPT-5.6 Sol configuration
- Incremented `defaultClientVersion` and `defaultCodexUserAgent` to `0.144.1`.
- Replaced GPT-5.5 with GPT-5.6 Sol in model registry, updating metadata including context window length, reasoning levels, and description.
- Enhanced model metadata with adjusted parameters, reasoning format, and new effort levels.
2026-07-10 12:46:09 +08:00
Luis Pater cfa90f9fbf Merge pull request #4175 from router-for-me/image 2026-07-10 12:05:45 +08:00
hkfires f9162d391c feat(executor): add image generation function tool checks and corresponding tests 2026-07-10 11:59:29 +08:00
Luis Pater 26d45fd46a feat(models): add model header overrides from configuration
- Introduced `override_header` in model configurations to support runtime customization of upstream request headers.
- Added `applyModelHeaderOverrides` utility to enforce header overrides for relevant executor and websocket paths.
- Updated model registry and `models.json` with enhanced configurations for header customizations.
- Implemented and extended test cases to validate header override behavior for various models and scenarios.
2026-07-10 05:30:12 +08:00
Luis Pater 5f8899b795 chore(models): remove GPT-5.6 Sol from model registry 2026-07-10 04:05:57 +08:00
Luis Pater 15f3037161 feat(models): restrict Codex input modalities to text and image
- Updated Codex client to validate and restrict input modalities to "text" and "image" only.
- Added deduplication logic for input modalities in `codex_client_models.go`.
- Introduced test cases to verify behavior with mixed and invalid modalities.
2026-07-10 03:21:01 +08:00
kogekiplay ed2933443d fix: expose ultra reasoning effort to Codex clients 2026-07-10 02:42:04 +08:00
Luis Pater ef0a4a5643 feat(middleware): support logging for Codex response websockets
- Updated request logging middleware to include `/backend-api/codex/responses` as a valid websocket path.
- Enhanced unit tests to cover new websocket path scenarios.
2026-07-10 02:38:53 +08:00
Luis Pater b4c594050e chore(models): update default client version and user agent, revise GPT-5.5 configurations
- Bumped the `defaultClientVersion` and `defaultCodexUserAgent` to `0.144.0`.
- Replaced GPT-5.6 Sol with GPT-5.5 in model registry, adjusting metadata including context window length and reasoning levels.
- Updated `usage_helpers` to include `cache_write_tokens` logic for input token details.
2026-07-10 01:54:37 +08:00
Luis Pater f21beb05b5 feat(models): register additional GPT-5.6 models (Sol, Terra, Luna) to model registry
- Added detailed configurations for new models, including context length, reasoning levels, and supported parameters.
2026-07-10 01:01:11 +08:00
Luis Pater 445de6c055 feat(models): add GPT-5.6 models (Sol, Terra, Luna) to registry with enhanced capabilities
- Registered new GPT-5.6 models (Sol, Terra, Luna) with detailed configurations, including increased context length and advanced reasoning levels.
- Updated client model configurations and metadata for GPT-5.6 Sol in `codex_client_models.json`.
2026-07-10 00:59:41 +08:00
Wraient 0df267adbb fix(xai): prevent Desktop hang on complex tool schemas and set free-usage Retry-After
Codex Desktop injects codex_app.automation_update with a large oneOf+$ref
schema. On xAI free/build Responses, that request accepts HTTP but never
emits SSE, so clients hang until cancel.

- Simplify automation_update (and similar large oneOf+$ref schemas) to a
  permissive object schema before upstream xAI
- Map subscription free-usage-exhausted 429s to a 24h RetryAfter for
  account rotation/cooldown
- Add unit tests for both behaviors
2026-07-09 21:49:01 +05:30
Luis Pater db4f1ceff4 feat(validation): enhance cross-family level clamping with model type mismatch handling
- Added `modelFamilyMismatch` check to improve validation for provider families reusing Claude-compatible formats (e.g., Kimi models).
- Adjusted `allowClampUnsupported` logic to account for mismatched model families.
- Updated `strictBudget` validation to exclude mismatched model types.
- Added test cases to verify clamping behavior for Kimi models serving Claude-compatible requests.
2026-07-10 00:12:18 +08:00