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

@mekik/langchain

v0.7.1

Published

LangChain integration for mekik — surface agent tool calls in the UI, gate them behind human approval, and make them exactly-once across an interrupt/resume.

Readme

@mekik/langchain

LangChain integration for mekik. Run a LangChain agent inside an ilmek node and get, per tool:

  • Visibility — the agent's tool calls surface in the UI as tool_call traces
  • Approval — a tool can pause for a human before it runs
  • Exactly-once — tools are journaled, so a pause/resume doesn't re-run them
import { withMekikTools } from "@mekik/langchain";

.node("agent", async (state, ctx) => {
    const tools = withMekikTools(ctx, [getOrder, refundPayment, internalLookup, charge], {
        get_order:       { show: true },                        // trace shown
        refund_payment:  { show: true, approve: true },          // ask the human first
        internal_lookup: { show: false },                        // runs, not shown
        charge:          { show: true, redact: ["cardNumber"] }, // shown, masked
    });

    // `createAgent` from `langchain` v1 — the prebuilt `createReactAgent` it
    // replaced still works, but it is the legacy entry point.
    const agent = createAgent({ model, tools });
    const out = await agent.invoke({ messages: [new HumanMessage(state.input)] });
    return { reply: lastText(out) };
})

The wrapped tools keep their name, description and schema, so the agent binds them to the model exactly as before.

Why wrapping, not just callbacks

A LangChain agent invokes its own tools. That leaves two gaps mekik normally closes for you with mekik.tool(...):

  1. Nothing emits a tool_call frame, so the UI never learns a tool ran.
  2. When a node pauses for a human and the graph resumes, the node re-runs from the top — and the agent calls its tools again. Only ctx.step makes an effect survive that replay.

withMekikTools closes both, because it owns the invocation. A callback handler can only close the first.

Policy

interface ToolPolicy {
    show?: boolean;                   // surface the trace (default true)
    approve?: boolean | ApproveSpec;  // pause for a human first (default false)
    redact?: readonly string[];       // mask these fields in the surfaced trace
}

redact masks only what is surfaced — the tool itself still receives the real values. When the human declines an approve tool, it is never executed and the agent gets a plain observation back (denyMessage, default "The user declined to run <tool>.") so its loop can continue.

Approvals reach the client as ordinary mekik interrupt frames: chativa renders Approve/Reject chips, or a form if you pass ui. Each tool gets its own stable interrupt key, so several approvals in one node stay separately addressable.

mekikCallbacks — the fallback

When you cannot wrap the tools (a prebuilt agent that owns them):

const out = await agent.invoke(input, { callbacks: [mekikCallbacks(ctx, policy)] });

Visibility only. It cannot journal the tool, so after a pause and resume the agent will invoke its tools a second time. Prefer withMekikTools; keep the tools behind this one side-effect free.

Install

pnpm add @mekik/langchain @mekik/core

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

MIT