一声棒喝,本不立文字
偏要著録,已是二义

cursor-changelog

用 Cursor SDK 构建程序化 agent

Build programmatic agents with the Cursor SDK

二〇二六年五月八日 · 英文原文

Cursor 推出 Cursor SDK,开发者可用同一 runtime、harness 和 models 以 TypeScript 构建 agents,支持本地或 Cursor cloud 专用 VM、任意 frontier model。SDK 通过 npm 安装,已 public beta,按 token 计费;Cloud Agents API 更新 run 作用域、SSE streaming、生命周期控制及 v1 response/error 结构。

我们推出 Cursor SDK,让你可以使用驱动 Cursor 的同一套 runtime、harness 和 models 来构建 agents。在 Cursor desktop app、CLI 和 web app 中运行的 agents,现在只需几行 TypeScript 就能使用。你可以在自己的机器上运行,也可以在 Cursor 的 cloud 上针对专用 VM 运行,并使用任意 frontier model。运行 npm install @cursor/sdk 即可开始,并使用 Cursor SDK plugin,让 Cursor 帮助你构建。```jsx import { Agent } from "@cursor/sdk";

const agent = await Agent.create({ apiKey: process.env.CURSOR_API_KEY!, model: { id: "composer-2" }, local: { cwd: process.cwd() }, });

const run = await agent.send("Summarize what this repository does");

for await (const event of run.stream()) { console.log(event); } ``` 我们构建了一些示例项目,你可以从 public repo 获取。Fork 并扩展它们,以适配你自己的用例。Cursor SDK 现已面向所有用户以 public beta 形式提供,并按标准的基于 token 的消耗定价计费。更多信息请参阅我们的 announcement 和 docs。Cloud Agents API 更新:围绕 durable agents 和 per-prompt runs 重新设计了 API,因此 follow-ups、status、streaming 和 cancellation 现在都以 run 为作用域。新增一等 run streaming,支持 SSE events、通过 Last-Event-ID 重新连接,并提供更清晰的 terminal states。新增明确的 agent lifecycle controls,包括 archive、unarchive 和 permanent delete。标准化 v1 response 和 error shapes,包括结构化 error codes、items list responses,以及独立的 agent / run objects。

译自 cursor-changelog · 录于 二〇二六年五月八日