(
agent_name: &str,
hook_type: HookType,
raw_json: serde_json::Value,
)
| 174 | } |
| 175 | |
| 176 | fn parse_session_info( |
| 177 | agent_name: &str, |
| 178 | hook_type: HookType, |
| 179 | raw_json: serde_json::Value, |
| 180 | ) -> AgentResult<TurnEvent> { |
| 181 | let parsed: SessionInfoInput = |
| 182 | serde_json::from_value(raw_json.clone()).map_err(|e| AgentError::HookParseFailed { |
| 183 | agent: agent_name.to_string(), |
| 184 | hook_type: hook_type.as_str().to_string(), |
| 185 | reason: e.to_string(), |
| 186 | })?; |
| 187 | |
| 188 | let mut event = |
| 189 | TurnEvent::new(extract_session_id(parsed.session_id), hook_type).with_raw_json(raw_json); |
| 190 | |
| 191 | if let Some(path) = parsed.transcript_path { |
| 192 | event = event.with_transcript_path(path); |
| 193 | } |
| 194 | |
| 195 | Ok(event) |
| 196 | } |
| 197 | |
| 198 | fn parse_user_prompt( |
| 199 | agent_name: &str, |
no test coverage detected