// Test the serialization fix require('ts-node/register'); const { agenticRAGProcessor } = require('./src/services/agenticRAGProcessor'); async function testSerializationFix() { try { console.log('Testing Agentic RAG with serialization fix...'); // Test document text const testText = ` CONFIDENTIAL INVESTMENT MEMORANDUM Restoration Systems Inc. Executive Summary Restoration Systems Inc. is a leading company in the restoration industry with strong financial performance and market position. The company has established itself as a market leader through innovative technology solutions and a strong customer base. Company Overview Restoration Systems Inc. was founded in 2010 and has grown to become one of the largest restoration service providers in the United States. The company specializes in disaster recovery, property restoration, and emergency response services. Financial Performance - Revenue: $50M (2023), up from $42M (2022) - EBITDA: $10M (2023), representing 20% margin - Growth Rate: 20% annually over the past 3 years - Profit Margin: 15% (industry average: 8%) - Cash Flow: Strong positive cash flow with $8M in free cash flow `; // Use a real document ID from the database const documentId = 'f51780b1-455c-4ce1-b0a5-c36b7f9c116b'; // Real document ID from database const userId = '4161c088-dfb1-4855-ad34-def1cdc5084e'; // Real user ID from database console.log('Processing document with Agentic RAG (serialization fix)...'); const result = await agenticRAGProcessor.processDocument(testText, documentId, userId); console.log('✅ Agentic RAG processing completed successfully!'); console.log('Success:', result.success); console.log('Processing Time:', result.processingTime, 'ms'); console.log('API Calls:', result.apiCalls); console.log('Total Cost:', result.totalCost); console.log('Session ID:', result.sessionId); console.log('Summary Length:', result.summary?.length || 0); console.log('Analysis Data Keys:', Object.keys(result.analysisData || {})); console.log('Reasoning Steps Count:', result.reasoningSteps?.length || 0); console.log('Quality Metrics Count:', result.qualityMetrics?.length || 0); if (result.error) { console.log('❌ Error:', result.error); } else { console.log('✅ No errors detected'); } } catch (error) { console.error('❌ Agentic RAG processing failed:', error); console.error('Error details:', { name: error.name, message: error.message, type: error.type, retryable: error.retryable, context: error.context }); } } testSerializationFix();