agent-commerce-framework 0.4.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 (257) hide show
  1. agent_commerce_framework-0.4.0/.deliveryignore +8 -0
  2. agent_commerce_framework-0.4.0/.dockerignore +11 -0
  3. agent_commerce_framework-0.4.0/.env.example +42 -0
  4. agent_commerce_framework-0.4.0/.gitignore +11 -0
  5. agent_commerce_framework-0.4.0/.internal/ARCHITECTURE.md +273 -0
  6. agent_commerce_framework-0.4.0/.internal/IMPLEMENTATION_PLAN.md +434 -0
  7. agent_commerce_framework-0.4.0/.internal/MARKET_RESEARCH.md +98 -0
  8. agent_commerce_framework-0.4.0/.internal/MARKET_RESEARCH_2026Q1.md +444 -0
  9. agent_commerce_framework-0.4.0/.internal/PRODUCT_SPEC.md +208 -0
  10. agent_commerce_framework-0.4.0/.internal/SECURITY_AUDIT_REPORT.md +142 -0
  11. agent_commerce_framework-0.4.0/.internal/security_audit_keys.md +300 -0
  12. agent_commerce_framework-0.4.0/.internal/security_audit_owasp.md +790 -0
  13. agent_commerce_framework-0.4.0/.internal/security_audit_ratelimit_validation.md +922 -0
  14. agent_commerce_framework-0.4.0/CHANGELOG.md +90 -0
  15. agent_commerce_framework-0.4.0/Dockerfile +30 -0
  16. agent_commerce_framework-0.4.0/LICENSE +21 -0
  17. agent_commerce_framework-0.4.0/PKG-INFO +398 -0
  18. agent_commerce_framework-0.4.0/QA_REPORT_MIM-371.md +192 -0
  19. agent_commerce_framework-0.4.0/README.md +352 -0
  20. agent_commerce_framework-0.4.0/api/__init__.py +0 -0
  21. agent_commerce_framework-0.4.0/api/deps.py +56 -0
  22. agent_commerce_framework-0.4.0/api/main.py +301 -0
  23. agent_commerce_framework-0.4.0/api/routes/__init__.py +0 -0
  24. agent_commerce_framework-0.4.0/api/routes/admin.py +557 -0
  25. agent_commerce_framework-0.4.0/api/routes/audit.py +45 -0
  26. agent_commerce_framework-0.4.0/api/routes/auth.py +137 -0
  27. agent_commerce_framework-0.4.0/api/routes/billing.py +548 -0
  28. agent_commerce_framework-0.4.0/api/routes/dashboard.py +478 -0
  29. agent_commerce_framework-0.4.0/api/routes/dashboard_queries.py +465 -0
  30. agent_commerce_framework-0.4.0/api/routes/discovery.py +238 -0
  31. agent_commerce_framework-0.4.0/api/routes/email.py +600 -0
  32. agent_commerce_framework-0.4.0/api/routes/health.py +291 -0
  33. agent_commerce_framework-0.4.0/api/routes/identity.py +164 -0
  34. agent_commerce_framework-0.4.0/api/routes/portal.py +550 -0
  35. agent_commerce_framework-0.4.0/api/routes/provider.py +492 -0
  36. agent_commerce_framework-0.4.0/api/routes/proxy.py +149 -0
  37. agent_commerce_framework-0.4.0/api/routes/referral.py +92 -0
  38. agent_commerce_framework-0.4.0/api/routes/reputation.py +98 -0
  39. agent_commerce_framework-0.4.0/api/routes/services.py +214 -0
  40. agent_commerce_framework-0.4.0/api/routes/settlement.py +126 -0
  41. agent_commerce_framework-0.4.0/api/routes/teams.py +379 -0
  42. agent_commerce_framework-0.4.0/api/routes/webhooks.py +81 -0
  43. agent_commerce_framework-0.4.0/cli/__init__.py +0 -0
  44. agent_commerce_framework-0.4.0/cli/__main__.py +4 -0
  45. agent_commerce_framework-0.4.0/cli/drip_sender.py +203 -0
  46. agent_commerce_framework-0.4.0/cli/manage.py +213 -0
  47. agent_commerce_framework-0.4.0/docker-compose.yml +43 -0
  48. agent_commerce_framework-0.4.0/docs/API_REFERENCE.md +1940 -0
  49. agent_commerce_framework-0.4.0/docs/COINSIFTER_API.md +299 -0
  50. agent_commerce_framework-0.4.0/docs/IR_DECK.md +642 -0
  51. agent_commerce_framework-0.4.0/docs/IR_DECK_zh-TW.md +642 -0
  52. agent_commerce_framework-0.4.0/docs/PRODUCT_SPEC.md +341 -0
  53. agent_commerce_framework-0.4.0/docs/PROVIDER_GUIDE.md +217 -0
  54. agent_commerce_framework-0.4.0/docs/QA_PROVIDER_DOCS.md +113 -0
  55. agent_commerce_framework-0.4.0/docs/architecture.md +235 -0
  56. agent_commerce_framework-0.4.0/docs/blog/01-how-to-list-ai-api-on-agentictrade.md +298 -0
  57. agent_commerce_framework-0.4.0/docs/blog/02-agentictrade-vs-rapidapi.md +213 -0
  58. agent_commerce_framework-0.4.0/docs/blog/03-agent-auto-pay-x402.md +395 -0
  59. agent_commerce_framework-0.4.0/docs/blog/ko/01-how-to-list-ai-api-on-agentictrade.md +298 -0
  60. agent_commerce_framework-0.4.0/docs/blog/ko/02-agentictrade-vs-rapidapi.md +213 -0
  61. agent_commerce_framework-0.4.0/docs/blog/ko/03-agent-auto-pay-x402.md +394 -0
  62. agent_commerce_framework-0.4.0/docs/blog/zh-TW/01-how-to-list-ai-api-on-agentictrade.md +298 -0
  63. agent_commerce_framework-0.4.0/docs/blog/zh-TW/02-agentictrade-vs-rapidapi.md +213 -0
  64. agent_commerce_framework-0.4.0/docs/blog/zh-TW/03-agent-auto-pay-x402.md +395 -0
  65. agent_commerce_framework-0.4.0/docs/getting_started.md +220 -0
  66. agent_commerce_framework-0.4.0/docs/ko/API_REFERENCE.md +1940 -0
  67. agent_commerce_framework-0.4.0/docs/ko/PRODUCT_SPEC.md +341 -0
  68. agent_commerce_framework-0.4.0/docs/ko/PROVIDER_GUIDE.md +217 -0
  69. agent_commerce_framework-0.4.0/docs/ko/README.md +350 -0
  70. agent_commerce_framework-0.4.0/docs/ko/getting_started.md +220 -0
  71. agent_commerce_framework-0.4.0/docs/payment_integration_plan.md +383 -0
  72. agent_commerce_framework-0.4.0/docs/payments.md +613 -0
  73. agent_commerce_framework-0.4.0/docs/zh-TW/API_REFERENCE.md +1940 -0
  74. agent_commerce_framework-0.4.0/docs/zh-TW/PRODUCT_SPEC.md +341 -0
  75. agent_commerce_framework-0.4.0/docs/zh-TW/README.md +352 -0
  76. agent_commerce_framework-0.4.0/docs/zh-TW/getting_started.md +220 -0
  77. agent_commerce_framework-0.4.0/examples/agent_buys_api.py +118 -0
  78. agent_commerce_framework-0.4.0/examples/check_analytics.py +62 -0
  79. agent_commerce_framework-0.4.0/examples/consume_service.py +53 -0
  80. agent_commerce_framework-0.4.0/examples/multi_agent_trade.py +167 -0
  81. agent_commerce_framework-0.4.0/examples/payment_flow.py +155 -0
  82. agent_commerce_framework-0.4.0/examples/quickstart.py +287 -0
  83. agent_commerce_framework-0.4.0/examples/register_service.py +58 -0
  84. agent_commerce_framework-0.4.0/examples/team_setup.py +138 -0
  85. agent_commerce_framework-0.4.0/examples/two_agents_trading.py +301 -0
  86. agent_commerce_framework-0.4.0/examples/webhook_listener.py +91 -0
  87. agent_commerce_framework-0.4.0/landing/copy.ko.md +183 -0
  88. agent_commerce_framework-0.4.0/landing/copy.md +159 -0
  89. agent_commerce_framework-0.4.0/landing/copy.zh-TW.md +159 -0
  90. agent_commerce_framework-0.4.0/marketing/MARKETING_PLAN.md +251 -0
  91. agent_commerce_framework-0.4.0/marketing/README.md +34 -0
  92. agent_commerce_framework-0.4.0/marketing/blog_outline_zh.md +57 -0
  93. agent_commerce_framework-0.4.0/marketing/x_thread_en.md +90 -0
  94. agent_commerce_framework-0.4.0/marketing/x_thread_zh.md +89 -0
  95. agent_commerce_framework-0.4.0/marketplace/__init__.py +2 -0
  96. agent_commerce_framework-0.4.0/marketplace/audit.py +162 -0
  97. agent_commerce_framework-0.4.0/marketplace/auth.py +191 -0
  98. agent_commerce_framework-0.4.0/marketplace/commission.py +267 -0
  99. agent_commerce_framework-0.4.0/marketplace/db.py +1167 -0
  100. agent_commerce_framework-0.4.0/marketplace/discovery.py +210 -0
  101. agent_commerce_framework-0.4.0/marketplace/drip_email.py +525 -0
  102. agent_commerce_framework-0.4.0/marketplace/health_monitor.py +308 -0
  103. agent_commerce_framework-0.4.0/marketplace/i18n.py +6075 -0
  104. agent_commerce_framework-0.4.0/marketplace/identity.py +184 -0
  105. agent_commerce_framework-0.4.0/marketplace/milestones.py +247 -0
  106. agent_commerce_framework-0.4.0/marketplace/models.py +156 -0
  107. agent_commerce_framework-0.4.0/marketplace/payment.py +149 -0
  108. agent_commerce_framework-0.4.0/marketplace/platform_consumer.py +193 -0
  109. agent_commerce_framework-0.4.0/marketplace/provider_auth.py +388 -0
  110. agent_commerce_framework-0.4.0/marketplace/proxy.py +327 -0
  111. agent_commerce_framework-0.4.0/marketplace/rate_limit.py +64 -0
  112. agent_commerce_framework-0.4.0/marketplace/referral.py +323 -0
  113. agent_commerce_framework-0.4.0/marketplace/registry.py +295 -0
  114. agent_commerce_framework-0.4.0/marketplace/reputation.py +168 -0
  115. agent_commerce_framework-0.4.0/marketplace/settlement.py +273 -0
  116. agent_commerce_framework-0.4.0/marketplace/wallet.py +234 -0
  117. agent_commerce_framework-0.4.0/marketplace/webhooks.py +324 -0
  118. agent_commerce_framework-0.4.0/mcp_bridge/__init__.py +2 -0
  119. agent_commerce_framework-0.4.0/mcp_bridge/discovery.py +100 -0
  120. agent_commerce_framework-0.4.0/mcp_bridge/server.py +296 -0
  121. agent_commerce_framework-0.4.0/payments/__init__.py +2 -0
  122. agent_commerce_framework-0.4.0/payments/agentkit_provider.py +216 -0
  123. agent_commerce_framework-0.4.0/payments/base.py +117 -0
  124. agent_commerce_framework-0.4.0/payments/nowpayments_provider.py +293 -0
  125. agent_commerce_framework-0.4.0/payments/router.py +96 -0
  126. agent_commerce_framework-0.4.0/payments/stripe_acp.py +281 -0
  127. agent_commerce_framework-0.4.0/payments/x402_provider.py +175 -0
  128. agent_commerce_framework-0.4.0/pyproject.toml +56 -0
  129. agent_commerce_framework-0.4.0/requirements.txt +24 -0
  130. agent_commerce_framework-0.4.0/sdk/__init__.py +12 -0
  131. agent_commerce_framework-0.4.0/sdk/buyer.py +392 -0
  132. agent_commerce_framework-0.4.0/sdk/client.py +703 -0
  133. agent_commerce_framework-0.4.0/seed/__init__.py +0 -0
  134. agent_commerce_framework-0.4.0/seed/coinsifter_api.py +283 -0
  135. agent_commerce_framework-0.4.0/seed/demo_data.py +271 -0
  136. agent_commerce_framework-0.4.0/seed/register_backtest.py +86 -0
  137. agent_commerce_framework-0.4.0/seed/register_coinsifter.py +142 -0
  138. agent_commerce_framework-0.4.0/starter-kit/README.md +142 -0
  139. agent_commerce_framework-0.4.0/starter-kit/cli/acf_test_payment.py +171 -0
  140. agent_commerce_framework-0.4.0/starter-kit/deploy/.env.production.template +27 -0
  141. agent_commerce_framework-0.4.0/starter-kit/deploy/docker-compose.prod.yml +51 -0
  142. agent_commerce_framework-0.4.0/starter-kit/deploy/nginx/acf.conf +113 -0
  143. agent_commerce_framework-0.4.0/starter-kit/guide/00-introduction.md +97 -0
  144. agent_commerce_framework-0.4.0/starter-kit/guide/01-landscape.md +147 -0
  145. agent_commerce_framework-0.4.0/starter-kit/guide/02-quickstart.md +180 -0
  146. agent_commerce_framework-0.4.0/starter-kit/guide/03-architecture.md +287 -0
  147. agent_commerce_framework-0.4.0/starter-kit/guide/04-services.md +203 -0
  148. agent_commerce_framework-0.4.0/starter-kit/guide/05-billing.md +206 -0
  149. agent_commerce_framework-0.4.0/starter-kit/guide/06-proxy.md +250 -0
  150. agent_commerce_framework-0.4.0/starter-kit/guide/07-payments.md +271 -0
  151. agent_commerce_framework-0.4.0/starter-kit/guide/08-mcp.md +290 -0
  152. agent_commerce_framework-0.4.0/starter-kit/guide/09-swarms.md +358 -0
  153. agent_commerce_framework-0.4.0/starter-kit/guide/10-deployment.md +275 -0
  154. agent_commerce_framework-0.4.0/starter-kit/guide/11-monetization.md +180 -0
  155. agent_commerce_framework-0.4.0/starter-kit/guide/12-whats-next.md +182 -0
  156. agent_commerce_framework-0.4.0/starter-kit/guide/cheatsheets/api-reference.md +128 -0
  157. agent_commerce_framework-0.4.0/starter-kit/guide/cheatsheets/troubleshooting.md +196 -0
  158. agent_commerce_framework-0.4.0/starter-kit/guide/diagrams/architecture.md +179 -0
  159. agent_commerce_framework-0.4.0/starter-kit/sdk/__init__.py +12 -0
  160. agent_commerce_framework-0.4.0/starter-kit/sdk/buyer.py +357 -0
  161. agent_commerce_framework-0.4.0/starter-kit/sdk/client.py +447 -0
  162. agent_commerce_framework-0.4.0/starter-kit/templates/api-monetization/README.md +44 -0
  163. agent_commerce_framework-0.4.0/starter-kit/templates/api-monetization/config.example.yaml +43 -0
  164. agent_commerce_framework-0.4.0/starter-kit/templates/api-monetization/register_services.py +95 -0
  165. agent_commerce_framework-0.4.0/starter-kit/templates/api-monetization/test_flow.py +154 -0
  166. agent_commerce_framework-0.4.0/starter-kit/templates/mcp-commerce-server/README.md +65 -0
  167. agent_commerce_framework-0.4.0/starter-kit/templates/mcp-commerce-server/server.py +259 -0
  168. agent_commerce_framework-0.4.0/starter-kit/templates/multi-agent-swarm/README.md +45 -0
  169. agent_commerce_framework-0.4.0/starter-kit/templates/multi-agent-swarm/config.example.yaml +26 -0
  170. agent_commerce_framework-0.4.0/starter-kit/templates/multi-agent-swarm/swarm.py +320 -0
  171. agent_commerce_framework-0.4.0/starter-kit/templates/webhook-automation/README.md +83 -0
  172. agent_commerce_framework-0.4.0/starter-kit/templates/webhook-automation/config.example.yaml +61 -0
  173. agent_commerce_framework-0.4.0/starter-kit/templates/webhook-automation/webhook_consumer.py +353 -0
  174. agent_commerce_framework-0.4.0/starter-kit.zip +0 -0
  175. agent_commerce_framework-0.4.0/static/css/api-docs.css +231 -0
  176. agent_commerce_framework-0.4.0/static/css/marketplace.css +267 -0
  177. agent_commerce_framework-0.4.0/static/css/product.css +249 -0
  178. agent_commerce_framework-0.4.0/static/css/public.css +503 -0
  179. agent_commerce_framework-0.4.0/static/img/favicon.ico +0 -0
  180. agent_commerce_framework-0.4.0/static/img/logo.jpg +0 -0
  181. agent_commerce_framework-0.4.0/static/img/logo.webp +0 -0
  182. agent_commerce_framework-0.4.0/static/img/og-default.jpg +0 -0
  183. agent_commerce_framework-0.4.0/static/logo.jpg +0 -0
  184. agent_commerce_framework-0.4.0/teamwork/__init__.py +2 -0
  185. agent_commerce_framework-0.4.0/teamwork/agent_config.py +72 -0
  186. agent_commerce_framework-0.4.0/teamwork/orchestrator.py +245 -0
  187. agent_commerce_framework-0.4.0/teamwork/quality_gates.py +127 -0
  188. agent_commerce_framework-0.4.0/teamwork/task_router.py +141 -0
  189. agent_commerce_framework-0.4.0/teamwork/templates.py +210 -0
  190. agent_commerce_framework-0.4.0/templates/api-docs.html +738 -0
  191. agent_commerce_framework-0.4.0/templates/checkout-success.html +43 -0
  192. agent_commerce_framework-0.4.0/templates/dashboard/agents.html +88 -0
  193. agent_commerce_framework-0.4.0/templates/dashboard/base.html +104 -0
  194. agent_commerce_framework-0.4.0/templates/dashboard/overview.html +91 -0
  195. agent_commerce_framework-0.4.0/templates/dashboard/providers.html +100 -0
  196. agent_commerce_framework-0.4.0/templates/dashboard/quality.html +98 -0
  197. agent_commerce_framework-0.4.0/templates/dashboard/services.html +58 -0
  198. agent_commerce_framework-0.4.0/templates/dashboard/transactions.html +141 -0
  199. agent_commerce_framework-0.4.0/templates/dashboard.html +482 -0
  200. agent_commerce_framework-0.4.0/templates/email/first_sale.html +47 -0
  201. agent_commerce_framework-0.4.0/templates/email/onboarding.html +45 -0
  202. agent_commerce_framework-0.4.0/templates/email/weekly_digest.html +55 -0
  203. agent_commerce_framework-0.4.0/templates/email/welcome.html +45 -0
  204. agent_commerce_framework-0.4.0/templates/marketplace.html +229 -0
  205. agent_commerce_framework-0.4.0/templates/portal/analytics.html +89 -0
  206. agent_commerce_framework-0.4.0/templates/portal/base.html +84 -0
  207. agent_commerce_framework-0.4.0/templates/portal/dashboard.html +93 -0
  208. agent_commerce_framework-0.4.0/templates/portal/login.html +33 -0
  209. agent_commerce_framework-0.4.0/templates/portal/register.html +43 -0
  210. agent_commerce_framework-0.4.0/templates/portal/services.html +49 -0
  211. agent_commerce_framework-0.4.0/templates/portal/settings.html +93 -0
  212. agent_commerce_framework-0.4.0/templates/portal/verify.html +23 -0
  213. agent_commerce_framework-0.4.0/templates/public/about.html +211 -0
  214. agent_commerce_framework-0.4.0/templates/public/base.html +147 -0
  215. agent_commerce_framework-0.4.0/templates/public/landing.html +864 -0
  216. agent_commerce_framework-0.4.0/templates/public/pricing.html +240 -0
  217. agent_commerce_framework-0.4.0/templates/public/providers.html +300 -0
  218. agent_commerce_framework-0.4.0/templates/starter-kit-product.html +352 -0
  219. agent_commerce_framework-0.4.0/tests/__init__.py +0 -0
  220. agent_commerce_framework-0.4.0/tests/conftest.py +11 -0
  221. agent_commerce_framework-0.4.0/tests/test_admin.py +728 -0
  222. agent_commerce_framework-0.4.0/tests/test_agentkit_provider.py +216 -0
  223. agent_commerce_framework-0.4.0/tests/test_audit.py +396 -0
  224. agent_commerce_framework-0.4.0/tests/test_auth.py +222 -0
  225. agent_commerce_framework-0.4.0/tests/test_billing.py +394 -0
  226. agent_commerce_framework-0.4.0/tests/test_billing_race.py +159 -0
  227. agent_commerce_framework-0.4.0/tests/test_coinsifter_integration.py +266 -0
  228. agent_commerce_framework-0.4.0/tests/test_commission.py +528 -0
  229. agent_commerce_framework-0.4.0/tests/test_dashboard.py +581 -0
  230. agent_commerce_framework-0.4.0/tests/test_dashboard_providers.py +440 -0
  231. agent_commerce_framework-0.4.0/tests/test_discovery.py +202 -0
  232. agent_commerce_framework-0.4.0/tests/test_drip_email.py +499 -0
  233. agent_commerce_framework-0.4.0/tests/test_drip_sender.py +108 -0
  234. agent_commerce_framework-0.4.0/tests/test_email.py +266 -0
  235. agent_commerce_framework-0.4.0/tests/test_founding_seller.py +146 -0
  236. agent_commerce_framework-0.4.0/tests/test_health_monitor.py +234 -0
  237. agent_commerce_framework-0.4.0/tests/test_identity.py +220 -0
  238. agent_commerce_framework-0.4.0/tests/test_integration.py +505 -0
  239. agent_commerce_framework-0.4.0/tests/test_mcp_bridge.py +400 -0
  240. agent_commerce_framework-0.4.0/tests/test_mcp_descriptor.py +113 -0
  241. agent_commerce_framework-0.4.0/tests/test_milestones.py +257 -0
  242. agent_commerce_framework-0.4.0/tests/test_payment.py +180 -0
  243. agent_commerce_framework-0.4.0/tests/test_payments_providers.py +1012 -0
  244. agent_commerce_framework-0.4.0/tests/test_platform_consumer.py +148 -0
  245. agent_commerce_framework-0.4.0/tests/test_portal_token.py +245 -0
  246. agent_commerce_framework-0.4.0/tests/test_provider.py +331 -0
  247. agent_commerce_framework-0.4.0/tests/test_proxy.py +572 -0
  248. agent_commerce_framework-0.4.0/tests/test_rate_limit.py +67 -0
  249. agent_commerce_framework-0.4.0/tests/test_referral.py +506 -0
  250. agent_commerce_framework-0.4.0/tests/test_registry.py +229 -0
  251. agent_commerce_framework-0.4.0/tests/test_reputation.py +182 -0
  252. agent_commerce_framework-0.4.0/tests/test_sdk.py +932 -0
  253. agent_commerce_framework-0.4.0/tests/test_settlement.py +166 -0
  254. agent_commerce_framework-0.4.0/tests/test_stripe_acp.py +488 -0
  255. agent_commerce_framework-0.4.0/tests/test_teamwork.py +406 -0
  256. agent_commerce_framework-0.4.0/tests/test_wallet.py +149 -0
  257. agent_commerce_framework-0.4.0/tests/test_webhooks.py +614 -0
@@ -0,0 +1,8 @@
1
+ # Files to exclude from customer delivery packaging
2
+ .internal/
3
+ .deliveryignore
4
+ .git/
5
+ __pycache__/
6
+ *.pyc
7
+ .pytest_cache/
8
+ data/
@@ -0,0 +1,11 @@
1
+ .git/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ data/
6
+ .internal/
7
+ .env
8
+ .gitignore
9
+ .deliveryignore
10
+ .dockerignore
11
+ tests/
@@ -0,0 +1,42 @@
1
+ # Agent Commerce Framework — Environment Variables
2
+
3
+ # Database (default: SQLite in ./data/)
4
+ # DATABASE_PATH=./data/marketplace.db
5
+
6
+ # Server
7
+ # HOST=0.0.0.0
8
+ # PORT=8000
9
+
10
+ # CORS
11
+ # CORS_ORIGINS=*
12
+
13
+ # Platform Settings
14
+ # PLATFORM_FEE_PCT=0.10
15
+
16
+ # --- x402 Payment (receive payments from buyers) ---
17
+ # Your wallet address that receives USDC from x402 payments
18
+ # WALLET_ADDRESS=0x...
19
+
20
+ # Network: Base Sepolia (testnet) or Base Mainnet (production)
21
+ # NETWORK=eip155:84532
22
+ # Production: NETWORK=eip155:8453
23
+
24
+ # Facilitator URL
25
+ # Testnet: FACILITATOR_URL=https://x402.org/facilitator
26
+ # Production: FACILITATOR_URL=https://api.cdp.coinbase.com/platform/v2/x402
27
+
28
+ # --- CDP Wallet (send USDC payouts to providers) ---
29
+ # Get CDP API keys from https://portal.cdp.coinbase.com/
30
+ # CDP_API_KEY_NAME=...
31
+ # CDP_API_KEY_SECRET=...
32
+ # CDP_WALLET_ID=...
33
+ # CDP_NETWORK=base-sepolia
34
+
35
+ # --- Stripe Agent Checkout Protocol (fiat payments, optional) ---
36
+ # STRIPE_SECRET_KEY=sk_...
37
+ # STRIPE_WEBHOOK_SECRET=whsec_...
38
+
39
+ # --- NOWPayments (crypto payments via USDT/BTC/etc, optional) ---
40
+ # NOWPAYMENTS_API_KEY=...
41
+ # NOWPAYMENTS_IPN_SECRET=...
42
+ # NOWPAYMENTS_SANDBOX=true
@@ -0,0 +1,11 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .eggs/
7
+ *.db
8
+ .env
9
+ .venv/
10
+ data/marketplace.db
11
+ .x402_wallet
@@ -0,0 +1,273 @@
1
+ # Agent Commerce Framework — Technical Architecture
2
+ > MIM-299 | v0.1 Draft | 2026-03-18
3
+
4
+ ## System Overview
5
+
6
+ ```
7
+ Client (Agent/Human)
8
+
9
+
10
+ ┌─────────────────────────┐
11
+ │ API Gateway │ FastAPI + x402 middleware
12
+ │ /api/v1/* │ Auth: API Key / Agent Cert
13
+ └─────────┬───────────────┘
14
+
15
+ ┌─────┴─────┐
16
+ │ │
17
+ ▼ ▼
18
+ ┌────────┐ ┌────────────┐
19
+ │Registry│ │ Proxy │ Service discovery + request forwarding
20
+ │Service │ │ + Billing │ x402 payment intercept
21
+ └────┬───┘ └─────┬──────┘
22
+ │ │
23
+ ▼ ▼
24
+ ┌────────┐ ┌────────────┐
25
+ │ SQLite │ │ Provider │ Actual service endpoints
26
+ │ /Postgres│ │ Agents │ (CoinSifter, custom...)
27
+ └────────┘ └────────────┘
28
+ ```
29
+
30
+ ## Core Components
31
+
32
+ ### 1. Service Registry
33
+
34
+ 職責:管理服務的註冊、更新、搜尋。
35
+
36
+ ```python
37
+ # Data model (immutable dataclasses)
38
+
39
+ @dataclass(frozen=True)
40
+ class ServiceListing:
41
+ id: str # UUID
42
+ provider_id: str # Agent/Developer ID
43
+ name: str # 服務名稱
44
+ description: str # 服務描述
45
+ endpoint: str # 實際服務 URL
46
+ pricing: PricingConfig # 定價配置
47
+ status: str # active / paused / reviewing
48
+ created_at: datetime
49
+ updated_at: datetime
50
+ metadata: dict # 自由欄位(tags, category 等)
51
+
52
+ @dataclass(frozen=True)
53
+ class PricingConfig:
54
+ price_per_call: Decimal # 每次呼叫價格 (USD)
55
+ currency: str # "USDC" | "USD"
56
+ payment_method: str # "x402" | "stripe" | "both"
57
+ free_tier_calls: int # 免費額度(0 = 無)
58
+ bulk_discount: dict # 批量折扣規則
59
+ ```
60
+
61
+ API:
62
+ - `POST /api/v1/services` — 註冊新服務
63
+ - `GET /api/v1/services` — 列出/搜尋服務
64
+ - `GET /api/v1/services/{id}` — 服務詳情
65
+ - `PATCH /api/v1/services/{id}` — 更新服務(owner only)
66
+ - `DELETE /api/v1/services/{id}` — 下架服務
67
+
68
+ ### 2. Payment Proxy (核心創新)
69
+
70
+ 職責:攔截 Agent 對 Agent 的請求,自動處理支付。
71
+
72
+ 流程:
73
+ ```
74
+ 1. Buyer Agent → 市集 API: GET /api/v1/proxy/{service_id}/endpoint
75
+ 2. 市集檢查 Buyer 餘額/授權
76
+ 3. 市集用 x402 替 Buyer 付款給 Provider
77
+ 4. 市集轉發請求到 Provider endpoint
78
+ 5. 收到回應 → 記錄用量 → 回傳給 Buyer
79
+ 6. 結算時:Provider 收到 (價格 - 平台費)
80
+ ```
81
+
82
+ 為什麼用 proxy 而不是直接 x402:
83
+ - 統一計費和報表
84
+ - 平台可以做品質監控
85
+ - 買方不需要自己處理 x402(降低門檻)
86
+ - 支援非 x402 的 Provider(Stripe 等)
87
+
88
+ ### 3. Metering & Billing
89
+
90
+ 職責:追蹤用量、計費、結算。
91
+
92
+ ```python
93
+ @dataclass(frozen=True)
94
+ class UsageRecord:
95
+ id: str
96
+ buyer_id: str
97
+ service_id: str
98
+ provider_id: str
99
+ timestamp: datetime
100
+ latency_ms: int
101
+ status_code: int
102
+ amount_usd: Decimal
103
+ payment_method: str # x402 | stripe | free_tier
104
+ payment_tx: str | None # x402 tx hash or stripe charge id
105
+ ```
106
+
107
+ 結算週期:
108
+ - 即時(x402):每筆交易即時結算
109
+ - 日結(Stripe):每日批次結算
110
+ - 平台費:預設 10%,可配置
111
+
112
+ ### 4. Authentication
113
+
114
+ 層級:
115
+ - **Platform API Key**:管理後台、服務註冊
116
+ - **Agent API Key**:Agent 呼叫服務
117
+ - **x402 Wallet**:支付認證(optional,有 API Key 也可以)
118
+
119
+ ```python
120
+ @dataclass(frozen=True)
121
+ class APIKey:
122
+ key_id: str # prefix_xxxxx
123
+ hashed_secret: str # bcrypt hash
124
+ owner_id: str
125
+ role: str # admin | provider | buyer
126
+ rate_limit: int # calls per minute
127
+ wallet_address: str | None # 綁定的 x402 錢包
128
+ created_at: datetime
129
+ expires_at: datetime | None
130
+ ```
131
+
132
+ ## Database Schema (MVP: SQLite → Production: PostgreSQL)
133
+
134
+ ```sql
135
+ -- 服務列表
136
+ CREATE TABLE services (
137
+ id TEXT PRIMARY KEY,
138
+ provider_id TEXT NOT NULL,
139
+ name TEXT NOT NULL,
140
+ description TEXT,
141
+ endpoint TEXT NOT NULL,
142
+ price_per_call REAL NOT NULL,
143
+ currency TEXT DEFAULT 'USDC',
144
+ payment_method TEXT DEFAULT 'x402',
145
+ status TEXT DEFAULT 'active',
146
+ category TEXT,
147
+ tags TEXT, -- JSON array
148
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
149
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
150
+ );
151
+
152
+ -- API Keys
153
+ CREATE TABLE api_keys (
154
+ key_id TEXT PRIMARY KEY,
155
+ hashed_secret TEXT NOT NULL,
156
+ owner_id TEXT NOT NULL,
157
+ role TEXT NOT NULL,
158
+ rate_limit INTEGER DEFAULT 60,
159
+ wallet_address TEXT,
160
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
161
+ expires_at TIMESTAMP
162
+ );
163
+
164
+ -- 用量記錄
165
+ CREATE TABLE usage_records (
166
+ id TEXT PRIMARY KEY,
167
+ buyer_id TEXT NOT NULL,
168
+ service_id TEXT NOT NULL,
169
+ provider_id TEXT NOT NULL,
170
+ timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
171
+ latency_ms INTEGER,
172
+ status_code INTEGER,
173
+ amount_usd REAL,
174
+ payment_method TEXT,
175
+ payment_tx TEXT
176
+ );
177
+
178
+ -- 結算記錄
179
+ CREATE TABLE settlements (
180
+ id TEXT PRIMARY KEY,
181
+ provider_id TEXT NOT NULL,
182
+ period_start TIMESTAMP,
183
+ period_end TIMESTAMP,
184
+ total_amount REAL,
185
+ platform_fee REAL,
186
+ net_amount REAL,
187
+ payment_tx TEXT,
188
+ status TEXT DEFAULT 'pending'
189
+ );
190
+
191
+ -- Indexes
192
+ CREATE INDEX idx_usage_buyer ON usage_records(buyer_id, timestamp);
193
+ CREATE INDEX idx_usage_service ON usage_records(service_id, timestamp);
194
+ CREATE INDEX idx_services_status ON services(status, category);
195
+ ```
196
+
197
+ ## Tech Stack
198
+
199
+ | Component | Technology | Rationale |
200
+ |-----------|-----------|-----------|
201
+ | API Server | FastAPI (Python) | x402 SDK 最成熟、生態好 |
202
+ | Database | SQLite (dev) → PostgreSQL (prod) | 零配置開發、生產可擴展 |
203
+ | Payment | x402 SDK + Stripe API | 雙軌支付 |
204
+ | Dashboard | Next.js 14 | 已有 CryptoLog 經驗 |
205
+ | Deployment | Docker Compose | 一鍵部署 |
206
+ | Monitoring | 內建 /health + /metrics | 簡單實用 |
207
+
208
+ ## MVP Scope (Phase 1)
209
+
210
+ 必須有:
211
+ - [x] 服務 Registry CRUD API
212
+ - [x] API Key 認證
213
+ - [x] Payment Proxy(x402)
214
+ - [x] 用量記錄
215
+ - [x] CoinSifter API 種子商品
216
+ - [x] Docker Compose 部署
217
+ - [x] 基本 CLI 管理工具
218
+
219
+ 可以沒有:
220
+ - Dashboard(Phase 3)
221
+ - Stripe 支付(Phase 2)
222
+ - 自動分潤結算(Phase 3)
223
+ - 服務品質監控(Phase 3)
224
+
225
+ ## Security Considerations
226
+
227
+ - API Key secrets 用 bcrypt hash 存儲
228
+ - x402 支付用 facilitator 驗證(不自建)
229
+ - Rate limit per API key(default 60/min)
230
+ - Provider endpoint URL 只接受 HTTPS
231
+ - 禁止 Provider endpoint 指向 localhost/內網
232
+ - 所有金額計算用 Decimal,不用 float
233
+ - Transaction log 不可修改(append-only)
234
+
235
+ ## File Structure (MVP)
236
+
237
+ ```
238
+ agent-commerce-framework/
239
+ ├── marketplace/
240
+ │ ├── __init__.py
241
+ │ ├── models.py # Data models (frozen dataclasses)
242
+ │ ├── registry.py # Service CRUD
243
+ │ ├── discovery.py # Search + filter
244
+ │ ├── proxy.py # Payment proxy + forwarding
245
+ │ ├── metering.py # Usage tracking
246
+ │ ├── auth.py # API Key management
247
+ │ └── db.py # Database operations
248
+ ├── api/
249
+ │ ├── __init__.py
250
+ │ ├── main.py # FastAPI app
251
+ │ ├── routes/
252
+ │ │ ├── services.py # /api/v1/services/*
253
+ │ │ ├── proxy.py # /api/v1/proxy/*
254
+ │ │ ├── keys.py # /api/v1/keys/*
255
+ │ │ └── health.py # /health, /metrics
256
+ │ └── middleware.py # Auth + rate limit
257
+ ├── cli/
258
+ │ ├── __init__.py
259
+ │ └── manage.py # CLI management tool
260
+ ├── seed/
261
+ │ └── coinsifter_api.py # CoinSifter 種子商品
262
+ ├── tests/
263
+ │ ├── test_registry.py
264
+ │ ├── test_proxy.py
265
+ │ ├── test_metering.py
266
+ │ └── test_auth.py
267
+ ├── docker-compose.yml
268
+ ├── Dockerfile
269
+ ├── requirements.txt
270
+ ├── .env.example
271
+ ├── README.md
272
+ └── LICENSE
273
+ ```