Dropstone SDK
適用於 Dropstone agent 的型別化 TypeScript 與 JavaScript 用戶端,提供兩個進入點:一個用於從 CI 或 serverless function 進行無狀態 API 呼叫,另一個則在本機執行 agent,並與 CLI 和 Chat 使用相同的帳戶記憶體。
Dropstone SDK 是 Dropstone agent 執行環境的型別化 TypeScript 與 JavaScript 用戶端。它讓你的程式碼能以程式化方式存取與 Dropstone Chat 和 CLI 中相同的 agent:工作階段、工具、串流回覆,以及結構化輸出。
npm install @blankline/dropstone-sdk
方法參考位於 docs.dropstone.io/cli/sdk。此頁面為總覽,而 安裝並執行你的第一個工作階段 則為逐步教學。
兩個進入點
SDK 提供兩個用戶端,選擇哪一個取決於你的程式碼執行環境。
| 無狀態 API 用戶端 | 本機 agent 用戶端 | |
|---|---|---|
| 匯入 | createDropstoneApi | createDropstone |
| 連線至 | api.dropstone.io/api/v1 | 由它為你啟動的 dropstone serve 程序 |
| 驗證方式 | API 金鑰 | 同一台機器上 CLI 的登入狀態 |
| 計費方式 | 從你的餘額中按使用量付費 | 與 CLI 相同,使用你的每週配額 |
| 你的記憶體 | 否。這是一個無狀態的 completions 端點 | 是,Chat 和 CLI 使用的帳戶記憶體 |
| 適用於 | CI、批次任務、serverless,以及任何未安裝 CLI 的主機 | 在 Node 應用程式中嵌入互動式 agent |
另外還有兩個進入點:createDropstoneClient 將相同的型別化用戶端指向你已在執行的伺服器,而 createDropstoneTui 則從 Node 程序啟動互動式終端介面。
一個記憶體,隨處可用
本機工作階段以你的帳戶身分執行,因此它會從 Dropstone 在其他介面上學到的所有內容開始。你在 Chat 中設定的規則,在透過 SDK 執行的程式碼中同樣有效,而工作階段記錄的內容,也會在你下次開啟 CLI 時出現。請參閱 每個介面共用一個記憶體。
無狀態用戶端則刻意相反:這是一個無狀態、與 OpenAI 相容的 completions 端點,不附加任何記憶體,因此管線可以獲得可預期的輸入與輸出。請參閱 搭配你的方案使用 API。
端到端的型別安全
請求、回應、串流事件和工具呼叫都是從伺服器的 OpenAPI 規格產生的,因此編輯器可以自動完成,編譯器可以檢查。單一套件中包含兩個介面:穩定的 v1 用戶端,以及位於 @blankline/dropstone-sdk/v2 的 v2 用戶端,後者針對檔案和工作區提供更豐富的資源模型。新端點會落在 v2 上。
需求
- Node.js
- 若使用本機 agent 用戶端,需在同一台機器上安裝 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.