@nextclaw/channel-plugin-feishu 0.2.25 → 0.2.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/channel-plugin-feishu",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "private": false,
5
5
  "description": "NextClaw Feishu/Lark channel plugin with doc/wiki/drive tools.",
6
6
  "type": "module",
package/src/bitable.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type * as Lark from "@larksuiteoapi/node-sdk";
2
2
  import { Type } from "@sinclair/typebox";
3
3
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
4
- import { listEnabledFeishuAccounts } from "./accounts.js";
5
4
  import { createFeishuToolClient } from "./tool-account.js";
6
5
 
7
6
  // ============ Helpers ============
@@ -538,12 +537,6 @@ export function registerFeishuBitableTools(api: OpenClawPluginApi) {
538
537
  return;
539
538
  }
540
539
 
541
- const accounts = listEnabledFeishuAccounts(api.config);
542
- if (accounts.length === 0) {
543
- api.logger.debug?.("feishu_bitable: No Feishu accounts configured, skipping bitable tools");
544
- return;
545
- }
546
-
547
540
  type AccountAwareParams = { accountId?: string };
548
541
 
549
542
  const getClient = (params: AccountAwareParams | undefined, defaultAccountId?: string) =>
package/src/calendar.ts CHANGED
@@ -1,16 +1,13 @@
1
1
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
2
- import { listEnabledFeishuAccounts } from "./accounts.js";
3
2
  import { registerFeishuCalendarCalendarTool } from "./calendar-calendar.js";
4
3
  import { registerFeishuCalendarEventTool } from "./calendar-event.js";
5
4
  import { registerFeishuCalendarEventAttendeeTool } from "./calendar-event-attendee.js";
6
5
  import { registerFeishuCalendarFreebusyTool } from "./calendar-freebusy.js";
7
- import { resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
6
+ import { resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
8
7
 
9
8
  export function registerFeishuCalendarTools(api: OpenClawPluginApi) {
10
9
  if (!api.config) return;
11
- const accounts = listEnabledFeishuAccounts(api.config);
12
- if (accounts.length === 0) return;
13
- if (!resolveAnyEnabledFeishuToolsConfig(accounts).calendar) return;
10
+ if (!resolveRegisteredFeishuToolsConfig(api.config).calendar) return;
14
11
  registerFeishuCalendarCalendarTool(api);
15
12
  registerFeishuCalendarEventTool(api);
16
13
  registerFeishuCalendarEventAttendeeTool(api);
package/src/chat.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type * as Lark from "@larksuiteoapi/node-sdk";
2
2
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
- import { listEnabledFeishuAccounts } from "./accounts.js";
4
3
  import { FeishuChatSchema, type FeishuChatParams } from "./chat-schema.js";
5
- import { createFeishuClient } from "./client.js";
6
- import { resolveToolsConfig } from "./tools-config.js";
4
+ import { createFeishuToolClient, resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
7
5
 
8
6
  function json(data: unknown) {
9
7
  return {
@@ -77,21 +75,12 @@ export function registerFeishuChatTools(api: OpenClawPluginApi) {
77
75
  return;
78
76
  }
79
77
 
80
- const accounts = listEnabledFeishuAccounts(api.config);
81
- if (accounts.length === 0) {
82
- api.logger.debug?.("feishu_chat: No Feishu accounts configured, skipping chat tools");
83
- return;
84
- }
85
-
86
- const firstAccount = accounts[0];
87
- const toolsCfg = resolveToolsConfig(firstAccount.config.tools);
78
+ const toolsCfg = resolveRegisteredFeishuToolsConfig(api.config);
88
79
  if (!toolsCfg.chat) {
89
80
  api.logger.debug?.("feishu_chat: chat tool disabled in config");
90
81
  return;
91
82
  }
92
83
 
93
- const getClient = () => createFeishuClient(firstAccount);
94
-
95
84
  api.registerTool(
96
85
  {
97
86
  name: "feishu_chat",
@@ -101,7 +90,7 @@ export function registerFeishuChatTools(api: OpenClawPluginApi) {
101
90
  async execute(_toolCallId, params) {
102
91
  const p = params as FeishuChatParams;
103
92
  try {
104
- const client = getClient();
93
+ const client = createFeishuToolClient({ api });
105
94
  switch (p.action) {
106
95
  case "members":
107
96
  return json(
package/src/docx.ts CHANGED
@@ -5,7 +5,6 @@ import { basename } from "node:path";
5
5
  import type * as Lark from "@larksuiteoapi/node-sdk";
6
6
  import { Type } from "@sinclair/typebox";
7
7
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
8
- import { listEnabledFeishuAccounts } from "./accounts.js";
9
8
  import { FeishuDocSchema, type FeishuDocParams } from "./doc-schema.js";
10
9
  import { BATCH_SIZE, insertBlocksInBatches } from "./docx-batch-insert.js";
11
10
  import { updateColorText } from "./docx-color-text.js";
@@ -20,8 +19,8 @@ import {
20
19
  import { getFeishuRuntime } from "./runtime.js";
21
20
  import {
22
21
  createFeishuToolClient,
23
- resolveAnyEnabledFeishuToolsConfig,
24
22
  resolveFeishuToolAccount,
23
+ resolveRegisteredFeishuToolsConfig,
25
24
  } from "./tool-account.js";
26
25
 
27
26
  // ============ Helpers ============
@@ -1232,15 +1231,8 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
1232
1231
  return;
1233
1232
  }
1234
1233
 
1235
- // Check if any account is configured
1236
- const accounts = listEnabledFeishuAccounts(api.config);
1237
- if (accounts.length === 0) {
1238
- api.logger.debug?.("feishu_doc: No Feishu accounts configured, skipping doc tools");
1239
- return;
1240
- }
1241
-
1242
- // Register if enabled on any account; account routing is resolved per execution.
1243
- const toolsCfg = resolveAnyEnabledFeishuToolsConfig(accounts);
1234
+ // Register if enabled by config; account routing is resolved per execution.
1235
+ const toolsCfg = resolveRegisteredFeishuToolsConfig(api.config);
1244
1236
 
1245
1237
  const registered: string[] = [];
1246
1238
  type FeishuDocExecuteParams = FeishuDocParams & { accountId?: string };
package/src/drive.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import type * as Lark from "@larksuiteoapi/node-sdk";
2
2
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
- import { listEnabledFeishuAccounts } from "./accounts.js";
4
3
  import { FeishuDriveSchema, type FeishuDriveParams } from "./drive-schema.js";
5
- import { createFeishuToolClient, resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
4
+ import { createFeishuToolClient, resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
6
5
  import {
7
6
  jsonToolResult,
8
7
  toolExecutionErrorResult,
@@ -169,13 +168,7 @@ export function registerFeishuDriveTools(api: OpenClawPluginApi) {
169
168
  return;
170
169
  }
171
170
 
172
- const accounts = listEnabledFeishuAccounts(api.config);
173
- if (accounts.length === 0) {
174
- api.logger.debug?.("feishu_drive: No Feishu accounts configured, skipping drive tools");
175
- return;
176
- }
177
-
178
- const toolsCfg = resolveAnyEnabledFeishuToolsConfig(accounts);
171
+ const toolsCfg = resolveRegisteredFeishuToolsConfig(api.config);
179
172
  if (!toolsCfg.drive) {
180
173
  api.logger.debug?.("feishu_drive: drive tool disabled in config");
181
174
  return;
package/src/identity.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Type } from "@sinclair/typebox";
2
2
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
- import { listEnabledFeishuAccounts } from "./accounts.js";
4
- import { resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
3
+ import { resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
5
4
  import {
6
5
  assertLarkOk,
7
6
  createToolContext,
@@ -43,12 +42,7 @@ export function registerFeishuIdentityTools(api: OpenClawPluginApi) {
43
42
  return;
44
43
  }
45
44
 
46
- const accounts = listEnabledFeishuAccounts(api.config);
47
- if (accounts.length === 0) {
48
- return;
49
- }
50
-
51
- const toolsConfig = resolveAnyEnabledFeishuToolsConfig(accounts);
45
+ const toolsConfig = resolveRegisteredFeishuToolsConfig(api.config);
52
46
  if (!toolsConfig.identity) {
53
47
  return;
54
48
  }
package/src/oauth.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import { Type } from "@sinclair/typebox";
2
2
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
- import { listEnabledFeishuAccounts } from "./accounts.js";
4
3
  import { requestDeviceAuthorization, pollDeviceToken } from "./device-flow.js";
5
4
  import { feishuFetch } from "./feishu-fetch.js";
6
5
  import { getTicket } from "./lark-ticket.js";
7
6
  import { getStoredToken, setStoredToken, tokenStatus } from "./token-store.js";
8
- import { resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
7
+ import { resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
9
8
  import { revokeUAT } from "./uat-client.js";
10
9
  import { createUserToolClient } from "./user-tool-client.js";
11
10
  import { jsonToolResult } from "./tool-result.js";
@@ -188,12 +187,7 @@ export function registerFeishuOAuthTool(api: OpenClawPluginApi) {
188
187
  return;
189
188
  }
190
189
 
191
- const accounts = listEnabledFeishuAccounts(api.config);
192
- if (accounts.length === 0) {
193
- return;
194
- }
195
-
196
- const toolsConfig = resolveAnyEnabledFeishuToolsConfig(accounts);
190
+ const toolsConfig = resolveRegisteredFeishuToolsConfig(api.config);
197
191
  if (!toolsConfig.oauth) {
198
192
  return;
199
193
  }
package/src/perm.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import type * as Lark from "@larksuiteoapi/node-sdk";
2
2
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
- import { listEnabledFeishuAccounts } from "./accounts.js";
4
3
  import { FeishuPermSchema, type FeishuPermParams } from "./perm-schema.js";
5
- import { createFeishuToolClient, resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
4
+ import { createFeishuToolClient, resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
6
5
  import {
7
6
  jsonToolResult,
8
7
  toolExecutionErrorResult,
@@ -118,13 +117,7 @@ export function registerFeishuPermTools(api: OpenClawPluginApi) {
118
117
  return;
119
118
  }
120
119
 
121
- const accounts = listEnabledFeishuAccounts(api.config);
122
- if (accounts.length === 0) {
123
- api.logger.debug?.("feishu_perm: No Feishu accounts configured, skipping perm tools");
124
- return;
125
- }
126
-
127
- const toolsCfg = resolveAnyEnabledFeishuToolsConfig(accounts);
120
+ const toolsCfg = resolveRegisteredFeishuToolsConfig(api.config);
128
121
  if (!toolsCfg.perm) {
129
122
  api.logger.debug?.("feishu_perm: perm tool disabled in config (default: false)");
130
123
  return;
package/src/sheets.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Type } from "@sinclair/typebox";
2
2
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
- import { listEnabledFeishuAccounts } from "./accounts.js";
4
3
  import {
5
4
  type SheetParams,
6
5
  handleCreate,
@@ -11,7 +10,7 @@ import {
11
10
  handleWrite,
12
11
  resolveToken,
13
12
  } from "./sheets-shared.js";
14
- import { resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
13
+ import { resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
15
14
  import { createToolContext, handleInvokeError, registerTool, StringEnum } from "./user-tool-helpers.js";
16
15
 
17
16
  const SheetSchema = Type.Union([
@@ -70,9 +69,7 @@ const SheetSchema = Type.Union([
70
69
 
71
70
  export function registerFeishuSheetsTools(api: OpenClawPluginApi) {
72
71
  if (!api.config) return;
73
- const accounts = listEnabledFeishuAccounts(api.config);
74
- if (accounts.length === 0) return;
75
- if (!resolveAnyEnabledFeishuToolsConfig(accounts).sheets) return;
72
+ if (!resolveRegisteredFeishuToolsConfig(api.config).sheets) return;
76
73
 
77
74
  registerTool(api, {
78
75
  name: "feishu_sheet",
package/src/task.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
2
- import { listEnabledFeishuAccounts } from "./accounts.js";
3
- import { resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
2
+ import { resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
4
3
  import { registerFeishuTaskCommentTool } from "./task-comment.js";
5
4
  import { registerFeishuTaskSubtaskTool } from "./task-subtask.js";
6
5
  import { registerFeishuTaskTaskTool } from "./task-task.js";
@@ -8,9 +7,7 @@ import { registerFeishuTaskTasklistTool } from "./task-tasklist.js";
8
7
 
9
8
  export function registerFeishuTaskTools(api: OpenClawPluginApi) {
10
9
  if (!api.config) return;
11
- const accounts = listEnabledFeishuAccounts(api.config);
12
- if (accounts.length === 0) return;
13
- if (!resolveAnyEnabledFeishuToolsConfig(accounts).task) return;
10
+ if (!resolveRegisteredFeishuToolsConfig(api.config).task) return;
14
11
  registerFeishuTaskTaskTool(api);
15
12
  registerFeishuTaskTasklistTool(api);
16
13
  registerFeishuTaskCommentTool(api);
@@ -1,6 +1,6 @@
1
1
  import type * as Lark from "@larksuiteoapi/node-sdk";
2
2
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
- import { resolveFeishuAccount } from "./accounts.js";
3
+ import { listFeishuAccountIds, resolveFeishuAccount } from "./accounts.js";
4
4
  import { createFeishuClient } from "./client.js";
5
5
  import { getTicket } from "./lark-ticket.js";
6
6
  import { resolveToolsConfig } from "./tools-config.js";
@@ -84,3 +84,12 @@ export function resolveAnyEnabledFeishuToolsConfig(
84
84
  }
85
85
  return merged;
86
86
  }
87
+
88
+ export function resolveRegisteredFeishuToolsConfig(
89
+ config: OpenClawPluginApi["config"],
90
+ ): Required<FeishuToolsConfig> {
91
+ const accounts = listFeishuAccountIds(config).map((accountId) =>
92
+ resolveFeishuAccount({ cfg: config, accountId }),
93
+ );
94
+ return resolveAnyEnabledFeishuToolsConfig(accounts);
95
+ }
package/src/wiki.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type * as Lark from "@larksuiteoapi/node-sdk";
2
2
  import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
- import { listEnabledFeishuAccounts } from "./accounts.js";
4
- import { createFeishuToolClient, resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
3
+ import { createFeishuToolClient, resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
5
4
  import {
6
5
  jsonToolResult,
7
6
  toolExecutionErrorResult,
@@ -157,13 +156,7 @@ export function registerFeishuWikiTools(api: OpenClawPluginApi) {
157
156
  return;
158
157
  }
159
158
 
160
- const accounts = listEnabledFeishuAccounts(api.config);
161
- if (accounts.length === 0) {
162
- api.logger.debug?.("feishu_wiki: No Feishu accounts configured, skipping wiki tools");
163
- return;
164
- }
165
-
166
- const toolsCfg = resolveAnyEnabledFeishuToolsConfig(accounts);
159
+ const toolsCfg = resolveRegisteredFeishuToolsConfig(api.config);
167
160
  if (!toolsCfg.wiki) {
168
161
  api.logger.debug?.("feishu_wiki: wiki tool disabled in config");
169
162
  return;