Metadata-Version: 2.4
Name: lelu-agent-auth-sdk
Version: 0.4.1
Summary: Python SDK for Lelu — framework-agnostic authorization engine for AI agents with confidence-aware controls, Docker deployment, and human-in-the-loop workflows
Project-URL: Homepage, https://lelu-ai.com/
Project-URL: Repository, https://github.com/lelu-ai/lelu
Author-email: Abenezer Getachew <abenezer.getachew@lelu-ai.com>
Maintainer: Abenezer Getachew
License: MIT
Keywords: ai-agents,audit-trail,auth,authorization,crewai,docker,fastapi,human-in-the-loop,langchain,langgraph,permissions,policy-engine,risk-evaluation
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.7.0
Provides-Extra: dev
Requires-Dist: mypy>=1.10.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
Requires-Dist: pytest>=8.2.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.111.0; extra == 'fastapi'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2.0; extra == 'langchain'
Provides-Extra: langgraph
Requires-Dist: langgraph>=0.1.0; extra == 'langgraph'
Description-Content-Type: text/markdown

# Lelu · Python SDK

Python client for [Lelu](https://github.com/lelu-ai/lelu) — the confidence-aware authorization engine for autonomous AI agents.

**Author:** Abenezer Getachew  
**Maintainer:** [Abenezer Getachew](https://github.com/Abenezer0923)

## Installation

```bash
pip install lelu-agent-auth-sdk
```

## Quick start

### Option 1: Zero-config local (recommended)

Run the local engine once — it self-generates its key and policy in `~/.lelu`,
no account needed:

```bash
npx -y lelu-mcp start
```

Then create one shared instance and import it everywhere. With no arguments,
`lelu()` discovers that engine automatically:

```python
import asyncio
from lelu import lelu

auth = lelu(actor="invoice_bot")   # zero-config: finds the local engine

async def main():
    result = await auth.authorize(tool="invoice:create")
    if result.decision == "allow":
        ...  # proceed
    elif result.decision == "human_review":
        ...  # queued — agent pauses, awaiting approval
    else:
        raise PermissionError(result.reason)

asyncio.run(main())
```

The instance exposes the full client as `auth.api` (tokens, review queue,
audit, policies): `await auth.api.mint_token(...)`.

### Option 2: Self-hosted or cloud engine

Point the same factory at any engine with explicit config — or set
`LELU_BASE_URL` / `LELU_API_KEY` and keep calling `lelu()` with no arguments:

```python
auth = lelu(
    base_url="https://your-engine.example.com",
    api_key=os.environ["LELU_API_KEY"],
    actor="invoice_bot",
)
```

`LeluClient(...)` from earlier versions keeps working unchanged — `auth.api`
is that same client.

## API

| Method | Description |
|---|---|
| `agent_authorize(req)` | Confidence-aware agent authorization |
| `authorize(req)` | Human RBAC authorization |
| `mint_token(req)` | Mint a JIT-scoped JWT |
| `revoke_token(token_id)` | Revoke a token immediately |
| `is_healthy()` | Health-check the engine |

## License

MIT
