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.
- agent_commerce_framework-0.4.0/.deliveryignore +8 -0
- agent_commerce_framework-0.4.0/.dockerignore +11 -0
- agent_commerce_framework-0.4.0/.env.example +42 -0
- agent_commerce_framework-0.4.0/.gitignore +11 -0
- agent_commerce_framework-0.4.0/.internal/ARCHITECTURE.md +273 -0
- agent_commerce_framework-0.4.0/.internal/IMPLEMENTATION_PLAN.md +434 -0
- agent_commerce_framework-0.4.0/.internal/MARKET_RESEARCH.md +98 -0
- agent_commerce_framework-0.4.0/.internal/MARKET_RESEARCH_2026Q1.md +444 -0
- agent_commerce_framework-0.4.0/.internal/PRODUCT_SPEC.md +208 -0
- agent_commerce_framework-0.4.0/.internal/SECURITY_AUDIT_REPORT.md +142 -0
- agent_commerce_framework-0.4.0/.internal/security_audit_keys.md +300 -0
- agent_commerce_framework-0.4.0/.internal/security_audit_owasp.md +790 -0
- agent_commerce_framework-0.4.0/.internal/security_audit_ratelimit_validation.md +922 -0
- agent_commerce_framework-0.4.0/CHANGELOG.md +90 -0
- agent_commerce_framework-0.4.0/Dockerfile +30 -0
- agent_commerce_framework-0.4.0/LICENSE +21 -0
- agent_commerce_framework-0.4.0/PKG-INFO +398 -0
- agent_commerce_framework-0.4.0/QA_REPORT_MIM-371.md +192 -0
- agent_commerce_framework-0.4.0/README.md +352 -0
- agent_commerce_framework-0.4.0/api/__init__.py +0 -0
- agent_commerce_framework-0.4.0/api/deps.py +56 -0
- agent_commerce_framework-0.4.0/api/main.py +301 -0
- agent_commerce_framework-0.4.0/api/routes/__init__.py +0 -0
- agent_commerce_framework-0.4.0/api/routes/admin.py +557 -0
- agent_commerce_framework-0.4.0/api/routes/audit.py +45 -0
- agent_commerce_framework-0.4.0/api/routes/auth.py +137 -0
- agent_commerce_framework-0.4.0/api/routes/billing.py +548 -0
- agent_commerce_framework-0.4.0/api/routes/dashboard.py +478 -0
- agent_commerce_framework-0.4.0/api/routes/dashboard_queries.py +465 -0
- agent_commerce_framework-0.4.0/api/routes/discovery.py +238 -0
- agent_commerce_framework-0.4.0/api/routes/email.py +600 -0
- agent_commerce_framework-0.4.0/api/routes/health.py +291 -0
- agent_commerce_framework-0.4.0/api/routes/identity.py +164 -0
- agent_commerce_framework-0.4.0/api/routes/portal.py +550 -0
- agent_commerce_framework-0.4.0/api/routes/provider.py +492 -0
- agent_commerce_framework-0.4.0/api/routes/proxy.py +149 -0
- agent_commerce_framework-0.4.0/api/routes/referral.py +92 -0
- agent_commerce_framework-0.4.0/api/routes/reputation.py +98 -0
- agent_commerce_framework-0.4.0/api/routes/services.py +214 -0
- agent_commerce_framework-0.4.0/api/routes/settlement.py +126 -0
- agent_commerce_framework-0.4.0/api/routes/teams.py +379 -0
- agent_commerce_framework-0.4.0/api/routes/webhooks.py +81 -0
- agent_commerce_framework-0.4.0/cli/__init__.py +0 -0
- agent_commerce_framework-0.4.0/cli/__main__.py +4 -0
- agent_commerce_framework-0.4.0/cli/drip_sender.py +203 -0
- agent_commerce_framework-0.4.0/cli/manage.py +213 -0
- agent_commerce_framework-0.4.0/docker-compose.yml +43 -0
- agent_commerce_framework-0.4.0/docs/API_REFERENCE.md +1940 -0
- agent_commerce_framework-0.4.0/docs/COINSIFTER_API.md +299 -0
- agent_commerce_framework-0.4.0/docs/IR_DECK.md +642 -0
- agent_commerce_framework-0.4.0/docs/IR_DECK_zh-TW.md +642 -0
- agent_commerce_framework-0.4.0/docs/PRODUCT_SPEC.md +341 -0
- agent_commerce_framework-0.4.0/docs/PROVIDER_GUIDE.md +217 -0
- agent_commerce_framework-0.4.0/docs/QA_PROVIDER_DOCS.md +113 -0
- agent_commerce_framework-0.4.0/docs/architecture.md +235 -0
- agent_commerce_framework-0.4.0/docs/blog/01-how-to-list-ai-api-on-agentictrade.md +298 -0
- agent_commerce_framework-0.4.0/docs/blog/02-agentictrade-vs-rapidapi.md +213 -0
- agent_commerce_framework-0.4.0/docs/blog/03-agent-auto-pay-x402.md +395 -0
- agent_commerce_framework-0.4.0/docs/blog/ko/01-how-to-list-ai-api-on-agentictrade.md +298 -0
- agent_commerce_framework-0.4.0/docs/blog/ko/02-agentictrade-vs-rapidapi.md +213 -0
- agent_commerce_framework-0.4.0/docs/blog/ko/03-agent-auto-pay-x402.md +394 -0
- agent_commerce_framework-0.4.0/docs/blog/zh-TW/01-how-to-list-ai-api-on-agentictrade.md +298 -0
- agent_commerce_framework-0.4.0/docs/blog/zh-TW/02-agentictrade-vs-rapidapi.md +213 -0
- agent_commerce_framework-0.4.0/docs/blog/zh-TW/03-agent-auto-pay-x402.md +395 -0
- agent_commerce_framework-0.4.0/docs/getting_started.md +220 -0
- agent_commerce_framework-0.4.0/docs/ko/API_REFERENCE.md +1940 -0
- agent_commerce_framework-0.4.0/docs/ko/PRODUCT_SPEC.md +341 -0
- agent_commerce_framework-0.4.0/docs/ko/PROVIDER_GUIDE.md +217 -0
- agent_commerce_framework-0.4.0/docs/ko/README.md +350 -0
- agent_commerce_framework-0.4.0/docs/ko/getting_started.md +220 -0
- agent_commerce_framework-0.4.0/docs/payment_integration_plan.md +383 -0
- agent_commerce_framework-0.4.0/docs/payments.md +613 -0
- agent_commerce_framework-0.4.0/docs/zh-TW/API_REFERENCE.md +1940 -0
- agent_commerce_framework-0.4.0/docs/zh-TW/PRODUCT_SPEC.md +341 -0
- agent_commerce_framework-0.4.0/docs/zh-TW/README.md +352 -0
- agent_commerce_framework-0.4.0/docs/zh-TW/getting_started.md +220 -0
- agent_commerce_framework-0.4.0/examples/agent_buys_api.py +118 -0
- agent_commerce_framework-0.4.0/examples/check_analytics.py +62 -0
- agent_commerce_framework-0.4.0/examples/consume_service.py +53 -0
- agent_commerce_framework-0.4.0/examples/multi_agent_trade.py +167 -0
- agent_commerce_framework-0.4.0/examples/payment_flow.py +155 -0
- agent_commerce_framework-0.4.0/examples/quickstart.py +287 -0
- agent_commerce_framework-0.4.0/examples/register_service.py +58 -0
- agent_commerce_framework-0.4.0/examples/team_setup.py +138 -0
- agent_commerce_framework-0.4.0/examples/two_agents_trading.py +301 -0
- agent_commerce_framework-0.4.0/examples/webhook_listener.py +91 -0
- agent_commerce_framework-0.4.0/landing/copy.ko.md +183 -0
- agent_commerce_framework-0.4.0/landing/copy.md +159 -0
- agent_commerce_framework-0.4.0/landing/copy.zh-TW.md +159 -0
- agent_commerce_framework-0.4.0/marketing/MARKETING_PLAN.md +251 -0
- agent_commerce_framework-0.4.0/marketing/README.md +34 -0
- agent_commerce_framework-0.4.0/marketing/blog_outline_zh.md +57 -0
- agent_commerce_framework-0.4.0/marketing/x_thread_en.md +90 -0
- agent_commerce_framework-0.4.0/marketing/x_thread_zh.md +89 -0
- agent_commerce_framework-0.4.0/marketplace/__init__.py +2 -0
- agent_commerce_framework-0.4.0/marketplace/audit.py +162 -0
- agent_commerce_framework-0.4.0/marketplace/auth.py +191 -0
- agent_commerce_framework-0.4.0/marketplace/commission.py +267 -0
- agent_commerce_framework-0.4.0/marketplace/db.py +1167 -0
- agent_commerce_framework-0.4.0/marketplace/discovery.py +210 -0
- agent_commerce_framework-0.4.0/marketplace/drip_email.py +525 -0
- agent_commerce_framework-0.4.0/marketplace/health_monitor.py +308 -0
- agent_commerce_framework-0.4.0/marketplace/i18n.py +6075 -0
- agent_commerce_framework-0.4.0/marketplace/identity.py +184 -0
- agent_commerce_framework-0.4.0/marketplace/milestones.py +247 -0
- agent_commerce_framework-0.4.0/marketplace/models.py +156 -0
- agent_commerce_framework-0.4.0/marketplace/payment.py +149 -0
- agent_commerce_framework-0.4.0/marketplace/platform_consumer.py +193 -0
- agent_commerce_framework-0.4.0/marketplace/provider_auth.py +388 -0
- agent_commerce_framework-0.4.0/marketplace/proxy.py +327 -0
- agent_commerce_framework-0.4.0/marketplace/rate_limit.py +64 -0
- agent_commerce_framework-0.4.0/marketplace/referral.py +323 -0
- agent_commerce_framework-0.4.0/marketplace/registry.py +295 -0
- agent_commerce_framework-0.4.0/marketplace/reputation.py +168 -0
- agent_commerce_framework-0.4.0/marketplace/settlement.py +273 -0
- agent_commerce_framework-0.4.0/marketplace/wallet.py +234 -0
- agent_commerce_framework-0.4.0/marketplace/webhooks.py +324 -0
- agent_commerce_framework-0.4.0/mcp_bridge/__init__.py +2 -0
- agent_commerce_framework-0.4.0/mcp_bridge/discovery.py +100 -0
- agent_commerce_framework-0.4.0/mcp_bridge/server.py +296 -0
- agent_commerce_framework-0.4.0/payments/__init__.py +2 -0
- agent_commerce_framework-0.4.0/payments/agentkit_provider.py +216 -0
- agent_commerce_framework-0.4.0/payments/base.py +117 -0
- agent_commerce_framework-0.4.0/payments/nowpayments_provider.py +293 -0
- agent_commerce_framework-0.4.0/payments/router.py +96 -0
- agent_commerce_framework-0.4.0/payments/stripe_acp.py +281 -0
- agent_commerce_framework-0.4.0/payments/x402_provider.py +175 -0
- agent_commerce_framework-0.4.0/pyproject.toml +56 -0
- agent_commerce_framework-0.4.0/requirements.txt +24 -0
- agent_commerce_framework-0.4.0/sdk/__init__.py +12 -0
- agent_commerce_framework-0.4.0/sdk/buyer.py +392 -0
- agent_commerce_framework-0.4.0/sdk/client.py +703 -0
- agent_commerce_framework-0.4.0/seed/__init__.py +0 -0
- agent_commerce_framework-0.4.0/seed/coinsifter_api.py +283 -0
- agent_commerce_framework-0.4.0/seed/demo_data.py +271 -0
- agent_commerce_framework-0.4.0/seed/register_backtest.py +86 -0
- agent_commerce_framework-0.4.0/seed/register_coinsifter.py +142 -0
- agent_commerce_framework-0.4.0/starter-kit/README.md +142 -0
- agent_commerce_framework-0.4.0/starter-kit/cli/acf_test_payment.py +171 -0
- agent_commerce_framework-0.4.0/starter-kit/deploy/.env.production.template +27 -0
- agent_commerce_framework-0.4.0/starter-kit/deploy/docker-compose.prod.yml +51 -0
- agent_commerce_framework-0.4.0/starter-kit/deploy/nginx/acf.conf +113 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/00-introduction.md +97 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/01-landscape.md +147 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/02-quickstart.md +180 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/03-architecture.md +287 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/04-services.md +203 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/05-billing.md +206 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/06-proxy.md +250 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/07-payments.md +271 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/08-mcp.md +290 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/09-swarms.md +358 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/10-deployment.md +275 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/11-monetization.md +180 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/12-whats-next.md +182 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/cheatsheets/api-reference.md +128 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/cheatsheets/troubleshooting.md +196 -0
- agent_commerce_framework-0.4.0/starter-kit/guide/diagrams/architecture.md +179 -0
- agent_commerce_framework-0.4.0/starter-kit/sdk/__init__.py +12 -0
- agent_commerce_framework-0.4.0/starter-kit/sdk/buyer.py +357 -0
- agent_commerce_framework-0.4.0/starter-kit/sdk/client.py +447 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/api-monetization/README.md +44 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/api-monetization/config.example.yaml +43 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/api-monetization/register_services.py +95 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/api-monetization/test_flow.py +154 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/mcp-commerce-server/README.md +65 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/mcp-commerce-server/server.py +259 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/multi-agent-swarm/README.md +45 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/multi-agent-swarm/config.example.yaml +26 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/multi-agent-swarm/swarm.py +320 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/webhook-automation/README.md +83 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/webhook-automation/config.example.yaml +61 -0
- agent_commerce_framework-0.4.0/starter-kit/templates/webhook-automation/webhook_consumer.py +353 -0
- agent_commerce_framework-0.4.0/starter-kit.zip +0 -0
- agent_commerce_framework-0.4.0/static/css/api-docs.css +231 -0
- agent_commerce_framework-0.4.0/static/css/marketplace.css +267 -0
- agent_commerce_framework-0.4.0/static/css/product.css +249 -0
- agent_commerce_framework-0.4.0/static/css/public.css +503 -0
- agent_commerce_framework-0.4.0/static/img/favicon.ico +0 -0
- agent_commerce_framework-0.4.0/static/img/logo.jpg +0 -0
- agent_commerce_framework-0.4.0/static/img/logo.webp +0 -0
- agent_commerce_framework-0.4.0/static/img/og-default.jpg +0 -0
- agent_commerce_framework-0.4.0/static/logo.jpg +0 -0
- agent_commerce_framework-0.4.0/teamwork/__init__.py +2 -0
- agent_commerce_framework-0.4.0/teamwork/agent_config.py +72 -0
- agent_commerce_framework-0.4.0/teamwork/orchestrator.py +245 -0
- agent_commerce_framework-0.4.0/teamwork/quality_gates.py +127 -0
- agent_commerce_framework-0.4.0/teamwork/task_router.py +141 -0
- agent_commerce_framework-0.4.0/teamwork/templates.py +210 -0
- agent_commerce_framework-0.4.0/templates/api-docs.html +738 -0
- agent_commerce_framework-0.4.0/templates/checkout-success.html +43 -0
- agent_commerce_framework-0.4.0/templates/dashboard/agents.html +88 -0
- agent_commerce_framework-0.4.0/templates/dashboard/base.html +104 -0
- agent_commerce_framework-0.4.0/templates/dashboard/overview.html +91 -0
- agent_commerce_framework-0.4.0/templates/dashboard/providers.html +100 -0
- agent_commerce_framework-0.4.0/templates/dashboard/quality.html +98 -0
- agent_commerce_framework-0.4.0/templates/dashboard/services.html +58 -0
- agent_commerce_framework-0.4.0/templates/dashboard/transactions.html +141 -0
- agent_commerce_framework-0.4.0/templates/dashboard.html +482 -0
- agent_commerce_framework-0.4.0/templates/email/first_sale.html +47 -0
- agent_commerce_framework-0.4.0/templates/email/onboarding.html +45 -0
- agent_commerce_framework-0.4.0/templates/email/weekly_digest.html +55 -0
- agent_commerce_framework-0.4.0/templates/email/welcome.html +45 -0
- agent_commerce_framework-0.4.0/templates/marketplace.html +229 -0
- agent_commerce_framework-0.4.0/templates/portal/analytics.html +89 -0
- agent_commerce_framework-0.4.0/templates/portal/base.html +84 -0
- agent_commerce_framework-0.4.0/templates/portal/dashboard.html +93 -0
- agent_commerce_framework-0.4.0/templates/portal/login.html +33 -0
- agent_commerce_framework-0.4.0/templates/portal/register.html +43 -0
- agent_commerce_framework-0.4.0/templates/portal/services.html +49 -0
- agent_commerce_framework-0.4.0/templates/portal/settings.html +93 -0
- agent_commerce_framework-0.4.0/templates/portal/verify.html +23 -0
- agent_commerce_framework-0.4.0/templates/public/about.html +211 -0
- agent_commerce_framework-0.4.0/templates/public/base.html +147 -0
- agent_commerce_framework-0.4.0/templates/public/landing.html +864 -0
- agent_commerce_framework-0.4.0/templates/public/pricing.html +240 -0
- agent_commerce_framework-0.4.0/templates/public/providers.html +300 -0
- agent_commerce_framework-0.4.0/templates/starter-kit-product.html +352 -0
- agent_commerce_framework-0.4.0/tests/__init__.py +0 -0
- agent_commerce_framework-0.4.0/tests/conftest.py +11 -0
- agent_commerce_framework-0.4.0/tests/test_admin.py +728 -0
- agent_commerce_framework-0.4.0/tests/test_agentkit_provider.py +216 -0
- agent_commerce_framework-0.4.0/tests/test_audit.py +396 -0
- agent_commerce_framework-0.4.0/tests/test_auth.py +222 -0
- agent_commerce_framework-0.4.0/tests/test_billing.py +394 -0
- agent_commerce_framework-0.4.0/tests/test_billing_race.py +159 -0
- agent_commerce_framework-0.4.0/tests/test_coinsifter_integration.py +266 -0
- agent_commerce_framework-0.4.0/tests/test_commission.py +528 -0
- agent_commerce_framework-0.4.0/tests/test_dashboard.py +581 -0
- agent_commerce_framework-0.4.0/tests/test_dashboard_providers.py +440 -0
- agent_commerce_framework-0.4.0/tests/test_discovery.py +202 -0
- agent_commerce_framework-0.4.0/tests/test_drip_email.py +499 -0
- agent_commerce_framework-0.4.0/tests/test_drip_sender.py +108 -0
- agent_commerce_framework-0.4.0/tests/test_email.py +266 -0
- agent_commerce_framework-0.4.0/tests/test_founding_seller.py +146 -0
- agent_commerce_framework-0.4.0/tests/test_health_monitor.py +234 -0
- agent_commerce_framework-0.4.0/tests/test_identity.py +220 -0
- agent_commerce_framework-0.4.0/tests/test_integration.py +505 -0
- agent_commerce_framework-0.4.0/tests/test_mcp_bridge.py +400 -0
- agent_commerce_framework-0.4.0/tests/test_mcp_descriptor.py +113 -0
- agent_commerce_framework-0.4.0/tests/test_milestones.py +257 -0
- agent_commerce_framework-0.4.0/tests/test_payment.py +180 -0
- agent_commerce_framework-0.4.0/tests/test_payments_providers.py +1012 -0
- agent_commerce_framework-0.4.0/tests/test_platform_consumer.py +148 -0
- agent_commerce_framework-0.4.0/tests/test_portal_token.py +245 -0
- agent_commerce_framework-0.4.0/tests/test_provider.py +331 -0
- agent_commerce_framework-0.4.0/tests/test_proxy.py +572 -0
- agent_commerce_framework-0.4.0/tests/test_rate_limit.py +67 -0
- agent_commerce_framework-0.4.0/tests/test_referral.py +506 -0
- agent_commerce_framework-0.4.0/tests/test_registry.py +229 -0
- agent_commerce_framework-0.4.0/tests/test_reputation.py +182 -0
- agent_commerce_framework-0.4.0/tests/test_sdk.py +932 -0
- agent_commerce_framework-0.4.0/tests/test_settlement.py +166 -0
- agent_commerce_framework-0.4.0/tests/test_stripe_acp.py +488 -0
- agent_commerce_framework-0.4.0/tests/test_teamwork.py +406 -0
- agent_commerce_framework-0.4.0/tests/test_wallet.py +149 -0
- agent_commerce_framework-0.4.0/tests/test_webhooks.py +614 -0
|
@@ -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,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
|
+
```
|