Cursor 发布 SDK,可用 TypeScript 构建智能体
Build programmatic agents with the Cursor SDK
Cursor 发布 Cursor SDK,开发者用几行 TypeScript 即可构建与 Cursor 桌面端、CLI 和 Web 应用同源的智能体,可运行在本机或 Cursor 云端专用 VM 上,并支持任意前沿模型。
Cursor 把自家智能体运行时和模型开放成 SDK,读者可据此判断现有编码工作流能否直接接入。
We're introducing the Cursor SDK so you can build agents with the same runtime, harness, and models that power Cursor.
The agents that run in the Cursor desktop app, CLI, and web app are now accessible with a few lines of TypeScript. Run it on your machine or on Cursor's cloud against a dedicated VM, with any frontier model.
Run `npm install @cursor/sdk` to get started. You can also use Cursor's native `/sdk` skill to help you start building.
```jsx import { Agent } from "@cursor/sdk";
const agent = await Agent.create({ apiKey: process.env.CURSOR_API_KEY!, model: { id: "composer-2.5" }, local: { cwd: process.cwd() }, });
const run = await agent.send("Summarize what this repository does");
for await (const event of run.stream()) { console.log(event); } ```
We built a few sample projects that you can access from a public repo. Fork and extend them for your own use case.
The Cursor SDK is now available for all users in public beta and is billed based on standard, token-based consumption pricing. Learn more in our announcement and docs.
Updates to the Cloud Agents API
- Reworked the API around durable agents and per-prompt runs, so follow-ups, status, streaming, and cancellation are now run-scoped.
- Added first-class run streaming with SSE events, reconnect support via `Last-Event-ID`, and clearer terminal states.
- Added explicit agent lifecycle controls with archive, unarchive, and permanent delete.
- Standardized v1 response and error shapes, including structured error codes, `items` list responses, and separate `agent` / `run` objects.
来源:Cursor Changelog · cursor.com