mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-01 05:00:46 +00:00
enable async tool discovery by making the registry accessor async; remove call to discoverTools that caused duplicate discovery (#691)
This commit is contained in:
parent
467dec4edf
commit
c5869db080
7 changed files with 21 additions and 20 deletions
|
|
@ -60,7 +60,7 @@ export interface ConfigParameters {
|
|||
}
|
||||
|
||||
export class Config {
|
||||
private toolRegistry: ToolRegistry;
|
||||
private toolRegistry: Promise<ToolRegistry>;
|
||||
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<ToolRegistry> {
|
||||
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<ToolRegistry> {
|
||||
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;
|
||||
})();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue