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.
AI Multi-Agent Stock Trading System: GPT-5 and Claude 4.5 Sonnet
Dianman VPN: Free Trial, Unlimited Data & Zero Throttling
Dayflow Mac App Review: Turn Screen Time Into an AI Timeline
PromptEnhancer: Rewrite Any Prompt for Stunning AI Images
Puter: An Open-Source Personal Cloud OS for Files, Apps, and Games
OxyGent: Build Multi-Agent Systems That Learn and Scale Without YAML
Notes MCP Guide: Connect Apple Notes to Claude, Cursor, and LLMs
SmartPDF: Summarize PDFs with Llama 3.3
MCP SuperAssistant: Bring MCP Tools to ChatGPT, Gemini, and Beyond
ONLYOFFICE Docs: A Powerful Online Collaborative Office Suite
ACE-Step: 15x Faster Open-Source Music Generation Model
PyVideoTrans: Open-Source Video Translation & Dubbing Tool