mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-05 18:16:28 +00:00
fix(cliproxy): add kiro/ghcp provider mappings to discoverExistingAccounts
- Replace hardcoded typeToProvider with dynamic lookup from PROVIDER_TYPE_VALUES - Add email extraction from filename as fallback for empty data.email - Fixes issue where Kiro/GHCP accounts were skipped during discovery Closes #242
This commit is contained in:
@@ -12,6 +12,7 @@ import * as fs from 'fs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { CLIProxyProvider } from './types';
|
import { CLIProxyProvider } from './types';
|
||||||
import { getCliproxyDir, getAuthDir } from './config-generator';
|
import { getCliproxyDir, getAuthDir } from './config-generator';
|
||||||
|
import { PROVIDER_TYPE_VALUES } from './auth/auth-types';
|
||||||
|
|
||||||
/** Account information */
|
/** Account information */
|
||||||
export interface AccountInfo {
|
export interface AccountInfo {
|
||||||
@@ -431,26 +432,33 @@ export function discoverExistingAccounts(): void {
|
|||||||
// Skip if no type field
|
// Skip if no type field
|
||||||
if (!data.type) continue;
|
if (!data.type) continue;
|
||||||
|
|
||||||
// Map token type values to internal provider names
|
// Build reverse mapping from PROVIDER_TYPE_VALUES (type value -> provider)
|
||||||
// CLIProxyAPI uses different type values in tokens (e.g., "antigravity" vs "agy")
|
// e.g., "antigravity" -> "agy", "kiro" -> "kiro", "codewhisperer" -> "kiro"
|
||||||
const typeToProvider: Record<string, CLIProxyProvider> = {
|
|
||||||
gemini: 'gemini',
|
|
||||||
antigravity: 'agy',
|
|
||||||
codex: 'codex',
|
|
||||||
qwen: 'qwen',
|
|
||||||
iflow: 'iflow',
|
|
||||||
};
|
|
||||||
|
|
||||||
const typeValue = data.type.toLowerCase();
|
const typeValue = data.type.toLowerCase();
|
||||||
const provider = typeToProvider[typeValue];
|
let provider: CLIProxyProvider | undefined;
|
||||||
|
for (const [prov, typeValues] of Object.entries(PROVIDER_TYPE_VALUES)) {
|
||||||
|
if (typeValues.includes(typeValue)) {
|
||||||
|
provider = prov as CLIProxyProvider;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Skip if unknown provider type
|
// Skip if unknown provider type
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract email if available
|
// Extract email if available, fallback to filename
|
||||||
const email = data.email || undefined;
|
let email = data.email || undefined;
|
||||||
|
|
||||||
|
// Fallback: extract email from filename (e.g., "kiro-google-user@example.com.json")
|
||||||
|
if (!email && file.includes('@')) {
|
||||||
|
const match = file.match(/([^-]+@[^.]+\.[^.]+)(?=\.json$)/);
|
||||||
|
if (match) {
|
||||||
|
email = match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const accountId = email || 'default';
|
const accountId = email || 'default';
|
||||||
|
|
||||||
// Initialize provider section if needed
|
// Initialize provider section if needed
|
||||||
|
|||||||
Reference in New Issue
Block a user