Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions agentscore_commerce/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,77 @@
from agentscore_commerce.checkout import (
Checkout,
CheckoutContext,
CheckoutGateConfig,
CheckoutRailSpec,
CheckoutRequest,
CheckoutResult,
CheckoutValidationError,
MppxComposeOutcome,
PricingResult,
SettleOutcome,
format_pydantic_errors,
validation_envelope,
validation_response_aiohttp,
validation_response_django,
validation_response_fastapi,
validation_response_flask,
validation_response_sanic,
)
from agentscore_commerce.checkout_hooks import make_mppx_compose_hook

# Re-export the most commonly used helpers at the package root so consumers
# don't have to remember which submodule each one lives in. Mirrors node's
# top-level `index.ts` surface; submodule imports still work for power users.
from agentscore_commerce.identity import (
AGENTSCORE_UCP_CAPABILITY,
FIXABLE_DENIAL_REASONS,
UCP_A2A_EXTENSION_URI,
AgentIdentity,
AgentMemoryHint,
AgentScoreCore,
AgentScoreGatePolicy,
AssessResult,
CreateSessionOnMissing,
DenialCode,
DenialReason,
PolicyBlock,
SignerVerdict,
UCPSigningKey,
UCPVerificationError,
VerifyWalletSignerResult,
build_a2a_agent_card,
build_agent_memory_hint,
build_contact_support_next_steps,
build_jwks_response,
build_signer_mismatch_body,
build_ucp_profile,
denial_reason_status,
denial_reason_to_body,
generate_ucp_signing_key,
hash_operator_token,
is_fixable_denial,
load_ucp_signing_key_from_env,
mpp_payment_handler,
sign_ucp_profile,
stripe_spt_payment_handler,
ucp_a2a_extension,
verification_agent_instructions,
verify_ucp_profile,
x402_payment_handler,
)
from agentscore_commerce.payment import (
PaymentSigner,
SignerNetwork,
SolanaMppRailSpec,
StripeRailSpec,
TempoRailSpec,
TempoSessionRailSpec,
X402BaseRailSpec,
extract_payment_signer,
extract_signer_for_precheck,
format_usd_cents,
load_solana_fee_payer,
read_x402_payment_header,
)

try:
Expand All @@ -33,13 +98,70 @@
__version__ = "0.0.0+local"

__all__ = [
"AGENTSCORE_UCP_CAPABILITY",
"FIXABLE_DENIAL_REASONS",
"UCP_A2A_EXTENSION_URI",
"AgentIdentity",
"AgentMemoryHint",
"AgentScoreCore",
"AgentScoreGatePolicy",
"AssessResult",
"Checkout",
"CheckoutContext",
"CheckoutGateConfig",
"CheckoutRailSpec",
"CheckoutRequest",
"CheckoutResult",
"CheckoutValidationError",
"CreateSessionOnMissing",
"DenialCode",
"DenialReason",
"MppxComposeOutcome",
"PaymentSigner",
"PolicyBlock",
"PricingResult",
"SettleOutcome",
"SignerNetwork",
"SignerVerdict",
"SolanaMppRailSpec",
"StripeRailSpec",
"TempoRailSpec",
"TempoSessionRailSpec",
"UCPSigningKey",
"UCPVerificationError",
"VerifyWalletSignerResult",
"X402BaseRailSpec",
"__version__",
"build_a2a_agent_card",
"build_agent_memory_hint",
"build_contact_support_next_steps",
"build_jwks_response",
"build_signer_mismatch_body",
"build_ucp_profile",
"denial_reason_status",
"denial_reason_to_body",
"extract_payment_signer",
"extract_signer_for_precheck",
"format_pydantic_errors",
"format_usd_cents",
"generate_ucp_signing_key",
"hash_operator_token",
"is_fixable_denial",
"load_solana_fee_payer",
"load_ucp_signing_key_from_env",
"make_mppx_compose_hook",
"mpp_payment_handler",
"read_x402_payment_header",
"sign_ucp_profile",
"stripe_spt_payment_handler",
"ucp_a2a_extension",
"validation_envelope",
"validation_response_aiohttp",
"validation_response_django",
"validation_response_fastapi",
"validation_response_flask",
"validation_response_sanic",
"verification_agent_instructions",
"verify_ucp_profile",
"x402_payment_handler",
]
6 changes: 6 additions & 0 deletions agentscore_commerce/challenge/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
class X402PaymentRequired:
accepts: list[Any]
version: Literal[1, 2] = 2
extensions: dict[str, Any] | None = None
"""Per-endpoint x402 ``extensions`` block (e.g. Bazaar discovery declared
via ``build_bazaar_discovery_payload``). Emitted on the 402 body as
``body.extensions`` per x402 spec when non-empty."""


def build_402_body(
Expand All @@ -34,6 +38,8 @@ def build_402_body(
if x402:
body["x402Version"] = x402.version
body["accepts"] = alias_amount_fields(x402.accepts)
if x402.extensions:
body["extensions"] = x402.extensions
if amount_usd is not None:
body["amount_usd"] = amount_usd
if currency:
Expand Down
Loading