feat: v0.10.2 - 可配置超时设置 + 默认值提升
- HTTP超时: 15s→30s(可配5s~300s), MCP超时: 30s→60s(可配10s~300s), 流式超时: 180s→300s(可配0~600s) - 设置面板新增超时配置区域(HTTP/流式/MCP),留空使用默认值 - 主进程HTTP_TIMEOUT/MCP_TIMEOUT改为可配置变量,通过IPC setTimeouts通道接收 - 帮助面板/README/release-notes更新四引擎搜索和超时描述 - 版本号同步更新至v0.10.2(16处)
This commit is contained in:
+12
-1
@@ -49,9 +49,10 @@ import {
|
||||
handleCompress
|
||||
} from './tool-handlers.js';
|
||||
import { browserOpen, browserScreenshot, browserEvaluate, browserExtract, browserClick, browserType, browserScroll, browserClose } from './browser.js';
|
||||
import { startServer, stopServer, stopAllServers, callTool, getAllTools, getServerStatuses, refreshTools } from './mcp-manager.js';
|
||||
import { startServer, stopServer, stopAllServers, callTool, getAllTools, getServerStatuses, refreshTools, setMCPTimeout } from './mcp-manager.js';
|
||||
import { getAllowedDirs, getBlockedDirs, setAllowedDirs } from './tool-security.js';
|
||||
import { startProcess, killProcess, getWorkspaceDir, setWorkspaceDir, listWorkspaceDir } from './workspace.js';
|
||||
import { setHTTPTimeout } from './tool-handlers-system.js';
|
||||
|
||||
/** 工具结果摘要(用于日志面板) */
|
||||
function summarizeResult(toolName: string, result: Record<string, unknown>): string {
|
||||
@@ -222,6 +223,16 @@ export async function setupIPC(): Promise<void> {
|
||||
setAllowedDirs(dirs);
|
||||
});
|
||||
|
||||
ipcMain.handle('tool:setTimeouts', (_, timeouts: { http?: number; mcp?: number }) => {
|
||||
if (typeof timeouts.http === 'number' && timeouts.http > 0) {
|
||||
setHTTPTimeout(timeouts.http);
|
||||
}
|
||||
if (typeof timeouts.mcp === 'number' && timeouts.mcp > 0) {
|
||||
setMCPTimeout(timeouts.mcp);
|
||||
}
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
// ── Workspace IPC ──
|
||||
|
||||
// 获取工作空间目录
|
||||
|
||||
@@ -52,7 +52,13 @@ interface MCPServerInstance {
|
||||
// ─── 状态 ───
|
||||
|
||||
const servers = new Map<string, MCPServerInstance>();
|
||||
const MCP_TIMEOUT = 30000; // 30 秒超时
|
||||
/** MCP 请求超时(毫秒),默认 60s,可通过 IPC 设置 */
|
||||
let MCP_TIMEOUT = 60_000;
|
||||
|
||||
/** 设置 MCP 请求超时(毫秒) */
|
||||
export function setMCPTimeout(ms: number): void {
|
||||
MCP_TIMEOUT = Math.max(10_000, Math.min(300_000, ms)); // 10s ~ 300s
|
||||
}
|
||||
|
||||
// ─── JSON-RPC 通信 ───
|
||||
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ export function createMenu(): void {
|
||||
dialog.showMessageBox(mainWindow!, {
|
||||
type: 'info',
|
||||
title: '关于 Metona Ollama',
|
||||
message: 'Metona Ollama Desktop v0.10.1',
|
||||
message: 'Metona Ollama Desktop v0.10.2',
|
||||
detail: 'TypeScript + Electron Ollama AI 聊天客户端\n\nhttps://gitee.com/thzxx/metona-ollama',
|
||||
icon: getIconPath()
|
||||
});
|
||||
|
||||
+2
-1
@@ -19,7 +19,8 @@ contextBridge.exposeInMainWorld('metonaDesktop', {
|
||||
tool: {
|
||||
execute: (toolName: string, args: Record<string, unknown>) => ipcRenderer.invoke('tool:execute', toolName, args),
|
||||
getConfig: () => ipcRenderer.invoke('tool:getConfig'),
|
||||
setAllowedDirs: (dirs: string[]) => ipcRenderer.invoke('tool:setAllowedDirs', dirs)
|
||||
setAllowedDirs: (dirs: string[]) => ipcRenderer.invoke('tool:setAllowedDirs', dirs),
|
||||
setTimeouts: (timeouts: { http?: number; mcp?: number }) => ipcRenderer.invoke('tool:setTimeouts', timeouts)
|
||||
},
|
||||
notify: (title: string, body: string) => ipcRenderer.invoke('notify', title, body),
|
||||
window: {
|
||||
|
||||
@@ -118,8 +118,13 @@ export function killToolProcess(): boolean {
|
||||
|
||||
|
||||
|
||||
/** HTTP 请求超时(毫秒) */
|
||||
const HTTP_TIMEOUT = 15_000;
|
||||
/** HTTP 请求超时(毫秒),默认 30s,可通过 IPC 设置 */
|
||||
let HTTP_TIMEOUT = 30_000;
|
||||
|
||||
/** 设置 HTTP 请求超时(毫秒) */
|
||||
export function setHTTPTimeout(ms: number): void {
|
||||
HTTP_TIMEOUT = Math.max(5000, Math.min(300_000, ms)); // 5s ~ 300s
|
||||
}
|
||||
|
||||
// ── LRU 搜索缓存 ──────────────────────────────────
|
||||
interface CacheEntry { results: Array<{ title: string; url: string; snippet: string; engine: string; reachable?: boolean }>; time: number; }
|
||||
|
||||
Reference in New Issue
Block a user