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

Function read_messages

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

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

Callers 1

read_turnFunction · 0.85

Calls 3

prepareMethod · 0.80
okMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected