Metadata-Version: 2.4
Name: langchain-vaultak
Version: 0.1.0
Summary: Vaultak runtime security callback handler for LangChain agents
License: MIT
Project-URL: Homepage, https://vaultak.com
Project-URL: Documentation, https://docs.vaultak.com
Project-URL: Repository, https://github.com/vaultak/langchain-vaultak
Project-URL: Issues, https://github.com/vaultak/langchain-vaultak/issues
Keywords: langchain,vaultak,ai-agents,security,runtime-security,llm,agent-security,ai-governance
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-core>=0.1.0
Requires-Dist: vaultak>=0.1.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: langchain>=0.1.0; extra == "dev"
Requires-Dist: langchain-openai; extra == "dev"
Dynamic: license-file

# langchain-vaultak

[![PyPI version](https://badge.fury.io/py/langchain-vaultak.svg)](https://pypi.org/project/langchain-vaultak)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)

**Runtime security for LangChain agents, powered by Vaultak.**

Intercept every agent action, score risk in real time, enforce policies, and automatically block dangerous behavior before it reaches your production systems — with two lines of code.

---

## The Problem

LangChain agents can write to databases, send emails, execute code, and call external APIs. Without a security layer, a single misconfigured tool call can cause real damage — deleted records, leaked PII, unauthorized transactions.

`langchain-vaultak` wraps your existing LangChain agents with Vaultak's runtime security engine. Every tool call and agent action is scored and checked against your policy rules before it executes.

---

## Install

```bash
pip install langchain-vaultak
```

Requires Python 3.8+, `langchain-core>=0.1.0`, and a Vaultak account at [vaultak.com](https://vaultak.com).

---

## Quick Start

```python
from langchain_vaultak import VaultakCallbackHandler

# Initialize with your Vaultak API key
handler = VaultakCallbackHandler(api_key="vtk_...")

# Pass as a callback to any LangChain agent
result = agent.run("Summarize our Q3 sales data", callbacks=[handler])
```

That is all. Every action the agent takes is now monitored, scored, and checked against your Vaultak policy rules.

---

## What It Does

| Event | Vaultak Action |
|---|---|
| Agent picks a tool | Risk-scores the action (0–10) |
| Tool call starts | Checks against policy rules |
| Tool call returns output | Scans output for PII and masks it |
| Tool or LLM error | Sends alert to your Vaultak dashboard |
| Chain error | Triggers automatic rollback |
| Risk score ≥ threshold | Blocks the action, raises exception |

---

## Configuration

```python
handler = VaultakCallbackHandler(
    api_key="vtk_...",           # Required — your Vaultak API key
    agent_name="sales-agent",    # Label for this agent in the dashboard
    block_on_high_risk=True,     # Block actions that exceed the threshold
    risk_threshold=7.0,          # 0–10 scale — default 7.0
    verbose=True,                # Log all scored actions
)
```

### Setting a lower threshold for sensitive workloads

```python
# For agents with access to production databases or financial systems
handler = VaultakCallbackHandler(
    api_key="vtk_...",
    agent_name="prod-db-agent",
    risk_threshold=5.0,  # More conservative
)
```

---

## Using with Different Agent Types

### ReAct / AgentExecutor

```python
from langchain.agents import AgentExecutor
from langchain_vaultak import VaultakCallbackHandler

handler = VaultakCallbackHandler(api_key="vtk_...")

agent_executor = AgentExecutor(agent=agent, tools=tools)
result = agent_executor.invoke(
    {"input": "your task"},
    config={"callbacks": [handler]}
)
```

### LCEL (LangChain Expression Language)

```python
from langchain_vaultak import VaultakCallbackHandler

handler = VaultakCallbackHandler(api_key="vtk_...")

chain = prompt | llm | output_parser
result = chain.invoke(
    {"input": "your task"},
    config={"callbacks": [handler]}
)
```

### Global callback (applies to all chains)

```python
from langchain.callbacks import set_handler
from langchain_vaultak import VaultakCallbackHandler

set_handler(VaultakCallbackHandler(api_key="vtk_..."))
```

---

## Viewing Results

Every action scored by this handler appears in your Vaultak dashboard at [app.vaultak.com](https://app.vaultak.com). You can:

- See real-time risk scores for every tool call
- Review the full action history for any agent run
- Configure or tighten policy rules without code changes
- Set up alerts for high-risk events

---

## Requirements

- Python 3.8+
- `langchain-core >= 0.1.0`
- `vaultak >= 0.1.0`
- A Vaultak account — sign up at [vaultak.com](https://vaultak.com)

---

## Links

- **Vaultak docs**: [docs.vaultak.com](https://docs.vaultak.com)
- **LangChain docs**: [python.langchain.com](https://python.langchain.com)
- **Issues**: [github.com/vaultak/langchain-vaultak/issues](https://github.com/vaultak/langchain-vaultak/issues)

---

## License

MIT — see [LICENSE](LICENSE)
