Skip to content
Merged

mr #2

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
33130f1
fix: require antigravity project id
sususu98 May 7, 2026
809feb1
fix(antigravity): mask project_id in logs
sususu98 May 7, 2026
28dfcae
fix(api): prevent idle TCP connections from blocking the accept loop
lihan3238 May 9, 2026
c5596e0
fix(api): clear sniff deadline before entering Redis handler
lihan3238 May 10, 2026
041ccf0
Merge pull request #3303 from lihan3238/fix-3267
luispater May 11, 2026
bd8c05a
feat(usage): add support for detailed token breakdown in usage tracking
luispater May 12, 2026
6bfcb0c
feat(auth): improve unauthorized error handling for refresh and auto-…
luispater May 12, 2026
bfdc0b3
fix: scope antigravity credits fallback gate
sususu98 May 13, 2026
bcbb949
feat(client): add cluster node failover and improve reconnection hand…
luispater May 13, 2026
437aa87
feat(api): add dynamic handler for Gemini models with home integration
luispater May 13, 2026
3a9fb37
fix(home): implement home dispatch headers and enhance Gemini model h…
luispater May 13, 2026
229d03a
feat(auth): add support for disabling auth via metadata
luispater May 14, 2026
1d529c3
feat(redis): implement Pub/Sub support for usage tracking
luispater May 15, 2026
9d01c80
feat(redis): implement Pub/Sub support for usage tracking
luispater May 15, 2026
30a8824
fix(gitstore): adjust garbage collection to run after push operation
luispater May 15, 2026
e7a1859
feat(api): add request body decoding with Content-Encoding support
luispater May 16, 2026
82c9e0d
feat(api, watcher): add zstd decoding for request logs and payload di…
luispater May 16, 2026
7a1a340
fix(home): use net.JoinHostPort for consistent host:port formatting
luispater May 16, 2026
48104ab
feat(home): implement home control plane integration with Redis and T…
hkfires May 16, 2026
644d5ea
feat(home): add support for disabling cluster discovery in Redis conf…
hkfires May 16, 2026
f4c6c41
Merge pull request #3430 from router-for-me/home
luispater May 16, 2026
c66fa37
feat(home): add cluster nodes payload parsing and Redis channel handling
luispater May 16, 2026
cd0cea3
refactor(server): consolidate `home_flag` logic into `main.go` for be…
luispater May 16, 2026
e4c9570
feat(auth): add OAuth2 support for xAI with PKCE and token persistence
luispater May 16, 2026
2ff9e33
feat(api, xai): integrate xAI Grok image models and extend API endpoi…
luispater May 16, 2026
53d1fd6
feat(api, xai): add xAI Grok video model support with API integration
luispater May 16, 2026
d606faa
fix: strip Claude Code attribution from non-Anthropic translations
madwiki May 16, 2026
088ab33
feat(api): add Codex client models support for OpenAI API
luispater May 16, 2026
ddd1053
feat(xai): normalize xAI input reasoning items and enhance test cases
luispater May 16, 2026
96754f5
refactor(api): move Codex client model handling to `registry` package
luispater May 16, 2026
8b3670b
feat(xai): support namespace tools and enhance tool normalization logic
luispater May 16, 2026
2607888
fix(xai): default missing function tool parameters
ben-vargas May 16, 2026
74cb53d
feat(xai): support namespace tools and enhance tool normalization logic
luispater May 17, 2026
4b13f9c
Merge pull request #3439 from ben-vargas/fix-grok-tool-params
luispater May 17, 2026
be841b8
log(registry): replace panic with warning on embedded model parse fai…
luispater May 17, 2026
26d13af
feat(runtime): enhance payload rule resolution with dynamic path support
luispater May 17, 2026
2007a89
feat(runtime): enhance payload rule resolution with dynamic path support
luispater May 17, 2026
9ef99aa
refactor(runtime): rename `FormProtocol` to `FromProtocol` across pay…
luispater May 17, 2026
605adaa
feat(api): add support for local management password validation and s…
luispater May 17, 2026
ed0ac68
feat(server): add HOME_ADDR and HOME_PASSWORD env var fallback for ho…
May 17, 2026
5f03965
refactor: move home env vars after godotenv and use lookupEnv helper
May 18, 2026
66c5d60
refactor(api): remove `newTestServerWithOptions` and spoofed IP rejec…
luispater May 18, 2026
64d233f
Merge pull request #3448 from LongDinhh/feat/home-env-vars
luispater May 18, 2026
1c2153a
fix(openai-claude): stabilize streaming tool_use blocks
May 18, 2026
4ad6ffe
Merge pull request #3438 from madwiki/fix/strip-claude-code-attribution
luispater May 18, 2026
2460205
Merge pull request #2926 from slicenferqin/fix-tool-use-name-loss-and…
luispater May 18, 2026
ec79951
fix(proxy): support HTTP CONNECT dialer
sususu98 May 18, 2026
8bc2eff
fix: shorten claude codex tool call ids
sususu98 May 18, 2026
2710f56
Merge pull request #3450 from sususu98/fix/http-connect-proxy-dialer
luispater May 18, 2026
cc0cb05
Merge pull request #3468 from sususu98/fix/claude-codex-call-id-length
luispater May 18, 2026
1583cb4
Cap Gemini max output tokens
sususu98 May 18, 2026
32a0d69
Fix Antigravity Gemini thought signatures
sususu98 May 18, 2026
77ba15f
feat(server): add mTLS certificate bootstrap via JWT for Home connect…
luispater May 18, 2026
ad98c95
feat(runtime): track upstream response headers in logging and usage r…
luispater May 18, 2026
bac006e
feat(thinking): add xAI provider support with reasoning.effort implem…
luispater May 18, 2026
6448235
Merge pull request #3469 from sususu98/fix/gemini-max-output-token-cap
sususu98 May 19, 2026
b67eb6f
Merge pull request #3470 from sususu98/fix/antigravity-gemini-thought…
sususu98 May 19, 2026
feebe6c
feat(api): add OpenAI compatibility for image models
luispater May 19, 2026
bbe30f5
feat(server): enhance Home certificate handling with CA fingerprint v…
luispater May 19, 2026
ad86830
fix codex context length stream errors
sususu98 May 19, 2026
67f2251
style(docs): improve sponsor section clarity in README files
luispater May 19, 2026
7efc162
feat(docker): add cluster-specific docker-compose configuration for C…
hkfires May 19, 2026
bb5ac40
feat(client): add timeout handling for Redis operations and subscript…
luispater May 19, 2026
7f68fa2
Add Codex Switch tool to README
9ycrooked May 19, 2026
5ef7693
Update README.md
9ycrooked May 19, 2026
0de0ad0
Add reasoning effort to usage events
yavon007 May 19, 2026
b9589e8
Merge pull request #3482 from 9ycrooked/patch-1
luispater May 19, 2026
99fa530
test: remove unused Redis protocol tests and helpers
luispater May 19, 2026
ea25949
feat(models): add Gemini 3.5 Flash models to registry
luispater May 19, 2026
de03949
feat(models): expand supported reasoning levels for Codex
luispater May 19, 2026
fdffe49
feat(models): register Gemini 3.5 Flash with dynamic thinking levels
luispater May 20, 2026
0ec07e5
feat(models): add Gemini 3.5 Flash to registry with enhanced thinking…
luispater May 20, 2026
1c632d1
fix(translator): skip empty text parts in Claude request conversion
luispater May 20, 2026
f1ee883
Merge pull request #3484 from yavon007/main
luispater May 20, 2026
a726e37
feat(redis): enhance Redis protocol handling with subscription and qu…
luispater May 20, 2026
42e9605
Merge pull request #3254 from sususu98/fix/antigravity-project-id-onb…
luispater May 20, 2026
8b9ecff
Merge pull request #3382 from sususu98/dev
luispater May 20, 2026
48a1c88
Merge pull request #3476 from sususu98/fix/codex-context-length-strea…
luispater May 20, 2026
21fad9d
Merge pull request #3477 from router-for-me/cluster
luispater May 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.cluster.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Cluster JWT example.
# After deploying https://github.com/router-for-me/CLIProxyAPIHome, get the JWT value with:
# curl -sS -X POST "http://<home-host>:8327/v0/management/certificates/clients" -H "X-MANAGEMENT-KEY: <management-key>" | jq -r '.home_jwt'
# Then paste it into HOME_JWT here or export it before starting Compose.
HOME_JWT=your-home-jwt-here
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

English | [中文](README_CN.md) | [日本語](README_JA.md)

A proxy server that provides OpenAI/Gemini/Claude/Codex compatible API interfaces for CLI.
A proxy server that provides OpenAI/Gemini/Claude/Codex/Grok compatible API interfaces for CLI.

It now also supports OpenAI Codex (GPT models) and Claude Code via OAuth.

Expand Down Expand Up @@ -32,29 +32,31 @@ PackyCode provides special discounts for our software users: register using <a h
</tr>
<tr>
<td width="180"><a href="https://coder.visioncoder.cn"><img src="./assets/visioncoder.png" alt="VisionCoder" width="150"></a></td>
<td>Thanks to VisionCoder for supporting this project. <a href="https://coder.visioncoder.cn" target="_blank">VisionCoder Developer Platform</a> is a reliable and efficient API relay service provider, offering access to mainstream AI models such as Claude Code, Codex, and Gemini. It helps developers and teams integrate AI capabilities more easily and improve productivity.
<td>Thanks to <b>VisionCoder</b> for supporting this project. <a href="https://coder.visioncoder.cn" target="_blank">VisionCoder Developer Platform</a> is a reliable and efficient API relay service provider, offering access to mainstream AI models such as Claude Code, Codex, and Gemini. It helps developers and teams integrate AI capabilities more easily and improve productivity.
<p></p>
VisionCoder is also offering our users a limited-time <a href="https://coder.visioncoder.cn" target="_blank">Token Plan</a> promotion: buy 1 month and get 1 month free.</td>
VisionCoder is also offering our users a limited-time <a href="https://coder.visioncoder.cn" target="_blank">Token Plan</a> promotion: <b>buy 1 month and get 1 month free</b>.</td>
</tr>
</tbody>
</table>

## Overview

- OpenAI/Gemini/Claude compatible API endpoints for CLI models
- OpenAI/Gemini/Claude/Grok compatible API endpoints for CLI models
- OpenAI Codex support (GPT models) via OAuth login
- Claude Code support via OAuth login
- Grok Build support via OAuth login
- Amp CLI and IDE extensions support with provider routing
- Streaming, non-streaming, and WebSocket responses where supported
- Function calling/tools support
- Multimodal input support (text and images)
- Multiple accounts with round-robin load balancing (Gemini, OpenAI, Claude)
- Simple CLI authentication flows (Gemini, OpenAI, Claude)
- Multiple accounts with round-robin load balancing (Gemini, OpenAI, Claude, Grok)
- Simple CLI authentication flows (Gemini, OpenAI, Claude, Grok)
- Generative Language API Key support
- AI Studio Build multi-account load balancing
- Gemini CLI multi-account load balancing
- Claude Code multi-account load balancing
- OpenAI Codex multi-account load balancing
- Grok Build multi-account load balancing
- OpenAI-compatible upstream providers via config (e.g., OpenRouter)
- Reusable Go SDK for embedding the proxy (see `docs/sdk-usage.md`)

Expand Down Expand Up @@ -220,6 +222,10 @@ OmniRoute is an AI gateway for multi-provider LLMs: an OpenAI-compatible endpoin

A public CLIProxyAPI-compatible fork and bundled management panel. It keeps upstream-style usage while restoring built-in usage statistics, adding cache hit rate, first-byte latency, TPS tracking, and Docker-oriented self-hosted installation docs.

### [Codex Switch](https://github.com/9ycrooked/CodexSwitch)

This is a tool built with Tauri 2 + Vue 3 for managing multiple OpenAI Codex desktop accounts. Switch between saved ChatGPT/Codex certification profiles, check 5-hour and weekly quota usage in real time, verify token health, view active account details, and import or save auth.json files without manual copying.

> [!NOTE]
> If you have developed a port of CLIProxyAPI or a project inspired by it, please open a PR to add it to this list.

Expand Down
18 changes: 12 additions & 6 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English](README.md) | 中文 | [日本語](README_JA.md)

一个为 CLI 提供 OpenAI/Gemini/Claude/Codex 兼容 API 接口的代理服务器。
一个为 CLI 提供 OpenAI/Gemini/Claude/Codex/Grok 兼容 API 接口的代理服务器。

现已支持通过 OAuth 登录接入 OpenAI Codex(GPT 系列)和 Claude Code。

Expand Down Expand Up @@ -32,29 +32,31 @@ PackyCode 为本软件用户提供了特别优惠:使用<a href="https://www.p
</tr>
<tr>
<td width="180"><a href="https://coder.visioncoder.cn"><img src="./assets/visioncoder.png" alt="VisionCoder" width="150"></a></td>
<td>感谢 VisionCoder 对本项目的支持。<a href="https://coder.visioncoder.cn" target="_blank">VisionCoder 开发平台</a> 是一个可靠高效的 API 中继服务提供商,提供 Claude Code、Codex、Gemini 等主流 AI 模型,帮助开发者和团队更轻松地集成 AI 功能,提升工作效率。
<td>感谢 <b>VisionCoder</b> 对本项目的支持。<a href="https://coder.visioncoder.cn" target="_blank">VisionCoder 开发平台</a> 是一个可靠高效的 API 中继服务提供商,提供 Claude Code、Codex、Gemini 等主流 AI 模型,帮助开发者和团队更轻松地集成 AI 功能,提升工作效率。
<p></p>
VisionCoder 还为我们的用户提供 <a href="https://coder.visioncoder.cn" target="_blank">Token Plan</a> 限时活动:购买 1 个月,赠送 1 个月。</td>
VisionCoder 还为我们的用户提供 <a href="https://coder.visioncoder.cn" target="_blank">Token Plan</a> 限时活动:<b>购买 1 个月,赠送 1 个月</b>。</td>
</tr>
</tbody>
</table>


## 功能特性

- 为 CLI 模型提供 OpenAI/Gemini/Claude/Codex 兼容的 API 端点
- 为 CLI 模型提供 OpenAI/Gemini/Claude/Codex/Grok 兼容的 API 端点
- 新增 OpenAI Codex(GPT 系列)支持(OAuth 登录)
- 新增 Claude Code 支持(OAuth 登录)
- 新增 Grok Build 支持(OAuth 登录)
- 支持流式、非流式响应,以及受支持场景下的 WebSocket 响应
- 函数调用/工具支持
- 多模态输入(文本、图片)
- 多账户支持与轮询负载均衡(Gemini、OpenAI、Claude)
- 简单的 CLI 身份验证流程(Gemini、OpenAI、Claude)
- 多账户支持与轮询负载均衡(Gemini、OpenAI、Claude、Grok
- 简单的 CLI 身份验证流程(Gemini、OpenAI、Claude、Grok
- 支持 Gemini AIStudio API 密钥
- 支持 AI Studio Build 多账户轮询
- 支持 Gemini CLI 多账户轮询
- 支持 Claude Code 多账户轮询
- 支持 OpenAI Codex 多账户轮询
- 支持 Grok Build 多账户轮询
- 通过配置接入上游 OpenAI 兼容提供商(例如 OpenRouter)
- 可复用的 Go SDK(见 `docs/sdk-usage_CN.md`)

Expand Down Expand Up @@ -216,6 +218,10 @@ OmniRoute 是一个面向多供应商大语言模型的 AI 网关:它提供兼

一个公开的 CLIProxyAPI 兼容二开版本和配套管理面板,尽量保持与上游一致的使用方式,同时恢复内置使用量统计,并补充缓存命中率、首字响应时间、TPS 记录和面向 Docker 自托管的安装说明。

### [Codex Switch](https://github.com/9ycrooked/CodexSwitch)

这是一个使用 Tauri 2 + Vue 3 构建的工具,用于管理多个 OpenAI Codex 桌面账户。它可以在已保存的 ChatGPT/Codex 认证配置之间切换,实时查看 5 小时和每周配额使用情况,验证 token 健康状态,查看当前账户详情,并在无需手动复制的情况下导入或保存 auth.json 文件。

> [!NOTE]
> 如果你开发了 CLIProxyAPI 的移植或衍生项目,请提交 PR 将其添加到此列表中。

Expand Down
16 changes: 11 additions & 5 deletions README_JA.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English](README.md) | [中文](README_CN.md) | 日本語

CLI向けのOpenAI/Gemini/Claude/Codex互換APIインターフェースを提供するプロキシサーバーです
CLI向けのOpenAI/Gemini/Claude/Codex/Grok互換APIインターフェースを提供するプロキシサーバーです

OAuth経由でOpenAI Codex(GPTモデル)およびClaude Codeもサポートしています。

Expand Down Expand Up @@ -32,27 +32,29 @@ PackyCodeは当ソフトウェアのユーザーに特別割引を提供して
</tr>
<tr>
<td width="180"><a href="https://coder.visioncoder.cn"><img src="./assets/visioncoder.png" alt="VisionCoder" width="150"></a></td>
<td>VisionCoderのご支援に感謝します!<a href="https://coder.visioncoder.cn">VisionCoder 開発プラットフォーム</a> は、信頼性が高く効率的なAPIリレーサービスプロバイダーで、Claude Code、Codex、Geminiなどの主要AIモデルを提供し、開発者やチームがより簡単にAI機能を統合して生産性を向上できるよう支援します。さらに、VisionCoderはユーザー向けに <a href="https://coder.visioncoder.cn">Token Plan</a> の期間限定キャンペーン(1か月購入で1か月分プレゼント)も提供しています。</td>
<td><b>VisionCoder</b>のご支援に感謝します!<a href="https://coder.visioncoder.cn">VisionCoder 開発プラットフォーム</a> は、信頼性が高く効率的なAPIリレーサービスプロバイダーで、Claude Code、Codex、Geminiなどの主要AIモデルを提供し、開発者やチームがより簡単にAI機能を統合して生産性を向上できるよう支援します。さらに、VisionCoderはユーザー向けに <a href="https://coder.visioncoder.cn">Token Plan</a> の期間限定キャンペーン(1か月購入で1か月分プレゼント)も提供しています。</td>
</tr>
</tbody>
</table>

## 概要

- CLIモデル向けのOpenAI/Gemini/Claude互換APIエンドポイント
- CLIモデル向けのOpenAI/Gemini/Claude/Grok互換APIエンドポイント
- OAuthログインによるOpenAI Codexサポート(GPTモデル)
- OAuthログインによるClaude Codeサポート
- OAuthログインによるGrok Buildサポート
- プロバイダールーティングによるAmp CLIおよびIDE拡張機能のサポート
- ストリーミング、非ストリーミング、および対応環境でのWebSocketレスポンス
- 関数呼び出し/ツールのサポート
- マルチモーダル入力サポート(テキストと画像)
- ラウンドロビン負荷分散による複数アカウント対応(Gemini、OpenAI、Claude)
- シンプルなCLI認証フロー(Gemini、OpenAI、Claude)
- ラウンドロビン負荷分散による複数アカウント対応(Gemini、OpenAI、Claude、Grok
- シンプルなCLI認証フロー(Gemini、OpenAI、Claude、Grok
- Generative Language APIキーのサポート
- AI Studioビルドのマルチアカウント負荷分散
- Gemini CLIのマルチアカウント負荷分散
- Claude Codeのマルチアカウント負荷分散
- OpenAI Codexのマルチアカウント負荷分散
- Grok Buildのマルチアカウント負荷分散
- 設定によるOpenAI互換アップストリームプロバイダー(例:OpenRouter)
- プロキシ埋め込み用の再利用可能なGo SDK(`docs/sdk-usage.md`を参照)

Expand Down Expand Up @@ -215,6 +217,10 @@ OmniRouteはマルチプロバイダーLLM向けのAIゲートウェイです:

上流に近い使い方を維持する公開CLIProxyAPI互換フォーク兼管理パネルです。内蔵の使用量統計を復元し、キャッシュヒット率、初回バイト待ち時間、TPSの記録、Docker向けのセルフホスト手順を追加しています。

### [Codex Switch](https://github.com/9ycrooked/CodexSwitch)

Tauri 2 + Vue 3で構築された、複数のOpenAI Codexデスクトップアカウントを管理するためのツールです。保存済みのChatGPT/Codex認証プロファイルを切り替え、5時間および週次クォータ使用量をリアルタイムで確認し、tokenの状態を検証し、現在のアカウント詳細を表示し、手動コピーなしでauth.jsonファイルをインポートまたは保存できます。

> [!NOTE]
> CLIProxyAPIの移植版またはそれに触発されたプロジェクトを開発した場合は、PRを送ってこのリストに追加してください。

Expand Down
56 changes: 26 additions & 30 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import (
"fmt"
"io"
"io/fs"
"net"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -68,13 +66,14 @@ func main() {
var oauthCallbackPort int
var antigravityLogin bool
var kimiLogin bool
var xaiLogin bool
var projectID string
var vertexImport string
var vertexImportPrefix string
var configPath string
var password string
var homeAddr string
var homePassword string
var homeJWT string
var homeDisableClusterDiscovery bool
var tuiMode bool
var standalone bool
var localModel bool
Expand All @@ -88,13 +87,14 @@ func main() {
flag.IntVar(&oauthCallbackPort, "oauth-callback-port", 0, "Override OAuth callback port (defaults to provider-specific port)")
flag.BoolVar(&antigravityLogin, "antigravity-login", false, "Login to Antigravity using OAuth")
flag.BoolVar(&kimiLogin, "kimi-login", false, "Login to Kimi using OAuth")
flag.BoolVar(&xaiLogin, "xai-login", false, "Login to xAI using OAuth")
flag.StringVar(&projectID, "project_id", "", "Project ID (Gemini only, not required)")
flag.StringVar(&configPath, "config", DefaultConfigPath, "Configure File Path")
flag.StringVar(&vertexImport, "vertex-import", "", "Import Vertex service account key JSON file")
flag.StringVar(&vertexImportPrefix, "vertex-import-prefix", "", "Prefix for Vertex model namespacing (use with -vertex-import)")
flag.StringVar(&password, "password", "", "")
flag.StringVar(&homeAddr, "home", "", "Home control plane address in host:port format (loads config from home and skips local config file)")
flag.StringVar(&homePassword, "home-password", "", "Home control plane password (Redis AUTH)")
flag.StringVar(&homeJWT, "home-jwt", "", "Home control plane JWT for mTLS certificate bootstrap and connection")
flag.BoolVar(&homeDisableClusterDiscovery, "home-disable-cluster-discovery", false, "Disable Home CLUSTER NODES discovery and keep using the configured -home-jwt address")
flag.BoolVar(&tuiMode, "tui", false, "Start with terminal management UI")
flag.BoolVar(&standalone, "standalone", false, "In TUI mode, start an embedded local server")
flag.BoolVar(&localModel, "local-model", false, "Use embedded model catalog only, skip remote model fetching")
Expand Down Expand Up @@ -181,6 +181,13 @@ func main() {
return "", false
}
writableBase := util.WritablePath()

if strings.TrimSpace(homeJWT) == "" {
if v, ok := lookupEnv("HOME_JWT", "home_jwt"); ok {
homeJWT = v
}
}

if value, ok := lookupEnv("PGSTORE_DSN", "pgstore_dsn"); ok {
usePostgresStore = true
pgStoreDSN = value
Expand Down Expand Up @@ -244,37 +251,24 @@ func main() {
// Determine and load the configuration file.
// Prefer the Postgres store when configured, otherwise fallback to git or local files.
var configFilePath string
if strings.TrimSpace(homeAddr) != "" {
if strings.TrimSpace(homeJWT) != "" {
configLoadedFromHome = true
trimmedHomePassword := strings.TrimSpace(homePassword)
host, portStr, errSplit := net.SplitHostPort(strings.TrimSpace(homeAddr))
if errSplit != nil {
log.Errorf("invalid -home address %q (expected host:port): %v", homeAddr, errSplit)
return
}
host = strings.TrimSpace(host)
if host == "" {
log.Errorf("invalid -home address %q: host is empty", homeAddr)
return
}
port, errPort := strconv.Atoi(strings.TrimSpace(portStr))
if errPort != nil || port <= 0 {
log.Errorf("invalid -home address %q: invalid port %q", homeAddr, portStr)
ctxHome, cancelHome := context.WithTimeout(context.Background(), 30*time.Second)
homeCfg, errHomeCfg := home.ConfigFromJWT(ctxHome, homeJWT)
cancelHome()
if errHomeCfg != nil {
log.Errorf("invalid -home-jwt: %v", errHomeCfg)
return
}

homeCfg := config.HomeConfig{
Enabled: true,
Host: host,
Port: port,
Password: trimmedHomePassword,
if homeDisableClusterDiscovery {
homeCfg.DisableClusterDiscovery = true
}
homeClient := home.New(homeCfg)
defer homeClient.Close()

ctxHome, cancelHome := context.WithTimeout(context.Background(), 30*time.Second)
raw, errGetConfig := homeClient.GetConfig(ctxHome)
cancelHome()
ctxHomeConfig, cancelHomeConfig := context.WithTimeout(context.Background(), 30*time.Second)
raw, errGetConfig := homeClient.GetConfig(ctxHomeConfig)
cancelHomeConfig()
if errGetConfig != nil {
log.Errorf("failed to fetch config from home: %v", errGetConfig)
return
Expand Down Expand Up @@ -554,6 +548,8 @@ func main() {
cmd.DoClaudeLogin(cfg, options)
} else if kimiLogin {
cmd.DoKimiLogin(cfg, options)
} else if xaiLogin {
cmd.DoXAILogin(cfg, options)
} else {
// In cloud deploy mode without config file, just wait for shutdown signals
if isCloudDeploy && !configFileExists {
Expand Down
Loading
Loading