/** * [WHO]: AgentLogger, createLogger(), structured logging for agent sessions * [FROM]: No external dependencies * [TO]: Consumed by core/runtime/agent-session.ts, core/extensions-host/runner.ts, core/tools/* * [HERE]: core/platform/utils/logger.ts - structured JSON logging with session/turn/span tracing */ /** Log levels in priority order */ export type LogLevel = "debug" | "info" | "warn" | "error"; /** Structured log entry */ export interface LogEntry { /** Timestamp in ISO 8601 */ timestamp: string; /** Log level */ level: LogLevel; /** Human-readable message */ message: string; /** Session ID for correlation */ sessionId?: string; /** Turn index within session */ turnId?: number; /** Tool call ID for tool execution tracing */ toolCallId?: string; /** Component/module source */ component?: string; /** Duration in milliseconds (for spans) */ durationMs?: number; /** Additional structured data */ data?: Record; } /** Logger configuration */ export interface LoggerConfig { /** Minimum log level (default: "info") */ level?: LogLevel; /** Session ID (set once per session) */ sessionId?: string; /** Component name prefix */ component?: string; /** Custom output handler (default: console.error for warn/error, console.log for info/debug) */ handler?: (entry: LogEntry) => void; } /** Format a LogEntry as a single-line JSON string */ export declare function formatLogEntry(entry: LogEntry): string; /** * AgentLogger — structured logger with session/turn/span tracing. * * Usage: * ```typescript * const logger = createLogger({ sessionId: "abc123", component: "compaction" }); * logger.info("Compaction started", { turnId: 5 }); * logger.warn("Slow tool execution", { toolCallId: "call_123", durationMs: 5000 }); * ``` */ export interface AgentLogger { debug(message: string, data?: Record): void; info(message: string, data?: Record): void; warn(message: string, data?: Record): void; error(message: string, data?: Record): void; /** Create a child logger with additional context */ child(extra: { component?: string; turnId?: number; toolCallId?: string; }): AgentLogger; /** Measure duration of an async operation */ measure(label: string, fn: () => Promise, data?: Record): Promise; } /** * Create a new AgentLogger instance. */ export declare function createLogger(config?: LoggerConfig): AgentLogger; /** * No-op logger that discards all output. * Useful for tests or when logging is disabled. */ export declare const noopLogger: AgentLogger;