(
agent_name: &str,
hook_type: HookType,
raw_json: serde_json::Value,
)
| 134 | } |
| 135 | |
| 136 | fn parse_session_start( |
| 137 | agent_name: &str, |
| 138 | hook_type: HookType, |
| 139 | raw_json: serde_json::Value, |
| 140 | ) -> AgentResult<TurnEvent> { |
| 141 | let parsed: SessionStartInput = |
| 142 | serde_json::from_value(raw_json.clone()).map_err(|e| AgentError::HookParseFailed { |
| 143 | agent: agent_name.to_string(), |
| 144 | hook_type: hook_type.as_str().to_string(), |
| 145 | reason: e.to_string(), |
| 146 | })?; |
| 147 | |
| 148 | let mut event = |
| 149 | TurnEvent::new(extract_session_id(parsed.session_id), hook_type).with_raw_json(raw_json); |
| 150 | |
| 151 | if let Some(path) = parsed.transcript_path { |
| 152 | event = event.with_transcript_path(path); |
| 153 | } |
| 154 | |
| 155 | // SessionStart includes model and source — store in raw_data |
| 156 | // so the orchestrator can set session.model from the real value |
| 157 | // rather than guessing. |
| 158 | if let Some(model) = parsed.model { |
| 159 | if let Some(ref mut raw) = event.raw_json { |
| 160 | if let Some(obj) = raw.as_object_mut() { |
| 161 | obj.insert("model".to_string(), serde_json::Value::String(model)); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | if let Some(source) = parsed.source { |
| 166 | if let Some(ref mut raw) = event.raw_json { |
| 167 | if let Some(obj) = raw.as_object_mut() { |
| 168 | obj.insert("source".to_string(), serde_json::Value::String(source)); |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | Ok(event) |
| 174 | } |
| 175 | |
| 176 | fn parse_session_info( |
| 177 | agent_name: &str, |
no test coverage detected