export declare const SESSION = "d365fo-mcp-trace"; export interface CaptureState { file: string; outputDir: string; mode: 'auto' | 'manual'; label?: string; startedAt: string; deadline: string; maxSizeMB: number; /** The server process that started it: instances sharing an index share this state file. */ ownerPid?: number; stoppedAt?: string; stopReason?: 'stop' | 'time limit' | 'size limit or ended outside MCP' | 'server shut down'; } export declare function readState(): CaptureState | undefined; export declare function writeState(state: CaptureState): void; export interface LogmanResult { code: number; output: string; } export declare function logman(args: string[]): Promise; /** * logman refused for lack of ETW rights. Its text is localised ("Access is denied.", * "Accesso negato.") and carries no code, so the exit code decides: 0x80070005, which * Node reports unsigned (2147942405). Measured with a token whose Administrators and * Performance Log Users groups were disabled. */ export declare const accessDenied: (r: LogmanResult) => boolean; export declare function isSessionRunning(): Promise; /** Free bytes on the volume of path (the nearest existing ancestor), or undefined. */ export declare function freeBytes(path: string): number | undefined; export interface DriveList { drives: Array<{ drive: string; freeGB: number; }>; skipped: string[]; } export interface DriveProbe { statfs?: (root: string) => Promise<{ bavail: number | bigint; bsize: number | bigint; }>; clock?: () => number; budgetMs?: number; /** Overrides D365FO_SCAN_DRIVES. */ letters?: string; } /** * Every drive with its free space, for the agent to offer. The same letters and time budget as the * packages-root scan (D365FO_SCAN_DRIVES pins them): a stat on a disconnected mapped network drive * stalls for the SMB timeout, so it runs on the threadpool, never on the event loop (which would stop * the server answering), one letter at a time; the letters left once the budget is spent are skipped * and named rather than waited for. */ export declare function listDrives(probe?: DriveProbe): Promise; /** Size limit for one capture: enough for the time asked (at least 200 MB), never more than the setup allows. */ export declare function sizeLimitMB(seconds: number, maxSizeMB: number): number; export declare const requiredFreeMB: (limitMB: number) => number; export declare function captureFileName(dir: string, label: string | undefined, now?: Date): string; export declare function startCapture(file: string, limitMB: number): Promise; export declare function stopCapture(): Promise; /** Started by this process, or by one that no longer runs (an earlier run of this installation). */ export declare const isOurs: (state: CaptureState) => boolean; /** Stop at the deadline even if nobody calls the tool again. */ export declare function armTimer(state: CaptureState): void; /** * Bring the state file in line with the machine: past its deadline → stop it; no longer * running (size limit reached, stopped by hand) → record that. Returns the current state. */ export declare function settleExpired(): Promise; export declare function clearTimer(): void; /** * Server start: a capture an earlier run of this installation left running gets its timer back, * and one already past its deadline is stopped at once. */ export declare function resumeTimer(): void; /** * Server shutdown: stop the capture this installation started. Without it, a client closed * mid-capture leaves the ETW session writing until the next call to the tool. */ export declare function stopOwnCapture(stop?: () => Promise, running?: () => Promise): Promise; /** * Whether file lies inside dir (case-insensitive, as on Windows). Windows path rules on every * platform: elsewhere "\" is not a separator, so "K:\t\..\a.etl" would stay one name inside dir. */ export declare function isInside(file: string, dir: string): boolean; export declare function captures(dir: string): Array<{ file: string; sizeMB: number; modified: string; }>; export declare const driveOf: (path: string) => string; /** The same file, compared as Windows does (case-insensitive). */ export declare const sameFile: (a: string, b: string) => boolean; /** A drive root (or share root) cannot be the trace folder: analyze and delete are confined to it. */ export declare const isDriveRoot: (dir: string) => boolean; //# sourceMappingURL=capture.d.ts.map