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

Method list_sessions

atomic-agent/src/turn/session.rs:963–990  ·  view source on GitHub ↗

Load every parseable session in the store (CB-12A: used by the pre-commit capture hook to find active managed sessions). Unparseable files are skipped: the capture hook is advisory evidence and must never fail a commit because one session file is corrupt.

(&self)

Source from the content-addressed store, hash-verified

961 /// Unparseable files are skipped: the capture hook is advisory evidence
962 /// and must never fail a commit because one session file is corrupt.
963 pub fn list_sessions(&self) -> AgentResult<Vec<AgentSession>> {
964 let mut sessions = Vec::new();
965 let entries = match std::fs::read_dir(&self.sessions_dir) {
966 Ok(entries) => entries,
967 Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
968 return Ok(sessions);
969 }
970 Err(error) => {
971 return Err(AgentError::SessionLoadFailed {
972 session_id: "*".to_string(),
973 reason: format!("cannot read sessions dir: {}", error),
974 });
975 }
976 };
977 for entry in entries.flatten() {
978 let path = entry.path();
979 if path.extension().and_then(|extension| extension.to_str()) != Some("json") {
980 continue;
981 }
982 let Ok(data) = std::fs::read(&path) else {
983 continue;
984 };
985 if let Ok(session) = serde_json::from_slice::<AgentSession>(&data) {
986 sessions.push(session);
987 }
988 }
989 Ok(sessions)
990 }
991
992 /// Every session currently in an active phase (CB-12A capture targets).
993 pub fn active_sessions(&self) -> AgentResult<Vec<AgentSession>> {

Callers 1

active_sessionsMethod · 0.45

Calls 5

extensionMethod · 0.80
readFunction · 0.50
kindMethod · 0.45
pathMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected