From 3e6dd2f32b6260f648af0976c2056d37d88f8035 Mon Sep 17 00:00:00 2001 From: Gabriel Rodrigues Date: Fri, 30 Oct 2026 21:31:12 -0300 Subject: [PATCH 1/5] feat(cursor): map optional Max Mode from the SDK catalog Cache catalog models from the timed status probe, expose a Max Mode composer boolean when matching variants allow it, and set send maxMode only when forced or admitted by the selected params. Co-authored-by: Cursor --- .../provider-cursor/src/server/adapter.ts | 11 +- packages/provider-cursor/src/server/driver.ts | 53 +++-- .../src/server/sdkModel.test.ts | 182 ++++++++++++++++++ .../provider-cursor/src/server/sdkModel.ts | 103 ++++++++-- .../provider-cursor/src/server/status.test.ts | 47 ++++- packages/provider-cursor/src/server/status.ts | 169 +++++++++------- 6 files changed, 463 insertions(+), 102 deletions(-) create mode 100644 packages/provider-cursor/src/server/sdkModel.test.ts diff --git a/packages/provider-cursor/src/server/adapter.ts b/packages/provider-cursor/src/server/adapter.ts index 73f7ac9d9767d..9534396910aec 100644 --- a/packages/provider-cursor/src/server/adapter.ts +++ b/packages/provider-cursor/src/server/adapter.ts @@ -4,6 +4,7 @@ import type { InteractionUpdate, McpServerConfig, RunResult, + SDKModel, SDKUserMessage, SettingSource, ToolCall, @@ -300,11 +301,12 @@ export function makeCursorAgentOptions(input: { readonly threadId: ThreadId; readonly mcpSession: McpProviderSession.McpProviderSessionConfig | undefined; readonly platform: NodeJS.Platform; + readonly sdkModels?: ReadonlyArray>; }): AgentOptions { const policy = cursorRuntimeAgentPolicy(input.runtimePolicy, input.platform); const mcpServers = cursorMcpServers(input.mcpSession); return { - model: cursorSdkModelSelection(input.modelSelection), + model: cursorSdkModelSelection(input.modelSelection, input.sdkModels), name: `T3 Code ${input.threadId}`, mode: input.runtimePolicy.interactionMode === "plan" ? "plan" : "agent", ...(input.apiKey === undefined ? {} : { apiKey: input.apiKey }), @@ -950,6 +952,7 @@ export interface CursorAdapterV2Options { readonly instanceId: ProviderInstanceId; readonly environment: NodeJS.ProcessEnv; readonly getModels?: () => ReadonlyArray; + readonly getSdkModels?: () => ReadonlyArray>; } export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( @@ -2238,6 +2241,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( platform, threadId: openInput.threadId, mcpSession: yield* mcpSessions.read(openInput.threadId), + sdkModels: adapterOptions.getSdkModels?.() ?? [], }); if ( platform === "win32" && @@ -2394,7 +2398,10 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( message, summarize: compacted, options: { - model: cursorSdkModelSelection(turnInput.modelSelection), + model: cursorSdkModelSelection( + turnInput.modelSelection, + adapterOptions.getSdkModels?.() ?? [], + ), mode: turnInput.runtimePolicy.interactionMode === "plan" ? "plan" : "agent", ...(mcpServers === undefined ? {} : { mcpServers }), }, diff --git a/packages/provider-cursor/src/server/driver.ts b/packages/provider-cursor/src/server/driver.ts index 088c97c685c58..d890325be1f1e 100644 --- a/packages/provider-cursor/src/server/driver.ts +++ b/packages/provider-cursor/src/server/driver.ts @@ -1,3 +1,4 @@ +import type { SDKModel } from "@cursor/sdk"; import { ProviderDriverKind, ProviderSetupError, @@ -166,10 +167,12 @@ export const CursorDriver: ProviderDriver< }); let catalogModels: ReadonlyArray = []; + let catalogSdkModels: ReadonlyArray = []; const orchestrationAdapter = yield* makeCursorAdapterV2({ instanceId, environment: processEnv, getModels: () => catalogModels, + getSdkModels: () => catalogSdkModels, }).pipe( Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, { ...sdkRunner, @@ -225,39 +228,53 @@ export const CursorDriver: ProviderDriver< }, auth.usesApiKey ? "api-key" : "browser", ).pipe( - Effect.filterOrElse( - (snapshot) => - !( - effectiveConfig.enabled && - snapshot.installed && - snapshot.auth.status === "authenticated" - ), - (snapshot) => - host.settings.get.pipe( - Effect.flatMap((settings) => - readCursorUsageLimits( - effectiveConfig, - { ...processEnv, CURSOR_API_KEY: apiKey }, - settings.cursorKeychainUsageEnabled, + Effect.flatMap(({ provider: statusProvider, sdkModels }) => + Effect.succeed(statusProvider).pipe( + Effect.filterOrElse( + (snapshot) => + !( + effectiveConfig.enabled && + snapshot.installed && + snapshot.auth.status === "authenticated" + ), + (snapshot) => + host.settings.get.pipe( + Effect.flatMap((settings) => + readCursorUsageLimits( + effectiveConfig, + { ...processEnv, CURSOR_API_KEY: apiKey }, + settings.cursorKeychainUsageEnabled, + ), + ), + Effect.map((usageLimits) => ({ ...snapshot, usageLimits })), ), - ), - Effect.map((usageLimits) => ({ ...snapshot, usageLimits })), ), + Effect.map((provider) => ({ provider, sdkModels })), + ), ), ), ), Effect.provideService(FileSystem.FileSystem, fileSystem), Effect.provideService(Path.Path, path), Effect.provideService(CursorKeychain.CursorKeychain, keychain), - Effect.map(stampSnapshot), - Effect.tap((provider) => + Effect.map(({ provider, sdkModels }) => ({ + provider: stampSnapshot(provider), + sdkModels, + })), + Effect.tap(({ provider, sdkModels }) => Effect.sync(() => { // A failed check lists only custom models, so keep the last loaded catalog. if (provider.models.some((model) => !model.isCustom)) { catalogModels = provider.models; } + // Reuse the timed status probe — a second unbounded catalog.read would + // defeat the probe timeout when the first request stalled. + if (sdkModels !== undefined) { + catalogSdkModels = sdkModels; + } }), ), + Effect.map(({ provider }) => provider), Effect.provide(CursorSdkCatalog.layer), Effect.provideService(HttpClient.HttpClient, httpClient), ); diff --git a/packages/provider-cursor/src/server/sdkModel.test.ts b/packages/provider-cursor/src/server/sdkModel.test.ts new file mode 100644 index 0000000000000..d90ea1ac77c6c --- /dev/null +++ b/packages/provider-cursor/src/server/sdkModel.test.ts @@ -0,0 +1,182 @@ +import { describe, expect, it } from "@effect/vitest"; +import { ProviderInstanceId } from "@t3tools/contracts"; +import { + CURSOR_SDK_MAX_MODE_OPTION_ID, + cursorSdkMaxModeForParams, + cursorSdkModelOffersOptionalMaxMode, + cursorSdkModelSelection, +} from "./sdkModel.ts"; + +describe("cursorSdkModelSelection", () => { + const instanceId = ProviderInstanceId.make("cursor"); + + it("sets maxMode when every matching catalog variant requires it", () => { + const selection = cursorSdkModelSelection( + { + instanceId, + model: "claude-opus-4-8", + options: [{ id: "contextWindow", value: "1m" }], + }, + [ + { + id: "claude-opus-4-8", + variants: [ + { + displayName: "1M", + isMaxMode: true, + params: [{ id: "context", value: "1m" }], + }, + ], + }, + ], + ); + expect(selection).toEqual({ + id: "claude-opus-4-8", + params: [{ id: "context", value: "1m" }], + maxMode: true, + }); + }); + + it("omits maxMode when a matching variant can run without it", () => { + expect( + cursorSdkMaxModeForParams( + { + variants: [ + { + displayName: "1M", + isMaxMode: true, + params: [{ id: "context", value: "1m" }], + }, + { + displayName: "1M standard", + params: [{ id: "context", value: "1m" }], + }, + ], + }, + [{ id: "context", value: "1m" }], + ), + ).toBe(false); + }); + + it("sets maxMode from the composer option without forwarding it as an SDK param", () => { + const catalog = [ + { + id: "composer-2", + variants: [ + { + displayName: "Composer", + isDefault: true, + params: [{ id: "fast", value: "false" }], + }, + { + displayName: "Composer Max", + isMaxMode: true, + params: [{ id: "fast", value: "false" }], + }, + { + displayName: "Composer Fast", + params: [{ id: "fast", value: "true" }], + }, + ], + }, + ]; + expect( + cursorSdkModelSelection( + { + instanceId, + model: "composer-2", + options: [ + { id: "fastMode", value: false }, + { id: CURSOR_SDK_MAX_MODE_OPTION_ID, value: true }, + ], + }, + catalog, + ), + ).toEqual({ + id: "composer-2", + params: [{ id: "fast", value: "false" }], + maxMode: true, + }); + expect( + cursorSdkModelSelection( + { + instanceId, + model: "composer-2", + options: [ + { id: "fastMode", value: false }, + { id: CURSOR_SDK_MAX_MODE_OPTION_ID, value: false }, + ], + }, + catalog, + ), + ).toEqual({ + id: "composer-2", + params: [{ id: "fast", value: "false" }], + }); + expect( + cursorSdkModelSelection( + { + instanceId, + model: "composer-2", + options: [ + { id: "fastMode", value: true }, + { id: CURSOR_SDK_MAX_MODE_OPTION_ID, value: true }, + ], + }, + catalog, + ), + ).toEqual({ + id: "composer-2", + params: [{ id: "fast", value: "true" }], + }); + }); +}); + +describe("cursorSdkModelOffersOptionalMaxMode", () => { + it("is true when the same params have both max and non-max variants", () => { + expect( + cursorSdkModelOffersOptionalMaxMode({ + variants: [ + { + displayName: "Standard", + isDefault: true, + params: [{ id: "fast", value: "false" }], + }, + { + displayName: "Max", + isMaxMode: true, + params: [{ id: "fast", value: "false" }], + }, + ], + }), + ).toBe(true); + }); + + it("is false when max mode is forced for every matching selection", () => { + expect( + cursorSdkModelOffersOptionalMaxMode({ + variants: [ + { + displayName: "1M", + isMaxMode: true, + params: [{ id: "context", value: "1m" }], + }, + ], + }), + ).toBe(false); + }); + + it("is false when no variants use max mode", () => { + expect( + cursorSdkModelOffersOptionalMaxMode({ + variants: [ + { + displayName: "Default", + isDefault: true, + params: [{ id: "fast", value: "false" }], + }, + ], + }), + ).toBe(false); + }); +}); diff --git a/packages/provider-cursor/src/server/sdkModel.ts b/packages/provider-cursor/src/server/sdkModel.ts index fec0bafc45eee..8ddcc52cd67b5 100644 --- a/packages/provider-cursor/src/server/sdkModel.ts +++ b/packages/provider-cursor/src/server/sdkModel.ts @@ -1,7 +1,15 @@ -import type { ModelSelection as CursorSdkModelSelection, ModelParameterValue } from "@cursor/sdk"; +import type { + ModelSelection as CursorSdkModelSelection, + ModelParameterValue, + ModelVariant, + SDKModel, +} from "@cursor/sdk"; import type { ModelSelection, ServerProviderModel } from "@t3tools/contracts"; import { getProviderOptionCurrentValue } from "@t3tools/shared/model"; +/** Composer option id for optional Cursor max mode; not an SDK model parameter. */ +export const CURSOR_SDK_MAX_MODE_OPTION_ID = "maxMode"; + const CURSOR_SDK_PARAMETER_TO_PROVIDER_OPTION: Readonly> = { context: "contextWindow", fast: "fastMode", @@ -55,16 +63,89 @@ export function cursorContextWindowTokens( return Number.isSafeInteger(tokens) && tokens > 0 ? tokens : undefined; } -export function cursorSdkModelSelection(modelSelection: ModelSelection): CursorSdkModelSelection { +function variantMatchesParams( + variant: ModelVariant, + params: ReadonlyArray | undefined, +): boolean { + if (params === undefined || params.length === 0) { + return variant.isDefault === true || variant.params.length === 0; + } + return params.every((param) => + variant.params.some((entry) => entry.id === param.id && entry.value === param.value), + ); +} + +export function cursorSdkMaxModeForParams( + model: Pick, + params: ReadonlyArray | undefined, +): boolean { + const variants = model.variants ?? []; + const matching = variants.filter((variant) => variantMatchesParams(variant, params)); + return matching.length > 0 && matching.every((variant) => variant.isMaxMode === true); +} + +function cursorSdkParamsAdmitMaxMode( + model: Pick, + params: ReadonlyArray | undefined, +): boolean { + return (model.variants ?? []).some( + (variant) => variantMatchesParams(variant, params) && variant.isMaxMode === true, + ); +} + +export function cursorSdkModelOffersOptionalMaxMode(model: Pick): boolean { + const variants = model.variants ?? []; + if ( + !variants.some((variant) => variant.isMaxMode === true) || + !variants.some((variant) => variant.isMaxMode !== true) + ) { + return false; + } + + const candidateParams: Array | undefined> = [undefined]; + for (const variant of variants) { + candidateParams.push(variant.params); + } + + for (const params of candidateParams) { + const matching = variants.filter((variant) => variantMatchesParams(variant, params)); + if ( + matching.some((variant) => variant.isMaxMode === true) && + matching.some((variant) => variant.isMaxMode !== true) + ) { + return true; + } + } + return false; +} + +export function cursorSdkModelSelection( + modelSelection: ModelSelection, + sdkModels?: ReadonlyArray>, +): CursorSdkModelSelection { + const id = modelSelection.model === "auto" ? "default" : modelSelection.model; + const options = modelSelection.options ?? []; + const userRequestedMaxMode = options.some( + (option) => option.id === CURSOR_SDK_MAX_MODE_OPTION_ID && option.value === true, + ); + const sdkOptions = options.filter((option) => option.id !== CURSOR_SDK_MAX_MODE_OPTION_ID); + const params = + sdkOptions.length === 0 + ? undefined + : sdkOptions.map((option): ModelParameterValue => ({ + id: cursorSdkParameterId(option.id), + value: String(option.value), + })); + const catalogModel = sdkModels?.find((model) => model.id === id); + const forcedMaxMode = + catalogModel !== undefined && cursorSdkMaxModeForParams(catalogModel, params); + const optionalMaxMode = + userRequestedMaxMode && + (catalogModel === undefined || cursorSdkParamsAdmitMaxMode(catalogModel, params)); + const maxMode = forcedMaxMode || optionalMaxMode; return { - id: modelSelection.model === "auto" ? "default" : modelSelection.model, - ...(modelSelection.options === undefined || modelSelection.options.length === 0 - ? {} - : { - params: modelSelection.options.map((option): ModelParameterValue => ({ - id: cursorSdkParameterId(option.id), - value: String(option.value), - })), - }), + id, + ...(params === undefined ? {} : { params }), + ...(maxMode ? { maxMode: true } : {}), }; } diff --git a/packages/provider-cursor/src/server/status.test.ts b/packages/provider-cursor/src/server/status.test.ts index c3dc7deb120ff..b077b930d1ce6 100644 --- a/packages/provider-cursor/src/server/status.test.ts +++ b/packages/provider-cursor/src/server/status.test.ts @@ -94,6 +94,30 @@ const sdkParameterizedModel = { ], } satisfies SDKModel; +const sdkOptionalMaxModeModel = { + id: "composer-2", + displayName: "Composer 2", + parameters: [ + { + id: "fast", + displayName: "Fast", + values: [{ value: "false" }, { value: "true", displayName: "Fast" }], + }, + ], + variants: [ + { + displayName: "Composer 2", + isDefault: true, + params: [{ id: "fast", value: "false" }], + }, + { + displayName: "Composer 2 Max", + isMaxMode: true, + params: [{ id: "fast", value: "false" }], + }, + ], +} satisfies SDKModel; + describe("buildCursorProviderSnapshot", () => { it("downgrades ready status to warning when SDK model discovery returns no models", () => { expect( @@ -136,6 +160,17 @@ describe("Cursor SDK model discovery", () => { ); }); + it("adds a Max Mode boolean when the catalog offers optional max mode", () => { + expect(buildCursorCapabilitiesFromSdkModel(sdkOptionalMaxModeModel)).toEqual( + createModelCapabilities({ + optionDescriptors: [ + booleanDescriptor("fastMode", "Fast", false), + booleanDescriptor("maxMode", "Max Mode", false), + ], + }), + ); + }); + it("filters invalid and duplicate SDK model entries", () => { expect( buildCursorDiscoveredModelsFromSdk([ @@ -157,7 +192,7 @@ describe("Cursor SDK model discovery", () => { describe("checkCursorProviderStatus", () => { it.effect("uses the SDK catalog when CURSOR_API_KEY is configured", () => Effect.gen(function* () { - const provider = yield* checkCursorProviderStatus( + const { provider, sdkModels } = yield* checkCursorProviderStatus( { ...baseCursorSettings, customModels: ["internal/cursor-model"], @@ -192,12 +227,13 @@ describe("checkCursorProviderStatus", () => { { slug: "internal/cursor-model", isCustom: true }, ], }); + expect(sdkModels).toEqual([sdkParameterizedModel]); }), ); it.effect("surfaces SDK authentication failures", () => Effect.gen(function* () { - const provider = yield* checkCursorProviderStatus(baseCursorSettings, { + const { provider, sdkModels } = yield* checkCursorProviderStatus(baseCursorSettings, { CURSOR_API_KEY: "invalid-test-key", }).pipe( Effect.provide( @@ -217,6 +253,7 @@ describe("checkCursorProviderStatus", () => { auth: { status: "unauthenticated" }, message: "Cursor SDK authentication failed. Check CURSOR_API_KEY.", }); + expect(sdkModels).toBeUndefined(); }), ); @@ -235,7 +272,7 @@ describe("checkCursorProviderStatus", () => { "explains a rejected plan for $authenticationType authentication", ({ authenticationType, message }) => Effect.gen(function* () { - const provider = yield* checkCursorProviderStatus( + const { provider, sdkModels } = yield* checkCursorProviderStatus( baseCursorSettings, { CURSOR_API_KEY: "free-plan-key" }, authenticationType, @@ -261,6 +298,7 @@ describe("checkCursorProviderStatus", () => { auth: { status: "unknown" }, message, }); + expect(sdkModels).toBeUndefined(); }), ); @@ -356,7 +394,7 @@ describe("checkCursorProviderStatus", () => { it.effect("requires a Cursor API key without probing any external Cursor binary", () => Effect.gen(function* () { - const provider = yield* checkCursorProviderStatus(baseCursorSettings).pipe( + const { provider, sdkModels } = yield* checkCursorProviderStatus(baseCursorSettings).pipe( Effect.provide( CursorSdkCatalog.layerTest(() => Effect.die("SDK catalog must not be used without CURSOR_API_KEY"), @@ -370,6 +408,7 @@ describe("checkCursorProviderStatus", () => { auth: { status: "unauthenticated" }, message: "Sign in with Cursor or add CURSOR_API_KEY in provider settings.", }); + expect(sdkModels).toBeUndefined(); }), ); }); diff --git a/packages/provider-cursor/src/server/status.ts b/packages/provider-cursor/src/server/status.ts index ffeca7a1da0b7..98a651e511174 100644 --- a/packages/provider-cursor/src/server/status.ts +++ b/packages/provider-cursor/src/server/status.ts @@ -13,7 +13,12 @@ import * as Effect from "effect/Effect"; import * as Option from "effect/Option"; import * as Result from "effect/Result"; -import { cursorSdkParameterPriority, cursorSdkProviderOptionId } from "./sdkModel.ts"; +import { + CURSOR_SDK_MAX_MODE_OPTION_ID, + cursorSdkModelOffersOptionalMaxMode, + cursorSdkParameterPriority, + cursorSdkProviderOptionId, +} from "./sdkModel.ts"; import { buildBooleanOptionDescriptor, buildSelectOptionDescriptor, @@ -34,6 +39,11 @@ const EMPTY_CAPABILITIES: ModelCapabilities = createModelCapabilities({ const CURSOR_SDK_CATALOG_TIMEOUT_MS = 15_000; +export interface CursorProviderStatusResult { + readonly provider: ServerProviderDraft; + readonly sdkModels: ReadonlyArray | undefined; +} + export const buildInitialCursorProviderSnapshot = Effect.fn( "CursorProviderStatus.buildInitialCursorProviderSnapshot", )(function* (cursorSettings: CursorSettings): Effect.fn.Return { @@ -157,6 +167,16 @@ export function buildCursorCapabilitiesFromSdkModel(model: SDKModel): ModelCapab ); } + if (cursorSdkModelOffersOptionalMaxMode(model)) { + optionDescriptors.push( + buildBooleanOptionDescriptor({ + id: CURSOR_SDK_MAX_MODE_OPTION_ID, + label: "Max Mode", + currentValue: false, + }), + ); + } + return createModelCapabilities({ optionDescriptors }); } @@ -248,41 +268,47 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")( cursorSettings: CursorSettings, environment?: NodeJS.ProcessEnv, authenticationType: "api-key" | "browser" = "api-key", -): Effect.fn.Return { +): Effect.fn.Return { const checkedAt = DateTime.formatIso(yield* DateTime.now); const fallbackModels = getCursorFallbackModels(cursorSettings); if (!cursorSettings.enabled) { - return buildServerProvider({ - presentation: CURSOR_PRESENTATION, - enabled: false, - checkedAt, - models: fallbackModels, - probe: { - installed: false, - version: null, - status: "warning", - auth: { status: "unknown" }, - message: "Cursor is disabled in T3 Code settings.", - }, - }); + return { + provider: buildServerProvider({ + presentation: CURSOR_PRESENTATION, + enabled: false, + checkedAt, + models: fallbackModels, + probe: { + installed: false, + version: null, + status: "warning", + auth: { status: "unknown" }, + message: "Cursor is disabled in T3 Code settings.", + }, + }), + sdkModels: undefined, + }; } const sdkApiKey = environment?.CURSOR_API_KEY?.trim(); if (!sdkApiKey) { - return buildServerProvider({ - presentation: CURSOR_PRESENTATION, - enabled: cursorSettings.enabled, - checkedAt, - models: fallbackModels, - probe: { - installed: true, - version: null, - status: "error", - auth: { status: "unauthenticated" }, - message: "Sign in with Cursor or add CURSOR_API_KEY in provider settings.", - }, - }); + return { + provider: buildServerProvider({ + presentation: CURSOR_PRESENTATION, + enabled: cursorSettings.enabled, + checkedAt, + models: fallbackModels, + probe: { + installed: true, + version: null, + status: "error", + auth: { status: "unauthenticated" }, + message: "Sign in with Cursor or add CURSOR_API_KEY in provider settings.", + }, + }), + sdkModels: undefined, + }; } const sdkCatalog = yield* CursorSdkCatalog.CursorSdkCatalog; @@ -307,50 +333,59 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")( ? "Cursor needs a paid plan to run in T3 Code. Upgrade this account or sign in with a different one." : "Cursor needs a paid plan to run in T3 Code. Upgrade the account that owns CURSOR_API_KEY or use a key from a paid account."; } - return buildServerProvider({ - presentation: CURSOR_PRESENTATION, - enabled: cursorSettings.enabled, - checkedAt, - models: fallbackModels, - probe: { - installed: true, - version: null, - status: "error", - auth: { status: failure.authenticationFailure ? "unauthenticated" : "unknown" }, - message, - }, - }); + return { + provider: buildServerProvider({ + presentation: CURSOR_PRESENTATION, + enabled: cursorSettings.enabled, + checkedAt, + models: fallbackModels, + probe: { + installed: true, + version: null, + status: "error", + auth: { status: failure.authenticationFailure ? "unauthenticated" : "unknown" }, + message, + }, + }), + sdkModels: undefined, + }; } if (Option.isNone(catalogResult.success)) { - return buildServerProvider({ - presentation: CURSOR_PRESENTATION, - enabled: cursorSettings.enabled, - checkedAt, - models: fallbackModels, - probe: { - installed: true, - version: null, - status: "error", - auth: { status: "unknown" }, - message: `Cursor SDK catalog request timed out after ${CURSOR_SDK_CATALOG_TIMEOUT_MS}ms.`, - }, - }); + return { + provider: buildServerProvider({ + presentation: CURSOR_PRESENTATION, + enabled: cursorSettings.enabled, + checkedAt, + models: fallbackModels, + probe: { + installed: true, + version: null, + status: "error", + auth: { status: "unknown" }, + message: `Cursor SDK catalog request timed out after ${CURSOR_SDK_CATALOG_TIMEOUT_MS}ms.`, + }, + }), + sdkModels: undefined, + }; } const snapshot = catalogResult.success.value; const discoveredModels = buildCursorDiscoveredModelsFromSdk(snapshot.models); - return buildCursorProviderSnapshot({ - checkedAt, - cursorSettings, - parsed: { - version: null, - status: "ready", - auth: cursorSdkAuth(snapshot.user, authenticationType), - }, - discoveredModels, - ...(discoveredModels.length === 0 - ? { discoveryWarning: "Cursor SDK model discovery returned no built-in models." } - : {}), - }); + return { + provider: buildCursorProviderSnapshot({ + checkedAt, + cursorSettings, + parsed: { + version: null, + status: "ready", + auth: cursorSdkAuth(snapshot.user, authenticationType), + }, + discoveredModels, + ...(discoveredModels.length === 0 + ? { discoveryWarning: "Cursor SDK model discovery returned no built-in models." } + : {}), + }), + sdkModels: snapshot.models, + }; }); From 8396d7028d3fd92bf12d7dd6d6c21ee0f6f53482 Mon Sep 17 00:00:00 2001 From: Gabriel Rodrigues Date: Sat, 31 Oct 2026 15:15:31 -0300 Subject: [PATCH 2/5] fix(cursor): honor Max Mode against the default catalog params When the composer only toggles Max Mode, resolve the default variant's params so matching max-mode variants are admitted instead of requiring isDefault on every candidate. Co-authored-by: Cursor --- .../src/server/sdkModel.test.ts | 13 ++++++++++++ .../provider-cursor/src/server/sdkModel.ts | 20 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/provider-cursor/src/server/sdkModel.test.ts b/packages/provider-cursor/src/server/sdkModel.test.ts index d90ea1ac77c6c..ae971a21ffdf6 100644 --- a/packages/provider-cursor/src/server/sdkModel.test.ts +++ b/packages/provider-cursor/src/server/sdkModel.test.ts @@ -129,6 +129,19 @@ describe("cursorSdkModelSelection", () => { id: "composer-2", params: [{ id: "fast", value: "true" }], }); + expect( + cursorSdkModelSelection( + { + instanceId, + model: "composer-2", + options: [{ id: CURSOR_SDK_MAX_MODE_OPTION_ID, value: true }], + }, + catalog, + ), + ).toEqual({ + id: "composer-2", + maxMode: true, + }); }); }); diff --git a/packages/provider-cursor/src/server/sdkModel.ts b/packages/provider-cursor/src/server/sdkModel.ts index 8ddcc52cd67b5..dab3b3fca5610 100644 --- a/packages/provider-cursor/src/server/sdkModel.ts +++ b/packages/provider-cursor/src/server/sdkModel.ts @@ -75,12 +75,27 @@ function variantMatchesParams( ); } +function defaultVariantParams( + model: Pick, +): ReadonlyArray | undefined { + return (model.variants ?? []).find((variant) => variant.isDefault === true)?.params; +} + +function effectiveVariantParams( + model: Pick, + params: ReadonlyArray | undefined, +): ReadonlyArray | undefined { + return params !== undefined && params.length > 0 ? params : defaultVariantParams(model); +} + export function cursorSdkMaxModeForParams( model: Pick, params: ReadonlyArray | undefined, ): boolean { const variants = model.variants ?? []; - const matching = variants.filter((variant) => variantMatchesParams(variant, params)); + const matching = variants.filter((variant) => + variantMatchesParams(variant, effectiveVariantParams(model, params)), + ); return matching.length > 0 && matching.every((variant) => variant.isMaxMode === true); } @@ -88,8 +103,9 @@ function cursorSdkParamsAdmitMaxMode( model: Pick, params: ReadonlyArray | undefined, ): boolean { + const effective = effectiveVariantParams(model, params); return (model.variants ?? []).some( - (variant) => variantMatchesParams(variant, params) && variant.isMaxMode === true, + (variant) => variantMatchesParams(variant, effective) && variant.isMaxMode === true, ); } From 67d9fda3e8f2fdc775a07341a0950d242f3edb2e Mon Sep 17 00:00:00 2001 From: Gabriel Rodrigues Date: Sat, 31 Oct 2026 15:16:30 -0300 Subject: [PATCH 3/5] fix(cursor): unwrap status probe in catalog auth tests checkCursorProviderStatus now returns { provider, sdkModels }; assert on the provider snapshot after main's auth cases landed beside the Max Mode catalog change. Co-authored-by: Cursor --- packages/provider-cursor/src/server/status.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/provider-cursor/src/server/status.test.ts b/packages/provider-cursor/src/server/status.test.ts index b077b930d1ce6..ef041bce43214 100644 --- a/packages/provider-cursor/src/server/status.test.ts +++ b/packages/provider-cursor/src/server/status.test.ts @@ -384,7 +384,7 @@ describe("checkCursorProviderStatus", () => { ), readModels: () => Effect.succeed([sdkParameterizedModel]), }); - const provider = yield* checkCursorProviderStatus(baseCursorSettings, { + const { provider } = yield* checkCursorProviderStatus(baseCursorSettings, { CURSOR_API_KEY: "enterprise-key", }).pipe(Effect.provideService(CursorSdkCatalog.CursorSdkCatalog, catalog)); From c28316e8db393d1a95da5384e5c2747c8b8f3092 Mon Sep 17 00:00:00 2001 From: Gabriel Rodrigues Date: Tue, 3 Nov 2026 13:47:54 -0300 Subject: [PATCH 4/5] test(cursor): assert Max Mode reaches the runner after catalog refresh Co-authored-by: Cursor --- packages/provider-cursor/src/server/driver.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/provider-cursor/src/server/driver.test.ts b/packages/provider-cursor/src/server/driver.test.ts index d273e4b278194..41910dca80ca5 100644 --- a/packages/provider-cursor/src/server/driver.test.ts +++ b/packages/provider-cursor/src/server/driver.test.ts @@ -363,6 +363,7 @@ it.layer(layerTest)("CursorDriver", (it) => { { displayName: "Claude Opus 5.5", isDefault: true, + isMaxMode: true, params: [{ id: "context", value: "1m" }], }, ], @@ -395,7 +396,7 @@ it.layer(layerTest)("CursorDriver", (it) => { allowance: DEFAULT_HANDOFF_TOKEN_CAP, }, catalogDefault: { - model: { id: "claude-opus-5-5" }, + model: { id: "claude-opus-5-5", maxMode: true }, window: 1_000_000, allowance: DEFAULT_HANDOFF_TOKEN_CAP, }, From d1be6dd2cf1db132cbaad65f9a726a61bfeca0e2 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 17 Nov 2026 04:24:47 +0000 Subject: [PATCH 5/5] refactor(cursor): capture the SDK catalog with one tap and share it with text generation Co-Authored-By: Claude Opus 5.5 --- packages/provider-cursor/src/server/driver.ts | 50 +++++++++---------- .../src/server/textGeneration.ts | 5 +- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/packages/provider-cursor/src/server/driver.ts b/packages/provider-cursor/src/server/driver.ts index 65ff4cf4cb137..690f048450e56 100644 --- a/packages/provider-cursor/src/server/driver.ts +++ b/packages/provider-cursor/src/server/driver.ts @@ -214,6 +214,7 @@ export const CursorDriver: ProviderDriver< auth.requireApiKey, auth.withAccess, () => catalogModels, + () => catalogSdkModels, ); const checkProvider = auth.readApiKey.pipe( @@ -227,46 +228,41 @@ export const CursorDriver: ProviderDriver< }, auth.usesApiKey ? "api-key" : "browser", ).pipe( - Effect.flatMap(({ provider: statusProvider, sdkModels }) => - Effect.succeed(statusProvider).pipe( - Effect.filterOrElse( - (snapshot) => - !( - effectiveConfig.enabled && - snapshot.installed && - snapshot.auth.status === "authenticated" - ), - (snapshot) => - readCursorUsageLimits(effectiveConfig, { - ...processEnv, - CURSOR_API_KEY: apiKey, - }).pipe(Effect.map((usageLimits) => ({ ...snapshot, usageLimits }))), + Effect.tap(({ sdkModels }) => + Effect.sync(() => { + // A failed check carries no catalog, so keep the last loaded one. + if (sdkModels !== undefined) { + catalogSdkModels = sdkModels; + } + }), + ), + Effect.map(({ provider }) => provider), + Effect.filterOrElse( + (snapshot) => + !( + effectiveConfig.enabled && + snapshot.installed && + snapshot.auth.status === "authenticated" ), - Effect.map((provider) => ({ provider, sdkModels })), - ), + (snapshot) => + readCursorUsageLimits(effectiveConfig, { + ...processEnv, + CURSOR_API_KEY: apiKey, + }).pipe(Effect.map((usageLimits) => ({ ...snapshot, usageLimits }))), ), ), ), Effect.provideService(FileSystem.FileSystem, fileSystem), Effect.provideService(Path.Path, path), - Effect.map(({ provider, sdkModels }) => ({ - provider: stampSnapshot(provider), - sdkModels, - })), - Effect.tap(({ provider, sdkModels }) => + Effect.map(stampSnapshot), + Effect.tap((provider) => Effect.sync(() => { // A failed check lists only custom models, so keep the last loaded catalog. if (provider.models.some((model) => !model.isCustom)) { catalogModels = provider.models; } - // Reuse the timed status probe — a second unbounded catalog.read would - // defeat the probe timeout when the first request stalled. - if (sdkModels !== undefined) { - catalogSdkModels = sdkModels; - } }), ), - Effect.map(({ provider }) => provider), Effect.provide(CursorSdkCatalog.layer), Effect.provideService(HttpClient.HttpClient, httpClient), ); diff --git a/packages/provider-cursor/src/server/textGeneration.ts b/packages/provider-cursor/src/server/textGeneration.ts index ba581bef38c1d..60a0f1d780114 100644 --- a/packages/provider-cursor/src/server/textGeneration.ts +++ b/packages/provider-cursor/src/server/textGeneration.ts @@ -1,6 +1,6 @@ import * as FileSystem from "effect/FileSystem"; -import type { AgentOptions, RunResult } from "@cursor/sdk"; +import type { AgentOptions, RunResult, SDKModel } from "@cursor/sdk"; import * as Effect from "effect/Effect"; import * as Option from "effect/Option"; import * as Schema from "effect/Schema"; @@ -56,6 +56,7 @@ export const makeCursorTextGeneration = Effect.fn("makeCursorTextGeneration")(fu resolveApiKey?: Effect.Effect, withAccess?: CursorAuth["withAccess"], getModels?: () => ReadonlyArray, + getSdkModels?: () => ReadonlyArray, ) { const fs = yield* FileSystem.FileSystem; const sdk = yield* CursorSdk.CursorSdk; @@ -122,7 +123,7 @@ export const makeCursorTextGeneration = Effect.fn("makeCursorTextGeneration")(fu const agentOptions = { apiKey, mode: "plan", - model: cursorSdkModelSelection(modelSelection, getModels?.() ?? []), + model: cursorSdkModelSelection(modelSelection, getModels?.() ?? [], getSdkModels?.() ?? []), local: { cwd, store,