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
import { describe, it, expect } from 'vitest';
import {
CAPABILITY_STATUS,
providersRow,
calendarRow,
brainRow,
voiceRow,
networkRow,
genomeRow,
telegramRow,
messagesRow,
appsRow,
buildCapabilityRows,
summarizeCapabilities,
summarizeSetupCapabilities,
} from './capabilityMap.js';
const { OK, WARN, ERROR, UNCONFIGURED } = CAPABILITY_STATUS;
describe('providersRow', () => {
it('is unconfigured with no enabled providers', () => {
expect(providersRow([]).status).toBe(UNCONFIGURED);
expect(providersRow([{ id: 'a', enabled: false }]).status).toBe(UNCONFIGURED);
});
// The server half of the rule the AI Providers page states: a switched-off
// provider is optional, so it must never reach the "need setup" tally or pull
// the row out of OK. The `enabled` filter above is what enforces it.
it('ignores switched-off providers even when their prerequisites are blocked', () => {
const r = providersRow(
[{ id: 'a' }, { id: 'off', enabled: false }],
{ providers: {} },
{ a: { status: 'ready' }, off: { status: 'blocked', reasonCodes: ['runtime'] } },
);
expect(r).toMatchObject({ status: OK, setupComplete: true });
expect(r.detail).toMatchObject({ configured: 1, available: 1, blocked: 0, unknown: 0 });
expect(r.summary).not.toMatch(/need setup/);
});
it('treats never-marked providers as available', () => {
const r = providersRow([{ id: 'a' }, { id: 'b' }], { providers: {} });
expect(r.status).toBe(OK);
expect(r.detail).toEqual({ configured: 2, available: 2, unavailable: 0 });
});
it('warns when some providers are unavailable but at least one is up', () => {
const r = providersRow(
[{ id: 'a' }, { id: 'b' }],
{ providers: { b: { available: false, reason: 'rate-limit' } } },
);
expect(r.status).toBe(WARN);
expect(r.detail).toMatchObject({ available: 1, unavailable: 1 });
});
it('errors when no provider is available', () => {
const r = providersRow([{ id: 'a' }], { providers: { a: { available: false } } });
expect(r.status).toBe(ERROR);
});
it('accepts a bare status map (no providers wrapper)', () => {
const r = providersRow([{ id: 'a' }], { a: { available: false } });
expect(r.status).toBe(ERROR);
});
it('does not call an enabled provider ready when strict prerequisites are blocked or unknown', () => {
const blocked = providersRow(
[{ id: 'a' }],
{ providers: {} },
{ a: { status: 'blocked', reasonCodes: ['runtime'] } },
);
expect(blocked).toMatchObject({ status: ERROR, setupComplete: false });
expect(blocked.detail).toMatchObject({ available: 0, blocked: 1, unknown: 0, setupReady: 0 });
const unavailableProbe = providersRow([{ id: 'a' }], { providers: {} }, null);
expect(unavailableProbe).toMatchObject({ status: WARN, setupComplete: false });
expect(unavailableProbe.detail.unknown).toBe(1);
});
it('marks setup complete when at least one strictly ready provider exists', () => {
const r = providersRow(
[{ id: 'a' }, { id: 'b' }],
{ providers: {} },
{ a: { status: 'ready' }, b: { status: 'blocked' } },
);
expect(r).toMatchObject({ status: WARN, setupComplete: true });
expect(r.detail).toMatchObject({ available: 1, blocked: 1, setupReady: 1 });
});
it('keeps setup complete during a transient provider availability outage', () => {
const r = providersRow(
[{ id: 'a' }],
{ providers: { a: { available: false, reason: 'rate-limit' } } },
{ a: { status: 'ready' } },
);
expect(r).toMatchObject({ status: ERROR, setupComplete: true });
expect(r.detail).toMatchObject({ setupReady: 1, unavailable: 1 });
});
it('requires a local daemon provider to be running with its model ready', () => {
const provider = {
id: 'local',
type: 'api',
endpoint: 'http://localhost:11434/v1',
defaultModel: 'example-model',
};
const blocked = providersRow(
[provider],
{ providers: {} },
{ local: { status: 'ready' } },
{ local: { ready: false } },
);
expect(blocked).toMatchObject({ status: ERROR, setupComplete: false });
expect(blocked.detail).toMatchObject({ blocked: 1, setupReady: 0 });
const ready = providersRow(
[provider],
{ providers: {} },
{ local: { status: 'ready' } },
{ local: { ready: true } },
);
expect(ready).toMatchObject({ status: OK, setupComplete: true });
});
it('keeps local provider readiness unknown when its daemon probe fails', () => {
const r = providersRow(
[{ id: 'local', type: 'api', endpoint: 'http://localhost:11434/v1' }],
{ providers: {} },
{ local: { status: 'ready' } },
null,
);
expect(r).toMatchObject({ status: WARN, setupComplete: false });
expect(r.detail).toMatchObject({ unknown: 1, setupReady: 0 });
});
it('does not turn an inconclusive local model listing into a setup failure', () => {
const r = providersRow(
[{ id: 'local', type: 'api', endpoint: 'http://localhost:11434/v1' }],
{ providers: {} },
{ local: { status: 'ready' } },
{ local: { ready: false, checks: [{ id: 'runtime', ok: true }, { id: 'model', ok: null }] } },
);
expect(r).toMatchObject({ status: WARN, setupComplete: false });
expect(r.detail).toMatchObject({ blocked: 0, unknown: 1 });
});
});
describe('calendarRow / messagesRow', () => {
it('unconfigured with no accounts', () => {
expect(calendarRow([]).status).toBe(UNCONFIGURED);
expect(messagesRow([]).status).toBe(UNCONFIGURED);
});
it('ok when at least one account is enabled', () => {
expect(calendarRow([{ enabled: true }, { enabled: false }]).status).toBe(OK);
expect(messagesRow([{ enabled: true }]).status).toBe(OK);
});
it('warns when accounts exist but none enabled', () => {
expect(calendarRow([{ enabled: false }]).status).toBe(WARN);
});
it('warns when an enabled account last sync failed', () => {
const r = calendarRow([{ enabled: true, lastSyncStatus: 'error' }, { enabled: true, lastSyncStatus: 'success' }]);
expect(r.status).toBe(WARN);
expect(r.detail.failing).toBe(1);
expect(r.summary).toContain('1 failing');
// 'partial' also counts as failing
expect(messagesRow([{ enabled: true, lastSyncStatus: 'partial' }]).status).toBe(WARN);
// a never-synced (null) account is not a failure
expect(calendarRow([{ enabled: true, lastSyncStatus: null }]).status).toBe(OK);
});
});
describe('brainRow', () => {
it('unconfigured with no memories and no embedding provider', () => {
expect(brainRow({ memoryCount: 0, embeddingProviderConfigured: false }).status).toBe(UNCONFIGURED);
});
it('ok with memories and a configured embedding provider', () => {
expect(brainRow({ memoryCount: 5, embeddingProviderConfigured: true }).status).toBe(OK);
});
it('warns with memories but no embedding provider', () => {
expect(brainRow({ memoryCount: 5, embeddingProviderConfigured: false }).status).toBe(WARN);
});
it('pluralizes the memory count', () => {
expect(brainRow({ memoryCount: 1, embeddingProviderConfigured: true }).summary).toContain('1 memory');
expect(brainRow({ memoryCount: 2, embeddingProviderConfigured: true }).summary).toContain('2 memories');
});
});
describe('voiceRow', () => {
it('unconfigured when disabled', () => {
expect(voiceRow({ enabled: false }).status).toBe(UNCONFIGURED);
expect(voiceRow({}).status).toBe(UNCONFIGURED);
});
it('ok when enabled, reporting engines', () => {
const r = voiceRow({ enabled: true, tts: { engine: 'kokoro' }, stt: { engine: 'whisper' } });
expect(r.status).toBe(OK);
expect(r.summary).toContain('kokoro');
expect(r.summary).toContain('whisper');
});
});
describe('networkRow', () => {
it('unconfigured on plain HTTP with no tailscale', () => {
expect(networkRow({ httpsEnabled: false, cert: {} }).status).toBe(UNCONFIGURED);
});
it('ok with HTTPS and a tailscale host', () => {
expect(networkRow({ httpsEnabled: true, cert: { tailscaleHost: 'host.ts.net' } }).status).toBe(OK);
});
it('warns when only one of the two is present', () => {
expect(networkRow({ httpsEnabled: true, cert: {} }).status).toBe(WARN);
expect(networkRow({ httpsEnabled: false, cert: { tailscaleHost: 'h' } }).status).toBe(WARN);
});
it('uses the ordered setup contract when present', () => {
const r = networkRow({
httpsEnabled: false,
tailscale: { available: true },
setup: {
complete: false,
summary: 'Enable MagicDNS',
nextStep: { id: 'magic-dns' },
},
cert: {},
});
expect(r).toMatchObject({ status: WARN, setupRequired: false, setupComplete: false });
expect(r.detail.nextStepId).toBe('magic-dns');
});
});
describe('genomeRow', () => {
it('unconfigured when not uploaded', () => {
expect(genomeRow({ uploaded: false }).status).toBe(UNCONFIGURED);
});
it('ok when uploaded, surfacing flagged markers', () => {
const r = genomeRow({ uploaded: true, markerCount: 12, statusCounts: { concern: 2, major_concern: 1 } });
expect(r.status).toBe(OK);
expect(r.summary).toContain('3 flagged');
});
});
describe('telegramRow', () => {
it('unconfigured without token + chatId', () => {
expect(telegramRow({ hasToken: true, hasChatId: false }).status).toBe(UNCONFIGURED);
});
it('ok when configured and connected', () => {
expect(telegramRow({ hasToken: true, hasChatId: true, connected: true }).status).toBe(OK);
});
it('warns when configured but not connected', () => {
expect(telegramRow({ hasToken: true, hasChatId: true, connected: false }).status).toBe(WARN);
});
});
describe('appsRow', () => {
it('unconfigured with no apps', () => {
expect(appsRow({ total: 0 }).status).toBe(UNCONFIGURED);
});
it('ok when all online, warns when some stopped', () => {
expect(appsRow({ total: 3, online: 3, stopped: 0 }).status).toBe(OK);
expect(appsRow({ total: 3, online: 2, stopped: 1 }).status).toBe(WARN);
});
it('warns when apps are registered but never started', () => {
const r = appsRow({ total: 3, online: 0, stopped: 0, notStarted: 3 });
expect(r.status).toBe(WARN);
expect(r.summary).toContain('3 not started');
expect(r.detail.notStarted).toBe(3);
});
it('warns and reports "status unavailable" when PM2 read degraded the summary', () => {
const r = appsRow({ total: 3, online: 2, stopped: 0, notStarted: 0, unknown: 1, degraded: true });
expect(r.status).toBe(WARN);
expect(r.summary).toContain('1 status unavailable');
expect(r.detail.unknown).toBe(1);
expect(r.detail.degraded).toBe(true);
});
it('reports native-only (unmanaged) apps as present, not "No apps"', () => {
// getAppStatusSummary().total excludes unmanaged native/Xcode apps.
const r = appsRow({ total: 0, online: 0, unmanaged: 2 });
expect(r.status).toBe(OK);
expect(r.configured).toBe(true);
expect(r.summary).toContain('2 native');
});
it('unconfigured only when there are no apps at all', () => {
expect(appsRow({ total: 0, unmanaged: 0 }).status).toBe(UNCONFIGURED);
});
});
describe('buildCapabilityRows', () => {
it('returns one row per integration even with empty input', () => {
const rows = buildCapabilityRows({});
expect(rows).toHaveLength(9);
// Every row degrades to unconfigured rather than throwing.
expect(rows.every((r) => r.status === UNCONFIGURED)).toBe(true);
expect(rows.every((r) => typeof r.settingsPath === 'string' && r.settingsPath.startsWith('/'))).toBe(true);
expect(new Set(rows.map((r) => r.id)).size).toBe(9);
});
});
describe('summarizeCapabilities', () => {
it('counts each tier and rolls up worst-wins', () => {
const rows = [
{ status: OK }, { status: OK }, { status: WARN }, { status: UNCONFIGURED },
];
const s = summarizeCapabilities(rows);
expect(s).toMatchObject({ ok: 2, warn: 1, error: 0, unconfigured: 1, total: 4, overall: WARN });
});
it('reports error overall when any row errors', () => {
expect(summarizeCapabilities([{ status: OK }, { status: ERROR }]).overall).toBe(ERROR);
});
it('reports ok overall only when every row is ok', () => {
expect(summarizeCapabilities([{ status: OK }, { status: OK }]).overall).toBe(OK);
});
it('reports unconfigured overall when only ok + unconfigured rows', () => {
expect(summarizeCapabilities([{ status: OK }, { status: UNCONFIGURED }]).overall).toBe(UNCONFIGURED);
});
it('reports unconfigured (not ok) for empty or garbage input', () => {
expect(summarizeCapabilities([]).overall).toBe(UNCONFIGURED);
expect(summarizeCapabilities(null).overall).toBe(UNCONFIGURED);
expect(summarizeCapabilities(null).total).toBe(0);
});
it('does not default to ok when a non-empty list has only unknown statuses', () => {
const s = summarizeCapabilities([{ status: 'bogus' }, {}]);
expect(s).toMatchObject({ ok: 0, warn: 0, error: 0, unconfigured: 0, total: 2, overall: UNCONFIGURED });
});
});
describe('summarizeSetupCapabilities', () => {
it('rolls up only essential first-run capabilities', () => {
expect(summarizeSetupCapabilities([
{ setupRequired: true, setupComplete: true },
{ setupRequired: true, setupComplete: false },
{ setupRequired: false, setupComplete: false },
])).toEqual({ total: 2, ready: 1, remaining: 1, complete: false });
});
it('requires a non-empty setup contract before reporting completion', () => {
expect(summarizeSetupCapabilities([])).toEqual({
total: 0,
ready: 0,
remaining: 0,
complete: false,
});
});
});