dashboard: POST /matrix-account-login + account-aware hive-priv matrix-token write (BE-2)

This commit is contained in:
damocles 2026-06-16 10:49:01 +02:00 committed by mara
commit 9c480daf0a
6 changed files with 228 additions and 12 deletions

View file

@ -253,14 +253,21 @@ pub async fn write_agent_forge_token(agent_name: &str, token: &str) -> Result<()
.await?)
}
/// Write the Matrix access token for `agent_name` to
/// `<agent_state_root>/<agent_name>/state/matrix-token` via hive-priv
/// (running as root). The file is written 0600 and chowned to the agent
/// user so it is readable from inside the agent container.
pub async fn write_agent_matrix_token(agent_name: &str, token: &str) -> Result<()> {
/// Write a Matrix access token for `agent_name` via hive-priv (running as
/// root). `account: None` writes the hive-internal
/// `<state>/matrix-token`; `account: Some(name)` writes
/// `<state>/matrix-token-<name>` for an extra (external) account. The file
/// is written 0600 and chowned to the agent user so it is readable from
/// inside the agent container. hive-priv validates the account suffix.
pub async fn write_agent_matrix_token(
agent_name: &str,
token: &str,
account: Option<&str>,
) -> Result<()> {
ok(call(&PrivRequest::WriteAgentMatrixToken {
agent_name: agent_name.to_owned(),
token: token.to_owned(),
account: account.map(ToOwned::to_owned),
})
.await?)
}