# 🧠 Synapse — Multi-Agent Bridge SDK

Connect AI agents together. Route messages between Claude, GPT, Groq, Gemini and more.

## Install

```bash
pip install synapse-bridge
```

## Quick Start

```python
from synapse import Agent, Bridge

# Define agents
researcher = Agent("researcher", provider="groq", model="llama-3.3-70b-versatile")
writer     = Agent("writer",     provider="groq", model="mixtral-8x7b-32768")

# Connect them
bridge = Bridge([researcher, writer])

# Run a task — agents collaborate automatically
result = bridge.run("Explain quantum computing simply")

print(result.final)          # Final answer
print(result.summary())      # Full agent trace
```

## Supported Providers

| Provider   | Models                        | API Key Env Var     |
|------------|-------------------------------|---------------------|
| `groq`     | llama-3.3-70b, mixtral        | `GROQ_API_KEY`      |
| `openai`   | gpt-4o, gpt-3.5-turbo         | `OPENAI_API_KEY`    |
| `anthropic`| claude-sonnet, claude-haiku   | `ANTHROPIC_API_KEY` |
| `gemini`   | gemini-1.5-flash, gemini-pro  | `GEMINI_API_KEY`    |

## Agent

```python
agent = Agent(
    name="my_agent",
    provider="groq",              # groq / openai / anthropic / gemini
    model="llama-3.3-70b-versatile",  # optional, uses default if not set
    api_key="gsk_...",            # optional, reads from env var if not set
    system_prompt="You are..."    # optional custom persona
)
```

## Bridge

```python
bridge = Bridge(
    agents=[agent_a, agent_b],   # agents run in this order
    memory=True,                  # share context between agents
    verbose=True                  # print progress
)

# Sequential pipeline — each agent builds on the previous
result = bridge.run("Your task")

# Direct agent-to-agent message
response = bridge.send(
    from_agent="researcher",
    to_agent="writer",
    message="Here is my research..."
)

# Add/remove agents dynamically
bridge.add_agent(new_agent)
bridge.remove_agent("agent_name")
```

## BridgeResult

```python
result.final          # Final answer string
result.agents_used    # ["researcher", "writer"]
result.trace          # List of TraceStep objects
result.summary()      # Pretty printed full trace
```

## Mix Different Providers

```python
from synapse import Agent, Bridge

claude  = Agent("analyst",  provider="anthropic", model="claude-sonnet-4-20250514")
gpt     = Agent("coder",    provider="openai",    model="gpt-4o")
llama   = Agent("reviewer", provider="groq",      model="llama-3.3-70b-versatile")

bridge = Bridge([claude, gpt, llama], verbose=True)
result = bridge.run("Build and review a Python REST API")
```

## Run Examples

```bash
# Set your API key
export GROQ_API_KEY=your_key_here   # Mac/Linux
set GROQ_API_KEY=your_key_here      # Windows

# Basic 2-agent example
python examples/basic.py

# Multi-agent pipeline + direct messaging
python examples/multi_agent.py
```
