Files
codewhale/integrations/feishu-bridge
yuanchenglu 82499e1c20 feat(feishu): add /model command for per-chat model switching
The bridge only supported a single global model (DEEPSEEK_MODEL env /
default_text_model in config.toml).  Users who wanted a different model
for a particular Feishu group had to restart the bridge with a different
env var — impractical and disruptive.

This commit adds per-chat model switching so users in a group chat can
run "/model <name>" to switch the model for all future threads and
turns in that chat, without affecting other chats.

Changes:

- **lib.mjs — commandAction()**: handle "model" command → { kind:
  "set_model", modelName }.

- **index.mjs**:
  - setChatModel(chatId, modelName): store/clear per-chat model in the
    thread store.  "/model default" resets to the bridge-level default.
  - ensureThread(): read per-chat model from store when creating a
    new runtime thread; fall back to config.model.
  - runPrompt(): read per-chat model for each turn submission
    (independent of the thread-creation model), so a /model change
    takes effect on the very next message.

Usage:
  /model deepseek-v4-flash      — switch this chat to Flash
  /model deepseek-v4-pro        — switch this chat to Pro
  /model default                — reset to bridge default

Resolution priority (per-chat): global default < per-chat /model.

/ 新增 /model 命令,支持按飞书群设置独立模型。
/ 群内输入 /model <name> 切换,/model default 恢复全局默认。
2026-05-26 09:52:53 +08:00
..

Feishu / Lark Bridge

This bridge lets a Feishu or Lark chat control a local codewhale serve --http runtime from a phone. It uses the official Lark/Feishu Node SDK long-connection mode, so the first version does not need a public webhook URL.

Security model:

  • codewhale serve --http stays bound to 127.0.0.1.
  • /v1/* runtime calls use DEEPSEEK_RUNTIME_TOKEN.
  • Feishu/Lark chats must be allowlisted unless DEEPSEEK_ALLOW_UNLISTED=true is set for first pairing.
  • Direct messages are the intended MVP control surface. Group chat control is disabled unless FEISHU_ALLOW_GROUPS=true.
  • Tool approvals are text commands: /allow <approval_id> or /deny <approval_id>.

Setup

cd /opt/codewhale/bridge
npm install --omit=dev
cp .env.example /etc/deepseek/feishu-bridge.env
sudoedit /etc/deepseek/feishu-bridge.env
node src/index.mjs

Validate the env files before starting the service:

npm run validate:config -- \
  --env /etc/deepseek/feishu-bridge.env \
  --runtime-env /etc/deepseek/runtime.env \
  --workspace-root /opt/whalebro \
  --check-filesystem

For a Tencent Lighthouse deployment, use:

sudo systemctl enable --now codewhale-runtime codewhale-feishu-bridge
sudo journalctl -u codewhale-feishu-bridge -f

Commands

  • /status
  • /threads
  • /new
  • /resume <thread_id>
  • /interrupt
  • /compact
  • /allow <approval_id> [remember]
  • /deny <approval_id>

Anything else is sent as a prompt. If group control is explicitly enabled, messages must start with /ds by default, for example:

/ds check git status and tell me what is dirty