const http = require('http'); console.log('๐Ÿงช Testing Nowhere AI Agent...\n'); // Test health endpoint function testHealth() { return new Promise((resolve, reject) => { const req = http.request({ hostname: 'localhost', port: 3001, path: '/health', method: 'GET' }, (res) => { let data = ''; res.on('data', (chunk) => data += chunk); res.on('end', () => { try { const response = JSON.parse(data); console.log('โœ… Health check passed:', response.status); resolve(response); } catch (error) { console.log('โŒ Health check failed:', error.message); reject(error); } }); }); req.on('error', (error) => { console.log('โŒ Health check failed:', error.message); reject(error); }); req.end(); }); } // Test command endpoint function testCommand() { return new Promise((resolve, reject) => { const postData = JSON.stringify({ command: 'analyze this code', userId: 'test-user' }); const req = http.request({ hostname: 'localhost', port: 3001, path: '/api/v1/command', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) } }, (res) => { let data = ''; res.on('data', (chunk) => data += chunk); res.on('end', () => { try { const response = JSON.parse(data); console.log('โœ… Command test passed:', response.message); resolve(response); } catch (error) { console.log('โŒ Command test failed:', error.message); reject(error); } }); }); req.on('error', (error) => { console.log('โŒ Command test failed:', error.message); reject(error); }); req.write(postData); req.end(); }); } // Test status endpoint function testStatus() { return new Promise((resolve, reject) => { const req = http.request({ hostname: 'localhost', port: 3001, path: '/api/v1/status', method: 'GET' }, (res) => { let data = ''; res.on('data', (chunk) => data += chunk); res.on('end', () => { try { const response = JSON.parse(data); console.log('โœ… Status test passed:', response.data.autopilot ? 'Autopilot enabled' : 'Autopilot disabled'); resolve(response); } catch (error) { console.log('โŒ Status test failed:', error.message); reject(error); } }); }); req.on('error', (error) => { console.log('โŒ Status test failed:', error.message); reject(error); }); req.end(); }); } // Run all tests async function runTests() { try { await testHealth(); await testCommand(); await testStatus(); console.log('\n๐ŸŽ‰ All tests passed! Nowhere AI Agent is working correctly.'); console.log('\n๐Ÿ“‹ Available endpoints:'); console.log(' โ€ข POST /api/v1/command - Process text commands'); console.log(' โ€ข POST /api/v1/voice - Process voice commands'); console.log(' โ€ข POST /api/v1/autopilot - Toggle autopilot mode'); console.log(' โ€ข GET /api/v1/memory/:userId - Get user memory'); console.log(' โ€ข GET /api/v1/status - Get system status'); console.log(' โ€ข GET /health - Health check'); } catch (error) { console.log('\nโŒ Some tests failed. Make sure the server is running on port 3001.'); console.log('๐Ÿ’ก Start the server with: cd backend && node server.js'); } } runTests();