Skip to content

Commit 20bf626

Browse files
hubo1989kaitranntt
andauthored
feat(cliproxy): add iFlow OAuth provider support (#55)
Add iFlow as a new OAuth-based provider for CLIProxy. Changes: - Add config/base-iflow.settings.json with iFlow provider configuration - Add iFlow to CLIProxyProvider type - Add iFlow OAuth config (authUrl, scopes, authFlag) - Add iFlow to provider display names, auth prefixes, and type values - Update config-generator to support iFlow provider - Update base-qwen.settings.json models (qwen3-coder-plus) Co-authored-by: kaitranntt <[email protected]>
1 parent 8fee404 commit 20bf626

File tree

5 files changed

+52
-12
lines changed

5 files changed

+52
-12
lines changed

config/base-iflow.settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"env": {
3+
"ANTHROPIC_BASE_URL": "http://127.0.0.1:8317/api/provider/iflow",
4+
"ANTHROPIC_AUTH_TOKEN": "ccs-internal-managed",
5+
"ANTHROPIC_MODEL": "deepseek-v3.2",
6+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "kimi-k2-thinking",
7+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v3.2",
8+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "minimax-m2"
9+
}
10+
}

config/base-qwen.settings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"env": {
33
"ANTHROPIC_BASE_URL": "http://127.0.0.1:8317/api/provider/qwen",
44
"ANTHROPIC_AUTH_TOKEN": "ccs-internal-managed",
5-
"ANTHROPIC_MODEL": "qwen3-coder",
6-
"ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3-coder",
7-
"ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3-coder",
8-
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3-coder"
5+
"ANTHROPIC_MODEL": "qwen3-coder-plus",
6+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3-coder-plus",
7+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3-coder-plus",
8+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3-vl-plus"
99
}
1010
}

src/cliproxy/auth-handler.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
* Each provider has its own directory to avoid conflicts.
1313
*/
1414

15+
import { execSync, spawn } from 'child_process';
1516
import * as fs from 'fs';
1617
import * as path from 'path';
17-
import { spawn, execSync } from 'child_process';
1818
import { ProgressIndicator } from '../utils/progress-indicator';
19-
import { getProviderAuthDir, generateConfig } from './config-generator';
2019
import { ensureCLIProxyBinary } from './binary-manager';
20+
import { generateConfig, getProviderAuthDir } from './config-generator';
2121
import { CLIProxyProvider } from './types';
2222

2323
/**
@@ -169,6 +169,13 @@ const OAUTH_CONFIGS: Record<CLIProxyProvider, ProviderOAuthConfig> = {
169169
scopes: ['openid', 'profile', 'email', 'model.completion'],
170170
authFlag: '--qwen-login',
171171
},
172+
iflow: {
173+
provider: 'iflow',
174+
displayName: 'iFlow',
175+
authUrl: 'https://iflow.cn/oauth',
176+
scopes: ['phone', 'profile', 'email'],
177+
authFlag: '--iflow-login',
178+
},
172179
};
173180

174181
/**
@@ -199,6 +206,7 @@ const PROVIDER_AUTH_PREFIXES: Record<CLIProxyProvider, string[]> = {
199206
codex: ['codex-', 'openai-'],
200207
agy: ['antigravity-', 'agy-'],
201208
qwen: ['qwen-'],
209+
iflow: ['iflow-'],
202210
};
203211

204212
/**
@@ -210,6 +218,7 @@ const PROVIDER_TYPE_VALUES: Record<CLIProxyProvider, string[]> = {
210218
codex: ['codex'],
211219
agy: ['antigravity'],
212220
qwen: ['qwen'],
221+
iflow: ['iflow'],
213222
};
214223

215224
/**
@@ -327,7 +336,7 @@ export function getAuthStatus(provider: CLIProxyProvider): AuthStatus {
327336
* Get auth status for all providers
328337
*/
329338
export function getAllAuthStatus(): AuthStatus[] {
330-
const providers: CLIProxyProvider[] = ['gemini', 'codex', 'agy', 'qwen'];
339+
const providers: CLIProxyProvider[] = ['gemini', 'codex', 'agy', 'qwen', 'iflow'];
331340
return providers.map(getAuthStatus);
332341
}
333342

src/cliproxy/config-generator.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as fs from 'fs';
1212
import * as path from 'path';
1313
import { getCcsDir } from '../utils/config-manager';
1414
import { CLIProxyProvider, ProviderConfig, ProviderModelMapping } from './types';
15-
import { getModelMappingFromConfig } from './base-config-loader';
15+
import { getModelMappingFromConfig, getEnvVarsFromConfig } from './base-config-loader';
1616

1717
/** Settings file structure for user overrides */
1818
interface ProviderSettings {
@@ -31,6 +31,7 @@ const PROVIDER_DISPLAY_NAMES: Record<CLIProxyProvider, string> = {
3131
codex: 'Codex',
3232
agy: 'Antigravity',
3333
qwen: 'Qwen Code',
34+
iflow: 'iFlow',
3435
};
3536

3637
/**
@@ -197,7 +198,11 @@ export function getClaudeEnvVars(
197198
): NodeJS.ProcessEnv {
198199
const models = getModelMapping(provider);
199200

200-
return {
201+
// Base env vars from config file (includes ANTHROPIC_MAX_TOKENS, etc.)
202+
const baseEnvVars = getEnvVarsFromConfig(provider);
203+
204+
// Core env vars that we always set dynamically
205+
const coreEnvVars = {
201206
// Provider-specific endpoint - routes to correct provider via URL path
202207
ANTHROPIC_BASE_URL: `http://127.0.0.1:${port}/api/provider/${provider}`,
203208
ANTHROPIC_AUTH_TOKEN: CCS_INTERNAL_API_KEY,
@@ -206,6 +211,23 @@ export function getClaudeEnvVars(
206211
ANTHROPIC_DEFAULT_SONNET_MODEL: models.sonnetModel || models.claudeModel,
207212
ANTHROPIC_DEFAULT_HAIKU_MODEL: models.haikuModel || models.claudeModel,
208213
};
214+
215+
// Filter out core env vars from base config to avoid conflicts
216+
const {
217+
ANTHROPIC_BASE_URL: _baseUrl,
218+
ANTHROPIC_AUTH_TOKEN: _authToken,
219+
ANTHROPIC_MODEL: _model,
220+
ANTHROPIC_DEFAULT_OPUS_MODEL: _opusModel,
221+
ANTHROPIC_DEFAULT_SONNET_MODEL: _sonnetModel,
222+
ANTHROPIC_DEFAULT_HAIKU_MODEL: _haikuModel,
223+
...additionalEnvVars
224+
} = baseEnvVars;
225+
226+
// Merge core env vars with additional env vars from base config
227+
return {
228+
...coreEnvVars,
229+
...additionalEnvVars, // Includes ANTHROPIC_MAX_TOKENS, etc.
230+
};
209231
}
210232

211233
/**

src/cliproxy/types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ export interface BinaryManagerConfig {
4646
maxRetries: number;
4747
/** Enable verbose logging */
4848
verbose: boolean;
49-
/** Force specific version (skip auto-upgrade to latest) */
50-
forceVersion?: boolean;
5149
}
5250

5351
/**
@@ -113,8 +111,9 @@ export interface DownloadResult {
113111
* - codex: OpenAI Codex via OAuth
114112
* - agy: Antigravity via OAuth (short name for easy usage)
115113
* - qwen: Qwen Code via OAuth (qwen3-coder)
114+
* - iflow: iFlow via OAuth
116115
*/
117-
export type CLIProxyProvider = 'gemini' | 'codex' | 'agy' | 'qwen';
116+
export type CLIProxyProvider = 'gemini' | 'codex' | 'agy' | 'qwen' | 'iflow';
118117

119118
/**
120119
* CLIProxy config.yaml structure (minimal)

0 commit comments

Comments
 (0)