Expand description
Agents rotate_token (POST /api/v1/agent/rotate-token): an agent replaces the token of an agent on this
machine. The token is part of the agent’s spawn environment, so the new one reaches the agent only through a
restart; the old value stops working the moment the stored row is replaced (Store::agent_token_rotate).
The caller is the agent its token names; a request without one is refused, so a change is never attributed to the operator. Each rotation, each wait for the person’s window and each refusal is recorded in the audit log under the calling agent. The answer, the note a caller is sent and the audit never carry a token value.
- Not your own agent: a restart of yourself is not yours to run; another agent rotates yours.
- A stopped agent: the row is replaced and nothing restarts; it takes the new token when it next starts.
- A running agent: it is stopped as
Agents stopstops it (the person’s 30 s window to keep it running, except for a worker the caller opened, which is stopped at once), its row is replaced once it has stopped, and it starts again in the pane and conversation it had. If its user keeps it running, nothing changes and the caller is told.
Structs§
Enums§
- Restart 🔒
- How a restart in the agent’s own pane went.
Constants§
- AUDIT_
ACTION 🔒 - The audit entry’s action for a rotation.
Functions§
- after_
restart_ 🔒note - finish_
after_ 🔒window - After the person’s window: if the agent stopped, replace its token and start it again; tell the caller how it
ended, by a held
[AgentMux]note that does not wake it, and record it under the caller. - handle_
agent_ 🔒rotate_ token - replace_
row 🔒 - Replace the stored token (and its index entry): off the async workers, as it takes the store’s lock.
- restart_
in_ 🔒place - Start the agent again, in the block (pane) it has, with its session resumed: its spawn environment is built afresh and carries the replaced token.
- rotate 🔒
- run 🔒
- settle 🔒
- wait_
for_ 🔒stop - Wait for the stop request to end:
Okonce the agent has stopped (or already had), else why it did not.