feat: deprecate GLMT user-facing surfaces

This commit is contained in:
Tam Nhu Tran committed 2026-03-17 15:49:29 -04:00
1 parent 33efaa77b9
commit 5525098400
33 files changed
+404 -752

No files matched your search

+1 -1
View File
@@ -337,7 +337,7 @@ export function getSettingsPath(profile: string): string {
/**
* Get display name for a profile by reading ANTHROPIC_MODEL from settings
* @param profile - Profile name (glm, glmt, kimi, custom, etc.)
* @param profile - Profile name (glm, km, glmt compatibility, custom, etc.)
* @returns Formatted display name (e.g., 'GLM-4.7', 'Kimi', 'Custom-Model')
*/
export function getModelDisplayName(profile: string): string {
+81
View File
@@ -0,0 +1,81 @@
const LEGACY_GLMT_PROFILE = 'glmt';
const LEGACY_GLMT_BASE_URL = 'https://api.z.ai/api/coding/paas/v4/chat/completions';
const DIRECT_GLM_BASE_URL = 'https://api.z.ai/api/anthropic';
const GLMT_PROXY_ONLY_ENV_KEYS = [
'API_TIMEOUT_MS',
'ANTHROPIC_SAFE_MODE',
'ENABLE_STREAMING',
'MAX_THINKING_TOKENS',
] as const;
export interface GlmtNormalizationResult {
env: Record<string, string>;
warnings: string[];
migrated: boolean;
}
export function isDeprecatedGlmtProfileName(profileName: string | null | undefined): boolean {
return (profileName || '').trim().toLowerCase() === LEGACY_GLMT_PROFILE;
}
export function isLegacyGlmtBaseUrl(baseUrl: string | null | undefined): boolean {
const normalized = (baseUrl || '').trim().toLowerCase().replace(/\/+$/, '');
if (!normalized) {
return false;
}
return (
normalized === LEGACY_GLMT_BASE_URL ||
normalized.includes('/api/coding/paas/v4') ||
normalized.endsWith('/chat/completions')
);
}
export function normalizeDeprecatedGlmtEnv(env: Record<string, string>): GlmtNormalizationResult {
const normalizedEnv = { ...env };
let migrated = false;
if (
!normalizedEnv['ANTHROPIC_BASE_URL'] ||
isLegacyGlmtBaseUrl(normalizedEnv['ANTHROPIC_BASE_URL'])
) {
normalizedEnv['ANTHROPIC_BASE_URL'] = DIRECT_GLM_BASE_URL;
migrated = true;
}
for (const key of GLMT_PROXY_ONLY_ENV_KEYS) {
if (key in normalizedEnv) {
delete normalizedEnv[key];
migrated = true;
}
}
return {
env: normalizedEnv,
warnings: buildGlmtCompatibilityWarnings(migrated),
migrated,
};
}
export function buildGlmtCompatibilityWarnings(migrated: boolean): string[] {
const warnings = [
'GLMT is deprecated and kept only as a compatibility path.',
'Use ccs glm for Z.AI API profiles.',
'Use ccs km for reasoning-first Kimi API profiles.',
];
if (migrated) {
warnings.splice(
1,
0,
'CCS normalized legacy GLMT proxy settings to the direct GLM endpoint for this run.'
);
}
return warnings;
}
export function getDirectGlmBaseUrl(): string {
return DIRECT_GLM_BASE_URL;
}