@@ -20,6 +20,7 @@ def completer(text, state):
2020
2121from mini_copilot .github_api import chat , get_copilot_token
2222from mini_copilot .web_search import web_search
23+ from mini_copilot .exec_tool import exec_command
2324from mini_copilot .commands .auth import handle_login_command
2425from mini_copilot .commands .model import handle_model_command
2526from mini_copilot .commands .search_provider import handle_search_provider_command
@@ -59,7 +60,25 @@ def completer(text, state):
5960 },
6061 },
6162}
62- TOOLS = [WEB_SEARCH_TOOL ]
63+
64+ EXEC_COMMAND_TOOL = {
65+ "type" : "function" ,
66+ "function" : {
67+ "name" : "exec_command" ,
68+ "description" : "Execute a shell command on the local system and return the output." ,
69+ "parameters" : {
70+ "type" : "object" ,
71+ "properties" : {
72+ "command" : {
73+ "type" : "string" ,
74+ "description" : "The shell command to execute." ,
75+ },
76+ },
77+ "required" : ["command" ],
78+ },
79+ },
80+ }
81+ TOOLS = [WEB_SEARCH_TOOL , EXEC_COMMAND_TOOL ]
6382
6483
6584def load_github_token ():
@@ -167,6 +186,19 @@ def main():
167186 "content" : search_context ,
168187 }
169188 )
189+
190+ if function_name == "exec_command" :
191+ command = function_args .get ("command" )
192+ output = exec_command (command )
193+
194+ messages .append (
195+ {
196+ "tool_call_id" : tool_call ["id" ],
197+ "role" : "tool" ,
198+ "name" : function_name ,
199+ "content" : output ,
200+ }
201+ )
170202 response_message = chat (
171203 messages , copilot_token , current_model , tools = TOOLS
172204 )
0 commit comments