Files
hermes-agent/tools/focus_pane_tool.py
Teknium d4cec15b47 refactor(tools): first-wave simplification of tools/ (file ops split, lazy_deps, code_exec, approval, browser, delegate, mcp, skills, terminal, voice, media)
Behavior-neutral structural pass over tools/*: god-file extractions into
sibling modules (file_operations_common/lint/search, file_tools_paths/
read_tracking/write, code_execution_env/rpc, tool_search_catalog/names/
validation, tts_command_provider, ...), duplicate helper unification,
if/elif -> dispatch tables, dead-code removal, docstring compaction.
Tool schemas (get_tool_definitions) verified byte-identical to base.
2026-09-02 14:43:45 -07:00

56 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Reveal/focus a pane in the Hermes desktop GUI (``pane.reveal`` via ``desktop_ui``).
The renderer runs each pane's own reveal path and only acts on the active window, so
a background turn never moves the user's focus. URLs/files go through `desktop_preview`.
"""
from tools import desktop_ui
from tools.registry import registry, tool_error
PANES = ("chat", "files", "terminal", "review", "sessions")
def focus_pane_tool(pane: str) -> str:
"""Ask the desktop GUI to reveal and focus ``pane``."""
name = (pane or "").strip().lower()
if name not in PANES:
return tool_error(f"pane must be one of: {', '.join(PANES)}.")
return desktop_ui.emit_or_error(
"pane.reveal",
{"pane": name},
f"Failed to focus the {name} pane: ",
"Pane focus is only available in the Hermes desktop app.",
{"success": True, "pane": name},
)
FOCUS_PANE_SCHEMA = {
"name": "focus_pane",
"description": (
"Reveal and focus a Hermes desktop pane when the user asks to see it: "
"chat, files, terminal, review (git diff), or sessions. For URLs/"
"files use the desktop_preview tool instead."
),
"parameters": {
"type": "object",
"properties": {
"pane": {
"type": "string",
"enum": list(PANES),
"description": "Which pane to reveal.",
},
},
"required": ["pane"],
},
}
registry.register(
name="focus_pane",
toolset="desktop_ui",
schema=FOCUS_PANE_SCHEMA,
handler=lambda args, **kw: focus_pane_tool(pane=args.get("pane", "")),
emoji="🪟",
)