/** * Serial Monitor Spooler Daemon * Background persistence for serial logs. * * Provides: * - startMonitor: Initiates an asynchronous serial hook directly to disk. * - stopMonitor: Safely kills the daemon and unlocks the port. * - queryLogs: Pulls historical/grep'd records from the spool buffer safely. */ import fs from "node:fs"; import { type TargetBinding } from "../core/target-resolution.js"; /** * State and context mapping for an actively spooled hardware port. */ type DaemonContext = { baudRate: number; environment?: string; hwid: string | null; logFile: string; fileOffset?: number; watcher?: fs.FSWatcher; poller?: ReturnType; taskId?: string; projectDir?: string; startedAt: string; lastActivityAt?: string; }; export declare function getSpoolerStates(): Record>; /** * Clears outdated serial traces beyond the rotation limit to prevent disk bloat. * * @param maxHistory - Maximum total bounded files to retain. */ /** * Safely stops an active monitor daemon session and unlocks its port. * * @param port - The serial COM port to terminate polling on. * @param projectDir - Optional project directory context. */ export declare function stopMonitor(port: string, projectDir?: string): Promise; /** * Binds to a specified UART interface and autonomously pushes data into the * persistence pipeline locally to the project workspace. */ /** * Re-attaches UI streaming for any active monitors orphaned by a server crash. */ export declare function rehydrateMonitors(): Promise; export declare function startMonitor(port?: string, baud?: number, projectDir?: string, environment?: string, rootCommandId?: string): Promise<{ success: boolean; port: string; logFile: string; taskId: `${string}-${string}-${string}-${string}-${string}`; startedAt: string; }>; /** * Tool for agents to scan historical offline device payloads. */ export declare function queryLogs(lines?: number, searchPattern?: string, taskId?: string, logPath?: string, projectDir?: string, port?: string): Promise<{ success: boolean; content: string; }>; /** Stable status details for one serial monitor. */ export interface MonitorStatusResult { state: "active" | "inactive" | "stale"; port?: string; baudRate?: number; environment?: string; projectDir?: string; taskId?: string; leaseOwner?: string; logPath?: string; cursor?: string; startedAt?: string; lastActivityAt?: string; } /** * Returns active, inactive, or stale monitor state without changing hardware. * * @param port - Optional exact port selector. * @param projectDir - Optional project scope. * @returns One status record when selected, otherwise all matching records. */ export declare function getMonitorStatus(port?: string, projectDir?: string): MonitorStatusResult | { monitors: MonitorStatusResult[]; }; /** Structured result from one bounded serial monitor capture. */ export interface SerialWindowResult { success: true; port: string; projectDir: string; content: string; bytes: number; cursor: string; cursorExpired: false; truncated: boolean; logPath: string; taskId?: string; startedMonitor: boolean; capturedAt: string; } /** * Reads one bounded byte range from an existing monitor log. * * @param logPath - Exact active monitor log path. * @param options - Cursor, explicit starting offset, and byte ceiling. * @returns Redacted content, cursor, and truncation metadata. */ export declare function readSerialWindowFromFile(logPath: string, options?: { cursor?: string; startOffset?: number; maxBytes?: number; }): { content: string; bytes: number; cursor: string; truncated: boolean; finalSize: number; }; /** * Acquires a bounded read lease, captures incremental serial bytes, and cleans up. * * @param input - Port, duration, cursor, and output bounds. * @returns Redacted incremental serial evidence and a new cursor. */ export declare function captureSerialWindow(input: { projectDir: string; port?: string; environment?: string; baudRate?: number; durationSeconds?: number; maxBytes?: number; cursor?: string; targetBinding?: TargetBinding; }): Promise; export {}; //# sourceMappingURL=monitor.d.ts.map