22import type * as Lark from "@larksuiteoapi/node-sdk" ;
33import type { OpenClawPluginApi } from "../runtime-api.js" ;
44import { listEnabledFeishuAccounts } from "./accounts.js" ;
5+ import { createFeishuClient } from "./client.js" ;
56import { FeishuPermSchema , type FeishuPermParams } from "./perm-schema.js" ;
6- import { createFeishuToolClient , resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js" ;
7+ import { resolveAnyEnabledFeishuToolsConfig , resolveFeishuToolAccount } from "./tool-account.js" ;
78import {
89 jsonToolResult ,
910 toolExecutionErrorResult ,
1011 unknownToolActionResult ,
1112} from "./tool-result.js" ;
13+ import { resolveToolsConfig } from "./tools-config.js" ;
1214
1315type ListTokenType =
1416 | "doc"
@@ -130,6 +132,17 @@ export function registerFeishuPermTools(api: OpenClawPluginApi) {
130132
131133 type FeishuPermExecuteParams = FeishuPermParams & { accountId ?: string } ;
132134
135+ const createPermClient = (
136+ params : FeishuPermExecuteParams | undefined ,
137+ defaultAccountId ?: string ,
138+ ) => {
139+ const account = resolveFeishuToolAccount ( { api, executeParams : params , defaultAccountId } ) ;
140+ if ( ! resolveToolsConfig ( account . config . tools ) . perm ) {
141+ throw new Error ( `Feishu Perm tools are disabled for account "${ account . accountId } "` ) ;
142+ }
143+ return createFeishuClient ( account ) ;
144+ } ;
145+
133146 api . registerTool (
134147 ( ctx ) => {
135148 const defaultAccountId = ctx . agentAccountId ;
@@ -141,11 +154,7 @@ export function registerFeishuPermTools(api: OpenClawPluginApi) {
141154 async execute ( _toolCallId , params ) {
142155 const p = params as FeishuPermExecuteParams ;
143156 try {
144- const client = createFeishuToolClient ( {
145- api,
146- executeParams : p ,
147- defaultAccountId,
148- } ) ;
157+ const client = createPermClient ( p , defaultAccountId ) ;
149158 switch ( p . action ) {
150159 case "list" :
151160 return jsonToolResult ( await listMembers ( client , p . token , p . type ) ) ;
0 commit comments