Skip to content

Commit 9aa8c1e

Browse files
committed
feat(settings): add CLIProxyAPI preset quick-pick
Adds a CLIProxyAPI entry to the Add Provider menu so users can one-click into AddCustomProviderModal pre-filled with the CPA endpoint (http://127.0.0.1:8317, anthropic wire). The proxy is heavily requested by Chinese users who run `router-for-me/CLIProxyAPI` to wrap their Claude/Codex/Gemini OAuth subscriptions. - packages/shared: new `cli-proxy-api` preset in PROXY_PRESETS - packages/i18n: `settings.providers.cliProxyApi.*` keys (en + zh-CN) - apps/desktop: AddProviderMenu gains CLIProxyAPI item that opens AddCustomProviderModal with pre-filled initialValues; claude-cli identity headers are injected automatically by the existing shouldForceClaudeCodeIdentity path
1 parent 5727a09 commit 9aa8c1e

5 files changed

Lines changed: 59 additions & 0 deletions

File tree

.changeset/cpa-preset.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@open-codesign/desktop': minor
3+
'@open-codesign/shared': patch
4+
'@open-codesign/i18n': patch
5+
---
6+
7+
feat(settings): add CLIProxyAPI preset quick-pick
8+
9+
Adds CLIProxyAPI (`router-for-me/CLIProxyAPI`) as a first-class preset in the Add Provider menu. CLIProxyAPI is a Go local proxy on port 8317 that wraps Claude/Codex/Gemini OAuth subscriptions into a unified Anthropic Messages API — heavily requested by the Chinese user base.
10+
11+
- `packages/shared`: new `cli-proxy-api` entry in `PROXY_PRESETS` (anthropic wire, `http://127.0.0.1:8317`)
12+
- `packages/i18n`: `settings.providers.cliProxyApi.*` keys in both `en.json` and `zh-CN.json` (preset name, description, api-key-optional hint, thinking-budget hint, model discovery strings)
13+
- `apps/desktop`: `AddProviderMenu` gains a CLIProxyAPI item that opens `AddCustomProviderModal` pre-filled with the CPA endpoint and anthropic wire; claude-cli identity headers are injected automatically by the existing `shouldForceClaudeCodeIdentity` path (no extra code needed)

apps/desktop/src/renderer/src/components/Settings.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,16 @@ function ModelsTab() {
15241524
setShowAddMenu(false);
15251525
setShowAddCustom(true);
15261526
}}
1527+
onAddCliProxyApi={() => {
1528+
setShowAddMenu(false);
1529+
setCustomProviderPreset({
1530+
name: 'CLIProxyAPI',
1531+
baseUrl: 'http://127.0.0.1:8317',
1532+
wire: 'anthropic',
1533+
defaultModel: '',
1534+
});
1535+
setShowAddCustom(true);
1536+
}}
15271537
/>
15281538
</div>
15291539

@@ -2130,6 +2140,7 @@ interface AddProviderMenuProps {
21302140
onImportCodex: () => void;
21312141
onImportClaudeCode: () => void;
21322142
onAddCustom: () => void;
2143+
onAddCliProxyApi: () => void;
21332144
}
21342145

21352146
function AddProviderMenu({
@@ -2139,6 +2150,7 @@ function AddProviderMenu({
21392150
onImportCodex,
21402151
onImportClaudeCode,
21412152
onAddCustom,
2153+
onAddCliProxyApi,
21422154
}: AddProviderMenuProps) {
21432155
const t = useT();
21442156
const rootRef = useRef<HTMLDivElement>(null);
@@ -2195,6 +2207,15 @@ function AddProviderMenu({
21952207
disabled: false,
21962208
onClick: onAddCustom,
21972209
},
2210+
{
2211+
key: 'cli-proxy-api',
2212+
label: t('settings.providers.cliProxyApi.presetName', { defaultValue: 'CLIProxyAPI' }),
2213+
desc: t('settings.providers.cliProxyApi.presetDescription', {
2214+
defaultValue: 'Local proxy that wraps Claude/Codex/Gemini OAuth subscriptions',
2215+
}),
2216+
disabled: false,
2217+
onClick: onAddCliProxyApi,
2218+
},
21982219
];
21992220

22002221
return (

packages/i18n/src/locales/en.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@
297297
"connectionOk": "Connection OK",
298298
"connectionFailed": "Connection failed"
299299
},
300+
"cliProxyApi": {
301+
"presetName": "CLIProxyAPI",
302+
"presetDescription": "Local proxy that wraps Claude/Codex/Gemini OAuth subscriptions",
303+
"apiKeyOptional": "API key only required if you configured `api-keys` in CPA config.yaml",
304+
"thinkingHint": "Tip: append `(high)` / `(xhigh)` / `(8192)` to model name to control thinking budget",
305+
"discoveringModels": "Discovering models...",
306+
"discoveredModels": "Found {{count}} models",
307+
"discoveryFailed": "Could not connect to CPA"
308+
},
300309
"reasoning": {
301310
"label": "Reasoning depth",
302311
"default": "Default (auto)",

packages/i18n/src/locales/zh-CN.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@
297297
"connectionOk": "连接正常",
298298
"connectionFailed": "连接失败"
299299
},
300+
"cliProxyApi": {
301+
"presetName": "CLIProxyAPI",
302+
"presetDescription": "本地反代,将 Claude/Codex/Gemini 的订阅账号包装成统一 API",
303+
"apiKeyOptional": "仅当你在 CPA config.yaml 里配置了 api-keys 才需要填",
304+
"thinkingHint": "提示:在 model 名后加 `(high)` / `(xhigh)` / `(8192)` 可控制思考力度",
305+
"discoveringModels": "正在发现模型…",
306+
"discoveredModels": "发现 {{count}} 个模型",
307+
"discoveryFailed": "连接 CPA 失败"
308+
},
300309
"reasoning": {
301310
"label": "推理深度",
302311
"default": "默认(自动)",

packages/shared/src/proxy-presets.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ export const PROXY_PRESETS = [
5252
baseUrl: 'http://localhost:3000/v1',
5353
notes: 'Edit URL to your deployment',
5454
},
55+
{
56+
id: 'cli-proxy-api',
57+
label: 'CLIProxyAPI',
58+
provider: 'anthropic',
59+
baseUrl: 'http://127.0.0.1:8317',
60+
notes: '',
61+
},
5562
{
5663
id: 'custom',
5764
label: 'Custom...',

0 commit comments

Comments
 (0)