diff --git a/packages/provider-cursor/src/server/adapter.ts b/packages/provider-cursor/src/server/adapter.ts index 04c6aa780e7d0..b11bdfa30f1e0 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, @@ -312,11 +313,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, input.models), + model: cursorSdkModelSelection(input.modelSelection, input.models, input.sdkModels), name: `T3 Code ${input.threadId}`, mode: input.runtimePolicy.interactionMode === "plan" ? "plan" : "agent", ...(input.apiKey === undefined ? {} : { apiKey: input.apiKey }), @@ -1016,6 +1018,7 @@ export interface CursorAdapterV2Options { readonly instanceId: ProviderInstanceId; readonly environment: NodeJS.ProcessEnv; readonly getModels?: () => ReadonlyArray; + readonly getSdkModels?: () => ReadonlyArray>; } export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( @@ -2551,6 +2554,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( platform, threadId: openInput.threadId, mcpSession: yield* mcpSessions.read(openInput.threadId), + sdkModels: adapterOptions.getSdkModels?.() ?? [], }); if ( platform === "win32" && @@ -2771,6 +2775,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( model: cursorSdkModelSelection( turnInput.modelSelection, adapterOptions.getModels?.() ?? [], + adapterOptions.getSdkModels?.() ?? [], ), mode: turnInput.runtimePolicy.interactionMode === "plan" ? "plan" : "agent", ...(Object.keys(turnMcpServers).length === 0 diff --git a/packages/provider-cursor/src/server/driver.test.ts b/packages/provider-cursor/src/server/driver.test.ts index 213d413b6dee2..88e13c31f7a26 100644 --- a/packages/provider-cursor/src/server/driver.test.ts +++ b/packages/provider-cursor/src/server/driver.test.ts @@ -357,6 +357,7 @@ it.layer(layerTest)("CursorDriver", (it) => { { displayName: "Claude Opus 5.5", isDefault: true, + isMaxMode: true, params: [{ id: "context", value: "1m" }], }, ], @@ -389,7 +390,11 @@ it.layer(layerTest)("CursorDriver", (it) => { allowance: DEFAULT_HANDOFF_TOKEN_CAP, }, catalogDefault: { - model: { id: "claude-opus-5-5", params: [{ id: "context", value: "1m" }] }, + model: { + id: "claude-opus-5-5", + params: [{ id: "context", value: "1m" }], + maxMode: true, + }, window: 1_000_000, allowance: DEFAULT_HANDOFF_TOKEN_CAP, }, diff --git a/packages/provider-cursor/src/server/driver.ts b/packages/provider-cursor/src/server/driver.ts index 4b7477295fbd8..690f048450e56 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, @@ -164,10 +165,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, @@ -211,6 +214,7 @@ export const CursorDriver: ProviderDriver< auth.requireApiKey, auth.withAccess, () => catalogModels, + () => catalogSdkModels, ); const checkProvider = auth.readApiKey.pipe( @@ -224,6 +228,15 @@ export const CursorDriver: ProviderDriver< }, auth.usesApiKey ? "api-key" : "browser", ).pipe( + 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) => !( diff --git a/packages/provider-cursor/src/server/sdkModel.test.ts b/packages/provider-cursor/src/server/sdkModel.test.ts index 4ad129e1ae239..beaa51f706880 100644 --- a/packages/provider-cursor/src/server/sdkModel.test.ts +++ b/packages/provider-cursor/src/server/sdkModel.test.ts @@ -1,7 +1,8 @@ +import type { SDKModel } from "@cursor/sdk"; import { ProviderInstanceId } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; -import { cursorSdkModelSelection } from "./sdkModel.ts"; +import { cursorSdkModelOffersOptionalMaxMode, cursorSdkModelSelection } from "./sdkModel.ts"; import { buildCursorDiscoveredModelsFromSdk } from "./status.ts"; const instanceId = ProviderInstanceId.make("cursor"); @@ -71,3 +72,80 @@ describe("cursorSdkModelSelection", () => { }); }); }); + +describe("cursorSdkModelSelection Max Mode", () => { + const sdkModels = [ + { + id: "composer-2", + displayName: "Composer 2", + parameters: [ + { id: "fast", displayName: "Fast", values: [{ value: "false" }, { value: "true" }] }, + ], + 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" }] }, + ], + }, + { + id: "claude-opus-4-8", + displayName: "Claude Opus 4.8", + parameters: [{ id: "context", displayName: "Context", values: [{ value: "1m" }] }], + variants: [ + { + displayName: "1M", + isDefault: true, + isMaxMode: true, + params: [{ id: "context", value: "1m" }], + }, + ], + }, + ] satisfies ReadonlyArray; + const catalogModels = buildCursorDiscoveredModelsFromSdk(sdkModels); + + it.each([ + { + name: "leaves optional Max Mode off by default", + model: "composer-2", + options: undefined, + expected: { id: "composer-2", params: [{ id: "fast", value: "false" }] }, + }, + { + name: "turns on optional Max Mode without sending it as a parameter", + model: "composer-2", + options: [{ id: "maxMode", value: true }], + expected: { id: "composer-2", params: [{ id: "fast", value: "false" }], maxMode: true }, + }, + { + name: "drops Max Mode when no variant with the chosen parameters offers it", + model: "composer-2", + options: [ + { id: "fastMode", value: true }, + { id: "maxMode", value: true }, + ], + expected: { id: "composer-2", params: [{ id: "fast", value: "true" }] }, + }, + { + name: "turns on Max Mode when every matching variant requires it", + model: "claude-opus-4-8", + options: undefined, + expected: { + id: "claude-opus-4-8", + params: [{ id: "context", value: "1m" }], + maxMode: true, + }, + }, + ])("$name", ({ model, options, expected }) => { + expect( + cursorSdkModelSelection( + { instanceId, model, ...(options === undefined ? {} : { options }) }, + catalogModels, + sdkModels, + ), + ).toEqual(expected); + }); + + it("offers a Max Mode toggle only where it is optional", () => { + expect(sdkModels.map(cursorSdkModelOffersOptionalMaxMode)).toEqual([true, false]); + }); +}); diff --git a/packages/provider-cursor/src/server/sdkModel.ts b/packages/provider-cursor/src/server/sdkModel.ts index ec2a53b6aea71..cc274b68ca395 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,30 +63,116 @@ export function cursorContextWindowTokens( return Number.isSafeInteger(tokens) && tokens > 0 ? tokens : undefined; } +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), + ); +} + +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); +} + +function cursorSdkMaxModeForParams( + model: Pick, + params: ReadonlyArray | undefined, +): boolean { + const variants = model.variants ?? []; + const matching = variants.filter((variant) => + variantMatchesParams(variant, effectiveVariantParams(model, params)), + ); + return matching.length > 0 && matching.every((variant) => variant.isMaxMode === true); +} + +function cursorSdkParamsAdmitMaxMode( + model: Pick, + params: ReadonlyArray | undefined, +): boolean { + const effective = effectiveVariantParams(model, params); + return (model.variants ?? []).some( + (variant) => variantMatchesParams(variant, effective) && 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, models: ReadonlyArray = [], + sdkModels: ReadonlyArray> = [], ): CursorSdkModelSelection { - const explicit = modelSelection.options ?? []; + const id = modelSelection.model === "auto" ? "default" : modelSelection.model; + const selected = modelSelection.options ?? []; + const userRequestedMaxMode = selected.some( + (option) => option.id === CURSOR_SDK_MAX_MODE_OPTION_ID && option.value === true, + ); + const explicit = selected.filter((option) => option.id !== CURSOR_SDK_MAX_MODE_OPTION_ID); const descriptors = models.find((model) => model.slug === modelSelection.model)?.capabilities?.optionDescriptors ?? []; // Some Cursor plans reject runs that leave a catalog parameter unset; T3 keeps Fast off until picked. const defaults = descriptors.flatMap((descriptor) => { + if (descriptor.id === CURSOR_SDK_MAX_MODE_OPTION_ID) return []; if (explicit.some((option) => option.id === descriptor.id)) return []; const value = descriptor.id === "fastMode" ? false : getProviderOptionCurrentValue(descriptor); return value === undefined ? [] : [{ id: descriptor.id, value }]; }); const options = [...explicit, ...defaults]; + const params = + options.length === 0 + ? undefined + : options.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)); return { - id: modelSelection.model === "auto" ? "default" : modelSelection.model, - ...(options.length === 0 - ? {} - : { - params: options.map((option): ModelParameterValue => ({ - id: cursorSdkParameterId(option.id), - value: String(option.value), - })), - }), + id, + ...(params === undefined ? {} : { params }), + ...(forcedMaxMode || optionalMaxMode ? { maxMode: true } : {}), }; } diff --git a/packages/provider-cursor/src/server/status.test.ts b/packages/provider-cursor/src/server/status.test.ts index 0ce81df747e30..b46ee3fe435ee 100644 --- a/packages/provider-cursor/src/server/status.test.ts +++ b/packages/provider-cursor/src/server/status.test.ts @@ -98,6 +98,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("buildInitialCursorProviderSnapshot", () => { it.effect.each([true, false])("advertises manual compaction only when enabled (%s)", (enabled) => Effect.gen(function* () { @@ -154,6 +178,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("keeps catalog aliases and filters invalid and duplicate SDK model entries", () => { const composer = { id: "composer-2", @@ -188,7 +223,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"], @@ -224,6 +259,7 @@ describe("checkCursorProviderStatus", () => { { slug: "internal/cursor-model", isCustom: true }, ], }); + expect(sdkModels).toEqual([sdkParameterizedModel]); }), ); @@ -250,13 +286,13 @@ describe("checkCursorProviderStatus", () => { Effect.forkChild, ); yield* TestClock.adjust("20 seconds"); - expect((yield* Fiber.join(fiber)).status).toBe("ready"); + expect((yield* Fiber.join(fiber)).provider.status).toBe("ready"); }), ); 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( @@ -276,6 +312,7 @@ describe("checkCursorProviderStatus", () => { auth: { status: "unauthenticated" }, message: "Cursor SDK authentication failed. Check CURSOR_API_KEY.", }); + expect(sdkModels).toBeUndefined(); }), ); @@ -294,7 +331,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, @@ -320,6 +357,7 @@ describe("checkCursorProviderStatus", () => { auth: { status: "unknown" }, message, }); + expect(sdkModels).toBeUndefined(); }), ); @@ -405,7 +443,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)); @@ -437,7 +475,7 @@ describe("checkCursorProviderStatus", () => { Effect.forkChild({ startImmediately: true }), ); yield* TestClock.adjust("1 minute"); - const provider = yield* Fiber.join(fiber); + const { provider } = yield* Fiber.join(fiber); expect(provider.status).not.toBe("error"); }), @@ -445,7 +483,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"), @@ -459,6 +497,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 570a7ac34f453..6b170cf3fc261 100644 --- a/packages/provider-cursor/src/server/status.ts +++ b/packages/provider-cursor/src/server/status.ts @@ -14,7 +14,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, @@ -36,6 +41,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 { @@ -160,6 +170,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 }); } @@ -254,41 +274,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; @@ -323,50 +349,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 ${timeoutMs}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 ${timeoutMs}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, + }; }); 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,