/**
 * Maps tool names (and optionally their arguments) to user-friendly status labels
 * shown in the UI during tool execution.
 *
 * Used by both the main agent (agent-harness) and subagents (spawn-service).
 */

const TOOL_LABELS: Record<string, string> = {
  MemoryLookup: 'Checking docs...',
  memory_lookup: 'Checking docs...',
  GetChartData: 'Fetching chart data...',
  SymbolLookup: 'Searching symbol...',
  WebSearch: 'Searching the web...',
  FetchPage: 'Fetching page...',
  ArxivSearch: 'Searching papers...',
  PythonList: 'Seeing what we have...',
  PythonEdit: 'Coding...',
  PythonWrite: 'Coding...',
  PythonRead: 'Inspecting...',
  ExecuteResearch: 'Running script...',
  BacktestStrategy: 'Backtesting...',
  ListActiveStrategies: 'Checking active strategies...',
  ActivateStrategy: 'Activating strategy...',
};

/** Labels for Spawn tool keyed by the `agent` argument value. */
const SPAWN_AGENT_LABELS: Record<string, string> = {
  indicator: 'Adjusting indicators...',
  research: 'Running analysis...',
  strategy: 'Working on strategy...',
  'web-explore': 'Searching the web...',
};

/**
 * Returns a human-friendly status label for a tool invocation.
 * For the Spawn tool, the label is derived from the `agent` argument.
 */
export function getToolLabel(toolName: string, args?: Record<string, unknown>): string {
  if (toolName === 'Spawn' && args?.agent) {
    return SPAWN_AGENT_LABELS[args.agent as string] ?? 'Working on it...';
  }
  return TOOL_LABELS[toolName] ?? `Running ${toolName}...`;
}
