openclaw-bridge 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,51 +1,86 @@
1
1
  # openclaw-bridge
2
2
 
3
- Cross-gateway communication plugin for [OpenClaw](https://github.com/nicepkg/openclaw). Enables independent gateway instances to discover each other, exchange files, relay messages, and hand off conversations.
3
+ The all-in-one client plugin for [OpenClaw](https://github.com/nicepkg/openclaw) distributed gateway architecture. Provides cross-gateway communication, local process management, and a full CLI for managing your OpenClaw agents.
4
4
 
5
- ## Features
5
+ ## What's Included
6
6
 
7
- - **Agent Discovery** — Auto-register and discover online agents via heartbeat
8
- - **File Transfer** — Send files between agents (local or cross-machine via Hub)
9
- - **Message Relay** — Send messages to any agent through the Hub and get replies
10
- - **Session Handoff** — Transfer active conversations between agents seamlessly
11
- - **Superuser Tools** — Read/write files and restart remote gateways
12
- - **Auto-Config** — Automatically patches `openclaw.json` with recommended settings on first run
7
+ - **Cross-Gateway Communication** — Agent discovery, file transfer, message relay, and session handoff
8
+ - **Local Manager** — PM2-based process management with remote control via Hub
9
+ - **CLI Tools** — Setup, status, start/stop/restart, log viewing, backup, agent creation, diagnostics
10
+ - **Auto-Config** — Automatically patches missing settings on first run
13
11
 
14
- ## Prerequisites
12
+ ## Quick Start
15
13
 
16
- You need [openclaw-bridge-hub](https://www.npmjs.com/package/openclaw-bridge-hub) (v0.2.4+) running on a reachable server first:
14
+ ```bash
15
+ # 1. Install globally
16
+ npm install -g openclaw-bridge
17
+
18
+ # 2. Interactive setup (Hub URL, API key, manager password)
19
+ openclaw-bridge setup
20
+
21
+ # 3. Check your environment
22
+ openclaw-bridge doctor
23
+
24
+ # 4. Start all gateway instances
25
+ openclaw-bridge start
26
+
27
+ # 5. Verify everything is running
28
+ openclaw-bridge status
29
+ ```
30
+
31
+ **Prerequisites:** [openclaw-bridge-hub](https://www.npmjs.com/package/openclaw-bridge-hub) running on a server, PM2 installed globally (`npm install -g pm2`), Node.js 18+.
32
+
33
+ ## CLI Commands
34
+
35
+ | Command | Description |
36
+ |---------|-------------|
37
+ | `setup` | Interactive setup — configure Hub URL, API key, and manager password |
38
+ | `status` | Show PM2 process status and Hub connection |
39
+ | `start` | Find and start all openclaw instances via PM2 ecosystem |
40
+ | `stop` | Stop all openclaw instances |
41
+ | `restart [agent]` | Restart a specific agent or all |
42
+ | `logs [agent]` | View PM2 logs for an agent (last 100 lines) |
43
+ | `backup` | Create encrypted backup of openclaw-instances |
44
+ | `clean-sessions` | Remove old/deleted session files to free disk space |
45
+ | `add-agent` | Wizard to create a new agent instance |
46
+ | `doctor` | Diagnose environment issues (PM2, Node, ports, Hub) |
47
+
48
+ ### Adding a New Agent
17
49
 
18
50
  ```bash
19
- # On your server:
20
- npm install -g openclaw-bridge-hub
21
- openclaw-bridge-hub init # generates API key — save it!
22
- openclaw-bridge-hub start # starts on port 3080
23
- openclaw-bridge-hub install-service # auto-start on boot (Linux)
51
+ openclaw-bridge add-agent
24
52
  ```
25
53
 
26
- Save the generated API key you'll need it for the plugin config below.
54
+ The wizard prompts for agent name, ID, description, and AI model. It automatically:
55
+ - Assigns the next available port
56
+ - Creates the directory with `openclaw.json`, `run.sh`, `run.ps1`
57
+ - Updates `ecosystem.config.cjs`
27
58
 
28
- ## Installation
59
+ ### Backup
29
60
 
30
61
  ```bash
31
- openclaw plugins install openclaw-bridge
62
+ openclaw-bridge backup
32
63
  ```
33
64
 
34
- Or manually: place this plugin in a directory listed in `plugins.load.paths` of your `openclaw.json`.
65
+ Creates an encrypted tar.gz archive. Config files are encrypted with AES-256-CBC. Excludes node_modules, state, workspace, and logs.
66
+
67
+ ---
35
68
 
36
- ## Configuration
69
+ ## Plugin Configuration
37
70
 
38
- Add to `openclaw.json` under `plugins.entries` (replace the API key and server URL with your own):
71
+ The plugin is also loaded by each OpenClaw gateway instance for cross-agent communication. Add to `openclaw.json`:
39
72
 
40
73
  ```json
41
74
  {
42
75
  "plugins": {
43
76
  "entries": {
44
77
  "openclaw-bridge": {
78
+ "enabled": true,
45
79
  "config": {
46
80
  "role": "normal",
47
81
  "agentId": "my-agent",
48
82
  "agentName": "My Agent",
83
+ "description": "Handles project management and sprint planning",
49
84
  "registry": {
50
85
  "baseUrl": "http://your-server:3080",
51
86
  "apiKey": "your-hub-api-key"
@@ -53,6 +88,11 @@ Add to `openclaw.json` under `plugins.entries` (replace the API key and server U
53
88
  "fileRelay": {
54
89
  "baseUrl": "http://your-server:3080",
55
90
  "apiKey": "your-hub-api-key"
91
+ },
92
+ "localManager": {
93
+ "enabled": true,
94
+ "hubUrl": "http://your-server:3080",
95
+ "managerPass": "your-manager-password"
56
96
  }
57
97
  }
58
98
  }
@@ -61,32 +101,59 @@ Add to `openclaw.json` under `plugins.entries` (replace the API key and server U
61
101
  }
62
102
  ```
63
103
 
64
- ### Auto-configured settings
104
+ ### Config Fields
105
+
106
+ | Field | Type | Description |
107
+ |-------|------|-------------|
108
+ | `role` | `"normal"` \| `"superuser"` | Agent permission level |
109
+ | `agentId` | string | Unique identifier (e.g., `pm`, `director`) |
110
+ | `agentName` | string | Display name (e.g., `PM Bot`, `Director`) |
111
+ | `description` | string | Short description shown on Hub dashboard |
112
+ | `supportsVision` | boolean | Accept image inputs. Auto-detected from model config if not set |
113
+ | `registry.baseUrl` | string | Hub server URL |
114
+ | `registry.apiKey` | string | Hub API key |
115
+ | `fileRelay.baseUrl` | string | Hub server URL (same as registry) |
116
+ | `fileRelay.apiKey` | string | Hub API key (same as registry) |
117
+ | `localManager.enabled` | boolean | Enable Local Manager on this machine |
118
+ | `localManager.hubUrl` | string | Hub server URL |
119
+ | `localManager.managerPass` | string | Password set via `openclaw-bridge-hub manager-pass` |
120
+
121
+ ### Roles
122
+
123
+ | Role | Capabilities |
124
+ |------|-------------|
125
+ | `normal` | discover, whois, send_file, send_message, handoff |
126
+ | `superuser` | All of normal + read_file, write_file, restart |
127
+
128
+ ### Auto-configured Settings
65
129
 
66
130
  On first startup, the plugin automatically adds these if missing:
67
131
 
68
132
  | Setting | Value | Purpose |
69
133
  |---------|-------|---------|
70
134
  | `messageRelay.url` | Derived from `fileRelay.baseUrl` | WebSocket connection to Hub |
71
- | `messageRelay.apiKey` | Same as `fileRelay.apiKey` | Hub authentication |
72
- | `gateway.http.endpoints.chatCompletions.enabled` | `true` | Required for message relay processing |
73
- | `channels.discord.accounts.*.dmHistoryLimit` | `0` | Fast DM responses (OpenViking handles memory) |
135
+ | `gateway.http.endpoints.chatCompletions.enabled` | `true` | Required for message relay |
136
+ | `channels.discord.accounts.*.dmHistoryLimit` | `0` | Fast DM responses |
74
137
 
75
- ### Roles
138
+ ## Local Manager
76
139
 
77
- | Role | Capabilities |
78
- |------|-------------|
79
- | `normal` | discover, whois, send_file, send_message, handoff |
80
- | `superuser` | All of normal + read_file, write_file, restart |
140
+ The Local Manager handles PM2 process management for your gateway instances. It connects to the Hub via WebSocket so the Hub dashboard can remotely start, stop, and restart gateways.
141
+
142
+ - Only one instance runs per machine (enforced via lock file)
143
+ - Reports process status (running state, memory, uptime) and logs every 30 seconds
144
+ - Handles remote commands from Hub dashboard
145
+ - Starts automatically when `localManager.enabled: true` in any gateway's bridge config
146
+
147
+ ## Bridge Tools
81
148
 
82
- ## Tools
149
+ These tools are available to agents during conversations:
83
150
 
84
151
  | Tool | Description |
85
152
  |------|-------------|
86
153
  | `bridge_discover` | List all online agents |
87
154
  | `bridge_whois` | Get details for a specific agent |
88
155
  | `bridge_send_file` | Send a file to another agent's inbox |
89
- | `bridge_send_message` | Send a message and wait for reply (relay mode) |
156
+ | `bridge_send_message` | Send a message and wait for reply |
90
157
  | `bridge_handoff` | Hand off conversation to another agent |
91
158
  | `bridge_handoff_end` | End handoff and return to original agent |
92
159
  | `bridge_handoff_switch` | Switch handoff to a different agent |
@@ -97,51 +164,67 @@ On first startup, the plugin automatically adds these if missing:
97
164
  ## Architecture
98
165
 
99
166
  ```
100
- User ←→ Discord DM ←→ Main Gateway
167
+ User ←→ Discord/Web ←→ Gateway Agent
101
168
  ↕ (WebSocket)
102
- openclaw-bridge-hub (port 3080)
169
+ openclaw-bridge-hub (:3080 + :9090 dashboard)
103
170
  ↕ (WebSocket)
104
- PM Gateway / Bot1-4
171
+ Other Gateway Agents
105
172
  ```
106
173
 
107
- - Each gateway runs one agent with this shared plugin
174
+ - Each gateway runs one agent with this plugin
108
175
  - Plugin auto-registers to Hub, heartbeats every 30 seconds
109
176
  - Messages and handoffs route through Hub WebSocket (`/ws`)
110
177
  - File transfers use local filesystem (same machine) or Hub relay (cross-machine)
178
+ - Local Manager connects to Hub via `/ws/manager` for remote control
111
179
 
112
- ## Requirements
180
+ ## Cross-Platform
113
181
 
114
- - [openclaw-bridge-hub](https://www.npmjs.com/package/openclaw-bridge-hub) v0.2.4+ running on a reachable server
115
- - OpenClaw gateway 2026.3.24+
182
+ Same code runs on **Windows** and **macOS** without modification. Local Manager and orphan process cleanup use platform detection. PM2 is cross-platform, so start/stop/restart, logs, and process metrics work identically on both.
116
183
 
117
184
  ---
118
185
 
119
186
  ## 中文说明
120
187
 
121
- openclaw-bridge 是 [OpenClaw](https://github.com/nicepkg/openclaw) 的跨网关通信插件,让独立运行的 Agent 网关之间能够互相发现、传输文件、实时传话和无缝切换对话。
188
+ openclaw-bridge 是 [OpenClaw](https://github.com/nicepkg/openclaw) 的一站式客户端插件,提供跨网关通信、本地进程管理和完整的 CLI 工具。
122
189
 
123
190
  ### 核心功能
124
191
 
125
- - **Agent 发现** 通过心跳自动注册和发现在线 Agent
126
- - **文件传输**Agent 之间发送文件(同机直传,跨机走 Hub 中转)
127
- - **消息中继**通过 Hub 向任意 Agent 发消息并等待回复(传话模式)
128
- - **会话交接**将对话无缝切换给其他 Agent(Handoff 模式)
129
- - **超级用户工具** — 读写远程 Agent 文件、重启远程网关
130
- - **自动配置** — 首次启动时自动补全推荐配置项
192
+ - **跨网关通信**Agent 发现、文件传输、消息中继、会话交接
193
+ - **本地管理器**基于 PM2 的进程管理,支持通过 Hub 远程控制
194
+ - **CLI 工具** 设置、状态查看、启停重启、日志、备份、创建 Agent、环境诊断
195
+ - **自动配置**首次启动自动补全推荐配置
131
196
 
132
197
  ### 快速开始
133
198
 
134
- 1. 先在服务器部署 [openclaw-bridge-hub](https://www.npmjs.com/package/openclaw-bridge-hub)
135
- 2. 安装本插件:`openclaw plugins install openclaw-bridge`
136
- 3. `openclaw.json` 中配置 Hub 地址和 API Key
137
- 4. 启动网关,插件会自动注册和连接
199
+ ```bash
200
+ npm install -g openclaw-bridge # 安装
201
+ openclaw-bridge setup # 配置 Hub 连接
202
+ openclaw-bridge doctor # 检查环境
203
+ openclaw-bridge start # 启动所有实例
204
+ openclaw-bridge status # 查看状态
205
+ ```
206
+
207
+ ### CLI 命令
208
+
209
+ | 命令 | 说明 |
210
+ |------|------|
211
+ | `setup` | 交互式设置 Hub 地址、API 密钥、管理密码 |
212
+ | `status` | 查看 PM2 进程状态和 Hub 连接 |
213
+ | `start` | 启动所有 openclaw 实例 |
214
+ | `stop` | 停止所有实例 |
215
+ | `restart [agent]` | 重启指定或全部 agent |
216
+ | `logs [agent]` | 查看 agent 日志(最近100行) |
217
+ | `backup` | 创建加密备份 |
218
+ | `clean-sessions` | 清理旧会话文件 |
219
+ | `add-agent` | 向导式创建新 agent |
220
+ | `doctor` | 环境诊断 |
138
221
 
139
222
  ### 使用场景
140
223
 
141
- - 用户在 DM 中让 Main Bot 传话给 PM Bot
142
- - 用户要求切换到其他 Bot 继续对话,无需换频道
143
- - 跨机器部署的 Agent 之间互相通信
144
- - Superuser 远程管理其他 Agent 的文件和生命周期
224
+ - 多台电脑部署 Agent,统一通过 Hub 互相通信和管理
225
+ - 用户让 Main Bot 传话给其他 Bot,或直接切换对话
226
+ - 通过 Hub Dashboard 远程监控和重启 Agent
227
+ - 一键备份整个 OpenClaw 实例,跨平台迁移部署
145
228
 
146
229
  ## Author
147
230
 
@@ -31,6 +31,26 @@
31
31
  "fileRelay.apiKey": {
32
32
  "label": "FileRelay API Key",
33
33
  "sensitive": true
34
+ },
35
+ "description": {
36
+ "label": "Agent Description",
37
+ "help": "Short description of what this agent does (shown on Hub dashboard)"
38
+ },
39
+ "supportsVision": {
40
+ "label": "Supports Vision",
41
+ "help": "Whether the agent's model can process images (auto-detected if not set)"
42
+ },
43
+ "localManager.enabled": {
44
+ "label": "Enable Local Manager",
45
+ "help": "Start PM2 process manager for this machine"
46
+ },
47
+ "localManager.hubUrl": {
48
+ "label": "Hub URL for Local Manager",
49
+ "placeholder": "http://your-server:3080"
50
+ },
51
+ "localManager.managerPass": {
52
+ "label": "Manager Password",
53
+ "sensitive": true
34
54
  }
35
55
  },
36
56
  "configSchema": {
@@ -65,7 +85,17 @@
65
85
  }
66
86
  },
67
87
  "heartbeatIntervalMs": { "type": "number" },
68
- "offlineThresholdMs": { "type": "number" }
88
+ "offlineThresholdMs": { "type": "number" },
89
+ "description": { "type": "string" },
90
+ "supportsVision": { "type": "boolean" },
91
+ "localManager": {
92
+ "type": "object",
93
+ "properties": {
94
+ "enabled": { "type": "boolean" },
95
+ "hubUrl": { "type": "string" },
96
+ "managerPass": { "type": "string" }
97
+ }
98
+ }
69
99
  }
70
100
  }
71
101
  }
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "openclaw-bridge",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "author": "Bill Zhao (https://www.linkedin.com/in/billzhaodi/)",
5
5
  "description": "Cross-gateway communication plugin for OpenClaw — agent discovery, file transfer, real-time messaging, and session handoff",
6
6
  "type": "module",
7
7
  "main": "src/index.ts",
8
+ "bin": {
9
+ "openclaw-bridge": "src/cli.ts"
10
+ },
8
11
  "openclaw": {
9
12
  "extensions": [
10
13
  "./src/index.ts"