mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-05-25 11:10:18 +00:00
This commit is contained in:
@@ -2183,6 +2183,43 @@ def handle_get(handler, parsed) -> bool:
|
||||
{"name": get_active_profile_name(), "path": str(get_active_hermes_home())},
|
||||
)
|
||||
|
||||
# ── Gateway Status (GET) ──
|
||||
if parsed.path == "/api/gateway/status":
|
||||
import datetime
|
||||
identity_map = _load_gateway_session_identity_map()
|
||||
sessions_path = _gateway_session_metadata_path()
|
||||
running = bool(identity_map)
|
||||
platforms_set: set[str] = set()
|
||||
for meta in identity_map.values():
|
||||
raw = meta.get("raw_source") or meta.get("platform") or ""
|
||||
norm = _normalize_messaging_source(raw)
|
||||
if norm:
|
||||
platforms_set.add(norm)
|
||||
_PLATFORM_LABELS = {
|
||||
"telegram": "Telegram",
|
||||
"discord": "Discord",
|
||||
"slack": "Slack",
|
||||
"web": "Web",
|
||||
"api": "API",
|
||||
}
|
||||
platforms = sorted(
|
||||
[{"name": p, "label": _PLATFORM_LABELS.get(p, p.title())} for p in platforms_set],
|
||||
key=lambda x: x["label"],
|
||||
)
|
||||
last_active = ""
|
||||
if running and sessions_path.exists():
|
||||
try:
|
||||
mtime = sessions_path.stat().st_mtime
|
||||
last_active = datetime.datetime.fromtimestamp(mtime).isoformat()
|
||||
except Exception:
|
||||
pass
|
||||
return j(handler, {
|
||||
"running": running,
|
||||
"platforms": platforms,
|
||||
"last_active": last_active,
|
||||
"session_count": len(identity_map),
|
||||
})
|
||||
|
||||
# ── MCP Servers (GET) ──
|
||||
if parsed.path == "/api/mcp/servers":
|
||||
return _handle_mcp_servers_list(handler)
|
||||
|
||||
@@ -932,6 +932,12 @@
|
||||
</div>
|
||||
<button class="sm-btn" id="btnDisableAuth" onclick="disableAuth()" style="margin-top:6px;width:100%;padding:8px;font-weight:600;color:#e8a030;border-color:rgba(232,160,48,.3);display:none" data-i18n="disable_auth">Disable Auth</button>
|
||||
<button class="sm-btn" id="btnSignOut" onclick="signOut()" style="margin-top:6px;width:100%;padding:8px;font-weight:600;color:var(--accent);border-color:rgba(233,69,96,.3);display:none" data-i18n="sign_out">Sign Out</button>
|
||||
<!-- Gateway Status Section -->
|
||||
<div class="settings-field" style="margin-top:18px;padding-top:16px;border-top:1px solid var(--border)">
|
||||
<label>Gateway Status</label>
|
||||
<div style="font-size:11px;color:var(--muted);margin-bottom:8px">Status of the Hermes gateway (Telegram, Discord, Slack, etc.)</div>
|
||||
<div id="gatewayStatusCard"><span style="color:var(--muted);font-size:12px">Loading…</span></div>
|
||||
</div>
|
||||
<!-- MCP Servers Section -->
|
||||
<div class="settings-field" style="margin-top:18px;padding-top:16px;border-top:1px solid var(--border)">
|
||||
<label data-i18n="mcp_servers_title">MCP Servers</label>
|
||||
|
||||
+23
-1
@@ -3840,11 +3840,33 @@ async function deleteMcpServer(name){
|
||||
else{showToast((r&&r.error)||t('mcp_delete_failed'));}
|
||||
}).catch(()=>{showToast(t('mcp_delete_failed'));});
|
||||
}
|
||||
function loadGatewayStatus(){
|
||||
const card=$('gatewayStatusCard');
|
||||
if(!card) return;
|
||||
api('/api/gateway/status').then(r=>{
|
||||
if(!r) return;
|
||||
if(!r.running){
|
||||
card.innerHTML=`<div style="color:var(--muted);font-size:12px;display:flex;align-items:center;gap:6px"><span style="width:8px;height:8px;border-radius:50%;background:#ef4444;display:inline-block"></span>Gateway not running</div>`;
|
||||
return;
|
||||
}
|
||||
const platformIcons={telegram:'💬',discord:'🎮',slack:'📝',web:'🌐',api:'🔌'};
|
||||
let badges='';
|
||||
if(r.platforms&&r.platforms.length){
|
||||
badges=r.platforms.map(p=>{
|
||||
const icon=platformIcons[p.name]||'📡';
|
||||
return `<span style="display:inline-flex;align-items:center;gap:4px;padding:3px 10px;background:var(--code-bg);border:1px solid var(--border2);border-radius:12px;font-size:12px;font-weight:500">${icon} ${esc(p.label)}</span>`;
|
||||
}).join(' ');
|
||||
}
|
||||
const lastActive=r.last_active?`<span style="font-size:11px;color:var(--muted)">Last active: ${esc(new Date(r.last_active).toLocaleString())}</span>`:'';
|
||||
const sessionInfo=r.session_count?`<span style="font-size:11px;color:var(--muted)">${r.session_count} session${r.session_count!==1?'s':''}</span>`:'';
|
||||
card.innerHTML=`<div style="display:flex;align-items:center;gap:6px;margin-bottom:8px"><span style="width:8px;height:8px;border-radius:50%;background:#22c55e;display:inline-block"></span><span style="font-size:13px;font-weight:500;color:#22c55e">Running</span></div>${badges?`<div style="display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px">${badges}</div>`:''}<div style="display:flex;gap:12px">${sessionInfo}${lastActive}</div>`;
|
||||
}).catch(()=>{card.innerHTML=`<div style="color:#ef4444;font-size:12px">Failed to load gateway status</div>`});
|
||||
}
|
||||
// Load MCP servers when system settings tab opens
|
||||
const _origSwitchSettings=switchSettingsSection;
|
||||
switchSettingsSection=function(name){
|
||||
_origSwitchSettings(name);
|
||||
if(name==='system') loadMcpServers();
|
||||
if(name==='system'){loadMcpServers();loadGatewayStatus();}
|
||||
};
|
||||
|
||||
// ── Checkpoints / Rollback ──────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user