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

secondwind

v0.3.2

Published

Lossless, provable, composable LLM context compression

Readme

secondwind

Lossless, provable, composable LLM tool-output compression, in-process.

Native (lowest-overhead path). One import, both runtimes: it binds the shared library through Bun's built-in FFI under Bun and through koffi under Node. The right per-platform binary installs automatically:

import { Session, compress, verify } from "secondwind";

const session = new Session();
const out = session.rewrite(request);       // compress a whole request's tool outputs
console.log(out.stats);                      // tokens saved

// one-line Vercel AI SDK integration:
import { wrapLanguageModel } from "ai";
import { secondwindMiddleware } from "secondwind/vercel";
const model = wrapLanguageModel({ model: openai("gpt-4o"), middleware: secondwindMiddleware() });

// LangGraph.js: compress the tool outputs an agent loop re-sends before each model call
import { compressPreModelHook } from "secondwind/langgraph";
const agent = createReactAgent({ llm: model, tools, preModelHook: compressPreModelHook() });

The Session takes an options object, the same surface as the Python binding:

new Session({ codec: myCodec });               // your codec competes in the best-of-N, dropped if it ever fails
new Session({ proposers: false });             // turn the aggressive search off
new Session({ store, resolver, offloadDir });  // offload + recover, or a Redis / S3 / db-backed store

Sandboxed WebAssembly (plain Node, Deno, Bun, or the browser; no native build, no Bun required):

import { load } from "secondwind/wasm";

const sw = await load();
const out = sw.compress(block);
// Inline result: { wire, certificate }. A large block returns a recoverable { stub, marker } instead.
if (out.wire) sw.verify(out.wire, out.certificate.hash);  // confirm losslessness in the sandbox
const session = sw.session();
session.rewrite(request);

Every result is lossless: an inline wire is independently verifiable with verify(wire, hash), and a large block is offloaded to a recoverable marker. The native library and the wasm module are both bundled, so there is no build step and no model download.

The wasm module imports nothing from the host (check WebAssembly.Module.imports yourself: the list is empty), so it has no capability to read a file, open a socket, or read a clock. It takes bytes in and gives bytes back.