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

@uncaged/nerve-daemon

v0.5.0

Published

The observation engine runtime for [nerve](../../README.md) — runs senses, routes signals, schedules reflexes, and manages workflows.

Downloads

1,531

Readme

@uncaged/nerve-daemon

The observation engine runtime for nerve — runs senses, routes signals, schedules reflexes, and manages workflows.

Architecture

| Module | Source (indicative) | Responsibility | |--------|---------------------|----------------| | Kernel | kernel.ts | Orchestrator — worker pool, signal bus, reflex scheduler, workflow manager, optional file watcher and daemon IPC, config reload hooks | | Worker pool | worker-pool.ts | Fork and supervise one child process per sense group; restart/shutdown; crash cleanup hooks for scheduler state | | Kernel sense groups | kernel-sense-groups.ts | Derive sense groups from config; list senses per group for scheduling | | Sense runtime | sense worker + Drizzle | Per-sense SQLite (node:sqlite), migrations, peer DB reads | | Sense worker | sense-worker.ts (fork target) | Child process entry — runs compute() per sense in a group | | Signal bus | signal-bus.ts | In-memory pub/sub for sense signals | | Reflex scheduler | reflex-scheduler.ts | Interval + on subscriptions, throttle/coalesce | | Workflow manager | workflow-manager.ts | One worker per workflow name, concurrency (drop/queue), queue caps | | Workflow worker | workflow-worker.ts | Child process — runs RFC-002 threads (start-thread, resume-thread IPC) | | IPC (parent ↔ workers) | ipc.ts | Typed messages for sense and workflow workers (includes resume-thread for recovery) | | Log / workflow persistence | via @uncaged/nerve-store | Structured logs, workflow_runs, thread messages (used for recovery) | | Blob store | @uncaged/nerve-store | CAS under data/blobs/ — sense workers construct createBlobStore(join(nerveRoot, "data", "blobs")) for artifact writes | | File watcher | file-watcher.ts | Watches workspace paths for config / sense / workflow file changes | | Kernel file watch | kernel-file-watch.ts | Maps watcher events to reloadConfig, sense group restart, workflow drainAndRespawn | | Daemon IPC | daemon-ipc.ts | Unix socket server — parses @uncaged/nerve-core DaemonIpcRequest, dispatches trigger-workflow / trigger-sense / list-senses |

Crash recovery (workflow workers)

If a workflow worker exits unexpectedly while threads are active:

  • In-flight runs are marked crashed in the log store; the manager respawns a fresh worker.
  • Runs still in started state can be resume-thread’d: the manager rebuilds the message chain from persisted workflow log rows and sends resume-thread to the new worker.
  • Crash-loop backoff: repeated crashes for the same workflow name are counted in a sliding window (60s); after 5 crashes in that window, the manager stops respawning that worker and logs the condition (avoids tight crash loops).

Hot reload (drainAndRespawn) uses a controlled drain: in-flight runs may be marked interrupted when the old worker is torn down after a timeout — that path is distinct from unexpected crash recovery.

Key Design Decisions

  • One worker process per sense group — isolation between groups, shared compute within a group
  • node:sqlite (DatabaseSync) — zero native addons, WAL mode, built into Node.js ≥ 22.5
  • Throttle + coalesce — if compute is in-flight, at most one pending trigger is queued (no unbounded accumulation)
  • Log ≠ Signal — logs are queryable data assets but cannot trigger reflexes (prevents feedback loops)

Usage

The daemon is typically started via the CLI (nerve daemon start / nerve dev), but you can embed the kernel:

import { readFileSync } from "node:fs";
import { join } from "node:path";

import { parseNerveConfig } from "@uncaged/nerve-core";
import { createKernel } from "@uncaged/nerve-daemon";

const nerveRoot = "/path/to/workspace";
const yamlPath = join(nerveRoot, "nerve.yaml");
const parsed = parseNerveConfig(readFileSync(yamlPath, "utf8"));
if (!parsed.ok) {
  throw parsed.error;
}

const kernel = createKernel(parsed.value, nerveRoot, {
  enableFileWatcher: true,
  ipcSocketPath: join(nerveRoot, "nerve.sock"),
});

await kernel.ready;

kernel.triggerSense("cpu-usage");
const health = kernel.getHealth();

await kernel.stop();

createKernel(config, nerveRoot, options?)config is a parsed NerveConfig; nerveRoot is the workspace root (contains nerve.yaml, data/, etc.). Optional KernelOptions:

| Field | Meaning | |-------|---------| | workerScript | Override path to the sense worker entry script (defaults to the package’s resolved worker) | | enableFileWatcher | Watch config / senses / workflows for hot reload | | logStore | Inject a LogStore instance (defaults to createLogStore(join(nerveRoot, "data", "logs.db"))) | | ipcSocketPath | When non-null, listen for daemon IPC on this Unix socket path |

Install

pnpm add @uncaged/nerve-daemon

Requires Node.js ≥ 22.5 (for node:sqlite).

License

MIT