@@ -217,6 +217,38 @@ describe("feishu tool account routing", () => {
217217 expect ( createFeishuClientMock . mock . calls . at ( - 1 ) ?. [ 0 ] ?. appId ) . toBe ( "app-b" ) ;
218218 } ) ;
219219
220+ test ( "bitable tool rejects a disabled contextual account when another account enables it" , async ( ) => {
221+ const { api, resolveTool } = createToolFactoryHarness (
222+ createConfig ( {
223+ toolsA : { bitable : false } ,
224+ toolsB : { bitable : true } ,
225+ } ) ,
226+ ) ;
227+ registerFeishuBitableTools ( api ) ;
228+
229+ const tool = resolveTool ( "feishu_bitable_get_meta" , { agentAccountId : "a" } ) ;
230+ const result = await tool . execute ( "call" , { url : "invalid-url" } ) ;
231+
232+ expect ( createFeishuClientMock ) . not . toHaveBeenCalled ( ) ;
233+ expect ( result . details . error ) . toBe ( 'Feishu Bitable tools are disabled for account "a"' ) ;
234+ } ) ;
235+
236+ test ( "bitable tool rejects an explicit disabled account override" , async ( ) => {
237+ const { api, resolveTool } = createToolFactoryHarness (
238+ createConfig ( {
239+ toolsA : { bitable : false } ,
240+ toolsB : { bitable : true } ,
241+ } ) ,
242+ ) ;
243+ registerFeishuBitableTools ( api ) ;
244+
245+ const tool = resolveTool ( "feishu_bitable_get_meta" , { agentAccountId : "b" } ) ;
246+ const result = await tool . execute ( "call" , { url : "invalid-url" , accountId : "a" } ) ;
247+
248+ expect ( createFeishuClientMock ) . not . toHaveBeenCalled ( ) ;
249+ expect ( result . details . error ) . toBe ( 'Feishu Bitable tools are disabled for account "a"' ) ;
250+ } ) ;
251+
220252 test ( "bitable tool routes to agentAccountId and allows explicit accountId override" , async ( ) => {
221253 const { api, resolveTool } = createToolFactoryHarness ( createConfig ( { } ) ) ;
222254 registerFeishuBitableTools ( api ) ;
@@ -289,6 +321,23 @@ describe("feishu tool account routing", () => {
289321 expect ( createFeishuClientMock . mock . calls . at ( - 1 ) ?. [ 0 ] ?. appId ) . toBe ( "app-a" ) ;
290322 } ) ;
291323
324+ test ( "account base alias disable wins over inherited top-level bitable enable" , async ( ) => {
325+ const { api, resolveTool } = createToolFactoryHarness (
326+ createConfig ( {
327+ topTools : { bitable : true } ,
328+ toolsA : { base : false } ,
329+ toolsB : { bitable : true } ,
330+ } ) ,
331+ ) ;
332+ registerFeishuBitableTools ( api ) ;
333+
334+ const tool = resolveTool ( "feishu_bitable_get_meta" , { agentAccountId : "a" } ) ;
335+ const result = await tool . execute ( "call" , { url : "invalid-url" } ) ;
336+
337+ expect ( createFeishuClientMock ) . not . toHaveBeenCalled ( ) ;
338+ expect ( result . details . error ) . toBe ( 'Feishu Bitable tools are disabled for account "a"' ) ;
339+ } ) ;
340+
292341 test ( "bitable tools are not registered when account bitable configs disable them" , async ( ) => {
293342 const { api, registered, resolveTool } = createToolFactoryHarness (
294343 createConfig ( {
0 commit comments