From c5869db0806d04bc0d1f4da6823f9e13d22e476b Mon Sep 17 00:00:00 2001 From: Olcan Date: Mon, 2 Jun 2025 09:56:32 -0700 Subject: enable async tool discovery by making the registry accessor async; remove call to discoverTools that caused duplicate discovery (#691) --- packages/core/src/config/config.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'packages/core/src/config') diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index d918de04..a6279e2e 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -60,7 +60,7 @@ export interface ConfigParameters { } export class Config { - private toolRegistry: ToolRegistry; + private toolRegistry: Promise; private readonly apiKey: string; private readonly model: string; private readonly sandbox: boolean | string; @@ -124,7 +124,7 @@ export class Config { return this.targetDir; } - getToolRegistry(): ToolRegistry { + async getToolRegistry(): Promise { return this.toolRegistry; } @@ -232,7 +232,7 @@ export function createServerConfig(params: ConfigParameters): Config { }); } -export function createToolRegistry(config: Config): ToolRegistry { +export function createToolRegistry(config: Config): Promise { const registry = new ToolRegistry(config); const targetDir = config.getTargetDir(); const tools = config.getCoreTools() @@ -259,6 +259,8 @@ export function createToolRegistry(config: Config): ToolRegistry { registerCoreTool(ShellTool, config); registerCoreTool(MemoryTool); registerCoreTool(WebSearchTool, config); - registry.discoverTools(); - return registry; + return (async () => { + await registry.discoverTools(); + return registry; + })(); } -- cgit v1.2.3