@openclaw-plugins/feishu-plus 0.1.7
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 +21 -0
- package/README.md +560 -0
- package/index.ts +63 -0
- package/openclaw.plugin.json +10 -0
- package/package.json +65 -0
- package/skills/feishu-doc/SKILL.md +99 -0
- package/skills/feishu-doc/references/block-types.md +102 -0
- package/skills/feishu-drive/SKILL.md +96 -0
- package/skills/feishu-perm/SKILL.md +90 -0
- package/skills/feishu-wiki/SKILL.md +96 -0
- package/src/accounts.ts +140 -0
- package/src/bitable.ts +441 -0
- package/src/bot.ts +881 -0
- package/src/channel.ts +334 -0
- package/src/client.ts +114 -0
- package/src/config-schema.ts +199 -0
- package/src/directory.ts +165 -0
- package/src/doc-schema.ts +47 -0
- package/src/docx.ts +480 -0
- package/src/drive-schema.ts +46 -0
- package/src/drive.ts +207 -0
- package/src/dynamic-agent.ts +131 -0
- package/src/media.ts +523 -0
- package/src/mention.ts +121 -0
- package/src/monitor.ts +190 -0
- package/src/onboarding.ts +358 -0
- package/src/outbound.ts +40 -0
- package/src/perm-schema.ts +52 -0
- package/src/perm.ts +166 -0
- package/src/policy.ts +92 -0
- package/src/probe.ts +43 -0
- package/src/reactions.ts +160 -0
- package/src/reply-dispatcher.ts +174 -0
- package/src/runtime.ts +14 -0
- package/src/send.ts +360 -0
- package/src/targets.ts +58 -0
- package/src/tools-config.ts +21 -0
- package/src/types.ts +77 -0
- package/src/typing.ts +75 -0
- package/src/wiki-schema.ts +55 -0
- package/src/wiki.ts +224 -0
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openclaw-plugins/feishu-plus",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "OpenClaw Feishu/Lark channel plugin",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"index.ts",
|
|
12
|
+
"src",
|
|
13
|
+
"skills",
|
|
14
|
+
"openclaw.plugin.json"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/charlzyx/openclaw-feishu-plus.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"openclaw",
|
|
22
|
+
"feishu",
|
|
23
|
+
"lark",
|
|
24
|
+
"飞书",
|
|
25
|
+
"chatbot",
|
|
26
|
+
"ai",
|
|
27
|
+
"claude"
|
|
28
|
+
],
|
|
29
|
+
"openclaw": {
|
|
30
|
+
"extensions": [
|
|
31
|
+
"./index.ts"
|
|
32
|
+
],
|
|
33
|
+
"channel": {
|
|
34
|
+
"id": "feishu-plus",
|
|
35
|
+
"label": "Feishu",
|
|
36
|
+
"selectionLabel": "Feishu/Lark (飞书)",
|
|
37
|
+
"docsPath": "/channels/feishu-plus",
|
|
38
|
+
"docsLabel": "feishu plus",
|
|
39
|
+
"blurb": "飞书/Lark enterprise messaging.",
|
|
40
|
+
"aliases": [
|
|
41
|
+
"lark"
|
|
42
|
+
],
|
|
43
|
+
"order": 70
|
|
44
|
+
},
|
|
45
|
+
"install": {
|
|
46
|
+
"npmSpec": "@openclaw-plugins/feishu-plus",
|
|
47
|
+
"localPath": ".",
|
|
48
|
+
"defaultChoice": "npm"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@larksuiteoapi/node-sdk": "^1.56.1",
|
|
53
|
+
"@sinclair/typebox": "^0.34.48",
|
|
54
|
+
"zod": "^4.3.6"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/node": "^25.0.10",
|
|
58
|
+
"openclaw": "2026.1.29",
|
|
59
|
+
"tsx": "^4.21.0",
|
|
60
|
+
"typescript": "^5.7.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"openclaw": ">=2026.1.29"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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.
|
|
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 (`` 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" }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
With folder:
|
|
50
|
+
```json
|
|
51
|
+
{ "action": "create", "title": "New Document", "folder_token": "fldcnXXX" }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### List Blocks
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{ "action": "list_blocks", "doc_token": "ABC123def" }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Returns full block data including tables, images. Use this to read structured content.
|
|
61
|
+
|
|
62
|
+
### Get Single Block
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{ "action": "get_block", "doc_token": "ABC123def", "block_id": "doxcnXXX" }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Update Block Text
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{ "action": "update_block", "doc_token": "ABC123def", "block_id": "doxcnXXX", "content": "New text" }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Delete Block
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{ "action": "delete_block", "doc_token": "ABC123def", "block_id": "doxcnXXX" }
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Reading Workflow
|
|
81
|
+
|
|
82
|
+
1. Start with `action: "read"` - get plain text + statistics
|
|
83
|
+
2. Check `block_types` in response for Table, Image, Code, etc.
|
|
84
|
+
3. If structured content exists, use `action: "list_blocks"` for full data
|
|
85
|
+
|
|
86
|
+
## Configuration
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
channels:
|
|
90
|
+
feishu:
|
|
91
|
+
tools:
|
|
92
|
+
doc: true # default: true
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Note:** `feishu_wiki` depends on this tool - wiki page content is read/written via `feishu_doc`.
|
|
96
|
+
|
|
97
|
+
## Permissions
|
|
98
|
+
|
|
99
|
+
Required: `docx:document`, `docx:document:readonly`, `docx:document.block:convert`, `drive:drive`
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
1. Read existing content
|
|
97
|
+
2. Delete affected blocks
|
|
98
|
+
3. Rewrite with new content in desired order
|
|
99
|
+
|
|
100
|
+
### Delete multiple blocks
|
|
101
|
+
|
|
102
|
+
Blocks must be deleted one at a time. Delete child blocks before parent containers.
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
```json
|
|
49
|
+
{ "action": "create_folder", "name": "New Folder", "folder_token": "fldcnXXX" }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Move File
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{ "action": "move", "file_token": "ABC123", "type": "docx", "folder_token": "fldcnXXX" }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Delete File
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{ "action": "delete", "file_token": "ABC123", "type": "docx" }
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## File Types
|
|
65
|
+
|
|
66
|
+
| Type | Description |
|
|
67
|
+
|------|-------------|
|
|
68
|
+
| `doc` | Old format document |
|
|
69
|
+
| `docx` | New format document |
|
|
70
|
+
| `sheet` | Spreadsheet |
|
|
71
|
+
| `bitable` | Multi-dimensional table |
|
|
72
|
+
| `folder` | Folder |
|
|
73
|
+
| `file` | Uploaded file |
|
|
74
|
+
| `mindnote` | Mind map |
|
|
75
|
+
| `shortcut` | Shortcut |
|
|
76
|
+
|
|
77
|
+
## Configuration
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
channels:
|
|
81
|
+
feishu:
|
|
82
|
+
tools:
|
|
83
|
+
drive: true # default: true
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Permissions
|
|
87
|
+
|
|
88
|
+
- `drive:drive` - Full access (create, move, delete)
|
|
89
|
+
- `drive:drive:readonly` - Read only (list, info)
|
|
90
|
+
|
|
91
|
+
## Known Limitations
|
|
92
|
+
|
|
93
|
+
- **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:
|
|
94
|
+
- `create_folder` without `folder_token` will fail (400 error)
|
|
95
|
+
- Bot can only access files/folders that have been **shared with it**
|
|
96
|
+
- **Workaround**: User must first create a folder manually and share it with the bot, then bot can create subfolders inside it
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
{ "action": "add", "token": "ABC123", "type": "docx", "member_type": "email", "member_id": "user@example.com", "perm": "edit" }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Remove Collaborator
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{ "action": "remove", "token": "ABC123", "type": "docx", "member_type": "email", "member_id": "user@example.com" }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Token Types
|
|
34
|
+
|
|
35
|
+
| Type | Description |
|
|
36
|
+
|------|-------------|
|
|
37
|
+
| `doc` | Old format document |
|
|
38
|
+
| `docx` | New format document |
|
|
39
|
+
| `sheet` | Spreadsheet |
|
|
40
|
+
| `bitable` | Multi-dimensional table |
|
|
41
|
+
| `folder` | Folder |
|
|
42
|
+
| `file` | Uploaded file |
|
|
43
|
+
| `wiki` | Wiki node |
|
|
44
|
+
| `mindnote` | Mind map |
|
|
45
|
+
|
|
46
|
+
## Member Types
|
|
47
|
+
|
|
48
|
+
| Type | Description |
|
|
49
|
+
|------|-------------|
|
|
50
|
+
| `email` | Email address |
|
|
51
|
+
| `openid` | User open_id |
|
|
52
|
+
| `userid` | User user_id |
|
|
53
|
+
| `unionid` | User union_id |
|
|
54
|
+
| `openchat` | Group chat open_id |
|
|
55
|
+
| `opendepartmentid` | Department open_id |
|
|
56
|
+
|
|
57
|
+
## Permission Levels
|
|
58
|
+
|
|
59
|
+
| Perm | Description |
|
|
60
|
+
|------|-------------|
|
|
61
|
+
| `view` | View only |
|
|
62
|
+
| `edit` | Can edit |
|
|
63
|
+
| `full_access` | Full access (can manage permissions) |
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
Share document with email:
|
|
68
|
+
```json
|
|
69
|
+
{ "action": "add", "token": "doxcnXXX", "type": "docx", "member_type": "email", "member_id": "alice@company.com", "perm": "edit" }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Share folder with group:
|
|
73
|
+
```json
|
|
74
|
+
{ "action": "add", "token": "fldcnXXX", "type": "folder", "member_type": "openchat", "member_id": "oc_xxx", "perm": "view" }
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Configuration
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
channels:
|
|
81
|
+
feishu:
|
|
82
|
+
tools:
|
|
83
|
+
perm: true # default: false (disabled)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Note:** This tool is disabled by default because permission management is a sensitive operation. Enable explicitly if needed.
|
|
87
|
+
|
|
88
|
+
## Permissions
|
|
89
|
+
|
|
90
|
+
Required: `drive:permission`
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: feishu-wiki
|
|
3
|
+
description: |
|
|
4
|
+
Feishu knowledge base navigation. Activate when user mentions knowledge base, wiki, or wiki links.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Feishu Wiki Tool
|
|
8
|
+
|
|
9
|
+
Single tool `feishu_wiki` for knowledge base operations.
|
|
10
|
+
|
|
11
|
+
## Token Extraction
|
|
12
|
+
|
|
13
|
+
From URL `https://xxx.feishu.cn/wiki/ABC123def` → `token` = `ABC123def`
|
|
14
|
+
|
|
15
|
+
## Actions
|
|
16
|
+
|
|
17
|
+
### List Knowledge Spaces
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{ "action": "spaces" }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Returns all accessible wiki spaces.
|
|
24
|
+
|
|
25
|
+
### List Nodes
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{ "action": "nodes", "space_id": "7xxx" }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
With parent:
|
|
32
|
+
```json
|
|
33
|
+
{ "action": "nodes", "space_id": "7xxx", "parent_node_token": "wikcnXXX" }
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Get Node Details
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{ "action": "get", "token": "ABC123def" }
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Returns: `node_token`, `obj_token`, `obj_type`, etc. Use `obj_token` with `feishu_doc` to read/write the document.
|
|
43
|
+
|
|
44
|
+
### Create Node
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{ "action": "create", "space_id": "7xxx", "title": "New Page" }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
With type and parent:
|
|
51
|
+
```json
|
|
52
|
+
{ "action": "create", "space_id": "7xxx", "title": "Sheet", "obj_type": "sheet", "parent_node_token": "wikcnXXX" }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`obj_type`: `docx` (default), `sheet`, `bitable`, `mindnote`, `file`, `doc`, `slides`
|
|
56
|
+
|
|
57
|
+
### Move Node
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{ "action": "move", "space_id": "7xxx", "node_token": "wikcnXXX" }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
To different location:
|
|
64
|
+
```json
|
|
65
|
+
{ "action": "move", "space_id": "7xxx", "node_token": "wikcnXXX", "target_space_id": "7yyy", "target_parent_token": "wikcnYYY" }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Rename Node
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{ "action": "rename", "space_id": "7xxx", "node_token": "wikcnXXX", "title": "New Title" }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Wiki-Doc Workflow
|
|
75
|
+
|
|
76
|
+
To edit a wiki page:
|
|
77
|
+
|
|
78
|
+
1. Get node: `{ "action": "get", "token": "wiki_token" }` → returns `obj_token`
|
|
79
|
+
2. Read doc: `feishu_doc { "action": "read", "doc_token": "obj_token" }`
|
|
80
|
+
3. Write doc: `feishu_doc { "action": "write", "doc_token": "obj_token", "content": "..." }`
|
|
81
|
+
|
|
82
|
+
## Configuration
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
channels:
|
|
86
|
+
feishu:
|
|
87
|
+
tools:
|
|
88
|
+
wiki: true # default: true
|
|
89
|
+
doc: true # required - wiki content uses feishu_doc
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Dependency:** This tool requires `feishu_doc` to be enabled. Wiki pages are documents - use `feishu_wiki` to navigate, then `feishu_doc` to read/edit content.
|
|
93
|
+
|
|
94
|
+
## Permissions
|
|
95
|
+
|
|
96
|
+
Required: `wiki:wiki` or `wiki:wiki:readonly`
|
package/src/accounts.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { ClawdbotConfig } from "openclaw/plugin-sdk";
|
|
2
|
+
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk";
|
|
3
|
+
import type { FeishuConfig, FeishuAccountConfig, FeishuDomain, ResolvedFeishuAccount } from "./types.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* List all configured account IDs from the accounts field.
|
|
7
|
+
*/
|
|
8
|
+
function listConfiguredAccountIds(cfg: ClawdbotConfig): string[] {
|
|
9
|
+
const accounts = (cfg.channels?.feishu as FeishuConfig)?.accounts;
|
|
10
|
+
if (!accounts || typeof accounts !== "object") {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
return Object.keys(accounts).filter(Boolean);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* List all Feishu account IDs.
|
|
18
|
+
* If no accounts are configured, returns [DEFAULT_ACCOUNT_ID] for backward compatibility.
|
|
19
|
+
*/
|
|
20
|
+
export function listFeishuAccountIds(cfg: ClawdbotConfig): string[] {
|
|
21
|
+
const ids = listConfiguredAccountIds(cfg);
|
|
22
|
+
if (ids.length === 0) {
|
|
23
|
+
// Backward compatibility: no accounts configured, use default
|
|
24
|
+
return [DEFAULT_ACCOUNT_ID];
|
|
25
|
+
}
|
|
26
|
+
return [...ids].sort((a, b) => a.localeCompare(b));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the default account ID.
|
|
31
|
+
*/
|
|
32
|
+
export function resolveDefaultFeishuAccountId(cfg: ClawdbotConfig): string {
|
|
33
|
+
const ids = listFeishuAccountIds(cfg);
|
|
34
|
+
if (ids.includes(DEFAULT_ACCOUNT_ID)) {
|
|
35
|
+
return DEFAULT_ACCOUNT_ID;
|
|
36
|
+
}
|
|
37
|
+
return ids[0] ?? DEFAULT_ACCOUNT_ID;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get the raw account-specific config.
|
|
42
|
+
*/
|
|
43
|
+
function resolveAccountConfig(
|
|
44
|
+
cfg: ClawdbotConfig,
|
|
45
|
+
accountId: string,
|
|
46
|
+
): FeishuAccountConfig | undefined {
|
|
47
|
+
const accounts = (cfg.channels?.feishu as FeishuConfig)?.accounts;
|
|
48
|
+
if (!accounts || typeof accounts !== "object") {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return accounts[accountId];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Merge top-level config with account-specific config.
|
|
56
|
+
* Account-specific fields override top-level fields.
|
|
57
|
+
*/
|
|
58
|
+
function mergeFeishuAccountConfig(
|
|
59
|
+
cfg: ClawdbotConfig,
|
|
60
|
+
accountId: string,
|
|
61
|
+
): FeishuConfig {
|
|
62
|
+
const feishuCfg = cfg.channels?.feishu as FeishuConfig | undefined;
|
|
63
|
+
|
|
64
|
+
// Extract base config (exclude accounts field to avoid recursion)
|
|
65
|
+
const { accounts: _ignored, ...base } = feishuCfg ?? {};
|
|
66
|
+
|
|
67
|
+
// Get account-specific overrides
|
|
68
|
+
const account = resolveAccountConfig(cfg, accountId) ?? {};
|
|
69
|
+
|
|
70
|
+
// Merge: account config overrides base config
|
|
71
|
+
return { ...base, ...account } as FeishuConfig;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Resolve Feishu credentials from a config.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveFeishuCredentials(cfg?: FeishuConfig): {
|
|
78
|
+
appId: string;
|
|
79
|
+
appSecret: string;
|
|
80
|
+
encryptKey?: string;
|
|
81
|
+
verificationToken?: string;
|
|
82
|
+
domain: FeishuDomain;
|
|
83
|
+
} | null {
|
|
84
|
+
const appId = cfg?.appId?.trim();
|
|
85
|
+
const appSecret = cfg?.appSecret?.trim();
|
|
86
|
+
if (!appId || !appSecret) return null;
|
|
87
|
+
return {
|
|
88
|
+
appId,
|
|
89
|
+
appSecret,
|
|
90
|
+
encryptKey: cfg?.encryptKey?.trim() || undefined,
|
|
91
|
+
verificationToken: cfg?.verificationToken?.trim() || undefined,
|
|
92
|
+
domain: cfg?.domain ?? "feishu",
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Resolve a complete Feishu account with merged config.
|
|
98
|
+
*/
|
|
99
|
+
export function resolveFeishuAccount(params: {
|
|
100
|
+
cfg: ClawdbotConfig;
|
|
101
|
+
accountId?: string | null;
|
|
102
|
+
}): ResolvedFeishuAccount {
|
|
103
|
+
const accountId = normalizeAccountId(params.accountId);
|
|
104
|
+
const feishuCfg = params.cfg.channels?.feishu as FeishuConfig | undefined;
|
|
105
|
+
|
|
106
|
+
// Base enabled state (top-level)
|
|
107
|
+
const baseEnabled = feishuCfg?.enabled !== false;
|
|
108
|
+
|
|
109
|
+
// Merge configs
|
|
110
|
+
const merged = mergeFeishuAccountConfig(params.cfg, accountId);
|
|
111
|
+
|
|
112
|
+
// Account-level enabled state
|
|
113
|
+
const accountEnabled = merged.enabled !== false;
|
|
114
|
+
const enabled = baseEnabled && accountEnabled;
|
|
115
|
+
|
|
116
|
+
// Resolve credentials from merged config
|
|
117
|
+
const creds = resolveFeishuCredentials(merged);
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
accountId,
|
|
121
|
+
enabled,
|
|
122
|
+
configured: Boolean(creds),
|
|
123
|
+
name: (merged as FeishuAccountConfig).name?.trim() || undefined,
|
|
124
|
+
appId: creds?.appId,
|
|
125
|
+
appSecret: creds?.appSecret,
|
|
126
|
+
encryptKey: creds?.encryptKey,
|
|
127
|
+
verificationToken: creds?.verificationToken,
|
|
128
|
+
domain: creds?.domain ?? "feishu",
|
|
129
|
+
config: merged,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* List all enabled and configured accounts.
|
|
135
|
+
*/
|
|
136
|
+
export function listEnabledFeishuAccounts(cfg: ClawdbotConfig): ResolvedFeishuAccount[] {
|
|
137
|
+
return listFeishuAccountIds(cfg)
|
|
138
|
+
.map((accountId) => resolveFeishuAccount({ cfg, accountId }))
|
|
139
|
+
.filter((account) => account.enabled && account.configured);
|
|
140
|
+
}
|