Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: 飞书 channel 文档更新&rail extensions提示信息修改

ray_led869860ad816
diff --git a/docs/en/Channels.md b/docs/en/Channels.md
index 05a9260088..15cb3580e0 100644
--- a/docs/en/Channels.md
+++ b/docs/en/Channels.md
@@ -133,7 +133,9 @@ Option 2: On a Harmony phone, open the published agent in the Xiaoyi app.
2. **Add events**:
- `im.message.receive_v1`
- `im.message.message_read_v1` (optional)
-3. If encryption is on, save **Encrypt Key**.
+3. **Add trigger**:
+ - `card.action.trigger`
+4. If encryption is on, save **Encrypt Key**.
![Feishu events](../assets/images/feishu_app_events.png)
diff --git "a/docs/zh/\351\242\221\351\201\223.md" "b/docs/zh/\351\242\221\351\201\223.md"
index 1fa6dbf7cf..9bec869c9e 100644
--- "a/docs/zh/\351\242\221\351\201\223.md"
+++ "b/docs/zh/\351\242\221\351\201\223.md"
@@ -148,7 +148,9 @@ channels:
2. **添加事件**:
- `im.message.receive_v1`(接收消息事件) 。
- `im.message.message_read_v1`(消息已读) 。
-3. (可选)**配置加密策略**:如果启用了加密,需要保存 `Encrypt Key`。
+3. **添加回调**
+ - `card.action.trigger`(卡片回传交互)
+4. (可选)**配置加密策略**:如果启用了加密,需要保存 `Encrypt Key`。
![image-20260312203514012](../assets/images/feishu_app_events.png)
diff --git a/jiuwenclaw/agentserver/deep_agent/rails/stream_event_rail.py b/jiuwenclaw/agentserver/deep_agent/rails/stream_event_rail.py
index 05f6baa83b..780332aa22 100644
--- a/jiuwenclaw/agentserver/deep_agent/rails/stream_event_rail.py
+++ b/jiuwenclaw/agentserver/deep_agent/rails/stream_event_rail.py
@@ -323,9 +323,6 @@ class JiuClawStreamEventRail(DeepAgentRail):
else:
uncompressed.append(message)
- if not compression_to_show:
- return
-
try:
try:
encoding = tiktoken.get_encoding("cl100k_base")
diff --git a/jiuwenclaw/channel/feishu.py b/jiuwenclaw/channel/feishu.py
index d80b5873db..6de5d0701c 100644
--- a/jiuwenclaw/channel/feishu.py
+++ b/jiuwenclaw/channel/feishu.py
@@ -198,6 +198,8 @@ class FeishuChannel(BaseChannel):
# 按 request_id 记录已通过 chat.file 发送的文件路径,用于兜底去重
# key=request_id, value=set of absolute file paths
self._sent_file_paths_by_req: dict[str, set[str]] = {}
+ # 自演进用户确认卡片, key=request_id, value=query card
+ self._user_question_card: dict[str, dict] = {}
@property
def channel_id(self) -> str:
@@ -1905,6 +1907,7 @@ class FeishuChannel(BaseChannel):
"template": request_id # 使用 template 字段存储 request_id
}
+ self._user_question_card[request_id] = card
# 发送卡片
receive_id, id_type = self._extract_receive_info(msg)
card_json = json.dumps(card, ensure_ascii=False)
@@ -2121,6 +2124,37 @@ class FeishuChannel(BaseChannel):
token = event.token or ""
action_value = action.value or ""
+ # 返回成功的响应:更新卡片去除按钮,显示已选择的内容
+ selected_label = action_value.get("label", "已选择")
+ request_id = action_value.get("request_id", "")
+ if not request_id or request_id not in self._user_question_card:
+ card_data = {
+ "elements": [
+ {
+ "tag": "div",
+ "text": {
+ "tag": "lark_md",
+ "content": f"您已选择:**{selected_label}**"
+ }
+ }
+ ]
+ }
+ header = {}
+ else:
+ card_data = self._user_question_card[request_id]
+ content = card_data["elements"][0].get("text", {}).get("content", "") \
+ if "elements" in card_data and len(card_data["elements"]) > 0 else ""
+ header = card_data.get("header", {})
+ card_data = {
+ "elements": [{
+ "tag": "div",
+ "text": {
+ "tag": "lark_md",
+ "content": f"{content} <br> <br> 您已选择:**{selected_label}**"
+ }
+ }]
+ }
+ self._user_question_card.pop(request_id)
# 获取用户和上下文信息
operator_id = event.operator.open_id if event.operator and event.operator.open_id else ""
@@ -2138,40 +2172,23 @@ class FeishuChannel(BaseChannel):
self._main_loop
)
- # 返回成功的响应:更新卡片去除按钮,显示已选择的内容
- selected_label = action_value.get("label", "已选择")
-
- # 构建更新后的卡片数据,移除按钮,显示已选择
- card_data = {
- "type": "raw",
- "data": {
- "schema": "2.0",
- "config": {
- "update_multi": True,
- "wide_screen_mode": True
- },
- "body": {
- "elements": [
- {
- "tag": "div",
- "text": {
- "tag": "lark_md",
- "content": f"您已选择:**{selected_label}**"
- }
- }
- ]
- }
- }
- }
-
- # 构建响应对象
# 返回成功的响应:更新卡片去除按钮,提示已接受
response = {
"toast": {
"type": "info",
"content": "已收到您的选择"
},
- "card": card_data
+ "card": {
+ "type": "raw",
+ "data": {
+ "schema": "2.0",
+ "config": {
+ "update_multi": True,
+ },
+ "body": card_data,
+ "header": header
+ }
+ }
}
return P2CardActionTriggerResponse(response)
except Exception as e:
diff --git a/jiuwenclaw/web/src/components/ExtensionsPanel/index.tsx b/jiuwenclaw/web/src/components/ExtensionsPanel/index.tsx
index b53bd8a2a1..50ccdab407 100644
--- a/jiuwenclaw/web/src/components/ExtensionsPanel/index.tsx
+++ b/jiuwenclaw/web/src/components/ExtensionsPanel/index.tsx
@@ -275,12 +275,6 @@ export function ExtensionsPanel({ isConnected }: ExtensionsPanelProps) {
<li>
{t(
'extensions.help2',
- '修改扩展状态后需要重新加载 Agent 配置才能生效'
- )}
- </li>
- <li>
- {t(
- 'extensions.help3',
'扩展文件夹会被保存到 ~/.jiuwenclaw/agent/jiuwenclaw_workspace/extensions/ 目录'
)}
</li>
diff --git a/jiuwenclaw/web/src/i18n/locales/en.json b/jiuwenclaw/web/src/i18n/locales/en.json
index 9e32b3d1c2..151a0c4b1a 100644
--- a/jiuwenclaw/web/src/i18n/locales/en.json
+++ b/jiuwenclaw/web/src/i18n/locales/en.json
@@ -900,8 +900,7 @@
"helpTitle": "Usage Guide",
"help0": "Extension folder must contain rail.py as the entry file",
"help1": "Rail extension files must inherit from DeepAgentRail or AgentRail base class",
- "help2": "Changes to extension status require reloading Agent configuration to take effect",
- "help3": "Extension files are saved to ~/.jiuwenclaw/agent/jiuwenclaw_workspace/extensions/ directory"
+ "help2": "Extension files are saved to ~/.jiuwenclaw/agent/jiuwenclaw_workspace/extensions/ directory"
},
"ownerScopes": {
"title": "Avatar Permission",
diff --git a/jiuwenclaw/web/src/i18n/locales/zh.json b/jiuwenclaw/web/src/i18n/locales/zh.json
index 0700341c0a..6d875307c8 100644
--- a/jiuwenclaw/web/src/i18n/locales/zh.json
+++ b/jiuwenclaw/web/src/i18n/locales/zh.json
@@ -900,8 +900,7 @@
"helpTitle": "使用说明",
"help0": "扩展文件夹必须包含 rail.py 作为入口文件",
"help1": "Rail 扩展文件必须继承 DeepAgentRail 或 AgentRail 基类",
- "help2": "修改扩展状态后需要重新加载 Agent 配置才能生效",
- "help3": "扩展文件会被保存到 ~/.jiuwenclaw/agent/jiuwenclaw_workspace/extensions/ 目录"
+ "help2": "扩展文件会被保存到 ~/.jiuwenclaw/agent/jiuwenclaw_workspace/extensions/ 目录"
},
"ownerScopes": {
"title": "分身权限配置",