Skip to main content

Tiny, dependency-free permission engine for AI agents.

Project description

nopeai for Python

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

Install

pip install nopeai

Usage

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nopeai-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nopeai-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file nopeai-0.1.0.tar.gz.

File metadata

  • Download URL: nopeai-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for nopeai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c7837d21d0b625519d4798aec391fdba08aa5dcc9cfcb7fe44a1379492f02246
MD5 aeb8989e2df8fa9174e20e7bcca8525a
BLAKE2b-256 ad49a82b903ca737e01e2e33e103eda9ca97d49f2deee21a54beeb5854c2d652

See more details on using hashes here.

File details

Details for the file nopeai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nopeai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for nopeai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15532c1327835f480499cf896f73da3d8afbe655d6beee80060036280b7d8812
MD5 62ee5db605dbfe846ef7befeabaa3c16
BLAKE2b-256 fa77a8437add0a89d1b7987a3745e9b243f1acc5249f1ab4a1d17976ca89659c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page