Skip to main content

XAP Protocol SDK — Settlement objects for autonomous agent commerce

Project description

XAP SDK

Settlement objects for autonomous agent commerce.

XAP is the only protocol combining schema validation, cryptographic signatures, enforced state machines, idempotency, governed receipts, and replayable reasoning into one governed object model.

CI PyPI Python License: MIT

Install

pip install xap-sdk

Quickstart: Two Agents, One Settlement, Full Provenance

import asyncio
from xap import XAPClient

# Create two agents with sandbox (fake money, no external services)
provider = XAPClient.sandbox(balance=0)
consumer = XAPClient.sandbox(balance=100_000)  # $1,000.00
consumer.adapter.fund_agent(str(provider.agent_id), 0)
provider.adapter = consumer.adapter

# Provider registers a capability
provider_identity = provider.identity(
    display_name="SummarizeBot",
    capabilities=[{
        "name": "text_summarization",
        "version": "1.0.0",
        "pricing": {"model": "fixed", "amount_minor_units": 500, "currency": "USD", "per": "request"},
        "sla": {"max_latency_ms": 2000, "availability_bps": 9950},
    }],
)
consumer.discovery.register(provider_identity)

# Consumer discovers and negotiates
results = consumer.discovery.search(capability="text_summarization")
offer = consumer.negotiation.create_offer(
    responder=provider.agent_id,
    capability="text_summarization",
    amount_minor_units=500,
)
accepted = provider.negotiation.accept(offer)

# Settle with full decision provenance
async def settle():
    settlement = consumer.settlement.create_from_contract(
        accepted_contract=accepted,
        payees=[{"agent_id": str(provider.agent_id), "share_bps": 10000}],
    )
    locked = await consumer.settlement.lock(settlement)
    result = await consumer.settlement.verify_and_settle(
        settlement=locked,
        condition_results=[{
            "condition_id": "cond_0001", "type": "deterministic",
            "check": "output_delivered", "passed": True,
        }],
    )

    # Verify the decision is deterministically replayable
    assert consumer.receipts.verify_replay(result.verity_receipt)
    print(f"Settlement: {result.receipt['outcome']}")
    print(f"Replay verified")
    return result

asyncio.run(settle())

What XAP Does

XAP is a settlement object protocol. Every agent-to-agent economic interaction produces governed objects that are:

  • Schema-validated — structured, machine-readable
  • Cryptographically signed — Ed25519, tamper-evident
  • State-transitioned — explicit state machines, no implicit jumps
  • Idempotent — safe retries, no duplicate effects
  • Receipted — every settlement emits a governed receipt
  • Replayable — every decision can be independently verified

The Stack

xap-protocol    — Open standard (MIT). The language agents speak.
verity-engine   — Open source truth engine (Rust). The Git of financial truth.
xap-sdk         — This package. Build with XAP in Python.
Agentra Rail    — Commercial infrastructure. The GitHub of agent settlement.

MCP Integration

Connect XAP to Claude, Cursor, or any MCP-compatible AI:

pip install xap-sdk[mcp]
python -m xap.mcp.setup  # Auto-configure for Claude

Or run the server directly:

xap-mcp

Examples

Example What it shows
Two-Agent Demo Full flow: discover, negotiate, settle, replay
Three-Agent Split Multi-party settlement with basis point splits
Unknown Outcome Partial settlement and refund scenarios
MCP Demo MCP server tools in action

Key Concepts

Money is always integers. 500 means $5.00 (minor units). No floating point, ever.

Shares are basis points. 4000 means 40%. Shares must sum to exactly 10000.

Every decision is replayable. The VerityReceipt captures inputs, rules, computation steps, and a replay hash. Any party can independently verify the outcome.

Sandbox mode is zero-config. XAPClient.sandbox() gives you fake money, in-memory registry, and test adapter. No external services needed.

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xap_sdk-0.4.0.tar.gz (60.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xap_sdk-0.4.0-py3-none-any.whl (62.8 kB view details)

Uploaded Python 3

File details

Details for the file xap_sdk-0.4.0.tar.gz.

File metadata

  • Download URL: xap_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 60.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for xap_sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 29160d9f2bfb33ba3c773962f9fff2741593bc3c03f9b62415e4d9ed9d857e90
MD5 c18bd36a42de9699147a45c16e8d944f
BLAKE2b-256 2aca22cc604afa653782919f3cf2da0a2d8c20105ac021a284dd43a0a173d45a

See more details on using hashes here.

File details

Details for the file xap_sdk-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: xap_sdk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 62.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for xap_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d4555636e1bbfe1f5fe8c4276ef524a49d350586b10786809fea97e1a8fc730
MD5 ace2f58615e1ffcda2ddb5691070bf8c
BLAKE2b-256 729e0f0bf8faf10e86f4d7f237fd5e2c3b403631c53416cf9cbc0f08cfee1056

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page