fix(easyagent): 移动 tools.json 到 src/tools/,修复被 .gitignore 中 doc/ 规则误排除的问题

tools.json 是子智能体运行时工具定义 Schema(OpenAI function calling),
不是文档,不应该放在 doc/ 下。doc/ 被 .gitignore 忽略导致部署后文件缺失。

- 移动 easyagent/doc/tools.json → easyagent/src/tools/tools.json
- 更新 batch/index.js 和 cli/index.js 中的引用路径
This commit is contained in:
JOJO 2026-06-16 20:18:45 +08:00
parent 1da269e2aa
commit ad1e9e1475
3 changed files with 283 additions and 2 deletions

View File

@ -105,7 +105,7 @@ async function main() {
}
// 加载工具
const tools = JSON.parse(fs.readFileSync(path.join(__dirname, '../../doc/tools.json'), 'utf8'));
const tools = JSON.parse(fs.readFileSync(path.join(__dirname, '../tools/tools.json'), 'utf8'));
tools.push({
type: 'function',
function: {

View File

@ -52,7 +52,7 @@ state.conversation = createConversation(WORKSPACE, {
});
const systemPrompt = fs.readFileSync(path.join(__dirname, '../../prompts/system.txt'), 'utf8');
const tools = JSON.parse(fs.readFileSync(path.join(__dirname, '../../doc/tools.json'), 'utf8'));
const tools = JSON.parse(fs.readFileSync(path.join(__dirname, '../tools/tools.json'), 'utf8'));
renderBanner({
modelKey: state.modelKey,

View File

@ -0,0 +1,281 @@
[
{
"type": "function",
"function": {
"name": "read_file",
"description": "读取/搜索/抽取 UTF-8 文本文件。type=read/search/extract仅单文件操作。",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "文件路径:工作区内请用相对路径,工作区外可用绝对路径。"
},
"type": {
"type": "string",
"enum": ["read", "search", "extract"],
"description": "读取模式read=按行读取search=在文件内搜索extract=按行段抽取。"
},
"max_chars": {
"type": "integer",
"description": "返回内容最大字符数,超出将截断。"
},
"start_line": {
"type": "integer",
"description": "[read] 起始行号1-based。"
},
"end_line": {
"type": "integer",
"description": "[read] 结束行号(>= start_line。"
},
"query": {
"type": "string",
"description": "[search] 搜索关键词。"
},
"max_matches": {
"type": "integer",
"description": "[search] 最多返回多少条命中窗口。"
},
"context_before": {
"type": "integer",
"description": "[search] 命中行向上追加行数。"
},
"context_after": {
"type": "integer",
"description": "[search] 命中行向下追加行数。"
},
"case_sensitive": {
"type": "boolean",
"description": "[search] 是否区分大小写。"
},
"segments": {
"type": "array",
"description": "[extract] 需要抽取的行区间数组。",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string",
"description": "片段标签(可选)。"
},
"start_line": {
"type": "integer",
"description": "起始行号(>=1。"
},
"end_line": {
"type": "integer",
"description": "结束行号(>= start_line。"
}
},
"required": ["start_line", "end_line"]
},
"minItems": 1
}
},
"required": ["path", "type"]
}
}
},
{
"type": "function",
"function": {
"name": "edit_file",
"description": "在文件中执行精确字符串替换;建议先用 read_file 精确复制 old_string。",
"parameters": {
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "文件路径:工作区内请用相对路径,工作区外可用绝对路径。"
},
"old_string": {
"type": "string",
"description": "要替换的旧文本(必须与文件内容精确匹配)。"
},
"new_string": {
"type": "string",
"description": "替换的新文本(必须不同于 old_string。"
},
"replace_all": {
"type": "boolean",
"enum": [true, false],
"default": false,
"description": "是否替换所有匹配内容。false=仅替换首个匹配true=替换全部匹配。"
}
},
"required": ["file_path", "old_string", "new_string"]
}
}
},
{
"type": "function",
"function": {
"name": "web_search",
"description": "网络搜索Tavily。用于外部资料或最新信息检索。",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "搜索关键词(不要包含时间范围)。"
},
"max_results": {
"type": "integer",
"description": "最大返回结果数。"
},
"topic": {
"type": "string",
"enum": ["general", "news", "finance"],
"description": "搜索主题类型。"
},
"time_range": {
"type": "string",
"enum": ["day", "week", "month", "year", "d", "w", "m", "y"],
"description": "相对时间范围(与 days / start_date+end_date 互斥)。"
},
"days": {
"type": "integer",
"description": "最近 N 天(仅 topic=news 可用)。"
},
"start_date": {
"type": "string",
"description": "开始日期 YYYY-MM-DD必须与 end_date 同时提供)。"
},
"end_date": {
"type": "string",
"description": "结束日期 YYYY-MM-DD必须与 start_date 同时提供)。"
},
"country": {
"type": "string",
"description": "国家过滤,仅 topic=general 可用(英文小写国名)。"
}
},
"required": ["query"]
}
}
},
{
"type": "function",
"function": {
"name": "extract_webpage",
"description": "网页内容提取Tavily。mode=read 直接返回内容mode=save 保存为文件。",
"parameters": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"enum": ["read", "save"],
"description": "read=直接返回内容save=写入文件。"
},
"url": {
"type": "string",
"description": "目标网页 URL。"
},
"target_path": {
"type": "string",
"description": "[save] 保存路径:工作区内请用相对路径,工作区外可用绝对路径。必须是 .md 文件。mode=save 必填。"
}
},
"required": ["mode", "url"]
}
}
},
{
"type": "function",
"function": {
"name": "run_command",
"description": "在当前终端环境执行一次性命令(非交互式)。",
"parameters": {
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "要执行的命令。"
},
"timeout": {
"type": "number",
"description": "超时时间(秒),必填。"
},
"working_dir": {
"type": "string",
"description": "工作目录:工作区内请用相对路径,工作区外可用绝对路径。"
}
},
"required": ["command", "timeout"]
}
}
},
{
"type": "function",
"function": {
"name": "search_workspace",
"description": "在本地目录内搜索文件名或文件内容(跨文件)。仅返回摘要。",
"parameters": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"enum": ["file", "content"],
"description": "file=搜索文件名content=跨文件搜索内容。"
},
"query": {
"type": "string",
"description": "搜索关键词或正则。"
},
"root": {
"type": "string",
"description": "搜索起点目录:工作区内请用相对路径,工作区外可用绝对路径。默认 '.'。"
},
"use_regex": {
"type": "boolean",
"description": "是否使用正则匹配(默认 false。"
},
"case_sensitive": {
"type": "boolean",
"description": "是否区分大小写(默认 false。"
},
"max_results": {
"type": "integer",
"description": "最大返回结果数(默认 20。"
},
"max_matches_per_file": {
"type": "integer",
"description": "[content] 每个文件最多返回多少处匹配(默认 3。"
},
"include_glob": {
"type": "array",
"description": "仅包含匹配这些 glob 的文件。",
"items": { "type": "string" }
},
"exclude_glob": {
"type": "array",
"description": "排除匹配这些 glob 的文件。",
"items": { "type": "string" }
},
"max_file_size": {
"type": "integer",
"description": "跳过超过该字节数的文件。"
}
},
"required": ["mode", "query"]
}
}
},
{
"type": "function",
"function": {
"name": "read_mediafile",
"description": "读取图片或视频文件并附加给模型。非媒体文件将拒绝。",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "媒体文件路径:工作区内请用相对路径,工作区外可用绝对路径。"
}
},
"required": ["path"]
}
}
}
]