Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: the setup assistant shows when ruth is declared destroyed

This commit is contained in:
iris 2026-10-28 22:14:52 +01:00
commit 1ee481c0b1
3 changed files with 25 additions and 6 deletions

View file

@ -22,7 +22,7 @@ shut. A dropdown inside a dialog opens above the dialog and the dialog doesn't c
| route | what |
| ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/` | the start page: the swarm's name over a digital-rain backdrop, plus a paperclip offering to set up an agent while no `ruth` exists (it opens the create form with `ruth` filled in); the swarm name in the header links here |
| `/` | the start page: the swarm's name over a digital-rain backdrop, plus a paperclip offering to set up an agent while no `ruth` exists, or her hive declares her destroyed (it opens the create form with `ruth` filled in); the swarm name in the header links here |
| `/agents` | every agent, under a folded **hives** card with the hive directory and each hive's last reported status: status, config PR, wanted state, inference settings, resource caps, permissions; create agents (with their permissions, optionally from an [archetype](archetypes.md)), link forge, matrix and GitHub accounts |
| `/agents/<name>/terminal` | one agent's live terminal |
| `/agents/<name>/subagents/<subagent>/terminal` | one of that agent's subagents' live terminal |

View file

@ -1,8 +1,10 @@
// 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.
// 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;
@ -15,7 +17,10 @@ export async function ruthIsMissing(fetchImpl: Fetch): Promise<boolean> {
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");
return !rows.some((row) => {
const { name, wanted } = row as { name?: unknown; wanted?: unknown };
return name === "ruth" && wanted !== "destroyed";
});
} catch {
return false;
}

View file

@ -33,6 +33,20 @@ test("a roster with ruth means she is not missing", async () => {
);
});
test("a ruth declared destroyed is missing; a stopped or paused one is not", async () => {
assert.equal(
await ruthIsMissing(answering([{ name: "ruth", wanted: "destroyed" }])),
true,
);
for (const wanted of ["up", "offline", "paused", null, undefined]) {
assert.equal(
await ruthIsMissing(answering([{ name: "ruth", wanted }])),
false,
String(wanted),
);
}
});
test("anything but a clear answer is not missing", async () => {
assert.equal(await ruthIsMissing(answering([], false)), false);
assert.equal(await ruthIsMissing(answering({ not: "a list" })), false);