Team Ai
Apppublic

Yash030/claude-code-proxy

sourceHugging Faceupdated 5mo agoView on Hugging Face
2likes
cli_event_constants.py68 linesDownload Raw Back to messaging
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