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

@benchspan/sdk

v0.3.1

Published

Prompt injection firewall for LLM agents. Scan tool outputs and user messages before they reach your model.

Readme

@benchspan/sdk

Prompt injection firewall for LLM agents. One-line integration that scans tool outputs and user messages before they reach your model.

Install

npm install @benchspan/sdk

Quick Start

import { BenchGuard } from "@benchspan/sdk";

const guard = new BenchGuard({ apiKey: "ag_live_...", agent: "my-agent" });

// Direct scan
const result = await guard.scan("some tool output", { role: "tool" });
// result.injection  -> true/false
// result.verdict    -> "block" | "warn" | "pass"

Framework Integrations

Vercel AI SDK

import { BenchGuard } from "@benchspan/sdk";
import { wrapLanguageModel, generateText } from "ai";
import { anthropic } from "@ai-sdk/anthropic";

const guard = new BenchGuard({ apiKey: "ag_live_..." });
const model = wrapLanguageModel({
    model: anthropic("claude-sonnet-4-6"),
    middleware: guard.asMiddleware(),
});
const { text } = await generateText({ model, prompt: "Hello" });

LangChain JS

import { BenchGuard } from "@benchspan/sdk";
import { ChatAnthropic } from "@langchain/anthropic";

const guard = new BenchGuard({ apiKey: "ag_live_..." });
const llm = new ChatAnthropic({ model: "claude-sonnet-4-6" });
const result = await llm.invoke(messages, { callbacks: [guard.asLangChainCallback()] });

OpenAI Agents SDK

import { BenchGuard } from "@benchspan/sdk";

const guard = new BenchGuard({ apiKey: "ag_live_..." });
const agent = new Agent({
    name: "assistant",
    model: "gpt-4o",
    hooks: guard.asAgentHooks(),
});

Google ADK

import { BenchGuard } from "@benchspan/sdk";
import { LlmAgent } from "@google/adk";

const guard = new BenchGuard({ apiKey: "ag_live_..." });
const agent = new LlmAgent({
    name: "assistant",
    model: "gemini-2.5-pro",
    beforeModelCallback: guard.asAdkCallback(),
});

Raw OpenAI / Anthropic SDK

import { BenchGuard } from "@benchspan/sdk";
import Anthropic from "@anthropic-ai/sdk";

const guard = new BenchGuard({ apiKey: "ag_live_..." });
const client = new Anthropic();

const result = await guard.wrapCall(messages, () =>
    client.messages.create({ model: "claude-sonnet-4-6", messages })
);

Modes

  • "block" (default) -- Waits for scan result. Throws InjectionDetectedError if injection detected.
  • "warn" -- Fires scan in the background with zero added latency. Logs a warning if injection detected but never blocks.
// Production -- block injections
const guard = new BenchGuard({ apiKey: "ag_live_...", mode: "block" });

// Evaluation -- monitor without blocking
const guard = new BenchGuard({ apiKey: "ag_live_...", mode: "warn" });

How It Works

  1. Framework hook fires before each LLM call
  2. SDK scans user and tool messages via the BenchSpan API
  3. system and assistant messages are skipped (trusted)
  4. Already-scanned messages are deduplicated across multi-turn conversations
  5. In block mode, InjectionDetectedError is thrown if injection detected
  6. In warn mode, the scan runs async -- zero latency added to your agent

Links