Spaces:
Build error
Build error
File size: 3,359 Bytes
85dd3af |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
"""
UI Components Module
Reusable UI elements and utilities for the Echo MCP Host.
"""
# Emoji mapping for server types - used across UI
EMOJI_MAP = {
"agentbell": "π",
"voice": "π",
"filesystem": "π",
"github": "π",
"brave": "π",
"playwright": "π",
"context7": "π",
"slack": "π¬",
"database": "ποΈ",
"sqlite": "ποΈ",
"postgres": "π",
"docker": "π³",
"git": "π¦",
"memory": "π§ ",
"search": "π",
"weather": "π€οΈ",
"time": "β°",
"calculator": "π’",
"email": "π§",
"calendar": "π
",
}
def get_server_emoji(name: str) -> str:
"""Get emoji for a server based on its name."""
name_lower = name.lower()
for key, emoji in EMOJI_MAP.items():
if key in name_lower:
return emoji
return "π¦" # Default package emoji
def create_status_badge(text: str, state: str) -> str:
"""
Generates the HTML for the Neo-Brutalist status badge.
Args:
text: Display text (e.g., "READY", "PROCESSING")
state: 'ready', 'active', 'wait', 'error'
"""
colors = {
"ready": "#00FF94", # Neon Green
"active": "#FF00F5", # Neon Pink
"wait": "#FFF500", # Neon Yellow
"error": "#FF3333" # Red
}
bg = colors.get(state, "#FFFFFF")
return f"""
<div style="display: flex; justify-content: flex-end; width: 100%;">
<div class="neo-status-badge" style="background-color: {bg};">
<div class="neo-status-text">{text}</div>
</div>
</div>
"""
def create_inspector_mock_html() -> str:
"""
Returns mock HTML for the Protocol Inspector panel.
Shows example bidirectional communication logs.
"""
return """
<div class="inspector-panel">
<div class="inspector-header">
<span class="inspector-title">// PROTOCOL_INSPECTOR</span>
<span class="inspector-status">βΈ IDLE</span>
</div>
<div class="inspector-log">
<div class="log-entry outgoing">
<span class="log-direction">β OUT</span>
<span class="log-method">initialize</span>
<pre class="log-payload">{"capabilities": {"experimental": {"agentbell_context": true}}}</pre>
</div>
<div class="log-entry incoming">
<span class="log-direction">β IN</span>
<span class="log-method">initialize (response)</span>
<pre class="log-payload">{"serverInfo": {"name": "agentbell-server", "version": "1.0.0"}}</pre>
</div>
<div class="log-entry outgoing">
<span class="log-direction">β OUT</span>
<span class="log-method">notifications/client_state</span>
<pre class="log-payload">{"state": "blocking", "reason": "User confirmation required for: rm -rf"}</pre>
</div>
<div class="log-entry incoming highlight">
<span class="log-direction">β IN</span>
<span class="log-method">notifications/agent_bell/speak</span>
<pre class="log-payload">{"text": "Warning! High risk command detected. Please confirm."}</pre>
</div>
</div>
<div class="inspector-footer">
<span>Bidirectional State Sync: <strong style="color: var(--accent-tertiary);">ACTIVE</strong></span>
</div>
</div>
"""
|