Metadata-Version: 2.4
Name: autogen-agentmail
Version: 0.1.0
Summary: Official AgentMail integration for AutoGen/AG2
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: agentmail-to>=0.1.0
Requires-Dist: autogen-agentchat>=0.4.0
Requires-Dist: httpx>=0.25.0

# AutoGen + AgentMail

Official AgentMail integration for [AutoGen / AG2](https://github.com/microsoft/autogen). Give your agents real email inboxes — send, receive, reply, forward, and organize messages via the AgentMail API.

## Install

```bash
pip install autogen-agentmail
```

## Quick Start

### 1. Set your API key

```bash
export AGENTMAIL_API_KEY=your_key_here
```

### 2. Create an inbox for your agent

```python
from autogen_agentmail import create_inbox

inbox = create_inbox(name="My Agent")
print(inbox["email"])  # e.g. agent-abc123@agentmail.to
```

### 3. Send an email

```python
from autogen_agentmail import send_email

send_email(
    to="bob@example.com",
    subject="Hello from my agent",
    body="This is an automated message.",
    from_inbox_id=inbox["id"],
)
```

### 4. Wait for a reply

```python
from autogen_agentmail import wait_for_message

msg = wait_for_message(inbox_id=inbox["id"], timeout=60)
print(msg["body"])
```

### 5. Register all tools with an AutoGen agent

```python
import autogen
from autogen_agentmail import register_agentmail_tools

agent = autogen.ConversableAgent(
    name="EmailBot",
    llm_config={"config_list": [{"model": "gpt-4o"}]},
)

register_agentmail_tools(agent)
# Agent can now create_inbox, send_email, list_messages, etc.
```

## Available Tools

| Tool | Description |
|------|-------------|
| `create_inbox` | Create a new email inbox |
| `send_email` | Send an email from an inbox |
| `list_messages` | List messages in an inbox |
| `get_message` | Get a single message by ID |
| `reply_to_email` | Reply to a message |
| `forward_email` | Forward a message to another recipient |
| `wait_for_message` | Long-poll for new messages |
| `search_messages` | Search messages by keyword |
| `create_label` | Create a label/tag |
| `apply_label` | Apply a label to a message |
| `delete_inbox` | Delete an inbox and its messages |

## Example

See [`example.py`](src/autogen_agentmail/example.py) for a full demo of two agents communicating via email with inboxes, send, wait, and cleanup.

## Configuration

| Variable | Description | Default |
|----------|-------------|---------|
| `AGENTMAIL_API_KEY` | Your AgentMail API key | — |
| `api_key` param | Per-call override | env var |
| `base_url` param | Custom API base URL | `https://api.agentmail.to` |

## License

MIT
