Skip to main content

Crate zeph_subagent

Crate zeph_subagent 

Source
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 .md files, 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 at PreToolUse, PostToolUse, SubagentStart, and SubagentStop lifecycle events.
  • Filter (FilteredToolExecutor) — enforce per-agent ToolPolicy and 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 persistent MEMORY.md content into the sub-agent system prompt.
  • Commands (AgentCommand, AgentsCommand) — typed parsers for /agent and /agents slash 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 /agent and /agents slash 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.md files 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.
HookMatcher
Tool-name matcher with associated hooks.
SkillFilter
Skill allow/deny filter for sub-agent definitions.
SubagentHooks
Per-agent frontmatter hook collections (PreToolUse / PostToolUse).

Enums§

HookType
The type of hook — currently only shell command hooks are supported.
MemoryScope
Persistence scope for sub-agent memory files.
ModelSpec
Specifies which LLM provider a sub-agent should use.
PermissionMode
Controls tool execution and prompt interactivity for a sub-agent.
ToolPolicy
Tool access policy for a sub-agent.