mcp-ai-agent-guidelines
Version:
A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices
134 lines • 3.91 kB
TypeScript
/**
* Session Manager - Pure domain logic for design session lifecycle
*
* This module provides functions for managing design session state.
* All functions are framework-independent and isolated to the domain layer.
*/
import type { PhaseId, PhaseTransition, SessionConfig, SessionContext, SessionState } from "./types.js";
/**
* Creates a new design session with initial state
*
* @param id - Unique session identifier
* @param context - Session context data
* @param config - Optional session configuration
* @returns Newly created session state
*
* @example
* ```typescript
* const session = createSession('session-1', {
* goal: 'Build authentication system',
* requirements: ['OAuth', 'JWT']
* });
* ```
*/
export declare function createSession(id: string, context: SessionContext, config?: SessionConfig): SessionState;
/**
* Retrieves an existing session by ID
*
* @param id - Session identifier
* @returns Session state if found, undefined otherwise
*
* @example
* ```typescript
* const session = getSession('session-1');
* if (session) {
* console.log(`Current phase: ${session.phase}`);
* }
* ```
*/
export declare function getSession(id: string): SessionState | undefined;
/**
* Updates the current phase of a session
*
* @param id - Session identifier
* @param newPhase - Target phase to transition to
* @param content - Optional content describing the transition
* @returns Updated session state
* @throws Error if session not found
*
* @example
* ```typescript
* const updated = updateSessionPhase('session-1', 'requirements', 'Discovery complete');
* console.log(`Transitioned from ${updated.history[0].from} to ${updated.history[0].to}`);
* ```
*/
export declare function updateSessionPhase(id: string, newPhase: PhaseId, content?: string): SessionState;
/**
* Updates session context with new data
*
* @param id - Session identifier
* @param updates - Context updates to merge
* @returns Updated session state
* @throws Error if session not found
*
* @example
* ```typescript
* const updated = updateSessionContext('session-1', {
* stakeholders: ['Product', 'Engineering']
* });
* ```
*/
export declare function updateSessionContext(id: string, updates: Partial<SessionContext>): SessionState;
/**
* Deletes a session from storage
*
* @param id - Session identifier
* @returns true if session was deleted, false if not found
*
* @example
* ```typescript
* const deleted = deleteSession('session-1');
* console.log(deleted ? 'Deleted' : 'Not found');
* ```
*/
export declare function deleteSession(id: string): boolean;
/**
* Lists all active session IDs
*
* @returns Array of session identifiers
*
* @example
* ```typescript
* const sessionIds = listSessions();
* console.log(`Active sessions: ${sessionIds.length}`);
* ```
*/
export declare function listSessions(): string[];
/**
* Clears all sessions from storage
* Useful for testing and cleanup
*
* @example
* ```typescript
* clearAllSessions();
* console.log(`Sessions: ${listSessions().length}`); // 0
* ```
*/
export declare function clearAllSessions(): void;
/**
* Gets the current phase of a session
*
* @param id - Session identifier
* @returns Current phase ID or undefined if session not found
*
* @example
* ```typescript
* const phase = getCurrentPhase('session-1');
* console.log(`Current phase: ${phase}`);
* ```
*/
export declare function getCurrentPhase(id: string): PhaseId | undefined;
/**
* Gets the transition history of a session
*
* @param id - Session identifier
* @returns Array of phase transitions or empty array if session not found
*
* @example
* ```typescript
* const history = getSessionHistory('session-1');
* console.log(`Total transitions: ${history.length}`);
* ```
*/
export declare function getSessionHistory(id: string): PhaseTransition[];
//# sourceMappingURL=session-manager.d.ts.map