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 Details

    • file

      static SessionStore file(String basePath)
      Creates a file-based session store.
      Parameters:
      basePath - the base directory path
      Returns:
      file session store
    • save

      void save(AgentSession session)
      Saves a session.
      Parameters:
      session - the session to save
    • load

      Optional<AgentSession> load(String sessionId)
      Loads a session by ID.
      Parameters:
      sessionId - the session ID
      Returns:
      the session if found
    • delete

      boolean delete(String sessionId)
      Deletes a session.
      Parameters:
      sessionId - the session ID
      Returns:
      true if deleted
    • listSessionIds

      List<String> listSessionIds()
      Lists all session IDs.
      Returns:
      list of session IDs
    • findByDate

      List<AgentSession> findByDate(LocalDate date)
      Lists sessions for a specific date.
      Parameters:
      date - the date
      Returns:
      list of sessions
    • findByDateRange

      List<AgentSession> findByDateRange(LocalDate startDate, LocalDate endDate)
      Lists sessions in a date range.
      Parameters:
      startDate - start date (inclusive)
      endDate - end date (inclusive)
      Returns:
      list of sessions
    • findByAgent

      List<AgentSession> findByAgent(String agentName)
      Lists sessions for a specific agent.
      Parameters:
      agentName - the agent name
      Returns:
      list of sessions
    • findByProject

      List<AgentSession> findByProject(String projectPath)
      Lists sessions for a specific project.
      Parameters:
      projectPath - the project path
      Returns:
      list of sessions
    • findByTag

      List<AgentSession> findByTag(String tag)
      Lists sessions with a specific tag.
      Parameters:
      tag - the tag
      Returns:
      list of sessions
    • findByOutcome

      List<AgentSession> findByOutcome(SessionOutcome outcome)
      Lists sessions with a specific outcome.
      Parameters:
      outcome - the outcome
      Returns:
      list of sessions
    • findRecent

      List<AgentSession> findRecent(int limit)
      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

      default boolean exists(String sessionId)
      Checks if a session exists.
      Parameters:
      sessionId - the session ID
      Returns:
      true if exists
    • clear

      void clear()
      Clears all sessions (use with caution).