JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
feat: 迁移工具简要描述目录与工具描述中文化
zepinzhangae9c4aa03257
diff --git a/jiuwenswarm/agents/harness/common/tools/audio_tools.py b/jiuwenswarm/agents/harness/common/tools/audio_tools.pyindex 339b9f3992..e20c8ef407 100644--- a/jiuwenswarm/agents/harness/common/tools/audio_tools.py+++ b/jiuwenswarm/agents/harness/common/tools/audio_tools.py@@ -146,10 +146,8 @@ def _build_missing_key_msg(tool_name: str) -> str:@tool(name="audio_question_answering",description=(- "Answer questions based on audio content. Use this tool when the user provides "- "an audio file and asks questions about the audio content, such as 'what is "- "discussed in this audio', 'how many speakers', or any analysis requiring "- "understanding of the audio."+ "基于音频内容回答问题。用户提供音频文件并询问内容时使用,"+ "例如「这段音频讲了什么」「有多少说话人」或任何需要理解音频的分析。"),)async def audio_question_answering(audio_path_or_url: str, question: str) -> str:@@ -224,7 +222,7 @@ async def audio_question_answering(audio_path_or_url: str, question: str) -> str@tool(name="audio_metadata",- description="Identify the metadata (name, author, year) of the given audio file using the ACRCloud API.",+ description="使用 ACRCloud API 识别给定音频文件的元数据(曲名、作者、年份)。",)async def audio_metadata(audio_path_or_url: str) -> str:cleanup = Falsediff --git a/jiuwenswarm/agents/harness/common/tools/command_tools.py b/jiuwenswarm/agents/harness/common/tools/command_tools.pyindex 64319e1e38..df86b55b96 100644--- a/jiuwenswarm/agents/harness/common/tools/command_tools.py+++ b/jiuwenswarm/agents/harness/common/tools/command_tools.py@@ -787,14 +787,13 @@ def _run_command_background(@tool(name="mcp_exec_command",description=(- "Execute simple cross-platform command-line command in project workspace. "- "Supports Windows cmd/PowerShell and macOS/Linux bash/sh. "- "Optional shell_type=auto|cmd|powershell|bash|sh. "- "Set background=True to run non-blocking (e.g. start a server); "- "returns immediately on success, error on failure. "- "Set max_output_chars=0 to disable output clipping. "- "Use a larger timeout_seconds for long-running commands. "- "Returns JSON: exit_code/stdout/stderr (blocking) or pid/status (background)."+ "在项目工作区执行跨平台命令行命令。"+ "支持 Windows cmd/PowerShell 与 macOS/Linux bash/sh。"+ "可选 shell_type=auto|cmd|powershell|bash|sh。"+ "设置 background=True 可非阻塞运行(如启动服务);成功立即返回,失败返回错误。"+ "设置 max_output_chars=0 可禁用输出截断。"+ "长时间命令可增大 timeout_seconds。"+ "返回 JSON:exit_code/stdout/stderr(阻塞)或 pid/status(后台)。"),)async def mcp_exec_command(diff --git a/jiuwenswarm/agents/harness/common/tools/cron/cron_tools.py b/jiuwenswarm/agents/harness/common/tools/cron/cron_tools.pyindex 26841a467f..ac0705013d 100644--- a/jiuwenswarm/agents/harness/common/tools/cron/cron_tools.py+++ b/jiuwenswarm/agents/harness/common/tools/cron/cron_tools.py@@ -532,13 +532,13 @@ class CronTools:return [make_tool(name="cron_list_jobs",- description="List all cron jobs.",+ description="列出所有定时任务。",input_params={"type": "object", "properties": {}},func=self.list_jobs,),make_tool(name="cron_get_job",- description="Get a cron job by id.",+ description="按 id 获取单个定时任务详情。",input_params={"type": "object","properties": {"job_id": {"type": "string"}},@@ -548,7 +548,7 @@ class CronTools:),make_tool(name="cron_create_job",- description="Create cron job.",+ description="创建定时任务。",input_params={"type": "object","properties": {@@ -601,9 +601,9 @@ class CronTools:make_tool(name="cron_update_job",description=(- "Update an existing cron job. Pass job_id and a patch dict with fields to update "- "(name, enabled, cron_expr, timezone, description, wake_offset_seconds, "- "targets, mode, model_name, project_dir, project_id)."+ "更新已有定时任务。传入 job_id 与包含待更新字段的 patch 字典"+ "(name、enabled、cron_expr、timezone、description、wake_offset_seconds、"+ "targets、mode、model_name、project_dir、project_id)。"),input_params={"type": "object",@@ -679,10 +679,9 @@ class CronTools:make_tool(name="cron_delete_job",description=(- "Delete cron job by id. "- "Note: jobs with protected=true (from cron_list_jobs) are managed by "- "system config and cannot be deleted here; tell the user to toggle the "- "corresponding config switch instead."+ "按 id 删除定时任务。"+ "注意:protected=true(见 cron_list_jobs)的任务由系统配置管理,"+ "不能在此删除;请告知用户去切换相应配置开关。"),input_params={"type": "object", "properties": {"job_id": {"type": "string"}}, "required": ["job_id"]},func=self.delete_job,@@ -690,9 +689,8 @@ class CronTools:make_tool(name="cron_toggle_job",description=(- "Enable or disable cron job. "- "Note: jobs with protected=true cannot be toggled here; they are driven by "- "system config."+ "启用或禁用定时任务。"+ "注意:protected=true 的任务不能在此启停;它们由系统配置驱动。"),input_params={"type": "object",@@ -706,7 +704,7 @@ class CronTools:),make_tool(name="cron_preview_job",- description="Preview next runs.",+ description="预览任务接下来若干次计划执行时间。",input_params={"type": "object","properties": {@@ -719,7 +717,7 @@ class CronTools:),make_tool(name="cron_run_now",- description="Trigger run now.",+ description="立即触发定时任务执行。",input_params={"type": "object", "properties": {"job_id": {"type": "string"}}, "required": ["job_id"]},func=self.run_now,),diff --git a/jiuwenswarm/agents/harness/common/tools/image_tools.py b/jiuwenswarm/agents/harness/common/tools/image_tools.pyindex 1198e6ffad..3143834a7f 100644--- a/jiuwenswarm/agents/harness/common/tools/image_tools.py+++ b/jiuwenswarm/agents/harness/common/tools/image_tools.py@@ -299,10 +299,8 @@ def _build_vqa_prompt(ocr_result: str, question: str) -> str:@tool(name="visual_question_answering",description=(- "Analyze and understand image content. Use this tool when the user provides "- "an image file path (e.g., .jpg, .png, .gif) or image URL and asks questions "- "about the image content, such as describing objects, scenes, text (OCR), "- "or people in the image."+ "分析并理解图片内容。用户提供图片文件路径(如 .jpg、.png、.gif)"+ "或图片 URL 并询问图片内容时使用,例如描述物体、场景、文字(OCR)或人物。"),)async def visual_question_answering(image_path_or_url: str, question: str) -> str:diff --git a/jiuwenswarm/agents/harness/common/tools/skill_toolkits.py b/jiuwenswarm/agents/harness/common/tools/skill_toolkits.pyindex 18553724cb..62798b679d 100644--- a/jiuwenswarm/agents/harness/common/tools/skill_toolkits.py+++ b/jiuwenswarm/agents/harness/common/tools/skill_toolkits.py@@ -722,10 +722,10 @@ class SkillToolkit:make_tool(name="search_skill",description=(- "Search installable skills from SkillNet, ClawHub, TeamSkillsHub, "- "and builtin directory. Use the returned identifier with install_skill "- "(SkillNet URL, ClawHub slug, TeamSkillsHub asset_id, or skill name "- "when source is builtin)."+ "从 SkillNet、ClawHub、TeamSkillsHub 及内置目录搜索可安装技能。"+ "将返回的 identifier 用于 install_skill"+ "(SkillNet URL、ClawHub slug、TeamSkillsHub asset_id,"+ "source 为 builtin 时则为技能名)。"),input_params={"type": "object",@@ -754,10 +754,9 @@ class SkillToolkit:make_tool(name="install_skill",description=(- "Install a skill. For skills found via search_skill, pass the identifier "- "and matching source. For builtin skills (not yet installed but available "- "locally), use source='builtin' and identifier=skill_name directly — "- "no prior search needed."+ "安装技能。对于通过 search_skill 找到的技能,传入其 identifier "+ "及匹配的 source。对于内置技能(本地已提供但尚未安装),"+ "直接使用 source='builtin' 并将 identifier 设为技能名——无需先搜索。"),input_params={"type": "object",@@ -786,7 +785,7 @@ class SkillToolkit:),make_tool(name="uninstall_skill",- description="Uninstall an installed skill by name.",+ description="按名称卸载已安装的技能。",input_params={"type": "object","properties": {diff --git a/jiuwenswarm/agents/harness/common/tools/task_tools.py b/jiuwenswarm/agents/harness/common/tools/task_tools.pyindex ef70f4a20f..32e2bfd12d 100644--- a/jiuwenswarm/agents/harness/common/tools/task_tools.py+++ b/jiuwenswarm/agents/harness/common/tools/task_tools.py@@ -283,8 +283,8 @@ def get_task_memory_service(cfg=None):@tool(name="experience_retrieve",description=(- "Retrieve relevant past memories and lessons for the current task. "- "Call this at the start of every task to check for prior experience."+ "检索与当前任务相关的历史记忆与经验教训。"+ "每个任务开始时都应调用,以检查是否有先例可参考。"),)async def experience_retrieve(@@ -380,16 +380,15 @@ def _format_trajectory_feedback(entry: Dict[str, Any]) -> str:@tool(name="experience_learn",description=(- "Record a key finding, rule, or insight from the current task and consolidate it into "- "reusable memory. Call this once before the final reply — it both saves the new entry "- "and summarizes everything learned so far. "- "Pass all fields inside a `params` object: "- "{content, section, when_to_use, title, description, query, label, tools_used}. "- "Include tools_used as a list of objects describing each tool call outcome this turn, "- "e.g. tools_used=[{\"tool\": \"web_search\", \"status\": \"success\"}, "+ "记录当前任务的关键发现、规则或洞察,并整合为可复用记忆。"+ "在最终回复前调用一次——既保存新条目,也汇总迄今所学。"+ "所有字段放在 params 对象内:"+ "{content, section, when_to_use, title, description, query, label, tools_used}。"+ "tools_used 为描述本轮各工具调用结果的对象列表,"+ "例如 tools_used=[{\"tool\": \"web_search\", \"status\": \"success\"}, ""{\"tool\": \"write_memory\", \"status\": \"failed\", \"error\": \"permission denied\", "- "\"note\": \"fell back to in-chat reply\"}]. "- "Always record failed tool calls — these are the most valuable learning signals."+ "\"note\": \"fell back to in-chat reply\"}]。"+ "务必记录失败的工具调用——这些是最有价值的学习信号。"),)async def experience_learn(params: TaskAddParams, matts: str = "none") -> Dict[str, Any]:@@ -570,8 +569,8 @@ async def experience_learn(params: TaskAddParams, matts: str = "none") -> Dict[s@tool(name="experience_clear",description=(- "Wipe all stored task memory from task-data.json. "- "ONLY call this when the user explicitly asks to clear all stored knowledge. Always confirm first."+ "清空 task-data.json 中存储的全部任务记忆。"+ "仅当用户明确要求清除所有已存储知识时调用,且须先确认。"),)async def experience_clear() -> Dict[str, Any]:diff --git a/jiuwenswarm/agents/harness/common/tools/video_tools.py b/jiuwenswarm/agents/harness/common/tools/video_tools.pyindex 2bb171904b..c587dffffb 100644--- a/jiuwenswarm/agents/harness/common/tools/video_tools.py+++ b/jiuwenswarm/agents/harness/common/tools/video_tools.py@@ -210,11 +210,9 @@ def _glm_video_understanding_sync(req: VideoUnderstandingRequest) -> str:@tool(name="video_understanding",description=(- "Analyze and understand video content. "- "Use this tool when the user provides a video file path (e.g., .mp4, .mov, .avi) "- "or video URL and asks questions about the video content, such as describing "- "scenes, actions, people, or objects in the video. "- "Input: query (question about the video) and video_path (local file path or HTTP/HTTPS URL)."+ "分析并理解视频内容。用户提供视频文件路径(如 .mp4、.mov、.avi)"+ "或视频 URL 并询问视频内容时使用,例如描述场景、动作、人物或物体。"+ "输入:query(关于视频的问题)和 video_path(本地文件路径或 HTTP/HTTPS URL)。"),)async def video_understanding(inputs: dict[str, Any], **kwargs) -> str:diff --git a/jiuwenswarm/agents/harness/common/tools/web_fetch_tools.py b/jiuwenswarm/agents/harness/common/tools/web_fetch_tools.pyindex 8b38691ffa..a749116bf2 100644--- a/jiuwenswarm/agents/harness/common/tools/web_fetch_tools.py+++ b/jiuwenswarm/agents/harness/common/tools/web_fetch_tools.py@@ -229,9 +229,9 @@ def _fetch_webpage_sync(url: str, timeout_seconds: int) -> dict[str, str | int]:@tool(name="mcp_fetch_webpage",description=(- "Fetch webpage text content from URL. Returns status/title/plain text content. "- "Set max_chars=0 to disable output clipping. "- "Use a larger timeout_seconds for slow websites."+ "抓取网页文本内容,返回状态码、标题和纯文本正文。"+ "设置 max_chars=0 可禁用输出截断。"+ "慢速网站可增大 timeout_seconds。"),)async def mcp_fetch_webpage(url: str, max_chars: int = 0, timeout_seconds: int = 30) -> str:diff --git a/jiuwenswarm/agents/harness/common/tools/wiki_tools.py b/jiuwenswarm/agents/harness/common/tools/wiki_tools.pyindex 88c8b2cd0a..74b2e01117 100644--- a/jiuwenswarm/agents/harness/common/tools/wiki_tools.py+++ b/jiuwenswarm/agents/harness/common/tools/wiki_tools.py@@ -403,11 +403,13 @@ def _resolve_workspace(workspace: str) -> Path:@tool(name="wiki_ingest",- description="Ingest a source file (PDF, TXT, MD) or a directory into the LLM Wiki."- " By default, identical files (by SHA-256) are skipped perfectly (deduplication)."- " Set `force=True` if the user explicitly asks to re-ingest, rebuild, or force the ingestion."- " The `workspace` parameter is the root folder where the `.llm_wiki` will be created."- " If the user specifies a target directory like 'wiki_lib' or 'bibliography', pass that exact path as `workspace`.",+ description=(+ "将源文件(PDF、TXT、MD)或目录导入 LLM Wiki。"+ "默认按 SHA-256 跳过相同文件(去重)。"+ "若用户明确要求重新导入、重建或强制导入,设置 force=True。"+ "workspace 为创建 .llm_wiki 的根目录;"+ "若用户指定 wiki_lib、bibliography 等目录,将该路径作为 workspace。"+ ),)async def wiki_ingest(source: str,@@ -461,9 +463,11 @@ async def wiki_ingest(@tool(name="wiki_query",- description="Query the LLM Wiki's compiled knowledge base directly via Natural Language."- " The `workspace` parameter is the folder containing the `.llm_wiki`."- " If the user specifies a target directory like 'wiki_lib' or 'bibliography', pass that exact path as `workspace`.",+ description=(+ "用自然语言直接查询 LLM Wiki 编译后的知识库。"+ "workspace 为包含 .llm_wiki 的文件夹;"+ "若用户指定 wiki_lib、bibliography 等目录,将该路径作为 workspace。"+ ),)async def wiki_query(query: str, workspace: str = "", sys_operation: Optional[SysOperation] = None@@ -494,9 +498,11 @@ async def wiki_query(@tool(name="wiki_lint",- description="Health-check and trigger automatic repairs of broken links, orphans, or anomalies in the LLM Wiki."- " The `workspace` parameter is the root folder containing the `.llm_wiki`."- " If the user specifies a target directory like 'wiki_lib' or 'bibliography', pass that exact path as `workspace`.",+ description=(+ "对 LLM Wiki 进行健康检查,并自动修复断链、孤立页或异常。"+ "workspace 为包含 .llm_wiki 的根目录;"+ "若用户指定 wiki_lib、bibliography 等目录,将该路径作为 workspace。"+ ),)async def wiki_lint(workspace: str = "", sys_operation: Optional[SysOperation] = None) -> str:"""Lints the LLM Wiki."""diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface.py b/jiuwenswarm/server/runtime/agent_adapter/interface.pyindex 803b95d5be..7e39e90fe9 100644--- a/jiuwenswarm/server/runtime/agent_adapter/interface.py+++ b/jiuwenswarm/server/runtime/agent_adapter/interface.py@@ -2857,6 +2857,18 @@ class JiuWenSwarm:def get_instance(self):return self._adapter._instance+ def get_registered_tools_catalog(self) -> list[dict[str, str]]:+ """枚举当前实例已注册工具(name / description / short_description)。"""+ from jiuwenswarm.server.runtime.tool_catalog import get_registered_tools_catalog++ instance = self.get_instance()+ if instance is None:+ return []+ ability_manager = getattr(instance, "ability_manager", None)+ if ability_manager is None and callable(getattr(instance, "list", None)):+ ability_manager = instance+ return get_registered_tools_catalog(ability_manager)+async def ensure_instance(self):"""Return the adapter's DeepAgent, building the root one on first use.diff --git a/jiuwenswarm/server/runtime/tenant_agent_pool.py b/jiuwenswarm/server/runtime/tenant_agent_pool.pyindex a31b782d82..4836991d1f 100644--- a/jiuwenswarm/server/runtime/tenant_agent_pool.py+++ b/jiuwenswarm/server/runtime/tenant_agent_pool.py@@ -48,6 +48,11 @@ class TenantAgentPool:logger.info("[TenantAgentPool] Created singleton instance")return cls._instance+ @classmethod+ def peek_instance(cls) -> "TenantAgentPool | None":+ """返回已初始化的单例;若尚未创建则返回 None(不触发构造)。"""+ return cls._instance+@classmethoddef reset_instance(cls) -> None:"""重置单例(仅用于测试)."""diff --git a/jiuwenswarm/server/runtime/tool_catalog.py b/jiuwenswarm/server/runtime/tool_catalog.pynew file mode 100644index 0000000000..e05ff79251--- /dev/null+++ b/jiuwenswarm/server/runtime/tool_catalog.py@@ -0,0 +1,167 @@+# Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.++"""Agent 工具目录(内部):简短描述(面向人/UI)与 ToolCard.description(面向模型)分离。++供 AgentServer、权限编排等模块直接调用,不对外暴露独立 RPC。+"""++from __future__ import annotations++import logging+import re+from typing import Any++from openjiuwen.core.foundation.tool import ToolCard++logger = logging.getLogger(__name__)++_SHORT_DESCRIPTION_MAX_LEN = 100+_CJK_RE = re.compile(r"[\u4e00-\u9fff]")+_FALLBACK_UNKNOWN_TEMPLATE = "工具「{name}」(暂无简短说明)"++__all__ = [+ "get_registered_tools_catalog",+ "resolve_short_description",+ "short_description_from_description",+ "tool_catalog_entry_from_card",+]+++def _is_sentence_terminal(index: int, char: str, text: str) -> bool:+ """判断 index 处字符是否为句末标点(排除 schema 可选标记如 description?、id?)。"""+ if char in "。!?":+ return True+ if char in "!?":+ if index > 0 and text[index - 1].isalnum():+ if index + 1 < len(text) and text[index + 1] in ",;)]}":+ return False+ return True+ if char != ".":+ return False+ if index + 1 >= len(text):+ return True+ nxt = text[index + 1]+ if nxt in " \t":+ return True+ # window.Provide / offloaded.The — 句号后紧跟大写新句(无空格)也视为句末;chat.delta 等仍不切分+ if nxt.isupper():+ return True+ return False+++def _is_meaningful_english_sentence(text: str) -> bool:+ """过滤 JSON/schema 碎片(如 ", id?"),仅保留像自然语言的英文句。"""+ normalized = str(text or "").strip()+ if not normalized or _has_cjk(normalized):+ return False+ if not re.search(r"[A-Za-z]{2,}", normalized):+ return False+ if len(normalized) < 8:+ return False+ return bool(re.search(r"[A-Za-z]{2,}\s+[A-Za-z]", normalized))+++def _split_sentences(text: str) -> list[str]:+ """按句末标点切分(支持中英文)。"""+ normalized = " ".join(str(text or "").split())+ if not normalized:+ return []+ sentences: list[str] = []+ start = 0+ for index, char in enumerate(normalized):+ if not _is_sentence_terminal(index, char, normalized):+ continue+ part = normalized[start:index + 1].strip()+ if part:+ sentences.append(part)+ start = index + 1+ while start < len(normalized) and normalized[start] in " \t":+ start += 1+ tail = normalized[start:].strip()+ if tail:+ sentences.append(tail)+ return sentences+++def _has_cjk(text: str) -> bool:+ return bool(_CJK_RE.search(text))+++def short_description_from_description(description: str) -> str:+ """从 ToolCard.description 提取 short_description:中英文各取第一句,再截断至 100 字。"""+ desc = str(description or "").strip()+ if not desc:+ return ""+ paragraphs = [part.strip() for part in re.split(r"\n+", desc) if part.strip()]+ if not paragraphs:+ return ""++ zh_sentence: str | None = None+ en_sentence: str | None = None+ for paragraph in paragraphs:+ for sentence in _split_sentences(paragraph):+ if _has_cjk(sentence):+ if zh_sentence is None:+ zh_sentence = sentence+ elif en_sentence is None and _is_meaningful_english_sentence(sentence):+ en_sentence = sentence+ if zh_sentence and en_sentence:+ break++ sentences = [part for part in (zh_sentence, en_sentence) if part]+ if not sentences:+ first = _split_sentences(paragraphs[0])+ sentences = [first[0]] if first else [paragraphs[0]]++ joined = " ".join(sentences)+ return _truncate_short_description(joined)+++def _truncate_short_description(text: str, max_len: int = _SHORT_DESCRIPTION_MAX_LEN) -> str:+ normalized = " ".join(str(text or "").split())+ if len(normalized) <= max_len:+ return normalized+ return f"{normalized[: max_len - 3].rstrip()}..."+++def resolve_short_description(tool_name: str, model_description: str = "") -> str:+ name = str(tool_name or "").strip()+ extracted = short_description_from_description(model_description)+ if extracted:+ return extracted+ if name:+ return _truncate_short_description(_FALLBACK_UNKNOWN_TEMPLATE.format(name=name))+ return _truncate_short_description("未知工具。")+++def tool_catalog_entry_from_card(card: ToolCard) -> dict[str, str]:+ name = str(getattr(card, "name", "") or "").strip()+ description = str(getattr(card, "description", "") or "")+ short = resolve_short_description(name, description)+ entry: dict[str, str] = {+ "name": name,+ "description": description,+ "short_description": short,+ }+ tool_id = str(getattr(card, "id", "") or "").strip()+ if tool_id:+ entry["id"] = tool_id+ return entry+++def get_registered_tools_catalog(ability_manager: Any) -> list[dict[str, str]]:+ """枚举 ability_manager 中已注册工具(name / description / short_description)。"""+ if ability_manager is None:+ return []+ list_fn = getattr(ability_manager, "list", None)+ if not callable(list_fn):+ return []+ by_name: dict[str, dict[str, str]] = {}+ for item in list_fn() or []:+ if not isinstance(item, ToolCard):+ continue+ entry = tool_catalog_entry_from_card(item)+ name = entry.get("name", "")+ if name:+ by_name[name] = entry+ return [by_name[k] for k in sorted(by_name)]\ No newline at end of filediff --git a/tests/unit_tests/agentserver/test_skill_toolkits.py b/tests/unit_tests/agentserver/test_skill_toolkits.pyindex b4d7d0e7ca..160444720a 100644--- a/tests/unit_tests/agentserver/test_skill_toolkits.py+++ b/tests/unit_tests/agentserver/test_skill_toolkits.py@@ -276,6 +276,17 @@ def test_install_skill_builtin_source_routes_to_handle_skills_install_builtin(tmassert (user_skills_dir / "my-builtin-skill").is_dir()+def test_skill_tool_descriptions_are_chinese(tmp_path):+ manager = SkillManager(workspace_dir=str(tmp_path / "workspace"))+ toolkit = SkillToolkit(manager)++ tools = {t.card.name: t.card.description for t in toolkit.get_tools()}++ assert "从 SkillNet、ClawHub、TeamSkillsHub 及内置目录搜索可安装技能。" in tools["search_skill"]+ assert "安装技能。" in tools["install_skill"]+ assert tools["uninstall_skill"] == "按名称卸载已安装的技能。"++def test_format_skills_for_llm_distinguishes_install_status():skills = [{"name": "installed-skill", "description": "already there", "installed": True, "source": "local"},diff --git a/tests/unit_tests/agentserver/test_tool_catalog.py b/tests/unit_tests/agentserver/test_tool_catalog.pynew file mode 100644index 0000000000..ecba2b73e2--- /dev/null+++ b/tests/unit_tests/agentserver/test_tool_catalog.py@@ -0,0 +1,120 @@+# Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.++from __future__ import annotations++from unittest.mock import patch++import pytest+from openjiuwen.core.foundation.tool import ToolCard++from jiuwenswarm.server.runtime.tool_catalog import (+ get_registered_tools_catalog,+ resolve_short_description,+ short_description_from_description,+ tool_catalog_entry_from_card,+)+++class _FakeAbilityManager:+ def __init__(self, cards: list[ToolCard]) -> None:+ self._cards = cards++ def list(self) -> list[ToolCard]:+ return list(self._cards)+++def test_short_description_from_description_first_sentence_english() -> None:+ text = short_description_from_description("Fetch data from an API.\nMore details.")+ assert text == "Fetch data from an API."+++def test_short_description_from_description_bilingual_paragraphs() -> None:+ text = short_description_from_description(+ "在会话工作目录下执行 Shell 命令。更多说明在此。\n"+ "Execute commands in the session workspace. More details here."+ )+ assert text == "在会话工作目录下执行 Shell 命令。 Execute commands in the session workspace."+++def test_resolve_short_description_uses_description_not_tool_name() -> None:+ short = resolve_short_description("bash", "Long model-facing description for bash execution.")+ assert short == "Long model-facing description for bash execution."+++def test_tool_catalog_entry_uses_description_not_cached_properties() -> None:+ long_short = "向用户展示一组带选项的结构化问题" * 5+ card = ToolCard(+ name="ask_user_question",+ description="向用户展示选项并等待选择。Show options to the user.",+ properties={"short_description": long_short},+ )+ entry = tool_catalog_entry_from_card(card)+ assert entry["short_description"] == "向用户展示选项并等待选择。 Show options to the user."+ assert len(entry["short_description"]) <= 100+++ASK_USER_QUESTION_DESCRIPTION = (+ "向用户展示一组带选项的结构化问题(可多题),并阻塞等待用户选择。仅当引导/交互已开启时推送选择 UI;"+ "未开启时不推送 chat.delta(由对话流展示),由用户在下一条消息中自由回复。"+ "questions 为 JSON 数组,每项含 question、options[{label, description?, id?}]、可选 header、multi_select;"+ "可选 preview{text,title?,format?,editable?,outline_ref?,meta?} 用于大纲等 Markdown 审阅"+ "(将注入 outline_confirm / outline_use_edited 选项)。"+)+++RELOAD_CONTEXT_DESCRIPTION = (+ "Retrieve messages that were previously offloaded from the context window."+ "Provide the exact handle and storage type returned when the content was offloaded;"+ "the tool will fetch the complete original message list and inject it back into the conversation, "+ "allowing the model to see the full text as if it had never been removed."+)+++def test_short_description_splits_period_before_uppercase_without_space() -> None:+ short = short_description_from_description(RELOAD_CONTEXT_DESCRIPTION)+ assert short == "Retrieve messages that were previously offloaded from the context window."+ assert "Provide" not in short+ assert not short.endswith("...")+++def test_short_description_ignores_schema_optional_markers() -> None:+ short = short_description_from_description(ASK_USER_QUESTION_DESCRIPTION)+ assert short == "向用户展示一组带选项的结构化问题(可多题),并阻塞等待用户选择。"+ assert ", id?" not in short+++def test_resolve_short_description_truncates_over_100_chars() -> None:+ long_line = "A" * 200+ short = resolve_short_description("unknown_tool_x", long_line)+ assert len(short) == 100+ assert short.endswith("...")+++def test_get_registered_tools_catalog_dedupes_by_name() -> None:+ mgr = _FakeAbilityManager(+ [+ ToolCard(name="bash", description="a"),+ ToolCard(name="bash", description="b"),+ ToolCard(name="read_file", description="read"),+ ],+ )+ tools = get_registered_tools_catalog(mgr)+ assert len(tools) == 2+ names = [t["name"] for t in tools]+ assert names == ["bash", "read_file"]+++def test_jiuwenswarm_get_registered_tools_catalog_member() -> None:+ from jiuwenswarm.server.runtime.agent_adapter.interface import JiuWenSwarm++ class _DeepInstance:+ ability_manager = _FakeAbilityManager(+ [ToolCard(name="grep", description="Search in files.")],+ )++ swarm = JiuWenSwarm()+ with patch.object(swarm, "get_instance", return_value=_DeepInstance()):+ tools = swarm.get_registered_tools_catalog()+ assert len(tools) == 1+ assert tools[0]["name"] == "grep"+ assert tools[0]["short_description"] == "Search in files."\ No newline at end of file