Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: start page setup assistant offers to create ruth

This commit is contained in:
damocles 2026-10-15 19:18:01 +02:00
commit 8bf53f7ed9
7 changed files with 208 additions and 15 deletions

View file

@ -0,0 +1,22 @@
// Whether the swarm has no agent named `ruth`, from `GET /api/agents/status`.
// The start page's setup assistant shows only then. It is a nudge, so
// anything short of a clear "ruth is not in the roster" answers `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<unknown>;
}>;
export async function ruthIsMissing(fetchImpl: Fetch): Promise<boolean> {
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) => (row as { name?: unknown }).name === "ruth");
} catch {
return false;
}
}