@openclaw-plugins/feishu-plus 0.1.7-fork.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 m1heng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,560 @@
1
+ # clawd-feishu
2
+
3
+ Feishu/Lark (飞书) channel plugin for [OpenClaw](https://github.com/openclaw/openclaw).
4
+
5
+ > **中文社区资料** - 配置教程、常见问题、使用技巧:[Wiki](https://github.com/m1heng/clawdbot-feishu/wiki)
6
+
7
+ [English](#english) | [中文](#中文)
8
+
9
+ ---
10
+
11
+ Fork from https://github.com/m1heng/clawdbot-feishu
12
+ from @0.1.7
13
+
14
+ ```bash
15
+ openclaw plugins install @openclaw-plugins/feishu-plus
16
+ ```
17
+
18
+ ---
19
+
20
+ ## English
21
+
22
+ ### Installation
23
+
24
+ ```bash
25
+ openclaw plugins install @m1heng-clawd/feishu
26
+ ```
27
+
28
+ ### Upgrade
29
+
30
+ ```bash
31
+ openclaw plugins update feishu
32
+ ```
33
+
34
+ ### Configuration
35
+
36
+ 1. Create a self-built app on [Feishu Open Platform](https://open.feishu.cn)
37
+ 2. Get your App ID and App Secret from the Credentials page
38
+ 3. Enable required permissions (see below)
39
+ 4. **Configure event subscriptions** (see below) ⚠️ Important
40
+ 5. Configure the plugin:
41
+
42
+ #### Required Permissions
43
+
44
+ | Permission | Scope | Description |
45
+ |------------|-------|-------------|
46
+ | `im:message` | Messaging | Send and receive messages |
47
+ | `im:message.p2p_msg:readonly` | DM | Read direct messages to bot |
48
+ | `im:message.group_at_msg:readonly` | Group | Receive @mention messages in groups |
49
+ | `im:message:send_as_bot` | Send | Send messages as the bot |
50
+ | `im:resource` | Media | Upload and download images/files |
51
+
52
+ #### Optional Permissions
53
+
54
+ | Permission | Scope | Description |
55
+ |------------|-------|-------------|
56
+ | `contact:user.base:readonly` | User info | Get basic user info (required to resolve sender display names for speaker attribution) |
57
+ | `im:message.group_msg` | Group | Read all group messages (sensitive) |
58
+ | `im:message:readonly` | Read | Get message history |
59
+ | `im:message:update` | Edit | Update/edit sent messages |
60
+ | `im:message:recall` | Recall | Recall sent messages |
61
+ | `im:message.reactions:read` | Reactions | View message reactions |
62
+
63
+ #### Tool Permissions
64
+
65
+ **Read-only** (minimum required):
66
+
67
+ | Permission | Tool | Description |
68
+ |------------|------|-------------|
69
+ | `docx:document:readonly` | `feishu_doc` | Read documents |
70
+ | `drive:drive:readonly` | `feishu_drive` | List folders, get file info |
71
+ | `wiki:wiki:readonly` | `feishu_wiki` | List spaces, list nodes, get node info, search |
72
+ | `bitable:app:readonly` | `feishu_bitable` | Read bitable records and fields |
73
+
74
+ **Read-write** (optional, for create/edit/delete operations):
75
+
76
+ | Permission | Tool | Description |
77
+ |------------|------|-------------|
78
+ | `docx:document` | `feishu_doc` | Create/edit documents |
79
+ | `docx:document.block:convert` | `feishu_doc` | Markdown to blocks conversion (required for write/append) |
80
+ | `drive:drive` | `feishu_doc`, `feishu_drive` | Upload images to documents, create folders, move/delete files |
81
+ | `wiki:wiki` | `feishu_wiki` | Create/move/rename wiki nodes |
82
+ | `bitable:app` | `feishu_bitable` | Create/update bitable records |
83
+
84
+ #### Drive Access ⚠️
85
+
86
+ > **Important:** Bots don't have their own "My Space" (root folder). Bots can only access files/folders that have been **shared with them**.
87
+
88
+ To let the bot manage files:
89
+ 1. Create a folder in your Feishu Drive
90
+ 2. Right-click the folder → **Share** → search for your bot name
91
+ 3. Grant appropriate permission (view/edit)
92
+
93
+ Without this step, `feishu_drive` operations like `create_folder` will fail because the bot has no root folder to create in.
94
+
95
+ #### Wiki Space Access ⚠️
96
+
97
+ > **Important:** API permissions alone are not enough for wiki access. You must also add the bot to each wiki space.
98
+
99
+ 1. Open the wiki space you want the bot to access
100
+ 2. Click **Settings** (gear icon) → **Members**
101
+ 3. Click **Add Member** → search for your bot name
102
+ 4. Select appropriate permission level (view/edit)
103
+
104
+ Without this step, `feishu_wiki` will return empty results even with correct API permissions.
105
+
106
+ Reference: [Wiki FAQ - How to add app to wiki](https://open.feishu.cn/document/server-docs/docs/wiki-v2/wiki-qa#a40ad4ca)
107
+
108
+ #### Bitable Access ⚠️
109
+
110
+ > **Important:** Like other resources, the bot can only access bitables that have been **shared with it**.
111
+
112
+ To let the bot access a bitable:
113
+ 1. Open the bitable you want the bot to access
114
+ 2. Click **Share** button → search for your bot name
115
+ 3. Grant appropriate permission (view/edit)
116
+
117
+ The `feishu_bitable` tools support both URL formats:
118
+ - `/base/XXX?table=YYY` - Standard bitable URL
119
+ - `/wiki/XXX?table=YYY` - Bitable embedded in wiki (auto-converts to app_token)
120
+
121
+ #### Event Subscriptions ⚠️
122
+
123
+ > **This is the most commonly missed configuration!** If the bot can send messages but cannot receive them, check this section.
124
+
125
+ In the Feishu Open Platform console, go to **Events & Callbacks**:
126
+
127
+ 1. **Event configuration**: Select **Long connection** (recommended)
128
+ 2. **Add event subscriptions**:
129
+
130
+ | Event | Description |
131
+ |-------|-------------|
132
+ | `im.message.receive_v1` | Receive messages (required) |
133
+ | `im.message.message_read_v1` | Message read receipts |
134
+ | `im.chat.member.bot.added_v1` | Bot added to group |
135
+ | `im.chat.member.bot.deleted_v1` | Bot removed from group |
136
+
137
+ 3. Ensure the event permissions are approved
138
+
139
+ ```bash
140
+ openclaw config set channels.feishu.appId "cli_xxxxx"
141
+ openclaw config set channels.feishu.appSecret "your_app_secret"
142
+ openclaw config set channels.feishu.enabled true
143
+ ```
144
+
145
+ ### Configuration Options
146
+
147
+ ```yaml
148
+ channels:
149
+ feishu:
150
+ enabled: true
151
+ appId: "cli_xxxxx"
152
+ appSecret: "secret"
153
+ # Domain: "feishu" (China), "lark" (International), or custom URL
154
+ domain: "feishu" # or "https://open.xxx.cn" for private deployment
155
+ # Connection mode: "websocket" (recommended) or "webhook"
156
+ connectionMode: "websocket"
157
+ # Webhook path (default: "/feishu/events")
158
+ webhookPath: "/feishu/events"
159
+ # DM policy: "pairing" | "open" | "allowlist"
160
+ dmPolicy: "pairing"
161
+ # Group policy: "open" | "allowlist" | "disabled"
162
+ groupPolicy: "allowlist"
163
+ # Require @mention in groups
164
+ requireMention: true
165
+ # Max media size in MB (default: 30)
166
+ mediaMaxMb: 30
167
+ # Render mode for bot replies: "auto" | "raw" | "card"
168
+ renderMode: "auto"
169
+ ```
170
+
171
+ #### Render Mode
172
+
173
+ | Mode | Description |
174
+ |------|-------------|
175
+ | `auto` | (Default) Automatically detect: use card for messages with code blocks or tables, plain text otherwise. |
176
+ | `raw` | Always send replies as plain text. Markdown tables are converted to ASCII. |
177
+ | `card` | Always send replies as interactive cards with full markdown rendering (syntax highlighting, tables, clickable links). |
178
+
179
+ #### Dynamic Agent Creation (Multi-User Workspace Isolation)
180
+
181
+ When enabled, each DM user automatically gets their own isolated agent instance with a dedicated workspace. This provides complete isolation including separate conversation history, memory (MEMORY.md), and workspace files.
182
+
183
+ ```yaml
184
+ channels:
185
+ feishu:
186
+ dmPolicy: "open"
187
+ allowFrom: ["*"]
188
+ dynamicAgentCreation:
189
+ enabled: true
190
+ # Template for workspace directory ({userId} = OpenID, {agentId} = generated agent ID)
191
+ workspaceTemplate: "~/workspaces/feishu-{agentId}"
192
+ # Template for agent config directory
193
+ agentDirTemplate: "~/.openclaw/agents/{agentId}/agent"
194
+ # Optional: limit total number of dynamic agents
195
+ maxAgents: 100
196
+
197
+ session:
198
+ # Also set dmScope for session isolation (conversation history)
199
+ dmScope: "per-peer"
200
+ ```
201
+
202
+ | Option | Description |
203
+ |--------|-------------|
204
+ | `enabled` | Enable dynamic agent creation for DM users |
205
+ | `workspaceTemplate` | Template for workspace path. Supports `{userId}` (OpenID) and `{agentId}` (= `feishu-{openId}`) |
206
+ | `agentDirTemplate` | Template for agent directory path |
207
+ | `maxAgents` | Optional limit on number of dynamic agents |
208
+
209
+ **How it works:**
210
+ 1. When a new user sends a DM, the system creates a new agent entry in `openclaw.json`
211
+ 2. A binding is created to route that user's DM to their dedicated agent
212
+ 3. Workspace and agent directories are created automatically
213
+ 4. Subsequent messages from that user go to their isolated agent
214
+
215
+ **Difference from `dmScope: "per-peer"`:**
216
+ - `dmScope: "per-peer"` only isolates conversation history
217
+ - `dynamicAgentCreation` provides full isolation (workspace, memory, identity, tools)
218
+
219
+ ### Features
220
+
221
+ - WebSocket and Webhook connection modes
222
+ - Direct messages and group chats
223
+ - Message replies and quoted message context
224
+ - **Inbound media support**: AI can see images, read files (PDF, Excel, etc.), and process rich text with embedded images
225
+ - Image and file uploads (outbound)
226
+ - Typing indicator (via emoji reactions)
227
+ - Pairing flow for DM approval
228
+ - User and group directory lookup
229
+ - **Card render mode**: Optional markdown rendering with syntax highlighting
230
+ - **Document tools**: Read, create, and write Feishu documents with markdown (tables not supported due to API limitations)
231
+ - **Wiki tools**: Navigate knowledge bases, list spaces, get node details, search, create/move/rename nodes
232
+ - **Drive tools**: List folders, get file info, create folders, move/delete files
233
+ - **Bitable tools**: Read/write bitable (多维表格) records, supports both `/base/` and `/wiki/` URLs
234
+ - **@mention forwarding**: When you @mention someone in your message, the bot's reply will automatically @mention them too
235
+ - **Permission error notification**: When the bot encounters a Feishu API permission error, it automatically notifies the user with the permission grant URL
236
+ - **Dynamic agent creation**: Each DM user can have their own isolated agent instance with dedicated workspace (optional)
237
+
238
+ #### @Mention Forwarding
239
+
240
+ When you want the bot to @mention someone in its reply, simply @mention them in your message:
241
+
242
+ - **In DM**: `@张三 say hello` → Bot replies with `@张三 Hello!`
243
+ - **In Group**: `@bot @张三 say hello` → Bot replies with `@张三 Hello!`
244
+
245
+ The bot automatically detects @mentions in your message and includes them in its reply. No extra permissions required beyond the standard messaging permissions.
246
+
247
+ ### FAQ
248
+
249
+ #### Bot cannot receive messages
250
+
251
+ Check the following:
252
+ 1. Have you configured **event subscriptions**? (See Event Subscriptions section)
253
+ 2. Is the event configuration set to **long connection**?
254
+ 3. Did you add the `im.message.receive_v1` event?
255
+ 4. Are the permissions approved?
256
+
257
+ #### 403 error when sending messages
258
+
259
+ Ensure `im:message:send_as_bot` permission is approved.
260
+
261
+ #### How to clear history / start new conversation
262
+
263
+ Send `/new` command in the chat.
264
+
265
+ #### Why is the output not streaming
266
+
267
+ Feishu API has rate limits. Streaming updates can easily trigger throttling. We use complete-then-send approach for stability.
268
+
269
+ #### Windows install error `spawn npm ENOENT`
270
+
271
+ If `openclaw plugins install` fails, install manually:
272
+
273
+ ```bash
274
+ # 1. Download the package
275
+ curl -O https://registry.npmjs.org/@m1heng-clawd/feishu/-/feishu-0.1.3.tgz
276
+
277
+ # 2. Install from local file
278
+ openclaw plugins install ./feishu-0.1.3.tgz
279
+ ```
280
+
281
+ #### Cannot find the bot in Feishu
282
+
283
+ 1. Ensure the app is published (at least to test version)
284
+ 2. Search for the bot name in Feishu search box
285
+ 3. Check if your account is in the app's availability scope
286
+
287
+ ---
288
+
289
+ ## 中文
290
+
291
+ ### 安装
292
+
293
+ ```bash
294
+ openclaw plugins install @m1heng-clawd/feishu
295
+ ```
296
+
297
+ ### 升级
298
+
299
+ ```bash
300
+ openclaw plugins update feishu
301
+ ```
302
+
303
+ ### 配置
304
+
305
+ 1. 在 [飞书开放平台](https://open.feishu.cn) 创建自建应用
306
+ 2. 在凭证页面获取 App ID 和 App Secret
307
+ 3. 开启所需权限(见下方)
308
+ 4. **配置事件订阅**(见下方)⚠️ 重要
309
+ 5. 配置插件:
310
+
311
+ #### 必需权限
312
+
313
+ | 权限 | 范围 | 说明 |
314
+ |------|------|------|
315
+ | `im:message` | 消息 | 发送和接收消息 |
316
+ | `im:message.p2p_msg:readonly` | 私聊 | 读取发给机器人的私聊消息 |
317
+ | `im:message.group_at_msg:readonly` | 群聊 | 接收群内 @机器人 的消息 |
318
+ | `im:message:send_as_bot` | 发送 | 以机器人身份发送消息 |
319
+ | `im:resource` | 媒体 | 上传和下载图片/文件 |
320
+
321
+ #### 可选权限
322
+
323
+ | 权限 | 范围 | 说明 |
324
+ |------|------|------|
325
+ | `contact:user.base:readonly` | 用户信息 | 获取用户基本信息(用于解析发送者姓名,避免群聊/私聊把不同人当成同一说话者) |
326
+ | `im:message.group_msg` | 群聊 | 读取所有群消息(敏感) |
327
+ | `im:message:readonly` | 读取 | 获取历史消息 |
328
+ | `im:message:update` | 编辑 | 更新/编辑已发送消息 |
329
+ | `im:message:recall` | 撤回 | 撤回已发送消息 |
330
+ | `im:message.reactions:read` | 表情 | 查看消息表情回复 |
331
+
332
+ #### 工具权限
333
+
334
+ **只读权限**(最低要求):
335
+
336
+ | 权限 | 工具 | 说明 |
337
+ |------|------|------|
338
+ | `docx:document:readonly` | `feishu_doc` | 读取文档 |
339
+ | `drive:drive:readonly` | `feishu_drive` | 列出文件夹、获取文件信息 |
340
+ | `wiki:wiki:readonly` | `feishu_wiki` | 列出空间、列出节点、获取节点详情、搜索 |
341
+ | `bitable:app:readonly` | `feishu_bitable` | 读取多维表格记录和字段 |
342
+
343
+ **读写权限**(可选,用于创建/编辑/删除操作):
344
+
345
+ | 权限 | 工具 | 说明 |
346
+ |------|------|------|
347
+ | `docx:document` | `feishu_doc` | 创建/编辑文档 |
348
+ | `docx:document.block:convert` | `feishu_doc` | Markdown 转 blocks(write/append 必需) |
349
+ | `drive:drive` | `feishu_doc`, `feishu_drive` | 上传图片到文档、创建文件夹、移动/删除文件 |
350
+ | `wiki:wiki` | `feishu_wiki` | 创建/移动/重命名知识库节点 |
351
+ | `bitable:app` | `feishu_bitable` | 创建/更新多维表格记录 |
352
+
353
+ #### 云空间访问权限 ⚠️
354
+
355
+ > **重要:** 机器人没有自己的"我的空间"(根目录)。机器人只能访问**被分享给它的文件/文件夹**。
356
+
357
+ 要让机器人管理文件:
358
+ 1. 在你的飞书云空间创建一个文件夹
359
+ 2. 右键文件夹 → **分享** → 搜索机器人名称
360
+ 3. 授予相应权限(查看/编辑)
361
+
362
+ 如果不做这一步,`feishu_drive` 的 `create_folder` 等操作会失败,因为机器人没有根目录可以创建文件夹。
363
+
364
+ #### 知识库空间权限 ⚠️
365
+
366
+ > **重要:** 仅有 API 权限不够,还需要将机器人添加到知识库空间。
367
+
368
+ 1. 打开需要机器人访问的知识库空间
369
+ 2. 点击 **设置**(齿轮图标)→ **成员管理**
370
+ 3. 点击 **添加成员** → 搜索机器人名称
371
+ 4. 选择权限级别(查看/编辑)
372
+
373
+ 如果不做这一步,即使 API 权限正确,`feishu_wiki` 也会返回空结果。
374
+
375
+ 参考文档:[知识库常见问题 - 如何将应用添加为知识库成员](https://open.feishu.cn/document/server-docs/docs/wiki-v2/wiki-qa#a40ad4ca)
376
+
377
+ #### 多维表格访问权限 ⚠️
378
+
379
+ > **重要:** 与其他资源一样,机器人只能访问**被分享给它的多维表格**。
380
+
381
+ 要让机器人访问多维表格:
382
+ 1. 打开需要机器人访问的多维表格
383
+ 2. 点击 **分享** 按钮 → 搜索机器人名称
384
+ 3. 授予相应权限(查看/编辑)
385
+
386
+ `feishu_bitable` 工具支持两种 URL 格式:
387
+ - `/base/XXX?table=YYY` - 标准多维表格链接
388
+ - `/wiki/XXX?table=YYY` - 嵌入在知识库中的多维表格(自动转换为 app_token)
389
+
390
+ #### 事件订阅 ⚠️
391
+
392
+ > **这是最容易遗漏的配置!** 如果机器人能发消息但收不到消息,请检查此项。
393
+
394
+ 在飞书开放平台的应用后台,进入 **事件与回调** 页面:
395
+
396
+ 1. **事件配置方式**:选择 **使用长连接接收事件**(推荐)
397
+ 2. **添加事件订阅**,勾选以下事件:
398
+
399
+ | 事件 | 说明 |
400
+ |------|------|
401
+ | `im.message.receive_v1` | 接收消息(必需) |
402
+ | `im.message.message_read_v1` | 消息已读回执 |
403
+ | `im.chat.member.bot.added_v1` | 机器人进群 |
404
+ | `im.chat.member.bot.deleted_v1` | 机器人被移出群 |
405
+
406
+ 3. 确保事件订阅的权限已申请并通过审核
407
+
408
+ ```bash
409
+ openclaw config set channels.feishu.appId "cli_xxxxx"
410
+ openclaw config set channels.feishu.appSecret "your_app_secret"
411
+ openclaw config set channels.feishu.enabled true
412
+ ```
413
+
414
+ ### 配置选项
415
+
416
+ ```yaml
417
+ channels:
418
+ feishu:
419
+ enabled: true
420
+ appId: "cli_xxxxx"
421
+ appSecret: "secret"
422
+ # 域名: "feishu" (国内)、"lark" (国际) 或自定义 URL
423
+ domain: "feishu" # 私有化部署可用 "https://open.xxx.cn"
424
+ # 连接模式: "websocket" (推荐) 或 "webhook"
425
+ connectionMode: "websocket"
426
+ # Webhook 路径 (默认: "/feishu/events")
427
+ webhookPath: "/feishu/events"
428
+ # 私聊策略: "pairing" | "open" | "allowlist"
429
+ dmPolicy: "pairing"
430
+ # 群聊策略: "open" | "allowlist" | "disabled"
431
+ groupPolicy: "allowlist"
432
+ # 群聊是否需要 @机器人
433
+ requireMention: true
434
+ # 媒体文件最大大小 (MB, 默认 30)
435
+ mediaMaxMb: 30
436
+ # 回复渲染模式: "auto" | "raw" | "card"
437
+ renderMode: "auto"
438
+ ```
439
+
440
+ #### 渲染模式
441
+
442
+ | 模式 | 说明 |
443
+ |------|------|
444
+ | `auto` | (默认)自动检测:有代码块或表格时用卡片,否则纯文本 |
445
+ | `raw` | 始终纯文本,表格转为 ASCII |
446
+ | `card` | 始终使用卡片,支持语法高亮、表格、链接等 |
447
+
448
+ #### 动态 Agent 创建(多用户 Workspace 隔离)
449
+
450
+ 启用后,每个私聊用户会自动获得独立的 agent 实例和专属 workspace。这提供完整的隔离,包括独立的对话历史、记忆(MEMORY.md)和工作区文件。
451
+
452
+ ```yaml
453
+ channels:
454
+ feishu:
455
+ dmPolicy: "open"
456
+ allowFrom: ["*"]
457
+ dynamicAgentCreation:
458
+ enabled: true
459
+ # workspace 目录模板 ({userId} = OpenID, {agentId} = 生成的 agent ID)
460
+ workspaceTemplate: "~/workspaces/feishu-{agentId}"
461
+ # agent 配置目录模板
462
+ agentDirTemplate: "~/.openclaw/agents/{agentId}/agent"
463
+ # 可选:限制动态 agent 总数
464
+ maxAgents: 100
465
+
466
+ session:
467
+ # 同时设置 dmScope 以隔离对话历史
468
+ dmScope: "per-peer"
469
+ ```
470
+
471
+ | 选项 | 说明 |
472
+ |------|------|
473
+ | `enabled` | 是否为私聊用户启用动态 agent 创建 |
474
+ | `workspaceTemplate` | workspace 路径模板,支持 `{userId}`(OpenID)和 `{agentId}`(= `feishu-{openId}`)|
475
+ | `agentDirTemplate` | agent 目录路径模板 |
476
+ | `maxAgents` | 可选,限制动态 agent 的最大数量 |
477
+
478
+ **工作原理:**
479
+ 1. 当新用户发送私聊时,系统在 `openclaw.json` 中创建新的 agent 条目
480
+ 2. 创建 binding 将该用户的私聊路由到专属 agent
481
+ 3. 自动创建 workspace 和 agent 目录
482
+ 4. 该用户后续的消息都会路由到其隔离的 agent
483
+
484
+ **与 `dmScope: "per-peer"` 的区别:**
485
+ - `dmScope: "per-peer"` 仅隔离对话历史
486
+ - `dynamicAgentCreation` 提供完整隔离(workspace、记忆、身份、工具)
487
+
488
+ ### 功能
489
+
490
+ - WebSocket 和 Webhook 连接模式
491
+ - 私聊和群聊
492
+ - 消息回复和引用上下文
493
+ - **入站媒体支持**:AI 可以看到图片、读取文件(PDF、Excel 等)、处理富文本中的嵌入图片
494
+ - 图片和文件上传(出站)
495
+ - 输入指示器(通过表情回复实现)
496
+ - 私聊配对审批流程
497
+ - 用户和群组目录查询
498
+ - **卡片渲染模式**:支持语法高亮的 Markdown 渲染
499
+ - **文档工具**:读取、创建、用 Markdown 写入飞书文档(表格因 API 限制不支持)
500
+ - **知识库工具**:浏览知识库、列出空间、获取节点详情、搜索、创建/移动/重命名节点
501
+ - **云空间工具**:列出文件夹、获取文件信息、创建文件夹、移动/删除文件
502
+ - **多维表格工具**:读写多维表格记录,支持 `/base/` 和 `/wiki/` 两种链接格式
503
+ - **@ 转发功能**:在消息中 @ 某人,机器人的回复会自动 @ 该用户
504
+ - **权限错误提示**:当机器人遇到飞书 API 权限错误时,会自动通知用户并提供权限授权链接
505
+ - **动态 Agent 创建**:每个私聊用户可拥有独立的 agent 实例和专属 workspace(可选)
506
+
507
+ #### @ 转发功能
508
+
509
+ 如果你希望机器人的回复中 @ 某人,只需在你的消息中 @ 他们:
510
+
511
+ - **私聊**:`@张三 跟他问好` → 机器人回复 `@张三 你好!`
512
+ - **群聊**:`@机器人 @张三 跟他问好` → 机器人回复 `@张三 你好!`
513
+
514
+ 机器人会自动检测消息中的 @ 并在回复时带上。无需额外权限。
515
+
516
+ ### 常见问题
517
+
518
+ #### 机器人收不到消息
519
+
520
+ 检查以下配置:
521
+ 1. 是否配置了 **事件订阅**?(见上方事件订阅章节)
522
+ 2. 事件配置方式是否选择了 **长连接**?
523
+ 3. 是否添加了 `im.message.receive_v1` 事件?
524
+ 4. 相关权限是否已申请并审核通过?
525
+
526
+ #### 返回消息时 403 错误
527
+
528
+ 确保已申请 `im:message:send_as_bot` 权限,并且权限已审核通过。
529
+
530
+ #### 如何清理历史会话 / 开启新对话
531
+
532
+ 在聊天中发送 `/new` 命令即可开启新对话。
533
+
534
+ #### 消息为什么不是流式输出
535
+
536
+ 飞书 API 有请求频率限制,流式更新消息很容易触发限流。当前采用完整回复后一次性发送的方式,以保证稳定性。
537
+
538
+ #### Windows 安装报错 `spawn npm ENOENT`
539
+
540
+ 如果 `openclaw plugins install` 失败,可以手动安装:
541
+
542
+ ```bash
543
+ # 1. 下载插件包
544
+ curl -O https://registry.npmjs.org/@m1heng-clawd/feishu/-/feishu-0.1.3.tgz
545
+
546
+ # 2. 从本地安装
547
+ openclaw plugins install ./feishu-0.1.3.tgz
548
+ ```
549
+
550
+ #### 在飞书里找不到机器人
551
+
552
+ 1. 确保应用已发布(至少发布到测试版本)
553
+ 2. 在飞书搜索框中搜索机器人名称
554
+ 3. 检查应用可用范围是否包含你的账号
555
+
556
+ ---
557
+
558
+ ## License
559
+
560
+ MIT
package/index.ts ADDED
@@ -0,0 +1,74 @@
1
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
2
+ import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
3
+ import { feishuPlugin } from "./src/channel.js";
4
+ import { setFeishuRuntime } from "./src/runtime.js";
5
+ import { registerFeishuDocTools } from "./src/docx.js";
6
+ import { registerFeishuWikiTools } from "./src/wiki.js";
7
+ import { registerFeishuDriveTools } from "./src/drive.js";
8
+ import { registerFeishuPermTools } from "./src/perm.js";
9
+ import { registerFeishuBitableTools } from "./src/bitable.js";
10
+
11
+ export { monitorFeishuProvider } from "./src/monitor.js";
12
+ export {
13
+ sendMessageFeishu,
14
+ sendCardFeishu,
15
+ updateCardFeishu,
16
+ editMessageFeishu,
17
+ getMessageFeishu,
18
+ buildMarkdownCard,
19
+ buildInteractiveCard,
20
+ createSimpleTextCard,
21
+ sendMarkdownCardFeishu,
22
+ type CardTemplate,
23
+ type CardButton,
24
+ } from "./src/send.js";
25
+ export {
26
+ uploadImageFeishu,
27
+ uploadFileFeishu,
28
+ sendImageFeishu,
29
+ sendFileFeishu,
30
+ sendMediaFeishu,
31
+ } from "./src/media.js";
32
+ export { probeFeishu, clearProbeCache } from "./src/probe.js";
33
+ export {
34
+ addReactionFeishu,
35
+ removeReactionFeishu,
36
+ listReactionsFeishu,
37
+ FeishuEmoji,
38
+ } from "./src/reactions.js";
39
+ export {
40
+ extractMentionTargets,
41
+ extractMessageBody,
42
+ isMentionForwardRequest,
43
+ formatMentionForText,
44
+ formatMentionForCard,
45
+ formatMentionAllForText,
46
+ formatMentionAllForCard,
47
+ buildMentionedMessage,
48
+ buildMentionedCardContent,
49
+ type MentionTarget,
50
+ } from "./src/mention.js";
51
+ export { feishuPlugin } from "./src/channel.js";
52
+ export {
53
+ FeishuStream,
54
+ createFeishuStreamingHandler,
55
+ type OnPartialReply,
56
+ } from "./src/stream.js";
57
+
58
+ const plugin = {
59
+ id: "feishu",
60
+ name: "Feishu",
61
+ description: "Feishu/Lark channel plugin",
62
+ configSchema: emptyPluginConfigSchema(),
63
+ register(api: OpenClawPluginApi) {
64
+ setFeishuRuntime(api.runtime);
65
+ api.registerChannel({ plugin: feishuPlugin });
66
+ registerFeishuDocTools(api);
67
+ registerFeishuWikiTools(api);
68
+ registerFeishuDriveTools(api);
69
+ registerFeishuPermTools(api);
70
+ registerFeishuBitableTools(api);
71
+ },
72
+ };
73
+
74
+ export default plugin;
@@ -0,0 +1,10 @@
1
+ {
2
+ "id": "feishu-plus",
3
+ "channels": ["feishu-plus"],
4
+ "skills": ["./skills"],
5
+ "configSchema": {
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {}
9
+ }
10
+ }