Skip to content

Client-side AI Guardrails for React. Auto-repairs broken JSON streams from LLMs (preventing crashes) and blocks PII/Secrets before they leave the browser. Zero-latency, Web Worker powered.

License

Notifications You must be signed in to change notification settings

AI-Guard-System/ai-guard-system

Repository files navigation

AI Guard v2.0: The Security Operating System for LLMs

Build Status Bundle Size License NPM Version

"The Firewall for GenAI."
Validates streams, prevents injections, and redacts secrets in real-time—entirely client-side.


⚡ v2.0 Architecture

We have transitioned from a utility library to a Privacy-First OS.

Package Role Version
@ai-guard/core The Kernel. Universal TypeScript logic. Runs in Node, Edge, or Browser (Worker). Contains the Entropy Engine and Injection Heuristics. npm
@ai-guard/react The UI Layer. React hooks (useAiGuard) that communicate with the Core Worker via the new Delta-Protocol. npm
@ai-guard/playground Test Lab. Local environment to fuzz-test the security engines. -

🛡️ New Security Engines

1. Entropy Scanner (src/security/EntropyScanner.ts)

Detects API keys, private tokens, and high-entropy secrets using Shannon Entropy analysis. It catches secrets regular Regex misses (e.g. sk-ant-12345AaBb...).

2. Injection Heuristics (src/security/InjectionScanner.ts)

A scoring engine that detects Jailbreak attempts like "Ignore previous instructions", "DAN Mode", and "System Override".

3. Smart PII Context

Context-aware Regex engines that reduce false positives by checking surrounding words (e.g. 123-45 vs SSN: 123-45).

Installation

npm install @ai-guard/react

Quick Start (Streaming)

import { useAiGuard } from '@ai-guard/react';

// Pipe your LLM stream directly through the Guard
const { scanStream } = useAiGuard({
  pii: { redact: true },
  blockOnInjection: true
});

// onChunkReceived:
await scanStream(newChunk); 
// Returns: { safe: true, text: "[REDACTED]" }

Contributing

See CONTRIBUTING.md.

License

MIT © ShyamSathish005

About

Client-side AI Guardrails for React. Auto-repairs broken JSON streams from LLMs (preventing crashes) and blocks PII/Secrets before they leave the browser. Zero-latency, Web Worker powered.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published