/** * Parsing for `wmic ... /format:csv`. * * Lives in utils because two unrelated tools shell out to wmic and BOTH got the * column mapping wrong in the same way. Splitting it out also means it can be * tested without a Windows host, which matters here: every CI job runs * ubuntu-latest, so these Windows branches had never been executed by a test * even once, which is exactly how both defects survived a green pipeline. * * TWO THINGS MAKE THE NAIVE PARSE WRONG: * * 1. WMIC EMITS COLUMNS ALPHABETICALLY, not in the order requested, and * prepends `Node`. Asking for `ProcessId,Name,CommandLine,HandleCount, * ThreadCount,WorkingSetSize,KernelModeTime,UserModeTime` returns * * Node,CommandLine,HandleCount,KernelModeTime,Name,ProcessId,ThreadCount,UserModeTime,WorkingSetSize * * Indexing by request order is therefore wrong for any field set whose * alphabetical order differs from it -- which is most of them. Measured on a * real table, one caller read `parseInt('explorer.exe')` as the pid (0 for * every process), KernelModeTime as the name, and the hostname as the * command. * * 2. A COMMAND LINE CONTAINS COMMAS -- 119 of 553 rows on one ordinary desktop. * Those rows split into MORE fields than the header, so a `parts.length < n` * guard never catches them; they silently shift every column after * CommandLine. * * The fix for both is to read the header rather than assume it, and to treat * CommandLine as the one variable-width column: everything left of it is * counted from the start, everything right of it from the end, and whatever * remains in the middle is the command line, rejoined. */ /** * Parse WMIC CSV into rows keyed by the header's own column names. * * @param stdout Raw `wmic ... /format:csv` output. * @returns One record per data row; malformed rows are dropped, never guessed at. */ export declare function parseWmicCsvRows(stdout: string): Array>; /** * `yyyymmddHHMMSS.ffffff±UUU` -> epoch milliseconds, or null if unparseable. * * The suffix is an offset in MINUTES from UTC, not hours -- `-240` is UTC-4. */ export declare function parseWmiDate(value: string): number | null; /** * CPU percentage on the same definition `ps aux` uses: CPU time consumed * divided by wall-clock time alive. * * Windows exposes only cumulative counters, so one sample cannot yield an * instantaneous percentage -- but a lifetime average is exactly what ps reports * too, which makes the two platforms comparable rather than merely both * populated. * * NOT clamped to 100. A process spread across many cores accumulates CPU time * faster than wall-clock; ps reports that honestly, and 2,653% for a 64-thread * job is the reading that distinguishes it from a single-threaded one. * * @param cpu100ns Kernel + user time, in 100-nanosecond ticks. * @param creationDate WMI datetime, e.g. `20260719223604.916473-240`. * @param now Epoch ms to measure against; injectable so tests are not clock-dependent. */ export declare function lifetimeCpuPercent(cpu100ns: number, creationDate: string, now: number): number; /** Reads a column as a finite number, or null when it is absent or not numeric. */ export declare function numericField(row: Record, column: string): number | null; //# sourceMappingURL=wmic-csv.d.ts.map