Class SessionManager
java.lang.Object
com.shaft.commandline.session.SessionManager
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 Summary
ConstructorsConstructorDescriptionCreates a manager backed by a real launcher locator and the default session store.SessionManager(McpLauncherLocator locator, SessionStore store) Creates a manager with injectable collaborators, for tests. -
Method Summary
Modifier and TypeMethodDescriptionstart()Starts the shaft-mcp HTTP daemon, waits for it to become ready, and persists its session metadata.status()Reports whether the persisted session's process is still alive.booleanstop()Stops the persisted session's process, if any, and clears the session file.
-
Constructor Details
-
SessionManager
public SessionManager()Creates a manager backed by a real launcher locator and the default session store. -
SessionManager
Creates a manager with injectable collaborators, for tests.- Parameters:
locator- resolves how to launch shaft-mcpstore- persists session metadata
-
-
Method Details
-
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
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:
trueif a session file was present, regardless of whether the process was still alive
-
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
-