npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-shield-classifier-onnx

v0.2.0

Published

Optional ONNX ML classifier for ai-shield — DeBERTa-style prompt-injection detection alongside heuristic patterns

Readme

ai-shield-classifier-onnx

Optional ONNX-runtime ML classifier for ai-shield. Pairs with ai-shield-core to add a DeBERTa-style prompt-injection classifier alongside the heuristic patterns.

Why a separate package?

ai-shield-core is zero-dependency by design. ONNX inference requires onnxruntime-node, which ships native binaries. Install this package only when you actively want ML-augmented detection on top of the regex layer.

Install

npm install ai-shield-core ai-shield-classifier-onnx onnxruntime-node

Usage

import { ScannerChain, HeuristicScanner } from "ai-shield-core";
import { loadOnnxClassifier } from "ai-shield-classifier-onnx";

// Bring your own tokenizer. Example: protectai/deberta-v3-base-prompt-injection
const tokenizer = await yourTokenizerFor("protectai/deberta-v3-base-prompt-injection");

const ml = await loadOnnxClassifier({
  modelPath: "./models/deberta-injection.onnx",
  tokenizer,
  threshold: 0.85, // tune per model
});

const chain = new ScannerChain({ earlyExit: true });
chain.add(new HeuristicScanner({ strictness: "high" })); // cheap regex first
chain.add(ml);                                            // ML fallback

const result = await chain.run("Ignore previous instructions...");
console.log(result.decision); // "block"

Or manually with an already-constructed InferenceSession:

import * as ort from "onnxruntime-node";
import { OnnxInjectionScanner } from "ai-shield-classifier-onnx";

const session = await ort.InferenceSession.create("./models/deberta.onnx");
const scanner = new OnnxInjectionScanner({ session, tokenizer, threshold: 0.85 });

Recommended models

Notes

  • The scanner degrades gracefully on inference errors — failure is logged as a content_policy violation but does not block traffic. This avoids taking down the whole chain when the model file is missing or the runtime hits a hardware-specific edge case.
  • Use after the heuristic scanner. Most known attacks short-circuit on cheap regex; the ML pass catches paraphrases and obfuscations that slip through.
  • The probability threshold is calibrated per model. Start at 0.85 and tune against your false-positive budget.

License

MIT — see LICENSE.