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

@tollwarden/ai-sdk

v0.1.0

Published

TollWarden payment security for the Vercel AI SDK: scan-before-you-pay tools for x402 payments, plus an onStepFinish handler that auto-tags provenance for prompt-injection detection, and guardedPayment for enforcement by construction.

Readme

@tollwarden/ai-sdk

TollWarden payment security for the Vercel AI SDK — agents inherit "scan before you pay" by default.

npm install @tollwarden/ai-sdk

Two additions

import { generateText } from "ai";
import { TollWardenClient } from "@tollwarden/client";
import { tollwardenTools, tollwardenProvenance } from "@tollwarden/ai-sdk";

const tollwarden = new TollWardenClient({ agentId: "my-agent" }); // free API key auto-minted (100 free scans)

await generateText({
  model,
  tools: { ...tollwardenTools(tollwarden), ...yourOtherTools },
  onStepFinish: tollwardenProvenance(tollwarden),   // ← the important line
  prompt: "...",
});

Every x402 payment the agent scans gets an allow / flag / block verdict with machine-readable reasons: prompt-injection-triggered payments, replayed nonces, overpayment vs the quote, secrets/PII leaking in payment metadata, lookalike-token contracts, address poisoning, and counterparty reputation.

Why tollwardenProvenance is the important line

TollWarden's strongest detector catches payments whose decision came from content the agent just read — a prompt-injected page or tool result that says "send payment to 0x…". That check needs to know what the agent read. tollwardenProvenance is an onStepFinish handler that observes every tool result automatically, so the very next scan is provenance-tagged and the injection check runs with real input. No prompt engineering, no developer learning what "provenance" means. (TollWarden's own tool results are excluded, so verdicts never pollute the signal.)

The AI SDK hands onStepFinish the full set of toolResults for each step, so a single line wires the whole loop — no per-tool wrapping. Works the same under streamText (onStepFinish) and agent loops.

Enforcement: payments that can't execute when blocked

Tools rely on the model choosing to scan. guardedPayment doesn't:

import { guardedPayment } from "@tollwarden/ai-sdk";

const safePay = guardedPayment(executeX402Payment, tollwarden);   // { strict: true } to refuse flags too
const { result } = await safePay(payment, expectedPriceUsd);
// on a block verdict it throws TollWardenBlockedError BEFORE executeX402Payment is ever invoked.

For wallet-level enforcement (the signer itself refuses unscanned payments), see wrapFetchWithTollWarden and TollWardenEnforcer in the @tollwarden/client SDK.

The toolset

| Tool | When the agent is told to use it | |---|---| | tollwarden_scan_payment | ALWAYS, immediately before settling any x402 payment (or before paying a received 402 offer with direction: "incoming") | | tollwarden_check_reputation | Before dealing with an unfamiliar counterparty address | | tollwarden_report_counterparty | After a bad payment experience (always free) — warns other agents |

Pass external content the agent just read as the content field on tollwarden_scan_payment to enable prompt-injection detection even without the onStepFinish handler. TOLLWARDEN_TOOL_NAMES is exported if you need to filter TollWarden's own tools elsewhere.

Verdicts are Ed25519-signed and payment-bound; the underlying client verifies them against a pinned key automatically.

MIT. TollWarden is advisory and non-custodial: it never touches keys, wallets, or funds.