// — the names every agent in the swarm may reach through its // hive's egress proxy: the swarm-wide allowed domains, with an add box and a // remove beside each. A card that starts folded and reads nothing until it is // opened. // // The entries are the ones of `GET /api/egress/allowed-domains` that hold for // every agent (an agent's own entries stay on its card). They add to the names // each hive's own configuration allows. An entry the controller keeps from an // environment or account (`derived`) is not listed here. Adding and removing // are the agent card's own: `AddForm` without an agent, `useAllowedDomains`. import { useState } from "preact/hooks"; import { ApiErrorPanel } from "@hive/shared/api-error-panel.js"; import { Badge } from "@hive/shared/badge.js"; import { AddForm } from "../../agent/detail/AllowedDomains.js"; import { useAllowedDomains } from "../../agent/detail/useAllowedDomains.js"; import { Button } from "../../ui/button/Button.js"; import { LazyDisclosure } from "../../ui/disclosure/LazyDisclosure.js"; import { Dialog } from "../../ui/dialog/Dialog.js"; import "../../agent/detail/AgentLimits.css"; import "./SwarmPage.css"; function EgressBody() { const { entries, error, busy, remove, refetch } = useAllowedDomains(); const [adding, setAdding] = useState(false); // A list already loaded stays under a failed refetch, so a change that // worked is not hidden by a read that did not. const errorPanel = error ? ( <> ) : null; if (entries === null) { return ( errorPanel ?? ( loading the allowed domains… ) ); } const swarmWide = entries.filter( (e) => e.agent === undefined && e.derived !== true, ); return ( <> {errorPanel}

Names every agent in the swarm may reach through its hive's proxy, on top of what each hive's own configuration allows. An agent that has unrestricted internet reaches any name anyway. The hive reads a change within about 30 seconds.

{swarmWide.length === 0 ? (

none added

) : ( )} setAdding(true)} /> setAdding(false)} label="add an allowed domain" plain > {/* Remounted per open, so a cancelled add leaves nothing behind. */} {adding ? ( setAdding(false)} onAdded={() => { setAdding(false); refetch(); }} /> ) : null} ); } export function EgressCard() { return ( ); }