@bobotu/feishu-fork 0.1.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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +922 -0
  3. package/index.ts +65 -0
  4. package/openclaw.plugin.json +10 -0
  5. package/package.json +72 -0
  6. package/skills/feishu-doc/SKILL.md +161 -0
  7. package/skills/feishu-doc/references/block-types.md +102 -0
  8. package/skills/feishu-drive/SKILL.md +96 -0
  9. package/skills/feishu-perm/SKILL.md +90 -0
  10. package/skills/feishu-task/SKILL.md +210 -0
  11. package/skills/feishu-wiki/SKILL.md +96 -0
  12. package/src/accounts.ts +140 -0
  13. package/src/bitable-tools/actions.ts +199 -0
  14. package/src/bitable-tools/common.ts +90 -0
  15. package/src/bitable-tools/index.ts +1 -0
  16. package/src/bitable-tools/meta.ts +80 -0
  17. package/src/bitable-tools/register.ts +195 -0
  18. package/src/bitable-tools/schemas.ts +221 -0
  19. package/src/bot.ts +1125 -0
  20. package/src/channel.ts +334 -0
  21. package/src/client.ts +114 -0
  22. package/src/config-schema.ts +237 -0
  23. package/src/dedup.ts +54 -0
  24. package/src/directory.ts +165 -0
  25. package/src/doc-tools/actions.ts +341 -0
  26. package/src/doc-tools/common.ts +33 -0
  27. package/src/doc-tools/index.ts +2 -0
  28. package/src/doc-tools/register.ts +90 -0
  29. package/src/doc-tools/schemas.ts +85 -0
  30. package/src/doc-write-service.ts +711 -0
  31. package/src/drive-tools/actions.ts +182 -0
  32. package/src/drive-tools/common.ts +18 -0
  33. package/src/drive-tools/index.ts +2 -0
  34. package/src/drive-tools/register.ts +71 -0
  35. package/src/drive-tools/schemas.ts +67 -0
  36. package/src/dynamic-agent.ts +135 -0
  37. package/src/external-keys.ts +19 -0
  38. package/src/media.ts +510 -0
  39. package/src/mention.ts +121 -0
  40. package/src/monitor.ts +323 -0
  41. package/src/onboarding.ts +449 -0
  42. package/src/outbound.ts +40 -0
  43. package/src/perm-tools/actions.ts +111 -0
  44. package/src/perm-tools/common.ts +18 -0
  45. package/src/perm-tools/index.ts +2 -0
  46. package/src/perm-tools/register.ts +65 -0
  47. package/src/perm-tools/schemas.ts +52 -0
  48. package/src/policy.ts +117 -0
  49. package/src/probe.ts +147 -0
  50. package/src/reactions.ts +160 -0
  51. package/src/reply-dispatcher.ts +240 -0
  52. package/src/runtime.ts +14 -0
  53. package/src/send.ts +391 -0
  54. package/src/streaming-card.ts +211 -0
  55. package/src/targets.ts +58 -0
  56. package/src/task-tools/actions.ts +590 -0
  57. package/src/task-tools/common.ts +18 -0
  58. package/src/task-tools/constants.ts +13 -0
  59. package/src/task-tools/index.ts +1 -0
  60. package/src/task-tools/register.ts +263 -0
  61. package/src/task-tools/schemas.ts +567 -0
  62. package/src/text/markdown-links.ts +104 -0
  63. package/src/tools-common/feishu-api.ts +184 -0
  64. package/src/tools-common/tool-context.ts +23 -0
  65. package/src/tools-common/tool-exec.ts +73 -0
  66. package/src/tools-config.ts +22 -0
  67. package/src/types.ts +79 -0
  68. package/src/typing.ts +75 -0
  69. package/src/wiki-tools/actions.ts +166 -0
  70. package/src/wiki-tools/common.ts +18 -0
  71. package/src/wiki-tools/index.ts +2 -0
  72. package/src/wiki-tools/register.ts +66 -0
  73. package/src/wiki-tools/schemas.ts +55 -0
@@ -0,0 +1,66 @@
1
+ import type { TSchema } from "@sinclair/typebox";
2
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
3
+ import { hasFeishuToolEnabledForAnyAccount, withFeishuToolClient } from "../tools-common/tool-exec.js";
4
+ import { runWikiAction } from "./actions.js";
5
+ import { errorResult, json, type WikiClient } from "./common.js";
6
+ import { FeishuWikiSchema, type FeishuWikiParams } from "./schemas.js";
7
+
8
+ type WikiToolSpec<P> = {
9
+ name: string;
10
+ label: string;
11
+ description: string;
12
+ parameters: TSchema;
13
+ run: (client: WikiClient, params: P) => Promise<unknown>;
14
+ };
15
+
16
+ function registerWikiTool<P>(api: OpenClawPluginApi, spec: WikiToolSpec<P>) {
17
+ api.registerTool(
18
+ {
19
+ name: spec.name,
20
+ label: spec.label,
21
+ description: spec.description,
22
+ parameters: spec.parameters,
23
+ async execute(_toolCallId, params) {
24
+ try {
25
+ return await withFeishuToolClient({
26
+ api,
27
+ toolName: spec.name,
28
+ requiredTool: "wiki",
29
+ run: async ({ client }) => json(await spec.run(client as WikiClient, params as P)),
30
+ });
31
+ } catch (err) {
32
+ return errorResult(err);
33
+ }
34
+ },
35
+ },
36
+ { name: spec.name },
37
+ );
38
+ }
39
+
40
+ export function registerFeishuWikiTools(api: OpenClawPluginApi) {
41
+ if (!api.config) {
42
+ api.logger.debug?.("feishu_wiki: No config available, skipping wiki tools");
43
+ return;
44
+ }
45
+
46
+ if (!hasFeishuToolEnabledForAnyAccount(api.config)) {
47
+ api.logger.debug?.("feishu_wiki: No Feishu accounts configured, skipping wiki tools");
48
+ return;
49
+ }
50
+
51
+ if (!hasFeishuToolEnabledForAnyAccount(api.config, "wiki")) {
52
+ api.logger.debug?.("feishu_wiki: wiki tool disabled in config");
53
+ return;
54
+ }
55
+
56
+ registerWikiTool<FeishuWikiParams>(api, {
57
+ name: "feishu_wiki",
58
+ label: "Feishu Wiki",
59
+ description:
60
+ "Feishu knowledge base operations. Actions: spaces, nodes, get, create, move, rename",
61
+ parameters: FeishuWikiSchema,
62
+ run: (client, params) => runWikiAction(client, params),
63
+ });
64
+
65
+ api.logger.debug?.("feishu_wiki: Registered feishu_wiki tool");
66
+ }
@@ -0,0 +1,55 @@
1
+ import { Type, type Static } from "@sinclair/typebox";
2
+
3
+ export const FeishuWikiSchema = Type.Union([
4
+ Type.Object({
5
+ action: Type.Literal("spaces"),
6
+ }),
7
+ Type.Object({
8
+ action: Type.Literal("nodes"),
9
+ space_id: Type.String({ description: "Knowledge space ID" }),
10
+ parent_node_token: Type.Optional(
11
+ Type.String({ description: "Parent node token (optional, omit for root)" }),
12
+ ),
13
+ }),
14
+ Type.Object({
15
+ action: Type.Literal("get"),
16
+ token: Type.String({ description: "Wiki node token (from URL /wiki/XXX)" }),
17
+ }),
18
+ Type.Object({
19
+ action: Type.Literal("search"),
20
+ query: Type.String({ description: "Search query" }),
21
+ space_id: Type.Optional(Type.String({ description: "Limit search to this space (optional)" })),
22
+ }),
23
+ Type.Object({
24
+ action: Type.Literal("create"),
25
+ space_id: Type.String({ description: "Knowledge space ID" }),
26
+ title: Type.String({ description: "Node title" }),
27
+ obj_type: Type.Optional(
28
+ Type.Union([Type.Literal("docx"), Type.Literal("sheet"), Type.Literal("bitable")], {
29
+ description: "Object type (default: docx)",
30
+ }),
31
+ ),
32
+ parent_node_token: Type.Optional(
33
+ Type.String({ description: "Parent node token (optional, omit for root)" }),
34
+ ),
35
+ }),
36
+ Type.Object({
37
+ action: Type.Literal("move"),
38
+ space_id: Type.String({ description: "Source knowledge space ID" }),
39
+ node_token: Type.String({ description: "Node token to move" }),
40
+ target_space_id: Type.Optional(
41
+ Type.String({ description: "Target space ID (optional, same space if omitted)" }),
42
+ ),
43
+ target_parent_token: Type.Optional(
44
+ Type.String({ description: "Target parent node token (optional, root if omitted)" }),
45
+ ),
46
+ }),
47
+ Type.Object({
48
+ action: Type.Literal("rename"),
49
+ space_id: Type.String({ description: "Knowledge space ID" }),
50
+ node_token: Type.String({ description: "Node token to rename" }),
51
+ title: Type.String({ description: "New title" }),
52
+ }),
53
+ ]);
54
+
55
+ export type FeishuWikiParams = Static<typeof FeishuWikiSchema>;