@max1874/feishu 0.2.20 → 0.2.22

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/docx.ts +58 -36
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@max1874/feishu",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "type": "module",
5
5
  "description": "OpenClaw Feishu/Lark channel plugin",
6
6
  "license": "MIT",
package/src/docx.ts CHANGED
@@ -508,19 +508,6 @@ async function grantFullAccess(client: Lark.Client, docToken: string, memberId:
508
508
  return res.data;
509
509
  }
510
510
 
511
- const DEFAULT_COVER_TOKEN = "KeMcb0lJdosqhtx4aAglZjaWgug";
512
-
513
- async function setDocCover(client: Lark.Client, docId: string, coverToken: string) {
514
- // SDK lacks document.patch — use client.request() which auto-injects tenant_access_token and domain
515
- await (client as any).request({
516
- method: "PATCH",
517
- url: `/open-apis/docx/v1/documents/${docId}`,
518
- data: {
519
- cover: { token: coverToken, offset_ratio_x: 0, offset_ratio_y: 0 },
520
- },
521
- });
522
- }
523
-
524
511
  async function createDoc(
525
512
  client: Lark.Client,
526
513
  title: string,
@@ -552,15 +539,6 @@ async function createDoc(
552
539
  }
553
540
  }
554
541
 
555
- // Set default cover
556
- if (docId) {
557
- try {
558
- await setDocCover(client, docId, DEFAULT_COVER_TOKEN);
559
- } catch (e) {
560
- console.warn("[docx] setDocCover failed:", e);
561
- }
562
- }
563
-
564
542
  return {
565
543
  document_id: docId,
566
544
  title: doc?.title,
@@ -887,7 +865,11 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
887
865
  {
888
866
  name: "feishu_doc_read",
889
867
  label: "Feishu Doc Read",
890
- description: "Read plain text content and metadata from a Feishu document",
868
+ description:
869
+ "Read plain text content and metadata from a Feishu document. " +
870
+ "Use this for a quick overview of document content. " +
871
+ "For structured content (tables, block details), use feishu_doc_list_blocks instead. " +
872
+ "Extract doc_token from URL: /docx/XXX or /docs/XXX.",
891
873
  parameters: DocTokenSchema,
892
874
  async execute(_toolCallId, params) {
893
875
  const { doc_token } = params as { doc_token: string };
@@ -908,7 +890,10 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
908
890
  name: "feishu_doc_create",
909
891
  label: "Feishu Doc Create",
910
892
  description:
911
- "Create a new empty Feishu document. Automatically grants full_access (manage) permission to the current conversation participant.",
893
+ "Create a new empty Feishu document. " +
894
+ "Automatically grants full_access permission to the conversation participant so they can edit. " +
895
+ "After creating, use feishu_doc_write to populate content. " +
896
+ "Set permission='tenant_editable' to allow anyone in the organization to edit via link.",
912
897
  parameters: CreateDocSchema,
913
898
  async execute(_toolCallId, params) {
914
899
  const { title, folder_token, permission } = params as {
@@ -933,7 +918,10 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
933
918
  name: "feishu_doc_write",
934
919
  label: "Feishu Doc Write",
935
920
  description:
936
- "Write markdown content to a Feishu document (replaces all content). Supports headings, lists, code blocks, quotes, links, images, tables, and text styling.",
921
+ "Write markdown content to a Feishu document. WARNING: This REPLACES ALL existing content. " +
922
+ "Use for: initial document population, complete rewrites. " +
923
+ "For partial edits, use feishu_doc_update_block instead. " +
924
+ "Supports: headings, lists, code blocks, quotes, links, images, tables, bold/italic/strikethrough.",
937
925
  parameters: WriteDocSchema,
938
926
  async execute(_toolCallId, params) {
939
927
  const { doc_token, content } = params as { doc_token: string; content: string };
@@ -954,7 +942,10 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
954
942
  name: "feishu_doc_append",
955
943
  label: "Feishu Doc Append",
956
944
  description:
957
- "Append markdown content to the end of a Feishu document. Supports same markdown syntax as write.",
945
+ "Append markdown content to the END of a Feishu document without touching existing content. " +
946
+ "Use for: adding new sections, logging, incremental content building. " +
947
+ "Cannot insert in the middle - for that, use feishu_doc_update_block or delete+append. " +
948
+ "Supports same markdown syntax as feishu_doc_write.",
958
949
  parameters: AppendDocSchema,
959
950
  async execute(_toolCallId, params) {
960
951
  const { doc_token, content } = params as { doc_token: string; content: string };
@@ -974,7 +965,11 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
974
965
  {
975
966
  name: "feishu_doc_update_block",
976
967
  label: "Feishu Doc Update Block",
977
- description: "Update the text content of a specific block in a Feishu document",
968
+ description:
969
+ "Update the text content of a specific block without affecting other parts of the document. " +
970
+ "WORKFLOW: First call feishu_doc_list_blocks to find the block_id, then update it here. " +
971
+ "Use for: fixing typos, updating a paragraph, modifying specific sections. " +
972
+ "Only works on text-based blocks (paragraphs, headings, lists). Cannot change block type.",
978
973
  parameters: UpdateBlockSchema,
979
974
  async execute(_toolCallId, params) {
980
975
  const { doc_token, block_id, content } = params as {
@@ -998,7 +993,11 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
998
993
  {
999
994
  name: "feishu_doc_delete_block",
1000
995
  label: "Feishu Doc Delete Block",
1001
- description: "Delete a specific block from a Feishu document",
996
+ description:
997
+ "Delete a specific block from a Feishu document. " +
998
+ "WORKFLOW: First call feishu_doc_list_blocks to find the block_id, then delete it here. " +
999
+ "Use for: removing outdated content, clearing sections before rewriting. " +
1000
+ "Combine with feishu_doc_append to replace content in the middle of a document.",
1002
1001
  parameters: DeleteBlockSchema,
1003
1002
  async execute(_toolCallId, params) {
1004
1003
  const { doc_token, block_id } = params as { doc_token: string; block_id: string };
@@ -1019,7 +1018,10 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
1019
1018
  name: "feishu_doc_list_blocks",
1020
1019
  label: "Feishu Doc List Blocks",
1021
1020
  description:
1022
- "List all blocks in a Feishu document with full content. Use this to read structured content like tables. Returns block_id for use with update/delete/get_block.",
1021
+ "List all blocks in a Feishu document with their block_id and full content. " +
1022
+ "ESSENTIAL for editing: returns block_id needed by update_block/delete_block/get_block. " +
1023
+ "Better than feishu_doc_read for: seeing document structure, reading tables, finding specific sections. " +
1024
+ "Block types include: text, headings (1-9), bullet/ordered lists, code, quote, table, image, divider.",
1023
1025
  parameters: DocTokenSchema,
1024
1026
  async execute(_toolCallId, params) {
1025
1027
  const { doc_token } = params as { doc_token: string };
@@ -1039,7 +1041,10 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
1039
1041
  {
1040
1042
  name: "feishu_doc_get_block",
1041
1043
  label: "Feishu Doc Get Block",
1042
- description: "Get detailed content of a specific block by ID (from list_blocks)",
1044
+ description:
1045
+ "Get detailed content of a specific block by its block_id. " +
1046
+ "Use when feishu_doc_list_blocks output is truncated or you need fresh data for one block. " +
1047
+ "Returns full block structure including nested content (e.g., table cells).",
1043
1048
  parameters: GetBlockSchema,
1044
1049
  async execute(_toolCallId, params) {
1045
1050
  const { doc_token, block_id } = params as { doc_token: string; block_id: string };
@@ -1059,7 +1064,11 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
1059
1064
  {
1060
1065
  name: "feishu_folder_list",
1061
1066
  label: "Feishu Folder List",
1062
- description: "List documents and subfolders in a Feishu folder",
1067
+ description:
1068
+ "List documents and subfolders in a Feishu Drive folder. " +
1069
+ "Extract folder_token from URL: /drive/folder/XXX. " +
1070
+ "Use to browse available documents or find a doc_token to read/edit. " +
1071
+ "Returns: file name, type (docx/sheet/folder/etc), token, URL, last modified time.",
1063
1072
  parameters: FolderTokenSchema,
1064
1073
  async execute(_toolCallId, params) {
1065
1074
  const { folder_token } = params as { folder_token: string };
@@ -1080,7 +1089,9 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
1080
1089
  name: "feishu_doc_set_permission",
1081
1090
  label: "Feishu Doc Set Permission",
1082
1091
  description:
1083
- "Set document sharing permission. Use 'tenant_editable' to allow organization members to edit via link.",
1092
+ "Change document sharing permissions after creation. " +
1093
+ "Options: 'tenant_editable' = anyone in organization can edit via link; 'private' = only owner/explicitly granted users. " +
1094
+ "Note: feishu_doc_create already grants full_access to the conversation participant.",
1084
1095
  parameters: SetPermissionSchema,
1085
1096
  async execute(_toolCallId, params) {
1086
1097
  const { doc_token, permission } = params as { doc_token: string; permission: DocPermission };
@@ -1116,7 +1127,10 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
1116
1127
  name: "feishu_wiki_read",
1117
1128
  label: "Feishu Wiki Read",
1118
1129
  description:
1119
- "Read content from a Feishu wiki page. Extract wiki_token from URL /wiki/XXX. Returns wiki metadata and document content if the underlying type is docx.",
1130
+ "Read content from a Feishu Wiki (knowledge base) page. " +
1131
+ "Extract wiki_token from URL: /wiki/XXX. " +
1132
+ "Different from feishu_doc_read - wikis have their own token format and metadata. " +
1133
+ "Returns wiki node info and document content if the underlying type is docx.",
1120
1134
  parameters: WikiTokenSchema,
1121
1135
  async execute(_toolCallId, params) {
1122
1136
  const { wiki_token } = params as { wiki_token: string };
@@ -1136,7 +1150,10 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
1136
1150
  {
1137
1151
  name: "feishu_wiki_spaces",
1138
1152
  label: "Feishu Wiki Spaces",
1139
- description: "List available wiki spaces (knowledge bases) the app has access to.",
1153
+ description:
1154
+ "List all Wiki spaces (knowledge bases) the app has access to. " +
1155
+ "Returns space_id needed for feishu_wiki_nodes. " +
1156
+ "Use this first when browsing wikis to find the right knowledge base.",
1140
1157
  parameters: Type.Object({}),
1141
1158
  async execute() {
1142
1159
  try {
@@ -1156,7 +1173,10 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
1156
1173
  name: "feishu_wiki_nodes",
1157
1174
  label: "Feishu Wiki Nodes",
1158
1175
  description:
1159
- "List wiki nodes (pages) in a space. Use parent_node_token to list children of a specific node.",
1176
+ "List wiki pages within a Wiki space. " +
1177
+ "WORKFLOW: First call feishu_wiki_spaces to get space_id, then list nodes here. " +
1178
+ "Use parent_node_token to browse nested pages (children of a specific node). " +
1179
+ "Returns node_token for use with feishu_wiki_read.",
1160
1180
  parameters: WikiSpaceIdSchema,
1161
1181
  async execute(_toolCallId, params) {
1162
1182
  const { space_id, parent_node_token } = params as {
@@ -1180,7 +1200,9 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
1180
1200
  name: "feishu_app_scopes",
1181
1201
  label: "Feishu App Scopes",
1182
1202
  description:
1183
- "List current app permissions (scopes). Use to debug permission issues or check available capabilities.",
1203
+ "List the app's current permissions (scopes) granted in Feishu admin console. " +
1204
+ "Use when a tool fails with permission errors to diagnose what's missing. " +
1205
+ "Common required scopes: docx:document (read/edit docs), wiki:wiki (read wikis), drive:drive (folder access).",
1184
1206
  parameters: Type.Object({}),
1185
1207
  async execute() {
1186
1208
  try {