Expand description
Subagent management: spawning, grants, transcripts, and lifecycle hooks.
zeph-subagent provides the full lifecycle of sub-agent tasks within the Zeph agent
framework. It covers:
- Definitions (
SubAgentDef) — parse YAML/TOML frontmatter from.mdfiles, validate names and permissions, and load from priority-ordered directories. - Manager (
SubAgentManager) — spawn, cancel, collect, and resume sub-agent tasks against a configurable concurrency limit. - Grants (
PermissionGrants) — zero-trust TTL-bounded permission tracking for vault secrets and runtime tool grants. - Hooks (
fire_hooks) — run shell commands atPreToolUse,PostToolUse,SubagentStart, andSubagentStoplifecycle events. - Filter (
FilteredToolExecutor) — enforce per-agentToolPolicyand denylist on every tool call before it reaches the real executor. - Transcripts (
TranscriptWriter,TranscriptReader) — persist conversation history to JSONL files for session resume and auditing. - Memory (
ensure_memory_dir,load_memory_content) — resolve and inject persistentMEMORY.mdcontent into the sub-agent system prompt. - Commands (
AgentCommand,AgentsCommand) — typed parsers for/agentand/agentsslash commands.
§Quick start
use std::sync::Arc;
use zeph_subagent::{SubAgentDef, SubAgentManager};
// Parse a definition from markdown frontmatter.
let content = "---\nname: helper\ndescription: A helpful sub-agent\n---\nYou are a helper.\n";
let def = SubAgentDef::parse(content).expect("valid definition");
assert_eq!(def.name, "helper");
// Create a manager with a concurrency limit of 4.
let _manager = SubAgentManager::new(4);Re-exports§
pub use command::AgentCommand;pub use command::AgentsCommand;pub use def::SubAgentDef;pub use def::SubAgentPermissions;pub use def::is_valid_agent_name;pub use error::SubAgentError;pub use filter::FilteredToolExecutor;pub use filter::PlanModeExecutor;pub use filter::filter_skills;pub use grants::Grant;pub use grants::GrantKind;pub use grants::PermissionGrants;pub use grants::SecretRequest;pub use hooks::HookError;pub use hooks::fire_hooks;pub use hooks::matching_hooks;pub use manager::SpawnContext;pub use manager::SubAgentHandle;pub use manager::SubAgentManager;pub use manager::SubAgentStatus;pub use memory::ensure_memory_dir;pub use memory::load_memory_content;pub use resolve::resolve_agent_paths;pub use state::SubAgentState;pub use transcript::TranscriptMeta;pub use transcript::TranscriptReader;pub use transcript::TranscriptWriter;pub use transcript::sweep_old_transcripts;
Modules§
- command
- Typed parsers for
/agentand/agentsslash commands. - def
- Sub-agent definition parsing and loading.
- error
- filter
- Tool and skill filtering for sub-agents.
- grants
- Zero-trust TTL-bounded permission grants for sub-agents.
- hooks
- Lifecycle hooks for sub-agents.
- manager
- Sub-agent lifecycle management: spawn, cancel, collect, and resume.
- memory
- Persistent per-agent memory backed by
MEMORY.mdfiles on the local filesystem. - resolve
- Priority-ordered resolution of sub-agent definition directories.
- state
- transcript
- JSONL-based transcript persistence for sub-agent conversations.
Structs§
- HookDef
- A single hook definition.
- Hook
Matcher - Tool-name matcher with associated hooks.
- Skill
Filter - Skill allow/deny filter for sub-agent definitions.
- Subagent
Hooks - Per-agent frontmatter hook collections (
PreToolUse/PostToolUse).
Enums§
- Hook
Type - The type of hook — currently only shell command hooks are supported.
- Memory
Scope - Persistence scope for sub-agent memory files.
- Model
Spec - Specifies which LLM provider a sub-agent should use.
- Permission
Mode - Controls tool execution and prompt interactivity for a sub-agent.
- Tool
Policy - Tool access policy for a sub-agent.