Metadata-Version: 2.4
Name: qarai-agent-guard
Version: 0.1.0
Summary: A lightweight guardrails framework for AI agents that supports multiple languages, primarily Arabic and its dialects, for safety and PII governance.
Author-email: Oussama Ben Slama <oussama@ben-slama.tn>, Safouene Ziadi <ziadisafouene@gmail.com>
License: Apache-2.0
Project-URL: Homepage, https://github.com/yourorg/qarai-agent-guard
Project-URL: Repository, https://github.com/yourorg/qarai-agent-guard
Project-URL: Issues, https://github.com/yourorg/qarai-agent-guard/issues
Keywords: guardrails,ai-guardrails,ai-safety,llm,llm-safety,agents,ai-agents,prompt-injection,pii,data-privacy,nlp,arabic,arabic-nlp,ai-governance
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Security
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx<1.0,>=0.27
Requires-Dist: pydantic<3.0,>=2.0
Requires-Dist: pyyaml<7.0,>=6.0
Dynamic: license-file

# Qarai Agent Guard

**Qarai Agent Guard** is a lightweight, composable guardrails framework for AI agents. It inspects agent memory and tool I/O at runtime, detects unsafe or sensitive content, and enforces policy-driven actions — block, warn, redact, or allow — before data is persisted or returned to users.

The project is built with multilingual safety in mind. **Arabic** is a first-class language today, with pattern libraries and detectors tuned for Modern Standard Arabic. **Arabic dialects** (Maghrebi, Egyptian, Levantine, Gulf, and others) are on the roadmap, reflecting the linguistic diversity of real-world deployments across the MENA region and the global Arabic-speaking diaspora.

Whether you run agents in English, French, Arabic, or a mix of languages, Qarai Agent Guard gives you a single, policy-driven layer to govern PII, secrets, prompt injection, and model-reasoning leakage — without rewriting your agent stack.

---

## Why Qarai Agent Guard?

AI agents accumulate context in memory, call external tools, and exchange messages across sessions. That context is a high-value attack surface: prompt injection can poison long-term memory, PII can leak into logs, and chain-of-thought content can surface where it should not.

Qarai Agent Guard addresses this by sitting **between your agent and its memory layer**, running detectors on every create, read, update, and delete operation. Policies map detection severity to concrete actions so security teams can tune behavior without touching application code.

| Capability | Description |
|---|---|
| **Multilingual detection** | YAML-driven regex patterns for English, French, and Arabic; extensible to dialects |
| **Policy engine** | Severity-based rules: block, redact, warn, allow |
| **Memory governance** | Hooks on all CRUD paths for agent memory |
| **Framework integrations** | LangChain buffer memory support out of the box |
| **Composable detectors** | PII, secrets, model-reasoning / injection patterns |
| **Custom policies** | Built-in presets or load your own YAML policy files |

---

## Quick start

Install the package (see [install.md](install.md) for full instructions):

```bash
pip install qarai-agent-guard
# LangChain integration (optional)
pip install langchain-community
```

Configure guards and attach them to LangChain buffer memory:

```python
from qarai_agent_guard import (
    BufferMemoryMiddleware,
    GuardedBufferChatMessageHistory,
    ModelReasoningDetector,
    PIIDetector,
    strict_policy,
)

middleware = BufferMemoryMiddleware(
    detectors=[
        ModelReasoningDetector(lang="ar"),
        PIIDetector(),
    ],
    policy=strict_policy(),
)

history = GuardedBufferChatMessageHistory(
    middleware=middleware,
    session_id="user-42",
)

history.add_user_message("مرحبا، كيف يمكنني المساعدة؟")
```

You pass **detectors** and **policy** to `BufferMemoryMiddleware`. The library wires `AgentGuard`, `MemoryGuard`, and the internal middleware for you.

---

## Documentation

| Document | Description |
|---|---|
| [install.md](install.md) | Installation, dependencies, and environment setup |
| [contributing.md](contributing.md) | How to contribute code, patterns, and documentation |
| [docs/index.md](docs/index.md) | Component reference and architecture guide |

---

## Project status

Qarai Agent Guard is under active development. The core detector, policy, and guard pipeline is stable; integrations and dialect coverage are expanding. We welcome contributions — especially Arabic dialect patterns, new integrations, and policy presets.

---

## License

Apache License 2.0. See [LICENSE](LICENSE) for details.
