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.
DeepSeek-OCR WebUI: Batch OCR with Markdown Tables and Visual Bounding Boxes
Skill Seeker: Convert Any Documentation Site Into Claude AI Skills
MOSS-Speech: Real Voice-to-Voice AI Without Text Bottlenecks
SpikingBrain: 100x Faster LLM Inference via Spike Sparsity
Shendeng VPN Review: High-Speed Gaming, Video Streaming, and Unlimited Data
Fooocus: Free Offline SDXL Image Generator & Installation Guide
BiliNote: Convert YouTube and Bilibili Videos Into Markdown Notes
Jitsi Meet Review: Open-Source Video Conferencing That Just Works
AutoGenLib: Generate Python Code on the Fly With OpenAI API
Muscle Memory: Cache AI Agent Actions to Cut LLM Costs and Latency
ACI.dev: 600+ Tools for AI Agents with Built-In Auth and MCP Support
ZeroSearch: Training LLMs to Search Without Real-World Search Engines