botmux 1.13.0 → 1.13.2

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.en.md CHANGED
@@ -4,84 +4,276 @@
4
4
  <img src="cover.svg" alt="botmux cover" width="800">
5
5
  </p>
6
6
 
7
- [中文](README.md) | English
8
-
9
- Bridge between Lark (Feishu) topic groups and AI coding CLIs. The daemon listens for Lark messages and automatically spawns an independent CLI process (supporting Claude Code, Aiden, CoCo, Codex, Gemini) for each new topic thread, with live streaming cards and a web-based terminal.
10
-
11
- ## Demo
7
+ <p align="center">
8
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License MIT"></a>
9
+ <img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg" alt="Node.js >= 20">
10
+ <a href="https://www.npmjs.com/package/botmux"><img src="https://img.shields.io/npm/v/botmux.svg" alt="npm version"></a>
11
+ <a href="https://github.com/deepcoldy/botmux"><img src="https://img.shields.io/github/stars/deepcoldy/botmux?style=social" alt="GitHub Stars"></a>
12
+ </p>
12
13
 
13
14
  <p align="center">
14
- <img src="gif/fold&unfold.gif" alt="Lark card interaction — streaming output fold/unfold" width="600">
15
+ <a href="#design-philosophy">Design</a> &middot;
16
+ <a href="#key-advantages">Advantages</a> &middot;
17
+ <a href="#5-minute-setup">Quick Start</a> &middot;
18
+ <a href="#usage">Usage</a> &middot;
19
+ <a href="#configuration">Config</a>
15
20
  </p>
16
21
 
22
+ [中文](README.md) | English
23
+
24
+ **Plug any AI coding CLI into Lark (Feishu) topic groups — one thread per session, streaming cards, web terminal, zero glue code.**
25
+
26
+ | Lark Streaming Cards | Web Terminal | tmux Session Management | Multi-Bot Collaboration |
27
+ |:-:|:-:|:-:|:-:|
28
+ | <img src="gif/fold&unfold.gif" width="220" /> | <img src="gif/web_terminal.gif" width="220" /> | <img src="gif/tmux.gif" width="220" /> | <img src="docs/setup/multi-bot-collab.png" width="220" /> |
29
+
17
30
  <details>
18
- <summary>📺 Full demo video</summary>
31
+ <summary>Full demo video</summary>
19
32
 
20
33
  [Demo Video](https://github.com/user-attachments/assets/3ba4c681-0a7e-4a03-89c8-b8d26b544a65)
21
34
  </details>
22
35
 
23
- ## Features
36
+ ---
37
+
38
+ ## Why botmux?
39
+
40
+ ### Design Philosophy
41
+
42
+ Core philosophy: **Bridge CLIs, don't rebuild them**. botmux doesn't reimplement Agent capabilities — it bridges existing AI coding CLIs (Claude Code, Codex, Aiden, CoCo, Gemini, OpenCode) directly. Memory, context management, tool use, permission systems — these capabilities are evolving rapidly within the CLIs themselves. botmux rides on top of that evolution rather than rebuilding in parallel. Every CLI upgrade benefits botmux automatically with zero adaptation.
43
+
44
+ ### Key Advantages
45
+
46
+ Compared to OpenClaw-style approaches built on Agent SDKs:
47
+
48
+ | Feature | botmux | OpenClaw-style |
49
+ |---------|--------|---------------|
50
+ | Architecture | Bridges full CLI processes directly | Rebuilds on Agent SDK |
51
+ | CLI Capabilities | Full runtime (hooks, memory, plan mode, MCP ecosystem, `/` commands) | SDK API subset, missing features must be reimplemented |
52
+ | CLI Upgrades | Zero-adaptation automatic benefit | Must track SDK version changes |
53
+ | Memory / Context | Reuses CLI's built-in memory system, improves as the CLI evolves | Must build custom memory system, duplicating CLI-native capabilities |
54
+ | Multi-CLI Support | 6 CLIs, switch with one config (Claude Code / Codex / Aiden / CoCo / Gemini / OpenCode) | Tied to a single SDK, cannot switch CLIs |
55
+ | Web Terminal | Interactive full terminal, mobile shortcut toolbar, phone/desktop/Lark tri-screen sync | Usually web chat UI or read-only output |
56
+ | Multi-Bot Collaboration | Multiple bots in same group via @mention routing, isolated processes, different CLIs sparring | Usually single bot |
57
+ | Terminal Access | tmux attach directly into the CLI process, same as local dev experience | No direct terminal access |
58
+ | Installation | `npm install -g botmux`, 5-min Lark setup | Easy to install, but more configuration needed |
24
59
 
25
- - **One topic = one AI coding session** — each Lark thread gets its own isolated CLI process
26
- - **Multi-CLI support** — adapter architecture supports Claude Code, Aiden, CoCo, Codex, Gemini, and is extensible
27
- - **Live streaming cards** — real-time terminal output rendered in Feishu cards with markdown support, per-turn card lifecycle
28
- - **Web terminal (xterm.js)** — full PTY output in the browser with a mobile shortcut toolbar and on-demand write access via DM link
29
- - **Session persistence** — sessions survive daemon restarts; with tmux backend, CLI processes persist across restarts with zero interruption
30
- - **Scheduled tasks** — cron-based recurring prompts with natural language scheduling (Chinese supported)
31
- - **Project management** — interactive repo selector, per-session working directory
32
- - **MCP integration** — CLI can reply to Lark threads, read message history, and add reactions via MCP tools
33
- - **Access control** — allowlist for users, token-based write access for terminals, button restrictions on cards
60
+ ---
34
61
 
35
62
  ## Prerequisites
36
63
 
37
64
  - **Node.js** >= 20
38
65
  - **AI coding CLI** installed and authenticated (`claude`, `aiden`, `coco`, `codex`, `gemini`, or `opencode` in PATH)
39
- - **Lark app** with Bot and Message permissions (WebSocket event subscription)
40
66
  - **tmux** >= 3.x (optional — auto-enabled when installed for persistent CLI sessions)
41
67
 
42
- ## Installation
68
+ ## 5-Minute Setup
43
69
 
44
- ```bash
45
- npm install -g botmux
70
+ ### Step 1: Create a Lark App
71
+
72
+ Go to the [Lark Open Platform](https://open.larkoffice.com/app) and click "Create Custom App".
73
+
74
+ ![Create App](docs/setup/create-app.png)
75
+
76
+ ### Step 2: Get Credentials
77
+
78
+ Open the app details page → "Credentials & Basic Info", and copy the **App ID** and **App Secret**.
79
+
80
+ ![Get Credentials](docs/setup/credentials.png)
81
+
82
+ ### Step 3: Add Permissions
83
+
84
+ Go to "Permissions & Scopes" → "Batch Import/Export", and paste the following JSON to import all permissions at once:
85
+
86
+ ![Permissions](docs/setup/permissions.png)
87
+
88
+ <details>
89
+ <summary>Click to expand batch import JSON</summary>
90
+
91
+ ```json
92
+ {
93
+ "scopes": {
94
+ "tenant": [
95
+ "contact:user.base:readonly",
96
+ "contact:user.id:readonly",
97
+ "im:chat:read",
98
+ "im:chat.members:bot_access",
99
+ "im:chat.members:read",
100
+ "im:message",
101
+ "im:message:readonly",
102
+ "im:message:send_as_bot",
103
+ "im:message:update",
104
+ "im:message.group_at_msg",
105
+ "im:message.group_at_msg:readonly",
106
+ "im:message.group_msg",
107
+ "im:message.p2p_msg:readonly",
108
+ "im:message.reactions:write_only",
109
+ "im:resource"
110
+ ]
111
+ }
112
+ }
46
113
  ```
114
+ </details>
47
115
 
48
- ## Quick Start
116
+ ### Step 4: Install & Start botmux
49
117
 
50
118
  ```bash
51
- # 1. Interactive setup — creates ~/.botmux/bots.json
119
+ # Install
120
+ npm install -g botmux
121
+
122
+ # Interactive setup — enter the App ID and App Secret from Step 2
52
123
  botmux setup
53
124
 
54
- # 2. Start the daemon
125
+ # Start (must be running before configuring WebSocket subscription — Lark checks for an active connection)
55
126
  botmux start
56
127
  ```
57
128
 
58
- The `setup` command will guide you through:
59
- - Creating a Lark app (with required permissions listed)
60
- - Entering App ID, App Secret, Chat ID
61
- - Optional: Claude model, working directory, access control
129
+ ### Step 5: Configure Event Subscription
62
130
 
63
- ## CLI Commands
131
+ Back in the Lark Open Platform, go to "Events & Callbacks":
132
+
133
+ 1. **Subscription mode**: Click the edit icon, select "Receive events via persistent connection" (WebSocket) — requires botmux to be running so Lark can detect the connection
134
+
135
+ ![WebSocket subscription](docs/setup/event-websocket.png)
136
+
137
+ 2. **Add event**: Click "Add Event", search and add `im.message.receive_v1` (Receive messages v2.0)
138
+
139
+ ![Add event](docs/setup/event-receive-msg.png)
140
+
141
+ 3. **Enable callback**: Switch to the "Callback Configuration" tab, turn on "Card action callback" (`card.action.trigger`)
142
+
143
+ ### Step 6: Publish the App
144
+
145
+ Go to "Version Management & Release", click "Create Version" and publish. Set availability to "Visible to me only" for automatic approval.
146
+
147
+ ![Publish](docs/setup/publish.png)
148
+
149
+ ### Step 7: Create a Group and Start Chatting
150
+
151
+ 1. Create a **topic-enabled group** in Lark
152
+ 2. Go to Group Settings → Bots → Add the bot you just created
153
+ 3. Send a message in the group — the bot responds automatically
154
+
155
+ ![Add bot to group](docs/setup/add-bot-to-group.png)
156
+
157
+ ---
158
+
159
+ ## Features
160
+
161
+ ### Streaming Cards
162
+
163
+ Each conversation turn gets a live-updating Feishu card that shows:
164
+
165
+ - Real-time terminal output rendered as Markdown, TUI chrome auto-filtered to show only actual work output
166
+ - Status indicator: Starting > Working > Idle
167
+ - Action buttons: Open Terminal, Get Write Link, Restart CLI, Close Session
168
+
169
+
170
+ ### Web Terminal (Interactive)
171
+
172
+ Each session exposes a web terminal at `http://<WEB_EXTERNAL_HOST>:<port>`.
173
+
174
+ - **Read-only link** — shown on the streaming card in the group thread
175
+ - **Write-enabled link** — sent via DM on demand (click "Get Write Link" on the card)
176
+
177
+ On mobile/tablet, a floating shortcut toolbar provides Esc, Ctrl+C, Tab, arrow keys and other control keys missing from virtual keyboards — full CLI control from your phone.
178
+
179
+ ### Multi-Bot Collaboration
180
+
181
+ Run multiple Lark bots on a single machine, each mapped to a different CLI. In the same group chat, messages are routed via @mention — each bot gets its own isolated CLI process. With a single bot in the group, it responds automatically without @.
182
+
183
+ ### Tmux Persistence
184
+
185
+ When tmux is installed, botmux automatically uses it. CLI processes persist inside tmux sessions — all features work unchanged.
186
+
187
+ **Key benefit: daemon restarts don't interrupt the CLI.** During `botmux restart`, the worker process exits but the tmux session (and the CLI inside it) keeps running. The next incoming message triggers a re-attach — no `--resume` context reload needed.
188
+
189
+ ```bash
190
+ # Recommended: interactive session picker — select and attach to tmux
191
+ npx botmux list
192
+
193
+ # Or manually attach (session name = bmx-<first 8 chars of session ID>)
194
+ tmux attach -t bmx-<first-8-chars-of-session-id>
195
+ # Ctrl+B, D to detach — CLI keeps running
196
+
197
+ # Force pure pty mode (disable tmux)
198
+ BACKEND_TYPE=pty botmux start
199
+ ```
200
+
201
+ `botmux list` provides an interactive TUI showing all active sessions with ID, title, working directory, PID, uptime, and status. Use arrow keys to select and Enter to attach. Use `botmux list --plain` for plain-text table output suitable for scripting.
202
+
203
+ **Session naming:** `bmx-<first 8 chars of session UUID>`
204
+
205
+ **Lifecycle:**
206
+
207
+ | Event | tmux session | CLI process |
208
+ |-------|-------------|-------------|
209
+ | `botmux restart` | Survives | Survives (re-attaches on next message) |
210
+ | `/close` or close button | Destroyed | Terminated (SIGHUP) |
211
+ | CLI exits / crashes | Closes with it | Already exited (auto-restart creates new session) |
212
+
213
+ ### Scheduled Tasks
214
+
215
+ Create recurring tasks with natural language:
216
+
217
+ ```
218
+ /schedule every day at 17:50 check AI news
219
+ /schedule weekdays at 9:00 run health check
220
+ /schedule every Monday at 10:00 generate weekly report
221
+ ```
222
+
223
+ ### MCP Integration
224
+
225
+ botmux exposes MCP tools so the CLI can interact with Lark directly:
226
+
227
+ - Reply to the current Lark thread
228
+ - Read message history from the thread
229
+ - Add emoji reactions to messages
230
+
231
+ ---
232
+
233
+ ## Usage
234
+
235
+ ### Workflow
236
+
237
+ 1. Send a message in your Lark topic group to create a new thread
238
+ 2. The bot shows a repo selection card — pick a project or click "Start directly"
239
+ 3. The CLI spawns in the selected directory
240
+ 4. A live streaming card appears in the thread, showing real-time terminal output with markdown rendering
241
+ 5. Each reply creates a new streaming card for that turn; previous cards freeze at their last state
242
+ 6. Click "Get Write Link" on the card to receive a write-enabled terminal URL via DM
243
+ 7. The CLI replies in the thread via MCP tools
244
+
245
+ ### Slash Commands
64
246
 
65
247
  | Command | Description |
66
248
  |---------|-------------|
67
- | `botmux setup` | Interactive setup (first-time or add bots) |
68
- | `botmux start` | Start daemon (PM2 managed) |
69
- | `botmux stop` | Stop daemon |
70
- | `botmux restart` | Restart daemon (auto-restores active sessions) |
71
- | `botmux logs` | View daemon logs (`--lines N` for more) |
72
- | `botmux status` | Show daemon status |
73
- | `botmux upgrade` | Upgrade to latest version |
74
- | `botmux list` | List all active sessions (alias: `ls`) |
75
- | `botmux delete <id>` | Close a session by ID prefix (alias: `del`/`rm`) |
76
- | `botmux delete all` | Close all active sessions |
77
- | `botmux delete stopped` | Clean up zombie sessions with dead processes |
249
+ | `/repo` | Show project selector card |
250
+ | `/repo <N>` | Switch to Nth project from last scan |
251
+ | `/skip` | Skip repo selection, start session directly |
252
+ | `/cd <path>` | Change working directory |
253
+ | `/status` | Show session info (uptime, terminal URL, etc.) |
254
+ | `/cost` | Show token usage and estimated cost |
255
+ | `/restart` | Restart CLI process |
256
+ | `/close` | Close session and terminate CLI |
257
+ | `/clear` | Clear context (new session, same thread) |
258
+ | `/schedule` | Manage scheduled tasks |
259
+ | `/help` | Show available commands |
260
+
261
+ ### Scheduled Task Management
262
+
263
+ ```
264
+ /schedule list
265
+ /schedule remove <id>
266
+ /schedule enable <id>
267
+ /schedule disable <id>
268
+ /schedule run <id>
269
+ ```
270
+
271
+ ---
78
272
 
79
273
  ## Configuration
80
274
 
81
275
  Configure bots via `~/.botmux/bots.json`. Run `botmux setup` to create it interactively, or edit manually.
82
276
 
83
- Supports running multiple Lark bots on a single machine, each mapped to a different CLI. Multiple bots in the same group chat route messages via @mention; a single bot responds automatically without @.
84
-
85
277
  ```bash
86
278
  # Interactive setup
87
279
  botmux setup
@@ -130,7 +322,7 @@ botmux setup
130
322
  | `SESSION_DATA_DIR` | `~/.botmux/data` | Where sessions and queues are stored |
131
323
  | `DEBUG` | _(unset)_ | Set to `1` for debug logging |
132
324
 
133
- ## File Locations
325
+ ### File Locations
134
326
 
135
327
  | Path | Description |
136
328
  |------|-------------|
@@ -138,110 +330,25 @@ botmux setup
138
330
  | `~/.botmux/data/` | Session data, message queues |
139
331
  | `~/.botmux/logs/` | Daemon logs |
140
332
 
141
- ## Usage
142
-
143
- ### Workflow
144
-
145
- 1. Send a message in your Lark topic group to create a new thread
146
- 2. The bot shows a repo selection card — pick a project or click "Start directly"
147
- 3. Claude Code spawns in the selected directory
148
- 4. A live streaming card appears in the thread, showing real-time terminal output with markdown rendering
149
- 5. Each reply creates a new streaming card for that turn; previous cards freeze at their last state
150
- 6. Click "🔑 Get Write Link" on the card to receive a write-enabled terminal URL via DM
151
- 7. Claude replies in the thread via MCP tools
333
+ ---
152
334
 
153
- ### Slash Commands
335
+ ## CLI Commands
154
336
 
155
337
  | Command | Description |
156
338
  |---------|-------------|
157
- | `/repo` | Show project selector card |
158
- | `/repo <N>` | Switch to Nth project from last scan |
159
- | `/skip` | Skip repo selection, start session directly |
160
- | `/cd <path>` | Change working directory |
161
- | `/status` | Show session info (uptime, terminal URL, etc.) |
162
- | `/cost` | Show token usage and estimated cost |
163
- | `/restart` | Restart Claude process |
164
- | `/close` | Close session and terminate Claude |
165
- | `/clear` | Clear context (new session, same thread) |
166
- | `/schedule` | Manage scheduled tasks |
167
- | `/help` | Show available commands |
168
-
169
- ### Scheduled Tasks
170
-
171
- Create recurring tasks with natural language:
172
-
173
- ```
174
- /schedule every day at 17:50 check AI news
175
- /schedule weekdays at 9:00 run health check
176
- /schedule every Monday at 10:00 generate weekly report
177
- ```
178
-
179
- Manage tasks:
180
-
181
- ```
182
- /schedule list
183
- /schedule remove <id>
184
- /schedule enable <id>
185
- /schedule disable <id>
186
- /schedule run <id>
187
- ```
188
-
189
- ### Streaming Cards
190
-
191
- Each conversation turn gets a live-updating Feishu card that shows:
192
-
193
- - Real-time terminal output (rendered via headless xterm + Feishu Card v2 markdown)
194
- - Status indicator: 🟡 Starting > 🔵 Working > 🟢 Idle
195
- - Action buttons: Open Terminal, Get Write Link, Restart Claude, Close Session
196
-
197
- The card content is captured from a headless xterm terminal that filters out TUI chrome (logo, status bar, prompts, box-drawing characters) and shows only Claude's actual work output.
198
-
199
- ### Web Terminal
200
-
201
- <p align="center">
202
- <img src="gif/web_terminal.gif" alt="Web terminal live output" width="600">
203
- </p>
204
-
205
- Each session exposes a web terminal at `http://<WEB_EXTERNAL_HOST>:<port>`.
206
-
207
- - **Read-only link** — shown on the streaming card in the group thread
208
- - **Write-enabled link** — sent via DM on demand (click "🔑 Get Write Link" on the card)
209
-
210
- Features: xterm.js with fit/unicode11/web-links addons, TokyoNight theme, scrollback buffer. On mobile/tablet, a floating shortcut toolbar provides Esc, Ctrl+C, Tab, arrow keys and other control keys missing from virtual keyboards, with automatic keyboard avoidance.
211
-
212
- ### Tmux Persistent Sessions
213
-
214
- <p align="center">
215
- <img src="gif/tmux.gif" alt="botmux list — interactive tmux session management" width="600">
216
- </p>
217
-
218
- When tmux is installed, botmux automatically uses the tmux backend. CLI processes run inside tmux sessions while the daemon attaches via node-pty to capture output — streaming cards, idle detection, and web terminal all work unchanged.
219
-
220
- **Key benefit: daemon restarts don't interrupt the CLI.** During `botmux restart`, the worker process exits but the tmux session (and the CLI inside it) keeps running. The next incoming message triggers a re-attach — no `--resume` context reload needed.
221
-
222
- ```bash
223
- # Recommended: interactive session picker — select and attach to tmux
224
- npx botmux list
225
-
226
- # Or manually attach (session name = bmx-<first 8 chars of session ID>)
227
- tmux attach -t bmx-<first-8-chars-of-session-id>
228
- # Ctrl+B, D to detach — CLI keeps running
229
-
230
- # Force pure pty mode (disable tmux)
231
- BACKEND_TYPE=pty botmux start
232
- ```
233
-
234
- `botmux list` provides an interactive TUI showing all active sessions with ID, title, working directory, PID, uptime, and status. Use arrow keys to select and Enter to attach. Use `botmux list --plain` for plain-text table output suitable for scripting.
235
-
236
- **Session naming:** `bmx-<first 8 chars of session UUID>`
237
-
238
- **Lifecycle:**
339
+ | `botmux setup` | Interactive setup (first-time or add bots) |
340
+ | `botmux start` | Start daemon (PM2 managed) |
341
+ | `botmux stop` | Stop daemon |
342
+ | `botmux restart` | Restart daemon (auto-restores active sessions) |
343
+ | `botmux logs` | View daemon logs (`--lines N` for more) |
344
+ | `botmux status` | Show daemon status |
345
+ | `botmux upgrade` | Upgrade to latest version |
346
+ | `botmux list` | List all active sessions (alias: `ls`) |
347
+ | `botmux delete <id>` | Close a session by ID prefix (alias: `del`/`rm`) |
348
+ | `botmux delete all` | Close all active sessions |
349
+ | `botmux delete stopped` | Clean up zombie sessions with dead processes |
239
350
 
240
- | Event | tmux session | CLI process |
241
- |-------|-------------|-------------|
242
- | `botmux restart` | Survives | Survives (re-attaches on next message) |
243
- | `/close` or close button | Destroyed | Terminated (SIGHUP) |
244
- | CLI exits / crashes | Closes with it | Already exited (auto-restart creates new session) |
351
+ ---
245
352
 
246
353
  ## Contributing
247
354