from __future__ import annotations

import re

ERROR_KEYWORDS = ("error:", "traceback", "failed", "exception", "permission denied")
TOOL_OBS_LAST_KEY = "_tool_observability_last"
SESSION_LANG_KEY = "_session_lang"
CJK_CHAR_RE = re.compile(r"[\u3400-\u9FFF]")
LATIN_CHAR_RE = re.compile(r"[A-Za-z]")
TOOL_HINT_LABELS = {
    "read_file": ("读取文件", "Read File"),
    "write_file": ("写入文件", "Write File"),
    "edit_file": ("编辑文件", "Edit File"),
    "list_dir": ("查看文件夹", "List Folder"),
    "exec": ("执行命令", "Run Command"),
    "coding_agent": ("代码代理", "Coding Agent"),
    "coding_agent_details": ("代理详情", "Agent Run Details"),
    "opencode": ("OpenCode 代理", "OpenCode Agent"),
    "opencode_details": ("OpenCode 详情", "OpenCode Details"),
    "codex": ("Codex 代理", "Codex Agent"),
    "codex_details": ("Codex 详情", "Codex Details"),
    "claudecode": ("Claude Code 代理", "Claude Code Agent"),
    "claudecode_details": ("Claude Code 详情", "Claude Code Details"),
    "generate_image": ("生成图片", "Create Image"),
    "web_search": ("搜索网页", "Search Web"),
    "web_fetch": ("打开网页", "Fetch Web Page"),
    "agent_browser": ("操作浏览器", "Control Browser"),
    "send_to_session": ("发到会话", "Send To Session"),
    "runtime_diagnostics": ("查看诊断", "Inspect Runtime"),
    "create_plan": ("创建计划", "Create Plan"),
    "update_plan_step": ("更新计划", "Update Plan"),
    "clear_plan": ("清空计划", "Clear Plan"),
    "spawn": ("委派任务", "Delegate Task"),
    "check_tasks": ("查看任务进度", "Check Task Progress"),
    "cancel_task": ("取消任务", "Cancel Task"),
    "check_tasks_json": ("任务进度 JSON", "Task Progress JSON"),
    "remember": ("保存记忆", "Save Memory"),
    "forget": ("删除记忆", "Delete Memory"),
    "update_memory": ("更新记忆", "Update Memory"),
    "cron": ("安排任务", "Schedule Task"),
    "screenshot": ("截图", "Take Screenshot"),
    "click": ("点击屏幕", "Click Screen"),
    "type_text": ("输入文字", "Type Text"),
    "key_press": ("按下按键", "Press Key"),
    "scroll": ("滚动页面", "Scroll Screen"),
    "drag": ("拖动光标", "Drag Cursor"),
    "get_screen_info": ("查看屏幕信息", "Screen Info"),
}
TOOL_HINT_ICONS = {
    "read_file": "📄",
    "write_file": "📝",
    "edit_file": "📝",
    "list_dir": "📁",
    "exec": "💻",
    "coding_agent": "🤖",
    "coding_agent_details": "🤖",
    "opencode": "🤖",
    "opencode_details": "🤖",
    "codex": "🤖",
    "codex_details": "🤖",
    "claudecode": "🤖",
    "claudecode_details": "🤖",
    "generate_image": "🖼️",
    "web_search": "🔎",
    "web_fetch": "🌐",
    "agent_browser": "🌐",
    "send_to_session": "📨",
    "runtime_diagnostics": "🩺",
    "create_plan": "🗂️",
    "update_plan_step": "🗂️",
    "clear_plan": "🗂️",
    "spawn": "🤖",
    "check_tasks": "📋",
    "cancel_task": "🛑",
    "check_tasks_json": "📋",
    "remember": "🧠",
    "forget": "🧠",
    "update_memory": "🧠",
    "cron": "⏰",
    "screenshot": "📸",
    "click": "🖱️",
    "type_text": "⌨️",
    "key_press": "⌨️",
    "scroll": "🖱️",
    "drag": "🖱️",
    "get_screen_info": "🖥️",
}
TOOL_HINT_CRON_ACTIONS = {
    "add": ("新增", "add"),
    "list": ("查看", "list"),
    "remove": ("删除", "remove"),
}
GREETING_WORDS = frozenset(
    {
        "hi",
        "hello",
        "hey",
        "yo",
        "你好",
        "您好",
        "在吗",
        "忙吗",
        "嗯",
        "ok",
        "好",
        "好的",
        "哈喽",
        "嘿",
        "哈",
        "嗨",
    }
)
