const WebSocket = require('ws'); const ws = new WebSocket('ws://localhost:5000/ws'); ws.on('open', function open() { const packet = JSON.stringify({ username: "test-user", password: "123456" }); ws.send(packet); runTest(); }); ws.on('message', function incoming(data) { const jsonResponse = JSON.parse(data); console.log(jsonResponse); }); function runTest() { const message = { action: 'create-agent', body: { name: 'First Agent', description: 'First agent does nothing', kind: 'simple', data: {} }, }; ws.send(JSON.stringify(message)); // Send the create-agent message }