| const socket = io(); | |
| let memoryCount = 0; | |
| function updateOutput(text) { | |
| const output = document.getElementById('output'); | |
| output.innerHTML += '> ' + text + '\n'; | |
| output.scrollTop = output.scrollHeight; | |
| } | |
| async function execute() { | |
| const input = document.getElementById('user-input').value; | |
| if (!input) return; | |
| try { | |
| const response = await fetch('/api/execute', { | |
| method: 'POST', | |
| headers: {'Content-Type': 'application/json'}, | |
| body: JSON.stringify({input: input}) | |
| }); | |
| const result = await response.json(); | |
| updateOutput(result.result); | |
| } catch (error) { | |
| updateOutput('Error: ' + error.message); | |
| } | |
| } | |
| socket.on('knowledge_update', (data) => { | |
| document.getElementById('knowledge-view').innerText = data.knowledge; | |
| }); | |
| socket.on('connect', () => { | |
| socket.emit('get_knowledge'); | |
| socket.emit('get_skills'); | |
| }); | |
| document.getElementById('user-input').addEventListener('keypress', (e) => { | |
| if (e.key === 'Enter') execute(); | |
| }); |