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

@escouade/graph-trace-langchain

v0.1.2

Published

LangChain/LangGraph callback adapter feeding graph-trace.

Readme

@escouade/graph-trace-langchain

npm version License: MIT TypeScript peer: @langchain/core

LangChain / LangGraph callback adapter for @escouade/graph-trace. Attach it to any LangChain or LangGraph run and the trace is captured for you — no manual event plumbing.

  • Native callback handler — extends BaseCallbackHandler; attach via config.callbacks.
  • Captures the whole run — LLM turns (handleChatModelStart/handleLLMEnd) and tools (handleToolStart/End/Error), even in graph mode where the stream hides them.
  • Graph-node attribution — reads LangGraph's langgraph_node metadata so each event knows which node emitted it.
  • Auto-closes the run — from the root chain end/error (run.end ok/error), so you never pose it by hand.

This is the only piece coupled to LangChain; the @escouade/graph-trace core stays runtime-agnostic.

Install

npm install @escouade/graph-trace-langchain @escouade/graph-trace @langchain/core

@langchain/core is a peer dependency.

Usage

Open a trace from a graph-trace collector, wrap it with the adapter, and attach it to the run.

import { TraceCollector } from '@escouade/graph-trace';
import { FileExporter } from '@escouade/graph-trace-file-exporter';
import { langChainTraceHandler } from '@escouade/graph-trace-langchain';

const collector = new TraceCollector({
  exporters: [new FileExporter({ resolvePath: (doc) => `./traces/${doc.meta.traceId}.json` })],
});

// At app shutdown — drain all buffered runs:
process.on('SIGTERM', async () => {
  await collector.shutdown();
  process.exit(0);
});

const trace = collector.createTrace({
  provider: 'anthropic', // known at LLM client init, not in input
  model: 'claude-sonnet-4-6', // idem
  workflow,
  systemPrompt: input.systemPrompt,
  context: input.context ?? '',
  history: input.messages, // your graph state's message list
  tags: { agent: 'assistant' }, // optional free-form metadata
});

try {
  await graph.invoke(input, { callbacks: [langChainTraceHandler(trace)] });
} catch (err) {
  trace.fail(err); // safety net if the error was thrown before any chain ran
  throw err;
}

langChainTraceHandler(recorder) returns a LangChainTraceHandler (also exported as a class). It feeds the TraceRecorder from graph-trace; pass several handlers in callbacks if you need your own alongside it.

Tagging runs

Pass tags in createTrace to attach free-form string → string metadata. Tags are forwarded to TraceTurn.tags in the projected document.

const trace = collector.createTrace({
  // …
  tags: {
    agent: 'planner',
    env: process.env.NODE_ENV,
    userId: session.userId,
  },
});

See graph-trace tagging docs for details.

Resources

License

MIT