Build autonomous reactive agents with TypeScript - A lightweight, modular framework for creating intelligent systems using trigger-condition-action flows.
Zero dependencies. Full TypeScript support. Less than 5KB minified + gzipped. Perfect for automation, workflow orchestration, state machines, and AI-powered applications.
import { Agent } from '@agentiny/core';
const agent = new Agent({ initialState: { count: 0 } });
agent.when((state) => state.count > 5, [(state) => console.log('Milestone reached:', state.count)]);
await agent.start();
agent.setState({ count: 10 }); // Triggers action
The agentiny framework consists of modular packages designed to work together:
Package | Purpose | Version | Status |
---|---|---|---|
@agentiny/core | Foundation - Trigger-condition-action framework | ✅ Foundation | |
@agentiny/utils | Utility helpers - Retry, timeout, validation | ✅ Ready | |
@agentiny/openai | OpenAI integration - AI-powered actions | ✅ Ready | |
@agentiny/anthropic | Anthropic integration - Claude API support | ✅ Ready | |
@agentiny/gemini | Google Gemini integration | ✅ Ready |
@agentiny/core (foundation)
│
├── @agentiny/utils (extends core with utilities)
│
├── @agentiny/openai (uses core for AI actions)
│
├── @agentiny/anthropic (uses core for AI actions)
│
└── @agentiny/gemini (uses core for AI actions)
npm install @agentiny/core
import { Agent } from '@agentiny/core';
interface AppState {
temperature: number;
alarm: boolean;
}
const agent = new Agent<AppState>({
initialState: { temperature: 0, alarm: false },
});
// Trigger when temperature exceeds 30°C
agent.when(
(state) => state.temperature > 30,
[(state) => (state.alarm = true), (state) => console.log('⚠️ Alert!')],
);
// Reset alarm when temperature normalizes
agent.when(
(state) => state.temperature <= 25,
[(state) => (state.alarm = false), (state) => console.log('✅ Normal')],
);
await agent.start();
// Simulate temperature changes
agent.setState({ temperature: 35 }); // Triggers alarm
agent.setState({ temperature: 20 }); // Resets alarm
await agent.stop();
import { Agent } from '@agentiny/core';
import { createAnthropicAction } from '@agentiny/anthropic';
const agent = new Agent({ initialState: { userInput: '' } });
const aiAction = createAnthropicAction({
prompt: (state) => `Respond to: ${state.userInput}`,
model: 'claude-3-sonnet-20240229',
apiKey: process.env.ANTHROPIC_API_KEY,
});
agent.when((state) => state.userInput.length > 0, [aiAction]);
await agent.start();
agent.setState({ userInput: 'Hello, how are you?' });
Functions that determine when to act:
// State-based trigger
(state) => state.count > 5;
// Event-based trigger
agent.on('user-login', [action]);
Optional validation before executing actions:
agent.when(
(state) => state.count > 5, // trigger
[(state) => state.approved], // condition
[(state) => executeAction(state)], // actions
);
Functions that do something when triggered:
(state) => {
state.count = 0;
console.log('Reset!');
};
- Workflow Automation - Automate multi-step processes with conditional logic
- Event-Driven Systems - Build responsive applications that react to state changes
- State Machines - Implement complex state management elegantly
- AI-Powered Agents - Create intelligent agents using AI models
- Real-time Monitoring - Monitor conditions and trigger alerts or actions
- Business Logic Orchestration - Coordinate complex business rules
- Core README - Complete framework documentation
- API Reference - Detailed method documentation
- Examples - Real-world usage examples
- Utils - Utility helpers and wrappers
- OpenAI - Create AI actions with OpenAI
- Anthropic - Integrate Claude for AI capabilities
- Gemini - Google Gemini AI integration
✅ Zero Dependencies - Minimal footprint, no runtime dependencies ✅ Type-Safe - Full TypeScript support with strict mode ✅ Event-Driven - Reactive trigger system with state management ✅ Flexible - Repeating triggers, one-time triggers, event-based triggers ✅ Async/Await - Full async support for all operations ✅ Small Bundle - Less than 5KB minified + gzipped ✅ Well-Tested - 124+ comprehensive tests ✅ Performance - Smart state change tracking for efficiency
# Clone and install
git clone https://github.com/keldrik/agentiny.git
cd agentiny
npm install
# Type checking
npm run typecheck
# Linting
npm run lint
# Formatting
npm run format # Check
npm run format:write # Auto-fix
# Building
npm run build
# Testing (core package)
npm run test:run -w @agentiny/core
npm run test -w @agentiny/core # Watch mode
# Build specific package
npm run build -w @agentiny/core
agentiny/
├── packages/
│ ├── core/ # Foundation framework
│ ├── utils/ # Utilities and helpers
│ ├── openai/ # OpenAI integration
│ ├── anthropic/ # Anthropic integration
│ └── gemini/ # Google Gemini integration
├── package.json # Workspace root
└── README.md # This file
We welcome contributions! Here's how you can help:
- Report Issues - Find a bug? Open an issue
- Suggest Features - Have an idea? Discuss it in issues
- Submit PRs - Fix bugs or add features
- Improve Docs - Help us document better
- Create a feature branch:
git checkout -b feature/my-feature
- Make your changes and add tests
- Run validation:
npm run typecheck && npm run lint && npm run format:write
- Build:
npm run build
- Commit and push to your fork
- Open a PR with a clear description
import { Agent } from '@agentiny/core';
const agent = new Agent({ initialState: { done: false } });
agent.once((state) => state.done, [() => console.log('Complete!')]);
await agent.start();
agent.setState({ done: true });
import { Agent } from '@agentiny/core';
import { retry, timeout } from '@agentiny/utils';
const agent = new Agent({
initialState: { retries: 0 },
onError: retry({ maxAttempts: 3 }),
});
import { Agent } from '@agentiny/core';
import { createAnthropicAction } from '@agentiny/anthropic';
const aiAction = createAnthropicAction({
prompt: (state) => `Analyze: ${state.data}`,
model: 'claude-3-sonnet-20240229',
apiKey: process.env.ANTHROPIC_API_KEY,
});
const agent = new Agent({ initialState: { data: '' } });
agent.when((state) => state.data.length > 0, [aiAction]);
- Bundle Size: < 5KB minified + gzipped (core only)
- Dependencies: 0 runtime dependencies
- Type Safety: Full TypeScript strict mode
- Scalability: Tested with 100+ concurrent triggers
- Test Coverage: 124+ tests across all packages
agentiny uses a trigger-condition-action architecture:
State Change
↓
Check Trigger
↓
Evaluate Conditions
↓
Execute Actions
↓
Update State
This creates a reactive system where agents automatically respond to state changes or events.
- Node.js 16+
- Modern browsers with ES2020 support
- Works with any framework (React, Vue, Angular, Svelte, etc.)
MIT - See LICENSE file for details
- No external dependencies = no supply chain risk
- Full TypeScript type safety
- Error handling throughout
- Memory-safe cleanup
- ✅ Core framework
- ✅ AI integrations (OpenAI, Anthropic, Gemini)
- ✅ Utilities (retry, timeout, validation)
- 🔄 Advanced features (persistence, clustering)
- 🔄 CLI tools for agent generation
- 📖 Read the documentation
- 🐛 Report issues on GitHub
- 💡 Check examples
Made with ❤️ by the agentiny team
Start building intelligent agents today. Install @agentiny/core
and create your first agent in seconds.