// Whether the swarm has no agent named `ruth`, from `GET /api/agents/status`. // The start page's setup assistant shows only then: when the roster has no // `ruth`, or has one its hive declares `destroyed` (the declaration stays in // the roster for good, though the agent is gone). Offline and paused still // count as an agent. It is a nudge, so anything short of a clear answer // is `false`: a failed request or an unreadable list must not tell the // operator to set up an agent that may already exist. type Fetch = (url: string) => Promise<{ ok: boolean; json: () => Promise; }>; export async function ruthIsMissing(fetchImpl: Fetch): Promise { try { const r = await fetchImpl("/api/agents/status"); if (!r.ok) return false; const rows = await r.json(); if (!Array.isArray(rows)) return false; return !rows.some((row) => { const { name, wanted } = row as { name?: unknown; wanted?: unknown }; return name === "ruth" && wanted !== "destroyed"; }); } catch { return false; } } /** The archetype the setup assistant's create form starts on. Its `meta` * gives ruth `manage_root_agent` (she recovers the other agents), `logs` and * `metrics`, and the model. swarm-controller refuses `logs` and `metrics` * (409, naming the hive) for a hive that does not advertise * `tolerant-permissions`; the form shows that error, and unticking them * creates ruth without. */ export const RUTH_ARCHETYPE = { source: "hyperhive", name: "ruth" };