fix(cliproxy): centralize gemini compatibility and fallback hints

This commit is contained in:
Tam Nhu Tran committed 2026-03-27 17:38:31 -04:00
1 parent 934e6ab52b
commit 2251312411
7 files changed
+63 -33

No files matched your search

+21 -7
View File
@@ -12,13 +12,7 @@ import {
normalizeModelIdForProvider,
} from './model-id-normalizer';
import { stripModelConfigurationSuffixes } from '../shared/extended-context-utils';
const GEMINI_MINOR_VERSION_COMPATIBILITY_IDS = Object.freeze({
'gemini-3-pro-preview': 'gemini-3.1-pro-preview',
'gemini-3.1-pro-preview': 'gemini-3-pro-preview',
'gemini-3-flash-preview': 'gemini-3.1-flash-preview',
'gemini-3.1-flash-preview': 'gemini-3-flash-preview',
});
import { GEMINI_MINOR_VERSION_COMPATIBILITY_IDS } from '../shared/gemini-minor-version-compatibility';
/**
* Thinking support configuration for a model.
@@ -391,6 +385,26 @@ export function getProviderCatalog(provider: CLIProxyProvider): ProviderCatalog
return MODEL_CATALOG[provider];
}
/**
* Suggest a supported replacement model from the provider catalog.
* Prefers the provider default unless it matches the excluded model or is itself broken.
*/
export function getSuggestedReplacementModel(
provider: CLIProxyProvider,
excludedModelId?: string
): string | undefined {
const catalog = MODEL_CATALOG[provider];
if (!catalog) return undefined;
const excludedId = excludedModelId ? findModel(provider, excludedModelId)?.id : undefined;
const defaultModel = findModel(provider, catalog.defaultModel);
if (defaultModel && !defaultModel.broken && defaultModel.id !== excludedId) {
return defaultModel.id;
}
return catalog.models.find((model) => !model.broken && model.id !== excludedId)?.id;
}
/**
* Find model entry by ID
* Note: Model IDs are normalized to lowercase for case-insensitive comparison