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

Function parse_session_start

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

Source from the content-addressed store, hash-verified

134}
135
136fn parse_session_start(
137 agent_name: &str,
138 hook_type: HookType,
139 raw_json: serde_json::Value,
140) -> AgentResult<TurnEvent> {
141 let parsed: SessionStartInput =
142 serde_json::from_value(raw_json.clone()).map_err(|e| AgentError::HookParseFailed {
143 agent: agent_name.to_string(),
144 hook_type: hook_type.as_str().to_string(),
145 reason: e.to_string(),
146 })?;
147
148 let mut event =
149 TurnEvent::new(extract_session_id(parsed.session_id), hook_type).with_raw_json(raw_json);
150
151 if let Some(path) = parsed.transcript_path {
152 event = event.with_transcript_path(path);
153 }
154
155 // SessionStart includes model and source — store in raw_data
156 // so the orchestrator can set session.model from the real value
157 // rather than guessing.
158 if let Some(model) = parsed.model {
159 if let Some(ref mut raw) = event.raw_json {
160 if let Some(obj) = raw.as_object_mut() {
161 obj.insert("model".to_string(), serde_json::Value::String(model));
162 }
163 }
164 }
165 if let Some(source) = parsed.source {
166 if let Some(ref mut raw) = event.raw_json {
167 if let Some(obj) = raw.as_object_mut() {
168 obj.insert("source".to_string(), serde_json::Value::String(source));
169 }
170 }
171 }
172
173 Ok(event)
174}
175
176fn parse_session_info(
177 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
cloneMethod · 0.45
as_strMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected