Owns agent session lifecycle independently of any UI.
Maps human-readable session IDs (e.g., "session-1") to session PIDs.
Sessions are started via MingaAgent.Supervisor (DynamicSupervisor) and
monitored here. When a session dies, the manager broadcasts an
:agent_session_stopped event so the Editor (or any subscriber) can
react without monitoring PIDs directly.
Summary
Functions
Aborts the current operation on a session by ID.
Returns a specification to start this module under a supervisor.
Looks up the PID for a session ID.
Lists all active sessions as {id, pid, metadata} tuples.
Sends a user prompt to a session by ID.
Looks up the session ID for a PID.
Starts the SessionManager.
Starts a new agent session with a generated human-readable ID.
Stops a session by its human-readable ID.
Stops a session by its PID (looks up the ID internally).
Types
An entry in the sessions map.
@type state() :: %{ sessions: %{required(String.t()) => session_entry()}, next_id: pos_integer() }
Internal state of the SessionManager.
Functions
@spec abort(String.t()) :: :ok | {:error, :not_found}
Aborts the current operation on a session by ID.
Returns a specification to start this module under a supervisor.
See Supervisor.
Looks up the PID for a session ID.
@spec list_sessions() :: [{String.t(), pid(), MingaAgent.SessionMetadata.t()}]
Lists all active sessions as {id, pid, metadata} tuples.
Sends a user prompt to a session by ID.
Looks up the session ID for a PID.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the SessionManager.
Starts a new agent session with a generated human-readable ID.
Returns {:ok, session_id, pid} on success.
@spec stop_session(String.t()) :: :ok | {:error, :not_found}
Stops a session by its human-readable ID.
@spec stop_session_by_pid(pid()) :: :ok | {:error, :not_found}
Stops a session by its PID (looks up the ID internally).