Skip to main content

agentmux_srv/server/remote_ops/
reclaim_op.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! `app.history_reclaim`: ask this machine to give the shared pane-history store's free space
5//! back at its next start, withdraw that, or read where it stands (spec ยง4.3). It is the local
6//! `App history_reclaim` unchanged (`app_api::agent_history_reclaim`), recorded as `agent@machine`.
7//! Nothing runs now, and the person sees the request pending in History > Storage.
8
9use serde_json::Value;
10
11use super::{AppState, RemoteCaller, RemoteRefusal, RemoteResult};
12use crate::server::app_api::agent_history_reclaim::run_for;
13
14pub(super) async fn history_reclaim(_state: &AppState, caller: &RemoteCaller, params: Value) -> RemoteResult {
15    let action = params.get("action").and_then(Value::as_str).unwrap_or("status");
16    if !matches!(action, "request" | "cancel" | "status") {
17        return Err(RemoteRefusal::failed(format!("action is \"request\", \"cancel\" or \"status\", not {action:?}")));
18    }
19    run_for(action, &caller.actor()).map_err(RemoteRefusal::failed)
20}