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

@bhooai/nexus-cluster

v0.1.5

Published

Multi-host mesh for BhooAI Nexus: node agent (control API on every node), central registry, round-robin load balancer, deterministic + AI autoscaler, and a `ClusterManager` that glues it together for the CLI and admin UI.

Readme

@bhooai/nexus-cluster

Multi-host mesh for BhooAI Nexus: node agent (control API on every node), central registry, round-robin load balancer, deterministic + AI autoscaler, and a ClusterManager that glues it together for the CLI and admin UI.

Exports

  • NodeAgent — lives on every node (cluster.nodeAgentPort, default 7575). Owns the node's role service as one child process and exposes /health, /info, /exec, /metrics, all bearer-gated by the shared pairing token.
  • NodeClient — central→node HTTP client; info(), health(), metrics(), exec(), bearer-authenticated.
  • NodeRegistry — the central's book of linked nodes, persisted to a JSON file (gitignored) so the mesh survives restarts. link(), poll(), readyByRole(role), remove.
  • LoadBalancer — central-side reverse proxy on cluster.lbPort (default 8080) that round-robins across every ready backend node, streaming raw bodies (SSE/uploads pass through) and stamping x-bhooai-node.
  • Autoscaler — samples the LB's RPS histogram + node metrics every 10s and decides scale-up / scale-down: deterministic guardrails (RPS + CPU hysteresis) always active in auto mode, with an optional AI advisor whose move is only followed inside the [minNodes, maxNodes] rails.
  • HttpAiAdvisor — the AI-manages-it layer; asks the BhooAI Nexus AI server for a one-line scale-up|scale-down|hold, falls back to rules on error/off-rail.
  • ClusterManager — assembles registry + LB + autoscaler from cluster.* config and exposes link, unlink, exec, scaleTo, startNode, stopNode, restartNode, pollAll, rps.
  • nodeIdFor(root, role) — canonical stable node id (project-root hash + role).
  • Types — NodeIdentity, NodeHealth, NodeMetricsSample, NodeExecRequest/Result, RegistryNode, NodeTier, NodeCommand.

Flow

node side:  nexus node serve --role=backend --port=<nodeAgentPort>   (starts NodeAgent)
central:    nexus cluster serve                                      (registry + LB + autoscaler)
            nexus cluster link http://<node-host>:<node-port>        (handshake + register)

Both sides read host/port/token from the same nexus.config.ts cluster section: lbPort 8080, nodeAgentPort 7575, shared token, autoscale minNodes/maxNodes.

Multiple nodes on one device

Each agent needs a unique --port and ideally its own project directory. Two agents on one machine can run from one project (quick test only — they share a node id), or from separate nexus init folders (recommended — distinct backend ports + node ids):

# project A (master)
nexus cluster serve
# project B (slave, different folder)
nexus node serve --role=backend --port=7575
# project C (slave, different folder, different port)
nexus node serve --role=backend --port=7576
# from project A
nexus cluster link http://localhost:7575
nexus cluster link http://localhost:7576

Config

cluster: {
  enabled: true,
  failOpenSingleNode: true,
  lbHost: '0.0.0.0', lbPort: 8080,
  nodeAgentHost: '0.0.0.0', nodeAgentPort: 7575,
  registryFile: 'cluster.runtime.json',
  token: '<shared pairing secret>',
  autoscale: { enabled: true, mode: 'auto', minNodes: 1, maxNodes: 4,
               cooldownMs: 60_000, cpuHigh: 80, rpsPerNodeHigh: 15, rpsPerNodeLow: 5 },
}

With failOpenSingleNode, the LB fails open to a single direct node when no scaling is needed.