ai-agent-flow - v1.0.0
ai-agent-flow
ai-agent-flow is a TypeScript-based Node.js framework designed for building intelligent, modular, and observable workflows for AI agents. It helps you compose systems using simple, pluggable components with built-in AI capabilities.
๐ Features
- ๐ Composable Node-based Flows: Build AI workflows using LLM, decision, batch, and custom logic nodes
- ๐ง AI-first Architecture: Native OpenAI support with persistent prompt history
- ๐ก Multi-agent Messaging: Event-driven agent communication via
MessageBus
- ๐ Built-in Observability: Winston logging and Prometheus-compatible metrics
- ๐ Extensible Plugin System: Add new nodes, providers, and context stores
- ๐ Typed and Robust: Full TypeScript support with retries, error handling, and shared context
๐ฆ Installation
npm install ai-agent-flow
๐ก How It Works
๐ก Chatbot Example Flow (Click to expand)
flowchart TD
A[Start Node (LLMNode)] -->|default| B[DecisionNode]
B -->|weather| C[Weather ActionNode]
B -->|default| D[Fallback ActionNode]
- Nodes: Smallest executable units (call LLM, run logic)
- Flows: Connect nodes with action-based transitions
- Context: Shared memory between nodes with data, metadata, and history
- Runner: Executes flows and handles retries/errors
- Agents: Flows + state + messaging capabilities
โจ Philosophy
We built ai-agent-flow
because:
- Most existing tools (LangChain, AutoGen) are too abstract or too complex for beginners
- Developers want to see, control, and debug each step in their flow
- We believe agents should be modular, testable, and observable โ like LEGO blocks
ai-agent-flow
gives you full control over how data flows, how AI responds, and how agents collaborate.
๐ง Quick Start Example
import { Flow, Runner } from './src/index';
import { ActionNode } from './src/nodes/action';
const context = { conversationHistory: [], data: {}, metadata: {} };
const hello = new ActionNode('hello', async () => 'Hello');
const world = new ActionNode('world', async () => 'World');
const flow = new Flow('greet')
.addNode(hello)
.addNode(world)
.setStartNode('hello')
.addTransition('hello', { action: 'default', to: 'world' });
await new Runner().runFlow(flow, context);
๐ Example Applications
๐ฎ Chatbot (examples/chatbot.ts
)
A conversational agent powered by OpenAI:
- LLMNode generates response
- DecisionNode routes based on keyword
- ActionNode responds with data (like weather)
npx ts-node examples/chatbot.ts
๐ค Multi-agent system (examples/multi-agent.ts
)
Two agents communicating using a message bus:
- Support agent triggers billing agent
- Billing agent replies back
npx ts-node examples/multi-agent.ts
๐งช Data pipeline (examples/data-pipeline.ts
)
Batch processing a list of users to flag eligibility:
- BatchNode loops over users
- Transformation stored in context
npx ts-node examples/data-pipeline.ts
๐ Project Structure
src/
โโโ nodes/ # Node types like ActionNode, LLMNode
โโโ stores/ # Redis or in-memory context stores
โโโ providers/ # LLM clients (OpenAI)
โโโ utils/ # Messaging utils
โโโ index.ts # Core framework (Node, Flow, Runner)
examples/ # Use cases
๐งช Tests
Run all unit tests:
npm test
โ๏ธ 100% coverage on statements, functions, and types.
โ๏ธ Covers edge cases (invalid flows, retries, node failures).
โ๏ธ All nodes and message flows tested.
๐ Documentation
Full API reference available via TypeDoc:
- ๐๏ธ View the Docs
You can also build docs locally:
npm run docs
open ./docs/index.html
๐ Extending the Framework
- Add your own nodes by extending
Node
- Plug in custom LLM providers (Anthropic, HuggingFace)
- Implement your own context stores (MongoDB, S3)
- Replace
MessageBus
with Redis Pub/Sub or NATS
๐ Observability
- โ Logging: via Winston
- โ Metrics: via prom-client
- โ
Events: listen to
nodeExecuted
,flowCompleted
onFlow
๐ Roadmap
Phase | Features |
---|---|
โ Now | Full engine + nodes + OpenAI + examples |
๐ธ๏ธ Short-term | Anthropic support, CLI tool, Prometheus |
๐ง Mid-term | Visual editor, plugin API, Redis bus |
๐๏ธ Long-term | Distributed agents, LLM auto-routing |
๐ ๏ธ Contributing
git clone https://github.com/EunixTech/ai-agent-flow
npm install
npm test
We welcome all contributions โ bug fixes, new nodes, documentation, examples ๐
๐ License
MIT ยฉ 2025 Rajesh Dhiman
๐ฌ Contact
Open issues or reach out here:
๐ https://www.rajeshdhiman.in/contact
"Build agent flows like LEGO blocks โ simple, powerful, and easy to debug."