agentmux_srv/server/agent_handlers/
endpoint.rs1use std::sync::Arc;
9
10use crate::backend::rpc::engine::WshRpcEngine;
11use crate::backend::rpc_types::{CommandUndoAgentEndpointData, UndoAgentEndpointResult, COMMAND_UNDO_AGENT_ENDPOINT};
12
13use super::super::AppState;
14
15pub fn register(engine: &Arc<WshRpcEngine>, state: &AppState) {
16 let state = state.clone();
17 engine.register_typed(COMMAND_UNDO_AGENT_ENDPOINT, move |cmd: CommandUndoAgentEndpointData, _ctx| {
18 let state = state.clone();
19 async move {
20 let result = tokio::task::spawn_blocking(move || crate::server::app_api::agent_env::undo_endpoint(&state, &cmd.notice_id, "you"))
21 .await
22 .map_err(|e| format!("undoagentendpoint: {e}"))?;
23 Ok(match result {
24 Ok(()) => UndoAgentEndpointResult { restored: true, reason: None },
25 Err(why) => UndoAgentEndpointResult { restored: false, reason: Some(why) },
26 })
27 }
28 });
29}