auto-sync: merge upstream/main (conflicts with remote-fix)#1
auto-sync: merge upstream/main (conflicts with remote-fix)#1github-actions[bot] wants to merge 35 commits into
remote-fix)#1Conversation
- Introduced a new test file for validating the conversion of OpenAI responses to chat completions. - Implemented tests to ensure correct merging of consecutive function calls and proper handling of interrupted function calls. - Enhanced the main conversion function to buffer consecutive function calls and emit them as a single assistant message.
- Introduced a new script `docker-build-local.sh` to build a local Docker image and start services using Docker Compose. - Updated `docker-compose.yml` to allow dynamic pull policy configuration via the `CLI_PROXY_PULL_POLICY` environment variable. - Modified `Dockerfile` to support build arguments for Go module proxy settings during the `go mod download` step.
- Added validation so OpenAI-style usage parsing only accepts object payloads with token fields. - Prevented streaming usage:null chunks from publishing zero-token records before the final usage chunk arrives. - Reused the shared OpenAI-style parser for stream usage to support both chat completions and responses token field names. - Added tests covering null usage chunks and input/output token usage fields in streaming responses.
连续的function_call 转换 tool_calls
- Updated all references from v6 to v7 for `github.com/router-for-me/CLIProxyAPI`. - Ensured consistency in imports within core libraries, tests, and integration tests. - Added missing tests for new features in Redis Protocol integration.
When auth-dir is not specified in config.yaml, ResolveAuthDir returns an empty string which causes os.MkdirAll to fail with no path. Use the documented default ~/.cli-proxy-api instead. Fixes router-for-me#3272
- Added new helper methods for OAuth session management (`RegisterOAuthSession`, `CompleteOAuthSession`, etc.). - Introduced `WriteConfig` for persisting management configurations. - Exported `Handler` type and `NewHandler` constructors for SDK consumers.
…e control plane - Introduced `-home` and `-home-password` flags for specifying home control plane address and authentication. - Implemented fetching and parsing configuration from the home control plane when `-home` is used. - Adjusted server configuration handling to bypass local config files when loading from home. - Ensured compatibility with cloud deploy mode and validation of home configurations.
- Introduced `disable_cooling` metadata field for fine-grained control over cooldown scheduling. - Updated `Auth` object to include `Metadata` with conditional logic for handling empty states. - Added YAML configuration support for `disable_cooling` in API key definitions across providers. - Enhanced unit tests to validate `disable_cooling` behavior in various scenarios.
…mplify session affinity logic
fix(executor): ignore null OpenAI stream usage chunks
fix: apply default auth-dir when config value is empty
- Updated `FileTokenStore` and related stores (`objectstore`, `gitstore`, `postgresstore`) to include the `disabled` flag in metadata for token storage. - Adjusted `Auth` metadata handling to initialize empty maps when absent. - Refined logic in `auto_refresh_loop` and `conductor` to exclude `disabled` tokens from refresh checks. - Added comprehensive unit tests to verify proper handling of the `disabled` flag in storage and retrieval operations.
…dling - Updated `EnsureIndex` logic to incorporate absolute and cleaned file paths when generating auth indexes. - Refined metadata handling to include OAuth type in auth index seed. - Improved compatibility for `json` file paths as sources in auth attributes. - Added unit tests to validate correct auth index behavior for various path and type scenarios.
…s-tool-output-context Fix Responses WebSocket tool output context repair
- Introduced `SetHomeEnabled` to enable/disable request-log forwarding to the home control plane. - Implemented `forwardRequestLogToHome` for non-streaming logs and `homeStreamingLogWriter` for real-time streaming logs. - Enhanced `FileRequestLogger` to bypass local logging when home forwarding is enabled. - Updated server configuration to dynamically toggle home request-log forwarding based on changes. - Added corresponding unit tests to ensure correct forwarding behavior and fallback mechanisms.
…ble usage statistics - Added `count` attribute to `homeAuthCount` requests to improve home message batching. - Enabled usage statistics for home mode by default and added config-level enforcement. - Adjusted failure logging to include detailed metadata in `UsageReporter`. - Updated multiple executors to pass error details to `PublishFailure` for better debugging. - Enhanced unit tests to validate `count` behavior and usage statistics enforcement across components.
…ve error handling in home mode - Introduced `shouldReturnLastErrorOnPickFailure` to streamline error return logic during provider selection. - Added `isHomeRequestRetryExceededError` for better home-specific error classification. - Updated fallback conditions to enhance error handling clarity in `pickNextMixed`.
Move per-connection protocol detection (TLS handshake, reader.Peek) out of the accept loop and into a per-connection goroutine. An idle TCP connection that never sends bytes would previously block Peek(1) indefinitely, preventing all subsequent connections from being accepted and making the management/API server unresponsive. Closes router-for-me#3267
…upport - Introduced `homeRuntimeAuths` to cache home auths for websocket session reuse. - Updated `pickNextViaHome` to prioritize cached auths for pinned websocket sessions. - Implemented automatic clearing of cached home auths when home mode is disabled. - Added unit tests to validate caching behavior, clearing logic, and fallback scenarios.
…ef counting - Added `homeRuntimeAuthSessions` and `homeRuntimeAuthRefs` for scoped caching of home auths per session. - Updated `pickNextViaHome` to prevent reuse of already-tried pinned auths during session retries. - Implemented reference counting for shared auths across multiple sessions to improve memory management. - Enhanced session cleanup logic to clear cached auths only when all referencing sessions are closed. - Added unit tests to validate scoped caching, retry logic, and session cleanup behavior.
…counting - Consolidated `homeRuntimeAuths` to store a map of session-scoped auth maps, replacing `homeRuntimeAuthSessions` and `homeRuntimeAuthRefs`. - Adjusted session cleanup logic to directly remove session-scoped auths without reference counting. - Added `GetExecutionSessionAuthByID` to retrieve auths scoped to a specific execution session. - Updated tests to reflect the new session-scoped caching behavior.
- Introduced `logHomeConfigChanges` to compare old and new configs, logging detected differences. - Leveraged `diff.BuildConfigChangeDetails` for structured change detection. - Adjusted logging behavior to enable debug-level logs dynamically when required.
Clear the 10s read deadline before calling handleRedisConnection so that authenticated Redis clients are not disconnected by an i/o timeout after 10 seconds of idle time. HTTP paths already clear the deadline after routing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fix(api): prevent idle TCP connections from blocking the accept loop
- Introduced `CacheReadTokens` and `CacheCreationTokens` to enhance token breakdown. - Refactored `parseClaudeUsageNode` for cleaner and reusable logic. - Adjusted helpers and updated token calculations to align with the new fields.
…refresh - Added `isUnauthorizedError` and `hasUnauthorizedAuthFailure` to classify and handle unauthorized errors. - Introduced `refreshErrorFromError` to map errors to standardized unauthorized responses. - Modified refresh logic to stop auto-refresh retries for unauthorized errors. - Updated tests to verify unauthorized error handling and refresh retry prevention.
…ling - Introduced cluster node management with `clusterNode` and `clusterNodesEnvelope` types. - Added failover handling for reconnection failures with configurable threshold (`homeReconnectFailoverThreshold`). - Implemented node switching and dynamic cluster target updates. - Enhanced Redis client management with centralized locking for concurrency safety. - Updated configuration refresh logic to prioritize the best cluster node. - Improved debug logging for reconnect failures and node switching.
- Introduced `geminiModelsHandler` to dynamically route Gemini model requests based on home configuration. - Added `handleHomeGeminiModels` and `loadHomeModelEntries` to support home-specific Gemini model handling. - Refactored and centralized error handling logic for improved maintainability. - Enhanced response formatting with `formatHomeGeminiModels` for consistent output structure.
|
Closing — the conflict surface is fundamentally larger than what an auto-sync PR can resolve. What I foundThe 9 conflicts the workflow reported are not 9 isolated text conflicts. Underneath them:
Why this PR can't be the vehicleAuto-sync was designed for the steady-state case where the fork is roughly current with upstream and conflicts are localized. The current divergence (35 upstream commits including a major-version bump) is a planned migration, not a sync. Next stepsTo stop the daily failures while you decide on the migration, I'm pausing the `auto-sync-upstream` schedule (keeping `workflow_dispatch` so it can still be triggered manually). When you're ready to do the v7 migration, reopen this via: ``` Or do the migration in a dedicated branch first, then re-enable the schedule. The new `auto-sync-upstream-copilot` (`feat/copilot` target) is unaffected — `feat/copilot` is already on v7 via the manual merge `65aa351e`. |
|
Closed — see analysis above. Pausing the auto-sync schedule in a follow-up commit so this stops re-opening daily until a v7 migration plan is in place. |
Auto-sync from
upstream/main(router-for-me/CLIProxyAPI).Reason for manual review: conflicts with
remote-fixNew commits
disable_coolingoverride supportClaudeCodeSessionAffinitysupport and simplify session affinity logicdisabledflag in token storagecountfor home auth dispatch requests and enable usage statisticsshouldReturnLastErrorOnPickFailurehelper and improve error handling in home mode