mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-12 22:14:22 +00:00
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:
1 parent
8a2a7c3eb0
commit
9a63f9bd36
2 files changed
+12
No files matched your search
@@ -309,12 +309,15 @@ class ProfileDetector {
|
|||||||
|
|
||||||
// Priority 2: Check user-defined CLIProxy variants (config.cliproxy section)
|
// Priority 2: Check user-defined CLIProxy variants (config.cliproxy section)
|
||||||
const config = this.readConfig();
|
const config = this.readConfig();
|
||||||
|
const legacyTargetMap = (config as { profile_targets?: Record<string, TargetType> })
|
||||||
|
.profile_targets;
|
||||||
|
|
||||||
if (config.cliproxy && config.cliproxy[profileName]) {
|
if (config.cliproxy && config.cliproxy[profileName]) {
|
||||||
const variant = config.cliproxy[profileName];
|
const variant = config.cliproxy[profileName];
|
||||||
return {
|
return {
|
||||||
type: 'cliproxy',
|
type: 'cliproxy',
|
||||||
name: profileName,
|
name: profileName,
|
||||||
|
target: variant.target,
|
||||||
provider: variant.provider as CLIProxyProfileName,
|
provider: variant.provider as CLIProxyProfileName,
|
||||||
settingsPath: variant.settings,
|
settingsPath: variant.settings,
|
||||||
port: variant.port,
|
port: variant.port,
|
||||||
@@ -333,6 +336,7 @@ class ProfileDetector {
|
|||||||
type: 'settings',
|
type: 'settings',
|
||||||
name: profileName,
|
name: profileName,
|
||||||
settingsPath: config.profiles[candidate],
|
settingsPath: config.profiles[candidate],
|
||||||
|
target: legacyTargetMap?.[candidate],
|
||||||
message: viaLegacyAlias
|
message: viaLegacyAlias
|
||||||
? `Using legacy API profile "${candidate}" for "${profileName}".`
|
? `Using legacy API profile "${candidate}" for "${profileName}".`
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -392,6 +396,8 @@ class ProfileDetector {
|
|||||||
|
|
||||||
// Check if settings-based default exists
|
// Check if settings-based default exists
|
||||||
const config = this.readConfig();
|
const config = this.readConfig();
|
||||||
|
const legacyTargetMap = (config as { profile_targets?: Record<string, TargetType> })
|
||||||
|
.profile_targets;
|
||||||
|
|
||||||
if (config.profiles && config.profiles['default']) {
|
if (config.profiles && config.profiles['default']) {
|
||||||
const settingsPath = config.profiles['default'];
|
const settingsPath = config.profiles['default'];
|
||||||
@@ -409,6 +415,7 @@ class ProfileDetector {
|
|||||||
type: 'settings',
|
type: 'settings',
|
||||||
name: 'default',
|
name: 'default',
|
||||||
settingsPath,
|
settingsPath,
|
||||||
|
target: legacyTargetMap?.['default'],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { CLIProxyProvider } from '../cliproxy/types';
|
import type { CLIProxyProvider } from '../cliproxy/types';
|
||||||
|
import type { TargetType } from '../targets/target-adapter';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Profile configuration mapping
|
* Profile configuration mapping
|
||||||
@@ -27,6 +28,8 @@ export interface CLIProxyVariantConfig {
|
|||||||
account?: string;
|
account?: string;
|
||||||
/** Unique port for variant isolation (8318-8417) */
|
/** Unique port for variant isolation (8318-8417) */
|
||||||
port?: number;
|
port?: number;
|
||||||
|
/** Target CLI to use for this variant (default: claude) */
|
||||||
|
target?: TargetType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,6 +47,8 @@ export interface CLIProxyVariantsConfig {
|
|||||||
export interface Config {
|
export interface Config {
|
||||||
/** Settings-based profiles (GLM, Kimi, etc.) */
|
/** Settings-based profiles (GLM, Kimi, etc.) */
|
||||||
profiles: ProfilesConfig;
|
profiles: ProfilesConfig;
|
||||||
|
/** Per-profile CLI target overrides (legacy mode) */
|
||||||
|
profile_targets?: Record<string, TargetType>;
|
||||||
/** User-defined CLIProxy profile variants (optional) */
|
/** User-defined CLIProxy profile variants (optional) */
|
||||||
cliproxy?: CLIProxyVariantsConfig;
|
cliproxy?: CLIProxyVariantsConfig;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user