Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix federation probe endpoint, sanitize peer names, add version tracking
Adam Eivy7b9475a0fc5d
diff --git a/client/src/pages/Instances.jsx b/client/src/pages/Instances.jsxindex 4e4984fdaf..9b3ad93987 100644--- a/client/src/pages/Instances.jsx+++ b/client/src/pages/Instances.jsx@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from 'react';import {Network, Plus, Trash2, RefreshCw, Edit3, Check, X,Wifi, WifiOff, CircleDot,- Cpu, HardDrive, Activity, Bot, MonitorSmartphone,+ Cpu, HardDrive, Activity, Bot, MonitorSmartphone, Tag,ArrowUpRight, ArrowDownLeft, ArrowLeftRight} from 'lucide-react';import toast from 'react-hot-toast';@@ -46,10 +46,16 @@ function timeAgo(iso) {return `${Math.floor(hrs / 24)}d ago`;}-function HealthSummary({ health }) {+function HealthSummary({ health, version }) {if (!health) return <span className="text-gray-500 text-xs">No data</span>;return (<div className="grid grid-cols-2 gap-x-4 gap-y-1 text-xs">+ {version && (+ <div className="flex items-center gap-1.5 text-gray-400 col-span-2">+ <Tag size={12} />+ <span>v{version}</span>+ </div>+ )}<div className="flex items-center gap-1.5 text-gray-400"><HardDrive size={12} /><span>Mem {health.system?.memory?.usagePercent ?? '?'}%</span>@@ -347,7 +353,7 @@ function PeerCard({ peer, onRefresh }) {)}</div>- <HealthSummary health={peer.lastHealth} />+ <HealthSummary health={peer.lastHealth} version={peer.version} /><div className="mt-2 text-xs text-gray-600">Last seen: {timeAgo(peer.lastSeen)}diff --git a/server/routes/systemHealth.js b/server/routes/systemHealth.jsindex 5b6e7ab9c3..e26801b1dc 100644--- a/server/routes/systemHealth.js+++ b/server/routes/systemHealth.js@@ -32,12 +32,13 @@ router.get('/health/details', async (req, res) => {const startTime = Date.now();// Gather data in parallel- const [pm2Processes, allApps, cosStatus, self, dbHealth] = await Promise.all([+ const [pm2Processes, allApps, cosStatus, self, dbHealth, version] = await Promise.all([listProcesses().catch(() => []),apps.getAllApps({ includeArchived: false }).catch(() => []),cos.getStatus().catch(() => null),getSelf().catch(() => null),- checkHealth().catch(() => ({ connected: false, hasSchema: false, error: 'Health check failed' }))+ checkHealth().catch(() => ({ connected: false, hasSchema: false, error: 'Health check failed' })),+ getCurrentVersion().catch(() => null)]);// System metrics@@ -139,6 +140,7 @@ router.get('/health/details', async (req, res) => {timestamp: new Date().toISOString(),hostname: os.hostname(),instanceId: self?.instanceId ?? null,+ version,overallHealth,warnings,system: {diff --git a/server/services/instances.js b/server/services/instances.jsindex d97bdc38bd..e0038edb3b 100644--- a/server/services/instances.js+++ b/server/services/instances.js@@ -86,13 +86,20 @@ export async function getPeers() {return data.peers;}+function validName(name, fallback) {+ if (!name || typeof name !== 'string') return fallback;+ const lower = name.trim().toLowerCase();+ if (['undefined', 'nan', 'null', ''].includes(lower)) return fallback;+ return name.trim();+}+export async function addPeer({ address, port = DEFAULT_PEER_PORT, name }) {const peer = await withData(async (data) => {const entry = {id: crypto.randomUUID(),address,port,- name: name || address,+ name: validName(name, address),instanceId: null,addedAt: new Date().toISOString(),lastSeen: null,@@ -138,24 +145,26 @@ export async function updatePeer(id, updates) {// --- Probing ---export async function probePeer(peer) {- const url = `http://${peer.address}:${peer.port}/api/health/system`;+ const baseUrl = `http://${peer.address}:${peer.port}`;const controller = new AbortController();const timeout = setTimeout(() => controller.abort(), PROBE_TIMEOUT_MS);const previousStatus = peer.status;- let status, lastHealth, lastSeen, remoteInstanceId, remoteApps;+ let status, lastHealth, lastSeen, remoteInstanceId, remoteVersion, remoteApps;try {- const res = await fetch(url, { signal: controller.signal });- if (!res.ok) throw new Error(`HTTP ${res.status}`);- const json = await res.json();+ // Fetch health details and apps in parallel+ const [healthRes, appsRes] = await Promise.all([+ fetch(`${baseUrl}/api/system/health/details`, { signal: controller.signal }),+ fetch(`${baseUrl}/api/apps`, { signal: controller.signal }).catch(() => null)+ ]);+ if (!healthRes.ok) throw new Error(`HTTP ${healthRes.status}`);+ const json = await healthRes.json();status = 'online';lastHealth = json;lastSeen = new Date().toISOString();remoteInstanceId = json.instanceId ?? null;+ remoteVersion = json.version ?? null;- // Fetch apps from the peer (piggybacks on probe cycle)- const appsUrl = `http://${peer.address}:${peer.port}/api/apps`;- const appsRes = await fetch(appsUrl, { signal: controller.signal }).catch(() => null);if (appsRes?.ok) {const appsJson = await appsRes.json().catch(() => null);const appsList = Array.isArray(appsJson) ? appsJson : appsJson?.apps;@@ -180,6 +189,12 @@ export async function probePeer(peer) {entry.lastHealth = lastHealth;entry.lastApps = remoteApps ?? entry.lastApps ?? null;if (remoteInstanceId) entry.instanceId = remoteInstanceId;+ if (remoteVersion) entry.version = remoteVersion;+ // Auto-update name from hostname if current name is just an IP address+ const remoteHostname = lastHealth?.hostname;+ if (remoteHostname && /^\d+\.\d+\.\d+\.\d+$/.test(entry.name)) {+ entry.name = remoteHostname;+ }return entry;});@@ -248,7 +263,8 @@ export async function handleAnnounce({ address, port, instanceId, name }) {existing.status = 'online';existing.instanceId = instanceId;existing.port = port;- if (name) existing.name = name;+ const sanitized = validName(name, null);+ if (sanitized) existing.name = sanitized;// Mark that this peer has announced to us (inbound connection)existing.directions = existing.directions || [];if (!existing.directions.includes('inbound')) existing.directions.push('inbound');@@ -262,7 +278,7 @@ export async function handleAnnounce({ address, port, instanceId, name }) {id: crypto.randomUUID(),address,port,- name: name || address,+ name: validName(name, address),instanceId,addedAt: new Date().toISOString(),lastSeen: new Date().toISOString(),