(
agent_name: &str,
hook_type: HookType,
raw_json: serde_json::Value,
)
| 221 | } |
| 222 | |
| 223 | fn parse_pre_tool( |
| 224 | agent_name: &str, |
| 225 | hook_type: HookType, |
| 226 | raw_json: serde_json::Value, |
| 227 | ) -> AgentResult<TurnEvent> { |
| 228 | let parsed: PreToolInput = |
| 229 | serde_json::from_value(raw_json.clone()).map_err(|e| AgentError::HookParseFailed { |
| 230 | agent: agent_name.to_string(), |
| 231 | hook_type: hook_type.as_str().to_string(), |
| 232 | reason: e.to_string(), |
| 233 | })?; |
| 234 | |
| 235 | let mut event = |
| 236 | TurnEvent::new(extract_session_id(parsed.session_id), hook_type).with_raw_json(raw_json); |
| 237 | |
| 238 | if let Some(path) = parsed.transcript_path { |
| 239 | event = event.with_transcript_path(path); |
| 240 | } |
| 241 | if let Some(id) = parsed.tool_use_id { |
| 242 | event = event.with_tool_use_id(id); |
| 243 | } |
| 244 | // For PreToolUse, the tool name comes from the matcher context, |
| 245 | // not from the JSON input. It will be set by the CLI dispatch layer. |
| 246 | |
| 247 | Ok(event) |
| 248 | } |
| 249 | |
| 250 | fn parse_post_tool( |
| 251 | agent_name: &str, |
no test coverage detected