diff --git a/Chat/backend/routes/trae.js b/Chat/backend/routes/trae.js index d91374e8..e088ac6f 100644 --- a/Chat/backend/routes/trae.js +++ b/Chat/backend/routes/trae.js @@ -142,47 +142,43 @@ router.post('/execute-batch', async (req, res) => { return res.status(400).json({ error: 'Operations array is required' }); } - const results = []; - - for (const op of operations) { + const results = await Promise.all(operations.map(async (op) => { const { tool, args = [] } = op; if (!tool) { - results.push({ + return { success: false, tool: null, error: 'Tool name is required' - }); - continue; + }; } const toolFunction = tools[tool]; if (!toolFunction) { - results.push({ + return { success: false, tool, error: `Tool '${tool}' not found` - }); - continue; + }; } try { console.log(`[TRAE] Batch executing: ${tool}`); const result = await toolFunction(...args); - results.push({ + return { success: true, tool, result - }); + }; } catch (e) { - results.push({ + return { success: false, tool, error: e.message - }); + }; } - } + })); res.json({ success: true,