/** * SessionManager - Container orchestrating all agent sessions * * Responsibilities: * - Fetch all sessions from persistence (enriched with runtime state) * - Create new AgentSession instances * - Load existing AgentSession from persistence * - Unload AgentSession instances (triggered by sandbox termination) * - Emit domain events to EventBus * * Note: Idle timeout is handled by Modal - when sandbox terminates, * the AgentSession notifies us via callback to unload the session. */ import type { ModalContext } from '../lib/sandbox/modal/client.js'; import type { PersistenceAdapter } from '../types/persistence-adapter.js'; import type { CreateSessionArgs, SessionListItem } from '../types/session/index.js'; import { AgentSession } from './agent-session.js'; import type { EventBus } from './event-bus.js'; /** * SessionManager - Container for all agent sessions * * Uses dependency injection pattern for all external dependencies */ export declare class SessionManager { private loadedSessions; private readonly modalContext; private readonly eventBus; private readonly adapters; constructor(modalContext: ModalContext, eventBus: EventBus, adapters: { persistence: PersistenceAdapter; }); /** * Get all sessions from persistence, enriched with runtime state */ getAllSessions(): Promise; /** * Get runtime state for a session */ private getRuntimeState; /** * Create a new session */ createSession(request: CreateSessionArgs): Promise; /** * Load existing session from persistence */ loadSession(sessionId: string): Promise; /** * Get loaded session by ID */ getSession(sessionId: string): AgentSession | undefined; /** * Check if session is loaded in memory */ isSessionLoaded(sessionId: string): boolean; /** * Unload session and cleanup (sync to persistence, terminate sandbox, remove from memory) */ unloadSession(sessionId: string): Promise; /** * Handle sandbox termination callback from AgentSession * Called when Modal terminates the sandbox (idle timeout) */ private handleSandboxTerminated; /** * Get loaded session count */ getLoadedSessionCount(): number; /** * Get all loaded session IDs */ getLoadedSessionIds(): string[]; /** * Get all loaded sessions */ getLoadedSessions(): AgentSession[]; /** * Get loaded sessions as SessionListItem (with runtime state) */ private getLoadedSessionsAsListItems; /** * Initialize SessionManager * Fetch all sessions from persistence */ initialize(): Promise; /** * Check if SessionManager is healthy */ isHealthy(): boolean; /** * Graceful shutdown - unload all sessions */ shutdown(): Promise; } //# sourceMappingURL=session-manager.d.ts.map