ZeroGraph TypeScript is a minimalist LLM framework designed specifically for building AI agents. As a direct TypeScript port of PocketFlow, its primary objective is to advance agent-oriented programming by stripping away unnecessary bloat.
The entire framework consists of just 300 lines of code—roughly 10KB. It carries zero dependencies and avoids vendor lock-in entirely. By providing full type safety and native IDE support, it facilitates "Agentic Coding," where AI tools like Cursor can assist in generating new agent logic. It is fast, lightweight, and strikes a balance between capability and simplicity.
The architecture relies on Nodes to handle individual tasks and Flows to orchestrate them. Batch processing and asynchronous operations are supported out of the box.
Lightweight: 300 lines, 10KB total size. No fluff, no dependencies, and no lock-in.
Native TypeScript: Full type safety ensures your IDE understands every interaction.
Agentic Coding: Built to let AI agents build other agents, significantly accelerating productivity.
Install via npm or yarn:
npm install @u0z/zero-graph
or
yarn add @u0z/zero-graph
Define a node, wrap it in a flow, and execute.
import { Node, Flow } from '@u0z/zero-graph';
class GreetingNode extends Node {
prep(shared: any): string {
return shared.name || 'World';
}
exec(name: string): string {
return `Hello, ${name}!`;
}
post(shared: any, prepRes: string, execRes: string): void {
shared.greeting = execRes;
}
}
const flow = new Flow(new GreetingNode());
const shared = { name: 'TypeScript' };
flow.run(shared);
console.log(shared.greeting); // "Hello, TypeScript!"
A Node is the fundamental building block of the framework. Three methods handle the workload:
prep: Retrieves data from shared storage.exec: Executes the core logic.post: Saves the results and determines the next step.class MyNode extends Node {
prep(shared: any): any {
return shared.input;
}
exec(prepResult: any): any {
return processData(prepResult);
}
post(shared: any, prepRes: any, execRes: any): string {
shared.result = execRes;
return 'default';
}
}
Flows connect nodes together, allowing you to turn complex tasks into manageable sequences.
const nodeA = new NodeA();
const nodeB = new NodeB();
const nodeC = new NodeC();
nodeA.next(nodeB, 'success');
nodeA.next(nodeC, 'error');
const flow = new Flow(nodeA);
flow.run(shared);
Batch Processing: Subclass BatchNode, implement exec for a single item, and execute using BatchFlow.
Async Support: Subclass AsyncNode, implement execAsync, and utilize AsyncFlow.runAsync.
The examples directory demonstrates several common patterns:
Further resources are available for deeper implementation:
While most LLM frameworks are heavy and complex, ZeroGraph remains intentionally lean.
| Framework | Lines of Code | Size | TypeScript Support |
|---|---|---|---|
| LangChain | 405K | +166MB | No |
| CrewAI | 18K | +173MB | No |
| LangGraph | 37K | +51MB | No |
| ZeroGraph | 300 | +10KB | Yes |
Building capable agents doesn't require a massive dependency tree; it requires clean abstractions and type safety. ZeroGraph delivers exactly that, and nothing more.
Gemini Conversation Timeline: Jump to Any Message Instantly
Feiniao VPN: Free Trial, 4K Streaming & Unblock Netflix (2026 Guide)
Shanlian VPN Review: High-Speed, Private & Optimized for China
Embedding Atlas: Interactive Visualization for Large-Scale Embeddings
Parlant: Build AI Agents That Follow Rules, Not Prompts
Cline AI Coding Assistant for VS Code: Powered by Claude Sonnet
Turso Database: A Rust-Based SQLite-Compatible Engine
ERPNext Open Source ERP: Installation Guide for Accounting and Inventory
SelfyAI: Build Your Own AI Agent as a Virtual World Asset
Anyi VPN Review: Free 365-Day Trial with No Data Caps or Ads
Natural Language CAD Control via CAD-MCP Server
Shendeng VPN: Unlimited Bandwidth, Smart Routing & VIP Membership (¥28/Month)