Skip to main content

Agent

Trait Agent 

Source
pub trait Agent {
    // Required methods
    fn name(&self) -> &'static str;
    fn extract_session_id(&self, stdin_json: &str) -> Option<String>;

    // Provided method
    fn extract_message(&self, _stdin_json: &str) -> Option<String> { ... }
}
Expand description

An agent implementation: knows how to extract a session ID from the JSON payload that agent’s hook delivers on stdin.

Required Methods§

Source

fn name(&self) -> &'static str

Stable, lowercase, hyphenated identifier (e.g. "claude-code"). Used for the --agent CLI flag and the agent field on persisted entries.

Source

fn extract_session_id(&self, stdin_json: &str) -> Option<String>

Extract the session ID from the agent’s hook event JSON. Returns None for invalid JSON, missing field, non-string value, or empty string.

Provided Methods§

Source

fn extract_message(&self, _stdin_json: &str) -> Option<String>

Extract the agent’s last-response text from the hook event JSON, when the payload carries one. Returns None when the field is absent, empty, or non-string. Default returns None; override in agents whose payload includes such text.

Implementors§