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