swarmctl: agent watch follows an agent's terminal rows
Reads GET /api/agents/{name}/term/stream over the controller socket or the
gateway and prints one line per row. The gateway path uses a client without
the total-request timeout so the stream isn't cut after 30 seconds.
Closes #6160
This commit is contained in:
parent
aa227a95c1
commit
9e0c51052b
1 changed files with 482 additions and 7 deletions
|
|
@ -34,6 +34,7 @@ mod permissions;
|
|||
mod remote;
|
||||
mod schedule;
|
||||
mod users;
|
||||
mod watch;
|
||||
|
||||
use std::fs::{self, File, Permissions};
|
||||
use std::io::{self, Write as _};
|
||||
|
|
@ -292,6 +293,15 @@ enum AgentVerb {
|
|||
/// No approval gate guards this: the caller is root on the controller's
|
||||
/// host, or logged in through the swarm domain's SSO gate.
|
||||
SetState(AgentSetStateArgs),
|
||||
/// Follow an agent's terminal rows live: the newest retained rows, then
|
||||
/// each new one, one line per row, until Ctrl-C or the stream ends.
|
||||
///
|
||||
/// The swarm-level counterpart of `hivectl agent watch`, read from the
|
||||
/// swarm-controller rather than from the agent's own web UI, so it works
|
||||
/// from any machine with `--swarm` and doesn't need the agent running to
|
||||
/// show what it last did. Fails when the swarm has never heard from the
|
||||
/// agent.
|
||||
Watch(AgentWatchArgs),
|
||||
/// Show the model, effort, subagent models and subagent cap the swarm sets
|
||||
/// for an agent, or change the model, effort and subagent models.
|
||||
///
|
||||
|
|
@ -445,6 +455,14 @@ struct AgentSetStateArgs {
|
|||
socket: ControllerSocketArg,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
struct AgentWatchArgs {
|
||||
/// Agent name.
|
||||
agent: String,
|
||||
#[command(flatten)]
|
||||
socket: ControllerSocketArg,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
struct AgentCreateArgs {
|
||||
/// Name for the new agent: 1–63 characters of `[a-z0-9-]`.
|
||||
|
|
@ -726,6 +744,12 @@ fn main() -> Result<()> {
|
|||
let target = args.socket.resolve(&remote)?;
|
||||
agent::set_state(&target, &args.agent, &args.hive, args.state, args.yes)
|
||||
}
|
||||
Verb::Agent {
|
||||
command: AgentVerb::Watch(args),
|
||||
} => {
|
||||
let target = args.socket.resolve(&remote)?;
|
||||
watch::watch(&target, &args.agent)
|
||||
}
|
||||
Verb::Agent {
|
||||
command: AgentVerb::Inference { command },
|
||||
} => inference(&remote, command),
|
||||
|
|
|
|||
Loading…
Reference in a new issue