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

@trustflow/vercel-ai-middleware

v1.0.5

Published

Vercel AI SDK fetch and stream middleware that rejects unverified Trustflow domain context.

Readme

@trustflow/vercel-ai-middleware

Fetch and language-model middleware for the Vercel AI SDK. The default mode is audit. Unverified, unsigned, or tampered Trustflow domain context does not throw. The middleware logs a security alert, emits a telemetry event, and does not parse llms.txt. { strict: true } or { mode: "strict" } rejects that context before a response stream starts and before llms.txt is parsed.

Verification and signing stay in @trustflow/sdk (agenticTrustMiddleware). The hosted registry is Trustflow Systems (https://api.trustflow.systems).

License: MIT

Do not install trustflow-sdk. That name is an unrelated package. Scaffold a domain with npx @trustflow/cli@latest init.

Install

npx @trustflow/cli@latest init
npm install @trustflow/vercel-ai-middleware @trustflow/sdk

Contributors

Clone and pnpm install apply only when changing this monorepo. They are not the product install.

ai is an optional peer dependency. Pass fetch to a provider and the middleware object to wrapLanguageModel. This package does not import ai.

Use

import { createOpenAI } from "@ai-sdk/openai";
import { generateText, streamText, wrapLanguageModel } from "ai";
import { agenticTrustVercelAiMiddleware } from "@trustflow/vercel-ai-middleware";

const trust = agenticTrustVercelAiMiddleware({
  verificationApiUrl: "https://api.trustflow.systems",
  // strict: true,
});

const openai = createOpenAI({ fetch: trust.fetch });

const model = wrapLanguageModel({
  model: openai("gpt-5.5"),
  middleware: trust,
});

const result = await generateText({
  model,
  prompt: "Summarize the verified domain context.",
});

const stream = streamText({
  model,
  prompt: "Summarize the verified domain context.",
});

const llms = await trust.loadLlmsFromUrl("https://example.com/llms.txt");
// llms.text starts with "Verified Domain Context | Trustflow"

trust.fetch forwards ordinary provider URLs (for example api.openai.com) without a domain check. A request is domain context when the path ends in llms.txt, or when the request sets x-agentic-trust-context: llms.txt or x-agentic-trust-context: domain. Those requests call the SDK first. In audit mode the fetch continues, the trust header is not set, and the alert below is logged. In strict mode UnverifiedDomainContextError is thrown before contextFetch runs, so the response body is never read.

import { UnverifiedDomainContextError } from "@trustflow/vercel-ai-middleware";

try {
  await trust.loadLlmsFromUrl("https://unsigned.example/llms.txt");
} catch (err) {
  if (err instanceof UnverifiedDomainContextError) {
    // err.domain, err.status ("UNVERIFIED" | "RISK"), err.reason
    // "[Trustflow Security Error] Context Poisoning Defense Triggered: Unverified or tampered llms.txt payload detected for unsigned.example. Execution blocked."
  }
}

transformParams rewrites llms.txt envelopes in prompt or messages after verification, which is what wrapLanguageModel applies before doGenerate and doStream. wrapGenerate and wrapStream run the same check. Strict mode does not call the model when the domain is unsigned. Audit mode calls it and does not parse the body. readVerifiedLlms({ target, content }) is the in-memory form of loadLlmsFromUrl: the content function is not called when verification fails.

Verified fetches keep the original body stream and set x-agentic-trust to { "verified": true, "domain", "trustScore" }.

The SDK lookup uses the fetch option (registry and did:web). The context download uses contextFetch, which defaults to global fetch.

The default is audit mode (mode: "audit"). fetch, transformParams, wrapGenerate, wrapStream, loadLlmsFromUrl, and readVerifiedLlms warn and continue without parsing. The console warning and the telemetry message are:

[Trustflow Security Alert] Unverified context payload detected for <domain>. Enable strict mode to block.

Pass onAudit to receive that event. There is no network call. { strict: true }, { mode: "strict" }, or { failClosed: true } throws before execution. The thrown message is:

[Trustflow Security Error] Context Poisoning Defense Triggered: Unverified or tampered llms.txt payload detected for <domain>. Execution blocked.

Signing the files those checks read, without a local terminal, is @trustflow/vercel-plugin: set AGENTIC_TRUST_PRIVATE_KEY and AGENTIC_TRUST_DOMAIN in the Vercel project environment and use buildCommand agentic-trust-vercel && next build. The private key is not committed. See packages/vercel-plugin.