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

Function parse_pre_tool

atomic-agent/src/hooks/claude_code/parse.rs:226–251  ·  view source on GitHub ↗
(
    agent_name: &str,
    hook_type: HookType,
    raw_json: serde_json::Value,
)

Source from the content-addressed store, hash-verified

224}
225
226fn parse_pre_tool(
227 agent_name: &str,
228 hook_type: HookType,
229 raw_json: serde_json::Value,
230) -> AgentResult<TurnEvent> {
231 let parsed: PreToolInput =
232 serde_json::from_value(raw_json.clone()).map_err(|e| AgentError::HookParseFailed {
233 agent: agent_name.to_string(),
234 hook_type: hook_type.as_str().to_string(),
235 reason: e.to_string(),
236 })?;
237
238 let mut event =
239 TurnEvent::new(extract_session_id(parsed.session_id), hook_type).with_raw_json(raw_json);
240
241 if let Some(path) = parsed.transcript_path {
242 event = event.with_transcript_path(path);
243 }
244 if let Some(id) = parsed.tool_use_id {
245 event = event.with_tool_use_id(id);
246 }
247 // For PreToolUse, the tool name comes from the matcher context,
248 // not from the JSON input. It will be set by the CLI dispatch layer.
249
250 Ok(event)
251}
252
253fn parse_post_tool(
254 agent_name: &str,

Callers 1

parse_hook_eventFunction · 0.85

Calls 6

extract_session_idFunction · 0.85
with_raw_jsonMethod · 0.80
with_transcript_pathMethod · 0.80
with_tool_use_idMethod · 0.80
cloneMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected