( modelInput: ModelName | ModelAlias, )
| 533 | * @param modelInput The model alias or name provided by the user. |
| 534 | */ |
| 535 | export function parseUserSpecifiedModel( |
| 536 | modelInput: ModelName | ModelAlias, |
| 537 | ): ModelName { |
| 538 | const modelInputTrimmed = modelInput.trim() |
| 539 | const normalizedModel = modelInputTrimmed.toLowerCase() |
| 540 | |
| 541 | const has1mTag = has1mContext(normalizedModel) |
| 542 | const modelString = has1mTag |
| 543 | ? normalizedModel.replace(/\[1m]$/i, '').trim() |
| 544 | : normalizedModel |
| 545 | |
| 546 | if (isModelAlias(modelString)) { |
| 547 | switch (modelString) { |
| 548 | case 'opusplan': |
| 549 | return getDefaultSonnetModel() + (has1mTag ? '[1m]' : '') // Sonnet is default, Opus in plan mode |
| 550 | case 'sonnet': |
| 551 | return getDefaultSonnetModel() + (has1mTag ? '[1m]' : '') |
| 552 | case 'haiku': |
| 553 | return getDefaultHaikuModel() + (has1mTag ? '[1m]' : '') |
| 554 | case 'opus': |
| 555 | return getDefaultOpusModel() + (has1mTag ? '[1m]' : '') |
| 556 | case 'best': |
| 557 | return getBestModel() |
| 558 | default: |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | // Opus 4/4.1 are no longer available on the first-party API (same as |
| 563 | // Claude.ai) — silently remap to the current Opus default. The 'opus' |
| 564 | // alias resolves to the current default Opus (4.7), so the only users |
| 565 | // on these explicit strings pinned them in settings/env/--model/SDK |
| 566 | // before 4.5 launched. 3P providers may not yet have 4.6/4.7 capacity, |
| 567 | // so pass through unchanged. |
| 568 | if ( |
| 569 | getAPIProvider() === 'firstParty' && |
| 570 | isLegacyOpusFirstParty(modelString) && |
| 571 | isLegacyModelRemapEnabled() |
| 572 | ) { |
| 573 | return getDefaultOpusModel() + (has1mTag ? '[1m]' : '') |
| 574 | } |
| 575 | |
| 576 | if (process.env.USER_TYPE === 'ant') { |
| 577 | const has1mAntTag = has1mContext(normalizedModel) |
| 578 | const baseAntModel = normalizedModel.replace(/\[1m]$/i, '').trim() |
| 579 | |
| 580 | const antModel = resolveAntModel(baseAntModel) |
| 581 | if (antModel) { |
| 582 | const suffix = has1mAntTag ? '[1m]' : '' |
| 583 | return antModel.model + suffix |
| 584 | } |
| 585 | |
| 586 | // Fall through to the alias string if we cannot load the config. The API calls |
| 587 | // will fail with this string, but we should hear about it through feedback and |
| 588 | // can tell the user to restart/wait for flag cache refresh to get the latest values. |
| 589 | } |
| 590 | |
| 591 | // Preserve original case for custom model names (e.g., Azure Foundry deployment IDs) |
| 592 | // Only strip [1m] suffix if present, maintaining case of the base model |
no test coverage detected