swarm-controller: send one operator message to several agents
The swarm UI's broadcast page (#5524) needs the controller to do the fan-out, so POST /api/agents/broadcast takes {agents, body} and answers 200 with {results: [{agent, sent, reason?}]} in request order. - agent_input.rs: the single-agent send is now send_one, which both routes call; the single route maps its outcome to the same statuses and texts as before. The broadcast validates the whole request first (sender, empty body, empty or duplicated agents, more than 64, a name outside the roster), then sends up to 16 at once with the single route's no-responders window. - main.rs: wires the route. - docs/swarm/ui.md: describes the route next to the single-agent one.
This commit is contained in:
parent
ef507b8912
commit
484a9fd4c1
3 changed files with 356 additions and 32 deletions
|
|
@ -223,6 +223,15 @@ credential may subscribe there. The harness doesn't reply, so swarm-controller
|
|||
answers 202 when the request times out after two seconds, and 503 when the
|
||||
queue reports no subscriber.
|
||||
|
||||
`POST /api/agents/broadcast` takes `{agents, body}` and sends the same
|
||||
message to each agent the same way, up to 16 at once. It answers 200 with
|
||||
`{results: [{agent, sent, reason?}]}`, one entry per agent in request order,
|
||||
and `reason` holds the text the single-agent route would have answered with.
|
||||
One agent not listening doesn't stop the others. swarm-controller refuses the
|
||||
whole request and sends nothing when `body` or `agents` is empty, when
|
||||
`agents` names an agent twice, names more than 64, or names one that
|
||||
`GET /api/agents` doesn't list.
|
||||
|
||||
A command has its own subject, so the harness never mistakes typed text for
|
||||
one. `POST /api/agents/<name>/cancel` sends `"cancel"` as a NATS request on
|
||||
`$SWARM.control.<name>`, and only swarm-controller may publish there. The
|
||||
|
|
|
|||
Loading…
Reference in a new issue