/** * Debug Logger Module * * A specialized debug logger for Hari Seldon that can be enabled/disabled * and configured to log specific types of events. Supports file output for * persistent debug logs. */ import type { Logger } from './logger.js'; /** * Configuration for the debug logger. */ export interface DebugLoggerConfig { /** Enable debug logging */ enabled: boolean; /** Log tool calls */ logToolCalls: boolean; /** Log tool outputs (can be verbose) */ logToolOutputs: boolean; /** Log provider requests */ logProviderRequests: boolean; /** Log provider responses */ logProviderResponses: boolean; /** Log failover events */ logFailovers: boolean; /** Log hook executions */ logHooks: boolean; /** Maximum output size to log (truncate beyond) */ maxOutputSize: number; /** Output file for debug logs (optional) */ outputFile?: string; } /** * A single debug log entry. */ export interface DebugLogEntry { /** ISO timestamp */ timestamp: string; /** Type of log entry */ type: string; /** Log data */ data: unknown; } /** * Specialized debug logger for Hari Seldon. * * Provides granular control over what events are logged and supports * writing debug logs to a file for later analysis. * * @example * ```typescript * const debugLogger = new DebugLogger({ enabled: true }, logger); * * // Log a tool call * debugLogger.toolCall('invoke_agent', { role: 'coder', task: '...' }); * * // Log a failover event * debugLogger.failover('openai', 'anthropic', 'Rate limited (429)'); * * // Clean up * await debugLogger.close(); * ``` */ export declare class DebugLogger { private readonly config; private readonly logger; private fileStream; private initialized; /** * Create a new DebugLogger instance. * * @param config - Partial configuration (merged with defaults) * @param logger - Base logger for fallback logging */ constructor(config: Partial, logger: Logger); /** * Check if debug logging is enabled. */ isEnabled(): boolean; /** * Log a tool call (if enabled). * * @param tool - Tool name * @param input - Tool input parameters */ toolCall(tool: string, input: unknown): void; /** * Log a tool result (if enabled). * * @param tool - Tool name * @param output - Tool output * @param durationMs - Execution duration in milliseconds */ toolResult(tool: string, output: unknown, durationMs: number): void; /** * Log a tool error (always logged if debug enabled). * * @param tool - Tool name * @param error - Error that occurred */ toolError(tool: string, error: Error): void; /** * Log a tool denial (always logged if debug enabled). * * @param tool - Tool name * @param reason - Denial reason */ toolDenial(tool: string, reason: string): void; /** * Log a provider request (if enabled). * * @param provider - Provider name * @param model - Model name * @param messages - Request messages */ providerRequest(provider: string, model: string, messages: unknown): void; /** * Log a provider response (if enabled). * * @param provider - Provider name * @param model - Model name * @param response - Provider response * @param durationMs - Request duration in milliseconds */ providerResponse(provider: string, model: string, response: unknown, durationMs: number): void; /** * Log a failover event (always logged if debug enabled). * * @param from - Provider being switched from * @param to - Provider being switched to * @param reason - Reason for failover */ failover(from: string, to: string, reason: string): void; /** * Log a provider health change. * * @param provider - Provider name * @param previousStatus - Previous health status * @param newStatus - New health status * @param reason - Reason for change */ healthChange(provider: string, previousStatus: string, newStatus: string, reason: string): void; /** * Log a rate limit warning. * * @param provider - Provider name * @param remaining - Remaining requests * @param limit - Total limit * @param usedPercentage - Percentage of limit used * @param resetsAt - When the rate limit resets */ rateLimitWarning(provider: string, remaining: number, limit: number, usedPercentage: number, resetsAt: Date): void; /** * Log a hook execution (if enabled). * * @param hookName - Name of the hook * @param event - Event that triggered the hook * @param output - Hook output */ hookExecution(hookName: string, event: string, output: unknown): void; /** * Log a circuit breaker state change. * * @param provider - Provider name * @param previousState - Previous circuit state * @param newState - New circuit state * @param failureCount - Number of failures */ circuitBreakerChange(provider: string, previousState: string, newState: string, failureCount: number): void; /** * Log a custom debug event. * * @param type - Event type * @param data - Event data */ custom(type: string, data: unknown): void; /** * Flush and close the file handle. */ close(): Promise; /** * Initialize the file stream for debug output. */ private initFileStream; /** * Write a debug log entry. */ private writeEntry; /** * Truncate data to max output size. */ private truncate; /** * Format current timestamp for log entries. */ private formatTimestamp; } /** * Create a DebugLogger instance with the given configuration. * * @param config - Partial configuration (merged with defaults) * @param logger - Base logger for fallback logging * @returns DebugLogger instance */ export declare function createDebugLogger(config: Partial, logger: Logger): DebugLogger; /** * Re-export types for convenience. */ export type { Logger }; //# sourceMappingURL=debug-logger.d.ts.map