1010from .app_management .killer import kill_application , list_running_applications
1111from .app_management .launcher import launch_application
1212from .app_management .scanner import scan_installed_applications
13- from .tools import get_system_status , set_volume
13+ from .tools import set_volume
1414
1515logger = get_logger (__name__ )
1616
@@ -34,9 +34,6 @@ def init_tools(self, add_tool, PropertyList, Property, PropertyType):
3434 try :
3535 logger .info ("[SystemManager] 开始注册系统工具" )
3636
37- # 注册获取设备状态工具
38- self ._register_device_status_tool (add_tool , PropertyList )
39-
4037 # 注册音量控制工具
4138 self ._register_volume_control_tool (
4239 add_tool , PropertyList , Property , PropertyType
@@ -64,27 +61,6 @@ def init_tools(self, add_tool, PropertyList, Property, PropertyType):
6461 logger .error (f"[SystemManager] 系统工具注册失败: { e } " , exc_info = True )
6562 raise
6663
67- def _register_device_status_tool (self , add_tool , PropertyList ):
68- """
69- 注册设备状态查询工具.
70- """
71- add_tool (
72- (
73- "self.get_device_status" ,
74- "Provides comprehensive real-time system information including "
75- "OS details, CPU usage, memory status, disk usage, battery info, "
76- "audio speaker volume and settings, and application state.\n "
77- "Use this tool for: \n "
78- "1. Answering questions about current system condition\n "
79- "2. Getting detailed hardware and software status\n "
80- "3. Checking current audio volume level and mute status\n "
81- "4. As the first step before controlling device settings" ,
82- PropertyList (),
83- get_system_status ,
84- )
85- )
86- logger .debug ("[SystemManager] 注册设备状态工具成功" )
87-
8864 def _register_volume_control_tool (
8965 self , add_tool , PropertyList , Property , PropertyType
9066 ):
@@ -97,22 +73,12 @@ def _register_volume_control_tool(
9773 add_tool (
9874 (
9975 "self.audio_speaker.set_volume" ,
100- "【音量控制】当用户提到:调音量、声音大小、音量设为、调大声音、调小声音、声音太大/太小、"
101- "静音、取消静音、增大音量、降低音量、把声音、音量调整、声音调节 时调用本工具。\n "
102- "功能:设置系统扬声器音量到绝对值(0-100)。\n "
103- "使用场景:\n "
104- "1. 用户要求设置音量到具体数值 (例如: '音量设为50', '把声音调到80', 'volume to 30')\n "
105- "2. 用户要求相对调整音量 ('调大一点', '声音小一点', '再大声点'): 必须先调用 "
106- "`self.get_device_status` 获取当前 audio_speaker.volume, 计算目标值(保持在0-100内), 然后调用本工具\n "
107- "3. 静音/取消静音: 静音设volume=0, 取消静音可设为之前的值或默认值(如30-50)\n \n "
108- "参数说明:\n "
109- "- volume: 整数类型,范围[0, 100],表示目标音量的绝对值\n \n "
110- "重要提示:如果当前音量未知,切勿猜测 —— 必须先调用 `self.get_device_status` 获取。"
111- "本工具不支持切换静音状态,要静音请设置volume=0。\n "
112- "English: Set the volume of the audio speaker. If the current volume is unknown, "
113- "you must call `self.get_device_status` tool first and then call this tool. "
114- "Use when user mentions: volume, sound, louder, quieter, mute, unmute, adjust volume. "
115- "Examples: '音量设为50', '调大声音', '声音小一点', 'set volume to 80', 'turn it up'." ,
76+ "Set the system speaker volume to an absolute value (0-100).\n "
77+ "Use when user mentions: volume, sound, louder, quieter, mute, unmute, adjust volume.\n "
78+ "Examples: 'set volume to 50', 'turn volume up', 'make it louder', 'mute', "
79+ "'音量设为50', '调大声音', '声音小一点', '静音'.\n "
80+ "Parameter:\n "
81+ "- volume: Integer (0-100) representing the target volume level. Set to 0 for mute." ,
11682 volume_props ,
11783 set_volume ,
11884 )
@@ -255,17 +221,17 @@ def get_status(self) -> Dict[str, Any]:
255221 """
256222 获取管理器状态.
257223 """
224+ available_tools = [
225+ "set_volume" ,
226+ "launch_application" ,
227+ "scan_installed_applications" ,
228+ "kill_application" ,
229+ "list_running_applications" ,
230+ ]
258231 return {
259232 "initialized" : self ._initialized ,
260- "tools_count" : 6 , # 当前注册的工具数量
261- "available_tools" : [
262- "get_device_status" ,
263- "set_volume" ,
264- "launch_application" ,
265- "scan_installed_applications" ,
266- "kill_application" ,
267- "list_running_applications" ,
268- ],
233+ "tools_count" : len (available_tools ),
234+ "available_tools" : available_tools ,
269235 }
270236
271237
0 commit comments