@m1heng-clawd/feishu 0.1.8 → 0.1.10

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/src/types.ts CHANGED
@@ -67,6 +67,7 @@ export type FeishuToolsConfig = {
67
67
  drive?: boolean;
68
68
  perm?: boolean;
69
69
  scopes?: boolean;
70
+ task?: boolean;
70
71
  };
71
72
 
72
73
  export type DynamicAgentCreationConfig = {
package/src/wiki.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
2
- import { createFeishuClient } from "./client.js";
3
- import { listEnabledFeishuAccounts } from "./accounts.js";
4
2
  import type * as Lark from "@larksuiteoapi/node-sdk";
5
3
  import { FeishuWikiSchema, type FeishuWikiParams } from "./wiki-schema.js";
6
- import { resolveToolsConfig } from "./tools-config.js";
4
+ import { hasFeishuToolEnabledForAnyAccount, withFeishuToolClient } from "./tools-common/tool-exec.js";
7
5
 
8
6
  // ============ Helpers ============
9
7
 
@@ -155,21 +153,16 @@ export function registerFeishuWikiTools(api: OpenClawPluginApi) {
155
153
  return;
156
154
  }
157
155
 
158
- const accounts = listEnabledFeishuAccounts(api.config);
159
- if (accounts.length === 0) {
156
+ if (!hasFeishuToolEnabledForAnyAccount(api.config)) {
160
157
  api.logger.debug?.("feishu_wiki: No Feishu accounts configured, skipping wiki tools");
161
158
  return;
162
159
  }
163
160
 
164
- const firstAccount = accounts[0];
165
- const toolsCfg = resolveToolsConfig(firstAccount.config.tools);
166
- if (!toolsCfg.wiki) {
161
+ if (!hasFeishuToolEnabledForAnyAccount(api.config, "wiki")) {
167
162
  api.logger.debug?.("feishu_wiki: wiki tool disabled in config");
168
163
  return;
169
164
  }
170
165
 
171
- const getClient = () => createFeishuClient(firstAccount);
172
-
173
166
  api.registerTool(
174
167
  {
175
168
  name: "feishu_wiki",
@@ -180,38 +173,44 @@ export function registerFeishuWikiTools(api: OpenClawPluginApi) {
180
173
  async execute(_toolCallId, params) {
181
174
  const p = params as FeishuWikiParams;
182
175
  try {
183
- const client = getClient();
184
- switch (p.action) {
185
- case "spaces":
186
- return json(await listSpaces(client));
187
- case "nodes":
188
- return json(await listNodes(client, p.space_id, p.parent_node_token));
189
- case "get":
190
- return json(await getNode(client, p.token));
191
- case "search":
192
- return json({
193
- error:
194
- "Search is not available. Use feishu_wiki with action: 'nodes' to browse or action: 'get' to lookup by token.",
195
- });
196
- case "create":
197
- return json(
198
- await createNode(client, p.space_id, p.title, p.obj_type, p.parent_node_token),
199
- );
200
- case "move":
201
- return json(
202
- await moveNode(
203
- client,
204
- p.space_id,
205
- p.node_token,
206
- p.target_space_id,
207
- p.target_parent_token,
208
- ),
209
- );
210
- case "rename":
211
- return json(await renameNode(client, p.space_id, p.node_token, p.title));
212
- default:
213
- return json({ error: `Unknown action: ${(p as any).action}` });
214
- }
176
+ return await withFeishuToolClient({
177
+ api,
178
+ toolName: "feishu_wiki",
179
+ requiredTool: "wiki",
180
+ run: async ({ client }) => {
181
+ switch (p.action) {
182
+ case "spaces":
183
+ return json(await listSpaces(client));
184
+ case "nodes":
185
+ return json(await listNodes(client, p.space_id, p.parent_node_token));
186
+ case "get":
187
+ return json(await getNode(client, p.token));
188
+ case "search":
189
+ return json({
190
+ error:
191
+ "Search is not available. Use feishu_wiki with action: 'nodes' to browse or action: 'get' to lookup by token.",
192
+ });
193
+ case "create":
194
+ return json(
195
+ await createNode(client, p.space_id, p.title, p.obj_type, p.parent_node_token),
196
+ );
197
+ case "move":
198
+ return json(
199
+ await moveNode(
200
+ client,
201
+ p.space_id,
202
+ p.node_token,
203
+ p.target_space_id,
204
+ p.target_parent_token,
205
+ ),
206
+ );
207
+ case "rename":
208
+ return json(await renameNode(client, p.space_id, p.node_token, p.title));
209
+ default:
210
+ return json({ error: `Unknown action: ${(p as any).action}` });
211
+ }
212
+ },
213
+ });
215
214
  } catch (err) {
216
215
  return json({ error: err instanceof Error ? err.message : String(err) });
217
216
  }
@@ -220,5 +219,5 @@ export function registerFeishuWikiTools(api: OpenClawPluginApi) {
220
219
  { name: "feishu_wiki" },
221
220
  );
222
221
 
223
- api.logger.info?.(`feishu_wiki: Registered feishu_wiki tool`);
222
+ api.logger.debug?.("feishu_wiki: Registered feishu_wiki tool");
224
223
  }