@devries-cameron20 / t3code-1 / commits / 80fd67eca6
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(provider-cursor): Cursor keeps working when a team blocks /v1/me (#24639)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Victor Vogel committed Oct 31, 2026 at 03:44 UTC 80fd67eca6aba67da3e632f90c4b82a4e1cf0fbc
3 files changed +103 -5
packages/provider-cursor/src/server/CursorSdkCatalog.ts
+12 -2
@@ -10,7 +10,7 @@ import * as Schema from "effect/Schema";
10 import { AuthenticationError, Cursor, CursorSdkError } from "./sdk.ts";
11
12 export interface CursorSdkCatalogSnapshot {
13 - readonly user: SDKUser;
13 + readonly user: SDKUser | undefined;
14 readonly models: ReadonlyArray<SDKModel>;
15 }
16
@@ -30,6 +30,10 @@ export class CursorSdkCatalogError extends Schema.TaggedError<CursorSdkCatalogEr
30 get planRequired(): boolean {
31 return this.cause instanceof CursorSdkError && this.cause.code === "plan_required";
32 }
33 +
34 + get accountBlocked(): boolean {
35 + return this.cause instanceof CursorSdkError && this.cause.status === 403 && !this.planRequired;
36 + }
37 }
38
39 export class CursorSdkCatalog extends Context.Service<
@@ -82,7 +86,13 @@ export const makeCursorSdkCatalog = Effect.fn("CursorSdkCatalog.make")(function*
86 read: Effect.fn("CursorSdkCatalog.read")(function (apiKey) {
87 return Effect.all(
88 {
85 - user: probes.readUser(apiKey),
89 + // Enterprise teams can block account labels while model discovery still works.
90 + user: Effect.catchIf(
91 + probes.readUser(apiKey),
92 + (error: CursorSdkCatalogError): boolean => error.accountBlocked,
93 + () => Effect.undefined,
94 + (error: CursorSdkCatalogError) => Effect.fail(error),
95 + ),
96 models: Cache.get(modelCache, apiKey),
97 },
98 { concurrency: "unbounded" },
packages/provider-cursor/src/server/status.test.ts
+88
@@ -261,6 +261,94 @@ describe("checkCursorProviderStatus", () => {
261 }),
262 );
263
264 + it.effect.each([
265 + {
266 + name: "keeps models when /v1/me is blocked",
267 + meFailure: new CursorSdkError("[feature_unavailable] Not available for this team.", {
268 + code: "feature_unavailable",
269 + status: 403,
270 + }),
271 + expected: {
272 + status: "ready",
273 + auth: { status: "authenticated", type: "api-key", label: "Cursor API key" },
274 + models: [{ slug: "claude-opus-4-8", isCustom: false }],
275 + },
276 + },
277 + {
278 + name: "keeps models when /v1/me returns a 403 without a code",
279 + meFailure: new CursorSdkError("[unknown] Forbidden", { code: "unknown", status: 403 }),
280 + expected: {
281 + status: "ready",
282 + auth: { status: "authenticated", type: "api-key", label: "Cursor API key" },
283 + models: [{ slug: "claude-opus-4-8", isCustom: false }],
284 + },
285 + },
286 + {
287 + name: "keeps the paid-plan message when /v1/me returns plan_required",
288 + meFailure: new CursorSdkError("[plan_required] Not available for free users.", {
289 + code: "plan_required",
290 + status: 403,
291 + }),
292 + expected: {
293 + status: "error",
294 + auth: { status: "unknown" },
295 + message:
296 + "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.",
297 + },
298 + },
299 + {
300 + name: "fails when /v1/me has a server error",
301 + meFailure: new CursorSdkError("[unknown] Service unavailable", {
302 + code: "unknown",
303 + status: 503,
304 + }),
305 + expected: {
306 + status: "error",
307 + auth: { status: "unknown" },
308 + message: "Cursor SDK catalog request failed. Check server logs for details.",
309 + },
310 + },
311 + {
312 + name: "rejects a 401 even when its code is feature_unavailable",
313 + meFailure: new CursorSdkError("Unauthorized", {
314 + code: "feature_unavailable",
315 + status: 401,
316 + }),
317 + expected: {
318 + status: "error",
319 + auth: { status: "unauthenticated" },
320 + message: "Cursor SDK authentication failed. Check CURSOR_API_KEY.",
321 + },
322 + },
323 + {
324 + name: "fails a key that /v1/me rejects",
325 + meFailure: new CursorSdkError("Unauthorized", { status: 401 }),
326 + expected: {
327 + status: "error",
328 + auth: { status: "unauthenticated" },
329 + message: "Cursor SDK authentication failed. Check CURSOR_API_KEY.",
330 + },
331 + },
332 + ])("$name", ({ meFailure, expected }) =>
333 + Effect.gen(function* () {
334 + const catalog = yield* CursorSdkCatalog.makeCursorSdkCatalog({
335 + readUser: () =>
336 + Effect.fail(
337 + new CursorSdkCatalog.CursorSdkCatalogError({
338 + authenticationFailure: meFailure.status === 401,
339 + cause: meFailure,
340 + }),
341 + ),
342 + readModels: () => Effect.succeed([sdkParameterizedModel]),
343 + });
344 + const provider = yield* checkCursorProviderStatus(baseCursorSettings, {
345 + CURSOR_API_KEY: "enterprise-key",
346 + }).pipe(Effect.provideService(CursorSdkCatalog.CursorSdkCatalog, catalog));
347 +
348 + expect(provider).toMatchObject(expected);
349 + }),
350 + );
351 +
352 it.effect("requires a Cursor API key without probing any external Cursor binary", () =>
353 Effect.gen(function* () {
354 const provider = yield* checkCursorProviderStatus(baseCursorSettings).pipe(
packages/provider-cursor/src/server/status.ts
+3 -3
@@ -182,9 +182,9 @@ export function buildCursorDiscoveredModelsFromSdk(
182 });
183 }
184
185 -function cursorSdkAuth(user: SDKUser, type: "api-key" | "browser"): ServerProviderAuth {
186 - const email = user.userEmail?.trim();
187 - const apiKeyName = user.apiKeyName.trim();
185 +function cursorSdkAuth(user: SDKUser | undefined, type: "api-key" | "browser"): ServerProviderAuth {
186 + const email = user?.userEmail?.trim();
187 + const apiKeyName = user?.apiKeyName.trim();
188 return {
189 status: "authenticated",
190 type,