(fastMode = false)
| 461 | } |
| 462 | |
| 463 | export function getModelOptions(fastMode = false): ModelOption[] { |
| 464 | const options = getModelOptionsBase(fastMode) |
| 465 | |
| 466 | // Add the custom model from the ANTHROPIC_CUSTOM_MODEL_OPTION env var |
| 467 | const envCustomModel = process.env.ANTHROPIC_CUSTOM_MODEL_OPTION |
| 468 | if ( |
| 469 | envCustomModel && |
| 470 | !options.some(existing => existing.value === envCustomModel) |
| 471 | ) { |
| 472 | options.push({ |
| 473 | value: envCustomModel, |
| 474 | label: process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME ?? envCustomModel, |
| 475 | description: |
| 476 | process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION ?? |
| 477 | `Custom model (${envCustomModel})`, |
| 478 | }) |
| 479 | } |
| 480 | |
| 481 | // Append additional model options fetched during bootstrap |
| 482 | for (const opt of getGlobalConfig().additionalModelOptionsCache ?? []) { |
| 483 | if (!options.some(existing => existing.value === opt.value)) { |
| 484 | options.push(opt) |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | // Add custom model from either the current model value or the initial one |
| 489 | // if it is not already in the options. |
| 490 | let customModel: ModelSetting = null |
| 491 | const currentMainLoopModel = getUserSpecifiedModelSetting() |
| 492 | const initialMainLoopModel = getInitialMainLoopModel() |
| 493 | if (currentMainLoopModel !== undefined && currentMainLoopModel !== null) { |
| 494 | customModel = currentMainLoopModel |
| 495 | } else if (initialMainLoopModel !== null) { |
| 496 | customModel = initialMainLoopModel |
| 497 | } |
| 498 | if (customModel === null || options.some(opt => opt.value === customModel)) { |
| 499 | return filterModelOptionsByAllowlist(options) |
| 500 | } else if (customModel === 'opusplan') { |
| 501 | return filterModelOptionsByAllowlist([...options, getOpusPlanOption()]) |
| 502 | } else if (customModel === 'opus' && getAPIProvider() === 'firstParty') { |
| 503 | return filterModelOptionsByAllowlist([ |
| 504 | ...options, |
| 505 | getMaxOpusOption(fastMode), |
| 506 | ]) |
| 507 | } else if (customModel === 'opus[1m]' && getAPIProvider() === 'firstParty') { |
| 508 | return filterModelOptionsByAllowlist([ |
| 509 | ...options, |
| 510 | getMergedOpus1MOption(fastMode), |
| 511 | ]) |
| 512 | } else { |
| 513 | // Try to show a human-readable label for known Anthropic models, with an |
| 514 | // upgrade hint if the alias now resolves to a newer version. |
| 515 | const knownOption = getKnownModelOption(customModel) |
| 516 | if (knownOption) { |
| 517 | options.push(knownOption) |
| 518 | } else { |
| 519 | options.push({ |
| 520 | value: customModel, |
no test coverage detected