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());