Skip to main content

Treeship for Claude Commerce Agents

Signed, offline-verifiable receipts for every tool call in anthropics/commerce-agents, on all three of its runtimes.

The reference draws its own boundary in docs/safety.md: the approval surface, payment, and log hygiene are "what a deployment owns". This package is what a deployment adds for the record of what happened. It records; it does not gate. The reference's provenance gates, caps, and host approval still decide what runs.

What it does

commerce_common.execution.BaseToolExecutor.execute is the one method every tool call passes through on the Messages API, the Agent SDK, and Managed Agents. TreeshipExecutorMixin overrides it:

  1. a signed intent receipt before dispatch: tool, SHA-256 of the canonical arguments, session tag;
  2. the tool, exactly as the reference runs it;
  3. a signed result receipt: status (ok, blocked with the gate's name, error), SHA-256 of the result text, event types, timing.

Each receipt names its parent, so a session reads intent → result → intent → result … from the Treeship session's root, and treeship verify walks it as one chain. A held call is a signed refusal, not a missing receipt.

Never written: the arguments, the result text (fenced third-party content on the reference), or the commerce session id (the request credential). The receipt carries the same twelve-hex session tag the reference's own log lines use, so an operator holding the id can correlate and a reader cannot.

Install

git clone https://github.com/anthropics/commerce-agents && cd commerce-agents
python3.11 -m venv .venv && source .venv/bin/activate   # the reference needs Python 3.11+
pip install -r requirements.txt            # their seven packages (unregistered on PyPI)
pip install treeship-sdk treeship-commerce
curl -fsSL https://treeship.dev/install | sh   # the CLI does the signing; the demos also fetch it themselves
treeship init --config .treeship/config.json   # a workspace for this directory

Or let Claude Code wire it

claude plugin marketplace add zerkerlabs/treeship
claude plugin install treeship-commerce@treeship
/add-treeship-receipts merchant      # or shopping, or both

The plugin (plugin/) mirrors the reference's commerce-builder: one command that reads your project and wires the seams below on your runtime, and one skill on what the receipts carry.

Use

from treeship_sdk import Treeship
from treeship_commerce import TreeshipReceipts, attach, receipted
from treeship_commerce.lifecycle import close_session, start_session
from shopping_agent.executor import ShoppingToolExecutor

ts = Treeship()
root = start_session(ts, name="storefront:acme", actor="agent://shopping")

executor = receipted(ShoppingToolExecutor)(backend=..., config=..., skills=..., session=..., state=..., memory=...)
attach(executor, TreeshipReceipts(ts, actor="agent://shopping", session_id=session.session_id, parent_id=root))

# ... the runtime calls executor.execute(...) as it always did ...

close_session(ts, summary="...")          # seals a .treeship package; `treeship session report` publishes it

All three runtimes construct executors themselves through executor_class (ShoppingAgent, ShoppingToolset, the MCP server's build_server). Give receipted() a recorder factory and each executor gets its own recorder on its first tool call:

ReceiptedShopping = receipted(ShoppingToolExecutor, recorder=lambda ex: TreeshipReceipts(
    ts, actor="agent://shopping", session_id=ex._session.session_id, parent_id=root))

Same for MerchantToolExecutor.

Recording never breaks the agent path: a receipt that cannot be written warns once, is counted in TreeshipReceipts.dropped, and later results say intent_recorded: false where the intent is missing. Nothing is invented. TREESHIP_DISABLE=1 turns recording off.

Demo

TREESHIP_BIN=... python -m treeship_commerce.demo

Runs the reference's shopping executor over the retail mock with no model and no API key: a search, a product read, an add, an add the provenance gate holds, a checkout hand-off. Prints every receipt id, seals the session, and shows the treeship verify command.

TREESHIP_BIN=... python -m treeship_commerce.demo_merchant

The merchant side: a staged price change, held while unapproved, applied once under a signed single-use operator approval, then refused on replay while the reference's own in-process approval mark is still set. Prints the grant id and the journal's record of its one use.

TREESHIP_BIN=... python -m treeship_commerce.demo_vi

The retail mock again, with a local wallet in front of checkout. The wallet (treeship_commerce.wallet) issues a Verifiable Intent Layer 1 and Layer 2 with the reference SDK's published demo keys, bound to a key from treeship vi keygen, and a demo mastercard.srcDigitalCard token. The run buys the tent the catalog search returns, holds an add the provenance gate refuses, and treeship vi attest signs the Layer 3 pair: L3a for the network, L3b for the merchant. The order chains onto that attestation. treeship vi verify --local checks it. No card is charged. Needs the reference SDK (agent-intent/verifiable-intent) as well as commerce-agents.

TREESHIP_BIN=... python -m treeship_commerce.demo_402

One approved budget and a localhost seller that answers HTTP 402. Three amounts fit: the agent signs a payment.voucher.sign receipt, the seller checks it with treeship verify, and delivery is its own receipt. A fourth amount would pass the limit, so no voucher is signed. The scheme is local.402.v1. Validation, redemption, escrow, and payout are not performed. Needs the treeship CLI only.

Checkout

receipted_backend(backend) wraps a storefront backend so checkout_handoff also signs a hand-off receipt: cart digest, item count, subtotal, currency, and a digest of each hosted URL (never the URL). order_placed(receipts, order_ref=..., amount=..., currency=...) is the host's half: a signed order receipt on the chain after the hand-off, naming it, the order reference digested. A holder of the checkout card can recompute the cart digest from the card alone.

Approvals

MerchantApprovals turns the host's y/N into a signed Approval Grant scoped to one actor, one action, and one change (change://<change_id>), max_uses=1. approved(receipted( MerchantToolExecutor), approvals) signs the apply's intent receipt with the grant's nonce, so the CLI reserves a use in the Approval Use Journal before signing. A second apply finds the grant spent; a grant for another change is refused by scope. The receipt says approval: "proven" or "unproven" with the reason. Recording only, unless enforce=True. Needs treeship-sdk 0.29.0 or later (attest_action takes subject).

On the Agent SDK runtime, approving(toolset, approvals) wraps MerchantToolset.host_approve and host_clear in place, so the reference console's y/N loop mints and forgets grants with no edits. On the Messages API the host calls approvals.grant() beside its own mark. On Managed Agents the platform's prompt is the approval surface and the click is outside the process; an apply there is receipted with no approval claim, never an invented one.

Verifiable Intent at hand-off

Verifiable Intent is the open v0.1 draft at verifiableintent.dev for proving an agent was authorized to buy. The published constraints page registers eight types, and the protocol landscape maps the credential onto AP2, UCP, and ACP. treeship vi attest signs the Layer 3 pair and puts this receipt chain in the spec's agent_attestation claim. Run it at hand-off and the chain head it names is the hand-off receipt, so the credential binds the cart that went to checkout:

from treeship_commerce import attest_at_handoff, vi_verify

summary = attest_at_handoff(
    ts, receipts,
    mandate=l2_sdjwt,                 # the user's Layer 2, from their wallet
    checkout_jwt=merchant_jwt,        # the merchant's checkout token
    merchant="merchant-uuid-1", items=[("BAB86345", 1)],
    amount_minor=27999, currency="USD",
    aud_network="https://www.mastercard.com", aud_merchant="https://tennis-warehouse.com",
    out="./vi-out",
)
summary["attestation"]["chain_head"] == receipts.last_handoff   # True
vi_verify(ts, mandate=l2_sdjwt, out="./vi-out")["outcome"]      # "pass"

The purchase values you pass must describe the cart: the check against the mandate happens before anything is signed, and a purchase outside it raises with nothing written. The attestation is itself a receipt (vi.l3.attested) on the chain after the hand-off, and the host's order chains onto it. Needs treeship 0.31 or later. One mandate pair per Layer 2. Cumulative budget and occurrence counts stay with the network.

Keep the preimages

Receipts carry digests only. To settle a dispute you also need the originals: the arguments and result keyed to the receipt's artifact_id, the cart that went to checkout, the order reference. Keep them in your own store under your own retention rules; Treeship deliberately does not. args_digest, text_digest and cart_digest recompute the digests from the originals, and then a receipt proves this ran, not something with the same hash.

What this does not do (yet)

  • Prove the work is correct. A receipt is evidence of what ran and what the gates decided. It does not make a wrong answer right.

Tests

TREESHIP_BIN=/path/to/treeship python -m pytest
ANTHROPIC_API_KEY=... TREESHIP_BIN=/path/to/treeship python -m pytest tests/test_live.py   # one real turn

Thirty-seven cases on a real isolated ship over the real retail and merchant mocks: chain order and linkage, a held call signed as blocked with its gate, digests-only content, recording failure leaving the tool untouched, TREESHIP_DISABLE, attach refusing an executor that would record nothing, one per runtime, and the approval properties: a grant binds to its receipt, is spendable once, is refused for another change, enforce=True holds an unapproved apply, the receipt note is the CLI's reason rather than the SDK's wrapper, the merchant side on all three runtimes through executor_class, and arguments that arrive as parsed pydantic models (the MCP server's shape) digesting like their dicts, and the checkout hand-off: the cart digest recomputable from the card, the URL never written, the host's order chaining from the hand-off, and an unwrapped backend's order saying so. One more drives demo_vi: a wallet mandate, the provenance refusal, and a Layer 3 pair that treeship vi verify --local accepts. One more drives demo_402: three signed vouchers under one budget, and a fourth payment withheld with no voucher.

Metadata

Release files for treeship-commerce 0.32.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for treeship-commerce 0.32.0
File Size Uploaded Provenance Actions
treeship_commerce-0.32.0.tar.gz 57.9 kB With provenance Details for treeship_commerce-0.32.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for treeship-commerce 0.32.0
File Interpreter ABI Platform Actions
treeship_commerce-0.32.0-py3-none-any.whl Python 3 none any Details for treeship_commerce-0.32.0-py3-none-any.whl

Total release size: 105.2 kB

Release files / treeship_commerce-0.32.0.tar.gz

Download URL treeship_commerce-0.32.0.tar.gz
Size 57.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3372613539736aef0601d82ad18d1b3ccf98424adc625e1bb43c39ae94303f3f
BLAKE2b-256 checksum
How to use checksums
0e59a945f83b0265a789ef418780b5ae5d440accb4141d815f60522438320818
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / treeship_commerce-0.32.0-py3-none-any.whl

Download URL treeship_commerce-0.32.0-py3-none-any.whl
Size 47.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff5b1780ab7c6c6dc535c88e61a473136296aa74a9d4f7f744f79e45f5fddf10
BLAKE2b-256 checksum
How to use checksums
fbee493ff38c813686a9d0d9d2e388cd7a25a2f688d404540ce30974a8506533
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for treeship-commerce 0.32.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for treeship_commerce-0.32.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page