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

@soterai/llamaindex-middleware

v0.2.0

Published

Soter is a safety layer for AI chatbots, agents, RAG systems, and LLM applications.

Downloads

306

Readme

@soterai/llamaindex-middleware

LlamaIndex integration for Soter — the AI safety layer.

Wrap any LlamaIndex query engine with createSoterQueryWrapper to automatically guard user queries against prompt injection, jailbreaks, and other AI safety risks before they reach your index.

Install

npm install @soterai/llamaindex-middleware

Requires @soterai/core (peer dependency) and Node.js 18.18+.

Usage

import { SoterClient } from "@soterai/core";
import { createSoterQueryWrapper } from "@soterai/llamaindex-middleware";

// Create the Soter guard client
const guard = new SoterClient({
  apiKey: process.env.SOTER_API_KEY!,
});

// Your existing LlamaIndex query engine
const queryEngine = /* ... */;

// Wrap it with Soter
const protectedEngine = createSoterQueryWrapper(queryEngine, guard);

// Use like a normal query engine — Soter guards every query
const result = await protectedEngine.query({ query: "What documents mention..." });
// → safe query is passed to your engine, or throws if blocked

How It Works

  1. Input guardguard.guardInput({ message: input.query }) runs before every query. If the action is "BLOCK", it throws an error with the reason.
  2. Safe query — Your query engine receives the safe or redacted query text.
  3. Result — The query engine response is returned as-is (output guard can be added separately if needed).

API

createSoterQueryWrapper(queryEngine, guard)

| Param | Type | Description | |-------|------|-------------| | queryEngine | { query(input: { query: string }): Promise<TResponse> } | Any LlamaIndex query engine with query() method | | guard | { guardInput(input: { message: string }): Promise<GuardDecision> } | A Soter client with guardInput() method |

Returns a wrapped query engine with the same query() interface.

Where GuardDecision contains:

  • action: "ALLOW" | "ALLOW_WITH_REDACTION" | "REWRITE" | "BLOCK" | "HUMAN_REVIEW"
  • safeText?: The safe/redacted text
  • redactedText?: The redacted version (if applicable)
  • reason?: Explanation of the decision

TypeScript

// Generic type for typed responses
const protectedEngine = createSoterQueryWrapper<{ text: string }>(engine, guard);

Backward Compatibility

createCyberRakshakQueryWrapper is exported as an alias for existing integrations.

Related Packages

| Package | Description | |---------|-------------| | @soterai/core | Core Soter client and agent firewall | | @soterai/langchain-middleware | LangChain integration | | @soterai/vercel-ai-sdk-middleware | Vercel AI SDK integration |

License

MIT