Metadata-Version: 2.4
Name: secureai-sdk
Version: 1.2.0
Summary: Enterprise AI Security, GrokBot & Autonomous Agent Runtime Firewall, In-Process Guardrails, Model Vulnerability Scanner & Reversible PII Vault SDK by AcadmyAI
Author-email: AcadmyAI <acadmyaiorg@gmail.com>
License: Apache-2.0
Project-URL: Homepage, https://secure.acadmyai.com
Project-URL: Documentation, https://secure.acadmyai.com/docs
Project-URL: Repository, https://github.com/nickmudit/secure_acadmyai
Project-URL: Bug Tracker, https://github.com/nickmudit/secure_acadmyai/issues
Keywords: ai-security,guardrails,prompt-injection,grok-bot,agent-firewall,mcp-guard,modelscan,pii-masking,ai-governance,llm-firewall
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
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: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Security
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.20.0; extra == "dev"
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: twine>=4.0.0; extra == "dev"
Dynamic: license-file

# SecureAI Python SDK (`secureai-sdk`)

[![PyPI Version](https://img.shields.io/pypi/v/secureai-sdk.svg)](https://pypi.org/project/secureai-sdk/)
[![Python Versions](https://img.shields.io/pypi/pyversions/secureai-sdk.svg)](https://pypi.org/project/secureai-sdk/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Website](https://img.shields.io/badge/Website-secure.acadmyai.com-cyan)](https://secure.acadmyai.com)

**SecureAI** is the enterprise cybersecurity armor for Large Language Models (LLMs), AI coding agents, and autonomous multi-agent workflows. Powered by **AcadmyAI** (https://secure.acadmyai.com).

---

## Key Capabilities

1. **Sub-0.5ms In-Process Guardrails (`@guard`)**: Intercepts direct prompt injection, DAN jailbreaks, synthetic delimiters, and toxic content in-memory before reaching LLMs.
2. **Autonomous Agent Runtime Action Firewall (`intercept_agent_action`)**: Intercepts filesystem reads/writes (`.env`, credentials), shell command executions (`rm -rf`, `curl | sh`), and outbound network egress (SSRF). Automatically rewrites dangerous commands into secure sandboxed operations.
3. **MLSecOps Model Vulnerability Scanner (`scan_model_artifact`)**: Scans serialized ML model artifacts (`.pkl`, `.pt`, `.safetensors`, `.onnx`) to detect remote code execution opcodes (`__reduce__`, `eval`, `exec`, `subprocess.Popen`) and trojans.
4. **Reversible Zero-Knowledge PII Vault (`tokenize_pii` / `detokenize_pii`)**: Redacts SSNs, credit cards, emails, passwords, and API keys with AES-256 synthetic surrogate tokens upstream.
5. **Model Context Protocol (MCP) Governance (`authorize_mcp_tool`)**: AST parameter sanitization for Claude Desktop, Cursor, and custom agent tool calls.
6. **Automated AI Red Teaming (`run_redteam_simulation`)**: Automated adversarial vulnerability testing across OWASP LLM01–LLM10.
7. **Canary Honeytoken Deception (`generate_canary_token` / `verify_canary_leakage`)**: Injects signed honeytokens to detect system prompt extraction.
8. **Compliance Reporting (`get_compliance_report`)**: Audit-ready mapping for the EU AI Act (2025) and ISO/IEC 42001.

---

## Installation

```bash
pip install --upgrade secureai-sdk
```

---

## Quickstart

### 1. Function Decorator (`@guard`)
```python
import secureai
from secureai import guard, SecurityPolicy

# Optional: Connect to SecureAI Gateway for real-time SIEM & console telemetry
secureai.init(api_key="sec_live_your_key_here") # or export SECUREAI_API_KEY="sec_live_..."

# Sub-0.5ms local inspection + PII tokenization
@guard(policy=SecurityPolicy.STRICT, user_context={"role": "analyst", "dept": "finance"})
def generate_response(prompt: str) -> str:
    # Prompt is verified safe and PII is vaulted before entering function
    return "Safe model response"
```

### 2. Centralized Gateway Client (`SecureAI`)
```python
from secureai import SecureAI

client = SecureAI(
    api_key="sec_live_your_key_here",
    base_url="https://secure.acadmyai.com/v1"
)

# 1. Prompt Inspection
report = client.inspect(prompt="Verify risk posture")
print("Verdict:", report["action"], "Risk:", report["injection_scan"]["risk_score"])

# 2. Autonomous Agent Runtime Action Firewall
# Intercepts agent shell commands, blocks reverse shells, and safely rewrites destructive operations
res = client.intercept_agent_action(
    action_type="EXECUTE_SHELL",
    command="rm -rf /var/log/app/* && echo 'Cleaned'"
)
print("Decision:", res["verdict"]) # "REWRITE_SAFE"
print("Safe Command:", res["rewritten_command"]) # "rm -rf ./scratch/sandbox_tmp/* && echo 'Cleaned'"

# 3. Model File Vulnerability Scanner (Protect AI style)
scan = client.scan_model_artifact(
    filename="weights.pkl",
    raw_content="cos\nsystem\n(S'rm -rf /'\ntR."
)
print("Model Safe:", scan["is_safe"], "Threats:", scan["malicious_opcodes"])

# 4. Zero-Knowledge PII Vault
vaulted = client.tokenize_pii("Contact user with SSN 123-45-6789")
print("Sanitized:", vaulted["sanitized_text"])
```

### 3. Asynchronous Client (`AsyncSecureAI`)
```python
import asyncio
from secureai import AsyncSecureAI

async def main():
    async with AsyncSecureAI(api_key="sec_live_...") as client:
        report = await client.inspect("Analyze portfolio")
        print("Report:", report["is_safe"])

asyncio.run(main())
```

---

## Zero-Code Reverse Proxy
Point any standard OpenAI SDK application to SecureAI without modifying your codebase:

```bash
export OPENAI_BASE_URL="https://secure.acadmyai.com/v1"
export OPENAI_API_KEY="sec_live_your_key_here"
```

```python
from openai import OpenAI

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello SecureAI"}]
)
print(response.choices[0].message.content)
```

---

## Documentation & Support
- **Official Portal**: https://secure.acadmyai.com
- **API Documentation**: https://secure.acadmyai.com/docs
- **Trust Center**: https://secure.acadmyai.com/whitepaper
- **PyPI Package**: https://pypi.org/project/secureai-sdk/
