agent-core-framework
v1.0.0
Published
Modular, async/sync agent flow framework in TypeScript
Maintainers
Readme
🧠 agent-core-framework
A minimal and powerful TypeScript framework to build data-driven, retryable, async/sync agent pipelines with logging and conditional routing. Inspired by flow orchestration patterns and LLM agent execution graphs.
📦 Installation
npm install agent-core-frameworkOr if you're using it locally:
npm install tsx typescript --save-dev🧪 Example (Sync)
import { Node, Agent } from "agent-core-framework";
class GreetNode extends Node {
exec() {
console.log("👋 Hello!");
return "next";
}
}
class DoneNode extends Node {
exec() {
console.log("✅ Finished.");
}
}
const greet = new GreetNode();
const done = new DoneNode();
greet.addSuccessor(done, "next");
const agent = new Agent(greet);
agent.setLogger((event, data) => console.log(`[LOG:${event}]`, data));
agent._run({});⚙️ Features
- ✅ Sync/async execution
- 🔁 Retry & fallback support
- ⛓️ Flow-based chaining
- 🧠 Conditional branching
- 🔀 Batch & parallel processing
- 🪵 Logger hooks for observability
🚀 Async Agent Example
import { AsyncNode, AsyncAgent } from "agent-core-framework";
class FetchData extends AsyncNode {
async execAsync() {
console.log("📡 Fetching...");
await new Promise((res) => setTimeout(res, 500));
return "next";
}
}
class ProcessData extends AsyncNode {
async execAsync() {
console.log("⚙️ Processing...");
}
}
(async () => {
const fetch = new FetchData();
const process = new ProcessData();
fetch.addSuccessor(process, "next");
const agent = new AsyncAgent(fetch);
agent.setLogger((e, d) => console.log(`[LOG:${e}]`, d));
await agent._run({});
})();📁 File Structure
src/core/
├── Agent.ts
├── AsyncAgent.ts
├── BaseNode.ts
├── Node.ts
├── AsyncNode.ts
├── ConditionalNode.ts
├── BatchNode.ts
├── AsyncBatchNode.ts
├── AsyncParallelBatchNode.ts
└── index.ts🧪 Run Test Locally
npx tsx test/example-agent.ts
npx tsx test/example-async-agent.ts📜 License
MIT
