Skip to content

feat(cursor)!: run cursor through the official @cursor/sdk - #96

Merged
xxchan merged 2 commits into
mainfrom
feat/cursor-sdk
Oct 3, 2026
Merged

xxchan merged 2 commits into
mainfrom
feat/cursor-sdk

Conversation

@xxchan

@xxchan xxchan commented Oct 3, 2026

Copy link
Copy Markdown
Member

cursor now runs through Cursor's official SDK, @cursor/sdk 1.0.35, inside the host process (the way pi runs). The cursor-agent ACP path is removed, along with the shared ACP code that only it used. Owner decision: in Raft #new-runtimes ("switch directly"), with downstream switching at the same time and no compatibility with the old adapter.

What changes

  • Session: one local SDK agent (agent-<uuid>); resume is Agent.resume in the same cwd. Resume without a model reopens the model of the agent's latest run (the SDK does not restore it, and refuses a send without one).
  • Turn: one send, ended by run.wait()'s status (finished, cancelled, error). Every onDelta update is one frame (text-delta, thinking-delta, tool-call-started/completed, user-message-appended, turn-ended with usage, bookkeeping kinds with no events).
  • Steer: run.steer. It is accepted once cursor took the text. If cursor hands it back, or the run ends first, it is rejected and the caller keeps the input. The echo is a user_message (evidence conversation, no input id).
  • Queue and abort: queue is adapter held and sent as the next run; abort is run.cancel, including an abort that lands before send returned the run.
  • Usage: per run, with cache reads and writes counted as input.
  • Subagents: tool-call-delta {callId, taskUpdate} is the child's update, recorded with agentPath = [taskCallId], one level per nested task (tier attributed).
  • Models and effort: models come from Cursor.models.list(). Effort is the model's own reasoning parameter (effort, reasoning, reasoning_effort, else the thinking switch). It is checked against that menu, because the SDK passes unknown values through unchecked.
  • Refused at open: systemPrompt and appendSystemPrompt (a local agent's run fails with unknown option '--system-prompt'), and env (no per-agent environment; so cursor cannot be a crew child yet).
  • Sandbox: the SDK sandbox is off, as for every OAR session.
  • Native companion: OAR points the SDK at @cursor/sdk-<platform>-<arch>. The SDK looks for that package by walking up from the host's entry script, which fails under pnpm and in bundles, and it then warns that tree-sitter is unavailable.
  • Installation: bundled and versionless; there is no check or upgrade.
  • Other changes: classifyTool learns cursor's tool names. The auth classifier reads Invalid User API Key. runtime-versions.ts reads the SDK's npm version.
  • Removed from shared ACP: extensionRequests, vendorSessionUpdates and vendor-updates.ts, clientCapabilitiesMeta, the switch versus menu effort rule, and the effort re-read after a model switch. Grok, kimi and antigravity are unchanged.

Breaking

  • Cursor sessions opened through cursor-agent (bare UUIDs) cannot be resumed.
  • Cursor signs in with CURSOR_API_KEY or Cursor.auth.login(), not the CLI login.
  • Cursor has no checkUpdate or upgrade.
  • The install is about 38 MB larger: the SDK, which is proprietary and under Cursor's terms, plus its native package.

Evidence

  • experiments/live-contract.ts cursor (gpt-5.4-nano, linux x64): basic, multi-turn, tool-detail, busy-and-late-control, steer, queue, abort, dispose-mid-turn, cursor, resume, subagent and bad-model pass; kill-runtime does not apply (in process).
  • Direct SDK probes for effort read back, unknown values, aliases, images, failed shell, read and edit results, busy send, missing credential, and resume without a model are recorded in docs/runtimes/cursor.md.
  • Unit tests: tests/cursor/ (a stand-in SDK for the session, plus recorded updates for the projection and models).
  • pnpm run typecheck, pnpm run lint and npx vitest run pass (546 passed).

🤖 Generated with Claude Code

The cursor runtime now embeds Cursor's own SDK (`@cursor/sdk` 1.0.35, a
dependency of this package) and runs the agent in the host process, the way
pi does; the cursor-agent ACP path is gone.

- A session is one local SDK agent (`agent-<uuid>`); a turn is one run,
  from `send` to `run.wait()`'s status. Every onDelta update is one frame.
- Steer is `run.steer`, accepted once cursor took the text; a hand back or a
  run that ends first leaves the input with the caller. The echo is a
  `user_message` event.
- Abort is `run.cancel`; queue is held here and sent as the next run.
- Per-run token usage (cache reads and writes counted as input).
- A subagent's updates arrive inside its `task` call and carry
  `agentPath = [taskCallId]` (tier `attributed`).
- Models from `Cursor.models.list()`; effort is the model's own reasoning
  parameter, checked against its menu because the SDK passes unknown values
  through. Resume without a model reopens the latest run's model.
- systemPrompt and SessionOptions.env are refused: the SDK breaks the first
  and has no channel for the second.
- OAR points the SDK at its native companion package, which it cannot find
  under pnpm or in a bundle.
- Shared ACP code that only served cursor-agent (vendor requests, carried
  session updates, client capability meta, the switch versus menu effort
  rule) is removed.

Live contract on a real login: 12 of 12 applicable scenarios pass.

BREAKING CHANGE: cursor sessions opened through cursor-agent cannot be
resumed, cursor needs `CURSOR_API_KEY` or `Cursor.auth.login()`, and cursor
has no update check or upgrade.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of #96, verified live where it touches the SDK:

- A resumed agent whose store still holds an unfinished run (a process that
  died mid run, a session closed before its first prompt) refused every
  send with "already has active run". The first send after a resume now
  passes the SDK's `local.force`; probed both cases, both answer.
- `send` has a 60 second deadline, and dispose gives up a send still on its
  way; a run the SDK returns after either is cancelled and its end recorded.
- Each send is its own launch object, so a run that ends at once can no
  longer let one start clear another's pending send or held abort.
- An effort keeps the model's other parameters from the catalog's default
  variant (a `thinking` switch stays on beside an `effort` level; probed on
  claude-opus-5).
- A shell exit with a signal is `exitCode: null`; a shell that printed
  nothing reports one empty text part.
- The SDK is pinned exactly: its behavior here is pinned by probes.
- Docs: resume takeover, send deadline, nesting the SDK schema forbids,
  run usage on the root, cursor in the exit code, effort, evidence and steer
  delivery tables, crew children need `env` (cursor cannot be one).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit a9483b6 into main Oct 3, 2026
12 checks passed
@xxchan
xxchan deleted the feat/cursor-sdk branch October 3, 2026 10:53
@xxchan xxchan mentioned this pull request Oct 3, 2026
xxchan added a commit that referenced this pull request Oct 3, 2026
Minor release, version bump only.

- #96: cursor runs through the official `@cursor/sdk` 1.0.35 in process.
Breaking for cursor: sessions opened through cursor-agent cannot be
resumed, cursor signs in with `CURSOR_API_KEY` or `Cursor.auth.login()`,
and cursor has no update check or upgrade. `SessionOptions.systemPrompt`
and `env` are refused for cursor.
- #95: `classifyTool` reads codex `sleep` as the new `wait` kind with
its `durationMs`; hosts that switch exhaustively on `ToolActionKind`
need a `wait` case.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant