Metadata-Version: 2.4
Name: yantrix-adapters
Version: 1.0.0
Summary: Cross-framework adapters for Yantrix agent infrastructure — LangChain, CrewAI, AutoGen, MCP
Home-page: https://github.com/yantrix-ai/yantrix-adapters
Author: Yantrix AI
Author-email: Yantrix AI <hello@yantrix.ai>
License: MIT
Project-URL: Homepage, https://yantrix.ai
Project-URL: Documentation, https://docs.yantrix.ai
Project-URL: Repository, https://github.com/yantrix-ai/yantrix-adapters
Project-URL: Trace Dashboard, https://trace.yantrix.ai
Project-URL: Issues, https://github.com/yantrix-ai/yantrix-adapters/issues
Keywords: ai agents,langchain,crewai,autogen,mcp,agent governance,policy enforcement,ai infrastructure,yantrix,x402,agent observability
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
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: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.25.0
Provides-Extra: langchain
Requires-Dist: langchain>=0.1.0; extra == "langchain"
Provides-Extra: crewai
Requires-Dist: crewai>=0.28.0; extra == "crewai"
Provides-Extra: autogen
Requires-Dist: pyautogen>=0.2.0; extra == "autogen"
Provides-Extra: mcp
Requires-Dist: mcp>=1.0.0; extra == "mcp"
Provides-Extra: all
Requires-Dist: langchain>=0.1.0; extra == "all"
Requires-Dist: crewai>=0.28.0; extra == "all"
Requires-Dist: pyautogen>=0.2.0; extra == "all"
Requires-Dist: mcp>=1.0.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: requires-python

# yantrix-adapters

Cross-framework adapters for [Yantrix](https://yantrix.ai) agent infrastructure.

Add **policy enforcement, semantic memory, and full audit traces** to any agent framework in 5 lines.

```bash
pip install yantrix-adapters
```

---

## Supported Frameworks

| Framework | Class | Install |
|-----------|-------|---------|
| LangChain | `YantrixToolkit` | `pip install yantrix-adapters[langchain]` |
| CrewAI    | `YantrixCrew`    | `pip install yantrix-adapters[crewai]` |
| AutoGen   | `YantrixAssistantAgent` | `pip install yantrix-adapters[autogen]` |
| MCP       | `YantrixMCPRouter` | `pip install yantrix-adapters[mcp]` |
| All       | —                | `pip install yantrix-adapters[all]` |

---

## LangChain

```python
from langchain.tools import DuckDuckGoSearchRun, WikipediaQueryRun
from yantrix_adapters.langchain import YantrixToolkit

# Before: tools = [DuckDuckGoSearchRun(), WikipediaQueryRun()]
# After:
ytx = YantrixToolkit(api_key="ytx_...", agent_id="research_agent")
tools = ytx.wrap([DuckDuckGoSearchRun(), WikipediaQueryRun()])

# Drop into your existing agent — nothing else changes
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION)
```

Observability-only (no tool replacement):
```python
from yantrix_adapters.langchain import YantrixCallbackHandler

handler = YantrixCallbackHandler(api_key="ytx_...")
agent = initialize_agent(tools, llm, callbacks=[handler])
```

---

## CrewAI

```python
from crewai import Crew, Agent, Task
from yantrix_adapters.crewai import YantrixCrew

researcher = Agent(role="researcher", goal="find information", ...)
writer = Agent(role="writer", goal="write content", ...)
task = Task(description="Research and write about AI trends", ...)

# Before: crew = Crew(agents=[researcher, writer], tasks=[task])
# After:
crew = YantrixCrew.wrap(
    Crew(agents=[researcher, writer], tasks=[task]),
    api_key="ytx_...",
    agent_id="content_crew",
)

result = crew.kickoff()  # Identical call — now governed
```

---

## AutoGen

```python
from yantrix_adapters.autogen import YantrixAssistantAgent, YantrixUserProxy

# Drop-in replacements for AssistantAgent and UserProxyAgent
assistant = YantrixAssistantAgent(
    "assistant",
    ytx_api_key="ytx_...",
    llm_config={"config_list": config_list},
)

user_proxy = YantrixUserProxy(
    "user_proxy",
    ytx_api_key="ytx_...",
    human_input_mode="NEVER",
    code_execution_config={"work_dir": "coding"},
)

user_proxy.initiate_chat(assistant, message="Research OpenAI pricing trends")
```

For GroupChat:
```python
from autogen import GroupChat, GroupChatManager
from yantrix_adapters.autogen import YantrixGroupChat

chat = YantrixGroupChat.wrap(
    GroupChat(agents=[agent1, agent2], messages=[], max_round=10),
    api_key="ytx_...",
)
manager = GroupChatManager(groupchat=chat, llm_config=llm_config)
```

---

## MCP

```python
from mcp.server import Server
from yantrix_adapters.mcp import YantrixMCPRouter

server = Server("my-tools")
router = YantrixMCPRouter(api_key="ytx_...", agent_id="mcp_server")

@server.call_tool()
async def call_tool(name: str, arguments: dict):
    # Route through Yantrix — policy check, memory, trace
    return await router.route(name, arguments, handler=_original_handler)

async def _original_handler(name, arguments):
    # Your existing tool logic here
    ...
```

FastAPI middleware (wraps entire MCP HTTP server):
```python
from fastapi import FastAPI
from yantrix_adapters.mcp import YantrixMCPMiddleware

app = FastAPI()
app.add_middleware(YantrixMCPMiddleware, api_key="ytx_...", agent_id="mcp_server")
```

---

## What happens on every call

```
Your agent action
      ↓
Yantrix Policy Engine  ← is this allowed? within budget?
      ↓ (if allowed)
Yantrix Memory         ← inject relevant past context
      ↓
Original handler       ← your tool/task/agent runs normally
      ↓
Yantrix Trace          ← full audit log stored
      ↓
Result returned
```

All traces visible at **[trace.yantrix.ai](https://trace.yantrix.ai)**.

---

## Configuration

```python
ytx = YantrixToolkit(
    api_key="ytx_...",           # or YANTRIX_API_KEY env var
    agent_id="my_agent",         # or YANTRIX_AGENT_ID env var
    budget_usd=5.0,              # optional daily budget cap
    timeout=30,                  # request timeout seconds
    fallback_on_error=True,      # if True: proceed if Yantrix is unreachable
)
```

`fallback_on_error=True` (default) means your agents keep working even if Yantrix has an outage. Set to `False` for strict enforcement.

---

## Links

- [Yantrix Runtime API](https://runtime.yantrix.ai/docs)
- [Trace Dashboard](https://trace.yantrix.ai)
- [Full Docs](https://docs.yantrix.ai)
- [GitHub](https://github.com/yantrix-ai/yantrix-adapters)
