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

Function read_messages

atomic-agent/src/transcript/opencode.rs:175–198  ·  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

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

Callers 1

read_turnFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected