Skip to content

Commit 908bc80

Browse files
fix(server): Cursor status says when the account's plan is rejected
1 parent d60a71e commit 908bc80

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

‎apps/server/src/provider/Layers/CursorProvider.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
buildInitialCursorProviderSnapshot,
1414
checkCursorProviderStatus,
1515
} from "./CursorProvider.ts";
16+
import { CursorSdkError } from "../cursorSdk.ts";
1617
import * as CursorSdkCatalog from "./CursorSdkCatalog.ts";
1718

1819
const decodeCursorSettings = Schema.decodeSync(CursorSettingsSchema);
@@ -231,6 +232,34 @@ describe("checkCursorProviderStatus", () => {
231232
}),
232233
);
233234

235+
it.effect("says when Cursor rejects the account's plan", () =>
236+
Effect.gen(function* () {
237+
const provider = yield* checkCursorProviderStatus(baseCursorSettings, {
238+
CURSOR_API_KEY: "free-plan-test-key",
239+
}).pipe(
240+
Effect.provide(
241+
CursorSdkCatalog.makeCursorSdkCatalogTestLayer(() =>
242+
Effect.fail(
243+
new CursorSdkCatalog.CursorSdkCatalogError({
244+
authenticationFailure: false,
245+
cause: new CursorSdkError(
246+
"[plan_required] Cloud Agent is not available for free users. Please upgrade to Pro.",
247+
{ code: "plan_required", status: 403, isRetryable: false },
248+
),
249+
}),
250+
),
251+
),
252+
),
253+
);
254+
255+
expect(provider).toMatchObject({
256+
status: "error",
257+
message:
258+
"Cursor's SDK is not available on the free plan. Upgrade the Cursor account to Pro.",
259+
});
260+
}),
261+
);
262+
234263
it.effect("requires a Cursor API key without probing any external Cursor binary", () =>
235264
Effect.gen(function* () {
236265
const provider = yield* checkCursorProviderStatus(baseCursorSettings).pipe(

‎apps/server/src/provider/Layers/CursorProvider.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
providerModelsFromSettings,
2222
type ServerProviderDraft,
2323
} from "../providerSnapshot.ts";
24+
import { CursorSdkError } from "../cursorSdk.ts";
2425
import * as CursorSdkCatalog from "./CursorSdkCatalog.ts";
2526

2627
const CURSOR_PRESENTATION = {
@@ -297,6 +298,8 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(
297298
cause: catalogResult.failure.cause,
298299
});
299300
const authenticationFailure = catalogResult.failure.authenticationFailure;
301+
const cause = catalogResult.failure.cause;
302+
const planRequired = cause instanceof CursorSdkError && cause.code === "plan_required";
300303
return buildServerProvider({
301304
presentation: CURSOR_PRESENTATION,
302305
enabled: cursorSettings.enabled,
@@ -311,7 +314,9 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(
311314
? authenticationType === "browser"
312315
? "Cursor sign-in expired or was rejected. Sign in again in provider settings."
313316
: "Cursor SDK authentication failed. Check CURSOR_API_KEY."
314-
: "Cursor SDK catalog request failed. Check server logs for details.",
317+
: planRequired
318+
? "Cursor's SDK is not available on the free plan. Upgrade the Cursor account to Pro."
319+
: "Cursor SDK catalog request failed. Check server logs for details.",
315320
},
316321
});
317322
}

0 commit comments

Comments
 (0)