@openclaw/feishu 2026.5.2 → 2026.5.3-beta.2

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 (224) hide show
  1. package/dist/accounts-Ba3-WP1z.js +423 -0
  2. package/dist/api.js +2280 -0
  3. package/dist/app-registration-B8qc1MCM.js +184 -0
  4. package/dist/audio-preflight.runtime-BPlzkO3l.js +7 -0
  5. package/dist/card-interaction-BfRLgvw_.js +96 -0
  6. package/dist/channel-CSD_Jt8I.js +1668 -0
  7. package/dist/channel-entry.js +22 -0
  8. package/dist/channel-plugin-api.js +2 -0
  9. package/dist/channel.runtime-DYsXcD36.js +700 -0
  10. package/dist/client-DBVoQL5w.js +157 -0
  11. package/dist/contract-api.js +9 -0
  12. package/dist/conversation-id-DWS3Ep2A.js +139 -0
  13. package/dist/directory.static-f3EeoRJd.js +44 -0
  14. package/dist/drive-C5eJLJr7.js +883 -0
  15. package/dist/index.js +68 -0
  16. package/dist/monitor-CT189QfR.js +60 -0
  17. package/dist/monitor.account-dJV2jO8C.js +4990 -0
  18. package/dist/monitor.state-DYM02ipp.js +100 -0
  19. package/dist/policy-D6c-wMPl.js +118 -0
  20. package/dist/probe-BNzzU_uR.js +149 -0
  21. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  22. package/dist/runtime-CG0DuRCy.js +8 -0
  23. package/dist/runtime-api.js +14 -0
  24. package/dist/secret-contract-Dm4Z_zQN.js +119 -0
  25. package/dist/secret-contract-api.js +2 -0
  26. package/dist/security-audit-DqJdocrN.js +11 -0
  27. package/dist/security-audit-shared-ByuMx9cJ.js +38 -0
  28. package/dist/security-contract-api.js +2 -0
  29. package/dist/send-DowxxbpH.js +1218 -0
  30. package/dist/session-conversation-B4nrW-vo.js +27 -0
  31. package/dist/session-key-api.js +2 -0
  32. package/dist/setup-api.js +2 -0
  33. package/dist/setup-entry.js +15 -0
  34. package/dist/subagent-hooks-C3UhPVLV.js +227 -0
  35. package/dist/subagent-hooks-api.js +23 -0
  36. package/dist/targets-JMFJRKSe.js +48 -0
  37. package/dist/thread-bindings-BmS6TLes.js +222 -0
  38. package/package.json +15 -6
  39. package/api.ts +0 -31
  40. package/channel-entry.ts +0 -20
  41. package/channel-plugin-api.ts +0 -1
  42. package/contract-api.ts +0 -16
  43. package/index.ts +0 -82
  44. package/runtime-api.ts +0 -55
  45. package/secret-contract-api.ts +0 -5
  46. package/security-contract-api.ts +0 -1
  47. package/session-key-api.ts +0 -1
  48. package/setup-api.ts +0 -3
  49. package/setup-entry.test.ts +0 -14
  50. package/setup-entry.ts +0 -13
  51. package/src/accounts.test.ts +0 -459
  52. package/src/accounts.ts +0 -326
  53. package/src/app-registration.ts +0 -331
  54. package/src/approval-auth.test.ts +0 -24
  55. package/src/approval-auth.ts +0 -25
  56. package/src/async.test.ts +0 -35
  57. package/src/async.ts +0 -104
  58. package/src/audio-preflight.runtime.ts +0 -9
  59. package/src/bitable.test.ts +0 -131
  60. package/src/bitable.ts +0 -762
  61. package/src/bot-content.ts +0 -474
  62. package/src/bot-group-name.test.ts +0 -108
  63. package/src/bot-runtime-api.ts +0 -12
  64. package/src/bot-sender-name.ts +0 -125
  65. package/src/bot.broadcast.test.ts +0 -463
  66. package/src/bot.card-action.test.ts +0 -577
  67. package/src/bot.checkBotMentioned.test.ts +0 -265
  68. package/src/bot.helpers.test.ts +0 -118
  69. package/src/bot.stripBotMention.test.ts +0 -126
  70. package/src/bot.test.ts +0 -3040
  71. package/src/bot.ts +0 -1559
  72. package/src/card-action.ts +0 -447
  73. package/src/card-interaction.test.ts +0 -129
  74. package/src/card-interaction.ts +0 -159
  75. package/src/card-test-helpers.ts +0 -47
  76. package/src/card-ux-approval.ts +0 -65
  77. package/src/card-ux-launcher.test.ts +0 -99
  78. package/src/card-ux-launcher.ts +0 -121
  79. package/src/card-ux-shared.ts +0 -33
  80. package/src/channel-runtime-api.ts +0 -16
  81. package/src/channel.runtime.ts +0 -47
  82. package/src/channel.test.ts +0 -959
  83. package/src/channel.ts +0 -1313
  84. package/src/chat-schema.ts +0 -25
  85. package/src/chat.test.ts +0 -196
  86. package/src/chat.ts +0 -188
  87. package/src/client.test.ts +0 -433
  88. package/src/client.ts +0 -290
  89. package/src/comment-dispatcher-runtime-api.ts +0 -6
  90. package/src/comment-dispatcher.test.ts +0 -169
  91. package/src/comment-dispatcher.ts +0 -107
  92. package/src/comment-handler-runtime-api.ts +0 -3
  93. package/src/comment-handler.test.ts +0 -486
  94. package/src/comment-handler.ts +0 -309
  95. package/src/comment-reaction.test.ts +0 -166
  96. package/src/comment-reaction.ts +0 -259
  97. package/src/comment-shared.test.ts +0 -182
  98. package/src/comment-shared.ts +0 -406
  99. package/src/comment-target.ts +0 -44
  100. package/src/config-schema.test.ts +0 -309
  101. package/src/config-schema.ts +0 -333
  102. package/src/conversation-id.test.ts +0 -18
  103. package/src/conversation-id.ts +0 -199
  104. package/src/dedup-runtime-api.ts +0 -1
  105. package/src/dedup.ts +0 -141
  106. package/src/directory.static.ts +0 -61
  107. package/src/directory.test.ts +0 -136
  108. package/src/directory.ts +0 -124
  109. package/src/doc-schema.ts +0 -182
  110. package/src/docx-batch-insert.test.ts +0 -91
  111. package/src/docx-batch-insert.ts +0 -223
  112. package/src/docx-color-text.ts +0 -154
  113. package/src/docx-table-ops.test.ts +0 -53
  114. package/src/docx-table-ops.ts +0 -316
  115. package/src/docx-types.ts +0 -38
  116. package/src/docx.account-selection.test.ts +0 -79
  117. package/src/docx.test.ts +0 -685
  118. package/src/docx.ts +0 -1616
  119. package/src/drive-schema.ts +0 -92
  120. package/src/drive.test.ts +0 -1219
  121. package/src/drive.ts +0 -829
  122. package/src/dynamic-agent.ts +0 -137
  123. package/src/event-types.ts +0 -45
  124. package/src/external-keys.test.ts +0 -20
  125. package/src/external-keys.ts +0 -19
  126. package/src/lifecycle.test-support.ts +0 -220
  127. package/src/media.test.ts +0 -900
  128. package/src/media.ts +0 -861
  129. package/src/mention-target.types.ts +0 -5
  130. package/src/mention.ts +0 -114
  131. package/src/message-action-contract.ts +0 -13
  132. package/src/monitor-state-runtime-api.ts +0 -7
  133. package/src/monitor-transport-runtime-api.ts +0 -7
  134. package/src/monitor.account.ts +0 -468
  135. package/src/monitor.acp-init-failure.lifecycle.test-support.ts +0 -219
  136. package/src/monitor.bot-identity.ts +0 -86
  137. package/src/monitor.bot-menu-handler.ts +0 -165
  138. package/src/monitor.bot-menu.lifecycle.test-support.ts +0 -224
  139. package/src/monitor.bot-menu.test.ts +0 -178
  140. package/src/monitor.broadcast.reply-once.lifecycle.test-support.ts +0 -264
  141. package/src/monitor.card-action.lifecycle.test-support.ts +0 -373
  142. package/src/monitor.cleanup.test.ts +0 -376
  143. package/src/monitor.comment-notice-handler.ts +0 -105
  144. package/src/monitor.comment.test.ts +0 -937
  145. package/src/monitor.comment.ts +0 -1386
  146. package/src/monitor.lifecycle.test.ts +0 -4
  147. package/src/monitor.message-handler.ts +0 -339
  148. package/src/monitor.reaction.lifecycle.test-support.ts +0 -68
  149. package/src/monitor.reaction.test.ts +0 -713
  150. package/src/monitor.startup.test.ts +0 -192
  151. package/src/monitor.startup.ts +0 -74
  152. package/src/monitor.state.defaults.test.ts +0 -46
  153. package/src/monitor.state.ts +0 -170
  154. package/src/monitor.synthetic-error.ts +0 -18
  155. package/src/monitor.test-mocks.ts +0 -45
  156. package/src/monitor.transport.ts +0 -424
  157. package/src/monitor.ts +0 -100
  158. package/src/monitor.webhook-e2e.test.ts +0 -272
  159. package/src/monitor.webhook-security.test.ts +0 -264
  160. package/src/monitor.webhook.test-helpers.ts +0 -116
  161. package/src/outbound-runtime-api.ts +0 -1
  162. package/src/outbound.test.ts +0 -935
  163. package/src/outbound.ts +0 -718
  164. package/src/perm-schema.ts +0 -52
  165. package/src/perm.ts +0 -170
  166. package/src/pins.ts +0 -108
  167. package/src/policy.test.ts +0 -334
  168. package/src/policy.ts +0 -236
  169. package/src/post.test.ts +0 -105
  170. package/src/post.ts +0 -275
  171. package/src/probe.test.ts +0 -275
  172. package/src/probe.ts +0 -166
  173. package/src/processing-claims.ts +0 -59
  174. package/src/qr-terminal.ts +0 -1
  175. package/src/reactions.ts +0 -123
  176. package/src/reasoning-preview.test.ts +0 -59
  177. package/src/reasoning-preview.ts +0 -20
  178. package/src/reply-dispatcher-runtime-api.ts +0 -7
  179. package/src/reply-dispatcher.test.ts +0 -1144
  180. package/src/reply-dispatcher.ts +0 -650
  181. package/src/runtime.ts +0 -9
  182. package/src/secret-contract.ts +0 -145
  183. package/src/secret-input.ts +0 -1
  184. package/src/security-audit-shared.ts +0 -69
  185. package/src/security-audit.test.ts +0 -61
  186. package/src/security-audit.ts +0 -1
  187. package/src/send-result.ts +0 -29
  188. package/src/send-target.test.ts +0 -80
  189. package/src/send-target.ts +0 -35
  190. package/src/send.reply-fallback.test.ts +0 -292
  191. package/src/send.test.ts +0 -550
  192. package/src/send.ts +0 -800
  193. package/src/sequential-key.test.ts +0 -72
  194. package/src/sequential-key.ts +0 -28
  195. package/src/sequential-queue.test.ts +0 -92
  196. package/src/sequential-queue.ts +0 -16
  197. package/src/session-conversation.ts +0 -42
  198. package/src/session-route.ts +0 -48
  199. package/src/setup-core.ts +0 -51
  200. package/src/setup-surface.test.ts +0 -174
  201. package/src/setup-surface.ts +0 -581
  202. package/src/streaming-card.test.ts +0 -190
  203. package/src/streaming-card.ts +0 -490
  204. package/src/subagent-hooks.test.ts +0 -603
  205. package/src/subagent-hooks.ts +0 -397
  206. package/src/targets.ts +0 -97
  207. package/src/test-support/lifecycle-test-support.ts +0 -453
  208. package/src/thread-bindings.test.ts +0 -143
  209. package/src/thread-bindings.ts +0 -330
  210. package/src/tool-account-routing.test.ts +0 -187
  211. package/src/tool-account.test.ts +0 -44
  212. package/src/tool-account.ts +0 -93
  213. package/src/tool-factory-test-harness.ts +0 -79
  214. package/src/tool-result.test.ts +0 -32
  215. package/src/tool-result.ts +0 -16
  216. package/src/tools-config.test.ts +0 -21
  217. package/src/tools-config.ts +0 -22
  218. package/src/types.ts +0 -104
  219. package/src/typing.test.ts +0 -144
  220. package/src/typing.ts +0 -214
  221. package/src/wiki-schema.ts +0 -55
  222. package/src/wiki.ts +0 -227
  223. package/subagent-hooks-api.ts +0 -31
  224. package/tsconfig.json +0 -16
@@ -1,25 +0,0 @@
1
- import { Type, type Static } from "typebox";
2
-
3
- const CHAT_ACTION_VALUES = ["members", "info", "member_info"] as const;
4
- const MEMBER_ID_TYPE_VALUES = ["open_id", "user_id", "union_id"] as const;
5
-
6
- export const FeishuChatSchema = Type.Object({
7
- action: Type.Unsafe<(typeof CHAT_ACTION_VALUES)[number]>({
8
- type: "string",
9
- enum: [...CHAT_ACTION_VALUES],
10
- description: "Action to run: members | info | member_info",
11
- }),
12
- chat_id: Type.Optional(Type.String({ description: "Chat ID (from URL or event payload)" })),
13
- member_id: Type.Optional(Type.String({ description: "Member ID for member_info lookups" })),
14
- page_size: Type.Optional(Type.Number({ description: "Page size (1-100, default 50)" })),
15
- page_token: Type.Optional(Type.String({ description: "Pagination token" })),
16
- member_id_type: Type.Optional(
17
- Type.Unsafe<(typeof MEMBER_ID_TYPE_VALUES)[number]>({
18
- type: "string",
19
- enum: [...MEMBER_ID_TYPE_VALUES],
20
- description: "Member ID type (default: open_id)",
21
- }),
22
- ),
23
- });
24
-
25
- export type FeishuChatParams = Static<typeof FeishuChatSchema>;
package/src/chat.test.ts DELETED
@@ -1,196 +0,0 @@
1
- import { createTestPluginApi } from "openclaw/plugin-sdk/plugin-test-api";
2
- import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
3
- import type { OpenClawPluginApi, PluginRuntime } from "../runtime-api.js";
4
-
5
- const createFeishuClientMock = vi.hoisted(() => vi.fn());
6
- const chatGetMock = vi.hoisted(() => vi.fn());
7
- const chatMembersGetMock = vi.hoisted(() => vi.fn());
8
- const contactUserGetMock = vi.hoisted(() => vi.fn());
9
-
10
- vi.mock("./client.js", () => ({
11
- createFeishuClient: createFeishuClientMock,
12
- }));
13
-
14
- let registerFeishuChatTools: typeof import("./chat.js").registerFeishuChatTools;
15
-
16
- function createFeishuToolRuntime(): PluginRuntime {
17
- return {} as PluginRuntime;
18
- }
19
-
20
- describe("registerFeishuChatTools", () => {
21
- function createChatToolApi(params: {
22
- config: OpenClawPluginApi["config"];
23
- registerTool: OpenClawPluginApi["registerTool"];
24
- }): OpenClawPluginApi {
25
- return createTestPluginApi({
26
- id: "feishu-test",
27
- name: "Feishu Test",
28
- source: "local",
29
- config: params.config,
30
- runtime: createFeishuToolRuntime(),
31
- logger: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
32
- registerTool: params.registerTool,
33
- });
34
- }
35
-
36
- beforeAll(async () => {
37
- ({ registerFeishuChatTools } = await import("./chat.js"));
38
- });
39
-
40
- beforeEach(() => {
41
- vi.clearAllMocks();
42
- createFeishuClientMock.mockReturnValue({
43
- im: {
44
- chat: { get: chatGetMock },
45
- chatMembers: { get: chatMembersGetMock },
46
- },
47
- contact: {
48
- user: { get: contactUserGetMock },
49
- },
50
- });
51
- });
52
-
53
- it("registers feishu_chat and handles info/members actions", async () => {
54
- const registerTool = vi.fn();
55
- registerFeishuChatTools(
56
- createChatToolApi({
57
- config: {
58
- channels: {
59
- feishu: {
60
- enabled: true,
61
- appId: "app_id",
62
- appSecret: "app_secret", // pragma: allowlist secret
63
- tools: { chat: true },
64
- },
65
- },
66
- },
67
- registerTool,
68
- }),
69
- );
70
-
71
- expect(registerTool).toHaveBeenCalledTimes(1);
72
- const tool = registerTool.mock.calls[0]?.[0];
73
- expect(tool?.name).toBe("feishu_chat");
74
-
75
- chatGetMock.mockResolvedValueOnce({
76
- code: 0,
77
- data: { name: "group name", user_count: 3 },
78
- });
79
- const infoResult = await tool.execute("tc_1", { action: "info", chat_id: "oc_1" });
80
- expect(infoResult.details).toEqual(
81
- expect.objectContaining({ chat_id: "oc_1", name: "group name", user_count: 3 }),
82
- );
83
-
84
- chatMembersGetMock.mockResolvedValueOnce({
85
- code: 0,
86
- data: {
87
- has_more: false,
88
- page_token: "",
89
- items: [{ member_id: "ou_1", name: "member1", member_id_type: "open_id" }],
90
- },
91
- });
92
- const membersResult = await tool.execute("tc_2", { action: "members", chat_id: "oc_1" });
93
- expect(membersResult.details).toEqual(
94
- expect.objectContaining({
95
- chat_id: "oc_1",
96
- members: [expect.objectContaining({ member_id: "ou_1", name: "member1" })],
97
- }),
98
- );
99
-
100
- contactUserGetMock.mockResolvedValueOnce({
101
- code: 0,
102
- data: {
103
- user: {
104
- open_id: "ou_1",
105
- name: "member1",
106
- email: "member1@example.com",
107
- department_ids: ["od_1"],
108
- },
109
- },
110
- });
111
- const memberInfoResult = await tool.execute("tc_3", {
112
- action: "member_info",
113
- member_id: "ou_1",
114
- });
115
- expect(memberInfoResult.details).toEqual(
116
- expect.objectContaining({
117
- member_id: "ou_1",
118
- open_id: "ou_1",
119
- name: "member1",
120
- email: "member1@example.com",
121
- department_ids: ["od_1"],
122
- }),
123
- );
124
- });
125
-
126
- it("skips registration when chat tool is disabled", () => {
127
- const registerTool = vi.fn();
128
- registerFeishuChatTools(
129
- createChatToolApi({
130
- config: {
131
- channels: {
132
- feishu: {
133
- enabled: true,
134
- appId: "app_id",
135
- appSecret: "app_secret", // pragma: allowlist secret
136
- tools: { chat: false },
137
- },
138
- },
139
- },
140
- registerTool,
141
- }),
142
- );
143
- expect(registerTool).not.toHaveBeenCalled();
144
- });
145
-
146
- it("preserves Feishu diagnostics from rejected member lookups", async () => {
147
- const registerTool = vi.fn();
148
- registerFeishuChatTools(
149
- createChatToolApi({
150
- config: {
151
- channels: {
152
- feishu: {
153
- enabled: true,
154
- appId: "app_id",
155
- appSecret: "app_secret", // pragma: allowlist secret
156
- tools: { chat: true },
157
- },
158
- },
159
- },
160
- registerTool,
161
- }),
162
- );
163
-
164
- const tool = registerTool.mock.calls[0]?.[0];
165
- contactUserGetMock.mockRejectedValueOnce(
166
- Object.assign(new Error("Request failed with status code 400"), {
167
- response: {
168
- status: 400,
169
- data: {
170
- code: 99992360,
171
- msg: "The request you send is not a valid {user_id} or not exists",
172
- error: {
173
- log_id: "20260429124800CHAT",
174
- troubleshooter: "https://open.feishu.cn/search?log_id=20260429124800CHAT",
175
- },
176
- },
177
- },
178
- }),
179
- );
180
-
181
- const result = await tool.execute("tc_4", {
182
- action: "member_info",
183
- member_id: "ou_1",
184
- });
185
-
186
- expect(result.details.error).toContain('"http_status":400');
187
- expect(result.details.error).toContain('"feishu_code":99992360');
188
- expect(result.details.error).toContain(
189
- '"feishu_msg":"The request you send is not a valid {user_id} or not exists"',
190
- );
191
- expect(result.details.error).toContain('"feishu_log_id":"20260429124800CHAT"');
192
- expect(result.details.error).toContain(
193
- '"feishu_troubleshooter":"https://open.feishu.cn/search?log_id=20260429124800CHAT"',
194
- );
195
- });
196
- });
package/src/chat.ts DELETED
@@ -1,188 +0,0 @@
1
- import type * as Lark from "@larksuiteoapi/node-sdk";
2
- import type { OpenClawPluginApi } from "../runtime-api.js";
3
- import { listEnabledFeishuAccounts } from "./accounts.js";
4
- import { FeishuChatSchema, type FeishuChatParams } from "./chat-schema.js";
5
- import { createFeishuClient } from "./client.js";
6
- import { formatFeishuApiError } from "./comment-shared.js";
7
- import { resolveToolsConfig } from "./tools-config.js";
8
-
9
- function json(data: unknown) {
10
- return {
11
- content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }],
12
- details: data,
13
- };
14
- }
15
-
16
- export async function getChatInfo(client: Lark.Client, chatId: string) {
17
- const res = await client.im.chat.get({ path: { chat_id: chatId } });
18
- if (res.code !== 0) {
19
- throw new Error(res.msg);
20
- }
21
-
22
- const chat = res.data;
23
- return {
24
- chat_id: chatId,
25
- name: chat?.name,
26
- description: chat?.description,
27
- owner_id: chat?.owner_id,
28
- tenant_key: chat?.tenant_key,
29
- user_count: chat?.user_count,
30
- chat_mode: chat?.chat_mode,
31
- chat_type: chat?.chat_type,
32
- join_message_visibility: chat?.join_message_visibility,
33
- leave_message_visibility: chat?.leave_message_visibility,
34
- membership_approval: chat?.membership_approval,
35
- moderation_permission: chat?.moderation_permission,
36
- avatar: chat?.avatar,
37
- };
38
- }
39
-
40
- export async function getChatMembers(
41
- client: Lark.Client,
42
- chatId: string,
43
- pageSize?: number,
44
- pageToken?: string,
45
- memberIdType?: "open_id" | "user_id" | "union_id",
46
- ) {
47
- const page_size = pageSize ? Math.max(1, Math.min(100, pageSize)) : 50;
48
- const res = await client.im.chatMembers.get({
49
- path: { chat_id: chatId },
50
- params: {
51
- page_size,
52
- page_token: pageToken,
53
- member_id_type: memberIdType ?? "open_id",
54
- },
55
- });
56
-
57
- if (res.code !== 0) {
58
- throw new Error(res.msg);
59
- }
60
-
61
- return {
62
- chat_id: chatId,
63
- has_more: res.data?.has_more,
64
- page_token: res.data?.page_token,
65
- members:
66
- res.data?.items?.map((item) => ({
67
- member_id: item.member_id,
68
- name: item.name,
69
- tenant_key: item.tenant_key,
70
- member_id_type: item.member_id_type,
71
- })) ?? [],
72
- };
73
- }
74
-
75
- export async function getFeishuMemberInfo(
76
- client: Lark.Client,
77
- memberId: string,
78
- memberIdType: "open_id" | "user_id" | "union_id" = "open_id",
79
- ) {
80
- const res = await client.contact.user.get({
81
- path: { user_id: memberId },
82
- params: {
83
- user_id_type: memberIdType,
84
- department_id_type: "open_department_id",
85
- },
86
- });
87
-
88
- if (res.code !== 0) {
89
- throw new Error(res.msg);
90
- }
91
-
92
- const user = res.data?.user;
93
- return {
94
- member_id: memberId,
95
- member_id_type: memberIdType,
96
- open_id: user?.open_id,
97
- user_id: user?.user_id,
98
- union_id: user?.union_id,
99
- name: user?.name,
100
- en_name: user?.en_name,
101
- nickname: user?.nickname,
102
- email: user?.email,
103
- enterprise_email: user?.enterprise_email,
104
- mobile: user?.mobile,
105
- mobile_visible: user?.mobile_visible,
106
- status: user?.status,
107
- avatar: user?.avatar,
108
- department_ids: user?.department_ids,
109
- department_path: user?.department_path,
110
- leader_user_id: user?.leader_user_id,
111
- city: user?.city,
112
- country: user?.country,
113
- work_station: user?.work_station,
114
- join_time: user?.join_time,
115
- is_tenant_manager: user?.is_tenant_manager,
116
- employee_no: user?.employee_no,
117
- employee_type: user?.employee_type,
118
- description: user?.description,
119
- job_title: user?.job_title,
120
- geo: user?.geo,
121
- };
122
- }
123
-
124
- export function registerFeishuChatTools(api: OpenClawPluginApi) {
125
- if (!api.config) {
126
- return;
127
- }
128
-
129
- const accounts = listEnabledFeishuAccounts(api.config);
130
- if (accounts.length === 0) {
131
- return;
132
- }
133
-
134
- const firstAccount = accounts[0];
135
- const toolsCfg = resolveToolsConfig(firstAccount.config.tools);
136
- if (!toolsCfg.chat) {
137
- return;
138
- }
139
-
140
- const getClient = () => createFeishuClient(firstAccount);
141
-
142
- api.registerTool(
143
- {
144
- name: "feishu_chat",
145
- label: "Feishu Chat",
146
- description: "Feishu chat operations. Actions: members, info, member_info",
147
- parameters: FeishuChatSchema,
148
- async execute(_toolCallId, params) {
149
- const p = params as FeishuChatParams;
150
- try {
151
- const client = getClient();
152
- switch (p.action) {
153
- case "members":
154
- if (!p.chat_id) {
155
- return json({ error: "chat_id is required for action members" });
156
- }
157
- return json(
158
- await getChatMembers(
159
- client,
160
- p.chat_id,
161
- p.page_size,
162
- p.page_token,
163
- p.member_id_type,
164
- ),
165
- );
166
- case "info":
167
- if (!p.chat_id) {
168
- return json({ error: "chat_id is required for action info" });
169
- }
170
- return json(await getChatInfo(client, p.chat_id));
171
- case "member_info":
172
- if (!p.member_id) {
173
- return json({ error: "member_id is required for action member_info" });
174
- }
175
- return json(
176
- await getFeishuMemberInfo(client, p.member_id, p.member_id_type ?? "open_id"),
177
- );
178
- default:
179
- return json({ error: `Unknown action: ${String(p.action)}` });
180
- }
181
- } catch (err) {
182
- return json({ error: formatFeishuApiError(err, { includeNestedErrorLogId: true }) });
183
- }
184
- },
185
- },
186
- { name: "feishu_chat" },
187
- );
188
- }