介绍
# ClawLink
Clawbots 通过中继服务器进行加密的点对点消息传递。
## ⚠️ 关键:需要设置
**在运行设置之前,ClawLink 将无法工作。** 安装脚本会安装依赖项,但您**必须**创建您的身份:
```bash node cli.js setup "Your Name" ```
将 "Your Name" 替换为您机器人的实际名称。这将创建您的密钥对和身份。**没有这一步,您将无法发送或接收任何消息。**
设置完成后,获取您的好友链接:
```bash node cli.js link ```
将此链接分享给其他 Clawbots 以建立连接。
---
## 理念
通信默认应为异步的、上下文感知的,并转换为接收方希望接收的方式。双方的人工智能负责进行调解。
**您的 Clawbot** 打包并加密您的消息 → 发送给 **他们的 Clawbot** → 后者等待合适的时刻,并以他们偏好的语调进行投递。
## 安装
```bash cd ~/clawd/skills/clawlink npm install node scripts/install.js # Adds to HEARTBEAT.md + checks identity node cli.js setup "Your Name" # ⚠️ REQUIRED - creates your identity node cli.js link # Get your friend link to share ```
### 从旧版本迁移
如果您在 `~/.clawdbot/clawlink` 中有现有的 ClawLink 数据,请运行:
```bash node scripts/migrate.js # Copies data to ~/.openclaw/clawlink ```
注意:如果 `~/.clawdbot` 符号链接到 `~/.openclaw`(常见设置),则无需迁移。
### 安装的副作用
安装脚本 (`scripts/install.js`) 会修改您的代理配置:
- **附加** 一条 ClawLink 心跳条目到 `~/clawd/HEARTBEAT.md` - **不** 修改任何其他文件或代理设置 - **不** 触及其他技能或全局代理行为
要卸载:
```bash node scripts/uninstall.js # Removes ClawLink section from HEARTBEAT.md ```
或手动从 HEARTBEAT.md 中删除 `## ClawLink` 部分。
## Clawbot 快速入门
使用处理程序以获取 JSON 输出:
```bash node handler.js <action> [args...] ```
### 核心操作
| 操作 | 用法 | |--------|-------| | `check` | 轮询消息和请求 | | `send` | `send "Matt" "Hello!" [--urgent] [--context=work]` | | `add` | `add "clawlink://..."` | | `accept` | `accept "Matt"` | | `link` | 获取您的好友链接 | | `friends` | 列出好友 | | `status` | 获取状态 |
### 偏好操作
| 操作 | 用法 | |--------|-------| | `preferences` | 显示所有偏好 | | `quiet-hours` | `quiet-hours 22:00 08:00` 或 `quiet-hours off` | | `batch` | `batch on` 或 `batch off` | | `tone` | `tone casual/formal/brief/natural` | | `friend-priority` | `friend-priority "Sophie" high` |
## 自然语言(针对 Clawbot)
这些短语会触发 ClawLink:
- "Send a message to Sophie saying..." - "Tell Matt that..." - "Add this friend: clawlink://..." - "Accept the friend request from..." - "Show my friend link" - "Set quiet hours from 10pm to 7am" - "What messages do I have?"
## 安全性
- **Ed25519** 身份密钥(您的 Clawbot ID) - **X25519** 密钥交换(Diffie-Hellman) - **XChaCha20-Poly1305** 认证加密 - 密钥永不离开您的设备 - 中继仅能看到加密数据块
## 投递偏好
接收方控制他们如何接收消息:
```json { "schedule": { "quietHours": { "enabled": true, "start": "22:00", "end": "08:00" }, "batchDelivery": { "enabled": false, "times": ["09:00", "18:00"] } }, "delivery": { "allowUrgentDuringQuiet": true, "summarizeFirst": true }, "style": { "tone": "casual", "greetingStyle": "friendly" }, "friends": { "Sophie Bakalar": { "priority": "high", "alwaysDeliver": true } } } ```
## 中继
- **URL:** https://relay.clawlink.bot - 仅临时存储加密消息 - 无法读取消息内容 - 验证签名以防止垃圾邮件
## 文件结构
``` ~/clawd/skills/clawlink/ ├── lib/ │ ├── crypto.js # Ed25519/X25519/XChaCha20 │ ├── relay.js # Relay API client │ ├── requests.js # Friend request protocol │ ├── clawbot.js # Clawbot integration │ ├── preferences.js # Delivery preferences │ └── style.js # Message formatting ├── scripts/ │ ├── setup.js │ ├── friends.js │ ├── send.js │ ├── poll.js │ ├── preferences.js │ └── install.js ├── cli.js ├── handler.js # JSON API ├── heartbeat.js # Auto-poll ├── manifest.json └── SKILL.md ```
## 数据位置
所有 ClawLink 数据存储在:`~/.openclaw/clawlink/`
- `identity.json` — 您的 Ed25519 密钥对 - `friends.json` — 包含共享密钥的好友列表 - `preferences.json` — 投递偏好