()
| 43 | |
| 44 | /** The single public entry point. */ |
| 45 | export function detectHardware(): HardwareProfile { |
| 46 | const platform = os.platform(); |
| 47 | const osKind: HardwareProfile['os'] = |
| 48 | platform === 'darwin' ? 'macos' : |
| 49 | platform === 'linux' ? 'linux' : |
| 50 | platform === 'win32' ? 'windows' : 'other'; |
| 51 | const arch: HardwareProfile['arch'] = |
| 52 | os.arch() === 'arm64' ? 'arm64' : |
| 53 | os.arch() === 'x64' ? 'x64' : 'other'; |
| 54 | const appleSilicon = osKind === 'macos' && arch === 'arm64'; |
| 55 | |
| 56 | const ramGb = Math.round(os.totalmem() / 1024 / 1024 / 1024); |
| 57 | const cpuCores = os.cpus().length; |
| 58 | const cpuLabel = detectCpuLabel(osKind); |
| 59 | const gpu = detectGpu(osKind, appleSilicon, ramGb); |
| 60 | const diskFreeGb = detectFreeDisk(osKind); |
| 61 | const tier = chooseTier(ramGb, gpu); |
| 62 | const recommendedModels = recommendModels(tier, appleSilicon); |
| 63 | |
| 64 | return { |
| 65 | os: osKind, arch, appleSilicon, |
| 66 | cpuLabel, cpuCores, ramGb, |
| 67 | gpu, diskFreeGb, |
| 68 | tier, recommendedModels, |
| 69 | }; |
| 70 | } |
| 71 | |
| 72 | // ── CPU label ──────────────────────────────────────────────────────────────── |
| 73 |
no test coverage detected