Documentation Index
Fetch the complete documentation index at: https://docs.agentscore.sh/llms.txt
Use this file to discover all available pages before exploring further.
@agent-score/commerce is the full merchant-side SDK for agent commerce. One install bundles identity gating, payment-protocol helpers, 402 challenge builders, discovery doc generators, and Stripe multichain support. Subpath imports keep bundle size focused: identity-only consumers pay no cost for payment helpers, and vice versa.
Installation
Subpaths
| Import | What it gives you |
|---|---|
@agent-score/commerce/identity/{hono,express,fastify,nextjs,web} | Trust gate middleware: KYC, age, sanctions, jurisdiction. agentscoreGate(...), captureWallet(...), verifyWalletSignerMatch(...), getAgentScoreData(c). |
@agent-score/commerce/payment | networks, USDC, rails registries; paymentDirective, buildPaymentHeaders (one-call WWW-Authenticate + PAYMENT-REQUIRED bundle), wwwAuthenticateHeader, paymentRequiredHeader, aliasAmountFields (v1↔v2 amount field shim for v1-only x402 parser compat), settlementOverrideHeader, dispatchSettlementByNetwork, extractPaymentSigner, buildIdempotencyKey; createX402Server, buildX402AcceptsFor402 (one-call helper for the 402-emit path; derives extra.name from the registered scheme so EIP-712 domain matches the on-chain USDC contract), createMppxServer; drop-in x402 helpers: validateX402NetworkConfig (boot-time guard), verifyX402Request (parse + validate inbound X-Payment), processX402Settle (verify-then-settle in one call), classifyX402SettleResult (maps the tagged settle result to a recommended HTTP status / code / next_steps so merchants get a controlled envelope without coupling to facilitator-specific error text). |
@agent-score/commerce/discovery | isDiscoveryProbeRequest, buildDiscoveryProbeResponse (with optional x402Sample for x402-aware crawlers), sampleX402AcceptForNetwork, buildWellKnownMpp, buildWellKnownX402 (x402scan v1 /.well-known/x402 shape: {version: 1, resources: ["METHOD /path"]}), buildLlmsTxt, buildSkillMd (Claude-Skill-compatible /skill.md agent-discovery manifest — strictly agent-facing data only, no internal posture), agentscoreOpenApiSnippets, siwxSecurityScheme + xPaymentInfoExtension (fixed/dynamic price + multi-protocol) + xGuidanceExtension per the x402scan OpenAPI spec, createBazaarDiscovery; noindexNonDiscoveryPaths (Hono middleware) + noindexNonDiscoveryPathsExpress + noindexNonDiscoveryPathsFastify + wrapNoindexResponse / applyNoindexHeader (Web Fetch + Next.js) — emits X-Robots-Tag: noindex on every path except the agent-discovery surfaces (/openapi.json, /llms.txt, /skill.md, /.well-known/{mpp.json,x402,agent-card.json,ucp}, /favicon.{png,ico}); pure helpers isDiscoveryPath + defaultDiscoveryPaths for any framework not listed. |
@agent-score/commerce/challenge | buildAcceptedMethods, buildIdentityMetadata, buildHowToPay, buildAgentInstructions, build402Body, buildPricingBlock (cents → dollar-string with shipping support), firstEncounterAgentMemory, OrderReceipt type; respond402 — drop-in 402 emit that preserves mppx’s WWW-Authenticate and layers x402’s PAYMENT-REQUIRED. buildValidationError — structured 4xx body builder ({error: {code, message}, required_fields?, example_body?, next_steps?, ...extra}) so vendors compose body shapes by name instead of inlining at every validation site. |
@agent-score/commerce/stripe-multichain | createMultichainPaymentIntent, getDepositAddress, simulateCryptoDeposit, createMppxStripe; createPiCache (TTL’d PI / deposit-address cache, Redis-backed when redisUrl set), simulateDepositIfTestMode (gates on sk_test_ and looks up the PI for you), STRIPE_TEST_TX_HASH_SUCCESS / STRIPE_TEST_TX_HASH_FAILED constants. |
@agent-score/commerce/api | Everything from @agent-score/sdk re-exported in one place: AgentScore + AgentScoreError, AGENTSCORE_TEST_ADDRESSES + isAgentScoreTestAddress. Don’t add @agent-score/sdk as a separate dep — the two can drift versions. |
@agent-score/commerce (top-level) | Identity-publishing helpers for cross-vendor standards: buildA2AAgentCard (Google A2A v1.0 Signed Agent Card, served at /.well-known/agent-card.json), buildUCPProfile (Google Universal Commerce Protocol, served at /.well-known/ucp). Both return unsigned payloads — vendor signs + publishes. |
Identity model
Two identity types: wallet (X-Wallet-Address) and operator-token (X-Operator-Token). Default checks operator-token first, then wallet. Address normalization is network-aware: EVM lowercased, Solana base58 preserved verbatim.
DenialReason codes (missing_identity, identity_verification_required, token_expired, invalid_credential, wallet_signer_mismatch, wallet_auth_requires_wallet_signing, wallet_not_trusted, api_error, payment_required) each carry a structured agent_instructions JSON block describing concrete recovery actions.
createSessionOnMissing auto-mints a verification session when no identity is present. verifyWalletSignerMatch (per-adapter) recovers the signer from MPP/x402 credentials and routes the verdict through the API’s server-side resolve_signer mode — one /v1/assess round trip carries both the gate verdict and the wallet-signer-match outcome. Repeat lookups for the same (claimed, signer) pair hit a per-entry cache so repeat payments under the same operator cost zero extra API calls. captureWallet is fire-and-forget — POSTs the signer to /v1/credentials/wallets so the operator’s cross-merchant credential↔wallet profile builds up over time.
Identity publishing (cross-vendor standards)
Two helpers compose AgentScore identity into the payload formats published to other agent-commerce ecosystems. Each returns an unsigned object — your service signs + serves it however its key infrastructure works.build402Body + buildPaymentHeaders + Stripe SPT rail.
Quick start: full merchant in 30 lines
Fail-open (opt-in)
By default AgentScore Gate fails closed on AgentScore-side infra failure (429 / 5xx / network timeout) — buyer gets 503. PassfailOpen: true to opt in to graceful degradation, then read the per-request degraded state via getGateDegradedState(c):
getGateDegradedState is exported by every Node adapter (Hono, Express, Fastify). For withAgentScoreGate (Next.js / Web Fetch), the degraded + infraReason fields land on the gate object passed to your handler. Compliance denials (sanctions, age, jurisdiction, signer-mismatch) still deny regardless of failOpen — see compliance-gating › Fail-open behavior.
Examples
The examples/ directory has runnable single-file Hono apps for each common merchant scenario:| Example | Scenario |
|---|---|
api-provider.ts | Per-call API billing on multiple rails: Tempo MPP + x402 (Base + Solana); no compliance gate |
identity-only.ts | Compliance gate without payment (vendor handles their own) |
multi-rail-merchant.ts | Full agent-commerce: identity + Tempo MPP + x402 + Stripe SPT |
stripe-multichain-merchant.ts | Stripe-anchored multichain (PaymentIntent → tempo/base/solana deposit addresses) |
variable-cost-merchant.ts | Pay-per-actual-usage on two protocols: x402 upto + MPP tempo session |
compliance-merchant.ts | Regulated-goods merchant — full compliance gate + custom onDenied composing the denial helpers (verificationAgentInstructions, isFixableDenial, buildSignerMismatchBody, buildContactSupportNextSteps) |
per-product-policy-merchant.ts | Multi-product merchant where each row carries its own compliance policy (hard gate, soft, or none). Uses PolicyBlock, policyToGateOptions, runGateWithEnforcement, shippingCountryAllowed, shippingStateAllowed. |