pub enum AgentCommand {
List,
Spawn {
name: String,
prompt: String,
},
Background {
name: String,
prompt: String,
},
Status,
Cancel {
id: String,
},
Approve {
id: String,
},
Deny {
id: String,
},
Mention {
agent: String,
prompt: String,
},
Resume {
id: String,
prompt: String,
},
}Expand description
Typed representation of a parsed /agent CLI command or @agent mention.
§Examples
use zeph_subagent::AgentCommand;
let cmd = AgentCommand::parse("/agent spawn helper fix the bug", &[]).unwrap();
assert_eq!(cmd, AgentCommand::Spawn {
name: "helper".to_owned(),
prompt: "fix the bug".to_owned(),
});
// @mention syntax routes to known agents.
let known = vec!["reviewer".to_owned()];
let cmd = AgentCommand::parse("@reviewer check the PR", &known).unwrap();
assert_eq!(cmd, AgentCommand::Mention {
agent: "reviewer".to_owned(),
prompt: "check the PR".to_owned(),
});Variants§
List
List all running sub-agent tasks.
Spawn
Spawn a foreground sub-agent and block until it completes.
Background
Spawn a background sub-agent that runs independently.
Status
Show a brief status summary of all running agents.
Cancel
Cancel a running agent by task ID.
Approve
Approve a pending vault secret request for a running agent.
Deny
Deny a pending vault secret request for a running agent.
Mention
Foreground spawn triggered by @agent_name <prompt> mention syntax.
Resume
Resume a previously completed sub-agent session by ID prefix.
Implementations§
Source§impl AgentCommand
impl AgentCommand
Sourcepub fn parse(
input: &str,
known_agents: &[String],
) -> Result<Self, SubAgentError>
pub fn parse( input: &str, known_agents: &[String], ) -> Result<Self, SubAgentError>
Parse from raw input text.
The input must start with /agent. Everything after that prefix is
interpreted as <subcommand> [args].
§Errors
Returns SubAgentError::InvalidCommand if:
inputdoes not start with/agent- the subcommand is missing (empty after prefix)
- required arguments are missing
- the subcommand is not recognised
Also handles @agent_name prompt mention syntax when known_agents
contains a match. If @ prefix is present but the agent is unknown,
returns Err so the caller can fall back to file-reference handling.
Sourcepub fn parse_mention(
input: &str,
known_agents: &[String],
) -> Result<Self, SubAgentError>
pub fn parse_mention( input: &str, known_agents: &[String], ) -> Result<Self, SubAgentError>
Parse an @agent_name <prompt> mention from raw input.
Returns Ok(Mention { agent, prompt }) if input starts with @ and the
token after @ matches one of known_agents. Returns
SubAgentError::InvalidCommand if:
inputdoes not start with@- the agent name token is empty (bare
@) - the named agent is not in
known_agents— caller should fall back to other@handling such as file references
§Errors
Returns SubAgentError::InvalidCommand on any parse failure.
§Examples
use zeph_subagent::AgentCommand;
let known = vec!["helper".to_owned()];
let cmd = AgentCommand::parse_mention("@helper fix this", &known).unwrap();
assert_eq!(cmd, AgentCommand::Mention {
agent: "helper".to_owned(),
prompt: "fix this".to_owned(),
});
// Unknown agents are rejected so callers can fall back to file-reference handling.
assert!(AgentCommand::parse_mention("@unknown do work", &known).is_err());Trait Implementations§
Source§impl Debug for AgentCommand
impl Debug for AgentCommand
Source§impl PartialEq for AgentCommand
impl PartialEq for AgentCommand
impl StructuralPartialEq for AgentCommand
Auto Trait Implementations§
impl Freeze for AgentCommand
impl RefUnwindSafe for AgentCommand
impl Send for AgentCommand
impl Sync for AgentCommand
impl Unpin for AgentCommand
impl UnsafeUnpin for AgentCommand
impl UnwindSafe for AgentCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request