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: address persistent mind review findings (#5066)
[._.]/ Adam Eivy081813c3a208
diff --git a/client/src/components/cos/tabs/MindTab.jsx b/client/src/components/cos/tabs/MindTab.jsxindex 8acfc3f39c..3bcc465b42 100644--- a/client/src/components/cos/tabs/MindTab.jsx+++ b/client/src/components/cos/tabs/MindTab.jsx@@ -10,6 +10,7 @@ import Banner from '../../ui/Banner';const PAGE_LIMIT = 200;const MAX_BACKFILL_PAGES = 5;+const MAX_VISIBLE_EVENTS = PAGE_LIMIT * MAX_BACKFILL_PAGES;const EVENT_LABELS = {'mind.message.accepted': 'User input',@@ -35,7 +36,7 @@ const eventText = (event) => {const mergeEvents = (previous, incoming) => {const byId = new Map(previous.map((event) => [event.eventId, event]));for (const event of incoming) byId.set(event.eventId, event);- return [...byId.values()].sort((a, b) => a.sequence - b.sequence);+ return [...byId.values()].sort((a, b) => a.sequence - b.sequence).slice(-MAX_VISIBLE_EVENTS);};const mintId = (prefix) => `${prefix}-${uuidv4()}`;@@ -48,12 +49,14 @@ export default function MindTab() {const [mind, setMind] = useState(null);const [loadError, setLoadError] = useState(null);const [gap, setGap] = useState(false);+ const [truncated, setTruncated] = useState(false);const [loading, setLoading] = useState(true);const [kind, setKind] = useState('message');const [text, setText] = useState('');const [submitting, setSubmitting] = useState(false);const [submitError, setSubmitError] = useState(null);const [lifecyclePending, setLifecyclePending] = useState(null);+ const [eventActionPending, setEventActionPending] = useState(null);const [lifecycleError, setLifecycleError] = useState(null);const cursorRef = useRef(null);const loadPendingRef = useRef(false);@@ -71,13 +74,15 @@ export default function MindTab() {let page = 0;let accumulated = [];let sawGap = false;+ let sawTruncation = false;let needsMore = false;try {do {const response = await api.getPersistentMind({ cursor, limit: PAGE_LIMIT }, { silent: true });accumulated = mergeEvents(accumulated, response.events || []);sawGap ||= response.gap === true;- cursor = response.cursor || cursor;+ sawTruncation ||= response.truncated === true;+ cursor = response.gap === true ? response.cursor : response.cursor || cursor;setMind({ state: response.state, profile: response.profile, autonomyMode: response.autonomyMode });page += 1;needsMore = response.hasMore === true && !sawGap;@@ -86,6 +91,7 @@ export default function MindTab() {cursorRef.current = cursor;setEvents((previous) => reset || sawGap || previous === null ? accumulated : mergeEvents(previous, accumulated));setGap(sawGap);+ setTruncated((current) => reset ? sawTruncation : current || sawTruncation);setLoadError(null);if (needsMore) deferredLoadRef.current = true;} catch (error) {@@ -161,6 +167,14 @@ export default function MindTab() {setSubmitError(null);};+ const changeText = (next) => {+ if (submitError) {+ draftIdRef.current = null;+ setSubmitError(null);+ }+ setText(next);+ };+const runLifecycle = async (action) => {setLifecyclePending(action);setLifecycleError(null);@@ -178,26 +192,33 @@ export default function MindTab() {};const acknowledge = async (event) => {+ if (eventActionPending) return;+ setEventActionPending(event.eventId);setLifecycleError(null);try {- await api.acknowledgePersistentMindEvent(event.eventId, mintId('ack'), { silent: true });+ await api.acknowledgePersistentMindEvent(event.eventId, `ack-${event.eventId}`, { silent: true });await loadHistory();} catch (error) {setLifecycleError(error?.message || 'Could not acknowledge the action');+ } finally {+ setEventActionPending(null);}};const promote = async (event) => {const content = eventText(event);- if (!content) return;+ if (!content || eventActionPending) return;+ setEventActionPending(event.eventId);setLifecycleError(null);try {await api.promotePersistentMindEvent(event.eventId, {- id: mintId('promotion'), approved: true, content, summary: content.slice(0, 500), type: 'insight', category: 'other',+ id: `promotion-${event.eventId}`, approved: true, content, summary: content.slice(0, 500), type: 'insight', category: 'other',}, { silent: true });await loadHistory();} catch (error) {setLifecycleError(error?.message || 'Could not promote the action');+ } finally {+ setEventActionPending(null);}};@@ -217,7 +238,7 @@ export default function MindTab() {{mind ? `${mind.profile?.providerId || 'No provider'} · ${mind.profile?.model || 'No model'} · ${mind.profile?.effort || 'provider default'} · autonomy ${mind.autonomyMode}` : 'Profile unavailable'}</p></div>- <div className="flex flex-wrap gap-2" aria-label="Persistent mind lifecycle">+ <div className="flex flex-wrap gap-2" role="group" aria-label="Persistent mind lifecycle">{!state?.started && <ActionButton label="Start" icon={CirclePlay} pending={lifecyclePending === 'start'} onClick={() => runLifecycle('start')} />}{state?.started && !isPaused && <ActionButton label="Pause" icon={CirclePause} pending={lifecyclePending === 'pause'} onClick={() => runLifecycle('pause')} />}{state?.started && isPaused && <ActionButton label="Resume" icon={CirclePlay} pending={lifecyclePending === 'resume'} onClick={() => runLifecycle('resume')} />}@@ -227,6 +248,7 @@ export default function MindTab() {</header>{gap && <Banner tone="warning" title="History gap detected">The saved cursor is no longer retained. The visible trace was reloaded from the newest bounded snapshot.</Banner>}+ {truncated && <Banner tone="info" title="Showing recent history">The trace is bounded to the newest {MAX_VISIBLE_EVENTS} events; older retained events are not shown.</Banner>}{loadError && <Banner tone="error" title="Conversation unavailable">{loadError}. Existing messages are preserved; retry when the connection recovers.</Banner>}{lifecycleError && <Banner tone="error" title="Action failed">{lifecycleError}</Banner>}@@ -279,10 +301,12 @@ export default function MindTab() {<p className="text-sm text-port-text">{eventLabel(selectedEvent.kind)}</p>{selectedEvent.kind === 'mind.capability.request' && (<div className="flex flex-wrap gap-2">- <ActionButton label="Acknowledge" icon={Check} onClick={() => acknowledge(selectedEvent)} />- <ActionButton label="Promote" icon={Upload} disabled={!eventText(selectedEvent)} onClick={() => promote(selectedEvent)} />+ <ActionButton label="Acknowledge" icon={Check} pending={eventActionPending === selectedEvent.eventId} onClick={() => acknowledge(selectedEvent)} /></div>)}+ {['mind.capability.request', 'mind.summary', 'mind.model.result'].includes(selectedEvent.kind) && (+ <ActionButton label="Promote" icon={Upload} pending={eventActionPending === selectedEvent.eventId} disabled={!eventText(selectedEvent)} onClick={() => promote(selectedEvent)} />+ )}</>) : <p className="text-sm text-port-text-muted">Choose an event to keep the selection in the URL and attach an annotation.</p>}</aside>@@ -299,7 +323,7 @@ export default function MindTab() {</div><div><label htmlFor="mind-input-text" className="mb-1 block text-sm font-medium text-port-text">{kind === 'message' ? 'Message' : 'Comment or idea'}</label>- <textarea id="mind-input-text" value={text} onChange={(event) => setText(event.target.value)} maxLength={8000} rows={3} className="w-full resize-y rounded border border-port-border bg-port-bg px-3 py-2 text-sm text-port-text" placeholder={kind === 'message' ? 'What should the mind consider on its next eligible wake?' : 'Add context without turning it into an immediate task.'} />+ <textarea id="mind-input-text" value={text} onChange={(event) => changeText(event.target.value)} maxLength={8000} rows={3} className="w-full resize-y rounded border border-port-border bg-port-bg px-3 py-2 text-sm text-port-text" placeholder={kind === 'message' ? 'What should the mind consider on its next eligible wake?' : 'Add context without turning it into an immediate task.'} /></div></div>{kind === 'annotation' && selectedEventId && <p className="mt-2 text-xs text-port-text-muted">Attached to selected event {selectedEventId}</p>}diff --git a/client/src/components/cos/tabs/MindTab.test.jsx b/client/src/components/cos/tabs/MindTab.test.jsxindex a5bf86fb2a..0502571689 100644--- a/client/src/components/cos/tabs/MindTab.test.jsx+++ b/client/src/components/cos/tabs/MindTab.test.jsx@@ -47,6 +47,7 @@ const response = (overrides = {}) => ({cursor: '1:mind-message:message-1',gap: false,hasMore: false,+ truncated: false,snapshot: {},state: { enabled: true, started: true, status: 'waiting', pauseReason: null },profile: { enabled: true, providerId: 'demo', model: 'demo-model', effort: 'high', thinkingInterface: 'text' },@@ -112,6 +113,25 @@ describe('MindTab', () => {expect(screen.getByText(/reloaded from the newest bounded snapshot/i)).toBeInTheDocument();});+ it('adopts a null server cursor after a fully pruned gap', async () => {+ renderTab();+ await screen.findByText('Review the next bounded slice.');+ api.getPersistentMind.mockResolvedValueOnce(response({ events: [], cursor: null, gap: true }));+ await act(async () => { socket.emitServer('connect'); });+ await waitFor(() => expect(api.getPersistentMind).toHaveBeenCalledTimes(2));++ api.getPersistentMind.mockResolvedValueOnce(response());+ await act(async () => { socket.emitServer('cos:mind:status'); });+ await waitFor(() => expect(api.getPersistentMind).toHaveBeenCalledTimes(3));+ expect(api.getPersistentMind.mock.calls[2][0].cursor).toBeNull();+ });++ it('labels a bounded initial snapshot as truncated', async () => {+ api.getPersistentMind.mockResolvedValue(response({ truncated: true }));+ renderTab();+ expect(await screen.findByText('Showing recent history')).toBeInTheDocument();+ });+it('keeps a failed message for a visible idempotent retry', async () => {const user = userEvent.setup();api.sendPersistentMindMessage.mockRejectedValueOnce(new Error('Provider unavailable'));@@ -129,6 +149,22 @@ describe('MindTab', () => {expect(api.sendPersistentMindMessage.mock.calls[1][0].id).toBe(firstId);});+ it('mints a new id when failed text is edited into a different submission', async () => {+ const user = userEvent.setup();+ api.sendPersistentMindMessage.mockRejectedValueOnce(new Error('Connection lost'));+ renderTab();+ await screen.findByText('Review the next bounded slice.');+ await user.type(screen.getByLabelText('Message'), 'Original text');+ await user.click(screen.getByRole('button', { name: 'Submit' }));+ await screen.findByRole('alert');+ const firstId = api.sendPersistentMindMessage.mock.calls[0][0].id;++ await user.type(screen.getByLabelText('Message'), ' updated');+ await user.click(screen.getByRole('button', { name: 'Submit' }));+ await waitFor(() => expect(api.sendPersistentMindMessage).toHaveBeenCalledTimes(2));+ expect(api.sendPersistentMindMessage.mock.calls[1][0].id).not.toBe(firstId);+ });+it('renders only redacted display fields, never hidden prompt payloads', async () => {api.getPersistentMind.mockResolvedValue(response({ events: [event({kind: 'mind.model.result',diff --git a/server/lib/agentRunEvents.js b/server/lib/agentRunEvents.jsindex a5d2663e94..168d6d1ca3 100644--- a/server/lib/agentRunEvents.js+++ b/server/lib/agentRunEvents.js@@ -132,7 +132,8 @@ const DROPPED_KEY_PATTERNS = [/^result$/i,/^params$/i,/^payload$/i,- /^transcript/i+ /^transcript/i,+ /^error$/i];/** Bounds. A ledger line must stay a diagnostic, not become a record copy. */diff --git a/server/lib/agentRunEvents.test.js b/server/lib/agentRunEvents.test.jsindex cd452f0200..55c8f354b9 100644--- a/server/lib/agentRunEvents.test.js+++ b/server/lib/agentRunEvents.test.js@@ -187,6 +187,13 @@ describe('redactRunEventData — privacy', () => {expect(data.detail).toContain('[REDACTED]');});+ it('drops free-form errors instead of exposing provider or record details', () => {+ const data = redactRunEventData({ error: 'provider failed for [email protected] with apiKey secret-value' });+ expect(data.error).toEqual({ redacted: 'content', chars: expect.any(Number) });+ expect(JSON.stringify(data)).not.toContain('[email protected]');+ expect(JSON.stringify(data)).not.toContain('secret-value');+ });+it('caps string length so a payload cannot smuggle a record body', () => {const data = redactRunEventData({ detail: 'x'.repeat(5000) });expect(data.detail.length).toBe(RUN_EVENT_LIMITS.maxStringChars + 1); // + the ellipsisdiff --git a/server/lib/index.js b/server/lib/index.jsindex 77126fae07..b74783bd4c 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -48,7 +48,6 @@ export * as spriteValidation from './spriteValidation.js';export * as storyBuilderValidation from './storyBuilderValidation.js';export * as telegramValidation from './telegramValidation.js';export * from './validation.js';-export * from './persistentMindPublic.js';// Cross-domain Zod fragments both `validation.js` and the per-domain files// import (leaf module, no cycle). Flat because `validation.js` re-exports the// same objects — same identity, so the collision detector is satisfied.@@ -219,6 +218,7 @@ export * from './agentRunReconcile.js';export * from './persistentMind.js';export * from './persistentMindTrajectory.js';export * from './persistentMindProfile.js';+export * from './persistentMindPublic.js';export * from './agentSentinel.js';export * from './bareUrl.js';export * from './bashResolver.js';diff --git a/server/routes/cosMindRoutes.js b/server/routes/cosMindRoutes.jsindex cf8e2a9d70..0180afc5f8 100644--- a/server/routes/cosMindRoutes.js+++ b/server/routes/cosMindRoutes.js@@ -13,7 +13,7 @@ import {import { normalizePersistentMindProfile } from '../lib/persistentMindProfile.js';import { publicPersistentMindState } from '../lib/persistentMindPublic.js';import { validateRequest } from '../lib/validation.js';-import { readPersistentMindEvents } from '../services/agentRunEventLog.js';+import { readPersistentMindEvents, readPersistentMindHistory } from '../services/agentRunEventLog.js';import { loadState } from '../services/cosState.js';import {appendPersistentMindAnnotation,@@ -65,6 +65,13 @@ const requireSuccess = (result) => {return result;};+const requireMindEvent = async (targetEventId) => {+ const events = await readPersistentMindHistory(PERSISTENT_MIND_ID);+ if (!events.some((event) => event.eventId === targetEventId)) {+ throw new ServerError('Persistent mind event not found', { status: 404, code: 'NOT_FOUND' });+ }+};+router.get('/mind', asyncHandler(async (req, res) => {const query = validateRequest(mindReadSchema, req.query);const [history, state, root] = await Promise.all([@@ -120,6 +127,7 @@ router.post('/mind/stop', asyncHandler(async (_req, res) => {router.post('/mind/events/:eventId/acknowledge', asyncHandler(async (req, res) => {const { eventId: targetEventId } = validateRequest(eventParamsSchema, req.params);const { id } = validateRequest(acknowledgementSchema, req.body);+ await requireMindEvent(targetEventId);const result = await appendPersistentMindAnnotation({id,targetEventId,@@ -131,7 +139,8 @@ router.post('/mind/events/:eventId/acknowledge', asyncHandler(async (req, res) =router.post('/mind/events/:eventId/promote', asyncHandler(async (req, res) => {const { eventId: sourceEventId } = validateRequest(eventParamsSchema, req.params);- const { id: _id, ...input } = validateRequest(promotionSchema, req.body);+ const input = validateRequest(promotionSchema, req.body);+ await requireMindEvent(sourceEventId);const result = requireSuccess(await promotePersistentMindMemory({ ...input, sourceEventId }));res.status(201).json({ success: true, memoryId: result.memory?.id || null });}));diff --git a/server/routes/cosMindRoutes.test.js b/server/routes/cosMindRoutes.test.jsindex 54a49b7586..4b150cfe8f 100644--- a/server/routes/cosMindRoutes.test.js+++ b/server/routes/cosMindRoutes.test.js@@ -5,6 +5,7 @@ import { errorMiddleware } from '../lib/errorHandler.js';const mocks = vi.hoisted(() => ({readPersistentMindEvents: vi.fn(),+ readPersistentMindHistory: vi.fn(),loadState: vi.fn(),getPersistentMindState: vi.fn(),enqueuePersistentMindMessage: vi.fn(),@@ -16,7 +17,10 @@ const mocks = vi.hoisted(() => ({stopPersistentMind: vi.fn(),}));-vi.mock('../services/agentRunEventLog.js', () => ({ readPersistentMindEvents: mocks.readPersistentMindEvents }));+vi.mock('../services/agentRunEventLog.js', () => ({+ readPersistentMindEvents: mocks.readPersistentMindEvents,+ readPersistentMindHistory: mocks.readPersistentMindHistory,+}));vi.mock('../services/cosState.js', () => ({ loadState: mocks.loadState }));vi.mock('../services/persistentMindContext.js', () => ({appendPersistentMindAnnotation: mocks.appendPersistentMindAnnotation,@@ -48,6 +52,7 @@ describe('persistent mind routes', () => {beforeEach(() => {vi.clearAllMocks();mocks.readPersistentMindEvents.mockResolvedValue({ events: [], cursor: null, gap: false, hasMore: false, snapshot: {} });+ mocks.readPersistentMindHistory.mockResolvedValue([{ eventId: 'event-1' }]);mocks.getPersistentMindState.mockResolvedValue({enabled: true, status: 'idle', started: false, queuedMessages: [{ id: 'private', text: 'must not leak' }],activeTurn: null, lastCompletedTurnId: null, lastCompletedAt: null, nextEligibleWakeAt: null,@@ -138,7 +143,17 @@ describe('persistent mind routes', () => {});expect(res.status).toBe(201);expect(mocks.promotePersistentMindMemory).toHaveBeenCalledWith(expect.objectContaining({- approved: true, content: 'Safe summary', sourceEventId: 'event-1',+ id: 'promotion-1', approved: true, content: 'Safe summary', sourceEventId: 'event-1',}));});++ it('refuses action annotations for an event outside the retained mind ledger', async () => {+ mocks.readPersistentMindHistory.mockResolvedValue([]);+ expect((await post('/mind/events/missing/acknowledge', { id: 'ack-1' })).status).toBe(404);+ expect((await post('/mind/events/missing/promote', {+ id: 'promotion-1', approved: true, content: 'Safe summary',+ })).status).toBe(404);+ expect(mocks.appendPersistentMindAnnotation).not.toHaveBeenCalled();+ expect(mocks.promotePersistentMindMemory).not.toHaveBeenCalled();+ });});diff --git a/server/services/agentRunEventLog.js b/server/services/agentRunEventLog.jsindex 77448b3553..5d43c13de7 100644--- a/server/services/agentRunEventLog.js+++ b/server/services/agentRunEventLog.js@@ -444,6 +444,7 @@ export async function readPersistentMindEvents({cursor: persistentMindEventCursor(last),gap,hasMore: cursorIndex >= 0 && available.length > events.length,+ truncated: cursorIndex < 0 && available.length > events.length,snapshot: projectPersistentMind(retained, mindId),};}diff --git a/server/services/persistentMindContext.js b/server/services/persistentMindContext.jsindex a8629c1721..3d21c8833e 100644--- a/server/services/persistentMindContext.js+++ b/server/services/persistentMindContext.js@@ -33,6 +33,7 @@ import * as memoryBackend from './memoryBackend.js';const ROLLUP_PATH = join(PATHS.cos, 'persistent-mind-rollups.json');const ROLLUP_STORE_SCHEMA_VERSION = 1;const queueRollupWrite = createFileWriteQueue();+const promotionRuns = new Map();const emptyStore = () => ({ schemaVersion: ROLLUP_STORE_SCHEMA_VERSION, rollups: [] });@@ -213,7 +214,8 @@ export function appendPersistentMindAnnotation({* Promote one user-approved fact into the existing Brain backend. Absence of an* explicit `approved: true` is a refusal, not a pending or empty memory.*/-export async function promotePersistentMindMemory({+async function performPersistentMindPromotion({+ id,approved,mindId = PERSISTENT_MIND_ID,turnId = null,@@ -226,7 +228,15 @@ export async function promotePersistentMindMemory({memoryApi = memoryBackend,} = {}) {if (approved !== true) return { success: false, error: 'Explicit user approval is required' };+ if (typeof id !== 'string' || !id.trim()) return { success: false, error: 'Promotion id is required' };if (typeof content !== 'string' || !content.trim()) return { success: false, error: 'Memory content is required' };+ const promotionId = id.trim();+ const previous = (await readPersistentMindHistory(mindId)).find(+ (event) => event.kind === 'mind.memory.promoted' && event.data?.promotionId === promotionId+ );+ if (previous) {+ return { success: true, duplicate: true, memory: { id: previous.data.memoryId } };+ }const memory = await memoryApi.createMemory({type,content: content.trim().slice(0, 10_240),@@ -243,6 +253,7 @@ export async function promotePersistentMindMemory({turnId,eventId: `mind-memory:${memory.id}`,data: {+ promotionId,memoryId: memory.id,sourceEventId,type,@@ -252,3 +263,11 @@ export async function promotePersistentMindMemory({});return { success: true, memory };}++export function promotePersistentMindMemory(input = {}) {+ const key = typeof input.id === 'string' ? input.id.trim() : '';+ if (key && promotionRuns.has(key)) return promotionRuns.get(key);+ const run = performPersistentMindPromotion(input).finally(() => promotionRuns.delete(key));+ if (key) promotionRuns.set(key, run);+ return run;+}diff --git a/server/services/persistentMindContext.test.js b/server/services/persistentMindContext.test.jsindex a5696cb4e2..743e03c8ad 100644--- a/server/services/persistentMindContext.test.js+++ b/server/services/persistentMindContext.test.js@@ -212,6 +212,7 @@ describe('trajectory annotations and Brain promotion', () => {const memoryApi = { createMemory: vi.fn(async (input) => ({ id: 'memory-1', ...input })) };await expect(promotePersistentMindMemory({+ id: 'promotion-refused',approved: false,content: 'Remember this.',memoryApi,@@ -220,6 +221,7 @@ describe('trajectory annotations and Brain promotion', () => {expect(mock.appendMindEvent).not.toHaveBeenCalled();const promoted = await promotePersistentMindMemory({+ id: 'promotion-1',approved: true,turnId: 'turn-1',sourceEventId: 'event-2',@@ -241,7 +243,21 @@ describe('trajectory annotations and Brain promotion', () => {expect(mock.appendMindEvent).toHaveBeenCalledWith(expect.objectContaining({kind: 'mind.memory.promoted',turnId: 'turn-1',- data: expect.objectContaining({ memoryId: 'memory-1', sourceEventId: 'event-2', approved: true }),+ data: expect.objectContaining({+ promotionId: 'promotion-1', memoryId: 'memory-1', sourceEventId: 'event-2', approved: true,+ }),}));++ mock.history = [{+ kind: 'mind.memory.promoted',+ data: { promotionId: 'promotion-1', memoryId: 'memory-1' },+ }];+ await expect(promotePersistentMindMemory({+ id: 'promotion-1',+ approved: true,+ content: 'Remember this user-approved fact.',+ memoryApi,+ })).resolves.toMatchObject({ success: true, duplicate: true, memory: { id: 'memory-1' } });+ expect(memoryApi.createMemory).toHaveBeenCalledTimes(1);});});diff --git a/server/services/persistentMindSupervisor.js b/server/services/persistentMindSupervisor.jsindex 55100cd4a8..ea84046e9e 100644--- a/server/services/persistentMindSupervisor.js+++ b/server/services/persistentMindSupervisor.js@@ -30,6 +30,7 @@ import { acquireCosActionReservation, acquireCosGlobalSlot } from './cosAdmissioimport { appendMindEvent } from './agentRunEventLog.js';import { preparePersistentMindContext } from './persistentMindContext.js';import { resolvePersistentMindProfile } from './persistentMindProfile.js';+import { publicPersistentMindState } from '../lib/persistentMindPublic.js';export const PERSISTENT_MIND_WAKE_EVENT_ID = 'cos-persistent-mind-wake';export const PERSISTENT_MIND_WATCHDOG_EVENT_ID = 'cos-persistent-mind-watchdog';@@ -57,16 +58,7 @@ async function mutateMindState(mutator) {}function emitMindStatus(state) {- cosEvents.emit('persistent-mind:status', {- enabled: state.enabled,- started: state.started,- status: state.status,- pauseReason: state.pauseReason,- queuedMessages: state.queuedMessages.length,- activeTurnId: state.activeTurn?.id || null,- lastCompletedTurnId: state.lastCompletedTurnId,- nextEligibleWakeAt: state.nextEligibleWakeAt,- });+ cosEvents.emit('persistent-mind:status', publicPersistentMindState(state));}function armWatchdog() {diff --git a/server/services/socket.js b/server/services/socket.jsindex 7813807bab..a527c54f6e 100644--- a/server/services/socket.js+++ b/server/services/socket.js@@ -36,7 +36,6 @@ import { detachShellSocket, registerShellHandlers } from '../sockets/shell.js';import { getBuildId } from '../lib/buildId.js';import { authEvents, extractToken, isAuthEnabled, verifySession } from './auth.js';import { runEventLogEvents } from './agentRunEventLog.js';-import { publicPersistentMindState } from '../lib/persistentMindPublic.js';// Store CoS subscribersconst cosSubscribers = new Set();@@ -332,9 +331,7 @@ function setupCosEventForwarding() {cosEvents.on('agent:completed', (data) => broadcastToCos('cos:agent:completed', data));cosEvents.on('agent:output', (data) => broadcastToCos('cos:agent:output', data));cosEvents.on('agent:btw', (data) => broadcastToCos('cos:agent:btw', data));- cosEvents.on('persistent-mind:status', (data) => {- broadcastToCos('cos:mind:status', publicPersistentMindState(data));- });+ cosEvents.on('persistent-mind:status', (data) => broadcastToCos('cos:mind:status', data));// Memory eventscosEvents.on('memory:created', (data) => broadcastToCos('cos:memory:created', data));