MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / parseUserSpecifiedModel

Function parseUserSpecifiedModel

source code/utils/model/model.ts:447–508  ·  view source on GitHub ↗
(
  modelInput: ModelName | ModelAlias,
)

Source from the content-addressed store, hash-verified

445 * @param modelInput The model alias or name provided by the user.
446 */
447export function parseUserSpecifiedModel(
448 modelInput: ModelName | ModelAlias,
449): ModelName {
450 const modelInputTrimmed = modelInput.trim()
451 const normalizedModel = modelInputTrimmed.toLowerCase()
452
453 const has1mTag = has1mContext(normalizedModel)
454 const modelString = has1mTag
455 ? normalizedModel.replace(/\[1m]$/i, '').trim()
456 : normalizedModel
457
458 if (isModelAlias(modelString)) {
459 switch (modelString) {
460 case 'opusplan':
461 return getDefaultSonnetModel() + (has1mTag ? '[1m]' : '') // Sonnet is default, Opus in plan mode
462 case 'sonnet':
463 return getDefaultSonnetModel() + (has1mTag ? '[1m]' : '')
464 case 'haiku':
465 return getDefaultHaikuModel() + (has1mTag ? '[1m]' : '')
466 case 'opus':
467 return getDefaultOpusModel() + (has1mTag ? '[1m]' : '')
468 case 'best':
469 return getBestModel()
470 default:
471 }
472 }
473
474 // Opus 4/4.1 are no longer available on the first-party API (same as
475 // Claude.ai) — silently remap to the current Opus default. The 'opus'
476 // alias already resolves to 4.6, so the only users on these explicit
477 // strings pinned them in settings/env/--model/SDK before 4.5 launched.
478 // 3P providers may not yet have 4.6 capacity, so pass through unchanged.
479 if (
480 getAPIProvider() === 'firstParty' &&
481 isLegacyOpusFirstParty(modelString) &&
482 isLegacyModelRemapEnabled()
483 ) {
484 return getDefaultOpusModel() + (has1mTag ? '[1m]' : '')
485 }
486
487 if (process.env.USER_TYPE === 'ant') {
488 const has1mAntTag = has1mContext(normalizedModel)
489 const baseAntModel = normalizedModel.replace(/\[1m]$/i, '').trim()
490
491 const antModel = resolveAntModel(baseAntModel)
492 if (antModel) {
493 const suffix = has1mAntTag ? '[1m]' : ''
494 return antModel.model + suffix
495 }
496
497 // Fall through to the alias string if we cannot load the config. The API calls
498 // will fail with this string, but we should hear about it through feedback and
499 // can tell the user to restart/wait for flag cache refresh to get the latest values.
500 }
501
502 // Preserve original case for custom model names (e.g., Azure Foundry deployment IDs)
503 // Only strip [1m] suffix if present, maintaining case of the base model
504 if (has1mTag) {

Callers 15

submitMessageMethod · 0.85
logSessionTelemetryFunction · 0.85
runFunction · 0.85
getDefaultTeammateModelFunction · 0.85
renderToolUseTagFunction · 0.85
callFunction · 0.85
shouldShowEffortCalloutFunction · 0.85
resolveOptionModelFunction · 0.85
restoreAgentFromSessionFunction · 0.85
modelBelongsToFamilyFunction · 0.85

Calls 10

has1mContextFunction · 0.85
isModelAliasFunction · 0.85
getDefaultSonnetModelFunction · 0.85
getDefaultHaikuModelFunction · 0.85
getDefaultOpusModelFunction · 0.85
getBestModelFunction · 0.85
getAPIProviderFunction · 0.85
isLegacyOpusFirstPartyFunction · 0.85
resolveAntModelFunction · 0.85

Tested by

no test coverage detected