fix(#1004,#1006): get_host_journal - JournalPriority enum, grep/since/until, default 30/max 100, verbatim container, fix doc comment

This commit is contained in:
damocles 2026-06-01 20:48:02 +02:00 committed by mara
commit b9ecacaafe
6 changed files with 96 additions and 30 deletions

View file

@ -863,11 +863,14 @@ impl AgentServer {
// performs a second capability check server-side before running journalctl.
#[tool(
description = "Fetch recent lines from the host journal (requires `read_host_journal` \
capability). All filters are optional omit to get the last N host journal lines. \
capability). All filters are optional - omit to get the last N host journal lines. \
`unit`: filter to a systemd unit (e.g. `hive-c0re.service`). \
`container`: logical agent name (e.g. `iris`) adds `-M h-iris`. \
`lines`: how many lines (default 100, max 500). \
`priority`: minimum syslog level (`err`, `warning`, `info`, `debug`)."
`container`: nspawn machine name verbatim (e.g. `h-iris`). Omit for host journal. \
`lines`: how many lines (default 30, max 100). \
`priority`: minimum syslog level enum. \
`grep`: regex matched against log message fields (journalctl --grep). \
`since`: show entries on or newer than this (e.g. `-1h`, `2024-01-01 12:00:00`). \
`until`: show entries on or older than this."
)]
async fn get_host_journal(
&self,
@ -881,6 +884,9 @@ impl AgentServer {
container: args.container,
lines: args.lines,
priority: args.priority,
grep: args.grep,
since: args.since,
until: args.until,
})
.await;
let result = match resp {
@ -1177,16 +1183,24 @@ pub struct GetHostJournalArgs {
/// Systemd unit to filter (e.g. `hive-c0re.service`). Omit for all units.
#[serde(default)]
pub unit: Option<String>,
/// Logical agent name (e.g. `iris`) — gets that container's journal via `-M h-iris`.
/// Omit for the host journal.
/// nspawn machine name verbatim (e.g. `h-iris`). Omit for host journal.
#[serde(default)]
pub container: Option<String>,
/// Number of lines to return (default 100, max 500).
/// Number of lines to return (default 30, max 100).
#[serde(default)]
pub lines: Option<u32>,
/// Minimum syslog priority: `err`, `warning`, `info`, `debug`.
/// Minimum syslog priority level.
#[serde(default)]
pub priority: Option<String>,
pub priority: Option<hive_sh4re::JournalPriority>,
/// Regex to match against log message fields (journalctl --grep).
#[serde(default)]
pub grep: Option<String>,
/// Show entries on or newer than this timestamp (e.g. `-1h`).
#[serde(default)]
pub since: Option<String>,
/// Show entries on or older than this timestamp.
#[serde(default)]
pub until: Option<String>,
}
#[derive(Debug, Clone)]