@nextclaw/channel-plugin-feishu 0.2.12 → 0.2.14

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.
Files changed (102) hide show
  1. package/README.md +3 -1
  2. package/index.ts +65 -0
  3. package/openclaw.plugin.json +3 -7
  4. package/package.json +33 -9
  5. package/skills/feishu-doc/SKILL.md +211 -0
  6. package/skills/feishu-doc/references/block-types.md +103 -0
  7. package/skills/feishu-drive/SKILL.md +97 -0
  8. package/skills/feishu-perm/SKILL.md +119 -0
  9. package/skills/feishu-wiki/SKILL.md +111 -0
  10. package/src/accounts.test.ts +371 -0
  11. package/src/accounts.ts +244 -0
  12. package/src/async.ts +62 -0
  13. package/src/bitable.ts +725 -0
  14. package/src/bot.card-action.test.ts +63 -0
  15. package/src/bot.checkBotMentioned.test.ts +193 -0
  16. package/src/bot.stripBotMention.test.ts +134 -0
  17. package/src/bot.test.ts +2107 -0
  18. package/src/bot.ts +1556 -0
  19. package/src/card-action.ts +79 -0
  20. package/src/channel.test.ts +48 -0
  21. package/src/channel.ts +369 -0
  22. package/src/chat-schema.ts +24 -0
  23. package/src/chat.test.ts +89 -0
  24. package/src/chat.ts +130 -0
  25. package/src/client.test.ts +324 -0
  26. package/src/client.ts +196 -0
  27. package/src/config-schema.test.ts +247 -0
  28. package/src/config-schema.ts +306 -0
  29. package/src/dedup.ts +203 -0
  30. package/src/directory.test.ts +40 -0
  31. package/src/directory.ts +156 -0
  32. package/src/doc-schema.ts +182 -0
  33. package/src/docx-batch-insert.test.ts +90 -0
  34. package/src/docx-batch-insert.ts +187 -0
  35. package/src/docx-color-text.ts +149 -0
  36. package/src/docx-table-ops.ts +298 -0
  37. package/src/docx.account-selection.test.ts +70 -0
  38. package/src/docx.test.ts +445 -0
  39. package/src/docx.ts +1460 -0
  40. package/src/drive-schema.ts +46 -0
  41. package/src/drive.ts +228 -0
  42. package/src/dynamic-agent.ts +131 -0
  43. package/src/external-keys.test.ts +20 -0
  44. package/src/external-keys.ts +19 -0
  45. package/src/feishu-command-handler.ts +59 -0
  46. package/src/media.test.ts +523 -0
  47. package/src/media.ts +484 -0
  48. package/src/mention.ts +133 -0
  49. package/src/monitor.account.ts +562 -0
  50. package/src/monitor.reaction.test.ts +653 -0
  51. package/src/monitor.startup.test.ts +190 -0
  52. package/src/monitor.startup.ts +64 -0
  53. package/src/monitor.state.defaults.test.ts +46 -0
  54. package/src/monitor.state.ts +155 -0
  55. package/src/monitor.test-mocks.ts +45 -0
  56. package/src/monitor.transport.ts +264 -0
  57. package/src/monitor.ts +95 -0
  58. package/src/monitor.webhook-e2e.test.ts +214 -0
  59. package/src/monitor.webhook-security.test.ts +142 -0
  60. package/src/monitor.webhook.test-helpers.ts +98 -0
  61. package/src/onboarding.status.test.ts +25 -0
  62. package/src/onboarding.test.ts +143 -0
  63. package/src/onboarding.ts +489 -0
  64. package/src/outbound.test.ts +356 -0
  65. package/src/outbound.ts +176 -0
  66. package/src/perm-schema.ts +52 -0
  67. package/src/perm.ts +176 -0
  68. package/src/policy.test.ts +154 -0
  69. package/src/policy.ts +123 -0
  70. package/src/post.test.ts +105 -0
  71. package/src/post.ts +274 -0
  72. package/src/probe.test.ts +270 -0
  73. package/src/probe.ts +156 -0
  74. package/src/reactions.ts +153 -0
  75. package/src/reply-dispatcher.test.ts +513 -0
  76. package/src/reply-dispatcher.ts +397 -0
  77. package/src/runtime.ts +6 -0
  78. package/src/secret-input.ts +13 -0
  79. package/src/send-message.ts +71 -0
  80. package/src/send-result.ts +29 -0
  81. package/src/send-target.test.ts +74 -0
  82. package/src/send-target.ts +29 -0
  83. package/src/send.reply-fallback.test.ts +189 -0
  84. package/src/send.test.ts +168 -0
  85. package/src/send.ts +481 -0
  86. package/src/streaming-card.test.ts +54 -0
  87. package/src/streaming-card.ts +374 -0
  88. package/src/targets.test.ts +70 -0
  89. package/src/targets.ts +107 -0
  90. package/src/tool-account-routing.test.ts +129 -0
  91. package/src/tool-account.ts +70 -0
  92. package/src/tool-factory-test-harness.ts +76 -0
  93. package/src/tool-result.test.ts +32 -0
  94. package/src/tool-result.ts +14 -0
  95. package/src/tools-config.test.ts +21 -0
  96. package/src/tools-config.ts +22 -0
  97. package/src/types.ts +103 -0
  98. package/src/typing.test.ts +144 -0
  99. package/src/typing.ts +210 -0
  100. package/src/wiki-schema.ts +55 -0
  101. package/src/wiki.ts +233 -0
  102. package/index.js +0 -27
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
1
  # @nextclaw/channel-plugin-feishu
2
2
 
3
- Builtin NextClaw `feishu` channel plugin in OpenClaw-compatible format.
3
+ NextClaw bundled Feishu/Lark channel plugin.
4
+
5
+ This package vendors the Feishu-specific implementation from the official OpenClaw plugin, then runs it through the NextClaw OpenClaw-compat loader so NextClaw can expose Feishu chat, doc, wiki, drive, scopes, and bitable capabilities without taking a runtime dependency on the upstream plugin package.
package/index.ts ADDED
@@ -0,0 +1,65 @@
1
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk/feishu";
2
+ import { emptyPluginConfigSchema } from "openclaw/plugin-sdk/feishu";
3
+ import { registerFeishuBitableTools } from "./src/bitable.js";
4
+ import { feishuPlugin } from "./src/channel.js";
5
+ import { registerFeishuChatTools } from "./src/chat.js";
6
+ import { registerFeishuDocTools } from "./src/docx.js";
7
+ import { registerFeishuDriveTools } from "./src/drive.js";
8
+ import { registerFeishuPermTools } from "./src/perm.js";
9
+ import { setFeishuRuntime } from "./src/runtime.js";
10
+ import { registerFeishuWikiTools } from "./src/wiki.js";
11
+
12
+ export { monitorFeishuProvider } from "./src/monitor.js";
13
+ export {
14
+ sendMessageFeishu,
15
+ sendCardFeishu,
16
+ updateCardFeishu,
17
+ editMessageFeishu,
18
+ getMessageFeishu,
19
+ } from "./src/send.js";
20
+ export {
21
+ uploadImageFeishu,
22
+ uploadFileFeishu,
23
+ sendImageFeishu,
24
+ sendFileFeishu,
25
+ sendMediaFeishu,
26
+ } from "./src/media.js";
27
+ export { probeFeishu } from "./src/probe.js";
28
+ export {
29
+ addReactionFeishu,
30
+ removeReactionFeishu,
31
+ listReactionsFeishu,
32
+ FeishuEmoji,
33
+ } from "./src/reactions.js";
34
+ export {
35
+ extractMentionTargets,
36
+ extractMessageBody,
37
+ isMentionForwardRequest,
38
+ formatMentionForText,
39
+ formatMentionForCard,
40
+ formatMentionAllForText,
41
+ formatMentionAllForCard,
42
+ buildMentionedMessage,
43
+ buildMentionedCardContent,
44
+ type MentionTarget,
45
+ } from "./src/mention.js";
46
+ export { feishuPlugin } from "./src/channel.js";
47
+
48
+ const plugin = {
49
+ id: "feishu",
50
+ name: "Feishu",
51
+ description: "Feishu/Lark channel plugin",
52
+ configSchema: emptyPluginConfigSchema(),
53
+ register(api: OpenClawPluginApi) {
54
+ setFeishuRuntime(api.runtime);
55
+ api.registerChannel({ plugin: feishuPlugin });
56
+ registerFeishuDocTools(api);
57
+ registerFeishuChatTools(api);
58
+ registerFeishuWikiTools(api);
59
+ registerFeishuDriveTools(api);
60
+ registerFeishuPermTools(api);
61
+ registerFeishuBitableTools(api);
62
+ },
63
+ };
64
+
65
+ export default plugin;
@@ -1,11 +1,7 @@
1
1
  {
2
- "id": "builtin-channel-feishu",
3
- "name": "Builtin Feishu Channel",
4
- "description": "Builtin NextClaw channel plugin for feishu",
5
- "version": "0.1.0",
6
- "channels": [
7
- "feishu"
8
- ],
2
+ "id": "feishu",
3
+ "channels": ["feishu"],
4
+ "skills": ["./skills"],
9
5
  "configSchema": {
10
6
  "type": "object",
11
7
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,28 +1,52 @@
1
1
  {
2
2
  "name": "@nextclaw/channel-plugin-feishu",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "private": false,
5
- "description": "NextClaw Feishu channel plugin (OpenClaw-compatible)",
5
+ "description": "NextClaw Feishu/Lark channel plugin with doc/wiki/drive tools.",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {
9
- "default": "./index.js"
9
+ "default": "./index.ts"
10
10
  }
11
11
  },
12
12
  "files": [
13
- "index.js",
13
+ "index.ts",
14
14
  "openclaw.plugin.json",
15
- "README.md"
15
+ "README.md",
16
+ "skills",
17
+ "src"
16
18
  ],
17
19
  "openclaw": {
18
20
  "extensions": [
19
- "index.js"
20
- ]
21
+ "./index.ts"
22
+ ],
23
+ "channel": {
24
+ "id": "feishu",
25
+ "label": "Feishu",
26
+ "selectionLabel": "Feishu/Lark (飞书)",
27
+ "docsPath": "/channels/feishu",
28
+ "docsLabel": "feishu",
29
+ "blurb": "飞书/Lark enterprise messaging with doc/wiki/drive tools.",
30
+ "aliases": [
31
+ "lark"
32
+ ],
33
+ "order": 35,
34
+ "quickstartAllowFrom": true
35
+ },
36
+ "install": {
37
+ "npmSpec": "@nextclaw/channel-plugin-feishu",
38
+ "localPath": "packages/extensions/nextclaw-channel-plugin-feishu",
39
+ "defaultChoice": "npm"
40
+ }
21
41
  },
22
42
  "dependencies": {
23
- "@nextclaw/channel-runtime": "0.2.12"
43
+ "@larksuiteoapi/node-sdk": "^1.59.0",
44
+ "@sinclair/typebox": "0.34.48",
45
+ "https-proxy-agent": "^8.0.0",
46
+ "openclaw": "2026.3.13",
47
+ "zod": "^4.3.6"
24
48
  },
25
49
  "scripts": {
26
- "lint": "eslint index.js"
50
+ "lint": "eslint index.ts"
27
51
  }
28
52
  }
@@ -0,0 +1,211 @@
1
+ ---
2
+ name: feishu-doc
3
+ description: |
4
+ Feishu document read/write operations. Activate when user mentions Feishu docs, cloud docs, or docx links.
5
+ ---
6
+
7
+ # Feishu Document Tool
8
+
9
+ Single tool `feishu_doc` with action parameter for all document operations, including table creation for Docx.
10
+
11
+ ## Token Extraction
12
+
13
+ From URL `https://xxx.feishu.cn/docx/ABC123def` → `doc_token` = `ABC123def`
14
+
15
+ ## Actions
16
+
17
+ ### Read Document
18
+
19
+ ```json
20
+ { "action": "read", "doc_token": "ABC123def" }
21
+ ```
22
+
23
+ Returns: title, plain text content, block statistics. Check `hint` field - if present, structured content (tables, images) exists that requires `list_blocks`.
24
+
25
+ ### Write Document (Replace All)
26
+
27
+ ```json
28
+ { "action": "write", "doc_token": "ABC123def", "content": "# Title\n\nMarkdown content..." }
29
+ ```
30
+
31
+ Replaces entire document with markdown content. Supports: headings, lists, code blocks, quotes, links, images (`![](url)` auto-uploaded), bold/italic/strikethrough.
32
+
33
+ **Limitation:** Markdown tables are NOT supported.
34
+
35
+ ### Append Content
36
+
37
+ ```json
38
+ { "action": "append", "doc_token": "ABC123def", "content": "Additional content" }
39
+ ```
40
+
41
+ Appends markdown to end of document.
42
+
43
+ ### Create Document
44
+
45
+ ```json
46
+ { "action": "create", "title": "New Document", "owner_open_id": "ou_xxx" }
47
+ ```
48
+
49
+ With folder:
50
+
51
+ ```json
52
+ {
53
+ "action": "create",
54
+ "title": "New Document",
55
+ "folder_token": "fldcnXXX",
56
+ "owner_open_id": "ou_xxx"
57
+ }
58
+ ```
59
+
60
+ **Important:** Always pass `owner_open_id` with the requesting user's `open_id` (from inbound metadata `sender_id`) so the user automatically gets `full_access` permission on the created document. Without this, only the bot app has access.
61
+
62
+ ### List Blocks
63
+
64
+ ```json
65
+ { "action": "list_blocks", "doc_token": "ABC123def" }
66
+ ```
67
+
68
+ Returns full block data including tables, images. Use this to read structured content.
69
+
70
+ ### Get Single Block
71
+
72
+ ```json
73
+ { "action": "get_block", "doc_token": "ABC123def", "block_id": "doxcnXXX" }
74
+ ```
75
+
76
+ ### Update Block Text
77
+
78
+ ```json
79
+ {
80
+ "action": "update_block",
81
+ "doc_token": "ABC123def",
82
+ "block_id": "doxcnXXX",
83
+ "content": "New text"
84
+ }
85
+ ```
86
+
87
+ ### Delete Block
88
+
89
+ ```json
90
+ { "action": "delete_block", "doc_token": "ABC123def", "block_id": "doxcnXXX" }
91
+ ```
92
+
93
+ ### Create Table (Docx Table Block)
94
+
95
+ ```json
96
+ {
97
+ "action": "create_table",
98
+ "doc_token": "ABC123def",
99
+ "row_size": 2,
100
+ "column_size": 2,
101
+ "column_width": [200, 200]
102
+ }
103
+ ```
104
+
105
+ Optional: `parent_block_id` to insert under a specific block.
106
+
107
+ ### Write Table Cells
108
+
109
+ ```json
110
+ {
111
+ "action": "write_table_cells",
112
+ "doc_token": "ABC123def",
113
+ "table_block_id": "doxcnTABLE",
114
+ "values": [
115
+ ["A1", "B1"],
116
+ ["A2", "B2"]
117
+ ]
118
+ }
119
+ ```
120
+
121
+ ### Create Table With Values (One-step)
122
+
123
+ ```json
124
+ {
125
+ "action": "create_table_with_values",
126
+ "doc_token": "ABC123def",
127
+ "row_size": 2,
128
+ "column_size": 2,
129
+ "column_width": [200, 200],
130
+ "values": [
131
+ ["A1", "B1"],
132
+ ["A2", "B2"]
133
+ ]
134
+ }
135
+ ```
136
+
137
+ Optional: `parent_block_id` to insert under a specific block.
138
+
139
+ ### Upload Image to Docx (from URL or local file)
140
+
141
+ ```json
142
+ {
143
+ "action": "upload_image",
144
+ "doc_token": "ABC123def",
145
+ "url": "https://example.com/image.png"
146
+ }
147
+ ```
148
+
149
+ Or local path with position control:
150
+
151
+ ```json
152
+ {
153
+ "action": "upload_image",
154
+ "doc_token": "ABC123def",
155
+ "file_path": "/tmp/image.png",
156
+ "parent_block_id": "doxcnParent",
157
+ "index": 5
158
+ }
159
+ ```
160
+
161
+ Optional `index` (0-based) inserts the image at a specific position among sibling blocks. Omit to append at end.
162
+
163
+ **Note:** Image display size is determined by the uploaded image's pixel dimensions. For small images (e.g. 480x270 GIFs), scale to 800px+ width before uploading to ensure proper display.
164
+
165
+ ### Upload File Attachment to Docx (from URL or local file)
166
+
167
+ ```json
168
+ {
169
+ "action": "upload_file",
170
+ "doc_token": "ABC123def",
171
+ "url": "https://example.com/report.pdf"
172
+ }
173
+ ```
174
+
175
+ Or local path:
176
+
177
+ ```json
178
+ {
179
+ "action": "upload_file",
180
+ "doc_token": "ABC123def",
181
+ "file_path": "/tmp/report.pdf",
182
+ "filename": "Q1-report.pdf"
183
+ }
184
+ ```
185
+
186
+ Rules:
187
+
188
+ - exactly one of `url` / `file_path`
189
+ - optional `filename` override
190
+ - optional `parent_block_id`
191
+
192
+ ## Reading Workflow
193
+
194
+ 1. Start with `action: "read"` - get plain text + statistics
195
+ 2. Check `block_types` in response for Table, Image, Code, etc.
196
+ 3. If structured content exists, use `action: "list_blocks"` for full data
197
+
198
+ ## Configuration
199
+
200
+ ```yaml
201
+ channels:
202
+ feishu:
203
+ tools:
204
+ doc: true # default: true
205
+ ```
206
+
207
+ **Note:** `feishu_wiki` depends on this tool - wiki page content is read/written via `feishu_doc`.
208
+
209
+ ## Permissions
210
+
211
+ Required: `docx:document`, `docx:document:readonly`, `docx:document.block:convert`, `drive:drive`
@@ -0,0 +1,103 @@
1
+ # Feishu Block Types Reference
2
+
3
+ Complete reference for Feishu document block types. Use with `feishu_doc_list_blocks`, `feishu_doc_update_block`, and `feishu_doc_delete_block`.
4
+
5
+ ## Block Type Table
6
+
7
+ | block_type | Name | Description | Editable |
8
+ | ---------- | --------------- | ------------------------------ | -------- |
9
+ | 1 | Page | Document root (contains title) | No |
10
+ | 2 | Text | Plain text paragraph | Yes |
11
+ | 3 | Heading1 | H1 heading | Yes |
12
+ | 4 | Heading2 | H2 heading | Yes |
13
+ | 5 | Heading3 | H3 heading | Yes |
14
+ | 6 | Heading4 | H4 heading | Yes |
15
+ | 7 | Heading5 | H5 heading | Yes |
16
+ | 8 | Heading6 | H6 heading | Yes |
17
+ | 9 | Heading7 | H7 heading | Yes |
18
+ | 10 | Heading8 | H8 heading | Yes |
19
+ | 11 | Heading9 | H9 heading | Yes |
20
+ | 12 | Bullet | Unordered list item | Yes |
21
+ | 13 | Ordered | Ordered list item | Yes |
22
+ | 14 | Code | Code block | Yes |
23
+ | 15 | Quote | Blockquote | Yes |
24
+ | 16 | Equation | LaTeX equation | Partial |
25
+ | 17 | Todo | Checkbox / task item | Yes |
26
+ | 18 | Bitable | Multi-dimensional table | No |
27
+ | 19 | Callout | Highlight block | Yes |
28
+ | 20 | ChatCard | Chat card embed | No |
29
+ | 21 | Diagram | Diagram embed | No |
30
+ | 22 | Divider | Horizontal rule | No |
31
+ | 23 | File | File attachment | No |
32
+ | 24 | Grid | Grid layout container | No |
33
+ | 25 | GridColumn | Grid column | No |
34
+ | 26 | Iframe | Embedded iframe | No |
35
+ | 27 | Image | Image | Partial |
36
+ | 28 | ISV | Third-party widget | No |
37
+ | 29 | MindnoteBlock | Mindmap embed | No |
38
+ | 30 | Sheet | Spreadsheet embed | No |
39
+ | 31 | Table | Table | Partial |
40
+ | 32 | TableCell | Table cell | Yes |
41
+ | 33 | View | View embed | No |
42
+ | 34 | Undefined | Unknown type | No |
43
+ | 35 | QuoteContainer | Quote container | No |
44
+ | 36 | Task | Lark Tasks integration | No |
45
+ | 37 | OKR | OKR integration | No |
46
+ | 38 | OKRObjective | OKR objective | No |
47
+ | 39 | OKRKeyResult | OKR key result | No |
48
+ | 40 | OKRProgress | OKR progress | No |
49
+ | 41 | AddOns | Add-ons block | No |
50
+ | 42 | JiraIssue | Jira issue embed | No |
51
+ | 43 | WikiCatalog | Wiki catalog | No |
52
+ | 44 | Board | Board embed | No |
53
+ | 45 | Agenda | Agenda block | No |
54
+ | 46 | AgendaItem | Agenda item | No |
55
+ | 47 | AgendaItemTitle | Agenda item title | No |
56
+ | 48 | SyncedBlock | Synced block reference | No |
57
+
58
+ ## Editing Guidelines
59
+
60
+ ### Text-based blocks (2-17, 19)
61
+
62
+ Update text content using `feishu_doc_update_block`:
63
+
64
+ ```json
65
+ {
66
+ "doc_token": "ABC123",
67
+ "block_id": "block_xxx",
68
+ "content": "New text content"
69
+ }
70
+ ```
71
+
72
+ ### Image blocks (27)
73
+
74
+ Images cannot be updated directly via `update_block`. Use `feishu_doc_write` or `feishu_doc_append` with markdown to add new images.
75
+
76
+ ### Table blocks (31)
77
+
78
+ **Important:** Table blocks CANNOT be created via the `documentBlockChildren.create` API (error 1770029). This affects `feishu_doc_write` and `feishu_doc_append` - markdown tables will be skipped with a warning.
79
+
80
+ Tables can only be read (via `list_blocks`) and individual cells (type 32) can be updated, but new tables cannot be inserted programmatically via markdown.
81
+
82
+ ### Container blocks (24, 25, 35)
83
+
84
+ Grid and QuoteContainer are layout containers. Edit their child blocks instead.
85
+
86
+ ## Common Patterns
87
+
88
+ ### Replace specific paragraph
89
+
90
+ 1. `feishu_doc_list_blocks` - find the block_id
91
+ 2. `feishu_doc_update_block` - update its content
92
+
93
+ ### Insert content at specific location
94
+
95
+ Currently, the API only supports appending to document end. For insertion at specific positions, consider:
96
+
97
+ 1. Read existing content
98
+ 2. Delete affected blocks
99
+ 3. Rewrite with new content in desired order
100
+
101
+ ### Delete multiple blocks
102
+
103
+ Blocks must be deleted one at a time. Delete child blocks before parent containers.
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: feishu-drive
3
+ description: |
4
+ Feishu cloud storage file management. Activate when user mentions cloud space, folders, drive.
5
+ ---
6
+
7
+ # Feishu Drive Tool
8
+
9
+ Single tool `feishu_drive` for cloud storage operations.
10
+
11
+ ## Token Extraction
12
+
13
+ From URL `https://xxx.feishu.cn/drive/folder/ABC123` → `folder_token` = `ABC123`
14
+
15
+ ## Actions
16
+
17
+ ### List Folder Contents
18
+
19
+ ```json
20
+ { "action": "list" }
21
+ ```
22
+
23
+ Root directory (no folder_token).
24
+
25
+ ```json
26
+ { "action": "list", "folder_token": "fldcnXXX" }
27
+ ```
28
+
29
+ Returns: files with token, name, type, url, timestamps.
30
+
31
+ ### Get File Info
32
+
33
+ ```json
34
+ { "action": "info", "file_token": "ABC123", "type": "docx" }
35
+ ```
36
+
37
+ Searches for the file in the root directory. Note: file must be in root or use `list` to browse folders first.
38
+
39
+ `type`: `doc`, `docx`, `sheet`, `bitable`, `folder`, `file`, `mindnote`, `shortcut`
40
+
41
+ ### Create Folder
42
+
43
+ ```json
44
+ { "action": "create_folder", "name": "New Folder" }
45
+ ```
46
+
47
+ In parent folder:
48
+
49
+ ```json
50
+ { "action": "create_folder", "name": "New Folder", "folder_token": "fldcnXXX" }
51
+ ```
52
+
53
+ ### Move File
54
+
55
+ ```json
56
+ { "action": "move", "file_token": "ABC123", "type": "docx", "folder_token": "fldcnXXX" }
57
+ ```
58
+
59
+ ### Delete File
60
+
61
+ ```json
62
+ { "action": "delete", "file_token": "ABC123", "type": "docx" }
63
+ ```
64
+
65
+ ## File Types
66
+
67
+ | Type | Description |
68
+ | ---------- | ----------------------- |
69
+ | `doc` | Old format document |
70
+ | `docx` | New format document |
71
+ | `sheet` | Spreadsheet |
72
+ | `bitable` | Multi-dimensional table |
73
+ | `folder` | Folder |
74
+ | `file` | Uploaded file |
75
+ | `mindnote` | Mind map |
76
+ | `shortcut` | Shortcut |
77
+
78
+ ## Configuration
79
+
80
+ ```yaml
81
+ channels:
82
+ feishu:
83
+ tools:
84
+ drive: true # default: true
85
+ ```
86
+
87
+ ## Permissions
88
+
89
+ - `drive:drive` - Full access (create, move, delete)
90
+ - `drive:drive:readonly` - Read only (list, info)
91
+
92
+ ## Known Limitations
93
+
94
+ - **Bots have no root folder**: Feishu bots use `tenant_access_token` and don't have their own "My Space". The root folder concept only exists for user accounts. This means:
95
+ - `create_folder` without `folder_token` will fail (400 error)
96
+ - Bot can only access files/folders that have been **shared with it**
97
+ - **Workaround**: User must first create a folder manually and share it with the bot, then bot can create subfolders inside it
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: feishu-perm
3
+ description: |
4
+ Feishu permission management for documents and files. Activate when user mentions sharing, permissions, collaborators.
5
+ ---
6
+
7
+ # Feishu Permission Tool
8
+
9
+ Single tool `feishu_perm` for managing file/document permissions.
10
+
11
+ ## Actions
12
+
13
+ ### List Collaborators
14
+
15
+ ```json
16
+ { "action": "list", "token": "ABC123", "type": "docx" }
17
+ ```
18
+
19
+ Returns: members with member_type, member_id, perm, name.
20
+
21
+ ### Add Collaborator
22
+
23
+ ```json
24
+ {
25
+ "action": "add",
26
+ "token": "ABC123",
27
+ "type": "docx",
28
+ "member_type": "email",
29
+ "member_id": "user@example.com",
30
+ "perm": "edit"
31
+ }
32
+ ```
33
+
34
+ ### Remove Collaborator
35
+
36
+ ```json
37
+ {
38
+ "action": "remove",
39
+ "token": "ABC123",
40
+ "type": "docx",
41
+ "member_type": "email",
42
+ "member_id": "user@example.com"
43
+ }
44
+ ```
45
+
46
+ ## Token Types
47
+
48
+ | Type | Description |
49
+ | ---------- | ----------------------- |
50
+ | `doc` | Old format document |
51
+ | `docx` | New format document |
52
+ | `sheet` | Spreadsheet |
53
+ | `bitable` | Multi-dimensional table |
54
+ | `folder` | Folder |
55
+ | `file` | Uploaded file |
56
+ | `wiki` | Wiki node |
57
+ | `mindnote` | Mind map |
58
+
59
+ ## Member Types
60
+
61
+ | Type | Description |
62
+ | ------------------ | ------------------ |
63
+ | `email` | Email address |
64
+ | `openid` | User open_id |
65
+ | `userid` | User user_id |
66
+ | `unionid` | User union_id |
67
+ | `openchat` | Group chat open_id |
68
+ | `opendepartmentid` | Department open_id |
69
+
70
+ ## Permission Levels
71
+
72
+ | Perm | Description |
73
+ | ------------- | ------------------------------------ |
74
+ | `view` | View only |
75
+ | `edit` | Can edit |
76
+ | `full_access` | Full access (can manage permissions) |
77
+
78
+ ## Examples
79
+
80
+ Share document with email:
81
+
82
+ ```json
83
+ {
84
+ "action": "add",
85
+ "token": "doxcnXXX",
86
+ "type": "docx",
87
+ "member_type": "email",
88
+ "member_id": "alice@company.com",
89
+ "perm": "edit"
90
+ }
91
+ ```
92
+
93
+ Share folder with group:
94
+
95
+ ```json
96
+ {
97
+ "action": "add",
98
+ "token": "fldcnXXX",
99
+ "type": "folder",
100
+ "member_type": "openchat",
101
+ "member_id": "oc_xxx",
102
+ "perm": "view"
103
+ }
104
+ ```
105
+
106
+ ## Configuration
107
+
108
+ ```yaml
109
+ channels:
110
+ feishu:
111
+ tools:
112
+ perm: true # default: false (disabled)
113
+ ```
114
+
115
+ **Note:** This tool is disabled by default because permission management is a sensitive operation. Enable explicitly if needed.
116
+
117
+ ## Permissions
118
+
119
+ Required: `drive:permission`