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

agent-budget-sdk

v0.1.0

Published

On-chain spending policy SDK for AI agents on Algorand x402

Readme

@agent-budget/sdk

On-chain spending policy SDK for AI agents on Algorand x402.

Install

npm install @agent-budget/sdk algosdk

Quick Start

import { AgentBudgetClient, makeBudgetWrappedFetch } from "@agent-budget/sdk";
import { x402Client } from "@x402-avm/core/client";
import { ExactAvmScheme } from "@x402-avm/avm/exact/client";
import { toClientAvmSigner } from "@x402-avm/avm";

// 1. Create the budget client
const budget = await AgentBudgetClient.create({
  appId: 758859031n,           // your deployed AgentBudget app ID
  mnemonic: "your 25-word ...", // agent's mnemonic
});

// 2. Check status
const status = await budget.getBudgetStatus();
console.log(`Remaining: ${status.remaining} µALGO`);

// 3. Wrap x402 fetch with budget enforcement
const avmSigner = toClientAvmSigner(secretKey);
const client = new x402Client().register("algorand:*", new ExactAvmScheme(avmSigner));
const budgetFetch = makeBudgetWrappedFetch({ budget, client });

// 4. Use like normal fetch — budget checks happen automatically
const res = await budgetFetch("https://x402.goplausible.xyz/examples/weather");

API

AgentBudgetClient.create(opts)

| Option | Type | Description | |--------|------|-------------| | appId | bigint | Deployed AgentBudget application ID | | mnemonic | string | 25-word Algorand mnemonic | | algorand? | AlgorandClient | Optional custom AlgorandClient |

Client Methods

| Method | Description | |--------|-------------| | checkAndRecordSpend(amount, server) | Check policy + record spend atomically | | getBudgetStatus() | Get daily limit, spent, remaining, per-tx limit, paused | | getLifetimeStats() | Get total spent, approved count, rejected count | | isWhitelisted(server) | Check if a server is whitelisted | | addWhitelist(server) | Add server to whitelist (owner-only) | | removeWhitelist(server) | Remove server from whitelist (owner-only) | | updateDailyLimit(limit) | Update daily cap (owner-only) | | updatePerTxLimit(limit) | Update per-tx cap (owner-only) | | pause() / unpause() | Emergency pause/unpause (owner-only) |

makeBudgetWrappedFetch(opts)

Returns a fetch-compatible function that automatically:

  1. Preflights the URL for x402 pricing
  2. Calls checkAndRecordSpend on the contract
  3. Signs payment only if approved
  4. Throws BudgetRejectedError if rejected

BudgetRejectedError

Thrown when the contract rejects a spend. Properties:

  • reasonREJECTED:PAUSED, REJECTED:NOT_WHITELISTED, REJECTED:EXCEEDS_TX_LIMIT, REJECTED:EXCEEDS_DAILY_LIMIT
  • url, amount, server

Deploy Your Own Contract

cd agent-sdk
cp .env.example .env
# Set AVM_MNEMONIC to your 25-word testnet mnemonic

pnpm install
pnpm run deploy    # deploys contract + sets limits + whitelists host
pnpm run demo      # runs 3-scenario e2e test

License

MIT