feat: 工具调用扩展,新增 5 个实用工具(共 12 个)
新增工具: - move_file: 移动/重命名文件(需确认) - copy_file: 复制文件/目录(需确认) - web_fetch: 抓取网页内容,自动提取文本(自动) - append_file: 追加内容到文件末尾(需确认) - edit_file: 文件内查找替换,支持全部替换(需确认) 同步更新: - 主进程 IPC 分发 - 工具安全检查(路径白名单) - 设置面板工具列表 UI - 帮助文档工具说明
This commit is contained in:
+11
-1
@@ -20,7 +20,12 @@ import {
|
||||
handleCreateDir,
|
||||
handleDeleteFile,
|
||||
handleRunCommand,
|
||||
killToolProcess
|
||||
killToolProcess,
|
||||
handleMoveFile,
|
||||
handleCopyFile,
|
||||
handleWebFetch,
|
||||
handleAppendFile,
|
||||
handleEditFile
|
||||
} from './tool-handlers.js';
|
||||
import { getAllowedDirs, getBlockedDirs, setAllowedDirs } from './tool-security.js';
|
||||
import { startProcess, killProcess, getWorkspaceDir, setWorkspaceDir, listWorkspaceDir } from './workspace.js';
|
||||
@@ -108,6 +113,11 @@ export function setupIPC(): void {
|
||||
case 'create_directory': return await handleCreateDir(args as { path: string });
|
||||
case 'delete_file': return await handleDeleteFile(args as { path: string; recursive?: boolean });
|
||||
case 'run_command': return await handleRunCommand(args as { command: string; cwd?: string; timeout?: number });
|
||||
case 'move_file': return await handleMoveFile(args as { source: string; destination: string });
|
||||
case 'copy_file': return await handleCopyFile(args as { source: string; destination: string; recursive?: boolean });
|
||||
case 'web_fetch': return await handleWebFetch(args as { url: string; max_chars?: number; extract_mode?: string });
|
||||
case 'append_file': return await handleAppendFile(args as { path: string; content: string; newline?: boolean });
|
||||
case 'edit_file': return await handleEditFile(args as { path: string; old_text: string; new_text: string; all?: boolean });
|
||||
default: return { success: false, error: `未知工具: ${toolName}` };
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user