From ac98c3e2420de5c8ee070528b70a036f7f280883 Mon Sep 17 00:00:00 2001 From: Christopher Mayor Date: Wed, 4 Mar 2026 15:41:01 -0800 Subject: [PATCH] fix: properly define agent enhancement variables before use --- server.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 4e36c16..636a902 100644 --- a/server.js +++ b/server.js @@ -557,11 +557,42 @@ app.get('/api/agents', (req, res) => { ); }); }; - - const agentPromises = agentDirs.map(async (agentName) => { +const agentPromises = agentDirs.map(async (agentName) => { const agentPath = path.join(AGENTS_DIR, agentName); const workspacePath = path.join(agentPath, 'workspace'); + // 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 agent = { id: agentName, emoji,