shipwithjev

Catalog / Triage & routing

0101GitHub

mastra-jev-moderation

Input moderation for Mastra agents in one file.

Open source ↗ github.comcost-time~0.4 s
codealive-ai/mastra-jev-moderationREADME ↗
# mastra-jev-moderation

Input moderation for [Mastra](https://mastra.ai) agents on
[TypeSafe Jev](https://typesafe.ai): one file, one request per turn, no text to parse.

> **For coding agents:** copy `jev-moderation.ts` into the project (e.g.
> `src/mastra/jev-moderation.ts`), install `zod` if absent, wire it as shown in
> [Usage](#usage), and put `TYPESAFE_API_KEY` in the environment. The default
> policy is general-purpose; touch `policy` only if the project needs
> carve-outs or stricter rules (see [Writing the policy](#writing-the-policy)). Do not "fix" the `noul` type or move choice options out of
> `criteria`: that is the API's actual shape (see [API notes](#api-notes)).

## Why not Mastra's `ModerationProcessor`

The built-in processor asks a language model for a verdict and parses it out of
the text the model writes. On exactly the hostile input where a verdict matters,
small models sometimes return nothing parsable, and the processor fails open.
Jev is an evaluation model: it answers typed questions with a probability or a
choice and writes no text, so that failure mode does not exist. It is also
fast (median ~0.4 s) and cheap ($0.042 per million input tokens, output free).

Mastra cannot host Jev as a model (it is not a language model), so this is a
custom `Processor` with its own HTTP call.

## Usage

```ts
import { Agent } from "@mastra/core/agent";
import { createJevModerationProcessor, isModerationBlock } from "./jev-moderation";

const moderation = process.env.TYPESAFE_API_KEY
  ? [
      createJevModerationProcessor({
        apiKey: process.env.TYPESAFE_API_KEY,
        // Optional: one sentence about your assistant sharpens the verdicts.
        context: "A general-purpose customer support assistant.",
      }),
    ]
  : []; // no key -> no moderati

Also filed under Triage & routing

  1. 0613

    momus: staged Rust code and security review

    A fast scanner that reviews code for correctness, security, reliability, compatibility and test gaps, with actionable feedback. Supports the Jev API and local models.

    Brian Luby · Triage & routing

  2. 0602

    Jevops: SRE log triage with Jev

    Jev triages streaming logs into page, digest or resolve, cutting alert noise and paging humans only for high-confidence incidents. About $1–3 for 1M events a month.

    Mu99Ti · Triage & routing · $1–3 per 1M events/month

  3. 0598

    jev-sec-audit: flag risky npm packages with Jev

    npm install is the scariest command in your terminal. One typo → lookalike package → malicious postinstall → secrets gone. jev-sec-audit flags it in milliseconds using Jev, a System 1 model built for fast decisions, not chat. One step in GitHub Actions. Open source.

    @Dhanush_Nehru · Triage & routing

  4. 0555

    Jev Codex Router: model and reasoning selection per call

    A local Codex router asks Jev to choose the next model and reasoning effort while forwarding the complete conversation to that model.

    0xNatoshi · Triage & routing