a2a-ap2 0.2.0

AP2 (Agent Payments Protocol) extension for the A2A Protocol
Documentation

a2a-ap2 — Agent Payments Protocol extension for A2A

This crate implements the AP2 (Agent Payments Protocol) v0.1 as a companion library to [a2a-rs]. It provides:

  • Strongly-typed Rust models for all AP2 types (mandates, payment requests, receipts, roles)
  • Helpers for embedding AP2 data into A2A Message and Artifact parts
  • Helpers for extracting AP2 data from A2A parts
  • AgentExtension builders for declaring AP2 support in AgentCards
  • Validation for all AP2 types

Quick Start

use a2a_ap2::{
    IntentMandate, intent_mandate_message,
    ap2_extension, Ap2Role,
};

// Declare AP2 support in an agent card
let ext = ap2_extension(vec![Ap2Role::Shopper], false);

// Create an intent mandate and wrap it in an A2A message
let intent = IntentMandate {
    user_cart_confirmation_required: true,
    natural_language_description: "Buy red shoes under $100".into(),
    merchants: None,
    skus: None,
    requires_refundability: Some(true),
    intent_expiry: "2026-12-31T23:59:59Z".into(),
};
let message = intent_mandate_message(&intent, "msg-1".into()).unwrap();