mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-09 19:45:41 +00:00
fix: correct MCP_REMOTE_CONFIG_DIR path
This commit is contained in:
parent
38b99b00d2
commit
81d59319aa
3 changed files with 66 additions and 60 deletions
|
|
@ -92,20 +92,20 @@ async function checkAndInstallDepsOnUpdate(): Promise<boolean> {
|
|||
if (!result) {
|
||||
log.error(' install dependencies failed');
|
||||
resolve(false);
|
||||
return
|
||||
return
|
||||
}
|
||||
resolve(true);
|
||||
log.info(' install dependencies complete');
|
||||
return
|
||||
return
|
||||
} else {
|
||||
log.info(' version not changed, skip install dependencies', { currentVersion });
|
||||
resolve(true);
|
||||
return
|
||||
return
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(' check version and install dependencies error:', error);
|
||||
resolve(false);
|
||||
return
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -651,12 +651,15 @@ function registerIpcHandlers() {
|
|||
const tempEmail = email.split("@")[0].replace(/[\\/*?:"<>|\s]/g, "_").replace(".", "_");
|
||||
const MCP_CONFIG_DIR = path.join(os.homedir(), '.eigent');
|
||||
const MCP_REMOTE_CONFIG_DIR = path.join(MCP_CONFIG_DIR, tempEmail);
|
||||
|
||||
|
||||
log.info('Getting MCP config path for email:', email);
|
||||
log.info('MCP config path:', MCP_REMOTE_CONFIG_DIR);
|
||||
|
||||
// 判断MCP_REMOTE_CONFIG_DIR+mcp-remote-0.1.18的文件夹是否存在
|
||||
const mcpRemoteDir = path.join(MCP_REMOTE_CONFIG_DIR, 'mcp-remote-0.1.18');
|
||||
const isMcpRemoteDirExists = fs.existsSync(mcpRemoteDir);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
success: isMcpRemoteDirExists,
|
||||
path: MCP_REMOTE_CONFIG_DIR,
|
||||
tempEmail: tempEmail,
|
||||
baseDir: MCP_CONFIG_DIR
|
||||
|
|
@ -732,40 +735,40 @@ function registerIpcHandlers() {
|
|||
try {
|
||||
const https = await import('https');
|
||||
const http = await import('http');
|
||||
|
||||
|
||||
// extract file name from URL
|
||||
const urlObj = new URL(url);
|
||||
const fileName = urlObj.pathname.split('/').pop() || 'download';
|
||||
|
||||
|
||||
// get download directory
|
||||
const downloadPath = path.join(app.getPath('downloads'), fileName);
|
||||
|
||||
|
||||
// create write stream
|
||||
const fileStream = fs.createWriteStream(downloadPath);
|
||||
|
||||
|
||||
// choose module according to protocol
|
||||
const client = url.startsWith('https:') ? https : http;
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = client.get(url, (response) => {
|
||||
if (response.statusCode !== 200) {
|
||||
reject(new Error(`HTTP ${response.statusCode}`));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
response.pipe(fileStream);
|
||||
|
||||
|
||||
fileStream.on('finish', () => {
|
||||
fileStream.close();
|
||||
shell.showItemInFolder(downloadPath);
|
||||
resolve({ success: true, path: downloadPath });
|
||||
});
|
||||
|
||||
|
||||
fileStream.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
request.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -276,53 +276,58 @@ export default function Folder({ data }: { data?: Agent }) {
|
|||
},
|
||||
]);
|
||||
useEffect(() => {
|
||||
window.ipcRenderer
|
||||
.invoke(
|
||||
const setFileList = async () => {
|
||||
let res = null;
|
||||
res = await window.ipcRenderer.invoke(
|
||||
"get-file-list",
|
||||
authStore.email,
|
||||
chatStore.activeTaskId as string
|
||||
)
|
||||
.then((res: FileInfo[]) => {
|
||||
);
|
||||
let tree: any = null;
|
||||
if ((res && res.length > 0) ) {
|
||||
tree = buildFileTree(res || []);
|
||||
} else {
|
||||
res = await proxyFetchGet("/api/chat/files", {
|
||||
task_id: chatStore.activeTaskId as string,
|
||||
});
|
||||
console.log("res", res);
|
||||
let tree: any = null;
|
||||
if ((res && res.length > 0)||import.meta.env.DEV) {
|
||||
tree = buildFileTree(res || []);
|
||||
setFileTree(tree);
|
||||
// Keep the old structure for compatibility
|
||||
setFileGroups((prev) => {
|
||||
return [
|
||||
{
|
||||
...prev[0],
|
||||
files: res || [],
|
||||
},
|
||||
];
|
||||
});
|
||||
} else {
|
||||
proxyFetchGet("/api/chat/files", {
|
||||
task_id: chatStore.activeTaskId as string,
|
||||
}).then((res) => {
|
||||
console.log("res", res);
|
||||
const files = res.map((item: any) => {
|
||||
return {
|
||||
name: item.filename,
|
||||
type: item.filename.split(".")[1],
|
||||
path: item.url,
|
||||
isRemote: true, // 标识为远程文件
|
||||
};
|
||||
});
|
||||
const tree = buildFileTree(files || []);
|
||||
setFileTree(tree);
|
||||
setFileGroups((prev) => {
|
||||
return [
|
||||
{
|
||||
...prev[0],
|
||||
files: files || [],
|
||||
},
|
||||
];
|
||||
});
|
||||
});
|
||||
res = res.map((item: any) => {
|
||||
return {
|
||||
name: item.filename,
|
||||
type: item.filename.split(".")[1],
|
||||
path: item.url,
|
||||
isRemote: true,
|
||||
};
|
||||
});
|
||||
tree = buildFileTree(res || []);
|
||||
}
|
||||
setFileTree(tree);
|
||||
// Keep the old structure for compatibility
|
||||
setFileGroups((prev) => {
|
||||
const chatStoreSelectedFile = chatStore.tasks[chatStore.activeTaskId as string]?.selectedFile;
|
||||
if (chatStoreSelectedFile) {
|
||||
console.log(res,chatStoreSelectedFile)
|
||||
const file = res.find((item: any) => item.name === chatStoreSelectedFile.name);
|
||||
console.log("file", file);
|
||||
if(file){
|
||||
selecetdFileChange(file as FileInfo,isShowSourceCode);
|
||||
}
|
||||
}
|
||||
return [
|
||||
{
|
||||
...prev[0],
|
||||
files: res || [],
|
||||
},
|
||||
];
|
||||
});
|
||||
// if (chatStore.tasks[chatStore.activeTaskId as string]?.selectedFile) {
|
||||
// selecetdFileChange(
|
||||
// chatStore.tasks[chatStore.activeTaskId as string]
|
||||
// .selectedFile as FileInfo
|
||||
// );
|
||||
// }
|
||||
};
|
||||
setFileList();
|
||||
}, [data, chatStore.tasks[chatStore.activeTaskId as string]?.taskAssigning]);
|
||||
const handleBack = () => {
|
||||
chatStore.setActiveWorkSpace(chatStore.activeTaskId as string, "workflow");
|
||||
|
|
|
|||
|
|
@ -295,14 +295,12 @@ const chatStore = create<ChatStore>()(
|
|||
} catch (error) {
|
||||
console.log('get-env-path error', error)
|
||||
}
|
||||
let mcpConfigPath = ''
|
||||
let mcpConfigPath = undefined
|
||||
if (email) {
|
||||
// Get MCP config path
|
||||
const result = await window.electronAPI.getMcpConfigPath(email);
|
||||
if (result.success) {
|
||||
mcpConfigPath = result.path
|
||||
} else {
|
||||
console.error('get mcp config path failed:', result.error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue