From 954c218085e062419cbab545a74689beec3be601 Mon Sep 17 00:00:00 2001 From: DoSun Date: Thu, 7 May 2026 18:00:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20serve=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=20GET=20/agent=20=E6=8E=A5=E5=8F=A3=EF=BC=8C=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E4=BB=8E=E5=86=85=E7=BD=AE=20agent=20=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8A=A0=E8=BD=BD=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/routes/info.ts | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/server/routes/info.ts b/src/server/routes/info.ts index 49a179efb..fd3e7adff 100644 --- a/src/server/routes/info.ts +++ b/src/server/routes/info.ts @@ -5,7 +5,7 @@ import { getClaudeConfigHomeDir } from '../../utils/envUtils.js' import { getCommands } from '../../commands.js' import { getCommandName } from '../../types/command.js' import type { SessionManager } from '../sessionManager.js' -import type { InitData } from '../sessionHandle.js' +import { getBuiltInAgents } from '@claude-code-best/builtin-tools/tools/AgentTool/builtInAgents.js' export function createInfoRoutes(sessionManager: SessionManager): Hono { return new Hono() @@ -44,18 +44,17 @@ export function createInfoRoutes(sessionManager: SessionManager): Hono { } }) .get('/agent', c => { - const initData = getFirstInitData(sessionManager) - if (initData?.agents && initData.agents.length > 0) { - return c.json( - initData.agents.map(a => ({ - id: a.name, - name: a.name, - description: a.description, - model: a.model, - })), - ) - } - return c.json([]) + const allAgents = getBuiltInAgents() + return c.json( + allAgents.map(a => ({ + name: a.agentType, + description: a.whenToUse, + mode: a.isMainThread ? ('primary' as const) : ('subagent' as const), + hidden: false, + options: {}, + permission: [], + })), + ) }) .get('/mcp', async c => { for (const handle of sessionManager.getAllSessions()) { @@ -71,10 +70,3 @@ export function createInfoRoutes(sessionManager: SessionManager): Hono { return c.json({ servers: [] }) }) } - -function getFirstInitData(sessionManager: SessionManager): InitData | null { - for (const handle of sessionManager.getAllSessions()) { - if (handle.initData) return handle.initData - } - return null -}