v0.11.5: 搜索抓取增强 + 流式进度修复 + 超时/写入容错
feat: 搜索面板新增认证类型 Bearer/Basic,自动抓取条数/类型(顺序/随机) feat: 随机抓取失败自动从未抓取池补1条,上限移除 fix: write_file 缺 path 时返回引导性报错(含工作空间路径+平台示例) fix: Ollama tool_calls arguments JSON字符串解析 fix: 流式进度日志不再删除,改为完整时间线记录 fix: 进度日志同步appendChild确保排在工具日志之前 fix: 超时设置面板/主进程 remove max上限 chore: 版本号 0.11.4 → 0.11.5
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
|
||||
import * as fs from 'fs/promises';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import { spawn } from 'child_process';
|
||||
import { checkPathAllowed } from './tool-security.js';
|
||||
import { sendLog, resolvePath, type ToolResult } from './tool-handlers-shared.js';
|
||||
import { getWorkspaceDir } from './workspace.js';
|
||||
|
||||
export async function handleReadFile(params: { path: string; encoding?: string; start_line?: number; end_line?: number; mode?: string; offset_bytes?: number; limit_bytes?: number }): Promise<ToolResult> {
|
||||
try {
|
||||
@@ -156,6 +158,17 @@ function extToMime(ext: string): string {
|
||||
|
||||
export async function handleWriteFile(params: { path: string; content: string; encoding?: string; mode?: string }): Promise<ToolResult> {
|
||||
try {
|
||||
if (!params.path || typeof params.path !== 'string') {
|
||||
const wsDir = getWorkspaceDir();
|
||||
const homeDir = os.homedir();
|
||||
const absExample = process.platform === 'win32'
|
||||
? `${homeDir}\\Documents\\file.txt`
|
||||
: `${homeDir}/file.txt`;
|
||||
return { success: false, error: `缺少 path 参数。请指定文件路径,相对路径基于工作空间 ${wsDir}。例如: "output.txt" 或 "${absExample}"` };
|
||||
}
|
||||
if (params.content === undefined || params.content === null) {
|
||||
return { success: false, error: '缺少 content 参数,请指定要写入的内容' };
|
||||
}
|
||||
const filePath = resolvePath(params.path);
|
||||
const allowed = checkPathAllowed(filePath, 'write');
|
||||
if (!allowed.ok) return { success: false, error: allowed.reason };
|
||||
|
||||
Reference in New Issue
Block a user