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

Method parse_event

atomic-agent/src/hooks/hermes.rs:109–135  ·  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 timestamp = TimestampFormat::Rfc3339.parse(self.name(), hook_type, &raw_json)?;
112 let mut event = TurnEvent::new(Self::extract_session_id(&raw_json), hook_type)
113 .with_raw_json(with_hermes_provider(raw_json.clone()));
114
115 if let Some(path) = Self::extract_transcript_path(&raw_json) {
116 event = event.with_transcript_path(path);
117 }
118
119 if hook_type == HookType::TurnStart {
120 if let Some(prompt) = Self::extract_prompt(&raw_json) {
121 event = event.with_prompt(prompt);
122 }
123 }
124
125 if matches!(hook_type, HookType::PreToolUse | HookType::PostToolUse) {
126 if let Some(name) = Self::extract_tool_name(&raw_json) {
127 event = event.with_tool_name(name);
128 }
129 if let Some(id) = Self::extract_tool_use_id(&raw_json) {
130 event = event.with_tool_use_id(id);
131 }
132 }
133
134 Ok(event.with_timestamp(timestamp))
135 }
136
137 fn install(&self, _repo_root: &Path) -> AgentResult<usize> {
138 // Hermes stores hooks in YAML config and often prompts for shell-hook

Calls 12

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
with_timestampMethod · 0.80
parse_jsonMethod · 0.45
parseMethod · 0.45
nameMethod · 0.45
cloneMethod · 0.45
with_tool_nameMethod · 0.45