add get_logs tool to manager mcp surface
This commit is contained in:
parent
fca480b86e
commit
1023acf69f
3 changed files with 90 additions and 0 deletions
|
|
@ -273,6 +273,35 @@ async fn dispatch(req: &ManagerRequest, coord: &Arc<Coordinator>) -> ManagerResp
|
|||
},
|
||||
}
|
||||
}
|
||||
ManagerRequest::GetLogs { agent, lines } => {
|
||||
let n = lines.unwrap_or(50);
|
||||
tracing::info!(%agent, %n, "manager: get_logs");
|
||||
match tokio::process::Command::new("journalctl")
|
||||
.args([
|
||||
"-M",
|
||||
agent,
|
||||
"-n",
|
||||
&n.to_string(),
|
||||
"--no-pager",
|
||||
"--output=short",
|
||||
])
|
||||
.output()
|
||||
.await
|
||||
{
|
||||
Ok(out) => {
|
||||
let content = if out.status.success() || !out.stdout.is_empty() {
|
||||
String::from_utf8_lossy(&out.stdout).into_owned()
|
||||
} else {
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
format!("journalctl exited {}: {stderr}", out.status)
|
||||
};
|
||||
ManagerResponse::Logs { content }
|
||||
}
|
||||
Err(e) => ManagerResponse::Err {
|
||||
message: format!("journalctl spawn failed: {e:#}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
ManagerRequest::RequestApplyCommit {
|
||||
agent,
|
||||
commit_ref,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue