swarm UI: send a message to an agent, without its hive
The agent view in the swarm UI gets a message box. The text reaches the
agent's harness straight from swarm-controller over the swarm queue and
becomes an inbox turn from the operator's authelia username. hive-c0re is
not in the path.
- gateway: `/api/` forwards authelia's `Remote-User`, replacing any the
client sent.
- swarm-controller: `POST /api/agents/{name}/input` takes that header as
the sender (401 without it) and sends `{from, body}` as a NATS request
on `$SWARM.input.<agent>`. No subscriber is a 503.
- swarm-nats-auth: the controller is granted publish on `$SWARM.input.*`;
no hive or agent grant names the family, so the harness can trust
`from`.
- hive-agent: a task subscribes to the agent's own input subject and
pushes each message into the serve loop's existing reminder channel,
renamed `local_msg_*` since it now carries both.
The harness does not reply to the request: no agent grant covers a reply
subject. The controller therefore answers 202 once the request times out
(2s) and 503 on the server's no-responders status.
Closes #4828
This commit is contained in:
parent
5971b51e65
commit
48ac4ac423
13 changed files with 664 additions and 24 deletions
|
|
@ -29,9 +29,35 @@ terminal in the same preview, and **expand** opens it in its own tab, as it
|
|||
does for the agent. The list refreshes every 10 seconds, so a subagent the
|
||||
agent spawns shows up once it writes output.
|
||||
|
||||
Both terminals are live views with no input box: a preview shows rows
|
||||
published while it's open. Subagents take no input from the swarm. A subagent
|
||||
terminal has no turn-state badges.
|
||||
A preview shows rows published while it's open. A subagent terminal has no
|
||||
turn-state badges.
|
||||
|
||||
### Sending a message to an agent
|
||||
|
||||
Under an agent's terminal, in the preview and in its own tab, is a **message**
|
||||
box. **send** hands the text to the agent's harness, and the agent takes it as
|
||||
an inbox message from your authelia username. **sent** means the harness was
|
||||
listening and holds the message. If the harness isn't running, or isn't
|
||||
connected to the swarm queue, the box shows an error and the agent gets nothing.
|
||||
Subagents have no message box.
|
||||
|
||||
The message doesn't go through the agent's hive, so the hive dashboard's
|
||||
message history doesn't list it. The agent's answer shows in its terminal; an
|
||||
agent that calls `send` to your username gets an unknown-recipient error. A
|
||||
harness that restarts before taking its turn loses the message.
|
||||
|
||||
<details><summary>How a message reaches the agent</summary>
|
||||
|
||||
The gateway sets `Remote-User` from authelia's answer on every `/api/`
|
||||
request, replacing any the browser sent. `POST /api/agents/<name>/input`
|
||||
takes that header as the sender and sends `{from, body}` as a NATS request on
|
||||
`$SWARM.input.<name>`. swarm-controller is the only queue client allowed to
|
||||
publish there. The agent's harness subscribes to its own subject and queues
|
||||
each message for its turn loop with its reminders. 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.
|
||||
|
||||
</details>
|
||||
|
||||
<details><summary>Where the subagent list and rows come from</summary>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue