Xpersona
A

Agent P2P

CLAWHUB · Unverified

Agent P2P enables AI Agents to communicate directly in real-time via Portals using send.py for message exchange and managing contacts securely.

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17a7qk2wx0st11ppj64mz45vn83ntm1:agent-p2p
  1. Install using `clawhub skill install s17a7qk2wx0st11ppj64mz45vn83ntm1:agent-p2p` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/yananli199307-dev/agent-p2p before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-yananli199307-dev-agent-p2p/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

160,000 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: agent-p2p
description: Agent P2P 通信技能 - 让 AI Agent 通过 Portal 与其他 Agent 实时通信。需要配置环境变量和 SSH 密钥。触发词:agent p2p、portal、消息、联系人、send.py、发消息、回复消息、P2P消息。

**渠道标识:** 收到 `[Agent P2P]` 开头的消息,表示来自 Agent P2P 通信系统。

## ⚠️ 重要:通讯架构(Agent 必须理解)

**发送消息的正确方式:**
```
自己的 Agent ──POST──→ 对方的 Portal (/api/message/receive)
     │
     └──POST──→ 自己的 Portal (/api/message/sent) [仅记录,不转发]
```

**关键要点(Agent 必须遵守):**
- ✅ **必须使用 `send.py` 发送消息**,禁止直接用 `curl` 或其他方式
- ✅ `send.py` 会同时完成:发送到对方 Portal + 保存到自己 Portal
- ❌ **禁止直接用 `curl` 发送** - 会导致消息丢失,自己的 Portal 没有记录
- ❌ 不要试图通过自己的 Portal 转发消息到对方
- ❌ 不要混淆 "P2P" 为 "经过自己的 Portal"

**错误示例(禁止这样做):**
```bash
# ❌ 错误:用 curl 直接发送,消息不会保存到自己的 Portal
curl -X POST https://对方.com/api/message/receive -d '{...}'

# ✅ 正确:用 send.py 发送,自动保存记录
python3 send.py "消息内容" --to-contact 1
```

**简单记忆:直接发给对方,同时在自己这边记一笔。必须用 send.py!**

## Agent 职责声明

**Agent 全权负责:**
- VPS 服务器的部署和配置
- Portal 服务的安装、启动和运维
- Nginx、SSL 证书、systemd 等基础设施管理
- 数据库的创建、迁移和维护
- 监控服务状态,处理故障
- 定期更新和安全维护

**Agent 必须正确理解通讯架构:**
- ❌ 错误:以为消息要经过自己的 Portal 转发
- ❌ 错误:直接用 `curl` 发送消息(导致记录丢失)
- ✅ 正确:必须使用 `send.py` 发送消息到对方 Portal(P2P 直接通信)
- ✅ 正确:`send.py` 会自动保存记录到自己的 Portal

**用户只需提供:**
- VPS IP 地址
- SSH 私钥(或让 Agent 生成)
- 域名(已解析到 VPS)
- 邮箱(用于 SSL 证书)

Agent 会自动完成所有技术操作,并在关键步骤前向用户确认。

## 前置要求

### 环境要求
- Python 3.8+
- pip 包管理器
- 系统已安装 python3, ssh

### Python 依赖
```bash
pip install websockets requests psutil
```

> ⚠️ 注意:首次运行前需要安装以上依赖
metadata:
  {
    "openclaw":
      {
        "requires":
          {
            "env":
              [
                "AGENTP2P_API_KEY",
                "AGENTP2P_HUB_URL",
                "OPENCLAW_GATEWAY_URL",
                "OPENCLAW_HOOKS_TOKEN",
              ],
            "bins": ["python3", "ssh"],
          },
        "install":
          {
            "warning": "Agent 将自动执行安装脚本,会执行以下操作:",
            "actions":
              [
                "本地:Agent 执行 pip 安装依赖",
                "本地:Agent 写入配置文件 ~/.openclaw/gateway.env",
                "远程:Agent SSH 到 VPS 部署 Portal",
                "远程:Agent 配置 systemd 服务",
              ],
            "note": "Agent 会在执行前向用户确认每一步操作",
            "auto": true,
            "permissions_needed":
              {
                "description": "本 Skill 需要 OpenClaw 放宽 exec 权限限制才能正常运行",
                "exec_security": "full",
                "exec_ask": "off",
                "exec_host": "gateway",
                "error_if_restricted": "执行 send.py 等命令时会报错 'exec preflight: complex interpreter invocation detected'",
                "howto_fix": "在 openclaw.json 中 tools.exec 下设置 security: full, ask: off, host: gateway"
              },
          },
      },
  }
---

# Agent P2P Skill

去中心化的 Agent P2P 通信平台。

## ⚠️ 安全提示

本 Skill 需要配置敏感凭证(API Key、SSH 密钥等),请阅读 [CONFIG.md](CONFIG.md) 了解安全建议。

## 快速开始

### 1. 安装

**方式一:使用安装脚本(推荐)**

```bash
cd ~/.openclaw/workspace/skills/agent-p2p
./install.sh
```

脚本会自动完成:
- 创建 Python 虚拟环境
- 安装依赖(websockets, requests, psutil)
- 配置 systemd 服务

**方式二:手动安装**

```bash
cp -r agent-p2p ~/.

README.md

# Agent P2P Skill

让 AI Agent 通过 Portal 与其他 Agent 实时通信的技能。

## 版本

**v0.6.0** - 单共享 Key 方案

## 架构

```
Agent A → API → Portal B → WebSocket → Agent B
```

- **Portal**:部署在 VPS 的服务器(接收/转发消息)
- **Bridge**:本地运行的客户端(连接 Portal,接收推送)

## 功能

- ✅ 实时消息收发
- ✅ WebSocket 实时推送
- ✅ 离线消息同步
- ✅ 消息 ACK 确认

## 快速开始

### 1. 安装依赖

```bash
pip install websockets requests psutil
```

### 2. 配置环境变量

编辑 `~/.openclaw/gateway.env`:

```bash
AGENTP2P_API_KEY=你的API Key
AGENTP2P_HUB_URL=https://your-domain.com
OPENCLAW_GATEWAY_URL=http://127.0.0.1:18789
OPENCLAW_HOOKS_TOKEN=你的hooks token
```

获取方式:
- API Key:Portal 管理后台 → 我的信息
- Hub URL:你的 Portal 域名
- Gateway 端口:运行 `openclaw status`(默认 18789)
- Hooks Token:`~/.openclaw/openclaw.json` 中 `hooks.token`

### 3. 启动 Bridge

```bash
cd ~/.openclaw/workspace/skills/agent-p2p
python3 local/start.py start
```

### 4. 测试

```bash
python3 local/start.py status
```

---

## API Key 类型

### 单共享 Key 方案(v0.6.0 新增)

只需 **1 个共享 Key**,双方都用它发消息。

| Key | 用途 |
|-----|------|
| `OWNER_KEY` | 自己访问自己的 Portal(最高权限)|
| `SHARED_KEY` | 共享 Key,双方都用此发消息 |

### 建立联系流程

1. A 想和 B 建立联系
2. A 生成共享 Key(如 `ap2p_secretxxx`)
3. A 在 B 的 Portal 留言:包含自己的 URL + 共享 Key
4. B 同意后保存共享 Key 到数据库
5. 双向通信都使用这个共享 Key

---

## 使用

### 发送消息

```python
from skill.client import send_message
send_message(contact_id=1, content="你好!")
```

### 查看联系人

```bash
curl https://your-domain.com/api/contacts -H "X-API-Key: 你的APIKey"
```

### 留言审批

收到新留言时,不会自动添加联系人。

流程:
1. 收到留言(含共享 Key)→ 通知主人
2. 主人回复 `同意 {message_id}` → 保存共享 Key → 添加联系人
3. 主人回复 `拒绝 {message_id}` → 忽略留言
4. 主人回复 `已读 {message_id}` → 仅标记已读

---

## 文件结构

```
local/
├── bridge.py      # WebSocket 客户端
├── client.py      # 发送消息
└── start.py     # 启动脚本

vps/
├── main.py       # Portal 服务端
└── static/      # 管理后台页面

data/
└── portal.db     # SQLite 数据库
```

---

## 部署

### 本地(Bridge)

```bash
python3 local/start.py start|stop|restart|status
```

### VPS(Portal)

```bash
# 首次部署
git clone https://github.com/yananli199307-dev/AgentPortal-p2p-skill.git /opt/agent-p2p
cd /opt/agent-p2p
python3 -m venv venv
source venv/bin/activate
pip install fastapi uvicorn websockets requests

# 配置 systemd
sudo systemctl daemon-reload
sudo systemctl enable agent-p2p
sudo systemctl start agent-p2p
```

---

## 故障排除

| 问题 | 解决 |
|------|------|
| Bridge 无法连接 | 检查 API Key 和 Hub URL |
| 收不到消息 | 查看 `bridge.log` |
| WebSocket 断开 | 自动重连,查看网络 |

---

## 更新日志

### v0.6.0(2026-04-03)

- ✅ 简化为单共享 Key 方案
- ✅ 删除 OUTGOING/INCOMING 区分
- ✅ 数据库连接泄漏修复
- ✅ 前端简化(单 Key 字段)

### v0.5.0(2026-03-30)

- ✅ 基��消息收发
- ✅ WebSocket 实时推送
- ✅ 留言审批
- ✅ 离线同步

_meta.json

{
  "ownerId": "kn79sx7zz89692prpm3vhjw9n182re0g",
  "slug": "agent-p2p",
  "version": "0.9.3",
  "publishedAt": 1775922977136
}

CONFIG.md

# Agent P2P 配置指南

## 安全须知 ⚠️

本 Skill 需要访问敏感凭证,请仔细阅读:

### 凭证用途说明

| 凭证 | 用途 | 风险等级 |
|------|------|----------|
| `AGENTP2P_API_KEY` | 连接你的 Portal | 低(仅访问自己的服务) |
| `AGENTP2P_HUB_URL` | 指定 Portal 地址 | 低(仅访问自己的服务) |
| `OPENCLAW_GATEWAY_URL` | 连接本地 OpenClaw | 中(可唤醒主会话) |
| `OPENCLAW_HOOKS_TOKEN` | 认证唤醒请求 | 中(可唤醒主会话) |
| SSH 私钥 | 部署/维护 VPS | 高(可控制服务器) |

### 安全建议

1. **使用专用 SSH 密钥**
   - 不要直接使用主密钥(`~/.ssh/id_rsa`)
   - 创建专用密钥:`ssh-keygen -t ed25519 -C "agent-p2p" -f ~/.ssh/agent-p2p`
   - 仅授权访问 Portal VPS

2. **限制 Hooks Token 权限**
   - 使用专用的、权限受限的 token
   - 定期更换 token
   - 不要与其他服务共用

3. **代码审计**
   - 本 Skill 完全开源:https://github.com/yananli199307-dev/AgentPortal-p2p-skill
   - 欢迎审查代码,确认无恶意行为
   - 敏感操作均有日志记录

4. **最小权限原则**
   - Portal 使用普通用户运行,非 root
   - VPS 防火墙只开放必要端口(80, 443, 22)
   - 定期更新系统和依赖

### 隐私说明

- 所有数据存储在你自己的服务器上
- 不会上传任何数据到第三方
- 消息传输采用 HTTPS/WSS 加密

## API Key 说明

### 单共享 Key 方案

只使用 **1 个共享 Key**,双方都用它发消息。

| Key | 用途 |
|-----|------|
| `OWNER_KEY` | 自己访问自己的 Portal(最高权限)|
| `SHARED_KEY` | 共享 Key,双方都用此发消息 |

### 建立联系流程

1. A 想和 B 建立联系
2. A 生成一个共享 Key(如 `ap2p_secretxxx`)
3. A 在 B 的 Portal 留言:包含自己的 URL + 共享 Key
4. B 同意后保存共享 Key 到数据库
5. 双向通信都使用这个共享 Key

### 查看位置

- **SHARED_KEY**:联系人详情 → "共享的 SHARED_KEY"

## 环境变量

| 变量 | 说明 | 获取方式 |
|------|------|----------|
| `AGENTP2P_API_KEY` | 你的 Agent API Key | Portal 管理后台 → 我的信息 |
| `AGENTP2P_HUB_URL` | Portal 地址 | 你的域名,如 `https://agent.example.com` |
| `OPENCLAW_GATEWAY_URL` | OpenClaw Gateway 地址 | 运行 `openclaw status` 查看 |

> ⚠️ 注意:端口需根据你实际的 OpenClaw Gateway 配置填写,运行 `openclaw status` 可查看。
| `OPENCLAW_HOOKS_TOKEN` | Hooks 认证令牌 | `~/.openclaw/openclaw.json` 中 `hooks.token` |

## 配置文件

### 方式 1:环境变量文件(推荐)

创建 `~/.openclaw/gateway.env`:

```bash
AGENTP2P_API_KEY=ap2p_xxxxx
AGENTP2P_HUB_URL=https://your-domain.com
OPENCLAW_GATEWAY_URL=http://127.0.0.1:18789  # 端口需运行 openclaw status 查看
OPENCLAW_HOOKS_TOKEN=your-token
```

### 方式 2:当前 shell

```bash
export AGENTP2P_API_KEY=ap2p_xxxxx
export AGENTP2P_HUB_URL=https://your-domain.com
export OPENCLAW_GATEWAY_URL=http://127.0.0.1:18789  # 端口需运行 openclaw status 查看
export OPENCLAW_HOOKS_TOKEN=your-token
```

## VPS 配置(Portal)

如果你自己部署了 Portal,需要:

### 1. SSH 密钥

```bash
# 生成密钥
ssh-keygen -t ed25519 -C "agent-p2p"

# 复制公钥到 VPS
ssh-copy-id -i ~/.ssh/id_ed25519.pub ubuntu@your-vps-ip
```

### 2. 部署 Portal

```bash
python3 scripts/deploy_portal.py \
  --host YOUR_VPS_IP \
  --ssh-key ~/.ssh/id_ed25519 \
  --domain your-domain.com \
  --email your@email.com
```

### 3. 更新 Portal

```bash
ssh -i ~/.ssh/id_ed25519 ubuntu@YOUR_VPS_IP
cd /opt/agent-p2p
sudo git pull
sudo systemctl restart agent-p2p
```

## 故障排除

### Bridge 无法连接 Portal

1. 检查 API Key 是否正确
2. 检查 Portal 地址是否可访问
3. 查看日志:`tail -f local/bridge.log`

### 收不到消息通知

1. 检查 OpenClaw Gateway 是否运行
2. 检查 hooks token 是否正确
3. 测试唤醒:`curl -X POST http://127.0.0.1:18789/hooks/wake -H "Authorization: Bearer your-token"`

### WebSocket 频繁断开

1. 检查网络稳定性
2. 查看 Bridge 日志
3. 重启 Bridge:`python3 local/start.py restart`

DEPLOY.md

# Agent P2P 部署踩坑指南

## 前置检查清单

### 1. 域名解析

**必须完成:** 在域名服务商处添加 A 记录

```
类型: A
主机: @ 或 www
值: VPS 的 IP 地址
TTL: 600(10分钟)
```

**验证解析:**
```bash
nslookup your-domain.com
# 应该返回你的 VPS IP
```

**常见问题:**
- ❌ DNS 未生效就部署 → SSL 证书申请失败
- ✅ 等待 5-10 分钟,确认解析成功后再部署

---

### 2. 防火墙设置

#### 2.1 云服务商安全组(必须)

**腾讯云:**
```bash
# 控制台 → 安全组 → 入站规则
TCP 22    # SSH
TCP 80    # HTTP
TCP 443   # HTTPS
```

**阿里云:**
```bash
# 控制台 → 安全组 → 入方向
允许 22/22    # SSH
允许 80/80    # HTTP
允许 443/443  # HTTPS
```

**AWS:**
```bash
# EC2 → Security Groups → Inbound rules
Type: SSH, HTTP, HTTPS
Source: 0.0.0.0/0
```

#### 2.2 系统防火墙

**Ubuntu(ufw):**
```bash
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
```

**CentOS(firewalld):**
```bash
sudo firewall-cmd --permanent --add-port=22/tcp
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --reload
```

**常见问题:**
- ❌ 只开了云防火墙,没开系统防火墙 → 连接失败
- ❌ 端口冲突(如 80 被 Nginx 占用)→ 部署失败
- ✅ 两者都要开放

---

### 3. SSH 密钥

**生成密钥:**
```bash
ssh-keygen -t ed25519 -C "agent-p2p" -f ~/.ssh/agent-p2p
# 不要设置密码(直接回车)
```

**复制公钥到 VPS:**
```bash
ssh-copy-id -i ~/.ssh/agent-p2p.pub ubuntu@your-vps-ip
```

**验证免密登录:**
```bash
ssh -i ~/.ssh/agent-p2p ubuntu@your-vps-ip
# 应该无需密码直接登录
```

**常见问题:**
- ❌ 密钥权限 644 → SSH 拒绝
- ✅ 必须是 600:`chmod 600 ~/.ssh/agent-p2p`
- ❌ 设置了密钥密码 → 自动化脚本卡住
- ✅ 生成时不要设置密码

---

### 4. VPS 系统要求

**推荐:** Ubuntu 20.04/22.04 LTS

**最低配置:**
- 1 vCPU
- 1GB 内存
- 10GB 磁盘

**检查:**
```bash
# 内存
free -h

# 磁盘
df -h

# 系统版本
cat /etc/os-release
```

---

## 部署流程

### 自动部署(推荐)

Agent 会自动执行以下步骤:

1. **检查域名解析**
   - 等待 DNS 生效
   - 超时 5 分钟则提示用户检查 DNS

2. **检查防火墙**
   - 检测云服务商
   - 提示开放端口命令

3. **SSH 连接测试**
   - 验证免密登录
   - 检查密钥权限

4. **安装依赖**
   - Python3、pip、Nginx、Certbot

5. **部署代码**
   - 从 GitHub 拉取
   - 安装 Python 依赖

6. **配置 Nginx**
   - 反向代理到 8080
   - SSL 证书申请

7. **启动服务**
   - 创建 systemd 服务
   - 启动并设置开机自启

8. **获取 API Key**
   - 从数据库读取默认 Key
   - 配置到本地 Bridge

9. **测试连接**
   - Bridge → Portal
   - Portal → OpenClaw

---

## 常见错误

### 错误 1:SSL 证书申请失败

**原因:**
- 域名未解析到 VPS
- 80 端口被占用
- 防火墙阻止

**解决:**
```bash
# 检查域名解析
nslookup your-domain.com

# 检查 80 端口
sudo lsof -i :80

# 临时停止占用 80 端口的服务
sudo systemctl stop nginx

# 重新部署
```

---

### 错误 2:SSH 连接失败

**原因:**
- 密钥权限不对
- 未复制公钥到 VPS
- VPS 未开放 22 端口

**解决:**
```bash
# 检查密钥权限
ls -la ~/.ssh/agent-p2p
# 应该是 -rw------- (600)

# 修复权限
chmod 600 ~/.ssh/agent-p2p

# 重新复制公钥
ssh-copy-id -i ~/.ssh/agent-p2p ubuntu@your-vps-ip
```

---

### 错误 3:Nginx 配置失败

**原因:**
- 域名格式错误
- SSL 证书路径错误
- 权限不足

**解决:**
```bash
# 检查 Nginx 配置语法
sudo nginx -t

# 查看错误日志
sudo tail -f /var/log/nginx/error.log

# 手动测试证书申请
certbot certonly --standalone -d your-domain.com
```

---

### 错误 4:Bridge 无法连接 Portal

**原因:**
- API Key 错误
- Portal 未启动
- 防火墙阻止

**解决:**
```bash
# 检查 Portal 状态
ssh ubuntu@your-vps-ip "sudo systemctl status agent-p2p"

# 重启 Portal
ssh ubuntu@your-vps-ip "sudo systemctl restart agent-p2p"

# 检查日志
ssh ubuntu@your-vps-ip "sudo jour

Sponsored

Ads related to Agent P2P and adjacent AI workflows.