Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/src/pages/SetupAssistant.tsx
atlas 7b5400ecb8 grant manage_root_agent by stored permission only, not by the name ruth
Permission::default_for and hive-sh4re's MANAGER_AGENT are gone: every
agent with no permissions key holds Permission::DEFAULT, ruth included.
The agent-name parameters that only fed default_for go with it
(permissions::effective, HiveCopy::before_read/after_read and their
callers).

swarm-controller seeds the grant ruth held by name: at start, a declared
ruth whose permissions are unset gets DEFAULT plus manage_root_agent
written into her key, once, logged. A set key is never touched. It is a
one-shot to delete once every swarm has passed it.

The swarm UI setup assistant opens the create form with
manage_root_agent checked, so a new ruth is created with the grant.
permissions_import no longer adds ruth to the import or splits her
default. Docs and help text no longer say ruth holds the grant by
default; swarmctl-cli.md regenerated.
2026-10-17 08:10:08 +02:00

85 lines
2.4 KiB
TypeScript

// <SetupAssistant> - the start page's first-time helper: a paperclip with a
// speech bubble offering to set up an agent. It renders only while the swarm
// has no `ruth` (see `ruthIsMissing`), and a click opens the create-agent
// form with her name filled in and `manage_root_agent` checked on top of the
// default permissions (`RUTH_EXTRA_PERMISSIONS`); the form already selects
// the only hive. No dismiss: once ruth exists it goes away.
import { useEffect, useState } from "preact/hooks";
import { Dialog } from "../ui/dialog/Dialog.js";
import {
RUTH_EXTRA_PERMISSIONS,
ruthIsMissing,
} from "../shell/ruth-missing.js";
import { CreateAgentForm } from "./CreateAgentForm.js";
import "./SetupAssistant.css";
export function SetupAssistant() {
const [missing, setMissing] = useState(false);
const [open, setOpen] = useState(false);
useEffect(() => {
let cancelled = false;
void ruthIsMissing((url) => fetch(url)).then((m) => {
if (!cancelled) setMissing(m);
});
return () => {
cancelled = true;
};
}, []);
if (!missing) return null;
return (
<>
<button
type="button"
class="setup-assistant"
onClick={() => setOpen(true)}
>
<span class="setup-assistant-bubble">
want to help me set up an agent? click here
</span>
<svg
class="setup-assistant-clip"
viewBox="0 0 40 80"
aria-hidden="true"
>
<path
d="M27 22v34a9 9 0 0 1-18 0V16a6 6 0 0 1 12 0v36a3 3 0 0 1-6 0V24"
fill="none"
stroke="currentColor"
stroke-width="3.5"
stroke-linecap="round"
/>
<circle
cx="13"
cy="38"
r="3.2"
fill="var(--bg)"
stroke="currentColor"
/>
<circle
cx="23"
cy="38"
r="3.2"
fill="var(--bg)"
stroke="currentColor"
/>
<circle cx="13.6" cy="38.4" r="1.2" fill="currentColor" />
<circle cx="23.6" cy="38.4" r="1.2" fill="currentColor" />
</svg>
</button>
<Dialog
open={open}
onClose={() => setOpen(false)}
label="create agent"
plain
>
<CreateAgentForm
initialName="ruth"
extraPermissions={RUTH_EXTRA_PERMISSIONS}
onClose={() => setOpen(false)}
/>
</Dialog>
</>
);
}