# @ailu-ai/graph-sdk 中文文档

规范地址：https://npmcn.com/package/%40ailu-ai/graph-sdk/

版本：2\.8\.5
npm 元数据更新时间：2026-11-06T08:56:16.479Z
中文译文更新时间：2026-11-06T15:39:40.041Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40ailu-ai/graph-sdk
原文对照：https://npmcn.com/package/%40ailu-ai/graph-sdk/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.8 MB，7 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：7 个
- 首次发布：2026-09-29T15:44:13.365Z
- 最新版本发布：2026-11-06T08:56:16.241Z
- 近 30 天下载量：2866（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：18（近 12 个月 18 个）

## 中文简介

Ailu框架的正门——构建,编译和运行状态,可重复的代理图. 运行在 Rust 引擎上 (@ailu-ai/napi),这是必需的依赖.

## 安装

```sh
npm install @ailu-ai/graph-sdk
```

也可以使用：`pnpm add @ailu-ai/graph-sdk`、`yarn add @ailu-ai/graph-sdk`、`bun add @ailu-ai/graph-sdk`

## README

# @ailu-ai/graph-sdk (英语)

前面的门 [爱路](https://github.com/AI-Adriane/ailu-core) 框架:建立、, 编译和运行 **状态、可更新的代理图表** ——代理,工具,人文审批 大门,文物和长跑的工作流程——不触及下层引擎.

每次跑步都会经过检查:它可以停在人类认可的大门上 从它停止的地方恢复。 要恢复到另一个进程, 请用 `runCatalogGraph` 并保持它返回的状态.

## 安装

```bash
npm install @ailu-ai/graph-sdk
# or: pnpm add @ailu-ai/graph-sdk   /   yarn add @ailu-ai/graph-sdk
```

Ailu的Rust引擎上有图 它作为预先建造的土生土长的船舶(`@ailu-ai/napi`, (中文(简体) ), 为macOS(x64,arm64),用glibc(x64,arm64)和Windows x64安装了SDK. 没有 TypeScript 倒置: 在另一个平台 `compile()` 掷出 `RustEngineRequiredError`。在启动时检查:

```ts
import { rustEngineAvailable } from "@ailu-ai/graph-sdk";
console.log(rustEngineAvailable()); // true when the native engine loaded
```

## 快速启动

```ts
import { createGraph } from "@ailu-ai/graph-sdk";

const app = createGraph({ name: "greeter" })
  .node("hello", async (_input, state) => ({
    greeting: `Hello, ${(state.channels as Record<string, unknown>).name}!`
  }))
  .compile();

const result = await app.run({ name: "Ada" });
console.log(result.channels.greeting); // "Hello, Ada!"
```

增加一个人类认可门和跑道 **暂停** 干净,那么 **恢复** 从其 检查站:

```ts
const app = createGraph({ name: "publish-flow" })
  .node("write", async () => ({ draft: "Hello from Ailu." }))
  .humanGate("review")
  .node("publish", async () => ({ approved: true }))
  .edge("write", "review")
  .edge("review", "publish")
  .compile();

const suspended = await app.run();              // status: "suspended"
const done = await app.resume(suspended.runId); // status: "completed"
```

代理节点需要一个模型和一个提示. API 密钥从环境读取 (单位:千美元)`ANTHROPIC_API_KEY` 这里); 没有密钥, 运行失败, 并说要设置哪个变量 . 在引擎的定型模拟器(测试,CI)上下线 `AILU_LLM_MOCK=1`。 。 。 .

```ts
import { createGraph, model } from "@ailu-ai/graph-sdk";

const app = createGraph({ name: "assistant" })
  .agentNode("reply", {
    model: model.anthropic("claude-sonnet-4-6"),
    prompt: { system: "Answer in one sentence." }
  })
  .compile();

const out = await app.run({ question: "What is a checkpoint?" });
console.log(out.channels.agentResult);
```

有条件的路线总是 **名称为上游** 从不 `eval`'d 字符串——哪个 让爱露的流量安全、可检查.

联合国 [https://ai-adriane.github.io/ailu-core/ 互联网档案馆的存檔,存档日期2013-12-21](https://ai-adriane.github.io/ailu-core/)。 。 。 .

## 许可证

阿帕奇2.0 (英语). 见 [`LICENSE`](https://npmcn.com/package/%40ailu-ai/graph-sdk/LICENSE)。 。 。 .

## 常见问题

### @ailu-ai/graph-sdk 是什么？

Ailu框架的正门——构建,编译和运行状态,可重复的代理图\. 运行在 Rust 引擎上 \(@ailu-ai/napi\),这是必需的依赖\.

### 如何安装 @ailu-ai/graph-sdk？

在项目目录运行 npm install @ailu-ai/graph-sdk，或使用 pnpm add / yarn add / bun add。

### @ailu-ai/graph-sdk 支持 TypeScript 吗？

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

### @ailu-ai/graph-sdk 支持 ESM 还是 CommonJS？

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

### @ailu-ai/graph-sdk 可以商用吗？

@ailu-ai/graph-sdk 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @ailu-ai/graph-sdk 的下载量有多少？

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

### @ailu-ai/graph-sdk 还在维护吗？

最新版本 2\.8\.5 发布于 2026/11/06（1 天前）；至今共发布 18 个版本，其中过去 12 个月发布了 18 个；首次发布于 2026/09/29。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

