Metadata-Version: 2.4
Name: realitykernel
Version: 0.1.0
Summary: Execution-layer security SDK for AI agents — Reality Kernel
Home-page: https://realitykernel.dev
Author: Keter Labs
Author-email: team@keterlabs.com
Project-URL: Documentation, https://realitykernel.dev/integration
Project-URL: Benchmark, https://realitykernel.dev/benchmark
Project-URL: Playground, https://realitykernel.dev/playground
Project-URL: Bug Reports, https://github.com/keterlabs/realitykernel-python/issues
Keywords: ai,agent,security,guardrails,langchain,prompt injection,llm,agentic,runtime,proxy
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: langchain
Requires-Dist: langchain>=0.1.0; extra == "langchain"
Provides-Extra: all
Requires-Dist: langchain>=0.1.0; extra == "all"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Reality Kernel Python SDK

Execution-layer security for AI agents. Reality Kernel intercepts agent tool calls before they execute and blocks prompt injection, SSRF, credential access, and exfiltration chains.

## Install

```bash
pip install realitykernel

# With LangChain integration
pip install realitykernel[langchain]
```

## Quick start

```python
import reality_kernel

rk = reality_kernel.Client(api_key="rk_live_...")

result = rk.check(
    command="cat /etc/shadow",
    intent="read application logs",
)

print(result.verdict)    # ALLOW | WARN | BLOCK
print(result.confidence) # 0.0 – 1.0
print(result.evidence)   # ["Static: CRITICAL violation..."]
```

## Generic decorator — works with any framework

```python
from reality_kernel import Client
from reality_kernel.integrations.generic import rk_guard

rk = Client(api_key="rk_live_...")

@rk_guard(rk, intent="read application config file")
def read_config(path: str) -> str:
    with open(path) as f:
        return f.read()

# RKSecurityException is raised automatically if the command is blocked
read_config("../../.env")  # → BLOCK
read_config("/app/config.yaml")  # → ALLOW
```

## LangChain integration

```python
from langchain.agents import initialize_agent
from reality_kernel import Client
from reality_kernel.integrations.langchain import RKLangChainGuardrail

rk = Client(api_key="rk_live_...")
guardrail = RKLangChainGuardrail(client=rk, agent_id="my-agent")

agent = initialize_agent(
    tools=tools,
    llm=llm,
    callbacks=[guardrail],
)

agent.run("Summarise the production logs.")
# If the agent is hijacked and tries to run curl 169.254.169.254,
# RKSecurityException is raised before the ShellTool executes.
```

## With a Least-Agency Policy

```python
rk.check(
    command="aws s3 cp /secrets s3://bucket",
    intent="backup config files",
    policy={
        "allowed_tools": ["aws"],
        "allowed_egress": ["*.amazonaws.com"],
        "read_only_paths": ["/app/config"],
    }
)
# → BLOCK: PolicyViolation: '/secrets' is outside read_only_paths
```

## Session tracking (slow-drip detection)

```python
# Pass the same session_id across multiple agent turns.
# Reality Kernel detects: read → read sensitive file → curl external URL
# and escalates the final verdict to BLOCK automatically.

for turn in agent_turns:
    rk.check(
        command=turn.command,
        intent=turn.intent,
        session_id="agent-session-42",
    )
```

## Docs

Full documentation: [realitykernel.dev/integration](https://realitykernel.dev/integration)  
Security benchmark: [realitykernel.dev/benchmark](https://realitykernel.dev/benchmark)  
Live playground: [realitykernel.dev/playground](https://realitykernel.dev/playground)
