@ailu-ai/graph-sdk

中文文档
2.8.5发布于 2026/11/06Apache-2.0TypeScriptES Module近 30 天下载 2866

The front door to the Ailu framework — build, compile and run stateful, resumable agent graphs. Runs on the Rust engine (@ailu-ai/napi), a required dependency.

原始使用文档
文档目录3 节
  1. Install
  2. Quickstart
  3. License

@ailu-ai/graph-sdk

The front door to the Ailu framework: build, compile and run stateful, resumable agent graphs — agents, tools, human-approval gates, artifacts and long-running workflows — without touching the lower-level engine.

Every run is checkpointed after every step: it can stop at a human-approval gate and resume from where it stopped. To resume in another process, run the graph with runCatalogGraph and keep the state it returns.

Install

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

Graphs run on Ailu's Rust engine. It ships as a prebuilt native addon (@ailu-ai/napi, installed with the SDK) for macOS (x64, arm64), Linux with glibc (x64, arm64) and Windows x64. There is no TypeScript fallback: on another platform compile() throws RustEngineRequiredError. Check at boot with:

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

Quickstart

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!"

Add a human-approval gate and the run suspends cleanly, then resumes from its checkpoint:

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"

An agent node takes a model and a prompt. The API key is read from the environment (ANTHROPIC_API_KEY here); with no key the run fails and says which variable to set. To run offline on the engine's deterministic mock (tests, CI), set AILU_LLM_MOCK=1.

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);

Conditional routing is always a named predicate — never an eval'd string — which is what keeps Ailu's flows safe and inspectable.

Documentation: https://ai-adriane.github.io/ailu-core/.

License

Apache-2.0. See LICENSE.

版本与发布记录

@ailu-ai/graph-sdk 共发布 18 个版本,首次发布于 2026/09/29;过去 12 个月发布了 18 个版本。

版本发布日期距今
2.8.5latest2026/11/061 天前
2.8.42026/11/053 天前
2.8.32026/11/053 天前
2.8.22026/10/308 天前
2.8.12026/10/299 天前
2.8.02026/10/299 天前

关于 @ailu-ai/graph-sdk 的常见问题

@ailu-ai/graph-sdk 是什么?

The front door to the Ailu framework — build, compile and run stateful, resumable agent graphs. Runs on the Rust engine (@ailu-ai/napi), a required dependency.

如何安装 @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 和提交记录判断。