Example project testing ai-armor v0.1.7 from npm.
pnpm install# Test all core features (rate limit, budget, cache, routing, fallback, pricing, logging)
pnpm test:core
# Test safety guards (prompt injection, PII, blocked patterns, max tokens)
pnpm test:safety
# Run all
pnpm test:allcreateArmor— all 15 methods exist- Rate limiting — sliding window, per-user isolation, peek
- Budget tracking — daily/monthly cost, block/downgrade actions
- Model routing — aliases, passthrough
- Exact cache — miss/hit/set
- Cost estimation — cross-provider comparison
- Pricing API — 69 models, provider detection
- Logging — structured logs with max entries
- Fallback chains — primary failure, automatic fallback
- Minimal config — empty config works
- Prompt injection detection (ignore instructions)
- PII detection (SSN, credit card)
- Custom blocked patterns (regex)
- Max token enforcement
- onBlocked callback
- Combined safety rules
All 76 tests pass with ai-armor@0.1.7 from npm.