feat(config): support legacy profile target overrides

- add profile_targets map to legacy config typing

- load target defaults for settings/default profiles from config.json

- expose target metadata for legacy cliproxy variants in profile detection
This commit is contained in:
Tam Nhu Tran
2026-02-25 15:52:50 +07:00
parent 8a2a7c3eb0
commit 9a63f9bd36
2 changed files with 12 additions and 0 deletions
+7
View File
@@ -309,12 +309,15 @@ class ProfileDetector {
// Priority 2: Check user-defined CLIProxy variants (config.cliproxy section)
const config = this.readConfig();
const legacyTargetMap = (config as { profile_targets?: Record<string, TargetType> })
.profile_targets;
if (config.cliproxy && config.cliproxy[profileName]) {
const variant = config.cliproxy[profileName];
return {
type: 'cliproxy',
name: profileName,
target: variant.target,
provider: variant.provider as CLIProxyProfileName,
settingsPath: variant.settings,
port: variant.port,
@@ -333,6 +336,7 @@ class ProfileDetector {
type: 'settings',
name: profileName,
settingsPath: config.profiles[candidate],
target: legacyTargetMap?.[candidate],
message: viaLegacyAlias
? `Using legacy API profile "${candidate}" for "${profileName}".`
: undefined,
@@ -392,6 +396,8 @@ class ProfileDetector {
// Check if settings-based default exists
const config = this.readConfig();
const legacyTargetMap = (config as { profile_targets?: Record<string, TargetType> })
.profile_targets;
if (config.profiles && config.profiles['default']) {
const settingsPath = config.profiles['default'];
@@ -409,6 +415,7 @@ class ProfileDetector {
type: 'settings',
name: 'default',
settingsPath,
target: legacyTargetMap?.['default'],
};
}
+5
View File
@@ -4,6 +4,7 @@
*/
import type { CLIProxyProvider } from '../cliproxy/types';
import type { TargetType } from '../targets/target-adapter';
/**
* Profile configuration mapping
@@ -27,6 +28,8 @@ export interface CLIProxyVariantConfig {
account?: string;
/** Unique port for variant isolation (8318-8417) */
port?: number;
/** Target CLI to use for this variant (default: claude) */
target?: TargetType;
}
/**
@@ -44,6 +47,8 @@ export interface CLIProxyVariantsConfig {
export interface Config {
/** Settings-based profiles (GLM, Kimi, etc.) */
profiles: ProfilesConfig;
/** Per-profile CLI target overrides (legacy mode) */
profile_targets?: Record<string, TargetType>;
/** User-defined CLIProxy profile variants (optional) */
cliproxy?: CLIProxyVariantsConfig;
}