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

@spendcap/policy

v0.1.0

Published

Programmable spend authority: a pure, deterministic, explainable policy engine for money movement.

Readme

@spendcap/policy

Programmable spend authority.

A payment may be requested by anyone — a person, a schedule, an autonomous agent. Spend authority belongs to the policy.

npm install @spendcap/policy
import { SpendGuard, MemoryLedgerStore, singlePolicy, explain } from "@spendcap/policy";

const policy = {
  account: "acct:agent", version: 1,
  rules: [{
    id: "daily", kind: "WINDOW_BUDGET", scope: { kind: "ANY" },
    asset: "anthropic:tokens", windowMs: 86_400_000, maxTotal: 50_000n,
  }],
};

const guard = new SpendGuard({ store: new MemoryLedgerStore(), policyFor: singlePolicy(policy) });

const draft = {
  requestId: "req-1", account: "acct:agent",
  requester: { kind: "AGENT", agentId: "research" },
  asset: "anthropic:tokens", amount: 4_000n, destination: "vendor:messages-api",
};

const result = await guard.run(draft, async (grant) => {
  const response = await callTheModel();
  grant.report(BigInt(response.usage.total_tokens));   // what it actually cost
  return response;
});

if (result.outcome === "REFUSED") console.log(explain(result.decision));

Nothing the requester sends can raise a limit, skip an approval or widen a window.

Ten rule kinds: requester allowlist, destination allow/denylist, asset allowlist, per-transaction limit, window budget, window velocity, approval threshold, time window, attestation required. Every rule is evaluated and recorded, not just the first to fail, so a refusal is auditable rather than merely obstructive.

Money is bigint in base units. Never a float.

Authorised, attempted and settled are three different states. An authorisation is not a spend, and a request that returned 200 is not a spend. The reconciler settles on an independent confirmation and nothing else; an observer that answers UNKNOWN resolves nothing in either direction.

Receipts verify without trusting the issuer — seven checks, one of which re-runs the decision from the attached policy and ledger facts and compares.

Signature verification reports five dispositions, not a boolean: authentic, binding_only, signer_authority_failed, signer_resolution_failed, signature_invalid. "Could not reach the key directory" and "this key may not speak for that name" call for opposite responses.

Interop: canonical encoding conforms to RFC 8785 (JCS), x402 v2 header names, Ed25519 with speaksFor authority binding, RFC 6962 Merkle commitments.

Not a payment rail, a wallet, an identity system, or a kill switch — it decides, it does not move money, it holds no keys, and it cannot interrupt a call already in flight. Approvals are counted, not authenticated; your shell must verify them first.

Ships without a test suite. npm run check at the repository root exercises the claims above against the built output.

Apache-2.0. One dependency (@spendcap/journal), which has none of its own.