import { readFileSync } from 'node:fs' import { arch, cpus, release, totalmem } from 'node:os' /** The host facts a reader of the results needs to compare devices. */ export function memAvailableBytes() { const info = readFileSync('/proc/meminfo', 'utf8') const match = /^MemAvailable:\s+(\d+) kB$/m.exec(info) return match ? Number(match[1]) * 1024 : null } function cpuModel() { const info = readFileSync('/proc/cpuinfo', 'utf8') return /^model name\s*:\s*(.+)$/m.exec(info)?.[1] ?? cpus()[0]?.model } export function hostFacts() { return { cpuModel: cpuModel(), logicalCpus: cpus().length, ramBytes: totalmem(), memAvailableBytesAtStart: memAvailableBytes(), kernel: release(), arch: arch(), node: process.version, } }