Changelog
All notable changes to @edwinfom/ai-guard are documented here.
v0.2.1 — 2026-04-13
New Features
registerModelPricing()— Register custom model pricing at runtime. Any model name, any price per 1M tokens.- New models in
KnownModel—gemini-2.5-flash,gemini-2.5-pro,gpt-4.1,gpt-4.1-mini,claude-3-7-sonnet-20250219added to the built-in pricing table. extractJSON()andrepairJSON()— New standalone exports from@edwinfom/ai-guard/schemafor lower-level JSON repair without schema validation.estimateTokensByChars()— New export from@edwinfom/ai-guard/budgetfor character-based token estimation.getPatternsForTargets()— New export from@edwinfom/ai-guard/piito retrieve the raw regex patterns for specific PII types.InjectionResulttype — Now exported from@edwinfom/ai-guard/injection.RedactionResulttype — Now exported from@edwinfom/ai-guard/pii.- Interactive Playground — Test all standalone modules directly in the documentation without any API key.
Bug Fixes
registerModelPricingnow persists across CJS/ESM module boundaries viaglobalThis.buildUsagecorrectly falls back to character-based estimation when real token counts are unavailable.
v0.2.0 — 2026-04-11
New Features
- Canary Tokens — Invisible markers detect system prompt leakage at runtime
- Content Policy — Detects toxicity, hate speech, violence, self-harm, sexual content
- Hallucination Detection — Named-entity grounding check for RAG pipelines
- Rate Limiter — Per-user sliding-window request and token limits
- Audit Log — Structured callback with every
protect()call - Added French PII types: NIR, SIRET, SIREN, passport, date of birth
Breaking Changes
- Schema Level 2 now uses
jsonrepairinstead of custom regex extractor (100+ more patterns covered)
Bug Fixes
- Fixed credit card validation (Luhn algorithm now applied strictly)
- Fixed TypeScript generic inference for nested Zod schemas
v0.1.0 — 2026-04-10
Initial Release
Guardianclass withprotect()method- PII Redaction: email, phone, creditCard, ssn, ipAddress, iban, url
- Schema Enforcement: 3-level repair (strip → extract → LLM retry)
- Prompt Injection Detection: 15+ attack patterns with sensitivity levels
- Budget Sentinel: token counting and cost estimation for 7 models
protectStream()for async streaminginspect()dry-run analysis- Vercel AI SDK adapter
- LangChain adapter
- Tree-shakeable sub-path exports