Files
codewhale/integrations/feishu-bridge
bluth 5e53866cc9 fix(feishu): reply inside thread/topic instead of creating standalone topics (#2148)
When running in a Feishu thread-enabled group (话题群), every bot
response — status messages, approval prompts, streaming progress,
turn results — was sent via the Lark SDK's `create` API which spawns
a new standalone topic.  The user sees a cluttered group with orphan
topics for each intermediate bot message.

Root cause: `sendText()` only called `client.im.message.create()`
with a bare `chat_id`, never passing any reply context.  The Feishu
`reply` API was completely unused.

Fix (two changes, one site each):

1. **lib.mjs — incomingIdentity()**: expose `parentId`, `rootId`,
   `threadId` from the raw Feishu message event so callers can
   determine thread context.  (Not consumed directly yet, but
   available for future use.)

2. **index.mjs**:
   - `handleIncomingMessage()`: store the latest incoming
     `messageId` as `replyToMessageId` in the per-chat thread store.
   - `sendText()`: look up `replyToMessageId` from the thread store;
     when present, call `client.im.message.reply()` instead of
     `create()`.  This keeps ALL bot responses nested under the
     original user message inside the same topic.

No config changes needed.  New chats automatically start using the
reply path; existing chats without a `replyToMessageId` in the store
fall back to the old `create` behaviour.

/ 修复飞书话题群中 bot 消息新建独立话题的问题。所有回复改为使用 reply API
/ 在原话题内嵌套回复,而非通过 create API 创建新话题。
2026-05-26 10:29:08 -05: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