@@ -231,22 +231,29 @@ export function registerMainHandlers() {
231231 } ) ;
232232 apiProcess . on ( 'message' , async msg => {
233233 console . log ( '[api-process] received message:' , msg ) ;
234- const resources = await convert ( msg . body ) ;
235- console . log ( '[api-process] converted to resources:' , resources ) ;
236- if ( resources && ! ( 'convertErrorMessage' in resources ) && resources . length > 0 ) {
237- const req = resources [ 0 ] as unknown as Partial < Request > ;
238- let url = '' ;
239- for ( const window of BrowserWindow . getAllWindows ( ) ) {
240- url = window . webContents . getURL ( ) ;
234+ if ( ! msg . curlRequests || ! Array . isArray ( msg . curlRequests ) ) {
235+ console . warn ( '[api-process] invalid message format, missing curlRequests array' ) ;
236+ return ;
237+ }
238+ for ( const request of msg . curlRequests ) {
239+ const resources = await convert ( request ) ;
240+ console . log ( '[api-process] converted to resources:' , resources ) ;
241+ if ( resources && ! ( 'convertErrorMessage' in resources ) && resources . length > 0 ) {
242+ const req = resources [ 0 ] as unknown as Partial < Request > ;
243+ let url = '' ;
244+ for ( const window of BrowserWindow . getAllWindows ( ) ) {
245+ url = window . webContents . getURL ( ) ;
246+ }
247+
248+ const workspaceId = url . match ( / w r k _ [ a - z A - Z 0 - 9 ] + / ) ?. [ 0 ] ;
249+ console . log ( '[api-process] got workspace:' , workspaceId ) ;
250+ await models . request . create ( {
251+ ...req ,
252+ _id : undefined ,
253+ name : req . url ,
254+ parentId : workspaceId || 'wrk_scratchpad' ,
255+ } ) ;
241256 }
242- const workspaceId = url . match ( / w r k _ [ a - z A - Z 0 - 9 ] + / ) ?. [ 0 ] ;
243- console . log ( '[api-process] got workspace:' , workspaceId ) ;
244- await models . request . create ( {
245- ...req ,
246- _id : undefined ,
247- name : req . url ,
248- parentId : workspaceId || 'wrk_scratchpad' ,
249- } ) ;
250257 for ( const window of BrowserWindow . getAllWindows ( ) ) {
251258 window . webContents . send ( 'reload-from-mcp' ) ;
252259 }
0 commit comments