Metadata-Version: 2.4
Name: openclay
Version: 0.1.0
Summary: The Secure-by-Default Execution Framework for LLM Agents.
Home-page: https://github.com/neuralchemy/openclay
Author: Neuralchemy
Classifier: Development Status :: 3 - Alpha
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
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: ahocorasick-rs
Requires-Dist: pyahocorasick
Requires-Dist: tiktoken
Requires-Dist: huggingface-hub
Requires-Dist: tqdm
Provides-Extra: ml
Requires-Dist: xgboost; extra == "ml"
Requires-Dist: scikit-learn; extra == "ml"
Requires-Dist: numpy; extra == "ml"
Requires-Dist: pandas; extra == "ml"
Provides-Extra: embed
Requires-Dist: sentence-transformers; extra == "embed"
Requires-Dist: torch; extra == "embed"
Provides-Extra: search
Requires-Dist: duckduckgo-search; extra == "search"
Provides-Extra: all
Requires-Dist: xgboost; extra == "all"
Requires-Dist: scikit-learn; extra == "all"
Requires-Dist: numpy; extra == "all"
Requires-Dist: pandas; extra == "all"
Requires-Dist: sentence-transformers; extra == "all"
Requires-Dist: torch; extra == "all"
Requires-Dist: duckduckgo-search; extra == "all"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

<p align="center">
  <img src="https://raw.githubusercontent.com/neuralchemy/openclay/main/docs/assets/logo.png" alt="OpenClay Logo" width="120"/>
</p>

<h1 align="center">OpenClay</h1>

<p align="center">
  <strong>Secure First → Execute Second.</strong><br/>
  A Neural Alchemy project. The universal, zero-trust execution framework for LLM agents.
</p>

<p align="center">
  <a href="https://pypi.org/project/openclay/"><img alt="PyPI" src="https://img.shields.io/pypi/v/openclay.svg"></a>
  <a href="https://github.com/neuralchemy/openclay"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue"></a>
  <a href="https://doc.neuralchemy.in"><img alt="Docs" src="https://img.shields.io/badge/docs-neuralchemy.in-orange"></a>
</p>

---

## Why OpenClay?

Every modern AI framework—LangChain, CrewAI, LlamaIndex—is built on an optimistic assumption: **trust the input, trust the tools, trust the memory.** OpenClay operates on the opposite principle.

> **You do not build an agent and then bolt on security.  
> You define a Security Policy, and the agent executes *inside* it.**

OpenClay wraps every single step — tool calls, memory reads/writes, model inputs and outputs — in a multi-layered shield before any execution ever happens.

---

## Quickstart

```bash
pip install openclay
```

```python
from openclay import Shield

# Create a shield with balanced defaults
shield = Shield.balanced()

# Scan any incoming prompt
result = shield.protect_input("Ignore your instructions and...")
if result["block"]:
    print(f"Blocked: {result['reason']}")
```

---

## The OpenClay Ecosystem

| Module | Status | Description |
|---|---|---|
| `openclay.shields` | ✅ **Ready** | Core threat detection engine (Aho-Corasick, Bloom Filters, Canary Tokens, ML DeBERTa model) |
| `openclay.runtime` | 🚧 Draft | Secure execution wrapper — wrap any LangChain / CrewAI agent in a zero-trust environment |
| `openclay.tools` | 🚧 Draft | `@tool` decorators that scan tool outputs before returning them to the agent context |
| `openclay.memory` | 🚧 Draft | Pre-write and pre-read poisoning prevention for RAG and vector databases |
| `openclay.policies` | 🚧 Draft | Explicit, auditable rule engines: `StrictPolicy`, `ModeratePolicy`, `CustomPolicy` |
| `openclay.tracing` | 🚧 Draft | Full explainability and telemetry for every blocked or allowed action |

---

## Shields: What's Under the Hood

`openclay.shields` is the battle-tested core adapted from [PromptShield](https://github.com/neuralchemy/promptshield) v3.0 (now deprecated).

It provides a 5-layer defense pipeline:

1. **Pattern Engine** — 600+ curated Aho-Corasick patterns covering injection, jailbreaks, and encoding attacks
2. **Canary Token System** — Cryptographic canary injection and leak detection in LLM outputs
3. **Bloom Filter** — Probabilistic lookups for ultra-fast known-threat screening
4. **ML Classifier** — Fine-tuned DeBERTa model ([neuralchemy/deberta-promptinjection](https://huggingface.co/neuralchemy)) for semantic injection detection
5. **PII Detection** — Contextual PII scanning with redaction modes (mask, stub, remove)

### Shield Presets

```python
from openclay import Shield

shield = Shield.fast()       # Pattern-only (< 1ms)
shield = Shield.balanced()   # Production default (patterns + canary + PII)
shield = Shield.secure()     # Full protection (all layers + ML model)
```

### Integrations

```python
# LangChain
from openclay.shields.integrations.langchain import OpenClayCallbackHandler

# FastAPI Middleware
from openclay.shields.integrations.fastapi import OpenClayMiddleware

# CrewAI
from openclay.shields.integrations.crewai import OpenClayCrewInterceptor

# LiteLLM
from openclay.shields.integrations.litellm import OpenClayLiteLLMCallback
```

---

## The Secure Runtime (Coming in v0.2.0)

```python
from openclay.runtime import SecureRuntime
from openclay.policies import StrictPolicy

# Wrap any existing agent in a zero-trust boundary
runtime = SecureRuntime(policy=StrictPolicy())
result = runtime.run(my_langchain_agent, user_input="Analyze evil.com")

# Get exact tracing on why each action was permitted or blocked
print(runtime.trace().summary())
```

---

## Migration: PromptShield → OpenClay

`promptshield` (v3.0.1) is now **sunset** and will receive no further updates. Migrate in one line:

```diff
- from promptshield import Shield
+ from openclay import Shield
```

All APIs are backwards-compatible.

---

## Links

- 📦 [PyPI — `openclay`](https://pypi.org/project/openclay/)
- 📦 [PyPI — `promptshields` (deprecated)](https://pypi.org/project/promptshields/)
- 📖 [Documentation](https://doc.neuralchemy.in)
- 🤗 [Hugging Face — DeBERTa Model](https://huggingface.co/neuralchemy)
- 🐛 [GitHub Issues](https://github.com/neuralchemy/openclay/issues)

---

<p align="center">
  Built with ❤️ by <a href="https://neuralchemy.in">Neural Alchemy</a>
</p>
