feat: 工具执行超时可配置 + 修复硬编码盖过工具自定义超时的 bug

1. 新增 agent.toolExecutionTimeoutMs 配置(默认 120s,范围 10~600s),AgentSettings 加输入框

2. 修复 engine.ts 硬编码 120s 会盖过 delegate-task(5min)/web-search(5min) 等工具自定义 timeoutMs 的 bug:改为取 max(配置值, tool.timeoutMs)

3. main.ts 启动时从 ConfigService 加载;handlers.ts 监听 config:set 即时更新
This commit is contained in:
thzxx
2026-07-12 14:51:12 +08:00
parent 6d31498e6a
commit 3858f5ede3
5 changed files with 27 additions and 4 deletions
+5 -3
View File
@@ -505,6 +505,10 @@ export function registerAllIPCHandlers(
// 工具确认超时变更,即时应用到 ConfirmationHook
confirmationHook.setConfirmationTimeout(value as number);
log.info(`[CONFIG] Confirmation timeout updated to ${value}ms`);
} else if (key === 'agent.toolExecutionTimeoutMs') {
// 工具执行兜底超时变更,即时应用到 Engine
agentLoop.updateConfig({ toolExecutionTimeoutMs: value as number });
log.info(`[CONFIG] Tool execution timeout updated to ${value}ms`);
}
// 日志级别变更时即时应用
@@ -670,7 +674,7 @@ export function registerAllIPCHandlers(
// 获取当前工作空间详情:路径 + 4 个核心文件状态 + 自动目录状态
ipcMain.handle('workspace:getInfo', async () => {
const { existsSync, statSync } = await import('fs');
const { existsSync, statSync, readFileSync, readdirSync } = await import('fs');
const workspacePath = workspaceService.getPath();
const files = workspaceService.reload(); // 同步外部可能的手动修改
@@ -690,7 +694,6 @@ export function registerAllIPCHandlers(
size = stat.size;
mtime = stat.mtimeMs;
// 截取前 500 字符作为预览
const { readFileSync } = await import('fs');
const content = readFileSync(filePath, 'utf-8');
preview = content.length > 500 ? content.slice(0, 500) + '\n...(已截断)' : content;
}
@@ -718,7 +721,6 @@ export function registerAllIPCHandlers(
exists = true;
const stat = statSync(dirPath);
if (stat.isDirectory()) {
const { readdirSync } = await import('fs');
fileCount = readdirSync(dirPath).length;
}
}