Metadata-Version: 2.4
Name: uagent-a2a-adapter
Version: 0.1.2
Summary: Adapters for integrating A2A agents with uAgents framework
Author-email: gautammanak <gautam.kumar@fetch.ai>
License: Apache-2.0
Project-URL: Homepage, https://github.com/gautammanak1/uagent-a2a-adapter
Project-URL: Repository, https://github.com/gautammanak1/uagent-a2a-adapter
Project-URL: Documentation, https://github.com/gautammanak1/uagent-a2a-adapter#readme
Project-URL: Bug Tracker, https://github.com/gautammanak1/uagent-a2a-adapter/issues
Keywords: uagents,a2a-sdk,ai,agents,adapter,integration
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: uagents
Requires-Dist: httpx>=0.24.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: uvicorn>=0.23.0
Provides-Extra: a2a-sdk
Requires-Dist: a2a-sdk; extra == "a2a-sdk"
Requires-Dist: agno>=0.1.0; extra == "a2a-sdk"
Provides-Extra: langchain
Requires-Dist: langchain>=0.1.0; extra == "langchain"
Requires-Dist: langchain-openai>=0.1.0; extra == "langchain"
Provides-Extra: crewai
Requires-Dist: crewai>=0.1.0; extra == "crewai"
Provides-Extra: mcp
Requires-Dist: mcp>=0.1.0; extra == "mcp"
Provides-Extra: all
Requires-Dist: a2a-sdk; extra == "all"
Requires-Dist: agno>=0.1.0; extra == "all"
Requires-Dist: langchain>=0.1.0; extra == "all"
Requires-Dist: langchain-openai>=0.1.0; extra == "all"
Requires-Dist: crewai>=0.1.0; extra == "all"
Requires-Dist: mcp>=0.1.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: isort>=5.12.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: twine>=4.0.0; extra == "dev"
Requires-Dist: build>=0.10.0; extra == "dev"

## uAgent A2A Adapter

A powerful adapter for integrating A2A (Agent-to-Agent) frameworks with uAgents, enabling seamless communication between different AI agent ecosystems.

## Features

- 🔗 **Seamless Integration**: Connects A2A agents with the uAgents framework.
- 🚀 **Easy Setup**: Simple configuration and deployment process.
- 💬 **Chat Protocol**: Built-in support for agent-to-agent communication.
- 🔄 **Bidirectional Communication**: Supports full-duplex communication between agents.
- 🛡️ **Error Handling**: Robust error handling with fallback mechanisms.



## Installation

### Basic Installation

```bash
pip install uagent-a2a-adapter
```


### With A2A Support

```bash
pip install uagent-a2a-adapter[a2a]
```

### With All Optional Dependencies

```bash
pip install uagent-a2a-adapter[all]
```

## Quick Start

Here's a simple example to get started:

```python
from dotenv import load_dotenv
from your_agent_executor import YourAgentExecutor  # Replace with your executor
from uagent_a2a_adapter import A2AAdapter

# Load environment variables
load_dotenv()

def main():
    # Initialize your agent executor
    executor = YourAgentExecutor()
    
    # Create the adapter
    adapter = A2AAdapter(
        agent_executor=executor,
        name="my_a2a_agent",
        description="My A2A agent with uAgents integration",
        port=8082,
        a2a_port=9997,
        mailbox=True,
        seed="my_agent_seed"
    )
    
    print("🚀 Starting A2A Agent...")
    adapter.run()

if __name__ == "__main__":
    main()
```

## Configuration

### A2AAdapter Parameters

- `agent_executor`: Your A2A agent executor instance.
- `name`: Name of your agent.
- `description`: Description of your agent's capabilities.
- `port`: Port for the uAgent (default: 8000).
- `a2a_port`: Port for the A2A server (default: 9999).
- `mailbox`: Enable mailbox functionality (default: True).
- `seed`: Seed for agent address generation (optional).

## Advanced Usage

### Using the Register Tool

```python
from uagent_a2a_adapter import A2ARegisterTool

tool = A2ARegisterTool()
result = tool.invoke({
    "agent_executor": your_executor,
    "name": "advanced_agent",
    "description": "An advanced A2A agent",
    "port": 8083,
    "a2a_port": 9998,
    "return_dict": True
})

print(f"Agent created: {result}")
```


## Supported Frameworks

The adapter supports integration with various AI frameworks through optional dependencies:

- **A2A**: Core A2A (Agent2Agent Protocol (A2A)) framework support.


## Communication Protocol

The adapter uses the uAgents chat protocol for communication:

1. **Message Reception**: Receives messages via uAgents chat protocol.
2. **A2A Processing**: Forwards messages to A2A agent for processing.
3. **Response Handling**: Returns processed responses through uAgents.
4. **Acknowledgments**: Automatically handles message acknowledgments.

## Error Handling

The adapter includes robust error handling:

- **Connection Failures**: Automatically falls back to direct executor calls.
- **Timeout Handling**: Configurable timeouts for HTTP requests.
- **Error Messages**: Detailed error messages for debugging.
- **Graceful Degradation**: Continues operation during partial failures.

## Development

### Setting up Development Environment

```bash
# Clone the repository
git clone https://github.com/gautammanak1/uagent-a2a-adapter.git
cd uagent-a2a-adapter

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest

# Format code
black .
isort .

# Type checking
mypy uagent_a2a_adapter
```

### Running Tests

```bash
# Run all tests
pytest

# Run with coverage
pytest --cov=uagent_a2a_adapter

# Run specific test file
pytest tests/test_adapter.py
```

## Contributing

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

1. Fork the repository.
2. Create a feature branch.
3. Make your changes.
4. Add tests.
5. Submit a pull request.

## License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.

## Changelog

See [CHANGELOG.md](CHANGELOG.md) for version history and changes.

## Support

- **Issues**: [GitHub Issues](https://github.com/gautammanak1/uagent-a2a-adapter/issues)
<!-- - **Discussions**: [GitHub Discussions](https://github.com/gautammanak1/uagent-a2a-adapter/discussions) -->
- **Email**: gautam.kumar@fetch.ai

## Acknowledgments

- [uAgents](https://github.com/fetchai/uAgents) - The underlying agent framework.
- [A2A](https://github.com/a2aproject/a2a-python) - Agent-to-Agent communication protocol.
- [Fetch.ai](https://fetch.ai) - For foundational agent technologies.
```
