# vorim

Official Python SDK for [Vorim AI](https://vorim.ai) — the identity, permissions, and audit layer for AI agents.

## Install

```bash
pip install vorim
```

With framework integrations:

```bash
pip install vorim[langchain]    # LangChain / LangGraph
pip install vorim[crewai]       # CrewAI
pip install vorim[openai]       # OpenAI Agents SDK
pip install vorim[all]          # All integrations
```

## Quick Start

```python
from vorim import Vorim

vorim = Vorim(api_key="agid_sk_live_...")

# Register an agent
result = vorim.register(
    name="invoice-processor",
    capabilities=["read_documents", "extract_data"],
    scopes=["agent:read", "agent:execute"],
)

# Check permissions (<5ms via Redis)
check = vorim.check(result.agent.agent_id, "agent:execute")

# Emit audit event
vorim.emit(
    agent_id=result.agent.agent_id,
    event_type="tool_call",
    action="process_invoice",
    result="success",
)
```

## Async

```python
from vorim import AsyncVorim

async with AsyncVorim(api_key="agid_sk_live_...") as vorim:
    result = await vorim.register(
        name="my-agent",
        capabilities=["search"],
        scopes=["agent:read"],
    )
```

## LangChain Integration

```python
from vorim import Vorim
from vorim.integrations.langchain import vorim_tool, VorimCallbackHandler

vorim = Vorim(api_key="agid_sk_live_...")

@vorim_tool(vorim, agent_id="agid_acme_...", permission="agent:execute")
def search(query: str) -> str:
    """Search documents."""
    return f"Results for {query}"

# Use as a standard LangChain tool with built-in permission checks + audit
```

## CrewAI Integration

```python
from vorim import Vorim
from vorim.integrations.crewai import register_crew

vorim = Vorim(api_key="agid_sk_live_...")

crew = register_crew(vorim, {
    "crew_name": "content-pipeline",
    "members": [
        {
            "role": "researcher",
            "name": "crew-researcher",
            "capabilities": ["web_search"],
            "scopes": ["agent:read", "agent:execute"],
        },
    ],
})
```

## OpenAI Integration

```python
from openai import OpenAI
from vorim import Vorim
from vorim.integrations.openai_agents import VorimToolRegistry

vorim = Vorim(api_key="agid_sk_live_...")
client = OpenAI()

registry = VorimToolRegistry(vorim=vorim, agent_id="agid_acme_...")
registry.add(
    name="search",
    description="Search documents",
    parameters={"type": "object", "properties": {"query": {"type": "string"}}},
    execute=lambda args: f"Results for {args['query']}",
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Search for AI papers"}],
    tools=registry.to_openai_tools(),
)

tool_messages = registry.execute_tool_calls(
    response.choices[0].message.tool_calls or []
)
```

## License

MIT
