Files
trading_bot_v3/app/api/automation/stop/route.js
mindesbunister d5bf485e72 fix: Complete automation v2 page runtime error fixes
- Fixed ES modules error by converting automation-with-learning-v2.js to pure ES6
- Fixed singleton pattern in automation-singleton.js for proper async handling
- Fixed EnhancedAILearningPanel to handle recommendation objects correctly
- Updated API routes to use correct import paths (../../../../lib/)
- Created proper db.js utility with ES6 exports
- Fixed simplified-stop-loss-learner imports and exports

 Automation v2 page now loads without errors
 AI learning system fully integrated and operational
 Learning status API working with detailed reports
 Recommendation rendering fixed for object structure
2025-07-27 12:38:32 +02:00

47 lines
1.4 KiB
JavaScript

// Import singleton automation manager
async function getAutomationInstance() {
try {
const { getAutomationInstance } = await import('../../../../lib/automation-singleton.js');
return await getAutomationInstance();
} catch (error) {
console.error('❌ Could not get automation instance:', error);
return null;
}
}
export async function POST() {
try {
console.log('🛑 AUTOMATION STOP: Request received');
const automation = await getAutomationInstance();
let result = { success: false, message: 'No automation instance available' };
if (automation) {
result = await automation.stop();
// Check if learning system was active
if (typeof automation.getLearningStatus === 'function') {
const learningStatus = await automation.getLearningStatus();
console.log('🧠 LEARNING SYSTEM: Stopped with', learningStatus.activeDecisions, 'active decisions');
}
}
// Additional cleanup
try {
const { execSync } = require('child_process');
execSync('pkill -f "chrome|chromium" 2>/dev/null || true');
console.log('✅ Additional cleanup completed');
} catch (cleanupError) {
console.error('Cleanup error:', cleanupError.message);
}
return Response.json(result);
} catch (error) {
console.error('❌ Stop automation error:', error);
return Response.json({
success: false,
message: error.message
}, { status: 500 });
}
}