Local-first runtime governance layer for AI systems
Project description
Guardian Runtime
Guardian Runtime sits securely on your machine, acting as a bodyguard for your code.
Whenever you use AI tools like Cursor or Claude Code, it scans every prompt locally to stop sensitive secrets and PII from reaching the cloud.
It also tracks your API spending to prevent surprise bills, all without slowing you down.
๐ Docs & Demo: ashp15205.github.io/guardian-runtime
๐ฆ PyPI: pypi.org/project/guardian-runtime
What is Guardian Runtime?
Guardian Runtime is a local HTTP proxy that runs entirely on your own machine. It sits between your AI coding tool and the cloud, inspecting every prompt before it leaves your infrastructure.
Your AI Tool Guardian Runtime Cloud LLM
(Claude Code / Cursor) (localhost:8080) (OpenAI / Anthropic / Gemini)
โ โ โ
โ Prompt + Files โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโถ โ โ
โ โ Secret Scanner โ
โ โ PII Detector โ
โ โ Doc Converter (PDFโMD) โ
โ โ Token Counter โ
โ โ Budget Guard โ
โ โ Jailbreak Detector โ
โ โ โ
โ [BLOCKED] โโโโโโโโโโโโโโโ โ โ Threat found โ
โ "line 3: AWS key. y/n?" โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโถ โ
โ Optimized Response โโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
All data stays on your machine. Your API keys live in a local .env file. All logs write to ~/.guardian_runtime/. Nothing leaves without clearance.
Table of Contents
- The Problem
- Architecture & Security Pipeline
- Features
- Supported Tools & Providers
- Installation
- Quickstart
- Interactive Block โ How It Looks
- Use Cases
- CLI Reference
- Policy Configuration
- License
The Problem
| Risk | Description |
|---|---|
| ๐ธ Cost Runaways | Agents operate in loops. A stuck agent can rack up a $100+ API bill overnight with zero warning. |
| ๐ Secret Leaks | Agents read your entire workspace. One .env file with an AWS_SECRET_KEY in context, and that credential silently travels to an Anthropic or OpenAI cloud server. |
| ๐ Compliance Risk | Sending unauthorized PII (SSNs, emails, Aadhaar) to public LLM APIs violates GDPR, HIPAA, and India's DPDP Act. |
Architecture & Security Pipeline
Every request passes through a strict local pipeline before reaching the cloud:
Agent / Dev Guardian Runtime (local) Cloud LLM
โ โ โ
โ 1. Prompt + Files โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโถโ โ
โ โ [File Router] โ
โ โ โโ Code files โ Secret Scanner โ
โ โ โโ Doc files โ MarkItDown โ MD โ
โ โ โ
โ โ [Security Guards] โ
โ โ โโ Regex: AWS / GitHub / OAI keysโ
โ โ โโ PII: SSN / Aadhaar / email โ
โ โ โโ Jailbreak patterns (40+) โ
โ โ โโ Report exact line number โ
โ โ โ
โ โ [Interactive Block] โ
โ "line 3: secret. y/n?" โโโ โ Ask user before dropping โ
โ โ โ
โ โ [Token Optimizer] โ
โ โ โโ tiktoken counting โ
โ โ โโ Whitespace normalization โ
โ โ โโ Terse Mode injection โ
โ โ โ
โ โ [FinOps Budget Guard] โ
โ โ โ Block if daily_budget exceeded โ
โ โ โ
โ โ 2. Clean, verified prompt โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโถโ
โ โ โ
โ โ 3. LLM Response โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โ [Output Guard] โ
โ โ Audit response for leaks โ
โ โ โ
โ 4. Optimzied Response โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
Features
| # | Feature | Description |
|---|---|---|
| 01 | ๐ Secret Scanner | Detects AWS keys, GitHub tokens, OpenAI/Anthropic keys, Stripe secrets, Razorpay, Groq. Reports the exact line number. |
| 02 | ๐ค PII Detector | Catches Aadhaar, PAN, SSN, credit cards, email, phone, passport. Fully offline. |
| 03 | ๐ก๏ธ Jailbreak Guard | 40+ patterns detecting DAN mode, role-play attacks, and prompt injection. |
| 04 | ๐ฌ Interactive y/n Override | Replies inside your chat: "Secret on line 3. Proceed? y/n" โ stays in the flow. Works on OpenAI, Anthropic, and Gemini formats. |
| 05 | ๐ Document Converter | PDF, DOCX, XLSX โ Markdown via Microsoft MarkItDown. Also available as a CLI command. |
| 06 | ๐ธ Hard Budget Caps | Set daily_budget: 5.00. Guardian blocks any request that would push you over. |
| 07 | โก Terse Mode | Injects a system prompt forcing concise replies. Cuts output tokens 40โ70% in benchmarks. |
| 08 | ๐ Universal Proxy | Speaks OpenAI, Anthropic, AND native Gemini (/v1beta/models/{model}:generateContent) formats. |
| 09 | ๐ Session Analytics | Tracks cost, tokens, blocks, and conversions locally. Query via guardian_runtime analytics or GET /stats. |
Supported Tools & Providers
| Category | Tools |
|---|---|
| Visual IDEs | Cursor, Windsurf, VS Code (via Cline/RooCode) |
| Terminal Agents | Claude Code, Aider, GitHub Copilot CLI |
| Frameworks | LangChain, AutoGen, LlamaIndex, CrewAI |
| LLM Providers | OpenAI, Anthropic Claude, Google Gemini |
| API Formats | OpenAI REST, Anthropic REST, Gemini v1beta (native) |
Installation
# Full install (all providers + document converter + ML scanner)
pip install "guardian_runtime[all]"
# Or install only what you need:
pip install "guardian_runtime[openai]"
pip install "guardian_runtime[anthropic]"
pip install "guardian_runtime[gemini]"
Done. No signup. No cloud account required.
Quickstart
1. Start the proxy
guardian_runtime proxy --port 8080
2. Connect your AI tool
# Claude Code
export ANTHROPIC_BASE_URL=http://localhost:8080
claude
# Aider
export OPENAI_API_BASE=http://localhost:8080/v1
aider
# Gemini CLI
export HTTPS_PROXY=http://localhost:8080
gemini
# Cursor / Windsurf
# Settings โ AI โ Base URL โ http://localhost:8080
3. Python SDK (optional)
from guardian_runtime import GuardianRuntime, GuardianRuntimeBlockedError
gr = GuardianRuntime() # zero-config
try:
response = gr.complete(
model="gpt-4o",
messages=[{"role": "user", "content": user_input}],
raise_on_block=True
)
print(response.content)
except GuardianRuntimeBlockedError as e:
print(f"Blocked: {e.response.violations[0].detail}")
Interactive Block โ How It Looks
When Guardian detects a secret or PII, instead of crashing your session, it replies inside your chat window as the assistant:
[GUARDIAN_RUNTIME BLOCKED] Your request was intercepted.
Violation : secret
Detail : AWS Access Key ID found on line 3
Line : AWS_KEY=AKIAIOSFODNN7EXAMPLE
Type y/n in your next message to proceed or cancel.
- Type
yโ Guardian bypasses the scanner for that single request only. - Type
nโ Block holds. The secret never leaves your machine.
Use Cases
Terminal Agents (Claude Code, Aider)
guardian_runtime proxy --port 8080
export ANTHROPIC_BASE_URL=http://localhost:8080
claude # All Claude Code traffic is now protected
Visual IDEs (Cursor, Windsurf)
1. guardian_runtime proxy --port 8080
2. Cursor Settings (Cmd+,) โ Models โ Override Base URL
3. Set to: http://localhost:8080
Agentic Frameworks (LangChain, AutoGen)
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-4o",
base_url="http://localhost:8080/v1",
api_key="sk-proj-..."
)
Document Conversion
# Convert before uploading to any AI chat
guardian_runtime convert report.pdf --out report.md
CLI Reference
| Command | Description |
|---|---|
guardian_runtime proxy --port 8080 |
Start the local security proxy |
guardian_runtime convert <file> --out <file.md> |
Convert PDF/DOCX/XLSX to Markdown |
guardian_runtime scan "<text>" |
Manually scan any text for threats |
guardian_runtime analytics |
Show today's cost, tokens, and blocks |
guardian_runtime analytics --all |
Show all-time historical analytics |
guardian_runtime logs |
Tail the live JSONL event stream |
guardian_runtime init |
Generate a boilerplate policy.yaml |
guardian_runtime validate |
Check policy.yaml for syntax errors |
guardian_runtime status |
Show health of local installation |
guardian_runtime clean |
Delete all local data and logs |
GET /stats |
Live REST endpoint (while proxy is running) |
Policy Configuration
Run guardian_runtime init to generate a policy.yaml, then customize:
version: "1.0"
agents:
default:
llm:
provider: openai
default_model: gpt-4o
input_guard:
scanner_enabled: true # Secret + PII scanning
jailbreak_detection: true # 40+ jailbreak patterns
scanner_action: block # "block" or "warn"
cost:
daily_budget: 5.00 # Hard block at $5/day
max_input_tokens: 20000 # Block oversized context windows
optimizer:
enabled: true
terse_mode: true # Cuts output tokens 40โ70%
max_history_messages: 20 # Trim old chat history
License
Released under the MIT License. Zero tracking. Zero cloud dependencies. Your code is yours.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guardian_runtime-1.2.0.tar.gz.
File metadata
- Download URL: guardian_runtime-1.2.0.tar.gz
- Upload date:
- Size: 675.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3065a4106757e32541a659bf819b765bbfe802ffcc20e4ea8e45f3bfca99669
|
|
| MD5 |
7ce6fa6744e3cbc8a77ee970cb3cdae7
|
|
| BLAKE2b-256 |
a4cd8a6df90f5a88241c8f0bb3a9d610fb58690c0367a6d8672f3235507e8395
|
File details
Details for the file guardian_runtime-1.2.0-py3-none-any.whl.
File metadata
- Download URL: guardian_runtime-1.2.0-py3-none-any.whl
- Upload date:
- Size: 62.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eefc27f328dfaec0e881a03d48cd2d17e9986bd3985ab188d1f04d734f683dcc
|
|
| MD5 |
461b1b753a0819e949b18944cc22ddcf
|
|
| BLAKE2b-256 |
9e7fa874812a425c4e66138605d4eae5afbbc713fb16ce0f0c2fee07a1477c33
|