Principle:23blocks OS Ai maestro Agent Status Presence
| Knowledge Sources | |
|---|---|
| Domains | Status_Presence |
| Last Updated | 2026-10-26 10:00 GMT |
Overview
A single-source status pattern where agent presence (working / needs-you / ready / offline) comes from one server feed, flows through one browser store, and is read by every view through one function.
Description
Agent status has one source. Working / Needs you / Ready / Offline comes only from the server feed (`getActivity`), normalized by `lib/agent-presence.ts`, through one browser store (`useSessionActivity`), read with `presenceOf(agent)`. No view computes status from its own data, and no view opens its own status socket. Fix wrong status at the server, never in a view.
The server feed merges hook states (the authority when fresh) with terminal activity timestamps (fallback for agents with no hook). The browser store subscribes via the `/status` WebSocket and exposes `presenceOf` via `useSyncExternalStore` (React 18).
Usage
Use this principle when designing a real-time status system where:
- All views must show the same status for the same agent
- Status is server-authoritative, not view-computed
- A single WebSocket feed serves all views (no per-view sockets)
Theoretical Basis
The pattern is single source of truth with normalized vocabulary:
Server: getActivity() → Record<session, SessionActivityInfo>
WS: broadcastStatusUpdate(session, status, hookStatus, ...)
Browser: useSessionActivity() → { activity, presenceOf }
View: presenceOf(agent) → 'working' | 'needs-you' | 'ready' | 'offline'
The normalization function maps raw hook words to the sidebar vocabulary. The hook fires `waiting_for_input` for both "needs you" (permission dialog) and "ready" (idle after a minute); `normalizeActivityStatus` distinguishes them using the notification type.