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

procage

v0.8.0

Published

Run commands caged by the OS sandbox from Node.js: macOS Seatbelt, Linux Landlock, seccomp and namespaces

Readme

procage

Run commands caged by the operating system's sandbox, from Node.js. On macOS procage applies Seatbelt profiles through libsandbox (no sandbox-exec); on Linux it uses Landlock, seccomp and, where the host allows, user namespaces. This package binds the Rust crate procage: the same presets, the same checks, the same refusals.

npm install procage

macOS on Apple silicon and Linux x64 and arm64 (glibc 2.28 or later), Node.js 22.12 or later. TypeScript declarations included; no build step, no dependencies. Every platform runs the binding's escape tests in CI from the packed package.

import { Policy, run } from "procage";

const policy = Policy.preset("agent_workspace", 3, { workspace: "/abs/project" });
const done = await run(policy, "npm test", { shell: true, timeout: 600_000 });
console.log(done.exitCode, done.stdout, done.violations);

agent_workspace lets the command read and write the workspace (its working directory), run the system's programs and nothing else: no network, no secrets of the user's home, no writes outside the workspace. Other presets: minimal, agent_readonly, build (adds loopback networking; macOS only). Any policy can also be loaded from procage's versioned JSON format with Policy.fromJSON.

run

const done = await run(policyOrCage, ["git", "status"], {
  cwd,            // default: the preset's workspace
  env: { CI: 1 }, // the only variables set explicitly; process.env is never copied
  input: "…",     // written to standard input
  timeout: 60_000,          // ms; then the run is ended: TimeoutError
  signal: controller.signal, // aborting ends the run
  check: true,              // non-zero exit: ExitError (with .result)
  encoding: "buffer",       // default "utf8"
});
// { command, exitCode, signal, stdout, stderr, violations, receipt }

A string command needs shell: true (/bin/sh -c). Paths may be strings or file: URLs. Spawning, waiting and reading happen on the thread pool, so many runs proceed at once and the event loop stays free.

Cages and runs

const cage = new Cage(policy, { violations: true }); // reuse for many runs
await using run = await cage.spawn(["node", "tool.js"]); // Node 24+: ends the run at the block's end
const { exitCode, stdout } = await run.output();

Run has pid, wait(), output({ input, timeout }), kill(), violations() and receipt(). A run ends, and every process it started is killed, on kill(), close(), disposal, an aborted signal, a timeout, garbage collection, or the exit of the Node process.

Running Node inside the cage

The presets let the child run the system's programs (/usr, /bin, Homebrew). A Node installed elsewhere (nvm, Volta, a CI tool cache) needs an exec rule for its directory:

const doc = Policy.preset("agent_workspace", 3, { workspace }).toJSON();
doc.fs.push({ access: "exec", target: { subpath: path.dirname(fs.realpathSync(process.execPath)) } });
const policy = Policy.fromJSON(doc);

Errors

All extend ProcageError: PolicyError, CapabilityGapError, UnsupportedError, AlreadySandboxedError (the caller is itself sandboxed, macOS), GrantError, SpawnError, TimeoutError, ExitError. When the host cannot enforce part of a policy, CapabilityGapError names the option that would accept each gap, for example on Linux:

hd-secrets: new Cage(policy, { acceptSpawnSnapshot: true }) accepts it
hd-trust-handoff: new Cage(policy, { relax: ["waive:trust-handoff"] }) accepts it
exec-program: new Cage(policy, { allow: ["exec-program"] }) accepts it

Nothing is accepted unless you pass it.

An agent's shell tool

examples/shell-tool.js is one function, shell(command, workspace), for an agent or an MCP server: it runs the command caged and returns the exit code, the output and what the sandbox refused.

Documentation: https://hupe1980.github.io/procage/docs/nodejs/. Read the threat model for what an OS sandbox does and does not stop.

Licensed under either of Apache License, Version 2.0 or MIT license at your option.