{"id":34612832,"url":"https://github.com/agent-network-protocol/octopus","last_synced_at":"2025-12-24T14:17:46.610Z","repository":{"id":301282882,"uuid":"1007743509","full_name":"agent-network-protocol/octopus","owner":"agent-network-protocol","description":"A Open Source Personal Agent","archived":false,"fork":false,"pushed_at":"2025-08-14T05:18:15.000Z","size":1003,"stargazers_count":1,"open_issues_count":1,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-14T07:15:43.976Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agent-network-protocol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-24T13:12:00.000Z","updated_at":"2025-08-14T05:18:19.000Z","dependencies_parsed_at":"2025-07-17T17:29:11.081Z","dependency_job_id":"3547d609-59e4-477d-b9f1-59a582cf7b77","html_url":"https://github.com/agent-network-protocol/octopus","commit_stats":null,"previous_names":["agent-network-protocol/octopus"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/agent-network-protocol/octopus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-network-protocol%2Foctopus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-network-protocol%2Foctopus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-network-protocol%2Foctopus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-network-protocol%2Foctopus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agent-network-protocol","download_url":"https://codeload.github.com/agent-network-protocol/octopus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-network-protocol%2Foctopus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28003727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-24T14:17:45.960Z","updated_at":"2025-12-24T14:17:46.603Z","avatar_url":"https://github.com/agent-network-protocol.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🐙 Octopus Multi-Agent AI System\n\nA modern, distributed multi-agent AI system with ANP (Agent Network Protocol) support.\n\n## ✨ 特性\n\n- 🤖 **多智能体架构**: 基于装饰符的智能体注册和发现机制\n- 🌐 **分布式通信**: 支持 ANP 协议的跨节点智能体通信\n- 🎯 **任务协调**: 自然语言任务分析、分解和智能分发\n- ⚡ **高性能**: 基于 FastAPI 的异步处理框架\n- 🛠️ **开发友好**: 丰富的 CLI 工具和配置选项\n- 🔐 **安全认证**: 支持 DID 去中心化身份认证\n\n## 环境配置\n\n### 1. 安装依赖\n\n本项目使用 [uv](https://github.com/astral-sh/uv) 作为包管理工具：\n\n```bash\n# 安装 uv（如果还没有安装）\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n\n# 同步项目依赖\nuv sync\n```\n\n### 2. 环境变量配置\n\n1. 复制环境变量模板文件：\n   ```bash\n   cp .env.example .env\n   ```\n\n2. 编辑 `.env` 文件，填入您的实际配置：\n   ```bash\n   # OpenAI Configuration\n   OPENAI_API_KEY=your_actual_openai_api_key\n   OPENAI_MODEL=openai/gpt-4o\n\n   # Application Configuration\n   PORT=9527\n   HOST=0.0.0.0\n   LOG_LEVEL=INFO\n\n   # ANP Configuration\n   ANP_SDK_ENABLED=true\n   ANP_GATEWAY_WS_URL=wss://anpproxy.com/ws\n   ANP_GATEWAY_HTTP_URL=www.anpproxy.com\n   ANP__RECEIVER__LOCAL_PORT=8001\n   ```\n\n**重要提示：** `.env` 文件包含敏感信息，已被 `.gitignore` 忽略，不会被提交到版本控制系统。\n\n## 🚀 快速开始\n\n### 1. 基础启动\n\n```bash\n# 默认启动（端口 9527）\nuv run python -m octopus.octopus\n\n# 查看所有选项\nuv run python -m octopus.octopus --help\n\n# 检查版本\nuv run python -m octopus.octopus --version\n```\n\n### 2. CLI 选项\n\n```bash\n# 自定义端口\nuv run python -m octopus.octopus --port 9529\n\n# 调试模式\nuv run python -m octopus.octopus --debug --log-level DEBUG\n\n# 禁用 ANP（单机模式）\nuv run python -m octopus.octopus --no-anp\n\n# 使用自定义配置文件\nuv run python -m octopus.octopus --config .env.production\n```\n\n### 3. 多实例部署\n\n启动两个 Octopus 实例进行 ANP 通信：\n\n```bash\n# 终端 1: 启动 ANP-Proxy（如需本地测试）\ncd /path/to/anp-proxy\nuv run python -m anp_proxy\n\n# 终端 2: 启动 Octopus-A\nuv run python -m octopus.octopus --port 9527 --anp-gateway wss://anpproxy.com/ws\n\n# 终端 3: 启动 Octopus-B\nuv run python -m octopus.octopus --port 9529 --anp-gateway wss://anpproxy.com/ws\n```\n\n### 4. 访问 API\n\n服务器启动后，可以访问（默认端口 9527）：\n- 🏠 主页面：http://localhost:9527/\n- 💚 健康检查：http://localhost:9527/health\n- ℹ️ 应用信息：http://localhost:9527/v1/info\n- 🤖 智能体描述：http://localhost:9527/ad.json\n- 📡 ANP 状态：http://localhost:9527/anp/status\n\n*注意：如果修改了端口配置，请相应调整URL*\n\n## 📁 项目结构\n\n```\noctopus/\n├── octopus/                    # 主要代码包\n│   ├── agents/                 # 智能体相关代码\n│   │   ├── base_agent.py       # 基础智能体类\n│   │   ├── message/            # 消息处理智能体\n│   │   └── text_processor_agent.py  # 文本处理智能体\n│   ├── core/                   # 核心功能模块\n│   │   └── receiver/           # ANP 接收器\n│   ├── router/                 # 路由管理\n│   │   └── agents_router.py    # 智能体路由器\n│   ├── api/                    # API 接口\n│   │   ├── chat_router.py      # 聊天接口\n│   │   └── ad_router.py        # 智能体描述接口\n│   ├── config/                 # 配置管理\n│   │   └── settings.py         # 应用设置（支持 CLI 覆盖）\n│   ├── utils/                  # 工具类\n│   │   └── log_base.py         # 增强日志系统\n│   ├── master_agent.py         # 主智能体协调器\n│   └── octopus.py              # CLI 和 FastAPI 应用入口\n├── .env.example                # 环境变量模板\n├── pyproject.toml              # 项目配置（包含 Click CLI）\n├── docs/                       # 项目文档\n│   ├── environment_setup.md    # 环境配置指南\n│   └── azure_openai_config.md  # Azure OpenAI 配置\n└── README.md                   # 项目说明\n```\n\n## 🛠️ 开发指南\n\n### 智能体开发\n\n创建自定义智能体的步骤：\n\n1. 继承 `BaseAgent` 类\n2. 使用 `@register_agent` 装饰器注册智能体\n3. 使用 `@agent_method` 装饰器注册方法\n\n示例：\n```python\nfrom octopus.agents.base_agent import BaseAgent\nfrom octopus.router.agents_router import register_agent, agent_method\n\n@register_agent(name=\"my_agent\", description=\"My custom agent\")\nclass MyAgent(BaseAgent):\n    @agent_method(description=\"Process text\")\n    async def process_text(self, text: str) -\u003e str:\n        return f\"Processed: {text}\"\n```\n\n### 日志系统\n\n- 📝 **增强日志**: 彩色输出，位置信息，文件记录\n- 📂 **日志文件**: `~/Library/Logs/octopus/octopus.log`（macOS）\n- 🎚️ **日志级别**: 通过 `--log-level` 或环境变量控制\n\n### 配置系统\n\n支持多层级配置优先级：\n1. **CLI 参数**（最高优先级）\n2. **环境变量**\n3. **配置文件**（最低优先级）\n\n## 🧪 测试和开发\n\n### 运行测试\n\n```bash\n# 运行所有测试\nuv run pytest\n\n# 运行特定测试类别\nuv run pytest -m unit        # 单元测试\nuv run pytest -m integration # 集成测试\nuv run pytest -m \"not slow\"  # 跳过慢速测试\n```\n\n### 代码质量\n\n```bash\n# 格式化代码\nuv run black octopus/\n\n# 代码检查\nuv run flake8 octopus/\n\n# 类型检查\nuv run mypy octopus/\n```\n\n### ANP 集成测试\n\n系统包含 ANP 协议的集成测试功能：\n\n```bash\n# 手动运行 ANP 爬虫测试\nuv run python -m octopus.test_scripts.test_anp_crawler\n\n# 测试 ANP 功能（需要 anp-proxy 运行）\nuv run python -m octopus.test_scripts.test_anp_functionality\n```\n\n## 🔧 技术栈\n\n- **Python**: 3.11+\n- **Web 框架**: FastAPI + Uvicorn\n- **CLI 框架**: Click\n- **配置管理**: Pydantic Settings\n- **包管理**: uv\n- **AI 集成**: OpenAI API\n- **协议支持**: ANP (Agent Network Protocol)\n- **身份认证**: DID (Decentralized Identity)\n\n## 📄 许可证\n\nMIT License - 详见 [LICENSE](LICENSE) 文件。\n\n## 🤝 贡献\n\n欢迎提交 Issue 和 Pull Request！\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagent-network-protocol%2Foctopus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagent-network-protocol%2Foctopus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagent-network-protocol%2Foctopus/lists"}