mirror of
https://github.com/xmanrui/OpenClaw-bot-review.git
synced 2026-07-27 22:25:52 +00:00
Fix pixel office agent discovery fallback
This commit is contained in:
@@ -40,6 +40,30 @@ export interface AgentActivity {
|
||||
subagents?: SubagentInfo[]
|
||||
}
|
||||
|
||||
type AgentConfigEntry = {
|
||||
id: string
|
||||
name?: string
|
||||
emoji?: string
|
||||
identity?: { emoji?: string }
|
||||
}
|
||||
|
||||
async function loadAgentList(config: any, agentsDir: string): Promise<AgentConfigEntry[]> {
|
||||
const configured = Array.isArray(config?.agents?.list)
|
||||
? config.agents.list.filter((agent: any) => agent && typeof agent.id === 'string' && agent.id)
|
||||
: []
|
||||
if (configured.length > 0) return configured
|
||||
|
||||
try {
|
||||
if (!existsSync(agentsDir)) return []
|
||||
const dirs = await fs.readdir(agentsDir, { withFileTypes: true })
|
||||
return dirs
|
||||
.filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))
|
||||
.map((entry) => ({ id: entry.name }))
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
function isSubtaskDescription(desc: string): boolean {
|
||||
const d = desc.toLowerCase()
|
||||
return desc.startsWith('Subtask:') || desc.startsWith('子任务') || d.includes('subtask')
|
||||
@@ -494,8 +518,8 @@ export async function GET() {
|
||||
const configContent = await fs.readFile(configPath, 'utf8')
|
||||
const config = parseJsonText(configContent)
|
||||
|
||||
const agentList = Array.isArray(config.agents) ? config.agents : config.agents?.list
|
||||
if (agentList && Array.isArray(agentList)) {
|
||||
const agentList = await loadAgentList(config, agentsDir)
|
||||
if (agentList.length > 0) {
|
||||
const now = Date.now()
|
||||
|
||||
for (const agent of agentList) {
|
||||
|
||||
Reference in New Issue
Block a user