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

@inariwatch/substrate-agent

v0.1.2

Published

Record and replay Node.js I/O — the execution layer for autonomous software

Downloads

337

Readme

@inariwatch/substrate-agent

Record and replay Node.js I/O for deterministic debugging and AI-powered fix verification.

Substrate captures every external interaction your app makes — HTTP requests, database queries, file reads, randomness, DNS lookups — and can replay them deterministically against new code to verify fixes before deployment.

Install

npm install @inariwatch/substrate-agent

Quick Start

SDK Mode (recommended)

Import and initialize in your app's entry point:

import { init, flush } from "@inariwatch/substrate-agent";

init({
  bufferSeconds: 60,  // Keep last 60 seconds of events
  dsn: process.env.INARIWATCH_DSN,  // Optional: auto-upload on exceptions
});

Flush the recording buffer on demand:

// Get the recording object
const recording = flush();

// Or upload directly to InariWatch
await flush("https://app.inariwatch.com/api/recordings/upload");

With @inariwatch/capture

If you're already using @inariwatch/capture, enable Substrate with one flag:

import { init } from "@inariwatch/capture";

init({
  dsn: "your-dsn",
  substrate: true,  // Enables I/O recording
});

Or via environment variable:

INARIWATCH_SUBSTRATE=true node app.js

What Gets Recorded

| Category | APIs Patched | Events | |---|---|---| | HTTP | http.request, https.request, fetch | Request URL, method, status, response body, duration | | Database | pg (PostgreSQL), mysql2, ioredis | Query text, row count, duration, errors | | Time | Date.now | Timestamp values | | Randomness | Math.random, crypto.randomBytes | Generated values | | DNS | dns.lookup | Hostname, resolved addresses | | File I/O | fs.readFile, fs.writeFile | Path, content, errors | | Exceptions | uncaughtException, unhandledRejection | Error name, message, stack trace |

Deterministic Replay

Substrate can replay recorded I/O against modified code to detect behavioral changes:

# Record a session
SUBSTRATE_RECORDER_PORT=9302 node --require @inariwatch/substrate-agent app.js

# Replay against new code
SUBSTRATE_REPLAY_FILE=recording.json node --require @inariwatch/substrate-agent/replay app.js

During replay:

  • HTTP requests return recorded responses (no network calls)
  • Database queries return recorded results (no DB connection)
  • Date.now() and Math.random() return recorded values
  • File reads return recorded content
  • File writes become no-ops
  • Divergences (extra HTTP calls, different queries) are detected and reported

Privacy & Redaction

Substrate redacts sensitive data by default:

init({
  redact: {
    headers: ["authorization", "cookie", "x-api-key"],
    body_urls: ["/api/auth/*", "/api/tokens/*"],
    query_patterns: ["password", "secret", "token"],
  },
});

API

init(config?)

Initialize Substrate instrumentation. Call once at app startup.

| Option | Type | Default | Description | |---|---|---|---| | bufferSeconds | number | 60 | Ring buffer duration (0 = unlimited) | | redact | object | Default rules | Redaction configuration | | dsn | string | — | InariWatch DSN for auto-notification on exceptions |

flush(dsn?)

Flush the event buffer and return a Recording object. If dsn is provided, uploads the recording to InariWatch.

getBuffer()

Get the current event buffer without clearing it. Returns { events, count }.

How InariWatch Uses Substrate

When InariWatch's AI remediation pipeline generates a fix:

  1. Shadow Replay — replays your production recording against the fix code
  2. Divergence Detection — identifies behavioral changes (new HTTP calls, different DB queries)
  3. Risk Scoring — assigns a risk score based on divergence severity
  4. Safety Gate — blocks auto-merge if replay risk exceeds threshold

This gives you confidence that the AI's fix doesn't change your app's behavior in unexpected ways.

License

MIT