Package com.tnsai.session
Interface SessionStore
- All Known Subinterfaces:
SearchableSessionStore
- All Known Implementing Classes:
FileSessionStore,SearchableFileSessionStore
public interface SessionStore
Interface for storing and retrieving agent sessions.
Implementations can store sessions in files, databases, or cloud storage.
Usage
SessionStore store = SessionStore.file(".tnsai/history/");
// Save session
store.save(session);
// Load session
AgentSession loaded = store.load("session-123").orElseThrow();
// Search sessions
List<AgentSession> recent = store.findByDateRange(
LocalDate.now().minusDays(7),
LocalDate.now()
);
- Author:
- TnsAI Team
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all sessions (use with caution).intcount()Counts total sessions.booleanDeletes a session.default booleanChecks if a session exists.static SessionStoreCreates a file-based session store.findByAgent(String agentName) Lists sessions for a specific agent.findByDate(LocalDate date) Lists sessions for a specific date.findByDateRange(LocalDate startDate, LocalDate endDate) Lists sessions in a date range.findByOutcome(SessionOutcome outcome) Lists sessions with a specific outcome.findByProject(String projectPath) Lists sessions for a specific project.Lists sessions with a specific tag.findRecent(int limit) Gets the most recent sessions.Lists all session IDs.Loads a session by ID.voidsave(AgentSession session) Saves a session.
-
Method Details
-
file
Creates a file-based session store.- Parameters:
basePath- the base directory path- Returns:
- file session store
-
save
Saves a session.- Parameters:
session- the session to save
-
load
Loads a session by ID.- Parameters:
sessionId- the session ID- Returns:
- the session if found
-
delete
Deletes a session.- Parameters:
sessionId- the session ID- Returns:
- true if deleted
-
listSessionIds
Lists all session IDs.- Returns:
- list of session IDs
-
findByDate
Lists sessions for a specific date.- Parameters:
date- the date- Returns:
- list of sessions
-
findByDateRange
Lists sessions in a date range.- Parameters:
startDate- start date (inclusive)endDate- end date (inclusive)- Returns:
- list of sessions
-
findByAgent
Lists sessions for a specific agent.- Parameters:
agentName- the agent name- Returns:
- list of sessions
-
findByProject
Lists sessions for a specific project.- Parameters:
projectPath- the project path- Returns:
- list of sessions
-
findByTag
Lists sessions with a specific tag.- Parameters:
tag- the tag- Returns:
- list of sessions
-
findByOutcome
Lists sessions with a specific outcome.- Parameters:
outcome- the outcome- Returns:
- list of sessions
-
findRecent
Gets the most recent sessions.- Parameters:
limit- maximum number to return- Returns:
- list of sessions, newest first
-
count
int count()Counts total sessions.- Returns:
- session count
-
exists
Checks if a session exists.- Parameters:
sessionId- the session ID- Returns:
- true if exists
-
clear
void clear()Clears all sessions (use with caution).
-