Skip to content

chore: reconcile CLIProxyAPIPlus v7.2.88#135

Merged
kaitranntt merged 115 commits into
mainfrom
kai/chore/upstream-sync-v7.2.88
Jul 18, 2026
Merged

chore: reconcile CLIProxyAPIPlus v7.2.88#135
kaitranntt merged 115 commits into
mainfrom
kai/chore/upstream-sync-v7.2.88

Conversation

@kaitranntt

Copy link
Copy Markdown
Owner

Summary

  • reconcile the fork from v7.2.62 to exact upstream v7.2.88 (93d74a89)
  • preserve Plus-only providers, plugins, management, auth, and release behavior
  • make scheduled sync discover the latest stable upstream tag while manual runs remain exact
  • serialize OAuth cancellation and credential persistence, including concurrent plugin polling

Topology

The reconciliation commit preserves both histories:

  • fork parent: 3aae95a1
  • upstream parent: 93d74a89 (v7.2.88)

Validation

  • go test -count=1 ./...
  • go build ./...
  • focused OAuth race suite, 50 repetitions
  • git diff --check
  • independent final review: merge-ready

Docs impact

Minor. Upstream README changes are reconciled and the sync workflow behavior is documented by the existing fork metadata/workflow contract.

luispater and others added 30 commits July 10, 2026 23:03
…nse 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
…age` and `grok-imagine-image-quality`

Closes: #4201
…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
… 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.
… 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.
…er-reporting

feat(usage): report request and response service tiers
…mpact 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
… 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.
- 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
…gic 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.
- 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.
- 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.
…t 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.
…ager

- Replaced `ExecuteWithAuthManager` with `ExecuteImageWithAuthManager`.
- Replaced `ExecuteStreamWithAuthManager` with `ExecuteImageStreamWithAuthManager` for improved clarity and specificity.
fix(executor): identify Grok CLI OAuth requests
部分 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
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
上游模型对 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
采纳 review 意见:responsesToolOutputText 支持纯字符串数组元素,
避免非 content-parts 形态的输出被静默丢弃;unwrapCustomToolInput
在 input 为对象/数组时以原始 JSON 解包,不再仅限字符串。

Ref #4219
…I 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.
… 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
…ned 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.
luispater and others added 28 commits July 17, 2026 16:13
…orUpstream`

- Updated `normalizeClaudeSamplingForUpstream` to delete `top_p` from payloads.
- Adjusted test to validate the removal of both `temperature` and `top_p`.

Closes: #4383
- Switched from `xaiChatBaseURL` to `xaiCompactBaseURL` for compact requests to avoid 404 errors from CLI chat-proxy.
- Updated headers to use standard API headers for compact endpoints.
- Added `xaiCompactBaseURL` helper function for dedicated compact request base URL resolution.
- Adjusted comments to clarify handling of compact and websocket transports.

Closes: #4376
- Introduced CPA trace ID middleware to inject trace IDs in response headers.
- Added support for CPA trace ID generation and validation.
- Updated metadata handling to include stable auth indices and trace ID callbacks for enhanced request tracking.
- Enhanced tests to verify CPA trace ID propagation and reserved header handling across middleware, metadata, and handlers.

Closes: #4370
… aliases

- Introduced `display-name` field for human-readable model names in config and YAML files.
- Updated alias application logic to set and preserve display names during model alias mapping.
- Enhanced tests to validate display name behavior for various scenarios, including forks and upstream preservation.
- Refined `sanitizeOAuthModelAlias` to handle `display-name` with proper trimming and formatting.

Closes: #4398
- Implemented deterministic shortening of overlong Codex input item IDs to meet 64-character limit.
- Added `SanitizeCodexInputItemIDs` helper for efficient ID shortening in request bodies.
- Updated Codex executor and websocket implementations to utilize the new helper.
- Introduced unit tests to validate ID length restrictions, avoidance of collisions, and deterministic behavior.

Closes: #4401
…sessions

- Introduced per-connection active channel management for Codex and XAI websocket sessions.
- Enhanced session behavior to support clearing and reassigning active channels tied to specific connections.
- Added support for detecting and detaching stale connections upon session target changes.
- Refactored websocket message handling logic to ensure connection-specific channel consistency.
- Extended test coverage for websocket session behaviors, including reconnections, target switching, and pinned auth transitions.
…e requests

- Updated `codex_claude_request` to set the service tier as "priority" when `speed` is "fast".
- Enhanced request template generation logic to reflect dynamic service tier evaluation.

Closes: #4349
…e replay handling

- Introduced agent-specific cache key isolation to ensure distinct prompt caching across agents.
- Improved reasoning replay handling for Claude models, including cumulative tool turn restoration and validation.
- Enhanced HTTP and WebSocket session consistency during execution scope and cache replay synchronization.
- Added new unit tests and extended coverage for prompt caching, agent isolation, and replay cache functionality.

Closes: #4352
- Removed the CatAPI entry from `README.md`, `README_JA.md`, and `README_CN.md`.
- Deleted the associated `catapi.png` asset.
- Introduced `normalizeXAIObjectRootUnionBranchTypes` for ensuring object-only branches in root-level unions.
- Updated XAI executor logic to handle additional schema adjustments, ensuring compatibility with stricter validations.
- Extended test coverage to validate schema normalization, including both functional and custom tool scenarios.

Closes: #4397
…ecutors

- Introduced `normalizeCodexWebsocketParallelToolCalls` and `normalizeCodexParallelToolCalls` to enforce consistent `parallel_tool_calls` handling.
- Updated WebSocket and HTTP executor logic to support headers during parallel tool normalization.
- Refactored redundant logic by consolidating normalization routines for improved clarity and maintainability.
- Added a new variant `kimi-k3[1M]` with extended 1M context length support.
- Updated `kimi-k3` metadata: adjusted context length, tokens, and thinking levels.
- Enhanced descriptions to reflect the latest specifications.
…ditional header support

- Added an `incomingHeaders` argument to `applyClaudeHeaders` to enable external header injection for flexibility.
- Updated Kimi executor to delegate header support to Claude executor, facilitating upstream request logging and beta header forwarding.
- Introduced tests for delegated configuration, header handling, and upstream request/response logging to improve coverage.
fix(config): rename SyncRevision to AuthRevision in PluginsConfig
Claude Code sends the configured model name (e.g. kimi-k3[1m]) to
CLIProxyAPI. The Kimi executor forwarded this internal ID to Kimi's
https://api.kimi.com/coding endpoint. Kimi treats kimi-k3 and
kimi-k3[1m] as 256K-context models, while only bare k3 supports the
full 1M context window.

Normalize the upstream model by stripping the CLIProxyAPI kimi- prefix
and any Claude Code [1m] suffix while preserving a trailing thinking
suffix (e.g. (1024)), so that requests for kimi-k3, kimi-k3[1m],
kimi-k3(1024), and kimi-k3[1m](1024) are all sent to Kimi as k3 or
k3(1024). This applies to:

- Execute (Claude and OpenAI branches)
- ExecuteStream (Claude and OpenAI branches)
- CountTokens

Validation (using the stored Kimi token):
- GET /v1/models shows k3 with context_length 1048576.
- Direct /v1/messages calls with ~270k input tokens:
  - model=k3 succeeds.
  - model=k3[1m], kimi-k3, kimi-k3[1m] fail with:
    'Your request exceeded model token limit: 262144 (requested: 270014)'.

Add unit tests for normalizeKimiUpstreamModel.

Closes #4418

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…move deprecated code

- Updated Kimi executor to route all Claude requests through the OpenAI-compatible chat completions API.
- Removed legacy delegation to Claude executor for non-streaming and streaming execution.
- Enhanced translator integration for request normalization and Kimi model stripping.
- Updated tests to validate chat completions behavior, including upstream request logging, payload transformation, and response handling.
- Deleted Kimi K3[1M] variant and associated metadata.
- Removed "Preview" suffix from model IDs, display names, and descriptions.
- Standardized naming conventions for all Gemini 3.x models to reflect production readiness.
- Updated Kimi executor to delegate non-streaming and streaming Claude requests to the Claude executor when `SourceFormat` is `claude`.
- Injected `base_url` for Claude API compatibility during delegation.
@kaitranntt
kaitranntt merged commit c178ba8 into main Jul 18, 2026
2 checks passed
@kaitranntt
kaitranntt deleted the kai/chore/upstream-sync-v7.2.88 branch July 18, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.