Add MCP delegation bridge and diagram tools

**Features Added**:

1. **Agent Registry (agent_registry.py)**
   - Thread-safe global singleton for MCP tool access to Agent instance
   - Enables MCP tools to call Agent.delegate() without circular imports
   - Registered at bot startup in bot_runner.py

2. **Sub-Agent Manager (sub_agent_manager.py)**
   - Watchdog system monitoring sub-agent lifecycle
   - Detects hung agents (5min timeout, 30s check interval)
   - Auto-cleanup and status tracking

3. **delegate_task MCP Tool (mcp_tools.py)**
   - Exposes Agent.delegate() to Claude via MCP protocol
   - Enables parallel sub-agent execution via tool calls
   - Supports specialist prompts and agent ID caching

4. **Memory Write Locks (memory_system.py)**
   - Thread-safe writes to prevent file corruption
   - Protects write_memory(), update_soul(), update_user()

5. **Diagram Tools**
   - Mermaid MCP server (flowcharts, sequence diagrams, etc.)
   - Excalidraw MCP server (hand-drawn style diagrams)
   - Config files in config/ directory

6. **Adapter Improvements**
   - Enhanced error handling across all adapters
   - Unified logging patterns

**Testing**: Ready for parallel sub-agent testing

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 14:34:24 -07:00
parent dd5beb11c2
commit e909cc0044
13 changed files with 1081 additions and 26 deletions

View File

@@ -145,6 +145,26 @@ class BaseAdapter(ABC):
async def send_typing_indicator(self, channel_id: str) -> None:
"""Show typing indicator. Optional."""
async def send_file(
self,
channel_id: str,
file_path: str,
caption: Optional[str] = None,
thread_id: Optional[str] = None
) -> Dict[str, Any]:
"""Send a file attachment to the platform. Optional - override if supported.
Args:
channel_id: Channel/chat ID to send to
file_path: Absolute path to file
caption: Optional caption/text with the file
thread_id: Optional thread/reply ID
Returns:
Dict with success status and message_id or error
"""
return {"success": False, "error": "send_file not implemented"}
async def health_check(self) -> Dict[str, Any]:
"""Perform health check on the adapter."""
return {