这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
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
3 changes: 3 additions & 0 deletions .github/workflows/python-x402-a2a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ jobs:

- name: Format
run: uvx ruff format --check .

- name: Typecheck
run: uv run typecheck
2 changes: 1 addition & 1 deletion python/examples/adk-demo/client_agent/client_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from ._remote_agent_connection import RemoteAgentConnections, TaskUpdateCallback
from .wallet import Wallet
from x402_a2a.core.utils import x402Utils
from x402_a2a.types import PaymentStatus
from x402_a2a.type_defs import PaymentStatus

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion python/examples/adk-demo/client_agent/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from abc import ABC, abstractmethod
import eth_account

from x402_a2a.types import PaymentPayload, x402PaymentRequiredResponse
from x402_a2a.type_defs import PaymentPayload, x402PaymentRequiredResponse
from x402_a2a.core.wallet import process_payment_required


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from google.genai import types

from x402_a2a.core.utils import x402Utils
from x402_a2a.types import x402PaymentRequiredException
from x402_a2a.type_defs import x402PaymentRequiredException

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
from google.adk.agents import LlmAgent
from google.adk.agents.callback_context import CallbackContext
from google.genai import types
from x402_a2a.types import PaymentRequirements
from x402_a2a.type_defs import PaymentRequirements

# Import the custom exception and the base agent interface
from .base_agent import BaseAgent
from x402_a2a.types import x402PaymentRequiredException
from x402_a2a.type_defs import x402PaymentRequiredException
from x402_a2a import x402Utils, get_extension_declaration

# This is the new, clean ADK Merchant Agent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import logging
from typing import override

from x402_a2a.types import (
from x402_a2a.type_defs import (
ExactPaymentPayload,
PaymentPayload,
PaymentRequirements,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from x402_a2a.executors import x402ServerExecutor
from .mock_facilitator import MockFacilitator
from x402_a2a.types import (
from x402_a2a.type_defs import (
PaymentPayload,
PaymentRequirements,
SettleResponse,
Expand Down
9 changes: 6 additions & 3 deletions python/examples/adk-demo/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion python/x402_a2a/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from x402.facilitator import FacilitatorConfig, FacilitatorClient

# A2A Extension Types & Functions
from .types import (
from .type_defs import (
# Extension Constants
X402_EXTENSION_URI,
# A2A-Specific Types
Expand Down
2 changes: 1 addition & 1 deletion python/x402_a2a/core/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from typing import List, Optional
from a2a.types import AgentCard, AgentCapabilities

from ..types import x402ExtensionConfig, get_extension_declaration
from ..type_defs import x402ExtensionConfig, get_extension_declaration


def create_x402_agent_card(
Expand Down
2 changes: 1 addition & 1 deletion python/x402_a2a/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from typing import Union, Optional, List, Callable, Any
from functools import wraps

from ..types import x402PaymentRequiredException, PaymentRequirements, TokenAmount
from ..type_defs import x402PaymentRequiredException, PaymentRequirements, TokenAmount
from .merchant import create_payment_requirements


Expand Down
2 changes: 1 addition & 1 deletion python/x402_a2a/core/merchant.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from typing import Optional, Any, cast
from x402.common import process_price_to_atomic_amount
from x402.types import Price
from ..types import PaymentRequirements, SupportedNetworks
from ..type_defs import PaymentRequirements, SupportedNetworks


def create_payment_requirements(
Expand Down
2 changes: 1 addition & 1 deletion python/x402_a2a/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from typing import Optional

from ..types import (
from ..type_defs import (
PaymentPayload,
PaymentRequirements,
SettleResponse,
Expand Down
10 changes: 5 additions & 5 deletions python/x402_a2a/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import logging
import uuid
from typing import Optional
from ..types import (
from ..type_defs import (
Task,
Message,
PaymentStatus,
Expand Down Expand Up @@ -181,7 +181,7 @@ def create_payment_required_task(

# Ensure task has a status message for metadata
if not hasattr(task.status, "message") or not task.status.message:
from ..types import Message
from ..type_defs import Message
from a2a.types import TextPart

task.status.message = Message(
Expand Down Expand Up @@ -215,7 +215,7 @@ def record_payment_verified(
"""Record payment verification in task metadata."""
# Ensure task has a status message for metadata
if not hasattr(task.status, "message") or not task.status.message:
from ..types import Message
from ..type_defs import Message
from a2a.types import TextPart

task.status.message = Message(
Expand Down Expand Up @@ -243,7 +243,7 @@ def record_payment_success(
"""Record successful payment with settlement response."""
# Ensure task has a status message for metadata
if not hasattr(task.status, "message") or not task.status.message:
from ..types import Message
from ..type_defs import Message
from a2a.types import TextPart

task.status.message = Message(
Expand Down Expand Up @@ -280,7 +280,7 @@ def record_payment_failure(
"""Record payment failure with error details."""
# Ensure task has a status message for metadata
if not hasattr(task.status, "message") or not task.status.message:
from ..types import Message
from ..type_defs import Message
from a2a.types import TextPart

task.status.message = Message(
Expand Down
2 changes: 1 addition & 1 deletion python/x402_a2a/core/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from x402.common import x402_VERSION
from x402.exact import prepare_payment_header, sign_payment_header, decode_payment

from ..types import (
from ..type_defs import (
PaymentRequirements,
x402PaymentRequiredResponse,
PaymentPayload,
Expand Down
2 changes: 1 addition & 1 deletion python/x402_a2a/executors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from abc import ABC, abstractmethod

from ..types import (
from ..type_defs import (
AgentExecutor,
RequestContext,
EventQueue,
Expand Down
4 changes: 2 additions & 2 deletions python/x402_a2a/executors/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from eth_account import Account

from .base import x402BaseExecutor
from ..types import (
from ..type_defs import (
AgentExecutor,
RequestContext,
EventQueue,
Expand Down Expand Up @@ -99,7 +99,7 @@ async def _auto_pay(self, task, event_queue: EventQueue):

except Exception as e:
# Payment processing failed
from ..types import SettleResponse, x402ErrorCode
from ..type_defs import SettleResponse, x402ErrorCode

failure_response = SettleResponse(
success=False, network="base", error_reason=f"Payment failed: {e}"
Expand Down
2 changes: 1 addition & 1 deletion python/x402_a2a/executors/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from a2a.server.tasks import TaskUpdater

from .base import x402BaseExecutor
from ..types import (
from ..type_defs import (
AgentExecutor,
RequestContext,
EventQueue,
Expand Down
2 changes: 1 addition & 1 deletion python/x402_a2a/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Extension declaration and constants for A2A x402 protocol."""

from .types.config import X402_EXTENSION_URI
from .type_defs.config import X402_EXTENSION_URI


def get_extension_declaration(
Expand Down
7 changes: 6 additions & 1 deletion python/x402_a2a/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ dev = [
]
lint = [
"ruff>=0.13.1",
"mypy>=1.8.0",
]

[project.scripts]
test = "pytest:main"
typecheck = "mypy.main:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
force-include = { "__init__.py" = "x402_a2a/__init__.py", "core" = "x402_a2a/core", "executors" = "x402_a2a/executors", "types" = "x402_a2a/types", "extension.py" = "x402_a2a/extension.py" }
force-include = { "__init__.py" = "x402_a2a/__init__.py", "core" = "x402_a2a/core", "executors" = "x402_a2a/executors", "type_defs" = "x402_a2a/type_defs", "extension.py" = "x402_a2a/extension.py" }

[tool.hatch.metadata]
allow-direct-references = true
Expand All @@ -56,3 +58,6 @@ markers = [

[tool.ruff]
target-version = "py311"

[tool.mypy]
files = ["core", "executors", "*.py"]
2 changes: 1 addition & 1 deletion python/x402_a2a/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from a2a.types import Task, Message, TaskState, TaskStatus, TextPart
from x402_a2a.executors.server import x402ServerExecutor
from x402_a2a.types import (
from x402_a2a.type_defs import (
PaymentStatus,
x402Metadata,
x402PaymentRequiredResponse,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class x402PaymentRequiredException(x402Error):
requirements instead of relying on static server configuration.

Example:
from x402_a2a.types.errors import x402PaymentRequiredException
from x402_a2a.type_defs.errors import x402PaymentRequiredException
from x402_a2a.core.merchant import create_payment_requirements

# Single payment option
Expand Down
File renamed without changes.
62 changes: 61 additions & 1 deletion python/x402_a2a/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading