feat: 实现 Tool Search Tool 动态工具发现机制
- 新增 ToolRegistry 工具注册表,支持核心工具和延迟加载工具分离 - 新增 tool_search 元工具,支持关键词搜索发现可用工具 - 新增基于关键词的搜索算法,按相关度评分排序 - 为所有工具添加 metadata(分类、关键词、延迟加载标识) - 修改 Agent 支持动态工具注入,tool_search 结果自动添加到可用工具 - 核心工具(tool_search, bash)始终加载,其他工具按需发现
This commit is contained in:
+5
-5
@@ -4,7 +4,7 @@ import { Command } from 'commander';
|
||||
import { Agent } from './core/agent.js';
|
||||
import { TerminalUI } from './ui/terminal.js';
|
||||
import { loadConfig, initConfig } from './utils/config.js';
|
||||
import { allTools } from './tools/index.js';
|
||||
import { toolRegistry } from './tools/index.js';
|
||||
import { getPermissionManager, promptPermission } from './permission/index.js';
|
||||
|
||||
const program = new Command();
|
||||
@@ -37,8 +37,8 @@ program
|
||||
const config = loadConfig();
|
||||
const agent = new Agent(config);
|
||||
|
||||
// 注册所有工具
|
||||
agent.registerTools(allTools);
|
||||
// 设置工具注册表(支持动态工具发现)
|
||||
agent.setRegistry(toolRegistry);
|
||||
|
||||
try {
|
||||
await agent.chat(question, (text) => {
|
||||
@@ -60,8 +60,8 @@ program.action(async () => {
|
||||
const config = loadConfig();
|
||||
const agent = new Agent(config);
|
||||
|
||||
// 注册所有工具
|
||||
agent.registerTools(allTools);
|
||||
// 设置工具注册表(支持动态工具发现)
|
||||
agent.setRegistry(toolRegistry);
|
||||
|
||||
// 启动终端 UI
|
||||
const ui = new TerminalUI(agent);
|
||||
|
||||
Reference in New Issue
Block a user