Skip to content

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

feat: add Eidoverse Controllers panel beside Foundations under World controls (#7488)

[._.]/ Adam Eivy91cd6825809a
diff --git a/client/src/components/eidoverse/EidoverseControllersPanel.jsx b/client/src/components/eidoverse/EidoverseControllersPanel.jsx
new file mode 100644
index 0000000000..26c9005032
--- /dev/null
+++ b/client/src/components/eidoverse/EidoverseControllersPanel.jsx
@@ -0,0 +1,373 @@
+import { useCallback, useEffect, useId, useMemo, useState } from 'react';
+import { useSearchParams } from 'react-router';
+import { AlertTriangle, Pause, Play, Radio, Trash2, Zap } from 'lucide-react';
+import {
+ installEidoverseController,
+ listEidoverseControllers,
+ retireEidoverseController,
+ setEidoverseControllerArmed,
+} from '../../services/api';
+import { formatCount, formatDateShort, timeAgo } from '../../utils/formatters';
+
+/**
+ * The install/arm/retire surface for executable Eidoverse world controllers
+ * (#7456, #7488) — following `EidoverseFoundationsPanel.jsx` closely, since
+ * this is the same shape of surface (a listing plus an authoring form, both
+ * reading a refusal verdict rather than trusting a generic error) against the
+ * same kind of store.
+ *
+ * The server route reuses the EXACT projection the `eidoverse.controllers`
+ * mind-tool group already returns (`describeControllerDefinitions()` /
+ * `summarizeControllerInstall()`), so nothing here re-derives what "armed",
+ * "delivering", or a tick outcome means — it only renders what the service
+ * already decided.
+ */
+
+const silent = { silent: true };
+
+const MS_PER_SECOND = 1000;
+
+const fieldClass = 'mt-1 min-h-[42px] w-full rounded-lg border border-port-border bg-port-bg px-3 py-2 text-sm text-white focus:border-port-accent focus:outline-none';
+const secondaryButton = 'inline-flex min-h-[40px] items-center justify-center rounded-lg border border-port-border px-3 py-2 text-sm text-gray-200 transition-colors hover:border-port-accent hover:text-white disabled:cursor-wait disabled:opacity-50';
+const primaryButton = 'inline-flex min-h-[40px] items-center justify-center rounded-lg bg-port-accent px-4 py-2 text-sm font-semibold text-black transition-opacity hover:opacity-90 disabled:cursor-wait disabled:opacity-50';
+const dangerButton = 'inline-flex min-h-[40px] items-center justify-center rounded-lg bg-port-error px-3 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90 disabled:cursor-wait disabled:opacity-50';
+
+const EMPTY_DRAFT = Object.freeze({
+ id: '', controllerId: '', tickIntervalSeconds: '300', districtId: '', anchorEntityId: '',
+ config: '{}', deliverEffects: false, note: '',
+});
+
+/**
+ * Parse one JSON textarea. Returns a `{ value }` OR an `{ error }` — never a
+ * bare `null`, because `null` and `{}` are both legitimate parses and
+ * collapsing "did not parse" into one of them would submit the wrong body.
+ */
+function parseJsonObject(text, label) {
+ const trimmed = text.trim();
+ if (!trimmed) return { value: {} };
+ let parsed;
+ try {
+ parsed = JSON.parse(trimmed);
+ } catch (reason) {
+ return { error: `${label} is not valid JSON: ${reason.message}` };
+ }
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return { error: `${label} must be a JSON object.` };
+ return { value: parsed };
+}
+
+/** What the install list needs to tell a user "is this thing alive, and did
+ * it work" without reasoning over `lastTickOk`/`lastTickReason` itself. */
+function TickOutcome({ install }) {
+ if (install.lastTickOk === null) return <span className="text-gray-500">Never ticked yet</span>;
+ if (install.lastTickOk) return <span className="text-port-success">Last tick ok</span>;
+ return <span className="text-port-error">Last tick failed{install.lastTickReason ? `: ${install.lastTickReason}` : ''}</span>;
+}
+
+/**
+ * A supervisor disarm carries a REASON; a human choosing to pause one never
+ * does — rendering the reason verbatim, right beside the re-arm action, is
+ * the whole point of this panel existing (#7488 acceptance).
+ */
+function DisarmedReason({ reason }) {
+ if (!reason) return null;
+ return (
+ <p className="mt-2 flex items-start gap-2 rounded-lg border border-port-warning/40 bg-port-warning/5 p-2 text-sm text-port-warning" role="status">
+ <AlertTriangle size={14} className="mt-0.5 shrink-0" aria-hidden="true" />
+ <span>The supervisor disarmed this controller: {reason}</span>
+ </p>
+ );
+}
+
+function Verdict({ verdict }) {
+ if (!verdict) return null;
+ if (verdict.outcome === 'installed' || verdict.outcome === 'updated' || verdict.outcome === 'retired') {
+ return <p className="mt-3 text-sm text-port-success" role="status">Done.</p>;
+ }
+ return (
+ <div className="mt-3 rounded-lg border border-port-error/40 p-3 text-sm text-port-error" role="status">
+ <p className="font-medium">Refused — nothing changed.</p>
+ {verdict.reasons?.length > 0 && (
+ <ul className="mt-1 list-disc space-y-1 pl-5">
+ {verdict.reasons.map((reason) => <li key={reason}>{reason}</li>)}
+ </ul>
+ )}
+ </div>
+ );
+}
+
+export default function EidoverseControllersPanel() {
+ const [searchParams, setSearchParams] = useSearchParams();
+ const openId = searchParams.get('controller');
+ const [available, setAvailable] = useState([]);
+ const [installs, setInstalls] = useState([]);
+ const [counts, setCounts] = useState({ total: 0, armed: 0, delivering: 0 });
+ const [loading, setLoading] = useState(true);
+ const [loadError, setLoadError] = useState('');
+ const [busyId, setBusyId] = useState('');
+ const [rowVerdicts, setRowVerdicts] = useState({});
+ const [retireArmedFor, setRetireArmedFor] = useState('');
+ const [draft, setDraft] = useState(EMPTY_DRAFT);
+ const [installVerdict, setInstallVerdict] = useState(null);
+ const [formError, setFormError] = useState('');
+ const [saving, setSaving] = useState(false);
+ const fieldId = useId();
+
+ const applyListing = useCallback((listing) => {
+ setAvailable(listing.available || []);
+ setInstalls(listing.installs || []);
+ setCounts(listing.counts || { total: 0, armed: 0, delivering: 0 });
+ }, []);
+
+ const refresh = useCallback(() => listEidoverseControllers(silent).then(applyListing), [applyListing]);
+
+ useEffect(() => {
+ let live = true;
+ refresh()
+ .then(() => { if (live) setLoadError(''); })
+ .catch((reason) => { if (live) setLoadError(reason?.message || 'Could not load controllers.'); })
+ .finally(() => { if (live) setLoading(false); });
+ return () => { live = false; };
+ }, [refresh]);
+
+ const openController = useCallback((id) => {
+ setSearchParams((prev) => {
+ const next = new URLSearchParams(prev);
+ if (id) next.set('controller', id);
+ else next.delete('controller');
+ return next;
+ }, { replace: true });
+ }, [setSearchParams]);
+
+ const toggleArmed = useCallback(async (install) => {
+ setBusyId(install.id);
+ const verdict = await setEidoverseControllerArmed(install.id, !install.armed, silent)
+ .catch((reason) => ({ outcome: 'refused', install: null, reasons: [reason?.message || 'The request failed.'] }));
+ setRowVerdicts((current) => ({ ...current, [install.id]: verdict }));
+ await refresh().catch(() => {});
+ setBusyId('');
+ }, [refresh]);
+
+ const retire = useCallback(async (id) => {
+ setBusyId(id);
+ setRetireArmedFor('');
+ const verdict = await retireEidoverseController(id, silent)
+ .catch((reason) => ({ outcome: 'refused', install: null, reasons: [reason?.message || 'The request failed.'] }));
+ setRowVerdicts((current) => ({ ...current, [id]: verdict }));
+ if (verdict.outcome === 'retired' && openId === id) openController('');
+ await refresh().catch(() => {});
+ setBusyId('');
+ }, [refresh, openId, openController]);
+
+ const chooseControllerId = useCallback((controllerId) => {
+ const definition = available.find((entry) => entry.id === controllerId);
+ setDraft((current) => ({
+ ...current,
+ controllerId,
+ config: JSON.stringify(definition?.exampleConfig ?? {}, null, 2),
+ }));
+ }, [available]);
+
+ const submitDraft = useCallback(async (event) => {
+ event.preventDefault();
+ const config = parseJsonObject(draft.config, 'Config');
+ if (config.error) { setFormError(config.error); return; }
+ const seconds = Number(draft.tickIntervalSeconds);
+ if (!Number.isFinite(seconds) || seconds <= 0) { setFormError('Tick interval must be a positive number of seconds.'); return; }
+ setFormError('');
+ setSaving(true);
+ const authoredId = draft.id.trim();
+ const result = await installEidoverseController({
+ id: authoredId,
+ controllerId: draft.controllerId,
+ tickIntervalMs: Math.round(seconds * MS_PER_SECOND),
+ placement: {
+ districtId: draft.districtId.trim() || null,
+ anchorEntityId: draft.anchorEntityId.trim() || null,
+ },
+ config: config.value,
+ deliverEffects: draft.deliverEffects,
+ note: draft.note.trim() || null,
+ }, silent).catch((reason) => ({ outcome: 'refused', install: null, reasons: [reason?.message || 'Could not install the controller.'] }));
+ setSaving(false);
+ setInstallVerdict(result);
+ if (result.outcome !== 'installed') return;
+ setDraft(EMPTY_DRAFT);
+ await refresh().catch(() => {});
+ openController(authoredId);
+ }, [draft, refresh, openController]);
+
+ const mutateDraft = (key) => (event) => setDraft((current) => ({ ...current, [key]: event.target.value }));
+
+ const openInstall = useMemo(() => installs.find((entry) => entry.id === openId) || null, [installs, openId]);
+ const draftDefinition = useMemo(() => available.find((entry) => entry.id === draft.controllerId) || null, [available, draft.controllerId]);
+
+ return (
+ <div className="space-y-5">
+ <section className="rounded-xl border border-port-border bg-port-card p-4">
+ <h3 className="flex items-center gap-2 font-medium text-white">
+ <Zap size={16} className="text-port-accent" aria-hidden="true" />
+ What is ticking in your world
+ </h3>
+ <p className="mt-1 text-sm leading-6 text-gray-400">
+ A controller is a small piece of behavior PortOS ships, run on a timer between your visits. Every tick is
+ synchronous and cannot reach an AI provider — the only thing a controller can do is propose bookkeeping,
+ a line of chat, or a construction operation, and only an <strong className="text-gray-200">armed</strong>{' '}
+ install with delivery turned on ever reaches the world itself.
+ </p>
+ <p className="mt-3 text-sm text-gray-400">
+ {formatCount(counts.total, { fallback: '0' })} installed · {formatCount(counts.armed, { fallback: '0' })} armed · {formatCount(counts.delivering, { fallback: '0' })} delivering to the world
+ </p>
+ </section>
+
+ {loadError && (
+ <p className="rounded-lg border border-port-error/40 bg-port-error/5 p-3 text-sm text-port-error" role="alert">{loadError}</p>
+ )}
+
+ {loading ? (
+ <p className="text-sm text-gray-400" role="status">Loading controllers…</p>
+ ) : installs.length === 0 ? (
+ <p className="text-sm text-gray-400">No controllers installed yet. Install one from the registry below.</p>
+ ) : (
+ <ul className="space-y-3">
+ {installs.map((install) => {
+ const expanded = install.id === openId;
+ const definition = available.find((entry) => entry.id === install.controllerId);
+ return (
+ <li key={install.id} className="rounded-xl border border-port-border bg-port-card p-4">
+ <div className="flex flex-wrap items-start justify-between gap-3">
+ <div className="min-w-0">
+ <div className="flex flex-wrap items-center gap-2">
+ <h4 className="font-medium text-white">{install.id}</h4>
+ <span className={`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium ${install.armed ? 'border-port-success/40 bg-port-success/10 text-port-success' : 'border-port-border text-gray-400'}`}>
+ <Radio size={12} aria-hidden="true" />
+ {install.armed ? 'Armed' : 'Disarmed'}
+ </span>
+ <span className={`rounded-full border px-2 py-0.5 text-xs ${install.deliverEffects ? 'border-port-accent/40 bg-port-accent/10 text-port-accent' : 'border-port-border text-gray-400'}`}>
+ {install.deliverEffects ? 'Delivers to the world' : 'Bookkeeping only'}
+ </span>
+ <span className="rounded-full border border-port-border px-2 py-0.5 text-xs text-gray-400">{install.controllerId}</span>
+ </div>
+ <p className="mt-1 text-sm text-gray-400">{definition?.summary || 'This install\'s registered controller is no longer shipped by this version.'}</p>
+ <p className="mt-1 text-xs text-gray-500">
+ Every {Math.round(install.tickIntervalMs / MS_PER_SECOND)}s · tick {formatCount(install.tick, { fallback: '0' })}
+ {install.lastTickAt ? ` · last ${timeAgo(install.lastTickAt)}` : ''} · <TickOutcome install={install} />
+ </p>
+ </div>
+ <div className="flex flex-wrap gap-2">
+ <button type="button" className={secondaryButton} disabled={busyId === install.id} onClick={() => toggleArmed(install)}>
+ {install.armed ? <Pause size={14} aria-hidden="true" /> : <Play size={14} aria-hidden="true" />}
+ {install.armed ? 'Disarm' : 'Arm'}
+ </button>
+ <button type="button" className={secondaryButton} onClick={() => openController(expanded ? '' : install.id)}>
+ {expanded ? 'Hide' : 'Details'}
+ </button>
+ {retireArmedFor === install.id ? (
+ <>
+ <button type="button" className={dangerButton} disabled={busyId === install.id} onClick={() => retire(install.id)}>Confirm retire</button>
+ <button type="button" className={secondaryButton} onClick={() => setRetireArmedFor('')}>Cancel</button>
+ </>
+ ) : (
+ <button type="button" className={secondaryButton} onClick={() => setRetireArmedFor(install.id)}>
+ <Trash2 size={14} aria-hidden="true" />
+ Retire
+ </button>
+ )}
+ </div>
+ </div>
+
+ <DisarmedReason reason={install.disarmedReason} />
+ <Verdict verdict={rowVerdicts[install.id]} />
+
+ {expanded && (
+ <div className="mt-3 space-y-2 border-t border-port-border pt-3 text-sm">
+ {install.note && <p className="text-gray-400">Note: {install.note}</p>}
+ <p className="text-gray-400">
+ Installed {formatDateShort(install.installedAt)} by {install.installedBy} ·
+ {' '}{install.consecutiveFailures > 0 ? `${install.consecutiveFailures} consecutive failure(s)` : 'no consecutive failures'}
+ </p>
+ <p className="text-gray-400">Config:</p>
+ <pre className="max-h-32 overflow-auto rounded-lg bg-port-bg p-3 text-xs text-gray-300">{JSON.stringify(install.config ?? {}, null, 2)}</pre>
+ {install.recentEffects?.length > 0 && (
+ <>
+ <p className="text-gray-400">Recent effects:</p>
+ <ul className="space-y-1 text-xs text-gray-400">
+ {install.recentEffects.map((effect) => (
+ <li key={`${effect.at}-${effect.tick}`}>{effect.kind}: {effect.summary} <span className="text-gray-500">({timeAgo(effect.at)})</span></li>
+ ))}
+ </ul>
+ </>
+ )}
+ </div>
+ )}
+ </li>
+ );
+ })}
+ </ul>
+ )}
+
+ <details className="rounded-xl border border-port-border bg-port-card p-4" open={installs.length === 0}>
+ <summary className="cursor-pointer font-medium text-white">Install a controller</summary>
+ <form className="mt-4 space-y-3" onSubmit={submitDraft}>
+ <div className="grid gap-3 sm:grid-cols-2">
+ <div>
+ <label htmlFor={`${fieldId}-id`} className="text-sm text-gray-300">Install id (lowercase slug)</label>
+ <input id={`${fieldId}-id`} className={fieldClass} value={draft.id} onChange={mutateDraft('id')} required placeholder="tide-beacon" />
+ </div>
+ <div>
+ <label htmlFor={`${fieldId}-controller`} className="text-sm text-gray-300">Controller</label>
+ <select id={`${fieldId}-controller`} className={fieldClass} value={draft.controllerId} onChange={(event) => chooseControllerId(event.target.value)} required>
+ <option value="">Choose a shipped controller…</option>
+ {available.map((definition) => <option key={definition.id} value={definition.id}>{definition.title}</option>)}
+ </select>
+ </div>
+ <div>
+ <label htmlFor={`${fieldId}-interval`} className="text-sm text-gray-300">Tick interval (seconds)</label>
+ <input id={`${fieldId}-interval`} type="number" min="60" step="1" className={fieldClass} value={draft.tickIntervalSeconds} onChange={mutateDraft('tickIntervalSeconds')} required />
+ </div>
+ <div>
+ <label htmlFor={`${fieldId}-note`} className="text-sm text-gray-300">Note (optional)</label>
+ <input id={`${fieldId}-note`} className={fieldClass} value={draft.note} onChange={mutateDraft('note')} />
+ </div>
+ <div>
+ <label htmlFor={`${fieldId}-district`} className="text-sm text-gray-300">District id (optional)</label>
+ <input id={`${fieldId}-district`} className={fieldClass} value={draft.districtId} onChange={mutateDraft('districtId')} />
+ </div>
+ <div>
+ <label htmlFor={`${fieldId}-anchor`} className="text-sm text-gray-300">Anchor entity id (optional)</label>
+ <input id={`${fieldId}-anchor`} className={fieldClass} value={draft.anchorEntityId} onChange={mutateDraft('anchorEntityId')} />
+ </div>
+ </div>
+ {draftDefinition?.summary && (
+ <p className="text-xs text-gray-500">{draftDefinition.summary}</p>
+ )}
+ <div>
+ <label htmlFor={`${fieldId}-config`} className="text-sm text-gray-300">Config — this controller&apos;s own JSON shape</label>
+ <textarea id={`${fieldId}-config`} rows={6} className={`${fieldClass} font-mono text-xs`} value={draft.config} onChange={mutateDraft('config')} />
+ </div>
+ <label className="flex items-start gap-3 rounded-lg border border-port-border bg-port-bg p-3">
+ <input type="checkbox" className="mt-1" checked={draft.deliverEffects} onChange={(event) => setDraft((current) => ({ ...current, deliverEffects: event.target.checked }))} />
+ <span className="text-sm">
+ <span className="font-medium text-white">Let this controller speak and build in the world on its own schedule</span>
+ <span className="block text-gray-400">
+ Off by default. Off, a tick can only keep its own notes. On, its <code>say</code> and <code>augment</code>{' '}
+ effects reach the world unattended, every tick, with nobody reviewing them first.
+ </span>
+ </span>
+ </label>
+ {formError && <p className="text-sm text-port-error" role="alert">{formError}</p>}
+ <Verdict verdict={installVerdict} />
+ <div className="flex flex-wrap justify-end gap-2">
+ <button type="button" className={secondaryButton} onClick={() => { setDraft(EMPTY_DRAFT); setFormError(''); setInstallVerdict(null); }}>Clear</button>
+ <button type="submit" className={primaryButton} disabled={saving}>{saving ? 'Installing…' : 'Install'}</button>
+ </div>
+ </form>
+ </details>
+
+ {openId && !openInstall && !loading && (
+ <p className="text-sm text-gray-400" role="status">
+ No controller is installed under &quot;{openId}&quot; on this install.
+ </p>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/components/eidoverse/EidoverseControllersPanel.test.jsx b/client/src/components/eidoverse/EidoverseControllersPanel.test.jsx
new file mode 100644
index 0000000000..c703cd2213
--- /dev/null
+++ b/client/src/components/eidoverse/EidoverseControllersPanel.test.jsx
@@ -0,0 +1,154 @@
+/**
+ * The controllers panel is the only surface that lets a user see and manage
+ * what is ticking in their own Eidoverse world without a mind in the loop
+ * (#7488). The regression this pins that a status-code check cannot: a
+ * supervisor-disarmed reason silently dropped instead of rendered verbatim,
+ * and an install refusal collapsing into a generic failure.
+ */
+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { MemoryRouter } from 'react-router';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+vi.mock('../../services/api', () => ({
+ listEidoverseControllers: vi.fn(),
+ installEidoverseController: vi.fn(),
+ setEidoverseControllerArmed: vi.fn(),
+ retireEidoverseController: vi.fn(),
+}));
+
+import {
+ installEidoverseController,
+ listEidoverseControllers,
+ retireEidoverseController,
+ setEidoverseControllerArmed,
+} from '../../services/api';
+import EidoverseControllersPanel from './EidoverseControllersPanel';
+
+const definition = (overrides = {}) => ({
+ id: 'resource-tick',
+ title: 'Resource tick',
+ summary: 'Ticks a resource counter forward.',
+ exampleConfig: { rate: 1 },
+ ...overrides,
+});
+
+const install = (overrides = {}) => ({
+ id: 'tide-beacon',
+ controllerId: 'resource-tick',
+ armed: true,
+ deliverEffects: false,
+ tickIntervalMs: 300000,
+ placement: { districtId: null, anchorEntityId: null },
+ installedBy: 'user',
+ installedAt: '2026-03-04T05:06:07.000Z',
+ tick: 3,
+ lastTickAt: '2026-03-04T06:00:00.000Z',
+ nextTickAt: '2026-03-04T06:05:00.000Z',
+ lastTickOk: true,
+ lastTickReason: null,
+ consecutiveFailures: 0,
+ disarmedReason: null,
+ note: null,
+ recentEffects: [],
+ ...overrides,
+});
+
+const listing = (installs, overrides = {}) => ({
+ available: [definition()],
+ counts: { total: installs.length, armed: installs.filter((entry) => entry.armed).length, delivering: 0 },
+ installs,
+ ...overrides,
+});
+
+// Settle the initial load OUTSIDE the act() a click needs, same reasoning as
+// the foundations panel test: React does not commit while an async act
+// callback is still running, so a findBy* inside one never sees the fetched list.
+const renderPanel = async () => {
+ const view = render(<MemoryRouter><EidoverseControllersPanel /></MemoryRouter>);
+ await act(async () => {});
+ return view;
+};
+
+afterEach(() => { vi.clearAllMocks(); });
+
+describe('the Eidoverse controllers panel', () => {
+ it('renders a supervisor-disarmed controller with its reason verbatim, and offers to re-arm it', async () => {
+ listEidoverseControllers.mockResolvedValue(listing([
+ install({ armed: false, disarmedReason: 'failed 3 consecutive ticks: step() threw a TypeError' }),
+ ]));
+ await renderPanel();
+
+ expect(screen.getByText(/failed 3 consecutive ticks: step\(\) threw a TypeError/)).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /Arm/ })).toBeInTheDocument();
+ });
+
+ it('shows an install refusal with its reasons beside the form, without installing anything', async () => {
+ listEidoverseControllers.mockResolvedValue(listing([]));
+ installEidoverseController.mockResolvedValue({
+ outcome: 'refused',
+ install: null,
+ reasons: ['no controller is registered under "ghost-controller"'],
+ });
+ await renderPanel();
+
+ fireEvent.change(screen.getByLabelText('Install id (lowercase slug)'), { target: { value: 'tide-beacon' } });
+ fireEvent.change(screen.getByLabelText('Controller'), { target: { value: 'resource-tick' } });
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Install' })); });
+
+ expect(screen.getByText(/no controller is registered under "ghost-controller"/)).toBeInTheDocument();
+ expect(screen.getByText('Refused — nothing changed.')).toBeInTheDocument();
+ });
+
+ it('refuses to submit an unparseable config instead of sending it to the install gate', async () => {
+ listEidoverseControllers.mockResolvedValue(listing([]));
+ await renderPanel();
+
+ fireEvent.change(screen.getByLabelText('Install id (lowercase slug)'), { target: { value: 'tide-beacon' } });
+ fireEvent.change(screen.getByLabelText('Controller'), { target: { value: 'resource-tick' } });
+ fireEvent.change(screen.getByLabelText(/Config/), { target: { value: '{ not json' } });
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Install' })); });
+
+ expect(screen.getByRole('alert')).toHaveTextContent('Config is not valid JSON');
+ expect(installEidoverseController).not.toHaveBeenCalled();
+ });
+
+ it('installs a controller with deliverEffects off by default, and shows it in the list after refresh', async () => {
+ listEidoverseControllers
+ .mockResolvedValueOnce(listing([]))
+ .mockResolvedValueOnce(listing([install()]));
+ installEidoverseController.mockResolvedValue({ outcome: 'installed', install: install(), reasons: [] });
+ await renderPanel();
+
+ fireEvent.change(screen.getByLabelText('Install id (lowercase slug)'), { target: { value: 'tide-beacon' } });
+ fireEvent.change(screen.getByLabelText('Controller'), { target: { value: 'resource-tick' } });
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Install' })); });
+
+ expect(installEidoverseController).toHaveBeenCalledWith(expect.objectContaining({
+ id: 'tide-beacon', controllerId: 'resource-tick', deliverEffects: false,
+ }), { silent: true });
+ await waitFor(() => expect(screen.getByRole('heading', { name: 'tide-beacon' })).toBeInTheDocument());
+ });
+
+ it('arms and disarms an installed controller from the list', async () => {
+ listEidoverseControllers.mockResolvedValue(listing([install()]));
+ setEidoverseControllerArmed.mockResolvedValue({ outcome: 'updated', install: install({ armed: false }), reasons: [] });
+ await renderPanel();
+
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: /Disarm/ })); });
+
+ expect(setEidoverseControllerArmed).toHaveBeenCalledWith('tide-beacon', false, { silent: true });
+ });
+
+ it('retires an installed controller only after a second confirming click', async () => {
+ listEidoverseControllers.mockResolvedValue(listing([install()]));
+ retireEidoverseController.mockResolvedValue({ outcome: 'retired', install: install(), reasons: [] });
+ await renderPanel();
+
+ fireEvent.click(screen.getByRole('button', { name: /Retire/ }));
+ expect(retireEidoverseController).not.toHaveBeenCalled();
+
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Confirm retire' })); });
+
+ expect(retireEidoverseController).toHaveBeenCalledWith('tide-beacon', { silent: true });
+ });
+});
diff --git a/client/src/components/eidoverse/EidoverseWorldDrawer.jsx b/client/src/components/eidoverse/EidoverseWorldDrawer.jsx
index 158fbc41d7..465fe839e8 100644
--- a/client/src/components/eidoverse/EidoverseWorldDrawer.jsx
+++ b/client/src/components/eidoverse/EidoverseWorldDrawer.jsx
@@ -1,11 +1,12 @@
import { useState } from 'react';
-import { Compass, Database, Globe2, Palette, RefreshCw } from 'lucide-react';
+import { Compass, Database, Globe2, Palette, RefreshCw, Zap } from 'lucide-react';
import { Link } from 'react-router';
import Drawer from '../Drawer';
import useDrawerTab from '../../hooks/useDrawerTab';
import { EIDOVERSE_SOURCE_ROUTES as SOURCE_ROUTES } from '../../lib/eidoverseFrame';
import EidoverseObjectLegend from './EidoverseObjectLegend';
import EidoverseFoundationsPanel from './EidoverseFoundationsPanel';
+import EidoverseControllersPanel from './EidoverseControllersPanel';
import { formatBytes } from '../../utils/formatters';
const TABS = [
@@ -13,6 +14,7 @@ const TABS = [
{ id: 'districts', label: 'Districts & Data', icon: Database },
{ id: 'appearance', label: 'Appearance & Assets', icon: Palette },
{ id: 'foundations', label: 'Foundations', icon: Globe2 },
+ { id: 'controllers', label: 'Controllers', icon: Zap },
{ id: 'updates', label: 'Updates & Advanced', icon: RefreshCw },
];
const TAB_IDS = TABS.map(({ id }) => id);
@@ -584,10 +586,11 @@ export default function EidoverseWorldDrawer({
activeTab={activeTab}
onTabChange={setActiveTab}
>
- {/* Foundations owns its own form (recording a foundation is not a world-config
- save), and a nested <form> is invalid HTML — so it renders beside the
+ {/* Foundations and Controllers each own their own form (recording a
+ foundation, or installing a controller, is not a world-config save),
+ and a nested <form> is invalid HTML — so they render beside the
config form rather than inside it. */}
- {activeTab === 'foundations' ? <EidoverseFoundationsPanel /> : (
+ {activeTab === 'foundations' ? <EidoverseFoundationsPanel /> : activeTab === 'controllers' ? <EidoverseControllersPanel /> : (
<form className="space-y-5" onSubmit={(event) => { event.preventDefault(); onSave(); }}>
{panel}
{(activeTab !== 'updates' || dirty) && (
diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.js
index 08f2b98c5b..8d51923256 100644
--- a/client/src/services/apiSystem.js
+++ b/client/src/services/apiSystem.js
@@ -130,6 +130,27 @@ export const promoteEidoverseFoundation = (id, options = {}) => request(`/eidove
method: 'POST',
...options,
});
+
+// Eidoverse world controllers — the install/arm/retire surface beside the
+// `eidoverse.controllers` mind-tool group (#7456, #7488). An install/arm
+// refusal (unknown `controllerId`, a bad config, an unknown install id) is a
+// 200 carrying its `outcome`/`reasons`, the same shape as the foundations
+// promote gate: callers read `outcome`, not the HTTP status, for a refusal.
+export const listEidoverseControllers = (options) => request('/eidoverse/world/controllers', options);
+export const installEidoverseController = (payload, options = {}) => request('/eidoverse/world/controllers', {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ ...options,
+});
+export const setEidoverseControllerArmed = (id, armed, options = {}) => request(`/eidoverse/world/controllers/${encodeURIComponent(id)}`, {
+ method: 'PATCH',
+ body: JSON.stringify({ armed }),
+ ...options,
+});
+export const retireEidoverseController = (id, options = {}) => request(`/eidoverse/world/controllers/${encodeURIComponent(id)}`, {
+ method: 'DELETE',
+ ...options,
+});
export const updateSettings = (data, options) => request('/settings', {
method: 'PUT',
body: JSON.stringify(data),
diff --git a/server/routes/eidoverseWorldRoutes.js b/server/routes/eidoverseWorldRoutes.js
index d49fae8369..2814b348d5 100644
--- a/server/routes/eidoverseWorldRoutes.js
+++ b/server/routes/eidoverseWorldRoutes.js
@@ -15,6 +15,11 @@ import {
validateRequest,
} from '../lib/validation.js';
import { eidoverseFoundationIdParamSchema, eidoverseFoundationInputSchema } from '../lib/eidoverseFoundations.js';
+import {
+ eidoverseControllerArmSchema,
+ eidoverseControllerIdParamSchema,
+ eidoverseControllerInstallSchema,
+} from '../lib/eidoverseControllers.js';
import {
getEidoverseFoundation,
listEidoverseFoundations,
@@ -23,6 +28,14 @@ import {
recordEidoverseFoundation,
} from '../services/eidoverseFoundationLedger.js';
import { listRegisteredContributionIds } from '../services/eidoverseResilienceContributions.js';
+import { describeControllerDefinitions } from '../services/eidoverseControllerRegistry.js';
+import {
+ installEidoverseController,
+ listEidoverseControllers,
+ retireEidoverseController,
+ setEidoverseControllerArmed,
+ summarizeControllerInstall,
+} from '../services/eidoverseControllerRuntime.js';
import { ensureInstanceId } from '../services/instanceIdentity.js';
import {
augmentEidoverseWorld,
@@ -149,4 +162,57 @@ router.get('/foundations/:id', asyncHandler(async (req, res) => {
res.json(foundation);
}));
+// --- Controllers: the executable world-controller install surface (#7456,
+// #7488) --------------------------------------------------------------------
+// Everything here is the same projection the `eidoverse.controllers` mind-tool
+// group in `services/cosToolRegistry.js` already exposes, reached this time
+// from the UI rather than a mind: `describeControllerDefinitions()` and
+// `summarizeControllerInstall()` stay the ONE projection either caller reads,
+// so a UI/tool drift is impossible by construction rather than by discipline.
+
+// GET /api/eidoverse/world/controllers — the shipped registry plus every
+// installed controller on this install.
+router.get('/controllers', asyncHandler(async (_req, res) => {
+ const [available, listed] = await Promise.all([describeControllerDefinitions(), listEidoverseControllers()]);
+ res.json({
+ available,
+ counts: listed.counts,
+ installs: listed.installs.map((install) => summarizeControllerInstall(install)),
+ });
+}));
+
+// POST /api/eidoverse/world/controllers — install (or re-install) a
+// controller. `installedBy: 'user'` — this route is the human's own surface,
+// never a mind's, which stays gated on `installEidoverseControllers`
+// separately in the tool catalog. A refusal (unknown `controllerId`, a config
+// its schema rejects) is a 200 carrying its reasons, the same shape the
+// foundations promote gate already uses: it is the useful output, not a
+// request error.
+router.post('/controllers', asyncHandler(async (req, res) => {
+ const input = validateRequest(eidoverseControllerInstallSchema, req.body || {});
+ const result = await installEidoverseController(input, { installedBy: 'user' });
+ res.json({ ...result, install: result.install ? summarizeControllerInstall(result.install, { includeState: true }) : null });
+}));
+
+// PATCH /api/eidoverse/world/controllers/:id — arm or disarm an installed
+// controller without losing its accumulated state. The id travels in the URL;
+// merging it with the body's `armed` lets this route validate against the
+// exact same `eidoverseControllerArmSchema` the mind tool uses, rather than a
+// second param/body split of the same two fields.
+router.patch('/controllers/:id', asyncHandler(async (req, res) => {
+ const { id, armed } = validateRequest(eidoverseControllerArmSchema, { ...(req.body || {}), id: req.params.id });
+ const result = await setEidoverseControllerArmed(id, armed);
+ if (result.outcome === 'unknown-install') throw new ServerError('Controller install not found', { status: 404 });
+ res.json({ ...result, install: result.install ? summarizeControllerInstall(result.install) : null });
+}));
+
+// DELETE /api/eidoverse/world/controllers/:id — retire an installed
+// controller, deleting it and its accumulated state.
+router.delete('/controllers/:id', asyncHandler(async (req, res) => {
+ const { id } = validateRequest(eidoverseControllerIdParamSchema, req.params || {});
+ const result = await retireEidoverseController(id);
+ if (result.outcome === 'unknown-install') throw new ServerError('Controller install not found', { status: 404 });
+ res.json({ ...result, install: result.install ? summarizeControllerInstall(result.install) : null });
+}));
+
export default router;
diff --git a/server/routes/eidoverseWorldRoutes.test.js b/server/routes/eidoverseWorldRoutes.test.js
index 2f9ba9c159..9bd7e2dba3 100644
--- a/server/routes/eidoverseWorldRoutes.test.js
+++ b/server/routes/eidoverseWorldRoutes.test.js
@@ -17,6 +17,11 @@ const mocks = vi.hoisted(() => ({
project: vi.fn(),
say: vi.fn(),
updateConfig: vi.fn(),
+ describeControllerDefinitions: vi.fn(),
+ listControllers: vi.fn(),
+ installController: vi.fn(),
+ retireController: vi.fn(),
+ armController: vi.fn(),
}));
vi.mock('../services/eidoverseWorld.js', () => ({
@@ -43,6 +48,25 @@ vi.mock('../services/eidoverseResilienceContributions.js', () => ({
vi.mock('../services/instanceIdentity.js', () => ({ ensureInstanceId: () => Promise.resolve('instance-aaaa') }));
+vi.mock('../services/eidoverseControllerRegistry.js', () => ({
+ describeControllerDefinitions: mocks.describeControllerDefinitions,
+}));
+
+// `summarizeControllerInstall` stays the REAL, pure projection from
+// `lib/eidoverseControllers.js` — it is the one thing #7488 requires the route
+// not re-implement, so doubling it here would hide the exact drift the issue
+// is guarding against.
+vi.mock('../services/eidoverseControllerRuntime.js', async (importOriginal) => {
+ const actual = await importOriginal();
+ return {
+ ...actual,
+ listEidoverseControllers: mocks.listControllers,
+ installEidoverseController: mocks.installController,
+ retireEidoverseController: mocks.retireController,
+ setEidoverseControllerArmed: mocks.armController,
+ };
+});
+
const { default: eidoverseWorldRoutes } = await import('./eidoverseWorldRoutes.js');
const makeApp = () => {
@@ -237,4 +261,110 @@ it('reports a promote refusal as a verdict and never moves the layer itself', as
expect(response.body).toEqual({ contributions: ['beacon-relay-demo'] });
expect(mocks.getFoundation).not.toHaveBeenCalled();
});
+
+ // --- Controllers: the install surface beside the mind tool (#7488) -------
+ describe('controllers', () => {
+ const install = (overrides = {}) => ({
+ id: 'tide-beacon',
+ controllerId: 'resource-tick',
+ tickIntervalMs: 300000,
+ placement: { districtId: null, anchorEntityId: null },
+ config: {},
+ deliverEffects: false,
+ armed: true,
+ note: null,
+ installedBy: 'user',
+ installedAt: '2026-03-04T05:06:07.000Z',
+ updatedAt: '2026-03-04T05:06:07.000Z',
+ state: { count: 0 },
+ tick: 0,
+ nextTickAt: '2026-03-04T05:11:07.000Z',
+ lastTickAt: null,
+ lastOutcome: null,
+ recentEffects: [],
+ consecutiveFailures: 0,
+ disarmedReason: null,
+ ...overrides,
+ });
+
+ it('reads the shipped registry and the install list from the same projection the mind tool uses', async () => {
+ mocks.describeControllerDefinitions.mockResolvedValue([{ id: 'resource-tick', title: 'Resource tick', summary: 'Ticks a counter.', exampleConfig: {} }]);
+ mocks.listControllers.mockResolvedValue({ counts: { total: 1, armed: 1, delivering: 0 }, installs: [install()] });
+
+ const response = await request(makeApp()).get('/api/eidoverse/world/controllers');
+
+ expect(response.status).toBe(200);
+ expect(response.body.available).toEqual([{ id: 'resource-tick', title: 'Resource tick', summary: 'Ticks a counter.', exampleConfig: {} }]);
+ expect(response.body.counts).toEqual({ total: 1, armed: 1, delivering: 0 });
+ expect(response.body.installs).toEqual([expect.objectContaining({ id: 'tide-beacon', armed: true })]);
+ // The list projection is state-free — only an install just authored gets it.
+ expect(response.body.installs[0].state).toBeUndefined();
+ });
+
+ it('refuses an install naming a controller id this version does not ship, with the reason beside the request', async () => {
+ mocks.installController.mockResolvedValue({ outcome: 'refused', install: null, reasons: ['no controller is registered under "ghost-controller"'] });
+
+ const response = await request(makeApp()).post('/api/eidoverse/world/controllers').send({ id: 'tide-beacon', controllerId: 'ghost-controller' });
+
+ expect(response.status).toBe(200);
+ expect(response.body).toMatchObject({ outcome: 'refused', install: null });
+ expect(response.body.reasons[0]).toContain('ghost-controller');
+ expect(mocks.installController).toHaveBeenCalledWith(
+ expect.objectContaining({ id: 'tide-beacon', controllerId: 'ghost-controller' }),
+ { installedBy: 'user' },
+ );
+ });
+
+ it('refuses a bad config with its field-level reason before the service is asked to resolve a definition', async () => {
+ const response = await request(makeApp()).post('/api/eidoverse/world/controllers').send({ id: 'tide-beacon', controllerId: 'resource-tick', config: 'not-an-object' });
+
+ expect(response.status).toBe(400);
+ expect(mocks.installController).not.toHaveBeenCalled();
+ });
+
+ it('installs and returns state only on a successful install, through the shared projection', async () => {
+ mocks.installController.mockResolvedValue({ outcome: 'installed', install: install(), reasons: [] });
+
+ const response = await request(makeApp()).post('/api/eidoverse/world/controllers').send({ id: 'tide-beacon', controllerId: 'resource-tick' });
+
+ expect(response.status).toBe(200);
+ expect(response.body.outcome).toBe('installed');
+ expect(response.body.install).toMatchObject({ id: 'tide-beacon', controllerId: 'resource-tick' });
+ expect(response.body.install.state).toEqual({ count: 0 });
+ });
+
+ it('arms and disarms an install by id, and 404s an unknown install id', async () => {
+ mocks.armController.mockResolvedValueOnce({ outcome: 'updated', install: install({ armed: false }), reasons: [] });
+ mocks.armController.mockResolvedValueOnce({ outcome: 'unknown-install', install: null, reasons: ['no controller is installed under "ghost-install"'] });
+
+ const armed = await request(makeApp()).patch('/api/eidoverse/world/controllers/tide-beacon').send({ armed: false });
+ const unknown = await request(makeApp()).patch('/api/eidoverse/world/controllers/ghost-install').send({ armed: true });
+
+ expect(armed.status).toBe(200);
+ expect(armed.body.install).toMatchObject({ armed: false });
+ expect(mocks.armController).toHaveBeenCalledWith('tide-beacon', false);
+ expect(unknown.status).toBe(404);
+ });
+
+ it('renders a supervisor-disarmed reason verbatim through the arm response', async () => {
+ mocks.armController.mockResolvedValue({ outcome: 'updated', install: install({ armed: false, disarmedReason: 'failed 3 consecutive ticks: step() threw' }), reasons: [] });
+
+ const response = await request(makeApp()).patch('/api/eidoverse/world/controllers/tide-beacon').send({ armed: false });
+
+ expect(response.body.install.disarmedReason).toBe('failed 3 consecutive ticks: step() threw');
+ });
+
+ it('retires an install by id and 404s an unknown install id', async () => {
+ mocks.retireController.mockResolvedValueOnce({ outcome: 'retired', install: install(), reasons: [] });
+ mocks.retireController.mockResolvedValueOnce({ outcome: 'unknown-install', install: null, reasons: ['no controller is installed under "ghost-install"'] });
+
+ const retired = await request(makeApp()).delete('/api/eidoverse/world/controllers/tide-beacon');
+ const unknown = await request(makeApp()).delete('/api/eidoverse/world/controllers/ghost-install');
+
+ expect(retired.status).toBe(200);
+ expect(retired.body.outcome).toBe('retired');
+ expect(mocks.retireController).toHaveBeenCalledWith('tide-beacon');
+ expect(unknown.status).toBe(404);
+ });
+ });
});