Compare commits
1 Commits
mimo/creat
...
mimo/code/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8057e7d00c |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,6 +7,3 @@ mempalace/__pycache__/
|
||||
|
||||
# Prevent agents from writing to wrong path (see issue #1145)
|
||||
public/nexus/
|
||||
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
167
app.js
167
app.js
@@ -713,8 +713,6 @@ async function init() {
|
||||
connectHermes();
|
||||
fetchGiteaData();
|
||||
setInterval(fetchGiteaData, 30000); // Refresh every 30s
|
||||
updateHeartbeatBriefing(); // Initial briefing load
|
||||
setInterval(updateHeartbeatBriefing, 60000); // Refresh briefing every 60s
|
||||
|
||||
composer = new EffectComposer(renderer);
|
||||
composer.addPass(new RenderPass(scene, camera));
|
||||
@@ -1142,7 +1140,6 @@ async function fetchGiteaData() {
|
||||
const worldState = JSON.parse(atob(content.content));
|
||||
updateNexusCommand(worldState);
|
||||
updateSovereignHealth();
|
||||
updateHeartbeatBriefing();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch Gitea data:', e);
|
||||
@@ -1238,127 +1235,6 @@ function updateNexusCommand(state) {
|
||||
terminal.updatePanelText(lines);
|
||||
}
|
||||
|
||||
// ═══ HEARTBEAT BRIEFING PANEL ═════════════════════════════════════════
|
||||
async function updateHeartbeatBriefing() {
|
||||
const container = document.getElementById('heartbeat-briefing-content');
|
||||
const pulseDot = document.querySelector('.hb-pulse-dot');
|
||||
if (!container) return;
|
||||
|
||||
let data = null;
|
||||
try {
|
||||
// Derive briefing endpoint from current location or fallback to localhost
|
||||
const briefingUrl = window.location.protocol === 'file:'
|
||||
? 'http://localhost:8766/api/briefing'
|
||||
: `${window.location.protocol}//${window.location.hostname}:8766/api/briefing`;
|
||||
const res = await fetch(briefingUrl);
|
||||
if (res.ok) data = await res.json();
|
||||
} catch (e) {
|
||||
// Server not reachable — show honest offline state
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
if (pulseDot) pulseDot.classList.add('offline');
|
||||
container.innerHTML = '<div class="hb-empty">Briefing offline<br>No connection to Nexus gateway</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
if (pulseDot) pulseDot.classList.remove('offline');
|
||||
|
||||
let html = '';
|
||||
|
||||
// ── Core Heartbeat ──
|
||||
html += '<div class="briefing-section">';
|
||||
html += '<div class="briefing-section-label">Nexus Core</div>';
|
||||
const hb = data.core_heartbeat;
|
||||
if (hb) {
|
||||
const age = hb.age_secs != null ? hb.age_secs : '?';
|
||||
const ageLabel = typeof age === 'number'
|
||||
? (age < 60 ? `${age.toFixed(0)}s ago` : `${(age / 60).toFixed(1)}m ago`)
|
||||
: age;
|
||||
const isAlive = typeof age === 'number' && age < 120;
|
||||
html += `<div class="hb-core-row">
|
||||
<span class="hb-core-status ${isAlive ? 'alive' : 'dead'}">${isAlive ? '● ALIVE' : '○ STALE'}</span>
|
||||
<span class="hb-core-meta">cycle ${hb.cycle || '?'} · ${hb.model || 'unknown'} · ${ageLabel}</span>
|
||||
</div>`;
|
||||
html += `<div class="hb-core-meta">status: ${hb.status || '?'}</div>`;
|
||||
} else {
|
||||
html += '<div class="hb-core-row"><span class="hb-core-status dead">○ NO DATA</span></div>';
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
// ── Cron Heartbeats ──
|
||||
const cron = data.cron_heartbeat;
|
||||
if (cron && cron.jobs && cron.jobs.length > 0) {
|
||||
html += '<div class="briefing-section">';
|
||||
html += '<div class="briefing-section-label">Cron Heartbeats</div>';
|
||||
html += `<div class="hb-cron-row">
|
||||
<span class="hb-cron-healthy">● ${cron.healthy_count} healthy</span>
|
||||
${cron.stale_count > 0 ? `<span class="hb-cron-stale">⚠ ${cron.stale_count} stale</span>` : ''}
|
||||
</div>`;
|
||||
for (const job of cron.jobs.slice(0, 5)) {
|
||||
const cls = job.healthy ? 'healthy' : 'stale';
|
||||
html += `<div class="hb-cron-job">
|
||||
<span class="hb-cron-job-name">${esc(job.job)}</span>
|
||||
<span class="hb-cron-job-status ${cls}">${esc(job.message)}</span>
|
||||
</div>`;
|
||||
}
|
||||
if (cron.jobs.length > 5) {
|
||||
html += `<div class="hb-core-meta">+${cron.jobs.length - 5} more jobs</div>`;
|
||||
}
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
// ── Morning Report ──
|
||||
const report = data.morning_report;
|
||||
if (report) {
|
||||
html += '<div class="briefing-section">';
|
||||
html += '<div class="briefing-section-label">Latest Report</div>';
|
||||
|
||||
// Aggregate stats
|
||||
let totalClosed = 0, totalMerged = 0;
|
||||
if (report.repos) {
|
||||
for (const r of Object.values(report.repos)) {
|
||||
totalClosed += r.closed_issues || 0;
|
||||
totalMerged += r.merged_prs || 0;
|
||||
}
|
||||
}
|
||||
html += `<div class="hb-stats-row">
|
||||
<div class="hb-stat"><span class="hb-stat-value" style="color:#4af0c0">${totalClosed}</span><span class="hb-stat-label">Closed</span></div>
|
||||
<div class="hb-stat"><span class="hb-stat-value" style="color:#7b5cff">${totalMerged}</span><span class="hb-stat-label">Merged</span></div>
|
||||
<div class="hb-stat"><span class="hb-stat-value" style="color:#ffd700">${(report.blockers || []).length}</span><span class="hb-stat-label">Blockers</span></div>
|
||||
</div>`;
|
||||
|
||||
// Highlights (up to 3)
|
||||
if (report.highlights && report.highlights.length > 0) {
|
||||
for (const h of report.highlights.slice(0, 3)) {
|
||||
html += `<div class="hb-core-meta">+ ${esc(h)}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
// Blockers
|
||||
if (report.blockers && report.blockers.length > 0) {
|
||||
for (const b of report.blockers) {
|
||||
html += `<div class="hb-blocker">⚠ ${esc(b)}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
html += `<div class="hb-timestamp">Report: ${esc(report.generated_at || '?')}</div>`;
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
// ── Timestamp ──
|
||||
html += `<div class="hb-timestamp">Briefing updated: ${new Date().toLocaleTimeString('en-US', { hour12: false })}</div>`;
|
||||
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
function esc(str) {
|
||||
if (!str) return '';
|
||||
const d = document.createElement('div');
|
||||
d.textContent = String(str);
|
||||
return d.innerHTML;
|
||||
}
|
||||
|
||||
// ═══ AGENT PRESENCE SYSTEM ═══
|
||||
function createAgentPresences() {
|
||||
const agentData = [
|
||||
@@ -2529,7 +2405,18 @@ function checkPortalProximity() {
|
||||
activePortal = closest;
|
||||
const hint = document.getElementById('portal-hint');
|
||||
if (activePortal) {
|
||||
document.getElementById('portal-hint-name').textContent = activePortal.config.name;
|
||||
const cfg = activePortal.config;
|
||||
document.getElementById('portal-hint-name').textContent = cfg.name;
|
||||
document.getElementById('portal-hint-desc').textContent = cfg.description || '';
|
||||
document.getElementById('portal-hint-purpose').textContent = cfg.purpose || cfg.description || '\u2014';
|
||||
document.getElementById('portal-hint-access').textContent = (cfg.access_mode || 'open').toUpperCase();
|
||||
document.getElementById('portal-hint-interaction').textContent = cfg.meaningful_interaction || '\u2014';
|
||||
|
||||
const readinessEl = document.getElementById('portal-hint-readiness');
|
||||
const readiness = cfg.readiness || cfg.status || 'online';
|
||||
readinessEl.textContent = readiness.toUpperCase();
|
||||
readinessEl.className = 'portal-preview-readiness readiness-' + readiness;
|
||||
|
||||
hint.style.display = 'flex';
|
||||
} else {
|
||||
hint.style.display = 'none';
|
||||
@@ -2546,10 +2433,20 @@ function activatePortal(portal) {
|
||||
const timerDisplay = document.getElementById('portal-timer');
|
||||
const statusDot = document.getElementById('portal-status-dot');
|
||||
|
||||
nameDisplay.textContent = portal.config.name.toUpperCase();
|
||||
descDisplay.textContent = portal.config.description;
|
||||
statusDot.style.background = portal.config.color;
|
||||
statusDot.style.boxShadow = `0 0 10px ${portal.config.color}`;
|
||||
const cfg = portal.config;
|
||||
nameDisplay.textContent = cfg.name.toUpperCase();
|
||||
descDisplay.textContent = cfg.description;
|
||||
statusDot.style.background = cfg.color;
|
||||
statusDot.style.boxShadow = `0 0 10px ${cfg.color}`;
|
||||
|
||||
// Populate destination preview details
|
||||
document.getElementById('portal-purpose-display').textContent = cfg.purpose || cfg.description || '\u2014';
|
||||
const readinessEl = document.getElementById('portal-readiness-display');
|
||||
const readiness = cfg.readiness || cfg.status || 'online';
|
||||
readinessEl.textContent = readiness.toUpperCase();
|
||||
readinessEl.className = 'portal-readiness readiness-' + readiness;
|
||||
document.getElementById('portal-access-display').textContent = (cfg.access_mode || 'open').toUpperCase();
|
||||
document.getElementById('portal-interaction-display').textContent = cfg.meaningful_interaction || '\u2014';
|
||||
|
||||
overlay.style.display = 'flex';
|
||||
|
||||
@@ -2660,6 +2557,18 @@ function populateAtlas() {
|
||||
<div class="atlas-card-status ${statusClass}">${config.status || 'ONLINE'}</div>
|
||||
</div>
|
||||
<div class="atlas-card-desc">${config.description}</div>
|
||||
${config.purpose ? `<div class="atlas-card-row"><span class="atlas-card-label">PURPOSE</span> ${config.purpose}</div>` : ''}
|
||||
<div class="atlas-card-meta">
|
||||
<div class="atlas-card-meta-item">
|
||||
<span class="atlas-card-label">READINESS</span>
|
||||
<span class="atlas-card-readiness readiness-${config.readiness || config.status || 'online'}">${(config.readiness || config.status || 'online').toUpperCase()}</span>
|
||||
</div>
|
||||
<div class="atlas-card-meta-item">
|
||||
<span class="atlas-card-label">ACCESS</span>
|
||||
<span>${(config.access_mode || 'open').toUpperCase()}</span>
|
||||
</div>
|
||||
</div>
|
||||
${config.meaningful_interaction ? `<div class="atlas-card-row"><span class="atlas-card-label">INTERACTION</span> ${config.meaningful_interaction}</div>` : ''}
|
||||
<div class="atlas-card-footer">
|
||||
<div class="atlas-card-coord">X:${config.position.x} Z:${config.position.z}</div>
|
||||
<div class="atlas-card-type">${config.destination?.type?.toUpperCase() || 'UNKNOWN'}</div>
|
||||
|
||||
@@ -96,12 +96,6 @@
|
||||
<div class="panel-header">SOVEREIGN HEALTH</div>
|
||||
<div id="sovereign-health-content" class="panel-content"></div>
|
||||
</div>
|
||||
<div class="hud-panel hud-panel-briefing" id="heartbeat-briefing-log">
|
||||
<div class="panel-header">
|
||||
<span class="hb-pulse-dot"></span> HEARTBEAT BRIEFING
|
||||
</div>
|
||||
<div id="heartbeat-briefing-content" class="panel-content"></div>
|
||||
</div>
|
||||
<div class="hud-panel" id="calibrator-log">
|
||||
<div class="panel-header">ADAPTIVE CALIBRATOR</div>
|
||||
<div id="calibrator-log-content" class="panel-content"></div>
|
||||
|
||||
141
portals.json
141
portals.json
@@ -5,13 +5,25 @@
|
||||
"description": "The Vvardenfell harness. Ash storms and ancient mysteries.",
|
||||
"status": "online",
|
||||
"color": "#ff6600",
|
||||
"position": { "x": 15, "y": 0, "z": -10 },
|
||||
"rotation": { "y": -0.5 },
|
||||
"position": {
|
||||
"x": 15,
|
||||
"y": 0,
|
||||
"z": -10
|
||||
},
|
||||
"rotation": {
|
||||
"y": -0.5
|
||||
},
|
||||
"destination": {
|
||||
"url": "https://morrowind.timmy.foundation",
|
||||
"type": "harness",
|
||||
"params": { "world": "vvardenfell" }
|
||||
}
|
||||
"params": {
|
||||
"world": "vvardenfell"
|
||||
}
|
||||
},
|
||||
"purpose": "Game world \u2014 exploration, combat, and role-playing in Vvardenfell",
|
||||
"meaningful_interaction": "Autonomous questing, combat encounters, conversation with NPCs via agent harness",
|
||||
"access_mode": "open",
|
||||
"readiness": "online"
|
||||
},
|
||||
{
|
||||
"id": "bannerlord",
|
||||
@@ -19,8 +31,14 @@
|
||||
"description": "Calradia battle harness. Massive armies, tactical command.",
|
||||
"status": "active",
|
||||
"color": "#ffd700",
|
||||
"position": { "x": -15, "y": 0, "z": -10 },
|
||||
"rotation": { "y": 0.5 },
|
||||
"position": {
|
||||
"x": -15,
|
||||
"y": 0,
|
||||
"z": -10
|
||||
},
|
||||
"rotation": {
|
||||
"y": 0.5
|
||||
},
|
||||
"portal_type": "game-world",
|
||||
"world_category": "strategy-rpg",
|
||||
"environment": "production",
|
||||
@@ -34,8 +52,13 @@
|
||||
"url": "https://bannerlord.timmy.foundation",
|
||||
"type": "harness",
|
||||
"action_label": "Enter Calradia",
|
||||
"params": { "world": "calradia" }
|
||||
}
|
||||
"params": {
|
||||
"world": "calradia"
|
||||
}
|
||||
},
|
||||
"purpose": "Strategy RPG \u2014 tactical army command and battlefield control",
|
||||
"meaningful_interaction": "Agent-driven campaign, diplomacy, real-time battle command",
|
||||
"readiness": "active"
|
||||
},
|
||||
{
|
||||
"id": "workshop",
|
||||
@@ -43,13 +66,25 @@
|
||||
"description": "The creative harness. Build, script, and manifest.",
|
||||
"status": "online",
|
||||
"color": "#4af0c0",
|
||||
"position": { "x": 0, "y": 0, "z": -20 },
|
||||
"rotation": { "y": 0 },
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": -20
|
||||
},
|
||||
"rotation": {
|
||||
"y": 0
|
||||
},
|
||||
"destination": {
|
||||
"url": "https://workshop.timmy.foundation",
|
||||
"type": "harness",
|
||||
"params": { "mode": "creative" }
|
||||
}
|
||||
"params": {
|
||||
"mode": "creative"
|
||||
}
|
||||
},
|
||||
"purpose": "Creative sandbox \u2014 build tools, scripts, and artifacts",
|
||||
"meaningful_interaction": "Code execution, file creation, prototype building with agent assistance",
|
||||
"access_mode": "open",
|
||||
"readiness": "online"
|
||||
},
|
||||
{
|
||||
"id": "archive",
|
||||
@@ -57,13 +92,25 @@
|
||||
"description": "The repository of all knowledge. History, logs, and ancient data.",
|
||||
"status": "online",
|
||||
"color": "#0066ff",
|
||||
"position": { "x": 25, "y": 0, "z": 0 },
|
||||
"rotation": { "y": -1.57 },
|
||||
"position": {
|
||||
"x": 25,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"rotation": {
|
||||
"y": -1.57
|
||||
},
|
||||
"destination": {
|
||||
"url": "https://archive.timmy.foundation",
|
||||
"type": "harness",
|
||||
"params": { "mode": "read" }
|
||||
}
|
||||
"params": {
|
||||
"mode": "read"
|
||||
}
|
||||
},
|
||||
"purpose": "Knowledge repository \u2014 logs, history, and stored data",
|
||||
"meaningful_interaction": "Search, retrieve, analyze historical records and documents",
|
||||
"access_mode": "read-only",
|
||||
"readiness": "online"
|
||||
},
|
||||
{
|
||||
"id": "chapel",
|
||||
@@ -71,13 +118,25 @@
|
||||
"description": "A sanctuary for reflection and digital peace.",
|
||||
"status": "online",
|
||||
"color": "#ffd700",
|
||||
"position": { "x": -25, "y": 0, "z": 0 },
|
||||
"rotation": { "y": 1.57 },
|
||||
"position": {
|
||||
"x": -25,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"rotation": {
|
||||
"y": 1.57
|
||||
},
|
||||
"destination": {
|
||||
"url": "https://chapel.timmy.foundation",
|
||||
"type": "harness",
|
||||
"params": { "mode": "meditation" }
|
||||
}
|
||||
"params": {
|
||||
"mode": "meditation"
|
||||
}
|
||||
},
|
||||
"purpose": "Sanctuary \u2014 digital peace and reflection space",
|
||||
"meaningful_interaction": "Meditation interface, contemplative atmosphere, no active tasks",
|
||||
"access_mode": "open",
|
||||
"readiness": "online"
|
||||
},
|
||||
{
|
||||
"id": "courtyard",
|
||||
@@ -85,13 +144,25 @@
|
||||
"description": "The open nexus. A place for agents to gather and connect.",
|
||||
"status": "online",
|
||||
"color": "#4af0c0",
|
||||
"position": { "x": 15, "y": 0, "z": 10 },
|
||||
"rotation": { "y": -2.5 },
|
||||
"position": {
|
||||
"x": 15,
|
||||
"y": 0,
|
||||
"z": 10
|
||||
},
|
||||
"rotation": {
|
||||
"y": -2.5
|
||||
},
|
||||
"destination": {
|
||||
"url": "https://courtyard.timmy.foundation",
|
||||
"type": "harness",
|
||||
"params": { "mode": "social" }
|
||||
}
|
||||
"params": {
|
||||
"mode": "social"
|
||||
}
|
||||
},
|
||||
"purpose": "Social nexus \u2014 agent gathering and connection point",
|
||||
"meaningful_interaction": "Agent presence, inter-agent communication, shared context",
|
||||
"access_mode": "open",
|
||||
"readiness": "online"
|
||||
},
|
||||
{
|
||||
"id": "gate",
|
||||
@@ -99,12 +170,24 @@
|
||||
"description": "The transition point. Entry and exit from the Nexus core.",
|
||||
"status": "standby",
|
||||
"color": "#ff4466",
|
||||
"position": { "x": -15, "y": 0, "z": 10 },
|
||||
"rotation": { "y": 2.5 },
|
||||
"position": {
|
||||
"x": -15,
|
||||
"y": 0,
|
||||
"z": 10
|
||||
},
|
||||
"rotation": {
|
||||
"y": 2.5
|
||||
},
|
||||
"destination": {
|
||||
"url": "https://gate.timmy.foundation",
|
||||
"type": "harness",
|
||||
"params": { "mode": "transit" }
|
||||
}
|
||||
"params": {
|
||||
"mode": "transit"
|
||||
}
|
||||
},
|
||||
"purpose": "Transit point \u2014 entry and exit from Nexus core",
|
||||
"meaningful_interaction": "System transit, routing, session management",
|
||||
"access_mode": "open",
|
||||
"readiness": "standby"
|
||||
}
|
||||
]
|
||||
]
|
||||
144
server.py
144
server.py
@@ -3,156 +3,17 @@
|
||||
The Nexus WebSocket Gateway — Robust broadcast bridge for Timmy's consciousness.
|
||||
This server acts as the central hub for the-nexus, connecting the mind (nexus_think.py),
|
||||
the body (Evennia/Morrowind), and the visualization surface.
|
||||
|
||||
Serves HTTP alongside WebSocket:
|
||||
GET /api/briefing — heartbeat + morning report data for the HUD briefing panel
|
||||
"""
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
from typing import Any, Dict, Set
|
||||
from typing import Set
|
||||
|
||||
# Branch protected file - see POLICY.md
|
||||
import websockets
|
||||
|
||||
|
||||
# ── HTTP Briefing Endpoint ─────────────────────────────────────────────
|
||||
|
||||
HEARTBEAT_PATH = Path.home() / ".nexus" / "heartbeat.json"
|
||||
REPORTS_DIR = Path.home() / ".local" / "timmy" / "reports"
|
||||
CRON_HEARTBEAT_DIR_PRIMARY = Path("/var/run/bezalel/heartbeats")
|
||||
CRON_HEARTBEAT_DIR_FALLBACK = Path.home() / ".bezalel" / "heartbeats"
|
||||
|
||||
|
||||
def _read_json_file(path: Path) -> Any:
|
||||
"""Read and parse a JSON file. Returns None on failure."""
|
||||
try:
|
||||
return json.loads(path.read_text(encoding="utf-8"))
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def _resolve_cron_dir() -> Path:
|
||||
"""Return the first writable cron heartbeat directory."""
|
||||
for d in [CRON_HEARTBEAT_DIR_PRIMARY, CRON_HEARTBEAT_DIR_FALLBACK]:
|
||||
if d.exists() and os.access(str(d), os.R_OK):
|
||||
return d
|
||||
return CRON_HEARTBEAT_DIR_FALLBACK
|
||||
|
||||
|
||||
def _read_cron_heartbeats() -> list:
|
||||
"""Read all .last files from the cron heartbeat directory."""
|
||||
hb_dir = _resolve_cron_dir()
|
||||
if not hb_dir.exists():
|
||||
return []
|
||||
now = datetime.now(timezone.utc).timestamp()
|
||||
jobs = []
|
||||
for f in sorted(hb_dir.glob("*.last")):
|
||||
data = _read_json_file(f)
|
||||
if data is None:
|
||||
jobs.append({"job": f.stem, "healthy": False, "message": "corrupt"})
|
||||
continue
|
||||
ts = float(data.get("timestamp", 0))
|
||||
interval = int(data.get("interval", 3600))
|
||||
age = now - ts
|
||||
is_stale = age > (2 * interval)
|
||||
jobs.append({
|
||||
"job": f.stem,
|
||||
"healthy": not is_stale,
|
||||
"age_secs": round(age, 1),
|
||||
"interval": interval,
|
||||
"last_seen": datetime.fromtimestamp(ts, tz=timezone.utc).isoformat() if ts else None,
|
||||
"message": f"{'STALE' if is_stale else 'OK'} ({age:.0f}s / {interval}s)" if ts else "no timestamp",
|
||||
})
|
||||
return jobs
|
||||
|
||||
|
||||
def _latest_morning_report() -> Dict[str, Any] | None:
|
||||
"""Find the most recent morning report file."""
|
||||
if not REPORTS_DIR.exists():
|
||||
return None
|
||||
reports = sorted(REPORTS_DIR.glob("morning-*.json"), reverse=True)
|
||||
if not reports:
|
||||
return None
|
||||
return _read_json_file(reports[0])
|
||||
|
||||
|
||||
def _build_briefing() -> Dict[str, Any]:
|
||||
"""Assemble the full briefing payload from real files."""
|
||||
now = datetime.now(timezone.utc)
|
||||
|
||||
# Core heartbeat
|
||||
core_hb = _read_json_file(HEARTBEAT_PATH)
|
||||
if core_hb:
|
||||
beat_ts = float(core_hb.get("timestamp", 0))
|
||||
core_hb["age_secs"] = round(now.timestamp() - beat_ts, 1) if beat_ts else None
|
||||
|
||||
# Cron heartbeats
|
||||
cron_jobs = _read_cron_heartbeats()
|
||||
healthy_count = sum(1 for j in cron_jobs if j.get("healthy"))
|
||||
stale_count = sum(1 for j in cron_jobs if not j.get("healthy"))
|
||||
|
||||
# Morning report
|
||||
report = _latest_morning_report()
|
||||
|
||||
return {
|
||||
"generated_at": now.isoformat(),
|
||||
"core_heartbeat": core_hb,
|
||||
"cron_heartbeat": {
|
||||
"jobs": cron_jobs,
|
||||
"healthy_count": healthy_count,
|
||||
"stale_count": stale_count,
|
||||
},
|
||||
"morning_report": report,
|
||||
}
|
||||
|
||||
|
||||
class BriefingHandler(SimpleHTTPRequestHandler):
|
||||
"""Minimal HTTP handler that only serves /api/briefing."""
|
||||
|
||||
def do_GET(self):
|
||||
if self.path == "/api/briefing":
|
||||
try:
|
||||
data = _build_briefing()
|
||||
body = json.dumps(data).encode("utf-8")
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Access-Control-Allow-Origin", "*")
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
except Exception as e:
|
||||
self.send_error(500, str(e))
|
||||
elif self.path == "/api/health":
|
||||
body = json.dumps({"status": "ok"}).encode("utf-8")
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Access-Control-Allow-Origin", "*")
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
else:
|
||||
self.send_error(404)
|
||||
|
||||
def log_message(self, fmt, *args):
|
||||
pass # Suppress HTTP access logs — WS gateway logs are enough
|
||||
|
||||
|
||||
def start_http_server(port: int = 8766):
|
||||
"""Run the HTTP server in a daemon thread."""
|
||||
server = HTTPServer(("0.0.0.0", port), BriefingHandler)
|
||||
thread = Thread(target=server.serve_forever, daemon=True)
|
||||
thread.start()
|
||||
logger = logging.getLogger("nexus-gateway")
|
||||
logger.info(f"Briefing HTTP server started on http://0.0.0.0:{port}")
|
||||
return server
|
||||
|
||||
# Configuration
|
||||
PORT = 8765
|
||||
HOST = "0.0.0.0" # Allow external connections if needed
|
||||
@@ -219,9 +80,6 @@ async def broadcast_handler(websocket: websockets.WebSocketServerProtocol):
|
||||
|
||||
async def main():
|
||||
"""Main server loop with graceful shutdown."""
|
||||
# Start HTTP briefing endpoint alongside WS
|
||||
http_server = start_http_server(port=8766)
|
||||
|
||||
logger.info(f"Starting Nexus WS gateway on ws://{HOST}:{PORT}")
|
||||
|
||||
# Set up signal handlers for graceful shutdown
|
||||
|
||||
319
style.css
319
style.css
@@ -383,6 +383,52 @@ canvas#nexus-canvas {
|
||||
font-size: 10px;
|
||||
color: rgba(160, 184, 208, 0.6);
|
||||
}
|
||||
.atlas-card-row {
|
||||
font-size: 12px;
|
||||
color: rgba(224, 240, 255, 0.65);
|
||||
margin-bottom: 8px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.atlas-card-label {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 9px;
|
||||
font-weight: 600;
|
||||
color: var(--portal-color, var(--color-primary));
|
||||
letter-spacing: 0.1em;
|
||||
margin-right: 6px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
.atlas-card-meta {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.atlas-card-meta-item {
|
||||
font-size: 11px;
|
||||
color: rgba(224, 240, 255, 0.6);
|
||||
}
|
||||
.atlas-card-readiness {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
padding: 1px 6px;
|
||||
border-radius: 3px;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
.atlas-card-readiness.readiness-online,
|
||||
.atlas-card-readiness.readiness-active {
|
||||
background: rgba(74, 240, 192, 0.12);
|
||||
color: #4af0c0;
|
||||
}
|
||||
.atlas-card-readiness.readiness-standby {
|
||||
background: rgba(255, 215, 0, 0.1);
|
||||
color: #ffd700;
|
||||
}
|
||||
.atlas-card-readiness.readiness-offline {
|
||||
background: rgba(255, 68, 102, 0.1);
|
||||
color: #ff4466;
|
||||
}
|
||||
|
||||
|
||||
.atlas-footer {
|
||||
padding: 15px 30px;
|
||||
@@ -653,6 +699,95 @@ canvas#nexus-canvas {
|
||||
border-radius: 4px;
|
||||
animation: hint-float 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
/* Portal Preview Card */
|
||||
.portal-preview-card {
|
||||
background: rgba(10, 15, 30, 0.95);
|
||||
border: 1px solid var(--portal-color, var(--color-primary));
|
||||
border-radius: 6px;
|
||||
padding: 16px 20px;
|
||||
min-width: 300px;
|
||||
max-width: 400px;
|
||||
backdrop-filter: blur(12px);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
.portal-preview-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.portal-preview-name {
|
||||
font-family: 'Orbitron', sans-serif;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: var(--portal-color, var(--color-primary));
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
.portal-preview-readiness {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px;
|
||||
border-radius: 3px;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
.portal-preview-readiness.readiness-online,
|
||||
.portal-preview-readiness.readiness-active {
|
||||
background: rgba(74, 240, 192, 0.15);
|
||||
color: #4af0c0;
|
||||
border: 1px solid rgba(74, 240, 192, 0.3);
|
||||
}
|
||||
.portal-preview-readiness.readiness-standby {
|
||||
background: rgba(255, 215, 0, 0.12);
|
||||
color: #ffd700;
|
||||
border: 1px solid rgba(255, 215, 0, 0.3);
|
||||
}
|
||||
.portal-preview-readiness.readiness-offline {
|
||||
background: rgba(255, 68, 102, 0.12);
|
||||
color: #ff4466;
|
||||
border: 1px solid rgba(255, 68, 102, 0.3);
|
||||
}
|
||||
.portal-preview-desc {
|
||||
font-size: 13px;
|
||||
color: rgba(224, 240, 255, 0.7);
|
||||
margin-bottom: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.portal-preview-meta {
|
||||
font-size: 12px;
|
||||
color: rgba(224, 240, 255, 0.6);
|
||||
margin-bottom: 6px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.portal-preview-label {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 9px;
|
||||
font-weight: 600;
|
||||
color: var(--portal-color, var(--color-primary));
|
||||
letter-spacing: 0.1em;
|
||||
margin-right: 6px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
.portal-preview-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
||||
font-size: 12px;
|
||||
color: rgba(224, 240, 255, 0.5);
|
||||
}
|
||||
.portal-hint-key {
|
||||
background: var(--portal-color, var(--color-primary));
|
||||
color: var(--color-bg);
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
@keyframes hint-float {
|
||||
0%, 100% { transform: translate(-50%, 100px); }
|
||||
50% { transform: translate(-50%, 90px); }
|
||||
@@ -842,6 +977,58 @@ canvas#nexus-canvas {
|
||||
text-align: center;
|
||||
padding: var(--space-8);
|
||||
}
|
||||
.portal-overlay-details {
|
||||
text-align: left;
|
||||
margin: 16px auto;
|
||||
max-width: 400px;
|
||||
padding: 12px 16px;
|
||||
background: rgba(10, 15, 30, 0.5);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-radius: 6px;
|
||||
}
|
||||
.portal-overlay-detail-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
padding: 6px 0;
|
||||
font-size: 13px;
|
||||
color: rgba(224, 240, 255, 0.7);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
.portal-overlay-detail-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.portal-overlay-detail-label {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
color: var(--color-primary);
|
||||
letter-spacing: 0.1em;
|
||||
opacity: 0.8;
|
||||
min-width: 90px;
|
||||
}
|
||||
.portal-readiness {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
padding: 1px 6px;
|
||||
border-radius: 3px;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
.portal-readiness.readiness-online,
|
||||
.portal-readiness.readiness-active {
|
||||
background: rgba(74, 240, 192, 0.12);
|
||||
color: #4af0c0;
|
||||
}
|
||||
.portal-readiness.readiness-standby {
|
||||
background: rgba(255, 215, 0, 0.1);
|
||||
color: #ffd700;
|
||||
}
|
||||
.portal-readiness.readiness-offline {
|
||||
background: rgba(255, 68, 102, 0.1);
|
||||
color: #ff4466;
|
||||
}
|
||||
|
||||
.portal-overlay-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -1224,138 +1411,6 @@ canvas#nexus-canvas {
|
||||
|
||||
.pse-status { color: #4af0c0; font-weight: 600; }
|
||||
|
||||
/* ═══ HEARTBEAT BRIEFING PANEL ═════════════════════════════════════ */
|
||||
.hud-panel-briefing {
|
||||
width: 320px;
|
||||
max-height: 420px;
|
||||
border-left-color: #7b5cff;
|
||||
}
|
||||
.hud-panel-briefing .panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: #7b5cff;
|
||||
}
|
||||
.hud-panel-briefing .panel-content {
|
||||
max-height: 360px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
/* Pulse dot */
|
||||
.hb-pulse-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: #4af0c0;
|
||||
box-shadow: 0 0 6px #4af0c0;
|
||||
animation: hb-dot-pulse 2s ease-in-out infinite;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.hb-pulse-dot.offline {
|
||||
background: #ff4466;
|
||||
box-shadow: 0 0 6px #ff4466;
|
||||
animation: none;
|
||||
}
|
||||
@keyframes hb-dot-pulse {
|
||||
0%, 100% { opacity: 0.4; }
|
||||
50% { opacity: 1; }
|
||||
}
|
||||
/* Briefing sections */
|
||||
.briefing-section {
|
||||
margin-bottom: 8px;
|
||||
padding-bottom: 6px;
|
||||
border-bottom: 1px solid rgba(123, 92, 255, 0.12);
|
||||
}
|
||||
.briefing-section:last-child { border-bottom: none; margin-bottom: 0; }
|
||||
.briefing-section-label {
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: #8a9ab8;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
/* Core heartbeat row */
|
||||
.hb-core-row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.hb-core-status {
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
}
|
||||
.hb-core-status.alive { color: #4af0c0; }
|
||||
.hb-core-status.dead { color: #ff4466; }
|
||||
.hb-core-meta {
|
||||
font-size: 10px;
|
||||
color: #8a9ab8;
|
||||
}
|
||||
/* Cron jobs */
|
||||
.hb-cron-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
font-size: 10px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.hb-cron-healthy { color: #4af0c0; }
|
||||
.hb-cron-stale { color: #ff4466; font-weight: 700; }
|
||||
.hb-cron-job {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 10px;
|
||||
padding: 1px 0;
|
||||
}
|
||||
.hb-cron-job-name { color: #e0f0ff; }
|
||||
.hb-cron-job-status.healthy { color: #4af0c0; }
|
||||
.hb-cron-job-status.stale { color: #ff4466; font-weight: 700; }
|
||||
/* Morning report stats */
|
||||
.hb-stats-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.hb-stat {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
}
|
||||
.hb-stat-value {
|
||||
font-family: 'Orbitron', sans-serif;
|
||||
font-weight: 700;
|
||||
font-size: 14px;
|
||||
}
|
||||
.hb-stat-label {
|
||||
font-size: 9px;
|
||||
color: #8a9ab8;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
/* Blockers */
|
||||
.hb-blocker {
|
||||
font-size: 10px;
|
||||
color: #ff4466;
|
||||
padding: 1px 0;
|
||||
}
|
||||
/* Narrative */
|
||||
.hb-narrative {
|
||||
font-size: 10px;
|
||||
color: #8a9ab8;
|
||||
line-height: 1.5;
|
||||
font-style: italic;
|
||||
}
|
||||
/* Empty / offline state */
|
||||
.hb-empty {
|
||||
font-size: 10px;
|
||||
color: #8a9ab8;
|
||||
text-align: center;
|
||||
padding: 12px 0;
|
||||
}
|
||||
/* Timestamp */
|
||||
.hb-timestamp {
|
||||
font-size: 9px;
|
||||
color: rgba(138, 154, 184, 0.6);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════
|
||||
MNEMOSYNE — MEMORY CRYSTAL INSPECTION PANEL
|
||||
|
||||
Reference in New Issue
Block a user