Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144import { SubstrateClient } from '../client.js';import { loadConfig, envGet } from '../config.js';import { getLocalLlmDiagnostics } from '../llm.js';import { getCloudflareSummary, getTailscaleSummary } from '../remote.js';import * as d from '../utils/display.js';import { tryReadCommand } from '../utils/shell.js';
export async function statusCommand(opts: { banner?: boolean; key?: string; url?: string }) { const config = loadConfig(opts); const client = new SubstrateClient(config);
if (opts.banner) { d.banner(); d.line(); }
d.header('Aether Substrate'); d.label('API URL', config.apiUrl); d.label('Env File', config.envFile);
// Health check const health = await client.health(); const reachable = health.ok; if (!health.ok) { d.error(`Not reachable at ${config.apiUrl}`); d.info(health.error); }
// Services if (reachable) { d.header('Services'); const svc = await client.services(); if (svc.ok) { for (const [name, service] of Object.entries(svc.data)) { const running = service.status === 'running'; const dot = d.statusDot(running); let detail = running ? d.GREEN(service.status) : d.DIM(service.status);
if (service.url) { detail += d.DIM(` ${service.url}`); } if (name === 'tap' && service.stats) { const s = service.stats; const repos = s.repoCount ?? s.repo_count ?? 0; const records = s.recordCount ?? s.record_count ?? 0; detail += d.DIM(` ${d.formatNumber(repos)} repos · ${d.formatNumber(records)} records`); }
console.log(` ${dot} ${d.BOLD(name.padEnd(12))} ${detail}`); } } else { for (const [name, status] of Object.entries(health.data.services)) { const running = status === 'running'; console.log(` ${d.statusDot(running)} ${d.BOLD(name.padEnd(12))} ${running ? d.GREEN(status) : d.DIM(status)}`); } } }
// Containers const containers = reachable ? await client.containers() : null; if (containers?.ok && containers.data.containers.length > 0) { d.header('Containers'); const rows = containers.data.containers.map(c => [ d.statusDot(c.status === 'running'), d.BOLD(d.truncate(c.name.replace('aetheros-user-', ''), 16)), c.status === 'running' ? d.GREEN(c.status) : d.DIM(c.status), d.DIM(d.truncate(c.image, 20)), ]); d.table(rows); }
// Configuration d.header('Configuration'); const key = envGet('SUBSTRATE_API_KEY', config.envFile); d.label('API Key', key ? `set (${key.length} chars)` : d.RED('not set')); d.label('Docker GID', envGet('DOCKER_GID', config.envFile) || 'not set');
const features = [ envGet('SUBSTRATE_ENABLE_CONTAINERS', config.envFile) === 'true' ? d.GREEN('containers ✓') : d.DIM('containers ○'), envGet('SUBSTRATE_ENABLE_WORKSPACE', config.envFile) === 'true' ? d.GREEN('workspace ✓') : d.DIM('workspace ○'), envGet('SUBSTRATE_ENABLE_TERMINAL_WS', config.envFile) === 'true' ? d.GREEN('host-terminal ✓') : d.DIM('host-terminal ○'), envGet('SUBSTRATE_ENABLE_EMBEDDINGS', config.envFile) === 'true' ? d.GREEN('embeddings ✓') : d.DIM('embeddings ○'), ]; d.label('Features', features.join(' '));
// Endpoints d.label('HTTP', config.apiUrl); try { const hostname = process.platform === 'darwin' ? `${tryReadCommand('scutil', ['--get', 'LocalHostName']) || 'localhost'}.local` : (tryReadCommand('hostname', ['-f']) || 'localhost'); const httpsPort = envGet('SUBSTRATE_HTTPS_PORT', config.envFile) || '8443'; d.label('HTTPS', `https://${hostname}:${httpsPort}`); } catch { // skip HTTPS label if hostname detection fails }
const cloudflare = getCloudflareSummary(config); const tailscale = getTailscaleSummary(); const llm = await getLocalLlmDiagnostics(config.envFile); d.header('Remote Access'); if (cloudflare.configExists) { const cloudflareLabel = cloudflare.hostname ? `https://${cloudflare.hostname}` : 'repo config present'; const source = cloudflare.configSource === 'home' ? 'home config' : 'repo config'; const runtime = cloudflare.running ? 'running locally' : 'not running locally'; d.label('Cloudflare', `${cloudflareLabel} (${source}, ${runtime})`); if (cloudflare.configPath) { d.label('CF Config', cloudflare.configPath); } if (cloudflare.tunnelName) { d.label('CF Name', cloudflare.tunnelName); } if (cloudflare.tunnelId) { d.label('CF Tunnel', cloudflare.tunnelId); } d.label('CF Streaming', cloudflare.disableChunkedEncoding ? d.GREEN('disableChunkedEncoding ✓') : d.RED('disableChunkedEncoding missing')); } else { d.label('Cloudflare', d.DIM('not configured')); if (cloudflare.tunnelName) { d.label('CF Name', cloudflare.tunnelName); } } if (tailscale.connected) { d.label('Tailscale', tailscale.serveHttpsUrl || tailscale.ip); } else if (tailscale.installed) { d.label('Tailscale', d.DIM('installed, not connected')); } else { d.label('Tailscale', d.DIM('not installed')); }
d.header('LLM'); d.label('Gateway', llm.configured.enabled ? d.GREEN('enabled') : d.DIM('disabled')); if (llm.configured.providerName) { d.label('Provider', `${llm.configured.providerName}${llm.configured.model ? ` (${llm.configured.model})` : ''}`); } if (llm.configured.baseUrl) { d.label('Base URL', llm.configured.baseUrl); } d.label('LM Studio', llm.lmstudio.ok ? d.GREEN(`${llm.lmstudio.modelCount} model(s) reachable`) : d.DIM('not reachable')); d.label('Ollama', llm.ollama.ok ? d.GREEN(`${llm.ollama.modelCount} model(s) reachable`) : d.DIM('not reachable'));
d.line();}