Skip to main content

Module agent_rotate_token

Module agent_rotate_token 

Source
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 stop stops 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§

RotateRequest 🔒

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: Ok once the agent has stopped (or already had), else why it did not.