import type { EventLogEntry, DailyStats, EmpathyEventStats, ToolCallEventData, PainSignalEventData, RulePromotionEventData, GovernanceActionEventData, HookExecutionEventData, GateBlockEventData, GateBypassEventData, EmpathyRollbackEventData, DiagnosisTaskEventData, HeartbeatDiagnosisEventData, DiagnosticianReportEventData, PrincipleCandidateEventData, RuleEnforcedEventData, RuleHostEvaluatedEventData, RuleHostBlockedEventData, RuleHostRequireApprovalEventData, RuleHostAutoCorrectProposedEventData, RuleHostAutoCorrectAppliedEventData, RuntimeV2PromptActivationsInjectedEventData, RuleHostUnhealthyEventData, RuleHostSkippedEventData, TrajectoryObservabilityFailureEventData } from '../types/event-types.js'; import type { PluginLogger } from '../openclaw-sdk.js'; export declare class EventLog { private readonly logsDir; private readonly statsFile; private readonly logger?; private readonly statsCache; private eventBuffer; private readonly maxBufferSize; private readonly flushIntervalMs; private flushTimer?; private currentEventsFile; private currentDate; constructor(stateDir: string, logger?: PluginLogger); private getEventsFile; private getTodayStr; private ensureEventsFile; private cleanupOldEventFiles; recordToolCall(sessionId: string | undefined, data: ToolCallEventData): void; recordPainSignal(sessionId: string | undefined, data: PainSignalEventData): void; recordRulePromotion(data: RulePromotionEventData): void; recordGovernanceAction(data: GovernanceActionEventData, opts?: { flushImmediately?: boolean; }): void; recordHookExecution(data: HookExecutionEventData, opts?: { flushImmediately?: boolean; }): void; recordGateBlock(sessionId: string | undefined, data: GateBlockEventData): void; recordGateBypass(sessionId: string | undefined, data: GateBypassEventData): void; recordEmpathyRollback(sessionId: string | undefined, data: EmpathyRollbackEventData): void; recordError(sessionId: string | undefined, message: string, context?: Record): void; recordWarn(sessionId: string | undefined, message: string, context?: Record): void; recordDiagnosisTask(data: DiagnosisTaskEventData): void; recordHeartbeatDiagnosis(data: HeartbeatDiagnosisEventData): void; recordDiagnosticianReport(data: DiagnosticianReportEventData): void; recordPrincipleCandidate(data: PrincipleCandidateEventData): void; recordRuleEnforced(data: RuleEnforcedEventData): void; recordRuleHostEvaluated(data: RuleHostEvaluatedEventData): void; recordRuleHostBlocked(data: RuleHostBlockedEventData): void; recordRuleHostRequireApproval(data: RuleHostRequireApprovalEventData): void; recordRuleHostAutoCorrectProposed(data: RuleHostAutoCorrectProposedEventData): void; recordRuleHostAutoCorrectApplied(data: RuleHostAutoCorrectAppliedEventData): void; recordRuntimeV2ActivationsInjected(data: RuntimeV2PromptActivationsInjectedEventData): void; /** * PRI-437: Record that an approved rule failed to compile or load. * * This is NOT just a logger.warn — the unhealthy state is persisted to EventLog * so it's visible to CLI (pd runtime health) and Console API. * * ERR-002: degradation includes a reason and nextAction (not silent). */ recordRuleHostUnhealthy(data: RuleHostUnhealthyEventData): void; /** * PRI-491: Record that an active activation was skipped at load time for a * structured reason (flag-off v2, unsupported action, unsupported context * version, missing target_ref). Unlike rulehost_unhealthy (compile/load * failures), these are configuration/flag issues — the RuleCode itself may * be valid, but the runtime chose not to execute it. * * ERR-002: degradation/suspension includes reason + nextAction (rc-9). */ recordRuleHostSkipped(data: RuleHostSkippedEventData): void; /** * PRI-647: trajectory observability side-channel failed (closed/disposed * SQLite connection) while the prompt build continued (fail-open). Recorded * as a structured event so the unavailable state stays observable via the * existing events read model — never logged silently. */ recordTrajectoryObservabilityFailure(data: TrajectoryObservabilityFailureEventData): void; /** * Redact telemetry-sensitive string values in event data before persistence. * Applies redactTelemetryString to known high-risk fields (filePath, command, * reason, args, new_string, old_string, text, paramsSummary values) and to all * string values in tool_call/rulehost_* data as a safety net. * * ERR-002: never throws; returns data unchanged on error. * ERR-045/046: covers composite command strings, Authorization headers, env vars. */ private redactEventData; private record; private formatDate; private loadStats; private updateStats; private startFlushTimer; flush(): void; getBufferedEvents(): EventLogEntry[]; private getEventDedupKey; private readPersistedEvents; private getMergedEvents; private flushEvents; private flushStats; getDailyStats(date: string): DailyStats; getEmpathyStats(range: 'today' | 'week' | 'session', sessionId?: string): EmpathyEventStats; private aggregateSessionEmpathy; rollbackEmpathyEvent(eventId: string, sessionId: string | undefined, reason: string, triggeredBy: 'user_command' | 'natural_language' | 'system'): number; getLastEmpathyEventId(sessionId: string): string | null; findLatestPainSignal(sessionId: string | undefined): PainSignalEventData | null; dispose(): void; } export declare class EventLogService { private static readonly instances; static get(stateDir: string, logger?: PluginLogger): EventLog; static flushAll(): void; static disposeAll(): void; }