Content
# Agent2Agent (A2A) Framework
A TypeScript framework for building agent-to-agent communication systems in the crypto and blockchain domain.
## Overview
The Agent2Agent (A2A) Framework provides a robust foundation for building systems where autonomous agents can communicate, discover each other, and coordinate activities. While originally designed for crypto trading and monitoring use cases, the framework is flexible enough to support various agent-based architectures.
## Features
- **Agent Management**: Create, manage, and coordinate different types of agents
- **Protocol Support**: Flexible communication protocols including HTTP/REST
- **Message Passing**: Secure and typed message format for inter-agent communication
- **Discovery Mechanism**: Registry for agent discovery and capability advertisement
- **Task Management**: Built-in task creation, tracking, and completion
- **Storage Interface**: Pluggable storage backends for persistence
- **Crypto Agent**: Specialized agent for cryptocurrency monitoring and analysis
- **Event System**: Rich event system for reacting to agent activities
## Installation
```bash
npm install a2a-framework
```
## Quick Start
```typescript
import { A2AFramework, CryptoAgent, HttpProtocol } from 'a2a-framework';
// Initialize the framework
const framework = new A2AFramework();
await framework.initialize();
// Create a crypto agent
const agent = new CryptoAgent('BitcoinMonitor');
// Register the agent with the framework
await framework.registerAgent(agent);
// Create an HTTP protocol for the agent using the server repository
await framework.createProtocolForAgent(
agent.getId(),
'http',
{
url: 'https://api.example.com',
authMethod: 'API_KEY',
apiKey: 'your-api-key'
}
);
// Connect the agent
await agent.connect();
// Start price updates
agent.startPriceUpdates();
// Discover other agents
const otherAgents = await framework.discoverAgents({
type: 'crypto',
capabilities: ['trading-signals']
});
console.log(`Found ${otherAgents.length} compatible trading agents`);
// Shutdown when done
await framework.shutdown();
```
## Architecture
The A2A Framework is built around several core components:
- **Agents**: Autonomous entities with specific capabilities
- **Protocols**: Communication mechanisms between agents
- **Messages**: Structured data exchanged between agents
- **Registry**: Service discovery and capability advertisement
- **Storage**: Persistence layer for agent data
- **Framework**: Main coordination point for the system
## Agent Types
The framework includes the following agent types:
- **BaseAgent**: Abstract base class for all agents
- **CryptoAgent**: Specialized agent for cryptocurrency monitoring and analysis
## Protocols
Communication protocols included:
- **BaseProtocol**: Abstract base class for all protocols
- **HttpProtocol**: HTTP/REST-based communication
## Storage
Storage backends included:
- **MemoryStorage**: In-memory storage suitable for development
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the LICENSE file for details.