import type { SessionEvent, SessionWriter } from '../types/session.js'; export type AuditLevel = 'minimal' | 'standard' | 'full'; /** * Configuration for sampling high-volume events inside the bridge. * This allows callers (CLI, TUI, WebUI, plugins) to tune how aggressively * noisy events like tool progress are persisted. */ export interface ToolProgressSamplingOptions { /** * How often to persist 'log' and 'partial_output' progress events. * - 1 = every message (no sampling) * - 8 = keep the first message + every 8th after that (default) */ sampleRate?: number | undefined; } export interface SessionSamplingOptions { /** Controls sampling behavior for `tool_progress` events (only relevant at auditLevel 'full'). */ toolProgress?: ToolProgressSamplingOptions | undefined; } export interface SessionEventBridgeOptions { /** Sampling rules for high-volume audit events. */ sampling?: SessionSamplingOptions | undefined; } /** * Small, safe helper that wraps a SessionWriter and enforces the * configured auditLevel. * * All appends are best-effort. Failures are swallowed (with optional * diagnostics) so they never crash the agent loop. */ export interface SessionEventBridge { /** Append an event if allowed by the current audit level. */ append(event: SessionEvent): Promise; /** Batch-append events allowed by the current audit level. */ appendBatch(events: SessionEvent[]): Promise; /** Current audit level. Reflects the latest {@link setAuditLevel} value. */ readonly level: AuditLevel; /** * Change the audit level on a live bridge. Subsequent appends are filtered * by the new level — used by the TUI `/settings` picker to apply an * `auditLevel` change to the running session without a restart. */ setAuditLevel(level: AuditLevel): void; /** Returns true if an event of this type should be written at the current level. */ allows(type: SessionEvent['type']): boolean; } /** Core events that are always written regardless of auditLevel. */ declare const CORE_RECONSTRUCT_EVENTS: Set<"agent_error" | "agent_spawned" | "agent_stopped" | "checkpoint" | "compaction" | "context_snapshot" | "error" | "file_event" | "file_observation" | "file_snapshot" | "in_flight_end" | "in_flight_start" | "llm_request" | "llm_response" | "message_appended" | "message_truncated" | "message_updated" | "messages_replaced" | "mode_changed" | "provider_error" | "provider_retry" | "rewound" | "session_end" | "session_forked" | "session_resumed" | "session_start" | "side_effect" | "skill_activated" | "skill_deactivated" | "spec_analyzed" | "spec_parsed" | "task_completed" | "task_created" | "task_failed" | "task_updated" | "tool_call_end" | "tool_call_start" | "tool_progress" | "tool_result" | "tool_use" | "user_input">; /** * Events that are considered "standard" audit detail. * These are lightweight and high-value for forensics. */ declare const STANDARD_AUDIT_EVENTS: Set<"agent_error" | "agent_spawned" | "agent_stopped" | "checkpoint" | "compaction" | "context_snapshot" | "error" | "file_event" | "file_observation" | "file_snapshot" | "in_flight_end" | "in_flight_start" | "llm_request" | "llm_response" | "message_appended" | "message_truncated" | "message_updated" | "messages_replaced" | "mode_changed" | "provider_error" | "provider_retry" | "rewound" | "session_end" | "session_forked" | "session_resumed" | "session_start" | "side_effect" | "skill_activated" | "skill_deactivated" | "spec_analyzed" | "spec_parsed" | "task_completed" | "task_created" | "task_failed" | "task_updated" | "tool_call_end" | "tool_call_start" | "tool_progress" | "tool_result" | "tool_use" | "user_input">; /** * Create a safe, audit-level-aware bridge around a SessionWriter. * * The bridge can also apply sampling for high-volume events (e.g. `tool_progress`) * when `auditLevel` is set to `'full'`. * * @example * const bridge = createSessionEventBridge(sessionWriter, 'full', { * sampling: { * toolProgress: { sampleRate: 5 } // more aggressive sampling * } * }); */ export declare function createSessionEventBridge(writer: SessionWriter | (() => SessionWriter | undefined | null) | undefined | null, level?: AuditLevel, options?: SessionEventBridgeOptions): SessionEventBridge; /** Convenience re-export of the allowed core set for tests/docs. */ export { CORE_RECONSTRUCT_EVENTS, STANDARD_AUDIT_EVENTS }; /** * Safely extract the auditLevel from a (possibly partial) Config object. * Falls back to 'standard' if not present or invalid. */ export declare function resolveAuditLevel(cfg?: { session?: { auditLevel?: AuditLevel | undefined; } | undefined; } | null): AuditLevel; /** * Fully resolves the session logging configuration with sensible defaults. * This is the recommended way for the CLI / TUI / WebUI to read session config. */ export declare function resolveSessionLoggingConfig(cfg?: { session?: { auditLevel?: AuditLevel | undefined; sampling?: { toolProgress?: { sampleRate?: number | undefined; }; }; }; } | null): { auditLevel: AuditLevel; sampling: { toolProgress: { sampleRate: number; }; }; }; //# sourceMappingURL=session-event-bridge.d.ts.map