@dograh/sdk

中文文档
0.1.7发布于 2026/05/31BSD-2-ClauseTypeScriptES Module零依赖近 30 天下载 1.2万

Typed builder for Dograh voice-AI workflows

原始使用文档
文档目录5 节
  1. Install
  2. Usage
  3. Client-side validation
  4. Environment
  5. License

@dograh/sdk

Typed builder for Dograh voice-AI workflows. Fetches the node-spec catalog from the Dograh backend at session start, validates every call against it at the call site, and produces wire-format JSON that round-trips through the Python ReactFlowDTO.

Install

npm install @dograh/sdk
# or
pnpm add @dograh/sdk

For local development against a checked-out monorepo, add a tsconfig paths entry:

{
  "paths": {
    "@dograh/sdk": ["../sdk/typescript/src/index.ts"]
  }
}

Usage

import { DograhClient, Workflow } from "@dograh/sdk";

const client = new DograhClient({
  baseUrl: "http://localhost:8000",
  apiKey: process.env.DOGRAH_API_KEY,
});

const wf = new Workflow({ client, name: "loan_qualification" });

const start = await wf.add({
  type: "startCall",
  name: "greeting",
  prompt: "You are Sarah from Acme Loans. Greet the caller warmly.",
  greeting_type: "text",
  greeting: "Hi {{first_name}}, this is Sarah.",
});

const qualify = await wf.add({
  type: "agentNode",
  name: "qualify",
  prompt: "Ask about loan amount and timeline.",
});

const done = await wf.add({ type: "endCall", name: "done", prompt: "Thank them." });

wf.edge(start, qualify, { label: "interested", condition: "Caller expressed interest." });
wf.edge(qualify, done, { label: "done", condition: "Qualification complete." });

await client.saveWorkflow(123, wf);

Client-side validation

Each add() call validates kwargs against the fetched spec. ValidationError is thrown immediately when:

  • an unknown field is passed (catches typos)
  • a required field is missing or empty
  • a scalar type is wrong (e.g., string for a boolean)
  • an options value isn't in the allowed list

When a spec carries an llm_hint, the hint is appended to the error so an LLM agent can self-correct on retry:

tool_uuids: expected tool_refs, got string
  Hint: List of tool UUIDs from `list_tools`.

Server-side Pydantic validators run on save and surface anything the client lets through.

Environment

DOGRAH_API_URL=http://localhost:8000   # default
DOGRAH_API_KEY=sk-...                  # sent as X-API-Key

License

BSD 2-Clause — see LICENSE.

版本与发布记录

@dograh/sdk 共发布 7 个版本,首次发布于 2026/04/20;过去 12 个月发布了 7 个版本。

版本发布日期距今
0.1.7latest2026/05/315 个月前
0.1.62026/05/235 个月前
0.1.52026/05/026 个月前
0.1.42026/04/256 个月前
0.1.22026/04/206 个月前
0.1.12026/04/206 个月前

关于 @dograh/sdk 的常见问题

@dograh/sdk 是什么?

Typed builder for Dograh voice-AI workflows

如何安装 @dograh/sdk?

在项目目录运行 npm install @dograh/sdk,或使用 pnpm add / yarn add / bun add。

@dograh/sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dograh/sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dograh/sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dograh/sdk 可以商用吗?

@dograh/sdk 使用 BSD-2-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dograh/sdk 的下载量有多少?

根据 npm 官方下载统计,@dograh/sdk 在 2026/10/13 – 2026/11/11 这 30 天内被下载 12,058 次,日均约 402 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dograh/sdk 还在维护吗?

最新版本 0.1.7 发布于 2026/05/31(5 个月前);至今共发布 7 个版本,其中过去 12 个月发布了 7 个;首次发布于 2026/04/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。