openclaw-lark-multi-agent 0.1.0
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/LICENSE +21 -0
- package/README.md +301 -0
- package/README.zh-CN.md +301 -0
- package/SECURITY.md +29 -0
- package/config.example.json +26 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +208 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +28 -0
- package/dist/feishu-bot.d.ts +123 -0
- package/dist/feishu-bot.js +985 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +52 -0
- package/dist/message-store.d.ts +80 -0
- package/dist/message-store.js +333 -0
- package/dist/openclaw-client.d.ts +111 -0
- package/dist/openclaw-client.js +555 -0
- package/package.json +65 -0
- package/scripts/install-linux-systemd.sh +147 -0
- package/scripts/install-windows-service.bat +47 -0
- package/scripts/openclaw-lark-multi-agent.plist +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenClaw Lark Multi-Agent contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# OpenClaw Lark Multi-Agent
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Run multiple Lark/Feishu bots against one OpenClaw Gateway, with each bot bound to its own model and isolated conversation state.
|
|
6
|
+
|
|
7
|
+
This project is a bridge layer for OpenClaw. It does **not** implement an agent runtime itself; messages are forwarded into normal OpenClaw sessions so every bot still uses the full OpenClaw pipeline, tools, memory, slash commands, and delivery behavior.
|
|
8
|
+
|
|
9
|
+
## Why this exists
|
|
10
|
+
|
|
11
|
+
Lark/Feishu gives each bot its own app identity, but OpenClaw normally exposes one assistant identity per channel account. This bridge lets you create several Lark bots such as:
|
|
12
|
+
|
|
13
|
+
- `GPT Bot` → `github-copilot/gpt-5.5`
|
|
14
|
+
- `Gemini Bot` → `github-copilot/gemini-3.1-pro-preview`
|
|
15
|
+
- `Claude Bot` → `github-copilot/claude-opus-4.7`
|
|
16
|
+
|
|
17
|
+
All of them connect to the same OpenClaw Gateway while keeping sessions, queues, and private chats isolated.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- Multiple Lark/Feishu bot apps in one process
|
|
22
|
+
- Per-bot model binding via OpenClaw session model override
|
|
23
|
+
- Per-chat OpenClaw sessions: `lma-<bot>-<chatId>`
|
|
24
|
+
- Private chat isolation: a p2p chat belongs to exactly one bot
|
|
25
|
+
- Group chat routing:
|
|
26
|
+
- reply when directly mentioned
|
|
27
|
+
- reply to `@all` / `@_all`
|
|
28
|
+
- optional Free Discussion mode
|
|
29
|
+
- Local SQLite message store for context, trigger tracking, and duplicate prevention
|
|
30
|
+
- `pending_triggers` queue so restart recovery does not replay every context message
|
|
31
|
+
- `delivered_replies` table so one trigger message gets at most one delivered reply per bot
|
|
32
|
+
- Feishu image download and OpenClaw multimodal attachment forwarding
|
|
33
|
+
- Bridge-level slash commands and escaped OpenClaw slash commands
|
|
34
|
+
- Linux systemd installer with separate runtime and state directories
|
|
35
|
+
|
|
36
|
+
## Architecture
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
Lark Bot App A ┐
|
|
40
|
+
Lark Bot App B ├─ WebSocket events ─→ openclaw-lark-multi-agent ─→ OpenClaw Gateway
|
|
41
|
+
Lark Bot App C ┘ └─ SQLite state
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The bridge stores every message as local context, but only messages that should trigger a bot response are inserted into `pending_triggers`. This distinction prevents startup drains from accidentally replaying unrelated history.
|
|
45
|
+
|
|
46
|
+
## Requirements
|
|
47
|
+
|
|
48
|
+
- Node.js 22+
|
|
49
|
+
- npm
|
|
50
|
+
- An OpenClaw Gateway reachable over HTTP/WebSocket
|
|
51
|
+
- One or more Lark/Feishu self-built apps with WebSocket event subscription enabled
|
|
52
|
+
- Linux systemd for the provided installer, or another process manager such as pm2
|
|
53
|
+
|
|
54
|
+
## Quick start with npm
|
|
55
|
+
|
|
56
|
+
After the package is published to npm:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install -g openclaw-lark-multi-agent
|
|
60
|
+
openclaw-lark-multi-agent init
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This creates:
|
|
64
|
+
|
|
65
|
+
- config: `~/.openclaw/openclaw-lark-multi-agent/config.json`
|
|
66
|
+
- data dir: `~/.openclaw/openclaw-lark-multi-agent/data/`
|
|
67
|
+
|
|
68
|
+
Edit the generated config and fill in your OpenClaw Gateway token and Lark app credentials. Then run:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
openclaw-lark-multi-agent start
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Install as a systemd user service:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
openclaw-lark-multi-agent install-systemd --user
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
On Windows, install [NSSM](https://nssm.cc/download), make sure `nssm.exe` is in `PATH`, then run PowerShell or Command Prompt as Administrator:
|
|
81
|
+
|
|
82
|
+
```powershell
|
|
83
|
+
openclaw-lark-multi-agent install-windows-service
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Useful CLI commands:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
openclaw-lark-multi-agent --help
|
|
90
|
+
openclaw-lark-multi-agent doctor
|
|
91
|
+
openclaw-lark-multi-agent start [config]
|
|
92
|
+
openclaw-lark-multi-agent init [--state-dir DIR] [--force]
|
|
93
|
+
openclaw-lark-multi-agent install-systemd [--user|--system] [--state-dir DIR]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Quick start from source
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git clone https://github.com/hackerphysics/openclaw-lark-multi-agent.git
|
|
100
|
+
cd openclaw-lark-multi-agent
|
|
101
|
+
npm ci
|
|
102
|
+
cp config.example.json config.json
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Edit `config.json`:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"openclaw": {
|
|
110
|
+
"baseUrl": "http://127.0.0.1:18789",
|
|
111
|
+
"token": "YOUR_OPENCLAW_GATEWAY_TOKEN"
|
|
112
|
+
},
|
|
113
|
+
"bots": [
|
|
114
|
+
{
|
|
115
|
+
"name": "GPT",
|
|
116
|
+
"appId": "cli_xxx",
|
|
117
|
+
"appSecret": "YOUR_LARK_APP_SECRET",
|
|
118
|
+
"model": "github-copilot/gpt-5.5"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "Gemini",
|
|
122
|
+
"appId": "cli_yyy",
|
|
123
|
+
"appSecret": "YOUR_LARK_APP_SECRET",
|
|
124
|
+
"model": "github-copilot/gemini-3.1-pro-preview"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Build and run locally:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm run build
|
|
134
|
+
npm start -- config.json
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
> `config.json` contains secrets and is ignored by git. Do not commit it.
|
|
138
|
+
|
|
139
|
+
## Recommended Linux deployment
|
|
140
|
+
|
|
141
|
+
Use the installer:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
./scripts/install-linux-systemd.sh --system
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
By default it uses:
|
|
148
|
+
|
|
149
|
+
- runtime files: `~/.local/lib/openclaw-lark-multi-agent/`
|
|
150
|
+
- state/config/data: `~/.openclaw/openclaw-lark-multi-agent/`
|
|
151
|
+
- systemd service: `openclaw-lark-multi-agent.service`
|
|
152
|
+
|
|
153
|
+
Only built runtime files are deployed to the runtime directory (`dist/`, `package.json`, `package-lock.json`, production `node_modules`). Source files are not copied there.
|
|
154
|
+
|
|
155
|
+
For a user service instead of a system service:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
./scripts/install-linux-systemd.sh --user
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Custom directories:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
./scripts/install-linux-systemd.sh \
|
|
165
|
+
--deploy-dir ~/.local/lib/openclaw-lark-multi-agent-prod \
|
|
166
|
+
--state-dir ~/.openclaw/openclaw-lark-multi-agent-prod
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Useful commands:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
systemctl status openclaw-lark-multi-agent
|
|
173
|
+
journalctl -u openclaw-lark-multi-agent -f
|
|
174
|
+
sudo systemctl restart openclaw-lark-multi-agent
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
## Windows deployment
|
|
179
|
+
|
|
180
|
+
The npm CLI works on Windows as well. It uses `%USERPROFILE%\.openclaw\openclaw-lark-multi-agent` as the default state directory.
|
|
181
|
+
|
|
182
|
+
```powershell
|
|
183
|
+
npm install -g openclaw-lark-multi-agent
|
|
184
|
+
openclaw-lark-multi-agent init
|
|
185
|
+
notepad $env:USERPROFILE\.openclaw\openclaw-lark-multi-agent\config.json
|
|
186
|
+
openclaw-lark-multi-agent start
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
To run as a Windows service, install [NSSM](https://nssm.cc/download), put `nssm.exe` in `PATH`, open an elevated terminal, then run:
|
|
190
|
+
|
|
191
|
+
```powershell
|
|
192
|
+
openclaw-lark-multi-agent install-windows-service
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
A legacy helper script is also available at `scripts/install-windows-service.bat`.
|
|
196
|
+
|
|
197
|
+
## macOS launchd
|
|
198
|
+
|
|
199
|
+
A sample launchd plist is available at `scripts/openclaw-lark-multi-agent.plist`. For most users, npm CLI + a process manager is simpler.
|
|
200
|
+
|
|
201
|
+
## Lark/Feishu app setup
|
|
202
|
+
|
|
203
|
+
For each bot:
|
|
204
|
+
|
|
205
|
+
1. Create a self-built Lark/Feishu app.
|
|
206
|
+
2. Enable bot capability.
|
|
207
|
+
3. Enable event subscription over WebSocket / long connection.
|
|
208
|
+
4. Subscribe to message receive events.
|
|
209
|
+
5. Copy the app ID and app secret into `config.json`.
|
|
210
|
+
6. Add the bot to the target chats.
|
|
211
|
+
|
|
212
|
+
Each bot app should have its own identity and credentials.
|
|
213
|
+
|
|
214
|
+
## Commands
|
|
215
|
+
|
|
216
|
+
Bridge-level commands use a single slash and are handled by this project:
|
|
217
|
+
|
|
218
|
+
- `/help` — show command help
|
|
219
|
+
- `/status` — show bot model, token usage, and session state
|
|
220
|
+
- `/compact` — compact the OpenClaw session
|
|
221
|
+
- `/reset` — reset the OpenClaw session
|
|
222
|
+
- `/verbose` — toggle tool-call messages for this bot in this chat
|
|
223
|
+
- `/free` — toggle Free Discussion mode in group chats
|
|
224
|
+
|
|
225
|
+
OpenClaw-level slash commands can be sent by escaping with a double slash:
|
|
226
|
+
|
|
227
|
+
```text
|
|
228
|
+
//status
|
|
229
|
+
//reset
|
|
230
|
+
//compact
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
The bridge converts `//status` to `/status` and forwards it to OpenClaw instead of handling it locally.
|
|
234
|
+
|
|
235
|
+
## Message routing rules
|
|
236
|
+
|
|
237
|
+
### Private chats
|
|
238
|
+
|
|
239
|
+
A private chat is owned by the bot connected to that chat. Other bots ignore it.
|
|
240
|
+
|
|
241
|
+
### Group chats
|
|
242
|
+
|
|
243
|
+
By default, a bot responds when:
|
|
244
|
+
|
|
245
|
+
- it is directly mentioned;
|
|
246
|
+
- `@all` / `@_all` appears in the message;
|
|
247
|
+
- Free Discussion is enabled for that group.
|
|
248
|
+
|
|
249
|
+
Bot messages do not trigger other bots unless they mention them. A bot-streak guard prevents infinite bot-to-bot loops.
|
|
250
|
+
|
|
251
|
+
## Data model
|
|
252
|
+
|
|
253
|
+
SQLite state lives in the configured data directory. Important tables:
|
|
254
|
+
|
|
255
|
+
- `messages` — local conversation log and context
|
|
256
|
+
- `sync_state` — per-bot/per-chat sync cursor
|
|
257
|
+
- `pending_triggers` — messages that should actively trigger a bot run
|
|
258
|
+
- `delivered_replies` — delivered response markers for idempotency
|
|
259
|
+
- `processed_events` — Feishu event de-duplication
|
|
260
|
+
- `bot_chat_settings` — per-bot/per-chat settings such as verbose mode
|
|
261
|
+
|
|
262
|
+
## Development
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
npm ci
|
|
266
|
+
npm run build
|
|
267
|
+
npm run dev -- config.json
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
TypeScript output goes to `dist/`.
|
|
271
|
+
|
|
272
|
+
## Repository hygiene
|
|
273
|
+
|
|
274
|
+
The repository intentionally excludes:
|
|
275
|
+
|
|
276
|
+
- `config.json`
|
|
277
|
+
- `config*.json.bak*`
|
|
278
|
+
- `.env*`
|
|
279
|
+
- `data/`
|
|
280
|
+
- `dist/`
|
|
281
|
+
- `node_modules/`
|
|
282
|
+
|
|
283
|
+
Before publishing or pushing, run:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
git status --short
|
|
287
|
+
git ls-files | grep -E 'config|secret|\.env' || true
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
If a secret is ever committed, remove it from the current tree and rewrite git history before making the repository public. Also rotate the leaked credential.
|
|
291
|
+
|
|
292
|
+
## Security notes
|
|
293
|
+
|
|
294
|
+
- Treat every Lark app secret and OpenClaw Gateway token as sensitive.
|
|
295
|
+
- Use one bot app per model/identity.
|
|
296
|
+
- Prefer private repositories until credentials have been audited and rotated if needed.
|
|
297
|
+
- Do not expose the OpenClaw Gateway to the public internet without authentication.
|
|
298
|
+
|
|
299
|
+
## License
|
|
300
|
+
|
|
301
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# OpenClaw Lark Multi-Agent
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
让多个 Lark/飞书机器人接入同一个 OpenClaw Gateway,并且每个机器人可以绑定不同模型、拥有隔离的会话状态。
|
|
6
|
+
|
|
7
|
+
这个项目是 OpenClaw 的桥接层。它本身不实现 Agent Runtime;消息会被转发到标准 OpenClaw Session,因此每个机器人仍然走完整的 OpenClaw pipeline,包括工具、记忆、slash commands 和交付逻辑。
|
|
8
|
+
|
|
9
|
+
## 为什么需要它
|
|
10
|
+
|
|
11
|
+
Lark/飞书里每个机器人都有自己的 App 身份,但 OpenClaw 通常在一个 channel account 下暴露一个助手身份。这个桥接层可以让你创建多个飞书机器人,例如:
|
|
12
|
+
|
|
13
|
+
- `GPT Bot` → `github-copilot/gpt-5.5`
|
|
14
|
+
- `Gemini Bot` → `github-copilot/gemini-3.1-pro-preview`
|
|
15
|
+
- `Claude Bot` → `github-copilot/claude-opus-4.7`
|
|
16
|
+
|
|
17
|
+
它们共享同一个 OpenClaw Gateway,同时保持各自的 session、队列和私聊隔离。
|
|
18
|
+
|
|
19
|
+
## 功能特性
|
|
20
|
+
|
|
21
|
+
- 单进程接入多个 Lark/飞书机器人应用
|
|
22
|
+
- 每个 bot 绑定独立模型(通过 OpenClaw session model override)
|
|
23
|
+
- 每个聊天一个 OpenClaw session:`lma-<bot>-<chatId>`
|
|
24
|
+
- 私聊隔离:一个私聊只归属一个 bot
|
|
25
|
+
- 群聊路由:
|
|
26
|
+
- 直接 @ 某个 bot 时回复
|
|
27
|
+
- `@all` / `@_all` 时回复
|
|
28
|
+
- 可选 Free Discussion 模式
|
|
29
|
+
- 本地 SQLite 消息存储,用于上下文、触发队列和重复投递防护
|
|
30
|
+
- `pending_triggers` 队列,避免重启后把所有历史上下文都重新发给 OpenClaw
|
|
31
|
+
- `delivered_replies` 表,保证同一个触发消息每个 bot 最多投递一次回复
|
|
32
|
+
- 支持飞书图片下载,并以 OpenClaw multimodal attachment 形式转发
|
|
33
|
+
- 桥接层 slash command + 转义后的 OpenClaw slash command
|
|
34
|
+
- Linux systemd 安装脚本,运行产物和状态目录分离
|
|
35
|
+
|
|
36
|
+
## 架构
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
Lark Bot App A ┐
|
|
40
|
+
Lark Bot App B ├─ WebSocket events ─→ openclaw-lark-multi-agent ─→ OpenClaw Gateway
|
|
41
|
+
Lark Bot App C ┘ └─ SQLite state
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
桥接层会把所有消息存为本地上下文,但只有真正应该触发回复的消息才会写入 `pending_triggers`。这样重启恢复时不会误把普通上下文消息重新发给 OpenClaw。
|
|
45
|
+
|
|
46
|
+
## 环境要求
|
|
47
|
+
|
|
48
|
+
- Node.js 22+
|
|
49
|
+
- npm
|
|
50
|
+
- 可访问的 OpenClaw Gateway(HTTP/WebSocket)
|
|
51
|
+
- 一个或多个 Lark/飞书自建应用,并启用 WebSocket 事件订阅
|
|
52
|
+
- 使用内置安装脚本时需要 Linux systemd;也可以用 pm2 等其他进程管理器
|
|
53
|
+
|
|
54
|
+
## 使用 npm 快速开始
|
|
55
|
+
|
|
56
|
+
发布到 npm 后,可以这样安装:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install -g openclaw-lark-multi-agent
|
|
60
|
+
openclaw-lark-multi-agent init
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
这会创建:
|
|
64
|
+
|
|
65
|
+
- 配置文件:`~/.openclaw/openclaw-lark-multi-agent/config.json`
|
|
66
|
+
- 数据目录:`~/.openclaw/openclaw-lark-multi-agent/data/`
|
|
67
|
+
|
|
68
|
+
编辑生成的配置文件,填入 OpenClaw Gateway token 和 Lark/飞书应用凭证。然后运行:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
openclaw-lark-multi-agent start
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
安装成 systemd user service:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
openclaw-lark-multi-agent install-systemd --user
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Windows 下先安装 [NSSM](https://nssm.cc/download),确保 `nssm.exe` 在 `PATH`,然后用管理员权限打开 PowerShell 或命令提示符:
|
|
81
|
+
|
|
82
|
+
```powershell
|
|
83
|
+
openclaw-lark-multi-agent install-windows-service
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
常用 CLI 命令:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
openclaw-lark-multi-agent --help
|
|
90
|
+
openclaw-lark-multi-agent doctor
|
|
91
|
+
openclaw-lark-multi-agent start [config]
|
|
92
|
+
openclaw-lark-multi-agent init [--state-dir DIR] [--force]
|
|
93
|
+
openclaw-lark-multi-agent install-systemd [--user|--system] [--state-dir DIR]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 从源码快速开始
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git clone https://github.com/hackerphysics/openclaw-lark-multi-agent.git
|
|
100
|
+
cd openclaw-lark-multi-agent
|
|
101
|
+
npm ci
|
|
102
|
+
cp config.example.json config.json
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
编辑 `config.json`:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"openclaw": {
|
|
110
|
+
"baseUrl": "http://127.0.0.1:18789",
|
|
111
|
+
"token": "YOUR_OPENCLAW_GATEWAY_TOKEN"
|
|
112
|
+
},
|
|
113
|
+
"bots": [
|
|
114
|
+
{
|
|
115
|
+
"name": "GPT",
|
|
116
|
+
"appId": "cli_xxx",
|
|
117
|
+
"appSecret": "YOUR_LARK_APP_SECRET",
|
|
118
|
+
"model": "github-copilot/gpt-5.5"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "Gemini",
|
|
122
|
+
"appId": "cli_yyy",
|
|
123
|
+
"appSecret": "YOUR_LARK_APP_SECRET",
|
|
124
|
+
"model": "github-copilot/gemini-3.1-pro-preview"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
本地构建和运行:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm run build
|
|
134
|
+
npm start -- config.json
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
> `config.json` 包含密钥,已被 git ignore。不要提交它。
|
|
138
|
+
|
|
139
|
+
## 推荐的 Linux 部署方式
|
|
140
|
+
|
|
141
|
+
使用安装脚本:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
./scripts/install-linux-systemd.sh --system
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
默认目录:
|
|
148
|
+
|
|
149
|
+
- 程序运行产物:`~/.local/lib/openclaw-lark-multi-agent/`
|
|
150
|
+
- 状态、配置、数据:`~/.openclaw/openclaw-lark-multi-agent/`
|
|
151
|
+
- systemd 服务:`openclaw-lark-multi-agent.service`
|
|
152
|
+
|
|
153
|
+
安装脚本只会把运行所需文件部署到 runtime 目录:`dist/`、`package.json`、`package-lock.json` 和 production `node_modules`。源码不会复制过去。
|
|
154
|
+
|
|
155
|
+
如果想安装成 user service:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
./scripts/install-linux-systemd.sh --user
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
自定义目录:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
./scripts/install-linux-systemd.sh \
|
|
165
|
+
--deploy-dir ~/.local/lib/openclaw-lark-multi-agent-prod \
|
|
166
|
+
--state-dir ~/.openclaw/openclaw-lark-multi-agent-prod
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
常用命令:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
systemctl status openclaw-lark-multi-agent
|
|
173
|
+
journalctl -u openclaw-lark-multi-agent -f
|
|
174
|
+
sudo systemctl restart openclaw-lark-multi-agent
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
## Windows 部署
|
|
179
|
+
|
|
180
|
+
npm CLI 也支持 Windows。默认状态目录是 `%USERPROFILE%\.openclaw\openclaw-lark-multi-agent`。
|
|
181
|
+
|
|
182
|
+
```powershell
|
|
183
|
+
npm install -g openclaw-lark-multi-agent
|
|
184
|
+
openclaw-lark-multi-agent init
|
|
185
|
+
notepad $env:USERPROFILE\.openclaw\openclaw-lark-multi-agent\config.json
|
|
186
|
+
openclaw-lark-multi-agent start
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
如果要作为 Windows Service 运行,安装 [NSSM](https://nssm.cc/download),把 `nssm.exe` 放进 `PATH`,用管理员权限打开终端,然后运行:
|
|
190
|
+
|
|
191
|
+
```powershell
|
|
192
|
+
openclaw-lark-multi-agent install-windows-service
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
兼容用的 bat 脚本也保留在 `scripts/install-windows-service.bat`。
|
|
196
|
+
|
|
197
|
+
## macOS launchd
|
|
198
|
+
|
|
199
|
+
示例 launchd plist 放在 `scripts/openclaw-lark-multi-agent.plist`。多数用户用 npm CLI 配合进程管理器会更简单。
|
|
200
|
+
|
|
201
|
+
## Lark/飞书应用配置
|
|
202
|
+
|
|
203
|
+
每个 bot 都需要一个独立的自建应用:
|
|
204
|
+
|
|
205
|
+
1. 创建 Lark/飞书自建应用。
|
|
206
|
+
2. 启用机器人能力。
|
|
207
|
+
3. 启用 WebSocket / 长连接事件订阅。
|
|
208
|
+
4. 订阅消息接收事件。
|
|
209
|
+
5. 把 App ID 和 App Secret 写入 `config.json`。
|
|
210
|
+
6. 把机器人加入目标聊天。
|
|
211
|
+
|
|
212
|
+
建议每个模型/身份对应一个独立 bot app。
|
|
213
|
+
|
|
214
|
+
## 命令
|
|
215
|
+
|
|
216
|
+
单斜杠命令由桥接层处理:
|
|
217
|
+
|
|
218
|
+
- `/help` — 显示命令帮助
|
|
219
|
+
- `/status` — 显示 bot 模型、token 使用和 session 状态
|
|
220
|
+
- `/compact` — 压缩 OpenClaw session
|
|
221
|
+
- `/reset` — 重置 OpenClaw session
|
|
222
|
+
- `/verbose` — 开关当前 bot 在当前聊天里的 tool-call 展示
|
|
223
|
+
- `/free` — 开关群聊 Free Discussion 模式
|
|
224
|
+
|
|
225
|
+
如果你想把 slash command 直接发给 OpenClaw,可以用双斜杠转义:
|
|
226
|
+
|
|
227
|
+
```text
|
|
228
|
+
//status
|
|
229
|
+
//reset
|
|
230
|
+
//compact
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
桥接层会把 `//status` 转成 `/status` 并转发给 OpenClaw,而不是自己处理。
|
|
234
|
+
|
|
235
|
+
## 消息路由规则
|
|
236
|
+
|
|
237
|
+
### 私聊
|
|
238
|
+
|
|
239
|
+
私聊归属当前 bot,其他 bot 不会处理这个私聊。
|
|
240
|
+
|
|
241
|
+
### 群聊
|
|
242
|
+
|
|
243
|
+
默认情况下,bot 会在这些场景回复:
|
|
244
|
+
|
|
245
|
+
- 被直接 @;
|
|
246
|
+
- 消息里出现 `@all` / `@_all`;
|
|
247
|
+
- 当前群开启了 Free Discussion 模式。
|
|
248
|
+
|
|
249
|
+
bot 发出的消息默认不会触发其他 bot,除非明确 @。同时有 bot-streak 防护,避免 bot 之间无限互相回复。
|
|
250
|
+
|
|
251
|
+
## 数据模型
|
|
252
|
+
|
|
253
|
+
SQLite 状态位于配置的数据目录。主要表:
|
|
254
|
+
|
|
255
|
+
- `messages` — 本地对话日志和上下文
|
|
256
|
+
- `sync_state` — 每个 bot / chat 的同步游标
|
|
257
|
+
- `pending_triggers` — 应主动触发 bot run 的消息
|
|
258
|
+
- `delivered_replies` — 已投递回复标记,用于幂等防重复
|
|
259
|
+
- `processed_events` — 飞书事件去重
|
|
260
|
+
- `bot_chat_settings` — 每个 bot / chat 的设置,例如 verbose mode
|
|
261
|
+
|
|
262
|
+
## 开发
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
npm ci
|
|
266
|
+
npm run build
|
|
267
|
+
npm run dev -- config.json
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
TypeScript 输出目录是 `dist/`。
|
|
271
|
+
|
|
272
|
+
## 仓库卫生
|
|
273
|
+
|
|
274
|
+
仓库会忽略:
|
|
275
|
+
|
|
276
|
+
- `config.json`
|
|
277
|
+
- `config*.json.bak*`
|
|
278
|
+
- `.env*`
|
|
279
|
+
- `data/`
|
|
280
|
+
- `dist/`
|
|
281
|
+
- `node_modules/`
|
|
282
|
+
|
|
283
|
+
发布或 push 前建议检查:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
git status --short
|
|
287
|
+
git ls-files | grep -E 'config|secret|\.env' || true
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
如果密钥曾经被提交,需要从当前 tree 删除、重写 git 历史、force push,并轮换泄露的凭证。
|
|
291
|
+
|
|
292
|
+
## 安全说明
|
|
293
|
+
|
|
294
|
+
- Lark/飞书 App Secret 和 OpenClaw Gateway token 都是敏感信息。
|
|
295
|
+
- 建议一个模型/身份对应一个 bot app。
|
|
296
|
+
- 在完成凭证审计和必要轮换前,建议保持私有仓库。
|
|
297
|
+
- 不要在没有认证保护的情况下把 OpenClaw Gateway 暴露到公网。
|
|
298
|
+
|
|
299
|
+
## License
|
|
300
|
+
|
|
301
|
+
MIT
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
This project is pre-1.0. Security fixes are applied to the default branch.
|
|
6
|
+
|
|
7
|
+
## Reporting a vulnerability
|
|
8
|
+
|
|
9
|
+
Please do not open a public issue for suspected credential leaks or security vulnerabilities.
|
|
10
|
+
|
|
11
|
+
If this repository is hosted on GitHub, use GitHub private vulnerability reporting when available, or contact the repository owner privately.
|
|
12
|
+
|
|
13
|
+
## Credential handling
|
|
14
|
+
|
|
15
|
+
Never commit:
|
|
16
|
+
|
|
17
|
+
- `config.json`
|
|
18
|
+
- Lark/Feishu app secrets
|
|
19
|
+
- OpenClaw Gateway tokens
|
|
20
|
+
- `.env` files
|
|
21
|
+
- database files under `data/`
|
|
22
|
+
|
|
23
|
+
If a secret is committed:
|
|
24
|
+
|
|
25
|
+
1. Remove it from the current tree.
|
|
26
|
+
2. Rewrite git history to purge it.
|
|
27
|
+
3. Force-push the cleaned history.
|
|
28
|
+
4. Rotate the leaked credential.
|
|
29
|
+
5. Re-clone any local working copies from the cleaned repository.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openclaw": {
|
|
3
|
+
"baseUrl": "http://127.0.0.1:18789",
|
|
4
|
+
"token": "YOUR_GATEWAY_TOKEN"
|
|
5
|
+
},
|
|
6
|
+
"bots": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Claude",
|
|
9
|
+
"appId": "cli_xxx1",
|
|
10
|
+
"appSecret": "xxx1",
|
|
11
|
+
"model": "github-copilot/claude-opus-4.6-1m"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "GPT",
|
|
15
|
+
"appId": "cli_xxx2",
|
|
16
|
+
"appSecret": "xxx2",
|
|
17
|
+
"model": "github-copilot/gpt-5.5"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "Gemini",
|
|
21
|
+
"appId": "cli_xxx3",
|
|
22
|
+
"appSecret": "xxx3",
|
|
23
|
+
"model": "github-copilot/gemini-3.1-pro-preview"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
package/dist/cli.d.ts
ADDED