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

Function parse_session_start

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

Source from the content-addressed store, hash-verified

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