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

trystub

v1.0.2

Published

Drop-in budget gate for autonomous AI agents: reserve, pay once, settle. Exactly-once spend control over a strongly-consistent double-entry ledger.

Readme

trystub

One budget your agents can't break.

npm version npm downloads install size types license

A drop-in budget gate for AI agents that spend real money: paid APIs, x402 micropayments, and LLM tokens. Put one enforceable budget in front of your whole fleet and keep an exact, double-entry record of what every agent spent. Zero dependencies, TypeScript-first, works with any runtime that has fetch.

The hard part it solves: a naive retry around an irreversible payment double-charges. trystub uses a reserve → pay → settle flow, so the payment fires exactly once, even under concurrent writers, conflict retries, or a crash mid-flight.

npm install trystub

Three lines in front of a paid call

import { StubClient } from "trystub";

const stub = new StubClient({ apiKey: process.env.STUB_API_KEY, baseUrl: process.env.STUB_URL });

if (await stub.guard({ vendorAccountId, amountUsd: 0.02, intent: "fetch market data" })) {
  await doThePaidThing();
}

Exactly-once around an irreversible payment

When the payment itself can't be taken back, reserve first, pay once, then settle the real cost:

import { StubClient } from "trystub";
import { payThroughStub } from "trystub/x402";

const stub = new StubClient({ apiKey: process.env.STUB_API_KEY, baseUrl: process.env.STUB_URL });

const data = await payThroughStub(stub, vendorAccountId, {
  status: 402,
  priceUsd: 0.04,
  intent: "fetch market data",
  costCenter: "Marketing",
  pay: async () => {
    const res = await fetchPaidResource();
    return { result: res.body, actualUsd: res.chargedUsd };
  },
});

payThroughStub reserves the estimate against the budget, runs pay() exactly once, then settles for the actual amount and refunds the difference. If the reservation is denied it throws BudgetDeniedError and never pays; if pay() throws, the hold is released.

API

  • new StubClient({ apiKey?, baseUrl?, fetch? })
  • stub.guard(input): Promise<boolean>: true only if the spend committed
  • stub.spend(input): Promise<SpendResult>: single-shot debit
  • stub.reserve(input): Promise<ReserveResult>: hold funds against the cap
  • stub.settle(reservationId, actualUsd?): Promise<SettleResult>: book the real cost
  • stub.release(reservationId): Promise<ReleaseResult>: return a hold

input accepts { vendorAccountId, amountUsd, intent?, costCenter?, idempotencyKey?, budgetAccountId?, receipt? }. A scoped API key pins spends to one budget account; without one, pass budgetAccountId and authenticate as an admin.

Links

License

MIT