cursor: Cursor — cursor-agent's browser sign-in (PKCE poll), its existing sign-in or an API key; agent.v1 Run over HTTP/2 as magpie's gateway does it, with tool calls; tried with real requests. README lists every package so far

This commit is contained in:
yetone
2026-09-30 17:17:06 +08:00
parent e08a374886
commit d7385c87c4
4 changed files with 1505 additions and 2 deletions
+7 -2
View File
@@ -8,12 +8,17 @@ subscription and makes its requests. The packages work in OpenCode and in
| Package | Signs in to | Provider id |
|---|---|---|
| [commandcode](packages/commandcode) | Command Code plans (Pro, GOAT, Max, Ultra, Go, Teams Pro) | `commandcode-plan` |
| [cursor](packages/cursor) | Cursor subscriptions (Pro, Pro+, Ultra, Teams), on the API cursor-agent talks to | `cursor` |
| [devin](packages/devin) | Devin subscription (the devin CLI's account) | `devin` |
| [factory](packages/factory) | Factory (Droid) subscription | `factory` |
| [grok](packages/grok) | Grok (SuperGrok / X Premium+), through the Grok Build CLI's sign-in | `grok` |
| [kiro](packages/kiro) | Kiro (Free, Pro, Pro+, Power), with Kiro's sign-in, kiro-cli's or the IDE's, or an API key | `kiro` |
| [mimo](packages/mimo) | Xiaomi MiMo, with a Xiaomi account | `mimo-app` |
| [qoder](packages/qoder) | Qoder subscription, with Qoder's device sign-in | `qoder` |
| [workbuddy](packages/workbuddy) | WorkBuddy (China build, CodeBuddy plan) | `workbuddy` |
| [workbuddy](packages/workbuddy) | WorkBuddy (international build) | `workbuddy-ai` |
| [zcode](packages/zcode) | ZCode: Z.ai / BigModel (智谱) GLM Coding Plan, team seats, Start Plan | `zcode` |
| [zed](packages/zed) | Zed (Pro, Pro Trial, Student, Business): Anthropic, OpenAI, Google and xAI models hosted by Zed | `zed` |
## Use
@@ -24,8 +29,8 @@ magpie plugin add @magpie-community/opencode-<name>-auth
magpie plugin login <provider id>
```
The same actions are in the app: Settings → Plugins, then Add provider →
From plugins.
In the app, the Plugins tab lists these packages: install one there, then
sign in.
OpenCode, in `opencode.json`:
+70
View File
@@ -0,0 +1,70 @@
# @magpie-community/opencode-cursor-auth
Signs in to a [Cursor](https://cursor.com) 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.
- Text, thinking (`reasoning_content`) and token usage come back streamed
or not. 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
(`AgentService/GetUsableModels`, cached 10 minutes), by the ids
`cursor-agent models` shows:
- Cursor lists a model once per effort (`gpt-5.6-low`, `gpt-5.6-high`, …).
Each family is one model here, with the efforts as variants; the
request's `reasoning_effort` picks the id, fitted to the nearest one there
is. `-fast` and `-thinking` models stay models of their own; a
`service_tier` of `priority` picks the fast one.
- The context window is 1M for a model whose name says 1M, else 200K.
## 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.
File diff suppressed because it is too large Load Diff
+11
View File
@@ -0,0 +1,11 @@
{
"name": "@magpie-community/opencode-cursor-auth",
"version": "0.1.0",
"description": "Cursor subscriptions (Pro, Pro+, Ultra, Teams) in OpenCode and magpie, through the API cursor-agent talks to",
"type": "module",
"main": "./index.mjs",
"exports": "./index.mjs",
"files": ["index.mjs", "README.md"],
"keywords": ["opencode", "opencode-plugin", "magpie", "cursor"],
"license": "MIT"
}