diff --git a/main.py b/main.py index 9b2b499..d984923 100644 --- a/main.py +++ b/main.py @@ -129,11 +129,11 @@ def execute_computer_tool(tool_input): return {"type": "text", "text": f"Error pressing key {text}: {str(e)}"} elif action == "scroll": - # Scroll action - direction = tool_input.get("direction", "down") - amount = tool_input.get("amount", 3) + # Scroll action (should we really have defaults here?) + direction = tool_input.get("scroll_direction", "down") + amount = tool_input.get("scroll_amount", 3) - scroll_amount = -amount if direction == "up" else amount + scroll_amount = -amount if direction == "down" else amount pyautogui.scroll(scroll_amount) return {"type": "text", "text": f"Scrolled {direction} by {amount}"} @@ -165,23 +165,23 @@ def execute_bash_tool(command): return {"type": "text", "text": f"Error executing command: {str(e)}"} -def execute_text_editor_tool(command, path, **kwargs): +def execute_text_editor_tool(_command, _path, **kwargs): """Execute text editor actions.""" - if command == "view": + if _command == "view": try: - with open(path, 'r') as f: + with open(_path, 'r') as f: content = f.read() return {"type": "text", "text": content} except Exception as e: return {"type": "text", "text": f"Error reading file: {str(e)}"} - elif command == "str_replace": + elif _command == "str_replace": old_str = kwargs.get("old_str", "") new_str = kwargs.get("new_str", "") try: - with open(path, 'r') as f: + with open(_path, 'r') as f: content = f.read() if old_str not in content: @@ -191,7 +191,7 @@ def execute_text_editor_tool(command, path, **kwargs): new_content = content.replace(old_str, new_str) # Write back to file - with open(path, 'w') as f: + with open(_path, 'w') as f: f.write(new_content) return {"type": "text", "text": "String replaced successfully"} @@ -199,17 +199,17 @@ def execute_text_editor_tool(command, path, **kwargs): except Exception as e: return {"type": "text", "text": f"Error modifying file: {str(e)}"} - elif command == "create": + elif _command == "create": content = kwargs.get("content", "") try: - with open(path, 'w') as f: + with open(_path, 'w') as f: f.write(content) - return {"type": "text", "text": f"File created: {path}"} + return {"type": "text", "text": f"File created: {_path}"} except Exception as e: return {"type": "text", "text": f"Error creating file: {str(e)}"} else: - return {"type": "text", "text": f"Unknown text editor command: {command}"} + return {"type": "text", "text": f"Unknown text editor command: {_command}"} def execute_tool(tool_name, tool_input):