From d079be151ed512ab323c6e5f72fb81af7f709010 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 3 Jun 2026 16:54:23 +0000 Subject: [PATCH] fix: restore config options fallback in discoverCursorModelsViaAcp 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. --- .../src/provider/Layers/CursorProvider.ts | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/apps/server/src/provider/Layers/CursorProvider.ts b/apps/server/src/provider/Layers/CursorProvider.ts index 551825df3e..9ae06bddd1 100644 --- a/apps/server/src/provider/Layers/CursorProvider.ts +++ b/apps/server/src/provider/Layers/CursorProvider.ts @@ -154,6 +154,12 @@ function normalizeCursorReasoningValue(value: string | null | undefined): string } } +function findCursorModelConfigOption( + configOptions: ReadonlyArray, +): EffectAcpSchema.SessionConfigOption | undefined { + return configOptions.find((option) => option.category === "model"); +} + function getCursorConfigOptionCategory(option: EffectAcpSchema.SessionConfigOption): string { return option.category?.trim().toLowerCase() ?? ""; } @@ -411,6 +417,35 @@ export function mergeCursorDiscoveredModelCapabilities( return mergedModels; } +export function buildCursorDiscoveredModelsFromConfigOptions( + configOptions: ReadonlyArray | null | undefined, +): ReadonlyArray { + if (!configOptions || configOptions.length === 0) { + return []; + } + + const modelOption = findCursorModelConfigOption(configOptions); + const modelChoices = flattenSessionConfigSelectOptions(modelOption); + if (!modelOption || modelChoices.length === 0) { + return []; + } + + const currentModelValue = + modelOption.type === "select" ? modelOption.currentValue?.trim() || undefined : undefined; + const currentModelCapabilities = buildCursorCapabilitiesFromConfigOptions(configOptions); + + return buildCursorDiscoveredModels( + modelChoices.map((modelChoice) => ({ + slug: modelChoice.value.trim(), + name: modelChoice.name.trim(), + capabilities: + currentModelValue === modelChoice.value.trim() + ? currentModelCapabilities + : EMPTY_CAPABILITIES, + })), + ); +} + function buildCursorDiscoveredModelsFromAvailableModelsResponse( response: typeof CursorListAvailableModelsResponse.Type, ): ReadonlyArray { @@ -602,7 +637,21 @@ const discoverCursorModelsViaListAvailableModels = ( export const discoverCursorModelsViaAcp = ( cursorSettings: CursorSettings, environment: NodeJS.ProcessEnv = process.env, -) => discoverCursorModelsViaListAvailableModels(cursorSettings, environment); +) => + discoverCursorModelsViaListAvailableModels(cursorSettings, environment).pipe( + Effect.catchCause(() => + withCursorAcpProbeRuntime( + cursorSettings, + (acp) => + Effect.map(acp.start(), (started) => + buildCursorDiscoveredModelsFromConfigOptions( + started.sessionSetupResult.configOptions ?? [], + ), + ), + environment, + ), + ), + ); export const discoverCursorModelCapabilitiesViaAcp = ( cursorSettings: CursorSettings,