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

thoughtproof-x402

v1.0.0

Published

Pre-settlement reasoning verification for x402 agent payments. Verifies AI agent decision quality before payment executes.

Readme

thoughtproof-x402

Pre-settlement reasoning verification for x402 agent payments.

x402 moves the money. ThoughtProof verifies the reasoning.

The Problem

x402 processes 119M+ transactions on Base alone. Every one settles without checking whether the agent's reasoning was sound. An agent with a valid wallet can make a catastrophic purchase decision — and the payment executes flawlessly.

thoughtproof-x402 adds the missing verification step between decide and settle:

Agent decides → ThoughtProof verifies → x402 settles

Quick Start

npm install thoughtproof-x402

Express Middleware

Drop in before your x402 paymentMiddleware:

import express from "express";
import { paymentMiddleware } from "@x402/express";
import { thoughtproofMiddleware } from "thoughtproof-x402/express";

const app = express();

// 1. Verify reasoning
app.use(thoughtproofMiddleware({
  thoughtproof: { apiKey: process.env.THOUGHTPROOF_KEY },
  policy: { onUncertain: "deny" },
}));

// 2. Process payment
app.use(paymentMiddleware({ /* x402 config */ }));

// 3. Serve resource
app.get("/api/data", (req, res) => res.json({ data: "verified" }));

Cloudflare Workers / Bun / Deno

Framework-agnostic — works with any Web Fetch API runtime:

import { verifyPayment } from "thoughtproof-x402";

export default {
  async fetch(request: Request): Promise<Response> {
    const verification = await verifyPayment(request, {
      thoughtproof: { apiKey: "tp_..." },
    });

    if (!verification.allowed) {
      return new Response(JSON.stringify(verification.result), { status: 403 });
    }

    const response = Response.json({ data: "verified" });
    for (const [k, v] of Object.entries(verification.headers)) {
      response.headers.set(k, v as string);
    }
    return response;
  },
};

How It Works

  1. Agent sends a payment request (x402 X-Payment header)
  2. thoughtproof-x402 extracts the agent context (address, resource, amount, reasoning)
  3. Sends to ThoughtProof API for multi-model adversarial verification
  4. If APPROVE (confidence ≥ threshold): adds attestation headers, continues to x402
  5. If DENY or UNCERTAIN: returns 403 with verification details

Attestation Headers

Verified responses include proof headers that downstream consumers can audit:

X-ThoughtProof-Version: 1
X-ThoughtProof-Verdict: APPROVE
X-ThoughtProof-Confidence: 0.92
X-ThoughtProof-Chain-Hash: sha256:abc123...
X-ThoughtProof-Verifiers: 3
X-ThoughtProof-Audit-URL: https://thoughtproof.ai/chain/abc123
X-ThoughtProof-Duration-Ms: 247
X-ThoughtProof-Timestamp: 2026-04-14T21:00:00.000Z

Parse them on the client side:

import { parseAttestationHeaders } from "thoughtproof-x402";

const proof = parseAttestationHeaders(response.headers);
console.log(proof?.verdict);    // "APPROVE"
console.log(proof?.confidence); // 0.92
console.log(proof?.auditUrl);   // Full verification trace

Configuration

ThoughtProof Client

| Option | Default | Description | |--------|---------|-------------| | apiUrl | https://api.thoughtproof.ai | API endpoint | | apiKey | — | API key (optional — x402 payment also accepted) | | tier | "fast" | "fast" ($0.008) · "standard" ($0.02) · "deep" ($0.08) | | confidenceThreshold | 0.7 | Minimum confidence to APPROVE | | timeout | 10000 | Request timeout in ms |

Verification Policy

| Option | Default | Description | |--------|---------|-------------| | minAmount | 0 | Skip verification below this USD amount | | maxAmount | Infinity | Auto-deny above this USD amount | | skipRoutes | [] | Glob patterns to skip (e.g., "/health", "/api/*/public") | | requireRoutes | [] | Only verify these routes (takes precedence) | | onUncertain | "deny" | Action on UNCERTAIN: "allow" or "deny" | | onError | "allow" | Action on timeout/error: "allow" or "deny" | | decide | — | Custom function: (result, context) => boolean |

Lifecycle Hooks

thoughtproofMiddleware({
  thoughtproof: { apiKey: "..." },
  onBeforeVerify: (context) => {
    // Return false to skip verification for this request
    return context.agentAddress !== TRUSTED_AGENT;
  },
  onAfterVerify: (result, context) => {
    // Log, emit metrics, update dashboards
    metrics.record("verification", result.verdict, result.durationMs);
  },
  onDeny: (result, context) => {
    // Alert, audit log, notify admin
    alerting.send(`Denied ${context.agentAddress}: ${result.reasoning}`);
  },
});

Architecture

┌─────────────┐     ┌──────────────────┐     ┌─────────┐     ┌──────────┐
│  AI Agent   │────▶│ thoughtproof-x402 │────▶│  x402   │────▶│ Resource │
│  (wallet)   │     │   verify reasoning │     │ payment │     │  Server  │
└─────────────┘     └──────────────────┘     └─────────┘     └──────────┘
                            │                       │
                            ▼                       ▼
                    ┌──────────────┐        ┌─────────────┐
                    │ ThoughtProof │        │  Base/ETH   │
                    │     API      │        │  Settlement │
                    └──────────────┘        └─────────────┘

thoughtproof-x402 intercepts the payment flow at the decision layer — after the agent decides to pay, before the money moves.

What ThoughtProof Verifies

  • Decision coherence: Is the agent's stated reasoning internally consistent?
  • Grounding: Are the claims in the reasoning backed by verifiable data?
  • Proportionality: Is the payment amount proportional to the stated purpose?
  • Intent alignment: Does the action match what the agent says it's trying to do?

This is not security (that's identity + permissions). This is not reputation (that's history). This is epistemic verification — checking whether the reasoning is actually sound.

License

MIT

Links