From 0a79912b67311fe4557d348ce9b09356c7317326 Mon Sep 17 00:00:00 2001 From: damocles Date: Wed, 20 May 2026 10:43:54 +0200 Subject: [PATCH] get_logs: resolve machine name via container_name like every other verb --- CLAUDE.md | 8 ++++++++ hive-ag3nt/src/mcp.rs | 9 ++++++--- hive-c0re/src/manager_server.rs | 9 +++++++-- hive-sh4re/src/lib.rs | 10 ++++++---- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 0ef3540..c60a726 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -183,6 +183,14 @@ read them à la carte. In-flight or recent context that hasn't earned a section yet. Prune freely. +- **Just landed:** `get_logs` now resolves the machine name. + `journalctl -M` wants the *machine* name (`h-gui`), not the + logical agent name (`gui`) — `get_logs` was the one manager + verb that passed the name straight through instead of mapping + it via `lifecycle::container_name()` like Kill/Start/Restart/ + Update do. Now consistent: pass the plain agent name, hive-c0re + resolves `h-` (manager stays `hm1nd`). Tool description + + `GetLogs` wire doc updated. - **Just landed:** applied config repos mirrored to the forge. New private `agent-configs` Forgejo org (renamed from the unused `agents` org in `SEEDED_ORGS`); core is the diff --git a/hive-ag3nt/src/mcp.rs b/hive-ag3nt/src/mcp.rs index 568170f..241db14 100644 --- a/hive-ag3nt/src/mcp.rs +++ b/hive-ag3nt/src/mcp.rs @@ -750,7 +750,9 @@ pub struct RequestApplyCommitArgs { #[derive(Debug, serde::Deserialize, schemars::JsonSchema)] pub struct GetLogsArgs { - /// Logical name of the sub-agent container to fetch logs for. + /// Logical agent name to fetch logs for (e.g. `gui`, `hm1nd`). + /// hive-c0re maps it to the underlying machine name (`h-gui`) + /// itself — pass the plain agent name, not the `h-` form. pub agent: String, /// How many journal lines to return (default: 50, max: 500). #[serde(default)] @@ -1128,8 +1130,9 @@ impl ManagerServer { #[tool( description = "Fetch recent journal log lines for a sub-agent container. Useful \ for diagnosing MCP server registration failures, startup crashes, plugin install \ - errors, or any harness issue you can't see from inside the container. `lines` \ - defaults to 50 (max capped at 500 on the host side)." + errors, or any harness issue you can't see from inside the container. Pass the \ + plain logical agent name (e.g. `gui`) — hive-c0re resolves the machine name. \ + `lines` defaults to 50 (max capped at 500 on the host side)." )] async fn get_logs(&self, Parameters(args): Parameters) -> String { let log = format!("{args:?}"); diff --git a/hive-c0re/src/manager_server.rs b/hive-c0re/src/manager_server.rs index 81099cd..64c1caf 100644 --- a/hive-c0re/src/manager_server.rs +++ b/hive-c0re/src/manager_server.rs @@ -286,11 +286,16 @@ async fn dispatch(req: &ManagerRequest, coord: &Arc) -> ManagerResp } ManagerRequest::GetLogs { agent, lines } => { let n = lines.unwrap_or(50); - tracing::info!(%agent, %n, "manager: get_logs"); + // `journalctl -M` wants the *machine* name, not the + // logical agent name. Map it the same way every other + // lifecycle verb does so the caller passes `gui` and we + // resolve `h-gui` (manager stays `hm1nd`). + let machine = crate::lifecycle::container_name(agent); + tracing::info!(%agent, %machine, %n, "manager: get_logs"); match tokio::process::Command::new("journalctl") .args([ "-M", - agent, + &machine, "-n", &n.to_string(), "--no-pager", diff --git a/hive-sh4re/src/lib.rs b/hive-sh4re/src/lib.rs index 435b62d..95e798e 100644 --- a/hive-sh4re/src/lib.rs +++ b/hive-sh4re/src/lib.rs @@ -697,10 +697,12 @@ pub enum ManagerRequest { /// `HelperEvent::QuestionAsked` (i.e. an agent asked the manager /// for input). Mirror of `AgentRequest::Answer`. Answer { id: i64, answer: String }, - /// Fetch recent journal lines for a sub-agent container. hive-c0re - /// runs `journalctl -M -n --no-pager` and returns - /// the output as a string. Useful for diagnosing MCP registration - /// failures, startup crashes, and harness errors. + /// Fetch recent journal lines for a sub-agent container. `agent` + /// is the logical agent name; hive-c0re resolves it to the + /// machine name (`gui` → `h-gui`) and runs `journalctl -M + /// -n --no-pager`, returning the output as a + /// string. Useful for diagnosing MCP registration failures, + /// startup crashes, and harness errors. /// /// `lines` defaults to 50 when omitted. GetLogs {