agentmux_srv/server/remote_ops/
google_ops.rs1use serde_json::Value;
11
12use super::{AppState, RemoteCaller, RemoteRefusal, RemoteResult};
13use crate::server::google_handlers::{grant_as, status_for, GrantBody};
14
15pub(super) async fn status(state: &AppState, _caller: &RemoteCaller, _params: Value) -> RemoteResult {
18 status_for(state, None).map_err(RemoteRefusal::failed)
19}
20
21pub(super) async fn grant(state: &AppState, caller: &RemoteCaller, params: Value) -> RemoteResult {
24 let names_an_agent = params.get("agent").and_then(Value::as_str).is_some_and(|a| !a.trim().is_empty());
25 if !names_an_agent {
26 return Err(RemoteRefusal::new("bad_params", "google.grant: name the agent on this machine (agent): there is no \"yourself\" across machines"));
27 }
28 let body: GrantBody = serde_json::from_value(params).map_err(|e| RemoteRefusal::new("bad_params", format!("google.grant: {e}")))?;
29 let actor = caller.actor();
30 let done = grant_as(state, &actor, &actor, None, &body).map_err(RemoteRefusal::failed)?;
31 tracing::info!(actor = %actor, "remote google.grant: a grant was set");
32 Ok(done)
33}
34
35#[cfg(test)]
36#[path = "google_ops_tests.rs"]
37mod tests;