| 107 | } |
| 108 | |
| 109 | fn parse_event(&self, hook_type: HookType, input: &[u8]) -> AgentResult<TurnEvent> { |
| 110 | let raw_json = self.parse_json(hook_type, input)?; |
| 111 | let mut event = TurnEvent::new(Self::extract_session_id(&raw_json), hook_type) |
| 112 | .with_raw_json(with_hermes_provider(raw_json.clone())); |
| 113 | |
| 114 | if let Some(path) = Self::extract_transcript_path(&raw_json) { |
| 115 | event = event.with_transcript_path(path); |
| 116 | } |
| 117 | |
| 118 | if hook_type == HookType::TurnStart { |
| 119 | if let Some(prompt) = Self::extract_prompt(&raw_json) { |
| 120 | event = event.with_prompt(prompt); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | if matches!(hook_type, HookType::PreToolUse | HookType::PostToolUse) { |
| 125 | if let Some(name) = Self::extract_tool_name(&raw_json) { |
| 126 | event = event.with_tool_name(name); |
| 127 | } |
| 128 | if let Some(id) = Self::extract_tool_use_id(&raw_json) { |
| 129 | event = event.with_tool_use_id(id); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | Ok(event) |
| 134 | } |
| 135 | |
| 136 | fn install(&self, _repo_root: &Path) -> AgentResult<usize> { |
| 137 | // Hermes stores hooks in YAML config and often prompts for shell-hook |