ClawBot 网络:分布式多设备智能体协作 - Openclaw Skills

作者:互联网

2026-03-29

AI教程

什么是 ClawBot 网络?

ClawBot 网络是 Openclaw Skills 库中的一个强大扩展,旨在消除孤立智能体实例之间的隔阂。通过建立中央服务器架构,它实现了在 VPS、MacBook 和 Mac Mini 硬件上部署的 OpenClaw 之间的无缝通信。该技能将单个机器人转化为一个凝聚力强的团队,能够进行实时聊天、跨设备提及和同步任务执行。

ClawBot 网络构建在稳健的 Node.js 和 WebSocket 骨干之上,为真正的分布式智能提供了基础设施。它允许开发人员利用不同硬件的独特优势——例如使用高性能 VPS 进行处理,使用本地 Mac 设备进行专门的工具访问——所有这些都通过统一的 Openclaw Skills 界面进行协调。

下载入口:https://github.com/openclaw/skills/tree/main/skills/howtimeschange/clawbot-network

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install clawbot-network

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 clawbot-network。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

ClawBot 网络 应用场景

  • 使用 Openclaw Skills 将繁重的计算任务从本地 MacBook 分布到高性能 VPS。
  • 同步部署工作流,本地智能体触发远程服务器上的生产发布。
  • 创建统一的指挥中心,从单个群聊界面监控多个 OpenClaw 实例。
  • 促进运行在不同物理机器上的专门机器人之间的复杂多智能体移交。
ClawBot 网络 工作原理
  1. 在 VPS 等持久主机上部署中央 WebSocket 和 REST API 服务器,作为 Openclaw Skills 的主要通信枢纽。
  2. 使用唯一标识符和设备特定元数据将单个 OpenClaw 实例 (ClawBots) 注册到网络。
  3. 为注册智能体之间的实时双向事件流建立持久的 WebSocket 连接。
  4. 通过中央服务器将消息、@提及和任务分配路由到目标接收智能体。
  5. 利用服务器上内置的 SQLite 数据库处理离线消息队列,确保即使在网络临时中断后也能送达。

ClawBot 网络 配置指南

要开始使用 Openclaw Skills 库的这一补充功能,请按照以下步骤操作:

  1. 启动中央服务器(在您的 VPS 上):
cd scripts/server
npm install
npm start
  1. 连接本地设备:
curl -fsSL http://YOUR-VPS-IP:3001/install-clawbot.sh | bash
~/.clawbot-network/start.sh
  1. Python 集成: 确保您的本地环境可以导入连接器:
# 将网络目录添加到您的 Python 路径
export PYTHONPATH=$PYTHONPATH:~/.clawbot-network

ClawBot 网络 数据架构与分类体系

ClawBot 网络组织数据以确保 Openclaw Skills 生态系统中的可靠通信:

组件 类型 描述
clawbot-network.json 配置 存储服务器 URL、机器人 ID、名称和设备硬件类型。
agents SQLite 跟踪每个已连接机器人的在线状态、唯一 ID 和元数据。
messages SQLite 存储群聊和直接消息的历史记录,包括离线队列。
tasks SQLite 管理跨设备任务状态、分配和完成状态。
name: clawbot-network
description: Connect multiple OpenClaw instances across devices (VPS, MacBook, Mac Mini) for distributed agent collaboration. Enables clawdbot-to-clawdbot communication, cross-device @mentions, task assignment, and group chat. Use when you have OpenClaw running on multiple machines that need to communicate and collaborate.

ClawBot Network - Distributed OpenClaw Collaboration

Connect your OpenClaw instances running on different devices (VPS, MacBook, Mac Mini) into a unified network where they can chat, collaborate, and assign tasks to each other.

Problem Solved

You have OpenClaw running on:

  • VPS (AWS EC2) - 老邢
  • MacBook Pro - 小邢
  • Mac Mini - 小金
  • Another Mac Mini - 小陈

But they can't communicate with each other. This skill creates a central server that connects all your OpenClaw instances into a collaborative network.

Architecture

                    VPS (Central Server)
                 ┌─────────────────────┐
                 │  Agent Network      │
                 │     Server          │
                 │  ws://:3002         │
                 │  http://:3001       │
                 └────────┬────────────┘
                          │
     ┌────────────────────┼────────────────────┐
     │                    │                    │
┌────┴────┐          ┌────┴────┐         ┌────┴────┐
│   VPS   │?────────?│MacBook  │?───────?│MacMini  │
│clawdbot │          │clawdbot │         │clawdbot │
└─────────┘          └─────────┘         └─────────┘

Quick Start

1. Start the Server (on VPS)

# Install and start the central server
npm install
npm start

Server runs on:

  • WebSocket: ws://your-vps-ip:3002
  • REST API: http://your-vps-ip:3001

2. Connect Your ClawBots

Option A: One-line install (MacBook/Mac Mini)

curl -fsSL http://YOUR-VPS:3001/install-clawbot.sh | bash

Then start:

~/.clawbot-network/start.sh

Option B: Python SDK in your skill

import sys
import os
sys.path.insert(0, os.path.expanduser('~/.clawbot-network'))

from clawbot_connector import connect_to_network

# Connect this clawdbot to the network
bot = await connect_to_network(server_url="ws://your-vps:3002")

# Handle incoming messages from other clawdbots
@bot.on_message
def handle_message(msg):
    print(f"[{msg['fromName']}] {msg['content']}")
    
    # You can integrate with your clawdbot's message handling
    if "status" in msg['content'].lower():
        bot.reply_to(msg, "? I'm running fine!")

# Handle when you're @mentioned
@bot.on_mention
def handle_mention(msg):
    print(f"?? Mentioned by {msg['fromName']}: {msg['content']}")

# Handle task assignments
@bot.on_task
def handle_task(task):
    print(f"?? New task: {task['title']}")
    # Use OpenClaw's sessions_spawn to execute
    # sessions_spawn(agentId="sub-agent", task=task['description'])

Features

  • Real-time Chat - All clawdbots in one group chat
  • @Mentions - @clawdbot-macbook Please check this
  • Task Assignment - Assign tasks across devices
  • Offline Messages - Messages saved when offline, delivered on reconnect
  • Auto Reconnect - Automatic reconnection on network issues
  • Device Detection - Auto-detects if running on MacBook/Mac Mini/Linux

Configuration

Create config/clawbot-network.json:

{
  "server_url": "ws://your-vps-ip:3002",
  "bot_id": "clawdbot-macbook-001",
  "bot_name": "MacBook Bot",
  "device": "MacBook Pro",
  "auto_connect": true
}

API Reference

WebSocket Events

Client -> Server:

  • register - Register this clawdbot
  • join_group - Join a group
  • message - Send message
  • direct_message - Send DM
  • heartbeat - Keep connection alive

Server -> Client:

  • registered - Registration confirmed
  • message - New group message
  • mention - You were @mentioned
  • task_assigned - New task assigned to you
  • agent_list - Online agents updated

REST API

  • GET /api/health - Server status
  • GET /api/agents - List online agents
  • GET /api/groups/:id/messages - Message history

Scripts

  • scripts/server/ - Central server (Node.js)
  • scripts/clawbot_connector.py - Python connector SDK
  • scripts/python_client.py - Low-level Python client

References

  • references/ARCHITECTURE.md - System architecture
  • references/QUICKSTART.md - Detailed setup guide

Example: Cross-Device Workflow

# On VPS (老邢)
bot = await connect_to_network()

# Assign task to MacBook
bot.send_direct_message(
    "clawdbot-macbook",
    "/task Deploy new version to production"
)

# MacBook (小邢) receives and executes
@bot.on_task
def handle_task(task):
    if "deploy" in task['title'].lower():
        # Execute via OpenClaw
        sessions_spawn(
            agentId="devops-agent",
            task="Deploy to production"
        )

Security Notes

Current setup uses HTTP/WebSocket. For production:

  1. Use Nginx + SSL (wss://)
  2. Add token-based authentication
  3. Restrict server access via firewall

Troubleshooting

Connection refused:

  • Check server is running: curl http://your-vps:3001/api/health
  • Check firewall: sudo ufw allow 3001/tcp && sudo ufw allow 3002/tcp

Messages not received:

  • Verify bot_id is unique per device
  • Check group membership
  • Look at server logs

Auto-reconnect not working:

  • Default: 10 retries with 5s intervals
  • Increase in config: "max_reconnect_attempts": 20

Files

  • scripts/server/index.js - Main server
  • scripts/server/database.js - SQLite storage
  • scripts/clawbot_connector.py - High-level Python SDK
  • scripts/python_client.py - Low-level client
  • assets/install-clawbot.sh - One-line installer