Files
plugins/packages/cursor/README.md
T
geoqiao 8cd5a0fad8 cursor 0.2.0: the list is Cursor's picker, a model once per context size with that window; effort and fast are the request's (#51)
* cursor 0.2.0: the list is Cursor's picker, a model once for each context size with that window (claude-opus-5-5@300k, @1m), and effort and fast are the request's, sent as the variant's parameters

The usable list (AgentService/GetUsableModels) names a model once for each effort and speed, and the window was read off the name: 1M when it said 1M, else 200K. The names say 1M of models Cursor serves at 300K outside Max Mode ("Claude Opus 5.5 1M"), and nothing of the 300K Sonnet and Haiku or the 256K Grok have, so on this account 110 of 153 names gave a wrong window: Opus too large, Sonnet, Haiku and Grok too small, and the agents compacted at the wrong point. The request carried no context parameter either, so the window Cursor ran at was its own choice, not the one magpie reported. The same id could go to a 300K and a 1M variant.

Now the list is Cursor's model picker alone (AiService/AvailableModels, asked as the CLI asks it: useModelParameters, doNotUseMarkdown), the way pi-cursor-sdk lists Cursor's catalog. A model with a context parameter is offered once for each size, as <model>@<size> named "<name> @ <size>", its window that many tokens; one without is offered once, its window Cursor's contextTokenLimit (Max Mode's for a model served only there), 200K when Cursor gives none. Effort is not a model of its own: the model's efforts (effort / reasoning_effort / reasoning; extra-high is xhigh) are its variants, the request's reasoning_effort is fitted to the nearest and sent as that parameter, and none turns a Claude's thinking off. Fast is not one either: a service_tier of priority or fast sends fast=true, anything else fast=false, so it is paid for only when asked. A request goes as the variant those parameters pick, by the variant's legacySlug (claude-opus-5-5-medium): the agent API refuses the picker's base name with 502 "AI Model Not Found: Model name is not valid". It goes in Max Mode when that variant is Max Mode's (a 1M size; Opus 300K with fast), or, with no variant for the size, when the size is over Cursor's limit outside it; the "Max Mode Required" retry stays. Hidden, Tab-only and chat-only models stay out, as in the CLI.

The ids change (cursor/claude-opus-5-5 is cursor/claude-opus-5-5@300k; the -fast, -low and -thinking models are gone), so 0.2.0: a model picked in magpie or an agent's config has to be picked again. An id the list doesn't have goes to Cursor as it is named, with the default window. poolBase and firstParty take the @size off, so usage pools as before (grok-4.7@256k Cursor Models, claude-opus-5-5@300k Other Models).

context.test.mjs (new) covers the list, the windows, the variants and the request's parameters and mode; maxmode.test.mjs (rewritten) checks what reaches a fake agent API; usage.test.mjs adds the sized ids. HOME=$(mktemp -d) bun test: 45 pass, 0 fail; check.mjs cursor passes. Tried with a real Cursor account: claude-opus-5-5@300k goes as claude-opus-5-5-medium with context=300k and answers, grok-4.6 as cursor-grok-4.6-high, and pi -p --model magpie/cursor/claude-opus-5-5@300k answers; the base name got the 502 above.

* cursor 0.2.0: an id 0.1.x listed still runs as the variant it stood for, and a variant the account hasn't got is neither offered nor asked for (review of #51)

An id the new list doesn't have went to Cursor as it was named. The ids 0.1.11 listed are families of the variants' own ids (claude-opus-5-5, claude-opus-5-5-fast, claude-haiku-5-5-thinking, cursor-grok-4.6), and they are saved in agents' configs, magpie's picks and routing groups: request(raw, "claude-opus-5-5", "high") was {id: "claude-opus-5-5", params: [], maxMode: false}, the bare name the agent API answers 502 "AI Model Not Found" for, with the effort dropped.

Now an id the list doesn't have is read as one of Cursor's own (named): a variant's legacySlug is that variant; a family of them, taken apart as 0.1.x's splitID did, is the family's variant nearest the default, fast for a -fast family, thinking as the family says, at the effort the id names when the request names none; the picker's name for a model, one of its legacySlugs or idAliases, is its default. Each is at the variant's context size, the default's when two sizes share the id. The request's reasoning_effort and service_tier count as for a listed model. The family is tried before the picker's name, so claude-haiku-5-5 stays the Claude without thinking it was in 0.1.11 where Cursor has variants named so; where it has none it is the model's default. Anything else still goes as it is named.

The usable list (AgentService/GetUsableModels) is read again, beside the picker: a variant whose legacySlug isn't in it is dropped, the model's efforts and sizes are the ones its remaining variants have, and a request no remaining variant matches goes as the nearest of them, not as the default's id with parameters the account hasn't got. A model the usable list has nothing of is the picker's alone (GLM-5.3, as 0.1.7 found) and is kept whole; a usable list Cursor can't give leaves the picker as it is.

answerOf's comment says what pick does with no service_tier (fast off). context.test.mjs checks the PICKER_SKIP names stay out (claude-4.5-haiku, claude-haiku-4-5), each id 0.1.11's offered() gives for the fixture's slugs, variant ids and a model's legacy slug, and the usable list's filter; maxmode.test.mjs checks claude-opus-5-5 reaches the fake agent API as claude-opus-5-5-medium. On b33ec2f's index.mjs the three new context tests and that maxmode test fail. HOME=$(mktemp -d) bun test: 48 pass, 0 fail; check.mjs cursor passes. Not tried with a real Cursor account, and not read against cursor-agent's source (neither is on this machine): the old-id rules follow the review's description and 0.1.11's splitID.
2026-10-08 22:03:11 +08:00

6.7 KiB

@magpie-community/opencode-cursor-auth

Signs in to a Cursor subscription (Pro, Pro+, Ultra, Teams) and makes its requests on the API cursor-agent talks to, in OpenCode and in magpie. Provider id: cursor.

Signing in

An account is a Cursor access token. There are three ways to get one:

  • Cursor (browser): the sign-in cursor-agent login does. The page cursor.com/loginDeepControl is opened with a PKCE challenge, and the plugin polls api2.cursor.sh/auth/poll until the browser has signed in. The account is named by its email (DashboardService/GetMe).
  • cursor-agent's sign-in: takes the account cursor-agent login signed in to. Its token is read on every request from where the CLI keeps it: the macOS keychain (cursor-access-token), else its auth.json (~/.cursor/, $XDG_CONFIG_HOME/cursor/ or %APPDATA%\Cursor\). The plugin never writes it; when it has less than 5 minutes left, cursor-agent status is run, which renews it.
  • Cursor API key: a key from cursor.com/dashboard → Integrations. It is exchanged for a token at /auth/exchange_user_api_key, as the CLI does with CURSOR_API_KEY, and exchanged again when the token runs out.

Sign-ins are kept where OpenCode keeps them (auth.json; in magpie, plugin-auth.json). A browser sign-in's token lasts about two months. Cursor gives the CLI no way to renew it, so after that you sign in again.

Requests

OpenCode speaks chat completions (@ai-sdk/openai-compatible); the plugin's fetch answers them on Cursor's agent API:

  • The agent API is the one ServerConfigService/GetServerConfig names for the account (a team may be served in one region only), else agentn.global.api5.cursor.sh. A refusal that names a region is tried once more with the config asked again.
  • Each request is one agent.v1.AgentService/Run, a Connect stream both ways over HTTP/2, with the CLI's headers (x-cursor-client-type: cli, its version, privacy mode on).
  • The whole conversation goes each time, as AI SDK messages kept as blobs the server asks for. The caller's tools are MCP tools, listed in the system prompt; the model calls them through Cursor's CallDynamicTool, and the calls come back as chat completion tool calls. Cursor's own tools (shell, file reads, edits) are never run.
  • A conversation's Runs share one conversation_id, so Cursor sends them to the machine that has the prompt cached (Grok on Cursor caches by machine). It is made from what names the session — the request's prompt_cache_key (Codex's thread id), else the session the chat.headers hook is told — and the conversation's first user message, so subagents under one session are conversations of their own. With nothing naming the session, each Run has a new one.
  • Text, thinking (reasoning_content) and token usage come back streamed or not. Cursor's input_tokens counts the cached prompt too: the cache read and written is taken out of it, and given as cached_tokens and cache_write_tokens, so it is counted once; its reasoning tokens are reasoning_tokens. A step that calls tools gets no usage in its Run (Cursor tells it only once the tools' results come back in the same Run), so once the Run is closed its usage is read from the dashboard's usage events, by the Run's conversation id: it shows in about 2.5 s, and is looked for up to 6 s. Far from Cursor it shows later than that (yetone/magpie#1053), so the step says 0 used and the conversation owes it: its next steps collect the event in the background and count it with their own, and a step that ends the turn waits for what is still owed, so the conversation adds up to what Cursor counted. An account whose events miss the wait 3 steps in a row stops waiting for them. With nothing naming the session (so no later step to collect it), or an account that can't read its usage events, the step is estimated as before. Failures keep their statuses: 401 to sign in again, 429 at the usage limit, 400 for a prompt too long, 403 for a region refusal.

Models

The config hook declares auto (Cursor's pick). Once signed in, the provider.models hook lists the account's models from Cursor's model picker (AiService/AvailableModels, as the CLI asks for it, cached 10 minutes), the way pi-cursor-sdk lists Cursor's catalog:

  • A model with a context parameter is listed once per size, as <model>@<size> named <name> @ <size> (claude-opus-5-5@300k, "Claude Opus 5.5 @ 300k"), its window that many tokens. A model with none is listed once, its window Cursor's contextTokenLimit (Max Mode's for a model served only in Max Mode); 200K when Cursor gives none.
  • Effort is not a model of its own: the model's efforts are its variants, and the request's reasoning_effort (fitted to the nearest there is) is sent as the model's effort parameter. none turns a Claude's thinking off.
  • Fast is not a model of its own either: a service_tier of priority or fast sends fast=true, anything else fast=false (it costs more, so only when asked).
  • A request goes as the picker's variant those parameters pick, in Max Mode when that variant is Max Mode's (a 1M size, say), as the CLI turns it on. A size with no variant goes in Max Mode when it is over Cursor's limit outside it. A model Cursor still answers "Max Mode Required" for is asked again in Max Mode, and so from then on.
  • Hidden, Tab-only and chat-only models stay out, as in the CLI's picker.
  • The usable list (AgentService/GetUsableModels, what cursor-agent models shows) says which variants the account has: a variant whose own id isn't in it is neither offered nor asked for (Sonnet 4.6 at any effort but medium, say), and a request for one goes as the nearest the account has. A model the usable list has nothing of is the picker's alone (GLM-5.3) and is kept whole; so is every model when Cursor can't give the usable list.
  • An id from before 0.2.0 still runs. A variant's own id (claude-opus-5-5-high) is that variant; a family 0.1.x listed (claude-opus-5-5, claude-opus-5-5-fast, claude-haiku-5-5-thinking, cursor-grok-4.6) is its variant nearest the default, fast for a -fast one; the picker's name for a model or a legacy slug of it is its default. Each is at the default context size, the request's reasoning_effort and service_tier counting as for a listed model. The list doesn't show these ids: pick the @<size> model for a window that is the model's.

Not included

  • Usage and plan limits.
  • Web search: Cursor's own web search is refused like its other tools.
  • Switching between several accounts. OpenCode keeps one sign-in per provider.
  • The Responses and Messages APIs: only chat completions are answered.