Commit Graph
3011 Commits
Author SHA1 Message Date
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
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
sususu 487f8afc98 fix(xai): disable unisolated replay without caller auth 2026-07-12 23:38:11 +08:00
huahai0202 c4eda81b93 fix(xai): address namespace routing review feedback
Use exact namespace separator matching, normalize replay-inserted calls, preserve payloads on JSON update failures, and remove redundant completed-response restoration.
2026-07-12 23:33:53 +08:00
sususu f1e9347f51 fix(xai): preserve tool-call-only replay batches 2026-07-12 23:19:36 +08:00
huahai0202 0e3a3e6199 fix(xai): preserve namespace tool routing
xAI Responses does not accept namespace tool containers, so the executor flattens nested tools before forwarding them upstream. The original namespace support in 8b3670b8 moved children to the top level but discarded their namespace identity; ca67caf later retained namespace context only for targeted schema simplification.

Qualify flattened names to avoid collisions, normalize namespaced function-call history, and restore name plus namespace on HTTP and WebSocket responses. This keeps Codex MCP routing intact without changing the existing xAI tool_search filtering policy.
2026-07-12 23:16:57 +08:00
sususu 3f875ecd2d fix(xai): avoid ambiguous reasoning replay injection 2026-07-12 23:07:04 +08:00
Luis Pater 55f4d6ed1d feat(codex): pass Gin context to auth selection for Alpha search
- Introduced `codexSearchGinContextSelector` to capture and validate Gin context during credential selection.
- Added test case to verify context propagation and query parameter usage (`TestCodexAlphaSearchPassesGinContextToAuthSelection`).
- Updated `SelectAuth` implementation to include Gin context for enhanced compatibility with Home scheduling.
2026-07-12 23:06:38 +08:00
Luis Pater 9c3f720710 feat(codex): implement session affinity and request logging for alpha search
- Added `SelectAuth` method to enhance flexible credential selection.
- Introduced session affinity mechanism for consistent credential reuse per session.
- Enabled detailed request/response logging for Codex alpha search API.
- Updated tests to validate session affinity behavior and log capture.

Closes: #4166
2026-07-12 22:59:14 +08:00
Luis Pater dee653cd6d Merge PR #4239: fix(codex): proxy GPT-5.6 standalone search 2026-07-12 22:41:36 +08:00
sususu dc551b7de5 refactor(xai): remove unused assistant content equal helpers
Drop xaiAssistantMessageContentEqual and xaiAssistantMessagePartValue,
which were left unused after the last-assistant skip path landed.
2026-07-12 22:31:19 +08:00
sususu 041816c2fd feat(xai): encrypted reasoning replay for Responses/Claude with hardened cache
Preserve include=reasoning.encrypted_content, cache reasoning+assistant message
for store:false multi-turn, and accept Grok thinking signatures on Claude→Codex
for grok targets.

Harden replay cache: blob-level reasoning filter, never double-inject assistant
when history has a last message, isolate session keys by downstream API key,
clear cache on non-replayable completed turns, and normalize refusal parts.
2026-07-12 22:31:19 +08:00
Luis Pater 3586d3e750 feat(config): add support for configurable model display names across all APIs
- Added `DisplayName` to model configuration for Codex, Claude, Gemini, Vertex, and OpenAI compatibility.
- Updated hash computation and model summary to account for `DisplayName`.
- Enhanced API handlers to use `DisplayName` for client-facing catalogs.
- Expanded tests to verify `DisplayName` usage, preservation, and fallback mechanisms.
- Updated documentation and configuration examples for `DisplayName` field.

Closes: #4245
2026-07-12 22:13:23 +08:00
Luis Pater f4a8aee695 feat(translator): support namespace and custom tool handling in OpenAI responses
- Enhanced `convertResponsesCustomToolToOpenAIChat` to handle custom tool overrides with qualified names.
- Added namespace child consolidation logic for tools.
- Updated `responsesCustomToolNames` to include namespace-aware tool extraction.
- Introduced new test cases to validate namespace and custom tool transformations in both streaming and non-streaming responses.
2026-07-12 21:36:12 +08:00
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
Ozwasyd 46e2894ad3 fix(codex): proxy GPT-5.6 standalone search 2026-07-12 15:40:12 +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