Class SessionManager

java.lang.Object
com.shaft.commandline.session.SessionManager

public final class SessionManager extends Object
Orchestrates the shaft-cli HTTP daemon session lifecycle: starting shaft-mcp in its HTTP profile, tracking whether it is still alive, and stopping it.
  • Constructor Details

    • SessionManager

      public SessionManager()
      Creates a manager backed by a real launcher locator and the default session store.
    • SessionManager

      public SessionManager(McpLauncherLocator locator, SessionStore store)
      Creates a manager with injectable collaborators, for tests.
      Parameters:
      locator - resolves how to launch shaft-mcp
      store - persists session metadata
  • Method Details

    • start

      public SessionInfo start()
      Starts the shaft-mcp HTTP daemon, waits for it to become ready, and persists its session metadata.
      Returns:
      the newly started session's metadata
      Throws:
      McpException - if a session is already running, the process fails to launch, or it does not become ready within the readiness timeout
    • status

      public SessionStatus status()
      Reports whether the persisted session's process is still alive. Does not probe the daemon over HTTP, so this is cheap and deterministic.
      Returns:
      the current session status
    • stop

      public boolean stop()
      Stops the persisted session's process, if any, and clears the session file.
      Returns:
      true if a session file was present, regardless of whether the process was still alive
    • liveSession

      public Optional<SessionInfo> liveSession()
      Returns:
      the persisted session, only if its process is still alive; used by the routing layer to decide between the HTTP daemon and a fresh stdio child