export interface LLMRequest { stage: string; prompt: string; systemMessage: string; modelName: string; temperature?: number; maxTokens?: number; contextInfo?: any; } export interface LLMResponse { rawResponse: string; cleanedResponse?: string; processingTime: number; tokensUsed?: number; error?: any; } export interface DataFlowEntry { timestamp: string; requestId: string; stage: string; operation: 'request' | 'response' | 'error' | 'context-prep' | 'json-cleaning'; contextId: string; contextType: string; data: any; } /** * Enhanced service for logging data flow in AI processing pipelines * Features: * - Ring buffer (max 1000 entries per file) * - Full prompt/response storage * - Request flow tracking * - Stage flow summaries * - Pluggable context identifier generation (generic by default) */ export declare class DataFlowLoggerService { private static instance; private readonly logDir; private currentRequestId; private readonly MAX_ENTRIES_PER_FILE; private contextIdentifierGenerator?; private constructor(); static getInstance(): DataFlowLoggerService; /** * Configure a custom context identifier generator * @param generator Function that extracts a context identifier from the context object * @example * // For book-based applications: * logger.setContextIdentifierGenerator(ctx => `C${ctx.chapter}P${ctx.page}`); * // For session-based applications: * logger.setContextIdentifierGenerator(ctx => ctx.sessionId || 'general'); */ setContextIdentifierGenerator(generator: (context: any) => string): void; private ensureLogDirectoryExists; /** * Generate a unique request ID */ private generateRequestId; /** * Get context identifier for logging * Uses custom generator if configured, otherwise falls back to generic identifiers */ private getContextIdentifier; /** * Start a new request and return request ID */ startRequest(stage: string, context?: any): string; /** * Log LLM request with full prompt/system message storage */ logLLMRequest(request: LLMRequest, context?: any, requestId?: string): void; /** * Log LLM response with full response storage */ logLLMResponse(stage: string, response: LLMResponse, context?: any, requestId?: string): void; /** * Log context preparation */ logContextPreparation(stage: string, context: any, contextPreparationDetails: any): void; /** * Log JSON cleaning operation */ logJsonCleaning(stage: string, context: any, cleaningDetails: { input: string; output?: string; method: string; success: boolean; iterations?: number; error?: any; }): void; /** * Log complete flow for a stage */ logStageFlow(stage: string, context: any, flowSummary: { totalDuration: number; contextPrepDuration?: number; llmRequestDuration?: number; jsonCleaningDuration?: number; success: boolean; outputSize?: number; error?: any; }): void; /** * Extract context features for detailed logging */ private extractContextFeatures; /** * Get log file path for a context */ private getLogFilePath; /** * Log entry with ring buffer (max 1000 entries per file) */ private logEntry; /** * Get flow entries for a specific request */ getRequestFlow(context: any, requestId: string): DataFlowEntry[]; /** * Get current request ID */ getCurrentRequestId(): string | null; /** * Clear current request ID */ clearCurrentRequestId(): void; } //# sourceMappingURL=data-flow-logger.service.d.ts.map