@superbenxxxh/feishu 2.0.0 → 3.0.0
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/README.md +423 -322
- package/index.ts +21 -13
- package/openclaw.plugin.json +10 -9
- package/package.json +2 -1
- package/src/bot.ts +35 -21
- package/src/channel.ts +13 -2
- package/src/config-schema.ts +31 -11
- package/src/doc-schema.ts +47 -0
- package/src/docx.ts +506 -0
- package/src/drive-schema.ts +46 -0
- package/src/drive.ts +201 -0
- package/src/perm-schema.ts +52 -0
- package/src/perm.ts +160 -0
- package/src/tools-config.ts +21 -0
- package/src/types.ts +13 -5
- package/src/wiki-schema.ts +55 -0
- package/src/wiki.ts +218 -0
package/index.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
3
|
-
import { feishuPlugin } from "./src/channel.js";
|
|
4
|
-
import { setFeishuRuntime } from "./src/runtime.js";
|
|
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";
|
|
5
9
|
|
|
6
10
|
export { monitorFeishuProvider } from "./src/monitor.js";
|
|
7
11
|
export {
|
|
@@ -40,14 +44,18 @@ export {
|
|
|
40
44
|
export { feishuPlugin } from "./src/channel.js";
|
|
41
45
|
|
|
42
46
|
const plugin = {
|
|
43
|
-
id: "feishu",
|
|
44
|
-
name: "Feishu",
|
|
45
|
-
description: "Feishu/Lark channel plugin",
|
|
46
|
-
configSchema: emptyPluginConfigSchema(),
|
|
47
|
-
register(api:
|
|
48
|
-
setFeishuRuntime(api.runtime);
|
|
49
|
-
api.registerChannel({ plugin: feishuPlugin });
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
id: "feishu",
|
|
48
|
+
name: "Feishu",
|
|
49
|
+
description: "Feishu/Lark channel plugin",
|
|
50
|
+
configSchema: emptyPluginConfigSchema(),
|
|
51
|
+
register(api: OpenClawPluginApi) {
|
|
52
|
+
setFeishuRuntime(api.runtime);
|
|
53
|
+
api.registerChannel({ plugin: feishuPlugin });
|
|
54
|
+
registerFeishuDocTools(api);
|
|
55
|
+
registerFeishuWikiTools(api);
|
|
56
|
+
registerFeishuDriveTools(api);
|
|
57
|
+
registerFeishuPermTools(api);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
52
60
|
|
|
53
61
|
export default plugin;
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "feishu",
|
|
3
|
-
"channels": ["feishu"],
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "feishu",
|
|
3
|
+
"channels": ["feishu"],
|
|
4
|
+
"skills": ["./skills"],
|
|
5
|
+
"configSchema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {}
|
|
9
|
+
}
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superbenxxxh/feishu",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenClaw Feishu/Lark channel plugin",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@larksuiteoapi/node-sdk": "^1.30.0",
|
|
49
|
+
"@sinclair/typebox": "^0.34.48",
|
|
49
50
|
"zod": "^4.3.6"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
package/src/bot.ts
CHANGED
|
@@ -428,27 +428,41 @@ export async function handleFeishuMessage(params: {
|
|
|
428
428
|
feishuCfg?.historyLimit ?? cfg.messages?.groupChat?.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT,
|
|
429
429
|
);
|
|
430
430
|
|
|
431
|
-
if (isGroup) {
|
|
432
|
-
const groupPolicy = feishuCfg?.groupPolicy ?? "open";
|
|
433
|
-
const groupAllowFrom = feishuCfg?.groupAllowFrom ?? [];
|
|
434
|
-
const groupConfig = resolveFeishuGroupConfig({ cfg: feishuCfg, groupId: ctx.chatId });
|
|
435
|
-
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
431
|
+
if (isGroup) {
|
|
432
|
+
const groupPolicy = feishuCfg?.groupPolicy ?? "open";
|
|
433
|
+
const groupAllowFrom = feishuCfg?.groupAllowFrom ?? [];
|
|
434
|
+
const groupConfig = resolveFeishuGroupConfig({ cfg: feishuCfg, groupId: ctx.chatId });
|
|
435
|
+
|
|
436
|
+
const groupAllowed = isFeishuGroupAllowed({
|
|
437
|
+
groupPolicy,
|
|
438
|
+
allowFrom: groupAllowFrom,
|
|
439
|
+
senderId: ctx.chatId,
|
|
440
|
+
senderName: undefined,
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
if (!groupAllowed) {
|
|
444
|
+
log(`feishu: group ${ctx.chatId} not in allowlist`);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const senderAllowFrom = groupConfig?.allowFrom ?? [];
|
|
449
|
+
if (senderAllowFrom.length > 0) {
|
|
450
|
+
const senderAllowed = isFeishuGroupAllowed({
|
|
451
|
+
groupPolicy: "allowlist",
|
|
452
|
+
allowFrom: senderAllowFrom,
|
|
453
|
+
senderId: ctx.senderOpenId,
|
|
454
|
+
senderName: ctx.senderName,
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
if (!senderAllowed) {
|
|
458
|
+
log(`feishu: sender ${ctx.senderOpenId} not in group ${ctx.chatId} allowlist`);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const { requireMention } = resolveFeishuReplyPolicy({
|
|
464
|
+
isDirectMessage: false,
|
|
465
|
+
globalConfig: feishuCfg,
|
|
452
466
|
groupConfig,
|
|
453
467
|
});
|
|
454
468
|
|
package/src/channel.ts
CHANGED
|
@@ -83,9 +83,20 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount> = {
|
|
|
83
83
|
historyLimit: { type: "integer", minimum: 0 },
|
|
84
84
|
dmHistoryLimit: { type: "integer", minimum: 0 },
|
|
85
85
|
textChunkLimit: { type: "integer", minimum: 1 },
|
|
86
|
-
chunkMode: { type: "string", enum: ["length", "newline"] },
|
|
87
|
-
mediaMaxMb: { type: "number", minimum: 0 },
|
|
86
|
+
chunkMode: { type: "string", enum: ["length", "newline"] },
|
|
87
|
+
mediaMaxMb: { type: "number", minimum: 0 },
|
|
88
88
|
renderMode: { type: "string", enum: ["auto", "raw", "post", "card"] },
|
|
89
|
+
tools: {
|
|
90
|
+
type: "object",
|
|
91
|
+
additionalProperties: false,
|
|
92
|
+
properties: {
|
|
93
|
+
doc: { type: "boolean" },
|
|
94
|
+
wiki: { type: "boolean" },
|
|
95
|
+
drive: { type: "boolean" },
|
|
96
|
+
perm: { type: "boolean" },
|
|
97
|
+
scopes: { type: "boolean" },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
89
100
|
},
|
|
90
101
|
},
|
|
91
102
|
},
|
package/src/config-schema.ts
CHANGED
|
@@ -42,13 +42,32 @@ const BlockStreamingCoalesceSchema = z
|
|
|
42
42
|
.strict()
|
|
43
43
|
.optional();
|
|
44
44
|
|
|
45
|
-
const ChannelHeartbeatVisibilitySchema = z
|
|
46
|
-
.object({
|
|
47
|
-
visibility: z.enum(["visible", "hidden"]).optional(),
|
|
48
|
-
intervalMs: z.number().int().positive().optional(),
|
|
49
|
-
})
|
|
50
|
-
.strict()
|
|
51
|
-
.optional();
|
|
45
|
+
const ChannelHeartbeatVisibilitySchema = z
|
|
46
|
+
.object({
|
|
47
|
+
visibility: z.enum(["visible", "hidden"]).optional(),
|
|
48
|
+
intervalMs: z.number().int().positive().optional(),
|
|
49
|
+
})
|
|
50
|
+
.strict()
|
|
51
|
+
.optional();
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Feishu tools configuration.
|
|
55
|
+
* Controls which tool categories are enabled.
|
|
56
|
+
*
|
|
57
|
+
* Dependencies:
|
|
58
|
+
* - wiki requires doc (wiki content is edited via doc tools)
|
|
59
|
+
* - perm can work independently but is typically used with drive
|
|
60
|
+
*/
|
|
61
|
+
const FeishuToolsConfigSchema = z
|
|
62
|
+
.object({
|
|
63
|
+
doc: z.boolean().optional(), // Document operations (default: true)
|
|
64
|
+
wiki: z.boolean().optional(), // Knowledge base operations (default: true, requires doc)
|
|
65
|
+
drive: z.boolean().optional(), // Cloud storage operations (default: true)
|
|
66
|
+
perm: z.boolean().optional(), // Permission management (default: false, sensitive)
|
|
67
|
+
scopes: z.boolean().optional(), // App scopes diagnostic (default: true)
|
|
68
|
+
})
|
|
69
|
+
.strict()
|
|
70
|
+
.optional();
|
|
52
71
|
|
|
53
72
|
export const FeishuGroupSchema = z
|
|
54
73
|
.object({
|
|
@@ -86,12 +105,13 @@ export const FeishuConfigSchema = z
|
|
|
86
105
|
dms: z.record(z.string(), DmConfigSchema).optional(),
|
|
87
106
|
textChunkLimit: z.number().int().positive().optional(),
|
|
88
107
|
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
89
|
-
blockStreamingCoalesce: BlockStreamingCoalesceSchema,
|
|
90
|
-
mediaMaxMb: z.number().positive().optional(),
|
|
91
|
-
heartbeat: ChannelHeartbeatVisibilitySchema,
|
|
108
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema,
|
|
109
|
+
mediaMaxMb: z.number().positive().optional(),
|
|
110
|
+
heartbeat: ChannelHeartbeatVisibilitySchema,
|
|
92
111
|
renderMode: RenderModeSchema, // post = rich text (default), raw = plain text, card = interactive card
|
|
112
|
+
tools: FeishuToolsConfigSchema,
|
|
93
113
|
})
|
|
94
|
-
.strict()
|
|
114
|
+
.strict()
|
|
95
115
|
.superRefine((value, ctx) => {
|
|
96
116
|
if (value.dmPolicy === "open") {
|
|
97
117
|
const allowFrom = value.allowFrom ?? [];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Type, type Static } from "@sinclair/typebox";
|
|
2
|
+
|
|
3
|
+
export const FeishuDocSchema = Type.Union([
|
|
4
|
+
Type.Object({
|
|
5
|
+
action: Type.Literal("read"),
|
|
6
|
+
doc_token: Type.String({ description: "Document token (extract from URL /docx/XXX)" }),
|
|
7
|
+
}),
|
|
8
|
+
Type.Object({
|
|
9
|
+
action: Type.Literal("write"),
|
|
10
|
+
doc_token: Type.String({ description: "Document token" }),
|
|
11
|
+
content: Type.String({
|
|
12
|
+
description: "Markdown content to write (replaces entire document content)",
|
|
13
|
+
}),
|
|
14
|
+
}),
|
|
15
|
+
Type.Object({
|
|
16
|
+
action: Type.Literal("append"),
|
|
17
|
+
doc_token: Type.String({ description: "Document token" }),
|
|
18
|
+
content: Type.String({ description: "Markdown content to append to end of document" }),
|
|
19
|
+
}),
|
|
20
|
+
Type.Object({
|
|
21
|
+
action: Type.Literal("create"),
|
|
22
|
+
title: Type.String({ description: "Document title" }),
|
|
23
|
+
folder_token: Type.Optional(Type.String({ description: "Target folder token (optional)" })),
|
|
24
|
+
}),
|
|
25
|
+
Type.Object({
|
|
26
|
+
action: Type.Literal("list_blocks"),
|
|
27
|
+
doc_token: Type.String({ description: "Document token" }),
|
|
28
|
+
}),
|
|
29
|
+
Type.Object({
|
|
30
|
+
action: Type.Literal("get_block"),
|
|
31
|
+
doc_token: Type.String({ description: "Document token" }),
|
|
32
|
+
block_id: Type.String({ description: "Block ID (from list_blocks)" }),
|
|
33
|
+
}),
|
|
34
|
+
Type.Object({
|
|
35
|
+
action: Type.Literal("update_block"),
|
|
36
|
+
doc_token: Type.String({ description: "Document token" }),
|
|
37
|
+
block_id: Type.String({ description: "Block ID (from list_blocks)" }),
|
|
38
|
+
content: Type.String({ description: "New text content" }),
|
|
39
|
+
}),
|
|
40
|
+
Type.Object({
|
|
41
|
+
action: Type.Literal("delete_block"),
|
|
42
|
+
doc_token: Type.String({ description: "Document token" }),
|
|
43
|
+
block_id: Type.String({ description: "Block ID" }),
|
|
44
|
+
}),
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
export type FeishuDocParams = Static<typeof FeishuDocSchema>;
|