Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/short-moles-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"braintrust": minor
---

feat: Add @cursor/sdk instrumentation
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ BRAINTRUST_API_KEY=
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GEMINI_API_KEY=
CURSOR_API_KEY=
OPENROUTER_API_KEY=
MISTRAL_API_KEY=
HUGGINGFACE_API_KEY=
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
BRAINTRUST_E2E_PROJECT_NAME: ${{ vars.BRAINTRUST_E2E_PROJECT_NAME }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }}
Expand Down Expand Up @@ -58,6 +59,7 @@ jobs:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
Expand Down Expand Up @@ -110,6 +112,7 @@ jobs:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
Expand Down
1 change: 1 addition & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Non-hermetic scenarios require provider credentials in addition to the mock Brai
- `OPENAI_API_KEY`
- `ANTHROPIC_API_KEY`
- `GEMINI_API_KEY` or `GOOGLE_API_KEY`
- `CURSOR_API_KEY`
- `OPENROUTER_API_KEY`
- `MISTRAL_API_KEY`
- `HUGGINGFACE_API_KEY`
Expand Down
6 changes: 6 additions & 0 deletions e2e/config/pr-comment-scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,11 @@
"label": "v0.2.81"
}
]
},
{
"scenarioDirName": "cursor-sdk-instrumentation",
"label": "Cursor SDK Instrumentation",
"metadataScenario": "cursor-sdk-instrumentation",
"variants": [{ "variantKey": "cursor-sdk-v1", "label": "v1" }]
}
]
37 changes: 5 additions & 32 deletions e2e/helpers/scenario-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const INSTALL_SECRET_ENV_VARS = [
"ANTHROPIC_API_KEY",
"BRAINTRUST_API_KEY",
"COHERE_API_KEY",
"CURSOR_API_KEY",
"GEMINI_API_KEY",
"GITHUB_TOKEN",
"GH_TOKEN",
Expand All @@ -37,10 +38,9 @@ let cleanupRegistered = false;

type CanaryDependencyRule = {
packageName: string;
query: string;
version: string;
};

const canaryVersionCache = new Map<string, string>();
const HELPERS_DIR = path.dirname(fileURLToPath(import.meta.url));
const E2E_ROOT = path.resolve(HELPERS_DIR, "..");

Expand Down Expand Up @@ -155,32 +155,6 @@ function packageSpecifier(
: `npm:${packageName}@${version}`;
}

async function resolveCanaryVersion(
rule: CanaryDependencyRule,
): Promise<string> {
const cacheKey = rule.query;
const cached = canaryVersionCache.get(cacheKey);
if (cached) {
return cached;
}

const output = await spawnOrThrow(
PNPM_COMMAND,
["view", rule.query, "version", "--json"],
process.cwd(),
installEnv(),
);
const parsed = JSON.parse(output) as string | string[];
const version = Array.isArray(parsed) ? parsed.at(-1) : parsed;

if (typeof version !== "string") {
throw new Error(`Could not resolve canary version for ${rule.query}`);
}

canaryVersionCache.set(cacheKey, version);
return version;
}

function parseCanaryDependencyRule(
dependencyName: string,
rawRule: string,
Expand All @@ -195,7 +169,7 @@ function parseCanaryDependencyRule(
if (rawRule === "latest") {
return {
packageName: dependencyName,
query: dependencyName,
version: "latest",
};
}

Expand All @@ -208,7 +182,7 @@ function parseCanaryDependencyRule(

return {
packageName: rawRule.slice(0, versionSeparator),
query: rawRule,
version: rawRule.slice(versionSeparator + 1),
};
}

Expand All @@ -230,11 +204,10 @@ async function rewriteManifestForCanary(scenarioDir: string): Promise<void> {
rawRule,
scenarioDir,
);
const version = await resolveCanaryVersion(rule);
dependencies[dependencyName] = packageSpecifier(
dependencyName,
rule.packageName,
version,
rule.version,
);
updated = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
{
"conversation": {
"operation": {
"has_input": false,
"has_output": false,
"metadata": {
"operation": "resume-conversation"
},
"metric_keys": [],
"name": "cursor-sdk-resume-conversation-operation",
"root_span_id": "<span:1>",
"span_id": "<span:2>",
"span_parents": [
"<span:1>"
],
"type": null
},
"task": {
"has_input": true,
"has_output": true,
"metadata": {
"cursor_sdk.agent_id": "<agent-id>",
"cursor_sdk.model": "composer-2",
"cursor_sdk.operation": "agent.send",
"cursor_sdk.run_id": "<run-id>",
"cursor_sdk.status": "finished",
"model": "composer-2",
"provider": "cursor"
},
"metric_keys": [
"duration"
],
"name": "Cursor Agent",
"root_span_id": "<span:1>",
"span_id": "<span:3>",
"span_parents": [
"<span:2>"
],
"type": "task"
}
},
"prompt": {
"operation": {
"has_input": false,
"has_output": false,
"metadata": {
"operation": "prompt"
},
"metric_keys": [],
"name": "cursor-sdk-prompt-operation",
"root_span_id": "<span:1>",
"span_id": "<span:4>",
"span_parents": [
"<span:1>"
],
"type": null
},
"task": {
"has_input": true,
"has_output": true,
"metadata": {
"cursor_sdk.model": "composer-2",
"cursor_sdk.operation": "Agent.prompt",
"cursor_sdk.run_id": "<run-id>",
"cursor_sdk.runtime": "local",
"cursor_sdk.status": "finished",
"model": "composer-2",
"provider": "cursor"
},
"metric_keys": [
"duration"
],
"name": "Cursor Agent",
"root_span_id": "<span:1>",
"span_id": "<span:5>",
"span_parents": [
"<span:4>"
],
"type": "task"
}
},
"root": {
"has_input": false,
"has_output": false,
"metadata": {
"scenario": "cursor-sdk-instrumentation"
},
"metric_keys": [],
"name": "cursor-sdk-root",
"root_span_id": "<span:1>",
"span_id": "<span:1>",
"span_parents": [],
"type": "task"
},
"stream": {
"operation": {
"has_input": false,
"has_output": false,
"metadata": {
"operation": "stream"
},
"metric_keys": [],
"name": "cursor-sdk-stream-operation",
"root_span_id": "<span:1>",
"span_id": "<span:6>",
"span_parents": [
"<span:1>"
],
"type": null
},
"subagent_task": {
"has_input": true,
"has_output": true,
"metadata": {
"cursor_sdk.tool.status": "completed",
"gen_ai.tool.name": "task"
},
"metric_keys": [],
"name": "Agent: <subagent>",
"root_span_id": "<span:1>",
"span_id": "<span:7>",
"span_parents": [
"<span:8>"
],
"type": "task"
},
"subagent_tool": {
"has_input": true,
"has_output": true,
"metadata": {
"cursor_sdk.tool.status": "completed",
"gen_ai.tool.name": "task"
},
"metric_keys": [],
"name": "tool: task",
"root_span_id": "<span:1>",
"span_id": "<span:8>",
"span_parents": [
"<span:9>"
],
"type": "tool"
},
"task": {
"has_input": true,
"has_output": true,
"metadata": {
"cursor_sdk.agent_id": "<agent-id>",
"cursor_sdk.model": "composer-2",
"cursor_sdk.operation": "agent.send",
"cursor_sdk.run_id": "<run-id>",
"cursor_sdk.status": "finished",
"model": "composer-2",
"provider": "cursor"
},
"metric_keys": [
"duration"
],
"name": "Cursor Agent",
"root_span_id": "<span:1>",
"span_id": "<span:9>",
"span_parents": [
"<span:6>"
],
"type": "task"
},
"tool": {
"has_input": true,
"has_output": true,
"metadata": {
"cursor_sdk.tool.status": "completed",
"gen_ai.tool.name": "shell"
},
"metric_keys": [],
"name": "tool: shell",
"root_span_id": "<span:1>",
"span_id": "<span:10>",
"span_parents": [
"<span:9>"
],
"type": "tool"
}
},
"wait": {
"operation": {
"has_input": false,
"has_output": false,
"metadata": {
"operation": "wait"
},
"metric_keys": [],
"name": "cursor-sdk-wait-operation",
"root_span_id": "<span:1>",
"span_id": "<span:11>",
"span_parents": [
"<span:1>"
],
"type": null
},
"task": {
"has_input": true,
"has_output": true,
"metadata": {
"cursor_sdk.agent_id": "<agent-id>",
"cursor_sdk.model": "composer-2",
"cursor_sdk.operation": "agent.send",
"cursor_sdk.run_id": "<run-id>",
"cursor_sdk.status": "finished",
"cursor_sdk.step_types": [
"assistantMessage"
],
"model": "composer-2",
"provider": "cursor"
},
"metric_keys": [
"completion_tokens",
"cursor_sdk.delta_tokens",
"cursor_sdk.step_duration_ms",
"cursor_sdk.steps",
"duration",
"prompt_cache_creation_tokens",
"prompt_cached_tokens",
"prompt_tokens",
"tokens"
],
"name": "Cursor Agent",
"root_span_id": "<span:1>",
"span_id": "<span:12>",
"span_parents": [
"<span:11>"
],
"type": "task"
}
}
}
Loading
Loading