Production-ready conversational AI agent framework with advanced context management and enterprise-grade reliability
Website β’ Documentation β’ Twitter β’ GitHub
- Features
- Installation
- Quick Start
- Architecture
- Core Capabilities
- Configuration
- Performance
- Documentation
- Examples
- Development
- Technology Stack
- Security
- Contributing
- Roadmap
- License
- Support
- Session Management - Isolated conversation contexts with automatic lifecycle management
- Context Compression - Token-aware compression with multiple retention strategies (FIFO, priority, semantic)
- Rate Limiting - Token bucket and sliding window algorithms with per-key tracking
- Error Handling - Comprehensive error hierarchy with detailed context and retry logic
- Type Safety - Full TypeScript support with strict typing and exported interfaces
- Performance Monitoring - Built-in metrics collection and performance optimization utilities
- Structured Logging - Configurable logging with JSON and text formats
- HTTP Client - Axios-based client with automatic retry and exponential backoff
- Input Validation - Comprehensive validation and sanitization for all inputs
- Extensible Architecture - Modular design supporting custom implementations
- Node.js >= 18.0.0
- npm >= 9.0.0 or yarn >= 1.22.0
npm install @synthra/coreyarn add @synthra/coreimport { SynthraAgent } from '@synthra/core';
// Initialize agent
const agent = new SynthraAgent({
apiKey: process.env.SYNTHRA_API_KEY,
endpoint: 'https://api.synthra.ai',
timeout: 10000
});
// Create session
const session = agent.createSession('user_123');
// Send message
const response = await agent.sendMessage(
session.id,
'Hello, Synthra!'
);
console.log(response.message.content);
console.log(`Tokens: ${response.usage.totalTokens}`);
console.log(`Latency: ${response.latency}ms`);Synthra is built on a modular architecture with four primary layers:
βββββββββββββββββββββββββββββββββββββββββββ
β Application Layer β
β SynthraAgent | Sessions | Context β
βββββββββββββββββββββββββββββββββββββββββββ€
β Core Services β
β HTTP Client | Rate Limiter | Logger β
βββββββββββββββββββββββββββββββββββββββββββ€
β Utility Layer β
β Validation | Helpers | Errors β
βββββββββββββββββββββββββββββββββββββββββββ€
β Infrastructure β
β Network | Memory | Storage β
βββββββββββββββββββββββββββββββββββββββββββ
// Create isolated conversation context
const session = agent.createSession('user_123');
// Send multiple messages
await agent.sendMessage(session.id, 'First message');
await agent.sendMessage(session.id, 'Second message');
// Check session state
const updatedSession = agent.getSession(session.id);
console.log(`Messages: ${updatedSession?.messageCount}`);
// Clear or delete session
agent.clearSession(session.id);
agent.deleteSession(session.id);// Configure context window
agent.setContextConfig({
maxTokens: 8192,
windowSize: 20,
compressionEnabled: true,
retentionPolicy: 'semantic'
});
// Automatic compression when approaching limits
const response = await agent.sendMessage(sessionId, longMessage);import { RateLimiter } from '@synthra/core';
const limiter = new RateLimiter({
maxRequests: 100,
windowMs: 60000 // 100 requests per minute
});
await limiter.checkLimit(userId);import {
RateLimitError,
ContextOverflowError,
NetworkError
} from '@synthra/core';
try {
await agent.sendMessage(sessionId, content);
} catch (error) {
if (error instanceof RateLimitError) {
await delay(error.retryAfter * 1000);
// Retry
} else if (error instanceof ContextOverflowError) {
agent.clearSession(sessionId);
} else if (error instanceof NetworkError) {
// Handle network error
}
}const agent = new SynthraAgent({
apiKey: 'your_api_key',
endpoint: 'https://api.synthra.ai',
timeout: 10000
});const agent = new SynthraAgent({
apiKey: process.env.SYNTHRA_API_KEY,
endpoint: 'https://api.synthra.ai',
timeout: 15000,
retries: 5,
retryDelay: 2000,
debug: true
});
agent.setContextConfig({
maxTokens: 8192,
windowSize: 50,
compressionEnabled: true,
retentionPolicy: 'semantic'
});| Operation | Average Latency | Throughput |
|---|---|---|
| Message Processing | <100ms | 10,000 msg/s |
| Context Compression | <50ms | 1,000 contexts/s |
| Rate Limit Check | <1ms | 100,000 checks/s |
| Session Creation | <5ms | 20,000 sessions/s |
- Token-aware context compression
- Lazy resource loading
- Memory-efficient circular buffers
- Memoization for expensive operations
- Batch processing capabilities
git clone https://github.com/synthra/synthra.git
cd synthra
npm installnpm test # Run all tests
npm run test:unit # Unit tests only
npm run test:integration # Integration tests
npm run test:coverage # With coverage reportnpm run build # Production build
npm run build:watch # Watch mode
npm run type-check # TypeScript validationnpm run lint # Run linter
npm run lint:fix # Fix linting issues
npm run format # Format code- Quickstart Guide - Get started in 5 minutes
- API Reference - Complete API documentation
- Architecture - System design and patterns
- Examples - Working code examples
- Contributing - Contribution guidelines
- Security - Security policy
import { SynthraAgent } from '@synthra/core';
const agent = new SynthraAgent({
apiKey: process.env.SYNTHRA_API_KEY
});
const session = agent.createSession('user_001');
const response = await agent.sendMessage(
session.id,
'What can you help me with?'
);
console.log(response.message.content);import {
SynthraAgent,
RateLimiter,
ContextManager
} from '@synthra/core';
const agent = new SynthraAgent({
apiKey: process.env.SYNTHRA_API_KEY,
timeout: 15000,
retries: 5,
debug: true
});
const rateLimiter = new RateLimiter({
maxRequests: 10,
windowMs: 60000
});
const contextManager = new ContextManager({
maxTokens: 8192,
windowSize: 50,
compressionEnabled: true,
retentionPolicy: 'semantic'
});
// Use with rate limiting
await rateLimiter.checkLimit(userId);
const response = await agent.sendMessage(sessionId, content);See examples/ for complete working examples.
| Component | Technology |
|---|---|
| Runtime | Node.js 18+ |
| Language | TypeScript 5.3+ |
| HTTP Client | Axios |
| Validation | Zod |
| Testing | Vitest |
| Build | tsup |
| Linting | ESLint + Prettier |
| CI/CD | GitHub Actions |
- Input validation and sanitization
- API key authentication
- Rate limiting to prevent abuse
- No sensitive data in logs
- Secure session management
- Regular dependency audits
See SECURITY.md for security policy and vulnerability reporting.
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
npm test) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Core agent implementation
- Session management
- Context compression
- Rate limiting
- Comprehensive error handling
- Performance monitoring
- WebSocket streaming support
- Multi-model support (GPT-4, Claude, LLaMA)
- Plugin system
- Distributed session storage
- GraphQL API layer
See CHANGELOG.md for version history and release notes.
This project is licensed under the MIT License - see LICENSE file for details.
- Documentation: docs/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@synthra.ai
If you use Synthra in your research or production application, please cite:
@software{synthra,
author = {Synthra Team},
title = {Synthra: Production-ready Conversational AI Agent Framework},
year = {2024},
publisher = {GitHub},
url = {https://github.com/synthra/synthra}
}Built with precision for developers who demand reliability.
synthra/
βββ .github/
β βββ workflows/
β β βββ ci.yml # CI/CD pipeline
β βββ ISSUE_TEMPLATE/
β β βββ bug_report.md
β β βββ feature_request.md
β βββ PULL_REQUEST_TEMPLATE.md
β βββ FUNDING.yml
β βββ dependabot.yml
βββ .vscode/
β βββ settings.json # VS Code settings
β βββ extensions.json # Recommended extensions
βββ docs/
β βββ architecture.md # System architecture
β βββ api-reference.md # Complete API docs
β βββ quickstart.md # Getting started guide
β βββ deployment.md # Deployment guide
β βββ faq.md # FAQ
βββ examples/
β βββ basic-usage.ts # Basic examples
β βββ advanced-patterns.ts # Advanced examples
β βββ README.md
βββ src/
β βββ core/
β β βββ agent.ts # Main agent class
β β βββ context-manager.ts # Context management
β β βββ rate-limiter.ts # Rate limiting
β β βββ http-client.ts # HTTP client
β β βββ logger.ts # Structured logging
β βββ errors/
β β βββ index.ts # Error hierarchy
β βββ types/
β β βββ index.ts # TypeScript types
β βββ utils/
β β βββ validation.ts # Input validation
β β βββ helpers.ts # Helper functions
β β βββ performance.ts # Performance utilities
β βββ constants.ts # Global constants
β βββ index.ts # Main exports
βββ tests/
β βββ unit/
β β βββ agent.test.ts
β β βββ validation.test.ts
β β βββ helpers.test.ts
β βββ integration/
β βββ agent-flow.test.ts
βββ public/
β βββ Frame 18.png # Banner image
βββ .editorconfig # Editor configuration
βββ .eslintrc.json # ESLint rules
βββ .gitignore # Git ignore rules
βββ .node-version # Node version
βββ .npmignore # NPM ignore rules
βββ .nvmrc # NVM configuration
βββ .prettierrc # Prettier configuration
βββ CHANGELOG.md # Version history
βββ CONTRIBUTING.md # Contribution guidelines
βββ LICENSE # MIT License
βββ package.json # Package configuration
βββ README.md # This file
βββ SECURITY.md # Security policy
βββ tsconfig.json # TypeScript configuration
βββ vitest.config.ts # Test configuration