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

@nia-agent-cyber/agent-trust-langchain

v0.1.0

Published

LangChain integration for Agent Trust SDK — trust-tier middleware for AI agent chains

Readme

@nia-agent-cyber/agent-trust-langchain

LangChain middleware for Agent Trust — add trust-tier gating to your LangChain agent chains.

Installation

npm install @nia-agent-cyber/agent-trust-langchain @nia-agent-cyber/agent-trust-sdk @langchain/core ethers

Quick Start

import { AgentTrust } from '@nia-agent-cyber/agent-trust-sdk';
import { TrustCheckTool, TrustGate, TrustGateError, createTrustMiddleware } from '@nia-agent-cyber/agent-trust-langchain';
import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://sepolia.base.org');
const agentTrust = new AgentTrust({ network: 'baseSepolia', provider });

// ── TrustCheckTool: look up trust tier ────────────────────────────────────
const tool = new TrustCheckTool({ agentTrust, requiredTier: 'contributor' });
const result = await tool._run({ address: '0x...' });
// { address, tier: { level, name, score }, meets: true, requiredTier: 'contributor' }

// Register with a LangChain agent
const langChainTool = tool.toLangChainTool();

// ── TrustGate: block chain execution below required tier ──────────────────
const gate = new TrustGate({
  agentTrust,
  requiredTier: 'contributor',
  addressKey: 'counterpartyAddress',
  onBlocked: (state) => ({ ...state, blocked: true }), // optional: fallback instead of throw
});

const chain = gate.pipe(myDownstreamTool);
const output = await chain.invoke({ counterpartyAddress: '0x...', ...otherState });

// ── createTrustMiddleware: factory for both ───────────────────────────────
const { tool: t, gate: g } = createTrustMiddleware({ agentTrust, requiredTier: 'contributor' });

API

TrustCheckTool

Wraps AgentTrust.getTier() + getScore() as a LangChain-compatible tool.

| Config | Type | Description | |--------|------|-------------| | agentTrust | AgentTrustLike | AgentTrust instance | | requiredTier? | TierName | Default minimum tier | | name? | string | Tool name (default: agent_trust_check) | | description? | string | Tool description |

Methods:

  • _run(input)TrustCheckOutput — structured result
  • invoke(input)string — JSON-serialized result
  • toLangChainTool()DynamicStructuredTool — LangChain-native tool

TrustGate

A Runnable step that gates chain execution by trust tier.

| Config | Type | Description | |--------|------|-------------| | agentTrust | AgentTrustLike | AgentTrust instance | | requiredTier | TierName | Minimum tier to pass | | addressKey? | string | State key for address (default: 'address') | | onBlocked? | (state) => state | Fallback instead of throwing |

Methods:

  • invoke(state) → passes state through or throws TrustGateError
  • pipe(next) → composed chain
  • toLangChainRunnable()RunnableLambda

TrustGateError

Thrown by TrustGate when trust check fails:

  • error.address — the blocked address
  • error.tier — actual tier name
  • error.requiredTier — required tier name

createTrustMiddleware(config)

Factory that creates a { tool, gate } pair from a shared config.

Tier Names

| Level | Name | Description | |-------|------|-------------| | 0 | unverified | Default for new agents | | 1 | contributor | Active with basic reputation | | 2 | trusted | Established with peer vouches | | 3 | verified | Highly trusted, strong validation | | 4 | expert | Elite, exceptional track record |

Testing

npm test

All tests are offline (mocked AgentTrust — no live RPC calls).

Tutorial

See docs/tutorials/langchain-trust-middleware.md for a full integration guide.