get_logs: resolve machine name via container_name like every other verb

This commit is contained in:
damocles 2026-05-20 10:43:54 +02:00
parent 7ce3da1e21
commit 0a79912b67
4 changed files with 27 additions and 9 deletions

View file

@ -183,6 +183,14 @@ read them à la carte.
In-flight or recent context that hasn't earned a section yet. In-flight or recent context that hasn't earned a section yet.
Prune freely. 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-<name>` (manager stays `hm1nd`). Tool description +
`GetLogs` wire doc updated.
- **Just landed:** applied config repos mirrored to the - **Just landed:** applied config repos mirrored to the
forge. New private `agent-configs` Forgejo org (renamed forge. New private `agent-configs` Forgejo org (renamed
from the unused `agents` org in `SEEDED_ORGS`); core is the from the unused `agents` org in `SEEDED_ORGS`); core is the

View file

@ -750,7 +750,9 @@ pub struct RequestApplyCommitArgs {
#[derive(Debug, serde::Deserialize, schemars::JsonSchema)] #[derive(Debug, serde::Deserialize, schemars::JsonSchema)]
pub struct GetLogsArgs { 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, pub agent: String,
/// How many journal lines to return (default: 50, max: 500). /// How many journal lines to return (default: 50, max: 500).
#[serde(default)] #[serde(default)]
@ -1128,8 +1130,9 @@ impl ManagerServer {
#[tool( #[tool(
description = "Fetch recent journal log lines for a sub-agent container. Useful \ description = "Fetch recent journal log lines for a sub-agent container. Useful \
for diagnosing MCP server registration failures, startup crashes, plugin install \ for diagnosing MCP server registration failures, startup crashes, plugin install \
errors, or any harness issue you can't see from inside the container. `lines` \ errors, or any harness issue you can't see from inside the container. Pass the \
defaults to 50 (max capped at 500 on the host side)." 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<GetLogsArgs>) -> String { async fn get_logs(&self, Parameters(args): Parameters<GetLogsArgs>) -> String {
let log = format!("{args:?}"); let log = format!("{args:?}");

View file

@ -286,11 +286,16 @@ async fn dispatch(req: &ManagerRequest, coord: &Arc<Coordinator>) -> ManagerResp
} }
ManagerRequest::GetLogs { agent, lines } => { ManagerRequest::GetLogs { agent, lines } => {
let n = lines.unwrap_or(50); 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") match tokio::process::Command::new("journalctl")
.args([ .args([
"-M", "-M",
agent, &machine,
"-n", "-n",
&n.to_string(), &n.to_string(),
"--no-pager", "--no-pager",

View file

@ -697,10 +697,12 @@ pub enum ManagerRequest {
/// `HelperEvent::QuestionAsked` (i.e. an agent asked the manager /// `HelperEvent::QuestionAsked` (i.e. an agent asked the manager
/// for input). Mirror of `AgentRequest::Answer`. /// for input). Mirror of `AgentRequest::Answer`.
Answer { id: i64, answer: String }, Answer { id: i64, answer: String },
/// Fetch recent journal lines for a sub-agent container. hive-c0re /// Fetch recent journal lines for a sub-agent container. `agent`
/// runs `journalctl -M <agent> -n <lines> --no-pager` and returns /// is the logical agent name; hive-c0re resolves it to the
/// the output as a string. Useful for diagnosing MCP registration /// machine name (`gui` → `h-gui`) and runs `journalctl -M
/// failures, startup crashes, and harness errors. /// <machine> -n <lines> --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. /// `lines` defaults to 50 when omitted.
GetLogs { GetLogs {