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

Function parse_pre_tool

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

Source from the content-addressed store, hash-verified

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