Add Cursor SDK orchestration replay support
- Wire Cursor adapter and provider session handling into orchestration v2 - Add replay fixtures, recording script, and coverage for Cursor turn flows - Update docs and debug timeline mapping for Cursor events
This commit is contained in:
1 parent
4fae73ee08
commit
ce64e37094
50 files changed
+7163
-201
No files matched your search
@@ -42,3 +42,13 @@ policy in [CONTRIBUTING.md](../CONTRIBUTING.md); agent rules in [AGENTS.md](../A
|
||||
- [Observability](./operations/observability.md)
|
||||
- [Relay observability](./operations/relay-observability.md)
|
||||
- [Mobile app store screenshots](./operations/mobile-app-store-screenshots.md)
|
||||
- [Getting started](./getting-started/quick-start.md)
|
||||
- [Architecture](./architecture/overview.md)
|
||||
- [T3 Connect](./cloud/t3-connect-clerk.md)
|
||||
- [Integrations](./integrations/source-control-providers.md)
|
||||
- [Mobile](./mobile/app.md)
|
||||
- [Operations](./operations/ci.md)
|
||||
- Providers: [Codex](./providers/codex.md), [Claude](./providers/claude.md),
|
||||
[Cursor](./providers/cursor.md)
|
||||
- [Reference](./reference/encyclopedia.md)
|
||||
- [User guides](./user/keybindings.md)
|
||||
@@ -84,10 +84,16 @@ Claude receives an HTTP MCP server in its query options:
|
||||
The adapter logs only whether MCP configuration exists; it does not log the
|
||||
server headers or token.
|
||||
|
||||
### Cursor Agent SDK V2
|
||||
|
||||
Cursor 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.
|
||||
|
||||
### Initial Provider Support
|
||||
|
||||
The initial V2 provider adapters are Codex and Claude Agent SDK. Capability
|
||||
discovery still reports other registered provider instances, but marks them
|
||||
The V2 provider adapters are Codex, Claude Agent SDK, and Cursor Agent SDK.
|
||||
Capability discovery still reports other registered provider instances, but marks them
|
||||
unavailable for orchestration when no V2 adapter exists. This keeps provider
|
||||
selection model-visible without allowing a request that cannot run.
|
||||
|
||||
@@ -293,6 +299,6 @@ Coverage includes:
|
||||
- inheritance and per-thread provider overrides; and
|
||||
- idempotent retries.
|
||||
|
||||
Provider adapter tests separately verify Codex and Claude MCP injection, and
|
||||
Provider adapter tests separately verify Codex, Claude, and Cursor MCP injection, and
|
||||
the provider-session manager test verifies that credentials exist before an
|
||||
adapter opens and are revoked when it closes.
|
||||
@@ -118,6 +118,10 @@ Codex replay transcript
|
||||
Claude replay transcript
|
||||
-> Claude Agent SDK query() outbound options and yielded SDKMessage chunks
|
||||
-> consumed by ClaudeAdapter
|
||||
|
||||
Cursor replay transcript
|
||||
-> Cursor Agent SDK open/send calls and ordered onDelta/run results
|
||||
-> consumed by CursorAdapter
|
||||
```
|
||||
|
||||
Fixtures should preserve raw provider evidence as closely as possible. Expected V2 events or projections are assertions, not fixture input.
|
||||
@@ -129,7 +133,8 @@ SDK output; it does not test the SDK's own subprocess or transport parser.
|
||||
|
||||
Provider transcript recorders live with the server orchestration testkit, not with provider client
|
||||
packages. Use `bun run record:codex-replay -- --scenario <name>` for Codex app-server transcripts
|
||||
and `bun run record:claude-replay -- --scenario <name>` for Claude Agent SDK transcripts.
|
||||
and `bun run record:claude-replay -- --scenario <name>` for Claude Agent SDK transcripts. Use
|
||||
`pnpm --filter t3 record:cursor-replay -- --scenario <name>` for Cursor Agent SDK transcripts.
|
||||
|
||||
## Contract Test Levels
|
||||
|
||||
@@ -201,7 +206,7 @@ Testing infrastructure should be built before production rewrites:
|
||||
2. Effect service definitions.
|
||||
3. provider runtime transport abstraction.
|
||||
4. generic replay runtime.
|
||||
5. Codex and Claude transcript loaders for app-owned provider replay fixtures.
|
||||
5. Codex, Claude, and Cursor transcript loaders for app-owned provider replay fixtures.
|
||||
6. projection reducer tests for core invariants.
|
||||
7. full command-to-projection integration tests.
|
||||
8. production layers.
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# Cursor
|
||||
|
||||
Cursor V2 runs through the official [`@cursor/sdk`](https://cursor.com/docs/api/sdk/typescript)
|
||||
TypeScript package. It does not use Cursor's ACP transport for V2 execution.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Node.js 22.13 or newer. The repository's supported Node version satisfies this requirement.
|
||||
- A Cursor API key in `CURSOR_API_KEY`. Provider-instance environment variables override the host
|
||||
environment in the same way as the other providers.
|
||||
- A model accepted by the Cursor SDK. `auto` is sent to the SDK as its `default` model selection.
|
||||
|
||||
The adapter currently uses the SDK's local-agent runtime so runs operate in the selected T3 Code
|
||||
workspace. Cursor cloud agents need repository and cloud-environment configuration that T3 Code does
|
||||
not expose yet.
|
||||
|
||||
## V2 Capability Mapping
|
||||
|
||||
The adapter supports:
|
||||
|
||||
- creating and resuming local Cursor agent threads;
|
||||
- changing the model and model parameters between turns;
|
||||
- assistant text, reasoning, tool output, plans, and todo streaming;
|
||||
- thread-scoped T3 Code MCP tools;
|
||||
- image attachments;
|
||||
- interruption, queued app messages, and orchestrator-owned interrupt/restart steering;
|
||||
- provider conversation snapshots through `Agent.messages.list()`;
|
||||
- Cursor `task` subagents, projected as read-only child app threads with their tool activity and
|
||||
final result.
|
||||
|
||||
The public SDK does not currently expose native agent fork, conversation rollback, active steering,
|
||||
or interactive approval callbacks. Direct active steering is advertised as unsupported, while V2
|
||||
steering uses the orchestrator's interrupt-and-restart path and preserves the app run identity across
|
||||
provider turns. Same-provider Cursor forks use the orchestrator's portable full-thread context
|
||||
handoff into a fresh Cursor agent. The SDK has in-process custom callback tools, but the V2 adapter
|
||||
intentionally uses the authenticated, thread-scoped MCP server instead.
|
||||
|
||||
Cursor task events include an `agentId`, but the local SDK does not register that identifier as a
|
||||
resumable agent: `Agent.resume()` returns `AgentNotFoundError`. The adapter therefore does not attach
|
||||
a provider thread to native task projections or advertise subagent thread IDs. Sending a new message
|
||||
from a projected child starts a new Cursor agent rather than pretending to resume the task runtime.
|
||||
|
||||
Runtime modes map to the controls the local SDK exposes: full access disables its sandbox, while
|
||||
restricted modes and explicit non-full-access sandbox policies enable it. Explicit approval policy
|
||||
overrides also control Cursor Auto-review. Auto-review is not represented as an interactive T3 Code
|
||||
approval flow.
|
||||
|
||||
The existing Cursor binary path and API endpoint settings belong to the CLI/ACP integration. Cursor
|
||||
V2 execution does not launch that binary, and the SDK does not expose an API endpoint override.
|
||||
|
||||
## Replay And Live Testing
|
||||
|
||||
Cursor replay fixtures preserve the SDK boundary: agent open/resume, sends, ordered `onDelta`
|
||||
updates, terminal results, cancellation, message snapshots, and close. The real V2 adapter,
|
||||
orchestrator, event store, projections, and checkpoint logic still run in tests.
|
||||
|
||||
Record a fixture against the real SDK with:
|
||||
|
||||
```bash
|
||||
pnpm --filter t3 record:cursor-replay -- --scenario simple
|
||||
```
|
||||
|
||||
Use `--out <path>` to record a temporary probe without replacing a checked-in fixture. Supported
|
||||
scenarios are listed by the recorder when an invalid scenario is supplied.
|
||||
Reference in new issue
Block a user