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

@kehto/rate-limit

v0.2.0

Published

Optional host-installed temporal budgets and burst controls

Readme

@kehto/rate-limit

Optional host-installed temporal protection. The package has no runtime dependencies. Neither runtime nor Firewall constructs a limiter implicitly.

Install

pnpm add @kehto/rate-limit

Opt in

import { createRateLimiter, defaultRateLimitConfig, defaultPromptRateLimitConfig } from '@kehto/rate-limit';

const operations = createRateLimiter(defaultRateLimitConfig());
const prompts = createRateLimiter(defaultPromptRateLimitConfig());
const permissions = {
  ...approvalAdapter,
  rateLimiter: operations,
  promptRateLimiter: prompts,
};
// Pass permissions to createRuntime({ ...hostAdapter, permissions }) or ShellAdapter.
operations.setConfig({ ...operations.config, unfocusedMultiplier: 0.5 });

Operation and prompt limiters are independent opt-ins. Omit either field to leave that traffic unthrottled. Approval, ACL, identity, source lifetime, cancellation, and domain-specific safety bounds still apply. Paja explicitly installs both. permissions.onRateLimit receives payload-free excess diagnostics.

createRateLimiter(config) validates and snapshots the configuration; setConfig keeps existing counters. The suggested operation configuration allows 60/minute, flags sustained excess, and blocks beyond 20 startup operations in three seconds. The suggested prompt configuration blocks beyond 12/minute or eight startup prompts. These suggestions apply only when the host passes them to a constructed limiter. A zero capacity always exceeds the budget and applies its configured action.

Pure evaluator

evaluateRateLimit(config, state, observation) returns a decision and next state. createRateLimitState creates empty counters. Observations carry a trusted subject, operation, lifecycle, focus and injected clock. retireRateLimitLifecycle clears only that lifecycle's startup counters; per-subject operation tokens survive frame replacement. Runtime invokes retire on supplied limiters when retiring a source. Standalone users own retirement. Clock rollback cannot mint refills.

Legacy migration

The previous behavioral Firewall exports moved to @kehto/rate-limit/legacy: evaluate, defaultConfig, createState, the config setters and their types. createFirewallState(persistence?) also moved here from runtime. Its name is retained only on this explicit compatibility subpath. It delegates temporal math to the same evaluator as the main entry point; it is not a scoped approval engine.

import { createFirewallState } from '@kehto/rate-limit/legacy';
const legacyFirewall = createFirewallState(optionalConfigStorage);
const runtime = createRuntime({ ...hostAdapter, legacyFirewall });
legacyFirewall.setRateLimit('chat', 'relay:write', { capacity: 10, windowMs: 1000, action: 'block' });
legacyFirewall.persist();

Legacy hosts without permissions can explicitly supply this adapter. Its policy and content matchers remain available, but allow no longer bypasses the installed rate/burst budgets. Using it emits FW-RUNTIME-LEGACY-GATE-001 once per runtime. With scoped permissions, the legacy adapter is ignored and warns once; install permissions.rateLimiter instead. See the central compatibility register.

Scope Boundaries

Counters and configuration belong to the installed instance. This package cannot grant NAP access or infer identity. It does not own pending-request bounds, resource quotas, network authorization or concurrency controls.

API Reference

See the generated package API documentation.