@raindrop-ai/cursor-agent-sdk package automatically instruments the
Cursor Agent SDK to capture events and traces from agent runs.
It wraps the SDK’s Agent.prompt, Agent.create, Agent.resume, and
SDKAgent.send APIs while preserving Cursor’s return values, streams, and
errors.
Features:
- No OpenTelemetry setup required
- Automatic event and trace capture for agent runs
- Thinking and tool-call child spans
- Token usage, model, output, status, and error capture
- Support for
Run.stream(),Run.wait(), andRun.conversation() - Per-context identity and routing metadata
Installation
Quick Start
Agent.create() and Agent.resume() return wrapped agents whose send()
method returns a wrapped run. Consume that run with stream(), wait(), or
conversation(). Each run is finalized once, regardless of which lifecycle
method is used.
Configuration
writeKey is absent, the wrapper remains usable and does not send
telemetry.
Per-Run Context
Cursor’s method signatures do not provide a trailing metadata argument. Supply identity and routing metadata through the wrapper context instead:Events and Traces
Events are enabled by default in the wrapper configuration, and traces include the run span plus thinking and tool-call child spans. The client also exposes the event lifecycle methods for partial events:flush() to drain queued event and trace delivery, and shutdown() to
close the client when the process exits.
Identifying Users
Signals
Flush and Shutdown
Callflush() before a short-lived process exits. Call shutdown() when the
client will no longer be used:
Limitations
- Concurrent runs should use separate wrapped contexts when each run needs distinct identity metadata.
- The Cursor SDK requires Node.js
>=22.13. - Cloud responses may omit usage, model, or message content; those fields are omitted gracefully.