Metadata-Version: 2.4
Name: nopeai
Version: 0.1.0
Summary: Tiny, dependency-free permission engine for AI agents.
Project-URL: Homepage, https://github.com/thelexned/nopeai
Project-URL: Repository, https://github.com/thelexned/nopeai
Project-URL: Issues, https://github.com/thelexned/nopeai/issues
License: MIT
License-File: LICENSE
Keywords: ai,authorization,permissions,security
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# nopeai for Python

`nopeai` is a tiny, dependency-free permission engine for AI agents.

## Install

```bash
pip install nopeai
```

## Usage

```python
from nopeai import PermissionDeniedError, createPermissionEngine

engine = createPermissionEngine(
    [
        {
            "role": "agent",
            "action": "call_tool",
            "resource_type": "tool",
            "resource_id": "search",
            "effect": "allow",
        }
    ]
)

agent = {"id": "agent_1", "roles": ["agent"]}
tool = {"type": "tool", "id": "search"}

assert engine.can(agent, "call_tool", tool) is True

try:
    engine.authorize(agent, "call_tool", {"type": "tool", "id": "email"})
except PermissionDeniedError as error:
    print(error.decision["reason"])
```

## Included Examples

```python
from nopeai.examples import examples, sample_agents, sample_resources

assert examples["tools"].can(
    sample_agents["agent"],
    "call_tool",
    sample_resources["search_tool"],
) is True

assert examples["tenant"].can(
    sample_agents["finance"],
    "read",
    sample_resources["invoice"],
) is True
```
