npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@theclawlab/xgw-plugin-feishu

v2.1.0

Published

Feishu/Lark channel plugin for xgw

Downloads

124

Readme

xgw-plugin-feishu

飞书(Feishu / Lark)渠道插件,为 xgw 网关提供飞书 IM Bot 接入能力。

通过飞书 WebSocket 长连接接收消息,无需公网 IP,部署简单。

功能

  • WebSocket 长连接接收飞书消息(SDK 内置自动重连)
  • 支持单聊(p2p)和群聊(group)
  • 群聊可配置是否需要 @bot 才触发
  • 收到消息立即添加 👀 reaction,表示已收到
  • 真正的流式响应:通过飞书 CardKit API 创建 streaming card,实时更新内容
  • 进度状态(thinking / tool_call 等)在同一张卡片内更新,无需额外消息
  • 凭证验证(pair):自动获取 bot open_id

安装

npm install @theclawlab/xgw-plugin-feishu

飞书应用配置

使用企业自建应用,需要以下凭证:

| 凭证 | 说明 | |------|------| | appId | 应用 ID(cli_xxxx) | | appSecret | 应用密钥 |

所需权限:

  • im:message — 获取与发送消息
  • im:message:send_as_bot — 以机器人身份发送消息

在飞书开发者后台开启 WebSocket 模式(事件订阅 → 长连接),订阅 im.message.receive_v1 事件。

xgw 配置

config.yamlchannels 中添加:

channels:
  - id: feishu-main
    type: feishu
    paired: true
    pair_mode: ws
    appId: "cli_xxxx"
    appSecret: "xxxx"
    domain: feishu          # feishu(默认)或 lark(国际版)
    requireMention: true    # 群聊是否需要 @bot,默认 true
    streamingThrottleMs: 100  # streaming card 更新节流,默认 100ms

配置字段

| 字段 | 类型 | 必需 | 默认值 | 说明 | |------|------|:----:|--------|------| | appId | string | ✅ | — | 飞书应用 ID | | appSecret | string | ✅ | — | 飞书应用密钥 | | domain | 'feishu' | 'lark' | URL | — | 'feishu' | API 域名 | | requireMention | boolean | — | true | 群聊是否需要 @bot | | streamingThrottleMs | number | — | 100 | Streaming card 更新节流间隔(ms) |

消息行为

收到消息时: 立即在原消息上添加 👀 reaction,表示已收到(best-effort,失败不影响处理)。

Streaming 流程:

  1. 收到第一个 progressstream: 'chunk' 时,通过 CardKit API 创建 streaming card 并发送 interactive 消息
  2. 后续 chunk 通过 PUT /cardkit/v1/cards/:id/elements/content/content 实时更新卡片内容(节流)
  3. stream: 'end' 时写入最终文本,然后 PATCH /cardkit/v1/cards/:id/settings 关闭 streaming mode

进度状态映射:

| progress | 显示文本 | |----------|---------| | thinking | 🤔 思考中... | | tool_call | 🔧 调用工具... | | tool_result | 📋 处理结果... | | compact_start | 🗜️ 压缩上下文... | | compact_end | ✅ 上下文已压缩 |

session_id 策略:

  • 单聊(p2p):session_id = sender open_id
  • 群聊(group):session_id = chat_id

消息类型支持:

| 飞书消息类型 | 处理方式 | |-------------|---------| | text | 直接提取文本 | | post | 递归提取文本节点拼接 | | image | [image] 占位符 | | file | [file: name] 占位符 | | 其他 | [unsupported: type] 占位符 |

Streaming: 使用飞书 CardKit API 实现真正的流式更新,每个 session 维护一个 streaming card,chunk 实时写入,stream: 'end' 时关闭 streaming mode。

开发

npm install
npm run build       # 构建
npm run test        # 单次测试
npm run dev         # watch 模式构建

与 OpenClaw Feishu Extension 的差异

本插件是面向 xgw 的最小化实现,不包含 OpenClaw 的 pairing 流程、Rich Card、多账号、附件处理等功能。详见 SPEC.md

License

MIT