/** * Session Context Types and Utilities * SMI-641: Session ID Storage in Claude-Flow Memory * * Defines types for session state tracking including: * - Current task/issue being worked on * - Files modified in session * - Checkpoints created * - Memory keys used */ /** * A checkpoint represents a recovery point in a session */ export interface Checkpoint { /** Unique checkpoint ID (crypto.randomUUID) */ id: string; /** ISO timestamp when checkpoint was created */ timestamp: string; /** Human-readable description of the checkpoint */ description: string; /** Memory key where checkpoint data is stored */ memoryKey: string; } /** * Session data stored in claude-flow memory */ export interface SessionData { /** Unique session ID (crypto.randomUUID per standards.md ยง4.8) */ sessionId: string; /** ISO timestamp when session started */ startedAt: string; /** Optional issue ID being worked on (e.g., "SMI-641") */ issueId?: string; /** Optional worktree name (e.g., "phase-2c-session") */ worktree?: string; /** List of checkpoints created during session */ checkpoints: Checkpoint[]; /** List of files modified during session */ filesModified: string[]; /** ISO timestamp of last activity */ lastActivity: string; } /** * Session context provides access to current session state * and utilities for managing session data */ export interface SessionContext { /** Get the current session data */ getSessionData(): SessionData | null; /** Get the current issue ID being worked on */ getCurrentIssueId(): string | undefined; /** Get the current worktree name */ getCurrentWorktree(): string | undefined; /** Get files modified in this session */ getModifiedFiles(): readonly string[]; /** Get checkpoints created in this session */ getCheckpoints(): readonly Checkpoint[]; /** Get memory keys used in this session */ getMemoryKeys(): readonly string[]; /** Check if session is active */ isActive(): boolean; } /** * Implementation of SessionContext for active sessions */ export declare class ActiveSessionContext implements SessionContext { private session; constructor(session: SessionData); getSessionData(): SessionData; getCurrentIssueId(): string | undefined; getCurrentWorktree(): string | undefined; getModifiedFiles(): readonly string[]; getCheckpoints(): readonly Checkpoint[]; getMemoryKeys(): readonly string[]; isActive(): boolean; /** * Update session data (used internally by SessionManager) */ updateSession(updates: Partial): void; } /** * Null context for when no session is active */ export declare class NullSessionContext implements SessionContext { getSessionData(): SessionData | null; getCurrentIssueId(): string | undefined; getCurrentWorktree(): string | undefined; getModifiedFiles(): readonly string[]; getCheckpoints(): readonly Checkpoint[]; getMemoryKeys(): readonly string[]; isActive(): boolean; } /** * Factory function to create appropriate session context */ export declare function createSessionContext(session: SessionData | null): SessionContext; /** * Type guard to check if context is active */ export declare function isActiveContext(context: SessionContext): context is ActiveSessionContext; /** * Calculate session duration in milliseconds */ export declare function getSessionDuration(session: SessionData): number; /** * Format session duration as human-readable string */ export declare function formatSessionDuration(session: SessionData): string; /** * Get the latest checkpoint from a session * * When timestamps are equal (created within same millisecond), * prefers the later item in the array (more recently added). */ export declare function getLatestCheckpoint(session: SessionData): Checkpoint | null; //# sourceMappingURL=SessionContext.d.ts.map