"""swarm hermes plugin — lifecycle bridge between hermes sessions and swarm-mcp.
Wires:
on_session_start— auto-callmcp_swarm_registerso the agent does not spend a tool call on bootstrap. The instance id returned is cached per session.on_session_finalize— auto-callmcp_swarm_deregisterat a real session boundary. Hermes'on_session_endfires after every turn, so it is intentionally non-destructive here./swarmslash command — peek at swarm state (instances, tasks, kv, recent messages) without spending an agent turn. Shells to theswarm-mcpCLI.pre_tool_call/post_tool_call— enforce peer-held locks on write-like file tools; post is retained as a no-op compatibility hook.- Workspace identity publishing — lets the adapter-neutral MCP
prompt_peertool wake a Hermes pane when appropriate.
The MCP server itself must be registered under the name swarm (matches
mcp_swarm_* tool prefix). If a different name was used, override via
SWARM_HERMES_MCP_NAME.
"""
from future import annotations
import logging
from . import cli, lifecycle
logger = logging.getLogger(name)
def register(ctx) -> None: ctx.register_hook("on_session_start", lifecycle.on_session_start) ctx.register_hook("on_session_finalize", lifecycle.on_session_finalize) ctx.register_hook("on_session_end", lifecycle.on_session_end) ctx.register_hook("pre_tool_call", lifecycle.on_pre_tool_call) ctx.register_hook("post_tool_call", lifecycle.on_post_tool_call) ctx.register_command( "swarm", handler=cli.handle_slash, description="Inspect swarm-mcp state (instances, tasks, kv, messages).", args_hint="[status|instances|tasks|kv|messages]", ) logger.info("swarm hermes plugin registered")
