mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
* feat: Refactor astrbot builtin tool management - Introduced a new registry for builtin tools to streamline their management. - Added `SendMessageToUserTool`, `KnowledgeBaseQueryTool`, and various web search tools as builtin tools. - Updated `FunctionToolManager` to cache and retrieve builtin tools efficiently. - Modified `CronJobManager` to utilize the new `SendMessageToUserTool`. - Enhanced the dashboard to display readonly status for builtin tools and prevent toggling their state. - Added tests for builtin tool injection and retrieval to ensure proper functionality. * fix: escape file path in shell command to prevent injection vulnerabilities
15 lines
571 B
Python
15 lines
571 B
Python
from astrbot.core import sp
|
|
from astrbot.core.provider.func_tool_manager import FunctionToolManager
|
|
from astrbot.core.tools.message_tools import SendMessageToUserTool
|
|
|
|
|
|
def test_get_builtin_tool_by_class_returns_cached_instance():
|
|
manager = FunctionToolManager()
|
|
|
|
tool_by_class = manager.get_builtin_tool(SendMessageToUserTool)
|
|
tool_by_name = manager.get_builtin_tool("send_message_to_user")
|
|
|
|
assert tool_by_class is tool_by_name
|
|
assert manager.get_func("send_message_to_user") is tool_by_class
|
|
assert tool_by_class.name == "send_message_to_user"
|