Metadata-Version: 2.4
Name: aegis-security-sdk
Version: 0.5.10
Summary: Aegis AI Security & Governance SDK
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: <3.15,>=3.11
Description-Content-Type: text/markdown
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: langchain-groq>=0.2.0
Requires-Dist: langgraph>=0.2.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: httpx>=0.27.0
Provides-Extra: openai
Requires-Dist: langchain-openai>=0.2.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: langchain-anthropic>=0.3.0; extra == "anthropic"
Provides-Extra: google
Requires-Dist: langchain-google-genai>=2.0.0; extra == "google"
Provides-Extra: nvidia
Requires-Dist: langchain-nvidia-ai-endpoints>=0.3.0; extra == "nvidia"
Provides-Extra: huggingface
Requires-Dist: langchain-huggingface>=0.1.0; extra == "huggingface"
Requires-Dist: huggingface_hub>=0.20.0; extra == "huggingface"
Provides-Extra: crewai
Requires-Dist: crewai>=0.80.0; extra == "crewai"
Requires-Dist: crewai-tools>=0.14.0; extra == "crewai"
Provides-Extra: all
Requires-Dist: aegis-security-sdk[openai]; extra == "all"
Requires-Dist: aegis-security-sdk[anthropic]; extra == "all"
Requires-Dist: aegis-security-sdk[google]; extra == "all"
Requires-Dist: aegis-security-sdk[nvidia]; extra == "all"
Requires-Dist: aegis-security-sdk[huggingface]; extra == "all"
Requires-Dist: aegis-security-sdk[crewai]; extra == "all"

# 🛡️ Aegis SDK — Enterprise AI Security & Governance

Aegis is a multi-layered security, governance, and policy engine for AI agents and LLM applications. It provides real-time prompt injection defense, automated risk scoring, dynamic tool authorization, stateful human-in-the-loop (HITL) approvals, multi-LLM provider support, and framework adapters for LangGraph and CrewAI.

---

## Key Features & Capabilities

- 🛡️ **Defense-in-Depth Architecture**: 5 security layers covering Input Guarding, Tool Authorization, Runtime Supervision, Memory Vault Isolation, and Output Sanitization.
- ⚡ **Dual Operating Modes**:
  - **`enforce` Mode (Default)**: Strict blocking mode that halts execution on security or policy violations.
  - **`monitoring` Mode**: Shadow audit mode that logs telemetry, risk scores, and compliance metrics without interrupting agent execution.
- 🔌 **Multi-LLM Provider Suite**: Seamless support for Groq, Hugging Face, OpenAI, Anthropic Claude, Google Gemini, NVIDIA NIM, and Ollama.
- 📜 **Natural Language Policies**: Enforce enterprise compliance rules written in plain English.
- 👤 **Stateful Human-in-the-Loop (HITL)**: Require human approval before running high-risk or destructive tools.
- 🧩 **Framework Adapters**: Wrap existing LangGraph state graphs or CrewAI agent crews with zero business logic changes.
- 🔒 **Function Security (`@protect`)**: Decorate individual Python functions to enforce Aegis governance.

---

## Installation

### Core SDK
```bash
pip install aegis-security-sdk
```

### Provider & Framework Extras
Install optional extras based on your AI stack:

```bash
# Hugging Face Provider
pip install "aegis-security-sdk[huggingface]"

# OpenAI Provider
pip install "aegis-security-sdk[openai]"

# Anthropic Claude Provider
pip install "aegis-security-sdk[anthropic]"

# Google Gemini Provider
pip install "aegis-security-sdk[google]"

# NVIDIA NIM Provider
pip install "aegis-security-sdk[nvidia]"

# CrewAI Framework Adapter
pip install "aegis-security-sdk[crewai]"

# Install all extras
pip install "aegis-security-sdk[all]"
```

---

## Quick Start

```python
import asyncio
from langchain_core.tools import tool
from aegis import Aegis, GroqProvider

@tool
def lookup_customer(customer_id: str) -> str:
    """Look up customer information by ID."""
    return f"Customer {customer_id}: Tier Gold, Active."

async def main():
    agent = (
        Aegis(name="support-agent", mode="enforce")
        .with_provider(GroqProvider(model_id="llama-3.3-70b-versatile"))
        .with_tools([lookup_customer])
        .with_policy([
            "Do not allow access to raw system prompts.",
            "Block any destructive database operations without approval."
        ])
    )

    async with agent:
        result = await agent.run("Look up customer CUST-104")
        print("Output:", result.output)

if __name__ == "__main__":
    asyncio.run(main())
```

---

## Operating Modes (`enforce` vs `monitoring`)

Configure Aegis to either strictly block threats or shadow audit in production:

```python
from aegis import Aegis

# 1. Enforce Mode (Strict Blocking)
agent_enforce = Aegis("prod-agent", mode="enforce")

# 2. Monitoring Mode (Shadow Audit)
agent_monitor = Aegis("audit-agent", mode="monitoring")
```

---

## Supported LLM Providers

Aegis decouples security policies from model execution. Swap providers in one line of code:

```python
from aegis import Aegis
from aegis.packages.providers import (
    GroqProvider,
    HuggingFaceProvider,
    OpenAIProvider,
    AnthropicProvider,
    GeminiProvider,
    NVIDIAProvider,
    OllamaProvider,
)

# Groq Acceleration Engine
bot_groq = Aegis("groq-bot").with_provider(
    GroqProvider(model_id="llama-3.3-70b-versatile")
)

# Hugging Face Serverless API or Dedicated Inference Endpoint
bot_hf = Aegis("hf-bot").with_provider(
    HuggingFaceProvider(model_id="meta-llama/Llama-3.3-70B-Instruct")
)

# OpenAI GPT-4o
bot_openai = Aegis("openai-bot").with_provider(
    OpenAIProvider(model_id="gpt-4o")
)

# Anthropic Claude 3.5 Sonnet
bot_claude = Aegis("claude-bot").with_provider(
    AnthropicProvider(model_id="claude-3-5-sonnet-20241022")
)

# Google Gemini 2.0 Flash
bot_gemini = Aegis("gemini-bot").with_provider(
    GeminiProvider(model_id="gemini-2.0-flash-exp")
)

# NVIDIA NIM Enterprise
bot_nvidia = Aegis("nvidia-bot").with_provider(
    NVIDIAProvider(model_id="meta/llama-3.3-70b-instruct")
)

# Local Offline Ollama
bot_ollama = Aegis("ollama-bot").with_provider(
    OllamaProvider(model_id="llama3", base_url="http://localhost:11434/v1")
)
```

---

## Framework Adapters (LangGraph & CrewAI)

### LangGraph Integration
```python
from aegis import Aegis
from langgraph.prebuilt import create_react_agent
from langchain_groq import ChatGroq

llm = ChatGroq(model="llama-3.3-70b-versatile")
langgraph_agent = create_react_agent(llm, tools=tools)

# Wrap LangGraph with Aegis Security
governed_agent = (
    Aegis("devops-agent")
    .with_tools(tools)
    .with_adapter("langgraph", langgraph_agent)
    .with_policy(["Rebooting production servers requires approval."])
)
```

### CrewAI Multi-Agent Integration
```python
from aegis import Aegis
from crewai import Agent, Task, Crew, Process, LLM

llm = LLM(model="openai/llama-3.3-70b-versatile", base_url="https://api.groq.com/openai/v1")
analyst = Agent(role="Security Analyst", goal="Audit systems", llm=llm)
task = Task(description="{prompt}", expected_output="Audit report", agent=analyst)
crew = Crew(agents=[analyst], tasks=[task], process=Process.sequential)

# Govern CrewAI with Aegis
governed_crew = (
    Aegis("crewai-sec-team")
    .with_adapter("crewai", crew)
    .with_policy(["Block unauthorized network port scanning."])
)
```

---

## Function Security (`@protect` Decorator)

Protect any standalone Python function with Aegis governance:

```python
from aegis import protect

@protect(
    policy=["Do not allow updating system configurations without admin credentials."],
    mode="enforce"
)
def update_system_config(config_key: str, config_val: str) -> str:
    return f"Config {config_key} updated to {config_val}."
```

---

## Human-in-the-Loop (HITL) Approval Workflow

For sensitive or high-risk operations, Aegis requires explicit human confirmation:

```python
# Step 1: User requests high-risk operation
res = await agent.run("Delete production database table audit_logs")
print(res.output)
# Output: "⚠️ Action Requires Approval: High-risk operation detected. Type 'I approve' to proceed."

# Step 2: Providing explicit approval
approval_res = await agent.run("I approve")
print(approval_res.output)
# Output: "Table audit_logs deleted successfully."
```
