/** * @license * Copyright 2025 Qwen * SPDX-License-Identifier: Apache-2.0 */ import { BaseEmitter } from './BaseEmitter.js'; import type { SessionContext, ToolCallStartParams, ToolCallResultParams, ResolvedToolMetadata } from '../types.js'; import type * as acp from '../../acp.js'; import { Kind } from '@3-/qwen-code-core'; /** * Unified tool call event emitter. * * Handles tool_call and tool_call_update for ALL flows: * - Normal tool execution in runTool() * - History replay in HistoryReplayer * - SubAgent tool tracking in SubAgentTracker * * This ensures consistent behavior across all tool event sources, * including special handling for tools like TodoWriteTool. */ export declare class ToolCallEmitter extends BaseEmitter { private readonly planEmitter; constructor(ctx: SessionContext); /** * Emits a tool call start event. * * @param params - Tool call start parameters * @returns true if event was emitted, false if skipped (e.g., TodoWriteTool) */ emitStart(params: ToolCallStartParams): Promise; /** * Emits a tool call result event. * Handles TodoWriteTool specially by routing to plan updates. * * @param params - Tool call result parameters */ emitResult(params: ToolCallResultParams): Promise; /** * Emits a tool call error event. * Use this for explicit error handling when not using emitResult. * * @param callId - The tool call ID * @param error - The error that occurred */ emitError(callId: string, error: Error): Promise; /** * Checks if a tool name is the TodoWriteTool. * Exposed for external use in components that need to check this. */ isTodoWriteTool(toolName: string): boolean; /** * Checks if a tool name is the ExitPlanModeTool. */ isExitPlanModeTool(toolName: string): boolean; /** * Resolves tool metadata from the registry. * Falls back to defaults if tool not found or build fails. * * @param toolName - Name of the tool * @param args - Tool call arguments (used to build invocation) */ resolveToolMetadata(toolName: string, args?: Record): ResolvedToolMetadata; /** * Maps core Tool Kind enum to ACP ToolKind string literals. * * @param kind - The core Kind enum value * @param toolName - Optional tool name to handle special cases like exit_plan_mode */ mapToolKind(kind: Kind, toolName?: string): acp.ToolKind; /** * Extracts diff content from resultDisplay if it's a diff type (edit tool result). * Returns null if not a diff. */ private extractDiffContent; /** * Transforms Part[] to ToolCallContent[]. * Extracts text from functionResponse parts and text parts. */ private transformPartsToToolCallContent; }