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
This commit is contained in:
@@ -4,7 +4,7 @@ let automationInstance = null;
|
||||
async function createAutomationInstance() {
|
||||
try {
|
||||
// Try to import the learning-enhanced automation first
|
||||
const AutomationWithLearning = require('./automation-with-learning-v2.js');
|
||||
const AutomationWithLearning = (await import('./automation-with-learning-v2.js')).default;
|
||||
console.log('✅ Creating automation instance with AI learning system');
|
||||
return new AutomationWithLearning();
|
||||
} catch (error) {
|
||||
@@ -23,24 +23,24 @@ async function createAutomationInstance() {
|
||||
}
|
||||
}
|
||||
|
||||
function getAutomationInstance() {
|
||||
async function getAutomationInstance() {
|
||||
if (!automationInstance) {
|
||||
automationInstance = createAutomationInstance();
|
||||
automationInstance = await createAutomationInstance();
|
||||
}
|
||||
return automationInstance;
|
||||
}
|
||||
|
||||
function resetAutomationInstance() {
|
||||
async function resetAutomationInstance() {
|
||||
if (automationInstance) {
|
||||
console.log('🔄 Resetting automation instance');
|
||||
if (typeof automationInstance.stop === 'function') {
|
||||
automationInstance.stop();
|
||||
await automationInstance.stop();
|
||||
}
|
||||
}
|
||||
automationInstance = null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
getAutomationInstance,
|
||||
resetAutomationInstance
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user