ai-agent-flow - v1.0.0

ai-agent-flow

Docs

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.


  • ๐Ÿ”„ 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

npm install ai-agent-flow

๐Ÿ’ก 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

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.


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

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

Two agents communicating using a message bus:

  • Support agent triggers billing agent
  • Billing agent replies back
npx ts-node examples/multi-agent.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

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

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.


Full API reference available via TypeDoc:

You can also build docs locally:

npm run docs
open ./docs/index.html

  • 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

  • โœ… Logging: via Winston
  • โœ… Metrics: via prom-client
  • โœ… Events: listen to nodeExecuted, flowCompleted on Flow

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

git clone https://github.com/EunixTech/ai-agent-flow
npm install
npm test

We welcome all contributions โ€” bug fixes, new nodes, documentation, examples ๐Ÿ™Œ


MIT ยฉ 2025 Rajesh Dhiman


Open issues or reach out here:
๐Ÿ‘‰ https://www.rajeshdhiman.in/contact

"Build agent flows like LEGO blocks โ€” simple, powerful, and easy to debug."