feat(lark): supports CardKit streaming output for feishu (#5777)

* feat(lark): 支持飞书 CardKit 流式输出

* refactor(lark): extract streaming fallback logic and deduplicate final text update

* fix(lark): 修复流式输出竞态条件及增强健壮性

- 修复 sender loop 中 delta 快照竟态: await 期间 delta 被 generator
  更新导致 last_sent 记录了未发送的值, 造成输出卡在最后一段
- send_streaming 入口增加 platform_meta 守卫, 未启用时直接回退
- _fallback_send_streaming 移除对已耗尽 generator 的 super() 调用,
  改为内联父类副作用 (Metric.upload + _has_send_oper)
- Metric.upload 统一改为 await, 确保指标上报在方法返回前完成
- 装饰器 support_streaming_message 改为 False, 与 meta() 动态配置对齐
- i18n hint 补充提示: 需在「AI 配置 → 其他配置」中开启流式输出

* chore(lark): 收口配置

* docs(lark): update streaming output instructions and client version requirements

---------

Co-authored-by: bread-ovo <2570425204@qq.com>
Co-authored-by: Soulter <905617992@qq.com>
This commit is contained in:
camera-2018
2026-03-10 19:40:46 +08:00
committed by GitHub
parent 1d26b96d90
commit ec21cb13d3
6 changed files with 274 additions and 10 deletions
+6
View File
@@ -14,6 +14,10 @@
Proactive message push: Supported.
Streaming output: Supported. You must enable the `Create and update cards (cardkit:card:write)` permission for your app in the Lark Developer Console.
The Lark client version must be >= 7.20. Lower versions only display the title and an upgrade prompt.
## Creating a Bot
Navigate to the [Developer Console](https://open.feishu.cn/app) and create a custom enterprise application.
@@ -88,6 +92,8 @@ Next, click on "Permission Management," click "Enable Permissions," and enter `i
Enter `im:resource:upload,im:resource` again to enable image upload permissions.
If you want to use streaming output, additionally enable `Create and update cards (cardkit:card:write)`.
The final set of permissions should look like this:
![Final Permissions](https://files.astrbot.app/docs/source/images/lark/image-11.png)
+6
View File
@@ -14,6 +14,10 @@
主动消息推送:支持。
流式输出:支持。需要在飞书开发者后台为应用开通 `创建与更新卡片(cardkit:card:write)` 权限。
飞书客户端版本需 >= 7.20。低版本客户端将只显示标题和升级提示。
## 创建机器人
前往 [开发者后台](https://open.feishu.cn/app) ,创建企业自建应用。
@@ -88,6 +92,8 @@
再次输入 `im:resource:upload,im:resource` 开通上传图片相关的权限。
如果需要使用流式输出,请额外开通 `创建与更新卡片(cardkit:card:write)` 权限。
最终开通的权限如下图:
![最终开通的权限](https://files.astrbot.app/docs/source/images/lark/image-11.png)