# ACP0 **Repository Path**: deloog_qqcom/acp0 ## Basic Information - **Project Name**: ACP0 - **Description**: ACP0 是 AI Agent 购物的开放协议。 它 99% 的流量走 MQTT(比主流电商平台快 20 倍), 1% 的流量走区块链(仅用于争议)。 用户买东西比主流电商平台更快, 没有平台抽佣,没有广告干扰, 争议时由代码而非客服裁决。 灵感来自 Perplexity vs Amazon 案—— 当 AI Agent 能自主购物,平台就不再必要。 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-13 - **Last Updated**: 2025-11-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: 协议, Agent, 开源, ecc, 链下 ## README # ACP0 - Agent Commerce Protocol 0 [![Python Version](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) **ACP0** 是一个去中心化的 AI Agent 商业协议,让 AI Agent 之间可以直接进行商业交易。 ## 🚀 快速开始 ### 安装 ```bash pip install acp0 ``` ### 开发安装 ```bash git clone https://gitee.com/deloog_qqcom/acp0.git cd acp0 pip install -e . ``` ### 运行最小 Demo ```bash python examples/minimal_demo.py ``` 或者使用安装后的命令行工具: ```bash acp0-demo ``` ## 📖 核心概念 ### 消息类型 - **Intent**: 买家表达购物意图 - **Offer**: 卖家提供商品报价 - **Deal**: 买家确认购买交易 ### 代理类型 - **BuyerAgent**: 买家代理,负责广播需求、选择最优报价、确认购买 - **SellerAgent**: 卖家代理,负责监听需求、匹配商品、提供报价 ## 🛠️ 使用示例 ### 基础用法 ```python from acp0.agents.buyer import BuyerAgent from acp0.agents.seller import SellerAgent from acp0.network.memory import InMemoryNetwork # 创建网络层 network = InMemoryNetwork() # 创建卖家代理 seller_inventory = { "laptop": { "name": "Laptop Pro 14 2025", "sku": "LTP-2025-16G-512G", "price": 499900, # 4999.00 CNY "stock": 10, "attributes": {"cpu": "R7-8840U", "ram": "16GB", "ssd": "512GB"} } } seller = SellerAgent( agent_id="seller-001", shop_name="Tech Paradise", inventory=seller_inventory, network=network ) # 创建买家代理 buyer = BuyerAgent( agent_id="buyer-001", network=network ) # 卖家开始监听 seller.listen() # 买家广播需求 offers = buyer.broadcast( category="laptop", budget_range=(400000, 600000), # 4000-6000 CNY currency="CNY", location="shanghai" ) # 选择最优报价并购买 if offers: best_offer = buyer.select_best(offers) deal = buyer.purchase(best_offer) print(f"交易完成: {deal.deal_id}") ``` ## 🔐 安全特性 - **ECC 签名**: 所有消息都使用 ECDSA 签名确保完整性 - **消息验证**: 自动验证消息签名和来源 - **防篡改**: 规范化 JSON 格式防止消息篡改 ## 🏗️ 架构设计 ``` ┌─────────────────┐ ┌─────────────────┐ │ BuyerAgent │ │ SellerAgent │ │ - broadcast() │ │ - listen() │ │ - select() │ │ - respond() │ │ - purchase() │ │ - fulfill() │ └─────────────────┘ └─────────────────┘ │ │ └──────────┬───────────┘ │ ┌───────▼────────┐ │ Message Core │ │ - Intent │ │ - Offer │ │ - Deal │ │ - Signature │ └────────────────┘ │ ┌───────▼────────┐ │ Network Layer │ │ - In-Memory │ │ - HTTP │ │ - MQTT │ └────────────────┘ ``` ## 📁 项目结构 ``` acp0/ ├── acp0/ # 主包 │ ├── core/ # 核心消息和加密 │ │ ├── messages.py # Intent/Offer/Deal 类 │ │ ├── crypto.py # 签名和验证 │ │ └── exceptions.py # 自定义异常 │ ├── agents/ # Agent 实现 │ │ ├── buyer.py # BuyerAgent │ │ └── seller.py # SellerAgent │ ├── network/ # 网络层(可插拔) │ │ ├── base.py # 抽象基类 │ │ ├── memory.py # In-Memory (Demo) │ │ └── http.py # HTTP (Phase 2) │ └── utils/ # 工具函数 ├── examples/ # 示例代码 │ └── minimal_demo.py # 最简单的例子 ├── tests/ # 单元测试 ├── docs/ # 文档 └── spec/ # 规范文档 ``` ## 🧪 测试 运行所有测试: ```bash pytest tests/ -v ``` 运行特定测试: ```bash pytest tests/test_messages.py -v pytest tests/test_crypto.py -v pytest tests/test_agents.py -v ``` ## 📄 许可证 本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。 ## 🤝 贡献 欢迎贡献!请查看 [CONTRIBUTING.md](CONTRIBUTING.md) 了解如何参与项目开发。 ## 📞 联系我们 - Gitee Issues: [https://gitee.com/deloog_qqcom/acp0/issues](https://gitee.com/deloog_qqcom/acp0/issues) - Email: deloog@qq.com ## 🚧 开发状态 当前版本: **v0.9.0 (Alpha)** **已实现功能:** - ✅ 核心消息类 (Intent/Offer/Deal) - ✅ ECC 签名和验证 - ✅ In-Memory 网络层 - ✅ BuyerAgent 和 SellerAgent - ✅ 最小可运行 Demo - ✅ 单元测试 **计划功能:** - 🔄 HTTP 网络层 - 🔄 MQTT 网络层 - 🔄 Web UI 界面 - 🔄 真实支付集成 - 🔄 区块链锚点