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

@riv-io/langchain

v0.2.0

Published

Adapter LangChain.js do Riv — tools prontas (riv_authorize, riv_get_activity) e guard determinístico para tools de pagamento.

Readme

@riv-io/langchain

Adapter LangChain.js do Riv — governança financeira para agentes, construído sobre @riv-io/sdk.

npm install @riv-io/langchain @langchain/core

Caminho recomendado: withRivGuard

Embrulhe sua tool de pagamento com o guard: o Riv é consultado antes de cada execução, deterministicamente — a governança não depende de o LLM lembrar de pedir autorização.

import { withRivGuard } from "@riv-io/langchain";

const guardedPay = withRivGuard(payInvoiceTool, {
  apiKey: process.env.RIV_API_KEY!,
  extract: (input) => ({ amount: input.total, currency: "BRL" }),
});

const agent = createReactAgent({ llm, tools: [guardedPay] });
  • allow → a tool executa normalmente.
  • block / require_approval → a tool nem executa; o agente recebe o veredito (decisão, motivo, activityId) como texto.
  • Falha ao consultar o Riv (rede, credencial) → fail-closed: a tool não executa.
  • extract mapeia o input da sua tool para { amount, currency, description? }.
  • O guard preserva nome, descrição e schema da tool original — para o LLM, nada muda.

Para reusar um client: withRivGuard(tool, { riv: meuClient, extract }).

As opções aceitam também baseUrl — default http://localhost:3000 (dev local); em produção, aponte para https://riv-io.vercel.app: withRivGuard(tool, { apiKey, baseUrl: "https://riv-io.vercel.app", extract }) ou rivTools({ apiKey, baseUrl: "https://riv-io.vercel.app" }).

Complemento: rivTools

Tools prontas para a lista do agente — para consultar o ledger e para fluxos sem uma tool de pagamento a embrulhar:

import { rivTools } from "@riv-io/langchain";

const agent = createReactAgent({
  llm,
  tools: [...rivTools({ apiKey: process.env.RIV_API_KEY! }), ...outrasTools],
});
  • riv_authorize({ amount, currency, description?, category? }) — pede a decisão de governança (mesma semântica do MCP server do Riv); category ativa mandatos por categoria.
  • riv_get_activity({ activityId?, limit? }) — consulta pontual ou extrato.

Atenção: por este caminho, executar o gasto só quando ALLOW depende do LLM. Quando existir uma tool de pagamento, prefira o withRivGuard.

Desenvolvimento

cd adapters/langchain
npm install
npm run build        # tsup → dist/ (ESM + CJS + d.ts)
npm run typecheck
npm run test         # unitários (fetch mockado)

# E2E (a partir da raiz do repo; sobe a app em porta efêmera):
#   node --env-file=.env scripts/verify-langchain.mjs