Some checks failed
Deploy Nexus / deploy (push) Failing after 3s
Co-authored-by: Google AI Agent <gemini@hermes.local> Co-committed-by: Google AI Agent <gemini@hermes.local>
303 lines
12 KiB
HTML
303 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="refresh" content="60">
|
|
<title>Nexus Heartbeat</title>
|
|
<style>
|
|
body {
|
|
font-family: 'Courier New', monospace;
|
|
background-color: #0a0a0a;
|
|
color: #00ff00;
|
|
margin: 0;
|
|
padding: 10px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
box-sizing: border-box;
|
|
line-height: 1.4;
|
|
}
|
|
.container {
|
|
width: 100%;
|
|
max-width: 375px; /* Mobile screen width */
|
|
padding: 10px;
|
|
border: 1px solid #006600;
|
|
box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
|
|
margin-bottom: 10px;
|
|
}
|
|
h1 {
|
|
color: #00ffff;
|
|
text-align: center;
|
|
font-size: 1.5em;
|
|
margin-top: 5px;
|
|
margin-bottom: 15px;
|
|
text-shadow: 0 0 5px rgba(0, 255, 255, 0.7);
|
|
}
|
|
.status-section {
|
|
margin-bottom: 15px;
|
|
}
|
|
.status-section h2 {
|
|
color: #00ffcc;
|
|
font-size: 1.2em;
|
|
border-bottom: 1px dashed #003300;
|
|
padding-bottom: 5px;
|
|
margin-top: 0;
|
|
margin-bottom: 10px;
|
|
}
|
|
.status-item {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-bottom: 5px;
|
|
}
|
|
.status-label {
|
|
color: #00ccff;
|
|
flex-shrink: 0;
|
|
margin-right: 10px;
|
|
}
|
|
.status-value {
|
|
color: #00ff00;
|
|
text-align: right;
|
|
word-break: break-all;
|
|
}
|
|
.agent-status.working { color: #00ff00; }
|
|
.agent-status.idle { color: #ffff00; }
|
|
.agent-status.dead { color: #ff0000; }
|
|
|
|
.last-updated {
|
|
text-align: center;
|
|
font-size: 0.8em;
|
|
color: #009900;
|
|
margin-top: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>NEXUS HEARTBEAT</h1>
|
|
|
|
<div class="status-section">
|
|
<h2>SOVEREIGNTY STATUS</h2>
|
|
<div class="status-item">
|
|
<span class="status-label">SCORE:</span>
|
|
<span class="status-value" id="sovereignty-score">LOADING...</span>
|
|
</div>
|
|
<div class="status-item">
|
|
<span class="status-label">LABEL:</span>
|
|
<span class="status-value" id="sovereignty-label">LOADING...</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="status-section">
|
|
<h2>AGENT STATUSES</h2>
|
|
<div id="agent-statuses">
|
|
<div class="status-item"><span class="status-label">LOADING...</span><span class="status-value"></span></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="status-section">
|
|
<h2>LAST COMMITS</h2>
|
|
<div id="last-commits">
|
|
<div class="status-item"><span class="status-label">LOADING...</span><span class="status-value"></span></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="status-section">
|
|
<h2>ENVIRONMENTALS</h2>
|
|
<div class="status-item">
|
|
<span class="status-label">WEATHER:</span>
|
|
<span class="status-value" id="weather">UNKNOWN</span>
|
|
</div>
|
|
<div class="status-item">
|
|
<span class="status-label">BTC BLOCK:</span>
|
|
<span class="status-value" id="btc-block">UNKNOWN</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="last-updated" id="last-updated">
|
|
Last Updated: NEVER
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const GITEA_API_URL = 'http://143.198.27.163:3000/api/v1/repos/Timmy_Foundation/the-nexus';
|
|
const GITEA_TOKEN = 'f7bcdaf878d479ad7747873ff6739a9bb89e3f80'; // Updated token
|
|
const SOVEREIGNTY_STATUS_FILE = './sovereignty-status.json';
|
|
|
|
const WEATHER_LAT = 43.2897; // Lempster NH
|
|
const WEATHER_LON = -72.1479; // Lempster NH
|
|
const BTC_API_URL = 'https://blockstream.info/api/blocks/tip/height';
|
|
// For agent status, we'll derive from Gitea commits. This is a placeholder list of expected agents.
|
|
const GITEA_USERS = ['perplexity', 'timmy', 'gemini']; // Example users, needs to be derived dynamically or configured
|
|
|
|
function weatherCodeToLabel(code) {
|
|
// Simplified mapping from Open-Meteo WMO codes to labels
|
|
if (code >= 0 && code <= 1) return { condition: 'Clear', icon: '☀️' };
|
|
if (code >= 2 && code <= 3) return { condition: 'Partly Cloudy', icon: '🌤️' };
|
|
if (code >= 45 && code <= 48) return { condition: 'Foggy', icon: '🌫️' };
|
|
if (code >= 51 && code <= 55) return { condition: 'Drizzle', icon: '🌧️' };
|
|
if (code >= 61 && code <= 65) return { condition: 'Rain', icon: '☔' };
|
|
if (code >= 71 && code <= 75) return { condition: 'Snow', icon: '🌨️' };
|
|
if (code >= 95 && code <= 99) return { condition: 'Thunderstorm', icon: '⛈️' };
|
|
return { condition: 'Unknown', icon: '❓' };
|
|
}
|
|
|
|
|
|
async function fetchSovereigntyStatus() {
|
|
try {
|
|
const response = await fetch(SOVEREIGNTY_STATUS_FILE);
|
|
const data = await response.json();
|
|
document.getElementById('sovereignty-score').textContent = data.score + '%';
|
|
document.getElementById('sovereignty-label').textContent = data.label.toUpperCase();
|
|
} catch (error) {
|
|
console.error('Error fetching sovereignty status:', error);
|
|
document.getElementById('sovereignty-score').textContent = 'ERROR';
|
|
document.getElementById('sovereignty-label').textContent = 'ERROR';
|
|
}
|
|
}
|
|
|
|
async function fetchAgentStatuses() {
|
|
try {
|
|
const response = await fetch(GITEA_API_URL + '/commits?limit=50', {
|
|
headers: {
|
|
'Authorization': `token ${GITEA_TOKEN}`
|
|
}
|
|
});
|
|
const commits = await response.json();
|
|
const agentStatusesDiv = document.getElementById('agent-statuses');
|
|
agentStatusesDiv.innerHTML = ''; // Clear previous statuses
|
|
|
|
const agentActivity = {};
|
|
const now = Date.now();
|
|
const twentyFourHours = 24 * 60 * 60 * 1000;
|
|
|
|
// Initialize all known agents as idle
|
|
GITEA_USERS.forEach(user => {
|
|
agentActivity[user.toLowerCase()] = { status: 'IDLE', lastCommit: 0 };
|
|
});
|
|
|
|
commits.forEach(commit => {
|
|
const authorName = commit.commit.author.name.toLowerCase();
|
|
const commitTime = new Date(commit.commit.author.date).getTime();
|
|
|
|
if (GITEA_USERS.includes(authorName)) {
|
|
if (commitTime > (now - twentyFourHours)) {
|
|
// If commit within last 24 hours, agent is working
|
|
agentActivity[authorName].status = 'WORKING';
|
|
}
|
|
if (commitTime > agentActivity[authorName].lastCommit) {
|
|
agentActivity[authorName].lastCommit = commitTime;
|
|
}
|
|
}
|
|
});
|
|
|
|
Object.keys(agentActivity).forEach(agentName => {
|
|
const agent = agentActivity[agentName];
|
|
const agentItem = document.createElement('div');
|
|
agentItem.className = 'status-item';
|
|
const statusClass = agent.status.toLowerCase();
|
|
agentItem.innerHTML = `
|
|
<span class="status-label">${agentName.toUpperCase()}:</span>
|
|
<span class="status-value agent-status ${statusClass}">${agent.status}</span>
|
|
`;
|
|
agentStatusesDiv.appendChild(agentItem);
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('Error fetching agent statuses:', error);
|
|
const agentStatusesDiv = document.getElementById('agent-statuses');
|
|
agentStatusesDiv.innerHTML = '<div class="status-item"><span class="status-label">AGENTS:</span><span class="status-value agent-status dead">ERROR</span></div>';
|
|
}
|
|
}
|
|
|
|
async function fetchLastCommits() {
|
|
try {
|
|
const response = await fetch(GITEA_API_URL + '/commits?limit=5', { // Limit to 5 for lightweight page
|
|
headers: {
|
|
'Authorization': `token ${GITEA_TOKEN}`
|
|
}
|
|
});
|
|
const commits = await response.json();
|
|
const lastCommitsDiv = document.getElementById('last-commits');
|
|
lastCommitsDiv.innerHTML = ''; // Clear previous commits
|
|
|
|
if (commits.length === 0) {
|
|
lastCommitsDiv.innerHTML = '<div class="status-item"><span class="status-label">NO COMMITS</span><span class="status-value"></span></div>';
|
|
return;
|
|
}
|
|
|
|
commits.slice(0, 5).forEach(commit => { // Display top 5 recent commits
|
|
const commitItem = document.createElement('div');
|
|
commitItem.className = 'status-item';
|
|
const author = commit.commit.author.name;
|
|
const date = new Date(commit.commit.author.date).toLocaleString();
|
|
const message = commit.commit.message.split('
|
|
')[0]; // First line of commit message
|
|
|
|
commitItem.innerHTML = `
|
|
<span class="status-label">${author}:</span>
|
|
<span class="status-value" title="${message}">${date}</span>
|
|
`;
|
|
lastCommitsDiv.appendChild(commitItem);
|
|
});
|
|
} catch (error) {
|
|
console.error('Error fetching last commits:', error);
|
|
const lastCommitsDiv = document.getElementById('last-commits');
|
|
lastCommitsDiv.innerHTML = '<div class="status-item"><span class="status-label">COMMITS:</span><span class="status-value agent-status dead">ERROR</span></div>';
|
|
}
|
|
}
|
|
|
|
async function fetchWeather() {
|
|
try {
|
|
const url = `https://api.open-meteo.com/v1/forecast?latitude=${WEATHER_LAT}&longitude=${WEATHER_LON}¤t=temperature_2m,weather_code&temperature_unit=fahrenheit&forecast_days=1`;
|
|
const response = await fetch(url);
|
|
const data = await response.json();
|
|
|
|
if (!response.ok) throw new Error('Weather fetch failed');
|
|
|
|
const temp = data.current.temperature_2m;
|
|
const code = data.current.weather_code;
|
|
const { condition } = weatherCodeToLabel(code);
|
|
|
|
document.getElementById('weather').textContent = `${temp}°F, ${condition}`;
|
|
|
|
} catch (error) {
|
|
console.error('Error fetching weather:', error);
|
|
document.getElementById('weather').textContent = 'ERROR';
|
|
}
|
|
}
|
|
|
|
async function fetchBtcBlock() {
|
|
try {
|
|
const response = await fetch(BTC_API_URL);
|
|
const blockHeight = await response.text();
|
|
document.getElementById('btc-block').textContent = blockHeight;
|
|
} catch (error) {
|
|
console.error('Error fetching BTC block:', error);
|
|
document.getElementById('btc-block').textContent = 'ERROR';
|
|
}
|
|
}
|
|
|
|
function updateTimestamp() {
|
|
document.getElementById('last-updated').textContent = 'Last Updated: ' + new Date().toLocaleString();
|
|
}
|
|
|
|
async function updateStatus() {
|
|
await fetchSovereigntyStatus();
|
|
await fetchAgentStatuses();
|
|
await fetchLastCommits();
|
|
await fetchWeather();
|
|
await fetchBtcBlock();
|
|
updateTimestamp();
|
|
}
|
|
|
|
// Initial load
|
|
updateStatus();
|
|
|
|
// Auto-refresh every 60 seconds (already set by meta tag, but this ensures data fetch)
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|