feat: 实现 Tool Search Tool 动态工具发现机制
- 新增 ToolRegistry 工具注册表,支持核心工具和延迟加载工具分离 - 新增 tool_search 元工具,支持关键词搜索发现可用工具 - 新增基于关键词的搜索算法,按相关度评分排序 - 为所有工具添加 metadata(分类、关键词、延迟加载标识) - 修改 Agent 支持动态工具注入,tool_search 结果自动添加到可用工具 - 核心工具(tool_search, bash)始终加载,其他工具按需发现
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as fs from 'fs/promises';
|
||||
import * as path from 'path';
|
||||
import type { Tool, ToolResult } from '../../types/index.js';
|
||||
import type { ToolResult } from '../../types/index.js';
|
||||
import type { ToolWithMetadata } from '../types.js';
|
||||
import { loadDescription } from '../load_description.js';
|
||||
import { getPermissionManager } from '../../permission/index.js';
|
||||
|
||||
@@ -45,9 +46,16 @@ function formatPermissions(mode: number): string {
|
||||
return `${fileType?.[1] || 'unknown'} (${perms})`;
|
||||
}
|
||||
|
||||
export const getFileInfoTool: Tool = {
|
||||
export const getFileInfoTool: ToolWithMetadata = {
|
||||
name: 'get_file_info',
|
||||
description: loadDescription('get_file_info'),
|
||||
metadata: {
|
||||
name: 'get_file_info',
|
||||
category: 'filesystem',
|
||||
description: '获取文件元信息',
|
||||
keywords: ['file', 'info', 'stat', 'size', 'permission', 'metadata', '文件', '信息', '大小', '权限', '属性'],
|
||||
deferLoading: true,
|
||||
},
|
||||
parameters: {
|
||||
path: {
|
||||
type: 'string',
|
||||
|
||||
Reference in New Issue
Block a user