55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
"""Conservative mapping from Hermes tools to HUX capabilities."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class ToolPolicy:
|
|
"""The HUX gate inputs for one tool family."""
|
|
|
|
capability: str
|
|
risk: str
|
|
external: bool
|
|
|
|
|
|
EXACT = {
|
|
"read_file": ToolPolicy("read_files", "low", False),
|
|
"read_many_files": ToolPolicy("read_files", "low", False),
|
|
"list_directory": ToolPolicy("read_files", "low", False),
|
|
"search_files": ToolPolicy("read_files", "low", False),
|
|
"session_search": ToolPolicy("read_files", "low", False),
|
|
"tool_search": ToolPolicy("read_files", "low", False),
|
|
"write_file": ToolPolicy("write_files", "medium", False),
|
|
"patch": ToolPolicy("write_files", "medium", False),
|
|
"memory": ToolPolicy("memory_write", "medium", False),
|
|
"delegate_task": ToolPolicy("delegate", "high", False),
|
|
"terminal": ToolPolicy("shell", "high", True),
|
|
"python": ToolPolicy("shell", "high", True),
|
|
}
|
|
|
|
PREFIXES = (
|
|
(("web_", "browser_", "http_", "mcp_"), ToolPolicy("network", "high", True)),
|
|
(("send_", "mail_", "email_", "slack_", "discord_", "telegram_"), ToolPolicy("send_message", "high", True)),
|
|
(("kubectl_", "flux_", "deploy_", "release_"), ToolPolicy("deploy", "high", True)),
|
|
(("image_", "video_", "vision_"), ToolPolicy("external_side_effect", "high", True)),
|
|
(("artifact_",), ToolPolicy("artifact_write", "medium", False)),
|
|
(("memory_",), ToolPolicy("memory_write", "medium", False)),
|
|
(("delegate_", "subagent_"), ToolPolicy("delegate", "high", False)),
|
|
(("write_", "edit_", "file_"), ToolPolicy("write_files", "medium", False)),
|
|
)
|
|
|
|
UNKNOWN = ToolPolicy("external_side_effect", "high", True)
|
|
|
|
|
|
def classify(tool_name: str) -> ToolPolicy:
|
|
"""Return a known mapping, treating every unknown tool as high-risk external."""
|
|
name = tool_name.strip().lower() if isinstance(tool_name, str) else ""
|
|
if name in EXACT:
|
|
return EXACT[name]
|
|
for prefixes, policy in PREFIXES:
|
|
if name.startswith(prefixes):
|
|
return policy
|
|
return UNKNOWN
|