AgentSessionManager class final
Manages several concurrent agent sessions.
Shared resources (the execution environment and the session repository) are injected once; per-session resources (the Agent and its Session) are created lazily and kept alive until explicitly closed.
Constructors
- AgentSessionManager({required ExecutionEnv env, required String sessionsRoot, String? cwd, JsonlSessionRepo? repo, SessionPresenceStore? presenceStore})
- Creates a session manager.
Properties
- active → ManagedSession?
-
The active session, if any.
no setter
- activeId → String?
-
The active session id, if any.
no setter
-
changes
→ Stream<
void> -
Stream of change notifications (session created/closed/switched/state).
no setter
- env → ExecutionEnv
-
The execution environment shared by all sessions.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sessions
→ List<
ManagedSession> -
All managed sessions, newest first.
no setter
- sessionsRoot → String
-
Root directory for JSONL sessions.
final
Methods
-
closeSession(
String sessionId, {bool deleteFile = false}) → Future< void> - Closes a session: aborts its run (if any), removes it from the manager, and optionally deletes the session file.
-
createSession(
{required Agent agentFactory(), Map< String, dynamic> ? metadata}) → Future<ManagedSession> - Creates a new session and makes it active.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openSession(
SessionMetadata metadata, {required Agent agentFactory()}) → Future< ManagedSession> - Opens an existing session from disk and makes it active.
-
persistAll(
) → Future< void> - Persists pending messages of every session (best effort).
-
switchTo(
String sessionId) → void - Switches the active session without aborting its run.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited