import type { LogEntry, LogFile, TailLogsResult } from '@salesforce/b2c-tooling-sdk/operations/logs'; import type { ToolExecutionContext } from '../adapter.js'; /** Maximum number of buffered entries before oldest are evicted. */ export declare const DEFAULT_BUFFER_CAP = 5000; /** * Maximum cumulative bytes buffered before oldest entries are evicted. * Guards against a small number of pathologically large entries (e.g. multi-MB * stack traces) blowing past the count cap's intended memory bound. */ export declare const DEFAULT_BUFFER_BYTES_CAP: number; export interface PollWaiter { resolve: () => void; timer: ReturnType; } export interface LogWatchEntry { watchId: string; hostname: string; prefixes: string[]; buffer: LogEntry[]; /** Running byte size of `buffer` (raw + message), used for the byte cap. */ bufferBytes: number; rotations: LogFile[]; /** Cumulative deduped list of every file ever discovered (for logs_watch_list). */ filesDiscovered: LogFile[]; /** Files discovered since the last poll drain (what logs_watch_poll returns). */ pendingFilesDiscovered: LogFile[]; errors: Array<{ message: string; at: string; }>; totalEntriesSeen: number; droppedEntries: number; bufferCap: number; bufferBytesCap: number; stop: () => Promise; done: Promise; pollWaiters: PollWaiter[]; createdAt: number; lastActivityAt: number; stopped: boolean; } export interface RegisterWatchOptions { hostname: string; prefixes: string[]; tailResult: TailLogsResult; bufferCap?: number; bufferBytesCap?: number; } export declare class LogWatchRegistry { private cleanupTimer; private readonly watches; constructor(); /** * Append a log entry to a watch buffer. Evicts oldest if over cap. * Resolves any pending poll waiters. */ appendEntry(watchId: string, entry: LogEntry): void; appendError(watchId: string, err: Error): void; /** * Append a discovered file (deduped by name). */ appendFileDiscovered(watchId: string, file: LogFile): void; appendRotation(watchId: string, file: LogFile): void; destroyAll(): Promise; destroyWatch(watchId: string): Promise; /** * Drain buffered entries (up to maxEntries) and any rotation/error events * from the watch. Removes drained items from the underlying buffers. */ drain(watchId: string, maxEntries: number): { entries: LogEntry[]; errors: Array<{ message: string; at: string; }>; filesDiscovered: LogFile[]; rotations: LogFile[]; truncated: boolean; }; findByHostname(hostname: string): LogWatchEntry | undefined; getWatch(watchId: string): LogWatchEntry | undefined; getWatchOrThrow(watchId: string): LogWatchEntry; listWatches(): LogWatchEntry[]; registerWatch(opts: RegisterWatchOptions): LogWatchEntry; /** * Wait until at least one entry is buffered (or rotation/error event), or until * timeout elapses. Returns immediately if the buffer is non-empty. */ waitForActivity(watchId: string, timeoutMs: number): Promise; private cleanupIdleWatches; private flushWaiters; } export declare function getLogWatchRegistry(context: ToolExecutionContext): LogWatchRegistry; export declare function getLogWatchEntry(context: ToolExecutionContext, watchId: string): LogWatchEntry;