pub struct ParsedHookInputBuilder<'a> { /* private fields */ }Expand description
Builder for extracting fields from JSON into ParsedHookInput.
This builder provides a fluent API for extracting fields from JSON hook payloads, supporting both simple top-level fields and nested paths using dot notation.
§Example
use mi6_core::framework::common::ParsedHookInputBuilder;
use serde_json::json;
let json = json!({
"session_id": "abc123",
"tool_input": {
"subagent_type": "Explore"
}
});
let parsed = ParsedHookInputBuilder::new(&json)
.session_id("session_id")
.subagent_type("tool_input.subagent_type")
.build();
assert_eq!(parsed.session_id, Some("abc123".to_string()));
assert_eq!(parsed.subagent_type, Some("Explore".to_string()));Implementations§
Source§impl<'a> ParsedHookInputBuilder<'a>
impl<'a> ParsedHookInputBuilder<'a>
Sourcepub fn new(json: &'a Value) -> Self
pub fn new(json: &'a Value) -> Self
Create a new builder for extracting fields from the given JSON value.
Sourcepub fn session_id(self, path: &str) -> Self
pub fn session_id(self, path: &str) -> Self
Set session_id from the given JSON path.
Sourcepub fn session_id_or(self, paths: &[&str]) -> Self
pub fn session_id_or(self, paths: &[&str]) -> Self
Set session_id with fallback paths. Uses the first path that yields a value.
Sourcepub fn tool_use_id(self, path: &str) -> Self
pub fn tool_use_id(self, path: &str) -> Self
Set tool_use_id from the given JSON path.
Sourcepub fn tool_use_id_or(self, paths: &[&str]) -> Self
pub fn tool_use_id_or(self, paths: &[&str]) -> Self
Set tool_use_id with fallback paths. Uses the first path that yields a value.
Sourcepub fn tool_name_or(self, paths: &[&str]) -> Self
pub fn tool_name_or(self, paths: &[&str]) -> Self
Set tool_name with fallback paths. Uses the first path that yields a value.
Sourcepub fn subagent_type(self, path: &str) -> Self
pub fn subagent_type(self, path: &str) -> Self
Set subagent_type from the given JSON path.
Sourcepub fn spawned_agent_id(self, path: &str) -> Self
pub fn spawned_agent_id(self, path: &str) -> Self
Set spawned_agent_id from the given JSON path.
Sourcepub fn permission_mode(self, path: &str) -> Self
pub fn permission_mode(self, path: &str) -> Self
Set permission_mode from the given JSON path.
Sourcepub fn transcript_path(self, path: &str) -> Self
pub fn transcript_path(self, path: &str) -> Self
Set transcript_path from the given JSON path.
Sourcepub fn cwd_or(self, paths: &[&str]) -> Self
pub fn cwd_or(self, paths: &[&str]) -> Self
Set cwd with fallback paths. Uses the first path that yields a value.
Sourcepub fn session_source(self, path: &str) -> Self
pub fn session_source(self, path: &str) -> Self
Set session_source from the given JSON path.
Sourcepub fn agent_transcript_path(self, path: &str) -> Self
pub fn agent_transcript_path(self, path: &str) -> Self
Set agent_transcript_path from the given JSON path.
Sourcepub fn compact_trigger(self, path: &str) -> Self
pub fn compact_trigger(self, path: &str) -> Self
Set compact_trigger from the given JSON path.
Sourcepub fn model_or(self, paths: &[&str]) -> Self
pub fn model_or(self, paths: &[&str]) -> Self
Set model with fallback paths. Uses the first path that yields a value.
Sourcepub fn duration_ms(self, path: &str) -> Self
pub fn duration_ms(self, path: &str) -> Self
Set duration_ms from the given JSON path.
Sourcepub fn duration_ms_or(self, paths: &[&str]) -> Self
pub fn duration_ms_or(self, paths: &[&str]) -> Self
Set duration_ms with fallback paths. Uses the first path that yields a value.
Sourcepub fn tokens_input(self, path: &str) -> Self
pub fn tokens_input(self, path: &str) -> Self
Set tokens_input from the given JSON path.
Sourcepub fn tokens_output(self, path: &str) -> Self
pub fn tokens_output(self, path: &str) -> Self
Set tokens_output from the given JSON path.
Sourcepub fn tokens_cache_read(self, path: &str) -> Self
pub fn tokens_cache_read(self, path: &str) -> Self
Set tokens_cache_read from the given JSON path.
Sourcepub fn tokens_cache_write(self, path: &str) -> Self
pub fn tokens_cache_write(self, path: &str) -> Self
Set tokens_cache_write from the given JSON path.
Sourcepub fn build(self) -> ParsedHookInput
pub fn build(self) -> ParsedHookInput
Consume the builder and return the constructed ParsedHookInput.