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

Function read_messages

atomic-agent/src/transcript/opencode.rs:172–195  ·  view source on GitHub ↗

Messages of the session in chronological order: `(id, role)`.

(conn: &Connection, session_id: &str)

Source from the content-addressed store, hash-verified

170
171/// Messages of the session in chronological order: `(id, role)`.
172fn read_messages(conn: &Connection, session_id: &str) -> Option<Vec<(String, String)>> {
173 let mut stmt = conn
174 .prepare(
175 "SELECT id, json_extract(data, '$.role') FROM message \
176 WHERE session_id = ?1 ORDER BY time_created, id",
177 )
178 .ok()?;
179 let rows = stmt
180 .query_map([session_id], |row| {
181 Ok((row.get::<_, String>(0)?, row.get::<_, String>(1)?))
182 })
183 .ok()?;
184
185 let mut out = Vec::new();
186 for row in rows {
187 match row {
188 Ok((id, role)) => out.push((id, role)),
189 Err(e) => {
190 log::debug!("opencode store: skipping message row: {}", e);
191 }
192 }
193 }
194 Some(out)
195}
196
197/// Content parts of the session in chronological order:
198/// `(message_id, data)`.

Callers 1

read_turnFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected