Restore the catchCause fallback that builds models from session/new config options when cursor/list_available_models fails or is unsupported. This re-adds buildCursorDiscoveredModelsFromConfigOptions and its findCursorModelConfigOption helper, which were removed in the prior commit.
Unified · Split
| @@ -154,6 +154,12 @@ function normalizeCursorReasoningValue(value: string | null | undefined): string · 153 unmodified lines | |||
| 154 | } | 154 | } |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | function findCursorModelConfigOption( | ||
| 158 | configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption>, | ||
| 159 | ): EffectAcpSchema.SessionConfigOption | undefined { | ||
| 160 | return configOptions.find((option) => option.category === "model"); | ||
| 161 | } | ||
| 162 | |||
| 157 | function getCursorConfigOptionCategory(option: EffectAcpSchema.SessionConfigOption): string { | 163 | function getCursorConfigOptionCategory(option: EffectAcpSchema.SessionConfigOption): string { |
| 158 | return option.category?.trim().toLowerCase() ?? ""; | 164 | return option.category?.trim().toLowerCase() ?? ""; |
| 159 | } | 165 | } |
| @@ -411,6 +417,35 @@ export function mergeCursorDiscoveredModelCapabilities( · 251 unmodified lines | |||
| 411 | return mergedModels; | 417 | return mergedModels; |
| 412 | } | 418 | } |
| 413 | 419 | ||
| 420 | export function buildCursorDiscoveredModelsFromConfigOptions( | ||
| 421 | configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption> | null | undefined, | ||
| 422 | ): ReadonlyArray<ServerProviderModel> { | ||
| 423 | if (!configOptions || configOptions.length === 0) { | ||
| 424 | return []; | ||
| 425 | } | ||
| 426 | |||
| 427 | const modelOption = findCursorModelConfigOption(configOptions); | ||
| 428 | const modelChoices = flattenSessionConfigSelectOptions(modelOption); | ||
| 429 | if (!modelOption || modelChoices.length === 0) { | ||
| 430 | return []; | ||
| 431 | } | ||
| 432 | |||
| 433 | const currentModelValue = | ||
| 434 | modelOption.type === "select" ? modelOption.currentValue?.trim() || undefined : undefined; | ||
| 435 | const currentModelCapabilities = buildCursorCapabilitiesFromConfigOptions(configOptions); | ||
| 436 | |||
| 437 | return buildCursorDiscoveredModels( | ||
| 438 | modelChoices.map((modelChoice) => ({ | ||
| 439 | slug: modelChoice.value.trim(), | ||
| 440 | name: modelChoice.name.trim(), | ||
| 441 | capabilities: | ||
| 442 | currentModelValue === modelChoice.value.trim() | ||
| 443 | ? currentModelCapabilities | ||
| 444 | : EMPTY_CAPABILITIES, | ||
| 445 | })), | ||
| 446 | ); | ||
| 447 | } | ||
| 448 | |||
| 414 | function buildCursorDiscoveredModelsFromAvailableModelsResponse( | 449 | function buildCursorDiscoveredModelsFromAvailableModelsResponse( |
| 415 | response: typeof CursorListAvailableModelsResponse.Type, | 450 | response: typeof CursorListAvailableModelsResponse.Type, |
| 416 | ): ReadonlyArray<ServerProviderModel> { | 451 | ): ReadonlyArray<ServerProviderModel> { |
| @@ -602,7 +637,21 @@ const discoverCursorModelsViaListAvailableModels = ( · 185 unmodified lines | |||
| 602 | export const discoverCursorModelsViaAcp = ( | 637 | export const discoverCursorModelsViaAcp = ( |
| 603 | cursorSettings: CursorSettings, | 638 | cursorSettings: CursorSettings, |
| 604 | environment: NodeJS.ProcessEnv = process.env, | 639 | environment: NodeJS.ProcessEnv = process.env, |
| 605 | ) => discoverCursorModelsViaListAvailableModels(cursorSettings, environment); | 640 | ) => |
| 641 | discoverCursorModelsViaListAvailableModels(cursorSettings, environment).pipe( | ||
| 642 | Effect.catchCause(() => | ||
| 643 | withCursorAcpProbeRuntime( | ||
| 644 | cursorSettings, | ||
| 645 | (acp) => | ||
| 646 | Effect.map(acp.start(), (started) => | ||
| 647 | buildCursorDiscoveredModelsFromConfigOptions( | ||
| 648 | started.sessionSetupResult.configOptions ?? [], | ||
| 649 | ), | ||
| 650 | ), | ||
| 651 | environment, | ||
| 652 | ), | ||
| 653 | ), | ||
| 654 | ); | ||
| 606 | 655 | ||
| 607 | export const discoverCursorModelCapabilitiesViaAcp = ( | 656 | export const discoverCursorModelCapabilitiesViaAcp = ( |
| 608 | cursorSettings: CursorSettings, | 657 | cursorSettings: CursorSettings, |