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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@aweto-agent/ap2

v0.2.1

Published

AP2 (Agent Payments Protocol) extension for Lucid agents

Readme

@aweto-agent/ap2

AP2 (Agent Payments Protocol) extension for Lucid agents. Adds AP2 extension metadata to Agent Cards, enabling agents to declare payment-related capabilities and roles.

What is AP2?

AP2 (Agent Payments Protocol) is an extension to the A2A Protocol that enables agents to declare payment-related capabilities. Agents can declare roles such as merchant (accepts payments) or shopper (makes payments), allowing other agents to discover payment-enabled capabilities.

Installation

bun add @aweto-agent/ap2

Quick Start

Basic Usage

import { createAgentCardWithAP2, createAP2Runtime } from '@aweto-agent/ap2';
import { buildAgentCard } from '@aweto-agent/a2a';

// Build base Agent Card
let card = buildAgentCard({
  meta: { name: 'my-agent', version: '1.0.0' },
  registry: entrypoints,
  origin: 'https://my-agent.example.com',
});

// Add AP2 extension
card = createAgentCardWithAP2(card, {
  roles: ['merchant'],
  description: 'Accepts payments for services',
});

// Create AP2 runtime
const ap2Runtime = createAP2Runtime({
  roles: ['merchant'],
});

Integration with Agent Runtime

import { createAgentApp } from '@aweto-agent/hono';
import { createAP2Runtime } from '@aweto-agent/ap2';

const { app, runtime } = createAgentApp(
  {
    name: 'my-agent',
    version: '1.0.0',
  },
  {
    // AP2 is automatically enabled when payments are configured
    payments: {
      payTo: process.env.PAYMENTS_RECEIVABLE_ADDRESS!,
      network: 'base-sepolia',
      facilitatorUrl: 'https://facilitator.example.com',
    },
  }
);

// AP2 runtime is available via runtime.ap2
if (runtime.ap2) {
  console.log('AP2 roles:', runtime.ap2.config.roles);
}

API Reference

createAP2Runtime(config?)

Creates an AP2 runtime from configuration. Returns undefined if no config provided.

import { createAP2Runtime } from '@aweto-agent/ap2';

const ap2Runtime = createAP2Runtime({
  roles: ['merchant', 'shopper'],
  description: 'Payment-enabled agent',
  required: true,
});

createAgentCardWithAP2(card, ap2Config)

Adds AP2 extension metadata to an Agent Card. Returns a new card (immutable).

import { createAgentCardWithAP2 } from '@aweto-agent/ap2';

const enhancedCard = createAgentCardWithAP2(card, {
  roles: ['merchant'],
  description: 'Accepts payments',
});

AP2_EXTENSION_URI

The canonical URI for the AP2 extension.

import { AP2_EXTENSION_URI } from '@aweto-agent/ap2';

console.log(AP2_EXTENSION_URI);

AP2 Roles

  • merchant: Agent accepts payments for its services
  • shopper: Agent makes payments to other agents

An agent can have multiple roles (e.g., both merchant and shopper).

Auto-Enablement

When payments are configured in the agent runtime, the merchant role is automatically added to the AP2 extension. This ensures that payment-enabled agents are discoverable by other agents.

Related Packages

  • @aweto-agent/a2a - A2A Protocol implementation (Agent Cards)
  • @aweto-agent/payments - x402 payment protocol utilities
  • @aweto-agent/core - Core agent runtime

Resources