Architecture overview
botmux is a thin orchestration layer that translates "Lark events" into "input/output for CLI processes". Core processes and modules:
Process model
The production form is one daemon process per bot. Multi-bot = multiple daemons, fully isolated processes that don't interfere with each other.
Module structure
Data flow
- Lark pushes
im.message.receive_v1→ event-dispatcher parses it and determines ownership (@mention / topic / group permissions). - command-handler intercepts
/xxxslash commands; non-command messages are handed to the session. - New topic → worker-pool spawns a worker; existing session → reuse it and write the message to the CLI's stdin.
- The worker continuously reads PTY output, converts it to Markdown via terminal-renderer, and updates the streaming card.
- The CLI proactively sends messages to the topic via injected Skills / commands like
botmux send.
Key point: the worker and the CLI are decoupled through the backend (PTY or tmux). With the tmux backend, when the daemon/worker restarts the CLI process stays alive inside tmux, and the next message automatically re-attaches — no need to reload context with --resume. See Persistent tmux sessions for details.