feat(cli): resolve agent tools based on main thread agent definition in headless streaming

This commit is contained in:
yhangf 2026-05-09 14:18:10 +08:00
parent ba2aad5c09
commit 1efba6b17a

View File

@ -38,6 +38,7 @@ import {
isBuiltInAgent, isBuiltInAgent,
parseAgentsFromJson, parseAgentsFromJson,
} from '@claude-code-best/builtin-tools/tools/AgentTool/loadAgentsDir.js' } from '@claude-code-best/builtin-tools/tools/AgentTool/loadAgentsDir.js'
import { resolveAgentTools } from '@claude-code-best/builtin-tools/tools/AgentTool/agentToolUtils.js'
import type { Message, NormalizedUserMessage } from 'src/types/message.js' import type { Message, NormalizedUserMessage } from 'src/types/message.js'
import type { QueuedCommand } from 'src/types/textInputTypes.js' import type { QueuedCommand } from 'src/types/textInputTypes.js'
import { import {
@ -2027,7 +2028,13 @@ function runHeadlessStreaming(
reregisterChannelHandlerAfterReconnect(client) reregisterChannelHandlerAfterReconnect(client)
} }
const allTools = buildAllTools(appState) const rawTools = buildAllTools(appState)
const mainThreadAgentDef = currentAgents.find(
a => a.agentType === getMainThreadAgentType(),
)
const allTools = mainThreadAgentDef
? resolveAgentTools(mainThreadAgentDef, rawTools, false, true).resolvedTools
: rawTools
for (const uuid of batchUuids) { for (const uuid of batchUuids) {
notifyCommandLifecycle(uuid, 'started') notifyCommandLifecycle(uuid, 'started')