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