archetypes: prefill the create form from flake-declared agent archetypes
A flake declares agent archetypes in its `hyperhiveArchetypes` output,
`<name> = { module; meta; }`. The hyperhive flake ships `reviewer`
(default permissions without `execution`).
swarm-builder answers `$SWARM.builder.archetypes` with the `meta` of
every archetype its own hyperhive source declares. swarm-controller asks
once the queue connects and every 10 minutes, checks each archetype as
`POST /api/agents` checks its settings, and stores the result in the
`agent-archetypes` KV bucket when it changed. `GET /api/archetypes`
serves it, and the create form's archetype select prefills permissions,
resource caps and inference from it.
The agent created is an ordinary agent with its own config repo; the
archetype's module is not applied yet.
Refs #5386
This commit is contained in:
parent
eb92e83c95
commit
51035eac1d
22 changed files with 1244 additions and 30 deletions
|
|
@ -121,6 +121,33 @@ let
|
|||
&& env.SWARM_BUILDER_CONFIG_ORG == "agent-configs"
|
||||
&& env.SWARM_BUILDER_FORGE_URL == "https://${withBuilder.services.hyperhive.swarm.forge.domain}";
|
||||
}
|
||||
{
|
||||
# The builder evaluates `builtins.mapAttrs (_: a: a.meta)` over this
|
||||
# output and prints it as JSON. A derivation or a path in `meta` would
|
||||
# make that evaluation build or copy something; a function would not
|
||||
# print at all.
|
||||
name = "the built-in archetypes carry a module and a meta of plain data, and reviewer has no shell";
|
||||
ok =
|
||||
let
|
||||
plain =
|
||||
v:
|
||||
if lib.isDerivation v || lib.isFunction v || builtins.isPath v then
|
||||
false
|
||||
else if lib.isAttrs v then
|
||||
lib.all plain (lib.attrValues v)
|
||||
else if lib.isList v then
|
||||
lib.all plain v
|
||||
else
|
||||
true;
|
||||
archetypes = self.hyperhiveArchetypes;
|
||||
metas = builtins.mapAttrs (_: a: a.meta) archetypes;
|
||||
reviewer = metas.reviewer.permissions;
|
||||
in
|
||||
lib.all (a: a ? module && a.meta.description != "") (lib.attrValues archetypes)
|
||||
&& plain metas
|
||||
&& lib.elem "messaging" reviewer
|
||||
&& !(lib.elem "execution" reviewer);
|
||||
}
|
||||
{
|
||||
# The responder denies a client id it does not know, and a NATS denial
|
||||
# arrives as a timeout.
|
||||
|
|
|
|||
Loading…
Reference in a new issue