From 6ecdecbdcca59d4daff7ec5921afc746e7d725ab Mon Sep 17 00:00:00 2001 From: JingboWang1997-1 Date: Wed, 11 Jun 2025 14:32:23 -0700 Subject: add excludeTools flag to settings.json config (#957) --- packages/core/src/config/config.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'packages/core/src') diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 297178fd..b94585a5 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -65,6 +65,7 @@ export interface ConfigParameters { question?: string; fullContext?: boolean; coreTools?: string[]; + excludeTools?: string[]; toolDiscoveryCommand?: string; toolCallCommand?: string; mcpServerCommand?: string; @@ -95,6 +96,7 @@ export class Config { private readonly question: string | undefined; private readonly fullContext: boolean; private readonly coreTools: string[] | undefined; + private readonly excludeTools: string[] | undefined; private readonly toolDiscoveryCommand: string | undefined; private readonly toolCallCommand: string | undefined; private readonly mcpServerCommand: string | undefined; @@ -126,6 +128,7 @@ export class Config { this.question = params.question; this.fullContext = params.fullContext ?? false; this.coreTools = params.coreTools; + this.excludeTools = params.excludeTools; this.toolDiscoveryCommand = params.toolDiscoveryCommand; this.toolCallCommand = params.toolCallCommand; this.mcpServerCommand = params.mcpServerCommand; @@ -210,6 +213,10 @@ export class Config { return this.coreTools; } + getExcludeTools(): string[] | undefined { + return this.excludeTools; + } + getToolDiscoveryCommand(): string | undefined { return this.toolDiscoveryCommand; } @@ -360,12 +367,22 @@ export function createToolRegistry(config: Config): Promise { const tools = config.getCoreTools() ? new Set(config.getCoreTools()) : undefined; + const excludeTools = config.getExcludeTools() + ? new Set(config.getExcludeTools()) + : undefined; // helper to create & register core tools that are enabled // eslint-disable-next-line @typescript-eslint/no-explicit-any const registerCoreTool = (ToolClass: any, ...args: unknown[]) => { // check both the tool name (.Name) and the class name (.name) - if (!tools || tools.has(ToolClass.Name) || tools.has(ToolClass.name)) { + if ( + // coreTools contain tool name + (!tools || tools.has(ToolClass.Name) || tools.has(ToolClass.name)) && + // excludeTools don't contain tool name + (!excludeTools || + (!excludeTools.has(ToolClass.Name) && + !excludeTools.has(ToolClass.name))) + ) { registry.registerTool(new ToolClass(...args)); } }; -- cgit v1.2.3