okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
0b3299a01
main
1import type { Hardware } from './types' ; 2 3/** Inventory total only. Placement and fit continue to use separate budgets. */ 4export function memoryInventory ( hardware :Hardware ) { 5const ram = hardware . memory . totalGb ; 6const dedicated = hardware . gpus . filter ( g => ! g . unified && g . backend !== 'cpu' ); 7const vram = dedicated . reduce (( sum , gpu ) => sum + Math . max ( 0 , gpu . vramGb || 0 ), 0 ); 8return { ram, vram, total :ram + vram , shared :hardware . accelerator . unified && ! vram }; 9} 10 11export function memoryReading ( used :number , total :number ){ const safeTotal = Number . isFinite ( total ) ?Math . max ( 0 , total ) :0 ; const safeUsed = Number . isFinite ( used ) ?Math . max ( 0 , used ) :0 ; return { used :Math . min ( safeUsed , safeTotal ), total :safeTotal , free :Math . max ( 0 , safeTotal - safeUsed ), over :Math . max ( 0 , safeUsed - safeTotal )};}