Metadata-Version: 2.4
Name: lyhna
Version: 0.1.0
Summary: Python SDK for the Lyhna governance API
Project-URL: Homepage, https://www.lyhna.com
Project-URL: Documentation, https://docs.lyhna.com
Project-URL: Repository, https://github.com/lyhna/lyhna-python
Author-email: "Lyhna, Inc." <eng@lyhna.com>
License-Expression: MIT
License-File: LICENSE
Keywords: ai,governance,lyhna,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
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: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: httpx>=0.24
Description-Content-Type: text/markdown

# Lyhna Python SDK

Governance infrastructure for autonomous systems. Every action gets a cryptographic receipt — **APPROVED**, **REFUSED**, or **ESCALATED** — before it executes.

## Install

```bash
pip install lyhna
```

## Quick start

```python
import os
from lyhna import bind

os.environ["LYHNA_API_KEY"] = "lyhna_..."

receipt = bind(
    action_type="deploy_production",
    intent="release_v3",
    authority_tier="tier_2",
    payload={"service": "api"},
)

if receipt.outcome == "APPROVED":
    deploy()
elif receipt.outcome == "ESCALATED":
    notify(receipt.escalate_to)
else:
    log(receipt.outcome_reason)
```

## Explicit client

```python
from lyhna import LyhnaClient

client = LyhnaClient(api_key="lyhna_...", base_url="https://www.lyhna.com")

receipt = client.bind(
    action_type="deploy_production",
    intent="release_v3",
    authority_tier="tier_2",
)
```

## Async

```python
from lyhna import AsyncLyhnaClient

async with AsyncLyhnaClient(api_key="lyhna_...") as client:
    receipt = await client.bind(
        action_type="deploy_production",
        intent="release_v3",
        authority_tier="tier_2",
    )
```

## Verify a receipt

```python
from lyhna import verify_receipt

result = verify_receipt(receipt)
assert result["valid"] is True
```

## Outcomes

| Outcome | Meaning |
|---|---|
| **APPROVED** | Action is authorized — proceed. |
| **REFUSED** | Action is denied — do not proceed. `outcome_reason` explains why. |
| **ESCALATED** | Action requires higher authority. `escalate_to` names who. |

## Errors

| Exception | When |
|---|---|
| `LyhnaAuthError` | 401 or 403 — bad or missing API key. |
| `LyhnaTimeoutError` | Request exceeded timeout. |
| `LyhnaError` | Any other API error. |

## Links

- [Documentation](https://docs.lyhna.com)
- [Dashboard](https://www.lyhna.com)
