@@ -28,6 +28,8 @@ import { commandSelectionInvoke, mcpServersProcessCallback } from './index'
2828import { getCachedText } from './aid/utils'
2929import { McpClientResponse , CommandResponse , McpInitResponse } from './types'
3030
31+ import { IpcFileTransferRequest , IpcFileTransferResponse } from '@/types/ipc'
32+
3133const handlerRegistry = new Map < string , Function > ( )
3234
3335interface ManifestResponse {
@@ -189,28 +191,39 @@ export default class IPCs {
189191 return dialogResult
190192 } )
191193
192- ipcMain . on ( 'msgFileTransferRequest' , async ( event : IpcMainEvent , { name, data } ) => {
193- try {
194- const buffer = Buffer . from ( data )
195- const saveOption = Constants . getDxtSource ( name )
196- const filePath = saveOption . mcpbPath
197- const dirPath = saveOption . outputDir
198- if ( ! existsSync ( dirPath ) ) {
199- mkdirSync ( dirPath , { recursive : true } )
194+ ipcMain . on (
195+ 'msgFileTransferRequest' ,
196+ async ( event : IpcMainEvent , { name, data } : IpcFileTransferRequest ) => {
197+ try {
198+ const buffer = Buffer . from ( data )
199+ const saveOption = Constants . getDxtSource ( name )
200+ const filePath = saveOption . mcpbPath
201+ const dirPath = saveOption . outputDir
202+ if ( ! existsSync ( dirPath ) ) {
203+ mkdirSync ( dirPath , { recursive : true } )
204+ }
205+ console . log ( 'MCP bundle to be saved in: ' , filePath )
206+
207+ writeFileSync ( filePath , buffer , { encoding : null } )
208+
209+ console . log ( saveOption )
210+ await unpackDxt ( saveOption )
211+ // console.log(getManifest(dirPath))
212+
213+ event . reply ( 'msgFileTransferResponse' , {
214+ name,
215+ success : true ,
216+ path : saveOption . outputDir
217+ } as IpcFileTransferResponse )
218+ } catch ( err ) {
219+ event . reply ( 'msgFileTransferResponse' , {
220+ name,
221+ success : false ,
222+ reason : err . message
223+ } as IpcFileTransferResponse )
200224 }
201- console . log ( 'MCP bundle to be saved in: ' , filePath )
202-
203- writeFileSync ( filePath , buffer , { encoding : null } )
204-
205- console . log ( saveOption )
206- await unpackDxt ( saveOption )
207- // console.log(getManifest(dirPath))
208-
209- event . reply ( 'msgFileTransferResponse' , { name, success : true , path : saveOption . outputDir } )
210- } catch ( err ) {
211- event . reply ( 'msgFileTransferResponse' , { name, success : false , reason : err . message } )
212225 }
213- } )
226+ )
214227
215228 ipcMain . on (
216229 'msgCommandSelectionResult' ,
0 commit comments