@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
Tool catalog capture (ai.prompt.tools)
Override only. The Cursor SDK streams messages, never the request it sends to the model, so this integration cannot observe the tool catalog and records nothing by default. tools on createRaindropCursorAgentSDK(...) is the default for every wrap() call and wrap(..., { tools }) replaces it entirely; the override is recorded verbatim on the cursor.agent.run span (the span carrying the prompt and ai.model.id), never on tool_call / thinking spans. tools: [] records an explicitly empty catalog. See Tool catalog capture for the attribute format, the absent / [] semantics and the override shapes accepted.
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.
Application Git identity
SetappGit on createRaindropCursorAgentSDK to provide commitSha, commitDirty, and optional
branch, or pass false to opt out. Cursor may operate against a remote workspace, so local
discovery requires a sourceDirectory that explicitly identifies the AUT and never defaults to the
observer or edited checkout. See the TypeScript Git reference.