// Quick WebSocket test for review pipeline const TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3ODIwNTIwNDYsImlhdCI6MTc3OTQ2MDA0NiwidHlwZSI6ImFjY2VzcyIsInVzZXJfaWQiOiJhZG1pbiJ9.dmNrCJsz576eEvNWlXVNP7BdZDEpijJ73pSrcqmTJdE'; const WS_URL = `ws://127.0.0.1:8080/ws/chat?token=${TOKEN}&session_id=test_review_${Date.now()}`; const ws = new WebSocket(WS_URL); ws.onopen = () => { console.log('Connected to WebSocket'); ws.send(JSON.stringify({ type: 'message', content: '帮我把客厅灯打开', session_id: null, mode: 'text', timestamp: Date.now() })); console.log('Sent: 帮我把客厅灯打开'); }; ws.onmessage = (event) => { try { const msg = JSON.parse(event.data); const short = JSON.stringify(msg).substring(0, 400); console.log(`[${msg.type}]`, short); if (msg.type === 'response' && msg.msg_type === 'action') { console.log('✅ Got ACTION message!'); } if (msg.type === 'response' && msg.msg_type === 'chat') { console.log('✅ Got CHAT message!'); } if (msg.type === 'stream_end') { console.log('Stream ended, closing...'); setTimeout(() => ws.close(), 500); } if (msg.type === 'error') { console.log('Error:', msg.error); ws.close(); } } catch (e) { console.log('Raw:', event.data.substring(0, 300)); } }; ws.onclose = () => { console.log('Connection closed'); process.exit(0); }; ws.onerror = (err) => { console.error('WebSocket error:', err.message); process.exit(1); }; setTimeout(() => { console.log('Timeout (30s) - closing'); ws.close(); process.exit(1); }, 30000);