- 新增 server/chat_flow_task_support.inject_runtime_user_message 作为唯一入口, 统一处理 add_conversation + messages.insert + sender(user_message) 三件事 - 子智能体 / 后台 run_command / runtime_guidance / mode notice 全部走该入口, role 一律 user,inline 仅作 metadata 标记,不再复用 system role 表达语义 - inline poll 移出 tool 执行循环,改为整轮 tool 完成后批量注入, 避免在 assistant.tool_calls 与 tool 序列之间插入 user 导致 API 报错 - 删除 _insert_completion_notice_message / _record_sub_agent_message 以及 build_messages 中 system→user 的回转分支 - 移除已废弃的 wait_sub_agent 工具残留(后端注册、前端图标/动画、 prompts、SKILL 文档;保留 sleep 的 wait_sub_agent_ids 参数) - 前端取消对 is_auto_generated/auto_message_type 的过滤, 让运行期注入的 user 消息在历史和实时推送中正常渲染 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
92 lines
2.2 KiB
Python
92 lines
2.2 KiB
Python
"""工具类别配置。
|
|
|
|
提供前端和终端公用的工具分组定义,方便按类别控制启用状态。
|
|
"""
|
|
|
|
from typing import Dict, List
|
|
|
|
|
|
class ToolCategory:
|
|
"""工具类别的结构化定义。"""
|
|
|
|
def __init__(
|
|
self,
|
|
label: str,
|
|
tools: List[str],
|
|
default_enabled: bool = True,
|
|
silent_when_disabled: bool = False,
|
|
):
|
|
self.label = label
|
|
self.tools = tools
|
|
self.default_enabled = default_enabled
|
|
self.silent_when_disabled = silent_when_disabled
|
|
|
|
|
|
TOOL_CATEGORIES: Dict[str, ToolCategory] = {
|
|
"network": ToolCategory(
|
|
label="网络检索",
|
|
tools=["web_search", "extract_webpage", "save_webpage"],
|
|
),
|
|
"mcp": ToolCategory(
|
|
label="MCP 工具",
|
|
tools=["list_mcp_servers"],
|
|
),
|
|
"file_edit": ToolCategory(
|
|
label="文件编辑",
|
|
tools=[
|
|
"create_file",
|
|
"write_file",
|
|
"edit_file",
|
|
"delete_file",
|
|
"rename_file",
|
|
"create_folder",
|
|
],
|
|
),
|
|
"read_focus": ToolCategory(
|
|
label="阅读聚焦",
|
|
tools=[
|
|
"read_skill",
|
|
"read_file",
|
|
"vlm_analyze",
|
|
"ocr_image",
|
|
"view_image",
|
|
],
|
|
),
|
|
"terminal_realtime": ToolCategory(
|
|
label="实时终端",
|
|
tools=[
|
|
"terminal_session",
|
|
"terminal_input",
|
|
"terminal_snapshot",
|
|
"sleep",
|
|
],
|
|
),
|
|
"terminal_command": ToolCategory(
|
|
label="终端指令",
|
|
tools=["run_command", "run_python"],
|
|
),
|
|
"memory": ToolCategory(
|
|
label="记忆",
|
|
tools=["update_memory"],
|
|
),
|
|
"todo": ToolCategory(
|
|
label="待办事项",
|
|
tools=["todo_create", "todo_update_task"],
|
|
),
|
|
"sub_agent": ToolCategory(
|
|
label="子智能体",
|
|
tools=["create_sub_agent", "close_sub_agent"],
|
|
),
|
|
"easter_egg": ToolCategory(
|
|
label="彩蛋实验",
|
|
tools=["trigger_easter_egg"],
|
|
default_enabled=False,
|
|
silent_when_disabled=True,
|
|
),
|
|
"personalization": ToolCategory(
|
|
label="个性化设置",
|
|
tools=["manage_personalization"],
|
|
default_enabled=True,
|
|
),
|
|
}
|