0400GitHub
tripwire
Runs seven checks on every LLM response in one Jev call, as AI SDK middleware or an OpenAI-compatible proxy.
noelzappy/tripwireREADME ↗
# tripwire
[](https://www.npmjs.com/package/@noelzappy/tripwire) [](https://github.com/noelzappy/tripwire/actions/workflows/ci.yml)
Judge every LLM response before the user sees it. Seven checks in one ~100 ms call to [TypeSafe's Jev](https://typesafe.ai), cheap enough to run on 100% of traffic instead of sampling 1% with a frontier judge.
- **AI SDK middleware**: `wrapLanguageModel({ model, middleware: tripwire(...) })`. Zero infra.
- **OpenAI-compatible proxy**: point any client's `baseURL` at it.
- **Policy as YAML**: which checks run, how confident Jev must be, what a block does.
- **Confidence-gated**: a check that fires with high confidence blocks; low confidence downgrades to flag, never suppresses.
- **Decision log** that is PII-free by default and doubles as your labelling dataset.
- **Eval CLI** that prints per-check precision/recall and coverage at each threshold. Run it before you trust anything.
## Status
v0.1. Middleware and proxy work end to end (29 tests, mock judge). **No accuracy numbers against real Jev yet.** The eval harness and a 27-item seed set exist so the first real run is one command. Do not put this in front of users until that run shows block precision above 95% on your own data.
## Install
```sh
npm install @noelzappy/tripwire ai
# or: bun add @noelzappy/tripwire ai
```
The library runs on Node 20+ and Bun. The proxy server needs Bun. `ai` (v7) is a peer dependency, so tripwire uses the same copy as your app.
## Develop
```sh
bun install
cp .env.example .env # add TYPESAFE_AI_API_KEY, or leave empty for the mock judge
bun test
bun run eval # replay eval/dataset.jsonl through the judge
```
### Middleware
```ts
import { anthropic } from "@ai-sdk/anthropic";
import { generateText, wrapLanguageModel } from "ai";