Files
python-sdk/pkg/hanzo-tools-computer/hanzo_tools/computer/ui_tool.py
T
zeekay 7f296c4a43 feat: add new tool packages and install command
- Add hanzo-tools-code: code analysis and transformation tools
- Add hanzo-tools-net: network and HTTP tools
- Add hanzo-tools-plan: planning and task management tools
- Add hanzo-tools-test: testing tools
- Add hanzo-tools-vcs: version control tools
- Add install command for dependency management
- Improve CDP bridge server with better error handling
- Add ui_tool for computer tools
- Add unified tool loading and id_tool
- Add HIP documentation (HIP-0300, HIP-0301)
2026-01-24 13:21:16 -08:00

69 lines
2.1 KiB
Python

"""Unified UI tool for HIP-0300 architecture.
This module provides a single unified 'ui' tool that consolidates:
- Computer control (click, type, screenshot, etc.)
- Screen recording (session, record, stop, analyze)
Following Unix philosophy: one tool for the Interface axis.
"""
from typing import Any, ClassVar
from mcp.server import FastMCP
from mcp.server.fastmcp import Context as MCPContext
from hanzo_tools.core import PermissionManager
from .computer_tool import ComputerTool
class UiTool(ComputerTool):
"""Unified UI tool (HIP-0300).
Consolidates computer + screen tools into single 'ui' tool.
Inherits all functionality from ComputerTool.
Actions:
- Mouse: click, double_click, right_click, middle_click, move, drag, scroll
- Touch: tap, swipe, pinch
- Keyboard: type, write, press, key_down, key_up, hotkey
- Screen capture: screenshot, screenshot_region, capture
- Screen recording: session, record, stop, analyze
- Image location: locate, locate_all, locate_center, wait_for_image
- Window: get_active_window, list_windows, focus_window
- Screen info: get_screens, screen_size, current_screen
- Region: define_region, region_screenshot, region_locate
- Batch: batch
"""
# Override name to 'ui' for HIP-0300
name: ClassVar[str] = "ui"
@property
def description(self) -> str:
return """Unified interface control tool (HIP-0300).
Actions:
- click, double_click, right_click, middle_click, move, drag, scroll
- tap, swipe, pinch (touch/mobile)
- type, write, press, key_down, key_up, hotkey (keyboard)
- screenshot, screenshot_region, capture
- session, record, stop, analyze (screen recording)
- focus_window, list_windows, get_active_window
- get_screens, screen_size
Cross-platform: macOS (Quartz), Linux (xdotool), Windows (win32api).
"""
def register(self, mcp_server: FastMCP) -> None:
"""Register as 'ui' tool with MCP server."""
# Delegate to parent registration but with 'ui' name
super().register(mcp_server)
# Backward compatibility aliases
ComputerToolAlias = UiTool
# For imports: from hanzo_tools.computer import ui_tool
ui_tool = UiTool