agentpay-gateway 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. agentpay_gateway-0.1.0/.gitignore +116 -0
  2. agentpay_gateway-0.1.0/Dockerfile +24 -0
  3. agentpay_gateway-0.1.0/PKG-INFO +81 -0
  4. agentpay_gateway-0.1.0/README.md +48 -0
  5. agentpay_gateway-0.1.0/pyproject.toml +50 -0
  6. agentpay_gateway-0.1.0/src/agentpay_gateway/__init__.py +9 -0
  7. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/__init__.py +0 -0
  8. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/__init__.py +390 -0
  9. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/composer.py +139 -0
  10. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/constructor.py +748 -0
  11. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/cyaml.py +101 -0
  12. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/dumper.py +62 -0
  13. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/emitter.py +1137 -0
  14. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/error.py +75 -0
  15. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/events.py +86 -0
  16. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/loader.py +63 -0
  17. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/nodes.py +49 -0
  18. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/parser.py +589 -0
  19. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/reader.py +185 -0
  20. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/representer.py +389 -0
  21. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/resolver.py +227 -0
  22. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/scanner.py +1435 -0
  23. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/serializer.py +111 -0
  24. agentpay_gateway-0.1.0/src/agentpay_gateway/_vendor/yaml/tokens.py +104 -0
  25. agentpay_gateway-0.1.0/src/agentpay_gateway/config/__init__.py +64 -0
  26. agentpay_gateway-0.1.0/src/agentpay_gateway/config/errors.py +47 -0
  27. agentpay_gateway-0.1.0/src/agentpay_gateway/config/loader.py +164 -0
  28. agentpay_gateway-0.1.0/src/agentpay_gateway/config/models.py +279 -0
  29. agentpay_gateway-0.1.0/src/agentpay_gateway/config/price_parser.py +101 -0
  30. agentpay_gateway-0.1.0/src/agentpay_gateway/config/router.py +151 -0
  31. agentpay_gateway-0.1.0/src/agentpay_gateway/facilitator/__init__.py +54 -0
  32. agentpay_gateway-0.1.0/src/agentpay_gateway/facilitator/client.py +305 -0
  33. agentpay_gateway-0.1.0/src/agentpay_gateway/facilitator/errors.py +58 -0
  34. agentpay_gateway-0.1.0/src/agentpay_gateway/facilitator/evm_service.py +566 -0
  35. agentpay_gateway-0.1.0/src/agentpay_gateway/facilitator/models.py +77 -0
  36. agentpay_gateway-0.1.0/src/agentpay_gateway/facilitator/server.py +44 -0
  37. agentpay_gateway-0.1.0/src/agentpay_gateway/facilitator/service.py +392 -0
  38. agentpay_gateway-0.1.0/src/agentpay_gateway/fulfillment/__init__.py +0 -0
  39. agentpay_gateway-0.1.0/src/agentpay_gateway/payment/__init__.py +54 -0
  40. agentpay_gateway-0.1.0/src/agentpay_gateway/payment/challenge.py +145 -0
  41. agentpay_gateway-0.1.0/src/agentpay_gateway/payment/errors.py +70 -0
  42. agentpay_gateway-0.1.0/src/agentpay_gateway/payment/models.py +73 -0
  43. agentpay_gateway-0.1.0/src/agentpay_gateway/payment/settlement.py +207 -0
  44. agentpay_gateway-0.1.0/src/agentpay_gateway/payment/verifier.py +438 -0
  45. agentpay_gateway-0.1.0/src/agentpay_gateway/proxy/__init__.py +49 -0
  46. agentpay_gateway-0.1.0/src/agentpay_gateway/proxy/forwarder.py +205 -0
  47. agentpay_gateway-0.1.0/src/agentpay_gateway/proxy/headers.py +140 -0
  48. agentpay_gateway-0.1.0/src/agentpay_gateway/proxy/logging.py +186 -0
  49. agentpay_gateway-0.1.0/src/agentpay_gateway/proxy/service.py +394 -0
  50. agentpay_gateway-0.1.0/src/agentpay_gateway/server.py +150 -0
  51. agentpay_gateway-0.1.0/src/agentpay_gateway/state/__init__.py +31 -0
  52. agentpay_gateway-0.1.0/src/agentpay_gateway/state/coordinator.py +603 -0
  53. agentpay_gateway-0.1.0/src/agentpay_gateway/state/db.py +144 -0
  54. agentpay_gateway-0.1.0/src/agentpay_gateway/state/reconciliation.py +293 -0
@@ -0,0 +1,116 @@
1
+ # Operating System Files
2
+ .DS_Store
3
+ .DS_Store?
4
+ ._*
5
+ .Spotlight-V100
6
+ .Trashes
7
+ ehthumbs.db
8
+ Thumbs.db
9
+
10
+ # Environment & Secrets
11
+ .env
12
+ .env.local
13
+ .env.*.local
14
+ *.pem
15
+ *.key
16
+ *.p12
17
+ *.keystore
18
+
19
+ # Node.js & pnpm
20
+ node_modules/
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
24
+ pnpm-debug.log*
25
+ lerna-debug.log*
26
+ .pnpm-store/
27
+ .pnpm-debug.log*
28
+
29
+ # Build outputs (TypeScript / JavaScript)
30
+ dist/
31
+ build/
32
+ out/
33
+ .turbo/
34
+ *.tsbuildinfo
35
+ .eslintcache
36
+
37
+ # Python
38
+ __pycache__/
39
+ *.py[cod]
40
+ *$py.class
41
+ *.so
42
+ .Python
43
+ env/
44
+ venv/
45
+ .venv/
46
+ ENV/
47
+ *.egg-info/
48
+ .eggs/
49
+ *.egg
50
+ .pytest_cache/
51
+ .mypy_cache/
52
+ .ruff_cache/
53
+
54
+ # Java & Gradle
55
+ .gradle/
56
+ build/
57
+ !src/**/build/
58
+ bin/
59
+ *.class
60
+ *.jar
61
+ *.war
62
+ *.ear
63
+ *.nar
64
+ .gradletasknamecache
65
+
66
+ # Maven
67
+ target/
68
+ pom.xml.tag
69
+ pom.xml.releaseBackup
70
+ pom.xml.versionsBackup
71
+ pom.xml.next
72
+ release.properties
73
+
74
+ # IDE & Editors
75
+ # IntelliJ IDEA
76
+ .idea/
77
+ *.iml
78
+ *.ipr
79
+ *.iws
80
+ out/
81
+
82
+ # Visual Studio Code
83
+ .vscode/*
84
+ !.vscode/settings.json
85
+ !.vscode/tasks.json
86
+ !.vscode/launch.json
87
+ !.vscode/extensions.json
88
+ *.code-workspace
89
+
90
+ # Eclipse
91
+ .apt_generated
92
+ .classpath
93
+ .factorypath
94
+ .project
95
+ .settings/
96
+ .springBeans
97
+
98
+ # Testing & Coverage
99
+ coverage/
100
+ .nyc_output/
101
+ *.lcov
102
+ test-results/
103
+ reports/
104
+
105
+ # Database & Local Infrastructure
106
+ postgres-data/
107
+ *.db
108
+ *.sqlite
109
+ *.sqlite3
110
+
111
+ # Logs
112
+ logs/
113
+ *.log
114
+
115
+ # Internal docs, design, and roadmap (local only)
116
+ docs/
@@ -0,0 +1,24 @@
1
+ FROM python:3.12-slim AS builder
2
+
3
+ WORKDIR /app
4
+
5
+ RUN pip install --no-cache-dir hatchling
6
+
7
+ # Install buyer SDK and gateway packages
8
+ COPY packages/agentpay /app/packages/agentpay
9
+ COPY packages/agentpay-gateway /app/packages/agentpay-gateway
10
+
11
+ RUN pip install --no-cache-dir /app/packages/agentpay /app/packages/agentpay-gateway
12
+
13
+ FROM python:3.12-slim AS runtime
14
+
15
+ WORKDIR /app
16
+
17
+ COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
18
+ COPY --from=builder /usr/local/bin /usr/local/bin
19
+
20
+ EXPOSE 8000
21
+
22
+ ENV PYTHONUNBUFFERED=1
23
+
24
+ ENTRYPOINT ["uvicorn", "agentpay_gateway.server:app", "--host", "0.0.0.0", "--port", "8000"]
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.5
2
+ Name: agentpay-gateway
3
+ Version: 0.1.0
4
+ Summary: AgentPay Reverse Proxy & Seller Gateway for Autonomous Agent Micro-Payments
5
+ Project-URL: Homepage, https://github.com/july-whj/AgentPay
6
+ Project-URL: Documentation, https://github.com/july-whj/AgentPay/blob/main/specs/gateway-guide.md
7
+ Project-URL: Repository, https://github.com/july-whj/AgentPay
8
+ Author: AgentPay Contributors
9
+ License-Expression: Apache-2.0
10
+ Keywords: agent,ai,arbitrum,eip-712,gateway,reverse-proxy,usdc,x402
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Internet :: Proxy Servers
19
+ Classifier: Topic :: Security
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: fastapi>=0.110.0
22
+ Requires-Dist: httpx>=0.27.0
23
+ Requires-Dist: open-agentpay>=0.1.0
24
+ Requires-Dist: pydantic-settings>=2.2.0
25
+ Requires-Dist: pydantic>=2.6.0
26
+ Requires-Dist: uvicorn>=0.28.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: mypy>=1.9.0; extra == 'dev'
29
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.3.0; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # AgentPay Gateway (`agentpay-gateway`)
35
+
36
+ [![PyPI Version](https://img.shields.io/pypi/v/agentpay-gateway.svg)](https://pypi.org/project/agentpay-gateway/)
37
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
38
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
39
+
40
+ **Autonomous Agent Payment Gateway & Reverse Proxy for API Monetization.**
41
+
42
+ `agentpay-gateway` sits directly in front of existing REST APIs and AI microservices, monetizing requests via HTTP 402 Payment Required challenges settled gaslessly on-chain (Arbitrum Sepolia & Base).
43
+
44
+ ---
45
+
46
+ ## ⚡ Quickstart
47
+
48
+ ### Installation
49
+ ```bash
50
+ pip install agentpay-gateway
51
+ ```
52
+
53
+ ### Configuration (`gateway.yaml`)
54
+ ```yaml
55
+ version: "1.0"
56
+
57
+ server:
58
+ host: "0.0.0.0"
59
+ port: 8000
60
+ db_path: "./data/gateway.db"
61
+
62
+ facilitator:
63
+ url: "http://127.0.0.1:8001"
64
+
65
+ settlement:
66
+ default_network: "eip155:421614" # Arbitrum Sepolia
67
+ default_asset: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d" # Circle USDC
68
+ default_pay_to: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
69
+
70
+ routes:
71
+ - path: "/v1/market-data"
72
+ upstream: "https://httpbin.org/get"
73
+ price: "0.001 USDC"
74
+ ```
75
+
76
+ ### Running the Gateway
77
+ ```bash
78
+ python3 -m agentpay_gateway.server --config ./gateway.yaml
79
+ ```
80
+
81
+ For complete documentation, visit [AgentPay Gateway Guide](https://github.com/july-whj/AgentPay/blob/main/specs/gateway-guide.md).
@@ -0,0 +1,48 @@
1
+ # AgentPay Gateway (`agentpay-gateway`)
2
+
3
+ [![PyPI Version](https://img.shields.io/pypi/v/agentpay-gateway.svg)](https://pypi.org/project/agentpay-gateway/)
4
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
6
+
7
+ **Autonomous Agent Payment Gateway & Reverse Proxy for API Monetization.**
8
+
9
+ `agentpay-gateway` sits directly in front of existing REST APIs and AI microservices, monetizing requests via HTTP 402 Payment Required challenges settled gaslessly on-chain (Arbitrum Sepolia & Base).
10
+
11
+ ---
12
+
13
+ ## ⚡ Quickstart
14
+
15
+ ### Installation
16
+ ```bash
17
+ pip install agentpay-gateway
18
+ ```
19
+
20
+ ### Configuration (`gateway.yaml`)
21
+ ```yaml
22
+ version: "1.0"
23
+
24
+ server:
25
+ host: "0.0.0.0"
26
+ port: 8000
27
+ db_path: "./data/gateway.db"
28
+
29
+ facilitator:
30
+ url: "http://127.0.0.1:8001"
31
+
32
+ settlement:
33
+ default_network: "eip155:421614" # Arbitrum Sepolia
34
+ default_asset: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d" # Circle USDC
35
+ default_pay_to: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
36
+
37
+ routes:
38
+ - path: "/v1/market-data"
39
+ upstream: "https://httpbin.org/get"
40
+ price: "0.001 USDC"
41
+ ```
42
+
43
+ ### Running the Gateway
44
+ ```bash
45
+ python3 -m agentpay_gateway.server --config ./gateway.yaml
46
+ ```
47
+
48
+ For complete documentation, visit [AgentPay Gateway Guide](https://github.com/july-whj/AgentPay/blob/main/specs/gateway-guide.md).
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "agentpay-gateway"
7
+ version = "0.1.0"
8
+ description = "AgentPay Reverse Proxy & Seller Gateway for Autonomous Agent Micro-Payments"
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ authors = [
12
+ { name = "AgentPay Contributors" }
13
+ ]
14
+ requires-python = ">=3.10"
15
+ keywords = ["agent", "ai", "x402", "gateway", "reverse-proxy", "usdc", "eip-712", "arbitrum"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: Apache Software License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Internet :: Proxy Servers",
25
+ "Topic :: Security",
26
+ ]
27
+ dependencies = [
28
+ "open-agentpay>=0.1.0",
29
+ "fastapi>=0.110.0",
30
+ "uvicorn>=0.28.0",
31
+ "httpx>=0.27.0",
32
+ "pydantic>=2.6.0",
33
+ "pydantic-settings>=2.2.0"
34
+ ]
35
+
36
+ [project.optional-dependencies]
37
+ dev = [
38
+ "pytest>=8.0.0",
39
+ "pytest-asyncio>=0.23.0",
40
+ "ruff>=0.3.0",
41
+ "mypy>=1.9.0"
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/july-whj/AgentPay"
46
+ Documentation = "https://github.com/july-whj/AgentPay/blob/main/specs/gateway-guide.md"
47
+ Repository = "https://github.com/july-whj/AgentPay"
48
+
49
+ [tool.hatch.build.targets.wheel]
50
+ packages = ["src/agentpay_gateway"]
@@ -0,0 +1,9 @@
1
+ """
2
+ AgentPay Gateway Package.
3
+
4
+ Reverse proxy, x402 challenge generation, Facilitator verification, and fulfillment tracking.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ __version__ = "0.1.0"