Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions Chat/backend/routes/trae.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down