source dump of claude code
at main 101 lines 2.5 kB view raw
1/** 2 * Model deprecation utilities 3 * 4 * Contains information about deprecated models and their retirement dates. 5 */ 6 7import { type APIProvider, getAPIProvider } from './providers.js' 8 9type DeprecatedModelInfo = { 10 isDeprecated: true 11 modelName: string 12 retirementDate: string 13} 14 15type NotDeprecatedInfo = { 16 isDeprecated: false 17} 18 19type DeprecationInfo = DeprecatedModelInfo | NotDeprecatedInfo 20 21type DeprecationEntry = { 22 /** Human-readable model name */ 23 modelName: string 24 /** Retirement dates by provider (null = not deprecated for that provider) */ 25 retirementDates: Record<APIProvider, string | null> 26} 27 28/** 29 * Deprecated models and their retirement dates by provider. 30 * Keys are substrings to match in model IDs (case-insensitive). 31 * To add a new deprecated model, add an entry to this object. 32 */ 33const DEPRECATED_MODELS: Record<string, DeprecationEntry> = { 34 'claude-3-opus': { 35 modelName: 'Claude 3 Opus', 36 retirementDates: { 37 firstParty: 'January 5, 2026', 38 bedrock: 'January 15, 2026', 39 vertex: 'January 5, 2026', 40 foundry: 'January 5, 2026', 41 }, 42 }, 43 'claude-3-7-sonnet': { 44 modelName: 'Claude 3.7 Sonnet', 45 retirementDates: { 46 firstParty: 'February 19, 2026', 47 bedrock: 'April 28, 2026', 48 vertex: 'May 11, 2026', 49 foundry: 'February 19, 2026', 50 }, 51 }, 52 'claude-3-5-haiku': { 53 modelName: 'Claude 3.5 Haiku', 54 retirementDates: { 55 firstParty: 'February 19, 2026', 56 bedrock: null, 57 vertex: null, 58 foundry: null, 59 }, 60 }, 61} 62 63/** 64 * Check if a model is deprecated and get its deprecation info 65 */ 66function getDeprecatedModelInfo(modelId: string): DeprecationInfo { 67 const lowercaseModelId = modelId.toLowerCase() 68 const provider = getAPIProvider() 69 70 for (const [key, value] of Object.entries(DEPRECATED_MODELS)) { 71 const retirementDate = value.retirementDates[provider] 72 if (!lowercaseModelId.includes(key) || !retirementDate) { 73 continue 74 } 75 return { 76 isDeprecated: true, 77 modelName: value.modelName, 78 retirementDate, 79 } 80 } 81 82 return { isDeprecated: false } 83} 84 85/** 86 * Get a deprecation warning message for a model, or null if not deprecated 87 */ 88export function getModelDeprecationWarning( 89 modelId: string | null, 90): string | null { 91 if (!modelId) { 92 return null 93 } 94 95 const info = getDeprecatedModelInfo(modelId) 96 if (!info.isDeprecated) { 97 return null 98 } 99 100 return `${info.modelName} will be retired on ${info.retirementDate}. Consider switching to a newer model.` 101}