Compare commits
1 Commits
mimo/creat
...
mimo/build
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fde7569e4 |
66
app.js
66
app.js
@@ -48,6 +48,9 @@ let chatOpen = true;
|
||||
let loadProgress = 0;
|
||||
let performanceTier = 'high';
|
||||
|
||||
// ═══ UI MODE (VISITOR / OPERATOR) ═══
|
||||
let uiMode = 'visitor'; // 'visitor' | 'operator'
|
||||
|
||||
// ═══ HERMES WS STATE ═══
|
||||
let hermesWs = null;
|
||||
let wsReconnectTimer = null;
|
||||
@@ -1867,6 +1870,9 @@ function setupControls() {
|
||||
if (e.key.toLowerCase() === 'v' && document.activeElement !== document.getElementById('chat-input')) {
|
||||
cycleNavMode();
|
||||
}
|
||||
if (e.key.toLowerCase() === 'o' && document.activeElement !== document.getElementById('chat-input')) {
|
||||
toggleUIMode();
|
||||
}
|
||||
if (e.key.toLowerCase() === 'f' && activePortal && !portalOverlayActive) {
|
||||
activatePortal(activePortal);
|
||||
}
|
||||
@@ -1964,18 +1970,9 @@ function setupControls() {
|
||||
});
|
||||
document.getElementById('chat-send').addEventListener('click', () => sendChatMessage());
|
||||
|
||||
// Add MemPalace mining button
|
||||
// Add MemPalace mining button (operator-only)
|
||||
document.querySelector('.chat-quick-actions').innerHTML += `
|
||||
<button class="quick-action-btn" onclick="mineMemPalaceContent()">Mine Chat</button>
|
||||
<div id="mem-palace-stats" class="mem-palace-stats">
|
||||
<div>Compression: <span id="compression-ratio">--</span>x</div>
|
||||
<div>Docs: <span id="docs-mined">0</span></div>
|
||||
<div>AAAK: <span id="aaak-size">0B</span></div>
|
||||
<div>Compression: <span id="compression-ratio">--</span>x</div>
|
||||
<div>Docs: <span id="docs-mined">0</span></div>
|
||||
<div>AAAK: <span id="aaak-size">0B</span></div>
|
||||
<div class="mem-palace-logs" style="margin-top:4px; font-size:10px; color:#4af0c0;">Logs: <span id="mem-logs">0</span></div>
|
||||
</div>
|
||||
<button class="quick-action-btn operator-only" onclick="mineMemPalaceContent()">Mine Chat</button>
|
||||
`;
|
||||
|
||||
// Chat quick actions
|
||||
@@ -2006,6 +2003,53 @@ function setupControls() {
|
||||
|
||||
document.getElementById('atlas-toggle-btn').addEventListener('click', openPortalAtlas);
|
||||
document.getElementById('atlas-close-btn').addEventListener('click', closePortalAtlas);
|
||||
|
||||
// ═══ VISITOR / OPERATOR MODE TOGGLE ═══
|
||||
// Restore saved mode from localStorage
|
||||
const savedMode = localStorage.getItem('nexus-ui-mode');
|
||||
if (savedMode === 'operator') {
|
||||
uiMode = 'operator';
|
||||
}
|
||||
applyUIMode();
|
||||
|
||||
// Create and append mode toggle button to the HUD controls area
|
||||
const modeBtn = document.createElement('button');
|
||||
modeBtn.id = 'mode-toggle-btn';
|
||||
modeBtn.className = 'mode-toggle-btn';
|
||||
modeBtn.setAttribute('data-mode', uiMode);
|
||||
modeBtn.innerHTML = modeToggleLabel();
|
||||
modeBtn.title = uiMode === 'visitor' ? 'Switch to Operator mode' : 'Switch to Visitor mode';
|
||||
modeBtn.addEventListener('click', toggleUIMode);
|
||||
|
||||
const hudEl = document.getElementById('hud');
|
||||
if (hudEl) hudEl.appendChild(modeBtn);
|
||||
}
|
||||
|
||||
function toggleUIMode() {
|
||||
uiMode = uiMode === 'visitor' ? 'operator' : 'visitor';
|
||||
localStorage.setItem('nexus-ui-mode', uiMode);
|
||||
applyUIMode();
|
||||
|
||||
// Update button
|
||||
const btn = document.getElementById('mode-toggle-btn');
|
||||
if (btn) {
|
||||
btn.setAttribute('data-mode', uiMode);
|
||||
btn.innerHTML = modeToggleLabel();
|
||||
btn.title = uiMode === 'visitor' ? 'Switch to Operator mode' : 'Switch to Visitor mode';
|
||||
}
|
||||
|
||||
addChatMessage('system', `Mode: ${uiMode.toUpperCase()}. ${uiMode === 'operator' ? 'Operator panels enabled.' : 'Visitor view. Clean and focused.'}`);
|
||||
}
|
||||
|
||||
function modeToggleLabel() {
|
||||
if (uiMode === 'visitor') {
|
||||
return '<span class="mode-icon">👁</span> VISITOR';
|
||||
}
|
||||
return '<span class="mode-icon">⚙</span> OPERATOR';
|
||||
}
|
||||
|
||||
function applyUIMode() {
|
||||
document.body.classList.toggle('visitor-mode', uiMode === 'visitor');
|
||||
}
|
||||
|
||||
function sendChatMessage(overrideText = null) {
|
||||
|
||||
Binary file not shown.
@@ -60,23 +60,6 @@ If the heartbeat is older than --stale-threshold seconds, the
|
||||
mind is considered dead even if the process is still running
|
||||
(e.g., hung on a blocking call).
|
||||
|
||||
KIMI HEARTBEAT
|
||||
==============
|
||||
The Kimi triage pipeline writes a cron heartbeat file after each run:
|
||||
|
||||
/var/run/bezalel/heartbeats/kimi-heartbeat.last
|
||||
(fallback: ~/.bezalel/heartbeats/kimi-heartbeat.last)
|
||||
{
|
||||
"job": "kimi-heartbeat",
|
||||
"timestamp": 1711843200.0,
|
||||
"interval_seconds": 900,
|
||||
"pid": 12345,
|
||||
"status": "ok"
|
||||
}
|
||||
|
||||
If the heartbeat is stale (>2x declared interval), the watchdog reports
|
||||
a Kimi Heartbeat failure alongside the other checks.
|
||||
|
||||
ZERO DEPENDENCIES
|
||||
=================
|
||||
Pure stdlib. No pip installs. Same machine as the nexus.
|
||||
@@ -121,10 +104,6 @@ DEFAULT_HEARTBEAT_PATH = Path.home() / ".nexus" / "heartbeat.json"
|
||||
DEFAULT_STALE_THRESHOLD = 300 # 5 minutes without a heartbeat = dead
|
||||
DEFAULT_INTERVAL = 60 # seconds between checks in watch mode
|
||||
|
||||
# Kimi Heartbeat — cron job heartbeat file written by the triage pipeline
|
||||
KIMI_HEARTBEAT_JOB = "kimi-heartbeat"
|
||||
KIMI_HEARTBEAT_STALE_MULTIPLIER = 2.0 # stale at 2x declared interval
|
||||
|
||||
GITEA_URL = os.environ.get("GITEA_URL", "https://forge.alexanderwhitestone.com")
|
||||
GITEA_TOKEN = os.environ.get("GITEA_TOKEN", "")
|
||||
GITEA_REPO = os.environ.get("NEXUS_REPO", "Timmy_Foundation/the-nexus")
|
||||
@@ -366,93 +345,6 @@ def check_syntax_health() -> CheckResult:
|
||||
)
|
||||
|
||||
|
||||
def check_kimi_heartbeat(
|
||||
job: str = KIMI_HEARTBEAT_JOB,
|
||||
stale_multiplier: float = KIMI_HEARTBEAT_STALE_MULTIPLIER,
|
||||
) -> CheckResult:
|
||||
"""Check if the Kimi Heartbeat cron job is alive.
|
||||
|
||||
Reads the ``<job>.last`` file from the standard Bezalel heartbeat
|
||||
directory (``/var/run/bezalel/heartbeats/`` or fallback
|
||||
``~/.bezalel/heartbeats/``). The file is written atomically by the
|
||||
cron_heartbeat module after each successful triage pipeline run.
|
||||
|
||||
A job is stale when:
|
||||
``time.time() - timestamp > stale_multiplier * interval_seconds``
|
||||
(same rule used by ``check_cron_heartbeats.py``).
|
||||
"""
|
||||
# Resolve heartbeat directory — same logic as cron_heartbeat._resolve
|
||||
primary = Path("/var/run/bezalel/heartbeats")
|
||||
fallback = Path.home() / ".bezalel" / "heartbeats"
|
||||
env_dir = os.environ.get("BEZALEL_HEARTBEAT_DIR")
|
||||
if env_dir:
|
||||
hb_dir = Path(env_dir)
|
||||
elif primary.exists():
|
||||
hb_dir = primary
|
||||
elif fallback.exists():
|
||||
hb_dir = fallback
|
||||
else:
|
||||
return CheckResult(
|
||||
name="Kimi Heartbeat",
|
||||
healthy=False,
|
||||
message="Heartbeat directory not found — no triage pipeline deployed yet",
|
||||
details={"searched": [str(primary), str(fallback)]},
|
||||
)
|
||||
|
||||
hb_file = hb_dir / f"{job}.last"
|
||||
if not hb_file.exists():
|
||||
return CheckResult(
|
||||
name="Kimi Heartbeat",
|
||||
healthy=False,
|
||||
message=f"No heartbeat file at {hb_file} — Kimi triage pipeline has never reported",
|
||||
details={"path": str(hb_file)},
|
||||
)
|
||||
|
||||
try:
|
||||
data = json.loads(hb_file.read_text())
|
||||
except (json.JSONDecodeError, OSError) as e:
|
||||
return CheckResult(
|
||||
name="Kimi Heartbeat",
|
||||
healthy=False,
|
||||
message=f"Heartbeat file corrupt: {e}",
|
||||
details={"path": str(hb_file), "error": str(e)},
|
||||
)
|
||||
|
||||
timestamp = float(data.get("timestamp", 0))
|
||||
interval = int(data.get("interval_seconds", 0))
|
||||
raw_status = data.get("status", "unknown")
|
||||
age = time.time() - timestamp
|
||||
|
||||
if interval <= 0:
|
||||
# No declared interval — use raw timestamp age (30 min default)
|
||||
interval = 1800
|
||||
|
||||
threshold = stale_multiplier * interval
|
||||
is_stale = age > threshold
|
||||
|
||||
age_str = f"{int(age)}s" if age < 3600 else f"{int(age // 3600)}h {int((age % 3600) // 60)}m"
|
||||
interval_str = f"{int(interval)}s" if interval < 3600 else f"{int(interval // 3600)}h {int((interval % 3600) // 60)}m"
|
||||
|
||||
if is_stale:
|
||||
return CheckResult(
|
||||
name="Kimi Heartbeat",
|
||||
healthy=False,
|
||||
message=(
|
||||
f"Silent for {age_str} "
|
||||
f"(threshold: {stale_multiplier}x {interval_str} = {int(threshold)}s). "
|
||||
f"Status: {raw_status}"
|
||||
),
|
||||
details=data,
|
||||
)
|
||||
|
||||
return CheckResult(
|
||||
name="Kimi Heartbeat",
|
||||
healthy=True,
|
||||
message=f"Alive — last beat {age_str} ago (interval {interval_str}, status={raw_status})",
|
||||
details=data,
|
||||
)
|
||||
|
||||
|
||||
# ── Gitea alerting ───────────────────────────────────────────────────
|
||||
|
||||
def _gitea_request(method: str, path: str, data: Optional[dict] = None) -> Any:
|
||||
@@ -554,7 +446,6 @@ def run_health_checks(
|
||||
check_mind_process(),
|
||||
check_heartbeat(heartbeat_path, stale_threshold),
|
||||
check_syntax_health(),
|
||||
check_kimi_heartbeat(),
|
||||
]
|
||||
return HealthReport(timestamp=time.time(), checks=checks)
|
||||
|
||||
@@ -654,14 +545,6 @@ def main():
|
||||
"--json", action="store_true", dest="output_json",
|
||||
help="Output results as JSON (for integration with other tools)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--kimi-job", default=KIMI_HEARTBEAT_JOB,
|
||||
help=f"Kimi heartbeat job name (default: {KIMI_HEARTBEAT_JOB})",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--kimi-stale-multiplier", type=float, default=KIMI_HEARTBEAT_STALE_MULTIPLIER,
|
||||
help=f"Kimi heartbeat staleness multiplier (default: {KIMI_HEARTBEAT_STALE_MULTIPLIER})",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
@@ -157,7 +157,8 @@
|
||||
<!-- Controls hint + nav mode -->
|
||||
<div class="hud-controls">
|
||||
<span>WASD</span> move <span>Mouse</span> look <span>Enter</span> chat
|
||||
<span>V</span> mode: <span id="nav-mode-label">WALK</span>
|
||||
<span>V</span> nav: <span id="nav-mode-label">WALK</span>
|
||||
<span>O</span> toggle mode
|
||||
<span id="nav-mode-hint" class="nav-mode-hint"></span>
|
||||
<span class="ws-hud-status">HERMES: <span id="ws-status-dot" class="chat-status-dot"></span></span>
|
||||
</div>
|
||||
|
||||
81
style.css
81
style.css
@@ -1580,3 +1580,84 @@ canvas#nexus-canvas {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* === VISITOR / OPERATOR MODE TOGGLE === */
|
||||
.mode-toggle-btn {
|
||||
position: absolute;
|
||||
bottom: var(--space-3);
|
||||
right: var(--space-3);
|
||||
pointer-events: auto;
|
||||
background: rgba(10, 15, 40, 0.7);
|
||||
border: 1px solid var(--color-primary);
|
||||
color: var(--color-primary);
|
||||
padding: 6px 14px;
|
||||
font-family: var(--font-display);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.12em;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
backdrop-filter: blur(5px);
|
||||
transition: all var(--transition-ui);
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.mode-toggle-btn:hover {
|
||||
background: var(--color-primary);
|
||||
color: var(--color-bg);
|
||||
box-shadow: 0 0 15px var(--color-primary);
|
||||
}
|
||||
|
||||
.mode-toggle-btn .mode-icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.mode-toggle-btn[data-mode="operator"] {
|
||||
border-color: var(--color-gold);
|
||||
color: var(--color-gold);
|
||||
box-shadow: 0 0 8px rgba(255, 215, 0, 0.15);
|
||||
}
|
||||
|
||||
.mode-toggle-btn[data-mode="operator"]:hover {
|
||||
background: var(--color-gold);
|
||||
color: var(--color-bg);
|
||||
box-shadow: 0 0 15px var(--color-gold);
|
||||
}
|
||||
|
||||
/* Visitor mode: hide operator-only surfaces */
|
||||
body.visitor-mode .gofai-hud,
|
||||
body.visitor-mode .hud-agent-log,
|
||||
body.visitor-mode .hud-debug,
|
||||
body.visitor-mode .bannerlord-hud,
|
||||
body.visitor-mode #mem-palace-status,
|
||||
body.visitor-mode #mem-palace-controls,
|
||||
body.visitor-mode #mempalace-results,
|
||||
body.visitor-mode .mem-palace-ui,
|
||||
body.visitor-mode .mem-palace-stats,
|
||||
body.visitor-mode .ws-hud-status,
|
||||
body.visitor-mode .chat-quick-actions .operator-only,
|
||||
body.visitor-mode .nexus-footer {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Visitor mode: simplify controls hint */
|
||||
body.visitor-mode .hud-controls {
|
||||
font-size: var(--text-xs);
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
/* Visitor mode: cleaner chat */
|
||||
body.visitor-mode .chat-panel {
|
||||
width: 320px;
|
||||
max-height: 300px;
|
||||
}
|
||||
|
||||
/* Operator badge in operator mode */
|
||||
body:not(.visitor-mode) .hud-controls::after {
|
||||
content: ' OPERATOR';
|
||||
color: var(--color-gold);
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user