Metadata-Version: 2.4
Name: leafmesh
Version: 2.1.51
Summary: LeafMesh — YAML-native multi-agent orchestration platform
Author-email: LeafCraft <koushik@leafcraftstudios.com>
Maintainer-email: LeafCraft <koushik@leafcraftstudios.com>
License: LicenseRef-Proprietary
Project-URL: Homepage, https://github.com/LeafCraftStudios/LeafMesh
Project-URL: Repository, https://github.com/LeafCraftStudios/LeafMesh.git
Project-URL: Documentation, https://github.com/LeafCraftStudios/LeafMesh/blob/main/README.md
Project-URL: Bug Tracker, https://github.com/LeafCraftStudios/LeafMesh/issues
Keywords: multi-agent,ai,orchestration,leafmesh,leafcraft,adk,swarm,human-in-the-loop,llm,automation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Framework :: AsyncIO
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: pydantic<3.0.0,>=2.0.0
Requires-Dist: redis>=5.0.0
Requires-Dist: PyYAML>=6.0.0
Requires-Dist: openai>=1.0.0
Requires-Dist: structlog>=23.0.0
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: requests>=2.28.0
Requires-Dist: certifi>=2023.0.0
Requires-Dist: composio-core>=0.5.0
Requires-Dist: Pillow<13.0,>=11.0
Requires-Dist: motor>=3.3.0
Requires-Dist: anthropic>=0.25.0
Requires-Dist: google-genai>=1.0.0
Requires-Dist: boto3>=1.28.0
Requires-Dist: google-auth>=2.0.0
Requires-Dist: opentelemetry-api>=1.21.0
Requires-Dist: opentelemetry-sdk>=1.21.0
Requires-Dist: opentelemetry-exporter-otlp>=1.21.0
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.21.0
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.21.0
Requires-Dist: opentelemetry-instrumentation>=0.42b0
Requires-Dist: opentelemetry-instrumentation-redis>=0.42b0
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.42b0
Requires-Dist: opentelemetry-instrumentation-requests>=0.42b0
Requires-Dist: opentelemetry-instrumentation-aiohttp-client>=0.42b0
Requires-Dist: opentelemetry-instrumentation-logging>=0.42b0
Requires-Dist: opentelemetry-instrumentation-system-metrics>=0.42b0
Requires-Dist: opentelemetry-semantic-conventions>=0.42b0
Provides-Extra: crewai
Requires-Dist: crewai>=0.41.0; extra == "crewai"
Provides-Extra: langgraph
Requires-Dist: langgraph>=0.0.40; extra == "langgraph"
Provides-Extra: autogen
Requires-Dist: pyautogen>=0.2.0; extra == "autogen"
Provides-Extra: a2a
Requires-Dist: a2a-sdk>=0.2.0; extra == "a2a"
Provides-Extra: mcp
Requires-Dist: mcp>=1.0.0; extra == "mcp"
Provides-Extra: composio
Requires-Dist: composio-core>=0.5.0; extra == "composio"
Provides-Extra: zapier
Requires-Dist: httpx>=0.25.0; extra == "zapier"
Provides-Extra: slack
Requires-Dist: slack-sdk>=3.27.0; extra == "slack"
Provides-Extra: telegram
Requires-Dist: python-telegram-bot>=21.0; extra == "telegram"
Provides-Extra: teams
Requires-Dist: botframework-connector>=4.16.0; extra == "teams"
Provides-Extra: discord
Requires-Dist: pynacl>=1.5.0; extra == "discord"
Provides-Extra: kafka
Requires-Dist: aiokafka>=0.10.0; extra == "kafka"
Provides-Extra: sqs
Requires-Dist: aioboto3>=12.0.0; extra == "sqs"
Provides-Extra: mqtt
Requires-Dist: asyncio-mqtt>=0.16.2; extra == "mqtt"
Provides-Extra: imap
Requires-Dist: aioimaplib>=1.1.0; extra == "imap"
Provides-Extra: listeners
Requires-Dist: aiokafka>=0.10.0; extra == "listeners"
Requires-Dist: aioboto3>=12.0.0; extra == "listeners"
Requires-Dist: asyncio-mqtt>=0.16.2; extra == "listeners"
Requires-Dist: aioimaplib>=1.1.0; extra == "listeners"
Provides-Extra: email
Requires-Dist: aiosmtplib>=3.0; extra == "email"
Requires-Dist: talon>=1.6.0; extra == "email"
Provides-Extra: channels
Requires-Dist: slack-sdk>=3.27.0; extra == "channels"
Requires-Dist: python-telegram-bot>=21.0; extra == "channels"
Requires-Dist: botbuilder-core>=4.16.0; extra == "channels"
Requires-Dist: botframework-connector>=4.16.0; extra == "channels"
Requires-Dist: pynacl>=1.5.0; extra == "channels"
Requires-Dist: aiosmtplib>=3.0; extra == "channels"
Requires-Dist: talon>=1.6.0; extra == "channels"
Provides-Extra: knowledge-mongo
Provides-Extra: knowledge-postgres
Requires-Dist: asyncpg>=0.29.0; extra == "knowledge-postgres"
Provides-Extra: knowledge-pinecone
Requires-Dist: pinecone-client>=3.0.0; extra == "knowledge-pinecone"
Provides-Extra: knowledge-docs
Requires-Dist: PyPDF2>=3.0.0; extra == "knowledge-docs"
Requires-Dist: python-docx>=1.0.0; extra == "knowledge-docs"
Provides-Extra: knowledge
Requires-Dist: motor>=3.3.0; extra == "knowledge"
Requires-Dist: asyncpg>=0.29.0; extra == "knowledge"
Requires-Dist: pinecone-client>=3.0.0; extra == "knowledge"
Requires-Dist: PyPDF2>=3.0.0; extra == "knowledge"
Requires-Dist: python-docx>=1.0.0; extra == "knowledge"
Provides-Extra: connectors
Requires-Dist: crewai>=0.41.0; extra == "connectors"
Requires-Dist: langgraph>=0.0.40; extra == "connectors"
Requires-Dist: pyautogen>=0.2.0; extra == "connectors"
Requires-Dist: a2a-sdk>=0.2.0; extra == "connectors"
Requires-Dist: mcp>=1.0.0; extra == "connectors"
Requires-Dist: composio-core>=0.5.0; extra == "connectors"
Requires-Dist: httpx>=0.25.0; extra == "connectors"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-mock>=3.10.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"
Dynamic: license-file

# LeafMesh — Multi-Agent AI Orchestration Platform

[![License: Commercial](https://img.shields.io/badge/License-Commercial-red.svg)](LICENSE)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![Version](https://img.shields.io/badge/version-1.0.0-green.svg)](https://github.com/LeafCraftStudios/LeafMesh/releases)
[![Redis](https://img.shields.io/badge/Redis-5.0+-red.svg)](https://redis.io/)

> **YAML-native multi-agent AI platform with self-healing and evolutionary capabilities**

LeafMesh transforms multi-agent AI development through declarative YAML configuration that becomes executable intelligence. Built on the MANAGED_MESH architecture with production-ready coordination and persistence.

## Core Features

- **YAML-Native Intelligence** - Zero-code agent creation with AST-parsed configuration
- **Built-in Coordination** - Manager and Summarizer agents provide automatic oversight
- **MANAGED_MESH Architecture** - Direct agent communication with conditional routing
- **Redis-Powered Persistence** - Automatic session management and conversation history
- **Enterprise Tool Ecosystem** - 15+ built-in tools with OpenAI-compatible function calling
- **Advanced Parallel Processing** - Multi-session threading with intelligent coordination

### Production Features

- **Self-Healing Networks** - 6 autonomous healing actions with failure detection
- **Evolutionary Optimization** - Genetic algorithms with real fitness testing
- **Adaptive Model Intelligence** - ML-powered model selection with performance prediction

---

## Quick Start

### 1. Installation

```bash
pip install leafmesh
```

### 2. Environment Setup

```bash
# Required: OpenAI API key
export OPENAI_API_KEY="your-openai-key"

# Optional: Additional providers
export ANTHROPIC_API_KEY="your-anthropic-key"
export GOOGLE_API_KEY="your-google-key"
```

### 3. Redis Setup

**Local Redis:**

```bash
# macOS
brew install redis && brew services start redis

# Ubuntu/Debian
sudo apt install redis-server && sudo systemctl start redis

# Docker
docker run -d -p 6379:6379 redis:alpine
```

### 4. Basic Usage

```python
from leafmesh import LeafMesh

# Initialize from YAML configuration
sdk = LeafMesh.from_yaml("config.yaml")

# Start the mesh
await sdk.start()

# Process requests
response = await sdk.process_request(
    session_id="user_session",
    input_data={"message": "Hello, how can you help me?"}
)

print(response)
```

**Example YAML Configuration:**

```yaml
name: "my_mesh"
architecture: "managed_mesh"

# Built-in coordination
manager:
  enabled: true
  model: "gpt-4o"

summarizer:
  enabled: true
  model: "gpt-4o-mini"

# User-defined agents
agents:
  conversation_agent:
    name: "conversation_agent"
    model: "gpt-4o-mini"
    prompt: "You are a helpful AI assistant."
    yields:
      response: "string"
      confidence: "number"
    tools: ["calculator", "current_time"]
```

---

## Architecture Overview

LeafMesh implements a **MANAGED_MESH** architecture with:

- **LLM Agents** - YAML-defined with optional Python enhancement
- **Manager Agent** - Built-in coordination and rule enforcement
- **Summarizer Agent** - Omnipresent monitoring and analysis
- **Redis Persistence** - Automatic session and conversation storage
- **Event System** - All communication flows through events
- **Tool System** - OpenAI-compatible function calling

**For detailed architecture information, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)**

---

## Agent Enhancement

Add Python logic to YAML-defined agents:

```python
@sdk.intelligence("conversation_agent")
async def enhance_conversation(llm_response, input_data, context):
    """Add business logic to agent responses"""

    # Access conversation history
    history = context.get("conversation_history", [])

    # Enhance the LLM response
    enhanced_response = add_context(llm_response, history)

    # Trigger other agents conditionally
    if needs_specialist(enhanced_response):
        await sdk.trigger_agents(data={"analysis": enhanced_response})

    return {
        "response": enhanced_response,
        "confidence": calculate_confidence(enhanced_response)
    }
```

---

## Revolutionary Features

### Self-Healing Networks

```python
# Enable automatic failure recovery
await sdk.enable_self_healing()

# Monitor agent health
health = await sdk.get_agent_health_status()
stats = await sdk.get_healing_statistics()
```

### Evolutionary Optimization

```python
# Optimize mesh configuration automatically
test_scenarios = [
    {"input": "Test case 1", "agents": ["conversation_agent"]},
    {"input": "Test case 2", "agents": ["technical_agent"]}
]

best_genome = await sdk.evolve_swarm_architecture(test_scenarios)
await sdk.apply_evolved_configuration()
```

### Adaptive Model Selection

```python
# Automatic model selection based on request characteristics
response = await sdk.adaptive_execute(
    prompt="Analyze this complex scenario",
    preferred_models=["gpt-4o", "claude-3.5-sonnet"]
)
```

---

## Documentation

- **[Architecture Guide](docs/ARCHITECTURE.md)** - Technical implementation details
- **[Debugging Guide](docs/DEBUGGING.md)** - Troubleshooting and monitoring
- **Getting Started** - Run `create-leafmesh my-project` to scaffold a complete example project

---

## Use Cases

LeafMesh excels at:

- **Customer Service Systems** - Multi-tier workflows with self-healing
- **Data Analysis Pipelines** - Collaborative analytical workflows
- **Content Creation** - Coordinated writing and editing
- **Decision Support** - Complex decision-making with oversight
- **Workflow Automation** - Business process automation

---

## Framework Comparison

| Feature                       | LeafMesh           | LangGraph  | CrewAI     | AutoGen    |
| ----------------------------- | ------------------ | ---------- | ---------- | ---------- |
| **YAML Configuration**        | Primary            | Code-based | Code-based | Code-based |
| **Built-in Coordination**     | Manager/Summarizer | Manual     | Manual     | Manual     |
| **Auto-Persistence**          | Redis              | Manual     | Manual     | Manual     |
| **Self-Healing**              | Production         | None       | None       | None       |
| **Evolutionary Optimization** | Genetic Algorithm  | None       | None       | None       |

---

## Licensing

**LeafMesh is commercial software owned by LeafCraft.**

- **Evaluation**: 30-day free evaluation for research/development
- **Commercial**: Requires valid commercial license for revenue-generating use
- **Enterprise**: Custom enterprise licensing available

**Licensing**: info@leafcraftstudios.com

---

## Getting Started

1. **[Install LeafMesh](#installation)** and set up Redis
2. **Create your first YAML configuration** with basic agents
3. **[Add Python enhancements](#agent-enhancement)** for custom logic
4. **[Enable revolutionary features](#revolutionary-features)** for production

**LeafMesh: Production-ready multi-agent AI with YAML-driven simplicity**

---

**Copyright 2025 LeafCraft. All rights reserved.**
