Yash030/claude-code-proxy
2
1"""CLI event types and status-line mapping for transcript / UI updates."""2 3from collections.abc import Callable4from typing import Any5 6# Status message prefixes used to filter our own messages (ignore echo)7STATUS_MESSAGE_PREFIXES = (8 "โณ",9 "๐ญ",10 "๐ง",11 "โ
",12 "โ",13 "๐",14 "๐ค",15 "๐",16 "๐",17 "๐",18)19 20# Event types that update the transcript (frozenset for O(1) membership)21TRANSCRIPT_EVENT_TYPES = frozenset(22 {23 "thinking_start",24 "thinking_delta",25 "thinking_chunk",26 "thinking_stop",27 "text_start",28 "text_delta",29 "text_chunk",30 "text_stop",31 "tool_use_start",32 "tool_use_delta",33 "tool_use_stop",34 "tool_use",35 "tool_result",36 "block_stop",37 "error",38 }39)40 41# Event type -> (emoji, label) for status updates (O(1) lookup)42_EVENT_STATUS_MAP: dict[str, tuple[str, str]] = {43 "thinking_start": ("๐ง ", "Claude is thinking..."),44 "thinking_delta": ("๐ง ", "Claude is thinking..."),45 "thinking_chunk": ("๐ง ", "Claude is thinking..."),46 "text_start": ("๐ง ", "Claude is working..."),47 "text_delta": ("๐ง ", "Claude is working..."),48 "text_chunk": ("๐ง ", "Claude is working..."),49 "tool_result": ("โณ", "Executing tools..."),50}51 52 53def get_status_for_event(54 ptype: str,55 parsed: dict[str, Any],56 format_status_fn: Callable[..., str],57) -> str | None:58 """Return status string for event type, or None if no status update needed."""59 entry = _EVENT_STATUS_MAP.get(ptype)60 if entry is not None:61 emoji, label = entry62 return format_status_fn(emoji, label)63 if ptype in ("tool_use_start", "tool_use_delta", "tool_use"):64 if parsed.get("name") == "Task":65 return format_status_fn("๐ค", "Subagent working...")66 return format_status_fn("โณ", "Executing tools...")67 return None68 