Dropstone SDK 概述
Dropstone 代理的带类型 TypeScript 和 JavaScript 客户端,提供两个入口:一个用于 CI 或 serverless 函数的无状态 API 调用,另一个在本地运行代理,并使用与 CLI 和 Chat 相同的账户记忆。
Dropstone SDK 是 Dropstone 代理运行时的带类型 TypeScript 和 JavaScript 客户端。它为你的代码提供对 Dropstone Chat 和 CLI 中运行的同一代理的程序化访问:会话、工具、流式回复和结构化输出。
npm install @blankline/dropstone-sdk
方法参考位于 docs.dropstone.io/cli/sdk。本页是概述,安装并运行你的第一个会话 是操作指南。
两个入口
SDK 提供两个客户端,选择哪一个取决于你的代码运行位置。
| 无状态 API 客户端 | 本地代理客户端 | |
|---|---|---|
| 导入 | createDropstoneApi | createDropstone |
| 通信对象 | api.dropstone.io/api/v1 | 它为你启动的 dropstone serve 进程 |
| 身份验证 | API 密钥 | 同一台机器上 CLI 的登录状态 |
| 计费 | 从你的信用余额中按使用量付费 | 你的每周配额,与 CLI 相同 |
| 你的记忆 | 无。它是一个无状态的补全端点 | 有,Chat 和 CLI 使用的账户记忆 |
| 适用场景 | CI、作业、serverless,以及任何没有 CLI 的主机 | 在 Node 应用中嵌入交互式代理 |
SDK 还附带另外两个入口:createDropstoneClient 将相同的带类型客户端指向你已在运行的服务器,createDropstoneTui 从 Node 进程启动交互式终端界面。
一处记忆,处处可用
本地会话以你的账户身份运行,因此它从 Dropstone 在其他界面上学到的所有内容开始。你在 Chat 中设置的规则在通过 SDK 运行的代码中同样生效,会话记录的内容在你下次打开 CLI 时也会存在。请参阅 每个界面共享一处记忆。
无状态客户端则刻意相反:一个无状态的、兼容 OpenAI 的补全端点,不附带任何记忆,因此管道可以获得可预测的输入和输出。请参阅 使用你的套餐调用 API。
端到端带类型
请求、响应、流式事件和工具调用均根据服务器的 OpenAPI 规范生成,因此编辑器可以自动补全,编译器可以检查它们。同一个包中提供两个界面:稳定的 v1 客户端,以及位于 @blankline/dropstone-sdk/v2 的 v2 客户端,后者为文件和 workspace 提供更丰富的资源模型。新端点会添加到 v2 中。
要求
- Node.js
- 对于本地代理客户端,同一台机器上需要安装 Dropstone CLI,并使用
dropstone login登录 - 对于无状态客户端,需要 API 密钥 和已充值的信用余额
获取帮助
CLI 参考 是解决方法级问题的首选。对于账户、计费或访问问题,请参阅 如何获取支持。
Related articles
- Install and run your first sessionInstall the Dropstone SDK, make a headless API call with an API key, and run a local agent session that carries your account memory. Includes streaming, structured output, and using the OpenAI SDK against Dropstone.
- Using the API with your planCall Dropstone over HTTP with an API key. The endpoint is OpenAI-compatible, billed pay-per-use from your credit balance, and works from any language. Keys, errors, rate limits, and what the API does not carry.
- One memory across every surfaceThe account memory that follows you across Dropstone Chat, the CLI, and the SDK, what shares it and what does not, and how to keep an integration's learning out of your own memory.
- Install the CLIInstall the Dropstone CLI on macOS, Linux, or Windows with one command, sign in, and check it works. Upgrading and uninstalling.
- Memory across chat, CLI, and SDKDropstone memory belongs to your account, not to one app. A rule you set in the CLI applies in chat, and something learned in chat is available to the SDK. One memory, every surface.