MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / parse_event

Method parse_event

atomic-agent/src/hooks/hermes.rs:109–134  ·  view source on GitHub ↗
(&self, hook_type: HookType, input: &[u8])

Source from the content-addressed store, hash-verified

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

Calls 9

extract_session_idFunction · 0.85
with_hermes_providerFunction · 0.85
with_raw_jsonMethod · 0.80
with_transcript_pathMethod · 0.80
with_promptMethod · 0.80
with_tool_use_idMethod · 0.80
parse_jsonMethod · 0.45
cloneMethod · 0.45
with_tool_nameMethod · 0.45