[gemini] Implement mobile heartbeat status page (#416) (#440)
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>
This commit was merged in pull request #440.
This commit is contained in:
2026-03-24 18:16:08 +00:00
committed by Timmy Time
parent e970746c28
commit 8580c6754b
2 changed files with 95 additions and 10 deletions

View File

@@ -121,10 +121,28 @@
</div>
<script>
const GITEA_API_URL = 'http://143.198.27.163:3000/api/v1/repos/Timmy_Foundation/the-nexus/commits?limit=10';
const GITEA_TOKEN = 'dc0517a965226b7a0c5ffdd961b1ba26521ac592';
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 API_STATUS_FILE = './api/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 {
@@ -141,21 +159,51 @@
async function fetchAgentStatuses() {
try {
const response = await fetch(API_STATUS_FILE);
const data = await response.json();
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
data.agents.forEach(agent => {
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(); // working, idle, dead
const statusClass = agent.status.toLowerCase();
agentItem.innerHTML = `
<span class="status-label">${agent.name.toUpperCase()}:</span>
<span class="status-value agent-status ${statusClass}">${agent.status.toUpperCase()}</span>
<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');
@@ -165,7 +213,7 @@
async function fetchLastCommits() {
try {
const response = await fetch(GITEA_API_URL, {
const response = await fetch(GITEA_API_URL + '/commits?limit=5', { // Limit to 5 for lightweight page
headers: {
'Authorization': `token ${GITEA_TOKEN}`
}
@@ -200,6 +248,37 @@
}
}
async function fetchWeather() {
try {
const url = `https://api.open-meteo.com/v1/forecast?latitude=${WEATHER_LAT}&longitude=${WEATHER_LON}&current=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();
}
@@ -208,6 +287,8 @@
await fetchSovereigntyStatus();
await fetchAgentStatuses();
await fetchLastCommits();
await fetchWeather();
await fetchBtcBlock();
updateTimestamp();
}

4
sovereignty-status.json Normal file
View File

@@ -0,0 +1,4 @@
{
"score": 75,
"label": "Stable"
}