TypeScript
fix(cursor): /compact compacts with the SDK's summarize (#29398)
Dara Adedejic8a601c0dfa5
diff --git a/apps/server/package.json b/apps/server/package.jsonindex 5d6c7e8d460..e6a572c8818 100644--- a/apps/server/package.json+++ b/apps/server/package.json@@ -34,7 +34,7 @@},"dependencies": {"@anthropic-ai/claude-agent-sdk": "^0.3.276",- "@cursor/sdk": "1.0.38",+ "@cursor/sdk": "1.2.0","@effect/platform-node": "catalog:","@effect/platform-node-shared": "catalog:","@ff-labs/fff-node": "0.11.0",diff --git a/docs/orchestration-v2/orchestrator-mcp-server.md b/docs/orchestration-v2/orchestrator-mcp-server.mdindex 11e7bd9a8d0..1a23cf0246f 100644--- a/docs/orchestration-v2/orchestrator-mcp-server.md+++ b/docs/orchestration-v2/orchestrator-mcp-server.md@@ -99,8 +99,11 @@ server headers or token.### Cursor Agent SDK V2Cursor receives the same authenticated HTTP MCP endpoint through the SDK's-`mcpServers` agent and send options. The adapter passes the authorization header-to the SDK but projects only redacted option metadata into protocol diagnostics.+`mcpServers` on `Agent.create` / `Agent.resume` and each `send`. With+`@cursor/sdk` 1.0.39+, send-level servers replace only the create-time inline+set; ambient servers from `settingSources` (`project`, `user`, `team`, `mdm`,+`plugins`) stay available. The adapter passes the authorization header to the+SDK but projects only redacted option metadata into protocol diagnostics.### Grok ACP V2diff --git a/docs/user/cursor.md b/docs/user/cursor.mdindex 6a6b1c8f284..4263ceb14fd 100644--- a/docs/user/cursor.md+++ b/docs/user/cursor.md@@ -15,6 +15,17 @@ The adapter currently uses the SDK's local-agent runtime so runs operate in theworkspace. Cursor cloud agents need repository and cloud-environment configuration that T3 Code doesnot expose yet.+Custom Cursor MCP servers and plugins are not configured in T3 Code. They load from the environment+machine's Cursor config when the agent opens: project `.cursor/mcp.json`, user `~/.cursor/mcp.json`,+and installed plugins under `~/.cursor/plugins`. Plugin tools+can appear without a login; OAuth MCP servers still need credentials. Run `agent mcp login <server>`+with the cwd set to the T3 project root (tokens land in+`~/.cursor/projects/<folder-slug>/mcp-auth.json`). Cursor desktop Connections auth does not write+that file, and the local SDK cannot complete interactive MCP OAuth itself—auth attempts fail with+messages such as "MCP authentication is not supported in local SDK runs" or that the auth server+does not support dynamic client registration. After you add or change skills, plugins, or MCP+servers, or after a successful CLI login, use **Restart agent session**.+## Sign inChoose **Sign in**, then open the sign-in page and complete it in your browser. T3 Code@@ -36,7 +47,7 @@ The adapter supports:- creating and resuming local Cursor agent threads;- changing the model and model parameters between turns;- assistant text, reasoning, tool activity, plans, and todo streaming;-- thread-scoped T3 Code MCP tools;+- thread-scoped T3 Code MCP tools alongside ambient Cursor MCP/plugins from disk;- image attachments;- interruption, queued app messages, and orchestrator-owned interrupt/restart steering;- provider conversation snapshots through `Agent.messages.list()`;diff --git a/packages/provider-cursor/package.json b/packages/provider-cursor/package.jsonindex b619c3b61fd..90122cbe57e 100644--- a/packages/provider-cursor/package.json+++ b/packages/provider-cursor/package.json@@ -49,7 +49,7 @@"test": "vp test run --config ../../vite.config.ts --dir ."},"dependencies": {- "@cursor/sdk": "1.0.38",+ "@cursor/sdk": "1.2.0","@napi-rs/keyring": "^1.3.0","@t3tools/contracts": "workspace:*","@t3tools/provider-core": "workspace:*",diff --git a/packages/provider-cursor/src/server/CursorAgentSdk.ts b/packages/provider-cursor/src/server/CursorAgentSdk.tsindex 791121a7140..f48d7baf1b2 100644--- a/packages/provider-cursor/src/server/CursorAgentSdk.ts+++ b/packages/provider-cursor/src/server/CursorAgentSdk.ts@@ -89,6 +89,8 @@ export interface CursorAgentSdkSendInput<Error> {readonly message: string | SDKUserMessage;readonly options?: Omit<SendOptions, "onDelta">;readonly onDelta?: (update: InteractionUpdate) => Effect.Effect<void, Error>;+ /** Runs `agent.summarize()` instead, which takes no message or options. */+ readonly summarize?: boolean;}export interface CursorAgentSdkRun {@@ -139,6 +141,8 @@ export interface CursorAgentSdkLoggedAgentOptions {export interface CursorAgentSdkLoggedSendOptions {readonly model?: SendOptions["model"];readonly mode?: SendOptions["mode"];+ readonly hasMcpServers?: boolean;+ readonly mcpServerNames?: ReadonlyArray<string>;readonly local?: {readonly force?: boolean;readonly hasCustomTools?: boolean;@@ -298,9 +302,12 @@ export function loggedCursorSendOptions(if (options === undefined) {return {};}+ const mcpServerNames =+ options.mcpServers === undefined ? undefined : Object.keys(options.mcpServers).toSorted();return {...(options.model === undefined ? {} : { model: options.model }),...(options.mode === undefined ? {} : { mode: options.mode }),+ ...(mcpServerNames === undefined ? {} : { hasMcpServers: true, mcpServerNames }),...(options.local === undefined? {}: {@@ -466,16 +473,18 @@ export const makeCursorAgentSdkRunner = Effect.fn("makeCursorAgentSdkRunner")(fuconst startRun = () =>Effect.tryPromise({try: () =>- agent.send(sendInput.message, {- ...sendInput.options,- onDelta: async ({ update }) => {- if (!callbacksReady) {- pendingUpdates.push(update);- return;- }- await dispatchUpdate(update);- },- }),+ sendInput.summarize === true+ ? agent.summarize()+ : agent.send(sendInput.message, {+ ...sendInput.options,+ onDelta: async ({ update }) => {+ if (!callbacksReady) {+ pendingUpdates.push(update);+ return;+ }+ await dispatchUpdate(update);+ },+ }),catch: (cause) => runnerError(cause, "run.start"),});const run = yield* startRun().pipe(diff --git a/packages/provider-cursor/src/server/adapter.test.ts b/packages/provider-cursor/src/server/adapter.test.tsindex e03c4e07242..4c421a352a8 100644--- a/packages/provider-cursor/src/server/adapter.test.ts+++ b/packages/provider-cursor/src/server/adapter.test.ts@@ -219,7 +219,7 @@ describe("CursorAdapterV2", () => {Stream.takeUntil((event) => event.type === "turn.terminal"),Stream.runCollect,);- assert.isFalse(sentWithMcpOverride);+ assert.isTrue(sentWithMcpOverride);const rows = events.filter((event) => event.type === "subagent.updated");assert.equal(rows[0]?.subagent.status, "running");assert.equal(rows[0]?.subagent.model, model ?? null);@@ -510,11 +510,11 @@ describe("CursorAdapterV2", () => {),);- it.effect("fails standalone SDK transport diagnostics and sends compaction as /compress", () =>+ it.effect("fails standalone SDK transport diagnostics and compacts with SDK summarize", () =>Effect.gen(function* () {const fileSystem = yield* FileSystem.FileSystem;const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-errors-" });- const sentMessages: Array<string> = [];+ const summarizeRequests: Array<boolean> = [];let sendCalls = 0;const instanceId = ProviderInstanceId.make("cursor");const threadId = ThreadId.make("cursor-transport-error-thread");@@ -538,9 +538,7 @@ describe("CursorAdapterV2", () => {send: (input) =>Effect.sync(() => {sendCalls += 1;- sentMessages.push(- typeof input.message === "string" ? input.message : input.message.text,- );+ summarizeRequests.push(input.summarize === true);const runId = `native-cursor-run-${sendCalls}`;return {agentId: "native-cursor-error",@@ -551,9 +549,10 @@ describe("CursorAdapterV2", () => {status: "finished" as const,model: { id: "composer-2.5" },durationMs: 1,- ...(sendCalls === 1- ? { result: "Error: RetriableError: WritableIterable is closed" }- : {}),+ result:+ sendCalls === 1+ ? "Error: RetriableError: WritableIterable is closed"+ : "Summary of the conversation so far",}),cancel: Effect.void,};@@ -646,11 +645,12 @@ describe("CursorAdapterV2", () => {attachments: [],},});- yield* runtime.events.pipe(- Stream.filter((event) => event.type === "turn.terminal"),- Stream.runHead,+ const compactionEvents = yield* runtime.events.pipe(+ Stream.takeUntil((event) => event.type === "turn.terminal"),+ Stream.runCollect,);- assert.equal(sentMessages[1], "/compress");+ assert.deepEqual(summarizeRequests, [false, true]);+ assert.notInclude(JSON.stringify(compactionEvents), "Summary of the conversation so far");}).pipe(Effect.scoped,Effect.provide(diff --git a/packages/provider-cursor/src/server/adapter.ts b/packages/provider-cursor/src/server/adapter.tsindex 924139ec34d..73f7ac9d976 100644--- a/packages/provider-cursor/src/server/adapter.ts+++ b/packages/provider-cursor/src/server/adapter.ts@@ -2385,15 +2385,18 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (hasDeviceTools,delivered,);+ const compacted = message === "/compress";const pendingUpdates: Array<InteractionUpdate> = [];let context: ActiveCursorTurn | null = null;- // MCP send overrides replace the ambient servers loaded when the agent opens.+ // Create-time and send-time mcpServers merge with settingSources (SDK >= 1.0.39).const sdkRun = yield* agent.session.send({message,+ summarize: compacted,options: {model: cursorSdkModelSelection(turnInput.modelSelection),mode: turnInput.runtimePolicy.interactionMode === "plan" ? "plan" : "agent",+ ...(mcpServers === undefined ? {} : { mcpServers }),},onDelta: (update) => {if (context === null) {@@ -2405,7 +2408,6 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (},}).pipe(Effect.mapError(classifyCursorModelRejection(turnInput.modelSelection)));- const compacted = message === "/compress";yield* Ref.set(told, {agent: agent.nativeThreadId,orchestration: !compacted && (delivered.orchestration || mcpServers !== undefined),@@ -2469,6 +2471,8 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (if (context !== null &&context.assistant.nextSegment === 0 &&+ // A summarize run's result is the summary, not an answer.+ !compacted &&// Text from a resume that made no progress is not the turn's answer.!isResumeFailureAfterTurnEnded(context, result) &&result.result !== undefined &&diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex fa3d8233954..ccc69351000 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -833,8 +833,8 @@ importers:specifier: ^0.3.276version: 0.3.276(@anthropic-ai/[email protected]([email protected]))(@modelcontextprotocol/[email protected]([email protected])([email protected]))([email protected])'@cursor/sdk':- specifier: 1.0.38- version: 1.0.38([email protected])+ specifier: 1.2.0+ version: 1.2.0([email protected])'@effect/platform-node':specifier: 4.0.5@@ -1701,8 +1701,8 @@ importers:packages/provider-cursor:dependencies:'@cursor/sdk':- specifier: 1.0.38- version: 1.0.38([email protected])+ specifier: 1.2.0+ version: 1.2.0([email protected])'@napi-rs/keyring':specifier: ^1.3.0version: 1.3.0@@ -3511,38 +3511,38 @@ packages:resolution: {integrity: sha512-bPlN9S9O1A0euCpEWE4qnvB5YDuyYVsUTrxSgmAM1Is0j4tICHoVyOVAXfWMP/kS9ZrjvyIXWV2PmomiAXXqOw==}engines: {node: '>=20.19.0'}- '@cursor/[email protected]':- resolution: {integrity: sha512-pXxj4pjbIoDo6ZjgksSf4VTD4EJz6BGDKvFjDVVUMg0PmLCVbceOnp0pqfRO8SVpdUSE45GFrXuLnSZgLag/xw==}+ '@cursor/[email protected]':+ resolution: {integrity: sha512-UkZ/RdxKCpOQ85nRgzSq+g0h+gIw36/lCEvQvomhs5EkSFZW3OwbeEzkAU3UYglZ7t3RNHj3mc5C5cdDtHguvw==}cpu: [arm64]os: [darwin]hasBin: true- '@cursor/[email protected]':- resolution: {integrity: sha512-rutfTMq1f9WZckPFH8R5bzNzHaZg7I/TijVUkfD3GbqIqqc5OKHzdTMqZf+AFAqRDQccGJn4GLWcnQ9wTwIVNA==}+ '@cursor/[email protected]':+ resolution: {integrity: sha512-mJTFdX+qv9dHAm59tT7uq7ci7+BDvFoNk4gdF2zGp9SLULicY+FdFD64p1qLen1bX5Y2soZaX5mWBy7BfObjcg==}cpu: [x64]os: [darwin]hasBin: true- '@cursor/[email protected]':- resolution: {integrity: sha512-CqmUnM8W8W2mKucSrdHO0kn4ems82siWuo7kvVJvXCtPkaziVNC++dro5h9hSh2oVgRbB91sWQ4lzsHVIDpkvA==}+ '@cursor/[email protected]':+ resolution: {integrity: sha512-Rs+cd5snuhxMAHkpqRfEGPB1qAsfqSOYJh5SOHZTOWy2LkRVO62WHwd4x80C2emj+dosTV5WAcuF2kMKKcrDJg==}cpu: [arm64]os: [linux]hasBin: true- '@cursor/[email protected]':- resolution: {integrity: sha512-RL6OJTAF3oozMG+HNtykySQ5BOP94yJNWP65wZ2yzMLTAW9ao80++OnaWJya1lndLacHLYP+QZT4igm5TT+BWQ==}+ '@cursor/[email protected]':+ resolution: {integrity: sha512-ainsGAFtkWTBZrLABp82Hvfv7VB/FxmZHE42qMVotFTRDwOY2iduvhSig910bVxv+kw3S00Srmu/9CxklLwhbw==}cpu: [x64]os: [linux]hasBin: true- '@cursor/[email protected]':- resolution: {integrity: sha512-IUfuCk/S/qzEB+tfT4yWH6iSMz56Lvakn1zNjdk+oAsZ7RJWtWkZcea6eqMSRB1WLmTeQG0uetXKX330w+xI0A==}+ '@cursor/[email protected]':+ resolution: {integrity: sha512-p3rkyta6R/nXIukd3/ifJq32otkkGoUi41T2jxnHbPHMhzE2F8OuJQGBVmORuQLMr+bIGGVZmCxertgs4WgzcQ==}cpu: [x64]os: [win32]hasBin: true- '@cursor/[email protected]':- resolution: {integrity: sha512-8UwPKaprIXvlVR71yHyNNTyFwZCOzfHW7W+FKjPdDS9Ym9FDZc51Jwsu9lAhxHf7n0US3t0pybkDaNFdldrQ+A==}+ '@cursor/[email protected]':+ resolution: {integrity: sha512-Nqm2U0zTWrYEDCv3Rdwsfa1gYZWsg+JnY+I2F8BwWSAr3FNo0TZWwyHWoWngZgriF1w02fJ4gjJWaul9zysvgQ==}engines: {node: '>=22.13'}peerDependencies:zod: ^3.25.0 || ^4.0.0@@ -13501,22 +13501,22 @@ snapshots:'@csstools/[email protected]': {}- '@cursor/[email protected]':+ '@cursor/[email protected]':optional: true- '@cursor/[email protected]':+ '@cursor/[email protected]':optional: true- '@cursor/[email protected]':+ '@cursor/[email protected]':optional: true- '@cursor/[email protected]':+ '@cursor/[email protected]':optional: true- '@cursor/[email protected]':+ '@cursor/[email protected]':optional: true- '@cursor/[email protected]([email protected])':+ '@cursor/[email protected]([email protected])':dependencies:'@bufbuild/protobuf': 1.10.0'@connectrpc/connect': 1.7.0(@bufbuild/[email protected])@@ -13524,11 +13524,11 @@ snapshots:'@statsig/js-client': 3.31.0zod: 4.6.5optionalDependencies:- '@cursor/sdk-darwin-arm64': 1.0.38- '@cursor/sdk-darwin-x64': 1.0.38- '@cursor/sdk-linux-arm64': 1.0.38- '@cursor/sdk-linux-x64': 1.0.38- '@cursor/sdk-win32-x64': 1.0.38+ '@cursor/sdk-darwin-arm64': 1.2.0+ '@cursor/sdk-darwin-x64': 1.2.0+ '@cursor/sdk-linux-arm64': 1.2.0+ '@cursor/sdk-linux-x64': 1.2.0+ '@cursor/sdk-win32-x64': 1.2.0'@date-fns/[email protected]': {}diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex be4d3c29ea7..e2865566986 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -227,6 +227,12 @@ minimumReleaseAgeExclude:- "@pierre/[email protected]"- "@pierre/[email protected]"+ - "@cursor/[email protected]"+ - "@cursor/[email protected]"+ - "@cursor/[email protected]"+ - "@cursor/[email protected]"+ - "@cursor/[email protected]"+ - "@cursor/[email protected]"overrides:# Pin every patched package, including transitive dependencies, so lockfile-free