mirror of
https://github.com/xmanrui/OpenClaw-bot-review.git
synced 2026-08-14 00:47:49 +00:00
- Add /workspace page: Agent grid with real-time status - Add /daily page: Daily report board with TTS playback - Add new API routes: /api/agents, /api/daily - Add new components: agent-card, agent-grid - Add sidebar navigation for new pages - Add i18n labels (zh-CN + en)
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
// lib/agents.ts
|
|
import { readFileSync, existsSync, readdirSync } from 'fs';
|
|
import { join } from 'path';
|
|
|
|
export interface AgentStatus {
|
|
id: string;
|
|
name: string;
|
|
emoji: string;
|
|
status: 'working' | 'idle' | 'thinking' | 'waiting';
|
|
mood: 'happy' | 'neutral' | 'busy' | 'tired' | 'thinking';
|
|
currentTask: string;
|
|
uptime: number;
|
|
lastActive: string;
|
|
}
|
|
|
|
export function getAgents(): AgentStatus[] {
|
|
const configPath = join(process.env.HOME || '', '.openclaw/openclaw.json');
|
|
|
|
if (!existsSync(configPath)) {
|
|
return [];
|
|
}
|
|
|
|
let config: any = {};
|
|
try {
|
|
config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
} catch {
|
|
return [];
|
|
}
|
|
|
|
// 从配置中提取 Agent 信息
|
|
const agents = Object.entries(config.agents || {}).map(([id, agent]: [string, any]) => ({
|
|
id,
|
|
name: agent.name || id,
|
|
emoji: agent.emoji || '🤖',
|
|
status: 'idle' as const,
|
|
mood: 'neutral' as const,
|
|
currentTask: '等待指令',
|
|
uptime: 0,
|
|
lastActive: new Date().toISOString(),
|
|
}));
|
|
|
|
return agents;
|
|
}
|