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

postbridge-langchain

v0.1.0

Published

PostBridge postal tools for LangChain JS and LangGraph — send physical letters to 5 countries from any LangChain agent.

Readme

postbridge-langchain (JS / TypeScript)

Drop-in PostBridge postal tools for LangChain JS and LangGraph — send physical letters to US, France, UK, Canada, and Germany from any LangChain Node/TypeScript agent.

Python user? Check the Python package: pip install postbridge-langchain.

Install

npm install postbridge-langchain @langchain/core
# or
pnpm add postbridge-langchain @langchain/core
# or
yarn add postbridge-langchain @langchain/core

@langchain/core is a peer dependency — bring your own version.

Quickstart — direct bindTools

import { ChatOpenAI } from "@langchain/openai";
import { postbridgeTools } from "postbridge-langchain";

const llm = new ChatOpenAI({ model: "gpt-4o-mini" });
const llmWithTools = llm.bindTools(postbridgeTools());

const response = await llmWithTools.invoke(
  "Send a letter to Marie Dupont at 15 Rue de Rivoli, 75001 Paris, France."
);

Quickstart — LangGraph createReactAgent

import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { postbridgeTools } from "postbridge-langchain";

const agent = createReactAgent({
  llm: new ChatOpenAI({ model: "gpt-4o-mini" }),
  tools: postbridgeTools(),
});

const result = await agent.invoke({
  messages: [{ role: "user", content: "Send a letter to Paris..." }],
});

Quickstart — AgentExecutor

import { ChatOpenAI } from "@langchain/openai";
import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { postbridgeTools } from "postbridge-langchain";

const tools = postbridgeTools();
const prompt = ChatPromptTemplate.fromMessages([
  ["system", "You are a postal assistant. Use the tools to send letters."],
  ["human", "{input}"],
  ["placeholder", "{agent_scratchpad}"],
]);
const agent = await createToolCallingAgent({
  llm: new ChatOpenAI({ model: "gpt-4o-mini" }),
  tools,
  prompt,
});
const executor = new AgentExecutor({ agent, tools });
const result = await executor.invoke({ input: "Send a letter to Paris..." });

Tools available

| Tool | HTTP | Purpose | |------|------|---------| | list_services | GET /api/services/{country} | Discover services per country | | quote_letter | POST /api/quote | Price a letter | | send_letter | POST /api/send | Mail it | | track_letter | GET /api/track/{letter_id} | Live status | | get_proof | GET /api/proof/{letter_id} | Signed PostalProof VC | | get_balance | GET /api/balance | Wallet + ledger | | negotiate_pricing | POST /api/anp/offer | ANP tiered offer | | accept_offer | POST /api/anp/accept | Lock in tier |

Subset selection

Filter to the tools your agent actually needs:

// Read-only reporter
const tools = postbridgeTools({
  only: ["list_services", "quote_letter", "track_letter", "get_proof"],
});

// Send-only dispatcher
const tools = postbridgeTools({ only: ["send_letter", "track_letter"] });

// Full negotiation flow
const tools = postbridgeTools({
  only: ["negotiate_pricing", "accept_offer", "send_letter"],
});

Authentication

Tools call https://api.postbridge.ai. By default the dispatcher reads POSTBRIDGE_API_KEY from process.env:

export POSTBRIDGE_API_KEY=pb_live_...
node your-agent.mjs

Or pass a token explicitly when building the toolkit:

const tools = postbridgeTools({ apiKey: "pb_live_..." });

Get a key in one request

curl -X POST https://api.postbridge.ai/auth/agent \
  -H 'Content-Type: application/json' \
  -d '{"agent_id": "my-agent", "agent_name": "My LangChain Agent"}'

Returns a scoped pb_live_... key. Or skip the key entirely and use x402 USDC per-request.

Direct dispatcher usage (outside an agent loop)

import { execute } from "postbridge-langchain";

const quote = await execute("quote_letter", {
  to_name: "Marie Dupont",
  to_line1: "15 Rue de Rivoli",
  to_city: "Paris",
  to_postal_code: "75001",
  to_country: "FR",
  service: "fr_lettre_verte",
});
console.log(quote);

How it works

  • Single source of truth — the canonical tool catalog (tools.json) is bundled into the package. The same catalog powers the Python postbridge-core package, so every agent framework across Python and JS sees identical tool definitions, identical Zod/Pydantic validation, and identical HTTP mappings.
  • Zod schemas, auto-generated — each tool's JSON Schema is converted to a Zod object at runtime so LangChain's tool-calling prompts include proper arg types, enums, and descriptions.
  • Server-side determinism — the tools never compute prices or format addresses. All of that happens in the PostBridge API, which enforces rate-table pricing, country-specific address formatting, and recipient-country postal routing.
  • Margin confidentiality — internal pricing fields are stripped from every response before reaching the client.

TypeScript support

Full .d.ts types shipped. Import the types if you're writing wrapping code:

import type {
  Catalog,
  ToolDef,
  DispatchResult,
  PostBridgeToolsOptions,
} from "postbridge-langchain";

Related packages

Python:

  • postbridge-core — raw catalog + dispatcher
  • postbridge-crewai — CrewAI tools
  • postbridge-langchain — LangChain (Python) tools
  • postbridge-llamaindex — LlamaIndex tools

Docs:

License

Proprietary. See postbridge.ai.