from __future__ import annotations

from bao.agent._tool_catalog_common import BuiltinToolFamily, iconoir

BUILTIN_TOOL_FAMILIES: tuple[BuiltinToolFamily, ...] = (
    BuiltinToolFamily(
        id="filesystem",
        name="Local Files",
        name_zh="本地文件",
        bundle="core",
        summary="Read, write, edit, and list workspace files.",
        summary_zh="读取、写入、编辑并列出工作区文件。",
        detail="These tools are the core local file surface for inspecting and changing project files.",
        detail_zh="这是 Bao 的核心本地文件能力，用于查看、创建和修改项目文件。",
        capabilities=("Filesystem", "Workspace", "Authoring"),
        included_tools=("read_file", "write_file", "edit_file", "list_dir"),
        icon_source=iconoir("book-stack"),
    ),
    BuiltinToolFamily(
        id="exec",
        name="Terminal Exec",
        name_zh="终端执行",
        bundle="core",
        summary="Run shell commands on the runtime host with sandbox controls.",
        summary_zh="在运行主机上执行命令，并受超时与沙箱策略约束。",
        detail="Exec is the bridge to local shell workflows. Its scope is shaped by timeout, sandbox mode, and workspace restrictions.",
        detail_zh="Exec 是本机命令桥。你可以在这里控制超时、PATH 追加、沙箱模式与工作区边界。",
        capabilities=("Shell", "Local host", "Diagnostics"),
        included_tools=("exec",),
        icon_source=iconoir("computer"),
        form_kind="exec",
        config_paths=(
            "tools.exec.timeout",
            "tools.exec.pathAppend",
            "tools.exec.sandboxMode",
            "tools.restrictToWorkspace",
        ),
    ),
    BuiltinToolFamily(
        id="coding",
        name="Coding Agent",
        name_zh="编程代理",
        bundle="code",
        summary="Delegate multi-file coding and debugging to external coding backends.",
        summary_zh="把多文件实现、调试与重构委派给已安装的编程后端。",
        detail="Coding Agent routes heavier implementation work to installed coding backends such as OpenCode, Codex, or Claude Code.",
        detail_zh="编程代理把高复杂度实现委派给 OpenCode、Codex 或 Claude Code 等后端；这里主要展示当前可用后端。",
        capabilities=("Codegen", "Refactor", "Debug"),
        included_tools=("coding_agent", "coding_agent_details"),
        icon_source="../resources/icons/sidebar-subagent.svg",
        form_kind="coding",
    ),
    BuiltinToolFamily(
        id="web",
        name="Web Retrieval",
        name_zh="网页检索",
        bundle="web",
        summary="Search the web, fetch URLs, and automate browser flows.",
        summary_zh="搜索网页、抓取 URL，并在需要时驱动浏览器。",
        detail="This family combines web search, direct fetch, and browser automation. Search quality depends on configured providers.",
        detail_zh="网页检索把搜索 provider、URL 抓取和浏览器操作聚合在同一工具族里；搜索质量取决于你配置的 provider key。",
        capabilities=("Search", "Fetch", "Browser"),
        included_tools=("web_search", "web_fetch", "agent_browser"),
        icon_source=iconoir("page-search"),
        form_kind="web",
        config_paths=(
            "tools.web.search.provider",
            "tools.web.search.tavilyApiKey",
            "tools.web.search.braveApiKey",
            "tools.web.search.exaApiKey",
            "tools.web.search.maxResults",
            "tools.web.browser.enabled",
        ),
    ),
    BuiltinToolFamily(
        id="embedding",
        name="Embeddings",
        name_zh="向量嵌入",
        bundle="core",
        summary="Provide semantic embeddings for memory and retrieval workflows.",
        summary_zh="为语义检索与长期记忆提供向量嵌入。",
        detail="Embedding settings back semantic search and long-term memory quality. They stay dormant until a model and API key are configured.",
        detail_zh="Embedding 设置会直接影响语义检索与记忆质量。只有模型与 API Key 都配置好时，它才会真正启用。",
        capabilities=("Embeddings", "Retrieval", "Memory"),
        included_tools=("embedding_runtime",),
        icon_source=iconoir("database-settings"),
        form_kind="embedding",
        config_paths=(
            "tools.embedding.model",
            "tools.embedding.apiKey",
            "tools.embedding.baseUrl",
            "tools.embedding.dim",
        ),
    ),
    BuiltinToolFamily(
        id="image_generation",
        name="Image Generation",
        name_zh="图像生成",
        bundle="core",
        summary="Create images from prompts when an image model is configured.",
        summary_zh="配置图像生成模型后即可从提示词产图。",
        detail="Image generation is optional and only becomes active once a provider key is configured.",
        detail_zh="图像生成是可选能力。配置好 API Key 之后，Bao 才会把它当作可调用工具。",
        capabilities=("Image", "Creative", "Generation"),
        included_tools=("image_generation",),
        icon_source=iconoir("circle-spark"),
        form_kind="image_generation",
        config_paths=(
            "tools.imageGeneration.apiKey",
            "tools.imageGeneration.model",
            "tools.imageGeneration.baseUrl",
        ),
    ),
    BuiltinToolFamily(
        id="memory",
        name="Memory Controls",
        name_zh="记忆控制",
        bundle="core",
        summary="Write, update, and remove explicit long-term memory entries.",
        summary_zh="显式写入、更新和删除长期记忆。",
        detail="These tools let Bao persist explicit facts into the long-term memory system without opening the memory workspace manually.",
        detail_zh="这组工具负责显式修改长期记忆；更细的查看与整理仍建议在记忆工作台完成。",
        capabilities=("Memory", "Persistence", "Curation"),
        included_tools=("remember", "forget", "update_memory"),
        icon_source="../resources/icons/sidebar-memory.svg",
    ),
    BuiltinToolFamily(
        id="planning_subagents",
        name="Planning and Subagents",
        name_zh="计划与子代理",
        bundle="core",
        summary="Create plans and delegate longer tasks to subagents.",
        summary_zh="管理计划步骤，并把长任务委派给子代理。",
        detail="This family covers linear planning, background subagent work, progress inspection, and task cancellation.",
        detail_zh="计划与子代理属于执行编排层：创建计划、推进步骤、委派任务、追踪进度和取消任务都在这里。",
        capabilities=("Plan", "Delegate", "Track"),
        included_tools=(
            "create_plan",
            "update_plan_step",
            "clear_plan",
            "spawn",
            "check_tasks",
            "cancel_task",
            "check_tasks_json",
        ),
        icon_source="../resources/icons/sidebar-subagent.svg",
    ),
    BuiltinToolFamily(
        id="session_handoff",
        name="Session Handoff and Diagnostics",
        name_zh="会话协作与诊断",
        bundle="core",
        summary="Resolve other sessions, hand work off across sessions, and inspect runtime diagnostics.",
        summary_zh="解析其他会话、跨会话协作，并查看运行诊断。",
        detail="This family covers session discovery, cross-session handoff, and structured internal diagnostics for framework-side failures.",
        detail_zh="这组工具负责会话查找、跨会话协作，以及框架内部诊断；直接外发属于 runtime 内部能力，不再单独暴露。",
        capabilities=("Session", "Handoff", "Diagnostics"),
        included_tools=(
            "session_default",
            "session_lookup",
            "session_recent",
            "session_resolve",
            "send_to_session",
            "runtime_diagnostics",
        ),
        icon_source=iconoir("message-alert"),
    ),
    BuiltinToolFamily(
        id="cron",
        name="Scheduled Tasks",
        name_zh="定时任务",
        bundle="core",
        summary="Schedule reminders and recurring workflows.",
        summary_zh="配置提醒和周期任务。",
        detail="Cron is active when the runtime includes the cron service and lets Bao manage scheduled reminders and routines.",
        detail_zh="Cron 只有在运行时挂上 cron service 时才会真正可用；这里先展示它的职责边界。",
        capabilities=("Schedule", "Reminder", "Automation"),
        included_tools=("cron",),
        icon_source=iconoir("calendar-rotate"),
    ),
    BuiltinToolFamily(
        id="desktop",
        name="Desktop Automation",
        name_zh="桌面自动化",
        bundle="desktop",
        summary="See and control the local desktop with screenshots and input actions.",
        summary_zh="截图、点击、输入并控制本地桌面。",
        detail="Desktop automation is powerful and high-risk. It should stay explicit, visible, and easy to disable.",
        detail_zh="桌面自动化是高权限能力，所以它的控制面应当清晰、直接、容易关闭。",
        capabilities=("Desktop", "Input", "Visual"),
        included_tools=(
            "screenshot",
            "click",
            "type_text",
            "key_press",
            "scroll",
            "drag",
            "get_screen_info",
        ),
        icon_source=iconoir("computer"),
        form_kind="desktop",
        config_paths=("tools.desktop.enabled",),
    ),
)
