From 9cce26b08aab56aa66f5b408ff1216755bcef9f3 Mon Sep 17 00:00:00 2001 From: Christopher Mayor Date: Wed, 4 Mar 2026 15:40:00 -0800 Subject: [PATCH] fix: properly add agent enhancements to async context --- server.js | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/server.js b/server.js index ce3df85..4e36c16 100644 --- a/server.js +++ b/server.js @@ -558,44 +558,16 @@ app.get('/api/agents', (req, res) => { }); }; - // Load openclaw config for identity info - let emoji = '🤖'; - let model = 'unknown'; - let identityName = agentName; - - if (fs.existsSync(OPENCLAW_CONFIG)) { - try { - const openclawConfig = JSON.parse(fs.readFileSync(OPENCLAW_CONFIG, 'utf8')); - const agentConfig = openclawConfig.agents?.list?.find(a => a.id === agentName); - if (agentConfig) { - emoji = agentConfig.identity?.emoji || '🤖'; - model = agentConfig.model?.primary || 'unknown'; - identityName = agentConfig.identity?.name || agentName; - } - } catch {} - } - - // Get last activity from session files - let lastActivity = null; - const sessionsPath = path.join(agentPath, 'sessions'); - if (fs.existsSync(sessionsPath)) { - const sessionFiles = fs.readdirSync(sessionsPath).filter(f => f.endsWith('.jsonl')); - if (sessionFiles.length > 0) { - const latestSession = sessionFiles - .map(f => ({ file: f, mtime: fs.statSync(path.join(sessionsPath, f)).mtime })) - .sort((a, b) => b.mtime - a.mtime)[0]; - if (latestSession) { - lastActivity = latestSession.mtime.toISOString(); - } - } - } + const agentPromises = agentDirs.map(async (agentName) => { + const agentPath = path.join(AGENTS_DIR, agentName); + const workspacePath = path.join(agentPath, 'workspace'); const agent = { id: agentName, - name: identityName, emoji, model, lastActivity, + name: identityName, status: 'active', currentTask: null, tools: [], @@ -606,6 +578,10 @@ app.get('/api/agents', (req, res) => { completedTasks: [], capabilities: [] }; + + if (fs.existsSync(workspacePath)) { + const files = fs.readdirSync(workspacePath); + agent.files = files.filter(f => f.endsWith('.md')); const memoryPath = path.join(workspacePath, 'MEMORY.md'); if (fs.existsSync(memoryPath)) {