Respan instrumentation plugin for Cursor SDK hook events
Project description
Respan Cursor SDK instrumentation
Trace Cursor hook events through the Respan OpenTelemetry runtime.
Cursor sends structured JSON to configured hook commands. This package converts those hook events into canonical Respan spans and injects them into the active respan-tracing pipeline.
Install
pip install respan-ai respan-instrumentation-cursor-sdk
Cursor hook command
Set Respan configuration in the environment used by Cursor:
export RESPAN_API_KEY="..."
export RESPAN_BASE_URL="https://api.respan.ai/api"
Then configure Cursor hooks to call the packaged runner:
{
"version": 1,
"hooks": {
"beforeSubmitPrompt": [{ "command": "respan-cursor-hook" }],
"afterAgentThought": [{ "command": "respan-cursor-hook" }],
"afterShellExecution": [{ "command": "respan-cursor-hook" }],
"afterFileEdit": [{ "command": "respan-cursor-hook" }],
"afterMCPExecution": [{ "command": "respan-cursor-hook" }],
"afterAgentResponse": [{ "command": "respan-cursor-hook" }],
"stop": [{ "command": "respan-cursor-hook" }]
}
}
The runner reads one Cursor hook JSON payload from stdin, stores prompt state between hook calls, emits child spans as they happen, and emits the root agent span when afterAgentResponse arrives.
Programmatic usage
from respan import Respan
from respan_instrumentation_cursor_sdk import CursorSDKInstrumentor
respan = Respan(
instrumentations=[CursorSDKInstrumentor()],
app_name="cursor-sdk",
)
processor = CursorSDKInstrumentor.create_processor()
processor.process_event(
{
"hook_event_name": "afterAgentThought",
"conversation_id": "conv_123",
"generation_id": "gen_456",
"text": "I need to inspect the repository.",
"duration_ms": 320,
}
)
respan.telemetry.flush()
Supported Cursor events
beforeSubmitPromptafterAgentThoughtafterShellExecutionafterFileEditafterMCPExecutionafterAgentResponsestop
Cursor-specific raw field names stay inside this package. The emitted spans use canonical Respan attributes for log type, entity input/output, workflow name, thread identifier, trace group, and metadata.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file respan_instrumentation_cursor_sdk-0.1.0.tar.gz.
File metadata
- Download URL: respan_instrumentation_cursor_sdk-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f6cca647c59d3783e950f9fb3511b207bfcf00ccf4ba90ea848b3841b504848
|
|
| MD5 |
79819bd83045530572fd855071b0c562
|
|
| BLAKE2b-256 |
3562d6390e836f8e7fdbadfbf4d15bc1d4ce15b21bf78d73823118d805faee1a
|
File details
Details for the file respan_instrumentation_cursor_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: respan_instrumentation_cursor_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c619590c9f53299eee73f6c54a6a5da2a081037e1448dee2f89dfab1602f3b2
|
|
| MD5 |
1cb00fb380470a644138f7ea535432a0
|
|
| BLAKE2b-256 |
77c9a0b278e313edc69ecbd0233ace63320ca0ffacb26330427ac6dc97fb431e
|