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

@agenttab/fetch

v0.1.2

Published

Drop-in fetch wrapper for AgentTab policy, funding, x402 pay, and audit

Readme

@agenttab/fetch

Drop-in fetch wrapper for agents that need AgentTab policy + exact-deficit funding in front of standard x402 payments.

your agent
  -> createAgentTabFetch / createAgentTabClient
       -> 402 challenge
       -> AgentTab gateway (policy / DFlow deficit funding)
       -> official @x402/fetch payment + retry
       -> optional audit (pay + fulfill) on the gateway

Install

pnpm add @agenttab/fetch @x402/core @x402/fetch @x402/svm

You still need a scheme client such as @x402/svm in the agent process (bring-your-own signer). For the gateway and operator CLIs, clone https://github.com/Kleangkao/agenttab (see docs/ADOPT.md).

Minimal usage (remote gateway)

This is the primary adoption path for an existing agent process. See also docs/ADOPT.md for policy files and operator CLIs.

import {
  createAgentTabClient,
  stablecoinAtomicAsUsdMicros
} from "@agenttab/fetch";
import { ExactSvmScheme } from "@x402/svm/exact/client";

const agent = createAgentTabClient({
  gatewayBaseUrl: process.env.AGENTTAB_GATEWAY_URL!, // e.g. http://127.0.0.1:8787
  schemes: [
    {
      network: "solana:mainnet",
      client: new ExactSvmScheme(svmSigner)
    }
  ],
  getUsdValueMicros: async ({ amountAtomic }) =>
    stablecoinAtomicAsUsdMicros(amountAtomic)
});

const response = await agent.fetch("https://merchant.example/v1/market-snapshot");
const meta = agent.getMeta(response);
const receipt = await agent.getExecution(meta!.operationId);

// Operator helpers on the same client:
// await agent.gateway?.getPolicy();
// await agent.gateway?.putPolicy(nextPolicy);
// await agent.gateway?.preview(intent); // never funds
// await agent.gateway?.approve(meta!.operationId);
// await agent.gateway?.deny(meta!.operationId);

See examples/remote-agent + examples/neutral-merchant for a reusable topology that does not embed the gateway in the agent process.

When policy mode is approve or observe, failed funding throws AgentTabApprovalRequiredError with operationId. The next fetch to the same method+url+body reuses that id from in-process memory, or by asking the gateway for a reusable execution with the same requestHash (so a new process after pnpm approve -- <id> still resumes). Prefer requestPaidResource(agent, url, init, { onApprovalRequired }) for the in-process approve-and-retry loop ("approve" | "deny" | "abort"). createOperationId always wins over reuse.

Options worth knowing

  • gatewayFetchImpl — HTTP client used only for gateway fund/pay/fulfill. Keep it separate from fetchImpl when you intercept merchant traffic in tests.
  • createAgentTabClient — paid fetch + getExecution / policy / preview / deny helpers. gateway.preview(intent) is read-only and never funds. gateway.deny(id) is terminal.
  • Prefer schemes over reusing a shared x402Client (x402 appends hooks).
  • createLocalSmokeScheme() is for local/CI only; production needs a real SVM signer.
  • AgentTabApprovalRequiredError / AgentTabFundingDeniedError carry operationId.

Embedded gateway (in-process coordinator)

const fetchPaid = createAgentTabFetch({
  coordinator: gateway.coordinator,
  audit: createGatewayAuditRecorder({ baseUrl: "http://127.0.0.1:8787" }),
  schemes: [{ network, client: new ExactSvmScheme(svmSigner) }]
});

Design notes

  • Merchants stay on standard x402; AgentTab is buyer-side only.
  • Signing is bring-your-own via schemes / x402Client (never pass raw keys here).
  • Request binding (operationId, requestHash, merchantId) is per-call via AsyncLocalStorage, so concurrent fetches stay isolated.
  • After a successful paid response, audit defaults on when a gateway URL or audit recorder is provided.
  • This package does not cover the local HMAC demo path.